diff --git a/Dockerfile b/Dockerfile index aa3aa7b4334bd67b141b788834f70503c31a8bbe..66c87018fe661d596fac5a85559ea85dc7080f0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ ############################################################################### -# STARRY HuggingFace Space — Lightweight Deployment +# STARRY HuggingFace Space — Full Deployment with ML Predictors (CPU mode) # nginx (reverse proxy) + omr-service (Fastify) + cluster-server (NestJS) -# No ML predictors — prediction features are disabled +# + 7 Python ML predictors via supervisord (layout, gauge, mask, semantic, +# loc, ocr, brackets) ############################################################################### FROM node:20-slim @@ -13,13 +14,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ postgresql postgresql-client \ nginx \ tini \ - python3 make g++ pkg-config \ + python3 python3-pip make g++ pkg-config \ libzmq3-dev libfontconfig1 curl \ + supervisor \ && rm -rf /var/lib/apt/lists/* # Install tsx globally RUN npm install -g tsx +# --- Python ML deps (CPU-only PyTorch + TensorFlow) --- +RUN pip install --no-cache-dir --break-system-packages \ + "numpy>=1.26.0,<2.0.0" \ + torch torchvision \ + --index-url https://download.pytorch.org/whl/cpu + +RUN pip install --no-cache-dir --break-system-packages \ + "numpy>=1.26.0,<2.0.0" \ + tensorflow-cpu \ + tf_keras \ + "opencv-python-headless<4.11" \ + Pillow>=8.0.0 \ + PyYAML>=5.4.0 \ + pyzmq>=22.0.0 \ + msgpack>=1.0.0 + +ENV TF_USE_LEGACY_KERAS=1 +ENV PYTHONUNBUFFERED=1 + # --- node user already has UID 1000 in node:20-slim --- # Ensure home directory exists RUN mkdir -p /home/node && chown node:node /home/node @@ -88,13 +109,20 @@ RUN ln -sf /home/node/app/backend/omr-service/node_modules /home/node/app/backen # --- Root tsconfig --- COPY --chown=node tsconfig.json ./ +# --- Python ML services --- +COPY --chown=node backend/python-services/ ./backend/python-services/ + +# --- Supervisord config --- +COPY --chown=node supervisord.conf ./supervisord.conf + # --- Config files --- COPY --chown=node docker-entrypoint.sh ./docker-entrypoint.sh COPY --chown=node nginx.conf /etc/nginx/nginx.conf RUN chmod +x docker-entrypoint.sh # Directories -RUN mkdir -p /tmp/starry-uploads && chown node:node /tmp/starry-uploads +RUN mkdir -p /tmp/starry-uploads /home/node/log/supervisor /home/node/run /home/node/app/models \ + && chown -R node:node /tmp/starry-uploads /home/node/log /home/node/run /home/node/app/models USER node diff --git a/backend/libs/PyProcessor.ts b/backend/libs/PyProcessor.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b37af8cc08942d2ef0c36606e0d0f59f3879e09 --- /dev/null +++ b/backend/libs/PyProcessor.ts @@ -0,0 +1,58 @@ +import { getPortPromise } from 'portfinder'; +import { Options, PythonShell } from 'python-shell'; +import { defaultsDeep } from 'lodash'; +import ZeroClient, { Logger } from './ZeroClient'; + +export default class PyProcessor extends ZeroClient { + private readonly scriptPath: string; + private readonly options: Options; + private pyShell: PythonShell; + + private retryCount: number = 0; + private retryDelay: number = 3000; + + constructor(scriptPath: string, options: Options = {}, logger: Logger = console) { + super(logger); + this.scriptPath = scriptPath; + this.options = options; + } + + async bind(port?: string | number) { + const freePort = + port || + (await getPortPromise({ + port: 12022, + stopPort: 12122, + })); + + // "./streamPredictor.py", "--inspect" + const options = defaultsDeep( + { + args: [...(this.options.args || []), '-p', `${freePort}`], + }, + this.options + ); + + this.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`); + + this.pyShell = new PythonShell(this.scriptPath, options); + + this.pyShell.stdout.on('data', (data) => this.logger.info(data)); + + this.pyShell.on('pythonError', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`, err)); + this.pyShell.on('stderr', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`, err)); + this.pyShell.on('error', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} error:`, err)); + this.pyShell.on('close', () => { + // python子进程关闭事件 + if (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:${freePort}`); + } +} diff --git a/backend/libs/ZeroClient.ts b/backend/libs/ZeroClient.ts new file mode 100644 index 0000000000000000000000000000000000000000..15f3ba6a73b26aa5253bb7c04d958d148c97432d --- /dev/null +++ b/backend/libs/ZeroClient.ts @@ -0,0 +1,85 @@ +import { pack, unpack } from 'msgpackr'; +import { Request } from 'zeromq'; +import { AsyncQueue } from './async-queue'; + +interface Response { + code: number; + msg: string; + data?: any; +} + +export interface Logger { + info: (...data: any[]) => void; + error: (...data: any[]) => void; +} + +type PyArgs = any[]; +type PyKwargs = Record; + +export default class ZeroClient { + logger: Logger; + private socket: Request; + private queue: AsyncQueue = new AsyncQueue(); + + private url: string; + + constructor(logger: Logger = console) { + this.logger = logger; + } + + bind(url?: string) { + url && (this.url = url); + this.socket = new Request({ + sendTimeout: 15e3, + receiveTimeout: 300e3, + }); + + this.socket.connect(this.url); + } + + private __request(payload) { + let retryTimes = 0; + + const req = async (data) => { + try { + if (this.socket.closed) this.bind(); + return await this.socket.send(pack(data)).then(() => this.socket.receive()); + } catch (err) { + if (retryTimes < 2) { + retryTimes++; + console.log(`请求失败,${err.stack}`); + console.error(`3s后重试第${retryTimes}次`); + this.socket.close(); + await new Promise((resolve) => setTimeout(resolve, 3000)); + return req(data); + } else { + throw err; + } + } + }; + + return req(payload); + } + + async request(method: string, args: PyArgs | PyKwargs = null, kwargs: PyKwargs = null): Promise { + const [args_, kwargs_] = Array.isArray(args) ? [args, kwargs] : [undefined, args]; + const msg: any = { method }; + if (args_) msg.args = args_; + if (kwargs_) msg.kwargs = kwargs_; + + return this.queue.addTask([ + async (opt) => { + const [result] = await this.__request(opt); + + const obj = unpack(result) as Response; + + if (obj.code === 0) { + return obj.data; + } else { + return Promise.reject(obj.msg); + } + }, + msg, + ]); + } +} diff --git a/backend/libs/adminSolutionStore.ts b/backend/libs/adminSolutionStore.ts new file mode 100644 index 0000000000000000000000000000000000000000..7992554c9d17619972285095a1964d9fdab8f01d --- /dev/null +++ b/backend/libs/adminSolutionStore.ts @@ -0,0 +1,95 @@ +import { SolutionStore } from './store'; +import { RegulationSolution } from '../../src/starry'; +import getSign from '../../src/utils/request/createSign'; +import * as asyncAtom from '../../src/utils/asyncAtom'; + +const getHeaders = (method: string = 'get', data: any = {}): Record => { + const headers = { + stmp: Date.now(), + sess: '654a591de5d3a4b0', + ver: 512, + orn: '(X11;$Linux x86_64$android$1.0.0$torchTrain', + sign: '', + size: 0, + dst: '', + type: 1, + lang: 'zh_CN', + seq: 0, + code: 0, + ext: 'CN', + desc: '', + } as any; + headers.sign = getSign({ method, data, requestHeader: headers }); + + return headers; +}; + +export default class AdminSolutionStore implements SolutionStore { + env: string; + host: string; + fetch: typeof fetch; + + constructor(options: { env: string; host: string; fetch: typeof fetch }) { + Object.assign(this, options); + } + + post(path, { data }: any): Promise { + const headers = getHeaders('post', data); + headers['content-type'] = 'application/json;charset=UTF-8'; + + return this.fetch(this.host + path, { + method: 'post', + headers, + body: JSON.stringify(data), + }).then((res) => res.json()); + } + + async batchGet(keys: string[]): Promise { + const solutions = ( + await this.post('/torch/musicSet/manage/cache/batchGet', { + data: { + env: this.env, + nameList: keys, + }, + }) + ).data as RegulationSolution[]; + //console.log('AdminSolutionStore.batchGet:', solutions); + + return Promise.all(solutions); + } + + async get(key: string): Promise { + const solution = (await this.post('/torch/musicSet/manage/cache/batchGet', { + data: { + env: this.env, + nameList: [key], + }, + }).then((res) => res.data[0])) as RegulationSolution; + //console.log('AdminSolutionStore.get:', key, solution); + + return solution; + } + + async set(key: string, value: RegulationSolution) { + const request = () => + this.post('/torch/musicSet/manage/cache/set', { + data: { + env: this.env, + name: key, + value: value, + }, + }).catch((err) => console.warn('failed to set solution:', key, err)); + asyncAtom.queue(this, request); + + //console.log('AdminSolutionStore.set:', key, res.ok); + } + + /*remove(key: string) { + return request.post('/torch/musicSet/manage/cache/delete', { + data: { + env: this.env, + name: key, + }, + }); + }*/ +} diff --git a/backend/libs/async-queue.ts b/backend/libs/async-queue.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4b446bc159c5438604285eee7268cc80b38cf7a --- /dev/null +++ b/backend/libs/async-queue.ts @@ -0,0 +1,72 @@ +import { EventEmitter } from 'events'; + +interface DSPromiseOption { + timeout?: number; +} + +export function destructPromise( + options: DSPromiseOption = {} +): [promise: Promise, resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void] { + const { timeout } = options; + let rs: (value: T | PromiseLike) => void; + let rj: (reason: any) => void; + + return [ + new Promise((resolve, reject) => { + rs = resolve; + rj = reject; + + if (timeout >= 0) setTimeout(rj, timeout, 'timeout'); + }), + rs, + rj, + ]; +} + +type AsyncTask = [fn: (data: any) => Promise, payload: any, resolve: (data: any) => void, reject: (reason: any) => void]; + +export class AsyncQueue extends EventEmitter { + private working = false; + + tasks: AsyncTask[]; + + constructor() { + super(); + this.working = false; + this.tasks = []; + process.nextTick(() => { + this.emit('idle'); + }); + } + + private async _digest(item: AsyncTask) { + this.working = true; + + const [taskFn, payload, resolve, reject] = item; + await taskFn(payload).then(resolve, reject); + + if (this.tasks.length > 0) { + await this._digest(this.tasks.shift()); + } else { + this.working = false; + this.emit('idle'); + } + } + + /** + * 添加队列任务 + * @param task + * @param options + */ + addTask(task: [AsyncTask[0], AsyncTask[1]], { timeout = 600000 }: { timeout?: number } = {}): Promise { + const [promise, resolve, reject] = destructPromise({ timeout }); + + if (this.working) { + this.tasks.push([...task, resolve, reject]); + } else { + this._digest([...task, resolve, reject]); + } + + return promise; + } +} diff --git a/backend/libs/beadPicker.ts b/backend/libs/beadPicker.ts new file mode 100644 index 0000000000000000000000000000000000000000..3988f2b74a7caf18ca84b3c0c6c39ea046491b43 --- /dev/null +++ b/backend/libs/beadPicker.ts @@ -0,0 +1,22 @@ +import * as starry from '../../src/starry'; +import OnnxBeadPicker from '../../src/utils/onnxBeadPicker'; + +const loadBeadPickers = (path: string, seqs: number[] = [32, 64, 128, 512]): Promise => { + return Promise.all( + seqs.map(async (n_seq) => { + let loading: any; + + const url = path.replace(/seq\d+/, `seq${n_seq}`); + const picker = new OnnxBeadPicker(url, { + n_seq, + usePivotX: true, + onLoad: (p) => (loading = p), + }); + await loading; + + return picker; + }) + ); +}; + +export { loadBeadPickers }; diff --git a/backend/libs/browserComponents.ts b/backend/libs/browserComponents.ts new file mode 100644 index 0000000000000000000000000000000000000000..45870d596b3ab83f4e41067c1f7228f7484e6783 --- /dev/null +++ b/backend/libs/browserComponents.ts @@ -0,0 +1,2 @@ +globalThis.btoa = (str) => Buffer.from(str, 'binary').toString('base64'); +globalThis.atob = (str) => Buffer.from(str, 'base64').toString('binary'); diff --git a/backend/libs/gauge-renderer-three.ts b/backend/libs/gauge-renderer-three.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f82379dc136f5d7ca111f37abffbd8acbeaf7bf --- /dev/null +++ b/backend/libs/gauge-renderer-three.ts @@ -0,0 +1,161 @@ +import { Canvas, loadImage } from 'skia-canvas'; +import * as THREE from './three/Three'; +import gl from 'gl'; + +// threejs内部使用了OffscreenCanvas +(globalThis as any).OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas; + +const cc = (a: T[][]): T[] => { + const result: T[] = []; + for (const x of a) { + for (const e of x) result.push(e); + } + + return result; +}; + +class GLCanvas { + ctx: ReturnType; + width: number = 256; + height: number = 192; + + resizeBuffer: number[]; + + constructor(width: number, height: number) { + this.width = width; + this.height = height; + } + + getContext(type, options) { + if (type === 'webgl') { + this.ctx = this.ctx || gl(this.width, this.height, options); + + return this.ctx; + } + + return null as WebGLRenderingContext; + } + + addEventListener(evt: 'webglcontextlost') {} + + removeEventListener(evt: any) {} + + async toBuffer() { + const pixels = new Uint8Array(this.width * this.height * 4); + this.ctx.readPixels(0, 0, this.width, this.height, this.ctx.RGBA, this.ctx.UNSIGNED_BYTE, pixels); + + const canvas = new Canvas(this.width, this.height); + const ctx = canvas.getContext('2d'); + ctx.putImageData({ data: new Uint8ClampedArray(pixels), width: this.width, height: this.height }, 0, 0); + + return canvas.toBuffer('png'); + } +} + +export const renderGaugeImage = async (sourceURL: string | Buffer, gaugeURL: string | Buffer, baseY: number) => { + const source = await loadImage(sourceURL); + const gauge = await loadImage(gaugeURL); + const { width: gaugeWidth, height: gaugeHeight } = gauge; + const { width: srcWidth, height: srcHeight } = source; + + let width: number = 256; + let height: number = 192; + + if (width !== srcWidth || height !== srcHeight) { + if (Number.isFinite(gaugeWidth)) { + width = gaugeWidth; + } else { + width = Math.round((height * srcWidth) / srcHeight); + } + } + + const camera = new THREE.OrthographicCamera(width / -2, width / 2, height / 2, height / -2, 0.1, 10); + camera.position.set(0, 0, 1); + camera.up.set(0, 1, 0); + camera.lookAt(0, 0, 0); + + const ctx = new Canvas(gaugeWidth, gaugeHeight).getContext('2d'); + ctx.drawImage(gauge, 0, 0); + const { data: buff } = ctx.getImageData(0, 0, gaugeWidth, gaugeHeight); + + const xFactor = width / gaugeWidth; + + baseY = Math.round(Number.isFinite(baseY) ? baseY : gaugeHeight / 2); + baseY = Math.max(0, Math.min(gaugeHeight - 1, baseY)); + + const propertyArray = Array(gaugeHeight) + .fill(null) + .map((_, y) => + Array(gaugeWidth) + .fill(null) + .map((_, x) => ({ + uv: [(x + 0.5) / gaugeWidth, 1 - (y + 0.5) / gaugeHeight], + position: [(x - gaugeWidth / 2) * xFactor, (buff[(y * gaugeWidth + x) * 4] + buff[(y * gaugeWidth + x) * 4 + 2] / 256 - 128) / xFactor, 0], + })) + ); + + // integral X by K + for (let y = baseY; y > 0; --y) { + for (let x = 0; x < gaugeWidth; ++x) + propertyArray[y - 1][x].position[0] = propertyArray[y][x].position[0] - ((buff[(y * gaugeWidth + x) * 4 + 1] - 128) * xFactor) / 127; + } + for (let y = baseY + 1; y < gaugeHeight; ++y) { + for (let x = 0; x < gaugeWidth; ++x) + propertyArray[y][x].position[0] = propertyArray[y - 1][x].position[0] + ((buff[((y - 1) * gaugeWidth + x) * 4 + 1] - 128) * xFactor) / 127; + } + + const uvs = cc(cc(propertyArray).map((p) => p.uv)); + const positions = cc(cc(propertyArray).map((p) => p.position)); + + const geometry = new THREE.BufferGeometry(); + geometry.setAttribute('uv', new THREE.Float32BufferAttribute(uvs, 2)); + geometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3)); + + const faces = Array(gaugeHeight - 1) + .fill(null) + .map((_, y) => + Array(gaugeWidth - 1) + .fill(null) + .map((_, x) => [ + y * gaugeWidth + x, + y * gaugeWidth + x + 1, + (y + 1) * gaugeWidth + x, + (y + 1) * gaugeWidth + x, + (y + 1) * gaugeWidth + x + 1, + y * gaugeWidth + x + 1, + ]) + ); + const indices = cc(cc(faces)); + geometry.setIndex(indices); + + const material = new THREE.MeshBasicMaterial({ + side: THREE.DoubleSide, + map: new THREE.Texture(source), + }); + material.map.needsUpdate = true; + material.needsUpdate = true; + + const scene = new THREE.Scene(); + const plane = new THREE.Mesh(geometry, material); + scene.add(plane); + + const glCanvas = new GLCanvas(width, height); + + const renderer = new THREE.WebGLRenderer({ + antialias: true, + canvas: glCanvas as any, + alpha: false, + }); + + renderer.render(scene, camera); + + renderer.dispose(); + + return { + buffer: await glCanvas.toBuffer(), + size: { + width, + height, + }, + }; +}; diff --git a/backend/libs/predictJianpuPages.ts b/backend/libs/predictJianpuPages.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec7e5b9f4c5c61bec1999ead36b5ce1a98eab9ce --- /dev/null +++ b/backend/libs/predictJianpuPages.ts @@ -0,0 +1,443 @@ +import { Canvas, Image, loadImage } from 'skia-canvas'; +import sha1 from 'sha1'; +import { WeakLRUCache } from 'weak-lru-cache'; +import * as starry from '../../src/starry'; +import { LayoutResult, PyClients } from './predictors'; +import { constructSystem, convertImage } from './util'; +import { SemanticGraph } from '../../src/starry'; + +globalThis.OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas; +globalThis.Image = globalThis.Image || Image; +globalThis.btoa = globalThis.btoa || ((str: string) => Buffer.from(str, 'binary').toString('base64')); + +const STAFF_PADDING_LEFT = 32; + +const MAX_PAGE_WIDTH = 1200; + +const GAUGE_VISION_SPEC = { + viewportHeight: 256, + viewportUnit: 8, +}; + +const MASK_VISION_SPEC = { + viewportHeight: 192, + viewportUnit: 8, +}; + +const SEMANTIC_VISION_SPEC = { + viewportHeight: 192, + viewportUnit: 8, +}; + +interface OMRStat { + cost: number; // in milliseconds + pagesCost: number; // in milliseconds + pages: number; +} + +interface OMRSummary { + costTotal: number; // in milliseconds + costPerPage: number; // in milliseconds + pagesTotal: number; + scoreN: number; +} + +/** + * 为布局识别的图片标准化处理 + * @param image + * @param width + */ +function scaleForLayout(image: Image, width: number): Canvas { + let height = (image.height / image.width) * width; + + const canvas = new Canvas(width, height); + const ctx = canvas.getContext('2d'); + + ctx.drawImage(image, 0, 0, width, (width * image.height) / image.width); + + return canvas; +} + +/** + * 根据所有图像的检测结果设置合适的全局页面尺寸 + * @param score + * @param detections + * @param outputWidth + */ +function setGlobalPageSize(score: starry.Score, detections: LayoutResult[], outputWidth: number) { + const sizeRatios = detections + .filter((s) => s && s.detection) + .map((v, k) => { + const staffInterval = Math.min(...v.detection.areas.filter((area) => area.staves?.middleRhos?.length).map((x) => x.staves.interval)); + + const sourceSize = v.sourceSize; + return { + ...v, + index: k, + vw: sourceSize.width / staffInterval, // 页面宽度(逻辑单位) + hwr: sourceSize.height / sourceSize.width, // 页面高宽比 + }; + }); + + if (!sizeRatios.length) { + throw new Error('empty result'); + } + + const maxVW = sizeRatios.sort((a, b) => b.vw - a.vw)[0]; + const maxAspect = Math.max(...sizeRatios.map((r) => r.hwr)); + + score.unitSize = outputWidth / maxVW.vw; + + // 页面显示尺寸 + score.pageSize = { + width: outputWidth, + height: outputWidth * maxAspect, + }; +} + +const batchTask = (fn: () => Promise) => fn(); +const concurrencyTask = (fns: (() => Promise)[]) => Promise.all(fns.map((fn) => fn())); + +const shootStaffImage = async ( + system: starry.System, + staffIndex: number, + { paddingLeft = 0, scaling = 1, spec }: { paddingLeft?: number; scaling?: number; spec: { viewportHeight: number; viewportUnit: number } } +): Promise => { + if (!system || !system.backgroundImage) return null; + + const staff = system.staves[staffIndex]; + if (!staff) return null; + + const middleUnits = spec.viewportHeight / spec.viewportUnit / 2; + + const width = system.imagePosition.width * spec.viewportUnit; + const height = system.imagePosition.height * spec.viewportUnit; + const x = system.imagePosition.x * spec.viewportUnit + paddingLeft; + const y = (system.imagePosition.y - (staff.top + staff.staffY - middleUnits)) * spec.viewportUnit; + + const canvas = new Canvas(Math.round(width + x) * scaling, spec.viewportHeight * scaling); + const context = canvas.getContext('2d'); + context.fillStyle = 'white'; + context.fillRect(0, 0, canvas.width, canvas.height); + context.drawImage(await loadImage(system.backgroundImage), x * scaling, y * scaling, width * scaling, height * scaling); + + return canvas; + // .substr(22); // remove the prefix of 'data:image/png;base64,' +}; + +/** + * 根据布局检测结果进行截图 + * @param score + * @param pageCanvas + * @param page + * @param detection + */ +async function shootImageByDetection({ + page, + score, + pageCanvas, +}: { + score: starry.Score; + page: starry.Page; + pageCanvas: Canvas; // 原始图片绘制好的canvas +}) { + if (!page?.layout?.areas?.length) { + return null; + } + + page.width = score.pageSize.width / score.unitSize; + page.height = score.pageSize.height / score.unitSize; + + const correctCanvas = new Canvas(pageCanvas.width, pageCanvas.height); + const ctx = correctCanvas.getContext('2d'); + + ctx.save(); + + const { width, height } = correctCanvas; + const [a, b, c, d] = page.source.matrix; + + ctx.setTransform(a, b, c, d, (-1 / 2) * width + (1 / 2) * a * width + (1 / 2) * b * height, (-1 / 2) * height + (1 / 2) * c * width + (1 / 2) * d * height); + + ctx.drawImage(pageCanvas, 0, 0); + + ctx.restore(); + + const interval = page.source.interval; + + page.layout.areas.map((area, systemIndex) => { + console.assert(area.staves?.middleRhos?.length, '[shootImageByDetection] empty area:', area); + + const data = ctx.getImageData(area.x, area.y, area.width, area.height); + + const canvas = new Canvas(area.width, area.height); + + const context = canvas.getContext('2d'); + // context.rotate(-area.staves.theta); + context.putImageData(data, 0, 0); + + const detection = area.staves; + const size = { width: area.width, height: area.height }; + + const sourceCenter = { + x: pageCanvas.width / 2 / interval, + y: pageCanvas.height / 2 / interval, + }; + + const position = { + x: (area.x + area.staves.phi1) / interval - sourceCenter.x + page.width / 2, + y: area.y / interval - sourceCenter.y + page.height / 2, + }; + + page.systems[systemIndex] = constructSystem({ + page, + backgroundImage: canvas.toBufferSync('png'), + detection, + imageSize: size, + position, + }); + }); + + return correctCanvas; +} + +async function shootStaffBackgroundImage({ system, staff, staffIndex }: { system: starry.System; staff: starry.Staff; staffIndex: number }) { + const sourceCanvas = await shootStaffImage(system, staffIndex, { + paddingLeft: STAFF_PADDING_LEFT, + spec: SEMANTIC_VISION_SPEC, + }); + + staff.backgroundImage = sourceCanvas.toBufferSync('png'); + + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, + y: staff.staffY - SEMANTIC_VISION_SPEC.viewportHeight / 2 / SEMANTIC_VISION_SPEC.viewportUnit, + width: sourceCanvas.width / SEMANTIC_VISION_SPEC.viewportUnit, + height: sourceCanvas.height / SEMANTIC_VISION_SPEC.viewportUnit, + }; +} + +/** + * 单个staff的变形矫正 + * @param system + * @param staff + * @param staffIndex + * @param gaugeImage + * @param pyClients + */ +async function gaugeStaff({ + system, + staff, + staffIndex, + gaugeImage, + pyClients, +}: { + system: starry.System; + staff: starry.Staff; + staffIndex: number; + gaugeImage: Buffer; + pyClients: PyClients; +}) { + const sourceCanvas = await shootStaffImage(system, staffIndex, { + paddingLeft: STAFF_PADDING_LEFT, + spec: GAUGE_VISION_SPEC, + scaling: 2, + }); + + const sourceBuffer = sourceCanvas.toBufferSync('png'); + + const baseY = (system.middleY - (staff.top + staff.staffY)) * GAUGE_VISION_SPEC.viewportUnit + GAUGE_VISION_SPEC.viewportHeight / 2; + + const { buffer, size } = await pyClients.predictScoreImages('gaugeRenderer', [sourceBuffer, gaugeImage, baseY]); + + staff.backgroundImage = buffer; + + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / GAUGE_VISION_SPEC.viewportUnit, + y: staff.staffY - GAUGE_VISION_SPEC.viewportHeight / 2 / GAUGE_VISION_SPEC.viewportUnit, + width: size.width / GAUGE_VISION_SPEC.viewportUnit, + height: size.height / GAUGE_VISION_SPEC.viewportUnit, + }; + + staff.maskImage = null; +} + +/** + * 单个staff的降噪 + * @param staff + * @param staffIndex + * @param maskImage + */ +async function maskStaff({ staff, staffIndex, maskImage }: { staff: starry.Staff; staffIndex: number; maskImage: Buffer }) { + const img = await loadImage(maskImage); + + staff.maskImage = maskImage; + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / MASK_VISION_SPEC.viewportUnit, + y: staff.staffY - MASK_VISION_SPEC.viewportHeight / 2 / MASK_VISION_SPEC.viewportUnit, + width: img.width / MASK_VISION_SPEC.viewportUnit, + height: img.height / MASK_VISION_SPEC.viewportUnit, + }; +} + +/** + * 单个staff的语义识别 + * @param score + * @param staffIndex + * @param system + * @param staff + * @param graph + */ +async function semanticStaff({ + score, + staffIndex, + system, + staff, + graph, +}: { + score: starry.Score; + staffIndex: number; + system: starry.System; + staff: starry.Staff; + graph: SemanticGraph; +}) { + graph.offset(-STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, 0); + + system.assignSemantics(staffIndex, graph); + + staff.assignSemantics(graph); + staff.clearPredictedTokens(); + + score.assembleSystem(system, score.settings?.semanticConfidenceThreshold || 1); +} + +function replacePageImages(page: starry.Page, onReplaceImageKey: (src: string) => any) { + const tasks = [ + [page.source, 'url'], + ...page.systems + .map((system) => { + return [ + [system, 'backgroundImage'], + ...system.staves + .map((staff) => [ + [staff, 'backgroundImage'], + [staff, 'maskImage'], + ]) + .flat(), + ]; + }) + .flat(), + ]; + + tasks.map(([target, key]: [any, string]) => { + target[key] = onReplaceImageKey(target[key]); + }); +} + +export type TaskProgress = { total?: number; finished?: number }; + +export interface OMRPage { + url: string | Buffer; + key?: string; + layout?: LayoutResult; + renew?: boolean; + enableGauge?: boolean; +} + +export interface ProgressState { + layout?: TaskProgress; + text?: TaskProgress; + gauge?: TaskProgress; + mask?: TaskProgress; + semantic?: TaskProgress; + regulate?: TaskProgress; + brackets?: TaskProgress; +} + +class OMRProgress { + state: ProgressState = {}; + + onChange: (evt: ProgressState) => void; + + constructor(onChange: (evt: ProgressState) => void) { + this.onChange = onChange; + } + + setTotal(stage: keyof ProgressState, total: number) { + this.state[stage] = this.state[stage] || { + total, + finished: 0, + }; + } + + increase(stage: keyof ProgressState, step = 1) { + const info: TaskProgress = this.state[stage] || { + finished: 0, + }; + info.finished += step; + + this.onChange(this.state); + } +} + +type SourceImage = string | Buffer; + +export interface OMROption { + outputWidth?: number; + title?: string; // 曲谱标题 + pageStore?: { + has?: (key: string) => Promise; + get: (key: string) => Promise; + set: (key: string, val: string) => Promise; + }; + renew?: boolean; + processes?: (keyof ProgressState)[]; // 选择流程 + onProgress?: (progress: ProgressState) => void; + onReplaceImage?: (src: SourceImage) => Promise; // 替换所有图片地址,用于上传或者格式转换 +} + +const lruCache = new WeakLRUCache(); + +// 默认store +const pageStore = { + async get(key: string) { + return lruCache.getValue(key) as string; + }, + async set(key: string, val: string) { + lruCache.setValue(key, val); + }, +}; + +/** + * 默认将图片转换为webp格式的base64字符串 + * @param src + */ +const onReplaceImage = async (src: SourceImage) => { + if (src instanceof Buffer || (typeof src === 'string' && (/^https?:\/\//.test(src) || /^data:image\//.test(src)))) { + const webpBuffer = (await convertImage(src)).buffer; + return `data:image/webp;base64,${webpBuffer.toString('base64')}`; + } + + return src; +}; + +/** + * 识别所有图片 + * @param pyClients + * @param images + * @param option + */ +export const predictPages = async ( + pyClients: PyClients, + images: OMRPage[], + option: OMROption = { outputWidth: 1200, pageStore, onReplaceImage } +): Promise<{ score: starry.Score; omitPages: number[]; stat: OMRStat }> => { + // return { + // score, + // omitPages, + // stat: { + // cost: t3 - t0, + // pagesCost: t2 - t1, + // pages: n_page, + // }, + // }; +}; diff --git a/backend/libs/predictPages.ts b/backend/libs/predictPages.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6006011e38cf433908c15fe5b76bb25d5a3e9eb --- /dev/null +++ b/backend/libs/predictPages.ts @@ -0,0 +1,887 @@ +import sha1 from 'sha1'; +import { Canvas, Image, loadImage } from 'skia-canvas'; +import { WeakLRUCache } from 'weak-lru-cache'; +import * as starry from '../../src/starry'; +import { SemanticGraph } from '../../src/starry'; +import { LayoutResult, PyClients } from './predictors'; +import { constructSystem, convertImage } from './util'; + +globalThis.OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas; +(globalThis as any).Image = (globalThis as any).Image || Image; +globalThis.btoa = globalThis.btoa || ((str: string) => Buffer.from(str, 'binary').toString('base64')); + +const STAFF_PADDING_LEFT = 32; + +const MAX_PAGE_WIDTH = 1200; + +const GAUGE_VISION_SPEC = { + viewportHeight: 256, + viewportUnit: 8, +}; + +const MASK_VISION_SPEC = { + viewportHeight: 192, + viewportUnit: 8, +}; + +const SEMANTIC_VISION_SPEC = { + viewportHeight: 192, + viewportUnit: 8, +}; + +interface OMRStat { + cost: number; // in milliseconds + pagesCost: number; // in milliseconds + pages: number; +} + +interface OMRSummary { + costTotal: number; // in milliseconds + costPerPage: number; // in milliseconds + pagesTotal: number; + scoreN: number; +} + +/** + * 为布局识别的图片标准化处理 + * @param image + * @param width + */ +function scaleForLayout(image: Image, width: number): Canvas { + let height = (image.height / image.width) * width; + + const canvas = new Canvas(width, height); + const ctx = canvas.getContext('2d'); + + ctx.drawImage(image, 0, 0, width, (width * image.height) / image.width); + + return canvas; +} + +/** + * 根据所有图像的检测结果设置合适的全局页面尺寸 + * @param score + * @param detections + * @param outputWidth + */ +function setGlobalPageSize(score: starry.Score, detections: LayoutResult[], outputWidth: number) { + const sizeRatios = detections + .filter((s) => s && s.detection && s.detection.areas?.length) + .map((v, k) => { + const staffInterval = Math.min(...v.detection.areas.filter((area) => area.staves?.middleRhos?.length).map((x) => x.staves.interval)); + + const sourceSize = v.sourceSize; + return { + ...v, + index: k, + vw: sourceSize.width / staffInterval, // 页面宽度(逻辑单位) + hwr: sourceSize.height / sourceSize.width, // 页面高宽比 + }; + }); + + if (!sizeRatios.length) { + throw new Error('empty result'); + } + + const maxVW = sizeRatios.sort((a, b) => b.vw - a.vw)[0]; + const maxAspect = Math.max(...sizeRatios.map((r) => r.hwr)); + + score.unitSize = outputWidth / maxVW.vw; + + // 页面显示尺寸 + score.pageSize = { + width: outputWidth, + height: outputWidth * maxAspect, + }; +} + +const batchTask = (fn: () => Promise) => fn(); +const concurrencyTask = (fns: (() => Promise)[]) => Promise.all(fns.map((fn) => fn())); + +const shootStaffImage = async ( + system: starry.System, + staffIndex: number, + { paddingLeft = 0, scaling = 1, spec }: { paddingLeft?: number; scaling?: number; spec: { viewportHeight: number; viewportUnit: number } } +): Promise => { + if (!system || !system.backgroundImage) return null; + + const staff = system.staves[staffIndex]; + if (!staff) return null; + + const middleUnits = spec.viewportHeight / spec.viewportUnit / 2; + + const width = system.imagePosition.width * spec.viewportUnit; + const height = system.imagePosition.height * spec.viewportUnit; + const x = system.imagePosition.x * spec.viewportUnit + paddingLeft; + const y = (system.imagePosition.y - (staff.top + staff.staffY - middleUnits)) * spec.viewportUnit; + + const canvas = new Canvas(Math.round(width + x) * scaling, spec.viewportHeight * scaling); + const context = canvas.getContext('2d'); + context.fillStyle = 'white'; + context.fillRect(0, 0, canvas.width, canvas.height); + context.drawImage(await loadImage(system.backgroundImage), x * scaling, y * scaling, width * scaling, height * scaling); + + return canvas; + // .substr(22); // remove the prefix of 'data:image/png;base64,' +}; + +/** + * 根据布局检测结果进行截图 + * @param score + * @param pageCanvas + * @param page + * @param detection + */ +async function shootImageByDetection({ + page, + score, + pageCanvas, +}: { + score: starry.Score; + page: starry.Page; + pageCanvas: Canvas; // 原始图片绘制好的canvas +}) { + if (!page?.layout?.areas?.length) { + return null; + } + + page.width = score.pageSize.width / score.unitSize; + page.height = score.pageSize.height / score.unitSize; + + const correctCanvas = new Canvas(pageCanvas.width, pageCanvas.height); + const ctx = correctCanvas.getContext('2d'); + + ctx.save(); + + const { width, height } = correctCanvas; + const [a, b, c, d] = page.source.matrix; + + ctx.setTransform(a, b, c, d, (-1 / 2) * width + (1 / 2) * a * width + (1 / 2) * b * height, (-1 / 2) * height + (1 / 2) * c * width + (1 / 2) * d * height); + + ctx.drawImage(pageCanvas, 0, 0); + + ctx.restore(); + + const interval = page.source.interval; + + page.layout.areas.map((area, systemIndex) => { + console.assert(area.staves?.middleRhos?.length, '[shootImageByDetection] empty area:', area); + + const data = ctx.getImageData(area.x, area.y, area.width, area.height); + + const canvas = new Canvas(area.width, area.height); + + const context = canvas.getContext('2d'); + // context.rotate(-area.staves.theta); + context.putImageData(data, 0, 0); + + const detection = area.staves; + const size = { width: area.width, height: area.height }; + + const sourceCenter = { + x: pageCanvas.width / 2 / interval, + y: pageCanvas.height / 2 / interval, + }; + + const position = { + x: (area.x + area.staves.phi1) / interval - sourceCenter.x + page.width / 2, + y: area.y / interval - sourceCenter.y + page.height / 2, + }; + + page.systems[systemIndex] = constructSystem({ + page, + backgroundImage: canvas.toBufferSync('png'), + detection, + imageSize: size, + position, + }); + }); + + return correctCanvas; +} + +async function shootStaffBackgroundImage({ system, staff, staffIndex }: { system: starry.System; staff: starry.Staff; staffIndex: number }) { + const sourceCanvas = await shootStaffImage(system, staffIndex, { + paddingLeft: STAFF_PADDING_LEFT, + spec: SEMANTIC_VISION_SPEC, + }); + + staff.backgroundImage = sourceCanvas.toBufferSync('png'); + + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, + y: staff.staffY - SEMANTIC_VISION_SPEC.viewportHeight / 2 / SEMANTIC_VISION_SPEC.viewportUnit, + width: sourceCanvas.width / SEMANTIC_VISION_SPEC.viewportUnit, + height: sourceCanvas.height / SEMANTIC_VISION_SPEC.viewportUnit, + }; +} + +/** + * 单个staff的变形矫正 + * @param system + * @param staff + * @param staffIndex + * @param gaugeImage + * @param pyClients + */ +async function gaugeStaff({ + system, + staff, + staffIndex, + gaugeImage, + pyClients, +}: { + system: starry.System; + staff: starry.Staff; + staffIndex: number; + gaugeImage: Buffer; + pyClients: PyClients; +}) { + const sourceCanvas = await shootStaffImage(system, staffIndex, { + paddingLeft: STAFF_PADDING_LEFT, + spec: GAUGE_VISION_SPEC, + scaling: 2, + }); + + const sourceBuffer = sourceCanvas.toBufferSync('png'); + + const baseY = (system.middleY - (staff.top + staff.staffY)) * GAUGE_VISION_SPEC.viewportUnit + GAUGE_VISION_SPEC.viewportHeight / 2; + + const { buffer, size } = await pyClients.predictScoreImages('gaugeRenderer', [sourceBuffer, gaugeImage, baseY]); + + staff.backgroundImage = buffer; + + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / GAUGE_VISION_SPEC.viewportUnit, + y: staff.staffY - size.height / 2 / GAUGE_VISION_SPEC.viewportUnit, + width: size.width / GAUGE_VISION_SPEC.viewportUnit, + height: size.height / GAUGE_VISION_SPEC.viewportUnit, + }; + + staff.maskImage = null; +} + +/** + * 单个staff的降噪 + * @param staff + * @param staffIndex + * @param maskImage + */ +async function maskStaff({ staff, staffIndex, maskImage }: { staff: starry.Staff; staffIndex: number; maskImage: Buffer }) { + const img = await loadImage(maskImage); + + staff.maskImage = maskImage; + staff.imagePosition = { + x: -STAFF_PADDING_LEFT / MASK_VISION_SPEC.viewportUnit, + y: staff.staffY - MASK_VISION_SPEC.viewportHeight / 2 / MASK_VISION_SPEC.viewportUnit, + width: img.width / MASK_VISION_SPEC.viewportUnit, + height: img.height / MASK_VISION_SPEC.viewportUnit, + }; +} + +/** + * 单个staff的语义识别 + * @param score + * @param staffIndex + * @param system + * @param staff + * @param graph + */ +async function semanticStaff({ + score, + staffIndex, + system, + staff, + graph, +}: { + score: starry.Score; + staffIndex: number; + system: starry.System; + staff: starry.Staff; + graph: SemanticGraph; +}) { + graph.offset(-STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, 0); + + system.assignSemantics(staffIndex, graph); + + staff.assignSemantics(graph); + staff.clearPredictedTokens(); + + score.assembleSystem(system, score.settings?.semanticConfidenceThreshold || 1); +} + +function replacePageImages(page: starry.Page, onReplaceImageKey: (src: string) => any) { + const tasks = [ + [page.source, 'url'], + ...page.systems + .map((system) => { + return [ + [system, 'backgroundImage'], + ...system.staves + .map((staff) => [ + [staff, 'backgroundImage'], + [staff, 'maskImage'], + ]) + .flat(), + ]; + }) + .flat(), + ]; + + tasks.map(([target, key]: [any, string]) => { + target[key] = onReplaceImageKey(target[key]); + }); +} + +export type TaskProgress = { total?: number; finished?: number }; + +export interface OMRPage { + url: string | Buffer; + key?: string; + layout?: LayoutResult; + renew?: boolean; + enableGauge?: boolean; +} + +export interface ProgressState { + layout?: TaskProgress; + text?: TaskProgress; + gauge?: TaskProgress; + mask?: TaskProgress; + semantic?: TaskProgress; + regulate?: TaskProgress; + brackets?: TaskProgress; +} + +class OMRProgress { + state: ProgressState = {}; + + onChange: (evt: ProgressState) => void; + + constructor(onChange: (evt: ProgressState) => void) { + this.onChange = onChange; + } + + setTotal(stage: keyof ProgressState, total: number) { + this.state[stage] = this.state[stage] || { + total, + finished: 0, + }; + } + + increase(stage: keyof ProgressState, step = 1) { + const info: TaskProgress = this.state[stage] || { + finished: 0, + }; + info.finished += step; + + this.onChange(this.state); + } +} + +type SourceImage = string | Buffer; + +export interface OMROption { + outputWidth?: number; + title?: string; // 曲谱标题 + pageStore?: { + has?: (key: string) => Promise; + get: (key: string) => Promise; + set: (key: string, val: string) => Promise; + }; + renew?: boolean; + processes?: (keyof ProgressState)[]; // 选择流程 + onProgress?: (progress: ProgressState) => void; + onReplaceImage?: (src: SourceImage) => Promise; // 替换所有图片地址,用于上传或者格式转换 +} + +const lruCache = new WeakLRUCache(); + +// 默认store +const pageStore = { + async get(key: string) { + return lruCache.getValue(key) as string; + }, + async set(key: string, val: string) { + lruCache.setValue(key, val); + }, +}; + +/** + * 默认将图片转换为webp格式的base64字符串 + * @param src + */ +const onReplaceImage = async (src: SourceImage) => { + if (src instanceof Buffer || (typeof src === 'string' && (/^https?:\/\//.test(src) || /^data:image\//.test(src)))) { + const webpBuffer = (await convertImage(src)).buffer; + return `data:image/webp;base64,${webpBuffer.toString('base64')}`; + } + + return src; +}; + +/** + * 识别所有图片 + * @param pyClients + * @param images + * @param option + */ +export const predictPages = async ( + pyClients: PyClients, + images: OMRPage[], + option: OMROption = { outputWidth: 1200, pageStore, onReplaceImage } +): Promise<{ score: starry.Score; omitPages: number[]; stat: OMRStat }> => { + const logger = pyClients.logger; + + option.outputWidth = option.outputWidth || 1200; + option.pageStore = option.pageStore || pageStore; + option.onReplaceImage = option.onReplaceImage || onReplaceImage; + + option.processes = + Array.isArray(option.processes) && option.processes.length > 0 ? option.processes : ['layout', 'text', 'gauge', 'mask', 'semantic', 'brackets']; + const progress: OMRProgress = new OMRProgress(option.onProgress); + + const t0 = Date.now(); + + // 预处理删除不合法区域 + images.forEach((image) => { + if (image.layout?.detection) { + image.layout.detection.areas = image.layout.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0); + } else { + delete image.layout; + } + }); + + const score = new starry.Score({ + title: option?.title, + stavesCount: 2, + paperOptions: { + raggedLast: true, + raggedLastBottom: true, + }, + headers: {}, + instrumentDict: {}, + settings: { + enabledGauge: option.processes.includes('gauge'), + semanticConfidenceThreshold: 1, + }, + }); + + logger.info(`[predictor]: download_source_images-${images.length}`); + + // 原始拍摄图 + const originalImages: Image[] = await Promise.all(images.map((img) => loadImage(img.url as any))); + + logger.info(`[predictor]: source_images_downloaded-${images.length}`); + + //const INPUT_IMAGE_WIDTH = images.filter((x) => x?.layout?.interval)?.[0]?.layout?.sourceSize?.width; + + /******************************* 布局识别 start *************************/ + // 输入给布局检测的图 + const pageCanvasList: Canvas[] = originalImages.map((img, index) => scaleForLayout(img, images[index]!.layout?.sourceSize?.width ?? img.width)); + + progress.setTotal('layout', originalImages.length); + progress.setTotal('text', originalImages.length); + + const detections = await Promise.all( + pageCanvasList.map(async (cvs, key) => { + if (!images[key].layout) return (await pyClients.predictScoreImages('layout', [cvs.toBufferSync('png')]))?.[0]; + + // reinforce layout from front-end if no gauge + if (!images[key].enableGauge && images[key]?.layout?.detection?.areas?.length) + return (await pyClients.predictScoreImages('layout$reinforce', [cvs.toBufferSync('png')], [images[key].layout]))?.[0]; + + return images[key].layout; + }) + ); + + detections.forEach((page) => { + page.detection.areas = page.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0); + }); + + const imageURLMap = new Map(); + const collectImage = async (source: SourceImage): Promise => { + const url = await option.onReplaceImage(source); + imageURLMap.set(source, url); + }; + + // 根据所有页面的宽高比决定全局显示尺寸 + setGlobalPageSize(score, detections, option.outputWidth); + + async function createPage(detect, pageIndex) { + const { url, key, layout, enableGauge } = images[pageIndex]; + + const pageKey = sha1(JSON.stringify({ key: key || url, layout, enableGauge })); + + const cachedPageJson = await option.pageStore.get(pageKey); + + const omit = !option.renew && ((cachedPageJson && !images[pageIndex].renew) || !detect.detection.areas?.length); + + const page = (score.pages[pageIndex] = + omit && cachedPageJson + ? starry.recoverJSON(cachedPageJson, starry) + : new starry.Page({ + source: { + name: key || (typeof url === 'string' && /https?:\/\//.test(url) ? url : null), + size: 0, + url, + crop: { + unit: '%', + x: 0, + y: 0, + width: 100, + height: 100, + }, + dimensions: detect.sourceSize, + matrix: [Math.cos(detect.theta), -Math.sin(detect.theta), Math.sin(detect.theta), Math.cos(detect.theta), 0, 0], + interval: detect.interval, + needGauge: images[pageIndex].enableGauge, + }, + layout: detect.detection, + })); + + const correctCanvas = omit + ? null + : await shootImageByDetection({ + score, + page, + pageCanvas: pageCanvasList[pageIndex], + }); + + progress.increase('layout'); + + return { + page, + omit, + hash: pageKey, + correctCanvas, + }; + } + + const systemsCount = detections.reduce((acc, x) => acc + (x.detection.areas?.length ?? 0), 0); + const stavesCount = detections.reduce((acc, x) => acc + (x.detection.areas?.reduce?.((a, y) => a + (y.staves?.middleRhos?.length ?? 0), 0) ?? 0), 0); + + progress.setTotal('gauge', stavesCount); + progress.setTotal('mask', stavesCount); + progress.setTotal('semantic', stavesCount); + progress.setTotal('brackets', systemsCount); + + const allTasks = []; + + const omitPages = []; + + const t1 = Date.now(); + + let n_page = 0; + + for (const pageIndex of detections.keys()) { + const pageTasks = []; + + const { page, correctCanvas, omit, hash } = await createPage(detections[pageIndex], pageIndex); + + pageTasks.push(collectImage(page.source.url)); + pageTasks.push(...page.systems.map((system) => collectImage(system.backgroundImage))); + + logger.info(`[predictor]: check_cache_pageIndex-${pageIndex} omit: ${omit}`); + if (omit) { + omitPages.push(pageIndex); + } else { + const staves = page.systems + .map((system, systemIndex) => system.staves.map((staff, staffIndex) => ({ pageIndex, systemIndex, staffIndex, page, system, staff }))) + .flat(1); + + await concurrencyTask([ + /******************************* 括号检测 start *************************/ + async () => { + if (!option.processes.includes('brackets')) return; + + const detection = page.layout; + const interval = page.source.interval; + + const startTime = Date.now(); + + const bracketImages = page.systems.map((system, systemIndex) => { + const { + x, + y, + staves: { middleRhos, phi1 }, + } = detection.areas[systemIndex]; + + const topMid = middleRhos[0]; + const bottomMid = middleRhos[middleRhos.length - 1]; + + const sourceRect = { + x: x + phi1 - 4 * interval, + y: y + topMid - 4 * interval, + width: 8 * interval, + height: bottomMid - topMid + 8 * interval, + }; + + const OUTPUT_INTERVAL = 8; + + const canvas = new Canvas(OUTPUT_INTERVAL * 8, (sourceRect.height / interval) * OUTPUT_INTERVAL); + + const context = canvas.getContext('2d'); + context.drawImage(correctCanvas, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height, 0, 0, canvas.width, canvas.height); + + // console.log(pageIndex, systemIndex, JSON.stringify(sourceRect), correctCanvas.width, correctCanvas.height) + // const pctx = canvas.getContext('2d') + // pctx.strokeStyle = 'red' + // pctx.fillStyle = 'rgba(255, 0, 0, 0.2)' + // pctx.fillRect(sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height) + // const area = detections[pageIndex].detection.areas[systemIndex] + // pctx.strokeStyle = 'green' + // pctx.fillStyle = 'rgba(0, 255, 0, 0.1)' + // pctx.fillRect(area.x, area.y, area.width, area.height) + // pctx.fillRect(area.x, area.y, area.width, area.height) + // require('fs').writeFile(`test--system-${systemIndex}.png`, canvas.toBufferSync('png'), () => {}) + // require('fs-extra').writeFile(`test--brackets-${pageIndex}-${systemIndex}.png`, canvas.toBufferSync('png')) + + return { + system, + buffer: canvas.toBufferSync('png'), + }; + }); + + logger.info(`[predictor]: brackets js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`); + + const bracketsRes = await pyClients.predictScoreImages('brackets', { buffers: bracketImages.map((x) => x.buffer) }); + progress.increase('brackets', bracketImages.length); + + bracketImages.forEach(({ system }, index) => { + if (bracketsRes[index]) { + system.bracketsAppearance = bracketsRes[index]; + } + }); + }, + /******************************* 括号检测 end *************************/ + + /******************************* 文本识别 start *************************/ + async () => { + if (!option.processes.includes('text')) return; + + try { + const startTime = Date.now(); + + // await require('fs-extra').writeFile(`test--text-location-${pageIndex}.png`, correctCanvas.toBufferSync('png')) + const bufferForText = correctCanvas.toBufferSync('png'); + + const resultLoc = await pyClients.predictScoreImages('textLoc', [bufferForText]); + + const location = resultLoc[0].filter((box) => box.score > 0); + + if (location.length > 0) { + const [resultOCR] = await pyClients.predictScoreImages('textOcr', { + buffers: [bufferForText], + location, + }); + + page.assignTexts(resultOCR.areas, resultOCR.imageSize); + page.assemble(); + } + + logger.info(`[predictor]: text js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`); + + progress.increase('text'); + + if (!option.title) { + const coverTexts: { + confidence: number; + fontSize: number; + id: string; + text: string; + textType: 'Title' | 'Author'; + type: starry.TokenType; + width_: number; + x: number; + y: number; + }[] = score.pages[0].tokens as any; + + if (Array.isArray(coverTexts) && coverTexts.length > 0) { + const [titleToken] = coverTexts + .filter((x) => x.type === starry.TokenType.Text && x.textType === 'Title') + .sort((a, b) => b.fontSize - a.fontSize); + + if (titleToken) { + score.title = titleToken.text; + } + } + } + } catch (err) { + logger.error(`[predictor]: text js [pageIndex-${pageIndex}] ${JSON.stringify(err)}`); + } + }, + /******************************* 文本识别 end *************************/ + async () => { + /******************************* 变形矫正 start *************************/ + await batchTask(async () => { + const disableGauge = !option.processes.includes('gauge') || images[pageIndex].enableGauge === false; + + if (!disableGauge) { + const gaugeRes = await pyClients.predictScoreImages( + 'gauge', + await Promise.all( + staves.map(async ({ staffIndex, system }) => { + const startTime = Date.now(); + const sourceCanvas = await shootStaffImage(system, staffIndex, { + paddingLeft: STAFF_PADDING_LEFT, + spec: GAUGE_VISION_SPEC, + }); + + logger.info(`[predictor]: gauge js shoot [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`); + + return sourceCanvas.toBufferSync('png'); + }) + ) + ); + + for (const [index, { system, staff, pageIndex, staffIndex }] of staves.entries()) { + const startTime = Date.now(); + + logger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] start..`); + await gaugeStaff({ + pyClients, + system, + staff, + staffIndex, + gaugeImage: gaugeRes[index].image, + }); + logger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`); + + progress.increase('gauge'); + + pageTasks.push(collectImage(staff.backgroundImage)); + } + } else { + for (const [_, { system, staff, staffIndex }] of staves.entries()) { + await shootStaffBackgroundImage({ + system, + staff, + staffIndex, + }); + pageTasks.push(collectImage(staff.backgroundImage)); + } + } + }); + /******************************* 变形矫正 end *************************/ + + await concurrencyTask([ + /******************************* 降噪 start *************************/ + async () => { + if (!option.processes.includes('mask')) return; + + const maskRes = await pyClients.predictScoreImages( + 'mask', + staves.map(({ staff }) => staff.backgroundImage as Buffer) + ); + + for (const [index, { staff, staffIndex }] of staves.entries()) { + const startTime = Date.now(); + + await maskStaff({ + staff, + staffIndex, + maskImage: maskRes[index].image, + }); + + logger.info(`[predictor]: mask js [page-${pageIndex}, ${index}, staff-${staffIndex}] duration: ${Date.now() - startTime}`); + progress.increase('mask'); + + pageTasks.push(collectImage(staff.maskImage)); + } + }, + /******************************* 降噪 end *************************/ + + /******************************* 语义识别 start *************************/ + async () => { + if (!option.processes.includes('semantic')) return; + + const semanticRes = starry.recoverJSON( + await pyClients.predictScoreImages( + 'semantic', + staves.map(({ staff }) => staff.backgroundImage as Buffer) + ), + starry + ); + + staves.forEach(({ system }) => system.clearTokens()); + + for (const [index, { staffIndex, system, staff }] of staves.entries()) { + const startTime = Date.now(); + + await semanticStaff({ + score, + system, + staff, + staffIndex, + graph: semanticRes[index], + }); + + logger.info( + `[predictor]: semantic js [page-${pageIndex}, system-${system.index}, staff-${staff.index}] duration: ${ + Date.now() - startTime + }` + ); + progress.increase('semantic'); + } + }, + /******************************* 语义识别 end *************************/ + ]); + }, + ]); + + ++n_page; + } + + allTasks.push( + Promise.all(pageTasks).then(() => { + replacePageImages(page, (src) => imageURLMap.get(src)); + logger.info(`[predictor]: pageStore set: [${pageIndex}]`); + return option.pageStore.set(hash, JSON.stringify(page)); + }) + ); + } + + const t2 = Date.now(); + + await Promise.all(allTasks); + + logger.info(`[predictor]: inferenceStaffLayout: ${score.title}, [${score.systems.length}]`); + + score.inferenceStaffLayout(); + + logger.info(`[predictor]: done: ${score.title}`); + + // correct semantic ids + score.assemble(); + + const t3 = Date.now(); + + return { + score, + omitPages, + stat: { + cost: t3 - t0, + pagesCost: t2 - t1, + pages: n_page, + }, + }; +}; + +export const abstractOMRStats = (stats: OMRStat[]): OMRSummary => { + const { costTotal, pagesCostTotal, pagesTotal } = stats.reduce( + (sum, stat) => ({ + costTotal: sum.costTotal + stat.cost, + pagesCostTotal: sum.pagesCostTotal + stat.pagesCost, + pagesTotal: sum.pagesTotal + stat.pages, + }), + { costTotal: 0, pagesCostTotal: 0, pagesTotal: 0 } + ); + + return { + costTotal, + costPerPage: pagesTotal ? costTotal / pagesTotal : null, + pagesTotal, + scoreN: stats.length, + }; +}; diff --git a/backend/libs/predictors.ts b/backend/libs/predictors.ts new file mode 100644 index 0000000000000000000000000000000000000000..4fe8fcfd763a263c7f276bbc003d663b7c3ab70a --- /dev/null +++ b/backend/libs/predictors.ts @@ -0,0 +1,139 @@ +import ZeroClient, { Logger } from './ZeroClient'; +import * as starry from '../../src/starry'; +import PyProcessor from './PyProcessor'; +import { destructPromise } from './async-queue'; +import { getPort } from 'portfinder'; +import util from 'util'; +import { Options } from 'python-shell'; + +const getPortPromise = util.promisify(getPort); + +export interface LayoutResult { + detection: starry.PageLayout; + theta: number; + interval: number; + sourceSize?: { + width: number; + height: number; + }; +} + +export interface PredictorInterface { + layout: (streams: Buffer[]) => LayoutResult[]; + layout$reinforce: (streams: Buffer[], baseLayouts: LayoutResult[]) => LayoutResult[]; + gauge: (streams: Buffer[]) => { + image: Buffer; + }[]; + mask: (streams: Buffer[]) => { + image: Buffer; + }[]; + semantic: (streams: Buffer[]) => any[]; + textLoc: (streams: Buffer[]) => any[]; + textOcr: (params: { buffers: Buffer[]; location: any[] }) => any[]; + brackets: (params: { buffers: Buffer[] }) => any[]; + topo: (params: { clusters: starry.EventCluster[] }) => any[]; + gaugeRenderer: (params: [Buffer, Buffer, number]) => { buffer: Buffer; size: { width: number; height: number } }; + jianpu: (params: { buffers: Buffer[] }) => any[]; + // [source: Buffer, gauge: Buffer, baseY: number] +} + +type PredictorType = keyof PredictorInterface; + +export type PyClientsConstructOptions = Partial>; + +export class PyClients { + clients = new Map>(); + + constructor(public readonly options: PyClientsConstructOptions, public readonly logger: Logger = console) {} + + async getClient(type: PredictorType) { + if (this.clients.has(type)) { + return this.clients.get(type); + } + + const [promise, resolve, reject] = destructPromise(); + + const opt = this.options[type]; + + if (!opt) { + throw new Error(`no config for client \`${type}\` found`); + } + + try { + if (typeof opt === 'string') { + const client = new ZeroClient(); + client.bind(opt); + resolve(client); + } else { + const { scriptPath, ...option } = opt; + const client = new PyProcessor(scriptPath, option, this.logger); + await client.bind(`${await getPortPromise()}`); + resolve(client); + } + + this.logger.info(`PyClients: ${type} started`); + } catch (err) { + this.logger.error(`PyClients: ${type} start fail: ${JSON.stringify(err)}`); + reject(err); + } + + this.clients.set(type, promise); + + return promise; + } + + async checkHost(type: PredictorType): Promise { + const client = await this.getClient(type); + + return client.request('checkHost'); + } + + async warmup() { + const opts = Object.keys(this.options) as PredictorType[]; + await Promise.all(opts.map((type) => this.getClient(type))); + } + + /** + * 模型预测 + * @param type layout | mask | gauge | semantic + * @param args + */ + async predictScoreImages(type: T, ...args: Parameters): Promise> { + const clientType = type.split('$')[0] as PredictorType; + const client = await this.getClient(clientType); + let res = null; + + this.logger.info(`[predictor]: ${type} py start..`); + const start = Date.now(); + + switch (type) { + case 'layout': + res = await client.request('predictDetection', args); + break; + case 'layout$reinforce': + res = await client.request('predictReinforce', args); + break; + case 'gauge': + case 'mask': + res = await client.request('predict', args, { by_buffer: true }); + break; + case 'semantic': + case 'textLoc': + res = await client.request('predict', args); + break; + case 'textOcr': + case 'brackets': + case 'topo': + case 'gaugeRenderer': + case 'jianpu': + res = await client.request('predict', ...args); + break; + default: + this.logger.error(`[predictor]: no predictor ${type}`); + } + + this.logger.info(`[predictor]: ${type} py duration: ${Date.now() - start}ms`); + + return res; + } +} diff --git a/backend/libs/regulation.ts b/backend/libs/regulation.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ec839a9d227e355621042072c2bd9670b28695f --- /dev/null +++ b/backend/libs/regulation.ts @@ -0,0 +1,350 @@ +import * as starry from '../../src/starry'; +import { PyClients } from './predictors'; +import { Logger } from './ZeroClient'; +import { SpartitoMeasure, EditableMeasure, evaluateMeasure } from '../../src/starry'; +import { EquationPolicy } from '../../src/starry/spartitoMeasure'; +import { genMeasureRectifications } from '../../src/starry/measureRectification'; +import { SolutionStore, DefaultSolutionStore, SaveIssueMeasure } from './store'; +export * from './regulationBead'; + +globalThis.btoa = globalThis.btoa || ((str) => Buffer.from(str, 'binary').toString('base64')); + +const RECTIFICATION_SEARCH_ITERATIONS = parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS || '30'); +const BASE_QUOTA_FACTOR = parseInt(process.env.BASE_QUOTA_FACTOR || '40'); +const RECTIFICATION_QUOTA_FACTOR = parseInt(process.env.RECTIFICATION_QUOTA_FACTOR || '80'); + +const MATRIXH_INTERPOLATION_K = 0.9; + +interface SolveMeasureOptions { + solver?: (...args: any[]) => any; + quotaMax?: number; + quotaFactor?: number; + solutionStore?: SolutionStore; + ignoreCache?: boolean; + logger?: Logger; +} + +const computeQuota = (n: number, factor: number, limit: number) => + Math.min(Math.ceil((n + 1) * factor * Math.log(n + 2)), Math.ceil(limit * Math.min(1, (24 / (n + 1)) ** 2))); + +interface BaseRegulationStat { + cached: number; + computed: number; + solved: number; +} + +async function solveMeasures( + measures: SpartitoMeasure[], + { solver, quotaMax = 1000, quotaFactor = BASE_QUOTA_FACTOR, solutionStore = DefaultSolutionStore, ignoreCache = false, logger }: SolveMeasureOptions = {} +): Promise { + let cached = 0; + let solved = 0; + + logger?.info(`[solveMeasures] begin, measure total: ${measures.length}.`); + + await Promise.all( + measures.map(async (measure) => { + if (!ignoreCache) { + const solution = await solutionStore.get(measure.regulationHash); + if (solution) { + measure.applySolution(solution); + ++cached; + return; + } + } + + const quota = computeQuota(measure.events.length, quotaFactor, quotaMax); + + await measure.regulate({ + policy: 'equations', + quota, + solver, + }); + + const stat = evaluateMeasure(measure); + if (!stat.error) solutionStore.set(measure.regulationHash0, { ...measure.asSolution(), priority: -measure?.solutionStat?.loss! }); + if (stat.perfect) ++solved; + + logger?.info( + `[solveMeasures] measure[${measure.measureIndex}/${measures.length}] regulated: ${stat.perfect ? 'solved' : stat.error ? 'error' : 'issue'}, ${ + measure.regulationHash + }` + ); + }) + ); + + logger?.info(`[solveMeasures] ${cached}/${measures.length} cache hit, ${solved} solved.`); + + return { + cached, + computed: measures.length - cached, + solved, + }; +} + +const solveMeasuresWithRectifications = async ( + measure: SpartitoMeasure, + { solver, quotaMax = 4000 }: SolveMeasureOptions +): Promise => { + let best = evaluateMeasure(measure); + let bestSolution: starry.RegulationSolution = measure.asSolution(); + const quota = computeQuota(measure.events.length, RECTIFICATION_QUOTA_FACTOR, quotaMax); + let n_rec = 0; + + // @ts-ignore + for (const rec of genMeasureRectifications(measure)) { + const solution = await EquationPolicy.regulateMeasureWithRectification(measure, rec, { solver, quota }); + + const testMeasure = measure.deepCopy() as SpartitoMeasure; + testMeasure.applySolution(solution); + const result = evaluateMeasure(testMeasure); + + if ( + result.perfect > best.perfect || + result.error < best.error || + (!result.error && result.perfect >= best.perfect && solution.priority! > bestSolution.priority!) + ) { + best = result; + bestSolution = solution; + } + + if (result.perfect) break; + + ++n_rec; + if (n_rec > RECTIFICATION_SEARCH_ITERATIONS) break; + } + + return bestSolution; +}; + +interface RegulateWithTopoOption { + solutionStore: SolutionStore; + pyClients: PyClients; + solver: (...args: any[]) => any; + onSaveIssueMeasure?: SaveIssueMeasure; +} + +interface RegulateMaybeWithTopoOption { + solutionStore: SolutionStore; + pyClients?: PyClients; + solver: (...args: any[]) => any; + onSaveIssueMeasure?: SaveIssueMeasure; +} + +interface RegulateSimpleOption { + solutionStore: SolutionStore; + solver: (...args: any[]) => any; + logger?: Logger; + quotaMax?: number; + quotaFactor?: number; +} + +interface TopoRegulationStat { + solved: number; + issue: number; + fatal: number; +} + +async function doRegulateWithTopo( + score: starry.Score, + { pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateWithTopoOption +): Promise { + pyClients.logger.info(`[RegulateWithTopo] regulate score: ${score.title}, measures: ${score.spartito!.measures.length}`); + + const issueMeasures = score.spartito!.measures.filter((measure) => { + const stat = evaluateMeasure(measure); + return !stat.perfect; + }); + pyClients.logger.info(`[RegulateWithTopo] basic issues: ${issueMeasures.length}`); + + if (issueMeasures.length === 0) { + return { + solved: 0, + issue: 0, + fatal: 0, + }; + } + + const clusters = ([] as starry.EventCluster[]).concat(...issueMeasures.map((measure) => measure.createClusters())); + const results = await pyClients.predictScoreImages('topo', { clusters }); + console.assert(results.length === clusters.length, 'prediction number mismatch:', clusters.length, results.length); + + clusters.forEach((cluster, index) => { + const result = results[index]; + console.assert(result, 'no result for cluster:', cluster.index); + + cluster.assignPrediction(result); + }); + + issueMeasures.forEach((measure) => { + const cs = clusters.filter((c) => c.index === measure.measureIndex); + measure.applyClusters(cs); + + // intepolate matrixH + const { matrixH } = EquationPolicy.estiamteMeasure(measure); + matrixH.forEach((row, i) => + row.forEach((v, j) => { + measure.matrixH[i][j] = measure.matrixH[i][j] * MATRIXH_INTERPOLATION_K + v * (1 - MATRIXH_INTERPOLATION_K); + }) + ); + }); + + const solvedIndices: number[] = []; + const errorIndices: number[] = []; + + // rectification search + await Promise.all( + issueMeasures.map(async (measure) => { + const hash = measure.regulationHash0; + const solution = await solveMeasuresWithRectifications(measure, { solver }); + if (solution) { + measure.applySolution(solution); + solutionStore.set(hash, solution); + solutionStore.set(measure.regulationHash, measure.asSolution()); + pyClients.logger.info(`[RegulateWithTopo] solutionStore set: ${measure.measureIndex}, ${hash}, ${measure.regulationHash}`); + } + + const stat = evaluateMeasure(measure); + onSaveIssueMeasure?.({ + measureIndex: measure.measureIndex, + measure: new EditableMeasure(measure), + status: stat.error ? 2 : 1, + }); + if (stat.perfect) solvedIndices.push(measure.measureIndex); + else if (stat.error) errorIndices.push(measure.measureIndex); + }) + ); + + const n_issues = issueMeasures.length - solvedIndices.length - errorIndices.length; + pyClients.logger.info(`[RegulateWithTopo] score: ${score.title}, solved/issue/fatal: ${solvedIndices.length}/${n_issues}/${errorIndices.length}`); + if (solvedIndices.length) pyClients.logger.info(`[RegulateWithTopo] solved measures: ${solvedIndices.join(', ')}`); + if (errorIndices.length) pyClients.logger.info(`[RegulateWithTopo] error measures: ${errorIndices.join(', ')}`); + + return { + solved: solvedIndices.length, + issue: n_issues, + fatal: errorIndices.length, + }; +} + +interface RegulationStat { + baseCost: number; // in milliseconds + topoCost: number; // in milliseconds + baseMeasures: BaseRegulationStat; + topoMeasures?: TopoRegulationStat; + qualityScore: number; +} + +const doRegulate = async ( + score: starry.Score, + { pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateMaybeWithTopoOption +): Promise => { + pyClients?.logger?.info(`[doRegulate] score: ${score.title}`); + + score.spartito = undefined; + score.assemble(); + const spartito = score.makeSpartito(); + + spartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure)); + + const t0 = Date.now(); + + const baseMeasures = await solveMeasures(spartito.measures, { solver, quotaMax: 1000, solutionStore, logger: pyClients?.logger }); + + const t1 = Date.now(); + + const topoMeasures = pyClients ? await doRegulateWithTopo(score, { pyClients, solver, solutionStore, onSaveIssueMeasure }) : undefined; + + const t2 = Date.now(); + + return { + baseCost: t1 - t0, + topoCost: t2 - t1, + baseMeasures, + topoMeasures, + qualityScore: spartito.qualityScore, + }; +}; + +const doSimpleRegulate = async ( + score: starry.Score, + { solver, solutionStore = DefaultSolutionStore, logger, quotaMax = 240, quotaFactor = 16 }: RegulateSimpleOption +): Promise => { + score.assemble(); + const spartito = score.spartito || score.makeSpartito(); + const measures = spartito.measures.filter((measure) => !measure.regulated); + + await solveMeasures(measures, { solver, quotaMax, quotaFactor, solutionStore, logger }); + + console.assert(score.spartito?.regulated, 'doSimpleRegulate: regulation incomplete:', spartito.measures.filter((measure) => !measure.regulated).length); +}; + +const evaluateScoreQuality = async (score: starry.Score, options: RegulateSimpleOption): Promise => { + if (!score.spartito?.regulated) await doSimpleRegulate(score, options); + + return score.spartito!.regulated ? score.spartito!.qualityScore : null; +}; + +interface RegulationSummary { + scoreN: number; + + baseCostTotal: number; // in milliseconds + topoCostTotal: number; // in milliseconds + baseCostPerMeasure: number | null; // in milliseconds + topoCostPerMeasure: number | null; // in milliseconds + + cached: number; + baseComputed: number; + baseSolved: number; + topoSolved: number; + topoIssue: number; + topoFatal: number; +} + +const abstractRegulationStats = (stats: RegulationStat[]): RegulationSummary => { + const { baseCostTotal, topoCostTotal, baseMeasures, topoMeasures } = stats.reduce( + (sum, stat) => ({ + baseCostTotal: sum.baseCostTotal + stat.baseCost, + topoCostTotal: sum.topoCostTotal + stat.topoCost, + baseMeasures: sum.baseMeasures + stat.baseMeasures.computed, + topoMeasures: sum.topoMeasures + (stat.topoMeasures!.solved + stat.topoMeasures!.issue + stat.topoMeasures!.fatal), + }), + { + baseCostTotal: 0, + topoCostTotal: 0, + baseMeasures: 0, + topoMeasures: 0, + } + ); + + const baseCostPerMeasure = baseMeasures > 0 ? baseCostTotal / baseMeasures : null; + const topoCostPerMeasure = topoMeasures > 0 ? topoCostTotal / topoMeasures : null; + + const { cached, baseComputed, baseSolved, topoSolved, topoIssue, topoFatal } = stats.reduce( + (sum, stat) => ({ + cached: sum.cached + stat.baseMeasures.cached, + baseComputed: sum.baseComputed + stat.baseMeasures.computed, + baseSolved: sum.baseSolved + stat.baseMeasures.solved, + topoSolved: sum.topoSolved + stat.topoMeasures!.solved, + topoIssue: sum.topoIssue + stat.topoMeasures!.issue, + topoFatal: sum.topoFatal + stat.topoMeasures!.fatal, + }), + { cached: 0, baseComputed: 0, baseSolved: 0, topoSolved: 0, topoIssue: 0, topoFatal: 0 } + ); + + return { + scoreN: stats.length, + baseCostTotal, + topoCostTotal, + baseCostPerMeasure, + topoCostPerMeasure, + cached, + baseComputed, + baseSolved, + topoSolved, + topoIssue, + topoFatal, + }; +}; + +export { doRegulate, doSimpleRegulate, evaluateScoreQuality, abstractRegulationStats }; diff --git a/backend/libs/regulationBead.ts b/backend/libs/regulationBead.ts new file mode 100644 index 0000000000000000000000000000000000000000..98584e2287b27b809d6015b70f5bad5dd129cf02 --- /dev/null +++ b/backend/libs/regulationBead.ts @@ -0,0 +1,372 @@ +import * as starry from '../../src/starry'; +import { Logger } from './ZeroClient'; +import { SolutionStore, DefaultSolutionStore, SaveIssueMeasure, MeasureStatus } from './store'; + +interface BeadRegulationCounting { + cached: number; + simple: number; + computed: number; + tryTimes: number; + solved: number; + issue: number; + fatal: number; +} + +interface RegulationBeadStat { + totalCost: number; // in milliseconds + pickerCost: number; // in milliseconds + measures: BeadRegulationCounting; + qualityScore: number; +} + +interface RegulationBeadSummary { + scoreN: number; + + totalCost: number; // in milliseconds + pickerCost: number; // in milliseconds + costPerMeasure: number | null; // in milliseconds + costPerTime: number | null; // in milliseconds + + cached: number; + simple: number; + computed: number; + tryTimes: number; + solved: number; + issue: number; + fatal: number; +} + +interface ProgressInfo { + pass: number; + remaining: number; + total: number; +} + +interface RegulateBeadOption { + logger?: Logger; + pickers: starry.BeadPicker[]; + solutionStore?: SolutionStore; + ignoreCache?: boolean; + freshOnly?: boolean; + onSaveIssueMeasure?: SaveIssueMeasure; + onProgress?: (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => void; + onPassStart?: (pass: number, conditionName: string, pendingCount: number) => void; +} + +interface MeasureReord { + origin: starry.SpartitoMeasure; + current: starry.SpartitoMeasure; + evaluation?: starry.MeasureEvaluation; + baseQuality: number; + picker: starry.BeadPicker; +} + +interface BeadSolverOptions { + stopLoss: number; + quotaMax: number; + quotaFactor: number; + ptFactor: number; +} + +enum PendingCondition { + ErrorOnly, + NotFine, + Imperfect, +} + +const isPending = (evaluation: starry.MeasureEvaluation, condition: PendingCondition) => { + switch (condition) { + case PendingCondition.ErrorOnly: + return evaluation.error; + + case PendingCondition.Imperfect: + return !evaluation.perfect; + } + + return !evaluation.fine; +}; + +type OnUpdate = (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean) => void; + +const solveMeasureRecords = async ( + records: MeasureReord[], + onUpdate: OnUpdate, + stdout: NodeJS.WritableStream | null, + options: Partial, + pendingCondition: PendingCondition = PendingCondition.NotFine, + pass: number = 0, + onProgress?: RegulateBeadOption['onProgress'] +): Promise => { + const pendingRecords = records.filter(({ evaluation }) => !evaluation || isPending(evaluation, pendingCondition)); + stdout?.write('.'.repeat(pendingRecords.length)); + stdout?.write('\b'.repeat(pendingRecords.length)); + + const total = pendingRecords.length; + let done = 0; + + for (const record of pendingRecords) { + const measure = record.current.deepCopy(); + measure.staffGroups = record.current.staffGroups; + + const solution = await starry.beadSolver.solveMeasure(measure, { picker: record.picker, ...options }); + measure.applySolution(solution); + + const evaluation = starry.evaluateMeasure(measure); + const better = + !record.evaluation || + evaluation.fine > record.evaluation.fine || + (evaluation.qualityScore > record.evaluation.qualityScore && evaluation.fine === record.evaluation.fine); + if (better) { + record.evaluation = evaluation; + Object.assign(record.current, measure); + } + + onUpdate(record.current, evaluation, better); + + done++; + onProgress?.(record.current, evaluation, better, { pass, remaining: total - done, total }); + } + + if (pendingRecords.length) stdout?.write('\n'); + + return pendingRecords.length; +}; + +const regulateWithBeadSolver = async ( + score: starry.Score, + { logger, pickers, solutionStore = DefaultSolutionStore, ignoreCache, freshOnly, onSaveIssueMeasure, onProgress, onPassStart }: RegulateBeadOption +): Promise => { + score.spartito = undefined; + score.assemble(); + const spartito = score.makeSpartito(); + + spartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure)); + + const t0 = Date.now(); + logger?.info(`[regulateWithBeadSolver] begin, measure total: ${spartito.measures.length}.`, ignoreCache ? 'ignoreCache' : '', freshOnly ? 'freshOnly' : ''); + + const records = spartito.measures + .filter((measure) => measure.events?.length && !measure.patched) + .map( + (measure) => + ({ + origin: measure.deepCopy(), + current: measure, + evaluation: undefined, + baseQuality: 0, + } as MeasureReord) + ); + + // rectify time signature + for (const measure of spartito.measures.filter((measure) => measure.events?.length)) { + const picker = pickers.find((picker) => picker.n_seq > measure.events.length + 1); + if (picker) await starry.beadSolver.estimateMeasure(measure, picker); + } + spartito.rectifyTimeSignatures(logger as any); + + // zero pickers' cost + pickers.forEach((picker) => (picker.cost = 0)); + + const counting = { + cached: 0, + simple: 0, + computed: 0, + tryTimes: 0, + solved: 0, + issue: 0, + fatal: 0, + }; + + logger?.info(`[regulateWithBeadSolver] measures estimation finished.`); + + // apply solutions + if (solutionStore && !ignoreCache) + for (const record of records) { + const solution = await solutionStore.get(record.origin.regulationHash0); + if (solution) { + record.current.applySolution(solution); + ++counting.cached; + + record.evaluation = starry.evaluateMeasure(record.current); + record.baseQuality = record.evaluation.qualityScore; + } + } + + logger?.info('[regulateWithBeadSolver]', `${counting.cached}/${records.length}`, 'solutions loaded.'); + + const stdout = logger ? null : process.stdout; + if (counting.cached) stdout?.write(`${counting.cached}c`); + + records.forEach((record) => { + const picker = pickers.find((picker) => picker.n_seq > record.current.events.length + 1); + if (!picker) { + logger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] size out of range:`, record.current.events.length); + } else record.picker = picker; + }); + + const pendingRecords = records.filter((record) => record.picker && (!record.evaluation || (!record.evaluation.fine && !freshOnly))) as (MeasureReord & { + evaluation: starry.MeasureEvaluation; + })[]; + + // solve by simple policy + pendingRecords.forEach((record) => { + const measure = record.current.deepCopy(); + measure.staffGroups = record.current.staffGroups; + + measure.regulate({ policy: 'simple' }); + + const evaluation = starry.evaluateMeasure(measure); + const better = !record.evaluation || evaluation.qualityScore > record.evaluation.qualityScore; + if (better) { + record.evaluation = evaluation; + Object.assign(record.current, measure); + + if (evaluation.perfect) { + logger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] regulated by simple policy.`); + ++counting.simple; + } + } + }); + counting.computed = pendingRecords.length - counting.simple; + + if (counting.simple) stdout?.write(`${counting.simple}s`); + + const onUpdate = (measure, evaluation, better) => { + logger?.info( + `[regulateWithBeadSolver] measure[${measure.measureIndex}/${spartito.measures.length}] regulated${ + better ? '+' : '-' + }: ${evaluation.qualityScore.toFixed(3)}, ${evaluation.fine ? 'solved' : evaluation.error ? 'error' : 'issue'}, ${measure.regulationHash}` + ); + + stdout?.write(`\x1b[${evaluation.fine ? '32' : evaluation.error ? '31' : '33'}m${better ? '+' : '-'}\x1b[0m`); + }; + + // Global progress: total = all measures, remaining = non-fine measures across all passes + const totalMeasures = spartito.measures.length; + const computeRemaining = () => pendingRecords.filter((r) => !r.evaluation?.fine).length; + const wrappedOnProgress = onProgress + ? (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => { + onProgress(measure, evaluation, better, { pass: progress.pass, remaining: computeRemaining(), total: totalMeasures }); + } + : undefined; + + onPassStart?.(1, 'Imperfect', computeRemaining()); + counting.tryTimes += await solveMeasureRecords( + pendingRecords, + onUpdate, + stdout, + { stopLoss: 0.05, quotaMax: 200, quotaFactor: 3, ptFactor: 1 }, + PendingCondition.Imperfect, + 1, + wrappedOnProgress + ); + onPassStart?.(2, 'NotFine', computeRemaining()); + counting.tryTimes += await solveMeasureRecords( + pendingRecords, + onUpdate, + stdout, + { stopLoss: 0.08, quotaMax: 1000, quotaFactor: 20, ptFactor: 1.6 }, + PendingCondition.NotFine, + 2, + wrappedOnProgress + ); + onPassStart?.(3, 'ErrorOnly', computeRemaining()); + counting.tryTimes += await solveMeasureRecords( + pendingRecords, + onUpdate, + stdout, + { stopLoss: 0.08, quotaMax: 1000, quotaFactor: 40, ptFactor: 3 }, + PendingCondition.ErrorOnly, + 3, + wrappedOnProgress + ); + + pendingRecords.forEach(({ evaluation, baseQuality, current, origin }) => { + if (evaluation.fine) ++counting.solved; + else if (evaluation.error) ++counting.fatal; + else ++counting.issue; + + if (evaluation.qualityScore > baseQuality || !baseQuality) { + solutionStore.set(origin.regulationHash0, { ...current.asSolution(origin), priority: -current?.solutionStat?.loss! }); + if (current.regulationHash !== origin.regulationHash0) + solutionStore.set(current.regulationHash, { ...current.asSolution(), priority: -current?.solutionStat?.loss! }); + //console.log('better:', current.measureIndex, evaluation.qualityScore, baseQuality); + } + + if (!evaluation.fine) { + onSaveIssueMeasure?.({ + measureIndex: current.measureIndex, + measure: new starry.EditableMeasure(current), + status: evaluation.error ? MeasureStatus.Fatal : MeasureStatus.Issue, + }); + } + }); + + const t1 = Date.now(); + const pickerCost = pickers.reduce((cost, picker) => cost + picker.cost, 0); + + const qualityScore = spartito.qualityScore; + const totalCost = t1 - t0; + + logger?.info('[regulateWithBeadSolver] done in ', totalCost, 'ms, qualityScore:', qualityScore); + + // zero 'cached' statistics for freshOnly mode + if (freshOnly) counting.cached = 0; + + return { + totalCost: t1 - t0, + pickerCost, + measures: counting, + qualityScore, + }; +}; + +const abstractRegulationBeadStats = (stats: RegulationBeadStat[]): RegulationBeadSummary => { + const { totalCost, pickerCost, measureN, timeN } = stats.reduce( + (sum, stat) => ({ + totalCost: sum.totalCost + stat.totalCost, + pickerCost: sum.pickerCost + stat.pickerCost, + measureN: sum.measureN + stat.measures.computed, + timeN: sum.timeN + stat.measures.tryTimes, + }), + { + totalCost: 0, + pickerCost: 0, + measureN: 0, + timeN: 0, + } + ); + + const costPerMeasure = measureN > 0 ? totalCost / measureN : null; + const costPerTime = timeN > 0 ? totalCost / timeN : null; + + const { cached, simple, computed, tryTimes, solved, issue, fatal } = stats.reduce( + (sum, stat) => ({ + cached: sum.cached + stat.measures.cached, + simple: sum.simple + stat.measures.simple, + computed: sum.computed + stat.measures.computed, + tryTimes: sum.tryTimes + stat.measures.tryTimes, + solved: sum.solved + stat.measures.solved, + issue: sum.issue + stat.measures.issue, + fatal: sum.fatal + stat.measures.fatal, + }), + { cached: 0, simple: 0, computed: 0, tryTimes: 0, solved: 0, issue: 0, fatal: 0 } + ); + + return { + scoreN: stats.length, + totalCost, + pickerCost, + costPerMeasure, + costPerTime, + cached, + simple, + computed, + tryTimes, + solved, + issue, + fatal, + }; +}; + +export { regulateWithBeadSolver, abstractRegulationBeadStats, RegulationBeadStat, ProgressInfo }; diff --git a/backend/libs/store.ts b/backend/libs/store.ts new file mode 100644 index 0000000000000000000000000000000000000000..e71730baa265c635eb3427071bcb910cd2d0f519 --- /dev/null +++ b/backend/libs/store.ts @@ -0,0 +1,42 @@ +import { WeakLRUCache } from 'weak-lru-cache'; + +import { RegulationSolution, SpartitoMeasure } from '../../src/starry'; + +const lruCache = new WeakLRUCache(); + +interface SolutionStore { + get: (key: string) => Promise; + set: (key: string, val: RegulationSolution) => Promise; + batchGet: (keys: string[]) => Promise; +} + +// 默认store +const DefaultSolutionStore: SolutionStore = { + async get(key: string) { + return lruCache.getValue(key) as RegulationSolution; + }, + async set(key: string, val: RegulationSolution) { + lruCache.setValue(key, val); + }, + async batchGet(keys: string[]) { + return keys.map((key) => lruCache.getValue(key) as RegulationSolution); + }, +}; + +const enum MeasureStatus { + Discard = -1, + Solved = 0, + Issue = 1, + Fatal = 2, +} + +interface IssueMeasure { + scoreId: string; + measureIndex: number; + measure: SpartitoMeasure; + status: MeasureStatus; +} + +type SaveIssueMeasure = (data: Omit) => void; + +export { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure }; diff --git a/backend/libs/three/Three.Legacy.d.ts b/backend/libs/three/Three.Legacy.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/backend/libs/three/Three.Legacy.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/backend/libs/three/Three.Legacy.js b/backend/libs/three/Three.Legacy.js new file mode 100644 index 0000000000000000000000000000000000000000..b85bd3eaa5427d5c492bb7cd37e6b50f1f9cfd23 --- /dev/null +++ b/backend/libs/three/Three.Legacy.js @@ -0,0 +1,1444 @@ +import { Audio } from './audio/Audio.js'; +import { AudioAnalyser } from './audio/AudioAnalyser.js'; +import { PerspectiveCamera } from './cameras/PerspectiveCamera.js'; +import { FlatShading, sRGBEncoding, LinearEncoding, StaticDrawUsage, DynamicDrawUsage, TrianglesDrawMode } from './constants.js'; +import { + Float64BufferAttribute, + Float32BufferAttribute, + Uint32BufferAttribute, + Int32BufferAttribute, + Uint16BufferAttribute, + Int16BufferAttribute, + Uint8ClampedBufferAttribute, + Uint8BufferAttribute, + Int8BufferAttribute, + BufferAttribute, +} from './core/BufferAttribute.js'; +import { BufferGeometry } from './core/BufferGeometry.js'; +import { InterleavedBuffer } from './core/InterleavedBuffer.js'; +import { Object3D } from './core/Object3D.js'; +import { Uniform } from './core/Uniform.js'; +import { Curve } from './extras/core/Curve.js'; +import { Path } from './extras/core/Path.js'; +import { AxesHelper } from './helpers/AxesHelper.js'; +import { BoxHelper } from './helpers/BoxHelper.js'; +import { GridHelper } from './helpers/GridHelper.js'; +import { SkeletonHelper } from './helpers/SkeletonHelper.js'; +import { EdgesGeometry } from './geometries/EdgesGeometry.js'; +import { ExtrudeGeometry } from './geometries/ExtrudeGeometry.js'; +import { ShapeGeometry } from './geometries/ShapeGeometry.js'; +import { WireframeGeometry } from './geometries/WireframeGeometry.js'; +import { Light } from './lights/Light.js'; +import { Loader } from './loaders/Loader.js'; +import { LoaderUtils } from './loaders/LoaderUtils.js'; +import { FileLoader } from './loaders/FileLoader.js'; +import { AudioLoader } from './loaders/AudioLoader.js'; +import { CubeTextureLoader } from './loaders/CubeTextureLoader.js'; +import { DataTextureLoader } from './loaders/DataTextureLoader.js'; +import { TextureLoader } from './loaders/TextureLoader.js'; +import { Material } from './materials/Material.js'; +import { LineBasicMaterial } from './materials/LineBasicMaterial.js'; +import { PointsMaterial } from './materials/PointsMaterial.js'; +import { ShaderMaterial } from './materials/ShaderMaterial.js'; +import { Box2 } from './math/Box2.js'; +import { Box3 } from './math/Box3.js'; +import { Sphere } from './math/Sphere.js'; +import { Color } from './math/Color.js'; +import { Frustum } from './math/Frustum.js'; +import { Line3 } from './math/Line3.js'; +import * as MathUtils from './math/MathUtils.js'; +import { Matrix3 } from './math/Matrix3.js'; +import { Matrix4 } from './math/Matrix4.js'; +import { Plane } from './math/Plane.js'; +import { Quaternion } from './math/Quaternion.js'; +import { Ray } from './math/Ray.js'; +import { Triangle } from './math/Triangle.js'; +import { Vector2 } from './math/Vector2.js'; +import { Vector3 } from './math/Vector3.js'; +import { Vector4 } from './math/Vector4.js'; +import { Mesh } from './objects/Mesh.js'; +import { LineSegments } from './objects/LineSegments.js'; +import { Points } from './objects/Points.js'; +import { Sprite } from './objects/Sprite.js'; +import { SkinnedMesh } from './objects/SkinnedMesh.js'; +import { WebGLRenderer } from './renderers/WebGLRenderer.js'; +import { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js'; +import { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js'; +import { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js'; +import { ImageUtils } from './extras/ImageUtils.js'; +import { Shape } from './extras/core/Shape.js'; +import { CubeCamera } from './cameras/CubeCamera.js'; +import { Scene } from './scenes/Scene.js'; + +export { MathUtils as Math }; + +export const LineStrip = 0; +export const LinePieces = 1; +export const NoColors = 0; +export const FaceColors = 1; +export const VertexColors = 2; + +export function MeshFaceMaterial(materials) { + console.warn('THREE.MeshFaceMaterial has been removed. Use an Array instead.'); + return materials; +} + +export function MultiMaterial(materials = []) { + console.warn('THREE.MultiMaterial has been removed. Use an Array instead.'); + materials.isMultiMaterial = true; + materials.materials = materials; + materials.clone = function () { + return materials.slice(); + }; + + return materials; +} + +export function PointCloud(geometry, material) { + console.warn('THREE.PointCloud has been renamed to THREE.Points.'); + return new Points(geometry, material); +} + +export function Particle(material) { + console.warn('THREE.Particle has been renamed to THREE.Sprite.'); + return new Sprite(material); +} + +export function ParticleSystem(geometry, material) { + console.warn('THREE.ParticleSystem has been renamed to THREE.Points.'); + return new Points(geometry, material); +} + +export function PointCloudMaterial(parameters) { + console.warn('THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.'); + return new PointsMaterial(parameters); +} + +export function ParticleBasicMaterial(parameters) { + console.warn('THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.'); + return new PointsMaterial(parameters); +} + +export function ParticleSystemMaterial(parameters) { + console.warn('THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.'); + return new PointsMaterial(parameters); +} + +export function Vertex(x, y, z) { + console.warn('THREE.Vertex has been removed. Use THREE.Vector3 instead.'); + return new Vector3(x, y, z); +} + +// + +export function DynamicBufferAttribute(array, itemSize) { + console.warn('THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.'); + return new BufferAttribute(array, itemSize).setUsage(DynamicDrawUsage); +} + +export function Int8Attribute(array, itemSize) { + console.warn('THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.'); + return new Int8BufferAttribute(array, itemSize); +} + +export function Uint8Attribute(array, itemSize) { + console.warn('THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.'); + return new Uint8BufferAttribute(array, itemSize); +} + +export function Uint8ClampedAttribute(array, itemSize) { + console.warn('THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.'); + return new Uint8ClampedBufferAttribute(array, itemSize); +} + +export function Int16Attribute(array, itemSize) { + console.warn('THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.'); + return new Int16BufferAttribute(array, itemSize); +} + +export function Uint16Attribute(array, itemSize) { + console.warn('THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.'); + return new Uint16BufferAttribute(array, itemSize); +} + +export function Int32Attribute(array, itemSize) { + console.warn('THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.'); + return new Int32BufferAttribute(array, itemSize); +} + +export function Uint32Attribute(array, itemSize) { + console.warn('THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.'); + return new Uint32BufferAttribute(array, itemSize); +} + +export function Float32Attribute(array, itemSize) { + console.warn('THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.'); + return new Float32BufferAttribute(array, itemSize); +} + +export function Float64Attribute(array, itemSize) { + console.warn('THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.'); + return new Float64BufferAttribute(array, itemSize); +} + +// + +Curve.create = function (construct, getPoint) { + console.log('THREE.Curve.create() has been deprecated'); + + construct.prototype = Object.create(Curve.prototype); + construct.prototype.constructor = construct; + construct.prototype.getPoint = getPoint; + + return construct; +}; + +// + +Path.prototype.fromPoints = function (points) { + console.warn('THREE.Path: .fromPoints() has been renamed to .setFromPoints().'); + return this.setFromPoints(points); +}; + +// + +export function AxisHelper(size) { + console.warn('THREE.AxisHelper has been renamed to THREE.AxesHelper.'); + return new AxesHelper(size); +} + +export function BoundingBoxHelper(object, color) { + console.warn('THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.'); + return new BoxHelper(object, color); +} + +export function EdgesHelper(object, hex) { + console.warn('THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.'); + return new LineSegments(new EdgesGeometry(object.geometry), new LineBasicMaterial({ color: hex !== undefined ? hex : 0xffffff })); +} + +GridHelper.prototype.setColors = function () { + console.error('THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.'); +}; + +SkeletonHelper.prototype.update = function () { + console.error('THREE.SkeletonHelper: update() no longer needs to be called.'); +}; + +export function WireframeHelper(object, hex) { + console.warn('THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.'); + return new LineSegments(new WireframeGeometry(object.geometry), new LineBasicMaterial({ color: hex !== undefined ? hex : 0xffffff })); +} + +// + +Loader.prototype.extractUrlBase = function (url) { + console.warn('THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.'); + return LoaderUtils.extractUrlBase(url); +}; + +Loader.Handlers = { + add: function (/* regex, loader */) { + console.error('THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.'); + }, + + get: function (/* file */) { + console.error('THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.'); + }, +}; + +export function XHRLoader(manager) { + console.warn('THREE.XHRLoader has been renamed to THREE.FileLoader.'); + return new FileLoader(manager); +} + +export function BinaryTextureLoader(manager) { + console.warn('THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.'); + return new DataTextureLoader(manager); +} + +// + +Box2.prototype.center = function (optionalTarget) { + console.warn('THREE.Box2: .center() has been renamed to .getCenter().'); + return this.getCenter(optionalTarget); +}; + +Box2.prototype.empty = function () { + console.warn('THREE.Box2: .empty() has been renamed to .isEmpty().'); + return this.isEmpty(); +}; + +Box2.prototype.isIntersectionBox = function (box) { + console.warn('THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().'); + return this.intersectsBox(box); +}; + +Box2.prototype.size = function (optionalTarget) { + console.warn('THREE.Box2: .size() has been renamed to .getSize().'); + return this.getSize(optionalTarget); +}; + +// + +Box3.prototype.center = function (optionalTarget) { + console.warn('THREE.Box3: .center() has been renamed to .getCenter().'); + return this.getCenter(optionalTarget); +}; + +Box3.prototype.empty = function () { + console.warn('THREE.Box3: .empty() has been renamed to .isEmpty().'); + return this.isEmpty(); +}; + +Box3.prototype.isIntersectionBox = function (box) { + console.warn('THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().'); + return this.intersectsBox(box); +}; + +Box3.prototype.isIntersectionSphere = function (sphere) { + console.warn('THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().'); + return this.intersectsSphere(sphere); +}; + +Box3.prototype.size = function (optionalTarget) { + console.warn('THREE.Box3: .size() has been renamed to .getSize().'); + return this.getSize(optionalTarget); +}; + +// + +Sphere.prototype.empty = function () { + console.warn('THREE.Sphere: .empty() has been renamed to .isEmpty().'); + return this.isEmpty(); +}; + +// + +Frustum.prototype.setFromMatrix = function (m) { + console.warn('THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().'); + return this.setFromProjectionMatrix(m); +}; + +// + +Line3.prototype.center = function (optionalTarget) { + console.warn('THREE.Line3: .center() has been renamed to .getCenter().'); + return this.getCenter(optionalTarget); +}; + +// + +Matrix3.prototype.flattenToArrayOffset = function (array, offset) { + console.warn('THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.'); + return this.toArray(array, offset); +}; + +Matrix3.prototype.multiplyVector3 = function (vector) { + console.warn('THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.'); + return vector.applyMatrix3(this); +}; + +Matrix3.prototype.multiplyVector3Array = function (/* a */) { + console.error('THREE.Matrix3: .multiplyVector3Array() has been removed.'); +}; + +Matrix3.prototype.applyToBufferAttribute = function (attribute) { + console.warn('THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.'); + return attribute.applyMatrix3(this); +}; + +Matrix3.prototype.applyToVector3Array = function (/* array, offset, length */) { + console.error('THREE.Matrix3: .applyToVector3Array() has been removed.'); +}; + +Matrix3.prototype.getInverse = function (matrix) { + console.warn('THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.'); + return this.copy(matrix).invert(); +}; + +// + +Matrix4.prototype.extractPosition = function (m) { + console.warn('THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().'); + return this.copyPosition(m); +}; + +Matrix4.prototype.flattenToArrayOffset = function (array, offset) { + console.warn('THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.'); + return this.toArray(array, offset); +}; + +Matrix4.prototype.getPosition = function () { + console.warn('THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.'); + return new Vector3().setFromMatrixColumn(this, 3); +}; + +Matrix4.prototype.setRotationFromQuaternion = function (q) { + console.warn('THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().'); + return this.makeRotationFromQuaternion(q); +}; + +Matrix4.prototype.multiplyToArray = function () { + console.warn('THREE.Matrix4: .multiplyToArray() has been removed.'); +}; + +Matrix4.prototype.multiplyVector3 = function (vector) { + console.warn('THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.'); + return vector.applyMatrix4(this); +}; + +Matrix4.prototype.multiplyVector4 = function (vector) { + console.warn('THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.'); + return vector.applyMatrix4(this); +}; + +Matrix4.prototype.multiplyVector3Array = function (/* a */) { + console.error('THREE.Matrix4: .multiplyVector3Array() has been removed.'); +}; + +Matrix4.prototype.rotateAxis = function (v) { + console.warn('THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.'); + v.transformDirection(this); +}; + +Matrix4.prototype.crossVector = function (vector) { + console.warn('THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.'); + return vector.applyMatrix4(this); +}; + +Matrix4.prototype.translate = function () { + console.error('THREE.Matrix4: .translate() has been removed.'); +}; + +Matrix4.prototype.rotateX = function () { + console.error('THREE.Matrix4: .rotateX() has been removed.'); +}; + +Matrix4.prototype.rotateY = function () { + console.error('THREE.Matrix4: .rotateY() has been removed.'); +}; + +Matrix4.prototype.rotateZ = function () { + console.error('THREE.Matrix4: .rotateZ() has been removed.'); +}; + +Matrix4.prototype.rotateByAxis = function () { + console.error('THREE.Matrix4: .rotateByAxis() has been removed.'); +}; + +Matrix4.prototype.applyToBufferAttribute = function (attribute) { + console.warn('THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.'); + return attribute.applyMatrix4(this); +}; + +Matrix4.prototype.applyToVector3Array = function (/* array, offset, length */) { + console.error('THREE.Matrix4: .applyToVector3Array() has been removed.'); +}; + +Matrix4.prototype.makeFrustum = function (left, right, bottom, top, near, far) { + console.warn('THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.'); + return this.makePerspective(left, right, top, bottom, near, far); +}; + +Matrix4.prototype.getInverse = function (matrix) { + console.warn('THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.'); + return this.copy(matrix).invert(); +}; + +// + +Plane.prototype.isIntersectionLine = function (line) { + console.warn('THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().'); + return this.intersectsLine(line); +}; + +// + +Quaternion.prototype.multiplyVector3 = function (vector) { + console.warn('THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.'); + return vector.applyQuaternion(this); +}; + +Quaternion.prototype.inverse = function () { + console.warn('THREE.Quaternion: .inverse() has been renamed to invert().'); + return this.invert(); +}; + +// + +Ray.prototype.isIntersectionBox = function (box) { + console.warn('THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().'); + return this.intersectsBox(box); +}; + +Ray.prototype.isIntersectionPlane = function (plane) { + console.warn('THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().'); + return this.intersectsPlane(plane); +}; + +Ray.prototype.isIntersectionSphere = function (sphere) { + console.warn('THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().'); + return this.intersectsSphere(sphere); +}; + +// + +Triangle.prototype.area = function () { + console.warn('THREE.Triangle: .area() has been renamed to .getArea().'); + return this.getArea(); +}; + +Triangle.prototype.barycoordFromPoint = function (point, target) { + console.warn('THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().'); + return this.getBarycoord(point, target); +}; + +Triangle.prototype.midpoint = function (target) { + console.warn('THREE.Triangle: .midpoint() has been renamed to .getMidpoint().'); + return this.getMidpoint(target); +}; + +Triangle.prototypenormal = function (target) { + console.warn('THREE.Triangle: .normal() has been renamed to .getNormal().'); + return this.getNormal(target); +}; + +Triangle.prototype.plane = function (target) { + console.warn('THREE.Triangle: .plane() has been renamed to .getPlane().'); + return this.getPlane(target); +}; + +Triangle.barycoordFromPoint = function (point, a, b, c, target) { + console.warn('THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().'); + return Triangle.getBarycoord(point, a, b, c, target); +}; + +Triangle.normal = function (a, b, c, target) { + console.warn('THREE.Triangle: .normal() has been renamed to .getNormal().'); + return Triangle.getNormal(a, b, c, target); +}; + +// + +Shape.prototype.extractAllPoints = function (divisions) { + console.warn('THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.'); + return this.extractPoints(divisions); +}; + +Shape.prototype.extrude = function (options) { + console.warn('THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.'); + return new ExtrudeGeometry(this, options); +}; + +Shape.prototype.makeGeometry = function (options) { + console.warn('THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.'); + return new ShapeGeometry(this, options); +}; + +// + +Vector2.prototype.fromAttribute = function (attribute, index, offset) { + console.warn('THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().'); + return this.fromBufferAttribute(attribute, index, offset); +}; + +Vector2.prototype.distanceToManhattan = function (v) { + console.warn('THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().'); + return this.manhattanDistanceTo(v); +}; + +Vector2.prototype.lengthManhattan = function () { + console.warn('THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().'); + return this.manhattanLength(); +}; + +// + +Vector3.prototype.setEulerFromRotationMatrix = function () { + console.error('THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.'); +}; + +Vector3.prototype.setEulerFromQuaternion = function () { + console.error('THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.'); +}; + +Vector3.prototype.getPositionFromMatrix = function (m) { + console.warn('THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().'); + return this.setFromMatrixPosition(m); +}; + +Vector3.prototype.getScaleFromMatrix = function (m) { + console.warn('THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().'); + return this.setFromMatrixScale(m); +}; + +Vector3.prototype.getColumnFromMatrix = function (index, matrix) { + console.warn('THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().'); + return this.setFromMatrixColumn(matrix, index); +}; + +Vector3.prototype.applyProjection = function (m) { + console.warn('THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.'); + return this.applyMatrix4(m); +}; + +Vector3.prototype.fromAttribute = function (attribute, index, offset) { + console.warn('THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().'); + return this.fromBufferAttribute(attribute, index, offset); +}; + +Vector3.prototype.distanceToManhattan = function (v) { + console.warn('THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().'); + return this.manhattanDistanceTo(v); +}; + +Vector3.prototype.lengthManhattan = function () { + console.warn('THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().'); + return this.manhattanLength(); +}; + +// + +Vector4.prototype.fromAttribute = function (attribute, index, offset) { + console.warn('THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().'); + return this.fromBufferAttribute(attribute, index, offset); +}; + +Vector4.prototype.lengthManhattan = function () { + console.warn('THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().'); + return this.manhattanLength(); +}; + +// + +Object3D.prototype.getChildByName = function (name) { + console.warn('THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().'); + return this.getObjectByName(name); +}; + +Object3D.prototype.renderDepth = function () { + console.warn('THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.'); +}; + +Object3D.prototype.translate = function (distance, axis) { + console.warn('THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.'); + return this.translateOnAxis(axis, distance); +}; + +Object3D.prototype.getWorldRotation = function () { + console.error('THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.'); +}; + +Object3D.prototype.applyMatrix = function (matrix) { + console.warn('THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().'); + return this.applyMatrix4(matrix); +}; + +Object.defineProperties(Object3D.prototype, { + eulerOrder: { + get: function () { + console.warn('THREE.Object3D: .eulerOrder is now .rotation.order.'); + return this.rotation.order; + }, + set: function (value) { + console.warn('THREE.Object3D: .eulerOrder is now .rotation.order.'); + this.rotation.order = value; + }, + }, + useQuaternion: { + get: function () { + console.warn('THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.'); + }, + set: function () { + console.warn('THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.'); + }, + }, +}); + +Mesh.prototype.setDrawMode = function () { + console.error( + 'THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' + ); +}; + +Object.defineProperties(Mesh.prototype, { + drawMode: { + get: function () { + console.error('THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.'); + return TrianglesDrawMode; + }, + set: function () { + console.error( + 'THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.' + ); + }, + }, +}); + +SkinnedMesh.prototype.initBones = function () { + console.error('THREE.SkinnedMesh: initBones() has been removed.'); +}; + +// + +PerspectiveCamera.prototype.setLens = function (focalLength, filmGauge) { + console.warn('THREE.PerspectiveCamera.setLens is deprecated. ' + 'Use .setFocalLength and .filmGauge for a photographic setup.'); + + if (filmGauge !== undefined) this.filmGauge = filmGauge; + this.setFocalLength(focalLength); +}; + +// + +Object.defineProperties(Light.prototype, { + onlyShadow: { + set: function () { + console.warn('THREE.Light: .onlyShadow has been removed.'); + }, + }, + shadowCameraFov: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraFov is now .shadow.camera.fov.'); + this.shadow.camera.fov = value; + }, + }, + shadowCameraLeft: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraLeft is now .shadow.camera.left.'); + this.shadow.camera.left = value; + }, + }, + shadowCameraRight: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraRight is now .shadow.camera.right.'); + this.shadow.camera.right = value; + }, + }, + shadowCameraTop: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraTop is now .shadow.camera.top.'); + this.shadow.camera.top = value; + }, + }, + shadowCameraBottom: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.'); + this.shadow.camera.bottom = value; + }, + }, + shadowCameraNear: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraNear is now .shadow.camera.near.'); + this.shadow.camera.near = value; + }, + }, + shadowCameraFar: { + set: function (value) { + console.warn('THREE.Light: .shadowCameraFar is now .shadow.camera.far.'); + this.shadow.camera.far = value; + }, + }, + shadowCameraVisible: { + set: function () { + console.warn('THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.'); + }, + }, + shadowBias: { + set: function (value) { + console.warn('THREE.Light: .shadowBias is now .shadow.bias.'); + this.shadow.bias = value; + }, + }, + shadowDarkness: { + set: function () { + console.warn('THREE.Light: .shadowDarkness has been removed.'); + }, + }, + shadowMapWidth: { + set: function (value) { + console.warn('THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.'); + this.shadow.mapSize.width = value; + }, + }, + shadowMapHeight: { + set: function (value) { + console.warn('THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.'); + this.shadow.mapSize.height = value; + }, + }, +}); + +// + +Object.defineProperties(BufferAttribute.prototype, { + length: { + get: function () { + console.warn('THREE.BufferAttribute: .length has been deprecated. Use .count instead.'); + return this.array.length; + }, + }, + dynamic: { + get: function () { + console.warn('THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.'); + return this.usage === DynamicDrawUsage; + }, + set: function (/* value */) { + console.warn('THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.'); + this.setUsage(DynamicDrawUsage); + }, + }, +}); + +BufferAttribute.prototype.setDynamic = function (value) { + console.warn('THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.'); + this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage); + return this; +}; + +(BufferAttribute.prototype.copyIndicesArray = function (/* indices */) { + console.error('THREE.BufferAttribute: .copyIndicesArray() has been removed.'); +}), + (BufferAttribute.prototype.setArray = function (/* array */) { + console.error('THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers'); + }); + +// + +BufferGeometry.prototype.addIndex = function (index) { + console.warn('THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().'); + this.setIndex(index); +}; + +BufferGeometry.prototype.addAttribute = function (name, attribute) { + console.warn('THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().'); + + if (!(attribute && attribute.isBufferAttribute) && !(attribute && attribute.isInterleavedBufferAttribute)) { + console.warn('THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).'); + + return this.setAttribute(name, new BufferAttribute(arguments[1], arguments[2])); + } + + if (name === 'index') { + console.warn('THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.'); + this.setIndex(attribute); + + return this; + } + + return this.setAttribute(name, attribute); +}; + +BufferGeometry.prototype.addDrawCall = function (start, count, indexOffset) { + if (indexOffset !== undefined) { + console.warn('THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.'); + } + + console.warn('THREE.BufferGeometry: .addDrawCall() is now .addGroup().'); + this.addGroup(start, count); +}; + +BufferGeometry.prototype.clearDrawCalls = function () { + console.warn('THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().'); + this.clearGroups(); +}; + +BufferGeometry.prototype.computeOffsets = function () { + console.warn('THREE.BufferGeometry: .computeOffsets() has been removed.'); +}; + +BufferGeometry.prototype.removeAttribute = function (name) { + console.warn('THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().'); + + return this.deleteAttribute(name); +}; + +BufferGeometry.prototype.applyMatrix = function (matrix) { + console.warn('THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().'); + return this.applyMatrix4(matrix); +}; + +Object.defineProperties(BufferGeometry.prototype, { + drawcalls: { + get: function () { + console.error('THREE.BufferGeometry: .drawcalls has been renamed to .groups.'); + return this.groups; + }, + }, + offsets: { + get: function () { + console.warn('THREE.BufferGeometry: .offsets has been renamed to .groups.'); + return this.groups; + }, + }, +}); + +InterleavedBuffer.prototype.setDynamic = function (value) { + console.warn('THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.'); + this.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage); + return this; +}; + +InterleavedBuffer.prototype.setArray = function (/* array */) { + console.error('THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers'); +}; + +// + +ExtrudeGeometry.prototype.getArrays = function () { + console.error('THREE.ExtrudeGeometry: .getArrays() has been removed.'); +}; + +ExtrudeGeometry.prototype.addShapeList = function () { + console.error('THREE.ExtrudeGeometry: .addShapeList() has been removed.'); +}; + +ExtrudeGeometry.prototype.addShape = function () { + console.error('THREE.ExtrudeGeometry: .addShape() has been removed.'); +}; + +// + +Scene.prototype.dispose = function () { + console.error('THREE.Scene: .dispose() has been removed.'); +}; + +// + +Uniform.prototype.onUpdate = function () { + console.warn('THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.'); + return this; +}; + +// + +Object.defineProperties(Material.prototype, { + wrapAround: { + get: function () { + console.warn('THREE.Material: .wrapAround has been removed.'); + }, + set: function () { + console.warn('THREE.Material: .wrapAround has been removed.'); + }, + }, + + overdraw: { + get: function () { + console.warn('THREE.Material: .overdraw has been removed.'); + }, + set: function () { + console.warn('THREE.Material: .overdraw has been removed.'); + }, + }, + + wrapRGB: { + get: function () { + console.warn('THREE.Material: .wrapRGB has been removed.'); + return new Color(); + }, + }, + + shading: { + get: function () { + console.error('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.'); + }, + set: function (value) { + console.warn('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.'); + this.flatShading = value === FlatShading; + }, + }, + + stencilMask: { + get: function () { + console.warn('THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.'); + return this.stencilFuncMask; + }, + set: function (value) { + console.warn('THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.'); + this.stencilFuncMask = value; + }, + }, + + vertexTangents: { + get: function () { + console.warn('THREE.' + this.type + ': .vertexTangents has been removed.'); + }, + set: function () { + console.warn('THREE.' + this.type + ': .vertexTangents has been removed.'); + }, + }, +}); + +Object.defineProperties(ShaderMaterial.prototype, { + derivatives: { + get: function () { + console.warn('THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.'); + return this.extensions.derivatives; + }, + set: function (value) { + console.warn('THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.'); + this.extensions.derivatives = value; + }, + }, +}); + +// + +WebGLRenderer.prototype.clearTarget = function (renderTarget, color, depth, stencil) { + console.warn('THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.'); + this.setRenderTarget(renderTarget); + this.clear(color, depth, stencil); +}; + +WebGLRenderer.prototype.animate = function (callback) { + console.warn('THREE.WebGLRenderer: .animate() is now .setAnimationLoop().'); + this.setAnimationLoop(callback); +}; + +WebGLRenderer.prototype.getCurrentRenderTarget = function () { + console.warn('THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().'); + return this.getRenderTarget(); +}; + +WebGLRenderer.prototype.getMaxAnisotropy = function () { + console.warn('THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().'); + return this.capabilities.getMaxAnisotropy(); +}; + +WebGLRenderer.prototype.getPrecision = function () { + console.warn('THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.'); + return this.capabilities.precision; +}; + +WebGLRenderer.prototype.resetGLState = function () { + console.warn('THREE.WebGLRenderer: .resetGLState() is now .state.reset().'); + return this.state.reset(); +}; + +WebGLRenderer.prototype.supportsFloatTextures = function () { + console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."); + return this.extensions.get('OES_texture_float'); +}; + +WebGLRenderer.prototype.supportsHalfFloatTextures = function () { + console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."); + return this.extensions.get('OES_texture_half_float'); +}; + +WebGLRenderer.prototype.supportsStandardDerivatives = function () { + console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."); + return this.extensions.get('OES_standard_derivatives'); +}; + +WebGLRenderer.prototype.supportsCompressedTextureS3TC = function () { + console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."); + return this.extensions.get('WEBGL_compressed_texture_s3tc'); +}; + +WebGLRenderer.prototype.supportsCompressedTexturePVRTC = function () { + console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."); + return this.extensions.get('WEBGL_compressed_texture_pvrtc'); +}; + +WebGLRenderer.prototype.supportsBlendMinMax = function () { + console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."); + return this.extensions.get('EXT_blend_minmax'); +}; + +WebGLRenderer.prototype.supportsVertexTextures = function () { + console.warn('THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.'); + return this.capabilities.vertexTextures; +}; + +WebGLRenderer.prototype.supportsInstancedArrays = function () { + console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."); + return this.extensions.get('ANGLE_instanced_arrays'); +}; + +WebGLRenderer.prototype.enableScissorTest = function (boolean) { + console.warn('THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().'); + this.setScissorTest(boolean); +}; + +WebGLRenderer.prototype.initMaterial = function () { + console.warn('THREE.WebGLRenderer: .initMaterial() has been removed.'); +}; + +WebGLRenderer.prototype.addPrePlugin = function () { + console.warn('THREE.WebGLRenderer: .addPrePlugin() has been removed.'); +}; + +WebGLRenderer.prototype.addPostPlugin = function () { + console.warn('THREE.WebGLRenderer: .addPostPlugin() has been removed.'); +}; + +WebGLRenderer.prototype.updateShadowMap = function () { + console.warn('THREE.WebGLRenderer: .updateShadowMap() has been removed.'); +}; + +WebGLRenderer.prototype.setFaceCulling = function () { + console.warn('THREE.WebGLRenderer: .setFaceCulling() has been removed.'); +}; + +WebGLRenderer.prototype.allocTextureUnit = function () { + console.warn('THREE.WebGLRenderer: .allocTextureUnit() has been removed.'); +}; + +WebGLRenderer.prototype.setTexture = function () { + console.warn('THREE.WebGLRenderer: .setTexture() has been removed.'); +}; + +WebGLRenderer.prototype.setTexture2D = function () { + console.warn('THREE.WebGLRenderer: .setTexture2D() has been removed.'); +}; + +WebGLRenderer.prototype.setTextureCube = function () { + console.warn('THREE.WebGLRenderer: .setTextureCube() has been removed.'); +}; + +WebGLRenderer.prototype.getActiveMipMapLevel = function () { + console.warn('THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().'); + return this.getActiveMipmapLevel(); +}; + +Object.defineProperties(WebGLRenderer.prototype, { + shadowMapEnabled: { + get: function () { + return this.shadowMap.enabled; + }, + set: function (value) { + console.warn('THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.'); + this.shadowMap.enabled = value; + }, + }, + shadowMapType: { + get: function () { + return this.shadowMap.type; + }, + set: function (value) { + console.warn('THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.'); + this.shadowMap.type = value; + }, + }, + shadowMapCullFace: { + get: function () { + console.warn('THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.'); + return undefined; + }, + set: function (/* value */) { + console.warn('THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.'); + }, + }, + context: { + get: function () { + console.warn('THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.'); + return this.getContext(); + }, + }, + vr: { + get: function () { + console.warn('THREE.WebGLRenderer: .vr has been renamed to .xr'); + return this.xr; + }, + }, + gammaInput: { + get: function () { + console.warn('THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.'); + return false; + }, + set: function () { + console.warn('THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.'); + }, + }, + gammaOutput: { + get: function () { + console.warn('THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.'); + return false; + }, + set: function (value) { + console.warn('THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.'); + this.outputEncoding = value === true ? sRGBEncoding : LinearEncoding; + }, + }, + toneMappingWhitePoint: { + get: function () { + console.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.'); + return 1.0; + }, + set: function () { + console.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.'); + }, + }, + gammaFactor: { + get: function () { + console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.'); + return 2; + }, + set: function () { + console.warn('THREE.WebGLRenderer: .gammaFactor has been removed.'); + }, + }, +}); + +Object.defineProperties(WebGLShadowMap.prototype, { + cullFace: { + get: function () { + console.warn('THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.'); + return undefined; + }, + set: function (/* cullFace */) { + console.warn('THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.'); + }, + }, + renderReverseSided: { + get: function () { + console.warn('THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.'); + return undefined; + }, + set: function () { + console.warn('THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.'); + }, + }, + renderSingleSided: { + get: function () { + console.warn('THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.'); + return undefined; + }, + set: function () { + console.warn('THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.'); + }, + }, +}); + +export function WebGLRenderTargetCube(width, height, options) { + console.warn('THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).'); + return new WebGLCubeRenderTarget(width, options); +} + +// + +Object.defineProperties(WebGLRenderTarget.prototype, { + wrapS: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.'); + return this.texture.wrapS; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.'); + this.texture.wrapS = value; + }, + }, + wrapT: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.'); + return this.texture.wrapT; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.'); + this.texture.wrapT = value; + }, + }, + magFilter: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.'); + return this.texture.magFilter; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.'); + this.texture.magFilter = value; + }, + }, + minFilter: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.'); + return this.texture.minFilter; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.'); + this.texture.minFilter = value; + }, + }, + anisotropy: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.'); + return this.texture.anisotropy; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.'); + this.texture.anisotropy = value; + }, + }, + offset: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .offset is now .texture.offset.'); + return this.texture.offset; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .offset is now .texture.offset.'); + this.texture.offset = value; + }, + }, + repeat: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .repeat is now .texture.repeat.'); + return this.texture.repeat; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .repeat is now .texture.repeat.'); + this.texture.repeat = value; + }, + }, + format: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .format is now .texture.format.'); + return this.texture.format; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .format is now .texture.format.'); + this.texture.format = value; + }, + }, + type: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .type is now .texture.type.'); + return this.texture.type; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .type is now .texture.type.'); + this.texture.type = value; + }, + }, + generateMipmaps: { + get: function () { + console.warn('THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.'); + return this.texture.generateMipmaps; + }, + set: function (value) { + console.warn('THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.'); + this.texture.generateMipmaps = value; + }, + }, +}); + +// + +Audio.prototype.load = function (file) { + console.warn('THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.'); + const scope = this; + const audioLoader = new AudioLoader(); + audioLoader.load(file, function (buffer) { + scope.setBuffer(buffer); + }); + return this; +}; + +AudioAnalyser.prototype.getData = function () { + console.warn('THREE.AudioAnalyser: .getData() is now .getFrequencyData().'); + return this.getFrequencyData(); +}; + +// + +CubeCamera.prototype.updateCubeMap = function (renderer, scene) { + console.warn('THREE.CubeCamera: .updateCubeMap() is now .update().'); + return this.update(renderer, scene); +}; + +CubeCamera.prototype.clear = function (renderer, color, depth, stencil) { + console.warn('THREE.CubeCamera: .clear() is now .renderTarget.clear().'); + return this.renderTarget.clear(renderer, color, depth, stencil); +}; + +ImageUtils.crossOrigin = undefined; + +ImageUtils.loadTexture = function (url, mapping, onLoad, onError) { + console.warn('THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.'); + + const loader = new TextureLoader(); + loader.setCrossOrigin(this.crossOrigin); + + const texture = loader.load(url, onLoad, undefined, onError); + + if (mapping) texture.mapping = mapping; + + return texture; +}; + +ImageUtils.loadTextureCube = function (urls, mapping, onLoad, onError) { + console.warn('THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.'); + + const loader = new CubeTextureLoader(); + loader.setCrossOrigin(this.crossOrigin); + + const texture = loader.load(urls, onLoad, undefined, onError); + + if (mapping) texture.mapping = mapping; + + return texture; +}; + +ImageUtils.loadCompressedTexture = function () { + console.error('THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.'); +}; + +ImageUtils.loadCompressedTextureCube = function () { + console.error('THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.'); +}; + +// + +export function CanvasRenderer() { + console.error('THREE.CanvasRenderer has been removed'); +} + +// + +export function JSONLoader() { + console.error('THREE.JSONLoader has been removed.'); +} + +// + +export const SceneUtils = { + createMultiMaterialObject: function (/* geometry, materials */) { + console.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js'); + }, + + detach: function (/* child, parent, scene */) { + console.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js'); + }, + + attach: function (/* child, scene, parent */) { + console.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js'); + }, +}; + +// + +export function LensFlare() { + console.error('THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js'); +} + +// + +export function ParametricGeometry() { + console.error('THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js'); + return new BufferGeometry(); +} + +export function TextGeometry() { + console.error('THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js'); + return new BufferGeometry(); +} + +export function FontLoader() { + console.error('THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js'); +} + +export function Font() { + console.error('THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js'); +} + +export function ImmediateRenderObject() { + console.error('THREE.ImmediateRenderObject has been removed.'); +} diff --git a/backend/libs/three/Three.d.ts b/backend/libs/three/Three.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7d91307cfba00d79067a5c6aa116b9c47d5f1405 --- /dev/null +++ b/backend/libs/three/Three.d.ts @@ -0,0 +1,234 @@ +/** + * SRC + */ +export * from './constants'; +export * from './Three.Legacy'; +export * from './utils'; +/** + * Animation + */ +export * from './animation/tracks/VectorKeyframeTrack'; +export * from './animation/tracks/StringKeyframeTrack'; +export * from './animation/tracks/QuaternionKeyframeTrack'; +export * from './animation/tracks/NumberKeyframeTrack'; +export * from './animation/tracks/ColorKeyframeTrack'; +export * from './animation/tracks/BooleanKeyframeTrack'; +export * from './animation/PropertyMixer'; +export * from './animation/PropertyBinding'; +export * from './animation/KeyframeTrack'; +export * from './animation/AnimationUtils'; +export * from './animation/AnimationObjectGroup'; +export * from './animation/AnimationMixer'; +export * from './animation/AnimationClip'; +export * from './animation/AnimationAction'; +/** + * Audio + */ +export * from './audio/AudioListener'; +export * from './audio/PositionalAudio'; +export * from './audio/AudioContext'; +export * from './audio/AudioAnalyser'; +export * from './audio/Audio'; +/** + * Cameras + */ +export * from './cameras/StereoCamera'; +export * from './cameras/PerspectiveCamera'; +export * from './cameras/OrthographicCamera'; +export * from './cameras/CubeCamera'; +export * from './cameras/ArrayCamera'; +export * from './cameras/Camera'; +/** + * Core + */ +export * from './core/Uniform'; +export * from './core/InstancedBufferGeometry'; +export * from './core/BufferGeometry'; +export * from './core/InterleavedBufferAttribute'; +export * from './core/InstancedInterleavedBuffer'; +export * from './core/InterleavedBuffer'; +export * from './core/InstancedBufferAttribute'; +export * from './core/GLBufferAttribute'; +export * from './core/BufferAttribute'; +export * from './core/Object3D'; +export * from './core/Raycaster'; +export * from './core/Layers'; +export * from './core/EventDispatcher'; +export * from './core/Clock'; +/** + * Extras + */ +export * from './extras/curves/Curves'; +export * from './extras/core/Shape'; +export * from './extras/core/Path'; +export * from './extras/core/ShapePath'; +export * from './extras/core/CurvePath'; +export * from './extras/core/Curve'; +export * from './extras/DataUtils'; +export * from './extras/ImageUtils'; +export * from './extras/ShapeUtils'; +export * from './extras/PMREMGenerator'; +/** + * Geometries + */ +export * from './geometries/Geometries'; +/** + * Helpers + */ +export * from './helpers/SpotLightHelper'; +export * from './helpers/SkeletonHelper'; +export * from './helpers/PointLightHelper'; +export * from './helpers/HemisphereLightHelper'; +export * from './helpers/GridHelper'; +export * from './helpers/PolarGridHelper'; +export * from './helpers/DirectionalLightHelper'; +export * from './helpers/CameraHelper'; +export * from './helpers/BoxHelper'; +export * from './helpers/Box3Helper'; +export * from './helpers/PlaneHelper'; +export * from './helpers/ArrowHelper'; +export * from './helpers/AxesHelper'; +/** + * Lights + */ +export * from './lights/SpotLightShadow'; +export * from './lights/SpotLight'; +export * from './lights/PointLight'; +export * from './lights/PointLightShadow'; +export * from './lights/RectAreaLight'; +export * from './lights/HemisphereLight'; +export * from './lights/DirectionalLightShadow'; +export * from './lights/DirectionalLight'; +export * from './lights/AmbientLight'; +export * from './lights/LightShadow'; +export * from './lights/Light'; +export * from './lights/AmbientLightProbe'; +export * from './lights/HemisphereLightProbe'; +export * from './lights/LightProbe'; +/** + * Loaders + */ +export * from './loaders/AnimationLoader'; +export * from './loaders/CompressedTextureLoader'; +export * from './loaders/DataTextureLoader'; +export * from './loaders/CubeTextureLoader'; +export * from './loaders/TextureLoader'; +export * from './loaders/ObjectLoader'; +export * from './loaders/MaterialLoader'; +export * from './loaders/BufferGeometryLoader'; +export * from './loaders/LoadingManager'; +export * from './loaders/ImageLoader'; +export * from './loaders/ImageBitmapLoader'; +export * from './loaders/FileLoader'; +export * from './loaders/Loader'; +export * from './loaders/LoaderUtils'; +export * from './loaders/Cache'; +export * from './loaders/AudioLoader'; +/** + * Materials + */ +export * from './materials/Materials'; +/** + * Math + */ +export * from './math/interpolants/QuaternionLinearInterpolant'; +export * from './math/interpolants/LinearInterpolant'; +export * from './math/interpolants/DiscreteInterpolant'; +export * from './math/interpolants/CubicInterpolant'; +export * from './math/Interpolant'; +export * from './math/Triangle'; +export * from './math/Spherical'; +export * from './math/Cylindrical'; +export * from './math/Plane'; +export * from './math/Frustum'; +export * from './math/Sphere'; +export * from './math/Ray'; +export * from './math/Matrix4'; +export * from './math/Matrix3'; +export * from './math/Box3'; +export * from './math/Box2'; +export * from './math/Line3'; +export * from './math/Euler'; +export * from './math/Vector4'; +export * from './math/Vector3'; +export * from './math/Vector2'; +export * from './math/Quaternion'; +export * from './math/Color'; +export * from './math/SphericalHarmonics3'; +import * as MathUtils from './math/MathUtils'; +export { MathUtils }; +/** + * Objects + */ +export * from './objects/Sprite'; +export * from './objects/LOD'; +export * from './objects/InstancedMesh'; +export * from './objects/SkinnedMesh'; +export * from './objects/Skeleton'; +export * from './objects/Bone'; +export * from './objects/Mesh'; +export * from './objects/LineSegments'; +export * from './objects/LineLoop'; +export * from './objects/Line'; +export * from './objects/Points'; +export * from './objects/Group'; +/** + * Renderers + */ +export * from './renderers/WebGLMultisampleRenderTarget'; +export * from './renderers/WebGLCubeRenderTarget'; +export * from './renderers/WebGLMultipleRenderTargets'; +export * from './renderers/WebGLRenderTarget'; +export * from './renderers/WebGLRenderer'; +export * from './renderers/WebGL1Renderer'; +export * from './renderers/WebGL3DRenderTarget'; +export * from './renderers/WebGLArrayRenderTarget'; +export * from './renderers/shaders/ShaderLib'; +export * from './renderers/shaders/UniformsLib'; +export * from './renderers/shaders/UniformsUtils'; +export * from './renderers/shaders/ShaderChunk'; +export * from './renderers/webgl/WebGLBufferRenderer'; +export * from './renderers/webgl/WebGLCapabilities'; +export * from './renderers/webgl/WebGLClipping'; +export * from './renderers/webgl/WebGLCubeUVMaps'; +export * from './renderers/webgl/WebGLExtensions'; +export * from './renderers/webgl/WebGLGeometries'; +export * from './renderers/webgl/WebGLIndexedBufferRenderer'; +export * from './renderers/webgl/WebGLInfo'; +export * from './renderers/webgl/WebGLLights'; +export * from './renderers/webgl/WebGLObjects'; +export * from './renderers/webgl/WebGLProgram'; +export * from './renderers/webgl/WebGLPrograms'; +export * from './renderers/webgl/WebGLProperties'; +export * from './renderers/webgl/WebGLRenderLists'; +export * from './renderers/webgl/WebGLShader'; +export * from './renderers/webgl/WebGLShadowMap'; +export * from './renderers/webgl/WebGLState'; +export * from './renderers/webgl/WebGLTextures'; +export * from './renderers/webgl/WebGLUniforms'; +export * from './renderers/webxr/WebXR'; +export * from './renderers/webxr/WebXRController'; +export * from './renderers/webxr/WebXRManager'; +export { WebGLUtils } from './renderers/webgl/WebGLUtils.js'; +/** + * Scenes + */ +export * from './scenes/FogExp2'; +export * from './scenes/Fog'; +export * from './scenes/Scene'; +/** + * Textures + */ +export * from './textures/VideoTexture'; +export * from './textures/DataTexture'; +export * from './textures/DataTexture2DArray'; +export * from './textures/DataTexture3D'; +export * from './textures/CompressedTexture'; +export * from './textures/CubeTexture'; +export * from './textures/Data3DTexture'; +export * from './textures/DataArrayTexture'; +export * from './textures/CanvasTexture'; +export * from './textures/DepthTexture'; +export * from './textures/FramebufferTexture'; +export * from './textures/Source'; +export * from './textures/Texture'; diff --git a/backend/libs/three/Three.js b/backend/libs/three/Three.js new file mode 100644 index 0000000000000000000000000000000000000000..5cdc14a3ffdc2a164f655e4d9b38c14637e0b3d3 --- /dev/null +++ b/backend/libs/three/Three.js @@ -0,0 +1,172 @@ +import { REVISION } from './constants.js'; + +export { WebGLMultipleRenderTargets } from './renderers/WebGLMultipleRenderTargets.js'; +export { WebGLMultisampleRenderTarget } from './renderers/WebGLMultisampleRenderTarget.js'; +export { WebGLCubeRenderTarget } from './renderers/WebGLCubeRenderTarget.js'; +export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js'; +export { WebGLRenderer } from './renderers/WebGLRenderer.js'; +export { WebGL1Renderer } from './renderers/WebGL1Renderer.js'; +export { ShaderLib } from './renderers/shaders/ShaderLib.js'; +export { UniformsLib } from './renderers/shaders/UniformsLib.js'; +export { UniformsUtils } from './renderers/shaders/UniformsUtils.js'; +export { ShaderChunk } from './renderers/shaders/ShaderChunk.js'; +export { FogExp2 } from './scenes/FogExp2.js'; +export { Fog } from './scenes/Fog.js'; +export { Scene } from './scenes/Scene.js'; +export { Sprite } from './objects/Sprite.js'; +export { LOD } from './objects/LOD.js'; +export { SkinnedMesh } from './objects/SkinnedMesh.js'; +export { Skeleton } from './objects/Skeleton.js'; +export { Bone } from './objects/Bone.js'; +export { Mesh } from './objects/Mesh.js'; +export { InstancedMesh } from './objects/InstancedMesh.js'; +export { LineSegments } from './objects/LineSegments.js'; +export { LineLoop } from './objects/LineLoop.js'; +export { Line } from './objects/Line.js'; +export { Points } from './objects/Points.js'; +export { Group } from './objects/Group.js'; +export { VideoTexture } from './textures/VideoTexture.js'; +export { FramebufferTexture } from './textures/FramebufferTexture.js'; +export { DataTexture } from './textures/DataTexture.js'; +export { DataTexture2DArray } from './textures/DataTexture2DArray.js'; +export { DataTexture3D } from './textures/DataTexture3D.js'; +export { CompressedTexture } from './textures/CompressedTexture.js'; +export { CubeTexture } from './textures/CubeTexture.js'; +export { CanvasTexture } from './textures/CanvasTexture.js'; +export { DepthTexture } from './textures/DepthTexture.js'; +export { Texture } from './textures/Texture.js'; +export * from './geometries/Geometries.js'; +export * from './materials/Materials.js'; +export { AnimationLoader } from './loaders/AnimationLoader.js'; +export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js'; +export { CubeTextureLoader } from './loaders/CubeTextureLoader.js'; +export { DataTextureLoader } from './loaders/DataTextureLoader.js'; +export { TextureLoader } from './loaders/TextureLoader.js'; +export { ObjectLoader } from './loaders/ObjectLoader.js'; +export { MaterialLoader } from './loaders/MaterialLoader.js'; +export { BufferGeometryLoader } from './loaders/BufferGeometryLoader.js'; +export { DefaultLoadingManager, LoadingManager } from './loaders/LoadingManager.js'; +export { ImageLoader } from './loaders/ImageLoader.js'; +export { ImageBitmapLoader } from './loaders/ImageBitmapLoader.js'; +export { FileLoader } from './loaders/FileLoader.js'; +export { Loader } from './loaders/Loader.js'; +export { LoaderUtils } from './loaders/LoaderUtils.js'; +export { Cache } from './loaders/Cache.js'; +export { AudioLoader } from './loaders/AudioLoader.js'; +export { SpotLight } from './lights/SpotLight.js'; +export { PointLight } from './lights/PointLight.js'; +export { RectAreaLight } from './lights/RectAreaLight.js'; +export { HemisphereLight } from './lights/HemisphereLight.js'; +export { HemisphereLightProbe } from './lights/HemisphereLightProbe.js'; +export { DirectionalLight } from './lights/DirectionalLight.js'; +export { AmbientLight } from './lights/AmbientLight.js'; +export { AmbientLightProbe } from './lights/AmbientLightProbe.js'; +export { Light } from './lights/Light.js'; +export { LightProbe } from './lights/LightProbe.js'; +export { StereoCamera } from './cameras/StereoCamera.js'; +export { PerspectiveCamera } from './cameras/PerspectiveCamera.js'; +export { OrthographicCamera } from './cameras/OrthographicCamera.js'; +export { CubeCamera } from './cameras/CubeCamera.js'; +export { ArrayCamera } from './cameras/ArrayCamera.js'; +export { Camera } from './cameras/Camera.js'; +export { AudioListener } from './audio/AudioListener.js'; +export { PositionalAudio } from './audio/PositionalAudio.js'; +export { AudioContext } from './audio/AudioContext.js'; +export { AudioAnalyser } from './audio/AudioAnalyser.js'; +export { Audio } from './audio/Audio.js'; +export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack.js'; +export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack.js'; +export { QuaternionKeyframeTrack } from './animation/tracks/QuaternionKeyframeTrack.js'; +export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack.js'; +export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack.js'; +export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack.js'; +export { PropertyMixer } from './animation/PropertyMixer.js'; +export { PropertyBinding } from './animation/PropertyBinding.js'; +export { KeyframeTrack } from './animation/KeyframeTrack.js'; +export { AnimationUtils } from './animation/AnimationUtils.js'; +export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js'; +export { AnimationMixer } from './animation/AnimationMixer.js'; +export { AnimationClip } from './animation/AnimationClip.js'; +export { Uniform } from './core/Uniform.js'; +export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js'; +export { BufferGeometry } from './core/BufferGeometry.js'; +export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js'; +export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js'; +export { InterleavedBuffer } from './core/InterleavedBuffer.js'; +export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js'; +export { GLBufferAttribute } from './core/GLBufferAttribute.js'; +export * from './core/BufferAttribute.js'; +export { Object3D } from './core/Object3D.js'; +export { Raycaster } from './core/Raycaster.js'; +export { Layers } from './core/Layers.js'; +export { EventDispatcher } from './core/EventDispatcher.js'; +export { Clock } from './core/Clock.js'; +export { QuaternionLinearInterpolant } from './math/interpolants/QuaternionLinearInterpolant.js'; +export { LinearInterpolant } from './math/interpolants/LinearInterpolant.js'; +export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js'; +export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js'; +export { Interpolant } from './math/Interpolant.js'; +export { Triangle } from './math/Triangle.js'; +export * as MathUtils from './math/MathUtils.js'; +export { Spherical } from './math/Spherical.js'; +export { Cylindrical } from './math/Cylindrical.js'; +export { Plane } from './math/Plane.js'; +export { Frustum } from './math/Frustum.js'; +export { Sphere } from './math/Sphere.js'; +export { Ray } from './math/Ray.js'; +export { Matrix4 } from './math/Matrix4.js'; +export { Matrix3 } from './math/Matrix3.js'; +export { Box3 } from './math/Box3.js'; +export { Box2 } from './math/Box2.js'; +export { Line3 } from './math/Line3.js'; +export { Euler } from './math/Euler.js'; +export { Vector4 } from './math/Vector4.js'; +export { Vector3 } from './math/Vector3.js'; +export { Vector2 } from './math/Vector2.js'; +export { Quaternion } from './math/Quaternion.js'; +export { Color } from './math/Color.js'; +export { SphericalHarmonics3 } from './math/SphericalHarmonics3.js'; +export { SpotLightHelper } from './helpers/SpotLightHelper.js'; +export { SkeletonHelper } from './helpers/SkeletonHelper.js'; +export { PointLightHelper } from './helpers/PointLightHelper.js'; +export { HemisphereLightHelper } from './helpers/HemisphereLightHelper.js'; +export { GridHelper } from './helpers/GridHelper.js'; +export { PolarGridHelper } from './helpers/PolarGridHelper.js'; +export { DirectionalLightHelper } from './helpers/DirectionalLightHelper.js'; +export { CameraHelper } from './helpers/CameraHelper.js'; +export { BoxHelper } from './helpers/BoxHelper.js'; +export { Box3Helper } from './helpers/Box3Helper.js'; +export { PlaneHelper } from './helpers/PlaneHelper.js'; +export { ArrowHelper } from './helpers/ArrowHelper.js'; +export { AxesHelper } from './helpers/AxesHelper.js'; +export * from './extras/curves/Curves.js'; +export { Shape } from './extras/core/Shape.js'; +export { Path } from './extras/core/Path.js'; +export { ShapePath } from './extras/core/ShapePath.js'; +export { CurvePath } from './extras/core/CurvePath.js'; +export { Curve } from './extras/core/Curve.js'; +export { DataUtils } from './extras/DataUtils.js'; +export { ImageUtils } from './extras/ImageUtils.js'; +export { ShapeUtils } from './extras/ShapeUtils.js'; +export { PMREMGenerator } from './extras/PMREMGenerator.js'; +export { WebGLUtils } from './renderers/webgl/WebGLUtils.js'; +export * from './constants.js'; +export * from './Three.Legacy.js'; + +if (typeof __THREE_DEVTOOLS__ !== 'undefined') { + __THREE_DEVTOOLS__.dispatchEvent( + new CustomEvent('register', { + detail: { + revision: REVISION, + }, + }) + ); +} + +if (typeof window !== 'undefined') { + if (window.__THREE__) { + console.warn('WARNING: Multiple instances of Three.js being imported.'); + } else { + window.__THREE__ = REVISION; + } +} diff --git a/backend/libs/three/animation/AnimationAction.d.ts b/backend/libs/three/animation/AnimationAction.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..facb265f9ac221e33f3690207edeb4663f0e0549 --- /dev/null +++ b/backend/libs/three/animation/AnimationAction.d.ts @@ -0,0 +1,86 @@ +import { AnimationMixer } from './AnimationMixer'; +import { AnimationClip } from './AnimationClip'; +import { AnimationActionLoopStyles, AnimationBlendMode } from '../constants'; +import { Object3D } from '../core/Object3D'; +// Animation //////////////////////////////////////////////////////////////////////////////////////// + +export class AnimationAction { + constructor(mixer: AnimationMixer, clip: AnimationClip, localRoot?: Object3D, blendMode?: AnimationBlendMode); + + blendMode: AnimationBlendMode; + + /** + * @default THREE.LoopRepeat + */ + loop: AnimationActionLoopStyles; + + /** + * @default 0 + */ + time: number; + + /** + * @default 1 + */ + timeScale: number; + + /** + * @default 1 + */ + weight: number; + + /** + * @default Infinity + */ + repetitions: number; + + /** + * @default false + */ + paused: boolean; + + /** + * @default true + */ + enabled: boolean; + + /** + * @default false + */ + clampWhenFinished: boolean; + + /** + * @default true + */ + zeroSlopeAtStart: boolean; + + /** + * @default true + */ + zeroSlopeAtEnd: boolean; + + play(): AnimationAction; + stop(): AnimationAction; + reset(): AnimationAction; + isRunning(): boolean; + isScheduled(): boolean; + startAt(time: number): AnimationAction; + setLoop(mode: AnimationActionLoopStyles, repetitions: number): AnimationAction; + setEffectiveWeight(weight: number): AnimationAction; + getEffectiveWeight(): number; + fadeIn(duration: number): AnimationAction; + fadeOut(duration: number): AnimationAction; + crossFadeFrom(fadeOutAction: AnimationAction, duration: number, warp: boolean): AnimationAction; + crossFadeTo(fadeInAction: AnimationAction, duration: number, warp: boolean): AnimationAction; + stopFading(): AnimationAction; + setEffectiveTimeScale(timeScale: number): AnimationAction; + getEffectiveTimeScale(): number; + setDuration(duration: number): AnimationAction; + syncWith(action: AnimationAction): AnimationAction; + halt(duration: number): AnimationAction; + warp(statTimeScale: number, endTimeScale: number, duration: number): AnimationAction; + stopWarping(): AnimationAction; + getMixer(): AnimationMixer; + getClip(): AnimationClip; + getRoot(): Object3D; +} diff --git a/backend/libs/three/animation/AnimationAction.js b/backend/libs/three/animation/AnimationAction.js new file mode 100644 index 0000000000000000000000000000000000000000..7639796e509929039c5bce32bdb361982d444402 --- /dev/null +++ b/backend/libs/three/animation/AnimationAction.js @@ -0,0 +1,553 @@ +import { + WrapAroundEnding, + ZeroCurvatureEnding, + ZeroSlopeEnding, + LoopPingPong, + LoopOnce, + LoopRepeat, + NormalAnimationBlendMode, + AdditiveAnimationBlendMode, +} from '../constants.js'; + +class AnimationAction { + constructor(mixer, clip, localRoot = null, blendMode = clip.blendMode) { + this._mixer = mixer; + this._clip = clip; + this._localRoot = localRoot; + this.blendMode = blendMode; + + const tracks = clip.tracks, + nTracks = tracks.length, + interpolants = new Array(nTracks); + + const interpolantSettings = { + endingStart: ZeroCurvatureEnding, + endingEnd: ZeroCurvatureEnding, + }; + + for (let i = 0; i !== nTracks; ++i) { + const interpolant = tracks[i].createInterpolant(null); + interpolants[i] = interpolant; + interpolant.settings = interpolantSettings; + } + + this._interpolantSettings = interpolantSettings; + + this._interpolants = interpolants; // bound by the mixer + + // inside: PropertyMixer (managed by the mixer) + this._propertyBindings = new Array(nTracks); + + this._cacheIndex = null; // for the memory manager + this._byClipCacheIndex = null; // for the memory manager + + this._timeScaleInterpolant = null; + this._weightInterpolant = null; + + this.loop = LoopRepeat; + this._loopCount = -1; + + // global mixer time when the action is to be started + // it's set back to 'null' upon start of the action + this._startTime = null; + + // scaled local time of the action + // gets clamped or wrapped to 0..clip.duration according to loop + this.time = 0; + + this.timeScale = 1; + this._effectiveTimeScale = 1; + + this.weight = 1; + this._effectiveWeight = 1; + + this.repetitions = Infinity; // no. of repetitions when looping + + this.paused = false; // true -> zero effective time scale + this.enabled = true; // false -> zero effective weight + + this.clampWhenFinished = false; // keep feeding the last frame? + + this.zeroSlopeAtStart = true; // for smooth interpolation w/o separate + this.zeroSlopeAtEnd = true; // clips for start, loop and end + } + + // State & Scheduling + + play() { + this._mixer._activateAction(this); + + return this; + } + + stop() { + this._mixer._deactivateAction(this); + + return this.reset(); + } + + reset() { + this.paused = false; + this.enabled = true; + + this.time = 0; // restart clip + this._loopCount = -1; // forget previous loops + this._startTime = null; // forget scheduling + + return this.stopFading().stopWarping(); + } + + isRunning() { + return this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this); + } + + // return true when play has been called + isScheduled() { + return this._mixer._isActiveAction(this); + } + + startAt(time) { + this._startTime = time; + + return this; + } + + setLoop(mode, repetitions) { + this.loop = mode; + this.repetitions = repetitions; + + return this; + } + + // Weight + + // set the weight stopping any scheduled fading + // although .enabled = false yields an effective weight of zero, this + // method does *not* change .enabled, because it would be confusing + setEffectiveWeight(weight) { + this.weight = weight; + + // note: same logic as when updated at runtime + this._effectiveWeight = this.enabled ? weight : 0; + + return this.stopFading(); + } + + // return the weight considering fading and .enabled + getEffectiveWeight() { + return this._effectiveWeight; + } + + fadeIn(duration) { + return this._scheduleFading(duration, 0, 1); + } + + fadeOut(duration) { + return this._scheduleFading(duration, 1, 0); + } + + crossFadeFrom(fadeOutAction, duration, warp) { + fadeOutAction.fadeOut(duration); + this.fadeIn(duration); + + if (warp) { + const fadeInDuration = this._clip.duration, + fadeOutDuration = fadeOutAction._clip.duration, + startEndRatio = fadeOutDuration / fadeInDuration, + endStartRatio = fadeInDuration / fadeOutDuration; + + fadeOutAction.warp(1.0, startEndRatio, duration); + this.warp(endStartRatio, 1.0, duration); + } + + return this; + } + + crossFadeTo(fadeInAction, duration, warp) { + return fadeInAction.crossFadeFrom(this, duration, warp); + } + + stopFading() { + const weightInterpolant = this._weightInterpolant; + + if (weightInterpolant !== null) { + this._weightInterpolant = null; + this._mixer._takeBackControlInterpolant(weightInterpolant); + } + + return this; + } + + // Time Scale Control + + // set the time scale stopping any scheduled warping + // although .paused = true yields an effective time scale of zero, this + // method does *not* change .paused, because it would be confusing + setEffectiveTimeScale(timeScale) { + this.timeScale = timeScale; + this._effectiveTimeScale = this.paused ? 0 : timeScale; + + return this.stopWarping(); + } + + // return the time scale considering warping and .paused + getEffectiveTimeScale() { + return this._effectiveTimeScale; + } + + setDuration(duration) { + this.timeScale = this._clip.duration / duration; + + return this.stopWarping(); + } + + syncWith(action) { + this.time = action.time; + this.timeScale = action.timeScale; + + return this.stopWarping(); + } + + halt(duration) { + return this.warp(this._effectiveTimeScale, 0, duration); + } + + warp(startTimeScale, endTimeScale, duration) { + const mixer = this._mixer, + now = mixer.time, + timeScale = this.timeScale; + + let interpolant = this._timeScaleInterpolant; + + if (interpolant === null) { + interpolant = mixer._lendControlInterpolant(); + this._timeScaleInterpolant = interpolant; + } + + const times = interpolant.parameterPositions, + values = interpolant.sampleValues; + + times[0] = now; + times[1] = now + duration; + + values[0] = startTimeScale / timeScale; + values[1] = endTimeScale / timeScale; + + return this; + } + + stopWarping() { + const timeScaleInterpolant = this._timeScaleInterpolant; + + if (timeScaleInterpolant !== null) { + this._timeScaleInterpolant = null; + this._mixer._takeBackControlInterpolant(timeScaleInterpolant); + } + + return this; + } + + // Object Accessors + + getMixer() { + return this._mixer; + } + + getClip() { + return this._clip; + } + + getRoot() { + return this._localRoot || this._mixer._root; + } + + // Interna + + _update(time, deltaTime, timeDirection, accuIndex) { + // called by the mixer + + if (!this.enabled) { + // call ._updateWeight() to update ._effectiveWeight + + this._updateWeight(time); + return; + } + + const startTime = this._startTime; + + if (startTime !== null) { + // check for scheduled start of action + + const timeRunning = (time - startTime) * timeDirection; + if (timeRunning < 0 || timeDirection === 0) { + return; // yet to come / don't decide when delta = 0 + } + + // start + + this._startTime = null; // unschedule + deltaTime = timeDirection * timeRunning; + } + + // apply time scale and advance time + + deltaTime *= this._updateTimeScale(time); + const clipTime = this._updateTime(deltaTime); + + // note: _updateTime may disable the action resulting in + // an effective weight of 0 + + const weight = this._updateWeight(time); + + if (weight > 0) { + const interpolants = this._interpolants; + const propertyMixers = this._propertyBindings; + + switch (this.blendMode) { + case AdditiveAnimationBlendMode: + for (let j = 0, m = interpolants.length; j !== m; ++j) { + interpolants[j].evaluate(clipTime); + propertyMixers[j].accumulateAdditive(weight); + } + + break; + + case NormalAnimationBlendMode: + default: + for (let j = 0, m = interpolants.length; j !== m; ++j) { + interpolants[j].evaluate(clipTime); + propertyMixers[j].accumulate(accuIndex, weight); + } + } + } + } + + _updateWeight(time) { + let weight = 0; + + if (this.enabled) { + weight = this.weight; + const interpolant = this._weightInterpolant; + + if (interpolant !== null) { + const interpolantValue = interpolant.evaluate(time)[0]; + + weight *= interpolantValue; + + if (time > interpolant.parameterPositions[1]) { + this.stopFading(); + + if (interpolantValue === 0) { + // faded out, disable + this.enabled = false; + } + } + } + } + + this._effectiveWeight = weight; + return weight; + } + + _updateTimeScale(time) { + let timeScale = 0; + + if (!this.paused) { + timeScale = this.timeScale; + + const interpolant = this._timeScaleInterpolant; + + if (interpolant !== null) { + const interpolantValue = interpolant.evaluate(time)[0]; + + timeScale *= interpolantValue; + + if (time > interpolant.parameterPositions[1]) { + this.stopWarping(); + + if (timeScale === 0) { + // motion has halted, pause + this.paused = true; + } else { + // warp done - apply final time scale + this.timeScale = timeScale; + } + } + } + } + + this._effectiveTimeScale = timeScale; + return timeScale; + } + + _updateTime(deltaTime) { + const duration = this._clip.duration; + const loop = this.loop; + + let time = this.time + deltaTime; + let loopCount = this._loopCount; + + const pingPong = loop === LoopPingPong; + + if (deltaTime === 0) { + if (loopCount === -1) return time; + + return pingPong && (loopCount & 1) === 1 ? duration - time : time; + } + + if (loop === LoopOnce) { + if (loopCount === -1) { + // just started + + this._loopCount = 0; + this._setEndings(true, true, false); + } + + handle_stop: { + if (time >= duration) { + time = duration; + } else if (time < 0) { + time = 0; + } else { + this.time = time; + + break handle_stop; + } + + if (this.clampWhenFinished) this.paused = true; + else this.enabled = false; + + this.time = time; + + this._mixer.dispatchEvent({ + type: 'finished', + action: this, + direction: deltaTime < 0 ? -1 : 1, + }); + } + } else { + // repetitive Repeat or PingPong + + if (loopCount === -1) { + // just started + + if (deltaTime >= 0) { + loopCount = 0; + + this._setEndings(true, this.repetitions === 0, pingPong); + } else { + // when looping in reverse direction, the initial + // transition through zero counts as a repetition, + // so leave loopCount at -1 + + this._setEndings(this.repetitions === 0, true, pingPong); + } + } + + if (time >= duration || time < 0) { + // wrap around + + const loopDelta = Math.floor(time / duration); // signed + time -= duration * loopDelta; + + loopCount += Math.abs(loopDelta); + + const pending = this.repetitions - loopCount; + + if (pending <= 0) { + // have to stop (switch state, clamp time, fire event) + + if (this.clampWhenFinished) this.paused = true; + else this.enabled = false; + + time = deltaTime > 0 ? duration : 0; + + this.time = time; + + this._mixer.dispatchEvent({ + type: 'finished', + action: this, + direction: deltaTime > 0 ? 1 : -1, + }); + } else { + // keep running + + if (pending === 1) { + // entering the last round + + const atStart = deltaTime < 0; + this._setEndings(atStart, !atStart, pingPong); + } else { + this._setEndings(false, false, pingPong); + } + + this._loopCount = loopCount; + + this.time = time; + + this._mixer.dispatchEvent({ + type: 'loop', + action: this, + loopDelta: loopDelta, + }); + } + } else { + this.time = time; + } + + if (pingPong && (loopCount & 1) === 1) { + // invert time for the "pong round" + + return duration - time; + } + } + + return time; + } + + _setEndings(atStart, atEnd, pingPong) { + const settings = this._interpolantSettings; + + if (pingPong) { + settings.endingStart = ZeroSlopeEnding; + settings.endingEnd = ZeroSlopeEnding; + } else { + // assuming for LoopOnce atStart == atEnd == true + + if (atStart) { + settings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding; + } else { + settings.endingStart = WrapAroundEnding; + } + + if (atEnd) { + settings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding; + } else { + settings.endingEnd = WrapAroundEnding; + } + } + } + + _scheduleFading(duration, weightNow, weightThen) { + const mixer = this._mixer, + now = mixer.time; + let interpolant = this._weightInterpolant; + + if (interpolant === null) { + interpolant = mixer._lendControlInterpolant(); + this._weightInterpolant = interpolant; + } + + const times = interpolant.parameterPositions, + values = interpolant.sampleValues; + + times[0] = now; + values[0] = weightNow; + times[1] = now + duration; + values[1] = weightThen; + + return this; + } +} + +export { AnimationAction }; diff --git a/backend/libs/three/animation/AnimationClip.d.ts b/backend/libs/three/animation/AnimationClip.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3249af7c4cdd2e0e840a4243f577e5d0f2cf807b --- /dev/null +++ b/backend/libs/three/animation/AnimationClip.d.ts @@ -0,0 +1,42 @@ +import { KeyframeTrack } from './KeyframeTrack'; +import { Vector3 } from './../math/Vector3'; +import { Bone } from './../objects/Bone'; +import { AnimationBlendMode } from '../constants'; + +export interface MorphTarget { + name: string; + vertices: Vector3[]; +} + +export class AnimationClip { + constructor(name?: string, duration?: number, tracks?: KeyframeTrack[], blendMode?: AnimationBlendMode); + + name: string; + tracks: KeyframeTrack[]; + + /** + * @default THREE.NormalAnimationBlendMode + */ + blendMode: AnimationBlendMode; + + /** + * @default -1 + */ + duration: number; + uuid: string; + results: any[]; + + resetDuration(): AnimationClip; + trim(): AnimationClip; + validate(): boolean; + optimize(): AnimationClip; + clone(): this; + toJSON(clip: AnimationClip): any; + + static CreateFromMorphTargetSequence(name: string, morphTargetSequence: MorphTarget[], fps: number, noLoop: boolean): AnimationClip; + static findByName(clipArray: AnimationClip[], name: string): AnimationClip; + static CreateClipsFromMorphTargetSequences(morphTargets: MorphTarget[], fps: number, noLoop: boolean): AnimationClip[]; + static parse(json: any): AnimationClip; + static parseAnimation(animation: any, bones: Bone[]): AnimationClip; + static toJSON(clip: AnimationClip): any; +} diff --git a/backend/libs/three/animation/AnimationClip.js b/backend/libs/three/animation/AnimationClip.js new file mode 100644 index 0000000000000000000000000000000000000000..ae3bdab837651606f088204f0676b162653b9873 --- /dev/null +++ b/backend/libs/three/animation/AnimationClip.js @@ -0,0 +1,350 @@ +import { AnimationUtils } from './AnimationUtils.js'; +import { KeyframeTrack } from './KeyframeTrack.js'; +import { BooleanKeyframeTrack } from './tracks/BooleanKeyframeTrack.js'; +import { ColorKeyframeTrack } from './tracks/ColorKeyframeTrack.js'; +import { NumberKeyframeTrack } from './tracks/NumberKeyframeTrack.js'; +import { QuaternionKeyframeTrack } from './tracks/QuaternionKeyframeTrack.js'; +import { StringKeyframeTrack } from './tracks/StringKeyframeTrack.js'; +import { VectorKeyframeTrack } from './tracks/VectorKeyframeTrack.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { NormalAnimationBlendMode } from '../constants.js'; + +class AnimationClip { + constructor(name, duration = -1, tracks, blendMode = NormalAnimationBlendMode) { + this.name = name; + this.tracks = tracks; + this.duration = duration; + this.blendMode = blendMode; + + this.uuid = MathUtils.generateUUID(); + + // this means it should figure out its duration by scanning the tracks + if (this.duration < 0) { + this.resetDuration(); + } + } + + static parse(json) { + const tracks = [], + jsonTracks = json.tracks, + frameTime = 1.0 / (json.fps || 1.0); + + for (let i = 0, n = jsonTracks.length; i !== n; ++i) { + tracks.push(parseKeyframeTrack(jsonTracks[i]).scale(frameTime)); + } + + const clip = new this(json.name, json.duration, tracks, json.blendMode); + clip.uuid = json.uuid; + + return clip; + } + + static toJSON(clip) { + const tracks = [], + clipTracks = clip.tracks; + + const json = { + name: clip.name, + duration: clip.duration, + tracks: tracks, + uuid: clip.uuid, + blendMode: clip.blendMode, + }; + + for (let i = 0, n = clipTracks.length; i !== n; ++i) { + tracks.push(KeyframeTrack.toJSON(clipTracks[i])); + } + + return json; + } + + static CreateFromMorphTargetSequence(name, morphTargetSequence, fps, noLoop) { + const numMorphTargets = morphTargetSequence.length; + const tracks = []; + + for (let i = 0; i < numMorphTargets; i++) { + let times = []; + let values = []; + + times.push((i + numMorphTargets - 1) % numMorphTargets, i, (i + 1) % numMorphTargets); + + values.push(0, 1, 0); + + const order = AnimationUtils.getKeyframeOrder(times); + times = AnimationUtils.sortedArray(times, 1, order); + values = AnimationUtils.sortedArray(values, 1, order); + + // if there is a key at the first frame, duplicate it as the + // last frame as well for perfect loop. + if (!noLoop && times[0] === 0) { + times.push(numMorphTargets); + values.push(values[0]); + } + + tracks.push(new NumberKeyframeTrack('.morphTargetInfluences[' + morphTargetSequence[i].name + ']', times, values).scale(1.0 / fps)); + } + + return new this(name, -1, tracks); + } + + static findByName(objectOrClipArray, name) { + let clipArray = objectOrClipArray; + + if (!Array.isArray(objectOrClipArray)) { + const o = objectOrClipArray; + clipArray = (o.geometry && o.geometry.animations) || o.animations; + } + + for (let i = 0; i < clipArray.length; i++) { + if (clipArray[i].name === name) { + return clipArray[i]; + } + } + + return null; + } + + static CreateClipsFromMorphTargetSequences(morphTargets, fps, noLoop) { + const animationToMorphTargets = {}; + + // tested with https://regex101.com/ on trick sequences + // such flamingo_flyA_003, flamingo_run1_003, crdeath0059 + const pattern = /^([\w-]*?)([\d]+)$/; + + // sort morph target names into animation groups based + // patterns like Walk_001, Walk_002, Run_001, Run_002 + for (let i = 0, il = morphTargets.length; i < il; i++) { + const morphTarget = morphTargets[i]; + const parts = morphTarget.name.match(pattern); + + if (parts && parts.length > 1) { + const name = parts[1]; + + let animationMorphTargets = animationToMorphTargets[name]; + + if (!animationMorphTargets) { + animationToMorphTargets[name] = animationMorphTargets = []; + } + + animationMorphTargets.push(morphTarget); + } + } + + const clips = []; + + for (const name in animationToMorphTargets) { + clips.push(this.CreateFromMorphTargetSequence(name, animationToMorphTargets[name], fps, noLoop)); + } + + return clips; + } + + // parse the animation.hierarchy format + static parseAnimation(animation, bones) { + if (!animation) { + console.error('THREE.AnimationClip: No animation in JSONLoader data.'); + return null; + } + + const addNonemptyTrack = function (trackType, trackName, animationKeys, propertyName, destTracks) { + // only return track if there are actually keys. + if (animationKeys.length !== 0) { + const times = []; + const values = []; + + AnimationUtils.flattenJSON(animationKeys, times, values, propertyName); + + // empty keys are filtered out, so check again + if (times.length !== 0) { + destTracks.push(new trackType(trackName, times, values)); + } + } + }; + + const tracks = []; + + const clipName = animation.name || 'default'; + const fps = animation.fps || 30; + const blendMode = animation.blendMode; + + // automatic length determination in AnimationClip. + let duration = animation.length || -1; + + const hierarchyTracks = animation.hierarchy || []; + + for (let h = 0; h < hierarchyTracks.length; h++) { + const animationKeys = hierarchyTracks[h].keys; + + // skip empty tracks + if (!animationKeys || animationKeys.length === 0) continue; + + // process morph targets + if (animationKeys[0].morphTargets) { + // figure out all morph targets used in this track + const morphTargetNames = {}; + + let k; + + for (k = 0; k < animationKeys.length; k++) { + if (animationKeys[k].morphTargets) { + for (let m = 0; m < animationKeys[k].morphTargets.length; m++) { + morphTargetNames[animationKeys[k].morphTargets[m]] = -1; + } + } + } + + // create a track for each morph target with all zero + // morphTargetInfluences except for the keys in which + // the morphTarget is named. + for (const morphTargetName in morphTargetNames) { + const times = []; + const values = []; + + for (let m = 0; m !== animationKeys[k].morphTargets.length; ++m) { + const animationKey = animationKeys[k]; + + times.push(animationKey.time); + values.push(animationKey.morphTarget === morphTargetName ? 1 : 0); + } + + tracks.push(new NumberKeyframeTrack('.morphTargetInfluence[' + morphTargetName + ']', times, values)); + } + + duration = morphTargetNames.length * (fps || 1.0); + } else { + // ...assume skeletal animation + + const boneName = '.bones[' + bones[h].name + ']'; + + addNonemptyTrack(VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks); + + addNonemptyTrack(QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks); + + addNonemptyTrack(VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks); + } + } + + if (tracks.length === 0) { + return null; + } + + const clip = new this(clipName, duration, tracks, blendMode); + + return clip; + } + + resetDuration() { + const tracks = this.tracks; + let duration = 0; + + for (let i = 0, n = tracks.length; i !== n; ++i) { + const track = this.tracks[i]; + + duration = Math.max(duration, track.times[track.times.length - 1]); + } + + this.duration = duration; + + return this; + } + + trim() { + for (let i = 0; i < this.tracks.length; i++) { + this.tracks[i].trim(0, this.duration); + } + + return this; + } + + validate() { + let valid = true; + + for (let i = 0; i < this.tracks.length; i++) { + valid = valid && this.tracks[i].validate(); + } + + return valid; + } + + optimize() { + for (let i = 0; i < this.tracks.length; i++) { + this.tracks[i].optimize(); + } + + return this; + } + + clone() { + const tracks = []; + + for (let i = 0; i < this.tracks.length; i++) { + tracks.push(this.tracks[i].clone()); + } + + return new this.constructor(this.name, this.duration, tracks, this.blendMode); + } + + toJSON() { + return this.constructor.toJSON(this); + } +} + +function getTrackTypeForValueTypeName(typeName) { + switch (typeName.toLowerCase()) { + case 'scalar': + case 'double': + case 'float': + case 'number': + case 'integer': + return NumberKeyframeTrack; + + case 'vector': + case 'vector2': + case 'vector3': + case 'vector4': + return VectorKeyframeTrack; + + case 'color': + return ColorKeyframeTrack; + + case 'quaternion': + return QuaternionKeyframeTrack; + + case 'bool': + case 'boolean': + return BooleanKeyframeTrack; + + case 'string': + return StringKeyframeTrack; + } + + throw new Error('THREE.KeyframeTrack: Unsupported typeName: ' + typeName); +} + +function parseKeyframeTrack(json) { + if (json.type === undefined) { + throw new Error('THREE.KeyframeTrack: track type undefined, can not parse'); + } + + const trackType = getTrackTypeForValueTypeName(json.type); + + if (json.times === undefined) { + const times = [], + values = []; + + AnimationUtils.flattenJSON(json.keys, times, values, 'value'); + + json.times = times; + json.values = values; + } + + // derived classes can define a static parse method + if (trackType.parse !== undefined) { + return trackType.parse(json); + } else { + // by default, we assume a constructor compatible with the base + return new trackType(json.name, json.times, json.values, json.interpolation); + } +} + +export { AnimationClip }; diff --git a/backend/libs/three/animation/AnimationMixer.d.ts b/backend/libs/three/animation/AnimationMixer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7424b5af967815106078233eeae6a381c902cab0 --- /dev/null +++ b/backend/libs/three/animation/AnimationMixer.d.ts @@ -0,0 +1,30 @@ +import { AnimationClip } from './AnimationClip'; +import { AnimationAction } from './AnimationAction'; +import { AnimationBlendMode } from '../constants'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { Object3D } from '../core/Object3D'; +import { AnimationObjectGroup } from './AnimationObjectGroup'; + +export class AnimationMixer extends EventDispatcher { + constructor(root: Object3D | AnimationObjectGroup); + + /** + * @default 0 + */ + time: number; + + /** + * @default 1.0 + */ + timeScale: number; + + clipAction(clip: AnimationClip, root?: Object3D | AnimationObjectGroup, blendMode?: AnimationBlendMode): AnimationAction; + existingAction(clip: AnimationClip, root?: Object3D | AnimationObjectGroup): AnimationAction | null; + stopAllAction(): AnimationMixer; + update(deltaTime: number): AnimationMixer; + setTime(timeInSeconds: number): AnimationMixer; + getRoot(): Object3D | AnimationObjectGroup; + uncacheClip(clip: AnimationClip): void; + uncacheRoot(root: Object3D | AnimationObjectGroup): void; + uncacheAction(clip: AnimationClip, root?: Object3D | AnimationObjectGroup): void; +} diff --git a/backend/libs/three/animation/AnimationMixer.js b/backend/libs/three/animation/AnimationMixer.js new file mode 100644 index 0000000000000000000000000000000000000000..05e92049367851df6ce2b9537de82a57d6877939 --- /dev/null +++ b/backend/libs/three/animation/AnimationMixer.js @@ -0,0 +1,590 @@ +import { AnimationAction } from './AnimationAction.js'; +import { EventDispatcher } from '../core/EventDispatcher.js'; +import { LinearInterpolant } from '../math/interpolants/LinearInterpolant.js'; +import { PropertyBinding } from './PropertyBinding.js'; +import { PropertyMixer } from './PropertyMixer.js'; +import { AnimationClip } from './AnimationClip.js'; +import { NormalAnimationBlendMode } from '../constants.js'; + +class AnimationMixer extends EventDispatcher { + constructor(root) { + super(); + + this._root = root; + this._initMemoryManager(); + this._accuIndex = 0; + this.time = 0; + this.timeScale = 1.0; + } + + _bindAction(action, prototypeAction) { + const root = action._localRoot || this._root, + tracks = action._clip.tracks, + nTracks = tracks.length, + bindings = action._propertyBindings, + interpolants = action._interpolants, + rootUuid = root.uuid, + bindingsByRoot = this._bindingsByRootAndName; + + let bindingsByName = bindingsByRoot[rootUuid]; + + if (bindingsByName === undefined) { + bindingsByName = {}; + bindingsByRoot[rootUuid] = bindingsByName; + } + + for (let i = 0; i !== nTracks; ++i) { + const track = tracks[i], + trackName = track.name; + + let binding = bindingsByName[trackName]; + + if (binding !== undefined) { + ++binding.referenceCount; + bindings[i] = binding; + } else { + binding = bindings[i]; + + if (binding !== undefined) { + // existing binding, make sure the cache knows + + if (binding._cacheIndex === null) { + ++binding.referenceCount; + this._addInactiveBinding(binding, rootUuid, trackName); + } + + continue; + } + + const path = prototypeAction && prototypeAction._propertyBindings[i].binding.parsedPath; + + binding = new PropertyMixer(PropertyBinding.create(root, trackName, path), track.ValueTypeName, track.getValueSize()); + + ++binding.referenceCount; + this._addInactiveBinding(binding, rootUuid, trackName); + + bindings[i] = binding; + } + + interpolants[i].resultBuffer = binding.buffer; + } + } + + _activateAction(action) { + if (!this._isActiveAction(action)) { + if (action._cacheIndex === null) { + // this action has been forgotten by the cache, but the user + // appears to be still using it -> rebind + + const rootUuid = (action._localRoot || this._root).uuid, + clipUuid = action._clip.uuid, + actionsForClip = this._actionsByClip[clipUuid]; + + this._bindAction(action, actionsForClip && actionsForClip.knownActions[0]); + + this._addInactiveAction(action, clipUuid, rootUuid); + } + + const bindings = action._propertyBindings; + + // increment reference counts / sort out state + for (let i = 0, n = bindings.length; i !== n; ++i) { + const binding = bindings[i]; + + if (binding.useCount++ === 0) { + this._lendBinding(binding); + binding.saveOriginalState(); + } + } + + this._lendAction(action); + } + } + + _deactivateAction(action) { + if (this._isActiveAction(action)) { + const bindings = action._propertyBindings; + + // decrement reference counts / sort out state + for (let i = 0, n = bindings.length; i !== n; ++i) { + const binding = bindings[i]; + + if (--binding.useCount === 0) { + binding.restoreOriginalState(); + this._takeBackBinding(binding); + } + } + + this._takeBackAction(action); + } + } + + // Memory manager + + _initMemoryManager() { + this._actions = []; // 'nActiveActions' followed by inactive ones + this._nActiveActions = 0; + + this._actionsByClip = {}; + // inside: + // { + // knownActions: Array< AnimationAction > - used as prototypes + // actionByRoot: AnimationAction - lookup + // } + + this._bindings = []; // 'nActiveBindings' followed by inactive ones + this._nActiveBindings = 0; + + this._bindingsByRootAndName = {}; // inside: Map< name, PropertyMixer > + + this._controlInterpolants = []; // same game as above + this._nActiveControlInterpolants = 0; + + const scope = this; + + this.stats = { + actions: { + get total() { + return scope._actions.length; + }, + get inUse() { + return scope._nActiveActions; + }, + }, + bindings: { + get total() { + return scope._bindings.length; + }, + get inUse() { + return scope._nActiveBindings; + }, + }, + controlInterpolants: { + get total() { + return scope._controlInterpolants.length; + }, + get inUse() { + return scope._nActiveControlInterpolants; + }, + }, + }; + } + + // Memory management for AnimationAction objects + + _isActiveAction(action) { + const index = action._cacheIndex; + return index !== null && index < this._nActiveActions; + } + + _addInactiveAction(action, clipUuid, rootUuid) { + const actions = this._actions, + actionsByClip = this._actionsByClip; + + let actionsForClip = actionsByClip[clipUuid]; + + if (actionsForClip === undefined) { + actionsForClip = { + knownActions: [action], + actionByRoot: {}, + }; + + action._byClipCacheIndex = 0; + + actionsByClip[clipUuid] = actionsForClip; + } else { + const knownActions = actionsForClip.knownActions; + + action._byClipCacheIndex = knownActions.length; + knownActions.push(action); + } + + action._cacheIndex = actions.length; + actions.push(action); + + actionsForClip.actionByRoot[rootUuid] = action; + } + + _removeInactiveAction(action) { + const actions = this._actions, + lastInactiveAction = actions[actions.length - 1], + cacheIndex = action._cacheIndex; + + lastInactiveAction._cacheIndex = cacheIndex; + actions[cacheIndex] = lastInactiveAction; + actions.pop(); + + action._cacheIndex = null; + + const clipUuid = action._clip.uuid, + actionsByClip = this._actionsByClip, + actionsForClip = actionsByClip[clipUuid], + knownActionsForClip = actionsForClip.knownActions, + lastKnownAction = knownActionsForClip[knownActionsForClip.length - 1], + byClipCacheIndex = action._byClipCacheIndex; + + lastKnownAction._byClipCacheIndex = byClipCacheIndex; + knownActionsForClip[byClipCacheIndex] = lastKnownAction; + knownActionsForClip.pop(); + + action._byClipCacheIndex = null; + + const actionByRoot = actionsForClip.actionByRoot, + rootUuid = (action._localRoot || this._root).uuid; + + delete actionByRoot[rootUuid]; + + if (knownActionsForClip.length === 0) { + delete actionsByClip[clipUuid]; + } + + this._removeInactiveBindingsForAction(action); + } + + _removeInactiveBindingsForAction(action) { + const bindings = action._propertyBindings; + + for (let i = 0, n = bindings.length; i !== n; ++i) { + const binding = bindings[i]; + + if (--binding.referenceCount === 0) { + this._removeInactiveBinding(binding); + } + } + } + + _lendAction(action) { + // [ active actions | inactive actions ] + // [ active actions >| inactive actions ] + // s a + // <-swap-> + // a s + + const actions = this._actions, + prevIndex = action._cacheIndex, + lastActiveIndex = this._nActiveActions++, + firstInactiveAction = actions[lastActiveIndex]; + + action._cacheIndex = lastActiveIndex; + actions[lastActiveIndex] = action; + + firstInactiveAction._cacheIndex = prevIndex; + actions[prevIndex] = firstInactiveAction; + } + + _takeBackAction(action) { + // [ active actions | inactive actions ] + // [ active actions |< inactive actions ] + // a s + // <-swap-> + // s a + + const actions = this._actions, + prevIndex = action._cacheIndex, + firstInactiveIndex = --this._nActiveActions, + lastActiveAction = actions[firstInactiveIndex]; + + action._cacheIndex = firstInactiveIndex; + actions[firstInactiveIndex] = action; + + lastActiveAction._cacheIndex = prevIndex; + actions[prevIndex] = lastActiveAction; + } + + // Memory management for PropertyMixer objects + + _addInactiveBinding(binding, rootUuid, trackName) { + const bindingsByRoot = this._bindingsByRootAndName, + bindings = this._bindings; + + let bindingByName = bindingsByRoot[rootUuid]; + + if (bindingByName === undefined) { + bindingByName = {}; + bindingsByRoot[rootUuid] = bindingByName; + } + + bindingByName[trackName] = binding; + + binding._cacheIndex = bindings.length; + bindings.push(binding); + } + + _removeInactiveBinding(binding) { + const bindings = this._bindings, + propBinding = binding.binding, + rootUuid = propBinding.rootNode.uuid, + trackName = propBinding.path, + bindingsByRoot = this._bindingsByRootAndName, + bindingByName = bindingsByRoot[rootUuid], + lastInactiveBinding = bindings[bindings.length - 1], + cacheIndex = binding._cacheIndex; + + lastInactiveBinding._cacheIndex = cacheIndex; + bindings[cacheIndex] = lastInactiveBinding; + bindings.pop(); + + delete bindingByName[trackName]; + + if (Object.keys(bindingByName).length === 0) { + delete bindingsByRoot[rootUuid]; + } + } + + _lendBinding(binding) { + const bindings = this._bindings, + prevIndex = binding._cacheIndex, + lastActiveIndex = this._nActiveBindings++, + firstInactiveBinding = bindings[lastActiveIndex]; + + binding._cacheIndex = lastActiveIndex; + bindings[lastActiveIndex] = binding; + + firstInactiveBinding._cacheIndex = prevIndex; + bindings[prevIndex] = firstInactiveBinding; + } + + _takeBackBinding(binding) { + const bindings = this._bindings, + prevIndex = binding._cacheIndex, + firstInactiveIndex = --this._nActiveBindings, + lastActiveBinding = bindings[firstInactiveIndex]; + + binding._cacheIndex = firstInactiveIndex; + bindings[firstInactiveIndex] = binding; + + lastActiveBinding._cacheIndex = prevIndex; + bindings[prevIndex] = lastActiveBinding; + } + + // Memory management of Interpolants for weight and time scale + + _lendControlInterpolant() { + const interpolants = this._controlInterpolants, + lastActiveIndex = this._nActiveControlInterpolants++; + + let interpolant = interpolants[lastActiveIndex]; + + if (interpolant === undefined) { + interpolant = new LinearInterpolant(new Float32Array(2), new Float32Array(2), 1, this._controlInterpolantsResultBuffer); + + interpolant.__cacheIndex = lastActiveIndex; + interpolants[lastActiveIndex] = interpolant; + } + + return interpolant; + } + + _takeBackControlInterpolant(interpolant) { + const interpolants = this._controlInterpolants, + prevIndex = interpolant.__cacheIndex, + firstInactiveIndex = --this._nActiveControlInterpolants, + lastActiveInterpolant = interpolants[firstInactiveIndex]; + + interpolant.__cacheIndex = firstInactiveIndex; + interpolants[firstInactiveIndex] = interpolant; + + lastActiveInterpolant.__cacheIndex = prevIndex; + interpolants[prevIndex] = lastActiveInterpolant; + } + + // return an action for a clip optionally using a custom root target + // object (this method allocates a lot of dynamic memory in case a + // previously unknown clip/root combination is specified) + clipAction(clip, optionalRoot, blendMode) { + const root = optionalRoot || this._root, + rootUuid = root.uuid; + + let clipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip; + + const clipUuid = clipObject !== null ? clipObject.uuid : clip; + + const actionsForClip = this._actionsByClip[clipUuid]; + let prototypeAction = null; + + if (blendMode === undefined) { + if (clipObject !== null) { + blendMode = clipObject.blendMode; + } else { + blendMode = NormalAnimationBlendMode; + } + } + + if (actionsForClip !== undefined) { + const existingAction = actionsForClip.actionByRoot[rootUuid]; + + if (existingAction !== undefined && existingAction.blendMode === blendMode) { + return existingAction; + } + + // we know the clip, so we don't have to parse all + // the bindings again but can just copy + prototypeAction = actionsForClip.knownActions[0]; + + // also, take the clip from the prototype action + if (clipObject === null) clipObject = prototypeAction._clip; + } + + // clip must be known when specified via string + if (clipObject === null) return null; + + // allocate all resources required to run it + const newAction = new AnimationAction(this, clipObject, optionalRoot, blendMode); + + this._bindAction(newAction, prototypeAction); + + // and make the action known to the memory manager + this._addInactiveAction(newAction, clipUuid, rootUuid); + + return newAction; + } + + // get an existing action + existingAction(clip, optionalRoot) { + const root = optionalRoot || this._root, + rootUuid = root.uuid, + clipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip, + clipUuid = clipObject ? clipObject.uuid : clip, + actionsForClip = this._actionsByClip[clipUuid]; + + if (actionsForClip !== undefined) { + return actionsForClip.actionByRoot[rootUuid] || null; + } + + return null; + } + + // deactivates all previously scheduled actions + stopAllAction() { + const actions = this._actions, + nActions = this._nActiveActions; + + for (let i = nActions - 1; i >= 0; --i) { + actions[i].stop(); + } + + return this; + } + + // advance the time and update apply the animation + update(deltaTime) { + deltaTime *= this.timeScale; + + const actions = this._actions, + nActions = this._nActiveActions, + time = (this.time += deltaTime), + timeDirection = Math.sign(deltaTime), + accuIndex = (this._accuIndex ^= 1); + + // run active actions + + for (let i = 0; i !== nActions; ++i) { + const action = actions[i]; + + action._update(time, deltaTime, timeDirection, accuIndex); + } + + // update scene graph + + const bindings = this._bindings, + nBindings = this._nActiveBindings; + + for (let i = 0; i !== nBindings; ++i) { + bindings[i].apply(accuIndex); + } + + return this; + } + + // Allows you to seek to a specific time in an animation. + setTime(timeInSeconds) { + this.time = 0; // Zero out time attribute for AnimationMixer object; + for (let i = 0; i < this._actions.length; i++) { + this._actions[i].time = 0; // Zero out time attribute for all associated AnimationAction objects. + } + + return this.update(timeInSeconds); // Update used to set exact time. Returns "this" AnimationMixer object. + } + + // return this mixer's root target object + getRoot() { + return this._root; + } + + // free all resources specific to a particular clip + uncacheClip(clip) { + const actions = this._actions, + clipUuid = clip.uuid, + actionsByClip = this._actionsByClip, + actionsForClip = actionsByClip[clipUuid]; + + if (actionsForClip !== undefined) { + // note: just calling _removeInactiveAction would mess up the + // iteration state and also require updating the state we can + // just throw away + + const actionsToRemove = actionsForClip.knownActions; + + for (let i = 0, n = actionsToRemove.length; i !== n; ++i) { + const action = actionsToRemove[i]; + + this._deactivateAction(action); + + const cacheIndex = action._cacheIndex, + lastInactiveAction = actions[actions.length - 1]; + + action._cacheIndex = null; + action._byClipCacheIndex = null; + + lastInactiveAction._cacheIndex = cacheIndex; + actions[cacheIndex] = lastInactiveAction; + actions.pop(); + + this._removeInactiveBindingsForAction(action); + } + + delete actionsByClip[clipUuid]; + } + } + + // free all resources specific to a particular root target object + uncacheRoot(root) { + const rootUuid = root.uuid, + actionsByClip = this._actionsByClip; + + for (const clipUuid in actionsByClip) { + const actionByRoot = actionsByClip[clipUuid].actionByRoot, + action = actionByRoot[rootUuid]; + + if (action !== undefined) { + this._deactivateAction(action); + this._removeInactiveAction(action); + } + } + + const bindingsByRoot = this._bindingsByRootAndName, + bindingByName = bindingsByRoot[rootUuid]; + + if (bindingByName !== undefined) { + for (const trackName in bindingByName) { + const binding = bindingByName[trackName]; + binding.restoreOriginalState(); + this._removeInactiveBinding(binding); + } + } + } + + // remove a targeted clip from the cache + uncacheAction(clip, optionalRoot) { + const action = this.existingAction(clip, optionalRoot); + + if (action !== null) { + this._deactivateAction(action); + this._removeInactiveAction(action); + } + } +} + +AnimationMixer.prototype._controlInterpolantsResultBuffer = new Float32Array(1); + +export { AnimationMixer }; diff --git a/backend/libs/three/animation/AnimationObjectGroup.d.ts b/backend/libs/three/animation/AnimationObjectGroup.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c4ef485634d28dd5351bce46ed636bfda406fd14 --- /dev/null +++ b/backend/libs/three/animation/AnimationObjectGroup.d.ts @@ -0,0 +1,17 @@ +export class AnimationObjectGroup { + constructor(...args: any[]); + + uuid: string; + stats: { + bindingsPerObject: number; + objects: { + total: number; + inUse: number; + }; + }; + readonly isAnimationObjectGroup: true; + + add(...args: any[]): void; + remove(...args: any[]): void; + uncache(...args: any[]): void; +} diff --git a/backend/libs/three/animation/AnimationObjectGroup.js b/backend/libs/three/animation/AnimationObjectGroup.js new file mode 100644 index 0000000000000000000000000000000000000000..7a84bd17a3aa08be8c50ae8d90219c6a0230c2bc --- /dev/null +++ b/backend/libs/three/animation/AnimationObjectGroup.js @@ -0,0 +1,327 @@ +import { PropertyBinding } from './PropertyBinding.js'; +import * as MathUtils from '../math/MathUtils.js'; + +/** + * + * A group of objects that receives a shared animation state. + * + * Usage: + * + * - Add objects you would otherwise pass as 'root' to the + * constructor or the .clipAction method of AnimationMixer. + * + * - Instead pass this object as 'root'. + * + * - You can also add and remove objects later when the mixer + * is running. + * + * Note: + * + * Objects of this class appear as one object to the mixer, + * so cache control of the individual objects must be done + * on the group. + * + * Limitation: + * + * - The animated properties must be compatible among the + * all objects in the group. + * + * - A single property can either be controlled through a + * target group or directly, but not both. + */ + +class AnimationObjectGroup { + constructor() { + this.uuid = MathUtils.generateUUID(); + + // cached objects followed by the active ones + this._objects = Array.prototype.slice.call(arguments); + + this.nCachedObjects_ = 0; // threshold + // note: read by PropertyBinding.Composite + + const indices = {}; + this._indicesByUUID = indices; // for bookkeeping + + for (let i = 0, n = arguments.length; i !== n; ++i) { + indices[arguments[i].uuid] = i; + } + + this._paths = []; // inside: string + this._parsedPaths = []; // inside: { we don't care, here } + this._bindings = []; // inside: Array< PropertyBinding > + this._bindingsIndicesByPath = {}; // inside: indices in these arrays + + const scope = this; + + this.stats = { + objects: { + get total() { + return scope._objects.length; + }, + get inUse() { + return this.total - scope.nCachedObjects_; + }, + }, + get bindingsPerObject() { + return scope._bindings.length; + }, + }; + } + + add() { + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + paths = this._paths, + parsedPaths = this._parsedPaths, + bindings = this._bindings, + nBindings = bindings.length; + + let knownObject = undefined, + nObjects = objects.length, + nCachedObjects = this.nCachedObjects_; + + for (let i = 0, n = arguments.length; i !== n; ++i) { + const object = arguments[i], + uuid = object.uuid; + let index = indicesByUUID[uuid]; + + if (index === undefined) { + // unknown object -> add it to the ACTIVE region + + index = nObjects++; + indicesByUUID[uuid] = index; + objects.push(object); + + // accounting is done, now do the same for all bindings + + for (let j = 0, m = nBindings; j !== m; ++j) { + bindings[j].push(new PropertyBinding(object, paths[j], parsedPaths[j])); + } + } else if (index < nCachedObjects) { + knownObject = objects[index]; + + // move existing object to the ACTIVE region + + const firstActiveIndex = --nCachedObjects, + lastCachedObject = objects[firstActiveIndex]; + + indicesByUUID[lastCachedObject.uuid] = index; + objects[index] = lastCachedObject; + + indicesByUUID[uuid] = firstActiveIndex; + objects[firstActiveIndex] = object; + + // accounting is done, now do the same for all bindings + + for (let j = 0, m = nBindings; j !== m; ++j) { + const bindingsForPath = bindings[j], + lastCached = bindingsForPath[firstActiveIndex]; + + let binding = bindingsForPath[index]; + + bindingsForPath[index] = lastCached; + + if (binding === undefined) { + // since we do not bother to create new bindings + // for objects that are cached, the binding may + // or may not exist + + binding = new PropertyBinding(object, paths[j], parsedPaths[j]); + } + + bindingsForPath[firstActiveIndex] = binding; + } + } else if (objects[index] !== knownObject) { + console.error( + 'THREE.AnimationObjectGroup: Different objects with the same UUID ' + + 'detected. Clean the caches or recreate your infrastructure when reloading scenes.' + ); + } // else the object is already where we want it to be + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + } + + remove() { + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + bindings = this._bindings, + nBindings = bindings.length; + + let nCachedObjects = this.nCachedObjects_; + + for (let i = 0, n = arguments.length; i !== n; ++i) { + const object = arguments[i], + uuid = object.uuid, + index = indicesByUUID[uuid]; + + if (index !== undefined && index >= nCachedObjects) { + // move existing object into the CACHED region + + const lastCachedIndex = nCachedObjects++, + firstActiveObject = objects[lastCachedIndex]; + + indicesByUUID[firstActiveObject.uuid] = index; + objects[index] = firstActiveObject; + + indicesByUUID[uuid] = lastCachedIndex; + objects[lastCachedIndex] = object; + + // accounting is done, now do the same for all bindings + + for (let j = 0, m = nBindings; j !== m; ++j) { + const bindingsForPath = bindings[j], + firstActive = bindingsForPath[lastCachedIndex], + binding = bindingsForPath[index]; + + bindingsForPath[index] = firstActive; + bindingsForPath[lastCachedIndex] = binding; + } + } + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + } + + // remove & forget + uncache() { + const objects = this._objects, + indicesByUUID = this._indicesByUUID, + bindings = this._bindings, + nBindings = bindings.length; + + let nCachedObjects = this.nCachedObjects_, + nObjects = objects.length; + + for (let i = 0, n = arguments.length; i !== n; ++i) { + const object = arguments[i], + uuid = object.uuid, + index = indicesByUUID[uuid]; + + if (index !== undefined) { + delete indicesByUUID[uuid]; + + if (index < nCachedObjects) { + // object is cached, shrink the CACHED region + + const firstActiveIndex = --nCachedObjects, + lastCachedObject = objects[firstActiveIndex], + lastIndex = --nObjects, + lastObject = objects[lastIndex]; + + // last cached object takes this object's place + indicesByUUID[lastCachedObject.uuid] = index; + objects[index] = lastCachedObject; + + // last object goes to the activated slot and pop + indicesByUUID[lastObject.uuid] = firstActiveIndex; + objects[firstActiveIndex] = lastObject; + objects.pop(); + + // accounting is done, now do the same for all bindings + + for (let j = 0, m = nBindings; j !== m; ++j) { + const bindingsForPath = bindings[j], + lastCached = bindingsForPath[firstActiveIndex], + last = bindingsForPath[lastIndex]; + + bindingsForPath[index] = lastCached; + bindingsForPath[firstActiveIndex] = last; + bindingsForPath.pop(); + } + } else { + // object is active, just swap with the last and pop + + const lastIndex = --nObjects, + lastObject = objects[lastIndex]; + + if (lastIndex > 0) { + indicesByUUID[lastObject.uuid] = index; + } + + objects[index] = lastObject; + objects.pop(); + + // accounting is done, now do the same for all bindings + + for (let j = 0, m = nBindings; j !== m; ++j) { + const bindingsForPath = bindings[j]; + + bindingsForPath[index] = bindingsForPath[lastIndex]; + bindingsForPath.pop(); + } + } // cached or active + } // if object is known + } // for arguments + + this.nCachedObjects_ = nCachedObjects; + } + + // Internal interface used by befriended PropertyBinding.Composite: + + subscribe_(path, parsedPath) { + // returns an array of bindings for the given path that is changed + // according to the contained objects in the group + + const indicesByPath = this._bindingsIndicesByPath; + let index = indicesByPath[path]; + const bindings = this._bindings; + + if (index !== undefined) return bindings[index]; + + const paths = this._paths, + parsedPaths = this._parsedPaths, + objects = this._objects, + nObjects = objects.length, + nCachedObjects = this.nCachedObjects_, + bindingsForPath = new Array(nObjects); + + index = bindings.length; + + indicesByPath[path] = index; + + paths.push(path); + parsedPaths.push(parsedPath); + bindings.push(bindingsForPath); + + for (let i = nCachedObjects, n = objects.length; i !== n; ++i) { + const object = objects[i]; + bindingsForPath[i] = new PropertyBinding(object, path, parsedPath); + } + + return bindingsForPath; + } + + unsubscribe_(path) { + // tells the group to forget about a property path and no longer + // update the array previously obtained with 'subscribe_' + + const indicesByPath = this._bindingsIndicesByPath, + index = indicesByPath[path]; + + if (index !== undefined) { + const paths = this._paths, + parsedPaths = this._parsedPaths, + bindings = this._bindings, + lastBindingsIndex = bindings.length - 1, + lastBindings = bindings[lastBindingsIndex], + lastBindingsPath = path[lastBindingsIndex]; + + indicesByPath[lastBindingsPath] = index; + + bindings[index] = lastBindings; + bindings.pop(); + + parsedPaths[index] = parsedPaths[lastBindingsIndex]; + parsedPaths.pop(); + + paths[index] = paths[lastBindingsIndex]; + paths.pop(); + } + } +} + +AnimationObjectGroup.prototype.isAnimationObjectGroup = true; + +export { AnimationObjectGroup }; diff --git a/backend/libs/three/animation/AnimationUtils.d.ts b/backend/libs/three/animation/AnimationUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cd455374af2e75eb13f2ed0edafbf4b6b21364fd --- /dev/null +++ b/backend/libs/three/animation/AnimationUtils.d.ts @@ -0,0 +1,27 @@ +import { AnimationClip } from './AnimationClip'; + +export namespace AnimationUtils { + function arraySlice(array: any, from: number, to: number): any; + function convertArray(array: any, type: any, forceClone: boolean): any; + function isTypedArray(object: any): boolean; + function getKeyframeOrder(times: number[]): number[]; + function sortedArray(values: any[], stride: number, order: number[]): any[]; + function flattenJSON(jsonKeys: string[], times: any[], values: any[], valuePropertyName: string): void; + + /** + * @param sourceClip + * @param name + * @param startFrame + * @param endFrame + * @param [fps=30] + */ + function subclip(sourceClip: AnimationClip, name: string, startFrame: number, endFrame: number, fps?: number): AnimationClip; + + /** + * @param targetClip + * @param [referenceFrame=0] + * @param [referenceClip=targetClip] + * @param [fps=30] + */ + function makeClipAdditive(targetClip: AnimationClip, referenceFrame?: number, referenceClip?: AnimationClip, fps?: number): AnimationClip; +} diff --git a/backend/libs/three/animation/AnimationUtils.js b/backend/libs/three/animation/AnimationUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..8a15f07da28e2e5603a0e23460d16ac610a05aa7 --- /dev/null +++ b/backend/libs/three/animation/AnimationUtils.js @@ -0,0 +1,267 @@ +import { Quaternion } from '../math/Quaternion.js'; +import { AdditiveAnimationBlendMode } from '../constants.js'; + +const AnimationUtils = { + // same as Array.prototype.slice, but also works on typed arrays + arraySlice: function (array, from, to) { + if (AnimationUtils.isTypedArray(array)) { + // in ios9 array.subarray(from, undefined) will return empty array + // but array.subarray(from) or array.subarray(from, len) is correct + return new array.constructor(array.subarray(from, to !== undefined ? to : array.length)); + } + + return array.slice(from, to); + }, + + // converts an array to a specific type + convertArray: function (array, type, forceClone) { + if ( + !array || // let 'undefined' and 'null' pass + (!forceClone && array.constructor === type) + ) + return array; + + if (typeof type.BYTES_PER_ELEMENT === 'number') { + return new type(array); // create typed array + } + + return Array.prototype.slice.call(array); // create Array + }, + + isTypedArray: function (object) { + return ArrayBuffer.isView(object) && !(object instanceof DataView); + }, + + // returns an array by which times and values can be sorted + getKeyframeOrder: function (times) { + function compareTime(i, j) { + return times[i] - times[j]; + } + + const n = times.length; + const result = new Array(n); + for (let i = 0; i !== n; ++i) result[i] = i; + + result.sort(compareTime); + + return result; + }, + + // uses the array previously returned by 'getKeyframeOrder' to sort data + sortedArray: function (values, stride, order) { + const nValues = values.length; + const result = new values.constructor(nValues); + + for (let i = 0, dstOffset = 0; dstOffset !== nValues; ++i) { + const srcOffset = order[i] * stride; + + for (let j = 0; j !== stride; ++j) { + result[dstOffset++] = values[srcOffset + j]; + } + } + + return result; + }, + + // function for parsing AOS keyframe formats + flattenJSON: function (jsonKeys, times, values, valuePropertyName) { + let i = 1, + key = jsonKeys[0]; + + while (key !== undefined && key[valuePropertyName] === undefined) { + key = jsonKeys[i++]; + } + + if (key === undefined) return; // no data + + let value = key[valuePropertyName]; + if (value === undefined) return; // no data + + if (Array.isArray(value)) { + do { + value = key[valuePropertyName]; + + if (value !== undefined) { + times.push(key.time); + values.push.apply(values, value); // push all elements + } + + key = jsonKeys[i++]; + } while (key !== undefined); + } else if (value.toArray !== undefined) { + // ...assume THREE.Math-ish + + do { + value = key[valuePropertyName]; + + if (value !== undefined) { + times.push(key.time); + value.toArray(values, values.length); + } + + key = jsonKeys[i++]; + } while (key !== undefined); + } else { + // otherwise push as-is + + do { + value = key[valuePropertyName]; + + if (value !== undefined) { + times.push(key.time); + values.push(value); + } + + key = jsonKeys[i++]; + } while (key !== undefined); + } + }, + + subclip: function (sourceClip, name, startFrame, endFrame, fps = 30) { + const clip = sourceClip.clone(); + + clip.name = name; + + const tracks = []; + + for (let i = 0; i < clip.tracks.length; ++i) { + const track = clip.tracks[i]; + const valueSize = track.getValueSize(); + + const times = []; + const values = []; + + for (let j = 0; j < track.times.length; ++j) { + const frame = track.times[j] * fps; + + if (frame < startFrame || frame >= endFrame) continue; + + times.push(track.times[j]); + + for (let k = 0; k < valueSize; ++k) { + values.push(track.values[j * valueSize + k]); + } + } + + if (times.length === 0) continue; + + track.times = AnimationUtils.convertArray(times, track.times.constructor); + track.values = AnimationUtils.convertArray(values, track.values.constructor); + + tracks.push(track); + } + + clip.tracks = tracks; + + // find minimum .times value across all tracks in the trimmed clip + + let minStartTime = Infinity; + + for (let i = 0; i < clip.tracks.length; ++i) { + if (minStartTime > clip.tracks[i].times[0]) { + minStartTime = clip.tracks[i].times[0]; + } + } + + // shift all tracks such that clip begins at t=0 + + for (let i = 0; i < clip.tracks.length; ++i) { + clip.tracks[i].shift(-1 * minStartTime); + } + + clip.resetDuration(); + + return clip; + }, + + makeClipAdditive: function (targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30) { + if (fps <= 0) fps = 30; + + const numTracks = referenceClip.tracks.length; + const referenceTime = referenceFrame / fps; + + // Make each track's values relative to the values at the reference frame + for (let i = 0; i < numTracks; ++i) { + const referenceTrack = referenceClip.tracks[i]; + const referenceTrackType = referenceTrack.ValueTypeName; + + // Skip this track if it's non-numeric + if (referenceTrackType === 'bool' || referenceTrackType === 'string') continue; + + // Find the track in the target clip whose name and type matches the reference track + const targetTrack = targetClip.tracks.find(function (track) { + return track.name === referenceTrack.name && track.ValueTypeName === referenceTrackType; + }); + + if (targetTrack === undefined) continue; + + let referenceOffset = 0; + const referenceValueSize = referenceTrack.getValueSize(); + + if (referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) { + referenceOffset = referenceValueSize / 3; + } + + let targetOffset = 0; + const targetValueSize = targetTrack.getValueSize(); + + if (targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) { + targetOffset = targetValueSize / 3; + } + + const lastIndex = referenceTrack.times.length - 1; + let referenceValue; + + // Find the value to subtract out of the track + if (referenceTime <= referenceTrack.times[0]) { + // Reference frame is earlier than the first keyframe, so just use the first keyframe + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice(referenceTrack.values, startIndex, endIndex); + } else if (referenceTime >= referenceTrack.times[lastIndex]) { + // Reference frame is after the last keyframe, so just use the last keyframe + const startIndex = lastIndex * referenceValueSize + referenceOffset; + const endIndex = startIndex + referenceValueSize - referenceOffset; + referenceValue = AnimationUtils.arraySlice(referenceTrack.values, startIndex, endIndex); + } else { + // Interpolate to the reference value + const interpolant = referenceTrack.createInterpolant(); + const startIndex = referenceOffset; + const endIndex = referenceValueSize - referenceOffset; + interpolant.evaluate(referenceTime); + referenceValue = AnimationUtils.arraySlice(interpolant.resultBuffer, startIndex, endIndex); + } + + // Conjugate the quaternion + if (referenceTrackType === 'quaternion') { + const referenceQuat = new Quaternion().fromArray(referenceValue).normalize().conjugate(); + referenceQuat.toArray(referenceValue); + } + + // Subtract the reference value from all of the track values + + const numTimes = targetTrack.times.length; + for (let j = 0; j < numTimes; ++j) { + const valueStart = j * targetValueSize + targetOffset; + + if (referenceTrackType === 'quaternion') { + // Multiply the conjugate for quaternion track types + Quaternion.multiplyQuaternionsFlat(targetTrack.values, valueStart, referenceValue, 0, targetTrack.values, valueStart); + } else { + const valueEnd = targetValueSize - targetOffset * 2; + + // Subtract each value for all other numeric track types + for (let k = 0; k < valueEnd; ++k) { + targetTrack.values[valueStart + k] -= referenceValue[k]; + } + } + } + } + + targetClip.blendMode = AdditiveAnimationBlendMode; + + return targetClip; + }, +}; + +export { AnimationUtils }; diff --git a/backend/libs/three/animation/KeyframeTrack.d.ts b/backend/libs/three/animation/KeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d59e323a54bf4122fda787a9ba34401e001f4bce --- /dev/null +++ b/backend/libs/three/animation/KeyframeTrack.d.ts @@ -0,0 +1,45 @@ +import { DiscreteInterpolant } from './../math/interpolants/DiscreteInterpolant'; +import { LinearInterpolant } from './../math/interpolants/LinearInterpolant'; +import { CubicInterpolant } from './../math/interpolants/CubicInterpolant'; +import { InterpolationModes } from '../constants'; + +export class KeyframeTrack { + /** + * @param name + * @param times + * @param values + * @param [interpolation=THREE.InterpolateLinear] + */ + constructor(name: string, times: ArrayLike, values: ArrayLike, interpolation?: InterpolationModes); + + name: string; + times: Float32Array; + values: Float32Array; + + ValueTypeName: string; + TimeBufferType: Float32Array; + ValueBufferType: Float32Array; + + /** + * @default THREE.InterpolateLinear + */ + DefaultInterpolation: InterpolationModes; + + InterpolantFactoryMethodDiscrete(result: any): DiscreteInterpolant; + InterpolantFactoryMethodLinear(result: any): LinearInterpolant; + InterpolantFactoryMethodSmooth(result: any): CubicInterpolant; + + setInterpolation(interpolation: InterpolationModes): KeyframeTrack; + getInterpolation(): InterpolationModes; + + getValueSize(): number; + + shift(timeOffset: number): KeyframeTrack; + scale(timeScale: number): KeyframeTrack; + trim(startTime: number, endTime: number): KeyframeTrack; + validate(): boolean; + optimize(): KeyframeTrack; + clone(): this; + + static toJSON(track: KeyframeTrack): any; +} diff --git a/backend/libs/three/animation/KeyframeTrack.js b/backend/libs/three/animation/KeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..bc3c7ad41fb7fab12438093f6d95e0595225fefe --- /dev/null +++ b/backend/libs/three/animation/KeyframeTrack.js @@ -0,0 +1,337 @@ +import { InterpolateLinear, InterpolateSmooth, InterpolateDiscrete } from '../constants.js'; +import { CubicInterpolant } from '../math/interpolants/CubicInterpolant.js'; +import { LinearInterpolant } from '../math/interpolants/LinearInterpolant.js'; +import { DiscreteInterpolant } from '../math/interpolants/DiscreteInterpolant.js'; +import { AnimationUtils } from './AnimationUtils.js'; + +class KeyframeTrack { + constructor(name, times, values, interpolation) { + if (name === undefined) throw new Error('THREE.KeyframeTrack: track name is undefined'); + if (times === undefined || times.length === 0) throw new Error('THREE.KeyframeTrack: no keyframes in track named ' + name); + + this.name = name; + + this.times = AnimationUtils.convertArray(times, this.TimeBufferType); + this.values = AnimationUtils.convertArray(values, this.ValueBufferType); + + this.setInterpolation(interpolation || this.DefaultInterpolation); + } + + // Serialization (in static context, because of constructor invocation + // and automatic invocation of .toJSON): + + static toJSON(track) { + const trackType = track.constructor; + + let json; + + // derived classes can define a static toJSON method + if (trackType.toJSON !== this.toJSON) { + json = trackType.toJSON(track); + } else { + // by default, we assume the data can be serialized as-is + json = { + name: track.name, + times: AnimationUtils.convertArray(track.times, Array), + values: AnimationUtils.convertArray(track.values, Array), + }; + + const interpolation = track.getInterpolation(); + + if (interpolation !== track.DefaultInterpolation) { + json.interpolation = interpolation; + } + } + + json.type = track.ValueTypeName; // mandatory + + return json; + } + + InterpolantFactoryMethodDiscrete(result) { + return new DiscreteInterpolant(this.times, this.values, this.getValueSize(), result); + } + + InterpolantFactoryMethodLinear(result) { + return new LinearInterpolant(this.times, this.values, this.getValueSize(), result); + } + + InterpolantFactoryMethodSmooth(result) { + return new CubicInterpolant(this.times, this.values, this.getValueSize(), result); + } + + setInterpolation(interpolation) { + let factoryMethod; + + switch (interpolation) { + case InterpolateDiscrete: + factoryMethod = this.InterpolantFactoryMethodDiscrete; + + break; + + case InterpolateLinear: + factoryMethod = this.InterpolantFactoryMethodLinear; + + break; + + case InterpolateSmooth: + factoryMethod = this.InterpolantFactoryMethodSmooth; + + break; + } + + if (factoryMethod === undefined) { + const message = 'unsupported interpolation for ' + this.ValueTypeName + ' keyframe track named ' + this.name; + + if (this.createInterpolant === undefined) { + // fall back to default, unless the default itself is messed up + if (interpolation !== this.DefaultInterpolation) { + this.setInterpolation(this.DefaultInterpolation); + } else { + throw new Error(message); // fatal, in this case + } + } + + console.warn('THREE.KeyframeTrack:', message); + return this; + } + + this.createInterpolant = factoryMethod; + + return this; + } + + getInterpolation() { + switch (this.createInterpolant) { + case this.InterpolantFactoryMethodDiscrete: + return InterpolateDiscrete; + + case this.InterpolantFactoryMethodLinear: + return InterpolateLinear; + + case this.InterpolantFactoryMethodSmooth: + return InterpolateSmooth; + } + } + + getValueSize() { + return this.values.length / this.times.length; + } + + // move all keyframes either forwards or backwards in time + shift(timeOffset) { + if (timeOffset !== 0.0) { + const times = this.times; + + for (let i = 0, n = times.length; i !== n; ++i) { + times[i] += timeOffset; + } + } + + return this; + } + + // scale all keyframe times by a factor (useful for frame <-> seconds conversions) + scale(timeScale) { + if (timeScale !== 1.0) { + const times = this.times; + + for (let i = 0, n = times.length; i !== n; ++i) { + times[i] *= timeScale; + } + } + + return this; + } + + // removes keyframes before and after animation without changing any values within the range [startTime, endTime]. + // IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values + trim(startTime, endTime) { + const times = this.times, + nKeys = times.length; + + let from = 0, + to = nKeys - 1; + + while (from !== nKeys && times[from] < startTime) { + ++from; + } + + while (to !== -1 && times[to] > endTime) { + --to; + } + + ++to; // inclusive -> exclusive bound + + if (from !== 0 || to !== nKeys) { + // empty tracks are forbidden, so keep at least one keyframe + if (from >= to) { + to = Math.max(to, 1); + from = to - 1; + } + + const stride = this.getValueSize(); + this.times = AnimationUtils.arraySlice(times, from, to); + this.values = AnimationUtils.arraySlice(this.values, from * stride, to * stride); + } + + return this; + } + + // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable + validate() { + let valid = true; + + const valueSize = this.getValueSize(); + if (valueSize - Math.floor(valueSize) !== 0) { + console.error('THREE.KeyframeTrack: Invalid value size in track.', this); + valid = false; + } + + const times = this.times, + values = this.values, + nKeys = times.length; + + if (nKeys === 0) { + console.error('THREE.KeyframeTrack: Track is empty.', this); + valid = false; + } + + let prevTime = null; + + for (let i = 0; i !== nKeys; i++) { + const currTime = times[i]; + + if (typeof currTime === 'number' && isNaN(currTime)) { + console.error('THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime); + valid = false; + break; + } + + if (prevTime !== null && prevTime > currTime) { + console.error('THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime); + valid = false; + break; + } + + prevTime = currTime; + } + + if (values !== undefined) { + if (AnimationUtils.isTypedArray(values)) { + for (let i = 0, n = values.length; i !== n; ++i) { + const value = values[i]; + + if (isNaN(value)) { + console.error('THREE.KeyframeTrack: Value is not a valid number.', this, i, value); + valid = false; + break; + } + } + } + } + + return valid; + } + + // removes equivalent sequential keys as common in morph target sequences + // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) + optimize() { + // times or values may be shared with other tracks, so overwriting is unsafe + const times = AnimationUtils.arraySlice(this.times), + values = AnimationUtils.arraySlice(this.values), + stride = this.getValueSize(), + smoothInterpolation = this.getInterpolation() === InterpolateSmooth, + lastIndex = times.length - 1; + + let writeIndex = 1; + + for (let i = 1; i < lastIndex; ++i) { + let keep = false; + + const time = times[i]; + const timeNext = times[i + 1]; + + // remove adjacent keyframes scheduled at the same time + + if (time !== timeNext && (i !== 1 || time !== times[0])) { + if (!smoothInterpolation) { + // remove unnecessary keyframes same as their neighbors + + const offset = i * stride, + offsetP = offset - stride, + offsetN = offset + stride; + + for (let j = 0; j !== stride; ++j) { + const value = values[offset + j]; + + if (value !== values[offsetP + j] || value !== values[offsetN + j]) { + keep = true; + break; + } + } + } else { + keep = true; + } + } + + // in-place compaction + + if (keep) { + if (i !== writeIndex) { + times[writeIndex] = times[i]; + + const readOffset = i * stride, + writeOffset = writeIndex * stride; + + for (let j = 0; j !== stride; ++j) { + values[writeOffset + j] = values[readOffset + j]; + } + } + + ++writeIndex; + } + } + + // flush last keyframe (compaction looks ahead) + + if (lastIndex > 0) { + times[writeIndex] = times[lastIndex]; + + for (let readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++j) { + values[writeOffset + j] = values[readOffset + j]; + } + + ++writeIndex; + } + + if (writeIndex !== times.length) { + this.times = AnimationUtils.arraySlice(times, 0, writeIndex); + this.values = AnimationUtils.arraySlice(values, 0, writeIndex * stride); + } else { + this.times = times; + this.values = values; + } + + return this; + } + + clone() { + const times = AnimationUtils.arraySlice(this.times, 0); + const values = AnimationUtils.arraySlice(this.values, 0); + + const TypedKeyframeTrack = this.constructor; + const track = new TypedKeyframeTrack(this.name, times, values); + + // Interpolant argument to constructor is not saved, so copy the factory method directly. + track.createInterpolant = this.createInterpolant; + + return track; + } +} + +KeyframeTrack.prototype.TimeBufferType = Float32Array; +KeyframeTrack.prototype.ValueBufferType = Float32Array; +KeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; + +export { KeyframeTrack }; diff --git a/backend/libs/three/animation/PropertyBinding.d.ts b/backend/libs/three/animation/PropertyBinding.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8908dc54ab171256e6ee2c018f2fc872a1db080b --- /dev/null +++ b/backend/libs/three/animation/PropertyBinding.d.ts @@ -0,0 +1,43 @@ +export interface ParseTrackNameResults { + nodeName: string; + objectName: string; + objectIndex: string; + propertyName: string; + propertyIndex: string; +} + +export class PropertyBinding { + constructor(rootNode: any, path: string, parsedPath?: any); + + path: string; + parsedPath: any; + node: any; + rootNode: any; + + getValue(targetArray: any, offset: number): any; + setValue(sourceArray: any, offset: number): void; + bind(): void; + unbind(): void; + + BindingType: { [bindingType: string]: number }; + Versioning: { [versioning: string]: number }; + + GetterByBindingType: Array<() => void>; + SetterByBindingTypeAndVersioning: Array void>>; + + static create(root: any, path: any, parsedPath?: any): PropertyBinding | PropertyBinding.Composite; + static sanitizeNodeName(name: string): string; + static parseTrackName(trackName: string): ParseTrackNameResults; + static findNode(root: any, nodeName: string): any; +} + +export namespace PropertyBinding { + class Composite { + constructor(targetGroup: any, path: any, parsedPath?: any); + + getValue(array: any, offset: number): any; + setValue(array: any, offset: number): void; + bind(): void; + unbind(): void; + } +} diff --git a/backend/libs/three/animation/PropertyBinding.js b/backend/libs/three/animation/PropertyBinding.js new file mode 100644 index 0000000000000000000000000000000000000000..79d8ce7fcf27747e6dc141c12a27168b46504bca --- /dev/null +++ b/backend/libs/three/animation/PropertyBinding.js @@ -0,0 +1,534 @@ +// Characters [].:/ are reserved for track binding syntax. +const _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +const _reservedRe = new RegExp('[' + _RESERVED_CHARS_RE + ']', 'g'); + +// Attempts to allow node names from any language. ES5's `\w` regexp matches +// only latin characters, and the unicode \p{L} is not yet supported. So +// instead, we exclude reserved characters and match everything else. +const _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; +const _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace('\\.', '') + ']'; + +// Parent directories, delimited by '/' or ':'. Currently unused, but must +// be matched to parse the rest of the track name. +const _directoryRe = /((?:WC+[\/:])*)/.source.replace('WC', _wordChar); + +// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. +const _nodeRe = /(WCOD+)?/.source.replace('WCOD', _wordCharOrDot); + +// Object on target node, and accessor. May not contain reserved +// characters. Accessor may contain any character except closing bracket. +const _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace('WC', _wordChar); + +// Property and accessor. May not contain reserved characters. Accessor may +// contain any non-bracket characters. +const _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace('WC', _wordChar); + +const _trackRe = new RegExp('' + '^' + _directoryRe + _nodeRe + _objectRe + _propertyRe + '$'); + +const _supportedObjectNames = ['material', 'materials', 'bones']; + +class Composite { + constructor(targetGroup, path, optionalParsedPath) { + const parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path); + + this._targetGroup = targetGroup; + this._bindings = targetGroup.subscribe_(path, parsedPath); + } + + getValue(array, offset) { + this.bind(); // bind all binding + + const firstValidIndex = this._targetGroup.nCachedObjects_, + binding = this._bindings[firstValidIndex]; + + // and only call .getValue on the first + if (binding !== undefined) binding.getValue(array, offset); + } + + setValue(array, offset) { + const bindings = this._bindings; + + for (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) { + bindings[i].setValue(array, offset); + } + } + + bind() { + const bindings = this._bindings; + + for (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) { + bindings[i].bind(); + } + } + + unbind() { + const bindings = this._bindings; + + for (let i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) { + bindings[i].unbind(); + } + } +} + +// Note: This class uses a State pattern on a per-method basis: +// 'bind' sets 'this.getValue' / 'setValue' and shadows the +// prototype version of these methods with one that represents +// the bound state. When the property is not found, the methods +// become no-ops. +class PropertyBinding { + constructor(rootNode, path, parsedPath) { + this.path = path; + this.parsedPath = parsedPath || PropertyBinding.parseTrackName(path); + + this.node = PropertyBinding.findNode(rootNode, this.parsedPath.nodeName) || rootNode; + + this.rootNode = rootNode; + + // initial state of these methods that calls 'bind' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + } + + static create(root, path, parsedPath) { + if (!(root && root.isAnimationObjectGroup)) { + return new PropertyBinding(root, path, parsedPath); + } else { + return new PropertyBinding.Composite(root, path, parsedPath); + } + } + + /** + * Replaces spaces with underscores and removes unsupported characters from + * node names, to ensure compatibility with parseTrackName(). + * + * @param {string} name Node name to be sanitized. + * @return {string} + */ + static sanitizeNodeName(name) { + return name.replace(/\s/g, '_').replace(_reservedRe, ''); + } + + static parseTrackName(trackName) { + const matches = _trackRe.exec(trackName); + + if (!matches) { + throw new Error('PropertyBinding: Cannot parse trackName: ' + trackName); + } + + const results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[2], + objectName: matches[3], + objectIndex: matches[4], + propertyName: matches[5], // required + propertyIndex: matches[6], + }; + + const lastDot = results.nodeName && results.nodeName.lastIndexOf('.'); + + if (lastDot !== undefined && lastDot !== -1) { + const objectName = results.nodeName.substring(lastDot + 1); + + // Object names must be checked against an allowlist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if (_supportedObjectNames.indexOf(objectName) !== -1) { + results.nodeName = results.nodeName.substring(0, lastDot); + results.objectName = objectName; + } + } + + if (results.propertyName === null || results.propertyName.length === 0) { + throw new Error('PropertyBinding: can not parse propertyName from trackName: ' + trackName); + } + + return results; + } + + static findNode(root, nodeName) { + if (!nodeName || nodeName === '' || nodeName === '.' || nodeName === -1 || nodeName === root.name || nodeName === root.uuid) { + return root; + } + + // search into skeleton bones. + if (root.skeleton) { + const bone = root.skeleton.getBoneByName(nodeName); + + if (bone !== undefined) { + return bone; + } + } + + // search into node subtree. + if (root.children) { + const searchNodeSubtree = function (children) { + for (let i = 0; i < children.length; i++) { + const childNode = children[i]; + + if (childNode.name === nodeName || childNode.uuid === nodeName) { + return childNode; + } + + const result = searchNodeSubtree(childNode.children); + + if (result) return result; + } + + return null; + }; + + const subTreeNode = searchNodeSubtree(root.children); + + if (subTreeNode) { + return subTreeNode; + } + } + + return null; + } + + // these are used to "bind" a nonexistent property + _getValue_unavailable() {} + _setValue_unavailable() {} + + // Getters + + _getValue_direct(buffer, offset) { + buffer[offset] = this.targetObject[this.propertyName]; + } + + _getValue_array(buffer, offset) { + const source = this.resolvedProperty; + + for (let i = 0, n = source.length; i !== n; ++i) { + buffer[offset++] = source[i]; + } + } + + _getValue_arrayElement(buffer, offset) { + buffer[offset] = this.resolvedProperty[this.propertyIndex]; + } + + _getValue_toArray(buffer, offset) { + this.resolvedProperty.toArray(buffer, offset); + } + + // Direct + + _setValue_direct(buffer, offset) { + this.targetObject[this.propertyName] = buffer[offset]; + } + + _setValue_direct_setNeedsUpdate(buffer, offset) { + this.targetObject[this.propertyName] = buffer[offset]; + this.targetObject.needsUpdate = true; + } + + _setValue_direct_setMatrixWorldNeedsUpdate(buffer, offset) { + this.targetObject[this.propertyName] = buffer[offset]; + this.targetObject.matrixWorldNeedsUpdate = true; + } + + // EntireArray + + _setValue_array(buffer, offset) { + const dest = this.resolvedProperty; + + for (let i = 0, n = dest.length; i !== n; ++i) { + dest[i] = buffer[offset++]; + } + } + + _setValue_array_setNeedsUpdate(buffer, offset) { + const dest = this.resolvedProperty; + + for (let i = 0, n = dest.length; i !== n; ++i) { + dest[i] = buffer[offset++]; + } + + this.targetObject.needsUpdate = true; + } + + _setValue_array_setMatrixWorldNeedsUpdate(buffer, offset) { + const dest = this.resolvedProperty; + + for (let i = 0, n = dest.length; i !== n; ++i) { + dest[i] = buffer[offset++]; + } + + this.targetObject.matrixWorldNeedsUpdate = true; + } + + // ArrayElement + + _setValue_arrayElement(buffer, offset) { + this.resolvedProperty[this.propertyIndex] = buffer[offset]; + } + + _setValue_arrayElement_setNeedsUpdate(buffer, offset) { + this.resolvedProperty[this.propertyIndex] = buffer[offset]; + this.targetObject.needsUpdate = true; + } + + _setValue_arrayElement_setMatrixWorldNeedsUpdate(buffer, offset) { + this.resolvedProperty[this.propertyIndex] = buffer[offset]; + this.targetObject.matrixWorldNeedsUpdate = true; + } + + // HasToFromArray + + _setValue_fromArray(buffer, offset) { + this.resolvedProperty.fromArray(buffer, offset); + } + + _setValue_fromArray_setNeedsUpdate(buffer, offset) { + this.resolvedProperty.fromArray(buffer, offset); + this.targetObject.needsUpdate = true; + } + + _setValue_fromArray_setMatrixWorldNeedsUpdate(buffer, offset) { + this.resolvedProperty.fromArray(buffer, offset); + this.targetObject.matrixWorldNeedsUpdate = true; + } + + _getValue_unbound(targetArray, offset) { + this.bind(); + this.getValue(targetArray, offset); + } + + _setValue_unbound(sourceArray, offset) { + this.bind(); + this.setValue(sourceArray, offset); + } + + // create getter / setter pair for a property in the scene graph + bind() { + let targetObject = this.node; + const parsedPath = this.parsedPath; + + const objectName = parsedPath.objectName; + const propertyName = parsedPath.propertyName; + let propertyIndex = parsedPath.propertyIndex; + + if (!targetObject) { + targetObject = PropertyBinding.findNode(this.rootNode, parsedPath.nodeName) || this.rootNode; + + this.node = targetObject; + } + + // set fail state so we can just 'return' on error + this.getValue = this._getValue_unavailable; + this.setValue = this._setValue_unavailable; + + // ensure there is a value node + if (!targetObject) { + console.error('THREE.PropertyBinding: Trying to update node for track: ' + this.path + " but it wasn't found."); + return; + } + + if (objectName) { + let objectIndex = parsedPath.objectIndex; + + // special cases were we need to reach deeper into the hierarchy to get the face materials.... + switch (objectName) { + case 'materials': + if (!targetObject.material) { + console.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this); + return; + } + + if (!targetObject.material.materials) { + console.error('THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this); + return; + } + + targetObject = targetObject.material.materials; + + break; + + case 'bones': + if (!targetObject.skeleton) { + console.error('THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this); + return; + } + + // potential future optimization: skip this if propertyIndex is already an integer + // and convert the integer string to a true integer. + + targetObject = targetObject.skeleton.bones; + + // support resolving morphTarget names into indices. + for (let i = 0; i < targetObject.length; i++) { + if (targetObject[i].name === objectIndex) { + objectIndex = i; + break; + } + } + + break; + + default: + if (targetObject[objectName] === undefined) { + console.error('THREE.PropertyBinding: Can not bind to objectName of node undefined.', this); + return; + } + + targetObject = targetObject[objectName]; + } + + if (objectIndex !== undefined) { + if (targetObject[objectIndex] === undefined) { + console.error('THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject); + return; + } + + targetObject = targetObject[objectIndex]; + } + } + + // resolve property + const nodeProperty = targetObject[propertyName]; + + if (nodeProperty === undefined) { + const nodeName = parsedPath.nodeName; + + console.error( + 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName + '.' + propertyName + " but it wasn't found.", + targetObject + ); + return; + } + + // determine versioning scheme + let versioning = this.Versioning.None; + + this.targetObject = targetObject; + + if (targetObject.needsUpdate !== undefined) { + // material + + versioning = this.Versioning.NeedsUpdate; + } else if (targetObject.matrixWorldNeedsUpdate !== undefined) { + // node transform + + versioning = this.Versioning.MatrixWorldNeedsUpdate; + } + + // determine how the property gets bound + let bindingType = this.BindingType.Direct; + + if (propertyIndex !== undefined) { + // access a sub element of the property array (only primitives are supported right now) + + if (propertyName === 'morphTargetInfluences') { + // potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. + + // support resolving morphTarget names into indices. + if (!targetObject.geometry) { + console.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this); + return; + } + + if (targetObject.geometry.isBufferGeometry) { + if (!targetObject.geometry.morphAttributes) { + console.error( + 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', + this + ); + return; + } + + if (targetObject.morphTargetDictionary[propertyIndex] !== undefined) { + propertyIndex = targetObject.morphTargetDictionary[propertyIndex]; + } + } else { + console.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.', this); + return; + } + } + + bindingType = this.BindingType.ArrayElement; + + this.resolvedProperty = nodeProperty; + this.propertyIndex = propertyIndex; + } else if (nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined) { + // must use copy for Object3D.Euler/Quaternion + + bindingType = this.BindingType.HasFromToArray; + + this.resolvedProperty = nodeProperty; + } else if (Array.isArray(nodeProperty)) { + bindingType = this.BindingType.EntireArray; + + this.resolvedProperty = nodeProperty; + } else { + this.propertyName = propertyName; + } + + // select getter / setter + this.getValue = this.GetterByBindingType[bindingType]; + this.setValue = this.SetterByBindingTypeAndVersioning[bindingType][versioning]; + } + + unbind() { + this.node = null; + + // back to the prototype version of getValue / setValue + // note: avoiding to mutate the shape of 'this' via 'delete' + this.getValue = this._getValue_unbound; + this.setValue = this._setValue_unbound; + } +} + +PropertyBinding.Composite = Composite; + +PropertyBinding.prototype.BindingType = { + Direct: 0, + EntireArray: 1, + ArrayElement: 2, + HasFromToArray: 3, +}; + +PropertyBinding.prototype.Versioning = { + None: 0, + NeedsUpdate: 1, + MatrixWorldNeedsUpdate: 2, +}; + +PropertyBinding.prototype.GetterByBindingType = [ + PropertyBinding.prototype._getValue_direct, + PropertyBinding.prototype._getValue_array, + PropertyBinding.prototype._getValue_arrayElement, + PropertyBinding.prototype._getValue_toArray, +]; + +PropertyBinding.prototype.SetterByBindingTypeAndVersioning = [ + [ + // Direct + PropertyBinding.prototype._setValue_direct, + PropertyBinding.prototype._setValue_direct_setNeedsUpdate, + PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate, + ], + [ + // EntireArray + + PropertyBinding.prototype._setValue_array, + PropertyBinding.prototype._setValue_array_setNeedsUpdate, + PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate, + ], + [ + // ArrayElement + PropertyBinding.prototype._setValue_arrayElement, + PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate, + PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate, + ], + [ + // HasToFromArray + PropertyBinding.prototype._setValue_fromArray, + PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate, + PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate, + ], +]; + +export { PropertyBinding }; diff --git a/backend/libs/three/animation/PropertyMixer.d.ts b/backend/libs/three/animation/PropertyMixer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b78555c1a86743b1f599acf5dd3483a953cff8c4 --- /dev/null +++ b/backend/libs/three/animation/PropertyMixer.d.ts @@ -0,0 +1,17 @@ +export class PropertyMixer { + constructor(binding: any, typeName: string, valueSize: number); + + binding: any; + valueSize: number; + buffer: any; + cumulativeWeight: number; + cumulativeWeightAdditive: number; + useCount: number; + referenceCount: number; + + accumulate(accuIndex: number, weight: number): void; + accumulateAdditive(weight: number): void; + apply(accuIndex: number): void; + saveOriginalState(): void; + restoreOriginalState(): void; +} diff --git a/backend/libs/three/animation/PropertyMixer.js b/backend/libs/three/animation/PropertyMixer.js new file mode 100644 index 0000000000000000000000000000000000000000..7a94c716f3c1a4653a406c5a7e64f9475e08dca5 --- /dev/null +++ b/backend/libs/three/animation/PropertyMixer.js @@ -0,0 +1,248 @@ +import { Quaternion } from '../math/Quaternion.js'; + +class PropertyMixer { + constructor(binding, typeName, valueSize) { + this.binding = binding; + this.valueSize = valueSize; + + let mixFunction, mixFunctionAdditive, setIdentity; + + // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ] + // + // interpolators can use .buffer as their .result + // the data then goes to 'incoming' + // + // 'accu0' and 'accu1' are used frame-interleaved for + // the cumulative result and are compared to detect + // changes + // + // 'orig' stores the original state of the property + // + // 'add' is used for additive cumulative results + // + // 'work' is optional and is only present for quaternion types. It is used + // to store intermediate quaternion multiplication results + + switch (typeName) { + case 'quaternion': + mixFunction = this._slerp; + mixFunctionAdditive = this._slerpAdditive; + setIdentity = this._setAdditiveIdentityQuaternion; + + this.buffer = new Float64Array(valueSize * 6); + this._workIndex = 5; + break; + + case 'string': + case 'bool': + mixFunction = this._select; + + // Use the regular mix function and for additive on these types, + // additive is not relevant for non-numeric types + mixFunctionAdditive = this._select; + + setIdentity = this._setAdditiveIdentityOther; + + this.buffer = new Array(valueSize * 5); + break; + + default: + mixFunction = this._lerp; + mixFunctionAdditive = this._lerpAdditive; + setIdentity = this._setAdditiveIdentityNumeric; + + this.buffer = new Float64Array(valueSize * 5); + } + + this._mixBufferRegion = mixFunction; + this._mixBufferRegionAdditive = mixFunctionAdditive; + this._setIdentity = setIdentity; + this._origIndex = 3; + this._addIndex = 4; + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + + this.useCount = 0; + this.referenceCount = 0; + } + + // accumulate data in the 'incoming' region into 'accu' + accumulate(accuIndex, weight) { + // note: happily accumulating nothing when weight = 0, the caller knows + // the weight and shouldn't have made the call in the first place + + const buffer = this.buffer, + stride = this.valueSize, + offset = accuIndex * stride + stride; + + let currentWeight = this.cumulativeWeight; + + if (currentWeight === 0) { + // accuN := incoming * weight + + for (let i = 0; i !== stride; ++i) { + buffer[offset + i] = buffer[i]; + } + + currentWeight = weight; + } else { + // accuN := accuN + incoming * weight + + currentWeight += weight; + const mix = weight / currentWeight; + this._mixBufferRegion(buffer, offset, 0, mix, stride); + } + + this.cumulativeWeight = currentWeight; + } + + // accumulate data in the 'incoming' region into 'add' + accumulateAdditive(weight) { + const buffer = this.buffer, + stride = this.valueSize, + offset = stride * this._addIndex; + + if (this.cumulativeWeightAdditive === 0) { + // add = identity + + this._setIdentity(); + } + + // add := add + incoming * weight + + this._mixBufferRegionAdditive(buffer, offset, 0, weight, stride); + this.cumulativeWeightAdditive += weight; + } + + // apply the state of 'accu' to the binding when accus differ + apply(accuIndex) { + const stride = this.valueSize, + buffer = this.buffer, + offset = accuIndex * stride + stride, + weight = this.cumulativeWeight, + weightAdditive = this.cumulativeWeightAdditive, + binding = this.binding; + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + + if (weight < 1) { + // accuN := accuN + original * ( 1 - cumulativeWeight ) + + const originalValueOffset = stride * this._origIndex; + + this._mixBufferRegion(buffer, offset, originalValueOffset, 1 - weight, stride); + } + + if (weightAdditive > 0) { + // accuN := accuN + additive accuN + + this._mixBufferRegionAdditive(buffer, offset, this._addIndex * stride, 1, stride); + } + + for (let i = stride, e = stride + stride; i !== e; ++i) { + if (buffer[i] !== buffer[i + stride]) { + // value has changed -> update scene graph + + binding.setValue(buffer, offset); + break; + } + } + } + + // remember the state of the bound property and copy it to both accus + saveOriginalState() { + const binding = this.binding; + + const buffer = this.buffer, + stride = this.valueSize, + originalValueOffset = stride * this._origIndex; + + binding.getValue(buffer, originalValueOffset); + + // accu[0..1] := orig -- initially detect changes against the original + for (let i = stride, e = originalValueOffset; i !== e; ++i) { + buffer[i] = buffer[originalValueOffset + (i % stride)]; + } + + // Add to identity for additive + this._setIdentity(); + + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; + } + + // apply the state previously taken via 'saveOriginalState' to the binding + restoreOriginalState() { + const originalValueOffset = this.valueSize * 3; + this.binding.setValue(this.buffer, originalValueOffset); + } + + _setAdditiveIdentityNumeric() { + const startIndex = this._addIndex * this.valueSize; + const endIndex = startIndex + this.valueSize; + + for (let i = startIndex; i < endIndex; i++) { + this.buffer[i] = 0; + } + } + + _setAdditiveIdentityQuaternion() { + this._setAdditiveIdentityNumeric(); + this.buffer[this._addIndex * this.valueSize + 3] = 1; + } + + _setAdditiveIdentityOther() { + const startIndex = this._origIndex * this.valueSize; + const targetIndex = this._addIndex * this.valueSize; + + for (let i = 0; i < this.valueSize; i++) { + this.buffer[targetIndex + i] = this.buffer[startIndex + i]; + } + } + + // mix functions + + _select(buffer, dstOffset, srcOffset, t, stride) { + if (t >= 0.5) { + for (let i = 0; i !== stride; ++i) { + buffer[dstOffset + i] = buffer[srcOffset + i]; + } + } + } + + _slerp(buffer, dstOffset, srcOffset, t) { + Quaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t); + } + + _slerpAdditive(buffer, dstOffset, srcOffset, t, stride) { + const workOffset = this._workIndex * stride; + + // Store result in intermediate buffer offset + Quaternion.multiplyQuaternionsFlat(buffer, workOffset, buffer, dstOffset, buffer, srcOffset); + + // Slerp to the intermediate result + Quaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t); + } + + _lerp(buffer, dstOffset, srcOffset, t, stride) { + const s = 1 - t; + + for (let i = 0; i !== stride; ++i) { + const j = dstOffset + i; + + buffer[j] = buffer[j] * s + buffer[srcOffset + i] * t; + } + } + + _lerpAdditive(buffer, dstOffset, srcOffset, t, stride) { + for (let i = 0; i !== stride; ++i) { + const j = dstOffset + i; + + buffer[j] = buffer[j] + buffer[srcOffset + i] * t; + } + } +} + +export { PropertyMixer }; diff --git a/backend/libs/three/animation/tracks/BooleanKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/BooleanKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..29e414d2edb110579de93971efa27e6d555d785f --- /dev/null +++ b/backend/libs/three/animation/tracks/BooleanKeyframeTrack.d.ts @@ -0,0 +1,10 @@ +import { KeyframeTrack } from './../KeyframeTrack'; + +export class BooleanKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[]); + + /** + * @default 'bool' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/BooleanKeyframeTrack.js b/backend/libs/three/animation/tracks/BooleanKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..277b3696318a3b93e6c5249716dc03439f8fa181 --- /dev/null +++ b/backend/libs/three/animation/tracks/BooleanKeyframeTrack.js @@ -0,0 +1,19 @@ +import { InterpolateDiscrete } from '../../constants.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; + +/** + * A Track of Boolean keyframe values. + */ +class BooleanKeyframeTrack extends KeyframeTrack {} + +BooleanKeyframeTrack.prototype.ValueTypeName = 'bool'; +BooleanKeyframeTrack.prototype.ValueBufferType = Array; +BooleanKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +// Note: Actually this track could have a optimized / compressed +// representation of a single value and a custom interpolant that +// computes "firstValue ^ isOdd( index )". + +export { BooleanKeyframeTrack }; diff --git a/backend/libs/three/animation/tracks/ColorKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/ColorKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..57817d5ccb1f9d9c567709a4a94d87407ce8ed9a --- /dev/null +++ b/backend/libs/three/animation/tracks/ColorKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class ColorKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[], interpolation?: InterpolationModes); + + /** + * @default 'color' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/ColorKeyframeTrack.js b/backend/libs/three/animation/tracks/ColorKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..ee789efac129d25d8d0101e25d1ca061bad661be --- /dev/null +++ b/backend/libs/three/animation/tracks/ColorKeyframeTrack.js @@ -0,0 +1,15 @@ +import { KeyframeTrack } from '../KeyframeTrack.js'; + +/** + * A Track of keyframe values that represent color. + */ +class ColorKeyframeTrack extends KeyframeTrack {} + +ColorKeyframeTrack.prototype.ValueTypeName = 'color'; +// ValueBufferType is inherited +// DefaultInterpolation is inherited + +// Note: Very basic implementation and nothing special yet. +// However, this is the place for color space parameterization. + +export { ColorKeyframeTrack }; diff --git a/backend/libs/three/animation/tracks/NumberKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/NumberKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0ac5277378fec9a4fa361c7a89a33146d03358a7 --- /dev/null +++ b/backend/libs/three/animation/tracks/NumberKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class NumberKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[], interpolation?: InterpolationModes); + + /** + * @default 'number' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/NumberKeyframeTrack.js b/backend/libs/three/animation/tracks/NumberKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..58b74ca540c2f396a118b85de2db5d15f599ac12 --- /dev/null +++ b/backend/libs/three/animation/tracks/NumberKeyframeTrack.js @@ -0,0 +1,12 @@ +import { KeyframeTrack } from '../KeyframeTrack.js'; + +/** + * A Track of numeric keyframe values. + */ +class NumberKeyframeTrack extends KeyframeTrack {} + +NumberKeyframeTrack.prototype.ValueTypeName = 'number'; +// ValueBufferType is inherited +// DefaultInterpolation is inherited + +export { NumberKeyframeTrack }; diff --git a/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e107c5f0fd148881564bbb2783f4fd156caeb6ab --- /dev/null +++ b/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class QuaternionKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[], interpolation?: InterpolationModes); + + /** + * @default 'quaternion' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.js b/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..5ea10f1746e6c1c187847a3641bb3102e51e11e0 --- /dev/null +++ b/backend/libs/three/animation/tracks/QuaternionKeyframeTrack.js @@ -0,0 +1,19 @@ +import { InterpolateLinear } from '../../constants.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; +import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js'; + +/** + * A Track of quaternion keyframe values. + */ +class QuaternionKeyframeTrack extends KeyframeTrack { + InterpolantFactoryMethodLinear(result) { + return new QuaternionLinearInterpolant(this.times, this.values, this.getValueSize(), result); + } +} + +QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion'; +// ValueBufferType is inherited +QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; +QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +export { QuaternionKeyframeTrack }; diff --git a/backend/libs/three/animation/tracks/StringKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/StringKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..dd3271c1bd3c496ef45752a084d6936c8459fd03 --- /dev/null +++ b/backend/libs/three/animation/tracks/StringKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class StringKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[], interpolation?: InterpolationModes); + + /** + * @default 'string' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/StringKeyframeTrack.js b/backend/libs/three/animation/tracks/StringKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..e7e615703e183c61a136bef9499e7acd24c2d460 --- /dev/null +++ b/backend/libs/three/animation/tracks/StringKeyframeTrack.js @@ -0,0 +1,15 @@ +import { InterpolateDiscrete } from '../../constants.js'; +import { KeyframeTrack } from '../KeyframeTrack.js'; + +/** + * A Track that interpolates Strings + */ +class StringKeyframeTrack extends KeyframeTrack {} + +StringKeyframeTrack.prototype.ValueTypeName = 'string'; +StringKeyframeTrack.prototype.ValueBufferType = Array; +StringKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; +StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; +StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; + +export { StringKeyframeTrack }; diff --git a/backend/libs/three/animation/tracks/VectorKeyframeTrack.d.ts b/backend/libs/three/animation/tracks/VectorKeyframeTrack.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b02c9ed8011f05732d3ffb69e685457fd5a11110 --- /dev/null +++ b/backend/libs/three/animation/tracks/VectorKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class VectorKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[], interpolation?: InterpolationModes); + + /** + * @default 'vector' + */ + ValueTypeName: string; +} diff --git a/backend/libs/three/animation/tracks/VectorKeyframeTrack.js b/backend/libs/three/animation/tracks/VectorKeyframeTrack.js new file mode 100644 index 0000000000000000000000000000000000000000..bdccf8b22534653e37e1e2d38bb20e2f9aec3e03 --- /dev/null +++ b/backend/libs/three/animation/tracks/VectorKeyframeTrack.js @@ -0,0 +1,12 @@ +import { KeyframeTrack } from '../KeyframeTrack.js'; + +/** + * A Track of vectored keyframe values. + */ +class VectorKeyframeTrack extends KeyframeTrack {} + +VectorKeyframeTrack.prototype.ValueTypeName = 'vector'; +// ValueBufferType is inherited +// DefaultInterpolation is inherited + +export { VectorKeyframeTrack }; diff --git a/backend/libs/three/audio/Audio.d.ts b/backend/libs/three/audio/Audio.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f367969a02757512db8483d8f9429c2461d0665e --- /dev/null +++ b/backend/libs/three/audio/Audio.d.ts @@ -0,0 +1,106 @@ +import { Object3D } from './../core/Object3D'; +import { AudioListener } from './AudioListener'; +import { AudioContext } from './AudioContext'; + +// Extras / Audio ///////////////////////////////////////////////////////////////////// + +export class Audio extends Object3D { + constructor(listener: AudioListener); + type: 'Audio'; + + listener: AudioListener; + context: AudioContext; + gain: GainNode; + + /** + * @default false + */ + autoplay: boolean; + buffer: null | AudioBuffer; + + /** + * @default 0 + */ + detune: number; + + /** + * @default false + */ + loop: boolean; + + /** + * @default 0 + */ + loopStart: number; + + /** + * @default 0 + */ + loopEnd: number; + + /** + * @default 0 + */ + offset: number; + + /** + * @default undefined + */ + duration: number | undefined; + + /** + * @default 1 + */ + playbackRate: number; + + /** + * @default false + */ + isPlaying: boolean; + + /** + * @default true + */ + hasPlaybackControl: boolean; + + /** + * @default 'empty' + */ + sourceType: string; + source: null | AudioBufferSourceNode; + + /** + * @default [] + */ + filters: AudioNode[]; + + getOutput(): NodeType; + setNodeSource(audioNode: AudioBufferSourceNode): this; + setMediaElementSource(mediaElement: HTMLMediaElement): this; + setMediaStreamSource(mediaStream: MediaStream): this; + setBuffer(audioBuffer: AudioBuffer): this; + play(delay?: number): this; + onEnded(): void; + pause(): this; + stop(): this; + connect(): this; + disconnect(): this; + setDetune(value: number): this; + getDetune(): number; + getFilters(): AudioNode[]; + setFilters(value: AudioNode[]): this; + getFilter(): AudioNode; + setFilter(filter: AudioNode): this; + setPlaybackRate(value: number): this; + getPlaybackRate(): number; + getLoop(): boolean; + setLoop(value: boolean): this; + setLoopStart(value: number): this; + setLoopEnd(value: number): this; + getVolume(): number; + setVolume(value: number): this; + /** + * @deprecated Use {@link AudioLoader} instead. + */ + load(file: string): Audio; +} diff --git a/backend/libs/three/audio/Audio.js b/backend/libs/three/audio/Audio.js new file mode 100644 index 0000000000000000000000000000000000000000..8c22ea07ca3a919b53395d6acc4619e971c204de --- /dev/null +++ b/backend/libs/three/audio/Audio.js @@ -0,0 +1,297 @@ +import { Object3D } from '../core/Object3D.js'; + +class Audio extends Object3D { + constructor(listener) { + super(); + + this.type = 'Audio'; + + this.listener = listener; + this.context = listener.context; + + this.gain = this.context.createGain(); + this.gain.connect(listener.getInput()); + + this.autoplay = false; + + this.buffer = null; + this.detune = 0; + this.loop = false; + this.loopStart = 0; + this.loopEnd = 0; + this.offset = 0; + this.duration = undefined; + this.playbackRate = 1; + this.isPlaying = false; + this.hasPlaybackControl = true; + this.source = null; + this.sourceType = 'empty'; + + this._startedAt = 0; + this._progress = 0; + this._connected = false; + + this.filters = []; + } + + getOutput() { + return this.gain; + } + + setNodeSource(audioNode) { + this.hasPlaybackControl = false; + this.sourceType = 'audioNode'; + this.source = audioNode; + this.connect(); + + return this; + } + + setMediaElementSource(mediaElement) { + this.hasPlaybackControl = false; + this.sourceType = 'mediaNode'; + this.source = this.context.createMediaElementSource(mediaElement); + this.connect(); + + return this; + } + + setMediaStreamSource(mediaStream) { + this.hasPlaybackControl = false; + this.sourceType = 'mediaStreamNode'; + this.source = this.context.createMediaStreamSource(mediaStream); + this.connect(); + + return this; + } + + setBuffer(audioBuffer) { + this.buffer = audioBuffer; + this.sourceType = 'buffer'; + + if (this.autoplay) this.play(); + + return this; + } + + play(delay = 0) { + if (this.isPlaying === true) { + console.warn('THREE.Audio: Audio is already playing.'); + return; + } + + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return; + } + + this._startedAt = this.context.currentTime + delay; + + const source = this.context.createBufferSource(); + source.buffer = this.buffer; + source.loop = this.loop; + source.loopStart = this.loopStart; + source.loopEnd = this.loopEnd; + source.onended = this.onEnded.bind(this); + source.start(this._startedAt, this._progress + this.offset, this.duration); + + this.isPlaying = true; + + this.source = source; + + this.setDetune(this.detune); + this.setPlaybackRate(this.playbackRate); + + return this.connect(); + } + + pause() { + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return; + } + + if (this.isPlaying === true) { + // update current progress + + this._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate; + + if (this.loop === true) { + // ensure _progress does not exceed duration with looped audios + + this._progress = this._progress % (this.duration || this.buffer.duration); + } + + this.source.stop(); + this.source.onended = null; + + this.isPlaying = false; + } + + return this; + } + + stop() { + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return; + } + + this._progress = 0; + + this.source.stop(); + this.source.onended = null; + this.isPlaying = false; + + return this; + } + + connect() { + if (this.filters.length > 0) { + this.source.connect(this.filters[0]); + + for (let i = 1, l = this.filters.length; i < l; i++) { + this.filters[i - 1].connect(this.filters[i]); + } + + this.filters[this.filters.length - 1].connect(this.getOutput()); + } else { + this.source.connect(this.getOutput()); + } + + this._connected = true; + + return this; + } + + disconnect() { + if (this.filters.length > 0) { + this.source.disconnect(this.filters[0]); + + for (let i = 1, l = this.filters.length; i < l; i++) { + this.filters[i - 1].disconnect(this.filters[i]); + } + + this.filters[this.filters.length - 1].disconnect(this.getOutput()); + } else { + this.source.disconnect(this.getOutput()); + } + + this._connected = false; + + return this; + } + + getFilters() { + return this.filters; + } + + setFilters(value) { + if (!value) value = []; + + if (this._connected === true) { + this.disconnect(); + this.filters = value.slice(); + this.connect(); + } else { + this.filters = value.slice(); + } + + return this; + } + + setDetune(value) { + this.detune = value; + + if (this.source.detune === undefined) return; // only set detune when available + + if (this.isPlaying === true) { + this.source.detune.setTargetAtTime(this.detune, this.context.currentTime, 0.01); + } + + return this; + } + + getDetune() { + return this.detune; + } + + getFilter() { + return this.getFilters()[0]; + } + + setFilter(filter) { + return this.setFilters(filter ? [filter] : []); + } + + setPlaybackRate(value) { + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return; + } + + this.playbackRate = value; + + if (this.isPlaying === true) { + this.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, 0.01); + } + + return this; + } + + getPlaybackRate() { + return this.playbackRate; + } + + onEnded() { + this.isPlaying = false; + } + + getLoop() { + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return false; + } + + return this.loop; + } + + setLoop(value) { + if (this.hasPlaybackControl === false) { + console.warn('THREE.Audio: this Audio has no playback control.'); + return; + } + + this.loop = value; + + if (this.isPlaying === true) { + this.source.loop = this.loop; + } + + return this; + } + + setLoopStart(value) { + this.loopStart = value; + + return this; + } + + setLoopEnd(value) { + this.loopEnd = value; + + return this; + } + + getVolume() { + return this.gain.gain.value; + } + + setVolume(value) { + this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01); + + return this; + } +} + +export { Audio }; diff --git a/backend/libs/three/audio/AudioAnalyser.d.ts b/backend/libs/three/audio/AudioAnalyser.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..506a80be4c8bed37ec05815e1fb101992590d34b --- /dev/null +++ b/backend/libs/three/audio/AudioAnalyser.d.ts @@ -0,0 +1,20 @@ +import { Audio } from './Audio'; + +export class AudioAnalyser { + /** + * @param audio + * @param [fftSize=2048] + */ + constructor(audio: Audio, fftSize?: number); + + analyser: AnalyserNode; + data: Uint8Array; + + getFrequencyData(): Uint8Array; + getAverageFrequency(): number; + + /** + * @deprecated Use {@link AudioAnalyser#getFrequencyData .getFrequencyData()} instead. + */ + getData(file: any): any; +} diff --git a/backend/libs/three/audio/AudioAnalyser.js b/backend/libs/three/audio/AudioAnalyser.js new file mode 100644 index 0000000000000000000000000000000000000000..72c9f35094adc00ec625e84200a37c258a58e272 --- /dev/null +++ b/backend/libs/three/audio/AudioAnalyser.js @@ -0,0 +1,29 @@ +class AudioAnalyser { + constructor(audio, fftSize = 2048) { + this.analyser = audio.context.createAnalyser(); + this.analyser.fftSize = fftSize; + + this.data = new Uint8Array(this.analyser.frequencyBinCount); + + audio.getOutput().connect(this.analyser); + } + + getFrequencyData() { + this.analyser.getByteFrequencyData(this.data); + + return this.data; + } + + getAverageFrequency() { + let value = 0; + const data = this.getFrequencyData(); + + for (let i = 0; i < data.length; i++) { + value += data[i]; + } + + return value / data.length; + } +} + +export { AudioAnalyser }; diff --git a/backend/libs/three/audio/AudioContext.d.ts b/backend/libs/three/audio/AudioContext.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..40a8ab771f2a414a671716ddb30a8b0d85e0be82 --- /dev/null +++ b/backend/libs/three/audio/AudioContext.d.ts @@ -0,0 +1,8 @@ +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/audio/AudioContext.js|src/audio/AudioContext.js} + */ +export namespace AudioContext { + function getContext(): AudioContext; + + function setContext(): void; +} diff --git a/backend/libs/three/audio/AudioContext.js b/backend/libs/three/audio/AudioContext.js new file mode 100644 index 0000000000000000000000000000000000000000..c42a0601e6473160373f45fc3926d794147130b0 --- /dev/null +++ b/backend/libs/three/audio/AudioContext.js @@ -0,0 +1,17 @@ +let _context; + +const AudioContext = { + getContext: function () { + if (_context === undefined) { + _context = new (window.AudioContext || window.webkitAudioContext)(); + } + + return _context; + }, + + setContext: function (value) { + _context = value; + }, +}; + +export { AudioContext }; diff --git a/backend/libs/three/audio/AudioListener.d.ts b/backend/libs/three/audio/AudioListener.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f2414436a46a14a2e3ab5884e7dcf3beb301b04b --- /dev/null +++ b/backend/libs/three/audio/AudioListener.d.ts @@ -0,0 +1,28 @@ +import { Object3D } from './../core/Object3D'; +import { AudioContext } from './AudioContext'; + +export class AudioListener extends Object3D { + constructor(); + + type: 'AudioListener'; + context: AudioContext; + gain: GainNode; + + /** + * @default null + */ + filter: any; + + /** + * @default 0 + */ + timeDelta: number; + + getInput(): GainNode; + removeFilter(): this; + setFilter(value: any): this; + getFilter(): any; + setMasterVolume(value: number): this; + getMasterVolume(): number; + updateMatrixWorld(force?: boolean): void; +} diff --git a/backend/libs/three/audio/AudioListener.js b/backend/libs/three/audio/AudioListener.js new file mode 100644 index 0000000000000000000000000000000000000000..2fa26c8dbf76d636d56f60d8b7272ffca2b54abd --- /dev/null +++ b/backend/libs/three/audio/AudioListener.js @@ -0,0 +1,109 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Quaternion } from '../math/Quaternion.js'; +import { Clock } from '../core/Clock.js'; +import { Object3D } from '../core/Object3D.js'; +import { AudioContext } from './AudioContext.js'; + +const _position = /*@__PURE__*/ new Vector3(); +const _quaternion = /*@__PURE__*/ new Quaternion(); +const _scale = /*@__PURE__*/ new Vector3(); +const _orientation = /*@__PURE__*/ new Vector3(); + +class AudioListener extends Object3D { + constructor() { + super(); + + this.type = 'AudioListener'; + + this.context = AudioContext.getContext(); + + this.gain = this.context.createGain(); + this.gain.connect(this.context.destination); + + this.filter = null; + + this.timeDelta = 0; + + // private + + this._clock = new Clock(); + } + + getInput() { + return this.gain; + } + + removeFilter() { + if (this.filter !== null) { + this.gain.disconnect(this.filter); + this.filter.disconnect(this.context.destination); + this.gain.connect(this.context.destination); + this.filter = null; + } + + return this; + } + + getFilter() { + return this.filter; + } + + setFilter(value) { + if (this.filter !== null) { + this.gain.disconnect(this.filter); + this.filter.disconnect(this.context.destination); + } else { + this.gain.disconnect(this.context.destination); + } + + this.filter = value; + this.gain.connect(this.filter); + this.filter.connect(this.context.destination); + + return this; + } + + getMasterVolume() { + return this.gain.gain.value; + } + + setMasterVolume(value) { + this.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01); + + return this; + } + + updateMatrixWorld(force) { + super.updateMatrixWorld(force); + + const listener = this.context.listener; + const up = this.up; + + this.timeDelta = this._clock.getDelta(); + + this.matrixWorld.decompose(_position, _quaternion, _scale); + + _orientation.set(0, 0, -1).applyQuaternion(_quaternion); + + if (listener.positionX) { + // code path for Chrome (see #14393) + + const endTime = this.context.currentTime + this.timeDelta; + + listener.positionX.linearRampToValueAtTime(_position.x, endTime); + listener.positionY.linearRampToValueAtTime(_position.y, endTime); + listener.positionZ.linearRampToValueAtTime(_position.z, endTime); + listener.forwardX.linearRampToValueAtTime(_orientation.x, endTime); + listener.forwardY.linearRampToValueAtTime(_orientation.y, endTime); + listener.forwardZ.linearRampToValueAtTime(_orientation.z, endTime); + listener.upX.linearRampToValueAtTime(up.x, endTime); + listener.upY.linearRampToValueAtTime(up.y, endTime); + listener.upZ.linearRampToValueAtTime(up.z, endTime); + } else { + listener.setPosition(_position.x, _position.y, _position.z); + listener.setOrientation(_orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z); + } + } +} + +export { AudioListener }; diff --git a/backend/libs/three/audio/PositionalAudio.d.ts b/backend/libs/three/audio/PositionalAudio.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..feda5fe5d6ddb321d62a2b574a69a1a61785b250 --- /dev/null +++ b/backend/libs/three/audio/PositionalAudio.d.ts @@ -0,0 +1,20 @@ +import { AudioListener } from './AudioListener'; +import { Audio } from './Audio'; + +export class PositionalAudio extends Audio { + constructor(listener: AudioListener); + + panner: PannerNode; + + getOutput(): PannerNode; + setRefDistance(value: number): this; + getRefDistance(): number; + setRolloffFactor(value: number): this; + getRolloffFactor(): number; + setDistanceModel(value: string): this; + getDistanceModel(): string; + setMaxDistance(value: number): this; + getMaxDistance(): number; + setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): this; + updateMatrixWorld(force?: boolean): void; +} diff --git a/backend/libs/three/audio/PositionalAudio.js b/backend/libs/three/audio/PositionalAudio.js new file mode 100644 index 0000000000000000000000000000000000000000..3684b48211084cffaf1165ac73029083651e3dd4 --- /dev/null +++ b/backend/libs/three/audio/PositionalAudio.js @@ -0,0 +1,100 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Quaternion } from '../math/Quaternion.js'; +import { Audio } from './Audio.js'; + +const _position = /*@__PURE__*/ new Vector3(); +const _quaternion = /*@__PURE__*/ new Quaternion(); +const _scale = /*@__PURE__*/ new Vector3(); +const _orientation = /*@__PURE__*/ new Vector3(); + +class PositionalAudio extends Audio { + constructor(listener) { + super(listener); + + this.panner = this.context.createPanner(); + this.panner.panningModel = 'HRTF'; + this.panner.connect(this.gain); + } + + getOutput() { + return this.panner; + } + + getRefDistance() { + return this.panner.refDistance; + } + + setRefDistance(value) { + this.panner.refDistance = value; + + return this; + } + + getRolloffFactor() { + return this.panner.rolloffFactor; + } + + setRolloffFactor(value) { + this.panner.rolloffFactor = value; + + return this; + } + + getDistanceModel() { + return this.panner.distanceModel; + } + + setDistanceModel(value) { + this.panner.distanceModel = value; + + return this; + } + + getMaxDistance() { + return this.panner.maxDistance; + } + + setMaxDistance(value) { + this.panner.maxDistance = value; + + return this; + } + + setDirectionalCone(coneInnerAngle, coneOuterAngle, coneOuterGain) { + this.panner.coneInnerAngle = coneInnerAngle; + this.panner.coneOuterAngle = coneOuterAngle; + this.panner.coneOuterGain = coneOuterGain; + + return this; + } + + updateMatrixWorld(force) { + super.updateMatrixWorld(force); + + if (this.hasPlaybackControl === true && this.isPlaying === false) return; + + this.matrixWorld.decompose(_position, _quaternion, _scale); + + _orientation.set(0, 0, 1).applyQuaternion(_quaternion); + + const panner = this.panner; + + if (panner.positionX) { + // code path for Chrome and Firefox (see #14393) + + const endTime = this.context.currentTime + this.listener.timeDelta; + + panner.positionX.linearRampToValueAtTime(_position.x, endTime); + panner.positionY.linearRampToValueAtTime(_position.y, endTime); + panner.positionZ.linearRampToValueAtTime(_position.z, endTime); + panner.orientationX.linearRampToValueAtTime(_orientation.x, endTime); + panner.orientationY.linearRampToValueAtTime(_orientation.y, endTime); + panner.orientationZ.linearRampToValueAtTime(_orientation.z, endTime); + } else { + panner.setPosition(_position.x, _position.y, _position.z); + panner.setOrientation(_orientation.x, _orientation.y, _orientation.z); + } + } +} + +export { PositionalAudio }; diff --git a/backend/libs/three/cameras/ArrayCamera.d.ts b/backend/libs/three/cameras/ArrayCamera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..20118d24e1d83066f8dad1bd68b89dceb8f3a422 --- /dev/null +++ b/backend/libs/three/cameras/ArrayCamera.d.ts @@ -0,0 +1,11 @@ +import { PerspectiveCamera } from './PerspectiveCamera'; + +export class ArrayCamera extends PerspectiveCamera { + constructor(cameras?: PerspectiveCamera[]); + + /** + * @default [] + */ + cameras: PerspectiveCamera[]; + readonly isArrayCamera: true; +} diff --git a/backend/libs/three/cameras/ArrayCamera.js b/backend/libs/three/cameras/ArrayCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..45aa1b3e5865ec6f6b978a2002d4ebad031a5510 --- /dev/null +++ b/backend/libs/three/cameras/ArrayCamera.js @@ -0,0 +1,13 @@ +import { PerspectiveCamera } from './PerspectiveCamera.js'; + +class ArrayCamera extends PerspectiveCamera { + constructor(array = []) { + super(); + + this.cameras = array; + } +} + +ArrayCamera.prototype.isArrayCamera = true; + +export { ArrayCamera }; diff --git a/backend/libs/three/cameras/Camera.d.ts b/backend/libs/three/cameras/Camera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1e58b29ba6f56b4bc4f625a23ad01820bab5883e --- /dev/null +++ b/backend/libs/three/cameras/Camera.d.ts @@ -0,0 +1,39 @@ +import { Matrix4 } from './../math/Matrix4'; +import { Vector3 } from './../math/Vector3'; +import { Object3D } from './../core/Object3D'; + +// Cameras //////////////////////////////////////////////////////////////////////////////////////// + +/** + * Abstract base class for cameras. This class should always be inherited when you build a new camera. + */ +export class Camera extends Object3D { + /** + * This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse. + */ + constructor(); + + /** + * This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera. + * @default new THREE.Matrix4() + */ + matrixWorldInverse: Matrix4; + + /** + * This is the matrix which contains the projection. + * @default new THREE.Matrix4() + */ + projectionMatrix: Matrix4; + + /** + * This is the inverse of projectionMatrix. + * @default new THREE.Matrix4() + */ + projectionMatrixInverse: Matrix4; + + readonly isCamera: true; + + getWorldDirection(target: Vector3): Vector3; + + updateMatrixWorld(force?: boolean): void; +} diff --git a/backend/libs/three/cameras/Camera.js b/backend/libs/three/cameras/Camera.js new file mode 100644 index 0000000000000000000000000000000000000000..22c133070d60077fb47b44cad776ffb3c3abafe5 --- /dev/null +++ b/backend/libs/three/cameras/Camera.js @@ -0,0 +1,54 @@ +import { Matrix4 } from '../math/Matrix4.js'; +import { Object3D } from '../core/Object3D.js'; + +class Camera extends Object3D { + constructor() { + super(); + + this.type = 'Camera'; + + this.matrixWorldInverse = new Matrix4(); + + this.projectionMatrix = new Matrix4(); + this.projectionMatrixInverse = new Matrix4(); + } + + copy(source, recursive) { + super.copy(source, recursive); + + this.matrixWorldInverse.copy(source.matrixWorldInverse); + + this.projectionMatrix.copy(source.projectionMatrix); + this.projectionMatrixInverse.copy(source.projectionMatrixInverse); + + return this; + } + + getWorldDirection(target) { + this.updateWorldMatrix(true, false); + + const e = this.matrixWorld.elements; + + return target.set(-e[8], -e[9], -e[10]).normalize(); + } + + updateMatrixWorld(force) { + super.updateMatrixWorld(force); + + this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + + updateWorldMatrix(updateParents, updateChildren) { + super.updateWorldMatrix(updateParents, updateChildren); + + this.matrixWorldInverse.copy(this.matrixWorld).invert(); + } + + clone() { + return new this.constructor().copy(this); + } +} + +Camera.prototype.isCamera = true; + +export { Camera }; diff --git a/backend/libs/three/cameras/CubeCamera.d.ts b/backend/libs/three/cameras/CubeCamera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1cd68d85c6adf845eaf69d4b3a1589c70b180671 --- /dev/null +++ b/backend/libs/three/cameras/CubeCamera.d.ts @@ -0,0 +1,14 @@ +import { WebGLCubeRenderTarget } from './../renderers/WebGLCubeRenderTarget'; +import { Scene } from './../scenes/Scene'; +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Object3D } from './../core/Object3D'; + +export class CubeCamera extends Object3D { + constructor(near: number, far: number, renderTarget: WebGLCubeRenderTarget); + + type: 'CubeCamera'; + + renderTarget: WebGLCubeRenderTarget; + + update(renderer: WebGLRenderer, scene: Scene): void; +} diff --git a/backend/libs/three/cameras/CubeCamera.js b/backend/libs/three/cameras/CubeCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..d97099b90f66c20fa4e7c61d26bd28e5068ecfb5 --- /dev/null +++ b/backend/libs/three/cameras/CubeCamera.js @@ -0,0 +1,102 @@ +import { Object3D } from '../core/Object3D.js'; +import { Vector3 } from '../math/Vector3.js'; +import { PerspectiveCamera } from './PerspectiveCamera.js'; + +const fov = 90, + aspect = 1; + +class CubeCamera extends Object3D { + constructor(near, far, renderTarget) { + super(); + + this.type = 'CubeCamera'; + + if (renderTarget.isWebGLCubeRenderTarget !== true) { + console.error('THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.'); + return; + } + + this.renderTarget = renderTarget; + + const cameraPX = new PerspectiveCamera(fov, aspect, near, far); + cameraPX.layers = this.layers; + cameraPX.up.set(0, -1, 0); + cameraPX.lookAt(new Vector3(1, 0, 0)); + this.add(cameraPX); + + const cameraNX = new PerspectiveCamera(fov, aspect, near, far); + cameraNX.layers = this.layers; + cameraNX.up.set(0, -1, 0); + cameraNX.lookAt(new Vector3(-1, 0, 0)); + this.add(cameraNX); + + const cameraPY = new PerspectiveCamera(fov, aspect, near, far); + cameraPY.layers = this.layers; + cameraPY.up.set(0, 0, 1); + cameraPY.lookAt(new Vector3(0, 1, 0)); + this.add(cameraPY); + + const cameraNY = new PerspectiveCamera(fov, aspect, near, far); + cameraNY.layers = this.layers; + cameraNY.up.set(0, 0, -1); + cameraNY.lookAt(new Vector3(0, -1, 0)); + this.add(cameraNY); + + const cameraPZ = new PerspectiveCamera(fov, aspect, near, far); + cameraPZ.layers = this.layers; + cameraPZ.up.set(0, -1, 0); + cameraPZ.lookAt(new Vector3(0, 0, 1)); + this.add(cameraPZ); + + const cameraNZ = new PerspectiveCamera(fov, aspect, near, far); + cameraNZ.layers = this.layers; + cameraNZ.up.set(0, -1, 0); + cameraNZ.lookAt(new Vector3(0, 0, -1)); + this.add(cameraNZ); + } + + update(renderer, scene) { + if (this.parent === null) this.updateMatrixWorld(); + + const renderTarget = this.renderTarget; + + const [cameraPX, cameraNX, cameraPY, cameraNY, cameraPZ, cameraNZ] = this.children; + + const currentXrEnabled = renderer.xr.enabled; + const currentRenderTarget = renderer.getRenderTarget(); + + renderer.xr.enabled = false; + + const generateMipmaps = renderTarget.texture.generateMipmaps; + + renderTarget.texture.generateMipmaps = false; + + renderer.setRenderTarget(renderTarget, 0); + renderer.render(scene, cameraPX); + + renderer.setRenderTarget(renderTarget, 1); + renderer.render(scene, cameraNX); + + renderer.setRenderTarget(renderTarget, 2); + renderer.render(scene, cameraPY); + + renderer.setRenderTarget(renderTarget, 3); + renderer.render(scene, cameraNY); + + renderer.setRenderTarget(renderTarget, 4); + renderer.render(scene, cameraPZ); + + renderTarget.texture.generateMipmaps = generateMipmaps; + + renderer.setRenderTarget(renderTarget, 5); + renderer.render(scene, cameraNZ); + + renderer.setRenderTarget(currentRenderTarget); + + renderer.xr.enabled = currentXrEnabled; + + renderTarget.texture.needsPMREMUpdate = true; + } +} + +export { CubeCamera }; diff --git a/backend/libs/three/cameras/OrthographicCamera.d.ts b/backend/libs/three/cameras/OrthographicCamera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e28e663ff44c6ed8816345075733b1babd8d4a29 --- /dev/null +++ b/backend/libs/three/cameras/OrthographicCamera.d.ts @@ -0,0 +1,88 @@ +import { Camera } from './Camera'; + +/** + * Camera with orthographic projection + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/OrthographicCamera.js|src/cameras/OrthographicCamera.js} + * + * @example + * const camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + * scene.add( camera ); + */ +export class OrthographicCamera extends Camera { + /** + * @param left Camera frustum left plane. + * @param right Camera frustum right plane. + * @param top Camera frustum top plane. + * @param bottom Camera frustum bottom plane. + * @param [near=0.1] Camera frustum near plane. + * @param [far=2000] Camera frustum far plane. + */ + constructor(left?: number, right?: number, top?: number, bottom?: number, near?: number, far?: number); + + type: 'OrthographicCamera'; + + readonly isOrthographicCamera: true; + + /** + * @default 1 + */ + zoom: number; + + /** + * @default null + */ + view: null | { + enabled: boolean; + fullWidth: number; + fullHeight: number; + offsetX: number; + offsetY: number; + width: number; + height: number; + }; + + /** + * Camera frustum left plane. + * @default -1 + */ + left: number; + + /** + * Camera frustum right plane. + * @default 1 + */ + right: number; + + /** + * Camera frustum top plane. + * @default 1 + */ + top: number; + + /** + * Camera frustum bottom plane. + * @default -1 + */ + bottom: number; + + /** + * Camera frustum near plane. + * @default 0.1 + */ + near: number; + + /** + * Camera frustum far plane. + * @default 2000 + */ + far: number; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + setViewOffset(fullWidth: number, fullHeight: number, offsetX: number, offsetY: number, width: number, height: number): void; + clearViewOffset(): void; + toJSON(meta?: any): any; +} diff --git a/backend/libs/three/cameras/OrthographicCamera.js b/backend/libs/three/cameras/OrthographicCamera.js new file mode 100755 index 0000000000000000000000000000000000000000..a43d2500e10451e3b4be1b80ad13ebf017de04c1 --- /dev/null +++ b/backend/libs/three/cameras/OrthographicCamera.js @@ -0,0 +1,116 @@ +import { Camera } from './Camera.js'; + +class OrthographicCamera extends Camera { + constructor(left = -1, right = 1, top = 1, bottom = -1, near = 0.1, far = 2000) { + super(); + + this.type = 'OrthographicCamera'; + + this.zoom = 1; + this.view = null; + + this.left = left; + this.right = right; + this.top = top; + this.bottom = bottom; + + this.near = near; + this.far = far; + + this.updateProjectionMatrix(); + } + + copy(source, recursive) { + super.copy(source, recursive); + + this.left = source.left; + this.right = source.right; + this.top = source.top; + this.bottom = source.bottom; + this.near = source.near; + this.far = source.far; + + this.zoom = source.zoom; + this.view = source.view === null ? null : Object.assign({}, source.view); + + return this; + } + + setViewOffset(fullWidth, fullHeight, x, y, width, height) { + if (this.view === null) { + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1, + }; + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + } + + clearViewOffset() { + if (this.view !== null) { + this.view.enabled = false; + } + + this.updateProjectionMatrix(); + } + + updateProjectionMatrix() { + const dx = (this.right - this.left) / (2 * this.zoom); + const dy = (this.top - this.bottom) / (2 * this.zoom); + const cx = (this.right + this.left) / 2; + const cy = (this.top + this.bottom) / 2; + + let left = cx - dx; + let right = cx + dx; + let top = cy + dy; + let bottom = cy - dy; + + if (this.view !== null && this.view.enabled) { + const scaleW = (this.right - this.left) / this.view.fullWidth / this.zoom; + const scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom; + + left += scaleW * this.view.offsetX; + right = left + scaleW * this.view.width; + top -= scaleH * this.view.offsetY; + bottom = top - scaleH * this.view.height; + } + + this.projectionMatrix.makeOrthographic(left, right, top, bottom, this.near, this.far); + + this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.object.zoom = this.zoom; + data.object.left = this.left; + data.object.right = this.right; + data.object.top = this.top; + data.object.bottom = this.bottom; + data.object.near = this.near; + data.object.far = this.far; + + if (this.view !== null) data.object.view = Object.assign({}, this.view); + + return data; + } +} + +OrthographicCamera.prototype.isOrthographicCamera = true; + +export { OrthographicCamera }; diff --git a/backend/libs/three/cameras/PerspectiveCamera.d.ts b/backend/libs/three/cameras/PerspectiveCamera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4beac900dc6e1025481fb0a6e5a26c8a520c453e --- /dev/null +++ b/backend/libs/three/cameras/PerspectiveCamera.d.ts @@ -0,0 +1,134 @@ +import { Camera } from './Camera'; + +/** + * Camera with perspective projection. + * + * @source https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js + */ +export class PerspectiveCamera extends Camera { + /** + * @param [fov=50] Camera frustum vertical field of view. Default value is 50. + * @param [aspect=1] Camera frustum aspect ratio. Default value is 1. + * @param [near=0.1] Camera frustum near plane. Default value is 0.1. + * @param [far=2000] Camera frustum far plane. Default value is 2000. + */ + constructor(fov?: number, aspect?: number, near?: number, far?: number); + + type: 'PerspectiveCamera'; + + readonly isPerspectiveCamera: true; + + /** + * @default 1 + */ + zoom: number; + + /** + * Camera frustum vertical field of view, from bottom to top of view, in degrees. + * @default 50 + */ + fov: number; + + /** + * Camera frustum aspect ratio, window width divided by window height. + * @default 1 + */ + aspect: number; + + /** + * Camera frustum near plane. + * @default 0.1 + */ + near: number; + + /** + * Camera frustum far plane. + * @default 2000 + */ + far: number; + + /** + * @default 10 + */ + focus: number; + + /** + * @default null + */ + view: null | { + enabled: boolean; + fullWidth: number; + fullHeight: number; + offsetX: number; + offsetY: number; + width: number; + height: number; + }; + + /** + * @default 35 + */ + filmGauge: number; + + /** + * @default 0 + */ + filmOffset: number; + + setFocalLength(focalLength: number): void; + getFocalLength(): number; + getEffectiveFOV(): number; + getFilmWidth(): number; + getFilmHeight(): number; + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this: + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this: + * + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * // A + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * // B + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * // C + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * // D + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * // E + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * // F + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid. + * + * @param fullWidth full width of multiview setup + * @param fullHeight full height of multiview setup + * @param x horizontal offset of subcamera + * @param y vertical offset of subcamera + * @param width width of subcamera + * @param height height of subcamera + */ + setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; + clearViewOffset(): void; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + toJSON(meta?: any): any; + + /** + * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. + */ + setLens(focalLength: number, frameHeight?: number): void; +} diff --git a/backend/libs/three/cameras/PerspectiveCamera.js b/backend/libs/three/cameras/PerspectiveCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..6a1456082cb2ff90e18c3dd79d464cd95a9a499a --- /dev/null +++ b/backend/libs/three/cameras/PerspectiveCamera.js @@ -0,0 +1,202 @@ +import { Camera } from './Camera.js'; +import * as MathUtils from '../math/MathUtils.js'; + +class PerspectiveCamera extends Camera { + constructor(fov = 50, aspect = 1, near = 0.1, far = 2000) { + super(); + + this.type = 'PerspectiveCamera'; + + this.fov = fov; + this.zoom = 1; + + this.near = near; + this.far = far; + this.focus = 10; + + this.aspect = aspect; + this.view = null; + + this.filmGauge = 35; // width of the film (default in millimeters) + this.filmOffset = 0; // horizontal film offset (same unit as gauge) + + this.updateProjectionMatrix(); + } + + copy(source, recursive) { + super.copy(source, recursive); + + this.fov = source.fov; + this.zoom = source.zoom; + + this.near = source.near; + this.far = source.far; + this.focus = source.focus; + + this.aspect = source.aspect; + this.view = source.view === null ? null : Object.assign({}, source.view); + + this.filmGauge = source.filmGauge; + this.filmOffset = source.filmOffset; + + return this; + } + + /** + * Sets the FOV by focal length in respect to the current .filmGauge. + * + * The default film gauge is 35, so that the focal length can be specified for + * a 35mm (full frame) camera. + * + * Values for focal length and film gauge must have the same unit. + */ + setFocalLength(focalLength) { + /** see {@link http://www.bobatkins.com/photography/technical/field_of_view.html} */ + const vExtentSlope = (0.5 * this.getFilmHeight()) / focalLength; + + this.fov = MathUtils.RAD2DEG * 2 * Math.atan(vExtentSlope); + this.updateProjectionMatrix(); + } + + /** + * Calculates the focal length from the current .fov and .filmGauge. + */ + getFocalLength() { + const vExtentSlope = Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov); + + return (0.5 * this.getFilmHeight()) / vExtentSlope; + } + + getEffectiveFOV() { + return MathUtils.RAD2DEG * 2 * Math.atan(Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom); + } + + getFilmWidth() { + // film not completely covered in portrait format (aspect < 1) + return this.filmGauge * Math.min(this.aspect, 1); + } + + getFilmHeight() { + // film not completely covered in landscape format (aspect > 1) + return this.filmGauge / Math.max(this.aspect, 1); + } + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or + * multi-monitor/multi-machine setups. + * + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and + * the monitors are in grid like this + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this + * + * const w = 1920; + * const h = 1080; + * const fullWidth = w * 3; + * const fullHeight = h * 2; + * + * --A-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * --B-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * --C-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * --D-- + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * --E-- + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * --F-- + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); + * + * Note there is no reason monitors have to be the same size or in a grid. + */ + setViewOffset(fullWidth, fullHeight, x, y, width, height) { + this.aspect = fullWidth / fullHeight; + + if (this.view === null) { + this.view = { + enabled: true, + fullWidth: 1, + fullHeight: 1, + offsetX: 0, + offsetY: 0, + width: 1, + height: 1, + }; + } + + this.view.enabled = true; + this.view.fullWidth = fullWidth; + this.view.fullHeight = fullHeight; + this.view.offsetX = x; + this.view.offsetY = y; + this.view.width = width; + this.view.height = height; + + this.updateProjectionMatrix(); + } + + clearViewOffset() { + if (this.view !== null) { + this.view.enabled = false; + } + + this.updateProjectionMatrix(); + } + + updateProjectionMatrix() { + const near = this.near; + let top = (near * Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov)) / this.zoom; + let height = 2 * top; + let width = this.aspect * height; + let left = -0.5 * width; + const view = this.view; + + if (this.view !== null && this.view.enabled) { + const fullWidth = view.fullWidth, + fullHeight = view.fullHeight; + + left += (view.offsetX * width) / fullWidth; + top -= (view.offsetY * height) / fullHeight; + width *= view.width / fullWidth; + height *= view.height / fullHeight; + } + + const skew = this.filmOffset; + if (skew !== 0) left += (near * skew) / this.getFilmWidth(); + + this.projectionMatrix.makePerspective(left, left + width, top, top - height, near, this.far); + + this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.object.fov = this.fov; + data.object.zoom = this.zoom; + + data.object.near = this.near; + data.object.far = this.far; + data.object.focus = this.focus; + + data.object.aspect = this.aspect; + + if (this.view !== null) data.object.view = Object.assign({}, this.view); + + data.object.filmGauge = this.filmGauge; + data.object.filmOffset = this.filmOffset; + + return data; + } +} + +PerspectiveCamera.prototype.isPerspectiveCamera = true; + +export { PerspectiveCamera }; diff --git a/backend/libs/three/cameras/StereoCamera.d.ts b/backend/libs/three/cameras/StereoCamera.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c71bdc8eb0d638086dbbd41fb5cedf00b9ba247a --- /dev/null +++ b/backend/libs/three/cameras/StereoCamera.d.ts @@ -0,0 +1,23 @@ +import { PerspectiveCamera } from './PerspectiveCamera'; +import { Camera } from './Camera'; + +export class StereoCamera extends Camera { + constructor(); + + type: 'StereoCamera'; + + /** + * @default 1 + */ + aspect: number; + + /** + * @default 0.064 + */ + eyeSep: number; + + cameraL: PerspectiveCamera; + cameraR: PerspectiveCamera; + + update(camera: PerspectiveCamera): void; +} diff --git a/backend/libs/three/cameras/StereoCamera.js b/backend/libs/three/cameras/StereoCamera.js new file mode 100644 index 0000000000000000000000000000000000000000..b7848943bb940a25c12331285063195dba386c4a --- /dev/null +++ b/backend/libs/three/cameras/StereoCamera.js @@ -0,0 +1,97 @@ +import { Matrix4 } from '../math/Matrix4.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { PerspectiveCamera } from './PerspectiveCamera.js'; + +const _eyeRight = /*@__PURE__*/ new Matrix4(); +const _eyeLeft = /*@__PURE__*/ new Matrix4(); +const _projectionMatrix = /*@__PURE__*/ new Matrix4(); + +class StereoCamera { + constructor() { + this.type = 'StereoCamera'; + + this.aspect = 1; + + this.eyeSep = 0.064; + + this.cameraL = new PerspectiveCamera(); + this.cameraL.layers.enable(1); + this.cameraL.matrixAutoUpdate = false; + + this.cameraR = new PerspectiveCamera(); + this.cameraR.layers.enable(2); + this.cameraR.matrixAutoUpdate = false; + + this._cache = { + focus: null, + fov: null, + aspect: null, + near: null, + far: null, + zoom: null, + eyeSep: null, + }; + } + + update(camera) { + const cache = this._cache; + + const needsUpdate = + cache.focus !== camera.focus || + cache.fov !== camera.fov || + cache.aspect !== camera.aspect * this.aspect || + cache.near !== camera.near || + cache.far !== camera.far || + cache.zoom !== camera.zoom || + cache.eyeSep !== this.eyeSep; + + if (needsUpdate) { + cache.focus = camera.focus; + cache.fov = camera.fov; + cache.aspect = camera.aspect * this.aspect; + cache.near = camera.near; + cache.far = camera.far; + cache.zoom = camera.zoom; + cache.eyeSep = this.eyeSep; + + // Off-axis stereoscopic effect based on + // http://paulbourke.net/stereographics/stereorender/ + + _projectionMatrix.copy(camera.projectionMatrix); + const eyeSepHalf = cache.eyeSep / 2; + const eyeSepOnProjection = (eyeSepHalf * cache.near) / cache.focus; + const ymax = (cache.near * Math.tan(MathUtils.DEG2RAD * cache.fov * 0.5)) / cache.zoom; + let xmin, xmax; + + // translate xOffset + + _eyeLeft.elements[12] = -eyeSepHalf; + _eyeRight.elements[12] = eyeSepHalf; + + // for left eye + + xmin = -ymax * cache.aspect + eyeSepOnProjection; + xmax = ymax * cache.aspect + eyeSepOnProjection; + + _projectionMatrix.elements[0] = (2 * cache.near) / (xmax - xmin); + _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin); + + this.cameraL.projectionMatrix.copy(_projectionMatrix); + + // for right eye + + xmin = -ymax * cache.aspect - eyeSepOnProjection; + xmax = ymax * cache.aspect - eyeSepOnProjection; + + _projectionMatrix.elements[0] = (2 * cache.near) / (xmax - xmin); + _projectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin); + + this.cameraR.projectionMatrix.copy(_projectionMatrix); + } + + this.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft); + this.cameraR.matrixWorld.copy(camera.matrixWorld).multiply(_eyeRight); + } +} + +export { StereoCamera }; diff --git a/backend/libs/three/constants.d.ts b/backend/libs/three/constants.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e10a47ea7a842f1ae2a88a99d233b88da31790c3 --- /dev/null +++ b/backend/libs/three/constants.d.ts @@ -0,0 +1,378 @@ +export const REVISION: string; + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button +export enum MOUSE { + LEFT = 0, + MIDDLE = 1, + RIGHT = 2, + ROTATE = 0, + DOLLY = 1, + PAN = 2, +} + +export enum TOUCH { + ROTATE, + PAN, + DOLLY_PAN, + DOLLY_ROTATE, +} + +// GL STATE CONSTANTS +export enum CullFace {} +export const CullFaceNone: CullFace; +export const CullFaceBack: CullFace; +export const CullFaceFront: CullFace; +export const CullFaceFrontBack: CullFace; + +// Shadowing Type +export enum ShadowMapType {} +export const BasicShadowMap: ShadowMapType; +export const PCFShadowMap: ShadowMapType; +export const PCFSoftShadowMap: ShadowMapType; +export const VSMShadowMap: ShadowMapType; + +// MATERIAL CONSTANTS + +// side +export enum Side {} +export const FrontSide: Side; +export const BackSide: Side; +export const DoubleSide: Side; + +// shading +export enum Shading {} +export const FlatShading: Shading; +export const SmoothShading: Shading; + +// blending modes +export enum Blending {} +export const NoBlending: Blending; +export const NormalBlending: Blending; +export const AdditiveBlending: Blending; +export const SubtractiveBlending: Blending; +export const MultiplyBlending: Blending; +export const CustomBlending: Blending; + +// custom blending equations +// (numbers start from 100 not to clash with other +// mappings to OpenGL constants defined in Texture.js) +export enum BlendingEquation {} +export const AddEquation: BlendingEquation; +export const SubtractEquation: BlendingEquation; +export const ReverseSubtractEquation: BlendingEquation; +export const MinEquation: BlendingEquation; +export const MaxEquation: BlendingEquation; + +// custom blending destination factors +export enum BlendingDstFactor {} +export const ZeroFactor: BlendingDstFactor; +export const OneFactor: BlendingDstFactor; +export const SrcColorFactor: BlendingDstFactor; +export const OneMinusSrcColorFactor: BlendingDstFactor; +export const SrcAlphaFactor: BlendingDstFactor; +export const OneMinusSrcAlphaFactor: BlendingDstFactor; +export const DstAlphaFactor: BlendingDstFactor; +export const OneMinusDstAlphaFactor: BlendingDstFactor; +export const DstColorFactor: BlendingDstFactor; +export const OneMinusDstColorFactor: BlendingDstFactor; + +// custom blending src factors +export enum BlendingSrcFactor {} +export const SrcAlphaSaturateFactor: BlendingSrcFactor; + +// depth modes +export enum DepthModes {} +export const NeverDepth: DepthModes; +export const AlwaysDepth: DepthModes; +export const LessDepth: DepthModes; +export const LessEqualDepth: DepthModes; +export const EqualDepth: DepthModes; +export const GreaterEqualDepth: DepthModes; +export const GreaterDepth: DepthModes; +export const NotEqualDepth: DepthModes; + +// TEXTURE CONSTANTS +// Operations +export enum Combine {} +export const MultiplyOperation: Combine; +export const MixOperation: Combine; +export const AddOperation: Combine; + +// Tone Mapping modes +export enum ToneMapping {} +export const NoToneMapping: ToneMapping; +export const LinearToneMapping: ToneMapping; +export const ReinhardToneMapping: ToneMapping; +export const CineonToneMapping: ToneMapping; +export const ACESFilmicToneMapping: ToneMapping; +export const CustomToneMapping: ToneMapping; + +// Mapping modes +export enum Mapping {} +export const UVMapping: Mapping; +export const CubeReflectionMapping: Mapping; +export const CubeRefractionMapping: Mapping; +export const EquirectangularReflectionMapping: Mapping; +export const EquirectangularRefractionMapping: Mapping; +export const CubeUVReflectionMapping: Mapping; + +// Wrapping modes +export enum Wrapping {} +export const RepeatWrapping: Wrapping; +export const ClampToEdgeWrapping: Wrapping; +export const MirroredRepeatWrapping: Wrapping; + +// Filters +export enum TextureFilter {} +export const NearestFilter: TextureFilter; +export const NearestMipmapNearestFilter: TextureFilter; +export const NearestMipMapNearestFilter: TextureFilter; +export const NearestMipmapLinearFilter: TextureFilter; +export const NearestMipMapLinearFilter: TextureFilter; +export const LinearFilter: TextureFilter; +export const LinearMipmapNearestFilter: TextureFilter; +export const LinearMipMapNearestFilter: TextureFilter; +export const LinearMipmapLinearFilter: TextureFilter; +export const LinearMipMapLinearFilter: TextureFilter; + +// Data types +export enum TextureDataType {} +export const UnsignedByteType: TextureDataType; +export const ByteType: TextureDataType; +export const ShortType: TextureDataType; +export const UnsignedShortType: TextureDataType; +export const IntType: TextureDataType; +export const UnsignedIntType: TextureDataType; +export const FloatType: TextureDataType; +export const HalfFloatType: TextureDataType; +export const UnsignedShort4444Type: TextureDataType; +export const UnsignedShort5551Type: TextureDataType; +export const UnsignedInt248Type: TextureDataType; + +// Pixel formats +export enum PixelFormat {} +export const AlphaFormat: PixelFormat; +export const RGBFormat: PixelFormat; +export const RGBAFormat: PixelFormat; +export const LuminanceFormat: PixelFormat; +export const LuminanceAlphaFormat: PixelFormat; +export const DepthFormat: PixelFormat; +export const DepthStencilFormat: PixelFormat; +export const RedFormat: PixelFormat; +export const RedIntegerFormat: PixelFormat; +export const RGFormat: PixelFormat; +export const RGIntegerFormat: PixelFormat; +export const RGBAIntegerFormat: PixelFormat; +export const _SRGBFormat: PixelFormat; // fallback for WebGL 1 +export const _SRGBAFormat: PixelFormat; // fallback for WebGL 1 + +// Internal Pixel Formats +export type PixelFormatGPU = + | 'ALPHA' + | 'RGB' + | 'RGBA' + | 'LUMINANCE' + | 'LUMINANCE_ALPHA' + | 'RED_INTEGER' + | 'R8' + | 'R8_SNORM' + | 'R8I' + | 'R8UI' + | 'R16I' + | 'R16UI' + | 'R16F' + | 'R32I' + | 'R32UI' + | 'R32F' + | 'RG8' + | 'RG8_SNORM' + | 'RG8I' + | 'RG8UI' + | 'RG16I' + | 'RG16UI' + | 'RG16F' + | 'RG32I' + | 'RG32UI' + | 'RG32F' + | 'RGB565' + | 'RGB8' + | 'RGB8_SNORM' + | 'RGB8I' + | 'RGB8UI' + | 'RGB16I' + | 'RGB16UI' + | 'RGB16F' + | 'RGB32I' + | 'RGB32UI' + | 'RGB32F' + | 'RGB9_E5' + | 'SRGB8' + | 'R11F_G11F_B10F' + | 'RGBA4' + | 'RGBA8' + | 'RGBA8_SNORM' + | 'RGBA8I' + | 'RGBA8UI' + | 'RGBA16I' + | 'RGBA16UI' + | 'RGBA16F' + | 'RGBA32I' + | 'RGBA32UI' + | 'RGBA32F' + | 'RGB5_A1' + | 'RGB10_A2' + | 'RGB10_A2UI' + | 'SRGB8_ALPHA8' + | 'SRGB8' + | 'DEPTH_COMPONENT16' + | 'DEPTH_COMPONENT24' + | 'DEPTH_COMPONENT32F' + | 'DEPTH24_STENCIL8' + | 'DEPTH32F_STENCIL8'; + +// Compressed texture formats +// DDS / ST3C Compressed texture formats +export enum CompressedPixelFormat {} +export const RGB_S3TC_DXT1_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT1_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT3_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT5_Format: CompressedPixelFormat; + +// PVRTC compressed './texture formats +export const RGB_PVRTC_4BPPV1_Format: CompressedPixelFormat; +export const RGB_PVRTC_2BPPV1_Format: CompressedPixelFormat; +export const RGBA_PVRTC_4BPPV1_Format: CompressedPixelFormat; +export const RGBA_PVRTC_2BPPV1_Format: CompressedPixelFormat; + +// ETC compressed texture formats +export const RGB_ETC1_Format: CompressedPixelFormat; +export const RGB_ETC2_Format: CompressedPixelFormat; +export const RGBA_ETC2_EAC_Format: CompressedPixelFormat; + +// ASTC compressed texture formats +export const RGBA_ASTC_4x4_Format: CompressedPixelFormat; +export const RGBA_ASTC_5x4_Format: CompressedPixelFormat; +export const RGBA_ASTC_5x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_6x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_6x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x8_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x8_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x10_Format: CompressedPixelFormat; +export const RGBA_ASTC_12x10_Format: CompressedPixelFormat; +export const RGBA_ASTC_12x12_Format: CompressedPixelFormat; + +// BPTC compressed texture formats +export const RGBA_BPTC_Format: CompressedPixelFormat; + +// Loop styles for AnimationAction +export enum AnimationActionLoopStyles {} +export const LoopOnce: AnimationActionLoopStyles; +export const LoopRepeat: AnimationActionLoopStyles; +export const LoopPingPong: AnimationActionLoopStyles; + +// Interpolation +export enum InterpolationModes {} +export const InterpolateDiscrete: InterpolationModes; +export const InterpolateLinear: InterpolationModes; +export const InterpolateSmooth: InterpolationModes; + +// Interpolant ending modes +export enum InterpolationEndingModes {} +export const ZeroCurvatureEnding: InterpolationEndingModes; +export const ZeroSlopeEnding: InterpolationEndingModes; +export const WrapAroundEnding: InterpolationEndingModes; + +// Animation blending modes +export enum AnimationBlendMode {} +export const NormalAnimationBlendMode: AnimationBlendMode; +export const AdditiveAnimationBlendMode: AnimationBlendMode; + +// Triangle Draw modes +export enum TrianglesDrawModes {} +export const TrianglesDrawMode: TrianglesDrawModes; +export const TriangleStripDrawMode: TrianglesDrawModes; +export const TriangleFanDrawMode: TrianglesDrawModes; + +// Texture Encodings +export enum TextureEncoding {} +export const LinearEncoding: TextureEncoding; +export const sRGBEncoding: TextureEncoding; +export const LogLuvEncoding: TextureEncoding; + +// Depth packing strategies +export enum DepthPackingStrategies {} +export const BasicDepthPacking: DepthPackingStrategies; +export const RGBADepthPacking: DepthPackingStrategies; + +// Normal Map types +export enum NormalMapTypes {} +export const TangentSpaceNormalMap: NormalMapTypes; +export const ObjectSpaceNormalMap: NormalMapTypes; + +export type ColorSpace = NoColorSpace | SRGBColorSpace | LinearSRGBColorSpace; +export type NoColorSpace = ''; +export type SRGBColorSpace = 'srgb'; +export type LinearSRGBColorSpace = 'srgb-linear'; + +// Stencil Op types +export enum StencilOp {} +export const ZeroStencilOp: StencilOp; +export const KeepStencilOp: StencilOp; +export const ReplaceStencilOp: StencilOp; +export const IncrementStencilOp: StencilOp; +export const DecrementStencilOp: StencilOp; +export const IncrementWrapStencilOp: StencilOp; +export const DecrementWrapStencilOp: StencilOp; +export const InvertStencilOp: StencilOp; + +// Stencil Func types +export enum StencilFunc {} +export const NeverStencilFunc: StencilFunc; +export const LessStencilFunc: StencilFunc; +export const EqualStencilFunc: StencilFunc; +export const LessEqualStencilFunc: StencilFunc; +export const GreaterStencilFunc: StencilFunc; +export const NotEqualStencilFunc: StencilFunc; +export const GreaterEqualStencilFunc: StencilFunc; +export const AlwaysStencilFunc: StencilFunc; + +// usage types +export enum Usage {} +export const StaticDrawUsage: Usage; +export const DynamicDrawUsage: Usage; +export const StreamDrawUsage: Usage; +export const StaticReadUsage: Usage; +export const DynamicReadUsage: Usage; +export const StreamReadUsage: Usage; +export const StaticCopyUsage: Usage; +export const DynamicCopyUsage: Usage; +export const StreamCopyUsage: Usage; + +export enum GLSLVersion {} +export const GLSL1: GLSLVersion; +export const GLSL3: GLSLVersion; + +export type BuiltinShaderAttributeName = + | 'position' + | 'normal' + | 'uv' + | 'color' + | 'skinIndex' + | 'skinWeight' + | 'instanceMatrix' + | 'morphTarget0' + | 'morphTarget1' + | 'morphTarget2' + | 'morphTarget3' + | 'morphTarget4' + | 'morphTarget5' + | 'morphTarget6' + | 'morphTarget7' + | 'morphNormal0' + | 'morphNormal1' + | 'morphNormal2' + | 'morphNormal3'; diff --git a/backend/libs/three/constants.js b/backend/libs/three/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..384605c988759f3886e15e4244309bacb17b1e64 --- /dev/null +++ b/backend/libs/three/constants.js @@ -0,0 +1,180 @@ +export const REVISION = '137dev'; +export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }; +export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }; +export const CullFaceNone = 0; +export const CullFaceBack = 1; +export const CullFaceFront = 2; +export const CullFaceFrontBack = 3; +export const BasicShadowMap = 0; +export const PCFShadowMap = 1; +export const PCFSoftShadowMap = 2; +export const VSMShadowMap = 3; +export const FrontSide = 0; +export const BackSide = 1; +export const DoubleSide = 2; +export const FlatShading = 1; +export const SmoothShading = 2; +export const NoBlending = 0; +export const NormalBlending = 1; +export const AdditiveBlending = 2; +export const SubtractiveBlending = 3; +export const MultiplyBlending = 4; +export const CustomBlending = 5; +export const AddEquation = 100; +export const SubtractEquation = 101; +export const ReverseSubtractEquation = 102; +export const MinEquation = 103; +export const MaxEquation = 104; +export const ZeroFactor = 200; +export const OneFactor = 201; +export const SrcColorFactor = 202; +export const OneMinusSrcColorFactor = 203; +export const SrcAlphaFactor = 204; +export const OneMinusSrcAlphaFactor = 205; +export const DstAlphaFactor = 206; +export const OneMinusDstAlphaFactor = 207; +export const DstColorFactor = 208; +export const OneMinusDstColorFactor = 209; +export const SrcAlphaSaturateFactor = 210; +export const NeverDepth = 0; +export const AlwaysDepth = 1; +export const LessDepth = 2; +export const LessEqualDepth = 3; +export const EqualDepth = 4; +export const GreaterEqualDepth = 5; +export const GreaterDepth = 6; +export const NotEqualDepth = 7; +export const MultiplyOperation = 0; +export const MixOperation = 1; +export const AddOperation = 2; +export const NoToneMapping = 0; +export const LinearToneMapping = 1; +export const ReinhardToneMapping = 2; +export const CineonToneMapping = 3; +export const ACESFilmicToneMapping = 4; +export const CustomToneMapping = 5; + +export const UVMapping = 300; +export const CubeReflectionMapping = 301; +export const CubeRefractionMapping = 302; +export const EquirectangularReflectionMapping = 303; +export const EquirectangularRefractionMapping = 304; +export const CubeUVReflectionMapping = 306; +export const CubeUVRefractionMapping = 307; +export const RepeatWrapping = 1000; +export const ClampToEdgeWrapping = 1001; +export const MirroredRepeatWrapping = 1002; +export const NearestFilter = 1003; +export const NearestMipmapNearestFilter = 1004; +export const NearestMipMapNearestFilter = 1004; +export const NearestMipmapLinearFilter = 1005; +export const NearestMipMapLinearFilter = 1005; +export const LinearFilter = 1006; +export const LinearMipmapNearestFilter = 1007; +export const LinearMipMapNearestFilter = 1007; +export const LinearMipmapLinearFilter = 1008; +export const LinearMipMapLinearFilter = 1008; +export const UnsignedByteType = 1009; +export const ByteType = 1010; +export const ShortType = 1011; +export const UnsignedShortType = 1012; +export const IntType = 1013; +export const UnsignedIntType = 1014; +export const FloatType = 1015; +export const HalfFloatType = 1016; +export const UnsignedShort4444Type = 1017; +export const UnsignedShort5551Type = 1018; +export const UnsignedShort565Type = 1019; +export const UnsignedInt248Type = 1020; +export const AlphaFormat = 1021; +export const RGBAFormat = 1023; +export const LuminanceFormat = 1024; +export const LuminanceAlphaFormat = 1025; +export const DepthFormat = 1026; +export const DepthStencilFormat = 1027; +export const RedFormat = 1028; +export const RedIntegerFormat = 1029; +export const RGFormat = 1030; +export const RGIntegerFormat = 1031; +export const RGBIntegerFormat = 1032; +export const RGBAIntegerFormat = 1033; + +export const RGB_S3TC_DXT1_Format = 33776; +export const RGBA_S3TC_DXT1_Format = 33777; +export const RGBA_S3TC_DXT3_Format = 33778; +export const RGBA_S3TC_DXT5_Format = 33779; +export const RGB_PVRTC_4BPPV1_Format = 35840; +export const RGB_PVRTC_2BPPV1_Format = 35841; +export const RGBA_PVRTC_4BPPV1_Format = 35842; +export const RGBA_PVRTC_2BPPV1_Format = 35843; +export const RGB_ETC1_Format = 36196; +export const RGB_ETC2_Format = 37492; +export const RGBA_ETC2_EAC_Format = 37496; +export const RGBA_ASTC_4x4_Format = 37808; +export const RGBA_ASTC_5x4_Format = 37809; +export const RGBA_ASTC_5x5_Format = 37810; +export const RGBA_ASTC_6x5_Format = 37811; +export const RGBA_ASTC_6x6_Format = 37812; +export const RGBA_ASTC_8x5_Format = 37813; +export const RGBA_ASTC_8x6_Format = 37814; +export const RGBA_ASTC_8x8_Format = 37815; +export const RGBA_ASTC_10x5_Format = 37816; +export const RGBA_ASTC_10x6_Format = 37817; +export const RGBA_ASTC_10x8_Format = 37818; +export const RGBA_ASTC_10x10_Format = 37819; +export const RGBA_ASTC_12x10_Format = 37820; +export const RGBA_ASTC_12x12_Format = 37821; +export const RGBA_BPTC_Format = 36492; +export const LoopOnce = 2200; +export const LoopRepeat = 2201; +export const LoopPingPong = 2202; +export const InterpolateDiscrete = 2300; +export const InterpolateLinear = 2301; +export const InterpolateSmooth = 2302; +export const ZeroCurvatureEnding = 2400; +export const ZeroSlopeEnding = 2401; +export const WrapAroundEnding = 2402; +export const NormalAnimationBlendMode = 2500; +export const AdditiveAnimationBlendMode = 2501; +export const TrianglesDrawMode = 0; +export const TriangleStripDrawMode = 1; +export const TriangleFanDrawMode = 2; +export const LinearEncoding = 3000; +export const sRGBEncoding = 3001; +export const BasicDepthPacking = 3200; +export const RGBADepthPacking = 3201; +export const TangentSpaceNormalMap = 0; +export const ObjectSpaceNormalMap = 1; + +export const ZeroStencilOp = 0; +export const KeepStencilOp = 7680; +export const ReplaceStencilOp = 7681; +export const IncrementStencilOp = 7682; +export const DecrementStencilOp = 7683; +export const IncrementWrapStencilOp = 34055; +export const DecrementWrapStencilOp = 34056; +export const InvertStencilOp = 5386; + +export const NeverStencilFunc = 512; +export const LessStencilFunc = 513; +export const EqualStencilFunc = 514; +export const LessEqualStencilFunc = 515; +export const GreaterStencilFunc = 516; +export const NotEqualStencilFunc = 517; +export const GreaterEqualStencilFunc = 518; +export const AlwaysStencilFunc = 519; + +export const StaticDrawUsage = 35044; +export const DynamicDrawUsage = 35048; +export const StreamDrawUsage = 35040; +export const StaticReadUsage = 35045; +export const DynamicReadUsage = 35049; +export const StreamReadUsage = 35041; +export const StaticCopyUsage = 35046; +export const DynamicCopyUsage = 35050; +export const StreamCopyUsage = 35042; + +export const GLSL1 = '100'; +export const GLSL3 = '300 es'; + +export const _SRGBAFormat = 1035; // fallback for WebGL 1 diff --git a/backend/libs/three/core/BufferAttribute.d.ts b/backend/libs/three/core/BufferAttribute.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d5d9af9e6e9c29716df69ca39d34e0d3cb68d904 --- /dev/null +++ b/backend/libs/three/core/BufferAttribute.d.ts @@ -0,0 +1,183 @@ +import { Usage } from '../constants'; +import { Matrix3 } from './../math/Matrix3'; +import { Matrix4 } from './../math/Matrix4'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js|src/core/BufferAttribute.js} + */ +export class BufferAttribute { + constructor(array: ArrayLike, itemSize: number, normalized?: boolean); // array parameter should be TypedArray. + + /** + * @default '' + */ + name: string; + array: ArrayLike; + itemSize: number; + + /** + * @default THREE.StaticDrawUsage + */ + usage: Usage; + + /** + * @default { offset: number; count: number } + */ + updateRange: { offset: number; count: number }; + + /** + * @default 0 + */ + version: number; + + /** + * @default false + */ + normalized: boolean; + + /** + * @default 0 + */ + count: number; + + set needsUpdate(value: boolean); + + readonly isBufferAttribute: true; + + onUploadCallback: () => void; + onUpload(callback: () => void): this; + setUsage(usage: Usage): this; + clone(): this; + copy(source: BufferAttribute): this; + copyAt(index1: number, attribute: BufferAttribute, index2: number): this; + copyArray(array: ArrayLike): this; + copyColorsArray(colors: Array<{ r: number; g: number; b: number }>): this; + copyVector2sArray(vectors: Array<{ x: number; y: number }>): this; + copyVector3sArray(vectors: Array<{ x: number; y: number; z: number }>): this; + copyVector4sArray(vectors: Array<{ x: number; y: number; z: number; w: number }>): this; + applyMatrix3(m: Matrix3): this; + applyMatrix4(m: Matrix4): this; + applyNormalMatrix(m: Matrix3): this; + transformDirection(m: Matrix4): this; + set(value: ArrayLike | ArrayBufferView, offset?: number): this; + getX(index: number): number; + setX(index: number, x: number): this; + getY(index: number): number; + setY(index: number, y: number): this; + getZ(index: number): number; + setZ(index: number, z: number): this; + getW(index: number): number; + setW(index: number, z: number): this; + setXY(index: number, x: number, y: number): this; + setXYZ(index: number, x: number, y: number, z: number): this; + setXYZW(index: number, x: number, y: number, z: number, w: number): this; + toJSON(): { + itemSize: number; + type: string; + array: number[]; + normalized: boolean; + }; +} + +/** + * @deprecated THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead. + */ +export class Int8Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead. + */ +export class Uint8Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead. + */ +export class Uint8ClampedAttribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead. + */ +export class Int16Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead. + */ +export class Uint16Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead. + */ +export class Int32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead. + */ +export class Uint32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead. + */ +export class Float32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead. + */ +export class Float64Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +export class Int8BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Uint8BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Uint8ClampedBufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Int16BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Uint16BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Int32BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Uint32BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Float16BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Float32BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} + +export class Float64BufferAttribute extends BufferAttribute { + constructor(array: Iterable | ArrayLike | ArrayBuffer | number, itemSize: number, normalized?: boolean); +} diff --git a/backend/libs/three/core/BufferAttribute.js b/backend/libs/three/core/BufferAttribute.js new file mode 100644 index 0000000000000000000000000000000000000000..d9f994e1c16523996ec2852a11a8c90115b92189 --- /dev/null +++ b/backend/libs/three/core/BufferAttribute.js @@ -0,0 +1,394 @@ +import { Vector4 } from '../math/Vector4.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Color } from '../math/Color.js'; +import { StaticDrawUsage } from '../constants.js'; + +const _vector = /*@__PURE__*/ new Vector3(); +const _vector2 = /*@__PURE__*/ new Vector2(); + +class BufferAttribute { + constructor(array, itemSize, normalized) { + if (Array.isArray(array)) { + throw new TypeError('THREE.BufferAttribute: array should be a Typed Array.'); + } + + this.name = ''; + + this.array = array; + this.itemSize = itemSize; + this.count = array !== undefined ? array.length / itemSize : 0; + this.normalized = normalized === true; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: -1 }; + + this.version = 0; + } + + onUploadCallback() {} + + set needsUpdate(value) { + if (value === true) this.version++; + } + + setUsage(value) { + this.usage = value; + + return this; + } + + copy(source) { + this.name = source.name; + this.array = new source.array.constructor(source.array); + this.itemSize = source.itemSize; + this.count = source.count; + this.normalized = source.normalized; + + this.usage = source.usage; + + return this; + } + + copyAt(index1, attribute, index2) { + index1 *= this.itemSize; + index2 *= attribute.itemSize; + + for (let i = 0, l = this.itemSize; i < l; i++) { + this.array[index1 + i] = attribute.array[index2 + i]; + } + + return this; + } + + copyArray(array) { + this.array.set(array); + + return this; + } + + copyColorsArray(colors) { + const array = this.array; + let offset = 0; + + for (let i = 0, l = colors.length; i < l; i++) { + let color = colors[i]; + + if (color === undefined) { + console.warn('THREE.BufferAttribute.copyColorsArray(): color is undefined', i); + color = new Color(); + } + + array[offset++] = color.r; + array[offset++] = color.g; + array[offset++] = color.b; + } + + return this; + } + + copyVector2sArray(vectors) { + const array = this.array; + let offset = 0; + + for (let i = 0, l = vectors.length; i < l; i++) { + let vector = vectors[i]; + + if (vector === undefined) { + console.warn('THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i); + vector = new Vector2(); + } + + array[offset++] = vector.x; + array[offset++] = vector.y; + } + + return this; + } + + copyVector3sArray(vectors) { + const array = this.array; + let offset = 0; + + for (let i = 0, l = vectors.length; i < l; i++) { + let vector = vectors[i]; + + if (vector === undefined) { + console.warn('THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i); + vector = new Vector3(); + } + + array[offset++] = vector.x; + array[offset++] = vector.y; + array[offset++] = vector.z; + } + + return this; + } + + copyVector4sArray(vectors) { + const array = this.array; + let offset = 0; + + for (let i = 0, l = vectors.length; i < l; i++) { + let vector = vectors[i]; + + if (vector === undefined) { + console.warn('THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i); + vector = new Vector4(); + } + + array[offset++] = vector.x; + array[offset++] = vector.y; + array[offset++] = vector.z; + array[offset++] = vector.w; + } + + return this; + } + + applyMatrix3(m) { + if (this.itemSize === 2) { + for (let i = 0, l = this.count; i < l; i++) { + _vector2.fromBufferAttribute(this, i); + _vector2.applyMatrix3(m); + + this.setXY(i, _vector2.x, _vector2.y); + } + } else if (this.itemSize === 3) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.fromBufferAttribute(this, i); + _vector.applyMatrix3(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + } + + return this; + } + + applyMatrix4(m) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.applyMatrix4(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + applyNormalMatrix(m) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.applyNormalMatrix(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + transformDirection(m) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.transformDirection(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + set(value, offset = 0) { + this.array.set(value, offset); + + return this; + } + + getX(index) { + return this.array[index * this.itemSize]; + } + + setX(index, x) { + this.array[index * this.itemSize] = x; + + return this; + } + + getY(index) { + return this.array[index * this.itemSize + 1]; + } + + setY(index, y) { + this.array[index * this.itemSize + 1] = y; + + return this; + } + + getZ(index) { + return this.array[index * this.itemSize + 2]; + } + + setZ(index, z) { + this.array[index * this.itemSize + 2] = z; + + return this; + } + + getW(index) { + return this.array[index * this.itemSize + 3]; + } + + setW(index, w) { + this.array[index * this.itemSize + 3] = w; + + return this; + } + + setXY(index, x, y) { + index *= this.itemSize; + + this.array[index + 0] = x; + this.array[index + 1] = y; + + return this; + } + + setXYZ(index, x, y, z) { + index *= this.itemSize; + + this.array[index + 0] = x; + this.array[index + 1] = y; + this.array[index + 2] = z; + + return this; + } + + setXYZW(index, x, y, z, w) { + index *= this.itemSize; + + this.array[index + 0] = x; + this.array[index + 1] = y; + this.array[index + 2] = z; + this.array[index + 3] = w; + + return this; + } + + onUpload(callback) { + this.onUploadCallback = callback; + + return this; + } + + clone() { + return new this.constructor(this.array, this.itemSize).copy(this); + } + + toJSON() { + const data = { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: Array.prototype.slice.call(this.array), + normalized: this.normalized, + }; + + if (this.name !== '') data.name = this.name; + if (this.usage !== StaticDrawUsage) data.usage = this.usage; + if (this.updateRange.offset !== 0 || this.updateRange.count !== -1) data.updateRange = this.updateRange; + + return data; + } +} + +BufferAttribute.prototype.isBufferAttribute = true; + +// + +class Int8BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Int8Array(array), itemSize, normalized); + } +} + +class Uint8BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Uint8Array(array), itemSize, normalized); + } +} + +class Uint8ClampedBufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Uint8ClampedArray(array), itemSize, normalized); + } +} + +class Int16BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Int16Array(array), itemSize, normalized); + } +} + +class Uint16BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Uint16Array(array), itemSize, normalized); + } +} + +class Int32BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Int32Array(array), itemSize, normalized); + } +} + +class Uint32BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Uint32Array(array), itemSize, normalized); + } +} + +class Float16BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Uint16Array(array), itemSize, normalized); + } +} + +Float16BufferAttribute.prototype.isFloat16BufferAttribute = true; + +class Float32BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Float32Array(array), itemSize, normalized); + } +} + +class Float64BufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized) { + super(new Float64Array(array), itemSize, normalized); + } +} + +// + +export { + Float64BufferAttribute, + Float32BufferAttribute, + Float16BufferAttribute, + Uint32BufferAttribute, + Int32BufferAttribute, + Uint16BufferAttribute, + Int16BufferAttribute, + Uint8ClampedBufferAttribute, + Uint8BufferAttribute, + Int8BufferAttribute, + BufferAttribute, +}; diff --git a/backend/libs/three/core/BufferGeometry.d.ts b/backend/libs/three/core/BufferGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..db7bbc3828381f918cebcdff87ee269574e11d4d --- /dev/null +++ b/backend/libs/three/core/BufferGeometry.d.ts @@ -0,0 +1,193 @@ +import { BufferAttribute } from './BufferAttribute'; +import { Box3 } from './../math/Box3'; +import { Sphere } from './../math/Sphere'; +import { Matrix4 } from './../math/Matrix4'; +import { Quaternion } from './../math/Quaternion'; +import { Vector2 } from './../math/Vector2'; +import { Vector3 } from './../math/Vector3'; +import { EventDispatcher } from './EventDispatcher'; +import { InterleavedBufferAttribute } from './InterleavedBufferAttribute'; +import { BuiltinShaderAttributeName } from '../constants'; + +/** + * This is a superefficent class for geometries because it saves all data in buffers. + * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the necessary buffer calculations. + * It is mainly interesting when working with static objects. + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js|src/core/BufferGeometry.js} + */ +export class BufferGeometry extends EventDispatcher { + /** + * This creates a new BufferGeometry. It also sets several properties to an default value. + */ + constructor(); + + /** + * Unique number of this buffergeometry instance + */ + id: number; + uuid: string; + + /** + * @default '' + */ + name: string; + + /** + * @default 'BufferGeometry' + */ + type: string; + + /** + * @default null + */ + index: BufferAttribute | null; + + /** + * @default {} + */ + attributes: { + [name: string]: BufferAttribute | InterleavedBufferAttribute; + }; + + /** + * @default {} + */ + morphAttributes: { + [name: string]: Array; + }; + + /** + * @default false + */ + morphTargetsRelative: boolean; + + /** + * @default [] + */ + groups: Array<{ start: number; count: number; materialIndex?: number | undefined }>; + + /** + * @default null + */ + boundingBox: Box3 | null; + + /** + * @default null + */ + boundingSphere: Sphere | null; + + /** + * @default { start: 0, count: Infinity } + */ + drawRange: { start: number; count: number }; + + /** + * @default {} + */ + userData: { [key: string]: any }; + readonly isBufferGeometry: true; + + getIndex(): BufferAttribute | null; + setIndex(index: BufferAttribute | number[] | null): BufferGeometry; + + setAttribute(name: BuiltinShaderAttributeName | (string & {}), attribute: BufferAttribute | InterleavedBufferAttribute): BufferGeometry; + getAttribute(name: BuiltinShaderAttributeName | (string & {})): BufferAttribute | InterleavedBufferAttribute; + deleteAttribute(name: BuiltinShaderAttributeName | (string & {})): BufferGeometry; + hasAttribute(name: BuiltinShaderAttributeName | (string & {})): boolean; + + addGroup(start: number, count: number, materialIndex?: number): void; + clearGroups(): void; + + setDrawRange(start: number, count: number): void; + + /** + * Bakes matrix transform directly into vertex coordinates. + */ + applyMatrix4(matrix: Matrix4): BufferGeometry; + applyQuaternion(q: Quaternion): BufferGeometry; + + rotateX(angle: number): BufferGeometry; + rotateY(angle: number): BufferGeometry; + rotateZ(angle: number): BufferGeometry; + translate(x: number, y: number, z: number): BufferGeometry; + scale(x: number, y: number, z: number): BufferGeometry; + lookAt(v: Vector3): void; + + center(): BufferGeometry; + + setFromPoints(points: Vector3[] | Vector2[]): BufferGeometry; + + /** + * Computes bounding box of the geometry, updating Geometry.boundingBox attribute. + * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingBox(): void; + + /** + * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. + * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingSphere(): void; + + /** + * Computes and adds tangent attribute to this geometry. + */ + computeTangents(): void; + + /** + * Computes vertex normals by averaging face normals. + */ + computeVertexNormals(): void; + + merge(geometry: BufferGeometry, offset?: number): BufferGeometry; + normalizeNormals(): void; + + toNonIndexed(): BufferGeometry; + + toJSON(): any; + clone(): BufferGeometry; + copy(source: BufferGeometry): this; + + /** + * Disposes the object from memory. + * You need to call this when you want the bufferGeometry removed while the application is running. + */ + dispose(): void; + + /** + * @deprecated Use {@link BufferGeometry#groups .groups} instead. + */ + drawcalls: any; + + /** + * @deprecated Use {@link BufferGeometry#groups .groups} instead. + */ + offsets: any; + + /** + * @deprecated Use {@link BufferGeometry#setIndex .setIndex()} instead. + */ + addIndex(index: any): void; + + /** + * @deprecated Use {@link BufferGeometry#addGroup .addGroup()} instead. + */ + addDrawCall(start: any, count: any, indexOffset?: any): void; + + /** + * @deprecated Use {@link BufferGeometry#clearGroups .clearGroups()} instead. + */ + clearDrawCalls(): void; + + /** + * @deprecated Use {@link BufferGeometry#setAttribute .setAttribute()} instead. + */ + addAttribute(name: string, attribute: BufferAttribute | InterleavedBufferAttribute): BufferGeometry; + addAttribute(name: any, array: any, itemSize: any): any; + + /** + * @deprecated Use {@link BufferGeometry#deleteAttribute .deleteAttribute()} instead. + */ + removeAttribute(name: string): BufferGeometry; +} diff --git a/backend/libs/three/core/BufferGeometry.js b/backend/libs/three/core/BufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..d008d2f7a2314e19d2a9137d207f7b8511ead041 --- /dev/null +++ b/backend/libs/three/core/BufferGeometry.js @@ -0,0 +1,915 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Box3 } from '../math/Box3.js'; +import { EventDispatcher } from './EventDispatcher.js'; +import { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js'; +import { Sphere } from '../math/Sphere.js'; +import { Object3D } from './Object3D.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Matrix3 } from '../math/Matrix3.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { arrayMax } from '../utils.js'; + +let _id = 0; + +const _m1 = /*@__PURE__*/ new Matrix4(); +const _obj = /*@__PURE__*/ new Object3D(); +const _offset = /*@__PURE__*/ new Vector3(); +const _box = /*@__PURE__*/ new Box3(); +const _boxMorphTargets = /*@__PURE__*/ new Box3(); +const _vector = /*@__PURE__*/ new Vector3(); + +class BufferGeometry extends EventDispatcher { + constructor() { + super(); + + Object.defineProperty(this, 'id', { value: _id++ }); + + this.uuid = MathUtils.generateUUID(); + + this.name = ''; + this.type = 'BufferGeometry'; + + this.index = null; + this.attributes = {}; + + this.morphAttributes = {}; + this.morphTargetsRelative = false; + + this.groups = []; + + this.boundingBox = null; + this.boundingSphere = null; + + this.drawRange = { start: 0, count: Infinity }; + + this.userData = {}; + } + + getIndex() { + return this.index; + } + + setIndex(index) { + if (Array.isArray(index)) { + this.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1); + } else { + this.index = index; + } + + return this; + } + + getAttribute(name) { + return this.attributes[name]; + } + + setAttribute(name, attribute) { + this.attributes[name] = attribute; + + return this; + } + + deleteAttribute(name) { + delete this.attributes[name]; + + return this; + } + + hasAttribute(name) { + return this.attributes[name] !== undefined; + } + + addGroup(start, count, materialIndex = 0) { + this.groups.push({ + start: start, + count: count, + materialIndex: materialIndex, + }); + } + + clearGroups() { + this.groups = []; + } + + setDrawRange(start, count) { + this.drawRange.start = start; + this.drawRange.count = count; + } + + applyMatrix4(matrix) { + const position = this.attributes.position; + + if (position !== undefined) { + position.applyMatrix4(matrix); + + position.needsUpdate = true; + } + + const normal = this.attributes.normal; + + if (normal !== undefined) { + const normalMatrix = new Matrix3().getNormalMatrix(matrix); + + normal.applyNormalMatrix(normalMatrix); + + normal.needsUpdate = true; + } + + const tangent = this.attributes.tangent; + + if (tangent !== undefined) { + tangent.transformDirection(matrix); + + tangent.needsUpdate = true; + } + + if (this.boundingBox !== null) { + this.computeBoundingBox(); + } + + if (this.boundingSphere !== null) { + this.computeBoundingSphere(); + } + + return this; + } + + applyQuaternion(q) { + _m1.makeRotationFromQuaternion(q); + + this.applyMatrix4(_m1); + + return this; + } + + rotateX(angle) { + // rotate geometry around world x-axis + + _m1.makeRotationX(angle); + + this.applyMatrix4(_m1); + + return this; + } + + rotateY(angle) { + // rotate geometry around world y-axis + + _m1.makeRotationY(angle); + + this.applyMatrix4(_m1); + + return this; + } + + rotateZ(angle) { + // rotate geometry around world z-axis + + _m1.makeRotationZ(angle); + + this.applyMatrix4(_m1); + + return this; + } + + translate(x, y, z) { + // translate geometry + + _m1.makeTranslation(x, y, z); + + this.applyMatrix4(_m1); + + return this; + } + + scale(x, y, z) { + // scale geometry + + _m1.makeScale(x, y, z); + + this.applyMatrix4(_m1); + + return this; + } + + lookAt(vector) { + _obj.lookAt(vector); + + _obj.updateMatrix(); + + this.applyMatrix4(_obj.matrix); + + return this; + } + + center() { + this.computeBoundingBox(); + + this.boundingBox.getCenter(_offset).negate(); + + this.translate(_offset.x, _offset.y, _offset.z); + + return this; + } + + setFromPoints(points) { + const position = []; + + for (let i = 0, l = points.length; i < l; i++) { + const point = points[i]; + position.push(point.x, point.y, point.z || 0); + } + + this.setAttribute('position', new Float32BufferAttribute(position, 3)); + + return this; + } + + computeBoundingBox() { + if (this.boundingBox === null) { + this.boundingBox = new Box3(); + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if (position && position.isGLBufferAttribute) { + console.error( + 'THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', + this + ); + + this.boundingBox.set(new Vector3(-Infinity, -Infinity, -Infinity), new Vector3(+Infinity, +Infinity, +Infinity)); + + return; + } + + if (position !== undefined) { + this.boundingBox.setFromBufferAttribute(position); + + // process morph attributes if present + + if (morphAttributesPosition) { + for (let i = 0, il = morphAttributesPosition.length; i < il; i++) { + const morphAttribute = morphAttributesPosition[i]; + _box.setFromBufferAttribute(morphAttribute); + + if (this.morphTargetsRelative) { + _vector.addVectors(this.boundingBox.min, _box.min); + this.boundingBox.expandByPoint(_vector); + + _vector.addVectors(this.boundingBox.max, _box.max); + this.boundingBox.expandByPoint(_vector); + } else { + this.boundingBox.expandByPoint(_box.min); + this.boundingBox.expandByPoint(_box.max); + } + } + } + } else { + this.boundingBox.makeEmpty(); + } + + if (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) { + console.error( + 'THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', + this + ); + } + } + + computeBoundingSphere() { + if (this.boundingSphere === null) { + this.boundingSphere = new Sphere(); + } + + const position = this.attributes.position; + const morphAttributesPosition = this.morphAttributes.position; + + if (position && position.isGLBufferAttribute) { + console.error( + 'THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', + this + ); + + this.boundingSphere.set(new Vector3(), Infinity); + + return; + } + + if (position) { + // first, find the center of the bounding sphere + + const center = this.boundingSphere.center; + + _box.setFromBufferAttribute(position); + + // process morph attributes if present + + if (morphAttributesPosition) { + for (let i = 0, il = morphAttributesPosition.length; i < il; i++) { + const morphAttribute = morphAttributesPosition[i]; + _boxMorphTargets.setFromBufferAttribute(morphAttribute); + + if (this.morphTargetsRelative) { + _vector.addVectors(_box.min, _boxMorphTargets.min); + _box.expandByPoint(_vector); + + _vector.addVectors(_box.max, _boxMorphTargets.max); + _box.expandByPoint(_vector); + } else { + _box.expandByPoint(_boxMorphTargets.min); + _box.expandByPoint(_boxMorphTargets.max); + } + } + } + + _box.getCenter(center); + + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + + let maxRadiusSq = 0; + + for (let i = 0, il = position.count; i < il; i++) { + _vector.fromBufferAttribute(position, i); + + maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector)); + } + + // process morph attributes if present + + if (morphAttributesPosition) { + for (let i = 0, il = morphAttributesPosition.length; i < il; i++) { + const morphAttribute = morphAttributesPosition[i]; + const morphTargetsRelative = this.morphTargetsRelative; + + for (let j = 0, jl = morphAttribute.count; j < jl; j++) { + _vector.fromBufferAttribute(morphAttribute, j); + + if (morphTargetsRelative) { + _offset.fromBufferAttribute(position, j); + _vector.add(_offset); + } + + maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector)); + } + } + } + + this.boundingSphere.radius = Math.sqrt(maxRadiusSq); + + if (isNaN(this.boundingSphere.radius)) { + console.error( + 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', + this + ); + } + } + } + + computeTangents() { + const index = this.index; + const attributes = this.attributes; + + // based on http://www.terathon.com/code/tangent.html + // (per vertex tangents) + + if (index === null || attributes.position === undefined || attributes.normal === undefined || attributes.uv === undefined) { + console.error('THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)'); + return; + } + + const indices = index.array; + const positions = attributes.position.array; + const normals = attributes.normal.array; + const uvs = attributes.uv.array; + + const nVertices = positions.length / 3; + + if (attributes.tangent === undefined) { + this.setAttribute('tangent', new BufferAttribute(new Float32Array(4 * nVertices), 4)); + } + + const tangents = attributes.tangent.array; + + const tan1 = [], + tan2 = []; + + for (let i = 0; i < nVertices; i++) { + tan1[i] = new Vector3(); + tan2[i] = new Vector3(); + } + + const vA = new Vector3(), + vB = new Vector3(), + vC = new Vector3(), + uvA = new Vector2(), + uvB = new Vector2(), + uvC = new Vector2(), + sdir = new Vector3(), + tdir = new Vector3(); + + function handleTriangle(a, b, c) { + vA.fromArray(positions, a * 3); + vB.fromArray(positions, b * 3); + vC.fromArray(positions, c * 3); + + uvA.fromArray(uvs, a * 2); + uvB.fromArray(uvs, b * 2); + uvC.fromArray(uvs, c * 2); + + vB.sub(vA); + vC.sub(vA); + + uvB.sub(uvA); + uvC.sub(uvA); + + const r = 1.0 / (uvB.x * uvC.y - uvC.x * uvB.y); + + // silently ignore degenerate uv triangles having coincident or colinear vertices + + if (!isFinite(r)) return; + + sdir.copy(vB).multiplyScalar(uvC.y).addScaledVector(vC, -uvB.y).multiplyScalar(r); + tdir.copy(vC).multiplyScalar(uvB.x).addScaledVector(vB, -uvC.x).multiplyScalar(r); + + tan1[a].add(sdir); + tan1[b].add(sdir); + tan1[c].add(sdir); + + tan2[a].add(tdir); + tan2[b].add(tdir); + tan2[c].add(tdir); + } + + let groups = this.groups; + + if (groups.length === 0) { + groups = [ + { + start: 0, + count: indices.length, + }, + ]; + } + + for (let i = 0, il = groups.length; i < il; ++i) { + const group = groups[i]; + + const start = group.start; + const count = group.count; + + for (let j = start, jl = start + count; j < jl; j += 3) { + handleTriangle(indices[j + 0], indices[j + 1], indices[j + 2]); + } + } + + const tmp = new Vector3(), + tmp2 = new Vector3(); + const n = new Vector3(), + n2 = new Vector3(); + + function handleVertex(v) { + n.fromArray(normals, v * 3); + n2.copy(n); + + const t = tan1[v]; + + // Gram-Schmidt orthogonalize + + tmp.copy(t); + tmp.sub(n.multiplyScalar(n.dot(t))).normalize(); + + // Calculate handedness + + tmp2.crossVectors(n2, t); + const test = tmp2.dot(tan2[v]); + const w = test < 0.0 ? -1.0 : 1.0; + + tangents[v * 4] = tmp.x; + tangents[v * 4 + 1] = tmp.y; + tangents[v * 4 + 2] = tmp.z; + tangents[v * 4 + 3] = w; + } + + for (let i = 0, il = groups.length; i < il; ++i) { + const group = groups[i]; + + const start = group.start; + const count = group.count; + + for (let j = start, jl = start + count; j < jl; j += 3) { + handleVertex(indices[j + 0]); + handleVertex(indices[j + 1]); + handleVertex(indices[j + 2]); + } + } + } + + computeVertexNormals() { + const index = this.index; + const positionAttribute = this.getAttribute('position'); + + if (positionAttribute !== undefined) { + let normalAttribute = this.getAttribute('normal'); + + if (normalAttribute === undefined) { + normalAttribute = new BufferAttribute(new Float32Array(positionAttribute.count * 3), 3); + this.setAttribute('normal', normalAttribute); + } else { + // reset existing normals to zero + + for (let i = 0, il = normalAttribute.count; i < il; i++) { + normalAttribute.setXYZ(i, 0, 0, 0); + } + } + + const pA = new Vector3(), + pB = new Vector3(), + pC = new Vector3(); + const nA = new Vector3(), + nB = new Vector3(), + nC = new Vector3(); + const cb = new Vector3(), + ab = new Vector3(); + + // indexed elements + + if (index) { + for (let i = 0, il = index.count; i < il; i += 3) { + const vA = index.getX(i + 0); + const vB = index.getX(i + 1); + const vC = index.getX(i + 2); + + pA.fromBufferAttribute(positionAttribute, vA); + pB.fromBufferAttribute(positionAttribute, vB); + pC.fromBufferAttribute(positionAttribute, vC); + + cb.subVectors(pC, pB); + ab.subVectors(pA, pB); + cb.cross(ab); + + nA.fromBufferAttribute(normalAttribute, vA); + nB.fromBufferAttribute(normalAttribute, vB); + nC.fromBufferAttribute(normalAttribute, vC); + + nA.add(cb); + nB.add(cb); + nC.add(cb); + + normalAttribute.setXYZ(vA, nA.x, nA.y, nA.z); + normalAttribute.setXYZ(vB, nB.x, nB.y, nB.z); + normalAttribute.setXYZ(vC, nC.x, nC.y, nC.z); + } + } else { + // non-indexed elements (unconnected triangle soup) + + for (let i = 0, il = positionAttribute.count; i < il; i += 3) { + pA.fromBufferAttribute(positionAttribute, i + 0); + pB.fromBufferAttribute(positionAttribute, i + 1); + pC.fromBufferAttribute(positionAttribute, i + 2); + + cb.subVectors(pC, pB); + ab.subVectors(pA, pB); + cb.cross(ab); + + normalAttribute.setXYZ(i + 0, cb.x, cb.y, cb.z); + normalAttribute.setXYZ(i + 1, cb.x, cb.y, cb.z); + normalAttribute.setXYZ(i + 2, cb.x, cb.y, cb.z); + } + } + + this.normalizeNormals(); + + normalAttribute.needsUpdate = true; + } + } + + merge(geometry, offset) { + if (!(geometry && geometry.isBufferGeometry)) { + console.error('THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry); + return; + } + + if (offset === undefined) { + offset = 0; + + console.warn( + 'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. ' + + 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.' + ); + } + + const attributes = this.attributes; + + for (const key in attributes) { + if (geometry.attributes[key] === undefined) continue; + + const attribute1 = attributes[key]; + const attributeArray1 = attribute1.array; + + const attribute2 = geometry.attributes[key]; + const attributeArray2 = attribute2.array; + + const attributeOffset = attribute2.itemSize * offset; + const length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset); + + for (let i = 0, j = attributeOffset; i < length; i++, j++) { + attributeArray1[j] = attributeArray2[i]; + } + } + + return this; + } + + normalizeNormals() { + const normals = this.attributes.normal; + + for (let i = 0, il = normals.count; i < il; i++) { + _vector.fromBufferAttribute(normals, i); + + _vector.normalize(); + + normals.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + } + + toNonIndexed() { + function convertBufferAttribute(attribute, indices) { + const array = attribute.array; + const itemSize = attribute.itemSize; + const normalized = attribute.normalized; + + const array2 = new array.constructor(indices.length * itemSize); + + let index = 0, + index2 = 0; + + for (let i = 0, l = indices.length; i < l; i++) { + if (attribute.isInterleavedBufferAttribute) { + index = indices[i] * attribute.data.stride + attribute.offset; + } else { + index = indices[i] * itemSize; + } + + for (let j = 0; j < itemSize; j++) { + array2[index2++] = array[index++]; + } + } + + return new BufferAttribute(array2, itemSize, normalized); + } + + // + + if (this.index === null) { + console.warn('THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.'); + return this; + } + + const geometry2 = new BufferGeometry(); + + const indices = this.index.array; + const attributes = this.attributes; + + // attributes + + for (const name in attributes) { + const attribute = attributes[name]; + + const newAttribute = convertBufferAttribute(attribute, indices); + + geometry2.setAttribute(name, newAttribute); + } + + // morph attributes + + const morphAttributes = this.morphAttributes; + + for (const name in morphAttributes) { + const morphArray = []; + const morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes + + for (let i = 0, il = morphAttribute.length; i < il; i++) { + const attribute = morphAttribute[i]; + + const newAttribute = convertBufferAttribute(attribute, indices); + + morphArray.push(newAttribute); + } + + geometry2.morphAttributes[name] = morphArray; + } + + geometry2.morphTargetsRelative = this.morphTargetsRelative; + + // groups + + const groups = this.groups; + + for (let i = 0, l = groups.length; i < l; i++) { + const group = groups[i]; + geometry2.addGroup(group.start, group.count, group.materialIndex); + } + + return geometry2; + } + + toJSON() { + const data = { + metadata: { + version: 4.5, + type: 'BufferGeometry', + generator: 'BufferGeometry.toJSON', + }, + }; + + // standard BufferGeometry serialization + + data.uuid = this.uuid; + data.type = this.type; + if (this.name !== '') data.name = this.name; + if (Object.keys(this.userData).length > 0) data.userData = this.userData; + + if (this.parameters !== undefined) { + const parameters = this.parameters; + + for (const key in parameters) { + if (parameters[key] !== undefined) data[key] = parameters[key]; + } + + return data; + } + + // for simplicity the code assumes attributes are not shared across geometries, see #15811 + + data.data = { attributes: {} }; + + const index = this.index; + + if (index !== null) { + data.data.index = { + type: index.array.constructor.name, + array: Array.prototype.slice.call(index.array), + }; + } + + const attributes = this.attributes; + + for (const key in attributes) { + const attribute = attributes[key]; + + data.data.attributes[key] = attribute.toJSON(data.data); + } + + const morphAttributes = {}; + let hasMorphAttributes = false; + + for (const key in this.morphAttributes) { + const attributeArray = this.morphAttributes[key]; + + const array = []; + + for (let i = 0, il = attributeArray.length; i < il; i++) { + const attribute = attributeArray[i]; + + array.push(attribute.toJSON(data.data)); + } + + if (array.length > 0) { + morphAttributes[key] = array; + + hasMorphAttributes = true; + } + } + + if (hasMorphAttributes) { + data.data.morphAttributes = morphAttributes; + data.data.morphTargetsRelative = this.morphTargetsRelative; + } + + const groups = this.groups; + + if (groups.length > 0) { + data.data.groups = JSON.parse(JSON.stringify(groups)); + } + + const boundingSphere = this.boundingSphere; + + if (boundingSphere !== null) { + data.data.boundingSphere = { + center: boundingSphere.center.toArray(), + radius: boundingSphere.radius, + }; + } + + return data; + } + + clone() { + return new this.constructor().copy(this); + } + + copy(source) { + // reset + + this.index = null; + this.attributes = {}; + this.morphAttributes = {}; + this.groups = []; + this.boundingBox = null; + this.boundingSphere = null; + + // used for storing cloned, shared data + + const data = {}; + + // name + + this.name = source.name; + + // index + + const index = source.index; + + if (index !== null) { + this.setIndex(index.clone(data)); + } + + // attributes + + const attributes = source.attributes; + + for (const name in attributes) { + const attribute = attributes[name]; + this.setAttribute(name, attribute.clone(data)); + } + + // morph attributes + + const morphAttributes = source.morphAttributes; + + for (const name in morphAttributes) { + const array = []; + const morphAttribute = morphAttributes[name]; // morphAttribute: array of Float32BufferAttributes + + for (let i = 0, l = morphAttribute.length; i < l; i++) { + array.push(morphAttribute[i].clone(data)); + } + + this.morphAttributes[name] = array; + } + + this.morphTargetsRelative = source.morphTargetsRelative; + + // groups + + const groups = source.groups; + + for (let i = 0, l = groups.length; i < l; i++) { + const group = groups[i]; + this.addGroup(group.start, group.count, group.materialIndex); + } + + // bounding box + + const boundingBox = source.boundingBox; + + if (boundingBox !== null) { + this.boundingBox = boundingBox.clone(); + } + + // bounding sphere + + const boundingSphere = source.boundingSphere; + + if (boundingSphere !== null) { + this.boundingSphere = boundingSphere.clone(); + } + + // draw range + + this.drawRange.start = source.drawRange.start; + this.drawRange.count = source.drawRange.count; + + // user data + + this.userData = source.userData; + + // geometry generator parameters + + if (source.parameters !== undefined) this.parameters = Object.assign({}, source.parameters); + + return this; + } + + dispose() { + this.dispatchEvent({ type: 'dispose' }); + } +} + +BufferGeometry.prototype.isBufferGeometry = true; + +export { BufferGeometry }; diff --git a/backend/libs/three/core/Clock.d.ts b/backend/libs/three/core/Clock.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ada519724bd35de8ed054d39f956a627f1f40c36 --- /dev/null +++ b/backend/libs/three/core/Clock.d.ts @@ -0,0 +1,64 @@ +/** + * Object for keeping track of time. + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Clock.js|src/core/Clock.js} + */ +export class Clock { + /** + * @param [autoStart=true] Automatically start the clock. + */ + constructor(autoStart?: boolean); + + /** + * If set, starts the clock automatically when the first update is called. + * @default true + */ + autoStart: boolean; + + /** + * When the clock is running, It holds the starttime of the clock. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + * @default 0 + */ + startTime: number; + + /** + * When the clock is running, It holds the previous time from a update. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + * @default 0 + */ + oldTime: number; + + /** + * When the clock is running, It holds the time elapsed between the start of the clock to the previous update. + * This parameter is in seconds of three decimal places. + * @default 0 + */ + elapsedTime: number; + + /** + * This property keeps track whether the clock is running or not. + * @default false + */ + running: boolean; + + /** + * Starts clock. + */ + start(): void; + + /** + * Stops clock. + */ + stop(): void; + + /** + * Get the seconds passed since the clock started. + */ + getElapsedTime(): number; + + /** + * Get the seconds passed since the last call to this method. + */ + getDelta(): number; +} diff --git a/backend/libs/three/core/Clock.js b/backend/libs/three/core/Clock.js new file mode 100644 index 0000000000000000000000000000000000000000..0eff1d2ff13c983a124dc1746d20404af41cd422 --- /dev/null +++ b/backend/libs/three/core/Clock.js @@ -0,0 +1,56 @@ +class Clock { + constructor(autoStart = true) { + this.autoStart = autoStart; + + this.startTime = 0; + this.oldTime = 0; + this.elapsedTime = 0; + + this.running = false; + } + + start() { + this.startTime = now(); + + this.oldTime = this.startTime; + this.elapsedTime = 0; + this.running = true; + } + + stop() { + this.getElapsedTime(); + this.running = false; + this.autoStart = false; + } + + getElapsedTime() { + this.getDelta(); + return this.elapsedTime; + } + + getDelta() { + let diff = 0; + + if (this.autoStart && !this.running) { + this.start(); + return 0; + } + + if (this.running) { + const newTime = now(); + + diff = (newTime - this.oldTime) / 1000; + this.oldTime = newTime; + + this.elapsedTime += diff; + } + + return diff; + } +} + +function now() { + return (typeof performance === 'undefined' ? Date : performance).now(); // see #10732 +} + +export { Clock }; diff --git a/backend/libs/three/core/EventDispatcher.d.ts b/backend/libs/three/core/EventDispatcher.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7809d36e810544e8a54742a67c879d0f25e164e1 --- /dev/null +++ b/backend/libs/three/core/EventDispatcher.d.ts @@ -0,0 +1,51 @@ +export interface BaseEvent { + type: string; +} + +/** + * Event object. + */ +export interface Event extends BaseEvent { + target?: any; + [attachment: string]: any; +} +export type EventListener = (event: E & { type: T } & { target: U }) => void; + +/** + * JavaScript events for custom objects + * + * @source src/core/EventDispatcher.js + */ +export class EventDispatcher { + /** + * Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object. + */ + constructor(); + + /** + * Adds a listener to an event type. + * @param type The type of event to listen to. + * @param listener The function that gets called when the event is fired. + */ + addEventListener(type: T, listener: EventListener): void; + + /** + * Checks if listener is added to an event type. + * @param type The type of event to listen to. + * @param listener The function that gets called when the event is fired. + */ + hasEventListener(type: T, listener: EventListener): boolean; + + /** + * Removes a listener from an event type. + * @param type The type of the listener that gets removed. + * @param listener The listener function that gets removed. + */ + removeEventListener(type: T, listener: EventListener): void; + + /** + * Fire an event type. + * @param type The type of event that gets fired. + */ + dispatchEvent(event: E): void; +} diff --git a/backend/libs/three/core/EventDispatcher.js b/backend/libs/three/core/EventDispatcher.js new file mode 100644 index 0000000000000000000000000000000000000000..a32ee3c8ed2d37da368242627c3bf1de997df168 --- /dev/null +++ b/backend/libs/three/core/EventDispatcher.js @@ -0,0 +1,64 @@ +/** + * https://github.com/mrdoob/eventdispatcher.js/ + */ + +class EventDispatcher { + addEventListener(type, listener) { + if (this._listeners === undefined) this._listeners = {}; + + const listeners = this._listeners; + + if (listeners[type] === undefined) { + listeners[type] = []; + } + + if (listeners[type].indexOf(listener) === -1) { + listeners[type].push(listener); + } + } + + hasEventListener(type, listener) { + if (this._listeners === undefined) return false; + + const listeners = this._listeners; + + return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1; + } + + removeEventListener(type, listener) { + if (this._listeners === undefined) return; + + const listeners = this._listeners; + const listenerArray = listeners[type]; + + if (listenerArray !== undefined) { + const index = listenerArray.indexOf(listener); + + if (index !== -1) { + listenerArray.splice(index, 1); + } + } + } + + dispatchEvent(event) { + if (this._listeners === undefined) return; + + const listeners = this._listeners; + const listenerArray = listeners[event.type]; + + if (listenerArray !== undefined) { + event.target = this; + + // Make a copy, in case listeners are removed while iterating. + const array = listenerArray.slice(0); + + for (let i = 0, l = array.length; i < l; i++) { + array[i].call(this, event); + } + + event.target = null; + } + } +} + +export { EventDispatcher }; diff --git a/backend/libs/three/core/GLBufferAttribute.d.ts b/backend/libs/three/core/GLBufferAttribute.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..07fb583bc5693829b03153e7a1c3c1d96371c1a7 --- /dev/null +++ b/backend/libs/three/core/GLBufferAttribute.d.ts @@ -0,0 +1,23 @@ +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/GLBufferAttribute.js|src/core/GLBufferAttribute.js} + */ + +export class GLBufferAttribute { + constructor(buffer: WebGLBuffer, type: number, itemSize: number, elementSize: 1 | 2 | 4, count: number); + + buffer: WebGLBuffer; + type: number; + itemSize: number; + elementSize: 1 | 2 | 4; + count: number; + version: number; + + readonly isGLBufferAttribute: true; + + set needsUpdate(value: boolean); + + setBuffer(buffer: WebGLBuffer): this; + setType(type: number, elementSize: 1 | 2 | 4): this; + setItemSize(itemSize: number): this; + setCount(count: number): this; +} diff --git a/backend/libs/three/core/GLBufferAttribute.js b/backend/libs/three/core/GLBufferAttribute.js new file mode 100644 index 0000000000000000000000000000000000000000..5e6c5a28b642b6c13977526b061b93f867b7362c --- /dev/null +++ b/backend/libs/three/core/GLBufferAttribute.js @@ -0,0 +1,44 @@ +class GLBufferAttribute { + constructor(buffer, type, itemSize, elementSize, count) { + this.buffer = buffer; + this.type = type; + this.itemSize = itemSize; + this.elementSize = elementSize; + this.count = count; + + this.version = 0; + } + + set needsUpdate(value) { + if (value === true) this.version++; + } + + setBuffer(buffer) { + this.buffer = buffer; + + return this; + } + + setType(type, elementSize) { + this.type = type; + this.elementSize = elementSize; + + return this; + } + + setItemSize(itemSize) { + this.itemSize = itemSize; + + return this; + } + + setCount(count) { + this.count = count; + + return this; + } +} + +GLBufferAttribute.prototype.isGLBufferAttribute = true; + +export { GLBufferAttribute }; diff --git a/backend/libs/three/core/InstancedBufferAttribute.d.ts b/backend/libs/three/core/InstancedBufferAttribute.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e1a694718d3fa77963755981b43a5e22145212a1 --- /dev/null +++ b/backend/libs/three/core/InstancedBufferAttribute.d.ts @@ -0,0 +1,37 @@ +import { BufferGeometry } from './BufferGeometry'; +import { BufferAttribute } from './BufferAttribute'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js|examples/jsm/utils/BufferGeometryUtils.js} + */ +export namespace BufferGeometryUtils { + function mergeBufferGeometries(geometries: BufferGeometry[]): BufferGeometry; + function computeTangents(geometry: BufferGeometry): null; + function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute; +} + +/** + * @deprecated + */ +export namespace GeometryUtils { + /** + * @deprecated Use {@link Geometry#merge geometry.merge( geometry2, matrix, materialIndexOffset )} instead. + */ + function merge(geometry1: any, geometry2: any, materialIndexOffset?: any): any; + /** + * @deprecated Use {@link Geometry#center geometry.center()} instead. + */ + function center(geometry: any): any; +} + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InstancedBufferAttribute.js|src/core/InstancedBufferAttribute.js} + */ +export class InstancedBufferAttribute extends BufferAttribute { + constructor(array: ArrayLike, itemSize: number, normalized?: boolean, meshPerAttribute?: number); + + /** + * @default 1 + */ + meshPerAttribute: number; +} diff --git a/backend/libs/three/core/InstancedBufferAttribute.js b/backend/libs/three/core/InstancedBufferAttribute.js new file mode 100644 index 0000000000000000000000000000000000000000..400a5d2a1e9a607e7828a86502bad016e9f211bd --- /dev/null +++ b/backend/libs/three/core/InstancedBufferAttribute.js @@ -0,0 +1,39 @@ +import { BufferAttribute } from './BufferAttribute.js'; + +class InstancedBufferAttribute extends BufferAttribute { + constructor(array, itemSize, normalized, meshPerAttribute = 1) { + if (typeof normalized === 'number') { + meshPerAttribute = normalized; + + normalized = false; + + console.error('THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.'); + } + + super(array, itemSize, normalized); + + this.meshPerAttribute = meshPerAttribute; + } + + copy(source) { + super.copy(source); + + this.meshPerAttribute = source.meshPerAttribute; + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.meshPerAttribute = this.meshPerAttribute; + + data.isInstancedBufferAttribute = true; + + return data; + } +} + +InstancedBufferAttribute.prototype.isInstancedBufferAttribute = true; + +export { InstancedBufferAttribute }; diff --git a/backend/libs/three/core/InstancedBufferGeometry.d.ts b/backend/libs/three/core/InstancedBufferGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d790b3f3f86fc1c03d99d611c4b729aca17761df --- /dev/null +++ b/backend/libs/three/core/InstancedBufferGeometry.d.ts @@ -0,0 +1,20 @@ +import { BufferGeometry } from './BufferGeometry'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InstancedBufferGeometry.js|src/core/InstancedBufferGeometry.js} + */ +export class InstancedBufferGeometry extends BufferGeometry { + constructor(); + + /** + * @default 'InstancedBufferGeometry + */ + type: string; + + isInstancedBufferGeometry: boolean; + + /** + * @default Infinity + */ + instanceCount: number; +} diff --git a/backend/libs/three/core/InstancedBufferGeometry.js b/backend/libs/three/core/InstancedBufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..ac34813004075d5de34f4cb77287836038f5d36d --- /dev/null +++ b/backend/libs/three/core/InstancedBufferGeometry.js @@ -0,0 +1,36 @@ +import { BufferGeometry } from './BufferGeometry.js'; + +class InstancedBufferGeometry extends BufferGeometry { + constructor() { + super(); + + this.type = 'InstancedBufferGeometry'; + this.instanceCount = Infinity; + } + + copy(source) { + super.copy(source); + + this.instanceCount = source.instanceCount; + + return this; + } + + clone() { + return new this.constructor().copy(this); + } + + toJSON() { + const data = super.toJSON(this); + + data.instanceCount = this.instanceCount; + + data.isInstancedBufferGeometry = true; + + return data; + } +} + +InstancedBufferGeometry.prototype.isInstancedBufferGeometry = true; + +export { InstancedBufferGeometry }; diff --git a/backend/libs/three/core/InstancedInterleavedBuffer.d.ts b/backend/libs/three/core/InstancedInterleavedBuffer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d245617f34cb2499d7830040ad14189964acf35a --- /dev/null +++ b/backend/libs/three/core/InstancedInterleavedBuffer.d.ts @@ -0,0 +1,13 @@ +import { InterleavedBuffer } from './InterleavedBuffer'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InstancedInterleavedBuffer.js|src/core/InstancedInterleavedBuffer.js} + */ +export class InstancedInterleavedBuffer extends InterleavedBuffer { + constructor(array: ArrayLike, stride: number, meshPerAttribute?: number); + + /** + * @default 1 + */ + meshPerAttribute: number; +} diff --git a/backend/libs/three/core/InstancedInterleavedBuffer.js b/backend/libs/three/core/InstancedInterleavedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..99289600c38c728f7297a9094dd5120fe73e936f --- /dev/null +++ b/backend/libs/three/core/InstancedInterleavedBuffer.js @@ -0,0 +1,38 @@ +import { InterleavedBuffer } from './InterleavedBuffer.js'; + +class InstancedInterleavedBuffer extends InterleavedBuffer { + constructor(array, stride, meshPerAttribute = 1) { + super(array, stride); + + this.meshPerAttribute = meshPerAttribute; + } + + copy(source) { + super.copy(source); + + this.meshPerAttribute = source.meshPerAttribute; + + return this; + } + + clone(data) { + const ib = super.clone(data); + + ib.meshPerAttribute = this.meshPerAttribute; + + return ib; + } + + toJSON(data) { + const json = super.toJSON(data); + + json.isInstancedInterleavedBuffer = true; + json.meshPerAttribute = this.meshPerAttribute; + + return json; + } +} + +InstancedInterleavedBuffer.prototype.isInstancedInterleavedBuffer = true; + +export { InstancedInterleavedBuffer }; diff --git a/backend/libs/three/core/InterleavedBuffer.d.ts b/backend/libs/three/core/InterleavedBuffer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ac2d938bfaacede2744187defd4387c330eafb7c --- /dev/null +++ b/backend/libs/three/core/InterleavedBuffer.d.ts @@ -0,0 +1,48 @@ +import { InterleavedBufferAttribute } from './InterleavedBufferAttribute'; +import { Usage } from '../constants'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js|src/core/InterleavedBuffer.js} + */ +export class InterleavedBuffer { + constructor(array: ArrayLike, stride: number); + + array: ArrayLike; + stride: number; + + /** + * @default THREE.StaticDrawUsage + */ + usage: Usage; + + /** + * @default { offset: number; count: number } + */ + updateRange: { offset: number; count: number }; + + /** + * @default 0 + */ + version: number; + + length: number; + + /** + * @default 0 + */ + count: number; + needsUpdate: boolean; + uuid: string; + + setUsage(usage: Usage): InterleavedBuffer; + clone(data: object): InterleavedBuffer; + copy(source: InterleavedBuffer): this; + copyAt(index1: number, attribute: InterleavedBufferAttribute, index2: number): InterleavedBuffer; + set(value: ArrayLike, index: number): InterleavedBuffer; + toJSON(data: object): { + uuid: string; + buffer: string; + type: string; + stride: number; + }; +} diff --git a/backend/libs/three/core/InterleavedBuffer.js b/backend/libs/three/core/InterleavedBuffer.js new file mode 100644 index 0000000000000000000000000000000000000000..ae272389c616df665caad8ed5e46222cc73c8845 --- /dev/null +++ b/backend/libs/three/core/InterleavedBuffer.js @@ -0,0 +1,111 @@ +import * as MathUtils from '../math/MathUtils.js'; +import { StaticDrawUsage } from '../constants.js'; + +class InterleavedBuffer { + constructor(array, stride) { + this.array = array; + this.stride = stride; + this.count = array !== undefined ? array.length / stride : 0; + + this.usage = StaticDrawUsage; + this.updateRange = { offset: 0, count: -1 }; + + this.version = 0; + + this.uuid = MathUtils.generateUUID(); + } + + onUploadCallback() {} + + set needsUpdate(value) { + if (value === true) this.version++; + } + + setUsage(value) { + this.usage = value; + + return this; + } + + copy(source) { + this.array = new source.array.constructor(source.array); + this.count = source.count; + this.stride = source.stride; + this.usage = source.usage; + + return this; + } + + copyAt(index1, attribute, index2) { + index1 *= this.stride; + index2 *= attribute.stride; + + for (let i = 0, l = this.stride; i < l; i++) { + this.array[index1 + i] = attribute.array[index2 + i]; + } + + return this; + } + + set(value, offset = 0) { + this.array.set(value, offset); + + return this; + } + + clone(data) { + if (data.arrayBuffers === undefined) { + data.arrayBuffers = {}; + } + + if (this.array.buffer._uuid === undefined) { + this.array.buffer._uuid = MathUtils.generateUUID(); + } + + if (data.arrayBuffers[this.array.buffer._uuid] === undefined) { + data.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer; + } + + const array = new this.array.constructor(data.arrayBuffers[this.array.buffer._uuid]); + + const ib = new this.constructor(array, this.stride); + ib.setUsage(this.usage); + + return ib; + } + + onUpload(callback) { + this.onUploadCallback = callback; + + return this; + } + + toJSON(data) { + if (data.arrayBuffers === undefined) { + data.arrayBuffers = {}; + } + + // generate UUID for array buffer if necessary + + if (this.array.buffer._uuid === undefined) { + this.array.buffer._uuid = MathUtils.generateUUID(); + } + + if (data.arrayBuffers[this.array.buffer._uuid] === undefined) { + data.arrayBuffers[this.array.buffer._uuid] = Array.prototype.slice.call(new Uint32Array(this.array.buffer)); + } + + // + + return { + uuid: this.uuid, + buffer: this.array.buffer._uuid, + type: this.array.constructor.name, + stride: this.stride, + }; + } +} + +InterleavedBuffer.prototype.isInterleavedBuffer = true; + +export { InterleavedBuffer }; diff --git a/backend/libs/three/core/InterleavedBufferAttribute.d.ts b/backend/libs/three/core/InterleavedBufferAttribute.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7ebfa3838b1f5391adadd56a3bbb6235486f364e --- /dev/null +++ b/backend/libs/three/core/InterleavedBufferAttribute.d.ts @@ -0,0 +1,52 @@ +import { BufferAttribute } from './BufferAttribute'; +import { InterleavedBuffer } from './InterleavedBuffer'; +import { Matrix4 } from './../math/Matrix4'; +import { Matrix } from './../math/Matrix3'; +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBufferAttribute.js|src/core/InterleavedBufferAttribute.js} + */ +export class InterleavedBufferAttribute { + constructor(interleavedBuffer: InterleavedBuffer, itemSize: number, offset: number, normalized?: boolean); + + /** + * @default '' + */ + name: string; + data: InterleavedBuffer; + itemSize: number; + offset: number; + + /** + * @default false + */ + normalized: boolean; + + get count(): number; + get array(): ArrayLike; + set needsUpdate(value: boolean); + + readonly isInterleavedBufferAttribute: true; + + applyMatrix4(m: Matrix4): this; + clone(data?: object): BufferAttribute; + getX(index: number): number; + setX(index: number, x: number): this; + getY(index: number): number; + setY(index: number, y: number): this; + getZ(index: number): number; + setZ(index: number, z: number): this; + getW(index: number): number; + setW(index: number, z: number): this; + setXY(index: number, x: number, y: number): this; + setXYZ(index: number, x: number, y: number, z: number): this; + setXYZW(index: number, x: number, y: number, z: number, w: number): this; + toJSON(data?: object): { + isInterleavedBufferAttribute: true; + itemSize: number; + data: string; + offset: number; + normalized: boolean; + }; + applyNormalMatrix(matrix: Matrix): this; + transformDirection(matrix: Matrix): this; +} diff --git a/backend/libs/three/core/InterleavedBufferAttribute.js b/backend/libs/three/core/InterleavedBufferAttribute.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1ee2a833188004a1e8aa13ad2bd680f8b05461 --- /dev/null +++ b/backend/libs/three/core/InterleavedBufferAttribute.js @@ -0,0 +1,215 @@ +import { Vector3 } from '../math/Vector3.js'; +import { BufferAttribute } from './BufferAttribute.js'; + +const _vector = /*@__PURE__*/ new Vector3(); + +class InterleavedBufferAttribute { + constructor(interleavedBuffer, itemSize, offset, normalized = false) { + this.name = ''; + + this.data = interleavedBuffer; + this.itemSize = itemSize; + this.offset = offset; + + this.normalized = normalized === true; + } + + get count() { + return this.data.count; + } + + get array() { + return this.data.array; + } + + set needsUpdate(value) { + this.data.needsUpdate = value; + } + + applyMatrix4(m) { + for (let i = 0, l = this.data.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.applyMatrix4(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + applyNormalMatrix(m) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.applyNormalMatrix(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + transformDirection(m) { + for (let i = 0, l = this.count; i < l; i++) { + _vector.x = this.getX(i); + _vector.y = this.getY(i); + _vector.z = this.getZ(i); + + _vector.transformDirection(m); + + this.setXYZ(i, _vector.x, _vector.y, _vector.z); + } + + return this; + } + + setX(index, x) { + this.data.array[index * this.data.stride + this.offset] = x; + + return this; + } + + setY(index, y) { + this.data.array[index * this.data.stride + this.offset + 1] = y; + + return this; + } + + setZ(index, z) { + this.data.array[index * this.data.stride + this.offset + 2] = z; + + return this; + } + + setW(index, w) { + this.data.array[index * this.data.stride + this.offset + 3] = w; + + return this; + } + + getX(index) { + return this.data.array[index * this.data.stride + this.offset]; + } + + getY(index) { + return this.data.array[index * this.data.stride + this.offset + 1]; + } + + getZ(index) { + return this.data.array[index * this.data.stride + this.offset + 2]; + } + + getW(index) { + return this.data.array[index * this.data.stride + this.offset + 3]; + } + + setXY(index, x, y) { + index = index * this.data.stride + this.offset; + + this.data.array[index + 0] = x; + this.data.array[index + 1] = y; + + return this; + } + + setXYZ(index, x, y, z) { + index = index * this.data.stride + this.offset; + + this.data.array[index + 0] = x; + this.data.array[index + 1] = y; + this.data.array[index + 2] = z; + + return this; + } + + setXYZW(index, x, y, z, w) { + index = index * this.data.stride + this.offset; + + this.data.array[index + 0] = x; + this.data.array[index + 1] = y; + this.data.array[index + 2] = z; + this.data.array[index + 3] = w; + + return this; + } + + clone(data) { + if (data === undefined) { + console.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.'); + + const array = []; + + for (let i = 0; i < this.count; i++) { + const index = i * this.data.stride + this.offset; + + for (let j = 0; j < this.itemSize; j++) { + array.push(this.data.array[index + j]); + } + } + + return new BufferAttribute(new this.array.constructor(array), this.itemSize, this.normalized); + } else { + if (data.interleavedBuffers === undefined) { + data.interleavedBuffers = {}; + } + + if (data.interleavedBuffers[this.data.uuid] === undefined) { + data.interleavedBuffers[this.data.uuid] = this.data.clone(data); + } + + return new InterleavedBufferAttribute(data.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); + } + } + + toJSON(data) { + if (data === undefined) { + console.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.'); + + const array = []; + + for (let i = 0; i < this.count; i++) { + const index = i * this.data.stride + this.offset; + + for (let j = 0; j < this.itemSize; j++) { + array.push(this.data.array[index + j]); + } + } + + // deinterleave data and save it as an ordinary buffer attribute for now + + return { + itemSize: this.itemSize, + type: this.array.constructor.name, + array: array, + normalized: this.normalized, + }; + } else { + // save as true interlaved attribtue + + if (data.interleavedBuffers === undefined) { + data.interleavedBuffers = {}; + } + + if (data.interleavedBuffers[this.data.uuid] === undefined) { + data.interleavedBuffers[this.data.uuid] = this.data.toJSON(data); + } + + return { + isInterleavedBufferAttribute: true, + itemSize: this.itemSize, + data: this.data.uuid, + offset: this.offset, + normalized: this.normalized, + }; + } + } +} + +InterleavedBufferAttribute.prototype.isInterleavedBufferAttribute = true; + +export { InterleavedBufferAttribute }; diff --git a/backend/libs/three/core/Layers.d.ts b/backend/libs/three/core/Layers.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a57e676e203742ff652bdab42154d9b3474c8483 --- /dev/null +++ b/backend/libs/three/core/Layers.d.ts @@ -0,0 +1,17 @@ +export class Layers { + constructor(); + + /** + * @default 1 | 0 + */ + mask: number; + + set(channel: number): void; + enable(channel: number): void; + enableAll(): void; + toggle(channel: number): void; + disable(channel: number): void; + disableAll(): void; + test(layers: Layers): boolean; + isEnabled(channel: number): boolean; +} diff --git a/backend/libs/three/core/Layers.js b/backend/libs/three/core/Layers.js new file mode 100644 index 0000000000000000000000000000000000000000..489f0aa9b5edad5b8d70f8e2c2e2a6bc7e5b1ef8 --- /dev/null +++ b/backend/libs/three/core/Layers.js @@ -0,0 +1,39 @@ +class Layers { + constructor() { + this.mask = 1 | 0; + } + + set(channel) { + this.mask = ((1 << channel) | 0) >>> 0; + } + + enable(channel) { + this.mask |= (1 << channel) | 0; + } + + enableAll() { + this.mask = 0xffffffff | 0; + } + + toggle(channel) { + this.mask ^= (1 << channel) | 0; + } + + disable(channel) { + this.mask &= ~((1 << channel) | 0); + } + + disableAll() { + this.mask = 0; + } + + test(layers) { + return (this.mask & layers.mask) !== 0; + } + + isEnabled(channel) { + return (this.mask & ((1 << channel) | 0)) !== 0; + } +} + +export { Layers }; diff --git a/backend/libs/three/core/Object3D.d.ts b/backend/libs/three/core/Object3D.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..2b7dc943107aa6efec20ead37348d25bcd8087d3 --- /dev/null +++ b/backend/libs/three/core/Object3D.d.ts @@ -0,0 +1,394 @@ +import { Vector3 } from './../math/Vector3'; +import { Euler } from './../math/Euler'; +import { Quaternion } from './../math/Quaternion'; +import { Matrix4 } from './../math/Matrix4'; +import { Matrix3 } from './../math/Matrix3'; +import { Layers } from './Layers'; +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Scene } from './../scenes/Scene'; +import { Camera } from './../cameras/Camera'; +import { Material } from './../materials/Material'; +import { Group } from './../objects/Group'; +import { Intersection, Raycaster } from './Raycaster'; +import { EventDispatcher, BaseEvent, Event } from './EventDispatcher'; +import { BufferGeometry } from './BufferGeometry'; +import { AnimationClip } from '../animation/AnimationClip'; + +/** + * Base class for scene graph objects + */ +export class Object3D extends EventDispatcher { + constructor(); + + /** + * Unique number of this object instance. + */ + id: number; + + uuid: string; + + /** + * Optional name of the object (doesn't need to be unique). + * @default '' + */ + name: string; + + /** + * @default 'Object3D' + */ + type: string; + + /** + * Object's parent in the scene graph. + * @default null + */ + parent: Object3D | null; + + /** + * Array with object's children. + * @default [] + */ + children: Object3D[]; + + /** + * Up direction. + * @default THREE.Object3D.DefaultUp.clone() + */ + up: Vector3; + + /** + * Object's local position. + * @default new THREE.Vector3() + */ + readonly position: Vector3; + + /** + * Object's local rotation (Euler angles), in radians. + * @default new THREE.Euler() + */ + readonly rotation: Euler; + + /** + * Object's local rotation as a Quaternion. + * @default new THREE.Quaternion() + */ + readonly quaternion: Quaternion; + + /** + * Object's local scale. + * @default new THREE.Vector3() + */ + readonly scale: Vector3; + + /** + * @default new THREE.Matrix4() + */ + readonly modelViewMatrix: Matrix4; + + /** + * @default new THREE.Matrix3() + */ + readonly normalMatrix: Matrix3; + + /** + * Local transform. + * @default new THREE.Matrix4() + */ + matrix: Matrix4; + + /** + * The global transform of the object. If the Object3d has no parent, then it's identical to the local transform. + * @default new THREE.Matrix4() + */ + matrixWorld: Matrix4; + + /** + * When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also + * recalculates the matrixWorld property. + * @default THREE.Object3D.DefaultMatrixAutoUpdate + */ + matrixAutoUpdate: boolean; + + /** + * When this is set, it calculates the matrixWorld in that frame and resets this property to false. + * @default false + */ + matrixWorldNeedsUpdate: boolean; + + /** + * @default new THREE.Layers() + */ + layers: Layers; + + /** + * Object gets rendered if true. + * @default true + */ + visible: boolean; + + /** + * Gets rendered into shadow map. + * @default false + */ + castShadow: boolean; + + /** + * Material gets baked in shadow receiving. + * @default false + */ + receiveShadow: boolean; + + /** + * When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object. + * If set to false the object gets rendered every frame even if it is not in the frustum of the camera. + * @default true + */ + frustumCulled: boolean; + + /** + * Overrides the default rendering order of scene graph objects, from lowest to highest renderOrder. + * Opaque and transparent objects remain sorted independently though. + * When this property is set for an instance of Group, all descendants objects will be sorted and rendered together. + * @default 0 + */ + renderOrder: number; + + /** + * Array with animation clips. + * @default [] + */ + animations: AnimationClip[]; + + /** + * An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned. + * @default {} + */ + userData: { [key: string]: any }; + + /** + * Custom depth material to be used when rendering to the depth map. Can only be used in context of meshes. + * When shadow-casting with a DirectionalLight or SpotLight, if you are (a) modifying vertex positions in + * the vertex shader, (b) using a displacement map, (c) using an alpha map with alphaTest, or (d) using a + * transparent texture with alphaTest, you must specify a customDepthMaterial for proper shadows. + */ + customDepthMaterial: Material; + + /** + * Same as customDepthMaterial, but used with PointLight. + */ + customDistanceMaterial: Material; + + /** + * Used to check whether this or derived classes are Object3Ds. Default is true. + * You should not change this, as it is used internally for optimisation. + */ + readonly isObject3D: true; + + /** + * Calls before rendering object + */ + onBeforeRender: (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group) => void; + + /** + * Calls after rendering object + */ + onAfterRender: (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group) => void; + + static DefaultUp: Vector3; + static DefaultMatrixAutoUpdate: boolean; + + /** + * Applies the matrix transform to the object and updates the object's position, rotation and scale. + */ + applyMatrix4(matrix: Matrix4): void; + + /** + * Applies the rotation represented by the quaternion to the object. + */ + applyQuaternion(quaternion: Quaternion): this; + + /** + * axis -- A normalized vector in object space. + * angle -- angle in radians + * @param axis A normalized vector in object space. + * @param angle angle in radians + */ + setRotationFromAxisAngle(axis: Vector3, angle: number): void; + + /** + * Calls setRotationFromEuler(euler) on the .quaternion. + * @param euler Euler angle specifying rotation amount. + */ + setRotationFromEuler(euler: Euler): void; + + /** + * Calls setFromRotationMatrix(m) on the .quaternion. + * + * Note that this assumes that the upper 3x3 of m is a pure rotation matrix (i.e, unscaled). + * @param m rotate the quaternion by the rotation component of the matrix. + */ + setRotationFromMatrix(m: Matrix4): void; + + /** + * Copy the given quaternion into .quaternion. + * @param q normalized Quaternion + */ + setRotationFromQuaternion(q: Quaternion): void; + + /** + * Rotate an object along an axis in object space. The axis is assumed to be normalized. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnAxis(axis: Vector3, angle: number): this; + + /** + * Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnWorldAxis(axis: Vector3, angle: number): this; + + /** + * Rotates the object around x axis in local space. + * @param angle the angle to rotate in radians. + */ + rotateX(angle: number): this; + + /** + * Rotates the object around y axis in local space. + * @param angle the angle to rotate in radians. + */ + rotateY(angle: number): this; + + /** + * Rotates the object around z axis in local space. + * @param angle the angle to rotate in radians. + */ + rotateZ(angle: number): this; + + /** + * Translate an object by distance along an axis in object space. The axis is assumed to be normalized. + * @param axis A normalized vector in object space. + * @param distance The distance to translate. + */ + translateOnAxis(axis: Vector3, distance: number): this; + + /** + * Translates object along x axis by distance. + * @param distance Distance. + */ + translateX(distance: number): this; + + /** + * Translates object along y axis by distance. + * @param distance Distance. + */ + translateY(distance: number): this; + + /** + * Translates object along z axis by distance. + * @param distance Distance. + */ + translateZ(distance: number): this; + + /** + * Updates the vector from local space to world space. + * @param vector A local vector. + */ + localToWorld(vector: Vector3): Vector3; + + /** + * Updates the vector from world space to local space. + * @param vector A world vector. + */ + worldToLocal(vector: Vector3): Vector3; + + /** + * Optionally, the x, y and z components of the world space position. + * Rotates the object to face a point in world space. + * This method does not support objects having non-uniformly-scaled parent(s). + * @param vector A world vector to look at. + */ + lookAt(vector: Vector3 | number, y?: number, z?: number): void; + + /** + * Adds object as child of this object. + */ + add(...object: Object3D[]): this; + + /** + * Removes object as child of this object. + */ + remove(...object: Object3D[]): this; + + /** + * Removes this object from its current parent. + */ + removeFromParent(): this; + + /** + * Removes all child objects. + */ + clear(): this; + + /** + * Adds object as a child of this, while maintaining the object's world transform. + */ + attach(object: Object3D): this; + + /** + * Searches through the object's children and returns the first with a matching id. + * @param id Unique number of the object instance + */ + getObjectById(id: number): Object3D | undefined; + + /** + * Searches through the object's children and returns the first with a matching name. + * @param name String to match to the children's Object3d.name property. + */ + getObjectByName(name: string): Object3D | undefined; + + getObjectByProperty(name: string, value: string): Object3D | undefined; + + getWorldPosition(target: Vector3): Vector3; + getWorldQuaternion(target: Quaternion): Quaternion; + getWorldScale(target: Vector3): Vector3; + getWorldDirection(target: Vector3): Vector3; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + + traverse(callback: (object: Object3D) => any): void; + + traverseVisible(callback: (object: Object3D) => any): void; + + traverseAncestors(callback: (object: Object3D) => any): void; + + /** + * Updates local transform. + */ + updateMatrix(): void; + + /** + * Updates global transform of the object and its children. + */ + updateMatrixWorld(force?: boolean): void; + + /** + * Updates the global transform of the object. + * @param updateParents recursively updates global transform of ancestors. + * @param updateChildren recursively updates global transform of descendants. + */ + updateWorldMatrix(updateParents: boolean, updateChildren: boolean): void; + + toJSON(meta?: { geometries: any; materials: any; textures: any; images: any }): any; + + clone(recursive?: boolean): this; + + /** + * + * @param object + * @param recursive + */ + copy(source: this, recursive?: boolean): this; +} diff --git a/backend/libs/three/core/Object3D.js b/backend/libs/three/core/Object3D.js new file mode 100644 index 0000000000000000000000000000000000000000..127fa34e6b74fb4404efbd68219d2ece4c2fdaac --- /dev/null +++ b/backend/libs/three/core/Object3D.js @@ -0,0 +1,717 @@ +import { Quaternion } from '../math/Quaternion.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { EventDispatcher } from './EventDispatcher.js'; +import { Euler } from '../math/Euler.js'; +import { Layers } from './Layers.js'; +import { Matrix3 } from '../math/Matrix3.js'; +import * as MathUtils from '../math/MathUtils.js'; + +let _object3DId = 0; + +const _v1 = /*@__PURE__*/ new Vector3(); +const _q1 = /*@__PURE__*/ new Quaternion(); +const _m1 = /*@__PURE__*/ new Matrix4(); +const _target = /*@__PURE__*/ new Vector3(); + +const _position = /*@__PURE__*/ new Vector3(); +const _scale = /*@__PURE__*/ new Vector3(); +const _quaternion = /*@__PURE__*/ new Quaternion(); + +const _xAxis = /*@__PURE__*/ new Vector3(1, 0, 0); +const _yAxis = /*@__PURE__*/ new Vector3(0, 1, 0); +const _zAxis = /*@__PURE__*/ new Vector3(0, 0, 1); + +const _addedEvent = { type: 'added' }; +const _removedEvent = { type: 'removed' }; + +class Object3D extends EventDispatcher { + constructor() { + super(); + + Object.defineProperty(this, 'id', { value: _object3DId++ }); + + this.uuid = MathUtils.generateUUID(); + + this.name = ''; + this.type = 'Object3D'; + + this.parent = null; + this.children = []; + + this.up = Object3D.DefaultUp.clone(); + + const position = new Vector3(); + const rotation = new Euler(); + const quaternion = new Quaternion(); + const scale = new Vector3(1, 1, 1); + + function onRotationChange() { + quaternion.setFromEuler(rotation, false); + } + + function onQuaternionChange() { + rotation.setFromQuaternion(quaternion, undefined, false); + } + + rotation._onChange(onRotationChange); + quaternion._onChange(onQuaternionChange); + + Object.defineProperties(this, { + position: { + configurable: true, + enumerable: true, + value: position, + }, + rotation: { + configurable: true, + enumerable: true, + value: rotation, + }, + quaternion: { + configurable: true, + enumerable: true, + value: quaternion, + }, + scale: { + configurable: true, + enumerable: true, + value: scale, + }, + modelViewMatrix: { + value: new Matrix4(), + }, + normalMatrix: { + value: new Matrix3(), + }, + }); + + this.matrix = new Matrix4(); + this.matrixWorld = new Matrix4(); + + this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate; + this.matrixWorldNeedsUpdate = false; + + this.layers = new Layers(); + this.visible = true; + + this.castShadow = false; + this.receiveShadow = false; + + this.frustumCulled = true; + this.renderOrder = 0; + + this.animations = []; + + this.userData = {}; + } + + onBeforeRender(/* renderer, scene, camera, geometry, material, group */) {} + + onAfterRender(/* renderer, scene, camera, geometry, material, group */) {} + + applyMatrix4(matrix) { + if (this.matrixAutoUpdate) this.updateMatrix(); + + this.matrix.premultiply(matrix); + + this.matrix.decompose(this.position, this.quaternion, this.scale); + } + + applyQuaternion(q) { + this.quaternion.premultiply(q); + + return this; + } + + setRotationFromAxisAngle(axis, angle) { + // assumes axis is normalized + + this.quaternion.setFromAxisAngle(axis, angle); + } + + setRotationFromEuler(euler) { + this.quaternion.setFromEuler(euler, true); + } + + setRotationFromMatrix(m) { + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + this.quaternion.setFromRotationMatrix(m); + } + + setRotationFromQuaternion(q) { + // assumes q is normalized + + this.quaternion.copy(q); + } + + rotateOnAxis(axis, angle) { + // rotate object on axis in object space + // axis is assumed to be normalized + + _q1.setFromAxisAngle(axis, angle); + + this.quaternion.multiply(_q1); + + return this; + } + + rotateOnWorldAxis(axis, angle) { + // rotate object on axis in world space + // axis is assumed to be normalized + // method assumes no rotated parent + + _q1.setFromAxisAngle(axis, angle); + + this.quaternion.premultiply(_q1); + + return this; + } + + rotateX(angle) { + return this.rotateOnAxis(_xAxis, angle); + } + + rotateY(angle) { + return this.rotateOnAxis(_yAxis, angle); + } + + rotateZ(angle) { + return this.rotateOnAxis(_zAxis, angle); + } + + translateOnAxis(axis, distance) { + // translate object by distance along axis in object space + // axis is assumed to be normalized + + _v1.copy(axis).applyQuaternion(this.quaternion); + + this.position.add(_v1.multiplyScalar(distance)); + + return this; + } + + translateX(distance) { + return this.translateOnAxis(_xAxis, distance); + } + + translateY(distance) { + return this.translateOnAxis(_yAxis, distance); + } + + translateZ(distance) { + return this.translateOnAxis(_zAxis, distance); + } + + localToWorld(vector) { + return vector.applyMatrix4(this.matrixWorld); + } + + worldToLocal(vector) { + return vector.applyMatrix4(_m1.copy(this.matrixWorld).invert()); + } + + lookAt(x, y, z) { + // This method does not support objects having non-uniformly-scaled parent(s) + + if (x.isVector3) { + _target.copy(x); + } else { + _target.set(x, y, z); + } + + const parent = this.parent; + + this.updateWorldMatrix(true, false); + + _position.setFromMatrixPosition(this.matrixWorld); + + if (this.isCamera || this.isLight) { + _m1.lookAt(_position, _target, this.up); + } else { + _m1.lookAt(_target, _position, this.up); + } + + this.quaternion.setFromRotationMatrix(_m1); + + if (parent) { + _m1.extractRotation(parent.matrixWorld); + _q1.setFromRotationMatrix(_m1); + this.quaternion.premultiply(_q1.invert()); + } + } + + add(object) { + if (arguments.length > 1) { + for (let i = 0; i < arguments.length; i++) { + this.add(arguments[i]); + } + + return this; + } + + if (object === this) { + console.error("THREE.Object3D.add: object can't be added as a child of itself.", object); + return this; + } + + if (object && object.isObject3D) { + if (object.parent !== null) { + object.parent.remove(object); + } + + object.parent = this; + this.children.push(object); + + object.dispatchEvent(_addedEvent); + } else { + console.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', object); + } + + return this; + } + + remove(object) { + if (arguments.length > 1) { + for (let i = 0; i < arguments.length; i++) { + this.remove(arguments[i]); + } + + return this; + } + + const index = this.children.indexOf(object); + + if (index !== -1) { + object.parent = null; + this.children.splice(index, 1); + + object.dispatchEvent(_removedEvent); + } + + return this; + } + + removeFromParent() { + const parent = this.parent; + + if (parent !== null) { + parent.remove(this); + } + + return this; + } + + clear() { + for (let i = 0; i < this.children.length; i++) { + const object = this.children[i]; + + object.parent = null; + + object.dispatchEvent(_removedEvent); + } + + this.children.length = 0; + + return this; + } + + attach(object) { + // adds object as a child of this, while maintaining the object's world transform + + // Note: This method does not support scene graphs having non-uniformly-scaled nodes(s) + + this.updateWorldMatrix(true, false); + + _m1.copy(this.matrixWorld).invert(); + + if (object.parent !== null) { + object.parent.updateWorldMatrix(true, false); + + _m1.multiply(object.parent.matrixWorld); + } + + object.applyMatrix4(_m1); + + this.add(object); + + object.updateWorldMatrix(false, true); + + return this; + } + + getObjectById(id) { + return this.getObjectByProperty('id', id); + } + + getObjectByName(name) { + return this.getObjectByProperty('name', name); + } + + getObjectByProperty(name, value) { + if (this[name] === value) return this; + + for (let i = 0, l = this.children.length; i < l; i++) { + const child = this.children[i]; + const object = child.getObjectByProperty(name, value); + + if (object !== undefined) { + return object; + } + } + + return undefined; + } + + getWorldPosition(target) { + this.updateWorldMatrix(true, false); + + return target.setFromMatrixPosition(this.matrixWorld); + } + + getWorldQuaternion(target) { + this.updateWorldMatrix(true, false); + + this.matrixWorld.decompose(_position, target, _scale); + + return target; + } + + getWorldScale(target) { + this.updateWorldMatrix(true, false); + + this.matrixWorld.decompose(_position, _quaternion, target); + + return target; + } + + getWorldDirection(target) { + this.updateWorldMatrix(true, false); + + const e = this.matrixWorld.elements; + + return target.set(e[8], e[9], e[10]).normalize(); + } + + raycast(/* raycaster, intersects */) {} + + traverse(callback) { + callback(this); + + const children = this.children; + + for (let i = 0, l = children.length; i < l; i++) { + children[i].traverse(callback); + } + } + + traverseVisible(callback) { + if (this.visible === false) return; + + callback(this); + + const children = this.children; + + for (let i = 0, l = children.length; i < l; i++) { + children[i].traverseVisible(callback); + } + } + + traverseAncestors(callback) { + const parent = this.parent; + + if (parent !== null) { + callback(parent); + + parent.traverseAncestors(callback); + } + } + + updateMatrix() { + this.matrix.compose(this.position, this.quaternion, this.scale); + + this.matrixWorldNeedsUpdate = true; + } + + updateMatrixWorld(force) { + if (this.matrixAutoUpdate) this.updateMatrix(); + + if (this.matrixWorldNeedsUpdate || force) { + if (this.parent === null) { + this.matrixWorld.copy(this.matrix); + } else { + this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); + } + + this.matrixWorldNeedsUpdate = false; + + force = true; + } + + // update children + + const children = this.children; + + for (let i = 0, l = children.length; i < l; i++) { + children[i].updateMatrixWorld(force); + } + } + + updateWorldMatrix(updateParents, updateChildren) { + const parent = this.parent; + + if (updateParents === true && parent !== null) { + parent.updateWorldMatrix(true, false); + } + + if (this.matrixAutoUpdate) this.updateMatrix(); + + if (this.parent === null) { + this.matrixWorld.copy(this.matrix); + } else { + this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix); + } + + // update children + + if (updateChildren === true) { + const children = this.children; + + for (let i = 0, l = children.length; i < l; i++) { + children[i].updateWorldMatrix(false, true); + } + } + } + + toJSON(meta) { + // meta is a string when called from JSON.stringify + const isRootObject = meta === undefined || typeof meta === 'string'; + + const output = {}; + + // meta is a hash used to collect geometries, materials. + // not providing it implies that this is the root object + // being serialized. + if (isRootObject) { + // initialize meta obj + meta = { + geometries: {}, + materials: {}, + textures: {}, + images: {}, + shapes: {}, + skeletons: {}, + animations: {}, + }; + + output.metadata = { + version: 4.5, + type: 'Object', + generator: 'Object3D.toJSON', + }; + } + + // standard Object3D serialization + + const object = {}; + + object.uuid = this.uuid; + object.type = this.type; + + if (this.name !== '') object.name = this.name; + if (this.castShadow === true) object.castShadow = true; + if (this.receiveShadow === true) object.receiveShadow = true; + if (this.visible === false) object.visible = false; + if (this.frustumCulled === false) object.frustumCulled = false; + if (this.renderOrder !== 0) object.renderOrder = this.renderOrder; + if (JSON.stringify(this.userData) !== '{}') object.userData = this.userData; + + object.layers = this.layers.mask; + object.matrix = this.matrix.toArray(); + + if (this.matrixAutoUpdate === false) object.matrixAutoUpdate = false; + + // object specific properties + + if (this.isInstancedMesh) { + object.type = 'InstancedMesh'; + object.count = this.count; + object.instanceMatrix = this.instanceMatrix.toJSON(); + if (this.instanceColor !== null) object.instanceColor = this.instanceColor.toJSON(); + } + + // + + function serialize(library, element) { + if (library[element.uuid] === undefined) { + library[element.uuid] = element.toJSON(meta); + } + + return element.uuid; + } + + if (this.isScene) { + if (this.background) { + if (this.background.isColor) { + object.background = this.background.toJSON(); + } else if (this.background.isTexture) { + object.background = this.background.toJSON(meta).uuid; + } + } + + if (this.environment && this.environment.isTexture) { + object.environment = this.environment.toJSON(meta).uuid; + } + } else if (this.isMesh || this.isLine || this.isPoints) { + object.geometry = serialize(meta.geometries, this.geometry); + + const parameters = this.geometry.parameters; + + if (parameters !== undefined && parameters.shapes !== undefined) { + const shapes = parameters.shapes; + + if (Array.isArray(shapes)) { + for (let i = 0, l = shapes.length; i < l; i++) { + const shape = shapes[i]; + + serialize(meta.shapes, shape); + } + } else { + serialize(meta.shapes, shapes); + } + } + } + + if (this.isSkinnedMesh) { + object.bindMode = this.bindMode; + object.bindMatrix = this.bindMatrix.toArray(); + + if (this.skeleton !== undefined) { + serialize(meta.skeletons, this.skeleton); + + object.skeleton = this.skeleton.uuid; + } + } + + if (this.material !== undefined) { + if (Array.isArray(this.material)) { + const uuids = []; + + for (let i = 0, l = this.material.length; i < l; i++) { + uuids.push(serialize(meta.materials, this.material[i])); + } + + object.material = uuids; + } else { + object.material = serialize(meta.materials, this.material); + } + } + + // + + if (this.children.length > 0) { + object.children = []; + + for (let i = 0; i < this.children.length; i++) { + object.children.push(this.children[i].toJSON(meta).object); + } + } + + // + + if (this.animations.length > 0) { + object.animations = []; + + for (let i = 0; i < this.animations.length; i++) { + const animation = this.animations[i]; + + object.animations.push(serialize(meta.animations, animation)); + } + } + + if (isRootObject) { + const geometries = extractFromCache(meta.geometries); + const materials = extractFromCache(meta.materials); + const textures = extractFromCache(meta.textures); + const images = extractFromCache(meta.images); + const shapes = extractFromCache(meta.shapes); + const skeletons = extractFromCache(meta.skeletons); + const animations = extractFromCache(meta.animations); + + if (geometries.length > 0) output.geometries = geometries; + if (materials.length > 0) output.materials = materials; + if (textures.length > 0) output.textures = textures; + if (images.length > 0) output.images = images; + if (shapes.length > 0) output.shapes = shapes; + if (skeletons.length > 0) output.skeletons = skeletons; + if (animations.length > 0) output.animations = animations; + } + + output.object = object; + + return output; + + // extract data from the cache hash + // remove metadata on each item + // and return as array + function extractFromCache(cache) { + const values = []; + for (const key in cache) { + const data = cache[key]; + delete data.metadata; + values.push(data); + } + + return values; + } + } + + clone(recursive) { + return new this.constructor().copy(this, recursive); + } + + copy(source, recursive = true) { + this.name = source.name; + + this.up.copy(source.up); + + this.position.copy(source.position); + this.rotation.order = source.rotation.order; + this.quaternion.copy(source.quaternion); + this.scale.copy(source.scale); + + this.matrix.copy(source.matrix); + this.matrixWorld.copy(source.matrixWorld); + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate; + + this.layers.mask = source.layers.mask; + this.visible = source.visible; + + this.castShadow = source.castShadow; + this.receiveShadow = source.receiveShadow; + + this.frustumCulled = source.frustumCulled; + this.renderOrder = source.renderOrder; + + this.userData = JSON.parse(JSON.stringify(source.userData)); + + if (recursive === true) { + for (let i = 0; i < source.children.length; i++) { + const child = source.children[i]; + this.add(child.clone()); + } + } + + return this; + } +} + +Object3D.DefaultUp = new Vector3(0, 1, 0); +Object3D.DefaultMatrixAutoUpdate = true; + +Object3D.prototype.isObject3D = true; + +export { Object3D }; diff --git a/backend/libs/three/core/Raycaster.d.ts b/backend/libs/three/core/Raycaster.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fdc73634cc12d19a7b54900762896425780fc0c6 --- /dev/null +++ b/backend/libs/three/core/Raycaster.d.ts @@ -0,0 +1,120 @@ +import { Vector3 } from './../math/Vector3'; +import { Object3D } from './Object3D'; +import { Vector2 } from './../math/Vector2'; +import { Ray } from './../math/Ray'; +import { Camera } from './../cameras/Camera'; +import { Layers } from './Layers'; + +export interface Face { + a: number; + b: number; + c: number; + normal: Vector3; + materialIndex: number; +} + +export interface Intersection { + distance: number; + distanceToRay?: number | undefined; + point: Vector3; + index?: number | undefined; + face?: Face | null | undefined; + faceIndex?: number | undefined; + object: TIntersected; + uv?: Vector2 | undefined; + uv2?: Vector2 | undefined; + instanceId?: number | undefined; +} + +export interface RaycasterParameters { + Mesh?: any; + Line?: { threshold: number } | undefined; + LOD?: any; + Points?: { threshold: number } | undefined; + Sprite?: any; +} + +export class Raycaster { + /** + * This creates a new raycaster object. + * @param origin The origin vector where the ray casts from. + * @param direction The direction vector that gives direction to the ray. Should be normalized. + * @param near All results returned are further away than near. Near can't be negative. Default value is 0. + * @param far All results returned are closer then far. Far can't be lower then near . Default value is Infinity. + */ + constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number); + + /** The Ray used for the raycasting. */ + ray: Ray; + + /** + * The near factor of the raycaster. This value indicates which objects can be discarded based on the + * distance. This value shouldn't be negative and should be smaller than the far property. + * @default 0 + */ + near: number; + + /** + * The far factor of the raycaster. This value indicates which objects can be discarded based on the + * distance. This value shouldn't be negative and should be larger than the near property. + * @default Infinity + */ + far: number; + + /** + * The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field + * can be set manually or is set when calling "setFromCamera". + */ + camera: Camera; + + /** + * Used by Raycaster to selectively ignore 3D objects when performing intersection tests. + * @default new THREE.Layers() + */ + layers: Layers; + + /** + * @default { Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} } + */ + params: RaycasterParameters; + + /** + * Updates the ray with a new origin and direction. + * @param origin The origin vector where the ray casts from. + * @param direction The normalized direction vector that gives direction to the ray. + */ + set(origin: Vector3, direction: Vector3): void; + + /** + * Updates the ray with a new origin and direction. + * @param coords 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1. + * @param camera camera from which the ray should originate + */ + setFromCamera(coords: { x: number; y: number }, camera: Camera): void; + + /** + * Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. + * @param object The object to check for intersection with the ray. + * @param recursive If true, it also checks all descendants. Otherwise it only checks intersecton with the object. Default is true. + * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;). + */ + intersectObject( + object: Object3D, + recursive?: boolean, + optionalTarget?: Array> + ): Array>; + + /** + * Checks all intersection between the ray and the objects with or without the descendants. + * Intersections are returned sorted by distance, closest first. + * Intersections are of the same form as those returned by .intersectObject. + * @param objects The objects to check for intersection with the ray. + * @param recursive If true, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects. Default is true. + * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;). + */ + intersectObjects( + objects: Object3D[], + recursive?: boolean, + optionalTarget?: Array> + ): Array>; +} diff --git a/backend/libs/three/core/Raycaster.js b/backend/libs/three/core/Raycaster.js new file mode 100644 index 0000000000000000000000000000000000000000..bc328193804d7f447dbf83dd67e282ad40dc7dd9 --- /dev/null +++ b/backend/libs/three/core/Raycaster.js @@ -0,0 +1,80 @@ +import { Ray } from '../math/Ray.js'; +import { Layers } from './Layers.js'; + +class Raycaster { + constructor(origin, direction, near = 0, far = Infinity) { + this.ray = new Ray(origin, direction); + // direction is assumed to be normalized (for accurate distance calculations) + + this.near = near; + this.far = far; + this.camera = null; + this.layers = new Layers(); + + this.params = { + Mesh: {}, + Line: { threshold: 1 }, + LOD: {}, + Points: { threshold: 1 }, + Sprite: {}, + }; + } + + set(origin, direction) { + // direction is assumed to be normalized (for accurate distance calculations) + + this.ray.set(origin, direction); + } + + setFromCamera(coords, camera) { + if (camera && camera.isPerspectiveCamera) { + this.ray.origin.setFromMatrixPosition(camera.matrixWorld); + this.ray.direction.set(coords.x, coords.y, 0.5).unproject(camera).sub(this.ray.origin).normalize(); + this.camera = camera; + } else if (camera && camera.isOrthographicCamera) { + this.ray.origin.set(coords.x, coords.y, (camera.near + camera.far) / (camera.near - camera.far)).unproject(camera); // set origin in plane of camera + this.ray.direction.set(0, 0, -1).transformDirection(camera.matrixWorld); + this.camera = camera; + } else { + console.error('THREE.Raycaster: Unsupported camera type: ' + camera.type); + } + } + + intersectObject(object, recursive = true, intersects = []) { + intersectObject(object, this, intersects, recursive); + + intersects.sort(ascSort); + + return intersects; + } + + intersectObjects(objects, recursive = true, intersects = []) { + for (let i = 0, l = objects.length; i < l; i++) { + intersectObject(objects[i], this, intersects, recursive); + } + + intersects.sort(ascSort); + + return intersects; + } +} + +function ascSort(a, b) { + return a.distance - b.distance; +} + +function intersectObject(object, raycaster, intersects, recursive) { + if (object.layers.test(raycaster.layers)) { + object.raycast(raycaster, intersects); + } + + if (recursive === true) { + const children = object.children; + + for (let i = 0, l = children.length; i < l; i++) { + intersectObject(children[i], raycaster, intersects, true); + } + } +} + +export { Raycaster }; diff --git a/backend/libs/three/core/Uniform.d.ts b/backend/libs/three/core/Uniform.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f9d293a173f8ac5f82f8b6f0880c3ccc1f7b786d --- /dev/null +++ b/backend/libs/three/core/Uniform.d.ts @@ -0,0 +1,21 @@ +export class Uniform { + constructor(value: any); + /** + * @deprecated + */ + constructor(type: string, value: any); + /** + * @deprecated + */ + type: string; + value: any; + /** + * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead. + */ + dynamic: boolean; + + /** + * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead. + */ + onUpdate(callback: () => void): Uniform; +} diff --git a/backend/libs/three/core/Uniform.js b/backend/libs/three/core/Uniform.js new file mode 100644 index 0000000000000000000000000000000000000000..f3b57f30ab3c5be2dd68ff26cc468405542b151c --- /dev/null +++ b/backend/libs/three/core/Uniform.js @@ -0,0 +1,16 @@ +class Uniform { + constructor(value) { + if (typeof value === 'string') { + console.warn('THREE.Uniform: Type parameter is no longer needed.'); + value = arguments[1]; + } + + this.value = value; + } + + clone() { + return new Uniform(this.value.clone === undefined ? this.value : this.value.clone()); + } +} + +export { Uniform }; diff --git a/backend/libs/three/extras/DataUtils.d.ts b/backend/libs/three/extras/DataUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a77f8b988ca8ad5cf47a700ba7ea71329e46e980 --- /dev/null +++ b/backend/libs/three/extras/DataUtils.d.ts @@ -0,0 +1,4 @@ +export namespace DataUtils { + function toHalfFloat(val: number): number; + function fromHalfFloat(val: number): number; +} diff --git a/backend/libs/three/extras/DataUtils.js b/backend/libs/three/extras/DataUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..c2bd4b480e68c2bcb85edb2d5735ae9b41e858b8 --- /dev/null +++ b/backend/libs/three/extras/DataUtils.js @@ -0,0 +1,57 @@ +const _floatView = new Float32Array(1); +const _int32View = new Int32Array(_floatView.buffer); + +class DataUtils { + // Converts float32 to float16 (stored as uint16 value). + + static toHalfFloat(val) { + if (val > 65504) { + console.warn('THREE.DataUtils.toHalfFloat(): value exceeds 65504.'); + + val = 65504; // maximum representable value in float16 + } + + // Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410 + + /* This method is faster than the OpenEXR implementation (very often + * used, eg. in Ogre), with the additional benefit of rounding, inspired + * by James Tursa?s half-precision code. */ + + _floatView[0] = val; + const x = _int32View[0]; + + let bits = (x >> 16) & 0x8000; /* Get the sign */ + let m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */ + const e = (x >> 23) & 0xff; /* Using int is faster here */ + + /* If zero, or denormal, or exponent underflows too much for a denormal + * half, return signed zero. */ + if (e < 103) return bits; + + /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */ + if (e > 142) { + bits |= 0x7c00; + /* If exponent was 0xff and one mantissa bit was set, it means NaN, + * not Inf, so make sure we set one mantissa bit too. */ + bits |= (e == 255 ? 0 : 1) && x & 0x007fffff; + return bits; + } + + /* If exponent underflows but not too much, return a denormal */ + if (e < 113) { + m |= 0x0800; + /* Extra rounding may overflow and set mantissa to 0 and exponent + * to 1, which is OK. */ + bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1); + return bits; + } + + bits |= ((e - 112) << 10) | (m >> 1); + /* Extra rounding. An overflow will set mantissa to 0 and increment + * the exponent, which is OK. */ + bits += m & 1; + return bits; + } +} + +export { DataUtils }; diff --git a/backend/libs/three/extras/Earcut.js b/backend/libs/three/extras/Earcut.js new file mode 100644 index 0000000000000000000000000000000000000000..714784a579d3a0a4d0e62517c4b6fb585340780b --- /dev/null +++ b/backend/libs/three/extras/Earcut.js @@ -0,0 +1,634 @@ +/** + * Port from https://github.com/mapbox/earcut (v2.2.2) + */ + +const Earcut = { + triangulate: function (data, holeIndices, dim = 2) { + const hasHoles = holeIndices && holeIndices.length; + const outerLen = hasHoles ? holeIndices[0] * dim : data.length; + let outerNode = linkedList(data, 0, outerLen, dim, true); + const triangles = []; + + if (!outerNode || outerNode.next === outerNode.prev) return triangles; + + let minX, minY, maxX, maxY, x, y, invSize; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (let i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max(maxX - minX, maxY - minY); + invSize = invSize !== 0 ? 1 / invSize : 0; + } + + earcutLinked(outerNode, triangles, dim, minX, minY, invSize); + + return triangles; + }, +}; + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + let i, last; + + if (clockwise === signedArea(data, start, end, dim) > 0) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + let p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) break; + again = true; + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && invSize) indexCurve(ear, minX, minY, invSize); + + let stop = ear, + prev, + next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertex leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(filterPoints(ear), triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, invSize); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + const a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + let p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, invSize) { + const a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + const minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : b.x < c.x ? b.x : c.x, + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : b.y < c.y ? b.y : c.y, + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : b.x > c.x ? b.x : c.x, + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : b.y > c.y ? b.y : c.y; + + // z-order range for the current triangle bbox; + const minZ = zOrder(minTX, minTY, minX, minY, invSize), + maxZ = zOrder(maxTX, maxTY, minX, minY, invSize); + + let p = ear.prevZ, + n = ear.nextZ; + + // look for points inside the triangle in both directions + while (p && p.z >= minZ && n && n.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + + if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + // look for remaining points in decreasing z-order + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + // look for remaining points in increasing z-order + while (n && n.z <= maxZ) { + if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + let p = start; + do { + const a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + + p = p.next; + } while (p !== start); + + return filterPoints(p); +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, invSize) { + // look for a valid diagonal that divides the polygon into two + let a = start; + do { + let b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + let c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, invSize); + earcutLinked(c, triangles, dim, minX, minY, invSize); + return; + } + + b = b.next; + } + + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + const queue = []; + let i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + const b = splitPolygon(outerNode, hole); + + // filter collinear points around the cuts + filterPoints(outerNode, outerNode.next); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + let p = outerNode; + const hx = hole.x; + const hy = hole.y; + let qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + const x = p.x + ((hy - p.y) * (p.next.x - p.x)) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + + m = p.x < p.next.x ? p : p.next; + } + } + + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m; // hole touches outer segment; pick leftmost endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + const stop = m, + mx = m.x, + my = m.y; + let tanMin = Infinity, + tan; + + p = m; + + do { + if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if (locallyInside(p, hole) && (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } while (p !== stop); + + return m; +} + +// whether sector in vertex m contains sector in vertex p in the same coordinates +function sectorContainsSector(m, p) { + return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, invSize) { + let p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + let i, + p, + q, + e, + tail, + numMerges, + pSize, + qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and inverse of the longer side of data bbox +function zOrder(x, y, minX, minY, invSize) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) * invSize; + y = 32767 * (y - minY) * invSize; + + x = (x | (x << 8)) & 0x00ff00ff; + x = (x | (x << 4)) & 0x0f0f0f0f; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00ff00ff; + y = (y | (y << 4)) & 0x0f0f0f0f; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + let p = start, + leftmost = start; + do { + if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return ( + (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0 + ); +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return ( + a.next.i !== b.i && + a.prev.i !== b.i && + !intersectsPolygon(a, b) && // dones't intersect other edges + ((locallyInside(a, b) && + locallyInside(b, a) && + middleInside(a, b) && // locally visible + (area(a.prev, a, b.prev) || area(a, b.prev, b))) || // does not create opposite-facing sectors + (equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0)) + ); // special zero-length case +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + const o1 = sign(area(p1, q1, p2)); + const o2 = sign(area(p1, q1, q2)); + const o3 = sign(area(p2, q2, p1)); + const o4 = sign(area(p2, q2, q1)); + + if (o1 !== o2 && o3 !== o4) return true; // general case + + if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; +} + +// for collinear points p, q, r, check if point q lies on segment pr +function onSegment(p, q, r) { + return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y); +} + +function sign(num) { + return num > 0 ? 1 : num < 0 ? -1 : 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + let p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + let p = a, + inside = false; + const px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < ((p.next.x - p.x) * (py - p.y)) / (p.next.y - p.y) + p.x) inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + const a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + const p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertex index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertex nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +function signedArea(data, start, end, dim) { + let sum = 0; + for (let i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + + return sum; +} + +export { Earcut }; diff --git a/backend/libs/three/extras/ImageUtils.d.ts b/backend/libs/three/extras/ImageUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..daab58a4cc2fbca3bb0f60fb85e4fed8cd17f52a --- /dev/null +++ b/backend/libs/three/extras/ImageUtils.d.ts @@ -0,0 +1,23 @@ +import { Mapping } from '../constants'; +import { Texture } from '../textures/Texture'; + +export namespace ImageUtils { + function getDataURL(image: any): string; + + /** + * @deprecated + */ + let crossOrigin: string; + + /** + * @deprecated Use {@link TextureLoader THREE.TextureLoader()} instead. + */ + function loadTexture(url: string, mapping?: Mapping, onLoad?: (texture: Texture) => void, onError?: (message: string) => void): Texture; + + /** + * @deprecated Use {@link CubeTextureLoader THREE.CubeTextureLoader()} instead. + */ + function loadTextureCube(array: string[], mapping?: Mapping, onLoad?: (texture: Texture) => void, onError?: (message: string) => void): Texture; + + function sRGBToLinear(image: any): HTMLCanvasElement | { data: number[]; width: number; height: number }; +} diff --git a/backend/libs/three/extras/ImageUtils.js b/backend/libs/three/extras/ImageUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..b4285acef218d669a3f3c5151a709b2677eb46d3 --- /dev/null +++ b/backend/libs/three/extras/ImageUtils.js @@ -0,0 +1,95 @@ +import { createElementNS } from '../utils.js'; +import { SRGBToLinear } from '../math/Color.js'; + +let _canvas; + +class ImageUtils { + static getDataURL(image) { + if (/^data:/i.test(image.src)) { + return image.src; + } + + if (typeof HTMLCanvasElement == 'undefined') { + return image.src; + } + + let canvas; + + if (image instanceof HTMLCanvasElement) { + canvas = image; + } else { + if (_canvas === undefined) _canvas = createElementNS('canvas'); + + _canvas.width = image.width; + _canvas.height = image.height; + + const context = _canvas.getContext('2d'); + + if (image instanceof ImageData) { + context.putImageData(image, 0, 0); + } else { + context.drawImage(image, 0, 0, image.width, image.height); + } + + canvas = _canvas; + } + + if (canvas.width > 2048 || canvas.height > 2048) { + console.warn('THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons', image); + + return canvas.toDataURL('image/jpeg', 0.6); + } else { + return canvas.toDataURL('image/png'); + } + } + + static sRGBToLinear(image) { + if ( + (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) || + (typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement) || + (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) + ) { + const canvas = createElementNS('canvas'); + + canvas.width = image.width; + canvas.height = image.height; + + const context = canvas.getContext('2d'); + context.drawImage(image, 0, 0, image.width, image.height); + + const imageData = context.getImageData(0, 0, image.width, image.height); + const data = imageData.data; + + for (let i = 0; i < data.length; i++) { + data[i] = SRGBToLinear(data[i] / 255) * 255; + } + + context.putImageData(imageData, 0, 0); + + return canvas; + } else if (image.data) { + const data = image.data.slice(0); + + for (let i = 0; i < data.length; i++) { + if (data instanceof Uint8Array || data instanceof Uint8ClampedArray) { + data[i] = Math.floor(SRGBToLinear(data[i] / 255) * 255); + } else { + // assuming float + + data[i] = SRGBToLinear(data[i]); + } + } + + return { + data: data, + width: image.width, + height: image.height, + }; + } else { + console.warn('THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.'); + return image; + } + } +} + +export { ImageUtils }; diff --git a/backend/libs/three/extras/PMREMGenerator.d.ts b/backend/libs/three/extras/PMREMGenerator.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c87c0c4070ccc5eb978df8e08f150885297d224d --- /dev/null +++ b/backend/libs/three/extras/PMREMGenerator.d.ts @@ -0,0 +1,15 @@ +import { WebGLRenderer } from '../renderers/WebGLRenderer'; +import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget'; +import { Texture } from '../textures/Texture'; +import { CubeTexture } from '../textures/CubeTexture'; +import { Scene } from '../scenes/Scene'; + +export class PMREMGenerator { + constructor(renderer: WebGLRenderer); + fromScene(scene: Scene, sigma?: number, near?: number, far?: number): WebGLRenderTarget; + fromEquirectangular(equirectangular: Texture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget; + fromCubemap(cubemap: CubeTexture, renderTarget?: WebGLRenderTarget | null): WebGLRenderTarget; + compileCubemapShader(): void; + compileEquirectangularShader(): void; + dispose(): void; +} diff --git a/backend/libs/three/extras/PMREMGenerator.js b/backend/libs/three/extras/PMREMGenerator.js new file mode 100644 index 0000000000000000000000000000000000000000..51acce67d826c3ad17a1a3c3710fc23bc48ff88e --- /dev/null +++ b/backend/libs/three/extras/PMREMGenerator.js @@ -0,0 +1,736 @@ +import { + CubeReflectionMapping, + CubeRefractionMapping, + CubeUVReflectionMapping, + LinearEncoding, + LinearFilter, + NoToneMapping, + NoBlending, + RGBAFormat, + HalfFloatType, +} from '../constants.js'; + +import { BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Mesh } from '../objects/Mesh.js'; +import { OrthographicCamera } from '../cameras/OrthographicCamera.js'; +import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; +import { RawShaderMaterial } from '../materials/RawShaderMaterial.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Color } from '../math/Color.js'; +import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { BoxGeometry } from '../geometries/BoxGeometry.js'; +import { BackSide } from '../constants.js'; + +const LOD_MIN = 4; +const LOD_MAX = 8; +const SIZE_MAX = Math.pow(2, LOD_MAX); + +// The standard deviations (radians) associated with the extra mips. These are +// chosen to approximate a Trowbridge-Reitz distribution function times the +// geometric shadowing function. These sigma values squared must match the +// variance #defines in cube_uv_reflection_fragment.glsl.js. +const EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582]; + +const TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; + +// The maximum length of the blur for loop. Smaller sigmas will use fewer +// samples and exit early, but not recompile the shader. +const MAX_SAMPLES = 20; + +const _flatCamera = /*@__PURE__*/ new OrthographicCamera(); +const { _lodPlanes, _sizeLods, _sigmas } = /*@__PURE__*/ _createPlanes(); +const _clearColor = /*@__PURE__*/ new Color(); +let _oldTarget = null; + +// Golden Ratio +const PHI = (1 + Math.sqrt(5)) / 2; +const INV_PHI = 1 / PHI; + +// Vertices of a dodecahedron (except the opposites, which represent the +// same axis), used as axis directions evenly spread on a sphere. +const _axisDirections = [ + /*@__PURE__*/ new Vector3(1, 1, 1), + /*@__PURE__*/ new Vector3(-1, 1, 1), + /*@__PURE__*/ new Vector3(1, 1, -1), + /*@__PURE__*/ new Vector3(-1, 1, -1), + /*@__PURE__*/ new Vector3(0, PHI, INV_PHI), + /*@__PURE__*/ new Vector3(0, PHI, -INV_PHI), + /*@__PURE__*/ new Vector3(INV_PHI, 0, PHI), + /*@__PURE__*/ new Vector3(-INV_PHI, 0, PHI), + /*@__PURE__*/ new Vector3(PHI, INV_PHI, 0), + /*@__PURE__*/ new Vector3(-PHI, INV_PHI, 0), +]; + +/** + * This class generates a Prefiltered, Mipmapped Radiance Environment Map + * (PMREM) from a cubeMap environment texture. This allows different levels of + * blur to be quickly accessed based on material roughness. It is packed into a + * special CubeUV format that allows us to perform custom interpolation so that + * we can support nonlinear formats such as RGBE. Unlike a traditional mipmap + * chain, it only goes down to the LOD_MIN level (above), and then creates extra + * even more filtered 'mips' at the same LOD_MIN resolution, associated with + * higher roughness levels. In this way we maintain resolution to smoothly + * interpolate diffuse lighting while limiting sampling computation. + * + * Paper: Fast, Accurate Image-Based Lighting + * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view + */ + +class PMREMGenerator { + constructor(renderer) { + this._renderer = renderer; + this._pingPongRenderTarget = null; + + this._blurMaterial = _getBlurShader(MAX_SAMPLES); + this._equirectShader = null; + this._cubemapShader = null; + + this._compileMaterial(this._blurMaterial); + } + + /** + * Generates a PMREM from a supplied Scene, which can be faster than using an + * image if networking bandwidth is low. Optional sigma specifies a blur radius + * in radians to be applied to the scene before PMREM generation. Optional near + * and far planes ensure the scene is rendered in its entirety (the cubeCamera + * is placed at the origin). + */ + fromScene(scene, sigma = 0, near = 0.1, far = 100) { + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = this._allocateTargets(); + + this._sceneToCubeUV(scene, near, far, cubeUVRenderTarget); + if (sigma > 0) { + this._blur(cubeUVRenderTarget, 0, 0, sigma); + } + + this._applyPMREM(cubeUVRenderTarget); + this._cleanup(cubeUVRenderTarget); + + return cubeUVRenderTarget; + } + + /** + * Generates a PMREM from an equirectangular texture, which can be either LDR + * or HDR. The ideal input image size is 1k (1024 x 512), + * as this matches best with the 256 x 256 cubemap output. + */ + fromEquirectangular(equirectangular, renderTarget = null) { + return this._fromTexture(equirectangular, renderTarget); + } + + /** + * Generates a PMREM from an cubemap texture, which can be either LDR + * or HDR. The ideal input cube size is 256 x 256, + * as this matches best with the 256 x 256 cubemap output. + */ + fromCubemap(cubemap, renderTarget = null) { + return this._fromTexture(cubemap, renderTarget); + } + + /** + * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileCubemapShader() { + if (this._cubemapShader === null) { + this._cubemapShader = _getCubemapShader(); + this._compileMaterial(this._cubemapShader); + } + } + + /** + * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during + * your texture's network fetch for increased concurrency. + */ + compileEquirectangularShader() { + if (this._equirectShader === null) { + this._equirectShader = _getEquirectShader(); + this._compileMaterial(this._equirectShader); + } + } + + /** + * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, + * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on + * one of them will cause any others to also become unusable. + */ + dispose() { + this._blurMaterial.dispose(); + + if (this._pingPongRenderTarget !== null) this._pingPongRenderTarget.dispose(); + + if (this._cubemapShader !== null) this._cubemapShader.dispose(); + if (this._equirectShader !== null) this._equirectShader.dispose(); + + for (let i = 0; i < _lodPlanes.length; i++) { + _lodPlanes[i].dispose(); + } + } + + // private interface + + _cleanup(outputTarget) { + this._renderer.setRenderTarget(_oldTarget); + outputTarget.scissorTest = false; + _setViewport(outputTarget, 0, 0, outputTarget.width, outputTarget.height); + } + + _fromTexture(texture, renderTarget) { + _oldTarget = this._renderer.getRenderTarget(); + const cubeUVRenderTarget = renderTarget || this._allocateTargets(texture); + this._textureToCubeUV(texture, cubeUVRenderTarget); + this._applyPMREM(cubeUVRenderTarget); + this._cleanup(cubeUVRenderTarget); + + return cubeUVRenderTarget; + } + + _allocateTargets(texture) { + // warning: null texture is valid + + const params = { + magFilter: LinearFilter, + minFilter: LinearFilter, + generateMipmaps: false, + type: HalfFloatType, + format: RGBAFormat, + encoding: LinearEncoding, + depthBuffer: false, + }; + + const cubeUVRenderTarget = _createRenderTarget(params); + cubeUVRenderTarget.depthBuffer = texture ? false : true; + + if (this._pingPongRenderTarget === null) { + this._pingPongRenderTarget = _createRenderTarget(params); + } + + return cubeUVRenderTarget; + } + + _compileMaterial(material) { + const tmpMesh = new Mesh(_lodPlanes[0], material); + this._renderer.compile(tmpMesh, _flatCamera); + } + + _sceneToCubeUV(scene, near, far, cubeUVRenderTarget) { + const fov = 90; + const aspect = 1; + const cubeCamera = new PerspectiveCamera(fov, aspect, near, far); + const upSign = [1, -1, 1, 1, 1, 1]; + const forwardSign = [1, 1, 1, -1, -1, -1]; + const renderer = this._renderer; + + const originalAutoClear = renderer.autoClear; + const toneMapping = renderer.toneMapping; + renderer.getClearColor(_clearColor); + + renderer.toneMapping = NoToneMapping; + renderer.autoClear = false; + + const backgroundMaterial = new MeshBasicMaterial({ + name: 'PMREM.Background', + side: BackSide, + depthWrite: false, + depthTest: false, + }); + + const backgroundBox = new Mesh(new BoxGeometry(), backgroundMaterial); + + let useSolidColor = false; + const background = scene.background; + + if (background) { + if (background.isColor) { + backgroundMaterial.color.copy(background); + scene.background = null; + useSolidColor = true; + } + } else { + backgroundMaterial.color.copy(_clearColor); + useSolidColor = true; + } + + for (let i = 0; i < 6; i++) { + const col = i % 3; + if (col === 0) { + cubeCamera.up.set(0, upSign[i], 0); + cubeCamera.lookAt(forwardSign[i], 0, 0); + } else if (col === 1) { + cubeCamera.up.set(0, 0, upSign[i]); + cubeCamera.lookAt(0, forwardSign[i], 0); + } else { + cubeCamera.up.set(0, upSign[i], 0); + cubeCamera.lookAt(0, 0, forwardSign[i]); + } + + _setViewport(cubeUVRenderTarget, col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX); + renderer.setRenderTarget(cubeUVRenderTarget); + + if (useSolidColor) { + renderer.render(backgroundBox, cubeCamera); + } + + renderer.render(scene, cubeCamera); + } + + backgroundBox.geometry.dispose(); + backgroundBox.material.dispose(); + + renderer.toneMapping = toneMapping; + renderer.autoClear = originalAutoClear; + scene.background = background; + } + + _textureToCubeUV(texture, cubeUVRenderTarget) { + const renderer = this._renderer; + + const isCubeTexture = texture.mapping === CubeReflectionMapping || texture.mapping === CubeRefractionMapping; + + if (isCubeTexture) { + if (this._cubemapShader === null) { + this._cubemapShader = _getCubemapShader(); + } + + this._cubemapShader.uniforms.flipEnvMap.value = texture.isRenderTargetTexture === false ? -1 : 1; + } else { + if (this._equirectShader === null) { + this._equirectShader = _getEquirectShader(); + } + } + + const material = isCubeTexture ? this._cubemapShader : this._equirectShader; + const mesh = new Mesh(_lodPlanes[0], material); + + const uniforms = material.uniforms; + + uniforms['envMap'].value = texture; + + if (!isCubeTexture) { + uniforms['texelSize'].value.set(1.0 / texture.image.width, 1.0 / texture.image.height); + } + + _setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX); + + renderer.setRenderTarget(cubeUVRenderTarget); + renderer.render(mesh, _flatCamera); + } + + _applyPMREM(cubeUVRenderTarget) { + const renderer = this._renderer; + const autoClear = renderer.autoClear; + renderer.autoClear = false; + + for (let i = 1; i < TOTAL_LODS; i++) { + const sigma = Math.sqrt(_sigmas[i] * _sigmas[i] - _sigmas[i - 1] * _sigmas[i - 1]); + + const poleAxis = _axisDirections[(i - 1) % _axisDirections.length]; + + this._blur(cubeUVRenderTarget, i - 1, i, sigma, poleAxis); + } + + renderer.autoClear = autoClear; + } + + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) { + const pingPongRenderTarget = this._pingPongRenderTarget; + + this._halfBlur(cubeUVRenderTarget, pingPongRenderTarget, lodIn, lodOut, sigma, 'latitudinal', poleAxis); + + this._halfBlur(pingPongRenderTarget, cubeUVRenderTarget, lodOut, lodOut, sigma, 'longitudinal', poleAxis); + } + + _halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) { + const renderer = this._renderer; + const blurMaterial = this._blurMaterial; + + if (direction !== 'latitudinal' && direction !== 'longitudinal') { + console.error('blur direction must be either latitudinal or longitudinal!'); + } + + // Number of standard deviations at which to cut off the discrete approximation. + const STANDARD_DEVIATIONS = 3; + + const blurMesh = new Mesh(_lodPlanes[lodOut], blurMaterial); + const blurUniforms = blurMaterial.uniforms; + + const pixels = _sizeLods[lodIn] - 1; + const radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : (2 * Math.PI) / (2 * MAX_SAMPLES - 1); + const sigmaPixels = sigmaRadians / radiansPerPixel; + const samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES; + + if (samples > MAX_SAMPLES) { + console.warn( + `sigmaRadians, ${sigmaRadians}, is too large and will clip, as it requested ${samples} samples when the maximum is set to ${MAX_SAMPLES}` + ); + } + + const weights = []; + let sum = 0; + + for (let i = 0; i < MAX_SAMPLES; ++i) { + const x = i / sigmaPixels; + const weight = Math.exp((-x * x) / 2); + weights.push(weight); + + if (i === 0) { + sum += weight; + } else if (i < samples) { + sum += 2 * weight; + } + } + + for (let i = 0; i < weights.length; i++) { + weights[i] = weights[i] / sum; + } + + blurUniforms['envMap'].value = targetIn.texture; + blurUniforms['samples'].value = samples; + blurUniforms['weights'].value = weights; + blurUniforms['latitudinal'].value = direction === 'latitudinal'; + + if (poleAxis) { + blurUniforms['poleAxis'].value = poleAxis; + } + + blurUniforms['dTheta'].value = radiansPerPixel; + blurUniforms['mipInt'].value = LOD_MAX - lodIn; + + const outputSize = _sizeLods[lodOut]; + const x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize); + const y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0); + + _setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize); + renderer.setRenderTarget(targetOut); + renderer.render(blurMesh, _flatCamera); + } +} + +function _createPlanes() { + const _lodPlanes = []; + const _sizeLods = []; + const _sigmas = []; + + let lod = LOD_MAX; + + for (let i = 0; i < TOTAL_LODS; i++) { + const sizeLod = Math.pow(2, lod); + _sizeLods.push(sizeLod); + let sigma = 1.0 / sizeLod; + + if (i > LOD_MAX - LOD_MIN) { + sigma = EXTRA_LOD_SIGMA[i - LOD_MAX + LOD_MIN - 1]; + } else if (i === 0) { + sigma = 0; + } + + _sigmas.push(sigma); + + const texelSize = 1.0 / (sizeLod - 1); + const min = -texelSize / 2; + const max = 1 + texelSize / 2; + const uv1 = [min, min, max, min, max, max, min, min, max, max, min, max]; + + const cubeFaces = 6; + const vertices = 6; + const positionSize = 3; + const uvSize = 2; + const faceIndexSize = 1; + + const position = new Float32Array(positionSize * vertices * cubeFaces); + const uv = new Float32Array(uvSize * vertices * cubeFaces); + const faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces); + + for (let face = 0; face < cubeFaces; face++) { + const x = ((face % 3) * 2) / 3 - 1; + const y = face > 2 ? 0 : -1; + const coordinates = [x, y, 0, x + 2 / 3, y, 0, x + 2 / 3, y + 1, 0, x, y, 0, x + 2 / 3, y + 1, 0, x, y + 1, 0]; + position.set(coordinates, positionSize * vertices * face); + uv.set(uv1, uvSize * vertices * face); + const fill = [face, face, face, face, face, face]; + faceIndex.set(fill, faceIndexSize * vertices * face); + } + + const planes = new BufferGeometry(); + planes.setAttribute('position', new BufferAttribute(position, positionSize)); + planes.setAttribute('uv', new BufferAttribute(uv, uvSize)); + planes.setAttribute('faceIndex', new BufferAttribute(faceIndex, faceIndexSize)); + _lodPlanes.push(planes); + + if (lod > LOD_MIN) { + lod--; + } + } + + return { _lodPlanes, _sizeLods, _sigmas }; +} + +function _createRenderTarget(params) { + const cubeUVRenderTarget = new WebGLRenderTarget(3 * SIZE_MAX, 3 * SIZE_MAX, params); + cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; + cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; + cubeUVRenderTarget.scissorTest = true; + return cubeUVRenderTarget; +} + +function _setViewport(target, x, y, width, height) { + target.viewport.set(x, y, width, height); + target.scissor.set(x, y, width, height); +} + +function _getBlurShader(maxSamples) { + const weights = new Float32Array(maxSamples); + const poleAxis = new Vector3(0, 1, 0); + const shaderMaterial = new RawShaderMaterial({ + name: 'SphericalGaussianBlur', + + defines: { n: maxSamples }, + + uniforms: { + envMap: { value: null }, + samples: { value: 1 }, + weights: { value: weights }, + latitudinal: { value: false }, + dTheta: { value: 0 }, + mipInt: { value: 0 }, + poleAxis: { value: poleAxis }, + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */ ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false, + }); + + return shaderMaterial; +} + +function _getEquirectShader() { + const texelSize = new Vector2(1, 1); + const shaderMaterial = new RawShaderMaterial({ + name: 'EquirectangularToCubeUV', + + uniforms: { + envMap: { value: null }, + texelSize: { value: texelSize }, + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */ ` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform vec2 texelSize; + + #include + + void main() { + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + vec2 f = fract( uv / texelSize - 0.5 ); + uv -= f * texelSize; + vec3 tl = texture2D ( envMap, uv ).rgb; + uv.x += texelSize.x; + vec3 tr = texture2D ( envMap, uv ).rgb; + uv.y += texelSize.y; + vec3 br = texture2D ( envMap, uv ).rgb; + uv.x -= texelSize.x; + vec3 bl = texture2D ( envMap, uv ).rgb; + + vec3 tm = mix( tl, tr, f.x ); + vec3 bm = mix( bl, br, f.x ); + gl_FragColor.rgb = mix( tm, bm, f.y ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false, + }); + + return shaderMaterial; +} + +function _getCubemapShader() { + const shaderMaterial = new RawShaderMaterial({ + name: 'CubemapToCubeUV', + + uniforms: { + envMap: { value: null }, + flipEnvMap: { value: -1 }, + }, + + vertexShader: _getCommonVertexShader(), + + fragmentShader: /* glsl */ ` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `, + + blending: NoBlending, + depthTest: false, + depthWrite: false, + }); + + return shaderMaterial; +} + +function _getCommonVertexShader() { + return /* glsl */ ` + + precision mediump float; + precision mediump int; + + attribute vec3 position; + attribute vec2 uv; + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `; +} + +export { PMREMGenerator }; diff --git a/backend/libs/three/extras/ShapeUtils.d.ts b/backend/libs/three/extras/ShapeUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3142f1e7f012f25160786644aab98cbdf67fe6a7 --- /dev/null +++ b/backend/libs/three/extras/ShapeUtils.d.ts @@ -0,0 +1,10 @@ +export interface Vec2 { + x: number; + y: number; +} + +export namespace ShapeUtils { + function area(contour: Vec2[]): number; + function triangulateShape(contour: Vec2[], holes: Vec2[][]): number[][]; + function isClockWise(pts: Vec2[]): boolean; +} diff --git a/backend/libs/three/extras/ShapeUtils.js b/backend/libs/three/extras/ShapeUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..3f99b8a159ce8397e8848d08a826f63ec2960b93 --- /dev/null +++ b/backend/libs/three/extras/ShapeUtils.js @@ -0,0 +1,70 @@ +import { Earcut } from './Earcut.js'; + +class ShapeUtils { + // calculate area of the contour polygon + + static area(contour) { + const n = contour.length; + let a = 0.0; + + for (let p = n - 1, q = 0; q < n; p = q++) { + a += contour[p].x * contour[q].y - contour[q].x * contour[p].y; + } + + return a * 0.5; + } + + static isClockWise(pts) { + return ShapeUtils.area(pts) < 0; + } + + static triangulateShape(contour, holes) { + const vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ] + const holeIndices = []; // array of hole indices + const faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ] + + removeDupEndPts(contour); + addContour(vertices, contour); + + // + + let holeIndex = contour.length; + + holes.forEach(removeDupEndPts); + + for (let i = 0; i < holes.length; i++) { + holeIndices.push(holeIndex); + holeIndex += holes[i].length; + addContour(vertices, holes[i]); + } + + // + + const triangles = Earcut.triangulate(vertices, holeIndices); + + // + + for (let i = 0; i < triangles.length; i += 3) { + faces.push(triangles.slice(i, i + 3)); + } + + return faces; + } +} + +function removeDupEndPts(points) { + const l = points.length; + + if (l > 2 && points[l - 1].equals(points[0])) { + points.pop(); + } +} + +function addContour(vertices, contour) { + for (let i = 0; i < contour.length; i++) { + vertices.push(contour[i].x); + vertices.push(contour[i].y); + } +} + +export { ShapeUtils }; diff --git a/backend/libs/three/extras/core/Curve.d.ts b/backend/libs/three/extras/core/Curve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e9b4fdfa816c85986c774f8d61b84be368681a88 --- /dev/null +++ b/backend/libs/three/extras/core/Curve.d.ts @@ -0,0 +1,101 @@ +import { Vector } from './../../math/Vector2'; +import { Vector3 } from './../../math/Vector3'; + +// Extras / Core ///////////////////////////////////////////////////////////////////// + +/** + * An extensible curve object which contains methods for interpolation + * class Curve + */ +export class Curve { + /** + * @default 'Curve' + */ + type: string; + + /** + * This value determines the amount of divisions when calculating the cumulative segment lengths of a curve via .getLengths. + * To ensure precision when using methods like .getSpacedPoints, it is recommended to increase .arcLengthDivisions if the curve is very large. + * @default 200 + */ + arcLengthDivisions: number; + + /** + * Returns a vector for point t of the curve where t is between 0 and 1 + * getPoint(t: number, optionalTarget?: T): T; + */ + getPoint(t: number, optionalTarget?: T): T; + + /** + * Returns a vector for point at relative position in curve according to arc length + * getPointAt(u: number, optionalTarget?: T): T; + */ + getPointAt(u: number, optionalTarget?: T): T; + + /** + * Get sequence of points using getPoint( t ) + * getPoints(divisions?: number): T[]; + */ + getPoints(divisions?: number): T[]; + + /** + * Get sequence of equi-spaced points using getPointAt( u ) + * getSpacedPoints(divisions?: number): T[]; + */ + getSpacedPoints(divisions?: number): T[]; + + /** + * Get total curve arc length + */ + getLength(): number; + + /** + * Get list of cumulative segment lengths + */ + getLengths(divisions?: number): number[]; + + /** + * Update the cumlative segment distance cache + */ + updateArcLengths(): void; + + /** + * Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance + */ + getUtoTmapping(u: number, distance: number): number; + + /** + * Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a + * small delta apart will be used to find its gradient which seems to give a reasonable approximation + * getTangent(t: number, optionalTarget?: T): T; + */ + getTangent(t: number, optionalTarget?: T): T; + + /** + * Returns tangent at equidistance point u on the curve + * getTangentAt(u: number, optionalTarget?: T): T; + */ + getTangentAt(u: number, optionalTarget?: T): T; + + /** + * Generate Frenet frames of the curve + */ + computeFrenetFrames( + segments: number, + closed?: boolean + ): { + tangents: Vector3[]; + normals: Vector3[]; + binormals: Vector3[]; + }; + + clone(): this; + copy(source: Curve): this; + toJSON(): object; + fromJSON(json: object): this; + + /** + * @deprecated since r84. + */ + static create(constructorFunc: () => void, getPointFunc: () => void): () => void; +} diff --git a/backend/libs/three/extras/core/Curve.js b/backend/libs/three/extras/core/Curve.js new file mode 100644 index 0000000000000000000000000000000000000000..6a3f7ed6373cdc4faf44214fbb3f1e7893eb7aed --- /dev/null +++ b/backend/libs/three/extras/core/Curve.js @@ -0,0 +1,341 @@ +import * as MathUtils from '../../math/MathUtils.js'; +import { Vector2 } from '../../math/Vector2.js'; +import { Vector3 } from '../../math/Vector3.js'; +import { Matrix4 } from '../../math/Matrix4.js'; + +/** + * Extensible curve object. + * + * Some common of curve methods: + * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget ) + * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget ) + * .getPoints(), .getSpacedPoints() + * .getLength() + * .updateArcLengths() + * + * This following curves inherit from THREE.Curve: + * + * -- 2D curves -- + * THREE.ArcCurve + * THREE.CubicBezierCurve + * THREE.EllipseCurve + * THREE.LineCurve + * THREE.QuadraticBezierCurve + * THREE.SplineCurve + * + * -- 3D curves -- + * THREE.CatmullRomCurve3 + * THREE.CubicBezierCurve3 + * THREE.LineCurve3 + * THREE.QuadraticBezierCurve3 + * + * A series of curves can be represented as a THREE.CurvePath. + * + **/ + +class Curve { + constructor() { + this.type = 'Curve'; + + this.arcLengthDivisions = 200; + } + + // Virtual base class method to overwrite and implement in subclasses + // - t [0 .. 1] + + getPoint(/* t, optionalTarget */) { + console.warn('THREE.Curve: .getPoint() not implemented.'); + return null; + } + + // Get point at relative position in curve according to arc length + // - u [0 .. 1] + + getPointAt(u, optionalTarget) { + const t = this.getUtoTmapping(u); + return this.getPoint(t, optionalTarget); + } + + // Get sequence of points using getPoint( t ) + + getPoints(divisions = 5) { + const points = []; + + for (let d = 0; d <= divisions; d++) { + points.push(this.getPoint(d / divisions)); + } + + return points; + } + + // Get sequence of points using getPointAt( u ) + + getSpacedPoints(divisions = 5) { + const points = []; + + for (let d = 0; d <= divisions; d++) { + points.push(this.getPointAt(d / divisions)); + } + + return points; + } + + // Get total curve arc length + + getLength() { + const lengths = this.getLengths(); + return lengths[lengths.length - 1]; + } + + // Get list of cumulative segment lengths + + getLengths(divisions = this.arcLengthDivisions) { + if (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) { + return this.cacheArcLengths; + } + + this.needsUpdate = false; + + const cache = []; + let current, + last = this.getPoint(0); + let sum = 0; + + cache.push(0); + + for (let p = 1; p <= divisions; p++) { + current = this.getPoint(p / divisions); + sum += current.distanceTo(last); + cache.push(sum); + last = current; + } + + this.cacheArcLengths = cache; + + return cache; // { sums: cache, sum: sum }; Sum is in the last element. + } + + updateArcLengths() { + this.needsUpdate = true; + this.getLengths(); + } + + // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant + + getUtoTmapping(u, distance) { + const arcLengths = this.getLengths(); + + let i = 0; + const il = arcLengths.length; + + let targetArcLength; // The targeted u distance value to get + + if (distance) { + targetArcLength = distance; + } else { + targetArcLength = u * arcLengths[il - 1]; + } + + // binary search for the index with largest value smaller than target u distance + + let low = 0, + high = il - 1, + comparison; + + while (low <= high) { + i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats + + comparison = arcLengths[i] - targetArcLength; + + if (comparison < 0) { + low = i + 1; + } else if (comparison > 0) { + high = i - 1; + } else { + high = i; + break; + + // DONE + } + } + + i = high; + + if (arcLengths[i] === targetArcLength) { + return i / (il - 1); + } + + // we could get finer grain at lengths, or use simple interpolation between two points + + const lengthBefore = arcLengths[i]; + const lengthAfter = arcLengths[i + 1]; + + const segmentLength = lengthAfter - lengthBefore; + + // determine where we are between the 'before' and 'after' points + + const segmentFraction = (targetArcLength - lengthBefore) / segmentLength; + + // add that fractional amount to t + + const t = (i + segmentFraction) / (il - 1); + + return t; + } + + // Returns a unit vector tangent at t + // In case any sub curve does not implement its tangent derivation, + // 2 points a small delta apart will be used to find its gradient + // which seems to give a reasonable approximation + + getTangent(t, optionalTarget) { + const delta = 0.0001; + let t1 = t - delta; + let t2 = t + delta; + + // Capping in case of danger + + if (t1 < 0) t1 = 0; + if (t2 > 1) t2 = 1; + + const pt1 = this.getPoint(t1); + const pt2 = this.getPoint(t2); + + const tangent = optionalTarget || (pt1.isVector2 ? new Vector2() : new Vector3()); + + tangent.copy(pt2).sub(pt1).normalize(); + + return tangent; + } + + getTangentAt(u, optionalTarget) { + const t = this.getUtoTmapping(u); + return this.getTangent(t, optionalTarget); + } + + computeFrenetFrames(segments, closed) { + // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf + + const normal = new Vector3(); + + const tangents = []; + const normals = []; + const binormals = []; + + const vec = new Vector3(); + const mat = new Matrix4(); + + // compute the tangent vectors for each segment on the curve + + for (let i = 0; i <= segments; i++) { + const u = i / segments; + + tangents[i] = this.getTangentAt(u, new Vector3()); + } + + // select an initial normal vector perpendicular to the first tangent vector, + // and in the direction of the minimum tangent xyz component + + normals[0] = new Vector3(); + binormals[0] = new Vector3(); + let min = Number.MAX_VALUE; + const tx = Math.abs(tangents[0].x); + const ty = Math.abs(tangents[0].y); + const tz = Math.abs(tangents[0].z); + + if (tx <= min) { + min = tx; + normal.set(1, 0, 0); + } + + if (ty <= min) { + min = ty; + normal.set(0, 1, 0); + } + + if (tz <= min) { + normal.set(0, 0, 1); + } + + vec.crossVectors(tangents[0], normal).normalize(); + + normals[0].crossVectors(tangents[0], vec); + binormals[0].crossVectors(tangents[0], normals[0]); + + // compute the slowly-varying normal and binormal vectors for each segment on the curve + + for (let i = 1; i <= segments; i++) { + normals[i] = normals[i - 1].clone(); + + binormals[i] = binormals[i - 1].clone(); + + vec.crossVectors(tangents[i - 1], tangents[i]); + + if (vec.length() > Number.EPSILON) { + vec.normalize(); + + const theta = Math.acos(MathUtils.clamp(tangents[i - 1].dot(tangents[i]), -1, 1)); // clamp for floating pt errors + + normals[i].applyMatrix4(mat.makeRotationAxis(vec, theta)); + } + + binormals[i].crossVectors(tangents[i], normals[i]); + } + + // if the curve is closed, postprocess the vectors so the first and last normal vectors are the same + + if (closed === true) { + let theta = Math.acos(MathUtils.clamp(normals[0].dot(normals[segments]), -1, 1)); + theta /= segments; + + if (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) { + theta = -theta; + } + + for (let i = 1; i <= segments; i++) { + // twist a little... + normals[i].applyMatrix4(mat.makeRotationAxis(tangents[i], theta * i)); + binormals[i].crossVectors(tangents[i], normals[i]); + } + } + + return { + tangents: tangents, + normals: normals, + binormals: binormals, + }; + } + + clone() { + return new this.constructor().copy(this); + } + + copy(source) { + this.arcLengthDivisions = source.arcLengthDivisions; + + return this; + } + + toJSON() { + const data = { + metadata: { + version: 4.5, + type: 'Curve', + generator: 'Curve.toJSON', + }, + }; + + data.arcLengthDivisions = this.arcLengthDivisions; + data.type = this.type; + + return data; + } + + fromJSON(json) { + this.arcLengthDivisions = json.arcLengthDivisions; + + return this; + } +} + +export { Curve }; diff --git a/backend/libs/three/extras/core/CurvePath.d.ts b/backend/libs/three/extras/core/CurvePath.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..067b5125f8292bcfb8fc063be876b6b697fce61f --- /dev/null +++ b/backend/libs/three/extras/core/CurvePath.d.ts @@ -0,0 +1,26 @@ +import { Curve } from './Curve'; +import { Vector } from './../../math/Vector2'; + +export class CurvePath extends Curve { + constructor(); + + /** + * @default 'CurvePath' + */ + type: string; + + /** + * @default [] + */ + curves: Array>; + + /** + * @default false + */ + autoClose: boolean; + + add(curve: Curve): void; + closePath(): void; + getPoint(t: number, optionalTarget?: T): T; + getCurveLengths(): number[]; +} diff --git a/backend/libs/three/extras/core/CurvePath.js b/backend/libs/three/extras/core/CurvePath.js new file mode 100644 index 0000000000000000000000000000000000000000..585240d9fa9de5e10b59938d7bec880dfa5f0892 --- /dev/null +++ b/backend/libs/three/extras/core/CurvePath.js @@ -0,0 +1,203 @@ +import { Curve } from './Curve.js'; +import * as Curves from '../curves/Curves.js'; + +/************************************************************** + * Curved Path - a curve path is simply a array of connected + * curves, but retains the api of a curve + **************************************************************/ + +class CurvePath extends Curve { + constructor() { + super(); + + this.type = 'CurvePath'; + + this.curves = []; + this.autoClose = false; // Automatically closes the path + } + + add(curve) { + this.curves.push(curve); + } + + closePath() { + // Add a line curve if start and end of lines are not connected + const startPoint = this.curves[0].getPoint(0); + const endPoint = this.curves[this.curves.length - 1].getPoint(1); + + if (!startPoint.equals(endPoint)) { + this.curves.push(new Curves['LineCurve'](endPoint, startPoint)); + } + } + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + getPoint(t, optionalTarget) { + const d = t * this.getLength(); + const curveLengths = this.getCurveLengths(); + let i = 0; + + // To think about boundaries points. + + while (i < curveLengths.length) { + if (curveLengths[i] >= d) { + const diff = curveLengths[i] - d; + const curve = this.curves[i]; + + const segmentLength = curve.getLength(); + const u = segmentLength === 0 ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt(u, optionalTarget); + } + + i++; + } + + return null; + + // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) { + points.push(points[0]); + } + + return points; + } + + copy(source) { + super.copy(source); + + this.curves = []; + + for (let i = 0, l = source.curves.length; i < l; i++) { + const curve = source.curves[i]; + + this.curves.push(curve.clone()); + } + + this.autoClose = source.autoClose; + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.autoClose = this.autoClose; + data.curves = []; + + for (let i = 0, l = this.curves.length; i < l; i++) { + const curve = this.curves[i]; + data.curves.push(curve.toJSON()); + } + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.autoClose = json.autoClose; + this.curves = []; + + for (let i = 0, l = json.curves.length; i < l; i++) { + const curve = json.curves[i]; + this.curves.push(new Curves[curve.type]().fromJSON(curve)); + } + + return this; + } +} + +export { CurvePath }; diff --git a/backend/libs/three/extras/core/Interpolations.js b/backend/libs/three/extras/core/Interpolations.js new file mode 100644 index 0000000000000000000000000000000000000000..69aeb9ce4e937a9deaae70a398390794c4a74bc0 --- /dev/null +++ b/backend/libs/three/extras/core/Interpolations.js @@ -0,0 +1,57 @@ +/** + * Bezier Curves formulas obtained from + * https://en.wikipedia.org/wiki/B%C3%A9zier_curve + */ + +function CatmullRom(t, p0, p1, p2, p3) { + const v0 = (p2 - p0) * 0.5; + const v1 = (p3 - p1) * 0.5; + const t2 = t * t; + const t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; +} + +// + +function QuadraticBezierP0(t, p) { + const k = 1 - t; + return k * k * p; +} + +function QuadraticBezierP1(t, p) { + return 2 * (1 - t) * t * p; +} + +function QuadraticBezierP2(t, p) { + return t * t * p; +} + +function QuadraticBezier(t, p0, p1, p2) { + return QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2); +} + +// + +function CubicBezierP0(t, p) { + const k = 1 - t; + return k * k * k * p; +} + +function CubicBezierP1(t, p) { + const k = 1 - t; + return 3 * k * k * t * p; +} + +function CubicBezierP2(t, p) { + return 3 * (1 - t) * t * t * p; +} + +function CubicBezierP3(t, p) { + return t * t * t * p; +} + +function CubicBezier(t, p0, p1, p2, p3) { + return CubicBezierP0(t, p0) + CubicBezierP1(t, p1) + CubicBezierP2(t, p2) + CubicBezierP3(t, p3); +} + +export { CatmullRom, QuadraticBezier, CubicBezier }; diff --git a/backend/libs/three/extras/core/Path.d.ts b/backend/libs/three/extras/core/Path.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7efe82185e91e6784e45f6311e4ad73ba49096ea --- /dev/null +++ b/backend/libs/three/extras/core/Path.d.ts @@ -0,0 +1,34 @@ +import { Vector2 } from './../../math/Vector2'; +import { CurvePath } from './CurvePath'; + +/** + * a 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api. It extends CurvePath. + */ +export class Path extends CurvePath { + constructor(points?: Vector2[]); + + /** + * @default 'Path' + */ + type: string; + + /** + * @default new THREE.Vector2() + */ + currentPoint: Vector2; + + /** + * @deprecated Use {@link Path#setFromPoints .setFromPoints()} instead. + */ + fromPoints(vectors: Vector2[]): this; + setFromPoints(vectors: Vector2[]): this; + moveTo(x: number, y: number): this; + lineTo(x: number, y: number): this; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): this; + bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): this; + splineThru(pts: Vector2[]): this; + arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): this; + absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): this; + ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean, aRotation: number): this; + absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean, aRotation: number): this; +} diff --git a/backend/libs/three/extras/core/Path.js b/backend/libs/three/extras/core/Path.js new file mode 100644 index 0000000000000000000000000000000000000000..703c232b4c926dbc48763f0e752bf3f00f05a85e --- /dev/null +++ b/backend/libs/three/extras/core/Path.js @@ -0,0 +1,146 @@ +import { Vector2 } from '../../math/Vector2.js'; +import { CurvePath } from './CurvePath.js'; +import { EllipseCurve } from '../curves/EllipseCurve.js'; +import { SplineCurve } from '../curves/SplineCurve.js'; +import { CubicBezierCurve } from '../curves/CubicBezierCurve.js'; +import { QuadraticBezierCurve } from '../curves/QuadraticBezierCurve.js'; +import { LineCurve } from '../curves/LineCurve.js'; + +class Path extends CurvePath { + constructor(points) { + super(); + this.type = 'Path'; + + this.currentPoint = new Vector2(); + + if (points) { + this.setFromPoints(points); + } + } + + setFromPoints(points) { + this.moveTo(points[0].x, points[0].y); + + for (let i = 1, l = points.length; i < l; i++) { + this.lineTo(points[i].x, points[i].y); + } + + return this; + } + + moveTo(x, y) { + this.currentPoint.set(x, y); // TODO consider referencing vectors instead of copying? + + return this; + } + + lineTo(x, y) { + const curve = new LineCurve(this.currentPoint.clone(), new Vector2(x, y)); + this.curves.push(curve); + + this.currentPoint.set(x, y); + + return this; + } + + quadraticCurveTo(aCPx, aCPy, aX, aY) { + const curve = new QuadraticBezierCurve(this.currentPoint.clone(), new Vector2(aCPx, aCPy), new Vector2(aX, aY)); + + this.curves.push(curve); + + this.currentPoint.set(aX, aY); + + return this; + } + + bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) { + const curve = new CubicBezierCurve(this.currentPoint.clone(), new Vector2(aCP1x, aCP1y), new Vector2(aCP2x, aCP2y), new Vector2(aX, aY)); + + this.curves.push(curve); + + this.currentPoint.set(aX, aY); + + return this; + } + + splineThru(pts /*Array of Vector*/) { + const npts = [this.currentPoint.clone()].concat(pts); + + const curve = new SplineCurve(npts); + this.curves.push(curve); + + this.currentPoint.copy(pts[pts.length - 1]); + + return this; + } + + arc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) { + const x0 = this.currentPoint.x; + const y0 = this.currentPoint.y; + + this.absarc(aX + x0, aY + y0, aRadius, aStartAngle, aEndAngle, aClockwise); + + return this; + } + + absarc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) { + this.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise); + + return this; + } + + ellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) { + const x0 = this.currentPoint.x; + const y0 = this.currentPoint.y; + + this.absellipse(aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation); + + return this; + } + + absellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) { + const curve = new EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation); + + if (this.curves.length > 0) { + // if a previous curve is present, attempt to join + const firstPoint = curve.getPoint(0); + + if (!firstPoint.equals(this.currentPoint)) { + this.lineTo(firstPoint.x, firstPoint.y); + } + } + + this.curves.push(curve); + + const lastPoint = curve.getPoint(1); + this.currentPoint.copy(lastPoint); + + return this; + } + + copy(source) { + super.copy(source); + + this.currentPoint.copy(source.currentPoint); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.currentPoint = this.currentPoint.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.currentPoint.fromArray(json.currentPoint); + + return this; + } +} + +export { Path }; diff --git a/backend/libs/three/extras/core/Shape.d.ts b/backend/libs/three/extras/core/Shape.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1b790a363af783d476753c712ed9420e2ca517fa --- /dev/null +++ b/backend/libs/three/extras/core/Shape.d.ts @@ -0,0 +1,28 @@ +import { Vector2 } from './../../math/Vector2'; +import { Path } from './Path'; + +/** + * Defines a 2d shape plane using paths. + */ +export class Shape extends Path { + constructor(points?: Vector2[]); + + /** + * @default 'Shape' + */ + type: string; + + uuid: string; + + /** + * @default [] + */ + holes: Path[]; + + getPointsHoles(divisions: number): Vector2[][]; + + extractPoints(divisions: number): { + shape: Vector2[]; + holes: Vector2[][]; + }; +} diff --git a/backend/libs/three/extras/core/Shape.js b/backend/libs/three/extras/core/Shape.js new file mode 100644 index 0000000000000000000000000000000000000000..4f338d1c148845647523c61c87deb7effc68b50d --- /dev/null +++ b/backend/libs/three/extras/core/Shape.js @@ -0,0 +1,77 @@ +import { Path } from './Path.js'; +import * as MathUtils from '../../math/MathUtils.js'; + +class Shape extends Path { + constructor(points) { + super(points); + + this.uuid = MathUtils.generateUUID(); + + this.type = 'Shape'; + + this.holes = []; + } + + getPointsHoles(divisions) { + const holesPts = []; + + for (let i = 0, l = this.holes.length; i < l; i++) { + holesPts[i] = this.holes[i].getPoints(divisions); + } + + return holesPts; + } + + // get points of shape and holes (keypoints based on segments parameter) + + extractPoints(divisions) { + return { + shape: this.getPoints(divisions), + holes: this.getPointsHoles(divisions), + }; + } + + copy(source) { + super.copy(source); + + this.holes = []; + + for (let i = 0, l = source.holes.length; i < l; i++) { + const hole = source.holes[i]; + + this.holes.push(hole.clone()); + } + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.uuid = this.uuid; + data.holes = []; + + for (let i = 0, l = this.holes.length; i < l; i++) { + const hole = this.holes[i]; + data.holes.push(hole.toJSON()); + } + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.uuid = json.uuid; + this.holes = []; + + for (let i = 0, l = json.holes.length; i < l; i++) { + const hole = json.holes[i]; + this.holes.push(new Path().fromJSON(hole)); + } + + return this; + } +} + +export { Shape }; diff --git a/backend/libs/three/extras/core/ShapePath.d.ts b/backend/libs/three/extras/core/ShapePath.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d56e15301785dbaedab2d8b2801681d6ffe53773 --- /dev/null +++ b/backend/libs/three/extras/core/ShapePath.d.ts @@ -0,0 +1,34 @@ +import { Vector2 } from './../../math/Vector2'; +import { Shape } from './Shape'; +import { Color } from '../../math/Color'; + +export class ShapePath { + constructor(); + + /** + * @default 'ShapePath' + */ + type: string; + + /** + * @default new THREE.Color() + */ + color: Color; + + /** + * @default [] + */ + subPaths: any[]; + + /** + * @default null + */ + currentPath: any; + + moveTo(x: number, y: number): this; + lineTo(x: number, y: number): this; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): this; + bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): this; + splineThru(pts: Vector2[]): this; + toShapes(isCCW: boolean, noHoles?: boolean): Shape[]; +} diff --git a/backend/libs/three/extras/core/ShapePath.js b/backend/libs/three/extras/core/ShapePath.js new file mode 100644 index 0000000000000000000000000000000000000000..477fd684a7b2e1e440d2f7a04e3bab1e72767ffc --- /dev/null +++ b/backend/libs/three/extras/core/ShapePath.js @@ -0,0 +1,227 @@ +import { Color } from '../../math/Color.js'; +import { Path } from './Path.js'; +import { Shape } from './Shape.js'; +import { ShapeUtils } from '../ShapeUtils.js'; + +class ShapePath { + constructor() { + this.type = 'ShapePath'; + + this.color = new Color(); + + this.subPaths = []; + this.currentPath = null; + } + + moveTo(x, y) { + this.currentPath = new Path(); + this.subPaths.push(this.currentPath); + this.currentPath.moveTo(x, y); + + return this; + } + + lineTo(x, y) { + this.currentPath.lineTo(x, y); + + return this; + } + + quadraticCurveTo(aCPx, aCPy, aX, aY) { + this.currentPath.quadraticCurveTo(aCPx, aCPy, aX, aY); + + return this; + } + + bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) { + this.currentPath.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY); + + return this; + } + + splineThru(pts) { + this.currentPath.splineThru(pts); + + return this; + } + + toShapes(isCCW, noHoles) { + function toShapesNoHoles(inSubpaths) { + const shapes = []; + + for (let i = 0, l = inSubpaths.length; i < l; i++) { + const tmpPath = inSubpaths[i]; + + const tmpShape = new Shape(); + tmpShape.curves = tmpPath.curves; + + shapes.push(tmpShape); + } + + return shapes; + } + + function isPointInsidePolygon(inPt, inPolygon) { + const polyLen = inPolygon.length; + + // inPt on polygon contour => immediate success or + // toggling of inside/outside at every single! intersection point of an edge + // with the horizontal line through inPt, left of inPt + // not counting lowerY endpoints of edges and whole edges on that line + let inside = false; + for (let p = polyLen - 1, q = 0; q < polyLen; p = q++) { + let edgeLowPt = inPolygon[p]; + let edgeHighPt = inPolygon[q]; + + let edgeDx = edgeHighPt.x - edgeLowPt.x; + let edgeDy = edgeHighPt.y - edgeLowPt.y; + + if (Math.abs(edgeDy) > Number.EPSILON) { + // not parallel + if (edgeDy < 0) { + edgeLowPt = inPolygon[q]; + edgeDx = -edgeDx; + edgeHighPt = inPolygon[p]; + edgeDy = -edgeDy; + } + + if (inPt.y < edgeLowPt.y || inPt.y > edgeHighPt.y) continue; + + if (inPt.y === edgeLowPt.y) { + if (inPt.x === edgeLowPt.x) return true; // inPt is on contour ? + // continue; // no intersection or edgeLowPt => doesn't count !!! + } else { + const perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y); + if (perpEdge === 0) return true; // inPt is on contour ? + if (perpEdge < 0) continue; + inside = !inside; // true intersection left of inPt + } + } else { + // parallel or collinear + if (inPt.y !== edgeLowPt.y) continue; // parallel + // edge lies on the same horizontal line as inPt + if ((edgeHighPt.x <= inPt.x && inPt.x <= edgeLowPt.x) || (edgeLowPt.x <= inPt.x && inPt.x <= edgeHighPt.x)) return true; // inPt: Point on contour ! + // continue; + } + } + + return inside; + } + + const isClockWise = ShapeUtils.isClockWise; + + const subPaths = this.subPaths; + if (subPaths.length === 0) return []; + + if (noHoles === true) return toShapesNoHoles(subPaths); + + let solid, tmpPath, tmpShape; + const shapes = []; + + if (subPaths.length === 1) { + tmpPath = subPaths[0]; + tmpShape = new Shape(); + tmpShape.curves = tmpPath.curves; + shapes.push(tmpShape); + return shapes; + } + + let holesFirst = !isClockWise(subPaths[0].getPoints()); + holesFirst = isCCW ? !holesFirst : holesFirst; + + // console.log("Holes first", holesFirst); + + const betterShapeHoles = []; + const newShapes = []; + let newShapeHoles = []; + let mainIdx = 0; + let tmpPoints; + + newShapes[mainIdx] = undefined; + newShapeHoles[mainIdx] = []; + + for (let i = 0, l = subPaths.length; i < l; i++) { + tmpPath = subPaths[i]; + tmpPoints = tmpPath.getPoints(); + solid = isClockWise(tmpPoints); + solid = isCCW ? !solid : solid; + + if (solid) { + if (!holesFirst && newShapes[mainIdx]) mainIdx++; + + newShapes[mainIdx] = { s: new Shape(), p: tmpPoints }; + newShapes[mainIdx].s.curves = tmpPath.curves; + + if (holesFirst) mainIdx++; + newShapeHoles[mainIdx] = []; + + //console.log('cw', i); + } else { + newShapeHoles[mainIdx].push({ h: tmpPath, p: tmpPoints[0] }); + + //console.log('ccw', i); + } + } + + // only Holes? -> probably all Shapes with wrong orientation + if (!newShapes[0]) return toShapesNoHoles(subPaths); + + if (newShapes.length > 1) { + let ambiguous = false; + const toChange = []; + + for (let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) { + betterShapeHoles[sIdx] = []; + } + + for (let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) { + const sho = newShapeHoles[sIdx]; + + for (let hIdx = 0; hIdx < sho.length; hIdx++) { + const ho = sho[hIdx]; + let hole_unassigned = true; + + for (let s2Idx = 0; s2Idx < newShapes.length; s2Idx++) { + if (isPointInsidePolygon(ho.p, newShapes[s2Idx].p)) { + if (sIdx !== s2Idx) toChange.push({ froms: sIdx, tos: s2Idx, hole: hIdx }); + if (hole_unassigned) { + hole_unassigned = false; + betterShapeHoles[s2Idx].push(ho); + } else { + ambiguous = true; + } + } + } + + if (hole_unassigned) { + betterShapeHoles[sIdx].push(ho); + } + } + } + // console.log("ambiguous: ", ambiguous); + + if (toChange.length > 0) { + // console.log("to change: ", toChange); + if (!ambiguous) newShapeHoles = betterShapeHoles; + } + } + + let tmpHoles; + + for (let i = 0, il = newShapes.length; i < il; i++) { + tmpShape = newShapes[i].s; + shapes.push(tmpShape); + tmpHoles = newShapeHoles[i]; + + for (let j = 0, jl = tmpHoles.length; j < jl; j++) { + tmpShape.holes.push(tmpHoles[j].h); + } + } + + //console.log("shape", shapes); + + return shapes; + } +} + +export { ShapePath }; diff --git a/backend/libs/three/extras/curves/ArcCurve.d.ts b/backend/libs/three/extras/curves/ArcCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..96fabd16cf7c875e0ac26eead566ecfda257921c --- /dev/null +++ b/backend/libs/three/extras/curves/ArcCurve.d.ts @@ -0,0 +1,9 @@ +import { EllipseCurve } from './EllipseCurve'; +export class ArcCurve extends EllipseCurve { + constructor(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean); + + /** + * @default 'ArcCurve' + */ + type: string; +} diff --git a/backend/libs/three/extras/curves/ArcCurve.js b/backend/libs/three/extras/curves/ArcCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..82536afeb42d4f909a8696d5938ba7d89a1e3bc2 --- /dev/null +++ b/backend/libs/three/extras/curves/ArcCurve.js @@ -0,0 +1,13 @@ +import { EllipseCurve } from './EllipseCurve.js'; + +class ArcCurve extends EllipseCurve { + constructor(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) { + super(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise); + + this.type = 'ArcCurve'; + } +} + +ArcCurve.prototype.isArcCurve = true; + +export { ArcCurve }; diff --git a/backend/libs/three/extras/curves/CatmullRomCurve3.d.ts b/backend/libs/three/extras/curves/CatmullRomCurve3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..232ae0b68ec470c7d44d6f4247baa9ef846123ec --- /dev/null +++ b/backend/libs/three/extras/curves/CatmullRomCurve3.d.ts @@ -0,0 +1,30 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +// Extras / Curves ///////////////////////////////////////////////////////////////////// +export namespace CurveUtils { + function tangentQuadraticBezier(t: number, p0: number, p1: number, p2: number): number; + function tangentCubicBezier(t: number, p0: number, p1: number, p2: number, p3: number): number; + function tangentSpline(t: number, p0: number, p1: number, p2: number, p3: number): number; + function interpolate(p0: number, p1: number, p2: number, p3: number, t: number): number; +} + +export class CatmullRomCurve3 extends Curve { + /** + * @param [points=[]] + * @param [closed=false] + * @param [curveType='centripetal'] + * @param [tension=0.5] + */ + constructor(points?: Vector3[], closed?: boolean, curveType?: string, tension?: number); + + /** + * @default 'CatmullRomCurve3' + */ + type: string; + + /** + * @default [] + */ + points: Vector3[]; +} diff --git a/backend/libs/three/extras/curves/CatmullRomCurve3.js b/backend/libs/three/extras/curves/CatmullRomCurve3.js new file mode 100644 index 0000000000000000000000000000000000000000..5446f9616d63c39472ad2390a0ef2adc3c757dc9 --- /dev/null +++ b/backend/libs/three/extras/curves/CatmullRomCurve3.js @@ -0,0 +1,207 @@ +import { Vector3 } from '../../math/Vector3.js'; +import { Curve } from '../core/Curve.js'; + +/** + * Centripetal CatmullRom Curve - which is useful for avoiding + * cusps and self-intersections in non-uniform catmull rom curves. + * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf + * + * curve.type accepts centripetal(default), chordal and catmullrom + * curve.tension is used for catmullrom which defaults to 0.5 + */ + +/* +Based on an optimized c++ solution in + - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/ + - http://ideone.com/NoEbVM + +This CubicPoly class could be used for reusing some variables and calculations, +but for three.js curve use, it could be possible inlined and flatten into a single function call +which can be placed in CurveUtils. +*/ + +function CubicPoly() { + let c0 = 0, + c1 = 0, + c2 = 0, + c3 = 0; + + /* + * Compute coefficients for a cubic polynomial + * p(s) = c0 + c1*s + c2*s^2 + c3*s^3 + * such that + * p(0) = x0, p(1) = x1 + * and + * p'(0) = t0, p'(1) = t1. + */ + function init(x0, x1, t0, t1) { + c0 = x0; + c1 = t0; + c2 = -3 * x0 + 3 * x1 - 2 * t0 - t1; + c3 = 2 * x0 - 2 * x1 + t0 + t1; + } + + return { + initCatmullRom: function (x0, x1, x2, x3, tension) { + init(x1, x2, tension * (x2 - x0), tension * (x3 - x1)); + }, + + initNonuniformCatmullRom: function (x0, x1, x2, x3, dt0, dt1, dt2) { + // compute tangents when parameterized in [t1,t2] + let t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1; + let t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2; + + // rescale tangents for parametrization in [0,1] + t1 *= dt1; + t2 *= dt1; + + init(x1, x2, t1, t2); + }, + + calc: function (t) { + const t2 = t * t; + const t3 = t2 * t; + return c0 + c1 * t + c2 * t2 + c3 * t3; + }, + }; +} + +// + +const tmp = new Vector3(); +const px = new CubicPoly(), + py = new CubicPoly(), + pz = new CubicPoly(); + +class CatmullRomCurve3 extends Curve { + constructor(points = [], closed = false, curveType = 'centripetal', tension = 0.5) { + super(); + + this.type = 'CatmullRomCurve3'; + + this.points = points; + this.closed = closed; + this.curveType = curveType; + this.tension = tension; + } + + getPoint(t, optionalTarget = new Vector3()) { + const point = optionalTarget; + + const points = this.points; + const l = points.length; + + const p = (l - (this.closed ? 0 : 1)) * t; + let intPoint = Math.floor(p); + let weight = p - intPoint; + + if (this.closed) { + intPoint += intPoint > 0 ? 0 : (Math.floor(Math.abs(intPoint) / l) + 1) * l; + } else if (weight === 0 && intPoint === l - 1) { + intPoint = l - 2; + weight = 1; + } + + let p0, p3; // 4 points (p1 & p2 defined below) + + if (this.closed || intPoint > 0) { + p0 = points[(intPoint - 1) % l]; + } else { + // extrapolate first point + tmp.subVectors(points[0], points[1]).add(points[0]); + p0 = tmp; + } + + const p1 = points[intPoint % l]; + const p2 = points[(intPoint + 1) % l]; + + if (this.closed || intPoint + 2 < l) { + p3 = points[(intPoint + 2) % l]; + } else { + // extrapolate last point + tmp.subVectors(points[l - 1], points[l - 2]).add(points[l - 1]); + p3 = tmp; + } + + if (this.curveType === 'centripetal' || this.curveType === 'chordal') { + // init Centripetal / Chordal Catmull-Rom + const pow = this.curveType === 'chordal' ? 0.5 : 0.25; + let dt0 = Math.pow(p0.distanceToSquared(p1), pow); + let dt1 = Math.pow(p1.distanceToSquared(p2), pow); + let dt2 = Math.pow(p2.distanceToSquared(p3), pow); + + // safety check for repeated points + if (dt1 < 1e-4) dt1 = 1.0; + if (dt0 < 1e-4) dt0 = dt1; + if (dt2 < 1e-4) dt2 = dt1; + + px.initNonuniformCatmullRom(p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2); + py.initNonuniformCatmullRom(p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2); + pz.initNonuniformCatmullRom(p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2); + } else if (this.curveType === 'catmullrom') { + px.initCatmullRom(p0.x, p1.x, p2.x, p3.x, this.tension); + py.initCatmullRom(p0.y, p1.y, p2.y, p3.y, this.tension); + pz.initCatmullRom(p0.z, p1.z, p2.z, p3.z, this.tension); + } + + point.set(px.calc(weight), py.calc(weight), pz.calc(weight)); + + return point; + } + + copy(source) { + super.copy(source); + + this.points = []; + + for (let i = 0, l = source.points.length; i < l; i++) { + const point = source.points[i]; + + this.points.push(point.clone()); + } + + this.closed = source.closed; + this.curveType = source.curveType; + this.tension = source.tension; + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.points = []; + + for (let i = 0, l = this.points.length; i < l; i++) { + const point = this.points[i]; + data.points.push(point.toArray()); + } + + data.closed = this.closed; + data.curveType = this.curveType; + data.tension = this.tension; + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.points = []; + + for (let i = 0, l = json.points.length; i < l; i++) { + const point = json.points[i]; + this.points.push(new Vector3().fromArray(point)); + } + + this.closed = json.closed; + this.curveType = json.curveType; + this.tension = json.tension; + + return this; + } +} + +CatmullRomCurve3.prototype.isCatmullRomCurve3 = true; + +export { CatmullRomCurve3 }; diff --git a/backend/libs/three/extras/curves/CubicBezierCurve.d.ts b/backend/libs/three/extras/curves/CubicBezierCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b0295dc20b1f76107e73fabfd494dcfebcc4f8a7 --- /dev/null +++ b/backend/libs/three/extras/curves/CubicBezierCurve.d.ts @@ -0,0 +1,31 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class CubicBezierCurve extends Curve { + constructor(v0: Vector2, v1: Vector2, v2: Vector2, v3: Vector2); + + /** + * @default 'CubicBezierCurve' + */ + type: string; + + /** + * @default new THREE.Vector2() + */ + v0: Vector2; + + /** + * @default new THREE.Vector2() + */ + v1: Vector2; + + /** + * @default new THREE.Vector2() + */ + v2: Vector2; + + /** + * @default new THREE.Vector2() + */ + v3: Vector2; +} diff --git a/backend/libs/three/extras/curves/CubicBezierCurve.js b/backend/libs/three/extras/curves/CubicBezierCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..19a1feb7eaa5b0a4e45f739d0472ef94839cd922 --- /dev/null +++ b/backend/libs/three/extras/curves/CubicBezierCurve.js @@ -0,0 +1,66 @@ +import { Curve } from '../core/Curve.js'; +import { CubicBezier } from '../core/Interpolations.js'; +import { Vector2 } from '../../math/Vector2.js'; + +class CubicBezierCurve extends Curve { + constructor(v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2()) { + super(); + + this.type = 'CubicBezierCurve'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + } + + getPoint(t, optionalTarget = new Vector2()) { + const point = optionalTarget; + + const v0 = this.v0, + v1 = this.v1, + v2 = this.v2, + v3 = this.v3; + + point.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y)); + + return point; + } + + copy(source) { + super.copy(source); + + this.v0.copy(source.v0); + this.v1.copy(source.v1); + this.v2.copy(source.v2); + this.v3.copy(source.v3); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + data.v3 = this.v3.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.v0.fromArray(json.v0); + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + this.v3.fromArray(json.v3); + + return this; + } +} + +CubicBezierCurve.prototype.isCubicBezierCurve = true; + +export { CubicBezierCurve }; diff --git a/backend/libs/three/extras/curves/CubicBezierCurve3.d.ts b/backend/libs/three/extras/curves/CubicBezierCurve3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e9ce12ce06629af798c042af0004cca6cba36070 --- /dev/null +++ b/backend/libs/three/extras/curves/CubicBezierCurve3.d.ts @@ -0,0 +1,31 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class CubicBezierCurve3 extends Curve { + constructor(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3); + + /** + * @default 'CubicBezierCurve3' + */ + type: string; + + /** + * @default new THREE.Vector3() + */ + v0: Vector3; + + /** + * @default new THREE.Vector3() + */ + v1: Vector3; + + /** + * @default new THREE.Vector3() + */ + v2: Vector3; + + /** + * @default new THREE.Vector3() + */ + v3: Vector3; +} diff --git a/backend/libs/three/extras/curves/CubicBezierCurve3.js b/backend/libs/three/extras/curves/CubicBezierCurve3.js new file mode 100644 index 0000000000000000000000000000000000000000..58ae7dd4b6c958fac49e3ab585265bd6522c278b --- /dev/null +++ b/backend/libs/three/extras/curves/CubicBezierCurve3.js @@ -0,0 +1,66 @@ +import { Curve } from '../core/Curve.js'; +import { CubicBezier } from '../core/Interpolations.js'; +import { Vector3 } from '../../math/Vector3.js'; + +class CubicBezierCurve3 extends Curve { + constructor(v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3(), v3 = new Vector3()) { + super(); + + this.type = 'CubicBezierCurve3'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + } + + getPoint(t, optionalTarget = new Vector3()) { + const point = optionalTarget; + + const v0 = this.v0, + v1 = this.v1, + v2 = this.v2, + v3 = this.v3; + + point.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y), CubicBezier(t, v0.z, v1.z, v2.z, v3.z)); + + return point; + } + + copy(source) { + super.copy(source); + + this.v0.copy(source.v0); + this.v1.copy(source.v1); + this.v2.copy(source.v2); + this.v3.copy(source.v3); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + data.v3 = this.v3.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.v0.fromArray(json.v0); + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + this.v3.fromArray(json.v3); + + return this; + } +} + +CubicBezierCurve3.prototype.isCubicBezierCurve3 = true; + +export { CubicBezierCurve3 }; diff --git a/backend/libs/three/extras/curves/Curves.d.ts b/backend/libs/three/extras/curves/Curves.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e89592bc676cff9f1397ef1f81d1eac6e1e66d5f --- /dev/null +++ b/backend/libs/three/extras/curves/Curves.d.ts @@ -0,0 +1,10 @@ +export * from './ArcCurve'; +export * from './CatmullRomCurve3'; +export * from './CubicBezierCurve'; +export * from './CubicBezierCurve3'; +export * from './EllipseCurve'; +export * from './LineCurve'; +export * from './LineCurve3'; +export * from './QuadraticBezierCurve'; +export * from './QuadraticBezierCurve3'; +export * from './SplineCurve'; diff --git a/backend/libs/three/extras/curves/Curves.js b/backend/libs/three/extras/curves/Curves.js new file mode 100644 index 0000000000000000000000000000000000000000..c984a853942011a89bcd2add1be38392c751a639 --- /dev/null +++ b/backend/libs/three/extras/curves/Curves.js @@ -0,0 +1,10 @@ +export { ArcCurve } from './ArcCurve.js'; +export { CatmullRomCurve3 } from './CatmullRomCurve3.js'; +export { CubicBezierCurve } from './CubicBezierCurve.js'; +export { CubicBezierCurve3 } from './CubicBezierCurve3.js'; +export { EllipseCurve } from './EllipseCurve.js'; +export { LineCurve } from './LineCurve.js'; +export { LineCurve3 } from './LineCurve3.js'; +export { QuadraticBezierCurve } from './QuadraticBezierCurve.js'; +export { QuadraticBezierCurve3 } from './QuadraticBezierCurve3.js'; +export { SplineCurve } from './SplineCurve.js'; diff --git a/backend/libs/three/extras/curves/EllipseCurve.d.ts b/backend/libs/three/extras/curves/EllipseCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ef32ab7d2065f756696feaceb87042c3b70ab44f --- /dev/null +++ b/backend/libs/three/extras/curves/EllipseCurve.d.ts @@ -0,0 +1,51 @@ +import { Curve } from './../core/Curve'; +import { Vector2 } from '../../math/Vector2'; + +export class EllipseCurve extends Curve { + constructor(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean, aRotation: number); + + /** + * @default 'EllipseCurve' + */ + type: string; + + /** + * @default 0 + */ + aX: number; + + /** + * @default 0 + */ + aY: number; + + /** + * @default 1 + */ + xRadius: number; + + /** + * @default 1 + */ + yRadius: number; + + /** + * @default 0 + */ + aStartAngle: number; + + /** + * @default 2 * Math.PI + */ + aEndAngle: number; + + /** + * @default false + */ + aClockwise: boolean; + + /** + * @default 0 + */ + aRotation: number; +} diff --git a/backend/libs/three/extras/curves/EllipseCurve.js b/backend/libs/three/extras/curves/EllipseCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..fe589ece93c3243bda55b60d3589f439a2445e33 --- /dev/null +++ b/backend/libs/three/extras/curves/EllipseCurve.js @@ -0,0 +1,130 @@ +import { Curve } from '../core/Curve.js'; +import { Vector2 } from '../../math/Vector2.js'; + +class EllipseCurve extends Curve { + constructor(aX = 0, aY = 0, xRadius = 1, yRadius = 1, aStartAngle = 0, aEndAngle = Math.PI * 2, aClockwise = false, aRotation = 0) { + super(); + + this.type = 'EllipseCurve'; + + this.aX = aX; + this.aY = aY; + + this.xRadius = xRadius; + this.yRadius = yRadius; + + this.aStartAngle = aStartAngle; + this.aEndAngle = aEndAngle; + + this.aClockwise = aClockwise; + + this.aRotation = aRotation; + } + + getPoint(t, optionalTarget) { + const point = optionalTarget || new Vector2(); + + const twoPi = Math.PI * 2; + let deltaAngle = this.aEndAngle - this.aStartAngle; + const samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) deltaAngle += twoPi; + while (deltaAngle > twoPi) deltaAngle -= twoPi; + + if (deltaAngle < Number.EPSILON) { + if (samePoints) { + deltaAngle = 0; + } else { + deltaAngle = twoPi; + } + } + + if (this.aClockwise === true && !samePoints) { + if (deltaAngle === twoPi) { + deltaAngle = -twoPi; + } else { + deltaAngle = deltaAngle - twoPi; + } + } + + const angle = this.aStartAngle + t * deltaAngle; + let x = this.aX + this.xRadius * Math.cos(angle); + let y = this.aY + this.yRadius * Math.sin(angle); + + if (this.aRotation !== 0) { + const cos = Math.cos(this.aRotation); + const sin = Math.sin(this.aRotation); + + const tx = x - this.aX; + const ty = y - this.aY; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.aX; + y = tx * sin + ty * cos + this.aY; + } + + return point.set(x, y); + } + + copy(source) { + super.copy(source); + + this.aX = source.aX; + this.aY = source.aY; + + this.xRadius = source.xRadius; + this.yRadius = source.yRadius; + + this.aStartAngle = source.aStartAngle; + this.aEndAngle = source.aEndAngle; + + this.aClockwise = source.aClockwise; + + this.aRotation = source.aRotation; + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.aX = this.aX; + data.aY = this.aY; + + data.xRadius = this.xRadius; + data.yRadius = this.yRadius; + + data.aStartAngle = this.aStartAngle; + data.aEndAngle = this.aEndAngle; + + data.aClockwise = this.aClockwise; + + data.aRotation = this.aRotation; + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.aX = json.aX; + this.aY = json.aY; + + this.xRadius = json.xRadius; + this.yRadius = json.yRadius; + + this.aStartAngle = json.aStartAngle; + this.aEndAngle = json.aEndAngle; + + this.aClockwise = json.aClockwise; + + this.aRotation = json.aRotation; + + return this; + } +} + +EllipseCurve.prototype.isEllipseCurve = true; + +export { EllipseCurve }; diff --git a/backend/libs/three/extras/curves/LineCurve.d.ts b/backend/libs/three/extras/curves/LineCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..028b50d0e16ce4a6d2fa9f6ffbf48b04c95e9e41 --- /dev/null +++ b/backend/libs/three/extras/curves/LineCurve.d.ts @@ -0,0 +1,21 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class LineCurve extends Curve { + constructor(v1: Vector2, v2: Vector2); + + /** + * @default 'LineCurve' + */ + type: string; + + /** + * @default new THREE.Vector2() + */ + v1: Vector2; + + /** + * @default new THREE.Vector2() + */ + v2: Vector2; +} diff --git a/backend/libs/three/extras/curves/LineCurve.js b/backend/libs/three/extras/curves/LineCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..8c5b6247ba38d80c7b92f99e07d3e2032474aafd --- /dev/null +++ b/backend/libs/three/extras/curves/LineCurve.js @@ -0,0 +1,70 @@ +import { Vector2 } from '../../math/Vector2.js'; +import { Curve } from '../core/Curve.js'; + +class LineCurve extends Curve { + constructor(v1 = new Vector2(), v2 = new Vector2()) { + super(); + + this.type = 'LineCurve'; + + this.v1 = v1; + this.v2 = v2; + } + + getPoint(t, optionalTarget = new Vector2()) { + const point = optionalTarget; + + if (t === 1) { + point.copy(this.v2); + } else { + point.copy(this.v2).sub(this.v1); + point.multiplyScalar(t).add(this.v1); + } + + return point; + } + + // Line curve is linear, so we can overwrite default getPointAt + getPointAt(u, optionalTarget) { + return this.getPoint(u, optionalTarget); + } + + getTangent(t, optionalTarget) { + const tangent = optionalTarget || new Vector2(); + + tangent.copy(this.v2).sub(this.v1).normalize(); + + return tangent; + } + + copy(source) { + super.copy(source); + + this.v1.copy(source.v1); + this.v2.copy(source.v2); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + + return this; + } +} + +LineCurve.prototype.isLineCurve = true; + +export { LineCurve }; diff --git a/backend/libs/three/extras/curves/LineCurve3.d.ts b/backend/libs/three/extras/curves/LineCurve3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8cd06871ea907f7b06df4f2cf0134f816ec6ccc3 --- /dev/null +++ b/backend/libs/three/extras/curves/LineCurve3.d.ts @@ -0,0 +1,21 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class LineCurve3 extends Curve { + constructor(v1: Vector3, v2: Vector3); + + /** + * @default 'LineCurve3' + */ + type: string; + + /** + * @default new THREE.Vector3() + */ + v1: Vector3; + + /** + * @default new THREE.Vector3() + */ + v2: Vector3; +} diff --git a/backend/libs/three/extras/curves/LineCurve3.js b/backend/libs/three/extras/curves/LineCurve3.js new file mode 100644 index 0000000000000000000000000000000000000000..52b025b84b078b0a3252eab38c28ac09e4de9d90 --- /dev/null +++ b/backend/libs/three/extras/curves/LineCurve3.js @@ -0,0 +1,56 @@ +import { Vector3 } from '../../math/Vector3.js'; +import { Curve } from '../core/Curve.js'; + +class LineCurve3 extends Curve { + constructor(v1 = new Vector3(), v2 = new Vector3()) { + super(); + + this.type = 'LineCurve3'; + this.isLineCurve3 = true; + + this.v1 = v1; + this.v2 = v2; + } + getPoint(t, optionalTarget = new Vector3()) { + const point = optionalTarget; + + if (t === 1) { + point.copy(this.v2); + } else { + point.copy(this.v2).sub(this.v1); + point.multiplyScalar(t).add(this.v1); + } + + return point; + } + // Line curve is linear, so we can overwrite default getPointAt + getPointAt(u, optionalTarget) { + return this.getPoint(u, optionalTarget); + } + copy(source) { + super.copy(source); + + this.v1.copy(source.v1); + this.v2.copy(source.v2); + + return this; + } + toJSON() { + const data = super.toJSON(); + + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + } + fromJSON(json) { + super.fromJSON(json); + + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + + return this; + } +} + +export { LineCurve3 }; diff --git a/backend/libs/three/extras/curves/QuadraticBezierCurve.d.ts b/backend/libs/three/extras/curves/QuadraticBezierCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b162ac7f8e4f76609755852b75d6427601b76458 --- /dev/null +++ b/backend/libs/three/extras/curves/QuadraticBezierCurve.d.ts @@ -0,0 +1,26 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class QuadraticBezierCurve extends Curve { + constructor(v0: Vector2, v1: Vector2, v2: Vector2); + + /** + * @default 'QuadraticBezierCurve' + */ + type: string; + + /** + * @default new THREE.Vector2() + */ + v0: Vector2; + + /** + * @default new THREE.Vector2() + */ + v1: Vector2; + + /** + * @default new THREE.Vector2() + */ + v2: Vector2; +} diff --git a/backend/libs/three/extras/curves/QuadraticBezierCurve.js b/backend/libs/three/extras/curves/QuadraticBezierCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..a35282d6b9c5c1ea655c36e0db1095a7a8220439 --- /dev/null +++ b/backend/libs/three/extras/curves/QuadraticBezierCurve.js @@ -0,0 +1,61 @@ +import { Curve } from '../core/Curve.js'; +import { QuadraticBezier } from '../core/Interpolations.js'; +import { Vector2 } from '../../math/Vector2.js'; + +class QuadraticBezierCurve extends Curve { + constructor(v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2()) { + super(); + + this.type = 'QuadraticBezierCurve'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + } + + getPoint(t, optionalTarget = new Vector2()) { + const point = optionalTarget; + + const v0 = this.v0, + v1 = this.v1, + v2 = this.v2; + + point.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y)); + + return point; + } + + copy(source) { + super.copy(source); + + this.v0.copy(source.v0); + this.v1.copy(source.v1); + this.v2.copy(source.v2); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.v0.fromArray(json.v0); + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + + return this; + } +} + +QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true; + +export { QuadraticBezierCurve }; diff --git a/backend/libs/three/extras/curves/QuadraticBezierCurve3.d.ts b/backend/libs/three/extras/curves/QuadraticBezierCurve3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..32583fa958cdbc57d89ac8c7a44413245f9d77ed --- /dev/null +++ b/backend/libs/three/extras/curves/QuadraticBezierCurve3.d.ts @@ -0,0 +1,26 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class QuadraticBezierCurve3 extends Curve { + constructor(v0: Vector3, v1: Vector3, v2: Vector3); + + /** + * @default 'QuadraticBezierCurve3' + */ + type: string; + + /** + * @default new THREE.Vector3() + */ + v0: Vector3; + + /** + * @default new THREE.Vector3() + */ + v1: Vector3; + + /** + * @default new THREE.Vector3() + */ + v2: Vector3; +} diff --git a/backend/libs/three/extras/curves/QuadraticBezierCurve3.js b/backend/libs/three/extras/curves/QuadraticBezierCurve3.js new file mode 100644 index 0000000000000000000000000000000000000000..07b0ca7b463edab4dfb89e9eb33d7298ecded28c --- /dev/null +++ b/backend/libs/three/extras/curves/QuadraticBezierCurve3.js @@ -0,0 +1,61 @@ +import { Curve } from '../core/Curve.js'; +import { QuadraticBezier } from '../core/Interpolations.js'; +import { Vector3 } from '../../math/Vector3.js'; + +class QuadraticBezierCurve3 extends Curve { + constructor(v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3()) { + super(); + + this.type = 'QuadraticBezierCurve3'; + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + } + + getPoint(t, optionalTarget = new Vector3()) { + const point = optionalTarget; + + const v0 = this.v0, + v1 = this.v1, + v2 = this.v2; + + point.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y), QuadraticBezier(t, v0.z, v1.z, v2.z)); + + return point; + } + + copy(source) { + super.copy(source); + + this.v0.copy(source.v0); + this.v1.copy(source.v1); + this.v2.copy(source.v2); + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.v0 = this.v0.toArray(); + data.v1 = this.v1.toArray(); + data.v2 = this.v2.toArray(); + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.v0.fromArray(json.v0); + this.v1.fromArray(json.v1); + this.v2.fromArray(json.v2); + + return this; + } +} + +QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true; + +export { QuadraticBezierCurve3 }; diff --git a/backend/libs/three/extras/curves/SplineCurve.d.ts b/backend/libs/three/extras/curves/SplineCurve.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1d478df2ae1984d36864f06c928b7b680b03f07d --- /dev/null +++ b/backend/libs/three/extras/curves/SplineCurve.d.ts @@ -0,0 +1,16 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class SplineCurve extends Curve { + constructor(points?: Vector2[]); + + /** + * @default 'SplineCurve' + */ + type: string; + + /** + * @default [] + */ + points: Vector2[]; +} diff --git a/backend/libs/three/extras/curves/SplineCurve.js b/backend/libs/three/extras/curves/SplineCurve.js new file mode 100644 index 0000000000000000000000000000000000000000..0604a8536372b20ab9c94263695e4178244af8a4 --- /dev/null +++ b/backend/libs/three/extras/curves/SplineCurve.js @@ -0,0 +1,76 @@ +import { Curve } from '../core/Curve.js'; +import { CatmullRom } from '../core/Interpolations.js'; +import { Vector2 } from '../../math/Vector2.js'; + +class SplineCurve extends Curve { + constructor(points = []) { + super(); + + this.type = 'SplineCurve'; + + this.points = points; + } + + getPoint(t, optionalTarget = new Vector2()) { + const point = optionalTarget; + + const points = this.points; + const p = (points.length - 1) * t; + + const intPoint = Math.floor(p); + const weight = p - intPoint; + + const p0 = points[intPoint === 0 ? intPoint : intPoint - 1]; + const p1 = points[intPoint]; + const p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1]; + const p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2]; + + point.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + + return point; + } + + copy(source) { + super.copy(source); + + this.points = []; + + for (let i = 0, l = source.points.length; i < l; i++) { + const point = source.points[i]; + + this.points.push(point.clone()); + } + + return this; + } + + toJSON() { + const data = super.toJSON(); + + data.points = []; + + for (let i = 0, l = this.points.length; i < l; i++) { + const point = this.points[i]; + data.points.push(point.toArray()); + } + + return data; + } + + fromJSON(json) { + super.fromJSON(json); + + this.points = []; + + for (let i = 0, l = json.points.length; i < l; i++) { + const point = json.points[i]; + this.points.push(new Vector2().fromArray(point)); + } + + return this; + } +} + +SplineCurve.prototype.isSplineCurve = true; + +export { SplineCurve }; diff --git a/backend/libs/three/geometries/BoxGeometry.d.ts b/backend/libs/three/geometries/BoxGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..887825d6d3efaeb46a373fc52147e054820b12c3 --- /dev/null +++ b/backend/libs/three/geometries/BoxGeometry.d.ts @@ -0,0 +1,31 @@ +import { BufferGeometry } from '../core/BufferGeometry'; + +export class BoxGeometry extends BufferGeometry { + /** + * @param [width=1] — Width of the sides on the X axis. + * @param [height=1] — Height of the sides on the Y axis. + * @param [depth=1] — Depth of the sides on the Z axis. + * @param [widthSegments=1] — Number of segmented faces along the width of the sides. + * @param [heightSegments=1] — Number of segmented faces along the height of the sides. + * @param [depthSegments=1] — Number of segmented faces along the depth of the sides. + */ + constructor(width?: number, height?: number, depth?: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); + + /** + * @default 'BoxGeometry' + */ + type: string; + + parameters: { + width: number; + height: number; + depth: number; + widthSegments: number; + heightSegments: number; + depthSegments: number; + }; + + static fromJSON(data: any): BoxGeometry; +} + +export { BoxGeometry as BoxBufferGeometry }; diff --git a/backend/libs/three/geometries/BoxGeometry.js b/backend/libs/three/geometries/BoxGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..805cd90fb4974fe564257e53754240ec6ff35787 --- /dev/null +++ b/backend/libs/three/geometries/BoxGeometry.js @@ -0,0 +1,154 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; + +class BoxGeometry extends BufferGeometry { + constructor(width = 1, height = 1, depth = 1, widthSegments = 1, heightSegments = 1, depthSegments = 1) { + super(); + + this.type = 'BoxGeometry'; + + this.parameters = { + width: width, + height: height, + depth: depth, + widthSegments: widthSegments, + heightSegments: heightSegments, + depthSegments: depthSegments, + }; + + const scope = this; + + // segments + + widthSegments = Math.floor(widthSegments); + heightSegments = Math.floor(heightSegments); + depthSegments = Math.floor(depthSegments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let numberOfVertices = 0; + let groupStart = 0; + + // build each side of the box geometry + + buildPlane('z', 'y', 'x', -1, -1, depth, height, width, depthSegments, heightSegments, 0); // px + buildPlane('z', 'y', 'x', 1, -1, depth, height, -width, depthSegments, heightSegments, 1); // nx + buildPlane('x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2); // py + buildPlane('x', 'z', 'y', 1, -1, width, depth, -height, widthSegments, depthSegments, 3); // ny + buildPlane('x', 'y', 'z', 1, -1, width, height, depth, widthSegments, heightSegments, 4); // pz + buildPlane('x', 'y', 'z', -1, -1, width, height, -depth, widthSegments, heightSegments, 5); // nz + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + + function buildPlane(u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex) { + const segmentWidth = width / gridX; + const segmentHeight = height / gridY; + + const widthHalf = width / 2; + const heightHalf = height / 2; + const depthHalf = depth / 2; + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + let vertexCounter = 0; + let groupCount = 0; + + const vector = new Vector3(); + + // generate vertices, normals and uvs + + for (let iy = 0; iy < gridY1; iy++) { + const y = iy * segmentHeight - heightHalf; + + for (let ix = 0; ix < gridX1; ix++) { + const x = ix * segmentWidth - widthHalf; + + // set values to correct vector component + + vector[u] = x * udir; + vector[v] = y * vdir; + vector[w] = depthHalf; + + // now apply vector to vertex buffer + + vertices.push(vector.x, vector.y, vector.z); + + // set values to correct vector component + + vector[u] = 0; + vector[v] = 0; + vector[w] = depth > 0 ? 1 : -1; + + // now apply vector to normal buffer + + normals.push(vector.x, vector.y, vector.z); + + // uvs + + uvs.push(ix / gridX); + uvs.push(1 - iy / gridY); + + // counters + + vertexCounter += 1; + } + } + + // indices + + // 1. you need three indices to draw a single face + // 2. a single segment consists of two faces + // 3. so we need to generate six (2*3) indices per segment + + for (let iy = 0; iy < gridY; iy++) { + for (let ix = 0; ix < gridX; ix++) { + const a = numberOfVertices + ix + gridX1 * iy; + const b = numberOfVertices + ix + gridX1 * (iy + 1); + const c = numberOfVertices + (ix + 1) + gridX1 * (iy + 1); + const d = numberOfVertices + (ix + 1) + gridX1 * iy; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + + // increase counter + + groupCount += 6; + } + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup(groupStart, groupCount, materialIndex); + + // calculate new start value for groups + + groupStart += groupCount; + + // update total number of vertices + + numberOfVertices += vertexCounter; + } + } + + static fromJSON(data) { + return new BoxGeometry(data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments); + } +} + +export { BoxGeometry, BoxGeometry as BoxBufferGeometry }; diff --git a/backend/libs/three/geometries/CapsuleGeometry.d.ts b/backend/libs/three/geometries/CapsuleGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d7f577849bf6660b6ebd47781d5302b34c8e12a2 --- /dev/null +++ b/backend/libs/three/geometries/CapsuleGeometry.d.ts @@ -0,0 +1,27 @@ +import { BufferGeometry } from '../core/BufferGeometry'; + +export class CapsuleGeometry extends BufferGeometry { + /** + * @param [radius=1] — Radius of the capsule. + * @param [length=1] — Length of the middle section. + * @param [capSegments=4] — Number of curve segments used to build the caps. + * @param [radialSegments=8] — Number of segmented faces around the circumference of the capsule. + */ + constructor(radius?: number, length?: number, capSegments?: number, radialSegments?: number); + + /** + * @default 'CapsuleGeometry' + */ + type: string; + + parameters: { + radius: number; + length: number; + capSegments: number; + radialSegments: number; + }; + + static fromJSON(data: any): CapsuleGeometry; +} + +export { CapsuleGeometry as CapsuleBufferGeometry }; diff --git a/backend/libs/three/geometries/CircleGeometry.d.ts b/backend/libs/three/geometries/CircleGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..af59efecdbd61aaf51aa7b1e6aa477d335d495a6 --- /dev/null +++ b/backend/libs/three/geometries/CircleGeometry.d.ts @@ -0,0 +1,27 @@ +import { BufferGeometry } from '../core/BufferGeometry'; + +export class CircleGeometry extends BufferGeometry { + /** + * @param [radius=1] + * @param [segments=8] + * @param [thetaStart=0] + * @param [thetaLength=Math.PI * 2] + */ + constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); + + /** + * @default 'CircleGeometry' + */ + type: string; + + parameters: { + radius: number; + segments: number; + thetaStart: number; + thetaLength: number; + }; + + static fromJSON(data: any): CircleGeometry; +} + +export { CircleGeometry as CircleBufferGeometry }; diff --git a/backend/libs/three/geometries/CircleGeometry.js b/backend/libs/three/geometries/CircleGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..0b7d3f1a41f05363ebabb05d7dc8b7f43e4e52d0 --- /dev/null +++ b/backend/libs/three/geometries/CircleGeometry.js @@ -0,0 +1,80 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; + +class CircleGeometry extends BufferGeometry { + constructor(radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2) { + super(); + + this.type = 'CircleGeometry'; + + this.parameters = { + radius: radius, + segments: segments, + thetaStart: thetaStart, + thetaLength: thetaLength, + }; + + segments = Math.max(3, segments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const vertex = new Vector3(); + const uv = new Vector2(); + + // center point + + vertices.push(0, 0, 0); + normals.push(0, 0, 1); + uvs.push(0.5, 0.5); + + for (let s = 0, i = 3; s <= segments; s++, i += 3) { + const segment = thetaStart + (s / segments) * thetaLength; + + // vertex + + vertex.x = radius * Math.cos(segment); + vertex.y = radius * Math.sin(segment); + + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + normals.push(0, 0, 1); + + // uvs + + uv.x = (vertices[i] / radius + 1) / 2; + uv.y = (vertices[i + 1] / radius + 1) / 2; + + uvs.push(uv.x, uv.y); + } + + // indices + + for (let i = 1; i <= segments; i++) { + indices.push(i, i + 1, 0); + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + } + + static fromJSON(data) { + return new CircleGeometry(data.radius, data.segments, data.thetaStart, data.thetaLength); + } +} + +export { CircleGeometry, CircleGeometry as CircleBufferGeometry }; diff --git a/backend/libs/three/geometries/ConeGeometry.d.ts b/backend/libs/three/geometries/ConeGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..bdf760222e2e53928da7a8b6d96828333b15bd6b --- /dev/null +++ b/backend/libs/three/geometries/ConeGeometry.d.ts @@ -0,0 +1,31 @@ +import { CylinderGeometry } from './CylinderGeometry'; + +export class ConeGeometry extends CylinderGeometry { + /** + * @param [radius=1] — Radius of the cone base. + * @param [height=1] — Height of the cone. + * @param [radialSegments=8] — Number of segmented faces around the circumference of the cone. + * @param [heightSegments=1] — Number of rows of faces along the height of the cone. + * @param [openEnded=false] — A Boolean indicating whether the base of the cone is open or capped. + * @param [thetaStart=0] + * @param [thetaLength=Math.PI * 2] + */ + constructor( + radius?: number, + height?: number, + radialSegments?: number, + heightSegments?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); + + /** + * @default 'ConeGeometry' + */ + type: string; + + static fromJSON(data: any): ConeGeometry; +} + +export { ConeGeometry as ConeBufferGeometry }; diff --git a/backend/libs/three/geometries/ConeGeometry.js b/backend/libs/three/geometries/ConeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..683fd1d73b507db51ebafa131ff72388009de7b0 --- /dev/null +++ b/backend/libs/three/geometries/ConeGeometry.js @@ -0,0 +1,25 @@ +import { CylinderGeometry } from './CylinderGeometry.js'; + +class ConeGeometry extends CylinderGeometry { + constructor(radius = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2) { + super(0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength); + + this.type = 'ConeGeometry'; + + this.parameters = { + radius: radius, + height: height, + radialSegments: radialSegments, + heightSegments: heightSegments, + openEnded: openEnded, + thetaStart: thetaStart, + thetaLength: thetaLength, + }; + } + + static fromJSON(data) { + return new ConeGeometry(data.radius, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength); + } +} + +export { ConeGeometry, ConeGeometry as ConeBufferGeometry }; diff --git a/backend/libs/three/geometries/CylinderGeometry.d.ts b/backend/libs/three/geometries/CylinderGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7ab3fd48d78cfe1dbe974c35131e7c3a590a9fb3 --- /dev/null +++ b/backend/libs/three/geometries/CylinderGeometry.d.ts @@ -0,0 +1,44 @@ +import { BufferGeometry } from '../core/BufferGeometry'; + +export class CylinderGeometry extends BufferGeometry { + /** + * @param [radiusTop=1] — Radius of the cylinder at the top. + * @param [radiusBottom=1] — Radius of the cylinder at the bottom. + * @param [height=1] — Height of the cylinder. + * @param [radialSegments=8] — Number of segmented faces around the circumference of the cylinder. + * @param [heightSegments=1] — Number of rows of faces along the height of the cylinder. + * @param [openEnded=false] - A Boolean indicating whether or not to cap the ends of the cylinder. + * @param [thetaStart=0] + * @param [thetaLength=Math.PI * 2] + */ + constructor( + radiusTop?: number, + radiusBottom?: number, + height?: number, + radialSegments?: number, + heightSegments?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); + + /** + * @default 'CylinderGeometry' + */ + type: string; + + parameters: { + radiusTop: number; + radiusBottom: number; + height: number; + radialSegments: number; + heightSegments: number; + openEnded: boolean; + thetaStart: number; + thetaLength: number; + }; + + static fromJSON(data: any): CylinderGeometry; +} + +export { CylinderGeometry as CylinderBufferGeometry }; diff --git a/backend/libs/three/geometries/CylinderGeometry.js b/backend/libs/three/geometries/CylinderGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..9ebeb7cda086e451f9e9432beed3e1528ef74800 --- /dev/null +++ b/backend/libs/three/geometries/CylinderGeometry.js @@ -0,0 +1,262 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; + +class CylinderGeometry extends BufferGeometry { + constructor( + radiusTop = 1, + radiusBottom = 1, + height = 1, + radialSegments = 8, + heightSegments = 1, + openEnded = false, + thetaStart = 0, + thetaLength = Math.PI * 2 + ) { + super(); + this.type = 'CylinderGeometry'; + + this.parameters = { + radiusTop: radiusTop, + radiusBottom: radiusBottom, + height: height, + radialSegments: radialSegments, + heightSegments: heightSegments, + openEnded: openEnded, + thetaStart: thetaStart, + thetaLength: thetaLength, + }; + + const scope = this; + + radialSegments = Math.floor(radialSegments); + heightSegments = Math.floor(heightSegments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let index = 0; + const indexArray = []; + const halfHeight = height / 2; + let groupStart = 0; + + // generate geometry + + generateTorso(); + + if (openEnded === false) { + if (radiusTop > 0) generateCap(true); + if (radiusBottom > 0) generateCap(false); + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + + function generateTorso() { + const normal = new Vector3(); + const vertex = new Vector3(); + + let groupCount = 0; + + // this will be used to calculate the normal + const slope = (radiusBottom - radiusTop) / height; + + // generate vertices, normals and uvs + + for (let y = 0; y <= heightSegments; y++) { + const indexRow = []; + + const v = y / heightSegments; + + // calculate the radius of the current row + + const radius = v * (radiusBottom - radiusTop) + radiusTop; + + for (let x = 0; x <= radialSegments; x++) { + const u = x / radialSegments; + + const theta = u * thetaLength + thetaStart; + + const sinTheta = Math.sin(theta); + const cosTheta = Math.cos(theta); + + // vertex + + vertex.x = radius * sinTheta; + vertex.y = -v * height + halfHeight; + vertex.z = radius * cosTheta; + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + normal.set(sinTheta, slope, cosTheta).normalize(); + normals.push(normal.x, normal.y, normal.z); + + // uv + + uvs.push(u, 1 - v); + + // save index of vertex in respective row + + indexRow.push(index++); + } + + // now save vertices of the row in our index array + + indexArray.push(indexRow); + } + + // generate indices + + for (let x = 0; x < radialSegments; x++) { + for (let y = 0; y < heightSegments; y++) { + // we use the index array to access the correct indices + + const a = indexArray[y][x]; + const b = indexArray[y + 1][x]; + const c = indexArray[y + 1][x + 1]; + const d = indexArray[y][x + 1]; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + + // update group counter + + groupCount += 6; + } + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup(groupStart, groupCount, 0); + + // calculate new start value for groups + + groupStart += groupCount; + } + + function generateCap(top) { + // save the index of the first center vertex + const centerIndexStart = index; + + const uv = new Vector2(); + const vertex = new Vector3(); + + let groupCount = 0; + + const radius = top === true ? radiusTop : radiusBottom; + const sign = top === true ? 1 : -1; + + // first we generate the center vertex data of the cap. + // because the geometry needs one set of uvs per face, + // we must generate a center vertex per face/segment + + for (let x = 1; x <= radialSegments; x++) { + // vertex + + vertices.push(0, halfHeight * sign, 0); + + // normal + + normals.push(0, sign, 0); + + // uv + + uvs.push(0.5, 0.5); + + // increase index + + index++; + } + + // save the index of the last center vertex + const centerIndexEnd = index; + + // now we generate the surrounding vertices, normals and uvs + + for (let x = 0; x <= radialSegments; x++) { + const u = x / radialSegments; + const theta = u * thetaLength + thetaStart; + + const cosTheta = Math.cos(theta); + const sinTheta = Math.sin(theta); + + // vertex + + vertex.x = radius * sinTheta; + vertex.y = halfHeight * sign; + vertex.z = radius * cosTheta; + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + normals.push(0, sign, 0); + + // uv + + uv.x = cosTheta * 0.5 + 0.5; + uv.y = sinTheta * 0.5 * sign + 0.5; + uvs.push(uv.x, uv.y); + + // increase index + + index++; + } + + // generate indices + + for (let x = 0; x < radialSegments; x++) { + const c = centerIndexStart + x; + const i = centerIndexEnd + x; + + if (top === true) { + // face top + + indices.push(i, i + 1, c); + } else { + // face bottom + + indices.push(i + 1, i, c); + } + + groupCount += 3; + } + + // add a group to the geometry. this will ensure multi material support + + scope.addGroup(groupStart, groupCount, top === true ? 1 : 2); + + // calculate new start value for groups + + groupStart += groupCount; + } + } + + static fromJSON(data) { + return new CylinderGeometry( + data.radiusTop, + data.radiusBottom, + data.height, + data.radialSegments, + data.heightSegments, + data.openEnded, + data.thetaStart, + data.thetaLength + ); + } +} + +export { CylinderGeometry, CylinderGeometry as CylinderBufferGeometry }; diff --git a/backend/libs/three/geometries/DodecahedronGeometry.d.ts b/backend/libs/three/geometries/DodecahedronGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fdbb403b6ba328a488ff7100dedb4612a70daadb --- /dev/null +++ b/backend/libs/three/geometries/DodecahedronGeometry.d.ts @@ -0,0 +1,18 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry'; + +export class DodecahedronGeometry extends PolyhedronGeometry { + /** + * @param [radius=1] + * @param [detail=0] + */ + constructor(radius?: number, detail?: number); + + /** + * @default 'DodecahedronGeometry' + */ + type: string; + + static fromJSON(data: any): DodecahedronGeometry; +} + +export { DodecahedronGeometry as DodecahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/DodecahedronGeometry.js b/backend/libs/three/geometries/DodecahedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..3c1fc23415a8d8ae70b3f177bdca605c5ebd0efd --- /dev/null +++ b/backend/libs/three/geometries/DodecahedronGeometry.js @@ -0,0 +1,99 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry.js'; + +class DodecahedronGeometry extends PolyhedronGeometry { + constructor(radius = 1, detail = 0) { + const t = (1 + Math.sqrt(5)) / 2; + const r = 1 / t; + + const vertices = [ + // (±1, ±1, ±1) + -1, + -1, + -1, + -1, + -1, + 1, + -1, + 1, + -1, + -1, + 1, + 1, + 1, + -1, + -1, + 1, + -1, + 1, + 1, + 1, + -1, + 1, + 1, + 1, + + // (0, ±1/φ, ±φ) + 0, + -r, + -t, + 0, + -r, + t, + 0, + r, + -t, + 0, + r, + t, + + // (±1/φ, ±φ, 0) + -r, + -t, + 0, + -r, + t, + 0, + r, + -t, + 0, + r, + t, + 0, + + // (±φ, 0, ±1/φ) + -t, + 0, + -r, + t, + 0, + -r, + -t, + 0, + r, + t, + 0, + r, + ]; + + const indices = [ + 3, 11, 7, 3, 7, 15, 3, 15, 13, 7, 19, 17, 7, 17, 6, 7, 6, 15, 17, 4, 8, 17, 8, 10, 17, 10, 6, 8, 0, 16, 8, 16, 2, 8, 2, 10, 0, 12, 1, 0, 1, 18, 0, + 18, 16, 6, 10, 2, 6, 2, 13, 6, 13, 15, 2, 16, 18, 2, 18, 3, 2, 3, 13, 18, 1, 9, 18, 9, 11, 18, 11, 3, 4, 14, 12, 4, 12, 0, 4, 0, 8, 11, 9, 5, 11, 5, + 19, 11, 19, 7, 19, 5, 14, 19, 14, 4, 19, 4, 17, 1, 12, 14, 1, 14, 5, 1, 5, 9, + ]; + + super(vertices, indices, radius, detail); + + this.type = 'DodecahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail, + }; + } + + static fromJSON(data) { + return new DodecahedronGeometry(data.radius, data.detail); + } +} + +export { DodecahedronGeometry, DodecahedronGeometry as DodecahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/EdgesGeometry.d.ts b/backend/libs/three/geometries/EdgesGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7bacae187d909225f3e7bdb8ac7784aa4eb1d8b4 --- /dev/null +++ b/backend/libs/three/geometries/EdgesGeometry.d.ts @@ -0,0 +1,19 @@ +import { BufferGeometry } from '../core/BufferGeometry'; + +export class EdgesGeometry extends BufferGeometry { + /** + * @param geometry + * @param [thresholdAngle=1] + */ + constructor(geometry?: TBufferGeometry, thresholdAngle?: number); + + /** + * @default 'EdgesGeometry' + */ + type: string; + + parameters: { + geometry: TBufferGeometry; + thresholdAngle: number; + }; +} diff --git a/backend/libs/three/geometries/EdgesGeometry.js b/backend/libs/three/geometries/EdgesGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..0048fda7cc33b5c889f3ffde9b0c1d241056c431 --- /dev/null +++ b/backend/libs/three/geometries/EdgesGeometry.js @@ -0,0 +1,113 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { Triangle } from '../math/Triangle.js'; +import { Vector3 } from '../math/Vector3.js'; + +const _v0 = new Vector3(); +const _v1 = new Vector3(); +const _normal = new Vector3(); +const _triangle = new Triangle(); + +class EdgesGeometry extends BufferGeometry { + constructor(geometry = null, thresholdAngle = 1) { + super(); + this.type = 'EdgesGeometry'; + + this.parameters = { + geometry: geometry, + thresholdAngle: thresholdAngle, + }; + + if (geometry !== null) { + const precisionPoints = 4; + const precision = Math.pow(10, precisionPoints); + const thresholdDot = Math.cos(MathUtils.DEG2RAD * thresholdAngle); + + const indexAttr = geometry.getIndex(); + const positionAttr = geometry.getAttribute('position'); + const indexCount = indexAttr ? indexAttr.count : positionAttr.count; + + const indexArr = [0, 0, 0]; + const vertKeys = ['a', 'b', 'c']; + const hashes = new Array(3); + + const edgeData = {}; + const vertices = []; + for (let i = 0; i < indexCount; i += 3) { + if (indexAttr) { + indexArr[0] = indexAttr.getX(i); + indexArr[1] = indexAttr.getX(i + 1); + indexArr[2] = indexAttr.getX(i + 2); + } else { + indexArr[0] = i; + indexArr[1] = i + 1; + indexArr[2] = i + 2; + } + + const { a, b, c } = _triangle; + a.fromBufferAttribute(positionAttr, indexArr[0]); + b.fromBufferAttribute(positionAttr, indexArr[1]); + c.fromBufferAttribute(positionAttr, indexArr[2]); + _triangle.getNormal(_normal); + + // create hashes for the edge from the vertices + hashes[0] = `${Math.round(a.x * precision)},${Math.round(a.y * precision)},${Math.round(a.z * precision)}`; + hashes[1] = `${Math.round(b.x * precision)},${Math.round(b.y * precision)},${Math.round(b.z * precision)}`; + hashes[2] = `${Math.round(c.x * precision)},${Math.round(c.y * precision)},${Math.round(c.z * precision)}`; + + // skip degenerate triangles + if (hashes[0] === hashes[1] || hashes[1] === hashes[2] || hashes[2] === hashes[0]) { + continue; + } + + // iterate over every edge + for (let j = 0; j < 3; j++) { + // get the first and next vertex making up the edge + const jNext = (j + 1) % 3; + const vecHash0 = hashes[j]; + const vecHash1 = hashes[jNext]; + const v0 = _triangle[vertKeys[j]]; + const v1 = _triangle[vertKeys[jNext]]; + + const hash = `${vecHash0}_${vecHash1}`; + const reverseHash = `${vecHash1}_${vecHash0}`; + + if (reverseHash in edgeData && edgeData[reverseHash]) { + // if we found a sibling edge add it into the vertex array if + // it meets the angle threshold and delete the edge from the map. + if (_normal.dot(edgeData[reverseHash].normal) <= thresholdDot) { + vertices.push(v0.x, v0.y, v0.z); + vertices.push(v1.x, v1.y, v1.z); + } + + edgeData[reverseHash] = null; + } else if (!(hash in edgeData)) { + // if we've already got an edge here then skip adding a new one + edgeData[hash] = { + index0: indexArr[j], + index1: indexArr[jNext], + normal: _normal.clone(), + }; + } + } + } + + // iterate over all remaining, unmatched edges and add them to the vertex array + for (const key in edgeData) { + if (edgeData[key]) { + const { index0, index1 } = edgeData[key]; + _v0.fromBufferAttribute(positionAttr, index0); + _v1.fromBufferAttribute(positionAttr, index1); + + vertices.push(_v0.x, _v0.y, _v0.z); + vertices.push(_v1.x, _v1.y, _v1.z); + } + } + + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + } + } +} + +export { EdgesGeometry }; diff --git a/backend/libs/three/geometries/ExtrudeGeometry.d.ts b/backend/libs/three/geometries/ExtrudeGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b8b404c3d93c030c16b0340c3537b315e94452ab --- /dev/null +++ b/backend/libs/three/geometries/ExtrudeGeometry.d.ts @@ -0,0 +1,60 @@ +import { Curve } from './../extras/core/Curve'; +import { Vector2 } from './../math/Vector2'; +import { Vector3 } from './../math/Vector3'; +import { Shape } from './../extras/core/Shape'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export interface ExtrudeGeometryOptions { + /** + * @default 12 + */ + curveSegments?: number | undefined; + /** + * @default 1 + */ + steps?: number | undefined; + /** + * @default 100 + */ + depth?: number | undefined; + /** + * @default true + */ + bevelEnabled?: boolean | undefined; + /** + * @default 6 + */ + bevelThickness?: number | undefined; + bevelSize?: number | undefined; + /** + * @default 0 + */ + bevelOffset?: number | undefined; + /** + * @default 3 + */ + bevelSegments?: number | undefined; + extrudePath?: Curve | undefined; + UVGenerator?: UVGenerator | undefined; +} + +export interface UVGenerator { + generateTopUV(geometry: ExtrudeGeometry, vertices: number[], indexA: number, indexB: number, indexC: number): Vector2[]; + generateSideWallUV(geometry: ExtrudeGeometry, vertices: number[], indexA: number, indexB: number, indexC: number, indexD: number): Vector2[]; +} + +export class ExtrudeGeometry extends BufferGeometry { + constructor(shapes?: Shape | Shape[], options?: ExtrudeGeometryOptions); + + /** + * @default 'ExtrudeGeometry' + */ + type: string; + + addShapeList(shapes: Shape[], options?: any): void; + addShape(shape: Shape, options?: any): void; + + static fromJSON(data: any): ExtrudeGeometry; +} + +export { ExtrudeGeometry as ExtrudeBufferGeometry }; diff --git a/backend/libs/three/geometries/ExtrudeGeometry.js b/backend/libs/three/geometries/ExtrudeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..66e854ca26a39fd27ea81bb56040edf82e25ace8 --- /dev/null +++ b/backend/libs/three/geometries/ExtrudeGeometry.js @@ -0,0 +1,633 @@ +/** + * Creates extruded geometry from a path shape. + * + * parameters = { + * + * curveSegments: , // number of points on the curves + * steps: , // number of points for z-side extrusions / used for subdividing segments of extrude spline too + * depth: , // Depth to extrude the shape + * + * bevelEnabled: , // turn on bevel + * bevelThickness: , // how deep into the original shape bevel goes + * bevelSize: , // how far from shape outline (including bevelOffset) is bevel + * bevelOffset: , // how far from shape outline does bevel start + * bevelSegments: , // number of bevel layers + * + * extrudePath: // curve to extrude shape along + * + * UVGenerator: // object that provides UV generator functions + * + * } + */ + +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import * as Curves from '../extras/curves/Curves.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Shape } from '../extras/core/Shape.js'; +import { ShapeUtils } from '../extras/ShapeUtils.js'; + +class ExtrudeGeometry extends BufferGeometry { + constructor(shapes = new Shape([new Vector2(0.5, 0.5), new Vector2(-0.5, 0.5), new Vector2(-0.5, -0.5), new Vector2(0.5, -0.5)]), options = {}) { + super(); + + this.type = 'ExtrudeGeometry'; + + this.parameters = { + shapes: shapes, + options: options, + }; + + shapes = Array.isArray(shapes) ? shapes : [shapes]; + + const scope = this; + + const verticesArray = []; + const uvArray = []; + + for (let i = 0, l = shapes.length; i < l; i++) { + const shape = shapes[i]; + addShape(shape); + } + + // build geometry + + this.setAttribute('position', new Float32BufferAttribute(verticesArray, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvArray, 2)); + + this.computeVertexNormals(); + + // functions + + function addShape(shape) { + const placeholder = []; + + // options + + const curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12; + const steps = options.steps !== undefined ? options.steps : 1; + let depth = options.depth !== undefined ? options.depth : 1; + + let bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true; + let bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 0.2; + let bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 0.1; + let bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0; + let bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3; + + const extrudePath = options.extrudePath; + + const uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator; + + // deprecated options + + if (options.amount !== undefined) { + console.warn('THREE.ExtrudeBufferGeometry: amount has been renamed to depth.'); + depth = options.amount; + } + + // + + let extrudePts, + extrudeByPath = false; + let splineTube, binormal, normal, position2; + + if (extrudePath) { + extrudePts = extrudePath.getSpacedPoints(steps); + + extrudeByPath = true; + bevelEnabled = false; // bevels not supported for path extrusion + + // SETUP TNB variables + + // TODO1 - have a .isClosed in spline? + + splineTube = extrudePath.computeFrenetFrames(steps, false); + + // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length); + + binormal = new Vector3(); + normal = new Vector3(); + position2 = new Vector3(); + } + + // Safeguards if bevels are not enabled + + if (!bevelEnabled) { + bevelSegments = 0; + bevelThickness = 0; + bevelSize = 0; + bevelOffset = 0; + } + + // Variables initialization + + const shapePoints = shape.extractPoints(curveSegments); + + let vertices = shapePoints.shape; + const holes = shapePoints.holes; + + const reverse = !ShapeUtils.isClockWise(vertices); + + if (reverse) { + vertices = vertices.reverse(); + + // Maybe we should also check if holes are in the opposite direction, just to be safe ... + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + + if (ShapeUtils.isClockWise(ahole)) { + holes[h] = ahole.reverse(); + } + } + } + + const faces = ShapeUtils.triangulateShape(vertices, holes); + + /* Vertices */ + + const contour = vertices; // vertices has all points but contour has only points of circumference + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + + vertices = vertices.concat(ahole); + } + + function scalePt2(pt, vec, size) { + if (!vec) console.error('THREE.ExtrudeGeometry: vec does not exist'); + + return vec.clone().multiplyScalar(size).add(pt); + } + + const vlen = vertices.length, + flen = faces.length; + + // Find directions for point movement + + function getBevelVec(inPt, inPrev, inNext) { + // computes for inPt the corresponding point inPt' on a new contour + // shifted by 1 unit (length of normalized vector) to the left + // if we walk along contour clockwise, this new contour is outside the old one + // + // inPt' is the intersection of the two lines parallel to the two + // adjacent edges of inPt at a distance of 1 unit on the left side. + + let v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt + + // good reading for geometry algorithms (here: line-line intersection) + // http://geomalgorithms.com/a05-_intersect-1.html + + const v_prev_x = inPt.x - inPrev.x, + v_prev_y = inPt.y - inPrev.y; + const v_next_x = inNext.x - inPt.x, + v_next_y = inNext.y - inPt.y; + + const v_prev_lensq = v_prev_x * v_prev_x + v_prev_y * v_prev_y; + + // check for collinear edges + const collinear0 = v_prev_x * v_next_y - v_prev_y * v_next_x; + + if (Math.abs(collinear0) > Number.EPSILON) { + // not collinear + + // length of vectors for normalizing + + const v_prev_len = Math.sqrt(v_prev_lensq); + const v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y); + + // shift adjacent points by unit vectors to the left + + const ptPrevShift_x = inPrev.x - v_prev_y / v_prev_len; + const ptPrevShift_y = inPrev.y + v_prev_x / v_prev_len; + + const ptNextShift_x = inNext.x - v_next_y / v_next_len; + const ptNextShift_y = inNext.y + v_next_x / v_next_len; + + // scaling factor for v_prev to intersection point + + const sf = + ((ptNextShift_x - ptPrevShift_x) * v_next_y - (ptNextShift_y - ptPrevShift_y) * v_next_x) / (v_prev_x * v_next_y - v_prev_y * v_next_x); + + // vector from inPt to intersection point + + v_trans_x = ptPrevShift_x + v_prev_x * sf - inPt.x; + v_trans_y = ptPrevShift_y + v_prev_y * sf - inPt.y; + + // Don't normalize!, otherwise sharp corners become ugly + // but prevent crazy spikes + const v_trans_lensq = v_trans_x * v_trans_x + v_trans_y * v_trans_y; + if (v_trans_lensq <= 2) { + return new Vector2(v_trans_x, v_trans_y); + } else { + shrink_by = Math.sqrt(v_trans_lensq / 2); + } + } else { + // handle special case of collinear edges + + let direction_eq = false; // assumes: opposite + + if (v_prev_x > Number.EPSILON) { + if (v_next_x > Number.EPSILON) { + direction_eq = true; + } + } else { + if (v_prev_x < -Number.EPSILON) { + if (v_next_x < -Number.EPSILON) { + direction_eq = true; + } + } else { + if (Math.sign(v_prev_y) === Math.sign(v_next_y)) { + direction_eq = true; + } + } + } + + if (direction_eq) { + // console.log("Warning: lines are a straight sequence"); + v_trans_x = -v_prev_y; + v_trans_y = v_prev_x; + shrink_by = Math.sqrt(v_prev_lensq); + } else { + // console.log("Warning: lines are a straight spike"); + v_trans_x = v_prev_x; + v_trans_y = v_prev_y; + shrink_by = Math.sqrt(v_prev_lensq / 2); + } + } + + return new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by); + } + + const contourMovements = []; + + for (let i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) { + if (j === il) j = 0; + if (k === il) k = 0; + + // (j)---(i)---(k) + // console.log('i,j,k', i, j , k) + + contourMovements[i] = getBevelVec(contour[i], contour[j], contour[k]); + } + + const holesMovements = []; + let oneHoleMovements, + verticesMovements = contourMovements.concat(); + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + + oneHoleMovements = []; + + for (let i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i++, j++, k++) { + if (j === il) j = 0; + if (k === il) k = 0; + + // (j)---(i)---(k) + oneHoleMovements[i] = getBevelVec(ahole[i], ahole[j], ahole[k]); + } + + holesMovements.push(oneHoleMovements); + verticesMovements = verticesMovements.concat(oneHoleMovements); + } + + // Loop bevelSegments, 1 for the front, 1 for the back + + for (let b = 0; b < bevelSegments; b++) { + //for ( b = bevelSegments; b > 0; b -- ) { + + const t = b / bevelSegments; + const z = bevelThickness * Math.cos((t * Math.PI) / 2); + const bs = bevelSize * Math.sin((t * Math.PI) / 2) + bevelOffset; + + // contract shape + + for (let i = 0, il = contour.length; i < il; i++) { + const vert = scalePt2(contour[i], contourMovements[i], bs); + + v(vert.x, vert.y, -z); + } + + // expand holes + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + oneHoleMovements = holesMovements[h]; + + for (let i = 0, il = ahole.length; i < il; i++) { + const vert = scalePt2(ahole[i], oneHoleMovements[i], bs); + + v(vert.x, vert.y, -z); + } + } + } + + const bs = bevelSize + bevelOffset; + + // Back facing vertices + + for (let i = 0; i < vlen; i++) { + const vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i]; + + if (!extrudeByPath) { + v(vert.x, vert.y, 0); + } else { + // v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x ); + + normal.copy(splineTube.normals[0]).multiplyScalar(vert.x); + binormal.copy(splineTube.binormals[0]).multiplyScalar(vert.y); + + position2.copy(extrudePts[0]).add(normal).add(binormal); + + v(position2.x, position2.y, position2.z); + } + } + + // Add stepped vertices... + // Including front facing vertices + + for (let s = 1; s <= steps; s++) { + for (let i = 0; i < vlen; i++) { + const vert = bevelEnabled ? scalePt2(vertices[i], verticesMovements[i], bs) : vertices[i]; + + if (!extrudeByPath) { + v(vert.x, vert.y, (depth / steps) * s); + } else { + // v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x ); + + normal.copy(splineTube.normals[s]).multiplyScalar(vert.x); + binormal.copy(splineTube.binormals[s]).multiplyScalar(vert.y); + + position2.copy(extrudePts[s]).add(normal).add(binormal); + + v(position2.x, position2.y, position2.z); + } + } + } + + // Add bevel segments planes + + //for ( b = 1; b <= bevelSegments; b ++ ) { + for (let b = bevelSegments - 1; b >= 0; b--) { + const t = b / bevelSegments; + const z = bevelThickness * Math.cos((t * Math.PI) / 2); + const bs = bevelSize * Math.sin((t * Math.PI) / 2) + bevelOffset; + + // contract shape + + for (let i = 0, il = contour.length; i < il; i++) { + const vert = scalePt2(contour[i], contourMovements[i], bs); + v(vert.x, vert.y, depth + z); + } + + // expand holes + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + oneHoleMovements = holesMovements[h]; + + for (let i = 0, il = ahole.length; i < il; i++) { + const vert = scalePt2(ahole[i], oneHoleMovements[i], bs); + + if (!extrudeByPath) { + v(vert.x, vert.y, depth + z); + } else { + v(vert.x, vert.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + z); + } + } + } + } + + /* Faces */ + + // Top and bottom faces + + buildLidFaces(); + + // Sides faces + + buildSideFaces(); + + ///// Internal functions + + function buildLidFaces() { + const start = verticesArray.length / 3; + + if (bevelEnabled) { + let layer = 0; // steps + 1 + let offset = vlen * layer; + + // Bottom faces + + for (let i = 0; i < flen; i++) { + const face = faces[i]; + f3(face[2] + offset, face[1] + offset, face[0] + offset); + } + + layer = steps + bevelSegments * 2; + offset = vlen * layer; + + // Top faces + + for (let i = 0; i < flen; i++) { + const face = faces[i]; + f3(face[0] + offset, face[1] + offset, face[2] + offset); + } + } else { + // Bottom faces + + for (let i = 0; i < flen; i++) { + const face = faces[i]; + f3(face[2], face[1], face[0]); + } + + // Top faces + + for (let i = 0; i < flen; i++) { + const face = faces[i]; + f3(face[0] + vlen * steps, face[1] + vlen * steps, face[2] + vlen * steps); + } + } + + scope.addGroup(start, verticesArray.length / 3 - start, 0); + } + + // Create faces for the z-sides of the shape + + function buildSideFaces() { + const start = verticesArray.length / 3; + let layeroffset = 0; + sidewalls(contour, layeroffset); + layeroffset += contour.length; + + for (let h = 0, hl = holes.length; h < hl; h++) { + const ahole = holes[h]; + sidewalls(ahole, layeroffset); + + //, true + layeroffset += ahole.length; + } + + scope.addGroup(start, verticesArray.length / 3 - start, 1); + } + + function sidewalls(contour, layeroffset) { + let i = contour.length; + + while (--i >= 0) { + const j = i; + let k = i - 1; + if (k < 0) k = contour.length - 1; + + //console.log('b', i,j, i-1, k,vertices.length); + + for (let s = 0, sl = steps + bevelSegments * 2; s < sl; s++) { + const slen1 = vlen * s; + const slen2 = vlen * (s + 1); + + const a = layeroffset + j + slen1, + b = layeroffset + k + slen1, + c = layeroffset + k + slen2, + d = layeroffset + j + slen2; + + f4(a, b, c, d); + } + } + } + + function v(x, y, z) { + placeholder.push(x); + placeholder.push(y); + placeholder.push(z); + } + + function f3(a, b, c) { + addVertex(a); + addVertex(b); + addVertex(c); + + const nextIndex = verticesArray.length / 3; + const uvs = uvgen.generateTopUV(scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1); + + addUV(uvs[0]); + addUV(uvs[1]); + addUV(uvs[2]); + } + + function f4(a, b, c, d) { + addVertex(a); + addVertex(b); + addVertex(d); + + addVertex(b); + addVertex(c); + addVertex(d); + + const nextIndex = verticesArray.length / 3; + const uvs = uvgen.generateSideWallUV(scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1); + + addUV(uvs[0]); + addUV(uvs[1]); + addUV(uvs[3]); + + addUV(uvs[1]); + addUV(uvs[2]); + addUV(uvs[3]); + } + + function addVertex(index) { + verticesArray.push(placeholder[index * 3 + 0]); + verticesArray.push(placeholder[index * 3 + 1]); + verticesArray.push(placeholder[index * 3 + 2]); + } + + function addUV(vector2) { + uvArray.push(vector2.x); + uvArray.push(vector2.y); + } + } + } + + toJSON() { + const data = super.toJSON(); + + const shapes = this.parameters.shapes; + const options = this.parameters.options; + + return toJSON(shapes, options, data); + } + + static fromJSON(data, shapes) { + const geometryShapes = []; + + for (let j = 0, jl = data.shapes.length; j < jl; j++) { + const shape = shapes[data.shapes[j]]; + + geometryShapes.push(shape); + } + + const extrudePath = data.options.extrudePath; + + if (extrudePath !== undefined) { + data.options.extrudePath = new Curves[extrudePath.type]().fromJSON(extrudePath); + } + + return new ExtrudeGeometry(geometryShapes, data.options); + } +} + +const WorldUVGenerator = { + generateTopUV: function (geometry, vertices, indexA, indexB, indexC) { + const a_x = vertices[indexA * 3]; + const a_y = vertices[indexA * 3 + 1]; + const b_x = vertices[indexB * 3]; + const b_y = vertices[indexB * 3 + 1]; + const c_x = vertices[indexC * 3]; + const c_y = vertices[indexC * 3 + 1]; + + return [new Vector2(a_x, a_y), new Vector2(b_x, b_y), new Vector2(c_x, c_y)]; + }, + + generateSideWallUV: function (geometry, vertices, indexA, indexB, indexC, indexD) { + const a_x = vertices[indexA * 3]; + const a_y = vertices[indexA * 3 + 1]; + const a_z = vertices[indexA * 3 + 2]; + const b_x = vertices[indexB * 3]; + const b_y = vertices[indexB * 3 + 1]; + const b_z = vertices[indexB * 3 + 2]; + const c_x = vertices[indexC * 3]; + const c_y = vertices[indexC * 3 + 1]; + const c_z = vertices[indexC * 3 + 2]; + const d_x = vertices[indexD * 3]; + const d_y = vertices[indexD * 3 + 1]; + const d_z = vertices[indexD * 3 + 2]; + + if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) { + return [new Vector2(a_x, 1 - a_z), new Vector2(b_x, 1 - b_z), new Vector2(c_x, 1 - c_z), new Vector2(d_x, 1 - d_z)]; + } else { + return [new Vector2(a_y, 1 - a_z), new Vector2(b_y, 1 - b_z), new Vector2(c_y, 1 - c_z), new Vector2(d_y, 1 - d_z)]; + } + }, +}; + +function toJSON(shapes, options, data) { + data.shapes = []; + + if (Array.isArray(shapes)) { + for (let i = 0, l = shapes.length; i < l; i++) { + const shape = shapes[i]; + + data.shapes.push(shape.uuid); + } + } else { + data.shapes.push(shapes.uuid); + } + + if (options.extrudePath !== undefined) data.options.extrudePath = options.extrudePath.toJSON(); + + return data; +} + +export { ExtrudeGeometry, ExtrudeGeometry as ExtrudeBufferGeometry }; diff --git a/backend/libs/three/geometries/Geometries.d.ts b/backend/libs/three/geometries/Geometries.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4cbb187335ba2b682ef867dc68eba1bf6394cfee --- /dev/null +++ b/backend/libs/three/geometries/Geometries.d.ts @@ -0,0 +1,21 @@ +export * from './BoxGeometry'; +export * from './CapsuleGeometry'; +export * from './CircleGeometry'; +export * from './ConeGeometry'; +export * from './CylinderGeometry'; +export * from './DodecahedronGeometry'; +export * from './EdgesGeometry'; +export * from './ExtrudeGeometry'; +export * from './IcosahedronGeometry'; +export * from './LatheGeometry'; +export * from './OctahedronGeometry'; +export * from './PlaneGeometry'; +export * from './PolyhedronGeometry'; +export * from './RingGeometry'; +export * from './ShapeGeometry'; +export * from './SphereGeometry'; +export * from './TetrahedronGeometry'; +export * from './TorusGeometry'; +export * from './TorusKnotGeometry'; +export * from './TubeGeometry'; +export * from './WireframeGeometry'; diff --git a/backend/libs/three/geometries/Geometries.js b/backend/libs/three/geometries/Geometries.js new file mode 100644 index 0000000000000000000000000000000000000000..ba9be33620fe7af6fab71ef26145c305f984c18b --- /dev/null +++ b/backend/libs/three/geometries/Geometries.js @@ -0,0 +1,20 @@ +export * from './BoxGeometry.js'; +export * from './CircleGeometry.js'; +export * from './ConeGeometry.js'; +export * from './CylinderGeometry.js'; +export * from './DodecahedronGeometry.js'; +export * from './EdgesGeometry.js'; +export * from './ExtrudeGeometry.js'; +export * from './IcosahedronGeometry.js'; +export * from './LatheGeometry.js'; +export * from './OctahedronGeometry.js'; +export * from './PlaneGeometry.js'; +export * from './PolyhedronGeometry.js'; +export * from './RingGeometry.js'; +export * from './ShapeGeometry.js'; +export * from './SphereGeometry.js'; +export * from './TetrahedronGeometry.js'; +export * from './TorusGeometry.js'; +export * from './TorusKnotGeometry.js'; +export * from './TubeGeometry.js'; +export * from './WireframeGeometry.js'; diff --git a/backend/libs/three/geometries/IcosahedronGeometry.d.ts b/backend/libs/three/geometries/IcosahedronGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4af48b82f1d585d9be97fec1698354007f3a5f89 --- /dev/null +++ b/backend/libs/three/geometries/IcosahedronGeometry.d.ts @@ -0,0 +1,18 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry'; + +export class IcosahedronGeometry extends PolyhedronGeometry { + /** + * @param [radius=1] + * @param [detail=0] + */ + constructor(radius?: number, detail?: number); + + /** + * @default 'IcosahedronGeometry' + */ + type: string; + + static fromJSON(data: any): IcosahedronGeometry; +} + +export { IcosahedronGeometry as IcosahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/IcosahedronGeometry.js b/backend/libs/three/geometries/IcosahedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..2789deb5b72ae83f87d75742fa46777a11697c56 --- /dev/null +++ b/backend/libs/three/geometries/IcosahedronGeometry.js @@ -0,0 +1,29 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry.js'; + +class IcosahedronGeometry extends PolyhedronGeometry { + constructor(radius = 1, detail = 0) { + const t = (1 + Math.sqrt(5)) / 2; + + const vertices = [-1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, 0, -1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, t, 0, -1, t, 0, 1, -t, 0, -1, -t, 0, 1]; + + const indices = [ + 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, + 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1, + ]; + + super(vertices, indices, radius, detail); + + this.type = 'IcosahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail, + }; + } + + static fromJSON(data) { + return new IcosahedronGeometry(data.radius, data.detail); + } +} + +export { IcosahedronGeometry, IcosahedronGeometry as IcosahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/LatheGeometry.d.ts b/backend/libs/three/geometries/LatheGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..14b9b6b50b491b2e478e0c44b6a8e75f999fd0f2 --- /dev/null +++ b/backend/libs/three/geometries/LatheGeometry.d.ts @@ -0,0 +1,28 @@ +import { Vector2 } from './../math/Vector2'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class LatheGeometry extends BufferGeometry { + /** + * @param points + * @param [segments=12] + * @param [phiStart=0] + * @param [phiLength=Math.PI * 2] + */ + constructor(points?: Vector2[], segments?: number, phiStart?: number, phiLength?: number); + + /** + * @default 'LatheGeometry' + */ + type: string; + + parameters: { + points: Vector2[]; + segments: number; + phiStart: number; + phiLength: number; + }; + + static fromJSON(data: any): LatheGeometry; +} + +export { LatheGeometry as LatheBufferGeometry }; diff --git a/backend/libs/three/geometries/LatheGeometry.js b/backend/libs/three/geometries/LatheGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..aeb918a1b1a4eefc7d5d78b12acbd3ea6ca26c3b --- /dev/null +++ b/backend/libs/three/geometries/LatheGeometry.js @@ -0,0 +1,159 @@ +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; +import * as MathUtils from '../math/MathUtils.js'; + +class LatheGeometry extends BufferGeometry { + constructor(points = [new Vector2(0, 0.5), new Vector2(0.5, 0), new Vector2(0, -0.5)], segments = 12, phiStart = 0, phiLength = Math.PI * 2) { + super(); + + this.type = 'LatheGeometry'; + + this.parameters = { + points: points, + segments: segments, + phiStart: phiStart, + phiLength: phiLength, + }; + + segments = Math.floor(segments); + + // clamp phiLength so it's in range of [ 0, 2PI ] + + phiLength = MathUtils.clamp(phiLength, 0, Math.PI * 2); + + // buffers + + const indices = []; + const vertices = []; + const uvs = []; + const initNormals = []; + const normals = []; + + // helper variables + + const inverseSegments = 1.0 / segments; + const vertex = new Vector3(); + const uv = new Vector2(); + const normal = new Vector3(); + const curNormal = new Vector3(); + const prevNormal = new Vector3(); + let dx = 0; + let dy = 0; + + // pre-compute normals for initial "meridian" + + for (let j = 0; j <= points.length - 1; j++) { + switch (j) { + case 0: // special handling for 1st vertex on path + dx = points[j + 1].x - points[j].x; + dy = points[j + 1].y - points[j].y; + + normal.x = dy * 1.0; + normal.y = -dx; + normal.z = dy * 0.0; + + prevNormal.copy(normal); + + normal.normalize(); + + initNormals.push(normal.x, normal.y, normal.z); + + break; + + case points.length - 1: // special handling for last Vertex on path + initNormals.push(prevNormal.x, prevNormal.y, prevNormal.z); + + break; + + default: + // default handling for all vertices in between + + dx = points[j + 1].x - points[j].x; + dy = points[j + 1].y - points[j].y; + + normal.x = dy * 1.0; + normal.y = -dx; + normal.z = dy * 0.0; + + curNormal.copy(normal); + + normal.x += prevNormal.x; + normal.y += prevNormal.y; + normal.z += prevNormal.z; + + normal.normalize(); + + initNormals.push(normal.x, normal.y, normal.z); + + prevNormal.copy(curNormal); + } + } + + // generate vertices, uvs and normals + + for (let i = 0; i <= segments; i++) { + const phi = phiStart + i * inverseSegments * phiLength; + + const sin = Math.sin(phi); + const cos = Math.cos(phi); + + for (let j = 0; j <= points.length - 1; j++) { + // vertex + + vertex.x = points[j].x * sin; + vertex.y = points[j].y; + vertex.z = points[j].x * cos; + + vertices.push(vertex.x, vertex.y, vertex.z); + + // uv + + uv.x = i / segments; + uv.y = j / (points.length - 1); + + uvs.push(uv.x, uv.y); + + // normal + + const x = initNormals[3 * j + 0] * sin; + const y = initNormals[3 * j + 1]; + const z = initNormals[3 * j + 0] * cos; + + normals.push(x, y, z); + } + } + + // indices + + for (let i = 0; i < segments; i++) { + for (let j = 0; j < points.length - 1; j++) { + const base = j + i * points.length; + + const a = base; + const b = base + points.length; + const c = base + points.length + 1; + const d = base + 1; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + } + + static fromJSON(data) { + return new LatheGeometry(data.points, data.segments, data.phiStart, data.phiLength); + } +} + +export { LatheGeometry, LatheGeometry as LatheBufferGeometry }; diff --git a/backend/libs/three/geometries/OctahedronGeometry.d.ts b/backend/libs/three/geometries/OctahedronGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..2aa338e5524d55ce243cc5b47aa592abaadd624e --- /dev/null +++ b/backend/libs/three/geometries/OctahedronGeometry.d.ts @@ -0,0 +1,18 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry'; + +export class OctahedronGeometry extends PolyhedronGeometry { + /** + * @param [radius=1] + * @param [detail=0] + */ + constructor(radius?: number, detail?: number); + + /** + * @default 'OctahedronGeometry' + */ + type: string; + + static fromJSON(data: any): OctahedronGeometry; +} + +export { OctahedronGeometry as OctahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/OctahedronGeometry.js b/backend/libs/three/geometries/OctahedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..17e564f35c189892cc83985fabeba35df49e944e --- /dev/null +++ b/backend/libs/three/geometries/OctahedronGeometry.js @@ -0,0 +1,24 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry.js'; + +class OctahedronGeometry extends PolyhedronGeometry { + constructor(radius = 1, detail = 0) { + const vertices = [1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1]; + + const indices = [0, 2, 4, 0, 4, 3, 0, 3, 5, 0, 5, 2, 1, 2, 5, 1, 5, 3, 1, 3, 4, 1, 4, 2]; + + super(vertices, indices, radius, detail); + + this.type = 'OctahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail, + }; + } + + static fromJSON(data) { + return new OctahedronGeometry(data.radius, data.detail); + } +} + +export { OctahedronGeometry, OctahedronGeometry as OctahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/PlaneGeometry.d.ts b/backend/libs/three/geometries/PlaneGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..766806e41e942da022c9822839c209212e218ee5 --- /dev/null +++ b/backend/libs/three/geometries/PlaneGeometry.d.ts @@ -0,0 +1,27 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class PlaneGeometry extends BufferGeometry { + /** + * @param [width=1] — Width of the sides on the X axis. + * @param [height=1] — Height of the sides on the Y axis. + * @param [widthSegments=1] — Number of segmented faces along the width of the sides. + * @param [heightSegments=1] — Number of segmented faces along the height of the sides. + */ + constructor(width?: number, height?: number, widthSegments?: number, heightSegments?: number); + + /** + * @default 'PlaneGeometry' + */ + type: string; + + parameters: { + width: number; + height: number; + widthSegments: number; + heightSegments: number; + }; + + static fromJSON(data: any): PlaneGeometry; +} + +export { PlaneGeometry as PlaneBufferGeometry }; diff --git a/backend/libs/three/geometries/PlaneGeometry.js b/backend/libs/three/geometries/PlaneGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..afae72f2bdfcb75f25fdfd9950f9019c41d67a92 --- /dev/null +++ b/backend/libs/three/geometries/PlaneGeometry.js @@ -0,0 +1,73 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; + +class PlaneGeometry extends BufferGeometry { + constructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) { + super(); + this.type = 'PlaneGeometry'; + + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments, + }; + + const width_half = width / 2; + const height_half = height / 2; + + const gridX = Math.floor(widthSegments); + const gridY = Math.floor(heightSegments); + + const gridX1 = gridX + 1; + const gridY1 = gridY + 1; + + const segment_width = width / gridX; + const segment_height = height / gridY; + + // + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + for (let iy = 0; iy < gridY1; iy++) { + const y = iy * segment_height - height_half; + + for (let ix = 0; ix < gridX1; ix++) { + const x = ix * segment_width - width_half; + + vertices.push(x, -y, 0); + + normals.push(0, 0, 1); + + uvs.push(ix / gridX); + uvs.push(1 - iy / gridY); + } + } + + for (let iy = 0; iy < gridY; iy++) { + for (let ix = 0; ix < gridX; ix++) { + const a = ix + gridX1 * iy; + const b = ix + gridX1 * (iy + 1); + const c = ix + 1 + gridX1 * (iy + 1); + const d = ix + 1 + gridX1 * iy; + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + } + + static fromJSON(data) { + return new PlaneGeometry(data.width, data.height, data.widthSegments, data.heightSegments); + } +} + +export { PlaneGeometry, PlaneGeometry as PlaneBufferGeometry }; diff --git a/backend/libs/three/geometries/PolyhedronGeometry.d.ts b/backend/libs/three/geometries/PolyhedronGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1abc3957515b2c4075e4c1e72ff90470716e078e --- /dev/null +++ b/backend/libs/three/geometries/PolyhedronGeometry.d.ts @@ -0,0 +1,27 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class PolyhedronGeometry extends BufferGeometry { + /** + * @param vertices + * @param indices + * @param [radius=1] + * @param [detail=0] + */ + constructor(vertices?: number[], indices?: number[], radius?: number, detail?: number); + + /** + * @default 'PolyhedronGeometry' + */ + type: string; + + parameters: { + vertices: number[]; + indices: number[]; + radius: number; + detail: number; + }; + + static fromJSON(data: any): PolyhedronGeometry; +} + +export { PolyhedronGeometry as PolyhedronBufferGeometry }; diff --git a/backend/libs/three/geometries/PolyhedronGeometry.js b/backend/libs/three/geometries/PolyhedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..b803ab75e43a1541fc6e1443c539932ecae81d65 --- /dev/null +++ b/backend/libs/three/geometries/PolyhedronGeometry.js @@ -0,0 +1,244 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; + +class PolyhedronGeometry extends BufferGeometry { + constructor(vertices = [], indices = [], radius = 1, detail = 0) { + super(); + + this.type = 'PolyhedronGeometry'; + + this.parameters = { + vertices: vertices, + indices: indices, + radius: radius, + detail: detail, + }; + + // default buffer data + + const vertexBuffer = []; + const uvBuffer = []; + + // the subdivision creates the vertex buffer data + + subdivide(detail); + + // all vertices should lie on a conceptual sphere with a given radius + + applyRadius(radius); + + // finally, create the uv data + + generateUVs(); + + // build non-indexed geometry + + this.setAttribute('position', new Float32BufferAttribute(vertexBuffer, 3)); + this.setAttribute('normal', new Float32BufferAttribute(vertexBuffer.slice(), 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvBuffer, 2)); + + if (detail === 0) { + this.computeVertexNormals(); // flat normals + } else { + this.normalizeNormals(); // smooth normals + } + + // helper functions + + function subdivide(detail) { + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + // iterate over all faces and apply a subdivison with the given detail value + + for (let i = 0; i < indices.length; i += 3) { + // get the vertices of the face + + getVertexByIndex(indices[i + 0], a); + getVertexByIndex(indices[i + 1], b); + getVertexByIndex(indices[i + 2], c); + + // perform subdivision + + subdivideFace(a, b, c, detail); + } + } + + function subdivideFace(a, b, c, detail) { + const cols = detail + 1; + + // we use this multidimensional array as a data structure for creating the subdivision + + const v = []; + + // construct all of the vertices for this subdivision + + for (let i = 0; i <= cols; i++) { + v[i] = []; + + const aj = a.clone().lerp(c, i / cols); + const bj = b.clone().lerp(c, i / cols); + + const rows = cols - i; + + for (let j = 0; j <= rows; j++) { + if (j === 0 && i === cols) { + v[i][j] = aj; + } else { + v[i][j] = aj.clone().lerp(bj, j / rows); + } + } + } + + // construct all of the faces + + for (let i = 0; i < cols; i++) { + for (let j = 0; j < 2 * (cols - i) - 1; j++) { + const k = Math.floor(j / 2); + + if (j % 2 === 0) { + pushVertex(v[i][k + 1]); + pushVertex(v[i + 1][k]); + pushVertex(v[i][k]); + } else { + pushVertex(v[i][k + 1]); + pushVertex(v[i + 1][k + 1]); + pushVertex(v[i + 1][k]); + } + } + } + } + + function applyRadius(radius) { + const vertex = new Vector3(); + + // iterate over the entire buffer and apply the radius to each vertex + + for (let i = 0; i < vertexBuffer.length; i += 3) { + vertex.x = vertexBuffer[i + 0]; + vertex.y = vertexBuffer[i + 1]; + vertex.z = vertexBuffer[i + 2]; + + vertex.normalize().multiplyScalar(radius); + + vertexBuffer[i + 0] = vertex.x; + vertexBuffer[i + 1] = vertex.y; + vertexBuffer[i + 2] = vertex.z; + } + } + + function generateUVs() { + const vertex = new Vector3(); + + for (let i = 0; i < vertexBuffer.length; i += 3) { + vertex.x = vertexBuffer[i + 0]; + vertex.y = vertexBuffer[i + 1]; + vertex.z = vertexBuffer[i + 2]; + + const u = azimuth(vertex) / 2 / Math.PI + 0.5; + const v = inclination(vertex) / Math.PI + 0.5; + uvBuffer.push(u, 1 - v); + } + + correctUVs(); + + correctSeam(); + } + + function correctSeam() { + // handle case when face straddles the seam, see #3269 + + for (let i = 0; i < uvBuffer.length; i += 6) { + // uv data of a single face + + const x0 = uvBuffer[i + 0]; + const x1 = uvBuffer[i + 2]; + const x2 = uvBuffer[i + 4]; + + const max = Math.max(x0, x1, x2); + const min = Math.min(x0, x1, x2); + + // 0.9 is somewhat arbitrary + + if (max > 0.9 && min < 0.1) { + if (x0 < 0.2) uvBuffer[i + 0] += 1; + if (x1 < 0.2) uvBuffer[i + 2] += 1; + if (x2 < 0.2) uvBuffer[i + 4] += 1; + } + } + } + + function pushVertex(vertex) { + vertexBuffer.push(vertex.x, vertex.y, vertex.z); + } + + function getVertexByIndex(index, vertex) { + const stride = index * 3; + + vertex.x = vertices[stride + 0]; + vertex.y = vertices[stride + 1]; + vertex.z = vertices[stride + 2]; + } + + function correctUVs() { + const a = new Vector3(); + const b = new Vector3(); + const c = new Vector3(); + + const centroid = new Vector3(); + + const uvA = new Vector2(); + const uvB = new Vector2(); + const uvC = new Vector2(); + + for (let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6) { + a.set(vertexBuffer[i + 0], vertexBuffer[i + 1], vertexBuffer[i + 2]); + b.set(vertexBuffer[i + 3], vertexBuffer[i + 4], vertexBuffer[i + 5]); + c.set(vertexBuffer[i + 6], vertexBuffer[i + 7], vertexBuffer[i + 8]); + + uvA.set(uvBuffer[j + 0], uvBuffer[j + 1]); + uvB.set(uvBuffer[j + 2], uvBuffer[j + 3]); + uvC.set(uvBuffer[j + 4], uvBuffer[j + 5]); + + centroid.copy(a).add(b).add(c).divideScalar(3); + + const azi = azimuth(centroid); + + correctUV(uvA, j + 0, a, azi); + correctUV(uvB, j + 2, b, azi); + correctUV(uvC, j + 4, c, azi); + } + } + + function correctUV(uv, stride, vector, azimuth) { + if (azimuth < 0 && uv.x === 1) { + uvBuffer[stride] = uv.x - 1; + } + + if (vector.x === 0 && vector.z === 0) { + uvBuffer[stride] = azimuth / 2 / Math.PI + 0.5; + } + } + + // Angle around the Y axis, counter-clockwise when looking from above. + + function azimuth(vector) { + return Math.atan2(vector.z, -vector.x); + } + + // Angle above the XZ plane. + + function inclination(vector) { + return Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z)); + } + } + + static fromJSON(data) { + return new PolyhedronGeometry(data.vertices, data.indices, data.radius, data.details); + } +} + +export { PolyhedronGeometry, PolyhedronGeometry as PolyhedronBufferGeometry }; diff --git a/backend/libs/three/geometries/RingGeometry.d.ts b/backend/libs/three/geometries/RingGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4fefedc7df426aec78dd1f7ed5659e32170c2791 --- /dev/null +++ b/backend/libs/three/geometries/RingGeometry.d.ts @@ -0,0 +1,31 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class RingGeometry extends BufferGeometry { + /** + * @param [innerRadius=0.5] + * @param [outerRadius=1] + * @param [thetaSegments=8] + * @param [phiSegments=1] + * @param [thetaStart=0] + * @param [thetaLength=Math.PI * 2] + */ + constructor(innerRadius?: number, outerRadius?: number, thetaSegments?: number, phiSegments?: number, thetaStart?: number, thetaLength?: number); + + /** + * @default 'RingGeometry' + */ + type: string; + + parameters: { + innerRadius: number; + outerRadius: number; + thetaSegments: number; + phiSegments: number; + thetaStart: number; + thetaLength: number; + }; + + static fromJSON(data: any): RingGeometry; +} + +export { RingGeometry as RingBufferGeometry }; diff --git a/backend/libs/three/geometries/RingGeometry.js b/backend/libs/three/geometries/RingGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..5d862ebc52440d783ee5029099942ee551db8a44 --- /dev/null +++ b/backend/libs/three/geometries/RingGeometry.js @@ -0,0 +1,103 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; + +class RingGeometry extends BufferGeometry { + constructor(innerRadius = 0.5, outerRadius = 1, thetaSegments = 8, phiSegments = 1, thetaStart = 0, thetaLength = Math.PI * 2) { + super(); + + this.type = 'RingGeometry'; + + this.parameters = { + innerRadius: innerRadius, + outerRadius: outerRadius, + thetaSegments: thetaSegments, + phiSegments: phiSegments, + thetaStart: thetaStart, + thetaLength: thetaLength, + }; + + thetaSegments = Math.max(3, thetaSegments); + phiSegments = Math.max(1, phiSegments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // some helper variables + + let radius = innerRadius; + const radiusStep = (outerRadius - innerRadius) / phiSegments; + const vertex = new Vector3(); + const uv = new Vector2(); + + // generate vertices, normals and uvs + + for (let j = 0; j <= phiSegments; j++) { + for (let i = 0; i <= thetaSegments; i++) { + // values are generate from the inside of the ring to the outside + + const segment = thetaStart + (i / thetaSegments) * thetaLength; + + // vertex + + vertex.x = radius * Math.cos(segment); + vertex.y = radius * Math.sin(segment); + + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + normals.push(0, 0, 1); + + // uv + + uv.x = (vertex.x / outerRadius + 1) / 2; + uv.y = (vertex.y / outerRadius + 1) / 2; + + uvs.push(uv.x, uv.y); + } + + // increase the radius for next row of vertices + + radius += radiusStep; + } + + // indices + + for (let j = 0; j < phiSegments; j++) { + const thetaSegmentLevel = j * (thetaSegments + 1); + + for (let i = 0; i < thetaSegments; i++) { + const segment = i + thetaSegmentLevel; + + const a = segment; + const b = segment + thetaSegments + 1; + const c = segment + thetaSegments + 2; + const d = segment + 1; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + } + + static fromJSON(data) { + return new RingGeometry(data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength); + } +} + +export { RingGeometry, RingGeometry as RingBufferGeometry }; diff --git a/backend/libs/three/geometries/ShapeGeometry.d.ts b/backend/libs/three/geometries/ShapeGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..116a3436dc13ab7aa3f69ffd13907865afee1b63 --- /dev/null +++ b/backend/libs/three/geometries/ShapeGeometry.d.ts @@ -0,0 +1,15 @@ +import { Shape } from './../extras/core/Shape'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class ShapeGeometry extends BufferGeometry { + /** + * @default 'ShapShapeGeometryeBufferGeometry' + */ + type: string; + + constructor(shapes?: Shape | Shape[], curveSegments?: number); + + static fromJSON(data: any): ShapeGeometry; +} + +export { ShapeGeometry as ShapeBufferGeometry }; diff --git a/backend/libs/three/geometries/ShapeGeometry.js b/backend/libs/three/geometries/ShapeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..58658d4993b9d139ada505c7215a4fd2afe770aa --- /dev/null +++ b/backend/libs/three/geometries/ShapeGeometry.js @@ -0,0 +1,145 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Shape } from '../extras/core/Shape.js'; +import { ShapeUtils } from '../extras/ShapeUtils.js'; +import { Vector2 } from '../math/Vector2.js'; + +class ShapeGeometry extends BufferGeometry { + constructor(shapes = new Shape([new Vector2(0, 0.5), new Vector2(-0.5, -0.5), new Vector2(0.5, -0.5)]), curveSegments = 12) { + super(); + this.type = 'ShapeGeometry'; + + this.parameters = { + shapes: shapes, + curveSegments: curveSegments, + }; + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + let groupStart = 0; + let groupCount = 0; + + // allow single and array values for "shapes" parameter + + if (Array.isArray(shapes) === false) { + addShape(shapes); + } else { + for (let i = 0; i < shapes.length; i++) { + addShape(shapes[i]); + + this.addGroup(groupStart, groupCount, i); // enables MultiMaterial support + + groupStart += groupCount; + groupCount = 0; + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + + // helper functions + + function addShape(shape) { + const indexOffset = vertices.length / 3; + const points = shape.extractPoints(curveSegments); + + let shapeVertices = points.shape; + const shapeHoles = points.holes; + + // check direction of vertices + + if (ShapeUtils.isClockWise(shapeVertices) === false) { + shapeVertices = shapeVertices.reverse(); + } + + for (let i = 0, l = shapeHoles.length; i < l; i++) { + const shapeHole = shapeHoles[i]; + + if (ShapeUtils.isClockWise(shapeHole) === true) { + shapeHoles[i] = shapeHole.reverse(); + } + } + + const faces = ShapeUtils.triangulateShape(shapeVertices, shapeHoles); + + // join vertices of inner and outer paths to a single array + + for (let i = 0, l = shapeHoles.length; i < l; i++) { + const shapeHole = shapeHoles[i]; + shapeVertices = shapeVertices.concat(shapeHole); + } + + // vertices, normals, uvs + + for (let i = 0, l = shapeVertices.length; i < l; i++) { + const vertex = shapeVertices[i]; + + vertices.push(vertex.x, vertex.y, 0); + normals.push(0, 0, 1); + uvs.push(vertex.x, vertex.y); // world uvs + } + + // incides + + for (let i = 0, l = faces.length; i < l; i++) { + const face = faces[i]; + + const a = face[0] + indexOffset; + const b = face[1] + indexOffset; + const c = face[2] + indexOffset; + + indices.push(a, b, c); + groupCount += 3; + } + } + } + + toJSON() { + const data = super.toJSON(); + + const shapes = this.parameters.shapes; + + return toJSON(shapes, data); + } + + static fromJSON(data, shapes) { + const geometryShapes = []; + + for (let j = 0, jl = data.shapes.length; j < jl; j++) { + const shape = shapes[data.shapes[j]]; + + geometryShapes.push(shape); + } + + return new ShapeGeometry(geometryShapes, data.curveSegments); + } +} + +function toJSON(shapes, data) { + data.shapes = []; + + if (Array.isArray(shapes)) { + for (let i = 0, l = shapes.length; i < l; i++) { + const shape = shapes[i]; + + data.shapes.push(shape.uuid); + } + } else { + data.shapes.push(shapes.uuid); + } + + return data; +} + +export { ShapeGeometry, ShapeGeometry as ShapeBufferGeometry }; diff --git a/backend/libs/three/geometries/SphereGeometry.d.ts b/backend/libs/three/geometries/SphereGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8f6489f0e8d63d883f6b8b6a6dd7a790e67625a8 --- /dev/null +++ b/backend/libs/three/geometries/SphereGeometry.d.ts @@ -0,0 +1,41 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class SphereGeometry extends BufferGeometry { + /** + * @param [radius=50] — sphere radius. Default is 50. + * @param [widthSegments=8] — number of horizontal segments. Minimum value is 3, and the default is 8. + * @param [heightSegments=6] — number of vertical segments. Minimum value is 2, and the default is 6. + * @param [phiStart=0] — specify horizontal starting angle. Default is 0. + * @param [phiLength=Math.PI * 2] — specify horizontal sweep angle size. Default is Math.PI * 2. + * @param [thetaStart=0] — specify vertical starting angle. Default is 0. + * @param [thetaLength=Math.PI * 2] — specify vertical sweep angle size. Default is Math.PI. + */ + constructor( + radius?: number, + widthSegments?: number, + heightSegments?: number, + phiStart?: number, + phiLength?: number, + thetaStart?: number, + thetaLength?: number + ); + + /** + * @default 'SphereGeometry' + */ + type: string; + + parameters: { + radius: number; + widthSegments: number; + heightSegments: number; + phiStart: number; + phiLength: number; + thetaStart: number; + thetaLength: number; + }; + + static fromJSON(data: any): SphereGeometry; +} + +export { SphereGeometry as SphereBufferGeometry }; diff --git a/backend/libs/three/geometries/SphereGeometry.js b/backend/libs/three/geometries/SphereGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..91fd39d050df155e9d7ba14c0be56073c348c3b4 --- /dev/null +++ b/backend/libs/three/geometries/SphereGeometry.js @@ -0,0 +1,108 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; + +class SphereGeometry extends BufferGeometry { + constructor(radius = 1, widthSegments = 32, heightSegments = 16, phiStart = 0, phiLength = Math.PI * 2, thetaStart = 0, thetaLength = Math.PI) { + super(); + this.type = 'SphereGeometry'; + + this.parameters = { + radius: radius, + widthSegments: widthSegments, + heightSegments: heightSegments, + phiStart: phiStart, + phiLength: phiLength, + thetaStart: thetaStart, + thetaLength: thetaLength, + }; + + widthSegments = Math.max(3, Math.floor(widthSegments)); + heightSegments = Math.max(2, Math.floor(heightSegments)); + + const thetaEnd = Math.min(thetaStart + thetaLength, Math.PI); + + let index = 0; + const grid = []; + + const vertex = new Vector3(); + const normal = new Vector3(); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // generate vertices, normals and uvs + + for (let iy = 0; iy <= heightSegments; iy++) { + const verticesRow = []; + + const v = iy / heightSegments; + + // special case for the poles + + let uOffset = 0; + + if (iy == 0 && thetaStart == 0) { + uOffset = 0.5 / widthSegments; + } else if (iy == heightSegments && thetaEnd == Math.PI) { + uOffset = -0.5 / widthSegments; + } + + for (let ix = 0; ix <= widthSegments; ix++) { + const u = ix / widthSegments; + + // vertex + + vertex.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); + vertex.y = radius * Math.cos(thetaStart + v * thetaLength); + vertex.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength); + + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + normal.copy(vertex).normalize(); + normals.push(normal.x, normal.y, normal.z); + + // uv + + uvs.push(u + uOffset, 1 - v); + + verticesRow.push(index++); + } + + grid.push(verticesRow); + } + + // indices + + for (let iy = 0; iy < heightSegments; iy++) { + for (let ix = 0; ix < widthSegments; ix++) { + const a = grid[iy][ix + 1]; + const b = grid[iy][ix]; + const c = grid[iy + 1][ix]; + const d = grid[iy + 1][ix + 1]; + + if (iy !== 0 || thetaStart > 0) indices.push(a, b, d); + if (iy !== heightSegments - 1 || thetaEnd < Math.PI) indices.push(b, c, d); + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + } + + static fromJSON(data) { + return new SphereGeometry(data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength); + } +} + +export { SphereGeometry, SphereGeometry as SphereBufferGeometry }; diff --git a/backend/libs/three/geometries/TetrahedronGeometry.d.ts b/backend/libs/three/geometries/TetrahedronGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..efa9c9cd5752d32aa57fb3d2af3453de268d8385 --- /dev/null +++ b/backend/libs/three/geometries/TetrahedronGeometry.d.ts @@ -0,0 +1,18 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry'; + +export class TetrahedronGeometry extends PolyhedronGeometry { + /** + * @param [radius=1] + * @param [detail=0] + */ + constructor(radius?: number, detail?: number); + + /** + * @default 'TetrahedronGeometry' + */ + type: string; + + static fromJSON(data: any): TetrahedronGeometry; +} + +export { TetrahedronGeometry as TetrahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/TetrahedronGeometry.js b/backend/libs/three/geometries/TetrahedronGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..f7f03eb57061be4bc5ccbd491b56efd50310a374 --- /dev/null +++ b/backend/libs/three/geometries/TetrahedronGeometry.js @@ -0,0 +1,24 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry.js'; + +class TetrahedronGeometry extends PolyhedronGeometry { + constructor(radius = 1, detail = 0) { + const vertices = [1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1]; + + const indices = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1]; + + super(vertices, indices, radius, detail); + + this.type = 'TetrahedronGeometry'; + + this.parameters = { + radius: radius, + detail: detail, + }; + } + + static fromJSON(data) { + return new TetrahedronGeometry(data.radius, data.detail); + } +} + +export { TetrahedronGeometry, TetrahedronGeometry as TetrahedronBufferGeometry }; diff --git a/backend/libs/three/geometries/TorusGeometry.d.ts b/backend/libs/three/geometries/TorusGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e553c5929dd316a2a33ca8626598957c16ff6e8c --- /dev/null +++ b/backend/libs/three/geometries/TorusGeometry.d.ts @@ -0,0 +1,29 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TorusGeometry extends BufferGeometry { + /** + * @param [radius=1] + * @param [tube=0.4] + * @param [radialSegments=8] + * @param [tubularSegments=6] + * @param [arc=Math.PI * 2] + */ + constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number); + + /** + * @default 'TorusGeometry' + */ + type: string; + + parameters: { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; + }; + + static fromJSON(data: any): TorusGeometry; +} + +export { TorusGeometry as TorusBufferGeometry }; diff --git a/backend/libs/three/geometries/TorusGeometry.js b/backend/libs/three/geometries/TorusGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..b05a82468db45dd3e6da56efdd7b2723bd9f44d0 --- /dev/null +++ b/backend/libs/three/geometries/TorusGeometry.js @@ -0,0 +1,95 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; + +class TorusGeometry extends BufferGeometry { + constructor(radius = 1, tube = 0.4, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2) { + super(); + this.type = 'TorusGeometry'; + + this.parameters = { + radius: radius, + tube: tube, + radialSegments: radialSegments, + tubularSegments: tubularSegments, + arc: arc, + }; + + radialSegments = Math.floor(radialSegments); + tubularSegments = Math.floor(tubularSegments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const center = new Vector3(); + const vertex = new Vector3(); + const normal = new Vector3(); + + // generate vertices, normals and uvs + + for (let j = 0; j <= radialSegments; j++) { + for (let i = 0; i <= tubularSegments; i++) { + const u = (i / tubularSegments) * arc; + const v = (j / radialSegments) * Math.PI * 2; + + // vertex + + vertex.x = (radius + tube * Math.cos(v)) * Math.cos(u); + vertex.y = (radius + tube * Math.cos(v)) * Math.sin(u); + vertex.z = tube * Math.sin(v); + + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal + + center.x = radius * Math.cos(u); + center.y = radius * Math.sin(u); + normal.subVectors(vertex, center).normalize(); + + normals.push(normal.x, normal.y, normal.z); + + // uv + + uvs.push(i / tubularSegments); + uvs.push(j / radialSegments); + } + } + + // generate indices + + for (let j = 1; j <= radialSegments; j++) { + for (let i = 1; i <= tubularSegments; i++) { + // indices + + const a = (tubularSegments + 1) * j + i - 1; + const b = (tubularSegments + 1) * (j - 1) + i - 1; + const c = (tubularSegments + 1) * (j - 1) + i; + const d = (tubularSegments + 1) * j + i; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + } + + static fromJSON(data) { + return new TorusGeometry(data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc); + } +} + +export { TorusGeometry, TorusGeometry as TorusBufferGeometry }; diff --git a/backend/libs/three/geometries/TorusKnotGeometry.d.ts b/backend/libs/three/geometries/TorusKnotGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e5968ad4bcd4e4438ceb8c22ddb4263cc8820123 --- /dev/null +++ b/backend/libs/three/geometries/TorusKnotGeometry.d.ts @@ -0,0 +1,31 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TorusKnotGeometry extends BufferGeometry { + /** + * @param [radius=1] + * @param [tube=0.4] + * @param [radialSegments=64] + * @param [tubularSegments=8] + * @param [p=2] + * @param [q=3] + */ + constructor(radius?: number, tube?: number, tubularSegments?: number, radialSegments?: number, p?: number, q?: number); + + /** + * @default 'TorusKnotGeometry' + */ + type: string; + + parameters: { + radius: number; + tube: number; + tubularSegments: number; + radialSegments: number; + p: number; + q: number; + }; + + static fromJSON(data: any): TorusKnotGeometry; +} + +export { TorusKnotGeometry as TorusKnotBufferGeometry }; diff --git a/backend/libs/three/geometries/TorusKnotGeometry.js b/backend/libs/three/geometries/TorusKnotGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..a34b835d254afca8d6b7ee3c81f15b92b4fa4541 --- /dev/null +++ b/backend/libs/three/geometries/TorusKnotGeometry.js @@ -0,0 +1,140 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; + +class TorusKnotGeometry extends BufferGeometry { + constructor(radius = 1, tube = 0.4, tubularSegments = 64, radialSegments = 8, p = 2, q = 3) { + super(); + this.type = 'TorusKnotGeometry'; + + this.parameters = { + radius: radius, + tube: tube, + tubularSegments: tubularSegments, + radialSegments: radialSegments, + p: p, + q: q, + }; + + tubularSegments = Math.floor(tubularSegments); + radialSegments = Math.floor(radialSegments); + + // buffers + + const indices = []; + const vertices = []; + const normals = []; + const uvs = []; + + // helper variables + + const vertex = new Vector3(); + const normal = new Vector3(); + + const P1 = new Vector3(); + const P2 = new Vector3(); + + const B = new Vector3(); + const T = new Vector3(); + const N = new Vector3(); + + // generate vertices, normals and uvs + + for (let i = 0; i <= tubularSegments; ++i) { + // the radian "u" is used to calculate the position on the torus curve of the current tubular segement + + const u = (i / tubularSegments) * p * Math.PI * 2; + + // now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead. + // these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions + + calculatePositionOnCurve(u, p, q, radius, P1); + calculatePositionOnCurve(u + 0.01, p, q, radius, P2); + + // calculate orthonormal basis + + T.subVectors(P2, P1); + N.addVectors(P2, P1); + B.crossVectors(T, N); + N.crossVectors(B, T); + + // normalize B, N. T can be ignored, we don't use it + + B.normalize(); + N.normalize(); + + for (let j = 0; j <= radialSegments; ++j) { + // now calculate the vertices. they are nothing more than an extrusion of the torus curve. + // because we extrude a shape in the xy-plane, there is no need to calculate a z-value. + + const v = (j / radialSegments) * Math.PI * 2; + const cx = -tube * Math.cos(v); + const cy = tube * Math.sin(v); + + // now calculate the final vertex position. + // first we orient the extrusion with our basis vectos, then we add it to the current position on the curve + + vertex.x = P1.x + (cx * N.x + cy * B.x); + vertex.y = P1.y + (cx * N.y + cy * B.y); + vertex.z = P1.z + (cx * N.z + cy * B.z); + + vertices.push(vertex.x, vertex.y, vertex.z); + + // normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal) + + normal.subVectors(vertex, P1).normalize(); + + normals.push(normal.x, normal.y, normal.z); + + // uv + + uvs.push(i / tubularSegments); + uvs.push(j / radialSegments); + } + } + + // generate indices + + for (let j = 1; j <= tubularSegments; j++) { + for (let i = 1; i <= radialSegments; i++) { + // indices + + const a = (radialSegments + 1) * (j - 1) + (i - 1); + const b = (radialSegments + 1) * j + (i - 1); + const c = (radialSegments + 1) * j + i; + const d = (radialSegments + 1) * (j - 1) + i; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + + // this function calculates the current position on the torus curve + + function calculatePositionOnCurve(u, p, q, radius, position) { + const cu = Math.cos(u); + const su = Math.sin(u); + const quOverP = (q / p) * u; + const cs = Math.cos(quOverP); + + position.x = radius * (2 + cs) * 0.5 * cu; + position.y = radius * (2 + cs) * su * 0.5; + position.z = radius * Math.sin(quOverP) * 0.5; + } + } + + static fromJSON(data) { + return new TorusKnotGeometry(data.radius, data.tube, data.tubularSegments, data.radialSegments, data.p, data.q); + } +} + +export { TorusKnotGeometry, TorusKnotGeometry as TorusKnotBufferGeometry }; diff --git a/backend/libs/three/geometries/TubeGeometry.d.ts b/backend/libs/three/geometries/TubeGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b8e1a1ae6d14c2d7c7aef5675490112124a0b018 --- /dev/null +++ b/backend/libs/three/geometries/TubeGeometry.d.ts @@ -0,0 +1,34 @@ +import { Curve } from './../extras/core/Curve'; +import { Vector3 } from './../math/Vector3'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TubeGeometry extends BufferGeometry { + /** + * @param path + * @param [tubularSegments=64] + * @param [radius=1] + * @param [radiusSegments=8] + * @param [closed=false] + */ + constructor(path?: Curve, tubularSegments?: number, radius?: number, radiusSegments?: number, closed?: boolean); + + /** + * @default 'TubeGeometry' + */ + type: string; + + parameters: { + path: Curve; + tubularSegments: number; + radius: number; + radialSegments: number; + closed: boolean; + }; + tangents: Vector3[]; + normals: Vector3[]; + binormals: Vector3[]; + + static fromJSON(data: any): TubeGeometry; +} + +export { TubeGeometry as TubeBufferGeometry }; diff --git a/backend/libs/three/geometries/TubeGeometry.js b/backend/libs/three/geometries/TubeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..973a8dac5e224b76c939b3d045f8ee83c80b6e9a --- /dev/null +++ b/backend/libs/three/geometries/TubeGeometry.js @@ -0,0 +1,163 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import * as Curves from '../extras/curves/Curves.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; + +class TubeGeometry extends BufferGeometry { + constructor( + path = new Curves['QuadraticBezierCurve3'](new Vector3(-1, -1, 0), new Vector3(-1, 1, 0), new Vector3(1, 1, 0)), + tubularSegments = 64, + radius = 1, + radialSegments = 8, + closed = false + ) { + super(); + this.type = 'TubeGeometry'; + + this.parameters = { + path: path, + tubularSegments: tubularSegments, + radius: radius, + radialSegments: radialSegments, + closed: closed, + }; + + const frames = path.computeFrenetFrames(tubularSegments, closed); + + // expose internals + + this.tangents = frames.tangents; + this.normals = frames.normals; + this.binormals = frames.binormals; + + // helper variables + + const vertex = new Vector3(); + const normal = new Vector3(); + const uv = new Vector2(); + let P = new Vector3(); + + // buffer + + const vertices = []; + const normals = []; + const uvs = []; + const indices = []; + + // create buffer data + + generateBufferData(); + + // build geometry + + this.setIndex(indices); + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.setAttribute('normal', new Float32BufferAttribute(normals, 3)); + this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); + + // functions + + function generateBufferData() { + for (let i = 0; i < tubularSegments; i++) { + generateSegment(i); + } + + // if the geometry is not closed, generate the last row of vertices and normals + // at the regular position on the given path + // + // if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ) + + generateSegment(closed === false ? tubularSegments : 0); + + // uvs are generated in a separate function. + // this makes it easy compute correct values for closed geometries + + generateUVs(); + + // finally create faces + + generateIndices(); + } + + function generateSegment(i) { + // we use getPointAt to sample evenly distributed points from the given path + + P = path.getPointAt(i / tubularSegments, P); + + // retrieve corresponding normal and binormal + + const N = frames.normals[i]; + const B = frames.binormals[i]; + + // generate normals and vertices for the current segment + + for (let j = 0; j <= radialSegments; j++) { + const v = (j / radialSegments) * Math.PI * 2; + + const sin = Math.sin(v); + const cos = -Math.cos(v); + + // normal + + normal.x = cos * N.x + sin * B.x; + normal.y = cos * N.y + sin * B.y; + normal.z = cos * N.z + sin * B.z; + normal.normalize(); + + normals.push(normal.x, normal.y, normal.z); + + // vertex + + vertex.x = P.x + radius * normal.x; + vertex.y = P.y + radius * normal.y; + vertex.z = P.z + radius * normal.z; + + vertices.push(vertex.x, vertex.y, vertex.z); + } + } + + function generateIndices() { + for (let j = 1; j <= tubularSegments; j++) { + for (let i = 1; i <= radialSegments; i++) { + const a = (radialSegments + 1) * (j - 1) + (i - 1); + const b = (radialSegments + 1) * j + (i - 1); + const c = (radialSegments + 1) * j + i; + const d = (radialSegments + 1) * (j - 1) + i; + + // faces + + indices.push(a, b, d); + indices.push(b, c, d); + } + } + } + + function generateUVs() { + for (let i = 0; i <= tubularSegments; i++) { + for (let j = 0; j <= radialSegments; j++) { + uv.x = i / tubularSegments; + uv.y = j / radialSegments; + + uvs.push(uv.x, uv.y); + } + } + } + } + + toJSON() { + const data = super.toJSON(); + + data.path = this.parameters.path.toJSON(); + + return data; + } + + static fromJSON(data) { + // This only works for built-in curves (e.g. CatmullRomCurve3). + // User defined curves or instances of CurvePath will not be deserialized. + return new TubeGeometry(new Curves[data.path.type]().fromJSON(data.path), data.tubularSegments, data.radius, data.radialSegments, data.closed); + } +} + +export { TubeGeometry, TubeGeometry as TubeBufferGeometry }; diff --git a/backend/libs/three/geometries/WireframeGeometry.d.ts b/backend/libs/three/geometries/WireframeGeometry.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b893cdefd727456ffd2294922228c2c63e8dbf6e --- /dev/null +++ b/backend/libs/three/geometries/WireframeGeometry.d.ts @@ -0,0 +1,14 @@ +import { BufferGeometry } from './../core/BufferGeometry'; + +export class WireframeGeometry extends BufferGeometry { + constructor(geometry?: TBufferGeometry); + + /** + * @default 'WireframeGeometry' + */ + type: string; + + parameters: { + geometry: TBufferGeometry; + }; +} diff --git a/backend/libs/three/geometries/WireframeGeometry.js b/backend/libs/three/geometries/WireframeGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..9c6665294162546da306b899829cfa27709d2590 --- /dev/null +++ b/backend/libs/three/geometries/WireframeGeometry.js @@ -0,0 +1,102 @@ +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { Vector3 } from '../math/Vector3.js'; + +class WireframeGeometry extends BufferGeometry { + constructor(geometry = null) { + super(); + this.type = 'WireframeGeometry'; + + this.parameters = { + geometry: geometry, + }; + + if (geometry !== null) { + // buffer + + const vertices = []; + const edges = new Set(); + + // helper variables + + const start = new Vector3(); + const end = new Vector3(); + + if (geometry.index !== null) { + // indexed BufferGeometry + + const position = geometry.attributes.position; + const indices = geometry.index; + let groups = geometry.groups; + + if (groups.length === 0) { + groups = [{ start: 0, count: indices.count, materialIndex: 0 }]; + } + + // create a data structure that contains all eges without duplicates + + for (let o = 0, ol = groups.length; o < ol; ++o) { + const group = groups[o]; + + const groupStart = group.start; + const groupCount = group.count; + + for (let i = groupStart, l = groupStart + groupCount; i < l; i += 3) { + for (let j = 0; j < 3; j++) { + const index1 = indices.getX(i + j); + const index2 = indices.getX(i + ((j + 1) % 3)); + + start.fromBufferAttribute(position, index1); + end.fromBufferAttribute(position, index2); + + if (isUniqueEdge(start, end, edges) === true) { + vertices.push(start.x, start.y, start.z); + vertices.push(end.x, end.y, end.z); + } + } + } + } + } else { + // non-indexed BufferGeometry + + const position = geometry.attributes.position; + + for (let i = 0, l = position.count / 3; i < l; i++) { + for (let j = 0; j < 3; j++) { + // three edges per triangle, an edge is represented as (index1, index2) + // e.g. the first triangle has the following edges: (0,1),(1,2),(2,0) + + const index1 = 3 * i + j; + const index2 = 3 * i + ((j + 1) % 3); + + start.fromBufferAttribute(position, index1); + end.fromBufferAttribute(position, index2); + + if (isUniqueEdge(start, end, edges) === true) { + vertices.push(start.x, start.y, start.z); + vertices.push(end.x, end.y, end.z); + } + } + } + } + + // build geometry + + this.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + } + } +} + +function isUniqueEdge(start, end, edges) { + const hash1 = `${start.x},${start.y},${start.z}-${end.x},${end.y},${end.z}`; + const hash2 = `${end.x},${end.y},${end.z}-${start.x},${start.y},${start.z}`; // coincident edge + + if (edges.has(hash1) === true || edges.has(hash2) === true) { + return false; + } else { + edges.add(hash1, hash2); + return true; + } +} + +export { WireframeGeometry }; diff --git a/backend/libs/three/helpers/ArrowHelper.d.ts b/backend/libs/three/helpers/ArrowHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..99c4c87d13b3ff14b1bcd5279c7e1c75723c2adc --- /dev/null +++ b/backend/libs/three/helpers/ArrowHelper.d.ts @@ -0,0 +1,51 @@ +import { Vector3 } from './../math/Vector3'; +import { Line } from './../objects/Line'; +import { Mesh } from './../objects/Mesh'; +import { Object3D } from './../core/Object3D'; +import { ColorRepresentation } from '../utils'; + +// Extras / Helpers ///////////////////////////////////////////////////////////////////// + +export class ArrowHelper extends Object3D { + /** + * @param [dir] Direction from origin. Must be a unit vector. + * @param [origin] Point at which the arrow starts. + * @param [length] Length of the arrow. + * @param [color] Hexadecimal value to define color. + * @param [headLength] The length of the head of the arrow. + * @param [headWidth] The width of the head of the arrow. + */ + constructor(dir?: Vector3, origin?: Vector3, length?: number, color?: ColorRepresentation, headLength?: number, headWidth?: number); + + /** + * @default 'ArrowHelper' + */ + type: string; + + /** + * Contains the line part of the arrowHelper. + */ + line: Line; + + /** + * Contains the cone part of the arrowHelper. + */ + cone: Mesh; + + /** + * @param dir The desired direction. Must be a unit vector. + */ + setDirection(dir: Vector3): void; + + /** + * @param length The desired length. + * @param [headLength] The length of the head of the arrow. + * @param [headWidth] The width of the head of the arrow. + */ + setLength(length: number, headLength?: number, headWidth?: number): void; + + /** + * @param color The desired color. + */ + setColor(color: ColorRepresentation): void; +} diff --git a/backend/libs/three/helpers/ArrowHelper.js b/backend/libs/three/helpers/ArrowHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..dffaa5053fb45d77fc013c722884f0e2e7585cf8 --- /dev/null +++ b/backend/libs/three/helpers/ArrowHelper.js @@ -0,0 +1,91 @@ +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Object3D } from '../core/Object3D.js'; +import { CylinderGeometry } from '../geometries/CylinderGeometry.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Mesh } from '../objects/Mesh.js'; +import { Line } from '../objects/Line.js'; +import { Vector3 } from '../math/Vector3.js'; + +const _axis = /*@__PURE__*/ new Vector3(); +let _lineGeometry, _coneGeometry; + +class ArrowHelper extends Object3D { + // dir is assumed to be normalized + + constructor( + dir = new Vector3(0, 0, 1), + origin = new Vector3(0, 0, 0), + length = 1, + color = 0xffff00, + headLength = length * 0.2, + headWidth = headLength * 0.2 + ) { + super(); + + this.type = 'ArrowHelper'; + + if (_lineGeometry === undefined) { + _lineGeometry = new BufferGeometry(); + _lineGeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3)); + + _coneGeometry = new CylinderGeometry(0, 0.5, 1, 5, 1); + _coneGeometry.translate(0, -0.5, 0); + } + + this.position.copy(origin); + + this.line = new Line(_lineGeometry, new LineBasicMaterial({ color: color, toneMapped: false })); + this.line.matrixAutoUpdate = false; + this.add(this.line); + + this.cone = new Mesh(_coneGeometry, new MeshBasicMaterial({ color: color, toneMapped: false })); + this.cone.matrixAutoUpdate = false; + this.add(this.cone); + + this.setDirection(dir); + this.setLength(length, headLength, headWidth); + } + + setDirection(dir) { + // dir is assumed to be normalized + + if (dir.y > 0.99999) { + this.quaternion.set(0, 0, 0, 1); + } else if (dir.y < -0.99999) { + this.quaternion.set(1, 0, 0, 0); + } else { + _axis.set(dir.z, 0, -dir.x).normalize(); + + const radians = Math.acos(dir.y); + + this.quaternion.setFromAxisAngle(_axis, radians); + } + } + + setLength(length, headLength = length * 0.2, headWidth = headLength * 0.2) { + this.line.scale.set(1, Math.max(0.0001, length - headLength), 1); // see #17458 + this.line.updateMatrix(); + + this.cone.scale.set(headWidth, headLength, headWidth); + this.cone.position.y = length; + this.cone.updateMatrix(); + } + + setColor(color) { + this.line.material.color.set(color); + this.cone.material.color.set(color); + } + + copy(source) { + super.copy(source, false); + + this.line.copy(source.line); + this.cone.copy(source.cone); + + return this; + } +} + +export { ArrowHelper }; diff --git a/backend/libs/three/helpers/AxesHelper.d.ts b/backend/libs/three/helpers/AxesHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c2304f2e57ecd399a948b88f7746d1c0926144bc --- /dev/null +++ b/backend/libs/three/helpers/AxesHelper.d.ts @@ -0,0 +1,18 @@ +import { Color } from '../math/Color'; +import { LineSegments } from './../objects/LineSegments'; + +export class AxesHelper extends LineSegments { + /** + * @param [size=1] + */ + constructor(size?: number); + + /** + * @default 'AxesHelper' + */ + type: string; + + setColors(xAxisColor: Color, yAxisColor: Color, zAxisColor: Color): this; + + dispose(): void; +} diff --git a/backend/libs/three/helpers/AxesHelper.js b/backend/libs/three/helpers/AxesHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..2e6e299c5288ad1270f36c36de8f8f4febdcb619 --- /dev/null +++ b/backend/libs/three/helpers/AxesHelper.js @@ -0,0 +1,51 @@ +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Color } from '../math/Color.js'; + +class AxesHelper extends LineSegments { + constructor(size = 1) { + const vertices = [0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size]; + + const colors = [1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1]; + + const geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + geometry.setAttribute('color', new Float32BufferAttribute(colors, 3)); + + const material = new LineBasicMaterial({ vertexColors: true, toneMapped: false }); + + super(geometry, material); + + this.type = 'AxesHelper'; + } + + setColors(xAxisColor, yAxisColor, zAxisColor) { + const color = new Color(); + const array = this.geometry.attributes.color.array; + + color.set(xAxisColor); + color.toArray(array, 0); + color.toArray(array, 3); + + color.set(yAxisColor); + color.toArray(array, 6); + color.toArray(array, 9); + + color.set(zAxisColor); + color.toArray(array, 12); + color.toArray(array, 15); + + this.geometry.attributes.color.needsUpdate = true; + + return this; + } + + dispose() { + this.geometry.dispose(); + this.material.dispose(); + } +} + +export { AxesHelper }; diff --git a/backend/libs/three/helpers/Box3Helper.d.ts b/backend/libs/three/helpers/Box3Helper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5f42e54b798378f9b2dd62848bcd51db0e36b63f --- /dev/null +++ b/backend/libs/three/helpers/Box3Helper.d.ts @@ -0,0 +1,18 @@ +import { Box3 } from './../math/Box3'; +import { Color } from './../math/Color'; +import { LineSegments } from './../objects/LineSegments'; + +export class Box3Helper extends LineSegments { + /** + * @param box + * @param [color=0xffff00] + */ + constructor(box: Box3, color?: Color); + + /** + * @default 'Box3Helper' + */ + type: string; + + box: Box3; +} diff --git a/backend/libs/three/helpers/Box3Helper.js b/backend/libs/three/helpers/Box3Helper.js new file mode 100644 index 0000000000000000000000000000000000000000..af4b3727e433e6f545fe134ae80f5f9bbe858f11 --- /dev/null +++ b/backend/libs/three/helpers/Box3Helper.js @@ -0,0 +1,43 @@ +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { BufferAttribute } from '../core/BufferAttribute.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; + +class Box3Helper extends LineSegments { + constructor(box, color = 0xffff00) { + const indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]); + + const positions = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1]; + + const geometry = new BufferGeometry(); + + geometry.setIndex(new BufferAttribute(indices, 1)); + + geometry.setAttribute('position', new Float32BufferAttribute(positions, 3)); + + super(geometry, new LineBasicMaterial({ color: color, toneMapped: false })); + + this.box = box; + + this.type = 'Box3Helper'; + + this.geometry.computeBoundingSphere(); + } + + updateMatrixWorld(force) { + const box = this.box; + + if (box.isEmpty()) return; + + box.getCenter(this.position); + + box.getSize(this.scale); + + this.scale.multiplyScalar(0.5); + + super.updateMatrixWorld(force); + } +} + +export { Box3Helper }; diff --git a/backend/libs/three/helpers/BoxHelper.d.ts b/backend/libs/three/helpers/BoxHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..662a792a778f63235f71d763883a36bc377a5ada --- /dev/null +++ b/backend/libs/three/helpers/BoxHelper.d.ts @@ -0,0 +1,20 @@ +import { ColorRepresentation } from '../utils'; +import { Object3D } from './../core/Object3D'; +import { LineSegments } from './../objects/LineSegments'; + +export class BoxHelper extends LineSegments { + /** + * @param object + * @param [color=0xffff00] + */ + constructor(object: Object3D, color?: ColorRepresentation); + + /** + * @default 'BoxHelper' + */ + type: string; + + update(object?: Object3D): void; + + setFromObject(object: Object3D): this; +} diff --git a/backend/libs/three/helpers/BoxHelper.js b/backend/libs/three/helpers/BoxHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..5715e5edc92655e9c29b035bc7131789cfd44fe1 --- /dev/null +++ b/backend/libs/three/helpers/BoxHelper.js @@ -0,0 +1,107 @@ +import { Box3 } from '../math/Box3.js'; +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; + +const _box = /*@__PURE__*/ new Box3(); + +class BoxHelper extends LineSegments { + constructor(object, color = 0xffff00) { + const indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]); + const positions = new Float32Array(8 * 3); + + const geometry = new BufferGeometry(); + geometry.setIndex(new BufferAttribute(indices, 1)); + geometry.setAttribute('position', new BufferAttribute(positions, 3)); + + super(geometry, new LineBasicMaterial({ color: color, toneMapped: false })); + + this.object = object; + this.type = 'BoxHelper'; + + this.matrixAutoUpdate = false; + + this.update(); + } + + update(object) { + if (object !== undefined) { + console.warn('THREE.BoxHelper: .update() has no longer arguments.'); + } + + if (this.object !== undefined) { + _box.setFromObject(this.object); + } + + if (_box.isEmpty()) return; + + const min = _box.min; + const max = _box.max; + + /* + 5____4 + 1/___0/| + | 6__|_7 + 2/___3/ + + 0: max.x, max.y, max.z + 1: min.x, max.y, max.z + 2: min.x, min.y, max.z + 3: max.x, min.y, max.z + 4: max.x, max.y, min.z + 5: min.x, max.y, min.z + 6: min.x, min.y, min.z + 7: max.x, min.y, min.z + */ + + const position = this.geometry.attributes.position; + const array = position.array; + + array[0] = max.x; + array[1] = max.y; + array[2] = max.z; + array[3] = min.x; + array[4] = max.y; + array[5] = max.z; + array[6] = min.x; + array[7] = min.y; + array[8] = max.z; + array[9] = max.x; + array[10] = min.y; + array[11] = max.z; + array[12] = max.x; + array[13] = max.y; + array[14] = min.z; + array[15] = min.x; + array[16] = max.y; + array[17] = min.z; + array[18] = min.x; + array[19] = min.y; + array[20] = min.z; + array[21] = max.x; + array[22] = min.y; + array[23] = min.z; + + position.needsUpdate = true; + + this.geometry.computeBoundingSphere(); + } + + setFromObject(object) { + this.object = object; + this.update(); + + return this; + } + + copy(source) { + LineSegments.prototype.copy.call(this, source); + + this.object = source.object; + + return this; + } +} + +export { BoxHelper }; diff --git a/backend/libs/three/helpers/CameraHelper.d.ts b/backend/libs/three/helpers/CameraHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..42301f0660a2280dc23a4e839b9e307a0fcdacae --- /dev/null +++ b/backend/libs/three/helpers/CameraHelper.d.ts @@ -0,0 +1,18 @@ +import { Camera } from './../cameras/Camera'; +import { LineSegments } from './../objects/LineSegments'; + +export class CameraHelper extends LineSegments { + constructor(camera: Camera); + + camera: Camera; + pointMap: { [id: string]: number[] }; + + /** + * @default 'CameraHelper' + */ + type: string; + + update(): void; + + dispose(): void; +} diff --git a/backend/libs/three/helpers/CameraHelper.js b/backend/libs/three/helpers/CameraHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..ba18334351ac168496cf1e2f5e4879c35816fd9e --- /dev/null +++ b/backend/libs/three/helpers/CameraHelper.js @@ -0,0 +1,190 @@ +import { Camera } from '../cameras/Camera.js'; +import { Vector3 } from '../math/Vector3.js'; +import { LineSegments } from '../objects/LineSegments.js'; +import { Color } from '../math/Color.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; + +const _vector = /*@__PURE__*/ new Vector3(); +const _camera = /*@__PURE__*/ new Camera(); + +/** + * - shows frustum, line of sight and up of the camera + * - suitable for fast updates + * - based on frustum visualization in lightgl.js shadowmap example + * https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html + */ + +class CameraHelper extends LineSegments { + constructor(camera) { + const geometry = new BufferGeometry(); + const material = new LineBasicMaterial({ color: 0xffffff, vertexColors: true, toneMapped: false }); + + const vertices = []; + const colors = []; + + const pointMap = {}; + + // colors + + const colorFrustum = new Color(0xffaa00); + const colorCone = new Color(0xff0000); + const colorUp = new Color(0x00aaff); + const colorTarget = new Color(0xffffff); + const colorCross = new Color(0x333333); + + // near + + addLine('n1', 'n2', colorFrustum); + addLine('n2', 'n4', colorFrustum); + addLine('n4', 'n3', colorFrustum); + addLine('n3', 'n1', colorFrustum); + + // far + + addLine('f1', 'f2', colorFrustum); + addLine('f2', 'f4', colorFrustum); + addLine('f4', 'f3', colorFrustum); + addLine('f3', 'f1', colorFrustum); + + // sides + + addLine('n1', 'f1', colorFrustum); + addLine('n2', 'f2', colorFrustum); + addLine('n3', 'f3', colorFrustum); + addLine('n4', 'f4', colorFrustum); + + // cone + + addLine('p', 'n1', colorCone); + addLine('p', 'n2', colorCone); + addLine('p', 'n3', colorCone); + addLine('p', 'n4', colorCone); + + // up + + addLine('u1', 'u2', colorUp); + addLine('u2', 'u3', colorUp); + addLine('u3', 'u1', colorUp); + + // target + + addLine('c', 't', colorTarget); + addLine('p', 'c', colorCross); + + // cross + + addLine('cn1', 'cn2', colorCross); + addLine('cn3', 'cn4', colorCross); + + addLine('cf1', 'cf2', colorCross); + addLine('cf3', 'cf4', colorCross); + + function addLine(a, b, color) { + addPoint(a, color); + addPoint(b, color); + } + + function addPoint(id, color) { + vertices.push(0, 0, 0); + colors.push(color.r, color.g, color.b); + + if (pointMap[id] === undefined) { + pointMap[id] = []; + } + + pointMap[id].push(vertices.length / 3 - 1); + } + + geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + geometry.setAttribute('color', new Float32BufferAttribute(colors, 3)); + + super(geometry, material); + + this.type = 'CameraHelper'; + + this.camera = camera; + if (this.camera.updateProjectionMatrix) this.camera.updateProjectionMatrix(); + + this.matrix = camera.matrixWorld; + this.matrixAutoUpdate = false; + + this.pointMap = pointMap; + + this.update(); + } + + update() { + const geometry = this.geometry; + const pointMap = this.pointMap; + + const w = 1, + h = 1; + + // we need just camera projection matrix inverse + // world matrix must be identity + + _camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse); + + // center / target + + setPoint('c', pointMap, geometry, _camera, 0, 0, -1); + setPoint('t', pointMap, geometry, _camera, 0, 0, 1); + + // near + + setPoint('n1', pointMap, geometry, _camera, -w, -h, -1); + setPoint('n2', pointMap, geometry, _camera, w, -h, -1); + setPoint('n3', pointMap, geometry, _camera, -w, h, -1); + setPoint('n4', pointMap, geometry, _camera, w, h, -1); + + // far + + setPoint('f1', pointMap, geometry, _camera, -w, -h, 1); + setPoint('f2', pointMap, geometry, _camera, w, -h, 1); + setPoint('f3', pointMap, geometry, _camera, -w, h, 1); + setPoint('f4', pointMap, geometry, _camera, w, h, 1); + + // up + + setPoint('u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, -1); + setPoint('u2', pointMap, geometry, _camera, -w * 0.7, h * 1.1, -1); + setPoint('u3', pointMap, geometry, _camera, 0, h * 2, -1); + + // cross + + setPoint('cf1', pointMap, geometry, _camera, -w, 0, 1); + setPoint('cf2', pointMap, geometry, _camera, w, 0, 1); + setPoint('cf3', pointMap, geometry, _camera, 0, -h, 1); + setPoint('cf4', pointMap, geometry, _camera, 0, h, 1); + + setPoint('cn1', pointMap, geometry, _camera, -w, 0, -1); + setPoint('cn2', pointMap, geometry, _camera, w, 0, -1); + setPoint('cn3', pointMap, geometry, _camera, 0, -h, -1); + setPoint('cn4', pointMap, geometry, _camera, 0, h, -1); + + geometry.getAttribute('position').needsUpdate = true; + } + + dispose() { + this.geometry.dispose(); + this.material.dispose(); + } +} + +function setPoint(point, pointMap, geometry, camera, x, y, z) { + _vector.set(x, y, z).unproject(camera); + + const points = pointMap[point]; + + if (points !== undefined) { + const position = geometry.getAttribute('position'); + + for (let i = 0, l = points.length; i < l; i++) { + position.setXYZ(points[i], _vector.x, _vector.y, _vector.z); + } + } +} + +export { CameraHelper }; diff --git a/backend/libs/three/helpers/DirectionalLightHelper.d.ts b/backend/libs/three/helpers/DirectionalLightHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cf876131a137287a06b1d0513d22fc3c3d800961 --- /dev/null +++ b/backend/libs/three/helpers/DirectionalLightHelper.d.ts @@ -0,0 +1,32 @@ +import { DirectionalLight } from './../lights/DirectionalLight'; +import { Line } from './../objects/Line'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; +import { ColorRepresentation } from '../utils'; + +export class DirectionalLightHelper extends Object3D { + /** + * @param light + * @param [size=1] + * @param color + */ + constructor(light: DirectionalLight, size?: number, color?: ColorRepresentation); + + light: DirectionalLight; + lightPlane: Line; + targetLine: Line; + + /** + * @default undefined + */ + color: ColorRepresentation | undefined; + matrix: Matrix4; + + /** + * @default false + */ + matrixAutoUpdate: boolean; + + dispose(): void; + update(): void; +} diff --git a/backend/libs/three/helpers/DirectionalLightHelper.js b/backend/libs/three/helpers/DirectionalLightHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..b1da41f7c8f59e6e515aa6f13d42b64a9ff8af3b --- /dev/null +++ b/backend/libs/three/helpers/DirectionalLightHelper.js @@ -0,0 +1,69 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Object3D } from '../core/Object3D.js'; +import { Line } from '../objects/Line.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; + +const _v1 = /*@__PURE__*/ new Vector3(); +const _v2 = /*@__PURE__*/ new Vector3(); +const _v3 = /*@__PURE__*/ new Vector3(); + +class DirectionalLightHelper extends Object3D { + constructor(light, size, color) { + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + if (size === undefined) size = 1; + + let geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute([-size, size, 0, size, size, 0, size, -size, 0, -size, -size, 0, -size, size, 0], 3)); + + const material = new LineBasicMaterial({ fog: false, toneMapped: false }); + + this.lightPlane = new Line(geometry, material); + this.add(this.lightPlane); + + geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3)); + + this.targetLine = new Line(geometry, material); + this.add(this.targetLine); + + this.update(); + } + + dispose() { + this.lightPlane.geometry.dispose(); + this.lightPlane.material.dispose(); + this.targetLine.geometry.dispose(); + this.targetLine.material.dispose(); + } + + update() { + _v1.setFromMatrixPosition(this.light.matrixWorld); + _v2.setFromMatrixPosition(this.light.target.matrixWorld); + _v3.subVectors(_v2, _v1); + + this.lightPlane.lookAt(_v2); + + if (this.color !== undefined) { + this.lightPlane.material.color.set(this.color); + this.targetLine.material.color.set(this.color); + } else { + this.lightPlane.material.color.copy(this.light.color); + this.targetLine.material.color.copy(this.light.color); + } + + this.targetLine.lookAt(_v2); + this.targetLine.scale.z = _v3.length(); + } +} + +export { DirectionalLightHelper }; diff --git a/backend/libs/three/helpers/GridHelper.d.ts b/backend/libs/three/helpers/GridHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c2d8e6f436b9d3d865fd1b0680b48e67ce5362ee --- /dev/null +++ b/backend/libs/three/helpers/GridHelper.d.ts @@ -0,0 +1,22 @@ +import { ColorRepresentation } from '../utils'; +import { LineSegments } from './../objects/LineSegments'; + +export class GridHelper extends LineSegments { + /** + * @param [size=10] + * @param [divisions=10] + * @param [color1=0x444444] + * @param [color2=0x888888] + */ + constructor(size?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation); + + /** + * @default 'GridHelper' + */ + type: string; + + /** + * @deprecated Colors should be specified in the constructor. + */ + setColors(color1?: ColorRepresentation, color2?: ColorRepresentation): void; +} diff --git a/backend/libs/three/helpers/GridHelper.js b/backend/libs/three/helpers/GridHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..2b5228598f8f3ef7a7bf3d618e2ea6497326f37f --- /dev/null +++ b/backend/libs/three/helpers/GridHelper.js @@ -0,0 +1,47 @@ +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Color } from '../math/Color.js'; + +class GridHelper extends LineSegments { + constructor(size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888) { + color1 = new Color(color1); + color2 = new Color(color2); + + const center = divisions / 2; + const step = size / divisions; + const halfSize = size / 2; + + const vertices = [], + colors = []; + + for (let i = 0, j = 0, k = -halfSize; i <= divisions; i++, k += step) { + vertices.push(-halfSize, 0, k, halfSize, 0, k); + vertices.push(k, 0, -halfSize, k, 0, halfSize); + + const color = i === center ? color1 : color2; + + color.toArray(colors, j); + j += 3; + color.toArray(colors, j); + j += 3; + color.toArray(colors, j); + j += 3; + color.toArray(colors, j); + j += 3; + } + + const geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + geometry.setAttribute('color', new Float32BufferAttribute(colors, 3)); + + const material = new LineBasicMaterial({ vertexColors: true, toneMapped: false }); + + super(geometry, material); + + this.type = 'GridHelper'; + } +} + +export { GridHelper }; diff --git a/backend/libs/three/helpers/HemisphereLightHelper.d.ts b/backend/libs/three/helpers/HemisphereLightHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a3bf708f17b7355dba38601fc9612ab360019064 --- /dev/null +++ b/backend/libs/three/helpers/HemisphereLightHelper.d.ts @@ -0,0 +1,20 @@ +import { HemisphereLight } from './../lights/HemisphereLight'; +import { Color } from './../math/Color'; +import { Matrix4 } from './../math/Matrix4'; +import { MeshBasicMaterial } from './../materials/MeshBasicMaterial'; +import { Object3D } from './../core/Object3D'; +import { ColorRepresentation } from '../utils'; + +export class HemisphereLightHelper extends Object3D { + constructor(light: HemisphereLight, size: number, color?: ColorRepresentation); + + light: HemisphereLight; + matrix: Matrix4; + matrixAutoUpdate: boolean; + material: MeshBasicMaterial; + + color: ColorRepresentation | undefined; + + dispose(): void; + update(): void; +} diff --git a/backend/libs/three/helpers/HemisphereLightHelper.js b/backend/libs/three/helpers/HemisphereLightHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..360676eb0617fb15a7659b82d7195979fd03222b --- /dev/null +++ b/backend/libs/three/helpers/HemisphereLightHelper.js @@ -0,0 +1,69 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Color } from '../math/Color.js'; +import { Object3D } from '../core/Object3D.js'; +import { Mesh } from '../objects/Mesh.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { OctahedronGeometry } from '../geometries/OctahedronGeometry.js'; +import { BufferAttribute } from '../core/BufferAttribute.js'; + +const _vector = /*@__PURE__*/ new Vector3(); +const _color1 = /*@__PURE__*/ new Color(); +const _color2 = /*@__PURE__*/ new Color(); + +class HemisphereLightHelper extends Object3D { + constructor(light, size, color) { + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + const geometry = new OctahedronGeometry(size); + geometry.rotateY(Math.PI * 0.5); + + this.material = new MeshBasicMaterial({ wireframe: true, fog: false, toneMapped: false }); + if (this.color === undefined) this.material.vertexColors = true; + + const position = geometry.getAttribute('position'); + const colors = new Float32Array(position.count * 3); + + geometry.setAttribute('color', new BufferAttribute(colors, 3)); + + this.add(new Mesh(geometry, this.material)); + + this.update(); + } + + dispose() { + this.children[0].geometry.dispose(); + this.children[0].material.dispose(); + } + + update() { + const mesh = this.children[0]; + + if (this.color !== undefined) { + this.material.color.set(this.color); + } else { + const colors = mesh.geometry.getAttribute('color'); + + _color1.copy(this.light.color); + _color2.copy(this.light.groundColor); + + for (let i = 0, l = colors.count; i < l; i++) { + const color = i < l / 2 ? _color1 : _color2; + + colors.setXYZ(i, color.r, color.g, color.b); + } + + colors.needsUpdate = true; + } + + mesh.lookAt(_vector.setFromMatrixPosition(this.light.matrixWorld).negate()); + } +} + +export { HemisphereLightHelper }; diff --git a/backend/libs/three/helpers/PlaneHelper.d.ts b/backend/libs/three/helpers/PlaneHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a4e8e8bbd19c717026d72b8f18235a72845db813 --- /dev/null +++ b/backend/libs/three/helpers/PlaneHelper.d.ts @@ -0,0 +1,25 @@ +import { Plane } from './../math/Plane'; +import { LineSegments } from './../objects/LineSegments'; + +export class PlaneHelper extends LineSegments { + /** + * @param plane + * @param [size=1] + * @param [hex=0xffff00] + */ + constructor(plane: Plane, size?: number, hex?: number); + + /** + * @default 'PlaneHelper' + */ + type: string; + + plane: Plane; + + /** + * @default 1 + */ + size: number; + + updateMatrixWorld(force?: boolean): void; +} diff --git a/backend/libs/three/helpers/PlaneHelper.js b/backend/libs/three/helpers/PlaneHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..1b0fe93d818d510724df178bd8968bcae5e623df --- /dev/null +++ b/backend/libs/three/helpers/PlaneHelper.js @@ -0,0 +1,51 @@ +import { Line } from '../objects/Line.js'; +import { Mesh } from '../objects/Mesh.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { FrontSide, BackSide } from '../constants.js'; + +class PlaneHelper extends Line { + constructor(plane, size = 1, hex = 0xffff00) { + const color = hex; + + const positions = [1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0]; + + const geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute(positions, 3)); + geometry.computeBoundingSphere(); + + super(geometry, new LineBasicMaterial({ color: color, toneMapped: false })); + + this.type = 'PlaneHelper'; + + this.plane = plane; + + this.size = size; + + const positions2 = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1]; + + const geometry2 = new BufferGeometry(); + geometry2.setAttribute('position', new Float32BufferAttribute(positions2, 3)); + geometry2.computeBoundingSphere(); + + this.add(new Mesh(geometry2, new MeshBasicMaterial({ color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false }))); + } + + updateMatrixWorld(force) { + let scale = -this.plane.constant; + + if (Math.abs(scale) < 1e-8) scale = 1e-8; // sign does not matter + + this.scale.set(0.5 * this.size, 0.5 * this.size, scale); + + this.children[0].material.side = scale < 0 ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here + + this.lookAt(this.plane.normal); + + super.updateMatrixWorld(force); + } +} + +export { PlaneHelper }; diff --git a/backend/libs/three/helpers/PointLightHelper.d.ts b/backend/libs/three/helpers/PointLightHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0d9e4aa9d27b689bb87ec84a34034293172e1547 --- /dev/null +++ b/backend/libs/three/helpers/PointLightHelper.d.ts @@ -0,0 +1,25 @@ +import { PointLight } from './../lights/PointLight'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; +import { ColorRepresentation } from '../utils'; + +export class PointLightHelper extends Object3D { + constructor(light: PointLight, sphereSize?: number, color?: ColorRepresentation); + + /** + * @default 'PointLightHelper' + */ + type: string; + + light: PointLight; + color: ColorRepresentation | undefined; + matrix: Matrix4; + + /** + * @default false + */ + matrixAutoUpdate: boolean; + + dispose(): void; + update(): void; +} diff --git a/backend/libs/three/helpers/PointLightHelper.js b/backend/libs/three/helpers/PointLightHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..85b3aeb570ef2173bd570528e5be85017fd97bdd --- /dev/null +++ b/backend/libs/three/helpers/PointLightHelper.js @@ -0,0 +1,77 @@ +import { Mesh } from '../objects/Mesh.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { SphereGeometry } from '../geometries/SphereGeometry.js'; + +class PointLightHelper extends Mesh { + constructor(light, sphereSize, color) { + const geometry = new SphereGeometry(sphereSize, 4, 2); + const material = new MeshBasicMaterial({ wireframe: true, fog: false, toneMapped: false }); + + super(geometry, material); + + this.light = light; + this.light.updateMatrixWorld(); + + this.color = color; + + this.type = 'PointLightHelper'; + + this.matrix = this.light.matrixWorld; + this.matrixAutoUpdate = false; + + this.update(); + + /* + // TODO: delete this comment? + const distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 ); + const distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } ); + + this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial ); + this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial ); + + const d = light.distance; + + if ( d === 0.0 ) { + + this.lightDistance.visible = false; + + } else { + + this.lightDistance.scale.set( d, d, d ); + + } + + this.add( this.lightDistance ); + */ + } + + dispose() { + this.geometry.dispose(); + this.material.dispose(); + } + + update() { + if (this.color !== undefined) { + this.material.color.set(this.color); + } else { + this.material.color.copy(this.light.color); + } + + /* + const d = this.light.distance; + + if ( d === 0.0 ) { + + this.lightDistance.visible = false; + + } else { + + this.lightDistance.visible = true; + this.lightDistance.scale.set( d, d, d ); + + } + */ + } +} + +export { PointLightHelper }; diff --git a/backend/libs/three/helpers/PolarGridHelper.d.ts b/backend/libs/three/helpers/PolarGridHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c3e4f328fd35733fd4035de483ff01b306b7eefe --- /dev/null +++ b/backend/libs/three/helpers/PolarGridHelper.d.ts @@ -0,0 +1,19 @@ +import { LineSegments } from '../objects/LineSegments'; +import { ColorRepresentation } from '../utils'; + +export class PolarGridHelper extends LineSegments { + /** + * @param [radius=10] + * @param [radials=16] + * @param [circles=8] + * @param [divisions=64] + * @param [color1=0x444444] + * @param [color2=0x888888] + */ + constructor(radius?: number, radials?: number, circles?: number, divisions?: number, color1?: ColorRepresentation, color2?: ColorRepresentation); + + /** + * @default 'PolarGridHelper' + */ + type: string; +} diff --git a/backend/libs/three/helpers/PolarGridHelper.js b/backend/libs/three/helpers/PolarGridHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..1eb45cfa974003b5a6a7ecab595aaf20f2a6e20f --- /dev/null +++ b/backend/libs/three/helpers/PolarGridHelper.js @@ -0,0 +1,74 @@ +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Color } from '../math/Color.js'; + +class PolarGridHelper extends LineSegments { + constructor(radius = 10, radials = 16, circles = 8, divisions = 64, color1 = 0x444444, color2 = 0x888888) { + color1 = new Color(color1); + color2 = new Color(color2); + + const vertices = []; + const colors = []; + + // create the radials + + for (let i = 0; i <= radials; i++) { + const v = (i / radials) * (Math.PI * 2); + + const x = Math.sin(v) * radius; + const z = Math.cos(v) * radius; + + vertices.push(0, 0, 0); + vertices.push(x, 0, z); + + const color = i & 1 ? color1 : color2; + + colors.push(color.r, color.g, color.b); + colors.push(color.r, color.g, color.b); + } + + // create the circles + + for (let i = 0; i <= circles; i++) { + const color = i & 1 ? color1 : color2; + + const r = radius - (radius / circles) * i; + + for (let j = 0; j < divisions; j++) { + // first vertex + + let v = (j / divisions) * (Math.PI * 2); + + let x = Math.sin(v) * r; + let z = Math.cos(v) * r; + + vertices.push(x, 0, z); + colors.push(color.r, color.g, color.b); + + // second vertex + + v = ((j + 1) / divisions) * (Math.PI * 2); + + x = Math.sin(v) * r; + z = Math.cos(v) * r; + + vertices.push(x, 0, z); + colors.push(color.r, color.g, color.b); + } + } + + const geometry = new BufferGeometry(); + geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + geometry.setAttribute('color', new Float32BufferAttribute(colors, 3)); + + const material = new LineBasicMaterial({ vertexColors: true, toneMapped: false }); + + super(geometry, material); + + this.type = 'PolarGridHelper'; + } +} + +export { PolarGridHelper }; diff --git a/backend/libs/three/helpers/SkeletonHelper.d.ts b/backend/libs/three/helpers/SkeletonHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ae76e6418fcc208fcff5a7846cdd28f589262c5e --- /dev/null +++ b/backend/libs/three/helpers/SkeletonHelper.d.ts @@ -0,0 +1,28 @@ +import { Object3D } from './../core/Object3D'; +import { Matrix4 } from './../math/Matrix4'; +import { Bone } from './../objects/Bone'; +import { LineSegments } from './../objects/LineSegments'; + +export class SkeletonHelper extends LineSegments { + constructor(object: Object3D); + + /** + * @default 'SkeletonHelper' + */ + type: string; + + bones: Bone[]; + root: Object3D; + + readonly isSkeletonHelper: true; + + matrix: Matrix4; + + /** + * @default false + */ + matrixAutoUpdate: boolean; + + getBoneList(object: Object3D): Bone[]; + update(): void; +} diff --git a/backend/libs/three/helpers/SkeletonHelper.js b/backend/libs/three/helpers/SkeletonHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..ed35141efd4a17c64b5f1778f8b92afafb4850fe --- /dev/null +++ b/backend/libs/three/helpers/SkeletonHelper.js @@ -0,0 +1,97 @@ +import { LineSegments } from '../objects/LineSegments.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Color } from '../math/Color.js'; +import { Vector3 } from '../math/Vector3.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; + +const _vector = /*@__PURE__*/ new Vector3(); +const _boneMatrix = /*@__PURE__*/ new Matrix4(); +const _matrixWorldInv = /*@__PURE__*/ new Matrix4(); + +class SkeletonHelper extends LineSegments { + constructor(object) { + const bones = getBoneList(object); + + const geometry = new BufferGeometry(); + + const vertices = []; + const colors = []; + + const color1 = new Color(0, 0, 1); + const color2 = new Color(0, 1, 0); + + for (let i = 0; i < bones.length; i++) { + const bone = bones[i]; + + if (bone.parent && bone.parent.isBone) { + vertices.push(0, 0, 0); + vertices.push(0, 0, 0); + colors.push(color1.r, color1.g, color1.b); + colors.push(color2.r, color2.g, color2.b); + } + } + + geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3)); + geometry.setAttribute('color', new Float32BufferAttribute(colors, 3)); + + const material = new LineBasicMaterial({ vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true }); + + super(geometry, material); + + this.type = 'SkeletonHelper'; + this.isSkeletonHelper = true; + + this.root = object; + this.bones = bones; + + this.matrix = object.matrixWorld; + this.matrixAutoUpdate = false; + } + + updateMatrixWorld(force) { + const bones = this.bones; + + const geometry = this.geometry; + const position = geometry.getAttribute('position'); + + _matrixWorldInv.copy(this.root.matrixWorld).invert(); + + for (let i = 0, j = 0; i < bones.length; i++) { + const bone = bones[i]; + + if (bone.parent && bone.parent.isBone) { + _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.matrixWorld); + _vector.setFromMatrixPosition(_boneMatrix); + position.setXYZ(j, _vector.x, _vector.y, _vector.z); + + _boneMatrix.multiplyMatrices(_matrixWorldInv, bone.parent.matrixWorld); + _vector.setFromMatrixPosition(_boneMatrix); + position.setXYZ(j + 1, _vector.x, _vector.y, _vector.z); + + j += 2; + } + } + + geometry.getAttribute('position').needsUpdate = true; + + super.updateMatrixWorld(force); + } +} + +function getBoneList(object) { + const boneList = []; + + if (object && object.isBone) { + boneList.push(object); + } + + for (let i = 0; i < object.children.length; i++) { + boneList.push.apply(boneList, getBoneList(object.children[i])); + } + + return boneList; +} + +export { SkeletonHelper }; diff --git a/backend/libs/three/helpers/SpotLightHelper.d.ts b/backend/libs/three/helpers/SpotLightHelper.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9e304b242682c6902383e664100a6317ae6c91eb --- /dev/null +++ b/backend/libs/three/helpers/SpotLightHelper.d.ts @@ -0,0 +1,22 @@ +import { Light } from './../lights/Light'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; +import { LineSegments } from '../objects/LineSegments'; +import { ColorRepresentation } from '../utils'; + +export class SpotLightHelper extends Object3D { + constructor(light: Light, color?: ColorRepresentation); + + light: Light; + matrix: Matrix4; + + /** + * @default false + */ + matrixAutoUpdate: boolean; + color: ColorRepresentation | undefined; + cone: LineSegments; + + dispose(): void; + update(): void; +} diff --git a/backend/libs/three/helpers/SpotLightHelper.js b/backend/libs/three/helpers/SpotLightHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..91dd8a7a45273dff716f72f89dd847aa35f3652a --- /dev/null +++ b/backend/libs/three/helpers/SpotLightHelper.js @@ -0,0 +1,67 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Object3D } from '../core/Object3D.js'; +import { LineSegments } from '../objects/LineSegments.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; + +const _vector = /*@__PURE__*/ new Vector3(); + +class SpotLightHelper extends Object3D { + constructor(light, color) { + super(); + this.light = light; + this.light.updateMatrixWorld(); + + this.matrix = light.matrixWorld; + this.matrixAutoUpdate = false; + + this.color = color; + + const geometry = new BufferGeometry(); + + const positions = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, 1]; + + for (let i = 0, j = 1, l = 32; i < l; i++, j++) { + const p1 = (i / l) * Math.PI * 2; + const p2 = (j / l) * Math.PI * 2; + + positions.push(Math.cos(p1), Math.sin(p1), 1, Math.cos(p2), Math.sin(p2), 1); + } + + geometry.setAttribute('position', new Float32BufferAttribute(positions, 3)); + + const material = new LineBasicMaterial({ fog: false, toneMapped: false }); + + this.cone = new LineSegments(geometry, material); + this.add(this.cone); + + this.update(); + } + + dispose() { + this.cone.geometry.dispose(); + this.cone.material.dispose(); + } + + update() { + this.light.updateMatrixWorld(); + + const coneLength = this.light.distance ? this.light.distance : 1000; + const coneWidth = coneLength * Math.tan(this.light.angle); + + this.cone.scale.set(coneWidth, coneWidth, coneLength); + + _vector.setFromMatrixPosition(this.light.target.matrixWorld); + + this.cone.lookAt(_vector); + + if (this.color !== undefined) { + this.cone.material.color.set(this.color); + } else { + this.cone.material.color.copy(this.light.color); + } + } +} + +export { SpotLightHelper }; diff --git a/backend/libs/three/lights/AmbientLight.d.ts b/backend/libs/three/lights/AmbientLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c098ce2a7d44627032e36133d4c648ecedf58256 --- /dev/null +++ b/backend/libs/three/lights/AmbientLight.d.ts @@ -0,0 +1,23 @@ +import { ColorRepresentation } from '../utils'; +import { Light } from './Light'; + +/** + * This light's color gets applied to all the objects in the scene globally. + * + * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js + */ +export class AmbientLight extends Light { + /** + * This creates a Ambientlight with a color. + * @param color Numeric value of the RGB component of the color or a Color instance. + * @param [intensity=1] + */ + constructor(color?: ColorRepresentation, intensity?: number); + + /** + * @default 'AmbientLight' + */ + type: string; + + readonly isAmbientLight: true; +} diff --git a/backend/libs/three/lights/AmbientLight.js b/backend/libs/three/lights/AmbientLight.js new file mode 100644 index 0000000000000000000000000000000000000000..e8038a8ef764faf3c1725d0aa68b234b51f3c6e4 --- /dev/null +++ b/backend/libs/three/lights/AmbientLight.js @@ -0,0 +1,13 @@ +import { Light } from './Light.js'; + +class AmbientLight extends Light { + constructor(color, intensity) { + super(color, intensity); + + this.type = 'AmbientLight'; + } +} + +AmbientLight.prototype.isAmbientLight = true; + +export { AmbientLight }; diff --git a/backend/libs/three/lights/AmbientLightProbe.d.ts b/backend/libs/three/lights/AmbientLightProbe.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..01fd80373bc961965dd23be8ee65c84dfb9e7b66 --- /dev/null +++ b/backend/libs/three/lights/AmbientLightProbe.d.ts @@ -0,0 +1,8 @@ +import { ColorRepresentation } from '../utils'; +import { LightProbe } from './LightProbe'; + +export class AmbientLightProbe extends LightProbe { + constructor(color?: ColorRepresentation, intensity?: number); + + readonly isAmbientLightProbe: true; +} diff --git a/backend/libs/three/lights/AmbientLightProbe.js b/backend/libs/three/lights/AmbientLightProbe.js new file mode 100644 index 0000000000000000000000000000000000000000..cdf18c62943e631cc33a3f5f684087183def664e --- /dev/null +++ b/backend/libs/three/lights/AmbientLightProbe.js @@ -0,0 +1,17 @@ +import { Color } from '../math/Color.js'; +import { LightProbe } from './LightProbe.js'; + +class AmbientLightProbe extends LightProbe { + constructor(color, intensity = 1) { + super(undefined, intensity); + + const color1 = new Color().set(color); + + // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI ); + this.sh.coefficients[0].set(color1.r, color1.g, color1.b).multiplyScalar(2 * Math.sqrt(Math.PI)); + } +} + +AmbientLightProbe.prototype.isAmbientLightProbe = true; + +export { AmbientLightProbe }; diff --git a/backend/libs/three/lights/DirectionalLight.d.ts b/backend/libs/three/lights/DirectionalLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..83be5e537984726d65383b99a1a61872560d8b85 --- /dev/null +++ b/backend/libs/three/lights/DirectionalLight.d.ts @@ -0,0 +1,46 @@ +import { Object3D } from './../core/Object3D'; +import { DirectionalLightShadow } from './DirectionalLightShadow'; +import { Light } from './Light'; +import { Vector3 } from '../math/Vector3'; +import { ColorRepresentation } from '../utils'; + +/** + * see {@link https://github.com/mrdoob/three.js/blob/master/src/lights/DirectionalLight.js|src/lights/DirectionalLight.js} + * + * @example + * // White directional light at half intensity shining from the top. + * const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + * directionalLight.position.set( 0, 1, 0 ); + * scene.add( directionalLight ); + */ +export class DirectionalLight extends Light { + constructor(color?: ColorRepresentation, intensity?: number); + + /** + * @default 'DirectionalLight' + */ + type: string; + + /** + * @default THREE.Object3D.DefaultUp + */ + readonly position: Vector3; + + /** + * Target used for shadow camera orientation. + * @default new THREE.Object3D() + */ + target: Object3D; + + /** + * Light's intensity. + * @default 1 + */ + intensity: number; + + /** + * @default new THREE.DirectionalLightShadow() + */ + shadow: DirectionalLightShadow; + readonly isDirectionalLight: true; +} diff --git a/backend/libs/three/lights/DirectionalLight.js b/backend/libs/three/lights/DirectionalLight.js new file mode 100644 index 0000000000000000000000000000000000000000..e2c54e009338999f718a38f44c5a32741a5b9fba --- /dev/null +++ b/backend/libs/three/lights/DirectionalLight.js @@ -0,0 +1,35 @@ +import { Light } from './Light.js'; +import { DirectionalLightShadow } from './DirectionalLightShadow.js'; +import { Object3D } from '../core/Object3D.js'; + +class DirectionalLight extends Light { + constructor(color, intensity) { + super(color, intensity); + + this.type = 'DirectionalLight'; + + this.position.copy(Object3D.DefaultUp); + this.updateMatrix(); + + this.target = new Object3D(); + + this.shadow = new DirectionalLightShadow(); + } + + dispose() { + this.shadow.dispose(); + } + + copy(source) { + super.copy(source); + + this.target = source.target.clone(); + this.shadow = source.shadow.clone(); + + return this; + } +} + +DirectionalLight.prototype.isDirectionalLight = true; + +export { DirectionalLight }; diff --git a/backend/libs/three/lights/DirectionalLightShadow.d.ts b/backend/libs/three/lights/DirectionalLightShadow.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cefaf44250b3a7a577806ca2731a5d8b138611d5 --- /dev/null +++ b/backend/libs/three/lights/DirectionalLightShadow.d.ts @@ -0,0 +1,7 @@ +import { OrthographicCamera } from './../cameras/OrthographicCamera'; +import { LightShadow } from './LightShadow'; + +export class DirectionalLightShadow extends LightShadow { + camera: OrthographicCamera; + readonly isDirectionalLightShadow: true; +} diff --git a/backend/libs/three/lights/DirectionalLightShadow.js b/backend/libs/three/lights/DirectionalLightShadow.js new file mode 100644 index 0000000000000000000000000000000000000000..6ead517a8396e431d0c3c48a8b8120b5590a9cf0 --- /dev/null +++ b/backend/libs/three/lights/DirectionalLightShadow.js @@ -0,0 +1,12 @@ +import { LightShadow } from './LightShadow.js'; +import { OrthographicCamera } from '../cameras/OrthographicCamera.js'; + +class DirectionalLightShadow extends LightShadow { + constructor() { + super(new OrthographicCamera(-5, 5, 5, -5, 0.5, 500)); + } +} + +DirectionalLightShadow.prototype.isDirectionalLightShadow = true; + +export { DirectionalLightShadow }; diff --git a/backend/libs/three/lights/HemisphereLight.d.ts b/backend/libs/three/lights/HemisphereLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0f7750e862277427548222bdd2f08fbe87fac4ce --- /dev/null +++ b/backend/libs/three/lights/HemisphereLight.d.ts @@ -0,0 +1,27 @@ +import { Color } from './../math/Color'; +import { Vector3 } from '../math/Vector3'; +import { Light } from './Light'; +import { ColorRepresentation } from '../utils'; + +export class HemisphereLight extends Light { + /** + * @param skyColor + * @param groundColor + * @param [intensity=1] + */ + constructor(skyColor?: ColorRepresentation, groundColor?: ColorRepresentation, intensity?: number); + + /** + * @default 'HemisphereLight' + */ + type: string; + + /** + * @default THREE.Object3D.DefaultUp + */ + position: Vector3; + + groundColor: Color; + + readonly isHemisphereLight: true; +} diff --git a/backend/libs/three/lights/HemisphereLight.js b/backend/libs/three/lights/HemisphereLight.js new file mode 100644 index 0000000000000000000000000000000000000000..97382d52685de0205354d7d2a01a15e0cc6594e6 --- /dev/null +++ b/backend/libs/three/lights/HemisphereLight.js @@ -0,0 +1,28 @@ +import { Light } from './Light.js'; +import { Color } from '../math/Color.js'; +import { Object3D } from '../core/Object3D.js'; + +class HemisphereLight extends Light { + constructor(skyColor, groundColor, intensity) { + super(skyColor, intensity); + + this.type = 'HemisphereLight'; + + this.position.copy(Object3D.DefaultUp); + this.updateMatrix(); + + this.groundColor = new Color(groundColor); + } + + copy(source) { + Light.prototype.copy.call(this, source); + + this.groundColor.copy(source.groundColor); + + return this; + } +} + +HemisphereLight.prototype.isHemisphereLight = true; + +export { HemisphereLight }; diff --git a/backend/libs/three/lights/HemisphereLightProbe.d.ts b/backend/libs/three/lights/HemisphereLightProbe.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cfdb54adf8b851d5b31b1b4dd782130a68f176b8 --- /dev/null +++ b/backend/libs/three/lights/HemisphereLightProbe.d.ts @@ -0,0 +1,8 @@ +import { ColorRepresentation } from '../utils'; +import { LightProbe } from './LightProbe'; + +export class HemisphereLightProbe extends LightProbe { + constructor(skyColor?: ColorRepresentation, groundColor?: ColorRepresentation, intensity?: number); + + readonly isHemisphereLightProbe: true; +} diff --git a/backend/libs/three/lights/HemisphereLightProbe.js b/backend/libs/three/lights/HemisphereLightProbe.js new file mode 100644 index 0000000000000000000000000000000000000000..66fa2764abe7480bee647beac75114e3aa6cc81c --- /dev/null +++ b/backend/libs/three/lights/HemisphereLightProbe.js @@ -0,0 +1,26 @@ +import { Color } from '../math/Color.js'; +import { Vector3 } from '../math/Vector3.js'; +import { LightProbe } from './LightProbe.js'; + +class HemisphereLightProbe extends LightProbe { + constructor(skyColor, groundColor, intensity = 1) { + super(undefined, intensity); + + const color1 = new Color().set(skyColor); + const color2 = new Color().set(groundColor); + + const sky = new Vector3(color1.r, color1.g, color1.b); + const ground = new Vector3(color2.r, color2.g, color2.b); + + // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI ); + const c0 = Math.sqrt(Math.PI); + const c1 = c0 * Math.sqrt(0.75); + + this.sh.coefficients[0].copy(sky).add(ground).multiplyScalar(c0); + this.sh.coefficients[1].copy(sky).sub(ground).multiplyScalar(c1); + } +} + +HemisphereLightProbe.prototype.isHemisphereLightProbe = true; + +export { HemisphereLightProbe }; diff --git a/backend/libs/three/lights/Light.d.ts b/backend/libs/three/lights/Light.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..42f749981ab38a92f71722fa00eeb2d1fae13f83 --- /dev/null +++ b/backend/libs/three/lights/Light.d.ts @@ -0,0 +1,69 @@ +import { Color } from './../math/Color'; +import { LightShadow } from './LightShadow'; +import { Object3D } from './../core/Object3D'; + +// Lights ////////////////////////////////////////////////////////////////////////////////// + +/** + * Abstract base class for lights. + */ +export class Light extends Object3D { + constructor(hex?: number | string, intensity?: number); + + /** + * @default 'Light' + */ + type: string; + + color: Color; + + /** + * @default 1 + */ + intensity: number; + readonly isLight: true; + + shadow: LightShadow; + /** + * @deprecated Use shadow.camera.fov instead. + */ + shadowCameraFov: any; + /** + * @deprecated Use shadow.camera.left instead. + */ + shadowCameraLeft: any; + /** + * @deprecated Use shadow.camera.right instead. + */ + shadowCameraRight: any; + /** + * @deprecated Use shadow.camera.top instead. + */ + shadowCameraTop: any; + /** + * @deprecated Use shadow.camera.bottom instead. + */ + shadowCameraBottom: any; + /** + * @deprecated Use shadow.camera.near instead. + */ + shadowCameraNear: any; + /** + * @deprecated Use shadow.camera.far instead. + */ + shadowCameraFar: any; + /** + * @deprecated Use shadow.bias instead. + */ + shadowBias: any; + /** + * @deprecated Use shadow.mapSize.width instead. + */ + shadowMapWidth: any; + /** + * @deprecated Use shadow.mapSize.height instead. + */ + shadowMapHeight: any; + + dispose(): void; +} diff --git a/backend/libs/three/lights/Light.js b/backend/libs/three/lights/Light.js new file mode 100644 index 0000000000000000000000000000000000000000..4b708c631ffbdd53bfa347c4a93ed839582fbff2 --- /dev/null +++ b/backend/libs/three/lights/Light.js @@ -0,0 +1,48 @@ +import { Object3D } from '../core/Object3D.js'; +import { Color } from '../math/Color.js'; + +class Light extends Object3D { + constructor(color, intensity = 1) { + super(); + + this.type = 'Light'; + + this.color = new Color(color); + this.intensity = intensity; + } + + dispose() { + // Empty here in base class; some subclasses override. + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + this.intensity = source.intensity; + + return this; + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.object.color = this.color.getHex(); + data.object.intensity = this.intensity; + + if (this.groundColor !== undefined) data.object.groundColor = this.groundColor.getHex(); + + if (this.distance !== undefined) data.object.distance = this.distance; + if (this.angle !== undefined) data.object.angle = this.angle; + if (this.decay !== undefined) data.object.decay = this.decay; + if (this.penumbra !== undefined) data.object.penumbra = this.penumbra; + + if (this.shadow !== undefined) data.object.shadow = this.shadow.toJSON(); + + return data; + } +} + +Light.prototype.isLight = true; + +export { Light }; diff --git a/backend/libs/three/lights/LightProbe.d.ts b/backend/libs/three/lights/LightProbe.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f9c17300c1c93057eae5a84b6e540da218ac8e8c --- /dev/null +++ b/backend/libs/three/lights/LightProbe.d.ts @@ -0,0 +1,20 @@ +import { SphericalHarmonics3 } from './../math/SphericalHarmonics3'; +import { Light } from './Light'; + +export class LightProbe extends Light { + constructor(sh?: SphericalHarmonics3, intensity?: number); + + /** + * @default 'LightProbe' + */ + type: string; + + readonly isLightProbe: true; + + /** + * @default new THREE.SphericalHarmonics3() + */ + sh: SphericalHarmonics3; + + fromJSON(json: object): LightProbe; +} diff --git a/backend/libs/three/lights/LightProbe.js b/backend/libs/three/lights/LightProbe.js new file mode 100644 index 0000000000000000000000000000000000000000..724e7dee3502d9373d050be394011c65a07dcfe9 --- /dev/null +++ b/backend/libs/three/lights/LightProbe.js @@ -0,0 +1,37 @@ +import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js'; +import { Light } from './Light.js'; + +class LightProbe extends Light { + constructor(sh = new SphericalHarmonics3(), intensity = 1) { + super(undefined, intensity); + + this.sh = sh; + } + + copy(source) { + super.copy(source); + + this.sh.copy(source.sh); + + return this; + } + + fromJSON(json) { + this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); + this.sh.fromArray(json.sh); + + return this; + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.object.sh = this.sh.toArray(); + + return data; + } +} + +LightProbe.prototype.isLightProbe = true; + +export { LightProbe }; diff --git a/backend/libs/three/lights/LightShadow.d.ts b/backend/libs/three/lights/LightShadow.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..30af0f4a8b3e06299b6a01a6b8cd8260b9ad5800 --- /dev/null +++ b/backend/libs/three/lights/LightShadow.d.ts @@ -0,0 +1,71 @@ +import { Camera } from './../cameras/Camera'; +import { Light } from './../lights/Light'; +import { Vector2 } from './../math/Vector2'; +import { Vector4 } from './../math/Vector4'; +import { Matrix4 } from './../math/Matrix4'; +import { WebGLRenderTarget } from '../renderers/WebGLRenderTarget'; + +export class LightShadow { + constructor(camera: Camera); + + camera: Camera; + + /** + * @default 0 + */ + bias: number; + + /** + * @default 0 + */ + normalBias: number; + + /** + * @default 1 + */ + radius: number; + + /** + * @default 8 + */ + blurSamples: number; + + /** + * @default new THREE.Vector2( 512, 512 ) + */ + mapSize: Vector2; + + /** + * @default null + */ + map: WebGLRenderTarget; + + /** + * @default null + */ + mapPass: WebGLRenderTarget; + + /** + * @default new THREE.Matrix4() + */ + matrix: Matrix4; + + /** + * @default true + */ + autoUpdate: boolean; + + /** + * @default false + */ + needsUpdate: boolean; + + copy(source: LightShadow): this; + clone(recursive?: boolean): this; + toJSON(): any; + getFrustum(): number; + updateMatrices(light: Light, viewportIndex?: number): void; + getViewport(viewportIndex: number): Vector4; + getFrameExtents(): Vector2; + dispose(): void; +} diff --git a/backend/libs/three/lights/LightShadow.js b/backend/libs/three/lights/LightShadow.js new file mode 100644 index 0000000000000000000000000000000000000000..a8099a7d38a5f6352e3cb00d1e9a31f98858d7a6 --- /dev/null +++ b/backend/libs/three/lights/LightShadow.js @@ -0,0 +1,113 @@ +import { Matrix4 } from '../math/Matrix4.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector4 } from '../math/Vector4.js'; +import { Frustum } from '../math/Frustum.js'; + +const _projScreenMatrix = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld = /*@__PURE__*/ new Vector3(); +const _lookTarget = /*@__PURE__*/ new Vector3(); + +class LightShadow { + constructor(camera) { + this.camera = camera; + + this.bias = 0; + this.normalBias = 0; + this.radius = 1; + this.blurSamples = 8; + + this.mapSize = new Vector2(512, 512); + + this.map = null; + this.mapPass = null; + this.matrix = new Matrix4(); + + this.autoUpdate = true; + this.needsUpdate = false; + + this._frustum = new Frustum(); + this._frameExtents = new Vector2(1, 1); + + this._viewportCount = 1; + + this._viewports = [new Vector4(0, 0, 1, 1)]; + } + + getViewportCount() { + return this._viewportCount; + } + + getFrustum() { + return this._frustum; + } + + updateMatrices(light) { + const shadowCamera = this.camera; + const shadowMatrix = this.matrix; + + _lightPositionWorld.setFromMatrixPosition(light.matrixWorld); + shadowCamera.position.copy(_lightPositionWorld); + + _lookTarget.setFromMatrixPosition(light.target.matrixWorld); + shadowCamera.lookAt(_lookTarget); + shadowCamera.updateMatrixWorld(); + + _projScreenMatrix.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse); + this._frustum.setFromProjectionMatrix(_projScreenMatrix); + + shadowMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0); + + shadowMatrix.multiply(shadowCamera.projectionMatrix); + shadowMatrix.multiply(shadowCamera.matrixWorldInverse); + } + + getViewport(viewportIndex) { + return this._viewports[viewportIndex]; + } + + getFrameExtents() { + return this._frameExtents; + } + + dispose() { + if (this.map) { + this.map.dispose(); + } + + if (this.mapPass) { + this.mapPass.dispose(); + } + } + + copy(source) { + this.camera = source.camera.clone(); + + this.bias = source.bias; + this.radius = source.radius; + + this.mapSize.copy(source.mapSize); + + return this; + } + + clone() { + return new this.constructor().copy(this); + } + + toJSON() { + const object = {}; + + if (this.bias !== 0) object.bias = this.bias; + if (this.normalBias !== 0) object.normalBias = this.normalBias; + if (this.radius !== 1) object.radius = this.radius; + if (this.mapSize.x !== 512 || this.mapSize.y !== 512) object.mapSize = this.mapSize.toArray(); + + object.camera = this.camera.toJSON(false).object; + delete object.camera.matrix; + + return object; + } +} + +export { LightShadow }; diff --git a/backend/libs/three/lights/PointLight.d.ts b/backend/libs/three/lights/PointLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9e6f01325e473a9717ab67f27cc44208e3d89746 --- /dev/null +++ b/backend/libs/three/lights/PointLight.d.ts @@ -0,0 +1,42 @@ +import { ColorRepresentation } from '../utils'; +import { Light } from './Light'; +import { PointLightShadow } from './PointLightShadow'; + +/** + * @example + * const light = new THREE.PointLight( 0xff0000, 1, 100 ); + * light.position.set( 50, 50, 50 ); + * scene.add( light ); + */ +export class PointLight extends Light { + constructor(color?: ColorRepresentation, intensity?: number, distance?: number, decay?: number); + + /** + * @default 'PointLight' + */ + type: string; + + /** + * Light's intensity. + * @default 1 + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * @default 0 + */ + distance: number; + + /** + * @default 1 + */ + decay: number; + + /** + * @default new THREE.PointLightShadow() + */ + shadow: PointLightShadow; + + power: number; +} diff --git a/backend/libs/three/lights/PointLight.js b/backend/libs/three/lights/PointLight.js new file mode 100644 index 0000000000000000000000000000000000000000..5df7a96dee0331b10e7e5db7126242514a2b6e72 --- /dev/null +++ b/backend/libs/three/lights/PointLight.js @@ -0,0 +1,45 @@ +import { Light } from './Light.js'; +import { PointLightShadow } from './PointLightShadow.js'; + +class PointLight extends Light { + constructor(color, intensity, distance = 0, decay = 1) { + super(color, intensity); + + this.type = 'PointLight'; + + this.distance = distance; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new PointLightShadow(); + } + + get power() { + // compute the light's luminous power (in lumens) from its intensity (in candela) + // for an isotropic light source, luminous power (lm) = 4 π luminous intensity (cd) + return this.intensity * 4 * Math.PI; + } + + set power(power) { + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / (4 * Math.PI); + } + + dispose() { + this.shadow.dispose(); + } + + copy(source) { + super.copy(source); + + this.distance = source.distance; + this.decay = source.decay; + + this.shadow = source.shadow.clone(); + + return this; + } +} + +PointLight.prototype.isPointLight = true; + +export { PointLight }; diff --git a/backend/libs/three/lights/PointLightShadow.d.ts b/backend/libs/three/lights/PointLightShadow.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ba5716ccb55fbee5a25c3a0f313382c94ffe171f --- /dev/null +++ b/backend/libs/three/lights/PointLightShadow.d.ts @@ -0,0 +1,6 @@ +import { PerspectiveCamera } from './../cameras/PerspectiveCamera'; +import { LightShadow } from './LightShadow'; + +export class PointLightShadow extends LightShadow { + camera: PerspectiveCamera; +} diff --git a/backend/libs/three/lights/PointLightShadow.js b/backend/libs/three/lights/PointLightShadow.js new file mode 100644 index 0000000000000000000000000000000000000000..1e5be21ef61f90c6d678b3f06d530a8adaa6e4fa --- /dev/null +++ b/backend/libs/three/lights/PointLightShadow.js @@ -0,0 +1,89 @@ +import { LightShadow } from './LightShadow.js'; +import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector4 } from '../math/Vector4.js'; + +const _projScreenMatrix = /*@__PURE__*/ new Matrix4(); +const _lightPositionWorld = /*@__PURE__*/ new Vector3(); +const _lookTarget = /*@__PURE__*/ new Vector3(); + +class PointLightShadow extends LightShadow { + constructor() { + super(new PerspectiveCamera(90, 1, 0.5, 500)); + + this._frameExtents = new Vector2(4, 2); + + this._viewportCount = 6; + + this._viewports = [ + // These viewports map a cube-map onto a 2D texture with the + // following orientation: + // + // xzXZ + // y Y + // + // X - Positive x direction + // x - Negative x direction + // Y - Positive y direction + // y - Negative y direction + // Z - Positive z direction + // z - Negative z direction + + // positive X + new Vector4(2, 1, 1, 1), + // negative X + new Vector4(0, 1, 1, 1), + // positive Z + new Vector4(3, 1, 1, 1), + // negative Z + new Vector4(1, 1, 1, 1), + // positive Y + new Vector4(3, 0, 1, 1), + // negative Y + new Vector4(1, 0, 1, 1), + ]; + + this._cubeDirections = [ + new Vector3(1, 0, 0), + new Vector3(-1, 0, 0), + new Vector3(0, 0, 1), + new Vector3(0, 0, -1), + new Vector3(0, 1, 0), + new Vector3(0, -1, 0), + ]; + + this._cubeUps = [new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1)]; + } + + updateMatrices(light, viewportIndex = 0) { + const camera = this.camera; + const shadowMatrix = this.matrix; + + const far = light.distance || camera.far; + + if (far !== camera.far) { + camera.far = far; + camera.updateProjectionMatrix(); + } + + _lightPositionWorld.setFromMatrixPosition(light.matrixWorld); + camera.position.copy(_lightPositionWorld); + + _lookTarget.copy(camera.position); + _lookTarget.add(this._cubeDirections[viewportIndex]); + camera.up.copy(this._cubeUps[viewportIndex]); + camera.lookAt(_lookTarget); + camera.updateMatrixWorld(); + + shadowMatrix.makeTranslation(-_lightPositionWorld.x, -_lightPositionWorld.y, -_lightPositionWorld.z); + + _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse); + this._frustum.setFromProjectionMatrix(_projScreenMatrix); + } +} + +PointLightShadow.prototype.isPointLightShadow = true; + +export { PointLightShadow }; diff --git a/backend/libs/three/lights/RectAreaLight.d.ts b/backend/libs/three/lights/RectAreaLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..58841fbe2d209ad859ce5f68fc6bc16828e07f3b --- /dev/null +++ b/backend/libs/three/lights/RectAreaLight.d.ts @@ -0,0 +1,30 @@ +import { Light } from './Light'; +import { ColorRepresentation } from '../utils'; + +export class RectAreaLight extends Light { + constructor(color?: ColorRepresentation, intensity?: number, width?: number, height?: number); + + /** + * @default 'RectAreaLight' + */ + type: string; + + /** + * @default 10 + */ + width: number; + + /** + * @default 10 + */ + height: number; + + /** + * @default 1 + */ + intensity: number; + + power: number; + + readonly isRectAreaLight: true; +} diff --git a/backend/libs/three/lights/RectAreaLight.js b/backend/libs/three/lights/RectAreaLight.js new file mode 100644 index 0000000000000000000000000000000000000000..7906dfccc74d162c12a4f66eefeb22ea92f91943 --- /dev/null +++ b/backend/libs/three/lights/RectAreaLight.js @@ -0,0 +1,44 @@ +import { Light } from './Light.js'; + +class RectAreaLight extends Light { + constructor(color, intensity, width = 10, height = 10) { + super(color, intensity); + + this.type = 'RectAreaLight'; + + this.width = width; + this.height = height; + } + + get power() { + // compute the light's luminous power (in lumens) from its intensity (in nits) + return this.intensity * this.width * this.height * Math.PI; + } + + set power(power) { + // set the light's intensity (in nits) from the desired luminous power (in lumens) + this.intensity = power / (this.width * this.height * Math.PI); + } + + copy(source) { + super.copy(source); + + this.width = source.width; + this.height = source.height; + + return this; + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.object.width = this.width; + data.object.height = this.height; + + return data; + } +} + +RectAreaLight.prototype.isRectAreaLight = true; + +export { RectAreaLight }; diff --git a/backend/libs/three/lights/SpotLight.d.ts b/backend/libs/three/lights/SpotLight.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a5d81106d9495f67b9504165dbacf66102dc3f44 --- /dev/null +++ b/backend/libs/three/lights/SpotLight.d.ts @@ -0,0 +1,65 @@ +import { Color } from './../math/Color'; +import { Vector3 } from '../math/Vector3'; +import { Object3D } from './../core/Object3D'; +import { SpotLightShadow } from './SpotLightShadow'; +import { Light } from './Light'; +import { ColorRepresentation } from '../utils'; + +/** + * A point light that can cast shadow in one direction. + */ +export class SpotLight extends Light { + constructor(color?: ColorRepresentation, intensity?: number, distance?: number, angle?: number, penumbra?: number, decay?: number); + + /** + * @default 'SpotLight' + */ + type: string; + + /** + * @default THREE.Object3D.DefaultUp + */ + position: Vector3; + + /** + * Spotlight focus points at target.position. + * @default new THREE.Object3D() + */ + target: Object3D; + + /** + * Light's intensity. + * @default 1 + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * @default 0 + */ + distance: number; + + /** + * Maximum extent of the spotlight, in radians, from its direction. + * @default Math.PI / 3. + */ + angle: number; + + /** + * @default 1 + */ + decay: number; + + /** + * @default new THREE.SpotLightShadow() + */ + shadow: SpotLightShadow; + power: number; + + /** + * @default 0 + */ + penumbra: number; + + readonly isSpotLight: true; +} diff --git a/backend/libs/three/lights/SpotLight.js b/backend/libs/three/lights/SpotLight.js new file mode 100644 index 0000000000000000000000000000000000000000..ec18ddf05981b189480c822c718beffd82511d34 --- /dev/null +++ b/backend/libs/three/lights/SpotLight.js @@ -0,0 +1,57 @@ +import { Light } from './Light.js'; +import { SpotLightShadow } from './SpotLightShadow.js'; +import { Object3D } from '../core/Object3D.js'; + +class SpotLight extends Light { + constructor(color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1) { + super(color, intensity); + + this.type = 'SpotLight'; + + this.position.copy(Object3D.DefaultUp); + this.updateMatrix(); + + this.target = new Object3D(); + + this.distance = distance; + this.angle = angle; + this.penumbra = penumbra; + this.decay = decay; // for physically correct lights, should be 2. + + this.shadow = new SpotLightShadow(); + } + + get power() { + // compute the light's luminous power (in lumens) from its intensity (in candela) + // by convention for a spotlight, luminous power (lm) = π * luminous intensity (cd) + return this.intensity * Math.PI; + } + + set power(power) { + // set the light's intensity (in candela) from the desired luminous power (in lumens) + this.intensity = power / Math.PI; + } + + dispose() { + this.shadow.dispose(); + } + + copy(source) { + super.copy(source); + + this.distance = source.distance; + this.angle = source.angle; + this.penumbra = source.penumbra; + this.decay = source.decay; + + this.target = source.target.clone(); + + this.shadow = source.shadow.clone(); + + return this; + } +} + +SpotLight.prototype.isSpotLight = true; + +export { SpotLight }; diff --git a/backend/libs/three/lights/SpotLightShadow.d.ts b/backend/libs/three/lights/SpotLightShadow.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..795fa4b44f525d89862a5fa8ae26a9bcebd17400 --- /dev/null +++ b/backend/libs/three/lights/SpotLightShadow.d.ts @@ -0,0 +1,12 @@ +import { PerspectiveCamera } from './../cameras/PerspectiveCamera'; +import { LightShadow } from './LightShadow'; + +export class SpotLightShadow extends LightShadow { + camera: PerspectiveCamera; + readonly isSpotLightShadow: true; + + /** + * @default 1 + */ + focus: number; +} diff --git a/backend/libs/three/lights/SpotLightShadow.js b/backend/libs/three/lights/SpotLightShadow.js new file mode 100644 index 0000000000000000000000000000000000000000..69b9e4fe428d79bef863a0fc1d3403f118d75054 --- /dev/null +++ b/backend/libs/three/lights/SpotLightShadow.js @@ -0,0 +1,40 @@ +import { LightShadow } from './LightShadow.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; + +class SpotLightShadow extends LightShadow { + constructor() { + super(new PerspectiveCamera(50, 1, 0.5, 500)); + + this.focus = 1; + } + + updateMatrices(light) { + const camera = this.camera; + + const fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus; + const aspect = this.mapSize.width / this.mapSize.height; + const far = light.distance || camera.far; + + if (fov !== camera.fov || aspect !== camera.aspect || far !== camera.far) { + camera.fov = fov; + camera.aspect = aspect; + camera.far = far; + camera.updateProjectionMatrix(); + } + + super.updateMatrices(light); + } + + copy(source) { + super.copy(source); + + this.focus = source.focus; + + return this; + } +} + +SpotLightShadow.prototype.isSpotLightShadow = true; + +export { SpotLightShadow }; diff --git a/backend/libs/three/loaders/AnimationLoader.d.ts b/backend/libs/three/loaders/AnimationLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5b1fd26313c6b675e65534eade8beb1557ecd2f1 --- /dev/null +++ b/backend/libs/three/loaders/AnimationLoader.d.ts @@ -0,0 +1,11 @@ +import { LoadingManager } from './LoadingManager'; +import { Loader } from './Loader'; +import { AnimationClip } from './../animation/AnimationClip'; + +export class AnimationLoader extends Loader { + constructor(manager?: LoadingManager); + + load(url: string, onLoad: (response: AnimationClip[]) => void, onProgress?: (request: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; + parse(json: any): AnimationClip[]; +} diff --git a/backend/libs/three/loaders/AnimationLoader.js b/backend/libs/three/loaders/AnimationLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..5e5ab7f75e58ec3b6d1ec9567971a72f842e8628 --- /dev/null +++ b/backend/libs/three/loaders/AnimationLoader.js @@ -0,0 +1,50 @@ +import { AnimationClip } from '../animation/AnimationClip.js'; +import { FileLoader } from './FileLoader.js'; +import { Loader } from './Loader.js'; + +class AnimationLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const loader = new FileLoader(this.manager); + loader.setPath(this.path); + loader.setRequestHeader(this.requestHeader); + loader.setWithCredentials(this.withCredentials); + loader.load( + url, + function (text) { + try { + onLoad(scope.parse(JSON.parse(text))); + } catch (e) { + if (onError) { + onError(e); + } else { + console.error(e); + } + + scope.manager.itemError(url); + } + }, + onProgress, + onError + ); + } + + parse(json) { + const animations = []; + + for (let i = 0; i < json.length; i++) { + const clip = AnimationClip.parse(json[i]); + + animations.push(clip); + } + + return animations; + } +} + +export { AnimationLoader }; diff --git a/backend/libs/three/loaders/AudioLoader.d.ts b/backend/libs/three/loaders/AudioLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..413a0f3c8cf9de493520f7e7f25f93fa497e075b --- /dev/null +++ b/backend/libs/three/loaders/AudioLoader.d.ts @@ -0,0 +1,10 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; + +export class AudioLoader extends Loader { + constructor(manager?: LoadingManager); + + load(url: string, onLoad: (audioBuffer: AudioBuffer) => void, onProgress?: (request: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/AudioLoader.js b/backend/libs/three/loaders/AudioLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..d3cbcaa220defc1e7373af6e66a734800db663d6 --- /dev/null +++ b/backend/libs/three/loaders/AudioLoader.js @@ -0,0 +1,46 @@ +import { AudioContext } from '../audio/AudioContext.js'; +import { FileLoader } from './FileLoader.js'; +import { Loader } from './Loader.js'; + +class AudioLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const loader = new FileLoader(this.manager); + loader.setResponseType('arraybuffer'); + loader.setPath(this.path); + loader.setRequestHeader(this.requestHeader); + loader.setWithCredentials(this.withCredentials); + loader.load( + url, + function (buffer) { + try { + // Create a copy of the buffer. The `decodeAudioData` method + // detaches the buffer when complete, preventing reuse. + const bufferCopy = buffer.slice(0); + + const context = AudioContext.getContext(); + context.decodeAudioData(bufferCopy, function (audioBuffer) { + onLoad(audioBuffer); + }); + } catch (e) { + if (onError) { + onError(e); + } else { + console.error(e); + } + + scope.manager.itemError(url); + } + }, + onProgress, + onError + ); + } +} + +export { AudioLoader }; diff --git a/backend/libs/three/loaders/BufferGeometryLoader.d.ts b/backend/libs/three/loaders/BufferGeometryLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c849ad7e685950de568735679f3bf97e06b4bc79 --- /dev/null +++ b/backend/libs/three/loaders/BufferGeometryLoader.d.ts @@ -0,0 +1,17 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { BufferGeometry } from './../core/BufferGeometry'; +import { InstancedBufferGeometry } from '../core/InstancedBufferGeometry'; + +export class BufferGeometryLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + url: string, + onLoad: (bufferGeometry: InstancedBufferGeometry | BufferGeometry) => void, + onProgress?: (request: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): void; + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; + parse(json: any): InstancedBufferGeometry | BufferGeometry; +} diff --git a/backend/libs/three/loaders/BufferGeometryLoader.js b/backend/libs/three/loaders/BufferGeometryLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..735526ad615a3313234c423f928354e33e7acaff --- /dev/null +++ b/backend/libs/three/loaders/BufferGeometryLoader.js @@ -0,0 +1,177 @@ +import { Sphere } from '../math/Sphere.js'; +import { Vector3 } from '../math/Vector3.js'; +import { BufferAttribute } from '../core/BufferAttribute.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { FileLoader } from './FileLoader.js'; +import { Loader } from './Loader.js'; +import { InstancedBufferGeometry } from '../core/InstancedBufferGeometry.js'; +import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js'; +import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js'; +import { InterleavedBuffer } from '../core/InterleavedBuffer.js'; +import { getTypedArray } from '../utils.js'; + +class BufferGeometryLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const loader = new FileLoader(scope.manager); + loader.setPath(scope.path); + loader.setRequestHeader(scope.requestHeader); + loader.setWithCredentials(scope.withCredentials); + loader.load( + url, + function (text) { + try { + onLoad(scope.parse(JSON.parse(text))); + } catch (e) { + if (onError) { + onError(e); + } else { + console.error(e); + } + + scope.manager.itemError(url); + } + }, + onProgress, + onError + ); + } + + parse(json) { + const interleavedBufferMap = {}; + const arrayBufferMap = {}; + + function getInterleavedBuffer(json, uuid) { + if (interleavedBufferMap[uuid] !== undefined) return interleavedBufferMap[uuid]; + + const interleavedBuffers = json.interleavedBuffers; + const interleavedBuffer = interleavedBuffers[uuid]; + + const buffer = getArrayBuffer(json, interleavedBuffer.buffer); + + const array = getTypedArray(interleavedBuffer.type, buffer); + const ib = new InterleavedBuffer(array, interleavedBuffer.stride); + ib.uuid = interleavedBuffer.uuid; + + interleavedBufferMap[uuid] = ib; + + return ib; + } + + function getArrayBuffer(json, uuid) { + if (arrayBufferMap[uuid] !== undefined) return arrayBufferMap[uuid]; + + const arrayBuffers = json.arrayBuffers; + const arrayBuffer = arrayBuffers[uuid]; + + const ab = new Uint32Array(arrayBuffer).buffer; + + arrayBufferMap[uuid] = ab; + + return ab; + } + + const geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry(); + + const index = json.data.index; + + if (index !== undefined) { + const typedArray = getTypedArray(index.type, index.array); + geometry.setIndex(new BufferAttribute(typedArray, 1)); + } + + const attributes = json.data.attributes; + + for (const key in attributes) { + const attribute = attributes[key]; + let bufferAttribute; + + if (attribute.isInterleavedBufferAttribute) { + const interleavedBuffer = getInterleavedBuffer(json.data, attribute.data); + bufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized); + } else { + const typedArray = getTypedArray(attribute.type, attribute.array); + const bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute; + bufferAttribute = new bufferAttributeConstr(typedArray, attribute.itemSize, attribute.normalized); + } + + if (attribute.name !== undefined) bufferAttribute.name = attribute.name; + if (attribute.usage !== undefined) bufferAttribute.setUsage(attribute.usage); + + if (attribute.updateRange !== undefined) { + bufferAttribute.updateRange.offset = attribute.updateRange.offset; + bufferAttribute.updateRange.count = attribute.updateRange.count; + } + + geometry.setAttribute(key, bufferAttribute); + } + + const morphAttributes = json.data.morphAttributes; + + if (morphAttributes) { + for (const key in morphAttributes) { + const attributeArray = morphAttributes[key]; + + const array = []; + + for (let i = 0, il = attributeArray.length; i < il; i++) { + const attribute = attributeArray[i]; + let bufferAttribute; + + if (attribute.isInterleavedBufferAttribute) { + const interleavedBuffer = getInterleavedBuffer(json.data, attribute.data); + bufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized); + } else { + const typedArray = getTypedArray(attribute.type, attribute.array); + bufferAttribute = new BufferAttribute(typedArray, attribute.itemSize, attribute.normalized); + } + + if (attribute.name !== undefined) bufferAttribute.name = attribute.name; + array.push(bufferAttribute); + } + + geometry.morphAttributes[key] = array; + } + } + + const morphTargetsRelative = json.data.morphTargetsRelative; + + if (morphTargetsRelative) { + geometry.morphTargetsRelative = true; + } + + const groups = json.data.groups || json.data.drawcalls || json.data.offsets; + + if (groups !== undefined) { + for (let i = 0, n = groups.length; i !== n; ++i) { + const group = groups[i]; + + geometry.addGroup(group.start, group.count, group.materialIndex); + } + } + + const boundingSphere = json.data.boundingSphere; + + if (boundingSphere !== undefined) { + const center = new Vector3(); + + if (boundingSphere.center !== undefined) { + center.fromArray(boundingSphere.center); + } + + geometry.boundingSphere = new Sphere(center, boundingSphere.radius); + } + + if (json.name) geometry.name = json.name; + if (json.userData) geometry.userData = json.userData; + + return geometry; + } +} + +export { BufferGeometryLoader }; diff --git a/backend/libs/three/loaders/Cache.d.ts b/backend/libs/three/loaders/Cache.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5c6434d5fd19efe2aea85c99df7ef2e2a4f4af16 --- /dev/null +++ b/backend/libs/three/loaders/Cache.d.ts @@ -0,0 +1,16 @@ +export namespace Cache { + /** + * @default false + */ + let enabled: boolean; + + /** + * @default {} + */ + let files: any; + + function add(key: string, file: any): void; + function get(key: string): any; + function remove(key: string): void; + function clear(): void; +} diff --git a/backend/libs/three/loaders/Cache.js b/backend/libs/three/loaders/Cache.js new file mode 100644 index 0000000000000000000000000000000000000000..df1a416883ab8a3794c52f32628e2c68546f98b8 --- /dev/null +++ b/backend/libs/three/loaders/Cache.js @@ -0,0 +1,31 @@ +const Cache = { + enabled: false, + + files: {}, + + add: function (key, file) { + if (this.enabled === false) return; + + // console.log( 'THREE.Cache', 'Adding key:', key ); + + this.files[key] = file; + }, + + get: function (key) { + if (this.enabled === false) return; + + // console.log( 'THREE.Cache', 'Checking key:', key ); + + return this.files[key]; + }, + + remove: function (key) { + delete this.files[key]; + }, + + clear: function () { + this.files = {}; + }, +}; + +export { Cache }; diff --git a/backend/libs/three/loaders/CompressedTextureLoader.d.ts b/backend/libs/three/loaders/CompressedTextureLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b9a0c6994546d49a2469980c89d765e6546a6534 --- /dev/null +++ b/backend/libs/three/loaders/CompressedTextureLoader.d.ts @@ -0,0 +1,16 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { CompressedTexture } from './../textures/CompressedTexture'; + +export class CompressedTextureLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + url: string, + onLoad: (texture: CompressedTexture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): CompressedTexture; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/CompressedTextureLoader.js b/backend/libs/three/loaders/CompressedTextureLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..155e2fbd3d0c84680fa6b15aebae9a9260e5bd74 --- /dev/null +++ b/backend/libs/three/loaders/CompressedTextureLoader.js @@ -0,0 +1,113 @@ +import { LinearFilter } from '../constants.js'; +import { FileLoader } from './FileLoader.js'; +import { CompressedTexture } from '../textures/CompressedTexture.js'; +import { Loader } from './Loader.js'; + +/** + * Abstract Base class to block based textures loader (dds, pvr, ...) + * + * Sub classes have to implement the parse() method which will be used in load(). + */ + +class CompressedTextureLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const images = []; + + const texture = new CompressedTexture(); + + const loader = new FileLoader(this.manager); + loader.setPath(this.path); + loader.setResponseType('arraybuffer'); + loader.setRequestHeader(this.requestHeader); + loader.setWithCredentials(scope.withCredentials); + + let loaded = 0; + + function loadTexture(i) { + loader.load( + url[i], + function (buffer) { + const texDatas = scope.parse(buffer, true); + + images[i] = { + width: texDatas.width, + height: texDatas.height, + format: texDatas.format, + mipmaps: texDatas.mipmaps, + }; + + loaded += 1; + + if (loaded === 6) { + if (texDatas.mipmapCount === 1) texture.minFilter = LinearFilter; + + texture.image = images; + texture.format = texDatas.format; + texture.needsUpdate = true; + + if (onLoad) onLoad(texture); + } + }, + onProgress, + onError + ); + } + + if (Array.isArray(url)) { + for (let i = 0, il = url.length; i < il; ++i) { + loadTexture(i); + } + } else { + // compressed cubemap texture stored in a single DDS file + + loader.load( + url, + function (buffer) { + const texDatas = scope.parse(buffer, true); + + if (texDatas.isCubemap) { + const faces = texDatas.mipmaps.length / texDatas.mipmapCount; + + for (let f = 0; f < faces; f++) { + images[f] = { mipmaps: [] }; + + for (let i = 0; i < texDatas.mipmapCount; i++) { + images[f].mipmaps.push(texDatas.mipmaps[f * texDatas.mipmapCount + i]); + images[f].format = texDatas.format; + images[f].width = texDatas.width; + images[f].height = texDatas.height; + } + } + + texture.image = images; + } else { + texture.image.width = texDatas.width; + texture.image.height = texDatas.height; + texture.mipmaps = texDatas.mipmaps; + } + + if (texDatas.mipmapCount === 1) { + texture.minFilter = LinearFilter; + } + + texture.format = texDatas.format; + texture.needsUpdate = true; + + if (onLoad) onLoad(texture); + }, + onProgress, + onError + ); + } + + return texture; + } +} + +export { CompressedTextureLoader }; diff --git a/backend/libs/three/loaders/CubeTextureLoader.d.ts b/backend/libs/three/loaders/CubeTextureLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cc0b519c4855b09ebd8cd753c263b808c5998219 --- /dev/null +++ b/backend/libs/three/loaders/CubeTextureLoader.d.ts @@ -0,0 +1,16 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { CubeTexture } from './../textures/CubeTexture'; + +export class CubeTextureLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + urls: string[], + onLoad?: (texture: CubeTexture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): CubeTexture; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/CubeTextureLoader.js b/backend/libs/three/loaders/CubeTextureLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..ec6d97bc466e21f827059c66cd50e3b41b9748f2 --- /dev/null +++ b/backend/libs/three/loaders/CubeTextureLoader.js @@ -0,0 +1,46 @@ +import { ImageLoader } from './ImageLoader.js'; +import { CubeTexture } from '../textures/CubeTexture.js'; +import { Loader } from './Loader.js'; + +class CubeTextureLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(urls, onLoad, onProgress, onError) { + const texture = new CubeTexture(); + + const loader = new ImageLoader(this.manager); + loader.setCrossOrigin(this.crossOrigin); + loader.setPath(this.path); + + let loaded = 0; + + function loadTexture(i) { + loader.load( + urls[i], + function (image) { + texture.images[i] = image; + + loaded++; + + if (loaded === 6) { + texture.needsUpdate = true; + + if (onLoad) onLoad(texture); + } + }, + undefined, + onError + ); + } + + for (let i = 0; i < urls.length; ++i) { + loadTexture(i); + } + + return texture; + } +} + +export { CubeTextureLoader }; diff --git a/backend/libs/three/loaders/DataTextureLoader.d.ts b/backend/libs/three/loaders/DataTextureLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6c0f56180304b8e2007ccd50659eb04e54a3a03f --- /dev/null +++ b/backend/libs/three/loaders/DataTextureLoader.d.ts @@ -0,0 +1,16 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { DataTexture } from './../textures/DataTexture'; + +export class DataTextureLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + url: string, + onLoad: (dataTexture: DataTexture, texData: object) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): DataTexture; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/DataTextureLoader.js b/backend/libs/three/loaders/DataTextureLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..748cc3acd2d73a8e1fc2289bd3a86c65d5078588 --- /dev/null +++ b/backend/libs/three/loaders/DataTextureLoader.js @@ -0,0 +1,91 @@ +import { LinearFilter, LinearMipmapLinearFilter, ClampToEdgeWrapping } from '../constants.js'; +import { FileLoader } from './FileLoader.js'; +import { DataTexture } from '../textures/DataTexture.js'; +import { Loader } from './Loader.js'; + +/** + * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...) + * + * Sub classes have to implement the parse() method which will be used in load(). + */ + +class DataTextureLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const texture = new DataTexture(); + + const loader = new FileLoader(this.manager); + loader.setResponseType('arraybuffer'); + loader.setRequestHeader(this.requestHeader); + loader.setPath(this.path); + loader.setWithCredentials(scope.withCredentials); + loader.load( + url, + function (buffer) { + const texData = scope.parse(buffer); + + if (!texData) return; + + if (texData.image !== undefined) { + texture.image = texData.image; + } else if (texData.data !== undefined) { + texture.image.width = texData.width; + texture.image.height = texData.height; + texture.image.data = texData.data; + } + + texture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping; + texture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping; + + texture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter; + texture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter; + + texture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1; + + if (texData.encoding !== undefined) { + texture.encoding = texData.encoding; + } + + if (texData.flipY !== undefined) { + texture.flipY = texData.flipY; + } + + if (texData.format !== undefined) { + texture.format = texData.format; + } + + if (texData.type !== undefined) { + texture.type = texData.type; + } + + if (texData.mipmaps !== undefined) { + texture.mipmaps = texData.mipmaps; + texture.minFilter = LinearMipmapLinearFilter; // presumably... + } + + if (texData.mipmapCount === 1) { + texture.minFilter = LinearFilter; + } + + if (texData.generateMipmaps !== undefined) { + texture.generateMipmaps = texData.generateMipmaps; + } + + texture.needsUpdate = true; + + if (onLoad) onLoad(texture, texData); + }, + onProgress, + onError + ); + + return texture; + } +} + +export { DataTextureLoader }; diff --git a/backend/libs/three/loaders/FileLoader.d.ts b/backend/libs/three/loaders/FileLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..68fda41a62b520ec81e03c9aa89444ab39cdebe6 --- /dev/null +++ b/backend/libs/three/loaders/FileLoader.d.ts @@ -0,0 +1,19 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; + +export class FileLoader extends Loader { + constructor(manager?: LoadingManager); + + mimeType: undefined | MimeType; + responseType: undefined | string; + + load( + url: string, + onLoad?: (response: string | ArrayBuffer) => void, + onProgress?: (request: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): any; + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; + setMimeType(mimeType: MimeType): FileLoader; + setResponseType(responseType: string): FileLoader; +} diff --git a/backend/libs/three/loaders/FileLoader.js b/backend/libs/three/loaders/FileLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..3e90f3c01359f68f6bdadf6c6db5e739b0744f97 --- /dev/null +++ b/backend/libs/three/loaders/FileLoader.js @@ -0,0 +1,185 @@ +import { Cache } from './Cache.js'; +import { Loader } from './Loader.js'; + +const loading = {}; + +class FileLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + if (url === undefined) url = ''; + + if (this.path !== undefined) url = this.path + url; + + url = this.manager.resolveURL(url); + + const cached = Cache.get(url); + + if (cached !== undefined) { + this.manager.itemStart(url); + + setTimeout(() => { + if (onLoad) onLoad(cached); + + this.manager.itemEnd(url); + }, 0); + + return cached; + } + + // Check if request is duplicate + + if (loading[url] !== undefined) { + loading[url].push({ + onLoad: onLoad, + onProgress: onProgress, + onError: onError, + }); + + return; + } + + // Initialise array for duplicate requests + loading[url] = []; + + loading[url].push({ + onLoad: onLoad, + onProgress: onProgress, + onError: onError, + }); + + // create request + const req = new Request(url, { + headers: new Headers(this.requestHeader), + credentials: this.withCredentials ? 'include' : 'same-origin', + // An abort controller could be added within a future PR + }); + + // start the fetch + fetch(req) + .then((response) => { + if (response.status === 200 || response.status === 0) { + // Some browsers return HTTP Status 0 when using non-http protocol + // e.g. 'file://' or 'data://'. Handle as success. + + if (response.status === 0) { + console.warn('THREE.FileLoader: HTTP Status 0 received.'); + } + + if (typeof ReadableStream === 'undefined' || response.body.getReader === undefined) { + return response; + } + + const callbacks = loading[url]; + const reader = response.body.getReader(); + const contentLength = response.headers.get('Content-Length'); + const total = contentLength ? parseInt(contentLength) : 0; + const lengthComputable = total !== 0; + let loaded = 0; + + // periodically read data into the new stream tracking while download progress + const stream = new ReadableStream({ + start(controller) { + readData(); + + function readData() { + reader.read().then(({ done, value }) => { + if (done) { + controller.close(); + } else { + loaded += value.byteLength; + + const event = new ProgressEvent('progress', { lengthComputable, loaded, total }); + for (let i = 0, il = callbacks.length; i < il; i++) { + const callback = callbacks[i]; + if (callback.onProgress) callback.onProgress(event); + } + + controller.enqueue(value); + readData(); + } + }); + } + }, + }); + + return new Response(stream); + } else { + throw Error(`fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`); + } + }) + .then((response) => { + switch (this.responseType) { + case 'arraybuffer': + return response.arrayBuffer(); + + case 'blob': + return response.blob(); + + case 'document': + return response.text().then((text) => { + const parser = new DOMParser(); + return parser.parseFromString(text, this.mimeType); + }); + + case 'json': + return response.json(); + + default: + return response.text(); + } + }) + .then((data) => { + // Add to cache only on HTTP success, so that we do not cache + // error response bodies as proper responses to requests. + Cache.add(url, data); + + const callbacks = loading[url]; + delete loading[url]; + + for (let i = 0, il = callbacks.length; i < il; i++) { + const callback = callbacks[i]; + if (callback.onLoad) callback.onLoad(data); + } + }) + .catch((err) => { + // Abort errors and other errors are handled the same + + const callbacks = loading[url]; + + if (callbacks === undefined) { + // When onLoad was called and url was deleted in `loading` + this.manager.itemError(url); + throw err; + } + + delete loading[url]; + + for (let i = 0, il = callbacks.length; i < il; i++) { + const callback = callbacks[i]; + if (callback.onError) callback.onError(err); + } + + this.manager.itemError(url); + }) + .finally(() => { + this.manager.itemEnd(url); + }); + + this.manager.itemStart(url); + } + + setResponseType(value) { + this.responseType = value; + return this; + } + + setMimeType(value) { + this.mimeType = value; + return this; + } +} + +export { FileLoader }; diff --git a/backend/libs/three/loaders/ImageBitmapLoader.d.ts b/backend/libs/three/loaders/ImageBitmapLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e607811c3c43e6e006153813544b61520829562f --- /dev/null +++ b/backend/libs/three/loaders/ImageBitmapLoader.d.ts @@ -0,0 +1,18 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; + +export class ImageBitmapLoader extends Loader { + constructor(manager?: LoadingManager); + + /** + * @default { premultiplyAlpha: 'none' } + */ + options: undefined | object; + + readonly isImageBitmapLoader: true; + + setOptions(options: object): ImageBitmapLoader; + load(url: string, onLoad?: (response: ImageBitmap) => void, onProgress?: (request: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): any; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/ImageBitmapLoader.js b/backend/libs/three/loaders/ImageBitmapLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..9712303c859dd2a0c875b6239cff4b6b243ab06a --- /dev/null +++ b/backend/libs/three/loaders/ImageBitmapLoader.js @@ -0,0 +1,79 @@ +import { Cache } from './Cache.js'; +import { Loader } from './Loader.js'; + +class ImageBitmapLoader extends Loader { + constructor(manager) { + super(manager); + + if (typeof createImageBitmap === 'undefined') { + console.warn('THREE.ImageBitmapLoader: createImageBitmap() not supported.'); + } + + if (typeof fetch === 'undefined') { + console.warn('THREE.ImageBitmapLoader: fetch() not supported.'); + } + + this.options = { premultiplyAlpha: 'none' }; + } + + setOptions(options) { + this.options = options; + + return this; + } + + load(url, onLoad, onProgress, onError) { + if (url === undefined) url = ''; + + if (this.path !== undefined) url = this.path + url; + + url = this.manager.resolveURL(url); + + const scope = this; + + const cached = Cache.get(url); + + if (cached !== undefined) { + scope.manager.itemStart(url); + + setTimeout(function () { + if (onLoad) onLoad(cached); + + scope.manager.itemEnd(url); + }, 0); + + return cached; + } + + const fetchOptions = {}; + fetchOptions.credentials = this.crossOrigin === 'anonymous' ? 'same-origin' : 'include'; + fetchOptions.headers = this.requestHeader; + + fetch(url, fetchOptions) + .then(function (res) { + return res.blob(); + }) + .then(function (blob) { + return createImageBitmap(blob, Object.assign(scope.options, { colorSpaceConversion: 'none' })); + }) + .then(function (imageBitmap) { + Cache.add(url, imageBitmap); + + if (onLoad) onLoad(imageBitmap); + + scope.manager.itemEnd(url); + }) + .catch(function (e) { + if (onError) onError(e); + + scope.manager.itemError(url); + scope.manager.itemEnd(url); + }); + + scope.manager.itemStart(url); + } +} + +ImageBitmapLoader.prototype.isImageBitmapLoader = true; + +export { ImageBitmapLoader }; diff --git a/backend/libs/three/loaders/ImageLoader.d.ts b/backend/libs/three/loaders/ImageLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..1daff2c107c4215f5ecfdab2457fa7d77114ae85 --- /dev/null +++ b/backend/libs/three/loaders/ImageLoader.d.ts @@ -0,0 +1,19 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; + +/** + * A loader for loading an image. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ +export class ImageLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + url: string, + onLoad?: (image: HTMLImageElement) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): HTMLImageElement; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/ImageLoader.js b/backend/libs/three/loaders/ImageLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..77093dff2b9a96b20e99dfc2de472f534155f071 --- /dev/null +++ b/backend/libs/three/loaders/ImageLoader.js @@ -0,0 +1,72 @@ +import { Cache } from './Cache.js'; +import { Loader } from './Loader.js'; +import { createElementNS } from '../utils.js'; + +class ImageLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + if (this.path !== undefined) url = this.path + url; + + url = this.manager.resolveURL(url); + + const scope = this; + + const cached = Cache.get(url); + + if (cached !== undefined) { + scope.manager.itemStart(url); + + setTimeout(function () { + if (onLoad) onLoad(cached); + + scope.manager.itemEnd(url); + }, 0); + + return cached; + } + + const image = createElementNS('img'); + + function onImageLoad() { + removeEventListeners(); + + Cache.add(url, this); + + if (onLoad) onLoad(this); + + scope.manager.itemEnd(url); + } + + function onImageError(event) { + removeEventListeners(); + + if (onError) onError(event); + + scope.manager.itemError(url); + scope.manager.itemEnd(url); + } + + function removeEventListeners() { + image.removeEventListener('load', onImageLoad, false); + image.removeEventListener('error', onImageError, false); + } + + image.addEventListener('load', onImageLoad, false); + image.addEventListener('error', onImageError, false); + + if (url.substr(0, 5) !== 'data:') { + if (this.crossOrigin !== undefined) image.crossOrigin = this.crossOrigin; + } + + scope.manager.itemStart(url); + + image.src = url; + + return image; + } +} + +export { ImageLoader }; diff --git a/backend/libs/three/loaders/Loader.d.ts b/backend/libs/three/loaders/Loader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5c6a84a6d69b10e8168c5ca7f23803f35b7ed222 --- /dev/null +++ b/backend/libs/three/loaders/Loader.d.ts @@ -0,0 +1,47 @@ +import { LoadingManager } from './LoadingManager'; + +/** + * Base class for implementing loaders. + */ +export class Loader { + constructor(manager?: LoadingManager); + + /** + * @default 'anonymous' + */ + crossOrigin: string; + + /** + * @default: false + */ + withCredentials: boolean; + + /** + * @default '' + */ + path: string; + + /** + * @default '' + */ + resourcePath: string; + manager: LoadingManager; + + /** + * @default {} + */ + requestHeader: { [header: string]: string }; + + /* + load(): void; + parse(): void; + */ + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; + + setCrossOrigin(crossOrigin: string): this; + setWithCredentials(value: boolean): this; + setPath(path: string): this; + setResourcePath(resourcePath: string): this; + setRequestHeader(requestHeader: { [header: string]: string }): this; +} diff --git a/backend/libs/three/loaders/Loader.js b/backend/libs/three/loaders/Loader.js new file mode 100644 index 0000000000000000000000000000000000000000..a3f46611a217bbe2ce64e1513b529495b9b6110d --- /dev/null +++ b/backend/libs/three/loaders/Loader.js @@ -0,0 +1,52 @@ +import { DefaultLoadingManager } from './LoadingManager.js'; + +class Loader { + constructor(manager) { + this.manager = manager !== undefined ? manager : DefaultLoadingManager; + + this.crossOrigin = 'anonymous'; + this.withCredentials = false; + this.path = ''; + this.resourcePath = ''; + this.requestHeader = {}; + } + + load(/* url, onLoad, onProgress, onError */) {} + + loadAsync(url, onProgress) { + const scope = this; + + return new Promise(function (resolve, reject) { + scope.load(url, resolve, onProgress, reject); + }); + } + + parse(/* data */) {} + + setCrossOrigin(crossOrigin) { + this.crossOrigin = crossOrigin; + return this; + } + + setWithCredentials(value) { + this.withCredentials = value; + return this; + } + + setPath(path) { + this.path = path; + return this; + } + + setResourcePath(resourcePath) { + this.resourcePath = resourcePath; + return this; + } + + setRequestHeader(requestHeader) { + this.requestHeader = requestHeader; + return this; + } +} + +export { Loader }; diff --git a/backend/libs/three/loaders/LoaderUtils.d.ts b/backend/libs/three/loaders/LoaderUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..dac730a6e4d624eda56239692f7b3faa5d343a64 --- /dev/null +++ b/backend/libs/three/loaders/LoaderUtils.d.ts @@ -0,0 +1,7 @@ +export interface LoaderUtils { + decodeText(array: BufferSource): string; + extractUrlBase(url: string): string; + resolveURL(url: string, path: string): string; +} + +export const LoaderUtils: LoaderUtils; diff --git a/backend/libs/three/loaders/LoaderUtils.js b/backend/libs/three/loaders/LoaderUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..7b44ac8cef541ad295cfc25fe4cf5af0ca199b48 --- /dev/null +++ b/backend/libs/three/loaders/LoaderUtils.js @@ -0,0 +1,59 @@ +class LoaderUtils { + static decodeText(array) { + if (typeof TextDecoder !== 'undefined') { + return new TextDecoder().decode(array); + } + + // Avoid the String.fromCharCode.apply(null, array) shortcut, which + // throws a "maximum call stack size exceeded" error for large arrays. + + let s = ''; + + for (let i = 0, il = array.length; i < il; i++) { + // Implicitly assumes little-endian. + s += String.fromCharCode(array[i]); + } + + try { + // merges multi-byte utf-8 characters. + + return decodeURIComponent(escape(s)); + } catch (e) { + // see #16358 + + return s; + } + } + + static extractUrlBase(url) { + const index = url.lastIndexOf('/'); + + if (index === -1) return './'; + + return url.substr(0, index + 1); + } + + static resolveURL(url, path) { + // Invalid URL + if (typeof url !== 'string' || url === '') return ''; + + // Host Relative URL + if (/^https?:\/\//i.test(path) && /^\//.test(url)) { + path = path.replace(/(^https?:\/\/[^\/]+).*/i, '$1'); + } + + // Absolute URL http://,https://,// + if (/^(https?:)?\/\//i.test(url)) return url; + + // Data URI + if (/^data:.*,.*$/i.test(url)) return url; + + // Blob URL + if (/^blob:.*$/i.test(url)) return url; + + // Relative URL + return path + url; + } +} + +export { LoaderUtils }; diff --git a/backend/libs/three/loaders/LoadingManager.d.ts b/backend/libs/three/loaders/LoadingManager.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a4e740a493e1ba5d4ce8d27e92a4cf6f8e313f86 --- /dev/null +++ b/backend/libs/three/loaders/LoadingManager.d.ts @@ -0,0 +1,65 @@ +import { Loader } from './Loader'; + +export const DefaultLoadingManager: LoadingManager; + +/** + * Handles and keeps track of loaded and pending data. + */ +export class LoadingManager { + constructor(onLoad?: () => void, onProgress?: (url: string, loaded: number, total: number) => void, onError?: (url: string) => void); + + /** + * Will be called when loading of an item starts. + * @param url The url of the item that started loading. + * @param loaded The number of items already loaded so far. + * @param total The total amount of items to be loaded. + */ + onStart?: ((url: string, loaded: number, total: number) => void) | undefined; + + /** + * Will be called when all items finish loading. + * The default is a function with empty body. + */ + onLoad: () => void; + + /** + * Will be called for each loaded item. + * The default is a function with empty body. + * @param url The url of the item just loaded. + * @param loaded The number of items already loaded so far. + * @param total The total amount of items to be loaded. + */ + onProgress: (url: string, loaded: number, total: number) => void; + + /** + * Will be called when item loading fails. + * The default is a function with empty body. + * @param url The url of the item that errored. + */ + onError: (url: string) => void; + + /** + * If provided, the callback will be passed each resource URL before a request is sent. + * The callback may return the original URL, or a new URL to override loading behavior. + * This behavior can be used to load assets from .ZIP files, drag-and-drop APIs, and Data URIs. + * @param callback URL modifier callback. Called with url argument, and must return resolvedURL. + */ + setURLModifier(callback?: (url: string) => string): this; + + /** + * Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. + * If no URL modifier is set, returns the original URL. + * @param url the url to load + */ + resolveURL(url: string): string; + + itemStart(url: string): void; + itemEnd(url: string): void; + itemError(url: string): void; + + // handlers + + addHandler(regex: RegExp, loader: Loader): this; + removeHandler(regex: RegExp): this; + getHandler(file: string): Loader | null; +} diff --git a/backend/libs/three/loaders/LoadingManager.js b/backend/libs/three/loaders/LoadingManager.js new file mode 100644 index 0000000000000000000000000000000000000000..f681d9d80617ad3131de04a43729d07c1f5b2b24 --- /dev/null +++ b/backend/libs/three/loaders/LoadingManager.js @@ -0,0 +1,102 @@ +class LoadingManager { + constructor(onLoad, onProgress, onError) { + const scope = this; + + let isLoading = false; + let itemsLoaded = 0; + let itemsTotal = 0; + let urlModifier = undefined; + const handlers = []; + + // Refer to #5689 for the reason why we don't set .onStart + // in the constructor + + this.onStart = undefined; + this.onLoad = onLoad; + this.onProgress = onProgress; + this.onError = onError; + + this.itemStart = function (url) { + itemsTotal++; + + if (isLoading === false) { + if (scope.onStart !== undefined) { + scope.onStart(url, itemsLoaded, itemsTotal); + } + } + + isLoading = true; + }; + + this.itemEnd = function (url) { + itemsLoaded++; + + if (scope.onProgress !== undefined) { + scope.onProgress(url, itemsLoaded, itemsTotal); + } + + if (itemsLoaded === itemsTotal) { + isLoading = false; + + if (scope.onLoad !== undefined) { + scope.onLoad(); + } + } + }; + + this.itemError = function (url) { + if (scope.onError !== undefined) { + scope.onError(url); + } + }; + + this.resolveURL = function (url) { + if (urlModifier) { + return urlModifier(url); + } + + return url; + }; + + this.setURLModifier = function (transform) { + urlModifier = transform; + + return this; + }; + + this.addHandler = function (regex, loader) { + handlers.push(regex, loader); + + return this; + }; + + this.removeHandler = function (regex) { + const index = handlers.indexOf(regex); + + if (index !== -1) { + handlers.splice(index, 2); + } + + return this; + }; + + this.getHandler = function (file) { + for (let i = 0, l = handlers.length; i < l; i += 2) { + const regex = handlers[i]; + const loader = handlers[i + 1]; + + if (regex.global) regex.lastIndex = 0; // see #17920 + + if (regex.test(file)) { + return loader; + } + } + + return null; + }; + } +} + +const DefaultLoadingManager = new LoadingManager(); + +export { DefaultLoadingManager, LoadingManager }; diff --git a/backend/libs/three/loaders/MaterialLoader.d.ts b/backend/libs/three/loaders/MaterialLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cc4a85f58e9bafdc80aeed79e327fa4645001f6f --- /dev/null +++ b/backend/libs/three/loaders/MaterialLoader.d.ts @@ -0,0 +1,18 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { Texture } from './../textures/Texture'; +import { Material } from './../materials/Material'; + +export class MaterialLoader extends Loader { + constructor(manager?: LoadingManager); + + /** + * @default {} + */ + textures: { [key: string]: Texture }; + + load(url: string, onLoad: (material: Material) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: Error | ErrorEvent) => void): void; + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; + setTextures(textures: { [key: string]: Texture }): this; + parse(json: any): Material; +} diff --git a/backend/libs/three/loaders/MaterialLoader.js b/backend/libs/three/loaders/MaterialLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..9bd853e75726697ad2a71140e5a225734b98bb67 --- /dev/null +++ b/backend/libs/three/loaders/MaterialLoader.js @@ -0,0 +1,268 @@ +import { Color } from '../math/Color.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector4 } from '../math/Vector4.js'; +import { Matrix3 } from '../math/Matrix3.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { FileLoader } from './FileLoader.js'; +import { Loader } from './Loader.js'; +import * as Materials from '../materials/Materials.js'; + +class MaterialLoader extends Loader { + constructor(manager) { + super(manager); + this.textures = {}; + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const loader = new FileLoader(scope.manager); + loader.setPath(scope.path); + loader.setRequestHeader(scope.requestHeader); + loader.setWithCredentials(scope.withCredentials); + loader.load( + url, + function (text) { + try { + onLoad(scope.parse(JSON.parse(text))); + } catch (e) { + if (onError) { + onError(e); + } else { + console.error(e); + } + + scope.manager.itemError(url); + } + }, + onProgress, + onError + ); + } + + parse(json) { + const textures = this.textures; + + function getTexture(name) { + if (textures[name] === undefined) { + console.warn('THREE.MaterialLoader: Undefined texture', name); + } + + return textures[name]; + } + + const material = new Materials[json.type](); + + if (json.uuid !== undefined) material.uuid = json.uuid; + if (json.name !== undefined) material.name = json.name; + if (json.color !== undefined && material.color !== undefined) material.color.setHex(json.color); + if (json.roughness !== undefined) material.roughness = json.roughness; + if (json.metalness !== undefined) material.metalness = json.metalness; + if (json.sheen !== undefined) material.sheen = json.sheen; + if (json.sheenColor !== undefined) material.sheenColor = new Color().setHex(json.sheenColor); + if (json.sheenRoughness !== undefined) material.sheenRoughness = json.sheenRoughness; + if (json.emissive !== undefined && material.emissive !== undefined) material.emissive.setHex(json.emissive); + if (json.specular !== undefined && material.specular !== undefined) material.specular.setHex(json.specular); + if (json.specularIntensity !== undefined) material.specularIntensity = json.specularIntensity; + if (json.specularColor !== undefined && material.specularColor !== undefined) material.specularColor.setHex(json.specularColor); + if (json.shininess !== undefined) material.shininess = json.shininess; + if (json.clearcoat !== undefined) material.clearcoat = json.clearcoat; + if (json.clearcoatRoughness !== undefined) material.clearcoatRoughness = json.clearcoatRoughness; + if (json.transmission !== undefined) material.transmission = json.transmission; + if (json.thickness !== undefined) material.thickness = json.thickness; + if (json.attenuationDistance !== undefined) material.attenuationDistance = json.attenuationDistance; + if (json.attenuationColor !== undefined && material.attenuationColor !== undefined) material.attenuationColor.setHex(json.attenuationColor); + if (json.fog !== undefined) material.fog = json.fog; + if (json.flatShading !== undefined) material.flatShading = json.flatShading; + if (json.blending !== undefined) material.blending = json.blending; + if (json.combine !== undefined) material.combine = json.combine; + if (json.side !== undefined) material.side = json.side; + if (json.shadowSide !== undefined) material.shadowSide = json.shadowSide; + if (json.opacity !== undefined) material.opacity = json.opacity; + if (json.transparent !== undefined) material.transparent = json.transparent; + if (json.alphaTest !== undefined) material.alphaTest = json.alphaTest; + if (json.depthTest !== undefined) material.depthTest = json.depthTest; + if (json.depthWrite !== undefined) material.depthWrite = json.depthWrite; + if (json.colorWrite !== undefined) material.colorWrite = json.colorWrite; + if (json.alphaWrite !== undefined) material.alphaWrite = json.alphaWrite; + + if (json.stencilWrite !== undefined) material.stencilWrite = json.stencilWrite; + if (json.stencilWriteMask !== undefined) material.stencilWriteMask = json.stencilWriteMask; + if (json.stencilFunc !== undefined) material.stencilFunc = json.stencilFunc; + if (json.stencilRef !== undefined) material.stencilRef = json.stencilRef; + if (json.stencilFuncMask !== undefined) material.stencilFuncMask = json.stencilFuncMask; + if (json.stencilFail !== undefined) material.stencilFail = json.stencilFail; + if (json.stencilZFail !== undefined) material.stencilZFail = json.stencilZFail; + if (json.stencilZPass !== undefined) material.stencilZPass = json.stencilZPass; + + if (json.wireframe !== undefined) material.wireframe = json.wireframe; + if (json.wireframeLinewidth !== undefined) material.wireframeLinewidth = json.wireframeLinewidth; + if (json.wireframeLinecap !== undefined) material.wireframeLinecap = json.wireframeLinecap; + if (json.wireframeLinejoin !== undefined) material.wireframeLinejoin = json.wireframeLinejoin; + + if (json.rotation !== undefined) material.rotation = json.rotation; + + if (json.linewidth !== 1) material.linewidth = json.linewidth; + if (json.dashSize !== undefined) material.dashSize = json.dashSize; + if (json.gapSize !== undefined) material.gapSize = json.gapSize; + if (json.scale !== undefined) material.scale = json.scale; + + if (json.polygonOffset !== undefined) material.polygonOffset = json.polygonOffset; + if (json.polygonOffsetFactor !== undefined) material.polygonOffsetFactor = json.polygonOffsetFactor; + if (json.polygonOffsetUnits !== undefined) material.polygonOffsetUnits = json.polygonOffsetUnits; + + if (json.dithering !== undefined) material.dithering = json.dithering; + + if (json.alphaToCoverage !== undefined) material.alphaToCoverage = json.alphaToCoverage; + if (json.premultipliedAlpha !== undefined) material.premultipliedAlpha = json.premultipliedAlpha; + + if (json.visible !== undefined) material.visible = json.visible; + + if (json.toneMapped !== undefined) material.toneMapped = json.toneMapped; + + if (json.userData !== undefined) material.userData = json.userData; + + if (json.vertexColors !== undefined) { + if (typeof json.vertexColors === 'number') { + material.vertexColors = json.vertexColors > 0 ? true : false; + } else { + material.vertexColors = json.vertexColors; + } + } + + // Shader Material + + if (json.uniforms !== undefined) { + for (const name in json.uniforms) { + const uniform = json.uniforms[name]; + + material.uniforms[name] = {}; + + switch (uniform.type) { + case 't': + material.uniforms[name].value = getTexture(uniform.value); + break; + + case 'c': + material.uniforms[name].value = new Color().setHex(uniform.value); + break; + + case 'v2': + material.uniforms[name].value = new Vector2().fromArray(uniform.value); + break; + + case 'v3': + material.uniforms[name].value = new Vector3().fromArray(uniform.value); + break; + + case 'v4': + material.uniforms[name].value = new Vector4().fromArray(uniform.value); + break; + + case 'm3': + material.uniforms[name].value = new Matrix3().fromArray(uniform.value); + break; + + case 'm4': + material.uniforms[name].value = new Matrix4().fromArray(uniform.value); + break; + + default: + material.uniforms[name].value = uniform.value; + } + } + } + + if (json.defines !== undefined) material.defines = json.defines; + if (json.vertexShader !== undefined) material.vertexShader = json.vertexShader; + if (json.fragmentShader !== undefined) material.fragmentShader = json.fragmentShader; + + if (json.extensions !== undefined) { + for (const key in json.extensions) { + material.extensions[key] = json.extensions[key]; + } + } + + // Deprecated + + if (json.shading !== undefined) material.flatShading = json.shading === 1; // THREE.FlatShading + + // for PointsMaterial + + if (json.size !== undefined) material.size = json.size; + if (json.sizeAttenuation !== undefined) material.sizeAttenuation = json.sizeAttenuation; + + // maps + + if (json.map !== undefined) material.map = getTexture(json.map); + if (json.matcap !== undefined) material.matcap = getTexture(json.matcap); + + if (json.alphaMap !== undefined) material.alphaMap = getTexture(json.alphaMap); + + if (json.bumpMap !== undefined) material.bumpMap = getTexture(json.bumpMap); + if (json.bumpScale !== undefined) material.bumpScale = json.bumpScale; + + if (json.normalMap !== undefined) material.normalMap = getTexture(json.normalMap); + if (json.normalMapType !== undefined) material.normalMapType = json.normalMapType; + if (json.normalScale !== undefined) { + let normalScale = json.normalScale; + + if (Array.isArray(normalScale) === false) { + // Blender exporter used to export a scalar. See #7459 + + normalScale = [normalScale, normalScale]; + } + + material.normalScale = new Vector2().fromArray(normalScale); + } + + if (json.displacementMap !== undefined) material.displacementMap = getTexture(json.displacementMap); + if (json.displacementScale !== undefined) material.displacementScale = json.displacementScale; + if (json.displacementBias !== undefined) material.displacementBias = json.displacementBias; + + if (json.roughnessMap !== undefined) material.roughnessMap = getTexture(json.roughnessMap); + if (json.metalnessMap !== undefined) material.metalnessMap = getTexture(json.metalnessMap); + + if (json.emissiveMap !== undefined) material.emissiveMap = getTexture(json.emissiveMap); + if (json.emissiveIntensity !== undefined) material.emissiveIntensity = json.emissiveIntensity; + + if (json.specularMap !== undefined) material.specularMap = getTexture(json.specularMap); + if (json.specularIntensityMap !== undefined) material.specularIntensityMap = getTexture(json.specularIntensityMap); + if (json.specularColorMap !== undefined) material.specularColorMap = getTexture(json.specularColorMap); + + if (json.envMap !== undefined) material.envMap = getTexture(json.envMap); + if (json.envMapIntensity !== undefined) material.envMapIntensity = json.envMapIntensity; + + if (json.reflectivity !== undefined) material.reflectivity = json.reflectivity; + if (json.refractionRatio !== undefined) material.refractionRatio = json.refractionRatio; + + if (json.lightMap !== undefined) material.lightMap = getTexture(json.lightMap); + if (json.lightMapIntensity !== undefined) material.lightMapIntensity = json.lightMapIntensity; + + if (json.aoMap !== undefined) material.aoMap = getTexture(json.aoMap); + if (json.aoMapIntensity !== undefined) material.aoMapIntensity = json.aoMapIntensity; + + if (json.gradientMap !== undefined) material.gradientMap = getTexture(json.gradientMap); + + if (json.clearcoatMap !== undefined) material.clearcoatMap = getTexture(json.clearcoatMap); + if (json.clearcoatRoughnessMap !== undefined) material.clearcoatRoughnessMap = getTexture(json.clearcoatRoughnessMap); + if (json.clearcoatNormalMap !== undefined) material.clearcoatNormalMap = getTexture(json.clearcoatNormalMap); + if (json.clearcoatNormalScale !== undefined) material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale); + + if (json.transmissionMap !== undefined) material.transmissionMap = getTexture(json.transmissionMap); + if (json.thicknessMap !== undefined) material.thicknessMap = getTexture(json.thicknessMap); + + if (json.sheenColorMap !== undefined) material.sheenColorMap = getTexture(json.sheenColorMap); + if (json.sheenRoughnessMap !== undefined) material.sheenRoughnessMap = getTexture(json.sheenRoughnessMap); + + return material; + } + + setTextures(value) { + this.textures = value; + return this; + } +} + +export { MaterialLoader }; diff --git a/backend/libs/three/loaders/ObjectLoader.d.ts b/backend/libs/three/loaders/ObjectLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6324139fff8a4c5d7773a8937d4f848a7e9021ff --- /dev/null +++ b/backend/libs/three/loaders/ObjectLoader.d.ts @@ -0,0 +1,42 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { Object3D } from './../core/Object3D'; +import { Texture } from './../textures/Texture'; +import { Material } from './../materials/Material'; +import { AnimationClip } from './../animation/AnimationClip'; +import { InstancedBufferGeometry } from '../core/InstancedBufferGeometry'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class ObjectLoader extends Loader { + constructor(manager?: LoadingManager); + + load( + url: string, + // tslint:disable-next-line:no-unnecessary-generics + onLoad?: (object: ObjectType) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: Error | ErrorEvent) => void + ): void; + loadAsync( + url: string, + onProgress?: (event: ProgressEvent) => void + ): // tslint:disable-next-line:no-unnecessary-generics + Promise; + // tslint:disable-next-line:no-unnecessary-generics + parse(json: any, onLoad?: (object: Object3D) => void): T; + // tslint:disable-next-line:no-unnecessary-generics + parseAsync(json: any): Promise; + parseGeometries(json: any): { [key: string]: InstancedBufferGeometry | BufferGeometry }; // Array of BufferGeometry or Geometry or Geometry2. + parseMaterials(json: any, textures: Texture[]): Material[]; // Array of Classes that inherits from Matrial. + parseAnimations(json: any): AnimationClip[]; + parseImages(json: any, onLoad: () => void): { [key: string]: HTMLImageElement }; + parseImagesAsync(json: any): Promise<{ [key: string]: HTMLImageElement }>; + parseTextures(json: any, images: any): Texture[]; + parseObject( + data: any, + geometries: any[], + materials: Material[], + animations: AnimationClip[] + ): // tslint:disable-next-line:no-unnecessary-generics + T; +} diff --git a/backend/libs/three/loaders/ObjectLoader.js b/backend/libs/three/loaders/ObjectLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..c2305058bb7daa79663a7c4b9e417d0c81b0467a --- /dev/null +++ b/backend/libs/three/loaders/ObjectLoader.js @@ -0,0 +1,875 @@ +import { + UVMapping, + CubeReflectionMapping, + CubeRefractionMapping, + EquirectangularReflectionMapping, + EquirectangularRefractionMapping, + CubeUVReflectionMapping, + CubeUVRefractionMapping, + RepeatWrapping, + ClampToEdgeWrapping, + MirroredRepeatWrapping, + NearestFilter, + NearestMipmapNearestFilter, + NearestMipmapLinearFilter, + LinearFilter, + LinearMipmapNearestFilter, + LinearMipmapLinearFilter, +} from '../constants.js'; +import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js'; +import { Color } from '../math/Color.js'; +import { Object3D } from '../core/Object3D.js'; +import { Group } from '../objects/Group.js'; +import { InstancedMesh } from '../objects/InstancedMesh.js'; +import { Sprite } from '../objects/Sprite.js'; +import { Points } from '../objects/Points.js'; +import { Line } from '../objects/Line.js'; +import { LineLoop } from '../objects/LineLoop.js'; +import { LineSegments } from '../objects/LineSegments.js'; +import { LOD } from '../objects/LOD.js'; +import { Mesh } from '../objects/Mesh.js'; +import { SkinnedMesh } from '../objects/SkinnedMesh.js'; +import { Bone } from '../objects/Bone.js'; +import { Skeleton } from '../objects/Skeleton.js'; +import { Shape } from '../extras/core/Shape.js'; +import { Fog } from '../scenes/Fog.js'; +import { FogExp2 } from '../scenes/FogExp2.js'; +import { HemisphereLight } from '../lights/HemisphereLight.js'; +import { SpotLight } from '../lights/SpotLight.js'; +import { PointLight } from '../lights/PointLight.js'; +import { DirectionalLight } from '../lights/DirectionalLight.js'; +import { AmbientLight } from '../lights/AmbientLight.js'; +import { RectAreaLight } from '../lights/RectAreaLight.js'; +import { LightProbe } from '../lights/LightProbe.js'; +import { OrthographicCamera } from '../cameras/OrthographicCamera.js'; +import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; +import { Scene } from '../scenes/Scene.js'; +import { CubeTexture } from '../textures/CubeTexture.js'; +import { Texture } from '../textures/Texture.js'; +import { DataTexture } from '../textures/DataTexture.js'; +import { ImageLoader } from './ImageLoader.js'; +import { LoadingManager } from './LoadingManager.js'; +import { AnimationClip } from '../animation/AnimationClip.js'; +import { MaterialLoader } from './MaterialLoader.js'; +import { LoaderUtils } from './LoaderUtils.js'; +import { BufferGeometryLoader } from './BufferGeometryLoader.js'; +import { Loader } from './Loader.js'; +import { FileLoader } from './FileLoader.js'; +import * as Geometries from '../geometries/Geometries.js'; +import { getTypedArray } from '../utils.js'; + +class ObjectLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const scope = this; + + const path = this.path === '' ? LoaderUtils.extractUrlBase(url) : this.path; + this.resourcePath = this.resourcePath || path; + + const loader = new FileLoader(this.manager); + loader.setPath(this.path); + loader.setRequestHeader(this.requestHeader); + loader.setWithCredentials(this.withCredentials); + loader.load( + url, + function (text) { + let json = null; + + try { + json = JSON.parse(text); + } catch (error) { + if (onError !== undefined) onError(error); + + console.error("THREE:ObjectLoader: Can't parse " + url + '.', error.message); + + return; + } + + const metadata = json.metadata; + + if (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') { + console.error("THREE.ObjectLoader: Can't load " + url); + return; + } + + scope.parse(json, onLoad); + }, + onProgress, + onError + ); + } + + async loadAsync(url, onProgress) { + const scope = this; + + const path = this.path === '' ? LoaderUtils.extractUrlBase(url) : this.path; + this.resourcePath = this.resourcePath || path; + + const loader = new FileLoader(this.manager); + loader.setPath(this.path); + loader.setRequestHeader(this.requestHeader); + loader.setWithCredentials(this.withCredentials); + + const text = await loader.loadAsync(url, onProgress); + + const json = JSON.parse(text); + + const metadata = json.metadata; + + if (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') { + throw new Error("THREE.ObjectLoader: Can't load " + url); + } + + return await scope.parseAsync(json); + } + + parse(json, onLoad) { + const animations = this.parseAnimations(json.animations); + const shapes = this.parseShapes(json.shapes); + const geometries = this.parseGeometries(json.geometries, shapes); + + const images = this.parseImages(json.images, function () { + if (onLoad !== undefined) onLoad(object); + }); + + const textures = this.parseTextures(json.textures, images); + const materials = this.parseMaterials(json.materials, textures); + + const object = this.parseObject(json.object, geometries, materials, textures, animations); + const skeletons = this.parseSkeletons(json.skeletons, object); + + this.bindSkeletons(object, skeletons); + + // + + if (onLoad !== undefined) { + let hasImages = false; + + for (const uuid in images) { + if (images[uuid] instanceof HTMLImageElement) { + hasImages = true; + break; + } + } + + if (hasImages === false) onLoad(object); + } + + return object; + } + + async parseAsync(json) { + const animations = this.parseAnimations(json.animations); + const shapes = this.parseShapes(json.shapes); + const geometries = this.parseGeometries(json.geometries, shapes); + + const images = await this.parseImagesAsync(json.images); + + const textures = this.parseTextures(json.textures, images); + const materials = this.parseMaterials(json.materials, textures); + + const object = this.parseObject(json.object, geometries, materials, textures, animations); + const skeletons = this.parseSkeletons(json.skeletons, object); + + this.bindSkeletons(object, skeletons); + + return object; + } + + parseShapes(json) { + const shapes = {}; + + if (json !== undefined) { + for (let i = 0, l = json.length; i < l; i++) { + const shape = new Shape().fromJSON(json[i]); + + shapes[shape.uuid] = shape; + } + } + + return shapes; + } + + parseSkeletons(json, object) { + const skeletons = {}; + const bones = {}; + + // generate bone lookup table + + object.traverse(function (child) { + if (child.isBone) bones[child.uuid] = child; + }); + + // create skeletons + + if (json !== undefined) { + for (let i = 0, l = json.length; i < l; i++) { + const skeleton = new Skeleton().fromJSON(json[i], bones); + + skeletons[skeleton.uuid] = skeleton; + } + } + + return skeletons; + } + + parseGeometries(json, shapes) { + const geometries = {}; + + if (json !== undefined) { + const bufferGeometryLoader = new BufferGeometryLoader(); + + for (let i = 0, l = json.length; i < l; i++) { + let geometry; + const data = json[i]; + + switch (data.type) { + case 'BufferGeometry': + case 'InstancedBufferGeometry': + geometry = bufferGeometryLoader.parse(data); + + break; + + case 'Geometry': + console.error('THREE.ObjectLoader: The legacy Geometry type is no longer supported.'); + + break; + + default: + if (data.type in Geometries) { + geometry = Geometries[data.type].fromJSON(data, shapes); + } else { + console.warn(`THREE.ObjectLoader: Unsupported geometry type "${data.type}"`); + } + } + + geometry.uuid = data.uuid; + + if (data.name !== undefined) geometry.name = data.name; + if (geometry.isBufferGeometry === true && data.userData !== undefined) geometry.userData = data.userData; + + geometries[data.uuid] = geometry; + } + } + + return geometries; + } + + parseMaterials(json, textures) { + const cache = {}; // MultiMaterial + const materials = {}; + + if (json !== undefined) { + const loader = new MaterialLoader(); + loader.setTextures(textures); + + for (let i = 0, l = json.length; i < l; i++) { + const data = json[i]; + + if (data.type === 'MultiMaterial') { + // Deprecated + + const array = []; + + for (let j = 0; j < data.materials.length; j++) { + const material = data.materials[j]; + + if (cache[material.uuid] === undefined) { + cache[material.uuid] = loader.parse(material); + } + + array.push(cache[material.uuid]); + } + + materials[data.uuid] = array; + } else { + if (cache[data.uuid] === undefined) { + cache[data.uuid] = loader.parse(data); + } + + materials[data.uuid] = cache[data.uuid]; + } + } + } + + return materials; + } + + parseAnimations(json) { + const animations = {}; + + if (json !== undefined) { + for (let i = 0; i < json.length; i++) { + const data = json[i]; + + const clip = AnimationClip.parse(data); + + animations[clip.uuid] = clip; + } + } + + return animations; + } + + parseImages(json, onLoad) { + const scope = this; + const images = {}; + + let loader; + + function loadImage(url) { + scope.manager.itemStart(url); + + return loader.load( + url, + function () { + scope.manager.itemEnd(url); + }, + undefined, + function () { + scope.manager.itemError(url); + scope.manager.itemEnd(url); + } + ); + } + + function deserializeImage(image) { + if (typeof image === 'string') { + const url = image; + + const path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(url) ? url : scope.resourcePath + url; + + return loadImage(path); + } else { + if (image.data) { + return { + data: getTypedArray(image.type, image.data), + width: image.width, + height: image.height, + }; + } else { + return null; + } + } + } + + if (json !== undefined && json.length > 0) { + const manager = new LoadingManager(onLoad); + + loader = new ImageLoader(manager); + loader.setCrossOrigin(this.crossOrigin); + + for (let i = 0, il = json.length; i < il; i++) { + const image = json[i]; + const url = image.url; + + if (Array.isArray(url)) { + // load array of images e.g CubeTexture + + images[image.uuid] = []; + + for (let j = 0, jl = url.length; j < jl; j++) { + const currentUrl = url[j]; + + const deserializedImage = deserializeImage(currentUrl); + + if (deserializedImage !== null) { + if (deserializedImage instanceof HTMLImageElement) { + images[image.uuid].push(deserializedImage); + } else { + // special case: handle array of data textures for cube textures + + images[image.uuid].push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height)); + } + } + } + } else { + // load single image + + const deserializedImage = deserializeImage(image.url); + + if (deserializedImage !== null) { + images[image.uuid] = deserializedImage; + } + } + } + } + + return images; + } + + async parseImagesAsync(json) { + const scope = this; + const images = {}; + + let loader; + + async function deserializeImage(image) { + if (typeof image === 'string') { + const url = image; + + const path = /^(\/\/)|([a-z]+:(\/\/)?)/i.test(url) ? url : scope.resourcePath + url; + + return await loader.loadAsync(path); + } else { + if (image.data) { + return { + data: getTypedArray(image.type, image.data), + width: image.width, + height: image.height, + }; + } else { + return null; + } + } + } + + if (json !== undefined && json.length > 0) { + loader = new ImageLoader(this.manager); + loader.setCrossOrigin(this.crossOrigin); + + for (let i = 0, il = json.length; i < il; i++) { + const image = json[i]; + const url = image.url; + + if (Array.isArray(url)) { + // load array of images e.g CubeTexture + + images[image.uuid] = []; + + for (let j = 0, jl = url.length; j < jl; j++) { + const currentUrl = url[j]; + + const deserializedImage = await deserializeImage(currentUrl); + + if (deserializedImage !== null) { + if (deserializedImage instanceof HTMLImageElement) { + images[image.uuid].push(deserializedImage); + } else { + // special case: handle array of data textures for cube textures + + images[image.uuid].push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height)); + } + } + } + } else { + // load single image + + const deserializedImage = await deserializeImage(image.url); + + if (deserializedImage !== null) { + images[image.uuid] = deserializedImage; + } + } + } + } + + return images; + } + + parseTextures(json, images) { + function parseConstant(value, type) { + if (typeof value === 'number') return value; + + console.warn('THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value); + + return type[value]; + } + + const textures = {}; + + if (json !== undefined) { + for (let i = 0, l = json.length; i < l; i++) { + const data = json[i]; + + if (data.image === undefined) { + console.warn('THREE.ObjectLoader: No "image" specified for', data.uuid); + } + + if (images[data.image] === undefined) { + console.warn('THREE.ObjectLoader: Undefined image', data.image); + } + + let texture; + const image = images[data.image]; + + if (Array.isArray(image)) { + texture = new CubeTexture(image); + + if (image.length === 6) texture.needsUpdate = true; + } else { + if (image && image.data) { + texture = new DataTexture(image.data, image.width, image.height); + } else { + texture = new Texture(image); + } + + if (image) texture.needsUpdate = true; // textures can have undefined image data + } + + texture.uuid = data.uuid; + + if (data.name !== undefined) texture.name = data.name; + + if (data.mapping !== undefined) texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING); + + if (data.offset !== undefined) texture.offset.fromArray(data.offset); + if (data.repeat !== undefined) texture.repeat.fromArray(data.repeat); + if (data.center !== undefined) texture.center.fromArray(data.center); + if (data.rotation !== undefined) texture.rotation = data.rotation; + + if (data.wrap !== undefined) { + texture.wrapS = parseConstant(data.wrap[0], TEXTURE_WRAPPING); + texture.wrapT = parseConstant(data.wrap[1], TEXTURE_WRAPPING); + } + + if (data.format !== undefined) texture.format = data.format; + if (data.type !== undefined) texture.type = data.type; + if (data.encoding !== undefined) texture.encoding = data.encoding; + + if (data.minFilter !== undefined) texture.minFilter = parseConstant(data.minFilter, TEXTURE_FILTER); + if (data.magFilter !== undefined) texture.magFilter = parseConstant(data.magFilter, TEXTURE_FILTER); + if (data.anisotropy !== undefined) texture.anisotropy = data.anisotropy; + + if (data.flipY !== undefined) texture.flipY = data.flipY; + + if (data.premultiplyAlpha !== undefined) texture.premultiplyAlpha = data.premultiplyAlpha; + if (data.unpackAlignment !== undefined) texture.unpackAlignment = data.unpackAlignment; + + if (data.userData !== undefined) texture.userData = data.userData; + + textures[data.uuid] = texture; + } + } + + return textures; + } + + parseObject(data, geometries, materials, textures, animations) { + let object; + + function getGeometry(name) { + if (geometries[name] === undefined) { + console.warn('THREE.ObjectLoader: Undefined geometry', name); + } + + return geometries[name]; + } + + function getMaterial(name) { + if (name === undefined) return undefined; + + if (Array.isArray(name)) { + const array = []; + + for (let i = 0, l = name.length; i < l; i++) { + const uuid = name[i]; + + if (materials[uuid] === undefined) { + console.warn('THREE.ObjectLoader: Undefined material', uuid); + } + + array.push(materials[uuid]); + } + + return array; + } + + if (materials[name] === undefined) { + console.warn('THREE.ObjectLoader: Undefined material', name); + } + + return materials[name]; + } + + function getTexture(uuid) { + if (textures[uuid] === undefined) { + console.warn('THREE.ObjectLoader: Undefined texture', uuid); + } + + return textures[uuid]; + } + + let geometry, material; + + switch (data.type) { + case 'Scene': + object = new Scene(); + + if (data.background !== undefined) { + if (Number.isInteger(data.background)) { + object.background = new Color(data.background); + } else { + object.background = getTexture(data.background); + } + } + + if (data.environment !== undefined) { + object.environment = getTexture(data.environment); + } + + if (data.fog !== undefined) { + if (data.fog.type === 'Fog') { + object.fog = new Fog(data.fog.color, data.fog.near, data.fog.far); + } else if (data.fog.type === 'FogExp2') { + object.fog = new FogExp2(data.fog.color, data.fog.density); + } + } + + break; + + case 'PerspectiveCamera': + object = new PerspectiveCamera(data.fov, data.aspect, data.near, data.far); + + if (data.focus !== undefined) object.focus = data.focus; + if (data.zoom !== undefined) object.zoom = data.zoom; + if (data.filmGauge !== undefined) object.filmGauge = data.filmGauge; + if (data.filmOffset !== undefined) object.filmOffset = data.filmOffset; + if (data.view !== undefined) object.view = Object.assign({}, data.view); + + break; + + case 'OrthographicCamera': + object = new OrthographicCamera(data.left, data.right, data.top, data.bottom, data.near, data.far); + + if (data.zoom !== undefined) object.zoom = data.zoom; + if (data.view !== undefined) object.view = Object.assign({}, data.view); + + break; + + case 'AmbientLight': + object = new AmbientLight(data.color, data.intensity); + + break; + + case 'DirectionalLight': + object = new DirectionalLight(data.color, data.intensity); + + break; + + case 'PointLight': + object = new PointLight(data.color, data.intensity, data.distance, data.decay); + + break; + + case 'RectAreaLight': + object = new RectAreaLight(data.color, data.intensity, data.width, data.height); + + break; + + case 'SpotLight': + object = new SpotLight(data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay); + + break; + + case 'HemisphereLight': + object = new HemisphereLight(data.color, data.groundColor, data.intensity); + + break; + + case 'LightProbe': + object = new LightProbe().fromJSON(data); + + break; + + case 'SkinnedMesh': + geometry = getGeometry(data.geometry); + material = getMaterial(data.material); + + object = new SkinnedMesh(geometry, material); + + if (data.bindMode !== undefined) object.bindMode = data.bindMode; + if (data.bindMatrix !== undefined) object.bindMatrix.fromArray(data.bindMatrix); + if (data.skeleton !== undefined) object.skeleton = data.skeleton; + + break; + + case 'Mesh': + geometry = getGeometry(data.geometry); + material = getMaterial(data.material); + + object = new Mesh(geometry, material); + + break; + + case 'InstancedMesh': + geometry = getGeometry(data.geometry); + material = getMaterial(data.material); + const count = data.count; + const instanceMatrix = data.instanceMatrix; + const instanceColor = data.instanceColor; + + object = new InstancedMesh(geometry, material, count); + object.instanceMatrix = new InstancedBufferAttribute(new Float32Array(instanceMatrix.array), 16); + if (instanceColor !== undefined) + object.instanceColor = new InstancedBufferAttribute(new Float32Array(instanceColor.array), instanceColor.itemSize); + + break; + + case 'LOD': + object = new LOD(); + + break; + + case 'Line': + object = new Line(getGeometry(data.geometry), getMaterial(data.material)); + + break; + + case 'LineLoop': + object = new LineLoop(getGeometry(data.geometry), getMaterial(data.material)); + + break; + + case 'LineSegments': + object = new LineSegments(getGeometry(data.geometry), getMaterial(data.material)); + + break; + + case 'PointCloud': + case 'Points': + object = new Points(getGeometry(data.geometry), getMaterial(data.material)); + + break; + + case 'Sprite': + object = new Sprite(getMaterial(data.material)); + + break; + + case 'Group': + object = new Group(); + + break; + + case 'Bone': + object = new Bone(); + + break; + + default: + object = new Object3D(); + } + + object.uuid = data.uuid; + + if (data.name !== undefined) object.name = data.name; + + if (data.matrix !== undefined) { + object.matrix.fromArray(data.matrix); + + if (data.matrixAutoUpdate !== undefined) object.matrixAutoUpdate = data.matrixAutoUpdate; + if (object.matrixAutoUpdate) object.matrix.decompose(object.position, object.quaternion, object.scale); + } else { + if (data.position !== undefined) object.position.fromArray(data.position); + if (data.rotation !== undefined) object.rotation.fromArray(data.rotation); + if (data.quaternion !== undefined) object.quaternion.fromArray(data.quaternion); + if (data.scale !== undefined) object.scale.fromArray(data.scale); + } + + if (data.castShadow !== undefined) object.castShadow = data.castShadow; + if (data.receiveShadow !== undefined) object.receiveShadow = data.receiveShadow; + + if (data.shadow) { + if (data.shadow.bias !== undefined) object.shadow.bias = data.shadow.bias; + if (data.shadow.normalBias !== undefined) object.shadow.normalBias = data.shadow.normalBias; + if (data.shadow.radius !== undefined) object.shadow.radius = data.shadow.radius; + if (data.shadow.mapSize !== undefined) object.shadow.mapSize.fromArray(data.shadow.mapSize); + if (data.shadow.camera !== undefined) object.shadow.camera = this.parseObject(data.shadow.camera); + } + + if (data.visible !== undefined) object.visible = data.visible; + if (data.frustumCulled !== undefined) object.frustumCulled = data.frustumCulled; + if (data.renderOrder !== undefined) object.renderOrder = data.renderOrder; + if (data.userData !== undefined) object.userData = data.userData; + if (data.layers !== undefined) object.layers.mask = data.layers; + + if (data.children !== undefined) { + const children = data.children; + + for (let i = 0; i < children.length; i++) { + object.add(this.parseObject(children[i], geometries, materials, textures, animations)); + } + } + + if (data.animations !== undefined) { + const objectAnimations = data.animations; + + for (let i = 0; i < objectAnimations.length; i++) { + const uuid = objectAnimations[i]; + + object.animations.push(animations[uuid]); + } + } + + if (data.type === 'LOD') { + if (data.autoUpdate !== undefined) object.autoUpdate = data.autoUpdate; + + const levels = data.levels; + + for (let l = 0; l < levels.length; l++) { + const level = levels[l]; + const child = object.getObjectByProperty('uuid', level.object); + + if (child !== undefined) { + object.addLevel(child, level.distance); + } + } + } + + return object; + } + + bindSkeletons(object, skeletons) { + if (Object.keys(skeletons).length === 0) return; + + object.traverse(function (child) { + if (child.isSkinnedMesh === true && child.skeleton !== undefined) { + const skeleton = skeletons[child.skeleton]; + + if (skeleton === undefined) { + console.warn('THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton); + } else { + child.bind(skeleton, child.bindMatrix); + } + } + }); + } + + /* DEPRECATED */ + + setTexturePath(value) { + console.warn('THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().'); + return this.setResourcePath(value); + } +} + +const TEXTURE_MAPPING = { + UVMapping: UVMapping, + CubeReflectionMapping: CubeReflectionMapping, + CubeRefractionMapping: CubeRefractionMapping, + EquirectangularReflectionMapping: EquirectangularReflectionMapping, + EquirectangularRefractionMapping: EquirectangularRefractionMapping, + CubeUVReflectionMapping: CubeUVReflectionMapping, + CubeUVRefractionMapping: CubeUVRefractionMapping, +}; + +const TEXTURE_WRAPPING = { + RepeatWrapping: RepeatWrapping, + ClampToEdgeWrapping: ClampToEdgeWrapping, + MirroredRepeatWrapping: MirroredRepeatWrapping, +}; + +const TEXTURE_FILTER = { + NearestFilter: NearestFilter, + NearestMipmapNearestFilter: NearestMipmapNearestFilter, + NearestMipmapLinearFilter: NearestMipmapLinearFilter, + LinearFilter: LinearFilter, + LinearMipmapNearestFilter: LinearMipmapNearestFilter, + LinearMipmapLinearFilter: LinearMipmapLinearFilter, +}; + +export { ObjectLoader }; diff --git a/backend/libs/three/loaders/TextureLoader.d.ts b/backend/libs/three/loaders/TextureLoader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f616967e5fed10a8d778fa2ace5cf7d960e77b0d --- /dev/null +++ b/backend/libs/three/loaders/TextureLoader.d.ts @@ -0,0 +1,15 @@ +import { Loader } from './Loader'; +import { LoadingManager } from './LoadingManager'; +import { Texture } from './../textures/Texture'; + +/** + * Class for loading a texture. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ +export class TextureLoader extends Loader { + constructor(manager?: LoadingManager); + + load(url: string, onLoad?: (texture: Texture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): Texture; + + loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise; +} diff --git a/backend/libs/three/loaders/TextureLoader.js b/backend/libs/three/loaders/TextureLoader.js new file mode 100644 index 0000000000000000000000000000000000000000..90efb7bb8d69ec8dd93eadf413ec5b41fb36a384 --- /dev/null +++ b/backend/libs/three/loaders/TextureLoader.js @@ -0,0 +1,35 @@ +import { ImageLoader } from './ImageLoader.js'; +import { Texture } from '../textures/Texture.js'; +import { Loader } from './Loader.js'; + +class TextureLoader extends Loader { + constructor(manager) { + super(manager); + } + + load(url, onLoad, onProgress, onError) { + const texture = new Texture(); + + const loader = new ImageLoader(this.manager); + loader.setCrossOrigin(this.crossOrigin); + loader.setPath(this.path); + + loader.load( + url, + function (image) { + texture.image = image; + texture.needsUpdate = true; + + if (onLoad !== undefined) { + onLoad(texture); + } + }, + onProgress, + onError + ); + + return texture; + } +} + +export { TextureLoader }; diff --git a/backend/libs/three/materials/LineBasicMaterial.d.ts b/backend/libs/three/materials/LineBasicMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d3a28f215ce617e8539afc92f441e541a111195b --- /dev/null +++ b/backend/libs/three/materials/LineBasicMaterial.d.ts @@ -0,0 +1,41 @@ +import { ColorRepresentation } from '../utils'; +import { Color } from './../math/Color'; +import { MaterialParameters, Material } from './Material'; + +export interface LineBasicMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + linewidth?: number | undefined; + linecap?: string | undefined; + linejoin?: string | undefined; +} + +export class LineBasicMaterial extends Material { + constructor(parameters?: LineBasicMaterialParameters); + + /** + * @default 'LineBasicMaterial' + */ + type: string; + + /** + * @default 0xffffff + */ + color: Color; + + /** + * @default 1 + */ + linewidth: number; + + /** + * @default 'round' + */ + linecap: string; + + /** + * @default 'round' + */ + linejoin: string; + + setValues(parameters: LineBasicMaterialParameters): void; +} diff --git a/backend/libs/three/materials/LineBasicMaterial.js b/backend/libs/three/materials/LineBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..5699223ac3b622a1ca2af93a1b10fc044ea7af7d --- /dev/null +++ b/backend/libs/three/materials/LineBasicMaterial.js @@ -0,0 +1,45 @@ +import { Material } from './Material.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * opacity: , + * + * linewidth: , + * linecap: "round", + * linejoin: "round" + * } + */ + +class LineBasicMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'LineBasicMaterial'; + + this.color = new Color(0xffffff); + + this.linewidth = 1; + this.linecap = 'round'; + this.linejoin = 'round'; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.linewidth = source.linewidth; + this.linecap = source.linecap; + this.linejoin = source.linejoin; + + return this; + } +} + +LineBasicMaterial.prototype.isLineBasicMaterial = true; + +export { LineBasicMaterial }; diff --git a/backend/libs/three/materials/LineDashedMaterial.d.ts b/backend/libs/three/materials/LineDashedMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..03e09d61260f3127887f201a0ef477a3ac274836 --- /dev/null +++ b/backend/libs/three/materials/LineDashedMaterial.d.ts @@ -0,0 +1,34 @@ +import { LineBasicMaterial, LineBasicMaterialParameters } from './LineBasicMaterial'; + +export interface LineDashedMaterialParameters extends LineBasicMaterialParameters { + scale?: number | undefined; + dashSize?: number | undefined; + gapSize?: number | undefined; +} + +export class LineDashedMaterial extends LineBasicMaterial { + constructor(parameters?: LineDashedMaterialParameters); + + /** + * @default 'LineDashedMaterial' + */ + type: string; + + /** + * @default 1 + */ + scale: number; + + /** + * @default 1 + */ + dashSize: number; + + /** + * @default 1 + */ + gapSize: number; + readonly isLineDashedMaterial: true; + + setValues(parameters: LineDashedMaterialParameters): void; +} diff --git a/backend/libs/three/materials/LineDashedMaterial.js b/backend/libs/three/materials/LineDashedMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..b6d0793e00d929e57627654ac086f5977af15070 --- /dev/null +++ b/backend/libs/three/materials/LineDashedMaterial.js @@ -0,0 +1,42 @@ +import { LineBasicMaterial } from './LineBasicMaterial.js'; + +/** + * parameters = { + * color: , + * opacity: , + * + * linewidth: , + * + * scale: , + * dashSize: , + * gapSize: + * } + */ + +class LineDashedMaterial extends LineBasicMaterial { + constructor(parameters) { + super(); + + this.type = 'LineDashedMaterial'; + + this.scale = 1; + this.dashSize = 3; + this.gapSize = 1; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.scale = source.scale; + this.dashSize = source.dashSize; + this.gapSize = source.gapSize; + + return this; + } +} + +LineDashedMaterial.prototype.isLineDashedMaterial = true; + +export { LineDashedMaterial }; diff --git a/backend/libs/three/materials/Material.d.ts b/backend/libs/three/materials/Material.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..dff0f7762d02f0ce0ca01ec02b2fb5ded29481bd --- /dev/null +++ b/backend/libs/three/materials/Material.d.ts @@ -0,0 +1,397 @@ +import { Plane } from './../math/Plane'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Shader } from './../renderers/shaders/ShaderLib'; +import { BlendingDstFactor, BlendingEquation, Blending, BlendingSrcFactor, DepthModes, Side, StencilFunc, StencilOp, PixelFormat } from '../constants'; +import { ColorRepresentation } from '../utils'; +import { Color } from '../math/Color'; +import { Texture } from '../textures/Texture'; + +export interface MaterialParameters { + alphaTest?: number | undefined; + alphaToCoverage?: boolean | undefined; + blendDst?: BlendingDstFactor | undefined; + blendDstAlpha?: number | undefined; + blendEquation?: BlendingEquation | undefined; + blendEquationAlpha?: number | undefined; + blending?: Blending | undefined; + blendSrc?: BlendingSrcFactor | BlendingDstFactor | undefined; + blendSrcAlpha?: number | undefined; + clipIntersection?: boolean | undefined; + clippingPlanes?: Plane[] | undefined; + clipShadows?: boolean | undefined; + colorWrite?: boolean | undefined; + defines?: any; + depthFunc?: DepthModes | undefined; + depthTest?: boolean | undefined; + depthWrite?: boolean | undefined; + fog?: boolean | undefined; + name?: string | undefined; + opacity?: number | undefined; + polygonOffset?: boolean | undefined; + polygonOffsetFactor?: number | undefined; + polygonOffsetUnits?: number | undefined; + precision?: 'highp' | 'mediump' | 'lowp' | null | undefined; + premultipliedAlpha?: boolean | undefined; + dithering?: boolean | undefined; + side?: Side | undefined; + shadowSide?: Side | undefined; + toneMapped?: boolean | undefined; + transparent?: boolean | undefined; + vertexColors?: boolean | undefined; + visible?: boolean | undefined; + format?: PixelFormat | undefined; + stencilWrite?: boolean | undefined; + stencilFunc?: StencilFunc | undefined; + stencilRef?: number | undefined; + stencilWriteMask?: number | undefined; + stencilFuncMask?: number | undefined; + stencilFail?: StencilOp | undefined; + stencilZFail?: StencilOp | undefined; + stencilZPass?: StencilOp | undefined; + userData?: any; +} + +/** + * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. + */ +export class Material extends EventDispatcher { + constructor(); + + /** + * Sets the alpha value to be used when running an alpha test. Default is 0. + * @default 0 + */ + alphaTest: number; + + /** + * Enables alpha to coverage. Can only be used with MSAA-enabled rendering contexts. + * @default false + */ + alphaToCoverage: boolean; + + /** + * Blending destination. It's one of the blending mode constants defined in Three.js. Default is {@link OneMinusSrcAlphaFactor}. + * @default THREE.OneMinusSrcAlphaFactor + */ + blendDst: BlendingDstFactor; + + /** + * The tranparency of the .blendDst. Default is null. + * @default null + */ + blendDstAlpha: number | null; + + /** + * Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is {@link AddEquation}. + * @default THREE.AddEquation + */ + blendEquation: BlendingEquation; + + /** + * The tranparency of the .blendEquation. Default is null. + * @default null + */ + blendEquationAlpha: number | null; + + /** + * Which blending to use when displaying objects with this material. Default is {@link NormalBlending}. + * @default THREE.NormalBlending + */ + blending: Blending; + + /** + * Blending source. It's one of the blending mode constants defined in Three.js. Default is {@link SrcAlphaFactor}. + * @default THREE.SrcAlphaFactor + */ + blendSrc: BlendingSrcFactor | BlendingDstFactor; + + /** + * The tranparency of the .blendSrc. Default is null. + * @default null + */ + blendSrcAlpha: number | null; + + /** + * Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. Default is false. + * @default false + */ + clipIntersection: boolean; + + /** + * User-defined clipping planes specified as THREE.Plane objects in world space. + * These planes apply to the objects this material is attached to. + * Points in space whose signed distance to the plane is negative are clipped (not rendered). + * See the WebGL / clipping /intersection example. Default is null. + * @default null + */ + clippingPlanes: any; + + /** + * Defines whether to clip shadows according to the clipping planes specified on this material. Default is false. + * @default false + */ + clipShadows: boolean; + + /** + * Whether to render the material's color. This can be used in conjunction with a mesh's .renderOrder property to create invisible objects that occlude other objects. Default is true. + * @default true + */ + colorWrite: boolean; + + /** + * Custom defines to be injected into the shader. These are passed in form of an object literal, with key/value pairs. { MY_CUSTOM_DEFINE: '' , PI2: Math.PI * 2 }. + * The pairs are defined in both vertex and fragment shaders. Default is undefined. + * @default undefined + */ + defines: undefined | { [key: string]: any }; + + /** + * Which depth function to use. Default is {@link LessEqualDepth}. See the depth mode constants for all possible values. + * @default THREE.LessEqualDepth + */ + depthFunc: DepthModes; + + /** + * Whether to have depth test enabled when rendering this material. Default is true. + * @default true + */ + depthTest: boolean; + + /** + * Whether rendering this material has any effect on the depth buffer. Default is true. + * When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts. + * @default true + */ + depthWrite: boolean; + + /** + * Whether the material is affected by fog. Default is true. + * @default fog + */ + fog: boolean; + + /** + * Unique number of this material instance. + */ + id: number; + + /** + * Whether rendering this material has any effect on the stencil buffer. Default is *false*. + * @default false + */ + stencilWrite: boolean; + + /** + * The stencil comparison function to use. Default is {@link AlwaysStencilFunc}. See stencil operation constants for all possible values. + * @default THREE.AlwaysStencilFunc + */ + stencilFunc: StencilFunc; + + /** + * The value to use when performing stencil comparisons or stencil operations. Default is *0*. + * @default 0 + */ + stencilRef: number; + + /** + * The bit mask to use when writing to the stencil buffer. Default is *0xFF*. + * @default 0xff + */ + stencilWriteMask: number; + + /** + * The bit mask to use when comparing against the stencil buffer. Default is *0xFF*. + * @default 0xff + */ + stencilFuncMask: number; + + /** + * Which stencil operation to perform when the comparison function returns false. Default is {@link KeepStencilOp}. See the stencil operation constants for all possible values. + * @default THREE.KeepStencilOp + */ + stencilFail: StencilOp; + + /** + * Which stencil operation to perform when the comparison function returns true but the depth test fails. + * Default is {@link KeepStencilOp}. + * See the stencil operation constants for all possible values. + * @default THREE.KeepStencilOp + */ + stencilZFail: StencilOp; + + /** + * Which stencil operation to perform when the comparison function returns true and the depth test passes. + * Default is {@link KeepStencilOp}. + * See the stencil operation constants for all possible values. + * @default THREE.KeepStencilOp + */ + stencilZPass: StencilOp; + + /** + * Used to check whether this or derived classes are materials. Default is true. + * You should not change this, as it used internally for optimisation. + */ + readonly isMaterial: true; + + /** + * Material name. Default is an empty string. + * @default '' + */ + name: string; + + /** + * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. + * This property is automatically set to true when instancing a new material. + * @default false + */ + needsUpdate: boolean; + + /** + * Opacity. Default is 1. + * @default 1 + */ + opacity: number; + + /** + * Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature. + * @default false + */ + polygonOffset: boolean; + + /** + * Sets the polygon offset factor. Default is 0. + * @default 0 + */ + polygonOffsetFactor: number; + + /** + * Sets the polygon offset units. Default is 0. + * @default 0 + */ + polygonOffsetUnits: number; + + /** + * Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp". Defaults is null. + * @default null + */ + precision: 'highp' | 'mediump' | 'lowp' | null; + + /** + * Whether to premultiply the alpha (transparency) value. See WebGL / Materials / Transparency for an example of the difference. Default is false. + * @default false + */ + premultipliedAlpha: boolean; + + /** + * Whether to apply dithering to the color to remove the appearance of banding. Default is false. + * @default false + */ + dithering: boolean; + + /** + * Defines which of the face sides will be rendered - front, back or both. + * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. + * @default THREE.FrontSide + */ + side: Side; + + /** + * Defines which of the face sides will cast shadows. Default is *null*. + * If *null*, the value is opposite that of side, above. + * @default null + */ + shadowSide: Side | null; + + /** + * Defines whether this material is tone mapped according to the renderer's toneMapping setting. + * Default is true. + * @default true + */ + toneMapped: boolean; + + /** + * Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. + * When set to true, the extent to which the material is transparent is controlled by setting it's .opacity property. + * Default is false. + * @default false + */ + transparent: boolean; + + /** + * Value is the string 'Material'. This shouldn't be changed, and can be used to find all objects of this type in a scene. + * @default 'Material' + */ + type: string; + + /** + * UUID of this material instance. This gets automatically assigned, so this shouldn't be edited. + */ + uuid: string; + + /** + * Defines whether vertex coloring is used. Default is false. + * @default false + */ + vertexColors: boolean; + + /** + * Defines whether this material is visible. Default is true. + * @default true + */ + visible: boolean; + + /** + * An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned. + * @default {} + */ + userData: any; + + /** + * This starts at 0 and counts how many times .needsUpdate is set to true. + * @default 0 + */ + version: number; + + /** + * Return a new material with the same parameters as this material. + */ + clone(): this; + + /** + * Copy the parameters from the passed material into this material. + * @param material + */ + copy(material: Material): this; + + /** + * This disposes the material. Textures of a material don't get disposed. These needs to be disposed by {@link Texture}. + */ + dispose(): void; + + /** + * An optional callback that is executed immediately before the shader program is compiled. + * This function is called with the shader source code as a parameter. + * Useful for the modification of built-in materials. + * @param shader Source code of the shader + * @param renderer WebGLRenderer Context that is initializing the material + */ + onBeforeCompile(shader: Shader, renderer: WebGLRenderer): void; + + /** + * In case onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile, so three.js can reuse a cached shader or recompile the shader as needed. + */ + customProgramCacheKey(): string; + + /** + * Sets the properties based on the values. + * @param values A container with parameters. + */ + setValues(values: MaterialParameters): void; + + /** + * Convert the material to three.js JSON format. + * @param meta Object containing metadata such as textures or images for the material. + */ + toJSON(meta?: any): any; +} diff --git a/backend/libs/three/materials/Material.js b/backend/libs/three/materials/Material.js new file mode 100644 index 0000000000000000000000000000000000000000..42d3e95b2e45a36956c707aa14710edec49100d8 --- /dev/null +++ b/backend/libs/three/materials/Material.js @@ -0,0 +1,431 @@ +import { EventDispatcher } from '../core/EventDispatcher.js'; +import { + FrontSide, + FlatShading, + NormalBlending, + LessEqualDepth, + AddEquation, + OneMinusSrcAlphaFactor, + SrcAlphaFactor, + AlwaysStencilFunc, + KeepStencilOp, +} from '../constants.js'; +import * as MathUtils from '../math/MathUtils.js'; + +let materialId = 0; + +class Material extends EventDispatcher { + constructor() { + super(); + + Object.defineProperty(this, 'id', { value: materialId++ }); + + this.uuid = MathUtils.generateUUID(); + + this.name = ''; + this.type = 'Material'; + + this.fog = true; + + this.blending = NormalBlending; + this.side = FrontSide; + this.vertexColors = false; + + this.opacity = 1; + this.transparent = false; + + this.blendSrc = SrcAlphaFactor; + this.blendDst = OneMinusSrcAlphaFactor; + this.blendEquation = AddEquation; + this.blendSrcAlpha = null; + this.blendDstAlpha = null; + this.blendEquationAlpha = null; + + this.depthFunc = LessEqualDepth; + this.depthTest = true; + this.depthWrite = true; + + this.stencilWriteMask = 0xff; + this.stencilFunc = AlwaysStencilFunc; + this.stencilRef = 0; + this.stencilFuncMask = 0xff; + this.stencilFail = KeepStencilOp; + this.stencilZFail = KeepStencilOp; + this.stencilZPass = KeepStencilOp; + this.stencilWrite = false; + + this.clippingPlanes = null; + this.clipIntersection = false; + this.clipShadows = false; + + this.shadowSide = null; + + this.colorWrite = true; + this.alphaWrite = true; + + this.precision = null; // override the renderer's default precision for this material + + this.polygonOffset = false; + this.polygonOffsetFactor = 0; + this.polygonOffsetUnits = 0; + + this.dithering = false; + + this.alphaToCoverage = false; + this.premultipliedAlpha = false; + + this.visible = true; + + this.toneMapped = true; + + this.userData = {}; + + this.version = 0; + + this._alphaTest = 0; + } + + get alphaTest() { + return this._alphaTest; + } + + set alphaTest(value) { + if (this._alphaTest > 0 !== value > 0) { + this.version++; + } + + this._alphaTest = value; + } + + onBuild(/* shaderobject, renderer */) {} + + onBeforeRender(/* renderer, scene, camera, geometry, object, group */) {} + + onBeforeCompile(/* shaderobject, renderer */) {} + + customProgramCacheKey() { + return this.onBeforeCompile.toString(); + } + + setValues(values) { + if (values === undefined) return; + + for (const key in values) { + const newValue = values[key]; + + if (newValue === undefined) { + console.warn("THREE.Material: '" + key + "' parameter is undefined."); + continue; + } + + // for backward compatability if shading is set in the constructor + if (key === 'shading') { + console.warn('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.'); + this.flatShading = newValue === FlatShading ? true : false; + continue; + } + + const currentValue = this[key]; + + if (currentValue === undefined) { + console.warn('THREE.' + this.type + ": '" + key + "' is not a property of this material."); + continue; + } + + if (currentValue && currentValue.isColor) { + currentValue.set(newValue); + } else if (currentValue && currentValue.isVector3 && newValue && newValue.isVector3) { + currentValue.copy(newValue); + } else { + this[key] = newValue; + } + } + } + + toJSON(meta) { + const isRoot = meta === undefined || typeof meta === 'string'; + + if (isRoot) { + meta = { + textures: {}, + images: {}, + }; + } + + const data = { + metadata: { + version: 4.5, + type: 'Material', + generator: 'Material.toJSON', + }, + }; + + // standard Material serialization + data.uuid = this.uuid; + data.type = this.type; + + if (this.name !== '') data.name = this.name; + + if (this.color && this.color.isColor) data.color = this.color.getHex(); + + if (this.roughness !== undefined) data.roughness = this.roughness; + if (this.metalness !== undefined) data.metalness = this.metalness; + + if (this.sheen !== undefined) data.sheen = this.sheen; + if (this.sheenColor && this.sheenColor.isColor) data.sheenColor = this.sheenColor.getHex(); + if (this.sheenRoughness !== undefined) data.sheenRoughness = this.sheenRoughness; + if (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex(); + if (this.emissiveIntensity && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity; + + if (this.specular && this.specular.isColor) data.specular = this.specular.getHex(); + if (this.specularIntensity !== undefined) data.specularIntensity = this.specularIntensity; + if (this.specularColor && this.specularColor.isColor) data.specularColor = this.specularColor.getHex(); + if (this.shininess !== undefined) data.shininess = this.shininess; + if (this.clearcoat !== undefined) data.clearcoat = this.clearcoat; + if (this.clearcoatRoughness !== undefined) data.clearcoatRoughness = this.clearcoatRoughness; + + if (this.clearcoatMap && this.clearcoatMap.isTexture) { + data.clearcoatMap = this.clearcoatMap.toJSON(meta).uuid; + } + + if (this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture) { + data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(meta).uuid; + } + + if (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) { + data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid; + data.clearcoatNormalScale = this.clearcoatNormalScale.toArray(); + } + + if (this.map && this.map.isTexture) data.map = this.map.toJSON(meta).uuid; + if (this.matcap && this.matcap.isTexture) data.matcap = this.matcap.toJSON(meta).uuid; + if (this.alphaMap && this.alphaMap.isTexture) data.alphaMap = this.alphaMap.toJSON(meta).uuid; + + if (this.lightMap && this.lightMap.isTexture) { + data.lightMap = this.lightMap.toJSON(meta).uuid; + data.lightMapIntensity = this.lightMapIntensity; + } + + if (this.aoMap && this.aoMap.isTexture) { + data.aoMap = this.aoMap.toJSON(meta).uuid; + data.aoMapIntensity = this.aoMapIntensity; + } + + if (this.bumpMap && this.bumpMap.isTexture) { + data.bumpMap = this.bumpMap.toJSON(meta).uuid; + data.bumpScale = this.bumpScale; + } + + if (this.normalMap && this.normalMap.isTexture) { + data.normalMap = this.normalMap.toJSON(meta).uuid; + data.normalMapType = this.normalMapType; + data.normalScale = this.normalScale.toArray(); + } + + if (this.displacementMap && this.displacementMap.isTexture) { + data.displacementMap = this.displacementMap.toJSON(meta).uuid; + data.displacementScale = this.displacementScale; + data.displacementBias = this.displacementBias; + } + + if (this.roughnessMap && this.roughnessMap.isTexture) data.roughnessMap = this.roughnessMap.toJSON(meta).uuid; + if (this.metalnessMap && this.metalnessMap.isTexture) data.metalnessMap = this.metalnessMap.toJSON(meta).uuid; + + if (this.emissiveMap && this.emissiveMap.isTexture) data.emissiveMap = this.emissiveMap.toJSON(meta).uuid; + if (this.specularMap && this.specularMap.isTexture) data.specularMap = this.specularMap.toJSON(meta).uuid; + if (this.specularIntensityMap && this.specularIntensityMap.isTexture) data.specularIntensityMap = this.specularIntensityMap.toJSON(meta).uuid; + if (this.specularColorMap && this.specularColorMap.isTexture) data.specularColorMap = this.specularColorMap.toJSON(meta).uuid; + + if (this.envMap && this.envMap.isTexture) { + data.envMap = this.envMap.toJSON(meta).uuid; + + if (this.combine !== undefined) data.combine = this.combine; + } + + if (this.envMapIntensity !== undefined) data.envMapIntensity = this.envMapIntensity; + if (this.reflectivity !== undefined) data.reflectivity = this.reflectivity; + if (this.refractionRatio !== undefined) data.refractionRatio = this.refractionRatio; + + if (this.gradientMap && this.gradientMap.isTexture) { + data.gradientMap = this.gradientMap.toJSON(meta).uuid; + } + + if (this.transmission !== undefined) data.transmission = this.transmission; + if (this.transmissionMap && this.transmissionMap.isTexture) data.transmissionMap = this.transmissionMap.toJSON(meta).uuid; + if (this.thickness !== undefined) data.thickness = this.thickness; + if (this.thicknessMap && this.thicknessMap.isTexture) data.thicknessMap = this.thicknessMap.toJSON(meta).uuid; + if (this.attenuationDistance !== undefined) data.attenuationDistance = this.attenuationDistance; + if (this.attenuationColor !== undefined) data.attenuationColor = this.attenuationColor.getHex(); + + if (this.size !== undefined) data.size = this.size; + if (this.shadowSide !== null) data.shadowSide = this.shadowSide; + if (this.sizeAttenuation !== undefined) data.sizeAttenuation = this.sizeAttenuation; + + if (this.blending !== NormalBlending) data.blending = this.blending; + if (this.side !== FrontSide) data.side = this.side; + if (this.vertexColors) data.vertexColors = true; + + if (this.opacity < 1) data.opacity = this.opacity; + if (this.transparent === true) data.transparent = this.transparent; + + data.depthFunc = this.depthFunc; + data.depthTest = this.depthTest; + data.depthWrite = this.depthWrite; + data.colorWrite = this.colorWrite; + data.alphaWrite = this.alphaWrite; + + data.stencilWrite = this.stencilWrite; + data.stencilWriteMask = this.stencilWriteMask; + data.stencilFunc = this.stencilFunc; + data.stencilRef = this.stencilRef; + data.stencilFuncMask = this.stencilFuncMask; + data.stencilFail = this.stencilFail; + data.stencilZFail = this.stencilZFail; + data.stencilZPass = this.stencilZPass; + + // rotation (SpriteMaterial) + if (this.rotation && this.rotation !== 0) data.rotation = this.rotation; + + if (this.polygonOffset === true) data.polygonOffset = true; + if (this.polygonOffsetFactor !== 0) data.polygonOffsetFactor = this.polygonOffsetFactor; + if (this.polygonOffsetUnits !== 0) data.polygonOffsetUnits = this.polygonOffsetUnits; + + if (this.linewidth && this.linewidth !== 1) data.linewidth = this.linewidth; + if (this.dashSize !== undefined) data.dashSize = this.dashSize; + if (this.gapSize !== undefined) data.gapSize = this.gapSize; + if (this.scale !== undefined) data.scale = this.scale; + + if (this.dithering === true) data.dithering = true; + + if (this.alphaTest > 0) data.alphaTest = this.alphaTest; + if (this.alphaToCoverage === true) data.alphaToCoverage = this.alphaToCoverage; + if (this.premultipliedAlpha === true) data.premultipliedAlpha = this.premultipliedAlpha; + + if (this.wireframe === true) data.wireframe = this.wireframe; + if (this.wireframeLinewidth > 1) data.wireframeLinewidth = this.wireframeLinewidth; + if (this.wireframeLinecap !== 'round') data.wireframeLinecap = this.wireframeLinecap; + if (this.wireframeLinejoin !== 'round') data.wireframeLinejoin = this.wireframeLinejoin; + + if (this.flatShading === true) data.flatShading = this.flatShading; + + if (this.visible === false) data.visible = false; + + if (this.toneMapped === false) data.toneMapped = false; + + if (JSON.stringify(this.userData) !== '{}') data.userData = this.userData; + + // TODO: Copied from Object3D.toJSON + + function extractFromCache(cache) { + const values = []; + + for (const key in cache) { + const data = cache[key]; + delete data.metadata; + values.push(data); + } + + return values; + } + + if (isRoot) { + const textures = extractFromCache(meta.textures); + const images = extractFromCache(meta.images); + + if (textures.length > 0) data.textures = textures; + if (images.length > 0) data.images = images; + } + + return data; + } + + clone() { + return new this.constructor().copy(this); + } + + copy(source) { + this.name = source.name; + + this.fog = source.fog; + + this.blending = source.blending; + this.side = source.side; + this.vertexColors = source.vertexColors; + + this.opacity = source.opacity; + this.transparent = source.transparent; + + this.blendSrc = source.blendSrc; + this.blendDst = source.blendDst; + this.blendEquation = source.blendEquation; + this.blendSrcAlpha = source.blendSrcAlpha; + this.blendDstAlpha = source.blendDstAlpha; + this.blendEquationAlpha = source.blendEquationAlpha; + + this.depthFunc = source.depthFunc; + this.depthTest = source.depthTest; + this.depthWrite = source.depthWrite; + + this.stencilWriteMask = source.stencilWriteMask; + this.stencilFunc = source.stencilFunc; + this.stencilRef = source.stencilRef; + this.stencilFuncMask = source.stencilFuncMask; + this.stencilFail = source.stencilFail; + this.stencilZFail = source.stencilZFail; + this.stencilZPass = source.stencilZPass; + this.stencilWrite = source.stencilWrite; + + const srcPlanes = source.clippingPlanes; + let dstPlanes = null; + + if (srcPlanes !== null) { + const n = srcPlanes.length; + dstPlanes = new Array(n); + + for (let i = 0; i !== n; ++i) { + dstPlanes[i] = srcPlanes[i].clone(); + } + } + + this.clippingPlanes = dstPlanes; + this.clipIntersection = source.clipIntersection; + this.clipShadows = source.clipShadows; + + this.shadowSide = source.shadowSide; + + this.colorWrite = source.colorWrite; + this.alphaWrite = source.alphaWrite; + + this.precision = source.precision; + + this.polygonOffset = source.polygonOffset; + this.polygonOffsetFactor = source.polygonOffsetFactor; + this.polygonOffsetUnits = source.polygonOffsetUnits; + + this.dithering = source.dithering; + + this.alphaTest = source.alphaTest; + this.alphaToCoverage = source.alphaToCoverage; + this.premultipliedAlpha = source.premultipliedAlpha; + + this.visible = source.visible; + + this.toneMapped = source.toneMapped; + + this.userData = JSON.parse(JSON.stringify(source.userData)); + + return this; + } + + dispose() { + this.dispatchEvent({ type: 'dispose' }); + } + + set needsUpdate(value) { + if (value === true) this.version++; + } +} + +Material.prototype.isMaterial = true; + +export { Material }; diff --git a/backend/libs/three/materials/Materials.d.ts b/backend/libs/three/materials/Materials.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ff7faa9d47a5fa6b4742812a335495f025f6327e --- /dev/null +++ b/backend/libs/three/materials/Materials.d.ts @@ -0,0 +1,18 @@ +export * from './ShadowMaterial'; +export * from './SpriteMaterial'; +export * from './RawShaderMaterial'; +export * from './ShaderMaterial'; +export * from './PointsMaterial'; +export * from './MeshPhysicalMaterial'; +export * from './MeshStandardMaterial'; +export * from './MeshPhongMaterial'; +export * from './MeshToonMaterial'; +export * from './MeshNormalMaterial'; +export * from './MeshLambertMaterial'; +export * from './MeshDepthMaterial'; +export * from './MeshDistanceMaterial'; +export * from './MeshBasicMaterial'; +export * from './MeshMatcapMaterial'; +export * from './LineDashedMaterial'; +export * from './LineBasicMaterial'; +export * from './Material'; diff --git a/backend/libs/three/materials/Materials.js b/backend/libs/three/materials/Materials.js new file mode 100644 index 0000000000000000000000000000000000000000..28844e95884fc52319624fb0d582e6ea6b2aa73e --- /dev/null +++ b/backend/libs/three/materials/Materials.js @@ -0,0 +1,18 @@ +export { ShadowMaterial } from './ShadowMaterial.js'; +export { SpriteMaterial } from './SpriteMaterial.js'; +export { RawShaderMaterial } from './RawShaderMaterial.js'; +export { ShaderMaterial } from './ShaderMaterial.js'; +export { PointsMaterial } from './PointsMaterial.js'; +export { MeshPhysicalMaterial } from './MeshPhysicalMaterial.js'; +export { MeshStandardMaterial } from './MeshStandardMaterial.js'; +export { MeshPhongMaterial } from './MeshPhongMaterial.js'; +export { MeshToonMaterial } from './MeshToonMaterial.js'; +export { MeshNormalMaterial } from './MeshNormalMaterial.js'; +export { MeshLambertMaterial } from './MeshLambertMaterial.js'; +export { MeshDepthMaterial } from './MeshDepthMaterial.js'; +export { MeshDistanceMaterial } from './MeshDistanceMaterial.js'; +export { MeshBasicMaterial } from './MeshBasicMaterial.js'; +export { MeshMatcapMaterial } from './MeshMatcapMaterial.js'; +export { LineDashedMaterial } from './LineDashedMaterial.js'; +export { LineBasicMaterial } from './LineBasicMaterial.js'; +export { Material } from './Material.js'; diff --git a/backend/libs/three/materials/MeshBasicMaterial.d.ts b/backend/libs/three/materials/MeshBasicMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..84f5e9729b51559eefbda4ebfecab7292bc918ba --- /dev/null +++ b/backend/libs/three/materials/MeshBasicMaterial.d.ts @@ -0,0 +1,118 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; +import { Combine } from '../constants'; +import { ColorRepresentation } from '../utils'; +/** + * parameters is an object with one or more properties defining the material's appearance. + */ +export interface MeshBasicMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + opacity?: number | undefined; + map?: Texture | null | undefined; + lightMap?: Texture | null; + lightMapIntensity?: number | undefined; + aoMap?: Texture | null | undefined; + aoMapIntensity?: number | undefined; + specularMap?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + envMap?: Texture | null | undefined; + combine?: Combine | undefined; + reflectivity?: number | undefined; + refractionRatio?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + wireframeLinecap?: string | undefined; + wireframeLinejoin?: string | undefined; +} + +export class MeshBasicMaterial extends Material { + constructor(parameters?: MeshBasicMaterialParameters); + + /** + * @default 'MeshBasicMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + lightMap: Texture | null; + + /** + * @default 1 + */ + lightMapIntensity: number; + + /** + * @default null + */ + aoMap: Texture | null; + + /** + * @default 1 + */ + aoMapIntensity: number; + + /** + * @default null + */ + specularMap: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default null + */ + envMap: Texture | null; + + /** + * @default THREE.MultiplyOperation + */ + combine: Combine; + + /** + * @default 1 + */ + reflectivity: number; + + /** + * @default 0.98 + */ + refractionRatio: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default 'round' + */ + wireframeLinecap: string; + + /** + * @default 'round' + */ + wireframeLinejoin: string; + + setValues(parameters: MeshBasicMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshBasicMaterial.js b/backend/libs/three/materials/MeshBasicMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..83edeef181b8f40e1afc6d71ff46d915bb61bcc3 --- /dev/null +++ b/backend/libs/three/materials/MeshBasicMaterial.js @@ -0,0 +1,100 @@ +import { Material } from './Material.js'; +import { MultiplyOperation } from '../constants.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + * + * depthTest: , + * depthWrite: , + * + * wireframe: , + * wireframeLinewidth: , + * } + */ + +class MeshBasicMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshBasicMaterial'; + + this.color = new Color(0xffffff); // emissive + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + } +} + +MeshBasicMaterial.prototype.isMeshBasicMaterial = true; + +export { MeshBasicMaterial }; diff --git a/backend/libs/three/materials/MeshDepthMaterial.d.ts b/backend/libs/three/materials/MeshDepthMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..851fde9a3e3059f1ebd32e91bc400cbb4b2b7e77 --- /dev/null +++ b/backend/libs/three/materials/MeshDepthMaterial.d.ts @@ -0,0 +1,70 @@ +import { DepthPackingStrategies } from '../constants'; +import { MaterialParameters, Material } from './Material'; +import { Texture } from './../textures/Texture'; + +export interface MeshDepthMaterialParameters extends MaterialParameters { + map?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + depthPacking?: DepthPackingStrategies | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; +} + +export class MeshDepthMaterial extends Material { + constructor(parameters?: MeshDepthMaterialParameters); + + /** + * @default 'MeshDepthMaterial' + */ + type: string; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default THREE.BasicDepthPacking + */ + depthPacking: DepthPackingStrategies; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default false + */ + fog: boolean; + + setValues(parameters: MeshDepthMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshDepthMaterial.js b/backend/libs/three/materials/MeshDepthMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..d46e1df43fc7699702bf0a817fc6b4891cfe3548 --- /dev/null +++ b/backend/libs/three/materials/MeshDepthMaterial.js @@ -0,0 +1,68 @@ +import { Material } from './Material.js'; +import { BasicDepthPacking } from '../constants.js'; + +/** + * parameters = { + * + * opacity: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * wireframe: , + * wireframeLinewidth: + * } + */ + +class MeshDepthMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshDepthMaterial'; + + this.depthPacking = BasicDepthPacking; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.depthPacking = source.depthPacking; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + return this; + } +} + +MeshDepthMaterial.prototype.isMeshDepthMaterial = true; + +export { MeshDepthMaterial }; diff --git a/backend/libs/three/materials/MeshDistanceMaterial.d.ts b/backend/libs/three/materials/MeshDistanceMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0ad50eace5842b10d095d0757d163edf7c93549d --- /dev/null +++ b/backend/libs/three/materials/MeshDistanceMaterial.d.ts @@ -0,0 +1,70 @@ +import { MaterialParameters, Material } from './Material'; +import { Vector3 } from './../math/Vector3'; +import { Texture } from './../textures/Texture'; + +export interface MeshDistanceMaterialParameters extends MaterialParameters { + map?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + farDistance?: number | undefined; + nearDistance?: number | undefined; + referencePosition?: Vector3 | undefined; +} + +export class MeshDistanceMaterial extends Material { + constructor(parameters?: MeshDistanceMaterialParameters); + + /** + * @default 'MeshDistanceMaterial' + */ + type: string; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default 1000 + */ + farDistance: number; + + /** + * @default 1 + */ + nearDistance: number; + + /** + * @default new THREE.Vector3() + */ + referencePosition: Vector3; + + /** + * @default false + */ + fog: boolean; + + setValues(parameters: MeshDistanceMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshDistanceMaterial.js b/backend/libs/three/materials/MeshDistanceMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..d70f557ca17be51464476ea5768028f65ef40f4f --- /dev/null +++ b/backend/libs/three/materials/MeshDistanceMaterial.js @@ -0,0 +1,66 @@ +import { Material } from './Material.js'; +import { Vector3 } from '../math/Vector3.js'; + +/** + * parameters = { + * + * referencePosition: , + * nearDistance: , + * farDistance: , + * + * map: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: + * + * } + */ + +class MeshDistanceMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshDistanceMaterial'; + + this.referencePosition = new Vector3(); + this.nearDistance = 1; + this.farDistance = 1000; + + this.map = null; + + this.alphaMap = null; + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.fog = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.referencePosition.copy(source.referencePosition); + this.nearDistance = source.nearDistance; + this.farDistance = source.farDistance; + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + return this; + } +} + +MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true; + +export { MeshDistanceMaterial }; diff --git a/backend/libs/three/materials/MeshLambertMaterial.d.ts b/backend/libs/three/materials/MeshLambertMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4f03406116917226832ad84fc4892b20209d2254 --- /dev/null +++ b/backend/libs/three/materials/MeshLambertMaterial.d.ts @@ -0,0 +1,133 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; +import { Combine } from '../constants'; +import { ColorRepresentation } from '../utils'; + +export interface MeshLambertMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + emissive?: ColorRepresentation | undefined; + emissiveIntensity?: number | undefined; + emissiveMap?: Texture | null | undefined; + map?: Texture | null | undefined; + lightMap?: Texture | null | undefined; + lightMapIntensity?: number | undefined; + aoMap?: Texture | null | undefined; + aoMapIntensity?: number | undefined; + specularMap?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + envMap?: Texture | null | undefined; + combine?: Combine | undefined; + reflectivity?: number | undefined; + refractionRatio?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + wireframeLinecap?: string | undefined; + wireframeLinejoin?: string | undefined; +} + +export class MeshLambertMaterial extends Material { + constructor(parameters?: MeshLambertMaterialParameters); + + /** + * @default 'MeshLambertMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default new THREE.Color( 0x000000 ) + */ + emissive: Color; + + /** + * @default 1 + */ + emissiveIntensity: number; + + /** + * @default null + */ + emissiveMap: Texture | null; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + lightMap: Texture | null; + + /** + * @default 1 + */ + lightMapIntensity: number; + + /** + * @default null + */ + aoMap: Texture | null; + + /** + * @default 1 + */ + aoMapIntensity: number; + + /** + * @default null + */ + specularMap: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default null + */ + envMap: Texture | null; + + /** + * @default THREE.MultiplyOperation + */ + combine: Combine; + + /** + * @default 1 + */ + reflectivity: number; + + /** + * @default 0.98 + */ + refractionRatio: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default 'round' + */ + wireframeLinecap: string; + + /** + * @default 'round' + */ + wireframeLinejoin: string; + + setValues(parameters: MeshLambertMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshLambertMaterial.js b/backend/libs/three/materials/MeshLambertMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..99512a8f150247381cd1124937eb6c8c5006e08e --- /dev/null +++ b/backend/libs/three/materials/MeshLambertMaterial.js @@ -0,0 +1,111 @@ +import { Material } from './Material.js'; +import { MultiplyOperation } from '../constants.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.Multiply, + * reflectivity: , + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * } + */ + +class MeshLambertMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshLambertMaterial'; + + this.color = new Color(0xffffff); // diffuse + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color(0x000000); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy(source.emissive); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + } +} + +MeshLambertMaterial.prototype.isMeshLambertMaterial = true; + +export { MeshLambertMaterial }; diff --git a/backend/libs/three/materials/MeshMatcapMaterial.d.ts b/backend/libs/three/materials/MeshMatcapMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e8b9b94bdb61fd23821d60910e622f5c6e085b92 --- /dev/null +++ b/backend/libs/three/materials/MeshMatcapMaterial.d.ts @@ -0,0 +1,105 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; +import { NormalMapTypes } from '../constants'; +import { ColorRepresentation } from '../utils'; + +export interface MeshMatcapMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + matcap?: Texture | null | undefined; + map?: Texture | null | undefined; + bumpMap?: Texture | null | undefined; + bumpScale?: number | undefined; + normalMap?: Texture | null | undefined; + normalMapType?: NormalMapTypes | undefined; + normalScale?: Vector2 | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + alphaMap?: Texture | null | undefined; + + flatShading?: boolean | undefined; +} + +export class MeshMatcapMaterial extends Material { + constructor(parameters?: MeshMatcapMaterialParameters); + + /** + * @default 'MeshMatcapMaterial' + */ + type: string; + + /** + * @default { 'MATCAP': '' } + */ + defines: { [key: string]: any }; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default null + */ + matcap: Texture | null; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + bumpMap: Texture | null; + + /** + * @default 1 + */ + bumpScale: number; + + /** + * @default null + */ + normalMap: Texture | null; + + /** + * @default THREE.TangentSpaceNormalMap + */ + normalMapType: NormalMapTypes; + + /** + * @default new Vector2( 1, 1 ) + */ + normalScale: Vector2; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * Define whether the material is rendered with flat shading. Default is false. + * @default false + */ + flatShading: boolean; + + setValues(parameters: MeshMatcapMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshMatcapMaterial.js b/backend/libs/three/materials/MeshMatcapMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..4c343a511de0e0acfb5dce11b4130f01a6d2f408 --- /dev/null +++ b/backend/libs/three/materials/MeshMatcapMaterial.js @@ -0,0 +1,96 @@ +import { TangentSpaceNormalMap } from '../constants.js'; +import { Material } from './Material.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * opacity: , + * + * matcap: new THREE.Texture( ), + * + * map: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * alphaMap: new THREE.Texture( ), + * + * flatShading: + * } + */ + +class MeshMatcapMaterial extends Material { + constructor(parameters) { + super(); + + this.defines = { MATCAP: '' }; + + this.type = 'MeshMatcapMaterial'; + + this.color = new Color(0xffffff); // diffuse + + this.matcap = null; + + this.map = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2(1, 1); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.alphaMap = null; + + this.flatShading = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.defines = { MATCAP: '' }; + + this.color.copy(source.color); + + this.matcap = source.matcap; + + this.map = source.map; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy(source.normalScale); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.alphaMap = source.alphaMap; + + this.flatShading = source.flatShading; + + return this; + } +} + +MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true; + +export { MeshMatcapMaterial }; diff --git a/backend/libs/three/materials/MeshNormalMaterial.d.ts b/backend/libs/three/materials/MeshNormalMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..2c24d2371645b8eea37d4ec22450de11c39084b7 --- /dev/null +++ b/backend/libs/three/materials/MeshNormalMaterial.d.ts @@ -0,0 +1,86 @@ +import { MaterialParameters, Material } from './Material'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { NormalMapTypes } from '../constants'; + +export interface MeshNormalMaterialParameters extends MaterialParameters { + bumpMap?: Texture | null | undefined; + bumpScale?: number | undefined; + normalMap?: Texture | null | undefined; + normalMapType?: NormalMapTypes | undefined; + normalScale?: Vector2 | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + + flatShading?: boolean | undefined; +} + +export class MeshNormalMaterial extends Material { + constructor(parameters?: MeshNormalMaterialParameters); + + /** + * @default 'MeshNormalMaterial' + */ + type: string; + + /** + * @default null + */ + bumpMap: Texture | null; + + /** + * @default 1 + */ + bumpScale: number; + + /** + * @default null + */ + normalMap: Texture | null; + + /** + * @default THREE.TangentSpaceNormalMap + */ + normalMapType: NormalMapTypes; + + /** + * @default new THREE.Vector2( 1, 1 ) + */ + normalScale: Vector2; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * Define whether the material is rendered with flat shading. Default is false. + * @default false + */ + flatShading: boolean; + + setValues(parameters: MeshNormalMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshNormalMaterial.js b/backend/libs/three/materials/MeshNormalMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..d29c60687bb50101f313ae1b3374e7f1b1f730e4 --- /dev/null +++ b/backend/libs/three/materials/MeshNormalMaterial.js @@ -0,0 +1,79 @@ +import { TangentSpaceNormalMap } from '../constants.js'; +import { Material } from './Material.js'; +import { Vector2 } from '../math/Vector2.js'; + +/** + * parameters = { + * opacity: , + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * wireframe: , + * wireframeLinewidth: + * + * flatShading: + * } + */ + +class MeshNormalMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshNormalMaterial'; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2(1, 1); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; + + this.flatShading = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy(source.normalScale); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + this.flatShading = source.flatShading; + + return this; + } +} + +MeshNormalMaterial.prototype.isMeshNormalMaterial = true; + +export { MeshNormalMaterial }; diff --git a/backend/libs/three/materials/MeshPhongMaterial.d.ts b/backend/libs/three/materials/MeshPhongMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6ab8105c0463ad9f7f4a601f53cf2c11ac48cd93 --- /dev/null +++ b/backend/libs/three/materials/MeshPhongMaterial.d.ts @@ -0,0 +1,209 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; +import { Combine, NormalMapTypes } from '../constants'; +import { ColorRepresentation } from '../utils'; + +export interface MeshPhongMaterialParameters extends MaterialParameters { + /** geometry color in hexadecimal. Default is 0xffffff. */ + color?: ColorRepresentation | undefined; + specular?: ColorRepresentation | undefined; + shininess?: number | undefined; + opacity?: number | undefined; + map?: Texture | null | undefined; + lightMap?: Texture | null | undefined; + lightMapIntensity?: number | undefined; + aoMap?: Texture | null | undefined; + aoMapIntensity?: number | undefined; + emissive?: ColorRepresentation | undefined; + emissiveIntensity?: number | undefined; + emissiveMap?: Texture | null | undefined; + bumpMap?: Texture | null | undefined; + bumpScale?: number | undefined; + normalMap?: Texture | null | undefined; + normalMapType?: NormalMapTypes | undefined; + normalScale?: Vector2 | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + specularMap?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + envMap?: Texture | null | undefined; + combine?: Combine | undefined; + reflectivity?: number | undefined; + refractionRatio?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + wireframeLinecap?: string | undefined; + wireframeLinejoin?: string | undefined; + + flatShading?: boolean | undefined; +} + +export class MeshPhongMaterial extends Material { + constructor(parameters?: MeshPhongMaterialParameters); + + /** + * @default 'MeshNormalMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default new THREE.Color( 0x111111 ) + */ + specular: Color; + + /** + * @default 30 + */ + shininess: number; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + lightMap: Texture | null; + + /** + * @default null + */ + lightMapIntensity: number; + + /** + * @default null + */ + aoMap: Texture | null; + + /** + * @default null + */ + aoMapIntensity: number; + + /** + * @default new THREE.Color( 0x000000 ) + */ + emissive: Color; + + /** + * @default 1 + */ + emissiveIntensity: number; + + /** + * @default null + */ + emissiveMap: Texture | null; + + /** + * @default null + */ + bumpMap: Texture | null; + + /** + * @default 1 + */ + bumpScale: number; + + /** + * @default null + */ + normalMap: Texture | null; + + /** + * @default THREE.TangentSpaceNormalMap + */ + normalMapType: NormalMapTypes; + + /** + * @default new Vector2( 1, 1 ) + */ + normalScale: Vector2; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default null + */ + specularMap: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default null + */ + envMap: Texture | null; + + /** + * @default THREE.MultiplyOperation + */ + combine: Combine; + + /** + * @default 1 + */ + reflectivity: number; + + /** + * @default 0.98 + */ + refractionRatio: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default 'round' + */ + wireframeLinecap: string; + + /** + * @default 'round' + */ + wireframeLinejoin: string; + + /** + * Define whether the material is rendered with flat shading. Default is false. + * @default false + */ + flatShading: boolean; + + /** + * @deprecated Use {@link MeshStandardMaterial THREE.MeshStandardMaterial} instead. + */ + metal: boolean; + + setValues(parameters: MeshPhongMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshPhongMaterial.js b/backend/libs/three/materials/MeshPhongMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..fb843326b812f84085890c1b585deeab783eba3a --- /dev/null +++ b/backend/libs/three/materials/MeshPhongMaterial.js @@ -0,0 +1,156 @@ +import { MultiplyOperation, TangentSpaceNormalMap } from '../constants.js'; +import { Material } from './Material.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * specular: , + * shininess: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * specularMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * combine: THREE.MultiplyOperation, + * reflectivity: , + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * flatShading: + * } + */ + +class MeshPhongMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'MeshPhongMaterial'; + + this.color = new Color(0xffffff); // diffuse + this.specular = new Color(0x111111); + this.shininess = 30; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color(0x000000); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2(1, 1); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.specularMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.combine = MultiplyOperation; + this.reflectivity = 1; + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.flatShading = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + this.specular.copy(source.specular); + this.shininess = source.shininess; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy(source.emissive); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy(source.normalScale); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.specularMap = source.specularMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.combine = source.combine; + this.reflectivity = source.reflectivity; + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.flatShading = source.flatShading; + + return this; + } +} + +MeshPhongMaterial.prototype.isMeshPhongMaterial = true; + +export { MeshPhongMaterial }; diff --git a/backend/libs/three/materials/MeshPhysicalMaterial.d.ts b/backend/libs/three/materials/MeshPhysicalMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d4950cdb1f109276552c5c0a8e8efe0b5cfaa40d --- /dev/null +++ b/backend/libs/three/materials/MeshPhysicalMaterial.d.ts @@ -0,0 +1,159 @@ +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MeshStandardMaterialParameters, MeshStandardMaterial } from './MeshStandardMaterial'; +import { Color } from './../math/Color'; + +export interface MeshPhysicalMaterialParameters extends MeshStandardMaterialParameters { + clearcoat?: number | undefined; + clearcoatMap?: Texture | null | undefined; + clearcoatRoughness?: number | undefined; + clearcoatRoughnessMap?: Texture | null | undefined; + clearcoatNormalScale?: Vector2 | undefined; + clearcoatNormalMap?: Texture | null | undefined; + + reflectivity?: number | undefined; + ior?: number | undefined; + + sheen?: number | undefined; + sheenColor?: Color | undefined; + sheenRoughness?: number | undefined; + + transmission?: number | undefined; + transmissionMap?: Texture | null | undefined; + attenuationDistance?: number | undefined; + attenuationColor?: Color | undefined; + + specularIntensity?: number | undefined; + specularColor?: Color | undefined; + specularIntensityMap?: Texture | null | undefined; + specularColorMap?: Texture | null | undefined; +} + +export class MeshPhysicalMaterial extends MeshStandardMaterial { + constructor(parameters?: MeshPhysicalMaterialParameters); + + /** + * @default 'MeshPhysicalMaterial' + */ + type: string; + + /** + * @default { 'STANDARD': '', 'PHYSICAL': '' } + */ + defines: { [key: string]: any }; + + /** + * @default 0 + */ + clearcoat: number; + + /** + * @default null + */ + clearcoatMap: Texture | null; + + /** + * @default 0 + */ + clearcoatRoughness: number; + + /** + * @default null + */ + clearcoatRoughnessMap: Texture | null; + + /** + * @default new THREE.Vector2( 1, 1 ) + */ + clearcoatNormalScale: Vector2; + + /** + * @default null + */ + clearcoatNormalMap: Texture | null; + + /** + * @default 0.5 + */ + reflectivity: number; + + /** + * @default 1.5 + */ + ior: number; + + /** + * @default 0.0 + */ + sheen: number; + + /** + * @default Color( 0x000000 ) + */ + sheenColor: Color; + + /** + * @default null + */ + sheenColorMap: Texture | null; + + /** + * @default 1.0 + */ + sheenRoughness: number; + + /** + * @default null + */ + sheenRoughnessMap: Texture | null; + + /** + * @default 0 + */ + transmission: number; + + /** + * @default null + */ + transmissionMap: Texture | null; + + /** + * @default 0.01 + */ + thickness: number; + + /** + * @default null + */ + thicknessMap: Texture | null; + + /** + * @default 0.0 + */ + attenuationDistance: number; + + /** + * @default Color( 1, 1, 1 ) + */ + attenuationColor: Color; + + /** + * @default 1.0 + */ + specularIntensity: number; + + /** + * @default Color(1, 1, 1) + */ + specularColor: Color; + + /** + * @default null + */ + specularIntensityMap: Texture | null; + + /** + * @default null + */ + specularColorMap: Texture | null; +} diff --git a/backend/libs/three/materials/MeshPhysicalMaterial.js b/backend/libs/three/materials/MeshPhysicalMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..b4945288faa057b833f5478991743a2ce118a7ac --- /dev/null +++ b/backend/libs/three/materials/MeshPhysicalMaterial.js @@ -0,0 +1,169 @@ +import { Vector2 } from '../math/Vector2.js'; +import { MeshStandardMaterial } from './MeshStandardMaterial.js'; +import { Color } from '../math/Color.js'; +import * as MathUtils from '../math/MathUtils.js'; + +/** + * parameters = { + * clearcoat: , + * clearcoatMap: new THREE.Texture( ), + * clearcoatRoughness: , + * clearcoatRoughnessMap: new THREE.Texture( ), + * clearcoatNormalScale: , + * clearcoatNormalMap: new THREE.Texture( ), + * + * ior: , + * reflectivity: , + * + * sheen: , + * sheenColor: , + * sheenColorMap: new THREE.Texture( ), + * sheenRoughness: , + * sheenRoughnessMap: new THREE.Texture( ), + * + * transmission: , + * transmissionMap: new THREE.Texture( ), + * + * thickness: , + * thicknessMap: new THREE.Texture( ), + * attenuationDistance: , + * attenuationColor: , + * + * specularIntensity: , + * specularIntensityMap: new THREE.Texture( ), + * specularColor: , + * specularColorMap: new THREE.Texture( ) + * } + */ + +class MeshPhysicalMaterial extends MeshStandardMaterial { + constructor(parameters) { + super(); + + this.defines = { + STANDARD: '', + PHYSICAL: '', + }; + + this.type = 'MeshPhysicalMaterial'; + + this.clearcoatMap = null; + this.clearcoatRoughness = 0.0; + this.clearcoatRoughnessMap = null; + this.clearcoatNormalScale = new Vector2(1, 1); + this.clearcoatNormalMap = null; + + this.ior = 1.5; + + Object.defineProperty(this, 'reflectivity', { + get: function () { + return MathUtils.clamp((2.5 * (this.ior - 1)) / (this.ior + 1), 0, 1); + }, + set: function (reflectivity) { + this.ior = (1 + 0.4 * reflectivity) / (1 - 0.4 * reflectivity); + }, + }); + + this.sheenColor = new Color(0x000000); + this.sheenColorMap = null; + this.sheenRoughness = 1.0; + this.sheenRoughnessMap = null; + + this.transmissionMap = null; + + this.thickness = 0; + this.thicknessMap = null; + this.attenuationDistance = 0.0; + this.attenuationColor = new Color(1, 1, 1); + + this.specularIntensity = 1.0; + this.specularIntensityMap = null; + this.specularColor = new Color(1, 1, 1); + this.specularColorMap = null; + + this._sheen = 0.0; + this._clearcoat = 0; + this._transmission = 0; + + this.setValues(parameters); + } + + get sheen() { + return this._sheen; + } + + set sheen(value) { + if (this._sheen > 0 !== value > 0) { + this.version++; + } + + this._sheen = value; + } + + get clearcoat() { + return this._clearcoat; + } + + set clearcoat(value) { + if (this._clearcoat > 0 !== value > 0) { + this.version++; + } + + this._clearcoat = value; + } + + get transmission() { + return this._transmission; + } + + set transmission(value) { + if (this._transmission > 0 !== value > 0) { + this.version++; + } + + this._transmission = value; + } + + copy(source) { + super.copy(source); + + this.defines = { + STANDARD: '', + PHYSICAL: '', + }; + + this.clearcoat = source.clearcoat; + this.clearcoatMap = source.clearcoatMap; + this.clearcoatRoughness = source.clearcoatRoughness; + this.clearcoatRoughnessMap = source.clearcoatRoughnessMap; + this.clearcoatNormalMap = source.clearcoatNormalMap; + this.clearcoatNormalScale.copy(source.clearcoatNormalScale); + + this.ior = source.ior; + + this.sheen = source.sheen; + this.sheenColor.copy(source.sheenColor); + this.sheenColorMap = source.sheenColorMap; + this.sheenRoughness = source.sheenRoughness; + this.sheenRoughnessMap = source.sheenRoughnessMap; + + this.transmission = source.transmission; + this.transmissionMap = source.transmissionMap; + + this.thickness = source.thickness; + this.thicknessMap = source.thicknessMap; + this.attenuationDistance = source.attenuationDistance; + this.attenuationColor.copy(source.attenuationColor); + + this.specularIntensity = source.specularIntensity; + this.specularIntensityMap = source.specularIntensityMap; + this.specularColor.copy(source.specularColor); + this.specularColorMap = source.specularColorMap; + + return this; + } +} + +MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true; + +export { MeshPhysicalMaterial }; diff --git a/backend/libs/three/materials/MeshStandardMaterial.d.ts b/backend/libs/three/materials/MeshStandardMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..56e3c77515f656a6f492ecdad9da2925d618adcd --- /dev/null +++ b/backend/libs/three/materials/MeshStandardMaterial.d.ts @@ -0,0 +1,201 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; +import { NormalMapTypes } from '../constants'; +import { ColorRepresentation } from '../utils'; + +export interface MeshStandardMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + roughness?: number | undefined; + metalness?: number | undefined; + map?: Texture | null | undefined; + lightMap?: Texture | null | undefined; + lightMapIntensity?: number | undefined; + aoMap?: Texture | null | undefined; + aoMapIntensity?: number | undefined; + emissive?: ColorRepresentation | undefined; + emissiveIntensity?: number | undefined; + emissiveMap?: Texture | null | undefined; + bumpMap?: Texture | null | undefined; + bumpScale?: number | undefined; + normalMap?: Texture | null | undefined; + normalMapType?: NormalMapTypes | undefined; + normalScale?: Vector2 | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + roughnessMap?: Texture | null | undefined; + metalnessMap?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + envMap?: Texture | null | undefined; + envMapIntensity?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + + flatShading?: boolean | undefined; +} + +export class MeshStandardMaterial extends Material { + constructor(parameters?: MeshStandardMaterialParameters); + + /** + * @default 'MeshStandardMaterial' + */ + type: string; + + /** + * @default { 'STANDARD': '' } + */ + defines: { [key: string]: any }; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default 1 + */ + roughness: number; + + /** + * @default 0 + */ + metalness: number; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + lightMap: Texture | null; + + /** + * @default 1 + */ + lightMapIntensity: number; + + /** + * @default null + */ + aoMap: Texture | null; + + /** + * @default 1 + */ + aoMapIntensity: number; + + /** + * @default new THREE.Color( 0x000000 ) + */ + emissive: Color; + + /** + * @default 1 + */ + emissiveIntensity: number; + + /** + * @default null + */ + emissiveMap: Texture | null; + + /** + * @default null + */ + bumpMap: Texture | null; + + /** + * @default 1 + */ + bumpScale: number; + + /** + * @default null + */ + normalMap: Texture | null; + + /** + * @default THREE.TangentSpaceNormalMap + */ + normalMapType: NormalMapTypes; + + /** + * @default new THREE.Vector2( 1, 1 ) + */ + normalScale: Vector2; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default null + */ + roughnessMap: Texture | null; + + /** + * @default null + */ + metalnessMap: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default null + */ + envMap: Texture | null; + + /** + * @default 1 + */ + envMapIntensity: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default 'round' + */ + wireframeLinecap: string; + + /** + * @default 'round' + */ + wireframeLinejoin: string; + + /** + * Define whether the material is rendered with flat shading. Default is false. + * @default false + */ + flatShading: boolean; + + isMeshStandardMaterial: boolean; + + setValues(parameters: MeshStandardMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshStandardMaterial.js b/backend/libs/three/materials/MeshStandardMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..b1721f49331d19cb38c0edaa1e39959172136708 --- /dev/null +++ b/backend/libs/three/materials/MeshStandardMaterial.js @@ -0,0 +1,166 @@ +import { TangentSpaceNormalMap } from '../constants.js'; +import { Material } from './Material.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * roughness: , + * metalness: , + * opacity: , + * + * map: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * roughnessMap: new THREE.Texture( ), + * + * metalnessMap: new THREE.Texture( ), + * + * alphaMap: new THREE.Texture( ), + * + * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ), + * envMapIntensity: + * + * refractionRatio: , + * + * wireframe: , + * wireframeLinewidth: , + * + * flatShading: + * } + */ + +class MeshStandardMaterial extends Material { + constructor(parameters) { + super(); + + this.defines = { STANDARD: '' }; + + this.type = 'MeshStandardMaterial'; + + this.color = new Color(0xffffff); // diffuse + this.roughness = 1.0; + this.metalness = 0.0; + + this.map = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color(0x000000); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2(1, 1); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.roughnessMap = null; + + this.metalnessMap = null; + + this.alphaMap = null; + + this.envMap = null; + this.envMapIntensity = 1.0; + + this.refractionRatio = 0.98; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.flatShading = false; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.defines = { STANDARD: '' }; + + this.color.copy(source.color); + this.roughness = source.roughness; + this.metalness = source.metalness; + + this.map = source.map; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy(source.emissive); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy(source.normalScale); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.roughnessMap = source.roughnessMap; + + this.metalnessMap = source.metalnessMap; + + this.alphaMap = source.alphaMap; + + this.envMap = source.envMap; + this.envMapIntensity = source.envMapIntensity; + + this.refractionRatio = source.refractionRatio; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + this.flatShading = source.flatShading; + + return this; + } +} + +MeshStandardMaterial.prototype.isMeshStandardMaterial = true; + +export { MeshStandardMaterial }; diff --git a/backend/libs/three/materials/MeshToonMaterial.d.ts b/backend/libs/three/materials/MeshToonMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ad30bb1d0e5c8c67d5da92698b08239b96c085fc --- /dev/null +++ b/backend/libs/three/materials/MeshToonMaterial.d.ts @@ -0,0 +1,165 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; +import { NormalMapTypes } from '../constants'; +import { ColorRepresentation } from '../utils'; + +export interface MeshToonMaterialParameters extends MaterialParameters { + /** geometry color in hexadecimal. Default is 0xffffff. */ + color?: ColorRepresentation | undefined; + opacity?: number | undefined; + gradientMap?: Texture | null | undefined; + map?: Texture | null | undefined; + lightMap?: Texture | null | undefined; + lightMapIntensity?: number | undefined; + aoMap?: Texture | null | undefined; + aoMapIntensity?: number | undefined; + emissive?: ColorRepresentation | undefined; + emissiveIntensity?: number | undefined; + emissiveMap?: Texture | null | undefined; + bumpMap?: Texture | null | undefined; + bumpScale?: number | undefined; + normalMap?: Texture | null | undefined; + normalMapType?: NormalMapTypes | undefined; + normalScale?: Vector2 | undefined; + displacementMap?: Texture | null | undefined; + displacementScale?: number | undefined; + displacementBias?: number | undefined; + alphaMap?: Texture | null | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + wireframeLinecap?: string | undefined; + wireframeLinejoin?: string | undefined; +} + +export class MeshToonMaterial extends Material { + constructor(parameters?: MeshToonMaterialParameters); + + /** + * @default 'MeshToonMaterial' + */ + type: string; + + /** + * @default { 'TOON': '' } + */ + defines: { [key: string]: any }; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default null + */ + gradientMap: Texture | null; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + lightMap: Texture | null; + + /** + * @default 1 + */ + lightMapIntensity: number; + + /** + * @default null + */ + aoMap: Texture | null; + + /** + * @default 1 + */ + aoMapIntensity: number; + + /** + * @default new THREE.Color( 0x000000 ) + */ + emissive: Color; + + /** + * @default 1 + */ + emissiveIntensity: number; + + /** + * @default null + */ + emissiveMap: Texture | null; + + /** + * @default null + */ + bumpMap: Texture | null; + + /** + * @default 1 + */ + bumpScale: number; + + /** + * @default null + */ + normalMap: Texture | null; + + /** + * @default THREE.TangentSpaceNormalMap + */ + normalMapType: NormalMapTypes; + + /** + * @default new THREE.Vector2( 1, 1 ) + */ + normalScale: Vector2; + + /** + * @default null + */ + displacementMap: Texture | null; + + /** + * @default 1 + */ + displacementScale: number; + + /** + * @default 0 + */ + displacementBias: number; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default 'round' + */ + wireframeLinecap: string; + + /** + * @default 'round' + */ + wireframeLinejoin: string; + + setValues(parameters: MeshToonMaterialParameters): void; +} diff --git a/backend/libs/three/materials/MeshToonMaterial.js b/backend/libs/three/materials/MeshToonMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..b5b8344f22a836842e0523753f98c91673eead26 --- /dev/null +++ b/backend/libs/three/materials/MeshToonMaterial.js @@ -0,0 +1,128 @@ +import { TangentSpaceNormalMap } from '../constants.js'; +import { Material } from './Material.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * + * map: new THREE.Texture( ), + * gradientMap: new THREE.Texture( ), + * + * lightMap: new THREE.Texture( ), + * lightMapIntensity: + * + * aoMap: new THREE.Texture( ), + * aoMapIntensity: + * + * emissive: , + * emissiveIntensity: + * emissiveMap: new THREE.Texture( ), + * + * bumpMap: new THREE.Texture( ), + * bumpScale: , + * + * normalMap: new THREE.Texture( ), + * normalMapType: THREE.TangentSpaceNormalMap, + * normalScale: , + * + * displacementMap: new THREE.Texture( ), + * displacementScale: , + * displacementBias: , + * + * alphaMap: new THREE.Texture( ), + * + * wireframe: , + * wireframeLinewidth: , + * + * } + */ + +class MeshToonMaterial extends Material { + constructor(parameters) { + super(); + + this.defines = { TOON: '' }; + + this.type = 'MeshToonMaterial'; + + this.color = new Color(0xffffff); + + this.map = null; + this.gradientMap = null; + + this.lightMap = null; + this.lightMapIntensity = 1.0; + + this.aoMap = null; + this.aoMapIntensity = 1.0; + + this.emissive = new Color(0x000000); + this.emissiveIntensity = 1.0; + this.emissiveMap = null; + + this.bumpMap = null; + this.bumpScale = 1; + + this.normalMap = null; + this.normalMapType = TangentSpaceNormalMap; + this.normalScale = new Vector2(1, 1); + + this.displacementMap = null; + this.displacementScale = 1; + this.displacementBias = 0; + + this.alphaMap = null; + + this.wireframe = false; + this.wireframeLinewidth = 1; + this.wireframeLinecap = 'round'; + this.wireframeLinejoin = 'round'; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.map = source.map; + this.gradientMap = source.gradientMap; + + this.lightMap = source.lightMap; + this.lightMapIntensity = source.lightMapIntensity; + + this.aoMap = source.aoMap; + this.aoMapIntensity = source.aoMapIntensity; + + this.emissive.copy(source.emissive); + this.emissiveMap = source.emissiveMap; + this.emissiveIntensity = source.emissiveIntensity; + + this.bumpMap = source.bumpMap; + this.bumpScale = source.bumpScale; + + this.normalMap = source.normalMap; + this.normalMapType = source.normalMapType; + this.normalScale.copy(source.normalScale); + + this.displacementMap = source.displacementMap; + this.displacementScale = source.displacementScale; + this.displacementBias = source.displacementBias; + + this.alphaMap = source.alphaMap; + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + this.wireframeLinecap = source.wireframeLinecap; + this.wireframeLinejoin = source.wireframeLinejoin; + + return this; + } +} + +MeshToonMaterial.prototype.isMeshToonMaterial = true; + +export { MeshToonMaterial }; diff --git a/backend/libs/three/materials/PointsMaterial.d.ts b/backend/libs/three/materials/PointsMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0b1307d8d731038a23fca67d982f4199b26108f7 --- /dev/null +++ b/backend/libs/three/materials/PointsMaterial.d.ts @@ -0,0 +1,48 @@ +import { Material, MaterialParameters } from './Material'; +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { ColorRepresentation } from '../utils'; + +export interface PointsMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + map?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + size?: number | undefined; + sizeAttenuation?: boolean | undefined; +} + +export class PointsMaterial extends Material { + constructor(parameters?: PointsMaterialParameters); + + /** + * @default 'PointsMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default 1 + */ + size: number; + + /** + * @default true + */ + sizeAttenuation: boolean; + + setValues(parameters: PointsMaterialParameters): void; +} diff --git a/backend/libs/three/materials/PointsMaterial.js b/backend/libs/three/materials/PointsMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..bb9dd9735fdcbb453b647358ccd1e32b19f291e8 --- /dev/null +++ b/backend/libs/three/materials/PointsMaterial.js @@ -0,0 +1,53 @@ +import { Material } from './Material.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * opacity: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * + * size: , + * sizeAttenuation: + * + * } + */ + +class PointsMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'PointsMaterial'; + + this.color = new Color(0xffffff); + + this.map = null; + + this.alphaMap = null; + + this.size = 1; + this.sizeAttenuation = true; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.size = source.size; + this.sizeAttenuation = source.sizeAttenuation; + + return this; + } +} + +PointsMaterial.prototype.isPointsMaterial = true; + +export { PointsMaterial }; diff --git a/backend/libs/three/materials/RawShaderMaterial.d.ts b/backend/libs/three/materials/RawShaderMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..76bc5fafa3948b99d4e3bb8d0c60de49e8292c59 --- /dev/null +++ b/backend/libs/three/materials/RawShaderMaterial.d.ts @@ -0,0 +1,5 @@ +import { ShaderMaterialParameters, ShaderMaterial } from './ShaderMaterial'; + +export class RawShaderMaterial extends ShaderMaterial { + constructor(parameters?: ShaderMaterialParameters); +} diff --git a/backend/libs/three/materials/RawShaderMaterial.js b/backend/libs/three/materials/RawShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..06404337fff55cc0fd17886ea3a9f091920fcfeb --- /dev/null +++ b/backend/libs/three/materials/RawShaderMaterial.js @@ -0,0 +1,13 @@ +import { ShaderMaterial } from './ShaderMaterial.js'; + +class RawShaderMaterial extends ShaderMaterial { + constructor(parameters) { + super(parameters); + + this.type = 'RawShaderMaterial'; + } +} + +RawShaderMaterial.prototype.isRawShaderMaterial = true; + +export { RawShaderMaterial }; diff --git a/backend/libs/three/materials/ShaderMaterial.d.ts b/backend/libs/three/materials/ShaderMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..626455674e57c250f071e057a8b07f00bf02ba8f --- /dev/null +++ b/backend/libs/three/materials/ShaderMaterial.d.ts @@ -0,0 +1,115 @@ +import { IUniform } from '../renderers/shaders/UniformsLib'; +import { MaterialParameters, Material } from './Material'; +import { GLSLVersion } from '../constants'; + +export interface ShaderMaterialParameters extends MaterialParameters { + uniforms?: { [uniform: string]: IUniform } | undefined; + vertexShader?: string | undefined; + fragmentShader?: string | undefined; + linewidth?: number | undefined; + wireframe?: boolean | undefined; + wireframeLinewidth?: number | undefined; + lights?: boolean | undefined; + clipping?: boolean | undefined; + + extensions?: + | { + derivatives?: boolean | undefined; + fragDepth?: boolean | undefined; + drawBuffers?: boolean | undefined; + shaderTextureLOD?: boolean | undefined; + } + | undefined; + glslVersion?: GLSLVersion | undefined; +} + +export class ShaderMaterial extends Material { + constructor(parameters?: ShaderMaterialParameters); + + /** + * @default 'ShaderMaterial' + */ + type: string; + + /** + * @default {} + */ + defines: { [key: string]: any }; + + /** + * @default {} + */ + uniforms: { [uniform: string]: IUniform }; + vertexShader: string; + fragmentShader: string; + + /** + * @default 1 + */ + linewidth: number; + + /** + * @default false + */ + wireframe: boolean; + + /** + * @default 1 + */ + wireframeLinewidth: number; + + /** + * @default false + */ + fog: boolean; + + /** + * @default false + */ + lights: boolean; + + /** + * @default false + */ + clipping: boolean; + + /** + * @deprecated Use {@link ShaderMaterial#extensions.derivatives extensions.derivatives} instead. + */ + derivatives: any; + + /** + * @default { derivatives: false, fragDepth: false, drawBuffers: false, shaderTextureLOD: false } + */ + extensions: { + derivatives: boolean; + fragDepth: boolean; + drawBuffers: boolean; + shaderTextureLOD: boolean; + }; + + /** + * @default { 'color': [ 1, 1, 1 ], 'uv': [ 0, 0 ], 'uv2': [ 0, 0 ] } + */ + defaultAttributeValues: any; + + /** + * @default undefined + */ + index0AttributeName: string | undefined; + + /** + * @default false + */ + uniformsNeedUpdate: boolean; + + /** + * @default null + */ + glslVersion: GLSLVersion | null; + + isShaderMaterial: boolean; + + setValues(parameters: ShaderMaterialParameters): void; + toJSON(meta: any): any; +} diff --git a/backend/libs/three/materials/ShaderMaterial.js b/backend/libs/three/materials/ShaderMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..9d04c2edecc09556ee2548f15399864edc23f0d9 --- /dev/null +++ b/backend/libs/three/materials/ShaderMaterial.js @@ -0,0 +1,168 @@ +import { Material } from './Material.js'; +import { cloneUniforms } from '../renderers/shaders/UniformsUtils.js'; + +import default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js'; +import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js'; + +/** + * parameters = { + * defines: { "label" : "value" }, + * uniforms: { "parameter1": { value: 1.0 }, "parameter2": { value2: 2 } }, + * + * fragmentShader: , + * vertexShader: , + * + * wireframe: , + * wireframeLinewidth: , + * + * lights: + * } + */ + +class ShaderMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'ShaderMaterial'; + + this.defines = {}; + this.uniforms = {}; + + this.vertexShader = default_vertex; + this.fragmentShader = default_fragment; + + this.linewidth = 1; + + this.wireframe = false; + this.wireframeLinewidth = 1; + + this.fog = false; // set to use scene fog + this.lights = false; // set to use scene lights + this.clipping = false; // set to use user-defined clipping planes + + this.extensions = { + derivatives: false, // set to use derivatives + fragDepth: false, // set to use fragment depth values + drawBuffers: false, // set to use draw buffers + shaderTextureLOD: false, // set to use shader texture LOD + }; + + // When rendered geometry doesn't include these attributes but the material does, + // use these default values in WebGL. This avoids errors when buffer data is missing. + this.defaultAttributeValues = { + color: [1, 1, 1], + uv: [0, 0], + uv2: [0, 0], + }; + + this.index0AttributeName = undefined; + this.uniformsNeedUpdate = false; + + this.glslVersion = null; + + if (parameters !== undefined) { + if (parameters.attributes !== undefined) { + console.error('THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.'); + } + + this.setValues(parameters); + } + } + + copy(source) { + super.copy(source); + + this.fragmentShader = source.fragmentShader; + this.vertexShader = source.vertexShader; + + this.uniforms = cloneUniforms(source.uniforms); + + this.defines = Object.assign({}, source.defines); + + this.wireframe = source.wireframe; + this.wireframeLinewidth = source.wireframeLinewidth; + + this.lights = source.lights; + this.clipping = source.clipping; + + this.extensions = Object.assign({}, source.extensions); + + this.glslVersion = source.glslVersion; + + return this; + } + + toJSON(meta) { + const data = super.toJSON(meta); + + data.glslVersion = this.glslVersion; + data.uniforms = {}; + + for (const name in this.uniforms) { + const uniform = this.uniforms[name]; + const value = uniform.value; + + if (value && value.isTexture) { + data.uniforms[name] = { + type: 't', + value: value.toJSON(meta).uuid, + }; + } else if (value && value.isColor) { + data.uniforms[name] = { + type: 'c', + value: value.getHex(), + }; + } else if (value && value.isVector2) { + data.uniforms[name] = { + type: 'v2', + value: value.toArray(), + }; + } else if (value && value.isVector3) { + data.uniforms[name] = { + type: 'v3', + value: value.toArray(), + }; + } else if (value && value.isVector4) { + data.uniforms[name] = { + type: 'v4', + value: value.toArray(), + }; + } else if (value && value.isMatrix3) { + data.uniforms[name] = { + type: 'm3', + value: value.toArray(), + }; + } else if (value && value.isMatrix4) { + data.uniforms[name] = { + type: 'm4', + value: value.toArray(), + }; + } else { + data.uniforms[name] = { + value: value, + }; + + // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far + } + } + + if (Object.keys(this.defines).length > 0) data.defines = this.defines; + + data.vertexShader = this.vertexShader; + data.fragmentShader = this.fragmentShader; + + const extensions = {}; + + for (const key in this.extensions) { + if (this.extensions[key] === true) extensions[key] = true; + } + + if (Object.keys(extensions).length > 0) data.extensions = extensions; + + return data; + } +} + +ShaderMaterial.prototype.isShaderMaterial = true; + +export { ShaderMaterial }; diff --git a/backend/libs/three/materials/ShadowMaterial.d.ts b/backend/libs/three/materials/ShadowMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e03d8fc4a69a29648f78d1b6b5e958f792eb4519 --- /dev/null +++ b/backend/libs/three/materials/ShadowMaterial.d.ts @@ -0,0 +1,26 @@ +import { ColorRepresentation } from '../utils'; +import { Color } from './../math/Color'; +import { MaterialParameters, Material } from './Material'; + +export interface ShadowMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; +} + +export class ShadowMaterial extends Material { + constructor(parameters?: ShadowMaterialParameters); + + /** + * @default 'ShadowMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0x000000 ) + */ + color: Color; + + /** + * @default true + */ + transparent: boolean; +} diff --git a/backend/libs/three/materials/ShadowMaterial.js b/backend/libs/three/materials/ShadowMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..dc5bea7f62b01fac2a6f63a0ae14ead6a80efb2e --- /dev/null +++ b/backend/libs/three/materials/ShadowMaterial.js @@ -0,0 +1,33 @@ +import { Material } from './Material.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: + * } + */ + +class ShadowMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'ShadowMaterial'; + + this.color = new Color(0x000000); + this.transparent = true; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + return this; + } +} + +ShadowMaterial.prototype.isShadowMaterial = true; + +export { ShadowMaterial }; diff --git a/backend/libs/three/materials/SpriteMaterial.d.ts b/backend/libs/three/materials/SpriteMaterial.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..13911eb46ca5182189743591d0bc00ce5b3d52b3 --- /dev/null +++ b/backend/libs/three/materials/SpriteMaterial.d.ts @@ -0,0 +1,55 @@ +import { ColorRepresentation } from '../utils'; +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; + +export interface SpriteMaterialParameters extends MaterialParameters { + color?: ColorRepresentation | undefined; + map?: Texture | null | undefined; + alphaMap?: Texture | null | undefined; + rotation?: number | undefined; + sizeAttenuation?: boolean | undefined; +} + +export class SpriteMaterial extends Material { + constructor(parameters?: SpriteMaterialParameters); + /** + * @default 'SpriteMaterial' + */ + type: string; + + /** + * @default new THREE.Color( 0xffffff ) + */ + color: Color; + + /** + * @default null + */ + map: Texture | null; + + /** + * @default null + */ + alphaMap: Texture | null; + + /** + * @default 0 + */ + rotation: number; + + /** + * @default true + */ + sizeAttenuation: boolean; + + /** + * @default true + */ + transparent: boolean; + + readonly isSpriteMaterial: true; + + setValues(parameters: SpriteMaterialParameters): void; + copy(source: SpriteMaterial): this; +} diff --git a/backend/libs/three/materials/SpriteMaterial.js b/backend/libs/three/materials/SpriteMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..53b33f99baf7395bb9be0fb46a19a5bc6c65eb56 --- /dev/null +++ b/backend/libs/three/materials/SpriteMaterial.js @@ -0,0 +1,54 @@ +import { Material } from './Material.js'; +import { Color } from '../math/Color.js'; + +/** + * parameters = { + * color: , + * map: new THREE.Texture( ), + * alphaMap: new THREE.Texture( ), + * rotation: , + * sizeAttenuation: + * } + */ + +class SpriteMaterial extends Material { + constructor(parameters) { + super(); + + this.type = 'SpriteMaterial'; + + this.color = new Color(0xffffff); + + this.map = null; + + this.alphaMap = null; + + this.rotation = 0; + + this.sizeAttenuation = true; + + this.transparent = true; + + this.setValues(parameters); + } + + copy(source) { + super.copy(source); + + this.color.copy(source.color); + + this.map = source.map; + + this.alphaMap = source.alphaMap; + + this.rotation = source.rotation; + + this.sizeAttenuation = source.sizeAttenuation; + + return this; + } +} + +SpriteMaterial.prototype.isSpriteMaterial = true; + +export { SpriteMaterial }; diff --git a/backend/libs/three/math/Box2.d.ts b/backend/libs/three/math/Box2.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..601c8d72ac7495f3e61823d25067bae5aa5f074e --- /dev/null +++ b/backend/libs/three/math/Box2.d.ts @@ -0,0 +1,48 @@ +import { Vector2 } from './Vector2'; + +// Math ////////////////////////////////////////////////////////////////////////////////// + +export class Box2 { + constructor(min?: Vector2, max?: Vector2); + + /** + * @default new THREE.Vector2( + Infinity, + Infinity ) + */ + min: Vector2; + + /** + * @default new THREE.Vector2( - Infinity, - Infinity ) + */ + max: Vector2; + + set(min: Vector2, max: Vector2): Box2; + setFromPoints(points: Vector2[]): Box2; + setFromCenterAndSize(center: Vector2, size: Vector2): Box2; + clone(): this; + copy(box: Box2): this; + makeEmpty(): Box2; + isEmpty(): boolean; + getCenter(target: Vector2): Vector2; + getSize(target: Vector2): Vector2; + expandByPoint(point: Vector2): Box2; + expandByVector(vector: Vector2): Box2; + expandByScalar(scalar: number): Box2; + containsPoint(point: Vector2): boolean; + containsBox(box: Box2): boolean; + getParameter(point: Vector2, target: Vector2): Vector2; + intersectsBox(box: Box2): boolean; + clampPoint(point: Vector2, target: Vector2): Vector2; + distanceToPoint(point: Vector2): number; + intersect(box: Box2): Box2; + union(box: Box2): Box2; + translate(offset: Vector2): Box2; + equals(box: Box2): boolean; + /** + * @deprecated Use {@link Box2#isEmpty .isEmpty()} instead. + */ + empty(): any; + /** + * @deprecated Use {@link Box2#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; +} diff --git a/backend/libs/three/math/Box2.js b/backend/libs/three/math/Box2.js new file mode 100644 index 0000000000000000000000000000000000000000..0115f0889c622c7c16f7b49680c017d8aab43320 --- /dev/null +++ b/backend/libs/three/math/Box2.js @@ -0,0 +1,147 @@ +import { Vector2 } from './Vector2.js'; + +const _vector = /*@__PURE__*/ new Vector2(); + +class Box2 { + constructor(min = new Vector2(+Infinity, +Infinity), max = new Vector2(-Infinity, -Infinity)) { + this.min = min; + this.max = max; + } + + set(min, max) { + this.min.copy(min); + this.max.copy(max); + + return this; + } + + setFromPoints(points) { + this.makeEmpty(); + + for (let i = 0, il = points.length; i < il; i++) { + this.expandByPoint(points[i]); + } + + return this; + } + + setFromCenterAndSize(center, size) { + const halfSize = _vector.copy(size).multiplyScalar(0.5); + this.min.copy(center).sub(halfSize); + this.max.copy(center).add(halfSize); + + return this; + } + + clone() { + return new this.constructor().copy(this); + } + + copy(box) { + this.min.copy(box.min); + this.max.copy(box.max); + + return this; + } + + makeEmpty() { + this.min.x = this.min.y = +Infinity; + this.max.x = this.max.y = -Infinity; + + return this; + } + + isEmpty() { + // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes + + return this.max.x < this.min.x || this.max.y < this.min.y; + } + + getCenter(target) { + return this.isEmpty() ? target.set(0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5); + } + + getSize(target) { + return this.isEmpty() ? target.set(0, 0) : target.subVectors(this.max, this.min); + } + + expandByPoint(point) { + this.min.min(point); + this.max.max(point); + + return this; + } + + expandByVector(vector) { + this.min.sub(vector); + this.max.add(vector); + + return this; + } + + expandByScalar(scalar) { + this.min.addScalar(-scalar); + this.max.addScalar(scalar); + + return this; + } + + containsPoint(point) { + return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true; + } + + containsBox(box) { + return this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y; + } + + getParameter(point, target) { + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + + return target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y)); + } + + intersectsBox(box) { + // using 4 splitting planes to rule out intersections + + return box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y ? false : true; + } + + clampPoint(point, target) { + return target.copy(point).clamp(this.min, this.max); + } + + distanceToPoint(point) { + const clampedPoint = _vector.copy(point).clamp(this.min, this.max); + return clampedPoint.sub(point).length(); + } + + intersect(box) { + this.min.max(box.min); + this.max.min(box.max); + + return this; + } + + union(box) { + this.min.min(box.min); + this.max.max(box.max); + + return this; + } + + translate(offset) { + this.min.add(offset); + this.max.add(offset); + + return this; + } + + equals(box) { + return box.min.equals(this.min) && box.max.equals(this.max); + } +} + +Box2.prototype.isBox2 = true; + +export { Box2 }; diff --git a/backend/libs/three/math/Box3.d.ts b/backend/libs/three/math/Box3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7cd8466dd68f91bfbde8125462bdffb1e959b0b3 --- /dev/null +++ b/backend/libs/three/math/Box3.d.ts @@ -0,0 +1,66 @@ +import { BufferAttribute } from './../core/BufferAttribute'; +import { Vector3 } from './Vector3'; +import { Object3D } from './../core/Object3D'; +import { Sphere } from './Sphere'; +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; +import { Triangle } from './Triangle'; + +export class Box3 { + constructor(min?: Vector3, max?: Vector3); + + /** + * @default new THREE.Vector3( + Infinity, + Infinity, + Infinity ) + */ + min: Vector3; + + /** + * @default new THREE.Vector3( - Infinity, - Infinity, - Infinity ) + */ + max: Vector3; + readonly isBox3: true; + + set(min: Vector3, max: Vector3): this; + setFromArray(array: ArrayLike): this; + setFromBufferAttribute(bufferAttribute: BufferAttribute): this; + setFromPoints(points: Vector3[]): this; + setFromCenterAndSize(center: Vector3, size: Vector3): this; + setFromObject(object: Object3D, precise?: boolean): this; + clone(): this; + copy(box: Box3): this; + makeEmpty(): this; + isEmpty(): boolean; + getCenter(target: Vector3): Vector3; + getSize(target: Vector3): Vector3; + expandByPoint(point: Vector3): this; + expandByVector(vector: Vector3): this; + expandByScalar(scalar: number): this; + expandByObject(object: Object3D, precise?: boolean): this; + containsPoint(point: Vector3): boolean; + containsBox(box: Box3): boolean; + getParameter(point: Vector3, target: Vector3): Vector3; + intersectsBox(box: Box3): boolean; + intersectsSphere(sphere: Sphere): boolean; + intersectsPlane(plane: Plane): boolean; + intersectsTriangle(triangle: Triangle): boolean; + clampPoint(point: Vector3, target: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + getBoundingSphere(target: Sphere): Sphere; + intersect(box: Box3): this; + union(box: Box3): this; + applyMatrix4(matrix: Matrix4): this; + translate(offset: Vector3): this; + equals(box: Box3): boolean; + /** + * @deprecated Use {@link Box3#isEmpty .isEmpty()} instead. + */ + empty(): any; + /** + * @deprecated Use {@link Box3#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; + /** + * @deprecated Use {@link Box3#intersectsSphere .intersectsSphere()} instead. + */ + isIntersectionSphere(s: any): any; +} diff --git a/backend/libs/three/math/Box3.js b/backend/libs/three/math/Box3.js new file mode 100644 index 0000000000000000000000000000000000000000..9d697967fb8e58ef917a6691ac18203598609cbc --- /dev/null +++ b/backend/libs/three/math/Box3.js @@ -0,0 +1,450 @@ +import { Vector3 } from './Vector3.js'; + +class Box3 { + constructor(min = new Vector3(+Infinity, +Infinity, +Infinity), max = new Vector3(-Infinity, -Infinity, -Infinity)) { + this.min = min; + this.max = max; + } + + set(min, max) { + this.min.copy(min); + this.max.copy(max); + + return this; + } + + setFromArray(array) { + let minX = +Infinity; + let minY = +Infinity; + let minZ = +Infinity; + + let maxX = -Infinity; + let maxY = -Infinity; + let maxZ = -Infinity; + + for (let i = 0, l = array.length; i < l; i += 3) { + const x = array[i]; + const y = array[i + 1]; + const z = array[i + 2]; + + if (x < minX) minX = x; + if (y < minY) minY = y; + if (z < minZ) minZ = z; + + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + if (z > maxZ) maxZ = z; + } + + this.min.set(minX, minY, minZ); + this.max.set(maxX, maxY, maxZ); + + return this; + } + + setFromBufferAttribute(attribute) { + let minX = +Infinity; + let minY = +Infinity; + let minZ = +Infinity; + + let maxX = -Infinity; + let maxY = -Infinity; + let maxZ = -Infinity; + + for (let i = 0, l = attribute.count; i < l; i++) { + const x = attribute.getX(i); + const y = attribute.getY(i); + const z = attribute.getZ(i); + + if (x < minX) minX = x; + if (y < minY) minY = y; + if (z < minZ) minZ = z; + + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + if (z > maxZ) maxZ = z; + } + + this.min.set(minX, minY, minZ); + this.max.set(maxX, maxY, maxZ); + + return this; + } + + setFromPoints(points) { + this.makeEmpty(); + + for (let i = 0, il = points.length; i < il; i++) { + this.expandByPoint(points[i]); + } + + return this; + } + + setFromCenterAndSize(center, size) { + const halfSize = _vector.copy(size).multiplyScalar(0.5); + + this.min.copy(center).sub(halfSize); + this.max.copy(center).add(halfSize); + + return this; + } + + setFromObject(object) { + this.makeEmpty(); + + return this.expandByObject(object); + } + + clone() { + return new this.constructor().copy(this); + } + + copy(box) { + this.min.copy(box.min); + this.max.copy(box.max); + + return this; + } + + makeEmpty() { + this.min.x = this.min.y = this.min.z = +Infinity; + this.max.x = this.max.y = this.max.z = -Infinity; + + return this; + } + + isEmpty() { + // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes + + return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z; + } + + getCenter(target) { + return this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5); + } + + getSize(target) { + return this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min); + } + + expandByPoint(point) { + this.min.min(point); + this.max.max(point); + + return this; + } + + expandByVector(vector) { + this.min.sub(vector); + this.max.add(vector); + + return this; + } + + expandByScalar(scalar) { + this.min.addScalar(-scalar); + this.max.addScalar(scalar); + + return this; + } + + expandByObject(object) { + // Computes the world-axis-aligned bounding box of an object (including its children), + // accounting for both the object's, and children's, world transforms + + object.updateWorldMatrix(false, false); + + const geometry = object.geometry; + + if (geometry !== undefined) { + if (geometry.boundingBox === null) { + geometry.computeBoundingBox(); + } + + _box.copy(geometry.boundingBox); + _box.applyMatrix4(object.matrixWorld); + + this.union(_box); + } + + const children = object.children; + + for (let i = 0, l = children.length; i < l; i++) { + this.expandByObject(children[i]); + } + + return this; + } + + containsPoint(point) { + return point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z + ? false + : true; + } + + containsBox(box) { + return ( + this.min.x <= box.min.x && + box.max.x <= this.max.x && + this.min.y <= box.min.y && + box.max.y <= this.max.y && + this.min.z <= box.min.z && + box.max.z <= this.max.z + ); + } + + getParameter(point, target) { + // This can potentially have a divide by zero if the box + // has a size dimension of 0. + + return target.set( + (point.x - this.min.x) / (this.max.x - this.min.x), + (point.y - this.min.y) / (this.max.y - this.min.y), + (point.z - this.min.z) / (this.max.z - this.min.z) + ); + } + + intersectsBox(box) { + // using 6 splitting planes to rule out intersections. + return box.max.x < this.min.x || + box.min.x > this.max.x || + box.max.y < this.min.y || + box.min.y > this.max.y || + box.max.z < this.min.z || + box.min.z > this.max.z + ? false + : true; + } + + intersectsSphere(sphere) { + // Find the point on the AABB closest to the sphere center. + this.clampPoint(sphere.center, _vector); + + // If that point is inside the sphere, the AABB and sphere intersect. + return _vector.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius; + } + + intersectsPlane(plane) { + // We compute the minimum and maximum dot product values. If those values + // are on the same side (back or front) of the plane, then there is no intersection. + + let min, max; + + if (plane.normal.x > 0) { + min = plane.normal.x * this.min.x; + max = plane.normal.x * this.max.x; + } else { + min = plane.normal.x * this.max.x; + max = plane.normal.x * this.min.x; + } + + if (plane.normal.y > 0) { + min += plane.normal.y * this.min.y; + max += plane.normal.y * this.max.y; + } else { + min += plane.normal.y * this.max.y; + max += plane.normal.y * this.min.y; + } + + if (plane.normal.z > 0) { + min += plane.normal.z * this.min.z; + max += plane.normal.z * this.max.z; + } else { + min += plane.normal.z * this.max.z; + max += plane.normal.z * this.min.z; + } + + return min <= -plane.constant && max >= -plane.constant; + } + + intersectsTriangle(triangle) { + if (this.isEmpty()) { + return false; + } + + // compute box center and extents + this.getCenter(_center); + _extents.subVectors(this.max, _center); + + // translate triangle to aabb origin + _v0.subVectors(triangle.a, _center); + _v1.subVectors(triangle.b, _center); + _v2.subVectors(triangle.c, _center); + + // compute edge vectors for triangle + _f0.subVectors(_v1, _v0); + _f1.subVectors(_v2, _v1); + _f2.subVectors(_v0, _v2); + + // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb + // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation + // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned) + let axes = [ + 0, + -_f0.z, + _f0.y, + 0, + -_f1.z, + _f1.y, + 0, + -_f2.z, + _f2.y, + _f0.z, + 0, + -_f0.x, + _f1.z, + 0, + -_f1.x, + _f2.z, + 0, + -_f2.x, + -_f0.y, + _f0.x, + 0, + -_f1.y, + _f1.x, + 0, + -_f2.y, + _f2.x, + 0, + ]; + if (!satForAxes(axes, _v0, _v1, _v2, _extents)) { + return false; + } + + // test 3 face normals from the aabb + axes = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + if (!satForAxes(axes, _v0, _v1, _v2, _extents)) { + return false; + } + + // finally testing the face normal of the triangle + // use already existing triangle edge vectors here + _triangleNormal.crossVectors(_f0, _f1); + axes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z]; + + return satForAxes(axes, _v0, _v1, _v2, _extents); + } + + clampPoint(point, target) { + return target.copy(point).clamp(this.min, this.max); + } + + distanceToPoint(point) { + const clampedPoint = _vector.copy(point).clamp(this.min, this.max); + + return clampedPoint.sub(point).length(); + } + + getBoundingSphere(target) { + this.getCenter(target.center); + + target.radius = this.getSize(_vector).length() * 0.5; + + return target; + } + + intersect(box) { + this.min.max(box.min); + this.max.min(box.max); + + // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values. + if (this.isEmpty()) this.makeEmpty(); + + return this; + } + + union(box) { + this.min.min(box.min); + this.max.max(box.max); + + return this; + } + + applyMatrix4(matrix) { + // transform of empty box is an empty box. + if (this.isEmpty()) return this; + + // NOTE: I am using a binary pattern to specify all 2^3 combinations below + _points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix); // 000 + _points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix); // 001 + _points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix); // 010 + _points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix); // 011 + _points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix); // 100 + _points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix); // 101 + _points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix); // 110 + _points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix); // 111 + + this.setFromPoints(_points); + + return this; + } + + translate(offset) { + this.min.add(offset); + this.max.add(offset); + + return this; + } + + equals(box) { + return box.min.equals(this.min) && box.max.equals(this.max); + } +} + +Box3.prototype.isBox3 = true; + +const _points = [ + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), + /*@__PURE__*/ new Vector3(), +]; + +const _vector = /*@__PURE__*/ new Vector3(); + +const _box = /*@__PURE__*/ new Box3(); + +// triangle centered vertices + +const _v0 = /*@__PURE__*/ new Vector3(); +const _v1 = /*@__PURE__*/ new Vector3(); +const _v2 = /*@__PURE__*/ new Vector3(); + +// triangle edge vectors + +const _f0 = /*@__PURE__*/ new Vector3(); +const _f1 = /*@__PURE__*/ new Vector3(); +const _f2 = /*@__PURE__*/ new Vector3(); + +const _center = /*@__PURE__*/ new Vector3(); +const _extents = /*@__PURE__*/ new Vector3(); +const _triangleNormal = /*@__PURE__*/ new Vector3(); +const _testAxis = /*@__PURE__*/ new Vector3(); + +function satForAxes(axes, v0, v1, v2, extents) { + for (let i = 0, j = axes.length - 3; i <= j; i += 3) { + _testAxis.fromArray(axes, i); + // project the aabb onto the seperating axis + const r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z); + // project all 3 vertices of the triangle onto the seperating axis + const p0 = v0.dot(_testAxis); + const p1 = v1.dot(_testAxis); + const p2 = v2.dot(_testAxis); + // actual test, basically see if either of the most extreme of the triangle points intersects r + if (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) { + // points of the projected triangle are outside the projected half-length of the aabb + // the axis is seperating and we can exit + return false; + } + } + + return true; +} + +export { Box3 }; diff --git a/backend/libs/three/math/Color.d.ts b/backend/libs/three/math/Color.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d3caa6b5bb263097bd4f6710ae96bec94b5710d0 --- /dev/null +++ b/backend/libs/three/math/Color.d.ts @@ -0,0 +1,182 @@ +import { ColorSpace } from '../constants'; +import { ColorRepresentation } from '../utils'; + +import { BufferAttribute } from './../core/BufferAttribute'; + +export { SRGBToLinear } from './ColorManagement'; + +export interface HSL { + h: number; + s: number; + l: number; +} + +export interface RGB { + r: number; + g: number; + b: number; +} + +/** + * Represents a color. See also {@link ColorUtils}. + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/math/Color.js|src/math/Color.js} + * + * @example + * const color = new THREE.Color( 0xff0000 ); + */ +export class Color { + constructor(color?: ColorRepresentation); + constructor(r: number, g: number, b: number); + + readonly isColor: true; + + /** + * Red channel value between 0 and 1. Default is 1. + * @default 1 + */ + r: number; + + /** + * Green channel value between 0 and 1. Default is 1. + * @default 1 + */ + g: number; + + /** + * Blue channel value between 0 and 1. Default is 1. + * @default 1 + */ + b: number; + + set(color: ColorRepresentation): Color; + setScalar(scalar: number): Color; + setHex(hex: number, colorSpace?: ColorSpace): Color; + + /** + * Sets this color from RGB values. + * @param r Red channel value between 0 and 1. + * @param g Green channel value between 0 and 1. + * @param b Blue channel value between 0 and 1. + */ + setRGB(r: number, g: number, b: number, colorSpace?: ColorSpace): Color; + + /** + * Sets this color from HSL values. + * Based on MochiKit implementation by Bob Ippolito. + * + * @param h Hue channel value between 0 and 1. + * @param s Saturation value channel between 0 and 1. + * @param l Value channel value between 0 and 1. + */ + setHSL(h: number, s: number, l: number, colorSpace?: ColorSpace): Color; + + /** + * Sets this color from a CSS context style string. + * @param contextStyle Color in CSS context style format. + */ + setStyle(style: string, colorSpace?: ColorSpace): Color; + + /** + * Sets this color from a color name. + * Faster than {@link Color#setStyle .setStyle()} method if you don't need the other CSS-style formats. + * @param style Color name in X11 format. + */ + setColorName(style: string, colorSpace?: ColorSpace): Color; + + /** + * Clones this color. + */ + clone(): this; + + /** + * Copies given color. + * @param color Color to copy. + */ + copy(color: Color): this; + + /** + * Copies given color making conversion from sRGB to linear space. + * @param color Color to copy. + */ + copySRGBToLinear(color: Color): Color; + + /** + * Copies given color making conversion from linear to sRGB space. + * @param color Color to copy. + */ + copyLinearToSRGB(color: Color): Color; + + /** + * Converts this color from sRGB to linear space. + */ + convertSRGBToLinear(): Color; + + /** + * Converts this color from linear to sRGB space. + */ + convertLinearToSRGB(): Color; + + /** + * Returns the hexadecimal value of this color. + */ + getHex(colorSpace?: ColorSpace): number; + + /** + * Returns the string formated hexadecimal value of this color. + */ + getHexString(colorSpace?: ColorSpace): string; + + getHSL(target: HSL, colorSpace?: ColorSpace): HSL; + + getRGB(target: RGB, colorSpace?: ColorSpace): RGB; + + /** + * Returns the value of this color in CSS context style. + * Example: rgb(r, g, b) + */ + getStyle(colorSpace?: ColorSpace): string; + + offsetHSL(h: number, s: number, l: number): this; + + add(color: Color): this; + addColors(color1: Color, color2: Color): this; + addScalar(s: number): this; + sub(color: Color): this; + multiply(color: Color): this; + multiplyScalar(s: number): this; + lerp(color: Color, alpha: number): this; + lerpColors(color1: Color, color2: Color, alpha: number): this; + lerpHSL(color: Color, alpha: number): this; + equals(color: Color): boolean; + + /** + * Sets this color's red, green and blue value from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array-like. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array [red, green, blue], or copies red, green and blue into the provided array. + * @param array (optional) array to store the color to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + + /** + * Copies red, green and blue into the provided array-like. + * @param array array-like to store the color to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(xyz: ArrayLike, offset?: number): ArrayLike; + + fromBufferAttribute(attribute: BufferAttribute, index: number): this; + + /** + * List of X11 color names. + */ + static NAMES: Record; +} diff --git a/backend/libs/three/math/Color.js b/backend/libs/three/math/Color.js new file mode 100644 index 0000000000000000000000000000000000000000..650b0ce4ec6870f251175cb21eb2f402c56f8f48 --- /dev/null +++ b/backend/libs/three/math/Color.js @@ -0,0 +1,579 @@ +import * as MathUtils from './MathUtils.js'; + +const _colorKeywords = { + aliceblue: 0xf0f8ff, + antiquewhite: 0xfaebd7, + aqua: 0x00ffff, + aquamarine: 0x7fffd4, + azure: 0xf0ffff, + beige: 0xf5f5dc, + bisque: 0xffe4c4, + black: 0x000000, + blanchedalmond: 0xffebcd, + blue: 0x0000ff, + blueviolet: 0x8a2be2, + brown: 0xa52a2a, + burlywood: 0xdeb887, + cadetblue: 0x5f9ea0, + chartreuse: 0x7fff00, + chocolate: 0xd2691e, + coral: 0xff7f50, + cornflowerblue: 0x6495ed, + cornsilk: 0xfff8dc, + crimson: 0xdc143c, + cyan: 0x00ffff, + darkblue: 0x00008b, + darkcyan: 0x008b8b, + darkgoldenrod: 0xb8860b, + darkgray: 0xa9a9a9, + darkgreen: 0x006400, + darkgrey: 0xa9a9a9, + darkkhaki: 0xbdb76b, + darkmagenta: 0x8b008b, + darkolivegreen: 0x556b2f, + darkorange: 0xff8c00, + darkorchid: 0x9932cc, + darkred: 0x8b0000, + darksalmon: 0xe9967a, + darkseagreen: 0x8fbc8f, + darkslateblue: 0x483d8b, + darkslategray: 0x2f4f4f, + darkslategrey: 0x2f4f4f, + darkturquoise: 0x00ced1, + darkviolet: 0x9400d3, + deeppink: 0xff1493, + deepskyblue: 0x00bfff, + dimgray: 0x696969, + dimgrey: 0x696969, + dodgerblue: 0x1e90ff, + firebrick: 0xb22222, + floralwhite: 0xfffaf0, + forestgreen: 0x228b22, + fuchsia: 0xff00ff, + gainsboro: 0xdcdcdc, + ghostwhite: 0xf8f8ff, + gold: 0xffd700, + goldenrod: 0xdaa520, + gray: 0x808080, + green: 0x008000, + greenyellow: 0xadff2f, + grey: 0x808080, + honeydew: 0xf0fff0, + hotpink: 0xff69b4, + indianred: 0xcd5c5c, + indigo: 0x4b0082, + ivory: 0xfffff0, + khaki: 0xf0e68c, + lavender: 0xe6e6fa, + lavenderblush: 0xfff0f5, + lawngreen: 0x7cfc00, + lemonchiffon: 0xfffacd, + lightblue: 0xadd8e6, + lightcoral: 0xf08080, + lightcyan: 0xe0ffff, + lightgoldenrodyellow: 0xfafad2, + lightgray: 0xd3d3d3, + lightgreen: 0x90ee90, + lightgrey: 0xd3d3d3, + lightpink: 0xffb6c1, + lightsalmon: 0xffa07a, + lightseagreen: 0x20b2aa, + lightskyblue: 0x87cefa, + lightslategray: 0x778899, + lightslategrey: 0x778899, + lightsteelblue: 0xb0c4de, + lightyellow: 0xffffe0, + lime: 0x00ff00, + limegreen: 0x32cd32, + linen: 0xfaf0e6, + magenta: 0xff00ff, + maroon: 0x800000, + mediumaquamarine: 0x66cdaa, + mediumblue: 0x0000cd, + mediumorchid: 0xba55d3, + mediumpurple: 0x9370db, + mediumseagreen: 0x3cb371, + mediumslateblue: 0x7b68ee, + mediumspringgreen: 0x00fa9a, + mediumturquoise: 0x48d1cc, + mediumvioletred: 0xc71585, + midnightblue: 0x191970, + mintcream: 0xf5fffa, + mistyrose: 0xffe4e1, + moccasin: 0xffe4b5, + navajowhite: 0xffdead, + navy: 0x000080, + oldlace: 0xfdf5e6, + olive: 0x808000, + olivedrab: 0x6b8e23, + orange: 0xffa500, + orangered: 0xff4500, + orchid: 0xda70d6, + palegoldenrod: 0xeee8aa, + palegreen: 0x98fb98, + paleturquoise: 0xafeeee, + palevioletred: 0xdb7093, + papayawhip: 0xffefd5, + peachpuff: 0xffdab9, + peru: 0xcd853f, + pink: 0xffc0cb, + plum: 0xdda0dd, + powderblue: 0xb0e0e6, + purple: 0x800080, + rebeccapurple: 0x663399, + red: 0xff0000, + rosybrown: 0xbc8f8f, + royalblue: 0x4169e1, + saddlebrown: 0x8b4513, + salmon: 0xfa8072, + sandybrown: 0xf4a460, + seagreen: 0x2e8b57, + seashell: 0xfff5ee, + sienna: 0xa0522d, + silver: 0xc0c0c0, + skyblue: 0x87ceeb, + slateblue: 0x6a5acd, + slategray: 0x708090, + slategrey: 0x708090, + snow: 0xfffafa, + springgreen: 0x00ff7f, + steelblue: 0x4682b4, + tan: 0xd2b48c, + teal: 0x008080, + thistle: 0xd8bfd8, + tomato: 0xff6347, + turquoise: 0x40e0d0, + violet: 0xee82ee, + wheat: 0xf5deb3, + white: 0xffffff, + whitesmoke: 0xf5f5f5, + yellow: 0xffff00, + yellowgreen: 0x9acd32, +}; + +const _hslA = { h: 0, s: 0, l: 0 }; +const _hslB = { h: 0, s: 0, l: 0 }; + +function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * 6 * (2 / 3 - t); + return p; +} + +function SRGBToLinear(c) { + return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4); +} + +function LinearToSRGB(c) { + return c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055; +} + +class Color { + constructor(r, g, b) { + if (g === undefined && b === undefined) { + // r is THREE.Color, hex or string + return this.set(r); + } + + return this.setRGB(r, g, b); + } + + set(value) { + if (value && value.isColor) { + this.copy(value); + } else if (typeof value === 'number') { + this.setHex(value); + } else if (typeof value === 'string') { + this.setStyle(value); + } + + return this; + } + + setScalar(scalar) { + this.r = scalar; + this.g = scalar; + this.b = scalar; + + return this; + } + + setHex(hex) { + hex = Math.floor(hex); + + this.r = ((hex >> 16) & 255) / 255; + this.g = ((hex >> 8) & 255) / 255; + this.b = (hex & 255) / 255; + + return this; + } + + setRGB(r, g, b) { + this.r = r; + this.g = g; + this.b = b; + + return this; + } + + setHSL(h, s, l) { + // h,s,l ranges are in 0.0 - 1.0 + h = MathUtils.euclideanModulo(h, 1); + s = MathUtils.clamp(s, 0, 1); + l = MathUtils.clamp(l, 0, 1); + + if (s === 0) { + this.r = this.g = this.b = l; + } else { + const p = l <= 0.5 ? l * (1 + s) : l + s - l * s; + const q = 2 * l - p; + + this.r = hue2rgb(q, p, h + 1 / 3); + this.g = hue2rgb(q, p, h); + this.b = hue2rgb(q, p, h - 1 / 3); + } + + return this; + } + + setStyle(style) { + function handleAlpha(string) { + if (string === undefined) return; + + if (parseFloat(string) < 1) { + console.warn('THREE.Color: Alpha component of ' + style + ' will be ignored.'); + } + } + + let m; + + if ((m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(style))) { + // rgb / hsl + + let color; + const name = m[1]; + const components = m[2]; + + switch (name) { + case 'rgb': + case 'rgba': + if ((color = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) { + // rgb(255,0,0) rgba(255,0,0,0.5) + this.r = Math.min(255, parseInt(color[1], 10)) / 255; + this.g = Math.min(255, parseInt(color[2], 10)) / 255; + this.b = Math.min(255, parseInt(color[3], 10)) / 255; + + handleAlpha(color[4]); + + return this; + } + + if ((color = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) { + // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5) + this.r = Math.min(100, parseInt(color[1], 10)) / 100; + this.g = Math.min(100, parseInt(color[2], 10)) / 100; + this.b = Math.min(100, parseInt(color[3], 10)) / 100; + + handleAlpha(color[4]); + + return this; + } + + break; + + case 'hsl': + case 'hsla': + if ((color = /^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(components))) { + // hsl(120,50%,50%) hsla(120,50%,50%,0.5) + const h = parseFloat(color[1]) / 360; + const s = parseInt(color[2], 10) / 100; + const l = parseInt(color[3], 10) / 100; + + handleAlpha(color[4]); + + return this.setHSL(h, s, l); + } + + break; + } + } else if ((m = /^\#([A-Fa-f\d]+)$/.exec(style))) { + // hex color + + const hex = m[1]; + const size = hex.length; + + if (size === 3) { + // #ff0 + this.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255; + this.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255; + this.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255; + + return this; + } else if (size === 6) { + // #ff0000 + this.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255; + this.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255; + this.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255; + + return this; + } + } + + if (style && style.length > 0) { + return this.setColorName(style); + } + + return this; + } + + setColorName(style) { + // color keywords + const hex = _colorKeywords[style.toLowerCase()]; + + if (hex !== undefined) { + // red + this.setHex(hex); + } else { + // unknown color + console.warn('THREE.Color: Unknown color ' + style); + } + + return this; + } + + clone() { + return new this.constructor(this.r, this.g, this.b); + } + + copy(color) { + this.r = color.r; + this.g = color.g; + this.b = color.b; + + return this; + } + + copySRGBToLinear(color) { + this.r = SRGBToLinear(color.r); + this.g = SRGBToLinear(color.g); + this.b = SRGBToLinear(color.b); + + return this; + } + + copyLinearToSRGB(color) { + this.r = LinearToSRGB(color.r); + this.g = LinearToSRGB(color.g); + this.b = LinearToSRGB(color.b); + + return this; + } + + convertSRGBToLinear() { + this.copySRGBToLinear(this); + + return this; + } + + convertLinearToSRGB() { + this.copyLinearToSRGB(this); + + return this; + } + + getHex() { + return ((this.r * 255) << 16) ^ ((this.g * 255) << 8) ^ ((this.b * 255) << 0); + } + + getHexString() { + return ('000000' + this.getHex().toString(16)).slice(-6); + } + + getHSL(target) { + // h,s,l ranges are in 0.0 - 1.0 + + const r = this.r, + g = this.g, + b = this.b; + + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + + let hue, saturation; + const lightness = (min + max) / 2.0; + + if (min === max) { + hue = 0; + saturation = 0; + } else { + const delta = max - min; + + saturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min); + + switch (max) { + case r: + hue = (g - b) / delta + (g < b ? 6 : 0); + break; + case g: + hue = (b - r) / delta + 2; + break; + case b: + hue = (r - g) / delta + 4; + break; + } + + hue /= 6; + } + + target.h = hue; + target.s = saturation; + target.l = lightness; + + return target; + } + + getStyle() { + return 'rgb(' + ((this.r * 255) | 0) + ',' + ((this.g * 255) | 0) + ',' + ((this.b * 255) | 0) + ')'; + } + + offsetHSL(h, s, l) { + this.getHSL(_hslA); + + _hslA.h += h; + _hslA.s += s; + _hslA.l += l; + + this.setHSL(_hslA.h, _hslA.s, _hslA.l); + + return this; + } + + add(color) { + this.r += color.r; + this.g += color.g; + this.b += color.b; + + return this; + } + + addColors(color1, color2) { + this.r = color1.r + color2.r; + this.g = color1.g + color2.g; + this.b = color1.b + color2.b; + + return this; + } + + addScalar(s) { + this.r += s; + this.g += s; + this.b += s; + + return this; + } + + sub(color) { + this.r = Math.max(0, this.r - color.r); + this.g = Math.max(0, this.g - color.g); + this.b = Math.max(0, this.b - color.b); + + return this; + } + + multiply(color) { + this.r *= color.r; + this.g *= color.g; + this.b *= color.b; + + return this; + } + + multiplyScalar(s) { + this.r *= s; + this.g *= s; + this.b *= s; + + return this; + } + + lerp(color, alpha) { + this.r += (color.r - this.r) * alpha; + this.g += (color.g - this.g) * alpha; + this.b += (color.b - this.b) * alpha; + + return this; + } + + lerpColors(color1, color2, alpha) { + this.r = color1.r + (color2.r - color1.r) * alpha; + this.g = color1.g + (color2.g - color1.g) * alpha; + this.b = color1.b + (color2.b - color1.b) * alpha; + + return this; + } + + lerpHSL(color, alpha) { + this.getHSL(_hslA); + color.getHSL(_hslB); + + const h = MathUtils.lerp(_hslA.h, _hslB.h, alpha); + const s = MathUtils.lerp(_hslA.s, _hslB.s, alpha); + const l = MathUtils.lerp(_hslA.l, _hslB.l, alpha); + + this.setHSL(h, s, l); + + return this; + } + + equals(c) { + return c.r === this.r && c.g === this.g && c.b === this.b; + } + + fromArray(array, offset = 0) { + this.r = array[offset]; + this.g = array[offset + 1]; + this.b = array[offset + 2]; + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this.r; + array[offset + 1] = this.g; + array[offset + 2] = this.b; + + return array; + } + + fromBufferAttribute(attribute, index) { + this.r = attribute.getX(index); + this.g = attribute.getY(index); + this.b = attribute.getZ(index); + + if (attribute.normalized === true) { + // assuming Uint8Array + + this.r /= 255; + this.g /= 255; + this.b /= 255; + } + + return this; + } + + toJSON() { + return this.getHex(); + } +} + +Color.NAMES = _colorKeywords; + +Color.prototype.isColor = true; +Color.prototype.r = 1; +Color.prototype.g = 1; +Color.prototype.b = 1; + +export { Color, SRGBToLinear }; diff --git a/backend/libs/three/math/ColorManagement.d.ts b/backend/libs/three/math/ColorManagement.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..daf95386c17e7ad55c7dc33da605d7f73cc181b7 --- /dev/null +++ b/backend/libs/three/math/ColorManagement.d.ts @@ -0,0 +1,14 @@ +import { LinearSRGBColorSpace, SRGBColorSpace } from '../constants'; +import { Color } from './Color'; + +export function SRGBToLinear(c: number): number; + +export function LinearToSRGB(c: number): number; + +export namespace ColorManagement { + function convert(color: Color, sourceColorSpace: SRGBColorSpace | LinearSRGBColorSpace, targetColorSpace: SRGBColorSpace | LinearSRGBColorSpace): Color; + + function fromWorkingColorSpace(color: Color, targetColorSpace: SRGBColorSpace | LinearSRGBColorSpace): Color; + + function toWorkingColorSpace(color: Color, sourceColorSpace: SRGBColorSpace | LinearSRGBColorSpace): Color; +} diff --git a/backend/libs/three/math/Cylindrical.d.ts b/backend/libs/three/math/Cylindrical.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c1f42bf54e1f2507d85614d1281338ac9f5a2188 --- /dev/null +++ b/backend/libs/three/math/Cylindrical.d.ts @@ -0,0 +1,26 @@ +import { Vector3 } from './Vector3'; + +export class Cylindrical { + constructor(radius?: number, theta?: number, y?: number); + + /** + * @default 1 + */ + radius: number; + + /** + * @default 0 + */ + theta: number; + + /** + * @default 0 + */ + y: number; + + clone(): this; + copy(other: Cylindrical): this; + set(radius: number, theta: number, y: number): this; + setFromVector3(vec3: Vector3): this; + setFromCartesianCoords(x: number, y: number, z: number): this; +} diff --git a/backend/libs/three/math/Cylindrical.js b/backend/libs/three/math/Cylindrical.js new file mode 100644 index 0000000000000000000000000000000000000000..9a540eafc57ce069ccc68ea43e88e2e40021f08e --- /dev/null +++ b/backend/libs/three/math/Cylindrical.js @@ -0,0 +1,47 @@ +/** + * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system + */ + +class Cylindrical { + constructor(radius = 1, theta = 0, y = 0) { + this.radius = radius; // distance from the origin to a point in the x-z plane + this.theta = theta; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis + this.y = y; // height above the x-z plane + + return this; + } + + set(radius, theta, y) { + this.radius = radius; + this.theta = theta; + this.y = y; + + return this; + } + + copy(other) { + this.radius = other.radius; + this.theta = other.theta; + this.y = other.y; + + return this; + } + + setFromVector3(v) { + return this.setFromCartesianCoords(v.x, v.y, v.z); + } + + setFromCartesianCoords(x, y, z) { + this.radius = Math.sqrt(x * x + z * z); + this.theta = Math.atan2(x, z); + this.y = y; + + return this; + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Cylindrical }; diff --git a/backend/libs/three/math/Euler.d.ts b/backend/libs/three/math/Euler.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e06a75f4f46d55eabd379007ec7089581acb0a06 --- /dev/null +++ b/backend/libs/three/math/Euler.d.ts @@ -0,0 +1,45 @@ +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { Vector3 } from './Vector3'; + +export class Euler { + constructor(x?: number, y?: number, z?: number, order?: string); + + /** + * @default 0 + */ + x: number; + + /** + * @default 0 + */ + y: number; + + /** + * @default 0 + */ + z: number; + + /** + * @default THREE.Euler.DefaultOrder + */ + order: string; + readonly isEuler: true; + + _onChangeCallback: () => void; + + set(x: number, y: number, z: number, order?: string): Euler; + clone(): this; + copy(euler: Euler): this; + setFromRotationMatrix(m: Matrix4, order?: string, update?: boolean): Euler; + setFromQuaternion(q: Quaternion, order?: string, update?: boolean): Euler; + setFromVector3(v: Vector3, order?: string): Euler; + reorder(newOrder: string): Euler; + equals(euler: Euler): boolean; + fromArray(xyzo: any[]): Euler; + toArray(array?: number[], offset?: number): number[]; + _onChange(callback: () => void): this; + + static RotationOrders: string[]; + static DefaultOrder: string; +} diff --git a/backend/libs/three/math/Euler.js b/backend/libs/three/math/Euler.js new file mode 100644 index 0000000000000000000000000000000000000000..0a4db7bccfbd69753e479ad27e904a5e3d208267 --- /dev/null +++ b/backend/libs/three/math/Euler.js @@ -0,0 +1,247 @@ +import { Quaternion } from './Quaternion.js'; +import { Vector3 } from './Vector3.js'; +import { Matrix4 } from './Matrix4.js'; +import { clamp } from './MathUtils.js'; + +const _matrix = /*@__PURE__*/ new Matrix4(); +const _quaternion = /*@__PURE__*/ new Quaternion(); + +class Euler { + constructor(x = 0, y = 0, z = 0, order = Euler.DefaultOrder) { + this._x = x; + this._y = y; + this._z = z; + this._order = order; + } + + get x() { + return this._x; + } + + set x(value) { + this._x = value; + this._onChangeCallback(); + } + + get y() { + return this._y; + } + + set y(value) { + this._y = value; + this._onChangeCallback(); + } + + get z() { + return this._z; + } + + set z(value) { + this._z = value; + this._onChangeCallback(); + } + + get order() { + return this._order; + } + + set order(value) { + this._order = value; + this._onChangeCallback(); + } + + set(x, y, z, order = this._order) { + this._x = x; + this._y = y; + this._z = z; + this._order = order; + + this._onChangeCallback(); + + return this; + } + + clone() { + return new this.constructor(this._x, this._y, this._z, this._order); + } + + copy(euler) { + this._x = euler._x; + this._y = euler._y; + this._z = euler._z; + this._order = euler._order; + + this._onChangeCallback(); + + return this; + } + + setFromRotationMatrix(m, order = this._order, update = true) { + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements; + const m11 = te[0], + m12 = te[4], + m13 = te[8]; + const m21 = te[1], + m22 = te[5], + m23 = te[9]; + const m31 = te[2], + m32 = te[6], + m33 = te[10]; + + switch (order) { + case 'XYZ': + this._y = Math.asin(clamp(m13, -1, 1)); + + if (Math.abs(m13) < 0.9999999) { + this._x = Math.atan2(-m23, m33); + this._z = Math.atan2(-m12, m11); + } else { + this._x = Math.atan2(m32, m22); + this._z = 0; + } + + break; + + case 'YXZ': + this._x = Math.asin(-clamp(m23, -1, 1)); + + if (Math.abs(m23) < 0.9999999) { + this._y = Math.atan2(m13, m33); + this._z = Math.atan2(m21, m22); + } else { + this._y = Math.atan2(-m31, m11); + this._z = 0; + } + + break; + + case 'ZXY': + this._x = Math.asin(clamp(m32, -1, 1)); + + if (Math.abs(m32) < 0.9999999) { + this._y = Math.atan2(-m31, m33); + this._z = Math.atan2(-m12, m22); + } else { + this._y = 0; + this._z = Math.atan2(m21, m11); + } + + break; + + case 'ZYX': + this._y = Math.asin(-clamp(m31, -1, 1)); + + if (Math.abs(m31) < 0.9999999) { + this._x = Math.atan2(m32, m33); + this._z = Math.atan2(m21, m11); + } else { + this._x = 0; + this._z = Math.atan2(-m12, m22); + } + + break; + + case 'YZX': + this._z = Math.asin(clamp(m21, -1, 1)); + + if (Math.abs(m21) < 0.9999999) { + this._x = Math.atan2(-m23, m22); + this._y = Math.atan2(-m31, m11); + } else { + this._x = 0; + this._y = Math.atan2(m13, m33); + } + + break; + + case 'XZY': + this._z = Math.asin(-clamp(m12, -1, 1)); + + if (Math.abs(m12) < 0.9999999) { + this._x = Math.atan2(m32, m22); + this._y = Math.atan2(m13, m11); + } else { + this._x = Math.atan2(-m23, m33); + this._y = 0; + } + + break; + + default: + console.warn('THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order); + } + + this._order = order; + + if (update === true) this._onChangeCallback(); + + return this; + } + + setFromQuaternion(q, order, update) { + _matrix.makeRotationFromQuaternion(q); + + return this.setFromRotationMatrix(_matrix, order, update); + } + + setFromVector3(v, order = this._order) { + return this.set(v.x, v.y, v.z, order); + } + + reorder(newOrder) { + // WARNING: this discards revolution information -bhouston + + _quaternion.setFromEuler(this); + + return this.setFromQuaternion(_quaternion, newOrder); + } + + equals(euler) { + return euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order; + } + + fromArray(array) { + this._x = array[0]; + this._y = array[1]; + this._z = array[2]; + if (array[3] !== undefined) this._order = array[3]; + + this._onChangeCallback(); + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this._x; + array[offset + 1] = this._y; + array[offset + 2] = this._z; + array[offset + 3] = this._order; + + return array; + } + + toVector3(optionalResult) { + if (optionalResult) { + return optionalResult.set(this._x, this._y, this._z); + } else { + return new Vector3(this._x, this._y, this._z); + } + } + + _onChange(callback) { + this._onChangeCallback = callback; + + return this; + } + + _onChangeCallback() {} +} + +Euler.prototype.isEuler = true; + +Euler.DefaultOrder = 'XYZ'; +Euler.RotationOrders = ['XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX']; + +export { Euler }; diff --git a/backend/libs/three/math/Frustum.d.ts b/backend/libs/three/math/Frustum.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f15073dd968f0bcc9fbaaadb08727906f636b7ea --- /dev/null +++ b/backend/libs/three/math/Frustum.d.ts @@ -0,0 +1,29 @@ +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; +import { Object3D } from './../core/Object3D'; +import { Sprite } from './../objects/Sprite'; +import { Sphere } from './Sphere'; +import { Box3 } from './Box3'; +import { Vector3 } from './Vector3'; + +/** + * Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process. + */ +export class Frustum { + constructor(p0?: Plane, p1?: Plane, p2?: Plane, p3?: Plane, p4?: Plane, p5?: Plane); + + /** + * Array of 6 vectors. + */ + planes: Plane[]; + + set(p0: Plane, p1: Plane, p2: Plane, p3: Plane, p4: Plane, p5: Plane): Frustum; + clone(): this; + copy(frustum: Frustum): this; + setFromProjectionMatrix(m: Matrix4): this; + intersectsObject(object: Object3D): boolean; + intersectsSprite(sprite: Sprite): boolean; + intersectsSphere(sphere: Sphere): boolean; + intersectsBox(box: Box3): boolean; + containsPoint(point: Vector3): boolean; +} diff --git a/backend/libs/three/math/Frustum.js b/backend/libs/three/math/Frustum.js new file mode 100644 index 0000000000000000000000000000000000000000..429fb4cdfae28fb92ef25241c83ba89f515be15e --- /dev/null +++ b/backend/libs/three/math/Frustum.js @@ -0,0 +1,137 @@ +import { Vector3 } from './Vector3.js'; +import { Sphere } from './Sphere.js'; +import { Plane } from './Plane.js'; + +const _sphere = /*@__PURE__*/ new Sphere(); +const _vector = /*@__PURE__*/ new Vector3(); + +class Frustum { + constructor(p0 = new Plane(), p1 = new Plane(), p2 = new Plane(), p3 = new Plane(), p4 = new Plane(), p5 = new Plane()) { + this.planes = [p0, p1, p2, p3, p4, p5]; + } + + set(p0, p1, p2, p3, p4, p5) { + const planes = this.planes; + + planes[0].copy(p0); + planes[1].copy(p1); + planes[2].copy(p2); + planes[3].copy(p3); + planes[4].copy(p4); + planes[5].copy(p5); + + return this; + } + + copy(frustum) { + const planes = this.planes; + + for (let i = 0; i < 6; i++) { + planes[i].copy(frustum.planes[i]); + } + + return this; + } + + setFromProjectionMatrix(m) { + const planes = this.planes; + const me = m.elements; + const me0 = me[0], + me1 = me[1], + me2 = me[2], + me3 = me[3]; + const me4 = me[4], + me5 = me[5], + me6 = me[6], + me7 = me[7]; + const me8 = me[8], + me9 = me[9], + me10 = me[10], + me11 = me[11]; + const me12 = me[12], + me13 = me[13], + me14 = me[14], + me15 = me[15]; + + planes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize(); + planes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize(); + planes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize(); + planes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize(); + planes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize(); + planes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize(); + + return this; + } + + intersectsObject(object) { + const geometry = object.geometry; + + if (geometry.boundingSphere === null) geometry.computeBoundingSphere(); + + _sphere.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld); + + return this.intersectsSphere(_sphere); + } + + intersectsSprite(sprite) { + _sphere.center.set(0, 0, 0); + _sphere.radius = 0.7071067811865476; + _sphere.applyMatrix4(sprite.matrixWorld); + + return this.intersectsSphere(_sphere); + } + + intersectsSphere(sphere) { + const planes = this.planes; + const center = sphere.center; + const negRadius = -sphere.radius; + + for (let i = 0; i < 6; i++) { + const distance = planes[i].distanceToPoint(center); + + if (distance < negRadius) { + return false; + } + } + + return true; + } + + intersectsBox(box) { + const planes = this.planes; + + for (let i = 0; i < 6; i++) { + const plane = planes[i]; + + // corner at max distance + + _vector.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector.z = plane.normal.z > 0 ? box.max.z : box.min.z; + + if (plane.distanceToPoint(_vector) < 0) { + return false; + } + } + + return true; + } + + containsPoint(point) { + const planes = this.planes; + + for (let i = 0; i < 6; i++) { + if (planes[i].distanceToPoint(point) < 0) { + return false; + } + } + + return true; + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Frustum }; diff --git a/backend/libs/three/math/Interpolant.d.ts b/backend/libs/three/math/Interpolant.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..aa3d4791e39f0f8fe1551925f346d6bedec95351 --- /dev/null +++ b/backend/libs/three/math/Interpolant.d.ts @@ -0,0 +1,10 @@ +export abstract class Interpolant { + constructor(parameterPositions: any, sampleValues: any, sampleSize: number, resultBuffer?: any); + + parameterPositions: any; + sampleValues: any; + valueSize: number; + resultBuffer: any; + + evaluate(time: number): any; +} diff --git a/backend/libs/three/math/Interpolant.js b/backend/libs/three/math/Interpolant.js new file mode 100644 index 0000000000000000000000000000000000000000..a58c46b93b6cadaed9bbc2596370aa59b7189fb7 --- /dev/null +++ b/backend/libs/three/math/Interpolant.js @@ -0,0 +1,195 @@ +/** + * Abstract base class of interpolants over parametric samples. + * + * The parameter domain is one dimensional, typically the time or a path + * along a curve defined by the data. + * + * The sample values can have any dimensionality and derived classes may + * apply special interpretations to the data. + * + * This class provides the interval seek in a Template Method, deferring + * the actual interpolation to derived classes. + * + * Time complexity is O(1) for linear access crossing at most two points + * and O(log N) for random access, where N is the number of positions. + * + * References: + * + * http://www.oodesign.com/template-method-pattern.html + * + */ + +class Interpolant { + constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { + this.parameterPositions = parameterPositions; + this._cachedIndex = 0; + + this.resultBuffer = resultBuffer !== undefined ? resultBuffer : new sampleValues.constructor(sampleSize); + this.sampleValues = sampleValues; + this.valueSize = sampleSize; + + this.settings = null; + this.DefaultSettings_ = {}; + } + + evaluate(t) { + const pp = this.parameterPositions; + let i1 = this._cachedIndex, + t1 = pp[i1], + t0 = pp[i1 - 1]; + + validate_interval: { + seek: { + let right; + + linear_scan: { + //- See http://jsperf.com/comparison-to-undefined/3 + //- slower code: + //- + //- if ( t >= t1 || t1 === undefined ) { + forward_scan: if (!(t < t1)) { + for (let giveUpAt = i1 + 2; ; ) { + if (t1 === undefined) { + if (t < t0) break forward_scan; + + // after end + + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_(i1 - 1, t, t0); + } + + if (i1 === giveUpAt) break; // this loop + + t0 = t1; + t1 = pp[++i1]; + + if (t < t1) { + // we have arrived at the sought interval + break seek; + } + } + + // prepare binary search on the right side of the index + right = pp.length; + break linear_scan; + } + + //- slower code: + //- if ( t < t0 || t0 === undefined ) { + if (!(t >= t0)) { + // looping? + + const t1global = pp[1]; + + if (t < t1global) { + i1 = 2; // + 1, using the scan for the details + t0 = t1global; + } + + // linear reverse scan + + for (let giveUpAt = i1 - 2; ; ) { + if (t0 === undefined) { + // before start + + this._cachedIndex = 0; + return this.beforeStart_(0, t, t1); + } + + if (i1 === giveUpAt) break; // this loop + + t1 = t0; + t0 = pp[--i1 - 1]; + + if (t >= t0) { + // we have arrived at the sought interval + break seek; + } + } + + // prepare binary search on the left side of the index + right = i1; + i1 = 0; + break linear_scan; + } + + // the interval is valid + + break validate_interval; + } // linear scan + + // binary search + + while (i1 < right) { + const mid = (i1 + right) >>> 1; + + if (t < pp[mid]) { + right = mid; + } else { + i1 = mid + 1; + } + } + + t1 = pp[i1]; + t0 = pp[i1 - 1]; + + // check boundary cases, again + + if (t0 === undefined) { + this._cachedIndex = 0; + return this.beforeStart_(0, t, t1); + } + + if (t1 === undefined) { + i1 = pp.length; + this._cachedIndex = i1; + return this.afterEnd_(i1 - 1, t0, t); + } + } // seek + + this._cachedIndex = i1; + + this.intervalChanged_(i1, t0, t1); + } // validate_interval + + return this.interpolate_(i1, t0, t, t1); + } + + getSettings_() { + return this.settings || this.DefaultSettings_; + } + + copySampleValue_(index) { + // copies a sample value to the result buffer + + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + offset = index * stride; + + for (let i = 0; i !== stride; ++i) { + result[i] = values[offset + i]; + } + + return result; + } + + // Template methods for derived classes: + + interpolate_(/* i1, t0, t, t1 */) { + throw new Error('call to abstract method'); + // implementations shall return this.resultBuffer + } + + intervalChanged_(/* i1, t0, t1 */) { + // empty + } +} + +// ALIAS DEFINITIONS + +Interpolant.prototype.beforeStart_ = Interpolant.prototype.copySampleValue_; +Interpolant.prototype.afterEnd_ = Interpolant.prototype.copySampleValue_; + +export { Interpolant }; diff --git a/backend/libs/three/math/Line3.d.ts b/backend/libs/three/math/Line3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..2a48231b86474c98b5de50de7c42b7adc784e594 --- /dev/null +++ b/backend/libs/three/math/Line3.d.ts @@ -0,0 +1,29 @@ +import { Vector3 } from './Vector3'; +import { Matrix4 } from './Matrix4'; + +export class Line3 { + constructor(start?: Vector3, end?: Vector3); + + /** + * @default new THREE.Vector3() + */ + start: Vector3; + + /** + * @default new THREE.Vector3() + */ + end: Vector3; + + set(start?: Vector3, end?: Vector3): Line3; + clone(): this; + copy(line: Line3): this; + getCenter(target: Vector3): Vector3; + delta(target: Vector3): Vector3; + distanceSq(): number; + distance(): number; + at(t: number, target: Vector3): Vector3; + closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number; + closestPointToPoint(point: Vector3, clampToLine: boolean, target: Vector3): Vector3; + applyMatrix4(matrix: Matrix4): Line3; + equals(line: Line3): boolean; +} diff --git a/backend/libs/three/math/Line3.js b/backend/libs/three/math/Line3.js new file mode 100644 index 0000000000000000000000000000000000000000..fbfea698ff258a90e32b5eeac41c6400564263d3 --- /dev/null +++ b/backend/libs/three/math/Line3.js @@ -0,0 +1,85 @@ +import { Vector3 } from './Vector3.js'; +import * as MathUtils from './MathUtils.js'; + +const _startP = /*@__PURE__*/ new Vector3(); +const _startEnd = /*@__PURE__*/ new Vector3(); + +class Line3 { + constructor(start = new Vector3(), end = new Vector3()) { + this.start = start; + this.end = end; + } + + set(start, end) { + this.start.copy(start); + this.end.copy(end); + + return this; + } + + copy(line) { + this.start.copy(line.start); + this.end.copy(line.end); + + return this; + } + + getCenter(target) { + return target.addVectors(this.start, this.end).multiplyScalar(0.5); + } + + delta(target) { + return target.subVectors(this.end, this.start); + } + + distanceSq() { + return this.start.distanceToSquared(this.end); + } + + distance() { + return this.start.distanceTo(this.end); + } + + at(t, target) { + return this.delta(target).multiplyScalar(t).add(this.start); + } + + closestPointToPointParameter(point, clampToLine) { + _startP.subVectors(point, this.start); + _startEnd.subVectors(this.end, this.start); + + const startEnd2 = _startEnd.dot(_startEnd); + const startEnd_startP = _startEnd.dot(_startP); + + let t = startEnd_startP / startEnd2; + + if (clampToLine) { + t = MathUtils.clamp(t, 0, 1); + } + + return t; + } + + closestPointToPoint(point, clampToLine, target) { + const t = this.closestPointToPointParameter(point, clampToLine); + + return this.delta(target).multiplyScalar(t).add(this.start); + } + + applyMatrix4(matrix) { + this.start.applyMatrix4(matrix); + this.end.applyMatrix4(matrix); + + return this; + } + + equals(line) { + return line.start.equals(this.start) && line.end.equals(this.end); + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Line3 }; diff --git a/backend/libs/three/math/MathUtils.d.ts b/backend/libs/three/math/MathUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b3335bf4e70f83ae7da9968bc2b17696a7bea45e --- /dev/null +++ b/backend/libs/three/math/MathUtils.d.ts @@ -0,0 +1,116 @@ +import { Quaternion } from './Quaternion'; + +/** + * @see {@link https://github.com/mrdoob/three.js/blob/master/src/math/MathUtils.js|src/math/MathUtils.js} + */ + +export const DEG2RAD: number; +export const RAD2DEG: number; + +export function generateUUID(): string; + +/** + * Clamps the x to be between a and b. + * + * @param value Value to be clamped. + * @param min Minimum value + * @param max Maximum value. + */ +export function clamp(value: number, min: number, max: number): number; +export function euclideanModulo(n: number, m: number): number; + +/** + * Linear mapping of x from range [a1, a2] to range [b1, b2]. + * + * @param x Value to be mapped. + * @param a1 Minimum value for range A. + * @param a2 Maximum value for range A. + * @param b1 Minimum value for range B. + * @param b2 Maximum value for range B. + */ +export function mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; + +export function smoothstep(x: number, min: number, max: number): number; + +export function smootherstep(x: number, min: number, max: number): number; + +/** + * Random float from 0 to 1 with 16 bits of randomness. + * Standard Math.random() creates repetitive patterns when applied over larger space. + * + * @deprecated Use {@link Math#random Math.random()} + */ +export function random16(): number; + +/** + * Random integer from low to high interval. + */ +export function randInt(low: number, high: number): number; + +/** + * Random float from low to high interval. + */ +export function randFloat(low: number, high: number): number; + +/** + * Random float from - range / 2 to range / 2 interval. + */ +export function randFloatSpread(range: number): number; + +/** + * Deterministic pseudo-random float in the interval [ 0, 1 ]. + */ +export function seededRandom(seed?: number): number; + +export function degToRad(degrees: number): number; + +export function radToDeg(radians: number): number; + +export function isPowerOfTwo(value: number): boolean; + +export function inverseLerp(x: number, y: number, t: number): number; + +/** + * Returns a value linearly interpolated from two known points based + * on the given interval - t = 0 will return x and t = 1 will return y. + * + * @param x Start point. + * @param y End point. + * @param t interpolation factor in the closed interval [0, 1] + */ +export function lerp(x: number, y: number, t: number): number; + +/** + * Smoothly interpolate a number from x toward y in a spring-like + * manner using the dt to maintain frame rate independent movement. + * + * @param x Current point. + * @param y Target point. + * @param lambda A higher lambda value will make the movement more sudden, and a lower value will make the movement more gradual. + * @param dt Delta time in seconds. + */ +export function damp(x: number, y: number, lambda: number, dt: number): number; + +/** + * Returns a value that alternates between 0 and length. + * + * @param x The value to pingpong. + * @param length The positive value the export function will pingpong to. Default is 1. + */ +export function pingpong(x: number, length?: number): number; + +/** + * @deprecated Use {@link Math#floorPowerOfTwo .floorPowerOfTwo()} + */ +export function nearestPowerOfTwo(value: number): number; + +/** + * @deprecated Use {@link Math#ceilPowerOfTwo .ceilPowerOfTwo()} + */ +export function nextPowerOfTwo(value: number): number; + +export function floorPowerOfTwo(value: number): number; + +export function ceilPowerOfTwo(value: number): number; + +export function setQuaternionFromProperEuler(q: Quaternion, a: number, b: number, c: number, order: string): void; diff --git a/backend/libs/three/math/MathUtils.js b/backend/libs/three/math/MathUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..7a74a9a3bdb6b4893a879b45e0a0698f4b7cfd8f --- /dev/null +++ b/backend/libs/three/math/MathUtils.js @@ -0,0 +1,223 @@ +const _lut = []; + +for (let i = 0; i < 256; i++) { + _lut[i] = (i < 16 ? '0' : '') + i.toString(16); +} + +let _seed = 1234567; + +const DEG2RAD = Math.PI / 180; +const RAD2DEG = 180 / Math.PI; + +// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136 +function generateUUID() { + const d0 = (Math.random() * 0xffffffff) | 0; + const d1 = (Math.random() * 0xffffffff) | 0; + const d2 = (Math.random() * 0xffffffff) | 0; + const d3 = (Math.random() * 0xffffffff) | 0; + const uuid = + _lut[d0 & 0xff] + + _lut[(d0 >> 8) & 0xff] + + _lut[(d0 >> 16) & 0xff] + + _lut[(d0 >> 24) & 0xff] + + '-' + + _lut[d1 & 0xff] + + _lut[(d1 >> 8) & 0xff] + + '-' + + _lut[((d1 >> 16) & 0x0f) | 0x40] + + _lut[(d1 >> 24) & 0xff] + + '-' + + _lut[(d2 & 0x3f) | 0x80] + + _lut[(d2 >> 8) & 0xff] + + '-' + + _lut[(d2 >> 16) & 0xff] + + _lut[(d2 >> 24) & 0xff] + + _lut[d3 & 0xff] + + _lut[(d3 >> 8) & 0xff] + + _lut[(d3 >> 16) & 0xff] + + _lut[(d3 >> 24) & 0xff]; + + // .toUpperCase() here flattens concatenated strings to save heap memory space. + return uuid.toUpperCase(); +} + +function clamp(value, min, max) { + return Math.max(min, Math.min(max, value)); +} + +// compute euclidian modulo of m % n +// https://en.wikipedia.org/wiki/Modulo_operation +function euclideanModulo(n, m) { + return ((n % m) + m) % m; +} + +// Linear mapping from range to range +function mapLinear(x, a1, a2, b1, b2) { + return b1 + ((x - a1) * (b2 - b1)) / (a2 - a1); +} + +// https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/ +function inverseLerp(x, y, value) { + if (x !== y) { + return (value - x) / (y - x); + } else { + return 0; + } +} + +// https://en.wikipedia.org/wiki/Linear_interpolation +function lerp(x, y, t) { + return (1 - t) * x + t * y; +} + +// http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/ +function damp(x, y, lambda, dt) { + return lerp(x, y, 1 - Math.exp(-lambda * dt)); +} + +// https://www.desmos.com/calculator/vcsjnyz7x4 +function pingpong(x, length = 1) { + return length - Math.abs(euclideanModulo(x, length * 2) - length); +} + +// http://en.wikipedia.org/wiki/Smoothstep +function smoothstep(x, min, max) { + if (x <= min) return 0; + if (x >= max) return 1; + + x = (x - min) / (max - min); + + return x * x * (3 - 2 * x); +} + +function smootherstep(x, min, max) { + if (x <= min) return 0; + if (x >= max) return 1; + + x = (x - min) / (max - min); + + return x * x * x * (x * (x * 6 - 15) + 10); +} + +// Random integer from interval +function randInt(low, high) { + return low + Math.floor(Math.random() * (high - low + 1)); +} + +// Random float from interval +function randFloat(low, high) { + return low + Math.random() * (high - low); +} + +// Random float from <-range/2, range/2> interval +function randFloatSpread(range) { + return range * (0.5 - Math.random()); +} + +// Deterministic pseudo-random float in the interval [ 0, 1 ] +function seededRandom(s) { + if (s !== undefined) _seed = s % 2147483647; + + // Park-Miller algorithm + + _seed = (_seed * 16807) % 2147483647; + + return (_seed - 1) / 2147483646; +} + +function degToRad(degrees) { + return degrees * DEG2RAD; +} + +function radToDeg(radians) { + return radians * RAD2DEG; +} + +function isPowerOfTwo(value) { + return (value & (value - 1)) === 0 && value !== 0; +} + +function ceilPowerOfTwo(value) { + return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)); +} + +function floorPowerOfTwo(value) { + return Math.pow(2, Math.floor(Math.log(value) / Math.LN2)); +} + +function setQuaternionFromProperEuler(q, a, b, c, order) { + // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles + + // rotations are applied to the axes in the order specified by 'order' + // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c' + // angles are in radians + + const cos = Math.cos; + const sin = Math.sin; + + const c2 = cos(b / 2); + const s2 = sin(b / 2); + + const c13 = cos((a + c) / 2); + const s13 = sin((a + c) / 2); + + const c1_3 = cos((a - c) / 2); + const s1_3 = sin((a - c) / 2); + + const c3_1 = cos((c - a) / 2); + const s3_1 = sin((c - a) / 2); + + switch (order) { + case 'XYX': + q.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13); + break; + + case 'YZY': + q.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13); + break; + + case 'ZXZ': + q.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13); + break; + + case 'XZX': + q.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13); + break; + + case 'YXY': + q.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13); + break; + + case 'ZYZ': + q.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13); + break; + + default: + console.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order); + } +} + +export { + DEG2RAD, + RAD2DEG, + generateUUID, + clamp, + euclideanModulo, + mapLinear, + inverseLerp, + lerp, + damp, + pingpong, + smoothstep, + smootherstep, + randInt, + randFloat, + randFloatSpread, + seededRandom, + degToRad, + radToDeg, + isPowerOfTwo, + ceilPowerOfTwo, + floorPowerOfTwo, + setQuaternionFromProperEuler, +}; diff --git a/backend/libs/three/math/Matrix3.d.ts b/backend/libs/three/math/Matrix3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..68e307547fd4e7fe000ec82c903dc7cf97ba3532 --- /dev/null +++ b/backend/libs/three/math/Matrix3.d.ts @@ -0,0 +1,154 @@ +import { Matrix4 } from './Matrix4'; +import { Vector3 } from './Vector3'; + +export type Matrix3Tuple = [number, number, number, number, number, number, number, number, number]; + +/** + * ( interface Matrix ) + */ +export interface Matrix { + /** + * Array with matrix values. + */ + elements: number[]; + + /** + * identity():T; + */ + identity(): Matrix; + + /** + * copy(m:T):T; + */ + copy(m: this): this; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): Matrix; + + determinant(): number; + + /** + * transpose():T; + */ + transpose(): Matrix; + + /** + * invert():T; + */ + invert(): Matrix; + + /** + * clone():T; + */ + clone(): Matrix; +} + +/** + * ( class Matrix3 implements Matrix ) + */ +export class Matrix3 implements Matrix { + /** + * Creates an identity matrix. + */ + constructor(); + + /** + * Array with matrix values. + * @default [1, 0, 0, 0, 1, 0, 0, 0, 1] + */ + elements: number[]; + + set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; + identity(): Matrix3; + clone(): this; + copy(m: Matrix3): this; + extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix3; + setFromMatrix4(m: Matrix4): Matrix3; + multiplyScalar(s: number): Matrix3; + determinant(): number; + + /** + * Inverts this matrix in place. + */ + invert(): Matrix3; + + /** + * Transposes this matrix in place. + */ + transpose(): Matrix3; + getNormalMatrix(matrix4: Matrix4): Matrix3; + + /** + * Transposes this matrix into the supplied array r, and returns itself. + */ + transposeIntoArray(r: number[]): Matrix3; + + setUvTransform(tx: number, ty: number, sx: number, sy: number, rotation: number, cx: number, cy: number): Matrix3; + + scale(sx: number, sy: number): Matrix3; + + rotate(theta: number): Matrix3; + + translate(tx: number, ty: number): Matrix3; + + equals(matrix: Matrix3): boolean; + + /** + * Sets the values of this matrix from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array-like. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): Matrix3; + + /** + * Returns an array with the values of this matrix, or copies them into the provided array. + * @param array (optional) array to store the matrix to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + toArray(array?: Matrix3Tuple, offset?: 0): Matrix3Tuple; + + /** + * Copies he values of this matrix into the provided array-like. + * @param array array-like to store the matrix to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(array?: ArrayLike, offset?: number): ArrayLike; + + /** + * Multiplies this matrix by m. + */ + multiply(m: Matrix3): Matrix3; + + premultiply(m: Matrix3): Matrix3; + + /** + * Sets this matrix to a x b. + */ + multiplyMatrices(a: Matrix3, b: Matrix3): Matrix3; + + /** + * @deprecated Use {@link Vector3.applyMatrix3 vector.applyMatrix3( matrix )} instead. + */ + multiplyVector3(vector: Vector3): any; + + /** + * @deprecated This method has been removed completely. + */ + multiplyVector3Array(a: any): any; + + /** + * @deprecated Use {@link Matrix3#invert .invert()} instead. + */ + getInverse(matrix: Matrix4, throwOnDegenerate?: boolean): Matrix3; + getInverse(matrix: Matrix): Matrix; + + /** + * @deprecated Use {@link Matrix3#toArray .toArray()} instead. + */ + flattenToArrayOffset(array: number[], offset: number): number[]; +} diff --git a/backend/libs/three/math/Matrix3.js b/backend/libs/three/math/Matrix3.js new file mode 100644 index 0000000000000000000000000000000000000000..6a60b2c679206e17605e7837e6ce7c90b58e190f --- /dev/null +++ b/backend/libs/three/math/Matrix3.js @@ -0,0 +1,320 @@ +class Matrix3 { + constructor() { + this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + + if (arguments.length > 0) { + console.error('THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.'); + } + } + + set(n11, n12, n13, n21, n22, n23, n31, n32, n33) { + const te = this.elements; + + te[0] = n11; + te[1] = n21; + te[2] = n31; + te[3] = n12; + te[4] = n22; + te[5] = n32; + te[6] = n13; + te[7] = n23; + te[8] = n33; + + return this; + } + + identity() { + this.set(1, 0, 0, 0, 1, 0, 0, 0, 1); + + return this; + } + + copy(m) { + const te = this.elements; + const me = m.elements; + + te[0] = me[0]; + te[1] = me[1]; + te[2] = me[2]; + te[3] = me[3]; + te[4] = me[4]; + te[5] = me[5]; + te[6] = me[6]; + te[7] = me[7]; + te[8] = me[8]; + + return this; + } + + extractBasis(xAxis, yAxis, zAxis) { + xAxis.setFromMatrix3Column(this, 0); + yAxis.setFromMatrix3Column(this, 1); + zAxis.setFromMatrix3Column(this, 2); + + return this; + } + + setFromMatrix4(m) { + const me = m.elements; + + this.set(me[0], me[4], me[8], me[1], me[5], me[9], me[2], me[6], me[10]); + + return this; + } + + multiply(m) { + return this.multiplyMatrices(this, m); + } + + premultiply(m) { + return this.multiplyMatrices(m, this); + } + + multiplyMatrices(a, b) { + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[0], + a12 = ae[3], + a13 = ae[6]; + const a21 = ae[1], + a22 = ae[4], + a23 = ae[7]; + const a31 = ae[2], + a32 = ae[5], + a33 = ae[8]; + + const b11 = be[0], + b12 = be[3], + b13 = be[6]; + const b21 = be[1], + b22 = be[4], + b23 = be[7]; + const b31 = be[2], + b32 = be[5], + b33 = be[8]; + + te[0] = a11 * b11 + a12 * b21 + a13 * b31; + te[3] = a11 * b12 + a12 * b22 + a13 * b32; + te[6] = a11 * b13 + a12 * b23 + a13 * b33; + + te[1] = a21 * b11 + a22 * b21 + a23 * b31; + te[4] = a21 * b12 + a22 * b22 + a23 * b32; + te[7] = a21 * b13 + a22 * b23 + a23 * b33; + + te[2] = a31 * b11 + a32 * b21 + a33 * b31; + te[5] = a31 * b12 + a32 * b22 + a33 * b32; + te[8] = a31 * b13 + a32 * b23 + a33 * b33; + + return this; + } + + multiplyScalar(s) { + const te = this.elements; + + te[0] *= s; + te[3] *= s; + te[6] *= s; + te[1] *= s; + te[4] *= s; + te[7] *= s; + te[2] *= s; + te[5] *= s; + te[8] *= s; + + return this; + } + + determinant() { + const te = this.elements; + + const a = te[0], + b = te[1], + c = te[2], + d = te[3], + e = te[4], + f = te[5], + g = te[6], + h = te[7], + i = te[8]; + + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; + } + + invert() { + const te = this.elements, + n11 = te[0], + n21 = te[1], + n31 = te[2], + n12 = te[3], + n22 = te[4], + n32 = te[5], + n13 = te[6], + n23 = te[7], + n33 = te[8], + t11 = n33 * n22 - n32 * n23, + t12 = n32 * n13 - n33 * n12, + t13 = n23 * n12 - n22 * n13, + det = n11 * t11 + n21 * t12 + n31 * t13; + + if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); + + const detInv = 1 / det; + + te[0] = t11 * detInv; + te[1] = (n31 * n23 - n33 * n21) * detInv; + te[2] = (n32 * n21 - n31 * n22) * detInv; + + te[3] = t12 * detInv; + te[4] = (n33 * n11 - n31 * n13) * detInv; + te[5] = (n31 * n12 - n32 * n11) * detInv; + + te[6] = t13 * detInv; + te[7] = (n21 * n13 - n23 * n11) * detInv; + te[8] = (n22 * n11 - n21 * n12) * detInv; + + return this; + } + + transpose() { + let tmp; + const m = this.elements; + + tmp = m[1]; + m[1] = m[3]; + m[3] = tmp; + tmp = m[2]; + m[2] = m[6]; + m[6] = tmp; + tmp = m[5]; + m[5] = m[7]; + m[7] = tmp; + + return this; + } + + getNormalMatrix(matrix4) { + return this.setFromMatrix4(matrix4).invert().transpose(); + } + + transposeIntoArray(r) { + const m = this.elements; + + r[0] = m[0]; + r[1] = m[3]; + r[2] = m[6]; + r[3] = m[1]; + r[4] = m[4]; + r[5] = m[7]; + r[6] = m[2]; + r[7] = m[5]; + r[8] = m[8]; + + return this; + } + + setUvTransform(tx, ty, sx, sy, rotation, cx, cy) { + const c = Math.cos(rotation); + const s = Math.sin(rotation); + + this.set(sx * c, sx * s, -sx * (c * cx + s * cy) + cx + tx, -sy * s, sy * c, -sy * (-s * cx + c * cy) + cy + ty, 0, 0, 1); + + return this; + } + + scale(sx, sy) { + const te = this.elements; + + te[0] *= sx; + te[3] *= sx; + te[6] *= sx; + te[1] *= sy; + te[4] *= sy; + te[7] *= sy; + + return this; + } + + rotate(theta) { + const c = Math.cos(theta); + const s = Math.sin(theta); + + const te = this.elements; + + const a11 = te[0], + a12 = te[3], + a13 = te[6]; + const a21 = te[1], + a22 = te[4], + a23 = te[7]; + + te[0] = c * a11 + s * a21; + te[3] = c * a12 + s * a22; + te[6] = c * a13 + s * a23; + + te[1] = -s * a11 + c * a21; + te[4] = -s * a12 + c * a22; + te[7] = -s * a13 + c * a23; + + return this; + } + + translate(tx, ty) { + const te = this.elements; + + te[0] += tx * te[2]; + te[3] += tx * te[5]; + te[6] += tx * te[8]; + te[1] += ty * te[2]; + te[4] += ty * te[5]; + te[7] += ty * te[8]; + + return this; + } + + equals(matrix) { + const te = this.elements; + const me = matrix.elements; + + for (let i = 0; i < 9; i++) { + if (te[i] !== me[i]) return false; + } + + return true; + } + + fromArray(array, offset = 0) { + for (let i = 0; i < 9; i++) { + this.elements[i] = array[i + offset]; + } + + return this; + } + + toArray(array = [], offset = 0) { + const te = this.elements; + + array[offset] = te[0]; + array[offset + 1] = te[1]; + array[offset + 2] = te[2]; + + array[offset + 3] = te[3]; + array[offset + 4] = te[4]; + array[offset + 5] = te[5]; + + array[offset + 6] = te[6]; + array[offset + 7] = te[7]; + array[offset + 8] = te[8]; + + return array; + } + + clone() { + return new this.constructor().fromArray(this.elements); + } +} + +Matrix3.prototype.isMatrix3 = true; + +export { Matrix3 }; diff --git a/backend/libs/three/math/Matrix4.d.ts b/backend/libs/three/math/Matrix4.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b5a2b3912c5823631981c3befe1dff7ae6008e09 --- /dev/null +++ b/backend/libs/three/math/Matrix4.d.ts @@ -0,0 +1,274 @@ +import { Vector3 } from './Vector3'; +import { Euler } from './Euler'; +import { Quaternion } from './Quaternion'; +import { Matrix, Matrix3 } from './Matrix3'; + +export type Matrix4Tuple = [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]; + +/** + * A 4x4 Matrix. + * + * @example + * // Simple rig for rotating around 3 axes + * const m = new THREE.Matrix4(); + * const m1 = new THREE.Matrix4(); + * const m2 = new THREE.Matrix4(); + * const m3 = new THREE.Matrix4(); + * const alpha = 0; + * const beta = Math.PI; + * const gamma = Math.PI/2; + * m1.makeRotationX( alpha ); + * m2.makeRotationY( beta ); + * m3.makeRotationZ( gamma ); + * m.multiplyMatrices( m1, m2 ); + * m.multiply( m3 ); + */ +export class Matrix4 implements Matrix { + constructor(); + + /** + * Array with matrix values. + * @default [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] + */ + elements: number[]; + + /** + * Sets all fields of this matrix. + */ + set( + n11: number, + n12: number, + n13: number, + n14: number, + n21: number, + n22: number, + n23: number, + n24: number, + n31: number, + n32: number, + n33: number, + n34: number, + n41: number, + n42: number, + n43: number, + n44: number + ): Matrix4; + + /** + * Resets this matrix to identity. + */ + identity(): Matrix4; + clone(): Matrix4; + copy(m: Matrix4): this; + copyPosition(m: Matrix4): Matrix4; + extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; + makeBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; + + /** + * Copies the rotation component of the supplied matrix m into this matrix rotation component. + */ + extractRotation(m: Matrix4): Matrix4; + makeRotationFromEuler(euler: Euler): Matrix4; + makeRotationFromQuaternion(q: Quaternion): Matrix4; + /** + * Constructs a rotation matrix, looking from eye towards center with defined up vector. + */ + lookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix4; + + /** + * Multiplies this matrix by m. + */ + multiply(m: Matrix4): Matrix4; + + premultiply(m: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b. + */ + multiplyMatrices(a: Matrix4, b: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b and stores the result into the flat array r. + * r can be either a regular Array or a TypedArray. + * + * @deprecated This method has been removed completely. + */ + multiplyToArray(a: Matrix4, b: Matrix4, r: number[]): Matrix4; + + /** + * Multiplies this matrix by s. + */ + multiplyScalar(s: number): Matrix4; + + /** + * Computes determinant of this matrix. + * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + */ + determinant(): number; + + /** + * Transposes this matrix. + */ + transpose(): Matrix4; + + /** + * Sets the position component for this matrix from vector v. + */ + setPosition(v: Vector3 | number, y?: number, z?: number): Matrix4; + + /** + * Inverts this matrix. + */ + invert(): Matrix4; + + /** + * Multiplies the columns of this matrix by vector v. + */ + scale(v: Vector3): Matrix4; + + getMaxScaleOnAxis(): number; + /** + * Sets this matrix as translation transform. + */ + makeTranslation(x: number, y: number, z: number): Matrix4; + + /** + * Sets this matrix as rotation transform around x axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationX(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around y axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationY(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around z axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationZ(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around axis by angle radians. + * Based on http://www.gamedev.net/reference/articles/article1199.asp. + * + * @param axis Rotation axis. + * @param theta Rotation angle in radians. + */ + makeRotationAxis(axis: Vector3, angle: number): Matrix4; + + /** + * Sets this matrix as scale transform. + */ + makeScale(x: number, y: number, z: number): Matrix4; + + /** + * Sets this matrix as shear transform. + */ + makeShear(xy: number, xz: number, yx: number, yz: number, zx: number, zy: number): Matrix4; + + /** + * Sets this matrix to the transformation composed of translation, rotation and scale. + */ + compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; + + /** + * Decomposes this matrix into it's position, quaternion and scale components. + */ + decompose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; + + /** + * Creates a frustum matrix. + */ + makePerspective(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4; + + /** + * Creates a perspective projection matrix. + */ + makePerspective(fov: number, aspect: number, near: number, far: number): Matrix4; + + /** + * Creates an orthographic projection matrix. + */ + makeOrthographic(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4; + equals(matrix: Matrix4): boolean; + + /** + * Sets the values of this matrix from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array-like. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): Matrix4; + + /** + * Returns an array with the values of this matrix, or copies them into the provided array. + * @param array (optional) array to store the matrix to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + toArray(array?: Matrix4Tuple, offset?: 0): Matrix4Tuple; + + /** + * Copies he values of this matrix into the provided array-like. + * @param array array-like to store the matrix to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(array?: ArrayLike, offset?: number): ArrayLike; + + /** + * Set the upper 3x3 elements of this matrix to the values of the Matrix3 m. + */ + setFromMatrix3(m: Matrix3): Matrix4; + + /** + * @deprecated Use {@link Matrix4#copyPosition .copyPosition()} instead. + */ + extractPosition(m: Matrix4): Matrix4; + + /** + * @deprecated Use {@link Matrix4#makeRotationFromQuaternion .makeRotationFromQuaternion()} instead. + */ + setRotationFromQuaternion(q: Quaternion): Matrix4; + + /** + * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + multiplyVector3(v: any): any; + + /** + * @deprecated Use {@link Vector4#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + multiplyVector4(v: any): any; + + /** + * @deprecated This method has been removed completely. + */ + multiplyVector3Array(array: number[]): number[]; + + /** + * @deprecated Use {@link Vector3#transformDirection Vector3.transformDirection( matrix )} instead. + */ + rotateAxis(v: any): void; + + /** + * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + crossVector(v: any): void; + + /** + * @deprecated Use {@link Matrix4#toArray .toArray()} instead. + */ + flattenToArrayOffset(array: number[], offset: number): number[]; + + /** + * @deprecated Use {@link Matrix4#invert .invert()} instead. + */ + getInverse(matrix: Matrix): Matrix; +} diff --git a/backend/libs/three/math/Matrix4.js b/backend/libs/three/math/Matrix4.js new file mode 100644 index 0000000000000000000000000000000000000000..ed62c7215e7bbe7d59524e508f4a3cf6c1158460 --- /dev/null +++ b/backend/libs/three/math/Matrix4.js @@ -0,0 +1,863 @@ +import { Vector3 } from './Vector3.js'; + +class Matrix4 { + constructor() { + this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + + if (arguments.length > 0) { + console.error('THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.'); + } + } + + set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) { + const te = this.elements; + + te[0] = n11; + te[4] = n12; + te[8] = n13; + te[12] = n14; + te[1] = n21; + te[5] = n22; + te[9] = n23; + te[13] = n24; + te[2] = n31; + te[6] = n32; + te[10] = n33; + te[14] = n34; + te[3] = n41; + te[7] = n42; + te[11] = n43; + te[15] = n44; + + return this; + } + + identity() { + this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + + return this; + } + + clone() { + return new Matrix4().fromArray(this.elements); + } + + copy(m) { + const te = this.elements; + const me = m.elements; + + te[0] = me[0]; + te[1] = me[1]; + te[2] = me[2]; + te[3] = me[3]; + te[4] = me[4]; + te[5] = me[5]; + te[6] = me[6]; + te[7] = me[7]; + te[8] = me[8]; + te[9] = me[9]; + te[10] = me[10]; + te[11] = me[11]; + te[12] = me[12]; + te[13] = me[13]; + te[14] = me[14]; + te[15] = me[15]; + + return this; + } + + copyPosition(m) { + const te = this.elements, + me = m.elements; + + te[12] = me[12]; + te[13] = me[13]; + te[14] = me[14]; + + return this; + } + + setFromMatrix3(m) { + const me = m.elements; + + this.set(me[0], me[3], me[6], 0, me[1], me[4], me[7], 0, me[2], me[5], me[8], 0, 0, 0, 0, 1); + + return this; + } + + extractBasis(xAxis, yAxis, zAxis) { + xAxis.setFromMatrixColumn(this, 0); + yAxis.setFromMatrixColumn(this, 1); + zAxis.setFromMatrixColumn(this, 2); + + return this; + } + + makeBasis(xAxis, yAxis, zAxis) { + this.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1); + + return this; + } + + extractRotation(m) { + // this method does not support reflection matrices + + const te = this.elements; + const me = m.elements; + + const scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length(); + const scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length(); + const scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length(); + + te[0] = me[0] * scaleX; + te[1] = me[1] * scaleX; + te[2] = me[2] * scaleX; + te[3] = 0; + + te[4] = me[4] * scaleY; + te[5] = me[5] * scaleY; + te[6] = me[6] * scaleY; + te[7] = 0; + + te[8] = me[8] * scaleZ; + te[9] = me[9] * scaleZ; + te[10] = me[10] * scaleZ; + te[11] = 0; + + te[12] = 0; + te[13] = 0; + te[14] = 0; + te[15] = 1; + + return this; + } + + makeRotationFromEuler(euler) { + if (!(euler && euler.isEuler)) { + console.error('THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.'); + } + + const te = this.elements; + + const x = euler.x, + y = euler.y, + z = euler.z; + const a = Math.cos(x), + b = Math.sin(x); + const c = Math.cos(y), + d = Math.sin(y); + const e = Math.cos(z), + f = Math.sin(z); + + if (euler.order === 'XYZ') { + const ae = a * e, + af = a * f, + be = b * e, + bf = b * f; + + te[0] = c * e; + te[4] = -c * f; + te[8] = d; + + te[1] = af + be * d; + te[5] = ae - bf * d; + te[9] = -b * c; + + te[2] = bf - ae * d; + te[6] = be + af * d; + te[10] = a * c; + } else if (euler.order === 'YXZ') { + const ce = c * e, + cf = c * f, + de = d * e, + df = d * f; + + te[0] = ce + df * b; + te[4] = de * b - cf; + te[8] = a * d; + + te[1] = a * f; + te[5] = a * e; + te[9] = -b; + + te[2] = cf * b - de; + te[6] = df + ce * b; + te[10] = a * c; + } else if (euler.order === 'ZXY') { + const ce = c * e, + cf = c * f, + de = d * e, + df = d * f; + + te[0] = ce - df * b; + te[4] = -a * f; + te[8] = de + cf * b; + + te[1] = cf + de * b; + te[5] = a * e; + te[9] = df - ce * b; + + te[2] = -a * d; + te[6] = b; + te[10] = a * c; + } else if (euler.order === 'ZYX') { + const ae = a * e, + af = a * f, + be = b * e, + bf = b * f; + + te[0] = c * e; + te[4] = be * d - af; + te[8] = ae * d + bf; + + te[1] = c * f; + te[5] = bf * d + ae; + te[9] = af * d - be; + + te[2] = -d; + te[6] = b * c; + te[10] = a * c; + } else if (euler.order === 'YZX') { + const ac = a * c, + ad = a * d, + bc = b * c, + bd = b * d; + + te[0] = c * e; + te[4] = bd - ac * f; + te[8] = bc * f + ad; + + te[1] = f; + te[5] = a * e; + te[9] = -b * e; + + te[2] = -d * e; + te[6] = ad * f + bc; + te[10] = ac - bd * f; + } else if (euler.order === 'XZY') { + const ac = a * c, + ad = a * d, + bc = b * c, + bd = b * d; + + te[0] = c * e; + te[4] = -f; + te[8] = d * e; + + te[1] = ac * f + bd; + te[5] = a * e; + te[9] = ad * f - bc; + + te[2] = bc * f - ad; + te[6] = b * e; + te[10] = bd * f + ac; + } + + // bottom row + te[3] = 0; + te[7] = 0; + te[11] = 0; + + // last column + te[12] = 0; + te[13] = 0; + te[14] = 0; + te[15] = 1; + + return this; + } + + makeRotationFromQuaternion(q) { + return this.compose(_zero, q, _one); + } + + lookAt(eye, target, up) { + const te = this.elements; + + _z.subVectors(eye, target); + + if (_z.lengthSq() === 0) { + // eye and target are in the same position + + _z.z = 1; + } + + _z.normalize(); + _x.crossVectors(up, _z); + + if (_x.lengthSq() === 0) { + // up and z are parallel + + if (Math.abs(up.z) === 1) { + _z.x += 0.0001; + } else { + _z.z += 0.0001; + } + + _z.normalize(); + _x.crossVectors(up, _z); + } + + _x.normalize(); + _y.crossVectors(_z, _x); + + te[0] = _x.x; + te[4] = _y.x; + te[8] = _z.x; + te[1] = _x.y; + te[5] = _y.y; + te[9] = _z.y; + te[2] = _x.z; + te[6] = _y.z; + te[10] = _z.z; + + return this; + } + + multiply(m, n) { + if (n !== undefined) { + console.warn('THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.'); + return this.multiplyMatrices(m, n); + } + + return this.multiplyMatrices(this, m); + } + + premultiply(m) { + return this.multiplyMatrices(m, this); + } + + multiplyMatrices(a, b) { + const ae = a.elements; + const be = b.elements; + const te = this.elements; + + const a11 = ae[0], + a12 = ae[4], + a13 = ae[8], + a14 = ae[12]; + const a21 = ae[1], + a22 = ae[5], + a23 = ae[9], + a24 = ae[13]; + const a31 = ae[2], + a32 = ae[6], + a33 = ae[10], + a34 = ae[14]; + const a41 = ae[3], + a42 = ae[7], + a43 = ae[11], + a44 = ae[15]; + + const b11 = be[0], + b12 = be[4], + b13 = be[8], + b14 = be[12]; + const b21 = be[1], + b22 = be[5], + b23 = be[9], + b24 = be[13]; + const b31 = be[2], + b32 = be[6], + b33 = be[10], + b34 = be[14]; + const b41 = be[3], + b42 = be[7], + b43 = be[11], + b44 = be[15]; + + te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; + te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; + te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; + te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; + + te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; + te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; + te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; + te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; + + te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; + te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; + te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; + te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; + + te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; + te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; + te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; + te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + + return this; + } + + multiplyScalar(s) { + const te = this.elements; + + te[0] *= s; + te[4] *= s; + te[8] *= s; + te[12] *= s; + te[1] *= s; + te[5] *= s; + te[9] *= s; + te[13] *= s; + te[2] *= s; + te[6] *= s; + te[10] *= s; + te[14] *= s; + te[3] *= s; + te[7] *= s; + te[11] *= s; + te[15] *= s; + + return this; + } + + determinant() { + const te = this.elements; + + const n11 = te[0], + n12 = te[4], + n13 = te[8], + n14 = te[12]; + const n21 = te[1], + n22 = te[5], + n23 = te[9], + n24 = te[13]; + const n31 = te[2], + n32 = te[6], + n33 = te[10], + n34 = te[14]; + const n41 = te[3], + n42 = te[7], + n43 = te[11], + n44 = te[15]; + + //TODO: make this more efficient + //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm ) + + return ( + n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31) + ); + } + + transpose() { + const te = this.elements; + let tmp; + + tmp = te[1]; + te[1] = te[4]; + te[4] = tmp; + tmp = te[2]; + te[2] = te[8]; + te[8] = tmp; + tmp = te[6]; + te[6] = te[9]; + te[9] = tmp; + + tmp = te[3]; + te[3] = te[12]; + te[12] = tmp; + tmp = te[7]; + te[7] = te[13]; + te[13] = tmp; + tmp = te[11]; + te[11] = te[14]; + te[14] = tmp; + + return this; + } + + setPosition(x, y, z) { + const te = this.elements; + + if (x.isVector3) { + te[12] = x.x; + te[13] = x.y; + te[14] = x.z; + } else { + te[12] = x; + te[13] = y; + te[14] = z; + } + + return this; + } + + invert() { + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + const te = this.elements, + n11 = te[0], + n21 = te[1], + n31 = te[2], + n41 = te[3], + n12 = te[4], + n22 = te[5], + n32 = te[6], + n42 = te[7], + n13 = te[8], + n23 = te[9], + n33 = te[10], + n43 = te[11], + n14 = te[12], + n24 = te[13], + n34 = te[14], + n44 = te[15], + t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44, + t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44, + t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44, + t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34; + + const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14; + + if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + const detInv = 1 / det; + + te[0] = t11 * detInv; + te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv; + te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv; + te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv; + + te[4] = t12 * detInv; + te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv; + te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv; + te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv; + + te[8] = t13 * detInv; + te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv; + te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv; + te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv; + + te[12] = t14 * detInv; + te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv; + te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv; + te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv; + + return this; + } + + scale(v) { + const te = this.elements; + const x = v.x, + y = v.y, + z = v.z; + + te[0] *= x; + te[4] *= y; + te[8] *= z; + te[1] *= x; + te[5] *= y; + te[9] *= z; + te[2] *= x; + te[6] *= y; + te[10] *= z; + te[3] *= x; + te[7] *= y; + te[11] *= z; + + return this; + } + + getMaxScaleOnAxis() { + const te = this.elements; + + const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2]; + const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6]; + const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10]; + + return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq)); + } + + makeTranslation(x, y, z) { + this.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1); + + return this; + } + + makeRotationX(theta) { + const c = Math.cos(theta), + s = Math.sin(theta); + + this.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1); + + return this; + } + + makeRotationY(theta) { + const c = Math.cos(theta), + s = Math.sin(theta); + + this.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1); + + return this; + } + + makeRotationZ(theta) { + const c = Math.cos(theta), + s = Math.sin(theta); + + this.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); + + return this; + } + + makeRotationAxis(axis, angle) { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + const c = Math.cos(angle); + const s = Math.sin(angle); + const t = 1 - c; + const x = axis.x, + y = axis.y, + z = axis.z; + const tx = t * x, + ty = t * y; + + this.set( + tx * x + c, + tx * y - s * z, + tx * z + s * y, + 0, + tx * y + s * z, + ty * y + c, + ty * z - s * x, + 0, + tx * z - s * y, + ty * z + s * x, + t * z * z + c, + 0, + 0, + 0, + 0, + 1 + ); + + return this; + } + + makeScale(x, y, z) { + this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1); + + return this; + } + + makeShear(xy, xz, yx, yz, zx, zy) { + this.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1); + + return this; + } + + compose(position, quaternion, scale) { + const te = this.elements; + + const x = quaternion._x, + y = quaternion._y, + z = quaternion._z, + w = quaternion._w; + const x2 = x + x, + y2 = y + y, + z2 = z + z; + const xx = x * x2, + xy = x * y2, + xz = x * z2; + const yy = y * y2, + yz = y * z2, + zz = z * z2; + const wx = w * x2, + wy = w * y2, + wz = w * z2; + + const sx = scale.x, + sy = scale.y, + sz = scale.z; + + te[0] = (1 - (yy + zz)) * sx; + te[1] = (xy + wz) * sx; + te[2] = (xz - wy) * sx; + te[3] = 0; + + te[4] = (xy - wz) * sy; + te[5] = (1 - (xx + zz)) * sy; + te[6] = (yz + wx) * sy; + te[7] = 0; + + te[8] = (xz + wy) * sz; + te[9] = (yz - wx) * sz; + te[10] = (1 - (xx + yy)) * sz; + te[11] = 0; + + te[12] = position.x; + te[13] = position.y; + te[14] = position.z; + te[15] = 1; + + return this; + } + + decompose(position, quaternion, scale) { + const te = this.elements; + + let sx = _v1.set(te[0], te[1], te[2]).length(); + const sy = _v1.set(te[4], te[5], te[6]).length(); + const sz = _v1.set(te[8], te[9], te[10]).length(); + + // if determine is negative, we need to invert one scale + const det = this.determinant(); + if (det < 0) sx = -sx; + + position.x = te[12]; + position.y = te[13]; + position.z = te[14]; + + // scale the rotation part + _m1.copy(this); + + const invSX = 1 / sx; + const invSY = 1 / sy; + const invSZ = 1 / sz; + + _m1.elements[0] *= invSX; + _m1.elements[1] *= invSX; + _m1.elements[2] *= invSX; + + _m1.elements[4] *= invSY; + _m1.elements[5] *= invSY; + _m1.elements[6] *= invSY; + + _m1.elements[8] *= invSZ; + _m1.elements[9] *= invSZ; + _m1.elements[10] *= invSZ; + + quaternion.setFromRotationMatrix(_m1); + + scale.x = sx; + scale.y = sy; + scale.z = sz; + + return this; + } + + makePerspective(left, right, top, bottom, near, far) { + if (far === undefined) { + console.warn('THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.'); + } + + const te = this.elements; + const x = (2 * near) / (right - left); + const y = (2 * near) / (top - bottom); + + const a = (right + left) / (right - left); + const b = (top + bottom) / (top - bottom); + const c = -(far + near) / (far - near); + const d = (-2 * far * near) / (far - near); + + te[0] = x; + te[4] = 0; + te[8] = a; + te[12] = 0; + te[1] = 0; + te[5] = y; + te[9] = b; + te[13] = 0; + te[2] = 0; + te[6] = 0; + te[10] = c; + te[14] = d; + te[3] = 0; + te[7] = 0; + te[11] = -1; + te[15] = 0; + + return this; + } + + makeOrthographic(left, right, top, bottom, near, far) { + const te = this.elements; + const w = 1.0 / (right - left); + const h = 1.0 / (top - bottom); + const p = 1.0 / (far - near); + + const x = (right + left) * w; + const y = (top + bottom) * h; + const z = (far + near) * p; + + te[0] = 2 * w; + te[4] = 0; + te[8] = 0; + te[12] = -x; + te[1] = 0; + te[5] = 2 * h; + te[9] = 0; + te[13] = -y; + te[2] = 0; + te[6] = 0; + te[10] = -2 * p; + te[14] = -z; + te[3] = 0; + te[7] = 0; + te[11] = 0; + te[15] = 1; + + return this; + } + + equals(matrix) { + const te = this.elements; + const me = matrix.elements; + + for (let i = 0; i < 16; i++) { + if (te[i] !== me[i]) return false; + } + + return true; + } + + fromArray(array, offset = 0) { + for (let i = 0; i < 16; i++) { + this.elements[i] = array[i + offset]; + } + + return this; + } + + toArray(array = [], offset = 0) { + const te = this.elements; + + array[offset] = te[0]; + array[offset + 1] = te[1]; + array[offset + 2] = te[2]; + array[offset + 3] = te[3]; + + array[offset + 4] = te[4]; + array[offset + 5] = te[5]; + array[offset + 6] = te[6]; + array[offset + 7] = te[7]; + + array[offset + 8] = te[8]; + array[offset + 9] = te[9]; + array[offset + 10] = te[10]; + array[offset + 11] = te[11]; + + array[offset + 12] = te[12]; + array[offset + 13] = te[13]; + array[offset + 14] = te[14]; + array[offset + 15] = te[15]; + + return array; + } +} + +Matrix4.prototype.isMatrix4 = true; + +const _v1 = /*@__PURE__*/ new Vector3(); +const _m1 = /*@__PURE__*/ new Matrix4(); +const _zero = /*@__PURE__*/ new Vector3(0, 0, 0); +const _one = /*@__PURE__*/ new Vector3(1, 1, 1); +const _x = /*@__PURE__*/ new Vector3(); +const _y = /*@__PURE__*/ new Vector3(); +const _z = /*@__PURE__*/ new Vector3(); + +export { Matrix4 }; diff --git a/backend/libs/three/math/Plane.d.ts b/backend/libs/three/math/Plane.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3560d627031f0070374f5cf33e2c739d21bd1b06 --- /dev/null +++ b/backend/libs/three/math/Plane.d.ts @@ -0,0 +1,47 @@ +import { Vector3 } from './Vector3'; +import { Sphere } from './Sphere'; +import { Line3 } from './Line3'; +import { Box3 } from './Box3'; +import { Matrix4 } from './Matrix4'; +import { Matrix3 } from './Matrix3'; + +export class Plane { + constructor(normal?: Vector3, constant?: number); + + /** + * @default new THREE.Vector3( 1, 0, 0 ) + */ + normal: Vector3; + + /** + * @default 0 + */ + constant: number; + + readonly isPlane: true; + + set(normal: Vector3, constant: number): Plane; + setComponents(x: number, y: number, z: number, w: number): Plane; + setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; + setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; + clone(): this; + copy(plane: Plane): this; + normalize(): Plane; + negate(): Plane; + distanceToPoint(point: Vector3): number; + distanceToSphere(sphere: Sphere): number; + projectPoint(point: Vector3, target: Vector3): Vector3; + intersectLine(line: Line3, target: Vector3): Vector3 | null; + intersectsLine(line: Line3): boolean; + intersectsBox(box: Box3): boolean; + intersectsSphere(sphere: Sphere): boolean; + coplanarPoint(target: Vector3): Vector3; + applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; + translate(offset: Vector3): Plane; + equals(plane: Plane): boolean; + + /** + * @deprecated Use {@link Plane#intersectsLine .intersectsLine()} instead. + */ + isIntersectionLine(l: any): any; +} diff --git a/backend/libs/three/math/Plane.js b/backend/libs/three/math/Plane.js new file mode 100644 index 0000000000000000000000000000000000000000..7d14949b96e091c6e6d45c52c72659089aaf85d3 --- /dev/null +++ b/backend/libs/three/math/Plane.js @@ -0,0 +1,157 @@ +import { Matrix3 } from './Matrix3.js'; +import { Vector3 } from './Vector3.js'; + +const _vector1 = /*@__PURE__*/ new Vector3(); +const _vector2 = /*@__PURE__*/ new Vector3(); +const _normalMatrix = /*@__PURE__*/ new Matrix3(); + +class Plane { + constructor(normal = new Vector3(1, 0, 0), constant = 0) { + // normal is assumed to be normalized + + this.normal = normal; + this.constant = constant; + } + + set(normal, constant) { + this.normal.copy(normal); + this.constant = constant; + + return this; + } + + setComponents(x, y, z, w) { + this.normal.set(x, y, z); + this.constant = w; + + return this; + } + + setFromNormalAndCoplanarPoint(normal, point) { + this.normal.copy(normal); + this.constant = -point.dot(this.normal); + + return this; + } + + setFromCoplanarPoints(a, b, c) { + const normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize(); + + // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? + + this.setFromNormalAndCoplanarPoint(normal, a); + + return this; + } + + copy(plane) { + this.normal.copy(plane.normal); + this.constant = plane.constant; + + return this; + } + + normalize() { + // Note: will lead to a divide by zero if the plane is invalid. + + const inverseNormalLength = 1.0 / this.normal.length(); + this.normal.multiplyScalar(inverseNormalLength); + this.constant *= inverseNormalLength; + + return this; + } + + negate() { + this.constant *= -1; + this.normal.negate(); + + return this; + } + + distanceToPoint(point) { + return this.normal.dot(point) + this.constant; + } + + distanceToSphere(sphere) { + return this.distanceToPoint(sphere.center) - sphere.radius; + } + + projectPoint(point, target) { + return target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point); + } + + intersectLine(line, target) { + const direction = line.delta(_vector1); + + const denominator = this.normal.dot(direction); + + if (denominator === 0) { + // line is coplanar, return origin + if (this.distanceToPoint(line.start) === 0) { + return target.copy(line.start); + } + + // Unsure if this is the correct method to handle this case. + return null; + } + + const t = -(line.start.dot(this.normal) + this.constant) / denominator; + + if (t < 0 || t > 1) { + return null; + } + + return target.copy(direction).multiplyScalar(t).add(line.start); + } + + intersectsLine(line) { + // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it. + + const startSign = this.distanceToPoint(line.start); + const endSign = this.distanceToPoint(line.end); + + return (startSign < 0 && endSign > 0) || (endSign < 0 && startSign > 0); + } + + intersectsBox(box) { + return box.intersectsPlane(this); + } + + intersectsSphere(sphere) { + return sphere.intersectsPlane(this); + } + + coplanarPoint(target) { + return target.copy(this.normal).multiplyScalar(-this.constant); + } + + applyMatrix4(matrix, optionalNormalMatrix) { + const normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix); + + const referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix); + + const normal = this.normal.applyMatrix3(normalMatrix).normalize(); + + this.constant = -referencePoint.dot(normal); + + return this; + } + + translate(offset) { + this.constant -= offset.dot(this.normal); + + return this; + } + + equals(plane) { + return plane.normal.equals(this.normal) && plane.constant === this.constant; + } + + clone() { + return new this.constructor().copy(this); + } +} + +Plane.prototype.isPlane = true; + +export { Plane }; diff --git a/backend/libs/three/math/Quaternion.d.ts b/backend/libs/three/math/Quaternion.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c22438eafd8baba81c87c8513c9668bdad28f61 --- /dev/null +++ b/backend/libs/three/math/Quaternion.d.ts @@ -0,0 +1,162 @@ +import { Euler } from './Euler'; +import { Vector3 } from './Vector3'; +import { Matrix4 } from './Matrix4'; + +/** + * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages. + * + * @example + * const quaternion = new THREE.Quaternion(); + * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); + * const vector = new THREE.Vector3( 1, 0, 0 ); + * vector.applyQuaternion( quaternion ); + */ +export class Quaternion { + /** + * @param x x coordinate + * @param y y coordinate + * @param z z coordinate + * @param w w coordinate + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + /** + * @default 0 + */ + x: number; + + /** + * @default 0 + */ + y: number; + + /** + * @default 0 + */ + z: number; + + /** + * @default 1 + */ + w: number; + readonly isQuaternion: true; + + /** + * Sets values of this quaternion. + */ + set(x: number, y: number, z: number, w: number): Quaternion; + + /** + * Clones this quaternion. + */ + clone(): this; + + /** + * Copies values of q to this quaternion. + */ + copy(q: Quaternion): this; + + /** + * Sets this quaternion from rotation specified by Euler angles. + */ + setFromEuler(euler: Euler, update?: boolean): Quaternion; + + /** + * Sets this quaternion from rotation specified by axis and angle. + * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm. + * Axis have to be normalized, angle is in radians. + */ + setFromAxisAngle(axis: Vector3, angle: number): Quaternion; + + /** + * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm. + */ + setFromRotationMatrix(m: Matrix4): Quaternion; + setFromUnitVectors(vFrom: Vector3, vTo: Vector3): Quaternion; + angleTo(q: Quaternion): number; + rotateTowards(q: Quaternion, step: number): Quaternion; + + identity(): Quaternion; + + /** + * Inverts this quaternion. + */ + invert(): Quaternion; + + conjugate(): Quaternion; + dot(v: Quaternion): number; + lengthSq(): number; + + /** + * Computes length of this quaternion. + */ + length(): number; + + /** + * Normalizes this quaternion. + */ + normalize(): Quaternion; + + /** + * Multiplies this quaternion by b. + */ + multiply(q: Quaternion): Quaternion; + premultiply(q: Quaternion): Quaternion; + + /** + * Sets this quaternion to a x b + * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm. + */ + multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; + + slerp(qb: Quaternion, t: number): Quaternion; + slerpQuaternions(qa: Quaternion, qb: Quaternion, t: number): Quaternion; + equals(v: Quaternion): boolean; + + /** + * Sets this quaternion's x, y, z and w value from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array [x, y, z, w], or copies x, y, z and w into the provided array. + * @param array (optional) array to store the quaternion to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + + /** + * Copies x, y, z and w into the provided array-like. + * @param array array-like to store the quaternion to. + * @param offset (optional) optional offset into the array. + * @return The provided array-like. + */ + toArray(array: ArrayLike, offset?: number): ArrayLike; + + _onChange(callback: () => void): Quaternion; + _onChangeCallback: () => void; + + static slerpFlat(dst: number[], dstOffset: number, src0: number[], srcOffset: number, src1: number[], stcOffset1: number, t: number): Quaternion; + + static multiplyQuaternionsFlat(dst: number[], dstOffset: number, src0: number[], srcOffset: number, src1: number[], stcOffset1: number): number[]; + + /** + * @deprecated Use qm.slerpQuaternions( qa, qb, t ) instead.. + */ + static slerp(qa: Quaternion, qb: Quaternion, qm: Quaternion, t: number): number; + + /** + * @deprecated Use {@link Vector#applyQuaternion vector.applyQuaternion( quaternion )} instead. + */ + multiplyVector3(v: any): any; + + /** + * @deprecated Use {@link Quaternion#invert .invert()} instead. + */ + inverse(): Quaternion; + + random(): Quaternion; +} diff --git a/backend/libs/three/math/Quaternion.js b/backend/libs/three/math/Quaternion.js new file mode 100644 index 0000000000000000000000000000000000000000..1de4cc8d6cc210c132ab9eb070816e0fd8018b8d --- /dev/null +++ b/backend/libs/three/math/Quaternion.js @@ -0,0 +1,577 @@ +import * as MathUtils from './MathUtils.js'; + +class Quaternion { + constructor(x = 0, y = 0, z = 0, w = 1) { + this._x = x; + this._y = y; + this._z = z; + this._w = w; + } + + static slerp(qa, qb, qm, t) { + console.warn('THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.'); + return qm.slerpQuaternions(qa, qb, t); + } + + static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) { + // fuzz-free, array-based Quaternion SLERP operation + + let x0 = src0[srcOffset0 + 0], + y0 = src0[srcOffset0 + 1], + z0 = src0[srcOffset0 + 2], + w0 = src0[srcOffset0 + 3]; + + const x1 = src1[srcOffset1 + 0], + y1 = src1[srcOffset1 + 1], + z1 = src1[srcOffset1 + 2], + w1 = src1[srcOffset1 + 3]; + + if (t === 0) { + dst[dstOffset + 0] = x0; + dst[dstOffset + 1] = y0; + dst[dstOffset + 2] = z0; + dst[dstOffset + 3] = w0; + return; + } + + if (t === 1) { + dst[dstOffset + 0] = x1; + dst[dstOffset + 1] = y1; + dst[dstOffset + 2] = z1; + dst[dstOffset + 3] = w1; + return; + } + + if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) { + let s = 1 - t; + const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, + dir = cos >= 0 ? 1 : -1, + sqrSin = 1 - cos * cos; + + // Skip the Slerp for tiny steps to avoid numeric problems: + if (sqrSin > Number.EPSILON) { + const sin = Math.sqrt(sqrSin), + len = Math.atan2(sin, cos * dir); + + s = Math.sin(s * len) / sin; + t = Math.sin(t * len) / sin; + } + + const tDir = t * dir; + + x0 = x0 * s + x1 * tDir; + y0 = y0 * s + y1 * tDir; + z0 = z0 * s + z1 * tDir; + w0 = w0 * s + w1 * tDir; + + // Normalize in case we just did a lerp: + if (s === 1 - t) { + const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0); + + x0 *= f; + y0 *= f; + z0 *= f; + w0 *= f; + } + } + + dst[dstOffset] = x0; + dst[dstOffset + 1] = y0; + dst[dstOffset + 2] = z0; + dst[dstOffset + 3] = w0; + } + + static multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) { + const x0 = src0[srcOffset0]; + const y0 = src0[srcOffset0 + 1]; + const z0 = src0[srcOffset0 + 2]; + const w0 = src0[srcOffset0 + 3]; + + const x1 = src1[srcOffset1]; + const y1 = src1[srcOffset1 + 1]; + const z1 = src1[srcOffset1 + 2]; + const w1 = src1[srcOffset1 + 3]; + + dst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1; + dst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1; + dst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1; + dst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1; + + return dst; + } + + get x() { + return this._x; + } + + set x(value) { + this._x = value; + this._onChangeCallback(); + } + + get y() { + return this._y; + } + + set y(value) { + this._y = value; + this._onChangeCallback(); + } + + get z() { + return this._z; + } + + set z(value) { + this._z = value; + this._onChangeCallback(); + } + + get w() { + return this._w; + } + + set w(value) { + this._w = value; + this._onChangeCallback(); + } + + set(x, y, z, w) { + this._x = x; + this._y = y; + this._z = z; + this._w = w; + + this._onChangeCallback(); + + return this; + } + + clone() { + return new this.constructor(this._x, this._y, this._z, this._w); + } + + copy(quaternion) { + this._x = quaternion.x; + this._y = quaternion.y; + this._z = quaternion.z; + this._w = quaternion.w; + + this._onChangeCallback(); + + return this; + } + + setFromEuler(euler, update) { + if (!(euler && euler.isEuler)) { + throw new Error('THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.'); + } + + const x = euler._x, + y = euler._y, + z = euler._z, + order = euler._order; + + // http://www.mathworks.com/matlabcentral/fileexchange/ + // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ + // content/SpinCalc.m + + const cos = Math.cos; + const sin = Math.sin; + + const c1 = cos(x / 2); + const c2 = cos(y / 2); + const c3 = cos(z / 2); + + const s1 = sin(x / 2); + const s2 = sin(y / 2); + const s3 = sin(z / 2); + + switch (order) { + case 'XYZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'YXZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'ZXY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'ZYX': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + case 'YZX': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; + + case 'XZY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; + + default: + console.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order); + } + + if (update !== false) this._onChangeCallback(); + + return this; + } + + setFromAxisAngle(axis, angle) { + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + + // assumes axis is normalized + + const halfAngle = angle / 2, + s = Math.sin(halfAngle); + + this._x = axis.x * s; + this._y = axis.y * s; + this._z = axis.z * s; + this._w = Math.cos(halfAngle); + + this._onChangeCallback(); + + return this; + } + + setFromRotationMatrix(m) { + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + const te = m.elements, + m11 = te[0], + m12 = te[4], + m13 = te[8], + m21 = te[1], + m22 = te[5], + m23 = te[9], + m31 = te[2], + m32 = te[6], + m33 = te[10], + trace = m11 + m22 + m33; + + if (trace > 0) { + const s = 0.5 / Math.sqrt(trace + 1.0); + + this._w = 0.25 / s; + this._x = (m32 - m23) * s; + this._y = (m13 - m31) * s; + this._z = (m21 - m12) * s; + } else if (m11 > m22 && m11 > m33) { + const s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33); + + this._w = (m32 - m23) / s; + this._x = 0.25 * s; + this._y = (m12 + m21) / s; + this._z = (m13 + m31) / s; + } else if (m22 > m33) { + const s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33); + + this._w = (m13 - m31) / s; + this._x = (m12 + m21) / s; + this._y = 0.25 * s; + this._z = (m23 + m32) / s; + } else { + const s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22); + + this._w = (m21 - m12) / s; + this._x = (m13 + m31) / s; + this._y = (m23 + m32) / s; + this._z = 0.25 * s; + } + + this._onChangeCallback(); + + return this; + } + + setFromUnitVectors(vFrom, vTo) { + // assumes direction vectors vFrom and vTo are normalized + + let r = vFrom.dot(vTo) + 1; + + if (r < Number.EPSILON) { + // vFrom and vTo point in opposite directions + + r = 0; + + if (Math.abs(vFrom.x) > Math.abs(vFrom.z)) { + this._x = -vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; + } else { + this._x = 0; + this._y = -vFrom.z; + this._z = vFrom.y; + this._w = r; + } + } else { + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 + + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; + } + + return this.normalize(); + } + + angleTo(q) { + return 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1))); + } + + rotateTowards(q, step) { + const angle = this.angleTo(q); + + if (angle === 0) return this; + + const t = Math.min(1, step / angle); + + this.slerp(q, t); + + return this; + } + + identity() { + return this.set(0, 0, 0, 1); + } + + invert() { + // quaternion is assumed to have unit length + + return this.conjugate(); + } + + conjugate() { + this._x *= -1; + this._y *= -1; + this._z *= -1; + + this._onChangeCallback(); + + return this; + } + + dot(v) { + return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; + } + + lengthSq() { + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + } + + length() { + return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); + } + + normalize() { + let l = this.length(); + + if (l === 0) { + this._x = 0; + this._y = 0; + this._z = 0; + this._w = 1; + } else { + l = 1 / l; + + this._x = this._x * l; + this._y = this._y * l; + this._z = this._z * l; + this._w = this._w * l; + } + + this._onChangeCallback(); + + return this; + } + + multiply(q, p) { + if (p !== undefined) { + console.warn('THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.'); + return this.multiplyQuaternions(q, p); + } + + return this.multiplyQuaternions(this, q); + } + + premultiply(q) { + return this.multiplyQuaternions(q, this); + } + + multiplyQuaternions(a, b) { + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + + const qax = a._x, + qay = a._y, + qaz = a._z, + qaw = a._w; + const qbx = b._x, + qby = b._y, + qbz = b._z, + qbw = b._w; + + this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + + this._onChangeCallback(); + + return this; + } + + slerp(qb, t) { + if (t === 0) return this; + if (t === 1) return this.copy(qb); + + const x = this._x, + y = this._y, + z = this._z, + w = this._w; + + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + + let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; + + if (cosHalfTheta < 0) { + this._w = -qb._w; + this._x = -qb._x; + this._y = -qb._y; + this._z = -qb._z; + + cosHalfTheta = -cosHalfTheta; + } else { + this.copy(qb); + } + + if (cosHalfTheta >= 1.0) { + this._w = w; + this._x = x; + this._y = y; + this._z = z; + + return this; + } + + const sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; + + if (sqrSinHalfTheta <= Number.EPSILON) { + const s = 1 - t; + this._w = s * w + t * this._w; + this._x = s * x + t * this._x; + this._y = s * y + t * this._y; + this._z = s * z + t * this._z; + + this.normalize(); + this._onChangeCallback(); + + return this; + } + + const sinHalfTheta = Math.sqrt(sqrSinHalfTheta); + const halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta); + const ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, + ratioB = Math.sin(t * halfTheta) / sinHalfTheta; + + this._w = w * ratioA + this._w * ratioB; + this._x = x * ratioA + this._x * ratioB; + this._y = y * ratioA + this._y * ratioB; + this._z = z * ratioA + this._z * ratioB; + + this._onChangeCallback(); + + return this; + } + + slerpQuaternions(qa, qb, t) { + return this.copy(qa).slerp(qb, t); + } + + random() { + // Derived from http://planning.cs.uiuc.edu/node198.html + // Note, this source uses w, x, y, z ordering, + // so we swap the order below. + + const u1 = Math.random(); + const sqrt1u1 = Math.sqrt(1 - u1); + const sqrtu1 = Math.sqrt(u1); + + const u2 = 2 * Math.PI * Math.random(); + + const u3 = 2 * Math.PI * Math.random(); + + return this.set(sqrt1u1 * Math.cos(u2), sqrtu1 * Math.sin(u3), sqrtu1 * Math.cos(u3), sqrt1u1 * Math.sin(u2)); + } + + equals(quaternion) { + return quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w; + } + + fromArray(array, offset = 0) { + this._x = array[offset]; + this._y = array[offset + 1]; + this._z = array[offset + 2]; + this._w = array[offset + 3]; + + this._onChangeCallback(); + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this._x; + array[offset + 1] = this._y; + array[offset + 2] = this._z; + array[offset + 3] = this._w; + + return array; + } + + fromBufferAttribute(attribute, index) { + this._x = attribute.getX(index); + this._y = attribute.getY(index); + this._z = attribute.getZ(index); + this._w = attribute.getW(index); + + return this; + } + + _onChange(callback) { + this._onChangeCallback = callback; + + return this; + } + + _onChangeCallback() {} +} + +Quaternion.prototype.isQuaternion = true; + +export { Quaternion }; diff --git a/backend/libs/three/math/Ray.d.ts b/backend/libs/three/math/Ray.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..654e5942233435942164df913c22a0b2bc98fd61 --- /dev/null +++ b/backend/libs/three/math/Ray.d.ts @@ -0,0 +1,55 @@ +import { Vector3 } from './Vector3'; +import { Sphere } from './Sphere'; +import { Plane } from './Plane'; +import { Box3 } from './Box3'; +import { Matrix4 } from './Matrix4'; + +export class Ray { + constructor(origin?: Vector3, direction?: Vector3); + + /** + * @default new THREE.Vector3() + */ + origin: Vector3; + + /** + * @default new THREE.Vector3( 0, 0, - 1 ) + */ + direction: Vector3; + + set(origin: Vector3, direction: Vector3): Ray; + clone(): this; + copy(ray: Ray): this; + at(t: number, target: Vector3): Vector3; + lookAt(v: Vector3): Ray; + recast(t: number): Ray; + closestPointToPoint(point: Vector3, target: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + distanceSqToPoint(point: Vector3): number; + distanceSqToSegment(v0: Vector3, v1: Vector3, optionalPointOnRay?: Vector3, optionalPointOnSegment?: Vector3): number; + intersectSphere(sphere: Sphere, target: Vector3): Vector3 | null; + intersectsSphere(sphere: Sphere): boolean; + distanceToPlane(plane: Plane): number; + intersectPlane(plane: Plane, target: Vector3): Vector3 | null; + intersectsPlane(plane: Plane): boolean; + intersectBox(box: Box3, target: Vector3): Vector3 | null; + intersectsBox(box: Box3): boolean; + intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, target: Vector3): Vector3 | null; + applyMatrix4(matrix4: Matrix4): Ray; + equals(ray: Ray): boolean; + + /** + * @deprecated Use {@link Ray#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; + + /** + * @deprecated Use {@link Ray#intersectsPlane .intersectsPlane()} instead. + */ + isIntersectionPlane(p: any): any; + + /** + * @deprecated Use {@link Ray#intersectsSphere .intersectsSphere()} instead. + */ + isIntersectionSphere(s: any): any; +} diff --git a/backend/libs/three/math/Ray.js b/backend/libs/three/math/Ray.js new file mode 100644 index 0000000000000000000000000000000000000000..f8ab39666e237c03ea95d418c15dc1025a1d6b68 --- /dev/null +++ b/backend/libs/three/math/Ray.js @@ -0,0 +1,386 @@ +import { Vector3 } from './Vector3.js'; + +const _vector = /*@__PURE__*/ new Vector3(); +const _segCenter = /*@__PURE__*/ new Vector3(); +const _segDir = /*@__PURE__*/ new Vector3(); +const _diff = /*@__PURE__*/ new Vector3(); + +const _edge1 = /*@__PURE__*/ new Vector3(); +const _edge2 = /*@__PURE__*/ new Vector3(); +const _normal = /*@__PURE__*/ new Vector3(); + +class Ray { + constructor(origin = new Vector3(), direction = new Vector3(0, 0, -1)) { + this.origin = origin; + this.direction = direction; + } + + set(origin, direction) { + this.origin.copy(origin); + this.direction.copy(direction); + + return this; + } + + copy(ray) { + this.origin.copy(ray.origin); + this.direction.copy(ray.direction); + + return this; + } + + at(t, target) { + return target.copy(this.direction).multiplyScalar(t).add(this.origin); + } + + lookAt(v) { + this.direction.copy(v).sub(this.origin).normalize(); + + return this; + } + + recast(t) { + this.origin.copy(this.at(t, _vector)); + + return this; + } + + closestPointToPoint(point, target) { + target.subVectors(point, this.origin); + + const directionDistance = target.dot(this.direction); + + if (directionDistance < 0) { + return target.copy(this.origin); + } + + return target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin); + } + + distanceToPoint(point) { + return Math.sqrt(this.distanceSqToPoint(point)); + } + + distanceSqToPoint(point) { + const directionDistance = _vector.subVectors(point, this.origin).dot(this.direction); + + // point behind the ray + + if (directionDistance < 0) { + return this.origin.distanceToSquared(point); + } + + _vector.copy(this.direction).multiplyScalar(directionDistance).add(this.origin); + + return _vector.distanceToSquared(point); + } + + distanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) { + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h + // It returns the min distance between the ray and the segment + // defined by v0 and v1 + // It can also set two optional targets : + // - The closest point on the ray + // - The closest point on the segment + + _segCenter.copy(v0).add(v1).multiplyScalar(0.5); + _segDir.copy(v1).sub(v0).normalize(); + _diff.copy(this.origin).sub(_segCenter); + + const segExtent = v0.distanceTo(v1) * 0.5; + const a01 = -this.direction.dot(_segDir); + const b0 = _diff.dot(this.direction); + const b1 = -_diff.dot(_segDir); + const c = _diff.lengthSq(); + const det = Math.abs(1 - a01 * a01); + let s0, s1, sqrDist, extDet; + + if (det > 0) { + // The ray and segment are not parallel. + + s0 = a01 * b1 - b0; + s1 = a01 * b0 - b1; + extDet = segExtent * det; + + if (s0 >= 0) { + if (s1 >= -extDet) { + if (s1 <= extDet) { + // region 0 + // Minimum at interior points of ray and segment. + + const invDet = 1 / det; + s0 *= invDet; + s1 *= invDet; + sqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c; + } else { + // region 1 + + s1 = segExtent; + s0 = Math.max(0, -(a01 * s1 + b0)); + sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c; + } + } else { + // region 5 + + s1 = -segExtent; + s0 = Math.max(0, -(a01 * s1 + b0)); + sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c; + } + } else { + if (s1 <= -extDet) { + // region 4 + + s0 = Math.max(0, -(-a01 * segExtent + b0)); + s1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent); + sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c; + } else if (s1 <= extDet) { + // region 3 + + s0 = 0; + s1 = Math.min(Math.max(-segExtent, -b1), segExtent); + sqrDist = s1 * (s1 + 2 * b1) + c; + } else { + // region 2 + + s0 = Math.max(0, -(a01 * segExtent + b0)); + s1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent); + sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c; + } + } + } else { + // Ray and segment are parallel. + + s1 = a01 > 0 ? -segExtent : segExtent; + s0 = Math.max(0, -(a01 * s1 + b0)); + sqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c; + } + + if (optionalPointOnRay) { + optionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin); + } + + if (optionalPointOnSegment) { + optionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter); + } + + return sqrDist; + } + + intersectSphere(sphere, target) { + _vector.subVectors(sphere.center, this.origin); + const tca = _vector.dot(this.direction); + const d2 = _vector.dot(_vector) - tca * tca; + const radius2 = sphere.radius * sphere.radius; + + if (d2 > radius2) return null; + + const thc = Math.sqrt(radius2 - d2); + + // t0 = first intersect point - entrance on front of sphere + const t0 = tca - thc; + + // t1 = second intersect point - exit point on back of sphere + const t1 = tca + thc; + + // test to see if both t0 and t1 are behind the ray - if so, return null + if (t0 < 0 && t1 < 0) return null; + + // test to see if t0 is behind the ray: + // if it is, the ray is inside the sphere, so return the second exit point scaled by t1, + // in order to always return an intersect point that is in front of the ray. + if (t0 < 0) return this.at(t1, target); + + // else t0 is in front of the ray, so return the first collision point scaled by t0 + return this.at(t0, target); + } + + intersectsSphere(sphere) { + return this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius; + } + + distanceToPlane(plane) { + const denominator = plane.normal.dot(this.direction); + + if (denominator === 0) { + // line is coplanar, return origin + if (plane.distanceToPoint(this.origin) === 0) { + return 0; + } + + // Null is preferable to undefined since undefined means.... it is undefined + + return null; + } + + const t = -(this.origin.dot(plane.normal) + plane.constant) / denominator; + + // Return if the ray never intersects the plane + + return t >= 0 ? t : null; + } + + intersectPlane(plane, target) { + const t = this.distanceToPlane(plane); + + if (t === null) { + return null; + } + + return this.at(t, target); + } + + intersectsPlane(plane) { + // check if the ray lies on the plane first + + const distToPoint = plane.distanceToPoint(this.origin); + + if (distToPoint === 0) { + return true; + } + + const denominator = plane.normal.dot(this.direction); + + if (denominator * distToPoint < 0) { + return true; + } + + // ray origin is behind the plane (and is pointing behind it) + + return false; + } + + intersectBox(box, target) { + let tmin, tmax, tymin, tymax, tzmin, tzmax; + + const invdirx = 1 / this.direction.x, + invdiry = 1 / this.direction.y, + invdirz = 1 / this.direction.z; + + const origin = this.origin; + + if (invdirx >= 0) { + tmin = (box.min.x - origin.x) * invdirx; + tmax = (box.max.x - origin.x) * invdirx; + } else { + tmin = (box.max.x - origin.x) * invdirx; + tmax = (box.min.x - origin.x) * invdirx; + } + + if (invdiry >= 0) { + tymin = (box.min.y - origin.y) * invdiry; + tymax = (box.max.y - origin.y) * invdiry; + } else { + tymin = (box.max.y - origin.y) * invdiry; + tymax = (box.min.y - origin.y) * invdiry; + } + + if (tmin > tymax || tymin > tmax) return null; + + // These lines also handle the case where tmin or tmax is NaN + // (result of 0 * Infinity). x !== x returns true if x is NaN + + if (tymin > tmin || tmin !== tmin) tmin = tymin; + + if (tymax < tmax || tmax !== tmax) tmax = tymax; + + if (invdirz >= 0) { + tzmin = (box.min.z - origin.z) * invdirz; + tzmax = (box.max.z - origin.z) * invdirz; + } else { + tzmin = (box.max.z - origin.z) * invdirz; + tzmax = (box.min.z - origin.z) * invdirz; + } + + if (tmin > tzmax || tzmin > tmax) return null; + + if (tzmin > tmin || tmin !== tmin) tmin = tzmin; + + if (tzmax < tmax || tmax !== tmax) tmax = tzmax; + + //return point closest to the ray (positive side) + + if (tmax < 0) return null; + + return this.at(tmin >= 0 ? tmin : tmax, target); + } + + intersectsBox(box) { + return this.intersectBox(box, _vector) !== null; + } + + intersectTriangle(a, b, c, backfaceCulling, target) { + // Compute the offset origin, edges, and normal. + + // from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h + + _edge1.subVectors(b, a); + _edge2.subVectors(c, a); + _normal.crossVectors(_edge1, _edge2); + + // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction, + // E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by + // |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2)) + // |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q)) + // |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N) + let DdN = this.direction.dot(_normal); + let sign; + + if (DdN > 0) { + if (backfaceCulling) return null; + sign = 1; + } else if (DdN < 0) { + sign = -1; + DdN = -DdN; + } else { + return null; + } + + _diff.subVectors(this.origin, a); + const DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2)); + + // b1 < 0, no intersection + if (DdQxE2 < 0) { + return null; + } + + const DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff)); + + // b2 < 0, no intersection + if (DdE1xQ < 0) { + return null; + } + + // b1+b2 > 1, no intersection + if (DdQxE2 + DdE1xQ > DdN) { + return null; + } + + // Line intersects triangle, check if ray does. + const QdN = -sign * _diff.dot(_normal); + + // t < 0, no intersection + if (QdN < 0) { + return null; + } + + // Ray intersects triangle. + return this.at(QdN / DdN, target); + } + + applyMatrix4(matrix4) { + this.origin.applyMatrix4(matrix4); + this.direction.transformDirection(matrix4); + + return this; + } + + equals(ray) { + return ray.origin.equals(this.origin) && ray.direction.equals(this.direction); + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Ray }; diff --git a/backend/libs/three/math/Sphere.d.ts b/backend/libs/three/math/Sphere.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0a52f3db5e97c46b70f7fababce16c0389987d54 --- /dev/null +++ b/backend/libs/three/math/Sphere.d.ts @@ -0,0 +1,42 @@ +import { Vector3 } from './Vector3'; +import { Box3 } from './Box3'; +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; + +export class Sphere { + constructor(center?: Vector3, radius?: number); + + /** + * @default new Vector3() + */ + center: Vector3; + + /** + * @default 1 + */ + radius: number; + + set(center: Vector3, radius: number): Sphere; + setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; + clone(): this; + copy(sphere: Sphere): this; + expandByPoint(point: Vector3): this; + isEmpty(): boolean; + makeEmpty(): this; + containsPoint(point: Vector3): boolean; + distanceToPoint(point: Vector3): number; + intersectsSphere(sphere: Sphere): boolean; + intersectsBox(box: Box3): boolean; + intersectsPlane(plane: Plane): boolean; + clampPoint(point: Vector3, target: Vector3): Vector3; + getBoundingBox(target: Box3): Box3; + applyMatrix4(matrix: Matrix4): Sphere; + translate(offset: Vector3): Sphere; + equals(sphere: Sphere): boolean; + union(sphere: Sphere): this; + + /** + * @deprecated Use {@link Sphere#isEmpty .isEmpty()} instead. + */ + empty(): any; +} diff --git a/backend/libs/three/math/Sphere.js b/backend/libs/three/math/Sphere.js new file mode 100644 index 0000000000000000000000000000000000000000..c99ce9d4cba85c79091fb54fb7001287ee37fb52 --- /dev/null +++ b/backend/libs/three/math/Sphere.js @@ -0,0 +1,171 @@ +import { Box3 } from './Box3.js'; +import { Vector3 } from './Vector3.js'; + +const _box = /*@__PURE__*/ new Box3(); +const _v1 = /*@__PURE__*/ new Vector3(); +const _toFarthestPoint = /*@__PURE__*/ new Vector3(); +const _toPoint = /*@__PURE__*/ new Vector3(); + +class Sphere { + constructor(center = new Vector3(), radius = -1) { + this.center = center; + this.radius = radius; + } + + set(center, radius) { + this.center.copy(center); + this.radius = radius; + + return this; + } + + setFromPoints(points, optionalCenter) { + const center = this.center; + + if (optionalCenter !== undefined) { + center.copy(optionalCenter); + } else { + _box.setFromPoints(points).getCenter(center); + } + + let maxRadiusSq = 0; + + for (let i = 0, il = points.length; i < il; i++) { + maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i])); + } + + this.radius = Math.sqrt(maxRadiusSq); + + return this; + } + + copy(sphere) { + this.center.copy(sphere.center); + this.radius = sphere.radius; + + return this; + } + + isEmpty() { + return this.radius < 0; + } + + makeEmpty() { + this.center.set(0, 0, 0); + this.radius = -1; + + return this; + } + + containsPoint(point) { + return point.distanceToSquared(this.center) <= this.radius * this.radius; + } + + distanceToPoint(point) { + return point.distanceTo(this.center) - this.radius; + } + + intersectsSphere(sphere) { + const radiusSum = this.radius + sphere.radius; + + return sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum; + } + + intersectsBox(box) { + return box.intersectsSphere(this); + } + + intersectsPlane(plane) { + return Math.abs(plane.distanceToPoint(this.center)) <= this.radius; + } + + clampPoint(point, target) { + const deltaLengthSq = this.center.distanceToSquared(point); + + target.copy(point); + + if (deltaLengthSq > this.radius * this.radius) { + target.sub(this.center).normalize(); + target.multiplyScalar(this.radius).add(this.center); + } + + return target; + } + + getBoundingBox(target) { + if (this.isEmpty()) { + // Empty sphere produces empty bounding box + target.makeEmpty(); + return target; + } + + target.set(this.center, this.center); + target.expandByScalar(this.radius); + + return target; + } + + applyMatrix4(matrix) { + this.center.applyMatrix4(matrix); + this.radius = this.radius * matrix.getMaxScaleOnAxis(); + + return this; + } + + translate(offset) { + this.center.add(offset); + + return this; + } + + expandByPoint(point) { + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671 + + _toPoint.subVectors(point, this.center); + + const lengthSq = _toPoint.lengthSq(); + + if (lengthSq > this.radius * this.radius) { + const length = Math.sqrt(lengthSq); + const missingRadiusHalf = (length - this.radius) * 0.5; + + // Nudge this sphere towards the target point. Add half the missing distance to radius, + // and the other half to position. This gives a tighter enclosure, instead of if + // the whole missing distance were just added to radius. + + this.center.add(_toPoint.multiplyScalar(missingRadiusHalf / length)); + this.radius += missingRadiusHalf; + } + + return this; + } + + union(sphere) { + // from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L759-L769 + + // To enclose another sphere into this sphere, we only need to enclose two points: + // 1) Enclose the farthest point on the other sphere into this sphere. + // 2) Enclose the opposite point of the farthest point into this sphere. + + if (this.center.equals(sphere.center) === true) { + _toFarthestPoint.set(0, 0, 1).multiplyScalar(sphere.radius); + } else { + _toFarthestPoint.subVectors(sphere.center, this.center).normalize().multiplyScalar(sphere.radius); + } + + this.expandByPoint(_v1.copy(sphere.center).add(_toFarthestPoint)); + this.expandByPoint(_v1.copy(sphere.center).sub(_toFarthestPoint)); + + return this; + } + + equals(sphere) { + return sphere.center.equals(this.center) && sphere.radius === this.radius; + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Sphere }; diff --git a/backend/libs/three/math/Spherical.d.ts b/backend/libs/three/math/Spherical.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e6935d872e46358c74f9ab9583d74ff1a7e25e1 --- /dev/null +++ b/backend/libs/three/math/Spherical.d.ts @@ -0,0 +1,27 @@ +import { Vector3 } from './Vector3'; + +export class Spherical { + constructor(radius?: number, phi?: number, theta?: number); + + /** + * @default 1 + */ + radius: number; + + /** + * @default 0 + */ + phi: number; + + /** + * @default 0 + */ + theta: number; + + set(radius: number, phi: number, theta: number): this; + clone(): this; + copy(other: Spherical): this; + makeSafe(): this; + setFromVector3(v: Vector3): this; + setFromCartesianCoords(x: number, y: number, z: number): this; +} diff --git a/backend/libs/three/math/Spherical.js b/backend/libs/three/math/Spherical.js new file mode 100644 index 0000000000000000000000000000000000000000..1c6c11d9d8f5194587ef8a8b7bb1cfc1d4635b6d --- /dev/null +++ b/backend/libs/three/math/Spherical.js @@ -0,0 +1,66 @@ +/** + * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system + * + * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up. + * The azimuthal angle (theta) is measured from the positive z-axis. + */ + +import * as MathUtils from './MathUtils.js'; + +class Spherical { + constructor(radius = 1, phi = 0, theta = 0) { + this.radius = radius; + this.phi = phi; // polar angle + this.theta = theta; // azimuthal angle + + return this; + } + + set(radius, phi, theta) { + this.radius = radius; + this.phi = phi; + this.theta = theta; + + return this; + } + + copy(other) { + this.radius = other.radius; + this.phi = other.phi; + this.theta = other.theta; + + return this; + } + + // restrict phi to be betwee EPS and PI-EPS + makeSafe() { + const EPS = 0.000001; + this.phi = Math.max(EPS, Math.min(Math.PI - EPS, this.phi)); + + return this; + } + + setFromVector3(v) { + return this.setFromCartesianCoords(v.x, v.y, v.z); + } + + setFromCartesianCoords(x, y, z) { + this.radius = Math.sqrt(x * x + y * y + z * z); + + if (this.radius === 0) { + this.theta = 0; + this.phi = 0; + } else { + this.theta = Math.atan2(x, z); + this.phi = Math.acos(MathUtils.clamp(y / this.radius, -1, 1)); + } + + return this; + } + + clone() { + return new this.constructor().copy(this); + } +} + +export { Spherical }; diff --git a/backend/libs/three/math/SphericalHarmonics3.d.ts b/backend/libs/three/math/SphericalHarmonics3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..db547bc20458a569d14d558c2a20b6563f945184 --- /dev/null +++ b/backend/libs/three/math/SphericalHarmonics3.d.ts @@ -0,0 +1,50 @@ +import { Vector3 } from './Vector3'; + +export class SphericalHarmonics3 { + constructor(); + + /** + * @default [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), + * new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()] + */ + coefficients: Vector3[]; + readonly isSphericalHarmonics3: true; + + set(coefficients: Vector3[]): SphericalHarmonics3; + zero(): SphericalHarmonics3; + add(sh: SphericalHarmonics3): SphericalHarmonics3; + addScaledSH(sh: SphericalHarmonics3, s: number): SphericalHarmonics3; + scale(s: number): SphericalHarmonics3; + lerp(sh: SphericalHarmonics3, alpha: number): SphericalHarmonics3; + equals(sh: SphericalHarmonics3): boolean; + copy(sh: SphericalHarmonics3): SphericalHarmonics3; + clone(): this; + + /** + * Sets the values of this spherical harmonics from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array with the values of this spherical harmonics, or copies them into the provided array. + * @param array (optional) array to store the spherical harmonics to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + + /** + * Returns an array with the values of this spherical harmonics, or copies them into the provided array-like. + * @param array array-like to store the spherical harmonics to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(array: ArrayLike, offset?: number): ArrayLike; + + getAt(normal: Vector3, target: Vector3): Vector3; + getIrradianceAt(normal: Vector3, target: Vector3): Vector3; + + static getBasisAt(normal: Vector3, shBasis: number[]): void; +} diff --git a/backend/libs/three/math/SphericalHarmonics3.js b/backend/libs/three/math/SphericalHarmonics3.js new file mode 100644 index 0000000000000000000000000000000000000000..1cf364152147a833f975a44b647555c74d133ca2 --- /dev/null +++ b/backend/libs/three/math/SphericalHarmonics3.js @@ -0,0 +1,195 @@ +import { Vector3 } from './Vector3.js'; + +/** + * Primary reference: + * https://graphics.stanford.edu/papers/envmap/envmap.pdf + * + * Secondary reference: + * https://www.ppsloan.org/publications/StupidSH36.pdf + */ + +// 3-band SH defined by 9 coefficients + +class SphericalHarmonics3 { + constructor() { + this.coefficients = []; + + for (let i = 0; i < 9; i++) { + this.coefficients.push(new Vector3()); + } + } + + set(coefficients) { + for (let i = 0; i < 9; i++) { + this.coefficients[i].copy(coefficients[i]); + } + + return this; + } + + zero() { + for (let i = 0; i < 9; i++) { + this.coefficients[i].set(0, 0, 0); + } + + return this; + } + + // get the radiance in the direction of the normal + // target is a Vector3 + getAt(normal, target) { + // normal is assumed to be unit length + + const x = normal.x, + y = normal.y, + z = normal.z; + + const coeff = this.coefficients; + + // band 0 + target.copy(coeff[0]).multiplyScalar(0.282095); + + // band 1 + target.addScaledVector(coeff[1], 0.488603 * y); + target.addScaledVector(coeff[2], 0.488603 * z); + target.addScaledVector(coeff[3], 0.488603 * x); + + // band 2 + target.addScaledVector(coeff[4], 1.092548 * (x * y)); + target.addScaledVector(coeff[5], 1.092548 * (y * z)); + target.addScaledVector(coeff[6], 0.315392 * (3.0 * z * z - 1.0)); + target.addScaledVector(coeff[7], 1.092548 * (x * z)); + target.addScaledVector(coeff[8], 0.546274 * (x * x - y * y)); + + return target; + } + + // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal + // target is a Vector3 + // https://graphics.stanford.edu/papers/envmap/envmap.pdf + getIrradianceAt(normal, target) { + // normal is assumed to be unit length + + const x = normal.x, + y = normal.y, + z = normal.z; + + const coeff = this.coefficients; + + // band 0 + target.copy(coeff[0]).multiplyScalar(0.886227); // π * 0.282095 + + // band 1 + target.addScaledVector(coeff[1], 2.0 * 0.511664 * y); // ( 2 * π / 3 ) * 0.488603 + target.addScaledVector(coeff[2], 2.0 * 0.511664 * z); + target.addScaledVector(coeff[3], 2.0 * 0.511664 * x); + + // band 2 + target.addScaledVector(coeff[4], 2.0 * 0.429043 * x * y); // ( π / 4 ) * 1.092548 + target.addScaledVector(coeff[5], 2.0 * 0.429043 * y * z); + target.addScaledVector(coeff[6], 0.743125 * z * z - 0.247708); // ( π / 4 ) * 0.315392 * 3 + target.addScaledVector(coeff[7], 2.0 * 0.429043 * x * z); + target.addScaledVector(coeff[8], 0.429043 * (x * x - y * y)); // ( π / 4 ) * 0.546274 + + return target; + } + + add(sh) { + for (let i = 0; i < 9; i++) { + this.coefficients[i].add(sh.coefficients[i]); + } + + return this; + } + + addScaledSH(sh, s) { + for (let i = 0; i < 9; i++) { + this.coefficients[i].addScaledVector(sh.coefficients[i], s); + } + + return this; + } + + scale(s) { + for (let i = 0; i < 9; i++) { + this.coefficients[i].multiplyScalar(s); + } + + return this; + } + + lerp(sh, alpha) { + for (let i = 0; i < 9; i++) { + this.coefficients[i].lerp(sh.coefficients[i], alpha); + } + + return this; + } + + equals(sh) { + for (let i = 0; i < 9; i++) { + if (!this.coefficients[i].equals(sh.coefficients[i])) { + return false; + } + } + + return true; + } + + copy(sh) { + return this.set(sh.coefficients); + } + + clone() { + return new this.constructor().copy(this); + } + + fromArray(array, offset = 0) { + const coefficients = this.coefficients; + + for (let i = 0; i < 9; i++) { + coefficients[i].fromArray(array, offset + i * 3); + } + + return this; + } + + toArray(array = [], offset = 0) { + const coefficients = this.coefficients; + + for (let i = 0; i < 9; i++) { + coefficients[i].toArray(array, offset + i * 3); + } + + return array; + } + + // evaluate the basis functions + // shBasis is an Array[ 9 ] + static getBasisAt(normal, shBasis) { + // normal is assumed to be unit length + + const x = normal.x, + y = normal.y, + z = normal.z; + + // band 0 + shBasis[0] = 0.282095; + + // band 1 + shBasis[1] = 0.488603 * y; + shBasis[2] = 0.488603 * z; + shBasis[3] = 0.488603 * x; + + // band 2 + shBasis[4] = 1.092548 * x * y; + shBasis[5] = 1.092548 * y * z; + shBasis[6] = 0.315392 * (3 * z * z - 1); + shBasis[7] = 1.092548 * x * z; + shBasis[8] = 0.546274 * (x * x - y * y); + } +} + +SphericalHarmonics3.prototype.isSphericalHarmonics3 = true; + +export { SphericalHarmonics3 }; diff --git a/backend/libs/three/math/Triangle.d.ts b/backend/libs/three/math/Triangle.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..43f66263ef67aa9cdfe3591c4925647becf6a385 --- /dev/null +++ b/backend/libs/three/math/Triangle.d.ts @@ -0,0 +1,49 @@ +import { Vector2 } from './Vector2'; +import { Vector3 } from './Vector3'; +import { Plane } from './Plane'; +import { Box3 } from './Box3'; + +import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute'; +import { BufferAttribute } from '../core/BufferAttribute'; + +export class Triangle { + constructor(a?: Vector3, b?: Vector3, c?: Vector3); + + /** + * @default new THREE.Vector3() + */ + a: Vector3; + + /** + * @default new THREE.Vector3() + */ + b: Vector3; + + /** + * @default new THREE.Vector3() + */ + c: Vector3; + + set(a: Vector3, b: Vector3, c: Vector3): Triangle; + setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): this; + setFromAttributeAndIndices(attribute: BufferAttribute | InterleavedBufferAttribute, i0: number, i1: number, i2: number): this; + clone(): this; + copy(triangle: Triangle): this; + getArea(): number; + getMidpoint(target: Vector3): Vector3; + getNormal(target: Vector3): Vector3; + getPlane(target: Plane): Plane; + getBarycoord(point: Vector3, target: Vector3): Vector3; + getUV(point: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2, target: Vector2): Vector2; + containsPoint(point: Vector3): boolean; + intersectsBox(box: Box3): boolean; + isFrontFacing(direction: Vector3): boolean; + closestPointToPoint(point: Vector3, target: Vector3): Vector3; + equals(triangle: Triangle): boolean; + + static getNormal(a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3; + static getBarycoord(point: Vector3, a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3; + static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean; + static getUV(point: Vector3, p1: Vector3, p2: Vector3, p3: Vector3, uv1: Vector2, uv2: Vector2, uv3: Vector2, target: Vector2): Vector2; + static isFrontFacing(a: Vector3, b: Vector3, c: Vector3, direction: Vector3): boolean; +} diff --git a/backend/libs/three/math/Triangle.js b/backend/libs/three/math/Triangle.js new file mode 100644 index 0000000000000000000000000000000000000000..8197d4d5d7adfb1203620f7459910e3e9726e871 --- /dev/null +++ b/backend/libs/three/math/Triangle.js @@ -0,0 +1,242 @@ +import { Vector3 } from './Vector3.js'; + +const _v0 = /*@__PURE__*/ new Vector3(); +const _v1 = /*@__PURE__*/ new Vector3(); +const _v2 = /*@__PURE__*/ new Vector3(); +const _v3 = /*@__PURE__*/ new Vector3(); + +const _vab = /*@__PURE__*/ new Vector3(); +const _vac = /*@__PURE__*/ new Vector3(); +const _vbc = /*@__PURE__*/ new Vector3(); +const _vap = /*@__PURE__*/ new Vector3(); +const _vbp = /*@__PURE__*/ new Vector3(); +const _vcp = /*@__PURE__*/ new Vector3(); + +class Triangle { + constructor(a = new Vector3(), b = new Vector3(), c = new Vector3()) { + this.a = a; + this.b = b; + this.c = c; + } + + static getNormal(a, b, c, target) { + target.subVectors(c, b); + _v0.subVectors(a, b); + target.cross(_v0); + + const targetLengthSq = target.lengthSq(); + if (targetLengthSq > 0) { + return target.multiplyScalar(1 / Math.sqrt(targetLengthSq)); + } + + return target.set(0, 0, 0); + } + + // static/instance method to calculate barycentric coordinates + // based on: http://www.blackpawn.com/texts/pointinpoly/default.html + static getBarycoord(point, a, b, c, target) { + _v0.subVectors(c, a); + _v1.subVectors(b, a); + _v2.subVectors(point, a); + + const dot00 = _v0.dot(_v0); + const dot01 = _v0.dot(_v1); + const dot02 = _v0.dot(_v2); + const dot11 = _v1.dot(_v1); + const dot12 = _v1.dot(_v2); + + const denom = dot00 * dot11 - dot01 * dot01; + + // collinear or singular triangle + if (denom === 0) { + // arbitrary location outside of triangle? + // not sure if this is the best idea, maybe should be returning undefined + return target.set(-2, -1, -1); + } + + const invDenom = 1 / denom; + const u = (dot11 * dot02 - dot01 * dot12) * invDenom; + const v = (dot00 * dot12 - dot01 * dot02) * invDenom; + + // barycentric coordinates must always sum to 1 + return target.set(1 - u - v, v, u); + } + + static containsPoint(point, a, b, c) { + this.getBarycoord(point, a, b, c, _v3); + + return _v3.x >= 0 && _v3.y >= 0 && _v3.x + _v3.y <= 1; + } + + static getUV(point, p1, p2, p3, uv1, uv2, uv3, target) { + this.getBarycoord(point, p1, p2, p3, _v3); + + target.set(0, 0); + target.addScaledVector(uv1, _v3.x); + target.addScaledVector(uv2, _v3.y); + target.addScaledVector(uv3, _v3.z); + + return target; + } + + static isFrontFacing(a, b, c, direction) { + _v0.subVectors(c, b); + _v1.subVectors(a, b); + + // strictly front facing + return _v0.cross(_v1).dot(direction) < 0 ? true : false; + } + + set(a, b, c) { + this.a.copy(a); + this.b.copy(b); + this.c.copy(c); + + return this; + } + + setFromPointsAndIndices(points, i0, i1, i2) { + this.a.copy(points[i0]); + this.b.copy(points[i1]); + this.c.copy(points[i2]); + + return this; + } + + setFromAttributeAndIndices(attribute, i0, i1, i2) { + this.a.fromBufferAttribute(attribute, i0); + this.b.fromBufferAttribute(attribute, i1); + this.c.fromBufferAttribute(attribute, i2); + + return this; + } + + clone() { + return new this.constructor().copy(this); + } + + copy(triangle) { + this.a.copy(triangle.a); + this.b.copy(triangle.b); + this.c.copy(triangle.c); + + return this; + } + + getArea() { + _v0.subVectors(this.c, this.b); + _v1.subVectors(this.a, this.b); + + return _v0.cross(_v1).length() * 0.5; + } + + getMidpoint(target) { + return target + .addVectors(this.a, this.b) + .add(this.c) + .multiplyScalar(1 / 3); + } + + getNormal(target) { + return Triangle.getNormal(this.a, this.b, this.c, target); + } + + getPlane(target) { + return target.setFromCoplanarPoints(this.a, this.b, this.c); + } + + getBarycoord(point, target) { + return Triangle.getBarycoord(point, this.a, this.b, this.c, target); + } + + getUV(point, uv1, uv2, uv3, target) { + return Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target); + } + + containsPoint(point) { + return Triangle.containsPoint(point, this.a, this.b, this.c); + } + + isFrontFacing(direction) { + return Triangle.isFrontFacing(this.a, this.b, this.c, direction); + } + + intersectsBox(box) { + return box.intersectsTriangle(this); + } + + closestPointToPoint(p, target) { + const a = this.a, + b = this.b, + c = this.c; + let v, w; + + // algorithm thanks to Real-Time Collision Detection by Christer Ericson, + // published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc., + // under the accompanying license; see chapter 5.1.5 for detailed explanation. + // basically, we're distinguishing which of the voronoi regions of the triangle + // the point lies in with the minimum amount of redundant computation. + + _vab.subVectors(b, a); + _vac.subVectors(c, a); + _vap.subVectors(p, a); + const d1 = _vab.dot(_vap); + const d2 = _vac.dot(_vap); + if (d1 <= 0 && d2 <= 0) { + // vertex region of A; barycentric coords (1, 0, 0) + return target.copy(a); + } + + _vbp.subVectors(p, b); + const d3 = _vab.dot(_vbp); + const d4 = _vac.dot(_vbp); + if (d3 >= 0 && d4 <= d3) { + // vertex region of B; barycentric coords (0, 1, 0) + return target.copy(b); + } + + const vc = d1 * d4 - d3 * d2; + if (vc <= 0 && d1 >= 0 && d3 <= 0) { + v = d1 / (d1 - d3); + // edge region of AB; barycentric coords (1-v, v, 0) + return target.copy(a).addScaledVector(_vab, v); + } + + _vcp.subVectors(p, c); + const d5 = _vab.dot(_vcp); + const d6 = _vac.dot(_vcp); + if (d6 >= 0 && d5 <= d6) { + // vertex region of C; barycentric coords (0, 0, 1) + return target.copy(c); + } + + const vb = d5 * d2 - d1 * d6; + if (vb <= 0 && d2 >= 0 && d6 <= 0) { + w = d2 / (d2 - d6); + // edge region of AC; barycentric coords (1-w, 0, w) + return target.copy(a).addScaledVector(_vac, w); + } + + const va = d3 * d6 - d5 * d4; + if (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) { + _vbc.subVectors(c, b); + w = (d4 - d3) / (d4 - d3 + (d5 - d6)); + // edge region of BC; barycentric coords (0, 1-w, w) + return target.copy(b).addScaledVector(_vbc, w); // edge region of BC + } + + // face region + const denom = 1 / (va + vb + vc); + // u = va * denom + v = vb * denom; + w = vc * denom; + + return target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w); + } + + equals(triangle) { + return triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c); + } +} + +export { Triangle }; diff --git a/backend/libs/three/math/Vector2.d.ts b/backend/libs/three/math/Vector2.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..20de35e15a61b2681bf23db90856cb1d920e8e7f --- /dev/null +++ b/backend/libs/three/math/Vector2.d.ts @@ -0,0 +1,446 @@ +import { Matrix3 } from './Matrix3'; +import { BufferAttribute } from './../core/BufferAttribute'; + +export type Vector2Tuple = [number, number]; + +/** + * ( interface Vector ) + * + * Abstract interface of {@link https://github.com/mrdoob/three.js/blob/master/src/math/Vector2.js|Vector2}, + * {@link https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js|Vector3} + * and {@link https://github.com/mrdoob/three.js/blob/master/src/math/Vector4.js|Vector4}. + * + * Currently the members of Vector is NOT type safe because it accepts different typed vectors. + * + * Those definitions will be changed when TypeScript innovates Generics to be type safe. + * + * @example + * const v:THREE.Vector = new THREE.Vector3(); + * v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully + */ +export interface Vector { + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + set(...args: number[]): this; + + setScalar(scalar: number): this; + + /** + * copy(v:T):T; + */ + copy(v: Vector): this; + + /** + * NOTE: The second argument is deprecated. + * + * add(v:T):T; + */ + add(v: Vector): this; + + /** + * addVectors(a:T, b:T):T; + */ + addVectors(a: Vector, b: Vector): this; + + addScaledVector(vector: Vector, scale: number): this; + + /** + * Adds the scalar value s to this vector's values. + */ + addScalar(scalar: number): this; + + /** + * sub(v:T):T; + */ + sub(v: Vector): this; + + /** + * subVectors(a:T, b:T):T; + */ + subVectors(a: Vector, b: Vector): this; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): this; + + /** + * divideScalar(s:number):T; + */ + divideScalar(s: number): this; + + /** + * negate():T; + */ + negate(): this; + + /** + * dot(v:T):T; + */ + dot(v: Vector): number; + + /** + * lengthSq():number; + */ + lengthSq(): number; + + /** + * length():number; + */ + length(): number; + + /** + * normalize():T; + */ + normalize(): this; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceTo(v:T):number; + */ + distanceTo?(v: Vector): number; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceToSquared(v:T):number; + */ + distanceToSquared?(v: Vector): number; + + /** + * setLength(l:number):T; + */ + setLength(l: number): this; + + /** + * lerp(v:T, alpha:number):T; + */ + lerp(v: Vector, alpha: number): this; + + /** + * equals(v:T):boolean; + */ + equals(v: Vector): boolean; + + /** + * clone():T; + */ + clone(): Vector; +} + +/** + * 2D vector. + * + * ( class Vector2 implements Vector ) + */ +export class Vector2 implements Vector { + constructor(x?: number, y?: number); + + /** + * @default 0 + */ + x: number; + + /** + * @default 0 + */ + y: number; + width: number; + height: number; + readonly isVector2: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number): this; + + /** + * Sets the x and y values of this vector both equal to scalar. + */ + setScalar(scalar: number): this; + + /** + * Sets X component of this vector. + */ + setX(x: number): this; + + /** + * Sets Y component of this vector. + */ + setY(y: number): this; + + /** + * Sets a component of this vector. + */ + setComponent(index: number, value: number): this; + + /** + * Gets a component of this vector. + */ + getComponent(index: number): number; + + /** + * Returns a new Vector2 instance with the same `x` and `y` values. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector2): this; + + /** + * Adds v to this vector. + */ + add(v: Vector2, w?: Vector2): this; + + /** + * Adds the scalar value s to this vector's x and y values. + */ + addScalar(s: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector2, b: Vector2): this; + + /** + * Adds the multiple of v and s to this vector. + */ + addScaledVector(v: Vector2, s: number): this; + + /** + * Subtracts v from this vector. + */ + sub(v: Vector2): this; + + /** + * Subtracts s from this vector's x and y components. + */ + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector2, b: Vector2): this; + + /** + * Multiplies this vector by v. + */ + multiply(v: Vector2): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(scalar: number): this; + + /** + * Divides this vector by v. + */ + divide(v: Vector2): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + /** + * Multiplies this vector (with an implicit 1 as the 3rd component) by m. + */ + applyMatrix3(m: Matrix3): this; + + /** + * If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value. + */ + min(v: Vector2): this; + + /** + * If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value. + */ + max(v: Vector2): this; + + /** + * If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. + * If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value. + * @param min the minimum x and y values. + * @param max the maximum x and y values in the desired range. + */ + clamp(min: Vector2, max: Vector2): this; + + /** + * If this vector's x or y values are greater than the max value, they are replaced by the max value. + * If this vector's x or y values are less than the min value, they are replaced by the min value. + * @param min the minimum value the components will be clamped to. + * @param max the maximum value the components will be clamped to. + */ + clampScalar(min: number, max: number): this; + + /** + * If this vector's length is greater than the max value, it is replaced by the max value. + * If this vector's length is less than the min value, it is replaced by the min value. + * @param min the minimum value the length will be clamped to. + * @param max the maximum value the length will be clamped to. + */ + clampLength(min: number, max: number): this; + + /** + * The components of the vector are rounded down to the nearest integer value. + */ + floor(): this; + + /** + * The x and y components of the vector are rounded up to the nearest integer value. + */ + ceil(): this; + + /** + * The components of the vector are rounded to the nearest integer value. + */ + round(): this; + + /** + * The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value. + */ + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector2): number; + + /** + * Computes cross product of this vector and v. + */ + cross(v: Vector2): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * @deprecated Use {@link Vector2#manhattanLength .manhattanLength()} instead. + */ + lengthManhattan(): number; + + /** + * Computes the Manhattan length of this vector. + * + * see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + + /** + * computes the angle in radians with respect to the positive x-axis + */ + angle(): number; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector2): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector2): number; + + /** + * @deprecated Use {@link Vector2#manhattanDistanceTo .manhattanDistanceTo()} instead. + */ + distanceToManhattan(v: Vector2): number; + + /** + * Computes the Manhattan length (distance) from this vector to the given vector v + * + * see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanDistanceTo(v: Vector2): number; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(length: number): this; + + /** + * Linearly interpolates between this vector and v, where alpha is the distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v. + * @param v vector to interpolate towards. + * @param alpha interpolation factor in the closed interval [0, 1]. + */ + lerp(v: Vector2, alpha: number): this; + + /** + * Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2. + * @param v1 the starting vector. + * @param v2 vector to interpolate towards. + * @param alpha interpolation factor in the closed interval [0, 1]. + */ + lerpVectors(v1: Vector2, v2: Vector2, alpha: number): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector2): boolean; + + /** + * Sets this vector's x and y value from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array [x, y], or copies x and y into the provided array. + * @param array (optional) array to store the vector to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + toArray(array?: Vector2Tuple, offset?: 0): Vector2Tuple; + + /** + * Copies x and y into the provided array-like. + * @param array array-like to store the vector to. + * @param offset (optional) optional offset into the array. + * @return The provided array-like. + */ + toArray(array: ArrayLike, offset?: number): ArrayLike; + + /** + * Sets this vector's x and y values from the attribute. + * @param attribute the source attribute. + * @param index index in the attribute. + */ + fromBufferAttribute(attribute: BufferAttribute, index: number): this; + + /** + * Rotates the vector around center by angle radians. + * @param center the point around which to rotate. + * @param angle the angle to rotate, in radians. + */ + rotateAround(center: Vector2, angle: number): this; + + /** + * Sets this vector's x and y from Math.random + */ + random(): this; +} diff --git a/backend/libs/three/math/Vector2.js b/backend/libs/three/math/Vector2.js new file mode 100644 index 0000000000000000000000000000000000000000..ccaa0705c06be934e3344cf675249cc17385852b --- /dev/null +++ b/backend/libs/three/math/Vector2.js @@ -0,0 +1,373 @@ +class Vector2 { + constructor(x = 0, y = 0) { + this.x = x; + this.y = y; + } + + get width() { + return this.x; + } + + set width(value) { + this.x = value; + } + + get height() { + return this.y; + } + + set height(value) { + this.y = value; + } + + set(x, y) { + this.x = x; + this.y = y; + + return this; + } + + setScalar(scalar) { + this.x = scalar; + this.y = scalar; + + return this; + } + + setX(x) { + this.x = x; + + return this; + } + + setY(y) { + this.y = y; + + return this; + } + + setComponent(index, value) { + switch (index) { + case 0: + this.x = value; + break; + case 1: + this.y = value; + break; + default: + throw new Error('index is out of range: ' + index); + } + + return this; + } + + getComponent(index) { + switch (index) { + case 0: + return this.x; + case 1: + return this.y; + default: + throw new Error('index is out of range: ' + index); + } + } + + clone() { + return new this.constructor(this.x, this.y); + } + + copy(v) { + this.x = v.x; + this.y = v.y; + + return this; + } + + add(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.'); + return this.addVectors(v, w); + } + + this.x += v.x; + this.y += v.y; + + return this; + } + + addScalar(s) { + this.x += s; + this.y += s; + + return this; + } + + addVectors(a, b) { + this.x = a.x + b.x; + this.y = a.y + b.y; + + return this; + } + + addScaledVector(v, s) { + this.x += v.x * s; + this.y += v.y * s; + + return this; + } + + sub(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.'); + return this.subVectors(v, w); + } + + this.x -= v.x; + this.y -= v.y; + + return this; + } + + subScalar(s) { + this.x -= s; + this.y -= s; + + return this; + } + + subVectors(a, b) { + this.x = a.x - b.x; + this.y = a.y - b.y; + + return this; + } + + multiply(v) { + this.x *= v.x; + this.y *= v.y; + + return this; + } + + multiplyScalar(scalar) { + this.x *= scalar; + this.y *= scalar; + + return this; + } + + divide(v) { + this.x /= v.x; + this.y /= v.y; + + return this; + } + + divideScalar(scalar) { + return this.multiplyScalar(1 / scalar); + } + + applyMatrix3(m) { + const x = this.x, + y = this.y; + const e = m.elements; + + this.x = e[0] * x + e[3] * y + e[6]; + this.y = e[1] * x + e[4] * y + e[7]; + + return this; + } + + min(v) { + this.x = Math.min(this.x, v.x); + this.y = Math.min(this.y, v.y); + + return this; + } + + max(v) { + this.x = Math.max(this.x, v.x); + this.y = Math.max(this.y, v.y); + + return this; + } + + clamp(min, max) { + // assumes min < max, componentwise + + this.x = Math.max(min.x, Math.min(max.x, this.x)); + this.y = Math.max(min.y, Math.min(max.y, this.y)); + + return this; + } + + clampScalar(minVal, maxVal) { + this.x = Math.max(minVal, Math.min(maxVal, this.x)); + this.y = Math.max(minVal, Math.min(maxVal, this.y)); + + return this; + } + + clampLength(min, max) { + const length = this.length(); + + return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length))); + } + + floor() { + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + + return this; + } + + ceil() { + this.x = Math.ceil(this.x); + this.y = Math.ceil(this.y); + + return this; + } + + round() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + + return this; + } + + roundToZero() { + this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x); + this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y); + + return this; + } + + negate() { + this.x = -this.x; + this.y = -this.y; + + return this; + } + + dot(v) { + return this.x * v.x + this.y * v.y; + } + + cross(v) { + return this.x * v.y - this.y * v.x; + } + + lengthSq() { + return this.x * this.x + this.y * this.y; + } + + length() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y); + } + + normalize() { + return this.divideScalar(this.length() || 1); + } + + angle() { + // computes the angle in radians with respect to the positive x-axis + + const angle = Math.atan2(-this.y, -this.x) + Math.PI; + + return angle; + } + + distanceTo(v) { + return Math.sqrt(this.distanceToSquared(v)); + } + + distanceToSquared(v) { + const dx = this.x - v.x, + dy = this.y - v.y; + return dx * dx + dy * dy; + } + + manhattanDistanceTo(v) { + return Math.abs(this.x - v.x) + Math.abs(this.y - v.y); + } + + setLength(length) { + return this.normalize().multiplyScalar(length); + } + + lerp(v, alpha) { + this.x += (v.x - this.x) * alpha; + this.y += (v.y - this.y) * alpha; + + return this; + } + + lerpVectors(v1, v2, alpha) { + this.x = v1.x + (v2.x - v1.x) * alpha; + this.y = v1.y + (v2.y - v1.y) * alpha; + + return this; + } + + equals(v) { + return v.x === this.x && v.y === this.y; + } + + fromArray(array, offset = 0) { + this.x = array[offset]; + this.y = array[offset + 1]; + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this.x; + array[offset + 1] = this.y; + + return array; + } + + fromBufferAttribute(attribute, index, offset) { + if (offset !== undefined) { + console.warn('THREE.Vector2: offset has been removed from .fromBufferAttribute().'); + } + + this.x = attribute.getX(index); + this.y = attribute.getY(index); + + return this; + } + + rotateAround(center, angle) { + const c = Math.cos(angle), + s = Math.sin(angle); + + const x = this.x - center.x; + const y = this.y - center.y; + + this.x = x * c - y * s + center.x; + this.y = x * s + y * c + center.y; + + return this; + } + + random() { + this.x = Math.random(); + this.y = Math.random(); + + return this; + } + + *[Symbol.iterator]() { + yield this.x; + yield this.y; + } +} + +Vector2.prototype.isVector2 = true; + +export { Vector2 }; diff --git a/backend/libs/three/math/Vector3.d.ts b/backend/libs/three/math/Vector3.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3835bbbfed5fe6fec3e7dc671e541f25109b734b --- /dev/null +++ b/backend/libs/three/math/Vector3.d.ts @@ -0,0 +1,297 @@ +import { Euler } from './Euler'; +import { Matrix3 } from './Matrix3'; +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { Camera } from './../cameras/Camera'; +import { Spherical } from './Spherical'; +import { Cylindrical } from './Cylindrical'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { InterleavedBufferAttribute } from './../core/InterleavedBufferAttribute'; +import { Vector } from './Vector2'; + +export type Vector3Tuple = [number, number, number]; + +/** + * 3D vector. ( class Vector3 implements Vector ) + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js} + * + * @example + * const a = new THREE.Vector3( 1, 0, 0 ); + * const b = new THREE.Vector3( 0, 1, 0 ); + * const c = new THREE.Vector3(); + * c.crossVectors( a, b ); + */ +export class Vector3 implements Vector { + constructor(x?: number, y?: number, z?: number); + + /** + * @default 0 + */ + x: number; + + /** + * @default 0 + */ + y: number; + + /** + * @default 0 + */ + z: number; + readonly isVector3: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number): this; + + /** + * Sets all values of this vector. + */ + setScalar(scalar: number): this; + + /** + * Sets x value of this vector. + */ + setX(x: number): Vector3; + + /** + * Sets y value of this vector. + */ + setY(y: number): Vector3; + + /** + * Sets z value of this vector. + */ + setZ(z: number): Vector3; + + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + /** + * Clones this vector. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector3): this; + + /** + * Adds v to this vector. + */ + add(v: Vector3): this; + + addScalar(s: number): this; + + addScaledVector(v: Vector3, s: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector3, b: Vector3): this; + + /** + * Subtracts v from this vector. + */ + sub(a: Vector3): this; + + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector3, b: Vector3): this; + + multiply(v: Vector3): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): this; + + multiplyVectors(a: Vector3, b: Vector3): this; + + applyEuler(euler: Euler): this; + + applyAxisAngle(axis: Vector3, angle: number): this; + + applyMatrix3(m: Matrix3): this; + + applyNormalMatrix(m: Matrix3): this; + + applyMatrix4(m: Matrix4): this; + + applyQuaternion(q: Quaternion): this; + + project(camera: Camera): this; + + unproject(camera: Camera): this; + + transformDirection(m: Matrix4): this; + + divide(v: Vector3): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + min(v: Vector3): this; + + max(v: Vector3): this; + + clamp(min: Vector3, max: Vector3): this; + + clampScalar(min: number, max: number): this; + + clampLength(min: number, max: number): this; + + floor(): this; + + ceil(): this; + + round(): this; + + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector3): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Computes Manhattan length of this vector. + * http://en.wikipedia.org/wiki/Taxicab_geometry + * + * @deprecated Use {@link Vector3#manhattanLength .manhattanLength()} instead. + */ + lengthManhattan(): number; + + /** + * Computes the Manhattan length of this vector. + * + * see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Computes the Manhattan length (distance) from this vector to the given vector v + * + * see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanDistanceTo(v: Vector3): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(l: number): this; + lerp(v: Vector3, alpha: number): this; + + lerpVectors(v1: Vector3, v2: Vector3, alpha: number): this; + + /** + * Sets this vector to cross product of itself and v. + */ + cross(a: Vector3): this; + + /** + * Sets this vector to cross product of a and b. + */ + crossVectors(a: Vector3, b: Vector3): this; + projectOnVector(v: Vector3): this; + projectOnPlane(planeNormal: Vector3): this; + reflect(vector: Vector3): this; + angleTo(v: Vector3): number; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector3): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector3): number; + + /** + * @deprecated Use {@link Vector3#manhattanDistanceTo .manhattanDistanceTo()} instead. + */ + distanceToManhattan(v: Vector3): number; + + setFromSpherical(s: Spherical): this; + setFromSphericalCoords(r: number, phi: number, theta: number): this; + setFromCylindrical(s: Cylindrical): this; + setFromCylindricalCoords(radius: number, theta: number, y: number): this; + setFromMatrixPosition(m: Matrix4): this; + setFromMatrixScale(m: Matrix4): this; + setFromMatrixColumn(matrix: Matrix4, index: number): this; + setFromMatrix3Column(matrix: Matrix3, index: number): this; + + /** + * Sets this vector's {@link x}, {@link y} and {@link z} components from the x, y, and z components of the specified {@link Euler Euler Angle}. + */ + setFromEuler(e: Euler): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector3): boolean; + + /** + * Sets this vector's x, y and z value from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array [x, y, z], or copies x, y and z into the provided array. + * @param array (optional) array to store the vector to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + toArray(array?: Vector3Tuple, offset?: 0): Vector3Tuple; + + /** + * Copies x, y and z into the provided array-like. + * @param array array-like to store the vector to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(array: ArrayLike, offset?: number): ArrayLike; + + fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this; + + /** + * Sets this vector's x, y and z from Math.random + */ + random(): this; + + randomDirection(): this; +} diff --git a/backend/libs/three/math/Vector3.js b/backend/libs/three/math/Vector3.js new file mode 100644 index 0000000000000000000000000000000000000000..0132befa5030e24ae9328c303a83a7407d7d3d2c --- /dev/null +++ b/backend/libs/three/math/Vector3.js @@ -0,0 +1,609 @@ +import * as MathUtils from './MathUtils.js'; +import { Quaternion } from './Quaternion.js'; + +class Vector3 { + constructor(x = 0, y = 0, z = 0) { + this.x = x; + this.y = y; + this.z = z; + } + + set(x, y, z) { + if (z === undefined) z = this.z; // sprite.scale.set(x,y) + + this.x = x; + this.y = y; + this.z = z; + + return this; + } + + setScalar(scalar) { + this.x = scalar; + this.y = scalar; + this.z = scalar; + + return this; + } + + setX(x) { + this.x = x; + + return this; + } + + setY(y) { + this.y = y; + + return this; + } + + setZ(z) { + this.z = z; + + return this; + } + + setComponent(index, value) { + switch (index) { + case 0: + this.x = value; + break; + case 1: + this.y = value; + break; + case 2: + this.z = value; + break; + default: + throw new Error('index is out of range: ' + index); + } + + return this; + } + + getComponent(index) { + switch (index) { + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + default: + throw new Error('index is out of range: ' + index); + } + } + + clone() { + return new this.constructor(this.x, this.y, this.z); + } + + copy(v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + + return this; + } + + add(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.'); + return this.addVectors(v, w); + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + + return this; + } + + addScalar(s) { + this.x += s; + this.y += s; + this.z += s; + + return this; + } + + addVectors(a, b) { + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + + return this; + } + + addScaledVector(v, s) { + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + + return this; + } + + sub(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.'); + return this.subVectors(v, w); + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + + return this; + } + + subScalar(s) { + this.x -= s; + this.y -= s; + this.z -= s; + + return this; + } + + subVectors(a, b) { + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + + return this; + } + + multiply(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.'); + return this.multiplyVectors(v, w); + } + + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + + return this; + } + + multiplyScalar(scalar) { + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + + return this; + } + + multiplyVectors(a, b) { + this.x = a.x * b.x; + this.y = a.y * b.y; + this.z = a.z * b.z; + + return this; + } + + applyEuler(euler) { + if (!(euler && euler.isEuler)) { + console.error('THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.'); + } + + return this.applyQuaternion(_quaternion.setFromEuler(euler)); + } + + applyAxisAngle(axis, angle) { + return this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle)); + } + + applyMatrix3(m) { + const x = this.x, + y = this.y, + z = this.z; + const e = m.elements; + + this.x = e[0] * x + e[3] * y + e[6] * z; + this.y = e[1] * x + e[4] * y + e[7] * z; + this.z = e[2] * x + e[5] * y + e[8] * z; + + return this; + } + + applyNormalMatrix(m) { + return this.applyMatrix3(m).normalize(); + } + + applyMatrix4(m) { + const x = this.x, + y = this.y, + z = this.z; + const e = m.elements; + + const w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]); + + this.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w; + this.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w; + this.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w; + + return this; + } + + applyQuaternion(q) { + const x = this.x, + y = this.y, + z = this.z; + const qx = q.x, + qy = q.y, + qz = q.z, + qw = q.w; + + // calculate quat * vector + + const ix = qw * x + qy * z - qz * y; + const iy = qw * y + qz * x - qx * z; + const iz = qw * z + qx * y - qy * x; + const iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + } + + project(camera) { + return this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix); + } + + unproject(camera) { + return this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld); + } + + transformDirection(m) { + // input: THREE.Matrix4 affine matrix + // vector interpreted as a direction + + const x = this.x, + y = this.y, + z = this.z; + const e = m.elements; + + this.x = e[0] * x + e[4] * y + e[8] * z; + this.y = e[1] * x + e[5] * y + e[9] * z; + this.z = e[2] * x + e[6] * y + e[10] * z; + + return this.normalize(); + } + + divide(v) { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; + + return this; + } + + divideScalar(scalar) { + return this.multiplyScalar(1 / scalar); + } + + min(v) { + this.x = Math.min(this.x, v.x); + this.y = Math.min(this.y, v.y); + this.z = Math.min(this.z, v.z); + + return this; + } + + max(v) { + this.x = Math.max(this.x, v.x); + this.y = Math.max(this.y, v.y); + this.z = Math.max(this.z, v.z); + + return this; + } + + clamp(min, max) { + // assumes min < max, componentwise + + this.x = Math.max(min.x, Math.min(max.x, this.x)); + this.y = Math.max(min.y, Math.min(max.y, this.y)); + this.z = Math.max(min.z, Math.min(max.z, this.z)); + + return this; + } + + clampScalar(minVal, maxVal) { + this.x = Math.max(minVal, Math.min(maxVal, this.x)); + this.y = Math.max(minVal, Math.min(maxVal, this.y)); + this.z = Math.max(minVal, Math.min(maxVal, this.z)); + + return this; + } + + clampLength(min, max) { + const length = this.length(); + + return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length))); + } + + floor() { + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + this.z = Math.floor(this.z); + + return this; + } + + ceil() { + this.x = Math.ceil(this.x); + this.y = Math.ceil(this.y); + this.z = Math.ceil(this.z); + + return this; + } + + round() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + this.z = Math.round(this.z); + + return this; + } + + roundToZero() { + this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x); + this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y); + this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z); + + return this; + } + + negate() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + } + + dot(v) { + return this.x * v.x + this.y * v.y + this.z * v.z; + } + + // TODO lengthSquared? + + lengthSq() { + return this.x * this.x + this.y * this.y + this.z * this.z; + } + + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + } + + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z); + } + + normalize() { + return this.divideScalar(this.length() || 1); + } + + setLength(length) { + return this.normalize().multiplyScalar(length); + } + + lerp(v, alpha) { + this.x += (v.x - this.x) * alpha; + this.y += (v.y - this.y) * alpha; + this.z += (v.z - this.z) * alpha; + + return this; + } + + lerpVectors(v1, v2, alpha) { + this.x = v1.x + (v2.x - v1.x) * alpha; + this.y = v1.y + (v2.y - v1.y) * alpha; + this.z = v1.z + (v2.z - v1.z) * alpha; + + return this; + } + + cross(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.'); + return this.crossVectors(v, w); + } + + return this.crossVectors(this, v); + } + + crossVectors(a, b) { + const ax = a.x, + ay = a.y, + az = a.z; + const bx = b.x, + by = b.y, + bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + } + + projectOnVector(v) { + const denominator = v.lengthSq(); + + if (denominator === 0) return this.set(0, 0, 0); + + const scalar = v.dot(this) / denominator; + + return this.copy(v).multiplyScalar(scalar); + } + + projectOnPlane(planeNormal) { + _vector.copy(this).projectOnVector(planeNormal); + + return this.sub(_vector); + } + + reflect(normal) { + // reflect incident vector off plane orthogonal to normal + // normal is assumed to have unit length + + return this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal))); + } + + angleTo(v) { + const denominator = Math.sqrt(this.lengthSq() * v.lengthSq()); + + if (denominator === 0) return Math.PI / 2; + + const theta = this.dot(v) / denominator; + + // clamp, to handle numerical problems + + return Math.acos(MathUtils.clamp(theta, -1, 1)); + } + + distanceTo(v) { + return Math.sqrt(this.distanceToSquared(v)); + } + + distanceToSquared(v) { + const dx = this.x - v.x, + dy = this.y - v.y, + dz = this.z - v.z; + + return dx * dx + dy * dy + dz * dz; + } + + manhattanDistanceTo(v) { + return Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z); + } + + setFromSpherical(s) { + return this.setFromSphericalCoords(s.radius, s.phi, s.theta); + } + + setFromSphericalCoords(radius, phi, theta) { + const sinPhiRadius = Math.sin(phi) * radius; + + this.x = sinPhiRadius * Math.sin(theta); + this.y = Math.cos(phi) * radius; + this.z = sinPhiRadius * Math.cos(theta); + + return this; + } + + setFromCylindrical(c) { + return this.setFromCylindricalCoords(c.radius, c.theta, c.y); + } + + setFromCylindricalCoords(radius, theta, y) { + this.x = radius * Math.sin(theta); + this.y = y; + this.z = radius * Math.cos(theta); + + return this; + } + + setFromMatrixPosition(m) { + const e = m.elements; + + this.x = e[12]; + this.y = e[13]; + this.z = e[14]; + + return this; + } + + setFromMatrixScale(m) { + const sx = this.setFromMatrixColumn(m, 0).length(); + const sy = this.setFromMatrixColumn(m, 1).length(); + const sz = this.setFromMatrixColumn(m, 2).length(); + + this.x = sx; + this.y = sy; + this.z = sz; + + return this; + } + + setFromMatrixColumn(m, index) { + return this.fromArray(m.elements, index * 4); + } + + setFromMatrix3Column(m, index) { + return this.fromArray(m.elements, index * 3); + } + + equals(v) { + return v.x === this.x && v.y === this.y && v.z === this.z; + } + + fromArray(array, offset = 0) { + this.x = array[offset]; + this.y = array[offset + 1]; + this.z = array[offset + 2]; + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this.x; + array[offset + 1] = this.y; + array[offset + 2] = this.z; + + return array; + } + + fromBufferAttribute(attribute, index, offset) { + if (offset !== undefined) { + console.warn('THREE.Vector3: offset has been removed from .fromBufferAttribute().'); + } + + this.x = attribute.getX(index); + this.y = attribute.getY(index); + this.z = attribute.getZ(index); + + return this; + } + + random() { + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + + return this; + } + + randomDirection() { + // Derived from https://mathworld.wolfram.com/SpherePointPicking.html + + const u = (Math.random() - 0.5) * 2; + const t = Math.random() * Math.PI * 2; + const f = Math.sqrt(1 - u ** 2); + + this.x = f * Math.cos(t); + this.y = f * Math.sin(t); + this.z = u; + + return this; + } + + *[Symbol.iterator]() { + yield this.x; + yield this.y; + yield this.z; + } +} + +Vector3.prototype.isVector3 = true; + +const _vector = /*@__PURE__*/ new Vector3(); +const _quaternion = /*@__PURE__*/ new Quaternion(); + +export { Vector3 }; diff --git a/backend/libs/three/math/Vector4.d.ts b/backend/libs/three/math/Vector4.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b8124c3f735e850a08031bfac77f5452b227ce98 --- /dev/null +++ b/backend/libs/three/math/Vector4.d.ts @@ -0,0 +1,223 @@ +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { Vector } from './Vector2'; + +export type Vector4Tuple = [number, number, number, number]; + +/** + * 4D vector. + * + * ( class Vector4 implements Vector ) + */ +export class Vector4 implements Vector { + constructor(x?: number, y?: number, z?: number, w?: number); + + /** + * @default 0 + */ + x: number; + + /** + * @default 0 + */ + y: number; + + /** + * @default 0 + */ + z: number; + + /** + * @default 0 + */ + w: number; + + width: number; + height: number; + readonly isVector4: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number, w: number): this; + + /** + * Sets all values of this vector. + */ + setScalar(scalar: number): this; + + /** + * Sets X component of this vector. + */ + setX(x: number): this; + + /** + * Sets Y component of this vector. + */ + setY(y: number): this; + + /** + * Sets Z component of this vector. + */ + setZ(z: number): this; + + /** + * Sets w component of this vector. + */ + setW(w: number): this; + + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + /** + * Clones this vector. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector4): this; + + /** + * Adds v to this vector. + */ + add(v: Vector4): this; + + addScalar(scalar: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector4, b: Vector4): this; + + addScaledVector(v: Vector4, s: number): this; + /** + * Subtracts v from this vector. + */ + sub(v: Vector4): this; + + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector4, b: Vector4): this; + + multiply(v: Vector4): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): this; + + applyMatrix4(m: Matrix4): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + * @param q is assumed to be normalized + */ + setAxisAngleFromQuaternion(q: Quaternion): this; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + */ + setAxisAngleFromRotationMatrix(m: Matrix4): this; + + min(v: Vector4): this; + max(v: Vector4): this; + clamp(min: Vector4, max: Vector4): this; + clampScalar(min: number, max: number): this; + floor(): this; + ceil(): this; + round(): this; + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector4): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Computes the Manhattan length of this vector. + * + * see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(length: number): this; + + /** + * Linearly interpolate between this vector and v with alpha factor. + */ + lerp(v: Vector4, alpha: number): this; + + lerpVectors(v1: Vector4, v2: Vector4, alpha: number): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector4): boolean; + + /** + * Sets this vector's x, y, z and w value from the provided array or array-like. + * @param array the source array or array-like. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[] | ArrayLike, offset?: number): this; + + /** + * Returns an array [x, y, z, w], or copies x, y, z and w into the provided array. + * @param array (optional) array to store the vector to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + * @return The created or provided array. + */ + toArray(array?: number[], offset?: number): number[]; + toArray(array?: Vector4Tuple, offset?: 0): Vector4Tuple; + + /** + * Copies x, y, z and w into the provided array-like. + * @param array array-like to store the vector to. + * @param offset (optional) optional offset into the array-like. + * @return The provided array-like. + */ + toArray(array: ArrayLike, offset?: number): ArrayLike; + + fromBufferAttribute(attribute: BufferAttribute, index: number): this; + + /** + * Sets this vector's x, y, z and w from Math.random + */ + random(): this; +} diff --git a/backend/libs/three/math/Vector4.js b/backend/libs/three/math/Vector4.js new file mode 100644 index 0000000000000000000000000000000000000000..cbd0149554a22c464687eaa1646a4dd02c010268 --- /dev/null +++ b/backend/libs/three/math/Vector4.js @@ -0,0 +1,541 @@ +class Vector4 { + constructor(x = 0, y = 0, z = 0, w = 1) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + get width() { + return this.z; + } + + set width(value) { + this.z = value; + } + + get height() { + return this.w; + } + + set height(value) { + this.w = value; + } + + set(x, y, z, w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + } + + setScalar(scalar) { + this.x = scalar; + this.y = scalar; + this.z = scalar; + this.w = scalar; + + return this; + } + + setX(x) { + this.x = x; + + return this; + } + + setY(y) { + this.y = y; + + return this; + } + + setZ(z) { + this.z = z; + + return this; + } + + setW(w) { + this.w = w; + + return this; + } + + setComponent(index, value) { + switch (index) { + case 0: + this.x = value; + break; + case 1: + this.y = value; + break; + case 2: + this.z = value; + break; + case 3: + this.w = value; + break; + default: + throw new Error('index is out of range: ' + index); + } + + return this; + } + + getComponent(index) { + switch (index) { + case 0: + return this.x; + case 1: + return this.y; + case 2: + return this.z; + case 3: + return this.w; + default: + throw new Error('index is out of range: ' + index); + } + } + + clone() { + return new this.constructor(this.x, this.y, this.z, this.w); + } + + copy(v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + this.w = v.w !== undefined ? v.w : 1; + + return this; + } + + add(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.'); + return this.addVectors(v, w); + } + + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + } + + addScalar(s) { + this.x += s; + this.y += s; + this.z += s; + this.w += s; + + return this; + } + + addVectors(a, b) { + this.x = a.x + b.x; + this.y = a.y + b.y; + this.z = a.z + b.z; + this.w = a.w + b.w; + + return this; + } + + addScaledVector(v, s) { + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + this.w += v.w * s; + + return this; + } + + sub(v, w) { + if (w !== undefined) { + console.warn('THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.'); + return this.subVectors(v, w); + } + + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + } + + subScalar(s) { + this.x -= s; + this.y -= s; + this.z -= s; + this.w -= s; + + return this; + } + + subVectors(a, b) { + this.x = a.x - b.x; + this.y = a.y - b.y; + this.z = a.z - b.z; + this.w = a.w - b.w; + + return this; + } + + multiply(v) { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; + this.w *= v.w; + + return this; + } + + multiplyScalar(scalar) { + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; + this.w *= scalar; + + return this; + } + + applyMatrix4(m) { + const x = this.x, + y = this.y, + z = this.z, + w = this.w; + const e = m.elements; + + this.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w; + this.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w; + this.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w; + this.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w; + + return this; + } + + divideScalar(scalar) { + return this.multiplyScalar(1 / scalar); + } + + setAxisAngleFromQuaternion(q) { + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + + // q is assumed to be normalized + + this.w = 2 * Math.acos(q.w); + + const s = Math.sqrt(1 - q.w * q.w); + + if (s < 0.0001) { + this.x = 1; + this.y = 0; + this.z = 0; + } else { + this.x = q.x / s; + this.y = q.y / s; + this.z = q.z / s; + } + + return this; + } + + setAxisAngleFromRotationMatrix(m) { + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + + let angle, x, y, z; // variables for result + const epsilon = 0.01, // margin to allow for rounding errors + epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees + te = m.elements, + m11 = te[0], + m12 = te[4], + m13 = te[8], + m21 = te[1], + m22 = te[5], + m23 = te[9], + m31 = te[2], + m32 = te[6], + m33 = te[10]; + + if (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) { + // singularity found + // first check for identity matrix which must have +1 for all terms + // in leading diagonal and zero in other terms + + if ( + Math.abs(m12 + m21) < epsilon2 && + Math.abs(m13 + m31) < epsilon2 && + Math.abs(m23 + m32) < epsilon2 && + Math.abs(m11 + m22 + m33 - 3) < epsilon2 + ) { + // this singularity is identity matrix so angle = 0 + + this.set(1, 0, 0, 0); + + return this; // zero angle, arbitrary axis + } + + // otherwise this singularity is angle = 180 + + angle = Math.PI; + + const xx = (m11 + 1) / 2; + const yy = (m22 + 1) / 2; + const zz = (m33 + 1) / 2; + const xy = (m12 + m21) / 4; + const xz = (m13 + m31) / 4; + const yz = (m23 + m32) / 4; + + if (xx > yy && xx > zz) { + // m11 is the largest diagonal term + + if (xx < epsilon) { + x = 0; + y = 0.707106781; + z = 0.707106781; + } else { + x = Math.sqrt(xx); + y = xy / x; + z = xz / x; + } + } else if (yy > zz) { + // m22 is the largest diagonal term + + if (yy < epsilon) { + x = 0.707106781; + y = 0; + z = 0.707106781; + } else { + y = Math.sqrt(yy); + x = xy / y; + z = yz / y; + } + } else { + // m33 is the largest diagonal term so base result on this + + if (zz < epsilon) { + x = 0.707106781; + y = 0.707106781; + z = 0; + } else { + z = Math.sqrt(zz); + x = xz / z; + y = yz / z; + } + } + + this.set(x, y, z, angle); + + return this; // return 180 deg rotation + } + + // as we have reached here there are no singularities so we can handle normally + + let s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12)); // used to normalize + + if (Math.abs(s) < 0.001) s = 1; + + // prevent divide by zero, should not happen if matrix is orthogonal and should be + // caught by singularity test above, but I've left it in just in case + + this.x = (m32 - m23) / s; + this.y = (m13 - m31) / s; + this.z = (m21 - m12) / s; + this.w = Math.acos((m11 + m22 + m33 - 1) / 2); + + return this; + } + + min(v) { + this.x = Math.min(this.x, v.x); + this.y = Math.min(this.y, v.y); + this.z = Math.min(this.z, v.z); + this.w = Math.min(this.w, v.w); + + return this; + } + + max(v) { + this.x = Math.max(this.x, v.x); + this.y = Math.max(this.y, v.y); + this.z = Math.max(this.z, v.z); + this.w = Math.max(this.w, v.w); + + return this; + } + + clamp(min, max) { + // assumes min < max, componentwise + + this.x = Math.max(min.x, Math.min(max.x, this.x)); + this.y = Math.max(min.y, Math.min(max.y, this.y)); + this.z = Math.max(min.z, Math.min(max.z, this.z)); + this.w = Math.max(min.w, Math.min(max.w, this.w)); + + return this; + } + + clampScalar(minVal, maxVal) { + this.x = Math.max(minVal, Math.min(maxVal, this.x)); + this.y = Math.max(minVal, Math.min(maxVal, this.y)); + this.z = Math.max(minVal, Math.min(maxVal, this.z)); + this.w = Math.max(minVal, Math.min(maxVal, this.w)); + + return this; + } + + clampLength(min, max) { + const length = this.length(); + + return this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length))); + } + + floor() { + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + this.z = Math.floor(this.z); + this.w = Math.floor(this.w); + + return this; + } + + ceil() { + this.x = Math.ceil(this.x); + this.y = Math.ceil(this.y); + this.z = Math.ceil(this.z); + this.w = Math.ceil(this.w); + + return this; + } + + round() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + this.z = Math.round(this.z); + this.w = Math.round(this.w); + + return this; + } + + roundToZero() { + this.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x); + this.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y); + this.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z); + this.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w); + + return this; + } + + negate() { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + } + + dot(v) { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + } + + lengthSq() { + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + } + + length() { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); + } + + manhattanLength() { + return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); + } + + normalize() { + return this.divideScalar(this.length() || 1); + } + + setLength(length) { + return this.normalize().multiplyScalar(length); + } + + lerp(v, alpha) { + this.x += (v.x - this.x) * alpha; + this.y += (v.y - this.y) * alpha; + this.z += (v.z - this.z) * alpha; + this.w += (v.w - this.w) * alpha; + + return this; + } + + lerpVectors(v1, v2, alpha) { + this.x = v1.x + (v2.x - v1.x) * alpha; + this.y = v1.y + (v2.y - v1.y) * alpha; + this.z = v1.z + (v2.z - v1.z) * alpha; + this.w = v1.w + (v2.w - v1.w) * alpha; + + return this; + } + + equals(v) { + return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w; + } + + fromArray(array, offset = 0) { + this.x = array[offset]; + this.y = array[offset + 1]; + this.z = array[offset + 2]; + this.w = array[offset + 3]; + + return this; + } + + toArray(array = [], offset = 0) { + array[offset] = this.x; + array[offset + 1] = this.y; + array[offset + 2] = this.z; + array[offset + 3] = this.w; + + return array; + } + + fromBufferAttribute(attribute, index, offset) { + if (offset !== undefined) { + console.warn('THREE.Vector4: offset has been removed from .fromBufferAttribute().'); + } + + this.x = attribute.getX(index); + this.y = attribute.getY(index); + this.z = attribute.getZ(index); + this.w = attribute.getW(index); + + return this; + } + + random() { + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + this.w = Math.random(); + + return this; + } + + *[Symbol.iterator]() { + yield this.x; + yield this.y; + yield this.z; + yield this.w; + } +} + +Vector4.prototype.isVector4 = true; + +export { Vector4 }; diff --git a/backend/libs/three/math/interpolants/CubicInterpolant.d.ts b/backend/libs/three/math/interpolants/CubicInterpolant.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..623748ff6f9ac437e5ceddf9d491a0e1b9aca487 --- /dev/null +++ b/backend/libs/three/math/interpolants/CubicInterpolant.d.ts @@ -0,0 +1,7 @@ +import { Interpolant } from '../Interpolant'; + +export class CubicInterpolant extends Interpolant { + constructor(parameterPositions: any, samplesValues: any, sampleSize: number, resultBuffer?: any); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/backend/libs/three/math/interpolants/CubicInterpolant.js b/backend/libs/three/math/interpolants/CubicInterpolant.js new file mode 100644 index 0000000000000000000000000000000000000000..accd466bccabf4664209039d8c8c9fb1f21a4291 --- /dev/null +++ b/backend/libs/three/math/interpolants/CubicInterpolant.js @@ -0,0 +1,125 @@ +import { ZeroCurvatureEnding } from '../../constants.js'; +import { Interpolant } from '../Interpolant.js'; +import { WrapAroundEnding, ZeroSlopeEnding } from '../../constants.js'; + +/** + * Fast and simple cubic spline interpolant. + * + * It was derived from a Hermitian construction setting the first derivative + * at each sample position to the linear slope between neighboring positions + * over their parameter interval. + */ + +class CubicInterpolant extends Interpolant { + constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { + super(parameterPositions, sampleValues, sampleSize, resultBuffer); + + this._weightPrev = -0; + this._offsetPrev = -0; + this._weightNext = -0; + this._offsetNext = -0; + + this.DefaultSettings_ = { + endingStart: ZeroCurvatureEnding, + endingEnd: ZeroCurvatureEnding, + }; + } + + intervalChanged_(i1, t0, t1) { + const pp = this.parameterPositions; + let iPrev = i1 - 2, + iNext = i1 + 1, + tPrev = pp[iPrev], + tNext = pp[iNext]; + + if (tPrev === undefined) { + switch (this.getSettings_().endingStart) { + case ZeroSlopeEnding: + // f'(t0) = 0 + iPrev = i1; + tPrev = 2 * t0 - t1; + + break; + + case WrapAroundEnding: + // use the other end of the curve + iPrev = pp.length - 2; + tPrev = t0 + pp[iPrev] - pp[iPrev + 1]; + + break; + + default: + // ZeroCurvatureEnding + + // f''(t0) = 0 a.k.a. Natural Spline + iPrev = i1; + tPrev = t1; + } + } + + if (tNext === undefined) { + switch (this.getSettings_().endingEnd) { + case ZeroSlopeEnding: + // f'(tN) = 0 + iNext = i1; + tNext = 2 * t1 - t0; + + break; + + case WrapAroundEnding: + // use the other end of the curve + iNext = 1; + tNext = t1 + pp[1] - pp[0]; + + break; + + default: + // ZeroCurvatureEnding + + // f''(tN) = 0, a.k.a. Natural Spline + iNext = i1 - 1; + tNext = t0; + } + } + + const halfDt = (t1 - t0) * 0.5, + stride = this.valueSize; + + this._weightPrev = halfDt / (t0 - tPrev); + this._weightNext = halfDt / (tNext - t1); + this._offsetPrev = iPrev * stride; + this._offsetNext = iNext * stride; + } + + interpolate_(i1, t0, t, t1) { + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + o1 = i1 * stride, + o0 = o1 - stride, + oP = this._offsetPrev, + oN = this._offsetNext, + wP = this._weightPrev, + wN = this._weightNext, + p = (t - t0) / (t1 - t0), + pp = p * p, + ppp = pp * p; + + // evaluate polynomials + + const sP = -wP * ppp + 2 * wP * pp - wP * p; + const s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1; + const s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p; + const sN = wN * ppp - wN * pp; + + // combine data linearly + + for (let i = 0; i !== stride; ++i) { + result[i] = sP * values[oP + i] + s0 * values[o0 + i] + s1 * values[o1 + i] + sN * values[oN + i]; + } + + return result; + } +} + +export { CubicInterpolant }; diff --git a/backend/libs/three/math/interpolants/DiscreteInterpolant.d.ts b/backend/libs/three/math/interpolants/DiscreteInterpolant.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d5fbf2e26e87b6f74e4eb3d61ae6758d602257c1 --- /dev/null +++ b/backend/libs/three/math/interpolants/DiscreteInterpolant.d.ts @@ -0,0 +1,7 @@ +import { Interpolant } from '../Interpolant'; + +export class DiscreteInterpolant extends Interpolant { + constructor(parameterPositions: any, samplesValues: any, sampleSize: number, resultBuffer?: any); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/backend/libs/three/math/interpolants/DiscreteInterpolant.js b/backend/libs/three/math/interpolants/DiscreteInterpolant.js new file mode 100644 index 0000000000000000000000000000000000000000..b7e8428b9e7fb66bc4125cfd5953c129c82de274 --- /dev/null +++ b/backend/libs/three/math/interpolants/DiscreteInterpolant.js @@ -0,0 +1,19 @@ +import { Interpolant } from '../Interpolant.js'; + +/** + * + * Interpolant that evaluates to the sample value at the position preceeding + * the parameter. + */ + +class DiscreteInterpolant extends Interpolant { + constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { + super(parameterPositions, sampleValues, sampleSize, resultBuffer); + } + + interpolate_(i1 /*, t0, t, t1 */) { + return this.copySampleValue_(i1 - 1); + } +} + +export { DiscreteInterpolant }; diff --git a/backend/libs/three/math/interpolants/LinearInterpolant.d.ts b/backend/libs/three/math/interpolants/LinearInterpolant.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..614d8825214e111fb4dcba943e43043ecc8398fc --- /dev/null +++ b/backend/libs/three/math/interpolants/LinearInterpolant.d.ts @@ -0,0 +1,7 @@ +import { Interpolant } from '../Interpolant'; + +export class LinearInterpolant extends Interpolant { + constructor(parameterPositions: any, samplesValues: any, sampleSize: number, resultBuffer?: any); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/backend/libs/three/math/interpolants/LinearInterpolant.js b/backend/libs/three/math/interpolants/LinearInterpolant.js new file mode 100644 index 0000000000000000000000000000000000000000..13ee945a3c7ae7ce1c29826a220b4b36a4d6c09f --- /dev/null +++ b/backend/libs/three/math/interpolants/LinearInterpolant.js @@ -0,0 +1,25 @@ +import { Interpolant } from '../Interpolant.js'; + +class LinearInterpolant extends Interpolant { + constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { + super(parameterPositions, sampleValues, sampleSize, resultBuffer); + } + + interpolate_(i1, t0, t, t1) { + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + offset1 = i1 * stride, + offset0 = offset1 - stride, + weight1 = (t - t0) / (t1 - t0), + weight0 = 1 - weight1; + + for (let i = 0; i !== stride; ++i) { + result[i] = values[offset0 + i] * weight0 + values[offset1 + i] * weight1; + } + + return result; + } +} + +export { LinearInterpolant }; diff --git a/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.d.ts b/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9a780fc0be2339fbc3be81a925511369bca304bc --- /dev/null +++ b/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.d.ts @@ -0,0 +1,7 @@ +import { Interpolant } from '../Interpolant'; + +export class QuaternionLinearInterpolant extends Interpolant { + constructor(parameterPositions: any, samplesValues: any, sampleSize: number, resultBuffer?: any); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.js b/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.js new file mode 100644 index 0000000000000000000000000000000000000000..2f19ff49b15c4799ec38b676fe68dea26d901c48 --- /dev/null +++ b/backend/libs/three/math/interpolants/QuaternionLinearInterpolant.js @@ -0,0 +1,29 @@ +import { Interpolant } from '../Interpolant.js'; +import { Quaternion } from '../Quaternion.js'; + +/** + * Spherical linear unit quaternion interpolant. + */ + +class QuaternionLinearInterpolant extends Interpolant { + constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { + super(parameterPositions, sampleValues, sampleSize, resultBuffer); + } + + interpolate_(i1, t0, t, t1) { + const result = this.resultBuffer, + values = this.sampleValues, + stride = this.valueSize, + alpha = (t - t0) / (t1 - t0); + + let offset = i1 * stride; + + for (let end = offset + stride; offset !== end; offset += 4) { + Quaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha); + } + + return result; + } +} + +export { QuaternionLinearInterpolant }; diff --git a/backend/libs/three/objects/Bone.d.ts b/backend/libs/three/objects/Bone.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fe3dc3c1c549cd126ec9012ff7290c710ac3b155 --- /dev/null +++ b/backend/libs/three/objects/Bone.d.ts @@ -0,0 +1,9 @@ +import { Object3D } from './../core/Object3D'; + +// Objects ////////////////////////////////////////////////////////////////////////////////// + +export class Bone extends Object3D { + constructor(); + readonly isBone: true; + type: 'Bone'; +} diff --git a/backend/libs/three/objects/Bone.js b/backend/libs/three/objects/Bone.js new file mode 100644 index 0000000000000000000000000000000000000000..867607d9e3177dc306cfa16b0d15a2246eb9f91d --- /dev/null +++ b/backend/libs/three/objects/Bone.js @@ -0,0 +1,13 @@ +import { Object3D } from '../core/Object3D.js'; + +class Bone extends Object3D { + constructor() { + super(); + + this.type = 'Bone'; + } +} + +Bone.prototype.isBone = true; + +export { Bone }; diff --git a/backend/libs/three/objects/Group.d.ts b/backend/libs/three/objects/Group.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b8b99edc3e00082c7ffb17220fed02868c0133d4 --- /dev/null +++ b/backend/libs/three/objects/Group.d.ts @@ -0,0 +1,7 @@ +import { Object3D } from './../core/Object3D'; + +export class Group extends Object3D { + constructor(); + type: 'Group'; + readonly isGroup: true; +} diff --git a/backend/libs/three/objects/Group.js b/backend/libs/three/objects/Group.js new file mode 100644 index 0000000000000000000000000000000000000000..22aa18aa811c3f8a17af85ab4d7b7acdec79ff2a --- /dev/null +++ b/backend/libs/three/objects/Group.js @@ -0,0 +1,13 @@ +import { Object3D } from '../core/Object3D.js'; + +class Group extends Object3D { + constructor() { + super(); + + this.type = 'Group'; + } +} + +Group.prototype.isGroup = true; + +export { Group }; diff --git a/backend/libs/three/objects/InstancedMesh.d.ts b/backend/libs/three/objects/InstancedMesh.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a8377ef29dec13a25b87f5919cc312722f6e20dc --- /dev/null +++ b/backend/libs/three/objects/InstancedMesh.d.ts @@ -0,0 +1,25 @@ +import { BufferGeometry } from '../core/BufferGeometry'; +import { Material } from './../materials/Material'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute'; +import { Mesh } from './Mesh'; +import { Matrix4 } from './../math/Matrix4'; +import { Color } from './../math/Color'; + +export class InstancedMesh extends Mesh< + TGeometry, + TMaterial +> { + constructor(geometry: TGeometry | undefined, material: TMaterial | undefined, count: number); + + count: number; + instanceColor: null | InstancedBufferAttribute; + instanceMatrix: InstancedBufferAttribute; + readonly isInstancedMesh: true; + + getColorAt(index: number, color: Color): void; + getMatrixAt(index: number, matrix: Matrix4): void; + setColorAt(index: number, color: Color): void; + setMatrixAt(index: number, matrix: Matrix4): void; + dispose(): void; +} diff --git a/backend/libs/three/objects/InstancedMesh.js b/backend/libs/three/objects/InstancedMesh.js new file mode 100644 index 0000000000000000000000000000000000000000..0c6bb72577ab5ba84a56091edef6b36815923c6d --- /dev/null +++ b/backend/libs/three/objects/InstancedMesh.js @@ -0,0 +1,100 @@ +import { InstancedBufferAttribute } from '../core/InstancedBufferAttribute.js'; +import { Mesh } from './Mesh.js'; +import { Matrix4 } from '../math/Matrix4.js'; + +const _instanceLocalMatrix = /*@__PURE__*/ new Matrix4(); +const _instanceWorldMatrix = /*@__PURE__*/ new Matrix4(); + +const _instanceIntersects = []; + +const _mesh = /*@__PURE__*/ new Mesh(); + +class InstancedMesh extends Mesh { + constructor(geometry, material, count) { + super(geometry, material); + + this.instanceMatrix = new InstancedBufferAttribute(new Float32Array(count * 16), 16); + this.instanceColor = null; + + this.count = count; + + this.frustumCulled = false; + } + + copy(source) { + super.copy(source); + + this.instanceMatrix.copy(source.instanceMatrix); + + if (source.instanceColor !== null) this.instanceColor = source.instanceColor.clone(); + + this.count = source.count; + + return this; + } + + getColorAt(index, color) { + color.fromArray(this.instanceColor.array, index * 3); + } + + getMatrixAt(index, matrix) { + matrix.fromArray(this.instanceMatrix.array, index * 16); + } + + raycast(raycaster, intersects) { + const matrixWorld = this.matrixWorld; + const raycastTimes = this.count; + + _mesh.geometry = this.geometry; + _mesh.material = this.material; + + if (_mesh.material === undefined) return; + + for (let instanceId = 0; instanceId < raycastTimes; instanceId++) { + // calculate the world matrix for each instance + + this.getMatrixAt(instanceId, _instanceLocalMatrix); + + _instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix); + + // the mesh represents this single instance + + _mesh.matrixWorld = _instanceWorldMatrix; + + _mesh.raycast(raycaster, _instanceIntersects); + + // process the result of raycast + + for (let i = 0, l = _instanceIntersects.length; i < l; i++) { + const intersect = _instanceIntersects[i]; + intersect.instanceId = instanceId; + intersect.object = this; + intersects.push(intersect); + } + + _instanceIntersects.length = 0; + } + } + + setColorAt(index, color) { + if (this.instanceColor === null) { + this.instanceColor = new InstancedBufferAttribute(new Float32Array(this.instanceMatrix.count * 3), 3); + } + + color.toArray(this.instanceColor.array, index * 3); + } + + setMatrixAt(index, matrix) { + matrix.toArray(this.instanceMatrix.array, index * 16); + } + + updateMorphTargets() {} + + dispose() { + this.dispatchEvent({ type: 'dispose' }); + } +} + +InstancedMesh.prototype.isInstancedMesh = true; + +export { InstancedMesh }; diff --git a/backend/libs/three/objects/LOD.d.ts b/backend/libs/three/objects/LOD.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..402a71db22951472f331e36b21026c6f4afe790c --- /dev/null +++ b/backend/libs/three/objects/LOD.d.ts @@ -0,0 +1,26 @@ +import { Object3D } from './../core/Object3D'; +import { Raycaster } from './../core/Raycaster'; +import { Camera } from './../cameras/Camera'; +import { Intersection } from '../core/Raycaster'; + +export class LOD extends Object3D { + constructor(); + + type: 'LOD'; + + levels: Array<{ distance: number; object: Object3D }>; + autoUpdate: boolean; + readonly isLOD: true; + + addLevel(object: Object3D, distance?: number): this; + getCurrentLevel(): number; + getObjectForDistance(distance: number): Object3D | null; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + update(camera: Camera): void; + toJSON(meta: any): any; + + /** + * @deprecated Use {@link LOD#levels .levels} instead. + */ + objects: any[]; +} diff --git a/backend/libs/three/objects/LOD.js b/backend/libs/three/objects/LOD.js new file mode 100644 index 0000000000000000000000000000000000000000..bf6161bb66b5da8496b9a772e0bb2a691c2106a7 --- /dev/null +++ b/backend/libs/three/objects/LOD.js @@ -0,0 +1,150 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Object3D } from '../core/Object3D.js'; + +const _v1 = /*@__PURE__*/ new Vector3(); +const _v2 = /*@__PURE__*/ new Vector3(); + +class LOD extends Object3D { + constructor() { + super(); + + this._currentLevel = 0; + + this.type = 'LOD'; + + Object.defineProperties(this, { + levels: { + enumerable: true, + value: [], + }, + isLOD: { + value: true, + }, + }); + + this.autoUpdate = true; + } + + copy(source) { + super.copy(source, false); + + const levels = source.levels; + + for (let i = 0, l = levels.length; i < l; i++) { + const level = levels[i]; + + this.addLevel(level.object.clone(), level.distance); + } + + this.autoUpdate = source.autoUpdate; + + return this; + } + + addLevel(object, distance = 0) { + distance = Math.abs(distance); + + const levels = this.levels; + + let l; + + for (l = 0; l < levels.length; l++) { + if (distance < levels[l].distance) { + break; + } + } + + levels.splice(l, 0, { distance: distance, object: object }); + + this.add(object); + + return this; + } + + getCurrentLevel() { + return this._currentLevel; + } + + getObjectForDistance(distance) { + const levels = this.levels; + + if (levels.length > 0) { + let i, l; + + for (i = 1, l = levels.length; i < l; i++) { + if (distance < levels[i].distance) { + break; + } + } + + return levels[i - 1].object; + } + + return null; + } + + raycast(raycaster, intersects) { + const levels = this.levels; + + if (levels.length > 0) { + _v1.setFromMatrixPosition(this.matrixWorld); + + const distance = raycaster.ray.origin.distanceTo(_v1); + + this.getObjectForDistance(distance).raycast(raycaster, intersects); + } + } + + update(camera) { + const levels = this.levels; + + if (levels.length > 1) { + _v1.setFromMatrixPosition(camera.matrixWorld); + _v2.setFromMatrixPosition(this.matrixWorld); + + const distance = _v1.distanceTo(_v2) / camera.zoom; + + levels[0].object.visible = true; + + let i, l; + + for (i = 1, l = levels.length; i < l; i++) { + if (distance >= levels[i].distance) { + levels[i - 1].object.visible = false; + levels[i].object.visible = true; + } else { + break; + } + } + + this._currentLevel = i - 1; + + for (; i < l; i++) { + levels[i].object.visible = false; + } + } + } + + toJSON(meta) { + const data = super.toJSON(meta); + + if (this.autoUpdate === false) data.object.autoUpdate = false; + + data.object.levels = []; + + const levels = this.levels; + + for (let i = 0, l = levels.length; i < l; i++) { + const level = levels[i]; + + data.object.levels.push({ + object: level.object.uuid, + distance: level.distance, + }); + } + + return data; + } +} + +export { LOD }; diff --git a/backend/libs/three/objects/Line.d.ts b/backend/libs/three/objects/Line.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..7dc62c9b18a74258a8d73bd28394c268a86dbf20 --- /dev/null +++ b/backend/libs/three/objects/Line.d.ts @@ -0,0 +1,22 @@ +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; + +export class Line extends Object3D { + constructor(geometry?: TGeometry, material?: TMaterial); + + geometry: TGeometry; + material: TMaterial; + + type: 'Line' | 'LineLoop' | 'LineSegments' | string; + readonly isLine: true; + + morphTargetInfluences?: number[] | undefined; + morphTargetDictionary?: { [key: string]: number } | undefined; + + computeLineDistances(): this; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + updateMorphTargets(): void; +} diff --git a/backend/libs/three/objects/Line.js b/backend/libs/three/objects/Line.js new file mode 100644 index 0000000000000000000000000000000000000000..d1b1cfa6db1d491f919c5ca4354da1319a9cb0ab --- /dev/null +++ b/backend/libs/three/objects/Line.js @@ -0,0 +1,202 @@ +import { Sphere } from '../math/Sphere.js'; +import { Ray } from '../math/Ray.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Object3D } from '../core/Object3D.js'; +import { Vector3 } from '../math/Vector3.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; + +const _start = /*@__PURE__*/ new Vector3(); +const _end = /*@__PURE__*/ new Vector3(); +const _inverseMatrix = /*@__PURE__*/ new Matrix4(); +const _ray = /*@__PURE__*/ new Ray(); +const _sphere = /*@__PURE__*/ new Sphere(); + +class Line extends Object3D { + constructor(geometry = new BufferGeometry(), material = new LineBasicMaterial()) { + super(); + + this.type = 'Line'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + } + + copy(source) { + super.copy(source); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + } + + computeLineDistances() { + const geometry = this.geometry; + + if (geometry.isBufferGeometry) { + // we assume non-indexed geometry + + if (geometry.index === null) { + const positionAttribute = geometry.attributes.position; + const lineDistances = [0]; + + for (let i = 1, l = positionAttribute.count; i < l; i++) { + _start.fromBufferAttribute(positionAttribute, i - 1); + _end.fromBufferAttribute(positionAttribute, i); + + lineDistances[i] = lineDistances[i - 1]; + lineDistances[i] += _start.distanceTo(_end); + } + + geometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1)); + } else { + console.warn('THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.'); + } + } else if (geometry.isGeometry) { + console.error('THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + + return this; + } + + raycast(raycaster, intersects) { + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Line.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if (geometry.boundingSphere === null) geometry.computeBoundingSphere(); + + _sphere.copy(geometry.boundingSphere); + _sphere.applyMatrix4(matrixWorld); + _sphere.radius += threshold; + + if (raycaster.ray.intersectsSphere(_sphere) === false) return; + + // + + _inverseMatrix.copy(matrixWorld).invert(); + _ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix); + + const localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3); + const localThresholdSq = localThreshold * localThreshold; + + const vStart = new Vector3(); + const vEnd = new Vector3(); + const interSegment = new Vector3(); + const interRay = new Vector3(); + const step = this.isLineSegments ? 2 : 1; + + if (geometry.isBufferGeometry) { + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if (index !== null) { + const start = Math.max(0, drawRange.start); + const end = Math.min(index.count, drawRange.start + drawRange.count); + + for (let i = start, l = end - 1; i < l; i += step) { + const a = index.getX(i); + const b = index.getX(i + 1); + + vStart.fromBufferAttribute(positionAttribute, a); + vEnd.fromBufferAttribute(positionAttribute, b); + + const distSq = _ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment); + + if (distSq > localThresholdSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo(interRay); + + if (distance < raycaster.near || distance > raycaster.far) continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this, + }); + } + } else { + const start = Math.max(0, drawRange.start); + const end = Math.min(positionAttribute.count, drawRange.start + drawRange.count); + + for (let i = start, l = end - 1; i < l; i += step) { + vStart.fromBufferAttribute(positionAttribute, i); + vEnd.fromBufferAttribute(positionAttribute, i + 1); + + const distSq = _ray.distanceSqToSegment(vStart, vEnd, interRay, interSegment); + + if (distSq > localThresholdSq) continue; + + interRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation + + const distance = raycaster.ray.origin.distanceTo(interRay); + + if (distance < raycaster.near || distance > raycaster.far) continue; + + intersects.push({ + distance: distance, + // What do we want? intersection point on the ray or on the segment?? + // point: raycaster.ray.at( distance ), + point: interSegment.clone().applyMatrix4(this.matrixWorld), + index: i, + face: null, + faceIndex: null, + object: this, + }); + } + } + } else if (geometry.isGeometry) { + console.error('THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } + + updateMorphTargets() { + const geometry = this.geometry; + + if (geometry.isBufferGeometry) { + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys(morphAttributes); + + if (keys.length > 0) { + const morphAttribute = morphAttributes[keys[0]]; + + if (morphAttribute !== undefined) { + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for (let m = 0, ml = morphAttribute.length; m < ml; m++) { + const name = morphAttribute[m].name || String(m); + + this.morphTargetInfluences.push(0); + this.morphTargetDictionary[name] = m; + } + } + } + } else { + const morphTargets = geometry.morphTargets; + + if (morphTargets !== undefined && morphTargets.length > 0) { + console.error('THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } + } +} + +Line.prototype.isLine = true; + +export { Line }; diff --git a/backend/libs/three/objects/LineLoop.d.ts b/backend/libs/three/objects/LineLoop.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3430c19e02919db9acb8eca66489dbe2cd7042d5 --- /dev/null +++ b/backend/libs/three/objects/LineLoop.d.ts @@ -0,0 +1,13 @@ +import { Line } from './Line'; +import { Material } from './../materials/Material'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class LineLoop extends Line< + TGeometry, + TMaterial +> { + constructor(geometry?: TGeometry, material?: TMaterial); + + type: 'LineLoop'; + readonly isLineLoop: true; +} diff --git a/backend/libs/three/objects/LineLoop.js b/backend/libs/three/objects/LineLoop.js new file mode 100644 index 0000000000000000000000000000000000000000..9a89518bbfadbb7bfd68eee60d8379eaea47a2cf --- /dev/null +++ b/backend/libs/three/objects/LineLoop.js @@ -0,0 +1,13 @@ +import { Line } from './Line.js'; + +class LineLoop extends Line { + constructor(geometry, material) { + super(geometry, material); + + this.type = 'LineLoop'; + } +} + +LineLoop.prototype.isLineLoop = true; + +export { LineLoop }; diff --git a/backend/libs/three/objects/LineSegments.d.ts b/backend/libs/three/objects/LineSegments.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f4c1d07ce537c10c9f3addc056cca41b1fd9f3ad --- /dev/null +++ b/backend/libs/three/objects/LineSegments.d.ts @@ -0,0 +1,25 @@ +import { Material } from './../materials/Material'; +import { Line } from './Line'; +import { BufferGeometry } from '../core/BufferGeometry'; + +/** + * @deprecated + */ +export const LineStrip: number; +/** + * @deprecated + */ +export const LinePieces: number; + +export class LineSegments extends Line< + TGeometry, + TMaterial +> { + constructor(geometry?: TGeometry, material?: TMaterial); + + /** + * @default 'LineSegments' + */ + type: 'LineSegments' | string; + readonly isLineSegments: true; +} diff --git a/backend/libs/three/objects/LineSegments.js b/backend/libs/three/objects/LineSegments.js new file mode 100644 index 0000000000000000000000000000000000000000..0ba8670d3d6c646e4b13e7bdcc740a84e8d08a41 --- /dev/null +++ b/backend/libs/three/objects/LineSegments.js @@ -0,0 +1,47 @@ +import { Line } from './Line.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Float32BufferAttribute } from '../core/BufferAttribute.js'; + +const _start = /*@__PURE__*/ new Vector3(); +const _end = /*@__PURE__*/ new Vector3(); + +class LineSegments extends Line { + constructor(geometry, material) { + super(geometry, material); + + this.type = 'LineSegments'; + } + + computeLineDistances() { + const geometry = this.geometry; + + if (geometry.isBufferGeometry) { + // we assume non-indexed geometry + + if (geometry.index === null) { + const positionAttribute = geometry.attributes.position; + const lineDistances = []; + + for (let i = 0, l = positionAttribute.count; i < l; i += 2) { + _start.fromBufferAttribute(positionAttribute, i); + _end.fromBufferAttribute(positionAttribute, i + 1); + + lineDistances[i] = i === 0 ? 0 : lineDistances[i - 1]; + lineDistances[i + 1] = lineDistances[i] + _start.distanceTo(_end); + } + + geometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1)); + } else { + console.warn('THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.'); + } + } else if (geometry.isGeometry) { + console.error('THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + + return this; + } +} + +LineSegments.prototype.isLineSegments = true; + +export { LineSegments }; diff --git a/backend/libs/three/objects/Mesh.d.ts b/backend/libs/three/objects/Mesh.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..49309b29ad9cfd070b829f34d74765721c59c77e --- /dev/null +++ b/backend/libs/three/objects/Mesh.d.ts @@ -0,0 +1,19 @@ +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; + +export class Mesh extends Object3D { + constructor(geometry?: TGeometry, material?: TMaterial); + + geometry: TGeometry; + material: TMaterial; + morphTargetInfluences?: number[] | undefined; + morphTargetDictionary?: { [key: string]: number } | undefined; + readonly isMesh: true; + type: string; + + updateMorphTargets(): void; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; +} diff --git a/backend/libs/three/objects/Mesh.js b/backend/libs/three/objects/Mesh.js new file mode 100644 index 0000000000000000000000000000000000000000..0ed8b901e6d58ff084d63fc6767f6ee9e0719886 --- /dev/null +++ b/backend/libs/three/objects/Mesh.js @@ -0,0 +1,383 @@ +import { Vector3 } from '../math/Vector3.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Sphere } from '../math/Sphere.js'; +import { Ray } from '../math/Ray.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Object3D } from '../core/Object3D.js'; +import { Triangle } from '../math/Triangle.js'; +import { DoubleSide, BackSide } from '../constants.js'; +import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; + +const _inverseMatrix = /*@__PURE__*/ new Matrix4(); +const _ray = /*@__PURE__*/ new Ray(); +const _sphere = /*@__PURE__*/ new Sphere(); + +const _vA = /*@__PURE__*/ new Vector3(); +const _vB = /*@__PURE__*/ new Vector3(); +const _vC = /*@__PURE__*/ new Vector3(); + +const _tempA = /*@__PURE__*/ new Vector3(); +const _tempB = /*@__PURE__*/ new Vector3(); +const _tempC = /*@__PURE__*/ new Vector3(); + +const _morphA = /*@__PURE__*/ new Vector3(); +const _morphB = /*@__PURE__*/ new Vector3(); +const _morphC = /*@__PURE__*/ new Vector3(); + +const _uvA = /*@__PURE__*/ new Vector2(); +const _uvB = /*@__PURE__*/ new Vector2(); +const _uvC = /*@__PURE__*/ new Vector2(); + +const _intersectionPoint = /*@__PURE__*/ new Vector3(); +const _intersectionPointWorld = /*@__PURE__*/ new Vector3(); + +class Mesh extends Object3D { + constructor(geometry = new BufferGeometry(), material = new MeshBasicMaterial()) { + super(); + + this.type = 'Mesh'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + } + + copy(source) { + super.copy(source); + + if (source.morphTargetInfluences !== undefined) { + this.morphTargetInfluences = source.morphTargetInfluences.slice(); + } + + if (source.morphTargetDictionary !== undefined) { + this.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary); + } + + this.material = source.material; + this.geometry = source.geometry; + + return this; + } + + updateMorphTargets() { + const geometry = this.geometry; + + if (geometry.isBufferGeometry) { + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys(morphAttributes); + + if (keys.length > 0) { + const morphAttribute = morphAttributes[keys[0]]; + + if (morphAttribute !== undefined) { + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for (let m = 0, ml = morphAttribute.length; m < ml; m++) { + const name = morphAttribute[m].name || String(m); + + this.morphTargetInfluences.push(0); + this.morphTargetDictionary[name] = m; + } + } + } + } else { + const morphTargets = geometry.morphTargets; + + if (morphTargets !== undefined && morphTargets.length > 0) { + console.error('THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } + } + + raycast(raycaster, intersects) { + const geometry = this.geometry; + const material = this.material; + const matrixWorld = this.matrixWorld; + + if (material === undefined) return; + + // Checking boundingSphere distance to ray + + if (geometry.boundingSphere === null) geometry.computeBoundingSphere(); + + _sphere.copy(geometry.boundingSphere); + _sphere.applyMatrix4(matrixWorld); + + if (raycaster.ray.intersectsSphere(_sphere) === false) return; + + // + + _inverseMatrix.copy(matrixWorld).invert(); + _ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix); + + // Check boundingBox before continuing + + if (geometry.boundingBox !== null) { + if (_ray.intersectsBox(geometry.boundingBox) === false) return; + } + + let intersection; + + if (geometry.isBufferGeometry) { + const index = geometry.index; + const position = geometry.attributes.position; + const morphPosition = geometry.morphAttributes.position; + const morphTargetsRelative = geometry.morphTargetsRelative; + const uv = geometry.attributes.uv; + const uv2 = geometry.attributes.uv2; + const groups = geometry.groups; + const drawRange = geometry.drawRange; + + if (index !== null) { + // indexed buffer geometry + + if (Array.isArray(material)) { + for (let i = 0, il = groups.length; i < il; i++) { + const group = groups[i]; + const groupMaterial = material[group.materialIndex]; + + const start = Math.max(group.start, drawRange.start); + const end = Math.min(index.count, Math.min(group.start + group.count, drawRange.start + drawRange.count)); + + for (let j = start, jl = end; j < jl; j += 3) { + const a = index.getX(j); + const b = index.getX(j + 1); + const c = index.getX(j + 2); + + intersection = checkBufferGeometryIntersection( + this, + groupMaterial, + raycaster, + _ray, + position, + morphPosition, + morphTargetsRelative, + uv, + uv2, + a, + b, + c + ); + + if (intersection) { + intersection.faceIndex = Math.floor(j / 3); // triangle number in indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push(intersection); + } + } + } + } else { + const start = Math.max(0, drawRange.start); + const end = Math.min(index.count, drawRange.start + drawRange.count); + + for (let i = start, il = end; i < il; i += 3) { + const a = index.getX(i); + const b = index.getX(i + 1); + const c = index.getX(i + 2); + + intersection = checkBufferGeometryIntersection( + this, + material, + raycaster, + _ray, + position, + morphPosition, + morphTargetsRelative, + uv, + uv2, + a, + b, + c + ); + + if (intersection) { + intersection.faceIndex = Math.floor(i / 3); // triangle number in indexed buffer semantics + intersects.push(intersection); + } + } + } + } else if (position !== undefined) { + // non-indexed buffer geometry + + if (Array.isArray(material)) { + for (let i = 0, il = groups.length; i < il; i++) { + const group = groups[i]; + const groupMaterial = material[group.materialIndex]; + + const start = Math.max(group.start, drawRange.start); + const end = Math.min(position.count, Math.min(group.start + group.count, drawRange.start + drawRange.count)); + + for (let j = start, jl = end; j < jl; j += 3) { + const a = j; + const b = j + 1; + const c = j + 2; + + intersection = checkBufferGeometryIntersection( + this, + groupMaterial, + raycaster, + _ray, + position, + morphPosition, + morphTargetsRelative, + uv, + uv2, + a, + b, + c + ); + + if (intersection) { + intersection.faceIndex = Math.floor(j / 3); // triangle number in non-indexed buffer semantics + intersection.face.materialIndex = group.materialIndex; + intersects.push(intersection); + } + } + } + } else { + const start = Math.max(0, drawRange.start); + const end = Math.min(position.count, drawRange.start + drawRange.count); + + for (let i = start, il = end; i < il; i += 3) { + const a = i; + const b = i + 1; + const c = i + 2; + + intersection = checkBufferGeometryIntersection( + this, + material, + raycaster, + _ray, + position, + morphPosition, + morphTargetsRelative, + uv, + uv2, + a, + b, + c + ); + + if (intersection) { + intersection.faceIndex = Math.floor(i / 3); // triangle number in non-indexed buffer semantics + intersects.push(intersection); + } + } + } + } + } else if (geometry.isGeometry) { + console.error('THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } +} + +Mesh.prototype.isMesh = true; + +function checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) { + let intersect; + + if (material.side === BackSide) { + intersect = ray.intersectTriangle(pC, pB, pA, true, point); + } else { + intersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point); + } + + if (intersect === null) return null; + + _intersectionPointWorld.copy(point); + _intersectionPointWorld.applyMatrix4(object.matrixWorld); + + const distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld); + + if (distance < raycaster.near || distance > raycaster.far) return null; + + return { + distance: distance, + point: _intersectionPointWorld.clone(), + object: object, + }; +} + +function checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) { + _vA.fromBufferAttribute(position, a); + _vB.fromBufferAttribute(position, b); + _vC.fromBufferAttribute(position, c); + + const morphInfluences = object.morphTargetInfluences; + + if (morphPosition && morphInfluences) { + _morphA.set(0, 0, 0); + _morphB.set(0, 0, 0); + _morphC.set(0, 0, 0); + + for (let i = 0, il = morphPosition.length; i < il; i++) { + const influence = morphInfluences[i]; + const morphAttribute = morphPosition[i]; + + if (influence === 0) continue; + + _tempA.fromBufferAttribute(morphAttribute, a); + _tempB.fromBufferAttribute(morphAttribute, b); + _tempC.fromBufferAttribute(morphAttribute, c); + + if (morphTargetsRelative) { + _morphA.addScaledVector(_tempA, influence); + _morphB.addScaledVector(_tempB, influence); + _morphC.addScaledVector(_tempC, influence); + } else { + _morphA.addScaledVector(_tempA.sub(_vA), influence); + _morphB.addScaledVector(_tempB.sub(_vB), influence); + _morphC.addScaledVector(_tempC.sub(_vC), influence); + } + } + + _vA.add(_morphA); + _vB.add(_morphB); + _vC.add(_morphC); + } + + if (object.isSkinnedMesh) { + object.boneTransform(a, _vA); + object.boneTransform(b, _vB); + object.boneTransform(c, _vC); + } + + const intersection = checkIntersection(object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint); + + if (intersection) { + if (uv) { + _uvA.fromBufferAttribute(uv, a); + _uvB.fromBufferAttribute(uv, b); + _uvC.fromBufferAttribute(uv, c); + + intersection.uv = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2()); + } + + if (uv2) { + _uvA.fromBufferAttribute(uv2, a); + _uvB.fromBufferAttribute(uv2, b); + _uvC.fromBufferAttribute(uv2, c); + + intersection.uv2 = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2()); + } + + const face = { + a: a, + b: b, + c: c, + normal: new Vector3(), + materialIndex: 0, + }; + + Triangle.getNormal(_vA, _vB, _vC, face.normal); + + intersection.face = face; + } + + return intersection; +} + +export { Mesh }; diff --git a/backend/libs/three/objects/Points.d.ts b/backend/libs/three/objects/Points.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8c3ac3b8dbb96531d668dd58e317a6ac8ef8b03b --- /dev/null +++ b/backend/libs/three/objects/Points.d.ts @@ -0,0 +1,34 @@ +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; + +/** + * A class for displaying points. The points are rendered by the WebGLRenderer using gl.POINTS. + */ +export class Points extends Object3D { + /** + * @param geometry An instance of BufferGeometry. + * @param material An instance of Material (optional). + */ + constructor(geometry?: TGeometry, material?: TMaterial); + + type: 'Points'; + morphTargetInfluences?: number[] | undefined; + morphTargetDictionary?: { [key: string]: number } | undefined; + readonly isPoints: true; + + /** + * An instance of BufferGeometry, where each vertex designates the position of a particle in the system. + */ + geometry: TGeometry; + + /** + * An instance of Material, defining the object's appearance. Default is a PointsMaterial with randomised colour. + */ + material: TMaterial; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + updateMorphTargets(): void; +} diff --git a/backend/libs/three/objects/Points.js b/backend/libs/three/objects/Points.js new file mode 100644 index 0000000000000000000000000000000000000000..4a9a7bd400cca6c658887a81be3a66ed53dbe4fd --- /dev/null +++ b/backend/libs/three/objects/Points.js @@ -0,0 +1,148 @@ +import { Sphere } from '../math/Sphere.js'; +import { Ray } from '../math/Ray.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Object3D } from '../core/Object3D.js'; +import { Vector3 } from '../math/Vector3.js'; +import { PointsMaterial } from '../materials/PointsMaterial.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; + +const _inverseMatrix = /*@__PURE__*/ new Matrix4(); +const _ray = /*@__PURE__*/ new Ray(); +const _sphere = /*@__PURE__*/ new Sphere(); +const _position = /*@__PURE__*/ new Vector3(); + +class Points extends Object3D { + constructor(geometry = new BufferGeometry(), material = new PointsMaterial()) { + super(); + + this.type = 'Points'; + + this.geometry = geometry; + this.material = material; + + this.updateMorphTargets(); + } + + copy(source) { + super.copy(source); + + this.material = source.material; + this.geometry = source.geometry; + + return this; + } + + raycast(raycaster, intersects) { + const geometry = this.geometry; + const matrixWorld = this.matrixWorld; + const threshold = raycaster.params.Points.threshold; + const drawRange = geometry.drawRange; + + // Checking boundingSphere distance to ray + + if (geometry.boundingSphere === null) geometry.computeBoundingSphere(); + + _sphere.copy(geometry.boundingSphere); + _sphere.applyMatrix4(matrixWorld); + _sphere.radius += threshold; + + if (raycaster.ray.intersectsSphere(_sphere) === false) return; + + // + + _inverseMatrix.copy(matrixWorld).invert(); + _ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix); + + const localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3); + const localThresholdSq = localThreshold * localThreshold; + + if (geometry.isBufferGeometry) { + const index = geometry.index; + const attributes = geometry.attributes; + const positionAttribute = attributes.position; + + if (index !== null) { + const start = Math.max(0, drawRange.start); + const end = Math.min(index.count, drawRange.start + drawRange.count); + + for (let i = start, il = end; i < il; i++) { + const a = index.getX(i); + + _position.fromBufferAttribute(positionAttribute, a); + + testPoint(_position, a, localThresholdSq, matrixWorld, raycaster, intersects, this); + } + } else { + const start = Math.max(0, drawRange.start); + const end = Math.min(positionAttribute.count, drawRange.start + drawRange.count); + + for (let i = start, l = end; i < l; i++) { + _position.fromBufferAttribute(positionAttribute, i); + + testPoint(_position, i, localThresholdSq, matrixWorld, raycaster, intersects, this); + } + } + } else { + console.error('THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } + + updateMorphTargets() { + const geometry = this.geometry; + + if (geometry.isBufferGeometry) { + const morphAttributes = geometry.morphAttributes; + const keys = Object.keys(morphAttributes); + + if (keys.length > 0) { + const morphAttribute = morphAttributes[keys[0]]; + + if (morphAttribute !== undefined) { + this.morphTargetInfluences = []; + this.morphTargetDictionary = {}; + + for (let m = 0, ml = morphAttribute.length; m < ml; m++) { + const name = morphAttribute[m].name || String(m); + + this.morphTargetInfluences.push(0); + this.morphTargetDictionary[name] = m; + } + } + } + } else { + const morphTargets = geometry.morphTargets; + + if (morphTargets !== undefined && morphTargets.length > 0) { + console.error('THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.'); + } + } + } +} + +Points.prototype.isPoints = true; + +function testPoint(point, index, localThresholdSq, matrixWorld, raycaster, intersects, object) { + const rayPointDistanceSq = _ray.distanceSqToPoint(point); + + if (rayPointDistanceSq < localThresholdSq) { + const intersectPoint = new Vector3(); + + _ray.closestPointToPoint(point, intersectPoint); + intersectPoint.applyMatrix4(matrixWorld); + + const distance = raycaster.ray.origin.distanceTo(intersectPoint); + + if (distance < raycaster.near || distance > raycaster.far) return; + + intersects.push({ + distance: distance, + distanceToRay: Math.sqrt(rayPointDistanceSq), + point: intersectPoint, + index: index, + face: null, + object: object, + }); + } +} + +export { Points }; diff --git a/backend/libs/three/objects/Skeleton.d.ts b/backend/libs/three/objects/Skeleton.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f1904f5a42399d4901fec2767167c63339f65716 --- /dev/null +++ b/backend/libs/three/objects/Skeleton.d.ts @@ -0,0 +1,29 @@ +import { Bone } from './Bone'; +import { Matrix4 } from './../math/Matrix4'; +import { DataTexture } from './../textures/DataTexture'; + +export class Skeleton { + constructor(bones: Bone[], boneInverses?: Matrix4[]); + + uuid: string; + bones: Bone[]; + boneInverses: Matrix4[]; + boneMatrices: Float32Array; + boneTexture: null | DataTexture; + boneTextureSize: number; + frame: number; + + init(): void; + calculateInverses(): void; + computeBoneTexture(): this; + pose(): void; + update(): void; + clone(): Skeleton; + getBoneByName(name: string): undefined | Bone; + dispose(): void; + + /** + * @deprecated This property has been removed completely. + */ + useVertexTexture: boolean; +} diff --git a/backend/libs/three/objects/Skeleton.js b/backend/libs/three/objects/Skeleton.js new file mode 100644 index 0000000000000000000000000000000000000000..316df479f5d2434b8d4706d4045114cfa5c455ab --- /dev/null +++ b/backend/libs/three/objects/Skeleton.js @@ -0,0 +1,214 @@ +import { RGBAFormat, FloatType } from '../constants.js'; +import { Bone } from './Bone.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { DataTexture } from '../textures/DataTexture.js'; +import * as MathUtils from '../math/MathUtils.js'; + +const _offsetMatrix = /*@__PURE__*/ new Matrix4(); +const _identityMatrix = /*@__PURE__*/ new Matrix4(); + +class Skeleton { + constructor(bones = [], boneInverses = []) { + this.uuid = MathUtils.generateUUID(); + + this.bones = bones.slice(0); + this.boneInverses = boneInverses; + this.boneMatrices = null; + + this.boneTexture = null; + this.boneTextureSize = 0; + + this.frame = -1; + + this.init(); + } + + init() { + const bones = this.bones; + const boneInverses = this.boneInverses; + + this.boneMatrices = new Float32Array(bones.length * 16); + + // calculate inverse bone matrices if necessary + + if (boneInverses.length === 0) { + this.calculateInverses(); + } else { + // handle special case + + if (bones.length !== boneInverses.length) { + console.warn('THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.'); + + this.boneInverses = []; + + for (let i = 0, il = this.bones.length; i < il; i++) { + this.boneInverses.push(new Matrix4()); + } + } + } + } + + calculateInverses() { + this.boneInverses.length = 0; + + for (let i = 0, il = this.bones.length; i < il; i++) { + const inverse = new Matrix4(); + + if (this.bones[i]) { + inverse.copy(this.bones[i].matrixWorld).invert(); + } + + this.boneInverses.push(inverse); + } + } + + pose() { + // recover the bind-time world matrices + + for (let i = 0, il = this.bones.length; i < il; i++) { + const bone = this.bones[i]; + + if (bone) { + bone.matrixWorld.copy(this.boneInverses[i]).invert(); + } + } + + // compute the local matrices, positions, rotations and scales + + for (let i = 0, il = this.bones.length; i < il; i++) { + const bone = this.bones[i]; + + if (bone) { + if (bone.parent && bone.parent.isBone) { + bone.matrix.copy(bone.parent.matrixWorld).invert(); + bone.matrix.multiply(bone.matrixWorld); + } else { + bone.matrix.copy(bone.matrixWorld); + } + + bone.matrix.decompose(bone.position, bone.quaternion, bone.scale); + } + } + } + + update() { + const bones = this.bones; + const boneInverses = this.boneInverses; + const boneMatrices = this.boneMatrices; + const boneTexture = this.boneTexture; + + // flatten bone matrices to array + + for (let i = 0, il = bones.length; i < il; i++) { + // compute the offset between the current and the original transform + + const matrix = bones[i] ? bones[i].matrixWorld : _identityMatrix; + + _offsetMatrix.multiplyMatrices(matrix, boneInverses[i]); + _offsetMatrix.toArray(boneMatrices, i * 16); + } + + if (boneTexture !== null) { + boneTexture.needsUpdate = true; + } + } + + clone() { + return new Skeleton(this.bones, this.boneInverses); + } + + computeBoneTexture() { + // layout (1 matrix = 4 pixels) + // RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4) + // with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8) + // 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16) + // 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32) + // 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64) + + let size = Math.sqrt(this.bones.length * 4); // 4 pixels needed for 1 matrix + size = MathUtils.ceilPowerOfTwo(size); + size = Math.max(size, 4); + + const boneMatrices = new Float32Array(size * size * 4); // 4 floats per RGBA pixel + boneMatrices.set(this.boneMatrices); // copy current values + + const boneTexture = new DataTexture(boneMatrices, size, size, RGBAFormat, FloatType); + boneTexture.needsUpdate = true; + + this.boneMatrices = boneMatrices; + this.boneTexture = boneTexture; + this.boneTextureSize = size; + + return this; + } + + getBoneByName(name) { + for (let i = 0, il = this.bones.length; i < il; i++) { + const bone = this.bones[i]; + + if (bone.name === name) { + return bone; + } + } + + return undefined; + } + + dispose() { + if (this.boneTexture !== null) { + this.boneTexture.dispose(); + + this.boneTexture = null; + } + } + + fromJSON(json, bones) { + this.uuid = json.uuid; + + for (let i = 0, l = json.bones.length; i < l; i++) { + const uuid = json.bones[i]; + let bone = bones[uuid]; + + if (bone === undefined) { + console.warn('THREE.Skeleton: No bone found with UUID:', uuid); + bone = new Bone(); + } + + this.bones.push(bone); + this.boneInverses.push(new Matrix4().fromArray(json.boneInverses[i])); + } + + this.init(); + + return this; + } + + toJSON() { + const data = { + metadata: { + version: 4.5, + type: 'Skeleton', + generator: 'Skeleton.toJSON', + }, + bones: [], + boneInverses: [], + }; + + data.uuid = this.uuid; + + const bones = this.bones; + const boneInverses = this.boneInverses; + + for (let i = 0, l = bones.length; i < l; i++) { + const bone = bones[i]; + data.bones.push(bone.uuid); + + const boneInverse = boneInverses[i]; + data.boneInverses.push(boneInverse.toArray()); + } + + return data; + } +} + +export { Skeleton }; diff --git a/backend/libs/three/objects/SkinnedMesh.d.ts b/backend/libs/three/objects/SkinnedMesh.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..21161887adb8e1f512e9c1e38633070c5b0ed0e0 --- /dev/null +++ b/backend/libs/three/objects/SkinnedMesh.d.ts @@ -0,0 +1,25 @@ +import { Material } from './../materials/Material'; +import { Matrix4 } from './../math/Matrix4'; +import { Vector3 } from './../math/Vector3'; +import { Skeleton } from './Skeleton'; +import { Mesh } from './Mesh'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class SkinnedMesh extends Mesh< + TGeometry, + TMaterial +> { + constructor(geometry?: TGeometry, material?: TMaterial, useVertexTexture?: boolean); + + bindMode: string; + bindMatrix: Matrix4; + bindMatrixInverse: Matrix4; + skeleton: Skeleton; + readonly isSkinnedMesh: true; + + bind(skeleton: Skeleton, bindMatrix?: Matrix4): void; + pose(): void; + normalizeSkinWeights(): void; + updateMatrixWorld(force?: boolean): void; + boneTransform(index: number, target: Vector3): Vector3; +} diff --git a/backend/libs/three/objects/SkinnedMesh.js b/backend/libs/three/objects/SkinnedMesh.js new file mode 100644 index 0000000000000000000000000000000000000000..79c5957d93a2f30d5a9969fc38439e0c02596c52 --- /dev/null +++ b/backend/libs/three/objects/SkinnedMesh.js @@ -0,0 +1,120 @@ +import { Mesh } from './Mesh.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector4 } from '../math/Vector4.js'; + +const _basePosition = /*@__PURE__*/ new Vector3(); + +const _skinIndex = /*@__PURE__*/ new Vector4(); +const _skinWeight = /*@__PURE__*/ new Vector4(); + +const _vector = /*@__PURE__*/ new Vector3(); +const _matrix = /*@__PURE__*/ new Matrix4(); + +class SkinnedMesh extends Mesh { + constructor(geometry, material) { + super(geometry, material); + + this.type = 'SkinnedMesh'; + + this.bindMode = 'attached'; + this.bindMatrix = new Matrix4(); + this.bindMatrixInverse = new Matrix4(); + } + + copy(source) { + super.copy(source); + + this.bindMode = source.bindMode; + this.bindMatrix.copy(source.bindMatrix); + this.bindMatrixInverse.copy(source.bindMatrixInverse); + + this.skeleton = source.skeleton; + + return this; + } + + bind(skeleton, bindMatrix) { + this.skeleton = skeleton; + + if (bindMatrix === undefined) { + this.updateMatrixWorld(true); + + this.skeleton.calculateInverses(); + + bindMatrix = this.matrixWorld; + } + + this.bindMatrix.copy(bindMatrix); + this.bindMatrixInverse.copy(bindMatrix).invert(); + } + + pose() { + this.skeleton.pose(); + } + + normalizeSkinWeights() { + const vector = new Vector4(); + + const skinWeight = this.geometry.attributes.skinWeight; + + for (let i = 0, l = skinWeight.count; i < l; i++) { + vector.x = skinWeight.getX(i); + vector.y = skinWeight.getY(i); + vector.z = skinWeight.getZ(i); + vector.w = skinWeight.getW(i); + + const scale = 1.0 / vector.manhattanLength(); + + if (scale !== Infinity) { + vector.multiplyScalar(scale); + } else { + vector.set(1, 0, 0, 0); // do something reasonable + } + + skinWeight.setXYZW(i, vector.x, vector.y, vector.z, vector.w); + } + } + + updateMatrixWorld(force) { + super.updateMatrixWorld(force); + + if (this.bindMode === 'attached') { + this.bindMatrixInverse.copy(this.matrixWorld).invert(); + } else if (this.bindMode === 'detached') { + this.bindMatrixInverse.copy(this.bindMatrix).invert(); + } else { + console.warn('THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode); + } + } + + boneTransform(index, target) { + const skeleton = this.skeleton; + const geometry = this.geometry; + + _skinIndex.fromBufferAttribute(geometry.attributes.skinIndex, index); + _skinWeight.fromBufferAttribute(geometry.attributes.skinWeight, index); + + _basePosition.copy(target).applyMatrix4(this.bindMatrix); + + target.set(0, 0, 0); + + for (let i = 0; i < 4; i++) { + const weight = _skinWeight.getComponent(i); + + if (weight !== 0) { + const boneIndex = _skinIndex.getComponent(i); + + _matrix.multiplyMatrices(skeleton.bones[boneIndex].matrixWorld, skeleton.boneInverses[boneIndex]); + + target.addScaledVector(_vector.copy(_basePosition).applyMatrix4(_matrix), weight); + } + } + + return target.applyMatrix4(this.bindMatrixInverse); + } +} + +SkinnedMesh.prototype.isSkinnedMesh = true; + +export { SkinnedMesh }; diff --git a/backend/libs/three/objects/Sprite.d.ts b/backend/libs/three/objects/Sprite.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e3e7c327132ef65efbfd715fd27b477ef5a7acb6 --- /dev/null +++ b/backend/libs/three/objects/Sprite.d.ts @@ -0,0 +1,20 @@ +import { Vector2 } from './../math/Vector2'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { Intersection } from '../core/Raycaster'; +import { SpriteMaterial } from '../materials/Materials'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class Sprite extends Object3D { + constructor(material?: SpriteMaterial); + + type: 'Sprite'; + readonly isSprite: true; + + geometry: BufferGeometry; + material: SpriteMaterial; + center: Vector2; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + copy(source: this): this; +} diff --git a/backend/libs/three/objects/Sprite.js b/backend/libs/three/objects/Sprite.js new file mode 100644 index 0000000000000000000000000000000000000000..241a49696fc5016ee4379685e1f887f6516d9435 --- /dev/null +++ b/backend/libs/three/objects/Sprite.js @@ -0,0 +1,147 @@ +import { Vector2 } from '../math/Vector2.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Triangle } from '../math/Triangle.js'; +import { Object3D } from '../core/Object3D.js'; +import { BufferGeometry } from '../core/BufferGeometry.js'; +import { InterleavedBuffer } from '../core/InterleavedBuffer.js'; +import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js'; +import { SpriteMaterial } from '../materials/SpriteMaterial.js'; + +let _geometry; + +const _intersectPoint = /*@__PURE__*/ new Vector3(); +const _worldScale = /*@__PURE__*/ new Vector3(); +const _mvPosition = /*@__PURE__*/ new Vector3(); + +const _alignedPosition = /*@__PURE__*/ new Vector2(); +const _rotatedPosition = /*@__PURE__*/ new Vector2(); +const _viewWorldMatrix = /*@__PURE__*/ new Matrix4(); + +const _vA = /*@__PURE__*/ new Vector3(); +const _vB = /*@__PURE__*/ new Vector3(); +const _vC = /*@__PURE__*/ new Vector3(); + +const _uvA = /*@__PURE__*/ new Vector2(); +const _uvB = /*@__PURE__*/ new Vector2(); +const _uvC = /*@__PURE__*/ new Vector2(); + +class Sprite extends Object3D { + constructor(material) { + super(); + + this.type = 'Sprite'; + + if (_geometry === undefined) { + _geometry = new BufferGeometry(); + + const float32Array = new Float32Array([-0.5, -0.5, 0, 0, 0, 0.5, -0.5, 0, 1, 0, 0.5, 0.5, 0, 1, 1, -0.5, 0.5, 0, 0, 1]); + + const interleavedBuffer = new InterleavedBuffer(float32Array, 5); + + _geometry.setIndex([0, 1, 2, 0, 2, 3]); + _geometry.setAttribute('position', new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false)); + _geometry.setAttribute('uv', new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false)); + } + + this.geometry = _geometry; + this.material = material !== undefined ? material : new SpriteMaterial(); + + this.center = new Vector2(0.5, 0.5); + } + + raycast(raycaster, intersects) { + if (raycaster.camera === null) { + console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'); + } + + _worldScale.setFromMatrixScale(this.matrixWorld); + + _viewWorldMatrix.copy(raycaster.camera.matrixWorld); + this.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld); + + _mvPosition.setFromMatrixPosition(this.modelViewMatrix); + + if (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) { + _worldScale.multiplyScalar(-_mvPosition.z); + } + + const rotation = this.material.rotation; + let sin, cos; + + if (rotation !== 0) { + cos = Math.cos(rotation); + sin = Math.sin(rotation); + } + + const center = this.center; + + transformVertex(_vA.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos); + transformVertex(_vB.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos); + transformVertex(_vC.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos); + + _uvA.set(0, 0); + _uvB.set(1, 0); + _uvC.set(1, 1); + + // check first triangle + let intersect = raycaster.ray.intersectTriangle(_vA, _vB, _vC, false, _intersectPoint); + + if (intersect === null) { + // check second triangle + transformVertex(_vB.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos); + _uvB.set(0, 1); + + intersect = raycaster.ray.intersectTriangle(_vA, _vC, _vB, false, _intersectPoint); + if (intersect === null) { + return; + } + } + + const distance = raycaster.ray.origin.distanceTo(_intersectPoint); + + if (distance < raycaster.near || distance > raycaster.far) return; + + intersects.push({ + distance: distance, + point: _intersectPoint.clone(), + uv: Triangle.getUV(_intersectPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2()), + face: null, + object: this, + }); + } + + copy(source) { + super.copy(source); + + if (source.center !== undefined) this.center.copy(source.center); + + this.material = source.material; + + return this; + } +} + +Sprite.prototype.isSprite = true; + +function transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) { + // compute position in camera space + _alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale); + + // to check if rotation is not zero + if (sin !== undefined) { + _rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y; + _rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y; + } else { + _rotatedPosition.copy(_alignedPosition); + } + + vertexPosition.copy(mvPosition); + vertexPosition.x += _rotatedPosition.x; + vertexPosition.y += _rotatedPosition.y; + + // transform to world space + vertexPosition.applyMatrix4(_viewWorldMatrix); +} + +export { Sprite }; diff --git a/backend/libs/three/renderers/WebGL1Renderer.d.ts b/backend/libs/three/renderers/WebGL1Renderer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..25d6cb6757bd0cc929192698a7bd7eb2c3c68acc --- /dev/null +++ b/backend/libs/three/renderers/WebGL1Renderer.d.ts @@ -0,0 +1,6 @@ +import { WebGLRenderer, WebGLRendererParameters } from './WebGLRenderer'; + +export class WebGL1Renderer extends WebGLRenderer { + constructor(parameters?: WebGLRendererParameters); + readonly isWebGL1Renderer: true; +} diff --git a/backend/libs/three/renderers/WebGL1Renderer.js b/backend/libs/three/renderers/WebGL1Renderer.js new file mode 100644 index 0000000000000000000000000000000000000000..e6cc82999521ffeeec3097afed74f5cc5e47e657 --- /dev/null +++ b/backend/libs/three/renderers/WebGL1Renderer.js @@ -0,0 +1,7 @@ +import { WebGLRenderer } from './WebGLRenderer.js'; + +class WebGL1Renderer extends WebGLRenderer {} + +WebGL1Renderer.prototype.isWebGL1Renderer = true; + +export { WebGL1Renderer }; diff --git a/backend/libs/three/renderers/WebGL3DRenderTarget.d.ts b/backend/libs/three/renderers/WebGL3DRenderTarget.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..32bf6c0a6d78bd87caa0e861ad559ec9be11bb25 --- /dev/null +++ b/backend/libs/three/renderers/WebGL3DRenderTarget.d.ts @@ -0,0 +1,28 @@ +import { Data3DTexture } from '../textures/Data3DTexture'; +import { WebGLRenderTarget } from './WebGLRenderTarget'; + +/** + * Represents a three-dimensional render target. + */ +export class WebGL3DRenderTarget extends WebGLRenderTarget { + /** + * Creates a new WebGL3DRenderTarget. + * + * @param width the width of the render target, in pixels. + * @param height the height of the render target, in pixels. + * @param depth the depth of the render target. + */ + constructor(width: number, height: number, depth: number); + + /** + * The depth of the render target. + */ + depth: number; + + /** + * The texture property is overwritten with an instance of {@link Data3DTexture}. + */ + texture: Data3DTexture; + + readonly isWebGL3DRenderTarget: true; +} diff --git a/backend/libs/three/renderers/WebGLArrayRenderTarget.d.ts b/backend/libs/three/renderers/WebGLArrayRenderTarget.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..62152c60bd6c39e904e52d94db57b9bdd63b1b7f --- /dev/null +++ b/backend/libs/three/renderers/WebGLArrayRenderTarget.d.ts @@ -0,0 +1,28 @@ +import { DataArrayTexture } from '../textures/DataArrayTexture'; +import { WebGLRenderTarget } from './WebGLRenderTarget'; + +/** + * This type of render target represents an array of textures. + */ +export class WebGLArrayRenderTarget extends WebGLRenderTarget { + /** + * Creates a new WebGLArrayRenderTarget. + * + * @param width the width of the render target, in pixels. + * @param height the height of the render target, in pixels. + * @param depth the depth/layer count of the render target. + */ + constructor(width: number, height: number, depth: number); + + /** + * The depth of the render target. + */ + depth: number; + + /** + * The texture property is overwritten with an instance of {@link DataArrayTexture}. + */ + texture: DataArrayTexture; + + readonly isWebGLArrayRenderTarget: true; +} diff --git a/backend/libs/three/renderers/WebGLCubeRenderTarget.d.ts b/backend/libs/three/renderers/WebGLCubeRenderTarget.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fabe43d4d9216088b544692b8b338fa43c522c51 --- /dev/null +++ b/backend/libs/three/renderers/WebGLCubeRenderTarget.d.ts @@ -0,0 +1,14 @@ +import { WebGLRenderTargetOptions, WebGLRenderTarget } from './WebGLRenderTarget'; +import { WebGLRenderer } from './WebGLRenderer'; +import { Texture } from './../textures/Texture'; +import { CubeTexture } from './../textures/CubeTexture'; + +export class WebGLCubeRenderTarget extends WebGLRenderTarget { + constructor(size: number, options?: WebGLRenderTargetOptions); + + texture: CubeTexture; + + fromEquirectangularTexture(renderer: WebGLRenderer, texture: Texture): this; + + clear(renderer: WebGLRenderer, color: boolean, depth: boolean, stencil: boolean): void; +} diff --git a/backend/libs/three/renderers/WebGLCubeRenderTarget.js b/backend/libs/three/renderers/WebGLCubeRenderTarget.js new file mode 100644 index 0000000000000000000000000000000000000000..398a879ba006e1cef2a4c66af7cf4118cacc0372 --- /dev/null +++ b/backend/libs/three/renderers/WebGLCubeRenderTarget.js @@ -0,0 +1,149 @@ +import { BackSide, LinearFilter, LinearMipmapLinearFilter, NoBlending, RGBAFormat } from '../constants.js'; +import { Mesh } from '../objects/Mesh.js'; +import { BoxGeometry } from '../geometries/BoxGeometry.js'; +import { ShaderMaterial } from '../materials/ShaderMaterial.js'; +import { cloneUniforms } from './shaders/UniformsUtils.js'; +import { WebGLRenderTarget } from './WebGLRenderTarget.js'; +import { CubeCamera } from '../cameras/CubeCamera.js'; +import { CubeTexture } from '../textures/CubeTexture.js'; + +class WebGLCubeRenderTarget extends WebGLRenderTarget { + constructor(size, options, dummy) { + if (Number.isInteger(options)) { + console.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )'); + + options = dummy; + } + + super(size, size, options); + + options = options || {}; + + // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) + // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words, + // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly. + + // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped + // and the flag isRenderTargetTexture controls this conversion. The flip is not required when using WebGLCubeRenderTarget.texture + // as a cube texture (this is detected when isRenderTargetTexture is set to true for cube textures). + + this.texture = new CubeTexture( + undefined, + options.mapping, + options.wrapS, + options.wrapT, + options.magFilter, + options.minFilter, + options.format, + options.type, + options.anisotropy, + options.encoding + ); + this.texture.isRenderTargetTexture = true; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + } + + fromEquirectangularTexture(renderer, texture) { + this.texture.type = texture.type; + this.texture.format = RGBAFormat; // see #18859 + this.texture.encoding = texture.encoding; + + this.texture.generateMipmaps = texture.generateMipmaps; + this.texture.minFilter = texture.minFilter; + this.texture.magFilter = texture.magFilter; + + const shader = { + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: /* glsl */ ` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `, + + fragmentShader: /* glsl */ ` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `, + }; + + const geometry = new BoxGeometry(5, 5, 5); + + const material = new ShaderMaterial({ + name: 'CubemapFromEquirect', + + uniforms: cloneUniforms(shader.uniforms), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader, + side: BackSide, + blending: NoBlending, + }); + + material.uniforms.tEquirect.value = texture; + + const mesh = new Mesh(geometry, material); + + const currentMinFilter = texture.minFilter; + + // Avoid blurred poles + if (texture.minFilter === LinearMipmapLinearFilter) texture.minFilter = LinearFilter; + + const camera = new CubeCamera(1, 10, this); + camera.update(renderer, mesh); + + texture.minFilter = currentMinFilter; + + mesh.geometry.dispose(); + mesh.material.dispose(); + + return this; + } + + clear(renderer, color, depth, stencil) { + const currentRenderTarget = renderer.getRenderTarget(); + + for (let i = 0; i < 6; i++) { + renderer.setRenderTarget(this, i); + + renderer.clear(color, depth, stencil); + } + + renderer.setRenderTarget(currentRenderTarget); + } +} + +WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true; + +export { WebGLCubeRenderTarget }; diff --git a/backend/libs/three/renderers/WebGLMultipleRenderTargets.d.ts b/backend/libs/three/renderers/WebGLMultipleRenderTargets.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f8876feca60830fd57de125329c47e73784b0c73 --- /dev/null +++ b/backend/libs/three/renderers/WebGLMultipleRenderTargets.d.ts @@ -0,0 +1,29 @@ +import { EventDispatcher } from '../core/EventDispatcher'; +import { Texture } from '../textures/Texture'; +import { WebGLRenderTargetOptions } from './WebGLRenderTarget'; + +/** + * This class originall extended WebGLMultipleRenderTarget + * However, there are some issues with this method as documented below + */ +export class WebGLMultipleRenderTargets extends EventDispatcher { + texture: Texture[]; + + readonly isWebGLMultipleRenderTargets = true; + + /** + * @param width The width of the render target. + * @param height The height of the render target. + * @param count The number of render targets. + * @param options object that holds texture parameters for an auto-generated target texture and depthBuffer/stencilBuffer booleans. + * For an explanation of the texture parameters see {@link Texture}. + */ + constructor(width: number, height: number, count: number, options?: WebGLRenderTargetOptions); + + setSize(width: number, height: number, depth?: number): this; + copy(source: WebGLMultipleRenderTargets): this; + clone(): this; + dispose(): void; + // This is an available method, however it will break the code see https://github.com/mrdoob/three.js/issues/21930 + setTexture(texture: Texture): void; +} diff --git a/backend/libs/three/renderers/WebGLMultipleRenderTargets.js b/backend/libs/three/renderers/WebGLMultipleRenderTargets.js new file mode 100644 index 0000000000000000000000000000000000000000..894f6b4fd629b25cc4785bf79056f7fb2e0a9c15 --- /dev/null +++ b/backend/libs/three/renderers/WebGLMultipleRenderTargets.js @@ -0,0 +1,63 @@ +import { WebGLRenderTarget } from './WebGLRenderTarget.js'; + +class WebGLMultipleRenderTargets extends WebGLRenderTarget { + constructor(width, height, count) { + super(width, height); + + const texture = this.texture; + + this.texture = []; + + for (let i = 0; i < count; i++) { + this.texture[i] = texture.clone(); + } + } + + setSize(width, height, depth = 1) { + if (this.width !== width || this.height !== height || this.depth !== depth) { + this.width = width; + this.height = height; + this.depth = depth; + + for (let i = 0, il = this.texture.length; i < il; i++) { + this.texture[i].image.width = width; + this.texture[i].image.height = height; + this.texture[i].image.depth = depth; + } + + this.dispose(); + } + + this.viewport.set(0, 0, width, height); + this.scissor.set(0, 0, width, height); + + return this; + } + + copy(source) { + this.dispose(); + + this.width = source.width; + this.height = source.height; + this.depth = source.depth; + + this.viewport.set(0, 0, this.width, this.height); + this.scissor.set(0, 0, this.width, this.height); + + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; + + this.texture.length = 0; + + for (let i = 0, il = source.texture.length; i < il; i++) { + this.texture[i] = source.texture[i].clone(); + } + + return this; + } +} + +WebGLMultipleRenderTargets.prototype.isWebGLMultipleRenderTargets = true; + +export { WebGLMultipleRenderTargets }; diff --git a/backend/libs/three/renderers/WebGLMultisampleRenderTarget.d.ts b/backend/libs/three/renderers/WebGLMultisampleRenderTarget.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..9e1d18815262e26fce27374c294e3ef8112d71c0 --- /dev/null +++ b/backend/libs/three/renderers/WebGLMultisampleRenderTarget.d.ts @@ -0,0 +1,6 @@ +import { WebGLRenderTarget } from './WebGLRenderTarget'; + +/** + * @deprecated THREE.WebGLMultisampleRenderTarget has been removed. Use a normal {@link WebGLRenderTarget render target} and set the "samples" property to greater 0 to enable multisampling. + */ +export class WebGLMultisampleRenderTarget extends WebGLRenderTarget {} diff --git a/backend/libs/three/renderers/WebGLMultisampleRenderTarget.js b/backend/libs/three/renderers/WebGLMultisampleRenderTarget.js new file mode 100644 index 0000000000000000000000000000000000000000..62d86d9836be1f06e110f13952117fac10743d68 --- /dev/null +++ b/backend/libs/three/renderers/WebGLMultisampleRenderTarget.js @@ -0,0 +1,27 @@ +import { WebGLRenderTarget } from './WebGLRenderTarget.js'; + +class WebGLMultisampleRenderTarget extends WebGLRenderTarget { + constructor(width, height, options = {}) { + super(width, height, options); + + this.samples = 4; + + this.ignoreDepthForMultisampleCopy = options.ignoreDepth !== undefined ? options.ignoreDepth : true; + this.useRenderToTexture = options.useRenderToTexture !== undefined ? options.useRenderToTexture : false; + this.useRenderbuffer = this.useRenderToTexture === false; + } + + copy(source) { + super.copy.call(this, source); + + this.samples = source.samples; + this.useRenderToTexture = source.useRenderToTexture; + this.useRenderbuffer = source.useRenderbuffer; + + return this; + } +} + +WebGLMultisampleRenderTarget.prototype.isWebGLMultisampleRenderTarget = true; + +export { WebGLMultisampleRenderTarget }; diff --git a/backend/libs/three/renderers/WebGLRenderTarget.d.ts b/backend/libs/three/renderers/WebGLRenderTarget.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fd2811d95e80f9a91ccde9e0a4184346980cf1be --- /dev/null +++ b/backend/libs/three/renderers/WebGLRenderTarget.d.ts @@ -0,0 +1,105 @@ +import { Vector4 } from './../math/Vector4'; +import { Texture } from './../textures/Texture'; +import { DepthTexture } from './../textures/DepthTexture'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { Wrapping, TextureFilter, TextureDataType, TextureEncoding } from '../constants'; + +export interface WebGLRenderTargetOptions { + wrapS?: Wrapping | undefined; + wrapT?: Wrapping | undefined; + magFilter?: TextureFilter | undefined; + minFilter?: TextureFilter | undefined; + format?: number | undefined; // RGBAFormat; + type?: TextureDataType | undefined; // UnsignedByteType; + anisotropy?: number | undefined; // 1; + depthBuffer?: boolean | undefined; // true; + stencilBuffer?: boolean | undefined; // false; + generateMipmaps?: boolean | undefined; // true; + depthTexture?: DepthTexture | undefined; + encoding?: TextureEncoding | undefined; +} + +export class WebGLRenderTarget extends EventDispatcher { + constructor(width: number, height: number, options?: WebGLRenderTargetOptions); + + width: number; + height: number; + depth: number; + + scissor: Vector4; + /** + * @default false + */ + scissorTest: boolean; + viewport: Vector4; + texture: Texture; + + /** + * @default true + */ + depthBuffer: boolean; + + /** + * @default true + */ + stencilBuffer: boolean; + + /** + * @default null + */ + depthTexture: DepthTexture; + + /** + * Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**. + * @default 0 + */ + samples: number; + + readonly isWebGLRenderTarget: true; + + /** + * @deprecated Use {@link Texture#wrapS texture.wrapS} instead. + */ + wrapS: any; + /** + * @deprecated Use {@link Texture#wrapT texture.wrapT} instead. + */ + wrapT: any; + /** + * @deprecated Use {@link Texture#magFilter texture.magFilter} instead. + */ + magFilter: any; + /** + * @deprecated Use {@link Texture#minFilter texture.minFilter} instead. + */ + minFilter: any; + /** + * @deprecated Use {@link Texture#anisotropy texture.anisotropy} instead. + */ + anisotropy: any; + /** + * @deprecated Use {@link Texture#offset texture.offset} instead. + */ + offset: any; + /** + * @deprecated Use {@link Texture#repeat texture.repeat} instead. + */ + repeat: any; + /** + * @deprecated Use {@link Texture#format texture.format} instead. + */ + format: any; + /** + * @deprecated Use {@link Texture#type texture.type} instead. + */ + type: any; + /** + * @deprecated Use {@link Texture#generateMipmaps texture.generateMipmaps} instead. + */ + generateMipmaps: any; + + setSize(width: number, height: number, depth?: number): void; + clone(): this; + copy(source: WebGLRenderTarget): this; + dispose(): void; +} diff --git a/backend/libs/three/renderers/WebGLRenderTarget.js b/backend/libs/three/renderers/WebGLRenderTarget.js new file mode 100644 index 0000000000000000000000000000000000000000..71be58e5ef17f4a1c8944c9a46a0145108ca2273 --- /dev/null +++ b/backend/libs/three/renderers/WebGLRenderTarget.js @@ -0,0 +1,107 @@ +import { EventDispatcher } from '../core/EventDispatcher.js'; +import { Texture } from '../textures/Texture.js'; +import { LinearFilter } from '../constants.js'; +import { Vector4 } from '../math/Vector4.js'; + +/* + In options, we can specify: + * Texture parameters for an auto-generated target texture + * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers +*/ +class WebGLRenderTarget extends EventDispatcher { + constructor(width, height, options = {}) { + super(); + + this.width = width; + this.height = height; + this.depth = 1; + + this.scissor = new Vector4(0, 0, width, height); + this.scissorTest = false; + + this.viewport = new Vector4(0, 0, width, height); + + this.texture = new Texture( + undefined, + options.mapping, + options.wrapS, + options.wrapT, + options.magFilter, + options.minFilter, + options.format, + options.type, + options.anisotropy, + options.encoding + ); + this.texture.isRenderTargetTexture = true; + + this.texture.image = { width: width, height: height, depth: 1 }; + + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + + this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; + this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false; + this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + } + + setTexture(texture) { + texture.image = { + width: this.width, + height: this.height, + depth: this.depth, + }; + + this.texture = texture; + } + + setSize(width, height, depth = 1) { + if (this.width !== width || this.height !== height || this.depth !== depth) { + this.width = width; + this.height = height; + this.depth = depth; + + this.texture.image.width = width; + this.texture.image.height = height; + this.texture.image.depth = depth; + + this.dispose(); + } + + this.viewport.set(0, 0, width, height); + this.scissor.set(0, 0, width, height); + } + + clone() { + return new this.constructor().copy(this); + } + + copy(source) { + this.width = source.width; + this.height = source.height; + this.depth = source.depth; + + this.viewport.copy(source.viewport); + + this.texture = source.texture.clone(); + + // ensure image object is not shared, see #20328 + + this.texture.image = Object.assign({}, source.texture.image); + + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; + + return this; + } + + dispose() { + this.dispatchEvent({ type: 'dispose' }); + } +} + +WebGLRenderTarget.prototype.isWebGLRenderTarget = true; + +export { WebGLRenderTarget }; diff --git a/backend/libs/three/renderers/WebGLRenderer.d.ts b/backend/libs/three/renderers/WebGLRenderer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8b6ff998ad48fd13c42eef0b10bf14f5041369d0 --- /dev/null +++ b/backend/libs/three/renderers/WebGLRenderer.d.ts @@ -0,0 +1,502 @@ +import { Scene } from './../scenes/Scene'; +import { Camera } from './../cameras/Camera'; +import { WebGLExtensions } from './webgl/WebGLExtensions'; +import { WebGLInfo } from './webgl/WebGLInfo'; +import { WebGLShadowMap } from './webgl/WebGLShadowMap'; +import { WebGLCapabilities } from './webgl/WebGLCapabilities'; +import { WebGLProperties } from './webgl/WebGLProperties'; +import { WebGLRenderLists } from './webgl/WebGLRenderLists'; +import { WebGLState } from './webgl/WebGLState'; +import { Vector2 } from './../math/Vector2'; +import { Vector4 } from './../math/Vector4'; +import { Color } from './../math/Color'; +import { WebGLRenderTarget } from './WebGLRenderTarget'; +import { WebGLMultipleRenderTargets } from './WebGLMultipleRenderTargets'; +import { Object3D } from './../core/Object3D'; +import { Material } from './../materials/Material'; +import { ToneMapping, ShadowMapType, CullFace, TextureEncoding } from '../constants'; +import { WebXRManager } from '../renderers/webxr/WebXRManager'; +import { BufferGeometry } from './../core/BufferGeometry'; +import { Texture } from '../textures/Texture'; +import { Data3DTexture } from '../textures/Data3DTexture'; +import { XRAnimationLoopCallback } from './webxr/WebXR'; +import { Vector3 } from '../math/Vector3'; +import { Box3 } from '../math/Box3'; +import { DataArrayTexture } from '../textures/DataArrayTexture'; +import { ColorRepresentation } from '../utils'; + +export interface Renderer { + domElement: HTMLCanvasElement; + + render(scene: Object3D, camera: Camera): void; + setSize(width: number, height: number, updateStyle?: boolean): void; +} + +/** This is only available in worker JS contexts, not the DOM. */ +// tslint:disable-next-line:no-empty-interface +export interface OffscreenCanvas extends EventTarget {} + +export interface WebGLRendererParameters { + /** + * A Canvas where the renderer draws its output. + */ + canvas?: HTMLCanvasElement | OffscreenCanvas | undefined; + + /** + * A WebGL Rendering Context. + * (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext) + * Default is null + */ + context?: WebGLRenderingContext | undefined; + + /** + * shader precision. Can be "highp", "mediump" or "lowp". + */ + precision?: string | undefined; + + /** + * default is false. + */ + alpha?: boolean | undefined; + + /** + * default is true. + */ + premultipliedAlpha?: boolean | undefined; + + /** + * default is false. + */ + antialias?: boolean | undefined; + + /** + * default is true. + */ + stencil?: boolean | undefined; + + /** + * default is false. + */ + preserveDrawingBuffer?: boolean | undefined; + + /** + * Can be "high-performance", "low-power" or "default" + */ + powerPreference?: string | undefined; + + /** + * default is true. + */ + depth?: boolean | undefined; + + /** + * default is false. + */ + logarithmicDepthBuffer?: boolean | undefined; + + /** + * default is false. + */ + failIfMajorPerformanceCaveat?: boolean | undefined; +} + +export interface WebGLDebug { + /** + * Enables error checking and reporting when shader programs are being compiled. + */ + checkShaderErrors: boolean; +} + +/** + * The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it. + * This renderer has way better performance than CanvasRenderer. + * + * see {@link https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderer.js|src/renderers/WebGLRenderer.js} + */ +export class WebGLRenderer implements Renderer { + /** + * parameters is an optional object with properties defining the renderer's behaviour. + * The constructor also accepts no parameters at all. + * In all cases, it will assume sane defaults when parameters are missing. + */ + constructor(parameters?: WebGLRendererParameters); + + /** + * A Canvas where the renderer draws its output. + * This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. + * @default document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ) + */ + domElement: HTMLCanvasElement; + + /** + * The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw. + */ + context: WebGLRenderingContext; + + /** + * Defines whether the renderer should automatically clear its output before rendering. + * @default true + */ + autoClear: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the color buffer. Default is true. + * @default true + */ + autoClearColor: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true. + * @default true + */ + autoClearDepth: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true. + * @default true + */ + autoClearStencil: boolean; + + /** + * Debug configurations. + * @default { checkShaderErrors: true } + */ + debug: WebGLDebug; + + /** + * Defines whether the renderer should sort objects. Default is true. + * @default true + */ + sortObjects: boolean; + + /** + * @default [] + */ + clippingPlanes: any[]; + + /** + * @default false + */ + localClippingEnabled: boolean; + + extensions: WebGLExtensions; + + /** + * Default is LinearEncoding. + * @default THREE.LinearEncoding + */ + outputEncoding: TextureEncoding; + + /** + * @default false + */ + physicallyCorrectLights: boolean; + + /** + * @default THREE.NoToneMapping + */ + toneMapping: ToneMapping; + + /** + * @default 1 + */ + toneMappingExposure: number; + + info: WebGLInfo; + + shadowMap: WebGLShadowMap; + + pixelRatio: number; + + capabilities: WebGLCapabilities; + properties: WebGLProperties; + renderLists: WebGLRenderLists; + state: WebGLState; + + xr: WebXRManager; + + /** + * Return the WebGL context. + */ + getContext(): WebGLRenderingContext | WebGL2RenderingContext; + getContextAttributes(): any; + forceContextLoss(): void; + forceContextRestore(): void; + + /** + * @deprecated Use {@link WebGLCapabilities#getMaxAnisotropy .capabilities.getMaxAnisotropy()} instead. + */ + getMaxAnisotropy(): number; + + /** + * @deprecated Use {@link WebGLCapabilities#precision .capabilities.precision} instead. + */ + getPrecision(): string; + + getPixelRatio(): number; + setPixelRatio(value: number): void; + + getDrawingBufferSize(target: Vector2): Vector2; + setDrawingBufferSize(width: number, height: number, pixelRatio: number): void; + + getSize(target: Vector2): Vector2; + + /** + * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). + */ + setSize(width: number, height: number, updateStyle?: boolean): void; + + getCurrentViewport(target: Vector4): Vector4; + + /** + * Copies the viewport into target. + */ + getViewport(target: Vector4): Vector4; + + /** + * Sets the viewport to render from (x, y) to (x + width, y + height). + * (x, y) is the lower-left corner of the region. + */ + setViewport(x: Vector4 | number, y?: number, width?: number, height?: number): void; + + /** + * Copies the scissor area into target. + */ + getScissor(target: Vector4): Vector4; + + /** + * Sets the scissor area from (x, y) to (x + width, y + height). + */ + setScissor(x: Vector4 | number, y?: number, width?: number, height?: number): void; + + /** + * Returns true if scissor test is enabled; returns false otherwise. + */ + getScissorTest(): boolean; + + /** + * Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions. + */ + setScissorTest(enable: boolean): void; + + /** + * Sets the custom opaque sort function for the WebGLRenderLists. Pass null to use the default painterSortStable function. + */ + setOpaqueSort(method: (a: any, b: any) => number): void; + + /** + * Sets the custom transparent sort function for the WebGLRenderLists. Pass null to use the default reversePainterSortStable function. + */ + setTransparentSort(method: (a: any, b: any) => number): void; + + /** + * Returns a THREE.Color instance with the current clear color. + */ + getClearColor(target: Color): Color; + + /** + * Sets the clear color, using color for the color and alpha for the opacity. + */ + setClearColor(color: ColorRepresentation, alpha?: number): void; + + /** + * Returns a float with the current clear alpha. Ranges from 0 to 1. + */ + getClearAlpha(): number; + + setClearAlpha(alpha: number): void; + + /** + * Tells the renderer to clear its color, depth or stencil drawing buffer(s). + * Arguments default to true + */ + clear(color?: boolean, depth?: boolean, stencil?: boolean): void; + + clearColor(): void; + clearDepth(): void; + clearStencil(): void; + clearTarget(renderTarget: WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; + + /** + * @deprecated Use {@link WebGLState#reset .state.reset()} instead. + */ + resetGLState(): void; + dispose(): void; + + renderBufferDirect(camera: Camera, scene: Scene, geometry: BufferGeometry, material: Material, object: Object3D, geometryGroup: any): void; + + /** + * A build in function that can be used instead of requestAnimationFrame. For WebXR projects this function must be used. + * @param callback The function will be called every available frame. If `null` is passed it will stop any already ongoing animation. + */ + setAnimationLoop(callback: XRAnimationLoopCallback | null): void; + + /** + * @deprecated Use {@link WebGLRenderer#setAnimationLoop .setAnimationLoop()} instead. + */ + animate(callback: () => void): void; + + /** + * Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first rendering. + */ + compile(scene: Object3D, camera: Camera): void; + + /** + * Render a scene or an object using a camera. + * The render is done to a previously specified {@link WebGLRenderTarget#renderTarget .renderTarget} set by calling + * {@link WebGLRenderer#setRenderTarget .setRenderTarget} or to the canvas as usual. + * + * By default render buffers are cleared before rendering but you can prevent this by setting the property + * {@link WebGLRenderer#autoClear autoClear} to false. If you want to prevent only certain buffers being cleared + * you can set either the {@link WebGLRenderer#autoClearColor autoClearColor}, + * {@link WebGLRenderer#autoClearStencil autoClearStencil} or {@link WebGLRenderer#autoClearDepth autoClearDepth} + * properties to false. To forcibly clear one ore more buffers call {@link WebGLRenderer#clear .clear}. + */ + render(scene: Object3D, camera: Camera): void; + + /** + * Returns the current active cube face. + */ + getActiveCubeFace(): number; + + /** + * Returns the current active mipmap level. + */ + getActiveMipmapLevel(): number; + + /** + * Returns the current render target. If no render target is set, null is returned. + */ + getRenderTarget(): WebGLRenderTarget | null; + + /** + * @deprecated Use {@link WebGLRenderer#getRenderTarget .getRenderTarget()} instead. + */ + getCurrentRenderTarget(): WebGLRenderTarget | null; + + /** + * Sets the active render target. + * + * @param renderTarget The {@link WebGLRenderTarget renderTarget} that needs to be activated. When `null` is given, the canvas is set as the active render target instead. + * @param activeCubeFace Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of {@link WebGLCubeRenderTarget}. + * @param activeMipmapLevel Specifies the active mipmap level. + */ + setRenderTarget(renderTarget: WebGLRenderTarget | WebGLMultipleRenderTargets | null, activeCubeFace?: number, activeMipmapLevel?: number): void; + + readRenderTargetPixels( + renderTarget: WebGLRenderTarget | WebGLMultipleRenderTargets, + x: number, + y: number, + width: number, + height: number, + buffer: any, + activeCubeFaceIndex?: number + ): void; + + /** + * Copies a region of the currently bound framebuffer into the selected mipmap level of the selected texture. + * This region is defined by the size of the destination texture's mip level, offset by the input position. + * + * @param position Specifies the pixel offset from which to copy out of the framebuffer. + * @param texture Specifies the destination texture. + * @param level Specifies the destination mipmap level of the texture. + */ + copyFramebufferToTexture(position: Vector2, texture: Texture, level?: number): void; + + /** + * Copies srcTexture to the specified level of dstTexture, offset by the input position. + * + * @param position Specifies the pixel offset into the dstTexture where the copy will occur. + * @param srcTexture Specifies the source texture. + * @param dstTexture Specifies the destination texture. + * @param level Specifies the destination mipmap level of the texture. + */ + copyTextureToTexture(position: Vector2, srcTexture: Texture, dstTexture: Texture, level?: number): void; + + /** + * Copies the pixels of a texture in the bounds sourceBox in the desination texture starting from the given position. + * @param sourceBox Specifies the bounds + * @param position Specifies the pixel offset into the dstTexture where the copy will occur. + * @param srcTexture Specifies the source texture. + * @param dstTexture Specifies the destination texture. + * @param level Specifies the destination mipmap level of the texture. + */ + copyTextureToTexture3D(sourceBox: Box3, position: Vector3, srcTexture: Texture, dstTexture: Data3DTexture | DataArrayTexture, level?: number): void; + + /** + * Initializes the given texture. Can be used to preload a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead). + * + * @param texture The texture to Initialize. + */ + initTexture(texture: Texture): void; + + /** + * Can be used to reset the internal WebGL state. + */ + resetState(): void; + + /** + * @deprecated Use {@link WebGLRenderer#xr .xr} instead. + */ + vr: boolean; + + /** + * @deprecated Use {@link WebGLShadowMap#enabled .shadowMap.enabled} instead. + */ + shadowMapEnabled: boolean; + + /** + * @deprecated Use {@link WebGLShadowMap#type .shadowMap.type} instead. + */ + shadowMapType: ShadowMapType; + + /** + * @deprecated Use {@link WebGLShadowMap#cullFace .shadowMap.cullFace} instead. + */ + shadowMapCullFace: CullFace; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_float' )} instead. + */ + supportsFloatTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_half_float' )} instead. + */ + supportsHalfFloatTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_standard_derivatives' )} instead. + */ + supportsStandardDerivatives(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_s3tc' )} instead. + */ + supportsCompressedTextureS3TC(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_pvrtc' )} instead. + */ + supportsCompressedTexturePVRTC(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'EXT_blend_minmax' )} instead. + */ + supportsBlendMinMax(): any; + + /** + * @deprecated Use {@link WebGLCapabilities#vertexTextures .capabilities.vertexTextures} instead. + */ + supportsVertexTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'ANGLE_instanced_arrays' )} instead. + */ + supportsInstancedArrays(): any; + + /** + * @deprecated Use {@link WebGLRenderer#setScissorTest .setScissorTest()} instead. + */ + enableScissorTest(boolean: any): any; +} diff --git a/backend/libs/three/renderers/WebGLRenderer.js b/backend/libs/three/renderers/WebGLRenderer.js new file mode 100644 index 0000000000000000000000000000000000000000..1439a5a3e4485aa8a37f8bd7dea7e859d9672a59 --- /dev/null +++ b/backend/libs/three/renderers/WebGLRenderer.js @@ -0,0 +1,1723 @@ +import { + REVISION, + BackSide, + DoubleSide, + FrontSide, + RGBAFormat, + HalfFloatType, + FloatType, + UnsignedByteType, + LinearEncoding, + NoToneMapping, + LinearMipmapLinearFilter, + NearestFilter, + ClampToEdgeWrapping, +} from '../constants.js'; +import { Frustum } from '../math/Frustum.js'; +import { Matrix4 } from '../math/Matrix4.js'; +import { Vector3 } from '../math/Vector3.js'; +import { Vector4 } from '../math/Vector4.js'; +import { WebGLAnimation } from './webgl/WebGLAnimation.js'; +import { WebGLAttributes } from './webgl/WebGLAttributes.js'; +import { WebGLBackground } from './webgl/WebGLBackground.js'; +import { WebGLBindingStates } from './webgl/WebGLBindingStates.js'; +import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js'; +import { WebGLCapabilities } from './webgl/WebGLCapabilities.js'; +import { WebGLClipping } from './webgl/WebGLClipping.js'; +import { WebGLCubeMaps } from './webgl/WebGLCubeMaps.js'; +import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js'; +import { WebGLExtensions } from './webgl/WebGLExtensions.js'; +import { WebGLGeometries } from './webgl/WebGLGeometries.js'; +import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js'; +import { WebGLInfo } from './webgl/WebGLInfo.js'; +import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js'; +import { WebGLMultisampleRenderTarget } from './WebGLMultisampleRenderTarget.js'; +import { WebGLObjects } from './webgl/WebGLObjects.js'; +import { WebGLPrograms } from './webgl/WebGLPrograms.js'; +import { WebGLProperties } from './webgl/WebGLProperties.js'; +import { WebGLRenderLists } from './webgl/WebGLRenderLists.js'; +import { WebGLRenderStates } from './webgl/WebGLRenderStates.js'; +import { WebGLRenderTarget } from './WebGLRenderTarget.js'; +import { WebGLShadowMap } from './webgl/WebGLShadowMap.js'; +import { WebGLState } from './webgl/WebGLState.js'; +import { WebGLTextures } from './webgl/WebGLTextures.js'; +import { WebGLUniforms } from './webgl/WebGLUniforms.js'; +import { WebGLUtils } from './webgl/WebGLUtils.js'; +import { WebXRManager } from './webxr/WebXRManager.js'; +import { WebGLMaterials } from './webgl/WebGLMaterials.js'; +import { createElementNS } from '../utils.js'; + +function createCanvasElement() { + const canvas = createElementNS('canvas'); + canvas.style.display = 'block'; + return canvas; +} + +function WebGLRenderer(parameters = {}) { + const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(), + _context = parameters.context !== undefined ? parameters.context : null, + _alpha = parameters.alpha !== undefined ? parameters.alpha : false, + _depth = parameters.depth !== undefined ? parameters.depth : true, + _stencil = parameters.stencil !== undefined ? parameters.stencil : true, + _antialias = parameters.antialias !== undefined ? parameters.antialias : false, + _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, + _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false, + _powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default', + _failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false; + + let currentRenderList = null; + let currentRenderState = null; + + // render() can be called from within a callback triggered by another render. + // We track this so that the nested render call gets its list and state isolated from the parent render call. + + const renderListStack = []; + const renderStateStack = []; + + // public properties + + this.domElement = _canvas; + + // Debug configuration container + this.debug = { + /** + * Enables error checking and reporting when shader programs are being compiled + * @type {boolean} + */ + checkShaderErrors: true, + }; + + // clearing + + this.autoClear = true; + this.autoClearColor = true; + this.autoClearDepth = true; + this.autoClearStencil = true; + + // scene graph + + this.sortObjects = true; + + // user-defined clipping + + this.clippingPlanes = []; + this.localClippingEnabled = false; + + // physically based shading + + this.outputEncoding = LinearEncoding; + + // physical lights + + this.physicallyCorrectLights = false; + + // tone mapping + + this.toneMapping = NoToneMapping; + this.toneMappingExposure = 1.0; + + // internal properties + + const _this = this; + + let _isContextLost = false; + + // internal state cache + + let _currentActiveCubeFace = 0; + let _currentActiveMipmapLevel = 0; + let _currentRenderTarget = null; + let _currentMaterialId = -1; + + let _currentCamera = null; + + const _currentViewport = new Vector4(); + const _currentScissor = new Vector4(); + let _currentScissorTest = null; + + // + + let _width = _canvas.width; + let _height = _canvas.height; + + let _pixelRatio = 1; + let _opaqueSort = null; + let _transparentSort = null; + + const _viewport = new Vector4(0, 0, _width, _height); + const _scissor = new Vector4(0, 0, _width, _height); + let _scissorTest = false; + + // frustum + + const _frustum = new Frustum(); + + // clipping + + let _clippingEnabled = false; + let _localClippingEnabled = false; + + // transmission + + let _transmissionRenderTarget = null; + + // camera matrices cache + + const _projScreenMatrix = new Matrix4(); + + const _vector3 = new Vector3(); + + const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true }; + + function getTargetPixelRatio() { + return _currentRenderTarget === null ? _pixelRatio : 1; + } + + // initialize + + let _gl = _context; + + function getContext(contextNames, contextAttributes) { + for (let i = 0; i < contextNames.length; i++) { + const contextName = contextNames[i]; + const context = _canvas.getContext(contextName, contextAttributes); + if (context !== null) return context; + } + + return null; + } + + try { + const contextAttributes = { + alpha: true, + depth: _depth, + stencil: _stencil, + antialias: _antialias, + premultipliedAlpha: _premultipliedAlpha, + preserveDrawingBuffer: _preserveDrawingBuffer, + powerPreference: _powerPreference, + failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat, + }; + + // OffscreenCanvas does not have setAttribute, see #22811 + if ('setAttribute' in _canvas) _canvas.setAttribute('data-engine', `three.js r${REVISION}`); + + // event listeners must be registered before WebGL context is created, see #12753 + _canvas.addEventListener('webglcontextlost', onContextLost, false); + _canvas.addEventListener('webglcontextrestored', onContextRestore, false); + + if (_gl === null) { + const contextNames = ['webgl2', 'webgl', 'experimental-webgl']; + + if (_this.isWebGL1Renderer === true) { + contextNames.shift(); + } + + _gl = getContext(contextNames, contextAttributes); + + if (_gl === null) { + if (getContext(contextNames)) { + throw new Error('Error creating WebGL context with your selected attributes.'); + } else { + throw new Error('Error creating WebGL context.'); + } + } + } + + // Some experimental-webgl implementations do not have getShaderPrecisionFormat + + if (_gl.getShaderPrecisionFormat === undefined) { + _gl.getShaderPrecisionFormat = function () { + return { rangeMin: 1, rangeMax: 1, precision: 1 }; + }; + } + } catch (error) { + console.error('THREE.WebGLRenderer: ' + error.message); + throw error; + } + + let extensions, capabilities, state, info; + let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects; + let programCache, materials, renderLists, renderStates, clipping, shadowMap; + + let background, morphtargets, bufferRenderer, indexedBufferRenderer; + + let utils, bindingStates; + + function initGLContext() { + extensions = new WebGLExtensions(_gl); + + capabilities = new WebGLCapabilities(_gl, extensions, parameters); + + extensions.init(capabilities); + + utils = new WebGLUtils(_gl, extensions, capabilities); + + state = new WebGLState(_gl, extensions, capabilities); + + info = new WebGLInfo(_gl); + properties = new WebGLProperties(); + textures = new WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info); + cubemaps = new WebGLCubeMaps(_this); + cubeuvmaps = new WebGLCubeUVMaps(_this); + attributes = new WebGLAttributes(_gl, capabilities); + bindingStates = new WebGLBindingStates(_gl, extensions, attributes, capabilities); + geometries = new WebGLGeometries(_gl, attributes, info, bindingStates); + objects = new WebGLObjects(_gl, geometries, attributes, info); + morphtargets = new WebGLMorphtargets(_gl, capabilities, textures); + clipping = new WebGLClipping(properties); + programCache = new WebGLPrograms(_this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping); + materials = new WebGLMaterials(properties); + renderLists = new WebGLRenderLists(); + renderStates = new WebGLRenderStates(extensions, capabilities); + background = new WebGLBackground(_this, cubemaps, state, objects, _alpha, _premultipliedAlpha); + shadowMap = new WebGLShadowMap(_this, objects, capabilities); + + bufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities); + indexedBufferRenderer = new WebGLIndexedBufferRenderer(_gl, extensions, info, capabilities); + + info.programs = programCache.programs; + + _this.capabilities = capabilities; + _this.extensions = extensions; + _this.properties = properties; + _this.renderLists = renderLists; + _this.shadowMap = shadowMap; + _this.state = state; + _this.info = info; + } + + initGLContext(); + + // xr + + const xr = new WebXRManager(_this, _gl); + + this.xr = xr; + + // API + + this.getContext = function () { + return _gl; + }; + + this.getContextAttributes = function () { + return _gl.getContextAttributes(); + }; + + this.forceContextLoss = function () { + const extension = extensions.get('WEBGL_lose_context'); + if (extension) extension.loseContext(); + }; + + this.forceContextRestore = function () { + const extension = extensions.get('WEBGL_lose_context'); + if (extension) extension.restoreContext(); + }; + + this.getPixelRatio = function () { + return _pixelRatio; + }; + + this.setPixelRatio = function (value) { + if (value === undefined) return; + + _pixelRatio = value; + + this.setSize(_width, _height, false); + }; + + this.getSize = function (target) { + return target.set(_width, _height); + }; + + this.setSize = function (width, height, updateStyle) { + if (xr.isPresenting) { + console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."); + return; + } + + _width = width; + _height = height; + + _canvas.width = Math.floor(width * _pixelRatio); + _canvas.height = Math.floor(height * _pixelRatio); + + if (updateStyle !== false) { + _canvas.style.width = width + 'px'; + _canvas.style.height = height + 'px'; + } + + this.setViewport(0, 0, width, height); + }; + + this.getDrawingBufferSize = function (target) { + return target.set(_width * _pixelRatio, _height * _pixelRatio).floor(); + }; + + this.setDrawingBufferSize = function (width, height, pixelRatio) { + _width = width; + _height = height; + + _pixelRatio = pixelRatio; + + _canvas.width = Math.floor(width * pixelRatio); + _canvas.height = Math.floor(height * pixelRatio); + + this.setViewport(0, 0, width, height); + }; + + this.getCurrentViewport = function (target) { + return target.copy(_currentViewport); + }; + + this.getViewport = function (target) { + return target.copy(_viewport); + }; + + this.setViewport = function (x, y, width, height) { + if (x.isVector4) { + _viewport.set(x.x, x.y, x.z, x.w); + } else { + _viewport.set(x, y, width, height); + } + + state.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor()); + }; + + this.getScissor = function (target) { + return target.copy(_scissor); + }; + + this.setScissor = function (x, y, width, height) { + if (x.isVector4) { + _scissor.set(x.x, x.y, x.z, x.w); + } else { + _scissor.set(x, y, width, height); + } + + state.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor()); + }; + + this.getScissorTest = function () { + return _scissorTest; + }; + + this.setScissorTest = function (boolean) { + state.setScissorTest((_scissorTest = boolean)); + }; + + this.setOpaqueSort = function (method) { + _opaqueSort = method; + }; + + this.setTransparentSort = function (method) { + _transparentSort = method; + }; + + // Clearing + + this.getClearColor = function (target) { + return target.copy(background.getClearColor()); + }; + + this.setClearColor = function () { + background.setClearColor.apply(background, arguments); + }; + + this.getClearAlpha = function () { + return background.getClearAlpha(); + }; + + this.setClearAlpha = function () { + background.setClearAlpha.apply(background, arguments); + }; + + this.clear = function (color, depth, stencil) { + let bits = 0; + + if (color === undefined || color) bits |= _gl.COLOR_BUFFER_BIT; + if (depth === undefined || depth) bits |= _gl.DEPTH_BUFFER_BIT; + if (stencil === undefined || stencil) bits |= _gl.STENCIL_BUFFER_BIT; + + _gl.clear(bits); + }; + + this.clearColor = function () { + this.clear(true, false, false); + }; + + this.clearDepth = function () { + this.clear(false, true, false); + }; + + this.clearStencil = function () { + this.clear(false, false, true); + }; + + // + + this.dispose = function () { + _canvas.removeEventListener('webglcontextlost', onContextLost, false); + _canvas.removeEventListener('webglcontextrestored', onContextRestore, false); + + renderLists.dispose(); + renderStates.dispose(); + properties.dispose(); + cubemaps.dispose(); + cubeuvmaps.dispose(); + objects.dispose(); + bindingStates.dispose(); + programCache.dispose(); + + xr.dispose(); + + xr.removeEventListener('sessionstart', onXRSessionStart); + xr.removeEventListener('sessionend', onXRSessionEnd); + + if (_transmissionRenderTarget) { + _transmissionRenderTarget.dispose(); + _transmissionRenderTarget = null; + } + + animation.stop(); + }; + + // Events + + function onContextLost(event) { + event.preventDefault(); + + console.log('THREE.WebGLRenderer: Context Lost.'); + + _isContextLost = true; + } + + function onContextRestore(/* event */) { + console.log('THREE.WebGLRenderer: Context Restored.'); + + _isContextLost = false; + + const infoAutoReset = info.autoReset; + const shadowMapEnabled = shadowMap.enabled; + const shadowMapAutoUpdate = shadowMap.autoUpdate; + const shadowMapNeedsUpdate = shadowMap.needsUpdate; + const shadowMapType = shadowMap.type; + + initGLContext(); + + info.autoReset = infoAutoReset; + shadowMap.enabled = shadowMapEnabled; + shadowMap.autoUpdate = shadowMapAutoUpdate; + shadowMap.needsUpdate = shadowMapNeedsUpdate; + shadowMap.type = shadowMapType; + } + + function onMaterialDispose(event) { + const material = event.target; + + material.removeEventListener('dispose', onMaterialDispose); + + deallocateMaterial(material); + } + + // Buffer deallocation + + function deallocateMaterial(material) { + releaseMaterialProgramReferences(material); + + properties.remove(material); + } + + function releaseMaterialProgramReferences(material) { + const programs = properties.get(material).programs; + + if (programs !== undefined) { + programs.forEach(function (program) { + programCache.releaseProgram(program); + }); + + if (material.isShaderMaterial) { + programCache.releaseShaderCache(material); + } + } + } + + // Buffer rendering + + this.renderBufferDirect = function (camera, scene, geometry, material, object, group) { + if (scene === null) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null) + + const frontFaceCW = object.isMesh && object.matrixWorld.determinant() < 0; + + const program = setProgram(camera, scene, geometry, material, object); + + state.setMaterial(material, frontFaceCW); + + // + + let index = geometry.index; + const position = geometry.attributes.position; + + // + + if (index === null) { + if (position === undefined || position.count === 0) return; + } else if (index.count === 0) { + return; + } + + // + + let rangeFactor = 1; + + if (material.wireframe === true) { + index = geometries.getWireframeAttribute(geometry); + rangeFactor = 2; + } + + bindingStates.setup(object, material, program, geometry, index); + + let attribute; + let renderer = bufferRenderer; + + if (index !== null) { + attribute = attributes.get(index); + + renderer = indexedBufferRenderer; + renderer.setIndex(attribute); + } + + // + + const dataCount = index !== null ? index.count : position.count; + + const rangeStart = geometry.drawRange.start * rangeFactor; + const rangeCount = geometry.drawRange.count * rangeFactor; + + const groupStart = group !== null ? group.start * rangeFactor : 0; + const groupCount = group !== null ? group.count * rangeFactor : Infinity; + + const drawStart = Math.max(rangeStart, groupStart); + const drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1; + + const drawCount = Math.max(0, drawEnd - drawStart + 1); + + if (drawCount === 0) return; + + // + + if (object.isMesh) { + if (material.wireframe === true) { + state.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio()); + renderer.setMode(_gl.LINES); + } else { + renderer.setMode(_gl.TRIANGLES); + } + } else if (object.isLine) { + let lineWidth = material.linewidth; + + if (lineWidth === undefined) lineWidth = 1; // Not using Line*Material + + state.setLineWidth(lineWidth * getTargetPixelRatio()); + + if (object.isLineSegments) { + renderer.setMode(_gl.LINES); + } else if (object.isLineLoop) { + renderer.setMode(_gl.LINE_LOOP); + } else { + renderer.setMode(_gl.LINE_STRIP); + } + } else if (object.isPoints) { + renderer.setMode(_gl.POINTS); + } else if (object.isSprite) { + renderer.setMode(_gl.TRIANGLES); + } + + if (object.isInstancedMesh) { + renderer.renderInstances(drawStart, drawCount, object.count); + } else if (geometry.isInstancedBufferGeometry) { + const instanceCount = Math.min(geometry.instanceCount, geometry._maxInstanceCount); + + renderer.renderInstances(drawStart, drawCount, instanceCount); + } else { + renderer.render(drawStart, drawCount); + } + }; + + // Compile + + this.compile = function (scene, camera) { + currentRenderState = renderStates.get(scene); + currentRenderState.init(); + + renderStateStack.push(currentRenderState); + + scene.traverseVisible(function (object) { + if (object.isLight && object.layers.test(camera.layers)) { + currentRenderState.pushLight(object); + + if (object.castShadow) { + currentRenderState.pushShadow(object); + } + } + }); + + currentRenderState.setupLights(_this.physicallyCorrectLights); + + scene.traverse(function (object) { + const material = object.material; + + if (material) { + if (Array.isArray(material)) { + for (let i = 0; i < material.length; i++) { + const material2 = material[i]; + + getProgram(material2, scene, object); + } + } else { + getProgram(material, scene, object); + } + } + }); + + renderStateStack.pop(); + currentRenderState = null; + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame(time) { + if (onAnimationFrameCallback) onAnimationFrameCallback(time); + } + + function onXRSessionStart() { + animation.stop(); + } + + function onXRSessionEnd() { + animation.start(); + } + + const animation = new WebGLAnimation(); + animation.setAnimationLoop(onAnimationFrame); + + if (typeof window !== 'undefined') animation.setContext(window); + + this.setAnimationLoop = function (callback) { + onAnimationFrameCallback = callback; + xr.setAnimationLoop(callback); + + callback === null ? animation.stop() : animation.start(); + }; + + xr.addEventListener('sessionstart', onXRSessionStart); + xr.addEventListener('sessionend', onXRSessionEnd); + + // Rendering + + this.render = function (scene, camera) { + if (camera !== undefined && camera.isCamera !== true) { + console.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.'); + return; + } + + if (_isContextLost === true) return; + + // update scene graph + + if (scene.autoUpdate === true) scene.updateMatrixWorld(); + + // update camera matrices and frustum + + if (camera.parent === null) camera.updateMatrixWorld(); + + if (xr.enabled === true && xr.isPresenting === true) { + if (xr.cameraAutoUpdate === true) xr.updateCamera(camera); + + camera = xr.getCamera(); // use XR camera for rendering + } + + // + if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget); + + currentRenderState = renderStates.get(scene, renderStateStack.length); + currentRenderState.init(); + + renderStateStack.push(currentRenderState); + + _projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse); + _frustum.setFromProjectionMatrix(_projScreenMatrix); + + _localClippingEnabled = this.localClippingEnabled; + _clippingEnabled = clipping.init(this.clippingPlanes, _localClippingEnabled, camera); + + currentRenderList = renderLists.get(scene, renderListStack.length); + currentRenderList.init(); + + renderListStack.push(currentRenderList); + + projectObject(scene, camera, 0, _this.sortObjects); + + currentRenderList.finish(); + + if (_this.sortObjects === true) { + currentRenderList.sort(_opaqueSort, _transparentSort); + } + + // + + if (_clippingEnabled === true) clipping.beginShadows(); + + const shadowsArray = currentRenderState.state.shadowsArray; + + shadowMap.render(shadowsArray, scene, camera); + + if (_clippingEnabled === true) clipping.endShadows(); + + // + + if (this.info.autoReset === true) this.info.reset(); + + // + + background.render(currentRenderList, scene); + + // render scene + + currentRenderState.setupLights(_this.physicallyCorrectLights); + + if (camera.isArrayCamera) { + const cameras = camera.cameras; + + for (let i = 0, l = cameras.length; i < l; i++) { + const camera2 = cameras[i]; + + renderScene(currentRenderList, scene, camera2, camera2.viewport); + } + } else { + renderScene(currentRenderList, scene, camera); + } + + // + + if (_currentRenderTarget !== null) { + // resolve multisample renderbuffers to a single-sample texture if necessary + + textures.updateMultisampleRenderTarget(_currentRenderTarget); + + // Generate mipmap if we're using any kind of mipmap filtering + + textures.updateRenderTargetMipmap(_currentRenderTarget); + } + + // + + if (scene.isScene === true) scene.onAfterRender(_this, scene, camera); + + // Ensure depth buffer writing is enabled so it can be cleared on next render + + state.buffers.depth.setTest(true); + state.buffers.depth.setMask(true); + state.buffers.color.setMask(true); + + state.setPolygonOffset(false); + + // _gl.finish(); + + bindingStates.resetDefaultState(); + _currentMaterialId = -1; + _currentCamera = null; + + renderStateStack.pop(); + + if (renderStateStack.length > 0) { + currentRenderState = renderStateStack[renderStateStack.length - 1]; + } else { + currentRenderState = null; + } + + renderListStack.pop(); + + if (renderListStack.length > 0) { + currentRenderList = renderListStack[renderListStack.length - 1]; + } else { + currentRenderList = null; + } + }; + + function projectObject(object, camera, groupOrder, sortObjects) { + if (object.visible === false) return; + + const visible = object.layers.test(camera.layers); + + if (visible) { + if (object.isGroup) { + groupOrder = object.renderOrder; + } else if (object.isLOD) { + if (object.autoUpdate === true) object.update(camera); + } else if (object.isLight) { + currentRenderState.pushLight(object); + + if (object.castShadow) { + currentRenderState.pushShadow(object); + } + } else if (object.isSprite) { + if (!object.frustumCulled || _frustum.intersectsSprite(object)) { + if (sortObjects) { + _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix); + } + + const geometry = objects.update(object); + const material = object.material; + + if (material.visible) { + currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null); + } + } + } else if (object.isMesh || object.isLine || object.isPoints) { + if (object.isSkinnedMesh) { + // update skeleton only once in a frame + + if (object.skeleton.frame !== info.render.frame) { + object.skeleton.update(); + object.skeleton.frame = info.render.frame; + } + } + + if (!object.frustumCulled || _frustum.intersectsObject(object)) { + if (sortObjects) { + _vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix); + } + + const geometry = objects.update(object); + const material = object.material; + + if (Array.isArray(material)) { + const groups = geometry.groups; + + for (let i = 0, l = groups.length; i < l; i++) { + const group = groups[i]; + const groupMaterial = material[group.materialIndex]; + + if (groupMaterial && groupMaterial.visible) { + currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector3.z, group); + } + } + } else if (material.visible) { + currentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null); + } + } + } + } + + const children = object.children; + + for (let i = 0, l = children.length; i < l; i++) { + projectObject(children[i], camera, groupOrder, sortObjects); + } + } + + function renderScene(currentRenderList, scene, camera, viewport) { + const opaqueObjects = currentRenderList.opaque; + const transmissiveObjects = currentRenderList.transmissive; + const transparentObjects = currentRenderList.transparent; + + currentRenderState.setupLightsView(camera); + + if (transmissiveObjects.length > 0) renderTransmissionPass(opaqueObjects, scene, camera); + + if (viewport) state.viewport(_currentViewport.copy(viewport)); + + if (opaqueObjects.length > 0) renderObjects(opaqueObjects, scene, camera); + if (transmissiveObjects.length > 0) renderObjects(transmissiveObjects, scene, camera); + if (transparentObjects.length > 0) renderObjects(transparentObjects, scene, camera); + } + + function renderTransmissionPass(opaqueObjects, scene, camera) { + if (_transmissionRenderTarget === null) { + const needsAntialias = _antialias === true && capabilities.isWebGL2 === true; + const renderTargetType = needsAntialias ? WebGLMultisampleRenderTarget : WebGLRenderTarget; + + _transmissionRenderTarget = new renderTargetType(1024, 1024, { + generateMipmaps: true, + type: utils.convert(HalfFloatType) !== null ? HalfFloatType : UnsignedByteType, + minFilter: LinearMipmapLinearFilter, + magFilter: NearestFilter, + wrapS: ClampToEdgeWrapping, + wrapT: ClampToEdgeWrapping, + useRenderToTexture: extensions.has('WEBGL_multisampled_render_to_texture'), + }); + } + + const currentRenderTarget = _this.getRenderTarget(); + _this.setRenderTarget(_transmissionRenderTarget); + _this.clear(); + + // Turn off the features which can affect the frag color for opaque objects pass. + // Otherwise they are applied twice in opaque objects pass and transmission objects pass. + const currentToneMapping = _this.toneMapping; + _this.toneMapping = NoToneMapping; + + renderObjects(opaqueObjects, scene, camera); + + _this.toneMapping = currentToneMapping; + + textures.updateMultisampleRenderTarget(_transmissionRenderTarget); + textures.updateRenderTargetMipmap(_transmissionRenderTarget); + + _this.setRenderTarget(currentRenderTarget); + } + + function renderObjects(renderList, scene, camera) { + const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null; + + for (let i = 0, l = renderList.length; i < l; i++) { + const renderItem = renderList[i]; + + const object = renderItem.object; + const geometry = renderItem.geometry; + const material = overrideMaterial === null ? renderItem.material : overrideMaterial; + const group = renderItem.group; + + if (object.layers.test(camera.layers)) { + renderObject(object, scene, camera, geometry, material, group); + } + } + } + + function renderObject(object, scene, camera, geometry, material, group) { + object.onBeforeRender(_this, scene, camera, geometry, material, group); + + object.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld); + object.normalMatrix.getNormalMatrix(object.modelViewMatrix); + + material.onBeforeRender(_this, scene, camera, geometry, object, group); + + if (material.transparent === true && material.side === DoubleSide) { + material.side = BackSide; + material.needsUpdate = true; + _this.renderBufferDirect(camera, scene, geometry, material, object, group); + + material.side = FrontSide; + material.needsUpdate = true; + _this.renderBufferDirect(camera, scene, geometry, material, object, group); + + material.side = DoubleSide; + } else { + _this.renderBufferDirect(camera, scene, geometry, material, object, group); + } + + object.onAfterRender(_this, scene, camera, geometry, material, group); + } + + function getProgram(material, scene, object) { + if (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + const materialProperties = properties.get(material); + + const lights = currentRenderState.state.lights; + const shadowsArray = currentRenderState.state.shadowsArray; + + const lightsStateVersion = lights.state.version; + + const parameters = programCache.getParameters(material, lights.state, shadowsArray, scene, object); + const programCacheKey = programCache.getProgramCacheKey(parameters); + + let programs = materialProperties.programs; + + // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change + + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; + materialProperties.fog = scene.fog; + materialProperties.envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || materialProperties.environment); + + if (programs === undefined) { + // new material + + material.addEventListener('dispose', onMaterialDispose); + + programs = new Map(); + materialProperties.programs = programs; + } + + let program = programs.get(programCacheKey); + + if (program !== undefined) { + // early out if program and light state is identical + + if (materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion) { + updateCommonMaterialProperties(material, parameters); + + return program; + } + } else { + parameters.uniforms = programCache.getUniforms(material); + + material.onBuild(object, parameters, _this); + + material.onBeforeCompile(parameters, _this); + + program = programCache.acquireProgram(parameters, programCacheKey); + programs.set(programCacheKey, program); + + materialProperties.uniforms = parameters.uniforms; + } + + const uniforms = materialProperties.uniforms; + + if ((!material.isShaderMaterial && !material.isRawShaderMaterial) || material.clipping === true) { + uniforms.clippingPlanes = clipping.uniform; + } + + updateCommonMaterialProperties(material, parameters); + + // store the light setup it was created for + + materialProperties.needsLights = materialNeedsLights(material); + materialProperties.lightsStateVersion = lightsStateVersion; + + if (materialProperties.needsLights) { + // wire up the material to this renderer's lighting state + + uniforms.ambientLightColor.value = lights.state.ambient; + uniforms.lightProbe.value = lights.state.probe; + uniforms.directionalLights.value = lights.state.directional; + uniforms.directionalLightShadows.value = lights.state.directionalShadow; + uniforms.spotLights.value = lights.state.spot; + uniforms.spotLightShadows.value = lights.state.spotShadow; + uniforms.rectAreaLights.value = lights.state.rectArea; + uniforms.ltc_1.value = lights.state.rectAreaLTC1; + uniforms.ltc_2.value = lights.state.rectAreaLTC2; + uniforms.pointLights.value = lights.state.point; + uniforms.pointLightShadows.value = lights.state.pointShadow; + uniforms.hemisphereLights.value = lights.state.hemi; + + uniforms.directionalShadowMap.value = lights.state.directionalShadowMap; + uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix; + uniforms.spotShadowMap.value = lights.state.spotShadowMap; + uniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix; + uniforms.pointShadowMap.value = lights.state.pointShadowMap; + uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix; + // TODO (abelnation): add area lights shadow info to uniforms + } + + const progUniforms = program.getUniforms(); + const uniformsList = WebGLUniforms.seqWithValue(progUniforms.seq, uniforms); + + materialProperties.currentProgram = program; + materialProperties.uniformsList = uniformsList; + + return program; + } + + function updateCommonMaterialProperties(material, parameters) { + const materialProperties = properties.get(material); + + materialProperties.outputEncoding = parameters.outputEncoding; + materialProperties.instancing = parameters.instancing; + materialProperties.skinning = parameters.skinning; + materialProperties.morphTargets = parameters.morphTargets; + materialProperties.morphNormals = parameters.morphNormals; + materialProperties.morphTargetsCount = parameters.morphTargetsCount; + materialProperties.numClippingPlanes = parameters.numClippingPlanes; + materialProperties.numIntersection = parameters.numClipIntersection; + materialProperties.vertexAlphas = parameters.vertexAlphas; + materialProperties.vertexTangents = parameters.vertexTangents; + materialProperties.toneMapping = parameters.toneMapping; + } + + function setProgram(camera, scene, geometry, material, object) { + if (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ... + + textures.resetTextureUnits(); + + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + const encoding = _currentRenderTarget === null ? _this.outputEncoding : LinearEncoding; + const envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment); + const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4; + const vertexTangents = !!material.normalMap && !!geometry.attributes.tangent; + const morphTargets = !!geometry.morphAttributes.position; + const morphNormals = !!geometry.morphAttributes.normal; + const morphTargetsCount = !!geometry.morphAttributes.position ? geometry.morphAttributes.position.length : 0; + const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping; + + const materialProperties = properties.get(material); + const lights = currentRenderState.state.lights; + + if (_clippingEnabled === true) { + if (_localClippingEnabled === true || camera !== _currentCamera) { + const useCache = camera === _currentCamera && material.id === _currentMaterialId; + + // we might want to call this function with some ClippingGroup + // object instead of the material, once it becomes feasible + // (#8465, #8379) + clipping.setState(material, camera, useCache); + } + } + + // + + let needsProgramChange = false; + + if (material.version === materialProperties.__version) { + if (materialProperties.needsLights && materialProperties.lightsStateVersion !== lights.state.version) { + needsProgramChange = true; + } else if (materialProperties.outputEncoding !== encoding) { + needsProgramChange = true; + } else if (object.isInstancedMesh && materialProperties.instancing === false) { + needsProgramChange = true; + } else if (!object.isInstancedMesh && materialProperties.instancing === true) { + needsProgramChange = true; + } else if (object.isSkinnedMesh && materialProperties.skinning === false) { + needsProgramChange = true; + } else if (!object.isSkinnedMesh && materialProperties.skinning === true) { + needsProgramChange = true; + } else if (materialProperties.envMap !== envMap) { + needsProgramChange = true; + } else if (material.fog && materialProperties.fog !== fog) { + needsProgramChange = true; + } else if ( + materialProperties.numClippingPlanes !== undefined && + (materialProperties.numClippingPlanes !== clipping.numPlanes || materialProperties.numIntersection !== clipping.numIntersection) + ) { + needsProgramChange = true; + } else if (materialProperties.vertexAlphas !== vertexAlphas) { + needsProgramChange = true; + } else if (materialProperties.vertexTangents !== vertexTangents) { + needsProgramChange = true; + } else if (materialProperties.morphTargets !== morphTargets) { + needsProgramChange = true; + } else if (materialProperties.morphNormals !== morphNormals) { + needsProgramChange = true; + } else if (materialProperties.toneMapping !== toneMapping) { + needsProgramChange = true; + } else if (capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount) { + needsProgramChange = true; + } + } else { + needsProgramChange = true; + materialProperties.__version = material.version; + } + + // + + let program = materialProperties.currentProgram; + + if (needsProgramChange === true) { + program = getProgram(material, scene, object); + } + + let refreshProgram = false; + let refreshMaterial = false; + let refreshLights = false; + + const p_uniforms = program.getUniforms(), + m_uniforms = materialProperties.uniforms; + + if (state.useProgram(program.program)) { + refreshProgram = true; + refreshMaterial = true; + refreshLights = true; + } + + if (material.id !== _currentMaterialId) { + _currentMaterialId = material.id; + + refreshMaterial = true; + } + + if (refreshProgram || _currentCamera !== camera) { + p_uniforms.setValue(_gl, 'projectionMatrix', camera.projectionMatrix); + + if (capabilities.logarithmicDepthBuffer) { + p_uniforms.setValue(_gl, 'logDepthBufFC', 2.0 / (Math.log(camera.far + 1.0) / Math.LN2)); + } + + if (_currentCamera !== camera) { + _currentCamera = camera; + + // lighting uniforms depend on the camera so enforce an update + // now, in case this material supports lights - or later, when + // the next material that does gets activated: + + refreshMaterial = true; // set to true on material change + refreshLights = true; // remains set until update done + } + + // load material specific uniforms + // (shader material also gets them for the sake of genericity) + + if ( + material.isShaderMaterial || + material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshStandardMaterial || + material.envMap + ) { + const uCamPos = p_uniforms.map.cameraPosition; + + if (uCamPos !== undefined) { + uCamPos.setValue(_gl, _vector3.setFromMatrixPosition(camera.matrixWorld)); + } + } + + if ( + material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial + ) { + p_uniforms.setValue(_gl, 'isOrthographic', camera.isOrthographicCamera === true); + } + + if ( + material.isMeshPhongMaterial || + material.isMeshToonMaterial || + material.isMeshLambertMaterial || + material.isMeshBasicMaterial || + material.isMeshStandardMaterial || + material.isShaderMaterial || + material.isShadowMaterial || + object.isSkinnedMesh + ) { + p_uniforms.setValue(_gl, 'viewMatrix', camera.matrixWorldInverse); + } + } + + // skinning and morph target uniforms must be set even if material didn't change + // auto-setting of texture unit for bone and morph texture must go before other textures + // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures + + if (object.isSkinnedMesh) { + p_uniforms.setOptional(_gl, object, 'bindMatrix'); + p_uniforms.setOptional(_gl, object, 'bindMatrixInverse'); + + const skeleton = object.skeleton; + + if (skeleton) { + if (capabilities.floatVertexTextures) { + if (skeleton.boneTexture === null) skeleton.computeBoneTexture(); + + p_uniforms.setValue(_gl, 'boneTexture', skeleton.boneTexture, textures); + p_uniforms.setValue(_gl, 'boneTextureSize', skeleton.boneTextureSize); + } else { + p_uniforms.setOptional(_gl, skeleton, 'boneMatrices'); + } + } + } + + if (!!geometry && (geometry.morphAttributes.position !== undefined || geometry.morphAttributes.normal !== undefined)) { + morphtargets.update(object, geometry, material, program); + } + + if (refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow) { + materialProperties.receiveShadow = object.receiveShadow; + p_uniforms.setValue(_gl, 'receiveShadow', object.receiveShadow); + } + + if (refreshMaterial) { + p_uniforms.setValue(_gl, 'toneMappingExposure', _this.toneMappingExposure); + + if (materialProperties.needsLights) { + // the current material requires lighting info + + // note: all lighting uniforms are always set correctly + // they simply reference the renderer's state for their + // values + // + // use the current material's .needsUpdate flags to set + // the GL state when required + + markUniformsLightsNeedsUpdate(m_uniforms, refreshLights); + } + + // refresh uniforms common to several materials + + if (fog && material.fog) { + materials.refreshFogUniforms(m_uniforms, fog); + } + + materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget); + + WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures); + } + + if (material.isShaderMaterial && material.uniformsNeedUpdate === true) { + WebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures); + material.uniformsNeedUpdate = false; + } + + if (material.isSpriteMaterial) { + p_uniforms.setValue(_gl, 'center', object.center); + } + + // common matrices + + p_uniforms.setValue(_gl, 'modelViewMatrix', object.modelViewMatrix); + p_uniforms.setValue(_gl, 'normalMatrix', object.normalMatrix); + p_uniforms.setValue(_gl, 'modelMatrix', object.matrixWorld); + + return program; + } + + // If uniforms are marked as clean, they don't need to be loaded to the GPU. + + function markUniformsLightsNeedsUpdate(uniforms, value) { + uniforms.ambientLightColor.needsUpdate = value; + uniforms.lightProbe.needsUpdate = value; + + uniforms.directionalLights.needsUpdate = value; + uniforms.directionalLightShadows.needsUpdate = value; + uniforms.pointLights.needsUpdate = value; + uniforms.pointLightShadows.needsUpdate = value; + uniforms.spotLights.needsUpdate = value; + uniforms.spotLightShadows.needsUpdate = value; + uniforms.rectAreaLights.needsUpdate = value; + uniforms.hemisphereLights.needsUpdate = value; + } + + function materialNeedsLights(material) { + return ( + material.isMeshLambertMaterial || + material.isMeshToonMaterial || + material.isMeshPhongMaterial || + material.isMeshStandardMaterial || + material.isShadowMaterial || + (material.isShaderMaterial && material.lights === true) + ); + } + + this.getActiveCubeFace = function () { + return _currentActiveCubeFace; + }; + + this.getActiveMipmapLevel = function () { + return _currentActiveMipmapLevel; + }; + + this.getRenderTarget = function () { + return _currentRenderTarget; + }; + + this.setRenderTargetTextures = function (renderTarget, colorTexture, depthTexture) { + properties.get(renderTarget.texture).__webglTexture = colorTexture; + properties.get(renderTarget.depthTexture).__webglTexture = depthTexture; + + const renderTargetProperties = properties.get(renderTarget); + renderTargetProperties.__hasExternalTextures = true; + + if (renderTargetProperties.__hasExternalTextures) { + renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined; + + if (!renderTargetProperties.__autoAllocateDepthBuffer) { + // The multisample_render_to_texture extension doesn't work properly if there + // are midframe flushes and an external depth buffer. Disable use of the extension. + if (renderTarget.useRenderToTexture) { + console.warn('render-to-texture extension was disabled because an external texture was provided'); + renderTarget.useRenderToTexture = false; + renderTarget.useRenderbuffer = true; + } + } + } + }; + + this.setRenderTargetFramebuffer = function (renderTarget, defaultFramebuffer) { + const renderTargetProperties = properties.get(renderTarget); + renderTargetProperties.__webglFramebuffer = defaultFramebuffer; + renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined; + }; + + this.setRenderTarget = function (renderTarget, activeCubeFace = 0, activeMipmapLevel = 0) { + _currentRenderTarget = renderTarget; + _currentActiveCubeFace = activeCubeFace; + _currentActiveMipmapLevel = activeMipmapLevel; + let useDefaultFramebuffer = true; + + if (renderTarget) { + const renderTargetProperties = properties.get(renderTarget); + + if (renderTargetProperties.__useDefaultFramebuffer !== undefined) { + // We need to make sure to rebind the framebuffer. + state.bindFramebuffer(_gl.FRAMEBUFFER, null); + useDefaultFramebuffer = false; + } else if (renderTargetProperties.__webglFramebuffer === undefined) { + textures.setupRenderTarget(renderTarget); + } else if (renderTargetProperties.__hasExternalTextures) { + // Color and depth texture must be rebound in order for the swapchain to update. + textures.rebindTextures( + renderTarget, + properties.get(renderTarget.texture).__webglTexture, + properties.get(renderTarget.depthTexture).__webglTexture + ); + } + } + + let framebuffer = null; + let isCube = false; + let isRenderTarget3D = false; + + if (renderTarget) { + const texture = renderTarget.texture; + + if (texture.isDataTexture3D || texture.isDataTexture2DArray) { + isRenderTarget3D = true; + } + + const __webglFramebuffer = properties.get(renderTarget).__webglFramebuffer; + + if (renderTarget.isWebGLCubeRenderTarget) { + framebuffer = __webglFramebuffer[activeCubeFace]; + isCube = true; + } else if (renderTarget.useRenderbuffer) { + framebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer; + } else { + framebuffer = __webglFramebuffer; + } + + _currentViewport.copy(renderTarget.viewport); + _currentScissor.copy(renderTarget.scissor); + _currentScissorTest = renderTarget.scissorTest; + } else { + _currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor(); + _currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor(); + _currentScissorTest = _scissorTest; + } + + const framebufferBound = state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer); + + if (framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer) { + state.drawBuffers(renderTarget, framebuffer); + } + + state.viewport(_currentViewport); + state.scissor(_currentScissor); + state.setScissorTest(_currentScissorTest); + + if (isCube) { + const textureProperties = properties.get(renderTarget.texture); + _gl.framebufferTexture2D( + _gl.FRAMEBUFFER, + _gl.COLOR_ATTACHMENT0, + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, + textureProperties.__webglTexture, + activeMipmapLevel + ); + } else if (isRenderTarget3D) { + const textureProperties = properties.get(renderTarget.texture); + const layer = activeCubeFace || 0; + _gl.framebufferTextureLayer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer); + } + + _currentMaterialId = -1; // reset current material to ensure correct uniform bindings + }; + + this.readRenderTargetPixels = function (renderTarget, x, y, width, height, buffer, activeCubeFaceIndex) { + if (!(renderTarget && renderTarget.isWebGLRenderTarget)) { + console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.'); + return; + } + + let framebuffer = properties.get(renderTarget).__webglFramebuffer; + + if (renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined) { + framebuffer = framebuffer[activeCubeFaceIndex]; + } + + if (framebuffer) { + state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer); + + try { + const texture = renderTarget.texture; + const textureFormat = texture.format; + const textureType = texture.type; + + if (textureFormat !== RGBAFormat && utils.convert(textureFormat) !== _gl.getParameter(_gl.IMPLEMENTATION_COLOR_READ_FORMAT)) { + console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.'); + return; + } + + const halfFloatSupportedByExt = + textureType === HalfFloatType && + (extensions.has('EXT_color_buffer_half_float') || (capabilities.isWebGL2 && extensions.has('EXT_color_buffer_float'))); + + if ( + textureType !== UnsignedByteType && + utils.convert(textureType) !== _gl.getParameter(_gl.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513) + !( + textureType === FloatType && + (capabilities.isWebGL2 || extensions.has('OES_texture_float') || extensions.has('WEBGL_color_buffer_float')) + ) && // Chrome Mac >= 52 and Firefox + !halfFloatSupportedByExt + ) { + console.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.'); + return; + } + + if (_gl.checkFramebufferStatus(_gl.FRAMEBUFFER) === _gl.FRAMEBUFFER_COMPLETE) { + // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604) + + if (x >= 0 && x <= renderTarget.width - width && y >= 0 && y <= renderTarget.height - height) { + _gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), buffer); + } + } else { + console.error('THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.'); + } + } finally { + // restore framebuffer of current render target if necessary + + const framebuffer = _currentRenderTarget !== null ? properties.get(_currentRenderTarget).__webglFramebuffer : null; + state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer); + } + } + }; + + this.copyFramebufferToTexture = function (position, texture, level = 0) { + if (texture.isFramebufferTexture !== true) { + console.error('THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.'); + return; + } + + const levelScale = Math.pow(2, -level); + const width = Math.floor(texture.image.width * levelScale); + const height = Math.floor(texture.image.height * levelScale); + + textures.setTexture2D(texture, 0); + + _gl.copyTexSubImage2D(_gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height); + + state.unbindTexture(); + }; + + this.copyTextureToTexture = function (position, srcTexture, dstTexture, level = 0) { + const width = srcTexture.image.width; + const height = srcTexture.image.height; + const glFormat = utils.convert(dstTexture.format); + const glType = utils.convert(dstTexture.type); + + textures.setTexture2D(dstTexture, 0); + + // As another texture upload may have changed pixelStorei + // parameters, make sure they are correct for the dstTexture + _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY); + _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha); + _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment); + + if (srcTexture.isDataTexture) { + _gl.texSubImage2D(_gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data); + } else { + if (srcTexture.isCompressedTexture) { + _gl.compressedTexSubImage2D( + _gl.TEXTURE_2D, + level, + position.x, + position.y, + srcTexture.mipmaps[0].width, + srcTexture.mipmaps[0].height, + glFormat, + srcTexture.mipmaps[0].data + ); + } else { + _gl.texSubImage2D(_gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image); + } + } + + // Generate mipmaps only when copying level 0 + if (level === 0 && dstTexture.generateMipmaps) _gl.generateMipmap(_gl.TEXTURE_2D); + + state.unbindTexture(); + }; + + this.copyTextureToTexture3D = function (sourceBox, position, srcTexture, dstTexture, level = 0) { + if (_this.isWebGL1Renderer) { + console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.'); + return; + } + + const width = sourceBox.max.x - sourceBox.min.x + 1; + const height = sourceBox.max.y - sourceBox.min.y + 1; + const depth = sourceBox.max.z - sourceBox.min.z + 1; + const glFormat = utils.convert(dstTexture.format); + const glType = utils.convert(dstTexture.type); + let glTarget; + + if (dstTexture.isDataTexture3D) { + textures.setTexture3D(dstTexture, 0); + glTarget = _gl.TEXTURE_3D; + } else if (dstTexture.isDataTexture2DArray) { + textures.setTexture2DArray(dstTexture, 0); + glTarget = _gl.TEXTURE_2D_ARRAY; + } else { + console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.'); + return; + } + + _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY); + _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha); + _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment); + + const unpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH); + const unpackImageHeight = _gl.getParameter(_gl.UNPACK_IMAGE_HEIGHT); + const unpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS); + const unpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS); + const unpackSkipImages = _gl.getParameter(_gl.UNPACK_SKIP_IMAGES); + + const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[0] : srcTexture.image; + + _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width); + _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height); + _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, sourceBox.min.x); + _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, sourceBox.min.y); + _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, sourceBox.min.z); + + if (srcTexture.isDataTexture || srcTexture.isDataTexture3D) { + _gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data); + } else { + if (srcTexture.isCompressedTexture) { + console.warn('THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.'); + _gl.compressedTexSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data); + } else { + _gl.texSubImage3D(glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image); + } + } + + _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, unpackRowLen); + _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight); + _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, unpackSkipPixels); + _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, unpackSkipRows); + _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, unpackSkipImages); + + // Generate mipmaps only when copying level 0 + if (level === 0 && dstTexture.generateMipmaps) _gl.generateMipmap(glTarget); + + state.unbindTexture(); + }; + + this.initTexture = function (texture) { + textures.setTexture2D(texture, 0); + + state.unbindTexture(); + }; + + this.resetState = function () { + _currentActiveCubeFace = 0; + _currentActiveMipmapLevel = 0; + _currentRenderTarget = null; + + state.reset(); + bindingStates.reset(); + }; + + if (typeof __THREE_DEVTOOLS__ !== 'undefined') { + __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this })); + } +} + +WebGLRenderer.prototype.isWebGLRenderer = true; + +export { WebGLRenderer }; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk.d.ts b/backend/libs/three/renderers/shaders/ShaderChunk.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..60e92c4d7114ba9f9bfff9b9fcb040dc9a2db481 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk.d.ts @@ -0,0 +1,120 @@ +// Renderers / Shaders ///////////////////////////////////////////////////////////////////// +export let ShaderChunk: { + [name: string]: string; + + alphamap_fragment: string; + alphamap_pars_fragment: string; + alphatest_fragment: string; + aomap_fragment: string; + aomap_pars_fragment: string; + begin_vertex: string; + beginnormal_vertex: string; + bsdfs: string; + bumpmap_pars_fragment: string; + clipping_planes_fragment: string; + clipping_planes_pars_fragment: string; + clipping_planes_pars_vertex: string; + clipping_planes_vertex: string; + color_fragment: string; + color_pars_fragment: string; + color_pars_vertex: string; + color_vertex: string; + common: string; + cube_frag: string; + cube_vert: string; + cube_uv_reflection_fragment: string; + defaultnormal_vertex: string; + depth_frag: string; + depth_vert: string; + distanceRGBA_frag: string; + distanceRGBA_vert: string; + displacementmap_vertex: string; + displacementmap_pars_vertex: string; + emissivemap_fragment: string; + emissivemap_pars_fragment: string; + encodings_pars_fragment: string; + encodings_fragment: string; + envmap_fragment: string; + envmap_common_pars_fragment: string; + envmap_pars_fragment: string; + envmap_pars_vertex: string; + envmap_vertex: string; + equirect_frag: string; + equirect_vert: string; + fog_fragment: string; + fog_pars_fragment: string; + linedashed_frag: string; + linedashed_vert: string; + lightmap_fragment: string; + lightmap_pars_fragment: string; + lights_lambert_vertex: string; + lights_pars_begin: string; + envmap_physical_pars_fragment: string; + lights_pars_map: string; + lights_phong_fragment: string; + lights_phong_pars_fragment: string; + lights_physical_fragment: string; + lights_physical_pars_fragment: string; + lights_fragment_begin: string; + lights_fragment_maps: string; + lights_fragment_end: string; + logdepthbuf_fragment: string; + logdepthbuf_pars_fragment: string; + logdepthbuf_pars_vertex: string; + logdepthbuf_vertex: string; + map_fragment: string; + map_pars_fragment: string; + map_particle_fragment: string; + map_particle_pars_fragment: string; + meshbasic_frag: string; + meshbasic_vert: string; + meshlambert_frag: string; + meshlambert_vert: string; + meshphong_frag: string; + meshphong_vert: string; + meshphysical_frag: string; + meshphysical_vert: string; + metalnessmap_fragment: string; + metalnessmap_pars_fragment: string; + morphnormal_vertex: string; + morphtarget_pars_vertex: string; + morphtarget_vertex: string; + normal_flip: string; + normal_frag: string; + normal_fragment_begin: string; + normal_fragment_maps: string; + normal_vert: string; + normalmap_pars_fragment: string; + clearcoat_normal_fragment_begin: string; + clearcoat_normal_fragment_maps: string; + clearcoat_pars_fragment: string; + packing: string; + points_frag: string; + points_vert: string; + shadow_frag: string; + shadow_vert: string; + + premultiplied_alpha_fragment: string; + project_vertex: string; + roughnessmap_fragment: string; + roughnessmap_pars_fragment: string; + shadowmap_pars_fragment: string; + shadowmap_pars_vertex: string; + shadowmap_vertex: string; + shadowmask_pars_fragment: string; + skinbase_vertex: string; + skinning_pars_vertex: string; + skinning_vertex: string; + skinnormal_vertex: string; + specularmap_fragment: string; + specularmap_pars_fragment: string; + tonemapping_fragment: string; + tonemapping_pars_fragment: string; + uv2_pars_fragment: string; + uv2_pars_vertex: string; + uv2_vertex: string; + uv_pars_fragment: string; + uv_pars_vertex: string; + uv_vertex: string; + worldpos_vertex: string; +}; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk.js b/backend/libs/three/renderers/shaders/ShaderChunk.js new file mode 100644 index 0000000000000000000000000000000000000000..90549ab0073774e78af10962944e3bd13c8b48b8 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk.js @@ -0,0 +1,257 @@ +import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js'; +import alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js'; +import alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js'; +import alphatest_pars_fragment from './ShaderChunk/alphatest_pars_fragment.glsl.js'; +import aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js'; +import aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js'; +import begin_vertex from './ShaderChunk/begin_vertex.glsl.js'; +import beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js'; +import bsdfs from './ShaderChunk/bsdfs.glsl.js'; +import bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js'; +import clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js'; +import clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js'; +import clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js'; +import clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js'; +import color_fragment from './ShaderChunk/color_fragment.glsl.js'; +import color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js'; +import color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js'; +import color_vertex from './ShaderChunk/color_vertex.glsl.js'; +import common from './ShaderChunk/common.glsl.js'; +import cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js'; +import defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js'; +import displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js'; +import displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js'; +import emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js'; +import emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js'; +import encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js'; +import encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js'; +import envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js'; +import envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js'; +import envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js'; +import envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js'; +import envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js'; +import fog_vertex from './ShaderChunk/fog_vertex.glsl.js'; +import fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js'; +import fog_fragment from './ShaderChunk/fog_fragment.glsl.js'; +import fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js'; +import gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js'; +import lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js'; +import lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js'; +import lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js'; +import lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js'; +import envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js'; +import lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js'; +import lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js'; +import lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js'; +import lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js'; +import lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js'; +import lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js'; +import lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js'; +import lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js'; +import lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js'; +import logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js'; +import logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js'; +import logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js'; +import logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js'; +import map_fragment from './ShaderChunk/map_fragment.glsl.js'; +import map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js'; +import map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js'; +import map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js'; +import metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js'; +import metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js'; +import morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js'; +import morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js'; +import morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js'; +import normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js'; +import normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js'; +import normal_pars_fragment from './ShaderChunk/normal_pars_fragment.glsl.js'; +import normal_pars_vertex from './ShaderChunk/normal_pars_vertex.glsl.js'; +import normal_vertex from './ShaderChunk/normal_vertex.glsl.js'; +import normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js'; +import clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js'; +import clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js'; +import clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js'; +import output_fragment from './ShaderChunk/output_fragment.glsl.js'; +import packing from './ShaderChunk/packing.glsl.js'; +import premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js'; +import project_vertex from './ShaderChunk/project_vertex.glsl.js'; +import dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js'; +import dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js'; +import roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js'; +import roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js'; +import shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js'; +import shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js'; +import shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js'; +import shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js'; +import skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js'; +import skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js'; +import skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js'; +import skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js'; +import specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js'; +import specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js'; +import tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js'; +import tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js'; +import transmission_fragment from './ShaderChunk/transmission_fragment.glsl.js'; +import transmission_pars_fragment from './ShaderChunk/transmission_pars_fragment.glsl.js'; +import uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js'; +import uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js'; +import uv_vertex from './ShaderChunk/uv_vertex.glsl.js'; +import uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js'; +import uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js'; +import uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js'; +import worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js'; + +import * as background from './ShaderLib/background.glsl.js'; +import * as cube from './ShaderLib/cube.glsl.js'; +import * as depth from './ShaderLib/depth.glsl.js'; +import * as distanceRGBA from './ShaderLib/distanceRGBA.glsl.js'; +import * as equirect from './ShaderLib/equirect.glsl.js'; +import * as linedashed from './ShaderLib/linedashed.glsl.js'; +import * as meshbasic from './ShaderLib/meshbasic.glsl.js'; +import * as meshlambert from './ShaderLib/meshlambert.glsl.js'; +import * as meshmatcap from './ShaderLib/meshmatcap.glsl.js'; +import * as meshnormal from './ShaderLib/meshnormal.glsl.js'; +import * as meshphong from './ShaderLib/meshphong.glsl.js'; +import * as meshphysical from './ShaderLib/meshphysical.glsl.js'; +import * as meshtoon from './ShaderLib/meshtoon.glsl.js'; +import * as points from './ShaderLib/points.glsl.js'; +import * as shadow from './ShaderLib/shadow.glsl.js'; +import * as sprite from './ShaderLib/sprite.glsl.js'; + +export const ShaderChunk = { + alphamap_fragment: alphamap_fragment, + alphamap_pars_fragment: alphamap_pars_fragment, + alphatest_fragment: alphatest_fragment, + alphatest_pars_fragment: alphatest_pars_fragment, + aomap_fragment: aomap_fragment, + aomap_pars_fragment: aomap_pars_fragment, + begin_vertex: begin_vertex, + beginnormal_vertex: beginnormal_vertex, + bsdfs: bsdfs, + bumpmap_pars_fragment: bumpmap_pars_fragment, + clipping_planes_fragment: clipping_planes_fragment, + clipping_planes_pars_fragment: clipping_planes_pars_fragment, + clipping_planes_pars_vertex: clipping_planes_pars_vertex, + clipping_planes_vertex: clipping_planes_vertex, + color_fragment: color_fragment, + color_pars_fragment: color_pars_fragment, + color_pars_vertex: color_pars_vertex, + color_vertex: color_vertex, + common: common, + cube_uv_reflection_fragment: cube_uv_reflection_fragment, + defaultnormal_vertex: defaultnormal_vertex, + displacementmap_pars_vertex: displacementmap_pars_vertex, + displacementmap_vertex: displacementmap_vertex, + emissivemap_fragment: emissivemap_fragment, + emissivemap_pars_fragment: emissivemap_pars_fragment, + encodings_fragment: encodings_fragment, + encodings_pars_fragment: encodings_pars_fragment, + envmap_fragment: envmap_fragment, + envmap_common_pars_fragment: envmap_common_pars_fragment, + envmap_pars_fragment: envmap_pars_fragment, + envmap_pars_vertex: envmap_pars_vertex, + envmap_physical_pars_fragment: envmap_physical_pars_fragment, + envmap_vertex: envmap_vertex, + fog_vertex: fog_vertex, + fog_pars_vertex: fog_pars_vertex, + fog_fragment: fog_fragment, + fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, + lightmap_fragment: lightmap_fragment, + lightmap_pars_fragment: lightmap_pars_fragment, + lights_lambert_vertex: lights_lambert_vertex, + lights_pars_begin: lights_pars_begin, + lights_toon_fragment: lights_toon_fragment, + lights_toon_pars_fragment: lights_toon_pars_fragment, + lights_phong_fragment: lights_phong_fragment, + lights_phong_pars_fragment: lights_phong_pars_fragment, + lights_physical_fragment: lights_physical_fragment, + lights_physical_pars_fragment: lights_physical_pars_fragment, + lights_fragment_begin: lights_fragment_begin, + lights_fragment_maps: lights_fragment_maps, + lights_fragment_end: lights_fragment_end, + logdepthbuf_fragment: logdepthbuf_fragment, + logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, + logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, + logdepthbuf_vertex: logdepthbuf_vertex, + map_fragment: map_fragment, + map_pars_fragment: map_pars_fragment, + map_particle_fragment: map_particle_fragment, + map_particle_pars_fragment: map_particle_pars_fragment, + metalnessmap_fragment: metalnessmap_fragment, + metalnessmap_pars_fragment: metalnessmap_pars_fragment, + morphnormal_vertex: morphnormal_vertex, + morphtarget_pars_vertex: morphtarget_pars_vertex, + morphtarget_vertex: morphtarget_vertex, + normal_fragment_begin: normal_fragment_begin, + normal_fragment_maps: normal_fragment_maps, + normal_pars_fragment: normal_pars_fragment, + normal_pars_vertex: normal_pars_vertex, + normal_vertex: normal_vertex, + normalmap_pars_fragment: normalmap_pars_fragment, + clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, + clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, + clearcoat_pars_fragment: clearcoat_pars_fragment, + output_fragment: output_fragment, + packing: packing, + premultiplied_alpha_fragment: premultiplied_alpha_fragment, + project_vertex: project_vertex, + dithering_fragment: dithering_fragment, + dithering_pars_fragment: dithering_pars_fragment, + roughnessmap_fragment: roughnessmap_fragment, + roughnessmap_pars_fragment: roughnessmap_pars_fragment, + shadowmap_pars_fragment: shadowmap_pars_fragment, + shadowmap_pars_vertex: shadowmap_pars_vertex, + shadowmap_vertex: shadowmap_vertex, + shadowmask_pars_fragment: shadowmask_pars_fragment, + skinbase_vertex: skinbase_vertex, + skinning_pars_vertex: skinning_pars_vertex, + skinning_vertex: skinning_vertex, + skinnormal_vertex: skinnormal_vertex, + specularmap_fragment: specularmap_fragment, + specularmap_pars_fragment: specularmap_pars_fragment, + tonemapping_fragment: tonemapping_fragment, + tonemapping_pars_fragment: tonemapping_pars_fragment, + transmission_fragment: transmission_fragment, + transmission_pars_fragment: transmission_pars_fragment, + uv_pars_fragment: uv_pars_fragment, + uv_pars_vertex: uv_pars_vertex, + uv_vertex: uv_vertex, + uv2_pars_fragment: uv2_pars_fragment, + uv2_pars_vertex: uv2_pars_vertex, + uv2_vertex: uv2_vertex, + worldpos_vertex: worldpos_vertex, + + background_vert: background.vertex, + background_frag: background.fragment, + cube_vert: cube.vertex, + cube_frag: cube.fragment, + depth_vert: depth.vertex, + depth_frag: depth.fragment, + distanceRGBA_vert: distanceRGBA.vertex, + distanceRGBA_frag: distanceRGBA.fragment, + equirect_vert: equirect.vertex, + equirect_frag: equirect.fragment, + linedashed_vert: linedashed.vertex, + linedashed_frag: linedashed.fragment, + meshbasic_vert: meshbasic.vertex, + meshbasic_frag: meshbasic.fragment, + meshlambert_vert: meshlambert.vertex, + meshlambert_frag: meshlambert.fragment, + meshmatcap_vert: meshmatcap.vertex, + meshmatcap_frag: meshmatcap.fragment, + meshnormal_vert: meshnormal.vertex, + meshnormal_frag: meshnormal.fragment, + meshphong_vert: meshphong.vertex, + meshphong_frag: meshphong.fragment, + meshphysical_vert: meshphysical.vertex, + meshphysical_frag: meshphysical.fragment, + meshtoon_vert: meshtoon.vertex, + meshtoon_frag: meshtoon.fragment, + points_vert: points.vertex, + points_frag: points.fragment, + shadow_vert: shadow.vertex, + shadow_frag: shadow.fragment, + sprite_vert: sprite.vertex, + sprite_frag: sprite.fragment, +}; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..276bb5976623b151f11f5192e8852b2a11b0e7b7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_ALPHAMAP + + diffuseColor.a *= texture2D( alphaMap, vUv ).g; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2610b87fcc5b87b0d067d4a82cd0458baa8a4aa0 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_ALPHAMAP + + uniform sampler2D alphaMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..cb1f05a59aad12a468321589b24736fba5606d3e --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_ALPHATEST + + if ( diffuseColor.a < alphaTest ) discard; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..bb531697d5be4f5c05b3b97a20ff9b8fc84cdcac --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js @@ -0,0 +1,5 @@ +export default /* glsl */ ` +#ifdef USE_ALPHATEST + uniform float alphaTest; +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..423fcd4f176fd1754af081369695c1744c99e8d3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js @@ -0,0 +1,18 @@ +export default /* glsl */ ` +#ifdef USE_AOMAP + + // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture + float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; + + reflectedLight.indirectDiffuse *= ambientOcclusion; + + #if defined( USE_ENVMAP ) && defined( STANDARD ) + + float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); + + reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..bb583aa7b42ff0ca5a83f73ceb8b1eae0fc9a733 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js @@ -0,0 +1,8 @@ +export default /* glsl */ ` +#ifdef USE_AOMAP + + uniform sampler2D aoMap; + uniform float aoMapIntensity; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/begin_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/begin_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..90c44e8b17363af71bdde9b3847e26749d2d9f24 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/begin_vertex.glsl.js @@ -0,0 +1,3 @@ +export default /* glsl */ ` +vec3 transformed = vec3( position ); +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..e0137676e001968d8f2672a73767e0675b3bdbab --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +vec3 objectNormal = vec3( normal ); + +#ifdef USE_TANGENT + + vec3 objectTangent = vec3( tangent.xyz ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/bsdfs.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/bsdfs.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..d01614aa8dc83768b1f30dda1d6679c4283df2d5 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/bsdfs.glsl.js @@ -0,0 +1,258 @@ +export default /* glsl */ ` + +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + + return RECIPROCAL_PI * diffuseColor; + +} // validated + +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + + // Original approximation by Christophe Schlick '94 + // float fresnel = pow( 1.0 - dotVH, 5.0 ); + + // Optimized variant (presented by Epic at SIGGRAPH '13) + // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); + +} // validated + +// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2 +// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + + float a2 = pow2( alpha ); + + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + + return 0.5 / max( gv + gl, EPSILON ); + +} + +// Microfacet Models for Refraction through Rough Surfaces - equation (33) +// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html +// alpha is "roughness squared" in Disney’s reparameterization +float D_GGX( const in float alpha, const in float dotNH ) { + + float a2 = pow2( alpha ); + + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1 + + return RECIPROCAL_PI * a2 / pow2( denom ); + +} + +// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) { + + float alpha = pow2( roughness ); // UE4's roughness + + vec3 halfDir = normalize( lightDir + viewDir ); + + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + + vec3 F = F_Schlick( f0, f90, dotVH ); + + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + + float D = D_GGX( alpha, dotNH ); + + return F * ( V * D ); + +} + +// Rect Area Light + +// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines +// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt +// code: https://github.com/selfshadow/ltc_code/ + +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + + float dotNV = saturate( dot( N, V ) ); + + // texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) ) + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + + uv = uv * LUT_SCALE + LUT_BIAS; + + return uv; + +} + +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + + // Real-Time Area Lighting: a Journey from Research to Production (p.102) + // An approximation of the form factor of a horizon-clipped rectangle. + + float l = length( f ); + + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); + +} + +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + + float x = dot( v1, v2 ); + + float y = abs( x ); + + // rational polynomial approximation to theta / sin( theta ) / 2PI + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + + return cross( v1, v2 ) * theta_sintheta; + +} + +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + + // bail if point is on back side of plane of light + // assumes ccw winding order of light vertices + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + + // construct orthonormal basis around N + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system + + // compute transform + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + + // transform rect + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + + // project rect onto sphere + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + + // calculate vector form factor + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + + // adjust for horizon clipping + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + +/* + // alternate method of adjusting for horizon clipping (see referece) + // refactoring required + float len = length( vectorFormFactor ); + float z = vectorFormFactor.z / len; + + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + + // tabulated horizon-clipped sphere, apparently... + vec2 uv = vec2( z * 0.5 + 0.5, len ); + uv = uv * LUT_SCALE + LUT_BIAS; + + float scale = texture2D( ltc_2, uv ).w; + + float result = len * scale; +*/ + + return vec3( result ); + +} + +// End Rect Area Light + + +float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) { + + // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v) + return 0.25; + +} + +float D_BlinnPhong( const in float shininess, const in float dotNH ) { + + return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); + +} + +vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { + + vec3 halfDir = normalize( lightDir + viewDir ); + + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + + vec3 F = F_Schlick( specularColor, 1.0, dotVH ); + + float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ ); + + float D = D_BlinnPhong( shininess, dotNH ); + + return F * ( G * D ); + +} // validated + +#if defined( USE_SHEEN ) + +// https://github.com/google/filament/blob/master/shaders/src/brdf.fs +float D_Charlie( float roughness, float dotNH ) { + + float alpha = pow2( roughness ); + + // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); // 2^(-14/2), so sin2h^2 > 0 in fp16 + + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); + +} + +// https://github.com/google/filament/blob/master/shaders/src/brdf.fs +float V_Neubelt( float dotNV, float dotNL ) { + + // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); + +} + +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + + vec3 halfDir = normalize( lightDir + viewDir ); + + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + + return sheenColor * ( D * V ); + +} + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a65e3b4f88e7af9ef664bacba5f6d402c50a14b6 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js @@ -0,0 +1,44 @@ +export default /* glsl */ ` +#ifdef USE_BUMPMAP + + uniform sampler2D bumpMap; + uniform float bumpScale; + + // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen + // https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf + + // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) + + vec2 dHdxy_fwd() { + + vec2 dSTdx = dFdx( vUv ); + vec2 dSTdy = dFdy( vUv ); + + float Hll = bumpScale * texture2D( bumpMap, vUv ).x; + float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; + float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; + + return vec2( dBx, dBy ); + + } + + vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { + + // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 + + vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); + vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); + vec3 vN = surf_norm; // normalized + + vec3 R1 = cross( vSigmaY, vN ); + vec3 R2 = cross( vN, vSigmaX ); + + float fDet = dot( vSigmaX, R1 ) * faceDirection; + + vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); + return normalize( abs( fDet ) * surf_norm - vGrad ); + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..32974385aa08b588f7014850e4fc9178e18c5f93 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_CLEARCOAT + + vec3 clearcoatNormal = geometryNormal; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3d5b03f5fc3f2275982ced32804bf38ef66a5b99 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js @@ -0,0 +1,18 @@ +export default /* glsl */ ` +#ifdef USE_CLEARCOAT_NORMALMAP + + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + + #ifdef USE_TANGENT + + clearcoatNormal = normalize( vTBN * clearcoatMapN ); + + #else + + clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2da930242888e48a27ff676ebfe7b7be09d31d02 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js @@ -0,0 +1,21 @@ +export default /* glsl */ ` + +#ifdef USE_CLEARCOATMAP + + uniform sampler2D clearcoatMap; + +#endif + +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + + uniform sampler2D clearcoatRoughnessMap; + +#endif + +#ifdef USE_CLEARCOAT_NORMALMAP + + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..fdd426a15269f39057a6c1b03690914eb209edbe --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js @@ -0,0 +1,33 @@ +export default /* glsl */ ` +#if NUM_CLIPPING_PLANES > 0 + + vec4 plane; + + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + + } + #pragma unroll_loop_end + + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + + bool clipped = true; + + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + + } + #pragma unroll_loop_end + + if ( clipped ) discard; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..ca5e143dc499e1457f7d38776a6ae8f3cbd7680c --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +#if NUM_CLIPPING_PLANES > 0 + + varying vec3 vClipPosition; + + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..b66a4d50da1f9f9538818c9ee9052c9c497bbc24 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if NUM_CLIPPING_PLANES > 0 + + varying vec3 vClipPosition; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..735f88c64a9deb8822e1a0be86a4ab43311b960e --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if NUM_CLIPPING_PLANES > 0 + + vClipPosition = - mvPosition.xyz; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/color_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/color_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..9bbb19793c9efe8a08098972691c6d955d5cbe74 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/color_fragment.glsl.js @@ -0,0 +1,11 @@ +export default /* glsl */ ` +#if defined( USE_COLOR_ALPHA ) + + diffuseColor *= vColor; + +#elif defined( USE_COLOR ) + + diffuseColor.rgb *= vColor; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2c86567d44aaa54f569bf9253e9c22a3bf26ed3d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js @@ -0,0 +1,11 @@ +export default /* glsl */ ` +#if defined( USE_COLOR_ALPHA ) + + varying vec4 vColor; + +#elif defined( USE_COLOR ) + + varying vec3 vColor; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..1b5dbe1172afdf71c1ac3cb705343ee7307fc4a0 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js @@ -0,0 +1,11 @@ +export default /* glsl */ ` +#if defined( USE_COLOR_ALPHA ) + + varying vec4 vColor; + +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + + varying vec3 vColor; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/color_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/color_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3911629eb5b2bf63f0b845cb61167f7d40ffd820 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/color_vertex.glsl.js @@ -0,0 +1,23 @@ +export default /* glsl */ ` +#if defined( USE_COLOR_ALPHA ) + + vColor = vec4( 1.0 ); + +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) + + vColor = vec3( 1.0 ); + +#endif + +#ifdef USE_COLOR + + vColor *= color; + +#endif + +#ifdef USE_INSTANCING_COLOR + + vColor.xyz *= instanceColor.xyz; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/common.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/common.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..35b1d11dd45c9adb7e754af5ae9959d16b6ad3db --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/common.glsl.js @@ -0,0 +1,116 @@ +export default /* glsl */ ` +#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 + +#ifndef saturate +// may have defined saturate() already +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) + +float pow2( const in float x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } + +// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range. +// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/ +highp float rand( const in vec2 uv ) { + + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + + return fract( sin( sn ) * c ); + +} + +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif + +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; + +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; + +struct GeometricContext { + vec3 position; + vec3 normal; + vec3 viewDir; +#ifdef USE_CLEARCOAT + vec3 clearcoatNormal; +#endif +}; + +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + +} + +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + + // dir can be either a direction vector or a normal vector + // upper-left 3x3 of matrix is assumed to be orthogonal + + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); + +} + +mat3 transposeMat3( const in mat3 m ) { + + mat3 tmp; + + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + + return tmp; + +} + +// https://en.wikipedia.org/wiki/Relative_luminance +float linearToRelativeLuminance( const in vec3 color ) { + + vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); + + return dot( weights, color.rgb ); + +} + +bool isPerspectiveMatrix( mat4 m ) { + + return m[ 2 ][ 3 ] == - 1.0; + +} + +vec2 equirectUv( in vec3 dir ) { + + // dir is assumed to be unit length + + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + + return vec2( u, v ); + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..6367d4a2a3e7490d8e0cbd761389a7eb7efcb9f5 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js @@ -0,0 +1,192 @@ +export default /* glsl */ ` +#ifdef ENVMAP_TYPE_CUBE_UV + + #define cubeUV_maxMipLevel 8.0 + #define cubeUV_minMipLevel 4.0 + #define cubeUV_maxTileSize 256.0 + #define cubeUV_minTileSize 16.0 + + // These shader functions convert between the UV coordinates of a single face of + // a cubemap, the 0-5 integer index of a cube face, and the direction vector for + // sampling a textureCube (not generally normalized ). + + float getFace( vec3 direction ) { + + vec3 absDirection = abs( direction ); + + float face = - 1.0; + + if ( absDirection.x > absDirection.z ) { + + if ( absDirection.x > absDirection.y ) + + face = direction.x > 0.0 ? 0.0 : 3.0; + + else + + face = direction.y > 0.0 ? 1.0 : 4.0; + + } else { + + if ( absDirection.z > absDirection.y ) + + face = direction.z > 0.0 ? 2.0 : 5.0; + + else + + face = direction.y > 0.0 ? 1.0 : 4.0; + + } + + return face; + + } + + // RH coordinate system; PMREM face-indexing convention + vec2 getUV( vec3 direction, float face ) { + + vec2 uv; + + if ( face == 0.0 ) { + + uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x + + } else if ( face == 1.0 ) { + + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y + + } else if ( face == 2.0 ) { + + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z + + } else if ( face == 3.0 ) { + + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x + + } else if ( face == 4.0 ) { + + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y + + } else { + + uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z + + } + + return 0.5 * ( uv + 1.0 ); + + } + + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + + float face = getFace( direction ); + + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + + mipInt = max( mipInt, cubeUV_minMipLevel ); + + float faceSize = exp2( mipInt ); + + float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize ); + + vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5; + + if ( face > 2.0 ) { + + uv.y += faceSize; + + face -= 3.0; + + } + + uv.x += face * faceSize; + + if ( mipInt < cubeUV_maxMipLevel ) { + + uv.y += 2.0 * cubeUV_maxTileSize; + + } + + uv.y += filterInt * 2.0 * cubeUV_minTileSize; + + uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize ); + + uv *= texelSize; + + return texture2D( envMap, uv ).rgb; + + } + + // These defines must match with PMREMGenerator + + #define r0 1.0 + #define v0 0.339 + #define m0 - 2.0 + #define r1 0.8 + #define v1 0.276 + #define m1 - 1.0 + #define r4 0.4 + #define v4 0.046 + #define m4 2.0 + #define r5 0.305 + #define v5 0.016 + #define m5 3.0 + #define r6 0.21 + #define v6 0.0038 + #define m6 4.0 + + float roughnessToMip( float roughness ) { + + float mip = 0.0; + + if ( roughness >= r1 ) { + + mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0; + + } else if ( roughness >= r4 ) { + + mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1; + + } else if ( roughness >= r5 ) { + + mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4; + + } else if ( roughness >= r6 ) { + + mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5; + + } else { + + mip = - 2.0 * log2( 1.16 * roughness ); // 1.16 = 1.79^0.25 + } + + return mip; + + } + + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + + float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel ); + + float mipF = fract( mip ); + + float mipInt = floor( mip ); + + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + + if ( mipF == 0.0 ) { + + return vec4( color0, 1.0 ); + + } else { + + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + + return vec4( mix( color0, color1, mipF ), 1.0 ); + + } + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/default_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/default_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..88bd741c5c60d0e61a0f3e5943974d4dd3480ff0 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/default_fragment.glsl.js @@ -0,0 +1,5 @@ +export default /* glsl */ ` +void main() { + gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/default_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/default_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0f3771e358f60dd9d92a29637265f399557830cb --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/default_vertex.glsl.js @@ -0,0 +1,5 @@ +export default /* glsl */ ` +void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..cea75dc3fba73c063ee8dd65af3a36b27557aa98 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js @@ -0,0 +1,36 @@ +export default /* glsl */ ` +vec3 transformedNormal = objectNormal; + +#ifdef USE_INSTANCING + + // this is in lieu of a per-instance normal-matrix + // shear transforms in the instance matrix are not supported + + mat3 m = mat3( instanceMatrix ); + + transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); + + transformedNormal = m * transformedNormal; + +#endif + +transformedNormal = normalMatrix * transformedNormal; + +#ifdef FLIP_SIDED + + transformedNormal = - transformedNormal; + +#endif + +#ifdef USE_TANGENT + + vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; + + #ifdef FLIP_SIDED + + transformedTangent = - transformedTangent; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..fae86f6b126e8c5c3cc5873955ad448bb32f5c49 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +#ifdef USE_DISPLACEMENTMAP + + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..c5ab08c8533bf90d6812cabb8c78c272b9e74322 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_DISPLACEMENTMAP + + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a8f040a0535fbb99b17b8667e2a7ff1fcef8493d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef DITHERING + + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0ad80a439963ac661af8a37e944faaad358b23b5 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js @@ -0,0 +1,20 @@ +export default /* glsl */ ` +#ifdef DITHERING + + // based on https://www.shadertoy.com/view/MslGR8 + vec3 dithering( vec3 color ) { + //Calculate grid position + float grid_position = rand( gl_FragCoord.xy ); + + //Shift the individual colors differently, thus making it even harder to see the dithering pattern + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + + //modify shift acording to grid position. + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + + //shift the color by dither_shift + return color + dither_shift_RGB; + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..71b8eb57d9c9c537b9cf853476801c6d6dcf3596 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +#ifdef USE_EMISSIVEMAP + + vec4 emissiveColor = texture2D( emissiveMap, vUv ); + + totalEmissiveRadiance *= emissiveColor.rgb; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..425338269ad9db77479c481a3408af53f6111d6c --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_EMISSIVEMAP + + uniform sampler2D emissiveMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..10b1ca3929808fab8356382220d6105e935de043 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js @@ -0,0 +1,3 @@ +export default /* glsl */ ` +gl_FragColor = linearToOutputTexel( gl_FragColor ); +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..ddecff550f77a025795e1a39d35410d1ba106bf7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js @@ -0,0 +1,11 @@ +export default /* glsl */ ` + +vec4 LinearToLinear( in vec4 value ) { + return value; +} + +vec4 LinearTosRGB( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +} + +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..e00f79cca921c0a9ce920af2192d2c22be8fe3b3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js @@ -0,0 +1,14 @@ +export default /* glsl */ ` +#ifdef USE_ENVMAP + + uniform float envMapIntensity; + uniform float flipEnvMap; + + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..b5861f03993e8b2b465330cc45742adb8833f591 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js @@ -0,0 +1,66 @@ +export default /* glsl */ ` +#ifdef USE_ENVMAP + + #ifdef ENV_WORLDPOS + + vec3 cameraToFrag; + + if ( isOrthographic ) { + + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + + } else { + + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + + } + + // Transforming Normal Vectors with the Inverse Transformation + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + + #ifdef ENVMAP_MODE_REFLECTION + + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + + #else + + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + + #endif + + #else + + vec3 reflectVec = vReflect; + + #endif + + #ifdef ENVMAP_TYPE_CUBE + + vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + + #elif defined( ENVMAP_TYPE_CUBE_UV ) + + vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 ); + + #else + + vec4 envColor = vec4( 0.0 ); + + #endif + + #ifdef ENVMAP_BLENDING_MULTIPLY + + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + + #elif defined( ENVMAP_BLENDING_MIX ) + + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + + #elif defined( ENVMAP_BLENDING_ADD ) + + outgoingLight += envColor.xyz * specularStrength * reflectivity; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..b64703c594fd18655f6d8c626f0b65558e6f1cf3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js @@ -0,0 +1,21 @@ +export default /* glsl */ ` +#ifdef USE_ENVMAP + + uniform float reflectivity; + + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) + + #define ENV_WORLDPOS + + #endif + + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0e8d28e78e4c7ef5ad13a93467632fd42b8790a1 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js @@ -0,0 +1,22 @@ +export default /* glsl */ ` +#ifdef USE_ENVMAP + + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG ) + + #define ENV_WORLDPOS + + #endif + + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + + #else + + varying vec3 vReflect; + uniform float refractionRatio; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..1147c52023fb37e3d1cb1aa6983e12db75e0b352 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js @@ -0,0 +1,62 @@ +export default /* glsl */ ` +#if defined( USE_ENVMAP ) + + #ifdef ENVMAP_MODE_REFRACTION + + uniform float refractionRatio; + + #endif + + vec3 getIBLIrradiance( const in vec3 normal ) { + + #if defined( ENVMAP_TYPE_CUBE_UV ) + + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + + vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); + + return PI * envMapColor.rgb * envMapIntensity; + + #else + + return vec3( 0.0 ); + + #endif + + } + + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + + #if defined( ENVMAP_TYPE_CUBE_UV ) + + vec3 reflectVec; + + #ifdef ENVMAP_MODE_REFLECTION + + reflectVec = reflect( - viewDir, normal ); + + // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane. + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + + #else + + reflectVec = refract( - viewDir, normal, refractionRatio ); + + #endif + + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + + vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); + + return envMapColor.rgb * envMapIntensity; + + #else + + return vec3( 0.0 ); + + #endif + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a3035867e05e6ebc3299ef2fa6963afd46f9ca17 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js @@ -0,0 +1,37 @@ +export default /* glsl */ ` +#ifdef USE_ENVMAP + + #ifdef ENV_WORLDPOS + + vWorldPosition = worldPosition.xyz; + + #else + + vec3 cameraToVertex; + + if ( isOrthographic ) { + + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + + } else { + + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + + } + + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + + #ifdef ENVMAP_MODE_REFLECTION + + vReflect = reflect( cameraToVertex, worldNormal ); + + #else + + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + + #endif + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/fog_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/fog_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..565d54506698d19fdd314480b283b9f93afebf08 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/fog_fragment.glsl.js @@ -0,0 +1,17 @@ +export default /* glsl */ ` +#ifdef USE_FOG + + #ifdef FOG_EXP2 + + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + + #else + + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + + #endif + + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2d2ca0f3e3d4e14457aaf2754afe5d850d9173ab --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js @@ -0,0 +1,19 @@ +export default /* glsl */ ` +#ifdef USE_FOG + + uniform vec3 fogColor; + varying float vFogDepth; + + #ifdef FOG_EXP2 + + uniform float fogDensity; + + #else + + uniform float fogNear; + uniform float fogFar; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..40d3a71adb087033883a8b6d39cf26cb1e59b991 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_FOG + + varying float vFogDepth; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/fog_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/fog_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..d9a6ed50a4de3836d2547a2fdef2b05b47103909 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/fog_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_FOG + + vFogDepth = - mvPosition.z; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..5bc0d128302eb6e1b0106a7ec087705e57f90923 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js @@ -0,0 +1,26 @@ +export default /* glsl */ ` + +#ifdef USE_GRADIENTMAP + + uniform sampler2D gradientMap; + +#endif + +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + + // dotNL will be from -1.0 to 1.0 + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + + #ifdef USE_GRADIENTMAP + + return vec3( texture2D( gradientMap, coord ).r ); + + #else + + return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); + + #endif + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..b56fe02901c3d25a4883074f829cd120cf136e2e --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js @@ -0,0 +1,16 @@ +export default /* glsl */ ` +#ifdef USE_LIGHTMAP + + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + + #ifndef PHYSICALLY_CORRECT_LIGHTS + + lightMapIrradiance *= PI; + + #endif + + reflectedLight.indirectDiffuse += lightMapIrradiance; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..bc1705fd2ecf991ee1985f1b12d5d54144de1848 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js @@ -0,0 +1,8 @@ +export default /* glsl */ ` +#ifdef USE_LIGHTMAP + + uniform sampler2D lightMap; + uniform float lightMapIntensity; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..42f65dd382fecbbab000c291bf9b05469efe4cf1 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js @@ -0,0 +1,152 @@ +export default /* glsl */ ` +/** + * This is a template that can be used to light a material, it uses pluggable + * RenderEquations (RE)for specific lighting scenarios. + * + * Instructions for use: + * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined + * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ??? + * - Create a material parameter that is to be passed as the third parameter to your lighting functions. + * + * TODO: + * - Add area light support. + * - Add sphere light support. + * - Add diffuse light probe (irradiance cubemap) support. + */ + +GeometricContext geometry; + +geometry.position = - vViewPosition; +geometry.normal = normal; +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); + +#ifdef USE_CLEARCOAT + + geometry.clearcoatNormal = clearcoatNormal; + +#endif + +IncidentLight directLight; + +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + + pointLight = pointLights[ i ]; + + getPointLightInfo( pointLight, geometry, directLight ); + + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + + RE_Direct( directLight, geometry, material, reflectedLight ); + + } + #pragma unroll_loop_end + +#endif + +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + + SpotLight spotLight; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + + spotLight = spotLights[ i ]; + + getSpotLightInfo( spotLight, geometry, directLight ); + + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + #endif + + RE_Direct( directLight, geometry, material, reflectedLight ); + + } + #pragma unroll_loop_end + +#endif + +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + + directionalLight = directionalLights[ i ]; + + getDirectionalLightInfo( directionalLight, geometry, directLight ); + + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + + RE_Direct( directLight, geometry, material, reflectedLight ); + + } + #pragma unroll_loop_end + +#endif + +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + + RectAreaLight rectAreaLight; + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); + + } + #pragma unroll_loop_end + +#endif + +#if defined( RE_IndirectDiffuse ) + + vec3 iblIrradiance = vec3( 0.0 ); + + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + + irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); + + #if ( NUM_HEMI_LIGHTS > 0 ) + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + + } + #pragma unroll_loop_end + + #endif + +#endif + +#if defined( RE_IndirectSpecular ) + + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..74810527f3382b2d38e7d8d439ca8b660ae1ddc1 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js @@ -0,0 +1,13 @@ +export default /* glsl */ ` +#if defined( RE_IndirectDiffuse ) + + RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); + +#endif + +#if defined( RE_IndirectSpecular ) + + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..74fc86a4fdfee39498a5130210d132db1035fefc --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js @@ -0,0 +1,38 @@ +export default /* glsl */ ` +#if defined( RE_IndirectDiffuse ) + + #ifdef USE_LIGHTMAP + + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + + #ifndef PHYSICALLY_CORRECT_LIGHTS + + lightMapIrradiance *= PI; + + #endif + + irradiance += lightMapIrradiance; + + #endif + + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + + iblIrradiance += getIBLIrradiance( geometry.normal ); + + #endif + +#endif + +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + + radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); + + #ifdef USE_CLEARCOAT + + clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..4161740f62f3589c125ac1e8cfd9d1dbdfb07310 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js @@ -0,0 +1,122 @@ +export default /* glsl */ ` +vec3 diffuse = vec3( 1.0 ); + +GeometricContext geometry; +geometry.position = mvPosition.xyz; +geometry.normal = normalize( transformedNormal ); +geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz ); + +GeometricContext backGeometry; +backGeometry.position = geometry.position; +backGeometry.normal = -geometry.normal; +backGeometry.viewDir = geometry.viewDir; + +vLightFront = vec3( 0.0 ); +vIndirectFront = vec3( 0.0 ); +#ifdef DOUBLE_SIDED + vLightBack = vec3( 0.0 ); + vIndirectBack = vec3( 0.0 ); +#endif + +IncidentLight directLight; +float dotNL; +vec3 directLightColor_Diffuse; + +vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); + +vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal ); + +#ifdef DOUBLE_SIDED + + vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); + + vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal ); + +#endif + +#if NUM_POINT_LIGHTS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + + getPointLightInfo( pointLights[ i ], geometry, directLight ); + + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + + #ifdef DOUBLE_SIDED + + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + + #endif + + } + #pragma unroll_loop_end + +#endif + +#if NUM_SPOT_LIGHTS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + + getSpotLightInfo( spotLights[ i ], geometry, directLight ); + + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + + #ifdef DOUBLE_SIDED + + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + + #endif + } + #pragma unroll_loop_end + +#endif + +#if NUM_DIR_LIGHTS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + + getDirectionalLightInfo( directionalLights[ i ], geometry, directLight ); + + dotNL = dot( geometry.normal, directLight.direction ); + directLightColor_Diffuse = directLight.color; + + vLightFront += saturate( dotNL ) * directLightColor_Diffuse; + + #ifdef DOUBLE_SIDED + + vLightBack += saturate( - dotNL ) * directLightColor_Diffuse; + + #endif + + } + #pragma unroll_loop_end + +#endif + +#if NUM_HEMI_LIGHTS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + + vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); + + #ifdef DOUBLE_SIDED + + vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal ); + + #endif + + } + #pragma unroll_loop_end + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0c7110a9a86e413447c4e6de742c5acf95bf4e6a --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js @@ -0,0 +1,223 @@ +export default /* glsl */ ` +uniform bool receiveShadow; +uniform vec3 ambientLightColor; +uniform vec3 lightProbe[ 9 ]; + +// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere +// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + + // normal is assumed to have unit length + + float x = normal.x, y = normal.y, z = normal.z; + + // band 0 + vec3 result = shCoefficients[ 0 ] * 0.886227; + + // band 1 + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + + // band 2 + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + + return result; + +} + +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + + return irradiance; + +} + +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + + vec3 irradiance = ambientLightColor; + + return irradiance; + +} + +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + + #if defined ( PHYSICALLY_CORRECT_LIGHTS ) + + // based upon Frostbite 3 Moving to Physically-based Rendering + // page 32, equation 26: E[window1] + // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + + if ( cutoffDistance > 0.0 ) { + + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + + } + + return distanceFalloff; + + #else + + if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { + + return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); + + } + + return 1.0; + + #endif + +} + +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + + return smoothstep( coneCosine, penumbraCosine, angleCosine ); + +} + +#if NUM_DIR_LIGHTS > 0 + + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + + void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { + + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + + } + +#endif + + +#if NUM_POINT_LIGHTS > 0 + + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + + // light is an out parameter as having it as a return value caused compiler errors on some devices + void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { + + vec3 lVector = pointLight.position - geometry.position; + + light.direction = normalize( lVector ); + + float lightDistance = length( lVector ); + + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + + } + +#endif + + +#if NUM_SPOT_LIGHTS > 0 + + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + + // light is an out parameter as having it as a return value caused compiler errors on some devices + void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { + + vec3 lVector = spotLight.position - geometry.position; + + light.direction = normalize( lVector ); + + float angleCos = dot( light.direction, spotLight.direction ); + + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + + if ( spotAttenuation > 0.0 ) { + + float lightDistance = length( lVector ); + + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + + } else { + + light.color = vec3( 0.0 ); + light.visible = false; + + } + + } + +#endif + + +#if NUM_RECT_AREA_LIGHTS > 0 + + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + + // Pre-computed values of LinearTransformedCosine approximation of BRDF + // BRDF approximation Texture is 64x64 + uniform sampler2D ltc_1; // RGBA Float + uniform sampler2D ltc_2; // RGBA Float + + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; + +#endif + + +#if NUM_HEMI_LIGHTS > 0 + + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + + return irradiance; + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..68644d09018d859cebbcf41718d10afb941a3d85 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength; +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..9852bfd6d198ede93a297e1e3df3ee35a775d82c --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js @@ -0,0 +1,34 @@ +export default /* glsl */ ` +varying vec3 vViewPosition; + +struct BlinnPhongMaterial { + + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; + +}; + +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; + +} + +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + +} + +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong + +#define Material_LightProbeLOD( material ) (0) +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..5eea982e047e6fe68558bda75c0633777f40387b --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js @@ -0,0 +1,95 @@ +export default /* glsl */ ` +PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); + +vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); + +material.roughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap. +material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); + +#ifdef IOR + + #ifdef SPECULAR + + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + + #ifdef USE_SPECULARINTENSITYMAP + + specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; + + #endif + + #ifdef USE_SPECULARCOLORMAP + + specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; + + #endif + + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + + #else + + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + + #endif + + material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); + +#else + + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; + +#endif + +#ifdef USE_CLEARCOAT + + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + + #ifdef USE_CLEARCOATMAP + + material.clearcoat *= texture2D( clearcoatMap, vUv ).x; + + #endif + + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; + + #endif + + material.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model + material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); + +#endif + +#ifdef USE_SHEEN + + material.sheenColor = sheenColor; + + #ifdef USE_SHEENCOLORMAP + + material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; + + #endif + + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + + #ifdef USE_SHEENROUGHNESSMAP + + material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..009a82a28db813de7c4e494f5ddb6f7bf5ba5188 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js @@ -0,0 +1,214 @@ +export default /* glsl */ ` +struct PhysicalMaterial { + + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + +}; + +// temporary +vec3 clearcoatSpecular = vec3( 0.0 ); +vec3 sheenSpecular = vec3( 0.0 ); + +// This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from +// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found +// in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) { + + float dotNV = saturate( dot( normal, viewDir ) ); + + float r2 = roughness * roughness; + + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + + return saturate( DG * RECIPROCAL_PI ); + +} + +// Analytical approximation of the DFG LUT, one half of the +// split-sum approximation used in indirect specular lighting. +// via 'environmentBRDF' from "Physically Based Shading on Mobile" +// https://www.unrealengine.com/blog/physically-based-shading-on-mobile +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + + float dotNV = saturate( dot( normal, viewDir ) ); + + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + + vec4 r = roughness * c0 + c1; + + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + + return fab; + +} + +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + + vec2 fab = DFGApprox( normal, viewDir, roughness ); + + return specularColor * fab.x + specularF90 * fab.y; + +} + +// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting" +// Approximates multiscattering in order to preserve energy. +// http://www.jcgt.org/published/0008/01/03/ +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { + + vec2 fab = DFGApprox( normal, viewDir, roughness ); + + vec3 FssEss = specularColor * fab.x + specularF90 * fab.y; + + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + + vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21 + vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + + singleScatter += FssEss; + multiScatter += Fms * Ems; + +} + +#if NUM_RECT_AREA_LIGHTS > 0 + + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + + vec3 normal = geometry.normal; + vec3 viewDir = geometry.viewDir; + vec3 position = geometry.position; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction + rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + + // LTC Fresnel Approximation by Stephen Hill + // http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + + } + +#endif + +void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + + vec3 irradiance = dotNL * directLight.color; + + #ifdef USE_CLEARCOAT + + float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); + + vec3 ccIrradiance = dotNLcc * directLight.color; + + clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + + #endif + + #ifdef USE_SHEEN + + sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); + + #endif + + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); + + + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} + +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + +} + +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + + #ifdef USE_CLEARCOAT + + clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + + #endif + + #ifdef USE_SHEEN + + sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); + + #endif + + // Both indirect specular and indirect diffuse light accumulate here + + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + + computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + + vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ); + + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; + +} + +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical + +// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..adbe4641777d822d9e5e9942119f9737d4f63923 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js @@ -0,0 +1,4 @@ +export default /* glsl */ ` +ToonMaterial material; +material.diffuseColor = diffuseColor.rgb; +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..c22df3945f1799b6bbb509ba6c496f252fbfdc72 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js @@ -0,0 +1,28 @@ +export default /* glsl */ ` +varying vec3 vViewPosition; + +struct ToonMaterial { + + vec3 diffuseColor; + +}; + +void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + +} + +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + +} + +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon + +#define Material_LightProbeLOD( material ) (0) +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..472f122c6dd7e7497562c24cdb93f454ff75150e --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + + // Doing a strict comparison with == 1.0 can cause noise artifacts + // on some platforms. See issue #17623. + gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0b5ae678e120bd5f64e0cca13e8666baef5b13c3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js @@ -0,0 +1,9 @@ +export default /* glsl */ ` +#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) + + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..90f365673dafbe4e04da598dff5a2b429372673b --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js @@ -0,0 +1,16 @@ +export default /* glsl */ ` +#ifdef USE_LOGDEPTHBUF + + #ifdef USE_LOGDEPTHBUF_EXT + + varying float vFragDepth; + varying float vIsPerspective; + + #else + + uniform float logDepthBufFC; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..891d20935966e765f86af1b6238977db10327477 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js @@ -0,0 +1,22 @@ +export default /* glsl */ ` +#ifdef USE_LOGDEPTHBUF + + #ifdef USE_LOGDEPTHBUF_EXT + + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); + + #else + + if ( isPerspectiveMatrix( projectionMatrix ) ) { + + gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; + + gl_Position.z *= gl_Position.w; + + } + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/map_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/map_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..02b8e6f3528fd84f770d6ffb65213add81900034 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/map_fragment.glsl.js @@ -0,0 +1,17 @@ +export default /* glsl */ ` +#ifdef USE_MAP + + vec4 sampledDiffuseColor = texture2D( map, vUv ); + + #ifdef DECODE_VIDEO_TEXTURE + + // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved) + + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + + diffuseColor *= sampledDiffuseColor; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..49cc6f5797cd88cf98c61bbb12936cd1e657edf7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_MAP + + uniform sampler2D map; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..48882da10de980c67c03c83d00492497c5982f17 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js @@ -0,0 +1,19 @@ +export default /* glsl */ ` +#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + +#endif + +#ifdef USE_MAP + + diffuseColor *= texture2D( map, uv ); + +#endif + +#ifdef USE_ALPHAMAP + + diffuseColor.a *= texture2D( alphaMap, uv ).g; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..eabdbcf88fa9d8d945d7b38f72beac33fce45786 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js @@ -0,0 +1,19 @@ +export default /* glsl */ ` +#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + + uniform mat3 uvTransform; + +#endif + +#ifdef USE_MAP + + uniform sampler2D map; + +#endif + +#ifdef USE_ALPHAMAP + + uniform sampler2D alphaMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..7d2b81dcd457b91405c799f870dfbe64983cfac3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js @@ -0,0 +1,12 @@ +export default /* glsl */ ` +float metalnessFactor = metalness; + +#ifdef USE_METALNESSMAP + + vec4 texelMetalness = texture2D( metalnessMap, vUv ); + + // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture + metalnessFactor *= texelMetalness.b; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..5f235f74ddcae7f5fa90b9b85bbb4abe5af71360 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_METALNESSMAP + + uniform sampler2D metalnessMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..23e75c7bcd5850e5931937487f2a9d4de12c4cf8 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js @@ -0,0 +1,27 @@ +export default /* glsl */ ` +#ifdef USE_MORPHNORMALS + + // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value: + // When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence) + // When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting + objectNormal *= morphTargetBaseInfluence; + + #ifdef MORPHTARGETS_TEXTURE + + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + + if ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ]; + + } + + #else + + objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; + objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; + objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; + objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3d07f689d72c93fe4b96b9c566888ee0c3e803d7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js @@ -0,0 +1,38 @@ +export default /* glsl */ ` +#ifdef USE_MORPHTARGETS + + uniform float morphTargetBaseInfluence; + + #ifdef MORPHTARGETS_TEXTURE + + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + uniform sampler2DArray morphTargetsTexture; + uniform vec2 morphTargetsTextureSize; + + vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) { + + float texelIndex = float( vertexIndex * stride + offset ); + float y = floor( texelIndex / morphTargetsTextureSize.x ); + float x = texelIndex - y * morphTargetsTextureSize.x; + + vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex ); + return texture( morphTargetsTexture, morphUV ).xyz; + + } + + #else + + #ifndef USE_MORPHNORMALS + + uniform float morphTargetInfluences[ 8 ]; + + #else + + uniform float morphTargetInfluences[ 4 ]; + + #endif + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..146e0e801a1cdf4206688d23bdd8a0d3e38ca76d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js @@ -0,0 +1,44 @@ +export default /* glsl */ ` +#ifdef USE_MORPHTARGETS + + // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value: + // When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence) + // When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting + transformed *= morphTargetBaseInfluence; + + #ifdef MORPHTARGETS_TEXTURE + + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + + #ifndef USE_MORPHNORMALS + + if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ]; + + #else + + if ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ]; + + #endif + + } + + #else + + transformed += morphTarget0 * morphTargetInfluences[ 0 ]; + transformed += morphTarget1 * morphTargetInfluences[ 1 ]; + transformed += morphTarget2 * morphTargetInfluences[ 2 ]; + transformed += morphTarget3 * morphTargetInfluences[ 3 ]; + + #ifndef USE_MORPHNORMALS + + transformed += morphTarget4 * morphTargetInfluences[ 4 ]; + transformed += morphTarget5 * morphTargetInfluences[ 5 ]; + transformed += morphTarget6 * morphTargetInfluences[ 6 ]; + transformed += morphTarget7 * morphTargetInfluences[ 7 ]; + + #endif + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..e7cb2c4ee8d49cb73ddf4e6d7951cbc52238044b --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js @@ -0,0 +1,48 @@ +export default /* glsl */ ` +float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; + +#ifdef FLAT_SHADED + + // Workaround for Adreno GPUs not able to do dFdx( vViewPosition ) + + vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); + vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); + vec3 normal = normalize( cross( fdx, fdy ) ); + +#else + + vec3 normal = normalize( vNormal ); + + #ifdef DOUBLE_SIDED + + normal = normal * faceDirection; + + #endif + + #ifdef USE_TANGENT + + vec3 tangent = normalize( vTangent ); + vec3 bitangent = normalize( vBitangent ); + + #ifdef DOUBLE_SIDED + + tangent = tangent * faceDirection; + bitangent = bitangent * faceDirection; + + #endif + + #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) + + mat3 vTBN = mat3( tangent, bitangent, normal ); + + #endif + + #endif + +#endif + +// non perturbed normal for clearcoat among others + +vec3 geometryNormal = normal; + +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..df5c1524c2251b156e0b1be0c49f1922762c03dd --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js @@ -0,0 +1,41 @@ +export default /* glsl */ ` + +#ifdef OBJECTSPACE_NORMALMAP + + normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals + + #ifdef FLIP_SIDED + + normal = - normal; + + #endif + + #ifdef DOUBLE_SIDED + + normal = normal * faceDirection; + + #endif + + normal = normalize( normalMatrix * normal ); + +#elif defined( TANGENTSPACE_NORMALMAP ) + + vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + + #ifdef USE_TANGENT + + normal = normalize( vTBN * mapN ); + + #else + + normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); + + #endif + +#elif defined( USE_BUMPMAP ) + + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..657072d29522721e80c4ed79032420878177376f --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js @@ -0,0 +1,14 @@ +export default /* glsl */ ` +#ifndef FLAT_SHADED + + varying vec3 vNormal; + + #ifdef USE_TANGENT + + varying vec3 vTangent; + varying vec3 vBitangent; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..657072d29522721e80c4ed79032420878177376f --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js @@ -0,0 +1,14 @@ +export default /* glsl */ ` +#ifndef FLAT_SHADED + + varying vec3 vNormal; + + #ifdef USE_TANGENT + + varying vec3 vTangent; + varying vec3 vBitangent; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normal_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normal_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..18ece807f024839c44b53e9bc088a446a55a9fb1 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normal_vertex.glsl.js @@ -0,0 +1,14 @@ +export default /* glsl */ ` +#ifndef FLAT_SHADED // normal is computed with derivatives when FLAT_SHADED + + vNormal = normalize( transformedNormal ); + + #ifdef USE_TANGENT + + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..9b9a0e3fc83b808f8105ba5b79a3ee8221ea408f --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js @@ -0,0 +1,45 @@ +export default /* glsl */ ` +#ifdef USE_NORMALMAP + + uniform sampler2D normalMap; + uniform vec2 normalScale; + +#endif + +#ifdef OBJECTSPACE_NORMALMAP + + uniform mat3 normalMatrix; + +#endif + +#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) + + // Normal Mapping Without Precomputed Tangents + // http://www.thetenthplanet.de/archives/1180 + + vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { + + // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 + + vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); + vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); + vec2 st0 = dFdx( vUv.st ); + vec2 st1 = dFdy( vUv.st ); + + vec3 N = surf_norm; // normalized + + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); + + return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/output_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/output_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..d03599afd31c7100cd79d32499ab3802dc7e9feb --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/output_fragment.glsl.js @@ -0,0 +1,12 @@ +export default /* glsl */ ` +#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif + +// https://github.com/mrdoob/three.js/pull/22425 +#ifdef USE_TRANSMISSION +diffuseColor.a *= transmissionAlpha + 0.1; +#endif + +gl_FragColor = vec4( outgoingLight, diffuseColor.a ); +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/packing.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/packing.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0c77840870ba539e691b63124f850b8091acc008 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/packing.glsl.js @@ -0,0 +1,54 @@ +export default /* glsl */ ` +vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} + +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} + +const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1) +const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1) + +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); + +const float ShiftRight8 = 1. / 256.; + +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; // tidy overflow + return r * PackUpscale; +} + +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} + +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} + +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} + +// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions + +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { + return linearClipZ * ( near - far ) - near; +} + +// NOTE: https://twitter.com/gonnavis/status/1377183786949959682 + +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * invClipZ - far ); +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0e31b5c286579dac918a4e32fb403f4f33b01666 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js @@ -0,0 +1,8 @@ +export default /* glsl */ ` +#ifdef PREMULTIPLIED_ALPHA + + // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation. + gl_FragColor.rgb *= gl_FragColor.a; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/project_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/project_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..1d706206e615ae141b258d36bfdf6eb4ea716a79 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/project_vertex.glsl.js @@ -0,0 +1,13 @@ +export default /* glsl */ ` +vec4 mvPosition = vec4( transformed, 1.0 ); + +#ifdef USE_INSTANCING + + mvPosition = instanceMatrix * mvPosition; + +#endif + +mvPosition = modelViewMatrix * mvPosition; + +gl_Position = projectionMatrix * mvPosition; +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..afbd573a4ab122853666fdf4078dbcf9799c0eef --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js @@ -0,0 +1,12 @@ +export default /* glsl */ ` +float roughnessFactor = roughness; + +#ifdef USE_ROUGHNESSMAP + + vec4 texelRoughness = texture2D( roughnessMap, vUv ); + + // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture + roughnessFactor *= texelRoughness.g; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..315a806d0e4176a5c957b8f7fa40dc937b129d23 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_ROUGHNESSMAP + + uniform sampler2D roughnessMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3f630f932079d73ce6e0aa454c006c710ca6ef9d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js @@ -0,0 +1,310 @@ +export default /* glsl */ ` +#ifdef USE_SHADOWMAP + + #if NUM_DIR_LIGHT_SHADOWS > 0 + + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + + #endif + + #if NUM_SPOT_LIGHT_SHADOWS > 0 + + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; + + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + + #endif + + #if NUM_POINT_LIGHT_SHADOWS > 0 + + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + + #endif + + /* + #if NUM_RECT_AREA_LIGHTS > 0 + + // TODO (abelnation): create uniforms for area light shadows + + #endif + */ + + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + + } + + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + + } + + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + + float occlusion = 1.0; + + vec2 distribution = texture2DDistribution( shadow, uv ); + + float hard_shadow = step( compare , distribution.x ); // Hard Shadow + + if (hard_shadow != 1.0 ) { + + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality + softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed + occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + + } + return occlusion; + + } + + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + + float shadow = 1.0; + + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + + // if ( something && something ) breaks ATI OpenGL shader compiler + // if ( all( something, something ) ) using this instead + + bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); + bool inFrustum = all( inFrustumVec ); + + bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); + + bool frustumTest = all( frustumTestVec ); + + if ( frustumTest ) { + + #if defined( SHADOWMAP_TYPE_PCF ) + + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + + #elif defined( SHADOWMAP_TYPE_VSM ) + + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + + #else // no percentage-closer filtering: + + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + + #endif + + } + + return shadow; + + } + + // cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D + // vector suitable for 2D texture mapping. This code uses the following layout for the + // 2D texture: + // + // xzXZ + // y Y + // + // Y - Positive y direction + // y - Negative y direction + // X - Positive x direction + // x - Negative x direction + // Z - Positive z direction + // z - Negative z direction + // + // Source and test bed: + // https://gist.github.com/tschw/da10c43c467ce8afd0c4 + + vec2 cubeToUV( vec3 v, float texelSizeY ) { + + // Number of texels to avoid at the edge of each square + + vec3 absV = abs( v ); + + // Intersect unit cube + + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + + // Apply scale to avoid seams + + // two texels less per square (one texel will do for NEAREST) + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + + // Unwrap + + // space: -1 ... 1 range for each square + // + // #X## dim := ( 4 , 2 ) + // # # center := ( 1 , 1 ) + + vec2 planar = v.xy; + + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + + if ( absV.z >= almostOne ) { + + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + + } else if ( absV.x >= almostOne ) { + + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + + } else if ( absV.y >= almostOne ) { + + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + + } + + // Transform to UV space + + // scale := 0.5 / dim + // translate := ( center + 0.5 ) / dim + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + + } + + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + + // for point lights, the uniform @vShadowCoord is re-purposed to hold + // the vector from the light to the world-space position of the fragment. + vec3 lightToPosition = shadowCoord.xyz; + + // dp = normalized distance from light to fragment position + float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp? + dp += shadowBias; + + // bd3D = base direction 3D + vec3 bd3D = normalize( lightToPosition ); + + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + + return ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + + #else // no percentage-closer filtering + + return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + + #endif + + } + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a9410c894a6a79db09a893d0ab87a747bfe4abac --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js @@ -0,0 +1,63 @@ +export default /* glsl */ ` +#ifdef USE_SHADOWMAP + + #if NUM_DIR_LIGHT_SHADOWS > 0 + + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + + struct DirectionalLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + + #endif + + #if NUM_SPOT_LIGHT_SHADOWS > 0 + + uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ]; + varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ]; + + struct SpotLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + + #endif + + #if NUM_POINT_LIGHT_SHADOWS > 0 + + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + + struct PointLightShadow { + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + + #endif + + /* + #if NUM_RECT_AREA_LIGHTS > 0 + + // TODO (abelnation): uniforms for area light shadows + + #endif + */ + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..cfc15eb41f8a9554e05112e13a4a53b78bfe9915 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js @@ -0,0 +1,60 @@ +export default /* glsl */ ` +#ifdef USE_SHADOWMAP + + #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 + + // Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne. + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; + + #endif + + #if NUM_DIR_LIGHT_SHADOWS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + + } + #pragma unroll_loop_end + + #endif + + #if NUM_SPOT_LIGHT_SHADOWS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 ); + vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition; + + } + #pragma unroll_loop_end + + #endif + + #if NUM_POINT_LIGHT_SHADOWS > 0 + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + + } + #pragma unroll_loop_end + + #endif + + /* + #if NUM_RECT_AREA_LIGHTS > 0 + + // TODO (abelnation): update vAreaShadowCoord with area light info + + #endif + */ + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..f4b559526de8fad3576cc4eb4289a25c18671775 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js @@ -0,0 +1,66 @@ +export default /* glsl */ ` +float getShadowMask() { + + float shadow = 1.0; + + #ifdef USE_SHADOWMAP + + #if NUM_DIR_LIGHT_SHADOWS > 0 + + DirectionalLightShadow directionalLight; + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + + } + #pragma unroll_loop_end + + #endif + + #if NUM_SPOT_LIGHT_SHADOWS > 0 + + SpotLightShadow spotLight; + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; + + } + #pragma unroll_loop_end + + #endif + + #if NUM_POINT_LIGHT_SHADOWS > 0 + + PointLightShadow pointLight; + + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + + } + #pragma unroll_loop_end + + #endif + + /* + #if NUM_RECT_AREA_LIGHTS > 0 + + // TODO (abelnation): update shadow for Area light + + #endif + */ + + #endif + + return shadow; + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..0b6dcbe33de82f6f0564e170975ebd00adecba28 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js @@ -0,0 +1,10 @@ +export default /* glsl */ ` +#ifdef USE_SKINNING + + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..52686f7555ca83e303ae7449fd616c8589eeb8fc --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js @@ -0,0 +1,48 @@ +export default /* glsl */ ` +#ifdef USE_SKINNING + + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + + #ifdef BONE_TEXTURE + + uniform highp sampler2D boneTexture; + uniform int boneTextureSize; + + mat4 getBoneMatrix( const in float i ) { + + float j = i * 4.0; + float x = mod( j, float( boneTextureSize ) ); + float y = floor( j / float( boneTextureSize ) ); + + float dx = 1.0 / float( boneTextureSize ); + float dy = 1.0 / float( boneTextureSize ); + + y = dy * ( y + 0.5 ); + + vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); + vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); + vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); + vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); + + mat4 bone = mat4( v1, v2, v3, v4 ); + + return bone; + + } + + #else + + uniform mat4 boneMatrices[ MAX_BONES ]; + + mat4 getBoneMatrix( const in float i ) { + + mat4 bone = boneMatrices[ int(i) ]; + return bone; + + } + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2f12f9499db7ee705295b8affd80e8fdb9ca199d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js @@ -0,0 +1,15 @@ +export default /* glsl */ ` +#ifdef USE_SKINNING + + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + + transformed = ( bindMatrixInverse * skinned ).xyz; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..7c6f8d56abc72322ce22d558bf50e583b1c02ba7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js @@ -0,0 +1,20 @@ +export default /* glsl */ ` +#ifdef USE_SKINNING + + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + + #ifdef USE_TANGENT + + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + + #endif + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..da74a7513d37ec77e1157d235e22c9706096a7e6 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js @@ -0,0 +1,14 @@ +export default /* glsl */ ` +float specularStrength; + +#ifdef USE_SPECULARMAP + + vec4 texelSpecular = texture2D( specularMap, vUv ); + specularStrength = texelSpecular.r; + +#else + + specularStrength = 1.0; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a7686d6707a3239b22ce04485cb185781880b330 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_SPECULARMAP + + uniform sampler2D specularMap; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..43cc82346d7581abcff76059ef8d7ad3a3d8ac11 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if defined( TONE_MAPPING ) + + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..25d251c49645dbe63b9c375ba1d7e48dea4bc5f6 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js @@ -0,0 +1,77 @@ +export default /* glsl */ ` +#ifndef saturate +// may have defined saturate() already +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif + +uniform float toneMappingExposure; + +// exposure only +vec3 LinearToneMapping( vec3 color ) { + + return toneMappingExposure * color; + +} + +// source: https://www.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf +vec3 ReinhardToneMapping( vec3 color ) { + + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); + +} + +// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/ +vec3 OptimizedCineonToneMapping( vec3 color ) { + + // optimized filmic operator by Jim Hejl and Richard Burgess-Dawson + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); + +} + +// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs +vec3 RRTAndODTFit( vec3 v ) { + + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; + +} + +// this implementation of ACES is modified to accommodate a brighter viewing environment. +// the scale factor of 1/0.6 is subjective. see discussion in #19621. + +vec3 ACESFilmicToneMapping( vec3 color ) { + + // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source + vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + + // ODT_SAT => XYZ => D60_2_D65 => sRGB + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source + vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + + color *= toneMappingExposure / 0.6; + + color = ACESInputMat * color; + + // Apply RRT and ODT + color = RRTAndODTFit( color ); + + color = ACESOutputMat * color; + + // Clamp to [0, 1] + return saturate( color ); + +} + +vec3 CustomToneMapping( vec3 color ) { return color; } +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..4e05d54bf17fbd25980bce6ba21d8287adfbca74 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js @@ -0,0 +1,32 @@ +export default /* glsl */ ` +#ifdef USE_TRANSMISSION + + float transmissionAlpha = 1.0; + float transmissionFactor = transmission; + float thicknessFactor = thickness; + + #ifdef USE_TRANSMISSIONMAP + + transmissionFactor *= texture2D( transmissionMap, vUv ).r; + + #endif + + #ifdef USE_THICKNESSMAP + + thicknessFactor *= texture2D( thicknessMap, vUv ).g; + + #endif + + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + + vec4 transmission = getIBLVolumeRefraction( + n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor, + attenuationColor, attenuationDistance ); + + totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor ); + transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor ); +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..2618b634d4af5e2ae5bc10ce91fec7b61e68da1f --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js @@ -0,0 +1,116 @@ +export default /* glsl */ ` +#ifdef USE_TRANSMISSION + + // Transmission code is based on glTF-Sampler-Viewer + // https://github.com/KhronosGroup/glTF-Sample-Viewer + + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + + #ifdef USE_TRANSMISSIONMAP + + uniform sampler2D transmissionMap; + + #endif + + #ifdef USE_THICKNESSMAP + + uniform sampler2D thicknessMap; + + #endif + + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + + varying vec3 vWorldPosition; + + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + + // Direction of refracted light. + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + + // Compute rotation-independant scaling of the model matrix. + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + + // The thickness is specified in local space. + return normalize( refractionVector ) * thickness * modelScale; + + } + + float applyIorToRoughness( const in float roughness, const in float ior ) { + + // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and + // an IOR of 1.5 results in the default amount of microfacet refraction. + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + + } + + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + + float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + + #ifdef TEXTURE_LOD_EXT + + return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + + #else + + return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); + + #endif + + } + + vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + + if ( attenuationDistance == 0.0 ) { + + // Attenuation distance is +∞ (which we indicate by zero), i.e. the transmitted color is not attenuated at all. + return radiance; + + } else { + + // Compute light attenuation using Beer's law. + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law + return transmittance * radiance; + + } + + } + + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + // Project refracted vector on the framebuffer, while mapping to normalized device coordinates. + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + // Sample framebuffer to get pixel the refracted ray hits. + vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + + vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); + + // Get the specular component. + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + + return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); + + } +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..625d2c9b39fb99d0d4fccebd02c2f55cb4683aeb --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + + varying vec2 vUv2; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3a9897ae1c592f12200f538b7441665a71cebcbb --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js @@ -0,0 +1,10 @@ +export default /* glsl */ ` +#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + + attribute vec2 uv2; + varying vec2 vUv2; + + uniform mat3 uv2Transform; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..7f9eefe55fd2e80727088e6e98dd63385d591f2c --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) + + vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..ede5e0c459dfd562cabe61d1a81d1602f3fa6e7b --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) + + varying vec2 vUv; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..18df68faf62e9cf230d7c813e17ad4c3acdbd4da --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js @@ -0,0 +1,17 @@ +export default /* glsl */ ` +#ifdef USE_UV + + #ifdef UVS_VERTEX_ONLY + + vec2 vUv; + + #else + + varying vec2 vUv; + + #endif + + uniform mat3 uvTransform; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/uv_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/uv_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..5e67510a0877f5ee5da9997229a273651eca8970 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/uv_vertex.glsl.js @@ -0,0 +1,7 @@ +export default /* glsl */ ` +#ifdef USE_UV + + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js b/backend/libs/three/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3246734308056f7d9155adc87a940b52e8354660 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js @@ -0,0 +1,15 @@ +export default /* glsl */ ` +#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) + + vec4 worldPosition = vec4( transformed, 1.0 ); + + #ifdef USE_INSTANCING + + worldPosition = instanceMatrix * worldPosition; + + #endif + + worldPosition = modelMatrix * worldPosition; + +#endif +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib.d.ts b/backend/libs/three/renderers/shaders/ShaderLib.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e2c31b942391f1da9ff0fc53f0949cb4971d3838 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib.d.ts @@ -0,0 +1,27 @@ +import { IUniform } from './UniformsLib'; + +export interface Shader { + uniforms: { [uniform: string]: IUniform }; + vertexShader: string; + fragmentShader: string; +} + +export let ShaderLib: { + [name: string]: Shader; + basic: Shader; + lambert: Shader; + phong: Shader; + standard: Shader; + matcap: Shader; + points: Shader; + dashed: Shader; + depth: Shader; + normal: Shader; + sprite: Shader; + background: Shader; + cube: Shader; + equirect: Shader; + distanceRGBA: Shader; + shadow: Shader; + physical: Shader; +}; diff --git a/backend/libs/three/renderers/shaders/ShaderLib.js b/backend/libs/three/renderers/shaders/ShaderLib.js new file mode 100644 index 0000000000000000000000000000000000000000..60788118c8bfe429db67cb21be1acb7322453422 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib.js @@ -0,0 +1,272 @@ +import { ShaderChunk } from './ShaderChunk.js'; +import { mergeUniforms } from './UniformsUtils.js'; +import { Vector2 } from '../../math/Vector2.js'; +import { Vector3 } from '../../math/Vector3.js'; +import { UniformsLib } from './UniformsLib.js'; +import { Color } from '../../math/Color.js'; +import { Matrix3 } from '../../math/Matrix3.js'; + +const ShaderLib = { + basic: { + uniforms: mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.fog]), + + vertexShader: ShaderChunk.meshbasic_vert, + fragmentShader: ShaderChunk.meshbasic_frag, + }, + + lambert: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color(0x000000) }, + }, + ]), + + vertexShader: ShaderChunk.meshlambert_vert, + fragmentShader: ShaderChunk.meshlambert_frag, + }, + + phong: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color(0x000000) }, + specular: { value: new Color(0x111111) }, + shininess: { value: 30 }, + }, + ]), + + vertexShader: ShaderChunk.meshphong_vert, + fragmentShader: ShaderChunk.meshphong_frag, + }, + + standard: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.roughnessmap, + UniformsLib.metalnessmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color(0x000000) }, + roughness: { value: 1.0 }, + metalness: { value: 0.0 }, + envMapIntensity: { value: 1 }, // temporary + }, + ]), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag, + }, + + toon: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.gradientmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color(0x000000) }, + }, + ]), + + vertexShader: ShaderChunk.meshtoon_vert, + fragmentShader: ShaderChunk.meshtoon_frag, + }, + + matcap: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + { + matcap: { value: null }, + }, + ]), + + vertexShader: ShaderChunk.meshmatcap_vert, + fragmentShader: ShaderChunk.meshmatcap_frag, + }, + + points: { + uniforms: mergeUniforms([UniformsLib.points, UniformsLib.fog]), + + vertexShader: ShaderChunk.points_vert, + fragmentShader: ShaderChunk.points_frag, + }, + + dashed: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 }, + }, + ]), + + vertexShader: ShaderChunk.linedashed_vert, + fragmentShader: ShaderChunk.linedashed_frag, + }, + + depth: { + uniforms: mergeUniforms([UniformsLib.common, UniformsLib.displacementmap]), + + vertexShader: ShaderChunk.depth_vert, + fragmentShader: ShaderChunk.depth_frag, + }, + + normal: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + { + opacity: { value: 1.0 }, + }, + ]), + + vertexShader: ShaderChunk.meshnormal_vert, + fragmentShader: ShaderChunk.meshnormal_frag, + }, + + sprite: { + uniforms: mergeUniforms([UniformsLib.sprite, UniformsLib.fog]), + + vertexShader: ShaderChunk.sprite_vert, + fragmentShader: ShaderChunk.sprite_frag, + }, + + background: { + uniforms: { + uvTransform: { value: new Matrix3() }, + t2D: { value: null }, + }, + + vertexShader: ShaderChunk.background_vert, + fragmentShader: ShaderChunk.background_frag, + }, + /* ------------------------------------------------------------------------- + // Cube map shader + ------------------------------------------------------------------------- */ + + cube: { + uniforms: mergeUniforms([ + UniformsLib.envmap, + { + opacity: { value: 1.0 }, + }, + ]), + + vertexShader: ShaderChunk.cube_vert, + fragmentShader: ShaderChunk.cube_frag, + }, + + equirect: { + uniforms: { + tEquirect: { value: null }, + }, + + vertexShader: ShaderChunk.equirect_vert, + fragmentShader: ShaderChunk.equirect_frag, + }, + + distanceRGBA: { + uniforms: mergeUniforms([ + UniformsLib.common, + UniformsLib.displacementmap, + { + referencePosition: { value: new Vector3() }, + nearDistance: { value: 1 }, + farDistance: { value: 1000 }, + }, + ]), + + vertexShader: ShaderChunk.distanceRGBA_vert, + fragmentShader: ShaderChunk.distanceRGBA_frag, + }, + + shadow: { + uniforms: mergeUniforms([ + UniformsLib.lights, + UniformsLib.fog, + { + color: { value: new Color(0x00000) }, + opacity: { value: 1.0 }, + }, + ]), + + vertexShader: ShaderChunk.shadow_vert, + fragmentShader: ShaderChunk.shadow_frag, + }, +}; + +ShaderLib.physical = { + uniforms: mergeUniforms([ + ShaderLib.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatNormalScale: { value: new Vector2(1, 1) }, + clearcoatNormalMap: { value: null }, + sheen: { value: 0 }, + sheenColor: { value: new Color(0x000000) }, + sheenColorMap: { value: null }, + sheenRoughness: { value: 1 }, + sheenRoughnessMap: { value: null }, + transmission: { value: 0 }, + transmissionMap: { value: null }, + transmissionSamplerSize: { value: new Vector2() }, + transmissionSamplerMap: { value: null }, + thickness: { value: 0 }, + thicknessMap: { value: null }, + attenuationDistance: { value: 0 }, + attenuationColor: { value: new Color(0x000000) }, + specularIntensity: { value: 1 }, + specularIntensityMap: { value: null }, + specularColor: { value: new Color(1, 1, 1) }, + specularColorMap: { value: null }, + }, + ]), + + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag, +}; + +export { ShaderLib }; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/background.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/background.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..a65967a9677e94c02a804f0bd693fb4564cc9d40 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/background.glsl.js @@ -0,0 +1,27 @@ +export const vertex = /* glsl */ ` +varying vec2 vUv; +uniform mat3 uvTransform; + +void main() { + + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + + gl_Position = vec4( position.xy, 1.0, 1.0 ); + +} +`; + +export const fragment = /* glsl */ ` +uniform sampler2D t2D; + +varying vec2 vUv; + +void main() { + + gl_FragColor = texture2D( t2D, vUv ); + + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/cube.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/cube.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..cb59f990ab50f11afa84be56204a7b60aa962d56 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/cube.glsl.js @@ -0,0 +1,38 @@ +export const vertex = /* glsl */ ` +varying vec3 vWorldDirection; + +#include + +void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + gl_Position.z = gl_Position.w; // set z to camera.far + +} +`; + +export const fragment = /* glsl */ ` +#include +uniform float opacity; + +varying vec3 vWorldDirection; + +#include + +void main() { + + vec3 vReflect = vWorldDirection; + #include + + gl_FragColor = envColor; + gl_FragColor.a *= opacity; + + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/depth.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/depth.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..d96b96ae7b01f64dfaa24290c2ad70f264584ec1 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/depth.glsl.js @@ -0,0 +1,92 @@ +export const vertex = /* glsl */ ` +#include +#include +#include +#include +#include +#include +#include + +// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible. +// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for +// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1. +varying vec2 vHighPrecisionZW; + +void main() { + + #include + + #include + + #ifdef USE_DISPLACEMENTMAP + + #include + #include + #include + + #endif + + #include + #include + #include + #include + #include + #include + #include + + vHighPrecisionZW = gl_Position.zw; + +} +`; + +export const fragment = /* glsl */ ` +#if DEPTH_PACKING == 3200 + + uniform float opacity; + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +varying vec2 vHighPrecisionZW; + +void main() { + + #include + + vec4 diffuseColor = vec4( 1.0 ); + + #if DEPTH_PACKING == 3200 + + diffuseColor.a = opacity; + + #endif + + #include + #include + #include + + #include + + // Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values. + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + + #if DEPTH_PACKING == 3200 + + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + + #elif DEPTH_PACKING == 3201 + + gl_FragColor = packDepthToRGBA( fragCoordZ ); + + #endif + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/distanceRGBA.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/distanceRGBA.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..37825bfa5ff9aa2d46e7de23db60f693b13c9280 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/distanceRGBA.glsl.js @@ -0,0 +1,73 @@ +export const vertex = /* glsl */ ` +#define DISTANCE + +varying vec3 vWorldPosition; + +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + #include + + #ifdef USE_DISPLACEMENTMAP + + #include + #include + #include + + #endif + + #include + #include + #include + #include + #include + #include + #include + + vWorldPosition = worldPosition.xyz; + +} +`; + +export const fragment = /* glsl */ ` +#define DISTANCE + +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; + +#include +#include +#include +#include +#include +#include +#include + +void main () { + + #include + + vec4 diffuseColor = vec4( 1.0 ); + + #include + #include + #include + + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); // clamp to [ 0, 1 ] + + gl_FragColor = packDepthToRGBA( dist ); + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/equirect.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/equirect.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..fb7fcde3a17e227acfd7bfd7e3ef986404801bbf --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/equirect.glsl.js @@ -0,0 +1,35 @@ +export const vertex = /* glsl */ ` +varying vec3 vWorldDirection; + +#include + +void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform sampler2D tEquirect; + +varying vec3 vWorldDirection; + +#include + +void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/linedashed.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/linedashed.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..ccd71f91ddfbbf650bd5f810cc06684e336c47a7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/linedashed.glsl.js @@ -0,0 +1,69 @@ +export const vertex = /* glsl */ ` +uniform float scale; +attribute float lineDistance; + +varying float vLineDistance; + +#include +#include +#include +#include +#include +#include + +void main() { + + vLineDistance = scale * lineDistance; + + #include + #include + #include + #include + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 diffuse; +uniform float opacity; + +uniform float dashSize; +uniform float totalSize; + +varying float vLineDistance; + +#include +#include +#include +#include +#include + +void main() { + + #include + + if ( mod( vLineDistance, totalSize ) > dashSize ) { + + discard; + + } + + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + + outgoingLight = diffuseColor.rgb; // simple shader + + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshbasic.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshbasic.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3e0b3dc49dc64a95e935870bf804e3964361781b --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshbasic.glsl.js @@ -0,0 +1,115 @@ +export const vertex = /* glsl */ ` +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + + #include + #include + #include + #include + #include + + #endif + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 diffuse; +uniform float opacity; + +#ifndef FLAT_SHADED + + varying vec3 vNormal; + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + #include + #include + #include + #include + + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + + // accumulation (baked indirect lighting only) + #ifdef USE_LIGHTMAP + + vec4 lightMapTexel= texture2D( lightMap, vUv2 ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity; + + #else + + reflectedLight.indirectDiffuse += vec3( 1.0 ); + + #endif + + // modulation + #include + + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + + vec3 outgoingLight = reflectedLight.indirectDiffuse; + + #include + + #include + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshlambert.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshlambert.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..fb15dca5b7dcf1043bf8b1921f3996ecb1580775 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshlambert.glsl.js @@ -0,0 +1,150 @@ +export const vertex = /* glsl */ ` +#define LAMBERT + +varying vec3 vLightFront; +varying vec3 vIndirectFront; + +#ifdef DOUBLE_SIDED + varying vec3 vLightBack; + varying vec3 vIndirectBack; +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; + +varying vec3 vLightFront; +varying vec3 vIndirectFront; + +#ifdef DOUBLE_SIDED + varying vec3 vLightBack; + varying vec3 vIndirectBack; +#endif + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + + #include + #include + #include + #include + #include + #include + #include + + // accumulation + + #ifdef DOUBLE_SIDED + + reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack; + + #else + + reflectedLight.indirectDiffuse += vIndirectFront; + + #endif + + #include + + reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb ); + + #ifdef DOUBLE_SIDED + + reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack; + + #else + + reflectedLight.directDiffuse = vLightFront; + + #endif + + reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask(); + + // modulation + + #include + + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + + #include + + #include + #include + #include + #include + #include + #include +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshmatcap.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshmatcap.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..bd243ec8667fa6cf2827df1b09f5c186c9ed8e05 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshmatcap.glsl.js @@ -0,0 +1,106 @@ +export const vertex = /* glsl */ ` +#define MATCAP + +varying vec3 vViewPosition; + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +void main() { + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + +} +`; + +export const fragment = /* glsl */ ` +#define MATCAP + +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; + +varying vec3 vViewPosition; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + #include + #include + #include + #include + #include + + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks + + #ifdef USE_MATCAP + + vec4 matcapColor = texture2D( matcap, uv ); + + #else + + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); // default if matcap is missing + + #endif + + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + + #include + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshnormal.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshnormal.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..6a24d3c59edeeeff3572d40a1f8efd22206f2fc8 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshnormal.glsl.js @@ -0,0 +1,76 @@ +export const vertex = /* glsl */ ` +#define NORMAL + +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + + varying vec3 vViewPosition; + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + + vViewPosition = - mvPosition.xyz; + +#endif + +} +`; + +export const fragment = /* glsl */ ` +#define NORMAL + +uniform float opacity; + +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) + + varying vec3 vViewPosition; + +#endif + +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + #include + + gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshphong.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshphong.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..85077205e53d9098b24447eab1c09164945d1282 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshphong.glsl.js @@ -0,0 +1,125 @@ +export const vertex = /* glsl */ ` +#define PHONG + +varying vec3 vViewPosition; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #include + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +#define PHONG + +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + + #include + #include + #include + #include + #include + #include + #include + #include + #include + + // accumulation + #include + #include + #include + #include + + // modulation + #include + + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + + #include + #include + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshphysical.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshphysical.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..be8dc653beae5bd182198a8e5c09417411b3737f --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshphysical.glsl.js @@ -0,0 +1,206 @@ +export const vertex = /* glsl */ ` +#define STANDARD + +varying vec3 vViewPosition; + +#ifdef USE_TRANSMISSION + + varying vec3 vWorldPosition; + +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #include + #include + #include + +#ifdef USE_TRANSMISSION + + vWorldPosition = worldPosition.xyz; + +#endif +} +`; + +export const fragment = /* glsl */ ` +#define STANDARD + +#ifdef PHYSICAL + #define IOR + #define SPECULAR +#endif + +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; + +#ifdef IOR + uniform float ior; +#endif + +#ifdef SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + + #ifdef USE_SPECULARINTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif + + #ifdef USE_SPECULARCOLORMAP + uniform sampler2D specularColorMap; + #endif +#endif + +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif + +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + + #ifdef USE_SHEENCOLORMAP + uniform sampler2D sheenColorMap; + #endif + + #ifdef USE_SHEENROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif + +varying vec3 vViewPosition; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + // accumulation + #include + #include + #include + #include + + // modulation + #include + + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + + #include + + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + + #ifdef USE_SHEEN + + // Sheen energy compensation approximation calculation can be found at the end of + // https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; + + #endif + + #ifdef USE_CLEARCOAT + + float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); + + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; + + #endif + + #include + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/meshtoon.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/meshtoon.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..fdae8102fa7775c74c3b4503a894e15c58ac63e3 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/meshtoon.glsl.js @@ -0,0 +1,116 @@ +export const vertex = /* glsl */ ` +#define TOON + +varying vec3 vViewPosition; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + #include + #include + #include + #include + + vViewPosition = - mvPosition.xyz; + + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +#define TOON + +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 diffuseColor = vec4( diffuse, opacity ); + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + + #include + #include + #include + #include + #include + #include + #include + #include + + // accumulation + #include + #include + #include + #include + + // modulation + #include + + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + + #include + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/points.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/points.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..cc18647c77f657d76bba78471109f3fa59cfbbc2 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/points.glsl.js @@ -0,0 +1,70 @@ +export const vertex = /* glsl */ ` +uniform float size; +uniform float scale; + +#include +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + #include + + gl_PointSize = size; + + #ifdef USE_SIZEATTENUATION + + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + + #endif + + #include + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 diffuse; +uniform float opacity; + +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + #include + #include + + outgoingLight = diffuseColor.rgb; + + #include + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/shadow.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/shadow.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..3b2674e519cfb80b6351aedf5ae6e1e17f796fb0 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/shadow.glsl.js @@ -0,0 +1,49 @@ +export const vertex = /* glsl */ ` +#include +#include +#include +#include +#include + +void main() { + + #include + #include + #include + #include + #include + + #include + #include + #include + #include + + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 color; +uniform float opacity; + +#include +#include +#include +#include +#include +#include +#include + +void main() { + + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/sprite.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/sprite.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..dd6d436585f319f202ff63034148b67025d55e3d --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/sprite.glsl.js @@ -0,0 +1,79 @@ +export const vertex = /* glsl */ ` +uniform float rotation; +uniform vec2 center; + +#include +#include +#include +#include +#include + +void main() { + + #include + + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + + #ifndef USE_SIZEATTENUATION + + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + + if ( isPerspective ) scale *= - mvPosition.z; + + #endif + + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + + mvPosition.xy += rotatedPosition; + + gl_Position = projectionMatrix * mvPosition; + + #include + #include + #include + +} +`; + +export const fragment = /* glsl */ ` +uniform vec3 diffuse; +uniform float opacity; + +#include +#include +#include +#include +#include +#include +#include +#include + +void main() { + + #include + + vec3 outgoingLight = vec3( 0.0 ); + vec4 diffuseColor = vec4( diffuse, opacity ); + + #include + #include + #include + #include + + outgoingLight = diffuseColor.rgb; + + #include + #include + #include + #include + +} +`; diff --git a/backend/libs/three/renderers/shaders/ShaderLib/vsm.glsl.js b/backend/libs/three/renderers/shaders/ShaderLib/vsm.glsl.js new file mode 100644 index 0000000000000000000000000000000000000000..8304729179e1efb3e138625e4a7e0de0a06773c7 --- /dev/null +++ b/backend/libs/three/renderers/shaders/ShaderLib/vsm.glsl.js @@ -0,0 +1,56 @@ +export const vertex = /* glsl */ ` +void main() { + + gl_Position = vec4( position, 1.0 ); + +} +`; + +export const fragment = /* glsl */ ` +uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; + +#include + +void main() { + + const float samples = float( VSM_SAMPLES ); + + float mean = 0.0; + float squared_mean = 0.0; + + // This seems totally useless but it's a crazy work around for a Adreno compiler bug + // float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) ); + + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + + float uvOffset = uvStart + i * uvStride; + + #ifdef HORIZONTAL_PASS + + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + + #else + + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + + #endif + + } + + mean = mean / samples; + squared_mean = squared_mean / samples; + + float std_dev = sqrt( squared_mean - mean * mean ); + + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); + +} +`; diff --git a/backend/libs/three/renderers/shaders/UniformsLib.d.ts b/backend/libs/three/renderers/shaders/UniformsLib.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..81e05fd81c328dd8324814bfe293c55245669668 --- /dev/null +++ b/backend/libs/three/renderers/shaders/UniformsLib.d.ts @@ -0,0 +1,153 @@ +// tslint:disable-next-line:interface-name +export interface IUniform { + value: TValue; +} + +export let UniformsLib: { + common: { + diffuse: IUniform; + opacity: IUniform; + map: IUniform; + uvTransform: IUniform; + uv2Transform: IUniform; + alphaMap: IUniform; + }; + specularmap: { + specularMap: IUniform; + }; + envmap: { + envMap: IUniform; + flipEnvMap: IUniform; + reflectivity: IUniform; + refractionRatio: IUniform; + maxMipLevel: IUniform; + }; + aomap: { + aoMap: IUniform; + aoMapIntensity: IUniform; + }; + lightmap: { + lightMap: IUniform; + lightMapIntensity: IUniform; + }; + emissivemap: { + emissiveMap: IUniform; + }; + bumpmap: { + bumpMap: IUniform; + bumpScale: IUniform; + }; + normalmap: { + normalMap: IUniform; + normalScale: IUniform; + }; + displacementmap: { + displacementMap: IUniform; + displacementScale: IUniform; + displacementBias: IUniform; + }; + roughnessmap: { + roughnessMap: IUniform; + }; + metalnessmap: { + metalnessMap: IUniform; + }; + gradientmap: { + gradientMap: IUniform; + }; + fog: { + fogDensity: IUniform; + fogNear: IUniform; + fogFar: IUniform; + fogColor: IUniform; + }; + lights: { + ambientLightColor: IUniform; + directionalLights: { + value: any[]; + properties: { + direction: {}; + color: {}; + }; + }; + directionalLightShadows: { + value: any[]; + properties: { + shadowBias: {}; + shadowNormalBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + directionalShadowMap: IUniform; + directionalShadowMatrix: IUniform; + spotLights: { + value: any[]; + properties: { + color: {}; + position: {}; + direction: {}; + distance: {}; + coneCos: {}; + penumbraCos: {}; + decay: {}; + }; + }; + spotLightShadows: { + value: any[]; + properties: { + shadowBias: {}; + shadowNormalBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + spotShadowMap: IUniform; + spotShadowMatrix: IUniform; + pointLights: { + value: any[]; + properties: { + color: {}; + position: {}; + decay: {}; + distance: {}; + }; + }; + pointLightShadows: { + value: any[]; + properties: { + shadowBias: {}; + shadowNormalBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + pointShadowMap: IUniform; + pointShadowMatrix: IUniform; + hemisphereLights: { + value: any[]; + properties: { + direction: {}; + skycolor: {}; + groundColor: {}; + }; + }; + rectAreaLights: { + value: any[]; + properties: { + color: {}; + position: {}; + width: {}; + height: {}; + }; + }; + }; + points: { + diffuse: IUniform; + opacity: IUniform; + size: IUniform; + scale: IUniform; + map: IUniform; + uvTransform: IUniform; + }; +}; diff --git a/backend/libs/three/renderers/shaders/UniformsLib.js b/backend/libs/three/renderers/shaders/UniformsLib.js new file mode 100644 index 0000000000000000000000000000000000000000..b7efb6979fe9449f70a34d9dd8e188b67929b6a5 --- /dev/null +++ b/backend/libs/three/renderers/shaders/UniformsLib.js @@ -0,0 +1,207 @@ +import { Color } from '../../math/Color.js'; +import { Vector2 } from '../../math/Vector2.js'; +import { Matrix3 } from '../../math/Matrix3.js'; + +/** + * Uniforms library for shared webgl shaders + */ + +const UniformsLib = { + common: { + diffuse: { value: new Color(0xffffff) }, + opacity: { value: 1.0 }, + + map: { value: null }, + uvTransform: { value: new Matrix3() }, + uv2Transform: { value: new Matrix3() }, + + alphaMap: { value: null }, + alphaTest: { value: 0 }, + }, + + specularmap: { + specularMap: { value: null }, + }, + + envmap: { + envMap: { value: null }, + flipEnvMap: { value: -1 }, + reflectivity: { value: 1.0 }, // basic, lambert, phong + ior: { value: 1.5 }, // standard, physical + refractionRatio: { value: 0.98 }, + }, + + aomap: { + aoMap: { value: null }, + aoMapIntensity: { value: 1 }, + }, + + lightmap: { + lightMap: { value: null }, + lightMapIntensity: { value: 1 }, + }, + + emissivemap: { + emissiveMap: { value: null }, + }, + + bumpmap: { + bumpMap: { value: null }, + bumpScale: { value: 1 }, + }, + + normalmap: { + normalMap: { value: null }, + normalScale: { value: new Vector2(1, 1) }, + }, + + displacementmap: { + displacementMap: { value: null }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 }, + }, + + roughnessmap: { + roughnessMap: { value: null }, + }, + + metalnessmap: { + metalnessMap: { value: null }, + }, + + gradientmap: { + gradientMap: { value: null }, + }, + + fog: { + fogDensity: { value: 0.00025 }, + fogNear: { value: 1 }, + fogFar: { value: 2000 }, + fogColor: { value: new Color(0xffffff) }, + }, + + lights: { + ambientLightColor: { value: [] }, + + lightProbe: { value: [] }, + + directionalLights: { + value: [], + properties: { + direction: {}, + color: {}, + }, + }, + + directionalLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + }, + }, + + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, + + spotLights: { + value: [], + properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {}, + }, + }, + + spotLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + }, + }, + + spotShadowMap: { value: [] }, + spotShadowMatrix: { value: [] }, + + pointLights: { + value: [], + properties: { + color: {}, + position: {}, + decay: {}, + distance: {}, + }, + }, + + pointLightShadows: { + value: [], + properties: { + shadowBias: {}, + shadowNormalBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {}, + }, + }, + + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, + + hemisphereLights: { + value: [], + properties: { + direction: {}, + skyColor: {}, + groundColor: {}, + }, + }, + + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { + value: [], + properties: { + color: {}, + position: {}, + width: {}, + height: {}, + }, + }, + + ltc_1: { value: null }, + ltc_2: { value: null }, + }, + + points: { + diffuse: { value: new Color(0xffffff) }, + opacity: { value: 1.0 }, + size: { value: 1.0 }, + scale: { value: 1.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() }, + }, + + sprite: { + diffuse: { value: new Color(0xffffff) }, + opacity: { value: 1.0 }, + center: { value: new Vector2(0.5, 0.5) }, + rotation: { value: 0.0 }, + map: { value: null }, + alphaMap: { value: null }, + alphaTest: { value: 0 }, + uvTransform: { value: new Matrix3() }, + }, +}; + +export { UniformsLib }; diff --git a/backend/libs/three/renderers/shaders/UniformsUtils.d.ts b/backend/libs/three/renderers/shaders/UniformsUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fe9ef815a448633d8e7003ad4775818628fdf1de --- /dev/null +++ b/backend/libs/three/renderers/shaders/UniformsUtils.d.ts @@ -0,0 +1,6 @@ +export function cloneUniforms(uniforms_src: any): any; +export function mergeUniforms(uniforms: any[]): any; + +export namespace UniformsUtils { + export { mergeUniforms as merge, cloneUniforms as clone }; +} diff --git a/backend/libs/three/renderers/shaders/UniformsUtils.js b/backend/libs/three/renderers/shaders/UniformsUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..b47c695cced5b059a5c90c8f473b1516aa4d0730 --- /dev/null +++ b/backend/libs/three/renderers/shaders/UniformsUtils.js @@ -0,0 +1,55 @@ +/** + * Uniform Utilities + */ + +export function cloneUniforms(src) { + const dst = {}; + + for (const u in src) { + dst[u] = {}; + + for (const p in src[u]) { + const property = src[u][p]; + + if ( + property && + (property.isColor || + property.isMatrix3 || + property.isMatrix4 || + property.isVector2 || + property.isVector3 || + property.isVector4 || + property.isTexture || + property.isQuaternion) + ) { + dst[u][p] = property.clone(); + } else if (Array.isArray(property)) { + dst[u][p] = property.slice(); + } else { + dst[u][p] = property; + } + } + } + + return dst; +} + +export function mergeUniforms(uniforms) { + const merged = {}; + + for (let u = 0; u < uniforms.length; u++) { + const tmp = cloneUniforms(uniforms[u]); + + for (const p in tmp) { + merged[p] = tmp[p]; + } + } + + return merged; +} + +// Legacy + +const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms }; + +export { UniformsUtils }; diff --git a/backend/libs/three/renderers/webgl/WebGLAnimation.js b/backend/libs/three/renderers/webgl/WebGLAnimation.js new file mode 100644 index 0000000000000000000000000000000000000000..4a1b6b864749e5d797b8f480da075aa049a5605c --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLAnimation.js @@ -0,0 +1,39 @@ +function WebGLAnimation() { + let context = null; + let isAnimating = false; + let animationLoop = null; + let requestId = null; + + function onAnimationFrame(time, frame) { + animationLoop(time, frame); + + requestId = context.requestAnimationFrame(onAnimationFrame); + } + + return { + start: function () { + if (isAnimating === true) return; + if (animationLoop === null) return; + + requestId = context.requestAnimationFrame(onAnimationFrame); + + isAnimating = true; + }, + + stop: function () { + context?.cancelAnimationFrame(requestId); + + isAnimating = false; + }, + + setAnimationLoop: function (callback) { + animationLoop = callback; + }, + + setContext: function (value) { + context = value; + }, + }; +} + +export { WebGLAnimation }; diff --git a/backend/libs/three/renderers/webgl/WebGLAttributes.d.ts b/backend/libs/three/renderers/webgl/WebGLAttributes.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6f4adf29a2fe53b4c2822fd97ceca6137c6db1b5 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLAttributes.d.ts @@ -0,0 +1,18 @@ +import { WebGLCapabilities } from './WebGLCapabilities'; +import { BufferAttribute } from '../../core/BufferAttribute'; +import { InterleavedBufferAttribute } from '../../core/InterleavedBufferAttribute'; + +export class WebGLAttributes { + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, capabilities: WebGLCapabilities); + + get(attribute: BufferAttribute | InterleavedBufferAttribute): { + buffer: WebGLBuffer; + type: number; + bytesPerElement: number; + version: number; + }; + + remove(attribute: BufferAttribute | InterleavedBufferAttribute): void; + + update(attribute: BufferAttribute | InterleavedBufferAttribute, bufferType: number): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLAttributes.js b/backend/libs/three/renderers/webgl/WebGLAttributes.js new file mode 100644 index 0000000000000000000000000000000000000000..76928dfaa4d822bde290fa3ec4cc8e374671a8ce --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLAttributes.js @@ -0,0 +1,136 @@ +function WebGLAttributes(gl, capabilities) { + const isWebGL2 = capabilities.isWebGL2; + + const buffers = new WeakMap(); + + function createBuffer(attribute, bufferType) { + const array = attribute.array; + const usage = attribute.usage; + + const buffer = gl.createBuffer(); + + gl.bindBuffer(bufferType, buffer); + gl.bufferData(bufferType, array, usage); + + attribute.onUploadCallback(); + + let type = gl.FLOAT; + + if (array instanceof Float32Array) { + type = gl.FLOAT; + } else if (array instanceof Float64Array) { + console.warn('THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.'); + } else if (array instanceof Uint16Array) { + if (attribute.isFloat16BufferAttribute) { + if (isWebGL2) { + type = gl.HALF_FLOAT; + } else { + console.warn('THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.'); + } + } else { + type = gl.UNSIGNED_SHORT; + } + } else if (array instanceof Int16Array) { + type = gl.SHORT; + } else if (array instanceof Uint32Array) { + type = gl.UNSIGNED_INT; + } else if (array instanceof Int32Array) { + type = gl.INT; + } else if (array instanceof Int8Array) { + type = gl.BYTE; + } else if (array instanceof Uint8Array) { + type = gl.UNSIGNED_BYTE; + } else if (array instanceof Uint8ClampedArray) { + type = gl.UNSIGNED_BYTE; + } + + return { + buffer: buffer, + type: type, + bytesPerElement: array.BYTES_PER_ELEMENT, + version: attribute.version, + }; + } + + function updateBuffer(buffer, attribute, bufferType) { + const array = attribute.array; + const updateRange = attribute.updateRange; + + gl.bindBuffer(bufferType, buffer); + + if (updateRange.count === -1) { + // Not using update ranges + + gl.bufferSubData(bufferType, 0, array); + } else { + if (isWebGL2) { + gl.bufferSubData(bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, array, updateRange.offset, updateRange.count); + } else { + gl.bufferSubData( + bufferType, + updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray(updateRange.offset, updateRange.offset + updateRange.count) + ); + } + + updateRange.count = -1; // reset range + } + } + + // + + function get(attribute) { + if (attribute.isInterleavedBufferAttribute) attribute = attribute.data; + + return buffers.get(attribute); + } + + function remove(attribute) { + if (attribute.isInterleavedBufferAttribute) attribute = attribute.data; + + const data = buffers.get(attribute); + + if (data) { + gl.deleteBuffer(data.buffer); + + buffers.delete(attribute); + } + } + + function update(attribute, bufferType) { + if (attribute.isGLBufferAttribute) { + const cached = buffers.get(attribute); + + if (!cached || cached.version < attribute.version) { + buffers.set(attribute, { + buffer: attribute.buffer, + type: attribute.type, + bytesPerElement: attribute.elementSize, + version: attribute.version, + }); + } + + return; + } + + if (attribute.isInterleavedBufferAttribute) attribute = attribute.data; + + const data = buffers.get(attribute); + + if (data === undefined) { + buffers.set(attribute, createBuffer(attribute, bufferType)); + } else if (data.version < attribute.version) { + updateBuffer(data.buffer, attribute, bufferType); + + data.version = attribute.version; + } + } + + return { + get: get, + remove: remove, + update: update, + }; +} + +export { WebGLAttributes }; diff --git a/backend/libs/three/renderers/webgl/WebGLBackground.js b/backend/libs/three/renderers/webgl/WebGLBackground.js new file mode 100644 index 0000000000000000000000000000000000000000..2ef6841f58e2460f08e0c82e9784d375428a9993 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLBackground.js @@ -0,0 +1,169 @@ +import { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js'; +import { BoxGeometry } from '../../geometries/BoxGeometry.js'; +import { PlaneGeometry } from '../../geometries/PlaneGeometry.js'; +import { ShaderMaterial } from '../../materials/ShaderMaterial.js'; +import { Color } from '../../math/Color.js'; +import { Mesh } from '../../objects/Mesh.js'; +import { ShaderLib } from '../shaders/ShaderLib.js'; +import { cloneUniforms } from '../shaders/UniformsUtils.js'; + +function WebGLBackground(renderer, cubemaps, state, objects, alpha, premultipliedAlpha) { + const clearColor = new Color(0x000000); + let clearAlpha = alpha === true ? 0 : 1; + + let planeMesh; + let boxMesh; + + let currentBackground = null; + let currentBackgroundVersion = 0; + let currentTonemapping = null; + + function render(renderList, scene) { + let forceClear = false; + let background = scene.isScene === true ? scene.background : null; + + if (background && background.isTexture) { + background = cubemaps.get(background); + } + + // Ignore background in AR + // TODO: Reconsider this. + + const xr = renderer.xr; + const session = xr.getSession && xr.getSession(); + + if (session && session.environmentBlendMode === 'additive') { + background = null; + } + + if (background === null) { + setClear(clearColor, clearAlpha); + } else if (background && background.isColor) { + setClear(background, 1); + forceClear = true; + } + + if (renderer.autoClear || forceClear) { + renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil); + } + + if (background && (background.isCubeTexture || background.mapping === CubeUVReflectionMapping)) { + if (boxMesh === undefined) { + boxMesh = new Mesh( + new BoxGeometry(1, 1, 1), + new ShaderMaterial({ + name: 'BackgroundCubeMaterial', + uniforms: cloneUniforms(ShaderLib.cube.uniforms), + vertexShader: ShaderLib.cube.vertexShader, + fragmentShader: ShaderLib.cube.fragmentShader, + side: BackSide, + depthTest: false, + depthWrite: false, + fog: false, + }) + ); + + boxMesh.geometry.deleteAttribute('normal'); + boxMesh.geometry.deleteAttribute('uv'); + + boxMesh.onBeforeRender = function (renderer, scene, camera) { + this.matrixWorld.copyPosition(camera.matrixWorld); + }; + + // enable code injection for non-built-in material + Object.defineProperty(boxMesh.material, 'envMap', { + get: function () { + return this.uniforms.envMap.value; + }, + }); + + objects.update(boxMesh); + } + + boxMesh.material.uniforms.envMap.value = background; + boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1; + + if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) { + boxMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + } + + // push to the pre-sorted opaque render list + renderList.unshift(boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null); + } else if (background && background.isTexture) { + if (planeMesh === undefined) { + planeMesh = new Mesh( + new PlaneGeometry(2, 2), + new ShaderMaterial({ + name: 'BackgroundMaterial', + uniforms: cloneUniforms(ShaderLib.background.uniforms), + vertexShader: ShaderLib.background.vertexShader, + fragmentShader: ShaderLib.background.fragmentShader, + side: FrontSide, + depthTest: false, + depthWrite: false, + fog: false, + }) + ); + + planeMesh.geometry.deleteAttribute('normal'); + + // enable code injection for non-built-in material + Object.defineProperty(planeMesh.material, 'map', { + get: function () { + return this.uniforms.t2D.value; + }, + }); + + objects.update(planeMesh); + } + + planeMesh.material.uniforms.t2D.value = background; + + if (background.matrixAutoUpdate === true) { + background.updateMatrix(); + } + + planeMesh.material.uniforms.uvTransform.value.copy(background.matrix); + + if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) { + planeMesh.material.needsUpdate = true; + + currentBackground = background; + currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; + } + + // push to the pre-sorted opaque render list + renderList.unshift(planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null); + } + } + + function setClear(color, alpha) { + state.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha); + } + + return { + getClearColor: function () { + return clearColor; + }, + setClearColor: function (color, alpha = 1) { + clearColor.set(color); + clearAlpha = alpha; + setClear(clearColor, clearAlpha); + }, + getClearAlpha: function () { + return clearAlpha; + }, + setClearAlpha: function (alpha) { + clearAlpha = alpha; + setClear(clearColor, clearAlpha); + }, + render: render, + }; +} + +export { WebGLBackground }; diff --git a/backend/libs/three/renderers/webgl/WebGLBindingStates.d.ts b/backend/libs/three/renderers/webgl/WebGLBindingStates.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e97bf90ded5c18966c48e0ae0d40c0cf6dec57a2 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLBindingStates.d.ts @@ -0,0 +1,22 @@ +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLAttributes } from './WebGLAttributes'; +import { WebGLProgram } from './WebGLProgram'; +import { WebGLCapabilities } from './WebGLCapabilities'; +import { Object3D } from './../../core/Object3D'; +import { BufferGeometry } from './../../core/BufferGeometry'; +import { BufferAttribute } from './../../core/BufferAttribute'; +import { Material } from './../../materials/Material'; + +export class WebGLBindingStates { + constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions, attributes: WebGLAttributes, capabilities: WebGLCapabilities); + + setup(object: Object3D, material: Material, program: WebGLProgram, geometry: BufferGeometry, index: BufferAttribute): void; + reset(): void; + resetDefaultState(): void; + dispose(): void; + releaseStatesOfGeometry(): void; + releaseStatesOfProgram(): void; + initAttributes(): void; + enableAttribute(attribute: number): void; + disableUnusedAttributes(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLBindingStates.js b/backend/libs/three/renderers/webgl/WebGLBindingStates.js new file mode 100644 index 0000000000000000000000000000000000000000..49a30f11996141dcb1d8420c0ff69a859d077fc2 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLBindingStates.js @@ -0,0 +1,446 @@ +function WebGLBindingStates(gl, extensions, attributes, capabilities) { + const maxVertexAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); + + const extension = capabilities.isWebGL2 ? null : extensions.get('OES_vertex_array_object'); + const vaoAvailable = capabilities.isWebGL2 || extension !== null; + + const bindingStates = {}; + + const defaultState = createBindingState(null); + let currentState = defaultState; + + function setup(object, material, program, geometry, index) { + let updateBuffers = false; + + if (vaoAvailable) { + const state = getBindingState(geometry, program, material); + + if (currentState !== state) { + currentState = state; + bindVertexArrayObject(currentState.object); + } + + updateBuffers = needsUpdate(geometry, index); + + if (updateBuffers) saveCache(geometry, index); + } else { + const wireframe = material.wireframe === true; + + if (currentState.geometry !== geometry.id || currentState.program !== program.id || currentState.wireframe !== wireframe) { + currentState.geometry = geometry.id; + currentState.program = program.id; + currentState.wireframe = wireframe; + + updateBuffers = true; + } + } + + if (object.isInstancedMesh === true) { + updateBuffers = true; + } + + if (index !== null) { + attributes.update(index, gl.ELEMENT_ARRAY_BUFFER); + } + + if (updateBuffers) { + setupVertexAttributes(object, material, program, geometry); + + if (index !== null) { + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, attributes.get(index).buffer); + } + } + } + + function createVertexArrayObject() { + if (capabilities.isWebGL2) return gl.createVertexArray(); + + return extension.createVertexArrayOES(); + } + + function bindVertexArrayObject(vao) { + if (capabilities.isWebGL2) return gl.bindVertexArray(vao); + + return extension.bindVertexArrayOES(vao); + } + + function deleteVertexArrayObject(vao) { + if (capabilities.isWebGL2) return gl.deleteVertexArray(vao); + + return extension.deleteVertexArrayOES(vao); + } + + function getBindingState(geometry, program, material) { + const wireframe = material.wireframe === true; + + let programMap = bindingStates[geometry.id]; + + if (programMap === undefined) { + programMap = {}; + bindingStates[geometry.id] = programMap; + } + + let stateMap = programMap[program.id]; + + if (stateMap === undefined) { + stateMap = {}; + programMap[program.id] = stateMap; + } + + let state = stateMap[wireframe]; + + if (state === undefined) { + state = createBindingState(createVertexArrayObject()); + stateMap[wireframe] = state; + } + + return state; + } + + function createBindingState(vao) { + const newAttributes = []; + const enabledAttributes = []; + const attributeDivisors = []; + + for (let i = 0; i < maxVertexAttributes; i++) { + newAttributes[i] = 0; + enabledAttributes[i] = 0; + attributeDivisors[i] = 0; + } + + return { + // for backward compatibility on non-VAO support browser + geometry: null, + program: null, + wireframe: false, + + newAttributes: newAttributes, + enabledAttributes: enabledAttributes, + attributeDivisors: attributeDivisors, + object: vao, + attributes: {}, + index: null, + }; + } + + function needsUpdate(geometry, index) { + const cachedAttributes = currentState.attributes; + const geometryAttributes = geometry.attributes; + + let attributesNum = 0; + + for (const key in geometryAttributes) { + const cachedAttribute = cachedAttributes[key]; + const geometryAttribute = geometryAttributes[key]; + + if (cachedAttribute === undefined) return true; + + if (cachedAttribute.attribute !== geometryAttribute) return true; + + if (cachedAttribute.data !== geometryAttribute.data) return true; + + attributesNum++; + } + + if (currentState.attributesNum !== attributesNum) return true; + + if (currentState.index !== index) return true; + + return false; + } + + function saveCache(geometry, index) { + const cache = {}; + const attributes = geometry.attributes; + let attributesNum = 0; + + for (const key in attributes) { + const attribute = attributes[key]; + + const data = {}; + data.attribute = attribute; + + if (attribute.data) { + data.data = attribute.data; + } + + cache[key] = data; + + attributesNum++; + } + + currentState.attributes = cache; + currentState.attributesNum = attributesNum; + + currentState.index = index; + } + + function initAttributes() { + const newAttributes = currentState.newAttributes; + + for (let i = 0, il = newAttributes.length; i < il; i++) { + newAttributes[i] = 0; + } + } + + function enableAttribute(attribute) { + enableAttributeAndDivisor(attribute, 0); + } + + function enableAttributeAndDivisor(attribute, meshPerAttribute) { + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + const attributeDivisors = currentState.attributeDivisors; + + newAttributes[attribute] = 1; + + if (enabledAttributes[attribute] === 0) { + gl.enableVertexAttribArray(attribute); + enabledAttributes[attribute] = 1; + } + + if (attributeDivisors[attribute] !== meshPerAttribute) { + const extension = capabilities.isWebGL2 ? gl : extensions.get('ANGLE_instanced_arrays'); + + extension[capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE'](attribute, meshPerAttribute); + attributeDivisors[attribute] = meshPerAttribute; + } + } + + function disableUnusedAttributes() { + const newAttributes = currentState.newAttributes; + const enabledAttributes = currentState.enabledAttributes; + + for (let i = 0, il = enabledAttributes.length; i < il; i++) { + if (enabledAttributes[i] !== newAttributes[i]) { + gl.disableVertexAttribArray(i); + enabledAttributes[i] = 0; + } + } + } + + function vertexAttribPointer(index, size, type, normalized, stride, offset) { + if (capabilities.isWebGL2 === true && (type === gl.INT || type === gl.UNSIGNED_INT)) { + gl.vertexAttribIPointer(index, size, type, stride, offset); + } else { + gl.vertexAttribPointer(index, size, type, normalized, stride, offset); + } + } + + function setupVertexAttributes(object, material, program, geometry) { + if (capabilities.isWebGL2 === false && (object.isInstancedMesh || geometry.isInstancedBufferGeometry)) { + if (extensions.get('ANGLE_instanced_arrays') === null) return; + } + + initAttributes(); + + const geometryAttributes = geometry.attributes; + + const programAttributes = program.getAttributes(); + + const materialDefaultAttributeValues = material.defaultAttributeValues; + + for (const name in programAttributes) { + const programAttribute = programAttributes[name]; + + if (programAttribute.location >= 0) { + let geometryAttribute = geometryAttributes[name]; + + if (geometryAttribute === undefined) { + if (name === 'instanceMatrix' && object.instanceMatrix) geometryAttribute = object.instanceMatrix; + if (name === 'instanceColor' && object.instanceColor) geometryAttribute = object.instanceColor; + } + + if (geometryAttribute !== undefined) { + const normalized = geometryAttribute.normalized; + const size = geometryAttribute.itemSize; + + const attribute = attributes.get(geometryAttribute); + + // TODO Attribute may not be available on context restore + + if (attribute === undefined) continue; + + const buffer = attribute.buffer; + const type = attribute.type; + const bytesPerElement = attribute.bytesPerElement; + + if (geometryAttribute.isInterleavedBufferAttribute) { + const data = geometryAttribute.data; + const stride = data.stride; + const offset = geometryAttribute.offset; + + if (data && data.isInstancedInterleavedBuffer) { + for (let i = 0; i < programAttribute.locationSize; i++) { + enableAttributeAndDivisor(programAttribute.location + i, data.meshPerAttribute); + } + + if (object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined) { + geometry._maxInstanceCount = data.meshPerAttribute * data.count; + } + } else { + for (let i = 0; i < programAttribute.locationSize; i++) { + enableAttribute(programAttribute.location + i); + } + } + + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + + for (let i = 0; i < programAttribute.locationSize; i++) { + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + stride * bytesPerElement, + (offset + (size / programAttribute.locationSize) * i) * bytesPerElement + ); + } + } else { + if (geometryAttribute.isInstancedBufferAttribute) { + for (let i = 0; i < programAttribute.locationSize; i++) { + enableAttributeAndDivisor(programAttribute.location + i, geometryAttribute.meshPerAttribute); + } + + if (object.isInstancedMesh !== true && geometry._maxInstanceCount === undefined) { + geometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count; + } + } else { + for (let i = 0; i < programAttribute.locationSize; i++) { + enableAttribute(programAttribute.location + i); + } + } + + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + + for (let i = 0; i < programAttribute.locationSize; i++) { + vertexAttribPointer( + programAttribute.location + i, + size / programAttribute.locationSize, + type, + normalized, + size * bytesPerElement, + (size / programAttribute.locationSize) * i * bytesPerElement + ); + } + } + } else if (materialDefaultAttributeValues !== undefined) { + const value = materialDefaultAttributeValues[name]; + + if (value !== undefined) { + switch (value.length) { + case 2: + gl.vertexAttrib2fv(programAttribute.location, value); + break; + + case 3: + gl.vertexAttrib3fv(programAttribute.location, value); + break; + + case 4: + gl.vertexAttrib4fv(programAttribute.location, value); + break; + + default: + gl.vertexAttrib1fv(programAttribute.location, value); + } + } + } + } + } + + disableUnusedAttributes(); + } + + function dispose() { + reset(); + + for (const geometryId in bindingStates) { + const programMap = bindingStates[geometryId]; + + for (const programId in programMap) { + const stateMap = programMap[programId]; + + for (const wireframe in stateMap) { + deleteVertexArrayObject(stateMap[wireframe].object); + + delete stateMap[wireframe]; + } + + delete programMap[programId]; + } + + delete bindingStates[geometryId]; + } + } + + function releaseStatesOfGeometry(geometry) { + if (bindingStates[geometry.id] === undefined) return; + + const programMap = bindingStates[geometry.id]; + + for (const programId in programMap) { + const stateMap = programMap[programId]; + + for (const wireframe in stateMap) { + deleteVertexArrayObject(stateMap[wireframe].object); + + delete stateMap[wireframe]; + } + + delete programMap[programId]; + } + + delete bindingStates[geometry.id]; + } + + function releaseStatesOfProgram(program) { + for (const geometryId in bindingStates) { + const programMap = bindingStates[geometryId]; + + if (programMap[program.id] === undefined) continue; + + const stateMap = programMap[program.id]; + + for (const wireframe in stateMap) { + deleteVertexArrayObject(stateMap[wireframe].object); + + delete stateMap[wireframe]; + } + + delete programMap[program.id]; + } + } + + function reset() { + resetDefaultState(); + + if (currentState === defaultState) return; + + currentState = defaultState; + bindVertexArrayObject(currentState.object); + } + + // for backward-compatilibity + + function resetDefaultState() { + defaultState.geometry = null; + defaultState.program = null; + defaultState.wireframe = false; + } + + return { + setup: setup, + reset: reset, + resetDefaultState: resetDefaultState, + dispose: dispose, + releaseStatesOfGeometry: releaseStatesOfGeometry, + releaseStatesOfProgram: releaseStatesOfProgram, + + initAttributes: initAttributes, + enableAttribute: enableAttribute, + disableUnusedAttributes: disableUnusedAttributes, + }; +} + +export { WebGLBindingStates }; diff --git a/backend/libs/three/renderers/webgl/WebGLBufferRenderer.d.ts b/backend/libs/three/renderers/webgl/WebGLBufferRenderer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0be12edf0ed97476a48f5450bff2d5854e36fec6 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLBufferRenderer.d.ts @@ -0,0 +1,12 @@ +// Renderers / WebGL ///////////////////////////////////////////////////////////////////// +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLInfo } from './WebGLInfo'; +import { WebGLCapabilities } from './WebGLCapabilities'; + +export class WebGLBufferRenderer { + constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions, info: WebGLInfo, capabilities: WebGLCapabilities); + + setMode(value: any): void; + render(start: any, count: number): void; + renderInstances(start: any, count: number, primcount: number): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLBufferRenderer.js b/backend/libs/three/renderers/webgl/WebGLBufferRenderer.js new file mode 100644 index 0000000000000000000000000000000000000000..91def19b40720f90bb134256c4400fc19c6d5dba --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLBufferRenderer.js @@ -0,0 +1,46 @@ +function WebGLBufferRenderer(gl, extensions, info, capabilities) { + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode(value) { + mode = value; + } + + function render(start, count) { + gl.drawArrays(mode, start, count); + + info.update(count, mode, 1); + } + + function renderInstances(start, count, primcount) { + if (primcount === 0) return; + + let extension, methodName; + + if (isWebGL2) { + extension = gl; + methodName = 'drawArraysInstanced'; + } else { + extension = extensions.get('ANGLE_instanced_arrays'); + methodName = 'drawArraysInstancedANGLE'; + + if (extension === null) { + console.error('THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.'); + return; + } + } + + extension[methodName](mode, start, count, primcount); + + info.update(count, mode, primcount); + } + + // + + this.setMode = setMode; + this.render = render; + this.renderInstances = renderInstances; +} + +export { WebGLBufferRenderer }; diff --git a/backend/libs/three/renderers/webgl/WebGLCapabilities.d.ts b/backend/libs/three/renderers/webgl/WebGLCapabilities.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..811a68a7276722ff30c9d85c90825c49653737bd --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCapabilities.d.ts @@ -0,0 +1,26 @@ +export interface WebGLCapabilitiesParameters { + precision?: string | undefined; + logarithmicDepthBuffer?: boolean | undefined; +} + +export class WebGLCapabilities { + constructor(gl: WebGLRenderingContext, extensions: any, parameters: WebGLCapabilitiesParameters); + + readonly isWebGL2: boolean; + precision: string; + logarithmicDepthBuffer: boolean; + maxTextures: number; + maxVertexTextures: number; + maxTextureSize: number; + maxCubemapSize: number; + maxAttributes: number; + maxVertexUniforms: number; + maxVaryings: number; + maxFragmentUniforms: number; + vertexTextures: boolean; + floatFragmentTextures: boolean; + floatVertexTextures: boolean; + + getMaxAnisotropy(): number; + getMaxPrecision(precision: string): string; +} diff --git a/backend/libs/three/renderers/webgl/WebGLCapabilities.js b/backend/libs/three/renderers/webgl/WebGLCapabilities.js new file mode 100644 index 0000000000000000000000000000000000000000..39459ab30988211adef448b6b59924ef67ce2115 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCapabilities.js @@ -0,0 +1,103 @@ +function WebGLCapabilities(gl, extensions, parameters) { + let maxAnisotropy; + + function getMaxAnisotropy() { + if (maxAnisotropy !== undefined) return maxAnisotropy; + + if (extensions.has('EXT_texture_filter_anisotropic') === true) { + const extension = extensions.get('EXT_texture_filter_anisotropic'); + + maxAnisotropy = gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT); + } else { + maxAnisotropy = 0; + } + + return maxAnisotropy; + } + + function getMaxPrecision(precision) { + if (precision === 'highp') { + if ( + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT).precision > 0 && + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT).precision > 0 + ) { + return 'highp'; + } + + precision = 'mediump'; + } + + if (precision === 'mediump') { + if ( + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).precision > 0 && + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT).precision > 0 + ) { + return 'mediump'; + } + } + + return 'lowp'; + } + + const isWebGL2 = + (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) || + (typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext); + + let precision = parameters.precision !== undefined ? parameters.precision : 'highp'; + const maxPrecision = getMaxPrecision(precision); + + if (maxPrecision !== precision) { + console.warn('THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.'); + precision = maxPrecision; + } + + const drawBuffers = isWebGL2 || extensions.has('WEBGL_draw_buffers'); + + const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true; + + const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS); + const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + const maxCubemapSize = gl.getParameter(gl.MAX_CUBE_MAP_TEXTURE_SIZE); + + const maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); + const maxVertexUniforms = gl.getParameter(gl.MAX_VERTEX_UNIFORM_VECTORS); + const maxVaryings = gl.getParameter(gl.MAX_VARYING_VECTORS); + const maxFragmentUniforms = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS); + + const vertexTextures = maxVertexTextures > 0; + const floatFragmentTextures = isWebGL2 || extensions.has('OES_texture_float'); + const floatVertexTextures = vertexTextures && floatFragmentTextures; + + const maxSamples = isWebGL2 ? gl.getParameter(gl.MAX_SAMPLES) : 0; + + return { + isWebGL2: isWebGL2, + + drawBuffers: drawBuffers, + + getMaxAnisotropy: getMaxAnisotropy, + getMaxPrecision: getMaxPrecision, + + precision: precision, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + maxTextures: maxTextures, + maxVertexTextures: maxVertexTextures, + maxTextureSize: maxTextureSize, + maxCubemapSize: maxCubemapSize, + + maxAttributes: maxAttributes, + maxVertexUniforms: maxVertexUniforms, + maxVaryings: maxVaryings, + maxFragmentUniforms: maxFragmentUniforms, + + vertexTextures: vertexTextures, + floatFragmentTextures: floatFragmentTextures, + floatVertexTextures: floatVertexTextures, + + maxSamples: maxSamples, + }; +} + +export { WebGLCapabilities }; diff --git a/backend/libs/three/renderers/webgl/WebGLClipping.d.ts b/backend/libs/three/renderers/webgl/WebGLClipping.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..938f3a2ab4efd05b9ea267263a40af59bc6139ac --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLClipping.d.ts @@ -0,0 +1,24 @@ +import { Camera } from './../../cameras/Camera'; +import { Material } from './../../materials/Material'; +import { WebGLProperties } from './WebGLProperties'; + +export class WebGLClipping { + constructor(properties: WebGLProperties); + + uniform: { value: any; needsUpdate: boolean }; + + /** + * @default 0 + */ + numPlanes: number; + + /** + * @default 0 + */ + numIntersection: number; + + init(planes: any[], enableLocalClipping: boolean, camera: Camera): boolean; + beginShadows(): void; + endShadows(): void; + setState(material: Material, camera: Camera, useCache: boolean): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLClipping.js b/backend/libs/three/renderers/webgl/WebGLClipping.js new file mode 100644 index 0000000000000000000000000000000000000000..d184b2219d0feac6a1e4ef78b588ee1aa1490265 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLClipping.js @@ -0,0 +1,130 @@ +import { Matrix3 } from '../../math/Matrix3.js'; +import { Plane } from '../../math/Plane.js'; + +function WebGLClipping(properties) { + const scope = this; + + let globalState = null, + numGlobalPlanes = 0, + localClippingEnabled = false, + renderingShadows = false; + + const plane = new Plane(), + viewNormalMatrix = new Matrix3(), + uniform = { value: null, needsUpdate: false }; + + this.uniform = uniform; + this.numPlanes = 0; + this.numIntersection = 0; + + this.init = function (planes, enableLocalClipping, camera) { + const enabled = + planes.length !== 0 || + enableLocalClipping || + // enable state of previous frame - the clipping code has to + // run another frame in order to reset the state: + numGlobalPlanes !== 0 || + localClippingEnabled; + + localClippingEnabled = enableLocalClipping; + + globalState = projectPlanes(planes, camera, 0); + numGlobalPlanes = planes.length; + + return enabled; + }; + + this.beginShadows = function () { + renderingShadows = true; + projectPlanes(null); + }; + + this.endShadows = function () { + renderingShadows = false; + resetGlobalState(); + }; + + this.setState = function (material, camera, useCache) { + const planes = material.clippingPlanes, + clipIntersection = material.clipIntersection, + clipShadows = material.clipShadows; + + const materialProperties = properties.get(material); + + if (!localClippingEnabled || planes === null || planes.length === 0 || (renderingShadows && !clipShadows)) { + // there's no local clipping + + if (renderingShadows) { + // there's no global clipping + + projectPlanes(null); + } else { + resetGlobalState(); + } + } else { + const nGlobal = renderingShadows ? 0 : numGlobalPlanes, + lGlobal = nGlobal * 4; + + let dstArray = materialProperties.clippingState || null; + + uniform.value = dstArray; // ensure unique state + + dstArray = projectPlanes(planes, camera, lGlobal, useCache); + + for (let i = 0; i !== lGlobal; ++i) { + dstArray[i] = globalState[i]; + } + + materialProperties.clippingState = dstArray; + this.numIntersection = clipIntersection ? this.numPlanes : 0; + this.numPlanes += nGlobal; + } + }; + + function resetGlobalState() { + if (uniform.value !== globalState) { + uniform.value = globalState; + uniform.needsUpdate = numGlobalPlanes > 0; + } + + scope.numPlanes = numGlobalPlanes; + scope.numIntersection = 0; + } + + function projectPlanes(planes, camera, dstOffset, skipTransform) { + const nPlanes = planes !== null ? planes.length : 0; + let dstArray = null; + + if (nPlanes !== 0) { + dstArray = uniform.value; + + if (skipTransform !== true || dstArray === null) { + const flatSize = dstOffset + nPlanes * 4, + viewMatrix = camera.matrixWorldInverse; + + viewNormalMatrix.getNormalMatrix(viewMatrix); + + if (dstArray === null || dstArray.length < flatSize) { + dstArray = new Float32Array(flatSize); + } + + for (let i = 0, i4 = dstOffset; i !== nPlanes; ++i, i4 += 4) { + plane.copy(planes[i]).applyMatrix4(viewMatrix, viewNormalMatrix); + + plane.normal.toArray(dstArray, i4); + dstArray[i4 + 3] = plane.constant; + } + } + + uniform.value = dstArray; + uniform.needsUpdate = true; + } + + scope.numPlanes = nPlanes; + scope.numIntersection = 0; + + return dstArray; + } +} + +export { WebGLClipping }; diff --git a/backend/libs/three/renderers/webgl/WebGLCubeMaps.d.ts b/backend/libs/three/renderers/webgl/WebGLCubeMaps.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..be1ba34e0b704e9cac2cfe303516be78a8219fb6 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCubeMaps.d.ts @@ -0,0 +1,8 @@ +import { WebGLRenderer } from '../WebGLRenderer'; + +export class WebGLCubeMaps { + constructor(renderer: WebGLRenderer); + + get(texture: any): any; + dispose(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLCubeMaps.js b/backend/libs/three/renderers/webgl/WebGLCubeMaps.js new file mode 100644 index 0000000000000000000000000000000000000000..65fd3975cc47275b3a0507b9ab6a0f1605cc7ded --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCubeMaps.js @@ -0,0 +1,71 @@ +import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js'; +import { WebGLCubeRenderTarget } from '../WebGLCubeRenderTarget.js'; + +function WebGLCubeMaps(renderer) { + let cubemaps = new WeakMap(); + + function mapTextureMapping(texture, mapping) { + if (mapping === EquirectangularReflectionMapping) { + texture.mapping = CubeReflectionMapping; + } else if (mapping === EquirectangularRefractionMapping) { + texture.mapping = CubeRefractionMapping; + } + + return texture; + } + + function get(texture) { + if (texture && texture.isTexture && texture.isRenderTargetTexture === false) { + const mapping = texture.mapping; + + if (mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping) { + if (cubemaps.has(texture)) { + const cubemap = cubemaps.get(texture).texture; + return mapTextureMapping(cubemap, texture.mapping); + } else { + const image = texture.image; + + if (image && image.height > 0) { + const renderTarget = new WebGLCubeRenderTarget(image.height / 2); + renderTarget.fromEquirectangularTexture(renderer, texture); + cubemaps.set(texture, renderTarget); + + texture.addEventListener('dispose', onTextureDispose); + + return mapTextureMapping(renderTarget.texture, texture.mapping); + } else { + // image not yet ready. try the conversion next frame + + return null; + } + } + } + } + + return texture; + } + + function onTextureDispose(event) { + const texture = event.target; + + texture.removeEventListener('dispose', onTextureDispose); + + const cubemap = cubemaps.get(texture); + + if (cubemap !== undefined) { + cubemaps.delete(texture); + cubemap.dispose(); + } + } + + function dispose() { + cubemaps = new WeakMap(); + } + + return { + get: get, + dispose: dispose, + }; +} + +export { WebGLCubeMaps }; diff --git a/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.d.ts b/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3f9babc325eade175e333ac3677dff308593a956 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.d.ts @@ -0,0 +1,8 @@ +import { WebGLRenderer, Texture } from '../../Three'; + +export class WebGLCubeUVMaps { + constructor(renderer: WebGLRenderer); + + get(texture: T): T extends Texture ? Texture : T; + dispose(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.js b/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.js new file mode 100644 index 0000000000000000000000000000000000000000..9bac13328502813f0d537bd228da8da88d6dfc35 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLCubeUVMaps.js @@ -0,0 +1,99 @@ +import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js'; +import { PMREMGenerator } from '../../extras/PMREMGenerator.js'; + +function WebGLCubeUVMaps(renderer) { + let cubeUVmaps = new WeakMap(); + + let pmremGenerator = null; + + function get(texture) { + if (texture && texture.isTexture) { + const mapping = texture.mapping; + + const isEquirectMap = mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping; + const isCubeMap = mapping === CubeReflectionMapping || mapping === CubeRefractionMapping; + + // equirect/cube map to cubeUV conversion + + if (isEquirectMap || isCubeMap) { + if (texture.isRenderTargetTexture && texture.needsPMREMUpdate === true) { + texture.needsPMREMUpdate = false; + + let renderTarget = cubeUVmaps.get(texture); + + if (pmremGenerator === null) pmremGenerator = new PMREMGenerator(renderer); + + renderTarget = isEquirectMap + ? pmremGenerator.fromEquirectangular(texture, renderTarget) + : pmremGenerator.fromCubemap(texture, renderTarget); + cubeUVmaps.set(texture, renderTarget); + + return renderTarget.texture; + } else { + if (cubeUVmaps.has(texture)) { + return cubeUVmaps.get(texture).texture; + } else { + const image = texture.image; + + if ((isEquirectMap && image && image.height > 0) || (isCubeMap && image && isCubeTextureComplete(image))) { + if (pmremGenerator === null) pmremGenerator = new PMREMGenerator(renderer); + + const renderTarget = isEquirectMap ? pmremGenerator.fromEquirectangular(texture) : pmremGenerator.fromCubemap(texture); + cubeUVmaps.set(texture, renderTarget); + + texture.addEventListener('dispose', onTextureDispose); + + return renderTarget.texture; + } else { + // image not yet ready. try the conversion next frame + + return null; + } + } + } + } + } + + return texture; + } + + function isCubeTextureComplete(image) { + let count = 0; + const length = 6; + + for (let i = 0; i < length; i++) { + if (image[i] !== undefined) count++; + } + + return count === length; + } + + function onTextureDispose(event) { + const texture = event.target; + + texture.removeEventListener('dispose', onTextureDispose); + + const cubemapUV = cubeUVmaps.get(texture); + + if (cubemapUV !== undefined) { + cubeUVmaps.delete(texture); + cubemapUV.dispose(); + } + } + + function dispose() { + cubeUVmaps = new WeakMap(); + + if (pmremGenerator !== null) { + pmremGenerator.dispose(); + pmremGenerator = null; + } + } + + return { + get: get, + dispose: dispose, + }; +} + +export { WebGLCubeUVMaps }; diff --git a/backend/libs/three/renderers/webgl/WebGLExtensions.d.ts b/backend/libs/three/renderers/webgl/WebGLExtensions.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4e6ce80a9edaf8c3ac54e28770ad2b4ddc2672d4 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLExtensions.d.ts @@ -0,0 +1,9 @@ +import { WebGLCapabilities } from './WebGLCapabilities'; + +export class WebGLExtensions { + constructor(gl: WebGLRenderingContext); + + has(name: string): boolean; + init(capabilities: WebGLCapabilities): void; + get(name: string): any; +} diff --git a/backend/libs/three/renderers/webgl/WebGLExtensions.js b/backend/libs/three/renderers/webgl/WebGLExtensions.js new file mode 100644 index 0000000000000000000000000000000000000000..6b537bbde91c60a97429b4d8249265744c64c7ad --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLExtensions.js @@ -0,0 +1,80 @@ +function WebGLExtensions(gl) { + const extensions = {}; + + function getExtension(name) { + if (extensions[name] !== undefined) { + return extensions[name]; + } + + let extension; + + switch (name) { + case 'WEBGL_depth_texture': + extension = + gl.getExtension('WEBGL_depth_texture') || gl.getExtension('MOZ_WEBGL_depth_texture') || gl.getExtension('WEBKIT_WEBGL_depth_texture'); + break; + + case 'EXT_texture_filter_anisotropic': + extension = + gl.getExtension('EXT_texture_filter_anisotropic') || + gl.getExtension('MOZ_EXT_texture_filter_anisotropic') || + gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic'); + break; + + case 'WEBGL_compressed_texture_s3tc': + extension = + gl.getExtension('WEBGL_compressed_texture_s3tc') || + gl.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || + gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'); + break; + + case 'WEBGL_compressed_texture_pvrtc': + extension = gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); + break; + + default: + extension = gl.getExtension(name); + } + + extensions[name] = extension; + + return extension; + } + + return { + has: function (name) { + return getExtension(name) !== null; + }, + + init: function (capabilities) { + if (capabilities.isWebGL2) { + getExtension('EXT_color_buffer_float'); + } else { + getExtension('WEBGL_depth_texture'); + getExtension('OES_texture_float'); + getExtension('OES_texture_half_float'); + getExtension('OES_texture_half_float_linear'); + getExtension('OES_standard_derivatives'); + getExtension('OES_element_index_uint'); + getExtension('OES_vertex_array_object'); + getExtension('ANGLE_instanced_arrays'); + } + + getExtension('OES_texture_float_linear'); + getExtension('EXT_color_buffer_half_float'); + getExtension('WEBGL_multisampled_render_to_texture'); + }, + + get: function (name) { + const extension = getExtension(name); + + if (extension === null) { + console.warn('THREE.WebGLRenderer: ' + name + ' extension not supported.'); + } + + return extension; + }, + }; +} + +export { WebGLExtensions }; diff --git a/backend/libs/three/renderers/webgl/WebGLGeometries.d.ts b/backend/libs/three/renderers/webgl/WebGLGeometries.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..ea6f139828762473ae71bd564077a1cb96ac909b --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLGeometries.d.ts @@ -0,0 +1,13 @@ +import { WebGLAttributes } from './WebGLAttributes'; +import { WebGLInfo } from './WebGLInfo'; +import { BufferAttribute } from '../../core/BufferAttribute'; +import { BufferGeometry } from '../../core/BufferGeometry'; +import { Object3D } from '../../core/Object3D'; + +export class WebGLGeometries { + constructor(gl: WebGLRenderingContext, attributes: WebGLAttributes, info: WebGLInfo); + + get(object: Object3D, geometry: BufferGeometry): BufferGeometry; + update(geometry: BufferGeometry): void; + getWireframeAttribute(geometry: BufferGeometry): BufferAttribute; +} diff --git a/backend/libs/three/renderers/webgl/WebGLGeometries.js b/backend/libs/three/renderers/webgl/WebGLGeometries.js new file mode 100644 index 0000000000000000000000000000000000000000..15672ed900b15f297dbb293e0c339abf862c3045 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLGeometries.js @@ -0,0 +1,150 @@ +import { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js'; +import { arrayMax } from '../../utils.js'; + +function WebGLGeometries(gl, attributes, info, bindingStates) { + const geometries = {}; + const wireframeAttributes = new WeakMap(); + + function onGeometryDispose(event) { + const geometry = event.target; + + if (geometry.index !== null) { + attributes.remove(geometry.index); + } + + for (const name in geometry.attributes) { + attributes.remove(geometry.attributes[name]); + } + + geometry.removeEventListener('dispose', onGeometryDispose); + + delete geometries[geometry.id]; + + const attribute = wireframeAttributes.get(geometry); + + if (attribute) { + attributes.remove(attribute); + wireframeAttributes.delete(geometry); + } + + bindingStates.releaseStatesOfGeometry(geometry); + + if (geometry.isInstancedBufferGeometry === true) { + delete geometry._maxInstanceCount; + } + + // + + info.memory.geometries--; + } + + function get(object, geometry) { + if (geometries[geometry.id] === true) return geometry; + + geometry.addEventListener('dispose', onGeometryDispose); + + geometries[geometry.id] = true; + + info.memory.geometries++; + + return geometry; + } + + function update(geometry) { + const geometryAttributes = geometry.attributes; + + // Updating index buffer in VAO now. See WebGLBindingStates. + + for (const name in geometryAttributes) { + attributes.update(geometryAttributes[name], gl.ARRAY_BUFFER); + } + + // morph targets + + const morphAttributes = geometry.morphAttributes; + + for (const name in morphAttributes) { + const array = morphAttributes[name]; + + for (let i = 0, l = array.length; i < l; i++) { + attributes.update(array[i], gl.ARRAY_BUFFER); + } + } + } + + function updateWireframeAttribute(geometry) { + const indices = []; + + const geometryIndex = geometry.index; + const geometryPosition = geometry.attributes.position; + let version = 0; + + if (geometryIndex !== null) { + const array = geometryIndex.array; + version = geometryIndex.version; + + for (let i = 0, l = array.length; i < l; i += 3) { + const a = array[i + 0]; + const b = array[i + 1]; + const c = array[i + 2]; + + indices.push(a, b, b, c, c, a); + } + } else { + const array = geometryPosition.array; + version = geometryPosition.version; + + for (let i = 0, l = array.length / 3 - 1; i < l; i += 3) { + const a = i + 0; + const b = i + 1; + const c = i + 2; + + indices.push(a, b, b, c, c, a); + } + } + + const attribute = new (arrayMax(indices) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1); + attribute.version = version; + + // Updating index buffer in VAO now. See WebGLBindingStates + + // + + const previousAttribute = wireframeAttributes.get(geometry); + + if (previousAttribute) attributes.remove(previousAttribute); + + // + + wireframeAttributes.set(geometry, attribute); + } + + function getWireframeAttribute(geometry) { + const currentAttribute = wireframeAttributes.get(geometry); + + if (currentAttribute) { + const geometryIndex = geometry.index; + + if (geometryIndex !== null) { + // if the attribute is obsolete, create a new one + + if (currentAttribute.version < geometryIndex.version) { + updateWireframeAttribute(geometry); + } + } + } else { + updateWireframeAttribute(geometry); + } + + return wireframeAttributes.get(geometry); + } + + return { + get: get, + update: update, + + getWireframeAttribute: getWireframeAttribute, + }; +} + +export { WebGLGeometries }; diff --git a/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.d.ts b/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..81a2eab55629bb4075f59c35e52fd238d6c94efb --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.d.ts @@ -0,0 +1,8 @@ +export class WebGLIndexedBufferRenderer { + constructor(gl: WebGLRenderingContext, extensions: any, info: any, capabilities: any); + + setMode(value: any): void; + setIndex(index: any): void; + render(start: any, count: number): void; + renderInstances(start: any, count: number, primcount: number): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.js b/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.js new file mode 100644 index 0000000000000000000000000000000000000000..c4a40ade35f3ee9f23c993e4ea00435cdbbb46c8 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLIndexedBufferRenderer.js @@ -0,0 +1,56 @@ +function WebGLIndexedBufferRenderer(gl, extensions, info, capabilities) { + const isWebGL2 = capabilities.isWebGL2; + + let mode; + + function setMode(value) { + mode = value; + } + + let type, bytesPerElement; + + function setIndex(value) { + type = value.type; + bytesPerElement = value.bytesPerElement; + } + + function render(start, count) { + gl.drawElements(mode, count, type, start * bytesPerElement); + + info.update(count, mode, 1); + } + + function renderInstances(start, count, primcount) { + if (primcount === 0) return; + + let extension, methodName; + + if (isWebGL2) { + extension = gl; + methodName = 'drawElementsInstanced'; + } else { + extension = extensions.get('ANGLE_instanced_arrays'); + methodName = 'drawElementsInstancedANGLE'; + + if (extension === null) { + console.error( + 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' + ); + return; + } + } + + extension[methodName](mode, count, type, start * bytesPerElement, primcount); + + info.update(count, mode, primcount); + } + + // + + this.setMode = setMode; + this.setIndex = setIndex; + this.render = render; + this.renderInstances = renderInstances; +} + +export { WebGLIndexedBufferRenderer }; diff --git a/backend/libs/three/renderers/webgl/WebGLInfo.d.ts b/backend/libs/three/renderers/webgl/WebGLInfo.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..57d9d7d3d1a446d004f86facc1b773e57d0cd7ce --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLInfo.d.ts @@ -0,0 +1,39 @@ +import { WebGLProgram } from './WebGLProgram'; + +/** + * An object with a series of statistical information about the graphics board memory and the rendering process. + */ +export class WebGLInfo { + constructor(gl: WebGLRenderingContext); + + /** + * @default true + */ + autoReset: boolean; + + /** + * @default { geometries: 0, textures: 0 } + */ + memory: { + geometries: number; + textures: number; + }; + + /** + * @default null + */ + programs: WebGLProgram[] | null; + + /** + * @default { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 } + */ + render: { + calls: number; + frame: number; + lines: number; + points: number; + triangles: number; + }; + update(count: number, mode: number, instanceCount: number): void; + reset(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLInfo.js b/backend/libs/three/renderers/webgl/WebGLInfo.js new file mode 100644 index 0000000000000000000000000000000000000000..c678958e3c31d23d7834996ccedd4faf97b63010 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLInfo.js @@ -0,0 +1,63 @@ +function WebGLInfo(gl) { + const memory = { + geometries: 0, + textures: 0, + }; + + const render = { + frame: 0, + calls: 0, + triangles: 0, + points: 0, + lines: 0, + }; + + function update(count, mode, instanceCount) { + render.calls++; + + switch (mode) { + case gl.TRIANGLES: + render.triangles += instanceCount * (count / 3); + break; + + case gl.LINES: + render.lines += instanceCount * (count / 2); + break; + + case gl.LINE_STRIP: + render.lines += instanceCount * (count - 1); + break; + + case gl.LINE_LOOP: + render.lines += instanceCount * count; + break; + + case gl.POINTS: + render.points += instanceCount * count; + break; + + default: + console.error('THREE.WebGLInfo: Unknown draw mode:', mode); + break; + } + } + + function reset() { + render.frame++; + render.calls = 0; + render.triangles = 0; + render.points = 0; + render.lines = 0; + } + + return { + memory: memory, + render: render, + programs: null, + autoReset: true, + reset: reset, + update: update, + }; +} + +export { WebGLInfo }; diff --git a/backend/libs/three/renderers/webgl/WebGLLights.d.ts b/backend/libs/three/renderers/webgl/WebGLLights.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b150643354471ff7ec0cca533a39a821ffc50a79 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLLights.d.ts @@ -0,0 +1,43 @@ +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLCapabilities } from './WebGLCapabilities'; + +export class WebGLLights { + constructor(extensions: WebGLExtensions, capabilities: WebGLCapabilities); + + state: { + version: number; + + hash: { + directionalLength: number; + pointLength: number; + spotLength: number; + rectAreaLength: number; + hemiLength: number; + + numDirectionalShadows: number; + numPointShadows: number; + numSpotShadows: number; + }; + + ambient: number[]; + probe: any[]; + directional: any[]; + directionalShadow: any[]; + directionalShadowMap: any[]; + directionalShadowMatrix: any[]; + spot: any[]; + spotShadow: any[]; + spotShadowMap: any[]; + spotShadowMatrix: any[]; + rectArea: any[]; + point: any[]; + pointShadow: any[]; + pointShadowMap: any[]; + pointShadowMatrix: any[]; + hemi: any[]; + }; + + get(light: any): any; + setup(lights: any): void; + setupView(lights: any, camera: any): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLLights.js b/backend/libs/three/renderers/webgl/WebGLLights.js new file mode 100644 index 0000000000000000000000000000000000000000..d6109d4b605f42629ddc63da3ec7491c83a7f42d --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLLights.js @@ -0,0 +1,472 @@ +import { Color } from '../../math/Color.js'; +import { Matrix4 } from '../../math/Matrix4.js'; +import { Vector2 } from '../../math/Vector2.js'; +import { Vector3 } from '../../math/Vector3.js'; +import { UniformsLib } from '../shaders/UniformsLib.js'; + +function UniformsCache() { + const lights = {}; + + return { + get: function (light) { + if (lights[light.id] !== undefined) { + return lights[light.id]; + } + + let uniforms; + + switch (light.type) { + case 'DirectionalLight': + uniforms = { + direction: new Vector3(), + color: new Color(), + }; + break; + + case 'SpotLight': + uniforms = { + position: new Vector3(), + direction: new Vector3(), + color: new Color(), + distance: 0, + coneCos: 0, + penumbraCos: 0, + decay: 0, + }; + break; + + case 'PointLight': + uniforms = { + position: new Vector3(), + color: new Color(), + distance: 0, + decay: 0, + }; + break; + + case 'HemisphereLight': + uniforms = { + direction: new Vector3(), + skyColor: new Color(), + groundColor: new Color(), + }; + break; + + case 'RectAreaLight': + uniforms = { + color: new Color(), + position: new Vector3(), + halfWidth: new Vector3(), + halfHeight: new Vector3(), + }; + break; + } + + lights[light.id] = uniforms; + + return uniforms; + }, + }; +} + +function ShadowUniformsCache() { + const lights = {}; + + return { + get: function (light) { + if (lights[light.id] !== undefined) { + return lights[light.id]; + } + + let uniforms; + + switch (light.type) { + case 'DirectionalLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + }; + break; + + case 'SpotLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + }; + break; + + case 'PointLight': + uniforms = { + shadowBias: 0, + shadowNormalBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + shadowCameraNear: 1, + shadowCameraFar: 1000, + }; + break; + + // TODO (abelnation): set RectAreaLight shadow uniforms + } + + lights[light.id] = uniforms; + + return uniforms; + }, + }; +} + +let nextVersion = 0; + +function shadowCastingLightsFirst(lightA, lightB) { + return (lightB.castShadow ? 1 : 0) - (lightA.castShadow ? 1 : 0); +} + +function WebGLLights(extensions, capabilities) { + const cache = new UniformsCache(); + + const shadowCache = ShadowUniformsCache(); + + const state = { + version: 0, + + hash: { + directionalLength: -1, + pointLength: -1, + spotLength: -1, + rectAreaLength: -1, + hemiLength: -1, + + numDirectionalShadows: -1, + numPointShadows: -1, + numSpotShadows: -1, + }, + + ambient: [0, 0, 0], + probe: [], + directional: [], + directionalShadow: [], + directionalShadowMap: [], + directionalShadowMatrix: [], + spot: [], + spotShadow: [], + spotShadowMap: [], + spotShadowMatrix: [], + rectArea: [], + rectAreaLTC1: null, + rectAreaLTC2: null, + point: [], + pointShadow: [], + pointShadowMap: [], + pointShadowMatrix: [], + hemi: [], + }; + + for (let i = 0; i < 9; i++) state.probe.push(new Vector3()); + + const vector3 = new Vector3(); + const matrix4 = new Matrix4(); + const matrix42 = new Matrix4(); + + function setup(lights, physicallyCorrectLights) { + let r = 0, + g = 0, + b = 0; + + for (let i = 0; i < 9; i++) state.probe[i].set(0, 0, 0); + + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + let numDirectionalShadows = 0; + let numPointShadows = 0; + let numSpotShadows = 0; + + lights.sort(shadowCastingLightsFirst); + + // artist-friendly light intensity scaling factor + const scaleFactor = physicallyCorrectLights !== true ? Math.PI : 1; + + for (let i = 0, l = lights.length; i < l; i++) { + const light = lights[i]; + + const color = light.color; + const intensity = light.intensity; + const distance = light.distance; + + const shadowMap = light.shadow && light.shadow.map ? light.shadow.map.texture : null; + + if (light.isAmbientLight) { + r += color.r * intensity * scaleFactor; + g += color.g * intensity * scaleFactor; + b += color.b * intensity * scaleFactor; + } else if (light.isLightProbe) { + for (let j = 0; j < 9; j++) { + state.probe[j].addScaledVector(light.sh.coefficients[j], intensity); + } + } else if (light.isDirectionalLight) { + const uniforms = cache.get(light); + + uniforms.color.copy(light.color).multiplyScalar(light.intensity * scaleFactor); + + if (light.castShadow) { + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get(light); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.directionalShadow[directionalLength] = shadowUniforms; + state.directionalShadowMap[directionalLength] = shadowMap; + state.directionalShadowMatrix[directionalLength] = light.shadow.matrix; + + numDirectionalShadows++; + } + + state.directional[directionalLength] = uniforms; + + directionalLength++; + } else if (light.isSpotLight) { + const uniforms = cache.get(light); + + uniforms.position.setFromMatrixPosition(light.matrixWorld); + + uniforms.color.copy(color).multiplyScalar(intensity * scaleFactor); + uniforms.distance = distance; + + uniforms.coneCos = Math.cos(light.angle); + uniforms.penumbraCos = Math.cos(light.angle * (1 - light.penumbra)); + uniforms.decay = light.decay; + + if (light.castShadow) { + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get(light); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + + state.spotShadow[spotLength] = shadowUniforms; + state.spotShadowMap[spotLength] = shadowMap; + state.spotShadowMatrix[spotLength] = light.shadow.matrix; + + numSpotShadows++; + } + + state.spot[spotLength] = uniforms; + + spotLength++; + } else if (light.isRectAreaLight) { + const uniforms = cache.get(light); + + // (a) intensity is the total visible light emitted + //uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) ); + + // (b) intensity is the brightness of the light + uniforms.color.copy(color).multiplyScalar(intensity); + + uniforms.halfWidth.set(light.width * 0.5, 0.0, 0.0); + uniforms.halfHeight.set(0.0, light.height * 0.5, 0.0); + + state.rectArea[rectAreaLength] = uniforms; + + rectAreaLength++; + } else if (light.isPointLight) { + const uniforms = cache.get(light); + + uniforms.color.copy(light.color).multiplyScalar(light.intensity * scaleFactor); + uniforms.distance = light.distance; + uniforms.decay = light.decay; + + if (light.castShadow) { + const shadow = light.shadow; + + const shadowUniforms = shadowCache.get(light); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowNormalBias = shadow.normalBias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + shadowUniforms.shadowCameraNear = shadow.camera.near; + shadowUniforms.shadowCameraFar = shadow.camera.far; + + state.pointShadow[pointLength] = shadowUniforms; + state.pointShadowMap[pointLength] = shadowMap; + state.pointShadowMatrix[pointLength] = light.shadow.matrix; + + numPointShadows++; + } + + state.point[pointLength] = uniforms; + + pointLength++; + } else if (light.isHemisphereLight) { + const uniforms = cache.get(light); + + uniforms.skyColor.copy(light.color).multiplyScalar(intensity * scaleFactor); + uniforms.groundColor.copy(light.groundColor).multiplyScalar(intensity * scaleFactor); + + state.hemi[hemiLength] = uniforms; + + hemiLength++; + } + } + + if (rectAreaLength > 0) { + if (capabilities.isWebGL2) { + // WebGL 2 + + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + } else { + // WebGL 1 + + if (extensions.has('OES_texture_float_linear') === true) { + state.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1; + state.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2; + } else if (extensions.has('OES_texture_half_float_linear') === true) { + state.rectAreaLTC1 = UniformsLib.LTC_HALF_1; + state.rectAreaLTC2 = UniformsLib.LTC_HALF_2; + } else { + console.error('THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.'); + } + } + } + + state.ambient[0] = r; + state.ambient[1] = g; + state.ambient[2] = b; + + const hash = state.hash; + + if ( + hash.directionalLength !== directionalLength || + hash.pointLength !== pointLength || + hash.spotLength !== spotLength || + hash.rectAreaLength !== rectAreaLength || + hash.hemiLength !== hemiLength || + hash.numDirectionalShadows !== numDirectionalShadows || + hash.numPointShadows !== numPointShadows || + hash.numSpotShadows !== numSpotShadows + ) { + state.directional.length = directionalLength; + state.spot.length = spotLength; + state.rectArea.length = rectAreaLength; + state.point.length = pointLength; + state.hemi.length = hemiLength; + + state.directionalShadow.length = numDirectionalShadows; + state.directionalShadowMap.length = numDirectionalShadows; + state.pointShadow.length = numPointShadows; + state.pointShadowMap.length = numPointShadows; + state.spotShadow.length = numSpotShadows; + state.spotShadowMap.length = numSpotShadows; + state.directionalShadowMatrix.length = numDirectionalShadows; + state.pointShadowMatrix.length = numPointShadows; + state.spotShadowMatrix.length = numSpotShadows; + + hash.directionalLength = directionalLength; + hash.pointLength = pointLength; + hash.spotLength = spotLength; + hash.rectAreaLength = rectAreaLength; + hash.hemiLength = hemiLength; + + hash.numDirectionalShadows = numDirectionalShadows; + hash.numPointShadows = numPointShadows; + hash.numSpotShadows = numSpotShadows; + + state.version = nextVersion++; + } + } + + function setupView(lights, camera) { + let directionalLength = 0; + let pointLength = 0; + let spotLength = 0; + let rectAreaLength = 0; + let hemiLength = 0; + + const viewMatrix = camera.matrixWorldInverse; + + for (let i = 0, l = lights.length; i < l; i++) { + const light = lights[i]; + + if (light.isDirectionalLight) { + const uniforms = state.directional[directionalLength]; + + uniforms.direction.setFromMatrixPosition(light.matrixWorld); + vector3.setFromMatrixPosition(light.target.matrixWorld); + uniforms.direction.sub(vector3); + uniforms.direction.transformDirection(viewMatrix); + + directionalLength++; + } else if (light.isSpotLight) { + const uniforms = state.spot[spotLength]; + + uniforms.position.setFromMatrixPosition(light.matrixWorld); + uniforms.position.applyMatrix4(viewMatrix); + + uniforms.direction.setFromMatrixPosition(light.matrixWorld); + vector3.setFromMatrixPosition(light.target.matrixWorld); + uniforms.direction.sub(vector3); + uniforms.direction.transformDirection(viewMatrix); + + spotLength++; + } else if (light.isRectAreaLight) { + const uniforms = state.rectArea[rectAreaLength]; + + uniforms.position.setFromMatrixPosition(light.matrixWorld); + uniforms.position.applyMatrix4(viewMatrix); + + // extract local rotation of light to derive width/height half vectors + matrix42.identity(); + matrix4.copy(light.matrixWorld); + matrix4.premultiply(viewMatrix); + matrix42.extractRotation(matrix4); + + uniforms.halfWidth.set(light.width * 0.5, 0.0, 0.0); + uniforms.halfHeight.set(0.0, light.height * 0.5, 0.0); + + uniforms.halfWidth.applyMatrix4(matrix42); + uniforms.halfHeight.applyMatrix4(matrix42); + + rectAreaLength++; + } else if (light.isPointLight) { + const uniforms = state.point[pointLength]; + + uniforms.position.setFromMatrixPosition(light.matrixWorld); + uniforms.position.applyMatrix4(viewMatrix); + + pointLength++; + } else if (light.isHemisphereLight) { + const uniforms = state.hemi[hemiLength]; + + uniforms.direction.setFromMatrixPosition(light.matrixWorld); + uniforms.direction.transformDirection(viewMatrix); + uniforms.direction.normalize(); + + hemiLength++; + } + } + } + + return { + setup: setup, + setupView: setupView, + state: state, + }; +} + +export { WebGLLights }; diff --git a/backend/libs/three/renderers/webgl/WebGLMaterials.js b/backend/libs/three/renderers/webgl/WebGLMaterials.js new file mode 100644 index 0000000000000000000000000000000000000000..03aa7095741d909123d8300e8305645d587da7aa --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLMaterials.js @@ -0,0 +1,544 @@ +import { BackSide } from '../../constants.js'; + +function WebGLMaterials(properties) { + function refreshFogUniforms(uniforms, fog) { + uniforms.fogColor.value.copy(fog.color); + + if (fog.isFog) { + uniforms.fogNear.value = fog.near; + uniforms.fogFar.value = fog.far; + } else if (fog.isFogExp2) { + uniforms.fogDensity.value = fog.density; + } + } + + function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) { + if (material.isMeshBasicMaterial) { + refreshUniformsCommon(uniforms, material); + } else if (material.isMeshLambertMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsLambert(uniforms, material); + } else if (material.isMeshToonMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsToon(uniforms, material); + } else if (material.isMeshPhongMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsPhong(uniforms, material); + } else if (material.isMeshStandardMaterial) { + refreshUniformsCommon(uniforms, material); + + if (material.isMeshPhysicalMaterial) { + refreshUniformsPhysical(uniforms, material, transmissionRenderTarget); + } else { + refreshUniformsStandard(uniforms, material); + } + } else if (material.isMeshMatcapMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsMatcap(uniforms, material); + } else if (material.isMeshDepthMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsDepth(uniforms, material); + } else if (material.isMeshDistanceMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsDistance(uniforms, material); + } else if (material.isMeshNormalMaterial) { + refreshUniformsCommon(uniforms, material); + refreshUniformsNormal(uniforms, material); + } else if (material.isLineBasicMaterial) { + refreshUniformsLine(uniforms, material); + + if (material.isLineDashedMaterial) { + refreshUniformsDash(uniforms, material); + } + } else if (material.isPointsMaterial) { + refreshUniformsPoints(uniforms, material, pixelRatio, height); + } else if (material.isSpriteMaterial) { + refreshUniformsSprites(uniforms, material); + } else if (material.isShadowMaterial) { + uniforms.color.value.copy(material.color); + uniforms.opacity.value = material.opacity; + } else if (material.isShaderMaterial) { + material.uniformsNeedUpdate = false; // #15581 + } + } + + function refreshUniformsCommon(uniforms, material) { + uniforms.opacity.value = material.opacity; + + if (material.color) { + uniforms.diffuse.value.copy(material.color); + } + + if (material.emissive) { + uniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity); + } + + if (material.map) { + uniforms.map.value = material.map; + } + + if (material.alphaMap) { + uniforms.alphaMap.value = material.alphaMap; + } + + if (material.specularMap) { + uniforms.specularMap.value = material.specularMap; + } + + if (material.alphaTest > 0) { + uniforms.alphaTest.value = material.alphaTest; + } + + const envMap = properties.get(material).envMap; + + if (envMap) { + uniforms.envMap.value = envMap; + + uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1; + + uniforms.reflectivity.value = material.reflectivity; + uniforms.ior.value = material.ior; + uniforms.refractionRatio.value = material.refractionRatio; + } + + if (material.lightMap) { + uniforms.lightMap.value = material.lightMap; + uniforms.lightMapIntensity.value = material.lightMapIntensity; + } + + if (material.aoMap) { + uniforms.aoMap.value = material.aoMap; + uniforms.aoMapIntensity.value = material.aoMapIntensity; + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. specular map + // 3. displacementMap map + // 4. normal map + // 5. bump map + // 6. roughnessMap map + // 7. metalnessMap map + // 8. alphaMap map + // 9. emissiveMap map + // 10. clearcoat map + // 11. clearcoat normal map + // 12. clearcoat roughnessMap map + // 13. specular intensity map + // 14. specular tint map + // 15. transmission map + // 16. thickness map + + let uvScaleMap; + + if (material.map) { + uvScaleMap = material.map; + } else if (material.specularMap) { + uvScaleMap = material.specularMap; + } else if (material.displacementMap) { + uvScaleMap = material.displacementMap; + } else if (material.normalMap) { + uvScaleMap = material.normalMap; + } else if (material.bumpMap) { + uvScaleMap = material.bumpMap; + } else if (material.roughnessMap) { + uvScaleMap = material.roughnessMap; + } else if (material.metalnessMap) { + uvScaleMap = material.metalnessMap; + } else if (material.alphaMap) { + uvScaleMap = material.alphaMap; + } else if (material.emissiveMap) { + uvScaleMap = material.emissiveMap; + } else if (material.clearcoatMap) { + uvScaleMap = material.clearcoatMap; + } else if (material.clearcoatNormalMap) { + uvScaleMap = material.clearcoatNormalMap; + } else if (material.clearcoatRoughnessMap) { + uvScaleMap = material.clearcoatRoughnessMap; + } else if (material.specularIntensityMap) { + uvScaleMap = material.specularIntensityMap; + } else if (material.specularColorMap) { + uvScaleMap = material.specularColorMap; + } else if (material.transmissionMap) { + uvScaleMap = material.transmissionMap; + } else if (material.thicknessMap) { + uvScaleMap = material.thicknessMap; + } else if (material.sheenColorMap) { + uvScaleMap = material.sheenColorMap; + } else if (material.sheenRoughnessMap) { + uvScaleMap = material.sheenRoughnessMap; + } + + if (uvScaleMap !== undefined) { + // backwards compatibility + if (uvScaleMap.isWebGLRenderTarget) { + uvScaleMap = uvScaleMap.texture; + } + + if (uvScaleMap.matrixAutoUpdate === true) { + uvScaleMap.updateMatrix(); + } + + uniforms.uvTransform.value.copy(uvScaleMap.matrix); + } + + // uv repeat and offset setting priorities for uv2 + // 1. ao map + // 2. light map + + let uv2ScaleMap; + + if (material.aoMap) { + uv2ScaleMap = material.aoMap; + } else if (material.lightMap) { + uv2ScaleMap = material.lightMap; + } + + if (uv2ScaleMap !== undefined) { + // backwards compatibility + if (uv2ScaleMap.isWebGLRenderTarget) { + uv2ScaleMap = uv2ScaleMap.texture; + } + + if (uv2ScaleMap.matrixAutoUpdate === true) { + uv2ScaleMap.updateMatrix(); + } + + uniforms.uv2Transform.value.copy(uv2ScaleMap.matrix); + } + } + + function refreshUniformsLine(uniforms, material) { + uniforms.diffuse.value.copy(material.color); + uniforms.opacity.value = material.opacity; + } + + function refreshUniformsDash(uniforms, material) { + uniforms.dashSize.value = material.dashSize; + uniforms.totalSize.value = material.dashSize + material.gapSize; + uniforms.scale.value = material.scale; + } + + function refreshUniformsPoints(uniforms, material, pixelRatio, height) { + uniforms.diffuse.value.copy(material.color); + uniforms.opacity.value = material.opacity; + uniforms.size.value = material.size * pixelRatio; + uniforms.scale.value = height * 0.5; + + if (material.map) { + uniforms.map.value = material.map; + } + + if (material.alphaMap) { + uniforms.alphaMap.value = material.alphaMap; + } + + if (material.alphaTest > 0) { + uniforms.alphaTest.value = material.alphaTest; + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if (material.map) { + uvScaleMap = material.map; + } else if (material.alphaMap) { + uvScaleMap = material.alphaMap; + } + + if (uvScaleMap !== undefined) { + if (uvScaleMap.matrixAutoUpdate === true) { + uvScaleMap.updateMatrix(); + } + + uniforms.uvTransform.value.copy(uvScaleMap.matrix); + } + } + + function refreshUniformsSprites(uniforms, material) { + uniforms.diffuse.value.copy(material.color); + uniforms.opacity.value = material.opacity; + uniforms.rotation.value = material.rotation; + + if (material.map) { + uniforms.map.value = material.map; + } + + if (material.alphaMap) { + uniforms.alphaMap.value = material.alphaMap; + } + + if (material.alphaTest > 0) { + uniforms.alphaTest.value = material.alphaTest; + } + + // uv repeat and offset setting priorities + // 1. color map + // 2. alpha map + + let uvScaleMap; + + if (material.map) { + uvScaleMap = material.map; + } else if (material.alphaMap) { + uvScaleMap = material.alphaMap; + } + + if (uvScaleMap !== undefined) { + if (uvScaleMap.matrixAutoUpdate === true) { + uvScaleMap.updateMatrix(); + } + + uniforms.uvTransform.value.copy(uvScaleMap.matrix); + } + } + + function refreshUniformsLambert(uniforms, material) { + if (material.emissiveMap) { + uniforms.emissiveMap.value = material.emissiveMap; + } + } + + function refreshUniformsPhong(uniforms, material) { + uniforms.specular.value.copy(material.specular); + uniforms.shininess.value = Math.max(material.shininess, 1e-4); // to prevent pow( 0.0, 0.0 ) + + if (material.emissiveMap) { + uniforms.emissiveMap.value = material.emissiveMap; + } + + if (material.bumpMap) { + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if (material.side === BackSide) uniforms.bumpScale.value *= -1; + } + + if (material.normalMap) { + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy(material.normalScale); + if (material.side === BackSide) uniforms.normalScale.value.negate(); + } + + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + } + + function refreshUniformsToon(uniforms, material) { + if (material.gradientMap) { + uniforms.gradientMap.value = material.gradientMap; + } + + if (material.emissiveMap) { + uniforms.emissiveMap.value = material.emissiveMap; + } + + if (material.bumpMap) { + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if (material.side === BackSide) uniforms.bumpScale.value *= -1; + } + + if (material.normalMap) { + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy(material.normalScale); + if (material.side === BackSide) uniforms.normalScale.value.negate(); + } + + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + } + + function refreshUniformsStandard(uniforms, material) { + uniforms.roughness.value = material.roughness; + uniforms.metalness.value = material.metalness; + + if (material.roughnessMap) { + uniforms.roughnessMap.value = material.roughnessMap; + } + + if (material.metalnessMap) { + uniforms.metalnessMap.value = material.metalnessMap; + } + + if (material.emissiveMap) { + uniforms.emissiveMap.value = material.emissiveMap; + } + + if (material.bumpMap) { + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if (material.side === BackSide) uniforms.bumpScale.value *= -1; + } + + if (material.normalMap) { + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy(material.normalScale); + if (material.side === BackSide) uniforms.normalScale.value.negate(); + } + + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + + const envMap = properties.get(material).envMap; + + if (envMap) { + //uniforms.envMap.value = material.envMap; // part of uniforms common + uniforms.envMapIntensity.value = material.envMapIntensity; + } + } + + function refreshUniformsPhysical(uniforms, material, transmissionRenderTarget) { + refreshUniformsStandard(uniforms, material); + + uniforms.ior.value = material.ior; // also part of uniforms common + + if (material.sheen > 0) { + uniforms.sheenColor.value.copy(material.sheenColor).multiplyScalar(material.sheen); + + uniforms.sheenRoughness.value = material.sheenRoughness; + + if (material.sheenColorMap) { + uniforms.sheenColorMap.value = material.sheenColorMap; + } + + if (material.sheenRoughnessMap) { + uniforms.sheenRoughnessMap.value = material.sheenRoughnessMap; + } + } + + if (material.clearcoat > 0) { + uniforms.clearcoat.value = material.clearcoat; + uniforms.clearcoatRoughness.value = material.clearcoatRoughness; + + if (material.clearcoatMap) { + uniforms.clearcoatMap.value = material.clearcoatMap; + } + + if (material.clearcoatRoughnessMap) { + uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap; + } + + if (material.clearcoatNormalMap) { + uniforms.clearcoatNormalScale.value.copy(material.clearcoatNormalScale); + uniforms.clearcoatNormalMap.value = material.clearcoatNormalMap; + + if (material.side === BackSide) { + uniforms.clearcoatNormalScale.value.negate(); + } + } + } + + if (material.transmission > 0) { + uniforms.transmission.value = material.transmission; + uniforms.transmissionSamplerMap.value = transmissionRenderTarget.texture; + uniforms.transmissionSamplerSize.value.set(transmissionRenderTarget.width, transmissionRenderTarget.height); + + if (material.transmissionMap) { + uniforms.transmissionMap.value = material.transmissionMap; + } + + uniforms.thickness.value = material.thickness; + + if (material.thicknessMap) { + uniforms.thicknessMap.value = material.thicknessMap; + } + + uniforms.attenuationDistance.value = material.attenuationDistance; + uniforms.attenuationColor.value.copy(material.attenuationColor); + } + + uniforms.specularIntensity.value = material.specularIntensity; + uniforms.specularColor.value.copy(material.specularColor); + + if (material.specularIntensityMap) { + uniforms.specularIntensityMap.value = material.specularIntensityMap; + } + + if (material.specularColorMap) { + uniforms.specularColorMap.value = material.specularColorMap; + } + } + + function refreshUniformsMatcap(uniforms, material) { + if (material.matcap) { + uniforms.matcap.value = material.matcap; + } + + if (material.bumpMap) { + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if (material.side === BackSide) uniforms.bumpScale.value *= -1; + } + + if (material.normalMap) { + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy(material.normalScale); + if (material.side === BackSide) uniforms.normalScale.value.negate(); + } + + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + } + + function refreshUniformsDepth(uniforms, material) { + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + } + + function refreshUniformsDistance(uniforms, material) { + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + + uniforms.referencePosition.value.copy(material.referencePosition); + uniforms.nearDistance.value = material.nearDistance; + uniforms.farDistance.value = material.farDistance; + } + + function refreshUniformsNormal(uniforms, material) { + if (material.bumpMap) { + uniforms.bumpMap.value = material.bumpMap; + uniforms.bumpScale.value = material.bumpScale; + if (material.side === BackSide) uniforms.bumpScale.value *= -1; + } + + if (material.normalMap) { + uniforms.normalMap.value = material.normalMap; + uniforms.normalScale.value.copy(material.normalScale); + if (material.side === BackSide) uniforms.normalScale.value.negate(); + } + + if (material.displacementMap) { + uniforms.displacementMap.value = material.displacementMap; + uniforms.displacementScale.value = material.displacementScale; + uniforms.displacementBias.value = material.displacementBias; + } + } + + return { + refreshFogUniforms: refreshFogUniforms, + refreshMaterialUniforms: refreshMaterialUniforms, + }; +} + +export { WebGLMaterials }; diff --git a/backend/libs/three/renderers/webgl/WebGLMorphtargets.js b/backend/libs/three/renderers/webgl/WebGLMorphtargets.js new file mode 100644 index 0000000000000000000000000000000000000000..2ed4bd52343c67d06fb33350fdb437c94ea84290 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLMorphtargets.js @@ -0,0 +1,236 @@ +import { FloatType, RGBAFormat } from '../../constants.js'; +import { DataTexture2DArray } from '../../textures/DataTexture2DArray.js'; +import { Vector3 } from '../../math/Vector3.js'; +import { Vector2 } from '../../math/Vector2.js'; + +function numericalSort(a, b) { + return a[0] - b[0]; +} + +function absNumericalSort(a, b) { + return Math.abs(b[1]) - Math.abs(a[1]); +} + +function denormalize(morph, attribute) { + let denominator = 1; + const array = attribute.isInterleavedBufferAttribute ? attribute.data.array : attribute.array; + + if (array instanceof Int8Array) denominator = 127; + else if (array instanceof Int16Array) denominator = 32767; + else if (array instanceof Int32Array) denominator = 2147483647; + else console.error('THREE.WebGLMorphtargets: Unsupported morph attribute data type: ', array); + + morph.divideScalar(denominator); +} + +function WebGLMorphtargets(gl, capabilities, textures) { + const influencesList = {}; + const morphInfluences = new Float32Array(8); + const morphTextures = new WeakMap(); + const morph = new Vector3(); + + const workInfluences = []; + + for (let i = 0; i < 8; i++) { + workInfluences[i] = [i, 0]; + } + + function update(object, geometry, material, program) { + const objectInfluences = object.morphTargetInfluences; + + if (capabilities.isWebGL2 === true) { + // instead of using attributes, the WebGL 2 code path encodes morph targets + // into an array of data textures. Each layer represents a single morph target. + + const numberOfMorphTargets = geometry.morphAttributes.position.length; + + let entry = morphTextures.get(geometry); + + if (entry === undefined || entry.count !== numberOfMorphTargets) { + if (entry !== undefined) entry.texture.dispose(); + + const hasMorphNormals = geometry.morphAttributes.normal !== undefined; + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal || []; + + const numberOfVertices = geometry.attributes.position.count; + const numberOfVertexData = hasMorphNormals === true ? 2 : 1; // (v,n) vs. (v) + + let width = numberOfVertices * numberOfVertexData; + let height = 1; + + if (width > capabilities.maxTextureSize) { + height = Math.ceil(width / capabilities.maxTextureSize); + width = capabilities.maxTextureSize; + } + + const buffer = new Float32Array(width * height * 4 * numberOfMorphTargets); + + const texture = new DataTexture2DArray(buffer, width, height, numberOfMorphTargets); + texture.format = RGBAFormat; // using RGBA since RGB might be emulated (and is thus slower) + texture.type = FloatType; + texture.needsUpdate = true; + + // fill buffer + + const vertexDataStride = numberOfVertexData * 4; + + for (let i = 0; i < numberOfMorphTargets; i++) { + const morphTarget = morphTargets[i]; + const morphNormal = morphNormals[i]; + + const offset = width * height * 4 * i; + + for (let j = 0; j < morphTarget.count; j++) { + morph.fromBufferAttribute(morphTarget, j); + + if (morphTarget.normalized === true) denormalize(morph, morphTarget); + + const stride = j * vertexDataStride; + + buffer[offset + stride + 0] = morph.x; + buffer[offset + stride + 1] = morph.y; + buffer[offset + stride + 2] = morph.z; + buffer[offset + stride + 3] = 0; + + if (hasMorphNormals === true) { + morph.fromBufferAttribute(morphNormal, j); + + if (morphNormal.normalized === true) denormalize(morph, morphNormal); + + buffer[offset + stride + 4] = morph.x; + buffer[offset + stride + 5] = morph.y; + buffer[offset + stride + 6] = morph.z; + buffer[offset + stride + 7] = 0; + } + } + } + + entry = { + count: numberOfMorphTargets, + texture: texture, + size: new Vector2(width, height), + }; + + morphTextures.set(geometry, entry); + + function disposeTexture() { + texture.dispose(); + + morphTextures.delete(geometry); + + geometry.removeEventListener('dispose', disposeTexture); + } + + geometry.addEventListener('dispose', disposeTexture); + } + + // + + let morphInfluencesSum = 0; + + for (let i = 0; i < objectInfluences.length; i++) { + morphInfluencesSum += objectInfluences[i]; + } + + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue(gl, 'morphTargetBaseInfluence', morphBaseInfluence); + program.getUniforms().setValue(gl, 'morphTargetInfluences', objectInfluences); + + program.getUniforms().setValue(gl, 'morphTargetsTexture', entry.texture, textures); + program.getUniforms().setValue(gl, 'morphTargetsTextureSize', entry.size); + } else { + // When object doesn't have morph target influences defined, we treat it as a 0-length array + // This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences + + const length = objectInfluences === undefined ? 0 : objectInfluences.length; + + let influences = influencesList[geometry.id]; + + if (influences === undefined || influences.length !== length) { + // initialise list + + influences = []; + + for (let i = 0; i < length; i++) { + influences[i] = [i, 0]; + } + + influencesList[geometry.id] = influences; + } + + // Collect influences + + for (let i = 0; i < length; i++) { + const influence = influences[i]; + + influence[0] = i; + influence[1] = objectInfluences[i]; + } + + influences.sort(absNumericalSort); + + for (let i = 0; i < 8; i++) { + if (i < length && influences[i][1]) { + workInfluences[i][0] = influences[i][0]; + workInfluences[i][1] = influences[i][1]; + } else { + workInfluences[i][0] = Number.MAX_SAFE_INTEGER; + workInfluences[i][1] = 0; + } + } + + workInfluences.sort(numericalSort); + + const morphTargets = geometry.morphAttributes.position; + const morphNormals = geometry.morphAttributes.normal; + + let morphInfluencesSum = 0; + + for (let i = 0; i < 8; i++) { + const influence = workInfluences[i]; + const index = influence[0]; + const value = influence[1]; + + if (index !== Number.MAX_SAFE_INTEGER && value) { + if (morphTargets && geometry.getAttribute('morphTarget' + i) !== morphTargets[index]) { + geometry.setAttribute('morphTarget' + i, morphTargets[index]); + } + + if (morphNormals && geometry.getAttribute('morphNormal' + i) !== morphNormals[index]) { + geometry.setAttribute('morphNormal' + i, morphNormals[index]); + } + + morphInfluences[i] = value; + morphInfluencesSum += value; + } else { + if (morphTargets && geometry.hasAttribute('morphTarget' + i) === true) { + geometry.deleteAttribute('morphTarget' + i); + } + + if (morphNormals && geometry.hasAttribute('morphNormal' + i) === true) { + geometry.deleteAttribute('morphNormal' + i); + } + + morphInfluences[i] = 0; + } + } + + // GLSL shader uses formula baseinfluence * base + sum(target * influence) + // This allows us to switch between absolute morphs and relative morphs without changing shader code + // When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence) + const morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum; + + program.getUniforms().setValue(gl, 'morphTargetBaseInfluence', morphBaseInfluence); + program.getUniforms().setValue(gl, 'morphTargetInfluences', morphInfluences); + } + } + + return { + update: update, + }; +} + +export { WebGLMorphtargets }; diff --git a/backend/libs/three/renderers/webgl/WebGLObjects.d.ts b/backend/libs/three/renderers/webgl/WebGLObjects.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5308ac64149ba45425dbb09229b675da62691330 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLObjects.d.ts @@ -0,0 +1,6 @@ +export class WebGLObjects { + constructor(gl: WebGLRenderingContext, geometries: any, attributes: any, info: any); + + update(object: any): any; + dispose(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLObjects.js b/backend/libs/three/renderers/webgl/WebGLObjects.js new file mode 100644 index 0000000000000000000000000000000000000000..b8649ec6950173747a2740dca3004e7c728dfd84 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLObjects.js @@ -0,0 +1,53 @@ +function WebGLObjects(gl, geometries, attributes, info) { + let updateMap = new WeakMap(); + + function update(object) { + const frame = info.render.frame; + + const geometry = object.geometry; + const buffergeometry = geometries.get(object, geometry); + + // Update once per frame + + if (updateMap.get(buffergeometry) !== frame) { + geometries.update(buffergeometry); + + updateMap.set(buffergeometry, frame); + } + + if (object.isInstancedMesh) { + if (object.hasEventListener('dispose', onInstancedMeshDispose) === false) { + object.addEventListener('dispose', onInstancedMeshDispose); + } + + attributes.update(object.instanceMatrix, gl.ARRAY_BUFFER); + + if (object.instanceColor !== null) { + attributes.update(object.instanceColor, gl.ARRAY_BUFFER); + } + } + + return buffergeometry; + } + + function dispose() { + updateMap = new WeakMap(); + } + + function onInstancedMeshDispose(event) { + const instancedMesh = event.target; + + instancedMesh.removeEventListener('dispose', onInstancedMeshDispose); + + attributes.remove(instancedMesh.instanceMatrix); + + if (instancedMesh.instanceColor !== null) attributes.remove(instancedMesh.instanceColor); + } + + return { + update: update, + dispose: dispose, + }; +} + +export { WebGLObjects }; diff --git a/backend/libs/three/renderers/webgl/WebGLProgram.d.ts b/backend/libs/three/renderers/webgl/WebGLProgram.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..8302fb069ad23f7a2695560804285bfbf1b125c2 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLProgram.d.ts @@ -0,0 +1,31 @@ +import { WebGLRenderer } from './../WebGLRenderer'; +import { WebGLShader } from './WebGLShader'; +import { WebGLUniforms } from './WebGLUniforms'; + +export class WebGLProgram { + constructor(renderer: WebGLRenderer, cacheKey: string, parameters: object); + + name: string; + id: number; + cacheKey: string; // unique identifier for this program, used for looking up compiled programs from cache. + + /** + * @default 1 + */ + usedTimes: number; + program: any; + vertexShader: WebGLShader; + fragmentShader: WebGLShader; + /** + * @deprecated Use {@link WebGLProgram#getUniforms getUniforms()} instead. + */ + uniforms: any; + /** + * @deprecated Use {@link WebGLProgram#getAttributes getAttributes()} instead. + */ + attributes: any; + + getUniforms(): WebGLUniforms; + getAttributes(): any; + destroy(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLProgram.js b/backend/libs/three/renderers/webgl/WebGLProgram.js new file mode 100644 index 0000000000000000000000000000000000000000..cfd40f0c31f51aec87120327beaa50ffc32c41d4 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLProgram.js @@ -0,0 +1,771 @@ +import { WebGLUniforms } from './WebGLUniforms.js'; +import { WebGLShader } from './WebGLShader.js'; +import { ShaderChunk } from '../shaders/ShaderChunk.js'; +import { + NoToneMapping, + AddOperation, + MixOperation, + MultiplyOperation, + CubeRefractionMapping, + CubeUVRefractionMapping, + CubeUVReflectionMapping, + CubeReflectionMapping, + PCFSoftShadowMap, + PCFShadowMap, + VSMShadowMap, + ACESFilmicToneMapping, + CineonToneMapping, + CustomToneMapping, + ReinhardToneMapping, + LinearToneMapping, + sRGBEncoding, + LinearEncoding, + GLSL3, +} from '../../constants.js'; + +let programIdCount = 0; + +function addLineNumbers(string) { + const lines = string.split('\n'); + + for (let i = 0; i < lines.length; i++) { + lines[i] = i + 1 + ': ' + lines[i]; + } + + return lines.join('\n'); +} + +function getEncodingComponents(encoding) { + switch (encoding) { + case LinearEncoding: + return ['Linear', '( value )']; + case sRGBEncoding: + return ['sRGB', '( value )']; + default: + console.warn('THREE.WebGLProgram: Unsupported encoding:', encoding); + return ['Linear', '( value )']; + } +} + +function getShaderErrors(gl, shader, type) { + const status = gl.getShaderParameter(shader, gl.COMPILE_STATUS); + const errors = gl.getShaderInfoLog(shader).trim(); + + if (status && errors === '') return ''; + + // --enable-privileged-webgl-extension + // console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) ); + + return type.toUpperCase() + '\n\n' + errors + '\n\n' + addLineNumbers(gl.getShaderSource(shader)); +} + +function getTexelEncodingFunction(functionName, encoding) { + const components = getEncodingComponents(encoding); + return 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[0] + components[1] + '; }'; +} + +function getToneMappingFunction(functionName, toneMapping) { + let toneMappingName; + + switch (toneMapping) { + case LinearToneMapping: + toneMappingName = 'Linear'; + break; + + case ReinhardToneMapping: + toneMappingName = 'Reinhard'; + break; + + case CineonToneMapping: + toneMappingName = 'OptimizedCineon'; + break; + + case ACESFilmicToneMapping: + toneMappingName = 'ACESFilmic'; + break; + + case CustomToneMapping: + toneMappingName = 'Custom'; + break; + + default: + console.warn('THREE.WebGLProgram: Unsupported toneMapping:', toneMapping); + toneMappingName = 'Linear'; + } + + return 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }'; +} + +function generateExtensions(parameters) { + const chunks = [ + parameters.extensionDerivatives || + parameters.envMapCubeUV || + parameters.bumpMap || + parameters.tangentSpaceNormalMap || + parameters.clearcoatNormalMap || + parameters.flatShading || + parameters.shaderID === 'physical' + ? '#extension GL_OES_standard_derivatives : enable' + : '', + (parameters.extensionFragDepth || parameters.logarithmicDepthBuffer) && parameters.rendererExtensionFragDepth + ? '#extension GL_EXT_frag_depth : enable' + : '', + parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ? '#extension GL_EXT_draw_buffers : require' : '', + (parameters.extensionShaderTextureLOD || parameters.envMap || parameters.transmission) && parameters.rendererExtensionShaderTextureLod + ? '#extension GL_EXT_shader_texture_lod : enable' + : '', + ]; + + return chunks.filter(filterEmptyLine).join('\n'); +} + +function generateDefines(defines) { + const chunks = []; + + for (const name in defines) { + const value = defines[name]; + + if (value === false) continue; + + chunks.push('#define ' + name + ' ' + value); + } + + return chunks.join('\n'); +} + +function fetchAttributeLocations(gl, program) { + const attributes = {}; + + const n = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES); + + for (let i = 0; i < n; i++) { + const info = gl.getActiveAttrib(program, i); + const name = info.name; + + let locationSize = 1; + if (info.type === gl.FLOAT_MAT2) locationSize = 2; + if (info.type === gl.FLOAT_MAT3) locationSize = 3; + if (info.type === gl.FLOAT_MAT4) locationSize = 4; + + // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i ); + + attributes[name] = { + type: info.type, + location: gl.getAttribLocation(program, name), + locationSize: locationSize, + }; + } + + return attributes; +} + +function filterEmptyLine(string) { + return string !== ''; +} + +function replaceLightNums(string, parameters) { + return string + .replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights) + .replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights) + .replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights) + .replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights) + .replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights) + .replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows) + .replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows) + .replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows); +} + +function replaceClippingPlaneNums(string, parameters) { + return string + .replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes) + .replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection); +} + +// Resolve Includes + +const includePattern = /^[ \t]*#include +<([\w\d./]+)>/gm; + +function resolveIncludes(string) { + return string.replace(includePattern, includeReplacer); +} + +function includeReplacer(match, include) { + const string = ShaderChunk[include]; + + if (string === undefined) { + throw new Error('Can not resolve #include <' + include + '>'); + } + + return resolveIncludes(string); +} + +// Unroll Loops + +const deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; +const unrollLoopPattern = + /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; + +function unrollLoops(string) { + return string.replace(unrollLoopPattern, loopReplacer).replace(deprecatedUnrollLoopPattern, deprecatedLoopReplacer); +} + +function deprecatedLoopReplacer(match, start, end, snippet) { + console.warn('WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.'); + return loopReplacer(match, start, end, snippet); +} + +function loopReplacer(match, start, end, snippet) { + let string = ''; + + for (let i = parseInt(start); i < parseInt(end); i++) { + string += snippet.replace(/\[\s*i\s*\]/g, '[ ' + i + ' ]').replace(/UNROLLED_LOOP_INDEX/g, i); + } + + return string; +} + +// + +function generatePrecision(parameters) { + let precisionstring = 'precision ' + parameters.precision + ' float;\nprecision ' + parameters.precision + ' int;'; + + if (parameters.precision === 'highp') { + precisionstring += '\n#define HIGH_PRECISION'; + } else if (parameters.precision === 'mediump') { + precisionstring += '\n#define MEDIUM_PRECISION'; + } else if (parameters.precision === 'lowp') { + precisionstring += '\n#define LOW_PRECISION'; + } + + return precisionstring; +} + +function generateShadowMapTypeDefine(parameters) { + let shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC'; + + if (parameters.shadowMapType === PCFShadowMap) { + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF'; + } else if (parameters.shadowMapType === PCFSoftShadowMap) { + shadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT'; + } else if (parameters.shadowMapType === VSMShadowMap) { + shadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM'; + } + + return shadowMapTypeDefine; +} + +function generateEnvMapTypeDefine(parameters) { + let envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + + if (parameters.envMap) { + switch (parameters.envMapMode) { + case CubeReflectionMapping: + case CubeRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE'; + break; + + case CubeUVReflectionMapping: + case CubeUVRefractionMapping: + envMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV'; + break; + } + } + + return envMapTypeDefine; +} + +function generateEnvMapModeDefine(parameters) { + let envMapModeDefine = 'ENVMAP_MODE_REFLECTION'; + + if (parameters.envMap) { + switch (parameters.envMapMode) { + case CubeRefractionMapping: + case CubeUVRefractionMapping: + envMapModeDefine = 'ENVMAP_MODE_REFRACTION'; + break; + } + } + + return envMapModeDefine; +} + +function generateEnvMapBlendingDefine(parameters) { + let envMapBlendingDefine = 'ENVMAP_BLENDING_NONE'; + + if (parameters.envMap) { + switch (parameters.combine) { + case MultiplyOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY'; + break; + + case MixOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_MIX'; + break; + + case AddOperation: + envMapBlendingDefine = 'ENVMAP_BLENDING_ADD'; + break; + } + } + + return envMapBlendingDefine; +} + +function WebGLProgram(renderer, cacheKey, parameters, bindingStates) { + // TODO Send this event to Three.js DevTools + // console.log( 'WebGLProgram', cacheKey ); + + const gl = renderer.getContext(); + + const defines = parameters.defines; + + let vertexShader = parameters.vertexShader; + let fragmentShader = parameters.fragmentShader; + + const shadowMapTypeDefine = generateShadowMapTypeDefine(parameters); + const envMapTypeDefine = generateEnvMapTypeDefine(parameters); + const envMapModeDefine = generateEnvMapModeDefine(parameters); + const envMapBlendingDefine = generateEnvMapBlendingDefine(parameters); + + const customExtensions = parameters.isWebGL2 ? '' : generateExtensions(parameters); + + const customDefines = generateDefines(defines); + + const program = gl.createProgram(); + + let prefixVertex, prefixFragment; + let versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\n' : ''; + + if (parameters.isRawShaderMaterial) { + prefixVertex = [customDefines].filter(filterEmptyLine).join('\n'); + + if (prefixVertex.length > 0) { + prefixVertex += '\n'; + } + + prefixFragment = [customExtensions, customDefines].filter(filterEmptyLine).join('\n'); + + if (prefixFragment.length > 0) { + prefixFragment += '\n'; + } + } else { + prefixVertex = [ + generatePrecision(parameters), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + parameters.instancing ? '#define USE_INSTANCING' : '', + parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', + + parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', + + '#define MAX_BONES ' + parameters.maxBones, + parameters.useFog && parameters.fog ? '#define USE_FOG' : '', + parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', + parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.skinning ? '#define USE_SKINNING' : '', + parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', + + parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', + parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', + parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_TEXTURE' : '', + parameters.morphTargets && parameters.isWebGL2 ? '#define MORPHTARGETS_COUNT ' + parameters.morphTargetsCount : '', + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', + + 'uniform mat4 modelMatrix;', + 'uniform mat4 modelViewMatrix;', + 'uniform mat4 projectionMatrix;', + 'uniform mat4 viewMatrix;', + 'uniform mat3 normalMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + '#ifdef USE_INSTANCING', + + ' attribute mat4 instanceMatrix;', + + '#endif', + + '#ifdef USE_INSTANCING_COLOR', + + ' attribute vec3 instanceColor;', + + '#endif', + + 'attribute vec3 position;', + 'attribute vec3 normal;', + 'attribute vec2 uv;', + + '#ifdef USE_TANGENT', + + ' attribute vec4 tangent;', + + '#endif', + + '#if defined( USE_COLOR_ALPHA )', + + ' attribute vec4 color;', + + '#elif defined( USE_COLOR )', + + ' attribute vec3 color;', + + '#endif', + + '#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )', + + ' attribute vec3 morphTarget0;', + ' attribute vec3 morphTarget1;', + ' attribute vec3 morphTarget2;', + ' attribute vec3 morphTarget3;', + + ' #ifdef USE_MORPHNORMALS', + + ' attribute vec3 morphNormal0;', + ' attribute vec3 morphNormal1;', + ' attribute vec3 morphNormal2;', + ' attribute vec3 morphNormal3;', + + ' #else', + + ' attribute vec3 morphTarget4;', + ' attribute vec3 morphTarget5;', + ' attribute vec3 morphTarget6;', + ' attribute vec3 morphTarget7;', + + ' #endif', + + '#endif', + + '#ifdef USE_SKINNING', + + ' attribute vec4 skinIndex;', + ' attribute vec4 skinWeight;', + + '#endif', + + '\n', + ] + .filter(filterEmptyLine) + .join('\n'); + + prefixFragment = [ + customExtensions, + + generatePrecision(parameters), + + '#define SHADER_NAME ' + parameters.shaderName, + + customDefines, + + parameters.useFog && parameters.fog ? '#define USE_FOG' : '', + parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', + + parameters.map ? '#define USE_MAP' : '', + parameters.matcap ? '#define USE_MATCAP' : '', + parameters.envMap ? '#define USE_ENVMAP' : '', + parameters.envMap ? '#define ' + envMapTypeDefine : '', + parameters.envMap ? '#define ' + envMapModeDefine : '', + parameters.envMap ? '#define ' + envMapBlendingDefine : '', + parameters.lightMap ? '#define USE_LIGHTMAP' : '', + parameters.aoMap ? '#define USE_AOMAP' : '', + parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', + parameters.bumpMap ? '#define USE_BUMPMAP' : '', + parameters.normalMap ? '#define USE_NORMALMAP' : '', + parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', + parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', + + parameters.clearcoat ? '#define USE_CLEARCOAT' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', + parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', + + parameters.specularMap ? '#define USE_SPECULARMAP' : '', + parameters.specularIntensityMap ? '#define USE_SPECULARINTENSITYMAP' : '', + parameters.specularColorMap ? '#define USE_SPECULARCOLORMAP' : '', + parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', + parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', + + parameters.alphaMap ? '#define USE_ALPHAMAP' : '', + parameters.alphaTest ? '#define USE_ALPHATEST' : '', + + parameters.sheen ? '#define USE_SHEEN' : '', + parameters.sheenColorMap ? '#define USE_SHEENCOLORMAP' : '', + parameters.sheenRoughnessMap ? '#define USE_SHEENROUGHNESSMAP' : '', + + parameters.transmission ? '#define USE_TRANSMISSION' : '', + parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', + parameters.thicknessMap ? '#define USE_THICKNESSMAP' : '', + + parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '', + + parameters.vertexTangents ? '#define USE_TANGENT' : '', + parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', + parameters.vertexAlphas ? '#define USE_COLOR_ALPHA' : '', + parameters.vertexUvs ? '#define USE_UV' : '', + parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', + + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + + parameters.flatShading ? '#define FLAT_SHADED' : '', + + parameters.doubleSided ? '#define DOUBLE_SIDED' : '', + parameters.flipSided ? '#define FLIP_SIDED' : '', + + parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', + parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', + + parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', + + parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', + + parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', + parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', + + (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', + + 'uniform mat4 viewMatrix;', + 'uniform vec3 cameraPosition;', + 'uniform bool isOrthographic;', + + parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', + parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below + parameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', + + parameters.dithering ? '#define DITHERING' : '', + parameters.alphaWrite ? '' : '#define OPAQUE', + + ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below + getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), + + parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', + + '\n', + ] + .filter(filterEmptyLine) + .join('\n'); + } + + vertexShader = resolveIncludes(vertexShader); + vertexShader = replaceLightNums(vertexShader, parameters); + vertexShader = replaceClippingPlaneNums(vertexShader, parameters); + + fragmentShader = resolveIncludes(fragmentShader); + fragmentShader = replaceLightNums(fragmentShader, parameters); + fragmentShader = replaceClippingPlaneNums(fragmentShader, parameters); + + vertexShader = unrollLoops(vertexShader); + fragmentShader = unrollLoops(fragmentShader); + + if (parameters.isWebGL2 && parameters.isRawShaderMaterial !== true) { + // GLSL 3.0 conversion for built-in materials and ShaderMaterial + + versionString = '#version 300 es\n'; + + prefixVertex = + ['precision mediump sampler2DArray;', '#define attribute in', '#define varying out', '#define texture2D texture'].join('\n') + '\n' + prefixVertex; + + prefixFragment = + [ + '#define varying in', + parameters.glslVersion === GLSL3 ? '' : 'layout(location = 0) out highp vec4 pc_fragColor;', + parameters.glslVersion === GLSL3 ? '' : '#define gl_FragColor pc_fragColor', + '#define gl_FragDepthEXT gl_FragDepth', + '#define texture2D texture', + '#define textureCube texture', + '#define texture2DProj textureProj', + '#define texture2DLodEXT textureLod', + '#define texture2DProjLodEXT textureProjLod', + '#define textureCubeLodEXT textureLod', + '#define texture2DGradEXT textureGrad', + '#define texture2DProjGradEXT textureProjGrad', + '#define textureCubeGradEXT textureGrad', + ].join('\n') + + '\n' + + prefixFragment; + } + + const vertexGlsl = versionString + prefixVertex + vertexShader; + const fragmentGlsl = versionString + prefixFragment + fragmentShader; + + // console.log( '*VERTEX*', vertexGlsl ); + // console.log( '*FRAGMENT*', fragmentGlsl ); + + const glVertexShader = WebGLShader(gl, gl.VERTEX_SHADER, vertexGlsl); + const glFragmentShader = WebGLShader(gl, gl.FRAGMENT_SHADER, fragmentGlsl); + + gl.attachShader(program, glVertexShader); + gl.attachShader(program, glFragmentShader); + + // Force a particular attribute to index 0. + + if (parameters.index0AttributeName !== undefined) { + gl.bindAttribLocation(program, 0, parameters.index0AttributeName); + } else if (parameters.morphTargets === true) { + // programs with morphTargets displace position out of attribute 0 + gl.bindAttribLocation(program, 0, 'position'); + } + + gl.linkProgram(program); + + // check for link errors + if (renderer.debug.checkShaderErrors) { + const programLog = gl.getProgramInfoLog(program).trim(); + const vertexLog = gl.getShaderInfoLog(glVertexShader).trim(); + const fragmentLog = gl.getShaderInfoLog(glFragmentShader).trim(); + + let runnable = true; + let haveDiagnostics = true; + + if (gl.getProgramParameter(program, gl.LINK_STATUS) === false) { + runnable = false; + + const vertexErrors = getShaderErrors(gl, glVertexShader, 'vertex'); + const fragmentErrors = getShaderErrors(gl, glFragmentShader, 'fragment'); + + console.error( + 'THREE.WebGLProgram: Shader Error ' + + gl.getError() + + ' - ' + + 'VALIDATE_STATUS ' + + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + + '\n\n' + + 'Program Info Log: ' + + programLog + + '\n' + + vertexErrors + + '\n' + + fragmentErrors + ); + } else if (programLog !== '') { + console.warn('THREE.WebGLProgram: Program Info Log:', programLog); + } else if (vertexLog === '' || fragmentLog === '') { + haveDiagnostics = false; + } + + if (haveDiagnostics) { + this.diagnostics = { + runnable: runnable, + + programLog: programLog, + + vertexShader: { + log: vertexLog, + prefix: prefixVertex, + }, + + fragmentShader: { + log: fragmentLog, + prefix: prefixFragment, + }, + }; + } + } + + // Clean up + + // Crashes in iOS9 and iOS10. #18402 + // gl.detachShader( program, glVertexShader ); + // gl.detachShader( program, glFragmentShader ); + + gl.deleteShader(glVertexShader); + gl.deleteShader(glFragmentShader); + + // set up caching for uniform locations + + let cachedUniforms; + + this.getUniforms = function () { + if (cachedUniforms === undefined) { + cachedUniforms = new WebGLUniforms(gl, program); + } + + return cachedUniforms; + }; + + // set up caching for attribute locations + + let cachedAttributes; + + this.getAttributes = function () { + if (cachedAttributes === undefined) { + cachedAttributes = fetchAttributeLocations(gl, program); + } + + return cachedAttributes; + }; + + // free resource + + this.destroy = function () { + bindingStates.releaseStatesOfProgram(this); + + gl.deleteProgram(program); + this.program = undefined; + }; + + // + + this.name = parameters.shaderName; + this.id = programIdCount++; + this.cacheKey = cacheKey; + this.usedTimes = 1; + this.program = program; + this.vertexShader = glVertexShader; + this.fragmentShader = glFragmentShader; + + return this; +} + +export { WebGLProgram }; diff --git a/backend/libs/three/renderers/webgl/WebGLPrograms.d.ts b/backend/libs/three/renderers/webgl/WebGLPrograms.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..346a67402b1e93c9f1004c00a389158938a6ca2f --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLPrograms.d.ts @@ -0,0 +1,28 @@ +import { WebGLRenderer } from './../WebGLRenderer'; +import { WebGLProgram } from './WebGLProgram'; +import { WebGLCapabilities } from './WebGLCapabilities'; +import { WebGLCubeMaps } from './WebGLCubeMaps'; +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLClipping } from './WebGLClipping'; +import { WebGLBindingStates } from './WebGLBindingStates'; +import { Material } from './../../materials/Material'; +import { Scene } from './../../scenes/Scene'; + +export class WebGLPrograms { + constructor( + renderer: WebGLRenderer, + cubemaps: WebGLCubeMaps, + extensions: WebGLExtensions, + capabilities: WebGLCapabilities, + bindingStates: WebGLBindingStates, + clipping: WebGLClipping + ); + + programs: WebGLProgram[]; + + getParameters(material: Material, lights: any, shadows: object[], scene: Scene, object: any): any; + getProgramCacheKey(parameters: any): string; + getUniforms(material: Material): object; + acquireProgram(parameters: any, cacheKey: string): WebGLProgram; + releaseProgram(program: WebGLProgram): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLPrograms.js b/backend/libs/three/renderers/webgl/WebGLPrograms.js new file mode 100644 index 0000000000000000000000000000000000000000..28848ccf598c5ef124427dca6712840091d7db5e --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLPrograms.js @@ -0,0 +1,481 @@ +import { + BackSide, + DoubleSide, + CubeUVRefractionMapping, + CubeUVReflectionMapping, + ObjectSpaceNormalMap, + TangentSpaceNormalMap, + NoToneMapping, + LinearEncoding, + sRGBEncoding, +} from '../../constants.js'; +import { Layers } from '../../core/Layers.js'; +import { WebGLProgram } from './WebGLProgram.js'; +import { WebGLShaderCache } from './WebGLShaderCache.js'; +import { ShaderLib } from '../shaders/ShaderLib.js'; +import { UniformsUtils } from '../shaders/UniformsUtils.js'; + +function WebGLPrograms(renderer, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping) { + const _programLayers = new Layers(); + const _customShaders = new WebGLShaderCache(); + const programs = []; + + const isWebGL2 = capabilities.isWebGL2; + const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer; + const floatVertexTextures = capabilities.floatVertexTextures; + const maxVertexUniforms = capabilities.maxVertexUniforms; + const vertexTextures = capabilities.vertexTextures; + let precision = capabilities.precision; + + const shaderIDs = { + MeshDepthMaterial: 'depth', + MeshDistanceMaterial: 'distanceRGBA', + MeshNormalMaterial: 'normal', + MeshBasicMaterial: 'basic', + MeshLambertMaterial: 'lambert', + MeshPhongMaterial: 'phong', + MeshToonMaterial: 'toon', + MeshStandardMaterial: 'physical', + MeshPhysicalMaterial: 'physical', + MeshMatcapMaterial: 'matcap', + LineBasicMaterial: 'basic', + LineDashedMaterial: 'dashed', + PointsMaterial: 'points', + ShadowMaterial: 'shadow', + SpriteMaterial: 'sprite', + }; + + function getMaxBones(object) { + const skeleton = object.skeleton; + const bones = skeleton.bones; + + if (floatVertexTextures) { + return 1024; + } else { + // default for when object is not specified + // ( for example when prebuilding shader to be used with multiple objects ) + // + // - leave some extra space for other uniforms + // - limit here is ANGLE's 254 max uniform vectors + // (up to 54 should be safe) + + const nVertexUniforms = maxVertexUniforms; + const nVertexMatrices = Math.floor((nVertexUniforms - 20) / 4); + + const maxBones = Math.min(nVertexMatrices, bones.length); + + if (maxBones < bones.length) { + console.warn('THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.'); + return 0; + } + + return maxBones; + } + } + + function getParameters(material, lights, shadows, scene, object) { + const fog = scene.fog; + const environment = material.isMeshStandardMaterial ? scene.environment : null; + + const envMap = (material.isMeshStandardMaterial ? cubeuvmaps : cubemaps).get(material.envMap || environment); + + const shaderID = shaderIDs[material.type]; + + // heuristics to create shader parameters according to lights in the scene + // (not to blow over maxLights budget) + + const maxBones = object.isSkinnedMesh ? getMaxBones(object) : 0; + + if (material.precision !== null) { + precision = capabilities.getMaxPrecision(material.precision); + + if (precision !== material.precision) { + console.warn('THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.'); + } + } + + let vertexShader, fragmentShader; + let customVertexShaderID, customFragmentShaderID; + + if (shaderID) { + const shader = ShaderLib[shaderID]; + + vertexShader = shader.vertexShader; + fragmentShader = shader.fragmentShader; + } else { + vertexShader = material.vertexShader; + fragmentShader = material.fragmentShader; + + _customShaders.update(material); + + customVertexShaderID = _customShaders.getVertexShaderID(material); + customFragmentShaderID = _customShaders.getFragmentShaderID(material); + } + + const currentRenderTarget = renderer.getRenderTarget(); + + const useAlphaTest = material.alphaTest > 0; + const useClearcoat = material.clearcoat > 0; + + const parameters = { + isWebGL2: isWebGL2, + + shaderID: shaderID, + shaderName: material.type, + + vertexShader: vertexShader, + fragmentShader: fragmentShader, + defines: material.defines, + + customVertexShaderID: customVertexShaderID, + customFragmentShaderID: customFragmentShaderID, + + isRawShaderMaterial: material.isRawShaderMaterial === true, + glslVersion: material.glslVersion, + + precision: precision, + + instancing: object.isInstancedMesh === true, + instancingColor: object.isInstancedMesh === true && object.instanceColor !== null, + + supportsVertexTextures: vertexTextures, + outputEncoding: currentRenderTarget === null ? renderer.outputEncoding : LinearEncoding, + map: !!material.map, + matcap: !!material.matcap, + envMap: !!envMap, + envMapMode: envMap && envMap.mapping, + envMapCubeUV: !!envMap && (envMap.mapping === CubeUVReflectionMapping || envMap.mapping === CubeUVRefractionMapping), + lightMap: !!material.lightMap, + aoMap: !!material.aoMap, + emissiveMap: !!material.emissiveMap, + bumpMap: !!material.bumpMap, + normalMap: !!material.normalMap, + objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap, + tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap, + + decodeVideoTexture: !!material.map && material.map.isVideoTexture === true && material.map.encoding === sRGBEncoding, + + clearcoat: useClearcoat, + clearcoatMap: useClearcoat && !!material.clearcoatMap, + clearcoatRoughnessMap: useClearcoat && !!material.clearcoatRoughnessMap, + clearcoatNormalMap: useClearcoat && !!material.clearcoatNormalMap, + + displacementMap: !!material.displacementMap, + roughnessMap: !!material.roughnessMap, + metalnessMap: !!material.metalnessMap, + specularMap: !!material.specularMap, + specularIntensityMap: !!material.specularIntensityMap, + specularColorMap: !!material.specularColorMap, + + alphaMap: !!material.alphaMap, + alphaTest: useAlphaTest, + alphaWrite: material.alphaWrite || material.transparent, + + gradientMap: !!material.gradientMap, + + sheen: material.sheen > 0, + sheenColorMap: !!material.sheenColorMap, + sheenRoughnessMap: !!material.sheenRoughnessMap, + + transmission: material.transmission > 0, + transmissionMap: !!material.transmissionMap, + thicknessMap: !!material.thicknessMap, + + combine: material.combine, + + vertexTangents: !!material.normalMap && !!object.geometry && !!object.geometry.attributes.tangent, + vertexColors: material.vertexColors, + vertexAlphas: + material.vertexColors === true && !!object.geometry && !!object.geometry.attributes.color && object.geometry.attributes.color.itemSize === 4, + vertexUvs: + !!material.map || + !!material.bumpMap || + !!material.normalMap || + !!material.specularMap || + !!material.alphaMap || + !!material.emissiveMap || + !!material.roughnessMap || + !!material.metalnessMap || + !!material.clearcoatMap || + !!material.clearcoatRoughnessMap || + !!material.clearcoatNormalMap || + !!material.displacementMap || + !!material.transmissionMap || + !!material.thicknessMap || + !!material.specularIntensityMap || + !!material.specularColorMap || + !!material.sheenColorMap || + !!material.sheenRoughnessMap, + uvsVertexOnly: + !( + !!material.map || + !!material.bumpMap || + !!material.normalMap || + !!material.specularMap || + !!material.alphaMap || + !!material.emissiveMap || + !!material.roughnessMap || + !!material.metalnessMap || + !!material.clearcoatNormalMap || + material.transmission > 0 || + !!material.transmissionMap || + !!material.thicknessMap || + !!material.specularIntensityMap || + !!material.specularColorMap || + material.sheen > 0 || + !!material.sheenColorMap || + !!material.sheenRoughnessMap + ) && !!material.displacementMap, + + fog: !!fog, + useFog: material.fog, + fogExp2: fog && fog.isFogExp2, + + flatShading: !!material.flatShading, + + sizeAttenuation: material.sizeAttenuation, + logarithmicDepthBuffer: logarithmicDepthBuffer, + + skinning: object.isSkinnedMesh === true && maxBones > 0, + maxBones: maxBones, + useVertexTexture: floatVertexTextures, + + morphTargets: !!object.geometry && !!object.geometry.morphAttributes.position, + morphNormals: !!object.geometry && !!object.geometry.morphAttributes.normal, + morphTargetsCount: !!object.geometry && !!object.geometry.morphAttributes.position ? object.geometry.morphAttributes.position.length : 0, + + numDirLights: lights.directional.length, + numPointLights: lights.point.length, + numSpotLights: lights.spot.length, + numRectAreaLights: lights.rectArea.length, + numHemiLights: lights.hemi.length, + + numDirLightShadows: lights.directionalShadowMap.length, + numPointLightShadows: lights.pointShadowMap.length, + numSpotLightShadows: lights.spotShadowMap.length, + + numClippingPlanes: clipping.numPlanes, + numClipIntersection: clipping.numIntersection, + + dithering: material.dithering, + + shadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0, + shadowMapType: renderer.shadowMap.type, + + toneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping, + physicallyCorrectLights: renderer.physicallyCorrectLights, + + premultipliedAlpha: material.premultipliedAlpha, + + doubleSided: material.side === DoubleSide, + flipSided: material.side === BackSide, + + depthPacking: material.depthPacking !== undefined ? material.depthPacking : false, + + index0AttributeName: material.index0AttributeName, + + extensionDerivatives: material.extensions && material.extensions.derivatives, + extensionFragDepth: material.extensions && material.extensions.fragDepth, + extensionDrawBuffers: material.extensions && material.extensions.drawBuffers, + extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD, + + rendererExtensionFragDepth: isWebGL2 || extensions.has('EXT_frag_depth'), + rendererExtensionDrawBuffers: isWebGL2 || extensions.has('WEBGL_draw_buffers'), + rendererExtensionShaderTextureLod: isWebGL2 || extensions.has('EXT_shader_texture_lod'), + + customProgramCacheKey: material.customProgramCacheKey(), + }; + + return parameters; + } + + function getProgramCacheKey(parameters) { + const array = []; + + if (parameters.shaderID) { + array.push(parameters.shaderID); + } else { + array.push(parameters.customVertexShaderID); + array.push(parameters.customFragmentShaderID); + } + + if (parameters.defines !== undefined) { + for (const name in parameters.defines) { + array.push(name); + array.push(parameters.defines[name]); + } + } + + if (parameters.isRawShaderMaterial === false) { + getProgramCacheKeyParameters(array, parameters); + getProgramCacheKeyBooleans(array, parameters); + array.push(renderer.outputEncoding); + } + + array.push(parameters.customProgramCacheKey); + + return array.join(); + } + + function getProgramCacheKeyParameters(array, parameters) { + array.push(parameters.precision); + array.push(parameters.outputEncoding); + array.push(parameters.envMapMode); + array.push(parameters.combine); + array.push(parameters.vertexUvs); + array.push(parameters.fogExp2); + array.push(parameters.sizeAttenuation); + array.push(parameters.maxBones); + array.push(parameters.morphTargetsCount); + array.push(parameters.numDirLights); + array.push(parameters.numPointLights); + array.push(parameters.numSpotLights); + array.push(parameters.numHemiLights); + array.push(parameters.numRectAreaLights); + array.push(parameters.numDirLightShadows); + array.push(parameters.numPointLightShadows); + array.push(parameters.numSpotLightShadows); + array.push(parameters.shadowMapType); + array.push(parameters.toneMapping); + array.push(parameters.numClippingPlanes); + array.push(parameters.numClipIntersection); + array.push(parameters.alphaWrite); + } + + function getProgramCacheKeyBooleans(array, parameters) { + _programLayers.disableAll(); + + if (parameters.isWebGL2) _programLayers.enable(0); + if (parameters.supportsVertexTextures) _programLayers.enable(1); + if (parameters.instancing) _programLayers.enable(2); + if (parameters.instancingColor) _programLayers.enable(3); + if (parameters.map) _programLayers.enable(4); + if (parameters.matcap) _programLayers.enable(5); + if (parameters.envMap) _programLayers.enable(6); + if (parameters.envMapCubeUV) _programLayers.enable(7); + if (parameters.lightMap) _programLayers.enable(8); + if (parameters.aoMap) _programLayers.enable(9); + if (parameters.emissiveMap) _programLayers.enable(10); + if (parameters.bumpMap) _programLayers.enable(11); + if (parameters.normalMap) _programLayers.enable(12); + if (parameters.objectSpaceNormalMap) _programLayers.enable(13); + if (parameters.tangentSpaceNormalMap) _programLayers.enable(14); + if (parameters.clearcoat) _programLayers.enable(15); + if (parameters.clearcoatMap) _programLayers.enable(16); + if (parameters.clearcoatRoughnessMap) _programLayers.enable(17); + if (parameters.clearcoatNormalMap) _programLayers.enable(18); + if (parameters.displacementMap) _programLayers.enable(19); + if (parameters.specularMap) _programLayers.enable(20); + if (parameters.roughnessMap) _programLayers.enable(21); + if (parameters.metalnessMap) _programLayers.enable(22); + if (parameters.gradientMap) _programLayers.enable(23); + if (parameters.alphaMap) _programLayers.enable(24); + if (parameters.alphaTest) _programLayers.enable(25); + if (parameters.vertexColors) _programLayers.enable(26); + if (parameters.vertexAlphas) _programLayers.enable(27); + if (parameters.vertexUvs) _programLayers.enable(28); + if (parameters.vertexTangents) _programLayers.enable(29); + if (parameters.uvsVertexOnly) _programLayers.enable(30); + if (parameters.fog) _programLayers.enable(31); + + array.push(_programLayers.mask); + _programLayers.disableAll(); + + if (parameters.useFog) _programLayers.enable(0); + if (parameters.flatShading) _programLayers.enable(1); + if (parameters.logarithmicDepthBuffer) _programLayers.enable(2); + if (parameters.skinning) _programLayers.enable(3); + if (parameters.useVertexTexture) _programLayers.enable(4); + if (parameters.morphTargets) _programLayers.enable(5); + if (parameters.morphNormals) _programLayers.enable(6); + if (parameters.premultipliedAlpha) _programLayers.enable(7); + if (parameters.shadowMapEnabled) _programLayers.enable(8); + if (parameters.physicallyCorrectLights) _programLayers.enable(9); + if (parameters.doubleSided) _programLayers.enable(10); + if (parameters.flipSided) _programLayers.enable(11); + if (parameters.depthPacking) _programLayers.enable(12); + if (parameters.dithering) _programLayers.enable(13); + if (parameters.specularIntensityMap) _programLayers.enable(14); + if (parameters.specularColorMap) _programLayers.enable(15); + if (parameters.transmission) _programLayers.enable(16); + if (parameters.transmissionMap) _programLayers.enable(17); + if (parameters.thicknessMap) _programLayers.enable(18); + if (parameters.sheen) _programLayers.enable(19); + if (parameters.sheenColorMap) _programLayers.enable(20); + if (parameters.sheenRoughnessMap) _programLayers.enable(21); + if (parameters.decodeVideoTexture) _programLayers.enable(22); + + array.push(_programLayers.mask); + } + + function getUniforms(material) { + const shaderID = shaderIDs[material.type]; + let uniforms; + + if (shaderID) { + const shader = ShaderLib[shaderID]; + uniforms = UniformsUtils.clone(shader.uniforms); + } else { + uniforms = material.uniforms; + } + + return uniforms; + } + + function acquireProgram(parameters, cacheKey) { + let program; + + // Check if code has been already compiled + for (let p = 0, pl = programs.length; p < pl; p++) { + const preexistingProgram = programs[p]; + + if (preexistingProgram.cacheKey === cacheKey) { + program = preexistingProgram; + ++program.usedTimes; + + break; + } + } + + if (program === undefined) { + program = new WebGLProgram(renderer, cacheKey, parameters, bindingStates); + programs.push(program); + } + + return program; + } + + function releaseProgram(program) { + if (--program.usedTimes === 0) { + // Remove from unordered set + const i = programs.indexOf(program); + programs[i] = programs[programs.length - 1]; + programs.pop(); + + // Free WebGL resources + program.destroy(); + } + } + + function releaseShaderCache(material) { + _customShaders.remove(material); + } + + function dispose() { + _customShaders.dispose(); + } + + return { + getParameters: getParameters, + getProgramCacheKey: getProgramCacheKey, + getUniforms: getUniforms, + acquireProgram: acquireProgram, + releaseProgram: releaseProgram, + releaseShaderCache: releaseShaderCache, + // Exposed for resource monitoring & error feedback via renderer.info: + programs: programs, + dispose: dispose, + }; +} + +export { WebGLPrograms }; diff --git a/backend/libs/three/renderers/webgl/WebGLProperties.d.ts b/backend/libs/three/renderers/webgl/WebGLProperties.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..f6b86e1bb8397174c0de899a9b54c5cd8b7b4827 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLProperties.d.ts @@ -0,0 +1,8 @@ +export class WebGLProperties { + constructor(); + + get(object: any): any; + remove(object: any): void; + update(object: any, key: any, value: any): any; + dispose(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLProperties.js b/backend/libs/three/renderers/webgl/WebGLProperties.js new file mode 100644 index 0000000000000000000000000000000000000000..6b047f2b9dd2d7dcaa4b448dc90ef6927ae46448 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLProperties.js @@ -0,0 +1,35 @@ +function WebGLProperties() { + let properties = new WeakMap(); + + function get(object) { + let map = properties.get(object); + + if (map === undefined) { + map = {}; + properties.set(object, map); + } + + return map; + } + + function remove(object) { + properties.delete(object); + } + + function update(object, key, value) { + properties.get(object)[key] = value; + } + + function dispose() { + properties = new WeakMap(); + } + + return { + get: get, + remove: remove, + update: update, + dispose: dispose, + }; +} + +export { WebGLProperties }; diff --git a/backend/libs/three/renderers/webgl/WebGLRenderLists.d.ts b/backend/libs/three/renderers/webgl/WebGLRenderLists.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fac302bc4db2d3bc58a973c2f60f2b41b19046b4 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLRenderLists.d.ts @@ -0,0 +1,52 @@ +import { Object3D } from './../../core/Object3D'; +import { Material } from './../../materials/Material'; +import { WebGLProgram } from './WebGLProgram'; +import { Group } from './../../objects/Group'; +import { Scene } from './../../scenes/Scene'; +import { Camera } from './../../cameras/Camera'; +import { BufferGeometry } from '../../core/BufferGeometry'; +import { WebGLProperties } from './WebGLProperties'; + +export interface RenderItem { + id: number; + object: Object3D; + geometry: BufferGeometry | null; + material: Material; + program: WebGLProgram; + groupOrder: number; + renderOrder: number; + z: number; + group: Group | null; +} + +export class WebGLRenderList { + constructor(properties: WebGLProperties); + + /** + * @default [] + */ + opaque: RenderItem[]; + + /** + * @default [] + */ + transparent: RenderItem[]; + + /** + * @default [] + */ + transmissive: RenderItem[]; + + init(): void; + push(object: Object3D, geometry: BufferGeometry | null, material: Material, groupOrder: number, z: number, group: Group | null): void; + unshift(object: Object3D, geometry: BufferGeometry | null, material: Material, groupOrder: number, z: number, group: Group | null): void; + sort(opaqueSort: (a: any, b: any) => number, transparentSort: (a: any, b: any) => number): void; + finish(): void; +} + +export class WebGLRenderLists { + constructor(properties: WebGLProperties); + + dispose(): void; + get(scene: Scene, renderCallDepth: number): WebGLRenderList; +} diff --git a/backend/libs/three/renderers/webgl/WebGLRenderLists.js b/backend/libs/three/renderers/webgl/WebGLRenderLists.js new file mode 100644 index 0000000000000000000000000000000000000000..487cb4f1889ccf512680357c472fd8090aef7625 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLRenderLists.js @@ -0,0 +1,166 @@ +function painterSortStable(a, b) { + if (a.groupOrder !== b.groupOrder) { + return a.groupOrder - b.groupOrder; + } else if (a.renderOrder !== b.renderOrder) { + return a.renderOrder - b.renderOrder; + } else if (a.material.id !== b.material.id) { + return a.material.id - b.material.id; + } else if (a.z !== b.z) { + return a.z - b.z; + } else { + return a.id - b.id; + } +} + +function reversePainterSortStable(a, b) { + if (a.groupOrder !== b.groupOrder) { + return a.groupOrder - b.groupOrder; + } else if (a.renderOrder !== b.renderOrder) { + return a.renderOrder - b.renderOrder; + } else if (a.z !== b.z) { + return b.z - a.z; + } else { + return a.id - b.id; + } +} + +function WebGLRenderList() { + const renderItems = []; + let renderItemsIndex = 0; + + const opaque = []; + const transmissive = []; + const transparent = []; + + function init() { + renderItemsIndex = 0; + + opaque.length = 0; + transmissive.length = 0; + transparent.length = 0; + } + + function getNextRenderItem(object, geometry, material, groupOrder, z, group) { + let renderItem = renderItems[renderItemsIndex]; + + if (renderItem === undefined) { + renderItem = { + id: object.id, + object: object, + geometry: geometry, + material: material, + groupOrder: groupOrder, + renderOrder: object.renderOrder, + z: z, + group: group, + }; + + renderItems[renderItemsIndex] = renderItem; + } else { + renderItem.id = object.id; + renderItem.object = object; + renderItem.geometry = geometry; + renderItem.material = material; + renderItem.groupOrder = groupOrder; + renderItem.renderOrder = object.renderOrder; + renderItem.z = z; + renderItem.group = group; + } + + renderItemsIndex++; + + return renderItem; + } + + function push(object, geometry, material, groupOrder, z, group) { + const renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group); + + if (material.transmission > 0.0) { + transmissive.push(renderItem); + } else if (material.transparent === true) { + transparent.push(renderItem); + } else { + opaque.push(renderItem); + } + } + + function unshift(object, geometry, material, groupOrder, z, group) { + const renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group); + + if (material.transmission > 0.0) { + transmissive.unshift(renderItem); + } else if (material.transparent === true) { + transparent.unshift(renderItem); + } else { + opaque.unshift(renderItem); + } + } + + function sort(customOpaqueSort, customTransparentSort) { + if (opaque.length > 1) opaque.sort(customOpaqueSort || painterSortStable); + if (transmissive.length > 1) transmissive.sort(customTransparentSort || reversePainterSortStable); + if (transparent.length > 1) transparent.sort(customTransparentSort || reversePainterSortStable); + } + + function finish() { + // Clear references from inactive renderItems in the list + + for (let i = renderItemsIndex, il = renderItems.length; i < il; i++) { + const renderItem = renderItems[i]; + + if (renderItem.id === null) break; + + renderItem.id = null; + renderItem.object = null; + renderItem.geometry = null; + renderItem.material = null; + renderItem.group = null; + } + } + + return { + opaque: opaque, + transmissive: transmissive, + transparent: transparent, + + init: init, + push: push, + unshift: unshift, + finish: finish, + + sort: sort, + }; +} + +function WebGLRenderLists() { + let lists = new WeakMap(); + + function get(scene, renderCallDepth) { + let list; + + if (lists.has(scene) === false) { + list = new WebGLRenderList(); + lists.set(scene, [list]); + } else { + if (renderCallDepth >= lists.get(scene).length) { + list = new WebGLRenderList(); + lists.get(scene).push(list); + } else { + list = lists.get(scene)[renderCallDepth]; + } + } + + return list; + } + + function dispose() { + lists = new WeakMap(); + } + + return { + get: get, + dispose: dispose, + }; +} + +export { WebGLRenderLists, WebGLRenderList }; diff --git a/backend/libs/three/renderers/webgl/WebGLRenderStates.js b/backend/libs/three/renderers/webgl/WebGLRenderStates.js new file mode 100644 index 0000000000000000000000000000000000000000..0e561ac8f168f51218141aa34039a7cb7f34eb54 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLRenderStates.js @@ -0,0 +1,79 @@ +import { WebGLLights } from './WebGLLights.js'; + +function WebGLRenderState(extensions, capabilities) { + const lights = new WebGLLights(extensions, capabilities); + + const lightsArray = []; + const shadowsArray = []; + + function init() { + lightsArray.length = 0; + shadowsArray.length = 0; + } + + function pushLight(light) { + lightsArray.push(light); + } + + function pushShadow(shadowLight) { + shadowsArray.push(shadowLight); + } + + function setupLights(physicallyCorrectLights) { + lights.setup(lightsArray, physicallyCorrectLights); + } + + function setupLightsView(camera) { + lights.setupView(lightsArray, camera); + } + + const state = { + lightsArray: lightsArray, + shadowsArray: shadowsArray, + + lights: lights, + }; + + return { + init: init, + state: state, + setupLights: setupLights, + setupLightsView: setupLightsView, + + pushLight: pushLight, + pushShadow: pushShadow, + }; +} + +function WebGLRenderStates(extensions, capabilities) { + let renderStates = new WeakMap(); + + function get(scene, renderCallDepth = 0) { + let renderState; + + if (renderStates.has(scene) === false) { + renderState = new WebGLRenderState(extensions, capabilities); + renderStates.set(scene, [renderState]); + } else { + if (renderCallDepth >= renderStates.get(scene).length) { + renderState = new WebGLRenderState(extensions, capabilities); + renderStates.get(scene).push(renderState); + } else { + renderState = renderStates.get(scene)[renderCallDepth]; + } + } + + return renderState; + } + + function dispose() { + renderStates = new WeakMap(); + } + + return { + get: get, + dispose: dispose, + }; +} + +export { WebGLRenderStates }; diff --git a/backend/libs/three/renderers/webgl/WebGLShader.d.ts b/backend/libs/three/renderers/webgl/WebGLShader.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..5704fb88e353d5e727a3b4f105d62eaeef471614 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLShader.d.ts @@ -0,0 +1 @@ +export function WebGLShader(gl: WebGLRenderingContext, type: string, string: string): WebGLShader; diff --git a/backend/libs/three/renderers/webgl/WebGLShader.js b/backend/libs/three/renderers/webgl/WebGLShader.js new file mode 100644 index 0000000000000000000000000000000000000000..68eeba05af06d40e5ed3f93ecca0f563de29487d --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLShader.js @@ -0,0 +1,10 @@ +function WebGLShader(gl, type, string) { + const shader = gl.createShader(type); + + gl.shaderSource(shader, string); + gl.compileShader(shader); + + return shader; +} + +export { WebGLShader }; diff --git a/backend/libs/three/renderers/webgl/WebGLShaderCache.js b/backend/libs/three/renderers/webgl/WebGLShaderCache.js new file mode 100644 index 0000000000000000000000000000000000000000..aada8bba7551634ade381afc7eab6d49bc7387ee --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLShaderCache.js @@ -0,0 +1,88 @@ +let _id = 0; + +class WebGLShaderCache { + constructor() { + this.shaderCache = new Map(); + this.materialCache = new Map(); + } + + update(material) { + const vertexShader = material.vertexShader; + const fragmentShader = material.fragmentShader; + + const vertexShaderStage = this._getShaderStage(vertexShader); + const fragmentShaderStage = this._getShaderStage(fragmentShader); + + const materialShaders = this._getShaderCacheForMaterial(material); + + if (materialShaders.has(vertexShaderStage) === false) { + materialShaders.add(vertexShaderStage); + vertexShaderStage.usedTimes++; + } + + if (materialShaders.has(fragmentShaderStage) === false) { + materialShaders.add(fragmentShaderStage); + fragmentShaderStage.usedTimes++; + } + + return this; + } + + remove(material) { + const materialShaders = this.materialCache.get(material); + + for (const shaderStage of materialShaders) { + shaderStage.usedTimes--; + + if (shaderStage.usedTimes === 0) this.shaderCache.delete(shaderStage); + } + + this.materialCache.delete(material); + + return this; + } + + getVertexShaderID(material) { + return this._getShaderStage(material.vertexShader).id; + } + + getFragmentShaderID(material) { + return this._getShaderStage(material.fragmentShader).id; + } + + dispose() { + this.shaderCache.clear(); + this.materialCache.clear(); + } + + _getShaderCacheForMaterial(material) { + const cache = this.materialCache; + + if (cache.has(material) === false) { + cache.set(material, new Set()); + } + + return cache.get(material); + } + + _getShaderStage(code) { + const cache = this.shaderCache; + + if (cache.has(code) === false) { + const stage = new WebGLShaderStage(); + cache.set(code, stage); + } + + return cache.get(code); + } +} + +class WebGLShaderStage { + constructor() { + this.id = _id++; + + this.usedTimes = 0; + } +} + +export { WebGLShaderCache }; diff --git a/backend/libs/three/renderers/webgl/WebGLShadowMap.d.ts b/backend/libs/three/renderers/webgl/WebGLShadowMap.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..08494756b1b4b38d5e2e4071ef4f7f6ce0a396f2 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLShadowMap.d.ts @@ -0,0 +1,38 @@ +import { WebGLCapabilities } from './WebGLCapabilities'; +import { Scene } from './../../scenes/Scene'; +import { Camera } from './../../cameras/Camera'; +import { WebGLRenderer } from '../WebGLRenderer'; +import { ShadowMapType } from '../../constants'; +import { WebGLObjects } from './WebGLObjects'; +import { Light } from '../../lights/Light'; + +export class WebGLShadowMap { + constructor(_renderer: WebGLRenderer, _objects: WebGLObjects, _capabilities: WebGLCapabilities); + + /** + * @default false + */ + enabled: boolean; + + /** + * @default true + */ + autoUpdate: boolean; + + /** + * @default false + */ + needsUpdate: boolean; + + /** + * @default THREE.PCFShadowMap + */ + type: ShadowMapType; + + render(shadowsArray: Light[], scene: Scene, camera: Camera): void; + + /** + * @deprecated Use {@link Material#shadowSide} instead. + */ + cullFace: any; +} diff --git a/backend/libs/three/renderers/webgl/WebGLShadowMap.js b/backend/libs/three/renderers/webgl/WebGLShadowMap.js new file mode 100644 index 0000000000000000000000000000000000000000..383eb0341d25dd246860d8387481f3cdeeab5dd0 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLShadowMap.js @@ -0,0 +1,318 @@ +import { + FrontSide, + BackSide, + DoubleSide, + RGBAFormat, + NearestFilter, + LinearFilter, + PCFShadowMap, + VSMShadowMap, + RGBADepthPacking, + NoBlending, +} from '../../constants.js'; +import { WebGLRenderTarget } from '../WebGLRenderTarget.js'; +import { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js'; +import { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js'; +import { ShaderMaterial } from '../../materials/ShaderMaterial.js'; +import { BufferAttribute } from '../../core/BufferAttribute.js'; +import { BufferGeometry } from '../../core/BufferGeometry.js'; +import { Mesh } from '../../objects/Mesh.js'; +import { Vector4 } from '../../math/Vector4.js'; +import { Vector2 } from '../../math/Vector2.js'; +import { Frustum } from '../../math/Frustum.js'; + +import * as vsm from '../shaders/ShaderLib/vsm.glsl.js'; + +function WebGLShadowMap(_renderer, _objects, _capabilities) { + let _frustum = new Frustum(); + + const _shadowMapSize = new Vector2(), + _viewportSize = new Vector2(), + _viewport = new Vector4(), + _depthMaterial = new MeshDepthMaterial({ depthPacking: RGBADepthPacking }), + _distanceMaterial = new MeshDistanceMaterial(), + _materialCache = {}, + _maxTextureSize = _capabilities.maxTextureSize; + + const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide }; + + const shadowMaterialVertical = new ShaderMaterial({ + defines: { + VSM_SAMPLES: 8, + }, + uniforms: { + shadow_pass: { value: null }, + resolution: { value: new Vector2() }, + radius: { value: 4.0 }, + }, + + vertexShader: vsm.vertex, + fragmentShader: vsm.fragment, + }); + + const shadowMaterialHorizontal = shadowMaterialVertical.clone(); + shadowMaterialHorizontal.defines.HORIZONTAL_PASS = 1; + + const fullScreenTri = new BufferGeometry(); + fullScreenTri.setAttribute('position', new BufferAttribute(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3)); + + const fullScreenMesh = new Mesh(fullScreenTri, shadowMaterialVertical); + + const scope = this; + + this.enabled = false; + + this.autoUpdate = true; + this.needsUpdate = false; + + this.type = PCFShadowMap; + + this.render = function (lights, scene, camera) { + if (scope.enabled === false) return; + if (scope.autoUpdate === false && scope.needsUpdate === false) return; + + if (lights.length === 0) return; + + const currentRenderTarget = _renderer.getRenderTarget(); + const activeCubeFace = _renderer.getActiveCubeFace(); + const activeMipmapLevel = _renderer.getActiveMipmapLevel(); + + const _state = _renderer.state; + + // Set GL state for depth map. + _state.setBlending(NoBlending); + _state.buffers.color.setClear(1, 1, 1, 1); + _state.buffers.depth.setTest(true); + _state.setScissorTest(false); + + // render depth map + + for (let i = 0, il = lights.length; i < il; i++) { + const light = lights[i]; + const shadow = light.shadow; + + if (shadow === undefined) { + console.warn('THREE.WebGLShadowMap:', light, 'has no shadow.'); + continue; + } + + if (shadow.autoUpdate === false && shadow.needsUpdate === false) continue; + + _shadowMapSize.copy(shadow.mapSize); + + const shadowFrameExtents = shadow.getFrameExtents(); + + _shadowMapSize.multiply(shadowFrameExtents); + + _viewportSize.copy(shadow.mapSize); + + if (_shadowMapSize.x > _maxTextureSize || _shadowMapSize.y > _maxTextureSize) { + if (_shadowMapSize.x > _maxTextureSize) { + _viewportSize.x = Math.floor(_maxTextureSize / shadowFrameExtents.x); + _shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x; + shadow.mapSize.x = _viewportSize.x; + } + + if (_shadowMapSize.y > _maxTextureSize) { + _viewportSize.y = Math.floor(_maxTextureSize / shadowFrameExtents.y); + _shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y; + shadow.mapSize.y = _viewportSize.y; + } + } + + if (shadow.map === null && !shadow.isPointLightShadow && this.type === VSMShadowMap) { + const pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars); + + shadow.camera.updateProjectionMatrix(); + } + + if (shadow.map === null) { + const pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat }; + + shadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars); + shadow.map.texture.name = light.name + '.shadowMap'; + + shadow.camera.updateProjectionMatrix(); + } + + _renderer.setRenderTarget(shadow.map); + _renderer.clear(); + + const viewportCount = shadow.getViewportCount(); + + for (let vp = 0; vp < viewportCount; vp++) { + const viewport = shadow.getViewport(vp); + + _viewport.set(_viewportSize.x * viewport.x, _viewportSize.y * viewport.y, _viewportSize.x * viewport.z, _viewportSize.y * viewport.w); + + _state.viewport(_viewport); + + shadow.updateMatrices(light, vp); + + _frustum = shadow.getFrustum(); + + renderObject(scene, camera, shadow.camera, light, this.type); + } + + // do blur pass for VSM + + if (!shadow.isPointLightShadow && this.type === VSMShadowMap) { + VSMPass(shadow, camera); + } + + shadow.needsUpdate = false; + } + + scope.needsUpdate = false; + + _renderer.setRenderTarget(currentRenderTarget, activeCubeFace, activeMipmapLevel); + }; + + function VSMPass(shadow, camera) { + const geometry = _objects.update(fullScreenMesh); + + if (shadowMaterialVertical.defines.VSM_SAMPLES !== shadow.blurSamples) { + shadowMaterialVertical.defines.VSM_SAMPLES = shadow.blurSamples; + shadowMaterialHorizontal.defines.VSM_SAMPLES = shadow.blurSamples; + + shadowMaterialVertical.needsUpdate = true; + shadowMaterialHorizontal.needsUpdate = true; + } + + // vertical pass + + shadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture; + shadowMaterialVertical.uniforms.resolution.value = shadow.mapSize; + shadowMaterialVertical.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget(shadow.mapPass); + _renderer.clear(); + _renderer.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null); + + // horizontal pass + + shadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture; + shadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize; + shadowMaterialHorizontal.uniforms.radius.value = shadow.radius; + _renderer.setRenderTarget(shadow.map); + _renderer.clear(); + _renderer.renderBufferDirect(camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null); + } + + function getDepthMaterial(object, geometry, material, light, shadowCameraNear, shadowCameraFar, type) { + let result = null; + + const customMaterial = light.isPointLight === true ? object.customDistanceMaterial : object.customDepthMaterial; + + if (customMaterial !== undefined) { + result = customMaterial; + } else { + result = light.isPointLight === true ? _distanceMaterial : _depthMaterial; + } + + if ( + (_renderer.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0) || + (material.displacementMap && material.displacementScale !== 0) || + (material.alphaMap && material.alphaTest > 0) + ) { + // in this case we need a unique material instance reflecting the + // appropriate state + + const keyA = result.uuid, + keyB = material.uuid; + + let materialsForVariant = _materialCache[keyA]; + + if (materialsForVariant === undefined) { + materialsForVariant = {}; + _materialCache[keyA] = materialsForVariant; + } + + let cachedMaterial = materialsForVariant[keyB]; + + if (cachedMaterial === undefined) { + cachedMaterial = result.clone(); + materialsForVariant[keyB] = cachedMaterial; + } + + result = cachedMaterial; + } + + result.visible = material.visible; + result.wireframe = material.wireframe; + + if (type === VSMShadowMap) { + result.side = material.shadowSide !== null ? material.shadowSide : material.side; + } else { + result.side = material.shadowSide !== null ? material.shadowSide : shadowSide[material.side]; + } + + result.alphaMap = material.alphaMap; + result.alphaTest = material.alphaTest; + + result.clipShadows = material.clipShadows; + result.clippingPlanes = material.clippingPlanes; + result.clipIntersection = material.clipIntersection; + + result.displacementMap = material.displacementMap; + result.displacementScale = material.displacementScale; + result.displacementBias = material.displacementBias; + + result.wireframeLinewidth = material.wireframeLinewidth; + result.linewidth = material.linewidth; + + if (light.isPointLight === true && result.isMeshDistanceMaterial === true) { + result.referencePosition.setFromMatrixPosition(light.matrixWorld); + result.nearDistance = shadowCameraNear; + result.farDistance = shadowCameraFar; + } + + return result; + } + + function renderObject(object, camera, shadowCamera, light, type) { + if (object.visible === false) return; + + const visible = object.layers.test(camera.layers); + + if (visible && (object.isMesh || object.isLine || object.isPoints)) { + if ((object.castShadow || (object.receiveShadow && type === VSMShadowMap)) && (!object.frustumCulled || _frustum.intersectsObject(object))) { + object.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld); + + const geometry = _objects.update(object); + const material = object.material; + + if (Array.isArray(material)) { + const groups = geometry.groups; + + for (let k = 0, kl = groups.length; k < kl; k++) { + const group = groups[k]; + const groupMaterial = material[group.materialIndex]; + + if (groupMaterial && groupMaterial.visible) { + const depthMaterial = getDepthMaterial(object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type); + + _renderer.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, group); + } + } + } else if (material.visible) { + const depthMaterial = getDepthMaterial(object, geometry, material, light, shadowCamera.near, shadowCamera.far, type); + + _renderer.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, null); + } + } + } + + const children = object.children; + + for (let i = 0, l = children.length; i < l; i++) { + renderObject(children[i], camera, shadowCamera, light, type); + } + } +} + +export { WebGLShadowMap }; diff --git a/backend/libs/three/renderers/webgl/WebGLState.d.ts b/backend/libs/three/renderers/webgl/WebGLState.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..67801092d6ba5a370bcbba59a0fbcfbefc326cde --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLState.d.ts @@ -0,0 +1,107 @@ +import { CullFace, Blending, BlendingEquation, BlendingSrcFactor, BlendingDstFactor, DepthModes } from '../../constants'; +import { WebGLCapabilities } from './WebGLCapabilities'; +import { WebGLExtensions } from './WebGLExtensions'; +import { Material } from '../../materials/Material'; +import { Vector4 } from '../../math/Vector4'; + +export class WebGLColorBuffer { + constructor(); + + setMask(colorMask: boolean): void; + setLocked(lock: boolean): void; + setClear(r: number, g: number, b: number, a: number, premultipliedAlpha: boolean): void; + reset(): void; +} + +export class WebGLDepthBuffer { + constructor(); + + setTest(depthTest: boolean): void; + setMask(depthMask: boolean): void; + setFunc(depthFunc: DepthModes): void; + setLocked(lock: boolean): void; + setClear(depth: number): void; + reset(): void; +} + +export class WebGLStencilBuffer { + constructor(); + + setTest(stencilTest: boolean): void; + setMask(stencilMask: number): void; + setFunc(stencilFunc: number, stencilRef: number, stencilMask: number): void; + setOp(stencilFail: number, stencilZFail: number, stencilZPass: number): void; + setLocked(lock: boolean): void; + setClear(stencil: number): void; + reset(): void; +} + +export class WebGLState { + constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions, capabilities: WebGLCapabilities); + + buffers: { + color: WebGLColorBuffer; + depth: WebGLDepthBuffer; + stencil: WebGLStencilBuffer; + }; + + initAttributes(): void; + enableAttribute(attribute: number): void; + enableAttributeAndDivisor(attribute: number, meshPerAttribute: number): void; + disableUnusedAttributes(): void; + vertexAttribPointer(index: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + enable(id: number): void; + disable(id: number): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; + bindXRFramebuffer(framebuffer: WebGLFramebuffer | null): void; + useProgram(program: any): boolean; + setBlending( + blending: Blending, + blendEquation?: BlendingEquation, + blendSrc?: BlendingSrcFactor, + blendDst?: BlendingDstFactor, + blendEquationAlpha?: BlendingEquation, + blendSrcAlpha?: BlendingSrcFactor, + blendDstAlpha?: BlendingDstFactor, + premultiplyAlpha?: boolean + ): void; + setMaterial(material: Material, frontFaceCW: boolean): void; + setFlipSided(flipSided: boolean): void; + setCullFace(cullFace: CullFace): void; + setLineWidth(width: number): void; + setPolygonOffset(polygonoffset: boolean, factor?: number, units?: number): void; + setScissorTest(scissorTest: boolean): void; + activeTexture(webglSlot: number): void; + bindTexture(webglType: number, webglTexture: any): void; + unbindTexture(): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D + texImage2D( + target: number, + level: number, + internalformat: number, + width: number, + height: number, + border: number, + format: number, + type: number, + pixels: ArrayBufferView | null + ): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, source: any): void; + texImage3D( + target: number, + level: number, + internalformat: number, + width: number, + height: number, + depth: number, + border: number, + format: number, + type: number, + pixels: any + ): void; + scissor(scissor: Vector4): void; + viewport(viewport: Vector4): void; + reset(): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLState.js b/backend/libs/three/renderers/webgl/WebGLState.js new file mode 100644 index 0000000000000000000000000000000000000000..b2a3021a3d5ed2fdaf17a4e4fcbe836280e3e86b --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLState.js @@ -0,0 +1,944 @@ +import { + NotEqualDepth, + GreaterDepth, + GreaterEqualDepth, + EqualDepth, + LessEqualDepth, + LessDepth, + AlwaysDepth, + NeverDepth, + CullFaceFront, + CullFaceBack, + CullFaceNone, + DoubleSide, + BackSide, + CustomBlending, + MultiplyBlending, + SubtractiveBlending, + AdditiveBlending, + NoBlending, + NormalBlending, + AddEquation, + SubtractEquation, + ReverseSubtractEquation, + MinEquation, + MaxEquation, + ZeroFactor, + OneFactor, + SrcColorFactor, + SrcAlphaFactor, + SrcAlphaSaturateFactor, + DstColorFactor, + DstAlphaFactor, + OneMinusSrcColorFactor, + OneMinusSrcAlphaFactor, + OneMinusDstColorFactor, + OneMinusDstAlphaFactor, +} from '../../constants.js'; +import { Vector4 } from '../../math/Vector4.js'; + +function WebGLState(gl, extensions, capabilities) { + const isWebGL2 = capabilities.isWebGL2; + + function ColorBuffer() { + let locked = false; + + const color = new Vector4(); + let currentColorMask = null; + const currentColorClear = new Vector4(0, 0, 0, 0); + + return { + setMask: function (colorMask) { + if (currentColorMask !== colorMask && !locked) { + gl.colorMask(colorMask, colorMask, colorMask, colorMask); + currentColorMask = colorMask; + } + }, + + setLocked: function (lock) { + locked = lock; + }, + + setClear: function (r, g, b, a, premultipliedAlpha) { + if (premultipliedAlpha === true) { + r *= a; + g *= a; + b *= a; + } + + color.set(r, g, b, a); + + if (currentColorClear.equals(color) === false) { + gl.clearColor(r, g, b, a); + currentColorClear.copy(color); + } + }, + + reset: function () { + locked = false; + + currentColorMask = null; + currentColorClear.set(-1, 0, 0, 0); // set to invalid state + }, + }; + } + + function DepthBuffer() { + let locked = false; + + let currentDepthMask = null; + let currentDepthFunc = null; + let currentDepthClear = null; + + return { + setTest: function (depthTest) { + if (depthTest) { + enable(gl.DEPTH_TEST); + } else { + disable(gl.DEPTH_TEST); + } + }, + + setMask: function (depthMask) { + if (currentDepthMask !== depthMask && !locked) { + gl.depthMask(depthMask); + currentDepthMask = depthMask; + } + }, + + setFunc: function (depthFunc) { + if (currentDepthFunc !== depthFunc) { + if (depthFunc) { + switch (depthFunc) { + case NeverDepth: + gl.depthFunc(gl.NEVER); + break; + + case AlwaysDepth: + gl.depthFunc(gl.ALWAYS); + break; + + case LessDepth: + gl.depthFunc(gl.LESS); + break; + + case LessEqualDepth: + gl.depthFunc(gl.LEQUAL); + break; + + case EqualDepth: + gl.depthFunc(gl.EQUAL); + break; + + case GreaterEqualDepth: + gl.depthFunc(gl.GEQUAL); + break; + + case GreaterDepth: + gl.depthFunc(gl.GREATER); + break; + + case NotEqualDepth: + gl.depthFunc(gl.NOTEQUAL); + break; + + default: + gl.depthFunc(gl.LEQUAL); + } + } else { + gl.depthFunc(gl.LEQUAL); + } + + currentDepthFunc = depthFunc; + } + }, + + setLocked: function (lock) { + locked = lock; + }, + + setClear: function (depth) { + if (currentDepthClear !== depth) { + gl.clearDepth(depth); + currentDepthClear = depth; + } + }, + + reset: function () { + locked = false; + + currentDepthMask = null; + currentDepthFunc = null; + currentDepthClear = null; + }, + }; + } + + function StencilBuffer() { + let locked = false; + + let currentStencilMask = null; + let currentStencilFunc = null; + let currentStencilRef = null; + let currentStencilFuncMask = null; + let currentStencilFail = null; + let currentStencilZFail = null; + let currentStencilZPass = null; + let currentStencilClear = null; + + return { + setTest: function (stencilTest) { + if (!locked) { + if (stencilTest) { + enable(gl.STENCIL_TEST); + } else { + disable(gl.STENCIL_TEST); + } + } + }, + + setMask: function (stencilMask) { + if (currentStencilMask !== stencilMask && !locked) { + gl.stencilMask(stencilMask); + currentStencilMask = stencilMask; + } + }, + + setFunc: function (stencilFunc, stencilRef, stencilMask) { + if (currentStencilFunc !== stencilFunc || currentStencilRef !== stencilRef || currentStencilFuncMask !== stencilMask) { + gl.stencilFunc(stencilFunc, stencilRef, stencilMask); + + currentStencilFunc = stencilFunc; + currentStencilRef = stencilRef; + currentStencilFuncMask = stencilMask; + } + }, + + setOp: function (stencilFail, stencilZFail, stencilZPass) { + if (currentStencilFail !== stencilFail || currentStencilZFail !== stencilZFail || currentStencilZPass !== stencilZPass) { + gl.stencilOp(stencilFail, stencilZFail, stencilZPass); + + currentStencilFail = stencilFail; + currentStencilZFail = stencilZFail; + currentStencilZPass = stencilZPass; + } + }, + + setLocked: function (lock) { + locked = lock; + }, + + setClear: function (stencil) { + if (currentStencilClear !== stencil) { + gl.clearStencil(stencil); + currentStencilClear = stencil; + } + }, + + reset: function () { + locked = false; + + currentStencilMask = null; + currentStencilFunc = null; + currentStencilRef = null; + currentStencilFuncMask = null; + currentStencilFail = null; + currentStencilZFail = null; + currentStencilZPass = null; + currentStencilClear = null; + }, + }; + } + + // + + const colorBuffer = new ColorBuffer(); + const depthBuffer = new DepthBuffer(); + const stencilBuffer = new StencilBuffer(); + + let enabledCapabilities = {}; + + let currentBoundFramebuffers = {}; + let currentDrawbuffers = new WeakMap(); + let defaultDrawbuffers = []; + + let currentProgram = null; + + let currentBlendingEnabled = false; + let currentBlending = null; + let currentBlendEquation = null; + let currentBlendSrc = null; + let currentBlendDst = null; + let currentBlendEquationAlpha = null; + let currentBlendSrcAlpha = null; + let currentBlendDstAlpha = null; + let currentPremultipledAlpha = false; + + let currentFlipSided = null; + let currentCullFace = null; + + let currentLineWidth = null; + + let currentPolygonOffsetFactor = null; + let currentPolygonOffsetUnits = null; + + const maxTextures = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); + + let lineWidthAvailable = false; + let version = 0; + const glVersion = gl.getParameter(gl.VERSION); + + if (glVersion.indexOf('WebGL') !== -1) { + version = parseFloat(/^WebGL (\d)/.exec(glVersion)[1]); + lineWidthAvailable = version >= 1.0; + } else if (glVersion.indexOf('OpenGL ES') !== -1) { + version = parseFloat(/^OpenGL ES (\d)/.exec(glVersion)[1]); + lineWidthAvailable = version >= 2.0; + } + + let currentTextureSlot = null; + let currentBoundTextures = {}; + + const scissorParam = gl.getParameter(gl.SCISSOR_BOX); + const viewportParam = gl.getParameter(gl.VIEWPORT); + + const currentScissor = new Vector4().fromArray(scissorParam); + const currentViewport = new Vector4().fromArray(viewportParam); + + function createTexture(type, target, count) { + const data = new Uint8Array(4); // 4 is required to match default unpack alignment of 4. + const texture = gl.createTexture(); + + gl.bindTexture(type, texture); + gl.texParameteri(type, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(type, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + for (let i = 0; i < count; i++) { + gl.texImage2D(target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data); + } + + return texture; + } + + const emptyTextures = {}; + emptyTextures[gl.TEXTURE_2D] = createTexture(gl.TEXTURE_2D, gl.TEXTURE_2D, 1); + emptyTextures[gl.TEXTURE_CUBE_MAP] = createTexture(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6); + + // init + + colorBuffer.setClear(0, 0, 0, 1); + depthBuffer.setClear(1); + stencilBuffer.setClear(0); + + enable(gl.DEPTH_TEST); + depthBuffer.setFunc(LessEqualDepth); + + setFlipSided(false); + setCullFace(CullFaceBack); + enable(gl.CULL_FACE); + + setBlending(NoBlending); + + // + + function enable(id) { + if (enabledCapabilities[id] !== true) { + gl.enable(id); + enabledCapabilities[id] = true; + } + } + + function disable(id) { + if (enabledCapabilities[id] !== false) { + gl.disable(id); + enabledCapabilities[id] = false; + } + } + + function bindFramebuffer(target, framebuffer) { + if (currentBoundFramebuffers[target] !== framebuffer) { + gl.bindFramebuffer(target, framebuffer); + + currentBoundFramebuffers[target] = framebuffer; + + if (isWebGL2) { + // gl.DRAW_FRAMEBUFFER is equivalent to gl.FRAMEBUFFER + + if (target === gl.DRAW_FRAMEBUFFER) { + currentBoundFramebuffers[gl.FRAMEBUFFER] = framebuffer; + } + + if (target === gl.FRAMEBUFFER) { + currentBoundFramebuffers[gl.DRAW_FRAMEBUFFER] = framebuffer; + } + } + + return true; + } + + return false; + } + + function drawBuffers(renderTarget, framebuffer) { + let drawBuffers = defaultDrawbuffers; + + let needsUpdate = false; + + if (renderTarget) { + drawBuffers = currentDrawbuffers.get(framebuffer); + + if (drawBuffers === undefined) { + drawBuffers = []; + currentDrawbuffers.set(framebuffer, drawBuffers); + } + + if (renderTarget.isWebGLMultipleRenderTargets) { + const textures = renderTarget.texture; + + if (drawBuffers.length !== textures.length || drawBuffers[0] !== gl.COLOR_ATTACHMENT0) { + for (let i = 0, il = textures.length; i < il; i++) { + drawBuffers[i] = gl.COLOR_ATTACHMENT0 + i; + } + + drawBuffers.length = textures.length; + + needsUpdate = true; + } + } else { + if (drawBuffers[0] !== gl.COLOR_ATTACHMENT0) { + drawBuffers[0] = gl.COLOR_ATTACHMENT0; + + needsUpdate = true; + } + } + } else { + if (drawBuffers[0] !== gl.BACK) { + drawBuffers[0] = gl.BACK; + + needsUpdate = true; + } + } + + if (needsUpdate) { + if (capabilities.isWebGL2) { + gl.drawBuffers(drawBuffers); + } else { + extensions.get('WEBGL_draw_buffers').drawBuffersWEBGL(drawBuffers); + } + } + } + + function useProgram(program) { + if (currentProgram !== program) { + gl.useProgram(program); + + currentProgram = program; + + return true; + } + + return false; + } + + const equationToGL = { + [AddEquation]: gl.FUNC_ADD, + [SubtractEquation]: gl.FUNC_SUBTRACT, + [ReverseSubtractEquation]: gl.FUNC_REVERSE_SUBTRACT, + }; + + if (isWebGL2) { + equationToGL[MinEquation] = gl.MIN; + equationToGL[MaxEquation] = gl.MAX; + } else { + const extension = extensions.get('EXT_blend_minmax'); + + if (extension !== null) { + equationToGL[MinEquation] = extension.MIN_EXT; + equationToGL[MaxEquation] = extension.MAX_EXT; + } + } + + const factorToGL = { + [ZeroFactor]: gl.ZERO, + [OneFactor]: gl.ONE, + [SrcColorFactor]: gl.SRC_COLOR, + [SrcAlphaFactor]: gl.SRC_ALPHA, + [SrcAlphaSaturateFactor]: gl.SRC_ALPHA_SATURATE, + [DstColorFactor]: gl.DST_COLOR, + [DstAlphaFactor]: gl.DST_ALPHA, + [OneMinusSrcColorFactor]: gl.ONE_MINUS_SRC_COLOR, + [OneMinusSrcAlphaFactor]: gl.ONE_MINUS_SRC_ALPHA, + [OneMinusDstColorFactor]: gl.ONE_MINUS_DST_COLOR, + [OneMinusDstAlphaFactor]: gl.ONE_MINUS_DST_ALPHA, + }; + + function setBlending(blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha) { + if (blending === NoBlending) { + if (currentBlendingEnabled === true) { + disable(gl.BLEND); + currentBlendingEnabled = false; + } + + return; + } + + if (currentBlendingEnabled === false) { + enable(gl.BLEND); + currentBlendingEnabled = true; + } + + if (blending !== CustomBlending) { + if (blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha) { + if (currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation) { + gl.blendEquation(gl.FUNC_ADD); + + currentBlendEquation = AddEquation; + currentBlendEquationAlpha = AddEquation; + } + + if (premultipliedAlpha) { + switch (blending) { + case NormalBlending: + gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + break; + + case AdditiveBlending: + gl.blendFunc(gl.ONE, gl.ONE); + break; + + case SubtractiveBlending: + gl.blendFuncSeparate(gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA); + break; + + case MultiplyBlending: + gl.blendFuncSeparate(gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA); + break; + + default: + console.error('THREE.WebGLState: Invalid blending: ', blending); + break; + } + } else { + switch (blending) { + case NormalBlending: + gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + break; + + case AdditiveBlending: + gl.blendFunc(gl.SRC_ALPHA, gl.ONE); + break; + + case SubtractiveBlending: + gl.blendFunc(gl.ZERO, gl.ONE_MINUS_SRC_COLOR); + break; + + case MultiplyBlending: + gl.blendFunc(gl.ZERO, gl.SRC_COLOR); + break; + + default: + console.error('THREE.WebGLState: Invalid blending: ', blending); + break; + } + } + + currentBlendSrc = null; + currentBlendDst = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + + currentBlending = blending; + currentPremultipledAlpha = premultipliedAlpha; + } + + return; + } + + // custom blending + + blendEquationAlpha = blendEquationAlpha || blendEquation; + blendSrcAlpha = blendSrcAlpha || blendSrc; + blendDstAlpha = blendDstAlpha || blendDst; + + if (blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha) { + gl.blendEquationSeparate(equationToGL[blendEquation], equationToGL[blendEquationAlpha]); + + currentBlendEquation = blendEquation; + currentBlendEquationAlpha = blendEquationAlpha; + } + + if (blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha) { + gl.blendFuncSeparate(factorToGL[blendSrc], factorToGL[blendDst], factorToGL[blendSrcAlpha], factorToGL[blendDstAlpha]); + + currentBlendSrc = blendSrc; + currentBlendDst = blendDst; + currentBlendSrcAlpha = blendSrcAlpha; + currentBlendDstAlpha = blendDstAlpha; + } + + currentBlending = blending; + currentPremultipledAlpha = null; + } + + function setMaterial(material, frontFaceCW) { + material.side === DoubleSide ? disable(gl.CULL_FACE) : enable(gl.CULL_FACE); + + let flipSided = material.side === BackSide; + if (frontFaceCW) flipSided = !flipSided; + + setFlipSided(flipSided); + + material.blending === NormalBlending && material.transparent === false + ? setBlending(NoBlending) + : setBlending( + material.blending, + material.blendEquation, + material.blendSrc, + material.blendDst, + material.blendEquationAlpha, + material.blendSrcAlpha, + material.blendDstAlpha, + material.premultipliedAlpha + ); + + depthBuffer.setFunc(material.depthFunc); + depthBuffer.setTest(material.depthTest); + depthBuffer.setMask(material.depthWrite); + colorBuffer.setMask(material.colorWrite); + + const stencilWrite = material.stencilWrite; + stencilBuffer.setTest(stencilWrite); + if (stencilWrite) { + stencilBuffer.setMask(material.stencilWriteMask); + stencilBuffer.setFunc(material.stencilFunc, material.stencilRef, material.stencilFuncMask); + stencilBuffer.setOp(material.stencilFail, material.stencilZFail, material.stencilZPass); + } + + setPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits); + + material.alphaToCoverage === true ? enable(gl.SAMPLE_ALPHA_TO_COVERAGE) : disable(gl.SAMPLE_ALPHA_TO_COVERAGE); + } + + // + + function setFlipSided(flipSided) { + if (currentFlipSided !== flipSided) { + if (flipSided) { + gl.frontFace(gl.CW); + } else { + gl.frontFace(gl.CCW); + } + + currentFlipSided = flipSided; + } + } + + function setCullFace(cullFace) { + if (cullFace !== CullFaceNone) { + enable(gl.CULL_FACE); + + if (cullFace !== currentCullFace) { + if (cullFace === CullFaceBack) { + gl.cullFace(gl.BACK); + } else if (cullFace === CullFaceFront) { + gl.cullFace(gl.FRONT); + } else { + gl.cullFace(gl.FRONT_AND_BACK); + } + } + } else { + disable(gl.CULL_FACE); + } + + currentCullFace = cullFace; + } + + function setLineWidth(width) { + if (width !== currentLineWidth) { + if (lineWidthAvailable) gl.lineWidth(width); + + currentLineWidth = width; + } + } + + function setPolygonOffset(polygonOffset, factor, units) { + if (polygonOffset) { + enable(gl.POLYGON_OFFSET_FILL); + + if (currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units) { + gl.polygonOffset(factor, units); + + currentPolygonOffsetFactor = factor; + currentPolygonOffsetUnits = units; + } + } else { + disable(gl.POLYGON_OFFSET_FILL); + } + } + + function setScissorTest(scissorTest) { + if (scissorTest) { + enable(gl.SCISSOR_TEST); + } else { + disable(gl.SCISSOR_TEST); + } + } + + // texture + + function activeTexture(webglSlot) { + if (webglSlot === undefined) webglSlot = gl.TEXTURE0 + maxTextures - 1; + + if (currentTextureSlot !== webglSlot) { + gl.activeTexture(webglSlot); + currentTextureSlot = webglSlot; + } + } + + function bindTexture(webglType, webglTexture) { + if (currentTextureSlot === null) { + activeTexture(); + } + + let boundTexture = currentBoundTextures[currentTextureSlot]; + + if (boundTexture === undefined) { + boundTexture = { type: undefined, texture: undefined }; + currentBoundTextures[currentTextureSlot] = boundTexture; + } + + if (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) { + gl.bindTexture(webglType, webglTexture || emptyTextures[webglType]); + + boundTexture.type = webglType; + boundTexture.texture = webglTexture; + } + } + + function unbindTexture() { + const boundTexture = currentBoundTextures[currentTextureSlot]; + + if (boundTexture !== undefined && boundTexture.type !== undefined) { + gl.bindTexture(boundTexture.type, null); + + boundTexture.type = undefined; + boundTexture.texture = undefined; + } + } + + function compressedTexImage2D() { + try { + gl.compressedTexImage2D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texSubImage2D() { + try { + gl.texSubImage2D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texSubImage3D() { + try { + gl.texSubImage3D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function compressedTexSubImage2D() { + try { + gl.compressedTexSubImage2D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texStorage2D() { + try { + gl.texStorage2D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texStorage3D() { + try { + gl.texStorage3D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texImage2D() { + try { + gl.texImage2D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + function texImage3D() { + try { + gl.texImage3D.apply(gl, arguments); + } catch (error) { + console.error('THREE.WebGLState:', error); + } + } + + // + + function scissor(scissor) { + if (currentScissor.equals(scissor) === false) { + gl.scissor(scissor.x, scissor.y, scissor.z, scissor.w); + currentScissor.copy(scissor); + } + } + + function viewport(viewport) { + if (currentViewport.equals(viewport) === false) { + gl.viewport(viewport.x, viewport.y, viewport.z, viewport.w); + currentViewport.copy(viewport); + } + } + + // + + function reset() { + // reset state + + gl.disable(gl.BLEND); + gl.disable(gl.CULL_FACE); + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.POLYGON_OFFSET_FILL); + gl.disable(gl.SCISSOR_TEST); + gl.disable(gl.STENCIL_TEST); + gl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE); + + gl.blendEquation(gl.FUNC_ADD); + gl.blendFunc(gl.ONE, gl.ZERO); + gl.blendFuncSeparate(gl.ONE, gl.ZERO, gl.ONE, gl.ZERO); + + gl.colorMask(true, true, true, true); + gl.clearColor(0, 0, 0, 0); + + gl.depthMask(true); + gl.depthFunc(gl.LESS); + gl.clearDepth(1); + + gl.stencilMask(0xffffffff); + gl.stencilFunc(gl.ALWAYS, 0, 0xffffffff); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + gl.clearStencil(0); + + gl.cullFace(gl.BACK); + gl.frontFace(gl.CCW); + + gl.polygonOffset(0, 0); + + gl.activeTexture(gl.TEXTURE0); + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + + if (isWebGL2 === true) { + gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null); + gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null); + } + + gl.useProgram(null); + + gl.lineWidth(1); + + gl.scissor(0, 0, gl.canvas.width, gl.canvas.height); + gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); + + // reset internals + + enabledCapabilities = {}; + + currentTextureSlot = null; + currentBoundTextures = {}; + + currentBoundFramebuffers = {}; + currentDrawbuffers = new WeakMap(); + defaultDrawbuffers = []; + + currentProgram = null; + + currentBlendingEnabled = false; + currentBlending = null; + currentBlendEquation = null; + currentBlendSrc = null; + currentBlendDst = null; + currentBlendEquationAlpha = null; + currentBlendSrcAlpha = null; + currentBlendDstAlpha = null; + currentPremultipledAlpha = false; + + currentFlipSided = null; + currentCullFace = null; + + currentLineWidth = null; + + currentPolygonOffsetFactor = null; + currentPolygonOffsetUnits = null; + + currentScissor.set(0, 0, gl.canvas.width, gl.canvas.height); + currentViewport.set(0, 0, gl.canvas.width, gl.canvas.height); + + colorBuffer.reset(); + depthBuffer.reset(); + stencilBuffer.reset(); + } + + return { + buffers: { + color: colorBuffer, + depth: depthBuffer, + stencil: stencilBuffer, + }, + + enable: enable, + disable: disable, + + bindFramebuffer: bindFramebuffer, + drawBuffers: drawBuffers, + + useProgram: useProgram, + + setBlending: setBlending, + setMaterial: setMaterial, + + setFlipSided: setFlipSided, + setCullFace: setCullFace, + + setLineWidth: setLineWidth, + setPolygonOffset: setPolygonOffset, + + setScissorTest: setScissorTest, + + activeTexture: activeTexture, + bindTexture: bindTexture, + unbindTexture: unbindTexture, + compressedTexImage2D: compressedTexImage2D, + texImage2D: texImage2D, + texImage3D: texImage3D, + + texStorage2D: texStorage2D, + texStorage3D: texStorage3D, + texSubImage2D: texSubImage2D, + texSubImage3D: texSubImage3D, + compressedTexSubImage2D: compressedTexSubImage2D, + + scissor: scissor, + viewport: viewport, + + reset: reset, + }; +} + +export { WebGLState }; diff --git a/backend/libs/three/renderers/webgl/WebGLTextures.d.ts b/backend/libs/three/renderers/webgl/WebGLTextures.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3a15a3f4a9740273bc500372701cc3cf89dc67e2 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLTextures.d.ts @@ -0,0 +1,30 @@ +import { WebGLExtensions } from './WebGLExtensions'; +import { WebGLState } from './WebGLState'; +import { WebGLProperties } from './WebGLProperties'; +import { WebGLCapabilities } from './WebGLCapabilities'; +import { WebGLUtils } from './WebGLUtils'; +import { WebGLInfo } from './WebGLInfo'; + +export class WebGLTextures { + constructor( + gl: WebGLRenderingContext, + extensions: WebGLExtensions, + state: WebGLState, + properties: WebGLProperties, + capabilities: WebGLCapabilities, + utils: WebGLUtils, + info: WebGLInfo + ); + + allocateTextureUnit(): void; + resetTextureUnits(): void; + setTexture2D(texture: any, slot: number): void; + setTexture2DArray(texture: any, slot: number): void; + setTexture3D(texture: any, slot: number): void; + setTextureCube(texture: any, slot: number): void; + setupRenderTarget(renderTarget: any): void; + updateRenderTargetMipmap(renderTarget: any): void; + updateMultisampleRenderTarget(renderTarget: any): void; + safeSetTexture2D(texture: any, slot: number): void; + safeSetTextureCube(texture: any, slot: number): void; +} diff --git a/backend/libs/three/renderers/webgl/WebGLTextures.js b/backend/libs/three/renderers/webgl/WebGLTextures.js new file mode 100644 index 0000000000000000000000000000000000000000..05c71304b7f5856ea523cb2582e8fb037bb1604e --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLTextures.js @@ -0,0 +1,1378 @@ +import { + LinearFilter, + LinearMipmapLinearFilter, + LinearMipmapNearestFilter, + NearestFilter, + NearestMipmapLinearFilter, + NearestMipmapNearestFilter, + RGBAFormat, + DepthFormat, + DepthStencilFormat, + UnsignedShortType, + UnsignedIntType, + UnsignedInt248Type, + FloatType, + HalfFloatType, + MirroredRepeatWrapping, + ClampToEdgeWrapping, + RepeatWrapping, + sRGBEncoding, + LinearEncoding, + UnsignedByteType, + _SRGBAFormat, +} from '../../constants.js'; +import * as MathUtils from '../../math/MathUtils.js'; +import { ImageUtils } from '../../extras/ImageUtils.js'; +import { createElementNS } from '../../utils.js'; +import { Image } from 'skia-canvas'; + +function WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info) { + const isWebGL2 = capabilities.isWebGL2; + const maxTextures = capabilities.maxTextures; + const maxCubemapSize = capabilities.maxCubemapSize; + const maxTextureSize = capabilities.maxTextureSize; + const maxSamples = capabilities.maxSamples; + const hasMultisampledRenderToTexture = extensions.has('WEBGL_multisampled_render_to_texture'); + const MultisampledRenderToTextureExtension = hasMultisampledRenderToTexture ? extensions.get('WEBGL_multisampled_render_to_texture') : undefined; + + const _videoTextures = new WeakMap(); + let _canvas; + + // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas, + // also OffscreenCanvas.getContext("webgl"), but not OffscreenCanvas.getContext("2d")! + // Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d). + + let useOffscreenCanvas = false; + + try { + useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' && new OffscreenCanvas(1, 1).getContext('2d') !== null; + } catch (err) { + // Ignore any errors + } + + function createCanvas(width, height) { + // Use OffscreenCanvas when available. Specially needed in web workers + + return useOffscreenCanvas ? new OffscreenCanvas(width, height) : createElementNS('canvas'); + } + + function resizeImage(image, needsPowerOfTwo, needsNewCanvas, maxSize) { + let scale = 1; + + // handle case if texture exceeds max size + + if (image.width > maxSize || image.height > maxSize) { + scale = maxSize / Math.max(image.width, image.height); + } + + // only perform resize if necessary + + if (scale < 1 || needsPowerOfTwo === true) { + // only perform resize for certain image types + + if ( + (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) || + (typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement) || + (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) || + (typeof Image !== 'undefined' && image instanceof Image) + ) { + const floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor; + + const width = floor(scale * image.width); + const height = floor(scale * image.height); + + if (_canvas === undefined) _canvas = createCanvas(width, height); + + // cube textures can't reuse the same canvas + + const canvas = needsNewCanvas ? createCanvas(width, height) : _canvas; + + canvas.width = width; + canvas.height = height; + + const context = canvas.getContext('2d'); + context.drawImage(image, 0, 0, width, height); + + console.warn( + 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' + ); + + return canvas; + } else { + if ('data' in image) { + console.warn('THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').'); + } + + return image; + } + } + + return image; + } + + function isPowerOfTwo(image) { + return MathUtils.isPowerOfTwo(image.width) && MathUtils.isPowerOfTwo(image.height); + } + + function textureNeedsPowerOfTwo(texture) { + if (isWebGL2) return false; + + return ( + texture.wrapS !== ClampToEdgeWrapping || + texture.wrapT !== ClampToEdgeWrapping || + (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) + ); + } + + function textureNeedsGenerateMipmaps(texture, supportsMips) { + return texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter; + } + + function generateMipmap(target) { + _gl.generateMipmap(target); + } + + function getInternalFormat(internalFormatName, glFormat, glType, encoding, isVideoTexture = false) { + if (isWebGL2 === false) return glFormat; + + if (internalFormatName !== null) { + if (_gl[internalFormatName] !== undefined) return _gl[internalFormatName]; + + console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'"); + } + + let internalFormat = glFormat; + + if (glFormat === _gl.RED) { + if (glType === _gl.FLOAT) internalFormat = _gl.R32F; + if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F; + if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8; + } + + if (glFormat === _gl.RGB) { + if (glType === _gl.FLOAT) internalFormat = _gl.RGB32F; + if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGB16F; + if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RGB8; + } + + if (glFormat === _gl.RGBA) { + if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F; + if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F; + if (glType === _gl.UNSIGNED_BYTE) internalFormat = encoding === sRGBEncoding && isVideoTexture === false ? _gl.SRGB8_ALPHA8 : _gl.RGBA8; + } + + if (internalFormat === _gl.R16F || internalFormat === _gl.R32F || internalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F) { + extensions.get('EXT_color_buffer_float'); + } + + return internalFormat; + } + + function getMipLevels(texture, image, supportsMips) { + if ( + textureNeedsGenerateMipmaps(texture, supportsMips) === true || + (texture.isFramebufferTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) + ) { + return Math.log2(Math.max(image.width, image.height)) + 1; + } else if (texture.mipmaps !== undefined && texture.mipmaps.length > 0) { + // user-defined mipmaps + + return texture.mipmaps.length; + } else if (texture.isCompressedTexture && Array.isArray(texture.image)) { + return image.mipmaps.length; + } else { + // texture without mipmaps (only base level) + + return 1; + } + } + + // Fallback filters for non-power-of-2 textures + + function filterFallback(f) { + if (f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter) { + return _gl.NEAREST; + } + + return _gl.LINEAR; + } + + // + + function onTextureDispose(event) { + const texture = event.target; + + texture.removeEventListener('dispose', onTextureDispose); + + deallocateTexture(texture); + + if (texture.isVideoTexture) { + _videoTextures.delete(texture); + } + + info.memory.textures--; + } + + function onRenderTargetDispose(event) { + const renderTarget = event.target; + + renderTarget.removeEventListener('dispose', onRenderTargetDispose); + + deallocateRenderTarget(renderTarget); + } + + // + + function deallocateTexture(texture) { + const textureProperties = properties.get(texture); + + if (textureProperties.__webglInit === undefined) return; + + _gl.deleteTexture(textureProperties.__webglTexture); + + properties.remove(texture); + } + + function deallocateRenderTarget(renderTarget) { + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get(renderTarget); + const textureProperties = properties.get(texture); + + if (!renderTarget) return; + + if (textureProperties.__webglTexture !== undefined) { + _gl.deleteTexture(textureProperties.__webglTexture); + + info.memory.textures--; + } + + if (renderTarget.depthTexture) { + renderTarget.depthTexture.dispose(); + } + + if (renderTarget.isWebGLCubeRenderTarget) { + for (let i = 0; i < 6; i++) { + _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer[i]); + if (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer[i]); + } + } else { + _gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer); + if (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer); + if (renderTargetProperties.__webglMultisampledFramebuffer) _gl.deleteFramebuffer(renderTargetProperties.__webglMultisampledFramebuffer); + if (renderTargetProperties.__webglColorRenderbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglColorRenderbuffer); + if (renderTargetProperties.__webglDepthRenderbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthRenderbuffer); + } + + if (renderTarget.isWebGLMultipleRenderTargets) { + for (let i = 0, il = texture.length; i < il; i++) { + const attachmentProperties = properties.get(texture[i]); + + if (attachmentProperties.__webglTexture) { + _gl.deleteTexture(attachmentProperties.__webglTexture); + + info.memory.textures--; + } + + properties.remove(texture[i]); + } + } + + properties.remove(texture); + properties.remove(renderTarget); + } + + // + + let textureUnits = 0; + + function resetTextureUnits() { + textureUnits = 0; + } + + function allocateTextureUnit() { + const textureUnit = textureUnits; + + if (textureUnit >= maxTextures) { + console.warn('THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures); + } + + textureUnits += 1; + + return textureUnit; + } + + // + + function setTexture2D(texture, slot) { + const textureProperties = properties.get(texture); + + if (texture.isVideoTexture) updateVideoTexture(texture); + + if (texture.version > 0 && textureProperties.__version !== texture.version) { + const image = texture.image; + + if (image === undefined) { + console.warn('THREE.WebGLRenderer: Texture marked for update but image is undefined'); + } else if (image.complete === false) { + console.warn('THREE.WebGLRenderer: Texture marked for update but image is incomplete'); + } else { + uploadTexture(textureProperties, texture, slot); + return; + } + } + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(_gl.TEXTURE_2D, textureProperties.__webglTexture); + } + + function setTexture2DArray(texture, slot) { + const textureProperties = properties.get(texture); + + if (texture.version > 0 && textureProperties.__version !== texture.version) { + uploadTexture(textureProperties, texture, slot); + return; + } + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(_gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture); + } + + function setTexture3D(texture, slot) { + const textureProperties = properties.get(texture); + + if (texture.version > 0 && textureProperties.__version !== texture.version) { + uploadTexture(textureProperties, texture, slot); + return; + } + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(_gl.TEXTURE_3D, textureProperties.__webglTexture); + } + + function setTextureCube(texture, slot) { + const textureProperties = properties.get(texture); + + if (texture.version > 0 && textureProperties.__version !== texture.version) { + uploadCubeTexture(textureProperties, texture, slot); + return; + } + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture); + } + + const wrappingToGL = { + [RepeatWrapping]: _gl.REPEAT, + [ClampToEdgeWrapping]: _gl.CLAMP_TO_EDGE, + [MirroredRepeatWrapping]: _gl.MIRRORED_REPEAT, + }; + + const filterToGL = { + [NearestFilter]: _gl.NEAREST, + [NearestMipmapNearestFilter]: _gl.NEAREST_MIPMAP_NEAREST, + [NearestMipmapLinearFilter]: _gl.NEAREST_MIPMAP_LINEAR, + + [LinearFilter]: _gl.LINEAR, + [LinearMipmapNearestFilter]: _gl.LINEAR_MIPMAP_NEAREST, + [LinearMipmapLinearFilter]: _gl.LINEAR_MIPMAP_LINEAR, + }; + + function setTextureParameters(textureType, texture, supportsMips) { + if (supportsMips) { + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[texture.wrapS]); + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[texture.wrapT]); + + if (textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY) { + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[texture.wrapR]); + } + + _gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[texture.magFilter]); + _gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[texture.minFilter]); + } else { + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE); + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE); + + if (textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY) { + _gl.texParameteri(textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE); + } + + if (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping) { + console.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.'); + } + + _gl.texParameteri(textureType, _gl.TEXTURE_MAG_FILTER, filterFallback(texture.magFilter)); + _gl.texParameteri(textureType, _gl.TEXTURE_MIN_FILTER, filterFallback(texture.minFilter)); + + if (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) { + console.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.'); + } + } + + if (extensions.has('EXT_texture_filter_anisotropic') === true) { + const extension = extensions.get('EXT_texture_filter_anisotropic'); + + if (texture.type === FloatType && extensions.has('OES_texture_float_linear') === false) return; // verify extension for WebGL 1 and WebGL 2 + if (isWebGL2 === false && texture.type === HalfFloatType && extensions.has('OES_texture_half_float_linear') === false) return; // verify extension for WebGL 1 only + + if (texture.anisotropy > 1 || properties.get(texture).__currentAnisotropy) { + _gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, capabilities.getMaxAnisotropy())); + properties.get(texture).__currentAnisotropy = texture.anisotropy; + } + } + } + + function initTexture(textureProperties, texture) { + if (textureProperties.__webglInit === undefined) { + textureProperties.__webglInit = true; + + texture.addEventListener('dispose', onTextureDispose); + + textureProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures++; + } + } + + function uploadTexture(textureProperties, texture, slot) { + let textureType = _gl.TEXTURE_2D; + + if (texture.isDataTexture2DArray) textureType = _gl.TEXTURE_2D_ARRAY; + if (texture.isDataTexture3D) textureType = _gl.TEXTURE_3D; + + initTexture(textureProperties, texture); + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(textureType, textureProperties.__webglTexture); + + _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY); + _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha); + _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment); + _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE); + + const needsPowerOfTwo = textureNeedsPowerOfTwo(texture) && isPowerOfTwo(texture.image) === false; + let image = resizeImage(texture.image, needsPowerOfTwo, false, maxTextureSize); + image = verifyColorSpace(texture, image); + + const supportsMips = isPowerOfTwo(image) || isWebGL2, + glFormat = utils.convert(texture.format, texture.encoding); + + let glType = utils.convert(texture.type), + glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding, texture.isVideoTexture); + + setTextureParameters(textureType, texture, supportsMips); + + let mipmap; + const mipmaps = texture.mipmaps; + + const useTexStorage = isWebGL2 && texture.isVideoTexture !== true; + const allocateMemory = textureProperties.__version === undefined; + const levels = getMipLevels(texture, image, supportsMips); + + if (texture.isDepthTexture) { + // populate depth texture with dummy data + + glInternalFormat = _gl.DEPTH_COMPONENT; + + if (isWebGL2) { + if (texture.type === FloatType) { + glInternalFormat = _gl.DEPTH_COMPONENT32F; + } else if (texture.type === UnsignedIntType) { + glInternalFormat = _gl.DEPTH_COMPONENT24; + } else if (texture.type === UnsignedInt248Type) { + glInternalFormat = _gl.DEPTH24_STENCIL8; + } else { + glInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D + } + } else { + if (texture.type === FloatType) { + console.error('WebGLRenderer: Floating point depth texture requires WebGL2.'); + } + } + + // validation checks for WebGL 1 + + if (texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT) { + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if (texture.type !== UnsignedShortType && texture.type !== UnsignedIntType) { + console.warn('THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.'); + + texture.type = UnsignedShortType; + glType = utils.convert(texture.type); + } + } + + if (texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT) { + // Depth stencil textures need the DEPTH_STENCIL internal format + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + glInternalFormat = _gl.DEPTH_STENCIL; + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL. + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if (texture.type !== UnsignedInt248Type) { + console.warn('THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.'); + + texture.type = UnsignedInt248Type; + glType = utils.convert(texture.type); + } + } + + // + + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height); + } else { + state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null); + } + } else if (texture.isDataTexture) { + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if (mipmaps.length > 0 && supportsMips) { + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height); + } + + for (let i = 0, il = mipmaps.length; i < il; i++) { + mipmap = mipmaps[i]; + + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data); + } else { + state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data); + } + } + + texture.generateMipmaps = false; + } else { + if (useTexStorage) { + if (allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height); + } + + state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data); + } else { + state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data); + } + } + } else if (texture.isCompressedTexture) { + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height); + } + + for (let i = 0, il = mipmaps.length; i < il; i++) { + mipmap = mipmaps[i]; + + if (texture.format !== RGBAFormat) { + if (glFormat !== null) { + if (useTexStorage) { + state.compressedTexSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data); + } else { + state.compressedTexImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data); + } + } else { + console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()'); + } + } else { + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data); + } else { + state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data); + } + } + } + } else if (texture.isDataTexture2DArray) { + if (useTexStorage) { + if (allocateMemory) { + state.texStorage3D(_gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth); + } + + state.texSubImage3D(_gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data); + } else { + state.texImage3D(_gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data); + } + } else if (texture.isDataTexture3D) { + if (useTexStorage) { + if (allocateMemory) { + state.texStorage3D(_gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth); + } + + state.texSubImage3D(_gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data); + } else { + state.texImage3D(_gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data); + } + } else if (texture.isFramebufferTexture) { + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height); + } else { + state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null); + } + } else { + // regular Texture (image, video, canvas) + + // use manually created mipmaps if available + // if there are no manual mipmaps + // set 0 level mipmap and then use GL to generate other mipmap levels + + if (mipmaps.length > 0 && supportsMips) { + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[0].width, mipmaps[0].height); + } + + for (let i = 0, il = mipmaps.length; i < il; i++) { + mipmap = mipmaps[i]; + + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_2D, i, 0, 0, glFormat, glType, mipmap); + } else { + state.texImage2D(_gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap); + } + } + + texture.generateMipmaps = false; + } else { + if (useTexStorage) { + if (allocateMemory) { + state.texStorage2D(_gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height); + } + + state.texSubImage2D(_gl.TEXTURE_2D, 0, 0, 0, glFormat, glType, image); + } else { + state.texImage2D(_gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image); + } + } + } + + if (textureNeedsGenerateMipmaps(texture, supportsMips)) { + generateMipmap(textureType); + } + + textureProperties.__version = texture.version; + + if (texture.onUpdate) texture.onUpdate(texture); + } + + function uploadCubeTexture(textureProperties, texture, slot) { + if (texture.image.length !== 6) return; + + initTexture(textureProperties, texture); + + state.activeTexture(_gl.TEXTURE0 + slot); + state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture); + + _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY); + _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha); + _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment); + _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, _gl.NONE); + + const isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture); + const isDataTexture = texture.image[0] && texture.image[0].isDataTexture; + + const cubeImage = []; + + for (let i = 0; i < 6; i++) { + if (!isCompressed && !isDataTexture) { + cubeImage[i] = resizeImage(texture.image[i], false, true, maxCubemapSize); + } else { + cubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i]; + } + + cubeImage[i] = verifyColorSpace(texture, cubeImage[i]); + } + + const image = cubeImage[0], + supportsMips = isPowerOfTwo(image) || isWebGL2, + glFormat = utils.convert(texture.format, texture.encoding), + glType = utils.convert(texture.type), + glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding); + + const useTexStorage = isWebGL2 && texture.isVideoTexture !== true; + const allocateMemory = textureProperties.__version === undefined; + let levels = getMipLevels(texture, image, supportsMips); + + setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips); + + let mipmaps; + + if (isCompressed) { + if (useTexStorage && allocateMemory) { + state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, image.width, image.height); + } + + for (let i = 0; i < 6; i++) { + mipmaps = cubeImage[i].mipmaps; + + for (let j = 0; j < mipmaps.length; j++) { + const mipmap = mipmaps[j]; + + if (texture.format !== RGBAFormat) { + if (glFormat !== null) { + if (useTexStorage) { + state.compressedTexSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data); + } else { + state.compressedTexImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + j, + glInternalFormat, + mipmap.width, + mipmap.height, + 0, + mipmap.data + ); + } + } else { + console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()'); + } + } else { + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data); + } else { + state.texImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + j, + glInternalFormat, + mipmap.width, + mipmap.height, + 0, + glFormat, + glType, + mipmap.data + ); + } + } + } + } + } else { + mipmaps = texture.mipmaps; + + if (useTexStorage && allocateMemory) { + // TODO: Uniformly handle mipmap definitions + // Normal textures and compressed cube textures define base level + mips with their mipmap array + // Uncompressed cube textures use their mipmap array only for mips (no base level) + + if (mipmaps.length > 0) levels++; + + state.texStorage2D(_gl.TEXTURE_CUBE_MAP, levels, glInternalFormat, cubeImage[0].width, cubeImage[0].height); + } + + for (let i = 0; i < 6; i++) { + if (isDataTexture) { + if (useTexStorage) { + state.texSubImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + 0, + 0, + 0, + cubeImage[i].width, + cubeImage[i].height, + glFormat, + glType, + cubeImage[i].data + ); + } else { + state.texImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + 0, + glInternalFormat, + cubeImage[i].width, + cubeImage[i].height, + 0, + glFormat, + glType, + cubeImage[i].data + ); + } + + for (let j = 0; j < mipmaps.length; j++) { + const mipmap = mipmaps[j]; + const mipmapImage = mipmap.image[i].image; + + if (useTexStorage) { + state.texSubImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + j + 1, + 0, + 0, + mipmapImage.width, + mipmapImage.height, + glFormat, + glType, + mipmapImage.data + ); + } else { + state.texImage2D( + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, + j + 1, + glInternalFormat, + mipmapImage.width, + mipmapImage.height, + 0, + glFormat, + glType, + mipmapImage.data + ); + } + } + } else { + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, glFormat, glType, cubeImage[i]); + } else { + state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[i]); + } + + for (let j = 0; j < mipmaps.length; j++) { + const mipmap = mipmaps[j]; + + if (useTexStorage) { + state.texSubImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, 0, 0, glFormat, glType, mipmap.image[i]); + } else { + state.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[i]); + } + } + } + } + } + + if (textureNeedsGenerateMipmaps(texture, supportsMips)) { + // We assume images for cube map have the same size. + generateMipmap(_gl.TEXTURE_CUBE_MAP); + } + + textureProperties.__version = texture.version; + + if (texture.onUpdate) texture.onUpdate(texture); + } + + // Render targets + + // Setup storage for target texture and bind it to correct framebuffer + function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget) { + const glFormat = utils.convert(texture.format, texture.encoding); + const glType = utils.convert(texture.type); + const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding); + const renderTargetProperties = properties.get(renderTarget); + + if (!renderTargetProperties.__hasExternalTextures) { + if (textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY) { + state.texImage3D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, renderTarget.depth, 0, glFormat, glType, null); + } else { + state.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null); + } + } + + state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer); + if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( + _gl.FRAMEBUFFER, + attachment, + textureTarget, + properties.get(texture).__webglTexture, + 0, + getRenderTargetSamples(renderTarget) + ); + } else { + _gl.framebufferTexture2D(_gl.FRAMEBUFFER, attachment, textureTarget, properties.get(texture).__webglTexture, 0); + } + + state.bindFramebuffer(_gl.FRAMEBUFFER, null); + } + + // Setup storage for internal depth/stencil buffers and bind to correct framebuffer + function setupRenderBufferStorage(renderbuffer, renderTarget, isMultisample) { + _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderbuffer); + + if (renderTarget.depthBuffer && !renderTarget.stencilBuffer) { + let glInternalFormat = _gl.DEPTH_COMPONENT16; + + if (isMultisample || renderTarget.useRenderToTexture) { + const depthTexture = renderTarget.depthTexture; + + if (depthTexture && depthTexture.isDepthTexture) { + if (depthTexture.type === FloatType) { + glInternalFormat = _gl.DEPTH_COMPONENT32F; + } else if (depthTexture.type === UnsignedIntType) { + glInternalFormat = _gl.DEPTH_COMPONENT24; + } + } + + const samples = getRenderTargetSamples(renderTarget); + + if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( + _gl.RENDERBUFFER, + samples, + glInternalFormat, + renderTarget.width, + renderTarget.height + ); + } else { + _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height); + } + } else { + _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height); + } + + _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer); + } else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) { + const samples = getRenderTargetSamples(renderTarget); + + if (isMultisample && renderTarget.useRenderbuffer) { + _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height); + } else if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( + _gl.RENDERBUFFER, + samples, + _gl.DEPTH24_STENCIL8, + renderTarget.width, + renderTarget.height + ); + } else { + _gl.renderbufferStorage(_gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height); + } + + _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer); + } else { + // Use the first texture for MRT so far + const texture = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture[0] : renderTarget.texture; + + const glFormat = utils.convert(texture.format, texture.encoding); + const glType = utils.convert(texture.type); + const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding); + const samples = getRenderTargetSamples(renderTarget); + + if (isMultisample && renderTarget.useRenderbuffer) { + _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height); + } else if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.renderbufferStorageMultisampleEXT( + _gl.RENDERBUFFER, + samples, + glInternalFormat, + renderTarget.width, + renderTarget.height + ); + } else { + _gl.renderbufferStorage(_gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height); + } + } + + _gl.bindRenderbuffer(_gl.RENDERBUFFER, null); + } + + // Setup resources for a Depth Texture for a FBO (needs an extension) + function setupDepthTexture(framebuffer, renderTarget) { + const isCube = renderTarget && renderTarget.isWebGLCubeRenderTarget; + if (isCube) throw new Error('Depth Texture with cube render targets is not supported'); + + state.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer); + + if (!(renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture)) { + throw new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture'); + } + + // upload an empty depth texture with framebuffer size + if ( + !properties.get(renderTarget.depthTexture).__webglTexture || + renderTarget.depthTexture.image.width !== renderTarget.width || + renderTarget.depthTexture.image.height !== renderTarget.height + ) { + renderTarget.depthTexture.image.width = renderTarget.width; + renderTarget.depthTexture.image.height = renderTarget.height; + renderTarget.depthTexture.needsUpdate = true; + } + + setTexture2D(renderTarget.depthTexture, 0); + + const webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture; + const samples = getRenderTargetSamples(renderTarget); + + if (renderTarget.depthTexture.format === DepthFormat) { + if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( + _gl.FRAMEBUFFER, + _gl.DEPTH_ATTACHMENT, + _gl.TEXTURE_2D, + webglDepthTexture, + 0, + samples + ); + } else { + _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0); + } + } else if (renderTarget.depthTexture.format === DepthStencilFormat) { + if (renderTarget.useRenderToTexture) { + MultisampledRenderToTextureExtension.framebufferTexture2DMultisampleEXT( + _gl.FRAMEBUFFER, + _gl.DEPTH_STENCIL_ATTACHMENT, + _gl.TEXTURE_2D, + webglDepthTexture, + 0, + samples + ); + } else { + _gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0); + } + } else { + throw new Error('Unknown depthTexture format'); + } + } + + // Setup GL resources for a non-texture depth buffer + function setupDepthRenderbuffer(renderTarget) { + const renderTargetProperties = properties.get(renderTarget); + const isCube = renderTarget.isWebGLCubeRenderTarget === true; + + if (renderTarget.depthTexture && !renderTargetProperties.__autoAllocateDepthBuffer) { + if (isCube) throw new Error('target.depthTexture not supported in Cube render targets'); + + setupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget); + } else { + if (isCube) { + renderTargetProperties.__webglDepthbuffer = []; + + for (let i = 0; i < 6; i++) { + state.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[i]); + renderTargetProperties.__webglDepthbuffer[i] = _gl.createRenderbuffer(); + setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer[i], renderTarget, false); + } + } else { + state.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer); + renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer, renderTarget, false); + } + } + + state.bindFramebuffer(_gl.FRAMEBUFFER, null); + } + + // rebind framebuffer with external textures + function rebindTextures(renderTarget, colorTexture, depthTexture) { + const renderTargetProperties = properties.get(renderTarget); + + if (colorTexture !== undefined) { + setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, renderTarget.texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D); + } + + if (depthTexture !== undefined) { + setupDepthRenderbuffer(renderTarget); + } + } + + // Set up GL resources for the render target + function setupRenderTarget(renderTarget) { + const texture = renderTarget.texture; + + const renderTargetProperties = properties.get(renderTarget); + const textureProperties = properties.get(texture); + + renderTarget.addEventListener('dispose', onRenderTargetDispose); + + if (renderTarget.isWebGLMultipleRenderTargets !== true) { + if (textureProperties.__webglTexture === undefined) { + textureProperties.__webglTexture = _gl.createTexture(); + } + + textureProperties.__version = texture.version; + info.memory.textures++; + } + + const isCube = renderTarget.isWebGLCubeRenderTarget === true; + const isMultipleRenderTargets = renderTarget.isWebGLMultipleRenderTargets === true; + const isRenderTarget3D = texture.isDataTexture3D || texture.isDataTexture2DArray; + const supportsMips = isPowerOfTwo(renderTarget) || isWebGL2; + + // Setup framebuffer + + if (isCube) { + renderTargetProperties.__webglFramebuffer = []; + + for (let i = 0; i < 6; i++) { + renderTargetProperties.__webglFramebuffer[i] = _gl.createFramebuffer(); + } + } else { + renderTargetProperties.__webglFramebuffer = _gl.createFramebuffer(); + + if (isMultipleRenderTargets) { + if (capabilities.drawBuffers) { + const textures = renderTarget.texture; + + for (let i = 0, il = textures.length; i < il; i++) { + const attachmentProperties = properties.get(textures[i]); + + if (attachmentProperties.__webglTexture === undefined) { + attachmentProperties.__webglTexture = _gl.createTexture(); + + info.memory.textures++; + } + } + } else { + console.warn('THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.'); + } + } else if (renderTarget.useRenderbuffer) { + if (isWebGL2) { + renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer(); + renderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer(); + + _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer); + + const glFormat = utils.convert(texture.format, texture.encoding); + const glType = utils.convert(texture.type); + const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.encoding); + const samples = getRenderTargetSamples(renderTarget); + _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height); + + state.bindFramebuffer(_gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer); + _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer); + _gl.bindRenderbuffer(_gl.RENDERBUFFER, null); + + if (renderTarget.depthBuffer) { + renderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer(); + setupRenderBufferStorage(renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true); + } + + state.bindFramebuffer(_gl.FRAMEBUFFER, null); + } else { + console.warn('THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.'); + } + } + } + + // Setup color buffer + + if (isCube) { + state.bindTexture(_gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture); + setTextureParameters(_gl.TEXTURE_CUBE_MAP, texture, supportsMips); + + for (let i = 0; i < 6; i++) { + setupFrameBufferTexture( + renderTargetProperties.__webglFramebuffer[i], + renderTarget, + texture, + _gl.COLOR_ATTACHMENT0, + _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i + ); + } + + if (textureNeedsGenerateMipmaps(texture, supportsMips)) { + generateMipmap(_gl.TEXTURE_CUBE_MAP); + } + + state.unbindTexture(); + } else if (isMultipleRenderTargets) { + const textures = renderTarget.texture; + + for (let i = 0, il = textures.length; i < il; i++) { + const attachment = textures[i]; + const attachmentProperties = properties.get(attachment); + + state.bindTexture(_gl.TEXTURE_2D, attachmentProperties.__webglTexture); + setTextureParameters(_gl.TEXTURE_2D, attachment, supportsMips); + setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, _gl.TEXTURE_2D); + + if (textureNeedsGenerateMipmaps(attachment, supportsMips)) { + generateMipmap(_gl.TEXTURE_2D); + } + } + + state.unbindTexture(); + } else { + let glTextureType = _gl.TEXTURE_2D; + + if (isRenderTarget3D) { + // Render targets containing layers, i.e: Texture 3D and 2d arrays + + if (isWebGL2) { + const isTexture3D = texture.isDataTexture3D; + glTextureType = isTexture3D ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY; + } else { + console.warn('THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.'); + } + } + + state.bindTexture(glTextureType, textureProperties.__webglTexture); + setTextureParameters(glTextureType, texture, supportsMips); + setupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, texture, _gl.COLOR_ATTACHMENT0, glTextureType); + + if (textureNeedsGenerateMipmaps(texture, supportsMips)) { + generateMipmap(glTextureType); + } + + state.unbindTexture(); + } + + // Setup depth and stencil buffers + + if (renderTarget.depthBuffer) { + setupDepthRenderbuffer(renderTarget); + } + } + + function updateRenderTargetMipmap(renderTarget) { + const supportsMips = isPowerOfTwo(renderTarget) || isWebGL2; + + const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [renderTarget.texture]; + + for (let i = 0, il = textures.length; i < il; i++) { + const texture = textures[i]; + + if (textureNeedsGenerateMipmaps(texture, supportsMips)) { + const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D; + const webglTexture = properties.get(texture).__webglTexture; + + state.bindTexture(target, webglTexture); + generateMipmap(target); + state.unbindTexture(); + } + } + } + + function updateMultisampleRenderTarget(renderTarget) { + if (renderTarget.useRenderbuffer) { + if (isWebGL2) { + const width = renderTarget.width; + const height = renderTarget.height; + let mask = _gl.COLOR_BUFFER_BIT; + const invalidationArray = [_gl.COLOR_ATTACHMENT0]; + const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT; + + if (renderTarget.depthBuffer) { + invalidationArray.push(depthStyle); + } + + if (!renderTarget.ignoreDepthForMultisampleCopy) { + if (renderTarget.depthBuffer) mask |= _gl.DEPTH_BUFFER_BIT; + if (renderTarget.stencilBuffer) mask |= _gl.STENCIL_BUFFER_BIT; + } + + const renderTargetProperties = properties.get(renderTarget); + + state.bindFramebuffer(_gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer); + state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer); + + if (renderTarget.ignoreDepthForMultisampleCopy) { + _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, [depthStyle]); + _gl.invalidateFramebuffer(_gl.DRAW_FRAMEBUFFER, [depthStyle]); + } + + _gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST); + _gl.invalidateFramebuffer(_gl.READ_FRAMEBUFFER, invalidationArray); + + state.bindFramebuffer(_gl.READ_FRAMEBUFFER, null); + state.bindFramebuffer(_gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer); + } else { + console.warn('THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.'); + } + } + } + + function getRenderTargetSamples(renderTarget) { + return isWebGL2 && (renderTarget.useRenderbuffer || renderTarget.useRenderToTexture) ? Math.min(maxSamples, renderTarget.samples) : 0; + } + + function updateVideoTexture(texture) { + const frame = info.render.frame; + + // Check the last frame we updated the VideoTexture + + if (_videoTextures.get(texture) !== frame) { + _videoTextures.set(texture, frame); + texture.update(); + } + } + + function verifyColorSpace(texture, image) { + const encoding = texture.encoding; + const format = texture.format; + const type = texture.type; + + if (texture.isCompressedTexture === true || texture.format === _SRGBAFormat) return image; + + if (encoding !== LinearEncoding) { + // sRGB + + if (encoding === sRGBEncoding && texture.isVideoTexture !== true) { + if (isWebGL2 === false) { + // in WebGL 1, try to use EXT_sRGB extension and unsized formats + + if (extensions.has('EXT_sRGB') === true && format === RGBAFormat) { + texture.format = _SRGBAFormat; + + // it's not possible to generate mips in WebGL 1 with this extension + + texture.minFilter = LinearFilter; + texture.generateMipmaps = false; + } else { + // slow fallback (CPU decode) + + image = ImageUtils.sRGBToLinear(image); + } + } else { + // in WebGL 2 uncompressed textures can only be sRGB encoded if they have the RGBA8 format + + if (format !== RGBAFormat || type !== UnsignedByteType) { + console.warn('THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.'); + } + } + } else { + console.error('THREE.WebGLTextures: Unsupported texture encoding:', encoding); + } + } + + return image; + } + + // backwards compatibility + + let warnedTexture2D = false; + let warnedTextureCube = false; + + function safeSetTexture2D(texture, slot) { + if (texture && texture.isWebGLRenderTarget) { + if (warnedTexture2D === false) { + console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."); + warnedTexture2D = true; + } + + texture = texture.texture; + } + + setTexture2D(texture, slot); + } + + function safeSetTextureCube(texture, slot) { + if (texture && texture.isWebGLCubeRenderTarget) { + if (warnedTextureCube === false) { + console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."); + warnedTextureCube = true; + } + + texture = texture.texture; + } + + setTextureCube(texture, slot); + } + + // + + this.allocateTextureUnit = allocateTextureUnit; + this.resetTextureUnits = resetTextureUnits; + + this.setTexture2D = setTexture2D; + this.setTexture2DArray = setTexture2DArray; + this.setTexture3D = setTexture3D; + this.setTextureCube = setTextureCube; + this.rebindTextures = rebindTextures; + this.setupRenderTarget = setupRenderTarget; + this.updateRenderTargetMipmap = updateRenderTargetMipmap; + this.updateMultisampleRenderTarget = updateMultisampleRenderTarget; + this.setupDepthRenderbuffer = setupDepthRenderbuffer; + this.setupFrameBufferTexture = setupFrameBufferTexture; + + this.safeSetTexture2D = safeSetTexture2D; + this.safeSetTextureCube = safeSetTextureCube; +} + +export { WebGLTextures }; diff --git a/backend/libs/three/renderers/webgl/WebGLUniforms.d.ts b/backend/libs/three/renderers/webgl/WebGLUniforms.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e0ca8b8d237f643034b1d7f2f2b2ddc630aa1d85 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLUniforms.d.ts @@ -0,0 +1,12 @@ +import { WebGLProgram } from './WebGLProgram'; +import { WebGLTextures } from './WebGLTextures'; + +export class WebGLUniforms { + constructor(gl: WebGLRenderingContext, program: WebGLProgram); + + setValue(gl: WebGLRenderingContext, name: string, value: any, textures: WebGLTextures): void; + setOptional(gl: WebGLRenderingContext, object: any, name: string): void; + + static upload(gl: WebGLRenderingContext, seq: any, values: any[], textures: WebGLTextures): void; + static seqWithValue(seq: any, values: any[]): any[]; +} diff --git a/backend/libs/three/renderers/webgl/WebGLUniforms.js b/backend/libs/three/renderers/webgl/WebGLUniforms.js new file mode 100644 index 0000000000000000000000000000000000000000..813159157646401c5d535e7be86ed052ad62008b --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLUniforms.js @@ -0,0 +1,850 @@ +/** + * Uniforms of a program. + * Those form a tree structure with a special top-level container for the root, + * which you get by calling 'new WebGLUniforms( gl, program )'. + * + * + * Properties of inner nodes including the top-level container: + * + * .seq - array of nested uniforms + * .map - nested uniforms by name + * + * + * Methods of all nodes except the top-level container: + * + * .setValue( gl, value, [textures] ) + * + * uploads a uniform value(s) + * the 'textures' parameter is needed for sampler uniforms + * + * + * Static methods of the top-level container (textures factorizations): + * + * .upload( gl, seq, values, textures ) + * + * sets uniforms in 'seq' to 'values[id].value' + * + * .seqWithValue( seq, values ) : filteredSeq + * + * filters 'seq' entries with corresponding entry in values + * + * + * Methods of the top-level container (textures factorizations): + * + * .setValue( gl, name, value, textures ) + * + * sets uniform with name 'name' to 'value' + * + * .setOptional( gl, obj, prop ) + * + * like .set for an optional property of the object + * + */ + +import { CubeTexture } from '../../textures/CubeTexture.js'; +import { Texture } from '../../textures/Texture.js'; +import { DataTexture2DArray } from '../../textures/DataTexture2DArray.js'; +import { DataTexture3D } from '../../textures/DataTexture3D.js'; + +const emptyTexture = new Texture(); +const emptyTexture2dArray = new DataTexture2DArray(); +const emptyTexture3d = new DataTexture3D(); +const emptyCubeTexture = new CubeTexture(); + +// --- Utilities --- + +// Array Caches (provide typed arrays for temporary by size) + +const arrayCacheF32 = []; +const arrayCacheI32 = []; + +// Float32Array caches used for uploading Matrix uniforms + +const mat4array = new Float32Array(16); +const mat3array = new Float32Array(9); +const mat2array = new Float32Array(4); + +// Flattening for arrays of vectors and matrices + +function flatten(array, nBlocks, blockSize) { + const firstElem = array[0]; + + if (firstElem <= 0 || firstElem > 0) return array; + // unoptimized: ! isNaN( firstElem ) + // see http://jacksondunstan.com/articles/983 + + const n = nBlocks * blockSize; + let r = arrayCacheF32[n]; + + if (r === undefined) { + r = new Float32Array(n); + arrayCacheF32[n] = r; + } + + if (nBlocks !== 0) { + firstElem.toArray(r, 0); + + for (let i = 1, offset = 0; i !== nBlocks; ++i) { + offset += blockSize; + array[i].toArray(r, offset); + } + } + + return r; +} + +function arraysEqual(a, b) { + if (a.length !== b.length) return false; + + for (let i = 0, l = a.length; i < l; i++) { + if (a[i] !== b[i]) return false; + } + + return true; +} + +function copyArray(a, b) { + for (let i = 0, l = b.length; i < l; i++) { + a[i] = b[i]; + } +} + +// Texture unit allocation + +function allocTexUnits(textures, n) { + let r = arrayCacheI32[n]; + + if (r === undefined) { + r = new Int32Array(n); + arrayCacheI32[n] = r; + } + + for (let i = 0; i !== n; ++i) { + r[i] = textures.allocateTextureUnit(); + } + + return r; +} + +// --- Setters --- + +// Note: Defining these methods externally, because they come in a bunch +// and this way their names minify. + +// Single scalar + +function setValueV1f(gl, v) { + const cache = this.cache; + + if (cache[0] === v) return; + + gl.uniform1f(this.addr, v); + + cache[0] = v; +} + +// Single float vector (from flat array or THREE.VectorN) + +function setValueV2f(gl, v) { + const cache = this.cache; + + if (v.x !== undefined) { + if (cache[0] !== v.x || cache[1] !== v.y) { + gl.uniform2f(this.addr, v.x, v.y); + + cache[0] = v.x; + cache[1] = v.y; + } + } else { + if (arraysEqual(cache, v)) return; + + gl.uniform2fv(this.addr, v); + + copyArray(cache, v); + } +} + +function setValueV3f(gl, v) { + const cache = this.cache; + + if (v.x !== undefined) { + if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) { + gl.uniform3f(this.addr, v.x, v.y, v.z); + + cache[0] = v.x; + cache[1] = v.y; + cache[2] = v.z; + } + } else if (v.r !== undefined) { + if (cache[0] !== v.r || cache[1] !== v.g || cache[2] !== v.b) { + gl.uniform3f(this.addr, v.r, v.g, v.b); + + cache[0] = v.r; + cache[1] = v.g; + cache[2] = v.b; + } + } else { + if (arraysEqual(cache, v)) return; + + gl.uniform3fv(this.addr, v); + + copyArray(cache, v); + } +} + +function setValueV4f(gl, v) { + const cache = this.cache; + + if (v.x !== undefined) { + if (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) { + gl.uniform4f(this.addr, v.x, v.y, v.z, v.w); + + cache[0] = v.x; + cache[1] = v.y; + cache[2] = v.z; + cache[3] = v.w; + } + } else { + if (arraysEqual(cache, v)) return; + + gl.uniform4fv(this.addr, v); + + copyArray(cache, v); + } +} + +// Single matrix (from flat array or THREE.MatrixN) + +function setValueM2(gl, v) { + const cache = this.cache; + const elements = v.elements; + + if (elements === undefined) { + if (arraysEqual(cache, v)) return; + + gl.uniformMatrix2fv(this.addr, false, v); + + copyArray(cache, v); + } else { + if (arraysEqual(cache, elements)) return; + + mat2array.set(elements); + + gl.uniformMatrix2fv(this.addr, false, mat2array); + + copyArray(cache, elements); + } +} + +function setValueM3(gl, v) { + const cache = this.cache; + const elements = v.elements; + + if (elements === undefined) { + if (arraysEqual(cache, v)) return; + + gl.uniformMatrix3fv(this.addr, false, v); + + copyArray(cache, v); + } else { + if (arraysEqual(cache, elements)) return; + + mat3array.set(elements); + + gl.uniformMatrix3fv(this.addr, false, mat3array); + + copyArray(cache, elements); + } +} + +function setValueM4(gl, v) { + const cache = this.cache; + const elements = v.elements; + + if (elements === undefined) { + if (arraysEqual(cache, v)) return; + + gl.uniformMatrix4fv(this.addr, false, v); + + copyArray(cache, v); + } else { + if (arraysEqual(cache, elements)) return; + + mat4array.set(elements); + + gl.uniformMatrix4fv(this.addr, false, mat4array); + + copyArray(cache, elements); + } +} + +// Single integer / boolean + +function setValueV1i(gl, v) { + const cache = this.cache; + + if (cache[0] === v) return; + + gl.uniform1i(this.addr, v); + + cache[0] = v; +} + +// Single integer / boolean vector (from flat array) + +function setValueV2i(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform2iv(this.addr, v); + + copyArray(cache, v); +} + +function setValueV3i(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform3iv(this.addr, v); + + copyArray(cache, v); +} + +function setValueV4i(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform4iv(this.addr, v); + + copyArray(cache, v); +} + +// Single unsigned integer + +function setValueV1ui(gl, v) { + const cache = this.cache; + + if (cache[0] === v) return; + + gl.uniform1ui(this.addr, v); + + cache[0] = v; +} + +// Single unsigned integer vector (from flat array) + +function setValueV2ui(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform2uiv(this.addr, v); + + copyArray(cache, v); +} + +function setValueV3ui(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform3uiv(this.addr, v); + + copyArray(cache, v); +} + +function setValueV4ui(gl, v) { + const cache = this.cache; + + if (arraysEqual(cache, v)) return; + + gl.uniform4uiv(this.addr, v); + + copyArray(cache, v); +} + +// Single texture (2D / Cube) + +function setValueT1(gl, v, textures) { + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if (cache[0] !== unit) { + gl.uniform1i(this.addr, unit); + cache[0] = unit; + } + + textures.safeSetTexture2D(v || emptyTexture, unit); +} + +function setValueT3D1(gl, v, textures) { + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if (cache[0] !== unit) { + gl.uniform1i(this.addr, unit); + cache[0] = unit; + } + + textures.setTexture3D(v || emptyTexture3d, unit); +} + +function setValueT6(gl, v, textures) { + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if (cache[0] !== unit) { + gl.uniform1i(this.addr, unit); + cache[0] = unit; + } + + textures.safeSetTextureCube(v || emptyCubeTexture, unit); +} + +function setValueT2DArray1(gl, v, textures) { + const cache = this.cache; + const unit = textures.allocateTextureUnit(); + + if (cache[0] !== unit) { + gl.uniform1i(this.addr, unit); + cache[0] = unit; + } + + textures.setTexture2DArray(v || emptyTexture2dArray, unit); +} + +// Helper to pick the right setter for the singular case + +function getSingularSetter(type) { + switch (type) { + case 0x1406: + return setValueV1f; // FLOAT + case 0x8b50: + return setValueV2f; // _VEC2 + case 0x8b51: + return setValueV3f; // _VEC3 + case 0x8b52: + return setValueV4f; // _VEC4 + + case 0x8b5a: + return setValueM2; // _MAT2 + case 0x8b5b: + return setValueM3; // _MAT3 + case 0x8b5c: + return setValueM4; // _MAT4 + + case 0x1404: + case 0x8b56: + return setValueV1i; // INT, BOOL + case 0x8b53: + case 0x8b57: + return setValueV2i; // _VEC2 + case 0x8b54: + case 0x8b58: + return setValueV3i; // _VEC3 + case 0x8b55: + case 0x8b59: + return setValueV4i; // _VEC4 + + case 0x1405: + return setValueV1ui; // UINT + case 0x8dc6: + return setValueV2ui; // _VEC2 + case 0x8dc7: + return setValueV3ui; // _VEC3 + case 0x8dc8: + return setValueV4ui; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3D1; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArray1; + } +} + +// Array of scalars + +function setValueV1fArray(gl, v) { + gl.uniform1fv(this.addr, v); +} + +// Array of vectors (from flat array or array of THREE.VectorN) + +function setValueV2fArray(gl, v) { + const data = flatten(v, this.size, 2); + + gl.uniform2fv(this.addr, data); +} + +function setValueV3fArray(gl, v) { + const data = flatten(v, this.size, 3); + + gl.uniform3fv(this.addr, data); +} + +function setValueV4fArray(gl, v) { + const data = flatten(v, this.size, 4); + + gl.uniform4fv(this.addr, data); +} + +// Array of matrices (from flat array or array of THREE.MatrixN) + +function setValueM2Array(gl, v) { + const data = flatten(v, this.size, 4); + + gl.uniformMatrix2fv(this.addr, false, data); +} + +function setValueM3Array(gl, v) { + const data = flatten(v, this.size, 9); + + gl.uniformMatrix3fv(this.addr, false, data); +} + +function setValueM4Array(gl, v) { + const data = flatten(v, this.size, 16); + + gl.uniformMatrix4fv(this.addr, false, data); +} + +// Array of integer / boolean + +function setValueV1iArray(gl, v) { + gl.uniform1iv(this.addr, v); +} + +// Array of integer / boolean vectors (from flat array) + +function setValueV2iArray(gl, v) { + gl.uniform2iv(this.addr, v); +} + +function setValueV3iArray(gl, v) { + gl.uniform3iv(this.addr, v); +} + +function setValueV4iArray(gl, v) { + gl.uniform4iv(this.addr, v); +} + +// Array of unsigned integer + +function setValueV1uiArray(gl, v) { + gl.uniform1uiv(this.addr, v); +} + +// Array of unsigned integer vectors (from flat array) + +function setValueV2uiArray(gl, v) { + gl.uniform2uiv(this.addr, v); +} + +function setValueV3uiArray(gl, v) { + gl.uniform3uiv(this.addr, v); +} + +function setValueV4uiArray(gl, v) { + gl.uniform4uiv(this.addr, v); +} + +// Array of textures (2D / 3D / Cube / 2DArray) + +function setValueT1Array(gl, v, textures) { + const n = v.length; + + const units = allocTexUnits(textures, n); + + gl.uniform1iv(this.addr, units); + + for (let i = 0; i !== n; ++i) { + textures.safeSetTexture2D(v[i] || emptyTexture, units[i]); + } +} + +function setValueT3DArray(gl, v, textures) { + const n = v.length; + + const units = allocTexUnits(textures, n); + + gl.uniform1iv(this.addr, units); + + for (let i = 0; i !== n; ++i) { + textures.setTexture3D(v[i] || emptyTexture3d, units[i]); + } +} + +function setValueT6Array(gl, v, textures) { + const n = v.length; + + const units = allocTexUnits(textures, n); + + gl.uniform1iv(this.addr, units); + + for (let i = 0; i !== n; ++i) { + textures.safeSetTextureCube(v[i] || emptyCubeTexture, units[i]); + } +} + +function setValueT2DArrayArray(gl, v, textures) { + const n = v.length; + + const units = allocTexUnits(textures, n); + + gl.uniform1iv(this.addr, units); + + for (let i = 0; i !== n; ++i) { + textures.setTexture2DArray(v[i] || emptyTexture2dArray, units[i]); + } +} + +// Helper to pick the right setter for a pure (bottom-level) array + +function getPureArraySetter(type) { + switch (type) { + case 0x1406: + return setValueV1fArray; // FLOAT + case 0x8b50: + return setValueV2fArray; // _VEC2 + case 0x8b51: + return setValueV3fArray; // _VEC3 + case 0x8b52: + return setValueV4fArray; // _VEC4 + + case 0x8b5a: + return setValueM2Array; // _MAT2 + case 0x8b5b: + return setValueM3Array; // _MAT3 + case 0x8b5c: + return setValueM4Array; // _MAT4 + + case 0x1404: + case 0x8b56: + return setValueV1iArray; // INT, BOOL + case 0x8b53: + case 0x8b57: + return setValueV2iArray; // _VEC2 + case 0x8b54: + case 0x8b58: + return setValueV3iArray; // _VEC3 + case 0x8b55: + case 0x8b59: + return setValueV4iArray; // _VEC4 + + case 0x1405: + return setValueV1uiArray; // UINT + case 0x8dc6: + return setValueV2uiArray; // _VEC2 + case 0x8dc7: + return setValueV3uiArray; // _VEC3 + case 0x8dc8: + return setValueV4uiArray; // _VEC4 + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1Array; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3DArray; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6Array; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArrayArray; + } +} + +// --- Uniform Classes --- + +function SingleUniform(id, activeInfo, addr) { + this.id = id; + this.addr = addr; + this.cache = []; + this.setValue = getSingularSetter(activeInfo.type); + + // this.path = activeInfo.name; // DEBUG +} + +function PureArrayUniform(id, activeInfo, addr) { + this.id = id; + this.addr = addr; + this.cache = []; + this.size = activeInfo.size; + this.setValue = getPureArraySetter(activeInfo.type); + + // this.path = activeInfo.name; // DEBUG +} + +PureArrayUniform.prototype.updateCache = function (data) { + const cache = this.cache; + + if (data instanceof Float32Array && cache.length !== data.length) { + this.cache = new Float32Array(data.length); + } + + copyArray(cache, data); +}; + +function StructuredUniform(id) { + this.id = id; + + this.seq = []; + this.map = {}; +} + +StructuredUniform.prototype.setValue = function (gl, value, textures) { + const seq = this.seq; + + for (let i = 0, n = seq.length; i !== n; ++i) { + const u = seq[i]; + u.setValue(gl, value[u.id], textures); + } +}; + +// --- Top-level --- + +// Parser - builds up the property tree from the path strings + +const RePathPart = /(\w+)(\])?(\[|\.)?/g; + +// extracts +// - the identifier (member name or array index) +// - followed by an optional right bracket (found when array index) +// - followed by an optional left bracket or dot (type of subscript) +// +// Note: These portions can be read in a non-overlapping fashion and +// allow straightforward parsing of the hierarchy that WebGL encodes +// in the uniform names. + +function addUniform(container, uniformObject) { + container.seq.push(uniformObject); + container.map[uniformObject.id] = uniformObject; +} + +function parseUniform(activeInfo, addr, container) { + const path = activeInfo.name, + pathLength = path.length; + + // reset RegExp object, because of the early exit of a previous run + RePathPart.lastIndex = 0; + + while (true) { + const match = RePathPart.exec(path), + matchEnd = RePathPart.lastIndex; + + let id = match[1]; + const idIsIndex = match[2] === ']', + subscript = match[3]; + + if (idIsIndex) id = id | 0; // convert to integer + + if (subscript === undefined || (subscript === '[' && matchEnd + 2 === pathLength)) { + // bare name or "pure" bottom-level array "[0]" suffix + + addUniform(container, subscript === undefined ? new SingleUniform(id, activeInfo, addr) : new PureArrayUniform(id, activeInfo, addr)); + + break; + } else { + // step into inner node / create it in case it doesn't exist + + const map = container.map; + let next = map[id]; + + if (next === undefined) { + next = new StructuredUniform(id); + addUniform(container, next); + } + + container = next; + } + } +} + +// Root Container + +function WebGLUniforms(gl, program) { + this.seq = []; + this.map = {}; + + const n = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); + + for (let i = 0; i < n; ++i) { + const info = gl.getActiveUniform(program, i), + addr = gl.getUniformLocation(program, info.name); + + parseUniform(info, addr, this); + } +} + +WebGLUniforms.prototype.setValue = function (gl, name, value, textures) { + const u = this.map[name]; + + if (u !== undefined) u.setValue(gl, value, textures); +}; + +WebGLUniforms.prototype.setOptional = function (gl, object, name) { + const v = object[name]; + + if (v !== undefined) this.setValue(gl, name, v); +}; + +// Static interface + +WebGLUniforms.upload = function (gl, seq, values, textures) { + for (let i = 0, n = seq.length; i !== n; ++i) { + const u = seq[i], + v = values[u.id]; + + if (v.needsUpdate !== false) { + // note: always updating when .needsUpdate is undefined + u.setValue(gl, v.value, textures); + } + } +}; + +WebGLUniforms.seqWithValue = function (seq, values) { + const r = []; + + for (let i = 0, n = seq.length; i !== n; ++i) { + const u = seq[i]; + if (u.id in values) r.push(u); + } + + return r; +}; + +export { WebGLUniforms }; diff --git a/backend/libs/three/renderers/webgl/WebGLUtils.d.ts b/backend/libs/three/renderers/webgl/WebGLUtils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..a45b51a932450dd2b847db0274a6f07d90ff1975 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLUtils.d.ts @@ -0,0 +1,7 @@ +import { CompressedPixelFormat, PixelFormat, TextureEncoding, TextureDataType } from '../../constants'; + +export class WebGLUtils { + constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, extensions: any, capabilities: any); + + convert(p: PixelFormat | CompressedPixelFormat | TextureDataType, encoding?: TextureEncoding | null): number | null; +} diff --git a/backend/libs/three/renderers/webgl/WebGLUtils.js b/backend/libs/three/renderers/webgl/WebGLUtils.js new file mode 100644 index 0000000000000000000000000000000000000000..0726536503e55a1e865287d6f40c2c0859ece307 --- /dev/null +++ b/backend/libs/three/renderers/webgl/WebGLUtils.js @@ -0,0 +1,268 @@ +import { + RGBA_ASTC_4x4_Format, + RGBA_ASTC_5x4_Format, + RGBA_ASTC_5x5_Format, + RGBA_ASTC_6x5_Format, + RGBA_ASTC_6x6_Format, + RGBA_ASTC_8x5_Format, + RGBA_ASTC_8x6_Format, + RGBA_ASTC_8x8_Format, + RGBA_ASTC_10x5_Format, + RGBA_ASTC_10x6_Format, + RGBA_ASTC_10x8_Format, + RGBA_ASTC_10x10_Format, + RGBA_ASTC_12x10_Format, + RGBA_ASTC_12x12_Format, + RGB_ETC1_Format, + RGB_ETC2_Format, + RGBA_ETC2_EAC_Format, + RGBA_PVRTC_2BPPV1_Format, + RGBA_PVRTC_4BPPV1_Format, + RGB_PVRTC_2BPPV1_Format, + RGB_PVRTC_4BPPV1_Format, + RGBA_S3TC_DXT5_Format, + RGBA_S3TC_DXT3_Format, + RGBA_S3TC_DXT1_Format, + RGB_S3TC_DXT1_Format, + DepthFormat, + DepthStencilFormat, + LuminanceAlphaFormat, + LuminanceFormat, + RedFormat, + RGBAFormat, + AlphaFormat, + RedIntegerFormat, + RGFormat, + RGIntegerFormat, + RGBIntegerFormat, + RGBAIntegerFormat, + HalfFloatType, + FloatType, + UnsignedIntType, + IntType, + UnsignedShortType, + ShortType, + ByteType, + UnsignedInt248Type, + UnsignedShort565Type, + UnsignedShort5551Type, + UnsignedShort4444Type, + UnsignedByteType, + RGBA_BPTC_Format, + sRGBEncoding, + _SRGBAFormat, +} from '../../constants.js'; + +function WebGLUtils(gl, extensions, capabilities) { + const isWebGL2 = capabilities.isWebGL2; + + function convert(p, encoding = null) { + let extension; + + if (p === UnsignedByteType) return gl.UNSIGNED_BYTE; + if (p === UnsignedShort4444Type) return gl.UNSIGNED_SHORT_4_4_4_4; + if (p === UnsignedShort5551Type) return gl.UNSIGNED_SHORT_5_5_5_1; + if (p === UnsignedShort565Type) return gl.UNSIGNED_SHORT_5_6_5; + + if (p === ByteType) return gl.BYTE; + if (p === ShortType) return gl.SHORT; + if (p === UnsignedShortType) return gl.UNSIGNED_SHORT; + if (p === IntType) return gl.INT; + if (p === UnsignedIntType) return gl.UNSIGNED_INT; + if (p === FloatType) return gl.FLOAT; + + if (p === HalfFloatType) { + if (isWebGL2) return gl.HALF_FLOAT; + + extension = extensions.get('OES_texture_half_float'); + + if (extension !== null) { + return extension.HALF_FLOAT_OES; + } else { + return null; + } + } + + if (p === AlphaFormat) return gl.ALPHA; + if (p === RGBAFormat) return gl.RGBA; + if (p === LuminanceFormat) return gl.LUMINANCE; + if (p === LuminanceAlphaFormat) return gl.LUMINANCE_ALPHA; + if (p === DepthFormat) return gl.DEPTH_COMPONENT; + if (p === DepthStencilFormat) return gl.DEPTH_STENCIL; + if (p === RedFormat) return gl.RED; + + // WebGL 1 sRGB fallback + + if (p === _SRGBAFormat) { + extension = extensions.get('EXT_sRGB'); + + if (extension !== null) { + return extension.SRGB_ALPHA_EXT; + } else { + return null; + } + } + + // WebGL2 formats. + + if (p === RedIntegerFormat) return gl.RED_INTEGER; + if (p === RGFormat) return gl.RG; + if (p === RGIntegerFormat) return gl.RG_INTEGER; + if (p === RGBIntegerFormat) return gl.RGB_INTEGER; + if (p === RGBAIntegerFormat) return gl.RGBA_INTEGER; + + // S3TC + + if (p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format) { + if (encoding === sRGBEncoding) { + extension = extensions.get('WEBGL_compressed_texture_s3tc_srgb'); + + if (extension !== null) { + if (p === RGB_S3TC_DXT1_Format) return extension.COMPRESSED_SRGB_S3TC_DXT1_EXT; + if (p === RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + if (p === RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; + if (p === RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + } else { + return null; + } + } else { + extension = extensions.get('WEBGL_compressed_texture_s3tc'); + + if (extension !== null) { + if (p === RGB_S3TC_DXT1_Format) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT; + if (p === RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT; + if (p === RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT; + if (p === RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT; + } else { + return null; + } + } + } + + // PVRTC + + if (p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format) { + extension = extensions.get('WEBGL_compressed_texture_pvrtc'); + + if (extension !== null) { + if (p === RGB_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + if (p === RGB_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + if (p === RGBA_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + if (p === RGBA_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + } else { + return null; + } + } + + // ETC1 + + if (p === RGB_ETC1_Format) { + extension = extensions.get('WEBGL_compressed_texture_etc1'); + + if (extension !== null) { + return extension.COMPRESSED_RGB_ETC1_WEBGL; + } else { + return null; + } + } + + // ETC2 + + if (p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format) { + extension = extensions.get('WEBGL_compressed_texture_etc'); + + if (extension !== null) { + if (p === RGB_ETC2_Format) return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2; + if (p === RGBA_ETC2_EAC_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC; + } else { + return null; + } + } + + // ASTC + + if ( + p === RGBA_ASTC_4x4_Format || + p === RGBA_ASTC_5x4_Format || + p === RGBA_ASTC_5x5_Format || + p === RGBA_ASTC_6x5_Format || + p === RGBA_ASTC_6x6_Format || + p === RGBA_ASTC_8x5_Format || + p === RGBA_ASTC_8x6_Format || + p === RGBA_ASTC_8x8_Format || + p === RGBA_ASTC_10x5_Format || + p === RGBA_ASTC_10x6_Format || + p === RGBA_ASTC_10x8_Format || + p === RGBA_ASTC_10x10_Format || + p === RGBA_ASTC_12x10_Format || + p === RGBA_ASTC_12x12_Format + ) { + extension = extensions.get('WEBGL_compressed_texture_astc'); + + if (extension !== null) { + if (p === RGBA_ASTC_4x4_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : extension.COMPRESSED_RGBA_ASTC_4x4_KHR; + if (p === RGBA_ASTC_5x4_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : extension.COMPRESSED_RGBA_ASTC_5x4_KHR; + if (p === RGBA_ASTC_5x5_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : extension.COMPRESSED_RGBA_ASTC_5x5_KHR; + if (p === RGBA_ASTC_6x5_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : extension.COMPRESSED_RGBA_ASTC_6x5_KHR; + if (p === RGBA_ASTC_6x6_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : extension.COMPRESSED_RGBA_ASTC_6x6_KHR; + if (p === RGBA_ASTC_8x5_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : extension.COMPRESSED_RGBA_ASTC_8x5_KHR; + if (p === RGBA_ASTC_8x6_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : extension.COMPRESSED_RGBA_ASTC_8x6_KHR; + if (p === RGBA_ASTC_8x8_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : extension.COMPRESSED_RGBA_ASTC_8x8_KHR; + if (p === RGBA_ASTC_10x5_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : extension.COMPRESSED_RGBA_ASTC_10x5_KHR; + if (p === RGBA_ASTC_10x6_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : extension.COMPRESSED_RGBA_ASTC_10x6_KHR; + if (p === RGBA_ASTC_10x8_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : extension.COMPRESSED_RGBA_ASTC_10x8_KHR; + if (p === RGBA_ASTC_10x10_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : extension.COMPRESSED_RGBA_ASTC_10x10_KHR; + if (p === RGBA_ASTC_12x10_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : extension.COMPRESSED_RGBA_ASTC_12x10_KHR; + if (p === RGBA_ASTC_12x12_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : extension.COMPRESSED_RGBA_ASTC_12x12_KHR; + } else { + return null; + } + } + + // BPTC + + if (p === RGBA_BPTC_Format) { + extension = extensions.get('EXT_texture_compression_bptc'); + + if (extension !== null) { + if (p === RGBA_BPTC_Format) + return encoding === sRGBEncoding ? extension.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : extension.COMPRESSED_RGBA_BPTC_UNORM_EXT; + } else { + return null; + } + } + + // + + if (p === UnsignedInt248Type) { + if (isWebGL2) return gl.UNSIGNED_INT_24_8; + + extension = extensions.get('WEBGL_depth_texture'); + + if (extension !== null) { + return extension.UNSIGNED_INT_24_8_WEBGL; + } else { + return null; + } + } + } + + return { convert: convert }; +} + +export { WebGLUtils }; diff --git a/backend/libs/three/renderers/webxr/WebXR.d.ts b/backend/libs/three/renderers/webxr/WebXR.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..bd2f3f1ec5a6357aa8c6887b3d728a23248db69b --- /dev/null +++ b/backend/libs/three/renderers/webxr/WebXR.d.ts @@ -0,0 +1,318 @@ +export type XRSessionMode = 'inline' | 'immersive-vr' | 'immersive-ar'; + +export type XRReferenceSpaceType = 'viewer' | 'local' | 'local-floor' | 'bounded-floor' | 'unbounded'; + +export type XREnvironmentBlendMode = 'opaque' | 'additive' | 'alpha-blend'; + +export type XRVisibilityState = 'visible' | 'visible-blurred' | 'hidden'; + +export type XRHandedness = 'none' | 'left' | 'right'; + +export type XRTargetRayMode = 'gaze' | 'tracked-pointer' | 'screen'; + +export type XREye = 'none' | 'left' | 'right'; + +export type XREventType = 'end' | 'select' | 'selectstart' | 'selectend' | 'squeeze' | 'squeezestart' | 'squeezeend' | 'inputsourceschange'; + +export type XRAnimationLoopCallback = (time: number, frame?: XRFrame) => void; + +export type XRFrameRequestCallback = (time: number, frame: XRFrame) => void; + +export interface XR extends EventTarget { + requestSession(mode: XRSessionMode, options?: XRSessionInit): Promise; + isSessionSupported(mode: XRSessionMode): Promise; +} + +export interface Window { + XRSession?: Constructor | undefined; + XR?: Constructor | undefined; +} + +export interface Navigator { + xr?: XR | undefined; +} + +export interface XRReferenceSpace extends EventTarget { + getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace; +} +export interface XRHitTestOptionsInit { + space: EventTarget; + offsetRay?: XRRay | undefined; +} + +export interface XRTransientInputHitTestOptionsInit { + profile: string; + offsetRay?: XRRay | undefined; +} + +export interface XRViewport { + readonly x: number; + readonly y: number; + readonly width: number; + readonly height: number; +} + +export interface WebGLRenderingContext { + makeXRCompatible(): Promise; +} + +export interface XRRenderState { + readonly depthNear: number; + readonly depthFar: number; + readonly inlineVerticalFieldOfView?: number | undefined; + readonly baseLayer?: XRWebGLLayer | undefined; +} + +export interface XRRenderStateInit { + depthNear?: number | undefined; + depthFar?: number | undefined; + inlineVerticalFieldOfView?: number | undefined; + baseLayer?: XRWebGLLayer | undefined; +} + +export interface XRGamepad { + readonly id: string; + readonly index: number; // long + readonly connected: boolean; + readonly timestamp: DOMHighResTimeStamp; + readonly mapping: GamepadMappingType; + readonly axes: Float32Array; // FrozenArray; + readonly buttons: GamepadButton[]; // FrozenArray; +} + +export interface XRInputSource { + readonly handedness: XRHandedness; + readonly targetRayMode: XRTargetRayMode; + readonly targetRaySpace: EventTarget; + readonly gripSpace?: EventTarget | undefined; + readonly profiles: string[]; + readonly gamepad: XRGamepad; + readonly hand?: XRHand | undefined; +} + +export interface XRSessionInit { + optionalFeatures?: string[] | undefined; + requiredFeatures?: string[] | undefined; +} + +export interface XRSession extends EventTarget { + requestReferenceSpace(type: XRReferenceSpaceType): Promise; + updateRenderState(renderStateInit: XRRenderStateInit): Promise; + requestAnimationFrame(callback: XRFrameRequestCallback): number; + cancelAnimationFrame(id: number): void; + end(): Promise; + renderState: XRRenderState; + inputSources: XRInputSource[]; + environmentBlendMode: XREnvironmentBlendMode; + visibilityState: XRVisibilityState; + + // hit test + requestHitTestSource(options: XRHitTestOptionsInit): Promise; + requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise; + + // legacy AR hit test + requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise; + + // legacy plane detection + updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } | undefined }): void; +} + +export interface XRReferenceSpace extends EventTarget { + getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace; + onreset: any; +} + +export type XRPlaneSet = Set; +export type XRAnchorSet = Set; + +export interface XRFrame { + readonly session: XRSession; + getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined; + getPose(space: EventTarget, baseSpace: EventTarget): XRPose | undefined; + + // AR + getHitTestResults(hitTestSource: XRHitTestSource): XRHitTestResult[]; + getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): XRTransientInputHitTestResult[]; + // Anchors + trackedAnchors?: XRAnchorSet | undefined; + createAnchor(pose: XRRigidTransform, space: EventTarget): Promise; + // Planes + worldInformation: { + detectedPlanes?: XRPlaneSet | undefined; + }; + // Hand tracking + getJointPose(joint: XRJointSpace, baseSpace: EventTarget): XRJointPose; +} + +export interface XRViewerPose { + readonly transform: XRRigidTransform; + readonly views: XRView[]; +} + +export interface XRPose { + readonly emulatedPosition: boolean; + readonly transform: XRRigidTransform; +} + +export interface XRWebGLLayerInit { + antialias?: boolean | undefined; + depth?: boolean | undefined; + stencil?: boolean | undefined; + alpha?: boolean | undefined; + ignoreDepthValues?: boolean | undefined; + framebufferScaleFactor?: number | undefined; +} + +export class XRWebGLLayer { + constructor(session: XRSession, gl: WebGLRenderingContext | undefined, options?: XRWebGLLayerInit); + framebuffer: WebGLFramebuffer; + framebufferWidth: number; + framebufferHeight: number; + getViewport(view: XRView): XRViewport; +} + +export interface DOMPointInit { + w?: number | undefined; + x?: number | undefined; + y?: number | undefined; + z?: number | undefined; +} + +export class XRRigidTransform { + constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit); + position: DOMPointReadOnly; + orientation: DOMPointReadOnly; + matrix: Float32Array; + inverse: XRRigidTransform; +} + +export interface XRView { + readonly eye: XREye; + readonly projectionMatrix: Float32Array; + readonly viewMatrix: Float32Array; + readonly transform: XRRigidTransform; +} + +export interface XRRayDirectionInit { + x?: number | undefined; + y?: number | undefined; + z?: number | undefined; + w?: number | undefined; +} + +export class XRRay { + readonly origin: DOMPointReadOnly; + readonly direction: XRRayDirectionInit; + matrix: Float32Array; + + constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: XRRayDirectionInit); +} + +export enum XRHitTestTrackableType { + 'point', + 'plane', + 'mesh', +} + +export interface XRHitResult { + hitMatrix: Float32Array; +} + +export interface XRTransientInputHitTestResult { + readonly inputSource: XRInputSource; + readonly results: XRHitTestResult[]; +} + +export interface XRHitTestResult { + getPose(baseSpace: EventTarget): XRPose | undefined | null; + // When anchor system is enabled + createAnchor?(pose: XRRigidTransform): Promise; +} + +export interface XRHitTestSource { + cancel(): void; +} + +export interface XRTransientInputHitTestSource { + cancel(): void; +} + +export interface XRHitTestOptionsInit { + space: EventTarget; + entityTypes?: XRHitTestTrackableType[] | undefined; + offsetRay?: XRRay | undefined; +} + +export interface XRTransientInputHitTestOptionsInit { + profile: string; + entityTypes?: XRHitTestTrackableType[] | undefined; + offsetRay?: XRRay | undefined; +} + +export interface XRAnchor { + anchorSpace: EventTarget; + delete(): void; +} + +export interface XRPlane { + orientation: 'Horizontal' | 'Vertical'; + planeSpace: EventTarget; + polygon: DOMPointReadOnly[]; + lastChangedTime: number; +} + +export enum XRHandJoint { + 'wrist', + 'thumb-metacarpal', + 'thumb-phalanx-proximal', + 'thumb-phalanx-distal', + 'thumb-tip', + 'index-finger-metacarpal', + 'index-finger-phalanx-proximal', + 'index-finger-phalanx-intermediate', + 'index-finger-phalanx-distal', + 'index-finger-tip', + 'middle-finger-metacarpal', + 'middle-finger-phalanx-proximal', + 'middle-finger-phalanx-intermediate', + 'middle-finger-phalanx-distal', + 'middle-finger-tip', + 'ring-finger-metacarpal', + 'ring-finger-phalanx-proximal', + 'ring-finger-phalanx-intermediate', + 'ring-finger-phalanx-distal', + 'ring-finger-tip', + 'pinky-finger-metacarpal', + 'pinky-finger-phalanx-proximal', + 'pinky-finger-phalanx-intermediate', + 'pinky-finger-phalanx-distal', + 'pinky-finger-tip', +} + +export interface XRJointSpace extends EventTarget { + readonly jointName: XRHandJoint; +} + +export interface XRJointPose extends XRPose { + readonly radius: number | undefined; +} + +export interface XRHand extends Map { + readonly size: number; +} + +export interface Constructor { + new (...args: any[]): T; + prototype: T; +} + +export interface XRInputSourceChangeEvent { + session: XRSession; + removed: XRInputSource[]; + added: XRInputSource[]; +} + +export interface XRInputSourceEvent extends Event { + readonly frame: XRFrame; + readonly inputSource: XRInputSource; +} diff --git a/backend/libs/three/renderers/webxr/WebXRController.d.ts b/backend/libs/three/renderers/webxr/WebXRController.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..65999b0502c7e37dbfbbb1beb401d1893b593987 --- /dev/null +++ b/backend/libs/three/renderers/webxr/WebXRController.d.ts @@ -0,0 +1,14 @@ +import { Group } from '../../objects/Group'; +import { XREventType, XRFrame, XRInputSource, XRReferenceSpace } from './WebXR'; + +export type XRControllerEventType = XREventType | 'disconnected' | 'connected'; + +export class WebXRController { + constructor(); + + getTargetRaySpace(): Group; + getGripSpace(): Group; + dispatchEvent(event: { type: XRControllerEventType; data?: XRInputSource | undefined }): this; + disconnect(inputSource: XRInputSource): this; + update(inputSource: XRInputSource, frame: XRFrame, referenceSpace: XRReferenceSpace): this; +} diff --git a/backend/libs/three/renderers/webxr/WebXRController.js b/backend/libs/three/renderers/webxr/WebXRController.js new file mode 100644 index 0000000000000000000000000000000000000000..e0cd665f5b4d81bbfc432a0a33f8669157ebc738 --- /dev/null +++ b/backend/libs/three/renderers/webxr/WebXRController.js @@ -0,0 +1,218 @@ +import { Vector3 } from '../../math/Vector3.js'; +import { Group } from '../../objects/Group.js'; + +const _moveEvent = { type: 'move' }; + +class WebXRController { + constructor() { + this._targetRay = null; + this._grip = null; + this._hand = null; + } + + getHandSpace() { + if (this._hand === null) { + this._hand = new Group(); + this._hand.matrixAutoUpdate = false; + this._hand.visible = false; + + this._hand.joints = {}; + this._hand.inputState = { pinching: false }; + } + + return this._hand; + } + + getTargetRaySpace() { + if (this._targetRay === null) { + this._targetRay = new Group(); + this._targetRay.matrixAutoUpdate = false; + this._targetRay.visible = false; + this._targetRay.hasLinearVelocity = false; + this._targetRay.linearVelocity = new Vector3(); + this._targetRay.hasAngularVelocity = false; + this._targetRay.angularVelocity = new Vector3(); + } + + return this._targetRay; + } + + getGripSpace() { + if (this._grip === null) { + this._grip = new Group(); + this._grip.matrixAutoUpdate = false; + this._grip.visible = false; + this._grip.hasLinearVelocity = false; + this._grip.linearVelocity = new Vector3(); + this._grip.hasAngularVelocity = false; + this._grip.angularVelocity = new Vector3(); + } + + return this._grip; + } + + dispatchEvent(event) { + if (this._targetRay !== null) { + this._targetRay.dispatchEvent(event); + } + + if (this._grip !== null) { + this._grip.dispatchEvent(event); + } + + if (this._hand !== null) { + this._hand.dispatchEvent(event); + } + + return this; + } + + disconnect(inputSource) { + this.dispatchEvent({ type: 'disconnected', data: inputSource }); + + if (this._targetRay !== null) { + this._targetRay.visible = false; + } + + if (this._grip !== null) { + this._grip.visible = false; + } + + if (this._hand !== null) { + this._hand.visible = false; + } + + return this; + } + + update(inputSource, frame, referenceSpace) { + let inputPose = null; + let gripPose = null; + let handPose = null; + + const targetRay = this._targetRay; + const grip = this._grip; + const hand = this._hand; + + if (inputSource && frame.session.visibilityState !== 'visible-blurred') { + if (targetRay !== null) { + inputPose = frame.getPose(inputSource.targetRaySpace, referenceSpace); + + if (inputPose !== null) { + targetRay.matrix.fromArray(inputPose.transform.matrix); + targetRay.matrix.decompose(targetRay.position, targetRay.rotation, targetRay.scale); + + if (inputPose.linearVelocity) { + targetRay.hasLinearVelocity = true; + targetRay.linearVelocity.copy(inputPose.linearVelocity); + } else { + targetRay.hasLinearVelocity = false; + } + + if (inputPose.angularVelocity) { + targetRay.hasAngularVelocity = true; + targetRay.angularVelocity.copy(inputPose.angularVelocity); + } else { + targetRay.hasAngularVelocity = false; + } + + this.dispatchEvent(_moveEvent); + } + } + + if (hand && inputSource.hand) { + handPose = true; + + for (const inputjoint of inputSource.hand.values()) { + // Update the joints groups with the XRJoint poses + const jointPose = frame.getJointPose(inputjoint, referenceSpace); + + if (hand.joints[inputjoint.jointName] === undefined) { + // The transform of this joint will be updated with the joint pose on each frame + const joint = new Group(); + joint.matrixAutoUpdate = false; + joint.visible = false; + hand.joints[inputjoint.jointName] = joint; + // ?? + hand.add(joint); + } + + const joint = hand.joints[inputjoint.jointName]; + + if (jointPose !== null) { + joint.matrix.fromArray(jointPose.transform.matrix); + joint.matrix.decompose(joint.position, joint.rotation, joint.scale); + joint.jointRadius = jointPose.radius; + } + + joint.visible = jointPose !== null; + } + + // Custom events + + // Check pinchz + const indexTip = hand.joints['index-finger-tip']; + const thumbTip = hand.joints['thumb-tip']; + const distance = indexTip.position.distanceTo(thumbTip.position); + + const distanceToPinch = 0.02; + const threshold = 0.005; + + if (hand.inputState.pinching && distance > distanceToPinch + threshold) { + hand.inputState.pinching = false; + this.dispatchEvent({ + type: 'pinchend', + handedness: inputSource.handedness, + target: this, + }); + } else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) { + hand.inputState.pinching = true; + this.dispatchEvent({ + type: 'pinchstart', + handedness: inputSource.handedness, + target: this, + }); + } + } else { + if (grip !== null && inputSource.gripSpace) { + gripPose = frame.getPose(inputSource.gripSpace, referenceSpace); + + if (gripPose !== null) { + grip.matrix.fromArray(gripPose.transform.matrix); + grip.matrix.decompose(grip.position, grip.rotation, grip.scale); + + if (gripPose.linearVelocity) { + grip.hasLinearVelocity = true; + grip.linearVelocity.copy(gripPose.linearVelocity); + } else { + grip.hasLinearVelocity = false; + } + + if (gripPose.angularVelocity) { + grip.hasAngularVelocity = true; + grip.angularVelocity.copy(gripPose.angularVelocity); + } else { + grip.hasAngularVelocity = false; + } + } + } + } + } + + if (targetRay !== null) { + targetRay.visible = inputPose !== null; + } + + if (grip !== null) { + grip.visible = gripPose !== null; + } + + if (hand !== null) { + hand.visible = handPose !== null; + } + + return this; + } +} + +export { WebXRController }; diff --git a/backend/libs/three/renderers/webxr/WebXRManager.d.ts b/backend/libs/three/renderers/webxr/WebXRManager.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..4c20587d0ff5c218702563cdbd5ba04bdcb9a606 --- /dev/null +++ b/backend/libs/three/renderers/webxr/WebXRManager.d.ts @@ -0,0 +1,32 @@ +import { Group } from '../../objects/Group'; +import { Camera } from '../../cameras/Camera'; +import { EventDispatcher } from '../../core/EventDispatcher'; +import { XRFrameRequestCallback, XRReferenceSpace, XRReferenceSpaceType, XRSession } from './WebXR'; + +export class WebXRManager extends EventDispatcher { + constructor(renderer: any, gl: WebGLRenderingContext); + + /** + * @default false + */ + enabled: boolean; + + /** + * @default false + */ + isPresenting: boolean; + + getController(index: number): Group; + getControllerGrip(index: number): Group; + getHand(index: number): Group; + setFramebufferScaleFactor(value: number): void; + setReferenceSpaceType(value: XRReferenceSpaceType): void; + getReferenceSpace(): XRReferenceSpace | null; + getSession(): XRSession | null; + setSession(value: XRSession): Promise; + getCamera(camera: Camera): Camera; + setAnimationLoop(callback: XRFrameRequestCallback | null): void; + getFoveation(): number | undefined; + setFoveation(foveation: number): void; + dispose(): void; +} diff --git a/backend/libs/three/renderers/webxr/WebXRManager.js b/backend/libs/three/renderers/webxr/WebXRManager.js new file mode 100644 index 0000000000000000000000000000000000000000..97b8d0a16f969f0368f03020996e082fa5b0f097 --- /dev/null +++ b/backend/libs/three/renderers/webxr/WebXRManager.js @@ -0,0 +1,568 @@ +import { ArrayCamera } from '../../cameras/ArrayCamera.js'; +import { EventDispatcher } from '../../core/EventDispatcher.js'; +import { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js'; +import { Vector3 } from '../../math/Vector3.js'; +import { Vector4 } from '../../math/Vector4.js'; +import { WebGLAnimation } from '../webgl/WebGLAnimation.js'; +import { WebGLRenderTarget } from '../WebGLRenderTarget.js'; +import { WebXRController } from './WebXRController.js'; +import { DepthTexture } from '../../textures/DepthTexture.js'; +import { WebGLMultisampleRenderTarget } from '../WebGLMultisampleRenderTarget.js'; +import { DepthFormat, DepthStencilFormat, RGBAFormat, sRGBEncoding, UnsignedByteType, UnsignedShortType, UnsignedInt248Type } from '../../constants.js'; + +class WebXRManager extends EventDispatcher { + constructor(renderer, gl) { + super(); + + const scope = this; + + let session = null; + let framebufferScaleFactor = 1.0; + + let referenceSpace = null; + let referenceSpaceType = 'local-floor'; + const hasMultisampledRenderToTexture = renderer.extensions.has('WEBGL_multisampled_render_to_texture'); + + let pose = null; + let glBinding = null; + let glProjLayer = null; + let glBaseLayer = null; + let isMultisample = false; + let xrFrame = null; + const attributes = gl.getContextAttributes(); + let initialRenderTarget = null; + let newRenderTarget = null; + + const controllers = []; + const inputSourcesMap = new Map(); + + // + + const cameraL = new PerspectiveCamera(); + cameraL.layers.enable(1); + cameraL.viewport = new Vector4(); + + const cameraR = new PerspectiveCamera(); + cameraR.layers.enable(2); + cameraR.viewport = new Vector4(); + + const cameras = [cameraL, cameraR]; + + const cameraVR = new ArrayCamera(); + cameraVR.layers.enable(1); + cameraVR.layers.enable(2); + + let _currentDepthNear = null; + let _currentDepthFar = null; + + // + + this.cameraAutoUpdate = true; + this.enabled = false; + + this.isPresenting = false; + + this.getController = function (index) { + let controller = controllers[index]; + + if (controller === undefined) { + controller = new WebXRController(); + controllers[index] = controller; + } + + return controller.getTargetRaySpace(); + }; + + this.getControllerGrip = function (index) { + let controller = controllers[index]; + + if (controller === undefined) { + controller = new WebXRController(); + controllers[index] = controller; + } + + return controller.getGripSpace(); + }; + + this.getHand = function (index) { + let controller = controllers[index]; + + if (controller === undefined) { + controller = new WebXRController(); + controllers[index] = controller; + } + + return controller.getHandSpace(); + }; + + // + + function onSessionEvent(event) { + const controller = inputSourcesMap.get(event.inputSource); + + if (controller) { + controller.dispatchEvent({ type: event.type, data: event.inputSource }); + } + } + + function onSessionEnd() { + inputSourcesMap.forEach(function (controller, inputSource) { + controller.disconnect(inputSource); + }); + + inputSourcesMap.clear(); + + _currentDepthNear = null; + _currentDepthFar = null; + + // restore framebuffer/rendering state + + renderer.setRenderTarget(initialRenderTarget); + + glBaseLayer = null; + glProjLayer = null; + glBinding = null; + session = null; + newRenderTarget = null; + + // + + animation.stop(); + + scope.isPresenting = false; + + scope.dispatchEvent({ type: 'sessionend' }); + } + + this.setFramebufferScaleFactor = function (value) { + framebufferScaleFactor = value; + + if (scope.isPresenting === true) { + console.warn('THREE.WebXRManager: Cannot change framebuffer scale while presenting.'); + } + }; + + this.setReferenceSpaceType = function (value) { + referenceSpaceType = value; + + if (scope.isPresenting === true) { + console.warn('THREE.WebXRManager: Cannot change reference space type while presenting.'); + } + }; + + this.getReferenceSpace = function () { + return referenceSpace; + }; + + this.getBaseLayer = function () { + return glProjLayer !== null ? glProjLayer : glBaseLayer; + }; + + this.getBinding = function () { + return glBinding; + }; + + this.getFrame = function () { + return xrFrame; + }; + + this.getSession = function () { + return session; + }; + + this.setSession = async function (value) { + session = value; + + if (session !== null) { + initialRenderTarget = renderer.getRenderTarget(); + + session.addEventListener('select', onSessionEvent); + session.addEventListener('selectstart', onSessionEvent); + session.addEventListener('selectend', onSessionEvent); + session.addEventListener('squeeze', onSessionEvent); + session.addEventListener('squeezestart', onSessionEvent); + session.addEventListener('squeezeend', onSessionEvent); + session.addEventListener('end', onSessionEnd); + session.addEventListener('inputsourceschange', onInputSourcesChange); + + if (attributes.xrCompatible !== true) { + await gl.makeXRCompatible(); + } + + if (session.renderState.layers === undefined || renderer.capabilities.isWebGL2 === false) { + const layerInit = { + antialias: session.renderState.layers === undefined ? attributes.antialias : true, + alpha: attributes.alpha, + depth: attributes.depth, + stencil: attributes.stencil, + framebufferScaleFactor: framebufferScaleFactor, + }; + + glBaseLayer = new XRWebGLLayer(session, gl, layerInit); + + session.updateRenderState({ baseLayer: glBaseLayer }); + + newRenderTarget = new WebGLRenderTarget(glBaseLayer.framebufferWidth, glBaseLayer.framebufferHeight, { + format: RGBAFormat, + type: UnsignedByteType, + encoding: renderer.outputEncoding, + }); + } else { + isMultisample = attributes.antialias; + let depthFormat = null; + let depthType = null; + let glDepthFormat = null; + + if (attributes.depth) { + glDepthFormat = attributes.stencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24; + depthFormat = attributes.stencil ? DepthStencilFormat : DepthFormat; + depthType = attributes.stencil ? UnsignedInt248Type : UnsignedShortType; + } + + const projectionlayerInit = { + colorFormat: renderer.outputEncoding === sRGBEncoding ? gl.SRGB8_ALPHA8 : gl.RGBA8, + depthFormat: glDepthFormat, + scaleFactor: framebufferScaleFactor, + }; + + glBinding = new XRWebGLBinding(session, gl); + + glProjLayer = glBinding.createProjectionLayer(projectionlayerInit); + + session.updateRenderState({ layers: [glProjLayer] }); + + if (isMultisample) { + newRenderTarget = new WebGLMultisampleRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + depthType, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + depthFormat + ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + useRenderToTexture: hasMultisampledRenderToTexture, + encoding: renderer.outputEncoding, + }); + } else { + newRenderTarget = new WebGLRenderTarget(glProjLayer.textureWidth, glProjLayer.textureHeight, { + format: RGBAFormat, + type: UnsignedByteType, + depthTexture: new DepthTexture( + glProjLayer.textureWidth, + glProjLayer.textureHeight, + depthType, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + depthFormat + ), + stencilBuffer: attributes.stencil, + ignoreDepth: glProjLayer.ignoreDepthValues, + encoding: renderer.outputEncoding, + }); + } + } + + // Set foveation to maximum. + this.setFoveation(1.0); + + referenceSpace = await session.requestReferenceSpace(referenceSpaceType); + + animation.setContext(session); + animation.start(); + + scope.isPresenting = true; + + scope.dispatchEvent({ type: 'sessionstart' }); + } + }; + + function onInputSourcesChange(event) { + const inputSources = session.inputSources; + + // Assign inputSources to available controllers + + for (let i = 0; i < controllers.length; i++) { + inputSourcesMap.set(inputSources[i], controllers[i]); + } + + // Notify disconnected + + for (let i = 0; i < event.removed.length; i++) { + const inputSource = event.removed[i]; + const controller = inputSourcesMap.get(inputSource); + + if (controller) { + controller.dispatchEvent({ type: 'disconnected', data: inputSource }); + inputSourcesMap.delete(inputSource); + } + } + + // Notify connected + + for (let i = 0; i < event.added.length; i++) { + const inputSource = event.added[i]; + const controller = inputSourcesMap.get(inputSource); + + if (controller) { + controller.dispatchEvent({ type: 'connected', data: inputSource }); + } + } + } + + // + + const cameraLPos = new Vector3(); + const cameraRPos = new Vector3(); + + /** + * Assumes 2 cameras that are parallel and share an X-axis, and that + * the cameras' projection and world matrices have already been set. + * And that near and far planes are identical for both cameras. + * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765 + */ + function setProjectionFromUnion(camera, cameraL, cameraR) { + cameraLPos.setFromMatrixPosition(cameraL.matrixWorld); + cameraRPos.setFromMatrixPosition(cameraR.matrixWorld); + + const ipd = cameraLPos.distanceTo(cameraRPos); + + const projL = cameraL.projectionMatrix.elements; + const projR = cameraR.projectionMatrix.elements; + + // VR systems will have identical far and near planes, and + // most likely identical top and bottom frustum extents. + // Use the left camera for these values. + const near = projL[14] / (projL[10] - 1); + const far = projL[14] / (projL[10] + 1); + const topFov = (projL[9] + 1) / projL[5]; + const bottomFov = (projL[9] - 1) / projL[5]; + + const leftFov = (projL[8] - 1) / projL[0]; + const rightFov = (projR[8] + 1) / projR[0]; + const left = near * leftFov; + const right = near * rightFov; + + // Calculate the new camera's position offset from the + // left camera. xOffset should be roughly half `ipd`. + const zOffset = ipd / (-leftFov + rightFov); + const xOffset = zOffset * -leftFov; + + // TODO: Better way to apply this offset? + cameraL.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale); + camera.translateX(xOffset); + camera.translateZ(zOffset); + camera.matrixWorld.compose(camera.position, camera.quaternion, camera.scale); + camera.matrixWorldInverse.copy(camera.matrixWorld).invert(); + + // Find the union of the frustum values of the cameras and scale + // the values so that the near plane's position does not change in world space, + // although must now be relative to the new union camera. + const near2 = near + zOffset; + const far2 = far + zOffset; + const left2 = left - xOffset; + const right2 = right + (ipd - xOffset); + const top2 = ((topFov * far) / far2) * near2; + const bottom2 = ((bottomFov * far) / far2) * near2; + + camera.projectionMatrix.makePerspective(left2, right2, top2, bottom2, near2, far2); + } + + function updateCamera(camera, parent) { + if (parent === null) { + camera.matrixWorld.copy(camera.matrix); + } else { + camera.matrixWorld.multiplyMatrices(parent.matrixWorld, camera.matrix); + } + + camera.matrixWorldInverse.copy(camera.matrixWorld).invert(); + } + + this.updateCamera = function (camera) { + if (session === null) return; + + cameraVR.near = cameraR.near = cameraL.near = camera.near; + cameraVR.far = cameraR.far = cameraL.far = camera.far; + + if (_currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far) { + // Note that the new renderState won't apply until the next frame. See #18320 + + session.updateRenderState({ + depthNear: cameraVR.near, + depthFar: cameraVR.far, + }); + + _currentDepthNear = cameraVR.near; + _currentDepthFar = cameraVR.far; + } + + const parent = camera.parent; + const cameras = cameraVR.cameras; + + updateCamera(cameraVR, parent); + + for (let i = 0; i < cameras.length; i++) { + updateCamera(cameras[i], parent); + } + + cameraVR.matrixWorld.decompose(cameraVR.position, cameraVR.quaternion, cameraVR.scale); + + // update user camera and its children + + camera.position.copy(cameraVR.position); + camera.quaternion.copy(cameraVR.quaternion); + camera.scale.copy(cameraVR.scale); + camera.matrix.copy(cameraVR.matrix); + camera.matrixWorld.copy(cameraVR.matrixWorld); + + const children = camera.children; + + for (let i = 0, l = children.length; i < l; i++) { + children[i].updateMatrixWorld(true); + } + + // update projection matrix for proper view frustum culling + + if (cameras.length === 2) { + setProjectionFromUnion(cameraVR, cameraL, cameraR); + } else { + // assume single camera setup (AR) + + cameraVR.projectionMatrix.copy(cameraL.projectionMatrix); + } + }; + + this.getCamera = function () { + return cameraVR; + }; + + this.getFoveation = function () { + if (glProjLayer !== null) { + return glProjLayer.fixedFoveation; + } + + if (glBaseLayer !== null) { + return glBaseLayer.fixedFoveation; + } + + return undefined; + }; + + this.setFoveation = function (foveation) { + // 0 = no foveation = full resolution + // 1 = maximum foveation = the edges render at lower resolution + + if (glProjLayer !== null) { + glProjLayer.fixedFoveation = foveation; + } + + if (glBaseLayer !== null && glBaseLayer.fixedFoveation !== undefined) { + glBaseLayer.fixedFoveation = foveation; + } + }; + + // Animation Loop + + let onAnimationFrameCallback = null; + + function onAnimationFrame(time, frame) { + pose = frame.getViewerPose(referenceSpace); + xrFrame = frame; + + if (pose !== null) { + const views = pose.views; + + if (glBaseLayer !== null) { + renderer.setRenderTargetFramebuffer(newRenderTarget, glBaseLayer.framebuffer); + renderer.setRenderTarget(newRenderTarget); + } + + let cameraVRNeedsUpdate = false; + + // check if it's necessary to rebuild cameraVR's camera list + + if (views.length !== cameraVR.cameras.length) { + cameraVR.cameras.length = 0; + cameraVRNeedsUpdate = true; + } + + for (let i = 0; i < views.length; i++) { + const view = views[i]; + + let viewport = null; + + if (glBaseLayer !== null) { + viewport = glBaseLayer.getViewport(view); + } else { + const glSubImage = glBinding.getViewSubImage(glProjLayer, view); + viewport = glSubImage.viewport; + + // For side-by-side projection, we only produce a single texture for both eyes. + if (i === 0) { + renderer.setRenderTargetTextures( + newRenderTarget, + glSubImage.colorTexture, + glProjLayer.ignoreDepthValues ? undefined : glSubImage.depthStencilTexture + ); + + renderer.setRenderTarget(newRenderTarget); + } + } + + const camera = cameras[i]; + + camera.matrix.fromArray(view.transform.matrix); + camera.projectionMatrix.fromArray(view.projectionMatrix); + camera.viewport.set(viewport.x, viewport.y, viewport.width, viewport.height); + + if (i === 0) { + cameraVR.matrix.copy(camera.matrix); + } + + if (cameraVRNeedsUpdate === true) { + cameraVR.cameras.push(camera); + } + } + } + + // + + const inputSources = session.inputSources; + + for (let i = 0; i < controllers.length; i++) { + const controller = controllers[i]; + const inputSource = inputSources[i]; + + controller.update(inputSource, frame, referenceSpace); + } + + if (onAnimationFrameCallback) onAnimationFrameCallback(time, frame); + + xrFrame = null; + } + + const animation = new WebGLAnimation(); + + animation.setAnimationLoop(onAnimationFrame); + + this.setAnimationLoop = function (callback) { + onAnimationFrameCallback = callback; + }; + + this.dispose = function () {}; + } +} + +export { WebXRManager }; diff --git a/backend/libs/three/scenes/Fog.d.ts b/backend/libs/three/scenes/Fog.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..60f2338bf7fe350b885e55fb446c024ac1e126d3 --- /dev/null +++ b/backend/libs/three/scenes/Fog.d.ts @@ -0,0 +1,43 @@ +import { ColorRepresentation } from '../utils'; +import { Color } from './../math/Color'; + +export interface FogBase { + name: string; + color: Color; + clone(): FogBase; + toJSON(): any; +} + +/** + * This class contains the parameters that define linear fog, i.e., that grows linearly denser with the distance. + */ +export class Fog implements FogBase { + constructor(color: ColorRepresentation, near?: number, far?: number); + + /** + * @default '' + */ + name: string; + + /** + * Fog color. + */ + color: Color; + + /** + * The minimum distance to start applying fog. Objects that are less than 'near' units from the active camera won't be affected by fog. + * @default 1 + */ + near: number; + + /** + * The maximum distance at which fog stops being calculated and applied. Objects that are more than 'far' units away from the active camera won't be affected by fog. + * @default 1000 + */ + far: number; + + readonly isFog: true; + + clone(): Fog; + toJSON(): any; +} diff --git a/backend/libs/three/scenes/Fog.js b/backend/libs/three/scenes/Fog.js new file mode 100644 index 0000000000000000000000000000000000000000..d976afd3bff7e919f0f4d2f29cfa26b891c59cf2 --- /dev/null +++ b/backend/libs/three/scenes/Fog.js @@ -0,0 +1,29 @@ +import { Color } from '../math/Color.js'; + +class Fog { + constructor(color, near = 1, far = 1000) { + this.name = ''; + + this.color = new Color(color); + + this.near = near; + this.far = far; + } + + clone() { + return new Fog(this.color, this.near, this.far); + } + + toJSON(/* meta */) { + return { + type: 'Fog', + color: this.color.getHex(), + near: this.near, + far: this.far, + }; + } +} + +Fog.prototype.isFog = true; + +export { Fog }; diff --git a/backend/libs/three/scenes/FogExp2.d.ts b/backend/libs/three/scenes/FogExp2.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..e46dd98102df7cdbcf25dc976d788855d0ac0d3b --- /dev/null +++ b/backend/libs/three/scenes/FogExp2.d.ts @@ -0,0 +1,26 @@ +import { Color } from './../math/Color'; +import { FogBase } from './Fog'; +/** + * This class contains the parameters that define linear fog, i.e., that grows exponentially denser with the distance. + */ +export class FogExp2 implements FogBase { + constructor(hex: number | string, density?: number); + + /** + * @default '' + */ + name: string; + + color: Color; + + /** + * Defines how fast the fog will grow dense. + * @default 0.00025 + */ + density: number; + + readonly isFogExp2: true; + + clone(): FogExp2; + toJSON(): any; +} diff --git a/backend/libs/three/scenes/FogExp2.js b/backend/libs/three/scenes/FogExp2.js new file mode 100644 index 0000000000000000000000000000000000000000..044138c450d64ecf888c09ca2a48311f2ca50af2 --- /dev/null +++ b/backend/libs/three/scenes/FogExp2.js @@ -0,0 +1,26 @@ +import { Color } from '../math/Color.js'; + +class FogExp2 { + constructor(color, density = 0.00025) { + this.name = ''; + + this.color = new Color(color); + this.density = density; + } + + clone() { + return new FogExp2(this.color, this.density); + } + + toJSON(/* meta */) { + return { + type: 'FogExp2', + color: this.color.getHex(), + density: this.density, + }; + } +} + +FogExp2.prototype.isFogExp2 = true; + +export { FogExp2 }; diff --git a/backend/libs/three/scenes/Scene.d.ts b/backend/libs/three/scenes/Scene.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c77ac62d479f728a0e1c86f040a4dca0419968d9 --- /dev/null +++ b/backend/libs/three/scenes/Scene.d.ts @@ -0,0 +1,49 @@ +import { FogBase } from './Fog'; +import { Material } from './../materials/Material'; +import { Object3D } from './../core/Object3D'; +import { Color } from '../math/Color'; +import { Texture } from '../textures/Texture'; +import { WebGLRenderer } from '../renderers/WebGLRenderer'; +import { Camera } from '../cameras/Camera'; + +// Scenes ///////////////////////////////////////////////////////////////////// + +/** + * Scenes allow you to set up what and where is to be rendered by three.js. This is where you place objects, lights and cameras. + */ +export class Scene extends Object3D { + constructor(); + + type: 'Scene'; + + /** + * A fog instance defining the type of fog that affects everything rendered in the scene. Default is null. + * @default null + */ + fog: FogBase | null; + + /** + * If not null, it will force everything in the scene to be rendered with that material. Default is null. + * @default null + */ + overrideMaterial: Material | null; + + /** + * @default true + */ + autoUpdate: boolean; + + /** + * @default null + */ + background: null | Color | Texture; + + /** + * @default null + */ + environment: null | Texture; + + readonly isScene: true; + + toJSON(meta?: any): any; +} diff --git a/backend/libs/three/scenes/Scene.js b/backend/libs/three/scenes/Scene.js new file mode 100644 index 0000000000000000000000000000000000000000..fb9f161c6da11fcb67eb4754a7aef34098a262c7 --- /dev/null +++ b/backend/libs/three/scenes/Scene.js @@ -0,0 +1,48 @@ +import { Object3D } from '../core/Object3D.js'; + +class Scene extends Object3D { + constructor() { + super(); + + this.type = 'Scene'; + + this.background = null; + this.environment = null; + this.fog = null; + + this.overrideMaterial = null; + + this.autoUpdate = true; // checked by the renderer + + if (typeof __THREE_DEVTOOLS__ !== 'undefined') { + __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', { detail: this })); + } + } + + copy(source, recursive) { + super.copy(source, recursive); + + if (source.background !== null) this.background = source.background.clone(); + if (source.environment !== null) this.environment = source.environment.clone(); + if (source.fog !== null) this.fog = source.fog.clone(); + + if (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone(); + + this.autoUpdate = source.autoUpdate; + this.matrixAutoUpdate = source.matrixAutoUpdate; + + return this; + } + + toJSON(meta) { + const data = super.toJSON(meta); + + if (this.fog !== null) data.object.fog = this.fog.toJSON(); + + return data; + } +} + +Scene.prototype.isScene = true; + +export { Scene }; diff --git a/backend/libs/three/textures/CanvasTexture.d.ts b/backend/libs/three/textures/CanvasTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..00156a8ec52472d915b396444c5c67a030762185 --- /dev/null +++ b/backend/libs/three/textures/CanvasTexture.d.ts @@ -0,0 +1,30 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType } from '../constants'; + +export class CanvasTexture extends Texture { + /** + * @param canvas + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.LinearFilter] + * @param [minFilter=THREE.LinearMipmapLinearFilter] + * @param [anisotropy=1] + * @param [encoding=THREE.LinearEncoding] + */ + constructor( + canvas: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + + readonly isCanvasTexture: true; +} diff --git a/backend/libs/three/textures/CanvasTexture.js b/backend/libs/three/textures/CanvasTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..bfef8087ad144bec12f21d3bf69167f012963d45 --- /dev/null +++ b/backend/libs/three/textures/CanvasTexture.js @@ -0,0 +1,13 @@ +import { Texture } from './Texture.js'; + +class CanvasTexture extends Texture { + constructor(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) { + super(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy); + + this.needsUpdate = true; + } +} + +CanvasTexture.prototype.isCanvasTexture = true; + +export { CanvasTexture }; diff --git a/backend/libs/three/textures/CompressedTexture.d.ts b/backend/libs/three/textures/CompressedTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..fd77a2eb77556294a3b92582230e309ec328c5b0 --- /dev/null +++ b/backend/libs/three/textures/CompressedTexture.d.ts @@ -0,0 +1,50 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, CompressedPixelFormat, TextureDataType, TextureEncoding } from '../constants'; + +export class CompressedTexture extends Texture { + /** + * @param mipmaps + * @param width + * @param height + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.LinearFilter] + * @param [minFilter=THREE.LinearMipmapLinearFilter] + * @param [anisotropy=1] + * @param [encoding=THREE.LinearEncoding] + */ + constructor( + mipmaps: ImageData[], + width: number, + height: number, + format?: CompressedPixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number, + encoding?: TextureEncoding + ); + + get image(): { width: number; height: number }; + set image(value: { width: number; height: number }); + + mipmaps: ImageData[]; + + /** + * @default false + */ + flipY: boolean; + + /** + * @default false + */ + generateMipmaps: boolean; + + readonly isCompressedTexture: true; +} diff --git a/backend/libs/three/textures/CompressedTexture.js b/backend/libs/three/textures/CompressedTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..1334f97dfcc5ab3a38be11bb77cdaf83411ff7d7 --- /dev/null +++ b/backend/libs/three/textures/CompressedTexture.js @@ -0,0 +1,24 @@ +import { Texture } from './Texture.js'; + +class CompressedTexture extends Texture { + constructor(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) { + super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding); + + this.image = { width: width, height: height }; + this.mipmaps = mipmaps; + + // no flipping for cube textures + // (also flipping doesn't work for compressed textures ) + + this.flipY = false; + + // can't generate mipmaps for compressed textures + // mips must be embedded in DDS files + + this.generateMipmaps = false; + } +} + +CompressedTexture.prototype.isCompressedTexture = true; + +export { CompressedTexture }; diff --git a/backend/libs/three/textures/CubeTexture.d.ts b/backend/libs/three/textures/CubeTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..b279885ae7e009e3ac31ae9c580e20e1765cb3b4 --- /dev/null +++ b/backend/libs/three/textures/CubeTexture.d.ts @@ -0,0 +1,38 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType, TextureEncoding } from '../constants'; + +export class CubeTexture extends Texture { + /** + * @param [images=[]] + * @param [mapping=THREE.CubeReflectionMapping] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.LinearFilter] + * @param [minFilter=THREE.LinearMipmapLinearFilter] + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [anisotropy=1] + * @param [encoding=THREE.LinearEncoding] + */ + constructor( + images?: any[], // HTMLImageElement or HTMLCanvasElement + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number, + encoding?: TextureEncoding + ); + + images: any; // returns and sets the value of Texture.image in the codde ? + + /** + * @default false + */ + flipY: boolean; + + readonly isCubeTexture: true; +} diff --git a/backend/libs/three/textures/CubeTexture.js b/backend/libs/three/textures/CubeTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..c1ea5a1e81d26547152dc931e6e6eebbd8c15593 --- /dev/null +++ b/backend/libs/three/textures/CubeTexture.js @@ -0,0 +1,25 @@ +import { Texture } from './Texture.js'; +import { CubeReflectionMapping } from '../constants.js'; + +class CubeTexture extends Texture { + constructor(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) { + images = images !== undefined ? images : []; + mapping = mapping !== undefined ? mapping : CubeReflectionMapping; + + super(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding); + + this.flipY = false; + } + + get images() { + return this.image; + } + + set images(value) { + this.image = value; + } +} + +CubeTexture.prototype.isCubeTexture = true; + +export { CubeTexture }; diff --git a/backend/libs/three/textures/Data3DTexture.d.ts b/backend/libs/three/textures/Data3DTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..6258c9d1882942016298f0db86333a7dcee6d6be --- /dev/null +++ b/backend/libs/three/textures/Data3DTexture.d.ts @@ -0,0 +1,33 @@ +import { Texture } from './Texture'; +import { TextureFilter } from '../constants'; + +export class Data3DTexture extends Texture { + constructor(data: BufferSource, width: number, height: number, depth: number); + + /** + * @default THREE.NearestFilter + */ + magFilter: TextureFilter; + + /** + * @default THREE.NearestFilter + */ + minFilter: TextureFilter; + + /** + * @default THREE.ClampToEdgeWrapping + */ + wrapR: boolean; + + /** + * @default false + */ + flipY: boolean; + + /** + * @default false + */ + generateMipmaps: boolean; + + readonly isData3DTexture: true; +} diff --git a/backend/libs/three/textures/DataArrayTexture.d.ts b/backend/libs/three/textures/DataArrayTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..358f0c2a7d3144a6ec1f0b4373e111f00b5191a7 --- /dev/null +++ b/backend/libs/three/textures/DataArrayTexture.d.ts @@ -0,0 +1,33 @@ +import { Texture } from './Texture'; +import { TextureFilter } from '../constants'; + +export class DataArrayTexture extends Texture { + constructor(data?: BufferSource, width?: number, height?: number, depth?: number); + + /** + * @default THREE.NearestFilter + */ + magFilter: TextureFilter; + + /** + * @default THREE.NearestFilter + */ + minFilter: TextureFilter; + + /** + * @default THREE.ClampToEdgeWrapping + */ + wrapR: boolean; + + /** + * @default false + */ + flipY: boolean; + + /** + * @default false + */ + generateMipmaps: boolean; + + readonly isDataArrayTexture: true; +} diff --git a/backend/libs/three/textures/DataTexture.d.ts b/backend/libs/three/textures/DataTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..63786e1ab94b772dcae6aee674e8e113fa901733 --- /dev/null +++ b/backend/libs/three/textures/DataTexture.d.ts @@ -0,0 +1,58 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType, TextureEncoding } from '../constants'; + +export class DataTexture extends Texture { + /** + * @param data + * @param width + * @param height + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.NearestFilter] + * @param [minFilter=THREE.NearestFilter] + * @param [anisotropy=1] + * @param [encoding=THREE.LinearEncoding] + */ + constructor( + data?: BufferSource | null, + width?: number, + height?: number, + format?: PixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number, + encoding?: TextureEncoding + ); + + get image(): ImageData; + set image(value: ImageData); + + /** + * @default false + */ + flipY: boolean; + + /** + * @default false + */ + generateMipmaps: boolean; + + /** + * @default 1 + */ + unpackAlignment: number; + + /** + * @default THREE.DepthFormat + */ + format: PixelFormat; + + readonly isDataTexture: true; +} diff --git a/backend/libs/three/textures/DataTexture.js b/backend/libs/three/textures/DataTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..665b8934485559087fef37c578651f9c9fd8f3f4 --- /dev/null +++ b/backend/libs/three/textures/DataTexture.js @@ -0,0 +1,34 @@ +import { Texture } from './Texture.js'; +import { NearestFilter } from '../constants.js'; + +class DataTexture extends Texture { + constructor( + data = null, + width = 1, + height = 1, + format, + type, + mapping, + wrapS, + wrapT, + magFilter = NearestFilter, + minFilter = NearestFilter, + anisotropy, + encoding + ) { + super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding); + + this.image = { data: data, width: width, height: height }; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + } +} + +DataTexture.prototype.isDataTexture = true; + +export { DataTexture }; diff --git a/backend/libs/three/textures/DataTexture2DArray.d.ts b/backend/libs/three/textures/DataTexture2DArray.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..58fd5da34a32c25ecc70df9b83bd1a353fe16afb --- /dev/null +++ b/backend/libs/three/textures/DataTexture2DArray.d.ts @@ -0,0 +1,6 @@ +import { DataArrayTexture } from './DataArrayTexture'; + +/** + * @deprecated THREE.DataTexture2DArray has been renamed to DataArrayTexture. + */ +export class DataTexture2DArray extends DataArrayTexture {} diff --git a/backend/libs/three/textures/DataTexture2DArray.js b/backend/libs/three/textures/DataTexture2DArray.js new file mode 100644 index 0000000000000000000000000000000000000000..d9d3ee31a71b2030e0783b339d48aa63a0156dd9 --- /dev/null +++ b/backend/libs/three/textures/DataTexture2DArray.js @@ -0,0 +1,23 @@ +import { Texture } from './Texture.js'; +import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; + +class DataTexture2DArray extends Texture { + constructor(data = null, width = 1, height = 1, depth = 1) { + super(null); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + } +} + +DataTexture2DArray.prototype.isDataTexture2DArray = true; + +export { DataTexture2DArray }; diff --git a/backend/libs/three/textures/DataTexture3D.d.ts b/backend/libs/three/textures/DataTexture3D.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0c3bb918c1cc16b3b137b6bc8d63b6a00ee20f97 --- /dev/null +++ b/backend/libs/three/textures/DataTexture3D.d.ts @@ -0,0 +1,6 @@ +import { Data3DTexture } from './Data3DTexture'; + +/** + * @deprecated THREE.DataTexture3D has been renamed to Data3DTexture. + */ +export class DataTexture3D extends Data3DTexture {} diff --git a/backend/libs/three/textures/DataTexture3D.js b/backend/libs/three/textures/DataTexture3D.js new file mode 100644 index 0000000000000000000000000000000000000000..48c8db1993e018e708d605893d88e34358976861 --- /dev/null +++ b/backend/libs/three/textures/DataTexture3D.js @@ -0,0 +1,31 @@ +import { Texture } from './Texture.js'; +import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; + +class DataTexture3D extends Texture { + constructor(data = null, width = 1, height = 1, depth = 1) { + // We're going to add .setXXX() methods for setting properties later. + // Users can still set in DataTexture3D directly. + // + // const texture = new THREE.DataTexture3D( data, width, height, depth ); + // texture.anisotropy = 16; + // + // See #14839 + + super(null); + + this.image = { data, width, height, depth }; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.wrapR = ClampToEdgeWrapping; + + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; + } +} + +DataTexture3D.prototype.isDataTexture3D = true; + +export { DataTexture3D }; diff --git a/backend/libs/three/textures/DepthTexture.d.ts b/backend/libs/three/textures/DepthTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..3a1034e118d29f242beecb9b62504231d38f73bc --- /dev/null +++ b/backend/libs/three/textures/DepthTexture.d.ts @@ -0,0 +1,42 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, TextureDataType } from '../constants'; + +export class DepthTexture extends Texture { + /** + * @param width + * @param height + * @param type + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.NearestFilter] + * @param [minFilter=THREE.NearestFilter] + * @param [anisotropy=1] + */ + constructor( + width: number, + height: number, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number + ); + + get image(): { width: number; height: number }; + set image(value: { width: number; height: number }); + + /** + * @default false + */ + flipY: boolean; + + /** + * @default false + */ + generateMipmaps: boolean; + + readonly isDepthTexture: true; +} diff --git a/backend/libs/three/textures/DepthTexture.js b/backend/libs/three/textures/DepthTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..fd24a6f52751af7aa398084478ab810ccbfd6b0c --- /dev/null +++ b/backend/libs/three/textures/DepthTexture.js @@ -0,0 +1,29 @@ +import { Texture } from './Texture.js'; +import { NearestFilter, UnsignedShortType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js'; + +class DepthTexture extends Texture { + constructor(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) { + format = format !== undefined ? format : DepthFormat; + + if (format !== DepthFormat && format !== DepthStencilFormat) { + throw new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat'); + } + + if (type === undefined && format === DepthFormat) type = UnsignedShortType; + if (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type; + + super(null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy); + + this.image = { width: width, height: height }; + + this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; + + this.flipY = false; + this.generateMipmaps = false; + } +} + +DepthTexture.prototype.isDepthTexture = true; + +export { DepthTexture }; diff --git a/backend/libs/three/textures/FramebufferTexture.d.ts b/backend/libs/three/textures/FramebufferTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c0cb8b4f2e6b0d105d9f483032de872707916958 --- /dev/null +++ b/backend/libs/three/textures/FramebufferTexture.d.ts @@ -0,0 +1,8 @@ +import { Texture } from './Texture'; +import { PixelFormat } from '../constants'; + +export class FramebufferTexture extends Texture { + readonly isFramebufferTexture: true; + + constructor(width: number, height: number, format: PixelFormat); +} diff --git a/backend/libs/three/textures/FramebufferTexture.js b/backend/libs/three/textures/FramebufferTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..8acac233ec447221e1ef0f463acd020dfbf124a7 --- /dev/null +++ b/backend/libs/three/textures/FramebufferTexture.js @@ -0,0 +1,21 @@ +import { Texture } from './Texture.js'; +import { NearestFilter } from '../constants.js'; + +class FramebufferTexture extends Texture { + constructor(width, height, format) { + super({ width, height }); + + this.format = format; + + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; + + this.generateMipmaps = false; + + this.needsUpdate = true; + } +} + +FramebufferTexture.prototype.isFramebufferTexture = true; + +export { FramebufferTexture }; diff --git a/backend/libs/three/textures/Source.d.ts b/backend/libs/three/textures/Source.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..d110817c889ac2eba240fe6f0c10f9212bb35b48 --- /dev/null +++ b/backend/libs/three/textures/Source.d.ts @@ -0,0 +1,39 @@ +/** + * Represents the data source of a texture. + */ +export class Source { + /** + * @param [data] The data definition of a texture. default is **null**. + */ + constructor(data: any); + + /** + * The actual data of a texture. The type of this property depends on the texture that uses this instance. + */ + data: any; + + /** + * Set this to **true** to trigger a data upload to the GPU next time the source is used. + */ + set needsUpdate(value: boolean); + + /** + * [UUID](http://en.wikipedia.org/wiki/Universally_unique_identifier) of this object instance. + * This gets automatically assigned, so this shouldn't be edited. + */ + uuid: string; + + /** + * This starts at **0** and counts how many times [property:Boolean needsUpdate] is set to **true**. + */ + version: number; + + /** + * Convert the data source to three.js [JSON Object/Scene format](https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4). + * + * @param [meta] optional object containing metadata. + */ + toJSON(meta: any): any; + + readonly isTexture: true; +} diff --git a/backend/libs/three/textures/Texture.d.ts b/backend/libs/three/textures/Texture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..c993df625923ad9a210c2ec5330f0fcac527d006 --- /dev/null +++ b/backend/libs/three/textures/Texture.d.ts @@ -0,0 +1,203 @@ +import { Vector2 } from './../math/Vector2'; +import { Matrix3 } from './../math/Matrix3'; +import { Source } from './Source'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { Mapping, Wrapping, TextureFilter, PixelFormat, PixelFormatGPU, TextureDataType, TextureEncoding } from '../constants'; + +export class Texture extends EventDispatcher { + /** + * @param [image] + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.LinearFilter] + * @param [minFilter=THREE.LinearMipmapLinearFilter] + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [anisotropy=1] + * @param [encoding=THREE.LinearEncoding] + */ + constructor( + image?: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number, + encoding?: TextureEncoding + ); + + id: number; + uuid: string; + + /** + * @default '' + */ + name: string; + sourceFile: string; + + /** + * The data definition of a texture. A reference to the data source can be shared across textures. + * This is often useful in context of spritesheets where multiple textures render the same data but with different texture transformations. + */ + source: Source; + + /** + * An image object, typically created using the {@link TextureLoader.load} method. + * This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by three.js. + * + * To use video as a texture you need to have a playing HTML5 + * video element as a source for your texture image and continuously update this texture + * as long as video is playing - the {@link VideoTexture} class handles this automatically. + */ + get image(): any; + + /** + * An image object, typically created using the {@link TextureLoader.load} method. + * This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by three.js. + * + * To use video as a texture you need to have a playing HTML5 + * video element as a source for your texture image and continuously update this texture + * as long as video is playing - the {@link VideoTexture} class handles this automatically. + */ + set image(data: any); + + /** + * @default [] + */ + mipmaps: any[]; // ImageData[] for 2D textures and CubeTexture[] for cube textures; + + /** + * @default THREE.Texture.DEFAULT_MAPPING + */ + mapping: Mapping; + + /** + * @default THREE.ClampToEdgeWrapping + */ + wrapS: Wrapping; + + /** + * @default THREE.ClampToEdgeWrapping + */ + wrapT: Wrapping; + + /** + * @default THREE.LinearFilter + */ + magFilter: TextureFilter; + + /** + * @default THREE.LinearMipmapLinearFilter + */ + minFilter: TextureFilter; + + /** + * @default 1 + */ + anisotropy: number; + + /** + * @default THREE.RGBAFormat + */ + format: PixelFormat; + + internalFormat: PixelFormatGPU | null; + + /** + * @default THREE.UnsignedByteType + */ + type: TextureDataType; + + /** + * @default new THREE.Matrix3() + */ + matrix: Matrix3; + + /** + * @default true + */ + matrixAutoUpdate: boolean; + + /** + * @default new THREE.Vector2( 0, 0 ) + */ + offset: Vector2; + + /** + * @default new THREE.Vector2( 1, 1 ) + */ + repeat: Vector2; + + /** + * @default new THREE.Vector2( 0, 0 ) + */ + center: Vector2; + + /** + * @default 0 + */ + rotation: number; + + /** + * @default true + */ + generateMipmaps: boolean; + + /** + * @default false + */ + premultiplyAlpha: boolean; + + /** + * @default true + */ + flipY: boolean; + + /** + * @default 4 + */ + unpackAlignment: number; + + /** + * @default THREE.LinearEncoding + */ + encoding: TextureEncoding; + + /** + * @default false + */ + isRenderTargetTexture: boolean; + + /** + * @default false + */ + needsPMREMUpdate: boolean; + + /** + * An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned. + * @default {} + */ + userData: any; + + /** + * @default 0 + */ + version: number; + set needsUpdate(value: boolean); + readonly isTexture: true; + + onUpdate: () => void; + static DEFAULT_IMAGE: any; + static DEFAULT_MAPPING: any; + + clone(): this; + copy(source: Texture): this; + toJSON(meta: any): any; + dispose(): void; + transformUv(uv: Vector2): Vector2; + updateMatrix(): void; +} diff --git a/backend/libs/three/textures/Texture.js b/backend/libs/three/textures/Texture.js new file mode 100644 index 0000000000000000000000000000000000000000..3156f3b97d0f44a0cc02e0f7d69f35deb959c0ca --- /dev/null +++ b/backend/libs/three/textures/Texture.js @@ -0,0 +1,317 @@ +import { EventDispatcher } from '../core/EventDispatcher.js'; +import { + MirroredRepeatWrapping, + ClampToEdgeWrapping, + RepeatWrapping, + LinearEncoding, + UnsignedByteType, + RGBAFormat, + LinearMipmapLinearFilter, + LinearFilter, + UVMapping, +} from '../constants.js'; +import * as MathUtils from '../math/MathUtils.js'; +import { Vector2 } from '../math/Vector2.js'; +import { Matrix3 } from '../math/Matrix3.js'; +import { ImageUtils } from '../extras/ImageUtils.js'; + +let textureId = 0; + +class Texture extends EventDispatcher { + constructor( + image = Texture.DEFAULT_IMAGE, + mapping = Texture.DEFAULT_MAPPING, + wrapS = ClampToEdgeWrapping, + wrapT = ClampToEdgeWrapping, + magFilter = LinearFilter, + minFilter = LinearMipmapLinearFilter, + format = RGBAFormat, + type = UnsignedByteType, + anisotropy = 1, + encoding = LinearEncoding + ) { + super(); + + Object.defineProperty(this, 'id', { value: textureId++ }); + + this.uuid = MathUtils.generateUUID(); + + this.name = ''; + + this.image = image; + this.mipmaps = []; + + this.mapping = mapping; + + this.wrapS = wrapS; + this.wrapT = wrapT; + + this.magFilter = magFilter; + this.minFilter = minFilter; + + this.anisotropy = anisotropy; + + this.format = format; + this.internalFormat = null; + this.type = type; + + this.offset = new Vector2(0, 0); + this.repeat = new Vector2(1, 1); + this.center = new Vector2(0, 0); + this.rotation = 0; + + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); + + this.generateMipmaps = true; + this.premultiplyAlpha = false; + this.flipY = true; + this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) + + // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. + // + // Also changing the encoding after already used by a Material will not automatically make the Material + // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. + this.encoding = encoding; + + this.userData = {}; + + this.version = 0; + this.onUpdate = null; + + this.isRenderTargetTexture = false; // indicates whether a texture belongs to a render target or not + this.needsPMREMUpdate = false; // indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target textures) + } + + updateMatrix() { + this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); + } + + clone() { + return new this.constructor().copy(this); + } + + copy(source) { + this.name = source.name; + + this.image = source.image; + this.mipmaps = source.mipmaps.slice(0); + + this.mapping = source.mapping; + + this.wrapS = source.wrapS; + this.wrapT = source.wrapT; + + this.magFilter = source.magFilter; + this.minFilter = source.minFilter; + + this.anisotropy = source.anisotropy; + + this.format = source.format; + this.internalFormat = source.internalFormat; + this.type = source.type; + + this.offset.copy(source.offset); + this.repeat.copy(source.repeat); + this.center.copy(source.center); + this.rotation = source.rotation; + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrix.copy(source.matrix); + + this.generateMipmaps = source.generateMipmaps; + this.premultiplyAlpha = source.premultiplyAlpha; + this.flipY = source.flipY; + this.unpackAlignment = source.unpackAlignment; + this.encoding = source.encoding; + + this.userData = JSON.parse(JSON.stringify(source.userData)); + + return this; + } + + toJSON(meta) { + const isRootObject = meta === undefined || typeof meta === 'string'; + + if (!isRootObject && meta.textures[this.uuid] !== undefined) { + return meta.textures[this.uuid]; + } + + const output = { + metadata: { + version: 4.5, + type: 'Texture', + generator: 'Texture.toJSON', + }, + + uuid: this.uuid, + name: this.name, + + mapping: this.mapping, + + repeat: [this.repeat.x, this.repeat.y], + offset: [this.offset.x, this.offset.y], + center: [this.center.x, this.center.y], + rotation: this.rotation, + + wrap: [this.wrapS, this.wrapT], + + format: this.format, + type: this.type, + encoding: this.encoding, + + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, + + flipY: this.flipY, + + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment, + }; + + if (this.image !== undefined) { + // TODO: Move to THREE.Image + + const image = this.image; + + if (image.uuid === undefined) { + image.uuid = MathUtils.generateUUID(); // UGH + } + + if (!isRootObject && meta.images[image.uuid] === undefined) { + let url; + + if (Array.isArray(image)) { + // process array of images e.g. CubeTexture + + url = []; + + for (let i = 0, l = image.length; i < l; i++) { + // check cube texture with data textures + + if (image[i].isDataTexture) { + url.push(serializeImage(image[i].image)); + } else { + url.push(serializeImage(image[i])); + } + } + } else { + // process single image + + url = serializeImage(image); + } + + meta.images[image.uuid] = { + uuid: image.uuid, + url: url, + }; + } + + output.image = image.uuid; + } + + if (JSON.stringify(this.userData) !== '{}') output.userData = this.userData; + + if (!isRootObject) { + meta.textures[this.uuid] = output; + } + + return output; + } + + dispose() { + this.dispatchEvent({ type: 'dispose' }); + } + + transformUv(uv) { + if (this.mapping !== UVMapping) return uv; + + uv.applyMatrix3(this.matrix); + + if (uv.x < 0 || uv.x > 1) { + switch (this.wrapS) { + case RepeatWrapping: + uv.x = uv.x - Math.floor(uv.x); + break; + + case ClampToEdgeWrapping: + uv.x = uv.x < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + if (Math.abs(Math.floor(uv.x) % 2) === 1) { + uv.x = Math.ceil(uv.x) - uv.x; + } else { + uv.x = uv.x - Math.floor(uv.x); + } + + break; + } + } + + if (uv.y < 0 || uv.y > 1) { + switch (this.wrapT) { + case RepeatWrapping: + uv.y = uv.y - Math.floor(uv.y); + break; + + case ClampToEdgeWrapping: + uv.y = uv.y < 0 ? 0 : 1; + break; + + case MirroredRepeatWrapping: + if (Math.abs(Math.floor(uv.y) % 2) === 1) { + uv.y = Math.ceil(uv.y) - uv.y; + } else { + uv.y = uv.y - Math.floor(uv.y); + } + + break; + } + } + + if (this.flipY) { + uv.y = 1 - uv.y; + } + + return uv; + } + + set needsUpdate(value) { + if (value === true) this.version++; + } +} + +Texture.DEFAULT_IMAGE = undefined; +Texture.DEFAULT_MAPPING = UVMapping; + +Texture.prototype.isTexture = true; + +function serializeImage(image) { + if ( + (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement) || + (typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement) || + (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) + ) { + // default images + + return ImageUtils.getDataURL(image); + } else { + if (image.data) { + // images of DataTexture + + return { + data: Array.prototype.slice.call(image.data), + width: image.width, + height: image.height, + type: image.data.constructor.name, + }; + } else { + console.warn('THREE.Texture: Unable to serialize Texture.'); + return {}; + } + } +} + +export { Texture }; diff --git a/backend/libs/three/textures/VideoTexture.d.ts b/backend/libs/three/textures/VideoTexture.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..22a74a5d8044cd9682632bf0ac3fb50bc94b34ad --- /dev/null +++ b/backend/libs/three/textures/VideoTexture.d.ts @@ -0,0 +1,34 @@ +import { Texture } from './Texture'; +import { Mapping, Wrapping, TextureFilter, PixelFormat, TextureDataType } from '../constants'; + +export class VideoTexture extends Texture { + /** + * @param video + * @param [mapping=THREE.Texture.DEFAULT_MAPPING] + * @param [wrapS=THREE.ClampToEdgeWrapping] + * @param [wrapT=THREE.ClampToEdgeWrapping] + * @param [magFilter=THREE.LinearFilter] + * @param [minFilter=THREE.LinearFilter] + * @param [format=THREE.RGBAFormat] + * @param [type=THREE.UnsignedByteType] + * @param [anisotropy=1] + */ + constructor( + video: HTMLVideoElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); + + readonly isVideoTexture: true; + + /** + * @default false + */ + generateMipmaps: boolean; +} diff --git a/backend/libs/three/textures/VideoTexture.js b/backend/libs/three/textures/VideoTexture.js new file mode 100644 index 0000000000000000000000000000000000000000..db026cc449e3b56142803a3fcb16e0f82ee9ba80 --- /dev/null +++ b/backend/libs/three/textures/VideoTexture.js @@ -0,0 +1,41 @@ +import { LinearFilter } from '../constants.js'; +import { Texture } from './Texture.js'; + +class VideoTexture extends Texture { + constructor(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) { + super(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy); + + this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + + this.generateMipmaps = false; + + const scope = this; + + function updateVideo() { + scope.needsUpdate = true; + video.requestVideoFrameCallback(updateVideo); + } + + if ('requestVideoFrameCallback' in video) { + video.requestVideoFrameCallback(updateVideo); + } + } + + clone() { + return new this.constructor(this.image).copy(this); + } + + update() { + const video = this.image; + const hasVideoFrameCallback = 'requestVideoFrameCallback' in video; + + if (hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA) { + this.needsUpdate = true; + } + } +} + +VideoTexture.prototype.isVideoTexture = true; + +export { VideoTexture }; diff --git a/backend/libs/three/utils.d.ts b/backend/libs/three/utils.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..16c1d366a4c4cb4a2d18a3780a3f3367f4267676 --- /dev/null +++ b/backend/libs/three/utils.d.ts @@ -0,0 +1,3 @@ +import { Color } from './math/Color'; + +export type ColorRepresentation = Color | string | number; diff --git a/backend/libs/three/utils.js b/backend/libs/three/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..d2c9feff2ca5710f8acc3a69b5e04b43941df706 --- /dev/null +++ b/backend/libs/three/utils.js @@ -0,0 +1,45 @@ +function arrayMin(array) { + if (array.length === 0) return Infinity; + + let min = array[0]; + + for (let i = 1, l = array.length; i < l; ++i) { + if (array[i] < min) min = array[i]; + } + + return min; +} + +function arrayMax(array) { + if (array.length === 0) return -Infinity; + + let max = array[0]; + + for (let i = 1, l = array.length; i < l; ++i) { + if (array[i] > max) max = array[i]; + } + + return max; +} + +const TYPED_ARRAYS = { + Int8Array: Int8Array, + Uint8Array: Uint8Array, + Uint8ClampedArray: Uint8ClampedArray, + Int16Array: Int16Array, + Uint16Array: Uint16Array, + Int32Array: Int32Array, + Uint32Array: Uint32Array, + Float32Array: Float32Array, + Float64Array: Float64Array, +}; + +function getTypedArray(type, buffer) { + return new TYPED_ARRAYS[type](buffer); +} + +function createElementNS(name) { + return document.createElementNS('http://www.w3.org/1999/xhtml', name); +} + +export { arrayMin, arrayMax, getTypedArray, createElementNS }; diff --git a/backend/libs/util.ts b/backend/libs/util.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c4f2eeb5c7a4412152aa66e6b5b36de258a3361 --- /dev/null +++ b/backend/libs/util.ts @@ -0,0 +1,212 @@ +import SparkMD5 from 'spark-md5'; +//import JSZip from 'jszip'; +import * as starry from '../../src/starry'; +//import { encodeFindResource } from '../../src/isomorphic/converter'; +import sharp, { FormatEnum } from 'sharp'; +import got from 'got'; +//import { Logger } from './ZeroClient'; +import type { SolutionStore, SaveIssueMeasure } from './store'; +import { ScoreJSON } from '../../src/isomorphic/types'; + +const SYSTEM_MARGIN = 4; + +export const constructSystem = ({ page, backgroundImage, detection, imageSize, position }) => { + const systemWidth = (detection.phi2 - detection.phi1) / detection.interval; + const systemHeight = imageSize.height / detection.interval; + + const lastSystem = page.systems[page.systems.length - 1]; + const top = position ? position.y : (lastSystem ? lastSystem.top + lastSystem.height : 0) + SYSTEM_MARGIN; + const left = position ? position.x : SYSTEM_MARGIN; + + const stavesTops = [ + 0, + ...Array(detection.middleRhos.length - 1) + .fill(0) + .map((_, i) => (detection.middleRhos[i] + detection.middleRhos[i + 1]) / 2 / detection.interval), + ]; + + const measureBars = [systemWidth]; + + const staves = stavesTops.map( + (top, i) => + new starry.Staff({ + top, + height: (stavesTops[i + 1] || systemHeight) - top, + staffY: detection.middleRhos[i] / detection.interval - top, + measureBars, + }) + ); + + //console.log("detection:", detection, options, stavesTops); + + const imagePosition = { + x: -detection.phi1 / detection.interval, + y: 0, + width: imageSize.width / detection.interval, + height: imageSize.height / detection.interval, + }; + + return new starry.System({ + staves, + left, + top, + width: systemWidth, + backgroundImage, + imagePosition, + measureBars, + }); +}; + +export interface ConvertOption { + format?: keyof FormatEnum; + quality?: number; + maxHeight?: number; +} + +const toBuffer = async (url: string | Buffer): Promise => { + if (typeof url === 'string') { + if (/^https?:\/\//.test(url)) { + return (await got(url, { responseType: 'buffer', decompress: true, https: { rejectUnauthorized: false } })).body; + } + + if (/^data:image\//.test(url)) { + return Buffer.from(url.split(',')[1], 'base64'); + } + + return Buffer.from(url); + } + + return url; +}; + +/** + * 转换图片格式,默认webp、最大高度1080,高度小于1080自动不做尺寸变换 + * @param url + * @param format + * @param maxHeight + * @param quality + */ +export async function convertImage(url: string | Buffer, { format = 'webp', maxHeight = 1080, quality = 80 }: ConvertOption = {}) { + let buf = await toBuffer(url); + + const webpBuffer = await new Promise((resolve) => { + sharp(buf) + .resize({ + width: maxHeight, + height: maxHeight, + fit: 'inside', + withoutEnlargement: true, + }) + .toFormat(format, { quality }) + .toBuffer((err, buf) => { + resolve(buf); + }); + }); + + const md5 = SparkMD5.ArrayBuffer.hash(webpBuffer); + + return { + buffer: webpBuffer, + filename: `${md5}.${format}`, + }; +} + +/** + * 替换scoreJson图片地址 + * @param scoreJson + * @param onReplaceImage + */ +export const replaceScoreJsonImages = (scoreJson: ScoreJSON, onReplaceImage: (src: string) => string = (src) => src) => { + const json = JSON.parse(JSON.stringify(scoreJson)); + + json.pages.forEach((page) => { + page?.src && (page.src = onReplaceImage(page?.src)); + }); + + json.lines.forEach((system) => { + system.lineStaves.forEach((line) => { + line.imgs.forEach((staff) => { + staff?.src && (staff.src = onReplaceImage(staff.src)); + }); + }); + }); + + return json; +}; + +/** + * 获取scoreJson图片资源列表 + * @param scoreJson + */ +export const getScoreJsonImages = (scoreJson: ScoreJSON) => { + return [ + ...scoreJson.pages.map((page) => page?.src), + ...scoreJson.lines + .map((system) => system.lineStaves.map((staff) => staff.imgs)) + .flat(2) + .map((staff) => staff?.src) + .filter(Boolean), + ]; +}; + +interface ScorePatchesUpdateOptions { + solutionStore?: SolutionStore; +} + +export const updateScorePatches = (score: starry.Score, measures: starry.SpartitoMeasure[], options: ScorePatchesUpdateOptions = {}): void => { + console.assert( + measures.every((measure) => measure.validRegulated), + '[updateScorePatches] some measures not valid regulated:', + measures.filter((measure) => !measure.validRegulated) + ); + + score.patches = measures.map((measure) => measure.createPatch()); + + if (options?.solutionStore) { + score.assemble(); + const spartito = score.makeSpartito(); + + measures.forEach((measure) => { + options.solutionStore!.set(measure.regulationHash, { ...measure.asSolution(), priority: 1 }); + if (measure.regulationHash0 !== measure.regulationHash) { + const originMeasure = spartito.measures.find((m) => m.measureIndex === measure.measureIndex); + options.solutionStore!.set(measure.regulationHash0, { ...measure.asSolution(originMeasure), priority: 1 }); + } + }); + } +}; + +interface EditableMeasuresSaveOptions { + status?: number; + solutionStore?: SolutionStore; +} + +export const saveEditableMeasures = async ( + score: starry.Score, + measureIndices: number[], + saveMeasure: SaveIssueMeasure, + { status = 2, solutionStore }: EditableMeasuresSaveOptions = {} +): Promise => { + score.assemble(); + const spartito = score.spartito || score.makeSpartito(); + + const measures = measureIndices + .map((index) => spartito.measures.find((measure) => measure.measureIndex === index)) + .filter(Boolean) as starry.SpartitoMeasure[]; + + if (solutionStore) { + const solutions = await solutionStore.batchGet(measures.map((measure) => measure.regulationHash0)); + measures.forEach((measure, i) => { + const solution = solutions[i]; + if (solution) measure.applySolution(solution); + }); + } + + measures.forEach((measure) => { + saveMeasure({ + measureIndex: measure.measureIndex, + measure: new starry.EditableMeasure(measure), + status, + }); + }); +}; diff --git a/backend/omr/dist/gauge-server.js b/backend/omr/dist/gauge-server.js index 04b51571336f311e216c8517dadd296997cda675..b6c06a1c58e6b30a313903febd04f3a20d825097 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-02-17T12:40:32.606Z","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-02-17T15:16:49.858Z","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/gauge-server.js.map b/backend/omr/dist/gauge-server.js.map index 711001a2b16726fcc3a6d2b3551ab9dbac04ae1d..9497cbfbb5f25899da14f68860440e1ef9a56b50 100644 --- a/backend/omr/dist/gauge-server.js.map +++ b/backend/omr/dist/gauge-server.js.map @@ -1 +1 @@ -{"version":3,"file":"gauge-server.js","sources":["../../libs/gauge-renderer.ts","../../../src/pages/playground/scripts/shaders.ts","../src/gauge-server.ts"],"sourcesContent":["/* global cv */\nimport { Canvas, Image, loadImage, ImageData } from 'skia-canvas';\n// threejs内部使用了OffscreenCanvas\n//(globalThis as any).OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas;\nglobalThis.ImageData = ImageData;\n\nimport createContext from 'gl';\n\nimport * as SHADER_SOURCE from '../../src/pages/playground/scripts/shaders';\n\n//const cc = (a: T[][]): T[] => a.flat(1);\t// This is slower!\nconst cc = (a: T[][]): T[] => {\n\tconst result: T[] = [];\n\tfor (const x of a) {\n\t\tfor (const e of x) result.push(e);\n\t}\n\n\treturn result;\n};\n\ntype RenderContext = ReturnType;\n\nclass GLCanvas {\n\tctx: RenderContext;\n\t_width: number = 256;\n\t_height: number = 192;\n\n\tresizeBuffer: number[];\n\n\tconstructor(context: RenderContext) {\n\t\tthis.ctx = context;\n\t}\n\n\tget width() {\n\t\treturn this._width;\n\t}\n\n\tset width(width: number) {\n\t\tthis._width = width;\n\t\tconst ext = this.ctx.getExtension('STACKGL_resize_drawingbuffer');\n\t\text.resize(width, this.height);\n\t}\n\n\tget height() {\n\t\treturn this._height;\n\t}\n\n\tset height(height: number) {\n\t\tthis._height = height;\n\t\tconst ext = this.ctx.getExtension('STACKGL_resize_drawingbuffer');\n\t\text.resize(this.width, height);\n\t}\n\n\t/*// @ts-ignore\n\tgetContext(type, options) {\n\t\tif (type === 'webgl') {\n\t\t\tthis.ctx = createContext(200, 300, options);\n\n\t\t\treturn this.ctx;\n\t\t}\n\n\t\treturn null as WebGLRenderingContext;\n\t}*/\n\n\taddEventListener(evt: 'webglcontextlost') {}\n\n\tasync toBuffer() {\n\t\tconst pixels = new Uint8Array(this.width * this.height * 4);\n\t\tthis.ctx.readPixels(0, 0, this.width, this.height, this.ctx.RGBA, this.ctx.UNSIGNED_BYTE, pixels);\n\n\t\tconst canvas = new Canvas(this.width, this.height);\n\t\tconst ctx = canvas.getContext('2d');\n\t\tctx.putImageData(new ImageData(new Uint8ClampedArray(pixels), this.width, this.height), 0, 0);\n\n\t\treturn canvas.toBuffer('png');\n\t}\n}\n\ninterface GaugeRendererInitOptions {\n\tsource: HTMLImageElement;\n\tgauge: HTMLImageElement;\n}\n\nconst gl = createContext(512, 192, { antialias: true });\n\nexport default class GaugeRenderer {\n\tsource: Image; // base64 string\n\tgauge: Image;\n\tcanvas: GLCanvas;\n\n\tprogram: WebGLProgram;\n\ttexture: WebGLTexture;\n\tpos: WebGLBuffer;\n\tuv: WebGLBuffer;\n\tib: WebGLBuffer;\n\tprimitiveCount: number;\n\n\twidth: number = 256;\n\theight: number = 192;\n\n\tconstructor(options: GaugeRendererInitOptions) {\n\t\tthis.source = options.source;\n\t\tthis.gauge = options.gauge;\n\t\tthis.canvas = new GLCanvas(gl);\n\n\t\tgl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);\n\t\tgl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n\n\t\tgl.getExtension('OES_element_index_uint');\n\n\t\t// initial program\n\t\tthis.program = gl.createProgram();\n\n\t\tconst vsShader = gl.createShader(gl.VERTEX_SHADER);\n\t\tgl.shaderSource(vsShader, SHADER_SOURCE.vs);\n\t\tgl.compileShader(vsShader);\n\t\tconst logVs = gl.getShaderInfoLog(vsShader);\n\t\tlogVs && console.warn('vs log:', logVs);\n\n\t\tconst fsShader = gl.createShader(gl.FRAGMENT_SHADER);\n\t\tgl.shaderSource(fsShader, SHADER_SOURCE.fs);\n\t\tgl.compileShader(fsShader);\n\t\tconst logFs = gl.getShaderInfoLog(fsShader);\n\t\tlogFs && console.warn('fs log:', logFs);\n\n\t\tgl.attachShader(this.program, vsShader);\n\t\tgl.attachShader(this.program, fsShader);\n\t\tgl.linkProgram(this.program);\n\n\t\tconst logProgram = gl.getProgramInfoLog(this.program);\n\t\tlogProgram && console.warn('program log:', logProgram);\n\n\t\tgl.deleteShader(vsShader);\n\t\tgl.deleteShader(fsShader);\n\n\t\tconst { name: nameModelView } = gl.getActiveUniform(this.program, 0);\n\t\tconst modelMat = gl.getUniformLocation(this.program, nameModelView);\n\t\tconst { name: nameProj } = gl.getActiveUniform(this.program, 1);\n\t\tconst projMat = gl.getUniformLocation(this.program, nameProj);\n\t\tconst { name: nameUV } = gl.getActiveUniform(this.program, 2);\n\t\tconst uvMat = gl.getUniformLocation(this.program, nameUV);\n\t\tconst { name: nameDiffuse } = gl.getActiveUniform(this.program, 3);\n\t\tconst diffuse = gl.getUniformLocation(this.program, nameDiffuse);\n\t\tconst { name: nameOpacity } = gl.getActiveUniform(this.program, 4);\n\t\tconst opacity = gl.getUniformLocation(this.program, nameOpacity);\n\t\tconst { name: nameMap } = gl.getActiveUniform(this.program, 5);\n\t\tconst map = gl.getUniformLocation(this.program, nameMap);\n\n\t\tgl.useProgram(this.program);\n\n\t\tgl.uniformMatrix4fv(\n\t\t\tprojMat,\n\t\t\tfalse,\n\t\t\t//new Float32Array([0.0026385225355625153, 0, 0, 0, 0, -0.010416666977107525, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t\tnew Float32Array([0.002739726100116968, 0, 0, 0, 0, 0.010416666977107525, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t);\n\t\tgl.uniformMatrix4fv(modelMat, false, new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 1]));\n\t\tgl.uniformMatrix3fv(uvMat, false, new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]));\n\t\tgl.uniform3f(diffuse, 1, 1, 1);\n\t\tgl.uniform1f(opacity, 1);\n\t\tgl.uniform1i(map, 0);\n\n\t\t// texture\n\t\tthis.texture = gl.createTexture();\n\t\tgl.activeTexture(gl.TEXTURE0);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n\t\tgl.pixelStorei(37440, true);\n\t\tgl.pixelStorei(37441, false);\n\t\tgl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n\t\tgl.pixelStorei(37443, 0);\n\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n\n\t\tgl.disable(gl.CULL_FACE);\n\t\tgl.depthMask(true);\n\t\tgl.colorMask(true, true, true, true);\n\t\tgl.disable(gl.STENCIL_TEST);\n\t\tgl.disable(gl.POLYGON_OFFSET_FILL);\n\t\tgl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE);\n\n\t\t// buffers\n\t\tthis.pos = gl.createBuffer();\n\t\tthis.uv = gl.createBuffer();\n\t\tthis.ib = gl.createBuffer();\n\n\t\tconst iPos = gl.getAttribLocation(this.program, 'position');\n\t\tconst iUV = gl.getAttribLocation(this.program, 'uv');\n\t\t//console.log('indices:', iPos, iUV);\n\n\t\tgl.enableVertexAttribArray(iPos);\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.pos);\n\t\tgl.vertexAttribPointer(iPos, 3, gl.FLOAT, false, 0, 0);\n\n\t\tgl.enableVertexAttribArray(iUV);\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.uv);\n\t\tgl.vertexAttribPointer(iUV, 2, gl.FLOAT, false, 0, 0);\n\t}\n\n\tupdateMaterial({ width = null, sw = this.width, sh = this.height } = {}) {\n\t\tif (sw !== this.width || sh !== this.height) {\n\t\t\tif (Number.isFinite(width)) {\n\t\t\t\tthis.width = width;\n\t\t\t} else {\n\t\t\t\tthis.width = Math.round((this.height * sw) / sh);\n\t\t\t}\n\n\t\t\tthis.canvas.width = this.width;\n\t\t\tthis.canvas.height = this.height;\n\n\t\t\tgl.viewport(0, 0, this.width, this.height);\n\n\t\t\tconst projMat = gl.getUniformLocation(this.program, 'projectionMatrix');\n\t\t\tgl.uniformMatrix4fv(\n\t\t\t\tprojMat,\n\t\t\t\tfalse,\n\t\t\t\tnew Float32Array([2 / this.width, 0, 0, 0, 0, 2 / this.height, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t\t);\n\t\t}\n\n\t\t// image to canvas\n\t\tconst sourceCanvas = new Canvas(this.source.width, this.source.height);\n\t\tsourceCanvas.getContext('2d').drawImage(this.source, 0, 0);\n\n\t\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, sourceCanvas as any);\n\t\tgl.generateMipmap(gl.TEXTURE_2D);\n\t}\n\n\tupdateGeometry(baseY = null) {\n\t\tconst { width, height } = this.gauge;\n\t\tconst canvas = new Canvas(width, height);\n\t\tconst ctx = canvas.getContext('2d');\n\t\tctx.drawImage(this.gauge, 0, 0);\n\t\tconst { data: buffer } = ctx.getImageData(0, 0, width, height);\n\n\t\tconst xFactor = this.width / width;\n\n\t\tbaseY = Math.round(Number.isFinite(baseY) ? baseY : height / 2);\n\t\tbaseY = Math.max(0, Math.min(height - 1, baseY));\n\n\t\tconst propertyArray = Array(height)\n\t\t\t.fill(null)\n\t\t\t.map((_, y) =>\n\t\t\t\tArray(width)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, x) => ({\n\t\t\t\t\t\tuv: [(x + 0.5) / width, 1 - (y + 0.5) / height],\n\t\t\t\t\t\tposition: [(x - width / 2) * xFactor, (buffer[(y * width + x) * 4] + buffer[(y * width + x) * 4 + 2] / 256 - 128) / xFactor, 0],\n\t\t\t\t\t}))\n\t\t\t);\n\n\t\t// integral X by K\n\t\tfor (let y = baseY; y > 0; --y) {\n\t\t\tfor (let x = 0; x < width; ++x)\n\t\t\t\tpropertyArray[y - 1][x].position[0] = propertyArray[y][x].position[0] - ((buffer[(y * width + x) * 4 + 1] - 128) * xFactor) / 127;\n\t\t}\n\t\tfor (let y = baseY + 1; y < height; ++y) {\n\t\t\tfor (let x = 0; x < width; ++x)\n\t\t\t\tpropertyArray[y][x].position[0] = propertyArray[y - 1][x].position[0] + ((buffer[((y - 1) * width + x) * 4 + 1] - 128) * xFactor) / 127;\n\t\t}\n\n\t\tconst uvs = cc(cc(propertyArray).map((p) => p.uv));\n\t\tconst positions = cc(cc(propertyArray).map((p) => p.position));\n\n\t\tconst faces = Array(height - 1)\n\t\t\t.fill(null)\n\t\t\t.map((_, y) =>\n\t\t\t\tArray(width - 1)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, x) => [y * width + x, y * width + x + 1, (y + 1) * width + x, (y + 1) * width + x, (y + 1) * width + x + 1, y * width + x + 1])\n\t\t\t);\n\t\tconst indices = cc(cc(faces));\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.pos);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.uv);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array(uvs), gl.STATIC_DRAW);\n\n\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.ib);\n\t\tgl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(indices), gl.STATIC_DRAW);\n\n\t\tthis.primitiveCount = indices.length;\n\t}\n\n\trender() {\n\t\tgl.clearColor(1, 1, 1, 1);\n\t\tgl.clear(gl.COLOR_BUFFER_BIT);\n\n\t\t//gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.ib);\n\n\t\tgl.drawElements(gl.TRIANGLES, this.primitiveCount, gl.UNSIGNED_INT, 0);\n\n\t\treturn this.canvas.toBuffer();\n\t}\n\n\tdispose() {\n\t\tgl.deleteBuffer(this.pos);\n\t\tgl.deleteBuffer(this.uv);\n\t\tgl.deleteBuffer(this.ib);\n\n\t\tgl.deleteProgram(this.program);\n\t\tgl.deleteTexture(this.texture);\n\t}\n}\n\nconst gaugeRenderer = new GaugeRenderer({\n\tsource: new Image(),\n\tgauge: new Image(),\n});\n\nexport const renderGaugeImage = async (sourceURL: string | Buffer, gaugeURL: string | Buffer, baseY?: number) => {\n\tconst source = await loadImage(sourceURL);\n\tconst gauge = await loadImage(gaugeURL);\n\n\tgaugeRenderer.source = source;\n\tgaugeRenderer.gauge = gauge;\n\n\tgaugeRenderer.updateMaterial({\n\t\twidth: gauge.width,\n\t\tsw: source.width,\n\t\tsh: source.height,\n\t});\n\n\tgaugeRenderer.updateGeometry(baseY);\n\n\tconsole.log(process.memoryUsage().heapUsed);\n\n\treturn {\n\t\tbuffer: await gaugeRenderer.render(),\n\t\tsize: {\n\t\t\twidth: gaugeRenderer.width,\n\t\t\theight: gaugeRenderer.height,\n\t\t},\n\t};\n};\n\n// renderGaugeImage('./images/source.png', './images/gauge.png');\n","export const vs = `//#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`;\n\nexport const fs = `//#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`;\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T12:40:32.606Z`, '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;');\nimport { argv } from 'yargs';\nimport { pack, unpack } from 'msgpackr';\nimport { Reply } from 'zeromq';\nimport { renderGaugeImage } from '../../libs/gauge-renderer';\n\ninterface Params {\n\tmethod: string;\n\targs: any[];\n\tkwargs: Record;\n}\n\nconst unsafeMethods = ['bind', 'constructor', 'toString', 'toJSON'];\n\nclass GaugeServer {\n\tprivate socket: Reply;\n\n\tasync bind(port?: string) {\n\t\tthis.socket = new Reply();\n\t\tawait this.socket.bind(port);\n\n\t\tconsole.log(`gauge server listening at ${port}`);\n\n\t\ttry {\n\t\t\tfor await (const [data] of this.socket) {\n\t\t\t\tconst { method, args, kwargs } = (unpack(data) as Params) ?? {};\n\n\t\t\t\tconsole.log(`request: ${method}`);\n\n\t\t\t\tif (!unsafeMethods.includes(method) && this[method]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst data = await this[method]?.(args, kwargs);\n\t\t\t\t\t\tconsole.log(`success: ${method}`);\n\n\t\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\t\tcode: 0,\n\t\t\t\t\t\t\t\tmsg: 'success',\n\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(`fail: ${method}, error: ${err}`);\n\t\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\t\tcode: -1,\n\t\t\t\t\t\t\t\tmsg: `Error: ${JSON.stringify(err)}`,\n\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`fail: ${method}, error: no method`);\n\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\tcode: -1,\n\t\t\t\t\t\t\tmsg: `no method: ${method}`,\n\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.log('restarting gauge server..', err.stack);\n\t\t\tawait this.socket.close();\n\t\t\tawait this.bind(port);\n\t\t}\n\t}\n\n\tasync predict(args?: any[], kwargs?: Record) {\n\t\tlet source, gauge, baseY;\n\n\t\tif (args) {\n\t\t\t[source, gauge, baseY] = args;\n\t\t}\n\n\t\tif (kwargs) {\n\t\t\t({ source, gauge, baseY } = kwargs);\n\t\t}\n\n\t\treturn renderGaugeImage(source, gauge, baseY);\n\t}\n}\n\nasync function main() {\n\tconst server = new GaugeServer();\n\n\tawait server.bind(`tcp://*:${argv.port}`);\n}\n\nmain();\n"],"names":["globalThis","ImageData","cc","a","result","x","e","push","GLCanvas","constructor","context","this","_width","_height","ctx","width","getExtension","resize","height","addEventListener","evt","toBuffer","pixels","Uint8Array","readPixels","RGBA","UNSIGNED_BYTE","canvas","Canvas","getContext","putImageData","Uint8ClampedArray","gl","createContext","antialias","gaugeRenderer","GaugeRenderer","options","source","gauge","getShaderPrecisionFormat","VERTEX_SHADER","HIGH_FLOAT","FRAGMENT_SHADER","program","createProgram","vsShader","createShader","shaderSource","compileShader","logVs","getShaderInfoLog","console","warn","fsShader","logFs","attachShader","linkProgram","logProgram","getProgramInfoLog","deleteShader","name","nameModelView","getActiveUniform","modelMat","getUniformLocation","nameProj","projMat","nameUV","uvMat","nameDiffuse","diffuse","nameOpacity","opacity","nameMap","map","useProgram","uniformMatrix4fv","Float32Array","uniformMatrix3fv","uniform3f","uniform1f","uniform1i","texture","createTexture","activeTexture","TEXTURE0","bindTexture","TEXTURE_2D","pixelStorei","UNPACK_ALIGNMENT","texParameteri","TEXTURE_WRAP_S","CLAMP_TO_EDGE","TEXTURE_WRAP_T","TEXTURE_MAG_FILTER","LINEAR","TEXTURE_MIN_FILTER","LINEAR_MIPMAP_LINEAR","disable","CULL_FACE","depthMask","colorMask","STENCIL_TEST","POLYGON_OFFSET_FILL","SAMPLE_ALPHA_TO_COVERAGE","pos","createBuffer","uv","ib","iPos","getAttribLocation","iUV","enableVertexAttribArray","bindBuffer","ARRAY_BUFFER","vertexAttribPointer","FLOAT","updateMaterial","sw","sh","Number","isFinite","Math","round","viewport","sourceCanvas","drawImage","texImage2D","generateMipmap","updateGeometry","baseY","data","buffer","getImageData","xFactor","max","min","propertyArray","Array","fill","_","y","position","uvs","p","positions","faces","indices","bufferData","STATIC_DRAW","ELEMENT_ARRAY_BUFFER","Uint32Array","primitiveCount","length","render","clearColor","clear","COLOR_BUFFER_BIT","drawElements","TRIANGLES","UNSIGNED_INT","dispose","deleteBuffer","deleteProgram","deleteTexture","Image","info","unsafeMethods","GaugeServer","bind","port","socket","Reply","log","method","args","kwargs","unpack","includes","send","pack","code","msg","err","error","JSON","stringify","stack","close","predict","async","sourceURL","gaugeURL","loadImage","process","memoryUsage","heapUsed","size","renderGaugeImage","server","argv","main"],"mappings":"sMAIAA,WAAWC,UAAYA,EAAAA,UAOvB,MAAMC,EAASC,IACd,MAAMC,EAAc,GACpB,IAAK,MAAMC,KAAKF,EACf,IAAK,MAAMG,KAAKD,EAAGD,EAAOG,KAAKD,GAGhC,OAAOF,GAKR,MAAMI,SAOL,WAAAC,CAAYC,GALZC,KAAMC,OAAW,IACjBD,KAAOE,QAAW,IAKjBF,KAAKG,IAAMJ,CACX,CAED,SAA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OAAK,CACJC,MAAO,EACPC,IAAK,cAAcR,IACnB3C,KAAM,OAIT,CACD,CAAC,MAAOoD,GACRpI,QAAQ0H,IAAI,4BAA6BU,EAAII,aACvCjL,KAAKiK,OAAOiB,cACZlL,KAAK+J,KAAKC,EAChB,CACD,CAED,aAAMmB,CAAQd,EAAcC,GAC3B,IAAI3I,EAAQC,EAAO4F,EAUnB,OARI6C,KACF1I,EAAQC,EAAO4F,GAAS6C,GAGtBC,KACA3I,SAAQC,QAAO4F,SAAU8C,GF6OCc,OAAOC,EAA4BC,EAA2B9D,KAC7F,MAAM7F,QAAe4J,YAAUF,GACzBzJ,QAAc2J,YAAUD,GAe9B,OAbA9J,EAAcG,OAASA,EACvBH,EAAcI,MAAQA,EAEtBJ,EAAcmF,eAAe,CAC5BvG,MAAOwB,EAAMxB,MACbwG,GAAIjF,EAAOvB,MACXyG,GAAIlF,EAAOpB,SAGZiB,EAAc+F,eAAeC,GAE7B/E,QAAQ0H,IAAIqB,QAAQC,cAAcC,UAE3B,CACNhE,aAAclG,EAAcwH,SAC5B2C,KAAM,CACLvL,MAAOoB,EAAcpB,MACrBG,OAAQiB,EAAcjB,UE/PhBqL,CAAiBjK,EAAQC,EAAO4F,EACvC,GAGF4D,iBACC,MAAMS,EAAS,IAAI/B,kBAEb+B,EAAO9B,KAAK,WAAW+B,EAAAA,KAAK9B,OACnC,CAEA+B"} \ No newline at end of file +{"version":3,"file":"gauge-server.js","sources":["../../libs/gauge-renderer.ts","../../../src/pages/playground/scripts/shaders.ts","../src/gauge-server.ts"],"sourcesContent":["/* global cv */\nimport { Canvas, Image, loadImage, ImageData } from 'skia-canvas';\n// threejs内部使用了OffscreenCanvas\n//(globalThis as any).OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas;\nglobalThis.ImageData = ImageData;\n\nimport createContext from 'gl';\n\nimport * as SHADER_SOURCE from '../../src/pages/playground/scripts/shaders';\n\n//const cc = (a: T[][]): T[] => a.flat(1);\t// This is slower!\nconst cc = (a: T[][]): T[] => {\n\tconst result: T[] = [];\n\tfor (const x of a) {\n\t\tfor (const e of x) result.push(e);\n\t}\n\n\treturn result;\n};\n\ntype RenderContext = ReturnType;\n\nclass GLCanvas {\n\tctx: RenderContext;\n\t_width: number = 256;\n\t_height: number = 192;\n\n\tresizeBuffer: number[];\n\n\tconstructor(context: RenderContext) {\n\t\tthis.ctx = context;\n\t}\n\n\tget width() {\n\t\treturn this._width;\n\t}\n\n\tset width(width: number) {\n\t\tthis._width = width;\n\t\tconst ext = this.ctx.getExtension('STACKGL_resize_drawingbuffer');\n\t\text.resize(width, this.height);\n\t}\n\n\tget height() {\n\t\treturn this._height;\n\t}\n\n\tset height(height: number) {\n\t\tthis._height = height;\n\t\tconst ext = this.ctx.getExtension('STACKGL_resize_drawingbuffer');\n\t\text.resize(this.width, height);\n\t}\n\n\t/*// @ts-ignore\n\tgetContext(type, options) {\n\t\tif (type === 'webgl') {\n\t\t\tthis.ctx = createContext(200, 300, options);\n\n\t\t\treturn this.ctx;\n\t\t}\n\n\t\treturn null as WebGLRenderingContext;\n\t}*/\n\n\taddEventListener(evt: 'webglcontextlost') {}\n\n\tasync toBuffer() {\n\t\tconst pixels = new Uint8Array(this.width * this.height * 4);\n\t\tthis.ctx.readPixels(0, 0, this.width, this.height, this.ctx.RGBA, this.ctx.UNSIGNED_BYTE, pixels);\n\n\t\tconst canvas = new Canvas(this.width, this.height);\n\t\tconst ctx = canvas.getContext('2d');\n\t\tctx.putImageData(new ImageData(new Uint8ClampedArray(pixels), this.width, this.height), 0, 0);\n\n\t\treturn canvas.toBuffer('png');\n\t}\n}\n\ninterface GaugeRendererInitOptions {\n\tsource: HTMLImageElement;\n\tgauge: HTMLImageElement;\n}\n\nconst gl = createContext(512, 192, { antialias: true });\n\nexport default class GaugeRenderer {\n\tsource: Image; // base64 string\n\tgauge: Image;\n\tcanvas: GLCanvas;\n\n\tprogram: WebGLProgram;\n\ttexture: WebGLTexture;\n\tpos: WebGLBuffer;\n\tuv: WebGLBuffer;\n\tib: WebGLBuffer;\n\tprimitiveCount: number;\n\n\twidth: number = 256;\n\theight: number = 192;\n\n\tconstructor(options: GaugeRendererInitOptions) {\n\t\tthis.source = options.source;\n\t\tthis.gauge = options.gauge;\n\t\tthis.canvas = new GLCanvas(gl);\n\n\t\tgl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);\n\t\tgl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n\n\t\tgl.getExtension('OES_element_index_uint');\n\n\t\t// initial program\n\t\tthis.program = gl.createProgram();\n\n\t\tconst vsShader = gl.createShader(gl.VERTEX_SHADER);\n\t\tgl.shaderSource(vsShader, SHADER_SOURCE.vs);\n\t\tgl.compileShader(vsShader);\n\t\tconst logVs = gl.getShaderInfoLog(vsShader);\n\t\tlogVs && console.warn('vs log:', logVs);\n\n\t\tconst fsShader = gl.createShader(gl.FRAGMENT_SHADER);\n\t\tgl.shaderSource(fsShader, SHADER_SOURCE.fs);\n\t\tgl.compileShader(fsShader);\n\t\tconst logFs = gl.getShaderInfoLog(fsShader);\n\t\tlogFs && console.warn('fs log:', logFs);\n\n\t\tgl.attachShader(this.program, vsShader);\n\t\tgl.attachShader(this.program, fsShader);\n\t\tgl.linkProgram(this.program);\n\n\t\tconst logProgram = gl.getProgramInfoLog(this.program);\n\t\tlogProgram && console.warn('program log:', logProgram);\n\n\t\tgl.deleteShader(vsShader);\n\t\tgl.deleteShader(fsShader);\n\n\t\tconst { name: nameModelView } = gl.getActiveUniform(this.program, 0);\n\t\tconst modelMat = gl.getUniformLocation(this.program, nameModelView);\n\t\tconst { name: nameProj } = gl.getActiveUniform(this.program, 1);\n\t\tconst projMat = gl.getUniformLocation(this.program, nameProj);\n\t\tconst { name: nameUV } = gl.getActiveUniform(this.program, 2);\n\t\tconst uvMat = gl.getUniformLocation(this.program, nameUV);\n\t\tconst { name: nameDiffuse } = gl.getActiveUniform(this.program, 3);\n\t\tconst diffuse = gl.getUniformLocation(this.program, nameDiffuse);\n\t\tconst { name: nameOpacity } = gl.getActiveUniform(this.program, 4);\n\t\tconst opacity = gl.getUniformLocation(this.program, nameOpacity);\n\t\tconst { name: nameMap } = gl.getActiveUniform(this.program, 5);\n\t\tconst map = gl.getUniformLocation(this.program, nameMap);\n\n\t\tgl.useProgram(this.program);\n\n\t\tgl.uniformMatrix4fv(\n\t\t\tprojMat,\n\t\t\tfalse,\n\t\t\t//new Float32Array([0.0026385225355625153, 0, 0, 0, 0, -0.010416666977107525, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t\tnew Float32Array([0.002739726100116968, 0, 0, 0, 0, 0.010416666977107525, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t);\n\t\tgl.uniformMatrix4fv(modelMat, false, new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 1]));\n\t\tgl.uniformMatrix3fv(uvMat, false, new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]));\n\t\tgl.uniform3f(diffuse, 1, 1, 1);\n\t\tgl.uniform1f(opacity, 1);\n\t\tgl.uniform1i(map, 0);\n\n\t\t// texture\n\t\tthis.texture = gl.createTexture();\n\t\tgl.activeTexture(gl.TEXTURE0);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n\t\tgl.pixelStorei(37440, true);\n\t\tgl.pixelStorei(37441, false);\n\t\tgl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);\n\t\tgl.pixelStorei(37443, 0);\n\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\n\n\t\tgl.disable(gl.CULL_FACE);\n\t\tgl.depthMask(true);\n\t\tgl.colorMask(true, true, true, true);\n\t\tgl.disable(gl.STENCIL_TEST);\n\t\tgl.disable(gl.POLYGON_OFFSET_FILL);\n\t\tgl.disable(gl.SAMPLE_ALPHA_TO_COVERAGE);\n\n\t\t// buffers\n\t\tthis.pos = gl.createBuffer();\n\t\tthis.uv = gl.createBuffer();\n\t\tthis.ib = gl.createBuffer();\n\n\t\tconst iPos = gl.getAttribLocation(this.program, 'position');\n\t\tconst iUV = gl.getAttribLocation(this.program, 'uv');\n\t\t//console.log('indices:', iPos, iUV);\n\n\t\tgl.enableVertexAttribArray(iPos);\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.pos);\n\t\tgl.vertexAttribPointer(iPos, 3, gl.FLOAT, false, 0, 0);\n\n\t\tgl.enableVertexAttribArray(iUV);\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.uv);\n\t\tgl.vertexAttribPointer(iUV, 2, gl.FLOAT, false, 0, 0);\n\t}\n\n\tupdateMaterial({ width = null, sw = this.width, sh = this.height } = {}) {\n\t\tif (sw !== this.width || sh !== this.height) {\n\t\t\tif (Number.isFinite(width)) {\n\t\t\t\tthis.width = width;\n\t\t\t} else {\n\t\t\t\tthis.width = Math.round((this.height * sw) / sh);\n\t\t\t}\n\n\t\t\tthis.canvas.width = this.width;\n\t\t\tthis.canvas.height = this.height;\n\n\t\t\tgl.viewport(0, 0, this.width, this.height);\n\n\t\t\tconst projMat = gl.getUniformLocation(this.program, 'projectionMatrix');\n\t\t\tgl.uniformMatrix4fv(\n\t\t\t\tprojMat,\n\t\t\t\tfalse,\n\t\t\t\tnew Float32Array([2 / this.width, 0, 0, 0, 0, 2 / this.height, 0, 0, 0, 0, -0.20202019810676575, 0, 0, 0, -1.0202020406723022, 1])\n\t\t\t);\n\t\t}\n\n\t\t// image to canvas\n\t\tconst sourceCanvas = new Canvas(this.source.width, this.source.height);\n\t\tsourceCanvas.getContext('2d').drawImage(this.source, 0, 0);\n\n\t\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, sourceCanvas as any);\n\t\tgl.generateMipmap(gl.TEXTURE_2D);\n\t}\n\n\tupdateGeometry(baseY = null) {\n\t\tconst { width, height } = this.gauge;\n\t\tconst canvas = new Canvas(width, height);\n\t\tconst ctx = canvas.getContext('2d');\n\t\tctx.drawImage(this.gauge, 0, 0);\n\t\tconst { data: buffer } = ctx.getImageData(0, 0, width, height);\n\n\t\tconst xFactor = this.width / width;\n\n\t\tbaseY = Math.round(Number.isFinite(baseY) ? baseY : height / 2);\n\t\tbaseY = Math.max(0, Math.min(height - 1, baseY));\n\n\t\tconst propertyArray = Array(height)\n\t\t\t.fill(null)\n\t\t\t.map((_, y) =>\n\t\t\t\tArray(width)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, x) => ({\n\t\t\t\t\t\tuv: [(x + 0.5) / width, 1 - (y + 0.5) / height],\n\t\t\t\t\t\tposition: [(x - width / 2) * xFactor, (buffer[(y * width + x) * 4] + buffer[(y * width + x) * 4 + 2] / 256 - 128) / xFactor, 0],\n\t\t\t\t\t}))\n\t\t\t);\n\n\t\t// integral X by K\n\t\tfor (let y = baseY; y > 0; --y) {\n\t\t\tfor (let x = 0; x < width; ++x)\n\t\t\t\tpropertyArray[y - 1][x].position[0] = propertyArray[y][x].position[0] - ((buffer[(y * width + x) * 4 + 1] - 128) * xFactor) / 127;\n\t\t}\n\t\tfor (let y = baseY + 1; y < height; ++y) {\n\t\t\tfor (let x = 0; x < width; ++x)\n\t\t\t\tpropertyArray[y][x].position[0] = propertyArray[y - 1][x].position[0] + ((buffer[((y - 1) * width + x) * 4 + 1] - 128) * xFactor) / 127;\n\t\t}\n\n\t\tconst uvs = cc(cc(propertyArray).map((p) => p.uv));\n\t\tconst positions = cc(cc(propertyArray).map((p) => p.position));\n\n\t\tconst faces = Array(height - 1)\n\t\t\t.fill(null)\n\t\t\t.map((_, y) =>\n\t\t\t\tArray(width - 1)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, x) => [y * width + x, y * width + x + 1, (y + 1) * width + x, (y + 1) * width + x, (y + 1) * width + x + 1, y * width + x + 1])\n\t\t\t);\n\t\tconst indices = cc(cc(faces));\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.pos);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);\n\n\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.uv);\n\t\tgl.bufferData(gl.ARRAY_BUFFER, new Float32Array(uvs), gl.STATIC_DRAW);\n\n\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.ib);\n\t\tgl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(indices), gl.STATIC_DRAW);\n\n\t\tthis.primitiveCount = indices.length;\n\t}\n\n\trender() {\n\t\tgl.clearColor(1, 1, 1, 1);\n\t\tgl.clear(gl.COLOR_BUFFER_BIT);\n\n\t\t//gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.ib);\n\n\t\tgl.drawElements(gl.TRIANGLES, this.primitiveCount, gl.UNSIGNED_INT, 0);\n\n\t\treturn this.canvas.toBuffer();\n\t}\n\n\tdispose() {\n\t\tgl.deleteBuffer(this.pos);\n\t\tgl.deleteBuffer(this.uv);\n\t\tgl.deleteBuffer(this.ib);\n\n\t\tgl.deleteProgram(this.program);\n\t\tgl.deleteTexture(this.texture);\n\t}\n}\n\nconst gaugeRenderer = new GaugeRenderer({\n\tsource: new Image(),\n\tgauge: new Image(),\n});\n\nexport const renderGaugeImage = async (sourceURL: string | Buffer, gaugeURL: string | Buffer, baseY?: number) => {\n\tconst source = await loadImage(sourceURL);\n\tconst gauge = await loadImage(gaugeURL);\n\n\tgaugeRenderer.source = source;\n\tgaugeRenderer.gauge = gauge;\n\n\tgaugeRenderer.updateMaterial({\n\t\twidth: gauge.width,\n\t\tsw: source.width,\n\t\tsh: source.height,\n\t});\n\n\tgaugeRenderer.updateGeometry(baseY);\n\n\tconsole.log(process.memoryUsage().heapUsed);\n\n\treturn {\n\t\tbuffer: await gaugeRenderer.render(),\n\t\tsize: {\n\t\t\twidth: gaugeRenderer.width,\n\t\t\theight: gaugeRenderer.height,\n\t\t},\n\t};\n};\n\n// renderGaugeImage('./images/source.png', './images/gauge.png');\n","export const vs = `//#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`;\n\nexport const fs = `//#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`;\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T15:16:49.858Z`, '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;');\nimport { argv } from 'yargs';\nimport { pack, unpack } from 'msgpackr';\nimport { Reply } from 'zeromq';\nimport { renderGaugeImage } from '../../libs/gauge-renderer';\n\ninterface Params {\n\tmethod: string;\n\targs: any[];\n\tkwargs: Record;\n}\n\nconst unsafeMethods = ['bind', 'constructor', 'toString', 'toJSON'];\n\nclass GaugeServer {\n\tprivate socket: Reply;\n\n\tasync bind(port?: string) {\n\t\tthis.socket = new Reply();\n\t\tawait this.socket.bind(port);\n\n\t\tconsole.log(`gauge server listening at ${port}`);\n\n\t\ttry {\n\t\t\tfor await (const [data] of this.socket) {\n\t\t\t\tconst { method, args, kwargs } = (unpack(data) as Params) ?? {};\n\n\t\t\t\tconsole.log(`request: ${method}`);\n\n\t\t\t\tif (!unsafeMethods.includes(method) && this[method]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst data = await this[method]?.(args, kwargs);\n\t\t\t\t\t\tconsole.log(`success: ${method}`);\n\n\t\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\t\tcode: 0,\n\t\t\t\t\t\t\t\tmsg: 'success',\n\t\t\t\t\t\t\t\tdata,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tconsole.error(`fail: ${method}, error: ${err}`);\n\t\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\t\tcode: -1,\n\t\t\t\t\t\t\t\tmsg: `Error: ${JSON.stringify(err)}`,\n\t\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`fail: ${method}, error: no method`);\n\t\t\t\t\tawait this.socket.send(\n\t\t\t\t\t\tpack({\n\t\t\t\t\t\t\tcode: -1,\n\t\t\t\t\t\t\tmsg: `no method: ${method}`,\n\t\t\t\t\t\t\tdata: null,\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.log('restarting gauge server..', err.stack);\n\t\t\tawait this.socket.close();\n\t\t\tawait this.bind(port);\n\t\t}\n\t}\n\n\tasync predict(args?: any[], kwargs?: Record) {\n\t\tlet source, gauge, baseY;\n\n\t\tif (args) {\n\t\t\t[source, gauge, baseY] = args;\n\t\t}\n\n\t\tif (kwargs) {\n\t\t\t({ source, gauge, baseY } = kwargs);\n\t\t}\n\n\t\treturn renderGaugeImage(source, gauge, baseY);\n\t}\n}\n\nasync function main() {\n\tconst server = new GaugeServer();\n\n\tawait server.bind(`tcp://*:${argv.port}`);\n}\n\nmain();\n"],"names":["globalThis","ImageData","cc","a","result","x","e","push","GLCanvas","constructor","context","this","_width","_height","ctx","width","getExtension","resize","height","addEventListener","evt","toBuffer","pixels","Uint8Array","readPixels","RGBA","UNSIGNED_BYTE","canvas","Canvas","getContext","putImageData","Uint8ClampedArray","gl","createContext","antialias","gaugeRenderer","GaugeRenderer","options","source","gauge","getShaderPrecisionFormat","VERTEX_SHADER","HIGH_FLOAT","FRAGMENT_SHADER","program","createProgram","vsShader","createShader","shaderSource","compileShader","logVs","getShaderInfoLog","console","warn","fsShader","logFs","attachShader","linkProgram","logProgram","getProgramInfoLog","deleteShader","name","nameModelView","getActiveUniform","modelMat","getUniformLocation","nameProj","projMat","nameUV","uvMat","nameDiffuse","diffuse","nameOpacity","opacity","nameMap","map","useProgram","uniformMatrix4fv","Float32Array","uniformMatrix3fv","uniform3f","uniform1f","uniform1i","texture","createTexture","activeTexture","TEXTURE0","bindTexture","TEXTURE_2D","pixelStorei","UNPACK_ALIGNMENT","texParameteri","TEXTURE_WRAP_S","CLAMP_TO_EDGE","TEXTURE_WRAP_T","TEXTURE_MAG_FILTER","LINEAR","TEXTURE_MIN_FILTER","LINEAR_MIPMAP_LINEAR","disable","CULL_FACE","depthMask","colorMask","STENCIL_TEST","POLYGON_OFFSET_FILL","SAMPLE_ALPHA_TO_COVERAGE","pos","createBuffer","uv","ib","iPos","getAttribLocation","iUV","enableVertexAttribArray","bindBuffer","ARRAY_BUFFER","vertexAttribPointer","FLOAT","updateMaterial","sw","sh","Number","isFinite","Math","round","viewport","sourceCanvas","drawImage","texImage2D","generateMipmap","updateGeometry","baseY","data","buffer","getImageData","xFactor","max","min","propertyArray","Array","fill","_","y","position","uvs","p","positions","faces","indices","bufferData","STATIC_DRAW","ELEMENT_ARRAY_BUFFER","Uint32Array","primitiveCount","length","render","clearColor","clear","COLOR_BUFFER_BIT","drawElements","TRIANGLES","UNSIGNED_INT","dispose","deleteBuffer","deleteProgram","deleteTexture","Image","info","unsafeMethods","GaugeServer","bind","port","socket","Reply","log","method","args","kwargs","unpack","includes","send","pack","code","msg","err","error","JSON","stringify","stack","close","predict","async","sourceURL","gaugeURL","loadImage","process","memoryUsage","heapUsed","size","renderGaugeImage","server","argv","main"],"mappings":"sMAIAA,WAAWC,UAAYA,EAAAA,UAOvB,MAAMC,EAASC,IACd,MAAMC,EAAc,GACpB,IAAK,MAAMC,KAAKF,EACf,IAAK,MAAMG,KAAKD,EAAGD,EAAOG,KAAKD,GAGhC,OAAOF,GAKR,MAAMI,SAOL,WAAAC,CAAYC,GALZC,KAAMC,OA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AEDhF,QAAQqI,MAAM,SAASV,6BACjBpK,KAAKiK,OAAOQ,KACjBC,OAAK,CACJC,MAAO,EACPC,IAAK,cAAcR,IACnB3C,KAAM,OAIT,CACD,CAAC,MAAOoD,GACRpI,QAAQ0H,IAAI,4BAA6BU,EAAII,aACvCjL,KAAKiK,OAAOiB,cACZlL,KAAK+J,KAAKC,EAChB,CACD,CAED,aAAMmB,CAAQd,EAAcC,GAC3B,IAAI3I,EAAQC,EAAO4F,EAUnB,OARI6C,KACF1I,EAAQC,EAAO4F,GAAS6C,GAGtBC,KACA3I,SAAQC,QAAO4F,SAAU8C,GF6OCc,OAAOC,EAA4BC,EAA2B9D,KAC7F,MAAM7F,QAAe4J,YAAUF,GACzBzJ,QAAc2J,YAAUD,GAe9B,OAbA9J,EAAcG,OAASA,EACvBH,EAAcI,MAAQA,EAEtBJ,EAAcmF,eAAe,CAC5BvG,MAAOwB,EAAMxB,MACbwG,GAAIjF,EAAOvB,MACXyG,GAAIlF,EAAOpB,SAGZiB,EAAc+F,eAAeC,GAE7B/E,QAAQ0H,IAAIqB,QAAQC,cAAcC,UAE3B,CACNhE,aAAclG,EAAcwH,SAC5B2C,KAAM,CACLvL,MAAOoB,EAAcpB,MACrBG,OAAQiB,EAAcjB,UE/PhBqL,CAAiBjK,EAAQC,EAAO4F,EACvC,GAGF4D,iBACC,MAAMS,EAAS,IAAI/B,kBAEb+B,EAAO9B,KAAK,WAAW+B,EAAAA,KAAK9B,OACnC,CAEA+B"} \ No newline at end of file diff --git a/backend/omr/dist/index.js b/backend/omr/dist/index.js index 1e21e149ae529bffec1da5d6eb0b6308b71326b2..d1cdc70440401236fcaa4bed2a38e91c90af11d5 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("js-sha1"),t=require("lodash/pick"),s=require("lodash"),i=require("math-erf"),r=require("msgpackr"),n=require("zeromq"),a=require("portfinder"),o=require("python-shell"),c=require("skia-canvas"),l=require("weak-lru-cache"),u=require("spark-md5"),h=require("sharp"),m=require("got");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d,p,g,y=f(e),v=f(t),x=f(s),S=f(i),b=f(u),k=f(h),T=f(m);globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"),globalThis.atob=e=>Buffer.from(e,"base64").toString("binary"),function(e){e.ByLines="ByLines",e.ByBlocks="ByBlocks"}(d||(d={})),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"}(p||(p={})),function(e){e.ClefG="ClefG",e.ClefF="ClefF",e.ClefC="ClefC",e.NoteheadS0="NoteheadS0",e.NoteheadS1="NoteheadS1",e.NoteheadS2="NoteheadS2",e.NoteheadS1stemU="NoteheadS1stemU",e.NoteheadS1stemD="NoteheadS1stemD",e.NoteheadS2stemU="NoteheadS2stemU",e.NoteheadS2stemD="NoteheadS2stemD",e.vline_Stem="vline_Stem",e.Flag3="Flag3",e.BeamLeft="BeamLeft",e.BeamContinue="BeamContinue",e.BeamRight="BeamRight",e.TremoloLeft="TremoloLeft",e.TremoloRight="TremoloRight",e.TremoloMiddle="TremoloMiddle",e.Dot="Dot",e.Rest0="Rest0",e.Rest1="Rest1",e.Rest2="Rest2",e.Rest3="Rest3",e.Rest4="Rest4",e.Rest5="Rest5",e.Rest6="Rest6",e.Rest0W="Rest0W",e.RestM1="RestM1",e.AccNatural="AccNatural",e.AccSharp="AccSharp",e.AccDoublesharp="AccDoublesharp",e.AccFlat="AccFlat",e.AccFlatflat="AccFlatflat",e.vline_VoltaLeft="vline_VoltaLeft",e.vline_VoltaRight="vline_VoltaRight",e.VoltaLeft="VoltaLeft",e.VoltaRight="VoltaRight",e.VoltaAlternativeBegin="VoltaAlternativeBegin",e.BarMeasure="BarMeasure",e.vline_BarMeasure="vline_BarMeasure",e.vline_BarTerminal="vline_BarTerminal",e.vline_BarSegment="vline_BarSegment",e.SlurBegin="SlurBegin",e.SlurEnd="SlurEnd",e.TimesigC44="TimesigC44",e.TimesigC22="TimesigC22",e.TimesigZero="TimesigZero",e.TimesigOne="TimesigOne",e.TimesigTwo="TimesigTwo",e.TimesigThree="TimesigThree",e.TimesigFour="TimesigFour",e.TimesigFive="TimesigFive",e.TimesigSix="TimesigSix",e.TimesigSeven="TimesigSeven",e.TimesigEight="TimesigEight",e.TimesigNine="TimesigNine",e.OctaveShift8va="OctaveShift8va",e.OctaveShift8vb="OctaveShift8vb",e.OctaveShift8="OctaveShift8",e.OctaveShift0="OctaveShift0",e.Zero="Zero",e.One="One",e.Two="Two",e.Three="Three",e.Four="Four",e.Five="Five",e.Six="Six",e.Seven="Seven",e.Eight="Eight",e.Nine="Nine",e.f="f",e.p="p",e.m="m",e.n="n",e.r="r",e.s="s",e.z="z",e.CrescendoBegin="CrescendoBegin",e.CrescendoEnd="CrescendoEnd",e.DecrescendoBegin="DecrescendoBegin",e.DecrescendoEnd="DecrescendoEnd",e.ScriptFermata="ScriptFermata",e.ScriptShortFermata="ScriptShortFermata",e.ScriptSforzato="ScriptSforzato",e.ScriptStaccato="ScriptStaccato",e.ScriptStaccatissimo="ScriptStaccatissimo",e.ScriptTurn="ScriptTurn",e.ScriptTrill="ScriptTrill",e.ScriptSegno="ScriptSegno",e.ScriptCoda="ScriptCoda",e.ScriptArpeggio="ScriptArpeggio",e.ScriptPrall="ScriptPrall",e.ScriptMordent="ScriptMordent",e.ScriptMarcato="ScriptMarcato",e.ScriptTenuto="ScriptTenuto",e.ScriptPortato="ScriptPortato",e.PedalStar="PedalStar",e.PedalPed="PedalPed",e.KeyAcc="KeyAcc",e.TempoNotehead="TempoNotehead",e.GraceNotehead="GraceNotehead",e.SignLined="SignLined",e.SignInterval="SignInterval",e.rect_Text="rect_Text",e.rect_Lyric="rect_Lyric"}(g||(g={}));const w={NoteheadS0:1.826,NoteheadS1:1.264,NoteheadS2:1.198},M={"clefs.F":{x:1.06},"clefs.G":{x:1.3},"clefs.F_change":{x:.87},"clefs.G_change":{x:1.07},"timesig.C44":{x:.9},"timesig.C22":{x:.9},zero:{x:.7,y:-1},one:{x:.7,y:-1},two:{x:.7,y:-1},three:{x:.7,y:-1},four:{x:.7,y:-1},five:{x:.7,y:-1},six:{x:.7,y:-1},seven:{x:.7,y:-1},eight:{x:.7,y:-1},nine:{x:.7,y:-1},"accidentals.sharp":{x:.55},"accidentals.doublesharp":{x:.5},"accidentals.natural":{x:.3},"accidentals.flat":{x:.3},"accidentals.flatflat":{x:.5},"noteheads.s0":{x:w.NoteheadS0/2},"noteheads.s1":{x:w.NoteheadS1/2},"noteheads.s2":{x:w.NoteheadS2/2},"rests.0":{x:.75,y:1},"rests.1":{x:.75},"rests.0o":{x:.75,y:1},"rests.1o":{x:.75},"rests.M1":{x:.75,y:1},"rests.2":{x:.5},"rests.3":{x:.5},"rests.4":{x:.5},"rests.5":{x:.5},"rests.6":{x:.5},f:{x:.6,y:-.5},m:{x:.9,y:-.5},p:{x:.5,y:-.5},r:{x:.5,y:-.5},s:{x:.5,y:-.5},z:{x:.5,y:-.5},"scripts.trill":{y:-.5},"scripts.segno":{x:0,y:0},"scripts.coda":{x:0,y:0},"scripts.arpeggio":{x:.5,y:-.5},"pedal.*":{x:.78,y:-.78},"pedal.Ped":{x:1.6,y:-.7}},E=[g.BarMeasure,g.vline_BarMeasure,g.vline_BarTerminal,g.vline_BarSegment,g.vline_VoltaLeft,g.vline_VoltaRight,g.VoltaAlternativeBegin],N=g,I=[[N.NoteheadS0,N.NoteheadS1,N.NoteheadS2],[N.Zero,N.One,N.Two,N.Three,N.Four,N.Five,N.Six,N.Seven,N.Eight,N.Nine,N.ScriptStaccatissimo],[N.TimesigZero,N.TimesigOne,N.TimesigTwo,N.TimesigThree,N.TimesigFour,N.TimesigFive,N.TimesigSix,N.TimesigSeven,N.TimesigEight,N.TimesigNine],[N.Rest0,N.Rest1,N.Rest2,N.Rest3,N.Rest4,N.Rest5,N.Rest6,N.Rest0W,N.RestM1],[N.SignInterval,N.SignLined],[N.BeamLeft,N.BeamContinue,N.BeamRight]],C=[N.ClefG,N.ClefF,N.ClefC,N.NoteheadS0,N.NoteheadS1,N.NoteheadS2,N.Dot,N.Rest0,N.Rest1,N.Rest2,N.Rest3,N.Rest4,N.Rest5,N.Rest6,N.RestM1,N.AccNatural,N.AccSharp,N.AccDoublesharp,N.AccFlat,N.AccFlatflat,N.TimesigC44,N.TimesigC22,N.TimesigZero,N.TimesigOne,N.TimesigTwo,N.TimesigThree,N.TimesigFour,N.TimesigFive,N.TimesigSix,N.TimesigSeven,N.TimesigEight,N.TimesigNine,N.One,N.Two,N.Three,N.Four,N.Five,N.OctaveShift8,N.OctaveShift0,N.f,N.p,N.m,N.n,N.r,N.s,N.z,N.ScriptFermata,N.ScriptShortFermata,N.ScriptSforzato,N.ScriptStaccato,N.ScriptStaccatissimo,N.ScriptTurn,N.ScriptTrill,N.ScriptSegno,N.ScriptCoda,N.ScriptArpeggio,N.ScriptPrall,N.ScriptMordent,N.ScriptMarcato,N.ScriptTenuto,N.ScriptPortato,N.PedalStar,N.PedalPed],_=(e,t,s)=>{const i=Math.round(10*s.x),r=Math.round(10*s.y),n=`${e}|${t}|${s.semantic}|${i}|${r}`,a=y.default.array(n).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),r=`p-${e}|${t.semantic}|${s}|${i}`,n=y.default.array(r).slice(12),a=globalThis.btoa(String.fromCharCode(...n)).substring(0,11);return t.id=a,a};var B;!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"}(B||(B={}));const A=B,P=Object.values(B),R=P.filter(e=>/clefs-/.test(e)),D=P.filter(e=>/timesig/.test(e)),F=P.filter(e=>/timesig-/.test(e)),L=P.filter(e=>/timesig\d/.test(e)),$=P.filter(e=>/octave-/.test(e)),j=P.filter(e=>/n\d/.test(e)),H=P.filter(e=>/accidentals-/.test(e)),V=P.filter(e=>/noteheads-/.test(e)),z=[A.NoteheadS0,A.NoteheadS1,A.NoteheadS2],q=P.filter(e=>/noteheads-.+-[ud]/.test(e)),G=P.filter(e=>/rests-/.test(e)),W=P.filter(e=>/flags-/.test(e)),U=P.filter(e=>/volta-/.test(e)),Y=P.filter(e=>/^[a-z]$/.test(e)),X=P.filter(e=>/scripts-/.test(e)),K=P.filter(e=>/pedal-/.test(e)),Z=[A.Dot,A.DotDot],J=[A.SlurBegin,A.SlurEnd,A.TieBegin,A.TieEnd],Q=P.filter(e=>/beam-/.test(e)),ee=P.filter(e=>/wedge-/.test(e)),te=[...j,...Y,...ee,...K,...J,A.ScriptFermata,A.ScriptShortFermata,A.ScriptSforzato,A.ScriptStaccato,A.ScriptStaccatissimo,A.ScriptTurn,A.ScriptTrill,A.ScriptPrall,A.ScriptMordent,A.ScriptMarcato,A.ScriptTenuto,A.ScriptPortato],se=[...K],ie=[...R,...D,...j,...H,A.NoteheadS0,A.NoteheadS1,A.NoteheadS2,...G,...Y,...X,...K,...Z],re={};R.forEach(e=>re[e]=1),L.forEach(e=>re[e]=1),H.forEach(e=>re[e]=.5),V.forEach(e=>re[e]=.5),G.forEach(e=>re[e]=.5),Z.forEach(e=>re[e]=.5);const ne={};F.forEach(e=>ne[e]=0),U.forEach(e=>ne[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 q.includes(this.type)||this.type===B.NoteheadS0}get isContexted(){return R.includes(this.type)||D.includes(this.type)||$.includes(this.type)||H.includes(this.type)}get isAccessory(){return j.includes(this.type)||Y.includes(this.type)||X.includes(this.type)||K.includes(this.type)}get division(){switch(this.type){case A.NoteheadS0:return 0;case A.NoteheadS1stemU:case A.NoteheadS1stemD:return 1;case A.NoteheadS2stemU:case A.NoteheadS2stemD:return 2;case A.Flag3:return 3;case A.Flag4:return 4;case A.Flag5:return 5;case A.Flag6:return 6;case A.Flag7:return 7;case A.Flag8:return 8;case A.RestM1:return-1;case A.Rest0:return 0;case A.Rest1:return 1;case A.Rest2:return 2;case A.Rest3:return 3;case A.Rest4:return 4;case A.Rest5:return 5;case A.Rest6:return 6}return null}get dots(){switch(this.type){case A.Dot:return 1;case A.DotDot:return 2}return null}get direction(){switch(this.type){case A.NoteheadS1stemU:case A.NoteheadS2stemU:return"u";case A.NoteheadS1stemD:case A.NoteheadS2stemD:return"d"}return null}get width(){switch(this.type){case A.NoteheadS0:return w.NoteheadS0;case A.NoteheadS1stemU:case A.NoteheadS1stemD:return w.NoteheadS1;case A.NoteheadS2stemU:case A.NoteheadS2stemD:return w.NoteheadS2}}get left(){switch(this.type){case A.NoteheadS0:return this.x-this.width/2;case A.NoteheadS1stemU:case A.NoteheadS2stemU:return this.x-this.width;case A.NoteheadS1stemD:case A.NoteheadS2stemD:return this.x}return this.x}get right(){switch(this.type){case A.NoteheadS0:return this.x+this.width/2;case A.NoteheadS1stemU:case A.NoteheadS2stemU:return this.x;case A.NoteheadS1stemD:case A.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<("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})),oe=(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(oe(e,t))),s}if(e&&"object"==typeof e){const s={};return t.set(e,s),Object.entries(e).forEach(([e,i])=>s[e]=oe(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?v.default(this,t):this;return{__prototype:e.className,...s}}deepCopy(){return oe(this)}}var ce;!function(e){e.Ordinary="ordinary",e.Full="full",e.Conservative="conservative",e.Once="once"}(ce||(ce={}));const le=(e,t=ce.Ordinary)=>[].concat(...e.map(e=>e.serialize(t))),ue=(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 le(this.seq,e)}get code(){return ue(this.seq,{withBrackets:!0})}}BlockMLayout.className="BlockMLayout";class VoltaMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=le(this.body);if(this.alternates){const s=this.alternates.map(e=>le(e)),i=s[s.length-1];switch(e){case ce.Ordinary:return t.concat(...s);case ce.Conservative:case ce.Full:return[...[].concat(...Array(this.times-1).fill(null).map((e,i)=>[...t,...s[i%(this.times-1)]])),...t,...i];case ce.Once:return[...t,...i]}}else switch(e){case ce.Ordinary:case ce.Conservative:case ce.Once:return t;case ce.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=ue(this.body,{withBrackets:!0});let t=`${this.times}*${e}`;return this.alternates&&(t+="{"+this.alternates.map(e=>ue(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=le(this.main.seq,ce.Once),i=le(this.rest,e);switch(e){case ce.Ordinary:return[...t,...i];case ce.Once:return[...i,...s];case ce.Conservative:case ce.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+", "+ue(this.rest)+">"}}ABAMLayout.className="ABAMLayout";var he=Object.freeze({__proto__:null,get LayoutType(){return ce},SingleMLayout:SingleMLayout,BlockMLayout:BlockMLayout,VoltaMLayout:VoltaMLayout,ABAMLayout:ABAMLayout}),me=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],r=[1,26],n=[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,r,n,a){var o=n.length-1;switch(r){case 1:return n[o-1];case 2:this.$=f(null,n[o]);break;case 3:this.$=f("index-wise",n[o]);break;case 4:this.$=f("segment-wise",b(n[o]));break;case 5:case 23:1===n[o].length&&"BlockMLayout"===n[o][0].__prototype?this.$=n[o][0]:this.$=p(n[o]);break;case 6:case 24:this.$=[n[o]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=n[o];break;case 8:this.$=[...n[o-2],n[o]];break;case 9:this.$=[...n[o-2],...n[o]];break;case 10:this.$=S(n[o-2],n[o]);break;case 15:this.$=d(n[o]);break;case 16:case 31:this.$=p(n[o]);break;case 17:case 32:this.$=n[o-1];break;case 18:case 33:this.$=g(n[o-3],n[o-1],n[o]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=x(n[o-1]);break;case 22:this.$=y(n[o-3],n[o-1]);break;case 25:this.$=[...n[o-1],n[o]];break;case 26:this.$=p([n[o]]);break;case 30:this.$=v(n[o]);break;case 37:this.$=y(n[o-2],n[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:r,21:n,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:r,21:n,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:r,21:n,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:r,21:n,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:n,36:46},{14:r,21:n,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:r,21:n,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:r,21:n,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:r,21:n,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:r,21:n,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],r=[],n=this.table,a="",o=0,c=0,l=r.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 f=u.yylloc;r.push(f);var d=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,b,k,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=n[g]&&n[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in k=[],n[g])this.terminals_[x]&&x>2&&k.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+k.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:f,expected:k})}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),r.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,f=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:r[r.length-(S||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(S||1)].first_column,last_column:r[r.length-1].last_column},d&&(w._$.range=[r[r.length-(S||1)].range[0],r[r.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,r].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),r=r.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),r.push(w._$),b=n[s[s.length-2]][s[s.length-1]],s.push(b);break;case 3:return!0}}return!0}};const f=(e,t)=>({__prototype:"MesaureLayout",type:e,data:t}),d=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)=>d(e+s))},b=(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)=>d(s+t))}return[b(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=b(e.main,t),e.rest=s(e.rest)}return e};var k={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 r=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=[r[0],r[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,r;if(this.options.backtrack_lexer&&(r={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&&(r.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 n in r)this[n]=r[n];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 r=this._currentRules(),n=0;nt[0].length)){if(t=s,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,r[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,r[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=k,T.prototype=m,m.Parser=T,new T}();me.Parser;me.Parser;var fe=function(){return me.parse.apply(me,arguments)};var de,pe;!function(e){e[e.Default=0]="Default",e[e.Brace=1]="Brace",e[e.Bracket=2]="Bracket",e[e.Square=3]="Square"}(de||(de={})),function(e){e[e.Blank=0]="Blank",e[e.Dashed=1]="Dashed",e[e.Solid=2]="Solid"}(pe||(pe={}));const ge=e=>({type:de.Default,staff:e}),ye={"{":de.Brace,"}":de.Brace,"<":de.Bracket,">":de.Bracket,"[":de.Square,"]":de.Square},ve={",":pe.Blank,"-":pe.Solid,".":pe.Dashed},xe=()=>btoa(Math.random().toString().substr(2)).replace(/=/g,"").split("").reverse().slice(0,6).join(""),Se=(e,t)=>{let s=t;for(;s.length;){const t=s.shift(),i=ye[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=Se(t,s),e.subs=e.subs||[],e.subs.push(t)}}else e.subs=e.subs||[],e.subs.push(ge(t))}for(;e.type===de.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===de.Default;){const t=e.subs[0];e.subs=t.subs,e.staff=t.staff}return e.grand=e.type===de.Brace&&e.subs&&e.subs.every(e=>e.staff),s},be=e=>e.staff?e.staff:e.subs?be(e.subs[0]):void 0,ke=e=>e.staff?e.staff:e.subs?ke(e.subs[e.subs.length-1]):void 0,Te=(e,t)=>{t[(e=>e.staff?e.staff:e.subs?`${be(e)}-${ke(e)}`:void 0)(e)]=e,e.subs&&e.subs.forEach(e=>Te(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+="_"+xe();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?ve[e.conjunction]:pe.Blank);const s=[].concat(...e.map(e=>[...e.leftBounds,e.id,...e.rightBounds]));this.group={type:de.Default},Se(this.group,s);const i={};Te(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=pe.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])]})),r=s.slice(0,s.length-1).map((t,i)=>{const r=s[i+1];return e.conjunctionBetween(e.staffIds.indexOf(t),e.staffIds.indexOf(r))});return{staffIds:s,conjunctions:r,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)),r=t.map(e=>e[0]).filter(Boolean).join(","),n=t.some(([e,t])=>t),a=r?((e,t=!1)=>{if(e===de.Default)return e=>e;if(t)switch(e){case de.Brace:return e=>`{${e}`;case de.Bracket:return e=>`<${e}`;case de.Square:return e=>`[${e}`;default:return e=>e}switch(e){case de.Brace:return e=>`{${e}}`;case de.Bracket:return e=>`<${e}>`;case de.Square:return e=>`[${e}]`;default:return e=>e}})(e.type,n)(r):null;return[a,n]};let[r]=i(this.group);return r=r||"",t||(r=r.replace(/[_\w]+/g,"")),r}}var we=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],r=[1,11],n=[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],f=[5,11,12,13,21,22,23,24],d={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,r,n,a){var o=n.length-1;switch(r){case 1:return n[o-1];case 2:n[o].next(),this.$=n[o].toJSON();break;case 3:this.$=new Seq;break;case 13:case 15:this.$=[n[o]];break;case 14:case 16:this.$=[...n[o-1],n[o]];break;case 20:this.$=new Seq,this.$.tip.i(n[o]);break;case 21:case 23:n[o-1].next(),n[o-1].tip.i(n[o]),this.$=n[o-1];break;case 22:case 24:n[o-1].tip.i(n[o]),this.$=n[o-1];break;case 25:this.$=new Seq,this.$.tip.bl(n[o]);break;case 26:case 27:n[o-1].next(),n[o-1].tip.bl(n[o]),this.$=n[o-1];break;case 28:n[o-1].tip.bl(n[o]),this.$=n[o-1];break;case 29:case 30:case 31:n[o-1].tip.br(n[o]),this.$=n[o-1];break;case 32:this.$=new Seq,this.$.tip.con(n[o]),this.$.next();break;case 33:case 34:case 35:case 36:n[o-1].tip.con(n[o]),n[o-1].next(),this.$=n[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:r,22:n,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:r,22:n,23:a,24:[1,19]},{5:[2,5],10:14,11:t,12:s,13:i,18:29,20:28,21:r,22:n,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:r,22:n,23:a,24:[1,30]},e(u,[2,20]),{14:23,15:o,16:c,17:l,19:35,20:36,21:r,22:n,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(f,[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(f,[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(f,[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],r=[],n=this.table,a="",o=0,c=0,l=r.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 f=u.yylloc;r.push(f);var d=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,b,k,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=n[g]&&n[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in k=[],n[g])this.terminals_[x]&&x>2&&k.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+k.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:f,expected:k})}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),r.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,f=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:r[r.length-(S||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(S||1)].first_column,last_column:r[r.length-1].last_column},d&&(w._$.range=[r[r.length-(S||1)].range[0],r[r.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,r].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),r=r.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),r.push(w._$),b=n[s[s.length-2]][s[s.length-1]],s.push(b);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 r=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=[r[0],r[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,r;if(this.options.backtrack_lexer&&(r={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&&(r.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 n in r)this[n]=r[n];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 r=this._currentRules(),n=0;nt[0].length)){if(t=s,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,r[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,r[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 d.lexer=p,g.prototype=d,d.Parser=g,new g}();we.Parser;we.Parser;var Me=function(){return we.parse.apply(we,arguments)};const Ee=e=>{const t=Me(e);return new StaffLayout(t)};class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const Ne=(e,t,s=-1/0)=>Math.max(Math.round(e/t)*t,s),Ie=(e,t)=>{const s=e.x-t.x,i=e.y-t.y;return Math.sqrt(s*s+i*i)},Ce=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:Ce(t,e%t):(console.error("non-integer gcd:",e,t),1),_e=(e,t)=>({numerator:e,denominator:t}),Oe=(e,t)=>{e=Math.round(e),t=Math.round(t);const s=0!==e?Ce(e,t):t;return _e(e/s,t/s)},Be=e=>`${e.numerator}/${e.denominator}`,Ae=(e,t)=>t?e*t.numerator/t.denominator:e,Pe=(e,t)=>{const s=[...e].sort((e,s)=>e[t]-s[t]);let i=null,r=null;return s.reduce((e,n,a)=>(r?n[t]-r[t]<.4?i.push(n):(i.length>1&&e.push(i),r=n,i=[n]):(r=n,i=[n]),i.length>1&&a===s.length-1&&e.push(i),e),[])},Re=e=>{if(e.length<=1)return[];let t=e.slice(1);const s=I.find(t=>t.includes(e[0].semantic));if(!s)return Re(t);const i=t.filter(e=>s.includes(e.semantic));return t=t.filter(e=>!s.includes(e.semantic)),[...i,...Re(t)]},De=e=>{const t=new Set(e),s=Pe(e,"x"),i=[].concat(...s.map(e=>Pe(e,"y")));return i.forEach(e=>e.sort((e,t)=>t.confidence-e.confidence)),i.forEach(e=>{Re(e).forEach(e=>t.delete(e))}),Array.from(t)},Fe=[0,2,4,5,7,9,11],Le=({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+Fe[i]+t},$e=e=>{const t=Math.max(...e);return e.indexOf(t)},je=1920;var He,Ve,ze,qe,Ge,We;!function(e){e.Up="^",e.Down="_",e.Middle="-"}(He||(He={})),function(e){e.Grace="grace",e.AfterGrace="afterGrace",e.Acciaccatura="acciaccatura",e.Appoggiatura="appoggiatura",e.SlashedGrace="slashedGrace"}(Ve||(Ve={})),function(e){e.Open="Open",e.Close="Close",e.Continue="Continue"}(ze||(ze={})),function(e){e.Pitcher="Pitcher",e.Catcher="Catcher",e.Pierced="Pierced"}(qe||(qe={})),function(e){e.Normal="normal",e.DashedLine="dashed-line",e.DottedLine="dotted-line",e.Zigzag="zigzag",e.Trill="trill"}(Ge||(Ge={})),function(e){e.Normal="Normal",e.Bracket="Bracket",e.Parenthesis="Parenthesis",e.ParenthesisDashed="ParenthesisDashed",e.ArrowDown="ArrowDown"}(We||(We={}));class Term extends SimpleClass{}class EventTerm extends Term{static space({tick:e,duration:t}){const s=new EventTerm({rest:"s",tick:e,accessories:[]});return s.duration=Math.round(t),s}constructor(e){super(),super.assign(e),Object.assign(this,e),Number.isFinite(e.left)&&Number.isFinite(e.right)&&(this.x=(this.left+this.right)/2),Number.isFinite(this.pivotX)||(this.pivotX=this.x)}get alignedTick(){return this.grace?this.tick+this.duration:this.tick}get mainDuration(){return je*2**-this.division*(2-2**-this.dots)}get duration(){let e=this.mainDuration;return this.multiplier&&(e*=this.multiplier.numerator/this.multiplier.denominator),this.timeWarp&&(e*=this.timeWarp.numerator/this.timeWarp.denominator),this.grace?e/8:e}set duration(e){console.assert(Number.isFinite(e),"invalid duration value:",e);const t=Ce(e,128),s=Math.log2(128/t),i=Oe(e*2**s,je);this.division=s,this.dots=0,i.numerator!==i.denominator?this.multiplier=i:this.multiplier=void 0}get prior(){return this.tick}get times(){return this.timeWarp?`${this.timeWarp.numerator}/${this.timeWarp.denominator}`:null}get fullMeasureRest(){return"R"===this.rest}get tipX(){return this.tip?this.tip.x:this.x}get tipY(){return this.tip?this.tip.y:this.ys?this.ys[0]:0}get tremoloCatcher(){return this.tremoloLink===qe.Catcher}get scaleChord(){return this.pitches.map(e=>"CDEFGAB"[(e.note+700)%7]).join("")}get zeroHolder(){return!!this.grace||this.tremoloCatcher}}var Ue;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"}(Ue||(Ue={}));class ContextedTerm extends Term{constructor(e){super(),Object.assign(this,e)}get type(){return R.includes(this.tokenType)?Ue.Clef:/\|key-/.test(this.tokenType)?Ue.KeyAcc:/accidentals-/.test(this.tokenType)?Ue.Acc:$.includes(this.tokenType)?Ue.OctaveShift:F.includes(this.tokenType)?Ue.TimeSignatureC:L.includes(this.tokenType)?Ue.TimeSignatureN:null}get staffLevel(){return[Ue.OctaveShift,Ue.Clef,Ue.KeyAcc].includes(this.type)}get prior(){return this.tick-.1}get clef(){switch(this.tokenType){case B.ClefG:return-this.y-2;case B.ClefF:return 2-this.y;case B.ClefC:return-this.y}return null}get alter(){switch(this.tokenType){case B.AccNatural:case B.KeyNatural:return 0;case B.AccSharp:case B.KeySharp:return 1;case B.AccFlat:case B.KeyFlat:return-1;case B.AccDoublesharp:return 2;case B.AccFlatflat:return-2}return null}get octaveShift(){switch(this.tokenType){case B.OctaveShift8va:return-1;case B.OctaveShift0:return 0;case B.OctaveShift8vb:return 1}return null}get number(){switch(this.tokenType){case B.TimesigZero:return 0;case B.TimesigOne:return 1;case B.TimesigTwo:return 2;case B.TimesigThree:return 3;case B.TimesigFour:return 4;case B.TimesigFive:return 5;case B.TimesigSix:return 6;case B.TimesigSeven:return 7;case B.TimesigEight:return 8;case B.TimesigNine:return 9}return null}}ContextedTerm.className="ContextedTerm";class MarkTerm extends Term{get prior(){return this.tick+.01}}MarkTerm.className="MarkTerm";const Ye=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=Ye.findIndex(e=>t.includes(e));i=i>=0?i:2;let r=(2**i).toString();return t.includes(".")&&(r+="."),new TempoTerm({tick:0,duration:r,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 je/Number(t)*(s?1.5:1)}get bpm(){const[e]=this.beats.match(/\d+/)||[90];return Number(e)*this.durationMagnitude*4/je}isValid(e=[10,400]){const t=this.bpm;return Number.isFinite(this.bpm)&&t>=e[0]&&t{if(!e.regulated)return;const t=e.eventMap,s=e.events.length,i=e.voices.flat(1).length,r=e.events.filter(e=>e.timeWarp).length,n=new Set(e.events.filter(e=>e.timeWarp&&!(e.rest&&0===e.division)).map(e=>`${e.timeWarp.numerator}/${e.timeWarp.denominator}`)),a=new Set(n);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,r=0,n=0;return s.some((e,t)=>{const a=e.timeWarp?e.timeWarp.denominator:0;if(a!==i){if(i>0&&(r%i||n<2))return!0;r=0,n=0}return i=a,r+=e.duration,++n,!!(t===s.length-1&&i>0&&(r%i||n<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=Ae(je,e.timeSignature),h=e.doubtfulTimesig?e.duration:u,m=e.voices.flat(1).map(e=>t[e]),f=m.some(e=>!e||!Number.isFinite(e.tick)||!Number.isFinite(e.division)||e.division<0||!Number.isFinite(e.duration)||e.duration<=0),d=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 Ce(Math.round(t),je)e.reduce(({status:e,broken:s},i)=>{const r=t[i];return r.beam&&(e+=Xe[r.beam],s=s||!(e>=0&&e<=1)),{status:e,broken:s}},{status:0,broken:!1})).some(({status:e,broken:t})=>e||t);let b=0,k=0;e.voices.forEach(s=>{const i=s.reduce((e,s)=>e+t[s].duration,0);b+=Math.max(0,e.duration-i),k+=Math.max(0,i-e.duration)}),b/=je;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,N=f||E>=1||c||M||e.tickRatesInStaves.some(e=>e<0)||T>2||!e.timeSignature||d||e.duration>h||e.events.some(e=>e.timeWarp&&e.timeWarp.numerator/e.timeWarp.denominator<=.5),I=!N&&!p&&E<.2&&!o&&!a.size&&!x&&!b&&!k&&!!e.voices.length&&!S&&!g&&!v&&(e.duration===h||Number.isFinite(e.estimatedDuration)&&e.estimatedDuration<=.75*h),C=!(N||p||!(E<.3)||o||x||k||S||g);let _=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(_=Math.max(0,Math.min(_,e.estimatedDuration)));const O=e.duration/_;let B=0;if(e.patched&&!f)B=1;else if(!N){const t=Math.tanh(1*Math.abs(b/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:r,complicatedTimewarp:l,spaceTime:b,surplusTime:k,durationRate:O,beamBroken:S,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:x,tickTwist:E,tickOverlapped:c,graceInVoice:g,graceN:y,graceDominant:v,perfect:I,fine:C,error:N,qualityScore:B}};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],r=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=r}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 Ze=[g.ClefG,g.ClefF,g.ClefC,g.TimesigC44,g.TimesigC22,g.TimesigZero,g.TimesigOne,g.TimesigTwo,g.TimesigThree,g.TimesigFour,g.TimesigFive,g.TimesigSix,g.TimesigSeven,g.TimesigEight,g.TimesigNine,g.OctaveShift8va,g.OctaveShift8vb,g.OctaveShift0,g.Zero,g.One,g.Two,g.Three,g.Four,g.Five,g.Six,g.Seven,g.Eight,g.Nine,g.AccNatural,g.AccSharp,g.AccDoublesharp,g.AccFlat,g.AccFlatflat,g.NoteheadS0,g.NoteheadS1,g.NoteheadS2,g.NoteheadS1stemU,g.NoteheadS1stemD,g.NoteheadS2stemU,g.NoteheadS2stemD,g.Rest0,g.Rest1,g.Rest2,g.Rest3,g.Rest4,g.Rest5,g.Rest6,g.Rest0W,g.RestM1,g.SlurBegin,g.SlurEnd,g.Dot,g.f,g.p,g.m,g.n,g.r,g.s,g.z,g.ScriptFermata,g.ScriptShortFermata,g.ScriptSforzato,g.ScriptStaccato,g.ScriptStaccatissimo,g.ScriptTurn,g.ScriptTrill,g.ScriptSegno,g.ScriptCoda,g.ScriptArpeggio,g.ScriptPrall,g.ScriptMordent,g.ScriptMarcato,g.ScriptTenuto,g.ScriptPortato,g.PedalStar,g.PedalPed,g.GraceNotehead,g.BeamLeft,g.BeamRight,g.BeamContinue,g.CrescendoBegin,g.CrescendoEnd,g.DecrescendoBegin,g.DecrescendoEnd,g.TremoloLeft,g.TremoloRight,g.TremoloMiddle],Je=[g.AccNatural,g.AccSharp,g.AccDoublesharp,g.AccFlat,g.AccFlatflat,g.NoteheadS0,g.NoteheadS1,g.NoteheadS2,g.NoteheadS1stemU,g.NoteheadS1stemD,g.NoteheadS2stemU,g.NoteheadS2stemD],Qe=[g.SignLined,g.SignInterval],et=[g.NoteheadS1,g.NoteheadS2],tt={AccSharp:B.KeySharp,AccNatural:B.KeyNatural,AccFlat:B.KeyFlat},st={[g.NoteheadS1]:{up:g.NoteheadS1stemU,down:g.NoteheadS1stemD},[g.NoteheadS2]:{up:g.NoteheadS2stemU,down:g.NoteheadS2stemD}},it=[g.Rest0,g.Rest1,g.Rest2,g.Rest3,g.Rest4,g.Rest5,g.Rest6],rt={[B.BeamLeft]:"Open",[B.BeamRight]:"Close",[B.BeamContinue]:"Continue"},nt={Alter1:p.Alternation1,Alter2:p.Alternation2},at=(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)),at(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=>[B.NoteheadS0,B.NoteheadS1stemU,B.NoteheadS2stemU,B.NoteheadS1stemD,B.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 r=`${s.type}|${i}`;return!s.tip&&e[r]&&(e[r].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)),r=Math.max(...e.map(e=>e.y)),n=e[0],a=n&&n.tip?n.tip.x:t;let o=t,c=s-t,l=null;switch(n.type){case B.NoteheadS0:o-=w.NoteheadS0/2,c+=w.NoteheadS0;break;case B.NoteheadS1stemU:case B.NoteheadS2stemU:l="u",o-=w.NoteheadS1,c+=w.NoteheadS1;break;case B.NoteheadS1stemD:case B.NoteheadS2stemD:l="d",c+=w.NoteheadS1}return{x:o,width:c,stemX:a,stemDirection:l,top:i,bottom:r,tip:n.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=>W.includes(e.type)),t=this.tokens.filter(e=>Z.includes(e.type)),s=this.tokens.filter(e=>Q.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),r=t.reduce((e,t)=>Math.max(e,t.division),0);return{rect:e,left:e.x,right:e.x+e.width,pivotX:(n=t,at(n.map(e=>Number.isFinite(e.pivotX)?e.pivotX:e.x),n[0].direction)),ys:s,tip:e.tip,noteIds:i,division:r,dots:null,rest:!1,stemDirection:e.stemDirection,beam:null};var n}).sort((e,t)=>t.left-e.left),r=new Set,n=i.map(({rect:i,...n})=>{if(n.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=>!r.has(e.id)&&e.x>i.stemX-.2&&e.xt[0]&&e.yMath.max(e,t.division),n.division),a.forEach(e=>r.add(e.id));const o=i.tip&&s.find(e=>Math.abs(i.tip.x-e.x)<.3&&Math.abs(i.tip.y-e.y)<.7);o&&(n.beam=rt[o.type])}const a=t.filter(e=>!r.has(e.id)&&e.x>i.x+i.width-.2&&e.xi.top-1&&e.y<=i.bottom+.5);return n.dots=a.reduce((e,t)=>Math.max(e,t.dots),0),a.forEach(e=>r.add(e.id)),n});return n.reverse(),n}getRests(){const e=this.tokens.filter(e=>G.includes(e.type)),t=this.tokens.filter(e=>Z.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=>te.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)?He.Down:He.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===B.ScriptArpeggio).forEach(e=>{const s=t.find(t=>e.xtt>e.y));s&&s.accessories.push({type:B.ScriptArpeggio,id:e.id,x:e.x-s.left})});this.tokens.filter(e=>e.type===B.GraceNotehead).forEach(t=>{const s=e.find(e=>t.x>e.left&&t.xMath.abs(t.y-e)<.4));s&&(s.grace=Ve.Grace)});const s=this.tokens.filter(e=>e.type===B.TremoloLeft),i=this.tokens.filter(e=>e.type===B.TremoloRight),r=this.tokens.filter(e=>e.type===B.TremoloMiddle),n=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}});r.forEach(e=>{const t=n.find(t=>!!t.event.tip&&(e.y>t.top&&e.y{const t=n.find(t=>e.y>t.top&&e.yt.stemR&&e.x{const t=n.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=qe.Catcher)})}assignFeaturesOnEvents(e,t){const s=t.filter(e=>e.x>this.left&&e.xit.includes(e.semantic)),r=s.filter(e=>e.semantic===g.Flag3),n=s.filter(e=>e.semantic===g.Dot),a=s.filter(e=>e.semantic===g.BeamLeft),o=s.filter(e=>e.semantic===g.BeamContinue),c=s.filter(e=>e.semantic===g.BeamRight),l=s.filter(e=>e.semantic===g.GraceNotehead),u=s.filter(e=>e.semantic===g.TremoloRight),h=s.filter(e=>e.semantic===g.vline_Stem),m=s.filter(e=>e.semantic===g.NoteheadS0),f=s.filter(e=>e.semantic===g.NoteheadS1),d=s.filter(e=>e.semantic===g.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=>Ie(s,{x:t,y:e.ys[0]})<.5).forEach(e=>{const t=it.indexOf(e.semantic);y[t]=Math.max(y[t],e.confidence)})}else{const i=[m,f,d].map(t=>t.filter(t=>t.x>e.left&&t.xs-.25&&t.yMath.max(0,...e.map(e=>e.confidence))),n=r.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]=n[t]?n[t].confidence:0)}const v=n.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))],b=[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))),k=h.filter(s=>Ie({x:t,y:e.ys[0]},{x:s.x,y:s.extension.y2})<.5),T=h.filter(s=>Ie({x:t,y:e.ys[e.ys.length-1]},{x:s.x,y:s.extension.y1})<.5),w=[Math.max(0,...k.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)),N=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:b,stemDirections:w,grace:E,tremoloCatcher:I}})}}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===g.TempoNotehead).forEach(e=>{const t=i.findIndex(t=>/^Notehead/.test(t.semantic)&&Ie(e,t)<.3);t>=0&&i.splice(t,1)});const r=e=>t.displacementSemantics?.[e]?this.semantics.find(t=>t.id===e):null;i.filter(e=>Ze.includes(e.semantic)).forEach(e=>this.appendPoint(e,{points:i}));const n=i.filter(e=>e.semantic===g.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=>et.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<.28&&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)),n=Math.min(...t.map(t=>e.y2-t.y));if(Math.min(s,n)>.5)return;const a=s!o.has(e.id)).forEach(e=>{const a=n.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?st[e.semantic].down:st[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:r(e.id),points:i})}else s.debug("isolated notehead:",t.index,this.index,e)});const l=i.filter(e=>e.semantic===g.Flag3);l.sort((e,t)=>e.x-t.x),this.appendFlags(l,n);const u=i.filter(e=>e.semantic===g.Dot).map(e=>{const t=Ne(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>n.x&&e.x-n.x<1.2)&&this.appendPoint({id:n.id,x:n.x,y:s,confidence:n.confidence},{type:B.DotDot,antiPoint:r(n.id),points:i})}}});const h=i.filter(e=>e.semantic===g.KeyAcc);i.filter(e=>tt[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,x:e.x,y:e.y,confidence:e.confidence},{type:tt[e.semantic],points:i})});i.filter(e=>e.semantic===g.OctaveShift8).forEach(e=>{const t=e.y<0?B.OctaveShift8va:B.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=>[g.VoltaLeft,g.VoltaRight].includes(e.semantic));m.sort((e,t)=>e.x-t.x);const f=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:B[t]})}})}appendPoint(e,{type:t,points:s=null,antiPoint:i,...r}={}){const n=e.x,a=this.measures.find(e=>nQe.includes(t.semantic)&&Math.abs(t.y-e.y)<.2&&Math.abs(t.x-e.x)<1.2);t.some(e=>e.semantic===g.SignLined)?o=!0:t.some(e=>e.semantic===g.SignInterval)&&(c=!0)}t=t||B[e.semantic];const l=ne[t];let u=re[t];(o||c)&&(u=Math.max(u,1));let h=e.y;Number.isFinite(l)?h=l:u&&(h=c?Ne(h+.5,u)-.5:Ne(h,u));const m=a.tokens.find(e=>e.type===t&&Math.abs(e.x-n)<.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:n,y:h,pivotX:e.pivotX,confidence:e.confidence,...r})),i&&a.antiTokens.push(new Token({id:i.id,type:t,x:n,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),r=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,n=W[r-1];n&&this.appendPoint({id:e.flags[0].id,x:e.x,y:i,confidence:Math.min(...e.flags.map(e=>e.confidence))},{type:n})})}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=>D.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===B.VoltaLeft),voltaEnd:t.tokens.some(e=>e.type===B.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=>[Ue.TimeSignatureC,Ue.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 r=this.getStaffArray(e).map((e,s)=>e?e.measures.map((e,i)=>{const r=t(s,i);return r&&{events:r.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===B.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===B.VoltaRight),alternative:e.alternative,barTypes:e.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),n=Array(this.measureCount).fill(null).map((e,t)=>{const s=r.map(e=>e[t]);if(s.some(e=>!e))return null;let n=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),{});n=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:n,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=>n.forEach(e)),{staffMask:this.staffMask,columns:n}}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===B.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===B.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=>[Ue.TimeSignatureC,Ue.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(g.vline_BarMeasure,e);s.sort((e,t)=>e.x-t.x);const i=this.staffTop,r=this.staffBottom;let n=0;const a=s.reduce((e,t)=>{const s=Number.isFinite(t.confidence)?Math.tanh(t.confidence):1,a=t.x-n>.4?t.x:n;n=t.x;let o=e[a]||0;return o+=(Math.min(t.extension.y2,r)-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));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=>[g.vline_BarTerminal,g.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<_(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:r,x:n,y:a,confidence:o=0,extension:c=null}=t,l={semantic:r,x:n,y:a,confidence:o,extension:c};return l.extension||delete l.extension,_(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 p.TempoNumeral:{const t=this.staves[0];if(t){const s=t.top+t.staffY;t.measures.forEach(t=>{t.tokens=t.tokens.filter(t=>!V.includes(t.type)||Math.abs(t.x-e.x)>e.width/2||Math.abs(s+t.y-e.y)>e.fontSize/2)})}}break;case p.Alternation1:case p.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.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 r={x:(e.cx-s/2)/i,y:(e.cy-t/2)/i},n=this.source&&this.source.matrix?(a=r,{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]}):r;var a,o;return{confidence:e.score,x:n.x+this.width/2,y:n.y+this.height/2,semantic:g.rect_Text,extension:{text:e.text,type:e.type,width:e.width/i,height:e.height/i,theta:e.theta,textFeature:e.feature_dict}}})}assemble({textAnnotations:e=null}={},t=new DummyLogger){if(this.tokens=[],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:B.Text,confidence:s.confidence,textType:nt[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===g.rect_Text)switch(i.textType){case p.Title:case p.Author:case p.PageMargin:case p.Other:this.tokens.push(new TextToken({x:s.x,y:s.y,...i}));break;case p.TempoNumeral:case p.Chord:case p.MeasureNumber:case p.Instrument:case p.Alternation1:case p.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 p.TextualMark:case p.Times:{const e=[...this.systems].reverse().find(e=>e.topt>=e.top&&tr>=e.left&&r[e,ot[`TimeD${e}`]])),lt=Object.fromEntries(Array(12).fill(null).map((e,t)=>t+1).map(e=>[e,ot[`TimeN${e}`]])),ut=ot,ht={[ut.BOS]:"BOS",[ut.NoteheadS0]:"noteheads-s0",[ut.NoteheadS1]:"noteheads-s1",[ut.NoteheadS2]:"noteheads-s2",[ut.NoteheadGrace]:"GraceNotehead",[ut.Flag3]:"flags-u3",[ut.BeamLeft]:"BeamLeft",[ut.BeamContinue]:"BeamContinue",[ut.BeamRight]:"BeamRight",[ut.Dot]:"dot",[ut.Rest0]:"rests-0o",[ut.Rest1]:"rests-1o",[ut.Rest2]:"rests-2",[ut.Rest3]:"rests-3",[ut.Rest4]:"rests-4",[ut.Rest5]:"rests-5",[ut.Rest6]:"rests-6"},mt={[ut.NoteheadS0]:0,[ut.NoteheadS1]:1,[ut.NoteheadS2]:2,[ut.NoteheadGrace]:2},ft=[ut.NoteheadS0,ut.NoteheadS1,ut.NoteheadS2,ut.NoteheadGrace],dt=[ut.Rest0,ut.Rest1,ut.Rest2,ut.Rest3,ut.Rest4,ut.Rest5,ut.Rest6],pt=[ut.BeamLeft,ut.BeamContinue,ut.BeamRight],gt=[...ft,...dt],yt=[...ft,...dt,ut.vline_Stem],vt=[ut.BOS,ut.NoteheadS0,ut.vline_Stem,...dt],xt=[...gt,ut.vline_Stem],St={[ut.BeamLeft]:"Open",[ut.BeamRight]:"Close"},bt=e=>({type:e,staff:-1,x:0,y1:0,y2:0}),kt=bt(ot.BOS),Tt=e=>[bt(lt[e.numerator]),bt(ct[e.denominator])],wt=(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=>yt.includes(e.type))}get targetMask(){return this.elements.map(e=>vt.includes(e.type))}get vMask(){return this.elements.map(e=>xt.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=Mt([].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&&Et(e,this.vMask)}get matrixV(){return this.groupsV&&Nt(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 r=0;r=.5){const e=t.findIndex(e=>e.includes(r));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]),r=i?i[0]:s;return r-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=>ft.includes(e.type));for(let s=0;st),t=this.masks?this.masks[1]:e.map(e=>vt.includes(this.elements[e].type)),s=e.map(e=>this.elements[e].type===ut.vline_Stem&&this.elements[e].y2-this.elements[e].y1>2),i=e.filter(e=>[ut.NoteheadS1,ut.NoteheadS2,ut.NoteheadGrace].includes(this.elements[e].type)),r=e.filter(e=>this.elements[e].type===ut.NoteheadS0),n=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)})}),r.forEach(e=>{const s=this.elements[e],i=wt(this.matrixH[e],t),r=this.elements[i];r.type===ut.NoteheadS0&&Math.abs(s.x-r.x)<2.6?(n[e]=!0,a[i]=a[i]||[i],a[i].push(e)):a[e]=a[e]||[e]});const o={},c=e.filter(e=>a[e]||dt.includes(this.elements[e].type));c.sort((e,t)=>this.elements[e].x-this.elements[t].x);const l=e.map(e=>e===ut.BOS);c.forEach(e=>{const t=wt(this.matrixH[e],l);o[e]=t,t&&!dt.includes(this.elements[t].type)&&(l[t]=!1),l[e]=!0});const u=this.elements.filter(e=>e.type===ut.Dot),h=this.elements.filter(e=>e.type===ut.Flag3),m=this.elements.filter(e=>pt.includes(e.type)),f=this.groupsV;return c.map(e=>{const t=this.elements[e],s=f?f.findIndex(t=>t.includes(e)):null;if(dt.includes(t.type)){const i=u.filter(e=>e.x>t.x+.5&&e.xt.y1-1&&e.y1this.elements[e]),r=Math.min(...i.map(e=>e.x-.7)),n=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),f=c[0],d=c[c.length-1],p=u.filter(e=>e.x>n&&e.xf-1&&e.y1{const s=Ne(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=mt[i[0].type],v=null,x=null,S=null;if(t.type===ut.vline_Stem){if(v=f-t.y1>t.y2-d?"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,r]=t;return i.map(e=>r.map(t=>e&&t?s.next().value:null))},Et=(e,t)=>{const s=function*(){for(const t of e)yield t}();return t.map((e,i)=>t.map((t,r)=>e&&t&&r{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 r=s[i],n=s[t];return r<0||n<0?null:r===n?1:0}))};var It;!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"}(It||(It={}));const Ct=class Stream{constructor(e){this.array=new Uint8Array(e),this.position=0}eof(){return this.position>=this.array.length}read(e){const t=this.array.slice(this.position,this.position+e);return this.position+=e,t}readString(e){return Array.from(this.read(e)).map(e=>String.fromCharCode(e)).join("")}readInt32(){const e=(this.array[this.position]<<24)+(this.array[this.position+1]<<16)+(this.array[this.position+2]<<8)+this.array[this.position+3];return this.position+=4,e}readInt16(){const e=(this.array[this.position]<<8)+this.array[this.position+1];return this.position+=2,e}readInt8(e){let t=this.array[this.position];return e&&t>127&&(t-=256),this.position+=1,t}readVarInt(){let e=0;for(;;){const t=this.readInt8();if(!(128&t))return e+t;e+=127&t,e<<=7}}};const _t=class OStream{constructor(){this.buffer=""}write(e){this.buffer+=e}writeInt32(e){this.buffer+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)}writeInt16(e){this.buffer+=String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)}writeInt8(e){this.buffer+=String.fromCharCode(255&e)}writeVarInt(e){if(e<0)throw new Error("OStream.writeVarInt minus number: "+e);const t=127&e;e>>=7;let s=String.fromCharCode(t);for(;e;){const t=127&e;e>>=7,s=String.fromCharCode(128|t)+s}this.buffer+=s}getBuffer(){return this.buffer}getArrayBuffer(){return Uint8Array.from(this.buffer.split("").map(e=>e.charCodeAt(0))).buffer}};var Ot={parseMidiData:function(e){function t(e){const t=e.readString(4),s=e.readInt32();return{id:t,length:s,data:e.read(s)}}let s;function i(e){const t={};t.deltaTime=e.readVarInt();let i=e.readInt8();if(240&~i){let r;128&i?(r=e.readInt8(),s=i):(r=i,i=s);const n=i>>4;switch(t.channel=15&i,t.type="channel",n){case 8:return t.subtype="noteOff",t.noteNumber=r,t.velocity=e.readInt8(),t;case 9:return t.noteNumber=r,t.velocity=e.readInt8(),0===t.velocity?t.subtype="noteOff":t.subtype="noteOn",t;case 10:return t.subtype="noteAftertouch",t.noteNumber=r,t.amount=e.readInt8(),t;case 11:return t.subtype="controller",t.controllerType=r,t.value=e.readInt8(),t;case 12:return t.subtype="programChange",t.programNumber=r,t;case 13:return t.subtype="channelAftertouch",t.amount=r,t;case 14:return t.subtype="pitchBend",t.value=r+(e.readInt8()<<7),t;default:throw new Error("Unrecognised MIDI event type: "+n)}}else{if(255!==i){if(240===i){t.type="sysEx";const s=e.readVarInt();return t.data=e.readString(s),t}if(247===i){t.type="dividedSysEx";const s=e.readVarInt();return t.data=e.readString(s),t}throw new Error("Unrecognised MIDI event type byte: "+i)}{t.type="meta";const s=e.readInt8(),i=e.readVarInt();switch(s){case 0:if(t.subtype="sequenceNumber",2!==i)throw new Error("Expected length for sequenceNumber event is 2, got "+i);return t.number=e.readInt16(),t;case 1:return t.subtype="text",t.text=e.readString(i),t;case 2:return t.subtype="copyrightNotice",t.text=e.readString(i),t;case 3:return t.subtype="trackName",t.text=e.readString(i),t;case 4:return t.subtype="instrumentName",t.text=e.readString(i),t;case 5:return t.subtype="lyrics",t.text=e.readString(i),t;case 6:return t.subtype="marker",t.text=e.readString(i),t;case 7:return t.subtype="cuePoint",t.text=e.readString(i),t;case 32:if(t.subtype="midiChannelPrefix",1!==i)throw new Error("Expected length for midiChannelPrefix event is 1, got "+i);return t.channel=e.readInt8(),t;case 47:if(t.subtype="endOfTrack",0!==i)throw new Error("Expected length for endOfTrack event is 0, got "+i);return t;case 81:if(t.subtype="setTempo",3!==i)throw new Error("Expected length for setTempo event is 3, got "+i);return t.microsecondsPerBeat=(e.readInt8()<<16)+(e.readInt8()<<8)+e.readInt8(),t;case 84:if(t.subtype="smpteOffset",5!==i)throw new Error("Expected length for smpteOffset event is 5, got "+i);const s=e.readInt8();return t.frameRate={0:24,32:25,64:29,96:30}[96&s],t.hour=31&s,t.min=e.readInt8(),t.sec=e.readInt8(),t.frame=e.readInt8(),t.subframe=e.readInt8(),t;case 88:if(t.subtype="timeSignature",4!==i)throw new Error("Expected length for timeSignature event is 4, got "+i);return t.numerator=e.readInt8(),t.denominator=Math.pow(2,e.readInt8()),t.metronome=e.readInt8(),t.thirtyseconds=e.readInt8(),t;case 89:if(t.subtype="keySignature",2!==i)throw new Error("Expected length for keySignature event is 2, got "+i);return t.key=e.readInt8(!0),t.scale=e.readInt8(),t;case 127:return t.subtype="sequencerSpecific",t.data=e.readString(i),t;default:return t.subtype="unknown",t.data=e.readString(i),t}}}}let r=e;"string"==typeof e&&(r=e.split("").map(e=>e.charCodeAt(0)));const n=new Ct(r),a=t(n);if("MThd"!==a.id||6!==a.length)throw new Error("Bad .mid file - header not found");const o=new Ct(a.data),c=o.readInt16(),l=o.readInt16(),u=o.readInt16();let h;if(32768&u)throw new Error("Expressing time division in SMTPE frames is not supported yet");h=u;const m={formatType:c,trackCount:l,ticksPerBeat:h},f=[];for(let e=0;e>16&255),e.writeInt8(t.microsecondsPerBeat>>8&255),e.writeInt8(255&t.microsecondsPerBeat);break;case"smpteOffset":e.writeInt8(84),e.writeVarInt(5);var s={24:0,25:32,29:64,30:96}[t.frameRate];e.writeInt8(t.hour|s),e.writeInt8(t.min),e.writeInt8(t.sec),e.writeInt8(t.frame),e.writeInt8(t.subframe);break;case"timeSignature":e.writeInt8(88),e.writeVarInt(4),e.writeInt8(t.numerator),e.writeInt8(Math.log2(t.denominator)),e.writeInt8(t.metronome),e.writeInt8(t.thirtyseconds);break;case"keySignature":e.writeInt8(89),e.writeVarInt(2),e.writeInt8(t.key),e.writeInt8(t.scale);break;case"sequencerSpecific":e.writeInt8(127),e.writeVarInt(t.data.length),e.write(t.data);break;default:throw new Error("unhandled event subtype:"+t.subtype)}break;case"sysEx":e.writeInt8(240),e.writeVarInt(t.data.length),e.write(t.data);break;case"dividedSysEx":e.writeInt8(247),e.writeVarInt(t.data.length),e.write(t.data);break;case"channel":switch(t.subtype){case"noteOn":e.writeInt8(144|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.velocity);break;case"noteOff":e.writeInt8(128|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.velocity?t.velocity:0);break;case"noteAftertouch":e.writeInt8(160|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.amount);break;case"controller":e.writeInt8(176|t.channel),e.writeInt8(t.controllerType),e.writeInt8(t.value);break;case"programChange":e.writeInt8(192|t.channel),e.writeInt8(t.programNumber);break;case"channelAftertouch":e.writeInt8(208|t.channel),e.writeInt8(t.amount);break;case"pitchBend":e.writeInt8(224|t.channel),e.writeInt8(255&t.value),e.writeInt8(t.value>>7&255);break;default:throw new Error("unhandled event subtype:"+t.subtype)}break;default:throw new Error("unhandled event type:"+t.type)}}const r=new _t,n=new _t;n.writeInt16(e.formatType),n.writeInt16(t.length),n.writeInt16(e.ticksPerBeat),s(r,"MThd",n.getBuffer());for(let e=0;e{const s=[];let i=120;const r=e.header.ticksPerBeat;for(let t=0;t0){e=a.ticksToEvent/r/(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=n()}if(a=n())for(;a;)e()}(),o},trimSequence: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)})},fixOverlapNotes:e=>{const t=new Map,s=new Map,i=[];let r=-1;return e.forEach(([{event:e,ticksToEvent:n}],a)=>{if(n>0&&(r=a),"channel"!==e.type)return;const o=`${e.channel}|${e.noteNumber}`;switch(e.subtype){case"noteOn":t.get(o)?s.set(o,r):t.set(o,r);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],r=e[s+1],n=e[t];if(!n[0].ticksToEvent)return void console.warn("invalid front index:",t,s,n);const a=n[1]/n[0].ticksToEvent;r[1]+=i[1],r[0].ticksToEvent+=i[0].ticksToEvent,i[0].ticksToEvent=n[0].ticksToEvent-1,n[0].ticksToEvent=1,i[1]=i[0].ticksToEvent*a,n[1]=n[0].ticksToEvent*a,e.splice(s,1),e.splice(t,0,i)}),e}};const At=Bt,Pt={64:"Sustain",65:"Portamento",66:"Sostenuto",67:"Soft"};class Notation$1{static parseMidi(e,{fixOverlap:t=!0}={}){const s=[],i={},r={},n=[],a=[];let o=0,c=5e3,l=0,u=4,h=0;const m={};let f,d=0,p=0;const g=[],y=e.header.ticksPerBeat;let v=At.midiToSequence(e);t&&(v=At.trimSequence(At.fixOverlapNotes(v)));const x=v.map(e=>({data:e[0].event,track:e[0].track,deltaTime:e[1],deltaTicks:e[0].ticksToEvent}));let S=0;for(const e of x){if(d+=e.deltaTicks,p=Math.round(1*d),e.deltaTicks>0){const t=e.deltaTicks/y;for(let e=Math.ceil(l);es.channel==t.channel&&s.pitch==e);if(i>=0){const r=s.splice(i,1)[0];n[t.channel].push({channel:t.channel,startTick:r.startTick,endTick:p,pitch:e,start:r.start,duration:o-r.start,velocity:r.velocity,beats:r.beats,track:r.track,finger:r.finger})}else console.debug("unexpected noteOff: ",o,t);m.high=Math.max(m.high||e,e)}break;case"controller":switch(t.controllerType){case 64:case 65:case 66:case 67:const e=Pt[t.controllerType];i[t.channel]=i[t.channel]||{},r[t.channel]=r[t.channel]||[];const s=i[t.channel][e];s&&r[t.channel].push({type:e,start:s.start,duration:o-s.start,value:s.value}),i[t.channel][e]={start:o,value:t.value}}}break;case"meta":switch(t.subtype){case"setTempo":c=t.microsecondsPerBeat/1e3,g.push({tempo:t.microsecondsPerBeat,tick:p,time:o});break;case"timeSignature":u=t.numerator,h=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,i]=t.text.match(/\((.+)\)/),r=Number(i);if(!Number.isNaN(r)){const e=s[s.length-1];e&&(e.finger=r);const t=x.find(e=>e.index==S-1);t&&(t.data.finger=r)}}break;case"copyrightNotice":console.log("MIDI copyright:",t.text)}}}return s.forEach(e=>{console.debug("unclosed noteOn event at",e.startTick,e),n[e.channel].push({startTick:e.startTick,endTick:p,pitch:e.pitch,start:e.start,duration:o-e.start,velocity:e.velocity,beats:e.beats,track:e.track,finger:e.finger})}),new Notation$1({channels:n,keyRange:m,pedals:r,bars:a,endTime:o,endTick:p,correspondences:f,events:x,tempos:g,ticksPerBeat:y,meta:{}})}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){console.assert(Number.isFinite(e),"invalid tick value:",e),console.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){console.assert(Number.isFinite(e),"invalid time value:",e),console.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 console.assert(e.to>=e.from,"invalid tick range:",e),{from:this.ticksToTime(e.from),to:this.ticksToTime(e.to)}}scaleTempo({factor:e,headTempo:t}){console.assert(this.tempos&&this.tempos.length,"[Notation.scaleTempo] tempos is empty."),t&&(e=t/this.tempos[0].tempo),console.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}}var Rt={Notation:Notation$1};const{Notation:Dt}=Rt,Ft=()=>new Promise(e=>requestAnimationFrame(e));var Lt=class MidiPlayer$1{constructor(e,{cacheSpan:t=600,onMidi:s,onPlayFinish:i,onTurnCursor:r}={}){let n;this.cacheSpan=t,this.onMidi=s,this.onPlayFinish=i,this.onTurnCursor=r,n=e.notes&&Number.isFinite(e.endTime)?e:Dt.parseMidi(e),this.notation=n,this.events=n.events,this.isPlaying=!1,this.progressTime=0,this.startTime=performance.now(),this.duration=n.endTime,this.cursorTurnDelta=0,console.assert(n.tempos&&n.tempos.length,"[MidiPlayer] invalid notation, tempos is empty.")}dispose(){this.isPlaying=!1,this.progressTime=0}get progressTicks(){return this.notation.timeToTicks(this.progressTime)}set progressTicks(e){this.progressTime=this.notation.ticksToTime(e),this.onTurnCursor&&this.onTurnCursor(this.progressTime)}async play({nextFrame:e=Ft}={}){this.progressTime>=this.duration&&(this.progressTime=0);let t=performance.now();this.startTime=t-this.progressTime,this.isPlaying=!0;let s=this.events.findIndex(e=>e.time>=t-this.startTime);for(;this.isPlaying;){for(;sthis.progressTime+this.cacheSpan)break;"channel"===e.data.type&&this.startTime+e.time>=t&&this.onMidi&&this.onMidi(e.data,this.startTime+e.time)}if(await e(),!this.isPlaying)break;if(0!==this.cursorTurnDelta){const e=this.cursorTurnDelta<0;if(this.startTime-=this.cursorTurnDelta,this.cursorTurnDelta=0,e)for(;s>0;--s){const e=this.events[s].time;if(this.startTime+ethis.duration&&(this.isPlaying=!1,this.onPlayFinish&&this.onPlayFinish())}}pause(){this.isPlaying=!1}turnCursor(e){this.isPlaying?this.cursorTurnDelta+=e-this.progressTime:this.progressTime=e,this.onTurnCursor&&this.onTurnCursor(e)}},$t={CostStepAttenuation:.6,SkipDeep:3,PriorDistanceSigmoidFactor:.1,PriorValueSigmoidFactor:.12,SkipCost:.5,LagOffsetCost:1,LeadOffsetCost:1.6,ZeroOffsetCost:.58,RelocationThreshold:6};const{pick:jt}=x.default,Ht=$t;class Node$2{constructor(e,t){this.s_note=e,this.c_note=t,console.assert(null!=this.s_note.softIndex,"s_note softIndex is null"),this.offset=this.s_note.softIndex-this.c_note.softIndex,this._prev=null,this._totalCost=0,this._value=0,this.cacheDirty=!0}get prev(){return this._prev}set prev(e){e!=this._prev&&(this._prev=e,this.cacheDirty=!0)}get si(){return this.s_note.index}get ci(){return this.c_note.index}get root(){return this.prev.root||this}get rootSi(){return this.prev.zero?this.si:this.prev.rootSi}get id(){return`${this.s_note.index},${this.c_note.index}`}static cost(e,t,s){return e*Ht.CostStepAttenuation+Math.tanh(t*Ht.SkipCost)+Math.tanh(.5*s)}updateCache(){this.cacheDirty&&(this._totalCost=Node$2.cost(this.prev.totalCost,this.si-this.prev.si-1,this.selfCost),this._value=this.prev.value+1-Math.tanh(.5*this.selfCost),this.cacheDirty=!1)}get totalCost(){return this.updateCache(),this._totalCost}get value(){return this.updateCache(),this._value}get deep(){return this.prev.deep+1}get path(){const e=[];for(let t=this;!t.zero;t=t.prev)e[t.si]=t.ci;for(let t=0;t=1,"node index error:",this,e);const s=Node$2.cost(e.totalCost,this.si-e.si-1,t);return(!this.prev||s0?Ht.LagOffsetCost:Ht.LeadOffsetCost))**2}return t}priorByOffset(e){const t=Math.abs(this.offset-e)/1;return Math.tanh(this.value*Ht.PriorValueSigmoidFactor)-Math.tanh(t*Ht.PriorDistanceSigmoidFactor)}static zero(){return{zero:!0,totalCost:0,value:0,si:-1,ci:-1,deep:0,offset:0}}}var Vt=Node$2;const zt=$t,qt=Vt;var Gt=class Navigator$1{constructor(e,t,s={}){this.criterion=e,this.sample=t,this.getCursorOffset=s.getCursorOffset||(()=>null),this.outOfPage=s.outOfPage,this.bestNode=null,this.fineCursor=null,this.breakingSI=t.notes.length-1,this.zeroNode=qt.zero(),this.zeroNode.offset=this.getCursorOffset()||0,this.relocationThreshold=s.relocationThreshold||zt.RelocationThreshold}step(e){const t=this.sample.notes[e];if(t.matches.length>0){t.matches.forEach(t=>{t.evaluatePrev(this.zeroNode);for(let s=e-1;s>=Math.max(this.breakingSI+1,e-zt.SkipDeep);--s){const i=this.sample.notes[s];console.assert(i,"prevNote is null:",s,e,this.sample.notes),i.matches.forEach(e=>{const s=t.offset-e.offset;s<2/zt.LagOffsetCost&&s>-2/zt.LeadOffsetCost&&t.evaluatePrev(e)})}if(t.prior=t.totalCost>1.99?-1:t.priorByOffset(this.zeroNode.offset),t.prior>0&&this.outOfPage){const e=this.criterion.notes[t.ci].startTick;this.outOfPage(e)&&(t.prior-=.7)}}),t.matches.sort((e,t)=>t.prior-e.prior),this.cursors=t.matches;let s=null;const i=this.nullSteps(e),r=this.cursors[0];r&&r.totalCost<1&&(r.prior>0||r.totalCost<.4&&Math.log(Math.max(i*r.value,.001))>this.relocationThreshold)&&(this.zeroNode.offset=r.offset,s=r,(!this.bestNode||r.value>this.bestNode.value)&&(this.bestNode=r)),s?this.fineCursor=s:this.resetCursor(e,{breaking:!1})||(this.zeroNode.offset+=t.deltaSi*Math.tanh(i),console.assert(!Number.isNaN(this.zeroNode.offset),"zeroNode.offset is NaN.",t.deltaSi,i))}else this.cursors=[]}path({fromIndex:e=0,toIndex:t=this.sample.notes.length-1}={}){const s=[];let i=null;for(let r=t;r>=e;){const e=this.sample.notes[r];if(!e.matches.length||e.matches[0].prior<-.01||e.matches[0].totalCost>=1){s[r]=-1,--r;continue}null!=i&&(e.matches.forEach(e=>e.backPrior=e.totalCost<1.99?e.priorByOffset(i):-1),e.matches.sort((e,t)=>t.backPrior-e.backPrior));const t=e.matches[0];t.path.forEach((e,t)=>s[t]=e),i=t.root.offset,r=t.rootSi-1}return console.assert(s.length==t+1,"path length error:",s,e,t+1,this.sample.notes.length,this.sample.notes.length?this.sample.notes[this.sample.notes.length-1].index:null),s}nullSteps(e){return e-(this.fineCursor?this.fineCursor.si:-1)-1}resetCursor(e,{breaking:t=!0}={}){t&&(this.breakingSI=e);const s=this.getCursorOffset();return null!=s&&(this.zeroNode.offset=s,this.zeroNode.si=e,this.fineCursor=null,console.assert(!Number.isNaN(this.zeroNode.offset),"zeroNode.offset is NaN.",s),!0)}get relocationTendency(){const e=this.cursors&&this.cursors[0];if(!e)return null;const t=this.nullSteps(e.si);return t<=0?0:Math.log(Math.max(t*e.value,.001))/this.relocationThreshold}};const Wt=Vt,Ut=Gt,Yt=e=>Math.tanh(e/192),Xt=function(e,t,{softIndexFactor:s=1}={}){const i=e[t=Number(t)];if(t>0){const r=e[t-1];console.assert(null!=i.start,"note.start is null",i),console.assert(null!=r.start,"lastNote.start is null",r),i.deltaSi=Yt((i.start-r.start)*s),i.softIndex=r.softIndex+i.deltaSi,console.assert(!Number.isNaN(i.deltaSi),"note.deltaSi is NaN.",i.start,r.start)}else i.softIndex=0,i.deltaSi=0};var Kt={normalizeInterval:Yt,makeNoteSoftIndex:Xt,makeMatchNodes:function(e,t,s=Wt.zero()){e.matches=[];const i=t.pitchMap[e.pitch];if(i)for(const t of i){const i=new Wt(e,t);s&&i.evaluatePrev(s),e.matches.push(i)}},genNotationContext:function(e,{softIndexFactor:t=1}={}){for(let s=0;s"setTempo"==e.subtype)||(n.push({time:t,type:"meta",subtype:"timeSignature",numerator:4,denominator:4,thirtyseconds:8}),n.push({time:t,type:"meta",subtype:"setTempo",microsecondsPerBeat:e.microsecondsPerBeat}));let a=t||0;if(e.notes)for(const t of e.notes)n.push({time:t.start,type:"channel",subtype:"noteOn",channel:t.channel||0,noteNumber:t.pitch,velocity:t.velocity,finger:t.finger}),a=Math.max(a,t.start),Number.isFinite(s)&&(t.duration=t.duration||s),t.duration&&(n.push({time:t.start+t.duration,type:"channel",subtype:"noteOff",channel:t.channel||0,noteNumber:t.pitch,velocity:0}),a=Math.max(a,t.start+t.duration));if(e.events){const t=e.events.filter(e=>!Jt.includes(e.data.subtype));for(const e of t)n.push({time:e.time,...e.data}),a=Math.max(a,e.time)}return n.push({time:a+100,type:"meta",subtype:"endOfTrack"}),n.sort(function(e,t){return e.time-t.time}),n.map((e,t)=>({event:e,index:t})).filter(({event:e})=>"noteOn"==e.subtype&&null!=e.finger).reverse().forEach(({event:e,index:t})=>n.splice(t+1,0,{time:e.time,type:"meta",subtype:"text",text:`fingering(${e.finger})`})),n.forEach(e=>e.ticks=Math.round((e.time-t)*i)),n.forEach((e,t)=>e.deltaTime=e.ticks-(t>0?n[t-1].ticks:0)),{header:r,tracks:[n]}}var es={sliceMidi:(e,t,s)=>({header:e.header,tracks:e.tracks.map(e=>((e,t,s)=>{(e=>{let t=0;e.forEach(e=>{t+=e.deltaTime,e.tick=t})})(e);const i=[],r={};return e.forEach(e=>{e.tick>=t&&e.tick<=s&&"endOfTrack"!==e.subtype?i.push({...e,tick:e.tick-t}):e.ticki.push({...e,tick:0})),i.push({tick:s-t,type:"meta",subtype:"endOfTrack"}),(e=>{let t=0;e.sort((e,t)=>e.tick-t.tick).forEach(e=>{e.deltaTime=e.tick-t,t=e.tick})})(i),i})(e,t,s))}),encodeToMIDIData:Qt,encodeToMIDI:function(e,t){const s=Qt(e,t);return Zt.encodeMidiFile(s)}};var ts={MIDI:Ot,MusicNotation:Rt,MidiPlayer:Lt,Matcher:Kt,MidiUtils:es};const ss=["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 r=t[i],n=t[i+1]?t[i+1]-r:0,a=e.filter(e=>e.measure===i+1).map(e=>({tick:e.startTick-r,duration:e.endTick-e.startTick,...v.default(e,ss),subNotes:[]}));return a.forEach(e=>["rest","tied","implicitType","afterGrace"].forEach(t=>{e[t]||delete e[t]})),{tick:r,duration:n,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 r=e.notes.find(e=>e.track===i);r&&(t[s]=Math.min(r.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,...v.default(s,ss)}));return t+=s.duration,i});return[].concat(...s)}toPerformingNotation(e,t={}){const s=this.toAbsoluteNotes(e),i=MetaNotation.performAbsoluteNotes(s,t),r=Math.max(...i.map(e=>e.start+e.duration)),n=e.reduce((e,t)=>e+this.measures[t-1].duration,0);return new ts.MusicNotation.Notation({ticksPerBeat:480,meta:{},tempos:[],channels:[i],endTime:r,endTick:n})}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 r=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}),n=e=>e.ticks+("noteOff"===e.subtype?-1e-8:0),a=[].concat(...r).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 r=i+s.tick,n=a[s.track]=a[s.track]||[];s.subNotes.forEach(t=>{n.push({ticks:r+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}),n.push({ticks:r+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)=>n(e)-n(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),r=ts.MusicNotation.Notation.parseMidi(i);is(r);let n=s;return r.measures=e.map(e=>{const t=n;return n+=this.measures[e-1].duration,{index:e,startTick:t,endTick:n}}),r}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 is=(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 r=s(e.data.channel,e.data.noteNumber,e.ticks),n=i[r];console.assert(!!n,"cannot find note of",r),n&&Object.assign(n,v.default(e.data,t))}})};var rs,ns={exports:{}},as={exports:{}};as.exports=rs=rs||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.")},r=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),n={},a=n.lib={},o=a.Base={extend:function(e){var t=r(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,r=e.sigBytes;if(this.clamp(),i%4)for(var n=0;n>>2]>>>24-n%4*8&255;t[i+n>>>2]|=a<<24-(i+n)%4*8}else for(var o=0;o>>2]=s[o>>>2];return this.sigBytes+=r,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-r%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).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=[],r=0;r>>2]>>>24-r%4*8&255;i.push(String.fromCharCode(n))}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)))}},f=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,r=i.words,n=i.sigBytes,a=this.blockSize,o=n/(4*a),l=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,u=e.min(4*l,n);if(l){for(var h=0;h>>7)^(d<<14|d>>>18)^d>>>3,g=l[f-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[f]=p+l[f-7]+y+l[f-16]}var v=i&r^i&n^r&n,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[f]+l[f];m=h,h=u,u=o,o=a+S|0,a=n,n=r,r=i,i=S+(x+v)|0}s[0]=s[0]+i|0,s[1]=s[1]+r|0,s[2]=s[2]+n|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,r=8*e.sigBytes;return s[r>>>5]|=128<<24-r%32,s[14+(r+64>>>9<<4)]=t.floor(i/4294967296),s[15+(r+64>>>9<<4)]=i,e.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});s.SHA256=n._createHelper(u),s.HmacSHA256=n._createHmacHelper(u)}(Math),e.SHA256}(as.exports);var os=ns.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}=os(e),i=t.map(e=>e<0?e+4294967296:e),r=s/t.length;return new Uint8Array(s).map((e,t)=>i[Math.floor(t/r)]>>8*(3-t%r)&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 cs=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));cs.reduce((e,t,s)=>({...e,[("0"+s.toString(16)).slice(-2)]:t}),{});const ls=(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+cs[t],0))/s},us=e=>("0"+e.toString(16)).slice(-2);var hs={Matrix:function(){}};hs.Matrix.create=function(e){return(new hs.Matrix).setElements(e)},hs.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 hs.Matrix.create(s)},hs.Matrix.prototype={dup:function(){return hs.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 hs.Matrix.create([]);var e,t,s,i,r=this.dup(),n=this.elements.length,a=this.elements[0].length;for(t=0;t=n&&l[a].push(r);for(o.elements[a]=s,e=a;e--;){for(s=[],t=0;t1===e?null:(e=>{const t=Math.round(1920*e);return Oe(t,1920)})(e);var ds,ps,gs;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(ds||(ds={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:ds.PLACE,e1:e})}static V(e,t,s=1){return new Action({type:ds.VERTICAL,e1:s>0?e:t,e2:s>0?t:e})}static H(e,t){return new Action({type:ds.HORIZONTAL,e1:e,e2:t})}get id(){switch(this.type){case ds.PLACE:return this.e1.toString();case ds.VERTICAL:return`${this.e1}|${this.e2}`;case ds.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===ds.HORIZONTAL).forEach(t=>{const i=e.stages.findIndex(e=>e.events.includes(t.e1)),r=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(i>=0&&r>=0,"invalid stages for H action:",e.id,e.stages,t),s[i][r].add(t.e1)}),s[0][e.stages.length-1].add(0);const i=e.stagedEvents,r=t.matrixH[t.matrixH.length-1].filter((e,t)=>!i.has(t)),n=Math.max(0,Math.max(...r)-.01),a=e.actions.filter(e=>e.type===ds.HORIZONTAL),o=Object.keys(t.eventMap).map(Number).filter(e=>!a.find(t=>t.e2===e));return e.stages.forEach(i=>{i.events.forEach(r=>{if(r>0){!a.find(e=>e.e1===r)&&t.matrixH[t.matrixH.length-1][r]>=n&&(o.some(e=>t.matrixH[e][r]>0)||s[i.index][e.stages.length-1].add(r))}})}),new StageMatrix({matrix:s})}constructor(e){Object.assign(this,e)}pathOf(e,t,s,i=0){if(this.matrix[e][t].size){const r=[...this.matrix[e][t]][i];if(t===s)return[r];for(let e=t+1;e<=s;++e){const i=this.pathOf(t,e,s);if(i)return[r,...i]}}return null}findDoublePath(e,t){const s=[];for(let i=t;i>=e+1;--i)for(let r=0;rt.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let s=1;sn[e]=1),r.forEach(e=>n[e]=-1),t.push(n),this.reducePath(i.length>r.length?i:r)}}}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 ds.PLACE:this.stages.unshift({events:[t.e1]});break;case ds.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 ds.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 r=s=>{console.assert(e.eventMap[s],"invalid event id:",t.id,s,e.eventMap);const i=e.eventMap[s].x,r=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(r)r.events.push(s);else{const t={events:[s]},r=this.stages.findIndex(t=>-1===t.events[0]||e.eventMap[t.events[0]].x>=i);this.stages.splice(r,0,t)}};s||r(t.e1),i||r(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),r=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const n=t<0?e.map(e=>-e):e;if(n[0]>0)continue;r.push(n),n.forEach((e,t)=>{i[t]=i[t]||e<0,e&&(s[t]=e<0||i[t])})}}return this.constraints.forEach(e=>{0!==e.reduce((e,t)=>e+t,0)||e[0]||e.some((e,t)=>e&&!s[t])&&(e.forEach((e,t)=>e&&(s[t]=!1)),r.push(e))}),{ones:s,inbalances:r}}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])),r=new Map;let n=!1;const a=t.map(e=>({line:e.filter((e,t)=>s.includes(t)),bias:-e.reduce((e,t,i)=>e+(s.includes(i)?0:t),0)})).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const s=e.join(",");return r.has(s)?(n=r.get(s)!==t,!1):(r.set(s,t),!0)});if(n)return null;const o=a.slice(0,s.length),c=a.slice(s.length);if(o.lengths===t?1:s===r?-1:0),bias:0,prior:(i[t]+i[r])/ms};o.some(e=>e.line[t]&&e.line[r])&&(n.prior-=10),o.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[r]))&&(n.prior+=1),e.push(n)}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=hs.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 f=e.map(()=>1);return s.forEach((e,t)=>f[e]=m[t]),f}optimallySolve(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e),i=t.map((t,s)=>t?-1:Ne(e.eventMap[s].shrinkness,.01)).reduce((e,t,s)=>(t>=0&&(e[t]=e[t]||[],e[t].push(s)),e),{}),r=Object.entries(i).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let i=1;i!n.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){if(i.reduce((s,i,r)=>s+i*(t[r]||i<=0?1:e.eventMap[r].lowWarp),0)>=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===ds.HORIZONTAL).sort((e,s)=>t(e)-t(s)),i=s.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),r=new Set([...Object.keys(i)].map(Number));s.forEach(e=>r.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&r.add(e));let n=[...r].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=>n.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=fs(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)),r=this.stages.find(e=>e.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(r.tick)&&(r.tick=i.tick+Ae(e.eventMap[s.e1].duration,o[s.e1].timeWarp),r.events.forEach(e=>o[e]&&(o[e].tick=r.tick)),t=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),r=this.stages.find(e=>e.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(r.tick)&&(i.tick=r.tick-Ae(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+Ae(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;n.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})}}),n=n.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:n,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,r=this.stagedEvents,n=[],a=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!n.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===ds.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===ds.HORIZONTAL&&t.index>i.index)return;if(e.action.type===ds.HORIZONTAL&&this.actions.some(t=>t.type===ds.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===ds.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}n.push(e)}};for(const e of r)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 r=s[e];r>0&&a({action:Action.H(e,i),possibility:r})}));n.some(e=>[ds.HORIZONTAL,ds.PLACE].includes(e.action.type)||!r.has(e.action.e1)||!r.has(e.action.e2))?this.children=n.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},r=this.pathRoot.deduce(i,s);if(r.credits=this.quota-s.credits,r.times=s.times,this.evaluateSolution(r),this.logger.debug("loss:",r.loss),e=!e||r.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,n=t[s.id].shrinkness;r.set(e,Math.max(r.get(e)||0,1-n)),r.set(i,Math.max(r.get(i)||0,1-n))}});const n=Oe(e.duration,this.eventMap[0].duration);r.set(n.numerator,Math.max(r.get(n.numerator)||0,1-this.eventMap[0].shrinkness)),r.set(n.denominator,Math.max(r.get(n.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,s]of r.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),r=t[s[s.length-1]].endTick;a+=Math.max(0,i+e.duration-r);let n=null;s.forEach(e=>{const s=t[e];s.staff!==n&&(null!==n&&++o,n=s.staff)})}),e.loss+=10*a/ms,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],r=t.x-i.x,n=t.tick-i.tick;if(!n)return r/this.xSpan;return(4*Math.atan2(n/e.duration,r/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,r,a,o),e.loss<0&&(e.loss=1/0)}}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[e.PAD=0]="PAD",e[e.BOS=1]="BOS",e[e.EOS=2]="EOS",e[e.CHORD=3]="CHORD",e[e.REST=4]="REST"}(ps||(ps={}));class EventCluster extends SimpleClass{constructor(e){super(),super.assign(e)}get regular(){return this.elements.some(e=>[ps.CHORD,ps.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===ps.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",function(e){e.computeMeasureTicks=e=>{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),r=Math.min(...i.map(e=>e.left)),n=Math.max(...i.map(e=>e.right));return Math.min(n,e.right)-Math.max(r,e.left)>.62*w.NoteheadS1})||s,e.roundX=i;const r=t.get(i)||[];t.set(i,r),r.push(e)}),t})(e);let s=0;const i=new Set([s]),r=[...t.entries()].sort(([e],[t])=>e-t);for(const[e,t]of r)t.forEach(e=>{e.predisposition&&(e.rest=e.rest&&e.predisposition.fullMeasure>.5?"R":e.rest,e.grace=e.predisposition.grace?Ve.Grace:null,e.division=$e(e.predisposition.divisionVector),e.dots=$e(e.predisposition.dotsVector),e.predisposition.timeWarped>.5&&(e.timeWarp=_e(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 r=[],n=e=>{r.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),n(a);;){const e=s.find(e=>i.has(e)&&e.alignedTick===t);if(!e)break;n(e)}e.voices.push(r)}}}}(gs||(gs={}));var ys;!function(e){const t=1921920,s=.7071067811865475,i=[[null,null],[null,ze.Open],[ze.Open,ze.Continue],[ze.Open,ze.Close],[ze.Continue,ze.Continue],[ze.Continue,ze.Close],[ze.Close,null],[ze.Close,ze.Open]].map(e=>e.join("-")),r=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};e.estiamteMeasure=e=>{const r=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/je,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 n=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(n=Math.max(n,Ne(e.estimatedDuration,480480)));const a=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),o=[0,...r.map(e=>e.id)],c=r.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=>S.default(e/1.6)*S.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-S.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,r=t.x-e.x,n=t.tipX-e.tipX;l[t.id][e.id]=(s*i*Math.min(h(r),h(n)))**(1/3)}const r=(1-t.pR)*(1-e.pR);u[t.id][e.id]*=r,l[t.id][e.id]*=r,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:n,measureShrinkness:0,endX:e.position.right,matrixH:l,matrixV:u}},e.regulateMeasure=async(s,{solver:i=null,...n})=>{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 r=s.matrixV[o[t]][o[i]];Number.isFinite(r)&&(l[t][i]=r)})),Number.isFinite(s.estimatedDuration)&&(a.measureShrinkness=Math.tanh(-3*Math.log(Math.min(1,s.estimatedDuration/s.duration)))),n.logger&&n.logger.info("--- MEASURE",s.measureIndex,"---",a);const u=i?await i(a,n):r(a,n),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*je/t):null,i.tickGroup=e.tickGroup,i.timeWarp=e.timeWarp}),s.duration=Math.round(u.duration*je/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:n=null,...a})=>{const o=e.events.filter(e=>!e.zeroHolder).map(s=>{const r=i.events.find(e=>e&&e.id===s.id),n=Number.isFinite(r?.division)?r.division:s.division,a=Number.isFinite(r?.dots)?r.dots:s.dots,o=t*2**-n*(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,Ne(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)),f=Array(u.length).fill(null).map(()=>Array(u.length).fill(0));for(const e of h)for(const t of h){f[e.id][t.id]=e!==t&&e.tickEstimated>=t.tickEstimated?1-S.default((e.tickEstimated-t.tickEstimated)*s/.6):0;const i=(1-e.pR)*(1-t.pR);f[e.id][t.id]*=i,f[e.id][t.id]<.01&&(f[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*je/t):s;return{id:e,tick:o,tickGroup:r,timeWarp:n,division:a?.division,dots:a?.dots}}),x=Math.round(g.duration*je/t);return{events:v,voices:g.voices,duration:x,priority:y}}}(ys||(ys={}));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 r=0;const n=s.map((e,t)=>(!t||s[t]-s[t-1]<.5||++r,r)),a=i.map(t=>new EventTerm({...e.find(e=>e.id===t.id),intX:t.rx,intY:n[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=>[Ue.TimeSignatureC,Ue.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 r=t[i],n=e.pivotX-r.pivotX,a=e.tick-r.tick;if(!a)return n/s;return(4*Math.atan2(a/this.duration,n/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(){return this.regulated&&this.events.some(e=>!e.zeroHolder&&!Number.isFinite(e.tick)&&!e.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 y.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),r=e?[]:i.map(e=>e.map(e=>e.scaleChord).join("-")),n=e?[]:i.map(e=>e.map(e=>e.division).join(""));return this.timeSignature&&n.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[s,r,n]}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=Ae(je,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 r=0;return t[s].forEach(e=>{e.tick>r&&(e.preTick=r,r=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===qe.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 r=Math.max(e.tremolo||3,t.tremolo||3);e.tremolo=r,t.tremolo=r,t.tick||(t.tick=e.tick+e.duration/2);const n=s.indexOf(e);n>=0&&s.splice(n,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),s.beam&&(t.beam=s.beam),void 0!==s.grace&&(t.grace=s.grace?Ve.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(){gs.computeMeasureTicks(this),gs.computeMeasureVoices(this)}async regulateEquations(e){await ys.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,r=this.events.filter(e=>t.includes(e.staff));if(!r.length)return null;const n=r.map(s=>({index:s.id,voice:(this.voices||[]).findIndex(e=>e.includes(s.id)),type:s.rest?ps.REST:ps.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(!n.some(e=>!e.fake))return null;const a=Ae(je,this.timeSignature);n.unshift({index:0,type:ps.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.durationn.map(()=>0)),this.voices.forEach(e=>{let t=0;e.forEach(e=>{const s=n.findIndex(t=>t.index===e);s>0&&t>=0&&(o[s][t]=1),t=s}),t>=0&&(o[n.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:n,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?Ve.Grace:null))})}),this.estimatedDuration=e.reduce((e,t)=>e+t.estimatedDuration,0)/e.length}}SpartitoMeasure.className="SpartitoMeasure",SpartitoMeasure.blackKeys=["staffGroups","solutionStat","measureNumber","deposit"];const vs=(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:[]}),xs=e=>{const t=[].concat(...e.measures.map(e=>Object.values(e.tickMap).filter(e=>e instanceof EventTerm)));for(let e=1;ee.type===B.SlurBegin)&&i.accessories.some(e=>e.type===B.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===B.SlurBegin);e>=0&&s.accessories.splice(e,1);const t=i.accessories.findIndex(e=>e.type===B.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),r=i>=0?s+i:e.length;e.slice(s,r-1).some(e=>e.ve)&&(t.leftSign="2*[")}if(t.ve){const i=e.slice(0,s+1).reverse(),r=i.slice(1).findIndex(e=>e.ve);if(r>=0&&!i.slice(1,r+1).some(e=>e.vb))return;if(t.alter){const r=i.findIndex(e=>!e.alter);r>0&&(i[r].rightSign="]",i[r-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(Ke).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,...Ke(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&&Be(e.timeSignature)!==Be(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:",`${Be(t)} -> ${Be(s)}`,i.map(e=>e.measureIndex))}return}const s=t[0].timeSignature,i=Number.isInteger(Math.log2(s.denominator));let r=i?4:8;i&&(r=Math.max(r,t[0].timeSignature.denominator));const n=t.map(e=>Math.round(e.estimatedDuration*r/je)),a=Object.entries(n.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 n=Number(c[0]);if(!i||s.denominator*n!==s.numerator*r){if(i&&r!==s.denominator){const e=n*s.denominator/r;Number.isInteger(e)&&(n=e,r=s.denominator)}const a=t.filter(e=>!e.patched),o=_e(n,r);a.forEach(e=>e.basics.forEach(e=>e.timeSignature=o)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by estimation:",`${Be(s)} -> ${n}/${r}`,a.map(e=>e.measureIndex))}}})}makeVoiceStaves(){this.regulate();const e=Math.max(...this.measures.map(e=>e.voices.length));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)})});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 r=null;if(t.barType)switch(t.barType){case"Segment":r="||";break;case"Terminal":r="|."}const n=t.voices.map(e=>{const n=e.map(e=>s[e]);n.sort((e,t)=>e.tick-t.tick);const a={};let o=0,c=null;for(const e of n)Number.isFinite(e?.tick)?(e.tick>o?a[o]=EventTerm.space({tick:o,duration:e.tick-o}):!e.grace&&e.tick{const s=t.eventMap[e];s&&(a[s.tick]=s)}))):console.warn("invalid event tick:",e);t.endEvent&&t.endEvent.graceIds&&t.endEvent.graceIds.forEach(e=>{const s=t.eventMap[e];!s||c&&s.staff!==c.staff||(a[s.tick]=s)}),ot.duration&&Number.isFinite(t.duration)&&(c.timeWarp=Oe(t.duration-c.tick,c.duration)),console.assert(!c||!c.timeWarp||Number.isInteger(c.timeWarp.numerator)&&Number.isInteger(c.timeWarp.denominator),"invalid time warp:",c);const l=n[0]?n[0].staff:0;i.delete(l);const u=t.basics[l],h=t.contexts[l],m=n[n.length-1],f=m?m.staff:0;return{tickMap:a,duration:t.duration,...u,contextedTerms:h,marks:[],break:t.break,pageBreak:t.pageBreak,headStaff:l,tailStaff:f,bar:r}});for(;n.lengtht.headStaff!==e),o=vs({terms:r,duration:t.duration,...s,break:t.break,pageBreak:t.pageBreak},a);o.headStaff=e,o.tailStaff=e,n.push(o)}return n});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 r=new Set(e);i.forEach(e=>{const i=[...r];let n=i[0];if(t>0&&i.length>1){const t=i.map(t=>s[t.headStaff]===s[e.headStaff]?ls(e.vector.toHash(),t.trait.toHash()):-1);n=i[$e(t)]}r.delete(n),n.voiceIndex=e.index,e.vector.scale(.4).add(n.trait),e.weight=Object.keys(n.tickMap).length,0===t&&(e.headStaff=n.headStaff)}),e.sort((e,t)=>e.voiceIndex-t.voiceIndex)});const r=Array(this.stavesCount).fill(null).map(()=>[]);i.forEach(e=>{r[e.headStaff].push(e.index)});const n=Array(this.stavesCount).fill(null).map((e,s)=>{if(!t[0])return{voices:[]};return{voices:r[s].map(e=>({mode:"relative",measures:t.map(t=>t[e])}))}});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={}}))})})(n),n.forEach(e=>e.voices.forEach(xs)),n}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 r=!1,n=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=n;n+=h.duration;const f=[].concat(...u.map((e,s)=>{const r=i[s],n=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(...n.map(e=>{const t=e.pitches.reduce((e,t)=>(e[Le(t)]=t,e),{});return Object.values(t).sort((e,t)=>e.note-t.note).filter(e=>!e.tied).map((t,s)=>{const i=Le(t),n=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:n,ids:[n],track:e.part,staff:e.staff,channel:r,subNotes:[{startTick:0,endTick:e.duration,pitch:i,velocity:127}]}})}))})),d=[];a=a||d,s.marks&&s.marks.forEach(e=>{if(e instanceof TempoTerm){const t=e.bpm;if(e.isValid()){const s=r?d:a,i=r?e.tick:0;s.push({track:0,ticks:i,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/t)}}),r=!0}}});const p=s.basics[0];return{tick:m,duration:s.duration,notes:f,events:d,timeSignature:p&&p.timeSignature,keySignature:p&&p.keySignature}});r||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,r=Math.round(s.estimatedDuration||Ae(je,s.timeSignature)),n=s.basics[0];t+=r;const{systemIndex:a,right:o}=s.position,c=s.measureIndex;return{tick:i,duration:r,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 r=Le(e),n=t.noteIds&&t.noteIds[i],a=this.staffGroups.findIndex(e=>e.includes(t.staff));return{tick:s,pitch:r,duration:t.duration,chordPosition:{index:i,count:t.pitches.length},tied:e.tied,id:n,ids:[n],track:a,staff:t.staff,channel:0,subNotes:[{startTick:0,endTick:t.duration,pitch:r,velocity:127}]}})}).flat(1),events:[],timeSignature:n&&n.timeSignature,keySignature:n&&n.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),r=s.map(e=>e[1]).flat(1),n=s.map(e=>e[2]).flat(1),[a,o,c]=[i,r,n].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(us).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 Ss=[0,2,4,5,7,9,11],bs=e=>{let t=e%7;for(;t<0;)t+=7;return t},ks=e=>{let t=e%12;for(;t<0;)t+=12;return t},Ts={[-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 Ue.Clef:this.clef=e.clef;break;case Ue.KeyAcc:this.keyAlters[bs(this.yToNote(e.y))]=e.alter;break;case Ue.Acc:this.alters[this.yToNote(e.y)]=e.alter;break;case Ue.OctaveShift:this.octaveShift=e.octaveShift;break;case Ue.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 Ue.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=ks(e),r=Ss.includes(i)?i:ks(i-t),n=Ss.indexOf(r);this.logger.assert(n>=0,"invalid preferredAlter:",e,t,r);const a=7*s+n,o=i-r,c=this.keyAlters[n]||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=bs(e);return Number.isInteger(this.keyAlters[t])?this.keyAlters[t]:0}noteToPitch(e){const t=Math.floor(e/7),s=bs(e),i=60+12*t+Ss[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=bs(t);let r=this.alterOnNote(t);return r||Number.isInteger(this.alters[t])||(r=null),`${Ts[r]?Ts[r]:""}${"CDEFGAB"[i]}${s+4}`}}const ws=e=>e.reduce((e,t,s)=>t?e|1<{if(e.version<3){const{version:t,stavesCount:s,layoutTemplate:i,...r}=e;let n=s>1?Array(s-1).fill(",").join(""):"";2===s&&(n="{-}"),e={version:3,staffLayoutCode:n,...r}}return e.version<8&&(e.pages.forEach(e=>{e.systems.forEach(e=>{if(e.semantics){const t=e.semantics.filter(e=>e.semantic===g.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 y.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,r)=>{const n=i.rows[s];console.assert(n,"[eventSystemsToTermStaves] measure is null:",s,i.rows);const a=n.contexts;0===r&&(a.some(e=>e.type===Ue.OctaveShift)||a.unshift(new ContextedTerm({staff:s,x:0,y:0,tokenType:B.OctaveShift0,tick:0})));const o=[...n.events||[],...a].sort((e,t)=>e.x-t.x),c=0===s&&r===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=je*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,r=.5*s.height/t;this.pages.forEach(e=>{const n=i-e.width/2,a=r-e.height/2;e.systems.forEach(e=>{e.left+=n,e.top+=a}),e.semantics&&e.semantics.forEach(e=>{e.x+=n,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:r.left,right:r.right,measures:n}}t-=s.measureCount}return null}getRawCluster(e,t,{timeSignature:s}={}){const i=this.getMeasure(e);if(!i)return null;const{system:r,left:n,right:a}=i,o=[kt];s&&o.push(...Tt(s));const c=r.staves[0].top+r.staves[0].staffY-2;return r.staves.forEach(e=>{let s=r.qualifiedSemantics(e.semantics,t).filter(e=>e.x>n&&e.xe.semantic===g.TempoNotehead).forEach(e=>{const t=s.findIndex(t=>/^Notehead/.test(t.semantic)&&Ie(e,t)<.3);t>=0&&s.splice(t,1)});const i=e.top+e.staffY-c;s.forEach(t=>{const s=ot[t.semantic];if(s){let r=t.y,a=t.y;s===ot.vline_Stem&&(r=t.extension.y1,a=t.extension.y2),o.push({id:t.id,type:s,staff:e.index,x:t.x-n,y1:r+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:r,keySignature:n,doubtfulTimesig:a}=e.rows[t][i];return{timeSignature:s,timeSigNumeric:r,keySignature:n,doubtfulTimesig:a}})})});const i=[].concat(...t.map(e=>e.columns.map(t=>{const s=t.measureIndex,{system:i,localIndex:r,left:n,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===r&&i.indent;return new SpartitoMeasure({measureIndex:s,staffMask:e.staffMask,position:{systemIndex:i.index,localIndex:r,left:n,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})}))),r=this.staffLayout,n=r.standaloneGroups.map(e=>e.map(e=>r.staffIds.indexOf(e)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:n,measures:i}),this.spartito}makeMusicSheet(){const e=this.spartito||this.makeSpartito();e.regulated||console.warn("[makeMusicSheet]\tspartito not regulated.");const t=e.makeVoiceStaves(),{title:s,pageSize:i,unitSize:r,staffLayout:n,paperOptions:a,headers:o,instrumentDict:c}=this;return{title:s,pageSize:i,unitSize:r,measureLayout:this.getMeasureLayout(),staffLayout:n,paperOptions:a,headers:o,voiceStaves:t,instrumentDict:c}}findPoint(e){for(const t of this.systems)for(let s=0;st.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,r=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,r]=Number.isFinite(e.extension?.y1)?[e.extension.y1,e.extension.y2]:[e.y,e.y];return{...e,staff:t,sy1:i+s,sy2:r+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((r,n)=>{r.index=n,r.headMeasureIndex=i,r.prev=this.systems[n-1]||null,r.next=this.systems[n+1]||null,r.semantics&&r.semantics.length&&r.semantics.forEach(e=>((e,i,r)=>{const n=_(e,i,r);t.assert(!s.has(n),"semantic point hash conflicted:",n,r,s.get(n)),s.set(n,r)})(n,null,e)),r.assemble(e,t),i+=r.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=>_(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,r)=>e.measures.forEach(e=>{const n=s.indexOf(`${i}|${r}`);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 Ee(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},{}),r=Math.max(...Object.values(i)),n=Object.entries(i).find(([e,t])=>t===r)[0].replace(/\{,*\}/g,e=>e.replace(/,/g,"-")),a=Ee(n);this.staffLayoutCode=n;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 ws(s);for(const i of[1,0]){const r=[...s,i],n=a.partialMaskCode(r);if(n===t.bracketsAppearance)return ws(r);if(t.bracketsAppearance.startsWith(n)){const t=e(r);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&&Ke(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=fe(e);return t?.data?ae(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}))})}),n=t.deepCopy();n.headers.SubScoreSystem=`${s}-${i-1}`,n.headers.SubScorePage=`${r[0].index}-${r[r.length-1].index}`,n.pages=r,n.assemble(),n.inferenceStaffLayout(),s=i,yield n}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}Score.className="Score";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"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?Ve.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"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","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),r=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:Le(t),velocity:96},{id:e.id,time:e.tick+e.duration,type:"channel",subtype:"noteOff",channel:e.staff,noteNumber:Le(t)}])).flat(2);return r.sort(function(e,t){return e.time-t.time}),0===s&&r.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}),r.forEach(e=>{e.ticks=Math.round(e.time-0)}),r.forEach((e,t)=>{e.deltaTime=e.ticks-(t>0?r[t-1].ticks:0)}),r.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),r});return{header:{formatType:0,ticksPerBeat:480},tracks:s}}}var Ms;EditableMeasure.className="EditableMeasure",EditableMeasure.blackKeys=[],function(e){e.Pass="i",e.Division="d",e.Dots="o"}(Ms||(Ms={}));const Es=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],Ns=.4/je,Is=1e-12,Cs=[void 0,"u","d"],_s=[void 0,ze.Open,ze.Continue,ze.Close],Os=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):$e(e)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(e){switch(this.type){case Ms.Pass:return`i_${e}`;case Ms.Division:return Es[e];case Ms.Dots:return"o"+".".repeat(e)}return""}async deduce({picker:e,logger:t,ptFactor:s},i=0){++this.accessCount;const r=this.nextBranch();if(t.debug(String.fromCodePoint(127817)+" ".repeat(i),this.branchID(r),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(r)||r<0)return this.accessCount=1/0,As(this.cluster,this.currentElem.order+1,this.pretentiousness);var n;if(this.pretentiousness+=(n=this.possibilities[r],Math.min(100,-Math.log(n))),this.pretentiousness>100*s)return this.accessCount=1/0,As(this.cluster,this.currentElem.order+1,this.pretentiousness);let a=null;switch(this.type){case Ms.Pass:{const t=this.currentElem.order+1,s=this.cluster.elements[r];if(console.assert(s,"null element:",r,this.cluster.elements.length),s.type===ps.EOS){if(a=As(this.cluster,t,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(this.cluster.elements[0].order=t,!this.children[r]){if(!e.quota)return a;const s=(await e.predictCluster(this.cluster,t+1)).map((e,s)=>this.cluster.elements[s].orderMath.max(Is,e));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:r,type:Ms.Division,possibilities:e,pretentiousness:this.pretentiousness})}}break;case Ms.Division:if(this.currentElem.division=r,!this.children[r]){const e=this.currentElem.predisposition.dotsVector.map(e=>Math.max(Is,e));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:Ms.Dots,possibilities:e,pretentiousness:this.pretentiousness})}break;case Ms.Dots:if(this.currentElem.dots=r,a=As(this.cluster,this.currentElem.order+1,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(!this.children[r]){if(!e.quota)return a;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=a.endTick,a}return o}}const Bs=e=>je*2**-e.division*(2-2**-e.dots),As=(e,t,s)=>{const i=e.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isInteger(e.order)&&e.ordere.order-t.order);const r=e.elements[e.elements.length-1];let n=0,a=0,o=0,c=1;const l=[[r.x,e.signatureDuration,e.signatureDuration]];let u=0;i.forEach(e=>{e.order>a+1&&(n=0,++c);const t=l.find(e=>e[1]>=n);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=Bs(e);e.predisposition.timeWarped>.5&&(i=2*i/3),n+=i,u+=i,o=Math.max(o,n),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),f=[...i].sort((e,t)=>e.pivotX-t.pivotX),d=f.slice(1).map((e,t)=>{const s=f[t],i=e.pivotX-s.pivotX,r=e.tick-s.tick;if(!r)return i/h;return(4*Math.atan2(r/m,i/h)/Math.PI-1)**2}),p=Math.max(...d,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=>[ps.CHORD,ps.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/je+p+.2*v+.002*c+S*Ns+.02*s}},Ps=async(e,t,s,i=200,r=0,n=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:Ms.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:n});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=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isInteger(e.order)),h=e.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&!Number.isInteger(e.order));u.length&&h.forEach(e=>{if(e.tick=void 0,e.predisposition.fakeP<.5){const t=Bs(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=Cs[$e(e.predisposition.stemDirectionVector)],e.beam=_s[$e(e.predisposition.beamVector)]});const m=e.elements.map(e=>e.index),f=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:r=5,ptFactor:n=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*r));a.info(`[measure-${e.measureIndex}]`,c);const{loss:u}=await Ps(l,t.picker,a,c,s,n);o=Math.max(o,u)}const l=[],u=[],h=[];c.forEach(t=>{const s=t.elements.filter(e=>[ps.CHORD,ps.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 r=0;s.forEach(e=>{e.fullMeasure||e.grace||e.tremoloCatcher||(e.order>r+1?(i=[e.index],l.push(i)):i.push(e.index),r=e.order)});let n=s[s.length-1];const a=t.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isFinite(e.tick)&&!Number.isInteger(e.order));for(;a.length;){const e=a.findIndex(e=>e.tick>=n.tick+Bs(n));e>=0?i.push(a.splice(e,1)[0].index):(n=a.splice(0,1)[0],i=[n.index],l.push(i))}if(s.some(e=>!e.fullMeasure&&Number.isInteger(e.order))){const e=t.elements.find(e=>e.type===ps.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?_e(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}},Ds=async(e,{picker:t,resetSignatureForDoubtfulOnly:s})=>{const i=e.createClusters(),r=e.eventMap;for(const n of i)s&&!e.doubtfulTimesig||(n.signatureDuration=0),n.elements.forEach((e,t)=>e.order=t?void 0:0),await t.predictCluster(n,1),n.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)).forEach(e=>{r[e.index].predisposition=e.predisposition});e.estimatedDuration=Math.max(...i.map(e=>e.estimatedDuration))},Fs=async(e,t)=>Ds(e,{picker:t,resetSignatureForDoubtfulOnly:!0});var Ls=Object.freeze({__proto__:null,solveCluster:Ps,solveMeasure:Rs,estimateMeasure:Fs,glimpseMeasure:Ds}),$s=Object.freeze({__proto__:null,beadSolver:Ls,get PageLayoutMethod(){return d},get TextType(){return p},TokenTypes:P,TokenClefs:R,TokenTimesigs:D,TokenTimesigsC:F,TokenTimesigsN:L,TokenOctshifts:$,TokenNumbers:j,TokenAccidentals:H,TokenNoteheads:V,TokenBareNoteheads:z,TokenDirectionalNoteheads:q,TokenRests:G,TokenFlags:W,TokenVolta:U,TokenDynamics:Y,TokenScripts:X,TokenPedals:K,TokenDots:Z,TokenArcs:J,TokenBeams:Q,TokenWedges:ee,TokenAccessories:te,TokenDirectionless:se,TokenGlyphs:ie,get TokenType(){return B},Token:Token,TextToken:TextToken,TOKEN_Y_ROUND:re,TOKEN_Y_FIXED:ne,VERSION:14,Score:Score,Page:Page,System:System,Staff:Staff,Measure:Measure,emptyVoiceFromStaffMeasure:vs,SpartitoMeasure:SpartitoMeasure,Spartito:Spartito,EditableEvent:EditableEvent,EditableMeasure:EditableMeasure,Term:Term,EventTerm:EventTerm,ContextedTerm:ContextedTerm,MarkTerm:MarkTerm,TempoTerm:TempoTerm,GlyphTerm:GlyphTerm,TextTerm:TextTerm,LyricTerm:LyricTerm,CommandTerm:CommandTerm,ChordmodeTerm:ChordmodeTerm,get ContextType(){return Ue},get GraceType(){return Ve},get GlissandoStyle(){return Ge},get ArpeggioStyle(){return We},get AccessoryDirection(){return He},WHOLE_DURATION:je,get StemBeam(){return ze},get TremoloLink(){return qe},mod7:bs,get SemanticType(){return g},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:I,STAMP_SEMANTICS:C,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:_,hashPageSemanticPoint:O,SemanticGraph:SemanticGraph,get SemanticElementType(){return ot},SemanticCluster:SemanticCluster,SemanticClusterSet:class SemanticClusterSet{constructor(e){if(e&&(this.clusters=e.clusters,e.vocab)){const t=e.vocab.map((e,t)=>[t,ot[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(ot).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}},ELEMENT_TOKEN_NAMES:ht,NOTEHEAD_ELEMENT_TYPES:ft,NOTE_ELEMENT_TYPES:gt,BOS_ELEMENT:kt,fractionToElems:Tt,expandMatrixByMasks:Mt,expandMatrixByMaskTriu:Et,matrixFromGroups:Nt,get EventElementType(){return ps},EventCluster:EventCluster,EventClusterSet:EventClusterSet,recoverJSON:ae,SimpleClass:SimpleClass,PatchMeasure:PatchMeasure,evaluateMeasure:Ke});const js=[B.ClefG,B.ClefF,B.ClefC],Hs=e=>{let t=null;switch(e.tokenType){case B.ClefG:t="Treble";break;case B.ClefF:t="Bass";break;case B.ClefC:t=-1===e.y?"Tenor":"Alto"}return t};var Vs,zs={exports:{}},qs="object"==typeof Reflect?Reflect:null,Gs=qs&&"function"==typeof qs.apply?qs.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};Vs=qs&&"function"==typeof qs.ownKeys?qs.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Ws=Number.isNaN||function(e){return e!=e};function Us(){Us.init.call(this)}zs.exports=Us,zs.exports.once=function(e,t){return new Promise(function(s,i){function r(s){e.removeListener(t,n),i(s)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",r),s([].slice.call(arguments))}ii(e,t,n,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&ii(e,"error",t,s)}(e,r,{once:!0})})},Us.EventEmitter=Us,Us.prototype._events=void 0,Us.prototype._eventsCount=0,Us.prototype._maxListeners=void 0;var Ys=10;function Xs(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Ks(e){return void 0===e._maxListeners?Us.defaultMaxListeners:e._maxListeners}function Zs(e,t,s,i){var r,n,a,o;if(Xs(s),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),n=e._events),a=n[t]),void 0===a)a=n[t]=s,++e._eventsCount;else if("function"==typeof a?a=n[t]=i?[s,a]:[a,s]:i?a.unshift(s):a.push(s),(r=Ks(e))>0&&a.length>r&&!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 Js(){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 Qs(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},r=Js.bind(i);return r.listener=s,i.wrapFn=r,r}function ei(e,t,s){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?s?[r.listener||r]:[r]:s?function(e){for(var t=new Array(e.length),s=0;s{s=e,i=r,t>=0&&setTimeout(i,t,"timeout")}),s,i]}Object.defineProperty(Us,"defaultMaxListeners",{enumerable:!0,get:function(){return Ys},set:function(e){if("number"!=typeof e||e<0||Ws(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ys=e}}),Us.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},Us.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Ws(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},Us.prototype.getMaxListeners=function(){return Ks(this)},Us.prototype.emit=function(e){for(var t=[],s=1;s0&&(n=t[0]),n instanceof Error)throw n;var a=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw a.context=n,a}var o=r[e];if(void 0===o)return!1;if("function"==typeof o)Gs(o,this,t);else{var c=o.length,l=si(o,c);for(s=0;s=0;n--)if(s[n]===t||s[n].listener===t){a=s[n].listener,r=n;break}if(r<0)return this;0===r?s.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},Us.prototype.listeners=function(e){return ei(this,e,!0)},Us.prototype.rawListeners=function(e){return ei(this,e,!1)},Us.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):ti.call(e,t)},Us.prototype.listenerCount=ti,Us.prototype.eventNames=function(){return this._eventsCount>0?Vs(this._events):[]};class AsyncQueue extends zs.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,r]=e;await t(s).then(i,r),this.tasks.length>0?await this._digest(this.tasks.shift()):(this.working=!1,this.emit("idle"))}addTask(e,{timeout:t=6e5}={}){const[s,i,r]=ri({timeout:t});return this.working?this.tasks.push([...e,i,r]):this._digest([...e,i,r]),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(r.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[i,n]=Array.isArray(t)?[t,s]:[void 0,t],a={method:e};return i&&(a.args=i),n&&(a.kwargs=n),this.queue.addTask([async e=>{const[t]=await this.__request(e),s=r.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 a.getPortPromise({port:12022,stopPort:12122}),i=s.defaultsDeep({args:[...this.options.args||[],"-p",`${t}`]},this.options);this.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`),this.pyShell=new o.PythonShell(this.scriptPath,i),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 ni={},ai=function(e){return e instanceof Buffer},oi={exports:{}},ci={exports:{}};"function"==typeof Object.create?ci.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:ci.exports=function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e};try{var li=require("util");if("function"!=typeof li.inherits)throw"";oi.exports=li.inherits}catch(e){oi.exports=ci.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(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}}),c=r[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=n.styles[t];return s?"["+n.colors[s][0]+"m"+e+"["+n.colors[s][1]+"m":e}function o(e,t){return e}function c(t,s,i){if(t.customInspect&&s&&b(s.inspect)&&s.inspect!==e.inspect&&(!s.constructor||s.constructor.prototype!==s)){var r=s.inspect(i,t);return p(r)||(r=c(t,r,i)),r}var n=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(d(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(f(t))return e.stylize("null","null")}(t,s);if(n)return n;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(b(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 k,T="",w=!1,E=["{","}"];(h(s)&&(w=!0,E=["[","]"]),b(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),k=w?function(e,t,s,i,r){for(var n=[],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]}(k,T,E)):E[0]+T+E[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function u(e,t,s,i,r,n){var a,o,l;if((l=Object.getOwnPropertyDescriptor(t,r)||{value:t[r]}).get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),M(i,r)||(a="["+r+"]"),o||(e.seen.indexOf(l.value)<0?(o=f(s)?c(e,l.value,null):c(e,l.value,s-1)).indexOf("\n")>-1&&(o=n?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(n&&r.match(/^\d+$/))return o;(a=JSON.stringify(""+r)).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 f(e){return null===e}function d(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]"===k(e)}function v(e){return"object"==typeof e&&null!==e}function x(e){return v(e)&&"[object Date]"===k(e)}function S(e){return v(e)&&("[object Error]"===k(e)||e instanceof Error)}function b(e){return"function"==typeof e}function k(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(),!r[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var s=process.pid;r[t]=function(){var i=e.format.apply(e,arguments);console.error("%s %d: %s",t,s,i)}}else r[t]=function(){};return r[t]},e.inspect=n,n.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]},n.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=f,e.isNullOrUndefined=function(e){return null==e},e.isNumber=d,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=b,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=ai;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=oi.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 N(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}),r=[],n=0;n>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&mi.rotl(e,8)|4278255360&mi.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-r)&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}},di.exports=mi;var pi={utf8:{stringToBytes:function(e){return pi.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(pi.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],s=0;s>5]|=128<<24-r%32,i[15+(r+64>>>9<<4)]=r;for(var h=0;h>>31}var x=(a<<5|a>>>27)+u+(n[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+=f,c+=d,l+=p,u+=g}return[a,o,c,l,u]}(i));return r&&r.asBytes?n:r&&r.asString?s.bytesToString(n):e.bytesToHex(n)};i._blocksize=16,i._digestsize=20,fi.exports=i}();var yi=fi.exports;const vi=({page:e,backgroundImage:t,detection:s,imageSize:i,position:r})=>{const n=(s.phi2-s.phi1)/s.interval,a=i.height/s.interval,o=e.systems[e.systems.length-1],c=r?r.y:(o?o.top+o.height:0)+4,l=r?r.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=[n],m=u.map((e,t)=>new Staff({top:e,height:(u[t+1]||a)-e,staffY:s.middleRhos[t]/s.interval-e,measureBars:h})),f={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:n,backgroundImage:t,imagePosition:f,measureBars:h})};async function xi(e,{format:t="webp",maxHeight:s=1080,quality:i=80}={}){let r=await(async e=>"string"==typeof e?/^https?:\/\//.test(e)?(await T.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 n=await new Promise(e=>{k.default(r).resize({width:s,height:s,fit:"inside",withoutEnlargement:!0}).toFormat(t,{quality:i}).toBuffer((t,s)=>{e(s)})});return{buffer:n,filename:`${b.default.ArrayBuffer.hash(n)}.${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 Si=32,bi={viewportHeight:256,viewportUnit:8},ki=192,Ti=8,wi={viewportHeight:192,viewportUnit:8};const Mi=e=>Promise.all(e.map(e=>e())),Ei=async(e,t,{paddingLeft:s=0,scaling:i=1,spec:r})=>{if(!e||!e.backgroundImage)return null;const n=e.staves[t];if(!n)return null;const a=r.viewportHeight/r.viewportUnit/2,o=e.imagePosition.width*r.viewportUnit,l=e.imagePosition.height*r.viewportUnit,u=e.imagePosition.x*r.viewportUnit+s,h=(e.imagePosition.y-(n.top+n.staffY-a))*r.viewportUnit,m=new c.Canvas(Math.round(o+u)*i,r.viewportHeight*i),f=m.getContext("2d");return f.fillStyle="white",f.fillRect(0,0,m.width,m.height),f.drawImage(await c.loadImage(e.backgroundImage),u*i,h*i,o*i,l*i),m};async function Ni({system:e,staff:t,staffIndex:s}){const i=await Ei(e,s,{paddingLeft:Si,spec:wi});t.backgroundImage=i.toBufferSync("png"),t.imagePosition={x:-32/wi.viewportUnit,y:t.staffY-wi.viewportHeight/2/wi.viewportUnit,width:i.width/wi.viewportUnit,height:i.height/wi.viewportUnit}}async function Ii({system:e,staff:t,staffIndex:s,gaugeImage:i,pyClients:r}){const n=(await Ei(e,s,{paddingLeft:Si,spec:bi,scaling:2})).toBufferSync("png"),a=(e.middleY-(t.top+t.staffY))*bi.viewportUnit+bi.viewportHeight/2,{buffer:o,size:c}=await r.predictScoreImages("gaugeRenderer",[n,i,a]);t.backgroundImage=o,t.imagePosition={x:-32/bi.viewportUnit,y:t.staffY-c.height/2/bi.viewportUnit,width:c.width/bi.viewportUnit,height:c.height/bi.viewportUnit},t.maskImage=null}async function Ci({staff:e,staffIndex:t,maskImage:s}){const i=await c.loadImage(s);e.maskImage=s,e.imagePosition={x:-32/Ti,y:e.staffY-ki/2/Ti,width:i.width/Ti,height:i.height/Ti}}async function _i({score:e,staffIndex:t,system:s,staff:i,graph:r}){r.offset(-32/wi.viewportUnit,0),s.assignSemantics(t,r),i.assignSemantics(r),i.clearPredictedTokens(),e.assembleSystem(s,e.settings?.semanticConfidenceThreshold||1)}function Oi(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 Bi=new l.WeakLRUCache,Ai={get:async e=>Bi.getValue(e),async set(e,t){Bi.setValue(e,t)}},Pi=async e=>{if(e instanceof Buffer||"string"==typeof e&&(/^https?:\/\//.test(e)||/^data:image\//.test(e))){return`data:image/webp;base64,${(await xi(e)).buffer.toString("base64")}`}return e},Ri=e=>{const t=Math.random();let s=0;for(let i=0;it)return i;return e.length-1},Di=(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)},Fi=e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return e;const t=e.predisposition?.divisionVector?Di(e.predisposition.divisionVector):null,s=e.predisposition?.dotsVector?Di(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=Ri(e.predisposition.divisionVector)),e.predisposition.dotsVector&&(s=Ri(e.predisposition.dotsVector)),{id:e.id,division:t,dots:s}})})}}const Li=new l.WeakLRUCache,$i={get:async e=>Li.getValue(e),async set(e,t){Li.setValue(e,t)},batchGet:async e=>e.map(e=>Li.getValue(e))};var ji;!function(e){e[e.ErrorOnly=0]="ErrorOnly",e[e.NotFine=1]="NotFine",e[e.Imperfect=2]="Imperfect"}(ji||(ji={}));const Hi=async(e,t,s,i,r=ji.NotFine,n=0,a)=>{const o=e.filter(({evaluation:e})=>!e||((e,t)=>{switch(t){case ji.ErrorOnly:return e.error;case ji.Imperfect:return!e.perfect}return!e.fine})(e,r));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 r=await Rs(s,{picker:e.picker,...i});s.applySolution(r);const o=Ke(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:n,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 Vi=parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS||"30"),zi=parseInt(process.env.BASE_QUOTA_FACTOR||"40"),qi=parseInt(process.env.RECTIFICATION_QUOTA_FACTOR||"80"),Gi=(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 Wi(e,{solver:t,quotaMax:s=1e3,quotaFactor:i=zi,solutionStore:r=$i,ignoreCache:n=!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(!n){const e=await r.get(l.regulationHash);if(e)return l.applySolution(e),void++o}const u=Gi(l.events.length,i,s);await l.regulate({policy:"equations",quota:u,solver:t});const h=Ke(l);h.error||r.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 Ui=async(e,{solver:t,quotaMax:s=4e3})=>{let i=Ke(e),r=e.asSolution();const n=Gi(e.events.length,qi,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,r=e.events;for(;i<100;){i&&i%10==0&&(r=r.map(Fi));const e=MeasureRectification.roll(r),s=e.toString();t.has(s)?++i:(i=0,t.add(s),yield e)}}(e)){const o=await ys.regulateMeasureWithRectification(e,s,{solver:t,quota:n}),c=e.deepCopy();c.applySolution(o);const l=Ke(c);if((l.perfect>i.perfect||l.error=i.perfect&&o.priority>r.priority)&&(i=l,r=o),l.perfect)break;if(++a,a>Vi)break}return r};const Yi=async(e,{solver:t,solutionStore:s=$i,logger:i,quotaMax:r=240,quotaFactor:n=16})=>{e.assemble();const a=e.spartito||e.makeSpartito(),o=a.measures.filter(e=>!e.regulated);await Wi(o,{solver:t,quotaMax:r,quotaFactor:n,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-02-17T12:40:18.113Z","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=$i,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]=ri(),r=this.options[e];if(!r)throw new Error(`no config for client \`${e}\` found`);try{if("string"==typeof r){const e=new ZeroClient;e.bind(r),s(e)}else{const{scriptPath:e,...t}=r,i=new PyProcessor(e,t,this.logger);await i.bind(`${await ui()}`),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 r=null;this.logger.info(`[predictor]: ${e} py start..`);const n=Date.now();switch(e){case"layout":r=await i.request("predictDetection",t);break;case"layout$reinforce":r=await i.request("predictReinforce",t);break;case"gauge":case"mask":r=await i.request("predict",t,{by_buffer:!0});break;case"semantic":case"textLoc":r=await i.request("predict",t);break;case"textOcr":case"brackets":case"topo":case"gaugeRenderer":case"jianpu":r=await i.request("predict",...t);break;default:this.logger.error(`[predictor]: no predictor ${e}`)}return this.logger.info(`[predictor]: ${e} py duration: ${Date.now()-n}ms`),r}},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:r}=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}),n=i>0?t/i:null,a=r>0?t/r:null,{cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:f}=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:n,costPerTime:a,cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:f}},exports.abstractRegulationStats=e=>{const{baseCostTotal:t,topoCostTotal:s,baseMeasures:i,topoMeasures:r}=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}),n=i>0?t/i:null,a=r>0?s/r: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:n,topoCostPerMeasure:a,cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}},exports.constructSystem=vi,exports.convertImage=xi,exports.doRegulate=async(e,{pyClients:t,solver:s,solutionStore:i=$i,onSaveIssueMeasure:r})=>{t?.logger?.info(`[doRegulate] score: ${e.title}`),e.spartito=void 0,e.assemble();const n=e.makeSpartito();n.measures.forEach(t=>e.assignBackgroundForMeasure(t));const a=Date.now(),o=await Wi(n.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=$i,onSaveIssueMeasure:r}){t.logger.info(`[RegulateWithTopo] regulate score: ${e.title}, measures: ${e.spartito.measures.length}`);const n=e.spartito.measures.filter(e=>!Ke(e).perfect);if(t.logger.info(`[RegulateWithTopo] basic issues: ${n.length}`),0===n.length)return{solved:0,issue:0,fatal:0};const a=[].concat(...n.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)}),n.forEach(e=>{const t=a.filter(t=>t.index===e.measureIndex);e.applyClusters(t);const{matrixH:s}=ys.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(n.map(async e=>{const n=e.regulationHash0,a=await Ui(e,{solver:s});a&&(e.applySolution(a),i.set(n,a),i.set(e.regulationHash,e.asSolution()),t.logger.info(`[RegulateWithTopo] solutionStore set: ${e.measureIndex}, ${n}, ${e.regulationHash}`));const o=Ke(e);r?.({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=n.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:r}):void 0;return{baseCost:c-a,topoCost:Date.now()-c,baseMeasures:o,topoMeasures:l,qualityScore:n.qualityScore}},exports.doSimpleRegulate=Yi,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,r={},n=new Map,a=new Map,o=new Map;r.unitSize=e.unitSize,r.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===B.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(r.title.title=t.text,r.title.t={size:t.fontSize}),s?.length>0&&(s.sort((e,t)=>e.y-t.y),r.title.subtitle=s.map(e=>e.text).join("\n"),r.title.s={size:s.reduce((e,t)=>e+t.fontSize,0)/s.length});const i=c.filter(t=>t.type===B.Text&&"Author"===t.textType&&t.x>e.pages[0].width/2);i.length>0&&(r.title.composer=i.map(e=>e.text).join("\n"),r.title.c={size:i.reduce((e,t)=>e+t.fontSize,0)/i.length})}if(r.page={w:e.pages[0].width,h:e.pages[0].height},r.pages=e.pages.map(t=>{const s=t.source.dimensions.width/t.source.interval,i=t.source.dimensions.height/t.source.interval,[r,n,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:[r,n,a,o,-.5*r*s+-.5*i*a+.5*t.width||0,-.5*n*s+-.5*i*o+.5*t.height||0]}}),r.parts=[],r.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((r,m)=>{const f=r.staves.slice(),d=t.flat().map(e=>1<m+1&&(p[m+1]=p[m]);continue}const g=[];for(const e of l){const t=d[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 d=u.tip?u.tip.x:u.right-u.left/2;u.noteIds.forEach((e,i)=>{const r=s.get(e),m=`n_${t.length>1?c+"_":""}${f}_${y}`;y++,n.set(r.id,m),a.set(r.id,(r.left+r.right)/2-v),o.set(r.id,l+1),h.push({line:2*-u.ys[i],id:m,staff:l+1,x:(r.left+r.right)/2-d})}),i[f]=i[f]||[],i[f].push(d-v);const p=e.spartito.measures[r.headMeasureIndex+m].events.filter(e=>e.noteIds.some(e=>u.noteIds.includes(e)));x.push({elems:h,x:d-v,type:2**u.division,...p.some(e=>e.grace)?{grace:{}}:{}})}),h.measures[f]={w:p[m+1]-p[m],staves:l.length,notes:x}}});let m=null;e.spartito.measures.forEach((s,i)=>{const r=e.spartito.measureIndexMapping[i],n=s.contexts.flat().filter(e=>js.includes(e.tokenType)&&l.includes(e.staff)).map(e=>{const s=t.find(t=>t.includes(e.staff));return{x:e.x,clef:Hs(e),staff:s.indexOf(e.staff)+1,tick:e.tick}});n.length>0&&h.measures[r]&&(h.measures[r].clefs=n);const a=s.basics.filter((e,t)=>1<0&&(r.parts[c]=h)}e.systems.forEach((s,i)=>{const n=[],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 f=t.filter(e=>!!e);if(f.length>0){const e=f[0],t=f[f.length-1],s=e.top+e.staffY-2,i=t.top+t.staffY-2;l=s-c,u=i-s+4}const{list:d,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];n.push({distances:d,imgs:g,y:l,staves:r.length,parti:i,height:u,...o?{details:o}:{},clef:Object.fromEntries(e.spartito.measures[s.headMeasureIndex]?.contexts.flat().filter(e=>js.includes(e.tokenType)&&r.includes(e.staff)).map(e=>[e.staff,Hs(e)])),fifths:y.basics.filter((e,t)=>1<e.spartito.measureIndexMapping[s.headMeasureIndex+i]).filter(e=>Number.isFinite(e));r.lines[i]={m1:f[0],m2:f.length>0?f[f.length-1]+1:void 0,x:s.left,y:s.top+c,w:s.measureBars[s.measureBars.length-1],h:l-c+4,lineStaves:n}});const c={0:"default",1:"brace",2:"bracket",3:"square"},l=Ee(e.staffLayoutCode),u=l.partGroups.map(e=>({sort:e.range[0],part:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.part);r.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&&(r.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,r;t.notation.measures.forEach((e,t)=>{const{numerator:s,denominator:n}=e.timeSignature;l.beats||l.beatsUnit||(l.beats=s,l.beatsUnit=n,i=s,r=n),l.beatInfos=l.beatInfos||[],i===s&&r===n||(i=s,r=n,l.beatInfos.push({tick:e.tick,beats:s,beatsUnit:n})),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 r=Array.from(new Set(t.notes.map(e=>e.tick))).sort((e,t)=>e-t);return t.notes.forEach(e=>{s.set(e.id,r.indexOf(e.tick))}),e[t.tick]={measure:i,duration:t.duration,note_ticks:r},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 r;switch(i){case"vi":case"vi1":case"vi2":r=40;break;case"viola":r=42;break;case"vo":r=55;break;case"basso":r=71;break;default:r=0}return{program:r,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 r,n=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);n=[e.staffLayout.staffIds.findIndex(e=>e===s?.key),e.staffLayout.staffIds.findIndex(e=>e===t?.key)],r=c.findIndex(e=>e.range[0]<=Math.min(...n)&&e.range[1]>=Math.max(...n))}if(Number.isFinite(r)&&r>-1){const e=u[r],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(r,1,t.filter(Boolean).map(t=>({...e,track:t}))),u=u.flat(),l.rightHandTrack=n[0],l.leftHandTrack=n[1]}else u.sort((e,t)=>e===u[r]?-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=n.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:n.get(e?.ids?.[0])}:{},tick:e.ticks,channel:e.channel,duration:e.duration,track:t,event:i,elem_ids:e?.ids.map(e=>n.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:r,midiJson:l}},exports.evaluateScoreQuality=async(e,t)=>(e.spartito?.regulated||await Yi(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:Ai,onReplaceImage:Pi})=>{const i=e.logger;s.outputWidth=s.outputWidth||1200,s.pageStore=s.pageStore||Ai,s.onReplaceImage=s.onReplaceImage||Pi,s.processes=Array.isArray(s.processes)&&s.processes.length>0?s.processes:["layout","text","gauge","mask","semantic","brackets"];const r=new OMRProgress(s.onProgress),n=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));r.setTotal("layout",o.length),r.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 f(e,i){const{url:n,key:o,layout:u,enableGauge:h}=t[i],m=yi(JSON.stringify({key:o||n,layout:u,enableGauge:h})),f=await s.pageStore.get(m),d=!s.renew&&(f&&!t[i].renew||!e.detection.areas?.length),p=a.pages[i]=d&&f?ae(f,$s):new Page({source:{name:o||("string"==typeof n&&/https?:\/\//.test(n)?n:null),size:0,url:n,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=d?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),r=i.getContext("2d");r.save();const{width:n,height:a}=i,[o,l,u,h]=e.source.matrix;r.setTransform(o,l,u,h,-.5*n+.5*o*n+.5*l*a,-.5*a+.5*u*n+.5*h*a),r.drawImage(s,0,0),r.restore();const m=e.source.interval;return e.layout.areas.map((t,i)=>{console.assert(t.staves?.middleRhos?.length,"[shootImageByDetection] empty area:",t);const n=r.getImageData(t.x,t.y,t.width,t.height),a=new c.Canvas(t.width,t.height);a.getContext("2d").putImageData(n,0,0);const o=t.staves,l={width:t.width,height:t.height},u=s.width/2/m,h=s.height/2/m,f={x:(t.x+t.staves.phi1)/m-u+e.width/2,y:t.y/m-h+e.height/2};e.systems[i]=vi({page:e,backgroundImage:a.toBufferSync("png"),detection:o,imageSize:l,position:f})}),i}({score:a,page:p,pageCanvas:l[i]});return r.increase("layout"),{page:p,omit:d,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 r=i.sort((e,t)=>t.vw-e.vw)[0],n=Math.max(...i.map(e=>e.hwr));e.unitSize=s/r.vw,e.pageSize={width:s,height:s*n}}(a,u,s.outputWidth);const d=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);r.setTotal("gauge",p),r.setTotal("mask",p),r.setTotal("semantic",p),r.setTotal("brackets",d);const g=[],y=[],v=Date.now();let x=0;for(const n of u.keys()){const o=[],{page:l,correctCanvas:d,omit:p,hash:v}=await f(u[n],n);if(o.push(m(l.source.url)),o.push(...l.systems.map(e=>m(e.backgroundImage))),i.info(`[predictor]: check_cache_pageIndex-${n} omit: ${p}`),p)y.push(n);else{const u=l.systems.map((e,t)=>e.staves.map((s,i)=>({pageIndex:n,systemIndex:t,staffIndex:i,page:l,system:e,staff:s}))).flat(1);await Mi([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:r,staves:{middleRhos:n,phi1:o}}=t.areas[s],l=n[0],u=n[n.length-1],h={x:i+o-4*a,y:r+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(d,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-${n}] duration: ${Date.now()-o}`);const h=await e.predictScoreImages("brackets",{buffers:u.map(e=>e.buffer)});r.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=d.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-${n}] duration: ${Date.now()-t}`),r.increase("text"),!s.title){const e=a.pages[0].tokens;if(Array.isArray(e)&&e.length>0){const[t]=e.filter(e=>e.type===B.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(a.title=t.text)}}}catch(e){i.error(`[predictor]: text js [pageIndex-${n}] ${JSON.stringify(e)}`)}},async()=>{var c;await(c=async()=>{if(s.processes.includes("gauge")&&!1!==t[n].enableGauge){const t=await e.predictScoreImages("gauge",await Promise.all(u.map(async({staffIndex:e,system:t})=>{const s=Date.now(),r=await Ei(t,e,{paddingLeft:Si,spec:bi});return i.info(`[predictor]: gauge js shoot [page-${n}, staff-${e}] duration: ${Date.now()-s}`),r.toBufferSync("png")})));for(const[s,{system:n,staff:a,pageIndex:c,staffIndex:l}]of u.entries()){const u=Date.now();i.info(`[predictor]: gauge js [page-${c}, staff-${l}] start..`),await Ii({pyClients:e,system:n,staff:a,staffIndex:l,gaugeImage:t[s].image}),i.info(`[predictor]: gauge js [page-${c}, staff-${l}] duration: ${Date.now()-u}`),r.increase("gauge"),o.push(m(a.backgroundImage))}}else for(const[e,{system:t,staff:s,staffIndex:i}]of u.entries())await Ni({system:t,staff:s,staffIndex:i}),o.push(m(s.backgroundImage))},c()),await Mi([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 Ci({staff:s,staffIndex:a,maskImage:t[e].image}),i.info(`[predictor]: mask js [page-${n}, ${e}, staff-${a}] duration: ${Date.now()-c}`),r.increase("mask"),o.push(m(s.maskImage))}},async()=>{if(!s.processes.includes("semantic"))return;const t=ae(await e.predictScoreImages("semantic",u.map(({staff:e})=>e.backgroundImage)),$s);u.forEach(({system:e})=>e.clearTokens());for(const[e,{staffIndex:s,system:o,staff:c}]of u.entries()){const l=Date.now();await _i({score:a,system:o,staff:c,staffIndex:s,graph:t[e]}),i.info(`[predictor]: semantic js [page-${n}, system-${o.index}, staff-${c.index}] duration: ${Date.now()-l}`),r.increase("semantic")}}])}]),++x}g.push(Promise.all(o).then(()=>(Oi(l,e=>h.get(e)),i.info(`[predictor]: pageStore set: [${n}]`),s.pageStore.set(v,JSON.stringify(l)))))}const S=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-n,pagesCost:S-v,pages:x}}},exports.regulateWithBeadSolver=async(e,{logger:t,pickers:s,solutionStore:i=$i,ignoreCache:r,freshOnly:n,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}.`,r?"ignoreCache":"",n?"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 Fs(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&&!r)for(const e of h){const t=await i.get(e.origin.regulationHash0);t&&(e.current.applySolution(t),++m.cached,e.evaluation=Ke(e.current),e.baseQuality=e.evaluation.qualityScore)}t?.info("[regulateWithBeadSolver]",`${m.cached}/${h.length}`,"solutions loaded.");const f=t?null:process.stdout;m.cached&&f?.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 d=h.filter(e=>e.picker&&(!e.evaluation||!e.evaluation.fine&&!n));d.forEach(e=>{const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups,s.regulate({policy:"simple"});const i=Ke(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=d.length-m.simple,m.simple&&f?.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}`),f?.write(`[${s.fine?"32":s.error?"31":"33"}m${i?"+":"-"}`)},g=l.measures.length,y=()=>d.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 Hi(d,p,f,{stopLoss:.05,quotaMax:200,quotaFactor:3,ptFactor:1},ji.Imperfect,1,v),c?.(2,"NotFine",y()),m.tryTimes+=await Hi(d,p,f,{stopLoss:.08,quotaMax:1e3,quotaFactor:20,ptFactor:1.6},ji.NotFine,2,v),c?.(3,"ErrorOnly",y()),m.tryTimes+=await Hi(d,p,f,{stopLoss:.08,quotaMax:1e3,quotaFactor:40,ptFactor:3},ji.ErrorOnly,3,v),d.forEach(({evaluation:e,baseQuality:t,current:s,origin:r})=>{e.fine?++m.solved:e.error?++m.fatal:++m.issue,(e.qualityScore>t||!t)&&(i.set(r.regulationHash0,{...s.asSolution(r),priority:-s?.solutionStat?.loss}),s.regulationHash!==r.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),b=l.qualityScore,k=x-u;return t?.info("[regulateWithBeadSolver] done in ",k,"ms, qualityScore:",b),n&&(m.cached=0),{totalCost:x-u,pickerCost:S,measures:m,qualityScore:b}},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:r}={})=>{e.assemble();const n=e.spartito||e.makeSpartito(),a=t.map(e=>n.measures.find(t=>t.measureIndex===e)).filter(Boolean);if(r){const e=await r.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=$s,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("js-sha1"),t=require("lodash/pick"),s=require("lodash"),i=require("math-erf"),r=require("msgpackr"),n=require("zeromq"),a=require("portfinder"),o=require("python-shell"),c=require("skia-canvas"),l=require("weak-lru-cache"),u=require("spark-md5"),h=require("sharp"),m=require("got");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d,p,g,y=f(e),v=f(t),x=f(s),S=f(i),b=f(u),k=f(h),T=f(m);globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"),globalThis.atob=e=>Buffer.from(e,"base64").toString("binary"),function(e){e.ByLines="ByLines",e.ByBlocks="ByBlocks"}(d||(d={})),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"}(p||(p={})),function(e){e.ClefG="ClefG",e.ClefF="ClefF",e.ClefC="ClefC",e.NoteheadS0="NoteheadS0",e.NoteheadS1="NoteheadS1",e.NoteheadS2="NoteheadS2",e.NoteheadS1stemU="NoteheadS1stemU",e.NoteheadS1stemD="NoteheadS1stemD",e.NoteheadS2stemU="NoteheadS2stemU",e.NoteheadS2stemD="NoteheadS2stemD",e.vline_Stem="vline_Stem",e.Flag3="Flag3",e.BeamLeft="BeamLeft",e.BeamContinue="BeamContinue",e.BeamRight="BeamRight",e.TremoloLeft="TremoloLeft",e.TremoloRight="TremoloRight",e.TremoloMiddle="TremoloMiddle",e.Dot="Dot",e.Rest0="Rest0",e.Rest1="Rest1",e.Rest2="Rest2",e.Rest3="Rest3",e.Rest4="Rest4",e.Rest5="Rest5",e.Rest6="Rest6",e.Rest0W="Rest0W",e.RestM1="RestM1",e.AccNatural="AccNatural",e.AccSharp="AccSharp",e.AccDoublesharp="AccDoublesharp",e.AccFlat="AccFlat",e.AccFlatflat="AccFlatflat",e.vline_VoltaLeft="vline_VoltaLeft",e.vline_VoltaRight="vline_VoltaRight",e.VoltaLeft="VoltaLeft",e.VoltaRight="VoltaRight",e.VoltaAlternativeBegin="VoltaAlternativeBegin",e.BarMeasure="BarMeasure",e.vline_BarMeasure="vline_BarMeasure",e.vline_BarTerminal="vline_BarTerminal",e.vline_BarSegment="vline_BarSegment",e.SlurBegin="SlurBegin",e.SlurEnd="SlurEnd",e.TimesigC44="TimesigC44",e.TimesigC22="TimesigC22",e.TimesigZero="TimesigZero",e.TimesigOne="TimesigOne",e.TimesigTwo="TimesigTwo",e.TimesigThree="TimesigThree",e.TimesigFour="TimesigFour",e.TimesigFive="TimesigFive",e.TimesigSix="TimesigSix",e.TimesigSeven="TimesigSeven",e.TimesigEight="TimesigEight",e.TimesigNine="TimesigNine",e.OctaveShift8va="OctaveShift8va",e.OctaveShift8vb="OctaveShift8vb",e.OctaveShift8="OctaveShift8",e.OctaveShift0="OctaveShift0",e.Zero="Zero",e.One="One",e.Two="Two",e.Three="Three",e.Four="Four",e.Five="Five",e.Six="Six",e.Seven="Seven",e.Eight="Eight",e.Nine="Nine",e.f="f",e.p="p",e.m="m",e.n="n",e.r="r",e.s="s",e.z="z",e.CrescendoBegin="CrescendoBegin",e.CrescendoEnd="CrescendoEnd",e.DecrescendoBegin="DecrescendoBegin",e.DecrescendoEnd="DecrescendoEnd",e.ScriptFermata="ScriptFermata",e.ScriptShortFermata="ScriptShortFermata",e.ScriptSforzato="ScriptSforzato",e.ScriptStaccato="ScriptStaccato",e.ScriptStaccatissimo="ScriptStaccatissimo",e.ScriptTurn="ScriptTurn",e.ScriptTrill="ScriptTrill",e.ScriptSegno="ScriptSegno",e.ScriptCoda="ScriptCoda",e.ScriptArpeggio="ScriptArpeggio",e.ScriptPrall="ScriptPrall",e.ScriptMordent="ScriptMordent",e.ScriptMarcato="ScriptMarcato",e.ScriptTenuto="ScriptTenuto",e.ScriptPortato="ScriptPortato",e.PedalStar="PedalStar",e.PedalPed="PedalPed",e.KeyAcc="KeyAcc",e.TempoNotehead="TempoNotehead",e.GraceNotehead="GraceNotehead",e.SignLined="SignLined",e.SignInterval="SignInterval",e.rect_Text="rect_Text",e.rect_Lyric="rect_Lyric"}(g||(g={}));const w={NoteheadS0:1.826,NoteheadS1:1.264,NoteheadS2:1.198},M={"clefs.F":{x:1.06},"clefs.G":{x:1.3},"clefs.F_change":{x:.87},"clefs.G_change":{x:1.07},"timesig.C44":{x:.9},"timesig.C22":{x:.9},zero:{x:.7,y:-1},one:{x:.7,y:-1},two:{x:.7,y:-1},three:{x:.7,y:-1},four:{x:.7,y:-1},five:{x:.7,y:-1},six:{x:.7,y:-1},seven:{x:.7,y:-1},eight:{x:.7,y:-1},nine:{x:.7,y:-1},"accidentals.sharp":{x:.55},"accidentals.doublesharp":{x:.5},"accidentals.natural":{x:.3},"accidentals.flat":{x:.3},"accidentals.flatflat":{x:.5},"noteheads.s0":{x:w.NoteheadS0/2},"noteheads.s1":{x:w.NoteheadS1/2},"noteheads.s2":{x:w.NoteheadS2/2},"rests.0":{x:.75,y:1},"rests.1":{x:.75},"rests.0o":{x:.75,y:1},"rests.1o":{x:.75},"rests.M1":{x:.75,y:1},"rests.2":{x:.5},"rests.3":{x:.5},"rests.4":{x:.5},"rests.5":{x:.5},"rests.6":{x:.5},f:{x:.6,y:-.5},m:{x:.9,y:-.5},p:{x:.5,y:-.5},r:{x:.5,y:-.5},s:{x:.5,y:-.5},z:{x:.5,y:-.5},"scripts.trill":{y:-.5},"scripts.segno":{x:0,y:0},"scripts.coda":{x:0,y:0},"scripts.arpeggio":{x:.5,y:-.5},"pedal.*":{x:.78,y:-.78},"pedal.Ped":{x:1.6,y:-.7}},E=[g.BarMeasure,g.vline_BarMeasure,g.vline_BarTerminal,g.vline_BarSegment,g.vline_VoltaLeft,g.vline_VoltaRight,g.VoltaAlternativeBegin],N=g,I=[[N.NoteheadS0,N.NoteheadS1,N.NoteheadS2],[N.Zero,N.One,N.Two,N.Three,N.Four,N.Five,N.Six,N.Seven,N.Eight,N.Nine,N.ScriptStaccatissimo],[N.TimesigZero,N.TimesigOne,N.TimesigTwo,N.TimesigThree,N.TimesigFour,N.TimesigFive,N.TimesigSix,N.TimesigSeven,N.TimesigEight,N.TimesigNine],[N.Rest0,N.Rest1,N.Rest2,N.Rest3,N.Rest4,N.Rest5,N.Rest6,N.Rest0W,N.RestM1],[N.SignInterval,N.SignLined],[N.BeamLeft,N.BeamContinue,N.BeamRight]],C=[N.ClefG,N.ClefF,N.ClefC,N.NoteheadS0,N.NoteheadS1,N.NoteheadS2,N.Dot,N.Rest0,N.Rest1,N.Rest2,N.Rest3,N.Rest4,N.Rest5,N.Rest6,N.RestM1,N.AccNatural,N.AccSharp,N.AccDoublesharp,N.AccFlat,N.AccFlatflat,N.TimesigC44,N.TimesigC22,N.TimesigZero,N.TimesigOne,N.TimesigTwo,N.TimesigThree,N.TimesigFour,N.TimesigFive,N.TimesigSix,N.TimesigSeven,N.TimesigEight,N.TimesigNine,N.One,N.Two,N.Three,N.Four,N.Five,N.OctaveShift8,N.OctaveShift0,N.f,N.p,N.m,N.n,N.r,N.s,N.z,N.ScriptFermata,N.ScriptShortFermata,N.ScriptSforzato,N.ScriptStaccato,N.ScriptStaccatissimo,N.ScriptTurn,N.ScriptTrill,N.ScriptSegno,N.ScriptCoda,N.ScriptArpeggio,N.ScriptPrall,N.ScriptMordent,N.ScriptMarcato,N.ScriptTenuto,N.ScriptPortato,N.PedalStar,N.PedalPed],_=(e,t,s)=>{const i=Math.round(10*s.x),r=Math.round(10*s.y),n=`${e}|${t}|${s.semantic}|${i}|${r}`,a=y.default.array(n).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),r=`p-${e}|${t.semantic}|${s}|${i}`,n=y.default.array(r).slice(12),a=globalThis.btoa(String.fromCharCode(...n)).substring(0,11);return t.id=a,a};var B;!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"}(B||(B={}));const A=B,P=Object.values(B),R=P.filter(e=>/clefs-/.test(e)),D=P.filter(e=>/timesig/.test(e)),F=P.filter(e=>/timesig-/.test(e)),L=P.filter(e=>/timesig\d/.test(e)),$=P.filter(e=>/octave-/.test(e)),j=P.filter(e=>/n\d/.test(e)),H=P.filter(e=>/accidentals-/.test(e)),V=P.filter(e=>/noteheads-/.test(e)),z=[A.NoteheadS0,A.NoteheadS1,A.NoteheadS2],q=P.filter(e=>/noteheads-.+-[ud]/.test(e)),G=P.filter(e=>/rests-/.test(e)),W=P.filter(e=>/flags-/.test(e)),U=P.filter(e=>/volta-/.test(e)),Y=P.filter(e=>/^[a-z]$/.test(e)),X=P.filter(e=>/scripts-/.test(e)),K=P.filter(e=>/pedal-/.test(e)),Z=[A.Dot,A.DotDot],J=[A.SlurBegin,A.SlurEnd,A.TieBegin,A.TieEnd],Q=P.filter(e=>/beam-/.test(e)),ee=P.filter(e=>/wedge-/.test(e)),te=[...j,...Y,...ee,...K,...J,A.ScriptFermata,A.ScriptShortFermata,A.ScriptSforzato,A.ScriptStaccato,A.ScriptStaccatissimo,A.ScriptTurn,A.ScriptTrill,A.ScriptPrall,A.ScriptMordent,A.ScriptMarcato,A.ScriptTenuto,A.ScriptPortato],se=[...K],ie=[...R,...D,...j,...H,A.NoteheadS0,A.NoteheadS1,A.NoteheadS2,...G,...Y,...X,...K,...Z],re={};R.forEach(e=>re[e]=1),L.forEach(e=>re[e]=1),H.forEach(e=>re[e]=.5),V.forEach(e=>re[e]=.5),G.forEach(e=>re[e]=.5),Z.forEach(e=>re[e]=.5);const ne={};F.forEach(e=>ne[e]=0),U.forEach(e=>ne[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 q.includes(this.type)||this.type===B.NoteheadS0}get isContexted(){return R.includes(this.type)||D.includes(this.type)||$.includes(this.type)||H.includes(this.type)}get isAccessory(){return j.includes(this.type)||Y.includes(this.type)||X.includes(this.type)||K.includes(this.type)}get division(){switch(this.type){case A.NoteheadS0:return 0;case A.NoteheadS1stemU:case A.NoteheadS1stemD:return 1;case A.NoteheadS2stemU:case A.NoteheadS2stemD:return 2;case A.Flag3:return 3;case A.Flag4:return 4;case A.Flag5:return 5;case A.Flag6:return 6;case A.Flag7:return 7;case A.Flag8:return 8;case A.RestM1:return-1;case A.Rest0:return 0;case A.Rest1:return 1;case A.Rest2:return 2;case A.Rest3:return 3;case A.Rest4:return 4;case A.Rest5:return 5;case A.Rest6:return 6}return null}get dots(){switch(this.type){case A.Dot:return 1;case A.DotDot:return 2}return null}get direction(){switch(this.type){case A.NoteheadS1stemU:case A.NoteheadS2stemU:return"u";case A.NoteheadS1stemD:case A.NoteheadS2stemD:return"d"}return null}get width(){switch(this.type){case A.NoteheadS0:return w.NoteheadS0;case A.NoteheadS1stemU:case A.NoteheadS1stemD:return w.NoteheadS1;case A.NoteheadS2stemU:case A.NoteheadS2stemD:return w.NoteheadS2}}get left(){switch(this.type){case A.NoteheadS0:return this.x-this.width/2;case A.NoteheadS1stemU:case A.NoteheadS2stemU:return this.x-this.width;case A.NoteheadS1stemD:case A.NoteheadS2stemD:return this.x}return this.x}get right(){switch(this.type){case A.NoteheadS0:return this.x+this.width/2;case A.NoteheadS1stemU:case A.NoteheadS2stemU:return this.x;case A.NoteheadS1stemD:case A.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<("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})),oe=(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(oe(e,t))),s}if(e&&"object"==typeof e){const s={};return t.set(e,s),Object.entries(e).forEach(([e,i])=>s[e]=oe(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?v.default(this,t):this;return{__prototype:e.className,...s}}deepCopy(){return oe(this)}}var ce;!function(e){e.Ordinary="ordinary",e.Full="full",e.Conservative="conservative",e.Once="once"}(ce||(ce={}));const le=(e,t=ce.Ordinary)=>[].concat(...e.map(e=>e.serialize(t))),ue=(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 le(this.seq,e)}get code(){return ue(this.seq,{withBrackets:!0})}}BlockMLayout.className="BlockMLayout";class VoltaMLayout extends SimpleClass{constructor(e=void 0){super(),this.assign(e)}serialize(e){const t=le(this.body);if(this.alternates){const s=this.alternates.map(e=>le(e)),i=s[s.length-1];switch(e){case ce.Ordinary:return t.concat(...s);case ce.Conservative:case ce.Full:return[...[].concat(...Array(this.times-1).fill(null).map((e,i)=>[...t,...s[i%(this.times-1)]])),...t,...i];case ce.Once:return[...t,...i]}}else switch(e){case ce.Ordinary:case ce.Conservative:case ce.Once:return t;case ce.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=ue(this.body,{withBrackets:!0});let t=`${this.times}*${e}`;return this.alternates&&(t+="{"+this.alternates.map(e=>ue(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=le(this.main.seq,ce.Once),i=le(this.rest,e);switch(e){case ce.Ordinary:return[...t,...i];case ce.Once:return[...i,...s];case ce.Conservative:case ce.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+", "+ue(this.rest)+">"}}ABAMLayout.className="ABAMLayout";var he=Object.freeze({__proto__:null,get LayoutType(){return ce},SingleMLayout:SingleMLayout,BlockMLayout:BlockMLayout,VoltaMLayout:VoltaMLayout,ABAMLayout:ABAMLayout}),me=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],r=[1,26],n=[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,r,n,a){var o=n.length-1;switch(r){case 1:return n[o-1];case 2:this.$=f(null,n[o]);break;case 3:this.$=f("index-wise",n[o]);break;case 4:this.$=f("segment-wise",b(n[o]));break;case 5:case 23:1===n[o].length&&"BlockMLayout"===n[o][0].__prototype?this.$=n[o][0]:this.$=p(n[o]);break;case 6:case 24:this.$=[n[o]];break;case 7:case 11:case 12:case 13:case 14:case 20:case 27:case 28:case 29:case 35:this.$=n[o];break;case 8:this.$=[...n[o-2],n[o]];break;case 9:this.$=[...n[o-2],...n[o]];break;case 10:this.$=S(n[o-2],n[o]);break;case 15:this.$=d(n[o]);break;case 16:case 31:this.$=p(n[o]);break;case 17:case 32:this.$=n[o-1];break;case 18:case 33:this.$=g(n[o-3],n[o-1],n[o]);break;case 19:case 34:this.$=null;break;case 21:case 36:this.$=x(n[o-1]);break;case 22:this.$=y(n[o-3],n[o-1]);break;case 25:this.$=[...n[o-1],n[o]];break;case 26:this.$=p([n[o]]);break;case 30:this.$=v(n[o]);break;case 37:this.$=y(n[o-2],n[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:r,21:n,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:r,21:n,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:r,21:n,28:a,31:38,32:22,33:23,34:24,35:25,36:27},{14:r,21:n,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:n,36:46},{14:r,21:n,28:a,30:47,31:21,32:22,33:23,34:24,35:25,36:27},{14:r,21:n,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:r,21:n,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:r,21:n,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:r,21:n,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],r=[],n=this.table,a="",o=0,c=0,l=r.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 f=u.yylloc;r.push(f);var d=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,b,k,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=n[g]&&n[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in k=[],n[g])this.terminals_[x]&&x>2&&k.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+k.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:f,expected:k})}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),r.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,f=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:r[r.length-(S||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(S||1)].first_column,last_column:r[r.length-1].last_column},d&&(w._$.range=[r[r.length-(S||1)].range[0],r[r.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,r].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),r=r.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),r.push(w._$),b=n[s[s.length-2]][s[s.length-1]],s.push(b);break;case 3:return!0}}return!0}};const f=(e,t)=>({__prototype:"MesaureLayout",type:e,data:t}),d=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)=>d(e+s))},b=(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)=>d(s+t))}return[b(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=b(e.main,t),e.rest=s(e.rest)}return e};var k={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 r=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=[r[0],r[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,r;if(this.options.backtrack_lexer&&(r={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&&(r.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 n in r)this[n]=r[n];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 r=this._currentRules(),n=0;nt[0].length)){if(t=s,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,r[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,r[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=k,T.prototype=m,m.Parser=T,new T}();me.Parser;me.Parser;var fe=function(){return me.parse.apply(me,arguments)};var de,pe;!function(e){e[e.Default=0]="Default",e[e.Brace=1]="Brace",e[e.Bracket=2]="Bracket",e[e.Square=3]="Square"}(de||(de={})),function(e){e[e.Blank=0]="Blank",e[e.Dashed=1]="Dashed",e[e.Solid=2]="Solid"}(pe||(pe={}));const ge=e=>({type:de.Default,staff:e}),ye={"{":de.Brace,"}":de.Brace,"<":de.Bracket,">":de.Bracket,"[":de.Square,"]":de.Square},ve={",":pe.Blank,"-":pe.Solid,".":pe.Dashed},xe=()=>btoa(Math.random().toString().substr(2)).replace(/=/g,"").split("").reverse().slice(0,6).join(""),Se=(e,t)=>{let s=t;for(;s.length;){const t=s.shift(),i=ye[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=Se(t,s),e.subs=e.subs||[],e.subs.push(t)}}else e.subs=e.subs||[],e.subs.push(ge(t))}for(;e.type===de.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===de.Default;){const t=e.subs[0];e.subs=t.subs,e.staff=t.staff}return e.grand=e.type===de.Brace&&e.subs&&e.subs.every(e=>e.staff),s},be=e=>e.staff?e.staff:e.subs?be(e.subs[0]):void 0,ke=e=>e.staff?e.staff:e.subs?ke(e.subs[e.subs.length-1]):void 0,Te=(e,t)=>{t[(e=>e.staff?e.staff:e.subs?`${be(e)}-${ke(e)}`:void 0)(e)]=e,e.subs&&e.subs.forEach(e=>Te(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+="_"+xe();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?ve[e.conjunction]:pe.Blank);const s=[].concat(...e.map(e=>[...e.leftBounds,e.id,...e.rightBounds]));this.group={type:de.Default},Se(this.group,s);const i={};Te(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=pe.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])]})),r=s.slice(0,s.length-1).map((t,i)=>{const r=s[i+1];return e.conjunctionBetween(e.staffIds.indexOf(t),e.staffIds.indexOf(r))});return{staffIds:s,conjunctions:r,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)),r=t.map(e=>e[0]).filter(Boolean).join(","),n=t.some(([e,t])=>t),a=r?((e,t=!1)=>{if(e===de.Default)return e=>e;if(t)switch(e){case de.Brace:return e=>`{${e}`;case de.Bracket:return e=>`<${e}`;case de.Square:return e=>`[${e}`;default:return e=>e}switch(e){case de.Brace:return e=>`{${e}}`;case de.Bracket:return e=>`<${e}>`;case de.Square:return e=>`[${e}]`;default:return e=>e}})(e.type,n)(r):null;return[a,n]};let[r]=i(this.group);return r=r||"",t||(r=r.replace(/[_\w]+/g,"")),r}}var we=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],r=[1,11],n=[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],f=[5,11,12,13,21,22,23,24],d={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,r,n,a){var o=n.length-1;switch(r){case 1:return n[o-1];case 2:n[o].next(),this.$=n[o].toJSON();break;case 3:this.$=new Seq;break;case 13:case 15:this.$=[n[o]];break;case 14:case 16:this.$=[...n[o-1],n[o]];break;case 20:this.$=new Seq,this.$.tip.i(n[o]);break;case 21:case 23:n[o-1].next(),n[o-1].tip.i(n[o]),this.$=n[o-1];break;case 22:case 24:n[o-1].tip.i(n[o]),this.$=n[o-1];break;case 25:this.$=new Seq,this.$.tip.bl(n[o]);break;case 26:case 27:n[o-1].next(),n[o-1].tip.bl(n[o]),this.$=n[o-1];break;case 28:n[o-1].tip.bl(n[o]),this.$=n[o-1];break;case 29:case 30:case 31:n[o-1].tip.br(n[o]),this.$=n[o-1];break;case 32:this.$=new Seq,this.$.tip.con(n[o]),this.$.next();break;case 33:case 34:case 35:case 36:n[o-1].tip.con(n[o]),n[o-1].next(),this.$=n[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:r,22:n,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:r,22:n,23:a,24:[1,19]},{5:[2,5],10:14,11:t,12:s,13:i,18:29,20:28,21:r,22:n,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:r,22:n,23:a,24:[1,30]},e(u,[2,20]),{14:23,15:o,16:c,17:l,19:35,20:36,21:r,22:n,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(f,[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(f,[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(f,[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],r=[],n=this.table,a="",o=0,c=0,l=r.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 f=u.yylloc;r.push(f);var d=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,b,k,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=n[g]&&n[g][p]),void 0===y||!y.length||!y[0]){var M="";for(x in k=[],n[g])this.terminals_[x]&&x>2&&k.push("'"+this.terminals_[x]+"'");M=u.showPosition?"Parse error on line "+(o+1)+":\n"+u.showPosition()+"\nExpecting "+k.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:f,expected:k})}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),r.push(u.yylloc),s.push(y[1]),p=null,c=u.yyleng,a=u.yytext,o=u.yylineno,f=u.yylloc;break;case 2:if(S=this.productions_[y[1]][1],w.$=i[i.length-S],w._$={first_line:r[r.length-(S||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(S||1)].first_column,last_column:r[r.length-1].last_column},d&&(w._$.range=[r[r.length-(S||1)].range[0],r[r.length-1].range[1]]),void 0!==(v=this.performAction.apply(w,[a,c,o,h.yy,y[1],i,r].concat(l))))return v;S&&(s=s.slice(0,-1*S*2),i=i.slice(0,-1*S),r=r.slice(0,-1*S)),s.push(this.productions_[y[1]][0]),i.push(w.$),r.push(w._$),b=n[s[s.length-2]][s[s.length-1]],s.push(b);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 r=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=[r[0],r[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,r;if(this.options.backtrack_lexer&&(r={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&&(r.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 n in r)this[n]=r[n];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 r=this._currentRules(),n=0;nt[0].length)){if(t=s,i=n,this.options.backtrack_lexer){if(!1!==(e=this.test_match(s,r[n])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,r[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 d.lexer=p,g.prototype=d,d.Parser=g,new g}();we.Parser;we.Parser;var Me=function(){return we.parse.apply(we,arguments)};const Ee=e=>{const t=Me(e);return new StaffLayout(t)};class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const Ne=(e,t,s=-1/0)=>Math.max(Math.round(e/t)*t,s),Ie=(e,t)=>{const s=e.x-t.x,i=e.y-t.y;return Math.sqrt(s*s+i*i)},Ce=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:Ce(t,e%t):(console.error("non-integer gcd:",e,t),1),_e=(e,t)=>({numerator:e,denominator:t}),Oe=(e,t)=>{e=Math.round(e),t=Math.round(t);const s=0!==e?Ce(e,t):t;return _e(e/s,t/s)},Be=e=>`${e.numerator}/${e.denominator}`,Ae=(e,t)=>t?e*t.numerator/t.denominator:e,Pe=(e,t)=>{const s=[...e].sort((e,s)=>e[t]-s[t]);let i=null,r=null;return s.reduce((e,n,a)=>(r?n[t]-r[t]<.4?i.push(n):(i.length>1&&e.push(i),r=n,i=[n]):(r=n,i=[n]),i.length>1&&a===s.length-1&&e.push(i),e),[])},Re=e=>{if(e.length<=1)return[];let t=e.slice(1);const s=I.find(t=>t.includes(e[0].semantic));if(!s)return Re(t);const i=t.filter(e=>s.includes(e.semantic));return t=t.filter(e=>!s.includes(e.semantic)),[...i,...Re(t)]},De=e=>{const t=new Set(e),s=Pe(e,"x"),i=[].concat(...s.map(e=>Pe(e,"y")));return i.forEach(e=>e.sort((e,t)=>t.confidence-e.confidence)),i.forEach(e=>{Re(e).forEach(e=>t.delete(e))}),Array.from(t)},Fe=[0,2,4,5,7,9,11],Le=({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+Fe[i]+t},$e=e=>{const t=Math.max(...e);return e.indexOf(t)},je=1920;var He,Ve,ze,qe,Ge,We;!function(e){e.Up="^",e.Down="_",e.Middle="-"}(He||(He={})),function(e){e.Grace="grace",e.AfterGrace="afterGrace",e.Acciaccatura="acciaccatura",e.Appoggiatura="appoggiatura",e.SlashedGrace="slashedGrace"}(Ve||(Ve={})),function(e){e.Open="Open",e.Close="Close",e.Continue="Continue"}(ze||(ze={})),function(e){e.Pitcher="Pitcher",e.Catcher="Catcher",e.Pierced="Pierced"}(qe||(qe={})),function(e){e.Normal="normal",e.DashedLine="dashed-line",e.DottedLine="dotted-line",e.Zigzag="zigzag",e.Trill="trill"}(Ge||(Ge={})),function(e){e.Normal="Normal",e.Bracket="Bracket",e.Parenthesis="Parenthesis",e.ParenthesisDashed="ParenthesisDashed",e.ArrowDown="ArrowDown"}(We||(We={}));class Term extends SimpleClass{}class EventTerm extends Term{static space({tick:e,duration:t}){const s=new EventTerm({rest:"s",tick:e,accessories:[]});return s.duration=Math.round(t),s}constructor(e){super(),super.assign(e),Object.assign(this,e),Number.isFinite(e.left)&&Number.isFinite(e.right)&&(this.x=(this.left+this.right)/2),Number.isFinite(this.pivotX)||(this.pivotX=this.x)}get alignedTick(){return this.grace?this.tick+this.duration:this.tick}get mainDuration(){return je*2**-this.division*(2-2**-this.dots)}get duration(){let e=this.mainDuration;return this.multiplier&&(e*=this.multiplier.numerator/this.multiplier.denominator),this.timeWarp&&(e*=this.timeWarp.numerator/this.timeWarp.denominator),this.grace?e/8:e}set duration(e){console.assert(Number.isFinite(e),"invalid duration value:",e);const t=Ce(e,128),s=Math.log2(128/t),i=Oe(e*2**s,je);this.division=s,this.dots=0,i.numerator!==i.denominator?this.multiplier=i:this.multiplier=void 0}get prior(){return this.tick}get times(){return this.timeWarp?`${this.timeWarp.numerator}/${this.timeWarp.denominator}`:null}get fullMeasureRest(){return"R"===this.rest}get tipX(){return this.tip?this.tip.x:this.x}get tipY(){return this.tip?this.tip.y:this.ys?this.ys[0]:0}get tremoloCatcher(){return this.tremoloLink===qe.Catcher}get scaleChord(){return this.pitches.map(e=>"CDEFGAB"[(e.note+700)%7]).join("")}get zeroHolder(){return!!this.grace||this.tremoloCatcher}}var Ue;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"}(Ue||(Ue={}));class ContextedTerm extends Term{constructor(e){super(),Object.assign(this,e)}get type(){return R.includes(this.tokenType)?Ue.Clef:/\|key-/.test(this.tokenType)?Ue.KeyAcc:/accidentals-/.test(this.tokenType)?Ue.Acc:$.includes(this.tokenType)?Ue.OctaveShift:F.includes(this.tokenType)?Ue.TimeSignatureC:L.includes(this.tokenType)?Ue.TimeSignatureN:null}get staffLevel(){return[Ue.OctaveShift,Ue.Clef,Ue.KeyAcc].includes(this.type)}get prior(){return this.tick-.1}get clef(){switch(this.tokenType){case B.ClefG:return-this.y-2;case B.ClefF:return 2-this.y;case B.ClefC:return-this.y}return null}get alter(){switch(this.tokenType){case B.AccNatural:case B.KeyNatural:return 0;case B.AccSharp:case B.KeySharp:return 1;case B.AccFlat:case B.KeyFlat:return-1;case B.AccDoublesharp:return 2;case B.AccFlatflat:return-2}return null}get octaveShift(){switch(this.tokenType){case B.OctaveShift8va:return-1;case B.OctaveShift0:return 0;case B.OctaveShift8vb:return 1}return null}get number(){switch(this.tokenType){case B.TimesigZero:return 0;case B.TimesigOne:return 1;case B.TimesigTwo:return 2;case B.TimesigThree:return 3;case B.TimesigFour:return 4;case B.TimesigFive:return 5;case B.TimesigSix:return 6;case B.TimesigSeven:return 7;case B.TimesigEight:return 8;case B.TimesigNine:return 9}return null}}ContextedTerm.className="ContextedTerm";class MarkTerm extends Term{get prior(){return this.tick+.01}}MarkTerm.className="MarkTerm";const Ye=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=Ye.findIndex(e=>t.includes(e));i=i>=0?i:2;let r=(2**i).toString();return t.includes(".")&&(r+="."),new TempoTerm({tick:0,duration:r,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 je/Number(t)*(s?1.5:1)}get bpm(){const[e]=this.beats.match(/\d+/)||[90];return Number(e)*this.durationMagnitude*4/je}isValid(e=[10,400]){const t=this.bpm;return Number.isFinite(this.bpm)&&t>=e[0]&&t{if(!e.regulated)return;const t=e.eventMap,s=e.events.length,i=e.voices.flat(1).length,r=e.events.filter(e=>e.timeWarp).length,n=new Set(e.events.filter(e=>e.timeWarp&&!(e.rest&&0===e.division)).map(e=>`${e.timeWarp.numerator}/${e.timeWarp.denominator}`)),a=new Set(n);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,r=0,n=0;return s.some((e,t)=>{const a=e.timeWarp?e.timeWarp.denominator:0;if(a!==i){if(i>0&&(r%i||n<2))return!0;r=0,n=0}return i=a,r+=e.duration,++n,!!(t===s.length-1&&i>0&&(r%i||n<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=Ae(je,e.timeSignature),h=e.doubtfulTimesig?e.duration:u,m=e.voices.flat(1).map(e=>t[e]),f=m.some(e=>!e||!Number.isFinite(e.tick)||!Number.isFinite(e.division)||e.division<0||!Number.isFinite(e.duration)||e.duration<=0),d=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 Ce(Math.round(t),je)e.reduce(({status:e,broken:s},i)=>{const r=t[i];return r.beam&&(e+=Xe[r.beam],s=s||!(e>=0&&e<=1)),{status:e,broken:s}},{status:0,broken:!1})).some(({status:e,broken:t})=>e||t);let b=0,k=0;e.voices.forEach(s=>{const i=s.reduce((e,s)=>e+t[s].duration,0);b+=Math.max(0,e.duration-i),k+=Math.max(0,i-e.duration)}),b/=je;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,N=f||E>=1||c||M||e.tickRatesInStaves.some(e=>e<0)||T>2||!e.timeSignature||d||e.duration>h||e.events.some(e=>e.timeWarp&&e.timeWarp.numerator/e.timeWarp.denominator<=.5),I=!N&&!p&&E<.2&&!o&&!a.size&&!x&&!b&&!k&&!!e.voices.length&&!S&&!g&&!v&&(e.duration===h||Number.isFinite(e.estimatedDuration)&&e.estimatedDuration<=.75*h),C=!(N||p||!(E<.3)||o||x||k||S||g);let _=Math.min(h,3840);Number.isFinite(e.estimatedDuration)&&(_=Math.max(0,Math.min(_,e.estimatedDuration)));const O=e.duration/_;let B=0;if(e.patched&&!f)B=1;else if(!N){const t=Math.tanh(1*Math.abs(b/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:r,complicatedTimewarp:l,spaceTime:b,surplusTime:k,durationRate:O,beamBroken:S,fractionalWarp:o,irregularWarpsN:a.size,irregularTick:x,tickTwist:E,tickOverlapped:c,graceInVoice:g,graceN:y,graceDominant:v,perfect:I,fine:C,error:N,qualityScore:B}};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],r=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=r}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 Ze=[g.ClefG,g.ClefF,g.ClefC,g.TimesigC44,g.TimesigC22,g.TimesigZero,g.TimesigOne,g.TimesigTwo,g.TimesigThree,g.TimesigFour,g.TimesigFive,g.TimesigSix,g.TimesigSeven,g.TimesigEight,g.TimesigNine,g.OctaveShift8va,g.OctaveShift8vb,g.OctaveShift0,g.Zero,g.One,g.Two,g.Three,g.Four,g.Five,g.Six,g.Seven,g.Eight,g.Nine,g.AccNatural,g.AccSharp,g.AccDoublesharp,g.AccFlat,g.AccFlatflat,g.NoteheadS0,g.NoteheadS1,g.NoteheadS2,g.NoteheadS1stemU,g.NoteheadS1stemD,g.NoteheadS2stemU,g.NoteheadS2stemD,g.Rest0,g.Rest1,g.Rest2,g.Rest3,g.Rest4,g.Rest5,g.Rest6,g.Rest0W,g.RestM1,g.SlurBegin,g.SlurEnd,g.Dot,g.f,g.p,g.m,g.n,g.r,g.s,g.z,g.ScriptFermata,g.ScriptShortFermata,g.ScriptSforzato,g.ScriptStaccato,g.ScriptStaccatissimo,g.ScriptTurn,g.ScriptTrill,g.ScriptSegno,g.ScriptCoda,g.ScriptArpeggio,g.ScriptPrall,g.ScriptMordent,g.ScriptMarcato,g.ScriptTenuto,g.ScriptPortato,g.PedalStar,g.PedalPed,g.GraceNotehead,g.BeamLeft,g.BeamRight,g.BeamContinue,g.CrescendoBegin,g.CrescendoEnd,g.DecrescendoBegin,g.DecrescendoEnd,g.TremoloLeft,g.TremoloRight,g.TremoloMiddle],Je=[g.AccNatural,g.AccSharp,g.AccDoublesharp,g.AccFlat,g.AccFlatflat,g.NoteheadS0,g.NoteheadS1,g.NoteheadS2,g.NoteheadS1stemU,g.NoteheadS1stemD,g.NoteheadS2stemU,g.NoteheadS2stemD],Qe=[g.SignLined,g.SignInterval],et=[g.NoteheadS1,g.NoteheadS2],tt={AccSharp:B.KeySharp,AccNatural:B.KeyNatural,AccFlat:B.KeyFlat},st={[g.NoteheadS1]:{up:g.NoteheadS1stemU,down:g.NoteheadS1stemD},[g.NoteheadS2]:{up:g.NoteheadS2stemU,down:g.NoteheadS2stemD}},it=[g.Rest0,g.Rest1,g.Rest2,g.Rest3,g.Rest4,g.Rest5,g.Rest6],rt={[B.BeamLeft]:"Open",[B.BeamRight]:"Close",[B.BeamContinue]:"Continue"},nt={Alter1:p.Alternation1,Alter2:p.Alternation2},at=(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)),at(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=>[B.NoteheadS0,B.NoteheadS1stemU,B.NoteheadS2stemU,B.NoteheadS1stemD,B.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 r=`${s.type}|${i}`;return!s.tip&&e[r]&&(e[r].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)),r=Math.max(...e.map(e=>e.y)),n=e[0],a=n&&n.tip?n.tip.x:t;let o=t,c=s-t,l=null;switch(n.type){case B.NoteheadS0:o-=w.NoteheadS0/2,c+=w.NoteheadS0;break;case B.NoteheadS1stemU:case B.NoteheadS2stemU:l="u",o-=w.NoteheadS1,c+=w.NoteheadS1;break;case B.NoteheadS1stemD:case B.NoteheadS2stemD:l="d",c+=w.NoteheadS1}return{x:o,width:c,stemX:a,stemDirection:l,top:i,bottom:r,tip:n.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=>W.includes(e.type)),t=this.tokens.filter(e=>Z.includes(e.type)),s=this.tokens.filter(e=>Q.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),r=t.reduce((e,t)=>Math.max(e,t.division),0);return{rect:e,left:e.x,right:e.x+e.width,pivotX:(n=t,at(n.map(e=>Number.isFinite(e.pivotX)?e.pivotX:e.x),n[0].direction)),ys:s,tip:e.tip,noteIds:i,division:r,dots:null,rest:!1,stemDirection:e.stemDirection,beam:null};var n}).sort((e,t)=>t.left-e.left),r=new Set,n=i.map(({rect:i,...n})=>{if(n.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=>!r.has(e.id)&&e.x>i.stemX-.2&&e.xt[0]&&e.yMath.max(e,t.division),n.division),a.forEach(e=>r.add(e.id));const o=i.tip&&s.find(e=>Math.abs(i.tip.x-e.x)<.3&&Math.abs(i.tip.y-e.y)<.7);o&&(n.beam=rt[o.type])}const a=t.filter(e=>!r.has(e.id)&&e.x>i.x+i.width-.2&&e.xi.top-1&&e.y<=i.bottom+.5);return n.dots=a.reduce((e,t)=>Math.max(e,t.dots),0),a.forEach(e=>r.add(e.id)),n});return n.reverse(),n}getRests(){const e=this.tokens.filter(e=>G.includes(e.type)),t=this.tokens.filter(e=>Z.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=>te.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)?He.Down:He.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===B.ScriptArpeggio).forEach(e=>{const s=t.find(t=>e.xtt>e.y));s&&s.accessories.push({type:B.ScriptArpeggio,id:e.id,x:e.x-s.left})});this.tokens.filter(e=>e.type===B.GraceNotehead).forEach(t=>{const s=e.find(e=>t.x>e.left&&t.xMath.abs(t.y-e)<.4));s&&(s.grace=Ve.Grace)});const s=this.tokens.filter(e=>e.type===B.TremoloLeft),i=this.tokens.filter(e=>e.type===B.TremoloRight),r=this.tokens.filter(e=>e.type===B.TremoloMiddle),n=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}});r.forEach(e=>{const t=n.find(t=>!!t.event.tip&&(e.y>t.top&&e.y{const t=n.find(t=>e.y>t.top&&e.yt.stemR&&e.x{const t=n.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=qe.Catcher)})}assignFeaturesOnEvents(e,t){const s=t.filter(e=>e.x>this.left&&e.xit.includes(e.semantic)),r=s.filter(e=>e.semantic===g.Flag3),n=s.filter(e=>e.semantic===g.Dot),a=s.filter(e=>e.semantic===g.BeamLeft),o=s.filter(e=>e.semantic===g.BeamContinue),c=s.filter(e=>e.semantic===g.BeamRight),l=s.filter(e=>e.semantic===g.GraceNotehead),u=s.filter(e=>e.semantic===g.TremoloRight),h=s.filter(e=>e.semantic===g.vline_Stem),m=s.filter(e=>e.semantic===g.NoteheadS0),f=s.filter(e=>e.semantic===g.NoteheadS1),d=s.filter(e=>e.semantic===g.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=>Ie(s,{x:t,y:e.ys[0]})<.5).forEach(e=>{const t=it.indexOf(e.semantic);y[t]=Math.max(y[t],e.confidence)})}else{const i=[m,f,d].map(t=>t.filter(t=>t.x>e.left&&t.xs-.25&&t.yMath.max(0,...e.map(e=>e.confidence))),n=r.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]=n[t]?n[t].confidence:0)}const v=n.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))],b=[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))),k=h.filter(s=>Ie({x:t,y:e.ys[0]},{x:s.x,y:s.extension.y2})<.5),T=h.filter(s=>Ie({x:t,y:e.ys[e.ys.length-1]},{x:s.x,y:s.extension.y1})<.5),w=[Math.max(0,...k.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)),N=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:b,stemDirections:w,grace:E,tremoloCatcher:I}})}}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===g.TempoNotehead).forEach(e=>{const t=i.findIndex(t=>/^Notehead/.test(t.semantic)&&Ie(e,t)<.3);t>=0&&i.splice(t,1)});const r=e=>t.displacementSemantics?.[e]?this.semantics.find(t=>t.id===e):null;i.filter(e=>Ze.includes(e.semantic)).forEach(e=>this.appendPoint(e,{points:i}));const n=i.filter(e=>e.semantic===g.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=>et.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<.28&&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)),n=Math.min(...t.map(t=>e.y2-t.y));if(Math.min(s,n)>.5)return;const a=s!o.has(e.id)).forEach(e=>{const a=n.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?st[e.semantic].down:st[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:r(e.id),points:i})}else s.debug("isolated notehead:",t.index,this.index,e)});const l=i.filter(e=>e.semantic===g.Flag3);l.sort((e,t)=>e.x-t.x),this.appendFlags(l,n);const u=i.filter(e=>e.semantic===g.Dot).map(e=>{const t=Ne(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>n.x&&e.x-n.x<1.2)&&this.appendPoint({id:n.id,x:n.x,y:s,confidence:n.confidence},{type:B.DotDot,antiPoint:r(n.id),points:i})}}});const h=i.filter(e=>e.semantic===g.KeyAcc);i.filter(e=>tt[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,x:e.x,y:e.y,confidence:e.confidence},{type:tt[e.semantic],points:i})});i.filter(e=>e.semantic===g.OctaveShift8).forEach(e=>{const t=e.y<0?B.OctaveShift8va:B.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=>[g.VoltaLeft,g.VoltaRight].includes(e.semantic));m.sort((e,t)=>e.x-t.x);const f=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:B[t]})}})}appendPoint(e,{type:t,points:s=null,antiPoint:i,...r}={}){const n=e.x,a=this.measures.find(e=>nQe.includes(t.semantic)&&Math.abs(t.y-e.y)<.2&&Math.abs(t.x-e.x)<1.2);t.some(e=>e.semantic===g.SignLined)?o=!0:t.some(e=>e.semantic===g.SignInterval)&&(c=!0)}t=t||B[e.semantic];const l=ne[t];let u=re[t];(o||c)&&(u=Math.max(u,1));let h=e.y;Number.isFinite(l)?h=l:u&&(h=c?Ne(h+.5,u)-.5:Ne(h,u));const m=a.tokens.find(e=>e.type===t&&Math.abs(e.x-n)<.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:n,y:h,pivotX:e.pivotX,confidence:e.confidence,...r})),i&&a.antiTokens.push(new Token({id:i.id,type:t,x:n,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),r=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,n=W[r-1];n&&this.appendPoint({id:e.flags[0].id,x:e.x,y:i,confidence:Math.min(...e.flags.map(e=>e.confidence))},{type:n})})}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=>D.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===B.VoltaLeft),voltaEnd:t.tokens.some(e=>e.type===B.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=>[Ue.TimeSignatureC,Ue.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 r=this.getStaffArray(e).map((e,s)=>e?e.measures.map((e,i)=>{const r=t(s,i);return r&&{events:r.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===B.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===B.VoltaRight),alternative:e.alternative,barTypes:e.barTypes}}):Array(this.measureCount).fill(null).map(()=>({events:[],contexts:[],voltaBegin:!1,voltaEnd:!1,alternative:!1,barTypes:{}}))),n=Array(this.measureCount).fill(null).map((e,t)=>{const s=r.map(e=>e[t]);if(s.some(e=>!e))return null;let n=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),{});n=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:n,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=>n.forEach(e)),{staffMask:this.staffMask,columns:n}}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===B.VoltaLeft),voltaEnd:e.tokens.some(e=>e.type===B.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=>[Ue.TimeSignatureC,Ue.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(g.vline_BarMeasure,e);s.sort((e,t)=>e.x-t.x);const i=this.staffTop,r=this.staffBottom;let n=0;const a=s.reduce((e,t)=>{const s=Number.isFinite(t.confidence)?Math.tanh(t.confidence):1,a=t.x-n>.4?t.x:n;n=t.x;let o=e[a]||0;return o+=(Math.min(t.extension.y2,r)-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));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=>[g.vline_BarTerminal,g.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<_(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:r,x:n,y:a,confidence:o=0,extension:c=null}=t,l={semantic:r,x:n,y:a,confidence:o,extension:c};return l.extension||delete l.extension,_(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 p.TempoNumeral:{const t=this.staves[0];if(t){const s=t.top+t.staffY;t.measures.forEach(t=>{t.tokens=t.tokens.filter(t=>!V.includes(t.type)||Math.abs(t.x-e.x)>e.width/2||Math.abs(s+t.y-e.y)>e.fontSize/2)})}}break;case p.Alternation1:case p.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.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 r={x:(e.cx-s/2)/i,y:(e.cy-t/2)/i},n=this.source&&this.source.matrix?(a=r,{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]}):r;var a,o;return{confidence:e.score,x:n.x+this.width/2,y:n.y+this.height/2,semantic:g.rect_Text,extension:{text:e.text,type:e.type,width:e.width/i,height:e.height/i,theta:e.theta,textFeature:e.feature_dict}}})}assemble({textAnnotations:e=null}={},t=new DummyLogger){if(this.tokens=[],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:B.Text,confidence:s.confidence,textType:nt[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===g.rect_Text)switch(i.textType){case p.Title:case p.Author:case p.PageMargin:case p.Other:this.tokens.push(new TextToken({x:s.x,y:s.y,...i}));break;case p.TempoNumeral:case p.Chord:case p.MeasureNumber:case p.Instrument:case p.Alternation1:case p.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 p.TextualMark:case p.Times:{const e=[...this.systems].reverse().find(e=>e.topt>=e.top&&tr>=e.left&&r[e,ot[`TimeD${e}`]])),lt=Object.fromEntries(Array(12).fill(null).map((e,t)=>t+1).map(e=>[e,ot[`TimeN${e}`]])),ut=ot,ht={[ut.BOS]:"BOS",[ut.NoteheadS0]:"noteheads-s0",[ut.NoteheadS1]:"noteheads-s1",[ut.NoteheadS2]:"noteheads-s2",[ut.NoteheadGrace]:"GraceNotehead",[ut.Flag3]:"flags-u3",[ut.BeamLeft]:"BeamLeft",[ut.BeamContinue]:"BeamContinue",[ut.BeamRight]:"BeamRight",[ut.Dot]:"dot",[ut.Rest0]:"rests-0o",[ut.Rest1]:"rests-1o",[ut.Rest2]:"rests-2",[ut.Rest3]:"rests-3",[ut.Rest4]:"rests-4",[ut.Rest5]:"rests-5",[ut.Rest6]:"rests-6"},mt={[ut.NoteheadS0]:0,[ut.NoteheadS1]:1,[ut.NoteheadS2]:2,[ut.NoteheadGrace]:2},ft=[ut.NoteheadS0,ut.NoteheadS1,ut.NoteheadS2,ut.NoteheadGrace],dt=[ut.Rest0,ut.Rest1,ut.Rest2,ut.Rest3,ut.Rest4,ut.Rest5,ut.Rest6],pt=[ut.BeamLeft,ut.BeamContinue,ut.BeamRight],gt=[...ft,...dt],yt=[...ft,...dt,ut.vline_Stem],vt=[ut.BOS,ut.NoteheadS0,ut.vline_Stem,...dt],xt=[...gt,ut.vline_Stem],St={[ut.BeamLeft]:"Open",[ut.BeamRight]:"Close"},bt=e=>({type:e,staff:-1,x:0,y1:0,y2:0}),kt=bt(ot.BOS),Tt=e=>[bt(lt[e.numerator]),bt(ct[e.denominator])],wt=(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=>yt.includes(e.type))}get targetMask(){return this.elements.map(e=>vt.includes(e.type))}get vMask(){return this.elements.map(e=>xt.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=Mt([].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&&Et(e,this.vMask)}get matrixV(){return this.groupsV&&Nt(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 r=0;r=.5){const e=t.findIndex(e=>e.includes(r));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]),r=i?i[0]:s;return r-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=>ft.includes(e.type));for(let s=0;st),t=this.masks?this.masks[1]:e.map(e=>vt.includes(this.elements[e].type)),s=e.map(e=>this.elements[e].type===ut.vline_Stem&&this.elements[e].y2-this.elements[e].y1>2),i=e.filter(e=>[ut.NoteheadS1,ut.NoteheadS2,ut.NoteheadGrace].includes(this.elements[e].type)),r=e.filter(e=>this.elements[e].type===ut.NoteheadS0),n=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)})}),r.forEach(e=>{const s=this.elements[e],i=wt(this.matrixH[e],t),r=this.elements[i];r.type===ut.NoteheadS0&&Math.abs(s.x-r.x)<2.6?(n[e]=!0,a[i]=a[i]||[i],a[i].push(e)):a[e]=a[e]||[e]});const o={},c=e.filter(e=>a[e]||dt.includes(this.elements[e].type));c.sort((e,t)=>this.elements[e].x-this.elements[t].x);const l=e.map(e=>e===ut.BOS);c.forEach(e=>{const t=wt(this.matrixH[e],l);o[e]=t,t&&!dt.includes(this.elements[t].type)&&(l[t]=!1),l[e]=!0});const u=this.elements.filter(e=>e.type===ut.Dot),h=this.elements.filter(e=>e.type===ut.Flag3),m=this.elements.filter(e=>pt.includes(e.type)),f=this.groupsV;return c.map(e=>{const t=this.elements[e],s=f?f.findIndex(t=>t.includes(e)):null;if(dt.includes(t.type)){const i=u.filter(e=>e.x>t.x+.5&&e.xt.y1-1&&e.y1this.elements[e]),r=Math.min(...i.map(e=>e.x-.7)),n=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),f=c[0],d=c[c.length-1],p=u.filter(e=>e.x>n&&e.xf-1&&e.y1{const s=Ne(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=mt[i[0].type],v=null,x=null,S=null;if(t.type===ut.vline_Stem){if(v=f-t.y1>t.y2-d?"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,r]=t;return i.map(e=>r.map(t=>e&&t?s.next().value:null))},Et=(e,t)=>{const s=function*(){for(const t of e)yield t}();return t.map((e,i)=>t.map((t,r)=>e&&t&&r{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 r=s[i],n=s[t];return r<0||n<0?null:r===n?1:0}))};var It;!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"}(It||(It={}));const Ct=class Stream{constructor(e){this.array=new Uint8Array(e),this.position=0}eof(){return this.position>=this.array.length}read(e){const t=this.array.slice(this.position,this.position+e);return this.position+=e,t}readString(e){return Array.from(this.read(e)).map(e=>String.fromCharCode(e)).join("")}readInt32(){const e=(this.array[this.position]<<24)+(this.array[this.position+1]<<16)+(this.array[this.position+2]<<8)+this.array[this.position+3];return this.position+=4,e}readInt16(){const e=(this.array[this.position]<<8)+this.array[this.position+1];return this.position+=2,e}readInt8(e){let t=this.array[this.position];return e&&t>127&&(t-=256),this.position+=1,t}readVarInt(){let e=0;for(;;){const t=this.readInt8();if(!(128&t))return e+t;e+=127&t,e<<=7}}};const _t=class OStream{constructor(){this.buffer=""}write(e){this.buffer+=e}writeInt32(e){this.buffer+=String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)}writeInt16(e){this.buffer+=String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)}writeInt8(e){this.buffer+=String.fromCharCode(255&e)}writeVarInt(e){if(e<0)throw new Error("OStream.writeVarInt minus number: "+e);const t=127&e;e>>=7;let s=String.fromCharCode(t);for(;e;){const t=127&e;e>>=7,s=String.fromCharCode(128|t)+s}this.buffer+=s}getBuffer(){return this.buffer}getArrayBuffer(){return Uint8Array.from(this.buffer.split("").map(e=>e.charCodeAt(0))).buffer}};var Ot={parseMidiData:function(e){function t(e){const t=e.readString(4),s=e.readInt32();return{id:t,length:s,data:e.read(s)}}let s;function i(e){const t={};t.deltaTime=e.readVarInt();let i=e.readInt8();if(240&~i){let r;128&i?(r=e.readInt8(),s=i):(r=i,i=s);const n=i>>4;switch(t.channel=15&i,t.type="channel",n){case 8:return t.subtype="noteOff",t.noteNumber=r,t.velocity=e.readInt8(),t;case 9:return t.noteNumber=r,t.velocity=e.readInt8(),0===t.velocity?t.subtype="noteOff":t.subtype="noteOn",t;case 10:return t.subtype="noteAftertouch",t.noteNumber=r,t.amount=e.readInt8(),t;case 11:return t.subtype="controller",t.controllerType=r,t.value=e.readInt8(),t;case 12:return t.subtype="programChange",t.programNumber=r,t;case 13:return t.subtype="channelAftertouch",t.amount=r,t;case 14:return t.subtype="pitchBend",t.value=r+(e.readInt8()<<7),t;default:throw new Error("Unrecognised MIDI event type: "+n)}}else{if(255!==i){if(240===i){t.type="sysEx";const s=e.readVarInt();return t.data=e.readString(s),t}if(247===i){t.type="dividedSysEx";const s=e.readVarInt();return t.data=e.readString(s),t}throw new Error("Unrecognised MIDI event type byte: "+i)}{t.type="meta";const s=e.readInt8(),i=e.readVarInt();switch(s){case 0:if(t.subtype="sequenceNumber",2!==i)throw new Error("Expected length for sequenceNumber event is 2, got "+i);return t.number=e.readInt16(),t;case 1:return t.subtype="text",t.text=e.readString(i),t;case 2:return t.subtype="copyrightNotice",t.text=e.readString(i),t;case 3:return t.subtype="trackName",t.text=e.readString(i),t;case 4:return t.subtype="instrumentName",t.text=e.readString(i),t;case 5:return t.subtype="lyrics",t.text=e.readString(i),t;case 6:return t.subtype="marker",t.text=e.readString(i),t;case 7:return t.subtype="cuePoint",t.text=e.readString(i),t;case 32:if(t.subtype="midiChannelPrefix",1!==i)throw new Error("Expected length for midiChannelPrefix event is 1, got "+i);return t.channel=e.readInt8(),t;case 47:if(t.subtype="endOfTrack",0!==i)throw new Error("Expected length for endOfTrack event is 0, got "+i);return t;case 81:if(t.subtype="setTempo",3!==i)throw new Error("Expected length for setTempo event is 3, got "+i);return t.microsecondsPerBeat=(e.readInt8()<<16)+(e.readInt8()<<8)+e.readInt8(),t;case 84:if(t.subtype="smpteOffset",5!==i)throw new Error("Expected length for smpteOffset event is 5, got "+i);const s=e.readInt8();return t.frameRate={0:24,32:25,64:29,96:30}[96&s],t.hour=31&s,t.min=e.readInt8(),t.sec=e.readInt8(),t.frame=e.readInt8(),t.subframe=e.readInt8(),t;case 88:if(t.subtype="timeSignature",4!==i)throw new Error("Expected length for timeSignature event is 4, got "+i);return t.numerator=e.readInt8(),t.denominator=Math.pow(2,e.readInt8()),t.metronome=e.readInt8(),t.thirtyseconds=e.readInt8(),t;case 89:if(t.subtype="keySignature",2!==i)throw new Error("Expected length for keySignature event is 2, got "+i);return t.key=e.readInt8(!0),t.scale=e.readInt8(),t;case 127:return t.subtype="sequencerSpecific",t.data=e.readString(i),t;default:return t.subtype="unknown",t.data=e.readString(i),t}}}}let r=e;"string"==typeof e&&(r=e.split("").map(e=>e.charCodeAt(0)));const n=new Ct(r),a=t(n);if("MThd"!==a.id||6!==a.length)throw new Error("Bad .mid file - header not found");const o=new Ct(a.data),c=o.readInt16(),l=o.readInt16(),u=o.readInt16();let h;if(32768&u)throw new Error("Expressing time division in SMTPE frames is not supported yet");h=u;const m={formatType:c,trackCount:l,ticksPerBeat:h},f=[];for(let e=0;e>16&255),e.writeInt8(t.microsecondsPerBeat>>8&255),e.writeInt8(255&t.microsecondsPerBeat);break;case"smpteOffset":e.writeInt8(84),e.writeVarInt(5);var s={24:0,25:32,29:64,30:96}[t.frameRate];e.writeInt8(t.hour|s),e.writeInt8(t.min),e.writeInt8(t.sec),e.writeInt8(t.frame),e.writeInt8(t.subframe);break;case"timeSignature":e.writeInt8(88),e.writeVarInt(4),e.writeInt8(t.numerator),e.writeInt8(Math.log2(t.denominator)),e.writeInt8(t.metronome),e.writeInt8(t.thirtyseconds);break;case"keySignature":e.writeInt8(89),e.writeVarInt(2),e.writeInt8(t.key),e.writeInt8(t.scale);break;case"sequencerSpecific":e.writeInt8(127),e.writeVarInt(t.data.length),e.write(t.data);break;default:throw new Error("unhandled event subtype:"+t.subtype)}break;case"sysEx":e.writeInt8(240),e.writeVarInt(t.data.length),e.write(t.data);break;case"dividedSysEx":e.writeInt8(247),e.writeVarInt(t.data.length),e.write(t.data);break;case"channel":switch(t.subtype){case"noteOn":e.writeInt8(144|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.velocity);break;case"noteOff":e.writeInt8(128|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.velocity?t.velocity:0);break;case"noteAftertouch":e.writeInt8(160|t.channel),e.writeInt8(t.noteNumber),e.writeInt8(t.amount);break;case"controller":e.writeInt8(176|t.channel),e.writeInt8(t.controllerType),e.writeInt8(t.value);break;case"programChange":e.writeInt8(192|t.channel),e.writeInt8(t.programNumber);break;case"channelAftertouch":e.writeInt8(208|t.channel),e.writeInt8(t.amount);break;case"pitchBend":e.writeInt8(224|t.channel),e.writeInt8(255&t.value),e.writeInt8(t.value>>7&255);break;default:throw new Error("unhandled event subtype:"+t.subtype)}break;default:throw new Error("unhandled event type:"+t.type)}}const r=new _t,n=new _t;n.writeInt16(e.formatType),n.writeInt16(t.length),n.writeInt16(e.ticksPerBeat),s(r,"MThd",n.getBuffer());for(let e=0;e{const s=[];let i=120;const r=e.header.ticksPerBeat;for(let t=0;t0){e=a.ticksToEvent/r/(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=n()}if(a=n())for(;a;)e()}(),o},trimSequence: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)})},fixOverlapNotes:e=>{const t=new Map,s=new Map,i=[];let r=-1;return e.forEach(([{event:e,ticksToEvent:n}],a)=>{if(n>0&&(r=a),"channel"!==e.type)return;const o=`${e.channel}|${e.noteNumber}`;switch(e.subtype){case"noteOn":t.get(o)?s.set(o,r):t.set(o,r);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],r=e[s+1],n=e[t];if(!n[0].ticksToEvent)return void console.warn("invalid front index:",t,s,n);const a=n[1]/n[0].ticksToEvent;r[1]+=i[1],r[0].ticksToEvent+=i[0].ticksToEvent,i[0].ticksToEvent=n[0].ticksToEvent-1,n[0].ticksToEvent=1,i[1]=i[0].ticksToEvent*a,n[1]=n[0].ticksToEvent*a,e.splice(s,1),e.splice(t,0,i)}),e}};const At=Bt,Pt={64:"Sustain",65:"Portamento",66:"Sostenuto",67:"Soft"};class Notation$1{static parseMidi(e,{fixOverlap:t=!0}={}){const s=[],i={},r={},n=[],a=[];let o=0,c=5e3,l=0,u=4,h=0;const m={};let f,d=0,p=0;const g=[],y=e.header.ticksPerBeat;let v=At.midiToSequence(e);t&&(v=At.trimSequence(At.fixOverlapNotes(v)));const x=v.map(e=>({data:e[0].event,track:e[0].track,deltaTime:e[1],deltaTicks:e[0].ticksToEvent}));let S=0;for(const e of x){if(d+=e.deltaTicks,p=Math.round(1*d),e.deltaTicks>0){const t=e.deltaTicks/y;for(let e=Math.ceil(l);es.channel==t.channel&&s.pitch==e);if(i>=0){const r=s.splice(i,1)[0];n[t.channel].push({channel:t.channel,startTick:r.startTick,endTick:p,pitch:e,start:r.start,duration:o-r.start,velocity:r.velocity,beats:r.beats,track:r.track,finger:r.finger})}else console.debug("unexpected noteOff: ",o,t);m.high=Math.max(m.high||e,e)}break;case"controller":switch(t.controllerType){case 64:case 65:case 66:case 67:const e=Pt[t.controllerType];i[t.channel]=i[t.channel]||{},r[t.channel]=r[t.channel]||[];const s=i[t.channel][e];s&&r[t.channel].push({type:e,start:s.start,duration:o-s.start,value:s.value}),i[t.channel][e]={start:o,value:t.value}}}break;case"meta":switch(t.subtype){case"setTempo":c=t.microsecondsPerBeat/1e3,g.push({tempo:t.microsecondsPerBeat,tick:p,time:o});break;case"timeSignature":u=t.numerator,h=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,i]=t.text.match(/\((.+)\)/),r=Number(i);if(!Number.isNaN(r)){const e=s[s.length-1];e&&(e.finger=r);const t=x.find(e=>e.index==S-1);t&&(t.data.finger=r)}}break;case"copyrightNotice":console.log("MIDI copyright:",t.text)}}}return s.forEach(e=>{console.debug("unclosed noteOn event at",e.startTick,e),n[e.channel].push({startTick:e.startTick,endTick:p,pitch:e.pitch,start:e.start,duration:o-e.start,velocity:e.velocity,beats:e.beats,track:e.track,finger:e.finger})}),new Notation$1({channels:n,keyRange:m,pedals:r,bars:a,endTime:o,endTick:p,correspondences:f,events:x,tempos:g,ticksPerBeat:y,meta:{}})}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){console.assert(Number.isFinite(e),"invalid tick value:",e),console.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){console.assert(Number.isFinite(e),"invalid time value:",e),console.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 console.assert(e.to>=e.from,"invalid tick range:",e),{from:this.ticksToTime(e.from),to:this.ticksToTime(e.to)}}scaleTempo({factor:e,headTempo:t}){console.assert(this.tempos&&this.tempos.length,"[Notation.scaleTempo] tempos is empty."),t&&(e=t/this.tempos[0].tempo),console.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}}var Rt={Notation:Notation$1};const{Notation:Dt}=Rt,Ft=()=>new Promise(e=>requestAnimationFrame(e));var Lt=class MidiPlayer$1{constructor(e,{cacheSpan:t=600,onMidi:s,onPlayFinish:i,onTurnCursor:r}={}){let n;this.cacheSpan=t,this.onMidi=s,this.onPlayFinish=i,this.onTurnCursor=r,n=e.notes&&Number.isFinite(e.endTime)?e:Dt.parseMidi(e),this.notation=n,this.events=n.events,this.isPlaying=!1,this.progressTime=0,this.startTime=performance.now(),this.duration=n.endTime,this.cursorTurnDelta=0,console.assert(n.tempos&&n.tempos.length,"[MidiPlayer] invalid notation, tempos is empty.")}dispose(){this.isPlaying=!1,this.progressTime=0}get progressTicks(){return this.notation.timeToTicks(this.progressTime)}set progressTicks(e){this.progressTime=this.notation.ticksToTime(e),this.onTurnCursor&&this.onTurnCursor(this.progressTime)}async play({nextFrame:e=Ft}={}){this.progressTime>=this.duration&&(this.progressTime=0);let t=performance.now();this.startTime=t-this.progressTime,this.isPlaying=!0;let s=this.events.findIndex(e=>e.time>=t-this.startTime);for(;this.isPlaying;){for(;sthis.progressTime+this.cacheSpan)break;"channel"===e.data.type&&this.startTime+e.time>=t&&this.onMidi&&this.onMidi(e.data,this.startTime+e.time)}if(await e(),!this.isPlaying)break;if(0!==this.cursorTurnDelta){const e=this.cursorTurnDelta<0;if(this.startTime-=this.cursorTurnDelta,this.cursorTurnDelta=0,e)for(;s>0;--s){const e=this.events[s].time;if(this.startTime+ethis.duration&&(this.isPlaying=!1,this.onPlayFinish&&this.onPlayFinish())}}pause(){this.isPlaying=!1}turnCursor(e){this.isPlaying?this.cursorTurnDelta+=e-this.progressTime:this.progressTime=e,this.onTurnCursor&&this.onTurnCursor(e)}},$t={CostStepAttenuation:.6,SkipDeep:3,PriorDistanceSigmoidFactor:.1,PriorValueSigmoidFactor:.12,SkipCost:.5,LagOffsetCost:1,LeadOffsetCost:1.6,ZeroOffsetCost:.58,RelocationThreshold:6};const{pick:jt}=x.default,Ht=$t;class Node$2{constructor(e,t){this.s_note=e,this.c_note=t,console.assert(null!=this.s_note.softIndex,"s_note softIndex is null"),this.offset=this.s_note.softIndex-this.c_note.softIndex,this._prev=null,this._totalCost=0,this._value=0,this.cacheDirty=!0}get prev(){return this._prev}set prev(e){e!=this._prev&&(this._prev=e,this.cacheDirty=!0)}get si(){return this.s_note.index}get ci(){return this.c_note.index}get root(){return this.prev.root||this}get rootSi(){return this.prev.zero?this.si:this.prev.rootSi}get id(){return`${this.s_note.index},${this.c_note.index}`}static cost(e,t,s){return e*Ht.CostStepAttenuation+Math.tanh(t*Ht.SkipCost)+Math.tanh(.5*s)}updateCache(){this.cacheDirty&&(this._totalCost=Node$2.cost(this.prev.totalCost,this.si-this.prev.si-1,this.selfCost),this._value=this.prev.value+1-Math.tanh(.5*this.selfCost),this.cacheDirty=!1)}get totalCost(){return this.updateCache(),this._totalCost}get value(){return this.updateCache(),this._value}get deep(){return this.prev.deep+1}get path(){const e=[];for(let t=this;!t.zero;t=t.prev)e[t.si]=t.ci;for(let t=0;t=1,"node index error:",this,e);const s=Node$2.cost(e.totalCost,this.si-e.si-1,t);return(!this.prev||s0?Ht.LagOffsetCost:Ht.LeadOffsetCost))**2}return t}priorByOffset(e){const t=Math.abs(this.offset-e)/1;return Math.tanh(this.value*Ht.PriorValueSigmoidFactor)-Math.tanh(t*Ht.PriorDistanceSigmoidFactor)}static zero(){return{zero:!0,totalCost:0,value:0,si:-1,ci:-1,deep:0,offset:0}}}var Vt=Node$2;const zt=$t,qt=Vt;var Gt=class Navigator$1{constructor(e,t,s={}){this.criterion=e,this.sample=t,this.getCursorOffset=s.getCursorOffset||(()=>null),this.outOfPage=s.outOfPage,this.bestNode=null,this.fineCursor=null,this.breakingSI=t.notes.length-1,this.zeroNode=qt.zero(),this.zeroNode.offset=this.getCursorOffset()||0,this.relocationThreshold=s.relocationThreshold||zt.RelocationThreshold}step(e){const t=this.sample.notes[e];if(t.matches.length>0){t.matches.forEach(t=>{t.evaluatePrev(this.zeroNode);for(let s=e-1;s>=Math.max(this.breakingSI+1,e-zt.SkipDeep);--s){const i=this.sample.notes[s];console.assert(i,"prevNote is null:",s,e,this.sample.notes),i.matches.forEach(e=>{const s=t.offset-e.offset;s<2/zt.LagOffsetCost&&s>-2/zt.LeadOffsetCost&&t.evaluatePrev(e)})}if(t.prior=t.totalCost>1.99?-1:t.priorByOffset(this.zeroNode.offset),t.prior>0&&this.outOfPage){const e=this.criterion.notes[t.ci].startTick;this.outOfPage(e)&&(t.prior-=.7)}}),t.matches.sort((e,t)=>t.prior-e.prior),this.cursors=t.matches;let s=null;const i=this.nullSteps(e),r=this.cursors[0];r&&r.totalCost<1&&(r.prior>0||r.totalCost<.4&&Math.log(Math.max(i*r.value,.001))>this.relocationThreshold)&&(this.zeroNode.offset=r.offset,s=r,(!this.bestNode||r.value>this.bestNode.value)&&(this.bestNode=r)),s?this.fineCursor=s:this.resetCursor(e,{breaking:!1})||(this.zeroNode.offset+=t.deltaSi*Math.tanh(i),console.assert(!Number.isNaN(this.zeroNode.offset),"zeroNode.offset is NaN.",t.deltaSi,i))}else this.cursors=[]}path({fromIndex:e=0,toIndex:t=this.sample.notes.length-1}={}){const s=[];let i=null;for(let r=t;r>=e;){const e=this.sample.notes[r];if(!e.matches.length||e.matches[0].prior<-.01||e.matches[0].totalCost>=1){s[r]=-1,--r;continue}null!=i&&(e.matches.forEach(e=>e.backPrior=e.totalCost<1.99?e.priorByOffset(i):-1),e.matches.sort((e,t)=>t.backPrior-e.backPrior));const t=e.matches[0];t.path.forEach((e,t)=>s[t]=e),i=t.root.offset,r=t.rootSi-1}return console.assert(s.length==t+1,"path length error:",s,e,t+1,this.sample.notes.length,this.sample.notes.length?this.sample.notes[this.sample.notes.length-1].index:null),s}nullSteps(e){return e-(this.fineCursor?this.fineCursor.si:-1)-1}resetCursor(e,{breaking:t=!0}={}){t&&(this.breakingSI=e);const s=this.getCursorOffset();return null!=s&&(this.zeroNode.offset=s,this.zeroNode.si=e,this.fineCursor=null,console.assert(!Number.isNaN(this.zeroNode.offset),"zeroNode.offset is NaN.",s),!0)}get relocationTendency(){const e=this.cursors&&this.cursors[0];if(!e)return null;const t=this.nullSteps(e.si);return t<=0?0:Math.log(Math.max(t*e.value,.001))/this.relocationThreshold}};const Wt=Vt,Ut=Gt,Yt=e=>Math.tanh(e/192),Xt=function(e,t,{softIndexFactor:s=1}={}){const i=e[t=Number(t)];if(t>0){const r=e[t-1];console.assert(null!=i.start,"note.start is null",i),console.assert(null!=r.start,"lastNote.start is null",r),i.deltaSi=Yt((i.start-r.start)*s),i.softIndex=r.softIndex+i.deltaSi,console.assert(!Number.isNaN(i.deltaSi),"note.deltaSi is NaN.",i.start,r.start)}else i.softIndex=0,i.deltaSi=0};var Kt={normalizeInterval:Yt,makeNoteSoftIndex:Xt,makeMatchNodes:function(e,t,s=Wt.zero()){e.matches=[];const i=t.pitchMap[e.pitch];if(i)for(const t of i){const i=new Wt(e,t);s&&i.evaluatePrev(s),e.matches.push(i)}},genNotationContext:function(e,{softIndexFactor:t=1}={}){for(let s=0;s"setTempo"==e.subtype)||(n.push({time:t,type:"meta",subtype:"timeSignature",numerator:4,denominator:4,thirtyseconds:8}),n.push({time:t,type:"meta",subtype:"setTempo",microsecondsPerBeat:e.microsecondsPerBeat}));let a=t||0;if(e.notes)for(const t of e.notes)n.push({time:t.start,type:"channel",subtype:"noteOn",channel:t.channel||0,noteNumber:t.pitch,velocity:t.velocity,finger:t.finger}),a=Math.max(a,t.start),Number.isFinite(s)&&(t.duration=t.duration||s),t.duration&&(n.push({time:t.start+t.duration,type:"channel",subtype:"noteOff",channel:t.channel||0,noteNumber:t.pitch,velocity:0}),a=Math.max(a,t.start+t.duration));if(e.events){const t=e.events.filter(e=>!Jt.includes(e.data.subtype));for(const e of t)n.push({time:e.time,...e.data}),a=Math.max(a,e.time)}return n.push({time:a+100,type:"meta",subtype:"endOfTrack"}),n.sort(function(e,t){return e.time-t.time}),n.map((e,t)=>({event:e,index:t})).filter(({event:e})=>"noteOn"==e.subtype&&null!=e.finger).reverse().forEach(({event:e,index:t})=>n.splice(t+1,0,{time:e.time,type:"meta",subtype:"text",text:`fingering(${e.finger})`})),n.forEach(e=>e.ticks=Math.round((e.time-t)*i)),n.forEach((e,t)=>e.deltaTime=e.ticks-(t>0?n[t-1].ticks:0)),{header:r,tracks:[n]}}var es={sliceMidi:(e,t,s)=>({header:e.header,tracks:e.tracks.map(e=>((e,t,s)=>{(e=>{let t=0;e.forEach(e=>{t+=e.deltaTime,e.tick=t})})(e);const i=[],r={};return e.forEach(e=>{e.tick>=t&&e.tick<=s&&"endOfTrack"!==e.subtype?i.push({...e,tick:e.tick-t}):e.ticki.push({...e,tick:0})),i.push({tick:s-t,type:"meta",subtype:"endOfTrack"}),(e=>{let t=0;e.sort((e,t)=>e.tick-t.tick).forEach(e=>{e.deltaTime=e.tick-t,t=e.tick})})(i),i})(e,t,s))}),encodeToMIDIData:Qt,encodeToMIDI:function(e,t){const s=Qt(e,t);return Zt.encodeMidiFile(s)}};var ts={MIDI:Ot,MusicNotation:Rt,MidiPlayer:Lt,Matcher:Kt,MidiUtils:es};const ss=["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 r=t[i],n=t[i+1]?t[i+1]-r:0,a=e.filter(e=>e.measure===i+1).map(e=>({tick:e.startTick-r,duration:e.endTick-e.startTick,...v.default(e,ss),subNotes:[]}));return a.forEach(e=>["rest","tied","implicitType","afterGrace"].forEach(t=>{e[t]||delete e[t]})),{tick:r,duration:n,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 r=e.notes.find(e=>e.track===i);r&&(t[s]=Math.min(r.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,...v.default(s,ss)}));return t+=s.duration,i});return[].concat(...s)}toPerformingNotation(e,t={}){const s=this.toAbsoluteNotes(e),i=MetaNotation.performAbsoluteNotes(s,t),r=Math.max(...i.map(e=>e.start+e.duration)),n=e.reduce((e,t)=>e+this.measures[t-1].duration,0);return new ts.MusicNotation.Notation({ticksPerBeat:480,meta:{},tempos:[],channels:[i],endTime:r,endTick:n})}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 r=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}),n=e=>e.ticks+("noteOff"===e.subtype?-1e-8:0),a=[].concat(...r).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 r=i+s.tick,n=a[s.track]=a[s.track]||[];s.subNotes.forEach(t=>{n.push({ticks:r+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}),n.push({ticks:r+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)=>n(e)-n(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),r=ts.MusicNotation.Notation.parseMidi(i);is(r);let n=s;return r.measures=e.map(e=>{const t=n;return n+=this.measures[e-1].duration,{index:e,startTick:t,endTick:n}}),r}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 is=(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 r=s(e.data.channel,e.data.noteNumber,e.ticks),n=i[r];console.assert(!!n,"cannot find note of",r),n&&Object.assign(n,v.default(e.data,t))}})};var rs,ns={exports:{}},as={exports:{}};as.exports=rs=rs||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.")},r=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),n={},a=n.lib={},o=a.Base={extend:function(e){var t=r(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,r=e.sigBytes;if(this.clamp(),i%4)for(var n=0;n>>2]>>>24-n%4*8&255;t[i+n>>>2]|=a<<24-(i+n)%4*8}else for(var o=0;o>>2]=s[o>>>2];return this.sigBytes+=r,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-r%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).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=[],r=0;r>>2]>>>24-r%4*8&255;i.push(String.fromCharCode(n))}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)))}},f=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,r=i.words,n=i.sigBytes,a=this.blockSize,o=n/(4*a),l=(o=t?e.ceil(o):e.max((0|o)-this._minBufferSize,0))*a,u=e.min(4*l,n);if(l){for(var h=0;h>>7)^(d<<14|d>>>18)^d>>>3,g=l[f-2],y=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;l[f]=p+l[f-7]+y+l[f-16]}var v=i&r^i&n^r&n,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[f]+l[f];m=h,h=u,u=o,o=a+S|0,a=n,n=r,r=i,i=S+(x+v)|0}s[0]=s[0]+i|0,s[1]=s[1]+r|0,s[2]=s[2]+n|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,r=8*e.sigBytes;return s[r>>>5]|=128<<24-r%32,s[14+(r+64>>>9<<4)]=t.floor(i/4294967296),s[15+(r+64>>>9<<4)]=i,e.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}});s.SHA256=n._createHelper(u),s.HmacSHA256=n._createHmacHelper(u)}(Math),e.SHA256}(as.exports);var os=ns.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}=os(e),i=t.map(e=>e<0?e+4294967296:e),r=s/t.length;return new Uint8Array(s).map((e,t)=>i[Math.floor(t/r)]>>8*(3-t%r)&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 cs=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));cs.reduce((e,t,s)=>({...e,[("0"+s.toString(16)).slice(-2)]:t}),{});const ls=(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+cs[t],0))/s},us=e=>("0"+e.toString(16)).slice(-2);var hs={Matrix:function(){}};hs.Matrix.create=function(e){return(new hs.Matrix).setElements(e)},hs.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 hs.Matrix.create(s)},hs.Matrix.prototype={dup:function(){return hs.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 hs.Matrix.create([]);var e,t,s,i,r=this.dup(),n=this.elements.length,a=this.elements[0].length;for(t=0;t=n&&l[a].push(r);for(o.elements[a]=s,e=a;e--;){for(s=[],t=0;t1===e?null:(e=>{const t=Math.round(1920*e);return Oe(t,1920)})(e);var ds,ps,gs;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(ds||(ds={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:ds.PLACE,e1:e})}static V(e,t,s=1){return new Action({type:ds.VERTICAL,e1:s>0?e:t,e2:s>0?t:e})}static H(e,t){return new Action({type:ds.HORIZONTAL,e1:e,e2:t})}get id(){switch(this.type){case ds.PLACE:return this.e1.toString();case ds.VERTICAL:return`${this.e1}|${this.e2}`;case ds.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===ds.HORIZONTAL).forEach(t=>{const i=e.stages.findIndex(e=>e.events.includes(t.e1)),r=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(i>=0&&r>=0,"invalid stages for H action:",e.id,e.stages,t),s[i][r].add(t.e1)}),s[0][e.stages.length-1].add(0);const i=e.stagedEvents,r=t.matrixH[t.matrixH.length-1].filter((e,t)=>!i.has(t)),n=Math.max(0,Math.max(...r)-.01),a=e.actions.filter(e=>e.type===ds.HORIZONTAL),o=Object.keys(t.eventMap).map(Number).filter(e=>!a.find(t=>t.e2===e));return e.stages.forEach(i=>{i.events.forEach(r=>{if(r>0){!a.find(e=>e.e1===r)&&t.matrixH[t.matrixH.length-1][r]>=n&&(o.some(e=>t.matrixH[e][r]>0)||s[i.index][e.stages.length-1].add(r))}})}),new StageMatrix({matrix:s})}constructor(e){Object.assign(this,e)}pathOf(e,t,s,i=0){if(this.matrix[e][t].size){const r=[...this.matrix[e][t]][i];if(t===s)return[r];for(let e=t+1;e<=s;++e){const i=this.pathOf(t,e,s);if(i)return[r,...i]}}return null}findDoublePath(e,t){const s=[];for(let i=t;i>=e+1;--i)for(let r=0;rt.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let s=1;sn[e]=1),r.forEach(e=>n[e]=-1),t.push(n),this.reducePath(i.length>r.length?i:r)}}}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 ds.PLACE:this.stages.unshift({events:[t.e1]});break;case ds.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 ds.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 r=s=>{console.assert(e.eventMap[s],"invalid event id:",t.id,s,e.eventMap);const i=e.eventMap[s].x,r=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(r)r.events.push(s);else{const t={events:[s]},r=this.stages.findIndex(t=>-1===t.events[0]||e.eventMap[t.events[0]].x>=i);this.stages.splice(r,0,t)}};s||r(t.e1),i||r(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),r=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const n=t<0?e.map(e=>-e):e;if(n[0]>0)continue;r.push(n),n.forEach((e,t)=>{i[t]=i[t]||e<0,e&&(s[t]=e<0||i[t])})}}return this.constraints.forEach(e=>{0!==e.reduce((e,t)=>e+t,0)||e[0]||e.some((e,t)=>e&&!s[t])&&(e.forEach((e,t)=>e&&(s[t]=!1)),r.push(e))}),{ones:s,inbalances:r}}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])),r=new Map;let n=!1;const a=t.map(e=>({line:e.filter((e,t)=>s.includes(t)),bias:-e.reduce((e,t,i)=>e+(s.includes(i)?0:t),0)})).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const s=e.join(",");return r.has(s)?(n=r.get(s)!==t,!1):(r.set(s,t),!0)});if(n)return null;const o=a.slice(0,s.length),c=a.slice(s.length);if(o.lengths===t?1:s===r?-1:0),bias:0,prior:(i[t]+i[r])/ms};o.some(e=>e.line[t]&&e.line[r])&&(n.prior-=10),o.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[r]))&&(n.prior+=1),e.push(n)}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=hs.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 f=e.map(()=>1);return s.forEach((e,t)=>f[e]=m[t]),f}optimallySolve(e){const{ones:t,inbalances:s}=this.inbalancesConstraints(e),i=t.map((t,s)=>t?-1:Ne(e.eventMap[s].shrinkness,.01)).reduce((e,t,s)=>(t>=0&&(e[t]=e[t]||[],e[t].push(s)),e),{}),r=Object.entries(i).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let i=1;i!n.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){if(i.reduce((s,i,r)=>s+i*(t[r]||i<=0?1:e.eventMap[r].lowWarp),0)>=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===ds.HORIZONTAL).sort((e,s)=>t(e)-t(s)),i=s.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),r=new Set([...Object.keys(i)].map(Number));s.forEach(e=>r.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&r.add(e));let n=[...r].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=>n.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=fs(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)),r=this.stages.find(e=>e.events.includes(s.e2));Number.isFinite(i.tick)&&!Number.isFinite(r.tick)&&(r.tick=i.tick+Ae(e.eventMap[s.e1].duration,o[s.e1].timeWarp),r.events.forEach(e=>o[e]&&(o[e].tick=r.tick)),t=!0)}),[...s].reverse().forEach(s=>{const i=this.stages.find(e=>e.events.includes(s.e1)),r=this.stages.find(e=>e.events.includes(s.e2));!Number.isFinite(i.tick)&&Number.isFinite(r.tick)&&(i.tick=r.tick-Ae(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+Ae(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;n.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})}}),n=n.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:n,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,r=this.stagedEvents,n=[],a=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!n.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===ds.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===ds.HORIZONTAL&&t.index>i.index)return;if(e.action.type===ds.HORIZONTAL&&this.actions.some(t=>t.type===ds.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===ds.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}n.push(e)}};for(const e of r)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 r=s[e];r>0&&a({action:Action.H(e,i),possibility:r})}));n.some(e=>[ds.HORIZONTAL,ds.PLACE].includes(e.action.type)||!r.has(e.action.e1)||!r.has(e.action.e2))?this.children=n.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},r=this.pathRoot.deduce(i,s);if(r.credits=this.quota-s.credits,r.times=s.times,this.evaluateSolution(r),this.logger.debug("loss:",r.loss),e=!e||r.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,n=t[s.id].shrinkness;r.set(e,Math.max(r.get(e)||0,1-n)),r.set(i,Math.max(r.get(i)||0,1-n))}});const n=Oe(e.duration,this.eventMap[0].duration);r.set(n.numerator,Math.max(r.get(n.numerator)||0,1-this.eventMap[0].shrinkness)),r.set(n.denominator,Math.max(r.get(n.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,s]of r.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),r=t[s[s.length-1]].endTick;a+=Math.max(0,i+e.duration-r);let n=null;s.forEach(e=>{const s=t[e];s.staff!==n&&(null!==n&&++o,n=s.staff)})}),e.loss+=10*a/ms,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],r=t.x-i.x,n=t.tick-i.tick;if(!n)return r/this.xSpan;return(4*Math.atan2(n/e.duration,r/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,r,a,o),e.loss<0&&(e.loss=1/0)}}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[e.PAD=0]="PAD",e[e.BOS=1]="BOS",e[e.EOS=2]="EOS",e[e.CHORD=3]="CHORD",e[e.REST=4]="REST"}(ps||(ps={}));class EventCluster extends SimpleClass{constructor(e){super(),super.assign(e)}get regular(){return this.elements.some(e=>[ps.CHORD,ps.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===ps.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",function(e){e.computeMeasureTicks=e=>{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),r=Math.min(...i.map(e=>e.left)),n=Math.max(...i.map(e=>e.right));return Math.min(n,e.right)-Math.max(r,e.left)>.62*w.NoteheadS1})||s,e.roundX=i;const r=t.get(i)||[];t.set(i,r),r.push(e)}),t})(e);let s=0;const i=new Set([s]),r=[...t.entries()].sort(([e],[t])=>e-t);for(const[e,t]of r)t.forEach(e=>{e.predisposition&&(e.rest=e.rest&&e.predisposition.fullMeasure>.5?"R":e.rest,e.grace=e.predisposition.grace?Ve.Grace:null,e.division=$e(e.predisposition.divisionVector),e.dots=$e(e.predisposition.dotsVector),e.predisposition.timeWarped>.5&&(e.timeWarp=_e(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 r=[],n=e=>{r.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),n(a);;){const e=s.find(e=>i.has(e)&&e.alignedTick===t);if(!e)break;n(e)}e.voices.push(r)}}}}(gs||(gs={}));var ys;!function(e){const t=1921920,s=.7071067811865475,i=[[null,null],[null,ze.Open],[ze.Open,ze.Continue],[ze.Open,ze.Close],[ze.Continue,ze.Continue],[ze.Continue,ze.Close],[ze.Close,null],[ze.Close,ze.Open]].map(e=>e.join("-")),r=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};e.estiamteMeasure=e=>{const r=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/je,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 n=t*e.timeSignature.numerator/e.timeSignature.denominator;Number.isFinite(e.estimatedDuration)&&(n=Math.max(n,Ne(e.estimatedDuration,480480)));const a=e.staffGroups.reduce((e,t,s)=>(t.forEach(t=>e[t]=s),e),{}),o=[0,...r.map(e=>e.id)],c=r.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=>S.default(e/1.6)*S.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-S.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,r=t.x-e.x,n=t.tipX-e.tipX;l[t.id][e.id]=(s*i*Math.min(h(r),h(n)))**(1/3)}const r=(1-t.pR)*(1-e.pR);u[t.id][e.id]*=r,l[t.id][e.id]*=r,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:n,measureShrinkness:0,endX:e.position.right,matrixH:l,matrixV:u}},e.regulateMeasure=async(s,{solver:i=null,...n})=>{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 r=s.matrixV[o[t]][o[i]];Number.isFinite(r)&&(l[t][i]=r)})),Number.isFinite(s.estimatedDuration)&&(a.measureShrinkness=Math.tanh(-3*Math.log(Math.min(1,s.estimatedDuration/s.duration)))),n.logger&&n.logger.info("--- MEASURE",s.measureIndex,"---",a);const u=i?await i(a,n):r(a,n),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*je/t):null,i.tickGroup=e.tickGroup,i.timeWarp=e.timeWarp}),s.duration=Math.round(u.duration*je/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:n=null,...a})=>{const o=e.events.filter(e=>!e.zeroHolder).map(s=>{const r=i.events.find(e=>e&&e.id===s.id),n=Number.isFinite(r?.division)?r.division:s.division,a=Number.isFinite(r?.dots)?r.dots:s.dots,o=t*2**-n*(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,Ne(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)),f=Array(u.length).fill(null).map(()=>Array(u.length).fill(0));for(const e of h)for(const t of h){f[e.id][t.id]=e!==t&&e.tickEstimated>=t.tickEstimated?1-S.default((e.tickEstimated-t.tickEstimated)*s/.6):0;const i=(1-e.pR)*(1-t.pR);f[e.id][t.id]*=i,f[e.id][t.id]<.01&&(f[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*je/t):s;return{id:e,tick:o,tickGroup:r,timeWarp:n,division:a?.division,dots:a?.dots}}),x=Math.round(g.duration*je/t);return{events:v,voices:g.voices,duration:x,priority:y}}}(ys||(ys={}));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 r=0;const n=s.map((e,t)=>(!t||s[t]-s[t-1]<.5||++r,r)),a=i.map(t=>new EventTerm({...e.find(e=>e.id===t.id),intX:t.rx,intY:n[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=>[Ue.TimeSignatureC,Ue.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 r=t[i],n=e.pivotX-r.pivotX,a=e.tick-r.tick;if(!a)return n/s;return(4*Math.atan2(a/this.duration,n/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(){return this.regulated&&this.events.some(e=>!e.zeroHolder&&!Number.isFinite(e.tick)&&!e.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 y.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),r=e?[]:i.map(e=>e.map(e=>e.scaleChord).join("-")),n=e?[]:i.map(e=>e.map(e=>e.division).join(""));return this.timeSignature&&n.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`),[s,r,n]}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=Ae(je,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 r=0;return t[s].forEach(e=>{e.tick>r&&(e.preTick=r,r=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===qe.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 r=Math.max(e.tremolo||3,t.tremolo||3);e.tremolo=r,t.tremolo=r,t.tick||(t.tick=e.tick+e.duration/2);const n=s.indexOf(e);n>=0&&s.splice(n,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),s.beam&&(t.beam=s.beam),void 0!==s.grace&&(t.grace=s.grace?Ve.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(){gs.computeMeasureTicks(this),gs.computeMeasureVoices(this)}async regulateEquations(e){await ys.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,r=this.events.filter(e=>t.includes(e.staff));if(!r.length)return null;const n=r.map(s=>({index:s.id,voice:(this.voices||[]).findIndex(e=>e.includes(s.id)),type:s.rest?ps.REST:ps.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(!n.some(e=>!e.fake))return null;const a=Ae(je,this.timeSignature);n.unshift({index:0,type:ps.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.durationn.map(()=>0)),this.voices.forEach(e=>{let t=0;e.forEach(e=>{const s=n.findIndex(t=>t.index===e);s>0&&t>=0&&(o[s][t]=1),t=s}),t>=0&&(o[n.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:n,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?Ve.Grace:null))})}),this.estimatedDuration=e.reduce((e,t)=>e+t.estimatedDuration,0)/e.length}}SpartitoMeasure.className="SpartitoMeasure",SpartitoMeasure.blackKeys=["staffGroups","solutionStat","measureNumber","deposit"];const vs=(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:[]}),xs=e=>{const t=[].concat(...e.measures.map(e=>Object.values(e.tickMap).filter(e=>e instanceof EventTerm)));for(let e=1;ee.type===B.SlurBegin)&&i.accessories.some(e=>e.type===B.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===B.SlurBegin);e>=0&&s.accessories.splice(e,1);const t=i.accessories.findIndex(e=>e.type===B.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),r=i>=0?s+i:e.length;e.slice(s,r-1).some(e=>e.ve)&&(t.leftSign="2*[")}if(t.ve){const i=e.slice(0,s+1).reverse(),r=i.slice(1).findIndex(e=>e.ve);if(r>=0&&!i.slice(1,r+1).some(e=>e.vb))return;if(t.alter){const r=i.findIndex(e=>!e.alter);r>0&&(i[r].rightSign="]",i[r-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(Ke).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,...Ke(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&&Be(e.timeSignature)!==Be(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:",`${Be(t)} -> ${Be(s)}`,i.map(e=>e.measureIndex))}return}const s=t[0].timeSignature,i=Number.isInteger(Math.log2(s.denominator));let r=i?4:8;i&&(r=Math.max(r,t[0].timeSignature.denominator));const n=t.map(e=>Math.round(e.estimatedDuration*r/je)),a=Object.entries(n.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 n=Number(c[0]);if(!i||s.denominator*n!==s.numerator*r){if(i&&r!==s.denominator){const e=n*s.denominator/r;Number.isInteger(e)&&(n=e,r=s.denominator)}const a=t.filter(e=>!e.patched),o=_e(n,r);a.forEach(e=>e.basics.forEach(e=>e.timeSignature=o)),e.info("[rectifyTimeSignatures]\ttimesignator overwrote by estimation:",`${Be(s)} -> ${n}/${r}`,a.map(e=>e.measureIndex))}}})}makeVoiceStaves(){this.regulate();const e=Math.max(...this.measures.map(e=>e.voices.length));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)})});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 r=null;if(t.barType)switch(t.barType){case"Segment":r="||";break;case"Terminal":r="|."}const n=t.voices.map(e=>{const n=e.map(e=>s[e]);n.sort((e,t)=>e.tick-t.tick);const a={};let o=0,c=null;for(const e of n)Number.isFinite(e?.tick)?(e.tick>o?a[o]=EventTerm.space({tick:o,duration:e.tick-o}):!e.grace&&e.tick{const s=t.eventMap[e];s&&(a[s.tick]=s)}))):console.warn("invalid event tick:",e);t.endEvent&&t.endEvent.graceIds&&t.endEvent.graceIds.forEach(e=>{const s=t.eventMap[e];!s||c&&s.staff!==c.staff||(a[s.tick]=s)}),ot.duration&&Number.isFinite(t.duration)&&(c.timeWarp=Oe(t.duration-c.tick,c.duration)),console.assert(!c||!c.timeWarp||Number.isInteger(c.timeWarp.numerator)&&Number.isInteger(c.timeWarp.denominator),"invalid time warp:",c);const l=n[0]?n[0].staff:0;i.delete(l);const u=t.basics[l],h=t.contexts[l],m=n[n.length-1],f=m?m.staff:0;return{tickMap:a,duration:t.duration,...u,contextedTerms:h,marks:[],break:t.break,pageBreak:t.pageBreak,headStaff:l,tailStaff:f,bar:r}});for(;n.lengtht.headStaff!==e),o=vs({terms:r,duration:t.duration,...s,break:t.break,pageBreak:t.pageBreak},a);o.headStaff=e,o.tailStaff=e,n.push(o)}return n});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 r=new Set(e);i.forEach(e=>{const i=[...r];let n=i[0];if(t>0&&i.length>1){const t=i.map(t=>s[t.headStaff]===s[e.headStaff]?ls(e.vector.toHash(),t.trait.toHash()):-1);n=i[$e(t)]}r.delete(n),n.voiceIndex=e.index,e.vector.scale(.4).add(n.trait),e.weight=Object.keys(n.tickMap).length,0===t&&(e.headStaff=n.headStaff)}),e.sort((e,t)=>e.voiceIndex-t.voiceIndex)});const r=Array(this.stavesCount).fill(null).map(()=>[]);i.forEach(e=>{r[e.headStaff].push(e.index)});const n=Array(this.stavesCount).fill(null).map((e,s)=>{if(!t[0])return{voices:[]};return{voices:r[s].map(e=>({mode:"relative",measures:t.map(t=>t[e])}))}});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={}}))})})(n),n.forEach(e=>e.voices.forEach(xs)),n}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 r=!1,n=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=n;n+=h.duration;const f=[].concat(...u.map((e,s)=>{const r=i[s],n=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(...n.map(e=>{const t=e.pitches.reduce((e,t)=>(e[Le(t)]=t,e),{});return Object.values(t).sort((e,t)=>e.note-t.note).filter(e=>!e.tied).map((t,s)=>{const i=Le(t),n=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:n,ids:[n],track:e.part,staff:e.staff,channel:r,subNotes:[{startTick:0,endTick:e.duration,pitch:i,velocity:127}]}})}))})),d=[];a=a||d,s.marks&&s.marks.forEach(e=>{if(e instanceof TempoTerm){const t=e.bpm;if(e.isValid()){const s=r?d:a,i=r?e.tick:0;s.push({track:0,ticks:i,data:{type:"meta",subtype:"setTempo",microsecondsPerBeat:Math.round(6e7/t)}}),r=!0}}});const p=s.basics[0];return{tick:m,duration:s.duration,notes:f,events:d,timeSignature:p&&p.timeSignature,keySignature:p&&p.keySignature}});r||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,r=Math.round(s.estimatedDuration||Ae(je,s.timeSignature)),n=s.basics[0];t+=r;const{systemIndex:a,right:o}=s.position,c=s.measureIndex;return{tick:i,duration:r,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 r=Le(e),n=t.noteIds&&t.noteIds[i],a=this.staffGroups.findIndex(e=>e.includes(t.staff));return{tick:s,pitch:r,duration:t.duration,chordPosition:{index:i,count:t.pitches.length},tied:e.tied,id:n,ids:[n],track:a,staff:t.staff,channel:0,subNotes:[{startTick:0,endTick:t.duration,pitch:r,velocity:127}]}})}).flat(1),events:[],timeSignature:n&&n.timeSignature,keySignature:n&&n.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),r=s.map(e=>e[1]).flat(1),n=s.map(e=>e[2]).flat(1),[a,o,c]=[i,r,n].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(us).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 Ss=[0,2,4,5,7,9,11],bs=e=>{let t=e%7;for(;t<0;)t+=7;return t},ks=e=>{let t=e%12;for(;t<0;)t+=12;return t},Ts={[-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 Ue.Clef:this.clef=e.clef;break;case Ue.KeyAcc:this.keyAlters[bs(this.yToNote(e.y))]=e.alter;break;case Ue.Acc:this.alters[this.yToNote(e.y)]=e.alter;break;case Ue.OctaveShift:this.octaveShift=e.octaveShift;break;case Ue.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 Ue.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=ks(e),r=Ss.includes(i)?i:ks(i-t),n=Ss.indexOf(r);this.logger.assert(n>=0,"invalid preferredAlter:",e,t,r);const a=7*s+n,o=i-r,c=this.keyAlters[n]||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=bs(e);return Number.isInteger(this.keyAlters[t])?this.keyAlters[t]:0}noteToPitch(e){const t=Math.floor(e/7),s=bs(e),i=60+12*t+Ss[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=bs(t);let r=this.alterOnNote(t);return r||Number.isInteger(this.alters[t])||(r=null),`${Ts[r]?Ts[r]:""}${"CDEFGAB"[i]}${s+4}`}}const ws=e=>e.reduce((e,t,s)=>t?e|1<{if(e.version<3){const{version:t,stavesCount:s,layoutTemplate:i,...r}=e;let n=s>1?Array(s-1).fill(",").join(""):"";2===s&&(n="{-}"),e={version:3,staffLayoutCode:n,...r}}return e.version<8&&(e.pages.forEach(e=>{e.systems.forEach(e=>{if(e.semantics){const t=e.semantics.filter(e=>e.semantic===g.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 y.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,r)=>{const n=i.rows[s];console.assert(n,"[eventSystemsToTermStaves] measure is null:",s,i.rows);const a=n.contexts;0===r&&(a.some(e=>e.type===Ue.OctaveShift)||a.unshift(new ContextedTerm({staff:s,x:0,y:0,tokenType:B.OctaveShift0,tick:0})));const o=[...n.events||[],...a].sort((e,t)=>e.x-t.x),c=0===s&&r===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=je*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,r=.5*s.height/t;this.pages.forEach(e=>{const n=i-e.width/2,a=r-e.height/2;e.systems.forEach(e=>{e.left+=n,e.top+=a}),e.semantics&&e.semantics.forEach(e=>{e.x+=n,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:r.left,right:r.right,measures:n}}t-=s.measureCount}return null}getRawCluster(e,t,{timeSignature:s}={}){const i=this.getMeasure(e);if(!i)return null;const{system:r,left:n,right:a}=i,o=[kt];s&&o.push(...Tt(s));const c=r.staves[0].top+r.staves[0].staffY-2;return r.staves.forEach(e=>{let s=r.qualifiedSemantics(e.semantics,t).filter(e=>e.x>n&&e.xe.semantic===g.TempoNotehead).forEach(e=>{const t=s.findIndex(t=>/^Notehead/.test(t.semantic)&&Ie(e,t)<.3);t>=0&&s.splice(t,1)});const i=e.top+e.staffY-c;s.forEach(t=>{const s=ot[t.semantic];if(s){let r=t.y,a=t.y;s===ot.vline_Stem&&(r=t.extension.y1,a=t.extension.y2),o.push({id:t.id,type:s,staff:e.index,x:t.x-n,y1:r+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:r,keySignature:n,doubtfulTimesig:a}=e.rows[t][i];return{timeSignature:s,timeSigNumeric:r,keySignature:n,doubtfulTimesig:a}})})});const i=[].concat(...t.map(e=>e.columns.map(t=>{const s=t.measureIndex,{system:i,localIndex:r,left:n,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===r&&i.indent;return new SpartitoMeasure({measureIndex:s,staffMask:e.staffMask,position:{systemIndex:i.index,localIndex:r,left:n,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})}))),r=this.staffLayout,n=r.standaloneGroups.map(e=>e.map(e=>r.staffIds.indexOf(e)));return this.spartito=new Spartito({stavesCount:this.maxStavesCount,staffGroups:n,measures:i}),this.spartito}makeMusicSheet(){const e=this.spartito||this.makeSpartito();e.regulated||console.warn("[makeMusicSheet]\tspartito not regulated.");const t=e.makeVoiceStaves(),{title:s,pageSize:i,unitSize:r,staffLayout:n,paperOptions:a,headers:o,instrumentDict:c}=this;return{title:s,pageSize:i,unitSize:r,measureLayout:this.getMeasureLayout(),staffLayout:n,paperOptions:a,headers:o,voiceStaves:t,instrumentDict:c}}findPoint(e){for(const t of this.systems)for(let s=0;st.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,r=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,r]=Number.isFinite(e.extension?.y1)?[e.extension.y1,e.extension.y2]:[e.y,e.y];return{...e,staff:t,sy1:i+s,sy2:r+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((r,n)=>{r.index=n,r.headMeasureIndex=i,r.prev=this.systems[n-1]||null,r.next=this.systems[n+1]||null,r.semantics&&r.semantics.length&&r.semantics.forEach(e=>((e,i,r)=>{const n=_(e,i,r);t.assert(!s.has(n),"semantic point hash conflicted:",n,r,s.get(n)),s.set(n,r)})(n,null,e)),r.assemble(e,t),i+=r.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=>_(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,r)=>e.measures.forEach(e=>{const n=s.indexOf(`${i}|${r}`);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 Ee(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},{}),r=Math.max(...Object.values(i)),n=Object.entries(i).find(([e,t])=>t===r)[0].replace(/\{,*\}/g,e=>e.replace(/,/g,"-")),a=Ee(n);this.staffLayoutCode=n;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 ws(s);for(const i of[1,0]){const r=[...s,i],n=a.partialMaskCode(r);if(n===t.bracketsAppearance)return ws(r);if(t.bracketsAppearance.startsWith(n)){const t=e(r);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&&Ke(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=fe(e);return t?.data?ae(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}))})}),n=t.deepCopy();n.headers.SubScoreSystem=`${s}-${i-1}`,n.headers.SubScorePage=`${r[0].index}-${r[r.length-1].index}`,n.pages=r,n.assemble(),n.inferenceStaffLayout(),s=i,yield n}}splitToSingleScores(){return[...this.splitToSingleScoresGen()]}}Score.className="Score";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"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?Ve.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"id":case"pitches":return!0}return!1},ownKeys:()=>["id","duration","rest","division","dots","stemDirection","tying","tied","beam","timeWarp","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),r=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:Le(t),velocity:96},{id:e.id,time:e.tick+e.duration,type:"channel",subtype:"noteOff",channel:e.staff,noteNumber:Le(t)}])).flat(2);return r.sort(function(e,t){return e.time-t.time}),0===s&&r.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}),r.forEach(e=>{e.ticks=Math.round(e.time-0)}),r.forEach((e,t)=>{e.deltaTime=e.ticks-(t>0?r[t-1].ticks:0)}),r.push({deltaTime:0,type:"meta",subtype:"endOfTrack"}),r});return{header:{formatType:0,ticksPerBeat:480},tracks:s}}}var Ms;EditableMeasure.className="EditableMeasure",EditableMeasure.blackKeys=[],function(e){e.Pass="i",e.Division="d",e.Dots="o"}(Ms||(Ms={}));const Es=["whole","half","quarter","eighth","sixteenth","thirtysecond","sixtyfourth","128th","256th"],Ns=.4/je,Is=1e-12,Cs=[void 0,"u","d"],_s=[void 0,ze.Open,ze.Continue,ze.Close],Os=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):$e(e)}get currentElem(){return this.cluster.elements[this.elemIndex]}branchID(e){switch(this.type){case Ms.Pass:return`i_${e}`;case Ms.Division:return Es[e];case Ms.Dots:return"o"+".".repeat(e)}return""}async deduce({picker:e,logger:t,ptFactor:s},i=0){++this.accessCount;const r=this.nextBranch();if(t.debug(String.fromCodePoint(127817)+" ".repeat(i),this.branchID(r),this.accessCount>1?`[${this.accessCount}]`:""),!Number.isInteger(r)||r<0)return this.accessCount=1/0,As(this.cluster,this.currentElem.order+1,this.pretentiousness);var n;if(this.pretentiousness+=(n=this.possibilities[r],Math.min(100,-Math.log(n))),this.pretentiousness>100*s)return this.accessCount=1/0,As(this.cluster,this.currentElem.order+1,this.pretentiousness);let a=null;switch(this.type){case Ms.Pass:{const t=this.currentElem.order+1,s=this.cluster.elements[r];if(console.assert(s,"null element:",r,this.cluster.elements.length),s.type===ps.EOS){if(a=As(this.cluster,t,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(this.cluster.elements[0].order=t,!this.children[r]){if(!e.quota)return a;const s=(await e.predictCluster(this.cluster,t+1)).map((e,s)=>this.cluster.elements[s].orderMath.max(Is,e));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:r,type:Ms.Division,possibilities:e,pretentiousness:this.pretentiousness})}}break;case Ms.Division:if(this.currentElem.division=r,!this.children[r]){const e=this.currentElem.predisposition.dotsVector.map(e=>Math.max(Is,e));this.children[r]=new BeadNode({cluster:this.cluster,elemIndex:this.elemIndex,type:Ms.Dots,possibilities:e,pretentiousness:this.pretentiousness})}break;case Ms.Dots:if(this.currentElem.dots=r,a=As(this.cluster,this.currentElem.order+1,this.pretentiousness),!a.residue||a.fatalError)return this.accessCount=1/0,a;if(!this.children[r]){if(!e.quota)return a;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=a.endTick,a}return o}}const Bs=e=>je*2**-e.division*(2-2**-e.dots),As=(e,t,s)=>{const i=e.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isInteger(e.order)&&e.ordere.order-t.order);const r=e.elements[e.elements.length-1];let n=0,a=0,o=0,c=1;const l=[[r.x,e.signatureDuration,e.signatureDuration]];let u=0;i.forEach(e=>{e.order>a+1&&(n=0,++c);const t=l.find(e=>e[1]>=n);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=Bs(e);e.predisposition.timeWarped>.5&&(i=2*i/3),n+=i,u+=i,o=Math.max(o,n),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),f=[...i].sort((e,t)=>e.pivotX-t.pivotX),d=f.slice(1).map((e,t)=>{const s=f[t],i=e.pivotX-s.pivotX,r=e.tick-s.tick;if(!r)return i/h;return(4*Math.atan2(r/m,i/h)/Math.PI-1)**2}),p=Math.max(...d,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=>[ps.CHORD,ps.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/je+p+.2*v+.002*c+S*Ns+.02*s}},Ps=async(e,t,s,i=200,r=0,n=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:Ms.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:n});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=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isInteger(e.order)),h=e.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&!Number.isInteger(e.order));u.length&&h.forEach(e=>{if(e.tick=void 0,e.predisposition.fakeP<.5){const t=Bs(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=Cs[$e(e.predisposition.stemDirectionVector)],e.beam=_s[$e(e.predisposition.beamVector)]});const m=e.elements.map(e=>e.index),f=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:r=5,ptFactor:n=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*r));a.info(`[measure-${e.measureIndex}]`,c);const{loss:u}=await Ps(l,t.picker,a,c,s,n);o=Math.max(o,u)}const l=[],u=[],h=[];c.forEach(t=>{const s=t.elements.filter(e=>[ps.CHORD,ps.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 r=0;s.forEach(e=>{e.fullMeasure||e.grace||e.tremoloCatcher||(e.order>r+1?(i=[e.index],l.push(i)):i.push(e.index),r=e.order)});let n=s[s.length-1];const a=t.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)&&Number.isFinite(e.tick)&&!Number.isInteger(e.order));for(;a.length;){const e=a.findIndex(e=>e.tick>=n.tick+Bs(n));e>=0?i.push(a.splice(e,1)[0].index):(n=a.splice(0,1)[0],i=[n.index],l.push(i))}if(s.some(e=>!e.fullMeasure&&Number.isInteger(e.order))){const e=t.elements.find(e=>e.type===ps.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?_e(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}},Ds=async(e,{picker:t,resetSignatureForDoubtfulOnly:s})=>{const i=e.createClusters(),r=e.eventMap;for(const n of i)s&&!e.doubtfulTimesig||(n.signatureDuration=0),n.elements.forEach((e,t)=>e.order=t?void 0:0),await t.predictCluster(n,1),n.elements.filter(e=>[ps.CHORD,ps.REST].includes(e.type)).forEach(e=>{r[e.index].predisposition=e.predisposition});e.estimatedDuration=Math.max(...i.map(e=>e.estimatedDuration))},Fs=async(e,t)=>Ds(e,{picker:t,resetSignatureForDoubtfulOnly:!0});var Ls=Object.freeze({__proto__:null,solveCluster:Ps,solveMeasure:Rs,estimateMeasure:Fs,glimpseMeasure:Ds}),$s=Object.freeze({__proto__:null,beadSolver:Ls,get PageLayoutMethod(){return d},get TextType(){return p},TokenTypes:P,TokenClefs:R,TokenTimesigs:D,TokenTimesigsC:F,TokenTimesigsN:L,TokenOctshifts:$,TokenNumbers:j,TokenAccidentals:H,TokenNoteheads:V,TokenBareNoteheads:z,TokenDirectionalNoteheads:q,TokenRests:G,TokenFlags:W,TokenVolta:U,TokenDynamics:Y,TokenScripts:X,TokenPedals:K,TokenDots:Z,TokenArcs:J,TokenBeams:Q,TokenWedges:ee,TokenAccessories:te,TokenDirectionless:se,TokenGlyphs:ie,get TokenType(){return B},Token:Token,TextToken:TextToken,TOKEN_Y_ROUND:re,TOKEN_Y_FIXED:ne,VERSION:14,Score:Score,Page:Page,System:System,Staff:Staff,Measure:Measure,emptyVoiceFromStaffMeasure:vs,SpartitoMeasure:SpartitoMeasure,Spartito:Spartito,EditableEvent:EditableEvent,EditableMeasure:EditableMeasure,Term:Term,EventTerm:EventTerm,ContextedTerm:ContextedTerm,MarkTerm:MarkTerm,TempoTerm:TempoTerm,GlyphTerm:GlyphTerm,TextTerm:TextTerm,LyricTerm:LyricTerm,CommandTerm:CommandTerm,ChordmodeTerm:ChordmodeTerm,get ContextType(){return Ue},get GraceType(){return Ve},get GlissandoStyle(){return Ge},get ArpeggioStyle(){return We},get AccessoryDirection(){return He},WHOLE_DURATION:je,get StemBeam(){return ze},get TremoloLink(){return qe},mod7:bs,get SemanticType(){return g},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:I,STAMP_SEMANTICS:C,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:_,hashPageSemanticPoint:O,SemanticGraph:SemanticGraph,get SemanticElementType(){return ot},SemanticCluster:SemanticCluster,SemanticClusterSet:class SemanticClusterSet{constructor(e){if(e&&(this.clusters=e.clusters,e.vocab)){const t=e.vocab.map((e,t)=>[t,ot[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(ot).filter(e=>Number.isFinite(e[1])).map(e=>e[0]),clusters:this.clusters.map(e=>e.toJSON())}}},ELEMENT_TOKEN_NAMES:ht,NOTEHEAD_ELEMENT_TYPES:ft,NOTE_ELEMENT_TYPES:gt,BOS_ELEMENT:kt,fractionToElems:Tt,expandMatrixByMasks:Mt,expandMatrixByMaskTriu:Et,matrixFromGroups:Nt,get EventElementType(){return ps},EventCluster:EventCluster,EventClusterSet:EventClusterSet,recoverJSON:ae,SimpleClass:SimpleClass,PatchMeasure:PatchMeasure,evaluateMeasure:Ke});const js=[B.ClefG,B.ClefF,B.ClefC],Hs=e=>{let t=null;switch(e.tokenType){case B.ClefG:t="Treble";break;case B.ClefF:t="Bass";break;case B.ClefC:t=-1===e.y?"Tenor":"Alto"}return t};var Vs,zs={exports:{}},qs="object"==typeof Reflect?Reflect:null,Gs=qs&&"function"==typeof qs.apply?qs.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)};Vs=qs&&"function"==typeof qs.ownKeys?qs.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Ws=Number.isNaN||function(e){return e!=e};function Us(){Us.init.call(this)}zs.exports=Us,zs.exports.once=function(e,t){return new Promise(function(s,i){function r(s){e.removeListener(t,n),i(s)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",r),s([].slice.call(arguments))}ii(e,t,n,{once:!0}),"error"!==t&&function(e,t,s){"function"==typeof e.on&&ii(e,"error",t,s)}(e,r,{once:!0})})},Us.EventEmitter=Us,Us.prototype._events=void 0,Us.prototype._eventsCount=0,Us.prototype._maxListeners=void 0;var Ys=10;function Xs(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Ks(e){return void 0===e._maxListeners?Us.defaultMaxListeners:e._maxListeners}function Zs(e,t,s,i){var r,n,a,o;if(Xs(s),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,s.listener?s.listener:s),n=e._events),a=n[t]),void 0===a)a=n[t]=s,++e._eventsCount;else if("function"==typeof a?a=n[t]=i?[s,a]:[a,s]:i?a.unshift(s):a.push(s),(r=Ks(e))>0&&a.length>r&&!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 Js(){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 Qs(e,t,s){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:s},r=Js.bind(i);return r.listener=s,i.wrapFn=r,r}function ei(e,t,s){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?s?[r.listener||r]:[r]:s?function(e){for(var t=new Array(e.length),s=0;s{s=e,i=r,t>=0&&setTimeout(i,t,"timeout")}),s,i]}Object.defineProperty(Us,"defaultMaxListeners",{enumerable:!0,get:function(){return Ys},set:function(e){if("number"!=typeof e||e<0||Ws(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ys=e}}),Us.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},Us.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Ws(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},Us.prototype.getMaxListeners=function(){return Ks(this)},Us.prototype.emit=function(e){for(var t=[],s=1;s0&&(n=t[0]),n instanceof Error)throw n;var a=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw a.context=n,a}var o=r[e];if(void 0===o)return!1;if("function"==typeof o)Gs(o,this,t);else{var c=o.length,l=si(o,c);for(s=0;s=0;n--)if(s[n]===t||s[n].listener===t){a=s[n].listener,r=n;break}if(r<0)return this;0===r?s.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},Us.prototype.listeners=function(e){return ei(this,e,!0)},Us.prototype.rawListeners=function(e){return ei(this,e,!1)},Us.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):ti.call(e,t)},Us.prototype.listenerCount=ti,Us.prototype.eventNames=function(){return this._eventsCount>0?Vs(this._events):[]};class AsyncQueue extends zs.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,r]=e;await t(s).then(i,r),this.tasks.length>0?await this._digest(this.tasks.shift()):(this.working=!1,this.emit("idle"))}addTask(e,{timeout:t=6e5}={}){const[s,i,r]=ri({timeout:t});return this.working?this.tasks.push([...e,i,r]):this._digest([...e,i,r]),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(r.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[i,n]=Array.isArray(t)?[t,s]:[void 0,t],a={method:e};return i&&(a.args=i),n&&(a.kwargs=n),this.queue.addTask([async e=>{const[t]=await this.__request(e),s=r.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 a.getPortPromise({port:12022,stopPort:12122}),i=s.defaultsDeep({args:[...this.options.args||[],"-p",`${t}`]},this.options);this.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`),this.pyShell=new o.PythonShell(this.scriptPath,i),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 ni={},ai=function(e){return e instanceof Buffer},oi={exports:{}},ci={exports:{}};"function"==typeof Object.create?ci.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:ci.exports=function(e,t){e.super_=t;var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e};try{var li=require("util");if("function"!=typeof li.inherits)throw"";oi.exports=li.inherits}catch(e){oi.exports=ci.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(r[i++]);case"%d":return Number(r[i++]);case"%j":try{return JSON.stringify(r[i++])}catch(e){return"[Circular]"}default:return e}}),c=r[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=n.styles[t];return s?"["+n.colors[s][0]+"m"+e+"["+n.colors[s][1]+"m":e}function o(e,t){return e}function c(t,s,i){if(t.customInspect&&s&&b(s.inspect)&&s.inspect!==e.inspect&&(!s.constructor||s.constructor.prototype!==s)){var r=s.inspect(i,t);return p(r)||(r=c(t,r,i)),r}var n=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(d(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(f(t))return e.stylize("null","null")}(t,s);if(n)return n;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(b(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 k,T="",w=!1,E=["{","}"];(h(s)&&(w=!0,E=["[","]"]),b(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),k=w?function(e,t,s,i,r){for(var n=[],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]}(k,T,E)):E[0]+T+E[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function u(e,t,s,i,r,n){var a,o,l;if((l=Object.getOwnPropertyDescriptor(t,r)||{value:t[r]}).get?o=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(o=e.stylize("[Setter]","special")),M(i,r)||(a="["+r+"]"),o||(e.seen.indexOf(l.value)<0?(o=f(s)?c(e,l.value,null):c(e,l.value,s-1)).indexOf("\n")>-1&&(o=n?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(n&&r.match(/^\d+$/))return o;(a=JSON.stringify(""+r)).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 f(e){return null===e}function d(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]"===k(e)}function v(e){return"object"==typeof e&&null!==e}function x(e){return v(e)&&"[object Date]"===k(e)}function S(e){return v(e)&&("[object Error]"===k(e)||e instanceof Error)}function b(e){return"function"==typeof e}function k(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(),!r[t])if(new RegExp("\\b"+t+"\\b","i").test(i)){var s=process.pid;r[t]=function(){var i=e.format.apply(e,arguments);console.error("%s %d: %s",t,s,i)}}else r[t]=function(){};return r[t]},e.inspect=n,n.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]},n.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=f,e.isNullOrUndefined=function(e){return null==e},e.isNumber=d,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=b,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=ai;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=oi.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 N(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}),r=[],n=0;n>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&mi.rotl(e,8)|4278255360&mi.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-r)&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}},di.exports=mi;var pi={utf8:{stringToBytes:function(e){return pi.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(pi.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],s=0;s>5]|=128<<24-r%32,i[15+(r+64>>>9<<4)]=r;for(var h=0;h>>31}var x=(a<<5|a>>>27)+u+(n[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+=f,c+=d,l+=p,u+=g}return[a,o,c,l,u]}(i));return r&&r.asBytes?n:r&&r.asString?s.bytesToString(n):e.bytesToHex(n)};i._blocksize=16,i._digestsize=20,fi.exports=i}();var yi=fi.exports;const vi=({page:e,backgroundImage:t,detection:s,imageSize:i,position:r})=>{const n=(s.phi2-s.phi1)/s.interval,a=i.height/s.interval,o=e.systems[e.systems.length-1],c=r?r.y:(o?o.top+o.height:0)+4,l=r?r.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=[n],m=u.map((e,t)=>new Staff({top:e,height:(u[t+1]||a)-e,staffY:s.middleRhos[t]/s.interval-e,measureBars:h})),f={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:n,backgroundImage:t,imagePosition:f,measureBars:h})};async function xi(e,{format:t="webp",maxHeight:s=1080,quality:i=80}={}){let r=await(async e=>"string"==typeof e?/^https?:\/\//.test(e)?(await T.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 n=await new Promise(e=>{k.default(r).resize({width:s,height:s,fit:"inside",withoutEnlargement:!0}).toFormat(t,{quality:i}).toBuffer((t,s)=>{e(s)})});return{buffer:n,filename:`${b.default.ArrayBuffer.hash(n)}.${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 Si=32,bi={viewportHeight:256,viewportUnit:8},ki=192,Ti=8,wi={viewportHeight:192,viewportUnit:8};const Mi=e=>Promise.all(e.map(e=>e())),Ei=async(e,t,{paddingLeft:s=0,scaling:i=1,spec:r})=>{if(!e||!e.backgroundImage)return null;const n=e.staves[t];if(!n)return null;const a=r.viewportHeight/r.viewportUnit/2,o=e.imagePosition.width*r.viewportUnit,l=e.imagePosition.height*r.viewportUnit,u=e.imagePosition.x*r.viewportUnit+s,h=(e.imagePosition.y-(n.top+n.staffY-a))*r.viewportUnit,m=new c.Canvas(Math.round(o+u)*i,r.viewportHeight*i),f=m.getContext("2d");return f.fillStyle="white",f.fillRect(0,0,m.width,m.height),f.drawImage(await c.loadImage(e.backgroundImage),u*i,h*i,o*i,l*i),m};async function Ni({system:e,staff:t,staffIndex:s}){const i=await Ei(e,s,{paddingLeft:Si,spec:wi});t.backgroundImage=i.toBufferSync("png"),t.imagePosition={x:-32/wi.viewportUnit,y:t.staffY-wi.viewportHeight/2/wi.viewportUnit,width:i.width/wi.viewportUnit,height:i.height/wi.viewportUnit}}async function Ii({system:e,staff:t,staffIndex:s,gaugeImage:i,pyClients:r}){const n=(await Ei(e,s,{paddingLeft:Si,spec:bi,scaling:2})).toBufferSync("png"),a=(e.middleY-(t.top+t.staffY))*bi.viewportUnit+bi.viewportHeight/2,{buffer:o,size:c}=await r.predictScoreImages("gaugeRenderer",[n,i,a]);t.backgroundImage=o,t.imagePosition={x:-32/bi.viewportUnit,y:t.staffY-c.height/2/bi.viewportUnit,width:c.width/bi.viewportUnit,height:c.height/bi.viewportUnit},t.maskImage=null}async function Ci({staff:e,staffIndex:t,maskImage:s}){const i=await c.loadImage(s);e.maskImage=s,e.imagePosition={x:-32/Ti,y:e.staffY-ki/2/Ti,width:i.width/Ti,height:i.height/Ti}}async function _i({score:e,staffIndex:t,system:s,staff:i,graph:r}){r.offset(-32/wi.viewportUnit,0),s.assignSemantics(t,r),i.assignSemantics(r),i.clearPredictedTokens(),e.assembleSystem(s,e.settings?.semanticConfidenceThreshold||1)}function Oi(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 Bi=new l.WeakLRUCache,Ai={get:async e=>Bi.getValue(e),async set(e,t){Bi.setValue(e,t)}},Pi=async e=>{if(e instanceof Buffer||"string"==typeof e&&(/^https?:\/\//.test(e)||/^data:image\//.test(e))){return`data:image/webp;base64,${(await xi(e)).buffer.toString("base64")}`}return e},Ri=e=>{const t=Math.random();let s=0;for(let i=0;it)return i;return e.length-1},Di=(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)},Fi=e=>{if(!e.predisposition?.divisionVector&&!e.predisposition?.dotsVector)return e;const t=e.predisposition?.divisionVector?Di(e.predisposition.divisionVector):null,s=e.predisposition?.dotsVector?Di(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=Ri(e.predisposition.divisionVector)),e.predisposition.dotsVector&&(s=Ri(e.predisposition.dotsVector)),{id:e.id,division:t,dots:s}})})}}const Li=new l.WeakLRUCache,$i={get:async e=>Li.getValue(e),async set(e,t){Li.setValue(e,t)},batchGet:async e=>e.map(e=>Li.getValue(e))};var ji;!function(e){e[e.ErrorOnly=0]="ErrorOnly",e[e.NotFine=1]="NotFine",e[e.Imperfect=2]="Imperfect"}(ji||(ji={}));const Hi=async(e,t,s,i,r=ji.NotFine,n=0,a)=>{const o=e.filter(({evaluation:e})=>!e||((e,t)=>{switch(t){case ji.ErrorOnly:return e.error;case ji.Imperfect:return!e.perfect}return!e.fine})(e,r));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 r=await Rs(s,{picker:e.picker,...i});s.applySolution(r);const o=Ke(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:n,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 Vi=parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS||"30"),zi=parseInt(process.env.BASE_QUOTA_FACTOR||"40"),qi=parseInt(process.env.RECTIFICATION_QUOTA_FACTOR||"80"),Gi=(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 Wi(e,{solver:t,quotaMax:s=1e3,quotaFactor:i=zi,solutionStore:r=$i,ignoreCache:n=!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(!n){const e=await r.get(l.regulationHash);if(e)return l.applySolution(e),void++o}const u=Gi(l.events.length,i,s);await l.regulate({policy:"equations",quota:u,solver:t});const h=Ke(l);h.error||r.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 Ui=async(e,{solver:t,quotaMax:s=4e3})=>{let i=Ke(e),r=e.asSolution();const n=Gi(e.events.length,qi,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,r=e.events;for(;i<100;){i&&i%10==0&&(r=r.map(Fi));const e=MeasureRectification.roll(r),s=e.toString();t.has(s)?++i:(i=0,t.add(s),yield e)}}(e)){const o=await ys.regulateMeasureWithRectification(e,s,{solver:t,quota:n}),c=e.deepCopy();c.applySolution(o);const l=Ke(c);if((l.perfect>i.perfect||l.error=i.perfect&&o.priority>r.priority)&&(i=l,r=o),l.perfect)break;if(++a,a>Vi)break}return r};const Yi=async(e,{solver:t,solutionStore:s=$i,logger:i,quotaMax:r=240,quotaFactor:n=16})=>{e.assemble();const a=e.spartito||e.makeSpartito(),o=a.measures.filter(e=>!e.regulated);await Wi(o,{solver:t,quotaMax:r,quotaFactor:n,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-02-17T15:16:28.868Z","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=$i,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]=ri(),r=this.options[e];if(!r)throw new Error(`no config for client \`${e}\` found`);try{if("string"==typeof r){const e=new ZeroClient;e.bind(r),s(e)}else{const{scriptPath:e,...t}=r,i=new PyProcessor(e,t,this.logger);await i.bind(`${await ui()}`),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 r=null;this.logger.info(`[predictor]: ${e} py start..`);const n=Date.now();switch(e){case"layout":r=await i.request("predictDetection",t);break;case"layout$reinforce":r=await i.request("predictReinforce",t);break;case"gauge":case"mask":r=await i.request("predict",t,{by_buffer:!0});break;case"semantic":case"textLoc":r=await i.request("predict",t);break;case"textOcr":case"brackets":case"topo":case"gaugeRenderer":case"jianpu":r=await i.request("predict",...t);break;default:this.logger.error(`[predictor]: no predictor ${e}`)}return this.logger.info(`[predictor]: ${e} py duration: ${Date.now()-n}ms`),r}},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:r}=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}),n=i>0?t/i:null,a=r>0?t/r:null,{cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:f}=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:n,costPerTime:a,cached:o,simple:c,computed:l,tryTimes:u,solved:h,issue:m,fatal:f}},exports.abstractRegulationStats=e=>{const{baseCostTotal:t,topoCostTotal:s,baseMeasures:i,topoMeasures:r}=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}),n=i>0?t/i:null,a=r>0?s/r: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:n,topoCostPerMeasure:a,cached:o,baseComputed:c,baseSolved:l,topoSolved:u,topoIssue:h,topoFatal:m}},exports.constructSystem=vi,exports.convertImage=xi,exports.doRegulate=async(e,{pyClients:t,solver:s,solutionStore:i=$i,onSaveIssueMeasure:r})=>{t?.logger?.info(`[doRegulate] score: ${e.title}`),e.spartito=void 0,e.assemble();const n=e.makeSpartito();n.measures.forEach(t=>e.assignBackgroundForMeasure(t));const a=Date.now(),o=await Wi(n.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=$i,onSaveIssueMeasure:r}){t.logger.info(`[RegulateWithTopo] regulate score: ${e.title}, measures: ${e.spartito.measures.length}`);const n=e.spartito.measures.filter(e=>!Ke(e).perfect);if(t.logger.info(`[RegulateWithTopo] basic issues: ${n.length}`),0===n.length)return{solved:0,issue:0,fatal:0};const a=[].concat(...n.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)}),n.forEach(e=>{const t=a.filter(t=>t.index===e.measureIndex);e.applyClusters(t);const{matrixH:s}=ys.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(n.map(async e=>{const n=e.regulationHash0,a=await Ui(e,{solver:s});a&&(e.applySolution(a),i.set(n,a),i.set(e.regulationHash,e.asSolution()),t.logger.info(`[RegulateWithTopo] solutionStore set: ${e.measureIndex}, ${n}, ${e.regulationHash}`));const o=Ke(e);r?.({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=n.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:r}):void 0;return{baseCost:c-a,topoCost:Date.now()-c,baseMeasures:o,topoMeasures:l,qualityScore:n.qualityScore}},exports.doSimpleRegulate=Yi,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,r={},n=new Map,a=new Map,o=new Map;r.unitSize=e.unitSize,r.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===B.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(r.title.title=t.text,r.title.t={size:t.fontSize}),s?.length>0&&(s.sort((e,t)=>e.y-t.y),r.title.subtitle=s.map(e=>e.text).join("\n"),r.title.s={size:s.reduce((e,t)=>e+t.fontSize,0)/s.length});const i=c.filter(t=>t.type===B.Text&&"Author"===t.textType&&t.x>e.pages[0].width/2);i.length>0&&(r.title.composer=i.map(e=>e.text).join("\n"),r.title.c={size:i.reduce((e,t)=>e+t.fontSize,0)/i.length})}if(r.page={w:e.pages[0].width,h:e.pages[0].height},r.pages=e.pages.map(t=>{const s=t.source.dimensions.width/t.source.interval,i=t.source.dimensions.height/t.source.interval,[r,n,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:[r,n,a,o,-.5*r*s+-.5*i*a+.5*t.width||0,-.5*n*s+-.5*i*o+.5*t.height||0]}}),r.parts=[],r.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((r,m)=>{const f=r.staves.slice(),d=t.flat().map(e=>1<m+1&&(p[m+1]=p[m]);continue}const g=[];for(const e of l){const t=d[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 d=u.tip?u.tip.x:u.right-u.left/2;u.noteIds.forEach((e,i)=>{const r=s.get(e),m=`n_${t.length>1?c+"_":""}${f}_${y}`;y++,n.set(r.id,m),a.set(r.id,(r.left+r.right)/2-v),o.set(r.id,l+1),h.push({line:2*-u.ys[i],id:m,staff:l+1,x:(r.left+r.right)/2-d})}),i[f]=i[f]||[],i[f].push(d-v);const p=e.spartito.measures[r.headMeasureIndex+m].events.filter(e=>e.noteIds.some(e=>u.noteIds.includes(e)));x.push({elems:h,x:d-v,type:2**u.division,...p.some(e=>e.grace)?{grace:{}}:{}})}),h.measures[f]={w:p[m+1]-p[m],staves:l.length,notes:x}}});let m=null;e.spartito.measures.forEach((s,i)=>{const r=e.spartito.measureIndexMapping[i],n=s.contexts.flat().filter(e=>js.includes(e.tokenType)&&l.includes(e.staff)).map(e=>{const s=t.find(t=>t.includes(e.staff));return{x:e.x,clef:Hs(e),staff:s.indexOf(e.staff)+1,tick:e.tick}});n.length>0&&h.measures[r]&&(h.measures[r].clefs=n);const a=s.basics.filter((e,t)=>1<0&&(r.parts[c]=h)}e.systems.forEach((s,i)=>{const n=[],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 f=t.filter(e=>!!e);if(f.length>0){const e=f[0],t=f[f.length-1],s=e.top+e.staffY-2,i=t.top+t.staffY-2;l=s-c,u=i-s+4}const{list:d,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];n.push({distances:d,imgs:g,y:l,staves:r.length,parti:i,height:u,...o?{details:o}:{},clef:Object.fromEntries(e.spartito.measures[s.headMeasureIndex]?.contexts.flat().filter(e=>js.includes(e.tokenType)&&r.includes(e.staff)).map(e=>[e.staff,Hs(e)])),fifths:y.basics.filter((e,t)=>1<e.spartito.measureIndexMapping[s.headMeasureIndex+i]).filter(e=>Number.isFinite(e));r.lines[i]={m1:f[0],m2:f.length>0?f[f.length-1]+1:void 0,x:s.left,y:s.top+c,w:s.measureBars[s.measureBars.length-1],h:l-c+4,lineStaves:n}});const c={0:"default",1:"brace",2:"bracket",3:"square"},l=Ee(e.staffLayoutCode),u=l.partGroups.map(e=>({sort:e.range[0],part:e})).sort((e,t)=>e.sort-t.sort).map(e=>e.part);r.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&&(r.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,r;t.notation.measures.forEach((e,t)=>{const{numerator:s,denominator:n}=e.timeSignature;l.beats||l.beatsUnit||(l.beats=s,l.beatsUnit=n,i=s,r=n),l.beatInfos=l.beatInfos||[],i===s&&r===n||(i=s,r=n,l.beatInfos.push({tick:e.tick,beats:s,beatsUnit:n})),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 r=Array.from(new Set(t.notes.map(e=>e.tick))).sort((e,t)=>e-t);return t.notes.forEach(e=>{s.set(e.id,r.indexOf(e.tick))}),e[t.tick]={measure:i,duration:t.duration,note_ticks:r},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 r;switch(i){case"vi":case"vi1":case"vi2":r=40;break;case"viola":r=42;break;case"vo":r=55;break;case"basso":r=71;break;default:r=0}return{program:r,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 r,n=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);n=[e.staffLayout.staffIds.findIndex(e=>e===s?.key),e.staffLayout.staffIds.findIndex(e=>e===t?.key)],r=c.findIndex(e=>e.range[0]<=Math.min(...n)&&e.range[1]>=Math.max(...n))}if(Number.isFinite(r)&&r>-1){const e=u[r],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(r,1,t.filter(Boolean).map(t=>({...e,track:t}))),u=u.flat(),l.rightHandTrack=n[0],l.leftHandTrack=n[1]}else u.sort((e,t)=>e===u[r]?-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=n.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:n.get(e?.ids?.[0])}:{},tick:e.ticks,channel:e.channel,duration:e.duration,track:t,event:i,elem_ids:e?.ids.map(e=>n.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:r,midiJson:l}},exports.evaluateScoreQuality=async(e,t)=>(e.spartito?.regulated||await Yi(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:Ai,onReplaceImage:Pi})=>{const i=e.logger;s.outputWidth=s.outputWidth||1200,s.pageStore=s.pageStore||Ai,s.onReplaceImage=s.onReplaceImage||Pi,s.processes=Array.isArray(s.processes)&&s.processes.length>0?s.processes:["layout","text","gauge","mask","semantic","brackets"];const r=new OMRProgress(s.onProgress),n=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));r.setTotal("layout",o.length),r.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 f(e,i){const{url:n,key:o,layout:u,enableGauge:h}=t[i],m=yi(JSON.stringify({key:o||n,layout:u,enableGauge:h})),f=await s.pageStore.get(m),d=!s.renew&&(f&&!t[i].renew||!e.detection.areas?.length),p=a.pages[i]=d&&f?ae(f,$s):new Page({source:{name:o||("string"==typeof n&&/https?:\/\//.test(n)?n:null),size:0,url:n,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=d?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),r=i.getContext("2d");r.save();const{width:n,height:a}=i,[o,l,u,h]=e.source.matrix;r.setTransform(o,l,u,h,-.5*n+.5*o*n+.5*l*a,-.5*a+.5*u*n+.5*h*a),r.drawImage(s,0,0),r.restore();const m=e.source.interval;return e.layout.areas.map((t,i)=>{console.assert(t.staves?.middleRhos?.length,"[shootImageByDetection] empty area:",t);const n=r.getImageData(t.x,t.y,t.width,t.height),a=new c.Canvas(t.width,t.height);a.getContext("2d").putImageData(n,0,0);const o=t.staves,l={width:t.width,height:t.height},u=s.width/2/m,h=s.height/2/m,f={x:(t.x+t.staves.phi1)/m-u+e.width/2,y:t.y/m-h+e.height/2};e.systems[i]=vi({page:e,backgroundImage:a.toBufferSync("png"),detection:o,imageSize:l,position:f})}),i}({score:a,page:p,pageCanvas:l[i]});return r.increase("layout"),{page:p,omit:d,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 r=i.sort((e,t)=>t.vw-e.vw)[0],n=Math.max(...i.map(e=>e.hwr));e.unitSize=s/r.vw,e.pageSize={width:s,height:s*n}}(a,u,s.outputWidth);const d=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);r.setTotal("gauge",p),r.setTotal("mask",p),r.setTotal("semantic",p),r.setTotal("brackets",d);const g=[],y=[],v=Date.now();let x=0;for(const n of u.keys()){const o=[],{page:l,correctCanvas:d,omit:p,hash:v}=await f(u[n],n);if(o.push(m(l.source.url)),o.push(...l.systems.map(e=>m(e.backgroundImage))),i.info(`[predictor]: check_cache_pageIndex-${n} omit: ${p}`),p)y.push(n);else{const u=l.systems.map((e,t)=>e.staves.map((s,i)=>({pageIndex:n,systemIndex:t,staffIndex:i,page:l,system:e,staff:s}))).flat(1);await Mi([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:r,staves:{middleRhos:n,phi1:o}}=t.areas[s],l=n[0],u=n[n.length-1],h={x:i+o-4*a,y:r+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(d,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-${n}] duration: ${Date.now()-o}`);const h=await e.predictScoreImages("brackets",{buffers:u.map(e=>e.buffer)});r.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=d.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-${n}] duration: ${Date.now()-t}`),r.increase("text"),!s.title){const e=a.pages[0].tokens;if(Array.isArray(e)&&e.length>0){const[t]=e.filter(e=>e.type===B.Text&&"Title"===e.textType).sort((e,t)=>t.fontSize-e.fontSize);t&&(a.title=t.text)}}}catch(e){i.error(`[predictor]: text js [pageIndex-${n}] ${JSON.stringify(e)}`)}},async()=>{var c;await(c=async()=>{if(s.processes.includes("gauge")&&!1!==t[n].enableGauge){const t=await e.predictScoreImages("gauge",await Promise.all(u.map(async({staffIndex:e,system:t})=>{const s=Date.now(),r=await Ei(t,e,{paddingLeft:Si,spec:bi});return i.info(`[predictor]: gauge js shoot [page-${n}, staff-${e}] duration: ${Date.now()-s}`),r.toBufferSync("png")})));for(const[s,{system:n,staff:a,pageIndex:c,staffIndex:l}]of u.entries()){const u=Date.now();i.info(`[predictor]: gauge js [page-${c}, staff-${l}] start..`),await Ii({pyClients:e,system:n,staff:a,staffIndex:l,gaugeImage:t[s].image}),i.info(`[predictor]: gauge js [page-${c}, staff-${l}] duration: ${Date.now()-u}`),r.increase("gauge"),o.push(m(a.backgroundImage))}}else for(const[e,{system:t,staff:s,staffIndex:i}]of u.entries())await Ni({system:t,staff:s,staffIndex:i}),o.push(m(s.backgroundImage))},c()),await Mi([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 Ci({staff:s,staffIndex:a,maskImage:t[e].image}),i.info(`[predictor]: mask js [page-${n}, ${e}, staff-${a}] duration: ${Date.now()-c}`),r.increase("mask"),o.push(m(s.maskImage))}},async()=>{if(!s.processes.includes("semantic"))return;const t=ae(await e.predictScoreImages("semantic",u.map(({staff:e})=>e.backgroundImage)),$s);u.forEach(({system:e})=>e.clearTokens());for(const[e,{staffIndex:s,system:o,staff:c}]of u.entries()){const l=Date.now();await _i({score:a,system:o,staff:c,staffIndex:s,graph:t[e]}),i.info(`[predictor]: semantic js [page-${n}, system-${o.index}, staff-${c.index}] duration: ${Date.now()-l}`),r.increase("semantic")}}])}]),++x}g.push(Promise.all(o).then(()=>(Oi(l,e=>h.get(e)),i.info(`[predictor]: pageStore set: [${n}]`),s.pageStore.set(v,JSON.stringify(l)))))}const S=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-n,pagesCost:S-v,pages:x}}},exports.regulateWithBeadSolver=async(e,{logger:t,pickers:s,solutionStore:i=$i,ignoreCache:r,freshOnly:n,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}.`,r?"ignoreCache":"",n?"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 Fs(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&&!r)for(const e of h){const t=await i.get(e.origin.regulationHash0);t&&(e.current.applySolution(t),++m.cached,e.evaluation=Ke(e.current),e.baseQuality=e.evaluation.qualityScore)}t?.info("[regulateWithBeadSolver]",`${m.cached}/${h.length}`,"solutions loaded.");const f=t?null:process.stdout;m.cached&&f?.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 d=h.filter(e=>e.picker&&(!e.evaluation||!e.evaluation.fine&&!n));d.forEach(e=>{const s=e.current.deepCopy();s.staffGroups=e.current.staffGroups,s.regulate({policy:"simple"});const i=Ke(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=d.length-m.simple,m.simple&&f?.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}`),f?.write(`[${s.fine?"32":s.error?"31":"33"}m${i?"+":"-"}`)},g=l.measures.length,y=()=>d.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 Hi(d,p,f,{stopLoss:.05,quotaMax:200,quotaFactor:3,ptFactor:1},ji.Imperfect,1,v),c?.(2,"NotFine",y()),m.tryTimes+=await Hi(d,p,f,{stopLoss:.08,quotaMax:1e3,quotaFactor:20,ptFactor:1.6},ji.NotFine,2,v),c?.(3,"ErrorOnly",y()),m.tryTimes+=await Hi(d,p,f,{stopLoss:.08,quotaMax:1e3,quotaFactor:40,ptFactor:3},ji.ErrorOnly,3,v),d.forEach(({evaluation:e,baseQuality:t,current:s,origin:r})=>{e.fine?++m.solved:e.error?++m.fatal:++m.issue,(e.qualityScore>t||!t)&&(i.set(r.regulationHash0,{...s.asSolution(r),priority:-s?.solutionStat?.loss}),s.regulationHash!==r.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),b=l.qualityScore,k=x-u;return t?.info("[regulateWithBeadSolver] done in ",k,"ms, qualityScore:",b),n&&(m.cached=0),{totalCost:x-u,pickerCost:S,measures:m,qualityScore:b}},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:r}={})=>{e.assemble();const n=e.spartito||e.makeSpartito(),a=t.map(e=>n.measures.find(t=>t.measureIndex===e)).filter(Boolean);if(r){const e=await r.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=$s,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/index.js.map b/backend/omr/dist/index.js.map index 669d4cda71fc5640997a73d2fbf51dec946fd8f2..d686007accef7cf86dfa3d8831b53d42647fd0d4 100644 --- a/backend/omr/dist/index.js.map +++ b/backend/omr/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../../src/starry/interfaces.ts","../../../src/starry/semanticPoint.ts","../../libs/browserComponents.ts","../../../src/starry/token.ts","../../../src/starry/aux_/typedJSON.ts","../../../src/measureLayout/measureLayout.ts","../../../src/measureLayout/grammar.jison.js","../../../src/staffLayout/staffLayout.ts","../../../src/staffLayout/grammar.jison.js","../../../src/staffLayout/parser.ts","../../../src/starry/logger.ts","../../../src/starry/utils.ts","../../../src/starry/term.ts","../../../src/starry/measureEvaluator.ts","../../../src/starry/semanticGraph.ts","../../../src/starry/scoreComponents.ts","../../../src/starry/semanticTopology.ts","../../../src/performer/types.ts","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifile.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/stream.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifileEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/streamEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiSequence.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MusicNotation.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiPlayer.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/config.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/node.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/navigator.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiUtils.js","../../../node_modules/@k-l-lambda/music-widgets/index.js","../../../src/performer/notation.ts","../../../node_modules/crypto-js/core.js","../../../node_modules/crypto-js/sha256.js","../../../src/starry/hashVector.ts","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/equationSolver.ts","../../../src/starry/eventTopology.ts","../../../src/starry/spartitoMeasure.ts","../../../src/starry/patch.ts","../../../src/starry/spartito.ts","../../../src/starry/staffContext.ts","../../../src/starry/score.ts","../../../src/measureLayout/parser.ts","../../../src/starry/editableMeasure.ts","../../../src/starry/beadSolver.ts","../../../src/isomorphic/converter.ts","../../../node_modules/events/events.js","../../libs/async-queue.ts","../../libs/ZeroClient.ts","../../libs/PyProcessor.ts","../../../node_modules/util/support/isBuffer.js","../../../node_modules/util/node_modules/inherits/inherits_browser.js","../../../node_modules/util/node_modules/inherits/inherits.js","../../../node_modules/util/util.js","../../libs/predictors.ts","../../../node_modules/crypt/crypt.js","../../../node_modules/charenc/charenc.js","../../../node_modules/sha1/sha1.js","../../libs/util.ts","../../libs/predictPages.ts","../../../src/starry/measureRectification.ts","../../libs/store.ts","../../libs/regulationBead.ts","../../libs/regulation.ts","../src/index.ts"],"sourcesContent":["import { MetaNotation, TokenPosition } from '../performer';\nimport { Term, EventTerm, ContextedTerm, ChordmodeTerm, MarkTerm, Accessory, GraceType, TremoloLink } from './term';\nimport { HashVector } from './hashVector';\nimport { StaffLayout } from '../staffLayout';\nimport * as measureLayout from '../measureLayout';\n\ninterface Rect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\ninterface ChordRect {\n\tx: number;\n\tstemX: number;\n\twidth: number;\n\ttop: number;\n\tbottom: number;\n\tstemDirection: string;\n\ttip?: { x: number; y: number };\n}\n\ninterface VLine {\n\tx: number;\n\ty1: number;\n\ty2: number;\n}\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ntype DivisionVecotor = [number, number, number, number, number, number, number, number, number]; // [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\ntype MeasureBarType = null | 'Terminal' | 'Segment' | 'VoltaRight';\n\ninterface EventFeature {\n\tdivisions: DivisionVecotor;\n\tdots: [number, number]; // [1, 2]\n\tbeams: [number, number, number]; // ['Open', 'Continue', 'Close']\n\tstemDirections: [number, number]; // ['u', 'd']\n\tgrace: number;\n\ttremoloCatcher: number;\n}\n\ninterface EventPredisposition {\n\tgrace: boolean;\n\ttimeWarped: number;\n\tfullMeasure: number;\n\tfake: number;\n\tfakeP: number;\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tdivisionVector: DivisionVecotor;\n\tdotsVector: [number, number, number]; // [0, 1, 2]\n\tbeamVector: [number, number, number, number]; // [null, open, continue, close]\n\tstemDirectionVector: [number, number, number]; // [null, up, down]\n}\n\ninterface ChordColumn {\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\tys: number[];\n\tnoteIds: string[]; // order by upwards\n\tdivision: number;\n\tdots: number;\n\trest: boolean;\n\tstemDirection: string;\n\taccessories?: Accessory[];\n\tgrace?: GraceType;\n\ttremolo?: number;\n\ttremoloLink?: TremoloLink;\n\tbeam?: string;\n\ttip?: { x: number; y: number };\n\n\t//stemTipY?: number;\n\n\t// for topology\n\tstaff?: number;\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature?: EventFeature;\n}\n\ninterface EventMeasure {\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[];\n}\n\ninterface StaffBasic {\n\ttimeSignature: Fraction;\n\ttimeSigNumeric: boolean;\n\tkeySignature: number;\n\tdoubtfulTimesig: boolean;\n}\n\ninterface EventMeasureColumn {\n\tmeasureIndex: number;\n\t//startX: number;\n\t//width: number;\n\n\trows: EventMeasure[]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\txMap?: Map;\n\tregularLoss?: number;\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n}\n\ninterface EventSystem {\n\tstaffMask: number;\n\tcolumns: EventMeasureColumn[]; // [measure]\n}\n\ninterface TermMeasure extends Partial {\n\tterms: Term[];\n\tduration: number;\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n}\n\ntype TermRow = TermMeasure[];\n\ninterface TermStaff {\n\trows: TermRow[]; // [system]\n}\n\ninterface Pitch {\n\tnote: number;\n\talter: number;\n}\n\nenum PageLayoutMethod {\n\tByLines = 'ByLines',\n\tByBlocks = 'ByBlocks',\n}\n\ninterface RecognitionSettings {\n\tenabledGauge: boolean; // staves straighten\n\tpageLayoutMethod: PageLayoutMethod;\n\tsemanticConfidenceThreshold: number;\n}\n\ninterface Crop {\n\taspect?: number | undefined;\n\tx?: number | undefined;\n\ty?: number | undefined;\n\twidth?: number | undefined;\n\theight?: number | undefined;\n\tunit?: 'px' | '%' | undefined;\n}\n\n//\t0 2 4\t\t\tr r tx\n//\t1 3 5\t\t\tr r ty\ntype Matrix2x3 = [number, number, number, number, number, number];\n\ninterface SourceImageFile {\n\tname: string;\n\tsize: number;\n\turl: string;\n\tcrop?: Crop;\n\tmatrix: Matrix2x3;\n\tdimensions: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tinterval: number;\n\tneedGauge?: boolean;\n}\n\ninterface Area extends Rect {\n\tstaves: {\n\t\tinterval: number;\n\t\tmiddleRhos: number[];\n\t\tphi1: number;\n\t\tphi2: number;\n\t};\n}\n\ninterface PageLayout {\n\tareas: Area[];\n}\n\ninterface MeasureBrief {\n\ttimeSignature: Fraction;\n}\n\ninterface VoiceMeasure {\n\ttickMap: { [key: number]: EventTerm | ChordmodeTerm };\n\tduration: number;\n\n\ttimeSignature?: Fraction;\n\ttimeSigNumeric?: boolean;\n\tkeySignature?: number;\n\n\tcontextedTerms: ContextedTerm[];\n\tmarks: MarkTerm[];\n\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbar?: string;\n\n\tempty?: boolean;\n\n\theadStaff?: number;\n\ttailStaff?: number;\n\n\ttrait?: HashVector;\n\tvoiceIndex?: number;\n}\n\ninterface TermVoice {\n\tmode: string;\n\tmeasures: VoiceMeasure[];\n}\n\ninterface VoicesStaff {\n\tcontext?: string;\n\tname?: string;\n\tvoices: TermVoice[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n\tslashSystemSeparator: boolean;\n}\n\ninterface MusicHeaders {\n\ttitle: string;\n\tsubtitle: string;\n\tsubsubtitle: string;\n\tcomposer: string;\n\tpoet: string;\n\tarranger: string;\n\topus: string;\n\tcopyright: string;\n\tinstrument: string;\n\tdedication: string;\n\ttagline: string;\n}\n\ninterface MusicSheet {\n\ttitle: string;\n\tpageSize: {\n\t\t// in pixels\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tunitSize: number;\n\tmeasureLayout?: measureLayout.MeasureLayout;\n\tstaffLayout: StaffLayout;\n\tpaperOptions?: Partial;\n\theaders: Partial;\n\n\tvoiceStaves: VoicesStaff[];\n\tinstrumentDict: { [key: string]: string };\n}\n\ninterface Performing {\n\tnotation: MetaNotation;\n\ttokenMap: Map;\n}\n\ntype RegulationPolicy = 'test' | 'simple' | 'equations' | 'advanced';\n\ninterface RegulationOptions {\n\tpolicy?: RegulationPolicy;\n\tquota?: number;\n\t[key: string]: any;\n}\n\ninterface ScoreData {\n\tversion?: number;\n\t[key: string]: any;\n}\n\ninterface AdditionalLineStack {\n\tleft: number;\n\tright: number;\n\tn: number;\n}\n\ninterface RegulationSolutionEvent {\n\tid: number;\n\ttick: number;\n\ttickGroup: number;\n\ttimeWarp: Fraction;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: string;\n\tgrace?: boolean;\n\tfullMeasure?: boolean;\n}\n\ninterface RegulationSolution {\n\tevents: RegulationSolutionEvent[];\n\tvoices: number[][];\n\tduration: number;\n\tpriority?: number;\n\testimatedDuration?: number;\n\ttimeSignature?: Fraction;\n}\n\ninterface BackgroundImage {\n\turl: string;\n\tposition: Rect;\n\toriginal?: boolean;\n}\n\nenum TextType { //\tLEVEL\t\t\tCHARSET\n\tTitle = 'Title', // page\t\t\t\tgeneral\n\tAuthor = 'Author', // page\t\t\t\tgeneral\n\tTempoText = 'TempoText', // measure\t\t\tspecific vocabulary\n\tTempoNumeral = 'TempoNumeral', // measure\t\t\tsymbolic and numeric\n\tTextualMark = 'TextualMark', // term\t\t\t\tspecific vocabulary\n\tLyric = 'Lyric', // term\t\t\t\tgeneral\n\tInstrument = 'Instrument', // system\t\t\tspecific vocabulary\n\tMeasureNumber = 'MeasureNumber', // system\t\t\tnumeric\n\tTimes = 'Times', // staff\t\t\tnumeric\n\tAlternation1 = 'Alternation1', // measure\t\t\tnumeric\n\tAlternation2 = 'Alternation2', // measure\t\t\tnumeric\n\tChord = 'Chord', // measure\t\t\tspecific domian\n\tPageMargin = 'PageMargin', // page\t\t\t\tgeneral\n\tOther = 'Other', // page\t\t\t\tgeneral\n}\n\nexport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tFraction,\n\tMeasureBarType,\n\tEventFeature,\n\tEventPredisposition,\n\tChordColumn,\n\tEventMeasure,\n\tEventMeasureColumn,\n\tEventSystem,\n\tTermMeasure,\n\tTermRow,\n\tTermStaff,\n\tPitch,\n\tPageLayoutMethod,\n\tRecognitionSettings,\n\tSourceImageFile,\n\tPageLayout,\n\tStaffBasic,\n\tVoiceMeasure,\n\tVoicesStaff,\n\tTermVoice,\n\tMeasureBrief,\n\tAdditionalLineStack,\n\tTextType,\n\tMusicSheet,\n\tPerforming,\n\tRegulationOptions,\n\tScoreData,\n\tMusicHeaders,\n\tMatrix2x3,\n\tRegulationSolutionEvent,\n\tRegulationSolution,\n\tBackgroundImage,\n};\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","globalThis.btoa = (str) => Buffer.from(str, 'binary').toString('base64');\nglobalThis.atob = (str) => Buffer.from(str, 'base64').toString('binary');\n","import { TextType } from './interfaces';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\n\nenum TokenType {\n\t// clefs\n\tClefG = 'clefs-G', // clefs.G_change\n\tClefF = 'clefs-F', // clefs.F_change\n\tClefC = 'clefs-C', // clefs.C_change\n\n\t// time signature\n\tTimesigC44 = 'timesig-C44',\n\tTimesigC22 = 'timesig-C22',\n\tTimesigZero = 'zero|timesig0',\n\tTimesigOne = 'one|timesig1',\n\tTimesigTwo = 'two|timesig2',\n\tTimesigThree = 'three|timesig3',\n\tTimesigFour = 'four|timesig4',\n\tTimesigFive = 'five|timesig5',\n\tTimesigSix = 'six|timesig6',\n\tTimesigSeven = 'seven|timesig7',\n\tTimesigEight = 'eight|timesig8',\n\tTimesigNine = 'nine|timesig9',\n\n\t// octave shifts\n\tOctaveShift8va = 'octave-a',\n\tOctaveShift8vb = 'octave-b',\n\tOctaveShift0 = 'octave-0',\n\n\t// numbers\n\tZero = 'zero|n0',\n\tOne = 'one|n1',\n\tTwo = 'two|n2',\n\tThree = 'three|n3',\n\tFour = 'four|n4',\n\tFive = 'five|n5',\n\tSix = 'six|n6',\n\tSeven = 'seven|n7',\n\tEight = 'eight|n8',\n\tNine = 'nine|n9',\n\n\t// accidentals\n\tAccNatural = 'accidentals-natural',\n\tAccSharp = 'accidentals-sharp',\n\tAccDoublesharp = 'accidentals-doublesharp',\n\tAccFlat = 'accidentals-flat',\n\tAccFlatflat = 'accidentals-flatflat',\n\tKeyNatural = 'accidentals-natural|key-natural',\n\tKeySharp = 'accidentals-sharp|key-sharp',\n\tKeyFlat = 'accidentals-flat|key-flat',\n\n\t// noteheads\n\tNoteheadS0 = 'noteheads-s0',\n\tNoteheadS1 = 'noteheads-s1',\n\tNoteheadS2 = 'noteheads-s2',\n\tNoteheadS1stemU = 'noteheads-s1|noteheads-s1-u',\n\tNoteheadS1stemD = 'noteheads-s1|noteheads-s1-d',\n\tNoteheadS2stemU = 'noteheads-s2|noteheads-s2-u',\n\tNoteheadS2stemD = 'noteheads-s2|noteheads-s2-d',\n\n\t// rests\n\tRest0 = 'rests-0o',\n\tRest1 = 'rests-1o',\n\tRest2 = 'rests-2',\n\tRest3 = 'rests-3',\n\tRest4 = 'rests-4',\n\tRest5 = 'rests-5',\n\tRest6 = 'rests-6',\n\tRest0W = 'rests-0',\n\tRestM1 = 'rests-M1',\n\n\t// flags\n\tFlag3 = 'flags-u3', // flags.d3\n\tFlag4 = 'flags-u4', // flags.d4\n\tFlag5 = 'flags-u5', // flags.d5\n\tFlag6 = 'flags-u6', // flags.d6\n\tFlag7 = 'flags-u7', // flags.d7\n\tFlag8 = 'flags-u8', // flags.d8\n\n\t// beams\n\tBeamLeft = '|beam-left',\n\tBeamRight = '|beam-right',\n\tBeamContinue = '|beam-continue',\n\n\t// tremolos\n\tTremoloLeft = '|tremolo-left',\n\tTremoloRight = '|tremolo-right',\n\tTremoloMiddle = '|tremolo-middle',\n\n\t// slur & tie\n\tSlurBegin = '|slur-begin',\n\tSlurEnd = '|slur-end',\n\tTieBegin = '|tie-begin',\n\tTieEnd = '|tie-end',\n\n\t// volta\n\tVoltaLeft = '|volta-left',\n\tVoltaRight = '|volta-right',\n\n\tVoltaAlternativeBegin = '|volta-alter-begin',\n\t//VoltaAlternativeEnd = \"|volta-alter-end\",\n\n\t// vertical bars\n\t//BarMeasure = \"|bar-measure\",\n\tBarTerminal = '|bar-terminal',\n\tBarSegment = '|bar-segment',\n\n\t// dots (duration)\n\tDot = '|dot',\n\tDotDot = '|dotdot',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\t//\n\tWedgeCrescendo = '|wedge-crescendo',\n\tWedgeDiminuendo = '|wedge-diminuendo',\n\tWedgeClose = '|wedge-close',\n\n\tCrescendoBegin = '|wedge-crescendo',\n\tDecrescendoBegin = '|wedge-diminuendo',\n\tCrescendoEnd = '|wedge-close',\n\tDecrescendoEnd = '|wedge-close',\n\n\t// scripts\n\tScriptFermata = 'scripts-ufermata', // scripts.dfermata\n\tScriptShortFermata = 'scripts-ushortfermata', // scripts.dshortfermata\n\tScriptSforzato = 'scripts-sforzato',\n\tScriptStaccato = 'scripts-staccato',\n\tScriptStaccatissimo = 'scripts-ustaccatissimo', // scripts.dstaccatissimo\n\tScriptTurn = 'scripts-turn',\n\tScriptTrill = 'scripts-trill',\n\tScriptSegno = 'scripts-segno',\n\tScriptCoda = 'scripts-coda',\n\tScriptArpeggio = 'scripts-arpeggio',\n\tScriptPrall = 'scripts-prall',\n\tScriptMordent = 'scripts-mordent',\n\tScriptMarcato = 'scripts-umarcato', // scripts.dmarcato\n\tScriptTenuto = 'scripts-tenuto',\n\tScriptPortato = 'scripts-uportato', // scripts.dportato\n\n\t// pedal\n\tPedalStar = 'pedal-star',\n\tPedalPed = 'pedal-Ped',\n\n\tText = '|text',\n\tGraceNotehead = '|grace-notehead',\n}\n\n// alias\nconst tt = TokenType;\n\nexport const TokenTypes = Object.values(TokenType);\nexport const TokenClefs = TokenTypes.filter((t) => /clefs-/.test(t));\nexport const TokenTimesigs = TokenTypes.filter((t) => /timesig/.test(t));\nexport const TokenTimesigsC = TokenTypes.filter((t) => /timesig-/.test(t));\nexport const TokenTimesigsN = TokenTypes.filter((t) => /timesig\\d/.test(t));\nexport const TokenOctshifts = TokenTypes.filter((t) => /octave-/.test(t));\nexport const TokenNumbers = TokenTypes.filter((t) => /n\\d/.test(t));\nexport const TokenAccidentals = TokenTypes.filter((t) => /accidentals-/.test(t));\nexport const TokenNoteheads = TokenTypes.filter((t) => /noteheads-/.test(t));\nexport const TokenBareNoteheads = [tt.NoteheadS0, tt.NoteheadS1, tt.NoteheadS2];\nexport const TokenDirectionalNoteheads = TokenTypes.filter((t) => /noteheads-.+-[ud]/.test(t));\nexport const TokenRests = TokenTypes.filter((t) => /rests-/.test(t));\nexport const TokenFlags = TokenTypes.filter((t) => /flags-/.test(t));\nexport const TokenVolta = TokenTypes.filter((t) => /volta-/.test(t));\nexport const TokenDynamics = TokenTypes.filter((t) => /^[a-z]$/.test(t));\nexport const TokenScripts = TokenTypes.filter((t) => /scripts-/.test(t));\nexport const TokenPedals = TokenTypes.filter((t) => /pedal-/.test(t));\nexport const TokenDots = [tt.Dot, tt.DotDot];\nexport const TokenArcs = [tt.SlurBegin, tt.SlurEnd, tt.TieBegin, tt.TieEnd];\nexport const TokenBeams = TokenTypes.filter((t) => /beam-/.test(t));\nexport const TokenWedges = TokenTypes.filter((t) => /wedge-/.test(t));\n\nexport const TokenAccessories = [\n\t...TokenNumbers,\n\t...TokenDynamics,\n\t...TokenWedges,\n\t...TokenPedals,\n\t...TokenArcs,\n\n\ttt.ScriptFermata,\n\ttt.ScriptShortFermata,\n\ttt.ScriptSforzato,\n\ttt.ScriptStaccato,\n\ttt.ScriptStaccatissimo,\n\ttt.ScriptTurn,\n\ttt.ScriptTrill,\n\ttt.ScriptPrall,\n\ttt.ScriptMordent,\n\ttt.ScriptMarcato,\n\ttt.ScriptTenuto,\n\ttt.ScriptPortato,\n];\n\nexport const TokenDirectionless = [...TokenPedals];\n\nexport const TokenGlyphs = [\n\t...TokenClefs,\n\t...TokenTimesigs,\n\t...TokenNumbers,\n\t...TokenAccidentals,\n\ttt.NoteheadS0,\n\ttt.NoteheadS1,\n\ttt.NoteheadS2,\n\t...TokenRests,\n\t...TokenDynamics,\n\t...TokenScripts,\n\t...TokenPedals,\n\t...TokenDots,\n];\n\nconst TOKEN_Y_ROUND = {} as Record;\nTokenClefs.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenTimesigsN.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenAccidentals.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenNoteheads.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenRests.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenDots.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\n\nconst TOKEN_Y_FIXED = {} as Record;\nTokenTimesigsC.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\nTokenVolta.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\n\nclass Token {\n\tstatic className = 'Token';\n\n\tid: string;\n\ttype: TokenType;\n\tx: number;\n\ty: number;\n\tpivotX?: number;\n\n\tconfidence: number;\n\n\ttip?: { x: number; y: number };\n\n\tvoice?: number; // integer, every bit stand for a voice\n\ttimeWarped?: boolean;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tget typeId(): string {\n\t\treturn this.type.split('|').reverse()[0];\n\t}\n\n\tget isPredicted(): boolean {\n\t\treturn Number.isFinite(this.confidence);\n\t}\n\n\tget isNotehead(): boolean {\n\t\treturn TokenDirectionalNoteheads.includes(this.type) || this.type === TokenType.NoteheadS0;\n\t}\n\n\tget isContexted(): boolean {\n\t\treturn (\n\t\t\tTokenClefs.includes(this.type) || TokenTimesigs.includes(this.type) || TokenOctshifts.includes(this.type) || TokenAccidentals.includes(this.type)\n\t\t);\n\t}\n\n\tget isAccessory(): boolean {\n\t\treturn TokenNumbers.includes(this.type) || TokenDynamics.includes(this.type) || TokenScripts.includes(this.type) || TokenPedals.includes(this.type);\n\t}\n\n\tget division(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Flag3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Flag4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Flag5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Flag6:\n\t\t\t\treturn 6;\n\n\t\t\tcase tt.Flag7:\n\t\t\t\treturn 7;\n\n\t\t\tcase tt.Flag8:\n\t\t\t\treturn 8;\n\n\t\t\tcase tt.RestM1:\n\t\t\t\treturn -1;\n\n\t\t\tcase tt.Rest0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.Rest1:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.Rest2:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Rest3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Rest4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Rest5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Rest6:\n\t\t\t\treturn 6;\n\n\t\t\t// TODO:\n\t\t\t//case tt.Rest0W:\n\t\t\t//\treturn 0;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget dots(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.Dot:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.DotDot:\n\t\t\t\treturn 2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget direction(): 'u' | 'd' | null {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn 'u';\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 'd';\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget width(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS2;\n\t\t}\n\t}\n\n\tget left(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x - this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x - this.width;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget right(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x + this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x + this.width;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget voiceIndices(): number[] {\n\t\tif (!this.voice || this.voice < 0) return [];\n\n\t\treturn Array(Math.floor(Math.log2(this.voice)) + 1)\n\t\t\t.fill(null)\n\t\t\t.reduce((indices, _, i) => (this.voice & (1 << i) ? [i + 1, ...indices] : indices), []);\n\t}\n}\n\nclass TextToken extends Token {\n\ttextType: TextType;\n\ttext: string;\n\ttextFeature?: Record;\n\twidth_: number;\n\tfontSize: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t\tObject.assign(this, data);\n\t}\n\n\tget width(): number {\n\t\treturn this.width_;\n\t}\n\n\tset width(value: number) {\n\t\tthis.width_ = value;\n\t}\n}\n\nexport { TokenType, Token, TextToken, TOKEN_Y_ROUND, TOKEN_Y_FIXED };\n","import pick from 'lodash/pick';\n\nconst recoverJSON = (json: string | object, classDict): T => {\n\tif (typeof json === 'object') json = JSON.stringify(json);\n\n\treturn JSON.parse(json, (_, value) => {\n\t\tif (value && typeof value === 'object' && value.__prototype) {\n\t\t\tconst Class = classDict[value.__prototype];\n\t\t\tif (Class) {\n\t\t\t\tconst { __prototype, ...fields } = value;\n\t\t\t\treturn new Class(fields);\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t});\n};\n\nconst deepCopy = (o: any, dict: Map = null): any => {\n\tdict = dict || new Map();\n\tif (dict.get(o)) return dict.get(o);\n\n\tif (Array.isArray(o)) {\n\t\tconst result = [];\n\t\tdict.set(o, result);\n\n\t\to.forEach((e) => result.push(deepCopy(e, dict)));\n\n\t\treturn result;\n\t} else if (o && typeof o === 'object') {\n\t\tconst result = {};\n\t\tdict.set(o, result);\n\n\t\tObject.entries(o).forEach(([key, value]) => (result[key] = deepCopy(value, dict)));\n\t\tObject.setPrototypeOf(result, o.__proto__);\n\n\t\treturn result;\n\t}\n\n\treturn o;\n};\n\nclass SimpleClass {\n\tassign(data?: object) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\ttoJSON() {\n\t\tconst cls = this.constructor as any;\n\n\t\tconst serializedKeys = cls.serializedKeys || (cls.blackKeys && Object.keys(this).filter((key) => !cls.blackKeys.includes(key)));\n\t\tconst fields = serializedKeys ? pick(this, serializedKeys) : this;\n\n\t\treturn {\n\t\t\t__prototype: cls.className,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tdeepCopy(): this {\n\t\treturn deepCopy(this);\n\t}\n}\n\nexport { recoverJSON, SimpleClass };\n","import { SimpleClass } from '../starry/aux_/typedJSON';\n\nenum LayoutType {\n\tOrdinary = 'ordinary',\n\tFull = 'full',\n\tConservative = 'conservative',\n\tOnce = 'once',\n}\n\ninterface MeasureLayout {\n\tserialize(type: LayoutType): number[];\n\n\tseq: MeasureSeq;\n\tcode: string;\n}\n\nexport type MeasureSeq = MeasureLayout[];\n\nconst spreadMeasureSeq = (seq: MeasureSeq, type: LayoutType = LayoutType.Ordinary): number[] => [].concat(...seq.map((layout) => layout.serialize(type)));\n\nconst seqToCode = (seq: MeasureSeq, { withBrackets = false }: { withBrackets?: boolean } = {}): string => {\n\t//const code = seq.map(layout => layout.code).join(\", \");\n\tlet code = '';\n\tlet inRange = false;\n\n\tfor (let i = 0; i < seq.length; ++i) {\n\t\tconst middle = seq[i - 1] instanceof SingleMLayout && seq[i] instanceof SingleMLayout && seq[i + 1] instanceof SingleMLayout;\n\t\tif (middle) {\n\t\t\tif (!inRange) {\n\t\t\t\tcode += '..';\n\t\t\t\tinRange = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (i > 0 && !inRange) code += ', ';\n\n\t\t\tinRange = false;\n\n\t\t\tcode += seq[i].code;\n\t\t}\n\t}\n\n\treturn withBrackets ? `[${code}]` : code;\n};\n\nclass SingleMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'SingleMLayout';\n\n\tmeasure: number;\n\n\tstatic from(measure: number) {\n\t\tconst layout = new SingleMLayout();\n\t\tlayout.measure = measure;\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(): number[] {\n\t\treturn [this.measure];\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this];\n\t}\n\n\tget code(): string {\n\t\treturn this.measure.toString();\n\t}\n}\n\nclass BlockMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'BlockMLayout';\n\n\tseq: MeasureSeq;\n\n\tstatic trimSeq(seq: MeasureSeq): MeasureSeq {\n\t\tconst seq2 = [];\n\t\tfor (const layout of seq) {\n\t\t\tif (layout instanceof BlockMLayout) {\n\t\t\t\tfor (const sub of layout.seq) seq2.push(sub);\n\t\t\t} else seq2.push(layout);\n\t\t}\n\n\t\t// reduce duplicated or backwards single measures\n\t\tconst seq3 = [];\n\t\tlet measure = null;\n\t\tfor (const layout of seq2) {\n\t\t\tif (layout instanceof SingleMLayout) {\n\t\t\t\tif (layout.measure > measure) {\n\t\t\t\t\tseq3.push(layout);\n\t\t\t\t\tmeasure = layout.measure;\n\t\t\t\t}\n\t\t\t} else seq3.push(layout);\n\t\t}\n\n\t\treturn seq3;\n\t}\n\n\tstatic fromSeq(seq: MeasureSeq): BlockMLayout {\n\t\tconst layout = new BlockMLayout();\n\t\tlayout.seq = BlockMLayout.trimSeq(seq);\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\treturn spreadMeasureSeq(this.seq, type);\n\t}\n\n\tget code(): string {\n\t\treturn seqToCode(this.seq, { withBrackets: true });\n\t}\n}\n\nclass VoltaMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'VoltaMLayout';\n\n\ttimes: number;\n\tbody: MeasureSeq;\n\talternates: MeasureSeq[];\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst bodySeq = spreadMeasureSeq(this.body);\n\n\t\tif (this.alternates) {\n\t\t\tconst alternateSeqs = this.alternates.map((seq) => spreadMeasureSeq(seq));\n\t\t\tconst lastAlternateSeq = alternateSeqs[alternateSeqs.length - 1];\n\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\t\treturn bodySeq.concat(...alternateSeqs);\n\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Full: {\n\t\t\t\t\tconst priorSeq = [].concat(\n\t\t\t\t\t\t...Array(this.times - 1)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map((_, i) => [...bodySeq, ...alternateSeqs[i % (this.times - 1)]])\n\t\t\t\t\t);\n\n\t\t\t\t\treturn [...priorSeq, ...bodySeq, ...lastAlternateSeq];\n\t\t\t\t}\n\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn [...bodySeq, ...lastAlternateSeq];\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn bodySeq;\n\n\t\t\t\tcase LayoutType.Full:\n\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t...Array(this.times)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map(() => bodySeq)\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconsole.warn('the current case not handled:', type, this);\n\t}\n\n\tget seq(): MeasureSeq {\n\t\tconst alternates = this.alternates ? this.alternates[this.alternates.length - 1] : [];\n\n\t\treturn [...this.body, ...alternates];\n\t}\n\n\tget code(): string {\n\t\tconst body = seqToCode(this.body, { withBrackets: true });\n\n\t\tlet code = `${this.times}*${body}`;\n\t\tif (this.alternates) code += '{' + this.alternates.map((seq) => seqToCode(seq, { withBrackets: seq.length > 1 })).join(', ') + '}';\n\n\t\treturn code;\n\t}\n}\n\nclass ABAMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'ABAMLayout';\n\n\tmain: MeasureLayout;\n\trest: MeasureSeq;\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst seqA = this.main.serialize(type);\n\t\tconst seqA_ = spreadMeasureSeq(this.main.seq, LayoutType.Once);\n\t\tconst seqB = spreadMeasureSeq(this.rest, type);\n\n\t\tswitch (type) {\n\t\t\tcase LayoutType.Ordinary: // A B\n\t\t\t\treturn [...seqA, ...seqB];\n\n\t\t\tcase LayoutType.Once: // B A'\n\t\t\t\treturn [...seqB, ...seqA_];\n\n\t\t\tcase LayoutType.Conservative: // A B A'\n\t\t\tcase LayoutType.Full: // A B A'\n\t\t\t\treturn [...seqA, ...seqB, ...seqA_];\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('the current case not handled:', type, this);\n\t\t}\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this.main, ...this.rest];\n\t}\n\n\tget code(): string {\n\t\treturn '<' + this.main.code + ', ' + seqToCode(this.rest) + '>';\n\t}\n}\n\nexport { LayoutType, MeasureLayout, SingleMLayout, BlockMLayout, VoltaMLayout, ABAMLayout };\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 13],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 15],\n\t\t$V3 = [1, 26],\n\t\t$V4 = [1, 29],\n\t\t$V5 = [1, 28],\n\t\t$V6 = [1, 30],\n\t\t$V7 = [5, 13, 22, 27, 29],\n\t\t$V8 = [2, 15],\n\t\t$V9 = [1, 32],\n\t\t$Va = [5, 14, 21, 22, 27, 28, 29];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tmeasure_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tindex_wise_measure_layout: 6,\n\t\t\t'i:': 7,\n\t\t\t's:': 8,\n\t\t\tsegment_wise_measure_layout: 9,\n\t\t\tiw_sequence: 10,\n\t\t\tiw_item: 11,\n\t\t\trange: 12,\n\t\t\t',': 13,\n\t\t\tUNSIGNED: 14,\n\t\t\t'..': 15,\n\t\t\tsingle: 16,\n\t\t\tiw_block_item: 17,\n\t\t\tiw_volta: 18,\n\t\t\tiw_aba: 19,\n\t\t\tiw_block: 20,\n\t\t\t'[': 21,\n\t\t\t']': 22,\n\t\t\t'*': 23,\n\t\t\tiw_optional_alternates: 24,\n\t\t\tiw_alternates: 25,\n\t\t\t'{': 26,\n\t\t\t'}': 27,\n\t\t\t'<': 28,\n\t\t\t'>': 29,\n\t\t\tsw_sequence: 30,\n\t\t\tsw_item: 31,\n\t\t\tsegment: 32,\n\t\t\tsw_block_item: 33,\n\t\t\tsw_volta: 34,\n\t\t\tsw_aba: 35,\n\t\t\tsw_block: 36,\n\t\t\tsw_optional_alternates: 37,\n\t\t\tsw_alternates: 38,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: {\n\t\t\t2: 'error',\n\t\t\t5: 'EOF',\n\t\t\t7: 'i:',\n\t\t\t8: 's:',\n\t\t\t13: ',',\n\t\t\t14: 'UNSIGNED',\n\t\t\t15: '..',\n\t\t\t21: '[',\n\t\t\t22: ']',\n\t\t\t23: '*',\n\t\t\t26: '{',\n\t\t\t27: '}',\n\t\t\t28: '<',\n\t\t\t29: '>',\n\t\t},\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[4, 2],\n\t\t\t[4, 2],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 3],\n\t\t\t[10, 3],\n\t\t\t[12, 3],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[16, 1],\n\t\t\t[17, 1],\n\t\t\t[20, 3],\n\t\t\t[18, 4],\n\t\t\t[24, 0],\n\t\t\t[24, 1],\n\t\t\t[25, 3],\n\t\t\t[19, 5],\n\t\t\t[9, 1],\n\t\t\t[30, 1],\n\t\t\t[30, 2],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[32, 1],\n\t\t\t[33, 1],\n\t\t\t[36, 3],\n\t\t\t[34, 4],\n\t\t\t[37, 0],\n\t\t\t[37, 1],\n\t\t\t[38, 3],\n\t\t\t[35, 4],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.$ = root(null, $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = root('index-wise', $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tthis.$ = root('segment-wise', serialize($$[$0]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 5:\n\t\t\t\tcase 23:\n\t\t\t\t\tif ($$[$0].length === 1 && $$[$0][0].__prototype === 'BlockMLayout') this.$ = $$[$0][0];\n\t\t\t\t\telse this.$ = blockLayout($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\tcase 24:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 7:\n\t\t\t\tcase 11:\n\t\t\t\tcase 12:\n\t\t\t\tcase 13:\n\t\t\t\tcase 14:\n\t\t\t\tcase 20:\n\t\t\t\tcase 27:\n\t\t\t\tcase 28:\n\t\t\t\tcase 29:\n\t\t\t\tcase 35:\n\t\t\t\t\tthis.$ = $$[$0];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 8:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 9:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], ...$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 10:\n\t\t\t\t\tthis.$ = range($$[$0 - 2], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = singleLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 16:\n\t\t\t\tcase 31:\n\t\t\t\t\tthis.$ = blockLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 17:\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 18:\n\t\t\t\tcase 33:\n\t\t\t\t\tthis.$ = voltaBlock($$[$0 - 3], $$[$0 - 1], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 19:\n\t\t\t\tcase 34:\n\t\t\t\t\tthis.$ = null;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 36:\n\t\t\t\t\tthis.$ = alternates($$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 3], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\t\tthis.$ = blockLayout([$$[$0]]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 30:\n\t\t\t\t\tthis.$ = segment($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 37:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 2], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 6: 3, 7: [1, 4], 8: [1, 5], 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 17] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 6: 18, 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 9: 19, 14: $V3, 21: $V4, 28: $V5, 30: 20, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 5: [2, 5], 13: $V6 },\n\t\t\to($V7, [2, 6]),\n\t\t\to($V7, [2, 7]),\n\t\t\to($V7, [2, 11]),\n\t\t\to($V7, [2, 12]),\n\t\t\to($V7, [2, 13]),\n\t\t\to($V7, [2, 14]),\n\t\t\to($V7, $V8, { 15: [1, 31], 23: $V9 }),\n\t\t\to($V7, [2, 16]),\n\t\t\t{ 11: 33, 14: [1, 34], 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 10: 35, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [2, 1] },\n\t\t\t{ 5: [2, 3] },\n\t\t\t{ 5: [2, 4] },\n\t\t\t{ 5: [2, 23], 14: $V3, 21: $V4, 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 24]),\n\t\t\to($Va, [2, 26]),\n\t\t\to($Va, [2, 27]),\n\t\t\to($Va, [2, 28]),\n\t\t\to($Va, [2, 29]),\n\t\t\to($Va, [2, 30], { 23: [1, 37] }),\n\t\t\to($Va, [2, 31]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 31: 38, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 39, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 11: 40, 12: 41, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 14: [1, 42] },\n\t\t\t{ 20: 43, 21: $V1 },\n\t\t\t{ 13: [1, 44] },\n\t\t\t{ 13: $V8, 23: $V9 },\n\t\t\t{ 13: $V6, 22: [1, 45] },\n\t\t\to($Va, [2, 25]),\n\t\t\t{ 21: $V4, 36: 46 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 47, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 22: [1, 48], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 8]),\n\t\t\to($V7, [2, 9]),\n\t\t\to($V7, [2, 10]),\n\t\t\to($V7, [2, 19], { 24: 49, 25: 50, 26: [1, 51] }),\n\t\t\t{ 10: 52, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\to([5, 13, 22, 26, 27, 29], [2, 17]),\n\t\t\to($Va, [2, 34], { 37: 53, 38: 54, 26: [1, 55] }),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 29: [1, 56], 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to([5, 14, 21, 22, 26, 27, 28, 29], [2, 32]),\n\t\t\to($V7, [2, 18]),\n\t\t\to($V7, [2, 20]),\n\t\t\t{ 10: 57, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 13: $V6, 29: [1, 58] },\n\t\t\to($Va, [2, 33]),\n\t\t\to($Va, [2, 35]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 59, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 37]),\n\t\t\t{ 13: $V6, 27: [1, 60] },\n\t\t\to($V7, [2, 22]),\n\t\t\t{ 14: $V3, 21: $V4, 27: [1, 61], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 21]),\n\t\t\to($Va, [2, 36]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 17: [2, 1], 18: [2, 3], 19: [2, 4] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tconst root = (type, data) => ({ __prototype: 'MesaureLayout', type, data });\n\n\tconst singleLayout = (n) => ({ __prototype: 'SingleMLayout', measure: Number(n) });\n\tconst blockLayout = (seq) => ({ __prototype: 'BlockMLayout', seq });\n\tconst voltaBlock = (times, body, alternates) => ({ __prototype: 'VoltaMLayout', times: Number(times), body, alternates });\n\tconst abaBlock = (main, rest) => ({ __prototype: 'ABAMLayout', main, rest });\n\n\tconst segment = (n) => ({ segment: true, length: Number(n) });\n\n\tconst alternates = (items) =>\n\t\titems.map((item) => {\n\t\t\tif (item.__prototype === 'BlockMLayout') return item.seq;\n\n\t\t\treturn [item];\n\t\t});\n\n\tconst range = (start, end) => {\n\t\tstart = Number(start);\n\t\tend = Number(end);\n\n\t\tif (!(end >= start)) throw new Error(`invalid measure range: ${start}..${end}`);\n\n\t\treturn Array(end + 1 - start)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => singleLayout(start + i));\n\t};\n\n\tconst serializeSeq = (item, options) => {\n\t\tif (item.segment) {\n\t\t\tconst index = options.index;\n\t\t\toptions.index += item.length;\n\n\t\t\treturn Array(item.length)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => singleLayout(index + i));\n\t\t}\n\n\t\treturn [serialize(item, options)];\n\t};\n\n\tconst serialize = (item, options = { index: 1 }) => {\n\t\tconst speard = (seq) => [].concat(...seq.map((it) => serializeSeq(it, options)));\n\n\t\tswitch (item.__prototype) {\n\t\t\tcase 'BlockMLayout':\n\t\t\t\titem.seq = speard(item.seq);\n\n\t\t\t\tbreak;\n\t\t\tcase 'VoltaMLayout':\n\t\t\t\titem.body = speard(item.body);\n\t\t\t\titem.alternates = item.alternates && item.alternates.map(speard);\n\n\t\t\t\tbreak;\n\t\t\tcase 'ABAMLayout':\n\t\t\t\titem.main = serialize(item.main, options);\n\t\t\t\titem.rest = speard(item.rest);\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn item;\n\t};\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 14;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([*,\\[\\]<>{}]))/, /^(?:(([1-9])([0-9])*))/, /^(?:(([a-z])+):)/, /^(?:\\.\\.)/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3, 4, 5], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","export interface RawItem {\n\tid: string;\n\tleftBounds: string[];\n\trightBounds: string[];\n\tconjunction: string;\n}\n\nexport enum StaffGroupType {\n\tDefault,\n\tBrace, // {}\n\tBracket, // <>\n\tSquare, // []\n}\n\nexport enum StaffConjunctionType {\n\tBlank,\n\tDashed,\n\tSolid,\n}\n\ntype StaffID = string;\n\nexport interface StaffGroup {\n\ttype: StaffGroupType;\n\tsubs?: StaffGroup[];\n\tstaff?: StaffID;\n\tlevel?: number;\n\tgrand?: boolean;\n}\n\ninterface StaffGroupTrait {\n\tgroup: StaffGroup;\n\trange: [number, number];\n\tkey: string;\n}\n\nconst singleGroup = (id: string) => ({ type: StaffGroupType.Default, staff: id });\n\nconst BOUNDS_TO_GROUPTYPE: { [bound: string]: StaffGroupType } = {\n\t'{': StaffGroupType.Brace,\n\t'}': StaffGroupType.Brace,\n\t'<': StaffGroupType.Bracket,\n\t'>': StaffGroupType.Bracket,\n\t'[': StaffGroupType.Square,\n\t']': StaffGroupType.Square,\n};\n\nconst OPEN_BOUNDS = '{<[';\nconst CLOSE_BOUNDS = '}>]';\n\nconst CONJUNCTIONS_MAP: { [conj: string]: StaffConjunctionType } = {\n\t',': StaffConjunctionType.Blank,\n\t'-': StaffConjunctionType.Solid,\n\t'.': StaffConjunctionType.Dashed,\n};\n\nconst bracketCode = (type: StaffGroupType, partial: boolean = false): ((inner: string) => string) => {\n\tif (type === StaffGroupType.Default) return (inner) => inner;\n\n\tif (partial) {\n\t\tswitch (type) {\n\t\t\tcase StaffGroupType.Brace:\n\t\t\t\treturn (inner) => `{${inner}`;\n\t\t\tcase StaffGroupType.Bracket:\n\t\t\t\treturn (inner) => `<${inner}`;\n\t\t\tcase StaffGroupType.Square:\n\t\t\t\treturn (inner) => `[${inner}`;\n\t\t\tdefault:\n\t\t\t\treturn (inner) => inner;\n\t\t}\n\t}\n\n\tswitch (type) {\n\t\tcase StaffGroupType.Brace:\n\t\t\treturn (inner) => `{${inner}}`;\n\t\tcase StaffGroupType.Bracket:\n\t\t\treturn (inner) => `<${inner}>`;\n\t\tcase StaffGroupType.Square:\n\t\t\treturn (inner) => `[${inner}]`;\n\t\tdefault:\n\t\t\treturn (inner) => inner;\n\t}\n};\n\nconst randomB64 = (): string => {\n\tconst code = btoa(Math.random().toString().substr(2)).replace(/=/g, '');\n\n\treturn code.split('').reverse().slice(0, 6).join('');\n};\n\nconst makeUniqueName = (set: Set, index: number, prefix?: string): string => {\n\tlet name = prefix;\n\tif (!name) name = index.toString();\n\telse if (set.has(name)) name += '_' + index.toString();\n\n\twhile (set.has(name)) name += '_' + randomB64();\n\n\treturn name;\n};\n\nconst makeGroupsFromRaw = (parent: StaffGroup, seq: string[]): string[] => {\n\tlet remains = seq;\n\twhile (remains.length) {\n\t\tconst word = remains.shift();\n\t\tconst bound = BOUNDS_TO_GROUPTYPE[word];\n\t\tif (bound) {\n\t\t\tif (CLOSE_BOUNDS.includes(word) && bound === parent.type) break;\n\n\t\t\tif (OPEN_BOUNDS.includes(word)) {\n\t\t\t\tconst group = { type: bound, level: Number.isFinite(parent.level) ? parent.level + 1 : 0 };\n\t\t\t\tremains = makeGroupsFromRaw(group, remains);\n\n\t\t\t\tparent.subs = parent.subs || [];\n\t\t\t\tparent.subs.push(group);\n\t\t\t}\n\t\t} else {\n\t\t\tparent.subs = parent.subs || [];\n\t\t\tparent.subs.push(singleGroup(word));\n\t\t}\n\t}\n\n\twhile (parent.type === StaffGroupType.Default && parent.subs && parent.subs.length === 1) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.type = sub.type;\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t\tparent.level = sub.level;\n\t}\n\n\twhile (parent.subs && parent.subs.length === 1 && parent.subs[0].type === StaffGroupType.Default) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t}\n\n\tparent.grand = parent.type === StaffGroupType.Brace && parent.subs && parent.subs.every((sub) => sub.staff);\n\n\treturn remains;\n};\n\nconst groupHead = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupHead(group.subs[0]);\n};\n\nconst groupTail = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupTail(group.subs[group.subs.length - 1]);\n};\n\nexport const groupKey = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return `${groupHead(group)}-${groupTail(group)}`;\n};\n\nconst groupDict = (group: StaffGroup, dict: { [key: string]: StaffGroup }): void => {\n\tdict[groupKey(group)] = group;\n\n\tif (group.subs) group.subs.forEach((sub) => groupDict(sub, dict));\n};\n\nexport interface MaskedStaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroups: StaffGroupTrait[];\n}\n\nclass StaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroup: StaffGroup;\n\tgroups: StaffGroupTrait[];\n\n\tmaskCache: Map;\n\n\tconstructor(raw: RawItem[]) {\n\t\t// make unique ids\n\t\tconst ids = new Set();\n\t\traw.forEach((item, i) => {\n\t\t\titem.id = makeUniqueName(ids, i + 1, item.id);\n\t\t\tids.add(item.id);\n\t\t});\n\t\tthis.staffIds = raw.map((item) => item.id);\n\t\tthis.conjunctions = raw.slice(0, raw.length - 1).map((item) => (item.conjunction ? CONJUNCTIONS_MAP[item.conjunction] : StaffConjunctionType.Blank));\n\n\t\t// make groups\n\t\tconst seq = [].concat(...raw.map((item) => [...item.leftBounds, item.id, ...item.rightBounds]));\n\t\tthis.group = { type: StaffGroupType.Default };\n\t\tmakeGroupsFromRaw(this.group, seq);\n\n\t\tconst dict = {};\n\t\tgroupDict(this.group, dict);\n\t\tthis.groups = Object.entries(dict).map(([key, group]) => {\n\t\t\tlet ids = key.split('-');\n\t\t\tif (ids.length === 1) ids = [ids[0], ids[0]];\n\t\t\tconst range = ids.map((id) => this.staffIds.indexOf(id));\n\n\t\t\treturn {\n\t\t\t\tgroup,\n\t\t\t\trange,\n\t\t\t\tkey,\n\t\t\t} as StaffGroupTrait;\n\t\t});\n\n\t\tthis.maskCache = new Map();\n\t}\n\n\tget stavesCount(): number {\n\t\tif (!this.staffIds) return null;\n\n\t\treturn this.staffIds.length;\n\t}\n\n\tget partGroups(): StaffGroupTrait[] {\n\t\tconst grands = this.groups.filter((g) => g.group.grand);\n\t\tconst parts = this.groups.filter((g) => {\n\t\t\tif (g.group.grand) return true;\n\n\t\t\tif (g.range[0] === g.range[1]) {\n\t\t\t\tconst index = g.range[0];\n\t\t\t\treturn !grands.some((g) => g.range[0] <= index && g.range[1] >= index);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn parts;\n\t}\n\n\tget standaloneGroups(): string[][] {\n\t\tconst groups: string[][] = [];\n\t\tconst collect = (group: StaffGroup): void => {\n\t\t\tif (group.grand) groups.push(group.subs.map((sub) => sub.staff));\n\t\t\telse if (group.staff) groups.push([group.staff]);\n\t\t\telse if (group.subs) group.subs.forEach((sub) => collect(sub));\n\t\t};\n\t\tcollect(this.group);\n\n\t\treturn groups;\n\t}\n\n\tconjunctionBetween(upStaff: number, downStaff: number): StaffConjunctionType {\n\t\tif (downStaff <= upStaff) return null;\n\n\t\tlet con = StaffConjunctionType.Solid;\n\t\tfor (let i = upStaff; i < downStaff; i++) con = Math.min(con, this.conjunctions[i]);\n\n\t\treturn con;\n\t}\n\n\tstatic makeMaskLayout(layout: StaffLayout, mask: number): MaskedStaffLayout {\n\t\tconst staffIds = layout.staffIds.filter((_, i) => mask & (1 << i));\n\t\tif (staffIds.length === layout.staffIds.length) {\n\t\t\treturn {\n\t\t\t\tstaffIds: layout.staffIds,\n\t\t\t\tconjunctions: layout.conjunctions,\n\t\t\t\tgroups: layout.groups,\n\t\t\t};\n\t\t}\n\n\t\tconst groups = layout.groups\n\t\t\t.map((g) => ({ ids: layout.staffIds.slice(g.range[0], g.range[1] + 1).filter((id) => staffIds.includes(id)), ...g }))\n\t\t\t.filter(({ ids }) => ids.length)\n\t\t\t.map(\n\t\t\t\t({ ids, ...g }) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tkey: g.key,\n\t\t\t\t\t\tgroup: g.group,\n\t\t\t\t\t\trange: [staffIds.indexOf(ids[0]), staffIds.indexOf(ids[ids.length - 1])],\n\t\t\t\t\t} as StaffGroupTrait)\n\t\t\t);\n\n\t\tconst conjunctions = staffIds.slice(0, staffIds.length - 1).map((id, i) => {\n\t\t\tconst nextId = staffIds[i + 1];\n\t\t\treturn layout.conjunctionBetween(layout.staffIds.indexOf(id), layout.staffIds.indexOf(nextId));\n\t\t});\n\n\t\treturn {\n\t\t\tstaffIds,\n\t\t\tconjunctions,\n\t\t\tgroups,\n\t\t};\n\t}\n\n\tmask(mask: number): MaskedStaffLayout {\n\t\tif (!this.maskCache.get(mask)) this.maskCache.set(mask, StaffLayout.makeMaskLayout(this, mask));\n\n\t\treturn this.maskCache.get(mask);\n\t}\n\n\t// {,}\t*\t1,1\t\t=> {,}\n\t// {,}\t*\t1,x\t\t=> {\n\t// {,}\t*\t0,x\t\t=>\n\t// {,}\t*\t0,1\t\t=> {}\n\tpartialMaskCode(bits: (1 | 0)[], withIds = false): string {\n\t\ttype Attendance = 0 | 1 | null;\n\t\tconst staffStatus = this.staffIds\n\t\t\t.map((_, i) => (i < bits.length ? bits[i] : null))\n\t\t\t.reduce((status, x, i) => {\n\t\t\t\tstatus[this.staffIds[i]] = x;\n\t\t\t\treturn status;\n\t\t\t}, {} as { [id: string]: Attendance });\n\n\t\tconst joinGroup = (group: StaffGroup): [string, boolean] => {\n\t\t\tif (group.staff) return [staffStatus[group.staff] ? group.staff : null, staffStatus[group.staff] === null];\n\n\t\t\tconst subs = group.subs.map((sub) => joinGroup(sub));\n\t\t\tconst subStr = subs\n\t\t\t\t.map((pair) => pair[0])\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(',');\n\t\t\tconst partial = subs.some(([_, partial]) => partial);\n\n\t\t\tconst code = subStr ? bracketCode(group.type, partial)(subStr) : null;\n\n\t\t\treturn [code, partial];\n\t\t};\n\n\t\tlet [code] = joinGroup(this.group);\n\t\tcode = code || '';\n\t\tif (!withIds) code = code.replace(/[_\\w]+/g, '');\n\n\t\treturn code;\n\t}\n}\n\nexport default StaffLayout;\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 15],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 17],\n\t\t$V3 = [1, 11],\n\t\t$V4 = [1, 12],\n\t\t$V5 = [1, 13],\n\t\t$V6 = [1, 24],\n\t\t$V7 = [1, 25],\n\t\t$V8 = [1, 26],\n\t\t$V9 = [5, 11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Va = [15, 16, 17, 21, 22, 23, 24],\n\t\t$Vb = [11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Vc = [5, 11, 12, 13, 21, 22, 23, 24];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tstaff_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tseq: 6,\n\t\t\tseq_id: 7,\n\t\t\tseq_br: 8,\n\t\t\tseq_con: 9,\n\t\t\tbound_left: 10,\n\t\t\t'<': 11,\n\t\t\t'[': 12,\n\t\t\t'{': 13,\n\t\t\tbound_right: 14,\n\t\t\t'>': 15,\n\t\t\t']': 16,\n\t\t\t'}': 17,\n\t\t\tbound_lefts: 18,\n\t\t\tbound_rights: 19,\n\t\t\tconjunction: 20,\n\t\t\t'-': 21,\n\t\t\t',': 22,\n\t\t\t'.': 23,\n\t\t\tID: 24,\n\t\t\tseq_bl: 25,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: { 2: 'error', 5: 'EOF', 11: '<', 12: '[', 13: '{', 15: '>', 16: ']', 17: '}', 21: '-', 22: ',', 23: '.', 24: 'ID' },\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[6, 0],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[18, 1],\n\t\t\t[18, 2],\n\t\t\t[19, 1],\n\t\t\t[19, 2],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[7, 1],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[25, 1],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[9, 1],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\t$$[$0].next();\n\n\t\t\t\t\tthis.$ = $$[$0].toJSON();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = new Seq();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 13:\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 14:\n\t\t\t\tcase 16:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 20:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.i($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 23:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\tcase 24:\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.bl($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\tcase 27:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 28:\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 29:\n\t\t\t\tcase 30:\n\t\t\t\tcase 31:\n\t\t\t\t\t$$[$0 - 1].tip.br($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.con($$[$0]);\n\t\t\t\t\tthis.$.next();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 33:\n\t\t\t\tcase 34:\n\t\t\t\tcase 35:\n\t\t\t\tcase 36:\n\t\t\t\t\t$$[$0 - 1].tip.con($$[$0]);\n\t\t\t\t\t$$[$0 - 1].next();\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 5: [2, 3], 6: 3, 7: 4, 8: 5, 9: 6, 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 10, 20: 9, 21: $V3, 22: $V4, 23: $V5, 24: [1, 7], 25: 8 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 18] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 5: [2, 4], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 22, 19: 20, 20: 21, 21: $V3, 22: $V4, 23: $V5, 24: [1, 19] },\n\t\t\t{ 5: [2, 5], 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 29, 20: 28, 21: $V3, 22: $V4, 23: $V5, 24: [1, 27] },\n\t\t\t{ 5: [2, 6], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 33, 19: 31, 20: 32, 21: $V3, 22: $V4, 23: $V5, 24: [1, 30] },\n\t\t\to($V9, [2, 20]),\n\t\t\t{ 14: 23, 15: $V6, 16: $V7, 17: $V8, 19: 35, 20: 36, 21: $V3, 22: $V4, 23: $V5, 24: [1, 34] },\n\t\t\to($V9, [2, 32]),\n\t\t\to($Va, [2, 25], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 17]),\n\t\t\to($V9, [2, 18]),\n\t\t\to($V9, [2, 19]),\n\t\t\to($Vb, [2, 13]),\n\t\t\to($Vb, [2, 7]),\n\t\t\to($Vb, [2, 8]),\n\t\t\to($Vb, [2, 9]),\n\t\t\t{ 1: [2, 1] },\n\t\t\to($V9, [2, 21]),\n\t\t\to($Vc, [2, 29], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 33]),\n\t\t\to($Va, [2, 26], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 15]),\n\t\t\to($V9, [2, 10]),\n\t\t\to($V9, [2, 11]),\n\t\t\to($V9, [2, 12]),\n\t\t\to($V9, [2, 23]),\n\t\t\to($V9, [2, 35]),\n\t\t\to($Va, [2, 27], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 24]),\n\t\t\to($Vc, [2, 31], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 36]),\n\t\t\to($Va, [2, 28], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 22]),\n\t\t\to($Vc, [2, 30], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 34]),\n\t\t\to($Vb, [2, 14]),\n\t\t\to($V9, [2, 16]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 18: [2, 1] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tclass Item {\n\t\tconstructor() {\n\t\t\tthis.id = null;\n\t\t\tthis.leftBounds = [];\n\t\t\tthis.rightBounds = [];\n\t\t\tthis.conjunction = null;\n\t\t}\n\n\t\ti(id) {\n\t\t\tthis.id = id;\n\t\t\treturn this;\n\t\t}\n\n\t\tbl(leftBounds) {\n\t\t\tthis.leftBounds = leftBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tbr(rightBounds) {\n\t\t\tthis.rightBounds = rightBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tcon(conjunction) {\n\t\t\tthis.conjunction = conjunction;\n\t\t\treturn this;\n\t\t}\n\t}\n\n\tclass Seq {\n\t\tconstructor() {\n\t\t\tthis.body = [];\n\t\t\tthis.tip = new Item();\n\t\t}\n\n\t\tnext() {\n\t\t\tthis.body.push(this.tip);\n\t\t\tthis.tip = new Item();\n\t\t\treturn this;\n\t\t}\n\n\t\ttoJSON() {\n\t\t\treturn this.body;\n\t\t}\n\t}\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 24;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([-,.\\[\\]<>{}]))/, /^(?:([a-zA-Z_0-9]+))/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\n// if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import StaffLayout from './staffLayout';\nimport grammar from './grammar.jison';\n\nconst parseCode = (code: string): StaffLayout => {\n\tconst raw = grammar.parse(code);\n\n\treturn new StaffLayout(raw);\n};\n\nexport { parseCode };\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","import { Fraction, Pitch, EventFeature, EventPredisposition } from './interfaces';\nimport { gcd, reducedFraction } from './utils';\nimport { TokenType } from './token';\nimport * as Token from './token';\nimport { SimpleClass } from './aux_/typedJSON';\n\nconst WHOLE_DURATION = 128 * 3 * 5;\nconst WHOLE_EXP2 = WHOLE_DURATION / 15;\n\nenum AccessoryDirection {\n\tUp = '^',\n\tDown = '_',\n\tMiddle = '-',\n}\n\nenum GraceType {\n\tGrace = 'grace',\n\tAfterGrace = 'afterGrace',\n\tAcciaccatura = 'acciaccatura',\n\tAppoggiatura = 'appoggiatura',\n\tSlashedGrace = 'slashedGrace',\n}\n\nenum StemBeam {\n\tOpen = 'Open',\n\tClose = 'Close',\n\tContinue = 'Continue',\n}\n\nenum TremoloLink {\n\tPitcher = 'Pitcher',\n\tCatcher = 'Catcher',\n\tPierced = 'Pierced',\n}\n\nenum GlissandoStyle {\n\tNormal = 'normal',\n\tDashedLine = 'dashed-line',\n\tDottedLine = 'dotted-line',\n\tZigzag = 'zigzag',\n\tTrill = 'trill',\n}\n\nenum ArpeggioStyle {\n\tNormal = 'Normal',\n\tBracket = 'Bracket',\n\tParenthesis = 'Parenthesis',\n\tParenthesisDashed = 'ParenthesisDashed',\n\tArrowDown = 'ArrowDown',\n}\n\ninterface Accessory {\n\tdirection?: AccessoryDirection;\n\tparenthesized?: boolean;\n\ttype: TokenType;\n\tid?: string;\n\tx: number;\n}\n\ninterface TermPitch extends Pitch {\n\ttying?: boolean;\n\ttied?: boolean;\n\tparenthesized?: boolean;\n\toctaveShift?: number;\n}\n\nclass Term extends SimpleClass {\n\tx: number;\n\tstaff?: number;\n}\n\ntype RestType = 'r' | 'R' | 's' | null;\n\ninterface DurationalTerm {\n\tdivision: number;\n\tdots: number;\n\tmultiplier?: Fraction;\n}\n\nconst SCALE_NAMES = 'CDEFGAB';\n\nclass EventTerm extends Term implements DurationalTerm {\n\tstatic className = 'EventTerm';\n\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\n\tsystem: number;\n\troundX: number; // for tick map, scheduler\n\tintX: number; // for measure hash\n\tintY: number;\n\tys: number[]; // order by ascending pitch, low (greater Y) to high (less Y)\n\tpitches?: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\taccessories: Accessory[];\n\tmultiplier: Fraction;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\trepetitionChord: boolean;\n\tgrace?: GraceType;\n\tbeam?: StemBeam;\n\ttimeWarp?: Fraction;\n\tparenthesized?: boolean;\n\ttremolo?: number; // like division, 'number of beams' + 2\n\ttremoloLink?: TremoloLink;\n\tglissando?: boolean;\n\tglissandoStyle?: GlissandoStyle;\n\tarpeggioStyle?: ArpeggioStyle;\n\ttip?: { x: number; y: number };\n\n\ttick: number;\n\n\t// for topology\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature: EventFeature;\n\tpredisposition: EventPredisposition;\n\n\tgraceIds?: number[];\n\tcatcherId?: number; // tremolo catcher event ID for tremolo pitcher event\n\n\tnoteIds?: string[]; // order by upwards\n\n\tstatic space({ tick, duration }: { tick: number; duration: number }): EventTerm {\n\t\tconst term = new EventTerm({\n\t\t\trest: 's',\n\t\t\ttick,\n\t\t\taccessories: [],\n\t\t});\n\t\tterm.duration = Math.round(duration);\n\n\t\treturn term;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tObject.assign(this, data);\n\n\t\tif (Number.isFinite(data.left) && Number.isFinite(data.right)) this.x = (this.left + this.right) / 2;\n\t\tif (!Number.isFinite(this.pivotX)) this.pivotX = this.x;\n\t\t//console.assert(Number.isFinite(this.x), \"EventTerm: invalid x,\", data);\n\t}\n\n\tget alignedTick(): number {\n\t\treturn this.grace ? this.tick + this.duration : this.tick;\n\t}\n\n\tget mainDuration(): number {\n\t\treturn WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t}\n\n\tget duration(): number {\n\t\tlet value = this.mainDuration;\n\t\tif (this.multiplier) value *= this.multiplier.numerator / this.multiplier.denominator;\n\t\tif (this.timeWarp) value *= this.timeWarp.numerator / this.timeWarp.denominator;\n\n\t\treturn this.grace ? value / 8 : value;\n\t}\n\n\tset duration(value: number) {\n\t\tconsole.assert(Number.isFinite(value), 'invalid duration value:', value);\n\n\t\tconst divider = gcd(value, WHOLE_EXP2);\n\t\tconst division = Math.log2(WHOLE_EXP2 / divider);\n\t\tconst multiplier = reducedFraction(value * 2 ** division, WHOLE_DURATION);\n\n\t\tthis.division = division;\n\t\tthis.dots = 0;\n\n\t\tif (multiplier.numerator !== multiplier.denominator) this.multiplier = multiplier;\n\t\telse this.multiplier = undefined;\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget times(): string {\n\t\tif (!this.timeWarp) return null;\n\n\t\treturn `${this.timeWarp.numerator}/${this.timeWarp.denominator}`;\n\t}\n\n\tget fullMeasureRest(): boolean {\n\t\treturn this.rest === 'R';\n\t}\n\n\tget tipX(): number {\n\t\treturn this.tip ? this.tip.x : this.x;\n\t}\n\n\tget tipY(): number {\n\t\treturn this.tip ? this.tip.y : this.ys ? this.ys[0] : 0;\n\t}\n\n\tget tremoloCatcher(): boolean {\n\t\treturn this.tremoloLink === TremoloLink.Catcher;\n\t}\n\n\tget scaleChord(): string {\n\t\treturn this.pitches.map((pitch) => SCALE_NAMES[(pitch.note + 700) % 7]).join('');\n\t}\n\n\tget zeroHolder(): boolean {\n\t\treturn !!this.grace || this.tremoloCatcher;\n\t}\n}\n\nenum ContextType {\n\tClef,\n\tKeyAcc,\n\tAcc,\n\tOctaveShift,\n\tTimeSignatureC,\n\tTimeSignatureN,\n}\n\nclass ContextedTerm extends Term {\n\tstatic className = 'ContextedTerm';\n\n\ty: number;\n\ttokenType: TokenType;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget type(): ContextType {\n\t\tif (Token.TokenClefs.includes(this.tokenType)) return ContextType.Clef;\n\t\tif (/\\|key-/.test(this.tokenType)) return ContextType.KeyAcc;\n\t\tif (/accidentals-/.test(this.tokenType)) return ContextType.Acc;\n\t\tif (Token.TokenOctshifts.includes(this.tokenType)) return ContextType.OctaveShift;\n\t\tif (Token.TokenTimesigsC.includes(this.tokenType)) return ContextType.TimeSignatureC;\n\t\tif (Token.TokenTimesigsN.includes(this.tokenType)) return ContextType.TimeSignatureN;\n\n\t\treturn null;\n\t}\n\n\tget staffLevel(): boolean {\n\t\treturn [ContextType.OctaveShift, ContextType.Clef, ContextType.KeyAcc].includes(this.type);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.1;\n\t}\n\n\tget clef(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.ClefG:\n\t\t\t\treturn -this.y - 2;\n\n\t\t\tcase TokenType.ClefF:\n\t\t\t\treturn -this.y + 2;\n\n\t\t\tcase TokenType.ClefC:\n\t\t\t\treturn -this.y;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget alter() {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.AccNatural:\n\t\t\tcase TokenType.KeyNatural:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.AccSharp:\n\t\t\tcase TokenType.KeySharp:\n\t\t\t\treturn 1;\n\n\t\t\tcase TokenType.AccFlat:\n\t\t\tcase TokenType.KeyFlat:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.AccDoublesharp:\n\t\t\t\treturn 2;\n\n\t\t\tcase TokenType.AccFlatflat:\n\t\t\t\treturn -2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget octaveShift(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.OctaveShift8va:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.OctaveShift0:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.OctaveShift8vb:\n\t\t\t\treturn 1;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget number(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.TimesigZero:\n\t\t\t\treturn 0;\n\t\t\tcase TokenType.TimesigOne:\n\t\t\t\treturn 1;\n\t\t\tcase TokenType.TimesigTwo:\n\t\t\t\treturn 2;\n\t\t\tcase TokenType.TimesigThree:\n\t\t\t\treturn 3;\n\t\t\tcase TokenType.TimesigFour:\n\t\t\t\treturn 4;\n\t\t\tcase TokenType.TimesigFive:\n\t\t\t\treturn 5;\n\t\t\tcase TokenType.TimesigSix:\n\t\t\t\treturn 6;\n\t\t\tcase TokenType.TimesigSeven:\n\t\t\t\treturn 7;\n\t\t\tcase TokenType.TimesigEight:\n\t\t\t\treturn 8;\n\t\t\tcase TokenType.TimesigNine:\n\t\t\t\treturn 9;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n//class BreakTerm extends Term {\n//};\n\nclass MarkTerm extends Term {\n\tstatic className = 'MarkTerm';\n\n\ttick: number;\n\n\tget prior(): number {\n\t\treturn this.tick + 0.01;\n\t}\n}\n\nconst MUSIC_NOTES = Array(7)\n\t.fill(0)\n\t.map((_, i) => String.fromCodePoint(0x1d15d + i));\n\nclass TempoTerm extends MarkTerm {\n\tstatic className = 'TempoTerm';\n\n\tduration: string;\n\tbeats: string;\n\n\tstatic fromNumeralText(text: string): TempoTerm {\n\t\tif (/.+=.*\\d+/.test(text)) {\n\t\t\tconst [symbol, value] = text.split('=');\n\t\t\tlet division = MUSIC_NOTES.findIndex((n) => symbol.includes(n));\n\t\t\tdivision = division >= 0 ? division : 2;\n\t\t\tlet duration = (2 ** division).toString();\n\t\t\tif (symbol.includes('.')) duration += '.';\n\n\t\t\treturn new TempoTerm({ tick: 0, duration, beats: value });\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.01;\n\t}\n\n\t// a whole note equal to 1920\n\tget durationMagnitude(): number {\n\t\tconst [_, den, dot] = this.duration.match(/^(\\d+)(\\.)?$/);\n\t\tconst magnitude = (WHOLE_DURATION / Number(den)) * (dot ? 1.5 : 1);\n\n\t\treturn magnitude;\n\t}\n\n\t// beats per minute, suppose 1 beat = 480 ticks\n\tget bpm(): number {\n\t\tconst [number] = this.beats.match(/\\d+/) || [90];\n\t\tconst beats = Number(number);\n\n\t\treturn (beats * this.durationMagnitude * 4) / WHOLE_DURATION;\n\t}\n\n\tisValid(range = [10, 400]): boolean {\n\t\tconst bpm = this.bpm;\n\n\t\treturn Number.isFinite(this.bpm) && bpm >= range[0] && bpm < range[1];\n\t}\n}\n\nclass GlyphTerm extends MarkTerm {\n\tstatic className = 'GlyphTerm';\n\n\tglyph: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass TextTerm extends MarkTerm {\n\tstatic className = 'TextTerm';\n\n\tdirection?: AccessoryDirection;\n\ttext: string;\n\tbold: boolean;\n\titalic: boolean;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass LyricTerm extends MarkTerm {\n\tstatic className = 'LyricTerm';\n\n\ttext: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass CommandTerm extends MarkTerm {\n\tstatic className = 'CommandTerm';\n\n\tcommand: string;\n\tparameters: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass ChordmodeTerm extends Term implements DurationalTerm {\n\tstatic className = 'ChordmodeTerm';\n\n\tpitch: Pitch;\n\tbasePitch?: Pitch;\n\tmodifier?: string;\n\n\tdivision: number;\n\tdots: number;\n\tmultiplier: Fraction;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget duration(): number {\n\t\tconst value = WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t\tif (this.multiplier) return (value * this.multiplier.numerator) / this.multiplier.denominator;\n\n\t\treturn value;\n\t}\n}\n\nexport {\n\tTerm,\n\tEventTerm,\n\tContextedTerm,\n\t//BreakTerm,\n\tMarkTerm,\n\tTempoTerm,\n\tGlyphTerm,\n\tTextTerm,\n\tLyricTerm,\n\tCommandTerm,\n\tChordmodeTerm,\n\tDurationalTerm,\n\tContextType,\n\tGraceType,\n\tTermPitch,\n\tRestType,\n\tGlissandoStyle,\n\tArpeggioStyle,\n\tAccessory,\n\tAccessoryDirection,\n\tWHOLE_DURATION,\n\tStemBeam,\n\tTremoloLink,\n};\n","import { fractionMul, gcd } from './utils';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { StemBeam, WHOLE_DURATION } from './term';\n\nexport interface MeasureEvaluation {\n\tevents: number;\n\tvalidEvents: number;\n\tvoiceRugged: boolean;\n\tnullEvents: number;\n\tfakeEvents: number;\n\twarpedEvents: number;\n\tcomplicatedTimewarp: boolean;\n\tspaceTime: number;\n\tsurplusTime: number;\n\tdurationRate: number;\n\tbeamBroken: boolean;\n\tfractionalWarp: boolean;\n\tirregularWarpsN: number;\n\tirregularTick: boolean;\n\ttickTwist: number;\n\ttickOverlapped: boolean;\n\tgraceInVoice: boolean;\n\tgraceN: number;\n\tgraceDominant: boolean;\n\tperfect: boolean;\n\tfine: boolean;\n\terror: boolean;\n\tqualityScore: number;\n}\n\nconst BEAM_STATUS = {\n\t[StemBeam.Open]: 1,\n\t[StemBeam.Continue]: 0,\n\t[StemBeam.Close]: -1,\n};\n\nexport const evaluateMeasure = (measure: SpartitoMeasure): MeasureEvaluation => {\n\tif (!measure.regulated) return undefined;\n\n\tconst eventMap = measure.eventMap;\n\n\tconst events = measure.events.length;\n\tconst validEvents = measure.voices.flat(1).length;\n\tconst warpedEvents = measure.events.filter((e) => e.timeWarp).length;\n\tconst warps = new Set(\n\t\tmeasure.events.filter((e) => e.timeWarp && !(e.rest && e.division === 0)).map((e) => `${e.timeWarp!.numerator}/${e.timeWarp!.denominator}`)\n\t);\n\tconst irregularWarps = new Set(warps);\n\tirregularWarps.delete('2/3');\n\n\tconst fractionalWarp = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tif (!events.some((e) => e.timeWarp)) return false;\n\n\t\tlet denominator = 0;\n\t\tlet tickSum = 0;\n\t\tlet eventN = 0;\n\t\treturn events.some((event, i) => {\n\t\t\tconst d = event.timeWarp ? event.timeWarp.denominator : 0;\n\t\t\tif (d !== denominator) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\n\t\t\t\ttickSum = 0;\n\t\t\t\teventN = 0;\n\t\t\t}\n\n\t\t\tdenominator = d;\n\t\t\ttickSum += event.duration;\n\t\t\t++eventN;\n\n\t\t\tif (i === events.length - 1) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst tickOverlapped = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tlet tick = 0;\n\t\treturn events.some((event) => {\n\t\t\tif (event.grace) return false;\n\n\t\t\tif (event.tick < tick) return true;\n\t\t\ttick = event.tick + event.duration;\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst fractionalTimes = new Set(measure.events.filter((e) => e.timeWarp && e.timeWarp.denominator > 3).map((e) => e.duration));\n\tconst complicatedTimewarp = fractionalTimes.size > 1;\n\n\tconst literalDuration = fractionMul(WHOLE_DURATION, measure.timeSignature);\n\tconst sigDuration = measure.doubtfulTimesig ? measure.duration : literalDuration;\n\n\tconst inVoiceEvents = measure.voices.flat(1).map((id) => eventMap[id]);\n\n\t// Guard: detect corrupted event data in voices (e.g. missing division, NaN tick)\n\tconst corruptedVoiceEvent = inVoiceEvents.some(\n\t\t(event) =>\n\t\t\t!event ||\n\t\t\t!Number.isFinite(event.tick) ||\n\t\t\t!Number.isFinite(event.division) ||\n\t\t\tevent.division < 0 ||\n\t\t\t!Number.isFinite(event.duration) ||\n\t\t\tevent.duration <= 0\n\t);\n\n\tconst overranged = inVoiceEvents.reduce((over, event) => over || event.tick < 0 || event.tick + event.duration > sigDuration, false);\n\tconst overDuration = measure.duration > literalDuration;\n\tconst graceInVoice = inVoiceEvents.some((event) => event.grace);\n\tconst graceN = measure.events.filter((e) => e.grace).length;\n\tconst graceDominant = graceN >= inVoiceEvents.length;\n\n\tconst irregularTick = inVoiceEvents.some((event) => {\n\t\tlet t = event.tick * 2 ** (event.division + 2);\n\t\tif (event.timeWarp) t *= event.timeWarp.denominator;\n\n\t\tif (!Number.isFinite(t)) return true;\n\n\t\tconst fragment = gcd(Math.round(t), WHOLE_DURATION);\n\t\t//if (fragment < WHOLE_DURATION)\n\t\t//\tconsole.log(\"irregularTick:\", event.tick, fragment);\n\t\treturn fragment < WHOLE_DURATION;\n\t});\n\n\tconst beamStatus = measure.voices!.map((voice) =>\n\t\tvoice.reduce(\n\t\t\t({ status, broken }, ei) => {\n\t\t\t\tconst event = eventMap[ei];\n\t\t\t\tif (event.beam) {\n\t\t\t\t\tstatus += BEAM_STATUS[event.beam];\n\t\t\t\t\tbroken = broken || !(status >= 0 && status <= 1);\n\t\t\t\t}\n\n\t\t\t\treturn { status, broken };\n\t\t\t},\n\t\t\t{ status: 0, broken: false }\n\t\t)\n\t);\n\tconst beamBroken = beamStatus.some(({ status, broken }) => status || broken);\n\tlet spaceTime = 0;\n\tlet surplusTime = 0;\n\tmeasure.voices!.forEach((voice) => {\n\t\tconst eventDuration = voice.reduce((sum, ei) => sum + eventMap[ei].duration, 0);\n\t\tspaceTime += Math.max(0, measure.duration - eventDuration);\n\t\tsurplusTime += Math.max(0, eventDuration - measure.duration);\n\t});\n\tspaceTime /= WHOLE_DURATION;\n\tconst nullEvents = measure.events.filter(\n\t\t(e) => !e.grace && !e.fullMeasureRest && !e.tremoloCatcher && (!e.predisposition || e.predisposition.fakeP < 0.1) && !Number.isFinite(e.tick)\n\t).length;\n\n\tconst fakeEvents = measure.events.filter(\n\t\t(event) => !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !inVoiceEvents.includes(event)\n\t).length;\n\n\tconst { voiceRugged } = measure.voices!.flat(1).reduce(\n\t\t(result, ei) => {\n\t\t\tif (!result.voiceRugged) {\n\t\t\t\tif (result.es.has(ei)) return { voiceRugged: true, es: result.es };\n\t\t\t}\n\n\t\t\tresult.es.add(ei);\n\n\t\t\treturn result;\n\t\t},\n\t\t{ voiceRugged: false, es: new Set() }\n\t);\n\n\tconst tickTwist = measure.tickTwist || 0;\n\n\tconst error =\n\t\tcorruptedVoiceEvent ||\n\t\ttickTwist >= 1 ||\n\t\ttickOverlapped ||\n\t\tvoiceRugged ||\n\t\tmeasure.tickRatesInStaves.some((rate) => rate < 0) ||\n\t\tnullEvents > 2 ||\n\t\t!measure.timeSignature ||\n\t\toverranged ||\n\t\tmeasure.duration > sigDuration ||\n\t\tmeasure.events.some((event) => event.timeWarp && event.timeWarp.numerator / event.timeWarp.denominator <= 0.5);\n\tconst perfect =\n\t\t!error &&\n\t\t!overDuration &&\n\t\ttickTwist < 0.2 &&\n\t\t!fractionalWarp &&\n\t\t!irregularWarps.size &&\n\t\t!irregularTick &&\n\t\t!spaceTime &&\n\t\t!surplusTime &&\n\t\t!!measure.voices!.length &&\n\t\t!beamBroken &&\n\t\t!graceInVoice &&\n\t\t!graceDominant &&\n\t\t(measure.duration === sigDuration || (Number.isFinite(measure.estimatedDuration) && measure.estimatedDuration <= sigDuration * 0.75));\n\tconst fine = !error && !overDuration && tickTwist < 0.3 && !fractionalWarp && !irregularTick && !surplusTime && !beamBroken && !graceInVoice;\n\n\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\tconst durationRate = measure.duration / expectDuration;\n\n\tlet qualityScore = 0;\n\tif (measure.patched && !corruptedVoiceEvent) qualityScore = 1;\n\telse if (!error) {\n\t\tconst spaceLoss = Math.tanh(Math.abs(spaceTime / Math.max(1, measure.voices.length)) * 1);\n\n\t\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\t\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\t\tconst durationLoss = expectDuration ? Math.max(0, 1 - durationRate) ** 2 : 0;\n\t\tconst warpsLoss = Math.tanh(irregularWarps.size);\n\n\t\tqualityScore = (1 - spaceLoss) * (1 - durationLoss) * (1 - warpsLoss) * (1 - tickTwist ** 2);\n\t}\n\n\treturn {\n\t\tevents,\n\t\tvalidEvents,\n\t\tvoiceRugged,\n\t\tnullEvents,\n\t\tfakeEvents,\n\t\twarpedEvents,\n\t\tcomplicatedTimewarp,\n\t\tspaceTime,\n\t\tsurplusTime,\n\t\tdurationRate,\n\t\tbeamBroken,\n\t\tfractionalWarp,\n\t\tirregularWarpsN: irregularWarps.size,\n\t\tirregularTick,\n\t\ttickTwist,\n\t\ttickOverlapped,\n\t\tgraceInVoice,\n\t\tgraceN,\n\t\tgraceDominant,\n\t\tperfect,\n\t\tfine,\n\t\terror,\n\t\tqualityScore,\n\t};\n};\n","//import { staffSvg } from \"@kelvinnxu/lotus\";\n\nimport { SemanticType, SemanticPoint, /*glyphSemanticMapping, glyphCenters,*/ SYSTEM_SEMANTIC_TYPES, Point } from './semanticPoint';\nimport { SimpleClass } from './aux_/typedJSON';\n\nclass SemanticGraph extends SimpleClass {\n\tstatic className = 'SemanticGraph';\n\n\tpoints: SemanticPoint[];\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\t/*static fromSheetStaff(staff: staffSvg.SheetStaff, hashTable: {[key: string]: any}): SemanticGraph {\n\t\tconst tokens = [].concat(...staff.measures.map(measure => measure.tokens));\n\n\t\tconst voltaRightXs = [];\n\n\t\tconst points = [];\n\t\ttokens.forEach(token => {\n\t\t\tconst def = hashTable[token.hash];\n\n\t\t\tif (token.glyph) {\n\t\t\t\tconst glyph = token.glyph as string;\n\t\t\t\tlet semantic = null;\n\n\t\t\t\tconst isKey = /^\\\\key/.test(token.source) || token.is(\"KEY\");\n\t\t\t\tlet { x: cx = 0, y: cy = 0 } = glyphCenters[glyph] || { x: 0, y: 0 };\n\t\t\t\tif (token.scale2) {\n\t\t\t\t\tcx *= token.scale2.x;\n\t\t\t\t\tcy *= token.scale2.y;\n\t\t\t\t}\n\n\t\t\t\tlet x = token.x + cx;\n\t\t\t\tconst y = token.y + cy;\n\n\t\t\t\tswitch (glyph) {\n\t\t\t\tcase \"rests.0\":\n\t\t\t\t\tif (/^R/.test(token.source))\n\t\t\t\t\t\tsemantic = \"Rest0W\";\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Rest0\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.flat\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.natural\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.sharp\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"dots.dot\":\n\t\t\t\t\tif (token.is(\"VOLTA\")) {\n\t\t\t\t\t\tx += 0.24;\t// dot glyph center X offset\n\t\t\t\t\t\tif (token.is(\"LEFT\"))\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaLeft;\n\t\t\t\t\t\telse if (token.is(\"RIGHT\")) {\n\t\t\t\t\t\t\tvoltaRightXs.push(x);\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaRight;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Dot\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"zero\":\n\t\t\t\tcase \"one\":\n\t\t\t\tcase \"two\":\n\t\t\t\tcase \"three\":\n\t\t\t\tcase \"four\":\n\t\t\t\tcase \"five\":\n\t\t\t\tcase \"six\":\n\t\t\t\tcase \"seven\":\n\t\t\t\tcase \"eight\":\n\t\t\t\tcase \"nine\": {\n\t\t\t\t\tconst upper = glyph[0].toUpperCase() + glyph.substr(1);\n\t\t\t\t\tsemantic = token.is(\"TIME_SIG\") ? \"Timesig\" + upper : upper;\n\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t}\n\n\t\t\t\tif (semantic) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (token.is(\"TEMPO_NOTEHEAD\")) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.TempoNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// grace noteheads\n\t\t\t\tif (token.is(\"NOTEHEAD\") && Number.isFinite(token.scale) && token.scale < 0.75) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.GraceNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// semantic from token symbol\n\t\t\tlet semantic = null;\n\t\t\tconst cx = 0;\n\t\t\tlet cy = 0;\n\t\t\tif (token.is(\"OCTAVE\")) {\n\t\t\t\tif (token.is(\"_8\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift8;\n\t\t\t\t\tcy = token.is(\"B\") ? -0.7512 : -0.7256;\n\t\t\t\t}\n\t\t\t\telse if (token.is(\"CLOSE\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift0;\n\t\t\t\t\tcy = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (/^flags/.test(token.glyph)) {\n\t\t\t\tlet direction = 0;\n\t\t\t\tif (/\\.u\\d/.test(token.glyph))\n\t\t\t\t\tdirection = 1;\n\t\t\t\tif (/\\.d\\d/.test(token.glyph))\n\t\t\t\t\tdirection = -1;\n\t\t\t\tif (direction) {\n\t\t\t\t\tconst [n] = token.glyph.match(/\\d+/);\n\t\t\t\t\tconst flagCount = Number(n) - 2;\n\t\t\t\t\t//console.log(\"flags:\", token.glyph, flagCount);\n\t\t\t\t\tfor (let i = 0; i < flagCount; ++i) {\n\t\t\t\t\t\tconst y = token.y + (i + 0.5) * direction;\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t//console.log(\"flags.1:\", token.x, y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"SLUR\")) {\n\t\t\t\tconst d = def && def.d;\n\t\t\t\tif (d) {\n\t\t\t\t\tconst numbers = d.match(/-?[\\d.]+/g).map(Number);\n\t\t\t\t\t//console.log(\"slur:\", numbers);\n\t\t\t\t\tconst x1 = token.x + numbers[0];\n\t\t\t\t\tconst y1 = token.y + numbers[1];\n\t\t\t\t\tconst x2 = token.x + numbers[6];\n\t\t\t\t\tconst y2 = token.y + numbers[7];\n\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurBegin,\n\t\t\t\t\t\tx: x1,\n\t\t\t\t\t\ty: y1,\n\t\t\t\t\t});\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurEnd,\n\t\t\t\t\t\tx: x2,\n\t\t\t\t\t\ty: y2,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"NOTE_STEM\")) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.vline_Stem,\n\t\t\t\t\tx: token.x + def.width / 2,\n\t\t\t\t\ty: token.y,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: token.y,\n\t\t\t\t\t\ty2: token.y + token.height,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (token.is(\"TEXT\") || token.is(\"CHORD_TEXT\")) {\n\t\t\t\tif (/\\S/.test(token.text)) {\n\t\t\t\t\t// NOTE: text rect computation is delayed to sheet rendering\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\tindex: token.index,\n\t\t\t\t\t\t\ttext: token.text,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx: token.x + cx,\n\t\t\t\t\ty: token.y + cy,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// beams\n\t\tconst stems = tokens.filter(token => token.is(\"NOTE_STEM\")).map(stem => ({\n\t\t\tx: stem.x + stem.width / 2,\n\t\t\ty1: stem.y,\n\t\t\ty2: stem.y + stem.height,\n\t\t}));\n\t\tconst beams = tokens.filter(token => token.is(\"NOTETAIL\") && token.is(\"JOINT\"))\n\t\t\t.map(beam => {\n\t\t\t\tconst def = hashTable[beam.hash];\n\t\t\t\tconst points = def && def.points;\n\t\t\t\tif (points) {\n\t\t\t\t\tconst floats = points.split(\" \").map(Number);\n\t\t\t\t\tconst x1 = beam.x + floats[4];\n\t\t\t\t\tconst x2 = beam.x + floats[0];\n\t\t\t\t\tconst y1 = beam.y + (floats[5] + floats[7]) / 2;\n\t\t\t\t\tconst y2 = beam.y + (floats[1] + floats[3]) / 2;\n\t\t\t\t\tconst k = (y2 - y1) / (x2 - x1);\n\n\t\t\t\t\treturn { x1, x2, y1, y2, k, capital: beam.is(\"CAPITAL_BEAM\") };\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}).filter(Boolean);\n\t\t//console.log(\"beams:\", beams);\n\t\tbeams.forEach(beam => {\n\t\t\tconst innerStems = stems.filter(stem => stem.x > beam.x1 - 0.2 && stem.x < beam.x2 + 0.2);\n\t\t\t//console.log(\"innerStems:\", beam, innerStems);\n\n\t\t\tlet lines = 0;\n\t\t\tinnerStems.forEach(stem => {\n\t\t\t\tconst beamY = beam.y1 + (stem.x - beam.x1) * beam.k;\n\t\t\t\t//console.log(\"beamY:\", beamY, Math.min(Math.abs(beamY - beam.y1), Math.abs(beamY - beam.y2)));\n\t\t\t\tif (beamY >= stem.y1 - 0.1 && beamY <= stem.y2 + 0.1) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t});\n\n\t\t\t\t\t++lines;\n\n\t\t\t\t\t// beam semantics\n\t\t\t\t\tif (beam.capital) {\n\t\t\t\t\t\tlet semantic = SemanticType.BeamContinue;\n\t\t\t\t\t\tif (Math.abs(stem.x - beam.x1) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamLeft;\n\t\t\t\t\t\telse if (Math.abs(stem.x - beam.x2) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamRight;\n\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!lines)\n\t\t\t\tconsole.warn(\"empty beam:\", beam, innerStems, stems);\n\t\t\t//else if (lines < 2)\n\t\t\t//\tconsole.debug(\"single beam:\", beam, innerStems, stems);\n\t\t});\n\n\t\t// wedges (crescendo & decrescendo)\n\t\tconst crescendos = tokens.filter(token => token.is(\"WEDGE CRESCENDO TOP\"));\n\t\tconst crescendoBottoms = tokens.filter(token => token.is(\"WEDGE CRESCENDO BOTTOM\"));\n\t\tconst decrescendos = tokens.filter(token => token.is(\"WEDGE DECRESCENDO TOP\"));\n\t\tconst decrescendoBottoms = tokens.filter(token => token.is(\"WEDGE DECRESCENDO BOTTOM\"));\n\t\tcrescendos.forEach(line => {\n\t\t\tconst partner = crescendoBottoms.find(b => b.x === line.x && Math.abs(b.y - line.y) < 0.06);\n\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.CrescendoBegin,\n\t\t\t\t\tx: line.x,\n\t\t\t\t\ty: line.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired crescendo:\", line, crescendoBottoms);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.CrescendoEnd,\n\t\t\t\tx: line.x + line.target.x,\n\t\t\t\ty: line.y + line.target.y,\n\t\t\t});\n\t\t});\n\t\tdecrescendos.forEach(line => {\n\t\t\tconst partner = decrescendoBottoms.find(b => b.x + b.target.x === line.x + line.target.x && Math.abs(b.y + b.target.y - (line.y + line.target.y)) < 0.06);\n\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.DecrescendoBegin,\n\t\t\t\tx: line.x,\n\t\t\t\ty: line.y,\n\t\t\t});\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.DecrescendoEnd,\n\t\t\t\t\tx: line.x + line.target.x,\n\t\t\t\t\ty: line.y + line.target.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired decrescendo:\", line, decrescendoBottoms);\n\t\t});\n\n\t\t// TODO: volta alternative\n\n\t\t// measure bars\n\t\tconst measureSeparators = staff.tokens.filter(token => token.is(\"MEASURE_SEPARATOR\"));\n\t\tconst singleBars = [];\n\t\tconst groupBars = [];\n\n\t\tfor (let i = 0; i < measureSeparators.length; ++i) {\n\t\t\tconst bar = measureSeparators[i];\n\t\t\tconst nextBar = measureSeparators[i + 1];\n\t\t\tconst inteval = nextBar ? nextBar.x - bar.x : Infinity;\n\n\t\t\tif (inteval < 1) {\n\t\t\t\tgroupBars.push([bar, nextBar]);\n\t\t\t\t++i;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsingleBars.push(bar);\n\t\t};\n\t\t//console.log(\"bars:\", singleBars, groupBars);\n\n\t\tsingleBars.forEach(bar => {\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx: bar.x + bar.sw / 2,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\tgroupBars.forEach(group => {\n\t\t\tlet x = (group[0].x + group[1].x) / 2;\n\t\t\tconst bold0 = group[0].is(\"BOLD\");\n\t\t\tconst bold1 = group[1].is(\"BOLD\");\n\n\t\t\tlet semantic = null;\n\t\t\tif (!bold0 && bold1) {\n\t\t\t\tx = group[0].x;\n\n\t\t\t\tif (!voltaRightXs.some(vx => x - vx < 2))\n\t\t\t\t\tsemantic = SemanticType.vline_BarTerminal;\n\t\t\t}\n\t\t\telse if (bold0 && !bold1)\n\t\t\t\tx = group[1].x;\n\t\t\telse if (!bold0 && !bold1)\n\t\t\t\tsemantic = SemanticType.vline_BarSegment;\n\n\t\t\t//console.log(\"group:\", group[0].x, group[1].x, x);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx,\n\t\t\t\t\ty: 0,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: -2,\n\t\t\t\t\t\ty2: 2,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}*/\n\n\tstatic fromPoints(points: SemanticPoint[] = []): SemanticGraph {\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}\n\n\tgetLayer(semantic: SemanticType): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic);\n\t}\n\n\tgetConfidentLayer(semantic: SemanticType, threshold: number): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic && (!Number.isFinite(p.confidence) || p.confidence >= threshold));\n\t}\n\n\tgetSystemPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\tgetStaffPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => !SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\toffset(x: number, y: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x += x;\n\t\t\tpoint.y += y;\n\t\t});\n\t}\n\n\tscale(factor: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x *= factor;\n\t\t\tpoint.y *= factor;\n\t\t});\n\t}\n\n\t// multipy 3x2 matrix\n\ttransform(matrix: [number, number][]): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tlet x = point.x * matrix[0][0] + point.y * matrix[1][0] + matrix[2][0];\n\t\t\tconst y = point.x * matrix[0][1] + point.y * matrix[1][1] + matrix[2][1];\n\n\t\t\tif (point.extension) {\n\t\t\t\tif (Number.isFinite(point.extension.y1)) {\n\t\t\t\t\tconst y1 = point.x * matrix[0][1] + point.extension.y1 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tconst y2 = point.x * matrix[0][1] + point.extension.y2 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tx = point.x * matrix[0][0] + (point.extension.y1 + point.extension.y2) * 0.5 * matrix[1][0] + matrix[2][0];\n\n\t\t\t\t\tpoint.extension.y1 = y1;\n\t\t\t\t\tpoint.extension.y2 = y2;\n\t\t\t\t}\n\n\t\t\t\tif (Number.isFinite(point.extension.width)) {\n\t\t\t\t\tconst scaling = Math.sqrt(matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]);\n\t\t\t\t\tpoint.extension.width *= scaling;\n\t\t\t\t\tpoint.extension.height *= scaling;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpoint.x = x;\n\t\t\tpoint.y = y;\n\t\t});\n\t}\n}\n\nexport { SemanticGraph };\n","import { SimpleClass } from './aux_/typedJSON';\nimport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tChordColumn,\n\tEventMeasureColumn,\n\tEventSystem,\n\tSourceImageFile,\n\tPageLayout,\n\tAdditionalLineStack,\n\tTextType,\n\tEventFeature,\n} from './interfaces';\nimport { distance2D, solveOverlapping, roundNumber, trans23 } from './utils';\nimport {\n\tToken,\n\tTextToken,\n\tTokenType,\n\tTokenNoteheads,\n\tTokenFlags,\n\tTokenDots,\n\tTokenRests,\n\tTokenAccessories,\n\tTokenDirectionless,\n\tTokenClefs,\n\tTokenBeams,\n\tTokenTimesigs,\n\tTOKEN_Y_FIXED,\n\tTOKEN_Y_ROUND,\n} from './token';\nimport { EventTerm, ContextedTerm, MarkTerm, TempoTerm, AccessoryDirection, GraceType, ContextType, TremoloLink } from './term';\nimport { SemanticGraph } from './semanticGraph';\nimport { SemanticType, SemanticPoint, NOTEHEAD_WIDTHS, hashSemanticPoint, hashPageSemanticPoint } from './semanticPoint';\nimport { Logger, DummyLogger } from './logger';\n\ntype ChordsFeeder = (si: number, mi: number) => ChordColumn[];\ntype ColumnProcessor = (column: EventMeasureColumn) => EventMeasureColumn;\n\nconst CHORD_X_TOLERANCE = 0.2;\n//const EVENT_X_TOLERANCE = 0.8;\n\nconst STEM_LENGTH_MAX = 6;\n\nconst INDENT_THRESHOLD = 2;\n\nconst MEASURE_SEMANTICS = [\n\tSemanticType.ClefG,\n\tSemanticType.ClefF,\n\tSemanticType.ClefC,\n\tSemanticType.TimesigC44,\n\tSemanticType.TimesigC22,\n\tSemanticType.TimesigZero,\n\tSemanticType.TimesigOne,\n\tSemanticType.TimesigTwo,\n\tSemanticType.TimesigThree,\n\tSemanticType.TimesigFour,\n\tSemanticType.TimesigFive,\n\tSemanticType.TimesigSix,\n\tSemanticType.TimesigSeven,\n\tSemanticType.TimesigEight,\n\tSemanticType.TimesigNine,\n\tSemanticType.OctaveShift8va,\n\tSemanticType.OctaveShift8vb,\n\tSemanticType.OctaveShift0,\n\tSemanticType.Zero,\n\tSemanticType.One,\n\tSemanticType.Two,\n\tSemanticType.Three,\n\tSemanticType.Four,\n\tSemanticType.Five,\n\tSemanticType.Six,\n\tSemanticType.Seven,\n\tSemanticType.Eight,\n\tSemanticType.Nine,\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n\tSemanticType.Rest0W,\n\tSemanticType.RestM1,\n\tSemanticType.SlurBegin,\n\tSemanticType.SlurEnd,\n\tSemanticType.Dot,\n\tSemanticType.f,\n\tSemanticType.p,\n\tSemanticType.m,\n\tSemanticType.n,\n\tSemanticType.r,\n\tSemanticType.s,\n\tSemanticType.z,\n\tSemanticType.ScriptFermata,\n\tSemanticType.ScriptShortFermata,\n\tSemanticType.ScriptSforzato,\n\tSemanticType.ScriptStaccato,\n\tSemanticType.ScriptStaccatissimo,\n\tSemanticType.ScriptTurn,\n\tSemanticType.ScriptTrill,\n\tSemanticType.ScriptSegno,\n\tSemanticType.ScriptCoda,\n\tSemanticType.ScriptArpeggio,\n\tSemanticType.ScriptPrall,\n\tSemanticType.ScriptMordent,\n\tSemanticType.ScriptMarcato,\n\tSemanticType.ScriptTenuto,\n\tSemanticType.ScriptPortato,\n\tSemanticType.PedalStar,\n\tSemanticType.PedalPed,\n\tSemanticType.GraceNotehead,\n\tSemanticType.BeamLeft,\n\tSemanticType.BeamRight,\n\tSemanticType.BeamContinue,\n\tSemanticType.CrescendoBegin,\n\tSemanticType.CrescendoEnd,\n\tSemanticType.DecrescendoBegin,\n\tSemanticType.DecrescendoEnd,\n\tSemanticType.TremoloLeft,\n\tSemanticType.TremoloRight,\n\tSemanticType.TremoloMiddle,\n];\n\nconst STAFF_LINED_SEMANTICS = [\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n];\n\nconst LINED_INTERVAL_SEMANTICS = [SemanticType.SignLined, SemanticType.SignInterval];\n\nconst NOTEHEAD_FOR_STEM_SEMANTICS = [SemanticType.NoteheadS1, SemanticType.NoteheadS2];\n\nconst KEYACC_CANDIDATE_SEMANTICS = {\n\tAccSharp: TokenType.KeySharp,\n\tAccNatural: TokenType.KeyNatural,\n\tAccFlat: TokenType.KeyFlat,\n};\n\nconst NOTEHEAD_TABLE: { [key: string]: { [key: string]: SemanticType } } = {\n\t[SemanticType.NoteheadS1]: {\n\t\tup: SemanticType.NoteheadS1stemU,\n\t\tdown: SemanticType.NoteheadS1stemD,\n\t},\n\t[SemanticType.NoteheadS2]: {\n\t\tup: SemanticType.NoteheadS2stemU,\n\t\tdown: SemanticType.NoteheadS2stemD,\n\t},\n};\n\nconst REST_SEMANTICS = [\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n];\n\nconst TOKEN_TO_STEMBEAM = {\n\t[TokenType.BeamLeft]: 'Open',\n\t[TokenType.BeamRight]: 'Close',\n\t[TokenType.BeamContinue]: 'Continue',\n};\n\nconst TEXT_TYPE_ALIAS = {\n\tAlter1: TextType.Alternation1,\n\tAlter2: TextType.Alternation2,\n};\n\ninterface StaffPosition {\n\ty: number;\n\tradius: number;\n}\n\ninterface TextArea {\n\tscore: number;\n\tcx: number;\n\tcy: number;\n\twidth: number;\n\theight: number;\n\ttext: string;\n\ttype: string;\n\ttheta: number;\n\tfeature_dict: Record;\n}\n\ntype Stem = VLine & { direction: 'u' | 'd' };\n\nconst noteheadsXPivot = (xs: number[], direction: 'u' | 'd' | null): number => {\n\tswitch (xs.length) {\n\t\tcase 0:\n\t\t\treturn undefined;\n\n\t\tcase 1:\n\t\t\treturn xs[0];\n\n\t\tcase 2:\n\t\t\treturn direction === 'u' ? Math.min(...xs) : Math.max(...xs);\n\n\t\tdefault: {\n\t\t\tconst mean = xs.reduce((sum, x) => sum + x, 0) / xs.length;\n\t\t\txs.sort((x1, x2) => Math.abs(x1 - mean) - Math.abs(x2 - mean));\n\n\t\t\treturn noteheadsXPivot(xs.slice(0, xs.length - 1), direction);\n\t\t}\n\t}\n};\n\nconst noteheadsPivot = (nhs: Token[]): number =>\n\tnoteheadsXPivot(\n\t\tnhs.map((nh) => (Number.isFinite(nh.pivotX) ? nh.pivotX : nh.x)),\n\t\tnhs[0].direction\n\t);\n\nclass Measure extends SimpleClass {\n\tstatic className = 'Measure';\n\tstatic blackKeys = ['tokens', 'antiTokens'];\n\n\tleft: number;\n\twidth: number;\n\theight: number;\n\n\talternative: boolean;\n\n\ttokens: Token[];\n\tantiTokens: Token[];\n\n\tbarTypes: Record;\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.tokens = this.tokens || [];\n\t\tthis.antiTokens = this.antiTokens || [];\n\t\tthis.barTypes = this.barTypes || {};\n\t}\n\n\tget right(): number {\n\t\treturn this.left + this.width;\n\t}\n\n\tget noteheads(): Token[] {\n\t\treturn this.tokens.filter((t) => t.isNotehead).sort((n1, n2) => n1.x - n2.x);\n\t}\n\n\tget chordRects(): ChordRect[] {\n\t\tconst noteheads = this.noteheads.filter((nh) =>\n\t\t\t[TokenType.NoteheadS0, TokenType.NoteheadS1stemU, TokenType.NoteheadS2stemU, TokenType.NoteheadS1stemD, TokenType.NoteheadS2stemD].includes(nh.type)\n\t\t);\n\n\t\tlet nulN = 0;\n\n\t\tconst nhmap: Record = noteheads.reduce((map, nh) => {\n\t\t\tconst tip = nh.tip ? `${nh.tip.x}|${nh.tip.y}` : `nul${nulN}`;\n\t\t\tlet key = `${nh.type}|${tip}`;\n\n\t\t\tif (!nh.tip && map[key]) {\n\t\t\t\tif (!map[key].some((hh) => Math.abs(hh.x - nh.x) < NOTEHEAD_WIDTHS.NoteheadS0)) {\n\t\t\t\t\t++nulN;\n\t\t\t\t\tkey = `${nh.type}|nul${nulN}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmap[key] = map[key] || [];\n\t\t\tmap[key].push(nh);\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(nhmap).map((nhs) => {\n\t\t\tconst left = Math.min(...nhs.map((nh) => nh.x));\n\t\t\tconst right = Math.max(...nhs.map((nh) => nh.x));\n\t\t\tconst top = Math.min(...nhs.map((nh) => nh.y));\n\t\t\tconst bottom = Math.max(...nhs.map((nh) => nh.y));\n\n\t\t\tconst nh0 = nhs[0];\n\n\t\t\tconst stemX = nh0 && nh0.tip ? nh0.tip.x : left;\n\n\t\t\tlet x = left;\n\t\t\tlet width = right - left;\n\t\t\tlet stemDirection = null;\n\n\t\t\tswitch (nh0.type) {\n\t\t\t\tcase TokenType.NoteheadS0:\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS0 / 2;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemU:\n\t\t\t\tcase TokenType.NoteheadS2stemU:\n\t\t\t\t\tstemDirection = 'u';\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS1;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemD:\n\t\t\t\tcase TokenType.NoteheadS2stemD:\n\t\t\t\t\tstemDirection = 'd';\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tx,\n\t\t\t\twidth,\n\t\t\t\tstemX,\n\t\t\t\tstemDirection,\n\t\t\t\ttop,\n\t\t\t\tbottom,\n\t\t\t\ttip: nh0.tip,\n\t\t\t};\n\t\t});\n\t}\n\n\tget timeWarped(): boolean {\n\t\treturn this.tokens && this.tokens.some((token) => token.timeWarped);\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\tconst chords = this.getChords();\n\t\tconst up = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y <= -3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.ceil(Math.min(...chord.ys)) + 2,\n\t\t\t}));\n\t\tconst down = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y >= 3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.floor(Math.max(...chord.ys)) - 2,\n\t\t\t}));\n\n\t\treturn [...up, ...down].map((stack) => ({\n\t\t\tleft: stack.left - 0.28,\n\t\t\tright: stack.right + 0.28,\n\t\t\tn: stack.n,\n\t\t}));\n\t}\n\n\tgetChords(): ChordColumn[] {\n\t\tconst flags = this.tokens.filter((t) => TokenFlags.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\t\tconst beams = this.tokens.filter((t) => TokenBeams.includes(t.type));\n\n\t\tconst chordRcs = this.chordRects\n\t\t\t.map((rect) => {\n\t\t\t\tconst noteheads = this.noteheads.filter(\n\t\t\t\t\t(nh) =>\n\t\t\t\t\t\tnh.direction === rect.stemDirection &&\n\t\t\t\t\t\tnh.left >= rect.x &&\n\t\t\t\t\t\tnh.right <= rect.x + rect.width + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tnh.y >= rect.top &&\n\t\t\t\t\t\tnh.y <= rect.bottom\n\t\t\t\t);\n\t\t\t\tnoteheads.sort((n1, n2) => n2.y - n1.y);\n\t\t\t\tconst ys = noteheads.map((nh) => nh.y);\n\t\t\t\tconst noteIds = noteheads.map((nh) => nh.id);\n\n\t\t\t\tconst division = noteheads.reduce((d, nh) => Math.max(d, nh.division), 0);\n\n\t\t\t\treturn {\n\t\t\t\t\trect,\n\t\t\t\t\tleft: rect.x,\n\t\t\t\t\tright: rect.x + rect.width,\n\t\t\t\t\tpivotX: noteheadsPivot(noteheads),\n\t\t\t\t\tys,\n\t\t\t\t\ttip: rect.tip,\n\t\t\t\t\tnoteIds,\n\t\t\t\t\tdivision,\n\t\t\t\t\tdots: null,\n\t\t\t\t\trest: false,\n\t\t\t\t\tstemDirection: rect.stemDirection,\n\t\t\t\t\tbeam: null,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((c1, c2) => c2.left - c1.left);\n\n\t\tconst accs = new Set();\n\n\t\tconst chords = chordRcs.map(({ rect, ...chord }) => {\n\t\t\tif (chord.division >= 1) {\n\t\t\t\t// NOTE: notehead-s1 may have flags too\n\t\t\t\tconst flagRange = [rect.bottom, rect.top];\n\t\t\t\tswitch (rect.stemDirection) {\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t\tflagRange[0] = rect.tip ? rect.tip.y - 0.2 : rect.top - STEM_LENGTH_MAX - 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'd':\n\t\t\t\t\t\tflagRange[1] = rect.tip ? rect.tip.y + 0.2 : rect.bottom + STEM_LENGTH_MAX + 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst nearbyFlags = flags.filter(\n\t\t\t\t\t(flag) =>\n\t\t\t\t\t\t!accs.has(flag.id) &&\n\t\t\t\t\t\tflag.x > rect.stemX - CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.x < rect.stemX + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.y > flagRange[0] &&\n\t\t\t\t\t\tflag.y < flagRange[1]\n\t\t\t\t);\n\t\t\t\tchord.division = nearbyFlags.reduce((d, flag) => Math.max(d, flag.division), chord.division);\n\n\t\t\t\tnearbyFlags.forEach((flag) => accs.add(flag.id));\n\n\t\t\t\tconst beamToken = rect.tip && beams.find((t) => Math.abs(rect.tip.x - t.x) < 0.3 && Math.abs(rect.tip.y - t.y) < 0.7);\n\t\t\t\tif (beamToken) chord.beam = TOKEN_TO_STEMBEAM[beamToken.type];\n\t\t\t}\n\n\t\t\tconst nearbyDots = dots.filter(\n\t\t\t\t(dot) =>\n\t\t\t\t\t!accs.has(dot.id) &&\n\t\t\t\t\tdot.x > rect.x + rect.width - 0.2 &&\n\t\t\t\t\tdot.x < rect.x + rect.width + 1.2 &&\n\t\t\t\t\tdot.y > rect.top - 1 &&\n\t\t\t\t\tdot.y <= rect.bottom + 0.5\n\t\t\t);\n\t\t\tchord.dots = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\tnearbyDots.forEach((dot) => accs.add(dot.id));\n\n\t\t\treturn chord;\n\t\t});\n\n\t\tchords.reverse();\n\n\t\treturn chords;\n\t}\n\n\tgetRests(): ChordColumn[] {\n\t\tconst rests = this.tokens.filter((t) => TokenRests.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\n\t\treturn rests.map((rest) => {\n\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > rest.x + 0.5 && dot.x < rest.x + 2 && dot.y > rest.y - 1 && dot.y < rest.y + 0.5);\n\t\t\tconst dotValue = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\treturn {\n\t\t\t\tleft: rest.x - 0.75,\n\t\t\t\tright: rest.x + 0.75,\n\t\t\t\tpivotX: rest.x,\n\t\t\t\trest: true,\n\t\t\t\tys: [rest.y],\n\t\t\t\tnoteIds: [rest.id],\n\t\t\t\tdots: dotValue,\n\t\t\t\tdivision: rest.division,\n\t\t\t\tstemDirection: null,\n\t\t\t};\n\t\t});\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\treturn [...this.getChords(), ...this.getRests()].sort((e1, e2) => e1.left - e2.left);\n\t}\n\n\tgetContexts(fields = {}): ContextedTerm[] {\n\t\treturn this.tokens\n\t\t\t.filter((t) => t.isContexted)\n\t\t\t.sort((n1, n2) => n1.x - n2.x)\n\t\t\t.map(\n\t\t\t\t(token) =>\n\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\ttokenType: token.type,\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t})\n\t\t\t);\n\t}\n\n\tassignAccessoriesOnEvents(events: ChordColumn[]): void {\n\t\tevents.forEach((event) => (event.accessories = event.accessories || []));\n\n\t\tconst accessories = this.tokens.filter((token) => TokenAccessories.includes(token.type));\n\t\t//console.log(\"accessories:\", accessories);\n\t\taccessories.forEach((accessory) => {\n\t\t\tconst relatedEvents = events.filter((event) => accessory.x > event.left - 1 && accessory.x < event.right + 1);\n\n\t\t\tif (relatedEvents.length > 0) {\n\t\t\t\tlet owner = relatedEvents[0];\n\t\t\t\tif (relatedEvents.length > 1) {\n\t\t\t\t\towner = relatedEvents\n\t\t\t\t\t\t.map((event) => ({ event, d: Math.min(...event.ys.map((y) => Math.abs(y - accessory.y))) }))\n\t\t\t\t\t\t.sort(({ d: d1 }, { d: d2 }) => d1 - d2)\n\t\t\t\t\t\t.map(({ event }) => event)[0];\n\t\t\t\t}\n\t\t\t\t//console.log(\"relatedEvents:\", accessory, owner);\n\n\t\t\t\tlet direction = accessory.y > Math.max(...owner.ys) ? AccessoryDirection.Down : AccessoryDirection.Up;\n\t\t\t\tif (TokenDirectionless.includes(accessory.type)) direction = null;\n\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: accessory.type,\n\t\t\t\t\tid: accessory.id,\n\t\t\t\t\tdirection,\n\t\t\t\t\tx: accessory.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone accessory:\", accessory.type);\n\t\t});\n\n\t\t// arpeggio\n\t\tconst sortEvents = [...events];\n\t\tsortEvents.sort((e1, e2) => e1.left - e2.left);\n\n\t\tconst arpeggios = this.tokens.filter((token) => token.type === TokenType.ScriptArpeggio);\n\t\tarpeggios.forEach((arpeggio) => {\n\t\t\tconst owner = sortEvents.find(\n\t\t\t\t(event) => arpeggio.x < event.left && event.ys.some((y) => y < arpeggio.y + 0.25) && event.ys.some((y) => y > arpeggio.y)\n\t\t\t);\n\t\t\t//const owner = sortEvents.find(event => event.left - leftMost.left < 2 && event.ys.some(y => Math.abs(y - arpeggio.y + 0.25) < 0.5));\n\t\t\tif (owner) {\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: TokenType.ScriptArpeggio,\n\t\t\t\t\tid: arpeggio.id,\n\t\t\t\t\tx: arpeggio.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone arpeggio:\", arpeggio);\n\t\t});\n\n\t\t// grace noteheads\n\t\tconst graceNhs = this.tokens.filter((token) => token.type === TokenType.GraceNotehead);\n\t\tgraceNhs.forEach((grace) => {\n\t\t\tconst event = events.find((event) => grace.x > event.left && grace.x < event.right && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tif (event) event.grace = GraceType.Grace;\n\t\t});\n\n\t\t// tremolos\n\t\tconst tremolsLs = this.tokens.filter((token) => token.type === TokenType.TremoloLeft);\n\t\tconst tremolsRs = this.tokens.filter((token) => token.type === TokenType.TremoloRight);\n\t\tconst tremolsMs = this.tokens.filter((token) => token.type === TokenType.TremoloMiddle);\n\n\t\tconst tevents = events\n\t\t\t.filter((event) => !event.rest)\n\t\t\t.map((event) => {\n\t\t\t\tconst ys = [...event.ys];\n\t\t\t\tif (event.tip) ys.push(event.tip.y);\n\t\t\t\telse {\n\t\t\t\t\tys.push(event.ys[0] + 2);\n\t\t\t\t\tys.push(event.ys[event.ys.length - 1] - 2);\n\t\t\t\t}\n\n\t\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\t\t\t\tconst stemR = event.tip ? event.tip.x : event.right;\n\n\t\t\t\treturn {\n\t\t\t\t\tevent,\n\t\t\t\t\ttop: Math.min(...ys),\n\t\t\t\t\tbottom: Math.max(...ys),\n\t\t\t\t\tstemL,\n\t\t\t\t\tstemR,\n\t\t\t\t};\n\t\t\t});\n\n\t\ttremolsMs.forEach((tm) => {\n\t\t\tconst te = tevents.find((te) => {\n\t\t\t\tif (te.event.tip) return tm.y > te.top && tm.y < te.bottom && Math.abs(tm.x - te.event.tip.x) < 0.3;\n\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t}\n\t\t});\n\t\ttremolsLs.forEach((tl) => {\n\t\t\tconst te = tevents.find((te) => tl.y > te.top && tl.y < te.bottom && tl.x > te.stemR && tl.x < te.stemR + 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Pitcher;\n\t\t\t}\n\t\t});\n\t\ttremolsRs.forEach((tr) => {\n\t\t\tconst te = tevents.find((te) => tr.y > te.top && tr.y < te.bottom && tr.x < te.stemL && tr.x > te.stemL - 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Catcher;\n\t\t\t}\n\t\t});\n\t}\n\n\tassignFeaturesOnEvents(events: ChordColumn[], semantics: SemanticPoint[]): void {\n\t\tconst points = semantics.filter((point) => point.x > this.left && point.x < this.right);\n\t\tconst rests = points.filter((point) => REST_SEMANTICS.includes(point.semantic));\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tconst dotPs = points.filter((point) => point.semantic === SemanticType.Dot);\n\t\tconst beamLs = points.filter((points) => points.semantic === SemanticType.BeamLeft);\n\t\tconst beamMs = points.filter((points) => points.semantic === SemanticType.BeamContinue);\n\t\tconst beamRs = points.filter((points) => points.semantic === SemanticType.BeamRight);\n\t\tconst gracePs = points.filter((point) => point.semantic === SemanticType.GraceNotehead);\n\t\tconst tremoloRs = points.filter((point) => point.semantic === SemanticType.TremoloRight);\n\t\tconst stems = points.filter((point) => point.semantic === SemanticType.vline_Stem);\n\t\tconst s0 = points.filter((point) => point.semantic === SemanticType.NoteheadS0);\n\t\tconst s1 = points.filter((point) => point.semantic === SemanticType.NoteheadS1);\n\t\tconst s2 = points.filter((point) => point.semantic === SemanticType.NoteheadS2);\n\n\t\tevents.forEach((event) => {\n\t\t\tconst cx = event.tip ? event.tip.x : (event.left + event.right) / 2;\n\t\t\tconst top = event.tip ? Math.min(event.tip.y, event.ys[event.ys.length - 1]) : event.ys[event.ys.length - 1];\n\t\t\tconst bottom = event.tip ? Math.max(event.tip.y, event.ys[0]) : event.ys[0];\n\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\n\t\t\tconst divisions = [0, 0, 0, 0, 0, 0, 0];\n\t\t\tif (event.rest) {\n\t\t\t\tconst i_rests = rests.filter((point) => distance2D(point, { x: cx, y: event.ys[0] }) < 0.5);\n\t\t\t\ti_rests.forEach((r) => {\n\t\t\t\t\tconst d = REST_SEMANTICS.indexOf(r.semantic);\n\t\t\t\t\tdivisions[d] = Math.max(divisions[d], r.confidence);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst nhs = [s0, s1, s2]\n\t\t\t\t\t.map((ss) => ss.filter((nh) => nh.x > event.left && nh.x < event.right && nh.y > top - 0.25 && nh.y < bottom + 0.25))\n\t\t\t\t\t.map((ss) => Math.max(0, ...ss.map((nh) => nh.confidence)));\n\n\t\t\t\tconst i_flags = flags.filter((flag) => flag.y > top - 0.2 && flag.y < bottom + 0.2 && Math.abs(flag.x - cx) < 0.2);\n\t\t\t\ti_flags.sort((f1, f2) => f2.confidence - f1.confidence);\n\n\t\t\t\tdivisions[0] = nhs[0];\n\t\t\t\tdivisions[1] = nhs[1];\n\t\t\t\tdivisions[2] = nhs[2];\n\t\t\t\tArray(divisions.length - 3)\n\t\t\t\t\t.fill(0)\n\t\t\t\t\t.forEach((_, i) => (divisions[3 + i] = i_flags[i] ? i_flags[i].confidence : 0));\n\t\t\t}\n\n\t\t\tconst i_dots = dotPs.filter((dot) => dot.x > cx && dot.x < event.right + 2.6);\n\t\t\tconst dots2 = i_dots.filter((dot) => i_dots.some((d) => dot.x > d.x && Math.abs(dot.y - d.y) < 0.2));\n\t\t\tconst dots = [Math.max(0, ...i_dots.map((dot) => dot.confidence)), Math.max(0, ...dots2.map((dot) => dot.confidence))];\n\n\t\t\tconst beams = [beamLs, beamMs, beamRs]\n\t\t\t\t.map((bs) => bs.filter((b) => Math.abs(b.x - cx) < 0.2 && b.y > top - 0.2 && b.y < bottom + 0.2))\n\t\t\t\t.map((bs) => Math.max(0, ...bs.map((b) => b.confidence)));\n\n\t\t\tconst u_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[0] }, { x: stem.x, y: stem.extension.y2 }) < 0.5);\n\t\t\tconst d_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[event.ys.length - 1] }, { x: stem.x, y: stem.extension.y1 }) < 0.5);\n\t\t\tconst stemDirections = [Math.max(0, ...u_stems.map((stem) => stem.confidence)), Math.max(0, ...d_stems.map((stem) => stem.confidence))];\n\n\t\t\tconst graces = gracePs.filter((grace) => Math.abs(grace.x - cx) < 0.6 && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tconst grace = Math.max(0, ...graces.map((grace) => grace.confidence));\n\n\t\t\tconst tremolos =\n\t\t\t\tevent.division === 0\n\t\t\t\t\t? tremoloRs.filter((tremolo) => tremolo.x > event.left - 2 && tremolo.x < event.right)\n\t\t\t\t\t: tremoloRs.filter((tremolo) => tremolo.y > top - 0.04 && tremolo.y < bottom + 0.04 && tremolo.x > stemL - 2 && tremolo.x < stemL);\n\t\t\tconst tremoloCatcher = Math.max(0, ...tremolos.map((tremolo) => tremolo.confidence));\n\n\t\t\tevent.feature = {\n\t\t\t\tdivisions,\n\t\t\t\tdots,\n\t\t\t\tbeams,\n\t\t\t\tstemDirections,\n\t\t\t\tgrace,\n\t\t\t\ttremoloCatcher,\n\t\t\t} as EventFeature;\n\t\t});\n\t}\n}\n\nclass Staff extends SimpleClass {\n\tstatic className = 'Staff';\n\tstatic blackKeys = ['index', 'semanticTop', 'semanticBttom'];\n\n\tindex?: number; // staff index in full staff layout\n\n\t// in units\n\ttop: number;\n\theight: number;\n\tstaffY: number;\n\n\tsemanticTop: number;\n\tsemanticBottom: number;\n\n\tbackgroundImage: string | Buffer;\n\tmaskImage: string | Buffer;\n\timagePosition: Rect;\n\n\tmeasures: Measure[];\n\n\tsemantics: SemanticPoint[];\n\n\tconstructor({ measureCount = null, measureBars = null, ...data }: Record = {}) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.height = this.height || 10;\n\t\tthis.staffY = this.staffY || 5;\n\n\t\tif (measureBars) {\n\t\t\tlet left = 0;\n\t\t\tthis.measures = measureBars.map((endX) => {\n\t\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\t\tleft = endX;\n\n\t\t\t\treturn measure;\n\t\t\t});\n\t\t} else if (measureCount)\n\t\t\tthis.measures = Array(measureCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Measure());\n\t\telse this.measures = [];\n\t}\n\n\t// relative to staffY\n\tget noteRange(): { top: number; bottom: number } {\n\t\tconst noteheads: Token[] = [].concat(...this.measures.map((measure) => measure.noteheads));\n\t\tconst ys = noteheads.map((note) => note.y);\n\t\tconst top = Math.min(-2, ...ys);\n\t\tconst bottom = Math.max(2, ...ys);\n\n\t\treturn { top, bottom };\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\treturn [].concat(...this.measures.map((measure) => measure.additionalLines));\n\t}\n\n\trearrangeMeasures(measureBars: number[]): void {\n\t\tif (!measureBars.length) {\n\t\t\tconsole.warn('rearrangeMeasures error, measureBars are empty.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst tokens = this.measures?.map((measure) => measure.tokens).flat(1) || [];\n\n\t\tlet left = 0;\n\t\tthis.measures = measureBars.map((endX) => {\n\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\tleft = endX;\n\n\t\t\treturn measure;\n\t\t});\n\n\t\tthis.reassignTokens(tokens);\n\t}\n\n\treassignTokens(tokens: Token[] = null): void {\n\t\tif (!tokens) tokens = [].concat(...this.measures.map((measure) => measure.tokens));\n\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\n\t\ttokens.forEach((token) => {\n\t\t\tfor (const measure of this.measures) {\n\t\t\t\tif (token.x < measure.right) {\n\t\t\t\t\tmeasure.tokens.push(token);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tassignSemantics(graph: SemanticGraph): void {\n\t\tthis.semantics = graph.getStaffPoints();\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, system: System, logger: Logger = new DummyLogger()): void {\n\t\tif (!this.semantics) return;\n\n\t\tlet points = system.qualifiedSemantics(this.semantics, threshold);\n\t\tpoints = solveOverlapping(points);\n\n\t\t// tempo noteheads\n\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t//console.log(\"temponh:\", tempoNh, index, points[index]);\n\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t// TODO: construct tempo term\n\t\t});\n\n\t\tconst antiP = (id: string): SemanticPoint | null => {\n\t\t\tif (system.displacementSemantics?.[id]) return this.semantics.find((p) => p.id === id);\n\n\t\t\treturn null;\n\t\t};\n\n\t\tpoints.filter((point) => MEASURE_SEMANTICS.includes(point.semantic)).forEach((point) => this.appendPoint(point, { points }));\n\n\t\t// noteheads with stem from noteheads & stems\n\t\tconst stems: Stem[] = points\n\t\t\t.filter((point) => point.semantic === SemanticType.vline_Stem)\n\t\t\t.filter((stem) => stem.extension.y2 - stem.extension.y1 > 1.5) // exclude too short stems\n\t\t\t.map((p) => ({\n\t\t\t\tx: p.x,\n\t\t\t\ty1: p.extension.y1,\n\t\t\t\ty2: p.extension.y2,\n\t\t\t\tdirection: null,\n\t\t\t}));\n\t\tconst noteheads = points.filter(\n\t\t\t(point) => NOTEHEAD_FOR_STEM_SEMANTICS.includes(point.semantic) && point.y > this.semanticTop && point.y < this.semanticBottom\n\t\t);\n\t\tconst rootNhs = new Set();\n\n\t\t// for 2nd degree chord notes\n\t\tconst nhOffsetX = (nh: SemanticPoint, stem: Stem, down: boolean): number => {\n\t\t\tif ((down ? 1 : 0) ^ (nh.x < stem.x ? 1 : 0)) return 0;\n\n\t\t\tconst offset = NOTEHEAD_WIDTHS[nh.semantic];\n\n\t\t\treturn down ? -offset : offset;\n\t\t};\n\n\t\t// find root noteheads on stem\n\t\tstems.forEach((stem) => {\n\t\t\tconst attachedHeads = noteheads.filter(\n\t\t\t\t(nh) =>\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 < 0.28 &&\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 > -0.44 && // for grace noteheads, more close to their stem\n\t\t\t\t\tnh.y > stem.y1 - 0.5 &&\n\t\t\t\t\tnh.y < stem.y2 + 0.5 &&\n\t\t\t\t\t!(nh.x > stem.x && nh.y > stem.y2) &&\n\t\t\t\t\t!(nh.x < stem.x && nh.y < stem.y1)\n\t\t\t);\n\t\t\t//if (stem.x===102.0625 && stem.y2===1.875)\n\t\t\t//\tdebugger;\n\t\t\tif (attachedHeads.length) {\n\t\t\t\tattachedHeads.sort((n1, n2) => n1.y - n2.y);\n\n\t\t\t\tconst topDist = Math.min(...attachedHeads.map((nh) => nh.y - stem.y1));\n\t\t\t\tconst bottomDist = Math.min(...attachedHeads.map((nh) => stem.y2 - nh.y));\n\t\t\t\tif (Math.min(topDist, bottomDist) > 0.5) return; // no root notehead on this stem\n\n\t\t\t\tconst down = topDist < bottomDist;\n\t\t\t\tstem.direction = down ? 'd' : 'u';\n\n\t\t\t\tif (!down) attachedHeads.reverse();\n\t\t\t\tconst root = attachedHeads[0];\n\n\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[root.semantic].down : NOTEHEAD_TABLE[root.semantic].up;\n\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: root.id,\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx: stem.x + nhOffsetX(root, stem, down),\n\t\t\t\t\t\ty: root.y,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tconfidence: root.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\tantiPoint: antiP(root.id),\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\trootNhs.add(root.id);\n\t\t\t}\n\t\t});\n\n\t\t// non-root noteheads\n\t\tnoteheads\n\t\t\t.filter((nh) => !rootNhs.has(nh.id))\n\t\t\t.forEach((nh) => {\n\t\t\t\tconst nearStems = stems\n\t\t\t\t\t.filter((stem) => Math.abs(stem.x - nh.x) < 2 && nh.y > stem.y1 && nh.y < stem.y2)\n\t\t\t\t\t.sort((s1, s2) => Math.abs(s1.x - nh.x) - Math.abs(s2.x - nh.x));\n\t\t\t\tconst stem = nearStems[0];\n\t\t\t\tif (stem) {\n\t\t\t\t\tconst down = stem.direction === 'd';\n\t\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[nh.semantic].down : NOTEHEAD_TABLE[nh.semantic].up;\n\n\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: nh.id,\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x + nhOffsetX(nh, stem, down),\n\t\t\t\t\t\t\ty: nh.y,\n\t\t\t\t\t\t\tpivotX: nh.x,\n\t\t\t\t\t\t\tconfidence: nh.confidence,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\t\tantiPoint: antiP(nh.id),\n\t\t\t\t\t\t\tpoints,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else logger.debug('isolated notehead:', system.index, this.index, nh);\n\t\t\t});\n\n\t\t// group flags\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tflags.sort((f1, f2) => f1.x - f2.x);\n\t\tthis.appendFlags(flags, stems);\n\n\t\t// group dots\n\t\tconst dots = points\n\t\t\t.filter((point) => point.semantic === SemanticType.Dot)\n\t\t\t.map((dot) => {\n\t\t\t\tconst y = roundNumber(dot.y, 0.5);\n\t\t\t\treturn { x: dot.x, y };\n\t\t\t});\n\t\tconst dotLines: { [key: number]: SemanticPoint[] } = dots.reduce((table, dot) => {\n\t\t\ttable[dot.y] = table[dot.y] || [];\n\t\t\ttable[dot.y].push(dot);\n\t\t\treturn table;\n\t\t}, {});\n\t\tObject.entries(dotLines).forEach(([sy, line]) => {\n\t\t\tconst y = Number(sy);\n\t\t\tif (line.length > 1) {\n\t\t\t\tline.sort((d1, d2) => d1.x - d2.x);\n\t\t\t\tfor (let i = 0; i < line.length - 1; i++) {\n\t\t\t\t\tconst dot = line[i];\n\t\t\t\t\tif (line.find((d) => d.x > dot.x && d.x - dot.x < 1.2)) {\n\t\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: dot.id,\n\t\t\t\t\t\t\t\tx: dot.x,\n\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\tconfidence: dot.confidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: TokenType.DotDot, antiPoint: antiP(dot.id), points }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// pair key accidentals\n\t\tconst keyaccs = points.filter((point) => point.semantic === SemanticType.KeyAcc);\n\t\tconst accs = points.filter((point) => KEYACC_CANDIDATE_SEMANTICS[point.semantic]);\n\t\taccs.forEach((acc) => {\n\t\t\tif (keyaccs.some((key) => Math.abs(acc.x - key.x) < 0.5 && Math.abs(acc.y - key.y) < 1)) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: acc.id,\n\t\t\t\t\t\tx: acc.x,\n\t\t\t\t\t\ty: acc.y,\n\t\t\t\t\t\tconfidence: acc.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{ type: KEYACC_CANDIDATE_SEMANTICS[acc.semantic], points }\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// octave shift heads\n\t\tconst octs = points.filter((point) => point.semantic === SemanticType.OctaveShift8);\n\t\tocts.forEach((oct) => {\n\t\t\tconst type = oct.y < 0 ? TokenType.OctaveShift8va : TokenType.OctaveShift8vb;\n\t\t\tthis.appendPoint(\n\t\t\t\t{\n\t\t\t\t\tid: oct.id,\n\t\t\t\t\tx: oct.x,\n\t\t\t\t\ty: oct.y,\n\t\t\t\t\tconfidence: oct.confidence,\n\t\t\t\t},\n\t\t\t\t{ type, points }\n\t\t\t);\n\t\t});\n\n\t\t// group volta dots\n\t\tconst voltaDots = this.semantics.filter((point) => [SemanticType.VoltaLeft, SemanticType.VoltaRight].includes(point.semantic));\n\t\tvoltaDots.sort((d1, d2) => d1.x - d2.x);\n\t\tconst voltaGroups: Record> = voltaDots.reduce(\n\t\t\t(groups, dot) => {\n\t\t\t\tconst group = groups[dot.semantic];\n\t\t\t\tconst xs = Array.from(Object.keys(group)).map(Number);\n\t\t\t\tconst x = xs.find((x) => dot.x < x + 0.2) || dot.x;\n\n\t\t\t\tgroup[x] = groups[dot.semantic][x] || [];\n\t\t\t\tgroup[x].push(dot);\n\n\t\t\t\treturn groups;\n\t\t\t},\n\t\t\t{ [SemanticType.VoltaLeft]: {}, [SemanticType.VoltaRight]: {} }\n\t\t);\n\t\tfor (const [type, group] of Object.entries(voltaGroups)) {\n\t\t\tObject.values(group).forEach((dots) => {\n\t\t\t\tif (dots.length > 1) {\n\t\t\t\t\tconst confidence = dots.reduce((sum, dot) => sum + dot.confidence, 0);\n\t\t\t\t\tif (dots[0].y * dots[1].y < 0 && confidence >= threshold * 2) this.appendPoint(dots[0], { type: TokenType[type] });\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tappendPoint(\n\t\tpoint: Partial,\n\t\t{ type, points = null, antiPoint, ...fields }: { type?: TokenType; antiPoint?: SemanticPoint; [key: string]: any } = {}\n\t): void {\n\t\t//console.log(\"appendPoint.0:\", point, point.x, point.y);\n\t\tconst x = point.x;\n\t\tconst measure = this.measures.find((measure) => x < measure.left + measure.width);\n\t\tif (!measure)\n\t\t\t// drop tokens out of measures range\n\t\t\treturn;\n\n\t\t// lined or interval\n\t\tlet lined = false;\n\t\tlet interval = false;\n\t\tif (STAFF_LINED_SEMANTICS.includes(point.semantic)) {\n\t\t\tconsole.assert(points, 'argument of points for this semantic is required:', point.semantic);\n\t\t\tconst signs = points.filter((p) => LINED_INTERVAL_SEMANTICS.includes(p.semantic) && Math.abs(p.y - point.y) < 0.2 && Math.abs(p.x - point.x) < 1.2);\n\t\t\tif (signs.some((s) => s.semantic === SemanticType.SignLined)) lined = true;\n\t\t\telse if (signs.some((s) => s.semantic === SemanticType.SignInterval)) interval = true;\n\t\t}\n\n\t\ttype = type || TokenType[point.semantic];\n\t\tconst fixedY = TOKEN_Y_FIXED[type];\n\t\tlet roundY = TOKEN_Y_ROUND[type];\n\n\t\tif (lined || interval) roundY = Math.max(roundY, 1);\n\n\t\tlet y = point.y;\n\t\tif (Number.isFinite(fixedY)) y = fixedY;\n\t\telse if (roundY) {\n\t\t\tif (interval) y = roundNumber(y + 0.5, roundY) - 0.5;\n\t\t\telse y = roundNumber(y, roundY);\n\t\t}\n\t\t//if (lined || interval)\n\t\t//\tconsole.log(\"round sign:\", point.semantic, y, lined, interval);\n\n\t\tconst holder = measure.tokens.find((token) => token.type === type && Math.abs(token.x - x) < 0.1 && Math.abs(token.y - y) < 0.1);\n\t\tif (holder) {\n\t\t\tif (Number.isFinite(holder.confidence) && holder.confidence < point.confidence) {\n\t\t\t\tholder.x = x;\n\t\t\t\tholder.y = y;\n\t\t\t\tholder.confidence = point.confidence;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// exlude clef out of pitch range\n\t\tif (TokenClefs.includes(type)) {\n\t\t\tif (Math.abs(y) > 3) return;\n\t\t}\n\n\t\t// TODO: exclude overlapped pair by a token prior table\n\n\t\tmeasure.tokens.push(\n\t\t\tnew Token({\n\t\t\t\tid: point.id,\n\t\t\t\ttype,\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tpivotX: point.pivotX,\n\t\t\t\tconfidence: point.confidence,\n\t\t\t\t...fields,\n\t\t\t})\n\t\t);\n\n\t\tif (antiPoint) {\n\t\t\tmeasure.antiTokens.push(\n\t\t\t\tnew Token({\n\t\t\t\t\tid: antiPoint.id,\n\t\t\t\t\ttype,\n\t\t\t\t\tx,\n\t\t\t\t\ty: antiPoint.y,\n\t\t\t\t\tconfidence: antiPoint.confidence,\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tappendFlags(flags: SemanticPoint[], stems: Stem[]): void {\n\t\t//console.log(\"flags:\", flags);\n\t\tconst stemGroups = stems\n\t\t\t.map((stem) => ({\n\t\t\t\t...stem,\n\t\t\t\tflags: flags.filter((flag) => Math.abs(flag.x - stem.x) < 0.3 && flag.y > stem.y1 - 0.5 && flag.y < stem.y2 + 0.5),\n\t\t\t}))\n\t\t\t.filter((group) => group.flags.length);\n\n\t\tstemGroups.forEach((group) => {\n\t\t\tconst mainFlag = group.flags.reduce((main, flag) => (main && main.confidence > flag.confidence ? main : flag), null);\n\n\t\t\t//const upDistance = mainFlag.y - group.y1;\n\t\t\t//const downDistance = group.y2 - mainFlag.y;\n\t\t\t//const downward = downDistance < upDistance;\n\t\t\tconst downward = group.direction === 'd';\n\n\t\t\tconst tailY = downward ? Math.min(group.y2, group.y1 + STEM_LENGTH_MAX) : Math.max(group.y1, group.y2 - STEM_LENGTH_MAX);\n\n\t\t\tconst flagTips = group.flags.map((flag) => ({\n\t\t\t\ttip: (tailY - flag.y) * (downward ? 1 : -1),\n\t\t\t\tconfidence: flag.confidence,\n\t\t\t}));\n\t\t\tconst count = flagTips.filter((f) => f.tip < 2 || f.confidence > mainFlag.confidence * 0.7).length;\n\n\t\t\tconst type = TokenFlags[count - 1];\n\t\t\tif (type) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: group.flags[0].id,\n\t\t\t\t\t\tx: group.x,\n\t\t\t\t\t\ty: tailY,\n\t\t\t\t\t\tconfidence: Math.min(...group.flags.map((flag) => flag.confidence)),\n\t\t\t\t\t},\n\t\t\t\t\t{ type }\n\t\t\t\t);\n\t\t\t\t//console.log(\"flag:\", type);\n\t\t\t}\n\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\t\tthis.semantics = [];\n\t}\n\n\tclearPredictedTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = measure.tokens.filter((token) => !token.isPredicted)));\n\t}\n}\n\nclass System extends SimpleClass {\n\tstatic className = 'System';\n\tstatic blackKeys = ['index', 'pageIndex', 'prev', 'next', 'headMeasureIndex', 'tokens', 'indent'];\n\n\tindex?: number;\n\tpageIndex?: number;\n\tprev?: System;\n\tnext?: System;\n\theadMeasureIndex?: number; // zero based\n\n\t// in units\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\tindent: boolean;\n\n\tmeasureCount: number;\n\tstaves: Staff[];\n\n\tmeasureBars: number[];\n\n\tbackgroundImage: string;\n\timagePosition: Rect;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tsidBlackList: string[];\n\tsidWhiteList: string[];\n\n\tdisplacementSemantics?: { [id: string]: Partial };\n\n\tstaffMaskChanged: number;\n\tbracketsAppearance: string; // the staff layout code by prediction\n\n\tconstructor({ stavesCount, ...fields }: any) {\n\t\tsuper();\n\t\tsuper.assign(fields);\n\n\t\tif (!this.measureBars) {\n\t\t\tconst HEAD_WIDTH = 5;\n\t\t\tconst segmentLength = (this.width - HEAD_WIDTH) / this.measureCount;\n\t\t\tthis.measureBars = Array(this.measureCount)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => HEAD_WIDTH + segmentLength * (i + 1));\n\t\t}\n\n\t\tif (!fields.staves && stavesCount)\n\t\t\tthis.staves = Array(stavesCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Staff({ measureBars: this.measureBars }));\n\n\t\tthis.arrangePosition();\n\n\t\tthis.measureCount = this.measureCount || this.measureBars.length;\n\n\t\tthis.sidBlackList = this.sidBlackList || [];\n\t\tthis.sidWhiteList = this.sidWhiteList || [];\n\t}\n\n\tget noteRange(): { top: number; bottom: number } {\n\t\tif (!this.staves.length) return null;\n\n\t\tconst staffTop = this.staves[0];\n\t\tconst staffBottom = this.staves[this.staves.length - 1];\n\n\t\treturn {\n\t\t\ttop: staffTop.top + staffTop.staffY + staffTop.noteRange.top,\n\t\t\tbottom: staffBottom.top + staffBottom.staffY + staffBottom.noteRange.bottom,\n\t\t};\n\t}\n\n\tget staffPositions(): StaffPosition[] {\n\t\treturn this.staves.map((staff) => ({\n\t\t\ty: staff.top + staff.staffY,\n\t\t\tradius: 2,\n\t\t}));\n\t}\n\n\tget staffMask(): number {\n\t\tif (this.staffMaskChanged) return this.staffMaskChanged;\n\n\t\tif (this.prev && this.staves.length === this.prev.staves.length) return this.prev.staffMask;\n\n\t\treturn 2 ** this.staves.length - 1;\n\t}\n\n\tget staffTop(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[0].y - positions[0].radius : 0;\n\t}\n\n\tget staffBottom(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[positions.length - 1].y + positions[positions.length - 1].radius : 0;\n\t}\n\n\tarrangePosition(): void {\n\t\tlet y = 0;\n\t\tfor (const staff of this.staves) {\n\t\t\tif (Number.isFinite(staff.top)) break;\n\n\t\t\tstaff.top = y;\n\t\t\ty += staff.height;\n\t\t}\n\t}\n\n\ttidyMeasureBars(): void {\n\t\tthis.measureBars = this.measureBars.filter((x) => x > 1);\n\t\tthis.measureBars.sort((b1, b2) => b1 - b2);\n\n\t\tconst restWidth = this.width - this.measureBars[this.measureBars.length - 1];\n\t\tif (restWidth > 12) this.measureBars.push(this.width);\n\t\telse if (restWidth < 2) this.measureBars[this.measureBars.length - 1] = this.width;\n\n\t\tthis.measureBars = this.measureBars.filter((x, i) => i < 1 || x - this.measureBars[i - 1] > 4);\n\t}\n\n\trearrangeMeasures(): void {\n\t\tthis.measureCount = this.measureBars.length;\n\t\tthis.staves.forEach((staff) => staff.rearrangeMeasures(this.measureBars));\n\t}\n\n\tget height(): number {\n\t\treturn this.staves.reduce((height, staff) => height + staff.height, 0);\n\t}\n\n\tget connectionLine(): { top: number; bottom: number } {\n\t\tconst staffHead = this.staves[0];\n\t\tconst staffTail = this.staves[this.staves.length - 1];\n\n\t\treturn (\n\t\t\tstaffHead && {\n\t\t\t\ttop: staffHead.top + staffHead.staffY - 2,\n\t\t\t\tbottom: staffTail.top + staffTail.staffY + 2,\n\t\t\t}\n\t\t);\n\t}\n\n\tget middleY(): number {\n\t\tif (!this.staves.length) return 0;\n\n\t\tconst sum = this.staves.reduce((sum, staff) => sum + staff.top + staff.staffY, 0);\n\n\t\treturn sum / this.staves.length;\n\t}\n\n\tget timeSignatureOnHead(): boolean {\n\t\treturn this.staves.some((staff) => staff.measures[0]?.tokens.some((token) => TokenTimesigs.includes(token.type)));\n\t}\n\n\t// an array staff or null on every position of full staff layout\n\tgetStaffArray(stavesCount: number): Staff[] {\n\t\tlet si = 0;\n\n\t\treturn Array(stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, i) => {\n\t\t\t\tconst on = this.staffMask & (1 << i);\n\t\t\t\tconst staff = on ? this.staves[si++] : null;\n\t\t\t\tconsole.assert(!on || staff, 'system staves count is less than staff mask declared:', this.staves.length, this.staffMask.toString(2));\n\n\t\t\t\treturn staff;\n\t\t\t});\n\t}\n\n\t// measureIndex: the local measure index\n\tgetMarksInMeasure(measureIndex: number): MarkTerm[] {\n\t\tconsole.assert(measureIndex < this.measureBars.length, 'measure index out of range:', measureIndex, this.measureBars.length);\n\n\t\tconst left = measureIndex > 0 ? this.measureBars[measureIndex - 1] : 0;\n\t\tconst right = this.measureBars[measureIndex];\n\n\t\tconst tempoTokens = (this.tokens ?? []).filter(\n\t\t\t(token) => token.x >= left && token.x < right && token instanceof TextToken && token.textType === TextType.TempoNumeral\n\t\t) as TextToken[];\n\n\t\treturn [...tempoTokens.map((token) => TempoTerm.fromNumeralText(token.text)).filter(Boolean)];\n\t}\n\n\tgetEvents(stavesCount: number): EventSystem {\n\t\tconsole.assert(Number.isInteger(this.headMeasureIndex), 'invalid headMeasureIndex:', this.headMeasureIndex);\n\n\t\t// Empty system (no measureBars / no staves with measures): return empty result\n\t\tif (!this.measureBars?.length && this.staves.every((s) => !s.measures?.length)) {\n\t\t\treturn { staffMask: this.staffMask, columns: [] };\n\t\t}\n\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => {\n\t\t\t\tconst events = measure.getEvents();\n\t\t\t\tmeasure.assignAccessoriesOnEvents(events);\n\t\t\t\tmeasure.assignFeaturesOnEvents(events, staff.semantics);\n\n\t\t\t\treturn {\n\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t\tcontexts: measure.getContexts({ staff: staff.index }),\n\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts?.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (row[mi] && !row[mi].contexts.length && !row[mi].events.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//onst measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: this.getMarksInMeasure(i),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i]?.voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i]?.voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row[i]?.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i]?.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\t\t//columns.forEach(computeMeasureTicks);\n\n\t\t// assign id on column events\n\t\tcolumns.forEach((column) => {\n\t\t\tconst events = [].concat(...column.rows.filter(Boolean).map((row) => row.events));\n\t\t\tevents.forEach((event, i) => (event.id = i + 1));\n\t\t});\n\n\t\tconst lastColumn = columns[columns.length - 1];\n\t\tif (lastColumn) lastColumn.break = true;\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tgetEventsFunctional(stavesCount: number, ev: ChordsFeeder, processors: ColumnProcessor[] = [], { useXMap = false } = {}): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff, si) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure, mi) => {\n\t\t\t\tconst events = ev(si, mi);\n\n\t\t\t\treturn (\n\t\t\t\t\tevents && {\n\t\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontexts: measure.getContexts({ staff: si }),\n\t\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\t// [measure, staff]\n\t\tconst columns: EventMeasureColumn[] = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => {\n\t\t\t\tconst localRows = rows.map((row) => row[mi]);\n\t\t\t\tif (localRows.some((row) => !row)) return null;\n\n\t\t\t\tlet xMap: Map = null;\n\t\t\t\tif (useXMap) {\n\t\t\t\t\tconst events: EventTerm[] = [].concat(...localRows.map((row) => row.events));\n\t\t\t\t\tconst groupMap: { [group: number]: EventTerm[] } = events.reduce((map, event) => {\n\t\t\t\t\t\tif (Number.isFinite(event.tickGroup)) map[event.tickGroup] = map[event.tickGroup] || [];\n\t\t\t\t\t\tmap[event.tickGroup].push(event);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, {});\n\n\t\t\t\t\txMap = Object.values(groupMap).reduce((map, events) => {\n\t\t\t\t\t\tconst x = Math.min(...events.map((event) => (event.left + event.right) / 2));\n\t\t\t\t\t\tmap.set(x, events);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, new Map());\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + mi,\n\t\t\t\t\t//startX: measureStartXs[mi],\n\t\t\t\t\t//width: measureWidths[mi],\n\t\t\t\t\trows: localRows, // [staff]\n\t\t\t\t\tmarks: this.getMarksInMeasure(mi),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\txMap,\n\t\t\t\t\tvoltaBegin: localRows.some((row) => row.voltaBegin),\n\t\t\t\t\tvoltaEnd: localRows.some((row) => row.voltaEnd),\n\t\t\t\t\talternative: localRows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: localRows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\tprocessors.forEach((proc) => columns.forEach(proc));\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\t// get EventSystem contains only contexted terms\n\tgetContexts(stavesCount: number): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: null,\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => ({\n\t\t\t\tevents: null,\n\t\t\t\tcontexts: measure.getContexts(),\n\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t}));\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (!row[mi].contexts.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: [],\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i].voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i].voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i].barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tassignSemantics(staffIndex: number, graph: SemanticGraph): void {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff is null:', staffIndex, this.staves);\n\t\tconst oy = staff.top + staff.staffY;\n\n\t\tgraph.getSystemPoints().forEach((point) => {\n\t\t\tconst p = { ...point };\n\t\t\tp.y += oy;\n\n\t\t\tif (p.extension) {\n\t\t\t\tp.extension = { ...p.extension };\n\t\t\t\tif (Number.isFinite(p.extension.y1)) {\n\t\t\t\t\tp.extension.y1 += oy;\n\t\t\t\t\tp.extension.y2 += oy;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.semantics.push(p);\n\t\t});\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, logger: Logger = new DummyLogger()): void {\n\t\t//console.log(\"System.assignSemantics:\", graph);\n\t\tthis.measureBars = [];\n\n\t\tif (!this.semantics) return;\n\n\t\tconst graph = SemanticGraph.fromPoints(this.semantics);\n\n\t\tconst bars = graph.getConfidentLayer(SemanticType.vline_BarMeasure, threshold);\n\t\tbars.sort((b1, b2) => b1.x - b2.x);\n\n\t\tconst staffTop = this.staffTop;\n\t\tconst staffBottom = this.staffBottom;\n\n\t\tconst MERGE_WINDOW = 0.4;\n\t\tlet lastX = 0;\n\t\tconst barColumns: { [key: number]: number } = bars.reduce((columns, bar) => {\n\t\t\tconst confidence = Number.isFinite(bar.confidence) ? Math.tanh(bar.confidence) : 1;\n\n\t\t\tconst x = bar.x - lastX > MERGE_WINDOW ? bar.x : lastX;\n\t\t\tlastX = bar.x;\n\t\t\tlet intensity = columns[x] || 0;\n\t\t\tintensity += (Math.min(bar.extension.y2, staffBottom) - Math.max(bar.extension.y1, staffTop)) * confidence;\n\n\t\t\tif (bar.x !== x) delete columns[x];\n\t\t\tcolumns[bar.x] = intensity;\n\n\t\t\treturn columns;\n\t\t}, {});\n\t\tconst barXs: number[] = Object.entries(barColumns)\n\t\t\t.filter(([x, intensity]) => (void x, intensity > 3 * this.staves.length))\n\t\t\t.map(([x]) => Number(x));\n\t\tbarXs.sort((x1, x2) => x1 - x2);\n\t\tbarXs.forEach((x, i) => {\n\t\t\tif (i <= 0 || x - barXs[i - 1] > 2) this.measureBars.push(x);\n\t\t});\n\n\t\tif (!this.measureBars.length) this.measureBars.push(this.width);\n\n\t\tthis.tidyMeasureBars();\n\t\tthis.rearrangeMeasures();\n\n\t\t// measure bar type\n\t\tconst typeBars = this.semantics.filter((point) => [SemanticType.vline_BarTerminal, SemanticType.vline_BarSegment].includes(point.semantic));\n\t\ttypeBars.forEach((bar) => {\n\t\t\tconst measure = this.staves[0].measures.find((measure) => bar.x > measure.right - 2 && bar.x < measure.right + 1);\n\t\t\tif (measure) {\n\t\t\t\tconst type = bar.semantic.replace(/^vline_Bar/, '');\n\t\t\t\tmeasure.barTypes[type] = measure.barTypes[type] || 0;\n\t\t\t\tmeasure.barTypes[type] += bar.confidence;\n\t\t\t}\n\t\t});\n\n\t\tlet staffIndex = 0;\n\t\tconst staffMask = this.staffMask;\n\t\tthis.staves.forEach((staff, si) => {\n\t\t\t// staff index\n\t\t\twhile (!(staffMask & (1 << staffIndex))) ++staffIndex;\n\t\t\tstaff.index = staffIndex++;\n\n\t\t\t// assign semantic boundaries\n\t\t\tif (si === 0) staff.semanticTop = -staff.staffY;\n\t\t\telse {\n\t\t\t\tconst prevStaff = this.staves[si - 1];\n\t\t\t\tstaff.semanticTop = prevStaff.top + prevStaff.staffY + 3 - (staff.top + staff.staffY);\n\t\t\t}\n\n\t\t\tif (si < this.staves.length - 1) {\n\t\t\t\tconst nextStaff = this.staves[si + 1];\n\t\t\t\tstaff.semanticBottom = nextStaff.top + nextStaff.staffY - 3 - (staff.top + staff.staffY);\n\t\t\t} else staff.semanticBottom = this.height - (staff.top + staff.staffY);\n\n\t\t\tif (staff.semantics && staff.semantics.length) {\n\t\t\t\tstaff.semantics.forEach((point) => hashSemanticPoint(this.index, si, point));\n\n\t\t\t\tstaff.clearPredictedTokens();\n\t\t\t\tstaff.assemble(threshold, this, logger);\n\t\t\t}\n\t\t});\n\t}\n\n\tqualifiedSemantics(semantics: SemanticPoint[], threshold: number = 1): SemanticPoint[] {\n\t\treturn semantics\n\t\t\t.filter(\n\t\t\t\t(p) => this.sidWhiteList.includes(p.id) || (!this.sidBlackList.includes(p.id) && (p.confidence >= threshold || !Number.isFinite(p.confidence)))\n\t\t\t)\n\t\t\t.map((point) => {\n\t\t\t\t// displace semantic point\n\t\t\t\tif (this.displacementSemantics && this.displacementSemantics[point.id]) return { ...point, ...this.displacementSemantics[point.id] };\n\n\t\t\t\treturn point;\n\t\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.staves.forEach((staff) => staff.clearTokens());\n\t\tthis.semantics = [];\n\t}\n\n\tnewPoint(staffIndex: number, data: SemanticPoint, threshold: number = 1): SemanticPoint {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff index out of bound:', staffIndex, this.staves.length);\n\n\t\tconst { semantic, x, y, confidence = 0, extension = null } = data;\n\t\tconst point = { semantic, x, y, confidence, extension };\n\t\tif (!point.extension) delete point.extension;\n\n\t\thashSemanticPoint(this.index, staffIndex, point);\n\t\tstaff.semantics.push(point);\n\t\tstaff.clearPredictedTokens();\n\t\tstaff.assemble(threshold, this);\n\n\t\treturn point;\n\t}\n\n\tappendToken(token: TextToken): void {\n\t\tthis.tokens.push(token);\n\n\t\tswitch (token.textType) {\n\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t{\n\t\t\t\t\t// remove noteheads in text area\n\t\t\t\t\tconst staff = this.staves[0];\n\t\t\t\t\tif (staff) {\n\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\t\t\t\t\t\tstaff.measures.forEach((measure) => {\n\t\t\t\t\t\t\tmeasure.tokens = measure.tokens.filter(\n\t\t\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t\t\t!TokenNoteheads.includes(t.type) ||\n\t\t\t\t\t\t\t\t\tMath.abs(t.x - token.x) > token.width / 2 ||\n\t\t\t\t\t\t\t\t\tMath.abs(oy + t.y - token.y) > token.fontSize / 2\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase TextType.Alternation1:\n\t\t\tcase TextType.Alternation2:\n\t\t\t\t//console.log(\"appendToken:\", token, this.staves[0].measures);\n\t\t\t\tthis.staves[0].measures.forEach((measure) => {\n\t\t\t\t\tconst overlap = Math.min(measure.left + measure.width, token.x + token.width / 2) - Math.max(measure.left, token.x - token.width / 2);\n\t\t\t\t\tmeasure.alternative = measure.alternative || overlap / measure.width > 0.5;\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nclass Page extends SimpleClass {\n\tstatic className = 'Page';\n\tstatic blackKeys = ['index', 'tokens'];\n\n\tindex?: number;\n\n\t// in units\n\twidth: number;\n\theight: number;\n\n\tsystems: System[];\n\n\tsource: SourceImageFile;\n\tlayout?: PageLayout;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.systems = this.systems || [];\n\n\t\tif (this.source) {\n\t\t\tthis.source.matrix = this.source.matrix || [1, 0, 0, 1, 0, 0];\n\t\t}\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tclearTokens(): void {\n\t\tthis.semantics = null;\n\t\tthis.tokens = null;\n\n\t\tthis.systems.forEach((system) => (system.tokens = null));\n\t}\n\n\tassignTexts(areas: TextArea[], [imageHeight, imageWidth]: [number, number]): void {\n\t\tconst interval = this.source && this.source.interval ? this.source.interval * (imageHeight / this.source.dimensions.height) : imageHeight / this.height;\n\n\t\tthis.semantics = areas.map((area) => {\n\t\t\tconst p = {\n\t\t\t\tx: (area.cx - imageWidth / 2) / interval,\n\t\t\t\ty: (area.cy - imageHeight / 2) / interval,\n\t\t\t};\n\t\t\tconst rp = this.source && this.source.matrix ? trans23(p, this.source.matrix) : p;\n\n\t\t\treturn {\n\t\t\t\tconfidence: area.score,\n\t\t\t\tx: rp.x + this.width / 2,\n\t\t\t\ty: rp.y + this.height / 2,\n\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\textension: {\n\t\t\t\t\ttext: area.text,\n\t\t\t\t\ttype: area.type,\n\t\t\t\t\twidth: area.width / interval,\n\t\t\t\t\theight: area.height / interval,\n\t\t\t\t\ttheta: area.theta,\n\t\t\t\t\ttextFeature: area.feature_dict,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tassemble({ textAnnotations = null }: { textAnnotations?: { [id: string]: string } } = {}, logger: Logger = new DummyLogger()): void {\n\t\tthis.tokens = [];\n\t\tthis.systems.forEach((system) => (system.tokens = []));\n\n\t\t// compute system indent\n\t\tif (this.systems.length) {\n\t\t\tconst sysXs = this.systems.map((system) => system.left);\n\t\t\tconst middleX = sysXs[Math.floor((sysXs.length - 1) / 2)];\n\t\t\tthis.systems.forEach((system) => (system.indent = system.left > middleX + INDENT_THRESHOLD));\n\t\t}\n\n\t\tif (this.semantics) {\n\t\t\tconst pageName = this.source ? this.source.name : this.index.toString();\n\n\t\t\tthis.semantics.forEach((point) => {\n\t\t\t\thashPageSemanticPoint(pageName, point);\n\n\t\t\t\tconst fields = {\n\t\t\t\t\tid: point.id,\n\t\t\t\t\ttype: TokenType.Text,\n\t\t\t\t\tconfidence: point.confidence,\n\t\t\t\t\ttextType: TEXT_TYPE_ALIAS[point.extension.type] || point.extension.type,\n\t\t\t\t\ttext: (textAnnotations && textAnnotations[point.id]) || point.extension.text,\n\t\t\t\t\ttextFeasure: point.extension.textFeature,\n\t\t\t\t\twidth: point.extension.width,\n\t\t\t\t\tfontSize: point.extension.height,\n\t\t\t\t};\n\n\t\t\t\tswitch (point.semantic) {\n\t\t\t\t\tcase SemanticType.rect_Text:\n\t\t\t\t\t\tswitch (fields.textType) {\n\t\t\t\t\t\t\t// page tokens\n\t\t\t\t\t\t\tcase TextType.Title:\n\t\t\t\t\t\t\tcase TextType.Author:\n\t\t\t\t\t\t\tcase TextType.PageMargin:\n\t\t\t\t\t\t\tcase TextType.Other:\n\t\t\t\t\t\t\t\tthis.tokens.push(\n\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens on the top of system\n\t\t\t\t\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t\t\t\tcase TextType.Chord:\n\t\t\t\t\t\t\tcase TextType.MeasureNumber:\n\t\t\t\t\t\t\tcase TextType.Instrument:\n\t\t\t\t\t\t\tcase TextType.Alternation1:\n\t\t\t\t\t\t\tcase TextType.Alternation2:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = this.systems.find((system) => system.top + system.staffTop > point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tsystem.appendToken(\n\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\tx: point.x - system.left,\n\t\t\t\t\t\t\t\t\t\t\t\ty: point.y - system.top,\n\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens in staff\n\t\t\t\t\t\t\tcase TextType.TextualMark:\n\t\t\t\t\t\t\tcase TextType.Times:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = [...this.systems].reverse().find((system) => system.top < point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tconst sy = point.y - (system.top + system.staffTop);\n\t\t\t\t\t\t\t\t\t\tconst sx = point.x - system.left;\n\t\t\t\t\t\t\t\t\t\tconst staff = system.staves.find((staff) => sy >= staff.top && sy < staff.top + staff.height);\n\t\t\t\t\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\t\t\t\t\tconst measure = staff.measures.find((measure) => sx >= measure.left && sx < measure.left + measure.width);\n\t\t\t\t\t\t\t\t\t\t\tif (measure) {\n\t\t\t\t\t\t\t\t\t\t\t\tmeasure.tokens.push(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx: sx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ty: sy,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport { Measure, Staff, System, Page };\n","import { ChordColumn, Fraction } from './interfaces';\nimport { GraceType } from './term';\nimport { roundNumber } from './utils';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum SemanticElementType {\n\tBOS,\n\tPAD,\n\n\tNoteheadS0,\n\tNoteheadS1,\n\tNoteheadS2,\n\tNoteheadGrace,\n\tvline_Stem,\n\tFlag3,\n\tBeamLeft,\n\tBeamContinue,\n\tBeamRight,\n\tDot,\n\tRest0,\n\tRest1,\n\tRest2,\n\tRest3,\n\tRest4,\n\tRest5,\n\tRest6,\n\n\t// measure time signature denominators & numerators\n\tTimeD2,\n\tTimeD4,\n\tTimeD8,\n\tTimeN1,\n\tTimeN2,\n\tTimeN3,\n\tTimeN4,\n\tTimeN5,\n\tTimeN6,\n\tTimeN7,\n\tTimeN8,\n\tTimeN9,\n\tTimeN10,\n\tTimeN11,\n\tTimeN12,\n}\n\nconst TIME_SIG_DENOMINATORS = Object.fromEntries([2, 4, 8].map((n) => [n, SemanticElementType[`TimeD${n}`]]));\nconst TIME_SIG_NUMERATORS = Object.fromEntries(\n\tArray(12)\n\t\t.fill(null)\n\t\t.map((_, i) => i + 1)\n\t\t.map((n) => [n, SemanticElementType[`TimeN${n}`]])\n);\n\nconst et = SemanticElementType;\n\nconst ELEMENT_TOKEN_NAMES = {\n\t[et.BOS]: 'BOS',\n\t[et.NoteheadS0]: 'noteheads-s0',\n\t[et.NoteheadS1]: 'noteheads-s1',\n\t[et.NoteheadS2]: 'noteheads-s2',\n\t[et.NoteheadGrace]: 'GraceNotehead',\n\t[et.Flag3]: 'flags-u3',\n\t[et.BeamLeft]: 'BeamLeft',\n\t[et.BeamContinue]: 'BeamContinue',\n\t[et.BeamRight]: 'BeamRight',\n\t[et.Dot]: 'dot',\n\t[et.Rest0]: 'rests-0o',\n\t[et.Rest1]: 'rests-1o',\n\t[et.Rest2]: 'rests-2',\n\t[et.Rest3]: 'rests-3',\n\t[et.Rest4]: 'rests-4',\n\t[et.Rest5]: 'rests-5',\n\t[et.Rest6]: 'rests-6',\n};\n\nconst NOTEHEAD_BASE_DIVISION = {\n\t[et.NoteheadS0]: 0,\n\t[et.NoteheadS1]: 1,\n\t[et.NoteheadS2]: 2,\n\t[et.NoteheadGrace]: 2,\n};\n\nconst NOTEHEAD_ELEMENT_TYPES = [et.NoteheadS0, et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace];\n\nconst REST_ELEMENT_TYPES = [et.Rest0, et.Rest1, et.Rest2, et.Rest3, et.Rest4, et.Rest5, et.Rest6];\n\nconst BEAM_ELEMENT_TYPES = [et.BeamLeft, et.BeamContinue, et.BeamRight];\n\nconst NOTE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES];\n\nconst SOURCE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES, et.vline_Stem];\n\nconst TARGET_ELEMENT_TYPES = [et.BOS, et.NoteheadS0, et.vline_Stem, ...REST_ELEMENT_TYPES];\n\nconst ROOT_NOTE_ELEMENT_TYPES = [...NOTE_ELEMENT_TYPES, et.vline_Stem];\n\nconst ELEMENT_TO_STEMBEAM = {\n\t[et.BeamLeft]: 'Open',\n\t[et.BeamRight]: 'Close',\n};\n\ninterface SemanticElement {\n\ttype: SemanticElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\n\tindex?: number;\n\ttick?: number;\n\tid?: string;\n}\n\ntype Matrix = number[][];\n\nconst metaElem = (type: SemanticElementType): SemanticElement => ({\n\ttype,\n\tstaff: -1,\n\tx: 0,\n\ty1: 0,\n\ty2: 0,\n});\n\nconst BOS_ELEMENT = metaElem(SemanticElementType.BOS);\n\nconst fractionToElems = (fraction: Fraction): SemanticElement[] => [\n\tmetaElem(TIME_SIG_NUMERATORS[fraction.numerator]),\n\tmetaElem(TIME_SIG_DENOMINATORS[fraction.denominator]),\n];\n\nconst argmax = (data: number[], mask: boolean[]): number => {\n\tconst values = data.filter((_, i) => mask[i]);\n\tconst max = Math.max(...values);\n\n\treturn data.findIndex((x) => x === max);\n};\n\nclass SemanticCluster extends SimpleClass {\n\tindex?: number;\n\n\telements: SemanticElement[];\n\tmatrixH?: Matrix; // matrix N x N\n\t_matrixV?: Matrix; // matrix N x N\n\tgroupsV?: number[][]; // ids array\n\tmasks?: [boolean[], boolean[], boolean[]]; // the masks for: [jointer source, jointer target, V]\n\n\tstatic elementToJSON(elem: SemanticElement): object {\n\t\tconst result: any = {\n\t\t\ttype: elem.type,\n\t\t\tstaff: elem.staff,\n\t\t\tx: elem.x,\n\t\t\ty1: elem.y1,\n\t\t\ty2: elem.y2,\n\t\t};\n\n\t\tif (elem.id) result.id = elem.id;\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget sourceMask(): boolean[] {\n\t\treturn this.elements.map((elem) => SOURCE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget targetMask(): boolean[] {\n\t\treturn this.elements.map((elem) => TARGET_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget vMask(): boolean[] {\n\t\treturn this.elements.map((elem) => ROOT_NOTE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget compactMatrixH(): Matrix {\n\t\tif (!this.matrixH) return null;\n\n\t\tconst sourceMask = this.sourceMask;\n\t\tconst targetMask = this.targetMask;\n\n\t\treturn this.matrixH.filter((_, i) => sourceMask[i]).map((row) => row.filter((_, j) => targetMask[j]));\n\t}\n\n\tset compactMatrixH(value: Matrix) {\n\t\tthis.matrixH = expandMatrixByMasks([].concat(...value), [this.sourceMask, this.targetMask]);\n\t}\n\n\tget compactMatrixV(): number[] {\n\t\tif (!this._matrixV) return null;\n\n\t\tconst vMask = this.vMask;\n\n\t\tconst matrix = this._matrixV.filter((_, i) => vMask[i]).map((row) => row.filter((_, j) => vMask[j]));\n\n\t\treturn [].concat(...matrix.map((row, i) => row.slice(0, i)));\n\t}\n\n\tset compactMatrixV(value: number[]) {\n\t\tthis.matrixV = value && expandMatrixByMaskTriu(value, this.vMask);\n\t}\n\n\tget matrixV(): Matrix {\n\t\treturn this.groupsV && matrixFromGroups(this.elements.length, this.groupsV);\n\t}\n\n\tset matrixV(value: Matrix) {\n\t\tif (!value) {\n\t\t\tthis.groupsV = null;\n\t\t\tthis._matrixV = value;\n\t\t\treturn;\n\t\t}\n\n\t\tconst THRESHOLD = 0.5;\n\n\t\tconst groups: number[][] = [];\n\t\tconst vMask = value.map((row, i) => row.some(Number.isFinite) || value.some((row) => Number.isFinite(row[i])));\n\n\t\tvalue.forEach((row, i) => {\n\t\t\tif (vMask[i]) {\n\t\t\t\tlet found = false;\n\n\t\t\t\tfor (let j = 0; j < i; ++j) {\n\t\t\t\t\tconst cell = row[j];\n\t\t\t\t\tif (cell >= THRESHOLD) {\n\t\t\t\t\t\tconst g = groups.findIndex((group) => group.includes(j));\n\t\t\t\t\t\tgroups[g].push(i);\n\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!found) groups.push([i]);\n\t\t\t}\n\t\t});\n\n\t\tthis.groupsV = groups;\n\t\tthis._matrixV = value;\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\t__prototype: 'SemanticCluster',\n\t\t\tindex: this.index,\n\t\t\telements: this.elements.map(SemanticCluster.elementToJSON),\n\t\t\tcompactMatrixH: this.compactMatrixH,\n\t\t\tcompactMatrixV: this.compactMatrixV,\n\t\t\t//groupsV: this.groupsV,\n\t\t};\n\t}\n\n\tstatic mapMatrix(matrix: number[][], x2i: number[], i2x: number[]): number[][] {\n\t\tconst rows = x2i.reduce((rows, i, x) => {\n\t\t\tif (rows[i]) rows[i] = rows[i].map((v, xi) => (v + matrix[x][xi] ? 1 : 0));\n\t\t\telse rows[i] = matrix[x];\n\n\t\t\treturn rows;\n\t\t}, [] as number[][]);\n\n\t\treturn rows.map((row) => i2x.map((x) => row[x]));\n\t}\n\n\tmergeOverlapping() {\n\t\tconst overlaps = this.overlappedNoteheads();\n\t\tif (overlaps.length) {\n\t\t\tconst x2i = this.elements.map((_, index) => {\n\t\t\t\tconst pair = overlaps.find((ij) => index === ij[1]);\n\t\t\t\tconst i = pair ? pair[0] : index;\n\n\t\t\t\treturn i - overlaps.filter((ij) => ij[1] < i).length;\n\t\t\t});\n\t\t\tconst i2x = Array(this.elements.length - overlaps.length)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, i) => x2i.findIndex((ii) => ii === i));\n\n\t\t\tthis.elements = i2x.map((x) => this.elements[x]);\n\t\t\tconsole.assert(this.elements.every(Boolean), 'null element found:', this, x2i, i2x);\n\n\t\t\tthis.matrixH = SemanticCluster.mapMatrix(this.matrixH, x2i, i2x);\n\t\t\tthis.groupsV = this.groupsV.map((group) => Array.from(new Set(group.map((x) => x2i[x]))));\n\t\t}\n\t}\n\n\toverlappedNoteheads(): [number, number][] {\n\t\tconst indices = [];\n\n\t\tconst noteheads = this.elements.filter((elem) => NOTEHEAD_ELEMENT_TYPES.includes(elem.type));\n\t\tfor (let i = 0; i < noteheads.length; ++i) {\n\t\t\tconst nh1 = noteheads[i];\n\t\t\tfor (let j = i + 1; j < noteheads.length; ++j) {\n\t\t\t\tconst nh2 = noteheads[j];\n\t\t\t\tif ((nh1.x - nh2.x) * (nh1.x - nh2.x) + (nh1.y1 - nh2.y1) * (nh1.y1 - nh2.y1) < 0.2 ** 2) indices.push([nh1.index, nh2.index]);\n\t\t\t}\n\t\t}\n\n\t\treturn indices;\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\tconsole.assert(this.matrixH, '[SemanticCluster.getEvents]\tmatrixH is null.');\n\n\t\tconst NOTE_STEM_CONFIDENCE = 0.5;\n\n\t\tconst ids = Array(this.elements.length)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => index);\n\n\t\tconst targetMask = this.masks ? this.masks[1] : ids.map((id) => TARGET_ELEMENT_TYPES.includes(this.elements[id].type));\n\n\t\t//const stems = ids.filter(i => this.elements[i].type === et.vline_Stem);\n\t\tconst stemMasks = ids.map((id) => this.elements[id].type === et.vline_Stem && this.elements[id].y2 - this.elements[id].y1 > 2); // TODO: sift out too short stems by rectification model\n\t\tconst stemNotes = ids.filter((i) => [et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace].includes(this.elements[i].type));\n\t\tconst s0s = ids.filter((i) => this.elements[i].type === et.NoteheadS0);\n\t\tconst subS0Masks = ids.map(() => false);\n\n\t\t// root elements: top NoteheadS0, Rests, stem with noteheads\n\t\tconst stemMap: { [stem: number]: number[] } = {};\n\t\tstemNotes.forEach((id) => {\n\t\t\tconst note = this.elements[id];\n\t\t\tconst stems = ids\n\t\t\t\t.filter((i) => stemMasks[i])\n\t\t\t\t.filter((stemId) => this.elements[stemId].y1 - 0.5 < note.y1 && this.elements[stemId].y2 + 0.5 > note.y1) // filter by stem Y range\n\t\t\t\t.sort((i1, i2) => this.matrixH[id][i2] - this.matrixH[id][i1]) // sort by confidence\n\t\t\t\t.slice(0, 2)\n\t\t\t\t.filter((i, ii) => ii === 0 || this.matrixH[id][i] >= NOTE_STEM_CONFIDENCE);\n\t\t\tstems.forEach((stem) => {\n\t\t\t\tstemMap[stem] = stemMap[stem] || [];\n\t\t\t\tstemMap[stem].push(id);\n\t\t\t});\n\t\t});\n\n\t\ts0s.forEach((id) => {\n\t\t\tconst s0 = this.elements[id];\n\t\t\tconst prevId = argmax(this.matrixH[id], targetMask);\n\t\t\tconst prev = this.elements[prevId];\n\t\t\tif (prev.type === et.NoteheadS0 && Math.abs(s0.x - prev.x) < 2.6) {\n\t\t\t\tsubS0Masks[id] = true;\n\t\t\t\tstemMap[prevId] = stemMap[prevId] || [prevId];\n\t\t\t\tstemMap[prevId].push(id);\n\t\t\t} else stemMap[id] = stemMap[id] || [id];\n\t\t});\n\n\t\t// setup linkings\n\t\tconst linkings: { [key: number]: number } = {};\n\n\t\tconst roots = ids.filter((id) => stemMap[id] || REST_ELEMENT_TYPES.includes(this.elements[id].type));\n\t\troots.sort((i1, i2) => this.elements[i1].x - this.elements[i2].x); // traverse roots from left to right later\n\n\t\tconst parentMasks = ids.map((id) => id === et.BOS);\n\t\troots.forEach((id) => {\n\t\t\tconst parentId = argmax(this.matrixH[id], parentMasks);\n\t\t\tlinkings[id] = parentId;\n\n\t\t\tif (parentId && !REST_ELEMENT_TYPES.includes(this.elements[parentId].type)) parentMasks[parentId] = false;\n\n\t\t\tparentMasks[id] = true;\n\t\t});\n\t\t//console.log(\"topology:\", stemMap, linkings);\n\n\t\tconst dots = this.elements.filter((elem) => elem.type === et.Dot);\n\t\tconst flags = this.elements.filter((elem) => elem.type === et.Flag3);\n\t\tconst beams = this.elements.filter((elem) => BEAM_ELEMENT_TYPES.includes(elem.type));\n\n\t\tconst groupsV = this.groupsV;\n\n\t\treturn roots\n\t\t\t.map((rootId): ChordColumn => {\n\t\t\t\tconst root = this.elements[rootId];\n\n\t\t\t\tconst tickGroup = groupsV ? groupsV.findIndex((group) => group.includes(rootId)) : null;\n\n\t\t\t\tif (REST_ELEMENT_TYPES.includes(root.type)) {\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > root.x + 0.5 && dot.x < root.x + 0.75 + 1.2 && dot.y1 > root.y1 - 1 && dot.y1 < root.y1);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft: root.x - 0.75,\n\t\t\t\t\t\tright: root.x + 0.75,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\trest: true,\n\t\t\t\t\t\tys: [root.y1],\n\t\t\t\t\t\tnoteIds: [root.id],\n\t\t\t\t\t\tdots: nearbyDots.length,\n\t\t\t\t\t\tdivision: root.type - et.Rest0,\n\t\t\t\t\t\tstemDirection: null,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: root.staff,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t} else if (stemMap[rootId]) {\n\t\t\t\t\tconst subNotes = stemMap[rootId].map((id) => this.elements[id]);\n\t\t\t\t\tconst left = Math.min(...subNotes.map((n) => n.x - 0.7));\n\t\t\t\t\tconst right = Math.max(...subNotes.map((n) => n.x + 0.7));\n\t\t\t\t\tsubNotes.sort((n1, n2) => n2.y1 - n1.y1);\n\n\t\t\t\t\tconst ys = subNotes.map((note) => note.y1);\n\n\t\t\t\t\tconst noteIds = subNotes.map((note) => note.id);\n\n\t\t\t\t\tconst top = ys[0];\n\t\t\t\t\tconst bottom = ys[ys.length - 1];\n\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > right && dot.x < right + 1.2 && dot.y1 > top - 1 && dot.y1 < bottom + 0.5);\n\t\t\t\t\tconst dotGroups: { [key: number]: SemanticElement[] } = nearbyDots.reduce((groups, dot) => {\n\t\t\t\t\t\tconst y = roundNumber(dot.y1, 0.5);\n\t\t\t\t\t\tgroups[y] = groups[y] || [];\n\t\t\t\t\t\tgroups[y].push(dot);\n\n\t\t\t\t\t\treturn groups;\n\t\t\t\t\t}, {});\n\t\t\t\t\tconst dotValue = Math.max(...Object.values(dotGroups).map((group) => group.length), 0);\n\n\t\t\t\t\tlet division = NOTEHEAD_BASE_DIVISION[subNotes[0].type];\n\n\t\t\t\t\tlet stemDirection = null;\n\t\t\t\t\tlet beam: string = null;\n\t\t\t\t\tlet tip = null;\n\t\t\t\t\tif (root.type === et.vline_Stem) {\n\t\t\t\t\t\tconst topTip = top - root.y1;\n\t\t\t\t\t\tconst bottomTip = root.y2 - bottom;\n\t\t\t\t\t\tstemDirection = topTip > bottomTip ? 'u' : 'd';\n\n\t\t\t\t\t\ttip = { x: root.x, y: stemDirection === 'u' ? root.y1 : root.y2 };\n\n\t\t\t\t\t\tif (division === 2) {\n\t\t\t\t\t\t\tconst flagRange = stemDirection === 'u' ? [root.y1 - 0.4, root.y2 - 1] : [root.y1 + 1, root.y2 + 0.4];\n\t\t\t\t\t\t\tconst nearbyFlags = flags.filter((flag) => Math.abs(flag.x - root.x) < 0.2 && flag.y1 > flagRange[0] && flag.y1 < flagRange[1]);\n\t\t\t\t\t\t\tdivision += nearbyFlags.length;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//const tipY = stemDirection === \"u\" ? root.y1 : root.y2;\n\t\t\t\t\t\tconst tipRange = stemDirection === 'u' ? [root.y1 - 0.2, root.y1 + 0.9] : [root.y2 - 0.9, root.y2 + 0.2];\n\t\t\t\t\t\tconst beamElem = beams.find((beam) => Math.abs(beam.x - root.x) < 0.2 && beam.y1 > tipRange[0] && beam.y1 < tipRange[1]);\n\t\t\t\t\t\tbeam = beamElem ? ELEMENT_TO_STEMBEAM[beamElem.type] : null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst grace = subNotes[0].type === SemanticElementType.NoteheadGrace ? GraceType.Grace : null;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\tright,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tys,\n\t\t\t\t\t\ttip,\n\t\t\t\t\t\tnoteIds,\n\t\t\t\t\t\tdivision,\n\t\t\t\t\t\tdots: dotValue,\n\t\t\t\t\t\trest: false,\n\t\t\t\t\t\tstemDirection,\n\t\t\t\t\t\tbeam,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: subNotes[0].staff,\n\t\t\t\t\t\tgrace,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n}\n\ninterface SemanticClusterSetData {\n\tvocab?: string[];\n\tclusters: SemanticCluster[];\n}\n\nclass SemanticClusterSet {\n\tclusters: SemanticCluster[];\n\n\tconstructor(data?: SemanticClusterSetData) {\n\t\tif (data) {\n\t\t\tthis.clusters = data.clusters;\n\n\t\t\t// upgrade vocab\n\t\t\tif (data.vocab) {\n\t\t\t\tconst converts = data.vocab\n\t\t\t\t\t.map((name, i) => [i, SemanticElementType[name]])\n\t\t\t\t\t.filter(([x, y]) => x !== y)\n\t\t\t\t\t.reduce((table, [x, y]) => ((table[x] = y), table), {});\n\t\t\t\tthis.clusters.forEach((connection) =>\n\t\t\t\t\tconnection.elements.forEach((elem) => {\n\t\t\t\t\t\tif (Number.isFinite(converts[elem.type])) elem.type = converts[elem.type];\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst vocab = Object.entries(SemanticElementType)\n\t\t\t.filter((entry) => Number.isFinite(entry[1]))\n\t\t\t.map((entry) => entry[0]);\n\n\t\treturn {\n\t\t\t__prototype: 'SemanticClusterSet',\n\t\t\tvocab,\n\t\t\tclusters: this.clusters.map((c) => c.toJSON()),\n\t\t};\n\t}\n}\n\nconst expandMatrixByMasks = (matrix: number[], masks: [boolean[], boolean[]]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\tconst [maskSrc, maskTar] = masks;\n\n\treturn maskSrc.map((src) => maskTar.map((tar) => (src && tar ? iter.next().value : null)));\n};\n\nconst expandMatrixByMaskTriu = (matrix: number[], mask: boolean[]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\treturn mask.map((row, i) => mask.map((column, j) => (row && column && j < i ? iter.next().value : null)));\n};\n\nconst matrixFromGroups = (len: number, groups: number[][]): Matrix => {\n\tconst groupIds = Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) => groups.findIndex((group) => group.includes(i)));\n\n\treturn Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) =>\n\t\t\tArray(len)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, j) => {\n\t\t\t\t\tif (j >= i) return null;\n\n\t\t\t\t\tconst id1 = groupIds[i];\n\t\t\t\t\tconst id2 = groupIds[j];\n\n\t\t\t\t\tif (id1 < 0 || id2 < 0) return null;\n\n\t\t\t\t\treturn id1 === id2 ? 1 : 0;\n\t\t\t\t})\n\t\t);\n};\n\nexport {\n\tSemanticElementType,\n\tSemanticElement,\n\tSemanticCluster,\n\tSemanticClusterSet,\n\tELEMENT_TOKEN_NAMES,\n\tNOTEHEAD_ELEMENT_TYPES,\n\tNOTE_ELEMENT_TYPES,\n\tBOS_ELEMENT,\n\tfractionToElems,\n\texpandMatrixByMasks,\n\texpandMatrixByMaskTriu,\n\tmatrixFromGroups,\n};\n","import { MusicNotation } from '@k-l-lambda/music-widgets';\n\n// implicit note (from expressive marks) types\nenum ImplicitType {\n\tNone = 0,\n\n\tMordent = 'mordent',\n\tPrall = 'prall',\n\tTurn = 'turn',\n\tTrill = 'trill',\n\tTremolo = 'tremolo',\n\tArpeggio = 'arpeggio',\n}\n\ninterface ChordPosition {\n\tindex: number;\n\tcount: number;\n}\n\nclass TokenPosition {\n\tsystem?: number;\n\tmeasure?: number;\n\tx: number;\n\tendX?: number;\n}\n\ninterface Note extends MusicNotation.Note {\n\tchordPosition?: ChordPosition;\n\tmeasure?: number;\n}\n\ninterface Notation {\n\tnotes: Note[];\n\tendTick: number;\n}\n\ninterface SheetPosition {\n\tsystem: number;\n\tx: number;\n}\n\nexport { ChordPosition, ImplicitType, TokenPosition, Note, Notation, SheetPosition };\n","/*\nclass to parse the .mid file format\n(depends on stream.js)\n*/\n\nconst Stream = require(\"./stream.js\");\n\n\n\nmodule.exports = function MidiFile (data) {\n\tfunction readChunk (stream) {\n\t\tconst id = stream.readString(4);\n\t\tconst length = stream.readInt32();\n\n\t\treturn {\n\t\t\tid,\n\t\t\tlength,\n\t\t\tdata: stream.read(length),\n\t\t};\n\t}\n\n\tlet lastEventTypeByte;\n\n\tfunction readEvent (stream) {\n\t\tconst event = {};\n\t\tevent.deltaTime = stream.readVarInt();\n\t\tlet eventTypeByte = stream.readInt8();\n\t\tif ((eventTypeByte & 0xf0) === 0xf0) {\n\t\t\t// system / meta event\n\t\t\tif (eventTypeByte === 0xff) {\n\t\t\t\t// meta event\n\t\t\t\tevent.type = \"meta\";\n\t\t\t\tconst subtypeByte = stream.readInt8();\n\t\t\t\tconst length = stream.readVarInt();\n\n\t\t\t\tswitch (subtypeByte) {\n\t\t\t\tcase 0x00:\n\t\t\t\t\tevent.subtype = \"sequenceNumber\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for sequenceNumber event is 2, got \" + length);\n\t\t\t\t\tevent.number = stream.readInt16();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x01:\n\t\t\t\t\tevent.subtype = \"text\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x02:\n\t\t\t\t\tevent.subtype = \"copyrightNotice\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x03:\n\t\t\t\t\tevent.subtype = \"trackName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x04:\n\t\t\t\t\tevent.subtype = \"instrumentName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x05:\n\t\t\t\t\tevent.subtype = \"lyrics\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x06:\n\t\t\t\t\tevent.subtype = \"marker\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x07:\n\t\t\t\t\tevent.subtype = \"cuePoint\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x20:\n\t\t\t\t\tevent.subtype = \"midiChannelPrefix\";\n\t\t\t\t\tif (length !== 1)\n\t\t\t\t\t\tthrow new Error(\"Expected length for midiChannelPrefix event is 1, got \" + length);\n\t\t\t\t\tevent.channel = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x2f:\n\t\t\t\t\tevent.subtype = \"endOfTrack\";\n\t\t\t\t\tif (length !== 0)\n\t\t\t\t\t\tthrow new Error(\"Expected length for endOfTrack event is 0, got \" + length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x51:\n\t\t\t\t\tevent.subtype = \"setTempo\";\n\t\t\t\t\tif (length !== 3)\n\t\t\t\t\t\tthrow new Error(\"Expected length for setTempo event is 3, got \" + length);\n\t\t\t\t\tevent.microsecondsPerBeat = (\n\t\t\t\t\t\t(stream.readInt8() << 16) +\n\t\t\t\t\t\t\t(stream.readInt8() << 8) +\n\t\t\t\t\t\t\tstream.readInt8()\n\t\t\t\t\t);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x54:\n\t\t\t\t\tevent.subtype = \"smpteOffset\";\n\t\t\t\t\tif (length !== 5)\n\t\t\t\t\t\tthrow new Error(\"Expected length for smpteOffset event is 5, got \" + length);\n\t\t\t\t\tconst hourByte = stream.readInt8();\n\t\t\t\t\tevent.frameRate = {\n\t\t\t\t\t\t0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30,\n\t\t\t\t\t}[hourByte & 0x60];\n\t\t\t\t\tevent.hour = hourByte & 0x1f;\n\t\t\t\t\tevent.min = stream.readInt8();\n\t\t\t\t\tevent.sec = stream.readInt8();\n\t\t\t\t\tevent.frame = stream.readInt8();\n\t\t\t\t\tevent.subframe = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x58:\n\t\t\t\t\tevent.subtype = \"timeSignature\";\n\t\t\t\t\tif (length !== 4)\n\t\t\t\t\t\tthrow new Error(\"Expected length for timeSignature event is 4, got \" + length);\n\t\t\t\t\tevent.numerator = stream.readInt8();\n\t\t\t\t\tevent.denominator = Math.pow(2, stream.readInt8());\n\t\t\t\t\tevent.metronome = stream.readInt8();\n\t\t\t\t\tevent.thirtyseconds = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x59:\n\t\t\t\t\tevent.subtype = \"keySignature\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for keySignature event is 2, got \" + length);\n\t\t\t\t\tevent.key = stream.readInt8(true);\n\t\t\t\t\tevent.scale = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x7f:\n\t\t\t\t\tevent.subtype = \"sequencerSpecific\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tdefault:\n\t\t\t\t\t// console.log(\"Unrecognised meta event subtype: \" + subtypeByte);\n\t\t\t\t\tevent.subtype = \"unknown\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\t}\n\n\t\t\t\t//event.data = stream.readString(length);\n\t\t\t\t//return event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf0) {\n\t\t\t\tevent.type = \"sysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf7) {\n\t\t\t\tevent.type = \"dividedSysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type byte: \" + eventTypeByte);\n\t\t}\n\t\telse {\n\t\t\t/* channel event */\n\t\t\tlet param1;\n\t\t\tif ((eventTypeByte & 0x80) === 0) {\n\t\t\t\t/* running status - reuse lastEventTypeByte as the event type.\n\t\t\t\t\teventTypeByte is actually the first parameter\n\t\t\t\t*/\n\t\t\t\tparam1 = eventTypeByte;\n\t\t\t\teventTypeByte = lastEventTypeByte;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tparam1 = stream.readInt8();\n\t\t\t\tlastEventTypeByte = eventTypeByte;\n\t\t\t}\n\n\t\t\tconst eventType = eventTypeByte >> 4;\n\t\t\tevent.channel = eventTypeByte & 0x0f;\n\t\t\tevent.type = \"channel\";\n\n\t\t\tswitch (eventType) {\n\t\t\tcase 0x08:\n\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x09:\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\t\t\t\tif (event.velocity === 0)\n\t\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\telse\n\t\t\t\t\tevent.subtype = \"noteOn\";\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0a:\n\t\t\t\tevent.subtype = \"noteAftertouch\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.amount = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0b:\n\t\t\t\tevent.subtype = \"controller\";\n\t\t\t\tevent.controllerType = param1;\n\t\t\t\tevent.value = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0c:\n\t\t\t\tevent.subtype = \"programChange\";\n\t\t\t\tevent.programNumber = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0d:\n\t\t\t\tevent.subtype = \"channelAftertouch\";\n\t\t\t\tevent.amount = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0e:\n\t\t\t\tevent.subtype = \"pitchBend\";\n\t\t\t\tevent.value = param1 + (stream.readInt8() << 7);\n\n\t\t\t\treturn event;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type: \" + eventType);\n\n\t\t\t\t/*\n\t\t\t\tconsole.log(\"Unrecognised MIDI event type: \" + eventType);\n\t\t\t\tstream.readInt8();\n\t\t\t\tevent.subtype = 'unknown';\n\t\t\t\treturn event;\n\t\t\t\t*/\n\t\t\t}\n\t\t}\n\t}\n\n\n\tlet source = data;\n\tif (typeof data === \"string\")\n\t\tsource = data.split(\"\").map(c => c.charCodeAt(0));\n\n\tconst stream = new Stream(source);\n\tconst headerChunk = readChunk(stream);\n\tif (headerChunk.id !== \"MThd\" || headerChunk.length !== 6)\n\t\tthrow new Error(\"Bad .mid file - header not found\");\n\n\tconst headerStream = new Stream(headerChunk.data);\n\tconst formatType = headerStream.readInt16();\n\tconst trackCount = headerStream.readInt16();\n\tconst timeDivision = headerStream.readInt16();\n\n\tlet ticksPerBeat;\n\tif (timeDivision & 0x8000)\n\t\tthrow new Error(\"Expressing time division in SMTPE frames is not supported yet\");\n\telse\n\t\tticksPerBeat = timeDivision;\n\n\n\tconst header = {\n\t\tformatType,\n\t\ttrackCount,\n\t\tticksPerBeat,\n\t};\n\tconst tracks = [];\n\tfor (let i = 0; i < header.trackCount; i++) {\n\t\ttracks[i] = [];\n\t\tconst trackChunk = readChunk(stream);\n\t\tif (trackChunk.id !== \"MTrk\")\n\t\t\tthrow new Error(\"Unexpected chunk - expected MTrk, got \" + trackChunk.id);\n\n\t\tconst trackStream = new Stream(trackChunk.data);\n\t\twhile (!trackStream.eof()) {\n\t\t\tconst event = readEvent(trackStream);\n\t\t\ttracks[i].push(event);\n\t\t}\n\t}\n\n\treturn {\n\t\theader,\n\t\ttracks,\n\t};\n};\n","\n/* Wrapper for accessing buffer through sequential reads */\n\n\n\nmodule.exports = class Stream {\n\tconstructor (buffer) {\n\t\tthis.array = new Uint8Array(buffer);\n\t\tthis.position = 0;\n\t}\n\n\n\teof () {\n\t\treturn this.position >= this.array.length;\n\t}\n\n\n\tread (length) {\n\t\tconst result = this.array.slice(this.position, this.position + length);\n\t\tthis.position += length;\n\n\t\treturn result;\n\t}\n\n\n\treadString (length) {\n\t\tconst data = Array.from(this.read(length));\n\n\t\treturn data.map(c => String.fromCharCode(c)).join(\"\");\n\t}\n\n\n\t// read a big-endian 32-bit integer\n\treadInt32 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 24) +\n\t\t\t(this.array[this.position + 1] << 16) +\n\t\t\t(this.array[this.position + 2] << 8) +\n\t\t\tthis.array[this.position + 3]);\n\t\tthis.position += 4;\n\n\t\treturn result;\n\t}\n\n\n\t// read a big-endian 16-bit integer\n\treadInt16 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 8) +\n\t\t\tthis.array[this.position + 1]);\n\t\tthis.position += 2;\n\n\t\treturn result;\n\t}\n\n\n\t// read an 8-bit integer\n\treadInt8 (signed) {\n\t\tlet result = this.array[this.position];\n\t\tif (signed && result > 127)\n\t\t\tresult -= 256;\n\t\tthis.position += 1;\n\n\t\treturn result;\n\t}\n\n\n\t/* read a MIDI-style variable-length integer\n\t\t(big-endian value in groups of 7 bits,\n\t\twith top bit set to signify that another byte follows)\n\t*/\n\treadVarInt () {\n\t\tlet result = 0;\n\t\twhile (true) {\n\t\t\tconst b = this.readInt8();\n\t\t\tif (b & 0x80) {\n\t\t\t\tresult += (b & 0x7f);\n\t\t\t\tresult <<= 7;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// b is the last byte\n\t\t\t\treturn result + b;\n\t\t\t}\n\t\t}\n\t}\n};\n","/*\r\nclass to encode the .mid file format\r\n(depends on streamEx.js)\r\n*/\r\n\r\nconst OStream = require(\"./streamEx.js\");\r\n\r\n\r\n\r\nmodule.exports = function OMidiFile ({ header, tracks }) {\r\n\tfunction writeChunk (stream, id, data) {\r\n\t\tconsole.assert(id.length === 4, \"chunk id must be 4 byte\");\r\n\r\n\t\tstream.write(id);\r\n\t\tstream.writeInt32(data.length);\r\n\t\tstream.write(data);\r\n\t}\r\n\r\n\tfunction writeEvent (stream, event) {\r\n\t\tif (event.subtype === \"unknown\")\r\n\t\t\treturn;\r\n\r\n\t\tstream.writeVarInt(event.deltaTime);\r\n\r\n\t\tswitch (event.type) {\r\n\t\tcase \"meta\":\r\n\t\t\tstream.writeInt8(0xff);\r\n\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"sequenceNumber\":\r\n\t\t\t\tstream.writeInt8(0x00);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt16(event.number);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"text\":\r\n\t\t\t\tstream.writeInt8(0x01);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"copyrightNotice\":\r\n\t\t\t\tstream.writeInt8(0x02);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"trackName\":\r\n\t\t\t\tstream.writeInt8(0x03);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"instrumentName\":\r\n\t\t\t\tstream.writeInt8(0x04);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"lyrics\":\r\n\t\t\t\tstream.writeInt8(0x05);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"marker\":\r\n\t\t\t\tstream.writeInt8(0x06);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"cuePoint\":\r\n\t\t\t\tstream.writeInt8(0x07);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"midiChannelPrefix\":\r\n\t\t\t\tstream.writeInt8(0x20);\r\n\t\t\t\tstream.writeVarInt(1);\r\n\r\n\t\t\t\tstream.writeInt8(event.channel);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"endOfTrack\":\r\n\t\t\t\tstream.writeInt8(0x2f);\r\n\t\t\t\tstream.writeVarInt(0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"setTempo\":\r\n\t\t\t\tstream.writeInt8(0x51);\r\n\t\t\t\tstream.writeVarInt(3);\r\n\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 16) & 0xff);\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 8) & 0xff);\r\n\t\t\t\tstream.writeInt8(event.microsecondsPerBeat & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"smpteOffset\":\r\n\t\t\t\tstream.writeInt8(0x54);\r\n\t\t\t\tstream.writeVarInt(5);\r\n\r\n\t\t\t\tvar frameByte = { 24: 0x00, 25: 0x20, 29: 0x40, 30: 0x60 }[event.frameRate];\r\n\t\t\t\tstream.writeInt8(event.hour | frameByte);\r\n\t\t\t\tstream.writeInt8(event.min);\r\n\t\t\t\tstream.writeInt8(event.sec);\r\n\t\t\t\tstream.writeInt8(event.frame);\r\n\t\t\t\tstream.writeInt8(event.subframe);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"timeSignature\":\r\n\t\t\t\tstream.writeInt8(0x58);\r\n\t\t\t\tstream.writeVarInt(4);\r\n\r\n\t\t\t\tstream.writeInt8(event.numerator);\r\n\t\t\t\tstream.writeInt8(Math.log2(event.denominator));\r\n\t\t\t\tstream.writeInt8(event.metronome);\r\n\t\t\t\tstream.writeInt8(event.thirtyseconds);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"keySignature\":\r\n\t\t\t\tstream.writeInt8(0x59);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt8(event.key);\r\n\t\t\t\tstream.writeInt8(event.scale);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"sequencerSpecific\":\r\n\t\t\t\tstream.writeInt8(0x7f);\r\n\t\t\t\tstream.writeVarInt(event.data.length);\r\n\r\n\t\t\t\tstream.write(event.data);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"sysEx\":\r\n\t\t\tstream.writeInt8(0xf0);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"dividedSysEx\":\r\n\t\t\tstream.writeInt8(0xf7);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"channel\":\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"noteOn\":\r\n\t\t\t\tstream.writeInt8(0x90 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteOff\":\r\n\t\t\t\tstream.writeInt8(0x80 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity ? event.velocity : 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xa0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"controller\":\r\n\t\t\t\tstream.writeInt8(0xb0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.controllerType);\r\n\t\t\t\tstream.writeInt8(event.value);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"programChange\":\r\n\t\t\t\tstream.writeInt8(0xc0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.programNumber);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"channelAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xd0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"pitchBend\":\r\n\t\t\t\tstream.writeInt8(0xe0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.value & 0xff);\r\n\t\t\t\tstream.writeInt8((event.value >> 7) & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tthrow new Error(\"unhandled event type:\" + event.type);\r\n\t\t}\r\n\t}\r\n\r\n\tconst stream = new OStream();\r\n\r\n\tconst headerChunk = new OStream();\r\n\theaderChunk.writeInt16(header.formatType);\r\n\theaderChunk.writeInt16(tracks.length);\r\n\theaderChunk.writeInt16(header.ticksPerBeat);\r\n\r\n\twriteChunk(stream, \"MThd\", headerChunk.getBuffer());\r\n\r\n\tfor (let i = 0; i < tracks.length; ++i) {\r\n\t\tconst trackChunk = new OStream();\r\n\r\n\t\tfor (let ei = 0; ei < tracks[i].length; ++ei)\r\n\t\t\twriteEvent(trackChunk, tracks[i][ei]);\r\n\r\n\t\twriteChunk(stream, \"MTrk\", trackChunk.getBuffer());\r\n\t}\r\n\r\n\treturn stream.getArrayBuffer();\r\n};\r\n","\r\n/* Wrapper for accessing strings through sequential writes */\r\n\r\n\r\n\r\nmodule.exports = class OStream {\r\n\tconstructor () {\r\n\t\tthis.buffer = \"\";\r\n\t}\r\n\r\n\twrite (str) {\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\t/* write a big-endian 32-bit integer */\r\n\twriteInt32 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 24) & 0xff) + String.fromCharCode((i >> 16) & 0xff) +\r\n\t\t\tString.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a big-endian 16-bit integer */\r\n\twriteInt16 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write an 8-bit integer */\r\n\twriteInt8 (i) {\r\n\t\tthis.buffer += String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a MIDI-style variable-length integer\r\n\t\t(big-endian value in groups of 7 bits,\r\n\t\twith top bit set to signify that another byte follows)\r\n\t*/\r\n\twriteVarInt (i) {\r\n\t\tif (i < 0)\r\n\t\t\tthrow new Error(\"OStream.writeVarInt minus number: \" + i);\r\n\r\n\t\tconst b = i & 0x7f;\r\n\t\ti >>= 7;\r\n\t\tlet str = String.fromCharCode(b);\r\n\r\n\t\twhile (i) {\r\n\t\t\tconst b = i & 0x7f;\r\n\t\t\ti >>= 7;\r\n\t\t\tstr = String.fromCharCode(b | 0x80) + str;\r\n\t\t}\r\n\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\tgetBuffer () {\r\n\t\treturn this.buffer;\r\n\t}\r\n\r\n\tgetArrayBuffer () {\r\n\t\treturn Uint8Array.from(this.buffer.split(\"\").map(c => c.charCodeAt(0))).buffer;\r\n\t}\r\n};\r\n","\nmodule.exports = {\n\tparseMidiData: require(\"./midifile.js\"),\n\tencodeMidiFile: require(\"./midifileEx.js\"),\n};\n","\nconst midiToSequence = (midiFile, {timeWarp = 1} = {}) => {\n\tconst trackStates = [];\n\tlet beatsPerMinute = 120;\n\tconst ticksPerBeat = midiFile.header.ticksPerBeat;\n\n\tfor (let i = 0; i < midiFile.tracks.length; i++) {\n\t\ttrackStates[i] = {\n\t\t\tnextEventIndex: 0,\n\t\t\tticksToNextEvent: (\n\t\t\t\tmidiFile.tracks[i].length ?\n\t\t\t\t\tmidiFile.tracks[i][0].deltaTime :\n\t\t\t\t\tnull\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction getNextEvent () {\n\t\tlet ticksToNextEvent = null;\n\t\tlet nextEventTrack = null;\n\t\tlet nextEventIndex = null;\n\n\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\tif (\n\t\t\t\ttrackStates[i].ticksToNextEvent != null\n\t\t\t\t&& (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent)\n\t\t\t) {\n\t\t\t\tticksToNextEvent = trackStates[i].ticksToNextEvent;\n\t\t\t\tnextEventTrack = i;\n\t\t\t\tnextEventIndex = trackStates[i].nextEventIndex;\n\t\t\t}\n\t\t}\n\t\tif (nextEventTrack != null) {\n\t\t\t/* consume event from that track */\n\t\t\tconst nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex];\n\t\t\tif (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime;\n\t\t\telse \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent = null;\n\n\t\t\ttrackStates[nextEventTrack].nextEventIndex += 1;\n\t\t\t/* advance timings on all tracks by ticksToNextEvent */\n\t\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\t\tif (trackStates[i].ticksToNextEvent != null) \n\t\t\t\t\ttrackStates[i].ticksToNextEvent -= ticksToNextEvent;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tticksToEvent: ticksToNextEvent,\n\t\t\t\tevent: nextEvent,\n\t\t\t\ttrack: nextEventTrack,\n\t\t\t};\n\t\t}\n\t\telse \n\t\t\treturn null;\n\t\t\n\t};\n\t//\n\tlet midiEvent;\n\tconst events = [];\n\t//\n\tfunction processEvents () {\n\t\tfunction processNext () {\n\t\t\tlet secondsToGenerate = 0;\n\t\t\tif (midiEvent.ticksToEvent > 0) {\n\t\t\t\tconst beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;\n\t\t\t\tsecondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);\n\t\t\t}\n\n\t\t\t// beatsPerMinute must be changed after secondsToGenerate calculation\n\t\t\tif ( midiEvent.event.type == \"meta\" && midiEvent.event.subtype == \"setTempo\" ) {\n\t\t\t\t// tempo change events can occur anywhere in the middle and affect events that follow\n\t\t\t\tbeatsPerMinute = 60e+6 / midiEvent.event.microsecondsPerBeat;\n\t\t\t}\n\n\t\t\tconst time = (secondsToGenerate * 1000 * timeWarp) || 0;\n\t\t\tevents.push([ midiEvent, time ]);\n\t\t\tmidiEvent = getNextEvent();\n\t\t};\n\t\t//\n\t\tif (midiEvent = getNextEvent()) {\n\t\t\twhile (midiEvent)\n\t\t\t\tprocessNext();\n\t\t}\n\t};\n\n\tprocessEvents();\n\n\treturn events;\n};\n\n\nconst trimSequence = seq => {\n\tconst status = new Map();\n\n\treturn seq.filter(([{event, ticksToEvent}]) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tstatus.clear();\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn true;\n\n\t\tconst key = `${event.subtype}|${event.channel}|${event.noteNumber}`;\n\n\t\tif (status.get(key)) {\n\t\t\t//console.debug(\"event trimmed:\", event, ticksToEvent);\n\t\t\treturn false;\n\t\t}\n\n\t\tstatus.set(key, event);\n\n\t\treturn true;\n\t});\n};\n\n\nconst fixOverlapNotes = seq => {\n\tconst noteMap = new Map();\n\tconst overlapMap = new Map();\n\tconst swaps = [];\n\n\tlet leapIndex = -1;\n\n\tseq.forEach(([{event, ticksToEvent}], index) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tleapIndex = index;\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn;\n\n\t\tconst key = `${event.channel}|${event.noteNumber}`;\n\n\t\tswitch (event.subtype) {\n\t\tcase \"noteOn\":\n\t\t\tif (noteMap.get(key))\n\t\t\t\toverlapMap.set(key, leapIndex);\n\t\t\telse\n\t\t\t\tnoteMap.set(key, leapIndex);\n\n\t\t\tbreak;\n\t\tcase \"noteOff\":\n\t\t\tif (overlapMap.get(key)) {\n\t\t\t\tswaps.push([overlapMap.get(key), index]);\n\t\t\t\toverlapMap.delete(key);\n\t\t\t}\n\t\t\telse\n\t\t\t\tnoteMap.delete(key);\n\n\t\t\tbreak;\n\t\t}\n\t});\n\n\t// shift overlapped swaps\n\tswaps.forEach((swap, i) => {\n\t\tfor (let ii = i - 1; ii >= 0; --ii) {\n\t\t\tconst pre = swaps[ii];\n\t\t\tif (pre[1] < swap[0])\n\t\t\t\tbreak;\n\n\t\t\tif (swap[0] > pre[0])\n\t\t\t\t++swap[0];\n\t\t}\n\t});\n\n\t//console.debug(\"swaps:\", swaps);\n\tswaps.forEach(([front, back]) => {\n\t\tif (back >= seq.length - 1 || front < 0)\n\t\t\treturn;\n\n\t\tconst offEvent = seq[back];\n\t\tconst nextEvent = seq[back + 1];\n\t\tconst leapEvent = seq[front];\n\n\t\tif (!leapEvent[0].ticksToEvent) {\n\t\t\tconsole.warn(\"invalid front index:\", front, back, leapEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t// ms per tick\n\t\tconst tempo = leapEvent[1] / leapEvent[0].ticksToEvent;\n\n\t\tnextEvent[1] += offEvent[1];\n\t\tnextEvent[0].ticksToEvent += offEvent[0].ticksToEvent;\n\n\t\toffEvent[0].ticksToEvent = leapEvent[0].ticksToEvent - 1;\n\t\tleapEvent[0].ticksToEvent = 1;\n\n\t\toffEvent[1] = offEvent[0].ticksToEvent * tempo;\n\t\tleapEvent[1] = leapEvent[0].ticksToEvent * tempo;\n\t\t//console.debug(\"swap:\", [front, back], offEvent, nextEvent, leapEvent);\n\n\t\tseq.splice(back, 1);\n\t\tseq.splice(front, 0, offEvent);\n\t});\n\n\treturn seq;\n};\n\n\n\nmodule.exports = {\n\tmidiToSequence,\n\ttrimSequence,\n\tfixOverlapNotes,\n};\n","\nconst MidiSequence = require(\"./MidiSequence.js\");\n\n\n\nconst PedalControllerTypes = {\n\t64: \"Sustain\",\n\t65: \"Portamento\",\n\t66: \"Sostenuto\",\n\t67: \"Soft\",\n};\n\n\n\nclass Notation {\n\tstatic parseMidi (data, {fixOverlap = true} = {}) {\n\t\tconst channelStatus = [];\n\t\tconst pedalStatus = {};\n\t\tconst pedals = {};\n\t\tconst channels = [];\n\t\tconst bars = [];\n\t\tlet time = 0;\n\t\tlet millisecondsPerBeat = 600000 / 120;\n\t\tlet beats = 0;\n\t\tlet numerator = 4;\n\t\tlet barIndex = 0;\n\t\tconst keyRange = {};\n\t\tlet rawTicks = 0;\n\t\tlet ticks = 0;\n\t\tlet correspondences;\n\t\tconst tempos = [];\n\n\t\tconst ticksPerBeat = data.header.ticksPerBeat;\n\n\t\tlet rawEvents = MidiSequence.midiToSequence(data);\n\n\t\tif (fixOverlap)\n\t\t\trawEvents = MidiSequence.trimSequence(MidiSequence.fixOverlapNotes(rawEvents));\n\n\t\tconst events = rawEvents.map(d => ({\n\t\t\tdata: d[0].event,\n\t\t\ttrack: d[0].track,\n\t\t\tdeltaTime: d[1],\n\t\t\tdeltaTicks: d[0].ticksToEvent,\n\t\t}));\n\n\t\tlet index = 0;\n\n\t\tconst ticksNormal = 1;\n\n\t\tfor (const ev of events) {\n\t\t\trawTicks += ev.deltaTicks;\n\t\t\tticks = Math.round(rawTicks * ticksNormal);\n\n\t\t\tif (ev.deltaTicks > 0) {\n\t\t\t\t// append bars\n\t\t\t\tconst deltaBeats = ev.deltaTicks / ticksPerBeat;\n\t\t\t\tfor (let b = Math.ceil(beats); b < beats + deltaBeats; ++b) {\n\t\t\t\t\tconst t = time + (b - beats) * millisecondsPerBeat;\n\t\t\t\t\tbars.push({time: t, index: barIndex % numerator});\n\n\t\t\t\t\t++barIndex;\n\t\t\t\t}\n\n\t\t\t\tbeats += deltaBeats;\n\t\t\t}\n\n\t\t\ttime += ev.deltaTime;\n\n\t\t\t//const ticksTime = beats * millisecondsPerBeat;\n\t\t\t//console.log(\"time:\", time, ticksTime, ticksTime - time);\n\n\t\t\tev.time = time;\n\t\t\tev.ticks = ticks;\n\n\t\t\tconst event = ev.data;\n\t\t\tswitch (event.type) {\n\t\t\tcase \"channel\":\n\t\t\t\t//channelStatus[event.channel] = channelStatus[event.channel] || [];\n\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"noteOn\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\t\t\t\t\t\t//channelStatus[event.channel][pitch] = {\n\t\t\t\t\t\tchannelStatus.push({\n\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\tstartTick: ticks,\n\t\t\t\t\t\t\tstart: time,\n\t\t\t\t\t\t\tvelocity: event.velocity,\n\t\t\t\t\t\t\tbeats: beats,\n\t\t\t\t\t\t\ttrack: ev.track,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tkeyRange.low = Math.min(keyRange.low || pitch, pitch);\n\n\t\t\t\t\t\tev.index = index;\n\t\t\t\t\t\t++index;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"noteOff\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\n\t\t\t\t\t\tchannels[event.channel] = channels[event.channel] || [];\n\n\t\t\t\t\t\tconst statusIndex = channelStatus.findIndex(status => status.channel == event.channel && status.pitch == pitch);\n\t\t\t\t\t\tif (statusIndex >= 0) {\n\t\t\t\t\t\t\tconst status = channelStatus.splice(statusIndex, 1)[0];\n\n\t\t\t\t\t\t\tchannels[event.channel].push({\n\t\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\t\tstartTick: status.startTick,\n\t\t\t\t\t\t\t\tendTick: ticks,\n\t\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\t\tstart: status.start,\n\t\t\t\t\t\t\t\tduration: time - status.start,\n\t\t\t\t\t\t\t\tvelocity: status.velocity,\n\t\t\t\t\t\t\t\tbeats: status.beats,\n\t\t\t\t\t\t\t\ttrack: status.track,\n\t\t\t\t\t\t\t\tfinger: status.finger,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tconsole.debug(\"unexpected noteOff: \", time, event);\n\n\t\t\t\t\t\tkeyRange.high = Math.max(keyRange.high || pitch, pitch);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"controller\":\n\t\t\t\t\tswitch (event.controllerType) {\n\t\t\t\t\t// pedal controllers\n\t\t\t\t\tcase 64:\n\t\t\t\t\tcase 65:\n\t\t\t\t\tcase 66:\n\t\t\t\t\tcase 67:\n\t\t\t\t\t\tconst pedalType = PedalControllerTypes[event.controllerType];\n\n\t\t\t\t\t\tpedalStatus[event.channel] = pedalStatus[event.channel] || {};\n\t\t\t\t\t\tpedals[event.channel] = pedals[event.channel] || [];\n\n\t\t\t\t\t\tconst status = pedalStatus[event.channel][pedalType];\n\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tpedals[event.channel].push({type: pedalType, start: status.start, duration: time - status.start, value: status.value});\n\t\t\t\t\t\tpedalStatus[event.channel][pedalType] = {start: time, value: event.value};\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase \"meta\":\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"setTempo\":\n\t\t\t\t\tmillisecondsPerBeat = event.microsecondsPerBeat / 1000;\n\t\t\t\t\t//beats = Math.round(beats);\n\t\t\t\t\t//console.assert(Number.isFinite(time), \"invalid time:\", time);\n\t\t\t\t\ttempos.push({tempo: event.microsecondsPerBeat, tick: ticks, time});\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"timeSignature\":\n\t\t\t\t\tnumerator = event.numerator;\n\t\t\t\t\tbarIndex = 0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text\":\n\t\t\t\t\tif (!correspondences && /^find-corres:/.test(event.text)) {\n\t\t\t\t\t\tconst captures = event.text.match(/:([\\d\\,-]+)/);\n\t\t\t\t\t\tconst str = captures && captures[1] || \"\";\n\t\t\t\t\t\tcorrespondences = str.split(\",\").map(s => Number(s));\n\t\t\t\t\t}\n\t\t\t\t\telse if (/fingering\\(.*\\)/.test(event.text)) {\n\t\t\t\t\t\tconst [_, fingers] = event.text.match(/\\((.+)\\)/);\n\t\t\t\t\t\tconst finger = Number(fingers);\n\t\t\t\t\t\tif (!Number.isNaN(finger)) {\n\t\t\t\t\t\t\tconst status = channelStatus[channelStatus.length - 1];\n\t\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\t\tstatus.finger = finger;\n\n\t\t\t\t\t\t\tconst event = events.find(e => e.index == index - 1);\n\t\t\t\t\t\t\tif (event)\n\t\t\t\t\t\t\t\tevent.data.finger = finger;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"copyrightNotice\":\n\t\t\t\t\tconsole.log(\"MIDI copyright:\", event.text);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tchannelStatus.forEach(status => {\n\t\t\tconsole.debug(\"unclosed noteOn event at\", status.startTick, status);\n\n\t\t\tchannels[status.channel].push({\n\t\t\t\tstartTick: status.startTick,\n\t\t\t\tendTick: ticks,\n\t\t\t\tpitch: status.pitch,\n\t\t\t\tstart: status.start,\n\t\t\t\tduration: time - status.start,\n\t\t\t\tvelocity: status.velocity,\n\t\t\t\tbeats: status.beats,\n\t\t\t\ttrack: status.track,\n\t\t\t\tfinger: status.finger,\n\t\t\t});\n\t\t});\n\n\t\treturn new Notation({\n\t\t\tchannels,\n\t\t\tkeyRange,\n\t\t\tpedals,\n\t\t\tbars,\n\t\t\tendTime: time,\n\t\t\tendTick: ticks,\n\t\t\tcorrespondences,\n\t\t\tevents,\n\t\t\ttempos,\n\t\t\tticksPerBeat,\n\t\t\tmeta: {},\n\t\t});\n\t}\n\n\n\tconstructor (fields) {\n\t\tObject.assign(this, fields);\n\n\t\t// channels to notes\n\t\tthis.notes = [];\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tfor (const note of channel)\n\t\t\t\t\tthis.notes.push(note);\n\t\t\t}\n\t\t}\n\t\tthis.notes.sort(function (n1, n2) {\n\t\t\treturn n1.start - n2.start;\n\t\t});\n\n\t\tfor (const i in this.notes)\n\t\t\tthis.notes[i].index = Number(i);\n\n\n\t\t// duration\n\t\tthis.duration = this.notes.length > 0 ? (this.endTime - this.notes[0].start) : 0,\n\n\t\t//this.endSoftIndex = this.notes.length ? this.notes[this.notes.length - 1].softIndex : 0;\n\n\n\t\t// pitch map\n\t\tthis.pitchMap = [];\n\t\tfor (const c in this.channels) {\n\t\t\tfor (const n in this.channels[c]) {\n\t\t\t\tconst pitch = this.channels[c][n].pitch;\n\t\t\t\tthis.pitchMap[pitch] = this.pitchMap[pitch] || [];\n\n\t\t\t\tthis.pitchMap[pitch].push(this.channels[c][n]);\n\t\t\t}\n\t\t}\n\n\t\tthis.pitchMap.forEach(notes => notes.sort((n1, n2) => n1.start - n2.start));\n\n\n\t\t/*// setup measure notes index\n\t\tif (this.measures) {\n\t\t\tconst measure_list = [];\n\n\t\t\tlet last_measure = null;\n\t\t\tconst measure_entries = Object.entries(this.measures).sort((e1, e2) => Number(e1[0]) - Number(e2[0]));\n\t\t\tfor (const [t, measure] of measure_entries) {\n\t\t\t\t//console.log(\"measure time:\", Number(t));\n\t\t\t\tmeasure.startTick = Number(t);\n\t\t\t\tmeasure.notes = [];\n\n\t\t\t\tif (last_measure)\n\t\t\t\t\tlast_measure.endTick = measure.startTick;\n\n\t\t\t\tconst m = measure.measure;\n\t\t\t\tmeasure_list[m] = measure_list[m] || [];\n\t\t\t\tmeasure_list[m].push(measure);\n\n\t\t\t\tlast_measure = measure;\n\t\t\t}\n\t\t\tif (last_measure)\n\t\t\t\tlast_measure.endTick = this.notes[this.notes.length - 1].endTick;\n\t\t\tfor (const i in this.notes) {\n\t\t\t\tconst note = this.notes[i];\n\t\t\t\tfor (const t in this.measures) {\n\t\t\t\t\tconst measure = this.measures[t];\n\t\t\t\t\tif (note.startTick >= measure.startTick && note.startTick < measure.endTick || note.endTick > measure.startTick && note.endTick <= measure.endTick)\n\t\t\t\t\t\tmeasure.notes.push(note);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.measure_list = measure_list;\n\t\t}*/\n\n\n\t\t// prepare beats info\n\t\tif (this.meta.beatInfos) {\n\t\t\tfor (let i = 0; i < this.meta.beatInfos.length; ++i) {\n\t\t\t\tconst info = this.meta.beatInfos[i];\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tconst lastInfo = this.meta.beatInfos[i - 1];\n\t\t\t\t\tinfo.beatIndex = lastInfo.beatIndex + Math.ceil((info.tick - lastInfo.tick) / this.ticksPerBeat);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tinfo.beatIndex = 0;\n\t\t\t}\n\t\t}\n\n\n\t\t// compute tempos tick -> time\n\t\t{\n\t\t\tlet time = 0;\n\t\t\tlet ticks = 0;\n\t\t\tlet tempo = 500000;\n\t\t\tfor (const entry of this.tempos) {\n\t\t\t\tconst deltaTicks = entry.tick - ticks;\n\t\t\t\ttime += (tempo / 1000) * deltaTicks / this.ticksPerBeat;\n\n\t\t\t\tticks = entry.tick;\n\t\t\t\ttempo = entry.tempo;\n\n\t\t\t\tentry.time = time;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfindChordBySoftindex (softIndex, radius = 0.8) {\n\t\treturn this.notes.filter(note => Math.abs(note.softIndex - softIndex) < radius);\n\t}\n\n\n\taverageTempo (tickRange) {\n\t\ttickRange = tickRange || {from: 0, to: this.endtick};\n\n\t\tconsole.assert(this.tempos, \"no tempos.\");\n\t\tconsole.assert(tickRange.to > tickRange.from, \"range is invalid:\", tickRange);\n\n\t\tconst span = index => {\n\t\t\tconst from = Math.max(tickRange.from, this.tempos[index].tick);\n\t\t\tconst to = (index < this.tempos.length - 1) ? Math.min(this.tempos[index + 1].tick, tickRange.to) : tickRange.to;\n\n\t\t\treturn Math.max(0, to - from);\n\t\t};\n\n\t\tconst tempo_sum = this.tempos.reduce((sum, tempo, index) => sum + tempo.tempo * span(index), 0);\n\n\t\tconst average = tempo_sum / (tickRange.to - tickRange.from);\n\n\t\t// convert microseconds per beat to beats per minute\n\t\treturn 60e+6 / average;\n\t}\n\n\n\tticksToTime (tick) {\n\t\tconsole.assert(Number.isFinite(tick), \"invalid tick value:\", tick);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.tick > tick);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.time + (tick - tempo.tick) * tempo.tempo * 1e-3 / this.ticksPerBeat;\n\t}\n\n\n\ttimeToTicks (time) {\n\t\tconsole.assert(Number.isFinite(time), \"invalid time value:\", time);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.time > time);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.tick + (time - tempo.time) * this.ticksPerBeat / (tempo.tempo * 1e-3);\n\t}\n\n\n\ttickRangeToTimeRange (tickRange) {\n\t\tconsole.assert(tickRange.to >= tickRange.from, \"invalid tick range:\", tickRange);\n\n\t\treturn {\n\t\t\tfrom: this.ticksToTime(tickRange.from),\n\t\t\tto: this.ticksToTime(tickRange.to),\n\t\t};\n\t}\n\n\n\t/*getMeasureRange (measureRange) {\n\t\tconsole.assert(Number.isInteger(measureRange.start) && Number.isInteger(measureRange.end), \"invalid measure range:\", measureRange);\n\t\tconsole.assert(this.measure_list && this.measure_list[measureRange.start] && this.measure_list[measureRange.end], \"no measure data for specific index:\", this.measure_list, measureRange);\n\n\t\tconst startMeasure = this.measure_list[measureRange.start][0];\n\t\tlet endMeasure = null;\n\t\tfor (const measure of this.measure_list[measureRange.end]) {\n\t\t\tif (measure.endTick > startMeasure.startTick) {\n\t\t\t\tendMeasure = measure;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// there no path between start measure and end measure.\n\t\tif (!endMeasure)\n\t\t\treturn null;\n\n\t\tconst tickRange = {from: startMeasure.startTick, to: endMeasure.endTick, duration: endMeasure.endTick - startMeasure.startTick};\n\t\tconst timeRange = this.tickRangeToTimeRange(tickRange);\n\t\ttimeRange.duration = timeRange.to - timeRange.from;\n\n\t\treturn {\n\t\t\ttickRange,\n\t\t\ttimeRange,\n\t\t};\n\t}*/\n\n\n\tscaleTempo ({factor, headTempo}) {\n\t\tconsole.assert(this.tempos && this.tempos.length, \"[Notation.scaleTempo] tempos is empty.\");\n\n\t\tif (headTempo)\n\t\t\tfactor = headTempo / this.tempos[0].tempo;\n\n\t\tconsole.assert(Number.isFinite(factor) && factor > 0, \"[Notation.scaleTempo] invalid factor:\", factor);\n\n\t\tthis.tempos.forEach(tempo => {\n\t\t\ttempo.tempo *= factor;\n\t\t\ttempo.time *= factor;\n\t\t});\n\t\tthis.events.forEach(event => {\n\t\t\tevent.deltaTime *= factor;\n\t\t\tevent.time *= factor;\n\t\t});\n\t\tthis.notes.forEach(note => {\n\t\t\tnote.start *= factor;\n\t\t\tnote.duration *= factor;\n\t\t});\n\n\t\tthis.endTime *= factor;\n\t}\n};\n\n\n\nmodule.exports = {\n\tNotation,\n};\n","\nconst { Notation } = require(\"./MusicNotation.js\");\n\n\n\n//const msDelay = ms => new Promise(resolve => setTimeout(resolve, ms));\nconst animationDelay = () => new Promise(resolve => requestAnimationFrame(resolve));\n\n\nclass MidiPlayer {\n\tconstructor (midiData, {cacheSpan = 600, onMidi, onPlayFinish, onTurnCursor} = {}) {\n\t\tthis.cacheSpan = cacheSpan;\n\t\tthis.onMidi = onMidi;\n\t\tthis.onPlayFinish = onPlayFinish;\n\t\tthis.onTurnCursor = onTurnCursor;\n\n\t\tlet notation;\n\t\tif (midiData.notes && Number.isFinite(midiData.endTime))\n\t\t\tnotation = midiData;\n\t\telse\n\t\t\tnotation = Notation.parseMidi(midiData);\n\n\t\tthis.notation = notation;\n\t\tthis.events = notation.events;\n\t\t//console.log(\"events:\", this.events);\n\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t\tthis.startTime = performance.now();\n\t\tthis.duration = notation.endTime;\n\t\tthis.cursorTurnDelta = 0;\n\n\t\tconsole.assert(notation.tempos && notation.tempos.length, \"[MidiPlayer] invalid notation, tempos is empty.\");\n\t}\n\n\n\tdispose () {\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t}\n\n\n\tget progressTicks () {\n\t\treturn this.notation.timeToTicks(this.progressTime);\n\t}\n\n\n\tset progressTicks (value) {\n\t\tthis.progressTime = this.notation.ticksToTime(value);\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(this.progressTime);\n\t}\n\n\n\tasync play ({nextFrame = animationDelay} = {}) {\n\t\tif (this.progressTime >= this.duration)\n\t\t\tthis.progressTime = 0;\n\n\t\tlet now = performance.now();\n\t\tthis.startTime = now - this.progressTime;\n\n\t\tthis.isPlaying = true;\n\n\t\tlet currentEventIndex = this.events.findIndex(event => event.time >= now - this.startTime);\n\n\t\twhile (this.isPlaying) {\n\t\t\tfor (; currentEventIndex < this.events.length; ++currentEventIndex) {\n\t\t\t\tconst event = this.events[currentEventIndex];\n\t\t\t\t//console.log(\"play event:\", currentEventIndex, event.time, this.progressTime + this.cacheSpan);\n\t\t\t\tif (!event || event.time > this.progressTime + this.cacheSpan)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif (event.data.type === \"channel\" && this.startTime + event.time >= now)\n\t\t\t\t\tif (this.onMidi)\n\t\t\t\t\t\tthis.onMidi(event.data, this.startTime + event.time);\n\t\t\t}\n\n\t\t\tawait nextFrame();\n\n\t\t\tif (!this.isPlaying)\n\t\t\t\tbreak;\n\n\t\t\tif (this.cursorTurnDelta !== 0) {\n\t\t\t\tconst backturn = this.cursorTurnDelta < 0;\n\n\t\t\t\tthis.startTime -= this.cursorTurnDelta;\n\t\t\t\tthis.cursorTurnDelta = 0;\n\n\t\t\t\tif (backturn) {\n\t\t\t\t\tfor (; currentEventIndex > 0; --currentEventIndex) {\n\t\t\t\t\t\tconst eventTime = this.events[currentEventIndex].time;\n\t\t\t\t\t\tif (this.startTime + eventTime < now)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnow = performance.now();\n\n\t\t\tthis.progressTime = now - this.startTime;\n\n\t\t\tif (this.progressTime > this.duration) {\n\t\t\t\tthis.isPlaying = false;\n\n\t\t\t\tif (this.onPlayFinish)\n\t\t\t\t\tthis.onPlayFinish();\n\t\t\t}\n\t\t}\n\t}\n\n\n\tpause () {\n\t\tthis.isPlaying = false;\n\t}\n\n\n\tturnCursor (time) {\n\t\t//console.log(\"onTurnCursor:\", time, oldTime);\n\t\tif (this.isPlaying)\n\t\t\tthis.cursorTurnDelta += time - this.progressTime;\n\t\telse\n\t\t\tthis.progressTime = time;\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(time);\n\t}\n};\n\n\n\nmodule.exports = MidiPlayer;\n","\nmodule.exports = {\n\tCostStepAttenuation: 0.6,\n\tSkipDeep: 3,\n\tPriorDistanceSigmoidFactor: 0.1,\n\tPriorValueSigmoidFactor: 0.12,\n\n\tSkipCost: 0.5,\n\tLagOffsetCost: 1,\n\tLeadOffsetCost: 1.6,\n\tZeroOffsetCost: 0.58,\n\n\tRelocationThreshold: 6,\n};\n","\nconst {pick} = require(\"lodash\");\n\nconst Config = require(\"./config.js\");\n\n\n\nclass Node {\n\tconstructor (s_note, c_note) {\n\t\tthis.s_note = s_note;\n\t\tthis.c_note = c_note;\n\n\t\tconsole.assert(this.s_note.softIndex != null, \"s_note softIndex is null\");\n\t\tthis.offset = this.s_note.softIndex - this.c_note.softIndex;\n\n\t\tthis._prev = null;\n\t\tthis._totalCost = 0;\n\t\tthis._value = 0;\n\t\tthis.cacheDirty = true;\n\n\t\t//this.evaluatePrev(Node.Zero);\n\t}\n\n\n\tget prev () {\n\t\treturn this._prev;\n\t}\n\n\n\tset prev (value) {\n\t\tif (value != this._prev) {\n\t\t\tthis._prev = value;\n\t\t\tthis.cacheDirty = true;\n\t\t}\n\t}\n\n\n\tget si () {\n\t\treturn this.s_note.index;\n\t}\n\n\n\tget ci () {\n\t\treturn this.c_note.index;\n\t}\n\n\n\tget root () {\n\t\treturn this.prev.root || this;\n\t}\n\n\n\tget rootSi () {\n\t\treturn !this.prev.zero ? this.prev.rootSi : this.si;\n\t}\n\n\n\tget id () {\n\t\treturn `${this.s_note.index},${this.c_note.index}`;\n\t}\n\n\n\tstatic cost (prev, skip, self) {\n\t\treturn prev * Config.CostStepAttenuation + Math.tanh(skip * Config.SkipCost) + Math.tanh(self * 0.5);\n\t}\n\n\n\tupdateCache () {\n\t\tif (this.cacheDirty) {\n\t\t\tthis._totalCost = Node.cost(this.prev.totalCost, this.si - this.prev.si - 1, this.selfCost);\n\t\t\tthis._value = this.prev.value + 1 - Math.tanh(this.selfCost * 0.5);\n\n\t\t\tthis.cacheDirty = false;\n\t\t}\n\t}\n\n\n\tget totalCost () {\n\t\tthis.updateCache();\n\n\t\treturn this._totalCost;\n\t}\n\n\n\tget value () {\n\t\tthis.updateCache();\n\n\t\treturn this._value;\n\t}\n\n\n\tget deep () {\n\t\treturn this.prev.deep + 1;\n\t}\n\n\n\tget path () {\n\t\tconst path = [];\n\t\tfor (let node = this; !node.zero; node = node.prev) {\n\t\t\tpath[node.si] = node.ci;\n\t\t}\n\n\t\tfor (let i = 0; i < path.length; ++i)\n\t\t\tif (typeof path[i] != \"number\")\n\t\t\t\tpath[i] = -1;\n\n\t\treturn path;\n\t}\n\n\n\tdump () {\n\t\treturn pick(this, [\"id\", \"si\", \"ci\", \"rootSi\", \"value\", \"deep\", \"rootSi\", \"offset\", \"prior\", \"selfCost\", \"totalCost\"]);\n\t}\n\n\n\tevaluatePrev (node) {\n\t\tconst cost = this.evaluatePrevCost(node);\n\n\t\tconsole.assert(this.si - node.si >= 1, \"node index error:\", this, node/*, {get [Symbol.toStringTag]() {debugger}}*/);\n\t\t//if (this.si - node.si < 1)\n\t\t//\tdebugger;\n\n\t\tconst totalCost = Node.cost(node.totalCost, this.si - node.si - 1, cost);\n\n\t\tif (!this.prev || totalCost < this.totalCost) {\n\t\t\tthis.prev = node;\n\t\t\tthis.selfCost = cost;\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tevaluatePrevCost (node) {\n\t\tlet cost = 0;\n\n\t\tif (node.offset != null) {\n\t\t\tconst bias = this.offset - node.offset;\n\t\t\tconst costCoeff = node.zero ? Config.ZeroOffsetCost : (bias > 0 ? Config.LagOffsetCost : Config.LeadOffsetCost);\n\t\t\tcost += (bias * costCoeff) ** 2;\n\t\t}\n\n\t\treturn cost;\n\t}\n\n\n\tpriorByOffset (offset) {\n\t\tconst distance = Math.abs(this.offset - offset) / 1;//(this.s_note.deltaSi + 0.04);\n\n\t\treturn Math.tanh(this.value * Config.PriorValueSigmoidFactor) - Math.tanh(distance * Config.PriorDistanceSigmoidFactor);\n\t\t//return Math.log(this.value) * Math.tanh(4 / distance);\n\t\t//return this.value - distance;\n\t}\n\n\n\tstatic zero () {\n\t\treturn {\n\t\t\tzero: true,\n\t\t\ttotalCost: 0,\n\t\t\tvalue: 0,\n\t\t\tsi: -1,\n\t\t\tci: -1,\n\t\t\tdeep: 0,\n\t\t\toffset: 0,\n\t\t};\n\t}\n};\n\n\n\nmodule.exports = Node;\n","\nconst Config = require(\"./config.js\");\nconst Node = require(\"./node.js\");\n\n\n\nclass Navigator {\n\tconstructor (criterion, sample, options = {}) {\n\t\tthis.criterion = criterion;\n\t\tthis.sample = sample;\n\n\t\tthis.getCursorOffset = options.getCursorOffset || (() => null);\n\t\tthis.outOfPage = options.outOfPage;\n\n\t\tthis.bestNode = null;\n\t\tthis.fineCursor = null;\n\n\t\tthis.breakingSI = sample.notes.length - 1;\n\n\t\tthis.zeroNode = Node.zero();\n\t\tthis.zeroNode.offset = this.getCursorOffset() || 0;\n\n\t\tthis.relocationThreshold = options.relocationThreshold || Config.RelocationThreshold;\n\t}\n\n\n\tstep (index) {\n\t\t//console.log(\"step:\", this.zeroNode.offset);\n\t\tconst note = this.sample.notes[index];\n\n\t\tif (note.matches.length > 0) {\n\t\t\t//console.log(\"zeroNode.offset:\", index, this.zeroNode.offset);\n\t\t\tnote.matches.forEach(node => {\n\t\t\t\tnode.evaluatePrev(this.zeroNode);\n\t\t\t\t//console.log(\"node:\", node, node.evaluatePrevCost(this.zeroNode), node.offset, this.zeroNode.offset);\n\n\t\t\t\tfor (let si = index - 1; si >= Math.max(this.breakingSI + 1, index - Config.SkipDeep); --si) {\n\t\t\t\t\t//const skipCost = Config.SkipCost * (index - 1 - si);\n\n\t\t\t\t\tconst prevNote = this.sample.notes[si];\n\t\t\t\t\tconsole.assert(prevNote, \"prevNote is null:\", si, index, this.sample.notes);\n\t\t\t\t\tprevNote.matches.forEach(prevNode => {\n\t\t\t\t\t\tconst bias = node.offset - prevNode.offset;\n\t\t\t\t\t\tif (/*prevNode.totalCost + skipCost < node.totalCost\n\t\t\t\t\t\t\t&&*/ (bias < 2 / Config.LagOffsetCost && bias > -2 / Config.LeadOffsetCost))\n\t\t\t\t\t\t\tnode.evaluatePrev(prevNode);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tnode.prior = node.totalCost > 1.99 ? -1 : node.priorByOffset(this.zeroNode.offset);\n\n\t\t\t\tif (node.prior > 0 && this.outOfPage) {\n\t\t\t\t\tconst tick = this.criterion.notes[node.ci].startTick;\n\t\t\t\t\tif (this.outOfPage(tick))\n\t\t\t\t\t\tnode.prior -= 0.7;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tnote.matches.sort((c1, c2) => c2.prior - c1.prior);\n\t\t\tthis.cursors = note.matches;\n\t\t\t//console.log(\"navigator cursors:\", this.cursors);\n\n\t\t\tlet fineCursor = null;\n\t\t\tconst nullLength = this.nullSteps(index);\n\n\t\t\tconst cursor = this.cursors[0];\n\t\t\tif (cursor && cursor.totalCost < 1) {\n\t\t\t\t//console.log(\"nullLength:\", nullLength, nullLength * Math.log(cursor.value / 4));\n\t\t\t\tif (cursor.prior > 0 || (cursor.totalCost < 0.4 && Math.log(Math.max(nullLength * cursor.value, 1e-3)) > this.relocationThreshold)) {\n\t\t\t\t\tthis.zeroNode.offset = cursor.offset;\n\n\t\t\t\t\tfineCursor = cursor;\n\n\t\t\t\t\tif (!this.bestNode || cursor.value > this.bestNode.value)\n\t\t\t\t\t\tthis.bestNode = cursor;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fineCursor)\n\t\t\t\tthis.fineCursor = fineCursor;\n\t\t\telse {\n\t\t\t\tif (!this.resetCursor(index, {breaking: false/*nullLength > Config.SkipDeep*/})) {\n\t\t\t\t\tthis.zeroNode.offset += note.deltaSi * Math.tanh(nullLength);\n\t\t\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", note.deltaSi, nullLength);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tthis.cursors = [];\n\t}\n\n\n\tpath ({fromIndex = 0, toIndex = this.sample.notes.length - 1} = {}) {\n\t\tconst path = [];\n\n\t\tlet offset = null;\n\n\t\tfor (let si = toIndex; si >= fromIndex;) {\n\t\t\tconst note = this.sample.notes[si];\n\n\t\t\tif (!note.matches.length || note.matches[0].prior < -0.01 || note.matches[0].totalCost >= 1) {\n\t\t\t\t//if (note.matches.length)\n\t\t\t\t//\tconsole.log(\"path -1:\", si, note.matches[0].prior, note.matches[0].totalCost);\n\t\t\t\tpath[si] = -1;\n\t\t\t\t--si;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// sort nodes by backwards heuristic offset\n\t\t\tif (offset != null) {\n\t\t\t\tnote.matches.forEach(node => node.backPrior = (node.totalCost < 1.99 ? node.priorByOffset(offset) : -1));\n\t\t\t\tnote.matches.sort((n1, n2) => n2.backPrior - n1.backPrior);\n\t\t\t}\n\n\t\t\tconst node = note.matches[0];\n\t\t\tnode.path.forEach((ci, si) => path[si] = ci);\n\t\t\t//console.log(\"node path:\", si, node.path);\n\n\t\t\toffset = node.root.offset;\n\n\t\t\tsi = node.rootSi - 1;\n\t\t}\n\n\t\tconsole.assert(path.length == toIndex + 1, \"path length error:\", path, fromIndex, toIndex + 1,\n\t\t\tthis.sample.notes.length, this.sample.notes.length ? this.sample.notes[this.sample.notes.length - 1].index : null);\n\n\t\treturn path;\n\t}\n\n\n\tnullSteps (index) {\n\t\treturn index - (this.fineCursor ? this.fineCursor.si : -1) - 1;\n\t}\n\n\n\tresetCursor (index, {breaking = true} = {}) {\n\t\tif (breaking)\n\t\t\tthis.breakingSI = index;\n\n\t\tconst cursorOffset = this.getCursorOffset();\n\t\tif (cursorOffset != null) {\n\t\t\t//console.log(\"cursorOffset:\", cursorOffset);\n\n\t\t\tthis.zeroNode.offset = cursorOffset;\n\t\t\t//this.breaking = this.nullSteps(index) > Config.SkipDeep;\n\t\t\t//if (this.breaking)\t// trivial zero node si resets result in focus path interruption\n\t\t\tthis.zeroNode.si = index;\n\t\t\tthis.fineCursor = null;\n\n\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", cursorOffset);\n\t\t\t//console.log(\"cursor offset reset:\", cursorOffset);\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tget relocationTendency () {\n\t\tconst cursor = this.cursors && this.cursors[0];\n\t\tif (!cursor)\n\t\t\treturn null;\n\n\t\tconst nullLength = this.nullSteps(cursor.si);\n\t\tif (nullLength <= 0)\n\t\t\treturn 0;\n\n\t\treturn Math.log(Math.max(nullLength * cursor.value, 1e-3)) / this.relocationThreshold;\n\t}\n};\n\n\n\nmodule.exports = Navigator;\n","\nconst Node = require(\"./node.js\");\nconst Navigator = require(\"./navigator.js\");\n\n\n\nconst HEART_BEAT = 800;\t// in ms\nconst SIMULTANEOUS_INTERVAL = HEART_BEAT * 0.24;\n\n\nconst normalizeInterval = interval => Math.tanh(interval / SIMULTANEOUS_INTERVAL);\n\n\n// greater softIndexFactor make 'harder' soft index\nconst makeNoteSoftIndex = function (notes, index, {softIndexFactor = 1} = {}) {\n\tindex = Number(index);\n\n\tconst note = notes[index];\n\n\t// make soft index\n\tif (index > 0) {\n\t\tconst lastNote = notes[index - 1];\n\n\t\tconsole.assert(note.start != null, \"note.start is null\", note);\n\t\tconsole.assert(lastNote.start != null, \"lastNote.start is null\", lastNote);\n\n\t\tnote.deltaSi = normalizeInterval((note.start - lastNote.start) * softIndexFactor);\n\t\tnote.softIndex = lastNote.softIndex + note.deltaSi;\n\n\t\tconsole.assert(!Number.isNaN(note.deltaSi), \"note.deltaSi is NaN.\", note.start, lastNote.start);\n\t}\n\telse {\n\t\tnote.softIndex = 0;\n\t\tnote.deltaSi = 0;\n\t}\n};\n\n\nconst makeMatchNodes = function (note, criterion, zeroNode = Node.zero()) {\n\tnote.matches = [];\n\n\tconst targetList = criterion.pitchMap[note.pitch];\n\tif (targetList) {\n\t\tfor (const targetNote of targetList) {\n\t\t\tconst node = new Node(note, targetNote);\n\t\t\tif (zeroNode)\n\t\t\t\tnode.evaluatePrev(zeroNode);\n\n\t\t\tnote.matches.push(node);\n\t\t}\n\t}\n};\n\n\nconst genNotationContext = function (notation, {softIndexFactor = 1} = {}) {\n\tfor (let i = 0; i < notation.notes.length; ++i)\n\t\tmakeNoteSoftIndex(notation.notes, i, {softIndexFactor});\n};\n\n\nconst runNavigation = async function(criterion, sample, onStep) {\n\tconst navigator = new Navigator(criterion, sample);\n\tnavigator.resetCursor(-1);\n\n\tfor (let i = 0; i < sample.notes.length; ++i) {\n\t\tnavigator.step(i);\n\n\t\tconst next = await (onStep && onStep(i, navigator));\n\t\tif (next === Symbol.for(\"end\")) {\n\t\t\tconsole.log(\"Navigation interrupted.\");\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t//console.log(\"Navigation accomplished.\");\n\n\treturn navigator;\n};\n\n\n\nmodule.exports = {\n\tnormalizeInterval,\n\tmakeNoteSoftIndex,\n\tmakeMatchNodes,\n\tgenNotationContext,\n\trunNavigation,\n\tNavigator,\n\tNode,\n};\n","\nconst MIDI = require(\"./MIDI\");\n\n\n\nconst trackDeltaToAbs = events => {\n\tlet tick = 0;\n\n\tevents.forEach(event => {\n\t\ttick += event.deltaTime;\n\t\tevent.tick = tick;\n\t});\n};\n\n\nconst trackAbsToDelta = events => {\n\tlet lastTick = 0;\n\n\tevents.sort((e1, e2) => e1.tick - e2.tick).forEach(event => {\n\t\tevent.deltaTime = event.tick - lastTick;\n\t\tlastTick = event.tick;\n\t});\n};\n\n\nconst sliceTrack = (track, startTick, endTick) => {\n\ttrackDeltaToAbs(track);\n\n\tconst events = [];\n\tconst status = {};\n\n\ttrack.forEach(event => {\n\t\tif (event.tick >= startTick && event.tick <= endTick && event.subtype !== \"endOfTrack\")\n\t\t\tevents.push({\n\t\t\t\t...event,\n\t\t\t\ttick: event.tick - startTick,\n\t\t\t});\n\t\telse if (event.tick < startTick) {\n\t\t\tswitch (event.type) {\n\t\t\tcase \"meta\":\n\t\t\t\tstatus[event.subtype] = event;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t});\n\n\tObject.values(status).forEach(event => events.push({\n\t\t...event,\n\t\ttick: 0,\n\t}));\n\n\tevents.push({\n\t\ttick: endTick - startTick,\n\t\ttype: \"meta\",\n\t\tsubtype: \"endOfTrack\",\n\t});\n\n\ttrackAbsToDelta(events);\n\n\treturn events;\n};\n\n\nconst sliceMidi = (midi, startTick, endTick) => ({\n\theader: midi.header,\n\ttracks: midi.tracks.map(track => sliceTrack(track, startTick, endTick)),\n});\n\n\nconst TICKS_PER_BEATS = 480;\n\nconst EXCLUDE_MIDI_EVENT_SUBTYPES = [\n\t\"endOfTrack\", \"trackName\",\n\t\"noteOn\", \"noteOff\",\n];\n\n\nfunction encodeToMIDIData(notation, {startTime, unclosedNoteDuration = 30e+3} = {}) {\n\tnotation.microsecondsPerBeat = notation.microsecondsPerBeat || 500000;\n\n\tconst ticksPerBeat = TICKS_PER_BEATS;\n\tconst msToTicks = ticksPerBeat * 1000 / notation.microsecondsPerBeat;\n\n\tconst header = { formatType: 0, ticksPerBeat };\n\tconst track = [];\n\n\tif (!Number.isFinite(startTime)) {\n\t\tif (!notation.notes || !notation.notes[0])\n\t\t\tthrow new Error(\"encodeToMidiData: no start time specificed\");\n\n\t\tstartTime = notation.notes[0].start;\n\t}\n\n\ttrack.push({ time: startTime, type: \"meta\", subtype: \"copyrightNotice\", text: `Composed by MusicWdigets. BUILT on ${new Date(Number(process.env.VUE_APP_BUILD_TIME)).toDateString()}` });\n\n\tconst containsTempo = notation.events && notation.events.find(event => event.subtype == \"setTempo\");\n\tif (!containsTempo) {\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"timeSignature\", numerator: 4, denominator: 4, thirtyseconds: 8 });\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"setTempo\", microsecondsPerBeat: notation.microsecondsPerBeat });\n\t}\n\n\t//if (notation.correspondences)\n\t//\ttrack.push({ time: startTime, type: \"meta\", subtype: \"text\", text: \"find-corres:\" + notation.correspondences.join(\",\") });\n\n\tlet endTime = startTime || 0;\n\n\tif (notation.notes) {\n\t\tfor (const note of notation.notes) {\n\t\t\ttrack.push({\n\t\t\t\ttime: note.start,\n\t\t\t\ttype: \"channel\",\n\t\t\t\tsubtype: \"noteOn\",\n\t\t\t\tchannel: note.channel || 0,\n\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\tvelocity: note.velocity,\n\t\t\t\tfinger: note.finger,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, note.start);\n\n\t\t\tif (Number.isFinite(unclosedNoteDuration))\n\t\t\t\tnote.duration = note.duration || unclosedNoteDuration;\n\t\t\tif (note.duration) {\n\t\t\t\ttrack.push({\n\t\t\t\t\ttime: note.start + note.duration,\n\t\t\t\t\ttype: \"channel\",\n\t\t\t\t\tsubtype: \"noteOff\",\n\t\t\t\t\tchannel: note.channel || 0,\n\t\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\t\tvelocity: 0,\n\t\t\t\t});\n\n\t\t\t\tendTime = Math.max(endTime, note.start + note.duration);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (notation.events) {\n\t\tconst events = notation.events.filter(event => !EXCLUDE_MIDI_EVENT_SUBTYPES.includes(event.data.subtype));\n\t\tfor (const event of events) {\n\t\t\ttrack.push({\n\t\t\t\ttime: event.time,\n\t\t\t\t...event.data,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, event.time);\n\t\t}\n\t}\n\n\ttrack.push({ time: endTime + 100, type: \"meta\", subtype: \"endOfTrack\" });\n\n\ttrack.sort(function (e1, e2) { return e1.time - e2.time; });\n\n\t// append finger event after every noteOn event\n\ttrack.map((event, index) => ({event, index}))\n\t\t.filter(({event}) => event.subtype == \"noteOn\" && event.finger != null)\n\t\t.reverse()\n\t\t.forEach(({event, index}) => track.splice(index + 1, 0, {\n\t\t\ttime: event.time,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `fingering(${event.finger})`,\n\t\t}));\n\n\ttrack.forEach(event => event.ticks = Math.round((event.time - startTime) * msToTicks));\n\ttrack.forEach((event, i) => event.deltaTime = (event.ticks - (i > 0 ? track[i - 1].ticks : 0)));\n\n\treturn {header, tracks: [track]};\n};\n\n\nfunction encodeToMIDI(notation, options) {\n\tconst data = encodeToMIDIData(notation, options);\n\treturn MIDI.encodeMidiFile(data);\n};\n\n\n\nmodule.exports = {\n\tsliceMidi,\n\tencodeToMIDIData,\n\tencodeToMIDI,\n};\n","\nconst MIDI = require(\"./source/inc/MIDI\");\nconst MusicNotation = require(\"./source/inc/MusicNotation\");\nconst MidiPlayer = require(\"./source/inc/MidiPlayer.js\");\nconst Matcher = require(\"./source/inc/Matcher\");\nconst MidiUtils = require(\"./source/inc/MidiUtils.js\");\n\n\n\nmodule.exports = {\n\tMIDI,\n\tMusicNotation,\n\tMidiPlayer,\n\tMatcher,\n\tMidiUtils,\n};\n","import pick from 'lodash/pick';\n\nimport { MusicNotation, MIDI } from '@k-l-lambda/music-widgets';\n\n//import {MeasureLayout, LayoutType} from\nimport { ImplicitType, ChordPosition } from './types';\n\nconst WHOLE_DURATION_MAGNITUDE = 1920;\nconst TICKS_PER_BEAT = WHOLE_DURATION_MAGNITUDE / 4;\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ninterface StaffNoteProperties {\n\trest: boolean;\n\ttied: boolean;\n\toverlapped: boolean;\n\timplicitType: ImplicitType;\n\tafterGrace: boolean;\n\tchordPosition: ChordPosition;\n\tdivision: number;\n\n\tcontextIndex: number;\n\tstaffTrack: number;\n}\n\ninterface MetaNote extends MusicNotation.Note, Partial {\n\tid: string;\n\tmeasure: number;\n\tendTick: number;\n}\n\ninterface SubNote {\n\tstartTick: number;\n\tendTick: number;\n\tpitch: number;\n\tvelocity?: number;\n}\n\ninterface MeasureNote extends Partial {\n\ttick: number;\n\tpitch: number;\n\tduration: number;\n\tchordPosition: ChordPosition;\n\tstaff: number;\n\n\ttrack: number;\n\tchannel: number;\n\tid: string;\n\tids: string[];\n\n\tsubNotes: SubNote[];\n}\n\ninterface MeasureEvent {\n\tdata: any;\n\ttrack: number;\n\tticks?: number;\n}\n\ninterface Measure {\n\ttick: number;\n\tduration: number;\n\n\tnotes: MeasureNote[];\n\tevents?: MeasureEvent[];\n\ttimeSignature?: Fraction;\n\tkeySignature?: number;\n}\n\ninterface PerformOptions {\n\twithRestTied?: boolean;\n}\n\ninterface MidiEvent extends MIDI.MidiEvent {\n\tticks?: number;\n\tmeasure?: number;\n\tids?: string[];\n\tstaffTrack?: number;\n\tstaff?: number;\n}\ntype MidiTrack = MidiEvent[];\n\nconst EXTRA_NOTE_FIELDS = ['rest', 'tied', 'overlapped', 'implicitType', 'afterGrace', 'contextIndex', 'staffTrack', 'chordPosition', 'division'];\nconst COMMON_NOTE_FIELDS = ['id', 'ids', 'pitch', 'velocity', 'track', 'channel', ...EXTRA_NOTE_FIELDS];\n\nclass MetaNotation {\n\t//pitchContextGroup: PitchContextTable[];\n\t//measureLayout: MeasureLayout;\n\tmeasures: Measure[];\n\n\ttrackNames: string[];\n\tidTrackMap: { [key: string]: number };\n\n\tripe: boolean = false;\n\n\tstatic fromAbsoluteNotes(notes: MetaNote[], measureHeads: number[], data?: Partial): MetaNotation {\n\t\tconst notation = new MetaNotation(data);\n\n\t\tnotation.measures = Array(measureHeads.length)\n\t\t\t.fill(null)\n\t\t\t.map((__, i) => {\n\t\t\t\tconst tick = measureHeads[i];\n\t\t\t\tconst duration = measureHeads[i + 1] ? measureHeads[i + 1] - tick : 0;\n\n\t\t\t\tconst mnotes = notes\n\t\t\t\t\t.filter((note) => note.measure === i + 1)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(note) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\ttick: note.startTick - tick,\n\t\t\t\t\t\t\t\tduration: note.endTick - note.startTick,\n\t\t\t\t\t\t\t\t...pick(note, COMMON_NOTE_FIELDS),\n\t\t\t\t\t\t\t\tsubNotes: [],\n\t\t\t\t\t\t\t} as MeasureNote)\n\t\t\t\t\t);\n\n\t\t\t\t// reduce note data size\n\t\t\t\tmnotes.forEach((mn) =>\n\t\t\t\t\t['rest', 'tied', 'implicitType', 'afterGrace'].forEach((field) => {\n\t\t\t\t\t\tif (!mn[field]) delete mn[field];\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes: mnotes,\n\t\t\t\t};\n\t\t\t});\n\n\t\tnotation.idTrackMap = notes.reduce((map, note) => {\n\t\t\tif (note.id) map[note.id] = note.track;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn notation;\n\t}\n\n\tstatic performAbsoluteNotes(abNotes: MetaNote[], { withRestTied = false }: PerformOptions = {}): MusicNotation.Note[] {\n\t\tconst notes = abNotes\n\t\t\t.filter((note) => (withRestTied || (!note.rest && !note.tied)) && !note.overlapped)\n\t\t\t.map((note) => ({\n\t\t\t\tmeasure: note.measure,\n\t\t\t\tchannel: note.channel,\n\t\t\t\ttrack: note.track,\n\t\t\t\tstart: note.start,\n\t\t\t\tstartTick: note.startTick,\n\t\t\t\tendTick: note.endTick,\n\t\t\t\tpitch: note.pitch,\n\t\t\t\tduration: note.duration,\n\t\t\t\tvelocity: note.velocity || 127,\n\t\t\t\tid: note.id,\n\t\t\t\tids: note.ids,\n\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\tcontextIndex: note.contextIndex,\n\t\t\t\timplicitType: note.implicitType,\n\t\t\t\tchordPosition: note.chordPosition,\n\t\t\t}));\n\n\t\tconst noteMap = notes.reduce((map, note) => {\n\t\t\tconst key = `${note.channel}|${note.start}|${note.pitch}`;\n\t\t\tconst priorNote = map[key];\n\t\t\tif (priorNote) priorNote.ids.push(...note.ids);\n\t\t\telse map[key] = note;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(noteMap);\n\t}\n\n\tconstructor(data?: Partial) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\t/*get ordinaryMeasureIndices (): number[] {\n\t\tif (this.measureLayout)\n\t\t\treturn this.measureLayout.serialize(LayoutType.Ordinary);\n\n\t\treturn Array(this.measures.length).fill(null).map((_, i) => i + 1);\n\t}*/\n\n\t// In Lilypond 2.20.0, minus tick value at the head of a track result in MIDI event time bias,\n\t//\tSo store the bias values to correct MIDI time from lilyond.\n\tget trackTickBias(): { [key: string]: number } {\n\t\tconst headMeasure = this.measures[0];\n\t\treturn this.trackNames.reduce((map, name, track) => {\n\t\t\tmap[name] = 0;\n\t\t\tif (headMeasure) {\n\t\t\t\tconst note = headMeasure.notes.find((note) => note.track === track);\n\t\t\t\tif (note) map[name] = Math.min(note.tick, 0);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget idSet(): Set {\n\t\treturn this.measures.reduce(\n\t\t\t(set, measure) => (measure.notes.filter((note) => !note.rest).forEach((note) => note.ids.forEach((id) => set.add(id))), set),\n\t\t\tnew Set()\n\t\t);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\t__prototype: 'LilyNotation',\n\t\t\t//pitchContextGroup: this.pitchContextGroup,\n\t\t\t//measureLayout: this.measureLayout,\n\t\t\tmeasures: this.measures,\n\t\t\tidTrackMap: this.idTrackMap,\n\t\t\ttrackNames: this.trackNames,\n\t\t\tripe: this.ripe,\n\t\t};\n\t}\n\n\ttoAbsoluteNotes(measureIndices: number[] /*= this.ordinaryMeasureIndices*/): MetaNote[] {\n\t\tlet measureTick = 0;\n\t\tconst measureNotes: MetaNote[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst notes = measure.notes.map((mnote) => {\n\t\t\t\treturn {\n\t\t\t\t\tstartTick: measureTick + mnote.tick,\n\t\t\t\t\tendTick: measureTick + mnote.tick + mnote.duration,\n\t\t\t\t\tstart: measureTick + mnote.tick,\n\t\t\t\t\tduration: mnote.duration,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t\t...pick(mnote, COMMON_NOTE_FIELDS),\n\t\t\t\t} as MetaNote;\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn notes;\n\t\t});\n\n\t\treturn [].concat(...measureNotes);\n\t}\n\n\t/*getMeasureIndices (type: LayoutType) {\n\t\treturn this.measureLayout.serialize(type);\n\t}*/\n\n\ttoPerformingNotation(measureIndices: number[] /*= this.ordinaryMeasureIndices*/, options: PerformOptions = {}): MusicNotation.Notation {\n\t\t//console.debug(\"toPerformingNotation:\", this, measureIndices);\n\t\tconst abNotes = this.toAbsoluteNotes(measureIndices);\n\t\tconst notes = MetaNotation.performAbsoluteNotes(abNotes, options);\n\n\t\t//const lastNote = notes[notes.length - 1];\n\t\tconst endTime = Math.max(...notes.map((note) => note.start + note.duration));\n\n\t\tconst endTick = measureIndices.reduce((tick, index) => tick + this.measures[index - 1].duration, 0);\n\n\t\tconst notation = new MusicNotation.Notation({\n\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\tmeta: {},\n\t\t\ttempos: [], // TODO\n\t\t\tchannels: [notes],\n\t\t\tendTime,\n\t\t\tendTick,\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\ttoPerformingMIDI(measureIndices: number[], { trackList }: { trackList?: boolean[] } = {}): MIDI.MidiData & { zeroTick: number } {\n\t\tif (!measureIndices.length) return null;\n\n\t\t// to avoid begin minus tick\n\t\tconst zeroTick = -Math.min(0, ...(this.measures[0]?.events.map((e) => e.ticks) || []), ...(this.measures[0]?.notes.map((note) => note.tick) || []));\n\n\t\tlet measureTick = zeroTick;\n\t\tconst measureEvents: MeasureEvent[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst events = measure.events.map((mevent) => ({\n\t\t\t\tticks: measureTick + mevent.ticks,\n\t\t\t\ttrack: mevent.track,\n\t\t\t\tdata: {\n\t\t\t\t\t...mevent.data,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn events;\n\t\t});\n\n\t\tconst eventPriority = (event: MidiEvent): number => event.ticks + (event.subtype === 'noteOff' ? -1e-8 : 0);\n\n\t\tconst tracks: MidiTrack[] = [].concat(...measureEvents).reduce((tracks, mevent) => {\n\t\t\ttracks[mevent.track] = tracks[mevent.track] || [];\n\t\t\ttracks[mevent.track].push({\n\t\t\t\tticks: mevent.ticks,\n\t\t\t\t...mevent.data,\n\t\t\t});\n\n\t\t\treturn tracks;\n\t\t}, []);\n\n\t\ttracks[0] = tracks[0] || [];\n\t\t/*tracks[0].push({\n\t\t\tticks: 0,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `${npmPackage.name} ${npmPackage.version}`,\n\t\t});*/\n\n\t\t// append note events\n\t\tmeasureTick = zeroTick;\n\t\tmeasureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\t\t\tif (!Number.isFinite(measure.duration)) return;\n\n\t\t\tmeasure.notes.forEach((note) => {\n\t\t\t\tif (trackList && !trackList[note.track]) return;\n\n\t\t\t\tif (note.rest) return;\n\n\t\t\t\tconst tick = measureTick + note.tick;\n\n\t\t\t\tconst track = (tracks[note.track] = tracks[note.track] || []);\n\n\t\t\t\tnote.subNotes.forEach((subnote) => {\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.startTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: subnote.velocity,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.endTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: 0,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\t\t});\n\n\t\tconst finalTick = measureTick;\n\n\t\t// ensure no empty track\n\t\tfor (let t = 0; t < tracks.length; ++t) tracks[t] = tracks[t] || [];\n\n\t\t// sort & make deltaTime\n\t\ttracks.forEach((events) => {\n\t\t\tevents.sort((e1, e2) => eventPriority(e1) - eventPriority(e2));\n\n\t\t\tlet ticks = 0;\n\t\t\tevents.forEach((event) => {\n\t\t\t\tevent.deltaTime = event.ticks - ticks;\n\t\t\t\tif (!Number.isFinite(event.deltaTime)) event.deltaTime = 0;\n\t\t\t\telse ticks = event.ticks;\n\t\t\t});\n\n\t\t\tevents.push({ deltaTime: Math.max(finalTick - ticks, 0), type: 'meta', subtype: 'endOfTrack' });\n\t\t});\n\n\t\treturn {\n\t\t\theader: {\n\t\t\t\tformatType: 0,\n\t\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\t},\n\t\t\ttracks,\n\t\t\tzeroTick,\n\t\t};\n\t}\n\n\ttoPerformingNotationWithEvents(measureIndices: number[], options: { trackList?: boolean[] } = {}): MusicNotation.Notation {\n\t\tif (!measureIndices.length) return null;\n\n\t\tconst { zeroTick, ...midi } = this.toPerformingMIDI(measureIndices, options);\n\t\tconst notation = MusicNotation.Notation.parseMidi(midi);\n\n\t\tassignNotationNoteDataFromEvents(notation);\n\n\t\tlet tick = zeroTick;\n\n\t\tnotation.measures = measureIndices.map((index) => {\n\t\t\tconst startTick = tick;\n\t\t\ttick += this.measures[index - 1].duration;\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tstartTick,\n\t\t\t\tendTick: tick,\n\t\t\t};\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\t// find the MIDI event of setTempo in measures data, and change the value of microsecondsPerBeat\n\tsetTempo(bpm: number): boolean {\n\t\tlet found = false;\n\t\tfor (const measure of this.measures) {\n\t\t\tfor (const event of measure.events) {\n\t\t\t\tif (event.data.subtype === 'setTempo') {\n\t\t\t\t\tevent.data.microsecondsPerBeat = 60e6 / bpm;\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn found;\n\t}\n}\n\nconst assignNotationNoteDataFromEvents = (midiNotation: MusicNotation.NotationData, fields = ['ids', 'measure', 'staffTrack']) => {\n\tconst noteId = (channel: number, pitch: number, tick: number): string => `${channel}|${pitch}|${tick}`;\n\n\tconst noteMap = midiNotation.notes.reduce((map, note) => {\n\t\tmap[noteId(note.channel, note.pitch, note.startTick)] = note;\n\n\t\treturn map;\n\t}, {});\n\n\tmidiNotation.events.forEach((event) => {\n\t\tif (event.data.subtype === 'noteOn') {\n\t\t\tconst id = noteId(event.data.channel, event.data.noteNumber, event.ticks);\n\t\t\tconst note = noteMap[id];\n\t\t\tconsole.assert(!!note, 'cannot find note of', id);\n\n\t\t\tif (note) Object.assign(note, pick(event.data, fields));\n\t\t}\n\t});\n};\n\nexport { MetaNote, MetaNotation, MidiEvent };\n",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import _SHA256 from 'crypto-js/sha256';\n\nconst SHA256 = (source: string): Uint8Array => {\n\tconst { words, sigBytes } = _SHA256(source);\n\tconst uwords = words.map((x) => (x < 0 ? x + 0x100000000 : x));\n\tconst word_len = sigBytes / words.length;\n\n\treturn new Uint8Array(sigBytes).map((_, i) => (uwords[Math.floor(i / word_len)] >> ((3 - (i % word_len)) * 8)) & 0xff);\n};\n\ntype Hash = Uint8Array;\nconst HASH_LEN = 256;\n\nclass HashVector {\n\tfields: number[];\n\n\tstatic fromHash(hash: Hash): HashVector {\n\t\tconst fields = [];\n\t\tfor (const byte of hash) {\n\t\t\tfor (let b = 0; b < 8; ++b) fields.push((byte >> b) & 1 ? 1 : -1);\n\t\t}\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic fromString(source: string): HashVector {\n\t\tconst hash = SHA256(source);\n\t\treturn HashVector.fromHash(hash);\n\t}\n\n\tstatic fromWords(words: string[]): HashVector {\n\t\tconst vs = words.map((word) => HashVector.fromString(word));\n\t\treturn vs.reduce((sum, v) => sum.add(v), HashVector.zero);\n\t}\n\n\tstatic concat(...vectors: HashVector[]): HashVector {\n\t\tconst fields = vectors.map((v) => v.fields).flat(1);\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tconstructor(fields: number[] | null = null) {\n\t\tthis.fields = fields || Array(HASH_LEN).fill(0);\n\t}\n\n\tget length(): number {\n\t\treturn this.fields.length;\n\t}\n\n\ttoHash(): Hash {\n\t\treturn Uint8Array.from(\n\t\t\tArray(this.length / 8)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => {\n\t\t\t\t\tconst bits = this.fields.slice(i * 8, (i + 1) * 8);\n\n\t\t\t\t\treturn bits.reduce((byte, bit, b) => byte | ((bit > 0 ? 1 : 0) << b), 0);\n\t\t\t\t})\n\t\t) as Hash;\n\t}\n\n\tadd(vec: HashVector): this {\n\t\tthis.fields.forEach((value, i) => (this.fields[i] = value + vec.fields[i]));\n\n\t\treturn this;\n\t}\n\n\tscale(factor: number): this {\n\t\tthis.fields = this.fields.map((value) => value * factor);\n\n\t\treturn this;\n\t}\n\n\tsub(crop: number): HashVector {\n\t\tconst fields = crop > 0 ? this.fields.slice(0, crop) : this.fields.slice(crop);\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic get zero(): HashVector {\n\t\treturn new HashVector();\n\t}\n}\n\nconst odds = (byte: number): number => {\n\tlet result = 0;\n\tfor (let b = byte; b > 0; b >>= 1) {\n\t\tif (b % 2) ++result;\n\t}\n\n\treturn result;\n};\nconst ODDS = Array(2 ** 8)\n\t.fill(0)\n\t.map((_, i) => odds(i));\nconst ODDS_HEX = ODDS.reduce((table, odd, i) => ({ ...table, [('0' + i.toString(16)).slice(-2)]: odd }), {});\n\nconst countOnes = (hash: Hash): number => hash.reduce((sum, byte) => sum + ODDS[byte], 0);\n\nconst xorHashes = (hash1: Hash, hash2: Hash): Hash => hash1.map((byte, i) => byte ^ hash2[i]) as Hash;\n\nconst cosHashes = (hash1: Hash, hash2: Hash): number => {\n\tconst len = hash1.length * 8;\n\n\tconst xor = xorHashes(hash1, hash2);\n\tconst ones = countOnes(xor);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst cosBigInts = (hash1: bigint, hash2: bigint, len: number = HASH_LEN): number => {\n\tconst xor = hash1 ^ hash2;\n\tconst xor_hex = '0'.repeat(len / 4) + xor.toString(16);\n\n\tconst ones = Array(len / 8)\n\t\t.fill(0)\n\t\t.reduce((ones, _, i) => ones + ODDS_HEX[xor_hex.slice((i + 1) * -2, i ? i * -2 : undefined)], 0);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst i2hex = (i) => ('0' + i.toString(16)).slice(-2);\nconst hashToHex = (hash: Hash): string => Array.from(hash).map(i2hex).join('');\n\nconst hexToHash = (hex: string): Hash =>\n\tUint8Array.from(\n\t\tArray(hex.length / 2)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => hex.substring(i * 2, (i + 1) * 2))\n\t\t\t.map((x) => parseInt(x, 16))\n\t);\n\nconst hashToBigInt = (hash: Hash): bigint => {\n\t// __NOT_FOR_BROWSER_\n\treturn Array.from(hash).reduce((r, x) => r * 0x100n + BigInt(x), 0n);\n\t/*\n\t// _NOT_FOR_BROWSER__\n\tthrow new Error('BigInt not supported');\n\t//*/\n};\n\nconst hashFromWords = (words: string[]): Hash => HashVector.fromWords(words).toHash();\n\nexport { Hash, HashVector, cosHashes, cosBigInts, hashToHex, hexToHash, hashToBigInt, hashFromWords };\n","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import { EventFeature, BackgroundImage, EventPredisposition } from './interfaces';\nimport { StemBeam } from './term';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum EventElementType {\n\tPAD,\n\tBOS,\n\tEOS,\n\n\tCHORD,\n\tREST,\n}\n\ninterface EventElement {\n\thref?: string;\n\tdisposed?: boolean;\n\tindex?: number;\n\tvoice?: number;\n\n\ttype: EventElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\tfeature: EventFeature;\n\tpivotX?: number;\n\theadY?: number;\n\n\t// targets\n\ttick?: number;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: StemBeam;\n\tstemDirection?: string;\n\tgrace?: boolean;\n\ttremoloCatcher?: boolean;\n\ttimeWarped?: boolean;\n\tfullMeasure?: boolean; // full measure rest\n\tfake?: boolean;\n\n\torder?: number;\n\n\tpredisposition?: EventPredisposition;\n}\n\ntype Matrix = number[][];\n\ninterface Annotation {\n\tloss: number;\n\tgrant: boolean;\n\tpatched: boolean; // from manually solved measure\n}\n\nclass EventCluster extends SimpleClass {\n\tstatic className = 'EventCluster';\n\tstatic blackKeys = ['id'];\n\n\tid?: string; // for db access\n\tindex?: number;\n\tduration?: number;\n\tstaffY0?: number; // the first staff top + staffY\n\n\tsignatureDuration: number;\n\telements: EventElement[];\n\tmatrixH?: Matrix; // matrix N x N, [next][prev]\n\n\tbackgroundImages?: BackgroundImage[];\n\n\tannotation?: Annotation;\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget regular(): boolean {\n\t\treturn (\n\t\t\tthis.elements.some((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !elem.fake) &&\n\t\t\tthis.elements.every((elem) => [elem.x, elem.y1, elem.y2, elem.tick].every(Number.isFinite)) &&\n\t\t\tthis.elements\n\t\t\t\t.slice(1)\n\t\t\t\t.every(\n\t\t\t\t\t(elem, ei) =>\n\t\t\t\t\t\telem.fake ||\n\t\t\t\t\t\tthis.elements[ei].fake ||\n\t\t\t\t\t\telem.grace ||\n\t\t\t\t\t\tthis.elements[ei].grace ||\n\t\t\t\t\t\telem.fullMeasure ||\n\t\t\t\t\t\tthis.elements[ei].fullMeasure ||\n\t\t\t\t\t\telem.tick <= this.elements[ei].tick ||\n\t\t\t\t\t\telem.x > this.elements[ei].x\n\t\t\t\t)\n\t\t);\n\t}\n\n\tget grant(): boolean {\n\t\treturn this.annotation && this.annotation.grant;\n\t}\n\n\tget feature(): Partial {\n\t\treturn {\n\t\t\tindex: this.index,\n\t\t\telements: this.elements,\n\t\t};\n\t}\n\n\tget estimatedDuration(): number {\n\t\tconst endElem = this.elements.find((elem) => elem.type === EventElementType.EOS);\n\n\t\tconst tick = endElem?.predisposition ? endElem.predisposition?.tick : endElem?.tick;\n\n\t\treturn Number.isFinite(tick) ? tick : this.duration;\n\t}\n\n\tassignPrediction(prediction: any): void {\n\t\tconsole.assert(prediction.index === this.index, 'index mismatch:', prediction.index, this.index);\n\n\t\tthis.matrixH = prediction.matrixH;\n\t\tprediction.elements.forEach((pe) => {\n\t\t\tconst { index, ...predisposition } = pe;\n\t\t\tconst elem = this.elements.find((elem) => elem.index === index);\n\t\t\tconsole.assert(elem, 'element not found:', index);\n\n\t\t\tif (elem) elem.predisposition = predisposition;\n\t\t});\n\t}\n}\n\nclass EventClusterSet extends SimpleClass {\n\tstatic className = 'EventClusterSet';\n\n\tname?: string;\n\n\tclusters: EventCluster[];\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\ttrimIrregular(): number {\n\t\tlet ir = 0;\n\n\t\tthis.clusters = this.clusters.filter((cluster) => {\n\t\t\tconst regular = cluster.regular;\n\t\t\tif (!regular) {\n\t\t\t\tconsole.debug('irregular cluster:', cluster);\n\t\t\t\t++ir;\n\t\t\t}\n\n\t\t\treturn regular;\n\t\t});\n\n\t\tif (ir) console.debug('Irregular clusters trimmed:', `${ir}/${this.clusters.length + ir}`);\n\t\telse console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`);\n\n\t\treturn ir;\n\t}\n}\n\nexport { EventElementType, EventElement, EventCluster, EventClusterSet };\n","import erf from 'math-erf';\nimport sha1 from 'js-sha1';\n\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventTerm, ContextedTerm, MarkTerm, WHOLE_DURATION, StemBeam, GraceType, ContextType, TremoloLink } from './term';\nimport {\n\tFraction,\n\tStaffBasic,\n\tEventMeasure,\n\tRegulationOptions,\n\tRegulationSolution,\n\tRegulationSolutionEvent,\n\tBackgroundImage,\n\tMeasureBarType,\n} from './interfaces';\nimport { frac, fractionMul, roundNumber, argmax } from './utils';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\nimport * as EquationSolver from './equationSolver';\nimport { PatchMeasure } from './patch';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport type { MeasureRectification } from './measureRectification';\nimport type { GraphMeasure } from './timewiseGraph';\n\nnamespace SimplePolicy {\n\tconst constructXMap = (measure: SpartitoMeasure): Map => {\n\t\tconst xMap = new Map();\n\n\t\t// mark full measure rests\n\t\tmeasure.rows.forEach((row) => {\n\t\t\tif (row.events.length === 1) {\n\t\t\t\tconst event = row.events[0];\n\t\t\t\tif (event.rest && event.division === 0) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst x = Math.round(event.pivotX * 10) / 10;\n\t\t\tlet key = 0;\n\t\t\tif (event.fullMeasureRest) key = Math.min(x, ...xMap.keys());\n\t\t\telse {\n\t\t\t\tkey =\n\t\t\t\t\t[...xMap.keys()].find((k) => {\n\t\t\t\t\t\t// check if the event is aligned with the current chord\n\t\t\t\t\t\tconst es = xMap.get(k);\n\t\t\t\t\t\tconst left = Math.min(...es.map((e) => e.left));\n\t\t\t\t\t\tconst right = Math.max(...es.map((e) => e.right));\n\n\t\t\t\t\t\tconst overlaySize = Math.min(right, event.right) - Math.max(left, event.left);\n\n\t\t\t\t\t\treturn overlaySize > NOTEHEAD_WIDTHS.NoteheadS1 * 0.62;\n\t\t\t\t\t}) || x;\n\t\t\t}\n\t\t\tevent.roundX = key;\n\n\t\t\tconst es = xMap.get(key) || [];\n\t\t\txMap.set(key, es);\n\n\t\t\tes.push(event);\n\t\t});\n\n\t\treturn xMap;\n\t};\n\n\texport const computeMeasureTicks = (measure: SpartitoMeasure): void => {\n\t\tconst xMap = constructXMap(measure);\n\n\t\tlet tick = 0;\n\t\tconst ts = new Set([tick]);\n\t\tconst eventGroups = [...xMap.entries()].sort(([x1], [x2]) => x1 - x2); //.map(entry => entry[1]);\n\t\tfor (const [x, events] of eventGroups) {\n\t\t\tvoid x;\n\n\t\t\tevents.forEach((event: EventTerm) => {\n\t\t\t\tif (event.predisposition) {\n\t\t\t\t\tevent.rest = event.rest && event.predisposition.fullMeasure > 0.5 ? 'R' : event.rest;\n\t\t\t\t\tevent.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t\tevent.division = argmax(event.predisposition.divisionVector);\n\t\t\t\t\tevent.dots = argmax(event.predisposition.dotsVector);\n\t\t\t\t\tif (event.predisposition.timeWarped > 0.5) event.timeWarp = frac(2, 3);\n\t\t\t\t}\n\n\t\t\t\tif (event.fullMeasureRest) event.tick = 0;\n\t\t\t\telse {\n\t\t\t\t\tif (event.zeroHolder) tick -= event.duration;\n\n\t\t\t\t\tif (!event.zeroHolder && event.predisposition && Number.isInteger(event.predisposition.tick)) event.tick = event.predisposition.tick;\n\t\t\t\t\telse event.tick = tick;\n\t\t\t\t\tts.add(event.tick + event.duration);\n\t\t\t\t}\n\t\t\t\t//console.log(\"append tick:\", event.tick + event.duration, event);\n\t\t\t});\n\t\t\tts.delete(tick);\n\n\t\t\t//column.xToTick[x] = tick;\n\n\t\t\tif (ts.size) tick = Math.min(...ts);\n\t\t}\n\n\t\tif (Number.isInteger(measure.estimatedDuration)) measure.duration = measure.estimatedDuration;\n\t\telse measure.duration = Math.max(...ts, 0);\n\t};\n\n\texport const computeMeasureVoices = (measure: SpartitoMeasure): void => {\n\t\tmeasure.voices = [];\n\t\tfor (const row of measure.rows) {\n\t\t\tconst events = row.events.filter(\n\t\t\t\t(event) => !event.grace && !event.tremoloCatcher && !event.fullMeasureRest && !(event.predisposition && event.predisposition.fake > 0.5)\n\t\t\t);\n\t\t\tconst eventSet = new Set(events);\n\n\t\t\twhile (eventSet.size) {\n\t\t\t\tlet tick = 0;\n\n\t\t\t\tconst voice = [];\n\t\t\t\tconst pushEvent = (e: EventTerm) => {\n\t\t\t\t\tvoice.push(e.id);\n\t\t\t\t\tif (!e.zeroHolder) tick += e.duration;\n\t\t\t\t\teventSet.delete(e);\n\t\t\t\t};\n\n\t\t\t\tconst e0 = events.find((e) => eventSet.has(e));\n\t\t\t\tif (e0.alignedTick > 0) {\n\t\t\t\t\t//voice.tickMap[tick] = EventTerm.space({ tick, duration: e0.alignedTick });\n\t\t\t\t\ttick = e0.alignedTick;\n\t\t\t\t}\n\t\t\t\tpushEvent(e0);\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// TODO: consider slur pair\n\t\t\t\t\tconst e = events.find((e) => eventSet.has(e) && e.alignedTick === tick);\n\t\t\t\t\tif (!e) break;\n\n\t\t\t\t\tpushEvent(e);\n\t\t\t\t}\n\n\t\t\t\t//if (tick < measure.duration)\n\t\t\t\t//\tvoice.tickMap[tick] = EventTerm.space({ tick, duration: staff.duration - tick });\n\n\t\t\t\tmeasure.voices.push(voice);\n\t\t\t}\n\t\t}\n\t};\n}\n\nconst solveGraceEvents = (measure: SpartitoMeasure): void => {\n\tconst graceEvents = measure.events.filter((event) => event.grace /*&& !Number.isFinite(event.tick)*/);\n\tif (!graceEvents.length) return;\n\n\tconst tickMap = measure.tickMap;\n\tconst staffMap = [...tickMap.entries()].reduce((smap, [tick, events]) => {\n\t\tevents.forEach((event) => {\n\t\t\tif (!event.grace) {\n\t\t\t\tsmap[event.staff] = smap[event.staff] || {};\n\n\t\t\t\tconst oldEvent = smap[event.staff][tick];\n\t\t\t\tsmap[event.staff][tick] = !oldEvent || oldEvent.x > event.x ? event : oldEvent;\n\t\t\t}\n\t\t});\n\n\t\treturn smap;\n\t}, {} as { [staff: number]: { [tick: number]: EventTerm } });\n\n\ttype Position = { tick: number; preTick: number; graces: EventTerm[]; event: EventTerm };\n\tconst staffPositions = Object.entries(staffMap).reduce((map, [staff, emap]) => {\n\t\tmap[staff] = Object.entries(emap)\n\t\t\t.map(([t, event]) => ({ event, tick: Number(t), preTick: -240, graces: [] }))\n\t\t\t.sort((p1, p2) => p1.event.x - p2.event.x);\n\t\tmap[staff].push({ tick: measure.duration, event: measure.endEvent, preTick: 0, graces: [] }); // terminal bar\n\n\t\tlet tick = 0;\n\t\tmap[staff].forEach((position) => {\n\t\t\tif (position.tick > tick) {\n\t\t\t\tposition.preTick = tick;\n\t\t\t\ttick = position.tick;\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}, {} as { [staff: number]: Position[] });\n\n\t// append grace events into positions\n\tgraceEvents.forEach((event) => {\n\t\tconst staff = staffPositions[event.staff];\n\t\tif (staff) {\n\t\t\tconst position = staff.find((p) => p.event.x > event.x);\n\t\t\tif (position) position.graces.push(event);\n\t\t\tevent.roundX = event.x;\n\t\t\t//if (position.tick >= measure.duration)\n\t\t\t//\tevent.grace = GraceType.AfterGrace;\n\t\t}\n\t});\n\n\tObject.values(staffPositions).forEach((staff) =>\n\t\tstaff.forEach((position) => {\n\t\t\tif (position.graces.length) {\n\t\t\t\tposition.event.graceIds = position.graces.map((e) => e.id);\n\n\t\t\t\tconst totalDuration = position.graces.reduce((t, e) => t + e.duration, 0);\n\t\t\t\tconst duration = Math.min(totalDuration, position.tick - position.preTick);\n\t\t\t\tconst warp = duration / totalDuration;\n\n\t\t\t\tlet tick = position.tick;\n\t\t\t\t[...position.graces].reverse().forEach((event) => {\n\t\t\t\t\tevent.tick = Math.round(tick - event.duration * warp);\n\t\t\t\t\ttick = event.tick;\n\t\t\t\t});\n\t\t\t}\n\t\t})\n\t);\n};\n\nconst solveTremoloPairs = (measure: SpartitoMeasure): void => {\n\tconst catchers = measure.events.filter((event) => event.tremoloCatcher && !event.grace);\n\tconst pitchers = measure.events.filter((event) => event.tremoloLink === TremoloLink.Pitcher && !event.grace);\n\n\tcatchers.forEach((catcher) => {\n\t\tlet candidates = pitchers.filter((event) => event.division === catcher.division && event.x < catcher.x);\n\t\tif (!candidates.length)\n\t\t\tcandidates = measure.events.filter(\n\t\t\t\t(event) =>\n\t\t\t\t\tNumber.isFinite(event.tick) &&\n\t\t\t\t\t!event.grace &&\n\t\t\t\t\t!event.rest &&\n\t\t\t\t\tevent.division === catcher.division &&\n\t\t\t\t\tevent.dots === catcher.dots &&\n\t\t\t\t\tevent.x < catcher.x\n\t\t\t);\n\t\tcandidates.sort((c1, c2) => c2.x - c1.x);\n\t\tif (candidates.length) {\n\t\t\tconst pitcher = candidates[0];\n\t\t\tpitcher.catcherId = catcher.id;\n\t\t\tconst tremolo = Math.max(pitcher.tremolo || 3, catcher.tremolo || 3);\n\t\t\tpitcher.tremolo = tremolo;\n\t\t\tcatcher.tremolo = tremolo;\n\n\t\t\tif (!catcher.tick) catcher.tick = pitcher.tick + pitcher.duration / 2;\n\n\t\t\tconst pi = pitchers.indexOf(pitcher);\n\t\t\tif (pi >= 0) pitchers.splice(pi, 1);\n\t\t}\n\t});\n};\n\nnamespace EquationPolicy {\n\ttype EventID = number;\n\ttype Time = number;\n\n\tconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\n\tconst CHORDS_SEAM_SIGMA = 0.6;\n\tconst NEIGHBOR_CHORDS_SIGMA = 1.6;\n\tconst Y_DECAY_SIGMA = 16;\n\tconst STAFF_DECAY_FACTOR = 2;\n\tconst STEM_DIRECTION_DECAY = 0.9;\n\tconst ILL_BEAMS_PENALTY = 0.2;\n\n\tconst INVERT_SQRT2 = 0.7071067811865475;\n\n\tconst MATRIX_H_WEIGHT = 3;\n\n\tconst FINE_BEAMS = [\n\t\t[null, null],\n\t\t[null, StemBeam.Open],\n\t\t[StemBeam.Open, StemBeam.Continue],\n\t\t[StemBeam.Open, StemBeam.Close],\n\t\t[StemBeam.Continue, StemBeam.Continue],\n\t\t[StemBeam.Continue, StemBeam.Close],\n\t\t[StemBeam.Close, null],\n\t\t[StemBeam.Close, StemBeam.Open],\n\t].map((bb) => bb.join('-'));\n\n\tinterface Event {\n\t\tid: EventID;\n\t\tstaff: number;\n\t\tx: number;\n\t\ty: number;\n\t\tduration: Time;\n\t\tconfidence: number;\n\t\tshrinkness: number;\n\t}\n\n\texport interface StaffGroup {\n\t\tevents: Event[];\n\t\texpectedDuration: Time;\n\t\tmeasureShrinkness: number;\n\t\tendX: number;\n\t\tmatrixH: Matrix;\n\t\tmatrixV: Matrix;\n\n\t\tids?: EventID[];\n\t}\n\n\tinterface EventResult {\n\t\tid: EventID;\n\t\ttick: Time;\n\t\tendTick: Time;\n\t\ttickGroup: number;\n\t\ttimeWarp?: Fraction;\n\t}\n\n\texport interface StaffGroupSolution {\n\t\tevents: EventResult[];\n\t\tvoices: EventID[][];\n\t\tduration: number;\n\n\t\tloss?: number;\n\t\tcredits?: number;\n\t\ttimes?: number;\n\t}\n\n\texport interface RegulatorOptions extends EquationSolver.SolverOptions {\n\t\tsolver?: (staffGroup: StaffGroup, options: EquationSolver.SolverOptions) => Promise;\n\t}\n\n\tconst solveStaffGroup = (staffGroup: StaffGroup, options: EquationSolver.SolverOptions): StaffGroupSolution => {\n\t\tif (!staffGroup.events.length) {\n\t\t\treturn {\n\t\t\t\tevents: [],\n\t\t\t\tvoices: [],\n\t\t\t\tduration: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\t\treturn solver.solve();\n\t};\n\n\texport const estiamteMeasure = (measure: SpartitoMeasure): StaffGroup => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => ({\n\t\t\t\tid: event.id,\n\t\t\t\tstaff: event.staff,\n\t\t\t\tx: event.x,\n\t\t\t\ttickEstimated: event.predisposition && Number.isFinite(event.predisposition.tick) ? event.predisposition.tick : event.x,\n\t\t\t\ttipX: event.tipX,\n\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\tduration: (event.mainDuration * DURATION_MULTIPLIER) / WHOLE_DURATION,\n\t\t\t\tdivision: event.division,\n\t\t\t\tdots: event.dots,\n\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\tbeam: event.beam,\n\t\t\t\trest: event.rest,\n\t\t\t\t// the possibility of full measure rest\n\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\tshrinkness: event.predisposition ? event.predisposition.timeWarped : null,\n\t\t\t}));\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: Number.isFinite(e.shrinkness) ? e.shrinkness : Math.tanh((e.division - e.dots * 0.1) / 4),\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\t//const hp = (dx: number): number => 1 - erf(((dx / NEIGHBOR_CHORDS_SIGMA) ** 0.6) * INVERT_SQRT2);\n\t\tconst hp = (dx: number): number => erf(dx / NEIGHBOR_CHORDS_SIGMA) * erf(NEIGHBOR_CHORDS_SIGMA / dx);\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\tif (e1.staffGroup !== e2.staffGroup) matrixH[e1.id][e2.id] = 0;\n\t\t\t\t// prohibit voice crossing staff groups\n\t\t\t\telse if (e1.x <= e2.x) matrixH[e1.id][e2.id] = 0;\n\t\t\t\telse {\n\t\t\t\t\tconst staffDecay = Math.exp(-Math.abs(e1.staff - e2.staff) * STAFF_DECAY_FACTOR);\n\t\t\t\t\tconst yDecay = e1.staff === e2.staff ? Math.exp(-Math.abs(e1.y - e2.y) / Y_DECAY_SIGMA) : 1;\n\t\t\t\t\tconst dx = e1.x - e2.x;\n\t\t\t\t\tconst dtx = e1.tipX - e2.tipX;\n\t\t\t\t\tmatrixH[e1.id][e2.id] = (staffDecay * yDecay * Math.min(hp(dx), hp(dtx))) ** (1 / MATRIX_H_WEIGHT);\n\t\t\t\t}\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\t\t\t\tmatrixH[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\n\t\t\t\t// weaken inconsistent stem directions\n\t\t\t\tif (e1.stemDirection && e2.stemDirection && e1.stemDirection !== e2.stemDirection) matrixH[e1.id][e2.id] *= STEM_DIRECTION_DECAY;\n\n\t\t\t\t// ill beams penalty\n\t\t\t\tif (!e1.rest && !e2.rest && !FINE_BEAMS.includes([e2.beam, e1.beam].join('-'))) matrixH[e1.id][e2.id] *= ILL_BEAMS_PENALTY;\n\t\t\t}\n\n\t\t\t// H possibility of e1 and end of measure\n\t\t\tmatrixH[ids.length][e1.id] = hp(measure.width - e1.x) ** (1 / MATRIX_H_WEIGHT);\n\t\t}\n\n\t\treturn {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness: 0,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t};\n\n\texport const regulateMeasure = async (measure: SpartitoMeasure, { solver = null, ...options }: RegulatorOptions): Promise => {\n\t\tconst env = estiamteMeasure(measure);\n\t\tconst { ids, matrixH, matrixV } = env;\n\n\t\t// copy matrices values from measure topology data\n\t\tif (measure.matrixH) {\n\t\t\tconsole.assert(\n\t\t\t\tmeasure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t\t'matrix shape mismatch:',\n\t\t\t\tids.length,\n\t\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t\t);\n\t\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t\t}\n\t\t}\n\t\tif (measure.matrixV) {\n\t\t\tmatrixV.forEach((row, i) =>\n\t\t\t\trow.forEach((_, j) => {\n\t\t\t\t\tconst mp = measure.matrixV[ids[i]][ids[j]];\n\t\t\t\t\tif (Number.isFinite(mp)) matrixV[i][j] = mp;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\tenv.measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tif (options.logger) options.logger.info('--- MEASURE', measure.measureIndex, '---', env);\n\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\t\tconst resultEvents = solution.events.map((e) => ({\n\t\t\t...e,\n\t\t\tid: env.ids[e.id], // decode compact ids\n\t\t}));\n\t\tresultEvents.forEach((e) => {\n\t\t\tconst event = measure.events.find((e0) => e0.id === e.id);\n\t\t\tevent.tick = Number.isFinite(e.tick) ? Math.round((e.tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : null;\n\t\t\tevent.tickGroup = e.tickGroup;\n\t\t\tevent.timeWarp = e.timeWarp;\n\t\t});\n\n\t\tmeasure.duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\t\tmeasure.voices = solution.voices.map((voice) => voice.map((id) => env.ids[id]));\n\n\t\tmeasure.solutionStat = {\n\t\t\tloss: solution.loss,\n\t\t\tsolverCredits: solution.credits,\n\t\t\tsolverTimes: solution.times,\n\t\t};\n\n\t\t// full measure rests\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst result = resultEvents.find((e) => e.id === event.id);\n\t\t\tif (!result) return;\n\t\t\telse if (!Number.isFinite(result.tick) && event.rest === 'r' && event.division === 0) {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.rest = 'R';\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t} else if (event.rest === 'R') {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t}\n\t\t});\n\t};\n\n\texport const regulateMeasureWithRectification = async (\n\t\tmeasure: SpartitoMeasure,\n\t\trectification: MeasureRectification,\n\t\t{ solver = null, ...options }: RegulatorOptions\n\t): Promise => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => {\n\t\t\t\tconst re = rectification.events.find((e) => e && e.id === event.id);\n\t\t\t\tconst division = Number.isFinite(re?.division) ? re.division : event.division;\n\t\t\t\tconst dots = Number.isFinite(re?.dots) ? re.dots : event.dots;\n\t\t\t\tconst duration = DURATION_MULTIPLIER * 2 ** -division * (2 - 2 ** -dots);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: event.id,\n\t\t\t\t\tstaff: event.staff,\n\t\t\t\t\tx: event.x,\n\t\t\t\t\ttickEstimated: event.predisposition?.tick,\n\t\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\t\tduration,\n\t\t\t\t\t// the possibility of full measure rest\n\t\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\t\tshrinkness: event.predisposition?.timeWarped || 0,\n\t\t\t\t};\n\t\t\t});\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: e.shrinkness,\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\t\t\t}\n\t\t}\n\n\t\t// copy matrices values from measure topology data\n\t\tconsole.assert(\n\t\t\tmeasure.matrixH && measure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t'matrix shape mismatch:',\n\t\t\tids.length,\n\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t);\n\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t}\n\n\t\tlet measureShrinkness = 0;\n\t\tif (Number.isFinite(measure.estimatedDuration)) measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tconst env = {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\n\t\tconst priority = -solution.loss;\n\n\t\tconst events = solution.events.map(({ id, tick, tickGroup, timeWarp }) => {\n\t\t\tconst re = rectification.events.find((e) => e && e.id === id);\n\t\t\tconst tickN = Number.isFinite(tick) ? Math.round((tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : tick;\n\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\ttick: tickN,\n\t\t\t\ttickGroup,\n\t\t\t\ttimeWarp,\n\t\t\t\tdivision: re?.division,\n\t\t\t\tdots: re?.dots,\n\t\t\t};\n\t\t});\n\n\t\tconst duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\n\t\treturn {\n\t\t\tevents,\n\t\t\tvoices: solution.voices,\n\t\t\tduration,\n\t\t\tpriority,\n\t\t};\n\t};\n}\n\ntype Matrix = number[][];\n\ntype TickMap = Map;\n\ninterface SolutionStatistics {\n\tloss?: number;\n\tsolverCredits?: number;\n\tsolverTimes?: number;\n}\n\nclass SpartitoMeasure extends SimpleClass {\n\tstatic className = 'SpartitoMeasure';\n\tstatic blackKeys = ['staffGroups', 'solutionStat', 'measureNumber', 'deposit'];\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tstaffGroups: number[][];\n\toriginalRegulationHash?: string;\n\tmeasureNumber?: number; // count from the last indent measure, head partial measure is zero, skip empty measures\n\n\tpatched: boolean;\n\tdiscard: boolean;\n\n\tposition: {\n\t\tsystemIndex: number;\n\t\tlocalIndex: number; // the measure local index in its system\n\t\tleft: number;\n\t\tright: number;\n\t\tstaffYs?: number[];\n\t\tstaffYsFull?: number[];\n\t};\n\n\tbackgroundImages: BackgroundImage[];\n\n\tevents: EventTerm[];\n\tendEvent: Partial; // the placeholder for end tick\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n\tindent: boolean;\n\n\tsolutionStat?: SolutionStatistics;\n\n\tmatrixH: Matrix; // matrix N x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n\testimatedDuration: number;\n\n\tgraph: GraphMeasure;\n\n\tdeposit: Record;\n\n\tstatic reorderEvents(events: EventTerm[], staffYsFull: number[]): EventTerm[] {\n\t\tconst HALF_NOTEHEAD = 0.7;\n\n\t\tconst ys = [];\n\n\t\tconst es = events.map((e) => ({\n\t\t\tid: e.id,\n\t\t\tstaff: e.staff,\n\t\t\tx: e.x / HALF_NOTEHEAD,\n\t\t\trx: 0,\n\t\t\try: staffYsFull[e.staff] + e.tipY,\n\t\t\ttipY: e.tipY,\n\t\t\tprior: 0,\n\t\t}));\n\t\tes.sort((e1, e2) => e1.x - e2.x);\n\t\tes.slice(1).forEach((e, i) => {\n\t\t\tconst dx = Math.min(Math.round(e.x - es[i].x), 2);\n\t\t\te.rx = es[i].rx + dx;\n\t\t});\n\t\tes.forEach((e) => {\n\t\t\te.prior = e.staff * 1e4 + e.rx + e.tipY * 0.01;\n\n\t\t\tif (!ys.includes(e.ry)) ys.push(e.ry);\n\t\t});\n\t\tes.sort((e1, e2) => e1.prior - e2.prior);\n\t\tys.sort((y1, y2) => y1 - y2);\n\n\t\tlet yi = 0;\n\t\tconst yis = ys.map((y, i) => {\n\t\t\tif (!i || ys[i] - ys[i - 1] < 0.5) return yi;\n\n\t\t\t++yi;\n\t\t\treturn yi;\n\t\t});\n\n\t\tconst result = es.map((e) => new EventTerm({ ...events.find((ev) => ev.id === e.id), intX: e.rx, intY: yis[ys.indexOf(e.ry)] }));\n\t\tresult.forEach((e, i) => (e.id = i + 1));\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tif (!this.originalRegulationHash && !this.regulated) this.originalRegulationHash = this.regulationHash;\n\n\t\tthis.barTypes = this.barTypes || {};\n\n\t\t// Ensure postRegulate runs for measures deserialized with voices (e.g. from patches/JSON)\n\t\t// to set endEvent and roundX needed for playback cursor positioning.\n\t\tif (this.regulated && this.position) this.postRegulate();\n\t}\n\n\tget timeSignature(): Fraction {\n\t\treturn this.basics && this.basics[0].timeSignature;\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.basics && this.basics[0].keySignature;\n\t}\n\n\tget timeSignatureChanged(): boolean {\n\t\treturn this.contexts.filter(Boolean)[0].some((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type));\n\t}\n\n\tget doubtfulTimesig(): boolean {\n\t\treturn this.basics && this.basics[0].doubtfulTimesig;\n\t}\n\n\tget regulated(): boolean {\n\t\treturn !!this.voices;\n\t}\n\n\tget validRegulated(): boolean {\n\t\tif (!this.voices) return false;\n\n\t\treturn this.voices.flat(1).every((id) => Number.isFinite(this.events.find((e) => e.id === id)?.tick));\n\t}\n\n\tget rows(): EventMeasure[] {\n\t\treturn this.contexts.map((contexts, si) => {\n\t\t\tconst events = this.events.filter((e) => e.staff === si);\n\n\t\t\treturn {\n\t\t\t\tevents,\n\t\t\t\tcontexts,\n\t\t\t};\n\t\t});\n\t}\n\n\tget eventStartX(): number {\n\t\treturn this.events.length ? Math.min(...this.events.map((e) => e.x)) : this.startX;\n\t}\n\n\tget startX(): number {\n\t\treturn this.position.left;\n\t}\n\n\tget width(): number {\n\t\treturn this.position.right - this.position.left;\n\t}\n\n\tget tickMap(): TickMap {\n\t\treturn this.events\n\t\t\t.concat([this.endEvent as EventTerm])\n\t\t\t.filter(Boolean)\n\t\t\t.reduce((map, event) => {\n\t\t\t\tif (Number.isFinite(event.tick)) {\n\t\t\t\t\tif (!map.has(event.tick)) map.set(event.tick, []);\n\n\t\t\t\t\tmap.get(event.tick).push(event);\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}, new Map());\n\t}\n\n\tget tickToX(): { [tick: number]: number } {\n\t\treturn [...this.tickMap.entries()].reduce((map, [tick, events]) => {\n\t\t\tevents = events.filter((e) => !e.fullMeasureRest && !e.grace);\n\t\t\tif (events.length) {\n\t\t\t\tconst x = Math.min(...events.map((e) => e.x));\n\t\t\t\tmap[tick] = x;\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget tickRates(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tevents.sort((e1, e2) => e1.x - e2.x);\n\n\t\treturn events.slice(0, events.length - 1).map((e1, i) => {\n\t\t\tconst e2 = events[i + 1];\n\n\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t});\n\t}\n\n\tget tickRatesInStaves(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(sevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickRatesInGroups(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(gevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickTwist(): number {\n\t\tif (!this.duration || !this.staffGroups) return undefined;\n\n\t\tconst events = this.events.filter(\n\t\t\t(event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !(event.rest && event.division === 0)\n\t\t); // ignore rest0\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst twists = Object.values(gevents).map((es) => {\n\t\t\tconst eventsXOrder = [...es].sort((e1, e2) => e1.pivotX - e2.pivotX);\n\t\t\tconst xSpan = this.position.right - eventsXOrder[0].x;\n\t\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\t\tconst e1 = eventsXOrder[i];\n\t\t\t\tconst dx = e2.pivotX - e1.pivotX;\n\t\t\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\t\t\tif (!dt) return dx / xSpan;\n\n\t\t\t\tconst rate = Math.atan2(dt / this.duration, dx / xSpan);\n\n\t\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t\t});\n\n\t\t\treturn Math.max(0, ...tickTwists);\n\t\t});\n\n\t\treturn Math.max(0, ...twists);\n\t}\n\n\tget eventMap(): Record {\n\t\treturn this.events.reduce((map, event) => {\n\t\t\tmap[event.id] = event;\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget empty(): boolean {\n\t\treturn !this.events?.length || !this.voices?.length;\n\t}\n\n\tget hasIllEvent(): boolean {\n\t\treturn this.regulated && this.events.some((event) => !event.zeroHolder && !Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t}\n\n\tget brief(): string {\n\t\tconst timesig = `${this.timeSignature.numerator}/${this.timeSignature.denominator}`;\n\t\tconst eventBrieves = this.events.map((e) =>\n\t\t\t[\n\t\t\t\te.staff,\n\t\t\t\te.intX,\n\t\t\t\tMath.round(e.tip ? e.tip.y : e.ys?.[0] ?? 0),\n\t\t\t\te.fullMeasureRest ? 0 : e.division,\n\t\t\t\te.fullMeasureRest ? 0 : e.dots,\n\t\t\t\te.rest ? 'r' : '',\n\t\t\t\te.grace || '',\n\t\t\t\te.stemDirection,\n\t\t\t\te.beam || '',\n\t\t\t].join('|')\n\t\t);\n\n\t\treturn [timesig, ...eventBrieves].join('\\n');\n\t}\n\n\tget regulationHash(): string {\n\t\treturn sha1(this.brief);\n\t}\n\n\t// prefer use originalRegulationHash\n\tget regulationHash0(): string {\n\t\treturn this.originalRegulationHash || this.regulationHash;\n\t}\n\n\tget regulationHashes(): string[] {\n\t\treturn Array.from(new Set([this.originalRegulationHash, this.regulationHash].filter(Boolean)));\n\t}\n\n\tget featureWords(): string[][] | null {\n\t\tif (!this.regulated || !this.voices || !this.voices.length) return null;\n\n\t\tconst invalid = this.tickRatesInStaves.some((rate) => rate < 0);\n\n\t\tconst mainEvents = this.events.filter((event) => !event.zeroHolder && !event.rest);\n\n\t\tconst ys = mainEvents\n\t\t\t.map((event) => event.ys)\n\t\t\t.flat(1)\n\t\t\t.map((y) => `Y${-y * 2}`);\n\t\tconst uys = Array.from(new Set(ys));\n\t\tif (this.keySignature) uys.push(`K${this.keySignature}`);\n\n\t\tconst voices = this.voices\n\t\t\t.map((ids) => ids.map((id) => this.events.find((e) => e.id === id)).filter((event) => !event.zeroHolder && !event.rest))\n\t\t\t.filter((voice) => voice.length);\n\n\t\tconst melodies = invalid ? [] : voices.map((es) => es.map((e) => e.scaleChord).join('-'));\n\n\t\tconst rhythm = invalid ? [] : voices.map((es) => es.map((e) => e.division).join(''));\n\t\tif (this.timeSignature) rhythm.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`);\n\n\t\treturn [uys, melodies, rhythm];\n\t}\n\n\tget barType(): MeasureBarType {\n\t\tif (this.voltaEnd) return 'VoltaRight';\n\n\t\tconst typeEntris = Object.entries(this.barTypes).sort((e1, e2) => e2[1] - e1[1]);\n\t\tif (typeEntris[0] && typeEntris[0][1] >= 1) return typeEntris[0][0] as MeasureBarType;\n\n\t\treturn null;\n\t}\n\n\tget partialDuration(): boolean {\n\t\tif (!Number.isFinite(this.duration)) return false;\n\n\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\treturn this.duration < signatureDuration;\n\t}\n\n\tpostRegulate(): void {\n\t\tthis.endEvent = new EventTerm({ tick: this.duration, x: this.position.right });\n\n\t\tthis.updateRoundX();\n\t\tsolveGraceEvents(this);\n\t\tsolveTremoloPairs(this);\n\t\tthis.updateContextTick();\n\t}\n\n\tupdateRoundX(): void {\n\t\tconst tickToX = this.tickToX;\n\t\tif (tickToX)\n\t\t\tthis.events.forEach((event) => {\n\t\t\t\tconst x = tickToX[event.tick];\n\t\t\t\tif (Number.isFinite(x)) event.roundX = x;\n\t\t\t});\n\t}\n\n\tupdateContextTick(): void {\n\t\tif (!this.staffGroups) return;\n\t\tconst contexts = this.contexts.flat(1);\n\t\tthis.staffGroups.flat(1).forEach((staffIndex) => {\n\t\t\tconst terms = [...this.events.filter((e) => e.staff === staffIndex), ...contexts.filter((c) => c.staff === staffIndex)];\n\t\t\tterms.sort((t1, t2) => t2.x - t1.x); // order by x from right to left\n\n\t\t\tlet tick = this.duration;\n\t\t\tterms.forEach((term) => {\n\t\t\t\tif (term instanceof EventTerm) {\n\t\t\t\t\tif (!term.fullMeasureRest && !term.zeroHolder) tick = term.tick;\n\t\t\t\t} else if (term instanceof ContextedTerm) term.tick = tick;\n\t\t\t});\n\t\t});\n\t}\n\n\tasSolution(ref: SpartitoMeasure = undefined): RegulationSolution {\n\t\tif (!this.regulated) return null;\n\n\t\t//let timeSignature = undefined;\n\t\t//if (ref && printFraction(ref.timeSignature) !== printFraction(this.timeSignature)) timeSignature = this.timeSignature;\n\n\t\treturn {\n\t\t\t//timeSignature,\n\t\t\tevents: this.events.map((e) => {\n\t\t\t\tconst se = {\n\t\t\t\t\tid: e.id,\n\t\t\t\t\ttick: e.tick,\n\t\t\t\t\ttickGroup: e.tickGroup,\n\t\t\t\t\ttimeWarp: e.timeWarp,\n\t\t\t\t} as RegulationSolutionEvent;\n\n\t\t\t\tif (ref) {\n\t\t\t\t\tconst refEvent = ref.events.find((re) => re.id === e.id);\n\t\t\t\t\tif (refEvent) {\n\t\t\t\t\t\tif (e.division !== refEvent.division) se.division = e.division;\n\t\t\t\t\t\tif (e.dots !== refEvent.dots) se.dots = e.dots;\n\t\t\t\t\t\tif (e.grace !== refEvent.grace) se.grace = !!e.grace;\n\t\t\t\t\t\tif (e.beam !== refEvent.beam) se.beam = e.beam;\n\t\t\t\t\t\tif (e.fullMeasureRest !== refEvent.fullMeasureRest) se.fullMeasure = e.fullMeasureRest;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn se;\n\t\t\t}),\n\t\t\tvoices: this.voices,\n\t\t\tduration: this.duration,\n\t\t\tpriority: -this.solutionStat?.loss,\n\t\t};\n\t}\n\n\tapplySolution(solution: RegulationSolution): void {\n\t\tif (solution.timeSignature) {\n\t\t\tthis.basics.forEach((basic) => {\n\t\t\t\tbasic.timeSignature = solution.timeSignature;\n\t\t\t\tbasic.doubtfulTimesig = false;\n\t\t\t});\n\t\t}\n\n\t\tthis.voices = solution.voices;\n\t\tthis.duration = solution.duration;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.timeWarp = null;\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\n\t\t\tconst se = solution.events?.find((e) => e.id === event.id);\n\t\t\tif (se) {\n\t\t\t\tevent.tick = se.tick;\n\t\t\t\tevent.timeWarp = se.timeWarp;\n\t\t\t\tevent.tickGroup = se.tickGroup;\n\n\t\t\t\tif (Number.isFinite(se.division)) event.division = se.division;\n\t\t\t\tif (Number.isFinite(se.dots)) event.dots = se.dots;\n\t\t\t\tif (se.beam) event.beam = se.beam as StemBeam;\n\t\t\t\tif (se.grace !== undefined) event.grace = se.grace ? GraceType.Grace : undefined;\n\t\t\t\tif (se.fullMeasure) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tif (Number.isFinite(solution.priority)) this.solutionStat = { loss: -solution.priority };\n\n\t\tthis.postRegulate();\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.voices = null;\n\t\tthis.duration = null;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\t\t\tevent.timeWarp = null;\n\t\t});\n\t}\n\n\tregulateTest(): void {\n\t\tthis.duration = 0;\n\t\tthis.voices = this.rows.map((row) => row.events.map((e) => e.id));\n\t\tthis.voices.forEach((ids) => {\n\t\t\tlet tick = 0;\n\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\t\t\tevents.forEach((e, index) => {\n\t\t\t\te.tickGroup = index;\n\t\t\t\te.tick = tick;\n\n\t\t\t\ttick += e.duration;\n\t\t\t});\n\n\t\t\tthis.duration = Math.max(this.duration, tick);\n\t\t});\n\t}\n\n\tregulateSimple(): void {\n\t\tSimplePolicy.computeMeasureTicks(this);\n\t\tSimplePolicy.computeMeasureVoices(this);\n\t}\n\n\tasync regulateEquations(options: EquationPolicy.RegulatorOptions): Promise {\n\t\tawait EquationPolicy.regulateMeasure(this, options);\n\t}\n\n\t// compute event.tick, event.tickGroup, event.timeWarp, voices, duration\n\tasync regulate({ policy = 'advanced', ...options }: RegulationOptions = {}): Promise {\n\t\tswitch (policy) {\n\t\t\tcase 'test':\n\t\t\t\tthis.regulateTest();\n\n\t\t\t\tbreak;\n\t\t\tcase 'equations':\n\t\t\tcase 'advanced':\n\t\t\t\tawait this.regulateEquations(options);\n\n\t\t\t\tbreak;\n\t\t\tcase 'simple':\n\t\t\tdefault:\n\t\t\t\tthis.regulateSimple();\n\t\t}\n\n\t\tthis.postRegulate();\n\t}\n\n\tcreatePatch(): PatchMeasure {\n\t\treturn new PatchMeasure({\n\t\t\tmeasureIndex: this.measureIndex,\n\t\t\tstaffMask: this.staffMask,\n\t\t\tbasic: this.basics[0],\n\t\t\t//points: [],\n\t\t\tevents: this.events,\n\t\t\tcontexts: this.contexts,\n\t\t\tmarks: this.marks,\n\t\t\tvoices: this.voices,\n\t\t});\n\t}\n\n\tcreateClusters(): EventCluster[] {\n\t\tconst trueEventIds = this.voices && new Set(this.voices.flat(1));\n\n\t\treturn this.staffGroups\n\t\t\t.filter((idx) => idx.length)\n\t\t\t.map((staffIndices) => {\n\t\t\t\tconst staffY0 = this.position.staffYs[0];\n\t\t\t\tconst staffYn = (n) => this.position.staffYs[staffIndices.indexOf(n)] - staffY0;\n\n\t\t\t\tconst events = this.events.filter((event) => staffIndices.includes(event.staff));\n\t\t\t\tif (!events.length) return null;\n\n\t\t\t\tconst elements: EventElement[] = events.map((event) => ({\n\t\t\t\t\tindex: event.id,\n\t\t\t\t\tvoice: (this.voices || []).findIndex((voice) => voice.includes(event.id)),\n\t\t\t\t\ttype: event.rest ? EventElementType.REST : EventElementType.CHORD,\n\t\t\t\t\tstaff: staffIndices.indexOf(event.staff),\n\t\t\t\t\tx: event.tipX,\n\t\t\t\t\tpivotX: event.pivotX,\n\t\t\t\t\ty1: staffYn(event.staff) + (event.stemDirection === 'u' ? event.tipY : event.ys[event.ys.length - 1]),\n\t\t\t\t\ty2: staffYn(event.staff) + (event.stemDirection === 'u' ? event.ys[0] : event.tipY),\n\t\t\t\t\theadY: event.stemDirection === 'u' ? event.ys[0] : event.ys[event.ys.length - 1],\n\t\t\t\t\tfeature: event.feature,\n\t\t\t\t\tdivision: event.division,\n\t\t\t\t\tdots: event.dots,\n\t\t\t\t\tbeam: event.beam || null,\n\t\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\t\tgrace: !!event.grace,\n\t\t\t\t\ttremoloCatcher: event.tremoloCatcher,\n\t\t\t\t\ttimeWarped: !!event.timeWarp,\n\t\t\t\t\tfullMeasure: event.fullMeasureRest,\n\t\t\t\t\ttick: event.tick || 0,\n\t\t\t\t\tfake: !event.fullMeasureRest && !event.grace && this.voices && !trueEventIds.has(event.id), // tremoloCatcher deemed as fake\n\t\t\t\t}));\n\t\t\t\tif (!elements.some((elem) => !elem.fake)) return null;\n\n\t\t\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\t\t\t// BOS & EOS\n\t\t\t\telements.unshift({\n\t\t\t\t\tindex: 0,\n\t\t\t\t\ttype: EventElementType.BOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.left,\n\t\t\t\t\tpivotX: this.position.left,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: this.duration < signatureDuration,\n\t\t\t\t\ttick: 0,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\t\t\t\telements.push({\n\t\t\t\t\tindex: -1,\n\t\t\t\t\ttype: EventElementType.EOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.right,\n\t\t\t\t\tpivotX: this.position.right,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: false,\n\t\t\t\t\ttick: this.duration,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\n\t\t\t\tlet matrixH = null;\n\t\t\t\tif (this.voices) {\n\t\t\t\t\tmatrixH = elements.map(() => elements.map(() => 0));\n\n\t\t\t\t\tthis.voices.forEach((voice) => {\n\t\t\t\t\t\tlet tar = 0;\n\t\t\t\t\t\tvoice.forEach((id) => {\n\t\t\t\t\t\t\tconst src = elements.findIndex((e) => e.index === id);\n\t\t\t\t\t\t\tif (src > 0 && tar >= 0) matrixH[src][tar] = 1;\n\t\t\t\t\t\t\ttar = src;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (tar >= 0) matrixH[elements.length - 1][tar] = 1;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst annotation = { ...this.solutionStat, patched: this.patched };\n\n\t\t\t\tconst backgroundImages =\n\t\t\t\t\tthis.backgroundImages &&\n\t\t\t\t\tthis.backgroundImages.map(({ url, position }) => ({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t...position,\n\t\t\t\t\t\t\ty: position.y - staffY0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\n\t\t\t\treturn new EventCluster({\n\t\t\t\t\tindex: this.measureIndex,\n\t\t\t\t\tduration: this.duration,\n\t\t\t\t\tsignatureDuration,\n\t\t\t\t\tstaffY0,\n\t\t\t\t\telements,\n\t\t\t\t\tmatrixH,\n\t\t\t\t\tannotation,\n\t\t\t\t\tbackgroundImages,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n\n\tapplyClusters(clusters: EventCluster[]): void {\n\t\tconst id_max = this.events.reduce((max, event) => Math.max(max, event.id), 0) + 1;\n\t\tthis.matrixH = Array(id_max + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(id_max).fill(0));\n\n\t\tclusters.forEach((cluster) => {\n\t\t\tconst ids = cluster.elements.map((e) => e.index);\n\t\t\tconsole.assert(cluster.matrixH.length === ids.length - 1, 'unexpected matrixH size:', cluster.matrixH.length, ids.length);\n\n\t\t\tfor (let is = 1; is < ids.length; ++is) {\n\t\t\t\tfor (let it = 0; it < ids.length - 1; ++it) {\n\t\t\t\t\tconst srcId = ids[is] < 0 ? id_max : ids[is];\n\t\t\t\t\tconst tarId = ids[it];\n\n\t\t\t\t\tthis.matrixH[srcId][tarId] = cluster.matrixH[is - 1][it];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// event predisposition\n\t\t\tcluster.elements.forEach((elem) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === elem.index);\n\t\t\t\tif (event) {\n\t\t\t\t\tevent.predisposition = elem.predisposition;\n\t\t\t\t\tif (event.predisposition.grace !== undefined) event.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// estimated measure duration\n\t\tthis.estimatedDuration = clusters.reduce((sum, cluster) => sum + cluster.estimatedDuration, 0) / clusters.length;\n\t}\n}\n\nexport { SpartitoMeasure, EquationPolicy };\n","import { SimpleClass } from './aux_/typedJSON';\nimport { StaffBasic } from './interfaces';\nimport { SemanticPoint } from './semanticPoint';\nimport { EventTerm, ContextedTerm, MarkTerm } from './term';\n\nclass PatchMeasure extends SimpleClass {\n\tstatic className = 'PatchMeasure';\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tbasic: StaffBasic;\n\n\t//points: SemanticPoint[];\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tvoices: number[][]; // [voice, id]\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tObject.assign(this, data);\n\t}\n\n\tget staffN(): number {\n\t\treturn Math.floor(Math.log2(this.staffMask)) + 1;\n\t}\n\n\tget basics(): StaffBasic[] {\n\t\treturn Array(this.staffN).fill(this.basic);\n\t}\n\n\tget duration(): number {\n\t\treturn Math.max(\n\t\t\t0,\n\t\t\t...this.voices.map((ids) => {\n\t\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\n\t\t\t\treturn events.reduce((duration, event) => duration + event.duration, 0);\n\t\t\t})\n\t\t);\n\t}\n}\n\nexport { PatchMeasure };\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Hash, HashVector, cosHashes, hashToHex, hashToBigInt } from './hashVector';\nimport { EventTerm, ContextedTerm, TermPitch, TempoTerm, WHOLE_DURATION } from './term';\nimport { VoicesStaff, VoiceMeasure, TermMeasure, TermVoice, Performing, RegulationOptions } from './interfaces';\nimport { reducedFraction, argmax, noteToPitch, frac, printFraction, fractionMul } from './utils';\nimport { TokenType } from './token';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { Logger, DummyLogger } from './logger';\n\nexport const emptyVoiceFromStaffMeasure = (staff: TermMeasure, chiefVoice: boolean = false): VoiceMeasure => {\n\treturn {\n\t\tempty: true,\n\t\tduration: staff.duration,\n\t\ttickMap: {\n\t\t\t[0]: EventTerm.space({ duration: staff.duration, tick: 0 }),\n\t\t},\n\t\ttimeSignature: staff.timeSignature,\n\t\ttimeSigNumeric: staff.timeSigNumeric,\n\t\tkeySignature: staff.keySignature,\n\t\tcontextedTerms: staff.terms.filter((term) => term instanceof ContextedTerm && (!term.staffLevel || chiefVoice)) as ContextedTerm[],\n\t\tmarks: [],\n\t};\n};\n\nconst removeEmptyMeasuresInVoicesStaves = (staves: VoicesStaff[]): void => {\n\t//console.assert(staves[0] && staves[0].voices[0], 'voices is empty:', staves);\n\tif (!(staves[0] && staves[0].voices[0])) {\n\t\tconsole.warn('empty voices:', staves);\n\t\treturn;\n\t}\n\n\tconst measureCount = staves[0].voices[0].measures.length;\n\tconst measureEmpties = Array(measureCount)\n\t\t.fill(null)\n\t\t.map((_, m) => {\n\t\t\tfor (const staff of staves) {\n\t\t\t\tfor (const voice of staff.voices) {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tif (!measure.empty) return false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\tmeasureEmpties.forEach((empty, m) => {\n\t\tif (empty) {\n\t\t\tstaves.forEach((staff) =>\n\t\t\t\tstaff.voices.forEach((voice) => {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tmeasure.tickMap = {};\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t});\n};\n\nconst markingTiesInVoice = (voice: TermVoice) => {\n\tconst events = [].concat(...voice.measures.map((m) => Object.values(m.tickMap).filter((event) => event instanceof EventTerm)));\n\t//console.log(\"events:\", events);\n\n\tfor (let i = 1; i < events.length; ++i) {\n\t\tconst event0 = events[i - 1];\n\t\tconst event1 = events[i];\n\t\tif (!event0.rest && !event1.rest) {\n\t\t\tif (event0.accessories.some((acc) => acc.type === TokenType.SlurBegin) && event1.accessories.some((acc) => acc.type === TokenType.SlurEnd)) {\n\t\t\t\tconst pitches = event0.pitches.filter((p0) => event1.pitches.some((p1) => p1.note === p0.note && p1.alter === p0.alter));\n\t\t\t\tif (pitches.length > 0) {\n\t\t\t\t\tevent0.tying = true;\n\t\t\t\t\tevent1.tied = true;\n\n\t\t\t\t\tpitches.forEach((p0) => {\n\t\t\t\t\t\tp0.tying = true;\n\t\t\t\t\t\tconst p1 = event1.pitches.find((p1) => p1.note === p0.note && p1.alter === p0.alter);\n\t\t\t\t\t\tp1.tied = true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// remove slurs from accessories\n\t\t\t\t\tpitches.forEach(() => {\n\t\t\t\t\t\tconst si0 = event0.accessories.findIndex((acc) => acc.type === TokenType.SlurBegin);\n\t\t\t\t\t\tif (si0 >= 0) event0.accessories.splice(si0, 1);\n\n\t\t\t\t\t\tconst si1 = event1.accessories.findIndex((acc) => acc.type === TokenType.SlurEnd);\n\t\t\t\t\t\tif (si1 >= 0) event1.accessories.splice(si1, 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nclass Spartito extends SimpleClass {\n\tstatic className = 'Spartito';\n\n\tstavesCount: number;\n\tstaffGroups: number[][];\n\tmeasures: SpartitoMeasure[];\n\n\ttags: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.measures.forEach((measure) => (measure.staffGroups = this.staffGroups));\n\t}\n\n\tget regulated(): boolean {\n\t\treturn this.measures.every((m) => m.regulated);\n\t}\n\n\tget solidMeasureCount(): number {\n\t\treturn this.measures.filter((measure) => !measure.empty).length;\n\t}\n\n\tget measureIndexMapping(): number[] {\n\t\tlet n = 0;\n\t\treturn this.measures.map((measure) => {\n\t\t\treturn !measure.empty ? n++ : null;\n\t\t});\n\t}\n\n\tget headBPM(): number {\n\t\tfor (const measure of this.measures) {\n\t\t\tif (measure.marks) {\n\t\t\t\tconst tempoMark = measure.marks.find((mark) => mark instanceof TempoTerm && mark.isValid()) as TempoTerm;\n\t\t\t\tif (tempoMark) return tempoMark.bpm;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget measureLayoutCode(): string {\n\t\tconst ms = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure, i) => ({\n\t\t\t\tindex: i + 1,\n\t\t\t\tvb: measure.voltaBegin,\n\t\t\t\tve: measure.voltaEnd,\n\t\t\t\talter: measure.alternative,\n\t\t\t\tleftSign: '',\n\t\t\t\trightSign: '',\n\t\t\t}));\n\t\tms.forEach((m, i) => {\n\t\t\tif (m.vb) {\n\t\t\t\tconst nextI = ms.slice(i + 1).findIndex((mm) => mm.vb);\n\t\t\t\tconst nextVBI = nextI >= 0 ? i + nextI : ms.length;\n\t\t\t\tif (ms.slice(i, nextVBI - 1).some((mm) => mm.ve))\n\t\t\t\t\t// check if volta range closed\n\t\t\t\t\tm.leftSign = '2*[';\n\t\t\t}\n\n\t\t\tif (m.ve) {\n\t\t\t\tconst pms = ms.slice(0, i + 1).reverse();\n\t\t\t\tconst lastVEI = pms.slice(1).findIndex((mm) => mm.ve);\n\t\t\t\tif (lastVEI >= 0) {\n\t\t\t\t\tif (!pms.slice(1, lastVEI + 1).some((mm) => mm.vb))\n\t\t\t\t\t\t// ignore unclosed right volta\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.alter) {\n\t\t\t\t\tconst lastMI = pms.findIndex((m) => !m.alter);\n\t\t\t\t\tif (lastMI > 0) {\n\t\t\t\t\t\tpms[lastMI].rightSign = ']';\n\t\t\t\t\t\tpms[lastMI - 1].leftSign = '{[';\n\n\t\t\t\t\t\tm.rightSign = '],';\n\n\t\t\t\t\t\tif (ms[i + 1]) ms[i + 1].rightSign = '},';\n\t\t\t\t\t}\n\t\t\t\t} else m.rightSign = '],';\n\n\t\t\t\tif (!pms.some((m) => m.vb)) ms[0].leftSign = '2*[';\n\t\t\t}\n\t\t});\n\n\t\treturn ms\n\t\t\t.map((m) => m.leftSign + m.index.toString() + m.rightSign + (m.rightSign ? '' : ','))\n\t\t\t.join(' ')\n\t\t\t.replace(/,$/, '');\n\t}\n\n\tget qualityScore(): number {\n\t\tconst measures = this.measures.filter((measure) => !measure.empty);\n\t\tconst qss = measures.map(evaluateMeasure).map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\t//console.log('qss:', qss);\n\n\t\treturn measures.length ? sum / measures.length : null;\n\t}\n\n\tdumpEvaluations(): void {\n\t\tconst es = this.measures.filter((measure) => !measure.empty).map((m) => ({ measureIndex: m.measureIndex, ...evaluateMeasure(m) }));\n\t\tconst qss = es.map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\tconsole.log('qualityScore:', sum / es.length);\n\n\t\tconsole.table(es);\n\t}\n\n\tregulate(options: RegulationOptions = {}): void {\n\t\tthis.measures.forEach((m) => m.regulated || m.regulate(options));\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.measures.forEach((m) => (m.voices = null));\n\t}\n\n\t// measures' estimatedDuration should be valid\n\trectifyTimeSignatures(logger: Logger = new DummyLogger()): void {\n\t\tconst mis = this.measures\n\t\t\t.map((measure, index) => ({ measure, index }))\n\t\t\t.filter(({ measure, index }) => !index || measure.timeSignatureChanged)\n\t\t\t.map(({ index }) => index);\n\t\tconst segments = mis\n\t\t\t.map((index, si) => this.measures.slice(index, si < mis.length - 1 ? mis[si + 1] : this.measures.length))\n\t\t\t.map((ms) => ms.filter((m) => m.estimatedDuration > 0))\n\t\t\t.filter((seg) => seg.length >= 3 || seg.some((measure) => measure.doubtfulTimesig));\n\t\t//console.log(\"segments:\", segments.map(ms => ms.map(m => m.measureIndex)));\n\n\t\tsegments.forEach((measures) => {\n\t\t\tif (measures[0].patched) {\n\t\t\t\t// rectify according to patched head measure\n\t\t\t\tconst newTimeSignature = measures[0].timeSignature;\n\t\t\t\tconst measuresToFix = measures\n\t\t\t\t\t.slice(1)\n\t\t\t\t\t.filter((measure) => !measure.patched && printFraction(measure.timeSignature) !== printFraction(newTimeSignature));\n\t\t\t\tif (measuresToFix.length) {\n\t\t\t\t\tconst originTimeSignature = measuresToFix[0].timeSignature;\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by patched head:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${printFraction(newTimeSignature)}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst originTimeSignature = measures[0].timeSignature;\n\t\t\tconst regularD = Number.isInteger(Math.log2(originTimeSignature.denominator));\n\n\t\t\tlet denominator = regularD ? 4 : 8;\n\t\t\tif (regularD) denominator = Math.max(denominator, measures[0].timeSignature.denominator);\n\n\t\t\tconst numerators = measures.map((measure) => Math.round((measure.estimatedDuration * denominator) / WHOLE_DURATION));\n\t\t\tconst countings = Object.entries(numerators.reduce((c, n) => ((c[n] = (c[n] || 0) + 1), c), {} as Record)).sort(\n\t\t\t\t(p1, p2) => p2[1] - p1[1]\n\t\t\t);\n\t\t\tconst peakCount = countings[0][1];\n\t\t\tconst candidateNumerators = countings.filter(([_, c]) => c > peakCount * 0.6);\n\t\t\tconst bestCounting = candidateNumerators.reduce((best, c) => (Number(c[0]) > Number(best[0]) ? c : best));\n\t\t\tif (bestCounting[1] > 1) {\n\t\t\t\t//console.log(\"countings:\", countings, bestCounting[0]);\n\t\t\t\tlet numerator = Number(bestCounting[0]);\n\t\t\t\tif (!regularD || originTimeSignature.denominator * numerator !== originTimeSignature.numerator * denominator) {\n\t\t\t\t\tif (regularD && denominator !== originTimeSignature.denominator) {\n\t\t\t\t\t\tconst reducedN = (numerator * originTimeSignature.denominator) / denominator;\n\t\t\t\t\t\tif (Number.isInteger(reducedN)) {\n\t\t\t\t\t\t\tnumerator = reducedN;\n\t\t\t\t\t\t\tdenominator = originTimeSignature.denominator;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst measuresToFix = measures.filter((measure) => !measure.patched);\n\n\t\t\t\t\tconst newTimeSignature = frac(numerator, denominator);\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by estimation:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${numerator}/${denominator}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tmakeVoiceStaves(): VoicesStaff[] {\n\t\tthis.regulate();\n\n\t\tconst voiceCount = Math.max(...this.measures.map((measure) => measure.voices.length));\n\t\tif (!voiceCount || !Number.isFinite(voiceCount)) return null;\n\n\t\t// mark tied pitches for patched measues\n\t\tthis.measures\n\t\t\t.filter((measure) => measure.patched)\n\t\t\t.forEach((measure) => {\n\t\t\t\tmeasure.events.forEach((event) => {\n\t\t\t\t\tif (event.tied) event.pitches.forEach((pitch) => (pitch.tied = true));\n\t\t\t\t});\n\t\t\t});\n\n\t\t// [measure, voice]\n\t\tconst measures: VoiceMeasure[][] = this.measures.map((measure /*, mi*/) => {\n\t\t\tconsole.assert(measure.validRegulated, '[makeVoiceStaves] measure is invalid:', measure);\n\n\t\t\tconst eventMap: { [key: number]: EventTerm } = {};\n\t\t\tmeasure.events.forEach((event) => (eventMap[event.id] = event));\n\n\t\t\tconst leftStaves = new Set(\n\t\t\t\tArray(measure.contexts.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, i) => i)\n\t\t\t);\n\n\t\t\tlet bar = null;\n\t\t\tif (measure.barType) {\n\t\t\t\tswitch (measure.barType) {\n\t\t\t\t\tcase 'Segment':\n\t\t\t\t\t\tbar = '||';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Terminal':\n\t\t\t\t\t\tbar = '|.';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst voices: VoiceMeasure[] = measure.voices.map((ids /*, vi*/) => {\n\t\t\t\tconst events = ids.map((id) => eventMap[id]);\n\t\t\t\tevents.sort((e1, e2) => e1.tick - e2.tick);\n\n\t\t\t\tconst tickMap = {};\n\t\t\t\tlet tick = 0;\n\t\t\t\tlet lastEvent = null;\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (!Number.isFinite(event?.tick)) {\n\t\t\t\t\t\tconsole.warn('invalid event tick:', event);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (event.tick > tick) tickMap[tick] = EventTerm.space({ tick, duration: event.tick - tick });\n\t\t\t\t\telse if (!event.grace && event.tick < tick && lastEvent)\n\t\t\t\t\t\tlastEvent.timeWarp = reducedFraction(event.tick - lastEvent.tick, lastEvent.duration);\n\t\t\t\t\t//console.log(\"timewarp:\", event.tick - lastEvent.tick, lastEvent.duration, lastEvent.timeWarp);\n\n\t\t\t\t\ttickMap[event.tick] = event;\n\n\t\t\t\t\tif (!event.zeroHolder) {\n\t\t\t\t\t\ttick = Math.round(event.tick + event.duration);\n\t\t\t\t\t\tlastEvent = event;\n\n\t\t\t\t\t\t// sub grace events\n\t\t\t\t\t\tif (event.graceIds) {\n\t\t\t\t\t\t\tevent.graceIds.forEach((id) => {\n\t\t\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\t\t\tif (grace) tickMap[grace.tick] = grace;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (measure.endEvent && measure.endEvent.graceIds) {\n\t\t\t\t\tmeasure.endEvent.graceIds.forEach((id) => {\n\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\tif (grace && (!lastEvent || grace.staff === lastEvent.staff)) tickMap[grace.tick] = grace;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (tick < measure.duration) tickMap[tick] = EventTerm.space({ tick, duration: measure.duration - tick });\n\t\t\t\telse if (tick > measure.duration && Number.isFinite(measure.duration))\n\t\t\t\t\t//console.warn(\"duration out of range:\", tick, column.duration, mi, vi);\n\t\t\t\t\tlastEvent.timeWarp = reducedFraction(measure.duration - lastEvent.tick, lastEvent.duration);\n\n\t\t\t\tconsole.assert(\n\t\t\t\t\t!lastEvent || !lastEvent.timeWarp || (Number.isInteger(lastEvent.timeWarp.numerator) && Number.isInteger(lastEvent.timeWarp.denominator)),\n\t\t\t\t\t'invalid time warp:',\n\t\t\t\t\tlastEvent\n\t\t\t\t);\n\n\t\t\t\tconst staffIndex = events[0] ? events[0].staff : 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\n\t\t\t\t//const row = measure.rows[staffIndex];\n\t\t\t\tconst contextedTerms = measure.contexts[staffIndex];\n\n\t\t\t\tconst tailEvent = events[events.length - 1];\n\t\t\t\tconst tailStaff = tailEvent ? tailEvent.staff : 0;\n\n\t\t\t\t// TODO: modify full measure rests duration\n\n\t\t\t\treturn {\n\t\t\t\t\ttickMap,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t...basic,\n\t\t\t\t\t// TODO: consider staff altered voice\n\t\t\t\t\tcontextedTerms,\n\t\t\t\t\tmarks: [],\n\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\theadStaff: staffIndex,\n\t\t\t\t\ttailStaff,\n\t\t\t\t\tbar,\n\t\t\t\t};\n\t\t\t});\n\n\t\t\twhile (voices.length < voiceCount) {\n\t\t\t\tconst staffIndex = leftStaves.values().next().value || 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\t\t\t\tconst terms = measure.contexts[staffIndex];\n\n\t\t\t\tconst chiefVoice = voices.every((voice) => voice.headStaff !== staffIndex);\n\n\t\t\t\tconst voice = emptyVoiceFromStaffMeasure(\n\t\t\t\t\t{\n\t\t\t\t\t\tterms,\n\t\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t\t...basic,\n\t\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\t},\n\t\t\t\t\tchiefVoice\n\t\t\t\t);\n\t\t\t\tvoice.headStaff = staffIndex;\n\t\t\t\tvoice.tailStaff = staffIndex;\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\n\t\t\treturn voices;\n\t\t});\n\t\t//console.log(\"measures:\", measures);\n\n\t\t// compute traits for voice-measures\n\t\tmeasures.forEach((voices) =>\n\t\t\tvoices.forEach((measure) => {\n\t\t\t\tconst words = [];\n\n\t\t\t\tif (!measure.empty) {\n\t\t\t\t\twords.push(`s${measure.headStaff}`);\n\t\t\t\t\twords.push(`s${measure.tailStaff}`);\n\t\t\t\t}\n\n\t\t\t\tObject.values(measure.tickMap).forEach((event) => {\n\t\t\t\t\tif (event instanceof EventTerm) {\n\t\t\t\t\t\twords.push(`s${event.staff}`);\n\n\t\t\t\t\t\tif (event.stemDirection) {\n\t\t\t\t\t\t\tconst sd = `st${event.staff}-${event.stemDirection}`;\n\t\t\t\t\t\t\twords.push(sd, sd);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.grace) words.push(`gd${event.mainDuration}`);\n\t\t\t\t\t\telse words.push(`d${event.mainDuration}`);\n\n\t\t\t\t\t\tif (event.rest) words.push('r-' + event.rest);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tevent.pitches.forEach((pitch) => {\n\t\t\t\t\t\t\t\twords.push(`p1-${pitch.note}`);\n\t\t\t\t\t\t\t\twords.push(`p8-${Math.round(pitch.note / 8)}`);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmeasure.trait = HashVector.fromWords(words);\n\t\t\t})\n\t\t);\n\t\t//console.log(\"measure traits:\");\n\t\t//console.table(measures.map(voices => voices.map(measure => hashToHex(measure.trait.toHash()))));\n\n\t\tconst staffToGroup: Record = this.staffGroups\n\t\t\t.flat(1)\n\t\t\t.reduce((map, si) => ((map[si] = this.staffGroups.findIndex((group) => group.includes(si))), map), {});\n\n\t\t// sort voices to connect voices between neighhoring measures\n\t\tconst voiceTraits = Array(voiceCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => ({ vector: HashVector.zero, index, weight: 0, headStaff: null }));\n\t\tmeasures.forEach((voices, mi) => {\n\t\t\tvoiceTraits.sort((v1, v2) => v2.weight - v1.weight);\n\n\t\t\tconst leftVoices = new Set(voices);\n\t\t\tvoiceTraits.forEach((voiceTrait) => {\n\t\t\t\tconst vs = [...leftVoices];\n\t\t\t\tlet measure = vs[0];\n\t\t\t\tif (mi > 0 && vs.length > 1) {\n\t\t\t\t\tconst consistencies = vs.map((measure) =>\n\t\t\t\t\t\tstaffToGroup[measure.headStaff] === staffToGroup[voiceTrait.headStaff]\n\t\t\t\t\t\t\t? cosHashes(voiceTrait.vector.toHash(), measure.trait.toHash())\n\t\t\t\t\t\t\t: -1\n\t\t\t\t\t);\n\t\t\t\t\tmeasure = vs[argmax(consistencies)];\n\t\t\t\t}\n\t\t\t\tleftVoices.delete(measure);\n\n\t\t\t\tmeasure.voiceIndex = voiceTrait.index;\n\t\t\t\tvoiceTrait.vector.scale(0.4).add(measure.trait);\n\n\t\t\t\tvoiceTrait.weight = Object.keys(measure.tickMap).length;\n\n\t\t\t\tif (mi === 0) voiceTrait.headStaff = measure.headStaff;\n\t\t\t});\n\n\t\t\tvoices.sort((m1, m2) => m1.voiceIndex - m2.voiceIndex);\n\t\t});\n\n\t\t//const staffTraits = Array(this.stavesCount).fill(null).map((_, si) => HashVector.fromString(`s${si}`).toHash());\n\t\tconst staffVoiceIndices = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map(() => []);\n\t\tvoiceTraits.forEach((trait) => {\n\t\t\t//const consistencies = staffTraits.map(staff => cosHashes(trait.vector.toHash(), staff));\n\t\t\t//staffVoiceIndices[argmax(consistencies)].push(trait.index);\n\t\t\tstaffVoiceIndices[trait.headStaff].push(trait.index);\n\t\t});\n\n\t\tconst staves = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, si) => {\n\t\t\t\tif (!measures[0]) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvoices: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t//const voiceIndicies = measures[0].map((voice, vi) => ({ voice, vi })).filter(({ voice }) => voice.headStaff === si).map(({ vi }) => vi);\n\t\t\t\tconst voiceIndicies = staffVoiceIndices[si];\n\n\t\t\t\tconst voices = voiceIndicies.map((vi): TermVoice => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmode: 'relative',\n\t\t\t\t\t\tmeasures: measures.map((m) => m[vi]),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\treturn { voices };\n\t\t\t});\n\n\t\tremoveEmptyMeasuresInVoicesStaves(staves);\n\t\tstaves.forEach((staff) => staff.voices.forEach(markingTiesInVoice));\n\n\t\treturn staves;\n\t}\n\n\tperform(): Performing {\n\t\tconst staves = this.makeVoiceStaves();\n\t\tif (!staves) return null;\n\n\t\tconst tokenMap = new Map();\n\n\t\t// TODO: store staff channels in score\n\t\tconst staffToChannel = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.reduce((map, _, i) => {\n\t\t\t\tmap[i] = i;\n\t\t\t\treturn map;\n\t\t\t}, {});\n\n\t\tconst voiceChannels = [].concat(...staves.map((staff, si) => staff.voices.map(() => staffToChannel[si])));\n\n\t\tlet hasTempo = false;\n\n\t\tlet nextTick = 0;\n\t\tlet events0 = null;\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure) => {\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst voices: VoiceMeasure[] = [].concat(...staves.map((staff) => staff.voices.map((voice) => voice.measures[measureIndex])));\n\t\t\t\tconst voice0 = voices[0];\n\t\t\t\tconst tick = nextTick;\n\n\t\t\t\t//const signatureDuration = (WHOLE_DURATION * voice0.timeSignature.numerator) / voice0.timeSignature.denominator;\n\n\t\t\t\tnextTick += voice0.duration;\n\n\t\t\t\tconst notes = [].concat(\n\t\t\t\t\t...voices.map((measure, vi) => {\n\t\t\t\t\t\tconst tickFactor = 1; //measure.duration ? signatureDuration / measure.duration : 1;\n\n\t\t\t\t\t\tconst channel = voiceChannels[vi];\n\n\t\t\t\t\t\tconst chords = Object.values(measure.tickMap)\n\t\t\t\t\t\t\t.filter((term) => term instanceof EventTerm && !term.rest)\n\t\t\t\t\t\t\t.map((term: EventTerm) => {\n\t\t\t\t\t\t\t\tconst duration = Math.round(term.duration * tickFactor);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(term.tick), 'invalid event term tick:', term);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(duration), 'invalid event term duration:', term);\n\n\t\t\t\t\t\t\t\tif (term.tick >= 0) {\n\t\t\t\t\t\t\t\t\t// exclude minus tick tokens\n\t\t\t\t\t\t\t\t\tterm.noteIds.forEach((id) => {\n\t\t\t\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: term.roundX,\n\t\t\t\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(term.staff));\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttick: Math.round(term.tick * tickFactor),\n\t\t\t\t\t\t\t\t\tduration,\n\t\t\t\t\t\t\t\t\tpitches: term.pitches,\n\t\t\t\t\t\t\t\t\tnoteIds: term.noteIds,\n\t\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\t\tstaff: term.staff,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t\t...chords.map((chord) => {\n\t\t\t\t\t\t\t\t// exclude repeated pitches\n\t\t\t\t\t\t\t\tconst pitchMap: { [pitch: number]: TermPitch } = chord.pitches.reduce((map, pitch) => {\n\t\t\t\t\t\t\t\t\tmap[noteToPitch(pitch)] = pitch;\n\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t}, {});\n\t\t\t\t\t\t\t\tconst pitches = Object.values(pitchMap).sort((p1, p2) => p1.note - p2.note);\n\n\t\t\t\t\t\t\t\treturn pitches\n\t\t\t\t\t\t\t\t\t.filter((pitch) => !pitch.tied)\n\t\t\t\t\t\t\t\t\t.map((pitch, i) => {\n\t\t\t\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\ttick: chord.tick,\n\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\t\t\t\ttrack: chord.part,\n\t\t\t\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\t\t\t\tchannel,\n\t\t\t\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst events = [];\n\t\t\t\tevents0 = events0 || events;\n\n\t\t\t\tif (measure.marks)\n\t\t\t\t\tmeasure.marks.forEach((mark) => {\n\t\t\t\t\t\tif (mark instanceof TempoTerm) {\n\t\t\t\t\t\t\tconst bpm = mark.bpm;\n\t\t\t\t\t\t\tif (mark.isValid()) {\n\t\t\t\t\t\t\t\tconst es = hasTempo ? events : events0; // set the first tempo to the beginning of the track\n\t\t\t\t\t\t\t\tconst tick = hasTempo ? mark.tick : 0;\n\t\t\t\t\t\t\t\tes.push({\n\t\t\t\t\t\t\t\t\ttrack: 0,\n\t\t\t\t\t\t\t\t\tticks: tick,\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\t\t\t\t\t\tmicrosecondsPerBeat: Math.round(60e6 / bpm),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\thasTempo = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents,\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tif (!hasTempo) {\n\t\t\tmeasures[0].events.push({\n\t\t\t\ttrack: 0,\n\t\t\t\tticks: 0,\n\t\t\t\tdata: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\tmicrosecondsPerBeat: 0.5e6, // TODO\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tperformByEstimation(): Performing {\n\t\tconst tokenMap = new Map();\n\t\tlet nextTick = 0;\n\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => measure.events.some((event) => event.predisposition))\n\t\t\t.map((measure) => {\n\t\t\t\tconst tick = nextTick;\n\t\t\t\tconst duration = Math.round(measure.estimatedDuration || fractionMul(WHOLE_DURATION, measure.timeSignature));\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\tnextTick += duration;\n\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst chords = measure.events.filter((event) => event.predisposition && event.predisposition.fake < 0.5 && !event.rest);\n\t\t\t\tconst notes = chords\n\t\t\t\t\t.map((chord) => {\n\t\t\t\t\t\tconst noteTick = Math.round(chord.predisposition.tick);\n\n\t\t\t\t\t\tchord.noteIds.forEach((id) => {\n\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\tx: chord.roundX,\n\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn chord.pitches.map((pitch, i) => {\n\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(chord.staff));\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttick: noteTick,\n\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\ttrack: part,\n\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\tchannel: 0,\n\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.flat(1);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents: [],\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tfeatureHash(): Hash {\n\t\tconst headMeasures = this.measures.slice(0, 16);\n\t\tconst measureWords = headMeasures.map((measure) => measure.featureWords);\n\n\t\tconst levels = [1, 4, 16].map((len) => {\n\t\t\tconst meaures = measureWords.slice(0, len).filter(Boolean);\n\t\t\tconst ys = meaures.map((words) => words[0]).flat(1);\n\t\t\tconst melodies = meaures.map((words) => words[1]).flat(1);\n\t\t\tconst rhythm = meaures.map((words) => words[2]).flat(1);\n\n\t\t\tconst [vecY, vecMelody, vecRhythm] = [ys, melodies, rhythm].map(HashVector.fromWords);\n\n\t\t\treturn HashVector.concat(vecY, vecMelody.sub(128), vecRhythm.sub(128));\n\t\t});\n\n\t\treturn HashVector.concat(...levels).toHash();\n\t}\n\n\tfeatureHashHex(): string {\n\t\treturn hashToHex(this.featureHash());\n\t}\n\n\tfeatureHashBigInt(): bigint {\n\t\treturn hashToBigInt(this.featureHash());\n\t}\n\n\tassignMeasureNumbers(): void {\n\t\tlet n = null as any;\n\t\tfor (const measure of this.measures) {\n\t\t\tif (!measure.discard && !measure.events.length) continue;\n\n\t\t\tif (measure.indent) n = null;\n\n\t\t\tif (!Number.isFinite(n)) n = measure.partialDuration ? 0 : 1;\n\n\t\t\tmeasure.measureNumber = n++;\n\t\t}\n\t}\n}\n\nexport { SpartitoMeasure, Spartito };\n","import { Fraction } from './interfaces';\nimport { ContextedTerm, ContextType } from './term';\nimport { Logger, DummyLogger } from './logger';\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nexport const mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst PHONETS = 'CDEFGAB';\n\nconst ALTER_NAMES = {\n\t[-2]: '\\u266D\\u266D',\n\t[-1]: '\\u266D',\n\t[0]: '\\u266E',\n\t[1]: '\\u266F',\n\t[2]: '\\uD834\\uDD2A',\n};\n\n/*\n\tCoordinates:\n\n\t\tnote:\n\t\t\tzero: the middle C line (maybe altered)\n\t\t\tpositive: high (right on piano keyboard)\n\t\t\tunit: a step in scales of the current staff key\n\n\t\tstaff Y:\n\t\t\tzero: the third (middle) line among 5 staff lines\n\t\t\tpositive: down\n\t\t\tunit: a interval between 2 neighbor staff lines\n*/\n\nexport default class StaffContext {\n\tlogger: Logger = new DummyLogger();\n\n\tclef: number = -3;\n\tkeyAlters: number[] = [];\n\toctaveShift: number = 0;\n\talters: number[] = [];\n\n\ttimeSignature: Fraction = {\n\t\tnumerator: 4,\n\t\tdenominator: 4,\n\t};\n\ttimeSigNumeric: boolean = false;\n\ttimeSigNumSet: boolean = false;\n\ttimeSigDenSet: boolean = false;\n\tdoubtingTimesig: boolean = true;\n\n\tchange(term: ContextedTerm) {\n\t\tswitch (term.type) {\n\t\t\tcase ContextType.Clef:\n\t\t\t\tthis.clef = term.clef;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.KeyAcc:\n\t\t\t\tthis.keyAlters[mod7(this.yToNote(term.y))] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.Acc:\n\t\t\t\tthis.alters[this.yToNote(term.y)] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.OctaveShift:\n\t\t\t\tthis.octaveShift = term.octaveShift;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureC:\n\t\t\t\tthis.timeSigNumeric = false;\n\t\t\t\tswitch (term.tokenType) {\n\t\t\t\t\tcase 'timesig-C44':\n\t\t\t\t\t\tthis.timeSignature.numerator = 4;\n\t\t\t\t\t\tthis.timeSignature.denominator = 4;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'timesig-C22':\n\t\t\t\t\t\tthis.timeSignature.numerator = 2;\n\t\t\t\t\t\tthis.timeSignature.denominator = 2;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureN:\n\t\t\t\tthis.timeSigNumeric = true;\n\t\t\t\tswitch (term.y) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tif (this.timeSigDenSet) this.timeSignature.denominator = this.timeSignature.denominator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.denominator = term.number;\n\n\t\t\t\t\t\tthis.timeSigDenSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase -1:\n\t\t\t\t\t\tif (this.timeSigNumSet) this.timeSignature.numerator = this.timeSignature.numerator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.numerator = term.number;\n\n\t\t\t\t\t\tthis.timeSigNumSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.logger.warn('unexpected time signature Y:', term.y);\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tresetMeasure() {\n\t\tthis.alters = [];\n\n\t\tthis.timeSigNumSet = false;\n\t\tthis.timeSigDenSet = false;\n\t}\n\n\tresetSystem() {\n\t\tthis.keyAlters = [];\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.keyAlters.filter((a) => Number.isInteger(a)).reduce((sum, a) => sum + a, 0);\n\t}\n\n\tget partialTimeSignature(): boolean {\n\t\treturn !this.timeSigNumSet !== !this.timeSigDenSet;\n\t}\n\n\tnoteToY(note: number): number {\n\t\treturn -note / 2 - this.clef - this.octaveShift * 3.5;\n\t}\n\n\tpitchToNote(pitch: number, { preferredAlter = null } = {}): { note: number; alter: number } {\n\t\tif (!preferredAlter) preferredAlter = this.keySignature < 0 ? -1 : 1;\n\n\t\tconst group = Math.floor((pitch - MIDDLE_C) / 12);\n\t\tconst gp = mod12(pitch);\n\t\tconst alteredGp = GROUP_N_TO_PITCH.includes(gp) ? gp : mod12(gp - preferredAlter);\n\t\tconst gn = GROUP_N_TO_PITCH.indexOf(alteredGp);\n\t\tthis.logger.assert(gn >= 0, 'invalid preferredAlter:', pitch, preferredAlter, alteredGp);\n\n\t\tconst naturalNote = group * 7 + gn;\n\n\t\tconst alterValue = gp - alteredGp;\n\t\tconst keyAlterValue = this.keyAlters[gn] || 0;\n\t\tconst onAcc = Number.isInteger(this.alters[naturalNote]);\n\n\t\tconst alter = onAcc ? alterValue : alterValue === keyAlterValue ? null : alterValue;\n\n\t\treturn { note: naturalNote, alter };\n\t}\n\n\tpitchToY(pitch: number, { preferredAlter = null } = {}): { y: number; alter: number } {\n\t\tconst { note, alter } = this.pitchToNote(pitch, { preferredAlter });\n\t\tconst y = this.noteToY(note);\n\n\t\treturn { y, alter };\n\t}\n\n\tyToNote(y: number): number {\n\t\tthis.logger.assert(Number.isInteger(y * 2), 'invalid y:', y);\n\n\t\treturn (-y - this.octaveShift * 3.5 - this.clef) * 2;\n\t}\n\n\talterOnNote(note: number): number {\n\t\tif (Number.isInteger(this.alters[note])) return this.alters[note];\n\n\t\tconst gn = mod7(note);\n\t\tif (Number.isInteger(this.keyAlters[gn])) return this.keyAlters[gn];\n\n\t\treturn 0;\n\t}\n\n\tnoteToPitch(note: number): number {\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tconst pitch = MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + this.alterOnNote(note);\n\t\tif (!Number.isFinite(pitch)) {\n\t\t\tthis.logger.warn('invalid pitch value:', pitch, note, group, gn);\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn pitch;\n\t}\n\n\tyToPitch(y: number): number {\n\t\treturn this.noteToPitch(this.yToNote(y));\n\t}\n\n\tyToPitchName(y: number): string {\n\t\tconst note = this.yToNote(y);\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tlet alter = this.alterOnNote(note);\n\t\tif (!alter && !Number.isInteger(this.alters[note])) alter = null;\n\n\t\treturn `${ALTER_NAMES[alter] ? ALTER_NAMES[alter] : ''}${PHONETS[gn]}${group + 4}`;\n\t}\n}\n","import sha1 from 'js-sha1';\n\nimport * as measureLayout from '../measureLayout';\nimport * as staffLayout from '../staffLayout';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventSystem, MeasureBrief, MusicSheet, RecognitionSettings, ScoreData, TermMeasure, TermStaff, VoicesStaff } from './interfaces';\nimport { DummyLogger, Logger } from './logger';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { PatchMeasure } from './patch';\nimport { Measure, Page, Staff, System } from './scoreComponents';\nimport { hashSemanticPoint, SemanticPoint, SemanticType } from './semanticPoint';\nimport { BOS_ELEMENT, fractionToElems, SemanticCluster, SemanticElement, SemanticElementType } from './semanticTopology';\nimport { Spartito, SpartitoMeasure } from './spartito';\nimport StaffContext from './staffContext';\nimport { ContextedTerm, ContextType, EventTerm, WHOLE_DURATION } from './term';\nimport type { SemanticPointInMeasure } from './timewiseGraph';\nimport { TimewiseGraph } from './timewiseGraph';\nimport { Token, TokenType } from './token';\nimport { distance2D, solveOverlapping } from './utils';\n\nexport const VERSION = 14;\n\ninterface Topology {\n\tclusters: SemanticCluster[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n}\n\nconst GRAND_STAFF_LAYOUT = '{-}';\n\nconst processStaffContext = (staff: TermStaff, logger: Logger = new DummyLogger()): void => {\n\tconst context = new StaffContext();\n\tcontext.logger = logger;\n\n\tfor (const row of staff.rows) {\n\t\tfor (const measure of row) {\n\t\t\tconst startEvent = measure.terms.find((term) => term instanceof EventTerm) as EventTerm;\n\t\t\tlet tick = startEvent ? Math.min(startEvent.tick, 0) : 0;\n\n\t\t\tmeasure.terms.forEach((term) => {\n\t\t\t\tif (term instanceof ContextedTerm) {\n\t\t\t\t\tterm.tick = tick; // TODO: not working here because measure not regulated yet\n\t\t\t\t\tcontext.change(term);\n\t\t\t\t} else if (term instanceof EventTerm) {\n\t\t\t\t\tconst endTick = term.tick + (term.duration || 0);\n\t\t\t\t\tif (endTick > tick) tick = endTick;\n\n\t\t\t\t\tif (term.ys) {\n\t\t\t\t\t\tterm.pitches = term.ys.map((y) => {\n\t\t\t\t\t\t\tconst note = context.yToNote(y);\n\t\t\t\t\t\t\tconst alter = context.alterOnNote(note);\n\n\t\t\t\t\t\t\treturn { note, alter, octaveShift: context.octaveShift };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tmeasure.timeSignature = { ...context.timeSignature };\n\t\t\tmeasure.timeSigNumeric = context.timeSigNumeric;\n\t\t\tmeasure.doubtfulTimesig =\n\t\t\t\tcontext.doubtingTimesig ||\n\t\t\t\t!Number.isInteger(Math.log2(measure.timeSignature.denominator)) ||\n\t\t\t\tmeasure.timeSignature.numerator <= measure.timeSignature.denominator / 4;\n\n\t\t\tmeasure.keySignature = context.keySignature;\n\n\t\t\t// fill empty measure duration\n\t\t\tif (measure.duration === 0) measure.duration = (WHOLE_DURATION * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\n\t\t\tcontext.resetMeasure();\n\t\t}\n\n\t\tcontext.resetSystem();\n\t}\n};\n\nconst upgradeScoreData = (data: ScoreData): ScoreData => {\n\tif (data.version < 3) {\n\t\tconst { version, stavesCount, layoutTemplate, ...fields } = data;\n\t\tvoid version;\n\t\tvoid layoutTemplate;\n\n\t\tlet staffLayoutCode =\n\t\t\tstavesCount > 1\n\t\t\t\t? Array(stavesCount - 1)\n\t\t\t\t\t\t.fill(',')\n\t\t\t\t\t\t.join('')\n\t\t\t\t: '';\n\n\t\t// use graph staff by default for 2 staves score\n\t\tif (stavesCount === 2) staffLayoutCode = '{-}';\n\n\t\tdata = {\n\t\t\tversion: 3,\n\t\t\tstaffLayoutCode,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tif (data.version < 8) {\n\t\t// upgrade system measure bar semantics\n\t\tdata.pages.forEach((page) => {\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tif (system.semantics) {\n\t\t\t\t\tconst bars = system.semantics.filter((point) => point.semantic === SemanticType.vline_BarMeasure);\n\n\t\t\t\t\tsystem.semantics = [].concat(\n\t\t\t\t\t\t...system.staves.map((staff) => {\n\t\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\n\t\t\t\t\t\t\treturn bars.map((point) => ({\n\t\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\t\ty: point.y + oy,\n\t\t\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\t\t\t...point.extension,\n\t\t\t\t\t\t\t\t\ty1: point.extension.y1 + oy,\n\t\t\t\t\t\t\t\t\ty2: point.extension.y2 + oy,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tdata.version = 8;\n\t}\n\n\tif (data.version < 9) {\n\t\t// remove old format spartito\n\t\tdata.spartito = null;\n\n\t\tdata.version = 9;\n\t}\n\n\treturn data;\n};\n\nconst bitsToMask = (bits: number[]): number => bits.reduce((mask, bit, i) => (bit ? mask | (1 << i) : mask), 0);\n\ninterface PointPosition {\n\tpoint: SemanticPoint;\n\tpageIndex: number;\n\tsystemIndex: number;\n\tstaffIndex: number;\n}\n\ninterface MeasureValidation {\n\ttickMap: { [tick: number]: number };\n}\n\ninterface Size {\n\twidth: number;\n\theight: number;\n}\n\nclass Score extends SimpleClass {\n\tstatic className = 'Score';\n\n\tversion = VERSION;\n\n\ttitle: string;\n\t// in pixels\n\tpageSize: Size;\n\tunitSize: number;\n\tstaffLayoutCode: string;\n\n\tpaperOptions?: Partial;\n\n\theaders: { [key: string]: string };\n\n\ttextAnnotations: { [id: string]: string };\n\n\ttags?: string[];\n\n\tinstrumentDict: { [key: string]: string };\n\n\tpages: Page[];\n\ttopology: Topology;\n\tspartito?: Spartito;\n\n\tpatches?: PatchMeasure[];\n\n\tsettings: RecognitionSettings;\n\n\tconstructor(data: ScoreData) {\n\t\tsuper();\n\t\tsuper.assign(upgradeScoreData(data));\n\n\t\tthis.pages = this.pages || [];\n\t\tthis.headers = this.headers || {};\n\t\tthis.instrumentDict = this.instrumentDict || {};\n\n\t\tthis.pageSize = this.pageSize || {\n\t\t\t// A4 paper\n\t\t\twidth: 794,\n\t\t\theight: 1122,\n\t\t};\n\n\t\tthis.unitSize = this.unitSize || null;\n\n\t\tthis.staffLayoutCode = this.staffLayoutCode || (this.maxStavesCount === 2 ? GRAND_STAFF_LAYOUT : Array(this.maxStavesCount).fill('').join(','));\n\t}\n\n\tget systems(): System[] {\n\t\treturn [].concat(...this.pages.map((page) => page.systems));\n\t}\n\n\tget measureCount(): number {\n\t\treturn this.systems.reduce((sum, system) => sum + (system.measureCount || 0), 0);\n\t}\n\n\tget imageKeys(): string[] {\n\t\treturn [\n\t\t\t...this.pages.map((page) => page.source?.url),\n\t\t\t...this.systems.map((system) => system.backgroundImage),\n\t\t\t...[].concat(\n\t\t\t\t...this.systems.map((system) =>\n\t\t\t\t\t[...system.staves.map((staff) => staff.backgroundImage), ...system.staves.map((staff) => staff.maskImage)].filter(Boolean)\n\t\t\t\t)\n\t\t\t),\n\t\t].filter(Boolean);\n\t}\n\n\tget breakSystemIndices(): number[] {\n\t\tconst indices = [];\n\t\tlet systemCount = 0;\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tif (i < this.pages.length - 1) {\n\t\t\t\tsystemCount += page.systems.length;\n\t\t\t\tindices.push(systemCount - 1);\n\t\t\t}\n\t\t});\n\n\t\treturn indices;\n\t}\n\n\tget staffLayout(): staffLayout.StaffLayout {\n\t\treturn staffLayout.parseCode(this.staffLayoutCode);\n\t}\n\n\tget measureLayoutCode(): string {\n\t\treturn this.spartito?.measureLayoutCode;\n\t}\n\n\tget maxStavesCount(): number {\n\t\treturn Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget semanticHash(): string {\n\t\tconst ids = [].concat(\n\t\t\t...this.systems.map((system) =>\n\t\t\t\t[].concat(...system.staves.map((staff) => (staff.semantics ? system.qualifiedSemantics(staff.semantics).map((s) => s.id) : [])))\n\t\t\t)\n\t\t);\n\t\treturn sha1(ids.join(''));\n\t}\n\n\teventSystemsToTermStaves(eventSystems: EventSystem[], logger: Logger = new DummyLogger()): TermStaff[] {\n\t\t// [staff]\n\t\tconst termStaves: TermStaff[] = Array(this.maxStavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, staffIndex): TermStaff => {\n\t\t\t\treturn {\n\t\t\t\t\t// [system, measure]\n\t\t\t\t\trows: eventSystems.map((sys, i) =>\n\t\t\t\t\t\tsys.columns.map((column, ii): TermMeasure => {\n\t\t\t\t\t\t\tconst measure = column.rows[staffIndex];\n\t\t\t\t\t\t\tconsole.assert(measure, '[eventSystemsToTermStaves] measure is null:', staffIndex, column.rows);\n\n\t\t\t\t\t\t\tconst contexts = measure.contexts;\n\n\t\t\t\t\t\t\t// prepend octave shift 0 at begin of every system\n\t\t\t\t\t\t\tif (ii === 0) {\n\t\t\t\t\t\t\t\tif (!contexts.some((term) => term.type === ContextType.OctaveShift)) {\n\t\t\t\t\t\t\t\t\tcontexts.unshift(\n\t\t\t\t\t\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\t\t\t\t\t\tstaff: staffIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\t\t\t\ttokenType: TokenType.OctaveShift0,\n\t\t\t\t\t\t\t\t\t\t\ttick: 0,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst terms = [...(measure.events || []), ...contexts].sort((t1, t2) => t1.x - t2.x);\n\n\t\t\t\t\t\t\tconst pageBreak = staffIndex === 0 && ii === sys.columns.length - 1 && this.breakSystemIndices.includes(i);\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tterms,\n\t\t\t\t\t\t\t\t//xToTick: column.xToTick,\n\t\t\t\t\t\t\t\tduration: column.duration,\n\t\t\t\t\t\t\t\tpageBreak,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\ttermStaves.forEach((staff) => processStaffContext(staff, logger));\n\n\t\treturn termStaves;\n\t}\n\n\tresetPageLayout(parameters: { unitSize?: number; pageSize?: Size }) {\n\t\tconst { unitSize = this.unitSize, pageSize = this.pageSize } = parameters;\n\n\t\tconst newCenter = {\n\t\t\tx: (pageSize.width * 0.5) / unitSize,\n\t\t\ty: (pageSize.height * 0.5) / unitSize,\n\t\t};\n\n\t\tthis.pages.forEach((page) => {\n\t\t\tconst offsetX = newCenter.x - page.width / 2;\n\t\t\tconst offsetY = newCenter.y - page.height / 2;\n\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tsystem.left += offsetX;\n\t\t\t\tsystem.top += offsetY;\n\t\t\t});\n\n\t\t\tif (page.semantics) {\n\t\t\t\tpage.semantics.forEach((point) => {\n\t\t\t\t\tpoint.x += offsetX;\n\t\t\t\t\tpoint.y += offsetY;\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpage.width = pageSize.width / unitSize;\n\t\t\tpage.height = pageSize.height / unitSize;\n\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations });\n\t\t});\n\n\t\tthis.unitSize = unitSize;\n\t\tthis.pageSize = pageSize;\n\t}\n\n\tgetMeasure(measureIndex: number): {\n\t\tmeasureIndex: number;\n\t\tsystem: System;\n\t\tlocalIndex: number;\n\t\tleft: number;\n\t\tright: number;\n\t\tmeasures: Measure[];\n\t} {\n\t\tlet index = measureIndex;\n\t\tfor (const system of this.systems) {\n\t\t\tif (index < system.measureCount) {\n\t\t\t\tconst staff = system.staves[0];\n\t\t\t\tconst measure = staff.measures[index];\n\t\t\t\tconsole.assert(measure, 'measure is null:', system.measureCount, index, staff.measures);\n\t\t\t\tconst measures = system.getStaffArray(this.maxStavesCount).map((staff) => staff && staff.measures[index]);\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex,\n\t\t\t\t\tsystem,\n\t\t\t\t\tlocalIndex: index,\n\t\t\t\t\tleft: measure.left,\n\t\t\t\t\tright: measure.right,\n\t\t\t\t\tmeasures,\n\t\t\t\t};\n\t\t\t}\n\t\t\tindex -= system.measureCount;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetRawCluster(measureIndex: number, threshold: number, { timeSignature }: Partial = {}): SemanticCluster {\n\t\tconst position = this.getMeasure(measureIndex);\n\t\tif (!position) return null;\n\n\t\tconst { system, left, right } = position;\n\t\t//console.log(\"measure:\", system, left, right);\n\n\t\tconst elements: SemanticElement[] = [BOS_ELEMENT];\n\n\t\tif (timeSignature) elements.push(...fractionToElems(timeSignature));\n\n\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tlet points = system.qualifiedSemantics(staff.semantics, threshold).filter((point) => point.x > left && point.x < right);\n\t\t\tpoints = solveOverlapping(points);\n\n\t\t\t// exlude tempo noteheads\n\t\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t});\n\n\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\n\t\t\tpoints.forEach((point) => {\n\t\t\t\tconst type = SemanticElementType[point.semantic];\n\t\t\t\tif (type) {\n\t\t\t\t\tlet y1 = point.y;\n\t\t\t\t\tlet y2 = point.y;\n\t\t\t\t\tif (type === SemanticElementType.vline_Stem) {\n\t\t\t\t\t\ty1 = point.extension.y1;\n\t\t\t\t\t\ty2 = point.extension.y2;\n\t\t\t\t\t}\n\n\t\t\t\t\telements.push({\n\t\t\t\t\t\tid: point.id,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\tx: point.x - left,\n\t\t\t\t\t\ty1: y1 + y0,\n\t\t\t\t\t\ty2: y2 + y0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new SemanticCluster({\n\t\t\tindex: measureIndex,\n\t\t\telements,\n\t\t});\n\t}\n\n\tgetRawClusters(threshold: number = 1): SemanticCluster[] {\n\t\t//const times = this.getMeasuresTime();\n\n\t\treturn Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => this.getRawCluster(mi, threshold /*, times[mi]*/));\n\t}\n\n\tmakeSpartito(logger: Logger = new DummyLogger()): Spartito {\n\t\tlet eventSystems: EventSystem[] = this.systems.map((system) => system.getEvents(this.maxStavesCount));\n\n\t\t/*if (this.topology) {\n\t\t\tconst clusters = this.topology.clusters;\n\n\t\t\t// [measure, staff, event]\n\t\t\tconst eventsColumns: ChordColumn[][][] = clusters\n\t\t\t\t.filter((cluster) => cluster.index < this.measureCount)\n\t\t\t\t.reduce((columns, cluster) => {\n\t\t\t\t\tconst { system, measures } = this.getMeasure(cluster.index);\n\t\t\t\t\tconst events = cluster.getEvents();\n\n\t\t\t\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\t\t\t\t\tconst x0 = measures.filter(Boolean)[0].left;\n\n\t\t\t\t\tconst staves = system.getStaffArray(this.maxStavesCount);\n\n\t\t\t\t\t// translate by staff & measure relative offset\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst staff = staves[event.staff];\n\t\t\t\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\t\t\t\t\t\tevent.ys = event.ys.map((y) => roundNumber(y - y0, 0.5));\n\n\t\t\t\t\t\tevent.left += x0;\n\t\t\t\t\t\tevent.right += x0;\n\t\t\t\t\t});\n\n\t\t\t\t\tconst column = measures.map((measure, staffIndex) => {\n\t\t\t\t\t\tif (!measure) return [];\n\n\t\t\t\t\t\t//console.log(\"m:\", mi, \"s:\", staffIndex);\n\t\t\t\t\t\tconst localEvents = events.filter((event) => event.staff === staffIndex);\n\t\t\t\t\t\t//measure.assignModifiersOnEvents(localEvents);\n\t\t\t\t\t\tmeasure.assignAccessoriesOnEvents(localEvents);\n\n\t\t\t\t\t\treturn localEvents;\n\t\t\t\t\t});\n\n\t\t\t\t\tcolumns[cluster.index] = column;\n\n\t\t\t\t\treturn columns;\n\t\t\t\t}, []);\n\n\t\t\tconst breakSystemIndices = this.breakSystemIndices;\n\n\t\t\tconst basicEventSystems = eventSystems;\n\t\t\teventSystems = [];\n\n\t\t\tlet measures = 0;\n\t\t\tfor (const system of this.systems) {\n\t\t\t\tconst esys = system.getEventsFunctional(this.maxStavesCount, (si, mi) => eventsColumns[measures + mi] && eventsColumns[measures + mi][si], [], {\n\t\t\t\t\tuseXMap: false,\n\t\t\t\t});\n\n\t\t\t\tconst basicSys = basicEventSystems[system.index];\n\t\t\t\t//onst nullN = esys.columns.filter(c => !c).length;\n\t\t\t\t//if (nullN)\n\t\t\t\t//\tconsole.log(\"null:\", nullN, esys.columns.length);\n\t\t\t\tesys.columns = esys.columns.map((column, i) => (column ? column : basicSys.columns[i]));\n\n\t\t\t\tconst sysIndex = this.systems.indexOf(system);\n\t\t\t\tconst pageBreak = breakSystemIndices.includes(sysIndex);\n\t\t\t\tconst lastColumn = esys.columns[esys.columns.length - 1];\n\t\t\t\tif (lastColumn) {\n\t\t\t\t\tlastColumn.break = true;\n\t\t\t\t\tlastColumn.pageBreak = pageBreak;\n\t\t\t\t}\n\n\t\t\t\teventSystems.push(esys);\n\t\t\t\tmeasures += system.measureCount;\n\t\t\t}\n\t\t}*/\n\n\t\tconst staves = this.eventSystemsToTermStaves(eventSystems, logger);\n\n\t\t// assign staff basics for columns\n\t\teventSystems.forEach((sys, ri) => {\n\t\t\tsys.columns.forEach((column, mi) => {\n\t\t\t\tcolumn.basics = staves.map((staff) => {\n\t\t\t\t\tconst { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig } = staff.rows[ri][mi];\n\n\t\t\t\t\treturn { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig };\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tconst clusters = null; //this.topology && this.topology.clusters;\n\n\t\tconst measures = [].concat(\n\t\t\t...eventSystems.map((esys) =>\n\t\t\t\tesys.columns.map((column) => {\n\t\t\t\t\tconst measureIndex = column.measureIndex;\n\t\t\t\t\tconst { system, localIndex, left, right } = this.getMeasure(measureIndex);\n\n\t\t\t\t\tconst cluster = clusters && clusters.find((cluster) => cluster.index === measureIndex);\n\n\t\t\t\t\tconst staffYsFull = [];\n\t\t\t\t\tsystem.staves.forEach((staff) => (staffYsFull[staff.index] = staff.top + staff.staffY));\n\n\t\t\t\t\tconst patch = this.patches && this.patches.find((patch) => patch.measureIndex === measureIndex);\n\t\t\t\t\tconst events = patch ? patch.events : SpartitoMeasure.reorderEvents([].concat(...column.rows.map((row) => row.events)), staffYsFull);\n\n\t\t\t\t\tconst barTypes = Object.fromEntries(Object.entries(column.barTypes).map(([k, v]) => [k, v / system.staves.length]));\n\t\t\t\t\tconst indent = localIndex === 0 && system.indent;\n\n\t\t\t\t\treturn new SpartitoMeasure({\n\t\t\t\t\t\tmeasureIndex,\n\t\t\t\t\t\tstaffMask: esys.staffMask,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\t\tlocalIndex,\n\t\t\t\t\t\t\tleft,\n\t\t\t\t\t\t\tright,\n\t\t\t\t\t\t\tstaffYs: system.staves.map((staff) => staff.top + staff.staffY),\n\t\t\t\t\t\t\tstaffYsFull,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t//startX: column.startX,\n\t\t\t\t\t\t//width: column.width,\n\t\t\t\t\t\tduration: patch ? patch.duration : column.duration,\n\t\t\t\t\t\tevents,\n\t\t\t\t\t\tcontexts: column.rows.map((row) => row.contexts),\n\t\t\t\t\t\tmarks: column.marks,\n\t\t\t\t\t\tbreak: column.break,\n\t\t\t\t\t\tpageBreak: column.pageBreak,\n\t\t\t\t\t\tvoltaBegin: column.voltaBegin,\n\t\t\t\t\t\tvoltaEnd: column.voltaEnd,\n\t\t\t\t\t\talternative: column.alternative,\n\t\t\t\t\t\tbarTypes,\n\t\t\t\t\t\tindent,\n\t\t\t\t\t\tbasics: patch ? patch.basics : column.basics,\n\t\t\t\t\t\tmatrixH: cluster && cluster.matrixH,\n\t\t\t\t\t\tmatrixV: cluster && cluster.matrixV,\n\t\t\t\t\t\tvoices: patch ? patch.voices : null,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst staffLayout = this.staffLayout;\n\t\tconst staffGroups = staffLayout.standaloneGroups.map((ids) => ids.map((id) => staffLayout.staffIds.indexOf(id)));\n\n\t\tthis.spartito = new Spartito({\n\t\t\tstavesCount: this.maxStavesCount,\n\t\t\tstaffGroups,\n\t\t\tmeasures,\n\t\t});\n\n\t\treturn this.spartito;\n\t}\n\n\tmakeMusicSheet(): MusicSheet {\n\t\tconst spartito = this.spartito || this.makeSpartito();\n\n\t\tif (!spartito.regulated) console.warn('[makeMusicSheet]\tspartito not regulated.');\n\n\t\tconst voiceStaves = spartito.makeVoiceStaves();\n\n\t\tconst { title, pageSize, unitSize, staffLayout, paperOptions, headers, instrumentDict } = this;\n\t\tconst measureLayout = this.getMeasureLayout();\n\n\t\treturn {\n\t\t\ttitle,\n\t\t\tpageSize,\n\t\t\tunitSize,\n\t\t\tmeasureLayout,\n\t\t\tstaffLayout,\n\t\t\tpaperOptions,\n\t\t\theaders,\n\t\t\tvoiceStaves,\n\t\t\tinstrumentDict,\n\t\t};\n\t}\n\n\tfindPoint(sid: string): PointPosition {\n\t\tfor (const system of this.systems) {\n\t\t\tfor (let si = 0; si < system.staves.length; ++si) {\n\t\t\t\tconst point = system.staves[si].semantics.find((point) => point.id === sid);\n\t\t\t\tif (point) {\n\t\t\t\t\tconst pageIndex = this.pages.findIndex((page) => page.systems.includes(system));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpoint,\n\t\t\t\t\t\tpageIndex,\n\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\tstaffIndex: si,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetMeasureSemantics(systemIndex: number, localIndex: number): SemanticPointInMeasure[] {\n\t\tconst system = this.systems[systemIndex];\n\t\tif (!system) return null;\n\n\t\tconst left = localIndex ? system.measureBars[localIndex - 1] : 0;\n\t\tconst right = system.measureBars[localIndex] || system.width;\n\n\t\treturn system.staves\n\t\t\t.map((staff, si) => {\n\t\t\t\tconst staffY = staff.top + staff.staffY;\n\t\t\t\treturn staff.semantics\n\t\t\t\t\t.filter((point) => point.x >= left && point.x < right)\n\t\t\t\t\t.map((point) => {\n\t\t\t\t\t\tconst [y1, y2] = Number.isFinite(point.extension?.y1) ? [point.extension.y1, point.extension.y2] : [point.y, point.y];\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\tstaff: si,\n\t\t\t\t\t\t\tsy1: y1 + staffY,\n\t\t\t\t\t\t\tsy2: y2 + staffY,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1);\n\t}\n\n\tmakeTimewiseGraph({ store = false }: { store?: boolean } = {}): TimewiseGraph {\n\t\tif (!this.spartito) return null;\n\n\t\tconst measures = this.spartito.measures\n\t\t\t.filter((measure) => measure.events.length > 0)\n\t\t\t.map((measure) => {\n\t\t\t\tconst points = this.getMeasureSemantics(measure.position.systemIndex, measure.position.localIndex);\n\n\t\t\t\tconst graph = {\n\t\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\t\tleft: measure.position.left,\n\t\t\t\t\tright: measure.position.right,\n\t\t\t\t\tpoints,\n\t\t\t\t};\n\n\t\t\t\tif (store) measure.graph = graph;\n\n\t\t\t\treturn graph;\n\t\t\t});\n\n\t\treturn { measures };\n\t}\n\n\tgetTokenMap(): Map {\n\t\tconst map = new Map();\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => staff.measures.forEach((measure) => measure.tokens.forEach((token) => map.set(token.id, token))))\n\t\t);\n\n\t\treturn map;\n\t}\n\n\tassemble(confidenceThreshold: number = 1, logger: Logger = new DummyLogger()) {\n\t\tconst ids = new Map();\n\n\t\tconst append = (systemIndex, staffIndex, point) => {\n\t\t\tconst id = hashSemanticPoint(systemIndex, staffIndex, point);\n\t\t\tlogger.assert(!ids.has(id), 'semantic point hash conflicted:', id, point, ids.get(id));\n\n\t\t\tids.set(id, point);\n\t\t};\n\n\t\tthis.pages.forEach((page, index) => (page.index = index));\n\n\t\tlet measureIndex = 0;\n\t\tthis.systems.forEach((system, systemIndex) => {\n\t\t\tsystem.index = systemIndex;\n\t\t\tsystem.headMeasureIndex = measureIndex;\n\t\t\tsystem.prev = this.systems[systemIndex - 1] || null;\n\t\t\tsystem.next = this.systems[systemIndex + 1] || null;\n\n\t\t\tif (system.semantics && system.semantics.length) system.semantics.forEach((point) => append(systemIndex, null, point));\n\n\t\t\tsystem.assemble(confidenceThreshold, logger);\n\t\t\tmeasureIndex += system.measureCount;\n\t\t});\n\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tpage.systems.forEach((system) => (system.pageIndex = i));\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations }, logger);\n\t\t});\n\t}\n\n\tassembleSystem(system: System, confidenceThreshold: number = 1) {\n\t\tthis.systems.forEach((system, si) => (system.index = si));\n\t\tconst systemIndex = system.index;\n\n\t\tif (system.semantics && system.semantics.length) {\n\t\t\tsystem.semantics.forEach((point) => hashSemanticPoint(systemIndex, null, point));\n\t\t\tsystem.assemble(confidenceThreshold);\n\t\t}\n\t}\n\n\tmarkVoices(staves: VoicesStaff[]): void {\n\t\tconst tokenMap = this.getTokenMap();\n\t\tfor (const token of tokenMap.values()) token.voice = 0;\n\n\t\tconst vis = []\n\t\t\t.concat(...staves.map((staff, s) => (staff.voices || []).map((_, v) => [s, v])))\n\t\t\t.sort(([s1, v1], [s2, v2]) => v1 - v2 || s1 - s2)\n\t\t\t.map(([s, v]) => `${s}|${v}`);\n\n\t\tstaves.forEach((staff, si) =>\n\t\t\t(staff.voices || []).forEach((voice, vi) =>\n\t\t\t\tvoice.measures.forEach((measure) => {\n\t\t\t\t\tconst voiceIndex = vis.indexOf(`${si}|${vi}`);\n\n\t\t\t\t\tconst events = Object.values(measure.tickMap).filter((event) => event instanceof EventTerm) as EventTerm[];\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst notes = event.noteIds ? event.noteIds.map((id) => tokenMap.get(id)).filter(Boolean) : [];\n\t\t\t\t\t\tconst accessories = event.accessories ? event.accessories.map((acc) => tokenMap.get(acc.id)).filter(Boolean) : [];\n\t\t\t\t\t\t//console.log(\"notes:\", si, vi, mi, event.noteIds, notes, accessories);\n\n\t\t\t\t\t\t[...notes, ...accessories].forEach((token) => (token.voice |= 1 << voiceIndex));\n\n\t\t\t\t\t\tif (event.timeWarp) notes.forEach((note) => (note.timeWarped = true));\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t}\n\n\tasync replaceImageKeys(proc: (x: string | Buffer) => Promise): Promise {\n\t\tawait Promise.all([\n\t\t\t...(this.pages.map(async (page) => {\n\t\t\t\tif (page.source) page.source.url = await proc(page.source.url);\n\t\t\t}) as Promise[]),\n\t\t\t...this.systems.map((system) =>\n\t\t\t\tPromise.all([\n\t\t\t\t\tproc(system.backgroundImage).then((key) => (system.backgroundImage = key)),\n\t\t\t\t\t...(system.staves.map(async (staff) => {\n\t\t\t\t\t\tstaff.backgroundImage = await proc(staff.backgroundImage);\n\t\t\t\t\t\tstaff.maskImage = await proc(staff.maskImage);\n\t\t\t\t\t}) as Promise[]),\n\t\t\t\t])\n\t\t\t),\n\t\t]);\n\t}\n\n\tinferenceStaffLayout(): void {\n\t\t// inference the complete layout\n\t\tconst staffTotal = Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t\tthis.staffLayoutCode = Array(staffTotal).fill('').join(',');\n\n\t\tconst completeSystems = this.systems.filter((system) => system.staves.length === staffTotal && system.bracketsAppearance);\n\t\tif (!completeSystems.length) return; // no enough evidence\n\n\t\tconst candidateCodes = completeSystems\n\t\t\t.map((system) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst layout = staffLayout.parseCode(system.bracketsAppearance);\n\t\t\t\t\tif (layout.staffIds.length !== system.staves.length) return null;\n\n\t\t\t\t\treturn system.bracketsAppearance;\n\t\t\t\t} catch (_) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t\tif (!candidateCodes.length) return; // no valid layout\n\n\t\tconst codeCounting = candidateCodes.reduce((acc, code) => {\n\t\t\tconst count = acc[code] || 0;\n\t\t\tacc[code] = count + 1;\n\t\t\treturn acc;\n\t\t}, {} as { [code: string]: number });\n\t\tconst maxCount = Math.max(...Object.values(codeCounting));\n\t\tconst code = Object.entries(codeCounting).find(([_, count]) => count === maxCount)[0];\n\n\t\t// added connection lines between braces {-}\n\t\tconst connectedCode = code.replace(/\\{,*\\}/g, (match) => match.replace(/,/g, '-'));\n\t\tconst layout = staffLayout.parseCode(connectedCode);\n\n\t\tthis.staffLayoutCode = connectedCode;\n\t\t//console.log(\"complete code:\", code);\n\n\t\t// inference systems' mask\n\t\tlet lastSys: System = null;\n\t\tfor (const system of this.systems) {\n\t\t\tif (lastSys && system.staves.length === lastSys.staves.length && system.bracketsAppearance === lastSys.bracketsAppearance) {\n\t\t\t\tsystem.staffMaskChanged = null;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (system.staves.length < staffTotal && system.bracketsAppearance) {\n\t\t\t\t// validate the system brackets code\n\t\t\t\ttry {\n\t\t\t\t\tif (!staffLayout.parseCode(system.bracketsAppearance)) continue;\n\t\t\t\t} catch (_) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst search = (bits: (0 | 1)[]): number => {\n\t\t\t\t\tif (bits.length > layout.staffIds.length) return null;\n\n\t\t\t\t\tif (bits.reduce((sum, bit) => sum + bit, 0) === system.staves.length) return bitsToMask(bits);\n\n\t\t\t\t\tfor (const bit of [1, 0]) {\n\t\t\t\t\t\tconst bb = [...bits, bit] as (0 | 1)[];\n\t\t\t\t\t\tconst code1 = layout.partialMaskCode(bb);\n\t\t\t\t\t\tif (code1 === system.bracketsAppearance) return bitsToMask(bb);\n\t\t\t\t\t\telse if (system.bracketsAppearance.startsWith(code1)) {\n\t\t\t\t\t\t\tconst result = search(bb);\n\t\t\t\t\t\t\tif (result) return result;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t};\n\t\t\t\tconst mask = search([]);\n\t\t\t\t//console.log(\"mask:\", system.bracketsAppearance, mask.toString(2));\n\n\t\t\t\tsystem.staffMaskChanged = !lastSys || mask !== lastSys.staffMask ? mask : null;\n\t\t\t}\n\n\t\t\tlastSys = system;\n\t\t}\n\t}\n\n\tassignBackgroundForMeasure(measure: SpartitoMeasure): void {\n\t\tmeasure.backgroundImages = [];\n\n\t\tconst system = this.systems[measure.position.systemIndex];\n\t\tif (system.backgroundImage) {\n\t\t\tmeasure.backgroundImages.push({\n\t\t\t\turl: system.backgroundImage,\n\t\t\t\tposition: system.imagePosition,\n\t\t\t\toriginal: true,\n\t\t\t});\n\t\t}\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tif (!system.backgroundImage && staff.backgroundImage)\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.backgroundImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t\toriginal: true,\n\t\t\t\t});\n\n\t\t\tif (staff.maskImage) {\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.maskImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tblackoutFakeNotes(scope: 'patched' | 'perfect' | 'all' = 'patched'): string[] {\n\t\tif (!this.spartito) return;\n\n\t\tlet inScope = (_) => true;\n\t\tswitch (scope) {\n\t\t\tcase 'patched':\n\t\t\t\tinScope = (measure) => measure.patched;\n\t\t\t\tbreak;\n\t\t\tcase 'perfect':\n\t\t\t\tinScope = (measure) => measure.patched || (measure.regulated && evaluateMeasure(measure).perfect);\n\t\t\t\tbreak;\n\t\t}\n\t\tconst measures = this.spartito.measures.filter(inScope);\n\n\t\tconst fakeIds = measures.reduce((ids, measure) => {\n\t\t\tif (!measure.regulated) return;\n\n\t\t\tconst voicedIds = measure.voices.flat(1);\n\t\t\tconst fakeChords = measure.events.filter((event) => !event.rest && !event.grace && !voicedIds.includes(event.id));\n\n\t\t\tfakeChords.forEach((event) => event.noteIds && ids.push(...event.noteIds));\n\n\t\t\treturn ids;\n\t\t}, [] as string[]);\n\t\tconst fakeIdSet = new Set(fakeIds);\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\tconst blackIds = staff.semantics.filter((point) => fakeIdSet.has(point.id)).map((point) => point.id);\n\t\t\t\tsystem.sidBlackList.push(...blackIds);\n\t\t\t})\n\t\t);\n\n\t\treturn fakeIds;\n\t}\n\n\tgetMeasureLayout(): measureLayout.MeasureLayout {\n\t\tconst code = this.spartito && this.spartito.measureLayoutCode;\n\t\tif (code) {\n\t\t\ttry {\n\t\t\t\treturn measureLayout.parseCode(code);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.debug('invalid measure layout code:', err);\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t*splitToSingleScoresGen(): Generator {\n\t\tthis.assemble();\n\t\tconst startSysIndices = this.systems.filter((system) => system.index > 0 && system.indent && system.timeSignatureOnHead).map((system) => system.index);\n\n\t\tif (!startSysIndices.length) {\n\t\t\tyield this.deepCopy();\n\t\t\treturn;\n\t\t}\n\n\t\tconst templateScore = new Score({ ...this, pages: [], topology: undefined, spartito: undefined, patches: undefined });\n\n\t\t// clear temporary objects before deep dopy\n\t\tthis.pages.forEach((page) => {\n\t\t\tdelete page.tokens;\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tdelete system.tokens;\n\t\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\t\tstaff.measures = [];\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tlet startSysIndex = 0;\n\t\tfor (const endSysIndex of [...startSysIndices, this.systems.length]) {\n\t\t\tconst sysInRange = (system) => system.index >= startSysIndex && system.index < endSysIndex;\n\t\t\tconst pages = this.pages\n\t\t\t\t.filter((page) => page.systems.some(sysInRange))\n\t\t\t\t.map((page) => {\n\t\t\t\t\tconst { systems, ...fields } = page;\n\t\t\t\t\treturn new Page({ ...fields, systems: systems.filter(sysInRange).map((system) => new System({ ...system })) });\n\t\t\t\t});\n\n\t\t\tconst newScore = templateScore.deepCopy();\n\t\t\tnewScore.headers.SubScoreSystem = `${startSysIndex}-${endSysIndex - 1}`;\n\t\t\tnewScore.headers.SubScorePage = `${pages[0].index}-${pages[pages.length - 1].index}`;\n\n\t\t\t//newScore.pages = pages.map((page) => page.deepCopy());\n\t\t\tnewScore.pages = pages;\n\t\t\tnewScore.assemble();\n\t\t\tnewScore.inferenceStaffLayout();\n\n\t\t\tstartSysIndex = endSysIndex;\n\n\t\t\tyield newScore;\n\t\t}\n\t}\n\n\tsplitToSingleScores(): Score[] {\n\t\treturn [...this.splitToSingleScoresGen()];\n\t}\n}\n\nexport { PaperOptions, Score, Page, System, Staff, Measure, MeasureValidation };\nexport type { SemanticPointInMeasure };\n","import type { MeasureLayout } from './measureLayout';\nimport * as measureLayout from './measureLayout';\nimport grammar from './grammar.jison';\nimport { recoverJSON } from '../starry/aux_/typedJSON';\n\nconst parseCode = (code: string): MeasureLayout => {\n\tconst raw = grammar.parse(code);\n\n\tif (raw?.data) return recoverJSON(raw.data, measureLayout);\n\n\treturn null;\n};\n\nexport { parseCode };\n","import { MIDI } from '@k-l-lambda/music-widgets';\n\nimport { Fraction } from './interfaces';\nimport { noteToPitch } from './utils';\nimport { EventTerm, RestType, GraceType, StemBeam, ArpeggioStyle, TermPitch, TremoloLink } from './term';\nimport { SpartitoMeasure } from './spartitoMeasure';\n\n// NOTE: 'JSONEditor.onEditable' determine whether a field is editable, here 'readonly' modifier has no effect to UI\n\ninterface EventUIAgent {\n\treadonly id: number;\n\treadonly duration: number;\n\n\t//ys: number[];\n\tpitches: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\tgrace: boolean; //\n\tbeam: StemBeam;\n\ttimeWarp: string; //\n\ttremolo: number;\n\ttremoloLink: TremoloLink;\n\tglissando: boolean;\n\tarpeggioStyle: ArpeggioStyle;\n\ttick: number;\n}\n\ninterface MeasureUIAgent {\n\treadonly measureIndex: number;\n\ttimeSignature: Fraction;\n\tdoubtfulTimesig: boolean;\n\tkeySignature: number;\n\t//readonly events: EventUIAgent[];\n\tduration: number;\n\treadonly voices: number[][];\n}\n\nclass EditableEvent extends EventTerm {\n\tvoice: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t}\n\n\tget agent(): EventUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget(target, key): any {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'arpeggioStyle': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? null : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'glissando': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? false : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\treturn !!self.grace;\n\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\treturn self.timeWarp ? `${self.timeWarp.numerator}/${self.timeWarp.denominator}` : null;\n\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn self.pitches;\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'glissando':\n\t\t\t\t\tcase 'arpeggioStyle':\n\t\t\t\t\t\t(self as any)[key] = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\tself.grace = value ? GraceType.Grace : null;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\tself.timeWarp = null;\n\t\t\t\t\t\tif (value && typeof value === 'string') {\n\t\t\t\t\t\t\tconst captures = value.match(/^(\\d+)\\/(\\d+)/);\n\t\t\t\t\t\t\tif (captures) {\n\t\t\t\t\t\t\t\tself.timeWarp = {\n\t\t\t\t\t\t\t\t\tnumerator: parseInt(captures[1]),\n\t\t\t\t\t\t\t\t\tdenominator: parseInt(captures[2]),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => [\n\t\t\t\t'id',\n\t\t\t\t'duration',\n\t\t\t\t'rest',\n\t\t\t\t'division',\n\t\t\t\t'dots',\n\t\t\t\t'stemDirection',\n\t\t\t\t'tying',\n\t\t\t\t'tied',\n\t\t\t\t'beam',\n\t\t\t\t'timeWarp',\n\t\t\t\t'tremolo',\n\t\t\t\t'tremoloLink',\n\t\t\t\t'glissando',\n\t\t\t\t'arpeggioStyle',\n\t\t\t\t'tick',\n\t\t\t\t'grace',\n\t\t\t\t'pitches',\n\t\t\t],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n}\n\nclass EditableMeasure extends SpartitoMeasure {\n\tstatic className = 'EditableMeasure';\n\tstatic blackKeys = [];\n\n\tevents: EditableEvent[] = null;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\n\t\tthis.events = data.events;\n\t\tif (this.events?.some((event) => !(event instanceof EditableEvent))) this.events = this.events.map((event) => new EditableEvent(event));\n\n\t\tif (this.voices) this.syncVoiceToEvents();\n\t}\n\n\tsyncVoiceToEvents(): void {\n\t\tthis.events.forEach((event) => (event.voice = -1));\n\t\tthis.voices.forEach((voice, voiceIndex) => {\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\tif (event) event.voice = voiceIndex;\n\t\t\t\telse console.warn('no event with id:', id, this.events.length);\n\t\t\t});\n\t\t});\n\t}\n\n\tsyncVoiceFromEvents(): void {\n\t\tconst voices: EditableEvent[][] = [];\n\t\tthis.events.forEach((event) => {\n\t\t\tif (event?.voice >= 0) {\n\t\t\t\tvoices[event.voice] = voices[event.voice] || [];\n\t\t\t\tvoices[event.voice].push(event);\n\t\t\t}\n\t\t});\n\n\t\tvoices.forEach((voice) => voice.sort((e1, e2) => e1.tick - e2.tick));\n\n\t\tthis.voices = voices.map((voice) => voice.map((event) => event.id));\n\t}\n\n\tget agent(): MeasureUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget: (target, key): any => {\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\treturn self[key];\n\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn self.voices?.map((voice) => voice.join(',')) || null;\n\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\treturn self.basics[0][key];\n\t\t\t\t\t//case 'events':\n\t\t\t\t\t//\treturn self.events.map(eventUIAgent);\n\t\t\t\t\tcase 'toJSON':\n\t\t\t\t\t\treturn () => ({\n\t\t\t\t\t\t\tmeasureIndex: self.measureIndex,\n\t\t\t\t\t\t\tvoices: self.voices,\n\t\t\t\t\t\t\tduration: self.duration,\n\t\t\t\t\t\t\ttimeSignature: self.basics[0].timeSignature,\n\t\t\t\t\t\t\tkeySignature: self.basics[0].keySignature,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\t//console.log('set:', key, value);\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\t(self.basics[0][key] as any) = value;\n\t\t\t\t\t\tself.basics = self.basics.map(() => self.basics[0]);\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\tself.duration = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => ['measureIndex', 'timeSignature', 'doubtfulTimesig', 'keySignature', 'duration', 'voices'],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n\n\tmakeMIDI(bpm: number = 120): MIDI.MidiData {\n\t\tif (!this.regulated) return null;\n\n\t\tconst microsecondsPerBeat = 60e6 / bpm;\n\n\t\tconst header = { formatType: 0, ticksPerBeat: 480 };\n\t\tconst tracks = this.voices.map((ids, vi) => {\n\t\t\tconst events = ids\n\t\t\t\t.map((id) => {\n\t\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\t\tif (event) {\n\t\t\t\t\t\tconst subEvents = event.graceIds ? event.graceIds.map((id) => this.events.find((event) => event.id === id)) : [];\n\n\t\t\t\t\t\treturn [...subEvents, event];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [];\n\t\t\t\t})\n\t\t\t\t.flat(1);\n\n\t\t\tconst startTime = 0;\n\n\t\t\ttype Event = MIDI.MidiEvent & { [key: string]: any };\n\t\t\tconst midiEvents: Event[] = events\n\t\t\t\t.filter((event) => !event.rest && Number.isFinite(event.tick) && event.tick >= 0 && Number.isFinite(event.duration))\n\t\t\t\t.map((event) =>\n\t\t\t\t\tevent.pitches.map((pitch) => [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t\tvelocity: 96,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick + event.duration,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t\t.flat(2);\n\n\t\t\tmidiEvents.sort(function (e1, e2) {\n\t\t\t\treturn e1.time - e2.time;\n\t\t\t});\n\n\t\t\tif (vi === 0) {\n\t\t\t\tmidiEvents.unshift(\n\t\t\t\t\t{\n\t\t\t\t\t\ttime: startTime,\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tsubtype: 'timeSignature',\n\t\t\t\t\t\tnumerator: this.timeSignature.numerator,\n\t\t\t\t\t\tdenominator: this.timeSignature.denominator,\n\t\t\t\t\t\tthirtyseconds: 8,\n\t\t\t\t\t},\n\t\t\t\t\t{ time: startTime, type: 'meta', subtype: 'setTempo', microsecondsPerBeat }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmidiEvents.forEach((event) => {\n\t\t\t\tevent.ticks = Math.round(event.time - startTime);\n\t\t\t});\n\t\t\tmidiEvents.forEach((event, i) => {\n\t\t\t\tevent.deltaTime = event.ticks - (i > 0 ? midiEvents[i - 1].ticks : 0);\n\t\t\t});\n\n\t\t\tmidiEvents.push({ deltaTime: 0, type: 'meta', subtype: 'endOfTrack' });\n\n\t\t\treturn midiEvents;\n\t\t});\n\n\t\treturn {\n\t\t\theader,\n\t\t\ttracks,\n\t\t};\n\t}\n}\n\nexport { EditableEvent, EditableMeasure };\n","import { RegulationSolution, RegulationSolutionEvent, EventPredisposition } from './interfaces';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport { argmax, frac } from './utils';\nimport { WHOLE_DURATION, StemBeam } from './term';\nimport { Logger, DummyLogger } from './logger';\n\ninterface BeadPicker {\n\tn_seq: number;\n\tquota: number;\n\tcost: number; // duration in milliseconds\n\n\tpredictCluster(cluster: EventCluster, tip: number): Promise;\n}\n\nenum BeadType {\n\tPass = 'i',\n\tDivision = 'd',\n\tDots = 'o',\n}\n\nconst DIVISION_NAMES = ['whole', 'half', 'quarter', 'eighth', 'sixteenth', 'thirtysecond', 'sixtyfourth', '128th', '256th'];\n\ninterface BeadNodeInitData {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n}\n\nconst RESIDUE_LOSS_WEIGHT = 0.2;\nconst VOICEN_LOSS_WEIGHT = 0.002;\nconst SPACE_LOSS_WEIGHT = 0.4 / WHOLE_DURATION;\nconst PRETENTIOUSNESS_LOSS_WEIGHT = 0.02;\n\nconst POSSIBILITY_LOW_BOUNDARY = 1e-12;\n\nconst PRETENTIOUSNESS_CLIP = 100;\n\ninterface ClusterEvaluation {\n\ttickErr: number;\n\ttwist: number;\n\tresidue: number;\n\tendTick: number;\n\tfatalError: boolean;\n\tvoiceN: number;\n\tspaceDuration: number;\n\tpretentiousness: number;\n\tloss: number;\n}\n\ninterface ElementState {\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tbeam: StemBeam;\n\tstemDirection: string;\n\tgrace: boolean;\n\ttimeWarped: boolean;\n\tfullMeasure: boolean; // full measure rest\n\tfake: boolean;\n\torder: number;\n\tpredisposition: EventPredisposition;\n}\n\ninterface ClusterState {\n\telements: ElementState[];\n}\n\nconst STEM_DIRECTION_OPTIONS = [undefined, 'u', 'd'];\n\nconst BEAM_OPTIONS = [undefined, StemBeam.Open, StemBeam.Continue, StemBeam.Close];\n\nconst saveClusterState = (cluster: EventCluster): ClusterState => ({\n\telements: cluster.elements.map((elem) => ({\n\t\ttick: elem.tick!,\n\t\tdivision: elem.division!,\n\t\tdots: elem.dots!,\n\t\tbeam: elem.beam!,\n\t\tstemDirection: elem.stemDirection!,\n\t\tgrace: elem.grace!,\n\t\ttimeWarped: elem.timeWarped!,\n\t\tfullMeasure: elem.fullMeasure!,\n\t\tfake: elem.fake!,\n\t\torder: elem.order!,\n\t\tpredisposition: elem.predisposition!,\n\t})),\n});\n\nconst restoreClusterState = (cluster: EventCluster, state: ClusterState): void => cluster.elements.forEach((elem, i) => Object.assign(elem, state.elements[i]));\n\nconst measurePretentious = (p) => Math.min(PRETENTIOUSNESS_CLIP, -Math.log(p));\n\ninterface BeadDeductionContext {\n\tpicker: BeadPicker;\n\tlogger: Logger;\n\tptFactor: number; // pretentiousness tolerance factor\n}\n\nclass BeadNode {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n\n\tchildren: Record;\n\taccessCount: number;\n\n\tconstructor(data: BeadNodeInitData) {\n\t\tObject.assign(this, data);\n\n\t\t//this.possibilities = this.possibilities.map((x, i) => (this.type === BeadType.Pass && !i) ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\n\t\tthis.children = {};\n\t\tthis.accessCount = 0;\n\t}\n\n\tnextBranch(): number | null {\n\t\tconst ps = this.possibilities.map((p, i) => p / (this.children[i] ? this.children[i].accessCount + 1 : 1));\n\t\t//const ps = this.possibilities.map((p, i) => p * (this.children[i] ? (2 ** -this.children[i].accessCount) : 1));\n\n\t\tif (ps.every((p) => !p)) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn null;\n\t\t}\n\n\t\treturn argmax(ps);\n\t}\n\n\tget currentElem(): EventElement {\n\t\treturn this.cluster.elements[this.elemIndex];\n\t}\n\n\tbranchID(ni: number): string {\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\treturn `i_${ni}`;\n\t\t\tcase BeadType.Division:\n\t\t\t\treturn DIVISION_NAMES[ni];\n\t\t\tcase BeadType.Dots:\n\t\t\t\treturn 'o' + '.'.repeat(ni);\n\t\t}\n\n\t\treturn '';\n\t}\n\n\tasync deduce({ picker, logger, ptFactor }: BeadDeductionContext, deep: number = 0): Promise {\n\t\t++this.accessCount;\n\n\t\tconst ni = this.nextBranch()!;\n\t\tlogger.debug(String.fromCodePoint(0x1f349) + ' '.repeat(deep), this.branchID(ni), this.accessCount > 1 ? `[${this.accessCount}]` : '');\n\n\t\tif (!Number.isInteger(ni) || ni < 0) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tthis.pretentiousness += measurePretentious(this.possibilities[ni]);\n\t\tif (this.pretentiousness > PRETENTIOUSNESS_CLIP * ptFactor) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tlet selfEval: null | ClusterEvaluation = null;\n\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\t{\n\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\tconst element = this.cluster.elements[ni];\n\t\t\t\t\tconsole.assert(element, 'null element:', ni, this.cluster.elements.length);\n\t\t\t\t\tif (element.type === EventElementType.EOS) {\n\t\t\t\t\t\tselfEval = evaluateCluster(this.cluster, tip, this.pretentiousness);\n\t\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.cluster.elements[0].order = tip;\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip + 1)).map((x, i) =>\n\t\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 || i === this.cluster.elements.length - 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: 0,\n\t\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.order = tip;\n\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tconsole.assert(element.predisposition, 'no predisposition:', ni, this.possibilities);\n\t\t\t\t\t\t\tconst possibilities = element.predisposition!.divisionVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: ni,\n\t\t\t\t\t\t\t\ttype: BeadType.Division,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Division:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.division = ni;\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tconst possibilities = this.currentElem.predisposition!.dotsVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Dots,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Dots:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.dots = ni;\n\n\t\t\t\t\tselfEval = evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip)).map((x, i) =>\n\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\tconst evaluation = await this.children[ni].deduce({ picker, logger, ptFactor }, deep + 1);\n\t\tif (selfEval && evaluation.fatalError) {\n\t\t\tconst tip = this.currentElem.order!;\n\t\t\tthis.cluster.elements.forEach((elem) => {\n\t\t\t\tif (elem.order! > tip) elem.order = undefined;\n\t\t\t});\n\n\t\t\t// clear children data\n\t\t\tthis.cluster.elements.forEach((elem) => (elem.order = elem.order! > this.currentElem.order! ? undefined : elem.order));\n\t\t\tthis.cluster.elements[this.cluster.elements.length - 1].tick = selfEval.endTick;\n\n\t\t\treturn selfEval;\n\t\t}\n\n\t\treturn evaluation;\n\t}\n}\n\nconst estimateElementDuration = (elem: EventElement) => WHOLE_DURATION * 2 ** -elem.division! * (2 - 2 ** -elem.dots!);\n\nconst evaluateCluster = (cluster: EventCluster, tip: number, pretentiousness: number): ClusterEvaluation => {\n\tconst events = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order) && elem.order! < tip\n\t);\n\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\tconst eos = cluster.elements[cluster.elements.length - 1];\n\n\tlet tick = 0;\n\tlet lastOrder = 0;\n\tlet endTick = 0;\n\tlet voiceN = 1;\n\n\t// [x, tick, estimated tick]\n\tconst scales: [number, number, number][] = [[eos.x, cluster.signatureDuration, cluster.signatureDuration]];\n\n\tlet totalDuration = 0;\n\n\t// assign tick for events\n\tevents.forEach((event) => {\n\t\tif (event.order! > lastOrder + 1) {\n\t\t\ttick = 0;\n\t\t\t++voiceN;\n\t\t}\n\n\t\tconst referenceScale = scales.find((s) => s[1] >= tick);\n\t\tif (referenceScale && event.x > referenceScale[0] + 3) {\n\t\t\tconst nearScale = scales.reduce((n, s) => (Math.abs(event.predisposition!.tick - s[2]) < Math.abs(event.predisposition!.tick - n[2]) ? s : n));\n\t\t\tif (Math.abs(nearScale[0] - event.x) < 2) tick = Math.max(tick, nearScale[1]);\n\t\t}\n\n\t\tevent.tick = tick;\n\n\t\tconst si = Math.max(\n\t\t\t0,\n\t\t\tscales.findIndex((s) => s[0] > event.x)\n\t\t);\n\t\tscales.splice(si, 0, [event.x, event.tick, event.predisposition!.tick]);\n\n\t\t//let duration = WHOLE_DURATION * (2 ** -event.division!) * (2 - 2 ** -event.dots!);\n\t\tlet duration = estimateElementDuration(event);\n\t\tif (event.predisposition!.timeWarped > 0.5) duration = (duration * 2) / 3;\n\n\t\ttick += duration;\n\t\ttotalDuration += duration;\n\t\tendTick = Math.max(endTick, tick);\n\t\tlastOrder = event.order!;\n\t});\n\n\t/*const pretentiousness = events.reduce((p, event) => p +\n\t\tmeasurePretentious(event.predisposition!.divisionVector![event.division!]) +\n\t\tmeasurePretentious(event.predisposition!.dotsVector![event.dots!]), 0);*/\n\n\tif (endTick > 0) cluster.elements[cluster.elements.length - 1].tick = endTick;\n\n\tconst xSpan = cluster.elements[cluster.elements.length - 1].pivotX! - cluster.elements[1].pivotX!;\n\tconst tickSpan = Math.max(...events.map((e) => e.tick!), endTick);\n\n\t// tick twist loss\n\tconst eventsXOrder = [...events].sort((e1, e2) => e1.pivotX! - e2.pivotX!);\n\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\tconst e1 = eventsXOrder[i];\n\t\tconst dx = e2.pivotX! - e1.pivotX!;\n\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\tif (!dt) return dx / xSpan;\n\n\t\tconst rate = Math.atan2(dt / tickSpan, dx / xSpan);\n\n\t\t//if (dt < 0)\n\t\t//\tconsole.log(\"minus dt:\", dt, dx, rate);\n\n\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t});\n\t//console.debug(\"tickTwists:\", tickTwists, eventsXOrder);\n\n\tconst twist = Math.max(...tickTwists, 0);\n\n\tconst tickMSE = events.map((event) => (event.tick! - event.predisposition!.tick) ** 2);\n\t//console.debug(\"tickMSE:\", tickMSE.map(Math.sqrt));\n\tconst tickErr = tickMSE.length ? Math.sqrt(tickMSE.reduce((sum, mse) => sum + mse, 0) / tickMSE.length) : 0;\n\t//console.debug(\"tick/twist:\", tickErr / WHOLE_DURATION, twist);\n\n\tconst residueElements = cluster.elements.filter(\n\t\t(elem) =>\n\t\t\t[EventElementType.CHORD, EventElementType.REST].includes(elem.type) &&\n\t\t\t!(Number.isInteger(elem.order) && elem.order! < tip) &&\n\t\t\t!(elem.predisposition && elem.predisposition.fakeP > 0.5)\n\t);\n\tconst residue = residueElements.length;\n\n\tconst fatalError = twist >= 1 || endTick > cluster.signatureDuration;\n\n\t//const spaceDuration = Math.max(0, cluster.signatureDuration - endTick);\n\tconst spaceDuration = Math.max(0, cluster.signatureDuration - totalDuration / voiceN);\n\n\tconst loss =\n\t\ttickErr / WHOLE_DURATION +\n\t\ttwist +\n\t\tresidue * RESIDUE_LOSS_WEIGHT +\n\t\tvoiceN * VOICEN_LOSS_WEIGHT +\n\t\tspaceDuration * SPACE_LOSS_WEIGHT +\n\t\tpretentiousness * PRETENTIOUSNESS_LOSS_WEIGHT;\n\n\treturn {\n\t\ttickErr,\n\t\ttwist,\n\t\tresidue,\n\t\tendTick,\n\t\tfatalError,\n\t\tvoiceN,\n\t\tspaceDuration,\n\t\tpretentiousness,\n\t\tloss,\n\t};\n};\n\nconst solveCluster = async (\n\tcluster: EventCluster,\n\tpicker: BeadPicker,\n\tlogger: Logger,\n\tquota: number = 200,\n\tstopLoss: number = 0,\n\tptFactor: number = 1\n): Promise => {\n\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\tconst suc0 = await picker.predictCluster(cluster, 1);\n\n\tconst root = new BeadNode({ cluster, elemIndex: 0, pretentiousness: 0, type: BeadType.Pass, possibilities: suc0 });\n\n\tlet bestEvaluation: ClusterEvaluation | null = null;\n\tlet bestState: ClusterState | null = null;\n\n\tpicker.quota = quota;\n\twhile (picker.quota) {\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\n\t\tconst evaluation = await root.deduce({ picker, logger, ptFactor });\n\n\t\tlogger.debug('loss:', evaluation);\n\n\t\tif (!bestEvaluation || evaluation.loss < bestEvaluation.loss) {\n\t\t\tbestEvaluation = evaluation;\n\n\t\t\tcluster.duration = bestEvaluation.endTick;\n\t\t\tbestState = saveClusterState(cluster);\n\n\t\t\tif (Number.isFinite(stopLoss) && bestEvaluation.loss <= stopLoss!) break;\n\t\t}\n\n\t\tif (!Number.isFinite(root.accessCount)) break;\n\t}\n\tlogger.debug('bestEvaluation:', bestEvaluation);\n\n\trestoreClusterState(cluster, bestState!);\n\n\t// solve residue elements\n\tconst fixedEvents = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\tconst pendingEvents = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !Number.isInteger(elem.order)\n\t);\n\tif (fixedEvents.length) {\n\t\tpendingEvents.forEach((event) => {\n\t\t\t// exclude fake events (includes grace, fullMeasure) from voices\n\t\t\tevent.tick = undefined;\n\n\t\t\tif (event.predisposition!.fakeP < 0.5) {\n\t\t\t\t//const near = fixedEvents.reduce((n, e) => Math.abs(e.predisposition!.tick - event.predisposition!.tick) < Math.abs(n.predisposition!.tick - event.predisposition!.tick) ? e : n);\n\t\t\t\tconst duration = estimateElementDuration(event);\n\t\t\t\tconst candidates = fixedEvents.filter((e) => e.tick! + duration <= bestEvaluation!.endTick);\n\t\t\t\tif (candidates.length) {\n\t\t\t\t\tconst near = candidates.reduce((n, e) => (Math.abs(e.x - event.x) < Math.abs(n.x - event.x) ? e : n));\n\t\t\t\t\tevent.tick = near.tick;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tfixedEvents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t// properties\n\t[...fixedEvents, ...pendingEvents].forEach((event) => {\n\t\tevent.grace = !Number.isFinite(event.tick) && event.predisposition!.grace;\n\t\tevent.timeWarped = event.predisposition!.timeWarped > 0.5;\n\t\tevent.fullMeasure = event.predisposition!.fullMeasure > 0.5;\n\t\tevent.stemDirection = STEM_DIRECTION_OPTIONS[argmax(event.predisposition!.stemDirectionVector)];\n\t\tevent.beam = BEAM_OPTIONS[argmax(event.predisposition!.beamVector)];\n\t});\n\n\t// construct matrixH\n\tconst ids = cluster.elements.map((e) => e.index);\n\tconst idx = (id: number): number => ids.indexOf(id);\n\tcluster.matrixH = cluster.elements.map(() => Array(cluster.elements.length).fill(0));\n\tfixedEvents.forEach((event, i) => {\n\t\tconst lastEvent = fixedEvents[i - 1];\n\t\tif (!lastEvent || lastEvent.order! < event.order! - 1) {\n\t\t\tcluster.matrixH![idx(event.index!)][0] = 1;\n\t\t\tif (lastEvent) cluster.matrixH![cluster.elements.length - 1][idx(lastEvent.index!)] = 1;\n\t\t} else {\n\t\t\tconsole.assert(\n\t\t\t\tcluster.matrixH![idx(event.index!)] && Number.isFinite(cluster.matrixH![idx(event.index!)][idx(lastEvent.index!)]),\n\t\t\t\t'matrixH out of range:',\n\t\t\t\tevent.index,\n\t\t\t\tlastEvent.index,\n\t\t\t\tcluster.matrixH!.length\n\t\t\t);\n\n\t\t\tcluster.matrixH![idx(event.index!)][idx(lastEvent.index!)] = 1;\n\t\t}\n\t});\n\tif (!pendingEvents.length && fixedEvents.length) cluster.matrixH![cluster.elements.length - 1][idx(fixedEvents[fixedEvents.length - 1].index!)] = 1;\n\n\treturn bestEvaluation!;\n};\n\ninterface BeadSolverOptions {\n\tpicker: BeadPicker;\n\tstopLoss?: number;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tptFactor?: number;\n\tlogger?: Logger;\n}\n\nconst solveMeasure = async (measure: SpartitoMeasure, options: BeadSolverOptions): Promise => {\n\tconst { stopLoss = 0.09, quotaMax = 1000, quotaFactor = 5, ptFactor = 1, logger = new DummyLogger() } = options;\n\n\tlet worstLoss = 0;\n\n\tconst clusters = measure.createClusters();\n\tfor (const cluster of clusters) {\n\t\tconst quota = Math.min(quotaMax, Math.ceil(cluster.elements.length * quotaFactor));\n\t\tlogger.info(`[measure-${measure.measureIndex}]`, quota);\n\t\tconst { loss } = await solveCluster(cluster, options.picker, logger, quota, stopLoss, ptFactor);\n\t\tworstLoss = Math.max(worstLoss, loss);\n\t}\n\n\tconst voices = [] as number[][];\n\n\tconst durations = [] as number[];\n\n\tconst solutionEvents = [] as RegulationSolutionEvent[];\n\n\tclusters.forEach((cluster) => {\n\t\tconst events = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\t\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t\tif (!events.length) return;\n\n\t\tlet voice = [] as number[];\n\t\tvoices.push(voice);\n\t\tlet lastOrder = 0;\n\t\tevents.forEach((event) => {\n\t\t\tif (event.fullMeasure || event.grace || event.tremoloCatcher) return;\n\n\t\t\tif (event.order! > lastOrder + 1) {\n\t\t\t\tvoice = [event.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t} else voice.push(event.index!);\n\n\t\t\tlastOrder = event.order!;\n\t\t});\n\n\t\tlet tipElem = events[events.length - 1];\n\n\t\t// complete voices from pending events\n\t\tconst pendingEvents = cluster.elements.filter(\n\t\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isFinite(elem.tick) && !Number.isInteger(elem.order)\n\t\t);\n\t\twhile (pendingEvents.length) {\n\t\t\tconst ei = pendingEvents.findIndex((e) => e.tick! >= tipElem.tick! + estimateElementDuration(tipElem));\n\t\t\tif (ei >= 0) voice.push(pendingEvents.splice(ei, 1)[0].index!);\n\t\t\telse {\n\t\t\t\ttipElem = pendingEvents.splice(0, 1)[0];\n\t\t\t\tvoice = [tipElem.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\t\t}\n\n\t\tif (events.some((elem) => !elem.fullMeasure && Number.isInteger(elem.order))) {\n\t\t\tconst eos = cluster.elements.find((elem) => elem.type === EventElementType.EOS);\n\t\t\tdurations.push(eos!.tick!);\n\t\t}\n\n\t\tconst eventMap = measure.eventMap;\n\n\t\tconst tickSet = cluster.elements.reduce((set, elem) => {\n\t\t\tif (Number.isFinite(elem.tick)) set.add(elem.tick!);\n\t\t\treturn set;\n\t\t}, new Set());\n\t\tconst ticks = Array.from(tickSet).sort((t1, t2) => t1 - t2);\n\n\t\t// fill solutionEvents\n\t\tevents.forEach((elem) => {\n\t\t\tconst event = eventMap[elem.index!];\n\t\t\tif (event) {\n\t\t\t\tsolutionEvents.push({\n\t\t\t\t\tid: event.id!,\n\t\t\t\t\ttick: elem.tick!,\n\t\t\t\t\ttickGroup: ticks.indexOf(elem.tick!),\n\t\t\t\t\tdivision: elem.division !== event.division ? elem.division : undefined,\n\t\t\t\t\tdots: elem.dots !== event.dots ? elem.dots : undefined,\n\t\t\t\t\ttimeWarp: elem.timeWarped ? frac(2, 3) : undefined, // TODO:\n\t\t\t\t\tbeam: elem.beam !== event.beam ? elem.beam : undefined,\n\t\t\t\t\tgrace: elem.grace !== !!event.grace ? elem.grace : undefined,\n\t\t\t\t\tfullMeasure: elem.fullMeasure || undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n\n\tconst estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n\n\treturn {\n\t\tvoices: voices.filter((voice) => voice.length),\n\t\tduration: Math.max(...durations),\n\t\tevents: solutionEvents,\n\t\tpriority: -worstLoss,\n\t\testimatedDuration,\n\t};\n};\n\ninterface GlimpseMeasureOptions {\n\tpicker: BeadPicker;\n\tresetSignatureForDoubtfulOnly?: boolean;\n}\n\nconst glimpseMeasure = async (measure: SpartitoMeasure, { picker, resetSignatureForDoubtfulOnly }: GlimpseMeasureOptions): Promise => {\n\tconst clusters = measure.createClusters();\n\tconst eventMap = measure.eventMap;\n\n\tfor (const cluster of clusters) {\n\t\tif (!resetSignatureForDoubtfulOnly || measure.doubtfulTimesig) cluster.signatureDuration = 0; // re-estimate measure duration\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\t\tawait picker.predictCluster(cluster, 1);\n\n\t\tcluster.elements\n\t\t\t.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type))\n\t\t\t.forEach((elem) => {\n\t\t\t\tconst event = eventMap[elem.index!];\n\t\t\t\tevent.predisposition = elem.predisposition!;\n\t\t\t});\n\t}\n\n\tmeasure.estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n};\n\nconst estimateMeasure = async (measure: SpartitoMeasure, picker: BeadPicker): Promise =>\n\tglimpseMeasure(measure, { picker, resetSignatureForDoubtfulOnly: true });\n\nexport { BeadPicker, solveCluster, solveMeasure, estimateMeasure, glimpseMeasure };\n","import * as starry from '../starry';\nimport { MidiJson, ScoreJSON } from './types';\nimport { ChordColumn, Staff } from '../starry';\nimport { parseCode } from '../staffLayout';\nimport { MidiEvent } from '../performer';\n\nexport interface FindScoreResource {\n\tscoreJson: ScoreJSON;\n\tmidiJson: MidiJson;\n}\n\nconst SUPPORT_CLEF_TYPES = [starry.TokenType.ClefG, starry.TokenType.ClefF, starry.TokenType.ClefC];\n\nconst tokenToText = (token: starry.ContextedTerm) => {\n\tlet text = null;\n\tswitch (token.tokenType) {\n\t\tcase starry.TokenType.ClefG:\n\t\t\ttext = 'Treble';\n\t\t\tbreak;\n\t\tcase starry.TokenType.ClefF:\n\t\t\ttext = 'Bass';\n\t\t\tbreak;\n\t\tcase starry.TokenType.ClefC:\n\t\t\tif (token.y === -1) {\n\t\t\t\ttext = 'Tenor';\n\t\t\t} else {\n\t\t\t\ttext = 'Alto';\n\t\t\t}\n\t\t\tbreak;\n\t}\n\n\treturn text;\n};\n\nexport function encodeFindResource(score: starry.Score): FindScoreResource {\n\tconst perform = score.spartito.perform();\n\tconst maskImages = score.systems.map((sy) => sy.staves.map((st) => st?.maskImage)).flat();\n\tconst hasMaskImage = maskImages.filter(Boolean).length > maskImages.length / 2;\n\n\tconst scoreJson: ScoreJSON = {} as ScoreJSON;\n\n\tconst idsMap = new Map(); // starry内部ID到find播放器id的映射\n\tconst idsXMap = new Map(); // 内部ID和元素X坐标的映射\n\tconst idStaffIndexMap = new Map(); // 内部ID和元素所属part的内部staff索引\n\n\tscoreJson.unitSize = score.unitSize;\n\n\tscoreJson.title = {\n\t\ttitle: score.title,\n\t} as any;\n\n\tconst coverTexts: {\n\t\tconfidence: number;\n\t\tfontSize: number;\n\t\tid: string;\n\t\ttext: string;\n\t\ttextType: 'Title' | 'Author';\n\t\ttype: starry.TokenType;\n\t\twidth_: number;\n\t\tx: number;\n\t\ty: number;\n\t}[] = score.pages[0].tokens as any;\n\n\tif (Array.isArray(coverTexts) && coverTexts.length > 0) {\n\t\tconst [title, ...subtitles] = coverTexts\n\t\t\t.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Title')\n\t\t\t.sort((a, b) => b.fontSize - a.fontSize);\n\n\t\tif (title) {\n\t\t\tscoreJson.title.title = title.text;\n\t\t\tscoreJson.title.t = { size: title.fontSize };\n\t\t}\n\n\t\tif (subtitles?.length > 0) {\n\t\t\tsubtitles.sort((a, b) => a.y - b.y);\n\t\t\tscoreJson.title.subtitle = subtitles.map((x) => x.text).join('\\n');\n\t\t\tscoreJson.title.s = { size: subtitles.reduce((a, n) => a + n.fontSize, 0) / subtitles.length };\n\t\t}\n\n\t\tconst authors = coverTexts.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Author' && x.x > score.pages[0].width / 2);\n\n\t\tif (authors.length > 0) {\n\t\t\tscoreJson.title.composer = authors.map((x) => x.text).join('\\n');\n\t\t\tscoreJson.title.c = { size: authors.reduce((a, n) => a + n.fontSize, 0) / authors.length };\n\t\t}\n\t}\n\n\tscoreJson.page = {\n\t\tw: score.pages[0].width,\n\t\th: score.pages[0].height,\n\t};\n\n\tscoreJson.pages = score.pages.map((page) => {\n\t\tconst bgWidth = page.source.dimensions.width / page.source.interval;\n\t\tconst bgHeight = page.source.dimensions.height / page.source.interval;\n\n\t\tconst [a, b, c, d] = page.source.matrix;\n\n\t\treturn {\n\t\t\tsrc: page.source.url, // 本页本地图片URL\n\t\t\tw: bgWidth, // 背景图\n\t\t\th: bgHeight, // 背景图\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tl1: score.systems.indexOf(page.systems[0]), // 本页起始system编号\n\t\t\tls: page.systems.length, // 本页system数量\n\t\t\tmatrix: [\n\t\t\t\ta,\n\t\t\t\tb,\n\t\t\t\tc,\n\t\t\t\td,\n\t\t\t\t(-1 / 2) * a * bgWidth + (-1 / 2) * bgHeight * c + (1 / 2) * page.width || 0,\n\t\t\t\t(-1 / 2) * b * bgWidth + (-1 / 2) * bgHeight * d + (1 / 2) * page.height || 0,\n\t\t\t],\n\t\t};\n\t});\n\n\tscoreJson.parts = [];\n\tscoreJson.lines = [];\n\n\t// 没有降噪图就不需要这些字段\n\tif (hasMaskImage) {\n\t\tconst partTemplates = score.staffLayout.partGroups.map((p) => (p.range[0] === p.range[1] ? [p.range[0]] : p.range));\n\t\tconst tokenMap = score.getTokenMap();\n\t\tconst measureXs: number[][] = [];\n\n\t\t// partIndex: part索引,template: 当前part所包含的staff的全局索引\n\t\tfor (const [partIndex, template] of partTemplates.entries()) {\n\t\t\tconst staffIndexBase = partTemplates.slice(0, partIndex).flat().length;\n\n\t\t\tconst part: ScoreJSON['parts'][0] = {\n\t\t\t\tmeasures: [],\n\t\t\t};\n\n\t\t\tscore.systems.forEach((system, systemIndex) => {\n\t\t\t\tconst staves = system.staves.slice();\n\n\t\t\t\t// 不可见staff用null填充的staff列表\n\t\t\t\tconst paddedStaves = partTemplates.flat().map((staffIndex) => (!((1 << staffIndex) & system.staffMask) ? null : staves.shift()));\n\t\t\t\tconst bars = [0, ...system.measureBars];\n\n\t\t\t\t// 便历当前system下的小节\n\t\t\t\tfor (let mi = 0; mi < system.measureCount; mi++) {\n\t\t\t\t\tconst measureIndex = score.spartito.measureIndexMapping[system.headMeasureIndex + mi];\n\n\t\t\t\t\t// 如果小节被过滤\n\t\t\t\t\tif (!Number.isFinite(measureIndex)) {\n\t\t\t\t\t\tif (bars.length > mi + 1) bars[mi + 1] = bars[mi];\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst chordColumns: { chord: ChordColumn; staffIndexInPart: number }[] = [];\n\n\t\t\t\t\tfor (const staffIndex of template) {\n\t\t\t\t\t\tconst staff = paddedStaves[staffIndex];\n\n\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\tchordColumns.push(...staff.measures[mi].getChords().map((chord) => ({ chord, staffIndexInPart: staffIndex - staffIndexBase })));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet noteIndex = 0;\n\n\t\t\t\t\tconst measureStartX = bars[mi]; // 小节开头相对system的x偏移\n\n\t\t\t\t\tconst measureNotes = [];\n\n\t\t\t\t\tchordColumns.forEach(({ staffIndexInPart, chord }) => {\n\t\t\t\t\t\tconst elems = [];\n\n\t\t\t\t\t\tlet firstX = chord.tip ? chord.tip.x : chord.right - chord.left / 2;\n\n\t\t\t\t\t\tchord.noteIds.forEach((noteId, key) => {\n\t\t\t\t\t\t\tconst token = tokenMap.get(noteId);\n\n\t\t\t\t\t\t\tconst innerId = `n_${partTemplates.length > 1 ? partIndex + '_' : ''}${measureIndex}_${noteIndex}`;\n\t\t\t\t\t\t\tnoteIndex++;\n\t\t\t\t\t\t\tidsMap.set(token.id, innerId);\n\t\t\t\t\t\t\tidsXMap.set(token.id, (token.left + token.right) / 2 - measureStartX);\n\t\t\t\t\t\t\tidStaffIndexMap.set(token.id, staffIndexInPart + 1);\n\n\t\t\t\t\t\t\telems.push({\n\t\t\t\t\t\t\t\tline: -chord.ys[key] * 2, // 五线中线为0,往上为正/向下为负,每半格子1个单位\n\t\t\t\t\t\t\t\tid: innerId, // n_小节号_第几个音符\n\t\t\t\t\t\t\t\t// acc: {\n\t\t\t\t\t\t\t\t// \tacc: AccType.Flat,\n\t\t\t\t\t\t\t\t// \tx: -1\n\t\t\t\t\t\t\t\t// }, // 临时升降记号及其偏移量\n\t\t\t\t\t\t\t\tstaff: staffIndexInPart + 1,\n\t\t\t\t\t\t\t\tx: (token.left + token.right) / 2 - firstX, // 当前符头相对第一个符头的偏移量\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tmeasureXs[measureIndex] = measureXs[measureIndex] || [];\n\t\t\t\t\t\tmeasureXs[measureIndex].push(firstX - measureStartX);\n\n\t\t\t\t\t\tconst events = score.spartito.measures[system.headMeasureIndex + mi].events.filter((x) =>\n\t\t\t\t\t\t\tx.noteIds.some((y) => chord.noteIds.includes(y))\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tmeasureNotes.push({\n\t\t\t\t\t\t\telems,\n\t\t\t\t\t\t\tx: firstX - measureStartX, // 本音符相对于小节开头的x偏移量\n\t\t\t\t\t\t\ttype: 2 ** chord.division, // n分音符,1为全音符\n\t\t\t\t\t\t\t...(events.some((x) => x.grace) ? { grace: {} } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\tpart.measures[measureIndex] = {\n\t\t\t\t\t\tw: bars[mi + 1] - bars[mi], // 本小节宽度\n\t\t\t\t\t\tstaves: template.length, // 本part的staff个数\n\t\t\t\t\t\tnotes: measureNotes,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// 提取谱号、调号\n\t\t\tlet lastFifths = null;\n\t\t\tscore.spartito.measures.forEach((measure, i) => {\n\t\t\t\tconst measureIndex = score.spartito.measureIndexMapping[i];\n\n\t\t\t\tconst clefTokens = measure.contexts.flat().filter((x) => SUPPORT_CLEF_TYPES.includes(x.tokenType) && template.includes(x.staff));\n\t\t\t\tconst clefs = clefTokens.map((token) => {\n\t\t\t\t\tconst pt = partTemplates.find((p) => p.includes(token.staff));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\tclef: tokenToText(token),\n\t\t\t\t\t\tstaff: pt.indexOf(token.staff) + 1, // staff索引从1开始\n\t\t\t\t\t\ttick: token.tick,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tif (clefs.length > 0) {\n\t\t\t\t\tpart.measures[measureIndex] && (part.measures[measureIndex].clefs = clefs);\n\t\t\t\t}\n\n\t\t\t\tconst fifths = measure.basics.filter((x, i) => (1 << i) & measure.staffMask)[0].keySignature;\n\n\t\t\t\tif (fifths !== lastFifths) {\n\t\t\t\t\tpart.measures[measureIndex] && (part.measures[measureIndex].fifths = { fifths });\n\t\t\t\t\tlastFifths = fifths;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (part.measures.length > 0) {\n\t\t\t\tscoreJson.parts[partIndex] = part;\n\t\t\t}\n\t\t}\n\n\t\tscore.systems.forEach((system, systemIndex) => {\n\t\t\tconst lineStaves = [];\n\n\t\t\tconst systemTopStaff = system.staves[0];\n\t\t\tconst systemBottomStaff = system.staves[system.staves.length - 1];\n\n\t\t\tconst systemTopStaffY = systemTopStaff.top + systemTopStaff.staffY - 2;\n\t\t\tconst systemBottomStaffY = systemBottomStaff.top + systemBottomStaff.staffY - 2;\n\n\t\t\tconst staves = system.staves.slice();\n\n\t\t\tconst paddedStaves = partTemplates.flat().map((staffIndex) => {\n\t\t\t\tconst isEmpty = !((1 << staffIndex) & system.staffMask);\n\t\t\t\tif (isEmpty) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\treturn staves.shift();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tlet lastPartLastStaff = null;\n\n\t\t\tfor (const [partIndex, template] of partTemplates.entries()) {\n\t\t\t\tconst partStaves: Staff[] = template.map((staffIndex) => paddedStaves.find((s) => s?.index === staffIndex) || null);\n\n\t\t\t\tconst staffs = partStaves.map((staff, index) => [index, !staff] as [number, boolean]).filter((s) => s[1]);\n\n\t\t\t\tlet details = null;\n\t\t\t\tif (staffs.length > 0) {\n\t\t\t\t\tdetails = Object.fromEntries(staffs.map((d) => [d[0] + 1, { hide: d[1] }]));\n\t\t\t\t}\n\n\t\t\t\tlet y = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tconst visibleStaves = partStaves.filter((s) => !!s);\n\n\t\t\t\tif (visibleStaves.length > 0) {\n\t\t\t\t\tconst partTopStaff = visibleStaves[0];\n\t\t\t\t\tconst partBottomStaff = visibleStaves[visibleStaves.length - 1];\n\t\t\t\t\tconst partTopStaffY = partTopStaff.top + partTopStaff.staffY - 2;\n\t\t\t\t\tconst partBottomStaffY = partBottomStaff.top + partBottomStaff.staffY - 2;\n\n\t\t\t\t\ty = partTopStaffY - systemTopStaffY;\n\t\t\t\t\theight = partBottomStaffY - partTopStaffY + 4;\n\t\t\t\t}\n\n\t\t\t\tconst { list: distances, last } = partStaves.reduce(\n\t\t\t\t\t(acc, next, index) => {\n\t\t\t\t\t\tif (acc.last === null || next === null) {\n\t\t\t\t\t\t\tif (index === 0 && y > 0) {\n\t\t\t\t\t\t\t\tacc.list.push(y - 4);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tacc.list.push(0);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tacc.list.push(next.top + next.staffY - (acc.last.top + acc.last.staffY) - 4);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tacc.last = next || acc.last;\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{ last: lastPartLastStaff, list: [] } as { last: Staff; list: number[] }\n\t\t\t\t);\n\n\t\t\t\tlastPartLastStaff = last;\n\n\t\t\t\tconst imgs = partStaves.map((staff) => {\n\t\t\t\t\tif (staff?.maskImage) {\n\t\t\t\t\t\tconst rect = staff.imagePosition;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsrc: staff.maskImage,\n\t\t\t\t\t\t\tx: rect.x,\n\t\t\t\t\t\t\ty: system.top + staff.top + rect.y - (system.top + staff.top + staff.staffY - 2),\n\t\t\t\t\t\t\tw: rect.width,\n\t\t\t\t\t\t\th: rect.height,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t});\n\n\t\t\t\tconst spartitoMeasure = score.spartito.measures[system.headMeasureIndex];\n\t\t\t\tlineStaves.push({\n\t\t\t\t\t// parts\n\t\t\t\t\tdistances, // 两个staff间距\n\t\t\t\t\timgs,\n\t\t\t\t\ty, // 本staff相对于当前system第一线的起始y坐标\n\t\t\t\t\tstaves: template.length, // 本staff数量\n\t\t\t\t\tparti: partIndex, // 本staff所属part编号\n\t\t\t\t\theight, // 本staff高度\n\t\t\t\t\t...(details ? { details } : {}),\n\t\t\t\t\tclef: Object.fromEntries(\n\t\t\t\t\t\tscore.spartito.measures[system.headMeasureIndex]?.contexts\n\t\t\t\t\t\t\t.flat()\n\t\t\t\t\t\t\t.filter((x) => SUPPORT_CLEF_TYPES.includes(x.tokenType) && template.includes(x.staff))\n\t\t\t\t\t\t\t.map((token) => [token.staff, tokenToText(token)])\n\t\t\t\t\t),\n\t\t\t\t\tfifths: spartitoMeasure.basics.filter((x, i) => (1 << i) & spartitoMeasure.staffMask)[0].keySignature,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst mIndices = system.measureBars\n\t\t\t\t.map((_, i) => score.spartito.measureIndexMapping[system.headMeasureIndex + i])\n\t\t\t\t.filter((x) => Number.isFinite(x));\n\n\t\t\tscoreJson.lines[systemIndex] = {\n\t\t\t\tm1: mIndices[0], // 本system起始小节编号\n\t\t\t\tm2: mIndices.length > 0 ? mIndices[mIndices.length - 1] + 1 : undefined, // 本system结尾小节编号+1\n\t\t\t\tx: system.left, // 本system左侧小节线x坐标\n\t\t\t\ty: system.top + systemTopStaffY, // 本system左侧小节线y坐标\n\t\t\t\tw: system.measureBars[system.measureBars.length - 1], // 本system宽度\n\t\t\t\th: systemBottomStaffY - systemTopStaffY + 4, // 本system高度\n\t\t\t\tlineStaves,\n\t\t\t};\n\t\t});\n\n\t\tconst map = { 0: 'default', 1: 'brace', 2: 'bracket', 3: 'square' };\n\n\t\tconst staffLayout = parseCode(score.staffLayoutCode);\n\t\tconst sortedParts = staffLayout.partGroups\n\t\t\t.map((x) => {\n\t\t\t\treturn {\n\t\t\t\t\tsort: x.range[0],\n\t\t\t\t\tpart: x,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((a, b) => a.sort - b.sort)\n\t\t\t.map((x) => x.part);\n\n\t\tscoreJson.groups = staffLayout.groups\n\t\t\t.filter((x) => x.group.type !== 0)\n\t\t\t.map((part, key) => {\n\t\t\t\treturn {\n\t\t\t\t\ttype: map[part.group.type] as any,\n\t\t\t\t\tp1: sortedParts.findIndex((x) => x.range.includes(part.range[0])),\n\t\t\t\t\tp2: sortedParts.findIndex((x) => x.range.includes(part.range[part.range.length - 1])),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.filter((x) => x.type !== 'default');\n\t}\n\n\tif (perform) {\n\t\tscoreJson.measInfo = perform.notation.measures.map((measure, measureIndex) => {\n\t\t\tconst map = new Map();\n\t\t\tmeasure.notes.forEach((n) => {\n\t\t\t\tmap.set(n.tick, [...(map.get(n.tick) || []), idsXMap.get(n.id)]);\n\t\t\t});\n\n\t\t\t// 找出每个tick对应的第一个音符的中心点的x\n\t\t\treturn Array.from(map.entries())\n\t\t\t\t.sort((a, b) => +a[0] - b[0])\n\t\t\t\t.reduce(\n\t\t\t\t\t(acc, ent, key) => {\n\t\t\t\t\t\tconst val = ent[1].find((x) => x > acc.last) || ent[1][0];\n\t\t\t\t\t\tacc.list.push(val);\n\t\t\t\t\t\tacc.last = val;\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{ last: null, list: [] }\n\t\t\t\t)\n\t\t\t\t.list.filter(Number.isFinite);\n\t\t});\n\t}\n\n\t/******************************* 生成 midiJson *************************************/\n\n\tlet midiJson: MidiJson;\n\n\tif (perform) {\n\t\tmidiJson = {} as MidiJson;\n\n\t\tconst idNoteMap = new Map();\n\n\t\tlet beatsCurrent;\n\t\tlet beatsUnitCurrent;\n\t\tperform.notation.measures.forEach((measure, mIndex) => {\n\t\t\tconst { numerator: beats, denominator: beatsUnit } = measure.timeSignature;\n\n\t\t\tif (!midiJson.beats && !midiJson.beatsUnit) {\n\t\t\t\tmidiJson.beats = beats;\n\t\t\t\tmidiJson.beatsUnit = beatsUnit;\n\t\t\t\tbeatsCurrent = beats;\n\t\t\t\tbeatsUnitCurrent = beatsUnit;\n\t\t\t}\n\n\t\t\tmidiJson.beatInfos = midiJson.beatInfos || [];\n\n\t\t\tif (beatsCurrent !== beats || beatsUnitCurrent !== beatsUnit) {\n\t\t\t\tbeatsCurrent = beats;\n\t\t\t\tbeatsUnitCurrent = beatsUnit;\n\n\t\t\t\tmidiJson.beatInfos.push({\n\t\t\t\t\ttick: measure.tick,\n\t\t\t\t\tbeats,\n\t\t\t\t\tbeatsUnit,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tmidiJson.tempos = midiJson.tempos || [];\n\n\t\t\tmeasure.events.forEach((evt) => {\n\t\t\t\tif (evt.data.type === 'meta' && evt.data.subtype === 'setTempo') {\n\t\t\t\t\tmidiJson.tempos.push({\n\t\t\t\t\t\ttick: measure.tick,\n\t\t\t\t\t\ttempo: evt.data.microsecondsPerBeat,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tmidiJson.measures = perform.notation.measures.reduce((acc, measure, index) => {\n\t\t\tconst note_ticks = Array.from(new Set(measure.notes.map((x) => x.tick))).sort((a, b) => a - b);\n\n\t\t\tmeasure.notes.forEach((x) => {\n\t\t\t\tidNoteMap.set(x.id, note_ticks.indexOf(x.tick));\n\t\t\t});\n\n\t\t\tacc[measure.tick] = {\n\t\t\t\tmeasure: index, // 小节编号\n\t\t\t\tduration: measure.duration, // 小节时值\n\t\t\t\tnote_ticks, // 本小节每列的tick\n\t\t\t};\n\n\t\t\treturn acc;\n\t\t}, {});\n\n\t\tmidiJson.measureInfos = perform.notation.measures.map((measure, key) => ({\n\t\t\tnumber: String(key + 1), // 小节编号\n\t\t\tfifths: measure.keySignature, // 调号 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7\n\t\t\tbeats: measure.timeSignature.numerator, // 拍号分子\n\t\t\tbeatUnit: measure.timeSignature.denominator, // 拍号分母\n\t\t}));\n\n\t\tconst midi = perform.notation.toPerformingMIDI(perform.notation.measures.map((_, key) => key + 1));\n\n\t\tconst tracks = midi.tracks as unknown as (MidiEvent & { duration: number })[][];\n\n\t\tconst { partGroups } = score.staffLayout;\n\n\t\tlet mergedTracks = tracks.map((track, trackIndex) => {\n\t\t\tconst key = partGroups[trackIndex].key;\n\n\t\t\tlet program: number;\n\n\t\t\tswitch (key) {\n\t\t\t\tcase 'vi':\n\t\t\t\tcase 'vi1':\n\t\t\t\tcase 'vi2':\n\t\t\t\t\tprogram = 40; // 小提琴\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'viola':\n\t\t\t\t\tprogram = 42; // 中提琴\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'vo':\n\t\t\t\t\tprogram = 55; // 合成人声\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'basso':\n\t\t\t\t\tprogram = 71; // 大管乐器\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: // 大钢琴\n\t\t\t\t\tprogram = 0;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprogram, // 音色:0-127\n\t\t\t\tchannel: trackIndex, // 通道:0-15\n\t\t\t\tname: score.instrumentDict[key] ?? 'Piano', // 轨道名称\n\t\t\t\ttrack,\n\t\t\t};\n\t\t});\n\n\t\t// 找出大谱表所在track(声部),根据分手条件拆分为左右手\n\t\tif (partGroups.some((g) => g.group.grand)) {\n\t\t\tconst lhPattern = /l\\.?h\\.?|左手|left hand/i;\n\t\t\tconst rhPattern = /r\\.?h\\.?|右手|right hand/i;\n\t\t\tconst instrus = Object.entries(score.instrumentDict)\n\t\t\t\t.filter(([key, value]) => lhPattern.test(value) || rhPattern.test(value))\n\t\t\t\t.map(([key, value]) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\thand: lhPattern.test(value) ? 'left' : 'right',\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tlet handStaves: number[] = null;\n\t\t\tlet partIndex;\n\n\t\t\t// 标记了左右手\n\t\t\tif (instrus.length === 2 && instrus[0].hand !== instrus[1].hand) {\n\t\t\t\tconst left = instrus.find((x) => x.hand === 'left');\n\t\t\t\tconst right = instrus.find((x) => x.hand === 'right');\n\t\t\t\thandStaves = [score.staffLayout.staffIds.findIndex((x) => x === right?.key), score.staffLayout.staffIds.findIndex((x) => x === left?.key)];\n\n\t\t\t\tpartIndex = partGroups.findIndex((g) => g.range[0] <= Math.min(...handStaves) && g.range[1] >= Math.max(...handStaves));\n\t\t\t}\n\n\t\t\tif (Number.isFinite(partIndex) && partIndex > -1) {\n\t\t\t\tconst trackToSplit = mergedTracks[partIndex];\n\t\t\t\tconst newTracks: any[][] = []; // Array.from(new Set(firstTrack.track.map(x => x.channel))).sort((a, b) => a - b)\n\n\t\t\t\ttrackToSplit.track.forEach((evt) => {\n\t\t\t\t\tif (Number.isFinite(evt.staff)) {\n\t\t\t\t\t\tif (!newTracks[evt.staff]) {\n\t\t\t\t\t\t\tnewTracks[evt.staff] = [];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewTracks[evt.staff].push(evt);\n\t\t\t\t\t}\n\t\t\t\t\tif (evt.type === 'meta') {\n\t\t\t\t\t\tnewTracks.forEach((stave) => {\n\t\t\t\t\t\t\tstave.push(evt);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmergedTracks.splice(partIndex, 1, newTracks.filter(Boolean).map((track) => ({ ...trackToSplit, track })) as any);\n\n\t\t\t\tmergedTracks = mergedTracks.flat();\n\n\t\t\t\t// 指定左右手track\n\t\t\t\tmidiJson.rightHandTrack = handStaves[0];\n\t\t\t\tmidiJson.leftHandTrack = handStaves[1];\n\t\t\t} else {\n\t\t\t\tmergedTracks.sort((a, b) => (a === mergedTracks[partIndex] ? -1 : 0));\n\t\t\t}\n\t\t}\n\n\t\tmidiJson.tracks = mergedTracks.map(({ program, channel, name }) => ({ program, channel, name }));\n\n\t\tconst transformedTracks = mergedTracks.map(({ track }) => {\n\t\t\tconst pitchMap: Map = new Map();\n\n\t\t\treturn track.map((evt) => {\n\t\t\t\tif (evt.subtype === 'noteOn') {\n\t\t\t\t\tpitchMap.set(evt.noteNumber, evt);\n\t\t\t\t}\n\n\t\t\t\tif (evt.subtype === 'noteOff') {\n\t\t\t\t\tconst onEvent = pitchMap.get(evt.noteNumber);\n\t\t\t\t\tif (onEvent?.noteNumber === evt.noteNumber) {\n\t\t\t\t\t\tonEvent.duration = evt.ticks - onEvent.ticks;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn evt;\n\t\t\t});\n\t\t});\n\n\t\tconst measureTickMap = new Map(Object.entries(midiJson.measures).map(([tick, m]) => [m.measure, +tick]));\n\n\t\tmidiJson.events = (transformedTracks as (MidiEvent & { duration: number; numId?: string; ticks: number })[][])\n\t\t\t.map((track, trackIndex) => {\n\t\t\t\treturn track\n\t\t\t\t\t.filter((x) => x.type === 'channel')\n\t\t\t\t\t.map((evt) => {\n\t\t\t\t\t\tif (evt?.ids?.[0]) {\n\t\t\t\t\t\t\tevt.numId = idsMap.get(evt.ids[0]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet newEvent: [number, number, number] = [0, 0, 0];\n\n\t\t\t\t\t\tswitch (evt.subtype) {\n\t\t\t\t\t\t\tcase 'noteOn':\n\t\t\t\t\t\t\t\tnewEvent = [0x90 | evt.channel, evt.noteNumber, evt.velocity];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'noteOff':\n\t\t\t\t\t\t\t\tnewEvent = [0x80 | evt.channel, evt.noteNumber, evt.velocity ? evt.velocity : 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'noteAftertouch':\n\t\t\t\t\t\t\t\tnewEvent = [0xa0 | evt.channel, evt.noteNumber, evt.amount];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'controller':\n\t\t\t\t\t\t\t\tnewEvent = [0xb0 | evt.channel, evt.controllerType, evt.value];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'programChange':\n\t\t\t\t\t\t\t\tnewEvent = [0xc0 | evt.channel, evt.programNumber, 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'channelAftertouch':\n\t\t\t\t\t\t\t\tnewEvent = [0xd0 | evt.channel, evt.amount, 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'pitchBend':\n\t\t\t\t\t\t\t\tnewEvent = [0xe0 | evt.channel, evt.value & 0xff, (evt.value >> 7) & 0xff];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new Error('unhandled event subtype:' + evt.subtype);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...(evt.subtype === 'noteOn' ? { id: idsMap.get(evt?.ids?.[0]) } : {}), // 对应符头的id\n\t\t\t\t\t\t\ttick: evt.ticks,\n\t\t\t\t\t\t\tchannel: evt.channel,\n\t\t\t\t\t\t\tduration: evt.duration, // 只有note on事件有时值\n\t\t\t\t\t\t\ttrack: trackIndex, // evt.staffTrack, // 所属track\n\t\t\t\t\t\t\tevent: newEvent, // [event, note, velocity]\n\t\t\t\t\t\t\telem_ids: evt?.ids.map((id) => idsMap.get(id)),\n\t\t\t\t\t\t\tmeasure: evt.measure - 1, // 所属小节编号\n\t\t\t\t\t\t\tmeas_start_tick: measureTickMap.get(evt.measure - 1), // 所属小节起始tick\n\t\t\t\t\t\t\tstaff: idStaffIndexMap.get(evt.ids[0]),\n\t\t\t\t\t\t\tnote: idNoteMap.get(evt.ids[0]),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1)\n\t\t\t.sort((a, b) => {\n\t\t\t\tfor (const field of ['tick', 'measure', 'track']) {\n\t\t\t\t\tif (a[field] !== b[field]) {\n\t\t\t\t\t\treturn a[field] - b[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t});\n\t}\n\n\treturn {\n\t\tscoreJson,\n\t\tmidiJson,\n\t};\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","import { EventEmitter } from 'events';\n\ninterface DSPromiseOption {\n\ttimeout?: number;\n}\n\nexport function destructPromise(\n\toptions: DSPromiseOption = {}\n): [promise: Promise, resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void] {\n\tconst { timeout } = options;\n\tlet rs: (value: T | PromiseLike) => void;\n\tlet rj: (reason: any) => void;\n\n\treturn [\n\t\tnew Promise((resolve, reject) => {\n\t\t\trs = resolve;\n\t\t\trj = reject;\n\n\t\t\tif (timeout >= 0) setTimeout(rj, timeout, 'timeout');\n\t\t}),\n\t\trs,\n\t\trj,\n\t];\n}\n\ntype AsyncTask = [fn: (data: any) => Promise, payload: any, resolve: (data: any) => void, reject: (reason: any) => void];\n\nexport class AsyncQueue extends EventEmitter {\n\tprivate working = false;\n\n\ttasks: AsyncTask[];\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.working = false;\n\t\tthis.tasks = [];\n\t\tprocess.nextTick(() => {\n\t\t\tthis.emit('idle');\n\t\t});\n\t}\n\n\tprivate async _digest(item: AsyncTask) {\n\t\tthis.working = true;\n\n\t\tconst [taskFn, payload, resolve, reject] = item;\n\t\tawait taskFn(payload).then(resolve, reject);\n\n\t\tif (this.tasks.length > 0) {\n\t\t\tawait this._digest(this.tasks.shift());\n\t\t} else {\n\t\t\tthis.working = false;\n\t\t\tthis.emit('idle');\n\t\t}\n\t}\n\n\t/**\n\t * 添加队列任务\n\t * @param task\n\t * @param options\n\t */\n\taddTask(task: [AsyncTask[0], AsyncTask[1]], { timeout = 600000 }: { timeout?: number } = {}): Promise {\n\t\tconst [promise, resolve, reject] = destructPromise({ timeout });\n\n\t\tif (this.working) {\n\t\t\tthis.tasks.push([...task, resolve, reject]);\n\t\t} else {\n\t\t\tthis._digest([...task, resolve, reject]);\n\t\t}\n\n\t\treturn promise;\n\t}\n}\n","import { pack, unpack } from 'msgpackr';\nimport { Request } from 'zeromq';\nimport { AsyncQueue } from './async-queue';\n\ninterface Response {\n\tcode: number;\n\tmsg: string;\n\tdata?: any;\n}\n\nexport interface Logger {\n\tinfo: (...data: any[]) => void;\n\terror: (...data: any[]) => void;\n}\n\ntype PyArgs = any[];\ntype PyKwargs = Record;\n\nexport default class ZeroClient {\n\tlogger: Logger;\n\tprivate socket: Request;\n\tprivate queue: AsyncQueue = new AsyncQueue();\n\n\tprivate url: string;\n\n\tconstructor(logger: Logger = console) {\n\t\tthis.logger = logger;\n\t}\n\n\tbind(url?: string) {\n\t\turl && (this.url = url);\n\t\tthis.socket = new Request({\n\t\t\tsendTimeout: 15e3,\n\t\t\treceiveTimeout: 300e3,\n\t\t});\n\n\t\tthis.socket.connect(this.url);\n\t}\n\n\tprivate __request(payload) {\n\t\tlet retryTimes = 0;\n\n\t\tconst req = async (data) => {\n\t\t\ttry {\n\t\t\t\tif (this.socket.closed) this.bind();\n\t\t\t\treturn await this.socket.send(pack(data)).then(() => this.socket.receive());\n\t\t\t} catch (err) {\n\t\t\t\tif (retryTimes < 2) {\n\t\t\t\t\tretryTimes++;\n\t\t\t\t\tconsole.log(`请求失败,${err.stack}`);\n\t\t\t\t\tconsole.error(`3s后重试第${retryTimes}次`);\n\t\t\t\t\tthis.socket.close();\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 3000));\n\t\t\t\t\treturn req(data);\n\t\t\t\t} else {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn req(payload);\n\t}\n\n\tasync request(method: string, args: PyArgs | PyKwargs = null, kwargs: PyKwargs = null): Promise {\n\t\tconst [args_, kwargs_] = Array.isArray(args) ? [args, kwargs] : [undefined, args];\n\t\tconst msg: any = { method };\n\t\tif (args_) msg.args = args_;\n\t\tif (kwargs_) msg.kwargs = kwargs_;\n\n\t\treturn this.queue.addTask([\n\t\t\tasync (opt) => {\n\t\t\t\tconst [result] = await this.__request(opt);\n\n\t\t\t\tconst obj = unpack(result) as Response;\n\n\t\t\t\tif (obj.code === 0) {\n\t\t\t\t\treturn obj.data;\n\t\t\t\t} else {\n\t\t\t\t\treturn Promise.reject(obj.msg);\n\t\t\t\t}\n\t\t\t},\n\t\t\tmsg,\n\t\t]);\n\t}\n}\n","import { getPortPromise } from 'portfinder';\nimport { Options, PythonShell } from 'python-shell';\nimport { defaultsDeep } from 'lodash';\nimport ZeroClient, { Logger } from './ZeroClient';\n\nexport default class PyProcessor extends ZeroClient {\n\tprivate readonly scriptPath: string;\n\tprivate readonly options: Options;\n\tprivate pyShell: PythonShell;\n\n\tprivate retryCount: number = 0;\n\tprivate retryDelay: number = 3000;\n\n\tconstructor(scriptPath: string, options: Options = {}, logger: Logger = console) {\n\t\tsuper(logger);\n\t\tthis.scriptPath = scriptPath;\n\t\tthis.options = options;\n\t}\n\n\tasync bind(port?: string | number) {\n\t\tconst freePort =\n\t\t\tport ||\n\t\t\t(await getPortPromise({\n\t\t\t\tport: 12022,\n\t\t\t\tstopPort: 12122,\n\t\t\t}));\n\n\t\t// \"./streamPredictor.py\", \"--inspect\"\n\t\tconst options = defaultsDeep(\n\t\t\t{\n\t\t\t\targs: [...(this.options.args || []), '-p', `${freePort}`],\n\t\t\t},\n\t\t\tthis.options\n\t\t);\n\n\t\tthis.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`);\n\n\t\tthis.pyShell = new PythonShell(this.scriptPath, options);\n\n\t\tthis.pyShell.stdout.on('data', (data) => this.logger.info(data));\n\n\t\tthis.pyShell.on('pythonError', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`, err));\n\t\tthis.pyShell.on('stderr', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`, err));\n\t\tthis.pyShell.on('error', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} error:`, err));\n\t\tthis.pyShell.on('close', () => {\n\t\t\t// python子进程关闭事件\n\t\t\tif (this.retryCount < 5) {\n\t\t\t\tthis.retryCount++;\n\t\t\t\tthis.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.bind();\n\t\t\t\t}, this.retryDelay);\n\t\t\t}\n\t\t});\n\n\t\tsuper.bind(`tcp://127.0.0.1:${freePort}`);\n\t}\n}\n","module.exports = function isBuffer(arg) {\n return arg instanceof Buffer;\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n","try {\n var util = require('util');\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n module.exports = require('./inherits_browser.js');\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(obj) {\n var keys = Object.keys(obj);\n var descriptors = {};\n for (var i = 0; i < keys.length; i++) {\n descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);\n }\n return descriptors;\n };\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n if (typeof process !== 'undefined' && process.noDeprecation === true) {\n return fn;\n }\n\n // Allow for deprecating things in the process of starting up.\n if (typeof process === 'undefined') {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nvar kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;\n\nexports.promisify = function promisify(original) {\n if (typeof original !== 'function')\n throw new TypeError('The \"original\" argument must be of type Function');\n\n if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {\n var fn = original[kCustomPromisifiedSymbol];\n if (typeof fn !== 'function') {\n throw new TypeError('The \"util.promisify.custom\" argument must be of type Function');\n }\n Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return fn;\n }\n\n function fn() {\n var promiseResolve, promiseReject;\n var promise = new Promise(function (resolve, reject) {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n args.push(function (err, value) {\n if (err) {\n promiseReject(err);\n } else {\n promiseResolve(value);\n }\n });\n\n try {\n original.apply(this, args);\n } catch (err) {\n promiseReject(err);\n }\n\n return promise;\n }\n\n Object.setPrototypeOf(fn, Object.getPrototypeOf(original));\n\n if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return Object.defineProperties(\n fn,\n getOwnPropertyDescriptors(original)\n );\n}\n\nexports.promisify.custom = kCustomPromisifiedSymbol\n\nfunction callbackifyOnRejected(reason, cb) {\n // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).\n // Because `null` is a special error value in callbacks which means \"no error\n // occurred\", we error-wrap so the callback consumer can distinguish between\n // \"the promise rejected with null\" or \"the promise fulfilled with undefined\".\n if (!reason) {\n var newReason = new Error('Promise was rejected with a falsy value');\n newReason.reason = reason;\n reason = newReason;\n }\n return cb(reason);\n}\n\nfunction callbackify(original) {\n if (typeof original !== 'function') {\n throw new TypeError('The \"original\" argument must be of type Function');\n }\n\n // We DO NOT return the promise as it gives the user a false sense that\n // the promise is actually somehow related to the callback's execution\n // and that the callback throwing will reject the promise.\n function callbackified() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n\n var maybeCb = args.pop();\n if (typeof maybeCb !== 'function') {\n throw new TypeError('The last argument must be of type Function');\n }\n var self = this;\n var cb = function() {\n return maybeCb.apply(self, arguments);\n };\n // In true node style we process the callback on `nextTick` with all the\n // implications (stack, `uncaughtException`, `async_hooks`)\n original.apply(this, args)\n .then(function(ret) { process.nextTick(cb, null, ret) },\n function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });\n }\n\n Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));\n Object.defineProperties(callbackified,\n getOwnPropertyDescriptors(original));\n return callbackified;\n}\nexports.callbackify = callbackify;\n","import ZeroClient, { Logger } from './ZeroClient';\nimport * as starry from '../../src/starry';\nimport PyProcessor from './PyProcessor';\nimport { destructPromise } from './async-queue';\nimport { getPort } from 'portfinder';\nimport util from 'util';\nimport { Options } from 'python-shell';\n\nconst getPortPromise = util.promisify(getPort);\n\nexport interface LayoutResult {\n\tdetection: starry.PageLayout;\n\ttheta: number;\n\tinterval: number;\n\tsourceSize?: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface PredictorInterface {\n\tlayout: (streams: Buffer[]) => LayoutResult[];\n\tlayout$reinforce: (streams: Buffer[], baseLayouts: LayoutResult[]) => LayoutResult[];\n\tgauge: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tmask: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tsemantic: (streams: Buffer[]) => any[];\n\ttextLoc: (streams: Buffer[]) => any[];\n\ttextOcr: (params: { buffers: Buffer[]; location: any[] }) => any[];\n\tbrackets: (params: { buffers: Buffer[] }) => any[];\n\ttopo: (params: { clusters: starry.EventCluster[] }) => any[];\n\tgaugeRenderer: (params: [Buffer, Buffer, number]) => { buffer: Buffer; size: { width: number; height: number } };\n\tjianpu: (params: { buffers: Buffer[] }) => any[];\n\t// [source: Buffer, gauge: Buffer, baseY: number]\n}\n\ntype PredictorType = keyof PredictorInterface;\n\nexport type PyClientsConstructOptions = Partial>;\n\nexport class PyClients {\n\tclients = new Map>();\n\n\tconstructor(public readonly options: PyClientsConstructOptions, public readonly logger: Logger = console) {}\n\n\tasync getClient(type: PredictorType) {\n\t\tif (this.clients.has(type)) {\n\t\t\treturn this.clients.get(type);\n\t\t}\n\n\t\tconst [promise, resolve, reject] = destructPromise();\n\n\t\tconst opt = this.options[type];\n\n\t\tif (!opt) {\n\t\t\tthrow new Error(`no config for client \\`${type}\\` found`);\n\t\t}\n\n\t\ttry {\n\t\t\tif (typeof opt === 'string') {\n\t\t\t\tconst client = new ZeroClient();\n\t\t\t\tclient.bind(opt);\n\t\t\t\tresolve(client);\n\t\t\t} else {\n\t\t\t\tconst { scriptPath, ...option } = opt;\n\t\t\t\tconst client = new PyProcessor(scriptPath, option, this.logger);\n\t\t\t\tawait client.bind(`${await getPortPromise()}`);\n\t\t\t\tresolve(client);\n\t\t\t}\n\n\t\t\tthis.logger.info(`PyClients: ${type} started`);\n\t\t} catch (err) {\n\t\t\tthis.logger.error(`PyClients: ${type} start fail: ${JSON.stringify(err)}`);\n\t\t\treject(err);\n\t\t}\n\n\t\tthis.clients.set(type, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync checkHost(type: PredictorType): Promise {\n\t\tconst client = await this.getClient(type);\n\n\t\treturn client.request('checkHost');\n\t}\n\n\tasync warmup() {\n\t\tconst opts = Object.keys(this.options) as PredictorType[];\n\t\tawait Promise.all(opts.map((type) => this.getClient(type)));\n\t}\n\n\t/**\n\t * 模型预测\n\t * @param type layout | mask | gauge | semantic\n\t * @param args\n\t */\n\tasync predictScoreImages(type: T, ...args: Parameters): Promise> {\n\t\tconst clientType = type.split('$')[0] as PredictorType;\n\t\tconst client = await this.getClient(clientType);\n\t\tlet res = null;\n\n\t\tthis.logger.info(`[predictor]: ${type} py start..`);\n\t\tconst start = Date.now();\n\n\t\tswitch (type) {\n\t\t\tcase 'layout':\n\t\t\t\tres = await client.request('predictDetection', args);\n\t\t\t\tbreak;\n\t\t\tcase 'layout$reinforce':\n\t\t\t\tres = await client.request('predictReinforce', args);\n\t\t\t\tbreak;\n\t\t\tcase 'gauge':\n\t\t\tcase 'mask':\n\t\t\t\tres = await client.request('predict', args, { by_buffer: true });\n\t\t\t\tbreak;\n\t\t\tcase 'semantic':\n\t\t\tcase 'textLoc':\n\t\t\t\tres = await client.request('predict', args);\n\t\t\t\tbreak;\n\t\t\tcase 'textOcr':\n\t\t\tcase 'brackets':\n\t\t\tcase 'topo':\n\t\t\tcase 'gaugeRenderer':\n\t\t\tcase 'jianpu':\n\t\t\t\tres = await client.request('predict', ...args);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.logger.error(`[predictor]: no predictor ${type}`);\n\t\t}\n\n\t\tthis.logger.info(`[predictor]: ${type} py duration: ${Date.now() - start}ms`);\n\n\t\treturn res;\n\t}\n}\n","(function() {\n var base64map\n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n\n crypt = {\n // Bit-wise rotation left\n rotl: function(n, b) {\n return (n << b) | (n >>> (32 - b));\n },\n\n // Bit-wise rotation right\n rotr: function(n, b) {\n return (n << (32 - b)) | (n >>> b);\n },\n\n // Swap big-endian to little-endian and vice versa\n endian: function(n) {\n // If number given, swap endian\n if (n.constructor == Number) {\n return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;\n }\n\n // Else, assume array and swap all items\n for (var i = 0; i < n.length; i++)\n n[i] = crypt.endian(n[i]);\n return n;\n },\n\n // Generate an array of any length of random bytes\n randomBytes: function(n) {\n for (var bytes = []; n > 0; n--)\n bytes.push(Math.floor(Math.random() * 256));\n return bytes;\n },\n\n // Convert a byte array to big-endian 32-bit words\n bytesToWords: function(bytes) {\n for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)\n words[b >>> 5] |= bytes[i] << (24 - b % 32);\n return words;\n },\n\n // Convert big-endian 32-bit words to a byte array\n wordsToBytes: function(words) {\n for (var bytes = [], b = 0; b < words.length * 32; b += 8)\n bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a hex string\n bytesToHex: function(bytes) {\n for (var hex = [], i = 0; i < bytes.length; i++) {\n hex.push((bytes[i] >>> 4).toString(16));\n hex.push((bytes[i] & 0xF).toString(16));\n }\n return hex.join('');\n },\n\n // Convert a hex string to a byte array\n hexToBytes: function(hex) {\n for (var bytes = [], c = 0; c < hex.length; c += 2)\n bytes.push(parseInt(hex.substr(c, 2), 16));\n return bytes;\n },\n\n // Convert a byte array to a base-64 string\n bytesToBase64: function(bytes) {\n for (var base64 = [], i = 0; i < bytes.length; i += 3) {\n var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];\n for (var j = 0; j < 4; j++)\n if (i * 8 + j * 6 <= bytes.length * 8)\n base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));\n else\n base64.push('=');\n }\n return base64.join('');\n },\n\n // Convert a base-64 string to a byte array\n base64ToBytes: function(base64) {\n // Remove non-base-64 characters\n base64 = base64.replace(/[^A-Z0-9+\\/]/ig, '');\n\n for (var bytes = [], i = 0, imod4 = 0; i < base64.length;\n imod4 = ++i % 4) {\n if (imod4 == 0) continue;\n bytes.push(((base64map.indexOf(base64.charAt(i - 1))\n & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))\n | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));\n }\n return bytes;\n }\n };\n\n module.exports = crypt;\n})();\n","var charenc = {\n // UTF-8 encoding\n utf8: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));\n }\n },\n\n // Binary encoding\n bin: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n for (var bytes = [], i = 0; i < str.length; i++)\n bytes.push(str.charCodeAt(i) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n for (var str = [], i = 0; i < bytes.length; i++)\n str.push(String.fromCharCode(bytes[i]));\n return str.join('');\n }\n }\n};\n\nmodule.exports = charenc;\n","(function() {\n var crypt = require('crypt'),\n utf8 = require('charenc').utf8,\n bin = require('charenc').bin,\n\n // The core\n sha1 = function (message) {\n // Convert to byte array\n if (message.constructor == String)\n message = utf8.stringToBytes(message);\n else if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message))\n message = Array.prototype.slice.call(message, 0);\n else if (!Array.isArray(message))\n message = message.toString();\n\n // otherwise assume byte array\n\n var m = crypt.bytesToWords(message),\n l = message.length * 8,\n w = [],\n H0 = 1732584193,\n H1 = -271733879,\n H2 = -1732584194,\n H3 = 271733878,\n H4 = -1009589776;\n\n // Padding\n m[l >> 5] |= 0x80 << (24 - l % 32);\n m[((l + 64 >>> 9) << 4) + 15] = l;\n\n for (var i = 0; i < m.length; i += 16) {\n var a = H0,\n b = H1,\n c = H2,\n d = H3,\n e = H4;\n\n for (var j = 0; j < 80; j++) {\n\n if (j < 16)\n w[j] = m[i + j];\n else {\n var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16];\n w[j] = (n << 1) | (n >>> 31);\n }\n\n var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (\n j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :\n j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :\n j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :\n (H1 ^ H2 ^ H3) - 899497514);\n\n H4 = H3;\n H3 = H2;\n H2 = (H1 << 30) | (H1 >>> 2);\n H1 = H0;\n H0 = t;\n }\n\n H0 += a;\n H1 += b;\n H2 += c;\n H3 += d;\n H4 += e;\n }\n\n return [H0, H1, H2, H3, H4];\n },\n\n // Public API\n api = function (message, options) {\n var digestbytes = crypt.wordsToBytes(sha1(message));\n return options && options.asBytes ? digestbytes :\n options && options.asString ? bin.bytesToString(digestbytes) :\n crypt.bytesToHex(digestbytes);\n };\n\n api._blocksize = 16;\n api._digestsize = 20;\n\n module.exports = api;\n})();\n","import SparkMD5 from 'spark-md5';\n//import JSZip from 'jszip';\nimport * as starry from '../../src/starry';\n//import { encodeFindResource } from '../../src/isomorphic/converter';\nimport sharp, { FormatEnum } from 'sharp';\nimport got from 'got';\n//import { Logger } from './ZeroClient';\nimport type { SolutionStore, SaveIssueMeasure } from './store';\nimport { ScoreJSON } from '../../src/isomorphic/types';\n\nconst SYSTEM_MARGIN = 4;\n\nexport const constructSystem = ({ page, backgroundImage, detection, imageSize, position }) => {\n\tconst systemWidth = (detection.phi2 - detection.phi1) / detection.interval;\n\tconst systemHeight = imageSize.height / detection.interval;\n\n\tconst lastSystem = page.systems[page.systems.length - 1];\n\tconst top = position ? position.y : (lastSystem ? lastSystem.top + lastSystem.height : 0) + SYSTEM_MARGIN;\n\tconst left = position ? position.x : SYSTEM_MARGIN;\n\n\tconst stavesTops = [\n\t\t0,\n\t\t...Array(detection.middleRhos.length - 1)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => (detection.middleRhos[i] + detection.middleRhos[i + 1]) / 2 / detection.interval),\n\t];\n\n\tconst measureBars = [systemWidth];\n\n\tconst staves = stavesTops.map(\n\t\t(top, i) =>\n\t\t\tnew starry.Staff({\n\t\t\t\ttop,\n\t\t\t\theight: (stavesTops[i + 1] || systemHeight) - top,\n\t\t\t\tstaffY: detection.middleRhos[i] / detection.interval - top,\n\t\t\t\tmeasureBars,\n\t\t\t})\n\t);\n\n\t//console.log(\"detection:\", detection, options, stavesTops);\n\n\tconst imagePosition = {\n\t\tx: -detection.phi1 / detection.interval,\n\t\ty: 0,\n\t\twidth: imageSize.width / detection.interval,\n\t\theight: imageSize.height / detection.interval,\n\t};\n\n\treturn new starry.System({\n\t\tstaves,\n\t\tleft,\n\t\ttop,\n\t\twidth: systemWidth,\n\t\tbackgroundImage,\n\t\timagePosition,\n\t\tmeasureBars,\n\t});\n};\n\nexport interface ConvertOption {\n\tformat?: keyof FormatEnum;\n\tquality?: number;\n\tmaxHeight?: number;\n}\n\nconst toBuffer = async (url: string | Buffer): Promise => {\n\tif (typeof url === 'string') {\n\t\tif (/^https?:\\/\\//.test(url)) {\n\t\t\treturn (await got(url, { responseType: 'buffer', decompress: true, https: { rejectUnauthorized: false } })).body;\n\t\t}\n\n\t\tif (/^data:image\\//.test(url)) {\n\t\t\treturn Buffer.from(url.split(',')[1], 'base64');\n\t\t}\n\n\t\treturn Buffer.from(url);\n\t}\n\n\treturn url;\n};\n\n/**\n * 转换图片格式,默认webp、最大高度1080,高度小于1080自动不做尺寸变换\n * @param url\n * @param format\n * @param maxHeight\n * @param quality\n */\nexport async function convertImage(url: string | Buffer, { format = 'webp', maxHeight = 1080, quality = 80 }: ConvertOption = {}) {\n\tlet buf = await toBuffer(url);\n\n\tconst webpBuffer = await new Promise((resolve) => {\n\t\tsharp(buf)\n\t\t\t.resize({\n\t\t\t\twidth: maxHeight,\n\t\t\t\theight: maxHeight,\n\t\t\t\tfit: 'inside',\n\t\t\t\twithoutEnlargement: true,\n\t\t\t})\n\t\t\t.toFormat(format, { quality })\n\t\t\t.toBuffer((err, buf) => {\n\t\t\t\tresolve(buf);\n\t\t\t});\n\t});\n\n\tconst md5 = SparkMD5.ArrayBuffer.hash(webpBuffer);\n\n\treturn {\n\t\tbuffer: webpBuffer,\n\t\tfilename: `${md5}.${format}`,\n\t};\n}\n\n/**\n * 替换scoreJson图片地址\n * @param scoreJson\n * @param onReplaceImage\n */\nexport const replaceScoreJsonImages = (scoreJson: ScoreJSON, onReplaceImage: (src: string) => string = (src) => src) => {\n\tconst json = JSON.parse(JSON.stringify(scoreJson));\n\n\tjson.pages.forEach((page) => {\n\t\tpage?.src && (page.src = onReplaceImage(page?.src));\n\t});\n\n\tjson.lines.forEach((system) => {\n\t\tsystem.lineStaves.forEach((line) => {\n\t\t\tline.imgs.forEach((staff) => {\n\t\t\t\tstaff?.src && (staff.src = onReplaceImage(staff.src));\n\t\t\t});\n\t\t});\n\t});\n\n\treturn json;\n};\n\n/**\n * 获取scoreJson图片资源列表\n * @param scoreJson\n */\nexport const getScoreJsonImages = (scoreJson: ScoreJSON) => {\n\treturn [\n\t\t...scoreJson.pages.map((page) => page?.src),\n\t\t...scoreJson.lines\n\t\t\t.map((system) => system.lineStaves.map((staff) => staff.imgs))\n\t\t\t.flat(2)\n\t\t\t.map((staff) => staff?.src)\n\t\t\t.filter(Boolean),\n\t];\n};\n\ninterface ScorePatchesUpdateOptions {\n\tsolutionStore?: SolutionStore;\n}\n\nexport const updateScorePatches = (score: starry.Score, measures: starry.SpartitoMeasure[], options: ScorePatchesUpdateOptions = {}): void => {\n\tconsole.assert(\n\t\tmeasures.every((measure) => measure.validRegulated),\n\t\t'[updateScorePatches] some measures not valid regulated:',\n\t\tmeasures.filter((measure) => !measure.validRegulated)\n\t);\n\n\tscore.patches = measures.map((measure) => measure.createPatch());\n\n\tif (options?.solutionStore) {\n\t\tscore.assemble();\n\t\tconst spartito = score.makeSpartito();\n\n\t\tmeasures.forEach((measure) => {\n\t\t\toptions.solutionStore!.set(measure.regulationHash, { ...measure.asSolution(), priority: 1 });\n\t\t\tif (measure.regulationHash0 !== measure.regulationHash) {\n\t\t\t\tconst originMeasure = spartito.measures.find((m) => m.measureIndex === measure.measureIndex);\n\t\t\t\toptions.solutionStore!.set(measure.regulationHash0, { ...measure.asSolution(originMeasure), priority: 1 });\n\t\t\t}\n\t\t});\n\t}\n};\n\ninterface EditableMeasuresSaveOptions {\n\tstatus?: number;\n\tsolutionStore?: SolutionStore;\n}\n\nexport const saveEditableMeasures = async (\n\tscore: starry.Score,\n\tmeasureIndices: number[],\n\tsaveMeasure: SaveIssueMeasure,\n\t{ status = 2, solutionStore }: EditableMeasuresSaveOptions = {}\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\n\tconst measures = measureIndices\n\t\t.map((index) => spartito.measures.find((measure) => measure.measureIndex === index))\n\t\t.filter(Boolean) as starry.SpartitoMeasure[];\n\n\tif (solutionStore) {\n\t\tconst solutions = await solutionStore.batchGet(measures.map((measure) => measure.regulationHash0));\n\t\tmeasures.forEach((measure, i) => {\n\t\t\tconst solution = solutions[i];\n\t\t\tif (solution) measure.applySolution(solution);\n\t\t});\n\t}\n\n\tmeasures.forEach((measure) => {\n\t\tsaveMeasure({\n\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\tmeasure: new starry.EditableMeasure(measure),\n\t\t\tstatus,\n\t\t});\n\t});\n};\n","import sha1 from 'sha1';\nimport { Canvas, Image, loadImage } from 'skia-canvas';\nimport { WeakLRUCache } from 'weak-lru-cache';\nimport * as starry from '../../src/starry';\nimport { SemanticGraph } from '../../src/starry';\nimport { LayoutResult, PyClients } from './predictors';\nimport { constructSystem, convertImage } from './util';\n\nglobalThis.OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas;\n(globalThis as any).Image = (globalThis as any).Image || Image;\nglobalThis.btoa = globalThis.btoa || ((str: string) => Buffer.from(str, 'binary').toString('base64'));\n\nconst STAFF_PADDING_LEFT = 32;\n\nconst MAX_PAGE_WIDTH = 1200;\n\nconst GAUGE_VISION_SPEC = {\n\tviewportHeight: 256,\n\tviewportUnit: 8,\n};\n\nconst MASK_VISION_SPEC = {\n\tviewportHeight: 192,\n\tviewportUnit: 8,\n};\n\nconst SEMANTIC_VISION_SPEC = {\n\tviewportHeight: 192,\n\tviewportUnit: 8,\n};\n\ninterface OMRStat {\n\tcost: number; // in milliseconds\n\tpagesCost: number; // in milliseconds\n\tpages: number;\n}\n\ninterface OMRSummary {\n\tcostTotal: number; // in milliseconds\n\tcostPerPage: number; // in milliseconds\n\tpagesTotal: number;\n\tscoreN: number;\n}\n\n/**\n * 为布局识别的图片标准化处理\n * @param image\n * @param width\n */\nfunction scaleForLayout(image: Image, width: number): Canvas {\n\tlet height = (image.height / image.width) * width;\n\n\tconst canvas = new Canvas(width, height);\n\tconst ctx = canvas.getContext('2d');\n\n\tctx.drawImage(image, 0, 0, width, (width * image.height) / image.width);\n\n\treturn canvas;\n}\n\n/**\n * 根据所有图像的检测结果设置合适的全局页面尺寸\n * @param score\n * @param detections\n * @param outputWidth\n */\nfunction setGlobalPageSize(score: starry.Score, detections: LayoutResult[], outputWidth: number) {\n\tconst sizeRatios = detections\n\t\t.filter((s) => s && s.detection && s.detection.areas?.length)\n\t\t.map((v, k) => {\n\t\t\tconst staffInterval = Math.min(...v.detection.areas.filter((area) => area.staves?.middleRhos?.length).map((x) => x.staves.interval));\n\n\t\t\tconst sourceSize = v.sourceSize;\n\t\t\treturn {\n\t\t\t\t...v,\n\t\t\t\tindex: k,\n\t\t\t\tvw: sourceSize.width / staffInterval, // 页面宽度(逻辑单位)\n\t\t\t\thwr: sourceSize.height / sourceSize.width, // 页面高宽比\n\t\t\t};\n\t\t});\n\n\tif (!sizeRatios.length) {\n\t\tthrow new Error('empty result');\n\t}\n\n\tconst maxVW = sizeRatios.sort((a, b) => b.vw - a.vw)[0];\n\tconst maxAspect = Math.max(...sizeRatios.map((r) => r.hwr));\n\n\tscore.unitSize = outputWidth / maxVW.vw;\n\n\t// 页面显示尺寸\n\tscore.pageSize = {\n\t\twidth: outputWidth,\n\t\theight: outputWidth * maxAspect,\n\t};\n}\n\nconst batchTask = (fn: () => Promise) => fn();\nconst concurrencyTask = (fns: (() => Promise)[]) => Promise.all(fns.map((fn) => fn()));\n\nconst shootStaffImage = async (\n\tsystem: starry.System,\n\tstaffIndex: number,\n\t{ paddingLeft = 0, scaling = 1, spec }: { paddingLeft?: number; scaling?: number; spec: { viewportHeight: number; viewportUnit: number } }\n): Promise => {\n\tif (!system || !system.backgroundImage) return null;\n\n\tconst staff = system.staves[staffIndex];\n\tif (!staff) return null;\n\n\tconst middleUnits = spec.viewportHeight / spec.viewportUnit / 2;\n\n\tconst width = system.imagePosition.width * spec.viewportUnit;\n\tconst height = system.imagePosition.height * spec.viewportUnit;\n\tconst x = system.imagePosition.x * spec.viewportUnit + paddingLeft;\n\tconst y = (system.imagePosition.y - (staff.top + staff.staffY - middleUnits)) * spec.viewportUnit;\n\n\tconst canvas = new Canvas(Math.round(width + x) * scaling, spec.viewportHeight * scaling);\n\tconst context = canvas.getContext('2d');\n\tcontext.fillStyle = 'white';\n\tcontext.fillRect(0, 0, canvas.width, canvas.height);\n\tcontext.drawImage(await loadImage(system.backgroundImage), x * scaling, y * scaling, width * scaling, height * scaling);\n\n\treturn canvas;\n\t// .substr(22);\t// remove the prefix of 'data:image/png;base64,'\n};\n\n/**\n * 根据布局检测结果进行截图\n * @param score\n * @param pageCanvas\n * @param page\n * @param detection\n */\nasync function shootImageByDetection({\n\tpage,\n\tscore,\n\tpageCanvas,\n}: {\n\tscore: starry.Score;\n\tpage: starry.Page;\n\tpageCanvas: Canvas; // 原始图片绘制好的canvas\n}) {\n\tif (!page?.layout?.areas?.length) {\n\t\treturn null;\n\t}\n\n\tpage.width = score.pageSize.width / score.unitSize;\n\tpage.height = score.pageSize.height / score.unitSize;\n\n\tconst correctCanvas = new Canvas(pageCanvas.width, pageCanvas.height);\n\tconst ctx = correctCanvas.getContext('2d');\n\n\tctx.save();\n\n\tconst { width, height } = correctCanvas;\n\tconst [a, b, c, d] = page.source.matrix;\n\n\tctx.setTransform(a, b, c, d, (-1 / 2) * width + (1 / 2) * a * width + (1 / 2) * b * height, (-1 / 2) * height + (1 / 2) * c * width + (1 / 2) * d * height);\n\n\tctx.drawImage(pageCanvas, 0, 0);\n\n\tctx.restore();\n\n\tconst interval = page.source.interval;\n\n\tpage.layout.areas.map((area, systemIndex) => {\n\t\tconsole.assert(area.staves?.middleRhos?.length, '[shootImageByDetection] empty area:', area);\n\n\t\tconst data = ctx.getImageData(area.x, area.y, area.width, area.height);\n\n\t\tconst canvas = new Canvas(area.width, area.height);\n\n\t\tconst context = canvas.getContext('2d');\n\t\t// context.rotate(-area.staves.theta);\n\t\tcontext.putImageData(data, 0, 0);\n\n\t\tconst detection = area.staves;\n\t\tconst size = { width: area.width, height: area.height };\n\n\t\tconst sourceCenter = {\n\t\t\tx: pageCanvas.width / 2 / interval,\n\t\t\ty: pageCanvas.height / 2 / interval,\n\t\t};\n\n\t\tconst position = {\n\t\t\tx: (area.x + area.staves.phi1) / interval - sourceCenter.x + page.width / 2,\n\t\t\ty: area.y / interval - sourceCenter.y + page.height / 2,\n\t\t};\n\n\t\tpage.systems[systemIndex] = constructSystem({\n\t\t\tpage,\n\t\t\tbackgroundImage: canvas.toBufferSync('png'),\n\t\t\tdetection,\n\t\t\timageSize: size,\n\t\t\tposition,\n\t\t});\n\t});\n\n\treturn correctCanvas;\n}\n\nasync function shootStaffBackgroundImage({ system, staff, staffIndex }: { system: starry.System; staff: starry.Staff; staffIndex: number }) {\n\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\tspec: SEMANTIC_VISION_SPEC,\n\t});\n\n\tstaff.backgroundImage = sourceCanvas.toBufferSync('png');\n\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - SEMANTIC_VISION_SPEC.viewportHeight / 2 / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\twidth: sourceCanvas.width / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\theight: sourceCanvas.height / SEMANTIC_VISION_SPEC.viewportUnit,\n\t};\n}\n\n/**\n * 单个staff的变形矫正\n * @param system\n * @param staff\n * @param staffIndex\n * @param gaugeImage\n * @param pyClients\n */\nasync function gaugeStaff({\n\tsystem,\n\tstaff,\n\tstaffIndex,\n\tgaugeImage,\n\tpyClients,\n}: {\n\tsystem: starry.System;\n\tstaff: starry.Staff;\n\tstaffIndex: number;\n\tgaugeImage: Buffer;\n\tpyClients: PyClients;\n}) {\n\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\tspec: GAUGE_VISION_SPEC,\n\t\tscaling: 2,\n\t});\n\n\tconst sourceBuffer = sourceCanvas.toBufferSync('png');\n\n\tconst baseY = (system.middleY - (staff.top + staff.staffY)) * GAUGE_VISION_SPEC.viewportUnit + GAUGE_VISION_SPEC.viewportHeight / 2;\n\n\tconst { buffer, size } = await pyClients.predictScoreImages('gaugeRenderer', [sourceBuffer, gaugeImage, baseY]);\n\n\tstaff.backgroundImage = buffer;\n\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / GAUGE_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - size.height / 2 / GAUGE_VISION_SPEC.viewportUnit,\n\t\twidth: size.width / GAUGE_VISION_SPEC.viewportUnit,\n\t\theight: size.height / GAUGE_VISION_SPEC.viewportUnit,\n\t};\n\n\tstaff.maskImage = null;\n}\n\n/**\n * 单个staff的降噪\n * @param staff\n * @param staffIndex\n * @param maskImage\n */\nasync function maskStaff({ staff, staffIndex, maskImage }: { staff: starry.Staff; staffIndex: number; maskImage: Buffer }) {\n\tconst img = await loadImage(maskImage);\n\n\tstaff.maskImage = maskImage;\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / MASK_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - MASK_VISION_SPEC.viewportHeight / 2 / MASK_VISION_SPEC.viewportUnit,\n\t\twidth: img.width / MASK_VISION_SPEC.viewportUnit,\n\t\theight: img.height / MASK_VISION_SPEC.viewportUnit,\n\t};\n}\n\n/**\n * 单个staff的语义识别\n * @param score\n * @param staffIndex\n * @param system\n * @param staff\n * @param graph\n */\nasync function semanticStaff({\n\tscore,\n\tstaffIndex,\n\tsystem,\n\tstaff,\n\tgraph,\n}: {\n\tscore: starry.Score;\n\tstaffIndex: number;\n\tsystem: starry.System;\n\tstaff: starry.Staff;\n\tgraph: SemanticGraph;\n}) {\n\tgraph.offset(-STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, 0);\n\n\tsystem.assignSemantics(staffIndex, graph);\n\n\tstaff.assignSemantics(graph);\n\tstaff.clearPredictedTokens();\n\n\tscore.assembleSystem(system, score.settings?.semanticConfidenceThreshold || 1);\n}\n\nfunction replacePageImages(page: starry.Page, onReplaceImageKey: (src: string) => any) {\n\tconst tasks = [\n\t\t[page.source, 'url'],\n\t\t...page.systems\n\t\t\t.map((system) => {\n\t\t\t\treturn [\n\t\t\t\t\t[system, 'backgroundImage'],\n\t\t\t\t\t...system.staves\n\t\t\t\t\t\t.map((staff) => [\n\t\t\t\t\t\t\t[staff, 'backgroundImage'],\n\t\t\t\t\t\t\t[staff, 'maskImage'],\n\t\t\t\t\t\t])\n\t\t\t\t\t\t.flat(),\n\t\t\t\t];\n\t\t\t})\n\t\t\t.flat(),\n\t];\n\n\ttasks.map(([target, key]: [any, string]) => {\n\t\ttarget[key] = onReplaceImageKey(target[key]);\n\t});\n}\n\nexport type TaskProgress = { total?: number; finished?: number };\n\nexport interface OMRPage {\n\turl: string | Buffer;\n\tkey?: string;\n\tlayout?: LayoutResult;\n\trenew?: boolean;\n\tenableGauge?: boolean;\n}\n\nexport interface ProgressState {\n\tlayout?: TaskProgress;\n\ttext?: TaskProgress;\n\tgauge?: TaskProgress;\n\tmask?: TaskProgress;\n\tsemantic?: TaskProgress;\n\tregulate?: TaskProgress;\n\tbrackets?: TaskProgress;\n}\n\nclass OMRProgress {\n\tstate: ProgressState = {};\n\n\tonChange: (evt: ProgressState) => void;\n\n\tconstructor(onChange: (evt: ProgressState) => void) {\n\t\tthis.onChange = onChange;\n\t}\n\n\tsetTotal(stage: keyof ProgressState, total: number) {\n\t\tthis.state[stage] = this.state[stage] || {\n\t\t\ttotal,\n\t\t\tfinished: 0,\n\t\t};\n\t}\n\n\tincrease(stage: keyof ProgressState, step = 1) {\n\t\tconst info: TaskProgress = this.state[stage] || {\n\t\t\tfinished: 0,\n\t\t};\n\t\tinfo.finished += step;\n\n\t\tthis.onChange(this.state);\n\t}\n}\n\ntype SourceImage = string | Buffer;\n\nexport interface OMROption {\n\toutputWidth?: number;\n\ttitle?: string; // 曲谱标题\n\tpageStore?: {\n\t\thas?: (key: string) => Promise;\n\t\tget: (key: string) => Promise;\n\t\tset: (key: string, val: string) => Promise;\n\t};\n\trenew?: boolean;\n\tprocesses?: (keyof ProgressState)[]; // 选择流程\n\tonProgress?: (progress: ProgressState) => void;\n\tonReplaceImage?: (src: SourceImage) => Promise; // 替换所有图片地址,用于上传或者格式转换\n}\n\nconst lruCache = new WeakLRUCache();\n\n// 默认store\nconst pageStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as string;\n\t},\n\tasync set(key: string, val: string) {\n\t\tlruCache.setValue(key, val);\n\t},\n};\n\n/**\n * 默认将图片转换为webp格式的base64字符串\n * @param src\n */\nconst onReplaceImage = async (src: SourceImage) => {\n\tif (src instanceof Buffer || (typeof src === 'string' && (/^https?:\\/\\//.test(src) || /^data:image\\//.test(src)))) {\n\t\tconst webpBuffer = (await convertImage(src)).buffer;\n\t\treturn `data:image/webp;base64,${webpBuffer.toString('base64')}`;\n\t}\n\n\treturn src;\n};\n\n/**\n * 识别所有图片\n * @param pyClients\n * @param images\n * @param option\n */\nexport const predictPages = async (\n\tpyClients: PyClients,\n\timages: OMRPage[],\n\toption: OMROption = { outputWidth: 1200, pageStore, onReplaceImage }\n): Promise<{ score: starry.Score; omitPages: number[]; stat: OMRStat }> => {\n\tconst logger = pyClients.logger;\n\n\toption.outputWidth = option.outputWidth || 1200;\n\toption.pageStore = option.pageStore || pageStore;\n\toption.onReplaceImage = option.onReplaceImage || onReplaceImage;\n\n\toption.processes =\n\t\tArray.isArray(option.processes) && option.processes.length > 0 ? option.processes : ['layout', 'text', 'gauge', 'mask', 'semantic', 'brackets'];\n\tconst progress: OMRProgress = new OMRProgress(option.onProgress);\n\n\tconst t0 = Date.now();\n\n\t// 预处理删除不合法区域\n\timages.forEach((image) => {\n\t\tif (image.layout?.detection) {\n\t\t\timage.layout.detection.areas = image.layout.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0);\n\t\t} else {\n\t\t\tdelete image.layout;\n\t\t}\n\t});\n\n\tconst score = new starry.Score({\n\t\ttitle: option?.title,\n\t\tstavesCount: 2,\n\t\tpaperOptions: {\n\t\t\traggedLast: true,\n\t\t\traggedLastBottom: true,\n\t\t},\n\t\theaders: {},\n\t\tinstrumentDict: {},\n\t\tsettings: {\n\t\t\tenabledGauge: option.processes.includes('gauge'),\n\t\t\tsemanticConfidenceThreshold: 1,\n\t\t},\n\t});\n\n\tlogger.info(`[predictor]: download_source_images-${images.length}`);\n\n\t// 原始拍摄图\n\tconst originalImages: Image[] = await Promise.all(images.map((img) => loadImage(img.url as any)));\n\n\tlogger.info(`[predictor]: source_images_downloaded-${images.length}`);\n\n\t//const INPUT_IMAGE_WIDTH = images.filter((x) => x?.layout?.interval)?.[0]?.layout?.sourceSize?.width;\n\n\t/******************************* 布局识别 start *************************/\n\t// 输入给布局检测的图\n\tconst pageCanvasList: Canvas[] = originalImages.map((img, index) => scaleForLayout(img, images[index]!.layout?.sourceSize?.width ?? img.width));\n\n\tprogress.setTotal('layout', originalImages.length);\n\tprogress.setTotal('text', originalImages.length);\n\n\tconst detections = await Promise.all(\n\t\tpageCanvasList.map(async (cvs, key) => {\n\t\t\tif (!images[key].layout) return (await pyClients.predictScoreImages('layout', [cvs.toBufferSync('png')]))?.[0];\n\n\t\t\t// reinforce layout from front-end if no gauge\n\t\t\tif (!images[key].enableGauge && images[key]?.layout?.detection?.areas?.length)\n\t\t\t\treturn (await pyClients.predictScoreImages('layout$reinforce', [cvs.toBufferSync('png')], [images[key].layout]))?.[0];\n\n\t\t\treturn images[key].layout;\n\t\t})\n\t);\n\n\tdetections.forEach((page) => {\n\t\tpage.detection.areas = page.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0);\n\t});\n\n\tconst imageURLMap = new Map();\n\tconst collectImage = async (source: SourceImage): Promise => {\n\t\tconst url = await option.onReplaceImage(source);\n\t\timageURLMap.set(source, url);\n\t};\n\n\t// 根据所有页面的宽高比决定全局显示尺寸\n\tsetGlobalPageSize(score, detections, option.outputWidth);\n\n\tasync function createPage(detect, pageIndex) {\n\t\tconst { url, key, layout, enableGauge } = images[pageIndex];\n\n\t\tconst pageKey = sha1(JSON.stringify({ key: key || url, layout, enableGauge }));\n\n\t\tconst cachedPageJson = await option.pageStore.get(pageKey);\n\n\t\tconst omit = !option.renew && ((cachedPageJson && !images[pageIndex].renew) || !detect.detection.areas?.length);\n\n\t\tconst page = (score.pages[pageIndex] =\n\t\t\tomit && cachedPageJson\n\t\t\t\t? starry.recoverJSON(cachedPageJson, starry)\n\t\t\t\t: new starry.Page({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tname: key || (typeof url === 'string' && /https?:\\/\\//.test(url) ? url : null),\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tcrop: {\n\t\t\t\t\t\t\t\tunit: '%',\n\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\twidth: 100,\n\t\t\t\t\t\t\t\theight: 100,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdimensions: detect.sourceSize,\n\t\t\t\t\t\t\tmatrix: [Math.cos(detect.theta), -Math.sin(detect.theta), Math.sin(detect.theta), Math.cos(detect.theta), 0, 0],\n\t\t\t\t\t\t\tinterval: detect.interval,\n\t\t\t\t\t\t\tneedGauge: images[pageIndex].enableGauge,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlayout: detect.detection,\n\t\t\t\t }));\n\n\t\tconst correctCanvas = omit\n\t\t\t? null\n\t\t\t: await shootImageByDetection({\n\t\t\t\t\tscore,\n\t\t\t\t\tpage,\n\t\t\t\t\tpageCanvas: pageCanvasList[pageIndex],\n\t\t\t });\n\n\t\tprogress.increase('layout');\n\n\t\treturn {\n\t\t\tpage,\n\t\t\tomit,\n\t\t\thash: pageKey,\n\t\t\tcorrectCanvas,\n\t\t};\n\t}\n\n\tconst systemsCount = detections.reduce((acc, x) => acc + (x.detection.areas?.length ?? 0), 0);\n\tconst stavesCount = detections.reduce((acc, x) => acc + (x.detection.areas?.reduce?.((a, y) => a + (y.staves?.middleRhos?.length ?? 0), 0) ?? 0), 0);\n\n\tprogress.setTotal('gauge', stavesCount);\n\tprogress.setTotal('mask', stavesCount);\n\tprogress.setTotal('semantic', stavesCount);\n\tprogress.setTotal('brackets', systemsCount);\n\n\tconst allTasks = [];\n\n\tconst omitPages = [];\n\n\tconst t1 = Date.now();\n\n\tlet n_page = 0;\n\n\tfor (const pageIndex of detections.keys()) {\n\t\tconst pageTasks = [];\n\n\t\tconst { page, correctCanvas, omit, hash } = await createPage(detections[pageIndex], pageIndex);\n\n\t\tpageTasks.push(collectImage(page.source.url));\n\t\tpageTasks.push(...page.systems.map((system) => collectImage(system.backgroundImage)));\n\n\t\tlogger.info(`[predictor]: check_cache_pageIndex-${pageIndex} omit: ${omit}`);\n\t\tif (omit) {\n\t\t\tomitPages.push(pageIndex);\n\t\t} else {\n\t\t\tconst staves = page.systems\n\t\t\t\t.map((system, systemIndex) => system.staves.map((staff, staffIndex) => ({ pageIndex, systemIndex, staffIndex, page, system, staff })))\n\t\t\t\t.flat(1);\n\n\t\t\tawait concurrencyTask([\n\t\t\t\t/******************************* 括号检测 start *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!option.processes.includes('brackets')) return;\n\n\t\t\t\t\tconst detection = page.layout;\n\t\t\t\t\tconst interval = page.source.interval;\n\n\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\tconst bracketImages = page.systems.map((system, systemIndex) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\tstaves: { middleRhos, phi1 },\n\t\t\t\t\t\t} = detection.areas[systemIndex];\n\n\t\t\t\t\t\tconst topMid = middleRhos[0];\n\t\t\t\t\t\tconst bottomMid = middleRhos[middleRhos.length - 1];\n\n\t\t\t\t\t\tconst sourceRect = {\n\t\t\t\t\t\t\tx: x + phi1 - 4 * interval,\n\t\t\t\t\t\t\ty: y + topMid - 4 * interval,\n\t\t\t\t\t\t\twidth: 8 * interval,\n\t\t\t\t\t\t\theight: bottomMid - topMid + 8 * interval,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst OUTPUT_INTERVAL = 8;\n\n\t\t\t\t\t\tconst canvas = new Canvas(OUTPUT_INTERVAL * 8, (sourceRect.height / interval) * OUTPUT_INTERVAL);\n\n\t\t\t\t\t\tconst context = canvas.getContext('2d');\n\t\t\t\t\t\tcontext.drawImage(correctCanvas, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height, 0, 0, canvas.width, canvas.height);\n\n\t\t\t\t\t\t// console.log(pageIndex, systemIndex, JSON.stringify(sourceRect), correctCanvas.width, correctCanvas.height)\n\t\t\t\t\t\t// const pctx = canvas.getContext('2d')\n\t\t\t\t\t\t// pctx.strokeStyle = 'red'\n\t\t\t\t\t\t// pctx.fillStyle = 'rgba(255, 0, 0, 0.2)'\n\t\t\t\t\t\t// pctx.fillRect(sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height)\n\t\t\t\t\t\t// const area = detections[pageIndex].detection.areas[systemIndex]\n\t\t\t\t\t\t// pctx.strokeStyle = 'green'\n\t\t\t\t\t\t// pctx.fillStyle = 'rgba(0, 255, 0, 0.1)'\n\t\t\t\t\t\t// pctx.fillRect(area.x, area.y, area.width, area.height)\n\t\t\t\t\t\t// pctx.fillRect(area.x, area.y, area.width, area.height)\n\t\t\t\t\t\t// require('fs').writeFile(`test--system-${systemIndex}.png`, canvas.toBufferSync('png'), () => {})\n\t\t\t\t\t\t// require('fs-extra').writeFile(`test--brackets-${pageIndex}-${systemIndex}.png`, canvas.toBufferSync('png'))\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tbuffer: canvas.toBufferSync('png'),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\tlogger.info(`[predictor]: brackets js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\tconst bracketsRes = await pyClients.predictScoreImages('brackets', { buffers: bracketImages.map((x) => x.buffer) });\n\t\t\t\t\tprogress.increase('brackets', bracketImages.length);\n\n\t\t\t\t\tbracketImages.forEach(({ system }, index) => {\n\t\t\t\t\t\tif (bracketsRes[index]) {\n\t\t\t\t\t\t\tsystem.bracketsAppearance = bracketsRes[index];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t/******************************* 括号检测 end *************************/\n\n\t\t\t\t/******************************* 文本识别 start *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!option.processes.includes('text')) return;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t// await require('fs-extra').writeFile(`test--text-location-${pageIndex}.png`, correctCanvas.toBufferSync('png'))\n\t\t\t\t\t\tconst bufferForText = correctCanvas.toBufferSync('png');\n\n\t\t\t\t\t\tconst resultLoc = await pyClients.predictScoreImages('textLoc', [bufferForText]);\n\n\t\t\t\t\t\tconst location = resultLoc[0].filter((box) => box.score > 0);\n\n\t\t\t\t\t\tif (location.length > 0) {\n\t\t\t\t\t\t\tconst [resultOCR] = await pyClients.predictScoreImages('textOcr', {\n\t\t\t\t\t\t\t\tbuffers: [bufferForText],\n\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tpage.assignTexts(resultOCR.areas, resultOCR.imageSize);\n\t\t\t\t\t\t\tpage.assemble();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger.info(`[predictor]: text js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\tprogress.increase('text');\n\n\t\t\t\t\t\tif (!option.title) {\n\t\t\t\t\t\t\tconst coverTexts: {\n\t\t\t\t\t\t\t\tconfidence: number;\n\t\t\t\t\t\t\t\tfontSize: number;\n\t\t\t\t\t\t\t\tid: string;\n\t\t\t\t\t\t\t\ttext: string;\n\t\t\t\t\t\t\t\ttextType: 'Title' | 'Author';\n\t\t\t\t\t\t\t\ttype: starry.TokenType;\n\t\t\t\t\t\t\t\twidth_: number;\n\t\t\t\t\t\t\t\tx: number;\n\t\t\t\t\t\t\t\ty: number;\n\t\t\t\t\t\t\t}[] = score.pages[0].tokens as any;\n\n\t\t\t\t\t\t\tif (Array.isArray(coverTexts) && coverTexts.length > 0) {\n\t\t\t\t\t\t\t\tconst [titleToken] = coverTexts\n\t\t\t\t\t\t\t\t\t.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Title')\n\t\t\t\t\t\t\t\t\t.sort((a, b) => b.fontSize - a.fontSize);\n\n\t\t\t\t\t\t\t\tif (titleToken) {\n\t\t\t\t\t\t\t\t\tscore.title = titleToken.text;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error(`[predictor]: text js [pageIndex-${pageIndex}] ${JSON.stringify(err)}`);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t/******************************* 文本识别 end *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\t/******************************* 变形矫正 start *************************/\n\t\t\t\t\tawait batchTask(async () => {\n\t\t\t\t\t\tconst disableGauge = !option.processes.includes('gauge') || images[pageIndex].enableGauge === false;\n\n\t\t\t\t\t\tif (!disableGauge) {\n\t\t\t\t\t\t\tconst gaugeRes = await pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t'gauge',\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tstaves.map(async ({ staffIndex, system }) => {\n\t\t\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\t\t\t\t\t\t\t\t\t\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\t\t\t\t\t\t\t\t\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\t\t\t\t\t\t\t\t\t\tspec: GAUGE_VISION_SPEC,\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js shoot [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\t\t\t\t\treturn sourceCanvas.toBufferSync('png');\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfor (const [index, { system, staff, pageIndex, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] start..`);\n\t\t\t\t\t\t\t\tawait gaugeStaff({\n\t\t\t\t\t\t\t\t\tpyClients,\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tgaugeImage: gaugeRes[index].image,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\t\t\tprogress.increase('gauge');\n\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.backgroundImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (const [_, { system, staff, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tawait shootStaffBackgroundImage({\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.backgroundImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\t/******************************* 变形矫正 end *************************/\n\n\t\t\t\t\tawait concurrencyTask([\n\t\t\t\t\t\t/******************************* 降噪 start *************************/\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tif (!option.processes.includes('mask')) return;\n\n\t\t\t\t\t\t\tconst maskRes = await pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t'mask',\n\t\t\t\t\t\t\t\tstaves.map(({ staff }) => staff.backgroundImage as Buffer)\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfor (const [index, { staff, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tawait maskStaff({\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tmaskImage: maskRes[index].image,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: mask js [page-${pageIndex}, ${index}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\t\t\t\t\t\t\t\tprogress.increase('mask');\n\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.maskImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/******************************* 降噪 end *************************/\n\n\t\t\t\t\t\t/******************************* 语义识别 start *************************/\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tif (!option.processes.includes('semantic')) return;\n\n\t\t\t\t\t\t\tconst semanticRes = starry.recoverJSON(\n\t\t\t\t\t\t\t\tawait pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t\t'semantic',\n\t\t\t\t\t\t\t\t\tstaves.map(({ staff }) => staff.backgroundImage as Buffer)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tstarry\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tstaves.forEach(({ system }) => system.clearTokens());\n\n\t\t\t\t\t\t\tfor (const [index, { staffIndex, system, staff }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tawait semanticStaff({\n\t\t\t\t\t\t\t\t\tscore,\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tgraph: semanticRes[index],\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t\t\t`[predictor]: semantic js [page-${pageIndex}, system-${system.index}, staff-${staff.index}] duration: ${\n\t\t\t\t\t\t\t\t\t\tDate.now() - startTime\n\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tprogress.increase('semantic');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/******************************* 语义识别 end *************************/\n\t\t\t\t\t]);\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\t++n_page;\n\t\t}\n\n\t\tallTasks.push(\n\t\t\tPromise.all(pageTasks).then(() => {\n\t\t\t\treplacePageImages(page, (src) => imageURLMap.get(src));\n\t\t\t\tlogger.info(`[predictor]: pageStore set: [${pageIndex}]`);\n\t\t\t\treturn option.pageStore.set(hash, JSON.stringify(page));\n\t\t\t})\n\t\t);\n\t}\n\n\tconst t2 = Date.now();\n\n\tawait Promise.all(allTasks);\n\n\tlogger.info(`[predictor]: inferenceStaffLayout: ${score.title}, [${score.systems.length}]`);\n\n\tscore.inferenceStaffLayout();\n\n\tlogger.info(`[predictor]: done: ${score.title}`);\n\n\t// correct semantic ids\n\tscore.assemble();\n\n\tconst t3 = Date.now();\n\n\treturn {\n\t\tscore,\n\t\tomitPages,\n\t\tstat: {\n\t\t\tcost: t3 - t0,\n\t\t\tpagesCost: t2 - t1,\n\t\t\tpages: n_page,\n\t\t},\n\t};\n};\n\nexport const abstractOMRStats = (stats: OMRStat[]): OMRSummary => {\n\tconst { costTotal, pagesCostTotal, pagesTotal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcostTotal: sum.costTotal + stat.cost,\n\t\t\tpagesCostTotal: sum.pagesCostTotal + stat.pagesCost,\n\t\t\tpagesTotal: sum.pagesTotal + stat.pages,\n\t\t}),\n\t\t{ costTotal: 0, pagesCostTotal: 0, pagesTotal: 0 }\n\t);\n\n\treturn {\n\t\tcostTotal,\n\t\tcostPerPage: pagesTotal ? costTotal / pagesTotal : null,\n\t\tpagesTotal,\n\t\tscoreN: stats.length,\n\t};\n};\n","import { EventTerm } from './term';\nimport type { SpartitoMeasure } from './spartitoMeasure';\n\ninterface EventRectification {\n\tid: number;\n\tdivision?: number;\n\tdots?: number;\n}\n\n// Here suppose sum of pvals equal to 1.\nconst multinomial_1 = (pvals: number[]): number => {\n\tconst n = Math.random();\n\n\tlet s = 0;\n\tfor (let i = 0; i < pvals.length; ++i) {\n\t\ts += pvals[i];\n\t\tif (s > n) return i;\n\t}\n\n\treturn pvals.length - 1;\n};\n\nconst looseVector = (ns: number[], factor = 0.9): number[] => {\n\tconst logits = ns.map((n) => Math.log(n) * factor);\n\tconst n2 = logits.map(Math.exp);\n\n\tconst sum = n2.reduce((sum, x) => sum + x, 0);\n\n\treturn n2.map((x) => x / sum);\n};\n\nconst looseEvent = (event: EventTerm): EventTerm => {\n\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return event;\n\n\tconst divisionVector = event.predisposition?.divisionVector ? looseVector(event.predisposition.divisionVector) : null;\n\tconst dotsVector = event.predisposition?.dotsVector ? looseVector(event.predisposition.dotsVector) : null;\n\n\treturn new EventTerm({\n\t\t...event,\n\t\tpredisposition: {\n\t\t\t...event.predisposition,\n\t\t\tdivisionVector,\n\t\t\tdotsVector,\n\t\t},\n\t});\n};\n\nclass MeasureRectification {\n\tevents: EventRectification[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\ttoString(): string {\n\t\treturn this.events\n\t\t\t.map((event) => {\n\t\t\t\tif (!event) return '';\n\n\t\t\t\tconst { division = '', dots = '' } = event;\n\t\t\t\treturn `${division}|${dots}`;\n\t\t\t})\n\t\t\t.join(',');\n\t}\n\n\tstatic default(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tconst division = event.predisposition.divisionVector ? event.division : undefined;\n\t\t\t\tconst dots = event.predisposition.dotsVector ? event.dots : undefined;\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n\n\tstatic roll(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tlet division = undefined;\n\t\t\t\tlet dots = undefined;\n\n\t\t\t\tif (event.predisposition.divisionVector) division = multinomial_1(event.predisposition.divisionVector);\n\n\t\t\t\tif (event.predisposition.dotsVector) dots = multinomial_1(event.predisposition.dotsVector);\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n}\n\nconst genMeasureRectifications = function* (measure: SpartitoMeasure): Generator {\n\tconst keys = new Set();\n\n\tconst origin = MeasureRectification.default(measure.events);\n\tkeys.add(origin.toString());\n\n\tyield origin;\n\n\tlet stale = 0;\n\tlet events = measure.events;\n\n\twhile (stale < 100) {\n\t\tif (stale && stale % 10 === 0) events = events.map(looseEvent);\n\n\t\tconst rectification = MeasureRectification.roll(events);\n\t\tconst key = rectification.toString();\n\n\t\tif (keys.has(key)) {\n\t\t\t++stale;\n\t\t\tcontinue;\n\t\t}\n\n\t\tstale = 0;\n\n\t\tkeys.add(key);\n\t\tyield rectification;\n\t}\n};\n\nexport { MeasureRectification, genMeasureRectifications };\n","import { WeakLRUCache } from 'weak-lru-cache';\n\nimport { RegulationSolution, SpartitoMeasure } from '../../src/starry';\n\nconst lruCache = new WeakLRUCache();\n\ninterface SolutionStore {\n\tget: (key: string) => Promise;\n\tset: (key: string, val: RegulationSolution) => Promise;\n\tbatchGet: (keys: string[]) => Promise;\n}\n\n// 默认store\nconst DefaultSolutionStore: SolutionStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as RegulationSolution;\n\t},\n\tasync set(key: string, val: RegulationSolution) {\n\t\tlruCache.setValue(key, val);\n\t},\n\tasync batchGet(keys: string[]) {\n\t\treturn keys.map((key) => lruCache.getValue(key) as RegulationSolution);\n\t},\n};\n\nconst enum MeasureStatus {\n\tDiscard = -1,\n\tSolved = 0,\n\tIssue = 1,\n\tFatal = 2,\n}\n\ninterface IssueMeasure {\n\tscoreId: string;\n\tmeasureIndex: number;\n\tmeasure: SpartitoMeasure;\n\tstatus: MeasureStatus;\n}\n\ntype SaveIssueMeasure = (data: Omit) => void;\n\nexport { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure };\n","import * as starry from '../../src/starry';\nimport { Logger } from './ZeroClient';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure, MeasureStatus } from './store';\n\ninterface BeadRegulationCounting {\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface RegulationBeadStat {\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tmeasures: BeadRegulationCounting;\n\tqualityScore: number;\n}\n\ninterface RegulationBeadSummary {\n\tscoreN: number;\n\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tcostPerMeasure: number | null; // in milliseconds\n\tcostPerTime: number | null; // in milliseconds\n\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface ProgressInfo {\n\tpass: number;\n\tremaining: number;\n\ttotal: number;\n}\n\ninterface RegulateBeadOption {\n\tlogger?: Logger;\n\tpickers: starry.BeadPicker[];\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tfreshOnly?: boolean;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n\tonProgress?: (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => void;\n\tonPassStart?: (pass: number, conditionName: string, pendingCount: number) => void;\n}\n\ninterface MeasureReord {\n\torigin: starry.SpartitoMeasure;\n\tcurrent: starry.SpartitoMeasure;\n\tevaluation?: starry.MeasureEvaluation;\n\tbaseQuality: number;\n\tpicker: starry.BeadPicker;\n}\n\ninterface BeadSolverOptions {\n\tstopLoss: number;\n\tquotaMax: number;\n\tquotaFactor: number;\n\tptFactor: number;\n}\n\nenum PendingCondition {\n\tErrorOnly,\n\tNotFine,\n\tImperfect,\n}\n\nconst isPending = (evaluation: starry.MeasureEvaluation, condition: PendingCondition) => {\n\tswitch (condition) {\n\t\tcase PendingCondition.ErrorOnly:\n\t\t\treturn evaluation.error;\n\n\t\tcase PendingCondition.Imperfect:\n\t\t\treturn !evaluation.perfect;\n\t}\n\n\treturn !evaluation.fine;\n};\n\ntype OnUpdate = (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean) => void;\n\nconst solveMeasureRecords = async (\n\trecords: MeasureReord[],\n\tonUpdate: OnUpdate,\n\tstdout: NodeJS.WritableStream | null,\n\toptions: Partial,\n\tpendingCondition: PendingCondition = PendingCondition.NotFine,\n\tpass: number = 0,\n\tonProgress?: RegulateBeadOption['onProgress']\n): Promise => {\n\tconst pendingRecords = records.filter(({ evaluation }) => !evaluation || isPending(evaluation, pendingCondition));\n\tstdout?.write('.'.repeat(pendingRecords.length));\n\tstdout?.write('\\b'.repeat(pendingRecords.length));\n\n\tconst total = pendingRecords.length;\n\tlet done = 0;\n\n\tfor (const record of pendingRecords) {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tconst solution = await starry.beadSolver.solveMeasure(measure, { picker: record.picker, ...options });\n\t\tmeasure.applySolution(solution);\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better =\n\t\t\t!record.evaluation ||\n\t\t\tevaluation.fine > record.evaluation.fine ||\n\t\t\t(evaluation.qualityScore > record.evaluation.qualityScore && evaluation.fine === record.evaluation.fine);\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\t\t}\n\n\t\tonUpdate(record.current, evaluation, better);\n\n\t\tdone++;\n\t\tonProgress?.(record.current, evaluation, better, { pass, remaining: total - done, total });\n\t}\n\n\tif (pendingRecords.length) stdout?.write('\\n');\n\n\treturn pendingRecords.length;\n};\n\nconst regulateWithBeadSolver = async (\n\tscore: starry.Score,\n\t{ logger, pickers, solutionStore = DefaultSolutionStore, ignoreCache, freshOnly, onSaveIssueMeasure, onProgress, onPassStart }: RegulateBeadOption\n): Promise => {\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\tlogger?.info(`[regulateWithBeadSolver] begin, measure total: ${spartito.measures.length}.`, ignoreCache ? 'ignoreCache' : '', freshOnly ? 'freshOnly' : '');\n\n\tconst records = spartito.measures\n\t\t.filter((measure) => measure.events?.length && !measure.patched)\n\t\t.map(\n\t\t\t(measure) =>\n\t\t\t\t({\n\t\t\t\t\torigin: measure.deepCopy(),\n\t\t\t\t\tcurrent: measure,\n\t\t\t\t\tevaluation: undefined,\n\t\t\t\t\tbaseQuality: 0,\n\t\t\t\t} as MeasureReord)\n\t\t);\n\n\t// rectify time signature\n\tfor (const measure of spartito.measures.filter((measure) => measure.events?.length)) {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > measure.events.length + 1);\n\t\tif (picker) await starry.beadSolver.estimateMeasure(measure, picker);\n\t}\n\tspartito.rectifyTimeSignatures(logger as any);\n\n\t// zero pickers' cost\n\tpickers.forEach((picker) => (picker.cost = 0));\n\n\tconst counting = {\n\t\tcached: 0,\n\t\tsimple: 0,\n\t\tcomputed: 0,\n\t\ttryTimes: 0,\n\t\tsolved: 0,\n\t\tissue: 0,\n\t\tfatal: 0,\n\t};\n\n\tlogger?.info(`[regulateWithBeadSolver] measures estimation finished.`);\n\n\t// apply solutions\n\tif (solutionStore && !ignoreCache)\n\t\tfor (const record of records) {\n\t\t\tconst solution = await solutionStore.get(record.origin.regulationHash0);\n\t\t\tif (solution) {\n\t\t\t\trecord.current.applySolution(solution);\n\t\t\t\t++counting.cached;\n\n\t\t\t\trecord.evaluation = starry.evaluateMeasure(record.current);\n\t\t\t\trecord.baseQuality = record.evaluation.qualityScore;\n\t\t\t}\n\t\t}\n\n\tlogger?.info('[regulateWithBeadSolver]', `${counting.cached}/${records.length}`, 'solutions loaded.');\n\n\tconst stdout = logger ? null : process.stdout;\n\tif (counting.cached) stdout?.write(`${counting.cached}c`);\n\n\trecords.forEach((record) => {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > record.current.events.length + 1);\n\t\tif (!picker) {\n\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] size out of range:`, record.current.events.length);\n\t\t} else record.picker = picker;\n\t});\n\n\tconst pendingRecords = records.filter((record) => record.picker && (!record.evaluation || (!record.evaluation.fine && !freshOnly))) as (MeasureReord & {\n\t\tevaluation: starry.MeasureEvaluation;\n\t})[];\n\n\t// solve by simple policy\n\tpendingRecords.forEach((record) => {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tmeasure.regulate({ policy: 'simple' });\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better = !record.evaluation || evaluation.qualityScore > record.evaluation.qualityScore;\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\n\t\t\tif (evaluation.perfect) {\n\t\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] regulated by simple policy.`);\n\t\t\t\t++counting.simple;\n\t\t\t}\n\t\t}\n\t});\n\tcounting.computed = pendingRecords.length - counting.simple;\n\n\tif (counting.simple) stdout?.write(`${counting.simple}s`);\n\n\tconst onUpdate = (measure, evaluation, better) => {\n\t\tlogger?.info(\n\t\t\t`[regulateWithBeadSolver] measure[${measure.measureIndex}/${spartito.measures.length}] regulated${\n\t\t\t\tbetter ? '+' : '-'\n\t\t\t}: ${evaluation.qualityScore.toFixed(3)}, ${evaluation.fine ? 'solved' : evaluation.error ? 'error' : 'issue'}, ${measure.regulationHash}`\n\t\t);\n\n\t\tstdout?.write(`\\x1b[${evaluation.fine ? '32' : evaluation.error ? '31' : '33'}m${better ? '+' : '-'}\\x1b[0m`);\n\t};\n\n\t// Global progress: total = all measures, remaining = non-fine measures across all passes\n\tconst totalMeasures = spartito.measures.length;\n\tconst computeRemaining = () => pendingRecords.filter((r) => !r.evaluation?.fine).length;\n\tconst wrappedOnProgress = onProgress\n\t\t? (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => {\n\t\t\t\tonProgress(measure, evaluation, better, { pass: progress.pass, remaining: computeRemaining(), total: totalMeasures });\n\t\t }\n\t\t: undefined;\n\n\tonPassStart?.(1, 'Imperfect', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.05, quotaMax: 200, quotaFactor: 3, ptFactor: 1 },\n\t\tPendingCondition.Imperfect,\n\t\t1,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(2, 'NotFine', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 20, ptFactor: 1.6 },\n\t\tPendingCondition.NotFine,\n\t\t2,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(3, 'ErrorOnly', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 40, ptFactor: 3 },\n\t\tPendingCondition.ErrorOnly,\n\t\t3,\n\t\twrappedOnProgress\n\t);\n\n\tpendingRecords.forEach(({ evaluation, baseQuality, current, origin }) => {\n\t\tif (evaluation.fine) ++counting.solved;\n\t\telse if (evaluation.error) ++counting.fatal;\n\t\telse ++counting.issue;\n\n\t\tif (evaluation.qualityScore > baseQuality || !baseQuality) {\n\t\t\tsolutionStore.set(origin.regulationHash0, { ...current.asSolution(origin), priority: -current?.solutionStat?.loss! });\n\t\t\tif (current.regulationHash !== origin.regulationHash0)\n\t\t\t\tsolutionStore.set(current.regulationHash, { ...current.asSolution(), priority: -current?.solutionStat?.loss! });\n\t\t\t//console.log('better:', current.measureIndex, evaluation.qualityScore, baseQuality);\n\t\t}\n\n\t\tif (!evaluation.fine) {\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: current.measureIndex,\n\t\t\t\tmeasure: new starry.EditableMeasure(current),\n\t\t\t\tstatus: evaluation.error ? MeasureStatus.Fatal : MeasureStatus.Issue,\n\t\t\t});\n\t\t}\n\t});\n\n\tconst t1 = Date.now();\n\tconst pickerCost = pickers.reduce((cost, picker) => cost + picker.cost, 0);\n\n\tconst qualityScore = spartito.qualityScore;\n\tconst totalCost = t1 - t0;\n\n\tlogger?.info('[regulateWithBeadSolver] done in ', totalCost, 'ms, qualityScore:', qualityScore);\n\n\t// zero 'cached' statistics for freshOnly mode\n\tif (freshOnly) counting.cached = 0;\n\n\treturn {\n\t\ttotalCost: t1 - t0,\n\t\tpickerCost,\n\t\tmeasures: counting,\n\t\tqualityScore,\n\t};\n};\n\nconst abstractRegulationBeadStats = (stats: RegulationBeadStat[]): RegulationBeadSummary => {\n\tconst { totalCost, pickerCost, measureN, timeN } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\ttotalCost: sum.totalCost + stat.totalCost,\n\t\t\tpickerCost: sum.pickerCost + stat.pickerCost,\n\t\t\tmeasureN: sum.measureN + stat.measures.computed,\n\t\t\ttimeN: sum.timeN + stat.measures.tryTimes,\n\t\t}),\n\t\t{\n\t\t\ttotalCost: 0,\n\t\t\tpickerCost: 0,\n\t\t\tmeasureN: 0,\n\t\t\ttimeN: 0,\n\t\t}\n\t);\n\n\tconst costPerMeasure = measureN > 0 ? totalCost / measureN : null;\n\tconst costPerTime = timeN > 0 ? totalCost / timeN : null;\n\n\tconst { cached, simple, computed, tryTimes, solved, issue, fatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.measures.cached,\n\t\t\tsimple: sum.simple + stat.measures.simple,\n\t\t\tcomputed: sum.computed + stat.measures.computed,\n\t\t\ttryTimes: sum.tryTimes + stat.measures.tryTimes,\n\t\t\tsolved: sum.solved + stat.measures.solved,\n\t\t\tissue: sum.issue + stat.measures.issue,\n\t\t\tfatal: sum.fatal + stat.measures.fatal,\n\t\t}),\n\t\t{ cached: 0, simple: 0, computed: 0, tryTimes: 0, solved: 0, issue: 0, fatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\ttotalCost,\n\t\tpickerCost,\n\t\tcostPerMeasure,\n\t\tcostPerTime,\n\t\tcached,\n\t\tsimple,\n\t\tcomputed,\n\t\ttryTimes,\n\t\tsolved,\n\t\tissue,\n\t\tfatal,\n\t};\n};\n\nexport { regulateWithBeadSolver, abstractRegulationBeadStats, RegulationBeadStat, ProgressInfo };\n","import * as starry from '../../src/starry';\nimport { PyClients } from './predictors';\nimport { Logger } from './ZeroClient';\nimport { SpartitoMeasure, EditableMeasure, evaluateMeasure } from '../../src/starry';\nimport { EquationPolicy } from '../../src/starry/spartitoMeasure';\nimport { genMeasureRectifications } from '../../src/starry/measureRectification';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure } from './store';\nexport * from './regulationBead';\n\nglobalThis.btoa = globalThis.btoa || ((str) => Buffer.from(str, 'binary').toString('base64'));\n\nconst RECTIFICATION_SEARCH_ITERATIONS = parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS || '30');\nconst BASE_QUOTA_FACTOR = parseInt(process.env.BASE_QUOTA_FACTOR || '40');\nconst RECTIFICATION_QUOTA_FACTOR = parseInt(process.env.RECTIFICATION_QUOTA_FACTOR || '80');\n\nconst MATRIXH_INTERPOLATION_K = 0.9;\n\ninterface SolveMeasureOptions {\n\tsolver?: (...args: any[]) => any;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tlogger?: Logger;\n}\n\nconst computeQuota = (n: number, factor: number, limit: number) =>\n\tMath.min(Math.ceil((n + 1) * factor * Math.log(n + 2)), Math.ceil(limit * Math.min(1, (24 / (n + 1)) ** 2)));\n\ninterface BaseRegulationStat {\n\tcached: number;\n\tcomputed: number;\n\tsolved: number;\n}\n\nasync function solveMeasures(\n\tmeasures: SpartitoMeasure[],\n\t{ solver, quotaMax = 1000, quotaFactor = BASE_QUOTA_FACTOR, solutionStore = DefaultSolutionStore, ignoreCache = false, logger }: SolveMeasureOptions = {}\n): Promise {\n\tlet cached = 0;\n\tlet solved = 0;\n\n\tlogger?.info(`[solveMeasures] begin, measure total: ${measures.length}.`);\n\n\tawait Promise.all(\n\t\tmeasures.map(async (measure) => {\n\t\t\tif (!ignoreCache) {\n\t\t\t\tconst solution = await solutionStore.get(measure.regulationHash);\n\t\t\t\tif (solution) {\n\t\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\t\t++cached;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst quota = computeQuota(measure.events.length, quotaFactor, quotaMax);\n\n\t\t\tawait measure.regulate({\n\t\t\t\tpolicy: 'equations',\n\t\t\t\tquota,\n\t\t\t\tsolver,\n\t\t\t});\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tif (!stat.error) solutionStore.set(measure.regulationHash0, { ...measure.asSolution(), priority: -measure?.solutionStat?.loss! });\n\t\t\tif (stat.perfect) ++solved;\n\n\t\t\tlogger?.info(\n\t\t\t\t`[solveMeasures] measure[${measure.measureIndex}/${measures.length}] regulated: ${stat.perfect ? 'solved' : stat.error ? 'error' : 'issue'}, ${\n\t\t\t\t\tmeasure.regulationHash\n\t\t\t\t}`\n\t\t\t);\n\t\t})\n\t);\n\n\tlogger?.info(`[solveMeasures] ${cached}/${measures.length} cache hit, ${solved} solved.`);\n\n\treturn {\n\t\tcached,\n\t\tcomputed: measures.length - cached,\n\t\tsolved,\n\t};\n}\n\nconst solveMeasuresWithRectifications = async (\n\tmeasure: SpartitoMeasure,\n\t{ solver, quotaMax = 4000 }: SolveMeasureOptions\n): Promise => {\n\tlet best = evaluateMeasure(measure);\n\tlet bestSolution: starry.RegulationSolution = measure.asSolution();\n\tconst quota = computeQuota(measure.events.length, RECTIFICATION_QUOTA_FACTOR, quotaMax);\n\tlet n_rec = 0;\n\n\t// @ts-ignore\n\tfor (const rec of genMeasureRectifications(measure)) {\n\t\tconst solution = await EquationPolicy.regulateMeasureWithRectification(measure, rec, { solver, quota });\n\n\t\tconst testMeasure = measure.deepCopy() as SpartitoMeasure;\n\t\ttestMeasure.applySolution(solution);\n\t\tconst result = evaluateMeasure(testMeasure);\n\n\t\tif (\n\t\t\tresult.perfect > best.perfect ||\n\t\t\tresult.error < best.error ||\n\t\t\t(!result.error && result.perfect >= best.perfect && solution.priority! > bestSolution.priority!)\n\t\t) {\n\t\t\tbest = result;\n\t\t\tbestSolution = solution;\n\t\t}\n\n\t\tif (result.perfect) break;\n\n\t\t++n_rec;\n\t\tif (n_rec > RECTIFICATION_SEARCH_ITERATIONS) break;\n\t}\n\n\treturn bestSolution;\n};\n\ninterface RegulateWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateMaybeWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients?: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateSimpleOption {\n\tsolutionStore: SolutionStore;\n\tsolver: (...args: any[]) => any;\n\tlogger?: Logger;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n}\n\ninterface TopoRegulationStat {\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\nasync function doRegulateWithTopo(\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateWithTopoOption\n): Promise {\n\tpyClients.logger.info(`[RegulateWithTopo] regulate score: ${score.title}, measures: ${score.spartito!.measures.length}`);\n\n\tconst issueMeasures = score.spartito!.measures.filter((measure) => {\n\t\tconst stat = evaluateMeasure(measure);\n\t\treturn !stat.perfect;\n\t});\n\tpyClients.logger.info(`[RegulateWithTopo] basic issues: ${issueMeasures.length}`);\n\n\tif (issueMeasures.length === 0) {\n\t\treturn {\n\t\t\tsolved: 0,\n\t\t\tissue: 0,\n\t\t\tfatal: 0,\n\t\t};\n\t}\n\n\tconst clusters = ([] as starry.EventCluster[]).concat(...issueMeasures.map((measure) => measure.createClusters()));\n\tconst results = await pyClients.predictScoreImages('topo', { clusters });\n\tconsole.assert(results.length === clusters.length, 'prediction number mismatch:', clusters.length, results.length);\n\n\tclusters.forEach((cluster, index) => {\n\t\tconst result = results[index];\n\t\tconsole.assert(result, 'no result for cluster:', cluster.index);\n\n\t\tcluster.assignPrediction(result);\n\t});\n\n\tissueMeasures.forEach((measure) => {\n\t\tconst cs = clusters.filter((c) => c.index === measure.measureIndex);\n\t\tmeasure.applyClusters(cs);\n\n\t\t// intepolate matrixH\n\t\tconst { matrixH } = EquationPolicy.estiamteMeasure(measure);\n\t\tmatrixH.forEach((row, i) =>\n\t\t\trow.forEach((v, j) => {\n\t\t\t\tmeasure.matrixH[i][j] = measure.matrixH[i][j] * MATRIXH_INTERPOLATION_K + v * (1 - MATRIXH_INTERPOLATION_K);\n\t\t\t})\n\t\t);\n\t});\n\n\tconst solvedIndices: number[] = [];\n\tconst errorIndices: number[] = [];\n\n\t// rectification search\n\tawait Promise.all(\n\t\tissueMeasures.map(async (measure) => {\n\t\t\tconst hash = measure.regulationHash0;\n\t\t\tconst solution = await solveMeasuresWithRectifications(measure, { solver });\n\t\t\tif (solution) {\n\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\tsolutionStore.set(hash, solution);\n\t\t\t\tsolutionStore.set(measure.regulationHash, measure.asSolution());\n\t\t\t\tpyClients.logger.info(`[RegulateWithTopo] solutionStore set: ${measure.measureIndex}, ${hash}, ${measure.regulationHash}`);\n\t\t\t}\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\tmeasure: new EditableMeasure(measure),\n\t\t\t\tstatus: stat.error ? 2 : 1,\n\t\t\t});\n\t\t\tif (stat.perfect) solvedIndices.push(measure.measureIndex);\n\t\t\telse if (stat.error) errorIndices.push(measure.measureIndex);\n\t\t})\n\t);\n\n\tconst n_issues = issueMeasures.length - solvedIndices.length - errorIndices.length;\n\tpyClients.logger.info(`[RegulateWithTopo] score: ${score.title}, solved/issue/fatal: ${solvedIndices.length}/${n_issues}/${errorIndices.length}`);\n\tif (solvedIndices.length) pyClients.logger.info(`[RegulateWithTopo] solved measures: ${solvedIndices.join(', ')}`);\n\tif (errorIndices.length) pyClients.logger.info(`[RegulateWithTopo] error measures: ${errorIndices.join(', ')}`);\n\n\treturn {\n\t\tsolved: solvedIndices.length,\n\t\tissue: n_issues,\n\t\tfatal: errorIndices.length,\n\t};\n}\n\ninterface RegulationStat {\n\tbaseCost: number; // in milliseconds\n\ttopoCost: number; // in milliseconds\n\tbaseMeasures: BaseRegulationStat;\n\ttopoMeasures?: TopoRegulationStat;\n\tqualityScore: number;\n}\n\nconst doRegulate = async (\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateMaybeWithTopoOption\n): Promise => {\n\tpyClients?.logger?.info(`[doRegulate] score: ${score.title}`);\n\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\n\tconst baseMeasures = await solveMeasures(spartito.measures, { solver, quotaMax: 1000, solutionStore, logger: pyClients?.logger });\n\n\tconst t1 = Date.now();\n\n\tconst topoMeasures = pyClients ? await doRegulateWithTopo(score, { pyClients, solver, solutionStore, onSaveIssueMeasure }) : undefined;\n\n\tconst t2 = Date.now();\n\n\treturn {\n\t\tbaseCost: t1 - t0,\n\t\ttopoCost: t2 - t1,\n\t\tbaseMeasures,\n\t\ttopoMeasures,\n\t\tqualityScore: spartito.qualityScore,\n\t};\n};\n\nconst doSimpleRegulate = async (\n\tscore: starry.Score,\n\t{ solver, solutionStore = DefaultSolutionStore, logger, quotaMax = 240, quotaFactor = 16 }: RegulateSimpleOption\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\tconst measures = spartito.measures.filter((measure) => !measure.regulated);\n\n\tawait solveMeasures(measures, { solver, quotaMax, quotaFactor, solutionStore, logger });\n\n\tconsole.assert(score.spartito?.regulated, 'doSimpleRegulate: regulation incomplete:', spartito.measures.filter((measure) => !measure.regulated).length);\n};\n\nconst evaluateScoreQuality = async (score: starry.Score, options: RegulateSimpleOption): Promise => {\n\tif (!score.spartito?.regulated) await doSimpleRegulate(score, options);\n\n\treturn score.spartito!.regulated ? score.spartito!.qualityScore : null;\n};\n\ninterface RegulationSummary {\n\tscoreN: number;\n\n\tbaseCostTotal: number; // in milliseconds\n\ttopoCostTotal: number; // in milliseconds\n\tbaseCostPerMeasure: number | null; // in milliseconds\n\ttopoCostPerMeasure: number | null; // in milliseconds\n\n\tcached: number;\n\tbaseComputed: number;\n\tbaseSolved: number;\n\ttopoSolved: number;\n\ttopoIssue: number;\n\ttopoFatal: number;\n}\n\nconst abstractRegulationStats = (stats: RegulationStat[]): RegulationSummary => {\n\tconst { baseCostTotal, topoCostTotal, baseMeasures, topoMeasures } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tbaseCostTotal: sum.baseCostTotal + stat.baseCost,\n\t\t\ttopoCostTotal: sum.topoCostTotal + stat.topoCost,\n\t\t\tbaseMeasures: sum.baseMeasures + stat.baseMeasures.computed,\n\t\t\ttopoMeasures: sum.topoMeasures + (stat.topoMeasures!.solved + stat.topoMeasures!.issue + stat.topoMeasures!.fatal),\n\t\t}),\n\t\t{\n\t\t\tbaseCostTotal: 0,\n\t\t\ttopoCostTotal: 0,\n\t\t\tbaseMeasures: 0,\n\t\t\ttopoMeasures: 0,\n\t\t}\n\t);\n\n\tconst baseCostPerMeasure = baseMeasures > 0 ? baseCostTotal / baseMeasures : null;\n\tconst topoCostPerMeasure = topoMeasures > 0 ? topoCostTotal / topoMeasures : null;\n\n\tconst { cached, baseComputed, baseSolved, topoSolved, topoIssue, topoFatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.baseMeasures.cached,\n\t\t\tbaseComputed: sum.baseComputed + stat.baseMeasures.computed,\n\t\t\tbaseSolved: sum.baseSolved + stat.baseMeasures.solved,\n\t\t\ttopoSolved: sum.topoSolved + stat.topoMeasures!.solved,\n\t\t\ttopoIssue: sum.topoIssue + stat.topoMeasures!.issue,\n\t\t\ttopoFatal: sum.topoFatal + stat.topoMeasures!.fatal,\n\t\t}),\n\t\t{ cached: 0, baseComputed: 0, baseSolved: 0, topoSolved: 0, topoIssue: 0, topoFatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\tbaseCostTotal,\n\t\ttopoCostTotal,\n\t\tbaseCostPerMeasure,\n\t\ttopoCostPerMeasure,\n\t\tcached,\n\t\tbaseComputed,\n\t\tbaseSolved,\n\t\ttopoSolved,\n\t\ttopoIssue,\n\t\ttopoFatal,\n\t};\n};\n\nexport { doRegulate, doSimpleRegulate, evaluateScoreQuality, abstractRegulationStats };\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T12:40:18.113Z`, '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;');\nimport '../../libs/browserComponents';\n\nexport * from '../../../src/isomorphic/converter';\nexport * as starry from '../../../src/starry';\nexport * from '../../libs/predictors';\nexport * from '../../libs/predictPages';\nexport * from '../../libs/regulation';\nexport * from '../../libs/store';\nexport * from '../../libs/util';\n"],"names":["PageLayoutMethod","TextType","SemanticType","globalThis","btoa","str","Buffer","from","toString","atob","NOTEHEAD_WIDTHS","NoteheadS0","NoteheadS1","NoteheadS2","glyphCenters","x","zero","y","one","two","three","four","five","six","seven","eight","nine","f","m","p","r","s","z","SYSTEM_SEMANTIC_TYPES","BarMeasure","vline_BarMeasure","vline_BarTerminal","vline_BarSegment","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","st","CONFLICTION_GROUPS","Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","ScriptStaccatissimo","TimesigZero","TimesigOne","TimesigTwo","TimesigThree","TimesigFour","TimesigFive","TimesigSix","TimesigSeven","TimesigEight","TimesigNine","Rest0","Rest1","Rest2","Rest3","Rest4","Rest5","Rest6","Rest0W","RestM1","SignInterval","SignLined","BeamLeft","BeamContinue","BeamRight","STAMP_SEMANTICS","ClefG","ClefF","ClefC","Dot","AccNatural","AccSharp","AccDoublesharp","AccFlat","AccFlatflat","TimesigC44","TimesigC22","OctaveShift8","OctaveShift0","n","ScriptFermata","ScriptShortFermata","ScriptSforzato","ScriptStaccato","ScriptTurn","ScriptTrill","ScriptSegno","ScriptCoda","ScriptArpeggio","ScriptPrall","ScriptMordent","ScriptMarcato","ScriptTenuto","ScriptPortato","PedalStar","PedalPed","hashSemanticPoint","systemIndex","staffIndex","point","Math","round","source","semantic","hash","sha1","array","slice","id","String","fromCharCode","substring","hashPageSemanticPoint","pageName","TokenType","tt","TokenTypes","Object","values","TokenClefs","filter","t","test","TokenTimesigs","TokenTimesigsC","TokenTimesigsN","TokenOctshifts","TokenNumbers","TokenAccidentals","TokenNoteheads","TokenBareNoteheads","TokenDirectionalNoteheads","TokenRests","TokenFlags","TokenVolta","TokenDynamics","TokenScripts","TokenPedals","TokenDots","DotDot","TokenArcs","SlurBegin","SlurEnd","TieBegin","TieEnd","TokenBeams","TokenWedges","TokenAccessories","TokenDirectionless","TokenGlyphs","TOKEN_Y_ROUND","forEach","TOKEN_Y_FIXED","Token","constructor","data","assign","this","typeId","type","split","reverse","isPredicted","Number","isFinite","confidence","isNotehead","includes","isContexted","isAccessory","division","NoteheadS1stemU","NoteheadS1stemD","NoteheadS2stemU","NoteheadS2stemD","Flag3","Flag4","Flag5","Flag6","Flag7","Flag8","dots","direction","width","left","right","voiceIndices","voice","Array","floor","log2","fill","reduce","indices","_","i","className","TextToken","super","width_","value","recoverJSON","json","classDict","JSON","stringify","parse","__prototype","Class","fields","deepCopy","o","dict","Map","get","isArray","result","set","e","push","entries","key","setPrototypeOf","__proto__","SimpleClass","toJSON","cls","serializedKeys","blackKeys","keys","pick","LayoutType","spreadMeasureSeq","seq","Ordinary","concat","map","layout","serialize","seqToCode","withBrackets","code","inRange","length","SingleMLayout","measure","undefined","BlockMLayout","trimSeq","seq2","sub","seq3","fromSeq","VoltaMLayout","bodySeq","body","alternates","alternateSeqs","lastAlternateSeq","Conservative","Full","times","Once","console","warn","join","ABAMLayout","seqA","main","seqA_","seqB","rest","parser","k","v","l","$V0","$V1","$V2","$V3","$V4","$V5","$V6","$V7","$V8","$V9","$Va","trace","yy","symbols_","error","start_symbol","measure_layout","EOF","index_wise_measure_layout","segment_wise_measure_layout","iw_sequence","iw_item","range","UNSIGNED","single","iw_block_item","iw_volta","iw_aba","iw_block","iw_optional_alternates","iw_alternates","sw_sequence","sw_item","segment","sw_block_item","sw_volta","sw_aba","sw_block","sw_optional_alternates","sw_alternates","$accept","$end","terminals_","productions_","performAction","yytext","yyleng","yylineno","yystate","$$","_$","$0","$","root","blockLayout","singleLayout","voltaBlock","abaBlock","table","defaultActions","parseError","recoverable","Error","input","self","stack","vstack","lstack","args","call","arguments","lexer","create","sharedState","prototype","hasOwnProperty","setInput","yylloc","yyloc","ranges","options","getPrototypeOf","symbol","state","action","len","newState","expected","lex","token","yyval","errStr","showPosition","text","match","line","loc","first_line","last_line","first_column","last_column","apply","items","item","start","end","index","speard","it","serializeSeq","_input","_more","_backtrack","done","matched","conditionStack","offset","ch","unput","lines","substr","oldLines","more","reject","backtrack_lexer","less","pastInput","past","replace","upcomingInput","next","pre","c","test_match","indexed_rule","backup","matches","tempMatch","rules","_currentRules","flex","begin","condition","popState","pop","conditions","topState","abs","pushState","stateStackSize","yy_","$avoiding_name_collisions","YY_START","INITIAL","inclusive","Parser","grammar$1","StaffGroupType","StaffConjunctionType","singleGroup","Default","staff","BOUNDS_TO_GROUPTYPE","Brace","Bracket","Square","CONJUNCTIONS_MAP","Blank","Solid","Dashed","randomB64","random","makeGroupsFromRaw","parent","remains","word","shift","bound","group","level","subs","grand","every","groupHead","groupTail","groupDict","groupKey","StaffLayout","raw","ids","Set","prefix","name","has","makeUniqueName","add","staffIds","conjunctions","conjunction","leftBounds","rightBounds","groups","indexOf","maskCache","stavesCount","partGroups","grands","g","some","standaloneGroups","collect","conjunctionBetween","upStaff","downStaff","con","min","makeMaskLayout","mask","nextId","partialMaskCode","bits","withIds","staffStatus","status","joinGroup","subStr","pair","Boolean","partial","inner","bracketCode","$Vb","$Vc","staff_layout","seq_id","seq_br","seq_con","bound_left","bound_right","bound_lefts","bound_rights","ID","seq_bl","Seq","tip","bl","br","Item","grammar","parseCode","DummyLogger","debug","groupCollapsed","groupEnd","info","assert","roundNumber","precision","Infinity","max","distance2D","p1","p2","dx","dy","sqrt","gcd","a","b","isInteger","frac","numerator","denominator","reducedFraction","d","printFraction","fractionMul","fraction","segmentPoints","points","axis","sorted","sort","seg","lastP","segments","filterWeekPoints","rests","find","weeks","solveOverlapping","pset","xClusters","clusters","ps","delete","GROUP_N_TO_PITCH","noteToPitch","note","alter","gn","mod7","argmax","WHOLE_DURATION","AccessoryDirection","GraceType","StemBeam","TremoloLink","GlissandoStyle","ArpeggioStyle","Term","EventTerm","space","tick","duration","term","accessories","pivotX","alignedTick","grace","mainDuration","multiplier","timeWarp","divider","prior","fullMeasureRest","tipX","tipY","ys","tremoloCatcher","tremoloLink","Catcher","scaleChord","pitches","pitch","zeroHolder","ContextType","ContextedTerm","Token.TokenClefs","tokenType","Clef","KeyAcc","Acc","Token.TokenOctshifts","OctaveShift","Token.TokenTimesigsC","TimeSignatureC","Token.TokenTimesigsN","TimeSignatureN","staffLevel","clef","KeyNatural","KeySharp","KeyFlat","octaveShift","OctaveShift8va","OctaveShift8vb","number","MarkTerm","MUSIC_NOTES","fromCodePoint","TempoTerm","fromNumeralText","findIndex","beats","durationMagnitude","den","dot","bpm","isValid","GlyphTerm","TextTerm","LyricTerm","CommandTerm","ChordmodeTerm","BEAM_STATUS","Open","Continue","Close","evaluateMeasure","regulated","eventMap","events","validEvents","voices","flat","warpedEvents","warps","irregularWarps","fractionalWarp","tickSum","eventN","event","tickOverlapped","complicatedTimewarp","size","literalDuration","timeSignature","sigDuration","doubtfulTimesig","inVoiceEvents","corruptedVoiceEvent","overranged","over","overDuration","graceInVoice","graceN","graceDominant","irregularTick","beamBroken","broken","ei","beam","spaceTime","surplusTime","eventDuration","sum","nullEvents","predisposition","fakeP","fakeEvents","voiceRugged","es","tickTwist","tickRatesInStaves","rate","perfect","estimatedDuration","fine","expectDuration","durationRate","qualityScore","patched","spaceLoss","tanh","irregularWarpsN","SemanticGraph","fromPoints","graph","getLayer","getConfidentLayer","threshold","getSystemPoints","getStaffPoints","scale","factor","transform","matrix","extension","y1","y2","scaling","height","MEASURE_SEMANTICS","GraceNotehead","CrescendoBegin","CrescendoEnd","DecrescendoBegin","DecrescendoEnd","TremoloLeft","TremoloRight","TremoloMiddle","STAFF_LINED_SEMANTICS","LINED_INTERVAL_SEMANTICS","NOTEHEAD_FOR_STEM_SEMANTICS","KEYACC_CANDIDATE_SEMANTICS","NOTEHEAD_TABLE","up","down","REST_SEMANTICS","TOKEN_TO_STEMBEAM","TEXT_TYPE_ALIAS","Alter1","Alternation1","Alter2","Alternation2","noteheadsXPivot","xs","mean","x1","x2","Measure","tokens","antiTokens","barTypes","noteheads","n1","n2","chordRects","nh","nulN","nhmap","hh","nhs","top","bottom","nh0","stemX","stemDirection","timeWarped","additionalLines","chords","getChords","chord","ceil","flags","beams","chordRcs","rect","noteIds","c1","c2","accs","flagRange","nearbyFlags","flag","beamToken","nearbyDots","getRests","dotValue","getEvents","e1","e2","getContexts","assignAccessoriesOnEvents","accessory","relatedEvents","owner","d1","d2","Down","Up","sortEvents","arpeggio","Grace","tremolsLs","tremolsRs","tremolsMs","tevents","stemL","stemR","tm","te","tremolo","tl","Pitcher","tr","assignFeaturesOnEvents","semantics","dotPs","beamLs","beamMs","beamRs","gracePs","tremoloRs","stems","vline_Stem","s0","s1","s2","cx","divisions","ss","i_flags","f1","f2","i_dots","dots2","bs","u_stems","stem","d_stems","stemDirections","graces","tremolos","feature","Staff","measureCount","measureBars","staffY","measures","endX","noteRange","rearrangeMeasures","reassignTokens","assignSemantics","assemble","system","logger","qualifiedSemantics","TempoNotehead","tempoNh","splice","antiP","displacementSemantics","appendPoint","semanticTop","semanticBottom","rootNhs","nhOffsetX","attachedHeads","topDist","bottomDist","antiPoint","nearStems","appendFlags","dotLines","sy","keyaccs","acc","oct","voltaDots","VoltaLeft","VoltaRight","voltaGroups","lined","interval","signs","fixedY","roundY","holder","mainFlag","downward","tailY","count","clearTokens","clearPredictedTokens","System","HEAD_WIDTH","segmentLength","staves","arrangePosition","sidBlackList","sidWhiteList","staffTop","staffBottom","staffPositions","radius","staffMask","staffMaskChanged","prev","positions","tidyMeasureBars","b1","b2","restWidth","connectionLine","staffHead","staffTail","middleY","timeSignatureOnHead","getStaffArray","si","on","getMarksInMeasure","measureIndex","textType","TempoNumeral","headMeasureIndex","columns","rows","contexts","voltaBegin","voltaEnd","alternative","mi","timeSigs","row","marks","ts","column","lastColumn","break","getEventsFunctional","ev","processors","useXMap","localRows","xMap","groupMap","tickGroup","proc","oy","bars","lastX","barColumns","bar","intensity","barXs","prevStaff","nextStaff","newPoint","appendToken","fontSize","overlap","Page","systems","assignTexts","areas","imageHeight","imageWidth","dimensions","area","cy","rp","score","rect_Text","theta","textFeature","feature_dict","textAnnotations","sysXs","middleX","indent","Text","textFeasure","Title","Author","PageMargin","Other","Chord","MeasureNumber","Instrument","TextualMark","Times","sx","SemanticElementType","TIME_SIG_DENOMINATORS","fromEntries","TIME_SIG_NUMERATORS","et","ELEMENT_TOKEN_NAMES","BOS","NoteheadGrace","NOTEHEAD_BASE_DIVISION","NOTEHEAD_ELEMENT_TYPES","REST_ELEMENT_TYPES","BEAM_ELEMENT_TYPES","NOTE_ELEMENT_TYPES","SOURCE_ELEMENT_TYPES","TARGET_ELEMENT_TYPES","ROOT_NOTE_ELEMENT_TYPES","ELEMENT_TO_STEMBEAM","metaElem","BOS_ELEMENT","fractionToElems","SemanticCluster","elementToJSON","elem","sourceMask","elements","targetMask","vMask","compactMatrixH","matrixH","j","expandMatrixByMasks","compactMatrixV","_matrixV","matrixV","expandMatrixByMaskTriu","groupsV","matrixFromGroups","found","mapMatrix","x2i","i2x","xi","mergeOverlapping","overlaps","overlappedNoteheads","ij","ii","nh1","nh2","masks","stemMasks","stemNotes","s0s","subS0Masks","stemMap","stemId","i1","i2","prevId","linkings","roots","parentMasks","parentId","rootId","subNotes","dotGroups","tipRange","beamElem","iter","gen","maskSrc","maskTar","src","tar","groupIds","id1","id2","ImplicitType","Stream","buffer","Uint8Array","position","eof","read","readString","readInt32","readInt16","readInt8","signed","readVarInt","OStream","write","writeInt32","writeInt16","writeInt8","writeVarInt","getBuffer","getArrayBuffer","charCodeAt","MIDI","parseMidiData","readChunk","stream","lastEventTypeByte","readEvent","deltaTime","eventTypeByte","param1","eventType","channel","subtype","noteNumber","velocity","amount","controllerType","programNumber","subtypeByte","microsecondsPerBeat","hourByte","frameRate","hour","sec","frame","subframe","pow","metronome","thirtyseconds","headerChunk","headerStream","formatType","trackCount","timeDivision","ticksPerBeat","header","tracks","trackChunk","trackStream","encodeMidiFile","writeChunk","writeEvent","frameByte","MidiSequence","midiToSequence","midiFile","trackStates","beatsPerMinute","nextEventIndex","ticksToNextEvent","getNextEvent","nextEventTrack","nextEvent","ticksToEvent","track","midiEvent","processNext","secondsToGenerate","time","processEvents","trimSequence","clear","fixOverlapNotes","noteMap","overlapMap","swaps","leapIndex","swap","front","back","offEvent","leapEvent","tempo","require$$0","PedalControllerTypes","Notation","parseMidi","fixOverlap","channelStatus","pedalStatus","pedals","channels","millisecondsPerBeat","barIndex","keyRange","correspondences","rawTicks","ticks","tempos","rawEvents","deltaTicks","deltaBeats","startTick","low","statusIndex","endTick","finger","high","pedalType","captures","fingers","isNaN","log","endTime","meta","notes","pitchMap","beatInfos","lastInfo","beatIndex","entry","findChordBySoftindex","softIndex","averageTempo","tickRange","to","endtick","span","ticksToTime","next_tempo_index","tempo_index","timeToTicks","tickRangeToTimeRange","scaleTempo","headTempo","MusicNotation","animationDelay","Promise","resolve","requestAnimationFrame","MidiPlayer_1","MidiPlayer","midiData","cacheSpan","onMidi","onPlayFinish","onTurnCursor","notation","isPlaying","progressTime","startTime","performance","now","cursorTurnDelta","dispose","progressTicks","play","nextFrame","currentEventIndex","backturn","eventTime","pause","turnCursor","config","CostStepAttenuation","SkipDeep","PriorDistanceSigmoidFactor","PriorValueSigmoidFactor","SkipCost","LagOffsetCost","LeadOffsetCost","ZeroOffsetCost","RelocationThreshold","Config","require$$1","Node","s_note","c_note","_prev","_totalCost","_value","cacheDirty","ci","rootSi","cost","skip","updateCache","totalCost","selfCost","deep","path","node","dump","evaluatePrev","evaluatePrevCost","bias","priorByOffset","distance","navigator","Navigator","criterion","sample","getCursorOffset","outOfPage","bestNode","fineCursor","breakingSI","zeroNode","relocationThreshold","step","prevNote","prevNode","cursors","nullLength","nullSteps","cursor","resetCursor","breaking","deltaSi","fromIndex","toIndex","backPrior","cursorOffset","relocationTendency","normalizeInterval","HEART_BEAT","makeNoteSoftIndex","softIndexFactor","lastNote","Matcher","makeMatchNodes","targetList","targetNote","genNotationContext","runNavigation","async","onStep","Symbol","for","EXCLUDE_MIDI_EVENT_SUBTYPES","encodeToMIDIData","unclosedNoteDuration","msToTicks","Date","process","env","VUE_APP_BUILD_TIME","toDateString","MidiUtils","sliceMidi","midi","trackDeltaToAbs","lastTick","trackAbsToDelta","sliceTrack","encodeToMIDI","musicWidgets","require$$2","require$$3","require$$4","COMMON_NOTE_FIELDS","MetaNotation","fromAbsoluteNotes","measureHeads","__","mnotes","mn","field","idTrackMap","performAbsoluteNotes","abNotes","withRestTied","tied","overlapped","staffTrack","contextIndex","implicitType","chordPosition","priorNote","ripe","trackTickBias","headMeasure","trackNames","idSet","toAbsoluteNotes","measureIndices","measureTick","measureNotes","mnote","toPerformingNotation","WHOLE_DURATION_MAGNITUDE","toPerformingMIDI","trackList","zeroTick","measureEvents","mevent","eventPriority","subnote","finalTick","toPerformingNotationWithEvents","assignNotationNoteDataFromEvents","setTempo","midiNotation","noteId","CryptoJS","exports","crypto","window","msCrypto","global","require","err","cryptoSecureRandomInt","getRandomValues","Uint32Array","randomBytes","readInt32LE","F","obj","C","C_lib","lib","Base","extend","overrides","mixIn","init","$super","instance","properties","propertyName","clone","WordArray","words","sigBytes","encoder","Hex","wordArray","thisWords","thatWords","thisSigBytes","thatSigBytes","clamp","thatByte","nBytes","C_enc","enc","hexChars","bite","hexStr","hexStrLength","parseInt","Latin1","latin1Chars","latin1Str","latin1StrLength","Utf8","decodeURIComponent","escape","utf8Str","unescape","encodeURIComponent","BufferedBlockAlgorithm","reset","_data","_nDataBytes","_append","_process","doFlush","processedWords","dataWords","dataSigBytes","blockSize","nBlocksReady","nWordsReady","_minBufferSize","nBytesReady","_doProcessBlock","Hasher","cfg","_doReset","update","messageUpdate","finalize","_doFinalize","_createHelper","hasher","message","_createHmacHelper","C_algo","HMAC","algo","H","K","isPrime","sqrtN","getFractionalBits","nPrime","W","SHA256","_hash","M","h","gamma0x","gamma0","gamma1x","gamma1","maj","sigma0","t1","nBitsTotal","nBitsLeft","HmacSHA256","factory","HashVector","fromHash","byte","fromString","_SHA256","uwords","word_len","fromWords","vectors","toHash","bit","vec","crop","ODDS","odds","odd","cosHashes","hash1","hash2","xor","xorHashes","i2hex","Sylvester","Matrix","setElements","I","els","dup","isSquare","cols","toRightTriangular","np","determinant","det","isSingular","augment","T","nj","inverse","divisor","new_element","inverse_elements","DURATION_MULTIPLIER","floatToTimeWarp","floatToFrac","ActionType","EventElementType","SimplePolicy","Action","P","PLACE","V","order","VERTICAL","HORIZONTAL","StageMatrix","fromNode","stages","actions","stage1","stage","stage2","stagedEvents","endHs","endHP","hActions","pendingHeads","eid","pathOf","target","findDoublePath","paths","reducePath","toEquations","eventCount","equations","path1","path2","equation","PathNode","last","like","constructStages","unshift","newStage","constructConstraints","factors","constraints","inbalancesConstraints","ones","fixed","inbalances","constraint","solveEquations","xis","equationMap","conflicted","squareLines","restLines","candidateLines","sl","invert","mat","matrixInverse","solution","optimallySolve","shrinkMap","shrinkness","released","releasedIds","lowWarp","isConflicted","eventTendencies","timeWarps","getSolution","actionKey","hacts","a1","a2","hmap","act","startEs","se","estages","solveStages","changed","measureDuration","outEI","deduce","quota","access","actionAccessing","closed","credits","children","expand","possibility","child","branches","appendBranch","branch","Solver","event0","measureShrinkness","expectedDuration","xSpan","solve","pathRoot","bestSolution","evaluateSolution","loss","sevents","partialFrac","weight","staffAlters","eventsXOrder","tickTwists","dt","atan2","PI","PatchMeasure","staffN","basics","basic","EventCluster","regular","CHORD","REST","fake","fullMeasure","grant","annotation","endElem","EOS","assignPrediction","prediction","pe","EventClusterSet","trimIrregular","ir","cluster","computeMeasureTicks","roundX","constructXMap","eventGroups","divisionVector","dotsVector","computeMeasureVoices","eventSet","pushEvent","e0","EquationPolicy","INVERT_SQRT2","FINE_BEAMS","bb","solveStaffGroup","staffGroup","EquationSolver.Solver","estiamteMeasure","allEvents","tickEstimated","pR","eventStartX","staffGroupMap","staffGroups","ievents","startX","hp","erf","staffDecay","exp","yDecay","dtx","nR","regulateMeasure","solver","mp","resultEvents","solutionStat","solverCredits","solverTimes","regulateMeasureWithRectification","rectification","re","priority","tickN","SpartitoMeasure","reorderEvents","staffYsFull","rx","ry","yi","yis","intX","intY","originalRegulationHash","regulationHash","postRegulate","keySignature","timeSignatureChanged","validRegulated","tickMap","endEvent","tickToX","tickRates","rates","tickRatesInGroups","gevents","groupIndex","twists","empty","hasIllEvent","brief","regulationHash0","regulationHashes","featureWords","invalid","uys","melodies","rhythm","barType","typeEntris","partialDuration","signatureDuration","updateRoundX","graceEvents","staffMap","smap","oldEvent","emap","preTick","graceIds","totalDuration","warp","solveGraceEvents","catchers","pitchers","catcher","candidates","pitcher","catcherId","pi","solveTremoloPairs","updateContextTick","terms","t2","asSolution","ref","refEvent","applySolution","cleanupRegulation","regulateTest","regulateSimple","regulateEquations","regulate","policy","createPatch","createClusters","trueEventIds","idx","staffIndices","staffY0","staffYs","staffYn","headY","backgroundImages","url","applyClusters","id_max","is","srcId","tarId","emptyVoiceFromStaffMeasure","chiefVoice","timeSigNumeric","contextedTerms","markingTiesInVoice","event1","p0","tying","si0","si1","Spartito","solidMeasureCount","measureIndexMapping","headBPM","tempoMark","mark","measureLayoutCode","ms","vb","ve","leftSign","rightSign","nextI","mm","nextVBI","pms","lastVEI","lastMI","dumpEvaluations","rectifyTimeSignatures","mis","newTimeSignature","measuresToFix","originTimeSignature","regularD","numerators","countings","peakCount","bestCounting","best","reducedN","makeVoiceStaves","voiceCount","leftStaves","lastEvent","tailEvent","tailStaff","pageBreak","headStaff","sd","trait","staffToGroup","voiceTraits","vector","v1","v2","leftVoices","voiceTrait","vs","consistencies","voiceIndex","m1","m2","staffVoiceIndices","vi","mode","removeEmptyMeasuresInVoicesStaves","perform","tokenMap","staffToChannel","voiceChannels","hasTempo","nextTick","events0","voice0","part","pitchValue","performByEstimation","noteTick","featureHash","measureWords","levels","meaures","vecY","vecMelody","vecRhythm","featureHashHex","featureHashBigInt","BigInt","assignMeasureNumbers","discard","measureNumber","mod12","ALTER_NAMES","StaffContext","keyAlters","alters","timeSigNumSet","timeSigDenSet","doubtingTimesig","change","yToNote","partialTimeSignature","resetMeasure","resetSystem","noteToY","pitchToNote","preferredAlter","gp","alteredGp","naturalNote","alterValue","keyAlterValue","pitchToY","alterOnNote","yToPitch","yToPitchName","bitsToMask","Score","version","layoutTemplate","staffLayoutCode","pages","page","spartito","upgradeScoreData","headers","instrumentDict","pageSize","unitSize","maxStavesCount","imageKeys","backgroundImage","maskImage","breakSystemIndices","systemCount","staffLayout","staffLayout.parseCode","semanticHash","eventSystemsToTermStaves","eventSystems","termStaves","sys","context","startEvent","processStaffContext","resetPageLayout","parameters","newCenter","offsetX","offsetY","getMeasure","localIndex","getRawCluster","systemY0","y0","getRawClusters","makeSpartito","ri","esys","patch","patches","makeMusicSheet","voiceStaves","title","paperOptions","measureLayout","getMeasureLayout","findPoint","sid","pageIndex","getMeasureSemantics","sy1","sy2","makeTimewiseGraph","store","getTokenMap","confidenceThreshold","append","assembleSystem","markVoices","vis","replaceImageKeys","all","then","inferenceStaffLayout","staffTotal","completeSystems","bracketsAppearance","candidateCodes","codeCounting","maxCount","connectedCode","lastSys","search","code1","startsWith","assignBackgroundForMeasure","imagePosition","original","blackoutFakeNotes","scope","inScope","fakeIds","voicedIds","fakeIdSet","blackIds","measureLayout.parseCode","splitToSingleScoresGen","startSysIndices","templateScore","topology","startSysIndex","endSysIndex","sysInRange","newScore","SubScoreSystem","SubScorePage","splitToSingleScores","EditableEvent","agent","Proxy","ownKeys","getOwnPropertyDescriptor","enumerable","configurable","EditableMeasure","syncVoiceToEvents","syncVoiceFromEvents","makeMIDI","subEvents","midiEvents","BeadType","DIVISION_NAMES","SPACE_LOSS_WEIGHT","POSSIBILITY_LOW_BOUNDARY","STEM_DIRECTION_OPTIONS","BEAM_OPTIONS","saveClusterState","BeadNode","accessCount","nextBranch","possibilities","currentElem","elemIndex","branchID","ni","Pass","Division","Dots","repeat","picker","ptFactor","evaluateCluster","pretentiousness","selfEval","element","residue","fatalError","predictCluster","evaluation","estimateElementDuration","eos","lastOrder","voiceN","scales","referenceScale","nearScale","tickSpan","twist","tickMSE","tickErr","mse","spaceDuration","solveCluster","stopLoss","suc0","bestEvaluation","bestState","restoreClusterState","fixedEvents","pendingEvents","near","stemDirectionVector","beamVector","solveMeasure","quotaMax","quotaFactor","worstLoss","durations","solutionEvents","tipElem","tickSet","glimpseMeasure","resetSignatureForDoubtfulOnly","estimateMeasure","StemTip","StemHead","rect_Lyric","SemanticClusterSet","vocab","converts","connection","SUPPORT_CLEF_TYPES","starry.TokenType","tokenToText","ReflectOwnKeys","R","Reflect","ReflectApply","receiver","Function","getOwnPropertySymbols","getOwnPropertyNames","NumberIsNaN","EventEmitter","eventsModule","once","emitter","errorListener","removeListener","resolver","eventTargetAgnosticAddListener","handler","addErrorHandlerIfEventEmitter","_events","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","prepend","existing","warning","newListener","emit","warned","w","onceWrapper","fired","wrapFn","_onceWrap","wrapped","bind","_listeners","unwrap","evlistener","arr","ret","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","destructPromise","timeout","rs","rj","setTimeout","defineProperty","RangeError","setMaxListeners","getMaxListeners","doError","er","listeners","addListener","prependListener","prependOnceListener","list","originalListener","spliceOne","off","removeAllListeners","rawListeners","eventNames","AsyncQueue","working","tasks","_digest","taskFn","payload","addTask","task","promise","ZeroClient","queue","socket","Request","sendTimeout","receiveTimeout","connect","__request","retryTimes","req","send","pack","receive","close","request","method","kwargs","args_","kwargs_","msg","opt","unpack","PyProcessor","scriptPath","retryCount","retryDelay","port","freePort","getPortPromise","stopPort","defaultsDeep","pyShell","PythonShell","stdout","isBuffer","inherits_browserModule","ctor","superCtor","super_","writable","TempCtor","util","inherits","inheritsModule","getOwnPropertyDescriptors","descriptors","formatRegExp","format","isString","objects","inspect","isNull","isObject","deprecate","fn","noDeprecation","throwDeprecation","traceDeprecation","debugEnviron","debugs","opts","ctx","seen","stylize","stylizeNoColor","depth","colors","isBoolean","showHidden","_extend","isUndefined","customInspect","stylizeWithColor","formatValue","styleType","style","styles","recurseTimes","isFunction","primitive","simple","isNumber","formatPrimitive","visibleKeys","val","arrayToHash","isError","formatError","isRegExp","RegExp","isDate","output","base","braces","toUTCString","formatProperty","formatArray","cur","reduceToSingleString","desc","ar","objectToString","pad","debuglog","NODE_DEBUG","toUpperCase","pid","bold","italic","underline","white","grey","black","blue","cyan","green","magenta","red","yellow","special","boolean","null","string","date","regexp","isNullOrUndefined","isSymbol","isPrimitive","months","prop","getHours","getMinutes","getSeconds","getDate","getMonth","origin","kCustomPromisifiedSymbol","callbackifyOnRejected","reason","cb","newReason","promisify","promiseResolve","promiseReject","defineProperties","custom","callbackify","callbackified","maybeCb","rej","getPort","base64map","crypt","rotl","rotr","endian","bytes","bytesToWords","wordsToBytes","bytesToHex","hex","hexToBytes","bytesToBase64","base64","triplet","charAt","base64ToBytes","imod4","cryptModule","charenc","utf8","stringToBytes","bin","bytesToString","charenc_1","api","digestbytes","H0","H1","H2","H3","H4","asBytes","asString","_blocksize","_digestsize","sha1Module","constructSystem","detection","imageSize","systemWidth","phi2","phi1","systemHeight","lastSystem","stavesTops","middleRhos","starry.Staff","starry.System","convertImage","maxHeight","quality","buf","got","responseType","decompress","https","rejectUnauthorized","toBuffer","webpBuffer","sharp","resize","fit","withoutEnlargement","toFormat","filename","SparkMD5","ArrayBuffer","OffscreenCanvas","Canvas","Image","STAFF_PADDING_LEFT","GAUGE_VISION_SPEC","viewportHeight","viewportUnit","MASK_VISION_SPEC","SEMANTIC_VISION_SPEC","concurrencyTask","fns","shootStaffImage","paddingLeft","spec","middleUnits","canvas","getContext","fillStyle","fillRect","drawImage","loadImage","shootStaffBackgroundImage","sourceCanvas","toBufferSync","gaugeStaff","gaugeImage","pyClients","sourceBuffer","baseY","predictScoreImages","maskStaff","img","semanticStaff","settings","semanticConfidenceThreshold","replacePageImages","onReplaceImageKey","OMRProgress","onChange","setTotal","total","finished","increase","lruCache","WeakLRUCache","pageStore","getValue","setValue","onReplaceImage","multinomial_1","pvals","looseVector","ns","looseEvent","MeasureRectification","roll","DefaultSolutionStore","PendingCondition","solveMeasureRecords","records","onUpdate","pendingCondition","NotFine","pass","onProgress","pendingRecords","ErrorOnly","Imperfect","isPending","record","current","starry.beadSolver.solveMeasure","starry.evaluateMeasure","better","remaining","RECTIFICATION_SEARCH_ITERATIONS","BASE_QUOTA_FACTOR","RECTIFICATION_QUOTA_FACTOR","computeQuota","limit","solveMeasures","solutionStore","ignoreCache","cached","solved","stat","computed","solveMeasuresWithRectifications","n_rec","rec","default","stale","genMeasureRectifications","testMeasure","doSimpleRegulate","PyClients","clients","getClient","client","option","checkHost","warmup","clientType","res","by_buffer","stats","costTotal","pagesCostTotal","pagesTotal","pagesCost","costPerPage","scoreN","pickerCost","measureN","timeN","tryTimes","costPerMeasure","costPerTime","issue","fatal","baseCostTotal","topoCostTotal","baseMeasures","topoMeasures","baseCost","topoCost","baseCostPerMeasure","topoCostPerMeasure","baseComputed","baseSolved","topoSolved","topoIssue","topoFatal","onSaveIssueMeasure","t0","issueMeasures","results","cs","solvedIndices","errorIndices","n_issues","doRegulateWithTopo","maskImages","hasMaskImage","scoreJson","idsMap","idsXMap","idStaffIndexMap","coverTexts","subtitles","subtitle","authors","composer","bgWidth","bgHeight","l1","ls","parts","partTemplates","measureXs","partIndex","template","staffIndexBase","paddedStaves","chordColumns","staffIndexInPart","noteIndex","measureStartX","elems","firstX","innerId","lastFifths","clefs","pt","fifths","lineStaves","systemTopStaff","systemBottomStaff","systemTopStaffY","systemBottomStaffY","lastPartLastStaff","partStaves","staffs","details","hide","visibleStaves","partTopStaff","partBottomStaff","partTopStaffY","partBottomStaffY","distances","imgs","spartitoMeasure","parti","mIndices","sortedParts","midiJson","measInfo","ent","idNoteMap","beatsCurrent","beatsUnitCurrent","mIndex","beatsUnit","evt","note_ticks","measureInfos","beatUnit","mergedTracks","trackIndex","program","lhPattern","rhPattern","instrus","hand","handStaves","trackToSplit","newTracks","stave","rightHandTrack","leftHandTrack","transformedTracks","onEvent","measureTickMap","numId","newEvent","elem_ids","meas_start_tick","images","outputWidth","processes","progress","image","starry.Score","raggedLast","raggedLastBottom","enabledGauge","originalImages","pageCanvasList","scaleForLayout","sourceSize","detections","cvs","enableGauge","imageURLMap","collectImage","createPage","detect","pageKey","cachedPageJson","omit","renew","starry.recoverJSON","starry","starry.Page","unit","cos","sin","needGauge","correctCanvas","pageCanvas","save","setTransform","restore","getImageData","putImageData","sourceCenter","shootImageByDetection","sizeRatios","staffInterval","vw","hwr","maxVW","maxAspect","setGlobalPageSize","systemsCount","allTasks","omitPages","n_page","pageTasks","bracketImages","topMid","bottomMid","sourceRect","OUTPUT_INTERVAL","bracketsRes","buffers","bufferForText","location","box","resultOCR","titleToken","gaugeRes","maskRes","semanticRes","t3","pickers","freshOnly","onPassStart","baseQuality","n_seq","starry.beadSolver.estimateMeasure","counting","toFixed","totalMeasures","computeRemaining","wrappedOnProgress","starry.EditableMeasure","saveMeasure","solutions","batchGet","originMeasure"],"mappings":"wbAkJKA,EAmLAC,ECnUAC,mDCFLC,WAAWC,KAAQC,GAAQC,OAAOC,KAAKF,EAAK,UA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AAKS,GAAYA,EAAQmhD,eAE9Cp6C,GAASumE,cAAe,CAC3Bt/C,EAAMvH,WACN,MAAMsjC,EAAW/7B,EAAMg+B,eAEvB7lC,EAASjsB,QAAS8F,IAEjB,GADA+G,EAAQumE,cAAelvE,IAAI4B,EAAQu9C,eAAgB,IAAKv9C,EAAQygD,aAAc9D,SAAU,IACpF38C,EAAQw+C,kBAAoBx+C,EAAQu9C,eAAgB,CACvD,MAAMq+B,EAAgB7xB,EAAS5jC,SAASpS,KAAMriB,GAAMA,EAAEo5B,eAAiB9qB,EAAQ8qB,cAC/E/jB,EAAQumE,cAAelvE,IAAI4B,EAAQw+C,gBAAiB,IAAKx+C,EAAQygD,WAAWm7B,GAAgBj/B,SAAU,GACtG,GAEF"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../../src/starry/interfaces.ts","../../../src/starry/semanticPoint.ts","../../libs/browserComponents.ts","../../../src/starry/token.ts","../../../src/starry/aux_/typedJSON.ts","../../../src/measureLayout/measureLayout.ts","../../../src/measureLayout/grammar.jison.js","../../../src/staffLayout/staffLayout.ts","../../../src/staffLayout/grammar.jison.js","../../../src/staffLayout/parser.ts","../../../src/starry/logger.ts","../../../src/starry/utils.ts","../../../src/starry/term.ts","../../../src/starry/measureEvaluator.ts","../../../src/starry/semanticGraph.ts","../../../src/starry/scoreComponents.ts","../../../src/starry/semanticTopology.ts","../../../src/performer/types.ts","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifile.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/stream.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifileEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/streamEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiSequence.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MusicNotation.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiPlayer.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/config.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/node.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/navigator.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiUtils.js","../../../node_modules/@k-l-lambda/music-widgets/index.js","../../../src/performer/notation.ts","../../../node_modules/crypto-js/core.js","../../../node_modules/crypto-js/sha256.js","../../../src/starry/hashVector.ts","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/equationSolver.ts","../../../src/starry/eventTopology.ts","../../../src/starry/spartitoMeasure.ts","../../../src/starry/patch.ts","../../../src/starry/spartito.ts","../../../src/starry/staffContext.ts","../../../src/starry/score.ts","../../../src/measureLayout/parser.ts","../../../src/starry/editableMeasure.ts","../../../src/starry/beadSolver.ts","../../../src/isomorphic/converter.ts","../../../node_modules/events/events.js","../../libs/async-queue.ts","../../libs/ZeroClient.ts","../../libs/PyProcessor.ts","../../../node_modules/util/support/isBuffer.js","../../../node_modules/util/node_modules/inherits/inherits_browser.js","../../../node_modules/util/node_modules/inherits/inherits.js","../../../node_modules/util/util.js","../../libs/predictors.ts","../../../node_modules/crypt/crypt.js","../../../node_modules/charenc/charenc.js","../../../node_modules/sha1/sha1.js","../../libs/util.ts","../../libs/predictPages.ts","../../../src/starry/measureRectification.ts","../../libs/store.ts","../../libs/regulationBead.ts","../../libs/regulation.ts","../src/index.ts"],"sourcesContent":["import { MetaNotation, TokenPosition } from '../performer';\nimport { Term, EventTerm, ContextedTerm, ChordmodeTerm, MarkTerm, Accessory, GraceType, TremoloLink } from './term';\nimport { HashVector } from './hashVector';\nimport { StaffLayout } from '../staffLayout';\nimport * as measureLayout from '../measureLayout';\n\ninterface Rect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\ninterface ChordRect {\n\tx: number;\n\tstemX: number;\n\twidth: number;\n\ttop: number;\n\tbottom: number;\n\tstemDirection: string;\n\ttip?: { x: number; y: number };\n}\n\ninterface VLine {\n\tx: number;\n\ty1: number;\n\ty2: number;\n}\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ntype DivisionVecotor = [number, number, number, number, number, number, number, number, number]; // [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\ntype MeasureBarType = null | 'Terminal' | 'Segment' | 'VoltaRight';\n\ninterface EventFeature {\n\tdivisions: DivisionVecotor;\n\tdots: [number, number]; // [1, 2]\n\tbeams: [number, number, number]; // ['Open', 'Continue', 'Close']\n\tstemDirections: [number, number]; // ['u', 'd']\n\tgrace: number;\n\ttremoloCatcher: number;\n}\n\ninterface EventPredisposition {\n\tgrace: boolean;\n\ttimeWarped: number;\n\tfullMeasure: number;\n\tfake: number;\n\tfakeP: number;\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tdivisionVector: DivisionVecotor;\n\tdotsVector: [number, number, number]; // [0, 1, 2]\n\tbeamVector: [number, number, number, number]; // [null, open, continue, close]\n\tstemDirectionVector: [number, number, number]; // [null, up, down]\n}\n\ninterface ChordColumn {\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\tys: number[];\n\tnoteIds: string[]; // order by upwards\n\tdivision: number;\n\tdots: number;\n\trest: boolean;\n\tstemDirection: string;\n\taccessories?: Accessory[];\n\tgrace?: GraceType;\n\ttremolo?: number;\n\ttremoloLink?: TremoloLink;\n\tbeam?: string;\n\ttip?: { x: number; y: number };\n\n\t//stemTipY?: number;\n\n\t// for topology\n\tstaff?: number;\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature?: EventFeature;\n}\n\ninterface EventMeasure {\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[];\n}\n\ninterface StaffBasic {\n\ttimeSignature: Fraction;\n\ttimeSigNumeric: boolean;\n\tkeySignature: number;\n\tdoubtfulTimesig: boolean;\n}\n\ninterface EventMeasureColumn {\n\tmeasureIndex: number;\n\t//startX: number;\n\t//width: number;\n\n\trows: EventMeasure[]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\txMap?: Map;\n\tregularLoss?: number;\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n}\n\ninterface EventSystem {\n\tstaffMask: number;\n\tcolumns: EventMeasureColumn[]; // [measure]\n}\n\ninterface TermMeasure extends Partial {\n\tterms: Term[];\n\tduration: number;\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n}\n\ntype TermRow = TermMeasure[];\n\ninterface TermStaff {\n\trows: TermRow[]; // [system]\n}\n\ninterface Pitch {\n\tnote: number;\n\talter: number;\n}\n\nenum PageLayoutMethod {\n\tByLines = 'ByLines',\n\tByBlocks = 'ByBlocks',\n}\n\ninterface RecognitionSettings {\n\tenabledGauge: boolean; // staves straighten\n\tpageLayoutMethod: PageLayoutMethod;\n\tsemanticConfidenceThreshold: number;\n}\n\ninterface Crop {\n\taspect?: number | undefined;\n\tx?: number | undefined;\n\ty?: number | undefined;\n\twidth?: number | undefined;\n\theight?: number | undefined;\n\tunit?: 'px' | '%' | undefined;\n}\n\n//\t0 2 4\t\t\tr r tx\n//\t1 3 5\t\t\tr r ty\ntype Matrix2x3 = [number, number, number, number, number, number];\n\ninterface SourceImageFile {\n\tname: string;\n\tsize: number;\n\turl: string;\n\tcrop?: Crop;\n\tmatrix: Matrix2x3;\n\tdimensions: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tinterval: number;\n\tneedGauge?: boolean;\n}\n\ninterface Area extends Rect {\n\tstaves: {\n\t\tinterval: number;\n\t\tmiddleRhos: number[];\n\t\tphi1: number;\n\t\tphi2: number;\n\t};\n}\n\ninterface PageLayout {\n\tareas: Area[];\n}\n\ninterface MeasureBrief {\n\ttimeSignature: Fraction;\n}\n\ninterface VoiceMeasure {\n\ttickMap: { [key: number]: EventTerm | ChordmodeTerm };\n\tduration: number;\n\n\ttimeSignature?: Fraction;\n\ttimeSigNumeric?: boolean;\n\tkeySignature?: number;\n\n\tcontextedTerms: ContextedTerm[];\n\tmarks: MarkTerm[];\n\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbar?: string;\n\n\tempty?: boolean;\n\n\theadStaff?: number;\n\ttailStaff?: number;\n\n\ttrait?: HashVector;\n\tvoiceIndex?: number;\n}\n\ninterface TermVoice {\n\tmode: string;\n\tmeasures: VoiceMeasure[];\n}\n\ninterface VoicesStaff {\n\tcontext?: string;\n\tname?: string;\n\tvoices: TermVoice[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n\tslashSystemSeparator: boolean;\n}\n\ninterface MusicHeaders {\n\ttitle: string;\n\tsubtitle: string;\n\tsubsubtitle: string;\n\tcomposer: string;\n\tpoet: string;\n\tarranger: string;\n\topus: string;\n\tcopyright: string;\n\tinstrument: string;\n\tdedication: string;\n\ttagline: string;\n}\n\ninterface MusicSheet {\n\ttitle: string;\n\tpageSize: {\n\t\t// in pixels\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tunitSize: number;\n\tmeasureLayout?: measureLayout.MeasureLayout;\n\tstaffLayout: StaffLayout;\n\tpaperOptions?: Partial;\n\theaders: Partial;\n\n\tvoiceStaves: VoicesStaff[];\n\tinstrumentDict: { [key: string]: string };\n}\n\ninterface Performing {\n\tnotation: MetaNotation;\n\ttokenMap: Map;\n}\n\ntype RegulationPolicy = 'test' | 'simple' | 'equations' | 'advanced';\n\ninterface RegulationOptions {\n\tpolicy?: RegulationPolicy;\n\tquota?: number;\n\t[key: string]: any;\n}\n\ninterface ScoreData {\n\tversion?: number;\n\t[key: string]: any;\n}\n\ninterface AdditionalLineStack {\n\tleft: number;\n\tright: number;\n\tn: number;\n}\n\ninterface RegulationSolutionEvent {\n\tid: number;\n\ttick: number;\n\ttickGroup: number;\n\ttimeWarp: Fraction;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: string;\n\tgrace?: boolean;\n\tfullMeasure?: boolean;\n}\n\ninterface RegulationSolution {\n\tevents: RegulationSolutionEvent[];\n\tvoices: number[][];\n\tduration: number;\n\tpriority?: number;\n\testimatedDuration?: number;\n\ttimeSignature?: Fraction;\n}\n\ninterface BackgroundImage {\n\turl: string;\n\tposition: Rect;\n\toriginal?: boolean;\n}\n\nenum TextType { //\tLEVEL\t\t\tCHARSET\n\tTitle = 'Title', // page\t\t\t\tgeneral\n\tAuthor = 'Author', // page\t\t\t\tgeneral\n\tTempoText = 'TempoText', // measure\t\t\tspecific vocabulary\n\tTempoNumeral = 'TempoNumeral', // measure\t\t\tsymbolic and numeric\n\tTextualMark = 'TextualMark', // term\t\t\t\tspecific vocabulary\n\tLyric = 'Lyric', // term\t\t\t\tgeneral\n\tInstrument = 'Instrument', // system\t\t\tspecific vocabulary\n\tMeasureNumber = 'MeasureNumber', // system\t\t\tnumeric\n\tTimes = 'Times', // staff\t\t\tnumeric\n\tAlternation1 = 'Alternation1', // measure\t\t\tnumeric\n\tAlternation2 = 'Alternation2', // measure\t\t\tnumeric\n\tChord = 'Chord', // measure\t\t\tspecific domian\n\tPageMargin = 'PageMargin', // page\t\t\t\tgeneral\n\tOther = 'Other', // page\t\t\t\tgeneral\n}\n\nexport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tFraction,\n\tMeasureBarType,\n\tEventFeature,\n\tEventPredisposition,\n\tChordColumn,\n\tEventMeasure,\n\tEventMeasureColumn,\n\tEventSystem,\n\tTermMeasure,\n\tTermRow,\n\tTermStaff,\n\tPitch,\n\tPageLayoutMethod,\n\tRecognitionSettings,\n\tSourceImageFile,\n\tPageLayout,\n\tStaffBasic,\n\tVoiceMeasure,\n\tVoicesStaff,\n\tTermVoice,\n\tMeasureBrief,\n\tAdditionalLineStack,\n\tTextType,\n\tMusicSheet,\n\tPerforming,\n\tRegulationOptions,\n\tScoreData,\n\tMusicHeaders,\n\tMatrix2x3,\n\tRegulationSolutionEvent,\n\tRegulationSolution,\n\tBackgroundImage,\n};\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","globalThis.btoa = (str) => Buffer.from(str, 'binary').toString('base64');\nglobalThis.atob = (str) => Buffer.from(str, 'base64').toString('binary');\n","import { TextType } from './interfaces';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\n\nenum TokenType {\n\t// clefs\n\tClefG = 'clefs-G', // clefs.G_change\n\tClefF = 'clefs-F', // clefs.F_change\n\tClefC = 'clefs-C', // clefs.C_change\n\n\t// time signature\n\tTimesigC44 = 'timesig-C44',\n\tTimesigC22 = 'timesig-C22',\n\tTimesigZero = 'zero|timesig0',\n\tTimesigOne = 'one|timesig1',\n\tTimesigTwo = 'two|timesig2',\n\tTimesigThree = 'three|timesig3',\n\tTimesigFour = 'four|timesig4',\n\tTimesigFive = 'five|timesig5',\n\tTimesigSix = 'six|timesig6',\n\tTimesigSeven = 'seven|timesig7',\n\tTimesigEight = 'eight|timesig8',\n\tTimesigNine = 'nine|timesig9',\n\n\t// octave shifts\n\tOctaveShift8va = 'octave-a',\n\tOctaveShift8vb = 'octave-b',\n\tOctaveShift0 = 'octave-0',\n\n\t// numbers\n\tZero = 'zero|n0',\n\tOne = 'one|n1',\n\tTwo = 'two|n2',\n\tThree = 'three|n3',\n\tFour = 'four|n4',\n\tFive = 'five|n5',\n\tSix = 'six|n6',\n\tSeven = 'seven|n7',\n\tEight = 'eight|n8',\n\tNine = 'nine|n9',\n\n\t// accidentals\n\tAccNatural = 'accidentals-natural',\n\tAccSharp = 'accidentals-sharp',\n\tAccDoublesharp = 'accidentals-doublesharp',\n\tAccFlat = 'accidentals-flat',\n\tAccFlatflat = 'accidentals-flatflat',\n\tKeyNatural = 'accidentals-natural|key-natural',\n\tKeySharp = 'accidentals-sharp|key-sharp',\n\tKeyFlat = 'accidentals-flat|key-flat',\n\n\t// noteheads\n\tNoteheadS0 = 'noteheads-s0',\n\tNoteheadS1 = 'noteheads-s1',\n\tNoteheadS2 = 'noteheads-s2',\n\tNoteheadS1stemU = 'noteheads-s1|noteheads-s1-u',\n\tNoteheadS1stemD = 'noteheads-s1|noteheads-s1-d',\n\tNoteheadS2stemU = 'noteheads-s2|noteheads-s2-u',\n\tNoteheadS2stemD = 'noteheads-s2|noteheads-s2-d',\n\n\t// rests\n\tRest0 = 'rests-0o',\n\tRest1 = 'rests-1o',\n\tRest2 = 'rests-2',\n\tRest3 = 'rests-3',\n\tRest4 = 'rests-4',\n\tRest5 = 'rests-5',\n\tRest6 = 'rests-6',\n\tRest0W = 'rests-0',\n\tRestM1 = 'rests-M1',\n\n\t// flags\n\tFlag3 = 'flags-u3', // flags.d3\n\tFlag4 = 'flags-u4', // flags.d4\n\tFlag5 = 'flags-u5', // flags.d5\n\tFlag6 = 'flags-u6', // flags.d6\n\tFlag7 = 'flags-u7', // flags.d7\n\tFlag8 = 'flags-u8', // flags.d8\n\n\t// beams\n\tBeamLeft = '|beam-left',\n\tBeamRight = '|beam-right',\n\tBeamContinue = '|beam-continue',\n\n\t// tremolos\n\tTremoloLeft = '|tremolo-left',\n\tTremoloRight = '|tremolo-right',\n\tTremoloMiddle = '|tremolo-middle',\n\n\t// slur & tie\n\tSlurBegin = '|slur-begin',\n\tSlurEnd = '|slur-end',\n\tTieBegin = '|tie-begin',\n\tTieEnd = '|tie-end',\n\n\t// volta\n\tVoltaLeft = '|volta-left',\n\tVoltaRight = '|volta-right',\n\n\tVoltaAlternativeBegin = '|volta-alter-begin',\n\t//VoltaAlternativeEnd = \"|volta-alter-end\",\n\n\t// vertical bars\n\t//BarMeasure = \"|bar-measure\",\n\tBarTerminal = '|bar-terminal',\n\tBarSegment = '|bar-segment',\n\n\t// dots (duration)\n\tDot = '|dot',\n\tDotDot = '|dotdot',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\t//\n\tWedgeCrescendo = '|wedge-crescendo',\n\tWedgeDiminuendo = '|wedge-diminuendo',\n\tWedgeClose = '|wedge-close',\n\n\tCrescendoBegin = '|wedge-crescendo',\n\tDecrescendoBegin = '|wedge-diminuendo',\n\tCrescendoEnd = '|wedge-close',\n\tDecrescendoEnd = '|wedge-close',\n\n\t// scripts\n\tScriptFermata = 'scripts-ufermata', // scripts.dfermata\n\tScriptShortFermata = 'scripts-ushortfermata', // scripts.dshortfermata\n\tScriptSforzato = 'scripts-sforzato',\n\tScriptStaccato = 'scripts-staccato',\n\tScriptStaccatissimo = 'scripts-ustaccatissimo', // scripts.dstaccatissimo\n\tScriptTurn = 'scripts-turn',\n\tScriptTrill = 'scripts-trill',\n\tScriptSegno = 'scripts-segno',\n\tScriptCoda = 'scripts-coda',\n\tScriptArpeggio = 'scripts-arpeggio',\n\tScriptPrall = 'scripts-prall',\n\tScriptMordent = 'scripts-mordent',\n\tScriptMarcato = 'scripts-umarcato', // scripts.dmarcato\n\tScriptTenuto = 'scripts-tenuto',\n\tScriptPortato = 'scripts-uportato', // scripts.dportato\n\n\t// pedal\n\tPedalStar = 'pedal-star',\n\tPedalPed = 'pedal-Ped',\n\n\tText = '|text',\n\tGraceNotehead = '|grace-notehead',\n}\n\n// alias\nconst tt = TokenType;\n\nexport const TokenTypes = Object.values(TokenType);\nexport const TokenClefs = TokenTypes.filter((t) => /clefs-/.test(t));\nexport const TokenTimesigs = TokenTypes.filter((t) => /timesig/.test(t));\nexport const TokenTimesigsC = TokenTypes.filter((t) => /timesig-/.test(t));\nexport const TokenTimesigsN = TokenTypes.filter((t) => /timesig\\d/.test(t));\nexport const TokenOctshifts = TokenTypes.filter((t) => /octave-/.test(t));\nexport const TokenNumbers = TokenTypes.filter((t) => /n\\d/.test(t));\nexport const TokenAccidentals = TokenTypes.filter((t) => /accidentals-/.test(t));\nexport const TokenNoteheads = TokenTypes.filter((t) => /noteheads-/.test(t));\nexport const TokenBareNoteheads = [tt.NoteheadS0, tt.NoteheadS1, tt.NoteheadS2];\nexport const TokenDirectionalNoteheads = TokenTypes.filter((t) => /noteheads-.+-[ud]/.test(t));\nexport const TokenRests = TokenTypes.filter((t) => /rests-/.test(t));\nexport const TokenFlags = TokenTypes.filter((t) => /flags-/.test(t));\nexport const TokenVolta = TokenTypes.filter((t) => /volta-/.test(t));\nexport const TokenDynamics = TokenTypes.filter((t) => /^[a-z]$/.test(t));\nexport const TokenScripts = TokenTypes.filter((t) => /scripts-/.test(t));\nexport const TokenPedals = TokenTypes.filter((t) => /pedal-/.test(t));\nexport const TokenDots = [tt.Dot, tt.DotDot];\nexport const TokenArcs = [tt.SlurBegin, tt.SlurEnd, tt.TieBegin, tt.TieEnd];\nexport const TokenBeams = TokenTypes.filter((t) => /beam-/.test(t));\nexport const TokenWedges = TokenTypes.filter((t) => /wedge-/.test(t));\n\nexport const TokenAccessories = [\n\t...TokenNumbers,\n\t...TokenDynamics,\n\t...TokenWedges,\n\t...TokenPedals,\n\t...TokenArcs,\n\n\ttt.ScriptFermata,\n\ttt.ScriptShortFermata,\n\ttt.ScriptSforzato,\n\ttt.ScriptStaccato,\n\ttt.ScriptStaccatissimo,\n\ttt.ScriptTurn,\n\ttt.ScriptTrill,\n\ttt.ScriptPrall,\n\ttt.ScriptMordent,\n\ttt.ScriptMarcato,\n\ttt.ScriptTenuto,\n\ttt.ScriptPortato,\n];\n\nexport const TokenDirectionless = [...TokenPedals];\n\nexport const TokenGlyphs = [\n\t...TokenClefs,\n\t...TokenTimesigs,\n\t...TokenNumbers,\n\t...TokenAccidentals,\n\ttt.NoteheadS0,\n\ttt.NoteheadS1,\n\ttt.NoteheadS2,\n\t...TokenRests,\n\t...TokenDynamics,\n\t...TokenScripts,\n\t...TokenPedals,\n\t...TokenDots,\n];\n\nconst TOKEN_Y_ROUND = {} as Record;\nTokenClefs.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenTimesigsN.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenAccidentals.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenNoteheads.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenRests.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenDots.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\n\nconst TOKEN_Y_FIXED = {} as Record;\nTokenTimesigsC.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\nTokenVolta.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\n\nclass Token {\n\tstatic className = 'Token';\n\n\tid: string;\n\ttype: TokenType;\n\tx: number;\n\ty: number;\n\tpivotX?: number;\n\n\tconfidence: number;\n\n\ttip?: { x: number; y: number };\n\n\tvoice?: number; // integer, every bit stand for a voice\n\ttimeWarped?: boolean;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tget typeId(): string {\n\t\treturn this.type.split('|').reverse()[0];\n\t}\n\n\tget isPredicted(): boolean {\n\t\treturn Number.isFinite(this.confidence);\n\t}\n\n\tget isNotehead(): boolean {\n\t\treturn TokenDirectionalNoteheads.includes(this.type) || this.type === TokenType.NoteheadS0;\n\t}\n\n\tget isContexted(): boolean {\n\t\treturn (\n\t\t\tTokenClefs.includes(this.type) || TokenTimesigs.includes(this.type) || TokenOctshifts.includes(this.type) || TokenAccidentals.includes(this.type)\n\t\t);\n\t}\n\n\tget isAccessory(): boolean {\n\t\treturn TokenNumbers.includes(this.type) || TokenDynamics.includes(this.type) || TokenScripts.includes(this.type) || TokenPedals.includes(this.type);\n\t}\n\n\tget division(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Flag3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Flag4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Flag5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Flag6:\n\t\t\t\treturn 6;\n\n\t\t\tcase tt.Flag7:\n\t\t\t\treturn 7;\n\n\t\t\tcase tt.Flag8:\n\t\t\t\treturn 8;\n\n\t\t\tcase tt.RestM1:\n\t\t\t\treturn -1;\n\n\t\t\tcase tt.Rest0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.Rest1:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.Rest2:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Rest3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Rest4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Rest5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Rest6:\n\t\t\t\treturn 6;\n\n\t\t\t// TODO:\n\t\t\t//case tt.Rest0W:\n\t\t\t//\treturn 0;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget dots(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.Dot:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.DotDot:\n\t\t\t\treturn 2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget direction(): 'u' | 'd' | null {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn 'u';\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 'd';\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget width(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS2;\n\t\t}\n\t}\n\n\tget left(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x - this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x - this.width;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget right(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x + this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x + this.width;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget voiceIndices(): number[] {\n\t\tif (!this.voice || this.voice < 0) return [];\n\n\t\treturn Array(Math.floor(Math.log2(this.voice)) + 1)\n\t\t\t.fill(null)\n\t\t\t.reduce((indices, _, i) => (this.voice & (1 << i) ? [i + 1, ...indices] : indices), []);\n\t}\n}\n\nclass TextToken extends Token {\n\ttextType: TextType;\n\ttext: string;\n\ttextFeature?: Record;\n\twidth_: number;\n\tfontSize: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t\tObject.assign(this, data);\n\t}\n\n\tget width(): number {\n\t\treturn this.width_;\n\t}\n\n\tset width(value: number) {\n\t\tthis.width_ = value;\n\t}\n}\n\nexport { TokenType, Token, TextToken, TOKEN_Y_ROUND, TOKEN_Y_FIXED };\n","import pick from 'lodash/pick';\n\nconst recoverJSON = (json: string | object, classDict): T => {\n\tif (typeof json === 'object') json = JSON.stringify(json);\n\n\treturn JSON.parse(json, (_, value) => {\n\t\tif (value && typeof value === 'object' && value.__prototype) {\n\t\t\tconst Class = classDict[value.__prototype];\n\t\t\tif (Class) {\n\t\t\t\tconst { __prototype, ...fields } = value;\n\t\t\t\treturn new Class(fields);\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t});\n};\n\nconst deepCopy = (o: any, dict: Map = null): any => {\n\tdict = dict || new Map();\n\tif (dict.get(o)) return dict.get(o);\n\n\tif (Array.isArray(o)) {\n\t\tconst result = [];\n\t\tdict.set(o, result);\n\n\t\to.forEach((e) => result.push(deepCopy(e, dict)));\n\n\t\treturn result;\n\t} else if (o && typeof o === 'object') {\n\t\tconst result = {};\n\t\tdict.set(o, result);\n\n\t\tObject.entries(o).forEach(([key, value]) => (result[key] = deepCopy(value, dict)));\n\t\tObject.setPrototypeOf(result, o.__proto__);\n\n\t\treturn result;\n\t}\n\n\treturn o;\n};\n\nclass SimpleClass {\n\tassign(data?: object) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\ttoJSON() {\n\t\tconst cls = this.constructor as any;\n\n\t\tconst serializedKeys = cls.serializedKeys || (cls.blackKeys && Object.keys(this).filter((key) => !cls.blackKeys.includes(key)));\n\t\tconst fields = serializedKeys ? pick(this, serializedKeys) : this;\n\n\t\treturn {\n\t\t\t__prototype: cls.className,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tdeepCopy(): this {\n\t\treturn deepCopy(this);\n\t}\n}\n\nexport { recoverJSON, SimpleClass };\n","import { SimpleClass } from '../starry/aux_/typedJSON';\n\nenum LayoutType {\n\tOrdinary = 'ordinary',\n\tFull = 'full',\n\tConservative = 'conservative',\n\tOnce = 'once',\n}\n\ninterface MeasureLayout {\n\tserialize(type: LayoutType): number[];\n\n\tseq: MeasureSeq;\n\tcode: string;\n}\n\nexport type MeasureSeq = MeasureLayout[];\n\nconst spreadMeasureSeq = (seq: MeasureSeq, type: LayoutType = LayoutType.Ordinary): number[] => [].concat(...seq.map((layout) => layout.serialize(type)));\n\nconst seqToCode = (seq: MeasureSeq, { withBrackets = false }: { withBrackets?: boolean } = {}): string => {\n\t//const code = seq.map(layout => layout.code).join(\", \");\n\tlet code = '';\n\tlet inRange = false;\n\n\tfor (let i = 0; i < seq.length; ++i) {\n\t\tconst middle = seq[i - 1] instanceof SingleMLayout && seq[i] instanceof SingleMLayout && seq[i + 1] instanceof SingleMLayout;\n\t\tif (middle) {\n\t\t\tif (!inRange) {\n\t\t\t\tcode += '..';\n\t\t\t\tinRange = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (i > 0 && !inRange) code += ', ';\n\n\t\t\tinRange = false;\n\n\t\t\tcode += seq[i].code;\n\t\t}\n\t}\n\n\treturn withBrackets ? `[${code}]` : code;\n};\n\nclass SingleMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'SingleMLayout';\n\n\tmeasure: number;\n\n\tstatic from(measure: number) {\n\t\tconst layout = new SingleMLayout();\n\t\tlayout.measure = measure;\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(): number[] {\n\t\treturn [this.measure];\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this];\n\t}\n\n\tget code(): string {\n\t\treturn this.measure.toString();\n\t}\n}\n\nclass BlockMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'BlockMLayout';\n\n\tseq: MeasureSeq;\n\n\tstatic trimSeq(seq: MeasureSeq): MeasureSeq {\n\t\tconst seq2 = [];\n\t\tfor (const layout of seq) {\n\t\t\tif (layout instanceof BlockMLayout) {\n\t\t\t\tfor (const sub of layout.seq) seq2.push(sub);\n\t\t\t} else seq2.push(layout);\n\t\t}\n\n\t\t// reduce duplicated or backwards single measures\n\t\tconst seq3 = [];\n\t\tlet measure = null;\n\t\tfor (const layout of seq2) {\n\t\t\tif (layout instanceof SingleMLayout) {\n\t\t\t\tif (layout.measure > measure) {\n\t\t\t\t\tseq3.push(layout);\n\t\t\t\t\tmeasure = layout.measure;\n\t\t\t\t}\n\t\t\t} else seq3.push(layout);\n\t\t}\n\n\t\treturn seq3;\n\t}\n\n\tstatic fromSeq(seq: MeasureSeq): BlockMLayout {\n\t\tconst layout = new BlockMLayout();\n\t\tlayout.seq = BlockMLayout.trimSeq(seq);\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\treturn spreadMeasureSeq(this.seq, type);\n\t}\n\n\tget code(): string {\n\t\treturn seqToCode(this.seq, { withBrackets: true });\n\t}\n}\n\nclass VoltaMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'VoltaMLayout';\n\n\ttimes: number;\n\tbody: MeasureSeq;\n\talternates: MeasureSeq[];\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst bodySeq = spreadMeasureSeq(this.body);\n\n\t\tif (this.alternates) {\n\t\t\tconst alternateSeqs = this.alternates.map((seq) => spreadMeasureSeq(seq));\n\t\t\tconst lastAlternateSeq = alternateSeqs[alternateSeqs.length - 1];\n\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\t\treturn bodySeq.concat(...alternateSeqs);\n\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Full: {\n\t\t\t\t\tconst priorSeq = [].concat(\n\t\t\t\t\t\t...Array(this.times - 1)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map((_, i) => [...bodySeq, ...alternateSeqs[i % (this.times - 1)]])\n\t\t\t\t\t);\n\n\t\t\t\t\treturn [...priorSeq, ...bodySeq, ...lastAlternateSeq];\n\t\t\t\t}\n\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn [...bodySeq, ...lastAlternateSeq];\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn bodySeq;\n\n\t\t\t\tcase LayoutType.Full:\n\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t...Array(this.times)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map(() => bodySeq)\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconsole.warn('the current case not handled:', type, this);\n\t}\n\n\tget seq(): MeasureSeq {\n\t\tconst alternates = this.alternates ? this.alternates[this.alternates.length - 1] : [];\n\n\t\treturn [...this.body, ...alternates];\n\t}\n\n\tget code(): string {\n\t\tconst body = seqToCode(this.body, { withBrackets: true });\n\n\t\tlet code = `${this.times}*${body}`;\n\t\tif (this.alternates) code += '{' + this.alternates.map((seq) => seqToCode(seq, { withBrackets: seq.length > 1 })).join(', ') + '}';\n\n\t\treturn code;\n\t}\n}\n\nclass ABAMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'ABAMLayout';\n\n\tmain: MeasureLayout;\n\trest: MeasureSeq;\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst seqA = this.main.serialize(type);\n\t\tconst seqA_ = spreadMeasureSeq(this.main.seq, LayoutType.Once);\n\t\tconst seqB = spreadMeasureSeq(this.rest, type);\n\n\t\tswitch (type) {\n\t\t\tcase LayoutType.Ordinary: // A B\n\t\t\t\treturn [...seqA, ...seqB];\n\n\t\t\tcase LayoutType.Once: // B A'\n\t\t\t\treturn [...seqB, ...seqA_];\n\n\t\t\tcase LayoutType.Conservative: // A B A'\n\t\t\tcase LayoutType.Full: // A B A'\n\t\t\t\treturn [...seqA, ...seqB, ...seqA_];\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('the current case not handled:', type, this);\n\t\t}\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this.main, ...this.rest];\n\t}\n\n\tget code(): string {\n\t\treturn '<' + this.main.code + ', ' + seqToCode(this.rest) + '>';\n\t}\n}\n\nexport { LayoutType, MeasureLayout, SingleMLayout, BlockMLayout, VoltaMLayout, ABAMLayout };\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 13],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 15],\n\t\t$V3 = [1, 26],\n\t\t$V4 = [1, 29],\n\t\t$V5 = [1, 28],\n\t\t$V6 = [1, 30],\n\t\t$V7 = [5, 13, 22, 27, 29],\n\t\t$V8 = [2, 15],\n\t\t$V9 = [1, 32],\n\t\t$Va = [5, 14, 21, 22, 27, 28, 29];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tmeasure_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tindex_wise_measure_layout: 6,\n\t\t\t'i:': 7,\n\t\t\t's:': 8,\n\t\t\tsegment_wise_measure_layout: 9,\n\t\t\tiw_sequence: 10,\n\t\t\tiw_item: 11,\n\t\t\trange: 12,\n\t\t\t',': 13,\n\t\t\tUNSIGNED: 14,\n\t\t\t'..': 15,\n\t\t\tsingle: 16,\n\t\t\tiw_block_item: 17,\n\t\t\tiw_volta: 18,\n\t\t\tiw_aba: 19,\n\t\t\tiw_block: 20,\n\t\t\t'[': 21,\n\t\t\t']': 22,\n\t\t\t'*': 23,\n\t\t\tiw_optional_alternates: 24,\n\t\t\tiw_alternates: 25,\n\t\t\t'{': 26,\n\t\t\t'}': 27,\n\t\t\t'<': 28,\n\t\t\t'>': 29,\n\t\t\tsw_sequence: 30,\n\t\t\tsw_item: 31,\n\t\t\tsegment: 32,\n\t\t\tsw_block_item: 33,\n\t\t\tsw_volta: 34,\n\t\t\tsw_aba: 35,\n\t\t\tsw_block: 36,\n\t\t\tsw_optional_alternates: 37,\n\t\t\tsw_alternates: 38,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: {\n\t\t\t2: 'error',\n\t\t\t5: 'EOF',\n\t\t\t7: 'i:',\n\t\t\t8: 's:',\n\t\t\t13: ',',\n\t\t\t14: 'UNSIGNED',\n\t\t\t15: '..',\n\t\t\t21: '[',\n\t\t\t22: ']',\n\t\t\t23: '*',\n\t\t\t26: '{',\n\t\t\t27: '}',\n\t\t\t28: '<',\n\t\t\t29: '>',\n\t\t},\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[4, 2],\n\t\t\t[4, 2],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 3],\n\t\t\t[10, 3],\n\t\t\t[12, 3],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[16, 1],\n\t\t\t[17, 1],\n\t\t\t[20, 3],\n\t\t\t[18, 4],\n\t\t\t[24, 0],\n\t\t\t[24, 1],\n\t\t\t[25, 3],\n\t\t\t[19, 5],\n\t\t\t[9, 1],\n\t\t\t[30, 1],\n\t\t\t[30, 2],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[32, 1],\n\t\t\t[33, 1],\n\t\t\t[36, 3],\n\t\t\t[34, 4],\n\t\t\t[37, 0],\n\t\t\t[37, 1],\n\t\t\t[38, 3],\n\t\t\t[35, 4],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.$ = root(null, $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = root('index-wise', $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tthis.$ = root('segment-wise', serialize($$[$0]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 5:\n\t\t\t\tcase 23:\n\t\t\t\t\tif ($$[$0].length === 1 && $$[$0][0].__prototype === 'BlockMLayout') this.$ = $$[$0][0];\n\t\t\t\t\telse this.$ = blockLayout($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\tcase 24:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 7:\n\t\t\t\tcase 11:\n\t\t\t\tcase 12:\n\t\t\t\tcase 13:\n\t\t\t\tcase 14:\n\t\t\t\tcase 20:\n\t\t\t\tcase 27:\n\t\t\t\tcase 28:\n\t\t\t\tcase 29:\n\t\t\t\tcase 35:\n\t\t\t\t\tthis.$ = $$[$0];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 8:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 9:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], ...$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 10:\n\t\t\t\t\tthis.$ = range($$[$0 - 2], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = singleLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 16:\n\t\t\t\tcase 31:\n\t\t\t\t\tthis.$ = blockLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 17:\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 18:\n\t\t\t\tcase 33:\n\t\t\t\t\tthis.$ = voltaBlock($$[$0 - 3], $$[$0 - 1], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 19:\n\t\t\t\tcase 34:\n\t\t\t\t\tthis.$ = null;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 36:\n\t\t\t\t\tthis.$ = alternates($$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 3], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\t\tthis.$ = blockLayout([$$[$0]]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 30:\n\t\t\t\t\tthis.$ = segment($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 37:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 2], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 6: 3, 7: [1, 4], 8: [1, 5], 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 17] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 6: 18, 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 9: 19, 14: $V3, 21: $V4, 28: $V5, 30: 20, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 5: [2, 5], 13: $V6 },\n\t\t\to($V7, [2, 6]),\n\t\t\to($V7, [2, 7]),\n\t\t\to($V7, [2, 11]),\n\t\t\to($V7, [2, 12]),\n\t\t\to($V7, [2, 13]),\n\t\t\to($V7, [2, 14]),\n\t\t\to($V7, $V8, { 15: [1, 31], 23: $V9 }),\n\t\t\to($V7, [2, 16]),\n\t\t\t{ 11: 33, 14: [1, 34], 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 10: 35, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [2, 1] },\n\t\t\t{ 5: [2, 3] },\n\t\t\t{ 5: [2, 4] },\n\t\t\t{ 5: [2, 23], 14: $V3, 21: $V4, 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 24]),\n\t\t\to($Va, [2, 26]),\n\t\t\to($Va, [2, 27]),\n\t\t\to($Va, [2, 28]),\n\t\t\to($Va, [2, 29]),\n\t\t\to($Va, [2, 30], { 23: [1, 37] }),\n\t\t\to($Va, [2, 31]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 31: 38, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 39, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 11: 40, 12: 41, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 14: [1, 42] },\n\t\t\t{ 20: 43, 21: $V1 },\n\t\t\t{ 13: [1, 44] },\n\t\t\t{ 13: $V8, 23: $V9 },\n\t\t\t{ 13: $V6, 22: [1, 45] },\n\t\t\to($Va, [2, 25]),\n\t\t\t{ 21: $V4, 36: 46 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 47, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 22: [1, 48], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 8]),\n\t\t\to($V7, [2, 9]),\n\t\t\to($V7, [2, 10]),\n\t\t\to($V7, [2, 19], { 24: 49, 25: 50, 26: [1, 51] }),\n\t\t\t{ 10: 52, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\to([5, 13, 22, 26, 27, 29], [2, 17]),\n\t\t\to($Va, [2, 34], { 37: 53, 38: 54, 26: [1, 55] }),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 29: [1, 56], 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to([5, 14, 21, 22, 26, 27, 28, 29], [2, 32]),\n\t\t\to($V7, [2, 18]),\n\t\t\to($V7, [2, 20]),\n\t\t\t{ 10: 57, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 13: $V6, 29: [1, 58] },\n\t\t\to($Va, [2, 33]),\n\t\t\to($Va, [2, 35]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 59, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 37]),\n\t\t\t{ 13: $V6, 27: [1, 60] },\n\t\t\to($V7, [2, 22]),\n\t\t\t{ 14: $V3, 21: $V4, 27: [1, 61], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 21]),\n\t\t\to($Va, [2, 36]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 17: [2, 1], 18: [2, 3], 19: [2, 4] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tconst root = (type, data) => ({ __prototype: 'MesaureLayout', type, data });\n\n\tconst singleLayout = (n) => ({ __prototype: 'SingleMLayout', measure: Number(n) });\n\tconst blockLayout = (seq) => ({ __prototype: 'BlockMLayout', seq });\n\tconst voltaBlock = (times, body, alternates) => ({ __prototype: 'VoltaMLayout', times: Number(times), body, alternates });\n\tconst abaBlock = (main, rest) => ({ __prototype: 'ABAMLayout', main, rest });\n\n\tconst segment = (n) => ({ segment: true, length: Number(n) });\n\n\tconst alternates = (items) =>\n\t\titems.map((item) => {\n\t\t\tif (item.__prototype === 'BlockMLayout') return item.seq;\n\n\t\t\treturn [item];\n\t\t});\n\n\tconst range = (start, end) => {\n\t\tstart = Number(start);\n\t\tend = Number(end);\n\n\t\tif (!(end >= start)) throw new Error(`invalid measure range: ${start}..${end}`);\n\n\t\treturn Array(end + 1 - start)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => singleLayout(start + i));\n\t};\n\n\tconst serializeSeq = (item, options) => {\n\t\tif (item.segment) {\n\t\t\tconst index = options.index;\n\t\t\toptions.index += item.length;\n\n\t\t\treturn Array(item.length)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => singleLayout(index + i));\n\t\t}\n\n\t\treturn [serialize(item, options)];\n\t};\n\n\tconst serialize = (item, options = { index: 1 }) => {\n\t\tconst speard = (seq) => [].concat(...seq.map((it) => serializeSeq(it, options)));\n\n\t\tswitch (item.__prototype) {\n\t\t\tcase 'BlockMLayout':\n\t\t\t\titem.seq = speard(item.seq);\n\n\t\t\t\tbreak;\n\t\t\tcase 'VoltaMLayout':\n\t\t\t\titem.body = speard(item.body);\n\t\t\t\titem.alternates = item.alternates && item.alternates.map(speard);\n\n\t\t\t\tbreak;\n\t\t\tcase 'ABAMLayout':\n\t\t\t\titem.main = serialize(item.main, options);\n\t\t\t\titem.rest = speard(item.rest);\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn item;\n\t};\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 14;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([*,\\[\\]<>{}]))/, /^(?:(([1-9])([0-9])*))/, /^(?:(([a-z])+):)/, /^(?:\\.\\.)/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3, 4, 5], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","export interface RawItem {\n\tid: string;\n\tleftBounds: string[];\n\trightBounds: string[];\n\tconjunction: string;\n}\n\nexport enum StaffGroupType {\n\tDefault,\n\tBrace, // {}\n\tBracket, // <>\n\tSquare, // []\n}\n\nexport enum StaffConjunctionType {\n\tBlank,\n\tDashed,\n\tSolid,\n}\n\ntype StaffID = string;\n\nexport interface StaffGroup {\n\ttype: StaffGroupType;\n\tsubs?: StaffGroup[];\n\tstaff?: StaffID;\n\tlevel?: number;\n\tgrand?: boolean;\n}\n\ninterface StaffGroupTrait {\n\tgroup: StaffGroup;\n\trange: [number, number];\n\tkey: string;\n}\n\nconst singleGroup = (id: string) => ({ type: StaffGroupType.Default, staff: id });\n\nconst BOUNDS_TO_GROUPTYPE: { [bound: string]: StaffGroupType } = {\n\t'{': StaffGroupType.Brace,\n\t'}': StaffGroupType.Brace,\n\t'<': StaffGroupType.Bracket,\n\t'>': StaffGroupType.Bracket,\n\t'[': StaffGroupType.Square,\n\t']': StaffGroupType.Square,\n};\n\nconst OPEN_BOUNDS = '{<[';\nconst CLOSE_BOUNDS = '}>]';\n\nconst CONJUNCTIONS_MAP: { [conj: string]: StaffConjunctionType } = {\n\t',': StaffConjunctionType.Blank,\n\t'-': StaffConjunctionType.Solid,\n\t'.': StaffConjunctionType.Dashed,\n};\n\nconst bracketCode = (type: StaffGroupType, partial: boolean = false): ((inner: string) => string) => {\n\tif (type === StaffGroupType.Default) return (inner) => inner;\n\n\tif (partial) {\n\t\tswitch (type) {\n\t\t\tcase StaffGroupType.Brace:\n\t\t\t\treturn (inner) => `{${inner}`;\n\t\t\tcase StaffGroupType.Bracket:\n\t\t\t\treturn (inner) => `<${inner}`;\n\t\t\tcase StaffGroupType.Square:\n\t\t\t\treturn (inner) => `[${inner}`;\n\t\t\tdefault:\n\t\t\t\treturn (inner) => inner;\n\t\t}\n\t}\n\n\tswitch (type) {\n\t\tcase StaffGroupType.Brace:\n\t\t\treturn (inner) => `{${inner}}`;\n\t\tcase StaffGroupType.Bracket:\n\t\t\treturn (inner) => `<${inner}>`;\n\t\tcase StaffGroupType.Square:\n\t\t\treturn (inner) => `[${inner}]`;\n\t\tdefault:\n\t\t\treturn (inner) => inner;\n\t}\n};\n\nconst randomB64 = (): string => {\n\tconst code = btoa(Math.random().toString().substr(2)).replace(/=/g, '');\n\n\treturn code.split('').reverse().slice(0, 6).join('');\n};\n\nconst makeUniqueName = (set: Set, index: number, prefix?: string): string => {\n\tlet name = prefix;\n\tif (!name) name = index.toString();\n\telse if (set.has(name)) name += '_' + index.toString();\n\n\twhile (set.has(name)) name += '_' + randomB64();\n\n\treturn name;\n};\n\nconst makeGroupsFromRaw = (parent: StaffGroup, seq: string[]): string[] => {\n\tlet remains = seq;\n\twhile (remains.length) {\n\t\tconst word = remains.shift();\n\t\tconst bound = BOUNDS_TO_GROUPTYPE[word];\n\t\tif (bound) {\n\t\t\tif (CLOSE_BOUNDS.includes(word) && bound === parent.type) break;\n\n\t\t\tif (OPEN_BOUNDS.includes(word)) {\n\t\t\t\tconst group = { type: bound, level: Number.isFinite(parent.level) ? parent.level + 1 : 0 };\n\t\t\t\tremains = makeGroupsFromRaw(group, remains);\n\n\t\t\t\tparent.subs = parent.subs || [];\n\t\t\t\tparent.subs.push(group);\n\t\t\t}\n\t\t} else {\n\t\t\tparent.subs = parent.subs || [];\n\t\t\tparent.subs.push(singleGroup(word));\n\t\t}\n\t}\n\n\twhile (parent.type === StaffGroupType.Default && parent.subs && parent.subs.length === 1) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.type = sub.type;\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t\tparent.level = sub.level;\n\t}\n\n\twhile (parent.subs && parent.subs.length === 1 && parent.subs[0].type === StaffGroupType.Default) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t}\n\n\tparent.grand = parent.type === StaffGroupType.Brace && parent.subs && parent.subs.every((sub) => sub.staff);\n\n\treturn remains;\n};\n\nconst groupHead = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupHead(group.subs[0]);\n};\n\nconst groupTail = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupTail(group.subs[group.subs.length - 1]);\n};\n\nexport const groupKey = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return `${groupHead(group)}-${groupTail(group)}`;\n};\n\nconst groupDict = (group: StaffGroup, dict: { [key: string]: StaffGroup }): void => {\n\tdict[groupKey(group)] = group;\n\n\tif (group.subs) group.subs.forEach((sub) => groupDict(sub, dict));\n};\n\nexport interface MaskedStaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroups: StaffGroupTrait[];\n}\n\nclass StaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroup: StaffGroup;\n\tgroups: StaffGroupTrait[];\n\n\tmaskCache: Map;\n\n\tconstructor(raw: RawItem[]) {\n\t\t// make unique ids\n\t\tconst ids = new Set();\n\t\traw.forEach((item, i) => {\n\t\t\titem.id = makeUniqueName(ids, i + 1, item.id);\n\t\t\tids.add(item.id);\n\t\t});\n\t\tthis.staffIds = raw.map((item) => item.id);\n\t\tthis.conjunctions = raw.slice(0, raw.length - 1).map((item) => (item.conjunction ? CONJUNCTIONS_MAP[item.conjunction] : StaffConjunctionType.Blank));\n\n\t\t// make groups\n\t\tconst seq = [].concat(...raw.map((item) => [...item.leftBounds, item.id, ...item.rightBounds]));\n\t\tthis.group = { type: StaffGroupType.Default };\n\t\tmakeGroupsFromRaw(this.group, seq);\n\n\t\tconst dict = {};\n\t\tgroupDict(this.group, dict);\n\t\tthis.groups = Object.entries(dict).map(([key, group]) => {\n\t\t\tlet ids = key.split('-');\n\t\t\tif (ids.length === 1) ids = [ids[0], ids[0]];\n\t\t\tconst range = ids.map((id) => this.staffIds.indexOf(id));\n\n\t\t\treturn {\n\t\t\t\tgroup,\n\t\t\t\trange,\n\t\t\t\tkey,\n\t\t\t} as StaffGroupTrait;\n\t\t});\n\n\t\tthis.maskCache = new Map();\n\t}\n\n\tget stavesCount(): number {\n\t\tif (!this.staffIds) return null;\n\n\t\treturn this.staffIds.length;\n\t}\n\n\tget partGroups(): StaffGroupTrait[] {\n\t\tconst grands = this.groups.filter((g) => g.group.grand);\n\t\tconst parts = this.groups.filter((g) => {\n\t\t\tif (g.group.grand) return true;\n\n\t\t\tif (g.range[0] === g.range[1]) {\n\t\t\t\tconst index = g.range[0];\n\t\t\t\treturn !grands.some((g) => g.range[0] <= index && g.range[1] >= index);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn parts;\n\t}\n\n\tget standaloneGroups(): string[][] {\n\t\tconst groups: string[][] = [];\n\t\tconst collect = (group: StaffGroup): void => {\n\t\t\tif (group.grand) groups.push(group.subs.map((sub) => sub.staff));\n\t\t\telse if (group.staff) groups.push([group.staff]);\n\t\t\telse if (group.subs) group.subs.forEach((sub) => collect(sub));\n\t\t};\n\t\tcollect(this.group);\n\n\t\treturn groups;\n\t}\n\n\tconjunctionBetween(upStaff: number, downStaff: number): StaffConjunctionType {\n\t\tif (downStaff <= upStaff) return null;\n\n\t\tlet con = StaffConjunctionType.Solid;\n\t\tfor (let i = upStaff; i < downStaff; i++) con = Math.min(con, this.conjunctions[i]);\n\n\t\treturn con;\n\t}\n\n\tstatic makeMaskLayout(layout: StaffLayout, mask: number): MaskedStaffLayout {\n\t\tconst staffIds = layout.staffIds.filter((_, i) => mask & (1 << i));\n\t\tif (staffIds.length === layout.staffIds.length) {\n\t\t\treturn {\n\t\t\t\tstaffIds: layout.staffIds,\n\t\t\t\tconjunctions: layout.conjunctions,\n\t\t\t\tgroups: layout.groups,\n\t\t\t};\n\t\t}\n\n\t\tconst groups = layout.groups\n\t\t\t.map((g) => ({ ids: layout.staffIds.slice(g.range[0], g.range[1] + 1).filter((id) => staffIds.includes(id)), ...g }))\n\t\t\t.filter(({ ids }) => ids.length)\n\t\t\t.map(\n\t\t\t\t({ ids, ...g }) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tkey: g.key,\n\t\t\t\t\t\tgroup: g.group,\n\t\t\t\t\t\trange: [staffIds.indexOf(ids[0]), staffIds.indexOf(ids[ids.length - 1])],\n\t\t\t\t\t} as StaffGroupTrait)\n\t\t\t);\n\n\t\tconst conjunctions = staffIds.slice(0, staffIds.length - 1).map((id, i) => {\n\t\t\tconst nextId = staffIds[i + 1];\n\t\t\treturn layout.conjunctionBetween(layout.staffIds.indexOf(id), layout.staffIds.indexOf(nextId));\n\t\t});\n\n\t\treturn {\n\t\t\tstaffIds,\n\t\t\tconjunctions,\n\t\t\tgroups,\n\t\t};\n\t}\n\n\tmask(mask: number): MaskedStaffLayout {\n\t\tif (!this.maskCache.get(mask)) this.maskCache.set(mask, StaffLayout.makeMaskLayout(this, mask));\n\n\t\treturn this.maskCache.get(mask);\n\t}\n\n\t// {,}\t*\t1,1\t\t=> {,}\n\t// {,}\t*\t1,x\t\t=> {\n\t// {,}\t*\t0,x\t\t=>\n\t// {,}\t*\t0,1\t\t=> {}\n\tpartialMaskCode(bits: (1 | 0)[], withIds = false): string {\n\t\ttype Attendance = 0 | 1 | null;\n\t\tconst staffStatus = this.staffIds\n\t\t\t.map((_, i) => (i < bits.length ? bits[i] : null))\n\t\t\t.reduce((status, x, i) => {\n\t\t\t\tstatus[this.staffIds[i]] = x;\n\t\t\t\treturn status;\n\t\t\t}, {} as { [id: string]: Attendance });\n\n\t\tconst joinGroup = (group: StaffGroup): [string, boolean] => {\n\t\t\tif (group.staff) return [staffStatus[group.staff] ? group.staff : null, staffStatus[group.staff] === null];\n\n\t\t\tconst subs = group.subs.map((sub) => joinGroup(sub));\n\t\t\tconst subStr = subs\n\t\t\t\t.map((pair) => pair[0])\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(',');\n\t\t\tconst partial = subs.some(([_, partial]) => partial);\n\n\t\t\tconst code = subStr ? bracketCode(group.type, partial)(subStr) : null;\n\n\t\t\treturn [code, partial];\n\t\t};\n\n\t\tlet [code] = joinGroup(this.group);\n\t\tcode = code || '';\n\t\tif (!withIds) code = code.replace(/[_\\w]+/g, '');\n\n\t\treturn code;\n\t}\n}\n\nexport default StaffLayout;\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 15],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 17],\n\t\t$V3 = [1, 11],\n\t\t$V4 = [1, 12],\n\t\t$V5 = [1, 13],\n\t\t$V6 = [1, 24],\n\t\t$V7 = [1, 25],\n\t\t$V8 = [1, 26],\n\t\t$V9 = [5, 11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Va = [15, 16, 17, 21, 22, 23, 24],\n\t\t$Vb = [11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Vc = [5, 11, 12, 13, 21, 22, 23, 24];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tstaff_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tseq: 6,\n\t\t\tseq_id: 7,\n\t\t\tseq_br: 8,\n\t\t\tseq_con: 9,\n\t\t\tbound_left: 10,\n\t\t\t'<': 11,\n\t\t\t'[': 12,\n\t\t\t'{': 13,\n\t\t\tbound_right: 14,\n\t\t\t'>': 15,\n\t\t\t']': 16,\n\t\t\t'}': 17,\n\t\t\tbound_lefts: 18,\n\t\t\tbound_rights: 19,\n\t\t\tconjunction: 20,\n\t\t\t'-': 21,\n\t\t\t',': 22,\n\t\t\t'.': 23,\n\t\t\tID: 24,\n\t\t\tseq_bl: 25,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: { 2: 'error', 5: 'EOF', 11: '<', 12: '[', 13: '{', 15: '>', 16: ']', 17: '}', 21: '-', 22: ',', 23: '.', 24: 'ID' },\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[6, 0],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[18, 1],\n\t\t\t[18, 2],\n\t\t\t[19, 1],\n\t\t\t[19, 2],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[7, 1],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[25, 1],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[9, 1],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\t$$[$0].next();\n\n\t\t\t\t\tthis.$ = $$[$0].toJSON();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = new Seq();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 13:\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 14:\n\t\t\t\tcase 16:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 20:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.i($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 23:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\tcase 24:\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.bl($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\tcase 27:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 28:\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 29:\n\t\t\t\tcase 30:\n\t\t\t\tcase 31:\n\t\t\t\t\t$$[$0 - 1].tip.br($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.con($$[$0]);\n\t\t\t\t\tthis.$.next();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 33:\n\t\t\t\tcase 34:\n\t\t\t\tcase 35:\n\t\t\t\tcase 36:\n\t\t\t\t\t$$[$0 - 1].tip.con($$[$0]);\n\t\t\t\t\t$$[$0 - 1].next();\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 5: [2, 3], 6: 3, 7: 4, 8: 5, 9: 6, 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 10, 20: 9, 21: $V3, 22: $V4, 23: $V5, 24: [1, 7], 25: 8 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 18] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 5: [2, 4], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 22, 19: 20, 20: 21, 21: $V3, 22: $V4, 23: $V5, 24: [1, 19] },\n\t\t\t{ 5: [2, 5], 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 29, 20: 28, 21: $V3, 22: $V4, 23: $V5, 24: [1, 27] },\n\t\t\t{ 5: [2, 6], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 33, 19: 31, 20: 32, 21: $V3, 22: $V4, 23: $V5, 24: [1, 30] },\n\t\t\to($V9, [2, 20]),\n\t\t\t{ 14: 23, 15: $V6, 16: $V7, 17: $V8, 19: 35, 20: 36, 21: $V3, 22: $V4, 23: $V5, 24: [1, 34] },\n\t\t\to($V9, [2, 32]),\n\t\t\to($Va, [2, 25], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 17]),\n\t\t\to($V9, [2, 18]),\n\t\t\to($V9, [2, 19]),\n\t\t\to($Vb, [2, 13]),\n\t\t\to($Vb, [2, 7]),\n\t\t\to($Vb, [2, 8]),\n\t\t\to($Vb, [2, 9]),\n\t\t\t{ 1: [2, 1] },\n\t\t\to($V9, [2, 21]),\n\t\t\to($Vc, [2, 29], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 33]),\n\t\t\to($Va, [2, 26], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 15]),\n\t\t\to($V9, [2, 10]),\n\t\t\to($V9, [2, 11]),\n\t\t\to($V9, [2, 12]),\n\t\t\to($V9, [2, 23]),\n\t\t\to($V9, [2, 35]),\n\t\t\to($Va, [2, 27], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 24]),\n\t\t\to($Vc, [2, 31], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 36]),\n\t\t\to($Va, [2, 28], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 22]),\n\t\t\to($Vc, [2, 30], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 34]),\n\t\t\to($Vb, [2, 14]),\n\t\t\to($V9, [2, 16]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 18: [2, 1] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tclass Item {\n\t\tconstructor() {\n\t\t\tthis.id = null;\n\t\t\tthis.leftBounds = [];\n\t\t\tthis.rightBounds = [];\n\t\t\tthis.conjunction = null;\n\t\t}\n\n\t\ti(id) {\n\t\t\tthis.id = id;\n\t\t\treturn this;\n\t\t}\n\n\t\tbl(leftBounds) {\n\t\t\tthis.leftBounds = leftBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tbr(rightBounds) {\n\t\t\tthis.rightBounds = rightBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tcon(conjunction) {\n\t\t\tthis.conjunction = conjunction;\n\t\t\treturn this;\n\t\t}\n\t}\n\n\tclass Seq {\n\t\tconstructor() {\n\t\t\tthis.body = [];\n\t\t\tthis.tip = new Item();\n\t\t}\n\n\t\tnext() {\n\t\t\tthis.body.push(this.tip);\n\t\t\tthis.tip = new Item();\n\t\t\treturn this;\n\t\t}\n\n\t\ttoJSON() {\n\t\t\treturn this.body;\n\t\t}\n\t}\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 24;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([-,.\\[\\]<>{}]))/, /^(?:([a-zA-Z_0-9]+))/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\n// if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import StaffLayout from './staffLayout';\nimport grammar from './grammar.jison';\n\nconst parseCode = (code: string): StaffLayout => {\n\tconst raw = grammar.parse(code);\n\n\treturn new StaffLayout(raw);\n};\n\nexport { parseCode };\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","import { Fraction, Pitch, EventFeature, EventPredisposition } from './interfaces';\nimport { gcd, reducedFraction } from './utils';\nimport { TokenType } from './token';\nimport * as Token from './token';\nimport { SimpleClass } from './aux_/typedJSON';\n\nconst WHOLE_DURATION = 128 * 3 * 5;\nconst WHOLE_EXP2 = WHOLE_DURATION / 15;\n\nenum AccessoryDirection {\n\tUp = '^',\n\tDown = '_',\n\tMiddle = '-',\n}\n\nenum GraceType {\n\tGrace = 'grace',\n\tAfterGrace = 'afterGrace',\n\tAcciaccatura = 'acciaccatura',\n\tAppoggiatura = 'appoggiatura',\n\tSlashedGrace = 'slashedGrace',\n}\n\nenum StemBeam {\n\tOpen = 'Open',\n\tClose = 'Close',\n\tContinue = 'Continue',\n}\n\nenum TremoloLink {\n\tPitcher = 'Pitcher',\n\tCatcher = 'Catcher',\n\tPierced = 'Pierced',\n}\n\nenum GlissandoStyle {\n\tNormal = 'normal',\n\tDashedLine = 'dashed-line',\n\tDottedLine = 'dotted-line',\n\tZigzag = 'zigzag',\n\tTrill = 'trill',\n}\n\nenum ArpeggioStyle {\n\tNormal = 'Normal',\n\tBracket = 'Bracket',\n\tParenthesis = 'Parenthesis',\n\tParenthesisDashed = 'ParenthesisDashed',\n\tArrowDown = 'ArrowDown',\n}\n\ninterface Accessory {\n\tdirection?: AccessoryDirection;\n\tparenthesized?: boolean;\n\ttype: TokenType;\n\tid?: string;\n\tx: number;\n}\n\ninterface TermPitch extends Pitch {\n\ttying?: boolean;\n\ttied?: boolean;\n\tparenthesized?: boolean;\n\toctaveShift?: number;\n}\n\nclass Term extends SimpleClass {\n\tx: number;\n\tstaff?: number;\n}\n\ntype RestType = 'r' | 'R' | 's' | null;\n\ninterface DurationalTerm {\n\tdivision: number;\n\tdots: number;\n\tmultiplier?: Fraction;\n}\n\nconst SCALE_NAMES = 'CDEFGAB';\n\nclass EventTerm extends Term implements DurationalTerm {\n\tstatic className = 'EventTerm';\n\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\n\tsystem: number;\n\troundX: number; // for tick map, scheduler\n\tintX: number; // for measure hash\n\tintY: number;\n\tys: number[]; // order by ascending pitch, low (greater Y) to high (less Y)\n\tpitches?: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\taccessories: Accessory[];\n\tmultiplier: Fraction;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\trepetitionChord: boolean;\n\tgrace?: GraceType;\n\tbeam?: StemBeam;\n\ttimeWarp?: Fraction;\n\tparenthesized?: boolean;\n\ttremolo?: number; // like division, 'number of beams' + 2\n\ttremoloLink?: TremoloLink;\n\tglissando?: boolean;\n\tglissandoStyle?: GlissandoStyle;\n\tarpeggioStyle?: ArpeggioStyle;\n\ttip?: { x: number; y: number };\n\n\ttick: number;\n\n\t// for topology\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature: EventFeature;\n\tpredisposition: EventPredisposition;\n\n\tgraceIds?: number[];\n\tcatcherId?: number; // tremolo catcher event ID for tremolo pitcher event\n\n\tnoteIds?: string[]; // order by upwards\n\n\tstatic space({ tick, duration }: { tick: number; duration: number }): EventTerm {\n\t\tconst term = new EventTerm({\n\t\t\trest: 's',\n\t\t\ttick,\n\t\t\taccessories: [],\n\t\t});\n\t\tterm.duration = Math.round(duration);\n\n\t\treturn term;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tObject.assign(this, data);\n\n\t\tif (Number.isFinite(data.left) && Number.isFinite(data.right)) this.x = (this.left + this.right) / 2;\n\t\tif (!Number.isFinite(this.pivotX)) this.pivotX = this.x;\n\t\t//console.assert(Number.isFinite(this.x), \"EventTerm: invalid x,\", data);\n\t}\n\n\tget alignedTick(): number {\n\t\treturn this.grace ? this.tick + this.duration : this.tick;\n\t}\n\n\tget mainDuration(): number {\n\t\treturn WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t}\n\n\tget duration(): number {\n\t\tlet value = this.mainDuration;\n\t\tif (this.multiplier) value *= this.multiplier.numerator / this.multiplier.denominator;\n\t\tif (this.timeWarp) value *= this.timeWarp.numerator / this.timeWarp.denominator;\n\n\t\treturn this.grace ? value / 8 : value;\n\t}\n\n\tset duration(value: number) {\n\t\tconsole.assert(Number.isFinite(value), 'invalid duration value:', value);\n\n\t\tconst divider = gcd(value, WHOLE_EXP2);\n\t\tconst division = Math.log2(WHOLE_EXP2 / divider);\n\t\tconst multiplier = reducedFraction(value * 2 ** division, WHOLE_DURATION);\n\n\t\tthis.division = division;\n\t\tthis.dots = 0;\n\n\t\tif (multiplier.numerator !== multiplier.denominator) this.multiplier = multiplier;\n\t\telse this.multiplier = undefined;\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget times(): string {\n\t\tif (!this.timeWarp) return null;\n\n\t\treturn `${this.timeWarp.numerator}/${this.timeWarp.denominator}`;\n\t}\n\n\tget fullMeasureRest(): boolean {\n\t\treturn this.rest === 'R';\n\t}\n\n\tget tipX(): number {\n\t\treturn this.tip ? this.tip.x : this.x;\n\t}\n\n\tget tipY(): number {\n\t\treturn this.tip ? this.tip.y : this.ys ? this.ys[0] : 0;\n\t}\n\n\tget tremoloCatcher(): boolean {\n\t\treturn this.tremoloLink === TremoloLink.Catcher;\n\t}\n\n\tget scaleChord(): string {\n\t\treturn this.pitches.map((pitch) => SCALE_NAMES[(pitch.note + 700) % 7]).join('');\n\t}\n\n\tget zeroHolder(): boolean {\n\t\treturn !!this.grace || this.tremoloCatcher;\n\t}\n}\n\nenum ContextType {\n\tClef,\n\tKeyAcc,\n\tAcc,\n\tOctaveShift,\n\tTimeSignatureC,\n\tTimeSignatureN,\n}\n\nclass ContextedTerm extends Term {\n\tstatic className = 'ContextedTerm';\n\n\ty: number;\n\ttokenType: TokenType;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget type(): ContextType {\n\t\tif (Token.TokenClefs.includes(this.tokenType)) return ContextType.Clef;\n\t\tif (/\\|key-/.test(this.tokenType)) return ContextType.KeyAcc;\n\t\tif (/accidentals-/.test(this.tokenType)) return ContextType.Acc;\n\t\tif (Token.TokenOctshifts.includes(this.tokenType)) return ContextType.OctaveShift;\n\t\tif (Token.TokenTimesigsC.includes(this.tokenType)) return ContextType.TimeSignatureC;\n\t\tif (Token.TokenTimesigsN.includes(this.tokenType)) return ContextType.TimeSignatureN;\n\n\t\treturn null;\n\t}\n\n\tget staffLevel(): boolean {\n\t\treturn [ContextType.OctaveShift, ContextType.Clef, ContextType.KeyAcc].includes(this.type);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.1;\n\t}\n\n\tget clef(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.ClefG:\n\t\t\t\treturn -this.y - 2;\n\n\t\t\tcase TokenType.ClefF:\n\t\t\t\treturn -this.y + 2;\n\n\t\t\tcase TokenType.ClefC:\n\t\t\t\treturn -this.y;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget alter() {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.AccNatural:\n\t\t\tcase TokenType.KeyNatural:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.AccSharp:\n\t\t\tcase TokenType.KeySharp:\n\t\t\t\treturn 1;\n\n\t\t\tcase TokenType.AccFlat:\n\t\t\tcase TokenType.KeyFlat:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.AccDoublesharp:\n\t\t\t\treturn 2;\n\n\t\t\tcase TokenType.AccFlatflat:\n\t\t\t\treturn -2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget octaveShift(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.OctaveShift8va:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.OctaveShift0:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.OctaveShift8vb:\n\t\t\t\treturn 1;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget number(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.TimesigZero:\n\t\t\t\treturn 0;\n\t\t\tcase TokenType.TimesigOne:\n\t\t\t\treturn 1;\n\t\t\tcase TokenType.TimesigTwo:\n\t\t\t\treturn 2;\n\t\t\tcase TokenType.TimesigThree:\n\t\t\t\treturn 3;\n\t\t\tcase TokenType.TimesigFour:\n\t\t\t\treturn 4;\n\t\t\tcase TokenType.TimesigFive:\n\t\t\t\treturn 5;\n\t\t\tcase TokenType.TimesigSix:\n\t\t\t\treturn 6;\n\t\t\tcase TokenType.TimesigSeven:\n\t\t\t\treturn 7;\n\t\t\tcase TokenType.TimesigEight:\n\t\t\t\treturn 8;\n\t\t\tcase TokenType.TimesigNine:\n\t\t\t\treturn 9;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n//class BreakTerm extends Term {\n//};\n\nclass MarkTerm extends Term {\n\tstatic className = 'MarkTerm';\n\n\ttick: number;\n\n\tget prior(): number {\n\t\treturn this.tick + 0.01;\n\t}\n}\n\nconst MUSIC_NOTES = Array(7)\n\t.fill(0)\n\t.map((_, i) => String.fromCodePoint(0x1d15d + i));\n\nclass TempoTerm extends MarkTerm {\n\tstatic className = 'TempoTerm';\n\n\tduration: string;\n\tbeats: string;\n\n\tstatic fromNumeralText(text: string): TempoTerm {\n\t\tif (/.+=.*\\d+/.test(text)) {\n\t\t\tconst [symbol, value] = text.split('=');\n\t\t\tlet division = MUSIC_NOTES.findIndex((n) => symbol.includes(n));\n\t\t\tdivision = division >= 0 ? division : 2;\n\t\t\tlet duration = (2 ** division).toString();\n\t\t\tif (symbol.includes('.')) duration += '.';\n\n\t\t\treturn new TempoTerm({ tick: 0, duration, beats: value });\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.01;\n\t}\n\n\t// a whole note equal to 1920\n\tget durationMagnitude(): number {\n\t\tconst [_, den, dot] = this.duration.match(/^(\\d+)(\\.)?$/);\n\t\tconst magnitude = (WHOLE_DURATION / Number(den)) * (dot ? 1.5 : 1);\n\n\t\treturn magnitude;\n\t}\n\n\t// beats per minute, suppose 1 beat = 480 ticks\n\tget bpm(): number {\n\t\tconst [number] = this.beats.match(/\\d+/) || [90];\n\t\tconst beats = Number(number);\n\n\t\treturn (beats * this.durationMagnitude * 4) / WHOLE_DURATION;\n\t}\n\n\tisValid(range = [10, 400]): boolean {\n\t\tconst bpm = this.bpm;\n\n\t\treturn Number.isFinite(this.bpm) && bpm >= range[0] && bpm < range[1];\n\t}\n}\n\nclass GlyphTerm extends MarkTerm {\n\tstatic className = 'GlyphTerm';\n\n\tglyph: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass TextTerm extends MarkTerm {\n\tstatic className = 'TextTerm';\n\n\tdirection?: AccessoryDirection;\n\ttext: string;\n\tbold: boolean;\n\titalic: boolean;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass LyricTerm extends MarkTerm {\n\tstatic className = 'LyricTerm';\n\n\ttext: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass CommandTerm extends MarkTerm {\n\tstatic className = 'CommandTerm';\n\n\tcommand: string;\n\tparameters: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass ChordmodeTerm extends Term implements DurationalTerm {\n\tstatic className = 'ChordmodeTerm';\n\n\tpitch: Pitch;\n\tbasePitch?: Pitch;\n\tmodifier?: string;\n\n\tdivision: number;\n\tdots: number;\n\tmultiplier: Fraction;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget duration(): number {\n\t\tconst value = WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t\tif (this.multiplier) return (value * this.multiplier.numerator) / this.multiplier.denominator;\n\n\t\treturn value;\n\t}\n}\n\nexport {\n\tTerm,\n\tEventTerm,\n\tContextedTerm,\n\t//BreakTerm,\n\tMarkTerm,\n\tTempoTerm,\n\tGlyphTerm,\n\tTextTerm,\n\tLyricTerm,\n\tCommandTerm,\n\tChordmodeTerm,\n\tDurationalTerm,\n\tContextType,\n\tGraceType,\n\tTermPitch,\n\tRestType,\n\tGlissandoStyle,\n\tArpeggioStyle,\n\tAccessory,\n\tAccessoryDirection,\n\tWHOLE_DURATION,\n\tStemBeam,\n\tTremoloLink,\n};\n","import { fractionMul, gcd } from './utils';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { StemBeam, WHOLE_DURATION } from './term';\n\nexport interface MeasureEvaluation {\n\tevents: number;\n\tvalidEvents: number;\n\tvoiceRugged: boolean;\n\tnullEvents: number;\n\tfakeEvents: number;\n\twarpedEvents: number;\n\tcomplicatedTimewarp: boolean;\n\tspaceTime: number;\n\tsurplusTime: number;\n\tdurationRate: number;\n\tbeamBroken: boolean;\n\tfractionalWarp: boolean;\n\tirregularWarpsN: number;\n\tirregularTick: boolean;\n\ttickTwist: number;\n\ttickOverlapped: boolean;\n\tgraceInVoice: boolean;\n\tgraceN: number;\n\tgraceDominant: boolean;\n\tperfect: boolean;\n\tfine: boolean;\n\terror: boolean;\n\tqualityScore: number;\n}\n\nconst BEAM_STATUS = {\n\t[StemBeam.Open]: 1,\n\t[StemBeam.Continue]: 0,\n\t[StemBeam.Close]: -1,\n};\n\nexport const evaluateMeasure = (measure: SpartitoMeasure): MeasureEvaluation => {\n\tif (!measure.regulated) return undefined;\n\n\tconst eventMap = measure.eventMap;\n\n\tconst events = measure.events.length;\n\tconst validEvents = measure.voices.flat(1).length;\n\tconst warpedEvents = measure.events.filter((e) => e.timeWarp).length;\n\tconst warps = new Set(\n\t\tmeasure.events.filter((e) => e.timeWarp && !(e.rest && e.division === 0)).map((e) => `${e.timeWarp!.numerator}/${e.timeWarp!.denominator}`)\n\t);\n\tconst irregularWarps = new Set(warps);\n\tirregularWarps.delete('2/3');\n\n\tconst fractionalWarp = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tif (!events.some((e) => e.timeWarp)) return false;\n\n\t\tlet denominator = 0;\n\t\tlet tickSum = 0;\n\t\tlet eventN = 0;\n\t\treturn events.some((event, i) => {\n\t\t\tconst d = event.timeWarp ? event.timeWarp.denominator : 0;\n\t\t\tif (d !== denominator) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\n\t\t\t\ttickSum = 0;\n\t\t\t\teventN = 0;\n\t\t\t}\n\n\t\t\tdenominator = d;\n\t\t\ttickSum += event.duration;\n\t\t\t++eventN;\n\n\t\t\tif (i === events.length - 1) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst tickOverlapped = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tlet tick = 0;\n\t\treturn events.some((event) => {\n\t\t\tif (event.grace) return false;\n\n\t\t\tif (event.tick < tick) return true;\n\t\t\ttick = event.tick + event.duration;\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst fractionalTimes = new Set(measure.events.filter((e) => e.timeWarp && e.timeWarp.denominator > 3).map((e) => e.duration));\n\tconst complicatedTimewarp = fractionalTimes.size > 1;\n\n\tconst literalDuration = fractionMul(WHOLE_DURATION, measure.timeSignature);\n\tconst sigDuration = measure.doubtfulTimesig ? measure.duration : literalDuration;\n\n\tconst inVoiceEvents = measure.voices.flat(1).map((id) => eventMap[id]);\n\n\t// Guard: detect corrupted event data in voices (e.g. missing division, NaN tick)\n\tconst corruptedVoiceEvent = inVoiceEvents.some(\n\t\t(event) =>\n\t\t\t!event ||\n\t\t\t!Number.isFinite(event.tick) ||\n\t\t\t!Number.isFinite(event.division) ||\n\t\t\tevent.division < 0 ||\n\t\t\t!Number.isFinite(event.duration) ||\n\t\t\tevent.duration <= 0\n\t);\n\n\tconst overranged = inVoiceEvents.reduce((over, event) => over || event.tick < 0 || event.tick + event.duration > sigDuration, false);\n\tconst overDuration = measure.duration > literalDuration;\n\tconst graceInVoice = inVoiceEvents.some((event) => event.grace);\n\tconst graceN = measure.events.filter((e) => e.grace).length;\n\tconst graceDominant = graceN >= inVoiceEvents.length;\n\n\tconst irregularTick = inVoiceEvents.some((event) => {\n\t\tlet t = event.tick * 2 ** (event.division + 2);\n\t\tif (event.timeWarp) t *= event.timeWarp.denominator;\n\n\t\tif (!Number.isFinite(t)) return true;\n\n\t\tconst fragment = gcd(Math.round(t), WHOLE_DURATION);\n\t\t//if (fragment < WHOLE_DURATION)\n\t\t//\tconsole.log(\"irregularTick:\", event.tick, fragment);\n\t\treturn fragment < WHOLE_DURATION;\n\t});\n\n\tconst beamStatus = measure.voices!.map((voice) =>\n\t\tvoice.reduce(\n\t\t\t({ status, broken }, ei) => {\n\t\t\t\tconst event = eventMap[ei];\n\t\t\t\tif (event.beam) {\n\t\t\t\t\tstatus += BEAM_STATUS[event.beam];\n\t\t\t\t\tbroken = broken || !(status >= 0 && status <= 1);\n\t\t\t\t}\n\n\t\t\t\treturn { status, broken };\n\t\t\t},\n\t\t\t{ status: 0, broken: false }\n\t\t)\n\t);\n\tconst beamBroken = beamStatus.some(({ status, broken }) => status || broken);\n\tlet spaceTime = 0;\n\tlet surplusTime = 0;\n\tmeasure.voices!.forEach((voice) => {\n\t\tconst eventDuration = voice.reduce((sum, ei) => sum + eventMap[ei].duration, 0);\n\t\tspaceTime += Math.max(0, measure.duration - eventDuration);\n\t\tsurplusTime += Math.max(0, eventDuration - measure.duration);\n\t});\n\tspaceTime /= WHOLE_DURATION;\n\tconst nullEvents = measure.events.filter(\n\t\t(e) => !e.grace && !e.fullMeasureRest && !e.tremoloCatcher && (!e.predisposition || e.predisposition.fakeP < 0.1) && !Number.isFinite(e.tick)\n\t).length;\n\n\tconst fakeEvents = measure.events.filter(\n\t\t(event) => !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !inVoiceEvents.includes(event)\n\t).length;\n\n\tconst { voiceRugged } = measure.voices!.flat(1).reduce(\n\t\t(result, ei) => {\n\t\t\tif (!result.voiceRugged) {\n\t\t\t\tif (result.es.has(ei)) return { voiceRugged: true, es: result.es };\n\t\t\t}\n\n\t\t\tresult.es.add(ei);\n\n\t\t\treturn result;\n\t\t},\n\t\t{ voiceRugged: false, es: new Set() }\n\t);\n\n\tconst tickTwist = measure.tickTwist || 0;\n\n\tconst error =\n\t\tcorruptedVoiceEvent ||\n\t\ttickTwist >= 1 ||\n\t\ttickOverlapped ||\n\t\tvoiceRugged ||\n\t\tmeasure.tickRatesInStaves.some((rate) => rate < 0) ||\n\t\tnullEvents > 2 ||\n\t\t!measure.timeSignature ||\n\t\toverranged ||\n\t\tmeasure.duration > sigDuration ||\n\t\tmeasure.events.some((event) => event.timeWarp && event.timeWarp.numerator / event.timeWarp.denominator <= 0.5);\n\tconst perfect =\n\t\t!error &&\n\t\t!overDuration &&\n\t\ttickTwist < 0.2 &&\n\t\t!fractionalWarp &&\n\t\t!irregularWarps.size &&\n\t\t!irregularTick &&\n\t\t!spaceTime &&\n\t\t!surplusTime &&\n\t\t!!measure.voices!.length &&\n\t\t!beamBroken &&\n\t\t!graceInVoice &&\n\t\t!graceDominant &&\n\t\t(measure.duration === sigDuration || (Number.isFinite(measure.estimatedDuration) && measure.estimatedDuration <= sigDuration * 0.75));\n\tconst fine = !error && !overDuration && tickTwist < 0.3 && !fractionalWarp && !irregularTick && !surplusTime && !beamBroken && !graceInVoice;\n\n\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\tconst durationRate = measure.duration / expectDuration;\n\n\tlet qualityScore = 0;\n\tif (measure.patched && !corruptedVoiceEvent) qualityScore = 1;\n\telse if (!error) {\n\t\tconst spaceLoss = Math.tanh(Math.abs(spaceTime / Math.max(1, measure.voices.length)) * 1);\n\n\t\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\t\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\t\tconst durationLoss = expectDuration ? Math.max(0, 1 - durationRate) ** 2 : 0;\n\t\tconst warpsLoss = Math.tanh(irregularWarps.size);\n\n\t\tqualityScore = (1 - spaceLoss) * (1 - durationLoss) * (1 - warpsLoss) * (1 - tickTwist ** 2);\n\t}\n\n\treturn {\n\t\tevents,\n\t\tvalidEvents,\n\t\tvoiceRugged,\n\t\tnullEvents,\n\t\tfakeEvents,\n\t\twarpedEvents,\n\t\tcomplicatedTimewarp,\n\t\tspaceTime,\n\t\tsurplusTime,\n\t\tdurationRate,\n\t\tbeamBroken,\n\t\tfractionalWarp,\n\t\tirregularWarpsN: irregularWarps.size,\n\t\tirregularTick,\n\t\ttickTwist,\n\t\ttickOverlapped,\n\t\tgraceInVoice,\n\t\tgraceN,\n\t\tgraceDominant,\n\t\tperfect,\n\t\tfine,\n\t\terror,\n\t\tqualityScore,\n\t};\n};\n","//import { staffSvg } from \"@kelvinnxu/lotus\";\n\nimport { SemanticType, SemanticPoint, /*glyphSemanticMapping, glyphCenters,*/ SYSTEM_SEMANTIC_TYPES, Point } from './semanticPoint';\nimport { SimpleClass } from './aux_/typedJSON';\n\nclass SemanticGraph extends SimpleClass {\n\tstatic className = 'SemanticGraph';\n\n\tpoints: SemanticPoint[];\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\t/*static fromSheetStaff(staff: staffSvg.SheetStaff, hashTable: {[key: string]: any}): SemanticGraph {\n\t\tconst tokens = [].concat(...staff.measures.map(measure => measure.tokens));\n\n\t\tconst voltaRightXs = [];\n\n\t\tconst points = [];\n\t\ttokens.forEach(token => {\n\t\t\tconst def = hashTable[token.hash];\n\n\t\t\tif (token.glyph) {\n\t\t\t\tconst glyph = token.glyph as string;\n\t\t\t\tlet semantic = null;\n\n\t\t\t\tconst isKey = /^\\\\key/.test(token.source) || token.is(\"KEY\");\n\t\t\t\tlet { x: cx = 0, y: cy = 0 } = glyphCenters[glyph] || { x: 0, y: 0 };\n\t\t\t\tif (token.scale2) {\n\t\t\t\t\tcx *= token.scale2.x;\n\t\t\t\t\tcy *= token.scale2.y;\n\t\t\t\t}\n\n\t\t\t\tlet x = token.x + cx;\n\t\t\t\tconst y = token.y + cy;\n\n\t\t\t\tswitch (glyph) {\n\t\t\t\tcase \"rests.0\":\n\t\t\t\t\tif (/^R/.test(token.source))\n\t\t\t\t\t\tsemantic = \"Rest0W\";\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Rest0\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.flat\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.natural\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.sharp\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"dots.dot\":\n\t\t\t\t\tif (token.is(\"VOLTA\")) {\n\t\t\t\t\t\tx += 0.24;\t// dot glyph center X offset\n\t\t\t\t\t\tif (token.is(\"LEFT\"))\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaLeft;\n\t\t\t\t\t\telse if (token.is(\"RIGHT\")) {\n\t\t\t\t\t\t\tvoltaRightXs.push(x);\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaRight;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Dot\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"zero\":\n\t\t\t\tcase \"one\":\n\t\t\t\tcase \"two\":\n\t\t\t\tcase \"three\":\n\t\t\t\tcase \"four\":\n\t\t\t\tcase \"five\":\n\t\t\t\tcase \"six\":\n\t\t\t\tcase \"seven\":\n\t\t\t\tcase \"eight\":\n\t\t\t\tcase \"nine\": {\n\t\t\t\t\tconst upper = glyph[0].toUpperCase() + glyph.substr(1);\n\t\t\t\t\tsemantic = token.is(\"TIME_SIG\") ? \"Timesig\" + upper : upper;\n\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t}\n\n\t\t\t\tif (semantic) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (token.is(\"TEMPO_NOTEHEAD\")) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.TempoNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// grace noteheads\n\t\t\t\tif (token.is(\"NOTEHEAD\") && Number.isFinite(token.scale) && token.scale < 0.75) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.GraceNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// semantic from token symbol\n\t\t\tlet semantic = null;\n\t\t\tconst cx = 0;\n\t\t\tlet cy = 0;\n\t\t\tif (token.is(\"OCTAVE\")) {\n\t\t\t\tif (token.is(\"_8\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift8;\n\t\t\t\t\tcy = token.is(\"B\") ? -0.7512 : -0.7256;\n\t\t\t\t}\n\t\t\t\telse if (token.is(\"CLOSE\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift0;\n\t\t\t\t\tcy = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (/^flags/.test(token.glyph)) {\n\t\t\t\tlet direction = 0;\n\t\t\t\tif (/\\.u\\d/.test(token.glyph))\n\t\t\t\t\tdirection = 1;\n\t\t\t\tif (/\\.d\\d/.test(token.glyph))\n\t\t\t\t\tdirection = -1;\n\t\t\t\tif (direction) {\n\t\t\t\t\tconst [n] = token.glyph.match(/\\d+/);\n\t\t\t\t\tconst flagCount = Number(n) - 2;\n\t\t\t\t\t//console.log(\"flags:\", token.glyph, flagCount);\n\t\t\t\t\tfor (let i = 0; i < flagCount; ++i) {\n\t\t\t\t\t\tconst y = token.y + (i + 0.5) * direction;\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t//console.log(\"flags.1:\", token.x, y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"SLUR\")) {\n\t\t\t\tconst d = def && def.d;\n\t\t\t\tif (d) {\n\t\t\t\t\tconst numbers = d.match(/-?[\\d.]+/g).map(Number);\n\t\t\t\t\t//console.log(\"slur:\", numbers);\n\t\t\t\t\tconst x1 = token.x + numbers[0];\n\t\t\t\t\tconst y1 = token.y + numbers[1];\n\t\t\t\t\tconst x2 = token.x + numbers[6];\n\t\t\t\t\tconst y2 = token.y + numbers[7];\n\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurBegin,\n\t\t\t\t\t\tx: x1,\n\t\t\t\t\t\ty: y1,\n\t\t\t\t\t});\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurEnd,\n\t\t\t\t\t\tx: x2,\n\t\t\t\t\t\ty: y2,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"NOTE_STEM\")) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.vline_Stem,\n\t\t\t\t\tx: token.x + def.width / 2,\n\t\t\t\t\ty: token.y,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: token.y,\n\t\t\t\t\t\ty2: token.y + token.height,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (token.is(\"TEXT\") || token.is(\"CHORD_TEXT\")) {\n\t\t\t\tif (/\\S/.test(token.text)) {\n\t\t\t\t\t// NOTE: text rect computation is delayed to sheet rendering\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\tindex: token.index,\n\t\t\t\t\t\t\ttext: token.text,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx: token.x + cx,\n\t\t\t\t\ty: token.y + cy,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// beams\n\t\tconst stems = tokens.filter(token => token.is(\"NOTE_STEM\")).map(stem => ({\n\t\t\tx: stem.x + stem.width / 2,\n\t\t\ty1: stem.y,\n\t\t\ty2: stem.y + stem.height,\n\t\t}));\n\t\tconst beams = tokens.filter(token => token.is(\"NOTETAIL\") && token.is(\"JOINT\"))\n\t\t\t.map(beam => {\n\t\t\t\tconst def = hashTable[beam.hash];\n\t\t\t\tconst points = def && def.points;\n\t\t\t\tif (points) {\n\t\t\t\t\tconst floats = points.split(\" \").map(Number);\n\t\t\t\t\tconst x1 = beam.x + floats[4];\n\t\t\t\t\tconst x2 = beam.x + floats[0];\n\t\t\t\t\tconst y1 = beam.y + (floats[5] + floats[7]) / 2;\n\t\t\t\t\tconst y2 = beam.y + (floats[1] + floats[3]) / 2;\n\t\t\t\t\tconst k = (y2 - y1) / (x2 - x1);\n\n\t\t\t\t\treturn { x1, x2, y1, y2, k, capital: beam.is(\"CAPITAL_BEAM\") };\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}).filter(Boolean);\n\t\t//console.log(\"beams:\", beams);\n\t\tbeams.forEach(beam => {\n\t\t\tconst innerStems = stems.filter(stem => stem.x > beam.x1 - 0.2 && stem.x < beam.x2 + 0.2);\n\t\t\t//console.log(\"innerStems:\", beam, innerStems);\n\n\t\t\tlet lines = 0;\n\t\t\tinnerStems.forEach(stem => {\n\t\t\t\tconst beamY = beam.y1 + (stem.x - beam.x1) * beam.k;\n\t\t\t\t//console.log(\"beamY:\", beamY, Math.min(Math.abs(beamY - beam.y1), Math.abs(beamY - beam.y2)));\n\t\t\t\tif (beamY >= stem.y1 - 0.1 && beamY <= stem.y2 + 0.1) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t});\n\n\t\t\t\t\t++lines;\n\n\t\t\t\t\t// beam semantics\n\t\t\t\t\tif (beam.capital) {\n\t\t\t\t\t\tlet semantic = SemanticType.BeamContinue;\n\t\t\t\t\t\tif (Math.abs(stem.x - beam.x1) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamLeft;\n\t\t\t\t\t\telse if (Math.abs(stem.x - beam.x2) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamRight;\n\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!lines)\n\t\t\t\tconsole.warn(\"empty beam:\", beam, innerStems, stems);\n\t\t\t//else if (lines < 2)\n\t\t\t//\tconsole.debug(\"single beam:\", beam, innerStems, stems);\n\t\t});\n\n\t\t// wedges (crescendo & decrescendo)\n\t\tconst crescendos = tokens.filter(token => token.is(\"WEDGE CRESCENDO TOP\"));\n\t\tconst crescendoBottoms = tokens.filter(token => token.is(\"WEDGE CRESCENDO BOTTOM\"));\n\t\tconst decrescendos = tokens.filter(token => token.is(\"WEDGE DECRESCENDO TOP\"));\n\t\tconst decrescendoBottoms = tokens.filter(token => token.is(\"WEDGE DECRESCENDO BOTTOM\"));\n\t\tcrescendos.forEach(line => {\n\t\t\tconst partner = crescendoBottoms.find(b => b.x === line.x && Math.abs(b.y - line.y) < 0.06);\n\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.CrescendoBegin,\n\t\t\t\t\tx: line.x,\n\t\t\t\t\ty: line.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired crescendo:\", line, crescendoBottoms);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.CrescendoEnd,\n\t\t\t\tx: line.x + line.target.x,\n\t\t\t\ty: line.y + line.target.y,\n\t\t\t});\n\t\t});\n\t\tdecrescendos.forEach(line => {\n\t\t\tconst partner = decrescendoBottoms.find(b => b.x + b.target.x === line.x + line.target.x && Math.abs(b.y + b.target.y - (line.y + line.target.y)) < 0.06);\n\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.DecrescendoBegin,\n\t\t\t\tx: line.x,\n\t\t\t\ty: line.y,\n\t\t\t});\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.DecrescendoEnd,\n\t\t\t\t\tx: line.x + line.target.x,\n\t\t\t\t\ty: line.y + line.target.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired decrescendo:\", line, decrescendoBottoms);\n\t\t});\n\n\t\t// TODO: volta alternative\n\n\t\t// measure bars\n\t\tconst measureSeparators = staff.tokens.filter(token => token.is(\"MEASURE_SEPARATOR\"));\n\t\tconst singleBars = [];\n\t\tconst groupBars = [];\n\n\t\tfor (let i = 0; i < measureSeparators.length; ++i) {\n\t\t\tconst bar = measureSeparators[i];\n\t\t\tconst nextBar = measureSeparators[i + 1];\n\t\t\tconst inteval = nextBar ? nextBar.x - bar.x : Infinity;\n\n\t\t\tif (inteval < 1) {\n\t\t\t\tgroupBars.push([bar, nextBar]);\n\t\t\t\t++i;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsingleBars.push(bar);\n\t\t};\n\t\t//console.log(\"bars:\", singleBars, groupBars);\n\n\t\tsingleBars.forEach(bar => {\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx: bar.x + bar.sw / 2,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\tgroupBars.forEach(group => {\n\t\t\tlet x = (group[0].x + group[1].x) / 2;\n\t\t\tconst bold0 = group[0].is(\"BOLD\");\n\t\t\tconst bold1 = group[1].is(\"BOLD\");\n\n\t\t\tlet semantic = null;\n\t\t\tif (!bold0 && bold1) {\n\t\t\t\tx = group[0].x;\n\n\t\t\t\tif (!voltaRightXs.some(vx => x - vx < 2))\n\t\t\t\t\tsemantic = SemanticType.vline_BarTerminal;\n\t\t\t}\n\t\t\telse if (bold0 && !bold1)\n\t\t\t\tx = group[1].x;\n\t\t\telse if (!bold0 && !bold1)\n\t\t\t\tsemantic = SemanticType.vline_BarSegment;\n\n\t\t\t//console.log(\"group:\", group[0].x, group[1].x, x);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx,\n\t\t\t\t\ty: 0,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: -2,\n\t\t\t\t\t\ty2: 2,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}*/\n\n\tstatic fromPoints(points: SemanticPoint[] = []): SemanticGraph {\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}\n\n\tgetLayer(semantic: SemanticType): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic);\n\t}\n\n\tgetConfidentLayer(semantic: SemanticType, threshold: number): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic && (!Number.isFinite(p.confidence) || p.confidence >= threshold));\n\t}\n\n\tgetSystemPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\tgetStaffPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => !SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\toffset(x: number, y: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x += x;\n\t\t\tpoint.y += y;\n\t\t});\n\t}\n\n\tscale(factor: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x *= factor;\n\t\t\tpoint.y *= factor;\n\t\t});\n\t}\n\n\t// multipy 3x2 matrix\n\ttransform(matrix: [number, number][]): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tlet x = point.x * matrix[0][0] + point.y * matrix[1][0] + matrix[2][0];\n\t\t\tconst y = point.x * matrix[0][1] + point.y * matrix[1][1] + matrix[2][1];\n\n\t\t\tif (point.extension) {\n\t\t\t\tif (Number.isFinite(point.extension.y1)) {\n\t\t\t\t\tconst y1 = point.x * matrix[0][1] + point.extension.y1 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tconst y2 = point.x * matrix[0][1] + point.extension.y2 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tx = point.x * matrix[0][0] + (point.extension.y1 + point.extension.y2) * 0.5 * matrix[1][0] + matrix[2][0];\n\n\t\t\t\t\tpoint.extension.y1 = y1;\n\t\t\t\t\tpoint.extension.y2 = y2;\n\t\t\t\t}\n\n\t\t\t\tif (Number.isFinite(point.extension.width)) {\n\t\t\t\t\tconst scaling = Math.sqrt(matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]);\n\t\t\t\t\tpoint.extension.width *= scaling;\n\t\t\t\t\tpoint.extension.height *= scaling;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpoint.x = x;\n\t\t\tpoint.y = y;\n\t\t});\n\t}\n}\n\nexport { SemanticGraph };\n","import { SimpleClass } from './aux_/typedJSON';\nimport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tChordColumn,\n\tEventMeasureColumn,\n\tEventSystem,\n\tSourceImageFile,\n\tPageLayout,\n\tAdditionalLineStack,\n\tTextType,\n\tEventFeature,\n} from './interfaces';\nimport { distance2D, solveOverlapping, roundNumber, trans23 } from './utils';\nimport {\n\tToken,\n\tTextToken,\n\tTokenType,\n\tTokenNoteheads,\n\tTokenFlags,\n\tTokenDots,\n\tTokenRests,\n\tTokenAccessories,\n\tTokenDirectionless,\n\tTokenClefs,\n\tTokenBeams,\n\tTokenTimesigs,\n\tTOKEN_Y_FIXED,\n\tTOKEN_Y_ROUND,\n} from './token';\nimport { EventTerm, ContextedTerm, MarkTerm, TempoTerm, AccessoryDirection, GraceType, ContextType, TremoloLink } from './term';\nimport { SemanticGraph } from './semanticGraph';\nimport { SemanticType, SemanticPoint, NOTEHEAD_WIDTHS, hashSemanticPoint, hashPageSemanticPoint } from './semanticPoint';\nimport { Logger, DummyLogger } from './logger';\n\ntype ChordsFeeder = (si: number, mi: number) => ChordColumn[];\ntype ColumnProcessor = (column: EventMeasureColumn) => EventMeasureColumn;\n\nconst CHORD_X_TOLERANCE = 0.2;\n//const EVENT_X_TOLERANCE = 0.8;\n\nconst STEM_LENGTH_MAX = 6;\n\nconst INDENT_THRESHOLD = 2;\n\nconst MEASURE_SEMANTICS = [\n\tSemanticType.ClefG,\n\tSemanticType.ClefF,\n\tSemanticType.ClefC,\n\tSemanticType.TimesigC44,\n\tSemanticType.TimesigC22,\n\tSemanticType.TimesigZero,\n\tSemanticType.TimesigOne,\n\tSemanticType.TimesigTwo,\n\tSemanticType.TimesigThree,\n\tSemanticType.TimesigFour,\n\tSemanticType.TimesigFive,\n\tSemanticType.TimesigSix,\n\tSemanticType.TimesigSeven,\n\tSemanticType.TimesigEight,\n\tSemanticType.TimesigNine,\n\tSemanticType.OctaveShift8va,\n\tSemanticType.OctaveShift8vb,\n\tSemanticType.OctaveShift0,\n\tSemanticType.Zero,\n\tSemanticType.One,\n\tSemanticType.Two,\n\tSemanticType.Three,\n\tSemanticType.Four,\n\tSemanticType.Five,\n\tSemanticType.Six,\n\tSemanticType.Seven,\n\tSemanticType.Eight,\n\tSemanticType.Nine,\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n\tSemanticType.Rest0W,\n\tSemanticType.RestM1,\n\tSemanticType.SlurBegin,\n\tSemanticType.SlurEnd,\n\tSemanticType.Dot,\n\tSemanticType.f,\n\tSemanticType.p,\n\tSemanticType.m,\n\tSemanticType.n,\n\tSemanticType.r,\n\tSemanticType.s,\n\tSemanticType.z,\n\tSemanticType.ScriptFermata,\n\tSemanticType.ScriptShortFermata,\n\tSemanticType.ScriptSforzato,\n\tSemanticType.ScriptStaccato,\n\tSemanticType.ScriptStaccatissimo,\n\tSemanticType.ScriptTurn,\n\tSemanticType.ScriptTrill,\n\tSemanticType.ScriptSegno,\n\tSemanticType.ScriptCoda,\n\tSemanticType.ScriptArpeggio,\n\tSemanticType.ScriptPrall,\n\tSemanticType.ScriptMordent,\n\tSemanticType.ScriptMarcato,\n\tSemanticType.ScriptTenuto,\n\tSemanticType.ScriptPortato,\n\tSemanticType.PedalStar,\n\tSemanticType.PedalPed,\n\tSemanticType.GraceNotehead,\n\tSemanticType.BeamLeft,\n\tSemanticType.BeamRight,\n\tSemanticType.BeamContinue,\n\tSemanticType.CrescendoBegin,\n\tSemanticType.CrescendoEnd,\n\tSemanticType.DecrescendoBegin,\n\tSemanticType.DecrescendoEnd,\n\tSemanticType.TremoloLeft,\n\tSemanticType.TremoloRight,\n\tSemanticType.TremoloMiddle,\n];\n\nconst STAFF_LINED_SEMANTICS = [\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n];\n\nconst LINED_INTERVAL_SEMANTICS = [SemanticType.SignLined, SemanticType.SignInterval];\n\nconst NOTEHEAD_FOR_STEM_SEMANTICS = [SemanticType.NoteheadS1, SemanticType.NoteheadS2];\n\nconst KEYACC_CANDIDATE_SEMANTICS = {\n\tAccSharp: TokenType.KeySharp,\n\tAccNatural: TokenType.KeyNatural,\n\tAccFlat: TokenType.KeyFlat,\n};\n\nconst NOTEHEAD_TABLE: { [key: string]: { [key: string]: SemanticType } } = {\n\t[SemanticType.NoteheadS1]: {\n\t\tup: SemanticType.NoteheadS1stemU,\n\t\tdown: SemanticType.NoteheadS1stemD,\n\t},\n\t[SemanticType.NoteheadS2]: {\n\t\tup: SemanticType.NoteheadS2stemU,\n\t\tdown: SemanticType.NoteheadS2stemD,\n\t},\n};\n\nconst REST_SEMANTICS = [\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n];\n\nconst TOKEN_TO_STEMBEAM = {\n\t[TokenType.BeamLeft]: 'Open',\n\t[TokenType.BeamRight]: 'Close',\n\t[TokenType.BeamContinue]: 'Continue',\n};\n\nconst TEXT_TYPE_ALIAS = {\n\tAlter1: TextType.Alternation1,\n\tAlter2: TextType.Alternation2,\n};\n\ninterface StaffPosition {\n\ty: number;\n\tradius: number;\n}\n\ninterface TextArea {\n\tscore: number;\n\tcx: number;\n\tcy: number;\n\twidth: number;\n\theight: number;\n\ttext: string;\n\ttype: string;\n\ttheta: number;\n\tfeature_dict: Record;\n}\n\ntype Stem = VLine & { direction: 'u' | 'd' };\n\nconst noteheadsXPivot = (xs: number[], direction: 'u' | 'd' | null): number => {\n\tswitch (xs.length) {\n\t\tcase 0:\n\t\t\treturn undefined;\n\n\t\tcase 1:\n\t\t\treturn xs[0];\n\n\t\tcase 2:\n\t\t\treturn direction === 'u' ? Math.min(...xs) : Math.max(...xs);\n\n\t\tdefault: {\n\t\t\tconst mean = xs.reduce((sum, x) => sum + x, 0) / xs.length;\n\t\t\txs.sort((x1, x2) => Math.abs(x1 - mean) - Math.abs(x2 - mean));\n\n\t\t\treturn noteheadsXPivot(xs.slice(0, xs.length - 1), direction);\n\t\t}\n\t}\n};\n\nconst noteheadsPivot = (nhs: Token[]): number =>\n\tnoteheadsXPivot(\n\t\tnhs.map((nh) => (Number.isFinite(nh.pivotX) ? nh.pivotX : nh.x)),\n\t\tnhs[0].direction\n\t);\n\nclass Measure extends SimpleClass {\n\tstatic className = 'Measure';\n\tstatic blackKeys = ['tokens', 'antiTokens'];\n\n\tleft: number;\n\twidth: number;\n\theight: number;\n\n\talternative: boolean;\n\n\ttokens: Token[];\n\tantiTokens: Token[];\n\n\tbarTypes: Record;\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.tokens = this.tokens || [];\n\t\tthis.antiTokens = this.antiTokens || [];\n\t\tthis.barTypes = this.barTypes || {};\n\t}\n\n\tget right(): number {\n\t\treturn this.left + this.width;\n\t}\n\n\tget noteheads(): Token[] {\n\t\treturn this.tokens.filter((t) => t.isNotehead).sort((n1, n2) => n1.x - n2.x);\n\t}\n\n\tget chordRects(): ChordRect[] {\n\t\tconst noteheads = this.noteheads.filter((nh) =>\n\t\t\t[TokenType.NoteheadS0, TokenType.NoteheadS1stemU, TokenType.NoteheadS2stemU, TokenType.NoteheadS1stemD, TokenType.NoteheadS2stemD].includes(nh.type)\n\t\t);\n\n\t\tlet nulN = 0;\n\n\t\tconst nhmap: Record = noteheads.reduce((map, nh) => {\n\t\t\tconst tip = nh.tip ? `${nh.tip.x}|${nh.tip.y}` : `nul${nulN}`;\n\t\t\tlet key = `${nh.type}|${tip}`;\n\n\t\t\tif (!nh.tip && map[key]) {\n\t\t\t\tif (!map[key].some((hh) => Math.abs(hh.x - nh.x) < NOTEHEAD_WIDTHS.NoteheadS0)) {\n\t\t\t\t\t++nulN;\n\t\t\t\t\tkey = `${nh.type}|nul${nulN}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmap[key] = map[key] || [];\n\t\t\tmap[key].push(nh);\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(nhmap).map((nhs) => {\n\t\t\tconst left = Math.min(...nhs.map((nh) => nh.x));\n\t\t\tconst right = Math.max(...nhs.map((nh) => nh.x));\n\t\t\tconst top = Math.min(...nhs.map((nh) => nh.y));\n\t\t\tconst bottom = Math.max(...nhs.map((nh) => nh.y));\n\n\t\t\tconst nh0 = nhs[0];\n\n\t\t\tconst stemX = nh0 && nh0.tip ? nh0.tip.x : left;\n\n\t\t\tlet x = left;\n\t\t\tlet width = right - left;\n\t\t\tlet stemDirection = null;\n\n\t\t\tswitch (nh0.type) {\n\t\t\t\tcase TokenType.NoteheadS0:\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS0 / 2;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemU:\n\t\t\t\tcase TokenType.NoteheadS2stemU:\n\t\t\t\t\tstemDirection = 'u';\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS1;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemD:\n\t\t\t\tcase TokenType.NoteheadS2stemD:\n\t\t\t\t\tstemDirection = 'd';\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tx,\n\t\t\t\twidth,\n\t\t\t\tstemX,\n\t\t\t\tstemDirection,\n\t\t\t\ttop,\n\t\t\t\tbottom,\n\t\t\t\ttip: nh0.tip,\n\t\t\t};\n\t\t});\n\t}\n\n\tget timeWarped(): boolean {\n\t\treturn this.tokens && this.tokens.some((token) => token.timeWarped);\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\tconst chords = this.getChords();\n\t\tconst up = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y <= -3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.ceil(Math.min(...chord.ys)) + 2,\n\t\t\t}));\n\t\tconst down = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y >= 3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.floor(Math.max(...chord.ys)) - 2,\n\t\t\t}));\n\n\t\treturn [...up, ...down].map((stack) => ({\n\t\t\tleft: stack.left - 0.28,\n\t\t\tright: stack.right + 0.28,\n\t\t\tn: stack.n,\n\t\t}));\n\t}\n\n\tgetChords(): ChordColumn[] {\n\t\tconst flags = this.tokens.filter((t) => TokenFlags.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\t\tconst beams = this.tokens.filter((t) => TokenBeams.includes(t.type));\n\n\t\tconst chordRcs = this.chordRects\n\t\t\t.map((rect) => {\n\t\t\t\tconst noteheads = this.noteheads.filter(\n\t\t\t\t\t(nh) =>\n\t\t\t\t\t\tnh.direction === rect.stemDirection &&\n\t\t\t\t\t\tnh.left >= rect.x &&\n\t\t\t\t\t\tnh.right <= rect.x + rect.width + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tnh.y >= rect.top &&\n\t\t\t\t\t\tnh.y <= rect.bottom\n\t\t\t\t);\n\t\t\t\tnoteheads.sort((n1, n2) => n2.y - n1.y);\n\t\t\t\tconst ys = noteheads.map((nh) => nh.y);\n\t\t\t\tconst noteIds = noteheads.map((nh) => nh.id);\n\n\t\t\t\tconst division = noteheads.reduce((d, nh) => Math.max(d, nh.division), 0);\n\n\t\t\t\treturn {\n\t\t\t\t\trect,\n\t\t\t\t\tleft: rect.x,\n\t\t\t\t\tright: rect.x + rect.width,\n\t\t\t\t\tpivotX: noteheadsPivot(noteheads),\n\t\t\t\t\tys,\n\t\t\t\t\ttip: rect.tip,\n\t\t\t\t\tnoteIds,\n\t\t\t\t\tdivision,\n\t\t\t\t\tdots: null,\n\t\t\t\t\trest: false,\n\t\t\t\t\tstemDirection: rect.stemDirection,\n\t\t\t\t\tbeam: null,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((c1, c2) => c2.left - c1.left);\n\n\t\tconst accs = new Set();\n\n\t\tconst chords = chordRcs.map(({ rect, ...chord }) => {\n\t\t\tif (chord.division >= 1) {\n\t\t\t\t// NOTE: notehead-s1 may have flags too\n\t\t\t\tconst flagRange = [rect.bottom, rect.top];\n\t\t\t\tswitch (rect.stemDirection) {\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t\tflagRange[0] = rect.tip ? rect.tip.y - 0.2 : rect.top - STEM_LENGTH_MAX - 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'd':\n\t\t\t\t\t\tflagRange[1] = rect.tip ? rect.tip.y + 0.2 : rect.bottom + STEM_LENGTH_MAX + 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst nearbyFlags = flags.filter(\n\t\t\t\t\t(flag) =>\n\t\t\t\t\t\t!accs.has(flag.id) &&\n\t\t\t\t\t\tflag.x > rect.stemX - CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.x < rect.stemX + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.y > flagRange[0] &&\n\t\t\t\t\t\tflag.y < flagRange[1]\n\t\t\t\t);\n\t\t\t\tchord.division = nearbyFlags.reduce((d, flag) => Math.max(d, flag.division), chord.division);\n\n\t\t\t\tnearbyFlags.forEach((flag) => accs.add(flag.id));\n\n\t\t\t\tconst beamToken = rect.tip && beams.find((t) => Math.abs(rect.tip.x - t.x) < 0.3 && Math.abs(rect.tip.y - t.y) < 0.7);\n\t\t\t\tif (beamToken) chord.beam = TOKEN_TO_STEMBEAM[beamToken.type];\n\t\t\t}\n\n\t\t\tconst nearbyDots = dots.filter(\n\t\t\t\t(dot) =>\n\t\t\t\t\t!accs.has(dot.id) &&\n\t\t\t\t\tdot.x > rect.x + rect.width - 0.2 &&\n\t\t\t\t\tdot.x < rect.x + rect.width + 1.2 &&\n\t\t\t\t\tdot.y > rect.top - 1 &&\n\t\t\t\t\tdot.y <= rect.bottom + 0.5\n\t\t\t);\n\t\t\tchord.dots = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\tnearbyDots.forEach((dot) => accs.add(dot.id));\n\n\t\t\treturn chord;\n\t\t});\n\n\t\tchords.reverse();\n\n\t\treturn chords;\n\t}\n\n\tgetRests(): ChordColumn[] {\n\t\tconst rests = this.tokens.filter((t) => TokenRests.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\n\t\treturn rests.map((rest) => {\n\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > rest.x + 0.5 && dot.x < rest.x + 2 && dot.y > rest.y - 1 && dot.y < rest.y + 0.5);\n\t\t\tconst dotValue = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\treturn {\n\t\t\t\tleft: rest.x - 0.75,\n\t\t\t\tright: rest.x + 0.75,\n\t\t\t\tpivotX: rest.x,\n\t\t\t\trest: true,\n\t\t\t\tys: [rest.y],\n\t\t\t\tnoteIds: [rest.id],\n\t\t\t\tdots: dotValue,\n\t\t\t\tdivision: rest.division,\n\t\t\t\tstemDirection: null,\n\t\t\t};\n\t\t});\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\treturn [...this.getChords(), ...this.getRests()].sort((e1, e2) => e1.left - e2.left);\n\t}\n\n\tgetContexts(fields = {}): ContextedTerm[] {\n\t\treturn this.tokens\n\t\t\t.filter((t) => t.isContexted)\n\t\t\t.sort((n1, n2) => n1.x - n2.x)\n\t\t\t.map(\n\t\t\t\t(token) =>\n\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\ttokenType: token.type,\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t})\n\t\t\t);\n\t}\n\n\tassignAccessoriesOnEvents(events: ChordColumn[]): void {\n\t\tevents.forEach((event) => (event.accessories = event.accessories || []));\n\n\t\tconst accessories = this.tokens.filter((token) => TokenAccessories.includes(token.type));\n\t\t//console.log(\"accessories:\", accessories);\n\t\taccessories.forEach((accessory) => {\n\t\t\tconst relatedEvents = events.filter((event) => accessory.x > event.left - 1 && accessory.x < event.right + 1);\n\n\t\t\tif (relatedEvents.length > 0) {\n\t\t\t\tlet owner = relatedEvents[0];\n\t\t\t\tif (relatedEvents.length > 1) {\n\t\t\t\t\towner = relatedEvents\n\t\t\t\t\t\t.map((event) => ({ event, d: Math.min(...event.ys.map((y) => Math.abs(y - accessory.y))) }))\n\t\t\t\t\t\t.sort(({ d: d1 }, { d: d2 }) => d1 - d2)\n\t\t\t\t\t\t.map(({ event }) => event)[0];\n\t\t\t\t}\n\t\t\t\t//console.log(\"relatedEvents:\", accessory, owner);\n\n\t\t\t\tlet direction = accessory.y > Math.max(...owner.ys) ? AccessoryDirection.Down : AccessoryDirection.Up;\n\t\t\t\tif (TokenDirectionless.includes(accessory.type)) direction = null;\n\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: accessory.type,\n\t\t\t\t\tid: accessory.id,\n\t\t\t\t\tdirection,\n\t\t\t\t\tx: accessory.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone accessory:\", accessory.type);\n\t\t});\n\n\t\t// arpeggio\n\t\tconst sortEvents = [...events];\n\t\tsortEvents.sort((e1, e2) => e1.left - e2.left);\n\n\t\tconst arpeggios = this.tokens.filter((token) => token.type === TokenType.ScriptArpeggio);\n\t\tarpeggios.forEach((arpeggio) => {\n\t\t\tconst owner = sortEvents.find(\n\t\t\t\t(event) => arpeggio.x < event.left && event.ys.some((y) => y < arpeggio.y + 0.25) && event.ys.some((y) => y > arpeggio.y)\n\t\t\t);\n\t\t\t//const owner = sortEvents.find(event => event.left - leftMost.left < 2 && event.ys.some(y => Math.abs(y - arpeggio.y + 0.25) < 0.5));\n\t\t\tif (owner) {\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: TokenType.ScriptArpeggio,\n\t\t\t\t\tid: arpeggio.id,\n\t\t\t\t\tx: arpeggio.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone arpeggio:\", arpeggio);\n\t\t});\n\n\t\t// grace noteheads\n\t\tconst graceNhs = this.tokens.filter((token) => token.type === TokenType.GraceNotehead);\n\t\tgraceNhs.forEach((grace) => {\n\t\t\tconst event = events.find((event) => grace.x > event.left && grace.x < event.right && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tif (event) event.grace = GraceType.Grace;\n\t\t});\n\n\t\t// tremolos\n\t\tconst tremolsLs = this.tokens.filter((token) => token.type === TokenType.TremoloLeft);\n\t\tconst tremolsRs = this.tokens.filter((token) => token.type === TokenType.TremoloRight);\n\t\tconst tremolsMs = this.tokens.filter((token) => token.type === TokenType.TremoloMiddle);\n\n\t\tconst tevents = events\n\t\t\t.filter((event) => !event.rest)\n\t\t\t.map((event) => {\n\t\t\t\tconst ys = [...event.ys];\n\t\t\t\tif (event.tip) ys.push(event.tip.y);\n\t\t\t\telse {\n\t\t\t\t\tys.push(event.ys[0] + 2);\n\t\t\t\t\tys.push(event.ys[event.ys.length - 1] - 2);\n\t\t\t\t}\n\n\t\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\t\t\t\tconst stemR = event.tip ? event.tip.x : event.right;\n\n\t\t\t\treturn {\n\t\t\t\t\tevent,\n\t\t\t\t\ttop: Math.min(...ys),\n\t\t\t\t\tbottom: Math.max(...ys),\n\t\t\t\t\tstemL,\n\t\t\t\t\tstemR,\n\t\t\t\t};\n\t\t\t});\n\n\t\ttremolsMs.forEach((tm) => {\n\t\t\tconst te = tevents.find((te) => {\n\t\t\t\tif (te.event.tip) return tm.y > te.top && tm.y < te.bottom && Math.abs(tm.x - te.event.tip.x) < 0.3;\n\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t}\n\t\t});\n\t\ttremolsLs.forEach((tl) => {\n\t\t\tconst te = tevents.find((te) => tl.y > te.top && tl.y < te.bottom && tl.x > te.stemR && tl.x < te.stemR + 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Pitcher;\n\t\t\t}\n\t\t});\n\t\ttremolsRs.forEach((tr) => {\n\t\t\tconst te = tevents.find((te) => tr.y > te.top && tr.y < te.bottom && tr.x < te.stemL && tr.x > te.stemL - 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Catcher;\n\t\t\t}\n\t\t});\n\t}\n\n\tassignFeaturesOnEvents(events: ChordColumn[], semantics: SemanticPoint[]): void {\n\t\tconst points = semantics.filter((point) => point.x > this.left && point.x < this.right);\n\t\tconst rests = points.filter((point) => REST_SEMANTICS.includes(point.semantic));\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tconst dotPs = points.filter((point) => point.semantic === SemanticType.Dot);\n\t\tconst beamLs = points.filter((points) => points.semantic === SemanticType.BeamLeft);\n\t\tconst beamMs = points.filter((points) => points.semantic === SemanticType.BeamContinue);\n\t\tconst beamRs = points.filter((points) => points.semantic === SemanticType.BeamRight);\n\t\tconst gracePs = points.filter((point) => point.semantic === SemanticType.GraceNotehead);\n\t\tconst tremoloRs = points.filter((point) => point.semantic === SemanticType.TremoloRight);\n\t\tconst stems = points.filter((point) => point.semantic === SemanticType.vline_Stem);\n\t\tconst s0 = points.filter((point) => point.semantic === SemanticType.NoteheadS0);\n\t\tconst s1 = points.filter((point) => point.semantic === SemanticType.NoteheadS1);\n\t\tconst s2 = points.filter((point) => point.semantic === SemanticType.NoteheadS2);\n\n\t\tevents.forEach((event) => {\n\t\t\tconst cx = event.tip ? event.tip.x : (event.left + event.right) / 2;\n\t\t\tconst top = event.tip ? Math.min(event.tip.y, event.ys[event.ys.length - 1]) : event.ys[event.ys.length - 1];\n\t\t\tconst bottom = event.tip ? Math.max(event.tip.y, event.ys[0]) : event.ys[0];\n\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\n\t\t\tconst divisions = [0, 0, 0, 0, 0, 0, 0];\n\t\t\tif (event.rest) {\n\t\t\t\tconst i_rests = rests.filter((point) => distance2D(point, { x: cx, y: event.ys[0] }) < 0.5);\n\t\t\t\ti_rests.forEach((r) => {\n\t\t\t\t\tconst d = REST_SEMANTICS.indexOf(r.semantic);\n\t\t\t\t\tdivisions[d] = Math.max(divisions[d], r.confidence);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst nhs = [s0, s1, s2]\n\t\t\t\t\t.map((ss) => ss.filter((nh) => nh.x > event.left && nh.x < event.right && nh.y > top - 0.25 && nh.y < bottom + 0.25))\n\t\t\t\t\t.map((ss) => Math.max(0, ...ss.map((nh) => nh.confidence)));\n\n\t\t\t\tconst i_flags = flags.filter((flag) => flag.y > top - 0.2 && flag.y < bottom + 0.2 && Math.abs(flag.x - cx) < 0.2);\n\t\t\t\ti_flags.sort((f1, f2) => f2.confidence - f1.confidence);\n\n\t\t\t\tdivisions[0] = nhs[0];\n\t\t\t\tdivisions[1] = nhs[1];\n\t\t\t\tdivisions[2] = nhs[2];\n\t\t\t\tArray(divisions.length - 3)\n\t\t\t\t\t.fill(0)\n\t\t\t\t\t.forEach((_, i) => (divisions[3 + i] = i_flags[i] ? i_flags[i].confidence : 0));\n\t\t\t}\n\n\t\t\tconst i_dots = dotPs.filter((dot) => dot.x > cx && dot.x < event.right + 2.6);\n\t\t\tconst dots2 = i_dots.filter((dot) => i_dots.some((d) => dot.x > d.x && Math.abs(dot.y - d.y) < 0.2));\n\t\t\tconst dots = [Math.max(0, ...i_dots.map((dot) => dot.confidence)), Math.max(0, ...dots2.map((dot) => dot.confidence))];\n\n\t\t\tconst beams = [beamLs, beamMs, beamRs]\n\t\t\t\t.map((bs) => bs.filter((b) => Math.abs(b.x - cx) < 0.2 && b.y > top - 0.2 && b.y < bottom + 0.2))\n\t\t\t\t.map((bs) => Math.max(0, ...bs.map((b) => b.confidence)));\n\n\t\t\tconst u_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[0] }, { x: stem.x, y: stem.extension.y2 }) < 0.5);\n\t\t\tconst d_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[event.ys.length - 1] }, { x: stem.x, y: stem.extension.y1 }) < 0.5);\n\t\t\tconst stemDirections = [Math.max(0, ...u_stems.map((stem) => stem.confidence)), Math.max(0, ...d_stems.map((stem) => stem.confidence))];\n\n\t\t\tconst graces = gracePs.filter((grace) => Math.abs(grace.x - cx) < 0.6 && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tconst grace = Math.max(0, ...graces.map((grace) => grace.confidence));\n\n\t\t\tconst tremolos =\n\t\t\t\tevent.division === 0\n\t\t\t\t\t? tremoloRs.filter((tremolo) => tremolo.x > event.left - 2 && tremolo.x < event.right)\n\t\t\t\t\t: tremoloRs.filter((tremolo) => tremolo.y > top - 0.04 && tremolo.y < bottom + 0.04 && tremolo.x > stemL - 2 && tremolo.x < stemL);\n\t\t\tconst tremoloCatcher = Math.max(0, ...tremolos.map((tremolo) => tremolo.confidence));\n\n\t\t\tevent.feature = {\n\t\t\t\tdivisions,\n\t\t\t\tdots,\n\t\t\t\tbeams,\n\t\t\t\tstemDirections,\n\t\t\t\tgrace,\n\t\t\t\ttremoloCatcher,\n\t\t\t} as EventFeature;\n\t\t});\n\t}\n}\n\nclass Staff extends SimpleClass {\n\tstatic className = 'Staff';\n\tstatic blackKeys = ['index', 'semanticTop', 'semanticBttom'];\n\n\tindex?: number; // staff index in full staff layout\n\n\t// in units\n\ttop: number;\n\theight: number;\n\tstaffY: number;\n\n\tsemanticTop: number;\n\tsemanticBottom: number;\n\n\tbackgroundImage: string | Buffer;\n\tmaskImage: string | Buffer;\n\timagePosition: Rect;\n\n\tmeasures: Measure[];\n\n\tsemantics: SemanticPoint[];\n\n\tconstructor({ measureCount = null, measureBars = null, ...data }: Record = {}) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.height = this.height || 10;\n\t\tthis.staffY = this.staffY || 5;\n\n\t\tif (measureBars) {\n\t\t\tlet left = 0;\n\t\t\tthis.measures = measureBars.map((endX) => {\n\t\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\t\tleft = endX;\n\n\t\t\t\treturn measure;\n\t\t\t});\n\t\t} else if (measureCount)\n\t\t\tthis.measures = Array(measureCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Measure());\n\t\telse this.measures = [];\n\t}\n\n\t// relative to staffY\n\tget noteRange(): { top: number; bottom: number } {\n\t\tconst noteheads: Token[] = [].concat(...this.measures.map((measure) => measure.noteheads));\n\t\tconst ys = noteheads.map((note) => note.y);\n\t\tconst top = Math.min(-2, ...ys);\n\t\tconst bottom = Math.max(2, ...ys);\n\n\t\treturn { top, bottom };\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\treturn [].concat(...this.measures.map((measure) => measure.additionalLines));\n\t}\n\n\trearrangeMeasures(measureBars: number[]): void {\n\t\tif (!measureBars.length) {\n\t\t\tconsole.warn('rearrangeMeasures error, measureBars are empty.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst tokens = this.measures?.map((measure) => measure.tokens).flat(1) || [];\n\n\t\tlet left = 0;\n\t\tthis.measures = measureBars.map((endX) => {\n\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\tleft = endX;\n\n\t\t\treturn measure;\n\t\t});\n\n\t\tthis.reassignTokens(tokens);\n\t}\n\n\treassignTokens(tokens: Token[] = null): void {\n\t\tif (!tokens) tokens = [].concat(...this.measures.map((measure) => measure.tokens));\n\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\n\t\ttokens.forEach((token) => {\n\t\t\tfor (const measure of this.measures) {\n\t\t\t\tif (token.x < measure.right) {\n\t\t\t\t\tmeasure.tokens.push(token);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tassignSemantics(graph: SemanticGraph): void {\n\t\tthis.semantics = graph.getStaffPoints();\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, system: System, logger: Logger = new DummyLogger()): void {\n\t\tif (!this.semantics) return;\n\n\t\tlet points = system.qualifiedSemantics(this.semantics, threshold);\n\t\tpoints = solveOverlapping(points);\n\n\t\t// tempo noteheads\n\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t//console.log(\"temponh:\", tempoNh, index, points[index]);\n\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t// TODO: construct tempo term\n\t\t});\n\n\t\tconst antiP = (id: string): SemanticPoint | null => {\n\t\t\tif (system.displacementSemantics?.[id]) return this.semantics.find((p) => p.id === id);\n\n\t\t\treturn null;\n\t\t};\n\n\t\tpoints.filter((point) => MEASURE_SEMANTICS.includes(point.semantic)).forEach((point) => this.appendPoint(point, { points }));\n\n\t\t// noteheads with stem from noteheads & stems\n\t\tconst stems: Stem[] = points\n\t\t\t.filter((point) => point.semantic === SemanticType.vline_Stem)\n\t\t\t.filter((stem) => stem.extension.y2 - stem.extension.y1 > 1.5) // exclude too short stems\n\t\t\t.map((p) => ({\n\t\t\t\tx: p.x,\n\t\t\t\ty1: p.extension.y1,\n\t\t\t\ty2: p.extension.y2,\n\t\t\t\tdirection: null,\n\t\t\t}));\n\t\tconst noteheads = points.filter(\n\t\t\t(point) => NOTEHEAD_FOR_STEM_SEMANTICS.includes(point.semantic) && point.y > this.semanticTop && point.y < this.semanticBottom\n\t\t);\n\t\tconst rootNhs = new Set();\n\n\t\t// for 2nd degree chord notes\n\t\tconst nhOffsetX = (nh: SemanticPoint, stem: Stem, down: boolean): number => {\n\t\t\tif ((down ? 1 : 0) ^ (nh.x < stem.x ? 1 : 0)) return 0;\n\n\t\t\tconst offset = NOTEHEAD_WIDTHS[nh.semantic];\n\n\t\t\treturn down ? -offset : offset;\n\t\t};\n\n\t\t// find root noteheads on stem\n\t\tstems.forEach((stem) => {\n\t\t\tconst attachedHeads = noteheads.filter(\n\t\t\t\t(nh) =>\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 < 0.28 &&\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 > -0.44 && // for grace noteheads, more close to their stem\n\t\t\t\t\tnh.y > stem.y1 - 0.5 &&\n\t\t\t\t\tnh.y < stem.y2 + 0.5 &&\n\t\t\t\t\t!(nh.x > stem.x && nh.y > stem.y2) &&\n\t\t\t\t\t!(nh.x < stem.x && nh.y < stem.y1)\n\t\t\t);\n\t\t\t//if (stem.x===102.0625 && stem.y2===1.875)\n\t\t\t//\tdebugger;\n\t\t\tif (attachedHeads.length) {\n\t\t\t\tattachedHeads.sort((n1, n2) => n1.y - n2.y);\n\n\t\t\t\tconst topDist = Math.min(...attachedHeads.map((nh) => nh.y - stem.y1));\n\t\t\t\tconst bottomDist = Math.min(...attachedHeads.map((nh) => stem.y2 - nh.y));\n\t\t\t\tif (Math.min(topDist, bottomDist) > 0.5) return; // no root notehead on this stem\n\n\t\t\t\tconst down = topDist < bottomDist;\n\t\t\t\tstem.direction = down ? 'd' : 'u';\n\n\t\t\t\tif (!down) attachedHeads.reverse();\n\t\t\t\tconst root = attachedHeads[0];\n\n\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[root.semantic].down : NOTEHEAD_TABLE[root.semantic].up;\n\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: root.id,\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx: stem.x + nhOffsetX(root, stem, down),\n\t\t\t\t\t\ty: root.y,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tconfidence: root.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\tantiPoint: antiP(root.id),\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\trootNhs.add(root.id);\n\t\t\t}\n\t\t});\n\n\t\t// non-root noteheads\n\t\tnoteheads\n\t\t\t.filter((nh) => !rootNhs.has(nh.id))\n\t\t\t.forEach((nh) => {\n\t\t\t\tconst nearStems = stems\n\t\t\t\t\t.filter((stem) => Math.abs(stem.x - nh.x) < 2 && nh.y > stem.y1 && nh.y < stem.y2)\n\t\t\t\t\t.sort((s1, s2) => Math.abs(s1.x - nh.x) - Math.abs(s2.x - nh.x));\n\t\t\t\tconst stem = nearStems[0];\n\t\t\t\tif (stem) {\n\t\t\t\t\tconst down = stem.direction === 'd';\n\t\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[nh.semantic].down : NOTEHEAD_TABLE[nh.semantic].up;\n\n\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: nh.id,\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x + nhOffsetX(nh, stem, down),\n\t\t\t\t\t\t\ty: nh.y,\n\t\t\t\t\t\t\tpivotX: nh.x,\n\t\t\t\t\t\t\tconfidence: nh.confidence,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\t\tantiPoint: antiP(nh.id),\n\t\t\t\t\t\t\tpoints,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else logger.debug('isolated notehead:', system.index, this.index, nh);\n\t\t\t});\n\n\t\t// group flags\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tflags.sort((f1, f2) => f1.x - f2.x);\n\t\tthis.appendFlags(flags, stems);\n\n\t\t// group dots\n\t\tconst dots = points\n\t\t\t.filter((point) => point.semantic === SemanticType.Dot)\n\t\t\t.map((dot) => {\n\t\t\t\tconst y = roundNumber(dot.y, 0.5);\n\t\t\t\treturn { x: dot.x, y };\n\t\t\t});\n\t\tconst dotLines: { [key: number]: SemanticPoint[] } = dots.reduce((table, dot) => {\n\t\t\ttable[dot.y] = table[dot.y] || [];\n\t\t\ttable[dot.y].push(dot);\n\t\t\treturn table;\n\t\t}, {});\n\t\tObject.entries(dotLines).forEach(([sy, line]) => {\n\t\t\tconst y = Number(sy);\n\t\t\tif (line.length > 1) {\n\t\t\t\tline.sort((d1, d2) => d1.x - d2.x);\n\t\t\t\tfor (let i = 0; i < line.length - 1; i++) {\n\t\t\t\t\tconst dot = line[i];\n\t\t\t\t\tif (line.find((d) => d.x > dot.x && d.x - dot.x < 1.2)) {\n\t\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: dot.id,\n\t\t\t\t\t\t\t\tx: dot.x,\n\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\tconfidence: dot.confidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: TokenType.DotDot, antiPoint: antiP(dot.id), points }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// pair key accidentals\n\t\tconst keyaccs = points.filter((point) => point.semantic === SemanticType.KeyAcc);\n\t\tconst accs = points.filter((point) => KEYACC_CANDIDATE_SEMANTICS[point.semantic]);\n\t\taccs.forEach((acc) => {\n\t\t\tif (keyaccs.some((key) => Math.abs(acc.x - key.x) < 0.5 && Math.abs(acc.y - key.y) < 1)) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: acc.id,\n\t\t\t\t\t\tx: acc.x,\n\t\t\t\t\t\ty: acc.y,\n\t\t\t\t\t\tconfidence: acc.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{ type: KEYACC_CANDIDATE_SEMANTICS[acc.semantic], points }\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// octave shift heads\n\t\tconst octs = points.filter((point) => point.semantic === SemanticType.OctaveShift8);\n\t\tocts.forEach((oct) => {\n\t\t\tconst type = oct.y < 0 ? TokenType.OctaveShift8va : TokenType.OctaveShift8vb;\n\t\t\tthis.appendPoint(\n\t\t\t\t{\n\t\t\t\t\tid: oct.id,\n\t\t\t\t\tx: oct.x,\n\t\t\t\t\ty: oct.y,\n\t\t\t\t\tconfidence: oct.confidence,\n\t\t\t\t},\n\t\t\t\t{ type, points }\n\t\t\t);\n\t\t});\n\n\t\t// group volta dots\n\t\tconst voltaDots = this.semantics.filter((point) => [SemanticType.VoltaLeft, SemanticType.VoltaRight].includes(point.semantic));\n\t\tvoltaDots.sort((d1, d2) => d1.x - d2.x);\n\t\tconst voltaGroups: Record> = voltaDots.reduce(\n\t\t\t(groups, dot) => {\n\t\t\t\tconst group = groups[dot.semantic];\n\t\t\t\tconst xs = Array.from(Object.keys(group)).map(Number);\n\t\t\t\tconst x = xs.find((x) => dot.x < x + 0.2) || dot.x;\n\n\t\t\t\tgroup[x] = groups[dot.semantic][x] || [];\n\t\t\t\tgroup[x].push(dot);\n\n\t\t\t\treturn groups;\n\t\t\t},\n\t\t\t{ [SemanticType.VoltaLeft]: {}, [SemanticType.VoltaRight]: {} }\n\t\t);\n\t\tfor (const [type, group] of Object.entries(voltaGroups)) {\n\t\t\tObject.values(group).forEach((dots) => {\n\t\t\t\tif (dots.length > 1) {\n\t\t\t\t\tconst confidence = dots.reduce((sum, dot) => sum + dot.confidence, 0);\n\t\t\t\t\tif (dots[0].y * dots[1].y < 0 && confidence >= threshold * 2) this.appendPoint(dots[0], { type: TokenType[type] });\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tappendPoint(\n\t\tpoint: Partial,\n\t\t{ type, points = null, antiPoint, ...fields }: { type?: TokenType; antiPoint?: SemanticPoint; [key: string]: any } = {}\n\t): void {\n\t\t//console.log(\"appendPoint.0:\", point, point.x, point.y);\n\t\tconst x = point.x;\n\t\tconst measure = this.measures.find((measure) => x < measure.left + measure.width);\n\t\tif (!measure)\n\t\t\t// drop tokens out of measures range\n\t\t\treturn;\n\n\t\t// lined or interval\n\t\tlet lined = false;\n\t\tlet interval = false;\n\t\tif (STAFF_LINED_SEMANTICS.includes(point.semantic)) {\n\t\t\tconsole.assert(points, 'argument of points for this semantic is required:', point.semantic);\n\t\t\tconst signs = points.filter((p) => LINED_INTERVAL_SEMANTICS.includes(p.semantic) && Math.abs(p.y - point.y) < 0.2 && Math.abs(p.x - point.x) < 1.2);\n\t\t\tif (signs.some((s) => s.semantic === SemanticType.SignLined)) lined = true;\n\t\t\telse if (signs.some((s) => s.semantic === SemanticType.SignInterval)) interval = true;\n\t\t}\n\n\t\ttype = type || TokenType[point.semantic];\n\t\tconst fixedY = TOKEN_Y_FIXED[type];\n\t\tlet roundY = TOKEN_Y_ROUND[type];\n\n\t\tif (lined || interval) roundY = Math.max(roundY, 1);\n\n\t\tlet y = point.y;\n\t\tif (Number.isFinite(fixedY)) y = fixedY;\n\t\telse if (roundY) {\n\t\t\tif (interval) y = roundNumber(y + 0.5, roundY) - 0.5;\n\t\t\telse y = roundNumber(y, roundY);\n\t\t}\n\t\t//if (lined || interval)\n\t\t//\tconsole.log(\"round sign:\", point.semantic, y, lined, interval);\n\n\t\tconst holder = measure.tokens.find((token) => token.type === type && Math.abs(token.x - x) < 0.1 && Math.abs(token.y - y) < 0.1);\n\t\tif (holder) {\n\t\t\tif (Number.isFinite(holder.confidence) && holder.confidence < point.confidence) {\n\t\t\t\tholder.x = x;\n\t\t\t\tholder.y = y;\n\t\t\t\tholder.confidence = point.confidence;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// exlude clef out of pitch range\n\t\tif (TokenClefs.includes(type)) {\n\t\t\tif (Math.abs(y) > 3) return;\n\t\t}\n\n\t\t// TODO: exclude overlapped pair by a token prior table\n\n\t\tmeasure.tokens.push(\n\t\t\tnew Token({\n\t\t\t\tid: point.id,\n\t\t\t\ttype,\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tpivotX: point.pivotX,\n\t\t\t\tconfidence: point.confidence,\n\t\t\t\t...fields,\n\t\t\t})\n\t\t);\n\n\t\tif (antiPoint) {\n\t\t\tmeasure.antiTokens.push(\n\t\t\t\tnew Token({\n\t\t\t\t\tid: antiPoint.id,\n\t\t\t\t\ttype,\n\t\t\t\t\tx,\n\t\t\t\t\ty: antiPoint.y,\n\t\t\t\t\tconfidence: antiPoint.confidence,\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tappendFlags(flags: SemanticPoint[], stems: Stem[]): void {\n\t\t//console.log(\"flags:\", flags);\n\t\tconst stemGroups = stems\n\t\t\t.map((stem) => ({\n\t\t\t\t...stem,\n\t\t\t\tflags: flags.filter((flag) => Math.abs(flag.x - stem.x) < 0.3 && flag.y > stem.y1 - 0.5 && flag.y < stem.y2 + 0.5),\n\t\t\t}))\n\t\t\t.filter((group) => group.flags.length);\n\n\t\tstemGroups.forEach((group) => {\n\t\t\tconst mainFlag = group.flags.reduce((main, flag) => (main && main.confidence > flag.confidence ? main : flag), null);\n\n\t\t\t//const upDistance = mainFlag.y - group.y1;\n\t\t\t//const downDistance = group.y2 - mainFlag.y;\n\t\t\t//const downward = downDistance < upDistance;\n\t\t\tconst downward = group.direction === 'd';\n\n\t\t\tconst tailY = downward ? Math.min(group.y2, group.y1 + STEM_LENGTH_MAX) : Math.max(group.y1, group.y2 - STEM_LENGTH_MAX);\n\n\t\t\tconst flagTips = group.flags.map((flag) => ({\n\t\t\t\ttip: (tailY - flag.y) * (downward ? 1 : -1),\n\t\t\t\tconfidence: flag.confidence,\n\t\t\t}));\n\t\t\tconst count = flagTips.filter((f) => f.tip < 2 || f.confidence > mainFlag.confidence * 0.7).length;\n\n\t\t\tconst type = TokenFlags[count - 1];\n\t\t\tif (type) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: group.flags[0].id,\n\t\t\t\t\t\tx: group.x,\n\t\t\t\t\t\ty: tailY,\n\t\t\t\t\t\tconfidence: Math.min(...group.flags.map((flag) => flag.confidence)),\n\t\t\t\t\t},\n\t\t\t\t\t{ type }\n\t\t\t\t);\n\t\t\t\t//console.log(\"flag:\", type);\n\t\t\t}\n\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\t\tthis.semantics = [];\n\t}\n\n\tclearPredictedTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = measure.tokens.filter((token) => !token.isPredicted)));\n\t}\n}\n\nclass System extends SimpleClass {\n\tstatic className = 'System';\n\tstatic blackKeys = ['index', 'pageIndex', 'prev', 'next', 'headMeasureIndex', 'tokens', 'indent'];\n\n\tindex?: number;\n\tpageIndex?: number;\n\tprev?: System;\n\tnext?: System;\n\theadMeasureIndex?: number; // zero based\n\n\t// in units\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\tindent: boolean;\n\n\tmeasureCount: number;\n\tstaves: Staff[];\n\n\tmeasureBars: number[];\n\n\tbackgroundImage: string;\n\timagePosition: Rect;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tsidBlackList: string[];\n\tsidWhiteList: string[];\n\n\tdisplacementSemantics?: { [id: string]: Partial };\n\n\tstaffMaskChanged: number;\n\tbracketsAppearance: string; // the staff layout code by prediction\n\n\tconstructor({ stavesCount, ...fields }: any) {\n\t\tsuper();\n\t\tsuper.assign(fields);\n\n\t\tif (!this.measureBars) {\n\t\t\tconst HEAD_WIDTH = 5;\n\t\t\tconst segmentLength = (this.width - HEAD_WIDTH) / this.measureCount;\n\t\t\tthis.measureBars = Array(this.measureCount)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => HEAD_WIDTH + segmentLength * (i + 1));\n\t\t}\n\n\t\tif (!fields.staves && stavesCount)\n\t\t\tthis.staves = Array(stavesCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Staff({ measureBars: this.measureBars }));\n\n\t\tthis.arrangePosition();\n\n\t\tthis.measureCount = this.measureCount || this.measureBars.length;\n\n\t\tthis.sidBlackList = this.sidBlackList || [];\n\t\tthis.sidWhiteList = this.sidWhiteList || [];\n\t}\n\n\tget noteRange(): { top: number; bottom: number } {\n\t\tif (!this.staves.length) return null;\n\n\t\tconst staffTop = this.staves[0];\n\t\tconst staffBottom = this.staves[this.staves.length - 1];\n\n\t\treturn {\n\t\t\ttop: staffTop.top + staffTop.staffY + staffTop.noteRange.top,\n\t\t\tbottom: staffBottom.top + staffBottom.staffY + staffBottom.noteRange.bottom,\n\t\t};\n\t}\n\n\tget staffPositions(): StaffPosition[] {\n\t\treturn this.staves.map((staff) => ({\n\t\t\ty: staff.top + staff.staffY,\n\t\t\tradius: 2,\n\t\t}));\n\t}\n\n\tget staffMask(): number {\n\t\tif (this.staffMaskChanged) return this.staffMaskChanged;\n\n\t\tif (this.prev && this.staves.length === this.prev.staves.length) return this.prev.staffMask;\n\n\t\treturn 2 ** this.staves.length - 1;\n\t}\n\n\tget staffTop(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[0].y - positions[0].radius : 0;\n\t}\n\n\tget staffBottom(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[positions.length - 1].y + positions[positions.length - 1].radius : 0;\n\t}\n\n\tarrangePosition(): void {\n\t\tlet y = 0;\n\t\tfor (const staff of this.staves) {\n\t\t\tif (Number.isFinite(staff.top)) break;\n\n\t\t\tstaff.top = y;\n\t\t\ty += staff.height;\n\t\t}\n\t}\n\n\ttidyMeasureBars(): void {\n\t\tthis.measureBars = this.measureBars.filter((x) => x > 1);\n\t\tthis.measureBars.sort((b1, b2) => b1 - b2);\n\n\t\tconst restWidth = this.width - this.measureBars[this.measureBars.length - 1];\n\t\tif (restWidth > 12) this.measureBars.push(this.width);\n\t\telse if (restWidth < 2) this.measureBars[this.measureBars.length - 1] = this.width;\n\n\t\tthis.measureBars = this.measureBars.filter((x, i) => i < 1 || x - this.measureBars[i - 1] > 4);\n\t}\n\n\trearrangeMeasures(): void {\n\t\tthis.measureCount = this.measureBars.length;\n\t\tthis.staves.forEach((staff) => staff.rearrangeMeasures(this.measureBars));\n\t}\n\n\tget height(): number {\n\t\treturn this.staves.reduce((height, staff) => height + staff.height, 0);\n\t}\n\n\tget connectionLine(): { top: number; bottom: number } {\n\t\tconst staffHead = this.staves[0];\n\t\tconst staffTail = this.staves[this.staves.length - 1];\n\n\t\treturn (\n\t\t\tstaffHead && {\n\t\t\t\ttop: staffHead.top + staffHead.staffY - 2,\n\t\t\t\tbottom: staffTail.top + staffTail.staffY + 2,\n\t\t\t}\n\t\t);\n\t}\n\n\tget middleY(): number {\n\t\tif (!this.staves.length) return 0;\n\n\t\tconst sum = this.staves.reduce((sum, staff) => sum + staff.top + staff.staffY, 0);\n\n\t\treturn sum / this.staves.length;\n\t}\n\n\tget timeSignatureOnHead(): boolean {\n\t\treturn this.staves.some((staff) => staff.measures[0]?.tokens.some((token) => TokenTimesigs.includes(token.type)));\n\t}\n\n\t// an array staff or null on every position of full staff layout\n\tgetStaffArray(stavesCount: number): Staff[] {\n\t\tlet si = 0;\n\n\t\treturn Array(stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, i) => {\n\t\t\t\tconst on = this.staffMask & (1 << i);\n\t\t\t\tconst staff = on ? this.staves[si++] : null;\n\t\t\t\tconsole.assert(!on || staff, 'system staves count is less than staff mask declared:', this.staves.length, this.staffMask.toString(2));\n\n\t\t\t\treturn staff;\n\t\t\t});\n\t}\n\n\t// measureIndex: the local measure index\n\tgetMarksInMeasure(measureIndex: number): MarkTerm[] {\n\t\tconsole.assert(measureIndex < this.measureBars.length, 'measure index out of range:', measureIndex, this.measureBars.length);\n\n\t\tconst left = measureIndex > 0 ? this.measureBars[measureIndex - 1] : 0;\n\t\tconst right = this.measureBars[measureIndex];\n\n\t\tconst tempoTokens = (this.tokens ?? []).filter(\n\t\t\t(token) => token.x >= left && token.x < right && token instanceof TextToken && token.textType === TextType.TempoNumeral\n\t\t) as TextToken[];\n\n\t\treturn [...tempoTokens.map((token) => TempoTerm.fromNumeralText(token.text)).filter(Boolean)];\n\t}\n\n\tgetEvents(stavesCount: number): EventSystem {\n\t\tconsole.assert(Number.isInteger(this.headMeasureIndex), 'invalid headMeasureIndex:', this.headMeasureIndex);\n\n\t\t// Empty system (no measureBars / no staves with measures): return empty result\n\t\tif (!this.measureBars?.length && this.staves.every((s) => !s.measures?.length)) {\n\t\t\treturn { staffMask: this.staffMask, columns: [] };\n\t\t}\n\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => {\n\t\t\t\tconst events = measure.getEvents();\n\t\t\t\tmeasure.assignAccessoriesOnEvents(events);\n\t\t\t\tmeasure.assignFeaturesOnEvents(events, staff.semantics);\n\n\t\t\t\treturn {\n\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t\tcontexts: measure.getContexts({ staff: staff.index }),\n\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts?.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (row[mi] && !row[mi].contexts.length && !row[mi].events.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//onst measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: this.getMarksInMeasure(i),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i]?.voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i]?.voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row[i]?.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i]?.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\t\t//columns.forEach(computeMeasureTicks);\n\n\t\t// assign id on column events\n\t\tcolumns.forEach((column) => {\n\t\t\tconst events = [].concat(...column.rows.filter(Boolean).map((row) => row.events));\n\t\t\tevents.forEach((event, i) => (event.id = i + 1));\n\t\t});\n\n\t\tconst lastColumn = columns[columns.length - 1];\n\t\tif (lastColumn) lastColumn.break = true;\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tgetEventsFunctional(stavesCount: number, ev: ChordsFeeder, processors: ColumnProcessor[] = [], { useXMap = false } = {}): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff, si) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure, mi) => {\n\t\t\t\tconst events = ev(si, mi);\n\n\t\t\t\treturn (\n\t\t\t\t\tevents && {\n\t\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontexts: measure.getContexts({ staff: si }),\n\t\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\t// [measure, staff]\n\t\tconst columns: EventMeasureColumn[] = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => {\n\t\t\t\tconst localRows = rows.map((row) => row[mi]);\n\t\t\t\tif (localRows.some((row) => !row)) return null;\n\n\t\t\t\tlet xMap: Map = null;\n\t\t\t\tif (useXMap) {\n\t\t\t\t\tconst events: EventTerm[] = [].concat(...localRows.map((row) => row.events));\n\t\t\t\t\tconst groupMap: { [group: number]: EventTerm[] } = events.reduce((map, event) => {\n\t\t\t\t\t\tif (Number.isFinite(event.tickGroup)) map[event.tickGroup] = map[event.tickGroup] || [];\n\t\t\t\t\t\tmap[event.tickGroup].push(event);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, {});\n\n\t\t\t\t\txMap = Object.values(groupMap).reduce((map, events) => {\n\t\t\t\t\t\tconst x = Math.min(...events.map((event) => (event.left + event.right) / 2));\n\t\t\t\t\t\tmap.set(x, events);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, new Map());\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + mi,\n\t\t\t\t\t//startX: measureStartXs[mi],\n\t\t\t\t\t//width: measureWidths[mi],\n\t\t\t\t\trows: localRows, // [staff]\n\t\t\t\t\tmarks: this.getMarksInMeasure(mi),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\txMap,\n\t\t\t\t\tvoltaBegin: localRows.some((row) => row.voltaBegin),\n\t\t\t\t\tvoltaEnd: localRows.some((row) => row.voltaEnd),\n\t\t\t\t\talternative: localRows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: localRows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\tprocessors.forEach((proc) => columns.forEach(proc));\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\t// get EventSystem contains only contexted terms\n\tgetContexts(stavesCount: number): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: null,\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => ({\n\t\t\t\tevents: null,\n\t\t\t\tcontexts: measure.getContexts(),\n\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t}));\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (!row[mi].contexts.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: [],\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i].voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i].voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i].barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tassignSemantics(staffIndex: number, graph: SemanticGraph): void {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff is null:', staffIndex, this.staves);\n\t\tconst oy = staff.top + staff.staffY;\n\n\t\tgraph.getSystemPoints().forEach((point) => {\n\t\t\tconst p = { ...point };\n\t\t\tp.y += oy;\n\n\t\t\tif (p.extension) {\n\t\t\t\tp.extension = { ...p.extension };\n\t\t\t\tif (Number.isFinite(p.extension.y1)) {\n\t\t\t\t\tp.extension.y1 += oy;\n\t\t\t\t\tp.extension.y2 += oy;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.semantics.push(p);\n\t\t});\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, logger: Logger = new DummyLogger()): void {\n\t\t//console.log(\"System.assignSemantics:\", graph);\n\t\tthis.measureBars = [];\n\n\t\tif (!this.semantics) return;\n\n\t\tconst graph = SemanticGraph.fromPoints(this.semantics);\n\n\t\tconst bars = graph.getConfidentLayer(SemanticType.vline_BarMeasure, threshold);\n\t\tbars.sort((b1, b2) => b1.x - b2.x);\n\n\t\tconst staffTop = this.staffTop;\n\t\tconst staffBottom = this.staffBottom;\n\n\t\tconst MERGE_WINDOW = 0.4;\n\t\tlet lastX = 0;\n\t\tconst barColumns: { [key: number]: number } = bars.reduce((columns, bar) => {\n\t\t\tconst confidence = Number.isFinite(bar.confidence) ? Math.tanh(bar.confidence) : 1;\n\n\t\t\tconst x = bar.x - lastX > MERGE_WINDOW ? bar.x : lastX;\n\t\t\tlastX = bar.x;\n\t\t\tlet intensity = columns[x] || 0;\n\t\t\tintensity += (Math.min(bar.extension.y2, staffBottom) - Math.max(bar.extension.y1, staffTop)) * confidence;\n\n\t\t\tif (bar.x !== x) delete columns[x];\n\t\t\tcolumns[bar.x] = intensity;\n\n\t\t\treturn columns;\n\t\t}, {});\n\t\tconst barXs: number[] = Object.entries(barColumns)\n\t\t\t.filter(([x, intensity]) => (void x, intensity > 3 * this.staves.length))\n\t\t\t.map(([x]) => Number(x));\n\t\tbarXs.sort((x1, x2) => x1 - x2);\n\t\tbarXs.forEach((x, i) => {\n\t\t\tif (i <= 0 || x - barXs[i - 1] > 2) this.measureBars.push(x);\n\t\t});\n\n\t\tif (!this.measureBars.length) this.measureBars.push(this.width);\n\n\t\tthis.tidyMeasureBars();\n\t\tthis.rearrangeMeasures();\n\n\t\t// measure bar type\n\t\tconst typeBars = this.semantics.filter((point) => [SemanticType.vline_BarTerminal, SemanticType.vline_BarSegment].includes(point.semantic));\n\t\ttypeBars.forEach((bar) => {\n\t\t\tconst measure = this.staves[0].measures.find((measure) => bar.x > measure.right - 2 && bar.x < measure.right + 1);\n\t\t\tif (measure) {\n\t\t\t\tconst type = bar.semantic.replace(/^vline_Bar/, '');\n\t\t\t\tmeasure.barTypes[type] = measure.barTypes[type] || 0;\n\t\t\t\tmeasure.barTypes[type] += bar.confidence;\n\t\t\t}\n\t\t});\n\n\t\tlet staffIndex = 0;\n\t\tconst staffMask = this.staffMask;\n\t\tthis.staves.forEach((staff, si) => {\n\t\t\t// staff index\n\t\t\twhile (!(staffMask & (1 << staffIndex))) ++staffIndex;\n\t\t\tstaff.index = staffIndex++;\n\n\t\t\t// assign semantic boundaries\n\t\t\tif (si === 0) staff.semanticTop = -staff.staffY;\n\t\t\telse {\n\t\t\t\tconst prevStaff = this.staves[si - 1];\n\t\t\t\tstaff.semanticTop = prevStaff.top + prevStaff.staffY + 3 - (staff.top + staff.staffY);\n\t\t\t}\n\n\t\t\tif (si < this.staves.length - 1) {\n\t\t\t\tconst nextStaff = this.staves[si + 1];\n\t\t\t\tstaff.semanticBottom = nextStaff.top + nextStaff.staffY - 3 - (staff.top + staff.staffY);\n\t\t\t} else staff.semanticBottom = this.height - (staff.top + staff.staffY);\n\n\t\t\tif (staff.semantics && staff.semantics.length) {\n\t\t\t\tstaff.semantics.forEach((point) => hashSemanticPoint(this.index, si, point));\n\n\t\t\t\tstaff.clearPredictedTokens();\n\t\t\t\tstaff.assemble(threshold, this, logger);\n\t\t\t}\n\t\t});\n\t}\n\n\tqualifiedSemantics(semantics: SemanticPoint[], threshold: number = 1): SemanticPoint[] {\n\t\treturn semantics\n\t\t\t.filter(\n\t\t\t\t(p) => this.sidWhiteList.includes(p.id) || (!this.sidBlackList.includes(p.id) && (p.confidence >= threshold || !Number.isFinite(p.confidence)))\n\t\t\t)\n\t\t\t.map((point) => {\n\t\t\t\t// displace semantic point\n\t\t\t\tif (this.displacementSemantics && this.displacementSemantics[point.id]) return { ...point, ...this.displacementSemantics[point.id] };\n\n\t\t\t\treturn point;\n\t\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.staves.forEach((staff) => staff.clearTokens());\n\t\tthis.semantics = [];\n\t}\n\n\tnewPoint(staffIndex: number, data: SemanticPoint, threshold: number = 1): SemanticPoint {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff index out of bound:', staffIndex, this.staves.length);\n\n\t\tconst { semantic, x, y, confidence = 0, extension = null } = data;\n\t\tconst point = { semantic, x, y, confidence, extension };\n\t\tif (!point.extension) delete point.extension;\n\n\t\thashSemanticPoint(this.index, staffIndex, point);\n\t\tstaff.semantics.push(point);\n\t\tstaff.clearPredictedTokens();\n\t\tstaff.assemble(threshold, this);\n\n\t\treturn point;\n\t}\n\n\tappendToken(token: TextToken): void {\n\t\tthis.tokens.push(token);\n\n\t\tswitch (token.textType) {\n\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t{\n\t\t\t\t\t// remove noteheads in text area\n\t\t\t\t\tconst staff = this.staves[0];\n\t\t\t\t\tif (staff) {\n\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\t\t\t\t\t\tstaff.measures.forEach((measure) => {\n\t\t\t\t\t\t\tmeasure.tokens = measure.tokens.filter(\n\t\t\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t\t\t!TokenNoteheads.includes(t.type) ||\n\t\t\t\t\t\t\t\t\tMath.abs(t.x - token.x) > token.width / 2 ||\n\t\t\t\t\t\t\t\t\tMath.abs(oy + t.y - token.y) > token.fontSize / 2\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase TextType.Alternation1:\n\t\t\tcase TextType.Alternation2:\n\t\t\t\t//console.log(\"appendToken:\", token, this.staves[0].measures);\n\t\t\t\tthis.staves[0].measures.forEach((measure) => {\n\t\t\t\t\tconst overlap = Math.min(measure.left + measure.width, token.x + token.width / 2) - Math.max(measure.left, token.x - token.width / 2);\n\t\t\t\t\tmeasure.alternative = measure.alternative || overlap / measure.width > 0.5;\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nclass Page extends SimpleClass {\n\tstatic className = 'Page';\n\tstatic blackKeys = ['index', 'tokens'];\n\n\tindex?: number;\n\n\t// in units\n\twidth: number;\n\theight: number;\n\n\tsystems: System[];\n\n\tsource: SourceImageFile;\n\tlayout?: PageLayout;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.systems = this.systems || [];\n\n\t\tif (this.source) {\n\t\t\tthis.source.matrix = this.source.matrix || [1, 0, 0, 1, 0, 0];\n\t\t}\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tclearTokens(): void {\n\t\tthis.semantics = null;\n\t\tthis.tokens = null;\n\n\t\tthis.systems.forEach((system) => (system.tokens = null));\n\t}\n\n\tassignTexts(areas: TextArea[], [imageHeight, imageWidth]: [number, number]): void {\n\t\tconst interval = this.source && this.source.interval ? this.source.interval * (imageHeight / this.source.dimensions.height) : imageHeight / this.height;\n\n\t\tthis.semantics = areas.map((area) => {\n\t\t\tconst p = {\n\t\t\t\tx: (area.cx - imageWidth / 2) / interval,\n\t\t\t\ty: (area.cy - imageHeight / 2) / interval,\n\t\t\t};\n\t\t\tconst rp = this.source && this.source.matrix ? trans23(p, this.source.matrix) : p;\n\n\t\t\treturn {\n\t\t\t\tconfidence: area.score,\n\t\t\t\tx: rp.x + this.width / 2,\n\t\t\t\ty: rp.y + this.height / 2,\n\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\textension: {\n\t\t\t\t\ttext: area.text,\n\t\t\t\t\ttype: area.type,\n\t\t\t\t\twidth: area.width / interval,\n\t\t\t\t\theight: area.height / interval,\n\t\t\t\t\ttheta: area.theta,\n\t\t\t\t\ttextFeature: area.feature_dict,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tassemble({ textAnnotations = null }: { textAnnotations?: { [id: string]: string } } = {}, logger: Logger = new DummyLogger()): void {\n\t\tthis.tokens = [];\n\t\tthis.systems.forEach((system) => (system.tokens = []));\n\n\t\t// compute system indent\n\t\tif (this.systems.length) {\n\t\t\tconst sysXs = this.systems.map((system) => system.left);\n\t\t\tconst middleX = sysXs[Math.floor((sysXs.length - 1) / 2)];\n\t\t\tthis.systems.forEach((system) => (system.indent = system.left > middleX + INDENT_THRESHOLD));\n\t\t}\n\n\t\tif (this.semantics) {\n\t\t\tconst pageName = this.source ? this.source.name : this.index.toString();\n\n\t\t\tthis.semantics.forEach((point) => {\n\t\t\t\thashPageSemanticPoint(pageName, point);\n\n\t\t\t\tconst fields = {\n\t\t\t\t\tid: point.id,\n\t\t\t\t\ttype: TokenType.Text,\n\t\t\t\t\tconfidence: point.confidence,\n\t\t\t\t\ttextType: TEXT_TYPE_ALIAS[point.extension.type] || point.extension.type,\n\t\t\t\t\ttext: (textAnnotations && textAnnotations[point.id]) || point.extension.text,\n\t\t\t\t\ttextFeasure: point.extension.textFeature,\n\t\t\t\t\twidth: point.extension.width,\n\t\t\t\t\tfontSize: point.extension.height,\n\t\t\t\t};\n\n\t\t\t\tswitch (point.semantic) {\n\t\t\t\t\tcase SemanticType.rect_Text:\n\t\t\t\t\t\tswitch (fields.textType) {\n\t\t\t\t\t\t\t// page tokens\n\t\t\t\t\t\t\tcase TextType.Title:\n\t\t\t\t\t\t\tcase TextType.Author:\n\t\t\t\t\t\t\tcase TextType.PageMargin:\n\t\t\t\t\t\t\tcase TextType.Other:\n\t\t\t\t\t\t\t\tthis.tokens.push(\n\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens on the top of system\n\t\t\t\t\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t\t\t\tcase TextType.Chord:\n\t\t\t\t\t\t\tcase TextType.MeasureNumber:\n\t\t\t\t\t\t\tcase TextType.Instrument:\n\t\t\t\t\t\t\tcase TextType.Alternation1:\n\t\t\t\t\t\t\tcase TextType.Alternation2:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = this.systems.find((system) => system.top + system.staffTop > point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tsystem.appendToken(\n\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\tx: point.x - system.left,\n\t\t\t\t\t\t\t\t\t\t\t\ty: point.y - system.top,\n\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens in staff\n\t\t\t\t\t\t\tcase TextType.TextualMark:\n\t\t\t\t\t\t\tcase TextType.Times:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = [...this.systems].reverse().find((system) => system.top < point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tconst sy = point.y - (system.top + system.staffTop);\n\t\t\t\t\t\t\t\t\t\tconst sx = point.x - system.left;\n\t\t\t\t\t\t\t\t\t\tconst staff = system.staves.find((staff) => sy >= staff.top && sy < staff.top + staff.height);\n\t\t\t\t\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\t\t\t\t\tconst measure = staff.measures.find((measure) => sx >= measure.left && sx < measure.left + measure.width);\n\t\t\t\t\t\t\t\t\t\t\tif (measure) {\n\t\t\t\t\t\t\t\t\t\t\t\tmeasure.tokens.push(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx: sx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ty: sy,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport { Measure, Staff, System, Page };\n","import { ChordColumn, Fraction } from './interfaces';\nimport { GraceType } from './term';\nimport { roundNumber } from './utils';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum SemanticElementType {\n\tBOS,\n\tPAD,\n\n\tNoteheadS0,\n\tNoteheadS1,\n\tNoteheadS2,\n\tNoteheadGrace,\n\tvline_Stem,\n\tFlag3,\n\tBeamLeft,\n\tBeamContinue,\n\tBeamRight,\n\tDot,\n\tRest0,\n\tRest1,\n\tRest2,\n\tRest3,\n\tRest4,\n\tRest5,\n\tRest6,\n\n\t// measure time signature denominators & numerators\n\tTimeD2,\n\tTimeD4,\n\tTimeD8,\n\tTimeN1,\n\tTimeN2,\n\tTimeN3,\n\tTimeN4,\n\tTimeN5,\n\tTimeN6,\n\tTimeN7,\n\tTimeN8,\n\tTimeN9,\n\tTimeN10,\n\tTimeN11,\n\tTimeN12,\n}\n\nconst TIME_SIG_DENOMINATORS = Object.fromEntries([2, 4, 8].map((n) => [n, SemanticElementType[`TimeD${n}`]]));\nconst TIME_SIG_NUMERATORS = Object.fromEntries(\n\tArray(12)\n\t\t.fill(null)\n\t\t.map((_, i) => i + 1)\n\t\t.map((n) => [n, SemanticElementType[`TimeN${n}`]])\n);\n\nconst et = SemanticElementType;\n\nconst ELEMENT_TOKEN_NAMES = {\n\t[et.BOS]: 'BOS',\n\t[et.NoteheadS0]: 'noteheads-s0',\n\t[et.NoteheadS1]: 'noteheads-s1',\n\t[et.NoteheadS2]: 'noteheads-s2',\n\t[et.NoteheadGrace]: 'GraceNotehead',\n\t[et.Flag3]: 'flags-u3',\n\t[et.BeamLeft]: 'BeamLeft',\n\t[et.BeamContinue]: 'BeamContinue',\n\t[et.BeamRight]: 'BeamRight',\n\t[et.Dot]: 'dot',\n\t[et.Rest0]: 'rests-0o',\n\t[et.Rest1]: 'rests-1o',\n\t[et.Rest2]: 'rests-2',\n\t[et.Rest3]: 'rests-3',\n\t[et.Rest4]: 'rests-4',\n\t[et.Rest5]: 'rests-5',\n\t[et.Rest6]: 'rests-6',\n};\n\nconst NOTEHEAD_BASE_DIVISION = {\n\t[et.NoteheadS0]: 0,\n\t[et.NoteheadS1]: 1,\n\t[et.NoteheadS2]: 2,\n\t[et.NoteheadGrace]: 2,\n};\n\nconst NOTEHEAD_ELEMENT_TYPES = [et.NoteheadS0, et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace];\n\nconst REST_ELEMENT_TYPES = [et.Rest0, et.Rest1, et.Rest2, et.Rest3, et.Rest4, et.Rest5, et.Rest6];\n\nconst BEAM_ELEMENT_TYPES = [et.BeamLeft, et.BeamContinue, et.BeamRight];\n\nconst NOTE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES];\n\nconst SOURCE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES, et.vline_Stem];\n\nconst TARGET_ELEMENT_TYPES = [et.BOS, et.NoteheadS0, et.vline_Stem, ...REST_ELEMENT_TYPES];\n\nconst ROOT_NOTE_ELEMENT_TYPES = [...NOTE_ELEMENT_TYPES, et.vline_Stem];\n\nconst ELEMENT_TO_STEMBEAM = {\n\t[et.BeamLeft]: 'Open',\n\t[et.BeamRight]: 'Close',\n};\n\ninterface SemanticElement {\n\ttype: SemanticElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\n\tindex?: number;\n\ttick?: number;\n\tid?: string;\n}\n\ntype Matrix = number[][];\n\nconst metaElem = (type: SemanticElementType): SemanticElement => ({\n\ttype,\n\tstaff: -1,\n\tx: 0,\n\ty1: 0,\n\ty2: 0,\n});\n\nconst BOS_ELEMENT = metaElem(SemanticElementType.BOS);\n\nconst fractionToElems = (fraction: Fraction): SemanticElement[] => [\n\tmetaElem(TIME_SIG_NUMERATORS[fraction.numerator]),\n\tmetaElem(TIME_SIG_DENOMINATORS[fraction.denominator]),\n];\n\nconst argmax = (data: number[], mask: boolean[]): number => {\n\tconst values = data.filter((_, i) => mask[i]);\n\tconst max = Math.max(...values);\n\n\treturn data.findIndex((x) => x === max);\n};\n\nclass SemanticCluster extends SimpleClass {\n\tindex?: number;\n\n\telements: SemanticElement[];\n\tmatrixH?: Matrix; // matrix N x N\n\t_matrixV?: Matrix; // matrix N x N\n\tgroupsV?: number[][]; // ids array\n\tmasks?: [boolean[], boolean[], boolean[]]; // the masks for: [jointer source, jointer target, V]\n\n\tstatic elementToJSON(elem: SemanticElement): object {\n\t\tconst result: any = {\n\t\t\ttype: elem.type,\n\t\t\tstaff: elem.staff,\n\t\t\tx: elem.x,\n\t\t\ty1: elem.y1,\n\t\t\ty2: elem.y2,\n\t\t};\n\n\t\tif (elem.id) result.id = elem.id;\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget sourceMask(): boolean[] {\n\t\treturn this.elements.map((elem) => SOURCE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget targetMask(): boolean[] {\n\t\treturn this.elements.map((elem) => TARGET_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget vMask(): boolean[] {\n\t\treturn this.elements.map((elem) => ROOT_NOTE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget compactMatrixH(): Matrix {\n\t\tif (!this.matrixH) return null;\n\n\t\tconst sourceMask = this.sourceMask;\n\t\tconst targetMask = this.targetMask;\n\n\t\treturn this.matrixH.filter((_, i) => sourceMask[i]).map((row) => row.filter((_, j) => targetMask[j]));\n\t}\n\n\tset compactMatrixH(value: Matrix) {\n\t\tthis.matrixH = expandMatrixByMasks([].concat(...value), [this.sourceMask, this.targetMask]);\n\t}\n\n\tget compactMatrixV(): number[] {\n\t\tif (!this._matrixV) return null;\n\n\t\tconst vMask = this.vMask;\n\n\t\tconst matrix = this._matrixV.filter((_, i) => vMask[i]).map((row) => row.filter((_, j) => vMask[j]));\n\n\t\treturn [].concat(...matrix.map((row, i) => row.slice(0, i)));\n\t}\n\n\tset compactMatrixV(value: number[]) {\n\t\tthis.matrixV = value && expandMatrixByMaskTriu(value, this.vMask);\n\t}\n\n\tget matrixV(): Matrix {\n\t\treturn this.groupsV && matrixFromGroups(this.elements.length, this.groupsV);\n\t}\n\n\tset matrixV(value: Matrix) {\n\t\tif (!value) {\n\t\t\tthis.groupsV = null;\n\t\t\tthis._matrixV = value;\n\t\t\treturn;\n\t\t}\n\n\t\tconst THRESHOLD = 0.5;\n\n\t\tconst groups: number[][] = [];\n\t\tconst vMask = value.map((row, i) => row.some(Number.isFinite) || value.some((row) => Number.isFinite(row[i])));\n\n\t\tvalue.forEach((row, i) => {\n\t\t\tif (vMask[i]) {\n\t\t\t\tlet found = false;\n\n\t\t\t\tfor (let j = 0; j < i; ++j) {\n\t\t\t\t\tconst cell = row[j];\n\t\t\t\t\tif (cell >= THRESHOLD) {\n\t\t\t\t\t\tconst g = groups.findIndex((group) => group.includes(j));\n\t\t\t\t\t\tgroups[g].push(i);\n\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!found) groups.push([i]);\n\t\t\t}\n\t\t});\n\n\t\tthis.groupsV = groups;\n\t\tthis._matrixV = value;\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\t__prototype: 'SemanticCluster',\n\t\t\tindex: this.index,\n\t\t\telements: this.elements.map(SemanticCluster.elementToJSON),\n\t\t\tcompactMatrixH: this.compactMatrixH,\n\t\t\tcompactMatrixV: this.compactMatrixV,\n\t\t\t//groupsV: this.groupsV,\n\t\t};\n\t}\n\n\tstatic mapMatrix(matrix: number[][], x2i: number[], i2x: number[]): number[][] {\n\t\tconst rows = x2i.reduce((rows, i, x) => {\n\t\t\tif (rows[i]) rows[i] = rows[i].map((v, xi) => (v + matrix[x][xi] ? 1 : 0));\n\t\t\telse rows[i] = matrix[x];\n\n\t\t\treturn rows;\n\t\t}, [] as number[][]);\n\n\t\treturn rows.map((row) => i2x.map((x) => row[x]));\n\t}\n\n\tmergeOverlapping() {\n\t\tconst overlaps = this.overlappedNoteheads();\n\t\tif (overlaps.length) {\n\t\t\tconst x2i = this.elements.map((_, index) => {\n\t\t\t\tconst pair = overlaps.find((ij) => index === ij[1]);\n\t\t\t\tconst i = pair ? pair[0] : index;\n\n\t\t\t\treturn i - overlaps.filter((ij) => ij[1] < i).length;\n\t\t\t});\n\t\t\tconst i2x = Array(this.elements.length - overlaps.length)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, i) => x2i.findIndex((ii) => ii === i));\n\n\t\t\tthis.elements = i2x.map((x) => this.elements[x]);\n\t\t\tconsole.assert(this.elements.every(Boolean), 'null element found:', this, x2i, i2x);\n\n\t\t\tthis.matrixH = SemanticCluster.mapMatrix(this.matrixH, x2i, i2x);\n\t\t\tthis.groupsV = this.groupsV.map((group) => Array.from(new Set(group.map((x) => x2i[x]))));\n\t\t}\n\t}\n\n\toverlappedNoteheads(): [number, number][] {\n\t\tconst indices = [];\n\n\t\tconst noteheads = this.elements.filter((elem) => NOTEHEAD_ELEMENT_TYPES.includes(elem.type));\n\t\tfor (let i = 0; i < noteheads.length; ++i) {\n\t\t\tconst nh1 = noteheads[i];\n\t\t\tfor (let j = i + 1; j < noteheads.length; ++j) {\n\t\t\t\tconst nh2 = noteheads[j];\n\t\t\t\tif ((nh1.x - nh2.x) * (nh1.x - nh2.x) + (nh1.y1 - nh2.y1) * (nh1.y1 - nh2.y1) < 0.2 ** 2) indices.push([nh1.index, nh2.index]);\n\t\t\t}\n\t\t}\n\n\t\treturn indices;\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\tconsole.assert(this.matrixH, '[SemanticCluster.getEvents]\tmatrixH is null.');\n\n\t\tconst NOTE_STEM_CONFIDENCE = 0.5;\n\n\t\tconst ids = Array(this.elements.length)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => index);\n\n\t\tconst targetMask = this.masks ? this.masks[1] : ids.map((id) => TARGET_ELEMENT_TYPES.includes(this.elements[id].type));\n\n\t\t//const stems = ids.filter(i => this.elements[i].type === et.vline_Stem);\n\t\tconst stemMasks = ids.map((id) => this.elements[id].type === et.vline_Stem && this.elements[id].y2 - this.elements[id].y1 > 2); // TODO: sift out too short stems by rectification model\n\t\tconst stemNotes = ids.filter((i) => [et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace].includes(this.elements[i].type));\n\t\tconst s0s = ids.filter((i) => this.elements[i].type === et.NoteheadS0);\n\t\tconst subS0Masks = ids.map(() => false);\n\n\t\t// root elements: top NoteheadS0, Rests, stem with noteheads\n\t\tconst stemMap: { [stem: number]: number[] } = {};\n\t\tstemNotes.forEach((id) => {\n\t\t\tconst note = this.elements[id];\n\t\t\tconst stems = ids\n\t\t\t\t.filter((i) => stemMasks[i])\n\t\t\t\t.filter((stemId) => this.elements[stemId].y1 - 0.5 < note.y1 && this.elements[stemId].y2 + 0.5 > note.y1) // filter by stem Y range\n\t\t\t\t.sort((i1, i2) => this.matrixH[id][i2] - this.matrixH[id][i1]) // sort by confidence\n\t\t\t\t.slice(0, 2)\n\t\t\t\t.filter((i, ii) => ii === 0 || this.matrixH[id][i] >= NOTE_STEM_CONFIDENCE);\n\t\t\tstems.forEach((stem) => {\n\t\t\t\tstemMap[stem] = stemMap[stem] || [];\n\t\t\t\tstemMap[stem].push(id);\n\t\t\t});\n\t\t});\n\n\t\ts0s.forEach((id) => {\n\t\t\tconst s0 = this.elements[id];\n\t\t\tconst prevId = argmax(this.matrixH[id], targetMask);\n\t\t\tconst prev = this.elements[prevId];\n\t\t\tif (prev.type === et.NoteheadS0 && Math.abs(s0.x - prev.x) < 2.6) {\n\t\t\t\tsubS0Masks[id] = true;\n\t\t\t\tstemMap[prevId] = stemMap[prevId] || [prevId];\n\t\t\t\tstemMap[prevId].push(id);\n\t\t\t} else stemMap[id] = stemMap[id] || [id];\n\t\t});\n\n\t\t// setup linkings\n\t\tconst linkings: { [key: number]: number } = {};\n\n\t\tconst roots = ids.filter((id) => stemMap[id] || REST_ELEMENT_TYPES.includes(this.elements[id].type));\n\t\troots.sort((i1, i2) => this.elements[i1].x - this.elements[i2].x); // traverse roots from left to right later\n\n\t\tconst parentMasks = ids.map((id) => id === et.BOS);\n\t\troots.forEach((id) => {\n\t\t\tconst parentId = argmax(this.matrixH[id], parentMasks);\n\t\t\tlinkings[id] = parentId;\n\n\t\t\tif (parentId && !REST_ELEMENT_TYPES.includes(this.elements[parentId].type)) parentMasks[parentId] = false;\n\n\t\t\tparentMasks[id] = true;\n\t\t});\n\t\t//console.log(\"topology:\", stemMap, linkings);\n\n\t\tconst dots = this.elements.filter((elem) => elem.type === et.Dot);\n\t\tconst flags = this.elements.filter((elem) => elem.type === et.Flag3);\n\t\tconst beams = this.elements.filter((elem) => BEAM_ELEMENT_TYPES.includes(elem.type));\n\n\t\tconst groupsV = this.groupsV;\n\n\t\treturn roots\n\t\t\t.map((rootId): ChordColumn => {\n\t\t\t\tconst root = this.elements[rootId];\n\n\t\t\t\tconst tickGroup = groupsV ? groupsV.findIndex((group) => group.includes(rootId)) : null;\n\n\t\t\t\tif (REST_ELEMENT_TYPES.includes(root.type)) {\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > root.x + 0.5 && dot.x < root.x + 0.75 + 1.2 && dot.y1 > root.y1 - 1 && dot.y1 < root.y1);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft: root.x - 0.75,\n\t\t\t\t\t\tright: root.x + 0.75,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\trest: true,\n\t\t\t\t\t\tys: [root.y1],\n\t\t\t\t\t\tnoteIds: [root.id],\n\t\t\t\t\t\tdots: nearbyDots.length,\n\t\t\t\t\t\tdivision: root.type - et.Rest0,\n\t\t\t\t\t\tstemDirection: null,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: root.staff,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t} else if (stemMap[rootId]) {\n\t\t\t\t\tconst subNotes = stemMap[rootId].map((id) => this.elements[id]);\n\t\t\t\t\tconst left = Math.min(...subNotes.map((n) => n.x - 0.7));\n\t\t\t\t\tconst right = Math.max(...subNotes.map((n) => n.x + 0.7));\n\t\t\t\t\tsubNotes.sort((n1, n2) => n2.y1 - n1.y1);\n\n\t\t\t\t\tconst ys = subNotes.map((note) => note.y1);\n\n\t\t\t\t\tconst noteIds = subNotes.map((note) => note.id);\n\n\t\t\t\t\tconst top = ys[0];\n\t\t\t\t\tconst bottom = ys[ys.length - 1];\n\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > right && dot.x < right + 1.2 && dot.y1 > top - 1 && dot.y1 < bottom + 0.5);\n\t\t\t\t\tconst dotGroups: { [key: number]: SemanticElement[] } = nearbyDots.reduce((groups, dot) => {\n\t\t\t\t\t\tconst y = roundNumber(dot.y1, 0.5);\n\t\t\t\t\t\tgroups[y] = groups[y] || [];\n\t\t\t\t\t\tgroups[y].push(dot);\n\n\t\t\t\t\t\treturn groups;\n\t\t\t\t\t}, {});\n\t\t\t\t\tconst dotValue = Math.max(...Object.values(dotGroups).map((group) => group.length), 0);\n\n\t\t\t\t\tlet division = NOTEHEAD_BASE_DIVISION[subNotes[0].type];\n\n\t\t\t\t\tlet stemDirection = null;\n\t\t\t\t\tlet beam: string = null;\n\t\t\t\t\tlet tip = null;\n\t\t\t\t\tif (root.type === et.vline_Stem) {\n\t\t\t\t\t\tconst topTip = top - root.y1;\n\t\t\t\t\t\tconst bottomTip = root.y2 - bottom;\n\t\t\t\t\t\tstemDirection = topTip > bottomTip ? 'u' : 'd';\n\n\t\t\t\t\t\ttip = { x: root.x, y: stemDirection === 'u' ? root.y1 : root.y2 };\n\n\t\t\t\t\t\tif (division === 2) {\n\t\t\t\t\t\t\tconst flagRange = stemDirection === 'u' ? [root.y1 - 0.4, root.y2 - 1] : [root.y1 + 1, root.y2 + 0.4];\n\t\t\t\t\t\t\tconst nearbyFlags = flags.filter((flag) => Math.abs(flag.x - root.x) < 0.2 && flag.y1 > flagRange[0] && flag.y1 < flagRange[1]);\n\t\t\t\t\t\t\tdivision += nearbyFlags.length;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//const tipY = stemDirection === \"u\" ? root.y1 : root.y2;\n\t\t\t\t\t\tconst tipRange = stemDirection === 'u' ? [root.y1 - 0.2, root.y1 + 0.9] : [root.y2 - 0.9, root.y2 + 0.2];\n\t\t\t\t\t\tconst beamElem = beams.find((beam) => Math.abs(beam.x - root.x) < 0.2 && beam.y1 > tipRange[0] && beam.y1 < tipRange[1]);\n\t\t\t\t\t\tbeam = beamElem ? ELEMENT_TO_STEMBEAM[beamElem.type] : null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst grace = subNotes[0].type === SemanticElementType.NoteheadGrace ? GraceType.Grace : null;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\tright,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tys,\n\t\t\t\t\t\ttip,\n\t\t\t\t\t\tnoteIds,\n\t\t\t\t\t\tdivision,\n\t\t\t\t\t\tdots: dotValue,\n\t\t\t\t\t\trest: false,\n\t\t\t\t\t\tstemDirection,\n\t\t\t\t\t\tbeam,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: subNotes[0].staff,\n\t\t\t\t\t\tgrace,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n}\n\ninterface SemanticClusterSetData {\n\tvocab?: string[];\n\tclusters: SemanticCluster[];\n}\n\nclass SemanticClusterSet {\n\tclusters: SemanticCluster[];\n\n\tconstructor(data?: SemanticClusterSetData) {\n\t\tif (data) {\n\t\t\tthis.clusters = data.clusters;\n\n\t\t\t// upgrade vocab\n\t\t\tif (data.vocab) {\n\t\t\t\tconst converts = data.vocab\n\t\t\t\t\t.map((name, i) => [i, SemanticElementType[name]])\n\t\t\t\t\t.filter(([x, y]) => x !== y)\n\t\t\t\t\t.reduce((table, [x, y]) => ((table[x] = y), table), {});\n\t\t\t\tthis.clusters.forEach((connection) =>\n\t\t\t\t\tconnection.elements.forEach((elem) => {\n\t\t\t\t\t\tif (Number.isFinite(converts[elem.type])) elem.type = converts[elem.type];\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst vocab = Object.entries(SemanticElementType)\n\t\t\t.filter((entry) => Number.isFinite(entry[1]))\n\t\t\t.map((entry) => entry[0]);\n\n\t\treturn {\n\t\t\t__prototype: 'SemanticClusterSet',\n\t\t\tvocab,\n\t\t\tclusters: this.clusters.map((c) => c.toJSON()),\n\t\t};\n\t}\n}\n\nconst expandMatrixByMasks = (matrix: number[], masks: [boolean[], boolean[]]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\tconst [maskSrc, maskTar] = masks;\n\n\treturn maskSrc.map((src) => maskTar.map((tar) => (src && tar ? iter.next().value : null)));\n};\n\nconst expandMatrixByMaskTriu = (matrix: number[], mask: boolean[]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\treturn mask.map((row, i) => mask.map((column, j) => (row && column && j < i ? iter.next().value : null)));\n};\n\nconst matrixFromGroups = (len: number, groups: number[][]): Matrix => {\n\tconst groupIds = Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) => groups.findIndex((group) => group.includes(i)));\n\n\treturn Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) =>\n\t\t\tArray(len)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, j) => {\n\t\t\t\t\tif (j >= i) return null;\n\n\t\t\t\t\tconst id1 = groupIds[i];\n\t\t\t\t\tconst id2 = groupIds[j];\n\n\t\t\t\t\tif (id1 < 0 || id2 < 0) return null;\n\n\t\t\t\t\treturn id1 === id2 ? 1 : 0;\n\t\t\t\t})\n\t\t);\n};\n\nexport {\n\tSemanticElementType,\n\tSemanticElement,\n\tSemanticCluster,\n\tSemanticClusterSet,\n\tELEMENT_TOKEN_NAMES,\n\tNOTEHEAD_ELEMENT_TYPES,\n\tNOTE_ELEMENT_TYPES,\n\tBOS_ELEMENT,\n\tfractionToElems,\n\texpandMatrixByMasks,\n\texpandMatrixByMaskTriu,\n\tmatrixFromGroups,\n};\n","import { MusicNotation } from '@k-l-lambda/music-widgets';\n\n// implicit note (from expressive marks) types\nenum ImplicitType {\n\tNone = 0,\n\n\tMordent = 'mordent',\n\tPrall = 'prall',\n\tTurn = 'turn',\n\tTrill = 'trill',\n\tTremolo = 'tremolo',\n\tArpeggio = 'arpeggio',\n}\n\ninterface ChordPosition {\n\tindex: number;\n\tcount: number;\n}\n\nclass TokenPosition {\n\tsystem?: number;\n\tmeasure?: number;\n\tx: number;\n\tendX?: number;\n}\n\ninterface Note extends MusicNotation.Note {\n\tchordPosition?: ChordPosition;\n\tmeasure?: number;\n}\n\ninterface Notation {\n\tnotes: Note[];\n\tendTick: number;\n}\n\ninterface SheetPosition {\n\tsystem: number;\n\tx: number;\n}\n\nexport { ChordPosition, ImplicitType, TokenPosition, Note, Notation, SheetPosition };\n","/*\nclass to parse the .mid file format\n(depends on stream.js)\n*/\n\nconst Stream = require(\"./stream.js\");\n\n\n\nmodule.exports = function MidiFile (data) {\n\tfunction readChunk (stream) {\n\t\tconst id = stream.readString(4);\n\t\tconst length = stream.readInt32();\n\n\t\treturn {\n\t\t\tid,\n\t\t\tlength,\n\t\t\tdata: stream.read(length),\n\t\t};\n\t}\n\n\tlet lastEventTypeByte;\n\n\tfunction readEvent (stream) {\n\t\tconst event = {};\n\t\tevent.deltaTime = stream.readVarInt();\n\t\tlet eventTypeByte = stream.readInt8();\n\t\tif ((eventTypeByte & 0xf0) === 0xf0) {\n\t\t\t// system / meta event\n\t\t\tif (eventTypeByte === 0xff) {\n\t\t\t\t// meta event\n\t\t\t\tevent.type = \"meta\";\n\t\t\t\tconst subtypeByte = stream.readInt8();\n\t\t\t\tconst length = stream.readVarInt();\n\n\t\t\t\tswitch (subtypeByte) {\n\t\t\t\tcase 0x00:\n\t\t\t\t\tevent.subtype = \"sequenceNumber\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for sequenceNumber event is 2, got \" + length);\n\t\t\t\t\tevent.number = stream.readInt16();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x01:\n\t\t\t\t\tevent.subtype = \"text\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x02:\n\t\t\t\t\tevent.subtype = \"copyrightNotice\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x03:\n\t\t\t\t\tevent.subtype = \"trackName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x04:\n\t\t\t\t\tevent.subtype = \"instrumentName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x05:\n\t\t\t\t\tevent.subtype = \"lyrics\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x06:\n\t\t\t\t\tevent.subtype = \"marker\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x07:\n\t\t\t\t\tevent.subtype = \"cuePoint\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x20:\n\t\t\t\t\tevent.subtype = \"midiChannelPrefix\";\n\t\t\t\t\tif (length !== 1)\n\t\t\t\t\t\tthrow new Error(\"Expected length for midiChannelPrefix event is 1, got \" + length);\n\t\t\t\t\tevent.channel = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x2f:\n\t\t\t\t\tevent.subtype = \"endOfTrack\";\n\t\t\t\t\tif (length !== 0)\n\t\t\t\t\t\tthrow new Error(\"Expected length for endOfTrack event is 0, got \" + length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x51:\n\t\t\t\t\tevent.subtype = \"setTempo\";\n\t\t\t\t\tif (length !== 3)\n\t\t\t\t\t\tthrow new Error(\"Expected length for setTempo event is 3, got \" + length);\n\t\t\t\t\tevent.microsecondsPerBeat = (\n\t\t\t\t\t\t(stream.readInt8() << 16) +\n\t\t\t\t\t\t\t(stream.readInt8() << 8) +\n\t\t\t\t\t\t\tstream.readInt8()\n\t\t\t\t\t);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x54:\n\t\t\t\t\tevent.subtype = \"smpteOffset\";\n\t\t\t\t\tif (length !== 5)\n\t\t\t\t\t\tthrow new Error(\"Expected length for smpteOffset event is 5, got \" + length);\n\t\t\t\t\tconst hourByte = stream.readInt8();\n\t\t\t\t\tevent.frameRate = {\n\t\t\t\t\t\t0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30,\n\t\t\t\t\t}[hourByte & 0x60];\n\t\t\t\t\tevent.hour = hourByte & 0x1f;\n\t\t\t\t\tevent.min = stream.readInt8();\n\t\t\t\t\tevent.sec = stream.readInt8();\n\t\t\t\t\tevent.frame = stream.readInt8();\n\t\t\t\t\tevent.subframe = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x58:\n\t\t\t\t\tevent.subtype = \"timeSignature\";\n\t\t\t\t\tif (length !== 4)\n\t\t\t\t\t\tthrow new Error(\"Expected length for timeSignature event is 4, got \" + length);\n\t\t\t\t\tevent.numerator = stream.readInt8();\n\t\t\t\t\tevent.denominator = Math.pow(2, stream.readInt8());\n\t\t\t\t\tevent.metronome = stream.readInt8();\n\t\t\t\t\tevent.thirtyseconds = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x59:\n\t\t\t\t\tevent.subtype = \"keySignature\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for keySignature event is 2, got \" + length);\n\t\t\t\t\tevent.key = stream.readInt8(true);\n\t\t\t\t\tevent.scale = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x7f:\n\t\t\t\t\tevent.subtype = \"sequencerSpecific\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tdefault:\n\t\t\t\t\t// console.log(\"Unrecognised meta event subtype: \" + subtypeByte);\n\t\t\t\t\tevent.subtype = \"unknown\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\t}\n\n\t\t\t\t//event.data = stream.readString(length);\n\t\t\t\t//return event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf0) {\n\t\t\t\tevent.type = \"sysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf7) {\n\t\t\t\tevent.type = \"dividedSysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type byte: \" + eventTypeByte);\n\t\t}\n\t\telse {\n\t\t\t/* channel event */\n\t\t\tlet param1;\n\t\t\tif ((eventTypeByte & 0x80) === 0) {\n\t\t\t\t/* running status - reuse lastEventTypeByte as the event type.\n\t\t\t\t\teventTypeByte is actually the first parameter\n\t\t\t\t*/\n\t\t\t\tparam1 = eventTypeByte;\n\t\t\t\teventTypeByte = lastEventTypeByte;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tparam1 = stream.readInt8();\n\t\t\t\tlastEventTypeByte = eventTypeByte;\n\t\t\t}\n\n\t\t\tconst eventType = eventTypeByte >> 4;\n\t\t\tevent.channel = eventTypeByte & 0x0f;\n\t\t\tevent.type = \"channel\";\n\n\t\t\tswitch (eventType) {\n\t\t\tcase 0x08:\n\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x09:\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\t\t\t\tif (event.velocity === 0)\n\t\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\telse\n\t\t\t\t\tevent.subtype = \"noteOn\";\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0a:\n\t\t\t\tevent.subtype = \"noteAftertouch\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.amount = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0b:\n\t\t\t\tevent.subtype = \"controller\";\n\t\t\t\tevent.controllerType = param1;\n\t\t\t\tevent.value = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0c:\n\t\t\t\tevent.subtype = \"programChange\";\n\t\t\t\tevent.programNumber = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0d:\n\t\t\t\tevent.subtype = \"channelAftertouch\";\n\t\t\t\tevent.amount = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0e:\n\t\t\t\tevent.subtype = \"pitchBend\";\n\t\t\t\tevent.value = param1 + (stream.readInt8() << 7);\n\n\t\t\t\treturn event;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type: \" + eventType);\n\n\t\t\t\t/*\n\t\t\t\tconsole.log(\"Unrecognised MIDI event type: \" + eventType);\n\t\t\t\tstream.readInt8();\n\t\t\t\tevent.subtype = 'unknown';\n\t\t\t\treturn event;\n\t\t\t\t*/\n\t\t\t}\n\t\t}\n\t}\n\n\n\tlet source = data;\n\tif (typeof data === \"string\")\n\t\tsource = data.split(\"\").map(c => c.charCodeAt(0));\n\n\tconst stream = new Stream(source);\n\tconst headerChunk = readChunk(stream);\n\tif (headerChunk.id !== \"MThd\" || headerChunk.length !== 6)\n\t\tthrow new Error(\"Bad .mid file - header not found\");\n\n\tconst headerStream = new Stream(headerChunk.data);\n\tconst formatType = headerStream.readInt16();\n\tconst trackCount = headerStream.readInt16();\n\tconst timeDivision = headerStream.readInt16();\n\n\tlet ticksPerBeat;\n\tif (timeDivision & 0x8000)\n\t\tthrow new Error(\"Expressing time division in SMTPE frames is not supported yet\");\n\telse\n\t\tticksPerBeat = timeDivision;\n\n\n\tconst header = {\n\t\tformatType,\n\t\ttrackCount,\n\t\tticksPerBeat,\n\t};\n\tconst tracks = [];\n\tfor (let i = 0; i < header.trackCount; i++) {\n\t\ttracks[i] = [];\n\t\tconst trackChunk = readChunk(stream);\n\t\tif (trackChunk.id !== \"MTrk\")\n\t\t\tthrow new Error(\"Unexpected chunk - expected MTrk, got \" + trackChunk.id);\n\n\t\tconst trackStream = new Stream(trackChunk.data);\n\t\twhile (!trackStream.eof()) {\n\t\t\tconst event = readEvent(trackStream);\n\t\t\ttracks[i].push(event);\n\t\t}\n\t}\n\n\treturn {\n\t\theader,\n\t\ttracks,\n\t};\n};\n","\n/* Wrapper for accessing buffer through sequential reads */\n\n\n\nmodule.exports = class Stream {\n\tconstructor (buffer) {\n\t\tthis.array = new Uint8Array(buffer);\n\t\tthis.position = 0;\n\t}\n\n\n\teof () {\n\t\treturn this.position >= this.array.length;\n\t}\n\n\n\tread (length) {\n\t\tconst result = this.array.slice(this.position, this.position + length);\n\t\tthis.position += length;\n\n\t\treturn result;\n\t}\n\n\n\treadString (length) {\n\t\tconst data = Array.from(this.read(length));\n\n\t\treturn data.map(c => String.fromCharCode(c)).join(\"\");\n\t}\n\n\n\t// read a big-endian 32-bit integer\n\treadInt32 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 24) +\n\t\t\t(this.array[this.position + 1] << 16) +\n\t\t\t(this.array[this.position + 2] << 8) +\n\t\t\tthis.array[this.position + 3]);\n\t\tthis.position += 4;\n\n\t\treturn result;\n\t}\n\n\n\t// read a big-endian 16-bit integer\n\treadInt16 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 8) +\n\t\t\tthis.array[this.position + 1]);\n\t\tthis.position += 2;\n\n\t\treturn result;\n\t}\n\n\n\t// read an 8-bit integer\n\treadInt8 (signed) {\n\t\tlet result = this.array[this.position];\n\t\tif (signed && result > 127)\n\t\t\tresult -= 256;\n\t\tthis.position += 1;\n\n\t\treturn result;\n\t}\n\n\n\t/* read a MIDI-style variable-length integer\n\t\t(big-endian value in groups of 7 bits,\n\t\twith top bit set to signify that another byte follows)\n\t*/\n\treadVarInt () {\n\t\tlet result = 0;\n\t\twhile (true) {\n\t\t\tconst b = this.readInt8();\n\t\t\tif (b & 0x80) {\n\t\t\t\tresult += (b & 0x7f);\n\t\t\t\tresult <<= 7;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// b is the last byte\n\t\t\t\treturn result + b;\n\t\t\t}\n\t\t}\n\t}\n};\n","/*\r\nclass to encode the .mid file format\r\n(depends on streamEx.js)\r\n*/\r\n\r\nconst OStream = require(\"./streamEx.js\");\r\n\r\n\r\n\r\nmodule.exports = function OMidiFile ({ header, tracks }) {\r\n\tfunction writeChunk (stream, id, data) {\r\n\t\tconsole.assert(id.length === 4, \"chunk id must be 4 byte\");\r\n\r\n\t\tstream.write(id);\r\n\t\tstream.writeInt32(data.length);\r\n\t\tstream.write(data);\r\n\t}\r\n\r\n\tfunction writeEvent (stream, event) {\r\n\t\tif (event.subtype === \"unknown\")\r\n\t\t\treturn;\r\n\r\n\t\tstream.writeVarInt(event.deltaTime);\r\n\r\n\t\tswitch (event.type) {\r\n\t\tcase \"meta\":\r\n\t\t\tstream.writeInt8(0xff);\r\n\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"sequenceNumber\":\r\n\t\t\t\tstream.writeInt8(0x00);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt16(event.number);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"text\":\r\n\t\t\t\tstream.writeInt8(0x01);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"copyrightNotice\":\r\n\t\t\t\tstream.writeInt8(0x02);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"trackName\":\r\n\t\t\t\tstream.writeInt8(0x03);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"instrumentName\":\r\n\t\t\t\tstream.writeInt8(0x04);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"lyrics\":\r\n\t\t\t\tstream.writeInt8(0x05);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"marker\":\r\n\t\t\t\tstream.writeInt8(0x06);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"cuePoint\":\r\n\t\t\t\tstream.writeInt8(0x07);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"midiChannelPrefix\":\r\n\t\t\t\tstream.writeInt8(0x20);\r\n\t\t\t\tstream.writeVarInt(1);\r\n\r\n\t\t\t\tstream.writeInt8(event.channel);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"endOfTrack\":\r\n\t\t\t\tstream.writeInt8(0x2f);\r\n\t\t\t\tstream.writeVarInt(0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"setTempo\":\r\n\t\t\t\tstream.writeInt8(0x51);\r\n\t\t\t\tstream.writeVarInt(3);\r\n\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 16) & 0xff);\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 8) & 0xff);\r\n\t\t\t\tstream.writeInt8(event.microsecondsPerBeat & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"smpteOffset\":\r\n\t\t\t\tstream.writeInt8(0x54);\r\n\t\t\t\tstream.writeVarInt(5);\r\n\r\n\t\t\t\tvar frameByte = { 24: 0x00, 25: 0x20, 29: 0x40, 30: 0x60 }[event.frameRate];\r\n\t\t\t\tstream.writeInt8(event.hour | frameByte);\r\n\t\t\t\tstream.writeInt8(event.min);\r\n\t\t\t\tstream.writeInt8(event.sec);\r\n\t\t\t\tstream.writeInt8(event.frame);\r\n\t\t\t\tstream.writeInt8(event.subframe);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"timeSignature\":\r\n\t\t\t\tstream.writeInt8(0x58);\r\n\t\t\t\tstream.writeVarInt(4);\r\n\r\n\t\t\t\tstream.writeInt8(event.numerator);\r\n\t\t\t\tstream.writeInt8(Math.log2(event.denominator));\r\n\t\t\t\tstream.writeInt8(event.metronome);\r\n\t\t\t\tstream.writeInt8(event.thirtyseconds);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"keySignature\":\r\n\t\t\t\tstream.writeInt8(0x59);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt8(event.key);\r\n\t\t\t\tstream.writeInt8(event.scale);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"sequencerSpecific\":\r\n\t\t\t\tstream.writeInt8(0x7f);\r\n\t\t\t\tstream.writeVarInt(event.data.length);\r\n\r\n\t\t\t\tstream.write(event.data);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"sysEx\":\r\n\t\t\tstream.writeInt8(0xf0);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"dividedSysEx\":\r\n\t\t\tstream.writeInt8(0xf7);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"channel\":\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"noteOn\":\r\n\t\t\t\tstream.writeInt8(0x90 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteOff\":\r\n\t\t\t\tstream.writeInt8(0x80 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity ? event.velocity : 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xa0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"controller\":\r\n\t\t\t\tstream.writeInt8(0xb0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.controllerType);\r\n\t\t\t\tstream.writeInt8(event.value);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"programChange\":\r\n\t\t\t\tstream.writeInt8(0xc0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.programNumber);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"channelAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xd0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"pitchBend\":\r\n\t\t\t\tstream.writeInt8(0xe0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.value & 0xff);\r\n\t\t\t\tstream.writeInt8((event.value >> 7) & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tthrow new Error(\"unhandled event type:\" + event.type);\r\n\t\t}\r\n\t}\r\n\r\n\tconst stream = new OStream();\r\n\r\n\tconst headerChunk = new OStream();\r\n\theaderChunk.writeInt16(header.formatType);\r\n\theaderChunk.writeInt16(tracks.length);\r\n\theaderChunk.writeInt16(header.ticksPerBeat);\r\n\r\n\twriteChunk(stream, \"MThd\", headerChunk.getBuffer());\r\n\r\n\tfor (let i = 0; i < tracks.length; ++i) {\r\n\t\tconst trackChunk = new OStream();\r\n\r\n\t\tfor (let ei = 0; ei < tracks[i].length; ++ei)\r\n\t\t\twriteEvent(trackChunk, tracks[i][ei]);\r\n\r\n\t\twriteChunk(stream, \"MTrk\", trackChunk.getBuffer());\r\n\t}\r\n\r\n\treturn stream.getArrayBuffer();\r\n};\r\n","\r\n/* Wrapper for accessing strings through sequential writes */\r\n\r\n\r\n\r\nmodule.exports = class OStream {\r\n\tconstructor () {\r\n\t\tthis.buffer = \"\";\r\n\t}\r\n\r\n\twrite (str) {\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\t/* write a big-endian 32-bit integer */\r\n\twriteInt32 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 24) & 0xff) + String.fromCharCode((i >> 16) & 0xff) +\r\n\t\t\tString.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a big-endian 16-bit integer */\r\n\twriteInt16 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write an 8-bit integer */\r\n\twriteInt8 (i) {\r\n\t\tthis.buffer += String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a MIDI-style variable-length integer\r\n\t\t(big-endian value in groups of 7 bits,\r\n\t\twith top bit set to signify that another byte follows)\r\n\t*/\r\n\twriteVarInt (i) {\r\n\t\tif (i < 0)\r\n\t\t\tthrow new Error(\"OStream.writeVarInt minus number: \" + i);\r\n\r\n\t\tconst b = i & 0x7f;\r\n\t\ti >>= 7;\r\n\t\tlet str = String.fromCharCode(b);\r\n\r\n\t\twhile (i) {\r\n\t\t\tconst b = i & 0x7f;\r\n\t\t\ti >>= 7;\r\n\t\t\tstr = String.fromCharCode(b | 0x80) + str;\r\n\t\t}\r\n\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\tgetBuffer () {\r\n\t\treturn this.buffer;\r\n\t}\r\n\r\n\tgetArrayBuffer () {\r\n\t\treturn Uint8Array.from(this.buffer.split(\"\").map(c => c.charCodeAt(0))).buffer;\r\n\t}\r\n};\r\n","\nmodule.exports = {\n\tparseMidiData: require(\"./midifile.js\"),\n\tencodeMidiFile: require(\"./midifileEx.js\"),\n};\n","\nconst midiToSequence = (midiFile, {timeWarp = 1} = {}) => {\n\tconst trackStates = [];\n\tlet beatsPerMinute = 120;\n\tconst ticksPerBeat = midiFile.header.ticksPerBeat;\n\n\tfor (let i = 0; i < midiFile.tracks.length; i++) {\n\t\ttrackStates[i] = {\n\t\t\tnextEventIndex: 0,\n\t\t\tticksToNextEvent: (\n\t\t\t\tmidiFile.tracks[i].length ?\n\t\t\t\t\tmidiFile.tracks[i][0].deltaTime :\n\t\t\t\t\tnull\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction getNextEvent () {\n\t\tlet ticksToNextEvent = null;\n\t\tlet nextEventTrack = null;\n\t\tlet nextEventIndex = null;\n\n\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\tif (\n\t\t\t\ttrackStates[i].ticksToNextEvent != null\n\t\t\t\t&& (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent)\n\t\t\t) {\n\t\t\t\tticksToNextEvent = trackStates[i].ticksToNextEvent;\n\t\t\t\tnextEventTrack = i;\n\t\t\t\tnextEventIndex = trackStates[i].nextEventIndex;\n\t\t\t}\n\t\t}\n\t\tif (nextEventTrack != null) {\n\t\t\t/* consume event from that track */\n\t\t\tconst nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex];\n\t\t\tif (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime;\n\t\t\telse \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent = null;\n\n\t\t\ttrackStates[nextEventTrack].nextEventIndex += 1;\n\t\t\t/* advance timings on all tracks by ticksToNextEvent */\n\t\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\t\tif (trackStates[i].ticksToNextEvent != null) \n\t\t\t\t\ttrackStates[i].ticksToNextEvent -= ticksToNextEvent;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tticksToEvent: ticksToNextEvent,\n\t\t\t\tevent: nextEvent,\n\t\t\t\ttrack: nextEventTrack,\n\t\t\t};\n\t\t}\n\t\telse \n\t\t\treturn null;\n\t\t\n\t};\n\t//\n\tlet midiEvent;\n\tconst events = [];\n\t//\n\tfunction processEvents () {\n\t\tfunction processNext () {\n\t\t\tlet secondsToGenerate = 0;\n\t\t\tif (midiEvent.ticksToEvent > 0) {\n\t\t\t\tconst beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;\n\t\t\t\tsecondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);\n\t\t\t}\n\n\t\t\t// beatsPerMinute must be changed after secondsToGenerate calculation\n\t\t\tif ( midiEvent.event.type == \"meta\" && midiEvent.event.subtype == \"setTempo\" ) {\n\t\t\t\t// tempo change events can occur anywhere in the middle and affect events that follow\n\t\t\t\tbeatsPerMinute = 60e+6 / midiEvent.event.microsecondsPerBeat;\n\t\t\t}\n\n\t\t\tconst time = (secondsToGenerate * 1000 * timeWarp) || 0;\n\t\t\tevents.push([ midiEvent, time ]);\n\t\t\tmidiEvent = getNextEvent();\n\t\t};\n\t\t//\n\t\tif (midiEvent = getNextEvent()) {\n\t\t\twhile (midiEvent)\n\t\t\t\tprocessNext();\n\t\t}\n\t};\n\n\tprocessEvents();\n\n\treturn events;\n};\n\n\nconst trimSequence = seq => {\n\tconst status = new Map();\n\n\treturn seq.filter(([{event, ticksToEvent}]) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tstatus.clear();\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn true;\n\n\t\tconst key = `${event.subtype}|${event.channel}|${event.noteNumber}`;\n\n\t\tif (status.get(key)) {\n\t\t\t//console.debug(\"event trimmed:\", event, ticksToEvent);\n\t\t\treturn false;\n\t\t}\n\n\t\tstatus.set(key, event);\n\n\t\treturn true;\n\t});\n};\n\n\nconst fixOverlapNotes = seq => {\n\tconst noteMap = new Map();\n\tconst overlapMap = new Map();\n\tconst swaps = [];\n\n\tlet leapIndex = -1;\n\n\tseq.forEach(([{event, ticksToEvent}], index) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tleapIndex = index;\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn;\n\n\t\tconst key = `${event.channel}|${event.noteNumber}`;\n\n\t\tswitch (event.subtype) {\n\t\tcase \"noteOn\":\n\t\t\tif (noteMap.get(key))\n\t\t\t\toverlapMap.set(key, leapIndex);\n\t\t\telse\n\t\t\t\tnoteMap.set(key, leapIndex);\n\n\t\t\tbreak;\n\t\tcase \"noteOff\":\n\t\t\tif (overlapMap.get(key)) {\n\t\t\t\tswaps.push([overlapMap.get(key), index]);\n\t\t\t\toverlapMap.delete(key);\n\t\t\t}\n\t\t\telse\n\t\t\t\tnoteMap.delete(key);\n\n\t\t\tbreak;\n\t\t}\n\t});\n\n\t// shift overlapped swaps\n\tswaps.forEach((swap, i) => {\n\t\tfor (let ii = i - 1; ii >= 0; --ii) {\n\t\t\tconst pre = swaps[ii];\n\t\t\tif (pre[1] < swap[0])\n\t\t\t\tbreak;\n\n\t\t\tif (swap[0] > pre[0])\n\t\t\t\t++swap[0];\n\t\t}\n\t});\n\n\t//console.debug(\"swaps:\", swaps);\n\tswaps.forEach(([front, back]) => {\n\t\tif (back >= seq.length - 1 || front < 0)\n\t\t\treturn;\n\n\t\tconst offEvent = seq[back];\n\t\tconst nextEvent = seq[back + 1];\n\t\tconst leapEvent = seq[front];\n\n\t\tif (!leapEvent[0].ticksToEvent) {\n\t\t\tconsole.warn(\"invalid front index:\", front, back, leapEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t// ms per tick\n\t\tconst tempo = leapEvent[1] / leapEvent[0].ticksToEvent;\n\n\t\tnextEvent[1] += offEvent[1];\n\t\tnextEvent[0].ticksToEvent += offEvent[0].ticksToEvent;\n\n\t\toffEvent[0].ticksToEvent = leapEvent[0].ticksToEvent - 1;\n\t\tleapEvent[0].ticksToEvent = 1;\n\n\t\toffEvent[1] = offEvent[0].ticksToEvent * tempo;\n\t\tleapEvent[1] = leapEvent[0].ticksToEvent * tempo;\n\t\t//console.debug(\"swap:\", [front, back], offEvent, nextEvent, leapEvent);\n\n\t\tseq.splice(back, 1);\n\t\tseq.splice(front, 0, offEvent);\n\t});\n\n\treturn seq;\n};\n\n\n\nmodule.exports = {\n\tmidiToSequence,\n\ttrimSequence,\n\tfixOverlapNotes,\n};\n","\nconst MidiSequence = require(\"./MidiSequence.js\");\n\n\n\nconst PedalControllerTypes = {\n\t64: \"Sustain\",\n\t65: \"Portamento\",\n\t66: \"Sostenuto\",\n\t67: \"Soft\",\n};\n\n\n\nclass Notation {\n\tstatic parseMidi (data, {fixOverlap = true} = {}) {\n\t\tconst channelStatus = [];\n\t\tconst pedalStatus = {};\n\t\tconst pedals = {};\n\t\tconst channels = [];\n\t\tconst bars = [];\n\t\tlet time = 0;\n\t\tlet millisecondsPerBeat = 600000 / 120;\n\t\tlet beats = 0;\n\t\tlet numerator = 4;\n\t\tlet barIndex = 0;\n\t\tconst keyRange = {};\n\t\tlet rawTicks = 0;\n\t\tlet ticks = 0;\n\t\tlet correspondences;\n\t\tconst tempos = [];\n\n\t\tconst ticksPerBeat = data.header.ticksPerBeat;\n\n\t\tlet rawEvents = MidiSequence.midiToSequence(data);\n\n\t\tif (fixOverlap)\n\t\t\trawEvents = MidiSequence.trimSequence(MidiSequence.fixOverlapNotes(rawEvents));\n\n\t\tconst events = rawEvents.map(d => ({\n\t\t\tdata: d[0].event,\n\t\t\ttrack: d[0].track,\n\t\t\tdeltaTime: d[1],\n\t\t\tdeltaTicks: d[0].ticksToEvent,\n\t\t}));\n\n\t\tlet index = 0;\n\n\t\tconst ticksNormal = 1;\n\n\t\tfor (const ev of events) {\n\t\t\trawTicks += ev.deltaTicks;\n\t\t\tticks = Math.round(rawTicks * ticksNormal);\n\n\t\t\tif (ev.deltaTicks > 0) {\n\t\t\t\t// append bars\n\t\t\t\tconst deltaBeats = ev.deltaTicks / ticksPerBeat;\n\t\t\t\tfor (let b = Math.ceil(beats); b < beats + deltaBeats; ++b) {\n\t\t\t\t\tconst t = time + (b - beats) * millisecondsPerBeat;\n\t\t\t\t\tbars.push({time: t, index: barIndex % numerator});\n\n\t\t\t\t\t++barIndex;\n\t\t\t\t}\n\n\t\t\t\tbeats += deltaBeats;\n\t\t\t}\n\n\t\t\ttime += ev.deltaTime;\n\n\t\t\t//const ticksTime = beats * millisecondsPerBeat;\n\t\t\t//console.log(\"time:\", time, ticksTime, ticksTime - time);\n\n\t\t\tev.time = time;\n\t\t\tev.ticks = ticks;\n\n\t\t\tconst event = ev.data;\n\t\t\tswitch (event.type) {\n\t\t\tcase \"channel\":\n\t\t\t\t//channelStatus[event.channel] = channelStatus[event.channel] || [];\n\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"noteOn\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\t\t\t\t\t\t//channelStatus[event.channel][pitch] = {\n\t\t\t\t\t\tchannelStatus.push({\n\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\tstartTick: ticks,\n\t\t\t\t\t\t\tstart: time,\n\t\t\t\t\t\t\tvelocity: event.velocity,\n\t\t\t\t\t\t\tbeats: beats,\n\t\t\t\t\t\t\ttrack: ev.track,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tkeyRange.low = Math.min(keyRange.low || pitch, pitch);\n\n\t\t\t\t\t\tev.index = index;\n\t\t\t\t\t\t++index;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"noteOff\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\n\t\t\t\t\t\tchannels[event.channel] = channels[event.channel] || [];\n\n\t\t\t\t\t\tconst statusIndex = channelStatus.findIndex(status => status.channel == event.channel && status.pitch == pitch);\n\t\t\t\t\t\tif (statusIndex >= 0) {\n\t\t\t\t\t\t\tconst status = channelStatus.splice(statusIndex, 1)[0];\n\n\t\t\t\t\t\t\tchannels[event.channel].push({\n\t\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\t\tstartTick: status.startTick,\n\t\t\t\t\t\t\t\tendTick: ticks,\n\t\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\t\tstart: status.start,\n\t\t\t\t\t\t\t\tduration: time - status.start,\n\t\t\t\t\t\t\t\tvelocity: status.velocity,\n\t\t\t\t\t\t\t\tbeats: status.beats,\n\t\t\t\t\t\t\t\ttrack: status.track,\n\t\t\t\t\t\t\t\tfinger: status.finger,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tconsole.debug(\"unexpected noteOff: \", time, event);\n\n\t\t\t\t\t\tkeyRange.high = Math.max(keyRange.high || pitch, pitch);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"controller\":\n\t\t\t\t\tswitch (event.controllerType) {\n\t\t\t\t\t// pedal controllers\n\t\t\t\t\tcase 64:\n\t\t\t\t\tcase 65:\n\t\t\t\t\tcase 66:\n\t\t\t\t\tcase 67:\n\t\t\t\t\t\tconst pedalType = PedalControllerTypes[event.controllerType];\n\n\t\t\t\t\t\tpedalStatus[event.channel] = pedalStatus[event.channel] || {};\n\t\t\t\t\t\tpedals[event.channel] = pedals[event.channel] || [];\n\n\t\t\t\t\t\tconst status = pedalStatus[event.channel][pedalType];\n\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tpedals[event.channel].push({type: pedalType, start: status.start, duration: time - status.start, value: status.value});\n\t\t\t\t\t\tpedalStatus[event.channel][pedalType] = {start: time, value: event.value};\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase \"meta\":\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"setTempo\":\n\t\t\t\t\tmillisecondsPerBeat = event.microsecondsPerBeat / 1000;\n\t\t\t\t\t//beats = Math.round(beats);\n\t\t\t\t\t//console.assert(Number.isFinite(time), \"invalid time:\", time);\n\t\t\t\t\ttempos.push({tempo: event.microsecondsPerBeat, tick: ticks, time});\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"timeSignature\":\n\t\t\t\t\tnumerator = event.numerator;\n\t\t\t\t\tbarIndex = 0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text\":\n\t\t\t\t\tif (!correspondences && /^find-corres:/.test(event.text)) {\n\t\t\t\t\t\tconst captures = event.text.match(/:([\\d\\,-]+)/);\n\t\t\t\t\t\tconst str = captures && captures[1] || \"\";\n\t\t\t\t\t\tcorrespondences = str.split(\",\").map(s => Number(s));\n\t\t\t\t\t}\n\t\t\t\t\telse if (/fingering\\(.*\\)/.test(event.text)) {\n\t\t\t\t\t\tconst [_, fingers] = event.text.match(/\\((.+)\\)/);\n\t\t\t\t\t\tconst finger = Number(fingers);\n\t\t\t\t\t\tif (!Number.isNaN(finger)) {\n\t\t\t\t\t\t\tconst status = channelStatus[channelStatus.length - 1];\n\t\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\t\tstatus.finger = finger;\n\n\t\t\t\t\t\t\tconst event = events.find(e => e.index == index - 1);\n\t\t\t\t\t\t\tif (event)\n\t\t\t\t\t\t\t\tevent.data.finger = finger;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"copyrightNotice\":\n\t\t\t\t\tconsole.log(\"MIDI copyright:\", event.text);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tchannelStatus.forEach(status => {\n\t\t\tconsole.debug(\"unclosed noteOn event at\", status.startTick, status);\n\n\t\t\tchannels[status.channel].push({\n\t\t\t\tstartTick: status.startTick,\n\t\t\t\tendTick: ticks,\n\t\t\t\tpitch: status.pitch,\n\t\t\t\tstart: status.start,\n\t\t\t\tduration: time - status.start,\n\t\t\t\tvelocity: status.velocity,\n\t\t\t\tbeats: status.beats,\n\t\t\t\ttrack: status.track,\n\t\t\t\tfinger: status.finger,\n\t\t\t});\n\t\t});\n\n\t\treturn new Notation({\n\t\t\tchannels,\n\t\t\tkeyRange,\n\t\t\tpedals,\n\t\t\tbars,\n\t\t\tendTime: time,\n\t\t\tendTick: ticks,\n\t\t\tcorrespondences,\n\t\t\tevents,\n\t\t\ttempos,\n\t\t\tticksPerBeat,\n\t\t\tmeta: {},\n\t\t});\n\t}\n\n\n\tconstructor (fields) {\n\t\tObject.assign(this, fields);\n\n\t\t// channels to notes\n\t\tthis.notes = [];\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tfor (const note of channel)\n\t\t\t\t\tthis.notes.push(note);\n\t\t\t}\n\t\t}\n\t\tthis.notes.sort(function (n1, n2) {\n\t\t\treturn n1.start - n2.start;\n\t\t});\n\n\t\tfor (const i in this.notes)\n\t\t\tthis.notes[i].index = Number(i);\n\n\n\t\t// duration\n\t\tthis.duration = this.notes.length > 0 ? (this.endTime - this.notes[0].start) : 0,\n\n\t\t//this.endSoftIndex = this.notes.length ? this.notes[this.notes.length - 1].softIndex : 0;\n\n\n\t\t// pitch map\n\t\tthis.pitchMap = [];\n\t\tfor (const c in this.channels) {\n\t\t\tfor (const n in this.channels[c]) {\n\t\t\t\tconst pitch = this.channels[c][n].pitch;\n\t\t\t\tthis.pitchMap[pitch] = this.pitchMap[pitch] || [];\n\n\t\t\t\tthis.pitchMap[pitch].push(this.channels[c][n]);\n\t\t\t}\n\t\t}\n\n\t\tthis.pitchMap.forEach(notes => notes.sort((n1, n2) => n1.start - n2.start));\n\n\n\t\t/*// setup measure notes index\n\t\tif (this.measures) {\n\t\t\tconst measure_list = [];\n\n\t\t\tlet last_measure = null;\n\t\t\tconst measure_entries = Object.entries(this.measures).sort((e1, e2) => Number(e1[0]) - Number(e2[0]));\n\t\t\tfor (const [t, measure] of measure_entries) {\n\t\t\t\t//console.log(\"measure time:\", Number(t));\n\t\t\t\tmeasure.startTick = Number(t);\n\t\t\t\tmeasure.notes = [];\n\n\t\t\t\tif (last_measure)\n\t\t\t\t\tlast_measure.endTick = measure.startTick;\n\n\t\t\t\tconst m = measure.measure;\n\t\t\t\tmeasure_list[m] = measure_list[m] || [];\n\t\t\t\tmeasure_list[m].push(measure);\n\n\t\t\t\tlast_measure = measure;\n\t\t\t}\n\t\t\tif (last_measure)\n\t\t\t\tlast_measure.endTick = this.notes[this.notes.length - 1].endTick;\n\t\t\tfor (const i in this.notes) {\n\t\t\t\tconst note = this.notes[i];\n\t\t\t\tfor (const t in this.measures) {\n\t\t\t\t\tconst measure = this.measures[t];\n\t\t\t\t\tif (note.startTick >= measure.startTick && note.startTick < measure.endTick || note.endTick > measure.startTick && note.endTick <= measure.endTick)\n\t\t\t\t\t\tmeasure.notes.push(note);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.measure_list = measure_list;\n\t\t}*/\n\n\n\t\t// prepare beats info\n\t\tif (this.meta.beatInfos) {\n\t\t\tfor (let i = 0; i < this.meta.beatInfos.length; ++i) {\n\t\t\t\tconst info = this.meta.beatInfos[i];\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tconst lastInfo = this.meta.beatInfos[i - 1];\n\t\t\t\t\tinfo.beatIndex = lastInfo.beatIndex + Math.ceil((info.tick - lastInfo.tick) / this.ticksPerBeat);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tinfo.beatIndex = 0;\n\t\t\t}\n\t\t}\n\n\n\t\t// compute tempos tick -> time\n\t\t{\n\t\t\tlet time = 0;\n\t\t\tlet ticks = 0;\n\t\t\tlet tempo = 500000;\n\t\t\tfor (const entry of this.tempos) {\n\t\t\t\tconst deltaTicks = entry.tick - ticks;\n\t\t\t\ttime += (tempo / 1000) * deltaTicks / this.ticksPerBeat;\n\n\t\t\t\tticks = entry.tick;\n\t\t\t\ttempo = entry.tempo;\n\n\t\t\t\tentry.time = time;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfindChordBySoftindex (softIndex, radius = 0.8) {\n\t\treturn this.notes.filter(note => Math.abs(note.softIndex - softIndex) < radius);\n\t}\n\n\n\taverageTempo (tickRange) {\n\t\ttickRange = tickRange || {from: 0, to: this.endtick};\n\n\t\tconsole.assert(this.tempos, \"no tempos.\");\n\t\tconsole.assert(tickRange.to > tickRange.from, \"range is invalid:\", tickRange);\n\n\t\tconst span = index => {\n\t\t\tconst from = Math.max(tickRange.from, this.tempos[index].tick);\n\t\t\tconst to = (index < this.tempos.length - 1) ? Math.min(this.tempos[index + 1].tick, tickRange.to) : tickRange.to;\n\n\t\t\treturn Math.max(0, to - from);\n\t\t};\n\n\t\tconst tempo_sum = this.tempos.reduce((sum, tempo, index) => sum + tempo.tempo * span(index), 0);\n\n\t\tconst average = tempo_sum / (tickRange.to - tickRange.from);\n\n\t\t// convert microseconds per beat to beats per minute\n\t\treturn 60e+6 / average;\n\t}\n\n\n\tticksToTime (tick) {\n\t\tconsole.assert(Number.isFinite(tick), \"invalid tick value:\", tick);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.tick > tick);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.time + (tick - tempo.tick) * tempo.tempo * 1e-3 / this.ticksPerBeat;\n\t}\n\n\n\ttimeToTicks (time) {\n\t\tconsole.assert(Number.isFinite(time), \"invalid time value:\", time);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.time > time);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.tick + (time - tempo.time) * this.ticksPerBeat / (tempo.tempo * 1e-3);\n\t}\n\n\n\ttickRangeToTimeRange (tickRange) {\n\t\tconsole.assert(tickRange.to >= tickRange.from, \"invalid tick range:\", tickRange);\n\n\t\treturn {\n\t\t\tfrom: this.ticksToTime(tickRange.from),\n\t\t\tto: this.ticksToTime(tickRange.to),\n\t\t};\n\t}\n\n\n\t/*getMeasureRange (measureRange) {\n\t\tconsole.assert(Number.isInteger(measureRange.start) && Number.isInteger(measureRange.end), \"invalid measure range:\", measureRange);\n\t\tconsole.assert(this.measure_list && this.measure_list[measureRange.start] && this.measure_list[measureRange.end], \"no measure data for specific index:\", this.measure_list, measureRange);\n\n\t\tconst startMeasure = this.measure_list[measureRange.start][0];\n\t\tlet endMeasure = null;\n\t\tfor (const measure of this.measure_list[measureRange.end]) {\n\t\t\tif (measure.endTick > startMeasure.startTick) {\n\t\t\t\tendMeasure = measure;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// there no path between start measure and end measure.\n\t\tif (!endMeasure)\n\t\t\treturn null;\n\n\t\tconst tickRange = {from: startMeasure.startTick, to: endMeasure.endTick, duration: endMeasure.endTick - startMeasure.startTick};\n\t\tconst timeRange = this.tickRangeToTimeRange(tickRange);\n\t\ttimeRange.duration = timeRange.to - timeRange.from;\n\n\t\treturn {\n\t\t\ttickRange,\n\t\t\ttimeRange,\n\t\t};\n\t}*/\n\n\n\tscaleTempo ({factor, headTempo}) {\n\t\tconsole.assert(this.tempos && this.tempos.length, \"[Notation.scaleTempo] tempos is empty.\");\n\n\t\tif (headTempo)\n\t\t\tfactor = headTempo / this.tempos[0].tempo;\n\n\t\tconsole.assert(Number.isFinite(factor) && factor > 0, \"[Notation.scaleTempo] invalid factor:\", factor);\n\n\t\tthis.tempos.forEach(tempo => {\n\t\t\ttempo.tempo *= factor;\n\t\t\ttempo.time *= factor;\n\t\t});\n\t\tthis.events.forEach(event => {\n\t\t\tevent.deltaTime *= factor;\n\t\t\tevent.time *= factor;\n\t\t});\n\t\tthis.notes.forEach(note => {\n\t\t\tnote.start *= factor;\n\t\t\tnote.duration *= factor;\n\t\t});\n\n\t\tthis.endTime *= factor;\n\t}\n};\n\n\n\nmodule.exports = {\n\tNotation,\n};\n","\nconst { Notation } = require(\"./MusicNotation.js\");\n\n\n\n//const msDelay = ms => new Promise(resolve => setTimeout(resolve, ms));\nconst animationDelay = () => new Promise(resolve => requestAnimationFrame(resolve));\n\n\nclass MidiPlayer {\n\tconstructor (midiData, {cacheSpan = 600, onMidi, onPlayFinish, onTurnCursor} = {}) {\n\t\tthis.cacheSpan = cacheSpan;\n\t\tthis.onMidi = onMidi;\n\t\tthis.onPlayFinish = onPlayFinish;\n\t\tthis.onTurnCursor = onTurnCursor;\n\n\t\tlet notation;\n\t\tif (midiData.notes && Number.isFinite(midiData.endTime))\n\t\t\tnotation = midiData;\n\t\telse\n\t\t\tnotation = Notation.parseMidi(midiData);\n\n\t\tthis.notation = notation;\n\t\tthis.events = notation.events;\n\t\t//console.log(\"events:\", this.events);\n\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t\tthis.startTime = performance.now();\n\t\tthis.duration = notation.endTime;\n\t\tthis.cursorTurnDelta = 0;\n\n\t\tconsole.assert(notation.tempos && notation.tempos.length, \"[MidiPlayer] invalid notation, tempos is empty.\");\n\t}\n\n\n\tdispose () {\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t}\n\n\n\tget progressTicks () {\n\t\treturn this.notation.timeToTicks(this.progressTime);\n\t}\n\n\n\tset progressTicks (value) {\n\t\tthis.progressTime = this.notation.ticksToTime(value);\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(this.progressTime);\n\t}\n\n\n\tasync play ({nextFrame = animationDelay} = {}) {\n\t\tif (this.progressTime >= this.duration)\n\t\t\tthis.progressTime = 0;\n\n\t\tlet now = performance.now();\n\t\tthis.startTime = now - this.progressTime;\n\n\t\tthis.isPlaying = true;\n\n\t\tlet currentEventIndex = this.events.findIndex(event => event.time >= now - this.startTime);\n\n\t\twhile (this.isPlaying) {\n\t\t\tfor (; currentEventIndex < this.events.length; ++currentEventIndex) {\n\t\t\t\tconst event = this.events[currentEventIndex];\n\t\t\t\t//console.log(\"play event:\", currentEventIndex, event.time, this.progressTime + this.cacheSpan);\n\t\t\t\tif (!event || event.time > this.progressTime + this.cacheSpan)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif (event.data.type === \"channel\" && this.startTime + event.time >= now)\n\t\t\t\t\tif (this.onMidi)\n\t\t\t\t\t\tthis.onMidi(event.data, this.startTime + event.time);\n\t\t\t}\n\n\t\t\tawait nextFrame();\n\n\t\t\tif (!this.isPlaying)\n\t\t\t\tbreak;\n\n\t\t\tif (this.cursorTurnDelta !== 0) {\n\t\t\t\tconst backturn = this.cursorTurnDelta < 0;\n\n\t\t\t\tthis.startTime -= this.cursorTurnDelta;\n\t\t\t\tthis.cursorTurnDelta = 0;\n\n\t\t\t\tif (backturn) {\n\t\t\t\t\tfor (; currentEventIndex > 0; --currentEventIndex) {\n\t\t\t\t\t\tconst eventTime = this.events[currentEventIndex].time;\n\t\t\t\t\t\tif (this.startTime + eventTime < now)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnow = performance.now();\n\n\t\t\tthis.progressTime = now - this.startTime;\n\n\t\t\tif (this.progressTime > this.duration) {\n\t\t\t\tthis.isPlaying = false;\n\n\t\t\t\tif (this.onPlayFinish)\n\t\t\t\t\tthis.onPlayFinish();\n\t\t\t}\n\t\t}\n\t}\n\n\n\tpause () {\n\t\tthis.isPlaying = false;\n\t}\n\n\n\tturnCursor (time) {\n\t\t//console.log(\"onTurnCursor:\", time, oldTime);\n\t\tif (this.isPlaying)\n\t\t\tthis.cursorTurnDelta += time - this.progressTime;\n\t\telse\n\t\t\tthis.progressTime = time;\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(time);\n\t}\n};\n\n\n\nmodule.exports = MidiPlayer;\n","\nmodule.exports = {\n\tCostStepAttenuation: 0.6,\n\tSkipDeep: 3,\n\tPriorDistanceSigmoidFactor: 0.1,\n\tPriorValueSigmoidFactor: 0.12,\n\n\tSkipCost: 0.5,\n\tLagOffsetCost: 1,\n\tLeadOffsetCost: 1.6,\n\tZeroOffsetCost: 0.58,\n\n\tRelocationThreshold: 6,\n};\n","\nconst {pick} = require(\"lodash\");\n\nconst Config = require(\"./config.js\");\n\n\n\nclass Node {\n\tconstructor (s_note, c_note) {\n\t\tthis.s_note = s_note;\n\t\tthis.c_note = c_note;\n\n\t\tconsole.assert(this.s_note.softIndex != null, \"s_note softIndex is null\");\n\t\tthis.offset = this.s_note.softIndex - this.c_note.softIndex;\n\n\t\tthis._prev = null;\n\t\tthis._totalCost = 0;\n\t\tthis._value = 0;\n\t\tthis.cacheDirty = true;\n\n\t\t//this.evaluatePrev(Node.Zero);\n\t}\n\n\n\tget prev () {\n\t\treturn this._prev;\n\t}\n\n\n\tset prev (value) {\n\t\tif (value != this._prev) {\n\t\t\tthis._prev = value;\n\t\t\tthis.cacheDirty = true;\n\t\t}\n\t}\n\n\n\tget si () {\n\t\treturn this.s_note.index;\n\t}\n\n\n\tget ci () {\n\t\treturn this.c_note.index;\n\t}\n\n\n\tget root () {\n\t\treturn this.prev.root || this;\n\t}\n\n\n\tget rootSi () {\n\t\treturn !this.prev.zero ? this.prev.rootSi : this.si;\n\t}\n\n\n\tget id () {\n\t\treturn `${this.s_note.index},${this.c_note.index}`;\n\t}\n\n\n\tstatic cost (prev, skip, self) {\n\t\treturn prev * Config.CostStepAttenuation + Math.tanh(skip * Config.SkipCost) + Math.tanh(self * 0.5);\n\t}\n\n\n\tupdateCache () {\n\t\tif (this.cacheDirty) {\n\t\t\tthis._totalCost = Node.cost(this.prev.totalCost, this.si - this.prev.si - 1, this.selfCost);\n\t\t\tthis._value = this.prev.value + 1 - Math.tanh(this.selfCost * 0.5);\n\n\t\t\tthis.cacheDirty = false;\n\t\t}\n\t}\n\n\n\tget totalCost () {\n\t\tthis.updateCache();\n\n\t\treturn this._totalCost;\n\t}\n\n\n\tget value () {\n\t\tthis.updateCache();\n\n\t\treturn this._value;\n\t}\n\n\n\tget deep () {\n\t\treturn this.prev.deep + 1;\n\t}\n\n\n\tget path () {\n\t\tconst path = [];\n\t\tfor (let node = this; !node.zero; node = node.prev) {\n\t\t\tpath[node.si] = node.ci;\n\t\t}\n\n\t\tfor (let i = 0; i < path.length; ++i)\n\t\t\tif (typeof path[i] != \"number\")\n\t\t\t\tpath[i] = -1;\n\n\t\treturn path;\n\t}\n\n\n\tdump () {\n\t\treturn pick(this, [\"id\", \"si\", \"ci\", \"rootSi\", \"value\", \"deep\", \"rootSi\", \"offset\", \"prior\", \"selfCost\", \"totalCost\"]);\n\t}\n\n\n\tevaluatePrev (node) {\n\t\tconst cost = this.evaluatePrevCost(node);\n\n\t\tconsole.assert(this.si - node.si >= 1, \"node index error:\", this, node/*, {get [Symbol.toStringTag]() {debugger}}*/);\n\t\t//if (this.si - node.si < 1)\n\t\t//\tdebugger;\n\n\t\tconst totalCost = Node.cost(node.totalCost, this.si - node.si - 1, cost);\n\n\t\tif (!this.prev || totalCost < this.totalCost) {\n\t\t\tthis.prev = node;\n\t\t\tthis.selfCost = cost;\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tevaluatePrevCost (node) {\n\t\tlet cost = 0;\n\n\t\tif (node.offset != null) {\n\t\t\tconst bias = this.offset - node.offset;\n\t\t\tconst costCoeff = node.zero ? Config.ZeroOffsetCost : (bias > 0 ? Config.LagOffsetCost : Config.LeadOffsetCost);\n\t\t\tcost += (bias * costCoeff) ** 2;\n\t\t}\n\n\t\treturn cost;\n\t}\n\n\n\tpriorByOffset (offset) {\n\t\tconst distance = Math.abs(this.offset - offset) / 1;//(this.s_note.deltaSi + 0.04);\n\n\t\treturn Math.tanh(this.value * Config.PriorValueSigmoidFactor) - Math.tanh(distance * Config.PriorDistanceSigmoidFactor);\n\t\t//return Math.log(this.value) * Math.tanh(4 / distance);\n\t\t//return this.value - distance;\n\t}\n\n\n\tstatic zero () {\n\t\treturn {\n\t\t\tzero: true,\n\t\t\ttotalCost: 0,\n\t\t\tvalue: 0,\n\t\t\tsi: -1,\n\t\t\tci: -1,\n\t\t\tdeep: 0,\n\t\t\toffset: 0,\n\t\t};\n\t}\n};\n\n\n\nmodule.exports = Node;\n","\nconst Config = require(\"./config.js\");\nconst Node = require(\"./node.js\");\n\n\n\nclass Navigator {\n\tconstructor (criterion, sample, options = {}) {\n\t\tthis.criterion = criterion;\n\t\tthis.sample = sample;\n\n\t\tthis.getCursorOffset = options.getCursorOffset || (() => null);\n\t\tthis.outOfPage = options.outOfPage;\n\n\t\tthis.bestNode = null;\n\t\tthis.fineCursor = null;\n\n\t\tthis.breakingSI = sample.notes.length - 1;\n\n\t\tthis.zeroNode = Node.zero();\n\t\tthis.zeroNode.offset = this.getCursorOffset() || 0;\n\n\t\tthis.relocationThreshold = options.relocationThreshold || Config.RelocationThreshold;\n\t}\n\n\n\tstep (index) {\n\t\t//console.log(\"step:\", this.zeroNode.offset);\n\t\tconst note = this.sample.notes[index];\n\n\t\tif (note.matches.length > 0) {\n\t\t\t//console.log(\"zeroNode.offset:\", index, this.zeroNode.offset);\n\t\t\tnote.matches.forEach(node => {\n\t\t\t\tnode.evaluatePrev(this.zeroNode);\n\t\t\t\t//console.log(\"node:\", node, node.evaluatePrevCost(this.zeroNode), node.offset, this.zeroNode.offset);\n\n\t\t\t\tfor (let si = index - 1; si >= Math.max(this.breakingSI + 1, index - Config.SkipDeep); --si) {\n\t\t\t\t\t//const skipCost = Config.SkipCost * (index - 1 - si);\n\n\t\t\t\t\tconst prevNote = this.sample.notes[si];\n\t\t\t\t\tconsole.assert(prevNote, \"prevNote is null:\", si, index, this.sample.notes);\n\t\t\t\t\tprevNote.matches.forEach(prevNode => {\n\t\t\t\t\t\tconst bias = node.offset - prevNode.offset;\n\t\t\t\t\t\tif (/*prevNode.totalCost + skipCost < node.totalCost\n\t\t\t\t\t\t\t&&*/ (bias < 2 / Config.LagOffsetCost && bias > -2 / Config.LeadOffsetCost))\n\t\t\t\t\t\t\tnode.evaluatePrev(prevNode);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tnode.prior = node.totalCost > 1.99 ? -1 : node.priorByOffset(this.zeroNode.offset);\n\n\t\t\t\tif (node.prior > 0 && this.outOfPage) {\n\t\t\t\t\tconst tick = this.criterion.notes[node.ci].startTick;\n\t\t\t\t\tif (this.outOfPage(tick))\n\t\t\t\t\t\tnode.prior -= 0.7;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tnote.matches.sort((c1, c2) => c2.prior - c1.prior);\n\t\t\tthis.cursors = note.matches;\n\t\t\t//console.log(\"navigator cursors:\", this.cursors);\n\n\t\t\tlet fineCursor = null;\n\t\t\tconst nullLength = this.nullSteps(index);\n\n\t\t\tconst cursor = this.cursors[0];\n\t\t\tif (cursor && cursor.totalCost < 1) {\n\t\t\t\t//console.log(\"nullLength:\", nullLength, nullLength * Math.log(cursor.value / 4));\n\t\t\t\tif (cursor.prior > 0 || (cursor.totalCost < 0.4 && Math.log(Math.max(nullLength * cursor.value, 1e-3)) > this.relocationThreshold)) {\n\t\t\t\t\tthis.zeroNode.offset = cursor.offset;\n\n\t\t\t\t\tfineCursor = cursor;\n\n\t\t\t\t\tif (!this.bestNode || cursor.value > this.bestNode.value)\n\t\t\t\t\t\tthis.bestNode = cursor;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fineCursor)\n\t\t\t\tthis.fineCursor = fineCursor;\n\t\t\telse {\n\t\t\t\tif (!this.resetCursor(index, {breaking: false/*nullLength > Config.SkipDeep*/})) {\n\t\t\t\t\tthis.zeroNode.offset += note.deltaSi * Math.tanh(nullLength);\n\t\t\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", note.deltaSi, nullLength);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tthis.cursors = [];\n\t}\n\n\n\tpath ({fromIndex = 0, toIndex = this.sample.notes.length - 1} = {}) {\n\t\tconst path = [];\n\n\t\tlet offset = null;\n\n\t\tfor (let si = toIndex; si >= fromIndex;) {\n\t\t\tconst note = this.sample.notes[si];\n\n\t\t\tif (!note.matches.length || note.matches[0].prior < -0.01 || note.matches[0].totalCost >= 1) {\n\t\t\t\t//if (note.matches.length)\n\t\t\t\t//\tconsole.log(\"path -1:\", si, note.matches[0].prior, note.matches[0].totalCost);\n\t\t\t\tpath[si] = -1;\n\t\t\t\t--si;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// sort nodes by backwards heuristic offset\n\t\t\tif (offset != null) {\n\t\t\t\tnote.matches.forEach(node => node.backPrior = (node.totalCost < 1.99 ? node.priorByOffset(offset) : -1));\n\t\t\t\tnote.matches.sort((n1, n2) => n2.backPrior - n1.backPrior);\n\t\t\t}\n\n\t\t\tconst node = note.matches[0];\n\t\t\tnode.path.forEach((ci, si) => path[si] = ci);\n\t\t\t//console.log(\"node path:\", si, node.path);\n\n\t\t\toffset = node.root.offset;\n\n\t\t\tsi = node.rootSi - 1;\n\t\t}\n\n\t\tconsole.assert(path.length == toIndex + 1, \"path length error:\", path, fromIndex, toIndex + 1,\n\t\t\tthis.sample.notes.length, this.sample.notes.length ? this.sample.notes[this.sample.notes.length - 1].index : null);\n\n\t\treturn path;\n\t}\n\n\n\tnullSteps (index) {\n\t\treturn index - (this.fineCursor ? this.fineCursor.si : -1) - 1;\n\t}\n\n\n\tresetCursor (index, {breaking = true} = {}) {\n\t\tif (breaking)\n\t\t\tthis.breakingSI = index;\n\n\t\tconst cursorOffset = this.getCursorOffset();\n\t\tif (cursorOffset != null) {\n\t\t\t//console.log(\"cursorOffset:\", cursorOffset);\n\n\t\t\tthis.zeroNode.offset = cursorOffset;\n\t\t\t//this.breaking = this.nullSteps(index) > Config.SkipDeep;\n\t\t\t//if (this.breaking)\t// trivial zero node si resets result in focus path interruption\n\t\t\tthis.zeroNode.si = index;\n\t\t\tthis.fineCursor = null;\n\n\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", cursorOffset);\n\t\t\t//console.log(\"cursor offset reset:\", cursorOffset);\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tget relocationTendency () {\n\t\tconst cursor = this.cursors && this.cursors[0];\n\t\tif (!cursor)\n\t\t\treturn null;\n\n\t\tconst nullLength = this.nullSteps(cursor.si);\n\t\tif (nullLength <= 0)\n\t\t\treturn 0;\n\n\t\treturn Math.log(Math.max(nullLength * cursor.value, 1e-3)) / this.relocationThreshold;\n\t}\n};\n\n\n\nmodule.exports = Navigator;\n","\nconst Node = require(\"./node.js\");\nconst Navigator = require(\"./navigator.js\");\n\n\n\nconst HEART_BEAT = 800;\t// in ms\nconst SIMULTANEOUS_INTERVAL = HEART_BEAT * 0.24;\n\n\nconst normalizeInterval = interval => Math.tanh(interval / SIMULTANEOUS_INTERVAL);\n\n\n// greater softIndexFactor make 'harder' soft index\nconst makeNoteSoftIndex = function (notes, index, {softIndexFactor = 1} = {}) {\n\tindex = Number(index);\n\n\tconst note = notes[index];\n\n\t// make soft index\n\tif (index > 0) {\n\t\tconst lastNote = notes[index - 1];\n\n\t\tconsole.assert(note.start != null, \"note.start is null\", note);\n\t\tconsole.assert(lastNote.start != null, \"lastNote.start is null\", lastNote);\n\n\t\tnote.deltaSi = normalizeInterval((note.start - lastNote.start) * softIndexFactor);\n\t\tnote.softIndex = lastNote.softIndex + note.deltaSi;\n\n\t\tconsole.assert(!Number.isNaN(note.deltaSi), \"note.deltaSi is NaN.\", note.start, lastNote.start);\n\t}\n\telse {\n\t\tnote.softIndex = 0;\n\t\tnote.deltaSi = 0;\n\t}\n};\n\n\nconst makeMatchNodes = function (note, criterion, zeroNode = Node.zero()) {\n\tnote.matches = [];\n\n\tconst targetList = criterion.pitchMap[note.pitch];\n\tif (targetList) {\n\t\tfor (const targetNote of targetList) {\n\t\t\tconst node = new Node(note, targetNote);\n\t\t\tif (zeroNode)\n\t\t\t\tnode.evaluatePrev(zeroNode);\n\n\t\t\tnote.matches.push(node);\n\t\t}\n\t}\n};\n\n\nconst genNotationContext = function (notation, {softIndexFactor = 1} = {}) {\n\tfor (let i = 0; i < notation.notes.length; ++i)\n\t\tmakeNoteSoftIndex(notation.notes, i, {softIndexFactor});\n};\n\n\nconst runNavigation = async function(criterion, sample, onStep) {\n\tconst navigator = new Navigator(criterion, sample);\n\tnavigator.resetCursor(-1);\n\n\tfor (let i = 0; i < sample.notes.length; ++i) {\n\t\tnavigator.step(i);\n\n\t\tconst next = await (onStep && onStep(i, navigator));\n\t\tif (next === Symbol.for(\"end\")) {\n\t\t\tconsole.log(\"Navigation interrupted.\");\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t//console.log(\"Navigation accomplished.\");\n\n\treturn navigator;\n};\n\n\n\nmodule.exports = {\n\tnormalizeInterval,\n\tmakeNoteSoftIndex,\n\tmakeMatchNodes,\n\tgenNotationContext,\n\trunNavigation,\n\tNavigator,\n\tNode,\n};\n","\nconst MIDI = require(\"./MIDI\");\n\n\n\nconst trackDeltaToAbs = events => {\n\tlet tick = 0;\n\n\tevents.forEach(event => {\n\t\ttick += event.deltaTime;\n\t\tevent.tick = tick;\n\t});\n};\n\n\nconst trackAbsToDelta = events => {\n\tlet lastTick = 0;\n\n\tevents.sort((e1, e2) => e1.tick - e2.tick).forEach(event => {\n\t\tevent.deltaTime = event.tick - lastTick;\n\t\tlastTick = event.tick;\n\t});\n};\n\n\nconst sliceTrack = (track, startTick, endTick) => {\n\ttrackDeltaToAbs(track);\n\n\tconst events = [];\n\tconst status = {};\n\n\ttrack.forEach(event => {\n\t\tif (event.tick >= startTick && event.tick <= endTick && event.subtype !== \"endOfTrack\")\n\t\t\tevents.push({\n\t\t\t\t...event,\n\t\t\t\ttick: event.tick - startTick,\n\t\t\t});\n\t\telse if (event.tick < startTick) {\n\t\t\tswitch (event.type) {\n\t\t\tcase \"meta\":\n\t\t\t\tstatus[event.subtype] = event;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t});\n\n\tObject.values(status).forEach(event => events.push({\n\t\t...event,\n\t\ttick: 0,\n\t}));\n\n\tevents.push({\n\t\ttick: endTick - startTick,\n\t\ttype: \"meta\",\n\t\tsubtype: \"endOfTrack\",\n\t});\n\n\ttrackAbsToDelta(events);\n\n\treturn events;\n};\n\n\nconst sliceMidi = (midi, startTick, endTick) => ({\n\theader: midi.header,\n\ttracks: midi.tracks.map(track => sliceTrack(track, startTick, endTick)),\n});\n\n\nconst TICKS_PER_BEATS = 480;\n\nconst EXCLUDE_MIDI_EVENT_SUBTYPES = [\n\t\"endOfTrack\", \"trackName\",\n\t\"noteOn\", \"noteOff\",\n];\n\n\nfunction encodeToMIDIData(notation, {startTime, unclosedNoteDuration = 30e+3} = {}) {\n\tnotation.microsecondsPerBeat = notation.microsecondsPerBeat || 500000;\n\n\tconst ticksPerBeat = TICKS_PER_BEATS;\n\tconst msToTicks = ticksPerBeat * 1000 / notation.microsecondsPerBeat;\n\n\tconst header = { formatType: 0, ticksPerBeat };\n\tconst track = [];\n\n\tif (!Number.isFinite(startTime)) {\n\t\tif (!notation.notes || !notation.notes[0])\n\t\t\tthrow new Error(\"encodeToMidiData: no start time specificed\");\n\n\t\tstartTime = notation.notes[0].start;\n\t}\n\n\ttrack.push({ time: startTime, type: \"meta\", subtype: \"copyrightNotice\", text: `Composed by MusicWdigets. BUILT on ${new Date(Number(process.env.VUE_APP_BUILD_TIME)).toDateString()}` });\n\n\tconst containsTempo = notation.events && notation.events.find(event => event.subtype == \"setTempo\");\n\tif (!containsTempo) {\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"timeSignature\", numerator: 4, denominator: 4, thirtyseconds: 8 });\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"setTempo\", microsecondsPerBeat: notation.microsecondsPerBeat });\n\t}\n\n\t//if (notation.correspondences)\n\t//\ttrack.push({ time: startTime, type: \"meta\", subtype: \"text\", text: \"find-corres:\" + notation.correspondences.join(\",\") });\n\n\tlet endTime = startTime || 0;\n\n\tif (notation.notes) {\n\t\tfor (const note of notation.notes) {\n\t\t\ttrack.push({\n\t\t\t\ttime: note.start,\n\t\t\t\ttype: \"channel\",\n\t\t\t\tsubtype: \"noteOn\",\n\t\t\t\tchannel: note.channel || 0,\n\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\tvelocity: note.velocity,\n\t\t\t\tfinger: note.finger,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, note.start);\n\n\t\t\tif (Number.isFinite(unclosedNoteDuration))\n\t\t\t\tnote.duration = note.duration || unclosedNoteDuration;\n\t\t\tif (note.duration) {\n\t\t\t\ttrack.push({\n\t\t\t\t\ttime: note.start + note.duration,\n\t\t\t\t\ttype: \"channel\",\n\t\t\t\t\tsubtype: \"noteOff\",\n\t\t\t\t\tchannel: note.channel || 0,\n\t\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\t\tvelocity: 0,\n\t\t\t\t});\n\n\t\t\t\tendTime = Math.max(endTime, note.start + note.duration);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (notation.events) {\n\t\tconst events = notation.events.filter(event => !EXCLUDE_MIDI_EVENT_SUBTYPES.includes(event.data.subtype));\n\t\tfor (const event of events) {\n\t\t\ttrack.push({\n\t\t\t\ttime: event.time,\n\t\t\t\t...event.data,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, event.time);\n\t\t}\n\t}\n\n\ttrack.push({ time: endTime + 100, type: \"meta\", subtype: \"endOfTrack\" });\n\n\ttrack.sort(function (e1, e2) { return e1.time - e2.time; });\n\n\t// append finger event after every noteOn event\n\ttrack.map((event, index) => ({event, index}))\n\t\t.filter(({event}) => event.subtype == \"noteOn\" && event.finger != null)\n\t\t.reverse()\n\t\t.forEach(({event, index}) => track.splice(index + 1, 0, {\n\t\t\ttime: event.time,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `fingering(${event.finger})`,\n\t\t}));\n\n\ttrack.forEach(event => event.ticks = Math.round((event.time - startTime) * msToTicks));\n\ttrack.forEach((event, i) => event.deltaTime = (event.ticks - (i > 0 ? track[i - 1].ticks : 0)));\n\n\treturn {header, tracks: [track]};\n};\n\n\nfunction encodeToMIDI(notation, options) {\n\tconst data = encodeToMIDIData(notation, options);\n\treturn MIDI.encodeMidiFile(data);\n};\n\n\n\nmodule.exports = {\n\tsliceMidi,\n\tencodeToMIDIData,\n\tencodeToMIDI,\n};\n","\nconst MIDI = require(\"./source/inc/MIDI\");\nconst MusicNotation = require(\"./source/inc/MusicNotation\");\nconst MidiPlayer = require(\"./source/inc/MidiPlayer.js\");\nconst Matcher = require(\"./source/inc/Matcher\");\nconst MidiUtils = require(\"./source/inc/MidiUtils.js\");\n\n\n\nmodule.exports = {\n\tMIDI,\n\tMusicNotation,\n\tMidiPlayer,\n\tMatcher,\n\tMidiUtils,\n};\n","import pick from 'lodash/pick';\n\nimport { MusicNotation, MIDI } from '@k-l-lambda/music-widgets';\n\n//import {MeasureLayout, LayoutType} from\nimport { ImplicitType, ChordPosition } from './types';\n\nconst WHOLE_DURATION_MAGNITUDE = 1920;\nconst TICKS_PER_BEAT = WHOLE_DURATION_MAGNITUDE / 4;\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ninterface StaffNoteProperties {\n\trest: boolean;\n\ttied: boolean;\n\toverlapped: boolean;\n\timplicitType: ImplicitType;\n\tafterGrace: boolean;\n\tchordPosition: ChordPosition;\n\tdivision: number;\n\n\tcontextIndex: number;\n\tstaffTrack: number;\n}\n\ninterface MetaNote extends MusicNotation.Note, Partial {\n\tid: string;\n\tmeasure: number;\n\tendTick: number;\n}\n\ninterface SubNote {\n\tstartTick: number;\n\tendTick: number;\n\tpitch: number;\n\tvelocity?: number;\n}\n\ninterface MeasureNote extends Partial {\n\ttick: number;\n\tpitch: number;\n\tduration: number;\n\tchordPosition: ChordPosition;\n\tstaff: number;\n\n\ttrack: number;\n\tchannel: number;\n\tid: string;\n\tids: string[];\n\n\tsubNotes: SubNote[];\n}\n\ninterface MeasureEvent {\n\tdata: any;\n\ttrack: number;\n\tticks?: number;\n}\n\ninterface Measure {\n\ttick: number;\n\tduration: number;\n\n\tnotes: MeasureNote[];\n\tevents?: MeasureEvent[];\n\ttimeSignature?: Fraction;\n\tkeySignature?: number;\n}\n\ninterface PerformOptions {\n\twithRestTied?: boolean;\n}\n\ninterface MidiEvent extends MIDI.MidiEvent {\n\tticks?: number;\n\tmeasure?: number;\n\tids?: string[];\n\tstaffTrack?: number;\n\tstaff?: number;\n}\ntype MidiTrack = MidiEvent[];\n\nconst EXTRA_NOTE_FIELDS = ['rest', 'tied', 'overlapped', 'implicitType', 'afterGrace', 'contextIndex', 'staffTrack', 'chordPosition', 'division'];\nconst COMMON_NOTE_FIELDS = ['id', 'ids', 'pitch', 'velocity', 'track', 'channel', ...EXTRA_NOTE_FIELDS];\n\nclass MetaNotation {\n\t//pitchContextGroup: PitchContextTable[];\n\t//measureLayout: MeasureLayout;\n\tmeasures: Measure[];\n\n\ttrackNames: string[];\n\tidTrackMap: { [key: string]: number };\n\n\tripe: boolean = false;\n\n\tstatic fromAbsoluteNotes(notes: MetaNote[], measureHeads: number[], data?: Partial): MetaNotation {\n\t\tconst notation = new MetaNotation(data);\n\n\t\tnotation.measures = Array(measureHeads.length)\n\t\t\t.fill(null)\n\t\t\t.map((__, i) => {\n\t\t\t\tconst tick = measureHeads[i];\n\t\t\t\tconst duration = measureHeads[i + 1] ? measureHeads[i + 1] - tick : 0;\n\n\t\t\t\tconst mnotes = notes\n\t\t\t\t\t.filter((note) => note.measure === i + 1)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(note) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\ttick: note.startTick - tick,\n\t\t\t\t\t\t\t\tduration: note.endTick - note.startTick,\n\t\t\t\t\t\t\t\t...pick(note, COMMON_NOTE_FIELDS),\n\t\t\t\t\t\t\t\tsubNotes: [],\n\t\t\t\t\t\t\t} as MeasureNote)\n\t\t\t\t\t);\n\n\t\t\t\t// reduce note data size\n\t\t\t\tmnotes.forEach((mn) =>\n\t\t\t\t\t['rest', 'tied', 'implicitType', 'afterGrace'].forEach((field) => {\n\t\t\t\t\t\tif (!mn[field]) delete mn[field];\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes: mnotes,\n\t\t\t\t};\n\t\t\t});\n\n\t\tnotation.idTrackMap = notes.reduce((map, note) => {\n\t\t\tif (note.id) map[note.id] = note.track;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn notation;\n\t}\n\n\tstatic performAbsoluteNotes(abNotes: MetaNote[], { withRestTied = false }: PerformOptions = {}): MusicNotation.Note[] {\n\t\tconst notes = abNotes\n\t\t\t.filter((note) => (withRestTied || (!note.rest && !note.tied)) && !note.overlapped)\n\t\t\t.map((note) => ({\n\t\t\t\tmeasure: note.measure,\n\t\t\t\tchannel: note.channel,\n\t\t\t\ttrack: note.track,\n\t\t\t\tstart: note.start,\n\t\t\t\tstartTick: note.startTick,\n\t\t\t\tendTick: note.endTick,\n\t\t\t\tpitch: note.pitch,\n\t\t\t\tduration: note.duration,\n\t\t\t\tvelocity: note.velocity || 127,\n\t\t\t\tid: note.id,\n\t\t\t\tids: note.ids,\n\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\tcontextIndex: note.contextIndex,\n\t\t\t\timplicitType: note.implicitType,\n\t\t\t\tchordPosition: note.chordPosition,\n\t\t\t}));\n\n\t\tconst noteMap = notes.reduce((map, note) => {\n\t\t\tconst key = `${note.channel}|${note.start}|${note.pitch}`;\n\t\t\tconst priorNote = map[key];\n\t\t\tif (priorNote) priorNote.ids.push(...note.ids);\n\t\t\telse map[key] = note;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(noteMap);\n\t}\n\n\tconstructor(data?: Partial) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\t/*get ordinaryMeasureIndices (): number[] {\n\t\tif (this.measureLayout)\n\t\t\treturn this.measureLayout.serialize(LayoutType.Ordinary);\n\n\t\treturn Array(this.measures.length).fill(null).map((_, i) => i + 1);\n\t}*/\n\n\t// In Lilypond 2.20.0, minus tick value at the head of a track result in MIDI event time bias,\n\t//\tSo store the bias values to correct MIDI time from lilyond.\n\tget trackTickBias(): { [key: string]: number } {\n\t\tconst headMeasure = this.measures[0];\n\t\treturn this.trackNames.reduce((map, name, track) => {\n\t\t\tmap[name] = 0;\n\t\t\tif (headMeasure) {\n\t\t\t\tconst note = headMeasure.notes.find((note) => note.track === track);\n\t\t\t\tif (note) map[name] = Math.min(note.tick, 0);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget idSet(): Set {\n\t\treturn this.measures.reduce(\n\t\t\t(set, measure) => (measure.notes.filter((note) => !note.rest).forEach((note) => note.ids.forEach((id) => set.add(id))), set),\n\t\t\tnew Set()\n\t\t);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\t__prototype: 'LilyNotation',\n\t\t\t//pitchContextGroup: this.pitchContextGroup,\n\t\t\t//measureLayout: this.measureLayout,\n\t\t\tmeasures: this.measures,\n\t\t\tidTrackMap: this.idTrackMap,\n\t\t\ttrackNames: this.trackNames,\n\t\t\tripe: this.ripe,\n\t\t};\n\t}\n\n\ttoAbsoluteNotes(measureIndices: number[] /*= this.ordinaryMeasureIndices*/): MetaNote[] {\n\t\tlet measureTick = 0;\n\t\tconst measureNotes: MetaNote[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst notes = measure.notes.map((mnote) => {\n\t\t\t\treturn {\n\t\t\t\t\tstartTick: measureTick + mnote.tick,\n\t\t\t\t\tendTick: measureTick + mnote.tick + mnote.duration,\n\t\t\t\t\tstart: measureTick + mnote.tick,\n\t\t\t\t\tduration: mnote.duration,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t\t...pick(mnote, COMMON_NOTE_FIELDS),\n\t\t\t\t} as MetaNote;\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn notes;\n\t\t});\n\n\t\treturn [].concat(...measureNotes);\n\t}\n\n\t/*getMeasureIndices (type: LayoutType) {\n\t\treturn this.measureLayout.serialize(type);\n\t}*/\n\n\ttoPerformingNotation(measureIndices: number[] /*= this.ordinaryMeasureIndices*/, options: PerformOptions = {}): MusicNotation.Notation {\n\t\t//console.debug(\"toPerformingNotation:\", this, measureIndices);\n\t\tconst abNotes = this.toAbsoluteNotes(measureIndices);\n\t\tconst notes = MetaNotation.performAbsoluteNotes(abNotes, options);\n\n\t\t//const lastNote = notes[notes.length - 1];\n\t\tconst endTime = Math.max(...notes.map((note) => note.start + note.duration));\n\n\t\tconst endTick = measureIndices.reduce((tick, index) => tick + this.measures[index - 1].duration, 0);\n\n\t\tconst notation = new MusicNotation.Notation({\n\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\tmeta: {},\n\t\t\ttempos: [], // TODO\n\t\t\tchannels: [notes],\n\t\t\tendTime,\n\t\t\tendTick,\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\ttoPerformingMIDI(measureIndices: number[], { trackList }: { trackList?: boolean[] } = {}): MIDI.MidiData & { zeroTick: number } {\n\t\tif (!measureIndices.length) return null;\n\n\t\t// to avoid begin minus tick\n\t\tconst zeroTick = -Math.min(0, ...(this.measures[0]?.events.map((e) => e.ticks) || []), ...(this.measures[0]?.notes.map((note) => note.tick) || []));\n\n\t\tlet measureTick = zeroTick;\n\t\tconst measureEvents: MeasureEvent[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst events = measure.events.map((mevent) => ({\n\t\t\t\tticks: measureTick + mevent.ticks,\n\t\t\t\ttrack: mevent.track,\n\t\t\t\tdata: {\n\t\t\t\t\t...mevent.data,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn events;\n\t\t});\n\n\t\tconst eventPriority = (event: MidiEvent): number => event.ticks + (event.subtype === 'noteOff' ? -1e-8 : 0);\n\n\t\tconst tracks: MidiTrack[] = [].concat(...measureEvents).reduce((tracks, mevent) => {\n\t\t\ttracks[mevent.track] = tracks[mevent.track] || [];\n\t\t\ttracks[mevent.track].push({\n\t\t\t\tticks: mevent.ticks,\n\t\t\t\t...mevent.data,\n\t\t\t});\n\n\t\t\treturn tracks;\n\t\t}, []);\n\n\t\ttracks[0] = tracks[0] || [];\n\t\t/*tracks[0].push({\n\t\t\tticks: 0,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `${npmPackage.name} ${npmPackage.version}`,\n\t\t});*/\n\n\t\t// append note events\n\t\tmeasureTick = zeroTick;\n\t\tmeasureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\t\t\tif (!Number.isFinite(measure.duration)) return;\n\n\t\t\tmeasure.notes.forEach((note) => {\n\t\t\t\tif (trackList && !trackList[note.track]) return;\n\n\t\t\t\tif (note.rest) return;\n\n\t\t\t\tconst tick = measureTick + note.tick;\n\n\t\t\t\tconst track = (tracks[note.track] = tracks[note.track] || []);\n\n\t\t\t\tnote.subNotes.forEach((subnote) => {\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.startTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: subnote.velocity,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.endTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: 0,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\t\t});\n\n\t\tconst finalTick = measureTick;\n\n\t\t// ensure no empty track\n\t\tfor (let t = 0; t < tracks.length; ++t) tracks[t] = tracks[t] || [];\n\n\t\t// sort & make deltaTime\n\t\ttracks.forEach((events) => {\n\t\t\tevents.sort((e1, e2) => eventPriority(e1) - eventPriority(e2));\n\n\t\t\tlet ticks = 0;\n\t\t\tevents.forEach((event) => {\n\t\t\t\tevent.deltaTime = event.ticks - ticks;\n\t\t\t\tif (!Number.isFinite(event.deltaTime)) event.deltaTime = 0;\n\t\t\t\telse ticks = event.ticks;\n\t\t\t});\n\n\t\t\tevents.push({ deltaTime: Math.max(finalTick - ticks, 0), type: 'meta', subtype: 'endOfTrack' });\n\t\t});\n\n\t\treturn {\n\t\t\theader: {\n\t\t\t\tformatType: 0,\n\t\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\t},\n\t\t\ttracks,\n\t\t\tzeroTick,\n\t\t};\n\t}\n\n\ttoPerformingNotationWithEvents(measureIndices: number[], options: { trackList?: boolean[] } = {}): MusicNotation.Notation {\n\t\tif (!measureIndices.length) return null;\n\n\t\tconst { zeroTick, ...midi } = this.toPerformingMIDI(measureIndices, options);\n\t\tconst notation = MusicNotation.Notation.parseMidi(midi);\n\n\t\tassignNotationNoteDataFromEvents(notation);\n\n\t\tlet tick = zeroTick;\n\n\t\tnotation.measures = measureIndices.map((index) => {\n\t\t\tconst startTick = tick;\n\t\t\ttick += this.measures[index - 1].duration;\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tstartTick,\n\t\t\t\tendTick: tick,\n\t\t\t};\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\t// find the MIDI event of setTempo in measures data, and change the value of microsecondsPerBeat\n\tsetTempo(bpm: number): boolean {\n\t\tlet found = false;\n\t\tfor (const measure of this.measures) {\n\t\t\tfor (const event of measure.events) {\n\t\t\t\tif (event.data.subtype === 'setTempo') {\n\t\t\t\t\tevent.data.microsecondsPerBeat = 60e6 / bpm;\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn found;\n\t}\n}\n\nconst assignNotationNoteDataFromEvents = (midiNotation: MusicNotation.NotationData, fields = ['ids', 'measure', 'staffTrack']) => {\n\tconst noteId = (channel: number, pitch: number, tick: number): string => `${channel}|${pitch}|${tick}`;\n\n\tconst noteMap = midiNotation.notes.reduce((map, note) => {\n\t\tmap[noteId(note.channel, note.pitch, note.startTick)] = note;\n\n\t\treturn map;\n\t}, {});\n\n\tmidiNotation.events.forEach((event) => {\n\t\tif (event.data.subtype === 'noteOn') {\n\t\t\tconst id = noteId(event.data.channel, event.data.noteNumber, event.ticks);\n\t\t\tconst note = noteMap[id];\n\t\t\tconsole.assert(!!note, 'cannot find note of', id);\n\n\t\t\tif (note) Object.assign(note, pick(event.data, fields));\n\t\t}\n\t});\n};\n\nexport { MetaNote, MetaNotation, MidiEvent };\n",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import _SHA256 from 'crypto-js/sha256';\n\nconst SHA256 = (source: string): Uint8Array => {\n\tconst { words, sigBytes } = _SHA256(source);\n\tconst uwords = words.map((x) => (x < 0 ? x + 0x100000000 : x));\n\tconst word_len = sigBytes / words.length;\n\n\treturn new Uint8Array(sigBytes).map((_, i) => (uwords[Math.floor(i / word_len)] >> ((3 - (i % word_len)) * 8)) & 0xff);\n};\n\ntype Hash = Uint8Array;\nconst HASH_LEN = 256;\n\nclass HashVector {\n\tfields: number[];\n\n\tstatic fromHash(hash: Hash): HashVector {\n\t\tconst fields = [];\n\t\tfor (const byte of hash) {\n\t\t\tfor (let b = 0; b < 8; ++b) fields.push((byte >> b) & 1 ? 1 : -1);\n\t\t}\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic fromString(source: string): HashVector {\n\t\tconst hash = SHA256(source);\n\t\treturn HashVector.fromHash(hash);\n\t}\n\n\tstatic fromWords(words: string[]): HashVector {\n\t\tconst vs = words.map((word) => HashVector.fromString(word));\n\t\treturn vs.reduce((sum, v) => sum.add(v), HashVector.zero);\n\t}\n\n\tstatic concat(...vectors: HashVector[]): HashVector {\n\t\tconst fields = vectors.map((v) => v.fields).flat(1);\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tconstructor(fields: number[] | null = null) {\n\t\tthis.fields = fields || Array(HASH_LEN).fill(0);\n\t}\n\n\tget length(): number {\n\t\treturn this.fields.length;\n\t}\n\n\ttoHash(): Hash {\n\t\treturn Uint8Array.from(\n\t\t\tArray(this.length / 8)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => {\n\t\t\t\t\tconst bits = this.fields.slice(i * 8, (i + 1) * 8);\n\n\t\t\t\t\treturn bits.reduce((byte, bit, b) => byte | ((bit > 0 ? 1 : 0) << b), 0);\n\t\t\t\t})\n\t\t) as Hash;\n\t}\n\n\tadd(vec: HashVector): this {\n\t\tthis.fields.forEach((value, i) => (this.fields[i] = value + vec.fields[i]));\n\n\t\treturn this;\n\t}\n\n\tscale(factor: number): this {\n\t\tthis.fields = this.fields.map((value) => value * factor);\n\n\t\treturn this;\n\t}\n\n\tsub(crop: number): HashVector {\n\t\tconst fields = crop > 0 ? this.fields.slice(0, crop) : this.fields.slice(crop);\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic get zero(): HashVector {\n\t\treturn new HashVector();\n\t}\n}\n\nconst odds = (byte: number): number => {\n\tlet result = 0;\n\tfor (let b = byte; b > 0; b >>= 1) {\n\t\tif (b % 2) ++result;\n\t}\n\n\treturn result;\n};\nconst ODDS = Array(2 ** 8)\n\t.fill(0)\n\t.map((_, i) => odds(i));\nconst ODDS_HEX = ODDS.reduce((table, odd, i) => ({ ...table, [('0' + i.toString(16)).slice(-2)]: odd }), {});\n\nconst countOnes = (hash: Hash): number => hash.reduce((sum, byte) => sum + ODDS[byte], 0);\n\nconst xorHashes = (hash1: Hash, hash2: Hash): Hash => hash1.map((byte, i) => byte ^ hash2[i]) as Hash;\n\nconst cosHashes = (hash1: Hash, hash2: Hash): number => {\n\tconst len = hash1.length * 8;\n\n\tconst xor = xorHashes(hash1, hash2);\n\tconst ones = countOnes(xor);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst cosBigInts = (hash1: bigint, hash2: bigint, len: number = HASH_LEN): number => {\n\tconst xor = hash1 ^ hash2;\n\tconst xor_hex = '0'.repeat(len / 4) + xor.toString(16);\n\n\tconst ones = Array(len / 8)\n\t\t.fill(0)\n\t\t.reduce((ones, _, i) => ones + ODDS_HEX[xor_hex.slice((i + 1) * -2, i ? i * -2 : undefined)], 0);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst i2hex = (i) => ('0' + i.toString(16)).slice(-2);\nconst hashToHex = (hash: Hash): string => Array.from(hash).map(i2hex).join('');\n\nconst hexToHash = (hex: string): Hash =>\n\tUint8Array.from(\n\t\tArray(hex.length / 2)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => hex.substring(i * 2, (i + 1) * 2))\n\t\t\t.map((x) => parseInt(x, 16))\n\t);\n\nconst hashToBigInt = (hash: Hash): bigint => {\n\t// __NOT_FOR_BROWSER_\n\treturn Array.from(hash).reduce((r, x) => r * 0x100n + BigInt(x), 0n);\n\t/*\n\t// _NOT_FOR_BROWSER__\n\tthrow new Error('BigInt not supported');\n\t//*/\n};\n\nconst hashFromWords = (words: string[]): Hash => HashVector.fromWords(words).toHash();\n\nexport { Hash, HashVector, cosHashes, cosBigInts, hashToHex, hexToHash, hashToBigInt, hashFromWords };\n","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import { EventFeature, BackgroundImage, EventPredisposition } from './interfaces';\nimport { StemBeam } from './term';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum EventElementType {\n\tPAD,\n\tBOS,\n\tEOS,\n\n\tCHORD,\n\tREST,\n}\n\ninterface EventElement {\n\thref?: string;\n\tdisposed?: boolean;\n\tindex?: number;\n\tvoice?: number;\n\n\ttype: EventElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\tfeature: EventFeature;\n\tpivotX?: number;\n\theadY?: number;\n\n\t// targets\n\ttick?: number;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: StemBeam;\n\tstemDirection?: string;\n\tgrace?: boolean;\n\ttremoloCatcher?: boolean;\n\ttimeWarped?: boolean;\n\tfullMeasure?: boolean; // full measure rest\n\tfake?: boolean;\n\n\torder?: number;\n\n\tpredisposition?: EventPredisposition;\n}\n\ntype Matrix = number[][];\n\ninterface Annotation {\n\tloss: number;\n\tgrant: boolean;\n\tpatched: boolean; // from manually solved measure\n}\n\nclass EventCluster extends SimpleClass {\n\tstatic className = 'EventCluster';\n\tstatic blackKeys = ['id'];\n\n\tid?: string; // for db access\n\tindex?: number;\n\tduration?: number;\n\tstaffY0?: number; // the first staff top + staffY\n\n\tsignatureDuration: number;\n\telements: EventElement[];\n\tmatrixH?: Matrix; // matrix N x N, [next][prev]\n\n\tbackgroundImages?: BackgroundImage[];\n\n\tannotation?: Annotation;\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget regular(): boolean {\n\t\treturn (\n\t\t\tthis.elements.some((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !elem.fake) &&\n\t\t\tthis.elements.every((elem) => [elem.x, elem.y1, elem.y2, elem.tick].every(Number.isFinite)) &&\n\t\t\tthis.elements\n\t\t\t\t.slice(1)\n\t\t\t\t.every(\n\t\t\t\t\t(elem, ei) =>\n\t\t\t\t\t\telem.fake ||\n\t\t\t\t\t\tthis.elements[ei].fake ||\n\t\t\t\t\t\telem.grace ||\n\t\t\t\t\t\tthis.elements[ei].grace ||\n\t\t\t\t\t\telem.fullMeasure ||\n\t\t\t\t\t\tthis.elements[ei].fullMeasure ||\n\t\t\t\t\t\telem.tick <= this.elements[ei].tick ||\n\t\t\t\t\t\telem.x > this.elements[ei].x\n\t\t\t\t)\n\t\t);\n\t}\n\n\tget grant(): boolean {\n\t\treturn this.annotation && this.annotation.grant;\n\t}\n\n\tget feature(): Partial {\n\t\treturn {\n\t\t\tindex: this.index,\n\t\t\telements: this.elements,\n\t\t};\n\t}\n\n\tget estimatedDuration(): number {\n\t\tconst endElem = this.elements.find((elem) => elem.type === EventElementType.EOS);\n\n\t\tconst tick = endElem?.predisposition ? endElem.predisposition?.tick : endElem?.tick;\n\n\t\treturn Number.isFinite(tick) ? tick : this.duration;\n\t}\n\n\tassignPrediction(prediction: any): void {\n\t\tconsole.assert(prediction.index === this.index, 'index mismatch:', prediction.index, this.index);\n\n\t\tthis.matrixH = prediction.matrixH;\n\t\tprediction.elements.forEach((pe) => {\n\t\t\tconst { index, ...predisposition } = pe;\n\t\t\tconst elem = this.elements.find((elem) => elem.index === index);\n\t\t\tconsole.assert(elem, 'element not found:', index);\n\n\t\t\tif (elem) elem.predisposition = predisposition;\n\t\t});\n\t}\n}\n\nclass EventClusterSet extends SimpleClass {\n\tstatic className = 'EventClusterSet';\n\n\tname?: string;\n\n\tclusters: EventCluster[];\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\ttrimIrregular(): number {\n\t\tlet ir = 0;\n\n\t\tthis.clusters = this.clusters.filter((cluster) => {\n\t\t\tconst regular = cluster.regular;\n\t\t\tif (!regular) {\n\t\t\t\tconsole.debug('irregular cluster:', cluster);\n\t\t\t\t++ir;\n\t\t\t}\n\n\t\t\treturn regular;\n\t\t});\n\n\t\tif (ir) console.debug('Irregular clusters trimmed:', `${ir}/${this.clusters.length + ir}`);\n\t\telse console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`);\n\n\t\treturn ir;\n\t}\n}\n\nexport { EventElementType, EventElement, EventCluster, EventClusterSet };\n","import erf from 'math-erf';\nimport sha1 from 'js-sha1';\n\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventTerm, ContextedTerm, MarkTerm, WHOLE_DURATION, StemBeam, GraceType, ContextType, TremoloLink } from './term';\nimport {\n\tFraction,\n\tStaffBasic,\n\tEventMeasure,\n\tRegulationOptions,\n\tRegulationSolution,\n\tRegulationSolutionEvent,\n\tBackgroundImage,\n\tMeasureBarType,\n} from './interfaces';\nimport { frac, fractionMul, roundNumber, argmax } from './utils';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\nimport * as EquationSolver from './equationSolver';\nimport { PatchMeasure } from './patch';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport type { MeasureRectification } from './measureRectification';\nimport type { GraphMeasure } from './timewiseGraph';\n\nnamespace SimplePolicy {\n\tconst constructXMap = (measure: SpartitoMeasure): Map => {\n\t\tconst xMap = new Map();\n\n\t\t// mark full measure rests\n\t\tmeasure.rows.forEach((row) => {\n\t\t\tif (row.events.length === 1) {\n\t\t\t\tconst event = row.events[0];\n\t\t\t\tif (event.rest && event.division === 0) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst x = Math.round(event.pivotX * 10) / 10;\n\t\t\tlet key = 0;\n\t\t\tif (event.fullMeasureRest) key = Math.min(x, ...xMap.keys());\n\t\t\telse {\n\t\t\t\tkey =\n\t\t\t\t\t[...xMap.keys()].find((k) => {\n\t\t\t\t\t\t// check if the event is aligned with the current chord\n\t\t\t\t\t\tconst es = xMap.get(k);\n\t\t\t\t\t\tconst left = Math.min(...es.map((e) => e.left));\n\t\t\t\t\t\tconst right = Math.max(...es.map((e) => e.right));\n\n\t\t\t\t\t\tconst overlaySize = Math.min(right, event.right) - Math.max(left, event.left);\n\n\t\t\t\t\t\treturn overlaySize > NOTEHEAD_WIDTHS.NoteheadS1 * 0.62;\n\t\t\t\t\t}) || x;\n\t\t\t}\n\t\t\tevent.roundX = key;\n\n\t\t\tconst es = xMap.get(key) || [];\n\t\t\txMap.set(key, es);\n\n\t\t\tes.push(event);\n\t\t});\n\n\t\treturn xMap;\n\t};\n\n\texport const computeMeasureTicks = (measure: SpartitoMeasure): void => {\n\t\tconst xMap = constructXMap(measure);\n\n\t\tlet tick = 0;\n\t\tconst ts = new Set([tick]);\n\t\tconst eventGroups = [...xMap.entries()].sort(([x1], [x2]) => x1 - x2); //.map(entry => entry[1]);\n\t\tfor (const [x, events] of eventGroups) {\n\t\t\tvoid x;\n\n\t\t\tevents.forEach((event: EventTerm) => {\n\t\t\t\tif (event.predisposition) {\n\t\t\t\t\tevent.rest = event.rest && event.predisposition.fullMeasure > 0.5 ? 'R' : event.rest;\n\t\t\t\t\tevent.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t\tevent.division = argmax(event.predisposition.divisionVector);\n\t\t\t\t\tevent.dots = argmax(event.predisposition.dotsVector);\n\t\t\t\t\tif (event.predisposition.timeWarped > 0.5) event.timeWarp = frac(2, 3);\n\t\t\t\t}\n\n\t\t\t\tif (event.fullMeasureRest) event.tick = 0;\n\t\t\t\telse {\n\t\t\t\t\tif (event.zeroHolder) tick -= event.duration;\n\n\t\t\t\t\tif (!event.zeroHolder && event.predisposition && Number.isInteger(event.predisposition.tick)) event.tick = event.predisposition.tick;\n\t\t\t\t\telse event.tick = tick;\n\t\t\t\t\tts.add(event.tick + event.duration);\n\t\t\t\t}\n\t\t\t\t//console.log(\"append tick:\", event.tick + event.duration, event);\n\t\t\t});\n\t\t\tts.delete(tick);\n\n\t\t\t//column.xToTick[x] = tick;\n\n\t\t\tif (ts.size) tick = Math.min(...ts);\n\t\t}\n\n\t\tif (Number.isInteger(measure.estimatedDuration)) measure.duration = measure.estimatedDuration;\n\t\telse measure.duration = Math.max(...ts, 0);\n\t};\n\n\texport const computeMeasureVoices = (measure: SpartitoMeasure): void => {\n\t\tmeasure.voices = [];\n\t\tfor (const row of measure.rows) {\n\t\t\tconst events = row.events.filter(\n\t\t\t\t(event) => !event.grace && !event.tremoloCatcher && !event.fullMeasureRest && !(event.predisposition && event.predisposition.fake > 0.5)\n\t\t\t);\n\t\t\tconst eventSet = new Set(events);\n\n\t\t\twhile (eventSet.size) {\n\t\t\t\tlet tick = 0;\n\n\t\t\t\tconst voice = [];\n\t\t\t\tconst pushEvent = (e: EventTerm) => {\n\t\t\t\t\tvoice.push(e.id);\n\t\t\t\t\tif (!e.zeroHolder) tick += e.duration;\n\t\t\t\t\teventSet.delete(e);\n\t\t\t\t};\n\n\t\t\t\tconst e0 = events.find((e) => eventSet.has(e));\n\t\t\t\tif (e0.alignedTick > 0) {\n\t\t\t\t\t//voice.tickMap[tick] = EventTerm.space({ tick, duration: e0.alignedTick });\n\t\t\t\t\ttick = e0.alignedTick;\n\t\t\t\t}\n\t\t\t\tpushEvent(e0);\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// TODO: consider slur pair\n\t\t\t\t\tconst e = events.find((e) => eventSet.has(e) && e.alignedTick === tick);\n\t\t\t\t\tif (!e) break;\n\n\t\t\t\t\tpushEvent(e);\n\t\t\t\t}\n\n\t\t\t\t//if (tick < measure.duration)\n\t\t\t\t//\tvoice.tickMap[tick] = EventTerm.space({ tick, duration: staff.duration - tick });\n\n\t\t\t\tmeasure.voices.push(voice);\n\t\t\t}\n\t\t}\n\t};\n}\n\nconst solveGraceEvents = (measure: SpartitoMeasure): void => {\n\tconst graceEvents = measure.events.filter((event) => event.grace /*&& !Number.isFinite(event.tick)*/);\n\tif (!graceEvents.length) return;\n\n\tconst tickMap = measure.tickMap;\n\tconst staffMap = [...tickMap.entries()].reduce((smap, [tick, events]) => {\n\t\tevents.forEach((event) => {\n\t\t\tif (!event.grace) {\n\t\t\t\tsmap[event.staff] = smap[event.staff] || {};\n\n\t\t\t\tconst oldEvent = smap[event.staff][tick];\n\t\t\t\tsmap[event.staff][tick] = !oldEvent || oldEvent.x > event.x ? event : oldEvent;\n\t\t\t}\n\t\t});\n\n\t\treturn smap;\n\t}, {} as { [staff: number]: { [tick: number]: EventTerm } });\n\n\ttype Position = { tick: number; preTick: number; graces: EventTerm[]; event: EventTerm };\n\tconst staffPositions = Object.entries(staffMap).reduce((map, [staff, emap]) => {\n\t\tmap[staff] = Object.entries(emap)\n\t\t\t.map(([t, event]) => ({ event, tick: Number(t), preTick: -240, graces: [] }))\n\t\t\t.sort((p1, p2) => p1.event.x - p2.event.x);\n\t\tmap[staff].push({ tick: measure.duration, event: measure.endEvent, preTick: 0, graces: [] }); // terminal bar\n\n\t\tlet tick = 0;\n\t\tmap[staff].forEach((position) => {\n\t\t\tif (position.tick > tick) {\n\t\t\t\tposition.preTick = tick;\n\t\t\t\ttick = position.tick;\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}, {} as { [staff: number]: Position[] });\n\n\t// append grace events into positions\n\tgraceEvents.forEach((event) => {\n\t\tconst staff = staffPositions[event.staff];\n\t\tif (staff) {\n\t\t\tconst position = staff.find((p) => p.event.x > event.x);\n\t\t\tif (position) position.graces.push(event);\n\t\t\tevent.roundX = event.x;\n\t\t\t//if (position.tick >= measure.duration)\n\t\t\t//\tevent.grace = GraceType.AfterGrace;\n\t\t}\n\t});\n\n\tObject.values(staffPositions).forEach((staff) =>\n\t\tstaff.forEach((position) => {\n\t\t\tif (position.graces.length) {\n\t\t\t\tposition.event.graceIds = position.graces.map((e) => e.id);\n\n\t\t\t\tconst totalDuration = position.graces.reduce((t, e) => t + e.duration, 0);\n\t\t\t\tconst duration = Math.min(totalDuration, position.tick - position.preTick);\n\t\t\t\tconst warp = duration / totalDuration;\n\n\t\t\t\tlet tick = position.tick;\n\t\t\t\t[...position.graces].reverse().forEach((event) => {\n\t\t\t\t\tevent.tick = Math.round(tick - event.duration * warp);\n\t\t\t\t\ttick = event.tick;\n\t\t\t\t});\n\t\t\t}\n\t\t})\n\t);\n};\n\nconst solveTremoloPairs = (measure: SpartitoMeasure): void => {\n\tconst catchers = measure.events.filter((event) => event.tremoloCatcher && !event.grace);\n\tconst pitchers = measure.events.filter((event) => event.tremoloLink === TremoloLink.Pitcher && !event.grace);\n\n\tcatchers.forEach((catcher) => {\n\t\tlet candidates = pitchers.filter((event) => event.division === catcher.division && event.x < catcher.x);\n\t\tif (!candidates.length)\n\t\t\tcandidates = measure.events.filter(\n\t\t\t\t(event) =>\n\t\t\t\t\tNumber.isFinite(event.tick) &&\n\t\t\t\t\t!event.grace &&\n\t\t\t\t\t!event.rest &&\n\t\t\t\t\tevent.division === catcher.division &&\n\t\t\t\t\tevent.dots === catcher.dots &&\n\t\t\t\t\tevent.x < catcher.x\n\t\t\t);\n\t\tcandidates.sort((c1, c2) => c2.x - c1.x);\n\t\tif (candidates.length) {\n\t\t\tconst pitcher = candidates[0];\n\t\t\tpitcher.catcherId = catcher.id;\n\t\t\tconst tremolo = Math.max(pitcher.tremolo || 3, catcher.tremolo || 3);\n\t\t\tpitcher.tremolo = tremolo;\n\t\t\tcatcher.tremolo = tremolo;\n\n\t\t\tif (!catcher.tick) catcher.tick = pitcher.tick + pitcher.duration / 2;\n\n\t\t\tconst pi = pitchers.indexOf(pitcher);\n\t\t\tif (pi >= 0) pitchers.splice(pi, 1);\n\t\t}\n\t});\n};\n\nnamespace EquationPolicy {\n\ttype EventID = number;\n\ttype Time = number;\n\n\tconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\n\tconst CHORDS_SEAM_SIGMA = 0.6;\n\tconst NEIGHBOR_CHORDS_SIGMA = 1.6;\n\tconst Y_DECAY_SIGMA = 16;\n\tconst STAFF_DECAY_FACTOR = 2;\n\tconst STEM_DIRECTION_DECAY = 0.9;\n\tconst ILL_BEAMS_PENALTY = 0.2;\n\n\tconst INVERT_SQRT2 = 0.7071067811865475;\n\n\tconst MATRIX_H_WEIGHT = 3;\n\n\tconst FINE_BEAMS = [\n\t\t[null, null],\n\t\t[null, StemBeam.Open],\n\t\t[StemBeam.Open, StemBeam.Continue],\n\t\t[StemBeam.Open, StemBeam.Close],\n\t\t[StemBeam.Continue, StemBeam.Continue],\n\t\t[StemBeam.Continue, StemBeam.Close],\n\t\t[StemBeam.Close, null],\n\t\t[StemBeam.Close, StemBeam.Open],\n\t].map((bb) => bb.join('-'));\n\n\tinterface Event {\n\t\tid: EventID;\n\t\tstaff: number;\n\t\tx: number;\n\t\ty: number;\n\t\tduration: Time;\n\t\tconfidence: number;\n\t\tshrinkness: number;\n\t}\n\n\texport interface StaffGroup {\n\t\tevents: Event[];\n\t\texpectedDuration: Time;\n\t\tmeasureShrinkness: number;\n\t\tendX: number;\n\t\tmatrixH: Matrix;\n\t\tmatrixV: Matrix;\n\n\t\tids?: EventID[];\n\t}\n\n\tinterface EventResult {\n\t\tid: EventID;\n\t\ttick: Time;\n\t\tendTick: Time;\n\t\ttickGroup: number;\n\t\ttimeWarp?: Fraction;\n\t}\n\n\texport interface StaffGroupSolution {\n\t\tevents: EventResult[];\n\t\tvoices: EventID[][];\n\t\tduration: number;\n\n\t\tloss?: number;\n\t\tcredits?: number;\n\t\ttimes?: number;\n\t}\n\n\texport interface RegulatorOptions extends EquationSolver.SolverOptions {\n\t\tsolver?: (staffGroup: StaffGroup, options: EquationSolver.SolverOptions) => Promise;\n\t}\n\n\tconst solveStaffGroup = (staffGroup: StaffGroup, options: EquationSolver.SolverOptions): StaffGroupSolution => {\n\t\tif (!staffGroup.events.length) {\n\t\t\treturn {\n\t\t\t\tevents: [],\n\t\t\t\tvoices: [],\n\t\t\t\tduration: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\t\treturn solver.solve();\n\t};\n\n\texport const estiamteMeasure = (measure: SpartitoMeasure): StaffGroup => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => ({\n\t\t\t\tid: event.id,\n\t\t\t\tstaff: event.staff,\n\t\t\t\tx: event.x,\n\t\t\t\ttickEstimated: event.predisposition && Number.isFinite(event.predisposition.tick) ? event.predisposition.tick : event.x,\n\t\t\t\ttipX: event.tipX,\n\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\tduration: (event.mainDuration * DURATION_MULTIPLIER) / WHOLE_DURATION,\n\t\t\t\tdivision: event.division,\n\t\t\t\tdots: event.dots,\n\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\tbeam: event.beam,\n\t\t\t\trest: event.rest,\n\t\t\t\t// the possibility of full measure rest\n\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\tshrinkness: event.predisposition ? event.predisposition.timeWarped : null,\n\t\t\t}));\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: Number.isFinite(e.shrinkness) ? e.shrinkness : Math.tanh((e.division - e.dots * 0.1) / 4),\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\t//const hp = (dx: number): number => 1 - erf(((dx / NEIGHBOR_CHORDS_SIGMA) ** 0.6) * INVERT_SQRT2);\n\t\tconst hp = (dx: number): number => erf(dx / NEIGHBOR_CHORDS_SIGMA) * erf(NEIGHBOR_CHORDS_SIGMA / dx);\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\tif (e1.staffGroup !== e2.staffGroup) matrixH[e1.id][e2.id] = 0;\n\t\t\t\t// prohibit voice crossing staff groups\n\t\t\t\telse if (e1.x <= e2.x) matrixH[e1.id][e2.id] = 0;\n\t\t\t\telse {\n\t\t\t\t\tconst staffDecay = Math.exp(-Math.abs(e1.staff - e2.staff) * STAFF_DECAY_FACTOR);\n\t\t\t\t\tconst yDecay = e1.staff === e2.staff ? Math.exp(-Math.abs(e1.y - e2.y) / Y_DECAY_SIGMA) : 1;\n\t\t\t\t\tconst dx = e1.x - e2.x;\n\t\t\t\t\tconst dtx = e1.tipX - e2.tipX;\n\t\t\t\t\tmatrixH[e1.id][e2.id] = (staffDecay * yDecay * Math.min(hp(dx), hp(dtx))) ** (1 / MATRIX_H_WEIGHT);\n\t\t\t\t}\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\t\t\t\tmatrixH[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\n\t\t\t\t// weaken inconsistent stem directions\n\t\t\t\tif (e1.stemDirection && e2.stemDirection && e1.stemDirection !== e2.stemDirection) matrixH[e1.id][e2.id] *= STEM_DIRECTION_DECAY;\n\n\t\t\t\t// ill beams penalty\n\t\t\t\tif (!e1.rest && !e2.rest && !FINE_BEAMS.includes([e2.beam, e1.beam].join('-'))) matrixH[e1.id][e2.id] *= ILL_BEAMS_PENALTY;\n\t\t\t}\n\n\t\t\t// H possibility of e1 and end of measure\n\t\t\tmatrixH[ids.length][e1.id] = hp(measure.width - e1.x) ** (1 / MATRIX_H_WEIGHT);\n\t\t}\n\n\t\treturn {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness: 0,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t};\n\n\texport const regulateMeasure = async (measure: SpartitoMeasure, { solver = null, ...options }: RegulatorOptions): Promise => {\n\t\tconst env = estiamteMeasure(measure);\n\t\tconst { ids, matrixH, matrixV } = env;\n\n\t\t// copy matrices values from measure topology data\n\t\tif (measure.matrixH) {\n\t\t\tconsole.assert(\n\t\t\t\tmeasure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t\t'matrix shape mismatch:',\n\t\t\t\tids.length,\n\t\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t\t);\n\t\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t\t}\n\t\t}\n\t\tif (measure.matrixV) {\n\t\t\tmatrixV.forEach((row, i) =>\n\t\t\t\trow.forEach((_, j) => {\n\t\t\t\t\tconst mp = measure.matrixV[ids[i]][ids[j]];\n\t\t\t\t\tif (Number.isFinite(mp)) matrixV[i][j] = mp;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\tenv.measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tif (options.logger) options.logger.info('--- MEASURE', measure.measureIndex, '---', env);\n\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\t\tconst resultEvents = solution.events.map((e) => ({\n\t\t\t...e,\n\t\t\tid: env.ids[e.id], // decode compact ids\n\t\t}));\n\t\tresultEvents.forEach((e) => {\n\t\t\tconst event = measure.events.find((e0) => e0.id === e.id);\n\t\t\tevent.tick = Number.isFinite(e.tick) ? Math.round((e.tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : null;\n\t\t\tevent.tickGroup = e.tickGroup;\n\t\t\tevent.timeWarp = e.timeWarp;\n\t\t});\n\n\t\tmeasure.duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\t\tmeasure.voices = solution.voices.map((voice) => voice.map((id) => env.ids[id]));\n\n\t\tmeasure.solutionStat = {\n\t\t\tloss: solution.loss,\n\t\t\tsolverCredits: solution.credits,\n\t\t\tsolverTimes: solution.times,\n\t\t};\n\n\t\t// full measure rests\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst result = resultEvents.find((e) => e.id === event.id);\n\t\t\tif (!result) return;\n\t\t\telse if (!Number.isFinite(result.tick) && event.rest === 'r' && event.division === 0) {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.rest = 'R';\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t} else if (event.rest === 'R') {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t}\n\t\t});\n\t};\n\n\texport const regulateMeasureWithRectification = async (\n\t\tmeasure: SpartitoMeasure,\n\t\trectification: MeasureRectification,\n\t\t{ solver = null, ...options }: RegulatorOptions\n\t): Promise => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => {\n\t\t\t\tconst re = rectification.events.find((e) => e && e.id === event.id);\n\t\t\t\tconst division = Number.isFinite(re?.division) ? re.division : event.division;\n\t\t\t\tconst dots = Number.isFinite(re?.dots) ? re.dots : event.dots;\n\t\t\t\tconst duration = DURATION_MULTIPLIER * 2 ** -division * (2 - 2 ** -dots);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: event.id,\n\t\t\t\t\tstaff: event.staff,\n\t\t\t\t\tx: event.x,\n\t\t\t\t\ttickEstimated: event.predisposition?.tick,\n\t\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\t\tduration,\n\t\t\t\t\t// the possibility of full measure rest\n\t\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\t\tshrinkness: event.predisposition?.timeWarped || 0,\n\t\t\t\t};\n\t\t\t});\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: e.shrinkness,\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\t\t\t}\n\t\t}\n\n\t\t// copy matrices values from measure topology data\n\t\tconsole.assert(\n\t\t\tmeasure.matrixH && measure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t'matrix shape mismatch:',\n\t\t\tids.length,\n\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t);\n\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t}\n\n\t\tlet measureShrinkness = 0;\n\t\tif (Number.isFinite(measure.estimatedDuration)) measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tconst env = {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\n\t\tconst priority = -solution.loss;\n\n\t\tconst events = solution.events.map(({ id, tick, tickGroup, timeWarp }) => {\n\t\t\tconst re = rectification.events.find((e) => e && e.id === id);\n\t\t\tconst tickN = Number.isFinite(tick) ? Math.round((tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : tick;\n\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\ttick: tickN,\n\t\t\t\ttickGroup,\n\t\t\t\ttimeWarp,\n\t\t\t\tdivision: re?.division,\n\t\t\t\tdots: re?.dots,\n\t\t\t};\n\t\t});\n\n\t\tconst duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\n\t\treturn {\n\t\t\tevents,\n\t\t\tvoices: solution.voices,\n\t\t\tduration,\n\t\t\tpriority,\n\t\t};\n\t};\n}\n\ntype Matrix = number[][];\n\ntype TickMap = Map;\n\ninterface SolutionStatistics {\n\tloss?: number;\n\tsolverCredits?: number;\n\tsolverTimes?: number;\n}\n\nclass SpartitoMeasure extends SimpleClass {\n\tstatic className = 'SpartitoMeasure';\n\tstatic blackKeys = ['staffGroups', 'solutionStat', 'measureNumber', 'deposit'];\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tstaffGroups: number[][];\n\toriginalRegulationHash?: string;\n\tmeasureNumber?: number; // count from the last indent measure, head partial measure is zero, skip empty measures\n\n\tpatched: boolean;\n\tdiscard: boolean;\n\n\tposition: {\n\t\tsystemIndex: number;\n\t\tlocalIndex: number; // the measure local index in its system\n\t\tleft: number;\n\t\tright: number;\n\t\tstaffYs?: number[];\n\t\tstaffYsFull?: number[];\n\t};\n\n\tbackgroundImages: BackgroundImage[];\n\n\tevents: EventTerm[];\n\tendEvent: Partial; // the placeholder for end tick\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n\tindent: boolean;\n\n\tsolutionStat?: SolutionStatistics;\n\n\tmatrixH: Matrix; // matrix N x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n\testimatedDuration: number;\n\n\tgraph: GraphMeasure;\n\n\tdeposit: Record;\n\n\tstatic reorderEvents(events: EventTerm[], staffYsFull: number[]): EventTerm[] {\n\t\tconst HALF_NOTEHEAD = 0.7;\n\n\t\tconst ys = [];\n\n\t\tconst es = events.map((e) => ({\n\t\t\tid: e.id,\n\t\t\tstaff: e.staff,\n\t\t\tx: e.x / HALF_NOTEHEAD,\n\t\t\trx: 0,\n\t\t\try: staffYsFull[e.staff] + e.tipY,\n\t\t\ttipY: e.tipY,\n\t\t\tprior: 0,\n\t\t}));\n\t\tes.sort((e1, e2) => e1.x - e2.x);\n\t\tes.slice(1).forEach((e, i) => {\n\t\t\tconst dx = Math.min(Math.round(e.x - es[i].x), 2);\n\t\t\te.rx = es[i].rx + dx;\n\t\t});\n\t\tes.forEach((e) => {\n\t\t\te.prior = e.staff * 1e4 + e.rx + e.tipY * 0.01;\n\n\t\t\tif (!ys.includes(e.ry)) ys.push(e.ry);\n\t\t});\n\t\tes.sort((e1, e2) => e1.prior - e2.prior);\n\t\tys.sort((y1, y2) => y1 - y2);\n\n\t\tlet yi = 0;\n\t\tconst yis = ys.map((y, i) => {\n\t\t\tif (!i || ys[i] - ys[i - 1] < 0.5) return yi;\n\n\t\t\t++yi;\n\t\t\treturn yi;\n\t\t});\n\n\t\tconst result = es.map((e) => new EventTerm({ ...events.find((ev) => ev.id === e.id), intX: e.rx, intY: yis[ys.indexOf(e.ry)] }));\n\t\tresult.forEach((e, i) => (e.id = i + 1));\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tif (!this.originalRegulationHash && !this.regulated) this.originalRegulationHash = this.regulationHash;\n\n\t\tthis.barTypes = this.barTypes || {};\n\n\t\t// Ensure postRegulate runs for measures deserialized with voices (e.g. from patches/JSON)\n\t\t// to set endEvent and roundX needed for playback cursor positioning.\n\t\tif (this.regulated && this.position) this.postRegulate();\n\t}\n\n\tget timeSignature(): Fraction {\n\t\treturn this.basics && this.basics[0].timeSignature;\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.basics && this.basics[0].keySignature;\n\t}\n\n\tget timeSignatureChanged(): boolean {\n\t\treturn this.contexts.filter(Boolean)[0].some((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type));\n\t}\n\n\tget doubtfulTimesig(): boolean {\n\t\treturn this.basics && this.basics[0].doubtfulTimesig;\n\t}\n\n\tget regulated(): boolean {\n\t\treturn !!this.voices;\n\t}\n\n\tget validRegulated(): boolean {\n\t\tif (!this.voices) return false;\n\n\t\treturn this.voices.flat(1).every((id) => Number.isFinite(this.events.find((e) => e.id === id)?.tick));\n\t}\n\n\tget rows(): EventMeasure[] {\n\t\treturn this.contexts.map((contexts, si) => {\n\t\t\tconst events = this.events.filter((e) => e.staff === si);\n\n\t\t\treturn {\n\t\t\t\tevents,\n\t\t\t\tcontexts,\n\t\t\t};\n\t\t});\n\t}\n\n\tget eventStartX(): number {\n\t\treturn this.events.length ? Math.min(...this.events.map((e) => e.x)) : this.startX;\n\t}\n\n\tget startX(): number {\n\t\treturn this.position.left;\n\t}\n\n\tget width(): number {\n\t\treturn this.position.right - this.position.left;\n\t}\n\n\tget tickMap(): TickMap {\n\t\treturn this.events\n\t\t\t.concat([this.endEvent as EventTerm])\n\t\t\t.filter(Boolean)\n\t\t\t.reduce((map, event) => {\n\t\t\t\tif (Number.isFinite(event.tick)) {\n\t\t\t\t\tif (!map.has(event.tick)) map.set(event.tick, []);\n\n\t\t\t\t\tmap.get(event.tick).push(event);\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}, new Map());\n\t}\n\n\tget tickToX(): { [tick: number]: number } {\n\t\treturn [...this.tickMap.entries()].reduce((map, [tick, events]) => {\n\t\t\tevents = events.filter((e) => !e.fullMeasureRest && !e.grace);\n\t\t\tif (events.length) {\n\t\t\t\tconst x = Math.min(...events.map((e) => e.x));\n\t\t\t\tmap[tick] = x;\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget tickRates(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tevents.sort((e1, e2) => e1.x - e2.x);\n\n\t\treturn events.slice(0, events.length - 1).map((e1, i) => {\n\t\t\tconst e2 = events[i + 1];\n\n\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t});\n\t}\n\n\tget tickRatesInStaves(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(sevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickRatesInGroups(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(gevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickTwist(): number {\n\t\tif (!this.duration || !this.staffGroups) return undefined;\n\n\t\tconst events = this.events.filter(\n\t\t\t(event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !(event.rest && event.division === 0)\n\t\t); // ignore rest0\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst twists = Object.values(gevents).map((es) => {\n\t\t\tconst eventsXOrder = [...es].sort((e1, e2) => e1.pivotX - e2.pivotX);\n\t\t\tconst xSpan = this.position.right - eventsXOrder[0].x;\n\t\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\t\tconst e1 = eventsXOrder[i];\n\t\t\t\tconst dx = e2.pivotX - e1.pivotX;\n\t\t\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\t\t\tif (!dt) return dx / xSpan;\n\n\t\t\t\tconst rate = Math.atan2(dt / this.duration, dx / xSpan);\n\n\t\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t\t});\n\n\t\t\treturn Math.max(0, ...tickTwists);\n\t\t});\n\n\t\treturn Math.max(0, ...twists);\n\t}\n\n\tget eventMap(): Record {\n\t\treturn this.events.reduce((map, event) => {\n\t\t\tmap[event.id] = event;\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget empty(): boolean {\n\t\treturn !this.events?.length || !this.voices?.length;\n\t}\n\n\tget hasIllEvent(): boolean {\n\t\treturn this.regulated && this.events.some((event) => !event.zeroHolder && !Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t}\n\n\tget brief(): string {\n\t\tconst timesig = `${this.timeSignature.numerator}/${this.timeSignature.denominator}`;\n\t\tconst eventBrieves = this.events.map((e) =>\n\t\t\t[\n\t\t\t\te.staff,\n\t\t\t\te.intX,\n\t\t\t\tMath.round(e.tip ? e.tip.y : e.ys?.[0] ?? 0),\n\t\t\t\te.fullMeasureRest ? 0 : e.division,\n\t\t\t\te.fullMeasureRest ? 0 : e.dots,\n\t\t\t\te.rest ? 'r' : '',\n\t\t\t\te.grace || '',\n\t\t\t\te.stemDirection,\n\t\t\t\te.beam || '',\n\t\t\t].join('|')\n\t\t);\n\n\t\treturn [timesig, ...eventBrieves].join('\\n');\n\t}\n\n\tget regulationHash(): string {\n\t\treturn sha1(this.brief);\n\t}\n\n\t// prefer use originalRegulationHash\n\tget regulationHash0(): string {\n\t\treturn this.originalRegulationHash || this.regulationHash;\n\t}\n\n\tget regulationHashes(): string[] {\n\t\treturn Array.from(new Set([this.originalRegulationHash, this.regulationHash].filter(Boolean)));\n\t}\n\n\tget featureWords(): string[][] | null {\n\t\tif (!this.regulated || !this.voices || !this.voices.length) return null;\n\n\t\tconst invalid = this.tickRatesInStaves.some((rate) => rate < 0);\n\n\t\tconst mainEvents = this.events.filter((event) => !event.zeroHolder && !event.rest);\n\n\t\tconst ys = mainEvents\n\t\t\t.map((event) => event.ys)\n\t\t\t.flat(1)\n\t\t\t.map((y) => `Y${-y * 2}`);\n\t\tconst uys = Array.from(new Set(ys));\n\t\tif (this.keySignature) uys.push(`K${this.keySignature}`);\n\n\t\tconst voices = this.voices\n\t\t\t.map((ids) => ids.map((id) => this.events.find((e) => e.id === id)).filter((event) => !event.zeroHolder && !event.rest))\n\t\t\t.filter((voice) => voice.length);\n\n\t\tconst melodies = invalid ? [] : voices.map((es) => es.map((e) => e.scaleChord).join('-'));\n\n\t\tconst rhythm = invalid ? [] : voices.map((es) => es.map((e) => e.division).join(''));\n\t\tif (this.timeSignature) rhythm.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`);\n\n\t\treturn [uys, melodies, rhythm];\n\t}\n\n\tget barType(): MeasureBarType {\n\t\tif (this.voltaEnd) return 'VoltaRight';\n\n\t\tconst typeEntris = Object.entries(this.barTypes).sort((e1, e2) => e2[1] - e1[1]);\n\t\tif (typeEntris[0] && typeEntris[0][1] >= 1) return typeEntris[0][0] as MeasureBarType;\n\n\t\treturn null;\n\t}\n\n\tget partialDuration(): boolean {\n\t\tif (!Number.isFinite(this.duration)) return false;\n\n\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\treturn this.duration < signatureDuration;\n\t}\n\n\tpostRegulate(): void {\n\t\tthis.endEvent = new EventTerm({ tick: this.duration, x: this.position.right });\n\n\t\tthis.updateRoundX();\n\t\tsolveGraceEvents(this);\n\t\tsolveTremoloPairs(this);\n\t\tthis.updateContextTick();\n\t}\n\n\tupdateRoundX(): void {\n\t\tconst tickToX = this.tickToX;\n\t\tif (tickToX)\n\t\t\tthis.events.forEach((event) => {\n\t\t\t\tconst x = tickToX[event.tick];\n\t\t\t\tif (Number.isFinite(x)) event.roundX = x;\n\t\t\t});\n\t}\n\n\tupdateContextTick(): void {\n\t\tif (!this.staffGroups) return;\n\t\tconst contexts = this.contexts.flat(1);\n\t\tthis.staffGroups.flat(1).forEach((staffIndex) => {\n\t\t\tconst terms = [...this.events.filter((e) => e.staff === staffIndex), ...contexts.filter((c) => c.staff === staffIndex)];\n\t\t\tterms.sort((t1, t2) => t2.x - t1.x); // order by x from right to left\n\n\t\t\tlet tick = this.duration;\n\t\t\tterms.forEach((term) => {\n\t\t\t\tif (term instanceof EventTerm) {\n\t\t\t\t\tif (!term.fullMeasureRest && !term.zeroHolder) tick = term.tick;\n\t\t\t\t} else if (term instanceof ContextedTerm) term.tick = tick;\n\t\t\t});\n\t\t});\n\t}\n\n\tasSolution(ref: SpartitoMeasure = undefined): RegulationSolution {\n\t\tif (!this.regulated) return null;\n\n\t\t//let timeSignature = undefined;\n\t\t//if (ref && printFraction(ref.timeSignature) !== printFraction(this.timeSignature)) timeSignature = this.timeSignature;\n\n\t\treturn {\n\t\t\t//timeSignature,\n\t\t\tevents: this.events.map((e) => {\n\t\t\t\tconst se = {\n\t\t\t\t\tid: e.id,\n\t\t\t\t\ttick: e.tick,\n\t\t\t\t\ttickGroup: e.tickGroup,\n\t\t\t\t\ttimeWarp: e.timeWarp,\n\t\t\t\t} as RegulationSolutionEvent;\n\n\t\t\t\tif (ref) {\n\t\t\t\t\tconst refEvent = ref.events.find((re) => re.id === e.id);\n\t\t\t\t\tif (refEvent) {\n\t\t\t\t\t\tif (e.division !== refEvent.division) se.division = e.division;\n\t\t\t\t\t\tif (e.dots !== refEvent.dots) se.dots = e.dots;\n\t\t\t\t\t\tif (e.grace !== refEvent.grace) se.grace = !!e.grace;\n\t\t\t\t\t\tif (e.beam !== refEvent.beam) se.beam = e.beam;\n\t\t\t\t\t\tif (e.fullMeasureRest !== refEvent.fullMeasureRest) se.fullMeasure = e.fullMeasureRest;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn se;\n\t\t\t}),\n\t\t\tvoices: this.voices,\n\t\t\tduration: this.duration,\n\t\t\tpriority: -this.solutionStat?.loss,\n\t\t};\n\t}\n\n\tapplySolution(solution: RegulationSolution): void {\n\t\tif (solution.timeSignature) {\n\t\t\tthis.basics.forEach((basic) => {\n\t\t\t\tbasic.timeSignature = solution.timeSignature;\n\t\t\t\tbasic.doubtfulTimesig = false;\n\t\t\t});\n\t\t}\n\n\t\tthis.voices = solution.voices;\n\t\tthis.duration = solution.duration;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.timeWarp = null;\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\n\t\t\tconst se = solution.events?.find((e) => e.id === event.id);\n\t\t\tif (se) {\n\t\t\t\tevent.tick = se.tick;\n\t\t\t\tevent.timeWarp = se.timeWarp;\n\t\t\t\tevent.tickGroup = se.tickGroup;\n\n\t\t\t\tif (Number.isFinite(se.division)) event.division = se.division;\n\t\t\t\tif (Number.isFinite(se.dots)) event.dots = se.dots;\n\t\t\t\tif (se.beam) event.beam = se.beam as StemBeam;\n\t\t\t\tif (se.grace !== undefined) event.grace = se.grace ? GraceType.Grace : undefined;\n\t\t\t\tif (se.fullMeasure) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tif (Number.isFinite(solution.priority)) this.solutionStat = { loss: -solution.priority };\n\n\t\tthis.postRegulate();\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.voices = null;\n\t\tthis.duration = null;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\t\t\tevent.timeWarp = null;\n\t\t});\n\t}\n\n\tregulateTest(): void {\n\t\tthis.duration = 0;\n\t\tthis.voices = this.rows.map((row) => row.events.map((e) => e.id));\n\t\tthis.voices.forEach((ids) => {\n\t\t\tlet tick = 0;\n\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\t\t\tevents.forEach((e, index) => {\n\t\t\t\te.tickGroup = index;\n\t\t\t\te.tick = tick;\n\n\t\t\t\ttick += e.duration;\n\t\t\t});\n\n\t\t\tthis.duration = Math.max(this.duration, tick);\n\t\t});\n\t}\n\n\tregulateSimple(): void {\n\t\tSimplePolicy.computeMeasureTicks(this);\n\t\tSimplePolicy.computeMeasureVoices(this);\n\t}\n\n\tasync regulateEquations(options: EquationPolicy.RegulatorOptions): Promise {\n\t\tawait EquationPolicy.regulateMeasure(this, options);\n\t}\n\n\t// compute event.tick, event.tickGroup, event.timeWarp, voices, duration\n\tasync regulate({ policy = 'advanced', ...options }: RegulationOptions = {}): Promise {\n\t\tswitch (policy) {\n\t\t\tcase 'test':\n\t\t\t\tthis.regulateTest();\n\n\t\t\t\tbreak;\n\t\t\tcase 'equations':\n\t\t\tcase 'advanced':\n\t\t\t\tawait this.regulateEquations(options);\n\n\t\t\t\tbreak;\n\t\t\tcase 'simple':\n\t\t\tdefault:\n\t\t\t\tthis.regulateSimple();\n\t\t}\n\n\t\tthis.postRegulate();\n\t}\n\n\tcreatePatch(): PatchMeasure {\n\t\treturn new PatchMeasure({\n\t\t\tmeasureIndex: this.measureIndex,\n\t\t\tstaffMask: this.staffMask,\n\t\t\tbasic: this.basics[0],\n\t\t\t//points: [],\n\t\t\tevents: this.events,\n\t\t\tcontexts: this.contexts,\n\t\t\tmarks: this.marks,\n\t\t\tvoices: this.voices,\n\t\t});\n\t}\n\n\tcreateClusters(): EventCluster[] {\n\t\tconst trueEventIds = this.voices && new Set(this.voices.flat(1));\n\n\t\treturn this.staffGroups\n\t\t\t.filter((idx) => idx.length)\n\t\t\t.map((staffIndices) => {\n\t\t\t\tconst staffY0 = this.position.staffYs[0];\n\t\t\t\tconst staffYn = (n) => this.position.staffYs[staffIndices.indexOf(n)] - staffY0;\n\n\t\t\t\tconst events = this.events.filter((event) => staffIndices.includes(event.staff));\n\t\t\t\tif (!events.length) return null;\n\n\t\t\t\tconst elements: EventElement[] = events.map((event) => ({\n\t\t\t\t\tindex: event.id,\n\t\t\t\t\tvoice: (this.voices || []).findIndex((voice) => voice.includes(event.id)),\n\t\t\t\t\ttype: event.rest ? EventElementType.REST : EventElementType.CHORD,\n\t\t\t\t\tstaff: staffIndices.indexOf(event.staff),\n\t\t\t\t\tx: event.tipX,\n\t\t\t\t\tpivotX: event.pivotX,\n\t\t\t\t\ty1: staffYn(event.staff) + (event.stemDirection === 'u' ? event.tipY : event.ys[event.ys.length - 1]),\n\t\t\t\t\ty2: staffYn(event.staff) + (event.stemDirection === 'u' ? event.ys[0] : event.tipY),\n\t\t\t\t\theadY: event.stemDirection === 'u' ? event.ys[0] : event.ys[event.ys.length - 1],\n\t\t\t\t\tfeature: event.feature,\n\t\t\t\t\tdivision: event.division,\n\t\t\t\t\tdots: event.dots,\n\t\t\t\t\tbeam: event.beam || null,\n\t\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\t\tgrace: !!event.grace,\n\t\t\t\t\ttremoloCatcher: event.tremoloCatcher,\n\t\t\t\t\ttimeWarped: !!event.timeWarp,\n\t\t\t\t\tfullMeasure: event.fullMeasureRest,\n\t\t\t\t\ttick: event.tick || 0,\n\t\t\t\t\tfake: !event.fullMeasureRest && !event.grace && this.voices && !trueEventIds.has(event.id), // tremoloCatcher deemed as fake\n\t\t\t\t}));\n\t\t\t\tif (!elements.some((elem) => !elem.fake)) return null;\n\n\t\t\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\t\t\t// BOS & EOS\n\t\t\t\telements.unshift({\n\t\t\t\t\tindex: 0,\n\t\t\t\t\ttype: EventElementType.BOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.left,\n\t\t\t\t\tpivotX: this.position.left,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: this.duration < signatureDuration,\n\t\t\t\t\ttick: 0,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\t\t\t\telements.push({\n\t\t\t\t\tindex: -1,\n\t\t\t\t\ttype: EventElementType.EOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.right,\n\t\t\t\t\tpivotX: this.position.right,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: false,\n\t\t\t\t\ttick: this.duration,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\n\t\t\t\tlet matrixH = null;\n\t\t\t\tif (this.voices) {\n\t\t\t\t\tmatrixH = elements.map(() => elements.map(() => 0));\n\n\t\t\t\t\tthis.voices.forEach((voice) => {\n\t\t\t\t\t\tlet tar = 0;\n\t\t\t\t\t\tvoice.forEach((id) => {\n\t\t\t\t\t\t\tconst src = elements.findIndex((e) => e.index === id);\n\t\t\t\t\t\t\tif (src > 0 && tar >= 0) matrixH[src][tar] = 1;\n\t\t\t\t\t\t\ttar = src;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (tar >= 0) matrixH[elements.length - 1][tar] = 1;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst annotation = { ...this.solutionStat, patched: this.patched };\n\n\t\t\t\tconst backgroundImages =\n\t\t\t\t\tthis.backgroundImages &&\n\t\t\t\t\tthis.backgroundImages.map(({ url, position }) => ({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t...position,\n\t\t\t\t\t\t\ty: position.y - staffY0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\n\t\t\t\treturn new EventCluster({\n\t\t\t\t\tindex: this.measureIndex,\n\t\t\t\t\tduration: this.duration,\n\t\t\t\t\tsignatureDuration,\n\t\t\t\t\tstaffY0,\n\t\t\t\t\telements,\n\t\t\t\t\tmatrixH,\n\t\t\t\t\tannotation,\n\t\t\t\t\tbackgroundImages,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n\n\tapplyClusters(clusters: EventCluster[]): void {\n\t\tconst id_max = this.events.reduce((max, event) => Math.max(max, event.id), 0) + 1;\n\t\tthis.matrixH = Array(id_max + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(id_max).fill(0));\n\n\t\tclusters.forEach((cluster) => {\n\t\t\tconst ids = cluster.elements.map((e) => e.index);\n\t\t\tconsole.assert(cluster.matrixH.length === ids.length - 1, 'unexpected matrixH size:', cluster.matrixH.length, ids.length);\n\n\t\t\tfor (let is = 1; is < ids.length; ++is) {\n\t\t\t\tfor (let it = 0; it < ids.length - 1; ++it) {\n\t\t\t\t\tconst srcId = ids[is] < 0 ? id_max : ids[is];\n\t\t\t\t\tconst tarId = ids[it];\n\n\t\t\t\t\tthis.matrixH[srcId][tarId] = cluster.matrixH[is - 1][it];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// event predisposition\n\t\t\tcluster.elements.forEach((elem) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === elem.index);\n\t\t\t\tif (event) {\n\t\t\t\t\tevent.predisposition = elem.predisposition;\n\t\t\t\t\tif (event.predisposition.grace !== undefined) event.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// estimated measure duration\n\t\tthis.estimatedDuration = clusters.reduce((sum, cluster) => sum + cluster.estimatedDuration, 0) / clusters.length;\n\t}\n}\n\nexport { SpartitoMeasure, EquationPolicy };\n","import { SimpleClass } from './aux_/typedJSON';\nimport { StaffBasic } from './interfaces';\nimport { SemanticPoint } from './semanticPoint';\nimport { EventTerm, ContextedTerm, MarkTerm } from './term';\n\nclass PatchMeasure extends SimpleClass {\n\tstatic className = 'PatchMeasure';\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tbasic: StaffBasic;\n\n\t//points: SemanticPoint[];\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tvoices: number[][]; // [voice, id]\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tObject.assign(this, data);\n\t}\n\n\tget staffN(): number {\n\t\treturn Math.floor(Math.log2(this.staffMask)) + 1;\n\t}\n\n\tget basics(): StaffBasic[] {\n\t\treturn Array(this.staffN).fill(this.basic);\n\t}\n\n\tget duration(): number {\n\t\treturn Math.max(\n\t\t\t0,\n\t\t\t...this.voices.map((ids) => {\n\t\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\n\t\t\t\treturn events.reduce((duration, event) => duration + event.duration, 0);\n\t\t\t})\n\t\t);\n\t}\n}\n\nexport { PatchMeasure };\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Hash, HashVector, cosHashes, hashToHex, hashToBigInt } from './hashVector';\nimport { EventTerm, ContextedTerm, TermPitch, TempoTerm, WHOLE_DURATION } from './term';\nimport { VoicesStaff, VoiceMeasure, TermMeasure, TermVoice, Performing, RegulationOptions } from './interfaces';\nimport { reducedFraction, argmax, noteToPitch, frac, printFraction, fractionMul } from './utils';\nimport { TokenType } from './token';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { Logger, DummyLogger } from './logger';\n\nexport const emptyVoiceFromStaffMeasure = (staff: TermMeasure, chiefVoice: boolean = false): VoiceMeasure => {\n\treturn {\n\t\tempty: true,\n\t\tduration: staff.duration,\n\t\ttickMap: {\n\t\t\t[0]: EventTerm.space({ duration: staff.duration, tick: 0 }),\n\t\t},\n\t\ttimeSignature: staff.timeSignature,\n\t\ttimeSigNumeric: staff.timeSigNumeric,\n\t\tkeySignature: staff.keySignature,\n\t\tcontextedTerms: staff.terms.filter((term) => term instanceof ContextedTerm && (!term.staffLevel || chiefVoice)) as ContextedTerm[],\n\t\tmarks: [],\n\t};\n};\n\nconst removeEmptyMeasuresInVoicesStaves = (staves: VoicesStaff[]): void => {\n\t//console.assert(staves[0] && staves[0].voices[0], 'voices is empty:', staves);\n\tif (!(staves[0] && staves[0].voices[0])) {\n\t\tconsole.warn('empty voices:', staves);\n\t\treturn;\n\t}\n\n\tconst measureCount = staves[0].voices[0].measures.length;\n\tconst measureEmpties = Array(measureCount)\n\t\t.fill(null)\n\t\t.map((_, m) => {\n\t\t\tfor (const staff of staves) {\n\t\t\t\tfor (const voice of staff.voices) {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tif (!measure.empty) return false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\tmeasureEmpties.forEach((empty, m) => {\n\t\tif (empty) {\n\t\t\tstaves.forEach((staff) =>\n\t\t\t\tstaff.voices.forEach((voice) => {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tmeasure.tickMap = {};\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t});\n};\n\nconst markingTiesInVoice = (voice: TermVoice) => {\n\tconst events = [].concat(...voice.measures.map((m) => Object.values(m.tickMap).filter((event) => event instanceof EventTerm)));\n\t//console.log(\"events:\", events);\n\n\tfor (let i = 1; i < events.length; ++i) {\n\t\tconst event0 = events[i - 1];\n\t\tconst event1 = events[i];\n\t\tif (!event0.rest && !event1.rest) {\n\t\t\tif (event0.accessories.some((acc) => acc.type === TokenType.SlurBegin) && event1.accessories.some((acc) => acc.type === TokenType.SlurEnd)) {\n\t\t\t\tconst pitches = event0.pitches.filter((p0) => event1.pitches.some((p1) => p1.note === p0.note && p1.alter === p0.alter));\n\t\t\t\tif (pitches.length > 0) {\n\t\t\t\t\tevent0.tying = true;\n\t\t\t\t\tevent1.tied = true;\n\n\t\t\t\t\tpitches.forEach((p0) => {\n\t\t\t\t\t\tp0.tying = true;\n\t\t\t\t\t\tconst p1 = event1.pitches.find((p1) => p1.note === p0.note && p1.alter === p0.alter);\n\t\t\t\t\t\tp1.tied = true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// remove slurs from accessories\n\t\t\t\t\tpitches.forEach(() => {\n\t\t\t\t\t\tconst si0 = event0.accessories.findIndex((acc) => acc.type === TokenType.SlurBegin);\n\t\t\t\t\t\tif (si0 >= 0) event0.accessories.splice(si0, 1);\n\n\t\t\t\t\t\tconst si1 = event1.accessories.findIndex((acc) => acc.type === TokenType.SlurEnd);\n\t\t\t\t\t\tif (si1 >= 0) event1.accessories.splice(si1, 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nclass Spartito extends SimpleClass {\n\tstatic className = 'Spartito';\n\n\tstavesCount: number;\n\tstaffGroups: number[][];\n\tmeasures: SpartitoMeasure[];\n\n\ttags: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.measures.forEach((measure) => (measure.staffGroups = this.staffGroups));\n\t}\n\n\tget regulated(): boolean {\n\t\treturn this.measures.every((m) => m.regulated);\n\t}\n\n\tget solidMeasureCount(): number {\n\t\treturn this.measures.filter((measure) => !measure.empty).length;\n\t}\n\n\tget measureIndexMapping(): number[] {\n\t\tlet n = 0;\n\t\treturn this.measures.map((measure) => {\n\t\t\treturn !measure.empty ? n++ : null;\n\t\t});\n\t}\n\n\tget headBPM(): number {\n\t\tfor (const measure of this.measures) {\n\t\t\tif (measure.marks) {\n\t\t\t\tconst tempoMark = measure.marks.find((mark) => mark instanceof TempoTerm && mark.isValid()) as TempoTerm;\n\t\t\t\tif (tempoMark) return tempoMark.bpm;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget measureLayoutCode(): string {\n\t\tconst ms = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure, i) => ({\n\t\t\t\tindex: i + 1,\n\t\t\t\tvb: measure.voltaBegin,\n\t\t\t\tve: measure.voltaEnd,\n\t\t\t\talter: measure.alternative,\n\t\t\t\tleftSign: '',\n\t\t\t\trightSign: '',\n\t\t\t}));\n\t\tms.forEach((m, i) => {\n\t\t\tif (m.vb) {\n\t\t\t\tconst nextI = ms.slice(i + 1).findIndex((mm) => mm.vb);\n\t\t\t\tconst nextVBI = nextI >= 0 ? i + nextI : ms.length;\n\t\t\t\tif (ms.slice(i, nextVBI - 1).some((mm) => mm.ve))\n\t\t\t\t\t// check if volta range closed\n\t\t\t\t\tm.leftSign = '2*[';\n\t\t\t}\n\n\t\t\tif (m.ve) {\n\t\t\t\tconst pms = ms.slice(0, i + 1).reverse();\n\t\t\t\tconst lastVEI = pms.slice(1).findIndex((mm) => mm.ve);\n\t\t\t\tif (lastVEI >= 0) {\n\t\t\t\t\tif (!pms.slice(1, lastVEI + 1).some((mm) => mm.vb))\n\t\t\t\t\t\t// ignore unclosed right volta\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.alter) {\n\t\t\t\t\tconst lastMI = pms.findIndex((m) => !m.alter);\n\t\t\t\t\tif (lastMI > 0) {\n\t\t\t\t\t\tpms[lastMI].rightSign = ']';\n\t\t\t\t\t\tpms[lastMI - 1].leftSign = '{[';\n\n\t\t\t\t\t\tm.rightSign = '],';\n\n\t\t\t\t\t\tif (ms[i + 1]) ms[i + 1].rightSign = '},';\n\t\t\t\t\t}\n\t\t\t\t} else m.rightSign = '],';\n\n\t\t\t\tif (!pms.some((m) => m.vb)) ms[0].leftSign = '2*[';\n\t\t\t}\n\t\t});\n\n\t\treturn ms\n\t\t\t.map((m) => m.leftSign + m.index.toString() + m.rightSign + (m.rightSign ? '' : ','))\n\t\t\t.join(' ')\n\t\t\t.replace(/,$/, '');\n\t}\n\n\tget qualityScore(): number {\n\t\tconst measures = this.measures.filter((measure) => !measure.empty);\n\t\tconst qss = measures.map(evaluateMeasure).map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\t//console.log('qss:', qss);\n\n\t\treturn measures.length ? sum / measures.length : null;\n\t}\n\n\tdumpEvaluations(): void {\n\t\tconst es = this.measures.filter((measure) => !measure.empty).map((m) => ({ measureIndex: m.measureIndex, ...evaluateMeasure(m) }));\n\t\tconst qss = es.map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\tconsole.log('qualityScore:', sum / es.length);\n\n\t\tconsole.table(es);\n\t}\n\n\tregulate(options: RegulationOptions = {}): void {\n\t\tthis.measures.forEach((m) => m.regulated || m.regulate(options));\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.measures.forEach((m) => (m.voices = null));\n\t}\n\n\t// measures' estimatedDuration should be valid\n\trectifyTimeSignatures(logger: Logger = new DummyLogger()): void {\n\t\tconst mis = this.measures\n\t\t\t.map((measure, index) => ({ measure, index }))\n\t\t\t.filter(({ measure, index }) => !index || measure.timeSignatureChanged)\n\t\t\t.map(({ index }) => index);\n\t\tconst segments = mis\n\t\t\t.map((index, si) => this.measures.slice(index, si < mis.length - 1 ? mis[si + 1] : this.measures.length))\n\t\t\t.map((ms) => ms.filter((m) => m.estimatedDuration > 0))\n\t\t\t.filter((seg) => seg.length >= 3 || seg.some((measure) => measure.doubtfulTimesig));\n\t\t//console.log(\"segments:\", segments.map(ms => ms.map(m => m.measureIndex)));\n\n\t\tsegments.forEach((measures) => {\n\t\t\tif (measures[0].patched) {\n\t\t\t\t// rectify according to patched head measure\n\t\t\t\tconst newTimeSignature = measures[0].timeSignature;\n\t\t\t\tconst measuresToFix = measures\n\t\t\t\t\t.slice(1)\n\t\t\t\t\t.filter((measure) => !measure.patched && printFraction(measure.timeSignature) !== printFraction(newTimeSignature));\n\t\t\t\tif (measuresToFix.length) {\n\t\t\t\t\tconst originTimeSignature = measuresToFix[0].timeSignature;\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by patched head:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${printFraction(newTimeSignature)}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst originTimeSignature = measures[0].timeSignature;\n\t\t\tconst regularD = Number.isInteger(Math.log2(originTimeSignature.denominator));\n\n\t\t\tlet denominator = regularD ? 4 : 8;\n\t\t\tif (regularD) denominator = Math.max(denominator, measures[0].timeSignature.denominator);\n\n\t\t\tconst numerators = measures.map((measure) => Math.round((measure.estimatedDuration * denominator) / WHOLE_DURATION));\n\t\t\tconst countings = Object.entries(numerators.reduce((c, n) => ((c[n] = (c[n] || 0) + 1), c), {} as Record)).sort(\n\t\t\t\t(p1, p2) => p2[1] - p1[1]\n\t\t\t);\n\t\t\tconst peakCount = countings[0][1];\n\t\t\tconst candidateNumerators = countings.filter(([_, c]) => c > peakCount * 0.6);\n\t\t\tconst bestCounting = candidateNumerators.reduce((best, c) => (Number(c[0]) > Number(best[0]) ? c : best));\n\t\t\tif (bestCounting[1] > 1) {\n\t\t\t\t//console.log(\"countings:\", countings, bestCounting[0]);\n\t\t\t\tlet numerator = Number(bestCounting[0]);\n\t\t\t\tif (!regularD || originTimeSignature.denominator * numerator !== originTimeSignature.numerator * denominator) {\n\t\t\t\t\tif (regularD && denominator !== originTimeSignature.denominator) {\n\t\t\t\t\t\tconst reducedN = (numerator * originTimeSignature.denominator) / denominator;\n\t\t\t\t\t\tif (Number.isInteger(reducedN)) {\n\t\t\t\t\t\t\tnumerator = reducedN;\n\t\t\t\t\t\t\tdenominator = originTimeSignature.denominator;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst measuresToFix = measures.filter((measure) => !measure.patched);\n\n\t\t\t\t\tconst newTimeSignature = frac(numerator, denominator);\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by estimation:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${numerator}/${denominator}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tmakeVoiceStaves(): VoicesStaff[] {\n\t\tthis.regulate();\n\n\t\tconst voiceCount = Math.max(...this.measures.map((measure) => measure.voices.length));\n\t\tif (!voiceCount || !Number.isFinite(voiceCount)) return null;\n\n\t\t// mark tied pitches for patched measues\n\t\tthis.measures\n\t\t\t.filter((measure) => measure.patched)\n\t\t\t.forEach((measure) => {\n\t\t\t\tmeasure.events.forEach((event) => {\n\t\t\t\t\tif (event.tied) event.pitches.forEach((pitch) => (pitch.tied = true));\n\t\t\t\t});\n\t\t\t});\n\n\t\t// [measure, voice]\n\t\tconst measures: VoiceMeasure[][] = this.measures.map((measure /*, mi*/) => {\n\t\t\tconsole.assert(measure.validRegulated, '[makeVoiceStaves] measure is invalid:', measure);\n\n\t\t\tconst eventMap: { [key: number]: EventTerm } = {};\n\t\t\tmeasure.events.forEach((event) => (eventMap[event.id] = event));\n\n\t\t\tconst leftStaves = new Set(\n\t\t\t\tArray(measure.contexts.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, i) => i)\n\t\t\t);\n\n\t\t\tlet bar = null;\n\t\t\tif (measure.barType) {\n\t\t\t\tswitch (measure.barType) {\n\t\t\t\t\tcase 'Segment':\n\t\t\t\t\t\tbar = '||';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Terminal':\n\t\t\t\t\t\tbar = '|.';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst voices: VoiceMeasure[] = measure.voices.map((ids /*, vi*/) => {\n\t\t\t\tconst events = ids.map((id) => eventMap[id]);\n\t\t\t\tevents.sort((e1, e2) => e1.tick - e2.tick);\n\n\t\t\t\tconst tickMap = {};\n\t\t\t\tlet tick = 0;\n\t\t\t\tlet lastEvent = null;\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (!Number.isFinite(event?.tick)) {\n\t\t\t\t\t\tconsole.warn('invalid event tick:', event);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (event.tick > tick) tickMap[tick] = EventTerm.space({ tick, duration: event.tick - tick });\n\t\t\t\t\telse if (!event.grace && event.tick < tick && lastEvent)\n\t\t\t\t\t\tlastEvent.timeWarp = reducedFraction(event.tick - lastEvent.tick, lastEvent.duration);\n\t\t\t\t\t//console.log(\"timewarp:\", event.tick - lastEvent.tick, lastEvent.duration, lastEvent.timeWarp);\n\n\t\t\t\t\ttickMap[event.tick] = event;\n\n\t\t\t\t\tif (!event.zeroHolder) {\n\t\t\t\t\t\ttick = Math.round(event.tick + event.duration);\n\t\t\t\t\t\tlastEvent = event;\n\n\t\t\t\t\t\t// sub grace events\n\t\t\t\t\t\tif (event.graceIds) {\n\t\t\t\t\t\t\tevent.graceIds.forEach((id) => {\n\t\t\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\t\t\tif (grace) tickMap[grace.tick] = grace;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (measure.endEvent && measure.endEvent.graceIds) {\n\t\t\t\t\tmeasure.endEvent.graceIds.forEach((id) => {\n\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\tif (grace && (!lastEvent || grace.staff === lastEvent.staff)) tickMap[grace.tick] = grace;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (tick < measure.duration) tickMap[tick] = EventTerm.space({ tick, duration: measure.duration - tick });\n\t\t\t\telse if (tick > measure.duration && Number.isFinite(measure.duration))\n\t\t\t\t\t//console.warn(\"duration out of range:\", tick, column.duration, mi, vi);\n\t\t\t\t\tlastEvent.timeWarp = reducedFraction(measure.duration - lastEvent.tick, lastEvent.duration);\n\n\t\t\t\tconsole.assert(\n\t\t\t\t\t!lastEvent || !lastEvent.timeWarp || (Number.isInteger(lastEvent.timeWarp.numerator) && Number.isInteger(lastEvent.timeWarp.denominator)),\n\t\t\t\t\t'invalid time warp:',\n\t\t\t\t\tlastEvent\n\t\t\t\t);\n\n\t\t\t\tconst staffIndex = events[0] ? events[0].staff : 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\n\t\t\t\t//const row = measure.rows[staffIndex];\n\t\t\t\tconst contextedTerms = measure.contexts[staffIndex];\n\n\t\t\t\tconst tailEvent = events[events.length - 1];\n\t\t\t\tconst tailStaff = tailEvent ? tailEvent.staff : 0;\n\n\t\t\t\t// TODO: modify full measure rests duration\n\n\t\t\t\treturn {\n\t\t\t\t\ttickMap,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t...basic,\n\t\t\t\t\t// TODO: consider staff altered voice\n\t\t\t\t\tcontextedTerms,\n\t\t\t\t\tmarks: [],\n\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\theadStaff: staffIndex,\n\t\t\t\t\ttailStaff,\n\t\t\t\t\tbar,\n\t\t\t\t};\n\t\t\t});\n\n\t\t\twhile (voices.length < voiceCount) {\n\t\t\t\tconst staffIndex = leftStaves.values().next().value || 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\t\t\t\tconst terms = measure.contexts[staffIndex];\n\n\t\t\t\tconst chiefVoice = voices.every((voice) => voice.headStaff !== staffIndex);\n\n\t\t\t\tconst voice = emptyVoiceFromStaffMeasure(\n\t\t\t\t\t{\n\t\t\t\t\t\tterms,\n\t\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t\t...basic,\n\t\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\t},\n\t\t\t\t\tchiefVoice\n\t\t\t\t);\n\t\t\t\tvoice.headStaff = staffIndex;\n\t\t\t\tvoice.tailStaff = staffIndex;\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\n\t\t\treturn voices;\n\t\t});\n\t\t//console.log(\"measures:\", measures);\n\n\t\t// compute traits for voice-measures\n\t\tmeasures.forEach((voices) =>\n\t\t\tvoices.forEach((measure) => {\n\t\t\t\tconst words = [];\n\n\t\t\t\tif (!measure.empty) {\n\t\t\t\t\twords.push(`s${measure.headStaff}`);\n\t\t\t\t\twords.push(`s${measure.tailStaff}`);\n\t\t\t\t}\n\n\t\t\t\tObject.values(measure.tickMap).forEach((event) => {\n\t\t\t\t\tif (event instanceof EventTerm) {\n\t\t\t\t\t\twords.push(`s${event.staff}`);\n\n\t\t\t\t\t\tif (event.stemDirection) {\n\t\t\t\t\t\t\tconst sd = `st${event.staff}-${event.stemDirection}`;\n\t\t\t\t\t\t\twords.push(sd, sd);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.grace) words.push(`gd${event.mainDuration}`);\n\t\t\t\t\t\telse words.push(`d${event.mainDuration}`);\n\n\t\t\t\t\t\tif (event.rest) words.push('r-' + event.rest);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tevent.pitches.forEach((pitch) => {\n\t\t\t\t\t\t\t\twords.push(`p1-${pitch.note}`);\n\t\t\t\t\t\t\t\twords.push(`p8-${Math.round(pitch.note / 8)}`);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmeasure.trait = HashVector.fromWords(words);\n\t\t\t})\n\t\t);\n\t\t//console.log(\"measure traits:\");\n\t\t//console.table(measures.map(voices => voices.map(measure => hashToHex(measure.trait.toHash()))));\n\n\t\tconst staffToGroup: Record = this.staffGroups\n\t\t\t.flat(1)\n\t\t\t.reduce((map, si) => ((map[si] = this.staffGroups.findIndex((group) => group.includes(si))), map), {});\n\n\t\t// sort voices to connect voices between neighhoring measures\n\t\tconst voiceTraits = Array(voiceCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => ({ vector: HashVector.zero, index, weight: 0, headStaff: null }));\n\t\tmeasures.forEach((voices, mi) => {\n\t\t\tvoiceTraits.sort((v1, v2) => v2.weight - v1.weight);\n\n\t\t\tconst leftVoices = new Set(voices);\n\t\t\tvoiceTraits.forEach((voiceTrait) => {\n\t\t\t\tconst vs = [...leftVoices];\n\t\t\t\tlet measure = vs[0];\n\t\t\t\tif (mi > 0 && vs.length > 1) {\n\t\t\t\t\tconst consistencies = vs.map((measure) =>\n\t\t\t\t\t\tstaffToGroup[measure.headStaff] === staffToGroup[voiceTrait.headStaff]\n\t\t\t\t\t\t\t? cosHashes(voiceTrait.vector.toHash(), measure.trait.toHash())\n\t\t\t\t\t\t\t: -1\n\t\t\t\t\t);\n\t\t\t\t\tmeasure = vs[argmax(consistencies)];\n\t\t\t\t}\n\t\t\t\tleftVoices.delete(measure);\n\n\t\t\t\tmeasure.voiceIndex = voiceTrait.index;\n\t\t\t\tvoiceTrait.vector.scale(0.4).add(measure.trait);\n\n\t\t\t\tvoiceTrait.weight = Object.keys(measure.tickMap).length;\n\n\t\t\t\tif (mi === 0) voiceTrait.headStaff = measure.headStaff;\n\t\t\t});\n\n\t\t\tvoices.sort((m1, m2) => m1.voiceIndex - m2.voiceIndex);\n\t\t});\n\n\t\t//const staffTraits = Array(this.stavesCount).fill(null).map((_, si) => HashVector.fromString(`s${si}`).toHash());\n\t\tconst staffVoiceIndices = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map(() => []);\n\t\tvoiceTraits.forEach((trait) => {\n\t\t\t//const consistencies = staffTraits.map(staff => cosHashes(trait.vector.toHash(), staff));\n\t\t\t//staffVoiceIndices[argmax(consistencies)].push(trait.index);\n\t\t\tstaffVoiceIndices[trait.headStaff].push(trait.index);\n\t\t});\n\n\t\tconst staves = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, si) => {\n\t\t\t\tif (!measures[0]) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvoices: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t//const voiceIndicies = measures[0].map((voice, vi) => ({ voice, vi })).filter(({ voice }) => voice.headStaff === si).map(({ vi }) => vi);\n\t\t\t\tconst voiceIndicies = staffVoiceIndices[si];\n\n\t\t\t\tconst voices = voiceIndicies.map((vi): TermVoice => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmode: 'relative',\n\t\t\t\t\t\tmeasures: measures.map((m) => m[vi]),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\treturn { voices };\n\t\t\t});\n\n\t\tremoveEmptyMeasuresInVoicesStaves(staves);\n\t\tstaves.forEach((staff) => staff.voices.forEach(markingTiesInVoice));\n\n\t\treturn staves;\n\t}\n\n\tperform(): Performing {\n\t\tconst staves = this.makeVoiceStaves();\n\t\tif (!staves) return null;\n\n\t\tconst tokenMap = new Map();\n\n\t\t// TODO: store staff channels in score\n\t\tconst staffToChannel = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.reduce((map, _, i) => {\n\t\t\t\tmap[i] = i;\n\t\t\t\treturn map;\n\t\t\t}, {});\n\n\t\tconst voiceChannels = [].concat(...staves.map((staff, si) => staff.voices.map(() => staffToChannel[si])));\n\n\t\tlet hasTempo = false;\n\n\t\tlet nextTick = 0;\n\t\tlet events0 = null;\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure) => {\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst voices: VoiceMeasure[] = [].concat(...staves.map((staff) => staff.voices.map((voice) => voice.measures[measureIndex])));\n\t\t\t\tconst voice0 = voices[0];\n\t\t\t\tconst tick = nextTick;\n\n\t\t\t\t//const signatureDuration = (WHOLE_DURATION * voice0.timeSignature.numerator) / voice0.timeSignature.denominator;\n\n\t\t\t\tnextTick += voice0.duration;\n\n\t\t\t\tconst notes = [].concat(\n\t\t\t\t\t...voices.map((measure, vi) => {\n\t\t\t\t\t\tconst tickFactor = 1; //measure.duration ? signatureDuration / measure.duration : 1;\n\n\t\t\t\t\t\tconst channel = voiceChannels[vi];\n\n\t\t\t\t\t\tconst chords = Object.values(measure.tickMap)\n\t\t\t\t\t\t\t.filter((term) => term instanceof EventTerm && !term.rest)\n\t\t\t\t\t\t\t.map((term: EventTerm) => {\n\t\t\t\t\t\t\t\tconst duration = Math.round(term.duration * tickFactor);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(term.tick), 'invalid event term tick:', term);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(duration), 'invalid event term duration:', term);\n\n\t\t\t\t\t\t\t\tif (term.tick >= 0) {\n\t\t\t\t\t\t\t\t\t// exclude minus tick tokens\n\t\t\t\t\t\t\t\t\tterm.noteIds.forEach((id) => {\n\t\t\t\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: term.roundX,\n\t\t\t\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(term.staff));\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttick: Math.round(term.tick * tickFactor),\n\t\t\t\t\t\t\t\t\tduration,\n\t\t\t\t\t\t\t\t\tpitches: term.pitches,\n\t\t\t\t\t\t\t\t\tnoteIds: term.noteIds,\n\t\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\t\tstaff: term.staff,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t\t...chords.map((chord) => {\n\t\t\t\t\t\t\t\t// exclude repeated pitches\n\t\t\t\t\t\t\t\tconst pitchMap: { [pitch: number]: TermPitch } = chord.pitches.reduce((map, pitch) => {\n\t\t\t\t\t\t\t\t\tmap[noteToPitch(pitch)] = pitch;\n\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t}, {});\n\t\t\t\t\t\t\t\tconst pitches = Object.values(pitchMap).sort((p1, p2) => p1.note - p2.note);\n\n\t\t\t\t\t\t\t\treturn pitches\n\t\t\t\t\t\t\t\t\t.filter((pitch) => !pitch.tied)\n\t\t\t\t\t\t\t\t\t.map((pitch, i) => {\n\t\t\t\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\ttick: chord.tick,\n\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\t\t\t\ttrack: chord.part,\n\t\t\t\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\t\t\t\tchannel,\n\t\t\t\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst events = [];\n\t\t\t\tevents0 = events0 || events;\n\n\t\t\t\tif (measure.marks)\n\t\t\t\t\tmeasure.marks.forEach((mark) => {\n\t\t\t\t\t\tif (mark instanceof TempoTerm) {\n\t\t\t\t\t\t\tconst bpm = mark.bpm;\n\t\t\t\t\t\t\tif (mark.isValid()) {\n\t\t\t\t\t\t\t\tconst es = hasTempo ? events : events0; // set the first tempo to the beginning of the track\n\t\t\t\t\t\t\t\tconst tick = hasTempo ? mark.tick : 0;\n\t\t\t\t\t\t\t\tes.push({\n\t\t\t\t\t\t\t\t\ttrack: 0,\n\t\t\t\t\t\t\t\t\tticks: tick,\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\t\t\t\t\t\tmicrosecondsPerBeat: Math.round(60e6 / bpm),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\thasTempo = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents,\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tif (!hasTempo) {\n\t\t\tmeasures[0].events.push({\n\t\t\t\ttrack: 0,\n\t\t\t\tticks: 0,\n\t\t\t\tdata: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\tmicrosecondsPerBeat: 0.5e6, // TODO\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tperformByEstimation(): Performing {\n\t\tconst tokenMap = new Map();\n\t\tlet nextTick = 0;\n\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => measure.events.some((event) => event.predisposition))\n\t\t\t.map((measure) => {\n\t\t\t\tconst tick = nextTick;\n\t\t\t\tconst duration = Math.round(measure.estimatedDuration || fractionMul(WHOLE_DURATION, measure.timeSignature));\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\tnextTick += duration;\n\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst chords = measure.events.filter((event) => event.predisposition && event.predisposition.fake < 0.5 && !event.rest);\n\t\t\t\tconst notes = chords\n\t\t\t\t\t.map((chord) => {\n\t\t\t\t\t\tconst noteTick = Math.round(chord.predisposition.tick);\n\n\t\t\t\t\t\tchord.noteIds.forEach((id) => {\n\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\tx: chord.roundX,\n\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn chord.pitches.map((pitch, i) => {\n\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(chord.staff));\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttick: noteTick,\n\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\ttrack: part,\n\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\tchannel: 0,\n\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.flat(1);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents: [],\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tfeatureHash(): Hash {\n\t\tconst headMeasures = this.measures.slice(0, 16);\n\t\tconst measureWords = headMeasures.map((measure) => measure.featureWords);\n\n\t\tconst levels = [1, 4, 16].map((len) => {\n\t\t\tconst meaures = measureWords.slice(0, len).filter(Boolean);\n\t\t\tconst ys = meaures.map((words) => words[0]).flat(1);\n\t\t\tconst melodies = meaures.map((words) => words[1]).flat(1);\n\t\t\tconst rhythm = meaures.map((words) => words[2]).flat(1);\n\n\t\t\tconst [vecY, vecMelody, vecRhythm] = [ys, melodies, rhythm].map(HashVector.fromWords);\n\n\t\t\treturn HashVector.concat(vecY, vecMelody.sub(128), vecRhythm.sub(128));\n\t\t});\n\n\t\treturn HashVector.concat(...levels).toHash();\n\t}\n\n\tfeatureHashHex(): string {\n\t\treturn hashToHex(this.featureHash());\n\t}\n\n\tfeatureHashBigInt(): bigint {\n\t\treturn hashToBigInt(this.featureHash());\n\t}\n\n\tassignMeasureNumbers(): void {\n\t\tlet n = null as any;\n\t\tfor (const measure of this.measures) {\n\t\t\tif (!measure.discard && !measure.events.length) continue;\n\n\t\t\tif (measure.indent) n = null;\n\n\t\t\tif (!Number.isFinite(n)) n = measure.partialDuration ? 0 : 1;\n\n\t\t\tmeasure.measureNumber = n++;\n\t\t}\n\t}\n}\n\nexport { SpartitoMeasure, Spartito };\n","import { Fraction } from './interfaces';\nimport { ContextedTerm, ContextType } from './term';\nimport { Logger, DummyLogger } from './logger';\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nexport const mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst PHONETS = 'CDEFGAB';\n\nconst ALTER_NAMES = {\n\t[-2]: '\\u266D\\u266D',\n\t[-1]: '\\u266D',\n\t[0]: '\\u266E',\n\t[1]: '\\u266F',\n\t[2]: '\\uD834\\uDD2A',\n};\n\n/*\n\tCoordinates:\n\n\t\tnote:\n\t\t\tzero: the middle C line (maybe altered)\n\t\t\tpositive: high (right on piano keyboard)\n\t\t\tunit: a step in scales of the current staff key\n\n\t\tstaff Y:\n\t\t\tzero: the third (middle) line among 5 staff lines\n\t\t\tpositive: down\n\t\t\tunit: a interval between 2 neighbor staff lines\n*/\n\nexport default class StaffContext {\n\tlogger: Logger = new DummyLogger();\n\n\tclef: number = -3;\n\tkeyAlters: number[] = [];\n\toctaveShift: number = 0;\n\talters: number[] = [];\n\n\ttimeSignature: Fraction = {\n\t\tnumerator: 4,\n\t\tdenominator: 4,\n\t};\n\ttimeSigNumeric: boolean = false;\n\ttimeSigNumSet: boolean = false;\n\ttimeSigDenSet: boolean = false;\n\tdoubtingTimesig: boolean = true;\n\n\tchange(term: ContextedTerm) {\n\t\tswitch (term.type) {\n\t\t\tcase ContextType.Clef:\n\t\t\t\tthis.clef = term.clef;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.KeyAcc:\n\t\t\t\tthis.keyAlters[mod7(this.yToNote(term.y))] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.Acc:\n\t\t\t\tthis.alters[this.yToNote(term.y)] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.OctaveShift:\n\t\t\t\tthis.octaveShift = term.octaveShift;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureC:\n\t\t\t\tthis.timeSigNumeric = false;\n\t\t\t\tswitch (term.tokenType) {\n\t\t\t\t\tcase 'timesig-C44':\n\t\t\t\t\t\tthis.timeSignature.numerator = 4;\n\t\t\t\t\t\tthis.timeSignature.denominator = 4;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'timesig-C22':\n\t\t\t\t\t\tthis.timeSignature.numerator = 2;\n\t\t\t\t\t\tthis.timeSignature.denominator = 2;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureN:\n\t\t\t\tthis.timeSigNumeric = true;\n\t\t\t\tswitch (term.y) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tif (this.timeSigDenSet) this.timeSignature.denominator = this.timeSignature.denominator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.denominator = term.number;\n\n\t\t\t\t\t\tthis.timeSigDenSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase -1:\n\t\t\t\t\t\tif (this.timeSigNumSet) this.timeSignature.numerator = this.timeSignature.numerator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.numerator = term.number;\n\n\t\t\t\t\t\tthis.timeSigNumSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.logger.warn('unexpected time signature Y:', term.y);\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tresetMeasure() {\n\t\tthis.alters = [];\n\n\t\tthis.timeSigNumSet = false;\n\t\tthis.timeSigDenSet = false;\n\t}\n\n\tresetSystem() {\n\t\tthis.keyAlters = [];\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.keyAlters.filter((a) => Number.isInteger(a)).reduce((sum, a) => sum + a, 0);\n\t}\n\n\tget partialTimeSignature(): boolean {\n\t\treturn !this.timeSigNumSet !== !this.timeSigDenSet;\n\t}\n\n\tnoteToY(note: number): number {\n\t\treturn -note / 2 - this.clef - this.octaveShift * 3.5;\n\t}\n\n\tpitchToNote(pitch: number, { preferredAlter = null } = {}): { note: number; alter: number } {\n\t\tif (!preferredAlter) preferredAlter = this.keySignature < 0 ? -1 : 1;\n\n\t\tconst group = Math.floor((pitch - MIDDLE_C) / 12);\n\t\tconst gp = mod12(pitch);\n\t\tconst alteredGp = GROUP_N_TO_PITCH.includes(gp) ? gp : mod12(gp - preferredAlter);\n\t\tconst gn = GROUP_N_TO_PITCH.indexOf(alteredGp);\n\t\tthis.logger.assert(gn >= 0, 'invalid preferredAlter:', pitch, preferredAlter, alteredGp);\n\n\t\tconst naturalNote = group * 7 + gn;\n\n\t\tconst alterValue = gp - alteredGp;\n\t\tconst keyAlterValue = this.keyAlters[gn] || 0;\n\t\tconst onAcc = Number.isInteger(this.alters[naturalNote]);\n\n\t\tconst alter = onAcc ? alterValue : alterValue === keyAlterValue ? null : alterValue;\n\n\t\treturn { note: naturalNote, alter };\n\t}\n\n\tpitchToY(pitch: number, { preferredAlter = null } = {}): { y: number; alter: number } {\n\t\tconst { note, alter } = this.pitchToNote(pitch, { preferredAlter });\n\t\tconst y = this.noteToY(note);\n\n\t\treturn { y, alter };\n\t}\n\n\tyToNote(y: number): number {\n\t\tthis.logger.assert(Number.isInteger(y * 2), 'invalid y:', y);\n\n\t\treturn (-y - this.octaveShift * 3.5 - this.clef) * 2;\n\t}\n\n\talterOnNote(note: number): number {\n\t\tif (Number.isInteger(this.alters[note])) return this.alters[note];\n\n\t\tconst gn = mod7(note);\n\t\tif (Number.isInteger(this.keyAlters[gn])) return this.keyAlters[gn];\n\n\t\treturn 0;\n\t}\n\n\tnoteToPitch(note: number): number {\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tconst pitch = MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + this.alterOnNote(note);\n\t\tif (!Number.isFinite(pitch)) {\n\t\t\tthis.logger.warn('invalid pitch value:', pitch, note, group, gn);\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn pitch;\n\t}\n\n\tyToPitch(y: number): number {\n\t\treturn this.noteToPitch(this.yToNote(y));\n\t}\n\n\tyToPitchName(y: number): string {\n\t\tconst note = this.yToNote(y);\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tlet alter = this.alterOnNote(note);\n\t\tif (!alter && !Number.isInteger(this.alters[note])) alter = null;\n\n\t\treturn `${ALTER_NAMES[alter] ? ALTER_NAMES[alter] : ''}${PHONETS[gn]}${group + 4}`;\n\t}\n}\n","import sha1 from 'js-sha1';\n\nimport * as measureLayout from '../measureLayout';\nimport * as staffLayout from '../staffLayout';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventSystem, MeasureBrief, MusicSheet, RecognitionSettings, ScoreData, TermMeasure, TermStaff, VoicesStaff } from './interfaces';\nimport { DummyLogger, Logger } from './logger';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { PatchMeasure } from './patch';\nimport { Measure, Page, Staff, System } from './scoreComponents';\nimport { hashSemanticPoint, SemanticPoint, SemanticType } from './semanticPoint';\nimport { BOS_ELEMENT, fractionToElems, SemanticCluster, SemanticElement, SemanticElementType } from './semanticTopology';\nimport { Spartito, SpartitoMeasure } from './spartito';\nimport StaffContext from './staffContext';\nimport { ContextedTerm, ContextType, EventTerm, WHOLE_DURATION } from './term';\nimport type { SemanticPointInMeasure } from './timewiseGraph';\nimport { TimewiseGraph } from './timewiseGraph';\nimport { Token, TokenType } from './token';\nimport { distance2D, solveOverlapping } from './utils';\n\nexport const VERSION = 14;\n\ninterface Topology {\n\tclusters: SemanticCluster[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n}\n\nconst GRAND_STAFF_LAYOUT = '{-}';\n\nconst processStaffContext = (staff: TermStaff, logger: Logger = new DummyLogger()): void => {\n\tconst context = new StaffContext();\n\tcontext.logger = logger;\n\n\tfor (const row of staff.rows) {\n\t\tfor (const measure of row) {\n\t\t\tconst startEvent = measure.terms.find((term) => term instanceof EventTerm) as EventTerm;\n\t\t\tlet tick = startEvent ? Math.min(startEvent.tick, 0) : 0;\n\n\t\t\tmeasure.terms.forEach((term) => {\n\t\t\t\tif (term instanceof ContextedTerm) {\n\t\t\t\t\tterm.tick = tick; // TODO: not working here because measure not regulated yet\n\t\t\t\t\tcontext.change(term);\n\t\t\t\t} else if (term instanceof EventTerm) {\n\t\t\t\t\tconst endTick = term.tick + (term.duration || 0);\n\t\t\t\t\tif (endTick > tick) tick = endTick;\n\n\t\t\t\t\tif (term.ys) {\n\t\t\t\t\t\tterm.pitches = term.ys.map((y) => {\n\t\t\t\t\t\t\tconst note = context.yToNote(y);\n\t\t\t\t\t\t\tconst alter = context.alterOnNote(note);\n\n\t\t\t\t\t\t\treturn { note, alter, octaveShift: context.octaveShift };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tmeasure.timeSignature = { ...context.timeSignature };\n\t\t\tmeasure.timeSigNumeric = context.timeSigNumeric;\n\t\t\tmeasure.doubtfulTimesig =\n\t\t\t\tcontext.doubtingTimesig ||\n\t\t\t\t!Number.isInteger(Math.log2(measure.timeSignature.denominator)) ||\n\t\t\t\tmeasure.timeSignature.numerator <= measure.timeSignature.denominator / 4;\n\n\t\t\tmeasure.keySignature = context.keySignature;\n\n\t\t\t// fill empty measure duration\n\t\t\tif (measure.duration === 0) measure.duration = (WHOLE_DURATION * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\n\t\t\tcontext.resetMeasure();\n\t\t}\n\n\t\tcontext.resetSystem();\n\t}\n};\n\nconst upgradeScoreData = (data: ScoreData): ScoreData => {\n\tif (data.version < 3) {\n\t\tconst { version, stavesCount, layoutTemplate, ...fields } = data;\n\t\tvoid version;\n\t\tvoid layoutTemplate;\n\n\t\tlet staffLayoutCode =\n\t\t\tstavesCount > 1\n\t\t\t\t? Array(stavesCount - 1)\n\t\t\t\t\t\t.fill(',')\n\t\t\t\t\t\t.join('')\n\t\t\t\t: '';\n\n\t\t// use graph staff by default for 2 staves score\n\t\tif (stavesCount === 2) staffLayoutCode = '{-}';\n\n\t\tdata = {\n\t\t\tversion: 3,\n\t\t\tstaffLayoutCode,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tif (data.version < 8) {\n\t\t// upgrade system measure bar semantics\n\t\tdata.pages.forEach((page) => {\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tif (system.semantics) {\n\t\t\t\t\tconst bars = system.semantics.filter((point) => point.semantic === SemanticType.vline_BarMeasure);\n\n\t\t\t\t\tsystem.semantics = [].concat(\n\t\t\t\t\t\t...system.staves.map((staff) => {\n\t\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\n\t\t\t\t\t\t\treturn bars.map((point) => ({\n\t\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\t\ty: point.y + oy,\n\t\t\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\t\t\t...point.extension,\n\t\t\t\t\t\t\t\t\ty1: point.extension.y1 + oy,\n\t\t\t\t\t\t\t\t\ty2: point.extension.y2 + oy,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tdata.version = 8;\n\t}\n\n\tif (data.version < 9) {\n\t\t// remove old format spartito\n\t\tdata.spartito = null;\n\n\t\tdata.version = 9;\n\t}\n\n\treturn data;\n};\n\nconst bitsToMask = (bits: number[]): number => bits.reduce((mask, bit, i) => (bit ? mask | (1 << i) : mask), 0);\n\ninterface PointPosition {\n\tpoint: SemanticPoint;\n\tpageIndex: number;\n\tsystemIndex: number;\n\tstaffIndex: number;\n}\n\ninterface MeasureValidation {\n\ttickMap: { [tick: number]: number };\n}\n\ninterface Size {\n\twidth: number;\n\theight: number;\n}\n\nclass Score extends SimpleClass {\n\tstatic className = 'Score';\n\n\tversion = VERSION;\n\n\ttitle: string;\n\t// in pixels\n\tpageSize: Size;\n\tunitSize: number;\n\tstaffLayoutCode: string;\n\n\tpaperOptions?: Partial;\n\n\theaders: { [key: string]: string };\n\n\ttextAnnotations: { [id: string]: string };\n\n\ttags?: string[];\n\n\tinstrumentDict: { [key: string]: string };\n\n\tpages: Page[];\n\ttopology: Topology;\n\tspartito?: Spartito;\n\n\tpatches?: PatchMeasure[];\n\n\tsettings: RecognitionSettings;\n\n\tconstructor(data: ScoreData) {\n\t\tsuper();\n\t\tsuper.assign(upgradeScoreData(data));\n\n\t\tthis.pages = this.pages || [];\n\t\tthis.headers = this.headers || {};\n\t\tthis.instrumentDict = this.instrumentDict || {};\n\n\t\tthis.pageSize = this.pageSize || {\n\t\t\t// A4 paper\n\t\t\twidth: 794,\n\t\t\theight: 1122,\n\t\t};\n\n\t\tthis.unitSize = this.unitSize || null;\n\n\t\tthis.staffLayoutCode = this.staffLayoutCode || (this.maxStavesCount === 2 ? GRAND_STAFF_LAYOUT : Array(this.maxStavesCount).fill('').join(','));\n\t}\n\n\tget systems(): System[] {\n\t\treturn [].concat(...this.pages.map((page) => page.systems));\n\t}\n\n\tget measureCount(): number {\n\t\treturn this.systems.reduce((sum, system) => sum + (system.measureCount || 0), 0);\n\t}\n\n\tget imageKeys(): string[] {\n\t\treturn [\n\t\t\t...this.pages.map((page) => page.source?.url),\n\t\t\t...this.systems.map((system) => system.backgroundImage),\n\t\t\t...[].concat(\n\t\t\t\t...this.systems.map((system) =>\n\t\t\t\t\t[...system.staves.map((staff) => staff.backgroundImage), ...system.staves.map((staff) => staff.maskImage)].filter(Boolean)\n\t\t\t\t)\n\t\t\t),\n\t\t].filter(Boolean);\n\t}\n\n\tget breakSystemIndices(): number[] {\n\t\tconst indices = [];\n\t\tlet systemCount = 0;\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tif (i < this.pages.length - 1) {\n\t\t\t\tsystemCount += page.systems.length;\n\t\t\t\tindices.push(systemCount - 1);\n\t\t\t}\n\t\t});\n\n\t\treturn indices;\n\t}\n\n\tget staffLayout(): staffLayout.StaffLayout {\n\t\treturn staffLayout.parseCode(this.staffLayoutCode);\n\t}\n\n\tget measureLayoutCode(): string {\n\t\treturn this.spartito?.measureLayoutCode;\n\t}\n\n\tget maxStavesCount(): number {\n\t\treturn Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget semanticHash(): string {\n\t\tconst ids = [].concat(\n\t\t\t...this.systems.map((system) =>\n\t\t\t\t[].concat(...system.staves.map((staff) => (staff.semantics ? system.qualifiedSemantics(staff.semantics).map((s) => s.id) : [])))\n\t\t\t)\n\t\t);\n\t\treturn sha1(ids.join(''));\n\t}\n\n\teventSystemsToTermStaves(eventSystems: EventSystem[], logger: Logger = new DummyLogger()): TermStaff[] {\n\t\t// [staff]\n\t\tconst termStaves: TermStaff[] = Array(this.maxStavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, staffIndex): TermStaff => {\n\t\t\t\treturn {\n\t\t\t\t\t// [system, measure]\n\t\t\t\t\trows: eventSystems.map((sys, i) =>\n\t\t\t\t\t\tsys.columns.map((column, ii): TermMeasure => {\n\t\t\t\t\t\t\tconst measure = column.rows[staffIndex];\n\t\t\t\t\t\t\tconsole.assert(measure, '[eventSystemsToTermStaves] measure is null:', staffIndex, column.rows);\n\n\t\t\t\t\t\t\tconst contexts = measure.contexts;\n\n\t\t\t\t\t\t\t// prepend octave shift 0 at begin of every system\n\t\t\t\t\t\t\tif (ii === 0) {\n\t\t\t\t\t\t\t\tif (!contexts.some((term) => term.type === ContextType.OctaveShift)) {\n\t\t\t\t\t\t\t\t\tcontexts.unshift(\n\t\t\t\t\t\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\t\t\t\t\t\tstaff: staffIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\t\t\t\ttokenType: TokenType.OctaveShift0,\n\t\t\t\t\t\t\t\t\t\t\ttick: 0,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst terms = [...(measure.events || []), ...contexts].sort((t1, t2) => t1.x - t2.x);\n\n\t\t\t\t\t\t\tconst pageBreak = staffIndex === 0 && ii === sys.columns.length - 1 && this.breakSystemIndices.includes(i);\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tterms,\n\t\t\t\t\t\t\t\t//xToTick: column.xToTick,\n\t\t\t\t\t\t\t\tduration: column.duration,\n\t\t\t\t\t\t\t\tpageBreak,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\ttermStaves.forEach((staff) => processStaffContext(staff, logger));\n\n\t\treturn termStaves;\n\t}\n\n\tresetPageLayout(parameters: { unitSize?: number; pageSize?: Size }) {\n\t\tconst { unitSize = this.unitSize, pageSize = this.pageSize } = parameters;\n\n\t\tconst newCenter = {\n\t\t\tx: (pageSize.width * 0.5) / unitSize,\n\t\t\ty: (pageSize.height * 0.5) / unitSize,\n\t\t};\n\n\t\tthis.pages.forEach((page) => {\n\t\t\tconst offsetX = newCenter.x - page.width / 2;\n\t\t\tconst offsetY = newCenter.y - page.height / 2;\n\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tsystem.left += offsetX;\n\t\t\t\tsystem.top += offsetY;\n\t\t\t});\n\n\t\t\tif (page.semantics) {\n\t\t\t\tpage.semantics.forEach((point) => {\n\t\t\t\t\tpoint.x += offsetX;\n\t\t\t\t\tpoint.y += offsetY;\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpage.width = pageSize.width / unitSize;\n\t\t\tpage.height = pageSize.height / unitSize;\n\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations });\n\t\t});\n\n\t\tthis.unitSize = unitSize;\n\t\tthis.pageSize = pageSize;\n\t}\n\n\tgetMeasure(measureIndex: number): {\n\t\tmeasureIndex: number;\n\t\tsystem: System;\n\t\tlocalIndex: number;\n\t\tleft: number;\n\t\tright: number;\n\t\tmeasures: Measure[];\n\t} {\n\t\tlet index = measureIndex;\n\t\tfor (const system of this.systems) {\n\t\t\tif (index < system.measureCount) {\n\t\t\t\tconst staff = system.staves[0];\n\t\t\t\tconst measure = staff.measures[index];\n\t\t\t\tconsole.assert(measure, 'measure is null:', system.measureCount, index, staff.measures);\n\t\t\t\tconst measures = system.getStaffArray(this.maxStavesCount).map((staff) => staff && staff.measures[index]);\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex,\n\t\t\t\t\tsystem,\n\t\t\t\t\tlocalIndex: index,\n\t\t\t\t\tleft: measure.left,\n\t\t\t\t\tright: measure.right,\n\t\t\t\t\tmeasures,\n\t\t\t\t};\n\t\t\t}\n\t\t\tindex -= system.measureCount;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetRawCluster(measureIndex: number, threshold: number, { timeSignature }: Partial = {}): SemanticCluster {\n\t\tconst position = this.getMeasure(measureIndex);\n\t\tif (!position) return null;\n\n\t\tconst { system, left, right } = position;\n\t\t//console.log(\"measure:\", system, left, right);\n\n\t\tconst elements: SemanticElement[] = [BOS_ELEMENT];\n\n\t\tif (timeSignature) elements.push(...fractionToElems(timeSignature));\n\n\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tlet points = system.qualifiedSemantics(staff.semantics, threshold).filter((point) => point.x > left && point.x < right);\n\t\t\tpoints = solveOverlapping(points);\n\n\t\t\t// exlude tempo noteheads\n\t\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t});\n\n\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\n\t\t\tpoints.forEach((point) => {\n\t\t\t\tconst type = SemanticElementType[point.semantic];\n\t\t\t\tif (type) {\n\t\t\t\t\tlet y1 = point.y;\n\t\t\t\t\tlet y2 = point.y;\n\t\t\t\t\tif (type === SemanticElementType.vline_Stem) {\n\t\t\t\t\t\ty1 = point.extension.y1;\n\t\t\t\t\t\ty2 = point.extension.y2;\n\t\t\t\t\t}\n\n\t\t\t\t\telements.push({\n\t\t\t\t\t\tid: point.id,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\tx: point.x - left,\n\t\t\t\t\t\ty1: y1 + y0,\n\t\t\t\t\t\ty2: y2 + y0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new SemanticCluster({\n\t\t\tindex: measureIndex,\n\t\t\telements,\n\t\t});\n\t}\n\n\tgetRawClusters(threshold: number = 1): SemanticCluster[] {\n\t\t//const times = this.getMeasuresTime();\n\n\t\treturn Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => this.getRawCluster(mi, threshold /*, times[mi]*/));\n\t}\n\n\tmakeSpartito(logger: Logger = new DummyLogger()): Spartito {\n\t\tlet eventSystems: EventSystem[] = this.systems.map((system) => system.getEvents(this.maxStavesCount));\n\n\t\t/*if (this.topology) {\n\t\t\tconst clusters = this.topology.clusters;\n\n\t\t\t// [measure, staff, event]\n\t\t\tconst eventsColumns: ChordColumn[][][] = clusters\n\t\t\t\t.filter((cluster) => cluster.index < this.measureCount)\n\t\t\t\t.reduce((columns, cluster) => {\n\t\t\t\t\tconst { system, measures } = this.getMeasure(cluster.index);\n\t\t\t\t\tconst events = cluster.getEvents();\n\n\t\t\t\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\t\t\t\t\tconst x0 = measures.filter(Boolean)[0].left;\n\n\t\t\t\t\tconst staves = system.getStaffArray(this.maxStavesCount);\n\n\t\t\t\t\t// translate by staff & measure relative offset\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst staff = staves[event.staff];\n\t\t\t\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\t\t\t\t\t\tevent.ys = event.ys.map((y) => roundNumber(y - y0, 0.5));\n\n\t\t\t\t\t\tevent.left += x0;\n\t\t\t\t\t\tevent.right += x0;\n\t\t\t\t\t});\n\n\t\t\t\t\tconst column = measures.map((measure, staffIndex) => {\n\t\t\t\t\t\tif (!measure) return [];\n\n\t\t\t\t\t\t//console.log(\"m:\", mi, \"s:\", staffIndex);\n\t\t\t\t\t\tconst localEvents = events.filter((event) => event.staff === staffIndex);\n\t\t\t\t\t\t//measure.assignModifiersOnEvents(localEvents);\n\t\t\t\t\t\tmeasure.assignAccessoriesOnEvents(localEvents);\n\n\t\t\t\t\t\treturn localEvents;\n\t\t\t\t\t});\n\n\t\t\t\t\tcolumns[cluster.index] = column;\n\n\t\t\t\t\treturn columns;\n\t\t\t\t}, []);\n\n\t\t\tconst breakSystemIndices = this.breakSystemIndices;\n\n\t\t\tconst basicEventSystems = eventSystems;\n\t\t\teventSystems = [];\n\n\t\t\tlet measures = 0;\n\t\t\tfor (const system of this.systems) {\n\t\t\t\tconst esys = system.getEventsFunctional(this.maxStavesCount, (si, mi) => eventsColumns[measures + mi] && eventsColumns[measures + mi][si], [], {\n\t\t\t\t\tuseXMap: false,\n\t\t\t\t});\n\n\t\t\t\tconst basicSys = basicEventSystems[system.index];\n\t\t\t\t//onst nullN = esys.columns.filter(c => !c).length;\n\t\t\t\t//if (nullN)\n\t\t\t\t//\tconsole.log(\"null:\", nullN, esys.columns.length);\n\t\t\t\tesys.columns = esys.columns.map((column, i) => (column ? column : basicSys.columns[i]));\n\n\t\t\t\tconst sysIndex = this.systems.indexOf(system);\n\t\t\t\tconst pageBreak = breakSystemIndices.includes(sysIndex);\n\t\t\t\tconst lastColumn = esys.columns[esys.columns.length - 1];\n\t\t\t\tif (lastColumn) {\n\t\t\t\t\tlastColumn.break = true;\n\t\t\t\t\tlastColumn.pageBreak = pageBreak;\n\t\t\t\t}\n\n\t\t\t\teventSystems.push(esys);\n\t\t\t\tmeasures += system.measureCount;\n\t\t\t}\n\t\t}*/\n\n\t\tconst staves = this.eventSystemsToTermStaves(eventSystems, logger);\n\n\t\t// assign staff basics for columns\n\t\teventSystems.forEach((sys, ri) => {\n\t\t\tsys.columns.forEach((column, mi) => {\n\t\t\t\tcolumn.basics = staves.map((staff) => {\n\t\t\t\t\tconst { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig } = staff.rows[ri][mi];\n\n\t\t\t\t\treturn { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig };\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tconst clusters = null; //this.topology && this.topology.clusters;\n\n\t\tconst measures = [].concat(\n\t\t\t...eventSystems.map((esys) =>\n\t\t\t\tesys.columns.map((column) => {\n\t\t\t\t\tconst measureIndex = column.measureIndex;\n\t\t\t\t\tconst { system, localIndex, left, right } = this.getMeasure(measureIndex);\n\n\t\t\t\t\tconst cluster = clusters && clusters.find((cluster) => cluster.index === measureIndex);\n\n\t\t\t\t\tconst staffYsFull = [];\n\t\t\t\t\tsystem.staves.forEach((staff) => (staffYsFull[staff.index] = staff.top + staff.staffY));\n\n\t\t\t\t\tconst patch = this.patches && this.patches.find((patch) => patch.measureIndex === measureIndex);\n\t\t\t\t\tconst events = patch ? patch.events : SpartitoMeasure.reorderEvents([].concat(...column.rows.map((row) => row.events)), staffYsFull);\n\n\t\t\t\t\tconst barTypes = Object.fromEntries(Object.entries(column.barTypes).map(([k, v]) => [k, v / system.staves.length]));\n\t\t\t\t\tconst indent = localIndex === 0 && system.indent;\n\n\t\t\t\t\treturn new SpartitoMeasure({\n\t\t\t\t\t\tmeasureIndex,\n\t\t\t\t\t\tstaffMask: esys.staffMask,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\t\tlocalIndex,\n\t\t\t\t\t\t\tleft,\n\t\t\t\t\t\t\tright,\n\t\t\t\t\t\t\tstaffYs: system.staves.map((staff) => staff.top + staff.staffY),\n\t\t\t\t\t\t\tstaffYsFull,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t//startX: column.startX,\n\t\t\t\t\t\t//width: column.width,\n\t\t\t\t\t\tduration: patch ? patch.duration : column.duration,\n\t\t\t\t\t\tevents,\n\t\t\t\t\t\tcontexts: column.rows.map((row) => row.contexts),\n\t\t\t\t\t\tmarks: column.marks,\n\t\t\t\t\t\tbreak: column.break,\n\t\t\t\t\t\tpageBreak: column.pageBreak,\n\t\t\t\t\t\tvoltaBegin: column.voltaBegin,\n\t\t\t\t\t\tvoltaEnd: column.voltaEnd,\n\t\t\t\t\t\talternative: column.alternative,\n\t\t\t\t\t\tbarTypes,\n\t\t\t\t\t\tindent,\n\t\t\t\t\t\tbasics: patch ? patch.basics : column.basics,\n\t\t\t\t\t\tmatrixH: cluster && cluster.matrixH,\n\t\t\t\t\t\tmatrixV: cluster && cluster.matrixV,\n\t\t\t\t\t\tvoices: patch ? patch.voices : null,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst staffLayout = this.staffLayout;\n\t\tconst staffGroups = staffLayout.standaloneGroups.map((ids) => ids.map((id) => staffLayout.staffIds.indexOf(id)));\n\n\t\tthis.spartito = new Spartito({\n\t\t\tstavesCount: this.maxStavesCount,\n\t\t\tstaffGroups,\n\t\t\tmeasures,\n\t\t});\n\n\t\treturn this.spartito;\n\t}\n\n\tmakeMusicSheet(): MusicSheet {\n\t\tconst spartito = this.spartito || this.makeSpartito();\n\n\t\tif (!spartito.regulated) console.warn('[makeMusicSheet]\tspartito not regulated.');\n\n\t\tconst voiceStaves = spartito.makeVoiceStaves();\n\n\t\tconst { title, pageSize, unitSize, staffLayout, paperOptions, headers, instrumentDict } = this;\n\t\tconst measureLayout = this.getMeasureLayout();\n\n\t\treturn {\n\t\t\ttitle,\n\t\t\tpageSize,\n\t\t\tunitSize,\n\t\t\tmeasureLayout,\n\t\t\tstaffLayout,\n\t\t\tpaperOptions,\n\t\t\theaders,\n\t\t\tvoiceStaves,\n\t\t\tinstrumentDict,\n\t\t};\n\t}\n\n\tfindPoint(sid: string): PointPosition {\n\t\tfor (const system of this.systems) {\n\t\t\tfor (let si = 0; si < system.staves.length; ++si) {\n\t\t\t\tconst point = system.staves[si].semantics.find((point) => point.id === sid);\n\t\t\t\tif (point) {\n\t\t\t\t\tconst pageIndex = this.pages.findIndex((page) => page.systems.includes(system));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpoint,\n\t\t\t\t\t\tpageIndex,\n\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\tstaffIndex: si,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetMeasureSemantics(systemIndex: number, localIndex: number): SemanticPointInMeasure[] {\n\t\tconst system = this.systems[systemIndex];\n\t\tif (!system) return null;\n\n\t\tconst left = localIndex ? system.measureBars[localIndex - 1] : 0;\n\t\tconst right = system.measureBars[localIndex] || system.width;\n\n\t\treturn system.staves\n\t\t\t.map((staff, si) => {\n\t\t\t\tconst staffY = staff.top + staff.staffY;\n\t\t\t\treturn staff.semantics\n\t\t\t\t\t.filter((point) => point.x >= left && point.x < right)\n\t\t\t\t\t.map((point) => {\n\t\t\t\t\t\tconst [y1, y2] = Number.isFinite(point.extension?.y1) ? [point.extension.y1, point.extension.y2] : [point.y, point.y];\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\tstaff: si,\n\t\t\t\t\t\t\tsy1: y1 + staffY,\n\t\t\t\t\t\t\tsy2: y2 + staffY,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1);\n\t}\n\n\tmakeTimewiseGraph({ store = false }: { store?: boolean } = {}): TimewiseGraph {\n\t\tif (!this.spartito) return null;\n\n\t\tconst measures = this.spartito.measures\n\t\t\t.filter((measure) => measure.events.length > 0)\n\t\t\t.map((measure) => {\n\t\t\t\tconst points = this.getMeasureSemantics(measure.position.systemIndex, measure.position.localIndex);\n\n\t\t\t\tconst graph = {\n\t\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\t\tleft: measure.position.left,\n\t\t\t\t\tright: measure.position.right,\n\t\t\t\t\tpoints,\n\t\t\t\t};\n\n\t\t\t\tif (store) measure.graph = graph;\n\n\t\t\t\treturn graph;\n\t\t\t});\n\n\t\treturn { measures };\n\t}\n\n\tgetTokenMap(): Map {\n\t\tconst map = new Map();\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => staff.measures.forEach((measure) => measure.tokens.forEach((token) => map.set(token.id, token))))\n\t\t);\n\n\t\treturn map;\n\t}\n\n\tassemble(confidenceThreshold: number = 1, logger: Logger = new DummyLogger()) {\n\t\tconst ids = new Map();\n\n\t\tconst append = (systemIndex, staffIndex, point) => {\n\t\t\tconst id = hashSemanticPoint(systemIndex, staffIndex, point);\n\t\t\tlogger.assert(!ids.has(id), 'semantic point hash conflicted:', id, point, ids.get(id));\n\n\t\t\tids.set(id, point);\n\t\t};\n\n\t\tthis.pages.forEach((page, index) => (page.index = index));\n\n\t\tlet measureIndex = 0;\n\t\tthis.systems.forEach((system, systemIndex) => {\n\t\t\tsystem.index = systemIndex;\n\t\t\tsystem.headMeasureIndex = measureIndex;\n\t\t\tsystem.prev = this.systems[systemIndex - 1] || null;\n\t\t\tsystem.next = this.systems[systemIndex + 1] || null;\n\n\t\t\tif (system.semantics && system.semantics.length) system.semantics.forEach((point) => append(systemIndex, null, point));\n\n\t\t\tsystem.assemble(confidenceThreshold, logger);\n\t\t\tmeasureIndex += system.measureCount;\n\t\t});\n\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tpage.systems.forEach((system) => (system.pageIndex = i));\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations }, logger);\n\t\t});\n\t}\n\n\tassembleSystem(system: System, confidenceThreshold: number = 1) {\n\t\tthis.systems.forEach((system, si) => (system.index = si));\n\t\tconst systemIndex = system.index;\n\n\t\tif (system.semantics && system.semantics.length) {\n\t\t\tsystem.semantics.forEach((point) => hashSemanticPoint(systemIndex, null, point));\n\t\t\tsystem.assemble(confidenceThreshold);\n\t\t}\n\t}\n\n\tmarkVoices(staves: VoicesStaff[]): void {\n\t\tconst tokenMap = this.getTokenMap();\n\t\tfor (const token of tokenMap.values()) token.voice = 0;\n\n\t\tconst vis = []\n\t\t\t.concat(...staves.map((staff, s) => (staff.voices || []).map((_, v) => [s, v])))\n\t\t\t.sort(([s1, v1], [s2, v2]) => v1 - v2 || s1 - s2)\n\t\t\t.map(([s, v]) => `${s}|${v}`);\n\n\t\tstaves.forEach((staff, si) =>\n\t\t\t(staff.voices || []).forEach((voice, vi) =>\n\t\t\t\tvoice.measures.forEach((measure) => {\n\t\t\t\t\tconst voiceIndex = vis.indexOf(`${si}|${vi}`);\n\n\t\t\t\t\tconst events = Object.values(measure.tickMap).filter((event) => event instanceof EventTerm) as EventTerm[];\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst notes = event.noteIds ? event.noteIds.map((id) => tokenMap.get(id)).filter(Boolean) : [];\n\t\t\t\t\t\tconst accessories = event.accessories ? event.accessories.map((acc) => tokenMap.get(acc.id)).filter(Boolean) : [];\n\t\t\t\t\t\t//console.log(\"notes:\", si, vi, mi, event.noteIds, notes, accessories);\n\n\t\t\t\t\t\t[...notes, ...accessories].forEach((token) => (token.voice |= 1 << voiceIndex));\n\n\t\t\t\t\t\tif (event.timeWarp) notes.forEach((note) => (note.timeWarped = true));\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t}\n\n\tasync replaceImageKeys(proc: (x: string | Buffer) => Promise): Promise {\n\t\tawait Promise.all([\n\t\t\t...(this.pages.map(async (page) => {\n\t\t\t\tif (page.source) page.source.url = await proc(page.source.url);\n\t\t\t}) as Promise[]),\n\t\t\t...this.systems.map((system) =>\n\t\t\t\tPromise.all([\n\t\t\t\t\tproc(system.backgroundImage).then((key) => (system.backgroundImage = key)),\n\t\t\t\t\t...(system.staves.map(async (staff) => {\n\t\t\t\t\t\tstaff.backgroundImage = await proc(staff.backgroundImage);\n\t\t\t\t\t\tstaff.maskImage = await proc(staff.maskImage);\n\t\t\t\t\t}) as Promise[]),\n\t\t\t\t])\n\t\t\t),\n\t\t]);\n\t}\n\n\tinferenceStaffLayout(): void {\n\t\t// inference the complete layout\n\t\tconst staffTotal = Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t\tthis.staffLayoutCode = Array(staffTotal).fill('').join(',');\n\n\t\tconst completeSystems = this.systems.filter((system) => system.staves.length === staffTotal && system.bracketsAppearance);\n\t\tif (!completeSystems.length) return; // no enough evidence\n\n\t\tconst candidateCodes = completeSystems\n\t\t\t.map((system) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst layout = staffLayout.parseCode(system.bracketsAppearance);\n\t\t\t\t\tif (layout.staffIds.length !== system.staves.length) return null;\n\n\t\t\t\t\treturn system.bracketsAppearance;\n\t\t\t\t} catch (_) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t\tif (!candidateCodes.length) return; // no valid layout\n\n\t\tconst codeCounting = candidateCodes.reduce((acc, code) => {\n\t\t\tconst count = acc[code] || 0;\n\t\t\tacc[code] = count + 1;\n\t\t\treturn acc;\n\t\t}, {} as { [code: string]: number });\n\t\tconst maxCount = Math.max(...Object.values(codeCounting));\n\t\tconst code = Object.entries(codeCounting).find(([_, count]) => count === maxCount)[0];\n\n\t\t// added connection lines between braces {-}\n\t\tconst connectedCode = code.replace(/\\{,*\\}/g, (match) => match.replace(/,/g, '-'));\n\t\tconst layout = staffLayout.parseCode(connectedCode);\n\n\t\tthis.staffLayoutCode = connectedCode;\n\t\t//console.log(\"complete code:\", code);\n\n\t\t// inference systems' mask\n\t\tlet lastSys: System = null;\n\t\tfor (const system of this.systems) {\n\t\t\tif (lastSys && system.staves.length === lastSys.staves.length && system.bracketsAppearance === lastSys.bracketsAppearance) {\n\t\t\t\tsystem.staffMaskChanged = null;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (system.staves.length < staffTotal && system.bracketsAppearance) {\n\t\t\t\t// validate the system brackets code\n\t\t\t\ttry {\n\t\t\t\t\tif (!staffLayout.parseCode(system.bracketsAppearance)) continue;\n\t\t\t\t} catch (_) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst search = (bits: (0 | 1)[]): number => {\n\t\t\t\t\tif (bits.length > layout.staffIds.length) return null;\n\n\t\t\t\t\tif (bits.reduce((sum, bit) => sum + bit, 0) === system.staves.length) return bitsToMask(bits);\n\n\t\t\t\t\tfor (const bit of [1, 0]) {\n\t\t\t\t\t\tconst bb = [...bits, bit] as (0 | 1)[];\n\t\t\t\t\t\tconst code1 = layout.partialMaskCode(bb);\n\t\t\t\t\t\tif (code1 === system.bracketsAppearance) return bitsToMask(bb);\n\t\t\t\t\t\telse if (system.bracketsAppearance.startsWith(code1)) {\n\t\t\t\t\t\t\tconst result = search(bb);\n\t\t\t\t\t\t\tif (result) return result;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t};\n\t\t\t\tconst mask = search([]);\n\t\t\t\t//console.log(\"mask:\", system.bracketsAppearance, mask.toString(2));\n\n\t\t\t\tsystem.staffMaskChanged = !lastSys || mask !== lastSys.staffMask ? mask : null;\n\t\t\t}\n\n\t\t\tlastSys = system;\n\t\t}\n\t}\n\n\tassignBackgroundForMeasure(measure: SpartitoMeasure): void {\n\t\tmeasure.backgroundImages = [];\n\n\t\tconst system = this.systems[measure.position.systemIndex];\n\t\tif (system.backgroundImage) {\n\t\t\tmeasure.backgroundImages.push({\n\t\t\t\turl: system.backgroundImage,\n\t\t\t\tposition: system.imagePosition,\n\t\t\t\toriginal: true,\n\t\t\t});\n\t\t}\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tif (!system.backgroundImage && staff.backgroundImage)\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.backgroundImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t\toriginal: true,\n\t\t\t\t});\n\n\t\t\tif (staff.maskImage) {\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.maskImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tblackoutFakeNotes(scope: 'patched' | 'perfect' | 'all' = 'patched'): string[] {\n\t\tif (!this.spartito) return;\n\n\t\tlet inScope = (_) => true;\n\t\tswitch (scope) {\n\t\t\tcase 'patched':\n\t\t\t\tinScope = (measure) => measure.patched;\n\t\t\t\tbreak;\n\t\t\tcase 'perfect':\n\t\t\t\tinScope = (measure) => measure.patched || (measure.regulated && evaluateMeasure(measure).perfect);\n\t\t\t\tbreak;\n\t\t}\n\t\tconst measures = this.spartito.measures.filter(inScope);\n\n\t\tconst fakeIds = measures.reduce((ids, measure) => {\n\t\t\tif (!measure.regulated) return;\n\n\t\t\tconst voicedIds = measure.voices.flat(1);\n\t\t\tconst fakeChords = measure.events.filter((event) => !event.rest && !event.grace && !voicedIds.includes(event.id));\n\n\t\t\tfakeChords.forEach((event) => event.noteIds && ids.push(...event.noteIds));\n\n\t\t\treturn ids;\n\t\t}, [] as string[]);\n\t\tconst fakeIdSet = new Set(fakeIds);\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\tconst blackIds = staff.semantics.filter((point) => fakeIdSet.has(point.id)).map((point) => point.id);\n\t\t\t\tsystem.sidBlackList.push(...blackIds);\n\t\t\t})\n\t\t);\n\n\t\treturn fakeIds;\n\t}\n\n\tgetMeasureLayout(): measureLayout.MeasureLayout {\n\t\tconst code = this.spartito && this.spartito.measureLayoutCode;\n\t\tif (code) {\n\t\t\ttry {\n\t\t\t\treturn measureLayout.parseCode(code);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.debug('invalid measure layout code:', err);\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t*splitToSingleScoresGen(): Generator {\n\t\tthis.assemble();\n\t\tconst startSysIndices = this.systems.filter((system) => system.index > 0 && system.indent && system.timeSignatureOnHead).map((system) => system.index);\n\n\t\tif (!startSysIndices.length) {\n\t\t\tyield this.deepCopy();\n\t\t\treturn;\n\t\t}\n\n\t\tconst templateScore = new Score({ ...this, pages: [], topology: undefined, spartito: undefined, patches: undefined });\n\n\t\t// clear temporary objects before deep dopy\n\t\tthis.pages.forEach((page) => {\n\t\t\tdelete page.tokens;\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tdelete system.tokens;\n\t\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\t\tstaff.measures = [];\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tlet startSysIndex = 0;\n\t\tfor (const endSysIndex of [...startSysIndices, this.systems.length]) {\n\t\t\tconst sysInRange = (system) => system.index >= startSysIndex && system.index < endSysIndex;\n\t\t\tconst pages = this.pages\n\t\t\t\t.filter((page) => page.systems.some(sysInRange))\n\t\t\t\t.map((page) => {\n\t\t\t\t\tconst { systems, ...fields } = page;\n\t\t\t\t\treturn new Page({ ...fields, systems: systems.filter(sysInRange).map((system) => new System({ ...system })) });\n\t\t\t\t});\n\n\t\t\tconst newScore = templateScore.deepCopy();\n\t\t\tnewScore.headers.SubScoreSystem = `${startSysIndex}-${endSysIndex - 1}`;\n\t\t\tnewScore.headers.SubScorePage = `${pages[0].index}-${pages[pages.length - 1].index}`;\n\n\t\t\t//newScore.pages = pages.map((page) => page.deepCopy());\n\t\t\tnewScore.pages = pages;\n\t\t\tnewScore.assemble();\n\t\t\tnewScore.inferenceStaffLayout();\n\n\t\t\tstartSysIndex = endSysIndex;\n\n\t\t\tyield newScore;\n\t\t}\n\t}\n\n\tsplitToSingleScores(): Score[] {\n\t\treturn [...this.splitToSingleScoresGen()];\n\t}\n}\n\nexport { PaperOptions, Score, Page, System, Staff, Measure, MeasureValidation };\nexport type { SemanticPointInMeasure };\n","import type { MeasureLayout } from './measureLayout';\nimport * as measureLayout from './measureLayout';\nimport grammar from './grammar.jison';\nimport { recoverJSON } from '../starry/aux_/typedJSON';\n\nconst parseCode = (code: string): MeasureLayout => {\n\tconst raw = grammar.parse(code);\n\n\tif (raw?.data) return recoverJSON(raw.data, measureLayout);\n\n\treturn null;\n};\n\nexport { parseCode };\n","import { MIDI } from '@k-l-lambda/music-widgets';\n\nimport { Fraction } from './interfaces';\nimport { noteToPitch } from './utils';\nimport { EventTerm, RestType, GraceType, StemBeam, ArpeggioStyle, TermPitch, TremoloLink } from './term';\nimport { SpartitoMeasure } from './spartitoMeasure';\n\n// NOTE: 'JSONEditor.onEditable' determine whether a field is editable, here 'readonly' modifier has no effect to UI\n\ninterface EventUIAgent {\n\treadonly id: number;\n\treadonly duration: number;\n\n\t//ys: number[];\n\tpitches: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\tgrace: boolean; //\n\tbeam: StemBeam;\n\ttimeWarp: string; //\n\ttremolo: number;\n\ttremoloLink: TremoloLink;\n\tglissando: boolean;\n\tarpeggioStyle: ArpeggioStyle;\n\ttick: number;\n}\n\ninterface MeasureUIAgent {\n\treadonly measureIndex: number;\n\ttimeSignature: Fraction;\n\tdoubtfulTimesig: boolean;\n\tkeySignature: number;\n\t//readonly events: EventUIAgent[];\n\tduration: number;\n\treadonly voices: number[][];\n}\n\nclass EditableEvent extends EventTerm {\n\tvoice: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t}\n\n\tget agent(): EventUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget(target, key): any {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'arpeggioStyle': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? null : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'glissando': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? false : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\treturn !!self.grace;\n\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\treturn self.timeWarp ? `${self.timeWarp.numerator}/${self.timeWarp.denominator}` : null;\n\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn self.pitches;\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'glissando':\n\t\t\t\t\tcase 'arpeggioStyle':\n\t\t\t\t\t\t(self as any)[key] = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\tself.grace = value ? GraceType.Grace : null;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\tself.timeWarp = null;\n\t\t\t\t\t\tif (value && typeof value === 'string') {\n\t\t\t\t\t\t\tconst captures = value.match(/^(\\d+)\\/(\\d+)/);\n\t\t\t\t\t\t\tif (captures) {\n\t\t\t\t\t\t\t\tself.timeWarp = {\n\t\t\t\t\t\t\t\t\tnumerator: parseInt(captures[1]),\n\t\t\t\t\t\t\t\t\tdenominator: parseInt(captures[2]),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => [\n\t\t\t\t'id',\n\t\t\t\t'duration',\n\t\t\t\t'rest',\n\t\t\t\t'division',\n\t\t\t\t'dots',\n\t\t\t\t'stemDirection',\n\t\t\t\t'tying',\n\t\t\t\t'tied',\n\t\t\t\t'beam',\n\t\t\t\t'timeWarp',\n\t\t\t\t'tremolo',\n\t\t\t\t'tremoloLink',\n\t\t\t\t'glissando',\n\t\t\t\t'arpeggioStyle',\n\t\t\t\t'tick',\n\t\t\t\t'grace',\n\t\t\t\t'pitches',\n\t\t\t],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n}\n\nclass EditableMeasure extends SpartitoMeasure {\n\tstatic className = 'EditableMeasure';\n\tstatic blackKeys = [];\n\n\tevents: EditableEvent[] = null;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\n\t\tthis.events = data.events;\n\t\tif (this.events?.some((event) => !(event instanceof EditableEvent))) this.events = this.events.map((event) => new EditableEvent(event));\n\n\t\tif (this.voices) this.syncVoiceToEvents();\n\t}\n\n\tsyncVoiceToEvents(): void {\n\t\tthis.events.forEach((event) => (event.voice = -1));\n\t\tthis.voices.forEach((voice, voiceIndex) => {\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\tif (event) event.voice = voiceIndex;\n\t\t\t\telse console.warn('no event with id:', id, this.events.length);\n\t\t\t});\n\t\t});\n\t}\n\n\tsyncVoiceFromEvents(): void {\n\t\tconst voices: EditableEvent[][] = [];\n\t\tthis.events.forEach((event) => {\n\t\t\tif (event?.voice >= 0) {\n\t\t\t\tvoices[event.voice] = voices[event.voice] || [];\n\t\t\t\tvoices[event.voice].push(event);\n\t\t\t}\n\t\t});\n\n\t\tvoices.forEach((voice) => voice.sort((e1, e2) => e1.tick - e2.tick));\n\n\t\tthis.voices = voices.map((voice) => voice.map((event) => event.id));\n\t}\n\n\tget agent(): MeasureUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget: (target, key): any => {\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\treturn self[key];\n\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn self.voices?.map((voice) => voice.join(',')) || null;\n\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\treturn self.basics[0][key];\n\t\t\t\t\t//case 'events':\n\t\t\t\t\t//\treturn self.events.map(eventUIAgent);\n\t\t\t\t\tcase 'toJSON':\n\t\t\t\t\t\treturn () => ({\n\t\t\t\t\t\t\tmeasureIndex: self.measureIndex,\n\t\t\t\t\t\t\tvoices: self.voices,\n\t\t\t\t\t\t\tduration: self.duration,\n\t\t\t\t\t\t\ttimeSignature: self.basics[0].timeSignature,\n\t\t\t\t\t\t\tkeySignature: self.basics[0].keySignature,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\t//console.log('set:', key, value);\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\t(self.basics[0][key] as any) = value;\n\t\t\t\t\t\tself.basics = self.basics.map(() => self.basics[0]);\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\tself.duration = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => ['measureIndex', 'timeSignature', 'doubtfulTimesig', 'keySignature', 'duration', 'voices'],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n\n\tmakeMIDI(bpm: number = 120): MIDI.MidiData {\n\t\tif (!this.regulated) return null;\n\n\t\tconst microsecondsPerBeat = 60e6 / bpm;\n\n\t\tconst header = { formatType: 0, ticksPerBeat: 480 };\n\t\tconst tracks = this.voices.map((ids, vi) => {\n\t\t\tconst events = ids\n\t\t\t\t.map((id) => {\n\t\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\t\tif (event) {\n\t\t\t\t\t\tconst subEvents = event.graceIds ? event.graceIds.map((id) => this.events.find((event) => event.id === id)) : [];\n\n\t\t\t\t\t\treturn [...subEvents, event];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [];\n\t\t\t\t})\n\t\t\t\t.flat(1);\n\n\t\t\tconst startTime = 0;\n\n\t\t\ttype Event = MIDI.MidiEvent & { [key: string]: any };\n\t\t\tconst midiEvents: Event[] = events\n\t\t\t\t.filter((event) => !event.rest && Number.isFinite(event.tick) && event.tick >= 0 && Number.isFinite(event.duration))\n\t\t\t\t.map((event) =>\n\t\t\t\t\tevent.pitches.map((pitch) => [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t\tvelocity: 96,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick + event.duration,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t\t.flat(2);\n\n\t\t\tmidiEvents.sort(function (e1, e2) {\n\t\t\t\treturn e1.time - e2.time;\n\t\t\t});\n\n\t\t\tif (vi === 0) {\n\t\t\t\tmidiEvents.unshift(\n\t\t\t\t\t{\n\t\t\t\t\t\ttime: startTime,\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tsubtype: 'timeSignature',\n\t\t\t\t\t\tnumerator: this.timeSignature.numerator,\n\t\t\t\t\t\tdenominator: this.timeSignature.denominator,\n\t\t\t\t\t\tthirtyseconds: 8,\n\t\t\t\t\t},\n\t\t\t\t\t{ time: startTime, type: 'meta', subtype: 'setTempo', microsecondsPerBeat }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmidiEvents.forEach((event) => {\n\t\t\t\tevent.ticks = Math.round(event.time - startTime);\n\t\t\t});\n\t\t\tmidiEvents.forEach((event, i) => {\n\t\t\t\tevent.deltaTime = event.ticks - (i > 0 ? midiEvents[i - 1].ticks : 0);\n\t\t\t});\n\n\t\t\tmidiEvents.push({ deltaTime: 0, type: 'meta', subtype: 'endOfTrack' });\n\n\t\t\treturn midiEvents;\n\t\t});\n\n\t\treturn {\n\t\t\theader,\n\t\t\ttracks,\n\t\t};\n\t}\n}\n\nexport { EditableEvent, EditableMeasure };\n","import { RegulationSolution, RegulationSolutionEvent, EventPredisposition } from './interfaces';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport { argmax, frac } from './utils';\nimport { WHOLE_DURATION, StemBeam } from './term';\nimport { Logger, DummyLogger } from './logger';\n\ninterface BeadPicker {\n\tn_seq: number;\n\tquota: number;\n\tcost: number; // duration in milliseconds\n\n\tpredictCluster(cluster: EventCluster, tip: number): Promise;\n}\n\nenum BeadType {\n\tPass = 'i',\n\tDivision = 'd',\n\tDots = 'o',\n}\n\nconst DIVISION_NAMES = ['whole', 'half', 'quarter', 'eighth', 'sixteenth', 'thirtysecond', 'sixtyfourth', '128th', '256th'];\n\ninterface BeadNodeInitData {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n}\n\nconst RESIDUE_LOSS_WEIGHT = 0.2;\nconst VOICEN_LOSS_WEIGHT = 0.002;\nconst SPACE_LOSS_WEIGHT = 0.4 / WHOLE_DURATION;\nconst PRETENTIOUSNESS_LOSS_WEIGHT = 0.02;\n\nconst POSSIBILITY_LOW_BOUNDARY = 1e-12;\n\nconst PRETENTIOUSNESS_CLIP = 100;\n\ninterface ClusterEvaluation {\n\ttickErr: number;\n\ttwist: number;\n\tresidue: number;\n\tendTick: number;\n\tfatalError: boolean;\n\tvoiceN: number;\n\tspaceDuration: number;\n\tpretentiousness: number;\n\tloss: number;\n}\n\ninterface ElementState {\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tbeam: StemBeam;\n\tstemDirection: string;\n\tgrace: boolean;\n\ttimeWarped: boolean;\n\tfullMeasure: boolean; // full measure rest\n\tfake: boolean;\n\torder: number;\n\tpredisposition: EventPredisposition;\n}\n\ninterface ClusterState {\n\telements: ElementState[];\n}\n\nconst STEM_DIRECTION_OPTIONS = [undefined, 'u', 'd'];\n\nconst BEAM_OPTIONS = [undefined, StemBeam.Open, StemBeam.Continue, StemBeam.Close];\n\nconst saveClusterState = (cluster: EventCluster): ClusterState => ({\n\telements: cluster.elements.map((elem) => ({\n\t\ttick: elem.tick!,\n\t\tdivision: elem.division!,\n\t\tdots: elem.dots!,\n\t\tbeam: elem.beam!,\n\t\tstemDirection: elem.stemDirection!,\n\t\tgrace: elem.grace!,\n\t\ttimeWarped: elem.timeWarped!,\n\t\tfullMeasure: elem.fullMeasure!,\n\t\tfake: elem.fake!,\n\t\torder: elem.order!,\n\t\tpredisposition: elem.predisposition!,\n\t})),\n});\n\nconst restoreClusterState = (cluster: EventCluster, state: ClusterState): void => cluster.elements.forEach((elem, i) => Object.assign(elem, state.elements[i]));\n\nconst measurePretentious = (p) => Math.min(PRETENTIOUSNESS_CLIP, -Math.log(p));\n\ninterface BeadDeductionContext {\n\tpicker: BeadPicker;\n\tlogger: Logger;\n\tptFactor: number; // pretentiousness tolerance factor\n}\n\nclass BeadNode {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n\n\tchildren: Record;\n\taccessCount: number;\n\n\tconstructor(data: BeadNodeInitData) {\n\t\tObject.assign(this, data);\n\n\t\t//this.possibilities = this.possibilities.map((x, i) => (this.type === BeadType.Pass && !i) ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\n\t\tthis.children = {};\n\t\tthis.accessCount = 0;\n\t}\n\n\tnextBranch(): number | null {\n\t\tconst ps = this.possibilities.map((p, i) => p / (this.children[i] ? this.children[i].accessCount + 1 : 1));\n\t\t//const ps = this.possibilities.map((p, i) => p * (this.children[i] ? (2 ** -this.children[i].accessCount) : 1));\n\n\t\tif (ps.every((p) => !p)) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn null;\n\t\t}\n\n\t\treturn argmax(ps);\n\t}\n\n\tget currentElem(): EventElement {\n\t\treturn this.cluster.elements[this.elemIndex];\n\t}\n\n\tbranchID(ni: number): string {\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\treturn `i_${ni}`;\n\t\t\tcase BeadType.Division:\n\t\t\t\treturn DIVISION_NAMES[ni];\n\t\t\tcase BeadType.Dots:\n\t\t\t\treturn 'o' + '.'.repeat(ni);\n\t\t}\n\n\t\treturn '';\n\t}\n\n\tasync deduce({ picker, logger, ptFactor }: BeadDeductionContext, deep: number = 0): Promise {\n\t\t++this.accessCount;\n\n\t\tconst ni = this.nextBranch()!;\n\t\tlogger.debug(String.fromCodePoint(0x1f349) + ' '.repeat(deep), this.branchID(ni), this.accessCount > 1 ? `[${this.accessCount}]` : '');\n\n\t\tif (!Number.isInteger(ni) || ni < 0) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tthis.pretentiousness += measurePretentious(this.possibilities[ni]);\n\t\tif (this.pretentiousness > PRETENTIOUSNESS_CLIP * ptFactor) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tlet selfEval: null | ClusterEvaluation = null;\n\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\t{\n\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\tconst element = this.cluster.elements[ni];\n\t\t\t\t\tconsole.assert(element, 'null element:', ni, this.cluster.elements.length);\n\t\t\t\t\tif (element.type === EventElementType.EOS) {\n\t\t\t\t\t\tselfEval = evaluateCluster(this.cluster, tip, this.pretentiousness);\n\t\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.cluster.elements[0].order = tip;\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip + 1)).map((x, i) =>\n\t\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 || i === this.cluster.elements.length - 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: 0,\n\t\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.order = tip;\n\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tconsole.assert(element.predisposition, 'no predisposition:', ni, this.possibilities);\n\t\t\t\t\t\t\tconst possibilities = element.predisposition!.divisionVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: ni,\n\t\t\t\t\t\t\t\ttype: BeadType.Division,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Division:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.division = ni;\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tconst possibilities = this.currentElem.predisposition!.dotsVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Dots,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Dots:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.dots = ni;\n\n\t\t\t\t\tselfEval = evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip)).map((x, i) =>\n\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\tconst evaluation = await this.children[ni].deduce({ picker, logger, ptFactor }, deep + 1);\n\t\tif (selfEval && evaluation.fatalError) {\n\t\t\tconst tip = this.currentElem.order!;\n\t\t\tthis.cluster.elements.forEach((elem) => {\n\t\t\t\tif (elem.order! > tip) elem.order = undefined;\n\t\t\t});\n\n\t\t\t// clear children data\n\t\t\tthis.cluster.elements.forEach((elem) => (elem.order = elem.order! > this.currentElem.order! ? undefined : elem.order));\n\t\t\tthis.cluster.elements[this.cluster.elements.length - 1].tick = selfEval.endTick;\n\n\t\t\treturn selfEval;\n\t\t}\n\n\t\treturn evaluation;\n\t}\n}\n\nconst estimateElementDuration = (elem: EventElement) => WHOLE_DURATION * 2 ** -elem.division! * (2 - 2 ** -elem.dots!);\n\nconst evaluateCluster = (cluster: EventCluster, tip: number, pretentiousness: number): ClusterEvaluation => {\n\tconst events = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order) && elem.order! < tip\n\t);\n\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\tconst eos = cluster.elements[cluster.elements.length - 1];\n\n\tlet tick = 0;\n\tlet lastOrder = 0;\n\tlet endTick = 0;\n\tlet voiceN = 1;\n\n\t// [x, tick, estimated tick]\n\tconst scales: [number, number, number][] = [[eos.x, cluster.signatureDuration, cluster.signatureDuration]];\n\n\tlet totalDuration = 0;\n\n\t// assign tick for events\n\tevents.forEach((event) => {\n\t\tif (event.order! > lastOrder + 1) {\n\t\t\ttick = 0;\n\t\t\t++voiceN;\n\t\t}\n\n\t\tconst referenceScale = scales.find((s) => s[1] >= tick);\n\t\tif (referenceScale && event.x > referenceScale[0] + 3) {\n\t\t\tconst nearScale = scales.reduce((n, s) => (Math.abs(event.predisposition!.tick - s[2]) < Math.abs(event.predisposition!.tick - n[2]) ? s : n));\n\t\t\tif (Math.abs(nearScale[0] - event.x) < 2) tick = Math.max(tick, nearScale[1]);\n\t\t}\n\n\t\tevent.tick = tick;\n\n\t\tconst si = Math.max(\n\t\t\t0,\n\t\t\tscales.findIndex((s) => s[0] > event.x)\n\t\t);\n\t\tscales.splice(si, 0, [event.x, event.tick, event.predisposition!.tick]);\n\n\t\t//let duration = WHOLE_DURATION * (2 ** -event.division!) * (2 - 2 ** -event.dots!);\n\t\tlet duration = estimateElementDuration(event);\n\t\tif (event.predisposition!.timeWarped > 0.5) duration = (duration * 2) / 3;\n\n\t\ttick += duration;\n\t\ttotalDuration += duration;\n\t\tendTick = Math.max(endTick, tick);\n\t\tlastOrder = event.order!;\n\t});\n\n\t/*const pretentiousness = events.reduce((p, event) => p +\n\t\tmeasurePretentious(event.predisposition!.divisionVector![event.division!]) +\n\t\tmeasurePretentious(event.predisposition!.dotsVector![event.dots!]), 0);*/\n\n\tif (endTick > 0) cluster.elements[cluster.elements.length - 1].tick = endTick;\n\n\tconst xSpan = cluster.elements[cluster.elements.length - 1].pivotX! - cluster.elements[1].pivotX!;\n\tconst tickSpan = Math.max(...events.map((e) => e.tick!), endTick);\n\n\t// tick twist loss\n\tconst eventsXOrder = [...events].sort((e1, e2) => e1.pivotX! - e2.pivotX!);\n\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\tconst e1 = eventsXOrder[i];\n\t\tconst dx = e2.pivotX! - e1.pivotX!;\n\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\tif (!dt) return dx / xSpan;\n\n\t\tconst rate = Math.atan2(dt / tickSpan, dx / xSpan);\n\n\t\t//if (dt < 0)\n\t\t//\tconsole.log(\"minus dt:\", dt, dx, rate);\n\n\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t});\n\t//console.debug(\"tickTwists:\", tickTwists, eventsXOrder);\n\n\tconst twist = Math.max(...tickTwists, 0);\n\n\tconst tickMSE = events.map((event) => (event.tick! - event.predisposition!.tick) ** 2);\n\t//console.debug(\"tickMSE:\", tickMSE.map(Math.sqrt));\n\tconst tickErr = tickMSE.length ? Math.sqrt(tickMSE.reduce((sum, mse) => sum + mse, 0) / tickMSE.length) : 0;\n\t//console.debug(\"tick/twist:\", tickErr / WHOLE_DURATION, twist);\n\n\tconst residueElements = cluster.elements.filter(\n\t\t(elem) =>\n\t\t\t[EventElementType.CHORD, EventElementType.REST].includes(elem.type) &&\n\t\t\t!(Number.isInteger(elem.order) && elem.order! < tip) &&\n\t\t\t!(elem.predisposition && elem.predisposition.fakeP > 0.5)\n\t);\n\tconst residue = residueElements.length;\n\n\tconst fatalError = twist >= 1 || endTick > cluster.signatureDuration;\n\n\t//const spaceDuration = Math.max(0, cluster.signatureDuration - endTick);\n\tconst spaceDuration = Math.max(0, cluster.signatureDuration - totalDuration / voiceN);\n\n\tconst loss =\n\t\ttickErr / WHOLE_DURATION +\n\t\ttwist +\n\t\tresidue * RESIDUE_LOSS_WEIGHT +\n\t\tvoiceN * VOICEN_LOSS_WEIGHT +\n\t\tspaceDuration * SPACE_LOSS_WEIGHT +\n\t\tpretentiousness * PRETENTIOUSNESS_LOSS_WEIGHT;\n\n\treturn {\n\t\ttickErr,\n\t\ttwist,\n\t\tresidue,\n\t\tendTick,\n\t\tfatalError,\n\t\tvoiceN,\n\t\tspaceDuration,\n\t\tpretentiousness,\n\t\tloss,\n\t};\n};\n\nconst solveCluster = async (\n\tcluster: EventCluster,\n\tpicker: BeadPicker,\n\tlogger: Logger,\n\tquota: number = 200,\n\tstopLoss: number = 0,\n\tptFactor: number = 1\n): Promise => {\n\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\tconst suc0 = await picker.predictCluster(cluster, 1);\n\n\tconst root = new BeadNode({ cluster, elemIndex: 0, pretentiousness: 0, type: BeadType.Pass, possibilities: suc0 });\n\n\tlet bestEvaluation: ClusterEvaluation | null = null;\n\tlet bestState: ClusterState | null = null;\n\n\tpicker.quota = quota;\n\twhile (picker.quota) {\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\n\t\tconst evaluation = await root.deduce({ picker, logger, ptFactor });\n\n\t\tlogger.debug('loss:', evaluation);\n\n\t\tif (!bestEvaluation || evaluation.loss < bestEvaluation.loss) {\n\t\t\tbestEvaluation = evaluation;\n\n\t\t\tcluster.duration = bestEvaluation.endTick;\n\t\t\tbestState = saveClusterState(cluster);\n\n\t\t\tif (Number.isFinite(stopLoss) && bestEvaluation.loss <= stopLoss!) break;\n\t\t}\n\n\t\tif (!Number.isFinite(root.accessCount)) break;\n\t}\n\tlogger.debug('bestEvaluation:', bestEvaluation);\n\n\trestoreClusterState(cluster, bestState!);\n\n\t// solve residue elements\n\tconst fixedEvents = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\tconst pendingEvents = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !Number.isInteger(elem.order)\n\t);\n\tif (fixedEvents.length) {\n\t\tpendingEvents.forEach((event) => {\n\t\t\t// exclude fake events (includes grace, fullMeasure) from voices\n\t\t\tevent.tick = undefined;\n\n\t\t\tif (event.predisposition!.fakeP < 0.5) {\n\t\t\t\t//const near = fixedEvents.reduce((n, e) => Math.abs(e.predisposition!.tick - event.predisposition!.tick) < Math.abs(n.predisposition!.tick - event.predisposition!.tick) ? e : n);\n\t\t\t\tconst duration = estimateElementDuration(event);\n\t\t\t\tconst candidates = fixedEvents.filter((e) => e.tick! + duration <= bestEvaluation!.endTick);\n\t\t\t\tif (candidates.length) {\n\t\t\t\t\tconst near = candidates.reduce((n, e) => (Math.abs(e.x - event.x) < Math.abs(n.x - event.x) ? e : n));\n\t\t\t\t\tevent.tick = near.tick;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tfixedEvents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t// properties\n\t[...fixedEvents, ...pendingEvents].forEach((event) => {\n\t\tevent.grace = !Number.isFinite(event.tick) && event.predisposition!.grace;\n\t\tevent.timeWarped = event.predisposition!.timeWarped > 0.5;\n\t\tevent.fullMeasure = event.predisposition!.fullMeasure > 0.5;\n\t\tevent.stemDirection = STEM_DIRECTION_OPTIONS[argmax(event.predisposition!.stemDirectionVector)];\n\t\tevent.beam = BEAM_OPTIONS[argmax(event.predisposition!.beamVector)];\n\t});\n\n\t// construct matrixH\n\tconst ids = cluster.elements.map((e) => e.index);\n\tconst idx = (id: number): number => ids.indexOf(id);\n\tcluster.matrixH = cluster.elements.map(() => Array(cluster.elements.length).fill(0));\n\tfixedEvents.forEach((event, i) => {\n\t\tconst lastEvent = fixedEvents[i - 1];\n\t\tif (!lastEvent || lastEvent.order! < event.order! - 1) {\n\t\t\tcluster.matrixH![idx(event.index!)][0] = 1;\n\t\t\tif (lastEvent) cluster.matrixH![cluster.elements.length - 1][idx(lastEvent.index!)] = 1;\n\t\t} else {\n\t\t\tconsole.assert(\n\t\t\t\tcluster.matrixH![idx(event.index!)] && Number.isFinite(cluster.matrixH![idx(event.index!)][idx(lastEvent.index!)]),\n\t\t\t\t'matrixH out of range:',\n\t\t\t\tevent.index,\n\t\t\t\tlastEvent.index,\n\t\t\t\tcluster.matrixH!.length\n\t\t\t);\n\n\t\t\tcluster.matrixH![idx(event.index!)][idx(lastEvent.index!)] = 1;\n\t\t}\n\t});\n\tif (!pendingEvents.length && fixedEvents.length) cluster.matrixH![cluster.elements.length - 1][idx(fixedEvents[fixedEvents.length - 1].index!)] = 1;\n\n\treturn bestEvaluation!;\n};\n\ninterface BeadSolverOptions {\n\tpicker: BeadPicker;\n\tstopLoss?: number;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tptFactor?: number;\n\tlogger?: Logger;\n}\n\nconst solveMeasure = async (measure: SpartitoMeasure, options: BeadSolverOptions): Promise => {\n\tconst { stopLoss = 0.09, quotaMax = 1000, quotaFactor = 5, ptFactor = 1, logger = new DummyLogger() } = options;\n\n\tlet worstLoss = 0;\n\n\tconst clusters = measure.createClusters();\n\tfor (const cluster of clusters) {\n\t\tconst quota = Math.min(quotaMax, Math.ceil(cluster.elements.length * quotaFactor));\n\t\tlogger.info(`[measure-${measure.measureIndex}]`, quota);\n\t\tconst { loss } = await solveCluster(cluster, options.picker, logger, quota, stopLoss, ptFactor);\n\t\tworstLoss = Math.max(worstLoss, loss);\n\t}\n\n\tconst voices = [] as number[][];\n\n\tconst durations = [] as number[];\n\n\tconst solutionEvents = [] as RegulationSolutionEvent[];\n\n\tclusters.forEach((cluster) => {\n\t\tconst events = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\t\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t\tif (!events.length) return;\n\n\t\tlet voice = [] as number[];\n\t\tvoices.push(voice);\n\t\tlet lastOrder = 0;\n\t\tevents.forEach((event) => {\n\t\t\tif (event.fullMeasure || event.grace || event.tremoloCatcher) return;\n\n\t\t\tif (event.order! > lastOrder + 1) {\n\t\t\t\tvoice = [event.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t} else voice.push(event.index!);\n\n\t\t\tlastOrder = event.order!;\n\t\t});\n\n\t\tlet tipElem = events[events.length - 1];\n\n\t\t// complete voices from pending events\n\t\tconst pendingEvents = cluster.elements.filter(\n\t\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isFinite(elem.tick) && !Number.isInteger(elem.order)\n\t\t);\n\t\twhile (pendingEvents.length) {\n\t\t\tconst ei = pendingEvents.findIndex((e) => e.tick! >= tipElem.tick! + estimateElementDuration(tipElem));\n\t\t\tif (ei >= 0) voice.push(pendingEvents.splice(ei, 1)[0].index!);\n\t\t\telse {\n\t\t\t\ttipElem = pendingEvents.splice(0, 1)[0];\n\t\t\t\tvoice = [tipElem.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\t\t}\n\n\t\tif (events.some((elem) => !elem.fullMeasure && Number.isInteger(elem.order))) {\n\t\t\tconst eos = cluster.elements.find((elem) => elem.type === EventElementType.EOS);\n\t\t\tdurations.push(eos!.tick!);\n\t\t}\n\n\t\tconst eventMap = measure.eventMap;\n\n\t\tconst tickSet = cluster.elements.reduce((set, elem) => {\n\t\t\tif (Number.isFinite(elem.tick)) set.add(elem.tick!);\n\t\t\treturn set;\n\t\t}, new Set());\n\t\tconst ticks = Array.from(tickSet).sort((t1, t2) => t1 - t2);\n\n\t\t// fill solutionEvents\n\t\tevents.forEach((elem) => {\n\t\t\tconst event = eventMap[elem.index!];\n\t\t\tif (event) {\n\t\t\t\tsolutionEvents.push({\n\t\t\t\t\tid: event.id!,\n\t\t\t\t\ttick: elem.tick!,\n\t\t\t\t\ttickGroup: ticks.indexOf(elem.tick!),\n\t\t\t\t\tdivision: elem.division !== event.division ? elem.division : undefined,\n\t\t\t\t\tdots: elem.dots !== event.dots ? elem.dots : undefined,\n\t\t\t\t\ttimeWarp: elem.timeWarped ? frac(2, 3) : undefined, // TODO:\n\t\t\t\t\tbeam: elem.beam !== event.beam ? elem.beam : undefined,\n\t\t\t\t\tgrace: elem.grace !== !!event.grace ? elem.grace : undefined,\n\t\t\t\t\tfullMeasure: elem.fullMeasure || undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n\n\tconst estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n\n\treturn {\n\t\tvoices: voices.filter((voice) => voice.length),\n\t\tduration: Math.max(...durations),\n\t\tevents: solutionEvents,\n\t\tpriority: -worstLoss,\n\t\testimatedDuration,\n\t};\n};\n\ninterface GlimpseMeasureOptions {\n\tpicker: BeadPicker;\n\tresetSignatureForDoubtfulOnly?: boolean;\n}\n\nconst glimpseMeasure = async (measure: SpartitoMeasure, { picker, resetSignatureForDoubtfulOnly }: GlimpseMeasureOptions): Promise => {\n\tconst clusters = measure.createClusters();\n\tconst eventMap = measure.eventMap;\n\n\tfor (const cluster of clusters) {\n\t\tif (!resetSignatureForDoubtfulOnly || measure.doubtfulTimesig) cluster.signatureDuration = 0; // re-estimate measure duration\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\t\tawait picker.predictCluster(cluster, 1);\n\n\t\tcluster.elements\n\t\t\t.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type))\n\t\t\t.forEach((elem) => {\n\t\t\t\tconst event = eventMap[elem.index!];\n\t\t\t\tevent.predisposition = elem.predisposition!;\n\t\t\t});\n\t}\n\n\tmeasure.estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n};\n\nconst estimateMeasure = async (measure: SpartitoMeasure, picker: BeadPicker): Promise =>\n\tglimpseMeasure(measure, { picker, resetSignatureForDoubtfulOnly: true });\n\nexport { BeadPicker, solveCluster, solveMeasure, estimateMeasure, glimpseMeasure };\n","import * as starry from '../starry';\nimport { MidiJson, ScoreJSON } from './types';\nimport { ChordColumn, Staff } from '../starry';\nimport { parseCode } from '../staffLayout';\nimport { MidiEvent } from '../performer';\n\nexport interface FindScoreResource {\n\tscoreJson: ScoreJSON;\n\tmidiJson: MidiJson;\n}\n\nconst SUPPORT_CLEF_TYPES = [starry.TokenType.ClefG, starry.TokenType.ClefF, starry.TokenType.ClefC];\n\nconst tokenToText = (token: starry.ContextedTerm) => {\n\tlet text = null;\n\tswitch (token.tokenType) {\n\t\tcase starry.TokenType.ClefG:\n\t\t\ttext = 'Treble';\n\t\t\tbreak;\n\t\tcase starry.TokenType.ClefF:\n\t\t\ttext = 'Bass';\n\t\t\tbreak;\n\t\tcase starry.TokenType.ClefC:\n\t\t\tif (token.y === -1) {\n\t\t\t\ttext = 'Tenor';\n\t\t\t} else {\n\t\t\t\ttext = 'Alto';\n\t\t\t}\n\t\t\tbreak;\n\t}\n\n\treturn text;\n};\n\nexport function encodeFindResource(score: starry.Score): FindScoreResource {\n\tconst perform = score.spartito.perform();\n\tconst maskImages = score.systems.map((sy) => sy.staves.map((st) => st?.maskImage)).flat();\n\tconst hasMaskImage = maskImages.filter(Boolean).length > maskImages.length / 2;\n\n\tconst scoreJson: ScoreJSON = {} as ScoreJSON;\n\n\tconst idsMap = new Map(); // starry内部ID到find播放器id的映射\n\tconst idsXMap = new Map(); // 内部ID和元素X坐标的映射\n\tconst idStaffIndexMap = new Map(); // 内部ID和元素所属part的内部staff索引\n\n\tscoreJson.unitSize = score.unitSize;\n\n\tscoreJson.title = {\n\t\ttitle: score.title,\n\t} as any;\n\n\tconst coverTexts: {\n\t\tconfidence: number;\n\t\tfontSize: number;\n\t\tid: string;\n\t\ttext: string;\n\t\ttextType: 'Title' | 'Author';\n\t\ttype: starry.TokenType;\n\t\twidth_: number;\n\t\tx: number;\n\t\ty: number;\n\t}[] = score.pages[0].tokens as any;\n\n\tif (Array.isArray(coverTexts) && coverTexts.length > 0) {\n\t\tconst [title, ...subtitles] = coverTexts\n\t\t\t.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Title')\n\t\t\t.sort((a, b) => b.fontSize - a.fontSize);\n\n\t\tif (title) {\n\t\t\tscoreJson.title.title = title.text;\n\t\t\tscoreJson.title.t = { size: title.fontSize };\n\t\t}\n\n\t\tif (subtitles?.length > 0) {\n\t\t\tsubtitles.sort((a, b) => a.y - b.y);\n\t\t\tscoreJson.title.subtitle = subtitles.map((x) => x.text).join('\\n');\n\t\t\tscoreJson.title.s = { size: subtitles.reduce((a, n) => a + n.fontSize, 0) / subtitles.length };\n\t\t}\n\n\t\tconst authors = coverTexts.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Author' && x.x > score.pages[0].width / 2);\n\n\t\tif (authors.length > 0) {\n\t\t\tscoreJson.title.composer = authors.map((x) => x.text).join('\\n');\n\t\t\tscoreJson.title.c = { size: authors.reduce((a, n) => a + n.fontSize, 0) / authors.length };\n\t\t}\n\t}\n\n\tscoreJson.page = {\n\t\tw: score.pages[0].width,\n\t\th: score.pages[0].height,\n\t};\n\n\tscoreJson.pages = score.pages.map((page) => {\n\t\tconst bgWidth = page.source.dimensions.width / page.source.interval;\n\t\tconst bgHeight = page.source.dimensions.height / page.source.interval;\n\n\t\tconst [a, b, c, d] = page.source.matrix;\n\n\t\treturn {\n\t\t\tsrc: page.source.url, // 本页本地图片URL\n\t\t\tw: bgWidth, // 背景图\n\t\t\th: bgHeight, // 背景图\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tl1: score.systems.indexOf(page.systems[0]), // 本页起始system编号\n\t\t\tls: page.systems.length, // 本页system数量\n\t\t\tmatrix: [\n\t\t\t\ta,\n\t\t\t\tb,\n\t\t\t\tc,\n\t\t\t\td,\n\t\t\t\t(-1 / 2) * a * bgWidth + (-1 / 2) * bgHeight * c + (1 / 2) * page.width || 0,\n\t\t\t\t(-1 / 2) * b * bgWidth + (-1 / 2) * bgHeight * d + (1 / 2) * page.height || 0,\n\t\t\t],\n\t\t};\n\t});\n\n\tscoreJson.parts = [];\n\tscoreJson.lines = [];\n\n\t// 没有降噪图就不需要这些字段\n\tif (hasMaskImage) {\n\t\tconst partTemplates = score.staffLayout.partGroups.map((p) => (p.range[0] === p.range[1] ? [p.range[0]] : p.range));\n\t\tconst tokenMap = score.getTokenMap();\n\t\tconst measureXs: number[][] = [];\n\n\t\t// partIndex: part索引,template: 当前part所包含的staff的全局索引\n\t\tfor (const [partIndex, template] of partTemplates.entries()) {\n\t\t\tconst staffIndexBase = partTemplates.slice(0, partIndex).flat().length;\n\n\t\t\tconst part: ScoreJSON['parts'][0] = {\n\t\t\t\tmeasures: [],\n\t\t\t};\n\n\t\t\tscore.systems.forEach((system, systemIndex) => {\n\t\t\t\tconst staves = system.staves.slice();\n\n\t\t\t\t// 不可见staff用null填充的staff列表\n\t\t\t\tconst paddedStaves = partTemplates.flat().map((staffIndex) => (!((1 << staffIndex) & system.staffMask) ? null : staves.shift()));\n\t\t\t\tconst bars = [0, ...system.measureBars];\n\n\t\t\t\t// 便历当前system下的小节\n\t\t\t\tfor (let mi = 0; mi < system.measureCount; mi++) {\n\t\t\t\t\tconst measureIndex = score.spartito.measureIndexMapping[system.headMeasureIndex + mi];\n\n\t\t\t\t\t// 如果小节被过滤\n\t\t\t\t\tif (!Number.isFinite(measureIndex)) {\n\t\t\t\t\t\tif (bars.length > mi + 1) bars[mi + 1] = bars[mi];\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst chordColumns: { chord: ChordColumn; staffIndexInPart: number }[] = [];\n\n\t\t\t\t\tfor (const staffIndex of template) {\n\t\t\t\t\t\tconst staff = paddedStaves[staffIndex];\n\n\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\tchordColumns.push(...staff.measures[mi].getChords().map((chord) => ({ chord, staffIndexInPart: staffIndex - staffIndexBase })));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet noteIndex = 0;\n\n\t\t\t\t\tconst measureStartX = bars[mi]; // 小节开头相对system的x偏移\n\n\t\t\t\t\tconst measureNotes = [];\n\n\t\t\t\t\tchordColumns.forEach(({ staffIndexInPart, chord }) => {\n\t\t\t\t\t\tconst elems = [];\n\n\t\t\t\t\t\tlet firstX = chord.tip ? chord.tip.x : chord.right - chord.left / 2;\n\n\t\t\t\t\t\tchord.noteIds.forEach((noteId, key) => {\n\t\t\t\t\t\t\tconst token = tokenMap.get(noteId);\n\n\t\t\t\t\t\t\tconst innerId = `n_${partTemplates.length > 1 ? partIndex + '_' : ''}${measureIndex}_${noteIndex}`;\n\t\t\t\t\t\t\tnoteIndex++;\n\t\t\t\t\t\t\tidsMap.set(token.id, innerId);\n\t\t\t\t\t\t\tidsXMap.set(token.id, (token.left + token.right) / 2 - measureStartX);\n\t\t\t\t\t\t\tidStaffIndexMap.set(token.id, staffIndexInPart + 1);\n\n\t\t\t\t\t\t\telems.push({\n\t\t\t\t\t\t\t\tline: -chord.ys[key] * 2, // 五线中线为0,往上为正/向下为负,每半格子1个单位\n\t\t\t\t\t\t\t\tid: innerId, // n_小节号_第几个音符\n\t\t\t\t\t\t\t\t// acc: {\n\t\t\t\t\t\t\t\t// \tacc: AccType.Flat,\n\t\t\t\t\t\t\t\t// \tx: -1\n\t\t\t\t\t\t\t\t// }, // 临时升降记号及其偏移量\n\t\t\t\t\t\t\t\tstaff: staffIndexInPart + 1,\n\t\t\t\t\t\t\t\tx: (token.left + token.right) / 2 - firstX, // 当前符头相对第一个符头的偏移量\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tmeasureXs[measureIndex] = measureXs[measureIndex] || [];\n\t\t\t\t\t\tmeasureXs[measureIndex].push(firstX - measureStartX);\n\n\t\t\t\t\t\tconst events = score.spartito.measures[system.headMeasureIndex + mi].events.filter((x) =>\n\t\t\t\t\t\t\tx.noteIds.some((y) => chord.noteIds.includes(y))\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tmeasureNotes.push({\n\t\t\t\t\t\t\telems,\n\t\t\t\t\t\t\tx: firstX - measureStartX, // 本音符相对于小节开头的x偏移量\n\t\t\t\t\t\t\ttype: 2 ** chord.division, // n分音符,1为全音符\n\t\t\t\t\t\t\t...(events.some((x) => x.grace) ? { grace: {} } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\tpart.measures[measureIndex] = {\n\t\t\t\t\t\tw: bars[mi + 1] - bars[mi], // 本小节宽度\n\t\t\t\t\t\tstaves: template.length, // 本part的staff个数\n\t\t\t\t\t\tnotes: measureNotes,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// 提取谱号、调号\n\t\t\tlet lastFifths = null;\n\t\t\tscore.spartito.measures.forEach((measure, i) => {\n\t\t\t\tconst measureIndex = score.spartito.measureIndexMapping[i];\n\n\t\t\t\tconst clefTokens = measure.contexts.flat().filter((x) => SUPPORT_CLEF_TYPES.includes(x.tokenType) && template.includes(x.staff));\n\t\t\t\tconst clefs = clefTokens.map((token) => {\n\t\t\t\t\tconst pt = partTemplates.find((p) => p.includes(token.staff));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\tclef: tokenToText(token),\n\t\t\t\t\t\tstaff: pt.indexOf(token.staff) + 1, // staff索引从1开始\n\t\t\t\t\t\ttick: token.tick,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tif (clefs.length > 0) {\n\t\t\t\t\tpart.measures[measureIndex] && (part.measures[measureIndex].clefs = clefs);\n\t\t\t\t}\n\n\t\t\t\tconst fifths = measure.basics.filter((x, i) => (1 << i) & measure.staffMask)[0].keySignature;\n\n\t\t\t\tif (fifths !== lastFifths) {\n\t\t\t\t\tpart.measures[measureIndex] && (part.measures[measureIndex].fifths = { fifths });\n\t\t\t\t\tlastFifths = fifths;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (part.measures.length > 0) {\n\t\t\t\tscoreJson.parts[partIndex] = part;\n\t\t\t}\n\t\t}\n\n\t\tscore.systems.forEach((system, systemIndex) => {\n\t\t\tconst lineStaves = [];\n\n\t\t\tconst systemTopStaff = system.staves[0];\n\t\t\tconst systemBottomStaff = system.staves[system.staves.length - 1];\n\n\t\t\tconst systemTopStaffY = systemTopStaff.top + systemTopStaff.staffY - 2;\n\t\t\tconst systemBottomStaffY = systemBottomStaff.top + systemBottomStaff.staffY - 2;\n\n\t\t\tconst staves = system.staves.slice();\n\n\t\t\tconst paddedStaves = partTemplates.flat().map((staffIndex) => {\n\t\t\t\tconst isEmpty = !((1 << staffIndex) & system.staffMask);\n\t\t\t\tif (isEmpty) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\treturn staves.shift();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tlet lastPartLastStaff = null;\n\n\t\t\tfor (const [partIndex, template] of partTemplates.entries()) {\n\t\t\t\tconst partStaves: Staff[] = template.map((staffIndex) => paddedStaves.find((s) => s?.index === staffIndex) || null);\n\n\t\t\t\tconst staffs = partStaves.map((staff, index) => [index, !staff] as [number, boolean]).filter((s) => s[1]);\n\n\t\t\t\tlet details = null;\n\t\t\t\tif (staffs.length > 0) {\n\t\t\t\t\tdetails = Object.fromEntries(staffs.map((d) => [d[0] + 1, { hide: d[1] }]));\n\t\t\t\t}\n\n\t\t\t\tlet y = 0;\n\t\t\t\tlet height = 0;\n\n\t\t\t\tconst visibleStaves = partStaves.filter((s) => !!s);\n\n\t\t\t\tif (visibleStaves.length > 0) {\n\t\t\t\t\tconst partTopStaff = visibleStaves[0];\n\t\t\t\t\tconst partBottomStaff = visibleStaves[visibleStaves.length - 1];\n\t\t\t\t\tconst partTopStaffY = partTopStaff.top + partTopStaff.staffY - 2;\n\t\t\t\t\tconst partBottomStaffY = partBottomStaff.top + partBottomStaff.staffY - 2;\n\n\t\t\t\t\ty = partTopStaffY - systemTopStaffY;\n\t\t\t\t\theight = partBottomStaffY - partTopStaffY + 4;\n\t\t\t\t}\n\n\t\t\t\tconst { list: distances, last } = partStaves.reduce(\n\t\t\t\t\t(acc, next, index) => {\n\t\t\t\t\t\tif (acc.last === null || next === null) {\n\t\t\t\t\t\t\tif (index === 0 && y > 0) {\n\t\t\t\t\t\t\t\tacc.list.push(y - 4);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tacc.list.push(0);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tacc.list.push(next.top + next.staffY - (acc.last.top + acc.last.staffY) - 4);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tacc.last = next || acc.last;\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{ last: lastPartLastStaff, list: [] } as { last: Staff; list: number[] }\n\t\t\t\t);\n\n\t\t\t\tlastPartLastStaff = last;\n\n\t\t\t\tconst imgs = partStaves.map((staff) => {\n\t\t\t\t\tif (staff?.maskImage) {\n\t\t\t\t\t\tconst rect = staff.imagePosition;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsrc: staff.maskImage,\n\t\t\t\t\t\t\tx: rect.x,\n\t\t\t\t\t\t\ty: system.top + staff.top + rect.y - (system.top + staff.top + staff.staffY - 2),\n\t\t\t\t\t\t\tw: rect.width,\n\t\t\t\t\t\t\th: rect.height,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t});\n\n\t\t\t\tconst spartitoMeasure = score.spartito.measures[system.headMeasureIndex];\n\t\t\t\tlineStaves.push({\n\t\t\t\t\t// parts\n\t\t\t\t\tdistances, // 两个staff间距\n\t\t\t\t\timgs,\n\t\t\t\t\ty, // 本staff相对于当前system第一线的起始y坐标\n\t\t\t\t\tstaves: template.length, // 本staff数量\n\t\t\t\t\tparti: partIndex, // 本staff所属part编号\n\t\t\t\t\theight, // 本staff高度\n\t\t\t\t\t...(details ? { details } : {}),\n\t\t\t\t\tclef: Object.fromEntries(\n\t\t\t\t\t\tscore.spartito.measures[system.headMeasureIndex]?.contexts\n\t\t\t\t\t\t\t.flat()\n\t\t\t\t\t\t\t.filter((x) => SUPPORT_CLEF_TYPES.includes(x.tokenType) && template.includes(x.staff))\n\t\t\t\t\t\t\t.map((token) => [token.staff, tokenToText(token)])\n\t\t\t\t\t),\n\t\t\t\t\tfifths: spartitoMeasure.basics.filter((x, i) => (1 << i) & spartitoMeasure.staffMask)[0].keySignature,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst mIndices = system.measureBars\n\t\t\t\t.map((_, i) => score.spartito.measureIndexMapping[system.headMeasureIndex + i])\n\t\t\t\t.filter((x) => Number.isFinite(x));\n\n\t\t\tscoreJson.lines[systemIndex] = {\n\t\t\t\tm1: mIndices[0], // 本system起始小节编号\n\t\t\t\tm2: mIndices.length > 0 ? mIndices[mIndices.length - 1] + 1 : undefined, // 本system结尾小节编号+1\n\t\t\t\tx: system.left, // 本system左侧小节线x坐标\n\t\t\t\ty: system.top + systemTopStaffY, // 本system左侧小节线y坐标\n\t\t\t\tw: system.measureBars[system.measureBars.length - 1], // 本system宽度\n\t\t\t\th: systemBottomStaffY - systemTopStaffY + 4, // 本system高度\n\t\t\t\tlineStaves,\n\t\t\t};\n\t\t});\n\n\t\tconst map = { 0: 'default', 1: 'brace', 2: 'bracket', 3: 'square' };\n\n\t\tconst staffLayout = parseCode(score.staffLayoutCode);\n\t\tconst sortedParts = staffLayout.partGroups\n\t\t\t.map((x) => {\n\t\t\t\treturn {\n\t\t\t\t\tsort: x.range[0],\n\t\t\t\t\tpart: x,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((a, b) => a.sort - b.sort)\n\t\t\t.map((x) => x.part);\n\n\t\tscoreJson.groups = staffLayout.groups\n\t\t\t.filter((x) => x.group.type !== 0)\n\t\t\t.map((part, key) => {\n\t\t\t\treturn {\n\t\t\t\t\ttype: map[part.group.type] as any,\n\t\t\t\t\tp1: sortedParts.findIndex((x) => x.range.includes(part.range[0])),\n\t\t\t\t\tp2: sortedParts.findIndex((x) => x.range.includes(part.range[part.range.length - 1])),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.filter((x) => x.type !== 'default');\n\t}\n\n\tif (perform) {\n\t\tscoreJson.measInfo = perform.notation.measures.map((measure, measureIndex) => {\n\t\t\tconst map = new Map();\n\t\t\tmeasure.notes.forEach((n) => {\n\t\t\t\tmap.set(n.tick, [...(map.get(n.tick) || []), idsXMap.get(n.id)]);\n\t\t\t});\n\n\t\t\t// 找出每个tick对应的第一个音符的中心点的x\n\t\t\treturn Array.from(map.entries())\n\t\t\t\t.sort((a, b) => +a[0] - b[0])\n\t\t\t\t.reduce(\n\t\t\t\t\t(acc, ent, key) => {\n\t\t\t\t\t\tconst val = ent[1].find((x) => x > acc.last) || ent[1][0];\n\t\t\t\t\t\tacc.list.push(val);\n\t\t\t\t\t\tacc.last = val;\n\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{ last: null, list: [] }\n\t\t\t\t)\n\t\t\t\t.list.filter(Number.isFinite);\n\t\t});\n\t}\n\n\t/******************************* 生成 midiJson *************************************/\n\n\tlet midiJson: MidiJson;\n\n\tif (perform) {\n\t\tmidiJson = {} as MidiJson;\n\n\t\tconst idNoteMap = new Map();\n\n\t\tlet beatsCurrent;\n\t\tlet beatsUnitCurrent;\n\t\tperform.notation.measures.forEach((measure, mIndex) => {\n\t\t\tconst { numerator: beats, denominator: beatsUnit } = measure.timeSignature;\n\n\t\t\tif (!midiJson.beats && !midiJson.beatsUnit) {\n\t\t\t\tmidiJson.beats = beats;\n\t\t\t\tmidiJson.beatsUnit = beatsUnit;\n\t\t\t\tbeatsCurrent = beats;\n\t\t\t\tbeatsUnitCurrent = beatsUnit;\n\t\t\t}\n\n\t\t\tmidiJson.beatInfos = midiJson.beatInfos || [];\n\n\t\t\tif (beatsCurrent !== beats || beatsUnitCurrent !== beatsUnit) {\n\t\t\t\tbeatsCurrent = beats;\n\t\t\t\tbeatsUnitCurrent = beatsUnit;\n\n\t\t\t\tmidiJson.beatInfos.push({\n\t\t\t\t\ttick: measure.tick,\n\t\t\t\t\tbeats,\n\t\t\t\t\tbeatsUnit,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tmidiJson.tempos = midiJson.tempos || [];\n\n\t\t\tmeasure.events.forEach((evt) => {\n\t\t\t\tif (evt.data.type === 'meta' && evt.data.subtype === 'setTempo') {\n\t\t\t\t\tmidiJson.tempos.push({\n\t\t\t\t\t\ttick: measure.tick,\n\t\t\t\t\t\ttempo: evt.data.microsecondsPerBeat,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tmidiJson.measures = perform.notation.measures.reduce((acc, measure, index) => {\n\t\t\tconst note_ticks = Array.from(new Set(measure.notes.map((x) => x.tick))).sort((a, b) => a - b);\n\n\t\t\tmeasure.notes.forEach((x) => {\n\t\t\t\tidNoteMap.set(x.id, note_ticks.indexOf(x.tick));\n\t\t\t});\n\n\t\t\tacc[measure.tick] = {\n\t\t\t\tmeasure: index, // 小节编号\n\t\t\t\tduration: measure.duration, // 小节时值\n\t\t\t\tnote_ticks, // 本小节每列的tick\n\t\t\t};\n\n\t\t\treturn acc;\n\t\t}, {});\n\n\t\tmidiJson.measureInfos = perform.notation.measures.map((measure, key) => ({\n\t\t\tnumber: String(key + 1), // 小节编号\n\t\t\tfifths: measure.keySignature, // 调号 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7\n\t\t\tbeats: measure.timeSignature.numerator, // 拍号分子\n\t\t\tbeatUnit: measure.timeSignature.denominator, // 拍号分母\n\t\t}));\n\n\t\tconst midi = perform.notation.toPerformingMIDI(perform.notation.measures.map((_, key) => key + 1));\n\n\t\tconst tracks = midi.tracks as unknown as (MidiEvent & { duration: number })[][];\n\n\t\tconst { partGroups } = score.staffLayout;\n\n\t\tlet mergedTracks = tracks.map((track, trackIndex) => {\n\t\t\tconst key = partGroups[trackIndex].key;\n\n\t\t\tlet program: number;\n\n\t\t\tswitch (key) {\n\t\t\t\tcase 'vi':\n\t\t\t\tcase 'vi1':\n\t\t\t\tcase 'vi2':\n\t\t\t\t\tprogram = 40; // 小提琴\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'viola':\n\t\t\t\t\tprogram = 42; // 中提琴\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'vo':\n\t\t\t\t\tprogram = 55; // 合成人声\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'basso':\n\t\t\t\t\tprogram = 71; // 大管乐器\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: // 大钢琴\n\t\t\t\t\tprogram = 0;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprogram, // 音色:0-127\n\t\t\t\tchannel: trackIndex, // 通道:0-15\n\t\t\t\tname: score.instrumentDict[key] ?? 'Piano', // 轨道名称\n\t\t\t\ttrack,\n\t\t\t};\n\t\t});\n\n\t\t// 找出大谱表所在track(声部),根据分手条件拆分为左右手\n\t\tif (partGroups.some((g) => g.group.grand)) {\n\t\t\tconst lhPattern = /l\\.?h\\.?|左手|left hand/i;\n\t\t\tconst rhPattern = /r\\.?h\\.?|右手|right hand/i;\n\t\t\tconst instrus = Object.entries(score.instrumentDict)\n\t\t\t\t.filter(([key, value]) => lhPattern.test(value) || rhPattern.test(value))\n\t\t\t\t.map(([key, value]) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\thand: lhPattern.test(value) ? 'left' : 'right',\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\tlet handStaves: number[] = null;\n\t\t\tlet partIndex;\n\n\t\t\t// 标记了左右手\n\t\t\tif (instrus.length === 2 && instrus[0].hand !== instrus[1].hand) {\n\t\t\t\tconst left = instrus.find((x) => x.hand === 'left');\n\t\t\t\tconst right = instrus.find((x) => x.hand === 'right');\n\t\t\t\thandStaves = [score.staffLayout.staffIds.findIndex((x) => x === right?.key), score.staffLayout.staffIds.findIndex((x) => x === left?.key)];\n\n\t\t\t\tpartIndex = partGroups.findIndex((g) => g.range[0] <= Math.min(...handStaves) && g.range[1] >= Math.max(...handStaves));\n\t\t\t}\n\n\t\t\tif (Number.isFinite(partIndex) && partIndex > -1) {\n\t\t\t\tconst trackToSplit = mergedTracks[partIndex];\n\t\t\t\tconst newTracks: any[][] = []; // Array.from(new Set(firstTrack.track.map(x => x.channel))).sort((a, b) => a - b)\n\n\t\t\t\ttrackToSplit.track.forEach((evt) => {\n\t\t\t\t\tif (Number.isFinite(evt.staff)) {\n\t\t\t\t\t\tif (!newTracks[evt.staff]) {\n\t\t\t\t\t\t\tnewTracks[evt.staff] = [];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tnewTracks[evt.staff].push(evt);\n\t\t\t\t\t}\n\t\t\t\t\tif (evt.type === 'meta') {\n\t\t\t\t\t\tnewTracks.forEach((stave) => {\n\t\t\t\t\t\t\tstave.push(evt);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmergedTracks.splice(partIndex, 1, newTracks.filter(Boolean).map((track) => ({ ...trackToSplit, track })) as any);\n\n\t\t\t\tmergedTracks = mergedTracks.flat();\n\n\t\t\t\t// 指定左右手track\n\t\t\t\tmidiJson.rightHandTrack = handStaves[0];\n\t\t\t\tmidiJson.leftHandTrack = handStaves[1];\n\t\t\t} else {\n\t\t\t\tmergedTracks.sort((a, b) => (a === mergedTracks[partIndex] ? -1 : 0));\n\t\t\t}\n\t\t}\n\n\t\tmidiJson.tracks = mergedTracks.map(({ program, channel, name }) => ({ program, channel, name }));\n\n\t\tconst transformedTracks = mergedTracks.map(({ track }) => {\n\t\t\tconst pitchMap: Map = new Map();\n\n\t\t\treturn track.map((evt) => {\n\t\t\t\tif (evt.subtype === 'noteOn') {\n\t\t\t\t\tpitchMap.set(evt.noteNumber, evt);\n\t\t\t\t}\n\n\t\t\t\tif (evt.subtype === 'noteOff') {\n\t\t\t\t\tconst onEvent = pitchMap.get(evt.noteNumber);\n\t\t\t\t\tif (onEvent?.noteNumber === evt.noteNumber) {\n\t\t\t\t\t\tonEvent.duration = evt.ticks - onEvent.ticks;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn evt;\n\t\t\t});\n\t\t});\n\n\t\tconst measureTickMap = new Map(Object.entries(midiJson.measures).map(([tick, m]) => [m.measure, +tick]));\n\n\t\tmidiJson.events = (transformedTracks as (MidiEvent & { duration: number; numId?: string; ticks: number })[][])\n\t\t\t.map((track, trackIndex) => {\n\t\t\t\treturn track\n\t\t\t\t\t.filter((x) => x.type === 'channel')\n\t\t\t\t\t.map((evt) => {\n\t\t\t\t\t\tif (evt?.ids?.[0]) {\n\t\t\t\t\t\t\tevt.numId = idsMap.get(evt.ids[0]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet newEvent: [number, number, number] = [0, 0, 0];\n\n\t\t\t\t\t\tswitch (evt.subtype) {\n\t\t\t\t\t\t\tcase 'noteOn':\n\t\t\t\t\t\t\t\tnewEvent = [0x90 | evt.channel, evt.noteNumber, evt.velocity];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'noteOff':\n\t\t\t\t\t\t\t\tnewEvent = [0x80 | evt.channel, evt.noteNumber, evt.velocity ? evt.velocity : 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'noteAftertouch':\n\t\t\t\t\t\t\t\tnewEvent = [0xa0 | evt.channel, evt.noteNumber, evt.amount];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'controller':\n\t\t\t\t\t\t\t\tnewEvent = [0xb0 | evt.channel, evt.controllerType, evt.value];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'programChange':\n\t\t\t\t\t\t\t\tnewEvent = [0xc0 | evt.channel, evt.programNumber, 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'channelAftertouch':\n\t\t\t\t\t\t\t\tnewEvent = [0xd0 | evt.channel, evt.amount, 0];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'pitchBend':\n\t\t\t\t\t\t\t\tnewEvent = [0xe0 | evt.channel, evt.value & 0xff, (evt.value >> 7) & 0xff];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new Error('unhandled event subtype:' + evt.subtype);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...(evt.subtype === 'noteOn' ? { id: idsMap.get(evt?.ids?.[0]) } : {}), // 对应符头的id\n\t\t\t\t\t\t\ttick: evt.ticks,\n\t\t\t\t\t\t\tchannel: evt.channel,\n\t\t\t\t\t\t\tduration: evt.duration, // 只有note on事件有时值\n\t\t\t\t\t\t\ttrack: trackIndex, // evt.staffTrack, // 所属track\n\t\t\t\t\t\t\tevent: newEvent, // [event, note, velocity]\n\t\t\t\t\t\t\telem_ids: evt?.ids.map((id) => idsMap.get(id)),\n\t\t\t\t\t\t\tmeasure: evt.measure - 1, // 所属小节编号\n\t\t\t\t\t\t\tmeas_start_tick: measureTickMap.get(evt.measure - 1), // 所属小节起始tick\n\t\t\t\t\t\t\tstaff: idStaffIndexMap.get(evt.ids[0]),\n\t\t\t\t\t\t\tnote: idNoteMap.get(evt.ids[0]),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1)\n\t\t\t.sort((a, b) => {\n\t\t\t\tfor (const field of ['tick', 'measure', 'track']) {\n\t\t\t\t\tif (a[field] !== b[field]) {\n\t\t\t\t\t\treturn a[field] - b[field];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t});\n\t}\n\n\treturn {\n\t\tscoreJson,\n\t\tmidiJson,\n\t};\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","import { EventEmitter } from 'events';\n\ninterface DSPromiseOption {\n\ttimeout?: number;\n}\n\nexport function destructPromise(\n\toptions: DSPromiseOption = {}\n): [promise: Promise, resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void] {\n\tconst { timeout } = options;\n\tlet rs: (value: T | PromiseLike) => void;\n\tlet rj: (reason: any) => void;\n\n\treturn [\n\t\tnew Promise((resolve, reject) => {\n\t\t\trs = resolve;\n\t\t\trj = reject;\n\n\t\t\tif (timeout >= 0) setTimeout(rj, timeout, 'timeout');\n\t\t}),\n\t\trs,\n\t\trj,\n\t];\n}\n\ntype AsyncTask = [fn: (data: any) => Promise, payload: any, resolve: (data: any) => void, reject: (reason: any) => void];\n\nexport class AsyncQueue extends EventEmitter {\n\tprivate working = false;\n\n\ttasks: AsyncTask[];\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.working = false;\n\t\tthis.tasks = [];\n\t\tprocess.nextTick(() => {\n\t\t\tthis.emit('idle');\n\t\t});\n\t}\n\n\tprivate async _digest(item: AsyncTask) {\n\t\tthis.working = true;\n\n\t\tconst [taskFn, payload, resolve, reject] = item;\n\t\tawait taskFn(payload).then(resolve, reject);\n\n\t\tif (this.tasks.length > 0) {\n\t\t\tawait this._digest(this.tasks.shift());\n\t\t} else {\n\t\t\tthis.working = false;\n\t\t\tthis.emit('idle');\n\t\t}\n\t}\n\n\t/**\n\t * 添加队列任务\n\t * @param task\n\t * @param options\n\t */\n\taddTask(task: [AsyncTask[0], AsyncTask[1]], { timeout = 600000 }: { timeout?: number } = {}): Promise {\n\t\tconst [promise, resolve, reject] = destructPromise({ timeout });\n\n\t\tif (this.working) {\n\t\t\tthis.tasks.push([...task, resolve, reject]);\n\t\t} else {\n\t\t\tthis._digest([...task, resolve, reject]);\n\t\t}\n\n\t\treturn promise;\n\t}\n}\n","import { pack, unpack } from 'msgpackr';\nimport { Request } from 'zeromq';\nimport { AsyncQueue } from './async-queue';\n\ninterface Response {\n\tcode: number;\n\tmsg: string;\n\tdata?: any;\n}\n\nexport interface Logger {\n\tinfo: (...data: any[]) => void;\n\terror: (...data: any[]) => void;\n}\n\ntype PyArgs = any[];\ntype PyKwargs = Record;\n\nexport default class ZeroClient {\n\tlogger: Logger;\n\tprivate socket: Request;\n\tprivate queue: AsyncQueue = new AsyncQueue();\n\n\tprivate url: string;\n\n\tconstructor(logger: Logger = console) {\n\t\tthis.logger = logger;\n\t}\n\n\tbind(url?: string) {\n\t\turl && (this.url = url);\n\t\tthis.socket = new Request({\n\t\t\tsendTimeout: 15e3,\n\t\t\treceiveTimeout: 300e3,\n\t\t});\n\n\t\tthis.socket.connect(this.url);\n\t}\n\n\tprivate __request(payload) {\n\t\tlet retryTimes = 0;\n\n\t\tconst req = async (data) => {\n\t\t\ttry {\n\t\t\t\tif (this.socket.closed) this.bind();\n\t\t\t\treturn await this.socket.send(pack(data)).then(() => this.socket.receive());\n\t\t\t} catch (err) {\n\t\t\t\tif (retryTimes < 2) {\n\t\t\t\t\tretryTimes++;\n\t\t\t\t\tconsole.log(`请求失败,${err.stack}`);\n\t\t\t\t\tconsole.error(`3s后重试第${retryTimes}次`);\n\t\t\t\t\tthis.socket.close();\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 3000));\n\t\t\t\t\treturn req(data);\n\t\t\t\t} else {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn req(payload);\n\t}\n\n\tasync request(method: string, args: PyArgs | PyKwargs = null, kwargs: PyKwargs = null): Promise {\n\t\tconst [args_, kwargs_] = Array.isArray(args) ? [args, kwargs] : [undefined, args];\n\t\tconst msg: any = { method };\n\t\tif (args_) msg.args = args_;\n\t\tif (kwargs_) msg.kwargs = kwargs_;\n\n\t\treturn this.queue.addTask([\n\t\t\tasync (opt) => {\n\t\t\t\tconst [result] = await this.__request(opt);\n\n\t\t\t\tconst obj = unpack(result) as Response;\n\n\t\t\t\tif (obj.code === 0) {\n\t\t\t\t\treturn obj.data;\n\t\t\t\t} else {\n\t\t\t\t\treturn Promise.reject(obj.msg);\n\t\t\t\t}\n\t\t\t},\n\t\t\tmsg,\n\t\t]);\n\t}\n}\n","import { getPortPromise } from 'portfinder';\nimport { Options, PythonShell } from 'python-shell';\nimport { defaultsDeep } from 'lodash';\nimport ZeroClient, { Logger } from './ZeroClient';\n\nexport default class PyProcessor extends ZeroClient {\n\tprivate readonly scriptPath: string;\n\tprivate readonly options: Options;\n\tprivate pyShell: PythonShell;\n\n\tprivate retryCount: number = 0;\n\tprivate retryDelay: number = 3000;\n\n\tconstructor(scriptPath: string, options: Options = {}, logger: Logger = console) {\n\t\tsuper(logger);\n\t\tthis.scriptPath = scriptPath;\n\t\tthis.options = options;\n\t}\n\n\tasync bind(port?: string | number) {\n\t\tconst freePort =\n\t\t\tport ||\n\t\t\t(await getPortPromise({\n\t\t\t\tport: 12022,\n\t\t\t\tstopPort: 12122,\n\t\t\t}));\n\n\t\t// \"./streamPredictor.py\", \"--inspect\"\n\t\tconst options = defaultsDeep(\n\t\t\t{\n\t\t\t\targs: [...(this.options.args || []), '-p', `${freePort}`],\n\t\t\t},\n\t\t\tthis.options\n\t\t);\n\n\t\tthis.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`);\n\n\t\tthis.pyShell = new PythonShell(this.scriptPath, options);\n\n\t\tthis.pyShell.stdout.on('data', (data) => this.logger.info(data));\n\n\t\tthis.pyShell.on('pythonError', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`, err));\n\t\tthis.pyShell.on('stderr', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`, err));\n\t\tthis.pyShell.on('error', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} error:`, err));\n\t\tthis.pyShell.on('close', () => {\n\t\t\t// python子进程关闭事件\n\t\t\tif (this.retryCount < 5) {\n\t\t\t\tthis.retryCount++;\n\t\t\t\tthis.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.bind();\n\t\t\t\t}, this.retryDelay);\n\t\t\t}\n\t\t});\n\n\t\tsuper.bind(`tcp://127.0.0.1:${freePort}`);\n\t}\n}\n","module.exports = function isBuffer(arg) {\n return arg instanceof Buffer;\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n","try {\n var util = require('util');\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n module.exports = require('./inherits_browser.js');\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(obj) {\n var keys = Object.keys(obj);\n var descriptors = {};\n for (var i = 0; i < keys.length; i++) {\n descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);\n }\n return descriptors;\n };\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n if (typeof process !== 'undefined' && process.noDeprecation === true) {\n return fn;\n }\n\n // Allow for deprecating things in the process of starting up.\n if (typeof process === 'undefined') {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nvar kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;\n\nexports.promisify = function promisify(original) {\n if (typeof original !== 'function')\n throw new TypeError('The \"original\" argument must be of type Function');\n\n if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {\n var fn = original[kCustomPromisifiedSymbol];\n if (typeof fn !== 'function') {\n throw new TypeError('The \"util.promisify.custom\" argument must be of type Function');\n }\n Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return fn;\n }\n\n function fn() {\n var promiseResolve, promiseReject;\n var promise = new Promise(function (resolve, reject) {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n args.push(function (err, value) {\n if (err) {\n promiseReject(err);\n } else {\n promiseResolve(value);\n }\n });\n\n try {\n original.apply(this, args);\n } catch (err) {\n promiseReject(err);\n }\n\n return promise;\n }\n\n Object.setPrototypeOf(fn, Object.getPrototypeOf(original));\n\n if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return Object.defineProperties(\n fn,\n getOwnPropertyDescriptors(original)\n );\n}\n\nexports.promisify.custom = kCustomPromisifiedSymbol\n\nfunction callbackifyOnRejected(reason, cb) {\n // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).\n // Because `null` is a special error value in callbacks which means \"no error\n // occurred\", we error-wrap so the callback consumer can distinguish between\n // \"the promise rejected with null\" or \"the promise fulfilled with undefined\".\n if (!reason) {\n var newReason = new Error('Promise was rejected with a falsy value');\n newReason.reason = reason;\n reason = newReason;\n }\n return cb(reason);\n}\n\nfunction callbackify(original) {\n if (typeof original !== 'function') {\n throw new TypeError('The \"original\" argument must be of type Function');\n }\n\n // We DO NOT return the promise as it gives the user a false sense that\n // the promise is actually somehow related to the callback's execution\n // and that the callback throwing will reject the promise.\n function callbackified() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n\n var maybeCb = args.pop();\n if (typeof maybeCb !== 'function') {\n throw new TypeError('The last argument must be of type Function');\n }\n var self = this;\n var cb = function() {\n return maybeCb.apply(self, arguments);\n };\n // In true node style we process the callback on `nextTick` with all the\n // implications (stack, `uncaughtException`, `async_hooks`)\n original.apply(this, args)\n .then(function(ret) { process.nextTick(cb, null, ret) },\n function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });\n }\n\n Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));\n Object.defineProperties(callbackified,\n getOwnPropertyDescriptors(original));\n return callbackified;\n}\nexports.callbackify = callbackify;\n","import ZeroClient, { Logger } from './ZeroClient';\nimport * as starry from '../../src/starry';\nimport PyProcessor from './PyProcessor';\nimport { destructPromise } from './async-queue';\nimport { getPort } from 'portfinder';\nimport util from 'util';\nimport { Options } from 'python-shell';\n\nconst getPortPromise = util.promisify(getPort);\n\nexport interface LayoutResult {\n\tdetection: starry.PageLayout;\n\ttheta: number;\n\tinterval: number;\n\tsourceSize?: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface PredictorInterface {\n\tlayout: (streams: Buffer[]) => LayoutResult[];\n\tlayout$reinforce: (streams: Buffer[], baseLayouts: LayoutResult[]) => LayoutResult[];\n\tgauge: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tmask: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tsemantic: (streams: Buffer[]) => any[];\n\ttextLoc: (streams: Buffer[]) => any[];\n\ttextOcr: (params: { buffers: Buffer[]; location: any[] }) => any[];\n\tbrackets: (params: { buffers: Buffer[] }) => any[];\n\ttopo: (params: { clusters: starry.EventCluster[] }) => any[];\n\tgaugeRenderer: (params: [Buffer, Buffer, number]) => { buffer: Buffer; size: { width: number; height: number } };\n\tjianpu: (params: { buffers: Buffer[] }) => any[];\n\t// [source: Buffer, gauge: Buffer, baseY: number]\n}\n\ntype PredictorType = keyof PredictorInterface;\n\nexport type PyClientsConstructOptions = Partial>;\n\nexport class PyClients {\n\tclients = new Map>();\n\n\tconstructor(public readonly options: PyClientsConstructOptions, public readonly logger: Logger = console) {}\n\n\tasync getClient(type: PredictorType) {\n\t\tif (this.clients.has(type)) {\n\t\t\treturn this.clients.get(type);\n\t\t}\n\n\t\tconst [promise, resolve, reject] = destructPromise();\n\n\t\tconst opt = this.options[type];\n\n\t\tif (!opt) {\n\t\t\tthrow new Error(`no config for client \\`${type}\\` found`);\n\t\t}\n\n\t\ttry {\n\t\t\tif (typeof opt === 'string') {\n\t\t\t\tconst client = new ZeroClient();\n\t\t\t\tclient.bind(opt);\n\t\t\t\tresolve(client);\n\t\t\t} else {\n\t\t\t\tconst { scriptPath, ...option } = opt;\n\t\t\t\tconst client = new PyProcessor(scriptPath, option, this.logger);\n\t\t\t\tawait client.bind(`${await getPortPromise()}`);\n\t\t\t\tresolve(client);\n\t\t\t}\n\n\t\t\tthis.logger.info(`PyClients: ${type} started`);\n\t\t} catch (err) {\n\t\t\tthis.logger.error(`PyClients: ${type} start fail: ${JSON.stringify(err)}`);\n\t\t\treject(err);\n\t\t}\n\n\t\tthis.clients.set(type, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync checkHost(type: PredictorType): Promise {\n\t\tconst client = await this.getClient(type);\n\n\t\treturn client.request('checkHost');\n\t}\n\n\tasync warmup() {\n\t\tconst opts = Object.keys(this.options) as PredictorType[];\n\t\tawait Promise.all(opts.map((type) => this.getClient(type)));\n\t}\n\n\t/**\n\t * 模型预测\n\t * @param type layout | mask | gauge | semantic\n\t * @param args\n\t */\n\tasync predictScoreImages(type: T, ...args: Parameters): Promise> {\n\t\tconst clientType = type.split('$')[0] as PredictorType;\n\t\tconst client = await this.getClient(clientType);\n\t\tlet res = null;\n\n\t\tthis.logger.info(`[predictor]: ${type} py start..`);\n\t\tconst start = Date.now();\n\n\t\tswitch (type) {\n\t\t\tcase 'layout':\n\t\t\t\tres = await client.request('predictDetection', args);\n\t\t\t\tbreak;\n\t\t\tcase 'layout$reinforce':\n\t\t\t\tres = await client.request('predictReinforce', args);\n\t\t\t\tbreak;\n\t\t\tcase 'gauge':\n\t\t\tcase 'mask':\n\t\t\t\tres = await client.request('predict', args, { by_buffer: true });\n\t\t\t\tbreak;\n\t\t\tcase 'semantic':\n\t\t\tcase 'textLoc':\n\t\t\t\tres = await client.request('predict', args);\n\t\t\t\tbreak;\n\t\t\tcase 'textOcr':\n\t\t\tcase 'brackets':\n\t\t\tcase 'topo':\n\t\t\tcase 'gaugeRenderer':\n\t\t\tcase 'jianpu':\n\t\t\t\tres = await client.request('predict', ...args);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.logger.error(`[predictor]: no predictor ${type}`);\n\t\t}\n\n\t\tthis.logger.info(`[predictor]: ${type} py duration: ${Date.now() - start}ms`);\n\n\t\treturn res;\n\t}\n}\n","(function() {\n var base64map\n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',\n\n crypt = {\n // Bit-wise rotation left\n rotl: function(n, b) {\n return (n << b) | (n >>> (32 - b));\n },\n\n // Bit-wise rotation right\n rotr: function(n, b) {\n return (n << (32 - b)) | (n >>> b);\n },\n\n // Swap big-endian to little-endian and vice versa\n endian: function(n) {\n // If number given, swap endian\n if (n.constructor == Number) {\n return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;\n }\n\n // Else, assume array and swap all items\n for (var i = 0; i < n.length; i++)\n n[i] = crypt.endian(n[i]);\n return n;\n },\n\n // Generate an array of any length of random bytes\n randomBytes: function(n) {\n for (var bytes = []; n > 0; n--)\n bytes.push(Math.floor(Math.random() * 256));\n return bytes;\n },\n\n // Convert a byte array to big-endian 32-bit words\n bytesToWords: function(bytes) {\n for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)\n words[b >>> 5] |= bytes[i] << (24 - b % 32);\n return words;\n },\n\n // Convert big-endian 32-bit words to a byte array\n wordsToBytes: function(words) {\n for (var bytes = [], b = 0; b < words.length * 32; b += 8)\n bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a hex string\n bytesToHex: function(bytes) {\n for (var hex = [], i = 0; i < bytes.length; i++) {\n hex.push((bytes[i] >>> 4).toString(16));\n hex.push((bytes[i] & 0xF).toString(16));\n }\n return hex.join('');\n },\n\n // Convert a hex string to a byte array\n hexToBytes: function(hex) {\n for (var bytes = [], c = 0; c < hex.length; c += 2)\n bytes.push(parseInt(hex.substr(c, 2), 16));\n return bytes;\n },\n\n // Convert a byte array to a base-64 string\n bytesToBase64: function(bytes) {\n for (var base64 = [], i = 0; i < bytes.length; i += 3) {\n var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];\n for (var j = 0; j < 4; j++)\n if (i * 8 + j * 6 <= bytes.length * 8)\n base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));\n else\n base64.push('=');\n }\n return base64.join('');\n },\n\n // Convert a base-64 string to a byte array\n base64ToBytes: function(base64) {\n // Remove non-base-64 characters\n base64 = base64.replace(/[^A-Z0-9+\\/]/ig, '');\n\n for (var bytes = [], i = 0, imod4 = 0; i < base64.length;\n imod4 = ++i % 4) {\n if (imod4 == 0) continue;\n bytes.push(((base64map.indexOf(base64.charAt(i - 1))\n & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))\n | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));\n }\n return bytes;\n }\n };\n\n module.exports = crypt;\n})();\n","var charenc = {\n // UTF-8 encoding\n utf8: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));\n }\n },\n\n // Binary encoding\n bin: {\n // Convert a string to a byte array\n stringToBytes: function(str) {\n for (var bytes = [], i = 0; i < str.length; i++)\n bytes.push(str.charCodeAt(i) & 0xFF);\n return bytes;\n },\n\n // Convert a byte array to a string\n bytesToString: function(bytes) {\n for (var str = [], i = 0; i < bytes.length; i++)\n str.push(String.fromCharCode(bytes[i]));\n return str.join('');\n }\n }\n};\n\nmodule.exports = charenc;\n","(function() {\n var crypt = require('crypt'),\n utf8 = require('charenc').utf8,\n bin = require('charenc').bin,\n\n // The core\n sha1 = function (message) {\n // Convert to byte array\n if (message.constructor == String)\n message = utf8.stringToBytes(message);\n else if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message))\n message = Array.prototype.slice.call(message, 0);\n else if (!Array.isArray(message))\n message = message.toString();\n\n // otherwise assume byte array\n\n var m = crypt.bytesToWords(message),\n l = message.length * 8,\n w = [],\n H0 = 1732584193,\n H1 = -271733879,\n H2 = -1732584194,\n H3 = 271733878,\n H4 = -1009589776;\n\n // Padding\n m[l >> 5] |= 0x80 << (24 - l % 32);\n m[((l + 64 >>> 9) << 4) + 15] = l;\n\n for (var i = 0; i < m.length; i += 16) {\n var a = H0,\n b = H1,\n c = H2,\n d = H3,\n e = H4;\n\n for (var j = 0; j < 80; j++) {\n\n if (j < 16)\n w[j] = m[i + j];\n else {\n var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16];\n w[j] = (n << 1) | (n >>> 31);\n }\n\n var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + (\n j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 :\n j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 :\n j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 :\n (H1 ^ H2 ^ H3) - 899497514);\n\n H4 = H3;\n H3 = H2;\n H2 = (H1 << 30) | (H1 >>> 2);\n H1 = H0;\n H0 = t;\n }\n\n H0 += a;\n H1 += b;\n H2 += c;\n H3 += d;\n H4 += e;\n }\n\n return [H0, H1, H2, H3, H4];\n },\n\n // Public API\n api = function (message, options) {\n var digestbytes = crypt.wordsToBytes(sha1(message));\n return options && options.asBytes ? digestbytes :\n options && options.asString ? bin.bytesToString(digestbytes) :\n crypt.bytesToHex(digestbytes);\n };\n\n api._blocksize = 16;\n api._digestsize = 20;\n\n module.exports = api;\n})();\n","import SparkMD5 from 'spark-md5';\n//import JSZip from 'jszip';\nimport * as starry from '../../src/starry';\n//import { encodeFindResource } from '../../src/isomorphic/converter';\nimport sharp, { FormatEnum } from 'sharp';\nimport got from 'got';\n//import { Logger } from './ZeroClient';\nimport type { SolutionStore, SaveIssueMeasure } from './store';\nimport { ScoreJSON } from '../../src/isomorphic/types';\n\nconst SYSTEM_MARGIN = 4;\n\nexport const constructSystem = ({ page, backgroundImage, detection, imageSize, position }) => {\n\tconst systemWidth = (detection.phi2 - detection.phi1) / detection.interval;\n\tconst systemHeight = imageSize.height / detection.interval;\n\n\tconst lastSystem = page.systems[page.systems.length - 1];\n\tconst top = position ? position.y : (lastSystem ? lastSystem.top + lastSystem.height : 0) + SYSTEM_MARGIN;\n\tconst left = position ? position.x : SYSTEM_MARGIN;\n\n\tconst stavesTops = [\n\t\t0,\n\t\t...Array(detection.middleRhos.length - 1)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => (detection.middleRhos[i] + detection.middleRhos[i + 1]) / 2 / detection.interval),\n\t];\n\n\tconst measureBars = [systemWidth];\n\n\tconst staves = stavesTops.map(\n\t\t(top, i) =>\n\t\t\tnew starry.Staff({\n\t\t\t\ttop,\n\t\t\t\theight: (stavesTops[i + 1] || systemHeight) - top,\n\t\t\t\tstaffY: detection.middleRhos[i] / detection.interval - top,\n\t\t\t\tmeasureBars,\n\t\t\t})\n\t);\n\n\t//console.log(\"detection:\", detection, options, stavesTops);\n\n\tconst imagePosition = {\n\t\tx: -detection.phi1 / detection.interval,\n\t\ty: 0,\n\t\twidth: imageSize.width / detection.interval,\n\t\theight: imageSize.height / detection.interval,\n\t};\n\n\treturn new starry.System({\n\t\tstaves,\n\t\tleft,\n\t\ttop,\n\t\twidth: systemWidth,\n\t\tbackgroundImage,\n\t\timagePosition,\n\t\tmeasureBars,\n\t});\n};\n\nexport interface ConvertOption {\n\tformat?: keyof FormatEnum;\n\tquality?: number;\n\tmaxHeight?: number;\n}\n\nconst toBuffer = async (url: string | Buffer): Promise => {\n\tif (typeof url === 'string') {\n\t\tif (/^https?:\\/\\//.test(url)) {\n\t\t\treturn (await got(url, { responseType: 'buffer', decompress: true, https: { rejectUnauthorized: false } })).body;\n\t\t}\n\n\t\tif (/^data:image\\//.test(url)) {\n\t\t\treturn Buffer.from(url.split(',')[1], 'base64');\n\t\t}\n\n\t\treturn Buffer.from(url);\n\t}\n\n\treturn url;\n};\n\n/**\n * 转换图片格式,默认webp、最大高度1080,高度小于1080自动不做尺寸变换\n * @param url\n * @param format\n * @param maxHeight\n * @param quality\n */\nexport async function convertImage(url: string | Buffer, { format = 'webp', maxHeight = 1080, quality = 80 }: ConvertOption = {}) {\n\tlet buf = await toBuffer(url);\n\n\tconst webpBuffer = await new Promise((resolve) => {\n\t\tsharp(buf)\n\t\t\t.resize({\n\t\t\t\twidth: maxHeight,\n\t\t\t\theight: maxHeight,\n\t\t\t\tfit: 'inside',\n\t\t\t\twithoutEnlargement: true,\n\t\t\t})\n\t\t\t.toFormat(format, { quality })\n\t\t\t.toBuffer((err, buf) => {\n\t\t\t\tresolve(buf);\n\t\t\t});\n\t});\n\n\tconst md5 = SparkMD5.ArrayBuffer.hash(webpBuffer);\n\n\treturn {\n\t\tbuffer: webpBuffer,\n\t\tfilename: `${md5}.${format}`,\n\t};\n}\n\n/**\n * 替换scoreJson图片地址\n * @param scoreJson\n * @param onReplaceImage\n */\nexport const replaceScoreJsonImages = (scoreJson: ScoreJSON, onReplaceImage: (src: string) => string = (src) => src) => {\n\tconst json = JSON.parse(JSON.stringify(scoreJson));\n\n\tjson.pages.forEach((page) => {\n\t\tpage?.src && (page.src = onReplaceImage(page?.src));\n\t});\n\n\tjson.lines.forEach((system) => {\n\t\tsystem.lineStaves.forEach((line) => {\n\t\t\tline.imgs.forEach((staff) => {\n\t\t\t\tstaff?.src && (staff.src = onReplaceImage(staff.src));\n\t\t\t});\n\t\t});\n\t});\n\n\treturn json;\n};\n\n/**\n * 获取scoreJson图片资源列表\n * @param scoreJson\n */\nexport const getScoreJsonImages = (scoreJson: ScoreJSON) => {\n\treturn [\n\t\t...scoreJson.pages.map((page) => page?.src),\n\t\t...scoreJson.lines\n\t\t\t.map((system) => system.lineStaves.map((staff) => staff.imgs))\n\t\t\t.flat(2)\n\t\t\t.map((staff) => staff?.src)\n\t\t\t.filter(Boolean),\n\t];\n};\n\ninterface ScorePatchesUpdateOptions {\n\tsolutionStore?: SolutionStore;\n}\n\nexport const updateScorePatches = (score: starry.Score, measures: starry.SpartitoMeasure[], options: ScorePatchesUpdateOptions = {}): void => {\n\tconsole.assert(\n\t\tmeasures.every((measure) => measure.validRegulated),\n\t\t'[updateScorePatches] some measures not valid regulated:',\n\t\tmeasures.filter((measure) => !measure.validRegulated)\n\t);\n\n\tscore.patches = measures.map((measure) => measure.createPatch());\n\n\tif (options?.solutionStore) {\n\t\tscore.assemble();\n\t\tconst spartito = score.makeSpartito();\n\n\t\tmeasures.forEach((measure) => {\n\t\t\toptions.solutionStore!.set(measure.regulationHash, { ...measure.asSolution(), priority: 1 });\n\t\t\tif (measure.regulationHash0 !== measure.regulationHash) {\n\t\t\t\tconst originMeasure = spartito.measures.find((m) => m.measureIndex === measure.measureIndex);\n\t\t\t\toptions.solutionStore!.set(measure.regulationHash0, { ...measure.asSolution(originMeasure), priority: 1 });\n\t\t\t}\n\t\t});\n\t}\n};\n\ninterface EditableMeasuresSaveOptions {\n\tstatus?: number;\n\tsolutionStore?: SolutionStore;\n}\n\nexport const saveEditableMeasures = async (\n\tscore: starry.Score,\n\tmeasureIndices: number[],\n\tsaveMeasure: SaveIssueMeasure,\n\t{ status = 2, solutionStore }: EditableMeasuresSaveOptions = {}\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\n\tconst measures = measureIndices\n\t\t.map((index) => spartito.measures.find((measure) => measure.measureIndex === index))\n\t\t.filter(Boolean) as starry.SpartitoMeasure[];\n\n\tif (solutionStore) {\n\t\tconst solutions = await solutionStore.batchGet(measures.map((measure) => measure.regulationHash0));\n\t\tmeasures.forEach((measure, i) => {\n\t\t\tconst solution = solutions[i];\n\t\t\tif (solution) measure.applySolution(solution);\n\t\t});\n\t}\n\n\tmeasures.forEach((measure) => {\n\t\tsaveMeasure({\n\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\tmeasure: new starry.EditableMeasure(measure),\n\t\t\tstatus,\n\t\t});\n\t});\n};\n","import sha1 from 'sha1';\nimport { Canvas, Image, loadImage } from 'skia-canvas';\nimport { WeakLRUCache } from 'weak-lru-cache';\nimport * as starry from '../../src/starry';\nimport { SemanticGraph } from '../../src/starry';\nimport { LayoutResult, PyClients } from './predictors';\nimport { constructSystem, convertImage } from './util';\n\nglobalThis.OffscreenCanvas = (globalThis as any).OffscreenCanvas || Canvas;\n(globalThis as any).Image = (globalThis as any).Image || Image;\nglobalThis.btoa = globalThis.btoa || ((str: string) => Buffer.from(str, 'binary').toString('base64'));\n\nconst STAFF_PADDING_LEFT = 32;\n\nconst MAX_PAGE_WIDTH = 1200;\n\nconst GAUGE_VISION_SPEC = {\n\tviewportHeight: 256,\n\tviewportUnit: 8,\n};\n\nconst MASK_VISION_SPEC = {\n\tviewportHeight: 192,\n\tviewportUnit: 8,\n};\n\nconst SEMANTIC_VISION_SPEC = {\n\tviewportHeight: 192,\n\tviewportUnit: 8,\n};\n\ninterface OMRStat {\n\tcost: number; // in milliseconds\n\tpagesCost: number; // in milliseconds\n\tpages: number;\n}\n\ninterface OMRSummary {\n\tcostTotal: number; // in milliseconds\n\tcostPerPage: number; // in milliseconds\n\tpagesTotal: number;\n\tscoreN: number;\n}\n\n/**\n * 为布局识别的图片标准化处理\n * @param image\n * @param width\n */\nfunction scaleForLayout(image: Image, width: number): Canvas {\n\tlet height = (image.height / image.width) * width;\n\n\tconst canvas = new Canvas(width, height);\n\tconst ctx = canvas.getContext('2d');\n\n\tctx.drawImage(image, 0, 0, width, (width * image.height) / image.width);\n\n\treturn canvas;\n}\n\n/**\n * 根据所有图像的检测结果设置合适的全局页面尺寸\n * @param score\n * @param detections\n * @param outputWidth\n */\nfunction setGlobalPageSize(score: starry.Score, detections: LayoutResult[], outputWidth: number) {\n\tconst sizeRatios = detections\n\t\t.filter((s) => s && s.detection && s.detection.areas?.length)\n\t\t.map((v, k) => {\n\t\t\tconst staffInterval = Math.min(...v.detection.areas.filter((area) => area.staves?.middleRhos?.length).map((x) => x.staves.interval));\n\n\t\t\tconst sourceSize = v.sourceSize;\n\t\t\treturn {\n\t\t\t\t...v,\n\t\t\t\tindex: k,\n\t\t\t\tvw: sourceSize.width / staffInterval, // 页面宽度(逻辑单位)\n\t\t\t\thwr: sourceSize.height / sourceSize.width, // 页面高宽比\n\t\t\t};\n\t\t});\n\n\tif (!sizeRatios.length) {\n\t\tthrow new Error('empty result');\n\t}\n\n\tconst maxVW = sizeRatios.sort((a, b) => b.vw - a.vw)[0];\n\tconst maxAspect = Math.max(...sizeRatios.map((r) => r.hwr));\n\n\tscore.unitSize = outputWidth / maxVW.vw;\n\n\t// 页面显示尺寸\n\tscore.pageSize = {\n\t\twidth: outputWidth,\n\t\theight: outputWidth * maxAspect,\n\t};\n}\n\nconst batchTask = (fn: () => Promise) => fn();\nconst concurrencyTask = (fns: (() => Promise)[]) => Promise.all(fns.map((fn) => fn()));\n\nconst shootStaffImage = async (\n\tsystem: starry.System,\n\tstaffIndex: number,\n\t{ paddingLeft = 0, scaling = 1, spec }: { paddingLeft?: number; scaling?: number; spec: { viewportHeight: number; viewportUnit: number } }\n): Promise => {\n\tif (!system || !system.backgroundImage) return null;\n\n\tconst staff = system.staves[staffIndex];\n\tif (!staff) return null;\n\n\tconst middleUnits = spec.viewportHeight / spec.viewportUnit / 2;\n\n\tconst width = system.imagePosition.width * spec.viewportUnit;\n\tconst height = system.imagePosition.height * spec.viewportUnit;\n\tconst x = system.imagePosition.x * spec.viewportUnit + paddingLeft;\n\tconst y = (system.imagePosition.y - (staff.top + staff.staffY - middleUnits)) * spec.viewportUnit;\n\n\tconst canvas = new Canvas(Math.round(width + x) * scaling, spec.viewportHeight * scaling);\n\tconst context = canvas.getContext('2d');\n\tcontext.fillStyle = 'white';\n\tcontext.fillRect(0, 0, canvas.width, canvas.height);\n\tcontext.drawImage(await loadImage(system.backgroundImage), x * scaling, y * scaling, width * scaling, height * scaling);\n\n\treturn canvas;\n\t// .substr(22);\t// remove the prefix of 'data:image/png;base64,'\n};\n\n/**\n * 根据布局检测结果进行截图\n * @param score\n * @param pageCanvas\n * @param page\n * @param detection\n */\nasync function shootImageByDetection({\n\tpage,\n\tscore,\n\tpageCanvas,\n}: {\n\tscore: starry.Score;\n\tpage: starry.Page;\n\tpageCanvas: Canvas; // 原始图片绘制好的canvas\n}) {\n\tif (!page?.layout?.areas?.length) {\n\t\treturn null;\n\t}\n\n\tpage.width = score.pageSize.width / score.unitSize;\n\tpage.height = score.pageSize.height / score.unitSize;\n\n\tconst correctCanvas = new Canvas(pageCanvas.width, pageCanvas.height);\n\tconst ctx = correctCanvas.getContext('2d');\n\n\tctx.save();\n\n\tconst { width, height } = correctCanvas;\n\tconst [a, b, c, d] = page.source.matrix;\n\n\tctx.setTransform(a, b, c, d, (-1 / 2) * width + (1 / 2) * a * width + (1 / 2) * b * height, (-1 / 2) * height + (1 / 2) * c * width + (1 / 2) * d * height);\n\n\tctx.drawImage(pageCanvas, 0, 0);\n\n\tctx.restore();\n\n\tconst interval = page.source.interval;\n\n\tpage.layout.areas.map((area, systemIndex) => {\n\t\tconsole.assert(area.staves?.middleRhos?.length, '[shootImageByDetection] empty area:', area);\n\n\t\tconst data = ctx.getImageData(area.x, area.y, area.width, area.height);\n\n\t\tconst canvas = new Canvas(area.width, area.height);\n\n\t\tconst context = canvas.getContext('2d');\n\t\t// context.rotate(-area.staves.theta);\n\t\tcontext.putImageData(data, 0, 0);\n\n\t\tconst detection = area.staves;\n\t\tconst size = { width: area.width, height: area.height };\n\n\t\tconst sourceCenter = {\n\t\t\tx: pageCanvas.width / 2 / interval,\n\t\t\ty: pageCanvas.height / 2 / interval,\n\t\t};\n\n\t\tconst position = {\n\t\t\tx: (area.x + area.staves.phi1) / interval - sourceCenter.x + page.width / 2,\n\t\t\ty: area.y / interval - sourceCenter.y + page.height / 2,\n\t\t};\n\n\t\tpage.systems[systemIndex] = constructSystem({\n\t\t\tpage,\n\t\t\tbackgroundImage: canvas.toBufferSync('png'),\n\t\t\tdetection,\n\t\t\timageSize: size,\n\t\t\tposition,\n\t\t});\n\t});\n\n\treturn correctCanvas;\n}\n\nasync function shootStaffBackgroundImage({ system, staff, staffIndex }: { system: starry.System; staff: starry.Staff; staffIndex: number }) {\n\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\tspec: SEMANTIC_VISION_SPEC,\n\t});\n\n\tstaff.backgroundImage = sourceCanvas.toBufferSync('png');\n\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - SEMANTIC_VISION_SPEC.viewportHeight / 2 / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\twidth: sourceCanvas.width / SEMANTIC_VISION_SPEC.viewportUnit,\n\t\theight: sourceCanvas.height / SEMANTIC_VISION_SPEC.viewportUnit,\n\t};\n}\n\n/**\n * 单个staff的变形矫正\n * @param system\n * @param staff\n * @param staffIndex\n * @param gaugeImage\n * @param pyClients\n */\nasync function gaugeStaff({\n\tsystem,\n\tstaff,\n\tstaffIndex,\n\tgaugeImage,\n\tpyClients,\n}: {\n\tsystem: starry.System;\n\tstaff: starry.Staff;\n\tstaffIndex: number;\n\tgaugeImage: Buffer;\n\tpyClients: PyClients;\n}) {\n\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\tspec: GAUGE_VISION_SPEC,\n\t\tscaling: 2,\n\t});\n\n\tconst sourceBuffer = sourceCanvas.toBufferSync('png');\n\n\tconst baseY = (system.middleY - (staff.top + staff.staffY)) * GAUGE_VISION_SPEC.viewportUnit + GAUGE_VISION_SPEC.viewportHeight / 2;\n\n\tconst { buffer, size } = await pyClients.predictScoreImages('gaugeRenderer', [sourceBuffer, gaugeImage, baseY]);\n\n\tstaff.backgroundImage = buffer;\n\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / GAUGE_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - size.height / 2 / GAUGE_VISION_SPEC.viewportUnit,\n\t\twidth: size.width / GAUGE_VISION_SPEC.viewportUnit,\n\t\theight: size.height / GAUGE_VISION_SPEC.viewportUnit,\n\t};\n\n\tstaff.maskImage = null;\n}\n\n/**\n * 单个staff的降噪\n * @param staff\n * @param staffIndex\n * @param maskImage\n */\nasync function maskStaff({ staff, staffIndex, maskImage }: { staff: starry.Staff; staffIndex: number; maskImage: Buffer }) {\n\tconst img = await loadImage(maskImage);\n\n\tstaff.maskImage = maskImage;\n\tstaff.imagePosition = {\n\t\tx: -STAFF_PADDING_LEFT / MASK_VISION_SPEC.viewportUnit,\n\t\ty: staff.staffY - MASK_VISION_SPEC.viewportHeight / 2 / MASK_VISION_SPEC.viewportUnit,\n\t\twidth: img.width / MASK_VISION_SPEC.viewportUnit,\n\t\theight: img.height / MASK_VISION_SPEC.viewportUnit,\n\t};\n}\n\n/**\n * 单个staff的语义识别\n * @param score\n * @param staffIndex\n * @param system\n * @param staff\n * @param graph\n */\nasync function semanticStaff({\n\tscore,\n\tstaffIndex,\n\tsystem,\n\tstaff,\n\tgraph,\n}: {\n\tscore: starry.Score;\n\tstaffIndex: number;\n\tsystem: starry.System;\n\tstaff: starry.Staff;\n\tgraph: SemanticGraph;\n}) {\n\tgraph.offset(-STAFF_PADDING_LEFT / SEMANTIC_VISION_SPEC.viewportUnit, 0);\n\n\tsystem.assignSemantics(staffIndex, graph);\n\n\tstaff.assignSemantics(graph);\n\tstaff.clearPredictedTokens();\n\n\tscore.assembleSystem(system, score.settings?.semanticConfidenceThreshold || 1);\n}\n\nfunction replacePageImages(page: starry.Page, onReplaceImageKey: (src: string) => any) {\n\tconst tasks = [\n\t\t[page.source, 'url'],\n\t\t...page.systems\n\t\t\t.map((system) => {\n\t\t\t\treturn [\n\t\t\t\t\t[system, 'backgroundImage'],\n\t\t\t\t\t...system.staves\n\t\t\t\t\t\t.map((staff) => [\n\t\t\t\t\t\t\t[staff, 'backgroundImage'],\n\t\t\t\t\t\t\t[staff, 'maskImage'],\n\t\t\t\t\t\t])\n\t\t\t\t\t\t.flat(),\n\t\t\t\t];\n\t\t\t})\n\t\t\t.flat(),\n\t];\n\n\ttasks.map(([target, key]: [any, string]) => {\n\t\ttarget[key] = onReplaceImageKey(target[key]);\n\t});\n}\n\nexport type TaskProgress = { total?: number; finished?: number };\n\nexport interface OMRPage {\n\turl: string | Buffer;\n\tkey?: string;\n\tlayout?: LayoutResult;\n\trenew?: boolean;\n\tenableGauge?: boolean;\n}\n\nexport interface ProgressState {\n\tlayout?: TaskProgress;\n\ttext?: TaskProgress;\n\tgauge?: TaskProgress;\n\tmask?: TaskProgress;\n\tsemantic?: TaskProgress;\n\tregulate?: TaskProgress;\n\tbrackets?: TaskProgress;\n}\n\nclass OMRProgress {\n\tstate: ProgressState = {};\n\n\tonChange: (evt: ProgressState) => void;\n\n\tconstructor(onChange: (evt: ProgressState) => void) {\n\t\tthis.onChange = onChange;\n\t}\n\n\tsetTotal(stage: keyof ProgressState, total: number) {\n\t\tthis.state[stage] = this.state[stage] || {\n\t\t\ttotal,\n\t\t\tfinished: 0,\n\t\t};\n\t}\n\n\tincrease(stage: keyof ProgressState, step = 1) {\n\t\tconst info: TaskProgress = this.state[stage] || {\n\t\t\tfinished: 0,\n\t\t};\n\t\tinfo.finished += step;\n\n\t\tthis.onChange(this.state);\n\t}\n}\n\ntype SourceImage = string | Buffer;\n\nexport interface OMROption {\n\toutputWidth?: number;\n\ttitle?: string; // 曲谱标题\n\tpageStore?: {\n\t\thas?: (key: string) => Promise;\n\t\tget: (key: string) => Promise;\n\t\tset: (key: string, val: string) => Promise;\n\t};\n\trenew?: boolean;\n\tprocesses?: (keyof ProgressState)[]; // 选择流程\n\tonProgress?: (progress: ProgressState) => void;\n\tonReplaceImage?: (src: SourceImage) => Promise; // 替换所有图片地址,用于上传或者格式转换\n}\n\nconst lruCache = new WeakLRUCache();\n\n// 默认store\nconst pageStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as string;\n\t},\n\tasync set(key: string, val: string) {\n\t\tlruCache.setValue(key, val);\n\t},\n};\n\n/**\n * 默认将图片转换为webp格式的base64字符串\n * @param src\n */\nconst onReplaceImage = async (src: SourceImage) => {\n\tif (src instanceof Buffer || (typeof src === 'string' && (/^https?:\\/\\//.test(src) || /^data:image\\//.test(src)))) {\n\t\tconst webpBuffer = (await convertImage(src)).buffer;\n\t\treturn `data:image/webp;base64,${webpBuffer.toString('base64')}`;\n\t}\n\n\treturn src;\n};\n\n/**\n * 识别所有图片\n * @param pyClients\n * @param images\n * @param option\n */\nexport const predictPages = async (\n\tpyClients: PyClients,\n\timages: OMRPage[],\n\toption: OMROption = { outputWidth: 1200, pageStore, onReplaceImage }\n): Promise<{ score: starry.Score; omitPages: number[]; stat: OMRStat }> => {\n\tconst logger = pyClients.logger;\n\n\toption.outputWidth = option.outputWidth || 1200;\n\toption.pageStore = option.pageStore || pageStore;\n\toption.onReplaceImage = option.onReplaceImage || onReplaceImage;\n\n\toption.processes =\n\t\tArray.isArray(option.processes) && option.processes.length > 0 ? option.processes : ['layout', 'text', 'gauge', 'mask', 'semantic', 'brackets'];\n\tconst progress: OMRProgress = new OMRProgress(option.onProgress);\n\n\tconst t0 = Date.now();\n\n\t// 预处理删除不合法区域\n\timages.forEach((image) => {\n\t\tif (image.layout?.detection) {\n\t\t\timage.layout.detection.areas = image.layout.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0);\n\t\t} else {\n\t\t\tdelete image.layout;\n\t\t}\n\t});\n\n\tconst score = new starry.Score({\n\t\ttitle: option?.title,\n\t\tstavesCount: 2,\n\t\tpaperOptions: {\n\t\t\traggedLast: true,\n\t\t\traggedLastBottom: true,\n\t\t},\n\t\theaders: {},\n\t\tinstrumentDict: {},\n\t\tsettings: {\n\t\t\tenabledGauge: option.processes.includes('gauge'),\n\t\t\tsemanticConfidenceThreshold: 1,\n\t\t},\n\t});\n\n\tlogger.info(`[predictor]: download_source_images-${images.length}`);\n\n\t// 原始拍摄图\n\tconst originalImages: Image[] = await Promise.all(images.map((img) => loadImage(img.url as any)));\n\n\tlogger.info(`[predictor]: source_images_downloaded-${images.length}`);\n\n\t//const INPUT_IMAGE_WIDTH = images.filter((x) => x?.layout?.interval)?.[0]?.layout?.sourceSize?.width;\n\n\t/******************************* 布局识别 start *************************/\n\t// 输入给布局检测的图\n\tconst pageCanvasList: Canvas[] = originalImages.map((img, index) => scaleForLayout(img, images[index]!.layout?.sourceSize?.width ?? img.width));\n\n\tprogress.setTotal('layout', originalImages.length);\n\tprogress.setTotal('text', originalImages.length);\n\n\tconst detections = await Promise.all(\n\t\tpageCanvasList.map(async (cvs, key) => {\n\t\t\tif (!images[key].layout) return (await pyClients.predictScoreImages('layout', [cvs.toBufferSync('png')]))?.[0];\n\n\t\t\t// reinforce layout from front-end if no gauge\n\t\t\tif (!images[key].enableGauge && images[key]?.layout?.detection?.areas?.length)\n\t\t\t\treturn (await pyClients.predictScoreImages('layout$reinforce', [cvs.toBufferSync('png')], [images[key].layout]))?.[0];\n\n\t\t\treturn images[key].layout;\n\t\t})\n\t);\n\n\tdetections.forEach((page) => {\n\t\tpage.detection.areas = page.detection?.areas?.filter((a) => a?.staves?.middleRhos?.length > 0);\n\t});\n\n\tconst imageURLMap = new Map();\n\tconst collectImage = async (source: SourceImage): Promise => {\n\t\tconst url = await option.onReplaceImage(source);\n\t\timageURLMap.set(source, url);\n\t};\n\n\t// 根据所有页面的宽高比决定全局显示尺寸\n\tsetGlobalPageSize(score, detections, option.outputWidth);\n\n\tasync function createPage(detect, pageIndex) {\n\t\tconst { url, key, layout, enableGauge } = images[pageIndex];\n\n\t\tconst pageKey = sha1(JSON.stringify({ key: key || url, layout, enableGauge }));\n\n\t\tconst cachedPageJson = await option.pageStore.get(pageKey);\n\n\t\tconst omit = !option.renew && ((cachedPageJson && !images[pageIndex].renew) || !detect.detection.areas?.length);\n\n\t\tconst page = (score.pages[pageIndex] =\n\t\t\tomit && cachedPageJson\n\t\t\t\t? starry.recoverJSON(cachedPageJson, starry)\n\t\t\t\t: new starry.Page({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tname: key || (typeof url === 'string' && /https?:\\/\\//.test(url) ? url : null),\n\t\t\t\t\t\t\tsize: 0,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tcrop: {\n\t\t\t\t\t\t\t\tunit: '%',\n\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\twidth: 100,\n\t\t\t\t\t\t\t\theight: 100,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdimensions: detect.sourceSize,\n\t\t\t\t\t\t\tmatrix: [Math.cos(detect.theta), -Math.sin(detect.theta), Math.sin(detect.theta), Math.cos(detect.theta), 0, 0],\n\t\t\t\t\t\t\tinterval: detect.interval,\n\t\t\t\t\t\t\tneedGauge: images[pageIndex].enableGauge,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlayout: detect.detection,\n\t\t\t\t }));\n\n\t\tconst correctCanvas = omit\n\t\t\t? null\n\t\t\t: await shootImageByDetection({\n\t\t\t\t\tscore,\n\t\t\t\t\tpage,\n\t\t\t\t\tpageCanvas: pageCanvasList[pageIndex],\n\t\t\t });\n\n\t\tprogress.increase('layout');\n\n\t\treturn {\n\t\t\tpage,\n\t\t\tomit,\n\t\t\thash: pageKey,\n\t\t\tcorrectCanvas,\n\t\t};\n\t}\n\n\tconst systemsCount = detections.reduce((acc, x) => acc + (x.detection.areas?.length ?? 0), 0);\n\tconst stavesCount = detections.reduce((acc, x) => acc + (x.detection.areas?.reduce?.((a, y) => a + (y.staves?.middleRhos?.length ?? 0), 0) ?? 0), 0);\n\n\tprogress.setTotal('gauge', stavesCount);\n\tprogress.setTotal('mask', stavesCount);\n\tprogress.setTotal('semantic', stavesCount);\n\tprogress.setTotal('brackets', systemsCount);\n\n\tconst allTasks = [];\n\n\tconst omitPages = [];\n\n\tconst t1 = Date.now();\n\n\tlet n_page = 0;\n\n\tfor (const pageIndex of detections.keys()) {\n\t\tconst pageTasks = [];\n\n\t\tconst { page, correctCanvas, omit, hash } = await createPage(detections[pageIndex], pageIndex);\n\n\t\tpageTasks.push(collectImage(page.source.url));\n\t\tpageTasks.push(...page.systems.map((system) => collectImage(system.backgroundImage)));\n\n\t\tlogger.info(`[predictor]: check_cache_pageIndex-${pageIndex} omit: ${omit}`);\n\t\tif (omit) {\n\t\t\tomitPages.push(pageIndex);\n\t\t} else {\n\t\t\tconst staves = page.systems\n\t\t\t\t.map((system, systemIndex) => system.staves.map((staff, staffIndex) => ({ pageIndex, systemIndex, staffIndex, page, system, staff })))\n\t\t\t\t.flat(1);\n\n\t\t\tawait concurrencyTask([\n\t\t\t\t/******************************* 括号检测 start *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!option.processes.includes('brackets')) return;\n\n\t\t\t\t\tconst detection = page.layout;\n\t\t\t\t\tconst interval = page.source.interval;\n\n\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\tconst bracketImages = page.systems.map((system, systemIndex) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\tstaves: { middleRhos, phi1 },\n\t\t\t\t\t\t} = detection.areas[systemIndex];\n\n\t\t\t\t\t\tconst topMid = middleRhos[0];\n\t\t\t\t\t\tconst bottomMid = middleRhos[middleRhos.length - 1];\n\n\t\t\t\t\t\tconst sourceRect = {\n\t\t\t\t\t\t\tx: x + phi1 - 4 * interval,\n\t\t\t\t\t\t\ty: y + topMid - 4 * interval,\n\t\t\t\t\t\t\twidth: 8 * interval,\n\t\t\t\t\t\t\theight: bottomMid - topMid + 8 * interval,\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst OUTPUT_INTERVAL = 8;\n\n\t\t\t\t\t\tconst canvas = new Canvas(OUTPUT_INTERVAL * 8, (sourceRect.height / interval) * OUTPUT_INTERVAL);\n\n\t\t\t\t\t\tconst context = canvas.getContext('2d');\n\t\t\t\t\t\tcontext.drawImage(correctCanvas, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height, 0, 0, canvas.width, canvas.height);\n\n\t\t\t\t\t\t// console.log(pageIndex, systemIndex, JSON.stringify(sourceRect), correctCanvas.width, correctCanvas.height)\n\t\t\t\t\t\t// const pctx = canvas.getContext('2d')\n\t\t\t\t\t\t// pctx.strokeStyle = 'red'\n\t\t\t\t\t\t// pctx.fillStyle = 'rgba(255, 0, 0, 0.2)'\n\t\t\t\t\t\t// pctx.fillRect(sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height)\n\t\t\t\t\t\t// const area = detections[pageIndex].detection.areas[systemIndex]\n\t\t\t\t\t\t// pctx.strokeStyle = 'green'\n\t\t\t\t\t\t// pctx.fillStyle = 'rgba(0, 255, 0, 0.1)'\n\t\t\t\t\t\t// pctx.fillRect(area.x, area.y, area.width, area.height)\n\t\t\t\t\t\t// pctx.fillRect(area.x, area.y, area.width, area.height)\n\t\t\t\t\t\t// require('fs').writeFile(`test--system-${systemIndex}.png`, canvas.toBufferSync('png'), () => {})\n\t\t\t\t\t\t// require('fs-extra').writeFile(`test--brackets-${pageIndex}-${systemIndex}.png`, canvas.toBufferSync('png'))\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\tbuffer: canvas.toBufferSync('png'),\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\tlogger.info(`[predictor]: brackets js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\tconst bracketsRes = await pyClients.predictScoreImages('brackets', { buffers: bracketImages.map((x) => x.buffer) });\n\t\t\t\t\tprogress.increase('brackets', bracketImages.length);\n\n\t\t\t\t\tbracketImages.forEach(({ system }, index) => {\n\t\t\t\t\t\tif (bracketsRes[index]) {\n\t\t\t\t\t\t\tsystem.bracketsAppearance = bracketsRes[index];\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t/******************************* 括号检测 end *************************/\n\n\t\t\t\t/******************************* 文本识别 start *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\tif (!option.processes.includes('text')) return;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t// await require('fs-extra').writeFile(`test--text-location-${pageIndex}.png`, correctCanvas.toBufferSync('png'))\n\t\t\t\t\t\tconst bufferForText = correctCanvas.toBufferSync('png');\n\n\t\t\t\t\t\tconst resultLoc = await pyClients.predictScoreImages('textLoc', [bufferForText]);\n\n\t\t\t\t\t\tconst location = resultLoc[0].filter((box) => box.score > 0);\n\n\t\t\t\t\t\tif (location.length > 0) {\n\t\t\t\t\t\t\tconst [resultOCR] = await pyClients.predictScoreImages('textOcr', {\n\t\t\t\t\t\t\t\tbuffers: [bufferForText],\n\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tpage.assignTexts(resultOCR.areas, resultOCR.imageSize);\n\t\t\t\t\t\t\tpage.assemble();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlogger.info(`[predictor]: text js [pageIndex-${pageIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\tprogress.increase('text');\n\n\t\t\t\t\t\tif (!option.title) {\n\t\t\t\t\t\t\tconst coverTexts: {\n\t\t\t\t\t\t\t\tconfidence: number;\n\t\t\t\t\t\t\t\tfontSize: number;\n\t\t\t\t\t\t\t\tid: string;\n\t\t\t\t\t\t\t\ttext: string;\n\t\t\t\t\t\t\t\ttextType: 'Title' | 'Author';\n\t\t\t\t\t\t\t\ttype: starry.TokenType;\n\t\t\t\t\t\t\t\twidth_: number;\n\t\t\t\t\t\t\t\tx: number;\n\t\t\t\t\t\t\t\ty: number;\n\t\t\t\t\t\t\t}[] = score.pages[0].tokens as any;\n\n\t\t\t\t\t\t\tif (Array.isArray(coverTexts) && coverTexts.length > 0) {\n\t\t\t\t\t\t\t\tconst [titleToken] = coverTexts\n\t\t\t\t\t\t\t\t\t.filter((x) => x.type === starry.TokenType.Text && x.textType === 'Title')\n\t\t\t\t\t\t\t\t\t.sort((a, b) => b.fontSize - a.fontSize);\n\n\t\t\t\t\t\t\t\tif (titleToken) {\n\t\t\t\t\t\t\t\t\tscore.title = titleToken.text;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.error(`[predictor]: text js [pageIndex-${pageIndex}] ${JSON.stringify(err)}`);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t/******************************* 文本识别 end *************************/\n\t\t\t\tasync () => {\n\t\t\t\t\t/******************************* 变形矫正 start *************************/\n\t\t\t\t\tawait batchTask(async () => {\n\t\t\t\t\t\tconst disableGauge = !option.processes.includes('gauge') || images[pageIndex].enableGauge === false;\n\n\t\t\t\t\t\tif (!disableGauge) {\n\t\t\t\t\t\t\tconst gaugeRes = await pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t'gauge',\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tstaves.map(async ({ staffIndex, system }) => {\n\t\t\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\t\t\t\t\t\t\t\t\t\tconst sourceCanvas = await shootStaffImage(system, staffIndex, {\n\t\t\t\t\t\t\t\t\t\t\tpaddingLeft: STAFF_PADDING_LEFT,\n\t\t\t\t\t\t\t\t\t\t\tspec: GAUGE_VISION_SPEC,\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js shoot [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\t\t\t\t\treturn sourceCanvas.toBufferSync('png');\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfor (const [index, { system, staff, pageIndex, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] start..`);\n\t\t\t\t\t\t\t\tawait gaugeStaff({\n\t\t\t\t\t\t\t\t\tpyClients,\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tgaugeImage: gaugeRes[index].image,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: gauge js [page-${pageIndex}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\n\t\t\t\t\t\t\t\tprogress.increase('gauge');\n\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.backgroundImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (const [_, { system, staff, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tawait shootStaffBackgroundImage({\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.backgroundImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\t/******************************* 变形矫正 end *************************/\n\n\t\t\t\t\tawait concurrencyTask([\n\t\t\t\t\t\t/******************************* 降噪 start *************************/\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tif (!option.processes.includes('mask')) return;\n\n\t\t\t\t\t\t\tconst maskRes = await pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t'mask',\n\t\t\t\t\t\t\t\tstaves.map(({ staff }) => staff.backgroundImage as Buffer)\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfor (const [index, { staff, staffIndex }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tawait maskStaff({\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tmaskImage: maskRes[index].image,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlogger.info(`[predictor]: mask js [page-${pageIndex}, ${index}, staff-${staffIndex}] duration: ${Date.now() - startTime}`);\n\t\t\t\t\t\t\t\tprogress.increase('mask');\n\n\t\t\t\t\t\t\t\tpageTasks.push(collectImage(staff.maskImage));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/******************************* 降噪 end *************************/\n\n\t\t\t\t\t\t/******************************* 语义识别 start *************************/\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tif (!option.processes.includes('semantic')) return;\n\n\t\t\t\t\t\t\tconst semanticRes = starry.recoverJSON(\n\t\t\t\t\t\t\t\tawait pyClients.predictScoreImages(\n\t\t\t\t\t\t\t\t\t'semantic',\n\t\t\t\t\t\t\t\t\tstaves.map(({ staff }) => staff.backgroundImage as Buffer)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tstarry\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tstaves.forEach(({ system }) => system.clearTokens());\n\n\t\t\t\t\t\t\tfor (const [index, { staffIndex, system, staff }] of staves.entries()) {\n\t\t\t\t\t\t\t\tconst startTime = Date.now();\n\n\t\t\t\t\t\t\t\tawait semanticStaff({\n\t\t\t\t\t\t\t\t\tscore,\n\t\t\t\t\t\t\t\t\tsystem,\n\t\t\t\t\t\t\t\t\tstaff,\n\t\t\t\t\t\t\t\t\tstaffIndex,\n\t\t\t\t\t\t\t\t\tgraph: semanticRes[index],\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\t\t\t`[predictor]: semantic js [page-${pageIndex}, system-${system.index}, staff-${staff.index}] duration: ${\n\t\t\t\t\t\t\t\t\t\tDate.now() - startTime\n\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tprogress.increase('semantic');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t/******************************* 语义识别 end *************************/\n\t\t\t\t\t]);\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\t++n_page;\n\t\t}\n\n\t\tallTasks.push(\n\t\t\tPromise.all(pageTasks).then(() => {\n\t\t\t\treplacePageImages(page, (src) => imageURLMap.get(src));\n\t\t\t\tlogger.info(`[predictor]: pageStore set: [${pageIndex}]`);\n\t\t\t\treturn option.pageStore.set(hash, JSON.stringify(page));\n\t\t\t})\n\t\t);\n\t}\n\n\tconst t2 = Date.now();\n\n\tawait Promise.all(allTasks);\n\n\tlogger.info(`[predictor]: inferenceStaffLayout: ${score.title}, [${score.systems.length}]`);\n\n\tscore.inferenceStaffLayout();\n\n\tlogger.info(`[predictor]: done: ${score.title}`);\n\n\t// correct semantic ids\n\tscore.assemble();\n\n\tconst t3 = Date.now();\n\n\treturn {\n\t\tscore,\n\t\tomitPages,\n\t\tstat: {\n\t\t\tcost: t3 - t0,\n\t\t\tpagesCost: t2 - t1,\n\t\t\tpages: n_page,\n\t\t},\n\t};\n};\n\nexport const abstractOMRStats = (stats: OMRStat[]): OMRSummary => {\n\tconst { costTotal, pagesCostTotal, pagesTotal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcostTotal: sum.costTotal + stat.cost,\n\t\t\tpagesCostTotal: sum.pagesCostTotal + stat.pagesCost,\n\t\t\tpagesTotal: sum.pagesTotal + stat.pages,\n\t\t}),\n\t\t{ costTotal: 0, pagesCostTotal: 0, pagesTotal: 0 }\n\t);\n\n\treturn {\n\t\tcostTotal,\n\t\tcostPerPage: pagesTotal ? costTotal / pagesTotal : null,\n\t\tpagesTotal,\n\t\tscoreN: stats.length,\n\t};\n};\n","import { EventTerm } from './term';\nimport type { SpartitoMeasure } from './spartitoMeasure';\n\ninterface EventRectification {\n\tid: number;\n\tdivision?: number;\n\tdots?: number;\n}\n\n// Here suppose sum of pvals equal to 1.\nconst multinomial_1 = (pvals: number[]): number => {\n\tconst n = Math.random();\n\n\tlet s = 0;\n\tfor (let i = 0; i < pvals.length; ++i) {\n\t\ts += pvals[i];\n\t\tif (s > n) return i;\n\t}\n\n\treturn pvals.length - 1;\n};\n\nconst looseVector = (ns: number[], factor = 0.9): number[] => {\n\tconst logits = ns.map((n) => Math.log(n) * factor);\n\tconst n2 = logits.map(Math.exp);\n\n\tconst sum = n2.reduce((sum, x) => sum + x, 0);\n\n\treturn n2.map((x) => x / sum);\n};\n\nconst looseEvent = (event: EventTerm): EventTerm => {\n\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return event;\n\n\tconst divisionVector = event.predisposition?.divisionVector ? looseVector(event.predisposition.divisionVector) : null;\n\tconst dotsVector = event.predisposition?.dotsVector ? looseVector(event.predisposition.dotsVector) : null;\n\n\treturn new EventTerm({\n\t\t...event,\n\t\tpredisposition: {\n\t\t\t...event.predisposition,\n\t\t\tdivisionVector,\n\t\t\tdotsVector,\n\t\t},\n\t});\n};\n\nclass MeasureRectification {\n\tevents: EventRectification[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\ttoString(): string {\n\t\treturn this.events\n\t\t\t.map((event) => {\n\t\t\t\tif (!event) return '';\n\n\t\t\t\tconst { division = '', dots = '' } = event;\n\t\t\t\treturn `${division}|${dots}`;\n\t\t\t})\n\t\t\t.join(',');\n\t}\n\n\tstatic default(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tconst division = event.predisposition.divisionVector ? event.division : undefined;\n\t\t\t\tconst dots = event.predisposition.dotsVector ? event.dots : undefined;\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n\n\tstatic roll(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tlet division = undefined;\n\t\t\t\tlet dots = undefined;\n\n\t\t\t\tif (event.predisposition.divisionVector) division = multinomial_1(event.predisposition.divisionVector);\n\n\t\t\t\tif (event.predisposition.dotsVector) dots = multinomial_1(event.predisposition.dotsVector);\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n}\n\nconst genMeasureRectifications = function* (measure: SpartitoMeasure): Generator {\n\tconst keys = new Set();\n\n\tconst origin = MeasureRectification.default(measure.events);\n\tkeys.add(origin.toString());\n\n\tyield origin;\n\n\tlet stale = 0;\n\tlet events = measure.events;\n\n\twhile (stale < 100) {\n\t\tif (stale && stale % 10 === 0) events = events.map(looseEvent);\n\n\t\tconst rectification = MeasureRectification.roll(events);\n\t\tconst key = rectification.toString();\n\n\t\tif (keys.has(key)) {\n\t\t\t++stale;\n\t\t\tcontinue;\n\t\t}\n\n\t\tstale = 0;\n\n\t\tkeys.add(key);\n\t\tyield rectification;\n\t}\n};\n\nexport { MeasureRectification, genMeasureRectifications };\n","import { WeakLRUCache } from 'weak-lru-cache';\n\nimport { RegulationSolution, SpartitoMeasure } from '../../src/starry';\n\nconst lruCache = new WeakLRUCache();\n\ninterface SolutionStore {\n\tget: (key: string) => Promise;\n\tset: (key: string, val: RegulationSolution) => Promise;\n\tbatchGet: (keys: string[]) => Promise;\n}\n\n// 默认store\nconst DefaultSolutionStore: SolutionStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as RegulationSolution;\n\t},\n\tasync set(key: string, val: RegulationSolution) {\n\t\tlruCache.setValue(key, val);\n\t},\n\tasync batchGet(keys: string[]) {\n\t\treturn keys.map((key) => lruCache.getValue(key) as RegulationSolution);\n\t},\n};\n\nconst enum MeasureStatus {\n\tDiscard = -1,\n\tSolved = 0,\n\tIssue = 1,\n\tFatal = 2,\n}\n\ninterface IssueMeasure {\n\tscoreId: string;\n\tmeasureIndex: number;\n\tmeasure: SpartitoMeasure;\n\tstatus: MeasureStatus;\n}\n\ntype SaveIssueMeasure = (data: Omit) => void;\n\nexport { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure };\n","import * as starry from '../../src/starry';\nimport { Logger } from './ZeroClient';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure, MeasureStatus } from './store';\n\ninterface BeadRegulationCounting {\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface RegulationBeadStat {\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tmeasures: BeadRegulationCounting;\n\tqualityScore: number;\n}\n\ninterface RegulationBeadSummary {\n\tscoreN: number;\n\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tcostPerMeasure: number | null; // in milliseconds\n\tcostPerTime: number | null; // in milliseconds\n\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface ProgressInfo {\n\tpass: number;\n\tremaining: number;\n\ttotal: number;\n}\n\ninterface RegulateBeadOption {\n\tlogger?: Logger;\n\tpickers: starry.BeadPicker[];\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tfreshOnly?: boolean;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n\tonProgress?: (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => void;\n\tonPassStart?: (pass: number, conditionName: string, pendingCount: number) => void;\n}\n\ninterface MeasureReord {\n\torigin: starry.SpartitoMeasure;\n\tcurrent: starry.SpartitoMeasure;\n\tevaluation?: starry.MeasureEvaluation;\n\tbaseQuality: number;\n\tpicker: starry.BeadPicker;\n}\n\ninterface BeadSolverOptions {\n\tstopLoss: number;\n\tquotaMax: number;\n\tquotaFactor: number;\n\tptFactor: number;\n}\n\nenum PendingCondition {\n\tErrorOnly,\n\tNotFine,\n\tImperfect,\n}\n\nconst isPending = (evaluation: starry.MeasureEvaluation, condition: PendingCondition) => {\n\tswitch (condition) {\n\t\tcase PendingCondition.ErrorOnly:\n\t\t\treturn evaluation.error;\n\n\t\tcase PendingCondition.Imperfect:\n\t\t\treturn !evaluation.perfect;\n\t}\n\n\treturn !evaluation.fine;\n};\n\ntype OnUpdate = (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean) => void;\n\nconst solveMeasureRecords = async (\n\trecords: MeasureReord[],\n\tonUpdate: OnUpdate,\n\tstdout: NodeJS.WritableStream | null,\n\toptions: Partial,\n\tpendingCondition: PendingCondition = PendingCondition.NotFine,\n\tpass: number = 0,\n\tonProgress?: RegulateBeadOption['onProgress']\n): Promise => {\n\tconst pendingRecords = records.filter(({ evaluation }) => !evaluation || isPending(evaluation, pendingCondition));\n\tstdout?.write('.'.repeat(pendingRecords.length));\n\tstdout?.write('\\b'.repeat(pendingRecords.length));\n\n\tconst total = pendingRecords.length;\n\tlet done = 0;\n\n\tfor (const record of pendingRecords) {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tconst solution = await starry.beadSolver.solveMeasure(measure, { picker: record.picker, ...options });\n\t\tmeasure.applySolution(solution);\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better =\n\t\t\t!record.evaluation ||\n\t\t\tevaluation.fine > record.evaluation.fine ||\n\t\t\t(evaluation.qualityScore > record.evaluation.qualityScore && evaluation.fine === record.evaluation.fine);\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\t\t}\n\n\t\tonUpdate(record.current, evaluation, better);\n\n\t\tdone++;\n\t\tonProgress?.(record.current, evaluation, better, { pass, remaining: total - done, total });\n\t}\n\n\tif (pendingRecords.length) stdout?.write('\\n');\n\n\treturn pendingRecords.length;\n};\n\nconst regulateWithBeadSolver = async (\n\tscore: starry.Score,\n\t{ logger, pickers, solutionStore = DefaultSolutionStore, ignoreCache, freshOnly, onSaveIssueMeasure, onProgress, onPassStart }: RegulateBeadOption\n): Promise => {\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\tlogger?.info(`[regulateWithBeadSolver] begin, measure total: ${spartito.measures.length}.`, ignoreCache ? 'ignoreCache' : '', freshOnly ? 'freshOnly' : '');\n\n\tconst records = spartito.measures\n\t\t.filter((measure) => measure.events?.length && !measure.patched)\n\t\t.map(\n\t\t\t(measure) =>\n\t\t\t\t({\n\t\t\t\t\torigin: measure.deepCopy(),\n\t\t\t\t\tcurrent: measure,\n\t\t\t\t\tevaluation: undefined,\n\t\t\t\t\tbaseQuality: 0,\n\t\t\t\t} as MeasureReord)\n\t\t);\n\n\t// rectify time signature\n\tfor (const measure of spartito.measures.filter((measure) => measure.events?.length)) {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > measure.events.length + 1);\n\t\tif (picker) await starry.beadSolver.estimateMeasure(measure, picker);\n\t}\n\tspartito.rectifyTimeSignatures(logger as any);\n\n\t// zero pickers' cost\n\tpickers.forEach((picker) => (picker.cost = 0));\n\n\tconst counting = {\n\t\tcached: 0,\n\t\tsimple: 0,\n\t\tcomputed: 0,\n\t\ttryTimes: 0,\n\t\tsolved: 0,\n\t\tissue: 0,\n\t\tfatal: 0,\n\t};\n\n\tlogger?.info(`[regulateWithBeadSolver] measures estimation finished.`);\n\n\t// apply solutions\n\tif (solutionStore && !ignoreCache)\n\t\tfor (const record of records) {\n\t\t\tconst solution = await solutionStore.get(record.origin.regulationHash0);\n\t\t\tif (solution) {\n\t\t\t\trecord.current.applySolution(solution);\n\t\t\t\t++counting.cached;\n\n\t\t\t\trecord.evaluation = starry.evaluateMeasure(record.current);\n\t\t\t\trecord.baseQuality = record.evaluation.qualityScore;\n\t\t\t}\n\t\t}\n\n\tlogger?.info('[regulateWithBeadSolver]', `${counting.cached}/${records.length}`, 'solutions loaded.');\n\n\tconst stdout = logger ? null : process.stdout;\n\tif (counting.cached) stdout?.write(`${counting.cached}c`);\n\n\trecords.forEach((record) => {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > record.current.events.length + 1);\n\t\tif (!picker) {\n\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] size out of range:`, record.current.events.length);\n\t\t} else record.picker = picker;\n\t});\n\n\tconst pendingRecords = records.filter((record) => record.picker && (!record.evaluation || (!record.evaluation.fine && !freshOnly))) as (MeasureReord & {\n\t\tevaluation: starry.MeasureEvaluation;\n\t})[];\n\n\t// solve by simple policy\n\tpendingRecords.forEach((record) => {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tmeasure.regulate({ policy: 'simple' });\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better = !record.evaluation || evaluation.qualityScore > record.evaluation.qualityScore;\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\n\t\t\tif (evaluation.perfect) {\n\t\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] regulated by simple policy.`);\n\t\t\t\t++counting.simple;\n\t\t\t}\n\t\t}\n\t});\n\tcounting.computed = pendingRecords.length - counting.simple;\n\n\tif (counting.simple) stdout?.write(`${counting.simple}s`);\n\n\tconst onUpdate = (measure, evaluation, better) => {\n\t\tlogger?.info(\n\t\t\t`[regulateWithBeadSolver] measure[${measure.measureIndex}/${spartito.measures.length}] regulated${\n\t\t\t\tbetter ? '+' : '-'\n\t\t\t}: ${evaluation.qualityScore.toFixed(3)}, ${evaluation.fine ? 'solved' : evaluation.error ? 'error' : 'issue'}, ${measure.regulationHash}`\n\t\t);\n\n\t\tstdout?.write(`\\x1b[${evaluation.fine ? '32' : evaluation.error ? '31' : '33'}m${better ? '+' : '-'}\\x1b[0m`);\n\t};\n\n\t// Global progress: total = all measures, remaining = non-fine measures across all passes\n\tconst totalMeasures = spartito.measures.length;\n\tconst computeRemaining = () => pendingRecords.filter((r) => !r.evaluation?.fine).length;\n\tconst wrappedOnProgress = onProgress\n\t\t? (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => {\n\t\t\t\tonProgress(measure, evaluation, better, { pass: progress.pass, remaining: computeRemaining(), total: totalMeasures });\n\t\t }\n\t\t: undefined;\n\n\tonPassStart?.(1, 'Imperfect', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.05, quotaMax: 200, quotaFactor: 3, ptFactor: 1 },\n\t\tPendingCondition.Imperfect,\n\t\t1,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(2, 'NotFine', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 20, ptFactor: 1.6 },\n\t\tPendingCondition.NotFine,\n\t\t2,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(3, 'ErrorOnly', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 40, ptFactor: 3 },\n\t\tPendingCondition.ErrorOnly,\n\t\t3,\n\t\twrappedOnProgress\n\t);\n\n\tpendingRecords.forEach(({ evaluation, baseQuality, current, origin }) => {\n\t\tif (evaluation.fine) ++counting.solved;\n\t\telse if (evaluation.error) ++counting.fatal;\n\t\telse ++counting.issue;\n\n\t\tif (evaluation.qualityScore > baseQuality || !baseQuality) {\n\t\t\tsolutionStore.set(origin.regulationHash0, { ...current.asSolution(origin), priority: -current?.solutionStat?.loss! });\n\t\t\tif (current.regulationHash !== origin.regulationHash0)\n\t\t\t\tsolutionStore.set(current.regulationHash, { ...current.asSolution(), priority: -current?.solutionStat?.loss! });\n\t\t\t//console.log('better:', current.measureIndex, evaluation.qualityScore, baseQuality);\n\t\t}\n\n\t\tif (!evaluation.fine) {\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: current.measureIndex,\n\t\t\t\tmeasure: new starry.EditableMeasure(current),\n\t\t\t\tstatus: evaluation.error ? MeasureStatus.Fatal : MeasureStatus.Issue,\n\t\t\t});\n\t\t}\n\t});\n\n\tconst t1 = Date.now();\n\tconst pickerCost = pickers.reduce((cost, picker) => cost + picker.cost, 0);\n\n\tconst qualityScore = spartito.qualityScore;\n\tconst totalCost = t1 - t0;\n\n\tlogger?.info('[regulateWithBeadSolver] done in ', totalCost, 'ms, qualityScore:', qualityScore);\n\n\t// zero 'cached' statistics for freshOnly mode\n\tif (freshOnly) counting.cached = 0;\n\n\treturn {\n\t\ttotalCost: t1 - t0,\n\t\tpickerCost,\n\t\tmeasures: counting,\n\t\tqualityScore,\n\t};\n};\n\nconst abstractRegulationBeadStats = (stats: RegulationBeadStat[]): RegulationBeadSummary => {\n\tconst { totalCost, pickerCost, measureN, timeN } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\ttotalCost: sum.totalCost + stat.totalCost,\n\t\t\tpickerCost: sum.pickerCost + stat.pickerCost,\n\t\t\tmeasureN: sum.measureN + stat.measures.computed,\n\t\t\ttimeN: sum.timeN + stat.measures.tryTimes,\n\t\t}),\n\t\t{\n\t\t\ttotalCost: 0,\n\t\t\tpickerCost: 0,\n\t\t\tmeasureN: 0,\n\t\t\ttimeN: 0,\n\t\t}\n\t);\n\n\tconst costPerMeasure = measureN > 0 ? totalCost / measureN : null;\n\tconst costPerTime = timeN > 0 ? totalCost / timeN : null;\n\n\tconst { cached, simple, computed, tryTimes, solved, issue, fatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.measures.cached,\n\t\t\tsimple: sum.simple + stat.measures.simple,\n\t\t\tcomputed: sum.computed + stat.measures.computed,\n\t\t\ttryTimes: sum.tryTimes + stat.measures.tryTimes,\n\t\t\tsolved: sum.solved + stat.measures.solved,\n\t\t\tissue: sum.issue + stat.measures.issue,\n\t\t\tfatal: sum.fatal + stat.measures.fatal,\n\t\t}),\n\t\t{ cached: 0, simple: 0, computed: 0, tryTimes: 0, solved: 0, issue: 0, fatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\ttotalCost,\n\t\tpickerCost,\n\t\tcostPerMeasure,\n\t\tcostPerTime,\n\t\tcached,\n\t\tsimple,\n\t\tcomputed,\n\t\ttryTimes,\n\t\tsolved,\n\t\tissue,\n\t\tfatal,\n\t};\n};\n\nexport { regulateWithBeadSolver, abstractRegulationBeadStats, RegulationBeadStat, ProgressInfo };\n","import * as starry from '../../src/starry';\nimport { PyClients } from './predictors';\nimport { Logger } from './ZeroClient';\nimport { SpartitoMeasure, EditableMeasure, evaluateMeasure } from '../../src/starry';\nimport { EquationPolicy } from '../../src/starry/spartitoMeasure';\nimport { genMeasureRectifications } from '../../src/starry/measureRectification';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure } from './store';\nexport * from './regulationBead';\n\nglobalThis.btoa = globalThis.btoa || ((str) => Buffer.from(str, 'binary').toString('base64'));\n\nconst RECTIFICATION_SEARCH_ITERATIONS = parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS || '30');\nconst BASE_QUOTA_FACTOR = parseInt(process.env.BASE_QUOTA_FACTOR || '40');\nconst RECTIFICATION_QUOTA_FACTOR = parseInt(process.env.RECTIFICATION_QUOTA_FACTOR || '80');\n\nconst MATRIXH_INTERPOLATION_K = 0.9;\n\ninterface SolveMeasureOptions {\n\tsolver?: (...args: any[]) => any;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tlogger?: Logger;\n}\n\nconst computeQuota = (n: number, factor: number, limit: number) =>\n\tMath.min(Math.ceil((n + 1) * factor * Math.log(n + 2)), Math.ceil(limit * Math.min(1, (24 / (n + 1)) ** 2)));\n\ninterface BaseRegulationStat {\n\tcached: number;\n\tcomputed: number;\n\tsolved: number;\n}\n\nasync function solveMeasures(\n\tmeasures: SpartitoMeasure[],\n\t{ solver, quotaMax = 1000, quotaFactor = BASE_QUOTA_FACTOR, solutionStore = DefaultSolutionStore, ignoreCache = false, logger }: SolveMeasureOptions = {}\n): Promise {\n\tlet cached = 0;\n\tlet solved = 0;\n\n\tlogger?.info(`[solveMeasures] begin, measure total: ${measures.length}.`);\n\n\tawait Promise.all(\n\t\tmeasures.map(async (measure) => {\n\t\t\tif (!ignoreCache) {\n\t\t\t\tconst solution = await solutionStore.get(measure.regulationHash);\n\t\t\t\tif (solution) {\n\t\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\t\t++cached;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst quota = computeQuota(measure.events.length, quotaFactor, quotaMax);\n\n\t\t\tawait measure.regulate({\n\t\t\t\tpolicy: 'equations',\n\t\t\t\tquota,\n\t\t\t\tsolver,\n\t\t\t});\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tif (!stat.error) solutionStore.set(measure.regulationHash0, { ...measure.asSolution(), priority: -measure?.solutionStat?.loss! });\n\t\t\tif (stat.perfect) ++solved;\n\n\t\t\tlogger?.info(\n\t\t\t\t`[solveMeasures] measure[${measure.measureIndex}/${measures.length}] regulated: ${stat.perfect ? 'solved' : stat.error ? 'error' : 'issue'}, ${\n\t\t\t\t\tmeasure.regulationHash\n\t\t\t\t}`\n\t\t\t);\n\t\t})\n\t);\n\n\tlogger?.info(`[solveMeasures] ${cached}/${measures.length} cache hit, ${solved} solved.`);\n\n\treturn {\n\t\tcached,\n\t\tcomputed: measures.length - cached,\n\t\tsolved,\n\t};\n}\n\nconst solveMeasuresWithRectifications = async (\n\tmeasure: SpartitoMeasure,\n\t{ solver, quotaMax = 4000 }: SolveMeasureOptions\n): Promise => {\n\tlet best = evaluateMeasure(measure);\n\tlet bestSolution: starry.RegulationSolution = measure.asSolution();\n\tconst quota = computeQuota(measure.events.length, RECTIFICATION_QUOTA_FACTOR, quotaMax);\n\tlet n_rec = 0;\n\n\t// @ts-ignore\n\tfor (const rec of genMeasureRectifications(measure)) {\n\t\tconst solution = await EquationPolicy.regulateMeasureWithRectification(measure, rec, { solver, quota });\n\n\t\tconst testMeasure = measure.deepCopy() as SpartitoMeasure;\n\t\ttestMeasure.applySolution(solution);\n\t\tconst result = evaluateMeasure(testMeasure);\n\n\t\tif (\n\t\t\tresult.perfect > best.perfect ||\n\t\t\tresult.error < best.error ||\n\t\t\t(!result.error && result.perfect >= best.perfect && solution.priority! > bestSolution.priority!)\n\t\t) {\n\t\t\tbest = result;\n\t\t\tbestSolution = solution;\n\t\t}\n\n\t\tif (result.perfect) break;\n\n\t\t++n_rec;\n\t\tif (n_rec > RECTIFICATION_SEARCH_ITERATIONS) break;\n\t}\n\n\treturn bestSolution;\n};\n\ninterface RegulateWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateMaybeWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients?: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateSimpleOption {\n\tsolutionStore: SolutionStore;\n\tsolver: (...args: any[]) => any;\n\tlogger?: Logger;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n}\n\ninterface TopoRegulationStat {\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\nasync function doRegulateWithTopo(\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateWithTopoOption\n): Promise {\n\tpyClients.logger.info(`[RegulateWithTopo] regulate score: ${score.title}, measures: ${score.spartito!.measures.length}`);\n\n\tconst issueMeasures = score.spartito!.measures.filter((measure) => {\n\t\tconst stat = evaluateMeasure(measure);\n\t\treturn !stat.perfect;\n\t});\n\tpyClients.logger.info(`[RegulateWithTopo] basic issues: ${issueMeasures.length}`);\n\n\tif (issueMeasures.length === 0) {\n\t\treturn {\n\t\t\tsolved: 0,\n\t\t\tissue: 0,\n\t\t\tfatal: 0,\n\t\t};\n\t}\n\n\tconst clusters = ([] as starry.EventCluster[]).concat(...issueMeasures.map((measure) => measure.createClusters()));\n\tconst results = await pyClients.predictScoreImages('topo', { clusters });\n\tconsole.assert(results.length === clusters.length, 'prediction number mismatch:', clusters.length, results.length);\n\n\tclusters.forEach((cluster, index) => {\n\t\tconst result = results[index];\n\t\tconsole.assert(result, 'no result for cluster:', cluster.index);\n\n\t\tcluster.assignPrediction(result);\n\t});\n\n\tissueMeasures.forEach((measure) => {\n\t\tconst cs = clusters.filter((c) => c.index === measure.measureIndex);\n\t\tmeasure.applyClusters(cs);\n\n\t\t// intepolate matrixH\n\t\tconst { matrixH } = EquationPolicy.estiamteMeasure(measure);\n\t\tmatrixH.forEach((row, i) =>\n\t\t\trow.forEach((v, j) => {\n\t\t\t\tmeasure.matrixH[i][j] = measure.matrixH[i][j] * MATRIXH_INTERPOLATION_K + v * (1 - MATRIXH_INTERPOLATION_K);\n\t\t\t})\n\t\t);\n\t});\n\n\tconst solvedIndices: number[] = [];\n\tconst errorIndices: number[] = [];\n\n\t// rectification search\n\tawait Promise.all(\n\t\tissueMeasures.map(async (measure) => {\n\t\t\tconst hash = measure.regulationHash0;\n\t\t\tconst solution = await solveMeasuresWithRectifications(measure, { solver });\n\t\t\tif (solution) {\n\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\tsolutionStore.set(hash, solution);\n\t\t\t\tsolutionStore.set(measure.regulationHash, measure.asSolution());\n\t\t\t\tpyClients.logger.info(`[RegulateWithTopo] solutionStore set: ${measure.measureIndex}, ${hash}, ${measure.regulationHash}`);\n\t\t\t}\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\tmeasure: new EditableMeasure(measure),\n\t\t\t\tstatus: stat.error ? 2 : 1,\n\t\t\t});\n\t\t\tif (stat.perfect) solvedIndices.push(measure.measureIndex);\n\t\t\telse if (stat.error) errorIndices.push(measure.measureIndex);\n\t\t})\n\t);\n\n\tconst n_issues = issueMeasures.length - solvedIndices.length - errorIndices.length;\n\tpyClients.logger.info(`[RegulateWithTopo] score: ${score.title}, solved/issue/fatal: ${solvedIndices.length}/${n_issues}/${errorIndices.length}`);\n\tif (solvedIndices.length) pyClients.logger.info(`[RegulateWithTopo] solved measures: ${solvedIndices.join(', ')}`);\n\tif (errorIndices.length) pyClients.logger.info(`[RegulateWithTopo] error measures: ${errorIndices.join(', ')}`);\n\n\treturn {\n\t\tsolved: solvedIndices.length,\n\t\tissue: n_issues,\n\t\tfatal: errorIndices.length,\n\t};\n}\n\ninterface RegulationStat {\n\tbaseCost: number; // in milliseconds\n\ttopoCost: number; // in milliseconds\n\tbaseMeasures: BaseRegulationStat;\n\ttopoMeasures?: TopoRegulationStat;\n\tqualityScore: number;\n}\n\nconst doRegulate = async (\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateMaybeWithTopoOption\n): Promise => {\n\tpyClients?.logger?.info(`[doRegulate] score: ${score.title}`);\n\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\n\tconst baseMeasures = await solveMeasures(spartito.measures, { solver, quotaMax: 1000, solutionStore, logger: pyClients?.logger });\n\n\tconst t1 = Date.now();\n\n\tconst topoMeasures = pyClients ? await doRegulateWithTopo(score, { pyClients, solver, solutionStore, onSaveIssueMeasure }) : undefined;\n\n\tconst t2 = Date.now();\n\n\treturn {\n\t\tbaseCost: t1 - t0,\n\t\ttopoCost: t2 - t1,\n\t\tbaseMeasures,\n\t\ttopoMeasures,\n\t\tqualityScore: spartito.qualityScore,\n\t};\n};\n\nconst doSimpleRegulate = async (\n\tscore: starry.Score,\n\t{ solver, solutionStore = DefaultSolutionStore, logger, quotaMax = 240, quotaFactor = 16 }: RegulateSimpleOption\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\tconst measures = spartito.measures.filter((measure) => !measure.regulated);\n\n\tawait solveMeasures(measures, { solver, quotaMax, quotaFactor, solutionStore, logger });\n\n\tconsole.assert(score.spartito?.regulated, 'doSimpleRegulate: regulation incomplete:', spartito.measures.filter((measure) => !measure.regulated).length);\n};\n\nconst evaluateScoreQuality = async (score: starry.Score, options: RegulateSimpleOption): Promise => {\n\tif (!score.spartito?.regulated) await doSimpleRegulate(score, options);\n\n\treturn score.spartito!.regulated ? score.spartito!.qualityScore : null;\n};\n\ninterface RegulationSummary {\n\tscoreN: number;\n\n\tbaseCostTotal: number; // in milliseconds\n\ttopoCostTotal: number; // in milliseconds\n\tbaseCostPerMeasure: number | null; // in milliseconds\n\ttopoCostPerMeasure: number | null; // in milliseconds\n\n\tcached: number;\n\tbaseComputed: number;\n\tbaseSolved: number;\n\ttopoSolved: number;\n\ttopoIssue: number;\n\ttopoFatal: number;\n}\n\nconst abstractRegulationStats = (stats: RegulationStat[]): RegulationSummary => {\n\tconst { baseCostTotal, topoCostTotal, baseMeasures, topoMeasures } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tbaseCostTotal: sum.baseCostTotal + stat.baseCost,\n\t\t\ttopoCostTotal: sum.topoCostTotal + stat.topoCost,\n\t\t\tbaseMeasures: sum.baseMeasures + stat.baseMeasures.computed,\n\t\t\ttopoMeasures: sum.topoMeasures + (stat.topoMeasures!.solved + stat.topoMeasures!.issue + stat.topoMeasures!.fatal),\n\t\t}),\n\t\t{\n\t\t\tbaseCostTotal: 0,\n\t\t\ttopoCostTotal: 0,\n\t\t\tbaseMeasures: 0,\n\t\t\ttopoMeasures: 0,\n\t\t}\n\t);\n\n\tconst baseCostPerMeasure = baseMeasures > 0 ? baseCostTotal / baseMeasures : null;\n\tconst topoCostPerMeasure = topoMeasures > 0 ? topoCostTotal / topoMeasures : null;\n\n\tconst { cached, baseComputed, baseSolved, topoSolved, topoIssue, topoFatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.baseMeasures.cached,\n\t\t\tbaseComputed: sum.baseComputed + stat.baseMeasures.computed,\n\t\t\tbaseSolved: sum.baseSolved + stat.baseMeasures.solved,\n\t\t\ttopoSolved: sum.topoSolved + stat.topoMeasures!.solved,\n\t\t\ttopoIssue: sum.topoIssue + stat.topoMeasures!.issue,\n\t\t\ttopoFatal: sum.topoFatal + stat.topoMeasures!.fatal,\n\t\t}),\n\t\t{ cached: 0, baseComputed: 0, baseSolved: 0, topoSolved: 0, topoIssue: 0, topoFatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\tbaseCostTotal,\n\t\ttopoCostTotal,\n\t\tbaseCostPerMeasure,\n\t\ttopoCostPerMeasure,\n\t\tcached,\n\t\tbaseComputed,\n\t\tbaseSolved,\n\t\ttopoSolved,\n\t\ttopoIssue,\n\t\ttopoFatal,\n\t};\n};\n\nexport { doRegulate, doSimpleRegulate, evaluateScoreQuality, abstractRegulationStats };\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T15:16:28.868Z`, '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;');\nimport '../../libs/browserComponents';\n\nexport * from '../../../src/isomorphic/converter';\nexport * as starry from '../../../src/starry';\nexport * from '../../libs/predictors';\nexport * from '../../libs/predictPages';\nexport * from '../../libs/regulation';\nexport * from '../../libs/store';\nexport * from '../../libs/util';\n"],"names":["PageLayoutMethod","TextType","SemanticType","globalThis","btoa","str","Buffer","from","toString","atob","NOTEHEAD_WIDTHS","NoteheadS0","NoteheadS1","NoteheadS2","glyphCenters","x","zero","y","one","two","three","four","five","six","seven","eight","nine","f","m","p","r","s","z","SYSTEM_SEMANTIC_TYPES","BarMeasure","vline_BarMeasure","vline_BarTerminal","vline_BarSegment","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","st","CONFLICTION_GROUPS","Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","ScriptStaccatissimo","TimesigZero","TimesigOne","TimesigTwo","TimesigThree","TimesigFour","TimesigFive","TimesigSix","TimesigSeven","TimesigEight","TimesigNine","Rest0","Rest1","Rest2","Rest3","Rest4","Rest5","Rest6","Rest0W","RestM1","SignInterval","SignLined","BeamLeft","BeamContinue","BeamRight","STAMP_SEMANTICS","ClefG","ClefF","ClefC","Dot","AccNatural","AccSharp","AccDoublesharp","AccFlat","AccFlatflat","TimesigC44","TimesigC22","OctaveShift8","OctaveShift0","n","ScriptFermata","ScriptShortFermata","ScriptSforzato","ScriptStaccato","ScriptTurn","ScriptTrill","ScriptSegno","ScriptCoda","ScriptArpeggio","ScriptPrall","ScriptMordent","ScriptMarcato","ScriptTenuto","ScriptPortato","PedalStar","PedalPed","hashSemanticPoint","systemIndex","staffIndex","point","Math","round","source","semantic","hash","sha1","array","slice","id","String","fromCharCode","substring","hashPageSemanticPoint","pageName","TokenType","tt","TokenTypes","Object","values","TokenClefs","filter","t","test","TokenTimesigs","TokenTimesigsC","TokenTimesigsN","TokenOctshifts","TokenNumbers","TokenAccidentals","TokenNoteheads","TokenBareNoteheads","TokenDirectionalNoteheads","TokenRests","TokenFlags","TokenVolta","TokenDynamics","TokenScripts","TokenPedals","TokenDots","DotDot","TokenArcs","SlurBegin","SlurEnd","TieBegin","TieEnd","TokenBeams","TokenWedges","TokenAccessories","TokenDirectionless","TokenGlyphs","TOKEN_Y_ROUND","forEach","TOKEN_Y_FIXED","Token","constructor","data","assign","this","typeId","type","split","reverse","isPredicted","Number","isFinite","confidence","isNotehead","includes","isContexted","isAccessory","division","NoteheadS1stemU","NoteheadS1stemD","NoteheadS2stemU","NoteheadS2stemD","Flag3","Flag4","Flag5","Flag6","Flag7","Flag8","dots","direction","width","left","right","voiceIndices","voice","Array","floor","log2","fill","reduce","indices","_","i","className","TextToken","super","width_","value","recoverJSON","json","classDict","JSON","stringify","parse","__prototype","Class","fields","deepCopy","o","dict","Map","get","isArray","result","set","e","push","entries","key","setPrototypeOf","__proto__","SimpleClass","toJSON","cls","serializedKeys","blackKeys","keys","pick","LayoutType","spreadMeasureSeq","seq","Ordinary","concat","map","layout","serialize","seqToCode","withBrackets","code","inRange","length","SingleMLayout","measure","undefined","BlockMLayout","trimSeq","seq2","sub","seq3","fromSeq","VoltaMLayout","bodySeq","body","alternates","alternateSeqs","lastAlternateSeq","Conservative","Full","times","Once","console","warn","join","ABAMLayout","seqA","main","seqA_","seqB","rest","parser","k","v","l","$V0","$V1","$V2","$V3","$V4","$V5","$V6","$V7","$V8","$V9","$Va","trace","yy","symbols_","error","start_symbol","measure_layout","EOF","index_wise_measure_layout","segment_wise_measure_layout","iw_sequence","iw_item","range","UNSIGNED","single","iw_block_item","iw_volta","iw_aba","iw_block","iw_optional_alternates","iw_alternates","sw_sequence","sw_item","segment","sw_block_item","sw_volta","sw_aba","sw_block","sw_optional_alternates","sw_alternates","$accept","$end","terminals_","productions_","performAction","yytext","yyleng","yylineno","yystate","$$","_$","$0","$","root","blockLayout","singleLayout","voltaBlock","abaBlock","table","defaultActions","parseError","recoverable","Error","input","self","stack","vstack","lstack","args","call","arguments","lexer","create","sharedState","prototype","hasOwnProperty","setInput","yylloc","yyloc","ranges","options","getPrototypeOf","symbol","state","action","len","newState","expected","lex","token","yyval","errStr","showPosition","text","match","line","loc","first_line","last_line","first_column","last_column","apply","items","item","start","end","index","speard","it","serializeSeq","_input","_more","_backtrack","done","matched","conditionStack","offset","ch","unput","lines","substr","oldLines","more","reject","backtrack_lexer","less","pastInput","past","replace","upcomingInput","next","pre","c","test_match","indexed_rule","backup","matches","tempMatch","rules","_currentRules","flex","begin","condition","popState","pop","conditions","topState","abs","pushState","stateStackSize","yy_","$avoiding_name_collisions","YY_START","INITIAL","inclusive","Parser","grammar$1","StaffGroupType","StaffConjunctionType","singleGroup","Default","staff","BOUNDS_TO_GROUPTYPE","Brace","Bracket","Square","CONJUNCTIONS_MAP","Blank","Solid","Dashed","randomB64","random","makeGroupsFromRaw","parent","remains","word","shift","bound","group","level","subs","grand","every","groupHead","groupTail","groupDict","groupKey","StaffLayout","raw","ids","Set","prefix","name","has","makeUniqueName","add","staffIds","conjunctions","conjunction","leftBounds","rightBounds","groups","indexOf","maskCache","stavesCount","partGroups","grands","g","some","standaloneGroups","collect","conjunctionBetween","upStaff","downStaff","con","min","makeMaskLayout","mask","nextId","partialMaskCode","bits","withIds","staffStatus","status","joinGroup","subStr","pair","Boolean","partial","inner","bracketCode","$Vb","$Vc","staff_layout","seq_id","seq_br","seq_con","bound_left","bound_right","bound_lefts","bound_rights","ID","seq_bl","Seq","tip","bl","br","Item","grammar","parseCode","DummyLogger","debug","groupCollapsed","groupEnd","info","assert","roundNumber","precision","Infinity","max","distance2D","p1","p2","dx","dy","sqrt","gcd","a","b","isInteger","frac","numerator","denominator","reducedFraction","d","printFraction","fractionMul","fraction","segmentPoints","points","axis","sorted","sort","seg","lastP","segments","filterWeekPoints","rests","find","weeks","solveOverlapping","pset","xClusters","clusters","ps","delete","GROUP_N_TO_PITCH","noteToPitch","note","alter","gn","mod7","argmax","WHOLE_DURATION","AccessoryDirection","GraceType","StemBeam","TremoloLink","GlissandoStyle","ArpeggioStyle","Term","EventTerm","space","tick","duration","term","accessories","pivotX","alignedTick","grace","mainDuration","multiplier","timeWarp","divider","prior","fullMeasureRest","tipX","tipY","ys","tremoloCatcher","tremoloLink","Catcher","scaleChord","pitches","pitch","zeroHolder","ContextType","ContextedTerm","Token.TokenClefs","tokenType","Clef","KeyAcc","Acc","Token.TokenOctshifts","OctaveShift","Token.TokenTimesigsC","TimeSignatureC","Token.TokenTimesigsN","TimeSignatureN","staffLevel","clef","KeyNatural","KeySharp","KeyFlat","octaveShift","OctaveShift8va","OctaveShift8vb","number","MarkTerm","MUSIC_NOTES","fromCodePoint","TempoTerm","fromNumeralText","findIndex","beats","durationMagnitude","den","dot","bpm","isValid","GlyphTerm","TextTerm","LyricTerm","CommandTerm","ChordmodeTerm","BEAM_STATUS","Open","Continue","Close","evaluateMeasure","regulated","eventMap","events","validEvents","voices","flat","warpedEvents","warps","irregularWarps","fractionalWarp","tickSum","eventN","event","tickOverlapped","complicatedTimewarp","size","literalDuration","timeSignature","sigDuration","doubtfulTimesig","inVoiceEvents","corruptedVoiceEvent","overranged","over","overDuration","graceInVoice","graceN","graceDominant","irregularTick","beamBroken","broken","ei","beam","spaceTime","surplusTime","eventDuration","sum","nullEvents","predisposition","fakeP","fakeEvents","voiceRugged","es","tickTwist","tickRatesInStaves","rate","perfect","estimatedDuration","fine","expectDuration","durationRate","qualityScore","patched","spaceLoss","tanh","irregularWarpsN","SemanticGraph","fromPoints","graph","getLayer","getConfidentLayer","threshold","getSystemPoints","getStaffPoints","scale","factor","transform","matrix","extension","y1","y2","scaling","height","MEASURE_SEMANTICS","GraceNotehead","CrescendoBegin","CrescendoEnd","DecrescendoBegin","DecrescendoEnd","TremoloLeft","TremoloRight","TremoloMiddle","STAFF_LINED_SEMANTICS","LINED_INTERVAL_SEMANTICS","NOTEHEAD_FOR_STEM_SEMANTICS","KEYACC_CANDIDATE_SEMANTICS","NOTEHEAD_TABLE","up","down","REST_SEMANTICS","TOKEN_TO_STEMBEAM","TEXT_TYPE_ALIAS","Alter1","Alternation1","Alter2","Alternation2","noteheadsXPivot","xs","mean","x1","x2","Measure","tokens","antiTokens","barTypes","noteheads","n1","n2","chordRects","nh","nulN","nhmap","hh","nhs","top","bottom","nh0","stemX","stemDirection","timeWarped","additionalLines","chords","getChords","chord","ceil","flags","beams","chordRcs","rect","noteIds","c1","c2","accs","flagRange","nearbyFlags","flag","beamToken","nearbyDots","getRests","dotValue","getEvents","e1","e2","getContexts","assignAccessoriesOnEvents","accessory","relatedEvents","owner","d1","d2","Down","Up","sortEvents","arpeggio","Grace","tremolsLs","tremolsRs","tremolsMs","tevents","stemL","stemR","tm","te","tremolo","tl","Pitcher","tr","assignFeaturesOnEvents","semantics","dotPs","beamLs","beamMs","beamRs","gracePs","tremoloRs","stems","vline_Stem","s0","s1","s2","cx","divisions","ss","i_flags","f1","f2","i_dots","dots2","bs","u_stems","stem","d_stems","stemDirections","graces","tremolos","feature","Staff","measureCount","measureBars","staffY","measures","endX","noteRange","rearrangeMeasures","reassignTokens","assignSemantics","assemble","system","logger","qualifiedSemantics","TempoNotehead","tempoNh","splice","antiP","displacementSemantics","appendPoint","semanticTop","semanticBottom","rootNhs","nhOffsetX","attachedHeads","topDist","bottomDist","antiPoint","nearStems","appendFlags","dotLines","sy","keyaccs","acc","oct","voltaDots","VoltaLeft","VoltaRight","voltaGroups","lined","interval","signs","fixedY","roundY","holder","mainFlag","downward","tailY","count","clearTokens","clearPredictedTokens","System","HEAD_WIDTH","segmentLength","staves","arrangePosition","sidBlackList","sidWhiteList","staffTop","staffBottom","staffPositions","radius","staffMask","staffMaskChanged","prev","positions","tidyMeasureBars","b1","b2","restWidth","connectionLine","staffHead","staffTail","middleY","timeSignatureOnHead","getStaffArray","si","on","getMarksInMeasure","measureIndex","textType","TempoNumeral","headMeasureIndex","columns","rows","contexts","voltaBegin","voltaEnd","alternative","mi","timeSigs","row","marks","ts","column","lastColumn","break","getEventsFunctional","ev","processors","useXMap","localRows","xMap","groupMap","tickGroup","proc","oy","bars","lastX","barColumns","bar","intensity","barXs","prevStaff","nextStaff","newPoint","appendToken","fontSize","overlap","Page","systems","assignTexts","areas","imageHeight","imageWidth","dimensions","area","cy","rp","score","rect_Text","theta","textFeature","feature_dict","textAnnotations","sysXs","middleX","indent","Text","textFeasure","Title","Author","PageMargin","Other","Chord","MeasureNumber","Instrument","TextualMark","Times","sx","SemanticElementType","TIME_SIG_DENOMINATORS","fromEntries","TIME_SIG_NUMERATORS","et","ELEMENT_TOKEN_NAMES","BOS","NoteheadGrace","NOTEHEAD_BASE_DIVISION","NOTEHEAD_ELEMENT_TYPES","REST_ELEMENT_TYPES","BEAM_ELEMENT_TYPES","NOTE_ELEMENT_TYPES","SOURCE_ELEMENT_TYPES","TARGET_ELEMENT_TYPES","ROOT_NOTE_ELEMENT_TYPES","ELEMENT_TO_STEMBEAM","metaElem","BOS_ELEMENT","fractionToElems","SemanticCluster","elementToJSON","elem","sourceMask","elements","targetMask","vMask","compactMatrixH","matrixH","j","expandMatrixByMasks","compactMatrixV","_matrixV","matrixV","expandMatrixByMaskTriu","groupsV","matrixFromGroups","found","mapMatrix","x2i","i2x","xi","mergeOverlapping","overlaps","overlappedNoteheads","ij","ii","nh1","nh2","masks","stemMasks","stemNotes","s0s","subS0Masks","stemMap","stemId","i1","i2","prevId","linkings","roots","parentMasks","parentId","rootId","subNotes","dotGroups","tipRange","beamElem","iter","gen","maskSrc","maskTar","src","tar","groupIds","id1","id2","ImplicitType","Stream","buffer","Uint8Array","position","eof","read","readString","readInt32","readInt16","readInt8","signed","readVarInt","OStream","write","writeInt32","writeInt16","writeInt8","writeVarInt","getBuffer","getArrayBuffer","charCodeAt","MIDI","parseMidiData","readChunk","stream","lastEventTypeByte","readEvent","deltaTime","eventTypeByte","param1","eventType","channel","subtype","noteNumber","velocity","amount","controllerType","programNumber","subtypeByte","microsecondsPerBeat","hourByte","frameRate","hour","sec","frame","subframe","pow","metronome","thirtyseconds","headerChunk","headerStream","formatType","trackCount","timeDivision","ticksPerBeat","header","tracks","trackChunk","trackStream","encodeMidiFile","writeChunk","writeEvent","frameByte","MidiSequence","midiToSequence","midiFile","trackStates","beatsPerMinute","nextEventIndex","ticksToNextEvent","getNextEvent","nextEventTrack","nextEvent","ticksToEvent","track","midiEvent","processNext","secondsToGenerate","time","processEvents","trimSequence","clear","fixOverlapNotes","noteMap","overlapMap","swaps","leapIndex","swap","front","back","offEvent","leapEvent","tempo","require$$0","PedalControllerTypes","Notation","parseMidi","fixOverlap","channelStatus","pedalStatus","pedals","channels","millisecondsPerBeat","barIndex","keyRange","correspondences","rawTicks","ticks","tempos","rawEvents","deltaTicks","deltaBeats","startTick","low","statusIndex","endTick","finger","high","pedalType","captures","fingers","isNaN","log","endTime","meta","notes","pitchMap","beatInfos","lastInfo","beatIndex","entry","findChordBySoftindex","softIndex","averageTempo","tickRange","to","endtick","span","ticksToTime","next_tempo_index","tempo_index","timeToTicks","tickRangeToTimeRange","scaleTempo","headTempo","MusicNotation","animationDelay","Promise","resolve","requestAnimationFrame","MidiPlayer_1","MidiPlayer","midiData","cacheSpan","onMidi","onPlayFinish","onTurnCursor","notation","isPlaying","progressTime","startTime","performance","now","cursorTurnDelta","dispose","progressTicks","play","nextFrame","currentEventIndex","backturn","eventTime","pause","turnCursor","config","CostStepAttenuation","SkipDeep","PriorDistanceSigmoidFactor","PriorValueSigmoidFactor","SkipCost","LagOffsetCost","LeadOffsetCost","ZeroOffsetCost","RelocationThreshold","Config","require$$1","Node","s_note","c_note","_prev","_totalCost","_value","cacheDirty","ci","rootSi","cost","skip","updateCache","totalCost","selfCost","deep","path","node","dump","evaluatePrev","evaluatePrevCost","bias","priorByOffset","distance","navigator","Navigator","criterion","sample","getCursorOffset","outOfPage","bestNode","fineCursor","breakingSI","zeroNode","relocationThreshold","step","prevNote","prevNode","cursors","nullLength","nullSteps","cursor","resetCursor","breaking","deltaSi","fromIndex","toIndex","backPrior","cursorOffset","relocationTendency","normalizeInterval","HEART_BEAT","makeNoteSoftIndex","softIndexFactor","lastNote","Matcher","makeMatchNodes","targetList","targetNote","genNotationContext","runNavigation","async","onStep","Symbol","for","EXCLUDE_MIDI_EVENT_SUBTYPES","encodeToMIDIData","unclosedNoteDuration","msToTicks","Date","process","env","VUE_APP_BUILD_TIME","toDateString","MidiUtils","sliceMidi","midi","trackDeltaToAbs","lastTick","trackAbsToDelta","sliceTrack","encodeToMIDI","musicWidgets","require$$2","require$$3","require$$4","COMMON_NOTE_FIELDS","MetaNotation","fromAbsoluteNotes","measureHeads","__","mnotes","mn","field","idTrackMap","performAbsoluteNotes","abNotes","withRestTied","tied","overlapped","staffTrack","contextIndex","implicitType","chordPosition","priorNote","ripe","trackTickBias","headMeasure","trackNames","idSet","toAbsoluteNotes","measureIndices","measureTick","measureNotes","mnote","toPerformingNotation","WHOLE_DURATION_MAGNITUDE","toPerformingMIDI","trackList","zeroTick","measureEvents","mevent","eventPriority","subnote","finalTick","toPerformingNotationWithEvents","assignNotationNoteDataFromEvents","setTempo","midiNotation","noteId","CryptoJS","exports","crypto","window","msCrypto","global","require","err","cryptoSecureRandomInt","getRandomValues","Uint32Array","randomBytes","readInt32LE","F","obj","C","C_lib","lib","Base","extend","overrides","mixIn","init","$super","instance","properties","propertyName","clone","WordArray","words","sigBytes","encoder","Hex","wordArray","thisWords","thatWords","thisSigBytes","thatSigBytes","clamp","thatByte","nBytes","C_enc","enc","hexChars","bite","hexStr","hexStrLength","parseInt","Latin1","latin1Chars","latin1Str","latin1StrLength","Utf8","decodeURIComponent","escape","utf8Str","unescape","encodeURIComponent","BufferedBlockAlgorithm","reset","_data","_nDataBytes","_append","_process","doFlush","processedWords","dataWords","dataSigBytes","blockSize","nBlocksReady","nWordsReady","_minBufferSize","nBytesReady","_doProcessBlock","Hasher","cfg","_doReset","update","messageUpdate","finalize","_doFinalize","_createHelper","hasher","message","_createHmacHelper","C_algo","HMAC","algo","H","K","isPrime","sqrtN","getFractionalBits","nPrime","W","SHA256","_hash","M","h","gamma0x","gamma0","gamma1x","gamma1","maj","sigma0","t1","nBitsTotal","nBitsLeft","HmacSHA256","factory","HashVector","fromHash","byte","fromString","_SHA256","uwords","word_len","fromWords","vectors","toHash","bit","vec","crop","ODDS","odds","odd","cosHashes","hash1","hash2","xor","xorHashes","i2hex","Sylvester","Matrix","setElements","I","els","dup","isSquare","cols","toRightTriangular","np","determinant","det","isSingular","augment","T","nj","inverse","divisor","new_element","inverse_elements","DURATION_MULTIPLIER","floatToTimeWarp","floatToFrac","ActionType","EventElementType","SimplePolicy","Action","P","PLACE","V","order","VERTICAL","HORIZONTAL","StageMatrix","fromNode","stages","actions","stage1","stage","stage2","stagedEvents","endHs","endHP","hActions","pendingHeads","eid","pathOf","target","findDoublePath","paths","reducePath","toEquations","eventCount","equations","path1","path2","equation","PathNode","last","like","constructStages","unshift","newStage","constructConstraints","factors","constraints","inbalancesConstraints","ones","fixed","inbalances","constraint","solveEquations","xis","equationMap","conflicted","squareLines","restLines","candidateLines","sl","invert","mat","matrixInverse","solution","optimallySolve","shrinkMap","shrinkness","released","releasedIds","lowWarp","isConflicted","eventTendencies","timeWarps","getSolution","actionKey","hacts","a1","a2","hmap","act","startEs","se","estages","solveStages","changed","measureDuration","outEI","deduce","quota","access","actionAccessing","closed","credits","children","expand","possibility","child","branches","appendBranch","branch","Solver","event0","measureShrinkness","expectedDuration","xSpan","solve","pathRoot","bestSolution","evaluateSolution","loss","sevents","partialFrac","weight","staffAlters","eventsXOrder","tickTwists","dt","atan2","PI","PatchMeasure","staffN","basics","basic","EventCluster","regular","CHORD","REST","fake","fullMeasure","grant","annotation","endElem","EOS","assignPrediction","prediction","pe","EventClusterSet","trimIrregular","ir","cluster","computeMeasureTicks","roundX","constructXMap","eventGroups","divisionVector","dotsVector","computeMeasureVoices","eventSet","pushEvent","e0","EquationPolicy","INVERT_SQRT2","FINE_BEAMS","bb","solveStaffGroup","staffGroup","EquationSolver.Solver","estiamteMeasure","allEvents","tickEstimated","pR","eventStartX","staffGroupMap","staffGroups","ievents","startX","hp","erf","staffDecay","exp","yDecay","dtx","nR","regulateMeasure","solver","mp","resultEvents","solutionStat","solverCredits","solverTimes","regulateMeasureWithRectification","rectification","re","priority","tickN","SpartitoMeasure","reorderEvents","staffYsFull","rx","ry","yi","yis","intX","intY","originalRegulationHash","regulationHash","postRegulate","keySignature","timeSignatureChanged","validRegulated","tickMap","endEvent","tickToX","tickRates","rates","tickRatesInGroups","gevents","groupIndex","twists","empty","hasIllEvent","brief","regulationHash0","regulationHashes","featureWords","invalid","uys","melodies","rhythm","barType","typeEntris","partialDuration","signatureDuration","updateRoundX","graceEvents","staffMap","smap","oldEvent","emap","preTick","graceIds","totalDuration","warp","solveGraceEvents","catchers","pitchers","catcher","candidates","pitcher","catcherId","pi","solveTremoloPairs","updateContextTick","terms","t2","asSolution","ref","refEvent","applySolution","cleanupRegulation","regulateTest","regulateSimple","regulateEquations","regulate","policy","createPatch","createClusters","trueEventIds","idx","staffIndices","staffY0","staffYs","staffYn","headY","backgroundImages","url","applyClusters","id_max","is","srcId","tarId","emptyVoiceFromStaffMeasure","chiefVoice","timeSigNumeric","contextedTerms","markingTiesInVoice","event1","p0","tying","si0","si1","Spartito","solidMeasureCount","measureIndexMapping","headBPM","tempoMark","mark","measureLayoutCode","ms","vb","ve","leftSign","rightSign","nextI","mm","nextVBI","pms","lastVEI","lastMI","dumpEvaluations","rectifyTimeSignatures","mis","newTimeSignature","measuresToFix","originTimeSignature","regularD","numerators","countings","peakCount","bestCounting","best","reducedN","makeVoiceStaves","voiceCount","leftStaves","lastEvent","tailEvent","tailStaff","pageBreak","headStaff","sd","trait","staffToGroup","voiceTraits","vector","v1","v2","leftVoices","voiceTrait","vs","consistencies","voiceIndex","m1","m2","staffVoiceIndices","vi","mode","removeEmptyMeasuresInVoicesStaves","perform","tokenMap","staffToChannel","voiceChannels","hasTempo","nextTick","events0","voice0","part","pitchValue","performByEstimation","noteTick","featureHash","measureWords","levels","meaures","vecY","vecMelody","vecRhythm","featureHashHex","featureHashBigInt","BigInt","assignMeasureNumbers","discard","measureNumber","mod12","ALTER_NAMES","StaffContext","keyAlters","alters","timeSigNumSet","timeSigDenSet","doubtingTimesig","change","yToNote","partialTimeSignature","resetMeasure","resetSystem","noteToY","pitchToNote","preferredAlter","gp","alteredGp","naturalNote","alterValue","keyAlterValue","pitchToY","alterOnNote","yToPitch","yToPitchName","bitsToMask","Score","version","layoutTemplate","staffLayoutCode","pages","page","spartito","upgradeScoreData","headers","instrumentDict","pageSize","unitSize","maxStavesCount","imageKeys","backgroundImage","maskImage","breakSystemIndices","systemCount","staffLayout","staffLayout.parseCode","semanticHash","eventSystemsToTermStaves","eventSystems","termStaves","sys","context","startEvent","processStaffContext","resetPageLayout","parameters","newCenter","offsetX","offsetY","getMeasure","localIndex","getRawCluster","systemY0","y0","getRawClusters","makeSpartito","ri","esys","patch","patches","makeMusicSheet","voiceStaves","title","paperOptions","measureLayout","getMeasureLayout","findPoint","sid","pageIndex","getMeasureSemantics","sy1","sy2","makeTimewiseGraph","store","getTokenMap","confidenceThreshold","append","assembleSystem","markVoices","vis","replaceImageKeys","all","then","inferenceStaffLayout","staffTotal","completeSystems","bracketsAppearance","candidateCodes","codeCounting","maxCount","connectedCode","lastSys","search","code1","startsWith","assignBackgroundForMeasure","imagePosition","original","blackoutFakeNotes","scope","inScope","fakeIds","voicedIds","fakeIdSet","blackIds","measureLayout.parseCode","splitToSingleScoresGen","startSysIndices","templateScore","topology","startSysIndex","endSysIndex","sysInRange","newScore","SubScoreSystem","SubScorePage","splitToSingleScores","EditableEvent","agent","Proxy","ownKeys","getOwnPropertyDescriptor","enumerable","configurable","EditableMeasure","syncVoiceToEvents","syncVoiceFromEvents","makeMIDI","subEvents","midiEvents","BeadType","DIVISION_NAMES","SPACE_LOSS_WEIGHT","POSSIBILITY_LOW_BOUNDARY","STEM_DIRECTION_OPTIONS","BEAM_OPTIONS","saveClusterState","BeadNode","accessCount","nextBranch","possibilities","currentElem","elemIndex","branchID","ni","Pass","Division","Dots","repeat","picker","ptFactor","evaluateCluster","pretentiousness","selfEval","element","residue","fatalError","predictCluster","evaluation","estimateElementDuration","eos","lastOrder","voiceN","scales","referenceScale","nearScale","tickSpan","twist","tickMSE","tickErr","mse","spaceDuration","solveCluster","stopLoss","suc0","bestEvaluation","bestState","restoreClusterState","fixedEvents","pendingEvents","near","stemDirectionVector","beamVector","solveMeasure","quotaMax","quotaFactor","worstLoss","durations","solutionEvents","tipElem","tickSet","glimpseMeasure","resetSignatureForDoubtfulOnly","estimateMeasure","StemTip","StemHead","rect_Lyric","SemanticClusterSet","vocab","converts","connection","SUPPORT_CLEF_TYPES","starry.TokenType","tokenToText","ReflectOwnKeys","R","Reflect","ReflectApply","receiver","Function","getOwnPropertySymbols","getOwnPropertyNames","NumberIsNaN","EventEmitter","eventsModule","once","emitter","errorListener","removeListener","resolver","eventTargetAgnosticAddListener","handler","addErrorHandlerIfEventEmitter","_events","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","prepend","existing","warning","newListener","emit","warned","w","onceWrapper","fired","wrapFn","_onceWrap","wrapped","bind","_listeners","unwrap","evlistener","arr","ret","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","destructPromise","timeout","rs","rj","setTimeout","defineProperty","RangeError","setMaxListeners","getMaxListeners","doError","er","listeners","addListener","prependListener","prependOnceListener","list","originalListener","spliceOne","off","removeAllListeners","rawListeners","eventNames","AsyncQueue","working","tasks","_digest","taskFn","payload","addTask","task","promise","ZeroClient","queue","socket","Request","sendTimeout","receiveTimeout","connect","__request","retryTimes","req","send","pack","receive","close","request","method","kwargs","args_","kwargs_","msg","opt","unpack","PyProcessor","scriptPath","retryCount","retryDelay","port","freePort","getPortPromise","stopPort","defaultsDeep","pyShell","PythonShell","stdout","isBuffer","inherits_browserModule","ctor","superCtor","super_","writable","TempCtor","util","inherits","inheritsModule","getOwnPropertyDescriptors","descriptors","formatRegExp","format","isString","objects","inspect","isNull","isObject","deprecate","fn","noDeprecation","throwDeprecation","traceDeprecation","debugEnviron","debugs","opts","ctx","seen","stylize","stylizeNoColor","depth","colors","isBoolean","showHidden","_extend","isUndefined","customInspect","stylizeWithColor","formatValue","styleType","style","styles","recurseTimes","isFunction","primitive","simple","isNumber","formatPrimitive","visibleKeys","val","arrayToHash","isError","formatError","isRegExp","RegExp","isDate","output","base","braces","toUTCString","formatProperty","formatArray","cur","reduceToSingleString","desc","ar","objectToString","pad","debuglog","NODE_DEBUG","toUpperCase","pid","bold","italic","underline","white","grey","black","blue","cyan","green","magenta","red","yellow","special","boolean","null","string","date","regexp","isNullOrUndefined","isSymbol","isPrimitive","months","prop","getHours","getMinutes","getSeconds","getDate","getMonth","origin","kCustomPromisifiedSymbol","callbackifyOnRejected","reason","cb","newReason","promisify","promiseResolve","promiseReject","defineProperties","custom","callbackify","callbackified","maybeCb","rej","getPort","base64map","crypt","rotl","rotr","endian","bytes","bytesToWords","wordsToBytes","bytesToHex","hex","hexToBytes","bytesToBase64","base64","triplet","charAt","base64ToBytes","imod4","cryptModule","charenc","utf8","stringToBytes","bin","bytesToString","charenc_1","api","digestbytes","H0","H1","H2","H3","H4","asBytes","asString","_blocksize","_digestsize","sha1Module","constructSystem","detection","imageSize","systemWidth","phi2","phi1","systemHeight","lastSystem","stavesTops","middleRhos","starry.Staff","starry.System","convertImage","maxHeight","quality","buf","got","responseType","decompress","https","rejectUnauthorized","toBuffer","webpBuffer","sharp","resize","fit","withoutEnlargement","toFormat","filename","SparkMD5","ArrayBuffer","OffscreenCanvas","Canvas","Image","STAFF_PADDING_LEFT","GAUGE_VISION_SPEC","viewportHeight","viewportUnit","MASK_VISION_SPEC","SEMANTIC_VISION_SPEC","concurrencyTask","fns","shootStaffImage","paddingLeft","spec","middleUnits","canvas","getContext","fillStyle","fillRect","drawImage","loadImage","shootStaffBackgroundImage","sourceCanvas","toBufferSync","gaugeStaff","gaugeImage","pyClients","sourceBuffer","baseY","predictScoreImages","maskStaff","img","semanticStaff","settings","semanticConfidenceThreshold","replacePageImages","onReplaceImageKey","OMRProgress","onChange","setTotal","total","finished","increase","lruCache","WeakLRUCache","pageStore","getValue","setValue","onReplaceImage","multinomial_1","pvals","looseVector","ns","looseEvent","MeasureRectification","roll","DefaultSolutionStore","PendingCondition","solveMeasureRecords","records","onUpdate","pendingCondition","NotFine","pass","onProgress","pendingRecords","ErrorOnly","Imperfect","isPending","record","current","starry.beadSolver.solveMeasure","starry.evaluateMeasure","better","remaining","RECTIFICATION_SEARCH_ITERATIONS","BASE_QUOTA_FACTOR","RECTIFICATION_QUOTA_FACTOR","computeQuota","limit","solveMeasures","solutionStore","ignoreCache","cached","solved","stat","computed","solveMeasuresWithRectifications","n_rec","rec","default","stale","genMeasureRectifications","testMeasure","doSimpleRegulate","PyClients","clients","getClient","client","option","checkHost","warmup","clientType","res","by_buffer","stats","costTotal","pagesCostTotal","pagesTotal","pagesCost","costPerPage","scoreN","pickerCost","measureN","timeN","tryTimes","costPerMeasure","costPerTime","issue","fatal","baseCostTotal","topoCostTotal","baseMeasures","topoMeasures","baseCost","topoCost","baseCostPerMeasure","topoCostPerMeasure","baseComputed","baseSolved","topoSolved","topoIssue","topoFatal","onSaveIssueMeasure","t0","issueMeasures","results","cs","solvedIndices","errorIndices","n_issues","doRegulateWithTopo","maskImages","hasMaskImage","scoreJson","idsMap","idsXMap","idStaffIndexMap","coverTexts","subtitles","subtitle","authors","composer","bgWidth","bgHeight","l1","ls","parts","partTemplates","measureXs","partIndex","template","staffIndexBase","paddedStaves","chordColumns","staffIndexInPart","noteIndex","measureStartX","elems","firstX","innerId","lastFifths","clefs","pt","fifths","lineStaves","systemTopStaff","systemBottomStaff","systemTopStaffY","systemBottomStaffY","lastPartLastStaff","partStaves","staffs","details","hide","visibleStaves","partTopStaff","partBottomStaff","partTopStaffY","partBottomStaffY","distances","imgs","spartitoMeasure","parti","mIndices","sortedParts","midiJson","measInfo","ent","idNoteMap","beatsCurrent","beatsUnitCurrent","mIndex","beatsUnit","evt","note_ticks","measureInfos","beatUnit","mergedTracks","trackIndex","program","lhPattern","rhPattern","instrus","hand","handStaves","trackToSplit","newTracks","stave","rightHandTrack","leftHandTrack","transformedTracks","onEvent","measureTickMap","numId","newEvent","elem_ids","meas_start_tick","images","outputWidth","processes","progress","image","starry.Score","raggedLast","raggedLastBottom","enabledGauge","originalImages","pageCanvasList","scaleForLayout","sourceSize","detections","cvs","enableGauge","imageURLMap","collectImage","createPage","detect","pageKey","cachedPageJson","omit","renew","starry.recoverJSON","starry","starry.Page","unit","cos","sin","needGauge","correctCanvas","pageCanvas","save","setTransform","restore","getImageData","putImageData","sourceCenter","shootImageByDetection","sizeRatios","staffInterval","vw","hwr","maxVW","maxAspect","setGlobalPageSize","systemsCount","allTasks","omitPages","n_page","pageTasks","bracketImages","topMid","bottomMid","sourceRect","OUTPUT_INTERVAL","bracketsRes","buffers","bufferForText","location","box","resultOCR","titleToken","gaugeRes","maskRes","semanticRes","t3","pickers","freshOnly","onPassStart","baseQuality","n_seq","starry.beadSolver.estimateMeasure","counting","toFixed","totalMeasures","computeRemaining","wrappedOnProgress","starry.EditableMeasure","saveMeasure","solutions","batchGet","originMeasure"],"mappings":"wbAk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AShuB,OAAQ6H,IAAaA,EAAQ29C,iBAGvC3vB,EAAMo+B,QAAUjmC,EAAS5mB,IAAKS,GAAYA,EAAQmhD,eAE9Cp6C,GAASumE,cAAe,CAC3Bt/C,EAAMvH,WACN,MAAMsjC,EAAW/7B,EAAMg+B,eAEvB7lC,EAASjsB,QAAS8F,IAEjB,GADA+G,EAAQumE,cAAelvE,IAAI4B,EAAQu9C,eAAgB,IAAKv9C,EAAQygD,aAAc9D,SAAU,IACpF38C,EAAQw+C,kBAAoBx+C,EAAQu9C,eAAgB,CACvD,MAAMq+B,EAAgB7xB,EAAS5jC,SAASpS,KAAMriB,GAAMA,EAAEo5B,eAAiB9qB,EAAQ8qB,cAC/E/jB,EAAQumE,cAAelvE,IAAI4B,EAAQw+C,gBAAiB,IAAKx+C,EAAQygD,WAAWm7B,GAAgBj/B,SAAU,GACtG,GAEF"} \ No newline at end of file diff --git a/backend/omr/dist/regulator.js b/backend/omr/dist/regulator.js index 621e02fb45381e31bb0630fbb9bca1a825268fb3..8489520decb2b790f9fa1b9203d46bb4dbe9f2e0 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: 2/17/2026, 8:40:18 PM + * build time: 2/17/2026, 11:16:28 PM * system user: camus * git user name: k.l.lambda * git user email: k.l.lambda@gmail.com @@ -16191,7 +16191,7 @@ const saveEditableMeasures = async (score, measureIndices, saveMeasure, { status }); }; -console.info(`%cstarry-omr%c v1.0.0 2026-02-17T12:40:40.287Z`, '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-02-17T15:17:01.645Z`, '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/regulator.js.map b/backend/omr/dist/regulator.js.map index 4db94478f965d48a579a06d747db7d0eccb72fcb..04d2c4ac14a595254669837a71d4a2678f1f4080 100644 --- a/backend/omr/dist/regulator.js.map +++ b/backend/omr/dist/regulator.js.map @@ -1 +1 @@ -{"version":3,"file":"regulator.js","sources":["../../libs/browserComponents.ts","../../../node_modules/events/events.js","../../libs/async-queue.ts","../../libs/ZeroClient.ts","../../libs/PyProcessor.ts","../../../node_modules/util/support/isBuffer.js","../../../node_modules/util/node_modules/inherits/inherits_browser.js","../../../node_modules/util/node_modules/inherits/inherits.js","../../../node_modules/util/util.js","../../libs/predictors.ts","../../../src/starry/interfaces.ts","../../../src/starry/semanticPoint.ts","../../../src/starry/token.ts","../../../src/starry/aux_/typedJSON.ts","../../../src/measureLayout/measureLayout.ts","../../../src/measureLayout/grammar.jison.js","../../../src/measureLayout/parser.ts","../../../src/staffLayout/staffLayout.ts","../../../src/staffLayout/grammar.jison.js","../../../src/staffLayout/parser.ts","../../../src/starry/logger.ts","../../../src/starry/utils.ts","../../../src/starry/term.ts","../../../src/starry/measureEvaluator.ts","../../../src/starry/semanticGraph.ts","../../../src/starry/scoreComponents.ts","../../../src/starry/semanticTopology.ts","../../../src/performer/types.ts","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/stream.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifile.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/streamEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifileEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiSequence.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MusicNotation.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiPlayer.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/config.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/node.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/navigator.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiUtils.js","../../../node_modules/@k-l-lambda/music-widgets/index.js","../../../src/performer/notation.ts","../../../node_modules/crypto-js/core.js","../../../node_modules/crypto-js/sha256.js","../../../src/starry/hashVector.ts","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/equationSolver.ts","../../../src/starry/patch.ts","../../../src/starry/eventTopology.ts","../../../src/starry/spartitoMeasure.ts","../../../src/starry/spartito.ts","../../../src/starry/staffContext.ts","../../../src/starry/score.ts","../../../src/starry/editableMeasure.ts","../../../src/starry/beadSolver.ts","../../../src/starry/measureRectification.ts","../../libs/store.ts","../../libs/regulationBead.ts","../../libs/regulation.ts","../../libs/util.ts","../src/regulator.ts"],"sourcesContent":["globalThis.btoa = (str) => Buffer.from(str, 'binary').toString('base64');\nglobalThis.atob = (str) => Buffer.from(str, 'base64').toString('binary');\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","import { EventEmitter } from 'events';\n\ninterface DSPromiseOption {\n\ttimeout?: number;\n}\n\nexport function destructPromise(\n\toptions: DSPromiseOption = {}\n): [promise: Promise, resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void] {\n\tconst { timeout } = options;\n\tlet rs: (value: T | PromiseLike) => void;\n\tlet rj: (reason: any) => void;\n\n\treturn [\n\t\tnew Promise((resolve, reject) => {\n\t\t\trs = resolve;\n\t\t\trj = reject;\n\n\t\t\tif (timeout >= 0) setTimeout(rj, timeout, 'timeout');\n\t\t}),\n\t\trs,\n\t\trj,\n\t];\n}\n\ntype AsyncTask = [fn: (data: any) => Promise, payload: any, resolve: (data: any) => void, reject: (reason: any) => void];\n\nexport class AsyncQueue extends EventEmitter {\n\tprivate working = false;\n\n\ttasks: AsyncTask[];\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.working = false;\n\t\tthis.tasks = [];\n\t\tprocess.nextTick(() => {\n\t\t\tthis.emit('idle');\n\t\t});\n\t}\n\n\tprivate async _digest(item: AsyncTask) {\n\t\tthis.working = true;\n\n\t\tconst [taskFn, payload, resolve, reject] = item;\n\t\tawait taskFn(payload).then(resolve, reject);\n\n\t\tif (this.tasks.length > 0) {\n\t\t\tawait this._digest(this.tasks.shift());\n\t\t} else {\n\t\t\tthis.working = false;\n\t\t\tthis.emit('idle');\n\t\t}\n\t}\n\n\t/**\n\t * 添加队列任务\n\t * @param task\n\t * @param options\n\t */\n\taddTask(task: [AsyncTask[0], AsyncTask[1]], { timeout = 600000 }: { timeout?: number } = {}): Promise {\n\t\tconst [promise, resolve, reject] = destructPromise({ timeout });\n\n\t\tif (this.working) {\n\t\t\tthis.tasks.push([...task, resolve, reject]);\n\t\t} else {\n\t\t\tthis._digest([...task, resolve, reject]);\n\t\t}\n\n\t\treturn promise;\n\t}\n}\n","import { pack, unpack } from 'msgpackr';\nimport { Request } from 'zeromq';\nimport { AsyncQueue } from './async-queue';\n\ninterface Response {\n\tcode: number;\n\tmsg: string;\n\tdata?: any;\n}\n\nexport interface Logger {\n\tinfo: (...data: any[]) => void;\n\terror: (...data: any[]) => void;\n}\n\ntype PyArgs = any[];\ntype PyKwargs = Record;\n\nexport default class ZeroClient {\n\tlogger: Logger;\n\tprivate socket: Request;\n\tprivate queue: AsyncQueue = new AsyncQueue();\n\n\tprivate url: string;\n\n\tconstructor(logger: Logger = console) {\n\t\tthis.logger = logger;\n\t}\n\n\tbind(url?: string) {\n\t\turl && (this.url = url);\n\t\tthis.socket = new Request({\n\t\t\tsendTimeout: 15e3,\n\t\t\treceiveTimeout: 300e3,\n\t\t});\n\n\t\tthis.socket.connect(this.url);\n\t}\n\n\tprivate __request(payload) {\n\t\tlet retryTimes = 0;\n\n\t\tconst req = async (data) => {\n\t\t\ttry {\n\t\t\t\tif (this.socket.closed) this.bind();\n\t\t\t\treturn await this.socket.send(pack(data)).then(() => this.socket.receive());\n\t\t\t} catch (err) {\n\t\t\t\tif (retryTimes < 2) {\n\t\t\t\t\tretryTimes++;\n\t\t\t\t\tconsole.log(`请求失败,${err.stack}`);\n\t\t\t\t\tconsole.error(`3s后重试第${retryTimes}次`);\n\t\t\t\t\tthis.socket.close();\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 3000));\n\t\t\t\t\treturn req(data);\n\t\t\t\t} else {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn req(payload);\n\t}\n\n\tasync request(method: string, args: PyArgs | PyKwargs = null, kwargs: PyKwargs = null): Promise {\n\t\tconst [args_, kwargs_] = Array.isArray(args) ? [args, kwargs] : [undefined, args];\n\t\tconst msg: any = { method };\n\t\tif (args_) msg.args = args_;\n\t\tif (kwargs_) msg.kwargs = kwargs_;\n\n\t\treturn this.queue.addTask([\n\t\t\tasync (opt) => {\n\t\t\t\tconst [result] = await this.__request(opt);\n\n\t\t\t\tconst obj = unpack(result) as Response;\n\n\t\t\t\tif (obj.code === 0) {\n\t\t\t\t\treturn obj.data;\n\t\t\t\t} else {\n\t\t\t\t\treturn Promise.reject(obj.msg);\n\t\t\t\t}\n\t\t\t},\n\t\t\tmsg,\n\t\t]);\n\t}\n}\n","import { getPortPromise } from 'portfinder';\nimport { Options, PythonShell } from 'python-shell';\nimport { defaultsDeep } from 'lodash';\nimport ZeroClient, { Logger } from './ZeroClient';\n\nexport default class PyProcessor extends ZeroClient {\n\tprivate readonly scriptPath: string;\n\tprivate readonly options: Options;\n\tprivate pyShell: PythonShell;\n\n\tprivate retryCount: number = 0;\n\tprivate retryDelay: number = 3000;\n\n\tconstructor(scriptPath: string, options: Options = {}, logger: Logger = console) {\n\t\tsuper(logger);\n\t\tthis.scriptPath = scriptPath;\n\t\tthis.options = options;\n\t}\n\n\tasync bind(port?: string | number) {\n\t\tconst freePort =\n\t\t\tport ||\n\t\t\t(await getPortPromise({\n\t\t\t\tport: 12022,\n\t\t\t\tstopPort: 12122,\n\t\t\t}));\n\n\t\t// \"./streamPredictor.py\", \"--inspect\"\n\t\tconst options = defaultsDeep(\n\t\t\t{\n\t\t\t\targs: [...(this.options.args || []), '-p', `${freePort}`],\n\t\t\t},\n\t\t\tthis.options\n\t\t);\n\n\t\tthis.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`);\n\n\t\tthis.pyShell = new PythonShell(this.scriptPath, options);\n\n\t\tthis.pyShell.stdout.on('data', (data) => this.logger.info(data));\n\n\t\tthis.pyShell.on('pythonError', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`, err));\n\t\tthis.pyShell.on('stderr', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`, err));\n\t\tthis.pyShell.on('error', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} error:`, err));\n\t\tthis.pyShell.on('close', () => {\n\t\t\t// python子进程关闭事件\n\t\t\tif (this.retryCount < 5) {\n\t\t\t\tthis.retryCount++;\n\t\t\t\tthis.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.bind();\n\t\t\t\t}, this.retryDelay);\n\t\t\t}\n\t\t});\n\n\t\tsuper.bind(`tcp://127.0.0.1:${freePort}`);\n\t}\n}\n","module.exports = function isBuffer(arg) {\n return arg instanceof Buffer;\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n","try {\n var util = require('util');\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n module.exports = require('./inherits_browser.js');\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(obj) {\n var keys = Object.keys(obj);\n var descriptors = {};\n for (var i = 0; i < keys.length; i++) {\n descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);\n }\n return descriptors;\n };\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n if (typeof process !== 'undefined' && process.noDeprecation === true) {\n return fn;\n }\n\n // Allow for deprecating things in the process of starting up.\n if (typeof process === 'undefined') {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nvar kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;\n\nexports.promisify = function promisify(original) {\n if (typeof original !== 'function')\n throw new TypeError('The \"original\" argument must be of type Function');\n\n if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {\n var fn = original[kCustomPromisifiedSymbol];\n if (typeof fn !== 'function') {\n throw new TypeError('The \"util.promisify.custom\" argument must be of type Function');\n }\n Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return fn;\n }\n\n function fn() {\n var promiseResolve, promiseReject;\n var promise = new Promise(function (resolve, reject) {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n args.push(function (err, value) {\n if (err) {\n promiseReject(err);\n } else {\n promiseResolve(value);\n }\n });\n\n try {\n original.apply(this, args);\n } catch (err) {\n promiseReject(err);\n }\n\n return promise;\n }\n\n Object.setPrototypeOf(fn, Object.getPrototypeOf(original));\n\n if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return Object.defineProperties(\n fn,\n getOwnPropertyDescriptors(original)\n );\n}\n\nexports.promisify.custom = kCustomPromisifiedSymbol\n\nfunction callbackifyOnRejected(reason, cb) {\n // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).\n // Because `null` is a special error value in callbacks which means \"no error\n // occurred\", we error-wrap so the callback consumer can distinguish between\n // \"the promise rejected with null\" or \"the promise fulfilled with undefined\".\n if (!reason) {\n var newReason = new Error('Promise was rejected with a falsy value');\n newReason.reason = reason;\n reason = newReason;\n }\n return cb(reason);\n}\n\nfunction callbackify(original) {\n if (typeof original !== 'function') {\n throw new TypeError('The \"original\" argument must be of type Function');\n }\n\n // We DO NOT return the promise as it gives the user a false sense that\n // the promise is actually somehow related to the callback's execution\n // and that the callback throwing will reject the promise.\n function callbackified() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n\n var maybeCb = args.pop();\n if (typeof maybeCb !== 'function') {\n throw new TypeError('The last argument must be of type Function');\n }\n var self = this;\n var cb = function() {\n return maybeCb.apply(self, arguments);\n };\n // In true node style we process the callback on `nextTick` with all the\n // implications (stack, `uncaughtException`, `async_hooks`)\n original.apply(this, args)\n .then(function(ret) { process.nextTick(cb, null, ret) },\n function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });\n }\n\n Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));\n Object.defineProperties(callbackified,\n getOwnPropertyDescriptors(original));\n return callbackified;\n}\nexports.callbackify = callbackify;\n","import ZeroClient, { Logger } from './ZeroClient';\nimport * as starry from '../../src/starry';\nimport PyProcessor from './PyProcessor';\nimport { destructPromise } from './async-queue';\nimport { getPort } from 'portfinder';\nimport util from 'util';\nimport { Options } from 'python-shell';\n\nconst getPortPromise = util.promisify(getPort);\n\nexport interface LayoutResult {\n\tdetection: starry.PageLayout;\n\ttheta: number;\n\tinterval: number;\n\tsourceSize?: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface PredictorInterface {\n\tlayout: (streams: Buffer[]) => LayoutResult[];\n\tlayout$reinforce: (streams: Buffer[], baseLayouts: LayoutResult[]) => LayoutResult[];\n\tgauge: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tmask: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tsemantic: (streams: Buffer[]) => any[];\n\ttextLoc: (streams: Buffer[]) => any[];\n\ttextOcr: (params: { buffers: Buffer[]; location: any[] }) => any[];\n\tbrackets: (params: { buffers: Buffer[] }) => any[];\n\ttopo: (params: { clusters: starry.EventCluster[] }) => any[];\n\tgaugeRenderer: (params: [Buffer, Buffer, number]) => { buffer: Buffer; size: { width: number; height: number } };\n\tjianpu: (params: { buffers: Buffer[] }) => any[];\n\t// [source: Buffer, gauge: Buffer, baseY: number]\n}\n\ntype PredictorType = keyof PredictorInterface;\n\nexport type PyClientsConstructOptions = Partial>;\n\nexport class PyClients {\n\tclients = new Map>();\n\n\tconstructor(public readonly options: PyClientsConstructOptions, public readonly logger: Logger = console) {}\n\n\tasync getClient(type: PredictorType) {\n\t\tif (this.clients.has(type)) {\n\t\t\treturn this.clients.get(type);\n\t\t}\n\n\t\tconst [promise, resolve, reject] = destructPromise();\n\n\t\tconst opt = this.options[type];\n\n\t\tif (!opt) {\n\t\t\tthrow new Error(`no config for client \\`${type}\\` found`);\n\t\t}\n\n\t\ttry {\n\t\t\tif (typeof opt === 'string') {\n\t\t\t\tconst client = new ZeroClient();\n\t\t\t\tclient.bind(opt);\n\t\t\t\tresolve(client);\n\t\t\t} else {\n\t\t\t\tconst { scriptPath, ...option } = opt;\n\t\t\t\tconst client = new PyProcessor(scriptPath, option, this.logger);\n\t\t\t\tawait client.bind(`${await getPortPromise()}`);\n\t\t\t\tresolve(client);\n\t\t\t}\n\n\t\t\tthis.logger.info(`PyClients: ${type} started`);\n\t\t} catch (err) {\n\t\t\tthis.logger.error(`PyClients: ${type} start fail: ${JSON.stringify(err)}`);\n\t\t\treject(err);\n\t\t}\n\n\t\tthis.clients.set(type, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync checkHost(type: PredictorType): Promise {\n\t\tconst client = await this.getClient(type);\n\n\t\treturn client.request('checkHost');\n\t}\n\n\tasync warmup() {\n\t\tconst opts = Object.keys(this.options) as PredictorType[];\n\t\tawait Promise.all(opts.map((type) => this.getClient(type)));\n\t}\n\n\t/**\n\t * 模型预测\n\t * @param type layout | mask | gauge | semantic\n\t * @param args\n\t */\n\tasync predictScoreImages(type: T, ...args: Parameters): Promise> {\n\t\tconst clientType = type.split('$')[0] as PredictorType;\n\t\tconst client = await this.getClient(clientType);\n\t\tlet res = null;\n\n\t\tthis.logger.info(`[predictor]: ${type} py start..`);\n\t\tconst start = Date.now();\n\n\t\tswitch (type) {\n\t\t\tcase 'layout':\n\t\t\t\tres = await client.request('predictDetection', args);\n\t\t\t\tbreak;\n\t\t\tcase 'layout$reinforce':\n\t\t\t\tres = await client.request('predictReinforce', args);\n\t\t\t\tbreak;\n\t\t\tcase 'gauge':\n\t\t\tcase 'mask':\n\t\t\t\tres = await client.request('predict', args, { by_buffer: true });\n\t\t\t\tbreak;\n\t\t\tcase 'semantic':\n\t\t\tcase 'textLoc':\n\t\t\t\tres = await client.request('predict', args);\n\t\t\t\tbreak;\n\t\t\tcase 'textOcr':\n\t\t\tcase 'brackets':\n\t\t\tcase 'topo':\n\t\t\tcase 'gaugeRenderer':\n\t\t\tcase 'jianpu':\n\t\t\t\tres = await client.request('predict', ...args);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.logger.error(`[predictor]: no predictor ${type}`);\n\t\t}\n\n\t\tthis.logger.info(`[predictor]: ${type} py duration: ${Date.now() - start}ms`);\n\n\t\treturn res;\n\t}\n}\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Term, EventTerm, ContextedTerm, ChordmodeTerm, MarkTerm, Accessory, GraceType, TremoloLink } from './term';\nimport { HashVector } from './hashVector';\nimport { StaffLayout } from '../staffLayout';\nimport * as measureLayout from '../measureLayout';\n\ninterface Rect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\ninterface ChordRect {\n\tx: number;\n\tstemX: number;\n\twidth: number;\n\ttop: number;\n\tbottom: number;\n\tstemDirection: string;\n\ttip?: { x: number; y: number };\n}\n\ninterface VLine {\n\tx: number;\n\ty1: number;\n\ty2: number;\n}\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ntype DivisionVecotor = [number, number, number, number, number, number, number, number, number]; // [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\ntype MeasureBarType = null | 'Terminal' | 'Segment' | 'VoltaRight';\n\ninterface EventFeature {\n\tdivisions: DivisionVecotor;\n\tdots: [number, number]; // [1, 2]\n\tbeams: [number, number, number]; // ['Open', 'Continue', 'Close']\n\tstemDirections: [number, number]; // ['u', 'd']\n\tgrace: number;\n\ttremoloCatcher: number;\n}\n\ninterface EventPredisposition {\n\tgrace: boolean;\n\ttimeWarped: number;\n\tfullMeasure: number;\n\tfake: number;\n\tfakeP: number;\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tdivisionVector: DivisionVecotor;\n\tdotsVector: [number, number, number]; // [0, 1, 2]\n\tbeamVector: [number, number, number, number]; // [null, open, continue, close]\n\tstemDirectionVector: [number, number, number]; // [null, up, down]\n}\n\ninterface ChordColumn {\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\tys: number[];\n\tnoteIds: string[]; // order by upwards\n\tdivision: number;\n\tdots: number;\n\trest: boolean;\n\tstemDirection: string;\n\taccessories?: Accessory[];\n\tgrace?: GraceType;\n\ttremolo?: number;\n\ttremoloLink?: TremoloLink;\n\tbeam?: string;\n\ttip?: { x: number; y: number };\n\n\t//stemTipY?: number;\n\n\t// for topology\n\tstaff?: number;\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature?: EventFeature;\n}\n\ninterface EventMeasure {\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[];\n}\n\ninterface StaffBasic {\n\ttimeSignature: Fraction;\n\ttimeSigNumeric: boolean;\n\tkeySignature: number;\n\tdoubtfulTimesig: boolean;\n}\n\ninterface EventMeasureColumn {\n\tmeasureIndex: number;\n\t//startX: number;\n\t//width: number;\n\n\trows: EventMeasure[]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\txMap?: Map;\n\tregularLoss?: number;\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n}\n\ninterface EventSystem {\n\tstaffMask: number;\n\tcolumns: EventMeasureColumn[]; // [measure]\n}\n\ninterface TermMeasure extends Partial {\n\tterms: Term[];\n\tduration: number;\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n}\n\ntype TermRow = TermMeasure[];\n\ninterface TermStaff {\n\trows: TermRow[]; // [system]\n}\n\ninterface Pitch {\n\tnote: number;\n\talter: number;\n}\n\nenum PageLayoutMethod {\n\tByLines = 'ByLines',\n\tByBlocks = 'ByBlocks',\n}\n\ninterface RecognitionSettings {\n\tenabledGauge: boolean; // staves straighten\n\tpageLayoutMethod: PageLayoutMethod;\n\tsemanticConfidenceThreshold: number;\n}\n\ninterface Crop {\n\taspect?: number | undefined;\n\tx?: number | undefined;\n\ty?: number | undefined;\n\twidth?: number | undefined;\n\theight?: number | undefined;\n\tunit?: 'px' | '%' | undefined;\n}\n\n//\t0 2 4\t\t\tr r tx\n//\t1 3 5\t\t\tr r ty\ntype Matrix2x3 = [number, number, number, number, number, number];\n\ninterface SourceImageFile {\n\tname: string;\n\tsize: number;\n\turl: string;\n\tcrop?: Crop;\n\tmatrix: Matrix2x3;\n\tdimensions: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tinterval: number;\n\tneedGauge?: boolean;\n}\n\ninterface Area extends Rect {\n\tstaves: {\n\t\tinterval: number;\n\t\tmiddleRhos: number[];\n\t\tphi1: number;\n\t\tphi2: number;\n\t};\n}\n\ninterface PageLayout {\n\tareas: Area[];\n}\n\ninterface MeasureBrief {\n\ttimeSignature: Fraction;\n}\n\ninterface VoiceMeasure {\n\ttickMap: { [key: number]: EventTerm | ChordmodeTerm };\n\tduration: number;\n\n\ttimeSignature?: Fraction;\n\ttimeSigNumeric?: boolean;\n\tkeySignature?: number;\n\n\tcontextedTerms: ContextedTerm[];\n\tmarks: MarkTerm[];\n\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbar?: string;\n\n\tempty?: boolean;\n\n\theadStaff?: number;\n\ttailStaff?: number;\n\n\ttrait?: HashVector;\n\tvoiceIndex?: number;\n}\n\ninterface TermVoice {\n\tmode: string;\n\tmeasures: VoiceMeasure[];\n}\n\ninterface VoicesStaff {\n\tcontext?: string;\n\tname?: string;\n\tvoices: TermVoice[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n\tslashSystemSeparator: boolean;\n}\n\ninterface MusicHeaders {\n\ttitle: string;\n\tsubtitle: string;\n\tsubsubtitle: string;\n\tcomposer: string;\n\tpoet: string;\n\tarranger: string;\n\topus: string;\n\tcopyright: string;\n\tinstrument: string;\n\tdedication: string;\n\ttagline: string;\n}\n\ninterface MusicSheet {\n\ttitle: string;\n\tpageSize: {\n\t\t// in pixels\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tunitSize: number;\n\tmeasureLayout?: measureLayout.MeasureLayout;\n\tstaffLayout: StaffLayout;\n\tpaperOptions?: Partial;\n\theaders: Partial;\n\n\tvoiceStaves: VoicesStaff[];\n\tinstrumentDict: { [key: string]: string };\n}\n\ninterface Performing {\n\tnotation: MetaNotation;\n\ttokenMap: Map;\n}\n\ntype RegulationPolicy = 'test' | 'simple' | 'equations' | 'advanced';\n\ninterface RegulationOptions {\n\tpolicy?: RegulationPolicy;\n\tquota?: number;\n\t[key: string]: any;\n}\n\ninterface ScoreData {\n\tversion?: number;\n\t[key: string]: any;\n}\n\ninterface AdditionalLineStack {\n\tleft: number;\n\tright: number;\n\tn: number;\n}\n\ninterface RegulationSolutionEvent {\n\tid: number;\n\ttick: number;\n\ttickGroup: number;\n\ttimeWarp: Fraction;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: string;\n\tgrace?: boolean;\n\tfullMeasure?: boolean;\n}\n\ninterface RegulationSolution {\n\tevents: RegulationSolutionEvent[];\n\tvoices: number[][];\n\tduration: number;\n\tpriority?: number;\n\testimatedDuration?: number;\n\ttimeSignature?: Fraction;\n}\n\ninterface BackgroundImage {\n\turl: string;\n\tposition: Rect;\n\toriginal?: boolean;\n}\n\nenum TextType { //\tLEVEL\t\t\tCHARSET\n\tTitle = 'Title', // page\t\t\t\tgeneral\n\tAuthor = 'Author', // page\t\t\t\tgeneral\n\tTempoText = 'TempoText', // measure\t\t\tspecific vocabulary\n\tTempoNumeral = 'TempoNumeral', // measure\t\t\tsymbolic and numeric\n\tTextualMark = 'TextualMark', // term\t\t\t\tspecific vocabulary\n\tLyric = 'Lyric', // term\t\t\t\tgeneral\n\tInstrument = 'Instrument', // system\t\t\tspecific vocabulary\n\tMeasureNumber = 'MeasureNumber', // system\t\t\tnumeric\n\tTimes = 'Times', // staff\t\t\tnumeric\n\tAlternation1 = 'Alternation1', // measure\t\t\tnumeric\n\tAlternation2 = 'Alternation2', // measure\t\t\tnumeric\n\tChord = 'Chord', // measure\t\t\tspecific domian\n\tPageMargin = 'PageMargin', // page\t\t\t\tgeneral\n\tOther = 'Other', // page\t\t\t\tgeneral\n}\n\nexport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tFraction,\n\tMeasureBarType,\n\tEventFeature,\n\tEventPredisposition,\n\tChordColumn,\n\tEventMeasure,\n\tEventMeasureColumn,\n\tEventSystem,\n\tTermMeasure,\n\tTermRow,\n\tTermStaff,\n\tPitch,\n\tPageLayoutMethod,\n\tRecognitionSettings,\n\tSourceImageFile,\n\tPageLayout,\n\tStaffBasic,\n\tVoiceMeasure,\n\tVoicesStaff,\n\tTermVoice,\n\tMeasureBrief,\n\tAdditionalLineStack,\n\tTextType,\n\tMusicSheet,\n\tPerforming,\n\tRegulationOptions,\n\tScoreData,\n\tMusicHeaders,\n\tMatrix2x3,\n\tRegulationSolutionEvent,\n\tRegulationSolution,\n\tBackgroundImage,\n};\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","import { TextType } from './interfaces';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\n\nenum TokenType {\n\t// clefs\n\tClefG = 'clefs-G', // clefs.G_change\n\tClefF = 'clefs-F', // clefs.F_change\n\tClefC = 'clefs-C', // clefs.C_change\n\n\t// time signature\n\tTimesigC44 = 'timesig-C44',\n\tTimesigC22 = 'timesig-C22',\n\tTimesigZero = 'zero|timesig0',\n\tTimesigOne = 'one|timesig1',\n\tTimesigTwo = 'two|timesig2',\n\tTimesigThree = 'three|timesig3',\n\tTimesigFour = 'four|timesig4',\n\tTimesigFive = 'five|timesig5',\n\tTimesigSix = 'six|timesig6',\n\tTimesigSeven = 'seven|timesig7',\n\tTimesigEight = 'eight|timesig8',\n\tTimesigNine = 'nine|timesig9',\n\n\t// octave shifts\n\tOctaveShift8va = 'octave-a',\n\tOctaveShift8vb = 'octave-b',\n\tOctaveShift0 = 'octave-0',\n\n\t// numbers\n\tZero = 'zero|n0',\n\tOne = 'one|n1',\n\tTwo = 'two|n2',\n\tThree = 'three|n3',\n\tFour = 'four|n4',\n\tFive = 'five|n5',\n\tSix = 'six|n6',\n\tSeven = 'seven|n7',\n\tEight = 'eight|n8',\n\tNine = 'nine|n9',\n\n\t// accidentals\n\tAccNatural = 'accidentals-natural',\n\tAccSharp = 'accidentals-sharp',\n\tAccDoublesharp = 'accidentals-doublesharp',\n\tAccFlat = 'accidentals-flat',\n\tAccFlatflat = 'accidentals-flatflat',\n\tKeyNatural = 'accidentals-natural|key-natural',\n\tKeySharp = 'accidentals-sharp|key-sharp',\n\tKeyFlat = 'accidentals-flat|key-flat',\n\n\t// noteheads\n\tNoteheadS0 = 'noteheads-s0',\n\tNoteheadS1 = 'noteheads-s1',\n\tNoteheadS2 = 'noteheads-s2',\n\tNoteheadS1stemU = 'noteheads-s1|noteheads-s1-u',\n\tNoteheadS1stemD = 'noteheads-s1|noteheads-s1-d',\n\tNoteheadS2stemU = 'noteheads-s2|noteheads-s2-u',\n\tNoteheadS2stemD = 'noteheads-s2|noteheads-s2-d',\n\n\t// rests\n\tRest0 = 'rests-0o',\n\tRest1 = 'rests-1o',\n\tRest2 = 'rests-2',\n\tRest3 = 'rests-3',\n\tRest4 = 'rests-4',\n\tRest5 = 'rests-5',\n\tRest6 = 'rests-6',\n\tRest0W = 'rests-0',\n\tRestM1 = 'rests-M1',\n\n\t// flags\n\tFlag3 = 'flags-u3', // flags.d3\n\tFlag4 = 'flags-u4', // flags.d4\n\tFlag5 = 'flags-u5', // flags.d5\n\tFlag6 = 'flags-u6', // flags.d6\n\tFlag7 = 'flags-u7', // flags.d7\n\tFlag8 = 'flags-u8', // flags.d8\n\n\t// beams\n\tBeamLeft = '|beam-left',\n\tBeamRight = '|beam-right',\n\tBeamContinue = '|beam-continue',\n\n\t// tremolos\n\tTremoloLeft = '|tremolo-left',\n\tTremoloRight = '|tremolo-right',\n\tTremoloMiddle = '|tremolo-middle',\n\n\t// slur & tie\n\tSlurBegin = '|slur-begin',\n\tSlurEnd = '|slur-end',\n\tTieBegin = '|tie-begin',\n\tTieEnd = '|tie-end',\n\n\t// volta\n\tVoltaLeft = '|volta-left',\n\tVoltaRight = '|volta-right',\n\n\tVoltaAlternativeBegin = '|volta-alter-begin',\n\t//VoltaAlternativeEnd = \"|volta-alter-end\",\n\n\t// vertical bars\n\t//BarMeasure = \"|bar-measure\",\n\tBarTerminal = '|bar-terminal',\n\tBarSegment = '|bar-segment',\n\n\t// dots (duration)\n\tDot = '|dot',\n\tDotDot = '|dotdot',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\t//\n\tWedgeCrescendo = '|wedge-crescendo',\n\tWedgeDiminuendo = '|wedge-diminuendo',\n\tWedgeClose = '|wedge-close',\n\n\tCrescendoBegin = '|wedge-crescendo',\n\tDecrescendoBegin = '|wedge-diminuendo',\n\tCrescendoEnd = '|wedge-close',\n\tDecrescendoEnd = '|wedge-close',\n\n\t// scripts\n\tScriptFermata = 'scripts-ufermata', // scripts.dfermata\n\tScriptShortFermata = 'scripts-ushortfermata', // scripts.dshortfermata\n\tScriptSforzato = 'scripts-sforzato',\n\tScriptStaccato = 'scripts-staccato',\n\tScriptStaccatissimo = 'scripts-ustaccatissimo', // scripts.dstaccatissimo\n\tScriptTurn = 'scripts-turn',\n\tScriptTrill = 'scripts-trill',\n\tScriptSegno = 'scripts-segno',\n\tScriptCoda = 'scripts-coda',\n\tScriptArpeggio = 'scripts-arpeggio',\n\tScriptPrall = 'scripts-prall',\n\tScriptMordent = 'scripts-mordent',\n\tScriptMarcato = 'scripts-umarcato', // scripts.dmarcato\n\tScriptTenuto = 'scripts-tenuto',\n\tScriptPortato = 'scripts-uportato', // scripts.dportato\n\n\t// pedal\n\tPedalStar = 'pedal-star',\n\tPedalPed = 'pedal-Ped',\n\n\tText = '|text',\n\tGraceNotehead = '|grace-notehead',\n}\n\n// alias\nconst tt = TokenType;\n\nexport const TokenTypes = Object.values(TokenType);\nexport const TokenClefs = TokenTypes.filter((t) => /clefs-/.test(t));\nexport const TokenTimesigs = TokenTypes.filter((t) => /timesig/.test(t));\nexport const TokenTimesigsC = TokenTypes.filter((t) => /timesig-/.test(t));\nexport const TokenTimesigsN = TokenTypes.filter((t) => /timesig\\d/.test(t));\nexport const TokenOctshifts = TokenTypes.filter((t) => /octave-/.test(t));\nexport const TokenNumbers = TokenTypes.filter((t) => /n\\d/.test(t));\nexport const TokenAccidentals = TokenTypes.filter((t) => /accidentals-/.test(t));\nexport const TokenNoteheads = TokenTypes.filter((t) => /noteheads-/.test(t));\nexport const TokenBareNoteheads = [tt.NoteheadS0, tt.NoteheadS1, tt.NoteheadS2];\nexport const TokenDirectionalNoteheads = TokenTypes.filter((t) => /noteheads-.+-[ud]/.test(t));\nexport const TokenRests = TokenTypes.filter((t) => /rests-/.test(t));\nexport const TokenFlags = TokenTypes.filter((t) => /flags-/.test(t));\nexport const TokenVolta = TokenTypes.filter((t) => /volta-/.test(t));\nexport const TokenDynamics = TokenTypes.filter((t) => /^[a-z]$/.test(t));\nexport const TokenScripts = TokenTypes.filter((t) => /scripts-/.test(t));\nexport const TokenPedals = TokenTypes.filter((t) => /pedal-/.test(t));\nexport const TokenDots = [tt.Dot, tt.DotDot];\nexport const TokenArcs = [tt.SlurBegin, tt.SlurEnd, tt.TieBegin, tt.TieEnd];\nexport const TokenBeams = TokenTypes.filter((t) => /beam-/.test(t));\nexport const TokenWedges = TokenTypes.filter((t) => /wedge-/.test(t));\n\nexport const TokenAccessories = [\n\t...TokenNumbers,\n\t...TokenDynamics,\n\t...TokenWedges,\n\t...TokenPedals,\n\t...TokenArcs,\n\n\ttt.ScriptFermata,\n\ttt.ScriptShortFermata,\n\ttt.ScriptSforzato,\n\ttt.ScriptStaccato,\n\ttt.ScriptStaccatissimo,\n\ttt.ScriptTurn,\n\ttt.ScriptTrill,\n\ttt.ScriptPrall,\n\ttt.ScriptMordent,\n\ttt.ScriptMarcato,\n\ttt.ScriptTenuto,\n\ttt.ScriptPortato,\n];\n\nexport const TokenDirectionless = [...TokenPedals];\n\nexport const TokenGlyphs = [\n\t...TokenClefs,\n\t...TokenTimesigs,\n\t...TokenNumbers,\n\t...TokenAccidentals,\n\ttt.NoteheadS0,\n\ttt.NoteheadS1,\n\ttt.NoteheadS2,\n\t...TokenRests,\n\t...TokenDynamics,\n\t...TokenScripts,\n\t...TokenPedals,\n\t...TokenDots,\n];\n\nconst TOKEN_Y_ROUND = {} as Record;\nTokenClefs.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenTimesigsN.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenAccidentals.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenNoteheads.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenRests.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenDots.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\n\nconst TOKEN_Y_FIXED = {} as Record;\nTokenTimesigsC.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\nTokenVolta.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\n\nclass Token {\n\tstatic className = 'Token';\n\n\tid: string;\n\ttype: TokenType;\n\tx: number;\n\ty: number;\n\tpivotX?: number;\n\n\tconfidence: number;\n\n\ttip?: { x: number; y: number };\n\n\tvoice?: number; // integer, every bit stand for a voice\n\ttimeWarped?: boolean;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tget typeId(): string {\n\t\treturn this.type.split('|').reverse()[0];\n\t}\n\n\tget isPredicted(): boolean {\n\t\treturn Number.isFinite(this.confidence);\n\t}\n\n\tget isNotehead(): boolean {\n\t\treturn TokenDirectionalNoteheads.includes(this.type) || this.type === TokenType.NoteheadS0;\n\t}\n\n\tget isContexted(): boolean {\n\t\treturn (\n\t\t\tTokenClefs.includes(this.type) || TokenTimesigs.includes(this.type) || TokenOctshifts.includes(this.type) || TokenAccidentals.includes(this.type)\n\t\t);\n\t}\n\n\tget isAccessory(): boolean {\n\t\treturn TokenNumbers.includes(this.type) || TokenDynamics.includes(this.type) || TokenScripts.includes(this.type) || TokenPedals.includes(this.type);\n\t}\n\n\tget division(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Flag3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Flag4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Flag5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Flag6:\n\t\t\t\treturn 6;\n\n\t\t\tcase tt.Flag7:\n\t\t\t\treturn 7;\n\n\t\t\tcase tt.Flag8:\n\t\t\t\treturn 8;\n\n\t\t\tcase tt.RestM1:\n\t\t\t\treturn -1;\n\n\t\t\tcase tt.Rest0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.Rest1:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.Rest2:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Rest3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Rest4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Rest5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Rest6:\n\t\t\t\treturn 6;\n\n\t\t\t// TODO:\n\t\t\t//case tt.Rest0W:\n\t\t\t//\treturn 0;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget dots(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.Dot:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.DotDot:\n\t\t\t\treturn 2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget direction(): 'u' | 'd' | null {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn 'u';\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 'd';\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget width(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS2;\n\t\t}\n\t}\n\n\tget left(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x - this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x - this.width;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget right(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x + this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x + this.width;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget voiceIndices(): number[] {\n\t\tif (!this.voice || this.voice < 0) return [];\n\n\t\treturn Array(Math.floor(Math.log2(this.voice)) + 1)\n\t\t\t.fill(null)\n\t\t\t.reduce((indices, _, i) => (this.voice & (1 << i) ? [i + 1, ...indices] : indices), []);\n\t}\n}\n\nclass TextToken extends Token {\n\ttextType: TextType;\n\ttext: string;\n\ttextFeature?: Record;\n\twidth_: number;\n\tfontSize: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t\tObject.assign(this, data);\n\t}\n\n\tget width(): number {\n\t\treturn this.width_;\n\t}\n\n\tset width(value: number) {\n\t\tthis.width_ = value;\n\t}\n}\n\nexport { TokenType, Token, TextToken, TOKEN_Y_ROUND, TOKEN_Y_FIXED };\n","import pick from 'lodash/pick';\n\nconst recoverJSON = (json: string | object, classDict): T => {\n\tif (typeof json === 'object') json = JSON.stringify(json);\n\n\treturn JSON.parse(json, (_, value) => {\n\t\tif (value && typeof value === 'object' && value.__prototype) {\n\t\t\tconst Class = classDict[value.__prototype];\n\t\t\tif (Class) {\n\t\t\t\tconst { __prototype, ...fields } = value;\n\t\t\t\treturn new Class(fields);\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t});\n};\n\nconst deepCopy = (o: any, dict: Map = null): any => {\n\tdict = dict || new Map();\n\tif (dict.get(o)) return dict.get(o);\n\n\tif (Array.isArray(o)) {\n\t\tconst result = [];\n\t\tdict.set(o, result);\n\n\t\to.forEach((e) => result.push(deepCopy(e, dict)));\n\n\t\treturn result;\n\t} else if (o && typeof o === 'object') {\n\t\tconst result = {};\n\t\tdict.set(o, result);\n\n\t\tObject.entries(o).forEach(([key, value]) => (result[key] = deepCopy(value, dict)));\n\t\tObject.setPrototypeOf(result, o.__proto__);\n\n\t\treturn result;\n\t}\n\n\treturn o;\n};\n\nclass SimpleClass {\n\tassign(data?: object) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\ttoJSON() {\n\t\tconst cls = this.constructor as any;\n\n\t\tconst serializedKeys = cls.serializedKeys || (cls.blackKeys && Object.keys(this).filter((key) => !cls.blackKeys.includes(key)));\n\t\tconst fields = serializedKeys ? pick(this, serializedKeys) : this;\n\n\t\treturn {\n\t\t\t__prototype: cls.className,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tdeepCopy(): this {\n\t\treturn deepCopy(this);\n\t}\n}\n\nexport { recoverJSON, SimpleClass };\n","import { SimpleClass } from '../starry/aux_/typedJSON';\n\nenum LayoutType {\n\tOrdinary = 'ordinary',\n\tFull = 'full',\n\tConservative = 'conservative',\n\tOnce = 'once',\n}\n\ninterface MeasureLayout {\n\tserialize(type: LayoutType): number[];\n\n\tseq: MeasureSeq;\n\tcode: string;\n}\n\nexport type MeasureSeq = MeasureLayout[];\n\nconst spreadMeasureSeq = (seq: MeasureSeq, type: LayoutType = LayoutType.Ordinary): number[] => [].concat(...seq.map((layout) => layout.serialize(type)));\n\nconst seqToCode = (seq: MeasureSeq, { withBrackets = false }: { withBrackets?: boolean } = {}): string => {\n\t//const code = seq.map(layout => layout.code).join(\", \");\n\tlet code = '';\n\tlet inRange = false;\n\n\tfor (let i = 0; i < seq.length; ++i) {\n\t\tconst middle = seq[i - 1] instanceof SingleMLayout && seq[i] instanceof SingleMLayout && seq[i + 1] instanceof SingleMLayout;\n\t\tif (middle) {\n\t\t\tif (!inRange) {\n\t\t\t\tcode += '..';\n\t\t\t\tinRange = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (i > 0 && !inRange) code += ', ';\n\n\t\t\tinRange = false;\n\n\t\t\tcode += seq[i].code;\n\t\t}\n\t}\n\n\treturn withBrackets ? `[${code}]` : code;\n};\n\nclass SingleMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'SingleMLayout';\n\n\tmeasure: number;\n\n\tstatic from(measure: number) {\n\t\tconst layout = new SingleMLayout();\n\t\tlayout.measure = measure;\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(): number[] {\n\t\treturn [this.measure];\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this];\n\t}\n\n\tget code(): string {\n\t\treturn this.measure.toString();\n\t}\n}\n\nclass BlockMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'BlockMLayout';\n\n\tseq: MeasureSeq;\n\n\tstatic trimSeq(seq: MeasureSeq): MeasureSeq {\n\t\tconst seq2 = [];\n\t\tfor (const layout of seq) {\n\t\t\tif (layout instanceof BlockMLayout) {\n\t\t\t\tfor (const sub of layout.seq) seq2.push(sub);\n\t\t\t} else seq2.push(layout);\n\t\t}\n\n\t\t// reduce duplicated or backwards single measures\n\t\tconst seq3 = [];\n\t\tlet measure = null;\n\t\tfor (const layout of seq2) {\n\t\t\tif (layout instanceof SingleMLayout) {\n\t\t\t\tif (layout.measure > measure) {\n\t\t\t\t\tseq3.push(layout);\n\t\t\t\t\tmeasure = layout.measure;\n\t\t\t\t}\n\t\t\t} else seq3.push(layout);\n\t\t}\n\n\t\treturn seq3;\n\t}\n\n\tstatic fromSeq(seq: MeasureSeq): BlockMLayout {\n\t\tconst layout = new BlockMLayout();\n\t\tlayout.seq = BlockMLayout.trimSeq(seq);\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\treturn spreadMeasureSeq(this.seq, type);\n\t}\n\n\tget code(): string {\n\t\treturn seqToCode(this.seq, { withBrackets: true });\n\t}\n}\n\nclass VoltaMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'VoltaMLayout';\n\n\ttimes: number;\n\tbody: MeasureSeq;\n\talternates: MeasureSeq[];\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst bodySeq = spreadMeasureSeq(this.body);\n\n\t\tif (this.alternates) {\n\t\t\tconst alternateSeqs = this.alternates.map((seq) => spreadMeasureSeq(seq));\n\t\t\tconst lastAlternateSeq = alternateSeqs[alternateSeqs.length - 1];\n\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\t\treturn bodySeq.concat(...alternateSeqs);\n\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Full: {\n\t\t\t\t\tconst priorSeq = [].concat(\n\t\t\t\t\t\t...Array(this.times - 1)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map((_, i) => [...bodySeq, ...alternateSeqs[i % (this.times - 1)]])\n\t\t\t\t\t);\n\n\t\t\t\t\treturn [...priorSeq, ...bodySeq, ...lastAlternateSeq];\n\t\t\t\t}\n\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn [...bodySeq, ...lastAlternateSeq];\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn bodySeq;\n\n\t\t\t\tcase LayoutType.Full:\n\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t...Array(this.times)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map(() => bodySeq)\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconsole.warn('the current case not handled:', type, this);\n\t}\n\n\tget seq(): MeasureSeq {\n\t\tconst alternates = this.alternates ? this.alternates[this.alternates.length - 1] : [];\n\n\t\treturn [...this.body, ...alternates];\n\t}\n\n\tget code(): string {\n\t\tconst body = seqToCode(this.body, { withBrackets: true });\n\n\t\tlet code = `${this.times}*${body}`;\n\t\tif (this.alternates) code += '{' + this.alternates.map((seq) => seqToCode(seq, { withBrackets: seq.length > 1 })).join(', ') + '}';\n\n\t\treturn code;\n\t}\n}\n\nclass ABAMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'ABAMLayout';\n\n\tmain: MeasureLayout;\n\trest: MeasureSeq;\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst seqA = this.main.serialize(type);\n\t\tconst seqA_ = spreadMeasureSeq(this.main.seq, LayoutType.Once);\n\t\tconst seqB = spreadMeasureSeq(this.rest, type);\n\n\t\tswitch (type) {\n\t\t\tcase LayoutType.Ordinary: // A B\n\t\t\t\treturn [...seqA, ...seqB];\n\n\t\t\tcase LayoutType.Once: // B A'\n\t\t\t\treturn [...seqB, ...seqA_];\n\n\t\t\tcase LayoutType.Conservative: // A B A'\n\t\t\tcase LayoutType.Full: // A B A'\n\t\t\t\treturn [...seqA, ...seqB, ...seqA_];\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('the current case not handled:', type, this);\n\t\t}\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this.main, ...this.rest];\n\t}\n\n\tget code(): string {\n\t\treturn '<' + this.main.code + ', ' + seqToCode(this.rest) + '>';\n\t}\n}\n\nexport { LayoutType, MeasureLayout, SingleMLayout, BlockMLayout, VoltaMLayout, ABAMLayout };\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 13],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 15],\n\t\t$V3 = [1, 26],\n\t\t$V4 = [1, 29],\n\t\t$V5 = [1, 28],\n\t\t$V6 = [1, 30],\n\t\t$V7 = [5, 13, 22, 27, 29],\n\t\t$V8 = [2, 15],\n\t\t$V9 = [1, 32],\n\t\t$Va = [5, 14, 21, 22, 27, 28, 29];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tmeasure_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tindex_wise_measure_layout: 6,\n\t\t\t'i:': 7,\n\t\t\t's:': 8,\n\t\t\tsegment_wise_measure_layout: 9,\n\t\t\tiw_sequence: 10,\n\t\t\tiw_item: 11,\n\t\t\trange: 12,\n\t\t\t',': 13,\n\t\t\tUNSIGNED: 14,\n\t\t\t'..': 15,\n\t\t\tsingle: 16,\n\t\t\tiw_block_item: 17,\n\t\t\tiw_volta: 18,\n\t\t\tiw_aba: 19,\n\t\t\tiw_block: 20,\n\t\t\t'[': 21,\n\t\t\t']': 22,\n\t\t\t'*': 23,\n\t\t\tiw_optional_alternates: 24,\n\t\t\tiw_alternates: 25,\n\t\t\t'{': 26,\n\t\t\t'}': 27,\n\t\t\t'<': 28,\n\t\t\t'>': 29,\n\t\t\tsw_sequence: 30,\n\t\t\tsw_item: 31,\n\t\t\tsegment: 32,\n\t\t\tsw_block_item: 33,\n\t\t\tsw_volta: 34,\n\t\t\tsw_aba: 35,\n\t\t\tsw_block: 36,\n\t\t\tsw_optional_alternates: 37,\n\t\t\tsw_alternates: 38,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: {\n\t\t\t2: 'error',\n\t\t\t5: 'EOF',\n\t\t\t7: 'i:',\n\t\t\t8: 's:',\n\t\t\t13: ',',\n\t\t\t14: 'UNSIGNED',\n\t\t\t15: '..',\n\t\t\t21: '[',\n\t\t\t22: ']',\n\t\t\t23: '*',\n\t\t\t26: '{',\n\t\t\t27: '}',\n\t\t\t28: '<',\n\t\t\t29: '>',\n\t\t},\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[4, 2],\n\t\t\t[4, 2],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 3],\n\t\t\t[10, 3],\n\t\t\t[12, 3],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[16, 1],\n\t\t\t[17, 1],\n\t\t\t[20, 3],\n\t\t\t[18, 4],\n\t\t\t[24, 0],\n\t\t\t[24, 1],\n\t\t\t[25, 3],\n\t\t\t[19, 5],\n\t\t\t[9, 1],\n\t\t\t[30, 1],\n\t\t\t[30, 2],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[32, 1],\n\t\t\t[33, 1],\n\t\t\t[36, 3],\n\t\t\t[34, 4],\n\t\t\t[37, 0],\n\t\t\t[37, 1],\n\t\t\t[38, 3],\n\t\t\t[35, 4],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.$ = root(null, $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = root('index-wise', $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tthis.$ = root('segment-wise', serialize($$[$0]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 5:\n\t\t\t\tcase 23:\n\t\t\t\t\tif ($$[$0].length === 1 && $$[$0][0].__prototype === 'BlockMLayout') this.$ = $$[$0][0];\n\t\t\t\t\telse this.$ = blockLayout($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\tcase 24:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 7:\n\t\t\t\tcase 11:\n\t\t\t\tcase 12:\n\t\t\t\tcase 13:\n\t\t\t\tcase 14:\n\t\t\t\tcase 20:\n\t\t\t\tcase 27:\n\t\t\t\tcase 28:\n\t\t\t\tcase 29:\n\t\t\t\tcase 35:\n\t\t\t\t\tthis.$ = $$[$0];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 8:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 9:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], ...$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 10:\n\t\t\t\t\tthis.$ = range($$[$0 - 2], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = singleLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 16:\n\t\t\t\tcase 31:\n\t\t\t\t\tthis.$ = blockLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 17:\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 18:\n\t\t\t\tcase 33:\n\t\t\t\t\tthis.$ = voltaBlock($$[$0 - 3], $$[$0 - 1], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 19:\n\t\t\t\tcase 34:\n\t\t\t\t\tthis.$ = null;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 36:\n\t\t\t\t\tthis.$ = alternates($$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 3], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\t\tthis.$ = blockLayout([$$[$0]]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 30:\n\t\t\t\t\tthis.$ = segment($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 37:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 2], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 6: 3, 7: [1, 4], 8: [1, 5], 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 17] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 6: 18, 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 9: 19, 14: $V3, 21: $V4, 28: $V5, 30: 20, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 5: [2, 5], 13: $V6 },\n\t\t\to($V7, [2, 6]),\n\t\t\to($V7, [2, 7]),\n\t\t\to($V7, [2, 11]),\n\t\t\to($V7, [2, 12]),\n\t\t\to($V7, [2, 13]),\n\t\t\to($V7, [2, 14]),\n\t\t\to($V7, $V8, { 15: [1, 31], 23: $V9 }),\n\t\t\to($V7, [2, 16]),\n\t\t\t{ 11: 33, 14: [1, 34], 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 10: 35, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [2, 1] },\n\t\t\t{ 5: [2, 3] },\n\t\t\t{ 5: [2, 4] },\n\t\t\t{ 5: [2, 23], 14: $V3, 21: $V4, 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 24]),\n\t\t\to($Va, [2, 26]),\n\t\t\to($Va, [2, 27]),\n\t\t\to($Va, [2, 28]),\n\t\t\to($Va, [2, 29]),\n\t\t\to($Va, [2, 30], { 23: [1, 37] }),\n\t\t\to($Va, [2, 31]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 31: 38, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 39, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 11: 40, 12: 41, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 14: [1, 42] },\n\t\t\t{ 20: 43, 21: $V1 },\n\t\t\t{ 13: [1, 44] },\n\t\t\t{ 13: $V8, 23: $V9 },\n\t\t\t{ 13: $V6, 22: [1, 45] },\n\t\t\to($Va, [2, 25]),\n\t\t\t{ 21: $V4, 36: 46 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 47, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 22: [1, 48], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 8]),\n\t\t\to($V7, [2, 9]),\n\t\t\to($V7, [2, 10]),\n\t\t\to($V7, [2, 19], { 24: 49, 25: 50, 26: [1, 51] }),\n\t\t\t{ 10: 52, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\to([5, 13, 22, 26, 27, 29], [2, 17]),\n\t\t\to($Va, [2, 34], { 37: 53, 38: 54, 26: [1, 55] }),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 29: [1, 56], 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to([5, 14, 21, 22, 26, 27, 28, 29], [2, 32]),\n\t\t\to($V7, [2, 18]),\n\t\t\to($V7, [2, 20]),\n\t\t\t{ 10: 57, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 13: $V6, 29: [1, 58] },\n\t\t\to($Va, [2, 33]),\n\t\t\to($Va, [2, 35]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 59, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 37]),\n\t\t\t{ 13: $V6, 27: [1, 60] },\n\t\t\to($V7, [2, 22]),\n\t\t\t{ 14: $V3, 21: $V4, 27: [1, 61], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 21]),\n\t\t\to($Va, [2, 36]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 17: [2, 1], 18: [2, 3], 19: [2, 4] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tconst root = (type, data) => ({ __prototype: 'MesaureLayout', type, data });\n\n\tconst singleLayout = (n) => ({ __prototype: 'SingleMLayout', measure: Number(n) });\n\tconst blockLayout = (seq) => ({ __prototype: 'BlockMLayout', seq });\n\tconst voltaBlock = (times, body, alternates) => ({ __prototype: 'VoltaMLayout', times: Number(times), body, alternates });\n\tconst abaBlock = (main, rest) => ({ __prototype: 'ABAMLayout', main, rest });\n\n\tconst segment = (n) => ({ segment: true, length: Number(n) });\n\n\tconst alternates = (items) =>\n\t\titems.map((item) => {\n\t\t\tif (item.__prototype === 'BlockMLayout') return item.seq;\n\n\t\t\treturn [item];\n\t\t});\n\n\tconst range = (start, end) => {\n\t\tstart = Number(start);\n\t\tend = Number(end);\n\n\t\tif (!(end >= start)) throw new Error(`invalid measure range: ${start}..${end}`);\n\n\t\treturn Array(end + 1 - start)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => singleLayout(start + i));\n\t};\n\n\tconst serializeSeq = (item, options) => {\n\t\tif (item.segment) {\n\t\t\tconst index = options.index;\n\t\t\toptions.index += item.length;\n\n\t\t\treturn Array(item.length)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => singleLayout(index + i));\n\t\t}\n\n\t\treturn [serialize(item, options)];\n\t};\n\n\tconst serialize = (item, options = { index: 1 }) => {\n\t\tconst speard = (seq) => [].concat(...seq.map((it) => serializeSeq(it, options)));\n\n\t\tswitch (item.__prototype) {\n\t\t\tcase 'BlockMLayout':\n\t\t\t\titem.seq = speard(item.seq);\n\n\t\t\t\tbreak;\n\t\t\tcase 'VoltaMLayout':\n\t\t\t\titem.body = speard(item.body);\n\t\t\t\titem.alternates = item.alternates && item.alternates.map(speard);\n\n\t\t\t\tbreak;\n\t\t\tcase 'ABAMLayout':\n\t\t\t\titem.main = serialize(item.main, options);\n\t\t\t\titem.rest = speard(item.rest);\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn item;\n\t};\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 14;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([*,\\[\\]<>{}]))/, /^(?:(([1-9])([0-9])*))/, /^(?:(([a-z])+):)/, /^(?:\\.\\.)/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3, 4, 5], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import type { MeasureLayout } from './measureLayout';\nimport * as measureLayout from './measureLayout';\nimport grammar from './grammar.jison';\nimport { recoverJSON } from '../starry/aux_/typedJSON';\n\nconst parseCode = (code: string): MeasureLayout => {\n\tconst raw = grammar.parse(code);\n\n\tif (raw?.data) return recoverJSON(raw.data, measureLayout);\n\n\treturn null;\n};\n\nexport { parseCode };\n","export interface RawItem {\n\tid: string;\n\tleftBounds: string[];\n\trightBounds: string[];\n\tconjunction: string;\n}\n\nexport enum StaffGroupType {\n\tDefault,\n\tBrace, // {}\n\tBracket, // <>\n\tSquare, // []\n}\n\nexport enum StaffConjunctionType {\n\tBlank,\n\tDashed,\n\tSolid,\n}\n\ntype StaffID = string;\n\nexport interface StaffGroup {\n\ttype: StaffGroupType;\n\tsubs?: StaffGroup[];\n\tstaff?: StaffID;\n\tlevel?: number;\n\tgrand?: boolean;\n}\n\ninterface StaffGroupTrait {\n\tgroup: StaffGroup;\n\trange: [number, number];\n\tkey: string;\n}\n\nconst singleGroup = (id: string) => ({ type: StaffGroupType.Default, staff: id });\n\nconst BOUNDS_TO_GROUPTYPE: { [bound: string]: StaffGroupType } = {\n\t'{': StaffGroupType.Brace,\n\t'}': StaffGroupType.Brace,\n\t'<': StaffGroupType.Bracket,\n\t'>': StaffGroupType.Bracket,\n\t'[': StaffGroupType.Square,\n\t']': StaffGroupType.Square,\n};\n\nconst OPEN_BOUNDS = '{<[';\nconst CLOSE_BOUNDS = '}>]';\n\nconst CONJUNCTIONS_MAP: { [conj: string]: StaffConjunctionType } = {\n\t',': StaffConjunctionType.Blank,\n\t'-': StaffConjunctionType.Solid,\n\t'.': StaffConjunctionType.Dashed,\n};\n\nconst bracketCode = (type: StaffGroupType, partial: boolean = false): ((inner: string) => string) => {\n\tif (type === StaffGroupType.Default) return (inner) => inner;\n\n\tif (partial) {\n\t\tswitch (type) {\n\t\t\tcase StaffGroupType.Brace:\n\t\t\t\treturn (inner) => `{${inner}`;\n\t\t\tcase StaffGroupType.Bracket:\n\t\t\t\treturn (inner) => `<${inner}`;\n\t\t\tcase StaffGroupType.Square:\n\t\t\t\treturn (inner) => `[${inner}`;\n\t\t\tdefault:\n\t\t\t\treturn (inner) => inner;\n\t\t}\n\t}\n\n\tswitch (type) {\n\t\tcase StaffGroupType.Brace:\n\t\t\treturn (inner) => `{${inner}}`;\n\t\tcase StaffGroupType.Bracket:\n\t\t\treturn (inner) => `<${inner}>`;\n\t\tcase StaffGroupType.Square:\n\t\t\treturn (inner) => `[${inner}]`;\n\t\tdefault:\n\t\t\treturn (inner) => inner;\n\t}\n};\n\nconst randomB64 = (): string => {\n\tconst code = btoa(Math.random().toString().substr(2)).replace(/=/g, '');\n\n\treturn code.split('').reverse().slice(0, 6).join('');\n};\n\nconst makeUniqueName = (set: Set, index: number, prefix?: string): string => {\n\tlet name = prefix;\n\tif (!name) name = index.toString();\n\telse if (set.has(name)) name += '_' + index.toString();\n\n\twhile (set.has(name)) name += '_' + randomB64();\n\n\treturn name;\n};\n\nconst makeGroupsFromRaw = (parent: StaffGroup, seq: string[]): string[] => {\n\tlet remains = seq;\n\twhile (remains.length) {\n\t\tconst word = remains.shift();\n\t\tconst bound = BOUNDS_TO_GROUPTYPE[word];\n\t\tif (bound) {\n\t\t\tif (CLOSE_BOUNDS.includes(word) && bound === parent.type) break;\n\n\t\t\tif (OPEN_BOUNDS.includes(word)) {\n\t\t\t\tconst group = { type: bound, level: Number.isFinite(parent.level) ? parent.level + 1 : 0 };\n\t\t\t\tremains = makeGroupsFromRaw(group, remains);\n\n\t\t\t\tparent.subs = parent.subs || [];\n\t\t\t\tparent.subs.push(group);\n\t\t\t}\n\t\t} else {\n\t\t\tparent.subs = parent.subs || [];\n\t\t\tparent.subs.push(singleGroup(word));\n\t\t}\n\t}\n\n\twhile (parent.type === StaffGroupType.Default && parent.subs && parent.subs.length === 1) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.type = sub.type;\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t\tparent.level = sub.level;\n\t}\n\n\twhile (parent.subs && parent.subs.length === 1 && parent.subs[0].type === StaffGroupType.Default) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t}\n\n\tparent.grand = parent.type === StaffGroupType.Brace && parent.subs && parent.subs.every((sub) => sub.staff);\n\n\treturn remains;\n};\n\nconst groupHead = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupHead(group.subs[0]);\n};\n\nconst groupTail = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupTail(group.subs[group.subs.length - 1]);\n};\n\nexport const groupKey = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return `${groupHead(group)}-${groupTail(group)}`;\n};\n\nconst groupDict = (group: StaffGroup, dict: { [key: string]: StaffGroup }): void => {\n\tdict[groupKey(group)] = group;\n\n\tif (group.subs) group.subs.forEach((sub) => groupDict(sub, dict));\n};\n\nexport interface MaskedStaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroups: StaffGroupTrait[];\n}\n\nclass StaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroup: StaffGroup;\n\tgroups: StaffGroupTrait[];\n\n\tmaskCache: Map;\n\n\tconstructor(raw: RawItem[]) {\n\t\t// make unique ids\n\t\tconst ids = new Set();\n\t\traw.forEach((item, i) => {\n\t\t\titem.id = makeUniqueName(ids, i + 1, item.id);\n\t\t\tids.add(item.id);\n\t\t});\n\t\tthis.staffIds = raw.map((item) => item.id);\n\t\tthis.conjunctions = raw.slice(0, raw.length - 1).map((item) => (item.conjunction ? CONJUNCTIONS_MAP[item.conjunction] : StaffConjunctionType.Blank));\n\n\t\t// make groups\n\t\tconst seq = [].concat(...raw.map((item) => [...item.leftBounds, item.id, ...item.rightBounds]));\n\t\tthis.group = { type: StaffGroupType.Default };\n\t\tmakeGroupsFromRaw(this.group, seq);\n\n\t\tconst dict = {};\n\t\tgroupDict(this.group, dict);\n\t\tthis.groups = Object.entries(dict).map(([key, group]) => {\n\t\t\tlet ids = key.split('-');\n\t\t\tif (ids.length === 1) ids = [ids[0], ids[0]];\n\t\t\tconst range = ids.map((id) => this.staffIds.indexOf(id));\n\n\t\t\treturn {\n\t\t\t\tgroup,\n\t\t\t\trange,\n\t\t\t\tkey,\n\t\t\t} as StaffGroupTrait;\n\t\t});\n\n\t\tthis.maskCache = new Map();\n\t}\n\n\tget stavesCount(): number {\n\t\tif (!this.staffIds) return null;\n\n\t\treturn this.staffIds.length;\n\t}\n\n\tget partGroups(): StaffGroupTrait[] {\n\t\tconst grands = this.groups.filter((g) => g.group.grand);\n\t\tconst parts = this.groups.filter((g) => {\n\t\t\tif (g.group.grand) return true;\n\n\t\t\tif (g.range[0] === g.range[1]) {\n\t\t\t\tconst index = g.range[0];\n\t\t\t\treturn !grands.some((g) => g.range[0] <= index && g.range[1] >= index);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn parts;\n\t}\n\n\tget standaloneGroups(): string[][] {\n\t\tconst groups: string[][] = [];\n\t\tconst collect = (group: StaffGroup): void => {\n\t\t\tif (group.grand) groups.push(group.subs.map((sub) => sub.staff));\n\t\t\telse if (group.staff) groups.push([group.staff]);\n\t\t\telse if (group.subs) group.subs.forEach((sub) => collect(sub));\n\t\t};\n\t\tcollect(this.group);\n\n\t\treturn groups;\n\t}\n\n\tconjunctionBetween(upStaff: number, downStaff: number): StaffConjunctionType {\n\t\tif (downStaff <= upStaff) return null;\n\n\t\tlet con = StaffConjunctionType.Solid;\n\t\tfor (let i = upStaff; i < downStaff; i++) con = Math.min(con, this.conjunctions[i]);\n\n\t\treturn con;\n\t}\n\n\tstatic makeMaskLayout(layout: StaffLayout, mask: number): MaskedStaffLayout {\n\t\tconst staffIds = layout.staffIds.filter((_, i) => mask & (1 << i));\n\t\tif (staffIds.length === layout.staffIds.length) {\n\t\t\treturn {\n\t\t\t\tstaffIds: layout.staffIds,\n\t\t\t\tconjunctions: layout.conjunctions,\n\t\t\t\tgroups: layout.groups,\n\t\t\t};\n\t\t}\n\n\t\tconst groups = layout.groups\n\t\t\t.map((g) => ({ ids: layout.staffIds.slice(g.range[0], g.range[1] + 1).filter((id) => staffIds.includes(id)), ...g }))\n\t\t\t.filter(({ ids }) => ids.length)\n\t\t\t.map(\n\t\t\t\t({ ids, ...g }) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tkey: g.key,\n\t\t\t\t\t\tgroup: g.group,\n\t\t\t\t\t\trange: [staffIds.indexOf(ids[0]), staffIds.indexOf(ids[ids.length - 1])],\n\t\t\t\t\t} as StaffGroupTrait)\n\t\t\t);\n\n\t\tconst conjunctions = staffIds.slice(0, staffIds.length - 1).map((id, i) => {\n\t\t\tconst nextId = staffIds[i + 1];\n\t\t\treturn layout.conjunctionBetween(layout.staffIds.indexOf(id), layout.staffIds.indexOf(nextId));\n\t\t});\n\n\t\treturn {\n\t\t\tstaffIds,\n\t\t\tconjunctions,\n\t\t\tgroups,\n\t\t};\n\t}\n\n\tmask(mask: number): MaskedStaffLayout {\n\t\tif (!this.maskCache.get(mask)) this.maskCache.set(mask, StaffLayout.makeMaskLayout(this, mask));\n\n\t\treturn this.maskCache.get(mask);\n\t}\n\n\t// {,}\t*\t1,1\t\t=> {,}\n\t// {,}\t*\t1,x\t\t=> {\n\t// {,}\t*\t0,x\t\t=>\n\t// {,}\t*\t0,1\t\t=> {}\n\tpartialMaskCode(bits: (1 | 0)[], withIds = false): string {\n\t\ttype Attendance = 0 | 1 | null;\n\t\tconst staffStatus = this.staffIds\n\t\t\t.map((_, i) => (i < bits.length ? bits[i] : null))\n\t\t\t.reduce((status, x, i) => {\n\t\t\t\tstatus[this.staffIds[i]] = x;\n\t\t\t\treturn status;\n\t\t\t}, {} as { [id: string]: Attendance });\n\n\t\tconst joinGroup = (group: StaffGroup): [string, boolean] => {\n\t\t\tif (group.staff) return [staffStatus[group.staff] ? group.staff : null, staffStatus[group.staff] === null];\n\n\t\t\tconst subs = group.subs.map((sub) => joinGroup(sub));\n\t\t\tconst subStr = subs\n\t\t\t\t.map((pair) => pair[0])\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(',');\n\t\t\tconst partial = subs.some(([_, partial]) => partial);\n\n\t\t\tconst code = subStr ? bracketCode(group.type, partial)(subStr) : null;\n\n\t\t\treturn [code, partial];\n\t\t};\n\n\t\tlet [code] = joinGroup(this.group);\n\t\tcode = code || '';\n\t\tif (!withIds) code = code.replace(/[_\\w]+/g, '');\n\n\t\treturn code;\n\t}\n}\n\nexport default StaffLayout;\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 15],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 17],\n\t\t$V3 = [1, 11],\n\t\t$V4 = [1, 12],\n\t\t$V5 = [1, 13],\n\t\t$V6 = [1, 24],\n\t\t$V7 = [1, 25],\n\t\t$V8 = [1, 26],\n\t\t$V9 = [5, 11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Va = [15, 16, 17, 21, 22, 23, 24],\n\t\t$Vb = [11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Vc = [5, 11, 12, 13, 21, 22, 23, 24];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tstaff_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tseq: 6,\n\t\t\tseq_id: 7,\n\t\t\tseq_br: 8,\n\t\t\tseq_con: 9,\n\t\t\tbound_left: 10,\n\t\t\t'<': 11,\n\t\t\t'[': 12,\n\t\t\t'{': 13,\n\t\t\tbound_right: 14,\n\t\t\t'>': 15,\n\t\t\t']': 16,\n\t\t\t'}': 17,\n\t\t\tbound_lefts: 18,\n\t\t\tbound_rights: 19,\n\t\t\tconjunction: 20,\n\t\t\t'-': 21,\n\t\t\t',': 22,\n\t\t\t'.': 23,\n\t\t\tID: 24,\n\t\t\tseq_bl: 25,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: { 2: 'error', 5: 'EOF', 11: '<', 12: '[', 13: '{', 15: '>', 16: ']', 17: '}', 21: '-', 22: ',', 23: '.', 24: 'ID' },\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[6, 0],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[18, 1],\n\t\t\t[18, 2],\n\t\t\t[19, 1],\n\t\t\t[19, 2],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[7, 1],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[25, 1],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[9, 1],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\t$$[$0].next();\n\n\t\t\t\t\tthis.$ = $$[$0].toJSON();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = new Seq();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 13:\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 14:\n\t\t\t\tcase 16:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 20:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.i($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 23:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\tcase 24:\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.bl($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\tcase 27:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 28:\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 29:\n\t\t\t\tcase 30:\n\t\t\t\tcase 31:\n\t\t\t\t\t$$[$0 - 1].tip.br($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.con($$[$0]);\n\t\t\t\t\tthis.$.next();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 33:\n\t\t\t\tcase 34:\n\t\t\t\tcase 35:\n\t\t\t\tcase 36:\n\t\t\t\t\t$$[$0 - 1].tip.con($$[$0]);\n\t\t\t\t\t$$[$0 - 1].next();\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 5: [2, 3], 6: 3, 7: 4, 8: 5, 9: 6, 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 10, 20: 9, 21: $V3, 22: $V4, 23: $V5, 24: [1, 7], 25: 8 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 18] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 5: [2, 4], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 22, 19: 20, 20: 21, 21: $V3, 22: $V4, 23: $V5, 24: [1, 19] },\n\t\t\t{ 5: [2, 5], 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 29, 20: 28, 21: $V3, 22: $V4, 23: $V5, 24: [1, 27] },\n\t\t\t{ 5: [2, 6], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 33, 19: 31, 20: 32, 21: $V3, 22: $V4, 23: $V5, 24: [1, 30] },\n\t\t\to($V9, [2, 20]),\n\t\t\t{ 14: 23, 15: $V6, 16: $V7, 17: $V8, 19: 35, 20: 36, 21: $V3, 22: $V4, 23: $V5, 24: [1, 34] },\n\t\t\to($V9, [2, 32]),\n\t\t\to($Va, [2, 25], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 17]),\n\t\t\to($V9, [2, 18]),\n\t\t\to($V9, [2, 19]),\n\t\t\to($Vb, [2, 13]),\n\t\t\to($Vb, [2, 7]),\n\t\t\to($Vb, [2, 8]),\n\t\t\to($Vb, [2, 9]),\n\t\t\t{ 1: [2, 1] },\n\t\t\to($V9, [2, 21]),\n\t\t\to($Vc, [2, 29], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 33]),\n\t\t\to($Va, [2, 26], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 15]),\n\t\t\to($V9, [2, 10]),\n\t\t\to($V9, [2, 11]),\n\t\t\to($V9, [2, 12]),\n\t\t\to($V9, [2, 23]),\n\t\t\to($V9, [2, 35]),\n\t\t\to($Va, [2, 27], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 24]),\n\t\t\to($Vc, [2, 31], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 36]),\n\t\t\to($Va, [2, 28], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 22]),\n\t\t\to($Vc, [2, 30], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 34]),\n\t\t\to($Vb, [2, 14]),\n\t\t\to($V9, [2, 16]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 18: [2, 1] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tclass Item {\n\t\tconstructor() {\n\t\t\tthis.id = null;\n\t\t\tthis.leftBounds = [];\n\t\t\tthis.rightBounds = [];\n\t\t\tthis.conjunction = null;\n\t\t}\n\n\t\ti(id) {\n\t\t\tthis.id = id;\n\t\t\treturn this;\n\t\t}\n\n\t\tbl(leftBounds) {\n\t\t\tthis.leftBounds = leftBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tbr(rightBounds) {\n\t\t\tthis.rightBounds = rightBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tcon(conjunction) {\n\t\t\tthis.conjunction = conjunction;\n\t\t\treturn this;\n\t\t}\n\t}\n\n\tclass Seq {\n\t\tconstructor() {\n\t\t\tthis.body = [];\n\t\t\tthis.tip = new Item();\n\t\t}\n\n\t\tnext() {\n\t\t\tthis.body.push(this.tip);\n\t\t\tthis.tip = new Item();\n\t\t\treturn this;\n\t\t}\n\n\t\ttoJSON() {\n\t\t\treturn this.body;\n\t\t}\n\t}\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 24;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([-,.\\[\\]<>{}]))/, /^(?:([a-zA-Z_0-9]+))/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\n// if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import StaffLayout from './staffLayout';\nimport grammar from './grammar.jison';\n\nconst parseCode = (code: string): StaffLayout => {\n\tconst raw = grammar.parse(code);\n\n\treturn new StaffLayout(raw);\n};\n\nexport { parseCode };\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","import { Fraction, Pitch, EventFeature, EventPredisposition } from './interfaces';\nimport { gcd, reducedFraction } from './utils';\nimport { TokenType } from './token';\nimport * as Token from './token';\nimport { SimpleClass } from './aux_/typedJSON';\n\nconst WHOLE_DURATION = 128 * 3 * 5;\nconst WHOLE_EXP2 = WHOLE_DURATION / 15;\n\nenum AccessoryDirection {\n\tUp = '^',\n\tDown = '_',\n\tMiddle = '-',\n}\n\nenum GraceType {\n\tGrace = 'grace',\n\tAfterGrace = 'afterGrace',\n\tAcciaccatura = 'acciaccatura',\n\tAppoggiatura = 'appoggiatura',\n\tSlashedGrace = 'slashedGrace',\n}\n\nenum StemBeam {\n\tOpen = 'Open',\n\tClose = 'Close',\n\tContinue = 'Continue',\n}\n\nenum TremoloLink {\n\tPitcher = 'Pitcher',\n\tCatcher = 'Catcher',\n\tPierced = 'Pierced',\n}\n\nenum GlissandoStyle {\n\tNormal = 'normal',\n\tDashedLine = 'dashed-line',\n\tDottedLine = 'dotted-line',\n\tZigzag = 'zigzag',\n\tTrill = 'trill',\n}\n\nenum ArpeggioStyle {\n\tNormal = 'Normal',\n\tBracket = 'Bracket',\n\tParenthesis = 'Parenthesis',\n\tParenthesisDashed = 'ParenthesisDashed',\n\tArrowDown = 'ArrowDown',\n}\n\ninterface Accessory {\n\tdirection?: AccessoryDirection;\n\tparenthesized?: boolean;\n\ttype: TokenType;\n\tid?: string;\n\tx: number;\n}\n\ninterface TermPitch extends Pitch {\n\ttying?: boolean;\n\ttied?: boolean;\n\tparenthesized?: boolean;\n\toctaveShift?: number;\n}\n\nclass Term extends SimpleClass {\n\tx: number;\n\tstaff?: number;\n}\n\ntype RestType = 'r' | 'R' | 's' | null;\n\ninterface DurationalTerm {\n\tdivision: number;\n\tdots: number;\n\tmultiplier?: Fraction;\n}\n\nconst SCALE_NAMES = 'CDEFGAB';\n\nclass EventTerm extends Term implements DurationalTerm {\n\tstatic className = 'EventTerm';\n\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\n\tsystem: number;\n\troundX: number; // for tick map, scheduler\n\tintX: number; // for measure hash\n\tintY: number;\n\tys: number[]; // order by ascending pitch, low (greater Y) to high (less Y)\n\tpitches?: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\taccessories: Accessory[];\n\tmultiplier: Fraction;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\trepetitionChord: boolean;\n\tgrace?: GraceType;\n\tbeam?: StemBeam;\n\ttimeWarp?: Fraction;\n\tparenthesized?: boolean;\n\ttremolo?: number; // like division, 'number of beams' + 2\n\ttremoloLink?: TremoloLink;\n\tglissando?: boolean;\n\tglissandoStyle?: GlissandoStyle;\n\tarpeggioStyle?: ArpeggioStyle;\n\ttip?: { x: number; y: number };\n\n\ttick: number;\n\n\t// for topology\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature: EventFeature;\n\tpredisposition: EventPredisposition;\n\n\tgraceIds?: number[];\n\tcatcherId?: number; // tremolo catcher event ID for tremolo pitcher event\n\n\tnoteIds?: string[]; // order by upwards\n\n\tstatic space({ tick, duration }: { tick: number; duration: number }): EventTerm {\n\t\tconst term = new EventTerm({\n\t\t\trest: 's',\n\t\t\ttick,\n\t\t\taccessories: [],\n\t\t});\n\t\tterm.duration = Math.round(duration);\n\n\t\treturn term;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tObject.assign(this, data);\n\n\t\tif (Number.isFinite(data.left) && Number.isFinite(data.right)) this.x = (this.left + this.right) / 2;\n\t\tif (!Number.isFinite(this.pivotX)) this.pivotX = this.x;\n\t\t//console.assert(Number.isFinite(this.x), \"EventTerm: invalid x,\", data);\n\t}\n\n\tget alignedTick(): number {\n\t\treturn this.grace ? this.tick + this.duration : this.tick;\n\t}\n\n\tget mainDuration(): number {\n\t\treturn WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t}\n\n\tget duration(): number {\n\t\tlet value = this.mainDuration;\n\t\tif (this.multiplier) value *= this.multiplier.numerator / this.multiplier.denominator;\n\t\tif (this.timeWarp) value *= this.timeWarp.numerator / this.timeWarp.denominator;\n\n\t\treturn this.grace ? value / 8 : value;\n\t}\n\n\tset duration(value: number) {\n\t\tconsole.assert(Number.isFinite(value), 'invalid duration value:', value);\n\n\t\tconst divider = gcd(value, WHOLE_EXP2);\n\t\tconst division = Math.log2(WHOLE_EXP2 / divider);\n\t\tconst multiplier = reducedFraction(value * 2 ** division, WHOLE_DURATION);\n\n\t\tthis.division = division;\n\t\tthis.dots = 0;\n\n\t\tif (multiplier.numerator !== multiplier.denominator) this.multiplier = multiplier;\n\t\telse this.multiplier = undefined;\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget times(): string {\n\t\tif (!this.timeWarp) return null;\n\n\t\treturn `${this.timeWarp.numerator}/${this.timeWarp.denominator}`;\n\t}\n\n\tget fullMeasureRest(): boolean {\n\t\treturn this.rest === 'R';\n\t}\n\n\tget tipX(): number {\n\t\treturn this.tip ? this.tip.x : this.x;\n\t}\n\n\tget tipY(): number {\n\t\treturn this.tip ? this.tip.y : this.ys ? this.ys[0] : 0;\n\t}\n\n\tget tremoloCatcher(): boolean {\n\t\treturn this.tremoloLink === TremoloLink.Catcher;\n\t}\n\n\tget scaleChord(): string {\n\t\treturn this.pitches.map((pitch) => SCALE_NAMES[(pitch.note + 700) % 7]).join('');\n\t}\n\n\tget zeroHolder(): boolean {\n\t\treturn !!this.grace || this.tremoloCatcher;\n\t}\n}\n\nenum ContextType {\n\tClef,\n\tKeyAcc,\n\tAcc,\n\tOctaveShift,\n\tTimeSignatureC,\n\tTimeSignatureN,\n}\n\nclass ContextedTerm extends Term {\n\tstatic className = 'ContextedTerm';\n\n\ty: number;\n\ttokenType: TokenType;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget type(): ContextType {\n\t\tif (Token.TokenClefs.includes(this.tokenType)) return ContextType.Clef;\n\t\tif (/\\|key-/.test(this.tokenType)) return ContextType.KeyAcc;\n\t\tif (/accidentals-/.test(this.tokenType)) return ContextType.Acc;\n\t\tif (Token.TokenOctshifts.includes(this.tokenType)) return ContextType.OctaveShift;\n\t\tif (Token.TokenTimesigsC.includes(this.tokenType)) return ContextType.TimeSignatureC;\n\t\tif (Token.TokenTimesigsN.includes(this.tokenType)) return ContextType.TimeSignatureN;\n\n\t\treturn null;\n\t}\n\n\tget staffLevel(): boolean {\n\t\treturn [ContextType.OctaveShift, ContextType.Clef, ContextType.KeyAcc].includes(this.type);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.1;\n\t}\n\n\tget clef(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.ClefG:\n\t\t\t\treturn -this.y - 2;\n\n\t\t\tcase TokenType.ClefF:\n\t\t\t\treturn -this.y + 2;\n\n\t\t\tcase TokenType.ClefC:\n\t\t\t\treturn -this.y;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget alter() {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.AccNatural:\n\t\t\tcase TokenType.KeyNatural:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.AccSharp:\n\t\t\tcase TokenType.KeySharp:\n\t\t\t\treturn 1;\n\n\t\t\tcase TokenType.AccFlat:\n\t\t\tcase TokenType.KeyFlat:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.AccDoublesharp:\n\t\t\t\treturn 2;\n\n\t\t\tcase TokenType.AccFlatflat:\n\t\t\t\treturn -2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget octaveShift(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.OctaveShift8va:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.OctaveShift0:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.OctaveShift8vb:\n\t\t\t\treturn 1;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget number(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.TimesigZero:\n\t\t\t\treturn 0;\n\t\t\tcase TokenType.TimesigOne:\n\t\t\t\treturn 1;\n\t\t\tcase TokenType.TimesigTwo:\n\t\t\t\treturn 2;\n\t\t\tcase TokenType.TimesigThree:\n\t\t\t\treturn 3;\n\t\t\tcase TokenType.TimesigFour:\n\t\t\t\treturn 4;\n\t\t\tcase TokenType.TimesigFive:\n\t\t\t\treturn 5;\n\t\t\tcase TokenType.TimesigSix:\n\t\t\t\treturn 6;\n\t\t\tcase TokenType.TimesigSeven:\n\t\t\t\treturn 7;\n\t\t\tcase TokenType.TimesigEight:\n\t\t\t\treturn 8;\n\t\t\tcase TokenType.TimesigNine:\n\t\t\t\treturn 9;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n//class BreakTerm extends Term {\n//};\n\nclass MarkTerm extends Term {\n\tstatic className = 'MarkTerm';\n\n\ttick: number;\n\n\tget prior(): number {\n\t\treturn this.tick + 0.01;\n\t}\n}\n\nconst MUSIC_NOTES = Array(7)\n\t.fill(0)\n\t.map((_, i) => String.fromCodePoint(0x1d15d + i));\n\nclass TempoTerm extends MarkTerm {\n\tstatic className = 'TempoTerm';\n\n\tduration: string;\n\tbeats: string;\n\n\tstatic fromNumeralText(text: string): TempoTerm {\n\t\tif (/.+=.*\\d+/.test(text)) {\n\t\t\tconst [symbol, value] = text.split('=');\n\t\t\tlet division = MUSIC_NOTES.findIndex((n) => symbol.includes(n));\n\t\t\tdivision = division >= 0 ? division : 2;\n\t\t\tlet duration = (2 ** division).toString();\n\t\t\tif (symbol.includes('.')) duration += '.';\n\n\t\t\treturn new TempoTerm({ tick: 0, duration, beats: value });\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.01;\n\t}\n\n\t// a whole note equal to 1920\n\tget durationMagnitude(): number {\n\t\tconst [_, den, dot] = this.duration.match(/^(\\d+)(\\.)?$/);\n\t\tconst magnitude = (WHOLE_DURATION / Number(den)) * (dot ? 1.5 : 1);\n\n\t\treturn magnitude;\n\t}\n\n\t// beats per minute, suppose 1 beat = 480 ticks\n\tget bpm(): number {\n\t\tconst [number] = this.beats.match(/\\d+/) || [90];\n\t\tconst beats = Number(number);\n\n\t\treturn (beats * this.durationMagnitude * 4) / WHOLE_DURATION;\n\t}\n\n\tisValid(range = [10, 400]): boolean {\n\t\tconst bpm = this.bpm;\n\n\t\treturn Number.isFinite(this.bpm) && bpm >= range[0] && bpm < range[1];\n\t}\n}\n\nclass GlyphTerm extends MarkTerm {\n\tstatic className = 'GlyphTerm';\n\n\tglyph: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass TextTerm extends MarkTerm {\n\tstatic className = 'TextTerm';\n\n\tdirection?: AccessoryDirection;\n\ttext: string;\n\tbold: boolean;\n\titalic: boolean;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass LyricTerm extends MarkTerm {\n\tstatic className = 'LyricTerm';\n\n\ttext: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass CommandTerm extends MarkTerm {\n\tstatic className = 'CommandTerm';\n\n\tcommand: string;\n\tparameters: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass ChordmodeTerm extends Term implements DurationalTerm {\n\tstatic className = 'ChordmodeTerm';\n\n\tpitch: Pitch;\n\tbasePitch?: Pitch;\n\tmodifier?: string;\n\n\tdivision: number;\n\tdots: number;\n\tmultiplier: Fraction;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget duration(): number {\n\t\tconst value = WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t\tif (this.multiplier) return (value * this.multiplier.numerator) / this.multiplier.denominator;\n\n\t\treturn value;\n\t}\n}\n\nexport {\n\tTerm,\n\tEventTerm,\n\tContextedTerm,\n\t//BreakTerm,\n\tMarkTerm,\n\tTempoTerm,\n\tGlyphTerm,\n\tTextTerm,\n\tLyricTerm,\n\tCommandTerm,\n\tChordmodeTerm,\n\tDurationalTerm,\n\tContextType,\n\tGraceType,\n\tTermPitch,\n\tRestType,\n\tGlissandoStyle,\n\tArpeggioStyle,\n\tAccessory,\n\tAccessoryDirection,\n\tWHOLE_DURATION,\n\tStemBeam,\n\tTremoloLink,\n};\n","import { fractionMul, gcd } from './utils';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { StemBeam, WHOLE_DURATION } from './term';\n\nexport interface MeasureEvaluation {\n\tevents: number;\n\tvalidEvents: number;\n\tvoiceRugged: boolean;\n\tnullEvents: number;\n\tfakeEvents: number;\n\twarpedEvents: number;\n\tcomplicatedTimewarp: boolean;\n\tspaceTime: number;\n\tsurplusTime: number;\n\tdurationRate: number;\n\tbeamBroken: boolean;\n\tfractionalWarp: boolean;\n\tirregularWarpsN: number;\n\tirregularTick: boolean;\n\ttickTwist: number;\n\ttickOverlapped: boolean;\n\tgraceInVoice: boolean;\n\tgraceN: number;\n\tgraceDominant: boolean;\n\tperfect: boolean;\n\tfine: boolean;\n\terror: boolean;\n\tqualityScore: number;\n}\n\nconst BEAM_STATUS = {\n\t[StemBeam.Open]: 1,\n\t[StemBeam.Continue]: 0,\n\t[StemBeam.Close]: -1,\n};\n\nexport const evaluateMeasure = (measure: SpartitoMeasure): MeasureEvaluation => {\n\tif (!measure.regulated) return undefined;\n\n\tconst eventMap = measure.eventMap;\n\n\tconst events = measure.events.length;\n\tconst validEvents = measure.voices.flat(1).length;\n\tconst warpedEvents = measure.events.filter((e) => e.timeWarp).length;\n\tconst warps = new Set(\n\t\tmeasure.events.filter((e) => e.timeWarp && !(e.rest && e.division === 0)).map((e) => `${e.timeWarp!.numerator}/${e.timeWarp!.denominator}`)\n\t);\n\tconst irregularWarps = new Set(warps);\n\tirregularWarps.delete('2/3');\n\n\tconst fractionalWarp = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tif (!events.some((e) => e.timeWarp)) return false;\n\n\t\tlet denominator = 0;\n\t\tlet tickSum = 0;\n\t\tlet eventN = 0;\n\t\treturn events.some((event, i) => {\n\t\t\tconst d = event.timeWarp ? event.timeWarp.denominator : 0;\n\t\t\tif (d !== denominator) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\n\t\t\t\ttickSum = 0;\n\t\t\t\teventN = 0;\n\t\t\t}\n\n\t\t\tdenominator = d;\n\t\t\ttickSum += event.duration;\n\t\t\t++eventN;\n\n\t\t\tif (i === events.length - 1) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst tickOverlapped = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tlet tick = 0;\n\t\treturn events.some((event) => {\n\t\t\tif (event.grace) return false;\n\n\t\t\tif (event.tick < tick) return true;\n\t\t\ttick = event.tick + event.duration;\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst fractionalTimes = new Set(measure.events.filter((e) => e.timeWarp && e.timeWarp.denominator > 3).map((e) => e.duration));\n\tconst complicatedTimewarp = fractionalTimes.size > 1;\n\n\tconst literalDuration = fractionMul(WHOLE_DURATION, measure.timeSignature);\n\tconst sigDuration = measure.doubtfulTimesig ? measure.duration : literalDuration;\n\n\tconst inVoiceEvents = measure.voices.flat(1).map((id) => eventMap[id]);\n\n\t// Guard: detect corrupted event data in voices (e.g. missing division, NaN tick)\n\tconst corruptedVoiceEvent = inVoiceEvents.some(\n\t\t(event) =>\n\t\t\t!event ||\n\t\t\t!Number.isFinite(event.tick) ||\n\t\t\t!Number.isFinite(event.division) ||\n\t\t\tevent.division < 0 ||\n\t\t\t!Number.isFinite(event.duration) ||\n\t\t\tevent.duration <= 0\n\t);\n\n\tconst overranged = inVoiceEvents.reduce((over, event) => over || event.tick < 0 || event.tick + event.duration > sigDuration, false);\n\tconst overDuration = measure.duration > literalDuration;\n\tconst graceInVoice = inVoiceEvents.some((event) => event.grace);\n\tconst graceN = measure.events.filter((e) => e.grace).length;\n\tconst graceDominant = graceN >= inVoiceEvents.length;\n\n\tconst irregularTick = inVoiceEvents.some((event) => {\n\t\tlet t = event.tick * 2 ** (event.division + 2);\n\t\tif (event.timeWarp) t *= event.timeWarp.denominator;\n\n\t\tif (!Number.isFinite(t)) return true;\n\n\t\tconst fragment = gcd(Math.round(t), WHOLE_DURATION);\n\t\t//if (fragment < WHOLE_DURATION)\n\t\t//\tconsole.log(\"irregularTick:\", event.tick, fragment);\n\t\treturn fragment < WHOLE_DURATION;\n\t});\n\n\tconst beamStatus = measure.voices!.map((voice) =>\n\t\tvoice.reduce(\n\t\t\t({ status, broken }, ei) => {\n\t\t\t\tconst event = eventMap[ei];\n\t\t\t\tif (event.beam) {\n\t\t\t\t\tstatus += BEAM_STATUS[event.beam];\n\t\t\t\t\tbroken = broken || !(status >= 0 && status <= 1);\n\t\t\t\t}\n\n\t\t\t\treturn { status, broken };\n\t\t\t},\n\t\t\t{ status: 0, broken: false }\n\t\t)\n\t);\n\tconst beamBroken = beamStatus.some(({ status, broken }) => status || broken);\n\tlet spaceTime = 0;\n\tlet surplusTime = 0;\n\tmeasure.voices!.forEach((voice) => {\n\t\tconst eventDuration = voice.reduce((sum, ei) => sum + eventMap[ei].duration, 0);\n\t\tspaceTime += Math.max(0, measure.duration - eventDuration);\n\t\tsurplusTime += Math.max(0, eventDuration - measure.duration);\n\t});\n\tspaceTime /= WHOLE_DURATION;\n\tconst nullEvents = measure.events.filter(\n\t\t(e) => !e.grace && !e.fullMeasureRest && !e.tremoloCatcher && (!e.predisposition || e.predisposition.fakeP < 0.1) && !Number.isFinite(e.tick)\n\t).length;\n\n\tconst fakeEvents = measure.events.filter(\n\t\t(event) => !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !inVoiceEvents.includes(event)\n\t).length;\n\n\tconst { voiceRugged } = measure.voices!.flat(1).reduce(\n\t\t(result, ei) => {\n\t\t\tif (!result.voiceRugged) {\n\t\t\t\tif (result.es.has(ei)) return { voiceRugged: true, es: result.es };\n\t\t\t}\n\n\t\t\tresult.es.add(ei);\n\n\t\t\treturn result;\n\t\t},\n\t\t{ voiceRugged: false, es: new Set() }\n\t);\n\n\tconst tickTwist = measure.tickTwist || 0;\n\n\tconst error =\n\t\tcorruptedVoiceEvent ||\n\t\ttickTwist >= 1 ||\n\t\ttickOverlapped ||\n\t\tvoiceRugged ||\n\t\tmeasure.tickRatesInStaves.some((rate) => rate < 0) ||\n\t\tnullEvents > 2 ||\n\t\t!measure.timeSignature ||\n\t\toverranged ||\n\t\tmeasure.duration > sigDuration ||\n\t\tmeasure.events.some((event) => event.timeWarp && event.timeWarp.numerator / event.timeWarp.denominator <= 0.5);\n\tconst perfect =\n\t\t!error &&\n\t\t!overDuration &&\n\t\ttickTwist < 0.2 &&\n\t\t!fractionalWarp &&\n\t\t!irregularWarps.size &&\n\t\t!irregularTick &&\n\t\t!spaceTime &&\n\t\t!surplusTime &&\n\t\t!!measure.voices!.length &&\n\t\t!beamBroken &&\n\t\t!graceInVoice &&\n\t\t!graceDominant &&\n\t\t(measure.duration === sigDuration || (Number.isFinite(measure.estimatedDuration) && measure.estimatedDuration <= sigDuration * 0.75));\n\tconst fine = !error && !overDuration && tickTwist < 0.3 && !fractionalWarp && !irregularTick && !surplusTime && !beamBroken && !graceInVoice;\n\n\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\tconst durationRate = measure.duration / expectDuration;\n\n\tlet qualityScore = 0;\n\tif (measure.patched && !corruptedVoiceEvent) qualityScore = 1;\n\telse if (!error) {\n\t\tconst spaceLoss = Math.tanh(Math.abs(spaceTime / Math.max(1, measure.voices.length)) * 1);\n\n\t\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\t\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\t\tconst durationLoss = expectDuration ? Math.max(0, 1 - durationRate) ** 2 : 0;\n\t\tconst warpsLoss = Math.tanh(irregularWarps.size);\n\n\t\tqualityScore = (1 - spaceLoss) * (1 - durationLoss) * (1 - warpsLoss) * (1 - tickTwist ** 2);\n\t}\n\n\treturn {\n\t\tevents,\n\t\tvalidEvents,\n\t\tvoiceRugged,\n\t\tnullEvents,\n\t\tfakeEvents,\n\t\twarpedEvents,\n\t\tcomplicatedTimewarp,\n\t\tspaceTime,\n\t\tsurplusTime,\n\t\tdurationRate,\n\t\tbeamBroken,\n\t\tfractionalWarp,\n\t\tirregularWarpsN: irregularWarps.size,\n\t\tirregularTick,\n\t\ttickTwist,\n\t\ttickOverlapped,\n\t\tgraceInVoice,\n\t\tgraceN,\n\t\tgraceDominant,\n\t\tperfect,\n\t\tfine,\n\t\terror,\n\t\tqualityScore,\n\t};\n};\n","//import { staffSvg } from \"@kelvinnxu/lotus\";\n\nimport { SemanticType, SemanticPoint, /*glyphSemanticMapping, glyphCenters,*/ SYSTEM_SEMANTIC_TYPES, Point } from './semanticPoint';\nimport { SimpleClass } from './aux_/typedJSON';\n\nclass SemanticGraph extends SimpleClass {\n\tstatic className = 'SemanticGraph';\n\n\tpoints: SemanticPoint[];\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\t/*static fromSheetStaff(staff: staffSvg.SheetStaff, hashTable: {[key: string]: any}): SemanticGraph {\n\t\tconst tokens = [].concat(...staff.measures.map(measure => measure.tokens));\n\n\t\tconst voltaRightXs = [];\n\n\t\tconst points = [];\n\t\ttokens.forEach(token => {\n\t\t\tconst def = hashTable[token.hash];\n\n\t\t\tif (token.glyph) {\n\t\t\t\tconst glyph = token.glyph as string;\n\t\t\t\tlet semantic = null;\n\n\t\t\t\tconst isKey = /^\\\\key/.test(token.source) || token.is(\"KEY\");\n\t\t\t\tlet { x: cx = 0, y: cy = 0 } = glyphCenters[glyph] || { x: 0, y: 0 };\n\t\t\t\tif (token.scale2) {\n\t\t\t\t\tcx *= token.scale2.x;\n\t\t\t\t\tcy *= token.scale2.y;\n\t\t\t\t}\n\n\t\t\t\tlet x = token.x + cx;\n\t\t\t\tconst y = token.y + cy;\n\n\t\t\t\tswitch (glyph) {\n\t\t\t\tcase \"rests.0\":\n\t\t\t\t\tif (/^R/.test(token.source))\n\t\t\t\t\t\tsemantic = \"Rest0W\";\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Rest0\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.flat\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.natural\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.sharp\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"dots.dot\":\n\t\t\t\t\tif (token.is(\"VOLTA\")) {\n\t\t\t\t\t\tx += 0.24;\t// dot glyph center X offset\n\t\t\t\t\t\tif (token.is(\"LEFT\"))\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaLeft;\n\t\t\t\t\t\telse if (token.is(\"RIGHT\")) {\n\t\t\t\t\t\t\tvoltaRightXs.push(x);\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaRight;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Dot\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"zero\":\n\t\t\t\tcase \"one\":\n\t\t\t\tcase \"two\":\n\t\t\t\tcase \"three\":\n\t\t\t\tcase \"four\":\n\t\t\t\tcase \"five\":\n\t\t\t\tcase \"six\":\n\t\t\t\tcase \"seven\":\n\t\t\t\tcase \"eight\":\n\t\t\t\tcase \"nine\": {\n\t\t\t\t\tconst upper = glyph[0].toUpperCase() + glyph.substr(1);\n\t\t\t\t\tsemantic = token.is(\"TIME_SIG\") ? \"Timesig\" + upper : upper;\n\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t}\n\n\t\t\t\tif (semantic) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (token.is(\"TEMPO_NOTEHEAD\")) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.TempoNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// grace noteheads\n\t\t\t\tif (token.is(\"NOTEHEAD\") && Number.isFinite(token.scale) && token.scale < 0.75) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.GraceNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// semantic from token symbol\n\t\t\tlet semantic = null;\n\t\t\tconst cx = 0;\n\t\t\tlet cy = 0;\n\t\t\tif (token.is(\"OCTAVE\")) {\n\t\t\t\tif (token.is(\"_8\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift8;\n\t\t\t\t\tcy = token.is(\"B\") ? -0.7512 : -0.7256;\n\t\t\t\t}\n\t\t\t\telse if (token.is(\"CLOSE\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift0;\n\t\t\t\t\tcy = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (/^flags/.test(token.glyph)) {\n\t\t\t\tlet direction = 0;\n\t\t\t\tif (/\\.u\\d/.test(token.glyph))\n\t\t\t\t\tdirection = 1;\n\t\t\t\tif (/\\.d\\d/.test(token.glyph))\n\t\t\t\t\tdirection = -1;\n\t\t\t\tif (direction) {\n\t\t\t\t\tconst [n] = token.glyph.match(/\\d+/);\n\t\t\t\t\tconst flagCount = Number(n) - 2;\n\t\t\t\t\t//console.log(\"flags:\", token.glyph, flagCount);\n\t\t\t\t\tfor (let i = 0; i < flagCount; ++i) {\n\t\t\t\t\t\tconst y = token.y + (i + 0.5) * direction;\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t//console.log(\"flags.1:\", token.x, y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"SLUR\")) {\n\t\t\t\tconst d = def && def.d;\n\t\t\t\tif (d) {\n\t\t\t\t\tconst numbers = d.match(/-?[\\d.]+/g).map(Number);\n\t\t\t\t\t//console.log(\"slur:\", numbers);\n\t\t\t\t\tconst x1 = token.x + numbers[0];\n\t\t\t\t\tconst y1 = token.y + numbers[1];\n\t\t\t\t\tconst x2 = token.x + numbers[6];\n\t\t\t\t\tconst y2 = token.y + numbers[7];\n\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurBegin,\n\t\t\t\t\t\tx: x1,\n\t\t\t\t\t\ty: y1,\n\t\t\t\t\t});\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurEnd,\n\t\t\t\t\t\tx: x2,\n\t\t\t\t\t\ty: y2,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"NOTE_STEM\")) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.vline_Stem,\n\t\t\t\t\tx: token.x + def.width / 2,\n\t\t\t\t\ty: token.y,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: token.y,\n\t\t\t\t\t\ty2: token.y + token.height,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (token.is(\"TEXT\") || token.is(\"CHORD_TEXT\")) {\n\t\t\t\tif (/\\S/.test(token.text)) {\n\t\t\t\t\t// NOTE: text rect computation is delayed to sheet rendering\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\tindex: token.index,\n\t\t\t\t\t\t\ttext: token.text,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx: token.x + cx,\n\t\t\t\t\ty: token.y + cy,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// beams\n\t\tconst stems = tokens.filter(token => token.is(\"NOTE_STEM\")).map(stem => ({\n\t\t\tx: stem.x + stem.width / 2,\n\t\t\ty1: stem.y,\n\t\t\ty2: stem.y + stem.height,\n\t\t}));\n\t\tconst beams = tokens.filter(token => token.is(\"NOTETAIL\") && token.is(\"JOINT\"))\n\t\t\t.map(beam => {\n\t\t\t\tconst def = hashTable[beam.hash];\n\t\t\t\tconst points = def && def.points;\n\t\t\t\tif (points) {\n\t\t\t\t\tconst floats = points.split(\" \").map(Number);\n\t\t\t\t\tconst x1 = beam.x + floats[4];\n\t\t\t\t\tconst x2 = beam.x + floats[0];\n\t\t\t\t\tconst y1 = beam.y + (floats[5] + floats[7]) / 2;\n\t\t\t\t\tconst y2 = beam.y + (floats[1] + floats[3]) / 2;\n\t\t\t\t\tconst k = (y2 - y1) / (x2 - x1);\n\n\t\t\t\t\treturn { x1, x2, y1, y2, k, capital: beam.is(\"CAPITAL_BEAM\") };\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}).filter(Boolean);\n\t\t//console.log(\"beams:\", beams);\n\t\tbeams.forEach(beam => {\n\t\t\tconst innerStems = stems.filter(stem => stem.x > beam.x1 - 0.2 && stem.x < beam.x2 + 0.2);\n\t\t\t//console.log(\"innerStems:\", beam, innerStems);\n\n\t\t\tlet lines = 0;\n\t\t\tinnerStems.forEach(stem => {\n\t\t\t\tconst beamY = beam.y1 + (stem.x - beam.x1) * beam.k;\n\t\t\t\t//console.log(\"beamY:\", beamY, Math.min(Math.abs(beamY - beam.y1), Math.abs(beamY - beam.y2)));\n\t\t\t\tif (beamY >= stem.y1 - 0.1 && beamY <= stem.y2 + 0.1) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t});\n\n\t\t\t\t\t++lines;\n\n\t\t\t\t\t// beam semantics\n\t\t\t\t\tif (beam.capital) {\n\t\t\t\t\t\tlet semantic = SemanticType.BeamContinue;\n\t\t\t\t\t\tif (Math.abs(stem.x - beam.x1) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamLeft;\n\t\t\t\t\t\telse if (Math.abs(stem.x - beam.x2) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamRight;\n\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!lines)\n\t\t\t\tconsole.warn(\"empty beam:\", beam, innerStems, stems);\n\t\t\t//else if (lines < 2)\n\t\t\t//\tconsole.debug(\"single beam:\", beam, innerStems, stems);\n\t\t});\n\n\t\t// wedges (crescendo & decrescendo)\n\t\tconst crescendos = tokens.filter(token => token.is(\"WEDGE CRESCENDO TOP\"));\n\t\tconst crescendoBottoms = tokens.filter(token => token.is(\"WEDGE CRESCENDO BOTTOM\"));\n\t\tconst decrescendos = tokens.filter(token => token.is(\"WEDGE DECRESCENDO TOP\"));\n\t\tconst decrescendoBottoms = tokens.filter(token => token.is(\"WEDGE DECRESCENDO BOTTOM\"));\n\t\tcrescendos.forEach(line => {\n\t\t\tconst partner = crescendoBottoms.find(b => b.x === line.x && Math.abs(b.y - line.y) < 0.06);\n\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.CrescendoBegin,\n\t\t\t\t\tx: line.x,\n\t\t\t\t\ty: line.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired crescendo:\", line, crescendoBottoms);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.CrescendoEnd,\n\t\t\t\tx: line.x + line.target.x,\n\t\t\t\ty: line.y + line.target.y,\n\t\t\t});\n\t\t});\n\t\tdecrescendos.forEach(line => {\n\t\t\tconst partner = decrescendoBottoms.find(b => b.x + b.target.x === line.x + line.target.x && Math.abs(b.y + b.target.y - (line.y + line.target.y)) < 0.06);\n\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.DecrescendoBegin,\n\t\t\t\tx: line.x,\n\t\t\t\ty: line.y,\n\t\t\t});\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.DecrescendoEnd,\n\t\t\t\t\tx: line.x + line.target.x,\n\t\t\t\t\ty: line.y + line.target.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired decrescendo:\", line, decrescendoBottoms);\n\t\t});\n\n\t\t// TODO: volta alternative\n\n\t\t// measure bars\n\t\tconst measureSeparators = staff.tokens.filter(token => token.is(\"MEASURE_SEPARATOR\"));\n\t\tconst singleBars = [];\n\t\tconst groupBars = [];\n\n\t\tfor (let i = 0; i < measureSeparators.length; ++i) {\n\t\t\tconst bar = measureSeparators[i];\n\t\t\tconst nextBar = measureSeparators[i + 1];\n\t\t\tconst inteval = nextBar ? nextBar.x - bar.x : Infinity;\n\n\t\t\tif (inteval < 1) {\n\t\t\t\tgroupBars.push([bar, nextBar]);\n\t\t\t\t++i;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsingleBars.push(bar);\n\t\t};\n\t\t//console.log(\"bars:\", singleBars, groupBars);\n\n\t\tsingleBars.forEach(bar => {\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx: bar.x + bar.sw / 2,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\tgroupBars.forEach(group => {\n\t\t\tlet x = (group[0].x + group[1].x) / 2;\n\t\t\tconst bold0 = group[0].is(\"BOLD\");\n\t\t\tconst bold1 = group[1].is(\"BOLD\");\n\n\t\t\tlet semantic = null;\n\t\t\tif (!bold0 && bold1) {\n\t\t\t\tx = group[0].x;\n\n\t\t\t\tif (!voltaRightXs.some(vx => x - vx < 2))\n\t\t\t\t\tsemantic = SemanticType.vline_BarTerminal;\n\t\t\t}\n\t\t\telse if (bold0 && !bold1)\n\t\t\t\tx = group[1].x;\n\t\t\telse if (!bold0 && !bold1)\n\t\t\t\tsemantic = SemanticType.vline_BarSegment;\n\n\t\t\t//console.log(\"group:\", group[0].x, group[1].x, x);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx,\n\t\t\t\t\ty: 0,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: -2,\n\t\t\t\t\t\ty2: 2,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}*/\n\n\tstatic fromPoints(points: SemanticPoint[] = []): SemanticGraph {\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}\n\n\tgetLayer(semantic: SemanticType): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic);\n\t}\n\n\tgetConfidentLayer(semantic: SemanticType, threshold: number): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic && (!Number.isFinite(p.confidence) || p.confidence >= threshold));\n\t}\n\n\tgetSystemPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\tgetStaffPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => !SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\toffset(x: number, y: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x += x;\n\t\t\tpoint.y += y;\n\t\t});\n\t}\n\n\tscale(factor: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x *= factor;\n\t\t\tpoint.y *= factor;\n\t\t});\n\t}\n\n\t// multipy 3x2 matrix\n\ttransform(matrix: [number, number][]): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tlet x = point.x * matrix[0][0] + point.y * matrix[1][0] + matrix[2][0];\n\t\t\tconst y = point.x * matrix[0][1] + point.y * matrix[1][1] + matrix[2][1];\n\n\t\t\tif (point.extension) {\n\t\t\t\tif (Number.isFinite(point.extension.y1)) {\n\t\t\t\t\tconst y1 = point.x * matrix[0][1] + point.extension.y1 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tconst y2 = point.x * matrix[0][1] + point.extension.y2 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tx = point.x * matrix[0][0] + (point.extension.y1 + point.extension.y2) * 0.5 * matrix[1][0] + matrix[2][0];\n\n\t\t\t\t\tpoint.extension.y1 = y1;\n\t\t\t\t\tpoint.extension.y2 = y2;\n\t\t\t\t}\n\n\t\t\t\tif (Number.isFinite(point.extension.width)) {\n\t\t\t\t\tconst scaling = Math.sqrt(matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]);\n\t\t\t\t\tpoint.extension.width *= scaling;\n\t\t\t\t\tpoint.extension.height *= scaling;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpoint.x = x;\n\t\t\tpoint.y = y;\n\t\t});\n\t}\n}\n\nexport { SemanticGraph };\n","import { SimpleClass } from './aux_/typedJSON';\nimport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tChordColumn,\n\tEventMeasureColumn,\n\tEventSystem,\n\tSourceImageFile,\n\tPageLayout,\n\tAdditionalLineStack,\n\tTextType,\n\tEventFeature,\n} from './interfaces';\nimport { distance2D, solveOverlapping, roundNumber, trans23 } from './utils';\nimport {\n\tToken,\n\tTextToken,\n\tTokenType,\n\tTokenNoteheads,\n\tTokenFlags,\n\tTokenDots,\n\tTokenRests,\n\tTokenAccessories,\n\tTokenDirectionless,\n\tTokenClefs,\n\tTokenBeams,\n\tTokenTimesigs,\n\tTOKEN_Y_FIXED,\n\tTOKEN_Y_ROUND,\n} from './token';\nimport { EventTerm, ContextedTerm, MarkTerm, TempoTerm, AccessoryDirection, GraceType, ContextType, TremoloLink } from './term';\nimport { SemanticGraph } from './semanticGraph';\nimport { SemanticType, SemanticPoint, NOTEHEAD_WIDTHS, hashSemanticPoint, hashPageSemanticPoint } from './semanticPoint';\nimport { Logger, DummyLogger } from './logger';\n\ntype ChordsFeeder = (si: number, mi: number) => ChordColumn[];\ntype ColumnProcessor = (column: EventMeasureColumn) => EventMeasureColumn;\n\nconst CHORD_X_TOLERANCE = 0.2;\n//const EVENT_X_TOLERANCE = 0.8;\n\nconst STEM_LENGTH_MAX = 6;\n\nconst INDENT_THRESHOLD = 2;\n\nconst MEASURE_SEMANTICS = [\n\tSemanticType.ClefG,\n\tSemanticType.ClefF,\n\tSemanticType.ClefC,\n\tSemanticType.TimesigC44,\n\tSemanticType.TimesigC22,\n\tSemanticType.TimesigZero,\n\tSemanticType.TimesigOne,\n\tSemanticType.TimesigTwo,\n\tSemanticType.TimesigThree,\n\tSemanticType.TimesigFour,\n\tSemanticType.TimesigFive,\n\tSemanticType.TimesigSix,\n\tSemanticType.TimesigSeven,\n\tSemanticType.TimesigEight,\n\tSemanticType.TimesigNine,\n\tSemanticType.OctaveShift8va,\n\tSemanticType.OctaveShift8vb,\n\tSemanticType.OctaveShift0,\n\tSemanticType.Zero,\n\tSemanticType.One,\n\tSemanticType.Two,\n\tSemanticType.Three,\n\tSemanticType.Four,\n\tSemanticType.Five,\n\tSemanticType.Six,\n\tSemanticType.Seven,\n\tSemanticType.Eight,\n\tSemanticType.Nine,\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n\tSemanticType.Rest0W,\n\tSemanticType.RestM1,\n\tSemanticType.SlurBegin,\n\tSemanticType.SlurEnd,\n\tSemanticType.Dot,\n\tSemanticType.f,\n\tSemanticType.p,\n\tSemanticType.m,\n\tSemanticType.n,\n\tSemanticType.r,\n\tSemanticType.s,\n\tSemanticType.z,\n\tSemanticType.ScriptFermata,\n\tSemanticType.ScriptShortFermata,\n\tSemanticType.ScriptSforzato,\n\tSemanticType.ScriptStaccato,\n\tSemanticType.ScriptStaccatissimo,\n\tSemanticType.ScriptTurn,\n\tSemanticType.ScriptTrill,\n\tSemanticType.ScriptSegno,\n\tSemanticType.ScriptCoda,\n\tSemanticType.ScriptArpeggio,\n\tSemanticType.ScriptPrall,\n\tSemanticType.ScriptMordent,\n\tSemanticType.ScriptMarcato,\n\tSemanticType.ScriptTenuto,\n\tSemanticType.ScriptPortato,\n\tSemanticType.PedalStar,\n\tSemanticType.PedalPed,\n\tSemanticType.GraceNotehead,\n\tSemanticType.BeamLeft,\n\tSemanticType.BeamRight,\n\tSemanticType.BeamContinue,\n\tSemanticType.CrescendoBegin,\n\tSemanticType.CrescendoEnd,\n\tSemanticType.DecrescendoBegin,\n\tSemanticType.DecrescendoEnd,\n\tSemanticType.TremoloLeft,\n\tSemanticType.TremoloRight,\n\tSemanticType.TremoloMiddle,\n];\n\nconst STAFF_LINED_SEMANTICS = [\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n];\n\nconst LINED_INTERVAL_SEMANTICS = [SemanticType.SignLined, SemanticType.SignInterval];\n\nconst NOTEHEAD_FOR_STEM_SEMANTICS = [SemanticType.NoteheadS1, SemanticType.NoteheadS2];\n\nconst KEYACC_CANDIDATE_SEMANTICS = {\n\tAccSharp: TokenType.KeySharp,\n\tAccNatural: TokenType.KeyNatural,\n\tAccFlat: TokenType.KeyFlat,\n};\n\nconst NOTEHEAD_TABLE: { [key: string]: { [key: string]: SemanticType } } = {\n\t[SemanticType.NoteheadS1]: {\n\t\tup: SemanticType.NoteheadS1stemU,\n\t\tdown: SemanticType.NoteheadS1stemD,\n\t},\n\t[SemanticType.NoteheadS2]: {\n\t\tup: SemanticType.NoteheadS2stemU,\n\t\tdown: SemanticType.NoteheadS2stemD,\n\t},\n};\n\nconst REST_SEMANTICS = [\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n];\n\nconst TOKEN_TO_STEMBEAM = {\n\t[TokenType.BeamLeft]: 'Open',\n\t[TokenType.BeamRight]: 'Close',\n\t[TokenType.BeamContinue]: 'Continue',\n};\n\nconst TEXT_TYPE_ALIAS = {\n\tAlter1: TextType.Alternation1,\n\tAlter2: TextType.Alternation2,\n};\n\ninterface StaffPosition {\n\ty: number;\n\tradius: number;\n}\n\ninterface TextArea {\n\tscore: number;\n\tcx: number;\n\tcy: number;\n\twidth: number;\n\theight: number;\n\ttext: string;\n\ttype: string;\n\ttheta: number;\n\tfeature_dict: Record;\n}\n\ntype Stem = VLine & { direction: 'u' | 'd' };\n\nconst noteheadsXPivot = (xs: number[], direction: 'u' | 'd' | null): number => {\n\tswitch (xs.length) {\n\t\tcase 0:\n\t\t\treturn undefined;\n\n\t\tcase 1:\n\t\t\treturn xs[0];\n\n\t\tcase 2:\n\t\t\treturn direction === 'u' ? Math.min(...xs) : Math.max(...xs);\n\n\t\tdefault: {\n\t\t\tconst mean = xs.reduce((sum, x) => sum + x, 0) / xs.length;\n\t\t\txs.sort((x1, x2) => Math.abs(x1 - mean) - Math.abs(x2 - mean));\n\n\t\t\treturn noteheadsXPivot(xs.slice(0, xs.length - 1), direction);\n\t\t}\n\t}\n};\n\nconst noteheadsPivot = (nhs: Token[]): number =>\n\tnoteheadsXPivot(\n\t\tnhs.map((nh) => (Number.isFinite(nh.pivotX) ? nh.pivotX : nh.x)),\n\t\tnhs[0].direction\n\t);\n\nclass Measure extends SimpleClass {\n\tstatic className = 'Measure';\n\tstatic blackKeys = ['tokens', 'antiTokens'];\n\n\tleft: number;\n\twidth: number;\n\theight: number;\n\n\talternative: boolean;\n\n\ttokens: Token[];\n\tantiTokens: Token[];\n\n\tbarTypes: Record;\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.tokens = this.tokens || [];\n\t\tthis.antiTokens = this.antiTokens || [];\n\t\tthis.barTypes = this.barTypes || {};\n\t}\n\n\tget right(): number {\n\t\treturn this.left + this.width;\n\t}\n\n\tget noteheads(): Token[] {\n\t\treturn this.tokens.filter((t) => t.isNotehead).sort((n1, n2) => n1.x - n2.x);\n\t}\n\n\tget chordRects(): ChordRect[] {\n\t\tconst noteheads = this.noteheads.filter((nh) =>\n\t\t\t[TokenType.NoteheadS0, TokenType.NoteheadS1stemU, TokenType.NoteheadS2stemU, TokenType.NoteheadS1stemD, TokenType.NoteheadS2stemD].includes(nh.type)\n\t\t);\n\n\t\tlet nulN = 0;\n\n\t\tconst nhmap: Record = noteheads.reduce((map, nh) => {\n\t\t\tconst tip = nh.tip ? `${nh.tip.x}|${nh.tip.y}` : `nul${nulN}`;\n\t\t\tlet key = `${nh.type}|${tip}`;\n\n\t\t\tif (!nh.tip && map[key]) {\n\t\t\t\tif (!map[key].some((hh) => Math.abs(hh.x - nh.x) < NOTEHEAD_WIDTHS.NoteheadS0)) {\n\t\t\t\t\t++nulN;\n\t\t\t\t\tkey = `${nh.type}|nul${nulN}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmap[key] = map[key] || [];\n\t\t\tmap[key].push(nh);\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(nhmap).map((nhs) => {\n\t\t\tconst left = Math.min(...nhs.map((nh) => nh.x));\n\t\t\tconst right = Math.max(...nhs.map((nh) => nh.x));\n\t\t\tconst top = Math.min(...nhs.map((nh) => nh.y));\n\t\t\tconst bottom = Math.max(...nhs.map((nh) => nh.y));\n\n\t\t\tconst nh0 = nhs[0];\n\n\t\t\tconst stemX = nh0 && nh0.tip ? nh0.tip.x : left;\n\n\t\t\tlet x = left;\n\t\t\tlet width = right - left;\n\t\t\tlet stemDirection = null;\n\n\t\t\tswitch (nh0.type) {\n\t\t\t\tcase TokenType.NoteheadS0:\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS0 / 2;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemU:\n\t\t\t\tcase TokenType.NoteheadS2stemU:\n\t\t\t\t\tstemDirection = 'u';\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS1;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemD:\n\t\t\t\tcase TokenType.NoteheadS2stemD:\n\t\t\t\t\tstemDirection = 'd';\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tx,\n\t\t\t\twidth,\n\t\t\t\tstemX,\n\t\t\t\tstemDirection,\n\t\t\t\ttop,\n\t\t\t\tbottom,\n\t\t\t\ttip: nh0.tip,\n\t\t\t};\n\t\t});\n\t}\n\n\tget timeWarped(): boolean {\n\t\treturn this.tokens && this.tokens.some((token) => token.timeWarped);\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\tconst chords = this.getChords();\n\t\tconst up = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y <= -3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.ceil(Math.min(...chord.ys)) + 2,\n\t\t\t}));\n\t\tconst down = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y >= 3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.floor(Math.max(...chord.ys)) - 2,\n\t\t\t}));\n\n\t\treturn [...up, ...down].map((stack) => ({\n\t\t\tleft: stack.left - 0.28,\n\t\t\tright: stack.right + 0.28,\n\t\t\tn: stack.n,\n\t\t}));\n\t}\n\n\tgetChords(): ChordColumn[] {\n\t\tconst flags = this.tokens.filter((t) => TokenFlags.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\t\tconst beams = this.tokens.filter((t) => TokenBeams.includes(t.type));\n\n\t\tconst chordRcs = this.chordRects\n\t\t\t.map((rect) => {\n\t\t\t\tconst noteheads = this.noteheads.filter(\n\t\t\t\t\t(nh) =>\n\t\t\t\t\t\tnh.direction === rect.stemDirection &&\n\t\t\t\t\t\tnh.left >= rect.x &&\n\t\t\t\t\t\tnh.right <= rect.x + rect.width + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tnh.y >= rect.top &&\n\t\t\t\t\t\tnh.y <= rect.bottom\n\t\t\t\t);\n\t\t\t\tnoteheads.sort((n1, n2) => n2.y - n1.y);\n\t\t\t\tconst ys = noteheads.map((nh) => nh.y);\n\t\t\t\tconst noteIds = noteheads.map((nh) => nh.id);\n\n\t\t\t\tconst division = noteheads.reduce((d, nh) => Math.max(d, nh.division), 0);\n\n\t\t\t\treturn {\n\t\t\t\t\trect,\n\t\t\t\t\tleft: rect.x,\n\t\t\t\t\tright: rect.x + rect.width,\n\t\t\t\t\tpivotX: noteheadsPivot(noteheads),\n\t\t\t\t\tys,\n\t\t\t\t\ttip: rect.tip,\n\t\t\t\t\tnoteIds,\n\t\t\t\t\tdivision,\n\t\t\t\t\tdots: null,\n\t\t\t\t\trest: false,\n\t\t\t\t\tstemDirection: rect.stemDirection,\n\t\t\t\t\tbeam: null,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((c1, c2) => c2.left - c1.left);\n\n\t\tconst accs = new Set();\n\n\t\tconst chords = chordRcs.map(({ rect, ...chord }) => {\n\t\t\tif (chord.division >= 1) {\n\t\t\t\t// NOTE: notehead-s1 may have flags too\n\t\t\t\tconst flagRange = [rect.bottom, rect.top];\n\t\t\t\tswitch (rect.stemDirection) {\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t\tflagRange[0] = rect.tip ? rect.tip.y - 0.2 : rect.top - STEM_LENGTH_MAX - 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'd':\n\t\t\t\t\t\tflagRange[1] = rect.tip ? rect.tip.y + 0.2 : rect.bottom + STEM_LENGTH_MAX + 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst nearbyFlags = flags.filter(\n\t\t\t\t\t(flag) =>\n\t\t\t\t\t\t!accs.has(flag.id) &&\n\t\t\t\t\t\tflag.x > rect.stemX - CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.x < rect.stemX + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.y > flagRange[0] &&\n\t\t\t\t\t\tflag.y < flagRange[1]\n\t\t\t\t);\n\t\t\t\tchord.division = nearbyFlags.reduce((d, flag) => Math.max(d, flag.division), chord.division);\n\n\t\t\t\tnearbyFlags.forEach((flag) => accs.add(flag.id));\n\n\t\t\t\tconst beamToken = rect.tip && beams.find((t) => Math.abs(rect.tip.x - t.x) < 0.3 && Math.abs(rect.tip.y - t.y) < 0.7);\n\t\t\t\tif (beamToken) chord.beam = TOKEN_TO_STEMBEAM[beamToken.type];\n\t\t\t}\n\n\t\t\tconst nearbyDots = dots.filter(\n\t\t\t\t(dot) =>\n\t\t\t\t\t!accs.has(dot.id) &&\n\t\t\t\t\tdot.x > rect.x + rect.width - 0.2 &&\n\t\t\t\t\tdot.x < rect.x + rect.width + 1.2 &&\n\t\t\t\t\tdot.y > rect.top - 1 &&\n\t\t\t\t\tdot.y <= rect.bottom + 0.5\n\t\t\t);\n\t\t\tchord.dots = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\tnearbyDots.forEach((dot) => accs.add(dot.id));\n\n\t\t\treturn chord;\n\t\t});\n\n\t\tchords.reverse();\n\n\t\treturn chords;\n\t}\n\n\tgetRests(): ChordColumn[] {\n\t\tconst rests = this.tokens.filter((t) => TokenRests.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\n\t\treturn rests.map((rest) => {\n\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > rest.x + 0.5 && dot.x < rest.x + 2 && dot.y > rest.y - 1 && dot.y < rest.y + 0.5);\n\t\t\tconst dotValue = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\treturn {\n\t\t\t\tleft: rest.x - 0.75,\n\t\t\t\tright: rest.x + 0.75,\n\t\t\t\tpivotX: rest.x,\n\t\t\t\trest: true,\n\t\t\t\tys: [rest.y],\n\t\t\t\tnoteIds: [rest.id],\n\t\t\t\tdots: dotValue,\n\t\t\t\tdivision: rest.division,\n\t\t\t\tstemDirection: null,\n\t\t\t};\n\t\t});\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\treturn [...this.getChords(), ...this.getRests()].sort((e1, e2) => e1.left - e2.left);\n\t}\n\n\tgetContexts(fields = {}): ContextedTerm[] {\n\t\treturn this.tokens\n\t\t\t.filter((t) => t.isContexted)\n\t\t\t.sort((n1, n2) => n1.x - n2.x)\n\t\t\t.map(\n\t\t\t\t(token) =>\n\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\ttokenType: token.type,\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t})\n\t\t\t);\n\t}\n\n\tassignAccessoriesOnEvents(events: ChordColumn[]): void {\n\t\tevents.forEach((event) => (event.accessories = event.accessories || []));\n\n\t\tconst accessories = this.tokens.filter((token) => TokenAccessories.includes(token.type));\n\t\t//console.log(\"accessories:\", accessories);\n\t\taccessories.forEach((accessory) => {\n\t\t\tconst relatedEvents = events.filter((event) => accessory.x > event.left - 1 && accessory.x < event.right + 1);\n\n\t\t\tif (relatedEvents.length > 0) {\n\t\t\t\tlet owner = relatedEvents[0];\n\t\t\t\tif (relatedEvents.length > 1) {\n\t\t\t\t\towner = relatedEvents\n\t\t\t\t\t\t.map((event) => ({ event, d: Math.min(...event.ys.map((y) => Math.abs(y - accessory.y))) }))\n\t\t\t\t\t\t.sort(({ d: d1 }, { d: d2 }) => d1 - d2)\n\t\t\t\t\t\t.map(({ event }) => event)[0];\n\t\t\t\t}\n\t\t\t\t//console.log(\"relatedEvents:\", accessory, owner);\n\n\t\t\t\tlet direction = accessory.y > Math.max(...owner.ys) ? AccessoryDirection.Down : AccessoryDirection.Up;\n\t\t\t\tif (TokenDirectionless.includes(accessory.type)) direction = null;\n\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: accessory.type,\n\t\t\t\t\tid: accessory.id,\n\t\t\t\t\tdirection,\n\t\t\t\t\tx: accessory.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone accessory:\", accessory.type);\n\t\t});\n\n\t\t// arpeggio\n\t\tconst sortEvents = [...events];\n\t\tsortEvents.sort((e1, e2) => e1.left - e2.left);\n\n\t\tconst arpeggios = this.tokens.filter((token) => token.type === TokenType.ScriptArpeggio);\n\t\tarpeggios.forEach((arpeggio) => {\n\t\t\tconst owner = sortEvents.find(\n\t\t\t\t(event) => arpeggio.x < event.left && event.ys.some((y) => y < arpeggio.y + 0.25) && event.ys.some((y) => y > arpeggio.y)\n\t\t\t);\n\t\t\t//const owner = sortEvents.find(event => event.left - leftMost.left < 2 && event.ys.some(y => Math.abs(y - arpeggio.y + 0.25) < 0.5));\n\t\t\tif (owner) {\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: TokenType.ScriptArpeggio,\n\t\t\t\t\tid: arpeggio.id,\n\t\t\t\t\tx: arpeggio.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone arpeggio:\", arpeggio);\n\t\t});\n\n\t\t// grace noteheads\n\t\tconst graceNhs = this.tokens.filter((token) => token.type === TokenType.GraceNotehead);\n\t\tgraceNhs.forEach((grace) => {\n\t\t\tconst event = events.find((event) => grace.x > event.left && grace.x < event.right && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tif (event) event.grace = GraceType.Grace;\n\t\t});\n\n\t\t// tremolos\n\t\tconst tremolsLs = this.tokens.filter((token) => token.type === TokenType.TremoloLeft);\n\t\tconst tremolsRs = this.tokens.filter((token) => token.type === TokenType.TremoloRight);\n\t\tconst tremolsMs = this.tokens.filter((token) => token.type === TokenType.TremoloMiddle);\n\n\t\tconst tevents = events\n\t\t\t.filter((event) => !event.rest)\n\t\t\t.map((event) => {\n\t\t\t\tconst ys = [...event.ys];\n\t\t\t\tif (event.tip) ys.push(event.tip.y);\n\t\t\t\telse {\n\t\t\t\t\tys.push(event.ys[0] + 2);\n\t\t\t\t\tys.push(event.ys[event.ys.length - 1] - 2);\n\t\t\t\t}\n\n\t\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\t\t\t\tconst stemR = event.tip ? event.tip.x : event.right;\n\n\t\t\t\treturn {\n\t\t\t\t\tevent,\n\t\t\t\t\ttop: Math.min(...ys),\n\t\t\t\t\tbottom: Math.max(...ys),\n\t\t\t\t\tstemL,\n\t\t\t\t\tstemR,\n\t\t\t\t};\n\t\t\t});\n\n\t\ttremolsMs.forEach((tm) => {\n\t\t\tconst te = tevents.find((te) => {\n\t\t\t\tif (te.event.tip) return tm.y > te.top && tm.y < te.bottom && Math.abs(tm.x - te.event.tip.x) < 0.3;\n\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t}\n\t\t});\n\t\ttremolsLs.forEach((tl) => {\n\t\t\tconst te = tevents.find((te) => tl.y > te.top && tl.y < te.bottom && tl.x > te.stemR && tl.x < te.stemR + 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Pitcher;\n\t\t\t}\n\t\t});\n\t\ttremolsRs.forEach((tr) => {\n\t\t\tconst te = tevents.find((te) => tr.y > te.top && tr.y < te.bottom && tr.x < te.stemL && tr.x > te.stemL - 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Catcher;\n\t\t\t}\n\t\t});\n\t}\n\n\tassignFeaturesOnEvents(events: ChordColumn[], semantics: SemanticPoint[]): void {\n\t\tconst points = semantics.filter((point) => point.x > this.left && point.x < this.right);\n\t\tconst rests = points.filter((point) => REST_SEMANTICS.includes(point.semantic));\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tconst dotPs = points.filter((point) => point.semantic === SemanticType.Dot);\n\t\tconst beamLs = points.filter((points) => points.semantic === SemanticType.BeamLeft);\n\t\tconst beamMs = points.filter((points) => points.semantic === SemanticType.BeamContinue);\n\t\tconst beamRs = points.filter((points) => points.semantic === SemanticType.BeamRight);\n\t\tconst gracePs = points.filter((point) => point.semantic === SemanticType.GraceNotehead);\n\t\tconst tremoloRs = points.filter((point) => point.semantic === SemanticType.TremoloRight);\n\t\tconst stems = points.filter((point) => point.semantic === SemanticType.vline_Stem);\n\t\tconst s0 = points.filter((point) => point.semantic === SemanticType.NoteheadS0);\n\t\tconst s1 = points.filter((point) => point.semantic === SemanticType.NoteheadS1);\n\t\tconst s2 = points.filter((point) => point.semantic === SemanticType.NoteheadS2);\n\n\t\tevents.forEach((event) => {\n\t\t\tconst cx = event.tip ? event.tip.x : (event.left + event.right) / 2;\n\t\t\tconst top = event.tip ? Math.min(event.tip.y, event.ys[event.ys.length - 1]) : event.ys[event.ys.length - 1];\n\t\t\tconst bottom = event.tip ? Math.max(event.tip.y, event.ys[0]) : event.ys[0];\n\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\n\t\t\tconst divisions = [0, 0, 0, 0, 0, 0, 0];\n\t\t\tif (event.rest) {\n\t\t\t\tconst i_rests = rests.filter((point) => distance2D(point, { x: cx, y: event.ys[0] }) < 0.5);\n\t\t\t\ti_rests.forEach((r) => {\n\t\t\t\t\tconst d = REST_SEMANTICS.indexOf(r.semantic);\n\t\t\t\t\tdivisions[d] = Math.max(divisions[d], r.confidence);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst nhs = [s0, s1, s2]\n\t\t\t\t\t.map((ss) => ss.filter((nh) => nh.x > event.left && nh.x < event.right && nh.y > top - 0.25 && nh.y < bottom + 0.25))\n\t\t\t\t\t.map((ss) => Math.max(0, ...ss.map((nh) => nh.confidence)));\n\n\t\t\t\tconst i_flags = flags.filter((flag) => flag.y > top - 0.2 && flag.y < bottom + 0.2 && Math.abs(flag.x - cx) < 0.2);\n\t\t\t\ti_flags.sort((f1, f2) => f2.confidence - f1.confidence);\n\n\t\t\t\tdivisions[0] = nhs[0];\n\t\t\t\tdivisions[1] = nhs[1];\n\t\t\t\tdivisions[2] = nhs[2];\n\t\t\t\tArray(divisions.length - 3)\n\t\t\t\t\t.fill(0)\n\t\t\t\t\t.forEach((_, i) => (divisions[3 + i] = i_flags[i] ? i_flags[i].confidence : 0));\n\t\t\t}\n\n\t\t\tconst i_dots = dotPs.filter((dot) => dot.x > cx && dot.x < event.right + 2.6);\n\t\t\tconst dots2 = i_dots.filter((dot) => i_dots.some((d) => dot.x > d.x && Math.abs(dot.y - d.y) < 0.2));\n\t\t\tconst dots = [Math.max(0, ...i_dots.map((dot) => dot.confidence)), Math.max(0, ...dots2.map((dot) => dot.confidence))];\n\n\t\t\tconst beams = [beamLs, beamMs, beamRs]\n\t\t\t\t.map((bs) => bs.filter((b) => Math.abs(b.x - cx) < 0.2 && b.y > top - 0.2 && b.y < bottom + 0.2))\n\t\t\t\t.map((bs) => Math.max(0, ...bs.map((b) => b.confidence)));\n\n\t\t\tconst u_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[0] }, { x: stem.x, y: stem.extension.y2 }) < 0.5);\n\t\t\tconst d_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[event.ys.length - 1] }, { x: stem.x, y: stem.extension.y1 }) < 0.5);\n\t\t\tconst stemDirections = [Math.max(0, ...u_stems.map((stem) => stem.confidence)), Math.max(0, ...d_stems.map((stem) => stem.confidence))];\n\n\t\t\tconst graces = gracePs.filter((grace) => Math.abs(grace.x - cx) < 0.6 && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tconst grace = Math.max(0, ...graces.map((grace) => grace.confidence));\n\n\t\t\tconst tremolos =\n\t\t\t\tevent.division === 0\n\t\t\t\t\t? tremoloRs.filter((tremolo) => tremolo.x > event.left - 2 && tremolo.x < event.right)\n\t\t\t\t\t: tremoloRs.filter((tremolo) => tremolo.y > top - 0.04 && tremolo.y < bottom + 0.04 && tremolo.x > stemL - 2 && tremolo.x < stemL);\n\t\t\tconst tremoloCatcher = Math.max(0, ...tremolos.map((tremolo) => tremolo.confidence));\n\n\t\t\tevent.feature = {\n\t\t\t\tdivisions,\n\t\t\t\tdots,\n\t\t\t\tbeams,\n\t\t\t\tstemDirections,\n\t\t\t\tgrace,\n\t\t\t\ttremoloCatcher,\n\t\t\t} as EventFeature;\n\t\t});\n\t}\n}\n\nclass Staff extends SimpleClass {\n\tstatic className = 'Staff';\n\tstatic blackKeys = ['index', 'semanticTop', 'semanticBttom'];\n\n\tindex?: number; // staff index in full staff layout\n\n\t// in units\n\ttop: number;\n\theight: number;\n\tstaffY: number;\n\n\tsemanticTop: number;\n\tsemanticBottom: number;\n\n\tbackgroundImage: string | Buffer;\n\tmaskImage: string | Buffer;\n\timagePosition: Rect;\n\n\tmeasures: Measure[];\n\n\tsemantics: SemanticPoint[];\n\n\tconstructor({ measureCount = null, measureBars = null, ...data }: Record = {}) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.height = this.height || 10;\n\t\tthis.staffY = this.staffY || 5;\n\n\t\tif (measureBars) {\n\t\t\tlet left = 0;\n\t\t\tthis.measures = measureBars.map((endX) => {\n\t\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\t\tleft = endX;\n\n\t\t\t\treturn measure;\n\t\t\t});\n\t\t} else if (measureCount)\n\t\t\tthis.measures = Array(measureCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Measure());\n\t\telse this.measures = [];\n\t}\n\n\t// relative to staffY\n\tget noteRange(): { top: number; bottom: number } {\n\t\tconst noteheads: Token[] = [].concat(...this.measures.map((measure) => measure.noteheads));\n\t\tconst ys = noteheads.map((note) => note.y);\n\t\tconst top = Math.min(-2, ...ys);\n\t\tconst bottom = Math.max(2, ...ys);\n\n\t\treturn { top, bottom };\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\treturn [].concat(...this.measures.map((measure) => measure.additionalLines));\n\t}\n\n\trearrangeMeasures(measureBars: number[]): void {\n\t\tif (!measureBars.length) {\n\t\t\tconsole.warn('rearrangeMeasures error, measureBars are empty.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst tokens = this.measures?.map((measure) => measure.tokens).flat(1) || [];\n\n\t\tlet left = 0;\n\t\tthis.measures = measureBars.map((endX) => {\n\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\tleft = endX;\n\n\t\t\treturn measure;\n\t\t});\n\n\t\tthis.reassignTokens(tokens);\n\t}\n\n\treassignTokens(tokens: Token[] = null): void {\n\t\tif (!tokens) tokens = [].concat(...this.measures.map((measure) => measure.tokens));\n\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\n\t\ttokens.forEach((token) => {\n\t\t\tfor (const measure of this.measures) {\n\t\t\t\tif (token.x < measure.right) {\n\t\t\t\t\tmeasure.tokens.push(token);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tassignSemantics(graph: SemanticGraph): void {\n\t\tthis.semantics = graph.getStaffPoints();\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, system: System, logger: Logger = new DummyLogger()): void {\n\t\tif (!this.semantics) return;\n\n\t\tlet points = system.qualifiedSemantics(this.semantics, threshold);\n\t\tpoints = solveOverlapping(points);\n\n\t\t// tempo noteheads\n\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t//console.log(\"temponh:\", tempoNh, index, points[index]);\n\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t// TODO: construct tempo term\n\t\t});\n\n\t\tconst antiP = (id: string): SemanticPoint | null => {\n\t\t\tif (system.displacementSemantics?.[id]) return this.semantics.find((p) => p.id === id);\n\n\t\t\treturn null;\n\t\t};\n\n\t\tpoints.filter((point) => MEASURE_SEMANTICS.includes(point.semantic)).forEach((point) => this.appendPoint(point, { points }));\n\n\t\t// noteheads with stem from noteheads & stems\n\t\tconst stems: Stem[] = points\n\t\t\t.filter((point) => point.semantic === SemanticType.vline_Stem)\n\t\t\t.filter((stem) => stem.extension.y2 - stem.extension.y1 > 1.5) // exclude too short stems\n\t\t\t.map((p) => ({\n\t\t\t\tx: p.x,\n\t\t\t\ty1: p.extension.y1,\n\t\t\t\ty2: p.extension.y2,\n\t\t\t\tdirection: null,\n\t\t\t}));\n\t\tconst noteheads = points.filter(\n\t\t\t(point) => NOTEHEAD_FOR_STEM_SEMANTICS.includes(point.semantic) && point.y > this.semanticTop && point.y < this.semanticBottom\n\t\t);\n\t\tconst rootNhs = new Set();\n\n\t\t// for 2nd degree chord notes\n\t\tconst nhOffsetX = (nh: SemanticPoint, stem: Stem, down: boolean): number => {\n\t\t\tif ((down ? 1 : 0) ^ (nh.x < stem.x ? 1 : 0)) return 0;\n\n\t\t\tconst offset = NOTEHEAD_WIDTHS[nh.semantic];\n\n\t\t\treturn down ? -offset : offset;\n\t\t};\n\n\t\t// find root noteheads on stem\n\t\tstems.forEach((stem) => {\n\t\t\tconst attachedHeads = noteheads.filter(\n\t\t\t\t(nh) =>\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 < 0.28 &&\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 > -0.44 && // for grace noteheads, more close to their stem\n\t\t\t\t\tnh.y > stem.y1 - 0.5 &&\n\t\t\t\t\tnh.y < stem.y2 + 0.5 &&\n\t\t\t\t\t!(nh.x > stem.x && nh.y > stem.y2) &&\n\t\t\t\t\t!(nh.x < stem.x && nh.y < stem.y1)\n\t\t\t);\n\t\t\t//if (stem.x===102.0625 && stem.y2===1.875)\n\t\t\t//\tdebugger;\n\t\t\tif (attachedHeads.length) {\n\t\t\t\tattachedHeads.sort((n1, n2) => n1.y - n2.y);\n\n\t\t\t\tconst topDist = Math.min(...attachedHeads.map((nh) => nh.y - stem.y1));\n\t\t\t\tconst bottomDist = Math.min(...attachedHeads.map((nh) => stem.y2 - nh.y));\n\t\t\t\tif (Math.min(topDist, bottomDist) > 0.5) return; // no root notehead on this stem\n\n\t\t\t\tconst down = topDist < bottomDist;\n\t\t\t\tstem.direction = down ? 'd' : 'u';\n\n\t\t\t\tif (!down) attachedHeads.reverse();\n\t\t\t\tconst root = attachedHeads[0];\n\n\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[root.semantic].down : NOTEHEAD_TABLE[root.semantic].up;\n\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: root.id,\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx: stem.x + nhOffsetX(root, stem, down),\n\t\t\t\t\t\ty: root.y,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tconfidence: root.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\tantiPoint: antiP(root.id),\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\trootNhs.add(root.id);\n\t\t\t}\n\t\t});\n\n\t\t// non-root noteheads\n\t\tnoteheads\n\t\t\t.filter((nh) => !rootNhs.has(nh.id))\n\t\t\t.forEach((nh) => {\n\t\t\t\tconst nearStems = stems\n\t\t\t\t\t.filter((stem) => Math.abs(stem.x - nh.x) < 2 && nh.y > stem.y1 && nh.y < stem.y2)\n\t\t\t\t\t.sort((s1, s2) => Math.abs(s1.x - nh.x) - Math.abs(s2.x - nh.x));\n\t\t\t\tconst stem = nearStems[0];\n\t\t\t\tif (stem) {\n\t\t\t\t\tconst down = stem.direction === 'd';\n\t\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[nh.semantic].down : NOTEHEAD_TABLE[nh.semantic].up;\n\n\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: nh.id,\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x + nhOffsetX(nh, stem, down),\n\t\t\t\t\t\t\ty: nh.y,\n\t\t\t\t\t\t\tpivotX: nh.x,\n\t\t\t\t\t\t\tconfidence: nh.confidence,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\t\tantiPoint: antiP(nh.id),\n\t\t\t\t\t\t\tpoints,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else logger.debug('isolated notehead:', system.index, this.index, nh);\n\t\t\t});\n\n\t\t// group flags\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tflags.sort((f1, f2) => f1.x - f2.x);\n\t\tthis.appendFlags(flags, stems);\n\n\t\t// group dots\n\t\tconst dots = points\n\t\t\t.filter((point) => point.semantic === SemanticType.Dot)\n\t\t\t.map((dot) => {\n\t\t\t\tconst y = roundNumber(dot.y, 0.5);\n\t\t\t\treturn { x: dot.x, y };\n\t\t\t});\n\t\tconst dotLines: { [key: number]: SemanticPoint[] } = dots.reduce((table, dot) => {\n\t\t\ttable[dot.y] = table[dot.y] || [];\n\t\t\ttable[dot.y].push(dot);\n\t\t\treturn table;\n\t\t}, {});\n\t\tObject.entries(dotLines).forEach(([sy, line]) => {\n\t\t\tconst y = Number(sy);\n\t\t\tif (line.length > 1) {\n\t\t\t\tline.sort((d1, d2) => d1.x - d2.x);\n\t\t\t\tfor (let i = 0; i < line.length - 1; i++) {\n\t\t\t\t\tconst dot = line[i];\n\t\t\t\t\tif (line.find((d) => d.x > dot.x && d.x - dot.x < 1.2)) {\n\t\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: dot.id,\n\t\t\t\t\t\t\t\tx: dot.x,\n\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\tconfidence: dot.confidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: TokenType.DotDot, antiPoint: antiP(dot.id), points }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// pair key accidentals\n\t\tconst keyaccs = points.filter((point) => point.semantic === SemanticType.KeyAcc);\n\t\tconst accs = points.filter((point) => KEYACC_CANDIDATE_SEMANTICS[point.semantic]);\n\t\taccs.forEach((acc) => {\n\t\t\tif (keyaccs.some((key) => Math.abs(acc.x - key.x) < 0.5 && Math.abs(acc.y - key.y) < 1)) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: acc.id,\n\t\t\t\t\t\tx: acc.x,\n\t\t\t\t\t\ty: acc.y,\n\t\t\t\t\t\tconfidence: acc.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{ type: KEYACC_CANDIDATE_SEMANTICS[acc.semantic], points }\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// octave shift heads\n\t\tconst octs = points.filter((point) => point.semantic === SemanticType.OctaveShift8);\n\t\tocts.forEach((oct) => {\n\t\t\tconst type = oct.y < 0 ? TokenType.OctaveShift8va : TokenType.OctaveShift8vb;\n\t\t\tthis.appendPoint(\n\t\t\t\t{\n\t\t\t\t\tid: oct.id,\n\t\t\t\t\tx: oct.x,\n\t\t\t\t\ty: oct.y,\n\t\t\t\t\tconfidence: oct.confidence,\n\t\t\t\t},\n\t\t\t\t{ type, points }\n\t\t\t);\n\t\t});\n\n\t\t// group volta dots\n\t\tconst voltaDots = this.semantics.filter((point) => [SemanticType.VoltaLeft, SemanticType.VoltaRight].includes(point.semantic));\n\t\tvoltaDots.sort((d1, d2) => d1.x - d2.x);\n\t\tconst voltaGroups: Record> = voltaDots.reduce(\n\t\t\t(groups, dot) => {\n\t\t\t\tconst group = groups[dot.semantic];\n\t\t\t\tconst xs = Array.from(Object.keys(group)).map(Number);\n\t\t\t\tconst x = xs.find((x) => dot.x < x + 0.2) || dot.x;\n\n\t\t\t\tgroup[x] = groups[dot.semantic][x] || [];\n\t\t\t\tgroup[x].push(dot);\n\n\t\t\t\treturn groups;\n\t\t\t},\n\t\t\t{ [SemanticType.VoltaLeft]: {}, [SemanticType.VoltaRight]: {} }\n\t\t);\n\t\tfor (const [type, group] of Object.entries(voltaGroups)) {\n\t\t\tObject.values(group).forEach((dots) => {\n\t\t\t\tif (dots.length > 1) {\n\t\t\t\t\tconst confidence = dots.reduce((sum, dot) => sum + dot.confidence, 0);\n\t\t\t\t\tif (dots[0].y * dots[1].y < 0 && confidence >= threshold * 2) this.appendPoint(dots[0], { type: TokenType[type] });\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tappendPoint(\n\t\tpoint: Partial,\n\t\t{ type, points = null, antiPoint, ...fields }: { type?: TokenType; antiPoint?: SemanticPoint; [key: string]: any } = {}\n\t): void {\n\t\t//console.log(\"appendPoint.0:\", point, point.x, point.y);\n\t\tconst x = point.x;\n\t\tconst measure = this.measures.find((measure) => x < measure.left + measure.width);\n\t\tif (!measure)\n\t\t\t// drop tokens out of measures range\n\t\t\treturn;\n\n\t\t// lined or interval\n\t\tlet lined = false;\n\t\tlet interval = false;\n\t\tif (STAFF_LINED_SEMANTICS.includes(point.semantic)) {\n\t\t\tconsole.assert(points, 'argument of points for this semantic is required:', point.semantic);\n\t\t\tconst signs = points.filter((p) => LINED_INTERVAL_SEMANTICS.includes(p.semantic) && Math.abs(p.y - point.y) < 0.2 && Math.abs(p.x - point.x) < 1.2);\n\t\t\tif (signs.some((s) => s.semantic === SemanticType.SignLined)) lined = true;\n\t\t\telse if (signs.some((s) => s.semantic === SemanticType.SignInterval)) interval = true;\n\t\t}\n\n\t\ttype = type || TokenType[point.semantic];\n\t\tconst fixedY = TOKEN_Y_FIXED[type];\n\t\tlet roundY = TOKEN_Y_ROUND[type];\n\n\t\tif (lined || interval) roundY = Math.max(roundY, 1);\n\n\t\tlet y = point.y;\n\t\tif (Number.isFinite(fixedY)) y = fixedY;\n\t\telse if (roundY) {\n\t\t\tif (interval) y = roundNumber(y + 0.5, roundY) - 0.5;\n\t\t\telse y = roundNumber(y, roundY);\n\t\t}\n\t\t//if (lined || interval)\n\t\t//\tconsole.log(\"round sign:\", point.semantic, y, lined, interval);\n\n\t\tconst holder = measure.tokens.find((token) => token.type === type && Math.abs(token.x - x) < 0.1 && Math.abs(token.y - y) < 0.1);\n\t\tif (holder) {\n\t\t\tif (Number.isFinite(holder.confidence) && holder.confidence < point.confidence) {\n\t\t\t\tholder.x = x;\n\t\t\t\tholder.y = y;\n\t\t\t\tholder.confidence = point.confidence;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// exlude clef out of pitch range\n\t\tif (TokenClefs.includes(type)) {\n\t\t\tif (Math.abs(y) > 3) return;\n\t\t}\n\n\t\t// TODO: exclude overlapped pair by a token prior table\n\n\t\tmeasure.tokens.push(\n\t\t\tnew Token({\n\t\t\t\tid: point.id,\n\t\t\t\ttype,\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tpivotX: point.pivotX,\n\t\t\t\tconfidence: point.confidence,\n\t\t\t\t...fields,\n\t\t\t})\n\t\t);\n\n\t\tif (antiPoint) {\n\t\t\tmeasure.antiTokens.push(\n\t\t\t\tnew Token({\n\t\t\t\t\tid: antiPoint.id,\n\t\t\t\t\ttype,\n\t\t\t\t\tx,\n\t\t\t\t\ty: antiPoint.y,\n\t\t\t\t\tconfidence: antiPoint.confidence,\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tappendFlags(flags: SemanticPoint[], stems: Stem[]): void {\n\t\t//console.log(\"flags:\", flags);\n\t\tconst stemGroups = stems\n\t\t\t.map((stem) => ({\n\t\t\t\t...stem,\n\t\t\t\tflags: flags.filter((flag) => Math.abs(flag.x - stem.x) < 0.3 && flag.y > stem.y1 - 0.5 && flag.y < stem.y2 + 0.5),\n\t\t\t}))\n\t\t\t.filter((group) => group.flags.length);\n\n\t\tstemGroups.forEach((group) => {\n\t\t\tconst mainFlag = group.flags.reduce((main, flag) => (main && main.confidence > flag.confidence ? main : flag), null);\n\n\t\t\t//const upDistance = mainFlag.y - group.y1;\n\t\t\t//const downDistance = group.y2 - mainFlag.y;\n\t\t\t//const downward = downDistance < upDistance;\n\t\t\tconst downward = group.direction === 'd';\n\n\t\t\tconst tailY = downward ? Math.min(group.y2, group.y1 + STEM_LENGTH_MAX) : Math.max(group.y1, group.y2 - STEM_LENGTH_MAX);\n\n\t\t\tconst flagTips = group.flags.map((flag) => ({\n\t\t\t\ttip: (tailY - flag.y) * (downward ? 1 : -1),\n\t\t\t\tconfidence: flag.confidence,\n\t\t\t}));\n\t\t\tconst count = flagTips.filter((f) => f.tip < 2 || f.confidence > mainFlag.confidence * 0.7).length;\n\n\t\t\tconst type = TokenFlags[count - 1];\n\t\t\tif (type) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: group.flags[0].id,\n\t\t\t\t\t\tx: group.x,\n\t\t\t\t\t\ty: tailY,\n\t\t\t\t\t\tconfidence: Math.min(...group.flags.map((flag) => flag.confidence)),\n\t\t\t\t\t},\n\t\t\t\t\t{ type }\n\t\t\t\t);\n\t\t\t\t//console.log(\"flag:\", type);\n\t\t\t}\n\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\t\tthis.semantics = [];\n\t}\n\n\tclearPredictedTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = measure.tokens.filter((token) => !token.isPredicted)));\n\t}\n}\n\nclass System extends SimpleClass {\n\tstatic className = 'System';\n\tstatic blackKeys = ['index', 'pageIndex', 'prev', 'next', 'headMeasureIndex', 'tokens', 'indent'];\n\n\tindex?: number;\n\tpageIndex?: number;\n\tprev?: System;\n\tnext?: System;\n\theadMeasureIndex?: number; // zero based\n\n\t// in units\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\tindent: boolean;\n\n\tmeasureCount: number;\n\tstaves: Staff[];\n\n\tmeasureBars: number[];\n\n\tbackgroundImage: string;\n\timagePosition: Rect;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tsidBlackList: string[];\n\tsidWhiteList: string[];\n\n\tdisplacementSemantics?: { [id: string]: Partial };\n\n\tstaffMaskChanged: number;\n\tbracketsAppearance: string; // the staff layout code by prediction\n\n\tconstructor({ stavesCount, ...fields }: any) {\n\t\tsuper();\n\t\tsuper.assign(fields);\n\n\t\tif (!this.measureBars) {\n\t\t\tconst HEAD_WIDTH = 5;\n\t\t\tconst segmentLength = (this.width - HEAD_WIDTH) / this.measureCount;\n\t\t\tthis.measureBars = Array(this.measureCount)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => HEAD_WIDTH + segmentLength * (i + 1));\n\t\t}\n\n\t\tif (!fields.staves && stavesCount)\n\t\t\tthis.staves = Array(stavesCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Staff({ measureBars: this.measureBars }));\n\n\t\tthis.arrangePosition();\n\n\t\tthis.measureCount = this.measureCount || this.measureBars.length;\n\n\t\tthis.sidBlackList = this.sidBlackList || [];\n\t\tthis.sidWhiteList = this.sidWhiteList || [];\n\t}\n\n\tget noteRange(): { top: number; bottom: number } {\n\t\tif (!this.staves.length) return null;\n\n\t\tconst staffTop = this.staves[0];\n\t\tconst staffBottom = this.staves[this.staves.length - 1];\n\n\t\treturn {\n\t\t\ttop: staffTop.top + staffTop.staffY + staffTop.noteRange.top,\n\t\t\tbottom: staffBottom.top + staffBottom.staffY + staffBottom.noteRange.bottom,\n\t\t};\n\t}\n\n\tget staffPositions(): StaffPosition[] {\n\t\treturn this.staves.map((staff) => ({\n\t\t\ty: staff.top + staff.staffY,\n\t\t\tradius: 2,\n\t\t}));\n\t}\n\n\tget staffMask(): number {\n\t\tif (this.staffMaskChanged) return this.staffMaskChanged;\n\n\t\tif (this.prev && this.staves.length === this.prev.staves.length) return this.prev.staffMask;\n\n\t\treturn 2 ** this.staves.length - 1;\n\t}\n\n\tget staffTop(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[0].y - positions[0].radius : 0;\n\t}\n\n\tget staffBottom(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[positions.length - 1].y + positions[positions.length - 1].radius : 0;\n\t}\n\n\tarrangePosition(): void {\n\t\tlet y = 0;\n\t\tfor (const staff of this.staves) {\n\t\t\tif (Number.isFinite(staff.top)) break;\n\n\t\t\tstaff.top = y;\n\t\t\ty += staff.height;\n\t\t}\n\t}\n\n\ttidyMeasureBars(): void {\n\t\tthis.measureBars = this.measureBars.filter((x) => x > 1);\n\t\tthis.measureBars.sort((b1, b2) => b1 - b2);\n\n\t\tconst restWidth = this.width - this.measureBars[this.measureBars.length - 1];\n\t\tif (restWidth > 12) this.measureBars.push(this.width);\n\t\telse if (restWidth < 2) this.measureBars[this.measureBars.length - 1] = this.width;\n\n\t\tthis.measureBars = this.measureBars.filter((x, i) => i < 1 || x - this.measureBars[i - 1] > 4);\n\t}\n\n\trearrangeMeasures(): void {\n\t\tthis.measureCount = this.measureBars.length;\n\t\tthis.staves.forEach((staff) => staff.rearrangeMeasures(this.measureBars));\n\t}\n\n\tget height(): number {\n\t\treturn this.staves.reduce((height, staff) => height + staff.height, 0);\n\t}\n\n\tget connectionLine(): { top: number; bottom: number } {\n\t\tconst staffHead = this.staves[0];\n\t\tconst staffTail = this.staves[this.staves.length - 1];\n\n\t\treturn (\n\t\t\tstaffHead && {\n\t\t\t\ttop: staffHead.top + staffHead.staffY - 2,\n\t\t\t\tbottom: staffTail.top + staffTail.staffY + 2,\n\t\t\t}\n\t\t);\n\t}\n\n\tget middleY(): number {\n\t\tif (!this.staves.length) return 0;\n\n\t\tconst sum = this.staves.reduce((sum, staff) => sum + staff.top + staff.staffY, 0);\n\n\t\treturn sum / this.staves.length;\n\t}\n\n\tget timeSignatureOnHead(): boolean {\n\t\treturn this.staves.some((staff) => staff.measures[0]?.tokens.some((token) => TokenTimesigs.includes(token.type)));\n\t}\n\n\t// an array staff or null on every position of full staff layout\n\tgetStaffArray(stavesCount: number): Staff[] {\n\t\tlet si = 0;\n\n\t\treturn Array(stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, i) => {\n\t\t\t\tconst on = this.staffMask & (1 << i);\n\t\t\t\tconst staff = on ? this.staves[si++] : null;\n\t\t\t\tconsole.assert(!on || staff, 'system staves count is less than staff mask declared:', this.staves.length, this.staffMask.toString(2));\n\n\t\t\t\treturn staff;\n\t\t\t});\n\t}\n\n\t// measureIndex: the local measure index\n\tgetMarksInMeasure(measureIndex: number): MarkTerm[] {\n\t\tconsole.assert(measureIndex < this.measureBars.length, 'measure index out of range:', measureIndex, this.measureBars.length);\n\n\t\tconst left = measureIndex > 0 ? this.measureBars[measureIndex - 1] : 0;\n\t\tconst right = this.measureBars[measureIndex];\n\n\t\tconst tempoTokens = (this.tokens ?? []).filter(\n\t\t\t(token) => token.x >= left && token.x < right && token instanceof TextToken && token.textType === TextType.TempoNumeral\n\t\t) as TextToken[];\n\n\t\treturn [...tempoTokens.map((token) => TempoTerm.fromNumeralText(token.text)).filter(Boolean)];\n\t}\n\n\tgetEvents(stavesCount: number): EventSystem {\n\t\tconsole.assert(Number.isInteger(this.headMeasureIndex), 'invalid headMeasureIndex:', this.headMeasureIndex);\n\n\t\t// Empty system (no measureBars / no staves with measures): return empty result\n\t\tif (!this.measureBars?.length && this.staves.every((s) => !s.measures?.length)) {\n\t\t\treturn { staffMask: this.staffMask, columns: [] };\n\t\t}\n\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => {\n\t\t\t\tconst events = measure.getEvents();\n\t\t\t\tmeasure.assignAccessoriesOnEvents(events);\n\t\t\t\tmeasure.assignFeaturesOnEvents(events, staff.semantics);\n\n\t\t\t\treturn {\n\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t\tcontexts: measure.getContexts({ staff: staff.index }),\n\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts?.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (row[mi] && !row[mi].contexts.length && !row[mi].events.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//onst measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: this.getMarksInMeasure(i),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i]?.voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i]?.voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row[i]?.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i]?.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\t\t//columns.forEach(computeMeasureTicks);\n\n\t\t// assign id on column events\n\t\tcolumns.forEach((column) => {\n\t\t\tconst events = [].concat(...column.rows.filter(Boolean).map((row) => row.events));\n\t\t\tevents.forEach((event, i) => (event.id = i + 1));\n\t\t});\n\n\t\tconst lastColumn = columns[columns.length - 1];\n\t\tif (lastColumn) lastColumn.break = true;\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tgetEventsFunctional(stavesCount: number, ev: ChordsFeeder, processors: ColumnProcessor[] = [], { useXMap = false } = {}): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff, si) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure, mi) => {\n\t\t\t\tconst events = ev(si, mi);\n\n\t\t\t\treturn (\n\t\t\t\t\tevents && {\n\t\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontexts: measure.getContexts({ staff: si }),\n\t\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\t// [measure, staff]\n\t\tconst columns: EventMeasureColumn[] = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => {\n\t\t\t\tconst localRows = rows.map((row) => row[mi]);\n\t\t\t\tif (localRows.some((row) => !row)) return null;\n\n\t\t\t\tlet xMap: Map = null;\n\t\t\t\tif (useXMap) {\n\t\t\t\t\tconst events: EventTerm[] = [].concat(...localRows.map((row) => row.events));\n\t\t\t\t\tconst groupMap: { [group: number]: EventTerm[] } = events.reduce((map, event) => {\n\t\t\t\t\t\tif (Number.isFinite(event.tickGroup)) map[event.tickGroup] = map[event.tickGroup] || [];\n\t\t\t\t\t\tmap[event.tickGroup].push(event);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, {});\n\n\t\t\t\t\txMap = Object.values(groupMap).reduce((map, events) => {\n\t\t\t\t\t\tconst x = Math.min(...events.map((event) => (event.left + event.right) / 2));\n\t\t\t\t\t\tmap.set(x, events);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, new Map());\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + mi,\n\t\t\t\t\t//startX: measureStartXs[mi],\n\t\t\t\t\t//width: measureWidths[mi],\n\t\t\t\t\trows: localRows, // [staff]\n\t\t\t\t\tmarks: this.getMarksInMeasure(mi),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\txMap,\n\t\t\t\t\tvoltaBegin: localRows.some((row) => row.voltaBegin),\n\t\t\t\t\tvoltaEnd: localRows.some((row) => row.voltaEnd),\n\t\t\t\t\talternative: localRows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: localRows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\tprocessors.forEach((proc) => columns.forEach(proc));\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\t// get EventSystem contains only contexted terms\n\tgetContexts(stavesCount: number): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: null,\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => ({\n\t\t\t\tevents: null,\n\t\t\t\tcontexts: measure.getContexts(),\n\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t}));\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (!row[mi].contexts.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: [],\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i].voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i].voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i].barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tassignSemantics(staffIndex: number, graph: SemanticGraph): void {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff is null:', staffIndex, this.staves);\n\t\tconst oy = staff.top + staff.staffY;\n\n\t\tgraph.getSystemPoints().forEach((point) => {\n\t\t\tconst p = { ...point };\n\t\t\tp.y += oy;\n\n\t\t\tif (p.extension) {\n\t\t\t\tp.extension = { ...p.extension };\n\t\t\t\tif (Number.isFinite(p.extension.y1)) {\n\t\t\t\t\tp.extension.y1 += oy;\n\t\t\t\t\tp.extension.y2 += oy;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.semantics.push(p);\n\t\t});\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, logger: Logger = new DummyLogger()): void {\n\t\t//console.log(\"System.assignSemantics:\", graph);\n\t\tthis.measureBars = [];\n\n\t\tif (!this.semantics) return;\n\n\t\tconst graph = SemanticGraph.fromPoints(this.semantics);\n\n\t\tconst bars = graph.getConfidentLayer(SemanticType.vline_BarMeasure, threshold);\n\t\tbars.sort((b1, b2) => b1.x - b2.x);\n\n\t\tconst staffTop = this.staffTop;\n\t\tconst staffBottom = this.staffBottom;\n\n\t\tconst MERGE_WINDOW = 0.4;\n\t\tlet lastX = 0;\n\t\tconst barColumns: { [key: number]: number } = bars.reduce((columns, bar) => {\n\t\t\tconst confidence = Number.isFinite(bar.confidence) ? Math.tanh(bar.confidence) : 1;\n\n\t\t\tconst x = bar.x - lastX > MERGE_WINDOW ? bar.x : lastX;\n\t\t\tlastX = bar.x;\n\t\t\tlet intensity = columns[x] || 0;\n\t\t\tintensity += (Math.min(bar.extension.y2, staffBottom) - Math.max(bar.extension.y1, staffTop)) * confidence;\n\n\t\t\tif (bar.x !== x) delete columns[x];\n\t\t\tcolumns[bar.x] = intensity;\n\n\t\t\treturn columns;\n\t\t}, {});\n\t\tconst barXs: number[] = Object.entries(barColumns)\n\t\t\t.filter(([x, intensity]) => (void x, intensity > 3 * this.staves.length))\n\t\t\t.map(([x]) => Number(x));\n\t\tbarXs.sort((x1, x2) => x1 - x2);\n\t\tbarXs.forEach((x, i) => {\n\t\t\tif (i <= 0 || x - barXs[i - 1] > 2) this.measureBars.push(x);\n\t\t});\n\n\t\tif (!this.measureBars.length) this.measureBars.push(this.width);\n\n\t\tthis.tidyMeasureBars();\n\t\tthis.rearrangeMeasures();\n\n\t\t// measure bar type\n\t\tconst typeBars = this.semantics.filter((point) => [SemanticType.vline_BarTerminal, SemanticType.vline_BarSegment].includes(point.semantic));\n\t\ttypeBars.forEach((bar) => {\n\t\t\tconst measure = this.staves[0].measures.find((measure) => bar.x > measure.right - 2 && bar.x < measure.right + 1);\n\t\t\tif (measure) {\n\t\t\t\tconst type = bar.semantic.replace(/^vline_Bar/, '');\n\t\t\t\tmeasure.barTypes[type] = measure.barTypes[type] || 0;\n\t\t\t\tmeasure.barTypes[type] += bar.confidence;\n\t\t\t}\n\t\t});\n\n\t\tlet staffIndex = 0;\n\t\tconst staffMask = this.staffMask;\n\t\tthis.staves.forEach((staff, si) => {\n\t\t\t// staff index\n\t\t\twhile (!(staffMask & (1 << staffIndex))) ++staffIndex;\n\t\t\tstaff.index = staffIndex++;\n\n\t\t\t// assign semantic boundaries\n\t\t\tif (si === 0) staff.semanticTop = -staff.staffY;\n\t\t\telse {\n\t\t\t\tconst prevStaff = this.staves[si - 1];\n\t\t\t\tstaff.semanticTop = prevStaff.top + prevStaff.staffY + 3 - (staff.top + staff.staffY);\n\t\t\t}\n\n\t\t\tif (si < this.staves.length - 1) {\n\t\t\t\tconst nextStaff = this.staves[si + 1];\n\t\t\t\tstaff.semanticBottom = nextStaff.top + nextStaff.staffY - 3 - (staff.top + staff.staffY);\n\t\t\t} else staff.semanticBottom = this.height - (staff.top + staff.staffY);\n\n\t\t\tif (staff.semantics && staff.semantics.length) {\n\t\t\t\tstaff.semantics.forEach((point) => hashSemanticPoint(this.index, si, point));\n\n\t\t\t\tstaff.clearPredictedTokens();\n\t\t\t\tstaff.assemble(threshold, this, logger);\n\t\t\t}\n\t\t});\n\t}\n\n\tqualifiedSemantics(semantics: SemanticPoint[], threshold: number = 1): SemanticPoint[] {\n\t\treturn semantics\n\t\t\t.filter(\n\t\t\t\t(p) => this.sidWhiteList.includes(p.id) || (!this.sidBlackList.includes(p.id) && (p.confidence >= threshold || !Number.isFinite(p.confidence)))\n\t\t\t)\n\t\t\t.map((point) => {\n\t\t\t\t// displace semantic point\n\t\t\t\tif (this.displacementSemantics && this.displacementSemantics[point.id]) return { ...point, ...this.displacementSemantics[point.id] };\n\n\t\t\t\treturn point;\n\t\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.staves.forEach((staff) => staff.clearTokens());\n\t\tthis.semantics = [];\n\t}\n\n\tnewPoint(staffIndex: number, data: SemanticPoint, threshold: number = 1): SemanticPoint {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff index out of bound:', staffIndex, this.staves.length);\n\n\t\tconst { semantic, x, y, confidence = 0, extension = null } = data;\n\t\tconst point = { semantic, x, y, confidence, extension };\n\t\tif (!point.extension) delete point.extension;\n\n\t\thashSemanticPoint(this.index, staffIndex, point);\n\t\tstaff.semantics.push(point);\n\t\tstaff.clearPredictedTokens();\n\t\tstaff.assemble(threshold, this);\n\n\t\treturn point;\n\t}\n\n\tappendToken(token: TextToken): void {\n\t\tthis.tokens.push(token);\n\n\t\tswitch (token.textType) {\n\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t{\n\t\t\t\t\t// remove noteheads in text area\n\t\t\t\t\tconst staff = this.staves[0];\n\t\t\t\t\tif (staff) {\n\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\t\t\t\t\t\tstaff.measures.forEach((measure) => {\n\t\t\t\t\t\t\tmeasure.tokens = measure.tokens.filter(\n\t\t\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t\t\t!TokenNoteheads.includes(t.type) ||\n\t\t\t\t\t\t\t\t\tMath.abs(t.x - token.x) > token.width / 2 ||\n\t\t\t\t\t\t\t\t\tMath.abs(oy + t.y - token.y) > token.fontSize / 2\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase TextType.Alternation1:\n\t\t\tcase TextType.Alternation2:\n\t\t\t\t//console.log(\"appendToken:\", token, this.staves[0].measures);\n\t\t\t\tthis.staves[0].measures.forEach((measure) => {\n\t\t\t\t\tconst overlap = Math.min(measure.left + measure.width, token.x + token.width / 2) - Math.max(measure.left, token.x - token.width / 2);\n\t\t\t\t\tmeasure.alternative = measure.alternative || overlap / measure.width > 0.5;\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nclass Page extends SimpleClass {\n\tstatic className = 'Page';\n\tstatic blackKeys = ['index', 'tokens'];\n\n\tindex?: number;\n\n\t// in units\n\twidth: number;\n\theight: number;\n\n\tsystems: System[];\n\n\tsource: SourceImageFile;\n\tlayout?: PageLayout;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.systems = this.systems || [];\n\n\t\tif (this.source) {\n\t\t\tthis.source.matrix = this.source.matrix || [1, 0, 0, 1, 0, 0];\n\t\t}\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tclearTokens(): void {\n\t\tthis.semantics = null;\n\t\tthis.tokens = null;\n\n\t\tthis.systems.forEach((system) => (system.tokens = null));\n\t}\n\n\tassignTexts(areas: TextArea[], [imageHeight, imageWidth]: [number, number]): void {\n\t\tconst interval = this.source && this.source.interval ? this.source.interval * (imageHeight / this.source.dimensions.height) : imageHeight / this.height;\n\n\t\tthis.semantics = areas.map((area) => {\n\t\t\tconst p = {\n\t\t\t\tx: (area.cx - imageWidth / 2) / interval,\n\t\t\t\ty: (area.cy - imageHeight / 2) / interval,\n\t\t\t};\n\t\t\tconst rp = this.source && this.source.matrix ? trans23(p, this.source.matrix) : p;\n\n\t\t\treturn {\n\t\t\t\tconfidence: area.score,\n\t\t\t\tx: rp.x + this.width / 2,\n\t\t\t\ty: rp.y + this.height / 2,\n\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\textension: {\n\t\t\t\t\ttext: area.text,\n\t\t\t\t\ttype: area.type,\n\t\t\t\t\twidth: area.width / interval,\n\t\t\t\t\theight: area.height / interval,\n\t\t\t\t\ttheta: area.theta,\n\t\t\t\t\ttextFeature: area.feature_dict,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tassemble({ textAnnotations = null }: { textAnnotations?: { [id: string]: string } } = {}, logger: Logger = new DummyLogger()): void {\n\t\tthis.tokens = [];\n\t\tthis.systems.forEach((system) => (system.tokens = []));\n\n\t\t// compute system indent\n\t\tif (this.systems.length) {\n\t\t\tconst sysXs = this.systems.map((system) => system.left);\n\t\t\tconst middleX = sysXs[Math.floor((sysXs.length - 1) / 2)];\n\t\t\tthis.systems.forEach((system) => (system.indent = system.left > middleX + INDENT_THRESHOLD));\n\t\t}\n\n\t\tif (this.semantics) {\n\t\t\tconst pageName = this.source ? this.source.name : this.index.toString();\n\n\t\t\tthis.semantics.forEach((point) => {\n\t\t\t\thashPageSemanticPoint(pageName, point);\n\n\t\t\t\tconst fields = {\n\t\t\t\t\tid: point.id,\n\t\t\t\t\ttype: TokenType.Text,\n\t\t\t\t\tconfidence: point.confidence,\n\t\t\t\t\ttextType: TEXT_TYPE_ALIAS[point.extension.type] || point.extension.type,\n\t\t\t\t\ttext: (textAnnotations && textAnnotations[point.id]) || point.extension.text,\n\t\t\t\t\ttextFeasure: point.extension.textFeature,\n\t\t\t\t\twidth: point.extension.width,\n\t\t\t\t\tfontSize: point.extension.height,\n\t\t\t\t};\n\n\t\t\t\tswitch (point.semantic) {\n\t\t\t\t\tcase SemanticType.rect_Text:\n\t\t\t\t\t\tswitch (fields.textType) {\n\t\t\t\t\t\t\t// page tokens\n\t\t\t\t\t\t\tcase TextType.Title:\n\t\t\t\t\t\t\tcase TextType.Author:\n\t\t\t\t\t\t\tcase TextType.PageMargin:\n\t\t\t\t\t\t\tcase TextType.Other:\n\t\t\t\t\t\t\t\tthis.tokens.push(\n\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens on the top of system\n\t\t\t\t\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t\t\t\tcase TextType.Chord:\n\t\t\t\t\t\t\tcase TextType.MeasureNumber:\n\t\t\t\t\t\t\tcase TextType.Instrument:\n\t\t\t\t\t\t\tcase TextType.Alternation1:\n\t\t\t\t\t\t\tcase TextType.Alternation2:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = this.systems.find((system) => system.top + system.staffTop > point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tsystem.appendToken(\n\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\tx: point.x - system.left,\n\t\t\t\t\t\t\t\t\t\t\t\ty: point.y - system.top,\n\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens in staff\n\t\t\t\t\t\t\tcase TextType.TextualMark:\n\t\t\t\t\t\t\tcase TextType.Times:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = [...this.systems].reverse().find((system) => system.top < point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tconst sy = point.y - (system.top + system.staffTop);\n\t\t\t\t\t\t\t\t\t\tconst sx = point.x - system.left;\n\t\t\t\t\t\t\t\t\t\tconst staff = system.staves.find((staff) => sy >= staff.top && sy < staff.top + staff.height);\n\t\t\t\t\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\t\t\t\t\tconst measure = staff.measures.find((measure) => sx >= measure.left && sx < measure.left + measure.width);\n\t\t\t\t\t\t\t\t\t\t\tif (measure) {\n\t\t\t\t\t\t\t\t\t\t\t\tmeasure.tokens.push(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx: sx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ty: sy,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport { Measure, Staff, System, Page };\n","import { ChordColumn, Fraction } from './interfaces';\nimport { GraceType } from './term';\nimport { roundNumber } from './utils';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum SemanticElementType {\n\tBOS,\n\tPAD,\n\n\tNoteheadS0,\n\tNoteheadS1,\n\tNoteheadS2,\n\tNoteheadGrace,\n\tvline_Stem,\n\tFlag3,\n\tBeamLeft,\n\tBeamContinue,\n\tBeamRight,\n\tDot,\n\tRest0,\n\tRest1,\n\tRest2,\n\tRest3,\n\tRest4,\n\tRest5,\n\tRest6,\n\n\t// measure time signature denominators & numerators\n\tTimeD2,\n\tTimeD4,\n\tTimeD8,\n\tTimeN1,\n\tTimeN2,\n\tTimeN3,\n\tTimeN4,\n\tTimeN5,\n\tTimeN6,\n\tTimeN7,\n\tTimeN8,\n\tTimeN9,\n\tTimeN10,\n\tTimeN11,\n\tTimeN12,\n}\n\nconst TIME_SIG_DENOMINATORS = Object.fromEntries([2, 4, 8].map((n) => [n, SemanticElementType[`TimeD${n}`]]));\nconst TIME_SIG_NUMERATORS = Object.fromEntries(\n\tArray(12)\n\t\t.fill(null)\n\t\t.map((_, i) => i + 1)\n\t\t.map((n) => [n, SemanticElementType[`TimeN${n}`]])\n);\n\nconst et = SemanticElementType;\n\nconst ELEMENT_TOKEN_NAMES = {\n\t[et.BOS]: 'BOS',\n\t[et.NoteheadS0]: 'noteheads-s0',\n\t[et.NoteheadS1]: 'noteheads-s1',\n\t[et.NoteheadS2]: 'noteheads-s2',\n\t[et.NoteheadGrace]: 'GraceNotehead',\n\t[et.Flag3]: 'flags-u3',\n\t[et.BeamLeft]: 'BeamLeft',\n\t[et.BeamContinue]: 'BeamContinue',\n\t[et.BeamRight]: 'BeamRight',\n\t[et.Dot]: 'dot',\n\t[et.Rest0]: 'rests-0o',\n\t[et.Rest1]: 'rests-1o',\n\t[et.Rest2]: 'rests-2',\n\t[et.Rest3]: 'rests-3',\n\t[et.Rest4]: 'rests-4',\n\t[et.Rest5]: 'rests-5',\n\t[et.Rest6]: 'rests-6',\n};\n\nconst NOTEHEAD_BASE_DIVISION = {\n\t[et.NoteheadS0]: 0,\n\t[et.NoteheadS1]: 1,\n\t[et.NoteheadS2]: 2,\n\t[et.NoteheadGrace]: 2,\n};\n\nconst NOTEHEAD_ELEMENT_TYPES = [et.NoteheadS0, et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace];\n\nconst REST_ELEMENT_TYPES = [et.Rest0, et.Rest1, et.Rest2, et.Rest3, et.Rest4, et.Rest5, et.Rest6];\n\nconst BEAM_ELEMENT_TYPES = [et.BeamLeft, et.BeamContinue, et.BeamRight];\n\nconst NOTE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES];\n\nconst SOURCE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES, et.vline_Stem];\n\nconst TARGET_ELEMENT_TYPES = [et.BOS, et.NoteheadS0, et.vline_Stem, ...REST_ELEMENT_TYPES];\n\nconst ROOT_NOTE_ELEMENT_TYPES = [...NOTE_ELEMENT_TYPES, et.vline_Stem];\n\nconst ELEMENT_TO_STEMBEAM = {\n\t[et.BeamLeft]: 'Open',\n\t[et.BeamRight]: 'Close',\n};\n\ninterface SemanticElement {\n\ttype: SemanticElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\n\tindex?: number;\n\ttick?: number;\n\tid?: string;\n}\n\ntype Matrix = number[][];\n\nconst metaElem = (type: SemanticElementType): SemanticElement => ({\n\ttype,\n\tstaff: -1,\n\tx: 0,\n\ty1: 0,\n\ty2: 0,\n});\n\nconst BOS_ELEMENT = metaElem(SemanticElementType.BOS);\n\nconst fractionToElems = (fraction: Fraction): SemanticElement[] => [\n\tmetaElem(TIME_SIG_NUMERATORS[fraction.numerator]),\n\tmetaElem(TIME_SIG_DENOMINATORS[fraction.denominator]),\n];\n\nconst argmax = (data: number[], mask: boolean[]): number => {\n\tconst values = data.filter((_, i) => mask[i]);\n\tconst max = Math.max(...values);\n\n\treturn data.findIndex((x) => x === max);\n};\n\nclass SemanticCluster extends SimpleClass {\n\tindex?: number;\n\n\telements: SemanticElement[];\n\tmatrixH?: Matrix; // matrix N x N\n\t_matrixV?: Matrix; // matrix N x N\n\tgroupsV?: number[][]; // ids array\n\tmasks?: [boolean[], boolean[], boolean[]]; // the masks for: [jointer source, jointer target, V]\n\n\tstatic elementToJSON(elem: SemanticElement): object {\n\t\tconst result: any = {\n\t\t\ttype: elem.type,\n\t\t\tstaff: elem.staff,\n\t\t\tx: elem.x,\n\t\t\ty1: elem.y1,\n\t\t\ty2: elem.y2,\n\t\t};\n\n\t\tif (elem.id) result.id = elem.id;\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget sourceMask(): boolean[] {\n\t\treturn this.elements.map((elem) => SOURCE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget targetMask(): boolean[] {\n\t\treturn this.elements.map((elem) => TARGET_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget vMask(): boolean[] {\n\t\treturn this.elements.map((elem) => ROOT_NOTE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget compactMatrixH(): Matrix {\n\t\tif (!this.matrixH) return null;\n\n\t\tconst sourceMask = this.sourceMask;\n\t\tconst targetMask = this.targetMask;\n\n\t\treturn this.matrixH.filter((_, i) => sourceMask[i]).map((row) => row.filter((_, j) => targetMask[j]));\n\t}\n\n\tset compactMatrixH(value: Matrix) {\n\t\tthis.matrixH = expandMatrixByMasks([].concat(...value), [this.sourceMask, this.targetMask]);\n\t}\n\n\tget compactMatrixV(): number[] {\n\t\tif (!this._matrixV) return null;\n\n\t\tconst vMask = this.vMask;\n\n\t\tconst matrix = this._matrixV.filter((_, i) => vMask[i]).map((row) => row.filter((_, j) => vMask[j]));\n\n\t\treturn [].concat(...matrix.map((row, i) => row.slice(0, i)));\n\t}\n\n\tset compactMatrixV(value: number[]) {\n\t\tthis.matrixV = value && expandMatrixByMaskTriu(value, this.vMask);\n\t}\n\n\tget matrixV(): Matrix {\n\t\treturn this.groupsV && matrixFromGroups(this.elements.length, this.groupsV);\n\t}\n\n\tset matrixV(value: Matrix) {\n\t\tif (!value) {\n\t\t\tthis.groupsV = null;\n\t\t\tthis._matrixV = value;\n\t\t\treturn;\n\t\t}\n\n\t\tconst THRESHOLD = 0.5;\n\n\t\tconst groups: number[][] = [];\n\t\tconst vMask = value.map((row, i) => row.some(Number.isFinite) || value.some((row) => Number.isFinite(row[i])));\n\n\t\tvalue.forEach((row, i) => {\n\t\t\tif (vMask[i]) {\n\t\t\t\tlet found = false;\n\n\t\t\t\tfor (let j = 0; j < i; ++j) {\n\t\t\t\t\tconst cell = row[j];\n\t\t\t\t\tif (cell >= THRESHOLD) {\n\t\t\t\t\t\tconst g = groups.findIndex((group) => group.includes(j));\n\t\t\t\t\t\tgroups[g].push(i);\n\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!found) groups.push([i]);\n\t\t\t}\n\t\t});\n\n\t\tthis.groupsV = groups;\n\t\tthis._matrixV = value;\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\t__prototype: 'SemanticCluster',\n\t\t\tindex: this.index,\n\t\t\telements: this.elements.map(SemanticCluster.elementToJSON),\n\t\t\tcompactMatrixH: this.compactMatrixH,\n\t\t\tcompactMatrixV: this.compactMatrixV,\n\t\t\t//groupsV: this.groupsV,\n\t\t};\n\t}\n\n\tstatic mapMatrix(matrix: number[][], x2i: number[], i2x: number[]): number[][] {\n\t\tconst rows = x2i.reduce((rows, i, x) => {\n\t\t\tif (rows[i]) rows[i] = rows[i].map((v, xi) => (v + matrix[x][xi] ? 1 : 0));\n\t\t\telse rows[i] = matrix[x];\n\n\t\t\treturn rows;\n\t\t}, [] as number[][]);\n\n\t\treturn rows.map((row) => i2x.map((x) => row[x]));\n\t}\n\n\tmergeOverlapping() {\n\t\tconst overlaps = this.overlappedNoteheads();\n\t\tif (overlaps.length) {\n\t\t\tconst x2i = this.elements.map((_, index) => {\n\t\t\t\tconst pair = overlaps.find((ij) => index === ij[1]);\n\t\t\t\tconst i = pair ? pair[0] : index;\n\n\t\t\t\treturn i - overlaps.filter((ij) => ij[1] < i).length;\n\t\t\t});\n\t\t\tconst i2x = Array(this.elements.length - overlaps.length)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, i) => x2i.findIndex((ii) => ii === i));\n\n\t\t\tthis.elements = i2x.map((x) => this.elements[x]);\n\t\t\tconsole.assert(this.elements.every(Boolean), 'null element found:', this, x2i, i2x);\n\n\t\t\tthis.matrixH = SemanticCluster.mapMatrix(this.matrixH, x2i, i2x);\n\t\t\tthis.groupsV = this.groupsV.map((group) => Array.from(new Set(group.map((x) => x2i[x]))));\n\t\t}\n\t}\n\n\toverlappedNoteheads(): [number, number][] {\n\t\tconst indices = [];\n\n\t\tconst noteheads = this.elements.filter((elem) => NOTEHEAD_ELEMENT_TYPES.includes(elem.type));\n\t\tfor (let i = 0; i < noteheads.length; ++i) {\n\t\t\tconst nh1 = noteheads[i];\n\t\t\tfor (let j = i + 1; j < noteheads.length; ++j) {\n\t\t\t\tconst nh2 = noteheads[j];\n\t\t\t\tif ((nh1.x - nh2.x) * (nh1.x - nh2.x) + (nh1.y1 - nh2.y1) * (nh1.y1 - nh2.y1) < 0.2 ** 2) indices.push([nh1.index, nh2.index]);\n\t\t\t}\n\t\t}\n\n\t\treturn indices;\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\tconsole.assert(this.matrixH, '[SemanticCluster.getEvents]\tmatrixH is null.');\n\n\t\tconst NOTE_STEM_CONFIDENCE = 0.5;\n\n\t\tconst ids = Array(this.elements.length)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => index);\n\n\t\tconst targetMask = this.masks ? this.masks[1] : ids.map((id) => TARGET_ELEMENT_TYPES.includes(this.elements[id].type));\n\n\t\t//const stems = ids.filter(i => this.elements[i].type === et.vline_Stem);\n\t\tconst stemMasks = ids.map((id) => this.elements[id].type === et.vline_Stem && this.elements[id].y2 - this.elements[id].y1 > 2); // TODO: sift out too short stems by rectification model\n\t\tconst stemNotes = ids.filter((i) => [et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace].includes(this.elements[i].type));\n\t\tconst s0s = ids.filter((i) => this.elements[i].type === et.NoteheadS0);\n\t\tconst subS0Masks = ids.map(() => false);\n\n\t\t// root elements: top NoteheadS0, Rests, stem with noteheads\n\t\tconst stemMap: { [stem: number]: number[] } = {};\n\t\tstemNotes.forEach((id) => {\n\t\t\tconst note = this.elements[id];\n\t\t\tconst stems = ids\n\t\t\t\t.filter((i) => stemMasks[i])\n\t\t\t\t.filter((stemId) => this.elements[stemId].y1 - 0.5 < note.y1 && this.elements[stemId].y2 + 0.5 > note.y1) // filter by stem Y range\n\t\t\t\t.sort((i1, i2) => this.matrixH[id][i2] - this.matrixH[id][i1]) // sort by confidence\n\t\t\t\t.slice(0, 2)\n\t\t\t\t.filter((i, ii) => ii === 0 || this.matrixH[id][i] >= NOTE_STEM_CONFIDENCE);\n\t\t\tstems.forEach((stem) => {\n\t\t\t\tstemMap[stem] = stemMap[stem] || [];\n\t\t\t\tstemMap[stem].push(id);\n\t\t\t});\n\t\t});\n\n\t\ts0s.forEach((id) => {\n\t\t\tconst s0 = this.elements[id];\n\t\t\tconst prevId = argmax(this.matrixH[id], targetMask);\n\t\t\tconst prev = this.elements[prevId];\n\t\t\tif (prev.type === et.NoteheadS0 && Math.abs(s0.x - prev.x) < 2.6) {\n\t\t\t\tsubS0Masks[id] = true;\n\t\t\t\tstemMap[prevId] = stemMap[prevId] || [prevId];\n\t\t\t\tstemMap[prevId].push(id);\n\t\t\t} else stemMap[id] = stemMap[id] || [id];\n\t\t});\n\n\t\t// setup linkings\n\t\tconst linkings: { [key: number]: number } = {};\n\n\t\tconst roots = ids.filter((id) => stemMap[id] || REST_ELEMENT_TYPES.includes(this.elements[id].type));\n\t\troots.sort((i1, i2) => this.elements[i1].x - this.elements[i2].x); // traverse roots from left to right later\n\n\t\tconst parentMasks = ids.map((id) => id === et.BOS);\n\t\troots.forEach((id) => {\n\t\t\tconst parentId = argmax(this.matrixH[id], parentMasks);\n\t\t\tlinkings[id] = parentId;\n\n\t\t\tif (parentId && !REST_ELEMENT_TYPES.includes(this.elements[parentId].type)) parentMasks[parentId] = false;\n\n\t\t\tparentMasks[id] = true;\n\t\t});\n\t\t//console.log(\"topology:\", stemMap, linkings);\n\n\t\tconst dots = this.elements.filter((elem) => elem.type === et.Dot);\n\t\tconst flags = this.elements.filter((elem) => elem.type === et.Flag3);\n\t\tconst beams = this.elements.filter((elem) => BEAM_ELEMENT_TYPES.includes(elem.type));\n\n\t\tconst groupsV = this.groupsV;\n\n\t\treturn roots\n\t\t\t.map((rootId): ChordColumn => {\n\t\t\t\tconst root = this.elements[rootId];\n\n\t\t\t\tconst tickGroup = groupsV ? groupsV.findIndex((group) => group.includes(rootId)) : null;\n\n\t\t\t\tif (REST_ELEMENT_TYPES.includes(root.type)) {\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > root.x + 0.5 && dot.x < root.x + 0.75 + 1.2 && dot.y1 > root.y1 - 1 && dot.y1 < root.y1);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft: root.x - 0.75,\n\t\t\t\t\t\tright: root.x + 0.75,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\trest: true,\n\t\t\t\t\t\tys: [root.y1],\n\t\t\t\t\t\tnoteIds: [root.id],\n\t\t\t\t\t\tdots: nearbyDots.length,\n\t\t\t\t\t\tdivision: root.type - et.Rest0,\n\t\t\t\t\t\tstemDirection: null,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: root.staff,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t} else if (stemMap[rootId]) {\n\t\t\t\t\tconst subNotes = stemMap[rootId].map((id) => this.elements[id]);\n\t\t\t\t\tconst left = Math.min(...subNotes.map((n) => n.x - 0.7));\n\t\t\t\t\tconst right = Math.max(...subNotes.map((n) => n.x + 0.7));\n\t\t\t\t\tsubNotes.sort((n1, n2) => n2.y1 - n1.y1);\n\n\t\t\t\t\tconst ys = subNotes.map((note) => note.y1);\n\n\t\t\t\t\tconst noteIds = subNotes.map((note) => note.id);\n\n\t\t\t\t\tconst top = ys[0];\n\t\t\t\t\tconst bottom = ys[ys.length - 1];\n\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > right && dot.x < right + 1.2 && dot.y1 > top - 1 && dot.y1 < bottom + 0.5);\n\t\t\t\t\tconst dotGroups: { [key: number]: SemanticElement[] } = nearbyDots.reduce((groups, dot) => {\n\t\t\t\t\t\tconst y = roundNumber(dot.y1, 0.5);\n\t\t\t\t\t\tgroups[y] = groups[y] || [];\n\t\t\t\t\t\tgroups[y].push(dot);\n\n\t\t\t\t\t\treturn groups;\n\t\t\t\t\t}, {});\n\t\t\t\t\tconst dotValue = Math.max(...Object.values(dotGroups).map((group) => group.length), 0);\n\n\t\t\t\t\tlet division = NOTEHEAD_BASE_DIVISION[subNotes[0].type];\n\n\t\t\t\t\tlet stemDirection = null;\n\t\t\t\t\tlet beam: string = null;\n\t\t\t\t\tlet tip = null;\n\t\t\t\t\tif (root.type === et.vline_Stem) {\n\t\t\t\t\t\tconst topTip = top - root.y1;\n\t\t\t\t\t\tconst bottomTip = root.y2 - bottom;\n\t\t\t\t\t\tstemDirection = topTip > bottomTip ? 'u' : 'd';\n\n\t\t\t\t\t\ttip = { x: root.x, y: stemDirection === 'u' ? root.y1 : root.y2 };\n\n\t\t\t\t\t\tif (division === 2) {\n\t\t\t\t\t\t\tconst flagRange = stemDirection === 'u' ? [root.y1 - 0.4, root.y2 - 1] : [root.y1 + 1, root.y2 + 0.4];\n\t\t\t\t\t\t\tconst nearbyFlags = flags.filter((flag) => Math.abs(flag.x - root.x) < 0.2 && flag.y1 > flagRange[0] && flag.y1 < flagRange[1]);\n\t\t\t\t\t\t\tdivision += nearbyFlags.length;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//const tipY = stemDirection === \"u\" ? root.y1 : root.y2;\n\t\t\t\t\t\tconst tipRange = stemDirection === 'u' ? [root.y1 - 0.2, root.y1 + 0.9] : [root.y2 - 0.9, root.y2 + 0.2];\n\t\t\t\t\t\tconst beamElem = beams.find((beam) => Math.abs(beam.x - root.x) < 0.2 && beam.y1 > tipRange[0] && beam.y1 < tipRange[1]);\n\t\t\t\t\t\tbeam = beamElem ? ELEMENT_TO_STEMBEAM[beamElem.type] : null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst grace = subNotes[0].type === SemanticElementType.NoteheadGrace ? GraceType.Grace : null;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\tright,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tys,\n\t\t\t\t\t\ttip,\n\t\t\t\t\t\tnoteIds,\n\t\t\t\t\t\tdivision,\n\t\t\t\t\t\tdots: dotValue,\n\t\t\t\t\t\trest: false,\n\t\t\t\t\t\tstemDirection,\n\t\t\t\t\t\tbeam,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: subNotes[0].staff,\n\t\t\t\t\t\tgrace,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n}\n\ninterface SemanticClusterSetData {\n\tvocab?: string[];\n\tclusters: SemanticCluster[];\n}\n\nclass SemanticClusterSet {\n\tclusters: SemanticCluster[];\n\n\tconstructor(data?: SemanticClusterSetData) {\n\t\tif (data) {\n\t\t\tthis.clusters = data.clusters;\n\n\t\t\t// upgrade vocab\n\t\t\tif (data.vocab) {\n\t\t\t\tconst converts = data.vocab\n\t\t\t\t\t.map((name, i) => [i, SemanticElementType[name]])\n\t\t\t\t\t.filter(([x, y]) => x !== y)\n\t\t\t\t\t.reduce((table, [x, y]) => ((table[x] = y), table), {});\n\t\t\t\tthis.clusters.forEach((connection) =>\n\t\t\t\t\tconnection.elements.forEach((elem) => {\n\t\t\t\t\t\tif (Number.isFinite(converts[elem.type])) elem.type = converts[elem.type];\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst vocab = Object.entries(SemanticElementType)\n\t\t\t.filter((entry) => Number.isFinite(entry[1]))\n\t\t\t.map((entry) => entry[0]);\n\n\t\treturn {\n\t\t\t__prototype: 'SemanticClusterSet',\n\t\t\tvocab,\n\t\t\tclusters: this.clusters.map((c) => c.toJSON()),\n\t\t};\n\t}\n}\n\nconst expandMatrixByMasks = (matrix: number[], masks: [boolean[], boolean[]]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\tconst [maskSrc, maskTar] = masks;\n\n\treturn maskSrc.map((src) => maskTar.map((tar) => (src && tar ? iter.next().value : null)));\n};\n\nconst expandMatrixByMaskTriu = (matrix: number[], mask: boolean[]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\treturn mask.map((row, i) => mask.map((column, j) => (row && column && j < i ? iter.next().value : null)));\n};\n\nconst matrixFromGroups = (len: number, groups: number[][]): Matrix => {\n\tconst groupIds = Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) => groups.findIndex((group) => group.includes(i)));\n\n\treturn Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) =>\n\t\t\tArray(len)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, j) => {\n\t\t\t\t\tif (j >= i) return null;\n\n\t\t\t\t\tconst id1 = groupIds[i];\n\t\t\t\t\tconst id2 = groupIds[j];\n\n\t\t\t\t\tif (id1 < 0 || id2 < 0) return null;\n\n\t\t\t\t\treturn id1 === id2 ? 1 : 0;\n\t\t\t\t})\n\t\t);\n};\n\nexport {\n\tSemanticElementType,\n\tSemanticElement,\n\tSemanticCluster,\n\tSemanticClusterSet,\n\tELEMENT_TOKEN_NAMES,\n\tNOTEHEAD_ELEMENT_TYPES,\n\tNOTE_ELEMENT_TYPES,\n\tBOS_ELEMENT,\n\tfractionToElems,\n\texpandMatrixByMasks,\n\texpandMatrixByMaskTriu,\n\tmatrixFromGroups,\n};\n","import { MusicNotation } from '@k-l-lambda/music-widgets';\n\n// implicit note (from expressive marks) types\nenum ImplicitType {\n\tNone = 0,\n\n\tMordent = 'mordent',\n\tPrall = 'prall',\n\tTurn = 'turn',\n\tTrill = 'trill',\n\tTremolo = 'tremolo',\n\tArpeggio = 'arpeggio',\n}\n\ninterface ChordPosition {\n\tindex: number;\n\tcount: number;\n}\n\nclass TokenPosition {\n\tsystem?: number;\n\tmeasure?: number;\n\tx: number;\n\tendX?: number;\n}\n\ninterface Note extends MusicNotation.Note {\n\tchordPosition?: ChordPosition;\n\tmeasure?: number;\n}\n\ninterface Notation {\n\tnotes: Note[];\n\tendTick: number;\n}\n\ninterface SheetPosition {\n\tsystem: number;\n\tx: number;\n}\n\nexport { ChordPosition, ImplicitType, TokenPosition, Note, Notation, SheetPosition };\n","\n/* Wrapper for accessing buffer through sequential reads */\n\n\n\nmodule.exports = class Stream {\n\tconstructor (buffer) {\n\t\tthis.array = new Uint8Array(buffer);\n\t\tthis.position = 0;\n\t}\n\n\n\teof () {\n\t\treturn this.position >= this.array.length;\n\t}\n\n\n\tread (length) {\n\t\tconst result = this.array.slice(this.position, this.position + length);\n\t\tthis.position += length;\n\n\t\treturn result;\n\t}\n\n\n\treadString (length) {\n\t\tconst data = Array.from(this.read(length));\n\n\t\treturn data.map(c => String.fromCharCode(c)).join(\"\");\n\t}\n\n\n\t// read a big-endian 32-bit integer\n\treadInt32 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 24) +\n\t\t\t(this.array[this.position + 1] << 16) +\n\t\t\t(this.array[this.position + 2] << 8) +\n\t\t\tthis.array[this.position + 3]);\n\t\tthis.position += 4;\n\n\t\treturn result;\n\t}\n\n\n\t// read a big-endian 16-bit integer\n\treadInt16 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 8) +\n\t\t\tthis.array[this.position + 1]);\n\t\tthis.position += 2;\n\n\t\treturn result;\n\t}\n\n\n\t// read an 8-bit integer\n\treadInt8 (signed) {\n\t\tlet result = this.array[this.position];\n\t\tif (signed && result > 127)\n\t\t\tresult -= 256;\n\t\tthis.position += 1;\n\n\t\treturn result;\n\t}\n\n\n\t/* read a MIDI-style variable-length integer\n\t\t(big-endian value in groups of 7 bits,\n\t\twith top bit set to signify that another byte follows)\n\t*/\n\treadVarInt () {\n\t\tlet result = 0;\n\t\twhile (true) {\n\t\t\tconst b = this.readInt8();\n\t\t\tif (b & 0x80) {\n\t\t\t\tresult += (b & 0x7f);\n\t\t\t\tresult <<= 7;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// b is the last byte\n\t\t\t\treturn result + b;\n\t\t\t}\n\t\t}\n\t}\n};\n","/*\nclass to parse the .mid file format\n(depends on stream.js)\n*/\n\nconst Stream = require(\"./stream.js\");\n\n\n\nmodule.exports = function MidiFile (data) {\n\tfunction readChunk (stream) {\n\t\tconst id = stream.readString(4);\n\t\tconst length = stream.readInt32();\n\n\t\treturn {\n\t\t\tid,\n\t\t\tlength,\n\t\t\tdata: stream.read(length),\n\t\t};\n\t}\n\n\tlet lastEventTypeByte;\n\n\tfunction readEvent (stream) {\n\t\tconst event = {};\n\t\tevent.deltaTime = stream.readVarInt();\n\t\tlet eventTypeByte = stream.readInt8();\n\t\tif ((eventTypeByte & 0xf0) === 0xf0) {\n\t\t\t// system / meta event\n\t\t\tif (eventTypeByte === 0xff) {\n\t\t\t\t// meta event\n\t\t\t\tevent.type = \"meta\";\n\t\t\t\tconst subtypeByte = stream.readInt8();\n\t\t\t\tconst length = stream.readVarInt();\n\n\t\t\t\tswitch (subtypeByte) {\n\t\t\t\tcase 0x00:\n\t\t\t\t\tevent.subtype = \"sequenceNumber\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for sequenceNumber event is 2, got \" + length);\n\t\t\t\t\tevent.number = stream.readInt16();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x01:\n\t\t\t\t\tevent.subtype = \"text\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x02:\n\t\t\t\t\tevent.subtype = \"copyrightNotice\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x03:\n\t\t\t\t\tevent.subtype = \"trackName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x04:\n\t\t\t\t\tevent.subtype = \"instrumentName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x05:\n\t\t\t\t\tevent.subtype = \"lyrics\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x06:\n\t\t\t\t\tevent.subtype = \"marker\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x07:\n\t\t\t\t\tevent.subtype = \"cuePoint\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x20:\n\t\t\t\t\tevent.subtype = \"midiChannelPrefix\";\n\t\t\t\t\tif (length !== 1)\n\t\t\t\t\t\tthrow new Error(\"Expected length for midiChannelPrefix event is 1, got \" + length);\n\t\t\t\t\tevent.channel = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x2f:\n\t\t\t\t\tevent.subtype = \"endOfTrack\";\n\t\t\t\t\tif (length !== 0)\n\t\t\t\t\t\tthrow new Error(\"Expected length for endOfTrack event is 0, got \" + length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x51:\n\t\t\t\t\tevent.subtype = \"setTempo\";\n\t\t\t\t\tif (length !== 3)\n\t\t\t\t\t\tthrow new Error(\"Expected length for setTempo event is 3, got \" + length);\n\t\t\t\t\tevent.microsecondsPerBeat = (\n\t\t\t\t\t\t(stream.readInt8() << 16) +\n\t\t\t\t\t\t\t(stream.readInt8() << 8) +\n\t\t\t\t\t\t\tstream.readInt8()\n\t\t\t\t\t);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x54:\n\t\t\t\t\tevent.subtype = \"smpteOffset\";\n\t\t\t\t\tif (length !== 5)\n\t\t\t\t\t\tthrow new Error(\"Expected length for smpteOffset event is 5, got \" + length);\n\t\t\t\t\tconst hourByte = stream.readInt8();\n\t\t\t\t\tevent.frameRate = {\n\t\t\t\t\t\t0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30,\n\t\t\t\t\t}[hourByte & 0x60];\n\t\t\t\t\tevent.hour = hourByte & 0x1f;\n\t\t\t\t\tevent.min = stream.readInt8();\n\t\t\t\t\tevent.sec = stream.readInt8();\n\t\t\t\t\tevent.frame = stream.readInt8();\n\t\t\t\t\tevent.subframe = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x58:\n\t\t\t\t\tevent.subtype = \"timeSignature\";\n\t\t\t\t\tif (length !== 4)\n\t\t\t\t\t\tthrow new Error(\"Expected length for timeSignature event is 4, got \" + length);\n\t\t\t\t\tevent.numerator = stream.readInt8();\n\t\t\t\t\tevent.denominator = Math.pow(2, stream.readInt8());\n\t\t\t\t\tevent.metronome = stream.readInt8();\n\t\t\t\t\tevent.thirtyseconds = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x59:\n\t\t\t\t\tevent.subtype = \"keySignature\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for keySignature event is 2, got \" + length);\n\t\t\t\t\tevent.key = stream.readInt8(true);\n\t\t\t\t\tevent.scale = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x7f:\n\t\t\t\t\tevent.subtype = \"sequencerSpecific\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tdefault:\n\t\t\t\t\t// console.log(\"Unrecognised meta event subtype: \" + subtypeByte);\n\t\t\t\t\tevent.subtype = \"unknown\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\t}\n\n\t\t\t\t//event.data = stream.readString(length);\n\t\t\t\t//return event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf0) {\n\t\t\t\tevent.type = \"sysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf7) {\n\t\t\t\tevent.type = \"dividedSysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type byte: \" + eventTypeByte);\n\t\t}\n\t\telse {\n\t\t\t/* channel event */\n\t\t\tlet param1;\n\t\t\tif ((eventTypeByte & 0x80) === 0) {\n\t\t\t\t/* running status - reuse lastEventTypeByte as the event type.\n\t\t\t\t\teventTypeByte is actually the first parameter\n\t\t\t\t*/\n\t\t\t\tparam1 = eventTypeByte;\n\t\t\t\teventTypeByte = lastEventTypeByte;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tparam1 = stream.readInt8();\n\t\t\t\tlastEventTypeByte = eventTypeByte;\n\t\t\t}\n\n\t\t\tconst eventType = eventTypeByte >> 4;\n\t\t\tevent.channel = eventTypeByte & 0x0f;\n\t\t\tevent.type = \"channel\";\n\n\t\t\tswitch (eventType) {\n\t\t\tcase 0x08:\n\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x09:\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\t\t\t\tif (event.velocity === 0)\n\t\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\telse\n\t\t\t\t\tevent.subtype = \"noteOn\";\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0a:\n\t\t\t\tevent.subtype = \"noteAftertouch\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.amount = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0b:\n\t\t\t\tevent.subtype = \"controller\";\n\t\t\t\tevent.controllerType = param1;\n\t\t\t\tevent.value = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0c:\n\t\t\t\tevent.subtype = \"programChange\";\n\t\t\t\tevent.programNumber = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0d:\n\t\t\t\tevent.subtype = \"channelAftertouch\";\n\t\t\t\tevent.amount = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0e:\n\t\t\t\tevent.subtype = \"pitchBend\";\n\t\t\t\tevent.value = param1 + (stream.readInt8() << 7);\n\n\t\t\t\treturn event;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type: \" + eventType);\n\n\t\t\t\t/*\n\t\t\t\tconsole.log(\"Unrecognised MIDI event type: \" + eventType);\n\t\t\t\tstream.readInt8();\n\t\t\t\tevent.subtype = 'unknown';\n\t\t\t\treturn event;\n\t\t\t\t*/\n\t\t\t}\n\t\t}\n\t}\n\n\n\tlet source = data;\n\tif (typeof data === \"string\")\n\t\tsource = data.split(\"\").map(c => c.charCodeAt(0));\n\n\tconst stream = new Stream(source);\n\tconst headerChunk = readChunk(stream);\n\tif (headerChunk.id !== \"MThd\" || headerChunk.length !== 6)\n\t\tthrow new Error(\"Bad .mid file - header not found\");\n\n\tconst headerStream = new Stream(headerChunk.data);\n\tconst formatType = headerStream.readInt16();\n\tconst trackCount = headerStream.readInt16();\n\tconst timeDivision = headerStream.readInt16();\n\n\tlet ticksPerBeat;\n\tif (timeDivision & 0x8000)\n\t\tthrow new Error(\"Expressing time division in SMTPE frames is not supported yet\");\n\telse\n\t\tticksPerBeat = timeDivision;\n\n\n\tconst header = {\n\t\tformatType,\n\t\ttrackCount,\n\t\tticksPerBeat,\n\t};\n\tconst tracks = [];\n\tfor (let i = 0; i < header.trackCount; i++) {\n\t\ttracks[i] = [];\n\t\tconst trackChunk = readChunk(stream);\n\t\tif (trackChunk.id !== \"MTrk\")\n\t\t\tthrow new Error(\"Unexpected chunk - expected MTrk, got \" + trackChunk.id);\n\n\t\tconst trackStream = new Stream(trackChunk.data);\n\t\twhile (!trackStream.eof()) {\n\t\t\tconst event = readEvent(trackStream);\n\t\t\ttracks[i].push(event);\n\t\t}\n\t}\n\n\treturn {\n\t\theader,\n\t\ttracks,\n\t};\n};\n","\r\n/* Wrapper for accessing strings through sequential writes */\r\n\r\n\r\n\r\nmodule.exports = class OStream {\r\n\tconstructor () {\r\n\t\tthis.buffer = \"\";\r\n\t}\r\n\r\n\twrite (str) {\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\t/* write a big-endian 32-bit integer */\r\n\twriteInt32 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 24) & 0xff) + String.fromCharCode((i >> 16) & 0xff) +\r\n\t\t\tString.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a big-endian 16-bit integer */\r\n\twriteInt16 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write an 8-bit integer */\r\n\twriteInt8 (i) {\r\n\t\tthis.buffer += String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a MIDI-style variable-length integer\r\n\t\t(big-endian value in groups of 7 bits,\r\n\t\twith top bit set to signify that another byte follows)\r\n\t*/\r\n\twriteVarInt (i) {\r\n\t\tif (i < 0)\r\n\t\t\tthrow new Error(\"OStream.writeVarInt minus number: \" + i);\r\n\r\n\t\tconst b = i & 0x7f;\r\n\t\ti >>= 7;\r\n\t\tlet str = String.fromCharCode(b);\r\n\r\n\t\twhile (i) {\r\n\t\t\tconst b = i & 0x7f;\r\n\t\t\ti >>= 7;\r\n\t\t\tstr = String.fromCharCode(b | 0x80) + str;\r\n\t\t}\r\n\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\tgetBuffer () {\r\n\t\treturn this.buffer;\r\n\t}\r\n\r\n\tgetArrayBuffer () {\r\n\t\treturn Uint8Array.from(this.buffer.split(\"\").map(c => c.charCodeAt(0))).buffer;\r\n\t}\r\n};\r\n","/*\r\nclass to encode the .mid file format\r\n(depends on streamEx.js)\r\n*/\r\n\r\nconst OStream = require(\"./streamEx.js\");\r\n\r\n\r\n\r\nmodule.exports = function OMidiFile ({ header, tracks }) {\r\n\tfunction writeChunk (stream, id, data) {\r\n\t\tconsole.assert(id.length === 4, \"chunk id must be 4 byte\");\r\n\r\n\t\tstream.write(id);\r\n\t\tstream.writeInt32(data.length);\r\n\t\tstream.write(data);\r\n\t}\r\n\r\n\tfunction writeEvent (stream, event) {\r\n\t\tif (event.subtype === \"unknown\")\r\n\t\t\treturn;\r\n\r\n\t\tstream.writeVarInt(event.deltaTime);\r\n\r\n\t\tswitch (event.type) {\r\n\t\tcase \"meta\":\r\n\t\t\tstream.writeInt8(0xff);\r\n\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"sequenceNumber\":\r\n\t\t\t\tstream.writeInt8(0x00);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt16(event.number);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"text\":\r\n\t\t\t\tstream.writeInt8(0x01);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"copyrightNotice\":\r\n\t\t\t\tstream.writeInt8(0x02);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"trackName\":\r\n\t\t\t\tstream.writeInt8(0x03);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"instrumentName\":\r\n\t\t\t\tstream.writeInt8(0x04);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"lyrics\":\r\n\t\t\t\tstream.writeInt8(0x05);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"marker\":\r\n\t\t\t\tstream.writeInt8(0x06);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"cuePoint\":\r\n\t\t\t\tstream.writeInt8(0x07);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"midiChannelPrefix\":\r\n\t\t\t\tstream.writeInt8(0x20);\r\n\t\t\t\tstream.writeVarInt(1);\r\n\r\n\t\t\t\tstream.writeInt8(event.channel);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"endOfTrack\":\r\n\t\t\t\tstream.writeInt8(0x2f);\r\n\t\t\t\tstream.writeVarInt(0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"setTempo\":\r\n\t\t\t\tstream.writeInt8(0x51);\r\n\t\t\t\tstream.writeVarInt(3);\r\n\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 16) & 0xff);\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 8) & 0xff);\r\n\t\t\t\tstream.writeInt8(event.microsecondsPerBeat & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"smpteOffset\":\r\n\t\t\t\tstream.writeInt8(0x54);\r\n\t\t\t\tstream.writeVarInt(5);\r\n\r\n\t\t\t\tvar frameByte = { 24: 0x00, 25: 0x20, 29: 0x40, 30: 0x60 }[event.frameRate];\r\n\t\t\t\tstream.writeInt8(event.hour | frameByte);\r\n\t\t\t\tstream.writeInt8(event.min);\r\n\t\t\t\tstream.writeInt8(event.sec);\r\n\t\t\t\tstream.writeInt8(event.frame);\r\n\t\t\t\tstream.writeInt8(event.subframe);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"timeSignature\":\r\n\t\t\t\tstream.writeInt8(0x58);\r\n\t\t\t\tstream.writeVarInt(4);\r\n\r\n\t\t\t\tstream.writeInt8(event.numerator);\r\n\t\t\t\tstream.writeInt8(Math.log2(event.denominator));\r\n\t\t\t\tstream.writeInt8(event.metronome);\r\n\t\t\t\tstream.writeInt8(event.thirtyseconds);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"keySignature\":\r\n\t\t\t\tstream.writeInt8(0x59);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt8(event.key);\r\n\t\t\t\tstream.writeInt8(event.scale);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"sequencerSpecific\":\r\n\t\t\t\tstream.writeInt8(0x7f);\r\n\t\t\t\tstream.writeVarInt(event.data.length);\r\n\r\n\t\t\t\tstream.write(event.data);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"sysEx\":\r\n\t\t\tstream.writeInt8(0xf0);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"dividedSysEx\":\r\n\t\t\tstream.writeInt8(0xf7);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"channel\":\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"noteOn\":\r\n\t\t\t\tstream.writeInt8(0x90 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteOff\":\r\n\t\t\t\tstream.writeInt8(0x80 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity ? event.velocity : 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xa0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"controller\":\r\n\t\t\t\tstream.writeInt8(0xb0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.controllerType);\r\n\t\t\t\tstream.writeInt8(event.value);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"programChange\":\r\n\t\t\t\tstream.writeInt8(0xc0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.programNumber);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"channelAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xd0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"pitchBend\":\r\n\t\t\t\tstream.writeInt8(0xe0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.value & 0xff);\r\n\t\t\t\tstream.writeInt8((event.value >> 7) & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tthrow new Error(\"unhandled event type:\" + event.type);\r\n\t\t}\r\n\t}\r\n\r\n\tconst stream = new OStream();\r\n\r\n\tconst headerChunk = new OStream();\r\n\theaderChunk.writeInt16(header.formatType);\r\n\theaderChunk.writeInt16(tracks.length);\r\n\theaderChunk.writeInt16(header.ticksPerBeat);\r\n\r\n\twriteChunk(stream, \"MThd\", headerChunk.getBuffer());\r\n\r\n\tfor (let i = 0; i < tracks.length; ++i) {\r\n\t\tconst trackChunk = new OStream();\r\n\r\n\t\tfor (let ei = 0; ei < tracks[i].length; ++ei)\r\n\t\t\twriteEvent(trackChunk, tracks[i][ei]);\r\n\r\n\t\twriteChunk(stream, \"MTrk\", trackChunk.getBuffer());\r\n\t}\r\n\r\n\treturn stream.getArrayBuffer();\r\n};\r\n","\nmodule.exports = {\n\tparseMidiData: require(\"./midifile.js\"),\n\tencodeMidiFile: require(\"./midifileEx.js\"),\n};\n","\nconst midiToSequence = (midiFile, {timeWarp = 1} = {}) => {\n\tconst trackStates = [];\n\tlet beatsPerMinute = 120;\n\tconst ticksPerBeat = midiFile.header.ticksPerBeat;\n\n\tfor (let i = 0; i < midiFile.tracks.length; i++) {\n\t\ttrackStates[i] = {\n\t\t\tnextEventIndex: 0,\n\t\t\tticksToNextEvent: (\n\t\t\t\tmidiFile.tracks[i].length ?\n\t\t\t\t\tmidiFile.tracks[i][0].deltaTime :\n\t\t\t\t\tnull\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction getNextEvent () {\n\t\tlet ticksToNextEvent = null;\n\t\tlet nextEventTrack = null;\n\t\tlet nextEventIndex = null;\n\n\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\tif (\n\t\t\t\ttrackStates[i].ticksToNextEvent != null\n\t\t\t\t&& (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent)\n\t\t\t) {\n\t\t\t\tticksToNextEvent = trackStates[i].ticksToNextEvent;\n\t\t\t\tnextEventTrack = i;\n\t\t\t\tnextEventIndex = trackStates[i].nextEventIndex;\n\t\t\t}\n\t\t}\n\t\tif (nextEventTrack != null) {\n\t\t\t/* consume event from that track */\n\t\t\tconst nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex];\n\t\t\tif (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime;\n\t\t\telse \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent = null;\n\n\t\t\ttrackStates[nextEventTrack].nextEventIndex += 1;\n\t\t\t/* advance timings on all tracks by ticksToNextEvent */\n\t\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\t\tif (trackStates[i].ticksToNextEvent != null) \n\t\t\t\t\ttrackStates[i].ticksToNextEvent -= ticksToNextEvent;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tticksToEvent: ticksToNextEvent,\n\t\t\t\tevent: nextEvent,\n\t\t\t\ttrack: nextEventTrack,\n\t\t\t};\n\t\t}\n\t\telse \n\t\t\treturn null;\n\t\t\n\t};\n\t//\n\tlet midiEvent;\n\tconst events = [];\n\t//\n\tfunction processEvents () {\n\t\tfunction processNext () {\n\t\t\tlet secondsToGenerate = 0;\n\t\t\tif (midiEvent.ticksToEvent > 0) {\n\t\t\t\tconst beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;\n\t\t\t\tsecondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);\n\t\t\t}\n\n\t\t\t// beatsPerMinute must be changed after secondsToGenerate calculation\n\t\t\tif ( midiEvent.event.type == \"meta\" && midiEvent.event.subtype == \"setTempo\" ) {\n\t\t\t\t// tempo change events can occur anywhere in the middle and affect events that follow\n\t\t\t\tbeatsPerMinute = 60e+6 / midiEvent.event.microsecondsPerBeat;\n\t\t\t}\n\n\t\t\tconst time = (secondsToGenerate * 1000 * timeWarp) || 0;\n\t\t\tevents.push([ midiEvent, time ]);\n\t\t\tmidiEvent = getNextEvent();\n\t\t};\n\t\t//\n\t\tif (midiEvent = getNextEvent()) {\n\t\t\twhile (midiEvent)\n\t\t\t\tprocessNext();\n\t\t}\n\t};\n\n\tprocessEvents();\n\n\treturn events;\n};\n\n\nconst trimSequence = seq => {\n\tconst status = new Map();\n\n\treturn seq.filter(([{event, ticksToEvent}]) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tstatus.clear();\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn true;\n\n\t\tconst key = `${event.subtype}|${event.channel}|${event.noteNumber}`;\n\n\t\tif (status.get(key)) {\n\t\t\t//console.debug(\"event trimmed:\", event, ticksToEvent);\n\t\t\treturn false;\n\t\t}\n\n\t\tstatus.set(key, event);\n\n\t\treturn true;\n\t});\n};\n\n\nconst fixOverlapNotes = seq => {\n\tconst noteMap = new Map();\n\tconst overlapMap = new Map();\n\tconst swaps = [];\n\n\tlet leapIndex = -1;\n\n\tseq.forEach(([{event, ticksToEvent}], index) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tleapIndex = index;\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn;\n\n\t\tconst key = `${event.channel}|${event.noteNumber}`;\n\n\t\tswitch (event.subtype) {\n\t\tcase \"noteOn\":\n\t\t\tif (noteMap.get(key))\n\t\t\t\toverlapMap.set(key, leapIndex);\n\t\t\telse\n\t\t\t\tnoteMap.set(key, leapIndex);\n\n\t\t\tbreak;\n\t\tcase \"noteOff\":\n\t\t\tif (overlapMap.get(key)) {\n\t\t\t\tswaps.push([overlapMap.get(key), index]);\n\t\t\t\toverlapMap.delete(key);\n\t\t\t}\n\t\t\telse\n\t\t\t\tnoteMap.delete(key);\n\n\t\t\tbreak;\n\t\t}\n\t});\n\n\t// shift overlapped swaps\n\tswaps.forEach((swap, i) => {\n\t\tfor (let ii = i - 1; ii >= 0; --ii) {\n\t\t\tconst pre = swaps[ii];\n\t\t\tif (pre[1] < swap[0])\n\t\t\t\tbreak;\n\n\t\t\tif (swap[0] > pre[0])\n\t\t\t\t++swap[0];\n\t\t}\n\t});\n\n\t//console.debug(\"swaps:\", swaps);\n\tswaps.forEach(([front, back]) => {\n\t\tif (back >= seq.length - 1 || front < 0)\n\t\t\treturn;\n\n\t\tconst offEvent = seq[back];\n\t\tconst nextEvent = seq[back + 1];\n\t\tconst leapEvent = seq[front];\n\n\t\tif (!leapEvent[0].ticksToEvent) {\n\t\t\tconsole.warn(\"invalid front index:\", front, back, leapEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t// ms per tick\n\t\tconst tempo = leapEvent[1] / leapEvent[0].ticksToEvent;\n\n\t\tnextEvent[1] += offEvent[1];\n\t\tnextEvent[0].ticksToEvent += offEvent[0].ticksToEvent;\n\n\t\toffEvent[0].ticksToEvent = leapEvent[0].ticksToEvent - 1;\n\t\tleapEvent[0].ticksToEvent = 1;\n\n\t\toffEvent[1] = offEvent[0].ticksToEvent * tempo;\n\t\tleapEvent[1] = leapEvent[0].ticksToEvent * tempo;\n\t\t//console.debug(\"swap:\", [front, back], offEvent, nextEvent, leapEvent);\n\n\t\tseq.splice(back, 1);\n\t\tseq.splice(front, 0, offEvent);\n\t});\n\n\treturn seq;\n};\n\n\n\nmodule.exports = {\n\tmidiToSequence,\n\ttrimSequence,\n\tfixOverlapNotes,\n};\n","\nconst MidiSequence = require(\"./MidiSequence.js\");\n\n\n\nconst PedalControllerTypes = {\n\t64: \"Sustain\",\n\t65: \"Portamento\",\n\t66: \"Sostenuto\",\n\t67: \"Soft\",\n};\n\n\n\nclass Notation {\n\tstatic parseMidi (data, {fixOverlap = true} = {}) {\n\t\tconst channelStatus = [];\n\t\tconst pedalStatus = {};\n\t\tconst pedals = {};\n\t\tconst channels = [];\n\t\tconst bars = [];\n\t\tlet time = 0;\n\t\tlet millisecondsPerBeat = 600000 / 120;\n\t\tlet beats = 0;\n\t\tlet numerator = 4;\n\t\tlet barIndex = 0;\n\t\tconst keyRange = {};\n\t\tlet rawTicks = 0;\n\t\tlet ticks = 0;\n\t\tlet correspondences;\n\t\tconst tempos = [];\n\n\t\tconst ticksPerBeat = data.header.ticksPerBeat;\n\n\t\tlet rawEvents = MidiSequence.midiToSequence(data);\n\n\t\tif (fixOverlap)\n\t\t\trawEvents = MidiSequence.trimSequence(MidiSequence.fixOverlapNotes(rawEvents));\n\n\t\tconst events = rawEvents.map(d => ({\n\t\t\tdata: d[0].event,\n\t\t\ttrack: d[0].track,\n\t\t\tdeltaTime: d[1],\n\t\t\tdeltaTicks: d[0].ticksToEvent,\n\t\t}));\n\n\t\tlet index = 0;\n\n\t\tconst ticksNormal = 1;\n\n\t\tfor (const ev of events) {\n\t\t\trawTicks += ev.deltaTicks;\n\t\t\tticks = Math.round(rawTicks * ticksNormal);\n\n\t\t\tif (ev.deltaTicks > 0) {\n\t\t\t\t// append bars\n\t\t\t\tconst deltaBeats = ev.deltaTicks / ticksPerBeat;\n\t\t\t\tfor (let b = Math.ceil(beats); b < beats + deltaBeats; ++b) {\n\t\t\t\t\tconst t = time + (b - beats) * millisecondsPerBeat;\n\t\t\t\t\tbars.push({time: t, index: barIndex % numerator});\n\n\t\t\t\t\t++barIndex;\n\t\t\t\t}\n\n\t\t\t\tbeats += deltaBeats;\n\t\t\t}\n\n\t\t\ttime += ev.deltaTime;\n\n\t\t\t//const ticksTime = beats * millisecondsPerBeat;\n\t\t\t//console.log(\"time:\", time, ticksTime, ticksTime - time);\n\n\t\t\tev.time = time;\n\t\t\tev.ticks = ticks;\n\n\t\t\tconst event = ev.data;\n\t\t\tswitch (event.type) {\n\t\t\tcase \"channel\":\n\t\t\t\t//channelStatus[event.channel] = channelStatus[event.channel] || [];\n\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"noteOn\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\t\t\t\t\t\t//channelStatus[event.channel][pitch] = {\n\t\t\t\t\t\tchannelStatus.push({\n\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\tstartTick: ticks,\n\t\t\t\t\t\t\tstart: time,\n\t\t\t\t\t\t\tvelocity: event.velocity,\n\t\t\t\t\t\t\tbeats: beats,\n\t\t\t\t\t\t\ttrack: ev.track,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tkeyRange.low = Math.min(keyRange.low || pitch, pitch);\n\n\t\t\t\t\t\tev.index = index;\n\t\t\t\t\t\t++index;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"noteOff\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\n\t\t\t\t\t\tchannels[event.channel] = channels[event.channel] || [];\n\n\t\t\t\t\t\tconst statusIndex = channelStatus.findIndex(status => status.channel == event.channel && status.pitch == pitch);\n\t\t\t\t\t\tif (statusIndex >= 0) {\n\t\t\t\t\t\t\tconst status = channelStatus.splice(statusIndex, 1)[0];\n\n\t\t\t\t\t\t\tchannels[event.channel].push({\n\t\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\t\tstartTick: status.startTick,\n\t\t\t\t\t\t\t\tendTick: ticks,\n\t\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\t\tstart: status.start,\n\t\t\t\t\t\t\t\tduration: time - status.start,\n\t\t\t\t\t\t\t\tvelocity: status.velocity,\n\t\t\t\t\t\t\t\tbeats: status.beats,\n\t\t\t\t\t\t\t\ttrack: status.track,\n\t\t\t\t\t\t\t\tfinger: status.finger,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tconsole.debug(\"unexpected noteOff: \", time, event);\n\n\t\t\t\t\t\tkeyRange.high = Math.max(keyRange.high || pitch, pitch);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"controller\":\n\t\t\t\t\tswitch (event.controllerType) {\n\t\t\t\t\t// pedal controllers\n\t\t\t\t\tcase 64:\n\t\t\t\t\tcase 65:\n\t\t\t\t\tcase 66:\n\t\t\t\t\tcase 67:\n\t\t\t\t\t\tconst pedalType = PedalControllerTypes[event.controllerType];\n\n\t\t\t\t\t\tpedalStatus[event.channel] = pedalStatus[event.channel] || {};\n\t\t\t\t\t\tpedals[event.channel] = pedals[event.channel] || [];\n\n\t\t\t\t\t\tconst status = pedalStatus[event.channel][pedalType];\n\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tpedals[event.channel].push({type: pedalType, start: status.start, duration: time - status.start, value: status.value});\n\t\t\t\t\t\tpedalStatus[event.channel][pedalType] = {start: time, value: event.value};\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase \"meta\":\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"setTempo\":\n\t\t\t\t\tmillisecondsPerBeat = event.microsecondsPerBeat / 1000;\n\t\t\t\t\t//beats = Math.round(beats);\n\t\t\t\t\t//console.assert(Number.isFinite(time), \"invalid time:\", time);\n\t\t\t\t\ttempos.push({tempo: event.microsecondsPerBeat, tick: ticks, time});\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"timeSignature\":\n\t\t\t\t\tnumerator = event.numerator;\n\t\t\t\t\tbarIndex = 0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text\":\n\t\t\t\t\tif (!correspondences && /^find-corres:/.test(event.text)) {\n\t\t\t\t\t\tconst captures = event.text.match(/:([\\d\\,-]+)/);\n\t\t\t\t\t\tconst str = captures && captures[1] || \"\";\n\t\t\t\t\t\tcorrespondences = str.split(\",\").map(s => Number(s));\n\t\t\t\t\t}\n\t\t\t\t\telse if (/fingering\\(.*\\)/.test(event.text)) {\n\t\t\t\t\t\tconst [_, fingers] = event.text.match(/\\((.+)\\)/);\n\t\t\t\t\t\tconst finger = Number(fingers);\n\t\t\t\t\t\tif (!Number.isNaN(finger)) {\n\t\t\t\t\t\t\tconst status = channelStatus[channelStatus.length - 1];\n\t\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\t\tstatus.finger = finger;\n\n\t\t\t\t\t\t\tconst event = events.find(e => e.index == index - 1);\n\t\t\t\t\t\t\tif (event)\n\t\t\t\t\t\t\t\tevent.data.finger = finger;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"copyrightNotice\":\n\t\t\t\t\tconsole.log(\"MIDI copyright:\", event.text);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tchannelStatus.forEach(status => {\n\t\t\tconsole.debug(\"unclosed noteOn event at\", status.startTick, status);\n\n\t\t\tchannels[status.channel].push({\n\t\t\t\tstartTick: status.startTick,\n\t\t\t\tendTick: ticks,\n\t\t\t\tpitch: status.pitch,\n\t\t\t\tstart: status.start,\n\t\t\t\tduration: time - status.start,\n\t\t\t\tvelocity: status.velocity,\n\t\t\t\tbeats: status.beats,\n\t\t\t\ttrack: status.track,\n\t\t\t\tfinger: status.finger,\n\t\t\t});\n\t\t});\n\n\t\treturn new Notation({\n\t\t\tchannels,\n\t\t\tkeyRange,\n\t\t\tpedals,\n\t\t\tbars,\n\t\t\tendTime: time,\n\t\t\tendTick: ticks,\n\t\t\tcorrespondences,\n\t\t\tevents,\n\t\t\ttempos,\n\t\t\tticksPerBeat,\n\t\t\tmeta: {},\n\t\t});\n\t}\n\n\n\tconstructor (fields) {\n\t\tObject.assign(this, fields);\n\n\t\t// channels to notes\n\t\tthis.notes = [];\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tfor (const note of channel)\n\t\t\t\t\tthis.notes.push(note);\n\t\t\t}\n\t\t}\n\t\tthis.notes.sort(function (n1, n2) {\n\t\t\treturn n1.start - n2.start;\n\t\t});\n\n\t\tfor (const i in this.notes)\n\t\t\tthis.notes[i].index = Number(i);\n\n\n\t\t// duration\n\t\tthis.duration = this.notes.length > 0 ? (this.endTime - this.notes[0].start) : 0,\n\n\t\t//this.endSoftIndex = this.notes.length ? this.notes[this.notes.length - 1].softIndex : 0;\n\n\n\t\t// pitch map\n\t\tthis.pitchMap = [];\n\t\tfor (const c in this.channels) {\n\t\t\tfor (const n in this.channels[c]) {\n\t\t\t\tconst pitch = this.channels[c][n].pitch;\n\t\t\t\tthis.pitchMap[pitch] = this.pitchMap[pitch] || [];\n\n\t\t\t\tthis.pitchMap[pitch].push(this.channels[c][n]);\n\t\t\t}\n\t\t}\n\n\t\tthis.pitchMap.forEach(notes => notes.sort((n1, n2) => n1.start - n2.start));\n\n\n\t\t/*// setup measure notes index\n\t\tif (this.measures) {\n\t\t\tconst measure_list = [];\n\n\t\t\tlet last_measure = null;\n\t\t\tconst measure_entries = Object.entries(this.measures).sort((e1, e2) => Number(e1[0]) - Number(e2[0]));\n\t\t\tfor (const [t, measure] of measure_entries) {\n\t\t\t\t//console.log(\"measure time:\", Number(t));\n\t\t\t\tmeasure.startTick = Number(t);\n\t\t\t\tmeasure.notes = [];\n\n\t\t\t\tif (last_measure)\n\t\t\t\t\tlast_measure.endTick = measure.startTick;\n\n\t\t\t\tconst m = measure.measure;\n\t\t\t\tmeasure_list[m] = measure_list[m] || [];\n\t\t\t\tmeasure_list[m].push(measure);\n\n\t\t\t\tlast_measure = measure;\n\t\t\t}\n\t\t\tif (last_measure)\n\t\t\t\tlast_measure.endTick = this.notes[this.notes.length - 1].endTick;\n\t\t\tfor (const i in this.notes) {\n\t\t\t\tconst note = this.notes[i];\n\t\t\t\tfor (const t in this.measures) {\n\t\t\t\t\tconst measure = this.measures[t];\n\t\t\t\t\tif (note.startTick >= measure.startTick && note.startTick < measure.endTick || note.endTick > measure.startTick && note.endTick <= measure.endTick)\n\t\t\t\t\t\tmeasure.notes.push(note);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.measure_list = measure_list;\n\t\t}*/\n\n\n\t\t// prepare beats info\n\t\tif (this.meta.beatInfos) {\n\t\t\tfor (let i = 0; i < this.meta.beatInfos.length; ++i) {\n\t\t\t\tconst info = this.meta.beatInfos[i];\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tconst lastInfo = this.meta.beatInfos[i - 1];\n\t\t\t\t\tinfo.beatIndex = lastInfo.beatIndex + Math.ceil((info.tick - lastInfo.tick) / this.ticksPerBeat);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tinfo.beatIndex = 0;\n\t\t\t}\n\t\t}\n\n\n\t\t// compute tempos tick -> time\n\t\t{\n\t\t\tlet time = 0;\n\t\t\tlet ticks = 0;\n\t\t\tlet tempo = 500000;\n\t\t\tfor (const entry of this.tempos) {\n\t\t\t\tconst deltaTicks = entry.tick - ticks;\n\t\t\t\ttime += (tempo / 1000) * deltaTicks / this.ticksPerBeat;\n\n\t\t\t\tticks = entry.tick;\n\t\t\t\ttempo = entry.tempo;\n\n\t\t\t\tentry.time = time;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfindChordBySoftindex (softIndex, radius = 0.8) {\n\t\treturn this.notes.filter(note => Math.abs(note.softIndex - softIndex) < radius);\n\t}\n\n\n\taverageTempo (tickRange) {\n\t\ttickRange = tickRange || {from: 0, to: this.endtick};\n\n\t\tconsole.assert(this.tempos, \"no tempos.\");\n\t\tconsole.assert(tickRange.to > tickRange.from, \"range is invalid:\", tickRange);\n\n\t\tconst span = index => {\n\t\t\tconst from = Math.max(tickRange.from, this.tempos[index].tick);\n\t\t\tconst to = (index < this.tempos.length - 1) ? Math.min(this.tempos[index + 1].tick, tickRange.to) : tickRange.to;\n\n\t\t\treturn Math.max(0, to - from);\n\t\t};\n\n\t\tconst tempo_sum = this.tempos.reduce((sum, tempo, index) => sum + tempo.tempo * span(index), 0);\n\n\t\tconst average = tempo_sum / (tickRange.to - tickRange.from);\n\n\t\t// convert microseconds per beat to beats per minute\n\t\treturn 60e+6 / average;\n\t}\n\n\n\tticksToTime (tick) {\n\t\tconsole.assert(Number.isFinite(tick), \"invalid tick value:\", tick);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.tick > tick);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.time + (tick - tempo.tick) * tempo.tempo * 1e-3 / this.ticksPerBeat;\n\t}\n\n\n\ttimeToTicks (time) {\n\t\tconsole.assert(Number.isFinite(time), \"invalid time value:\", time);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.time > time);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.tick + (time - tempo.time) * this.ticksPerBeat / (tempo.tempo * 1e-3);\n\t}\n\n\n\ttickRangeToTimeRange (tickRange) {\n\t\tconsole.assert(tickRange.to >= tickRange.from, \"invalid tick range:\", tickRange);\n\n\t\treturn {\n\t\t\tfrom: this.ticksToTime(tickRange.from),\n\t\t\tto: this.ticksToTime(tickRange.to),\n\t\t};\n\t}\n\n\n\t/*getMeasureRange (measureRange) {\n\t\tconsole.assert(Number.isInteger(measureRange.start) && Number.isInteger(measureRange.end), \"invalid measure range:\", measureRange);\n\t\tconsole.assert(this.measure_list && this.measure_list[measureRange.start] && this.measure_list[measureRange.end], \"no measure data for specific index:\", this.measure_list, measureRange);\n\n\t\tconst startMeasure = this.measure_list[measureRange.start][0];\n\t\tlet endMeasure = null;\n\t\tfor (const measure of this.measure_list[measureRange.end]) {\n\t\t\tif (measure.endTick > startMeasure.startTick) {\n\t\t\t\tendMeasure = measure;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// there no path between start measure and end measure.\n\t\tif (!endMeasure)\n\t\t\treturn null;\n\n\t\tconst tickRange = {from: startMeasure.startTick, to: endMeasure.endTick, duration: endMeasure.endTick - startMeasure.startTick};\n\t\tconst timeRange = this.tickRangeToTimeRange(tickRange);\n\t\ttimeRange.duration = timeRange.to - timeRange.from;\n\n\t\treturn {\n\t\t\ttickRange,\n\t\t\ttimeRange,\n\t\t};\n\t}*/\n\n\n\tscaleTempo ({factor, headTempo}) {\n\t\tconsole.assert(this.tempos && this.tempos.length, \"[Notation.scaleTempo] tempos is empty.\");\n\n\t\tif (headTempo)\n\t\t\tfactor = headTempo / this.tempos[0].tempo;\n\n\t\tconsole.assert(Number.isFinite(factor) && factor > 0, \"[Notation.scaleTempo] invalid factor:\", factor);\n\n\t\tthis.tempos.forEach(tempo => {\n\t\t\ttempo.tempo *= factor;\n\t\t\ttempo.time *= factor;\n\t\t});\n\t\tthis.events.forEach(event => {\n\t\t\tevent.deltaTime *= factor;\n\t\t\tevent.time *= factor;\n\t\t});\n\t\tthis.notes.forEach(note => {\n\t\t\tnote.start *= factor;\n\t\t\tnote.duration *= factor;\n\t\t});\n\n\t\tthis.endTime *= factor;\n\t}\n};\n\n\n\nmodule.exports = {\n\tNotation,\n};\n","\nconst { Notation } = require(\"./MusicNotation.js\");\n\n\n\n//const msDelay = ms => new Promise(resolve => setTimeout(resolve, ms));\nconst animationDelay = () => new Promise(resolve => requestAnimationFrame(resolve));\n\n\nclass MidiPlayer {\n\tconstructor (midiData, {cacheSpan = 600, onMidi, onPlayFinish, onTurnCursor} = {}) {\n\t\tthis.cacheSpan = cacheSpan;\n\t\tthis.onMidi = onMidi;\n\t\tthis.onPlayFinish = onPlayFinish;\n\t\tthis.onTurnCursor = onTurnCursor;\n\n\t\tlet notation;\n\t\tif (midiData.notes && Number.isFinite(midiData.endTime))\n\t\t\tnotation = midiData;\n\t\telse\n\t\t\tnotation = Notation.parseMidi(midiData);\n\n\t\tthis.notation = notation;\n\t\tthis.events = notation.events;\n\t\t//console.log(\"events:\", this.events);\n\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t\tthis.startTime = performance.now();\n\t\tthis.duration = notation.endTime;\n\t\tthis.cursorTurnDelta = 0;\n\n\t\tconsole.assert(notation.tempos && notation.tempos.length, \"[MidiPlayer] invalid notation, tempos is empty.\");\n\t}\n\n\n\tdispose () {\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t}\n\n\n\tget progressTicks () {\n\t\treturn this.notation.timeToTicks(this.progressTime);\n\t}\n\n\n\tset progressTicks (value) {\n\t\tthis.progressTime = this.notation.ticksToTime(value);\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(this.progressTime);\n\t}\n\n\n\tasync play ({nextFrame = animationDelay} = {}) {\n\t\tif (this.progressTime >= this.duration)\n\t\t\tthis.progressTime = 0;\n\n\t\tlet now = performance.now();\n\t\tthis.startTime = now - this.progressTime;\n\n\t\tthis.isPlaying = true;\n\n\t\tlet currentEventIndex = this.events.findIndex(event => event.time >= now - this.startTime);\n\n\t\twhile (this.isPlaying) {\n\t\t\tfor (; currentEventIndex < this.events.length; ++currentEventIndex) {\n\t\t\t\tconst event = this.events[currentEventIndex];\n\t\t\t\t//console.log(\"play event:\", currentEventIndex, event.time, this.progressTime + this.cacheSpan);\n\t\t\t\tif (!event || event.time > this.progressTime + this.cacheSpan)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif (event.data.type === \"channel\" && this.startTime + event.time >= now)\n\t\t\t\t\tif (this.onMidi)\n\t\t\t\t\t\tthis.onMidi(event.data, this.startTime + event.time);\n\t\t\t}\n\n\t\t\tawait nextFrame();\n\n\t\t\tif (!this.isPlaying)\n\t\t\t\tbreak;\n\n\t\t\tif (this.cursorTurnDelta !== 0) {\n\t\t\t\tconst backturn = this.cursorTurnDelta < 0;\n\n\t\t\t\tthis.startTime -= this.cursorTurnDelta;\n\t\t\t\tthis.cursorTurnDelta = 0;\n\n\t\t\t\tif (backturn) {\n\t\t\t\t\tfor (; currentEventIndex > 0; --currentEventIndex) {\n\t\t\t\t\t\tconst eventTime = this.events[currentEventIndex].time;\n\t\t\t\t\t\tif (this.startTime + eventTime < now)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnow = performance.now();\n\n\t\t\tthis.progressTime = now - this.startTime;\n\n\t\t\tif (this.progressTime > this.duration) {\n\t\t\t\tthis.isPlaying = false;\n\n\t\t\t\tif (this.onPlayFinish)\n\t\t\t\t\tthis.onPlayFinish();\n\t\t\t}\n\t\t}\n\t}\n\n\n\tpause () {\n\t\tthis.isPlaying = false;\n\t}\n\n\n\tturnCursor (time) {\n\t\t//console.log(\"onTurnCursor:\", time, oldTime);\n\t\tif (this.isPlaying)\n\t\t\tthis.cursorTurnDelta += time - this.progressTime;\n\t\telse\n\t\t\tthis.progressTime = time;\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(time);\n\t}\n};\n\n\n\nmodule.exports = MidiPlayer;\n","\nmodule.exports = {\n\tCostStepAttenuation: 0.6,\n\tSkipDeep: 3,\n\tPriorDistanceSigmoidFactor: 0.1,\n\tPriorValueSigmoidFactor: 0.12,\n\n\tSkipCost: 0.5,\n\tLagOffsetCost: 1,\n\tLeadOffsetCost: 1.6,\n\tZeroOffsetCost: 0.58,\n\n\tRelocationThreshold: 6,\n};\n","\nconst {pick} = require(\"lodash\");\n\nconst Config = require(\"./config.js\");\n\n\n\nclass Node {\n\tconstructor (s_note, c_note) {\n\t\tthis.s_note = s_note;\n\t\tthis.c_note = c_note;\n\n\t\tconsole.assert(this.s_note.softIndex != null, \"s_note softIndex is null\");\n\t\tthis.offset = this.s_note.softIndex - this.c_note.softIndex;\n\n\t\tthis._prev = null;\n\t\tthis._totalCost = 0;\n\t\tthis._value = 0;\n\t\tthis.cacheDirty = true;\n\n\t\t//this.evaluatePrev(Node.Zero);\n\t}\n\n\n\tget prev () {\n\t\treturn this._prev;\n\t}\n\n\n\tset prev (value) {\n\t\tif (value != this._prev) {\n\t\t\tthis._prev = value;\n\t\t\tthis.cacheDirty = true;\n\t\t}\n\t}\n\n\n\tget si () {\n\t\treturn this.s_note.index;\n\t}\n\n\n\tget ci () {\n\t\treturn this.c_note.index;\n\t}\n\n\n\tget root () {\n\t\treturn this.prev.root || this;\n\t}\n\n\n\tget rootSi () {\n\t\treturn !this.prev.zero ? this.prev.rootSi : this.si;\n\t}\n\n\n\tget id () {\n\t\treturn `${this.s_note.index},${this.c_note.index}`;\n\t}\n\n\n\tstatic cost (prev, skip, self) {\n\t\treturn prev * Config.CostStepAttenuation + Math.tanh(skip * Config.SkipCost) + Math.tanh(self * 0.5);\n\t}\n\n\n\tupdateCache () {\n\t\tif (this.cacheDirty) {\n\t\t\tthis._totalCost = Node.cost(this.prev.totalCost, this.si - this.prev.si - 1, this.selfCost);\n\t\t\tthis._value = this.prev.value + 1 - Math.tanh(this.selfCost * 0.5);\n\n\t\t\tthis.cacheDirty = false;\n\t\t}\n\t}\n\n\n\tget totalCost () {\n\t\tthis.updateCache();\n\n\t\treturn this._totalCost;\n\t}\n\n\n\tget value () {\n\t\tthis.updateCache();\n\n\t\treturn this._value;\n\t}\n\n\n\tget deep () {\n\t\treturn this.prev.deep + 1;\n\t}\n\n\n\tget path () {\n\t\tconst path = [];\n\t\tfor (let node = this; !node.zero; node = node.prev) {\n\t\t\tpath[node.si] = node.ci;\n\t\t}\n\n\t\tfor (let i = 0; i < path.length; ++i)\n\t\t\tif (typeof path[i] != \"number\")\n\t\t\t\tpath[i] = -1;\n\n\t\treturn path;\n\t}\n\n\n\tdump () {\n\t\treturn pick(this, [\"id\", \"si\", \"ci\", \"rootSi\", \"value\", \"deep\", \"rootSi\", \"offset\", \"prior\", \"selfCost\", \"totalCost\"]);\n\t}\n\n\n\tevaluatePrev (node) {\n\t\tconst cost = this.evaluatePrevCost(node);\n\n\t\tconsole.assert(this.si - node.si >= 1, \"node index error:\", this, node/*, {get [Symbol.toStringTag]() {debugger}}*/);\n\t\t//if (this.si - node.si < 1)\n\t\t//\tdebugger;\n\n\t\tconst totalCost = Node.cost(node.totalCost, this.si - node.si - 1, cost);\n\n\t\tif (!this.prev || totalCost < this.totalCost) {\n\t\t\tthis.prev = node;\n\t\t\tthis.selfCost = cost;\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tevaluatePrevCost (node) {\n\t\tlet cost = 0;\n\n\t\tif (node.offset != null) {\n\t\t\tconst bias = this.offset - node.offset;\n\t\t\tconst costCoeff = node.zero ? Config.ZeroOffsetCost : (bias > 0 ? Config.LagOffsetCost : Config.LeadOffsetCost);\n\t\t\tcost += (bias * costCoeff) ** 2;\n\t\t}\n\n\t\treturn cost;\n\t}\n\n\n\tpriorByOffset (offset) {\n\t\tconst distance = Math.abs(this.offset - offset) / 1;//(this.s_note.deltaSi + 0.04);\n\n\t\treturn Math.tanh(this.value * Config.PriorValueSigmoidFactor) - Math.tanh(distance * Config.PriorDistanceSigmoidFactor);\n\t\t//return Math.log(this.value) * Math.tanh(4 / distance);\n\t\t//return this.value - distance;\n\t}\n\n\n\tstatic zero () {\n\t\treturn {\n\t\t\tzero: true,\n\t\t\ttotalCost: 0,\n\t\t\tvalue: 0,\n\t\t\tsi: -1,\n\t\t\tci: -1,\n\t\t\tdeep: 0,\n\t\t\toffset: 0,\n\t\t};\n\t}\n};\n\n\n\nmodule.exports = Node;\n","\nconst Config = require(\"./config.js\");\nconst Node = require(\"./node.js\");\n\n\n\nclass Navigator {\n\tconstructor (criterion, sample, options = {}) {\n\t\tthis.criterion = criterion;\n\t\tthis.sample = sample;\n\n\t\tthis.getCursorOffset = options.getCursorOffset || (() => null);\n\t\tthis.outOfPage = options.outOfPage;\n\n\t\tthis.bestNode = null;\n\t\tthis.fineCursor = null;\n\n\t\tthis.breakingSI = sample.notes.length - 1;\n\n\t\tthis.zeroNode = Node.zero();\n\t\tthis.zeroNode.offset = this.getCursorOffset() || 0;\n\n\t\tthis.relocationThreshold = options.relocationThreshold || Config.RelocationThreshold;\n\t}\n\n\n\tstep (index) {\n\t\t//console.log(\"step:\", this.zeroNode.offset);\n\t\tconst note = this.sample.notes[index];\n\n\t\tif (note.matches.length > 0) {\n\t\t\t//console.log(\"zeroNode.offset:\", index, this.zeroNode.offset);\n\t\t\tnote.matches.forEach(node => {\n\t\t\t\tnode.evaluatePrev(this.zeroNode);\n\t\t\t\t//console.log(\"node:\", node, node.evaluatePrevCost(this.zeroNode), node.offset, this.zeroNode.offset);\n\n\t\t\t\tfor (let si = index - 1; si >= Math.max(this.breakingSI + 1, index - Config.SkipDeep); --si) {\n\t\t\t\t\t//const skipCost = Config.SkipCost * (index - 1 - si);\n\n\t\t\t\t\tconst prevNote = this.sample.notes[si];\n\t\t\t\t\tconsole.assert(prevNote, \"prevNote is null:\", si, index, this.sample.notes);\n\t\t\t\t\tprevNote.matches.forEach(prevNode => {\n\t\t\t\t\t\tconst bias = node.offset - prevNode.offset;\n\t\t\t\t\t\tif (/*prevNode.totalCost + skipCost < node.totalCost\n\t\t\t\t\t\t\t&&*/ (bias < 2 / Config.LagOffsetCost && bias > -2 / Config.LeadOffsetCost))\n\t\t\t\t\t\t\tnode.evaluatePrev(prevNode);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tnode.prior = node.totalCost > 1.99 ? -1 : node.priorByOffset(this.zeroNode.offset);\n\n\t\t\t\tif (node.prior > 0 && this.outOfPage) {\n\t\t\t\t\tconst tick = this.criterion.notes[node.ci].startTick;\n\t\t\t\t\tif (this.outOfPage(tick))\n\t\t\t\t\t\tnode.prior -= 0.7;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tnote.matches.sort((c1, c2) => c2.prior - c1.prior);\n\t\t\tthis.cursors = note.matches;\n\t\t\t//console.log(\"navigator cursors:\", this.cursors);\n\n\t\t\tlet fineCursor = null;\n\t\t\tconst nullLength = this.nullSteps(index);\n\n\t\t\tconst cursor = this.cursors[0];\n\t\t\tif (cursor && cursor.totalCost < 1) {\n\t\t\t\t//console.log(\"nullLength:\", nullLength, nullLength * Math.log(cursor.value / 4));\n\t\t\t\tif (cursor.prior > 0 || (cursor.totalCost < 0.4 && Math.log(Math.max(nullLength * cursor.value, 1e-3)) > this.relocationThreshold)) {\n\t\t\t\t\tthis.zeroNode.offset = cursor.offset;\n\n\t\t\t\t\tfineCursor = cursor;\n\n\t\t\t\t\tif (!this.bestNode || cursor.value > this.bestNode.value)\n\t\t\t\t\t\tthis.bestNode = cursor;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fineCursor)\n\t\t\t\tthis.fineCursor = fineCursor;\n\t\t\telse {\n\t\t\t\tif (!this.resetCursor(index, {breaking: false/*nullLength > Config.SkipDeep*/})) {\n\t\t\t\t\tthis.zeroNode.offset += note.deltaSi * Math.tanh(nullLength);\n\t\t\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", note.deltaSi, nullLength);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tthis.cursors = [];\n\t}\n\n\n\tpath ({fromIndex = 0, toIndex = this.sample.notes.length - 1} = {}) {\n\t\tconst path = [];\n\n\t\tlet offset = null;\n\n\t\tfor (let si = toIndex; si >= fromIndex;) {\n\t\t\tconst note = this.sample.notes[si];\n\n\t\t\tif (!note.matches.length || note.matches[0].prior < -0.01 || note.matches[0].totalCost >= 1) {\n\t\t\t\t//if (note.matches.length)\n\t\t\t\t//\tconsole.log(\"path -1:\", si, note.matches[0].prior, note.matches[0].totalCost);\n\t\t\t\tpath[si] = -1;\n\t\t\t\t--si;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// sort nodes by backwards heuristic offset\n\t\t\tif (offset != null) {\n\t\t\t\tnote.matches.forEach(node => node.backPrior = (node.totalCost < 1.99 ? node.priorByOffset(offset) : -1));\n\t\t\t\tnote.matches.sort((n1, n2) => n2.backPrior - n1.backPrior);\n\t\t\t}\n\n\t\t\tconst node = note.matches[0];\n\t\t\tnode.path.forEach((ci, si) => path[si] = ci);\n\t\t\t//console.log(\"node path:\", si, node.path);\n\n\t\t\toffset = node.root.offset;\n\n\t\t\tsi = node.rootSi - 1;\n\t\t}\n\n\t\tconsole.assert(path.length == toIndex + 1, \"path length error:\", path, fromIndex, toIndex + 1,\n\t\t\tthis.sample.notes.length, this.sample.notes.length ? this.sample.notes[this.sample.notes.length - 1].index : null);\n\n\t\treturn path;\n\t}\n\n\n\tnullSteps (index) {\n\t\treturn index - (this.fineCursor ? this.fineCursor.si : -1) - 1;\n\t}\n\n\n\tresetCursor (index, {breaking = true} = {}) {\n\t\tif (breaking)\n\t\t\tthis.breakingSI = index;\n\n\t\tconst cursorOffset = this.getCursorOffset();\n\t\tif (cursorOffset != null) {\n\t\t\t//console.log(\"cursorOffset:\", cursorOffset);\n\n\t\t\tthis.zeroNode.offset = cursorOffset;\n\t\t\t//this.breaking = this.nullSteps(index) > Config.SkipDeep;\n\t\t\t//if (this.breaking)\t// trivial zero node si resets result in focus path interruption\n\t\t\tthis.zeroNode.si = index;\n\t\t\tthis.fineCursor = null;\n\n\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", cursorOffset);\n\t\t\t//console.log(\"cursor offset reset:\", cursorOffset);\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tget relocationTendency () {\n\t\tconst cursor = this.cursors && this.cursors[0];\n\t\tif (!cursor)\n\t\t\treturn null;\n\n\t\tconst nullLength = this.nullSteps(cursor.si);\n\t\tif (nullLength <= 0)\n\t\t\treturn 0;\n\n\t\treturn Math.log(Math.max(nullLength * cursor.value, 1e-3)) / this.relocationThreshold;\n\t}\n};\n\n\n\nmodule.exports = Navigator;\n","\nconst Node = require(\"./node.js\");\nconst Navigator = require(\"./navigator.js\");\n\n\n\nconst HEART_BEAT = 800;\t// in ms\nconst SIMULTANEOUS_INTERVAL = HEART_BEAT * 0.24;\n\n\nconst normalizeInterval = interval => Math.tanh(interval / SIMULTANEOUS_INTERVAL);\n\n\n// greater softIndexFactor make 'harder' soft index\nconst makeNoteSoftIndex = function (notes, index, {softIndexFactor = 1} = {}) {\n\tindex = Number(index);\n\n\tconst note = notes[index];\n\n\t// make soft index\n\tif (index > 0) {\n\t\tconst lastNote = notes[index - 1];\n\n\t\tconsole.assert(note.start != null, \"note.start is null\", note);\n\t\tconsole.assert(lastNote.start != null, \"lastNote.start is null\", lastNote);\n\n\t\tnote.deltaSi = normalizeInterval((note.start - lastNote.start) * softIndexFactor);\n\t\tnote.softIndex = lastNote.softIndex + note.deltaSi;\n\n\t\tconsole.assert(!Number.isNaN(note.deltaSi), \"note.deltaSi is NaN.\", note.start, lastNote.start);\n\t}\n\telse {\n\t\tnote.softIndex = 0;\n\t\tnote.deltaSi = 0;\n\t}\n};\n\n\nconst makeMatchNodes = function (note, criterion, zeroNode = Node.zero()) {\n\tnote.matches = [];\n\n\tconst targetList = criterion.pitchMap[note.pitch];\n\tif (targetList) {\n\t\tfor (const targetNote of targetList) {\n\t\t\tconst node = new Node(note, targetNote);\n\t\t\tif (zeroNode)\n\t\t\t\tnode.evaluatePrev(zeroNode);\n\n\t\t\tnote.matches.push(node);\n\t\t}\n\t}\n};\n\n\nconst genNotationContext = function (notation, {softIndexFactor = 1} = {}) {\n\tfor (let i = 0; i < notation.notes.length; ++i)\n\t\tmakeNoteSoftIndex(notation.notes, i, {softIndexFactor});\n};\n\n\nconst runNavigation = async function(criterion, sample, onStep) {\n\tconst navigator = new Navigator(criterion, sample);\n\tnavigator.resetCursor(-1);\n\n\tfor (let i = 0; i < sample.notes.length; ++i) {\n\t\tnavigator.step(i);\n\n\t\tconst next = await (onStep && onStep(i, navigator));\n\t\tif (next === Symbol.for(\"end\")) {\n\t\t\tconsole.log(\"Navigation interrupted.\");\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t//console.log(\"Navigation accomplished.\");\n\n\treturn navigator;\n};\n\n\n\nmodule.exports = {\n\tnormalizeInterval,\n\tmakeNoteSoftIndex,\n\tmakeMatchNodes,\n\tgenNotationContext,\n\trunNavigation,\n\tNavigator,\n\tNode,\n};\n","\nconst MIDI = require(\"./MIDI\");\n\n\n\nconst trackDeltaToAbs = events => {\n\tlet tick = 0;\n\n\tevents.forEach(event => {\n\t\ttick += event.deltaTime;\n\t\tevent.tick = tick;\n\t});\n};\n\n\nconst trackAbsToDelta = events => {\n\tlet lastTick = 0;\n\n\tevents.sort((e1, e2) => e1.tick - e2.tick).forEach(event => {\n\t\tevent.deltaTime = event.tick - lastTick;\n\t\tlastTick = event.tick;\n\t});\n};\n\n\nconst sliceTrack = (track, startTick, endTick) => {\n\ttrackDeltaToAbs(track);\n\n\tconst events = [];\n\tconst status = {};\n\n\ttrack.forEach(event => {\n\t\tif (event.tick >= startTick && event.tick <= endTick && event.subtype !== \"endOfTrack\")\n\t\t\tevents.push({\n\t\t\t\t...event,\n\t\t\t\ttick: event.tick - startTick,\n\t\t\t});\n\t\telse if (event.tick < startTick) {\n\t\t\tswitch (event.type) {\n\t\t\tcase \"meta\":\n\t\t\t\tstatus[event.subtype] = event;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t});\n\n\tObject.values(status).forEach(event => events.push({\n\t\t...event,\n\t\ttick: 0,\n\t}));\n\n\tevents.push({\n\t\ttick: endTick - startTick,\n\t\ttype: \"meta\",\n\t\tsubtype: \"endOfTrack\",\n\t});\n\n\ttrackAbsToDelta(events);\n\n\treturn events;\n};\n\n\nconst sliceMidi = (midi, startTick, endTick) => ({\n\theader: midi.header,\n\ttracks: midi.tracks.map(track => sliceTrack(track, startTick, endTick)),\n});\n\n\nconst TICKS_PER_BEATS = 480;\n\nconst EXCLUDE_MIDI_EVENT_SUBTYPES = [\n\t\"endOfTrack\", \"trackName\",\n\t\"noteOn\", \"noteOff\",\n];\n\n\nfunction encodeToMIDIData(notation, {startTime, unclosedNoteDuration = 30e+3} = {}) {\n\tnotation.microsecondsPerBeat = notation.microsecondsPerBeat || 500000;\n\n\tconst ticksPerBeat = TICKS_PER_BEATS;\n\tconst msToTicks = ticksPerBeat * 1000 / notation.microsecondsPerBeat;\n\n\tconst header = { formatType: 0, ticksPerBeat };\n\tconst track = [];\n\n\tif (!Number.isFinite(startTime)) {\n\t\tif (!notation.notes || !notation.notes[0])\n\t\t\tthrow new Error(\"encodeToMidiData: no start time specificed\");\n\n\t\tstartTime = notation.notes[0].start;\n\t}\n\n\ttrack.push({ time: startTime, type: \"meta\", subtype: \"copyrightNotice\", text: `Composed by MusicWdigets. BUILT on ${new Date(Number(process.env.VUE_APP_BUILD_TIME)).toDateString()}` });\n\n\tconst containsTempo = notation.events && notation.events.find(event => event.subtype == \"setTempo\");\n\tif (!containsTempo) {\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"timeSignature\", numerator: 4, denominator: 4, thirtyseconds: 8 });\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"setTempo\", microsecondsPerBeat: notation.microsecondsPerBeat });\n\t}\n\n\t//if (notation.correspondences)\n\t//\ttrack.push({ time: startTime, type: \"meta\", subtype: \"text\", text: \"find-corres:\" + notation.correspondences.join(\",\") });\n\n\tlet endTime = startTime || 0;\n\n\tif (notation.notes) {\n\t\tfor (const note of notation.notes) {\n\t\t\ttrack.push({\n\t\t\t\ttime: note.start,\n\t\t\t\ttype: \"channel\",\n\t\t\t\tsubtype: \"noteOn\",\n\t\t\t\tchannel: note.channel || 0,\n\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\tvelocity: note.velocity,\n\t\t\t\tfinger: note.finger,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, note.start);\n\n\t\t\tif (Number.isFinite(unclosedNoteDuration))\n\t\t\t\tnote.duration = note.duration || unclosedNoteDuration;\n\t\t\tif (note.duration) {\n\t\t\t\ttrack.push({\n\t\t\t\t\ttime: note.start + note.duration,\n\t\t\t\t\ttype: \"channel\",\n\t\t\t\t\tsubtype: \"noteOff\",\n\t\t\t\t\tchannel: note.channel || 0,\n\t\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\t\tvelocity: 0,\n\t\t\t\t});\n\n\t\t\t\tendTime = Math.max(endTime, note.start + note.duration);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (notation.events) {\n\t\tconst events = notation.events.filter(event => !EXCLUDE_MIDI_EVENT_SUBTYPES.includes(event.data.subtype));\n\t\tfor (const event of events) {\n\t\t\ttrack.push({\n\t\t\t\ttime: event.time,\n\t\t\t\t...event.data,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, event.time);\n\t\t}\n\t}\n\n\ttrack.push({ time: endTime + 100, type: \"meta\", subtype: \"endOfTrack\" });\n\n\ttrack.sort(function (e1, e2) { return e1.time - e2.time; });\n\n\t// append finger event after every noteOn event\n\ttrack.map((event, index) => ({event, index}))\n\t\t.filter(({event}) => event.subtype == \"noteOn\" && event.finger != null)\n\t\t.reverse()\n\t\t.forEach(({event, index}) => track.splice(index + 1, 0, {\n\t\t\ttime: event.time,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `fingering(${event.finger})`,\n\t\t}));\n\n\ttrack.forEach(event => event.ticks = Math.round((event.time - startTime) * msToTicks));\n\ttrack.forEach((event, i) => event.deltaTime = (event.ticks - (i > 0 ? track[i - 1].ticks : 0)));\n\n\treturn {header, tracks: [track]};\n};\n\n\nfunction encodeToMIDI(notation, options) {\n\tconst data = encodeToMIDIData(notation, options);\n\treturn MIDI.encodeMidiFile(data);\n};\n\n\n\nmodule.exports = {\n\tsliceMidi,\n\tencodeToMIDIData,\n\tencodeToMIDI,\n};\n","\nconst MIDI = require(\"./source/inc/MIDI\");\nconst MusicNotation = require(\"./source/inc/MusicNotation\");\nconst MidiPlayer = require(\"./source/inc/MidiPlayer.js\");\nconst Matcher = require(\"./source/inc/Matcher\");\nconst MidiUtils = require(\"./source/inc/MidiUtils.js\");\n\n\n\nmodule.exports = {\n\tMIDI,\n\tMusicNotation,\n\tMidiPlayer,\n\tMatcher,\n\tMidiUtils,\n};\n","import pick from 'lodash/pick';\n\nimport { MusicNotation, MIDI } from '@k-l-lambda/music-widgets';\n\n//import {MeasureLayout, LayoutType} from\nimport { ImplicitType, ChordPosition } from './types';\n\nconst WHOLE_DURATION_MAGNITUDE = 1920;\nconst TICKS_PER_BEAT = WHOLE_DURATION_MAGNITUDE / 4;\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ninterface StaffNoteProperties {\n\trest: boolean;\n\ttied: boolean;\n\toverlapped: boolean;\n\timplicitType: ImplicitType;\n\tafterGrace: boolean;\n\tchordPosition: ChordPosition;\n\tdivision: number;\n\n\tcontextIndex: number;\n\tstaffTrack: number;\n}\n\ninterface MetaNote extends MusicNotation.Note, Partial {\n\tid: string;\n\tmeasure: number;\n\tendTick: number;\n}\n\ninterface SubNote {\n\tstartTick: number;\n\tendTick: number;\n\tpitch: number;\n\tvelocity?: number;\n}\n\ninterface MeasureNote extends Partial {\n\ttick: number;\n\tpitch: number;\n\tduration: number;\n\tchordPosition: ChordPosition;\n\tstaff: number;\n\n\ttrack: number;\n\tchannel: number;\n\tid: string;\n\tids: string[];\n\n\tsubNotes: SubNote[];\n}\n\ninterface MeasureEvent {\n\tdata: any;\n\ttrack: number;\n\tticks?: number;\n}\n\ninterface Measure {\n\ttick: number;\n\tduration: number;\n\n\tnotes: MeasureNote[];\n\tevents?: MeasureEvent[];\n\ttimeSignature?: Fraction;\n\tkeySignature?: number;\n}\n\ninterface PerformOptions {\n\twithRestTied?: boolean;\n}\n\ninterface MidiEvent extends MIDI.MidiEvent {\n\tticks?: number;\n\tmeasure?: number;\n\tids?: string[];\n\tstaffTrack?: number;\n\tstaff?: number;\n}\ntype MidiTrack = MidiEvent[];\n\nconst EXTRA_NOTE_FIELDS = ['rest', 'tied', 'overlapped', 'implicitType', 'afterGrace', 'contextIndex', 'staffTrack', 'chordPosition', 'division'];\nconst COMMON_NOTE_FIELDS = ['id', 'ids', 'pitch', 'velocity', 'track', 'channel', ...EXTRA_NOTE_FIELDS];\n\nclass MetaNotation {\n\t//pitchContextGroup: PitchContextTable[];\n\t//measureLayout: MeasureLayout;\n\tmeasures: Measure[];\n\n\ttrackNames: string[];\n\tidTrackMap: { [key: string]: number };\n\n\tripe: boolean = false;\n\n\tstatic fromAbsoluteNotes(notes: MetaNote[], measureHeads: number[], data?: Partial): MetaNotation {\n\t\tconst notation = new MetaNotation(data);\n\n\t\tnotation.measures = Array(measureHeads.length)\n\t\t\t.fill(null)\n\t\t\t.map((__, i) => {\n\t\t\t\tconst tick = measureHeads[i];\n\t\t\t\tconst duration = measureHeads[i + 1] ? measureHeads[i + 1] - tick : 0;\n\n\t\t\t\tconst mnotes = notes\n\t\t\t\t\t.filter((note) => note.measure === i + 1)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(note) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\ttick: note.startTick - tick,\n\t\t\t\t\t\t\t\tduration: note.endTick - note.startTick,\n\t\t\t\t\t\t\t\t...pick(note, COMMON_NOTE_FIELDS),\n\t\t\t\t\t\t\t\tsubNotes: [],\n\t\t\t\t\t\t\t} as MeasureNote)\n\t\t\t\t\t);\n\n\t\t\t\t// reduce note data size\n\t\t\t\tmnotes.forEach((mn) =>\n\t\t\t\t\t['rest', 'tied', 'implicitType', 'afterGrace'].forEach((field) => {\n\t\t\t\t\t\tif (!mn[field]) delete mn[field];\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes: mnotes,\n\t\t\t\t};\n\t\t\t});\n\n\t\tnotation.idTrackMap = notes.reduce((map, note) => {\n\t\t\tif (note.id) map[note.id] = note.track;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn notation;\n\t}\n\n\tstatic performAbsoluteNotes(abNotes: MetaNote[], { withRestTied = false }: PerformOptions = {}): MusicNotation.Note[] {\n\t\tconst notes = abNotes\n\t\t\t.filter((note) => (withRestTied || (!note.rest && !note.tied)) && !note.overlapped)\n\t\t\t.map((note) => ({\n\t\t\t\tmeasure: note.measure,\n\t\t\t\tchannel: note.channel,\n\t\t\t\ttrack: note.track,\n\t\t\t\tstart: note.start,\n\t\t\t\tstartTick: note.startTick,\n\t\t\t\tendTick: note.endTick,\n\t\t\t\tpitch: note.pitch,\n\t\t\t\tduration: note.duration,\n\t\t\t\tvelocity: note.velocity || 127,\n\t\t\t\tid: note.id,\n\t\t\t\tids: note.ids,\n\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\tcontextIndex: note.contextIndex,\n\t\t\t\timplicitType: note.implicitType,\n\t\t\t\tchordPosition: note.chordPosition,\n\t\t\t}));\n\n\t\tconst noteMap = notes.reduce((map, note) => {\n\t\t\tconst key = `${note.channel}|${note.start}|${note.pitch}`;\n\t\t\tconst priorNote = map[key];\n\t\t\tif (priorNote) priorNote.ids.push(...note.ids);\n\t\t\telse map[key] = note;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(noteMap);\n\t}\n\n\tconstructor(data?: Partial) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\t/*get ordinaryMeasureIndices (): number[] {\n\t\tif (this.measureLayout)\n\t\t\treturn this.measureLayout.serialize(LayoutType.Ordinary);\n\n\t\treturn Array(this.measures.length).fill(null).map((_, i) => i + 1);\n\t}*/\n\n\t// In Lilypond 2.20.0, minus tick value at the head of a track result in MIDI event time bias,\n\t//\tSo store the bias values to correct MIDI time from lilyond.\n\tget trackTickBias(): { [key: string]: number } {\n\t\tconst headMeasure = this.measures[0];\n\t\treturn this.trackNames.reduce((map, name, track) => {\n\t\t\tmap[name] = 0;\n\t\t\tif (headMeasure) {\n\t\t\t\tconst note = headMeasure.notes.find((note) => note.track === track);\n\t\t\t\tif (note) map[name] = Math.min(note.tick, 0);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget idSet(): Set {\n\t\treturn this.measures.reduce(\n\t\t\t(set, measure) => (measure.notes.filter((note) => !note.rest).forEach((note) => note.ids.forEach((id) => set.add(id))), set),\n\t\t\tnew Set()\n\t\t);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\t__prototype: 'LilyNotation',\n\t\t\t//pitchContextGroup: this.pitchContextGroup,\n\t\t\t//measureLayout: this.measureLayout,\n\t\t\tmeasures: this.measures,\n\t\t\tidTrackMap: this.idTrackMap,\n\t\t\ttrackNames: this.trackNames,\n\t\t\tripe: this.ripe,\n\t\t};\n\t}\n\n\ttoAbsoluteNotes(measureIndices: number[] /*= this.ordinaryMeasureIndices*/): MetaNote[] {\n\t\tlet measureTick = 0;\n\t\tconst measureNotes: MetaNote[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst notes = measure.notes.map((mnote) => {\n\t\t\t\treturn {\n\t\t\t\t\tstartTick: measureTick + mnote.tick,\n\t\t\t\t\tendTick: measureTick + mnote.tick + mnote.duration,\n\t\t\t\t\tstart: measureTick + mnote.tick,\n\t\t\t\t\tduration: mnote.duration,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t\t...pick(mnote, COMMON_NOTE_FIELDS),\n\t\t\t\t} as MetaNote;\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn notes;\n\t\t});\n\n\t\treturn [].concat(...measureNotes);\n\t}\n\n\t/*getMeasureIndices (type: LayoutType) {\n\t\treturn this.measureLayout.serialize(type);\n\t}*/\n\n\ttoPerformingNotation(measureIndices: number[] /*= this.ordinaryMeasureIndices*/, options: PerformOptions = {}): MusicNotation.Notation {\n\t\t//console.debug(\"toPerformingNotation:\", this, measureIndices);\n\t\tconst abNotes = this.toAbsoluteNotes(measureIndices);\n\t\tconst notes = MetaNotation.performAbsoluteNotes(abNotes, options);\n\n\t\t//const lastNote = notes[notes.length - 1];\n\t\tconst endTime = Math.max(...notes.map((note) => note.start + note.duration));\n\n\t\tconst endTick = measureIndices.reduce((tick, index) => tick + this.measures[index - 1].duration, 0);\n\n\t\tconst notation = new MusicNotation.Notation({\n\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\tmeta: {},\n\t\t\ttempos: [], // TODO\n\t\t\tchannels: [notes],\n\t\t\tendTime,\n\t\t\tendTick,\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\ttoPerformingMIDI(measureIndices: number[], { trackList }: { trackList?: boolean[] } = {}): MIDI.MidiData & { zeroTick: number } {\n\t\tif (!measureIndices.length) return null;\n\n\t\t// to avoid begin minus tick\n\t\tconst zeroTick = -Math.min(0, ...(this.measures[0]?.events.map((e) => e.ticks) || []), ...(this.measures[0]?.notes.map((note) => note.tick) || []));\n\n\t\tlet measureTick = zeroTick;\n\t\tconst measureEvents: MeasureEvent[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst events = measure.events.map((mevent) => ({\n\t\t\t\tticks: measureTick + mevent.ticks,\n\t\t\t\ttrack: mevent.track,\n\t\t\t\tdata: {\n\t\t\t\t\t...mevent.data,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn events;\n\t\t});\n\n\t\tconst eventPriority = (event: MidiEvent): number => event.ticks + (event.subtype === 'noteOff' ? -1e-8 : 0);\n\n\t\tconst tracks: MidiTrack[] = [].concat(...measureEvents).reduce((tracks, mevent) => {\n\t\t\ttracks[mevent.track] = tracks[mevent.track] || [];\n\t\t\ttracks[mevent.track].push({\n\t\t\t\tticks: mevent.ticks,\n\t\t\t\t...mevent.data,\n\t\t\t});\n\n\t\t\treturn tracks;\n\t\t}, []);\n\n\t\ttracks[0] = tracks[0] || [];\n\t\t/*tracks[0].push({\n\t\t\tticks: 0,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `${npmPackage.name} ${npmPackage.version}`,\n\t\t});*/\n\n\t\t// append note events\n\t\tmeasureTick = zeroTick;\n\t\tmeasureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\t\t\tif (!Number.isFinite(measure.duration)) return;\n\n\t\t\tmeasure.notes.forEach((note) => {\n\t\t\t\tif (trackList && !trackList[note.track]) return;\n\n\t\t\t\tif (note.rest) return;\n\n\t\t\t\tconst tick = measureTick + note.tick;\n\n\t\t\t\tconst track = (tracks[note.track] = tracks[note.track] || []);\n\n\t\t\t\tnote.subNotes.forEach((subnote) => {\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.startTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: subnote.velocity,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.endTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: 0,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\t\t});\n\n\t\tconst finalTick = measureTick;\n\n\t\t// ensure no empty track\n\t\tfor (let t = 0; t < tracks.length; ++t) tracks[t] = tracks[t] || [];\n\n\t\t// sort & make deltaTime\n\t\ttracks.forEach((events) => {\n\t\t\tevents.sort((e1, e2) => eventPriority(e1) - eventPriority(e2));\n\n\t\t\tlet ticks = 0;\n\t\t\tevents.forEach((event) => {\n\t\t\t\tevent.deltaTime = event.ticks - ticks;\n\t\t\t\tif (!Number.isFinite(event.deltaTime)) event.deltaTime = 0;\n\t\t\t\telse ticks = event.ticks;\n\t\t\t});\n\n\t\t\tevents.push({ deltaTime: Math.max(finalTick - ticks, 0), type: 'meta', subtype: 'endOfTrack' });\n\t\t});\n\n\t\treturn {\n\t\t\theader: {\n\t\t\t\tformatType: 0,\n\t\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\t},\n\t\t\ttracks,\n\t\t\tzeroTick,\n\t\t};\n\t}\n\n\ttoPerformingNotationWithEvents(measureIndices: number[], options: { trackList?: boolean[] } = {}): MusicNotation.Notation {\n\t\tif (!measureIndices.length) return null;\n\n\t\tconst { zeroTick, ...midi } = this.toPerformingMIDI(measureIndices, options);\n\t\tconst notation = MusicNotation.Notation.parseMidi(midi);\n\n\t\tassignNotationNoteDataFromEvents(notation);\n\n\t\tlet tick = zeroTick;\n\n\t\tnotation.measures = measureIndices.map((index) => {\n\t\t\tconst startTick = tick;\n\t\t\ttick += this.measures[index - 1].duration;\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tstartTick,\n\t\t\t\tendTick: tick,\n\t\t\t};\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\t// find the MIDI event of setTempo in measures data, and change the value of microsecondsPerBeat\n\tsetTempo(bpm: number): boolean {\n\t\tlet found = false;\n\t\tfor (const measure of this.measures) {\n\t\t\tfor (const event of measure.events) {\n\t\t\t\tif (event.data.subtype === 'setTempo') {\n\t\t\t\t\tevent.data.microsecondsPerBeat = 60e6 / bpm;\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn found;\n\t}\n}\n\nconst assignNotationNoteDataFromEvents = (midiNotation: MusicNotation.NotationData, fields = ['ids', 'measure', 'staffTrack']) => {\n\tconst noteId = (channel: number, pitch: number, tick: number): string => `${channel}|${pitch}|${tick}`;\n\n\tconst noteMap = midiNotation.notes.reduce((map, note) => {\n\t\tmap[noteId(note.channel, note.pitch, note.startTick)] = note;\n\n\t\treturn map;\n\t}, {});\n\n\tmidiNotation.events.forEach((event) => {\n\t\tif (event.data.subtype === 'noteOn') {\n\t\t\tconst id = noteId(event.data.channel, event.data.noteNumber, event.ticks);\n\t\t\tconst note = noteMap[id];\n\t\t\tconsole.assert(!!note, 'cannot find note of', id);\n\n\t\t\tif (note) Object.assign(note, pick(event.data, fields));\n\t\t}\n\t});\n};\n\nexport { MetaNote, MetaNotation, MidiEvent };\n",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import _SHA256 from 'crypto-js/sha256';\n\nconst SHA256 = (source: string): Uint8Array => {\n\tconst { words, sigBytes } = _SHA256(source);\n\tconst uwords = words.map((x) => (x < 0 ? x + 0x100000000 : x));\n\tconst word_len = sigBytes / words.length;\n\n\treturn new Uint8Array(sigBytes).map((_, i) => (uwords[Math.floor(i / word_len)] >> ((3 - (i % word_len)) * 8)) & 0xff);\n};\n\ntype Hash = Uint8Array;\nconst HASH_LEN = 256;\n\nclass HashVector {\n\tfields: number[];\n\n\tstatic fromHash(hash: Hash): HashVector {\n\t\tconst fields = [];\n\t\tfor (const byte of hash) {\n\t\t\tfor (let b = 0; b < 8; ++b) fields.push((byte >> b) & 1 ? 1 : -1);\n\t\t}\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic fromString(source: string): HashVector {\n\t\tconst hash = SHA256(source);\n\t\treturn HashVector.fromHash(hash);\n\t}\n\n\tstatic fromWords(words: string[]): HashVector {\n\t\tconst vs = words.map((word) => HashVector.fromString(word));\n\t\treturn vs.reduce((sum, v) => sum.add(v), HashVector.zero);\n\t}\n\n\tstatic concat(...vectors: HashVector[]): HashVector {\n\t\tconst fields = vectors.map((v) => v.fields).flat(1);\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tconstructor(fields: number[] | null = null) {\n\t\tthis.fields = fields || Array(HASH_LEN).fill(0);\n\t}\n\n\tget length(): number {\n\t\treturn this.fields.length;\n\t}\n\n\ttoHash(): Hash {\n\t\treturn Uint8Array.from(\n\t\t\tArray(this.length / 8)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => {\n\t\t\t\t\tconst bits = this.fields.slice(i * 8, (i + 1) * 8);\n\n\t\t\t\t\treturn bits.reduce((byte, bit, b) => byte | ((bit > 0 ? 1 : 0) << b), 0);\n\t\t\t\t})\n\t\t) as Hash;\n\t}\n\n\tadd(vec: HashVector): this {\n\t\tthis.fields.forEach((value, i) => (this.fields[i] = value + vec.fields[i]));\n\n\t\treturn this;\n\t}\n\n\tscale(factor: number): this {\n\t\tthis.fields = this.fields.map((value) => value * factor);\n\n\t\treturn this;\n\t}\n\n\tsub(crop: number): HashVector {\n\t\tconst fields = crop > 0 ? this.fields.slice(0, crop) : this.fields.slice(crop);\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic get zero(): HashVector {\n\t\treturn new HashVector();\n\t}\n}\n\nconst odds = (byte: number): number => {\n\tlet result = 0;\n\tfor (let b = byte; b > 0; b >>= 1) {\n\t\tif (b % 2) ++result;\n\t}\n\n\treturn result;\n};\nconst ODDS = Array(2 ** 8)\n\t.fill(0)\n\t.map((_, i) => odds(i));\nconst ODDS_HEX = ODDS.reduce((table, odd, i) => ({ ...table, [('0' + i.toString(16)).slice(-2)]: odd }), {});\n\nconst countOnes = (hash: Hash): number => hash.reduce((sum, byte) => sum + ODDS[byte], 0);\n\nconst xorHashes = (hash1: Hash, hash2: Hash): Hash => hash1.map((byte, i) => byte ^ hash2[i]) as Hash;\n\nconst cosHashes = (hash1: Hash, hash2: Hash): number => {\n\tconst len = hash1.length * 8;\n\n\tconst xor = xorHashes(hash1, hash2);\n\tconst ones = countOnes(xor);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst cosBigInts = (hash1: bigint, hash2: bigint, len: number = HASH_LEN): number => {\n\tconst xor = hash1 ^ hash2;\n\tconst xor_hex = '0'.repeat(len / 4) + xor.toString(16);\n\n\tconst ones = Array(len / 8)\n\t\t.fill(0)\n\t\t.reduce((ones, _, i) => ones + ODDS_HEX[xor_hex.slice((i + 1) * -2, i ? i * -2 : undefined)], 0);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst i2hex = (i) => ('0' + i.toString(16)).slice(-2);\nconst hashToHex = (hash: Hash): string => Array.from(hash).map(i2hex).join('');\n\nconst hexToHash = (hex: string): Hash =>\n\tUint8Array.from(\n\t\tArray(hex.length / 2)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => hex.substring(i * 2, (i + 1) * 2))\n\t\t\t.map((x) => parseInt(x, 16))\n\t);\n\nconst hashToBigInt = (hash: Hash): bigint => {\n\t// __NOT_FOR_BROWSER_\n\treturn Array.from(hash).reduce((r, x) => r * 0x100n + BigInt(x), 0n);\n\t/*\n\t// _NOT_FOR_BROWSER__\n\tthrow new Error('BigInt not supported');\n\t//*/\n};\n\nconst hashFromWords = (words: string[]): Hash => HashVector.fromWords(words).toHash();\n\nexport { Hash, HashVector, cosHashes, cosBigInts, hashToHex, hexToHash, hashToBigInt, hashFromWords };\n","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import { SimpleClass } from './aux_/typedJSON';\nimport { StaffBasic } from './interfaces';\nimport { SemanticPoint } from './semanticPoint';\nimport { EventTerm, ContextedTerm, MarkTerm } from './term';\n\nclass PatchMeasure extends SimpleClass {\n\tstatic className = 'PatchMeasure';\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tbasic: StaffBasic;\n\n\t//points: SemanticPoint[];\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tvoices: number[][]; // [voice, id]\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tObject.assign(this, data);\n\t}\n\n\tget staffN(): number {\n\t\treturn Math.floor(Math.log2(this.staffMask)) + 1;\n\t}\n\n\tget basics(): StaffBasic[] {\n\t\treturn Array(this.staffN).fill(this.basic);\n\t}\n\n\tget duration(): number {\n\t\treturn Math.max(\n\t\t\t0,\n\t\t\t...this.voices.map((ids) => {\n\t\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\n\t\t\t\treturn events.reduce((duration, event) => duration + event.duration, 0);\n\t\t\t})\n\t\t);\n\t}\n}\n\nexport { PatchMeasure };\n","import { EventFeature, BackgroundImage, EventPredisposition } from './interfaces';\nimport { StemBeam } from './term';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum EventElementType {\n\tPAD,\n\tBOS,\n\tEOS,\n\n\tCHORD,\n\tREST,\n}\n\ninterface EventElement {\n\thref?: string;\n\tdisposed?: boolean;\n\tindex?: number;\n\tvoice?: number;\n\n\ttype: EventElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\tfeature: EventFeature;\n\tpivotX?: number;\n\theadY?: number;\n\n\t// targets\n\ttick?: number;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: StemBeam;\n\tstemDirection?: string;\n\tgrace?: boolean;\n\ttremoloCatcher?: boolean;\n\ttimeWarped?: boolean;\n\tfullMeasure?: boolean; // full measure rest\n\tfake?: boolean;\n\n\torder?: number;\n\n\tpredisposition?: EventPredisposition;\n}\n\ntype Matrix = number[][];\n\ninterface Annotation {\n\tloss: number;\n\tgrant: boolean;\n\tpatched: boolean; // from manually solved measure\n}\n\nclass EventCluster extends SimpleClass {\n\tstatic className = 'EventCluster';\n\tstatic blackKeys = ['id'];\n\n\tid?: string; // for db access\n\tindex?: number;\n\tduration?: number;\n\tstaffY0?: number; // the first staff top + staffY\n\n\tsignatureDuration: number;\n\telements: EventElement[];\n\tmatrixH?: Matrix; // matrix N x N, [next][prev]\n\n\tbackgroundImages?: BackgroundImage[];\n\n\tannotation?: Annotation;\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget regular(): boolean {\n\t\treturn (\n\t\t\tthis.elements.some((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !elem.fake) &&\n\t\t\tthis.elements.every((elem) => [elem.x, elem.y1, elem.y2, elem.tick].every(Number.isFinite)) &&\n\t\t\tthis.elements\n\t\t\t\t.slice(1)\n\t\t\t\t.every(\n\t\t\t\t\t(elem, ei) =>\n\t\t\t\t\t\telem.fake ||\n\t\t\t\t\t\tthis.elements[ei].fake ||\n\t\t\t\t\t\telem.grace ||\n\t\t\t\t\t\tthis.elements[ei].grace ||\n\t\t\t\t\t\telem.fullMeasure ||\n\t\t\t\t\t\tthis.elements[ei].fullMeasure ||\n\t\t\t\t\t\telem.tick <= this.elements[ei].tick ||\n\t\t\t\t\t\telem.x > this.elements[ei].x\n\t\t\t\t)\n\t\t);\n\t}\n\n\tget grant(): boolean {\n\t\treturn this.annotation && this.annotation.grant;\n\t}\n\n\tget feature(): Partial {\n\t\treturn {\n\t\t\tindex: this.index,\n\t\t\telements: this.elements,\n\t\t};\n\t}\n\n\tget estimatedDuration(): number {\n\t\tconst endElem = this.elements.find((elem) => elem.type === EventElementType.EOS);\n\n\t\tconst tick = endElem?.predisposition ? endElem.predisposition?.tick : endElem?.tick;\n\n\t\treturn Number.isFinite(tick) ? tick : this.duration;\n\t}\n\n\tassignPrediction(prediction: any): void {\n\t\tconsole.assert(prediction.index === this.index, 'index mismatch:', prediction.index, this.index);\n\n\t\tthis.matrixH = prediction.matrixH;\n\t\tprediction.elements.forEach((pe) => {\n\t\t\tconst { index, ...predisposition } = pe;\n\t\t\tconst elem = this.elements.find((elem) => elem.index === index);\n\t\t\tconsole.assert(elem, 'element not found:', index);\n\n\t\t\tif (elem) elem.predisposition = predisposition;\n\t\t});\n\t}\n}\n\nclass EventClusterSet extends SimpleClass {\n\tstatic className = 'EventClusterSet';\n\n\tname?: string;\n\n\tclusters: EventCluster[];\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\ttrimIrregular(): number {\n\t\tlet ir = 0;\n\n\t\tthis.clusters = this.clusters.filter((cluster) => {\n\t\t\tconst regular = cluster.regular;\n\t\t\tif (!regular) {\n\t\t\t\tconsole.debug('irregular cluster:', cluster);\n\t\t\t\t++ir;\n\t\t\t}\n\n\t\t\treturn regular;\n\t\t});\n\n\t\tif (ir) console.debug('Irregular clusters trimmed:', `${ir}/${this.clusters.length + ir}`);\n\t\telse console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`);\n\n\t\treturn ir;\n\t}\n}\n\nexport { EventElementType, EventElement, EventCluster, EventClusterSet };\n","import erf from 'math-erf';\nimport sha1 from 'js-sha1';\n\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventTerm, ContextedTerm, MarkTerm, WHOLE_DURATION, StemBeam, GraceType, ContextType, TremoloLink } from './term';\nimport {\n\tFraction,\n\tStaffBasic,\n\tEventMeasure,\n\tRegulationOptions,\n\tRegulationSolution,\n\tRegulationSolutionEvent,\n\tBackgroundImage,\n\tMeasureBarType,\n} from './interfaces';\nimport { frac, fractionMul, roundNumber, argmax } from './utils';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\nimport * as EquationSolver from './equationSolver';\nimport { PatchMeasure } from './patch';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport type { MeasureRectification } from './measureRectification';\nimport type { GraphMeasure } from './timewiseGraph';\n\nnamespace SimplePolicy {\n\tconst constructXMap = (measure: SpartitoMeasure): Map => {\n\t\tconst xMap = new Map();\n\n\t\t// mark full measure rests\n\t\tmeasure.rows.forEach((row) => {\n\t\t\tif (row.events.length === 1) {\n\t\t\t\tconst event = row.events[0];\n\t\t\t\tif (event.rest && event.division === 0) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst x = Math.round(event.pivotX * 10) / 10;\n\t\t\tlet key = 0;\n\t\t\tif (event.fullMeasureRest) key = Math.min(x, ...xMap.keys());\n\t\t\telse {\n\t\t\t\tkey =\n\t\t\t\t\t[...xMap.keys()].find((k) => {\n\t\t\t\t\t\t// check if the event is aligned with the current chord\n\t\t\t\t\t\tconst es = xMap.get(k);\n\t\t\t\t\t\tconst left = Math.min(...es.map((e) => e.left));\n\t\t\t\t\t\tconst right = Math.max(...es.map((e) => e.right));\n\n\t\t\t\t\t\tconst overlaySize = Math.min(right, event.right) - Math.max(left, event.left);\n\n\t\t\t\t\t\treturn overlaySize > NOTEHEAD_WIDTHS.NoteheadS1 * 0.62;\n\t\t\t\t\t}) || x;\n\t\t\t}\n\t\t\tevent.roundX = key;\n\n\t\t\tconst es = xMap.get(key) || [];\n\t\t\txMap.set(key, es);\n\n\t\t\tes.push(event);\n\t\t});\n\n\t\treturn xMap;\n\t};\n\n\texport const computeMeasureTicks = (measure: SpartitoMeasure): void => {\n\t\tconst xMap = constructXMap(measure);\n\n\t\tlet tick = 0;\n\t\tconst ts = new Set([tick]);\n\t\tconst eventGroups = [...xMap.entries()].sort(([x1], [x2]) => x1 - x2); //.map(entry => entry[1]);\n\t\tfor (const [x, events] of eventGroups) {\n\t\t\tvoid x;\n\n\t\t\tevents.forEach((event: EventTerm) => {\n\t\t\t\tif (event.predisposition) {\n\t\t\t\t\tevent.rest = event.rest && event.predisposition.fullMeasure > 0.5 ? 'R' : event.rest;\n\t\t\t\t\tevent.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t\tevent.division = argmax(event.predisposition.divisionVector);\n\t\t\t\t\tevent.dots = argmax(event.predisposition.dotsVector);\n\t\t\t\t\tif (event.predisposition.timeWarped > 0.5) event.timeWarp = frac(2, 3);\n\t\t\t\t}\n\n\t\t\t\tif (event.fullMeasureRest) event.tick = 0;\n\t\t\t\telse {\n\t\t\t\t\tif (event.zeroHolder) tick -= event.duration;\n\n\t\t\t\t\tif (!event.zeroHolder && event.predisposition && Number.isInteger(event.predisposition.tick)) event.tick = event.predisposition.tick;\n\t\t\t\t\telse event.tick = tick;\n\t\t\t\t\tts.add(event.tick + event.duration);\n\t\t\t\t}\n\t\t\t\t//console.log(\"append tick:\", event.tick + event.duration, event);\n\t\t\t});\n\t\t\tts.delete(tick);\n\n\t\t\t//column.xToTick[x] = tick;\n\n\t\t\tif (ts.size) tick = Math.min(...ts);\n\t\t}\n\n\t\tif (Number.isInteger(measure.estimatedDuration)) measure.duration = measure.estimatedDuration;\n\t\telse measure.duration = Math.max(...ts, 0);\n\t};\n\n\texport const computeMeasureVoices = (measure: SpartitoMeasure): void => {\n\t\tmeasure.voices = [];\n\t\tfor (const row of measure.rows) {\n\t\t\tconst events = row.events.filter(\n\t\t\t\t(event) => !event.grace && !event.tremoloCatcher && !event.fullMeasureRest && !(event.predisposition && event.predisposition.fake > 0.5)\n\t\t\t);\n\t\t\tconst eventSet = new Set(events);\n\n\t\t\twhile (eventSet.size) {\n\t\t\t\tlet tick = 0;\n\n\t\t\t\tconst voice = [];\n\t\t\t\tconst pushEvent = (e: EventTerm) => {\n\t\t\t\t\tvoice.push(e.id);\n\t\t\t\t\tif (!e.zeroHolder) tick += e.duration;\n\t\t\t\t\teventSet.delete(e);\n\t\t\t\t};\n\n\t\t\t\tconst e0 = events.find((e) => eventSet.has(e));\n\t\t\t\tif (e0.alignedTick > 0) {\n\t\t\t\t\t//voice.tickMap[tick] = EventTerm.space({ tick, duration: e0.alignedTick });\n\t\t\t\t\ttick = e0.alignedTick;\n\t\t\t\t}\n\t\t\t\tpushEvent(e0);\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// TODO: consider slur pair\n\t\t\t\t\tconst e = events.find((e) => eventSet.has(e) && e.alignedTick === tick);\n\t\t\t\t\tif (!e) break;\n\n\t\t\t\t\tpushEvent(e);\n\t\t\t\t}\n\n\t\t\t\t//if (tick < measure.duration)\n\t\t\t\t//\tvoice.tickMap[tick] = EventTerm.space({ tick, duration: staff.duration - tick });\n\n\t\t\t\tmeasure.voices.push(voice);\n\t\t\t}\n\t\t}\n\t};\n}\n\nconst solveGraceEvents = (measure: SpartitoMeasure): void => {\n\tconst graceEvents = measure.events.filter((event) => event.grace /*&& !Number.isFinite(event.tick)*/);\n\tif (!graceEvents.length) return;\n\n\tconst tickMap = measure.tickMap;\n\tconst staffMap = [...tickMap.entries()].reduce((smap, [tick, events]) => {\n\t\tevents.forEach((event) => {\n\t\t\tif (!event.grace) {\n\t\t\t\tsmap[event.staff] = smap[event.staff] || {};\n\n\t\t\t\tconst oldEvent = smap[event.staff][tick];\n\t\t\t\tsmap[event.staff][tick] = !oldEvent || oldEvent.x > event.x ? event : oldEvent;\n\t\t\t}\n\t\t});\n\n\t\treturn smap;\n\t}, {} as { [staff: number]: { [tick: number]: EventTerm } });\n\n\ttype Position = { tick: number; preTick: number; graces: EventTerm[]; event: EventTerm };\n\tconst staffPositions = Object.entries(staffMap).reduce((map, [staff, emap]) => {\n\t\tmap[staff] = Object.entries(emap)\n\t\t\t.map(([t, event]) => ({ event, tick: Number(t), preTick: -240, graces: [] }))\n\t\t\t.sort((p1, p2) => p1.event.x - p2.event.x);\n\t\tmap[staff].push({ tick: measure.duration, event: measure.endEvent, preTick: 0, graces: [] }); // terminal bar\n\n\t\tlet tick = 0;\n\t\tmap[staff].forEach((position) => {\n\t\t\tif (position.tick > tick) {\n\t\t\t\tposition.preTick = tick;\n\t\t\t\ttick = position.tick;\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}, {} as { [staff: number]: Position[] });\n\n\t// append grace events into positions\n\tgraceEvents.forEach((event) => {\n\t\tconst staff = staffPositions[event.staff];\n\t\tif (staff) {\n\t\t\tconst position = staff.find((p) => p.event.x > event.x);\n\t\t\tif (position) position.graces.push(event);\n\t\t\tevent.roundX = event.x;\n\t\t\t//if (position.tick >= measure.duration)\n\t\t\t//\tevent.grace = GraceType.AfterGrace;\n\t\t}\n\t});\n\n\tObject.values(staffPositions).forEach((staff) =>\n\t\tstaff.forEach((position) => {\n\t\t\tif (position.graces.length) {\n\t\t\t\tposition.event.graceIds = position.graces.map((e) => e.id);\n\n\t\t\t\tconst totalDuration = position.graces.reduce((t, e) => t + e.duration, 0);\n\t\t\t\tconst duration = Math.min(totalDuration, position.tick - position.preTick);\n\t\t\t\tconst warp = duration / totalDuration;\n\n\t\t\t\tlet tick = position.tick;\n\t\t\t\t[...position.graces].reverse().forEach((event) => {\n\t\t\t\t\tevent.tick = Math.round(tick - event.duration * warp);\n\t\t\t\t\ttick = event.tick;\n\t\t\t\t});\n\t\t\t}\n\t\t})\n\t);\n};\n\nconst solveTremoloPairs = (measure: SpartitoMeasure): void => {\n\tconst catchers = measure.events.filter((event) => event.tremoloCatcher && !event.grace);\n\tconst pitchers = measure.events.filter((event) => event.tremoloLink === TremoloLink.Pitcher && !event.grace);\n\n\tcatchers.forEach((catcher) => {\n\t\tlet candidates = pitchers.filter((event) => event.division === catcher.division && event.x < catcher.x);\n\t\tif (!candidates.length)\n\t\t\tcandidates = measure.events.filter(\n\t\t\t\t(event) =>\n\t\t\t\t\tNumber.isFinite(event.tick) &&\n\t\t\t\t\t!event.grace &&\n\t\t\t\t\t!event.rest &&\n\t\t\t\t\tevent.division === catcher.division &&\n\t\t\t\t\tevent.dots === catcher.dots &&\n\t\t\t\t\tevent.x < catcher.x\n\t\t\t);\n\t\tcandidates.sort((c1, c2) => c2.x - c1.x);\n\t\tif (candidates.length) {\n\t\t\tconst pitcher = candidates[0];\n\t\t\tpitcher.catcherId = catcher.id;\n\t\t\tconst tremolo = Math.max(pitcher.tremolo || 3, catcher.tremolo || 3);\n\t\t\tpitcher.tremolo = tremolo;\n\t\t\tcatcher.tremolo = tremolo;\n\n\t\t\tif (!catcher.tick) catcher.tick = pitcher.tick + pitcher.duration / 2;\n\n\t\t\tconst pi = pitchers.indexOf(pitcher);\n\t\t\tif (pi >= 0) pitchers.splice(pi, 1);\n\t\t}\n\t});\n};\n\nnamespace EquationPolicy {\n\ttype EventID = number;\n\ttype Time = number;\n\n\tconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\n\tconst CHORDS_SEAM_SIGMA = 0.6;\n\tconst NEIGHBOR_CHORDS_SIGMA = 1.6;\n\tconst Y_DECAY_SIGMA = 16;\n\tconst STAFF_DECAY_FACTOR = 2;\n\tconst STEM_DIRECTION_DECAY = 0.9;\n\tconst ILL_BEAMS_PENALTY = 0.2;\n\n\tconst INVERT_SQRT2 = 0.7071067811865475;\n\n\tconst MATRIX_H_WEIGHT = 3;\n\n\tconst FINE_BEAMS = [\n\t\t[null, null],\n\t\t[null, StemBeam.Open],\n\t\t[StemBeam.Open, StemBeam.Continue],\n\t\t[StemBeam.Open, StemBeam.Close],\n\t\t[StemBeam.Continue, StemBeam.Continue],\n\t\t[StemBeam.Continue, StemBeam.Close],\n\t\t[StemBeam.Close, null],\n\t\t[StemBeam.Close, StemBeam.Open],\n\t].map((bb) => bb.join('-'));\n\n\tinterface Event {\n\t\tid: EventID;\n\t\tstaff: number;\n\t\tx: number;\n\t\ty: number;\n\t\tduration: Time;\n\t\tconfidence: number;\n\t\tshrinkness: number;\n\t}\n\n\texport interface StaffGroup {\n\t\tevents: Event[];\n\t\texpectedDuration: Time;\n\t\tmeasureShrinkness: number;\n\t\tendX: number;\n\t\tmatrixH: Matrix;\n\t\tmatrixV: Matrix;\n\n\t\tids?: EventID[];\n\t}\n\n\tinterface EventResult {\n\t\tid: EventID;\n\t\ttick: Time;\n\t\tendTick: Time;\n\t\ttickGroup: number;\n\t\ttimeWarp?: Fraction;\n\t}\n\n\texport interface StaffGroupSolution {\n\t\tevents: EventResult[];\n\t\tvoices: EventID[][];\n\t\tduration: number;\n\n\t\tloss?: number;\n\t\tcredits?: number;\n\t\ttimes?: number;\n\t}\n\n\texport interface RegulatorOptions extends EquationSolver.SolverOptions {\n\t\tsolver?: (staffGroup: StaffGroup, options: EquationSolver.SolverOptions) => Promise;\n\t}\n\n\tconst solveStaffGroup = (staffGroup: StaffGroup, options: EquationSolver.SolverOptions): StaffGroupSolution => {\n\t\tif (!staffGroup.events.length) {\n\t\t\treturn {\n\t\t\t\tevents: [],\n\t\t\t\tvoices: [],\n\t\t\t\tduration: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\t\treturn solver.solve();\n\t};\n\n\texport const estiamteMeasure = (measure: SpartitoMeasure): StaffGroup => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => ({\n\t\t\t\tid: event.id,\n\t\t\t\tstaff: event.staff,\n\t\t\t\tx: event.x,\n\t\t\t\ttickEstimated: event.predisposition && Number.isFinite(event.predisposition.tick) ? event.predisposition.tick : event.x,\n\t\t\t\ttipX: event.tipX,\n\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\tduration: (event.mainDuration * DURATION_MULTIPLIER) / WHOLE_DURATION,\n\t\t\t\tdivision: event.division,\n\t\t\t\tdots: event.dots,\n\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\tbeam: event.beam,\n\t\t\t\trest: event.rest,\n\t\t\t\t// the possibility of full measure rest\n\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\tshrinkness: event.predisposition ? event.predisposition.timeWarped : null,\n\t\t\t}));\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: Number.isFinite(e.shrinkness) ? e.shrinkness : Math.tanh((e.division - e.dots * 0.1) / 4),\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\t//const hp = (dx: number): number => 1 - erf(((dx / NEIGHBOR_CHORDS_SIGMA) ** 0.6) * INVERT_SQRT2);\n\t\tconst hp = (dx: number): number => erf(dx / NEIGHBOR_CHORDS_SIGMA) * erf(NEIGHBOR_CHORDS_SIGMA / dx);\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\tif (e1.staffGroup !== e2.staffGroup) matrixH[e1.id][e2.id] = 0;\n\t\t\t\t// prohibit voice crossing staff groups\n\t\t\t\telse if (e1.x <= e2.x) matrixH[e1.id][e2.id] = 0;\n\t\t\t\telse {\n\t\t\t\t\tconst staffDecay = Math.exp(-Math.abs(e1.staff - e2.staff) * STAFF_DECAY_FACTOR);\n\t\t\t\t\tconst yDecay = e1.staff === e2.staff ? Math.exp(-Math.abs(e1.y - e2.y) / Y_DECAY_SIGMA) : 1;\n\t\t\t\t\tconst dx = e1.x - e2.x;\n\t\t\t\t\tconst dtx = e1.tipX - e2.tipX;\n\t\t\t\t\tmatrixH[e1.id][e2.id] = (staffDecay * yDecay * Math.min(hp(dx), hp(dtx))) ** (1 / MATRIX_H_WEIGHT);\n\t\t\t\t}\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\t\t\t\tmatrixH[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\n\t\t\t\t// weaken inconsistent stem directions\n\t\t\t\tif (e1.stemDirection && e2.stemDirection && e1.stemDirection !== e2.stemDirection) matrixH[e1.id][e2.id] *= STEM_DIRECTION_DECAY;\n\n\t\t\t\t// ill beams penalty\n\t\t\t\tif (!e1.rest && !e2.rest && !FINE_BEAMS.includes([e2.beam, e1.beam].join('-'))) matrixH[e1.id][e2.id] *= ILL_BEAMS_PENALTY;\n\t\t\t}\n\n\t\t\t// H possibility of e1 and end of measure\n\t\t\tmatrixH[ids.length][e1.id] = hp(measure.width - e1.x) ** (1 / MATRIX_H_WEIGHT);\n\t\t}\n\n\t\treturn {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness: 0,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t};\n\n\texport const regulateMeasure = async (measure: SpartitoMeasure, { solver = null, ...options }: RegulatorOptions): Promise => {\n\t\tconst env = estiamteMeasure(measure);\n\t\tconst { ids, matrixH, matrixV } = env;\n\n\t\t// copy matrices values from measure topology data\n\t\tif (measure.matrixH) {\n\t\t\tconsole.assert(\n\t\t\t\tmeasure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t\t'matrix shape mismatch:',\n\t\t\t\tids.length,\n\t\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t\t);\n\t\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t\t}\n\t\t}\n\t\tif (measure.matrixV) {\n\t\t\tmatrixV.forEach((row, i) =>\n\t\t\t\trow.forEach((_, j) => {\n\t\t\t\t\tconst mp = measure.matrixV[ids[i]][ids[j]];\n\t\t\t\t\tif (Number.isFinite(mp)) matrixV[i][j] = mp;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\tenv.measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tif (options.logger) options.logger.info('--- MEASURE', measure.measureIndex, '---', env);\n\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\t\tconst resultEvents = solution.events.map((e) => ({\n\t\t\t...e,\n\t\t\tid: env.ids[e.id], // decode compact ids\n\t\t}));\n\t\tresultEvents.forEach((e) => {\n\t\t\tconst event = measure.events.find((e0) => e0.id === e.id);\n\t\t\tevent.tick = Number.isFinite(e.tick) ? Math.round((e.tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : null;\n\t\t\tevent.tickGroup = e.tickGroup;\n\t\t\tevent.timeWarp = e.timeWarp;\n\t\t});\n\n\t\tmeasure.duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\t\tmeasure.voices = solution.voices.map((voice) => voice.map((id) => env.ids[id]));\n\n\t\tmeasure.solutionStat = {\n\t\t\tloss: solution.loss,\n\t\t\tsolverCredits: solution.credits,\n\t\t\tsolverTimes: solution.times,\n\t\t};\n\n\t\t// full measure rests\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst result = resultEvents.find((e) => e.id === event.id);\n\t\t\tif (!result) return;\n\t\t\telse if (!Number.isFinite(result.tick) && event.rest === 'r' && event.division === 0) {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.rest = 'R';\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t} else if (event.rest === 'R') {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t}\n\t\t});\n\t};\n\n\texport const regulateMeasureWithRectification = async (\n\t\tmeasure: SpartitoMeasure,\n\t\trectification: MeasureRectification,\n\t\t{ solver = null, ...options }: RegulatorOptions\n\t): Promise => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => {\n\t\t\t\tconst re = rectification.events.find((e) => e && e.id === event.id);\n\t\t\t\tconst division = Number.isFinite(re?.division) ? re.division : event.division;\n\t\t\t\tconst dots = Number.isFinite(re?.dots) ? re.dots : event.dots;\n\t\t\t\tconst duration = DURATION_MULTIPLIER * 2 ** -division * (2 - 2 ** -dots);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: event.id,\n\t\t\t\t\tstaff: event.staff,\n\t\t\t\t\tx: event.x,\n\t\t\t\t\ttickEstimated: event.predisposition?.tick,\n\t\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\t\tduration,\n\t\t\t\t\t// the possibility of full measure rest\n\t\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\t\tshrinkness: event.predisposition?.timeWarped || 0,\n\t\t\t\t};\n\t\t\t});\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: e.shrinkness,\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\t\t\t}\n\t\t}\n\n\t\t// copy matrices values from measure topology data\n\t\tconsole.assert(\n\t\t\tmeasure.matrixH && measure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t'matrix shape mismatch:',\n\t\t\tids.length,\n\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t);\n\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t}\n\n\t\tlet measureShrinkness = 0;\n\t\tif (Number.isFinite(measure.estimatedDuration)) measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tconst env = {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\n\t\tconst priority = -solution.loss;\n\n\t\tconst events = solution.events.map(({ id, tick, tickGroup, timeWarp }) => {\n\t\t\tconst re = rectification.events.find((e) => e && e.id === id);\n\t\t\tconst tickN = Number.isFinite(tick) ? Math.round((tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : tick;\n\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\ttick: tickN,\n\t\t\t\ttickGroup,\n\t\t\t\ttimeWarp,\n\t\t\t\tdivision: re?.division,\n\t\t\t\tdots: re?.dots,\n\t\t\t};\n\t\t});\n\n\t\tconst duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\n\t\treturn {\n\t\t\tevents,\n\t\t\tvoices: solution.voices,\n\t\t\tduration,\n\t\t\tpriority,\n\t\t};\n\t};\n}\n\ntype Matrix = number[][];\n\ntype TickMap = Map;\n\ninterface SolutionStatistics {\n\tloss?: number;\n\tsolverCredits?: number;\n\tsolverTimes?: number;\n}\n\nclass SpartitoMeasure extends SimpleClass {\n\tstatic className = 'SpartitoMeasure';\n\tstatic blackKeys = ['staffGroups', 'solutionStat', 'measureNumber', 'deposit'];\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tstaffGroups: number[][];\n\toriginalRegulationHash?: string;\n\tmeasureNumber?: number; // count from the last indent measure, head partial measure is zero, skip empty measures\n\n\tpatched: boolean;\n\tdiscard: boolean;\n\n\tposition: {\n\t\tsystemIndex: number;\n\t\tlocalIndex: number; // the measure local index in its system\n\t\tleft: number;\n\t\tright: number;\n\t\tstaffYs?: number[];\n\t\tstaffYsFull?: number[];\n\t};\n\n\tbackgroundImages: BackgroundImage[];\n\n\tevents: EventTerm[];\n\tendEvent: Partial; // the placeholder for end tick\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n\tindent: boolean;\n\n\tsolutionStat?: SolutionStatistics;\n\n\tmatrixH: Matrix; // matrix N x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n\testimatedDuration: number;\n\n\tgraph: GraphMeasure;\n\n\tdeposit: Record;\n\n\tstatic reorderEvents(events: EventTerm[], staffYsFull: number[]): EventTerm[] {\n\t\tconst HALF_NOTEHEAD = 0.7;\n\n\t\tconst ys = [];\n\n\t\tconst es = events.map((e) => ({\n\t\t\tid: e.id,\n\t\t\tstaff: e.staff,\n\t\t\tx: e.x / HALF_NOTEHEAD,\n\t\t\trx: 0,\n\t\t\try: staffYsFull[e.staff] + e.tipY,\n\t\t\ttipY: e.tipY,\n\t\t\tprior: 0,\n\t\t}));\n\t\tes.sort((e1, e2) => e1.x - e2.x);\n\t\tes.slice(1).forEach((e, i) => {\n\t\t\tconst dx = Math.min(Math.round(e.x - es[i].x), 2);\n\t\t\te.rx = es[i].rx + dx;\n\t\t});\n\t\tes.forEach((e) => {\n\t\t\te.prior = e.staff * 1e4 + e.rx + e.tipY * 0.01;\n\n\t\t\tif (!ys.includes(e.ry)) ys.push(e.ry);\n\t\t});\n\t\tes.sort((e1, e2) => e1.prior - e2.prior);\n\t\tys.sort((y1, y2) => y1 - y2);\n\n\t\tlet yi = 0;\n\t\tconst yis = ys.map((y, i) => {\n\t\t\tif (!i || ys[i] - ys[i - 1] < 0.5) return yi;\n\n\t\t\t++yi;\n\t\t\treturn yi;\n\t\t});\n\n\t\tconst result = es.map((e) => new EventTerm({ ...events.find((ev) => ev.id === e.id), intX: e.rx, intY: yis[ys.indexOf(e.ry)] }));\n\t\tresult.forEach((e, i) => (e.id = i + 1));\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tif (!this.originalRegulationHash && !this.regulated) this.originalRegulationHash = this.regulationHash;\n\n\t\tthis.barTypes = this.barTypes || {};\n\n\t\t// Ensure postRegulate runs for measures deserialized with voices (e.g. from patches/JSON)\n\t\t// to set endEvent and roundX needed for playback cursor positioning.\n\t\tif (this.regulated && this.position) this.postRegulate();\n\t}\n\n\tget timeSignature(): Fraction {\n\t\treturn this.basics && this.basics[0].timeSignature;\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.basics && this.basics[0].keySignature;\n\t}\n\n\tget timeSignatureChanged(): boolean {\n\t\treturn this.contexts.filter(Boolean)[0].some((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type));\n\t}\n\n\tget doubtfulTimesig(): boolean {\n\t\treturn this.basics && this.basics[0].doubtfulTimesig;\n\t}\n\n\tget regulated(): boolean {\n\t\treturn !!this.voices;\n\t}\n\n\tget validRegulated(): boolean {\n\t\tif (!this.voices) return false;\n\n\t\treturn this.voices.flat(1).every((id) => Number.isFinite(this.events.find((e) => e.id === id)?.tick));\n\t}\n\n\tget rows(): EventMeasure[] {\n\t\treturn this.contexts.map((contexts, si) => {\n\t\t\tconst events = this.events.filter((e) => e.staff === si);\n\n\t\t\treturn {\n\t\t\t\tevents,\n\t\t\t\tcontexts,\n\t\t\t};\n\t\t});\n\t}\n\n\tget eventStartX(): number {\n\t\treturn this.events.length ? Math.min(...this.events.map((e) => e.x)) : this.startX;\n\t}\n\n\tget startX(): number {\n\t\treturn this.position.left;\n\t}\n\n\tget width(): number {\n\t\treturn this.position.right - this.position.left;\n\t}\n\n\tget tickMap(): TickMap {\n\t\treturn this.events\n\t\t\t.concat([this.endEvent as EventTerm])\n\t\t\t.filter(Boolean)\n\t\t\t.reduce((map, event) => {\n\t\t\t\tif (Number.isFinite(event.tick)) {\n\t\t\t\t\tif (!map.has(event.tick)) map.set(event.tick, []);\n\n\t\t\t\t\tmap.get(event.tick).push(event);\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}, new Map());\n\t}\n\n\tget tickToX(): { [tick: number]: number } {\n\t\treturn [...this.tickMap.entries()].reduce((map, [tick, events]) => {\n\t\t\tevents = events.filter((e) => !e.fullMeasureRest && !e.grace);\n\t\t\tif (events.length) {\n\t\t\t\tconst x = Math.min(...events.map((e) => e.x));\n\t\t\t\tmap[tick] = x;\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget tickRates(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tevents.sort((e1, e2) => e1.x - e2.x);\n\n\t\treturn events.slice(0, events.length - 1).map((e1, i) => {\n\t\t\tconst e2 = events[i + 1];\n\n\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t});\n\t}\n\n\tget tickRatesInStaves(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(sevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickRatesInGroups(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(gevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickTwist(): number {\n\t\tif (!this.duration || !this.staffGroups) return undefined;\n\n\t\tconst events = this.events.filter(\n\t\t\t(event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !(event.rest && event.division === 0)\n\t\t); // ignore rest0\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst twists = Object.values(gevents).map((es) => {\n\t\t\tconst eventsXOrder = [...es].sort((e1, e2) => e1.pivotX - e2.pivotX);\n\t\t\tconst xSpan = this.position.right - eventsXOrder[0].x;\n\t\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\t\tconst e1 = eventsXOrder[i];\n\t\t\t\tconst dx = e2.pivotX - e1.pivotX;\n\t\t\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\t\t\tif (!dt) return dx / xSpan;\n\n\t\t\t\tconst rate = Math.atan2(dt / this.duration, dx / xSpan);\n\n\t\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t\t});\n\n\t\t\treturn Math.max(0, ...tickTwists);\n\t\t});\n\n\t\treturn Math.max(0, ...twists);\n\t}\n\n\tget eventMap(): Record {\n\t\treturn this.events.reduce((map, event) => {\n\t\t\tmap[event.id] = event;\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget empty(): boolean {\n\t\treturn !this.events?.length || !this.voices?.length;\n\t}\n\n\tget hasIllEvent(): boolean {\n\t\treturn this.regulated && this.events.some((event) => !event.zeroHolder && !Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t}\n\n\tget brief(): string {\n\t\tconst timesig = `${this.timeSignature.numerator}/${this.timeSignature.denominator}`;\n\t\tconst eventBrieves = this.events.map((e) =>\n\t\t\t[\n\t\t\t\te.staff,\n\t\t\t\te.intX,\n\t\t\t\tMath.round(e.tip ? e.tip.y : e.ys?.[0] ?? 0),\n\t\t\t\te.fullMeasureRest ? 0 : e.division,\n\t\t\t\te.fullMeasureRest ? 0 : e.dots,\n\t\t\t\te.rest ? 'r' : '',\n\t\t\t\te.grace || '',\n\t\t\t\te.stemDirection,\n\t\t\t\te.beam || '',\n\t\t\t].join('|')\n\t\t);\n\n\t\treturn [timesig, ...eventBrieves].join('\\n');\n\t}\n\n\tget regulationHash(): string {\n\t\treturn sha1(this.brief);\n\t}\n\n\t// prefer use originalRegulationHash\n\tget regulationHash0(): string {\n\t\treturn this.originalRegulationHash || this.regulationHash;\n\t}\n\n\tget regulationHashes(): string[] {\n\t\treturn Array.from(new Set([this.originalRegulationHash, this.regulationHash].filter(Boolean)));\n\t}\n\n\tget featureWords(): string[][] | null {\n\t\tif (!this.regulated || !this.voices || !this.voices.length) return null;\n\n\t\tconst invalid = this.tickRatesInStaves.some((rate) => rate < 0);\n\n\t\tconst mainEvents = this.events.filter((event) => !event.zeroHolder && !event.rest);\n\n\t\tconst ys = mainEvents\n\t\t\t.map((event) => event.ys)\n\t\t\t.flat(1)\n\t\t\t.map((y) => `Y${-y * 2}`);\n\t\tconst uys = Array.from(new Set(ys));\n\t\tif (this.keySignature) uys.push(`K${this.keySignature}`);\n\n\t\tconst voices = this.voices\n\t\t\t.map((ids) => ids.map((id) => this.events.find((e) => e.id === id)).filter((event) => !event.zeroHolder && !event.rest))\n\t\t\t.filter((voice) => voice.length);\n\n\t\tconst melodies = invalid ? [] : voices.map((es) => es.map((e) => e.scaleChord).join('-'));\n\n\t\tconst rhythm = invalid ? [] : voices.map((es) => es.map((e) => e.division).join(''));\n\t\tif (this.timeSignature) rhythm.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`);\n\n\t\treturn [uys, melodies, rhythm];\n\t}\n\n\tget barType(): MeasureBarType {\n\t\tif (this.voltaEnd) return 'VoltaRight';\n\n\t\tconst typeEntris = Object.entries(this.barTypes).sort((e1, e2) => e2[1] - e1[1]);\n\t\tif (typeEntris[0] && typeEntris[0][1] >= 1) return typeEntris[0][0] as MeasureBarType;\n\n\t\treturn null;\n\t}\n\n\tget partialDuration(): boolean {\n\t\tif (!Number.isFinite(this.duration)) return false;\n\n\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\treturn this.duration < signatureDuration;\n\t}\n\n\tpostRegulate(): void {\n\t\tthis.endEvent = new EventTerm({ tick: this.duration, x: this.position.right });\n\n\t\tthis.updateRoundX();\n\t\tsolveGraceEvents(this);\n\t\tsolveTremoloPairs(this);\n\t\tthis.updateContextTick();\n\t}\n\n\tupdateRoundX(): void {\n\t\tconst tickToX = this.tickToX;\n\t\tif (tickToX)\n\t\t\tthis.events.forEach((event) => {\n\t\t\t\tconst x = tickToX[event.tick];\n\t\t\t\tif (Number.isFinite(x)) event.roundX = x;\n\t\t\t});\n\t}\n\n\tupdateContextTick(): void {\n\t\tif (!this.staffGroups) return;\n\t\tconst contexts = this.contexts.flat(1);\n\t\tthis.staffGroups.flat(1).forEach((staffIndex) => {\n\t\t\tconst terms = [...this.events.filter((e) => e.staff === staffIndex), ...contexts.filter((c) => c.staff === staffIndex)];\n\t\t\tterms.sort((t1, t2) => t2.x - t1.x); // order by x from right to left\n\n\t\t\tlet tick = this.duration;\n\t\t\tterms.forEach((term) => {\n\t\t\t\tif (term instanceof EventTerm) {\n\t\t\t\t\tif (!term.fullMeasureRest && !term.zeroHolder) tick = term.tick;\n\t\t\t\t} else if (term instanceof ContextedTerm) term.tick = tick;\n\t\t\t});\n\t\t});\n\t}\n\n\tasSolution(ref: SpartitoMeasure = undefined): RegulationSolution {\n\t\tif (!this.regulated) return null;\n\n\t\t//let timeSignature = undefined;\n\t\t//if (ref && printFraction(ref.timeSignature) !== printFraction(this.timeSignature)) timeSignature = this.timeSignature;\n\n\t\treturn {\n\t\t\t//timeSignature,\n\t\t\tevents: this.events.map((e) => {\n\t\t\t\tconst se = {\n\t\t\t\t\tid: e.id,\n\t\t\t\t\ttick: e.tick,\n\t\t\t\t\ttickGroup: e.tickGroup,\n\t\t\t\t\ttimeWarp: e.timeWarp,\n\t\t\t\t} as RegulationSolutionEvent;\n\n\t\t\t\tif (ref) {\n\t\t\t\t\tconst refEvent = ref.events.find((re) => re.id === e.id);\n\t\t\t\t\tif (refEvent) {\n\t\t\t\t\t\tif (e.division !== refEvent.division) se.division = e.division;\n\t\t\t\t\t\tif (e.dots !== refEvent.dots) se.dots = e.dots;\n\t\t\t\t\t\tif (e.grace !== refEvent.grace) se.grace = !!e.grace;\n\t\t\t\t\t\tif (e.beam !== refEvent.beam) se.beam = e.beam;\n\t\t\t\t\t\tif (e.fullMeasureRest !== refEvent.fullMeasureRest) se.fullMeasure = e.fullMeasureRest;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn se;\n\t\t\t}),\n\t\t\tvoices: this.voices,\n\t\t\tduration: this.duration,\n\t\t\tpriority: -this.solutionStat?.loss,\n\t\t};\n\t}\n\n\tapplySolution(solution: RegulationSolution): void {\n\t\tif (solution.timeSignature) {\n\t\t\tthis.basics.forEach((basic) => {\n\t\t\t\tbasic.timeSignature = solution.timeSignature;\n\t\t\t\tbasic.doubtfulTimesig = false;\n\t\t\t});\n\t\t}\n\n\t\tthis.voices = solution.voices;\n\t\tthis.duration = solution.duration;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.timeWarp = null;\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\n\t\t\tconst se = solution.events?.find((e) => e.id === event.id);\n\t\t\tif (se) {\n\t\t\t\tevent.tick = se.tick;\n\t\t\t\tevent.timeWarp = se.timeWarp;\n\t\t\t\tevent.tickGroup = se.tickGroup;\n\n\t\t\t\tif (Number.isFinite(se.division)) event.division = se.division;\n\t\t\t\tif (Number.isFinite(se.dots)) event.dots = se.dots;\n\t\t\t\tif (se.beam) event.beam = se.beam as StemBeam;\n\t\t\t\tif (se.grace !== undefined) event.grace = se.grace ? GraceType.Grace : undefined;\n\t\t\t\tif (se.fullMeasure) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tif (Number.isFinite(solution.priority)) this.solutionStat = { loss: -solution.priority };\n\n\t\tthis.postRegulate();\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.voices = null;\n\t\tthis.duration = null;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\t\t\tevent.timeWarp = null;\n\t\t});\n\t}\n\n\tregulateTest(): void {\n\t\tthis.duration = 0;\n\t\tthis.voices = this.rows.map((row) => row.events.map((e) => e.id));\n\t\tthis.voices.forEach((ids) => {\n\t\t\tlet tick = 0;\n\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\t\t\tevents.forEach((e, index) => {\n\t\t\t\te.tickGroup = index;\n\t\t\t\te.tick = tick;\n\n\t\t\t\ttick += e.duration;\n\t\t\t});\n\n\t\t\tthis.duration = Math.max(this.duration, tick);\n\t\t});\n\t}\n\n\tregulateSimple(): void {\n\t\tSimplePolicy.computeMeasureTicks(this);\n\t\tSimplePolicy.computeMeasureVoices(this);\n\t}\n\n\tasync regulateEquations(options: EquationPolicy.RegulatorOptions): Promise {\n\t\tawait EquationPolicy.regulateMeasure(this, options);\n\t}\n\n\t// compute event.tick, event.tickGroup, event.timeWarp, voices, duration\n\tasync regulate({ policy = 'advanced', ...options }: RegulationOptions = {}): Promise {\n\t\tswitch (policy) {\n\t\t\tcase 'test':\n\t\t\t\tthis.regulateTest();\n\n\t\t\t\tbreak;\n\t\t\tcase 'equations':\n\t\t\tcase 'advanced':\n\t\t\t\tawait this.regulateEquations(options);\n\n\t\t\t\tbreak;\n\t\t\tcase 'simple':\n\t\t\tdefault:\n\t\t\t\tthis.regulateSimple();\n\t\t}\n\n\t\tthis.postRegulate();\n\t}\n\n\tcreatePatch(): PatchMeasure {\n\t\treturn new PatchMeasure({\n\t\t\tmeasureIndex: this.measureIndex,\n\t\t\tstaffMask: this.staffMask,\n\t\t\tbasic: this.basics[0],\n\t\t\t//points: [],\n\t\t\tevents: this.events,\n\t\t\tcontexts: this.contexts,\n\t\t\tmarks: this.marks,\n\t\t\tvoices: this.voices,\n\t\t});\n\t}\n\n\tcreateClusters(): EventCluster[] {\n\t\tconst trueEventIds = this.voices && new Set(this.voices.flat(1));\n\n\t\treturn this.staffGroups\n\t\t\t.filter((idx) => idx.length)\n\t\t\t.map((staffIndices) => {\n\t\t\t\tconst staffY0 = this.position.staffYs[0];\n\t\t\t\tconst staffYn = (n) => this.position.staffYs[staffIndices.indexOf(n)] - staffY0;\n\n\t\t\t\tconst events = this.events.filter((event) => staffIndices.includes(event.staff));\n\t\t\t\tif (!events.length) return null;\n\n\t\t\t\tconst elements: EventElement[] = events.map((event) => ({\n\t\t\t\t\tindex: event.id,\n\t\t\t\t\tvoice: (this.voices || []).findIndex((voice) => voice.includes(event.id)),\n\t\t\t\t\ttype: event.rest ? EventElementType.REST : EventElementType.CHORD,\n\t\t\t\t\tstaff: staffIndices.indexOf(event.staff),\n\t\t\t\t\tx: event.tipX,\n\t\t\t\t\tpivotX: event.pivotX,\n\t\t\t\t\ty1: staffYn(event.staff) + (event.stemDirection === 'u' ? event.tipY : event.ys[event.ys.length - 1]),\n\t\t\t\t\ty2: staffYn(event.staff) + (event.stemDirection === 'u' ? event.ys[0] : event.tipY),\n\t\t\t\t\theadY: event.stemDirection === 'u' ? event.ys[0] : event.ys[event.ys.length - 1],\n\t\t\t\t\tfeature: event.feature,\n\t\t\t\t\tdivision: event.division,\n\t\t\t\t\tdots: event.dots,\n\t\t\t\t\tbeam: event.beam || null,\n\t\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\t\tgrace: !!event.grace,\n\t\t\t\t\ttremoloCatcher: event.tremoloCatcher,\n\t\t\t\t\ttimeWarped: !!event.timeWarp,\n\t\t\t\t\tfullMeasure: event.fullMeasureRest,\n\t\t\t\t\ttick: event.tick || 0,\n\t\t\t\t\tfake: !event.fullMeasureRest && !event.grace && this.voices && !trueEventIds.has(event.id), // tremoloCatcher deemed as fake\n\t\t\t\t}));\n\t\t\t\tif (!elements.some((elem) => !elem.fake)) return null;\n\n\t\t\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\t\t\t// BOS & EOS\n\t\t\t\telements.unshift({\n\t\t\t\t\tindex: 0,\n\t\t\t\t\ttype: EventElementType.BOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.left,\n\t\t\t\t\tpivotX: this.position.left,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: this.duration < signatureDuration,\n\t\t\t\t\ttick: 0,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\t\t\t\telements.push({\n\t\t\t\t\tindex: -1,\n\t\t\t\t\ttype: EventElementType.EOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.right,\n\t\t\t\t\tpivotX: this.position.right,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: false,\n\t\t\t\t\ttick: this.duration,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\n\t\t\t\tlet matrixH = null;\n\t\t\t\tif (this.voices) {\n\t\t\t\t\tmatrixH = elements.map(() => elements.map(() => 0));\n\n\t\t\t\t\tthis.voices.forEach((voice) => {\n\t\t\t\t\t\tlet tar = 0;\n\t\t\t\t\t\tvoice.forEach((id) => {\n\t\t\t\t\t\t\tconst src = elements.findIndex((e) => e.index === id);\n\t\t\t\t\t\t\tif (src > 0 && tar >= 0) matrixH[src][tar] = 1;\n\t\t\t\t\t\t\ttar = src;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (tar >= 0) matrixH[elements.length - 1][tar] = 1;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst annotation = { ...this.solutionStat, patched: this.patched };\n\n\t\t\t\tconst backgroundImages =\n\t\t\t\t\tthis.backgroundImages &&\n\t\t\t\t\tthis.backgroundImages.map(({ url, position }) => ({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t...position,\n\t\t\t\t\t\t\ty: position.y - staffY0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\n\t\t\t\treturn new EventCluster({\n\t\t\t\t\tindex: this.measureIndex,\n\t\t\t\t\tduration: this.duration,\n\t\t\t\t\tsignatureDuration,\n\t\t\t\t\tstaffY0,\n\t\t\t\t\telements,\n\t\t\t\t\tmatrixH,\n\t\t\t\t\tannotation,\n\t\t\t\t\tbackgroundImages,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n\n\tapplyClusters(clusters: EventCluster[]): void {\n\t\tconst id_max = this.events.reduce((max, event) => Math.max(max, event.id), 0) + 1;\n\t\tthis.matrixH = Array(id_max + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(id_max).fill(0));\n\n\t\tclusters.forEach((cluster) => {\n\t\t\tconst ids = cluster.elements.map((e) => e.index);\n\t\t\tconsole.assert(cluster.matrixH.length === ids.length - 1, 'unexpected matrixH size:', cluster.matrixH.length, ids.length);\n\n\t\t\tfor (let is = 1; is < ids.length; ++is) {\n\t\t\t\tfor (let it = 0; it < ids.length - 1; ++it) {\n\t\t\t\t\tconst srcId = ids[is] < 0 ? id_max : ids[is];\n\t\t\t\t\tconst tarId = ids[it];\n\n\t\t\t\t\tthis.matrixH[srcId][tarId] = cluster.matrixH[is - 1][it];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// event predisposition\n\t\t\tcluster.elements.forEach((elem) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === elem.index);\n\t\t\t\tif (event) {\n\t\t\t\t\tevent.predisposition = elem.predisposition;\n\t\t\t\t\tif (event.predisposition.grace !== undefined) event.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// estimated measure duration\n\t\tthis.estimatedDuration = clusters.reduce((sum, cluster) => sum + cluster.estimatedDuration, 0) / clusters.length;\n\t}\n}\n\nexport { SpartitoMeasure, EquationPolicy };\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Hash, HashVector, cosHashes, hashToHex, hashToBigInt } from './hashVector';\nimport { EventTerm, ContextedTerm, TermPitch, TempoTerm, WHOLE_DURATION } from './term';\nimport { VoicesStaff, VoiceMeasure, TermMeasure, TermVoice, Performing, RegulationOptions } from './interfaces';\nimport { reducedFraction, argmax, noteToPitch, frac, printFraction, fractionMul } from './utils';\nimport { TokenType } from './token';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { Logger, DummyLogger } from './logger';\n\nexport const emptyVoiceFromStaffMeasure = (staff: TermMeasure, chiefVoice: boolean = false): VoiceMeasure => {\n\treturn {\n\t\tempty: true,\n\t\tduration: staff.duration,\n\t\ttickMap: {\n\t\t\t[0]: EventTerm.space({ duration: staff.duration, tick: 0 }),\n\t\t},\n\t\ttimeSignature: staff.timeSignature,\n\t\ttimeSigNumeric: staff.timeSigNumeric,\n\t\tkeySignature: staff.keySignature,\n\t\tcontextedTerms: staff.terms.filter((term) => term instanceof ContextedTerm && (!term.staffLevel || chiefVoice)) as ContextedTerm[],\n\t\tmarks: [],\n\t};\n};\n\nconst removeEmptyMeasuresInVoicesStaves = (staves: VoicesStaff[]): void => {\n\t//console.assert(staves[0] && staves[0].voices[0], 'voices is empty:', staves);\n\tif (!(staves[0] && staves[0].voices[0])) {\n\t\tconsole.warn('empty voices:', staves);\n\t\treturn;\n\t}\n\n\tconst measureCount = staves[0].voices[0].measures.length;\n\tconst measureEmpties = Array(measureCount)\n\t\t.fill(null)\n\t\t.map((_, m) => {\n\t\t\tfor (const staff of staves) {\n\t\t\t\tfor (const voice of staff.voices) {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tif (!measure.empty) return false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\tmeasureEmpties.forEach((empty, m) => {\n\t\tif (empty) {\n\t\t\tstaves.forEach((staff) =>\n\t\t\t\tstaff.voices.forEach((voice) => {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tmeasure.tickMap = {};\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t});\n};\n\nconst markingTiesInVoice = (voice: TermVoice) => {\n\tconst events = [].concat(...voice.measures.map((m) => Object.values(m.tickMap).filter((event) => event instanceof EventTerm)));\n\t//console.log(\"events:\", events);\n\n\tfor (let i = 1; i < events.length; ++i) {\n\t\tconst event0 = events[i - 1];\n\t\tconst event1 = events[i];\n\t\tif (!event0.rest && !event1.rest) {\n\t\t\tif (event0.accessories.some((acc) => acc.type === TokenType.SlurBegin) && event1.accessories.some((acc) => acc.type === TokenType.SlurEnd)) {\n\t\t\t\tconst pitches = event0.pitches.filter((p0) => event1.pitches.some((p1) => p1.note === p0.note && p1.alter === p0.alter));\n\t\t\t\tif (pitches.length > 0) {\n\t\t\t\t\tevent0.tying = true;\n\t\t\t\t\tevent1.tied = true;\n\n\t\t\t\t\tpitches.forEach((p0) => {\n\t\t\t\t\t\tp0.tying = true;\n\t\t\t\t\t\tconst p1 = event1.pitches.find((p1) => p1.note === p0.note && p1.alter === p0.alter);\n\t\t\t\t\t\tp1.tied = true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// remove slurs from accessories\n\t\t\t\t\tpitches.forEach(() => {\n\t\t\t\t\t\tconst si0 = event0.accessories.findIndex((acc) => acc.type === TokenType.SlurBegin);\n\t\t\t\t\t\tif (si0 >= 0) event0.accessories.splice(si0, 1);\n\n\t\t\t\t\t\tconst si1 = event1.accessories.findIndex((acc) => acc.type === TokenType.SlurEnd);\n\t\t\t\t\t\tif (si1 >= 0) event1.accessories.splice(si1, 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nclass Spartito extends SimpleClass {\n\tstatic className = 'Spartito';\n\n\tstavesCount: number;\n\tstaffGroups: number[][];\n\tmeasures: SpartitoMeasure[];\n\n\ttags: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.measures.forEach((measure) => (measure.staffGroups = this.staffGroups));\n\t}\n\n\tget regulated(): boolean {\n\t\treturn this.measures.every((m) => m.regulated);\n\t}\n\n\tget solidMeasureCount(): number {\n\t\treturn this.measures.filter((measure) => !measure.empty).length;\n\t}\n\n\tget measureIndexMapping(): number[] {\n\t\tlet n = 0;\n\t\treturn this.measures.map((measure) => {\n\t\t\treturn !measure.empty ? n++ : null;\n\t\t});\n\t}\n\n\tget headBPM(): number {\n\t\tfor (const measure of this.measures) {\n\t\t\tif (measure.marks) {\n\t\t\t\tconst tempoMark = measure.marks.find((mark) => mark instanceof TempoTerm && mark.isValid()) as TempoTerm;\n\t\t\t\tif (tempoMark) return tempoMark.bpm;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget measureLayoutCode(): string {\n\t\tconst ms = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure, i) => ({\n\t\t\t\tindex: i + 1,\n\t\t\t\tvb: measure.voltaBegin,\n\t\t\t\tve: measure.voltaEnd,\n\t\t\t\talter: measure.alternative,\n\t\t\t\tleftSign: '',\n\t\t\t\trightSign: '',\n\t\t\t}));\n\t\tms.forEach((m, i) => {\n\t\t\tif (m.vb) {\n\t\t\t\tconst nextI = ms.slice(i + 1).findIndex((mm) => mm.vb);\n\t\t\t\tconst nextVBI = nextI >= 0 ? i + nextI : ms.length;\n\t\t\t\tif (ms.slice(i, nextVBI - 1).some((mm) => mm.ve))\n\t\t\t\t\t// check if volta range closed\n\t\t\t\t\tm.leftSign = '2*[';\n\t\t\t}\n\n\t\t\tif (m.ve) {\n\t\t\t\tconst pms = ms.slice(0, i + 1).reverse();\n\t\t\t\tconst lastVEI = pms.slice(1).findIndex((mm) => mm.ve);\n\t\t\t\tif (lastVEI >= 0) {\n\t\t\t\t\tif (!pms.slice(1, lastVEI + 1).some((mm) => mm.vb))\n\t\t\t\t\t\t// ignore unclosed right volta\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.alter) {\n\t\t\t\t\tconst lastMI = pms.findIndex((m) => !m.alter);\n\t\t\t\t\tif (lastMI > 0) {\n\t\t\t\t\t\tpms[lastMI].rightSign = ']';\n\t\t\t\t\t\tpms[lastMI - 1].leftSign = '{[';\n\n\t\t\t\t\t\tm.rightSign = '],';\n\n\t\t\t\t\t\tif (ms[i + 1]) ms[i + 1].rightSign = '},';\n\t\t\t\t\t}\n\t\t\t\t} else m.rightSign = '],';\n\n\t\t\t\tif (!pms.some((m) => m.vb)) ms[0].leftSign = '2*[';\n\t\t\t}\n\t\t});\n\n\t\treturn ms\n\t\t\t.map((m) => m.leftSign + m.index.toString() + m.rightSign + (m.rightSign ? '' : ','))\n\t\t\t.join(' ')\n\t\t\t.replace(/,$/, '');\n\t}\n\n\tget qualityScore(): number {\n\t\tconst measures = this.measures.filter((measure) => !measure.empty);\n\t\tconst qss = measures.map(evaluateMeasure).map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\t//console.log('qss:', qss);\n\n\t\treturn measures.length ? sum / measures.length : null;\n\t}\n\n\tdumpEvaluations(): void {\n\t\tconst es = this.measures.filter((measure) => !measure.empty).map((m) => ({ measureIndex: m.measureIndex, ...evaluateMeasure(m) }));\n\t\tconst qss = es.map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\tconsole.log('qualityScore:', sum / es.length);\n\n\t\tconsole.table(es);\n\t}\n\n\tregulate(options: RegulationOptions = {}): void {\n\t\tthis.measures.forEach((m) => m.regulated || m.regulate(options));\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.measures.forEach((m) => (m.voices = null));\n\t}\n\n\t// measures' estimatedDuration should be valid\n\trectifyTimeSignatures(logger: Logger = new DummyLogger()): void {\n\t\tconst mis = this.measures\n\t\t\t.map((measure, index) => ({ measure, index }))\n\t\t\t.filter(({ measure, index }) => !index || measure.timeSignatureChanged)\n\t\t\t.map(({ index }) => index);\n\t\tconst segments = mis\n\t\t\t.map((index, si) => this.measures.slice(index, si < mis.length - 1 ? mis[si + 1] : this.measures.length))\n\t\t\t.map((ms) => ms.filter((m) => m.estimatedDuration > 0))\n\t\t\t.filter((seg) => seg.length >= 3 || seg.some((measure) => measure.doubtfulTimesig));\n\t\t//console.log(\"segments:\", segments.map(ms => ms.map(m => m.measureIndex)));\n\n\t\tsegments.forEach((measures) => {\n\t\t\tif (measures[0].patched) {\n\t\t\t\t// rectify according to patched head measure\n\t\t\t\tconst newTimeSignature = measures[0].timeSignature;\n\t\t\t\tconst measuresToFix = measures\n\t\t\t\t\t.slice(1)\n\t\t\t\t\t.filter((measure) => !measure.patched && printFraction(measure.timeSignature) !== printFraction(newTimeSignature));\n\t\t\t\tif (measuresToFix.length) {\n\t\t\t\t\tconst originTimeSignature = measuresToFix[0].timeSignature;\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by patched head:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${printFraction(newTimeSignature)}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst originTimeSignature = measures[0].timeSignature;\n\t\t\tconst regularD = Number.isInteger(Math.log2(originTimeSignature.denominator));\n\n\t\t\tlet denominator = regularD ? 4 : 8;\n\t\t\tif (regularD) denominator = Math.max(denominator, measures[0].timeSignature.denominator);\n\n\t\t\tconst numerators = measures.map((measure) => Math.round((measure.estimatedDuration * denominator) / WHOLE_DURATION));\n\t\t\tconst countings = Object.entries(numerators.reduce((c, n) => ((c[n] = (c[n] || 0) + 1), c), {} as Record)).sort(\n\t\t\t\t(p1, p2) => p2[1] - p1[1]\n\t\t\t);\n\t\t\tconst peakCount = countings[0][1];\n\t\t\tconst candidateNumerators = countings.filter(([_, c]) => c > peakCount * 0.6);\n\t\t\tconst bestCounting = candidateNumerators.reduce((best, c) => (Number(c[0]) > Number(best[0]) ? c : best));\n\t\t\tif (bestCounting[1] > 1) {\n\t\t\t\t//console.log(\"countings:\", countings, bestCounting[0]);\n\t\t\t\tlet numerator = Number(bestCounting[0]);\n\t\t\t\tif (!regularD || originTimeSignature.denominator * numerator !== originTimeSignature.numerator * denominator) {\n\t\t\t\t\tif (regularD && denominator !== originTimeSignature.denominator) {\n\t\t\t\t\t\tconst reducedN = (numerator * originTimeSignature.denominator) / denominator;\n\t\t\t\t\t\tif (Number.isInteger(reducedN)) {\n\t\t\t\t\t\t\tnumerator = reducedN;\n\t\t\t\t\t\t\tdenominator = originTimeSignature.denominator;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst measuresToFix = measures.filter((measure) => !measure.patched);\n\n\t\t\t\t\tconst newTimeSignature = frac(numerator, denominator);\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by estimation:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${numerator}/${denominator}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tmakeVoiceStaves(): VoicesStaff[] {\n\t\tthis.regulate();\n\n\t\tconst voiceCount = Math.max(...this.measures.map((measure) => measure.voices.length));\n\t\tif (!voiceCount || !Number.isFinite(voiceCount)) return null;\n\n\t\t// mark tied pitches for patched measues\n\t\tthis.measures\n\t\t\t.filter((measure) => measure.patched)\n\t\t\t.forEach((measure) => {\n\t\t\t\tmeasure.events.forEach((event) => {\n\t\t\t\t\tif (event.tied) event.pitches.forEach((pitch) => (pitch.tied = true));\n\t\t\t\t});\n\t\t\t});\n\n\t\t// [measure, voice]\n\t\tconst measures: VoiceMeasure[][] = this.measures.map((measure /*, mi*/) => {\n\t\t\tconsole.assert(measure.validRegulated, '[makeVoiceStaves] measure is invalid:', measure);\n\n\t\t\tconst eventMap: { [key: number]: EventTerm } = {};\n\t\t\tmeasure.events.forEach((event) => (eventMap[event.id] = event));\n\n\t\t\tconst leftStaves = new Set(\n\t\t\t\tArray(measure.contexts.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, i) => i)\n\t\t\t);\n\n\t\t\tlet bar = null;\n\t\t\tif (measure.barType) {\n\t\t\t\tswitch (measure.barType) {\n\t\t\t\t\tcase 'Segment':\n\t\t\t\t\t\tbar = '||';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Terminal':\n\t\t\t\t\t\tbar = '|.';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst voices: VoiceMeasure[] = measure.voices.map((ids /*, vi*/) => {\n\t\t\t\tconst events = ids.map((id) => eventMap[id]);\n\t\t\t\tevents.sort((e1, e2) => e1.tick - e2.tick);\n\n\t\t\t\tconst tickMap = {};\n\t\t\t\tlet tick = 0;\n\t\t\t\tlet lastEvent = null;\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (!Number.isFinite(event?.tick)) {\n\t\t\t\t\t\tconsole.warn('invalid event tick:', event);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (event.tick > tick) tickMap[tick] = EventTerm.space({ tick, duration: event.tick - tick });\n\t\t\t\t\telse if (!event.grace && event.tick < tick && lastEvent)\n\t\t\t\t\t\tlastEvent.timeWarp = reducedFraction(event.tick - lastEvent.tick, lastEvent.duration);\n\t\t\t\t\t//console.log(\"timewarp:\", event.tick - lastEvent.tick, lastEvent.duration, lastEvent.timeWarp);\n\n\t\t\t\t\ttickMap[event.tick] = event;\n\n\t\t\t\t\tif (!event.zeroHolder) {\n\t\t\t\t\t\ttick = Math.round(event.tick + event.duration);\n\t\t\t\t\t\tlastEvent = event;\n\n\t\t\t\t\t\t// sub grace events\n\t\t\t\t\t\tif (event.graceIds) {\n\t\t\t\t\t\t\tevent.graceIds.forEach((id) => {\n\t\t\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\t\t\tif (grace) tickMap[grace.tick] = grace;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (measure.endEvent && measure.endEvent.graceIds) {\n\t\t\t\t\tmeasure.endEvent.graceIds.forEach((id) => {\n\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\tif (grace && (!lastEvent || grace.staff === lastEvent.staff)) tickMap[grace.tick] = grace;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (tick < measure.duration) tickMap[tick] = EventTerm.space({ tick, duration: measure.duration - tick });\n\t\t\t\telse if (tick > measure.duration && Number.isFinite(measure.duration))\n\t\t\t\t\t//console.warn(\"duration out of range:\", tick, column.duration, mi, vi);\n\t\t\t\t\tlastEvent.timeWarp = reducedFraction(measure.duration - lastEvent.tick, lastEvent.duration);\n\n\t\t\t\tconsole.assert(\n\t\t\t\t\t!lastEvent || !lastEvent.timeWarp || (Number.isInteger(lastEvent.timeWarp.numerator) && Number.isInteger(lastEvent.timeWarp.denominator)),\n\t\t\t\t\t'invalid time warp:',\n\t\t\t\t\tlastEvent\n\t\t\t\t);\n\n\t\t\t\tconst staffIndex = events[0] ? events[0].staff : 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\n\t\t\t\t//const row = measure.rows[staffIndex];\n\t\t\t\tconst contextedTerms = measure.contexts[staffIndex];\n\n\t\t\t\tconst tailEvent = events[events.length - 1];\n\t\t\t\tconst tailStaff = tailEvent ? tailEvent.staff : 0;\n\n\t\t\t\t// TODO: modify full measure rests duration\n\n\t\t\t\treturn {\n\t\t\t\t\ttickMap,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t...basic,\n\t\t\t\t\t// TODO: consider staff altered voice\n\t\t\t\t\tcontextedTerms,\n\t\t\t\t\tmarks: [],\n\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\theadStaff: staffIndex,\n\t\t\t\t\ttailStaff,\n\t\t\t\t\tbar,\n\t\t\t\t};\n\t\t\t});\n\n\t\t\twhile (voices.length < voiceCount) {\n\t\t\t\tconst staffIndex = leftStaves.values().next().value || 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\t\t\t\tconst terms = measure.contexts[staffIndex];\n\n\t\t\t\tconst chiefVoice = voices.every((voice) => voice.headStaff !== staffIndex);\n\n\t\t\t\tconst voice = emptyVoiceFromStaffMeasure(\n\t\t\t\t\t{\n\t\t\t\t\t\tterms,\n\t\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t\t...basic,\n\t\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\t},\n\t\t\t\t\tchiefVoice\n\t\t\t\t);\n\t\t\t\tvoice.headStaff = staffIndex;\n\t\t\t\tvoice.tailStaff = staffIndex;\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\n\t\t\treturn voices;\n\t\t});\n\t\t//console.log(\"measures:\", measures);\n\n\t\t// compute traits for voice-measures\n\t\tmeasures.forEach((voices) =>\n\t\t\tvoices.forEach((measure) => {\n\t\t\t\tconst words = [];\n\n\t\t\t\tif (!measure.empty) {\n\t\t\t\t\twords.push(`s${measure.headStaff}`);\n\t\t\t\t\twords.push(`s${measure.tailStaff}`);\n\t\t\t\t}\n\n\t\t\t\tObject.values(measure.tickMap).forEach((event) => {\n\t\t\t\t\tif (event instanceof EventTerm) {\n\t\t\t\t\t\twords.push(`s${event.staff}`);\n\n\t\t\t\t\t\tif (event.stemDirection) {\n\t\t\t\t\t\t\tconst sd = `st${event.staff}-${event.stemDirection}`;\n\t\t\t\t\t\t\twords.push(sd, sd);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.grace) words.push(`gd${event.mainDuration}`);\n\t\t\t\t\t\telse words.push(`d${event.mainDuration}`);\n\n\t\t\t\t\t\tif (event.rest) words.push('r-' + event.rest);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tevent.pitches.forEach((pitch) => {\n\t\t\t\t\t\t\t\twords.push(`p1-${pitch.note}`);\n\t\t\t\t\t\t\t\twords.push(`p8-${Math.round(pitch.note / 8)}`);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmeasure.trait = HashVector.fromWords(words);\n\t\t\t})\n\t\t);\n\t\t//console.log(\"measure traits:\");\n\t\t//console.table(measures.map(voices => voices.map(measure => hashToHex(measure.trait.toHash()))));\n\n\t\tconst staffToGroup: Record = this.staffGroups\n\t\t\t.flat(1)\n\t\t\t.reduce((map, si) => ((map[si] = this.staffGroups.findIndex((group) => group.includes(si))), map), {});\n\n\t\t// sort voices to connect voices between neighhoring measures\n\t\tconst voiceTraits = Array(voiceCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => ({ vector: HashVector.zero, index, weight: 0, headStaff: null }));\n\t\tmeasures.forEach((voices, mi) => {\n\t\t\tvoiceTraits.sort((v1, v2) => v2.weight - v1.weight);\n\n\t\t\tconst leftVoices = new Set(voices);\n\t\t\tvoiceTraits.forEach((voiceTrait) => {\n\t\t\t\tconst vs = [...leftVoices];\n\t\t\t\tlet measure = vs[0];\n\t\t\t\tif (mi > 0 && vs.length > 1) {\n\t\t\t\t\tconst consistencies = vs.map((measure) =>\n\t\t\t\t\t\tstaffToGroup[measure.headStaff] === staffToGroup[voiceTrait.headStaff]\n\t\t\t\t\t\t\t? cosHashes(voiceTrait.vector.toHash(), measure.trait.toHash())\n\t\t\t\t\t\t\t: -1\n\t\t\t\t\t);\n\t\t\t\t\tmeasure = vs[argmax(consistencies)];\n\t\t\t\t}\n\t\t\t\tleftVoices.delete(measure);\n\n\t\t\t\tmeasure.voiceIndex = voiceTrait.index;\n\t\t\t\tvoiceTrait.vector.scale(0.4).add(measure.trait);\n\n\t\t\t\tvoiceTrait.weight = Object.keys(measure.tickMap).length;\n\n\t\t\t\tif (mi === 0) voiceTrait.headStaff = measure.headStaff;\n\t\t\t});\n\n\t\t\tvoices.sort((m1, m2) => m1.voiceIndex - m2.voiceIndex);\n\t\t});\n\n\t\t//const staffTraits = Array(this.stavesCount).fill(null).map((_, si) => HashVector.fromString(`s${si}`).toHash());\n\t\tconst staffVoiceIndices = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map(() => []);\n\t\tvoiceTraits.forEach((trait) => {\n\t\t\t//const consistencies = staffTraits.map(staff => cosHashes(trait.vector.toHash(), staff));\n\t\t\t//staffVoiceIndices[argmax(consistencies)].push(trait.index);\n\t\t\tstaffVoiceIndices[trait.headStaff].push(trait.index);\n\t\t});\n\n\t\tconst staves = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, si) => {\n\t\t\t\tif (!measures[0]) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvoices: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t//const voiceIndicies = measures[0].map((voice, vi) => ({ voice, vi })).filter(({ voice }) => voice.headStaff === si).map(({ vi }) => vi);\n\t\t\t\tconst voiceIndicies = staffVoiceIndices[si];\n\n\t\t\t\tconst voices = voiceIndicies.map((vi): TermVoice => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmode: 'relative',\n\t\t\t\t\t\tmeasures: measures.map((m) => m[vi]),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\treturn { voices };\n\t\t\t});\n\n\t\tremoveEmptyMeasuresInVoicesStaves(staves);\n\t\tstaves.forEach((staff) => staff.voices.forEach(markingTiesInVoice));\n\n\t\treturn staves;\n\t}\n\n\tperform(): Performing {\n\t\tconst staves = this.makeVoiceStaves();\n\t\tif (!staves) return null;\n\n\t\tconst tokenMap = new Map();\n\n\t\t// TODO: store staff channels in score\n\t\tconst staffToChannel = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.reduce((map, _, i) => {\n\t\t\t\tmap[i] = i;\n\t\t\t\treturn map;\n\t\t\t}, {});\n\n\t\tconst voiceChannels = [].concat(...staves.map((staff, si) => staff.voices.map(() => staffToChannel[si])));\n\n\t\tlet hasTempo = false;\n\n\t\tlet nextTick = 0;\n\t\tlet events0 = null;\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure) => {\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst voices: VoiceMeasure[] = [].concat(...staves.map((staff) => staff.voices.map((voice) => voice.measures[measureIndex])));\n\t\t\t\tconst voice0 = voices[0];\n\t\t\t\tconst tick = nextTick;\n\n\t\t\t\t//const signatureDuration = (WHOLE_DURATION * voice0.timeSignature.numerator) / voice0.timeSignature.denominator;\n\n\t\t\t\tnextTick += voice0.duration;\n\n\t\t\t\tconst notes = [].concat(\n\t\t\t\t\t...voices.map((measure, vi) => {\n\t\t\t\t\t\tconst tickFactor = 1; //measure.duration ? signatureDuration / measure.duration : 1;\n\n\t\t\t\t\t\tconst channel = voiceChannels[vi];\n\n\t\t\t\t\t\tconst chords = Object.values(measure.tickMap)\n\t\t\t\t\t\t\t.filter((term) => term instanceof EventTerm && !term.rest)\n\t\t\t\t\t\t\t.map((term: EventTerm) => {\n\t\t\t\t\t\t\t\tconst duration = Math.round(term.duration * tickFactor);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(term.tick), 'invalid event term tick:', term);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(duration), 'invalid event term duration:', term);\n\n\t\t\t\t\t\t\t\tif (term.tick >= 0) {\n\t\t\t\t\t\t\t\t\t// exclude minus tick tokens\n\t\t\t\t\t\t\t\t\tterm.noteIds.forEach((id) => {\n\t\t\t\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: term.roundX,\n\t\t\t\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(term.staff));\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttick: Math.round(term.tick * tickFactor),\n\t\t\t\t\t\t\t\t\tduration,\n\t\t\t\t\t\t\t\t\tpitches: term.pitches,\n\t\t\t\t\t\t\t\t\tnoteIds: term.noteIds,\n\t\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\t\tstaff: term.staff,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t\t...chords.map((chord) => {\n\t\t\t\t\t\t\t\t// exclude repeated pitches\n\t\t\t\t\t\t\t\tconst pitchMap: { [pitch: number]: TermPitch } = chord.pitches.reduce((map, pitch) => {\n\t\t\t\t\t\t\t\t\tmap[noteToPitch(pitch)] = pitch;\n\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t}, {});\n\t\t\t\t\t\t\t\tconst pitches = Object.values(pitchMap).sort((p1, p2) => p1.note - p2.note);\n\n\t\t\t\t\t\t\t\treturn pitches\n\t\t\t\t\t\t\t\t\t.filter((pitch) => !pitch.tied)\n\t\t\t\t\t\t\t\t\t.map((pitch, i) => {\n\t\t\t\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\ttick: chord.tick,\n\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\t\t\t\ttrack: chord.part,\n\t\t\t\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\t\t\t\tchannel,\n\t\t\t\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst events = [];\n\t\t\t\tevents0 = events0 || events;\n\n\t\t\t\tif (measure.marks)\n\t\t\t\t\tmeasure.marks.forEach((mark) => {\n\t\t\t\t\t\tif (mark instanceof TempoTerm) {\n\t\t\t\t\t\t\tconst bpm = mark.bpm;\n\t\t\t\t\t\t\tif (mark.isValid()) {\n\t\t\t\t\t\t\t\tconst es = hasTempo ? events : events0; // set the first tempo to the beginning of the track\n\t\t\t\t\t\t\t\tconst tick = hasTempo ? mark.tick : 0;\n\t\t\t\t\t\t\t\tes.push({\n\t\t\t\t\t\t\t\t\ttrack: 0,\n\t\t\t\t\t\t\t\t\tticks: tick,\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\t\t\t\t\t\tmicrosecondsPerBeat: Math.round(60e6 / bpm),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\thasTempo = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents,\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tif (!hasTempo) {\n\t\t\tmeasures[0].events.push({\n\t\t\t\ttrack: 0,\n\t\t\t\tticks: 0,\n\t\t\t\tdata: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\tmicrosecondsPerBeat: 0.5e6, // TODO\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tperformByEstimation(): Performing {\n\t\tconst tokenMap = new Map();\n\t\tlet nextTick = 0;\n\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => measure.events.some((event) => event.predisposition))\n\t\t\t.map((measure) => {\n\t\t\t\tconst tick = nextTick;\n\t\t\t\tconst duration = Math.round(measure.estimatedDuration || fractionMul(WHOLE_DURATION, measure.timeSignature));\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\tnextTick += duration;\n\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst chords = measure.events.filter((event) => event.predisposition && event.predisposition.fake < 0.5 && !event.rest);\n\t\t\t\tconst notes = chords\n\t\t\t\t\t.map((chord) => {\n\t\t\t\t\t\tconst noteTick = Math.round(chord.predisposition.tick);\n\n\t\t\t\t\t\tchord.noteIds.forEach((id) => {\n\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\tx: chord.roundX,\n\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn chord.pitches.map((pitch, i) => {\n\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(chord.staff));\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttick: noteTick,\n\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\ttrack: part,\n\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\tchannel: 0,\n\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.flat(1);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents: [],\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tfeatureHash(): Hash {\n\t\tconst headMeasures = this.measures.slice(0, 16);\n\t\tconst measureWords = headMeasures.map((measure) => measure.featureWords);\n\n\t\tconst levels = [1, 4, 16].map((len) => {\n\t\t\tconst meaures = measureWords.slice(0, len).filter(Boolean);\n\t\t\tconst ys = meaures.map((words) => words[0]).flat(1);\n\t\t\tconst melodies = meaures.map((words) => words[1]).flat(1);\n\t\t\tconst rhythm = meaures.map((words) => words[2]).flat(1);\n\n\t\t\tconst [vecY, vecMelody, vecRhythm] = [ys, melodies, rhythm].map(HashVector.fromWords);\n\n\t\t\treturn HashVector.concat(vecY, vecMelody.sub(128), vecRhythm.sub(128));\n\t\t});\n\n\t\treturn HashVector.concat(...levels).toHash();\n\t}\n\n\tfeatureHashHex(): string {\n\t\treturn hashToHex(this.featureHash());\n\t}\n\n\tfeatureHashBigInt(): bigint {\n\t\treturn hashToBigInt(this.featureHash());\n\t}\n\n\tassignMeasureNumbers(): void {\n\t\tlet n = null as any;\n\t\tfor (const measure of this.measures) {\n\t\t\tif (!measure.discard && !measure.events.length) continue;\n\n\t\t\tif (measure.indent) n = null;\n\n\t\t\tif (!Number.isFinite(n)) n = measure.partialDuration ? 0 : 1;\n\n\t\t\tmeasure.measureNumber = n++;\n\t\t}\n\t}\n}\n\nexport { SpartitoMeasure, Spartito };\n","import { Fraction } from './interfaces';\nimport { ContextedTerm, ContextType } from './term';\nimport { Logger, DummyLogger } from './logger';\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nexport const mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst PHONETS = 'CDEFGAB';\n\nconst ALTER_NAMES = {\n\t[-2]: '\\u266D\\u266D',\n\t[-1]: '\\u266D',\n\t[0]: '\\u266E',\n\t[1]: '\\u266F',\n\t[2]: '\\uD834\\uDD2A',\n};\n\n/*\n\tCoordinates:\n\n\t\tnote:\n\t\t\tzero: the middle C line (maybe altered)\n\t\t\tpositive: high (right on piano keyboard)\n\t\t\tunit: a step in scales of the current staff key\n\n\t\tstaff Y:\n\t\t\tzero: the third (middle) line among 5 staff lines\n\t\t\tpositive: down\n\t\t\tunit: a interval between 2 neighbor staff lines\n*/\n\nexport default class StaffContext {\n\tlogger: Logger = new DummyLogger();\n\n\tclef: number = -3;\n\tkeyAlters: number[] = [];\n\toctaveShift: number = 0;\n\talters: number[] = [];\n\n\ttimeSignature: Fraction = {\n\t\tnumerator: 4,\n\t\tdenominator: 4,\n\t};\n\ttimeSigNumeric: boolean = false;\n\ttimeSigNumSet: boolean = false;\n\ttimeSigDenSet: boolean = false;\n\tdoubtingTimesig: boolean = true;\n\n\tchange(term: ContextedTerm) {\n\t\tswitch (term.type) {\n\t\t\tcase ContextType.Clef:\n\t\t\t\tthis.clef = term.clef;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.KeyAcc:\n\t\t\t\tthis.keyAlters[mod7(this.yToNote(term.y))] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.Acc:\n\t\t\t\tthis.alters[this.yToNote(term.y)] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.OctaveShift:\n\t\t\t\tthis.octaveShift = term.octaveShift;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureC:\n\t\t\t\tthis.timeSigNumeric = false;\n\t\t\t\tswitch (term.tokenType) {\n\t\t\t\t\tcase 'timesig-C44':\n\t\t\t\t\t\tthis.timeSignature.numerator = 4;\n\t\t\t\t\t\tthis.timeSignature.denominator = 4;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'timesig-C22':\n\t\t\t\t\t\tthis.timeSignature.numerator = 2;\n\t\t\t\t\t\tthis.timeSignature.denominator = 2;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureN:\n\t\t\t\tthis.timeSigNumeric = true;\n\t\t\t\tswitch (term.y) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tif (this.timeSigDenSet) this.timeSignature.denominator = this.timeSignature.denominator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.denominator = term.number;\n\n\t\t\t\t\t\tthis.timeSigDenSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase -1:\n\t\t\t\t\t\tif (this.timeSigNumSet) this.timeSignature.numerator = this.timeSignature.numerator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.numerator = term.number;\n\n\t\t\t\t\t\tthis.timeSigNumSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.logger.warn('unexpected time signature Y:', term.y);\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tresetMeasure() {\n\t\tthis.alters = [];\n\n\t\tthis.timeSigNumSet = false;\n\t\tthis.timeSigDenSet = false;\n\t}\n\n\tresetSystem() {\n\t\tthis.keyAlters = [];\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.keyAlters.filter((a) => Number.isInteger(a)).reduce((sum, a) => sum + a, 0);\n\t}\n\n\tget partialTimeSignature(): boolean {\n\t\treturn !this.timeSigNumSet !== !this.timeSigDenSet;\n\t}\n\n\tnoteToY(note: number): number {\n\t\treturn -note / 2 - this.clef - this.octaveShift * 3.5;\n\t}\n\n\tpitchToNote(pitch: number, { preferredAlter = null } = {}): { note: number; alter: number } {\n\t\tif (!preferredAlter) preferredAlter = this.keySignature < 0 ? -1 : 1;\n\n\t\tconst group = Math.floor((pitch - MIDDLE_C) / 12);\n\t\tconst gp = mod12(pitch);\n\t\tconst alteredGp = GROUP_N_TO_PITCH.includes(gp) ? gp : mod12(gp - preferredAlter);\n\t\tconst gn = GROUP_N_TO_PITCH.indexOf(alteredGp);\n\t\tthis.logger.assert(gn >= 0, 'invalid preferredAlter:', pitch, preferredAlter, alteredGp);\n\n\t\tconst naturalNote = group * 7 + gn;\n\n\t\tconst alterValue = gp - alteredGp;\n\t\tconst keyAlterValue = this.keyAlters[gn] || 0;\n\t\tconst onAcc = Number.isInteger(this.alters[naturalNote]);\n\n\t\tconst alter = onAcc ? alterValue : alterValue === keyAlterValue ? null : alterValue;\n\n\t\treturn { note: naturalNote, alter };\n\t}\n\n\tpitchToY(pitch: number, { preferredAlter = null } = {}): { y: number; alter: number } {\n\t\tconst { note, alter } = this.pitchToNote(pitch, { preferredAlter });\n\t\tconst y = this.noteToY(note);\n\n\t\treturn { y, alter };\n\t}\n\n\tyToNote(y: number): number {\n\t\tthis.logger.assert(Number.isInteger(y * 2), 'invalid y:', y);\n\n\t\treturn (-y - this.octaveShift * 3.5 - this.clef) * 2;\n\t}\n\n\talterOnNote(note: number): number {\n\t\tif (Number.isInteger(this.alters[note])) return this.alters[note];\n\n\t\tconst gn = mod7(note);\n\t\tif (Number.isInteger(this.keyAlters[gn])) return this.keyAlters[gn];\n\n\t\treturn 0;\n\t}\n\n\tnoteToPitch(note: number): number {\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tconst pitch = MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + this.alterOnNote(note);\n\t\tif (!Number.isFinite(pitch)) {\n\t\t\tthis.logger.warn('invalid pitch value:', pitch, note, group, gn);\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn pitch;\n\t}\n\n\tyToPitch(y: number): number {\n\t\treturn this.noteToPitch(this.yToNote(y));\n\t}\n\n\tyToPitchName(y: number): string {\n\t\tconst note = this.yToNote(y);\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tlet alter = this.alterOnNote(note);\n\t\tif (!alter && !Number.isInteger(this.alters[note])) alter = null;\n\n\t\treturn `${ALTER_NAMES[alter] ? ALTER_NAMES[alter] : ''}${PHONETS[gn]}${group + 4}`;\n\t}\n}\n","import sha1 from 'js-sha1';\n\nimport * as measureLayout from '../measureLayout';\nimport * as staffLayout from '../staffLayout';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventSystem, MeasureBrief, MusicSheet, RecognitionSettings, ScoreData, TermMeasure, TermStaff, VoicesStaff } from './interfaces';\nimport { DummyLogger, Logger } from './logger';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { PatchMeasure } from './patch';\nimport { Measure, Page, Staff, System } from './scoreComponents';\nimport { hashSemanticPoint, SemanticPoint, SemanticType } from './semanticPoint';\nimport { BOS_ELEMENT, fractionToElems, SemanticCluster, SemanticElement, SemanticElementType } from './semanticTopology';\nimport { Spartito, SpartitoMeasure } from './spartito';\nimport StaffContext from './staffContext';\nimport { ContextedTerm, ContextType, EventTerm, WHOLE_DURATION } from './term';\nimport type { SemanticPointInMeasure } from './timewiseGraph';\nimport { TimewiseGraph } from './timewiseGraph';\nimport { Token, TokenType } from './token';\nimport { distance2D, solveOverlapping } from './utils';\n\nexport const VERSION = 14;\n\ninterface Topology {\n\tclusters: SemanticCluster[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n}\n\nconst GRAND_STAFF_LAYOUT = '{-}';\n\nconst processStaffContext = (staff: TermStaff, logger: Logger = new DummyLogger()): void => {\n\tconst context = new StaffContext();\n\tcontext.logger = logger;\n\n\tfor (const row of staff.rows) {\n\t\tfor (const measure of row) {\n\t\t\tconst startEvent = measure.terms.find((term) => term instanceof EventTerm) as EventTerm;\n\t\t\tlet tick = startEvent ? Math.min(startEvent.tick, 0) : 0;\n\n\t\t\tmeasure.terms.forEach((term) => {\n\t\t\t\tif (term instanceof ContextedTerm) {\n\t\t\t\t\tterm.tick = tick; // TODO: not working here because measure not regulated yet\n\t\t\t\t\tcontext.change(term);\n\t\t\t\t} else if (term instanceof EventTerm) {\n\t\t\t\t\tconst endTick = term.tick + (term.duration || 0);\n\t\t\t\t\tif (endTick > tick) tick = endTick;\n\n\t\t\t\t\tif (term.ys) {\n\t\t\t\t\t\tterm.pitches = term.ys.map((y) => {\n\t\t\t\t\t\t\tconst note = context.yToNote(y);\n\t\t\t\t\t\t\tconst alter = context.alterOnNote(note);\n\n\t\t\t\t\t\t\treturn { note, alter, octaveShift: context.octaveShift };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tmeasure.timeSignature = { ...context.timeSignature };\n\t\t\tmeasure.timeSigNumeric = context.timeSigNumeric;\n\t\t\tmeasure.doubtfulTimesig =\n\t\t\t\tcontext.doubtingTimesig ||\n\t\t\t\t!Number.isInteger(Math.log2(measure.timeSignature.denominator)) ||\n\t\t\t\tmeasure.timeSignature.numerator <= measure.timeSignature.denominator / 4;\n\n\t\t\tmeasure.keySignature = context.keySignature;\n\n\t\t\t// fill empty measure duration\n\t\t\tif (measure.duration === 0) measure.duration = (WHOLE_DURATION * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\n\t\t\tcontext.resetMeasure();\n\t\t}\n\n\t\tcontext.resetSystem();\n\t}\n};\n\nconst upgradeScoreData = (data: ScoreData): ScoreData => {\n\tif (data.version < 3) {\n\t\tconst { version, stavesCount, layoutTemplate, ...fields } = data;\n\t\tvoid version;\n\t\tvoid layoutTemplate;\n\n\t\tlet staffLayoutCode =\n\t\t\tstavesCount > 1\n\t\t\t\t? Array(stavesCount - 1)\n\t\t\t\t\t\t.fill(',')\n\t\t\t\t\t\t.join('')\n\t\t\t\t: '';\n\n\t\t// use graph staff by default for 2 staves score\n\t\tif (stavesCount === 2) staffLayoutCode = '{-}';\n\n\t\tdata = {\n\t\t\tversion: 3,\n\t\t\tstaffLayoutCode,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tif (data.version < 8) {\n\t\t// upgrade system measure bar semantics\n\t\tdata.pages.forEach((page) => {\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tif (system.semantics) {\n\t\t\t\t\tconst bars = system.semantics.filter((point) => point.semantic === SemanticType.vline_BarMeasure);\n\n\t\t\t\t\tsystem.semantics = [].concat(\n\t\t\t\t\t\t...system.staves.map((staff) => {\n\t\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\n\t\t\t\t\t\t\treturn bars.map((point) => ({\n\t\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\t\ty: point.y + oy,\n\t\t\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\t\t\t...point.extension,\n\t\t\t\t\t\t\t\t\ty1: point.extension.y1 + oy,\n\t\t\t\t\t\t\t\t\ty2: point.extension.y2 + oy,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tdata.version = 8;\n\t}\n\n\tif (data.version < 9) {\n\t\t// remove old format spartito\n\t\tdata.spartito = null;\n\n\t\tdata.version = 9;\n\t}\n\n\treturn data;\n};\n\nconst bitsToMask = (bits: number[]): number => bits.reduce((mask, bit, i) => (bit ? mask | (1 << i) : mask), 0);\n\ninterface PointPosition {\n\tpoint: SemanticPoint;\n\tpageIndex: number;\n\tsystemIndex: number;\n\tstaffIndex: number;\n}\n\ninterface MeasureValidation {\n\ttickMap: { [tick: number]: number };\n}\n\ninterface Size {\n\twidth: number;\n\theight: number;\n}\n\nclass Score extends SimpleClass {\n\tstatic className = 'Score';\n\n\tversion = VERSION;\n\n\ttitle: string;\n\t// in pixels\n\tpageSize: Size;\n\tunitSize: number;\n\tstaffLayoutCode: string;\n\n\tpaperOptions?: Partial;\n\n\theaders: { [key: string]: string };\n\n\ttextAnnotations: { [id: string]: string };\n\n\ttags?: string[];\n\n\tinstrumentDict: { [key: string]: string };\n\n\tpages: Page[];\n\ttopology: Topology;\n\tspartito?: Spartito;\n\n\tpatches?: PatchMeasure[];\n\n\tsettings: RecognitionSettings;\n\n\tconstructor(data: ScoreData) {\n\t\tsuper();\n\t\tsuper.assign(upgradeScoreData(data));\n\n\t\tthis.pages = this.pages || [];\n\t\tthis.headers = this.headers || {};\n\t\tthis.instrumentDict = this.instrumentDict || {};\n\n\t\tthis.pageSize = this.pageSize || {\n\t\t\t// A4 paper\n\t\t\twidth: 794,\n\t\t\theight: 1122,\n\t\t};\n\n\t\tthis.unitSize = this.unitSize || null;\n\n\t\tthis.staffLayoutCode = this.staffLayoutCode || (this.maxStavesCount === 2 ? GRAND_STAFF_LAYOUT : Array(this.maxStavesCount).fill('').join(','));\n\t}\n\n\tget systems(): System[] {\n\t\treturn [].concat(...this.pages.map((page) => page.systems));\n\t}\n\n\tget measureCount(): number {\n\t\treturn this.systems.reduce((sum, system) => sum + (system.measureCount || 0), 0);\n\t}\n\n\tget imageKeys(): string[] {\n\t\treturn [\n\t\t\t...this.pages.map((page) => page.source?.url),\n\t\t\t...this.systems.map((system) => system.backgroundImage),\n\t\t\t...[].concat(\n\t\t\t\t...this.systems.map((system) =>\n\t\t\t\t\t[...system.staves.map((staff) => staff.backgroundImage), ...system.staves.map((staff) => staff.maskImage)].filter(Boolean)\n\t\t\t\t)\n\t\t\t),\n\t\t].filter(Boolean);\n\t}\n\n\tget breakSystemIndices(): number[] {\n\t\tconst indices = [];\n\t\tlet systemCount = 0;\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tif (i < this.pages.length - 1) {\n\t\t\t\tsystemCount += page.systems.length;\n\t\t\t\tindices.push(systemCount - 1);\n\t\t\t}\n\t\t});\n\n\t\treturn indices;\n\t}\n\n\tget staffLayout(): staffLayout.StaffLayout {\n\t\treturn staffLayout.parseCode(this.staffLayoutCode);\n\t}\n\n\tget measureLayoutCode(): string {\n\t\treturn this.spartito?.measureLayoutCode;\n\t}\n\n\tget maxStavesCount(): number {\n\t\treturn Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget semanticHash(): string {\n\t\tconst ids = [].concat(\n\t\t\t...this.systems.map((system) =>\n\t\t\t\t[].concat(...system.staves.map((staff) => (staff.semantics ? system.qualifiedSemantics(staff.semantics).map((s) => s.id) : [])))\n\t\t\t)\n\t\t);\n\t\treturn sha1(ids.join(''));\n\t}\n\n\teventSystemsToTermStaves(eventSystems: EventSystem[], logger: Logger = new DummyLogger()): TermStaff[] {\n\t\t// [staff]\n\t\tconst termStaves: TermStaff[] = Array(this.maxStavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, staffIndex): TermStaff => {\n\t\t\t\treturn {\n\t\t\t\t\t// [system, measure]\n\t\t\t\t\trows: eventSystems.map((sys, i) =>\n\t\t\t\t\t\tsys.columns.map((column, ii): TermMeasure => {\n\t\t\t\t\t\t\tconst measure = column.rows[staffIndex];\n\t\t\t\t\t\t\tconsole.assert(measure, '[eventSystemsToTermStaves] measure is null:', staffIndex, column.rows);\n\n\t\t\t\t\t\t\tconst contexts = measure.contexts;\n\n\t\t\t\t\t\t\t// prepend octave shift 0 at begin of every system\n\t\t\t\t\t\t\tif (ii === 0) {\n\t\t\t\t\t\t\t\tif (!contexts.some((term) => term.type === ContextType.OctaveShift)) {\n\t\t\t\t\t\t\t\t\tcontexts.unshift(\n\t\t\t\t\t\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\t\t\t\t\t\tstaff: staffIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\t\t\t\ttokenType: TokenType.OctaveShift0,\n\t\t\t\t\t\t\t\t\t\t\ttick: 0,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst terms = [...(measure.events || []), ...contexts].sort((t1, t2) => t1.x - t2.x);\n\n\t\t\t\t\t\t\tconst pageBreak = staffIndex === 0 && ii === sys.columns.length - 1 && this.breakSystemIndices.includes(i);\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tterms,\n\t\t\t\t\t\t\t\t//xToTick: column.xToTick,\n\t\t\t\t\t\t\t\tduration: column.duration,\n\t\t\t\t\t\t\t\tpageBreak,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\ttermStaves.forEach((staff) => processStaffContext(staff, logger));\n\n\t\treturn termStaves;\n\t}\n\n\tresetPageLayout(parameters: { unitSize?: number; pageSize?: Size }) {\n\t\tconst { unitSize = this.unitSize, pageSize = this.pageSize } = parameters;\n\n\t\tconst newCenter = {\n\t\t\tx: (pageSize.width * 0.5) / unitSize,\n\t\t\ty: (pageSize.height * 0.5) / unitSize,\n\t\t};\n\n\t\tthis.pages.forEach((page) => {\n\t\t\tconst offsetX = newCenter.x - page.width / 2;\n\t\t\tconst offsetY = newCenter.y - page.height / 2;\n\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tsystem.left += offsetX;\n\t\t\t\tsystem.top += offsetY;\n\t\t\t});\n\n\t\t\tif (page.semantics) {\n\t\t\t\tpage.semantics.forEach((point) => {\n\t\t\t\t\tpoint.x += offsetX;\n\t\t\t\t\tpoint.y += offsetY;\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpage.width = pageSize.width / unitSize;\n\t\t\tpage.height = pageSize.height / unitSize;\n\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations });\n\t\t});\n\n\t\tthis.unitSize = unitSize;\n\t\tthis.pageSize = pageSize;\n\t}\n\n\tgetMeasure(measureIndex: number): {\n\t\tmeasureIndex: number;\n\t\tsystem: System;\n\t\tlocalIndex: number;\n\t\tleft: number;\n\t\tright: number;\n\t\tmeasures: Measure[];\n\t} {\n\t\tlet index = measureIndex;\n\t\tfor (const system of this.systems) {\n\t\t\tif (index < system.measureCount) {\n\t\t\t\tconst staff = system.staves[0];\n\t\t\t\tconst measure = staff.measures[index];\n\t\t\t\tconsole.assert(measure, 'measure is null:', system.measureCount, index, staff.measures);\n\t\t\t\tconst measures = system.getStaffArray(this.maxStavesCount).map((staff) => staff && staff.measures[index]);\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex,\n\t\t\t\t\tsystem,\n\t\t\t\t\tlocalIndex: index,\n\t\t\t\t\tleft: measure.left,\n\t\t\t\t\tright: measure.right,\n\t\t\t\t\tmeasures,\n\t\t\t\t};\n\t\t\t}\n\t\t\tindex -= system.measureCount;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetRawCluster(measureIndex: number, threshold: number, { timeSignature }: Partial = {}): SemanticCluster {\n\t\tconst position = this.getMeasure(measureIndex);\n\t\tif (!position) return null;\n\n\t\tconst { system, left, right } = position;\n\t\t//console.log(\"measure:\", system, left, right);\n\n\t\tconst elements: SemanticElement[] = [BOS_ELEMENT];\n\n\t\tif (timeSignature) elements.push(...fractionToElems(timeSignature));\n\n\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tlet points = system.qualifiedSemantics(staff.semantics, threshold).filter((point) => point.x > left && point.x < right);\n\t\t\tpoints = solveOverlapping(points);\n\n\t\t\t// exlude tempo noteheads\n\t\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t});\n\n\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\n\t\t\tpoints.forEach((point) => {\n\t\t\t\tconst type = SemanticElementType[point.semantic];\n\t\t\t\tif (type) {\n\t\t\t\t\tlet y1 = point.y;\n\t\t\t\t\tlet y2 = point.y;\n\t\t\t\t\tif (type === SemanticElementType.vline_Stem) {\n\t\t\t\t\t\ty1 = point.extension.y1;\n\t\t\t\t\t\ty2 = point.extension.y2;\n\t\t\t\t\t}\n\n\t\t\t\t\telements.push({\n\t\t\t\t\t\tid: point.id,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\tx: point.x - left,\n\t\t\t\t\t\ty1: y1 + y0,\n\t\t\t\t\t\ty2: y2 + y0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new SemanticCluster({\n\t\t\tindex: measureIndex,\n\t\t\telements,\n\t\t});\n\t}\n\n\tgetRawClusters(threshold: number = 1): SemanticCluster[] {\n\t\t//const times = this.getMeasuresTime();\n\n\t\treturn Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => this.getRawCluster(mi, threshold /*, times[mi]*/));\n\t}\n\n\tmakeSpartito(logger: Logger = new DummyLogger()): Spartito {\n\t\tlet eventSystems: EventSystem[] = this.systems.map((system) => system.getEvents(this.maxStavesCount));\n\n\t\t/*if (this.topology) {\n\t\t\tconst clusters = this.topology.clusters;\n\n\t\t\t// [measure, staff, event]\n\t\t\tconst eventsColumns: ChordColumn[][][] = clusters\n\t\t\t\t.filter((cluster) => cluster.index < this.measureCount)\n\t\t\t\t.reduce((columns, cluster) => {\n\t\t\t\t\tconst { system, measures } = this.getMeasure(cluster.index);\n\t\t\t\t\tconst events = cluster.getEvents();\n\n\t\t\t\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\t\t\t\t\tconst x0 = measures.filter(Boolean)[0].left;\n\n\t\t\t\t\tconst staves = system.getStaffArray(this.maxStavesCount);\n\n\t\t\t\t\t// translate by staff & measure relative offset\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst staff = staves[event.staff];\n\t\t\t\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\t\t\t\t\t\tevent.ys = event.ys.map((y) => roundNumber(y - y0, 0.5));\n\n\t\t\t\t\t\tevent.left += x0;\n\t\t\t\t\t\tevent.right += x0;\n\t\t\t\t\t});\n\n\t\t\t\t\tconst column = measures.map((measure, staffIndex) => {\n\t\t\t\t\t\tif (!measure) return [];\n\n\t\t\t\t\t\t//console.log(\"m:\", mi, \"s:\", staffIndex);\n\t\t\t\t\t\tconst localEvents = events.filter((event) => event.staff === staffIndex);\n\t\t\t\t\t\t//measure.assignModifiersOnEvents(localEvents);\n\t\t\t\t\t\tmeasure.assignAccessoriesOnEvents(localEvents);\n\n\t\t\t\t\t\treturn localEvents;\n\t\t\t\t\t});\n\n\t\t\t\t\tcolumns[cluster.index] = column;\n\n\t\t\t\t\treturn columns;\n\t\t\t\t}, []);\n\n\t\t\tconst breakSystemIndices = this.breakSystemIndices;\n\n\t\t\tconst basicEventSystems = eventSystems;\n\t\t\teventSystems = [];\n\n\t\t\tlet measures = 0;\n\t\t\tfor (const system of this.systems) {\n\t\t\t\tconst esys = system.getEventsFunctional(this.maxStavesCount, (si, mi) => eventsColumns[measures + mi] && eventsColumns[measures + mi][si], [], {\n\t\t\t\t\tuseXMap: false,\n\t\t\t\t});\n\n\t\t\t\tconst basicSys = basicEventSystems[system.index];\n\t\t\t\t//onst nullN = esys.columns.filter(c => !c).length;\n\t\t\t\t//if (nullN)\n\t\t\t\t//\tconsole.log(\"null:\", nullN, esys.columns.length);\n\t\t\t\tesys.columns = esys.columns.map((column, i) => (column ? column : basicSys.columns[i]));\n\n\t\t\t\tconst sysIndex = this.systems.indexOf(system);\n\t\t\t\tconst pageBreak = breakSystemIndices.includes(sysIndex);\n\t\t\t\tconst lastColumn = esys.columns[esys.columns.length - 1];\n\t\t\t\tif (lastColumn) {\n\t\t\t\t\tlastColumn.break = true;\n\t\t\t\t\tlastColumn.pageBreak = pageBreak;\n\t\t\t\t}\n\n\t\t\t\teventSystems.push(esys);\n\t\t\t\tmeasures += system.measureCount;\n\t\t\t}\n\t\t}*/\n\n\t\tconst staves = this.eventSystemsToTermStaves(eventSystems, logger);\n\n\t\t// assign staff basics for columns\n\t\teventSystems.forEach((sys, ri) => {\n\t\t\tsys.columns.forEach((column, mi) => {\n\t\t\t\tcolumn.basics = staves.map((staff) => {\n\t\t\t\t\tconst { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig } = staff.rows[ri][mi];\n\n\t\t\t\t\treturn { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig };\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tconst clusters = null; //this.topology && this.topology.clusters;\n\n\t\tconst measures = [].concat(\n\t\t\t...eventSystems.map((esys) =>\n\t\t\t\tesys.columns.map((column) => {\n\t\t\t\t\tconst measureIndex = column.measureIndex;\n\t\t\t\t\tconst { system, localIndex, left, right } = this.getMeasure(measureIndex);\n\n\t\t\t\t\tconst cluster = clusters && clusters.find((cluster) => cluster.index === measureIndex);\n\n\t\t\t\t\tconst staffYsFull = [];\n\t\t\t\t\tsystem.staves.forEach((staff) => (staffYsFull[staff.index] = staff.top + staff.staffY));\n\n\t\t\t\t\tconst patch = this.patches && this.patches.find((patch) => patch.measureIndex === measureIndex);\n\t\t\t\t\tconst events = patch ? patch.events : SpartitoMeasure.reorderEvents([].concat(...column.rows.map((row) => row.events)), staffYsFull);\n\n\t\t\t\t\tconst barTypes = Object.fromEntries(Object.entries(column.barTypes).map(([k, v]) => [k, v / system.staves.length]));\n\t\t\t\t\tconst indent = localIndex === 0 && system.indent;\n\n\t\t\t\t\treturn new SpartitoMeasure({\n\t\t\t\t\t\tmeasureIndex,\n\t\t\t\t\t\tstaffMask: esys.staffMask,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\t\tlocalIndex,\n\t\t\t\t\t\t\tleft,\n\t\t\t\t\t\t\tright,\n\t\t\t\t\t\t\tstaffYs: system.staves.map((staff) => staff.top + staff.staffY),\n\t\t\t\t\t\t\tstaffYsFull,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t//startX: column.startX,\n\t\t\t\t\t\t//width: column.width,\n\t\t\t\t\t\tduration: patch ? patch.duration : column.duration,\n\t\t\t\t\t\tevents,\n\t\t\t\t\t\tcontexts: column.rows.map((row) => row.contexts),\n\t\t\t\t\t\tmarks: column.marks,\n\t\t\t\t\t\tbreak: column.break,\n\t\t\t\t\t\tpageBreak: column.pageBreak,\n\t\t\t\t\t\tvoltaBegin: column.voltaBegin,\n\t\t\t\t\t\tvoltaEnd: column.voltaEnd,\n\t\t\t\t\t\talternative: column.alternative,\n\t\t\t\t\t\tbarTypes,\n\t\t\t\t\t\tindent,\n\t\t\t\t\t\tbasics: patch ? patch.basics : column.basics,\n\t\t\t\t\t\tmatrixH: cluster && cluster.matrixH,\n\t\t\t\t\t\tmatrixV: cluster && cluster.matrixV,\n\t\t\t\t\t\tvoices: patch ? patch.voices : null,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst staffLayout = this.staffLayout;\n\t\tconst staffGroups = staffLayout.standaloneGroups.map((ids) => ids.map((id) => staffLayout.staffIds.indexOf(id)));\n\n\t\tthis.spartito = new Spartito({\n\t\t\tstavesCount: this.maxStavesCount,\n\t\t\tstaffGroups,\n\t\t\tmeasures,\n\t\t});\n\n\t\treturn this.spartito;\n\t}\n\n\tmakeMusicSheet(): MusicSheet {\n\t\tconst spartito = this.spartito || this.makeSpartito();\n\n\t\tif (!spartito.regulated) console.warn('[makeMusicSheet]\tspartito not regulated.');\n\n\t\tconst voiceStaves = spartito.makeVoiceStaves();\n\n\t\tconst { title, pageSize, unitSize, staffLayout, paperOptions, headers, instrumentDict } = this;\n\t\tconst measureLayout = this.getMeasureLayout();\n\n\t\treturn {\n\t\t\ttitle,\n\t\t\tpageSize,\n\t\t\tunitSize,\n\t\t\tmeasureLayout,\n\t\t\tstaffLayout,\n\t\t\tpaperOptions,\n\t\t\theaders,\n\t\t\tvoiceStaves,\n\t\t\tinstrumentDict,\n\t\t};\n\t}\n\n\tfindPoint(sid: string): PointPosition {\n\t\tfor (const system of this.systems) {\n\t\t\tfor (let si = 0; si < system.staves.length; ++si) {\n\t\t\t\tconst point = system.staves[si].semantics.find((point) => point.id === sid);\n\t\t\t\tif (point) {\n\t\t\t\t\tconst pageIndex = this.pages.findIndex((page) => page.systems.includes(system));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpoint,\n\t\t\t\t\t\tpageIndex,\n\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\tstaffIndex: si,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetMeasureSemantics(systemIndex: number, localIndex: number): SemanticPointInMeasure[] {\n\t\tconst system = this.systems[systemIndex];\n\t\tif (!system) return null;\n\n\t\tconst left = localIndex ? system.measureBars[localIndex - 1] : 0;\n\t\tconst right = system.measureBars[localIndex] || system.width;\n\n\t\treturn system.staves\n\t\t\t.map((staff, si) => {\n\t\t\t\tconst staffY = staff.top + staff.staffY;\n\t\t\t\treturn staff.semantics\n\t\t\t\t\t.filter((point) => point.x >= left && point.x < right)\n\t\t\t\t\t.map((point) => {\n\t\t\t\t\t\tconst [y1, y2] = Number.isFinite(point.extension?.y1) ? [point.extension.y1, point.extension.y2] : [point.y, point.y];\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\tstaff: si,\n\t\t\t\t\t\t\tsy1: y1 + staffY,\n\t\t\t\t\t\t\tsy2: y2 + staffY,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1);\n\t}\n\n\tmakeTimewiseGraph({ store = false }: { store?: boolean } = {}): TimewiseGraph {\n\t\tif (!this.spartito) return null;\n\n\t\tconst measures = this.spartito.measures\n\t\t\t.filter((measure) => measure.events.length > 0)\n\t\t\t.map((measure) => {\n\t\t\t\tconst points = this.getMeasureSemantics(measure.position.systemIndex, measure.position.localIndex);\n\n\t\t\t\tconst graph = {\n\t\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\t\tleft: measure.position.left,\n\t\t\t\t\tright: measure.position.right,\n\t\t\t\t\tpoints,\n\t\t\t\t};\n\n\t\t\t\tif (store) measure.graph = graph;\n\n\t\t\t\treturn graph;\n\t\t\t});\n\n\t\treturn { measures };\n\t}\n\n\tgetTokenMap(): Map {\n\t\tconst map = new Map();\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => staff.measures.forEach((measure) => measure.tokens.forEach((token) => map.set(token.id, token))))\n\t\t);\n\n\t\treturn map;\n\t}\n\n\tassemble(confidenceThreshold: number = 1, logger: Logger = new DummyLogger()) {\n\t\tconst ids = new Map();\n\n\t\tconst append = (systemIndex, staffIndex, point) => {\n\t\t\tconst id = hashSemanticPoint(systemIndex, staffIndex, point);\n\t\t\tlogger.assert(!ids.has(id), 'semantic point hash conflicted:', id, point, ids.get(id));\n\n\t\t\tids.set(id, point);\n\t\t};\n\n\t\tthis.pages.forEach((page, index) => (page.index = index));\n\n\t\tlet measureIndex = 0;\n\t\tthis.systems.forEach((system, systemIndex) => {\n\t\t\tsystem.index = systemIndex;\n\t\t\tsystem.headMeasureIndex = measureIndex;\n\t\t\tsystem.prev = this.systems[systemIndex - 1] || null;\n\t\t\tsystem.next = this.systems[systemIndex + 1] || null;\n\n\t\t\tif (system.semantics && system.semantics.length) system.semantics.forEach((point) => append(systemIndex, null, point));\n\n\t\t\tsystem.assemble(confidenceThreshold, logger);\n\t\t\tmeasureIndex += system.measureCount;\n\t\t});\n\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tpage.systems.forEach((system) => (system.pageIndex = i));\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations }, logger);\n\t\t});\n\t}\n\n\tassembleSystem(system: System, confidenceThreshold: number = 1) {\n\t\tthis.systems.forEach((system, si) => (system.index = si));\n\t\tconst systemIndex = system.index;\n\n\t\tif (system.semantics && system.semantics.length) {\n\t\t\tsystem.semantics.forEach((point) => hashSemanticPoint(systemIndex, null, point));\n\t\t\tsystem.assemble(confidenceThreshold);\n\t\t}\n\t}\n\n\tmarkVoices(staves: VoicesStaff[]): void {\n\t\tconst tokenMap = this.getTokenMap();\n\t\tfor (const token of tokenMap.values()) token.voice = 0;\n\n\t\tconst vis = []\n\t\t\t.concat(...staves.map((staff, s) => (staff.voices || []).map((_, v) => [s, v])))\n\t\t\t.sort(([s1, v1], [s2, v2]) => v1 - v2 || s1 - s2)\n\t\t\t.map(([s, v]) => `${s}|${v}`);\n\n\t\tstaves.forEach((staff, si) =>\n\t\t\t(staff.voices || []).forEach((voice, vi) =>\n\t\t\t\tvoice.measures.forEach((measure) => {\n\t\t\t\t\tconst voiceIndex = vis.indexOf(`${si}|${vi}`);\n\n\t\t\t\t\tconst events = Object.values(measure.tickMap).filter((event) => event instanceof EventTerm) as EventTerm[];\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst notes = event.noteIds ? event.noteIds.map((id) => tokenMap.get(id)).filter(Boolean) : [];\n\t\t\t\t\t\tconst accessories = event.accessories ? event.accessories.map((acc) => tokenMap.get(acc.id)).filter(Boolean) : [];\n\t\t\t\t\t\t//console.log(\"notes:\", si, vi, mi, event.noteIds, notes, accessories);\n\n\t\t\t\t\t\t[...notes, ...accessories].forEach((token) => (token.voice |= 1 << voiceIndex));\n\n\t\t\t\t\t\tif (event.timeWarp) notes.forEach((note) => (note.timeWarped = true));\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t}\n\n\tasync replaceImageKeys(proc: (x: string | Buffer) => Promise): Promise {\n\t\tawait Promise.all([\n\t\t\t...(this.pages.map(async (page) => {\n\t\t\t\tif (page.source) page.source.url = await proc(page.source.url);\n\t\t\t}) as Promise[]),\n\t\t\t...this.systems.map((system) =>\n\t\t\t\tPromise.all([\n\t\t\t\t\tproc(system.backgroundImage).then((key) => (system.backgroundImage = key)),\n\t\t\t\t\t...(system.staves.map(async (staff) => {\n\t\t\t\t\t\tstaff.backgroundImage = await proc(staff.backgroundImage);\n\t\t\t\t\t\tstaff.maskImage = await proc(staff.maskImage);\n\t\t\t\t\t}) as Promise[]),\n\t\t\t\t])\n\t\t\t),\n\t\t]);\n\t}\n\n\tinferenceStaffLayout(): void {\n\t\t// inference the complete layout\n\t\tconst staffTotal = Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t\tthis.staffLayoutCode = Array(staffTotal).fill('').join(',');\n\n\t\tconst completeSystems = this.systems.filter((system) => system.staves.length === staffTotal && system.bracketsAppearance);\n\t\tif (!completeSystems.length) return; // no enough evidence\n\n\t\tconst candidateCodes = completeSystems\n\t\t\t.map((system) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst layout = staffLayout.parseCode(system.bracketsAppearance);\n\t\t\t\t\tif (layout.staffIds.length !== system.staves.length) return null;\n\n\t\t\t\t\treturn system.bracketsAppearance;\n\t\t\t\t} catch (_) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t\tif (!candidateCodes.length) return; // no valid layout\n\n\t\tconst codeCounting = candidateCodes.reduce((acc, code) => {\n\t\t\tconst count = acc[code] || 0;\n\t\t\tacc[code] = count + 1;\n\t\t\treturn acc;\n\t\t}, {} as { [code: string]: number });\n\t\tconst maxCount = Math.max(...Object.values(codeCounting));\n\t\tconst code = Object.entries(codeCounting).find(([_, count]) => count === maxCount)[0];\n\n\t\t// added connection lines between braces {-}\n\t\tconst connectedCode = code.replace(/\\{,*\\}/g, (match) => match.replace(/,/g, '-'));\n\t\tconst layout = staffLayout.parseCode(connectedCode);\n\n\t\tthis.staffLayoutCode = connectedCode;\n\t\t//console.log(\"complete code:\", code);\n\n\t\t// inference systems' mask\n\t\tlet lastSys: System = null;\n\t\tfor (const system of this.systems) {\n\t\t\tif (lastSys && system.staves.length === lastSys.staves.length && system.bracketsAppearance === lastSys.bracketsAppearance) {\n\t\t\t\tsystem.staffMaskChanged = null;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (system.staves.length < staffTotal && system.bracketsAppearance) {\n\t\t\t\t// validate the system brackets code\n\t\t\t\ttry {\n\t\t\t\t\tif (!staffLayout.parseCode(system.bracketsAppearance)) continue;\n\t\t\t\t} catch (_) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst search = (bits: (0 | 1)[]): number => {\n\t\t\t\t\tif (bits.length > layout.staffIds.length) return null;\n\n\t\t\t\t\tif (bits.reduce((sum, bit) => sum + bit, 0) === system.staves.length) return bitsToMask(bits);\n\n\t\t\t\t\tfor (const bit of [1, 0]) {\n\t\t\t\t\t\tconst bb = [...bits, bit] as (0 | 1)[];\n\t\t\t\t\t\tconst code1 = layout.partialMaskCode(bb);\n\t\t\t\t\t\tif (code1 === system.bracketsAppearance) return bitsToMask(bb);\n\t\t\t\t\t\telse if (system.bracketsAppearance.startsWith(code1)) {\n\t\t\t\t\t\t\tconst result = search(bb);\n\t\t\t\t\t\t\tif (result) return result;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t};\n\t\t\t\tconst mask = search([]);\n\t\t\t\t//console.log(\"mask:\", system.bracketsAppearance, mask.toString(2));\n\n\t\t\t\tsystem.staffMaskChanged = !lastSys || mask !== lastSys.staffMask ? mask : null;\n\t\t\t}\n\n\t\t\tlastSys = system;\n\t\t}\n\t}\n\n\tassignBackgroundForMeasure(measure: SpartitoMeasure): void {\n\t\tmeasure.backgroundImages = [];\n\n\t\tconst system = this.systems[measure.position.systemIndex];\n\t\tif (system.backgroundImage) {\n\t\t\tmeasure.backgroundImages.push({\n\t\t\t\turl: system.backgroundImage,\n\t\t\t\tposition: system.imagePosition,\n\t\t\t\toriginal: true,\n\t\t\t});\n\t\t}\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tif (!system.backgroundImage && staff.backgroundImage)\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.backgroundImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t\toriginal: true,\n\t\t\t\t});\n\n\t\t\tif (staff.maskImage) {\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.maskImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tblackoutFakeNotes(scope: 'patched' | 'perfect' | 'all' = 'patched'): string[] {\n\t\tif (!this.spartito) return;\n\n\t\tlet inScope = (_) => true;\n\t\tswitch (scope) {\n\t\t\tcase 'patched':\n\t\t\t\tinScope = (measure) => measure.patched;\n\t\t\t\tbreak;\n\t\t\tcase 'perfect':\n\t\t\t\tinScope = (measure) => measure.patched || (measure.regulated && evaluateMeasure(measure).perfect);\n\t\t\t\tbreak;\n\t\t}\n\t\tconst measures = this.spartito.measures.filter(inScope);\n\n\t\tconst fakeIds = measures.reduce((ids, measure) => {\n\t\t\tif (!measure.regulated) return;\n\n\t\t\tconst voicedIds = measure.voices.flat(1);\n\t\t\tconst fakeChords = measure.events.filter((event) => !event.rest && !event.grace && !voicedIds.includes(event.id));\n\n\t\t\tfakeChords.forEach((event) => event.noteIds && ids.push(...event.noteIds));\n\n\t\t\treturn ids;\n\t\t}, [] as string[]);\n\t\tconst fakeIdSet = new Set(fakeIds);\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\tconst blackIds = staff.semantics.filter((point) => fakeIdSet.has(point.id)).map((point) => point.id);\n\t\t\t\tsystem.sidBlackList.push(...blackIds);\n\t\t\t})\n\t\t);\n\n\t\treturn fakeIds;\n\t}\n\n\tgetMeasureLayout(): measureLayout.MeasureLayout {\n\t\tconst code = this.spartito && this.spartito.measureLayoutCode;\n\t\tif (code) {\n\t\t\ttry {\n\t\t\t\treturn measureLayout.parseCode(code);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.debug('invalid measure layout code:', err);\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t*splitToSingleScoresGen(): Generator {\n\t\tthis.assemble();\n\t\tconst startSysIndices = this.systems.filter((system) => system.index > 0 && system.indent && system.timeSignatureOnHead).map((system) => system.index);\n\n\t\tif (!startSysIndices.length) {\n\t\t\tyield this.deepCopy();\n\t\t\treturn;\n\t\t}\n\n\t\tconst templateScore = new Score({ ...this, pages: [], topology: undefined, spartito: undefined, patches: undefined });\n\n\t\t// clear temporary objects before deep dopy\n\t\tthis.pages.forEach((page) => {\n\t\t\tdelete page.tokens;\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tdelete system.tokens;\n\t\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\t\tstaff.measures = [];\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tlet startSysIndex = 0;\n\t\tfor (const endSysIndex of [...startSysIndices, this.systems.length]) {\n\t\t\tconst sysInRange = (system) => system.index >= startSysIndex && system.index < endSysIndex;\n\t\t\tconst pages = this.pages\n\t\t\t\t.filter((page) => page.systems.some(sysInRange))\n\t\t\t\t.map((page) => {\n\t\t\t\t\tconst { systems, ...fields } = page;\n\t\t\t\t\treturn new Page({ ...fields, systems: systems.filter(sysInRange).map((system) => new System({ ...system })) });\n\t\t\t\t});\n\n\t\t\tconst newScore = templateScore.deepCopy();\n\t\t\tnewScore.headers.SubScoreSystem = `${startSysIndex}-${endSysIndex - 1}`;\n\t\t\tnewScore.headers.SubScorePage = `${pages[0].index}-${pages[pages.length - 1].index}`;\n\n\t\t\t//newScore.pages = pages.map((page) => page.deepCopy());\n\t\t\tnewScore.pages = pages;\n\t\t\tnewScore.assemble();\n\t\t\tnewScore.inferenceStaffLayout();\n\n\t\t\tstartSysIndex = endSysIndex;\n\n\t\t\tyield newScore;\n\t\t}\n\t}\n\n\tsplitToSingleScores(): Score[] {\n\t\treturn [...this.splitToSingleScoresGen()];\n\t}\n}\n\nexport { PaperOptions, Score, Page, System, Staff, Measure, MeasureValidation };\nexport type { SemanticPointInMeasure };\n","import { MIDI } from '@k-l-lambda/music-widgets';\n\nimport { Fraction } from './interfaces';\nimport { noteToPitch } from './utils';\nimport { EventTerm, RestType, GraceType, StemBeam, ArpeggioStyle, TermPitch, TremoloLink } from './term';\nimport { SpartitoMeasure } from './spartitoMeasure';\n\n// NOTE: 'JSONEditor.onEditable' determine whether a field is editable, here 'readonly' modifier has no effect to UI\n\ninterface EventUIAgent {\n\treadonly id: number;\n\treadonly duration: number;\n\n\t//ys: number[];\n\tpitches: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\tgrace: boolean; //\n\tbeam: StemBeam;\n\ttimeWarp: string; //\n\ttremolo: number;\n\ttremoloLink: TremoloLink;\n\tglissando: boolean;\n\tarpeggioStyle: ArpeggioStyle;\n\ttick: number;\n}\n\ninterface MeasureUIAgent {\n\treadonly measureIndex: number;\n\ttimeSignature: Fraction;\n\tdoubtfulTimesig: boolean;\n\tkeySignature: number;\n\t//readonly events: EventUIAgent[];\n\tduration: number;\n\treadonly voices: number[][];\n}\n\nclass EditableEvent extends EventTerm {\n\tvoice: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t}\n\n\tget agent(): EventUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget(target, key): any {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'arpeggioStyle': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? null : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'glissando': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? false : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\treturn !!self.grace;\n\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\treturn self.timeWarp ? `${self.timeWarp.numerator}/${self.timeWarp.denominator}` : null;\n\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn self.pitches;\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'glissando':\n\t\t\t\t\tcase 'arpeggioStyle':\n\t\t\t\t\t\t(self as any)[key] = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\tself.grace = value ? GraceType.Grace : null;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\tself.timeWarp = null;\n\t\t\t\t\t\tif (value && typeof value === 'string') {\n\t\t\t\t\t\t\tconst captures = value.match(/^(\\d+)\\/(\\d+)/);\n\t\t\t\t\t\t\tif (captures) {\n\t\t\t\t\t\t\t\tself.timeWarp = {\n\t\t\t\t\t\t\t\t\tnumerator: parseInt(captures[1]),\n\t\t\t\t\t\t\t\t\tdenominator: parseInt(captures[2]),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => [\n\t\t\t\t'id',\n\t\t\t\t'duration',\n\t\t\t\t'rest',\n\t\t\t\t'division',\n\t\t\t\t'dots',\n\t\t\t\t'stemDirection',\n\t\t\t\t'tying',\n\t\t\t\t'tied',\n\t\t\t\t'beam',\n\t\t\t\t'timeWarp',\n\t\t\t\t'tremolo',\n\t\t\t\t'tremoloLink',\n\t\t\t\t'glissando',\n\t\t\t\t'arpeggioStyle',\n\t\t\t\t'tick',\n\t\t\t\t'grace',\n\t\t\t\t'pitches',\n\t\t\t],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n}\n\nclass EditableMeasure extends SpartitoMeasure {\n\tstatic className = 'EditableMeasure';\n\tstatic blackKeys = [];\n\n\tevents: EditableEvent[] = null;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\n\t\tthis.events = data.events;\n\t\tif (this.events?.some((event) => !(event instanceof EditableEvent))) this.events = this.events.map((event) => new EditableEvent(event));\n\n\t\tif (this.voices) this.syncVoiceToEvents();\n\t}\n\n\tsyncVoiceToEvents(): void {\n\t\tthis.events.forEach((event) => (event.voice = -1));\n\t\tthis.voices.forEach((voice, voiceIndex) => {\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\tif (event) event.voice = voiceIndex;\n\t\t\t\telse console.warn('no event with id:', id, this.events.length);\n\t\t\t});\n\t\t});\n\t}\n\n\tsyncVoiceFromEvents(): void {\n\t\tconst voices: EditableEvent[][] = [];\n\t\tthis.events.forEach((event) => {\n\t\t\tif (event?.voice >= 0) {\n\t\t\t\tvoices[event.voice] = voices[event.voice] || [];\n\t\t\t\tvoices[event.voice].push(event);\n\t\t\t}\n\t\t});\n\n\t\tvoices.forEach((voice) => voice.sort((e1, e2) => e1.tick - e2.tick));\n\n\t\tthis.voices = voices.map((voice) => voice.map((event) => event.id));\n\t}\n\n\tget agent(): MeasureUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget: (target, key): any => {\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\treturn self[key];\n\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn self.voices?.map((voice) => voice.join(',')) || null;\n\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\treturn self.basics[0][key];\n\t\t\t\t\t//case 'events':\n\t\t\t\t\t//\treturn self.events.map(eventUIAgent);\n\t\t\t\t\tcase 'toJSON':\n\t\t\t\t\t\treturn () => ({\n\t\t\t\t\t\t\tmeasureIndex: self.measureIndex,\n\t\t\t\t\t\t\tvoices: self.voices,\n\t\t\t\t\t\t\tduration: self.duration,\n\t\t\t\t\t\t\ttimeSignature: self.basics[0].timeSignature,\n\t\t\t\t\t\t\tkeySignature: self.basics[0].keySignature,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\t//console.log('set:', key, value);\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\t(self.basics[0][key] as any) = value;\n\t\t\t\t\t\tself.basics = self.basics.map(() => self.basics[0]);\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\tself.duration = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => ['measureIndex', 'timeSignature', 'doubtfulTimesig', 'keySignature', 'duration', 'voices'],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n\n\tmakeMIDI(bpm: number = 120): MIDI.MidiData {\n\t\tif (!this.regulated) return null;\n\n\t\tconst microsecondsPerBeat = 60e6 / bpm;\n\n\t\tconst header = { formatType: 0, ticksPerBeat: 480 };\n\t\tconst tracks = this.voices.map((ids, vi) => {\n\t\t\tconst events = ids\n\t\t\t\t.map((id) => {\n\t\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\t\tif (event) {\n\t\t\t\t\t\tconst subEvents = event.graceIds ? event.graceIds.map((id) => this.events.find((event) => event.id === id)) : [];\n\n\t\t\t\t\t\treturn [...subEvents, event];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [];\n\t\t\t\t})\n\t\t\t\t.flat(1);\n\n\t\t\tconst startTime = 0;\n\n\t\t\ttype Event = MIDI.MidiEvent & { [key: string]: any };\n\t\t\tconst midiEvents: Event[] = events\n\t\t\t\t.filter((event) => !event.rest && Number.isFinite(event.tick) && event.tick >= 0 && Number.isFinite(event.duration))\n\t\t\t\t.map((event) =>\n\t\t\t\t\tevent.pitches.map((pitch) => [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t\tvelocity: 96,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick + event.duration,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t\t.flat(2);\n\n\t\t\tmidiEvents.sort(function (e1, e2) {\n\t\t\t\treturn e1.time - e2.time;\n\t\t\t});\n\n\t\t\tif (vi === 0) {\n\t\t\t\tmidiEvents.unshift(\n\t\t\t\t\t{\n\t\t\t\t\t\ttime: startTime,\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tsubtype: 'timeSignature',\n\t\t\t\t\t\tnumerator: this.timeSignature.numerator,\n\t\t\t\t\t\tdenominator: this.timeSignature.denominator,\n\t\t\t\t\t\tthirtyseconds: 8,\n\t\t\t\t\t},\n\t\t\t\t\t{ time: startTime, type: 'meta', subtype: 'setTempo', microsecondsPerBeat }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmidiEvents.forEach((event) => {\n\t\t\t\tevent.ticks = Math.round(event.time - startTime);\n\t\t\t});\n\t\t\tmidiEvents.forEach((event, i) => {\n\t\t\t\tevent.deltaTime = event.ticks - (i > 0 ? midiEvents[i - 1].ticks : 0);\n\t\t\t});\n\n\t\t\tmidiEvents.push({ deltaTime: 0, type: 'meta', subtype: 'endOfTrack' });\n\n\t\t\treturn midiEvents;\n\t\t});\n\n\t\treturn {\n\t\t\theader,\n\t\t\ttracks,\n\t\t};\n\t}\n}\n\nexport { EditableEvent, EditableMeasure };\n","import { RegulationSolution, RegulationSolutionEvent, EventPredisposition } from './interfaces';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport { argmax, frac } from './utils';\nimport { WHOLE_DURATION, StemBeam } from './term';\nimport { Logger, DummyLogger } from './logger';\n\ninterface BeadPicker {\n\tn_seq: number;\n\tquota: number;\n\tcost: number; // duration in milliseconds\n\n\tpredictCluster(cluster: EventCluster, tip: number): Promise;\n}\n\nenum BeadType {\n\tPass = 'i',\n\tDivision = 'd',\n\tDots = 'o',\n}\n\nconst DIVISION_NAMES = ['whole', 'half', 'quarter', 'eighth', 'sixteenth', 'thirtysecond', 'sixtyfourth', '128th', '256th'];\n\ninterface BeadNodeInitData {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n}\n\nconst RESIDUE_LOSS_WEIGHT = 0.2;\nconst VOICEN_LOSS_WEIGHT = 0.002;\nconst SPACE_LOSS_WEIGHT = 0.4 / WHOLE_DURATION;\nconst PRETENTIOUSNESS_LOSS_WEIGHT = 0.02;\n\nconst POSSIBILITY_LOW_BOUNDARY = 1e-12;\n\nconst PRETENTIOUSNESS_CLIP = 100;\n\ninterface ClusterEvaluation {\n\ttickErr: number;\n\ttwist: number;\n\tresidue: number;\n\tendTick: number;\n\tfatalError: boolean;\n\tvoiceN: number;\n\tspaceDuration: number;\n\tpretentiousness: number;\n\tloss: number;\n}\n\ninterface ElementState {\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tbeam: StemBeam;\n\tstemDirection: string;\n\tgrace: boolean;\n\ttimeWarped: boolean;\n\tfullMeasure: boolean; // full measure rest\n\tfake: boolean;\n\torder: number;\n\tpredisposition: EventPredisposition;\n}\n\ninterface ClusterState {\n\telements: ElementState[];\n}\n\nconst STEM_DIRECTION_OPTIONS = [undefined, 'u', 'd'];\n\nconst BEAM_OPTIONS = [undefined, StemBeam.Open, StemBeam.Continue, StemBeam.Close];\n\nconst saveClusterState = (cluster: EventCluster): ClusterState => ({\n\telements: cluster.elements.map((elem) => ({\n\t\ttick: elem.tick!,\n\t\tdivision: elem.division!,\n\t\tdots: elem.dots!,\n\t\tbeam: elem.beam!,\n\t\tstemDirection: elem.stemDirection!,\n\t\tgrace: elem.grace!,\n\t\ttimeWarped: elem.timeWarped!,\n\t\tfullMeasure: elem.fullMeasure!,\n\t\tfake: elem.fake!,\n\t\torder: elem.order!,\n\t\tpredisposition: elem.predisposition!,\n\t})),\n});\n\nconst restoreClusterState = (cluster: EventCluster, state: ClusterState): void => cluster.elements.forEach((elem, i) => Object.assign(elem, state.elements[i]));\n\nconst measurePretentious = (p) => Math.min(PRETENTIOUSNESS_CLIP, -Math.log(p));\n\ninterface BeadDeductionContext {\n\tpicker: BeadPicker;\n\tlogger: Logger;\n\tptFactor: number; // pretentiousness tolerance factor\n}\n\nclass BeadNode {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n\n\tchildren: Record;\n\taccessCount: number;\n\n\tconstructor(data: BeadNodeInitData) {\n\t\tObject.assign(this, data);\n\n\t\t//this.possibilities = this.possibilities.map((x, i) => (this.type === BeadType.Pass && !i) ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\n\t\tthis.children = {};\n\t\tthis.accessCount = 0;\n\t}\n\n\tnextBranch(): number | null {\n\t\tconst ps = this.possibilities.map((p, i) => p / (this.children[i] ? this.children[i].accessCount + 1 : 1));\n\t\t//const ps = this.possibilities.map((p, i) => p * (this.children[i] ? (2 ** -this.children[i].accessCount) : 1));\n\n\t\tif (ps.every((p) => !p)) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn null;\n\t\t}\n\n\t\treturn argmax(ps);\n\t}\n\n\tget currentElem(): EventElement {\n\t\treturn this.cluster.elements[this.elemIndex];\n\t}\n\n\tbranchID(ni: number): string {\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\treturn `i_${ni}`;\n\t\t\tcase BeadType.Division:\n\t\t\t\treturn DIVISION_NAMES[ni];\n\t\t\tcase BeadType.Dots:\n\t\t\t\treturn 'o' + '.'.repeat(ni);\n\t\t}\n\n\t\treturn '';\n\t}\n\n\tasync deduce({ picker, logger, ptFactor }: BeadDeductionContext, deep: number = 0): Promise {\n\t\t++this.accessCount;\n\n\t\tconst ni = this.nextBranch()!;\n\t\tlogger.debug(String.fromCodePoint(0x1f349) + ' '.repeat(deep), this.branchID(ni), this.accessCount > 1 ? `[${this.accessCount}]` : '');\n\n\t\tif (!Number.isInteger(ni) || ni < 0) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tthis.pretentiousness += measurePretentious(this.possibilities[ni]);\n\t\tif (this.pretentiousness > PRETENTIOUSNESS_CLIP * ptFactor) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tlet selfEval: null | ClusterEvaluation = null;\n\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\t{\n\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\tconst element = this.cluster.elements[ni];\n\t\t\t\t\tconsole.assert(element, 'null element:', ni, this.cluster.elements.length);\n\t\t\t\t\tif (element.type === EventElementType.EOS) {\n\t\t\t\t\t\tselfEval = evaluateCluster(this.cluster, tip, this.pretentiousness);\n\t\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.cluster.elements[0].order = tip;\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip + 1)).map((x, i) =>\n\t\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 || i === this.cluster.elements.length - 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: 0,\n\t\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.order = tip;\n\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tconsole.assert(element.predisposition, 'no predisposition:', ni, this.possibilities);\n\t\t\t\t\t\t\tconst possibilities = element.predisposition!.divisionVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: ni,\n\t\t\t\t\t\t\t\ttype: BeadType.Division,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Division:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.division = ni;\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tconst possibilities = this.currentElem.predisposition!.dotsVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Dots,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Dots:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.dots = ni;\n\n\t\t\t\t\tselfEval = evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip)).map((x, i) =>\n\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\tconst evaluation = await this.children[ni].deduce({ picker, logger, ptFactor }, deep + 1);\n\t\tif (selfEval && evaluation.fatalError) {\n\t\t\tconst tip = this.currentElem.order!;\n\t\t\tthis.cluster.elements.forEach((elem) => {\n\t\t\t\tif (elem.order! > tip) elem.order = undefined;\n\t\t\t});\n\n\t\t\t// clear children data\n\t\t\tthis.cluster.elements.forEach((elem) => (elem.order = elem.order! > this.currentElem.order! ? undefined : elem.order));\n\t\t\tthis.cluster.elements[this.cluster.elements.length - 1].tick = selfEval.endTick;\n\n\t\t\treturn selfEval;\n\t\t}\n\n\t\treturn evaluation;\n\t}\n}\n\nconst estimateElementDuration = (elem: EventElement) => WHOLE_DURATION * 2 ** -elem.division! * (2 - 2 ** -elem.dots!);\n\nconst evaluateCluster = (cluster: EventCluster, tip: number, pretentiousness: number): ClusterEvaluation => {\n\tconst events = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order) && elem.order! < tip\n\t);\n\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\tconst eos = cluster.elements[cluster.elements.length - 1];\n\n\tlet tick = 0;\n\tlet lastOrder = 0;\n\tlet endTick = 0;\n\tlet voiceN = 1;\n\n\t// [x, tick, estimated tick]\n\tconst scales: [number, number, number][] = [[eos.x, cluster.signatureDuration, cluster.signatureDuration]];\n\n\tlet totalDuration = 0;\n\n\t// assign tick for events\n\tevents.forEach((event) => {\n\t\tif (event.order! > lastOrder + 1) {\n\t\t\ttick = 0;\n\t\t\t++voiceN;\n\t\t}\n\n\t\tconst referenceScale = scales.find((s) => s[1] >= tick);\n\t\tif (referenceScale && event.x > referenceScale[0] + 3) {\n\t\t\tconst nearScale = scales.reduce((n, s) => (Math.abs(event.predisposition!.tick - s[2]) < Math.abs(event.predisposition!.tick - n[2]) ? s : n));\n\t\t\tif (Math.abs(nearScale[0] - event.x) < 2) tick = Math.max(tick, nearScale[1]);\n\t\t}\n\n\t\tevent.tick = tick;\n\n\t\tconst si = Math.max(\n\t\t\t0,\n\t\t\tscales.findIndex((s) => s[0] > event.x)\n\t\t);\n\t\tscales.splice(si, 0, [event.x, event.tick, event.predisposition!.tick]);\n\n\t\t//let duration = WHOLE_DURATION * (2 ** -event.division!) * (2 - 2 ** -event.dots!);\n\t\tlet duration = estimateElementDuration(event);\n\t\tif (event.predisposition!.timeWarped > 0.5) duration = (duration * 2) / 3;\n\n\t\ttick += duration;\n\t\ttotalDuration += duration;\n\t\tendTick = Math.max(endTick, tick);\n\t\tlastOrder = event.order!;\n\t});\n\n\t/*const pretentiousness = events.reduce((p, event) => p +\n\t\tmeasurePretentious(event.predisposition!.divisionVector![event.division!]) +\n\t\tmeasurePretentious(event.predisposition!.dotsVector![event.dots!]), 0);*/\n\n\tif (endTick > 0) cluster.elements[cluster.elements.length - 1].tick = endTick;\n\n\tconst xSpan = cluster.elements[cluster.elements.length - 1].pivotX! - cluster.elements[1].pivotX!;\n\tconst tickSpan = Math.max(...events.map((e) => e.tick!), endTick);\n\n\t// tick twist loss\n\tconst eventsXOrder = [...events].sort((e1, e2) => e1.pivotX! - e2.pivotX!);\n\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\tconst e1 = eventsXOrder[i];\n\t\tconst dx = e2.pivotX! - e1.pivotX!;\n\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\tif (!dt) return dx / xSpan;\n\n\t\tconst rate = Math.atan2(dt / tickSpan, dx / xSpan);\n\n\t\t//if (dt < 0)\n\t\t//\tconsole.log(\"minus dt:\", dt, dx, rate);\n\n\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t});\n\t//console.debug(\"tickTwists:\", tickTwists, eventsXOrder);\n\n\tconst twist = Math.max(...tickTwists, 0);\n\n\tconst tickMSE = events.map((event) => (event.tick! - event.predisposition!.tick) ** 2);\n\t//console.debug(\"tickMSE:\", tickMSE.map(Math.sqrt));\n\tconst tickErr = tickMSE.length ? Math.sqrt(tickMSE.reduce((sum, mse) => sum + mse, 0) / tickMSE.length) : 0;\n\t//console.debug(\"tick/twist:\", tickErr / WHOLE_DURATION, twist);\n\n\tconst residueElements = cluster.elements.filter(\n\t\t(elem) =>\n\t\t\t[EventElementType.CHORD, EventElementType.REST].includes(elem.type) &&\n\t\t\t!(Number.isInteger(elem.order) && elem.order! < tip) &&\n\t\t\t!(elem.predisposition && elem.predisposition.fakeP > 0.5)\n\t);\n\tconst residue = residueElements.length;\n\n\tconst fatalError = twist >= 1 || endTick > cluster.signatureDuration;\n\n\t//const spaceDuration = Math.max(0, cluster.signatureDuration - endTick);\n\tconst spaceDuration = Math.max(0, cluster.signatureDuration - totalDuration / voiceN);\n\n\tconst loss =\n\t\ttickErr / WHOLE_DURATION +\n\t\ttwist +\n\t\tresidue * RESIDUE_LOSS_WEIGHT +\n\t\tvoiceN * VOICEN_LOSS_WEIGHT +\n\t\tspaceDuration * SPACE_LOSS_WEIGHT +\n\t\tpretentiousness * PRETENTIOUSNESS_LOSS_WEIGHT;\n\n\treturn {\n\t\ttickErr,\n\t\ttwist,\n\t\tresidue,\n\t\tendTick,\n\t\tfatalError,\n\t\tvoiceN,\n\t\tspaceDuration,\n\t\tpretentiousness,\n\t\tloss,\n\t};\n};\n\nconst solveCluster = async (\n\tcluster: EventCluster,\n\tpicker: BeadPicker,\n\tlogger: Logger,\n\tquota: number = 200,\n\tstopLoss: number = 0,\n\tptFactor: number = 1\n): Promise => {\n\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\tconst suc0 = await picker.predictCluster(cluster, 1);\n\n\tconst root = new BeadNode({ cluster, elemIndex: 0, pretentiousness: 0, type: BeadType.Pass, possibilities: suc0 });\n\n\tlet bestEvaluation: ClusterEvaluation | null = null;\n\tlet bestState: ClusterState | null = null;\n\n\tpicker.quota = quota;\n\twhile (picker.quota) {\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\n\t\tconst evaluation = await root.deduce({ picker, logger, ptFactor });\n\n\t\tlogger.debug('loss:', evaluation);\n\n\t\tif (!bestEvaluation || evaluation.loss < bestEvaluation.loss) {\n\t\t\tbestEvaluation = evaluation;\n\n\t\t\tcluster.duration = bestEvaluation.endTick;\n\t\t\tbestState = saveClusterState(cluster);\n\n\t\t\tif (Number.isFinite(stopLoss) && bestEvaluation.loss <= stopLoss!) break;\n\t\t}\n\n\t\tif (!Number.isFinite(root.accessCount)) break;\n\t}\n\tlogger.debug('bestEvaluation:', bestEvaluation);\n\n\trestoreClusterState(cluster, bestState!);\n\n\t// solve residue elements\n\tconst fixedEvents = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\tconst pendingEvents = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !Number.isInteger(elem.order)\n\t);\n\tif (fixedEvents.length) {\n\t\tpendingEvents.forEach((event) => {\n\t\t\t// exclude fake events (includes grace, fullMeasure) from voices\n\t\t\tevent.tick = undefined;\n\n\t\t\tif (event.predisposition!.fakeP < 0.5) {\n\t\t\t\t//const near = fixedEvents.reduce((n, e) => Math.abs(e.predisposition!.tick - event.predisposition!.tick) < Math.abs(n.predisposition!.tick - event.predisposition!.tick) ? e : n);\n\t\t\t\tconst duration = estimateElementDuration(event);\n\t\t\t\tconst candidates = fixedEvents.filter((e) => e.tick! + duration <= bestEvaluation!.endTick);\n\t\t\t\tif (candidates.length) {\n\t\t\t\t\tconst near = candidates.reduce((n, e) => (Math.abs(e.x - event.x) < Math.abs(n.x - event.x) ? e : n));\n\t\t\t\t\tevent.tick = near.tick;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tfixedEvents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t// properties\n\t[...fixedEvents, ...pendingEvents].forEach((event) => {\n\t\tevent.grace = !Number.isFinite(event.tick) && event.predisposition!.grace;\n\t\tevent.timeWarped = event.predisposition!.timeWarped > 0.5;\n\t\tevent.fullMeasure = event.predisposition!.fullMeasure > 0.5;\n\t\tevent.stemDirection = STEM_DIRECTION_OPTIONS[argmax(event.predisposition!.stemDirectionVector)];\n\t\tevent.beam = BEAM_OPTIONS[argmax(event.predisposition!.beamVector)];\n\t});\n\n\t// construct matrixH\n\tconst ids = cluster.elements.map((e) => e.index);\n\tconst idx = (id: number): number => ids.indexOf(id);\n\tcluster.matrixH = cluster.elements.map(() => Array(cluster.elements.length).fill(0));\n\tfixedEvents.forEach((event, i) => {\n\t\tconst lastEvent = fixedEvents[i - 1];\n\t\tif (!lastEvent || lastEvent.order! < event.order! - 1) {\n\t\t\tcluster.matrixH![idx(event.index!)][0] = 1;\n\t\t\tif (lastEvent) cluster.matrixH![cluster.elements.length - 1][idx(lastEvent.index!)] = 1;\n\t\t} else {\n\t\t\tconsole.assert(\n\t\t\t\tcluster.matrixH![idx(event.index!)] && Number.isFinite(cluster.matrixH![idx(event.index!)][idx(lastEvent.index!)]),\n\t\t\t\t'matrixH out of range:',\n\t\t\t\tevent.index,\n\t\t\t\tlastEvent.index,\n\t\t\t\tcluster.matrixH!.length\n\t\t\t);\n\n\t\t\tcluster.matrixH![idx(event.index!)][idx(lastEvent.index!)] = 1;\n\t\t}\n\t});\n\tif (!pendingEvents.length && fixedEvents.length) cluster.matrixH![cluster.elements.length - 1][idx(fixedEvents[fixedEvents.length - 1].index!)] = 1;\n\n\treturn bestEvaluation!;\n};\n\ninterface BeadSolverOptions {\n\tpicker: BeadPicker;\n\tstopLoss?: number;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tptFactor?: number;\n\tlogger?: Logger;\n}\n\nconst solveMeasure = async (measure: SpartitoMeasure, options: BeadSolverOptions): Promise => {\n\tconst { stopLoss = 0.09, quotaMax = 1000, quotaFactor = 5, ptFactor = 1, logger = new DummyLogger() } = options;\n\n\tlet worstLoss = 0;\n\n\tconst clusters = measure.createClusters();\n\tfor (const cluster of clusters) {\n\t\tconst quota = Math.min(quotaMax, Math.ceil(cluster.elements.length * quotaFactor));\n\t\tlogger.info(`[measure-${measure.measureIndex}]`, quota);\n\t\tconst { loss } = await solveCluster(cluster, options.picker, logger, quota, stopLoss, ptFactor);\n\t\tworstLoss = Math.max(worstLoss, loss);\n\t}\n\n\tconst voices = [] as number[][];\n\n\tconst durations = [] as number[];\n\n\tconst solutionEvents = [] as RegulationSolutionEvent[];\n\n\tclusters.forEach((cluster) => {\n\t\tconst events = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\t\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t\tif (!events.length) return;\n\n\t\tlet voice = [] as number[];\n\t\tvoices.push(voice);\n\t\tlet lastOrder = 0;\n\t\tevents.forEach((event) => {\n\t\t\tif (event.fullMeasure || event.grace || event.tremoloCatcher) return;\n\n\t\t\tif (event.order! > lastOrder + 1) {\n\t\t\t\tvoice = [event.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t} else voice.push(event.index!);\n\n\t\t\tlastOrder = event.order!;\n\t\t});\n\n\t\tlet tipElem = events[events.length - 1];\n\n\t\t// complete voices from pending events\n\t\tconst pendingEvents = cluster.elements.filter(\n\t\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isFinite(elem.tick) && !Number.isInteger(elem.order)\n\t\t);\n\t\twhile (pendingEvents.length) {\n\t\t\tconst ei = pendingEvents.findIndex((e) => e.tick! >= tipElem.tick! + estimateElementDuration(tipElem));\n\t\t\tif (ei >= 0) voice.push(pendingEvents.splice(ei, 1)[0].index!);\n\t\t\telse {\n\t\t\t\ttipElem = pendingEvents.splice(0, 1)[0];\n\t\t\t\tvoice = [tipElem.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\t\t}\n\n\t\tif (events.some((elem) => !elem.fullMeasure && Number.isInteger(elem.order))) {\n\t\t\tconst eos = cluster.elements.find((elem) => elem.type === EventElementType.EOS);\n\t\t\tdurations.push(eos!.tick!);\n\t\t}\n\n\t\tconst eventMap = measure.eventMap;\n\n\t\tconst tickSet = cluster.elements.reduce((set, elem) => {\n\t\t\tif (Number.isFinite(elem.tick)) set.add(elem.tick!);\n\t\t\treturn set;\n\t\t}, new Set());\n\t\tconst ticks = Array.from(tickSet).sort((t1, t2) => t1 - t2);\n\n\t\t// fill solutionEvents\n\t\tevents.forEach((elem) => {\n\t\t\tconst event = eventMap[elem.index!];\n\t\t\tif (event) {\n\t\t\t\tsolutionEvents.push({\n\t\t\t\t\tid: event.id!,\n\t\t\t\t\ttick: elem.tick!,\n\t\t\t\t\ttickGroup: ticks.indexOf(elem.tick!),\n\t\t\t\t\tdivision: elem.division !== event.division ? elem.division : undefined,\n\t\t\t\t\tdots: elem.dots !== event.dots ? elem.dots : undefined,\n\t\t\t\t\ttimeWarp: elem.timeWarped ? frac(2, 3) : undefined, // TODO:\n\t\t\t\t\tbeam: elem.beam !== event.beam ? elem.beam : undefined,\n\t\t\t\t\tgrace: elem.grace !== !!event.grace ? elem.grace : undefined,\n\t\t\t\t\tfullMeasure: elem.fullMeasure || undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n\n\tconst estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n\n\treturn {\n\t\tvoices: voices.filter((voice) => voice.length),\n\t\tduration: Math.max(...durations),\n\t\tevents: solutionEvents,\n\t\tpriority: -worstLoss,\n\t\testimatedDuration,\n\t};\n};\n\ninterface GlimpseMeasureOptions {\n\tpicker: BeadPicker;\n\tresetSignatureForDoubtfulOnly?: boolean;\n}\n\nconst glimpseMeasure = async (measure: SpartitoMeasure, { picker, resetSignatureForDoubtfulOnly }: GlimpseMeasureOptions): Promise => {\n\tconst clusters = measure.createClusters();\n\tconst eventMap = measure.eventMap;\n\n\tfor (const cluster of clusters) {\n\t\tif (!resetSignatureForDoubtfulOnly || measure.doubtfulTimesig) cluster.signatureDuration = 0; // re-estimate measure duration\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\t\tawait picker.predictCluster(cluster, 1);\n\n\t\tcluster.elements\n\t\t\t.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type))\n\t\t\t.forEach((elem) => {\n\t\t\t\tconst event = eventMap[elem.index!];\n\t\t\t\tevent.predisposition = elem.predisposition!;\n\t\t\t});\n\t}\n\n\tmeasure.estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n};\n\nconst estimateMeasure = async (measure: SpartitoMeasure, picker: BeadPicker): Promise =>\n\tglimpseMeasure(measure, { picker, resetSignatureForDoubtfulOnly: true });\n\nexport { BeadPicker, solveCluster, solveMeasure, estimateMeasure, glimpseMeasure };\n","import { EventTerm } from './term';\nimport type { SpartitoMeasure } from './spartitoMeasure';\n\ninterface EventRectification {\n\tid: number;\n\tdivision?: number;\n\tdots?: number;\n}\n\n// Here suppose sum of pvals equal to 1.\nconst multinomial_1 = (pvals: number[]): number => {\n\tconst n = Math.random();\n\n\tlet s = 0;\n\tfor (let i = 0; i < pvals.length; ++i) {\n\t\ts += pvals[i];\n\t\tif (s > n) return i;\n\t}\n\n\treturn pvals.length - 1;\n};\n\nconst looseVector = (ns: number[], factor = 0.9): number[] => {\n\tconst logits = ns.map((n) => Math.log(n) * factor);\n\tconst n2 = logits.map(Math.exp);\n\n\tconst sum = n2.reduce((sum, x) => sum + x, 0);\n\n\treturn n2.map((x) => x / sum);\n};\n\nconst looseEvent = (event: EventTerm): EventTerm => {\n\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return event;\n\n\tconst divisionVector = event.predisposition?.divisionVector ? looseVector(event.predisposition.divisionVector) : null;\n\tconst dotsVector = event.predisposition?.dotsVector ? looseVector(event.predisposition.dotsVector) : null;\n\n\treturn new EventTerm({\n\t\t...event,\n\t\tpredisposition: {\n\t\t\t...event.predisposition,\n\t\t\tdivisionVector,\n\t\t\tdotsVector,\n\t\t},\n\t});\n};\n\nclass MeasureRectification {\n\tevents: EventRectification[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\ttoString(): string {\n\t\treturn this.events\n\t\t\t.map((event) => {\n\t\t\t\tif (!event) return '';\n\n\t\t\t\tconst { division = '', dots = '' } = event;\n\t\t\t\treturn `${division}|${dots}`;\n\t\t\t})\n\t\t\t.join(',');\n\t}\n\n\tstatic default(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tconst division = event.predisposition.divisionVector ? event.division : undefined;\n\t\t\t\tconst dots = event.predisposition.dotsVector ? event.dots : undefined;\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n\n\tstatic roll(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tlet division = undefined;\n\t\t\t\tlet dots = undefined;\n\n\t\t\t\tif (event.predisposition.divisionVector) division = multinomial_1(event.predisposition.divisionVector);\n\n\t\t\t\tif (event.predisposition.dotsVector) dots = multinomial_1(event.predisposition.dotsVector);\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n}\n\nconst genMeasureRectifications = function* (measure: SpartitoMeasure): Generator {\n\tconst keys = new Set();\n\n\tconst origin = MeasureRectification.default(measure.events);\n\tkeys.add(origin.toString());\n\n\tyield origin;\n\n\tlet stale = 0;\n\tlet events = measure.events;\n\n\twhile (stale < 100) {\n\t\tif (stale && stale % 10 === 0) events = events.map(looseEvent);\n\n\t\tconst rectification = MeasureRectification.roll(events);\n\t\tconst key = rectification.toString();\n\n\t\tif (keys.has(key)) {\n\t\t\t++stale;\n\t\t\tcontinue;\n\t\t}\n\n\t\tstale = 0;\n\n\t\tkeys.add(key);\n\t\tyield rectification;\n\t}\n};\n\nexport { MeasureRectification, genMeasureRectifications };\n","import { WeakLRUCache } from 'weak-lru-cache';\n\nimport { RegulationSolution, SpartitoMeasure } from '../../src/starry';\n\nconst lruCache = new WeakLRUCache();\n\ninterface SolutionStore {\n\tget: (key: string) => Promise;\n\tset: (key: string, val: RegulationSolution) => Promise;\n\tbatchGet: (keys: string[]) => Promise;\n}\n\n// 默认store\nconst DefaultSolutionStore: SolutionStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as RegulationSolution;\n\t},\n\tasync set(key: string, val: RegulationSolution) {\n\t\tlruCache.setValue(key, val);\n\t},\n\tasync batchGet(keys: string[]) {\n\t\treturn keys.map((key) => lruCache.getValue(key) as RegulationSolution);\n\t},\n};\n\nconst enum MeasureStatus {\n\tDiscard = -1,\n\tSolved = 0,\n\tIssue = 1,\n\tFatal = 2,\n}\n\ninterface IssueMeasure {\n\tscoreId: string;\n\tmeasureIndex: number;\n\tmeasure: SpartitoMeasure;\n\tstatus: MeasureStatus;\n}\n\ntype SaveIssueMeasure = (data: Omit) => void;\n\nexport { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure };\n","import * as starry from '../../src/starry';\nimport { Logger } from './ZeroClient';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure, MeasureStatus } from './store';\n\ninterface BeadRegulationCounting {\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface RegulationBeadStat {\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tmeasures: BeadRegulationCounting;\n\tqualityScore: number;\n}\n\ninterface RegulationBeadSummary {\n\tscoreN: number;\n\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tcostPerMeasure: number | null; // in milliseconds\n\tcostPerTime: number | null; // in milliseconds\n\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface ProgressInfo {\n\tpass: number;\n\tremaining: number;\n\ttotal: number;\n}\n\ninterface RegulateBeadOption {\n\tlogger?: Logger;\n\tpickers: starry.BeadPicker[];\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tfreshOnly?: boolean;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n\tonProgress?: (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => void;\n\tonPassStart?: (pass: number, conditionName: string, pendingCount: number) => void;\n}\n\ninterface MeasureReord {\n\torigin: starry.SpartitoMeasure;\n\tcurrent: starry.SpartitoMeasure;\n\tevaluation?: starry.MeasureEvaluation;\n\tbaseQuality: number;\n\tpicker: starry.BeadPicker;\n}\n\ninterface BeadSolverOptions {\n\tstopLoss: number;\n\tquotaMax: number;\n\tquotaFactor: number;\n\tptFactor: number;\n}\n\nenum PendingCondition {\n\tErrorOnly,\n\tNotFine,\n\tImperfect,\n}\n\nconst isPending = (evaluation: starry.MeasureEvaluation, condition: PendingCondition) => {\n\tswitch (condition) {\n\t\tcase PendingCondition.ErrorOnly:\n\t\t\treturn evaluation.error;\n\n\t\tcase PendingCondition.Imperfect:\n\t\t\treturn !evaluation.perfect;\n\t}\n\n\treturn !evaluation.fine;\n};\n\ntype OnUpdate = (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean) => void;\n\nconst solveMeasureRecords = async (\n\trecords: MeasureReord[],\n\tonUpdate: OnUpdate,\n\tstdout: NodeJS.WritableStream | null,\n\toptions: Partial,\n\tpendingCondition: PendingCondition = PendingCondition.NotFine,\n\tpass: number = 0,\n\tonProgress?: RegulateBeadOption['onProgress']\n): Promise => {\n\tconst pendingRecords = records.filter(({ evaluation }) => !evaluation || isPending(evaluation, pendingCondition));\n\tstdout?.write('.'.repeat(pendingRecords.length));\n\tstdout?.write('\\b'.repeat(pendingRecords.length));\n\n\tconst total = pendingRecords.length;\n\tlet done = 0;\n\n\tfor (const record of pendingRecords) {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tconst solution = await starry.beadSolver.solveMeasure(measure, { picker: record.picker, ...options });\n\t\tmeasure.applySolution(solution);\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better =\n\t\t\t!record.evaluation ||\n\t\t\tevaluation.fine > record.evaluation.fine ||\n\t\t\t(evaluation.qualityScore > record.evaluation.qualityScore && evaluation.fine === record.evaluation.fine);\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\t\t}\n\n\t\tonUpdate(record.current, evaluation, better);\n\n\t\tdone++;\n\t\tonProgress?.(record.current, evaluation, better, { pass, remaining: total - done, total });\n\t}\n\n\tif (pendingRecords.length) stdout?.write('\\n');\n\n\treturn pendingRecords.length;\n};\n\nconst regulateWithBeadSolver = async (\n\tscore: starry.Score,\n\t{ logger, pickers, solutionStore = DefaultSolutionStore, ignoreCache, freshOnly, onSaveIssueMeasure, onProgress, onPassStart }: RegulateBeadOption\n): Promise => {\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\tlogger?.info(`[regulateWithBeadSolver] begin, measure total: ${spartito.measures.length}.`, ignoreCache ? 'ignoreCache' : '', freshOnly ? 'freshOnly' : '');\n\n\tconst records = spartito.measures\n\t\t.filter((measure) => measure.events?.length && !measure.patched)\n\t\t.map(\n\t\t\t(measure) =>\n\t\t\t\t({\n\t\t\t\t\torigin: measure.deepCopy(),\n\t\t\t\t\tcurrent: measure,\n\t\t\t\t\tevaluation: undefined,\n\t\t\t\t\tbaseQuality: 0,\n\t\t\t\t} as MeasureReord)\n\t\t);\n\n\t// rectify time signature\n\tfor (const measure of spartito.measures.filter((measure) => measure.events?.length)) {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > measure.events.length + 1);\n\t\tif (picker) await starry.beadSolver.estimateMeasure(measure, picker);\n\t}\n\tspartito.rectifyTimeSignatures(logger as any);\n\n\t// zero pickers' cost\n\tpickers.forEach((picker) => (picker.cost = 0));\n\n\tconst counting = {\n\t\tcached: 0,\n\t\tsimple: 0,\n\t\tcomputed: 0,\n\t\ttryTimes: 0,\n\t\tsolved: 0,\n\t\tissue: 0,\n\t\tfatal: 0,\n\t};\n\n\tlogger?.info(`[regulateWithBeadSolver] measures estimation finished.`);\n\n\t// apply solutions\n\tif (solutionStore && !ignoreCache)\n\t\tfor (const record of records) {\n\t\t\tconst solution = await solutionStore.get(record.origin.regulationHash0);\n\t\t\tif (solution) {\n\t\t\t\trecord.current.applySolution(solution);\n\t\t\t\t++counting.cached;\n\n\t\t\t\trecord.evaluation = starry.evaluateMeasure(record.current);\n\t\t\t\trecord.baseQuality = record.evaluation.qualityScore;\n\t\t\t}\n\t\t}\n\n\tlogger?.info('[regulateWithBeadSolver]', `${counting.cached}/${records.length}`, 'solutions loaded.');\n\n\tconst stdout = logger ? null : process.stdout;\n\tif (counting.cached) stdout?.write(`${counting.cached}c`);\n\n\trecords.forEach((record) => {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > record.current.events.length + 1);\n\t\tif (!picker) {\n\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] size out of range:`, record.current.events.length);\n\t\t} else record.picker = picker;\n\t});\n\n\tconst pendingRecords = records.filter((record) => record.picker && (!record.evaluation || (!record.evaluation.fine && !freshOnly))) as (MeasureReord & {\n\t\tevaluation: starry.MeasureEvaluation;\n\t})[];\n\n\t// solve by simple policy\n\tpendingRecords.forEach((record) => {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tmeasure.regulate({ policy: 'simple' });\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better = !record.evaluation || evaluation.qualityScore > record.evaluation.qualityScore;\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\n\t\t\tif (evaluation.perfect) {\n\t\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] regulated by simple policy.`);\n\t\t\t\t++counting.simple;\n\t\t\t}\n\t\t}\n\t});\n\tcounting.computed = pendingRecords.length - counting.simple;\n\n\tif (counting.simple) stdout?.write(`${counting.simple}s`);\n\n\tconst onUpdate = (measure, evaluation, better) => {\n\t\tlogger?.info(\n\t\t\t`[regulateWithBeadSolver] measure[${measure.measureIndex}/${spartito.measures.length}] regulated${\n\t\t\t\tbetter ? '+' : '-'\n\t\t\t}: ${evaluation.qualityScore.toFixed(3)}, ${evaluation.fine ? 'solved' : evaluation.error ? 'error' : 'issue'}, ${measure.regulationHash}`\n\t\t);\n\n\t\tstdout?.write(`\\x1b[${evaluation.fine ? '32' : evaluation.error ? '31' : '33'}m${better ? '+' : '-'}\\x1b[0m`);\n\t};\n\n\t// Global progress: total = all measures, remaining = non-fine measures across all passes\n\tconst totalMeasures = spartito.measures.length;\n\tconst computeRemaining = () => pendingRecords.filter((r) => !r.evaluation?.fine).length;\n\tconst wrappedOnProgress = onProgress\n\t\t? (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => {\n\t\t\t\tonProgress(measure, evaluation, better, { pass: progress.pass, remaining: computeRemaining(), total: totalMeasures });\n\t\t }\n\t\t: undefined;\n\n\tonPassStart?.(1, 'Imperfect', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.05, quotaMax: 200, quotaFactor: 3, ptFactor: 1 },\n\t\tPendingCondition.Imperfect,\n\t\t1,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(2, 'NotFine', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 20, ptFactor: 1.6 },\n\t\tPendingCondition.NotFine,\n\t\t2,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(3, 'ErrorOnly', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 40, ptFactor: 3 },\n\t\tPendingCondition.ErrorOnly,\n\t\t3,\n\t\twrappedOnProgress\n\t);\n\n\tpendingRecords.forEach(({ evaluation, baseQuality, current, origin }) => {\n\t\tif (evaluation.fine) ++counting.solved;\n\t\telse if (evaluation.error) ++counting.fatal;\n\t\telse ++counting.issue;\n\n\t\tif (evaluation.qualityScore > baseQuality || !baseQuality) {\n\t\t\tsolutionStore.set(origin.regulationHash0, { ...current.asSolution(origin), priority: -current?.solutionStat?.loss! });\n\t\t\tif (current.regulationHash !== origin.regulationHash0)\n\t\t\t\tsolutionStore.set(current.regulationHash, { ...current.asSolution(), priority: -current?.solutionStat?.loss! });\n\t\t\t//console.log('better:', current.measureIndex, evaluation.qualityScore, baseQuality);\n\t\t}\n\n\t\tif (!evaluation.fine) {\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: current.measureIndex,\n\t\t\t\tmeasure: new starry.EditableMeasure(current),\n\t\t\t\tstatus: evaluation.error ? MeasureStatus.Fatal : MeasureStatus.Issue,\n\t\t\t});\n\t\t}\n\t});\n\n\tconst t1 = Date.now();\n\tconst pickerCost = pickers.reduce((cost, picker) => cost + picker.cost, 0);\n\n\tconst qualityScore = spartito.qualityScore;\n\tconst totalCost = t1 - t0;\n\n\tlogger?.info('[regulateWithBeadSolver] done in ', totalCost, 'ms, qualityScore:', qualityScore);\n\n\t// zero 'cached' statistics for freshOnly mode\n\tif (freshOnly) counting.cached = 0;\n\n\treturn {\n\t\ttotalCost: t1 - t0,\n\t\tpickerCost,\n\t\tmeasures: counting,\n\t\tqualityScore,\n\t};\n};\n\nconst abstractRegulationBeadStats = (stats: RegulationBeadStat[]): RegulationBeadSummary => {\n\tconst { totalCost, pickerCost, measureN, timeN } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\ttotalCost: sum.totalCost + stat.totalCost,\n\t\t\tpickerCost: sum.pickerCost + stat.pickerCost,\n\t\t\tmeasureN: sum.measureN + stat.measures.computed,\n\t\t\ttimeN: sum.timeN + stat.measures.tryTimes,\n\t\t}),\n\t\t{\n\t\t\ttotalCost: 0,\n\t\t\tpickerCost: 0,\n\t\t\tmeasureN: 0,\n\t\t\ttimeN: 0,\n\t\t}\n\t);\n\n\tconst costPerMeasure = measureN > 0 ? totalCost / measureN : null;\n\tconst costPerTime = timeN > 0 ? totalCost / timeN : null;\n\n\tconst { cached, simple, computed, tryTimes, solved, issue, fatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.measures.cached,\n\t\t\tsimple: sum.simple + stat.measures.simple,\n\t\t\tcomputed: sum.computed + stat.measures.computed,\n\t\t\ttryTimes: sum.tryTimes + stat.measures.tryTimes,\n\t\t\tsolved: sum.solved + stat.measures.solved,\n\t\t\tissue: sum.issue + stat.measures.issue,\n\t\t\tfatal: sum.fatal + stat.measures.fatal,\n\t\t}),\n\t\t{ cached: 0, simple: 0, computed: 0, tryTimes: 0, solved: 0, issue: 0, fatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\ttotalCost,\n\t\tpickerCost,\n\t\tcostPerMeasure,\n\t\tcostPerTime,\n\t\tcached,\n\t\tsimple,\n\t\tcomputed,\n\t\ttryTimes,\n\t\tsolved,\n\t\tissue,\n\t\tfatal,\n\t};\n};\n\nexport { regulateWithBeadSolver, abstractRegulationBeadStats, RegulationBeadStat, ProgressInfo };\n","import * as starry from '../../src/starry';\nimport { PyClients } from './predictors';\nimport { Logger } from './ZeroClient';\nimport { SpartitoMeasure, EditableMeasure, evaluateMeasure } from '../../src/starry';\nimport { EquationPolicy } from '../../src/starry/spartitoMeasure';\nimport { genMeasureRectifications } from '../../src/starry/measureRectification';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure } from './store';\nexport * from './regulationBead';\n\nglobalThis.btoa = globalThis.btoa || ((str) => Buffer.from(str, 'binary').toString('base64'));\n\nconst RECTIFICATION_SEARCH_ITERATIONS = parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS || '30');\nconst BASE_QUOTA_FACTOR = parseInt(process.env.BASE_QUOTA_FACTOR || '40');\nconst RECTIFICATION_QUOTA_FACTOR = parseInt(process.env.RECTIFICATION_QUOTA_FACTOR || '80');\n\nconst MATRIXH_INTERPOLATION_K = 0.9;\n\ninterface SolveMeasureOptions {\n\tsolver?: (...args: any[]) => any;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tlogger?: Logger;\n}\n\nconst computeQuota = (n: number, factor: number, limit: number) =>\n\tMath.min(Math.ceil((n + 1) * factor * Math.log(n + 2)), Math.ceil(limit * Math.min(1, (24 / (n + 1)) ** 2)));\n\ninterface BaseRegulationStat {\n\tcached: number;\n\tcomputed: number;\n\tsolved: number;\n}\n\nasync function solveMeasures(\n\tmeasures: SpartitoMeasure[],\n\t{ solver, quotaMax = 1000, quotaFactor = BASE_QUOTA_FACTOR, solutionStore = DefaultSolutionStore, ignoreCache = false, logger }: SolveMeasureOptions = {}\n): Promise {\n\tlet cached = 0;\n\tlet solved = 0;\n\n\tlogger?.info(`[solveMeasures] begin, measure total: ${measures.length}.`);\n\n\tawait Promise.all(\n\t\tmeasures.map(async (measure) => {\n\t\t\tif (!ignoreCache) {\n\t\t\t\tconst solution = await solutionStore.get(measure.regulationHash);\n\t\t\t\tif (solution) {\n\t\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\t\t++cached;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst quota = computeQuota(measure.events.length, quotaFactor, quotaMax);\n\n\t\t\tawait measure.regulate({\n\t\t\t\tpolicy: 'equations',\n\t\t\t\tquota,\n\t\t\t\tsolver,\n\t\t\t});\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tif (!stat.error) solutionStore.set(measure.regulationHash0, { ...measure.asSolution(), priority: -measure?.solutionStat?.loss! });\n\t\t\tif (stat.perfect) ++solved;\n\n\t\t\tlogger?.info(\n\t\t\t\t`[solveMeasures] measure[${measure.measureIndex}/${measures.length}] regulated: ${stat.perfect ? 'solved' : stat.error ? 'error' : 'issue'}, ${\n\t\t\t\t\tmeasure.regulationHash\n\t\t\t\t}`\n\t\t\t);\n\t\t})\n\t);\n\n\tlogger?.info(`[solveMeasures] ${cached}/${measures.length} cache hit, ${solved} solved.`);\n\n\treturn {\n\t\tcached,\n\t\tcomputed: measures.length - cached,\n\t\tsolved,\n\t};\n}\n\nconst solveMeasuresWithRectifications = async (\n\tmeasure: SpartitoMeasure,\n\t{ solver, quotaMax = 4000 }: SolveMeasureOptions\n): Promise => {\n\tlet best = evaluateMeasure(measure);\n\tlet bestSolution: starry.RegulationSolution = measure.asSolution();\n\tconst quota = computeQuota(measure.events.length, RECTIFICATION_QUOTA_FACTOR, quotaMax);\n\tlet n_rec = 0;\n\n\t// @ts-ignore\n\tfor (const rec of genMeasureRectifications(measure)) {\n\t\tconst solution = await EquationPolicy.regulateMeasureWithRectification(measure, rec, { solver, quota });\n\n\t\tconst testMeasure = measure.deepCopy() as SpartitoMeasure;\n\t\ttestMeasure.applySolution(solution);\n\t\tconst result = evaluateMeasure(testMeasure);\n\n\t\tif (\n\t\t\tresult.perfect > best.perfect ||\n\t\t\tresult.error < best.error ||\n\t\t\t(!result.error && result.perfect >= best.perfect && solution.priority! > bestSolution.priority!)\n\t\t) {\n\t\t\tbest = result;\n\t\t\tbestSolution = solution;\n\t\t}\n\n\t\tif (result.perfect) break;\n\n\t\t++n_rec;\n\t\tif (n_rec > RECTIFICATION_SEARCH_ITERATIONS) break;\n\t}\n\n\treturn bestSolution;\n};\n\ninterface RegulateWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateMaybeWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients?: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateSimpleOption {\n\tsolutionStore: SolutionStore;\n\tsolver: (...args: any[]) => any;\n\tlogger?: Logger;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n}\n\ninterface TopoRegulationStat {\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\nasync function doRegulateWithTopo(\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateWithTopoOption\n): Promise {\n\tpyClients.logger.info(`[RegulateWithTopo] regulate score: ${score.title}, measures: ${score.spartito!.measures.length}`);\n\n\tconst issueMeasures = score.spartito!.measures.filter((measure) => {\n\t\tconst stat = evaluateMeasure(measure);\n\t\treturn !stat.perfect;\n\t});\n\tpyClients.logger.info(`[RegulateWithTopo] basic issues: ${issueMeasures.length}`);\n\n\tif (issueMeasures.length === 0) {\n\t\treturn {\n\t\t\tsolved: 0,\n\t\t\tissue: 0,\n\t\t\tfatal: 0,\n\t\t};\n\t}\n\n\tconst clusters = ([] as starry.EventCluster[]).concat(...issueMeasures.map((measure) => measure.createClusters()));\n\tconst results = await pyClients.predictScoreImages('topo', { clusters });\n\tconsole.assert(results.length === clusters.length, 'prediction number mismatch:', clusters.length, results.length);\n\n\tclusters.forEach((cluster, index) => {\n\t\tconst result = results[index];\n\t\tconsole.assert(result, 'no result for cluster:', cluster.index);\n\n\t\tcluster.assignPrediction(result);\n\t});\n\n\tissueMeasures.forEach((measure) => {\n\t\tconst cs = clusters.filter((c) => c.index === measure.measureIndex);\n\t\tmeasure.applyClusters(cs);\n\n\t\t// intepolate matrixH\n\t\tconst { matrixH } = EquationPolicy.estiamteMeasure(measure);\n\t\tmatrixH.forEach((row, i) =>\n\t\t\trow.forEach((v, j) => {\n\t\t\t\tmeasure.matrixH[i][j] = measure.matrixH[i][j] * MATRIXH_INTERPOLATION_K + v * (1 - MATRIXH_INTERPOLATION_K);\n\t\t\t})\n\t\t);\n\t});\n\n\tconst solvedIndices: number[] = [];\n\tconst errorIndices: number[] = [];\n\n\t// rectification search\n\tawait Promise.all(\n\t\tissueMeasures.map(async (measure) => {\n\t\t\tconst hash = measure.regulationHash0;\n\t\t\tconst solution = await solveMeasuresWithRectifications(measure, { solver });\n\t\t\tif (solution) {\n\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\tsolutionStore.set(hash, solution);\n\t\t\t\tsolutionStore.set(measure.regulationHash, measure.asSolution());\n\t\t\t\tpyClients.logger.info(`[RegulateWithTopo] solutionStore set: ${measure.measureIndex}, ${hash}, ${measure.regulationHash}`);\n\t\t\t}\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\tmeasure: new EditableMeasure(measure),\n\t\t\t\tstatus: stat.error ? 2 : 1,\n\t\t\t});\n\t\t\tif (stat.perfect) solvedIndices.push(measure.measureIndex);\n\t\t\telse if (stat.error) errorIndices.push(measure.measureIndex);\n\t\t})\n\t);\n\n\tconst n_issues = issueMeasures.length - solvedIndices.length - errorIndices.length;\n\tpyClients.logger.info(`[RegulateWithTopo] score: ${score.title}, solved/issue/fatal: ${solvedIndices.length}/${n_issues}/${errorIndices.length}`);\n\tif (solvedIndices.length) pyClients.logger.info(`[RegulateWithTopo] solved measures: ${solvedIndices.join(', ')}`);\n\tif (errorIndices.length) pyClients.logger.info(`[RegulateWithTopo] error measures: ${errorIndices.join(', ')}`);\n\n\treturn {\n\t\tsolved: solvedIndices.length,\n\t\tissue: n_issues,\n\t\tfatal: errorIndices.length,\n\t};\n}\n\ninterface RegulationStat {\n\tbaseCost: number; // in milliseconds\n\ttopoCost: number; // in milliseconds\n\tbaseMeasures: BaseRegulationStat;\n\ttopoMeasures?: TopoRegulationStat;\n\tqualityScore: number;\n}\n\nconst doRegulate = async (\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateMaybeWithTopoOption\n): Promise => {\n\tpyClients?.logger?.info(`[doRegulate] score: ${score.title}`);\n\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\n\tconst baseMeasures = await solveMeasures(spartito.measures, { solver, quotaMax: 1000, solutionStore, logger: pyClients?.logger });\n\n\tconst t1 = Date.now();\n\n\tconst topoMeasures = pyClients ? await doRegulateWithTopo(score, { pyClients, solver, solutionStore, onSaveIssueMeasure }) : undefined;\n\n\tconst t2 = Date.now();\n\n\treturn {\n\t\tbaseCost: t1 - t0,\n\t\ttopoCost: t2 - t1,\n\t\tbaseMeasures,\n\t\ttopoMeasures,\n\t\tqualityScore: spartito.qualityScore,\n\t};\n};\n\nconst doSimpleRegulate = async (\n\tscore: starry.Score,\n\t{ solver, solutionStore = DefaultSolutionStore, logger, quotaMax = 240, quotaFactor = 16 }: RegulateSimpleOption\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\tconst measures = spartito.measures.filter((measure) => !measure.regulated);\n\n\tawait solveMeasures(measures, { solver, quotaMax, quotaFactor, solutionStore, logger });\n\n\tconsole.assert(score.spartito?.regulated, 'doSimpleRegulate: regulation incomplete:', spartito.measures.filter((measure) => !measure.regulated).length);\n};\n\nconst evaluateScoreQuality = async (score: starry.Score, options: RegulateSimpleOption): Promise => {\n\tif (!score.spartito?.regulated) await doSimpleRegulate(score, options);\n\n\treturn score.spartito!.regulated ? score.spartito!.qualityScore : null;\n};\n\ninterface RegulationSummary {\n\tscoreN: number;\n\n\tbaseCostTotal: number; // in milliseconds\n\ttopoCostTotal: number; // in milliseconds\n\tbaseCostPerMeasure: number | null; // in milliseconds\n\ttopoCostPerMeasure: number | null; // in milliseconds\n\n\tcached: number;\n\tbaseComputed: number;\n\tbaseSolved: number;\n\ttopoSolved: number;\n\ttopoIssue: number;\n\ttopoFatal: number;\n}\n\nconst abstractRegulationStats = (stats: RegulationStat[]): RegulationSummary => {\n\tconst { baseCostTotal, topoCostTotal, baseMeasures, topoMeasures } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tbaseCostTotal: sum.baseCostTotal + stat.baseCost,\n\t\t\ttopoCostTotal: sum.topoCostTotal + stat.topoCost,\n\t\t\tbaseMeasures: sum.baseMeasures + stat.baseMeasures.computed,\n\t\t\ttopoMeasures: sum.topoMeasures + (stat.topoMeasures!.solved + stat.topoMeasures!.issue + stat.topoMeasures!.fatal),\n\t\t}),\n\t\t{\n\t\t\tbaseCostTotal: 0,\n\t\t\ttopoCostTotal: 0,\n\t\t\tbaseMeasures: 0,\n\t\t\ttopoMeasures: 0,\n\t\t}\n\t);\n\n\tconst baseCostPerMeasure = baseMeasures > 0 ? baseCostTotal / baseMeasures : null;\n\tconst topoCostPerMeasure = topoMeasures > 0 ? topoCostTotal / topoMeasures : null;\n\n\tconst { cached, baseComputed, baseSolved, topoSolved, topoIssue, topoFatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.baseMeasures.cached,\n\t\t\tbaseComputed: sum.baseComputed + stat.baseMeasures.computed,\n\t\t\tbaseSolved: sum.baseSolved + stat.baseMeasures.solved,\n\t\t\ttopoSolved: sum.topoSolved + stat.topoMeasures!.solved,\n\t\t\ttopoIssue: sum.topoIssue + stat.topoMeasures!.issue,\n\t\t\ttopoFatal: sum.topoFatal + stat.topoMeasures!.fatal,\n\t\t}),\n\t\t{ cached: 0, baseComputed: 0, baseSolved: 0, topoSolved: 0, topoIssue: 0, topoFatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\tbaseCostTotal,\n\t\ttopoCostTotal,\n\t\tbaseCostPerMeasure,\n\t\ttopoCostPerMeasure,\n\t\tcached,\n\t\tbaseComputed,\n\t\tbaseSolved,\n\t\ttopoSolved,\n\t\ttopoIssue,\n\t\ttopoFatal,\n\t};\n};\n\nexport { doRegulate, doSimpleRegulate, evaluateScoreQuality, abstractRegulationStats };\n","import SparkMD5 from 'spark-md5';\n//import JSZip from 'jszip';\nimport * as starry from '../../src/starry';\n//import { encodeFindResource } from '../../src/isomorphic/converter';\nimport sharp, { FormatEnum } from 'sharp';\nimport got from 'got';\n//import { Logger } from './ZeroClient';\nimport type { SolutionStore, SaveIssueMeasure } from './store';\nimport { ScoreJSON } from '../../src/isomorphic/types';\n\nconst SYSTEM_MARGIN = 4;\n\nexport const constructSystem = ({ page, backgroundImage, detection, imageSize, position }) => {\n\tconst systemWidth = (detection.phi2 - detection.phi1) / detection.interval;\n\tconst systemHeight = imageSize.height / detection.interval;\n\n\tconst lastSystem = page.systems[page.systems.length - 1];\n\tconst top = position ? position.y : (lastSystem ? lastSystem.top + lastSystem.height : 0) + SYSTEM_MARGIN;\n\tconst left = position ? position.x : SYSTEM_MARGIN;\n\n\tconst stavesTops = [\n\t\t0,\n\t\t...Array(detection.middleRhos.length - 1)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => (detection.middleRhos[i] + detection.middleRhos[i + 1]) / 2 / detection.interval),\n\t];\n\n\tconst measureBars = [systemWidth];\n\n\tconst staves = stavesTops.map(\n\t\t(top, i) =>\n\t\t\tnew starry.Staff({\n\t\t\t\ttop,\n\t\t\t\theight: (stavesTops[i + 1] || systemHeight) - top,\n\t\t\t\tstaffY: detection.middleRhos[i] / detection.interval - top,\n\t\t\t\tmeasureBars,\n\t\t\t})\n\t);\n\n\t//console.log(\"detection:\", detection, options, stavesTops);\n\n\tconst imagePosition = {\n\t\tx: -detection.phi1 / detection.interval,\n\t\ty: 0,\n\t\twidth: imageSize.width / detection.interval,\n\t\theight: imageSize.height / detection.interval,\n\t};\n\n\treturn new starry.System({\n\t\tstaves,\n\t\tleft,\n\t\ttop,\n\t\twidth: systemWidth,\n\t\tbackgroundImage,\n\t\timagePosition,\n\t\tmeasureBars,\n\t});\n};\n\nexport interface ConvertOption {\n\tformat?: keyof FormatEnum;\n\tquality?: number;\n\tmaxHeight?: number;\n}\n\nconst toBuffer = async (url: string | Buffer): Promise => {\n\tif (typeof url === 'string') {\n\t\tif (/^https?:\\/\\//.test(url)) {\n\t\t\treturn (await got(url, { responseType: 'buffer', decompress: true, https: { rejectUnauthorized: false } })).body;\n\t\t}\n\n\t\tif (/^data:image\\//.test(url)) {\n\t\t\treturn Buffer.from(url.split(',')[1], 'base64');\n\t\t}\n\n\t\treturn Buffer.from(url);\n\t}\n\n\treturn url;\n};\n\n/**\n * 转换图片格式,默认webp、最大高度1080,高度小于1080自动不做尺寸变换\n * @param url\n * @param format\n * @param maxHeight\n * @param quality\n */\nexport async function convertImage(url: string | Buffer, { format = 'webp', maxHeight = 1080, quality = 80 }: ConvertOption = {}) {\n\tlet buf = await toBuffer(url);\n\n\tconst webpBuffer = await new Promise((resolve) => {\n\t\tsharp(buf)\n\t\t\t.resize({\n\t\t\t\twidth: maxHeight,\n\t\t\t\theight: maxHeight,\n\t\t\t\tfit: 'inside',\n\t\t\t\twithoutEnlargement: true,\n\t\t\t})\n\t\t\t.toFormat(format, { quality })\n\t\t\t.toBuffer((err, buf) => {\n\t\t\t\tresolve(buf);\n\t\t\t});\n\t});\n\n\tconst md5 = SparkMD5.ArrayBuffer.hash(webpBuffer);\n\n\treturn {\n\t\tbuffer: webpBuffer,\n\t\tfilename: `${md5}.${format}`,\n\t};\n}\n\n/**\n * 替换scoreJson图片地址\n * @param scoreJson\n * @param onReplaceImage\n */\nexport const replaceScoreJsonImages = (scoreJson: ScoreJSON, onReplaceImage: (src: string) => string = (src) => src) => {\n\tconst json = JSON.parse(JSON.stringify(scoreJson));\n\n\tjson.pages.forEach((page) => {\n\t\tpage?.src && (page.src = onReplaceImage(page?.src));\n\t});\n\n\tjson.lines.forEach((system) => {\n\t\tsystem.lineStaves.forEach((line) => {\n\t\t\tline.imgs.forEach((staff) => {\n\t\t\t\tstaff?.src && (staff.src = onReplaceImage(staff.src));\n\t\t\t});\n\t\t});\n\t});\n\n\treturn json;\n};\n\n/**\n * 获取scoreJson图片资源列表\n * @param scoreJson\n */\nexport const getScoreJsonImages = (scoreJson: ScoreJSON) => {\n\treturn [\n\t\t...scoreJson.pages.map((page) => page?.src),\n\t\t...scoreJson.lines\n\t\t\t.map((system) => system.lineStaves.map((staff) => staff.imgs))\n\t\t\t.flat(2)\n\t\t\t.map((staff) => staff?.src)\n\t\t\t.filter(Boolean),\n\t];\n};\n\ninterface ScorePatchesUpdateOptions {\n\tsolutionStore?: SolutionStore;\n}\n\nexport const updateScorePatches = (score: starry.Score, measures: starry.SpartitoMeasure[], options: ScorePatchesUpdateOptions = {}): void => {\n\tconsole.assert(\n\t\tmeasures.every((measure) => measure.validRegulated),\n\t\t'[updateScorePatches] some measures not valid regulated:',\n\t\tmeasures.filter((measure) => !measure.validRegulated)\n\t);\n\n\tscore.patches = measures.map((measure) => measure.createPatch());\n\n\tif (options?.solutionStore) {\n\t\tscore.assemble();\n\t\tconst spartito = score.makeSpartito();\n\n\t\tmeasures.forEach((measure) => {\n\t\t\toptions.solutionStore!.set(measure.regulationHash, { ...measure.asSolution(), priority: 1 });\n\t\t\tif (measure.regulationHash0 !== measure.regulationHash) {\n\t\t\t\tconst originMeasure = spartito.measures.find((m) => m.measureIndex === measure.measureIndex);\n\t\t\t\toptions.solutionStore!.set(measure.regulationHash0, { ...measure.asSolution(originMeasure), priority: 1 });\n\t\t\t}\n\t\t});\n\t}\n};\n\ninterface EditableMeasuresSaveOptions {\n\tstatus?: number;\n\tsolutionStore?: SolutionStore;\n}\n\nexport const saveEditableMeasures = async (\n\tscore: starry.Score,\n\tmeasureIndices: number[],\n\tsaveMeasure: SaveIssueMeasure,\n\t{ status = 2, solutionStore }: EditableMeasuresSaveOptions = {}\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\n\tconst measures = measureIndices\n\t\t.map((index) => spartito.measures.find((measure) => measure.measureIndex === index))\n\t\t.filter(Boolean) as starry.SpartitoMeasure[];\n\n\tif (solutionStore) {\n\t\tconst solutions = await solutionStore.batchGet(measures.map((measure) => measure.regulationHash0));\n\t\tmeasures.forEach((measure, i) => {\n\t\t\tconst solution = solutions[i];\n\t\t\tif (solution) measure.applySolution(solution);\n\t\t});\n\t}\n\n\tmeasures.forEach((measure) => {\n\t\tsaveMeasure({\n\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\tmeasure: new starry.EditableMeasure(measure),\n\t\t\tstatus,\n\t\t});\n\t});\n};\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T12:40:40.287Z`, '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;');\nimport '../../libs/browserComponents';\n\nexport * from '../../libs/predictors';\nexport * from '../../libs/regulation';\nexport * from '../../libs/util';\nexport * as starry from '../../../src/starry';\n"],"names":["eventsModule","events","EventEmitter","Request","pack","unpack","getPortPromise","defaultsDeep","PythonShell","inherits_browserModule","inheritsModule","require$$0","require$$1","util","getPort","sha1","pick","parser","parse","parseCode","grammar","GROUP_N_TO_PITCH","MIDDLE_C","mod7","argmax","Token.TokenClefs","Token.TokenOctshifts","Token.TokenTimesigsC","Token.TokenTimesigsN","MIDI","MidiSequence","Notation","MusicNotation","MidiPlayer","Config","Node","Navigator","Matcher","MidiUtils","require$$2","require$$3","require$$4","undefined","require","EquationSolver.Solver","erf","staffLayout.parseCode","measureLayout.parseCode","WeakLRUCache","starry.beadSolver.solveMeasure","starry.evaluateMeasure","starry.beadSolver.estimateMeasure","starry.EditableMeasure","starry.Staff","starry.System","got","sharp","SparkMD5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAU,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzE,UAAU,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;;;;;;ACsBxE,IAAI,CAAC,GAAG,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,KAAI;AACpD,IAAI,YAAY,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,UAAU;AACrD,IAAI,CAAC,CAAC,KAAK;AACX,IAAI,SAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;AAClD,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACjE,IAAG;AACH;AACA,IAAI,eAAc;AAClB,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,EAAE;AAC1C,EAAE,cAAc,GAAG,CAAC,CAAC,QAAO;AAC5B,CAAC,MAAM,IAAI,MAAM,CAAC,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,OAAO,CAAC,YAAY;AAClC,YAAA,OAAO,EAAE,IAAIL,eAAsB,CAAC,OAAO,CAAC;YAC5C,MAAM;AACN,SAAA,CAAC,CAAC;AACJ,KAAC,CAAC,CAAC;AACJ;;ACnNA,OAAO,CAAC,IAAI,CAAC,CAAA,+CAAA,CAAiD,EAAE,6EAA6E,EAAE,iFAAiF,CAAC;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"regulator.js","sources":["../../libs/browserComponents.ts","../../../node_modules/events/events.js","../../libs/async-queue.ts","../../libs/ZeroClient.ts","../../libs/PyProcessor.ts","../../../node_modules/util/support/isBuffer.js","../../../node_modules/util/node_modules/inherits/inherits_browser.js","../../../node_modules/util/node_modules/inherits/inherits.js","../../../node_modules/util/util.js","../../libs/predictors.ts","../../../src/starry/interfaces.ts","../../../src/starry/semanticPoint.ts","../../../src/starry/token.ts","../../../src/starry/aux_/typedJSON.ts","../../../src/measureLayout/measureLayout.ts","../../../src/measureLayout/grammar.jison.js","../../../src/measureLayout/parser.ts","../../../src/staffLayout/staffLayout.ts","../../../src/staffLayout/grammar.jison.js","../../../src/staffLayout/parser.ts","../../../src/starry/logger.ts","../../../src/starry/utils.ts","../../../src/starry/term.ts","../../../src/starry/measureEvaluator.ts","../../../src/starry/semanticGraph.ts","../../../src/starry/scoreComponents.ts","../../../src/starry/semanticTopology.ts","../../../src/performer/types.ts","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/stream.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifile.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/streamEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/midifileEx.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MIDI/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiSequence.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MusicNotation.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiPlayer.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/config.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/node.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/navigator.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/Matcher/index.js","../../../node_modules/@k-l-lambda/music-widgets/source/inc/MidiUtils.js","../../../node_modules/@k-l-lambda/music-widgets/index.js","../../../src/performer/notation.ts","../../../node_modules/crypto-js/core.js","../../../node_modules/crypto-js/sha256.js","../../../src/starry/hashVector.ts","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/equationSolver.ts","../../../src/starry/patch.ts","../../../src/starry/eventTopology.ts","../../../src/starry/spartitoMeasure.ts","../../../src/starry/spartito.ts","../../../src/starry/staffContext.ts","../../../src/starry/score.ts","../../../src/starry/editableMeasure.ts","../../../src/starry/beadSolver.ts","../../../src/starry/measureRectification.ts","../../libs/store.ts","../../libs/regulationBead.ts","../../libs/regulation.ts","../../libs/util.ts","../src/regulator.ts"],"sourcesContent":["globalThis.btoa = (str) => Buffer.from(str, 'binary').toString('base64');\nglobalThis.atob = (str) => Buffer.from(str, 'base64').toString('binary');\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","import { EventEmitter } from 'events';\n\ninterface DSPromiseOption {\n\ttimeout?: number;\n}\n\nexport function destructPromise(\n\toptions: DSPromiseOption = {}\n): [promise: Promise, resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void] {\n\tconst { timeout } = options;\n\tlet rs: (value: T | PromiseLike) => void;\n\tlet rj: (reason: any) => void;\n\n\treturn [\n\t\tnew Promise((resolve, reject) => {\n\t\t\trs = resolve;\n\t\t\trj = reject;\n\n\t\t\tif (timeout >= 0) setTimeout(rj, timeout, 'timeout');\n\t\t}),\n\t\trs,\n\t\trj,\n\t];\n}\n\ntype AsyncTask = [fn: (data: any) => Promise, payload: any, resolve: (data: any) => void, reject: (reason: any) => void];\n\nexport class AsyncQueue extends EventEmitter {\n\tprivate working = false;\n\n\ttasks: AsyncTask[];\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.working = false;\n\t\tthis.tasks = [];\n\t\tprocess.nextTick(() => {\n\t\t\tthis.emit('idle');\n\t\t});\n\t}\n\n\tprivate async _digest(item: AsyncTask) {\n\t\tthis.working = true;\n\n\t\tconst [taskFn, payload, resolve, reject] = item;\n\t\tawait taskFn(payload).then(resolve, reject);\n\n\t\tif (this.tasks.length > 0) {\n\t\t\tawait this._digest(this.tasks.shift());\n\t\t} else {\n\t\t\tthis.working = false;\n\t\t\tthis.emit('idle');\n\t\t}\n\t}\n\n\t/**\n\t * 添加队列任务\n\t * @param task\n\t * @param options\n\t */\n\taddTask(task: [AsyncTask[0], AsyncTask[1]], { timeout = 600000 }: { timeout?: number } = {}): Promise {\n\t\tconst [promise, resolve, reject] = destructPromise({ timeout });\n\n\t\tif (this.working) {\n\t\t\tthis.tasks.push([...task, resolve, reject]);\n\t\t} else {\n\t\t\tthis._digest([...task, resolve, reject]);\n\t\t}\n\n\t\treturn promise;\n\t}\n}\n","import { pack, unpack } from 'msgpackr';\nimport { Request } from 'zeromq';\nimport { AsyncQueue } from './async-queue';\n\ninterface Response {\n\tcode: number;\n\tmsg: string;\n\tdata?: any;\n}\n\nexport interface Logger {\n\tinfo: (...data: any[]) => void;\n\terror: (...data: any[]) => void;\n}\n\ntype PyArgs = any[];\ntype PyKwargs = Record;\n\nexport default class ZeroClient {\n\tlogger: Logger;\n\tprivate socket: Request;\n\tprivate queue: AsyncQueue = new AsyncQueue();\n\n\tprivate url: string;\n\n\tconstructor(logger: Logger = console) {\n\t\tthis.logger = logger;\n\t}\n\n\tbind(url?: string) {\n\t\turl && (this.url = url);\n\t\tthis.socket = new Request({\n\t\t\tsendTimeout: 15e3,\n\t\t\treceiveTimeout: 300e3,\n\t\t});\n\n\t\tthis.socket.connect(this.url);\n\t}\n\n\tprivate __request(payload) {\n\t\tlet retryTimes = 0;\n\n\t\tconst req = async (data) => {\n\t\t\ttry {\n\t\t\t\tif (this.socket.closed) this.bind();\n\t\t\t\treturn await this.socket.send(pack(data)).then(() => this.socket.receive());\n\t\t\t} catch (err) {\n\t\t\t\tif (retryTimes < 2) {\n\t\t\t\t\tretryTimes++;\n\t\t\t\t\tconsole.log(`请求失败,${err.stack}`);\n\t\t\t\t\tconsole.error(`3s后重试第${retryTimes}次`);\n\t\t\t\t\tthis.socket.close();\n\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 3000));\n\t\t\t\t\treturn req(data);\n\t\t\t\t} else {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn req(payload);\n\t}\n\n\tasync request(method: string, args: PyArgs | PyKwargs = null, kwargs: PyKwargs = null): Promise {\n\t\tconst [args_, kwargs_] = Array.isArray(args) ? [args, kwargs] : [undefined, args];\n\t\tconst msg: any = { method };\n\t\tif (args_) msg.args = args_;\n\t\tif (kwargs_) msg.kwargs = kwargs_;\n\n\t\treturn this.queue.addTask([\n\t\t\tasync (opt) => {\n\t\t\t\tconst [result] = await this.__request(opt);\n\n\t\t\t\tconst obj = unpack(result) as Response;\n\n\t\t\t\tif (obj.code === 0) {\n\t\t\t\t\treturn obj.data;\n\t\t\t\t} else {\n\t\t\t\t\treturn Promise.reject(obj.msg);\n\t\t\t\t}\n\t\t\t},\n\t\t\tmsg,\n\t\t]);\n\t}\n}\n","import { getPortPromise } from 'portfinder';\nimport { Options, PythonShell } from 'python-shell';\nimport { defaultsDeep } from 'lodash';\nimport ZeroClient, { Logger } from './ZeroClient';\n\nexport default class PyProcessor extends ZeroClient {\n\tprivate readonly scriptPath: string;\n\tprivate readonly options: Options;\n\tprivate pyShell: PythonShell;\n\n\tprivate retryCount: number = 0;\n\tprivate retryDelay: number = 3000;\n\n\tconstructor(scriptPath: string, options: Options = {}, logger: Logger = console) {\n\t\tsuper(logger);\n\t\tthis.scriptPath = scriptPath;\n\t\tthis.options = options;\n\t}\n\n\tasync bind(port?: string | number) {\n\t\tconst freePort =\n\t\t\tport ||\n\t\t\t(await getPortPromise({\n\t\t\t\tport: 12022,\n\t\t\t\tstopPort: 12122,\n\t\t\t}));\n\n\t\t// \"./streamPredictor.py\", \"--inspect\"\n\t\tconst options = defaultsDeep(\n\t\t\t{\n\t\t\t\targs: [...(this.options.args || []), '-p', `${freePort}`],\n\t\t\t},\n\t\t\tthis.options\n\t\t);\n\n\t\tthis.logger.info(`[python-shell]: starting python shell. path: ${this.scriptPath}`);\n\n\t\tthis.pyShell = new PythonShell(this.scriptPath, options);\n\n\t\tthis.pyShell.stdout.on('data', (data) => this.logger.info(data));\n\n\t\tthis.pyShell.on('pythonError', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} pythonError:`, err));\n\t\tthis.pyShell.on('stderr', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} stderr:`, err));\n\t\tthis.pyShell.on('error', (err) => this.logger.error(`[python-shell]: ${this.scriptPath} error:`, err));\n\t\tthis.pyShell.on('close', () => {\n\t\t\t// python子进程关闭事件\n\t\t\tif (this.retryCount < 5) {\n\t\t\t\tthis.retryCount++;\n\t\t\t\tthis.logger.info(`[python-shell]: ${this.scriptPath} will retry ${this.retryCount}th time after 3 seconds`);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.bind();\n\t\t\t\t}, this.retryDelay);\n\t\t\t}\n\t\t});\n\n\t\tsuper.bind(`tcp://127.0.0.1:${freePort}`);\n\t}\n}\n","module.exports = function isBuffer(arg) {\n return arg instanceof Buffer;\n}\n","if (typeof Object.create === 'function') {\n // implementation from standard node.js 'util' module\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n // old school shim for old browsers\n module.exports = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor\n var TempCtor = function () {}\n TempCtor.prototype = superCtor.prototype\n ctor.prototype = new TempCtor()\n ctor.prototype.constructor = ctor\n }\n}\n","try {\n var util = require('util');\n if (typeof util.inherits !== 'function') throw '';\n module.exports = util.inherits;\n} catch (e) {\n module.exports = require('./inherits_browser.js');\n}\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(obj) {\n var keys = Object.keys(obj);\n var descriptors = {};\n for (var i = 0; i < keys.length; i++) {\n descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);\n }\n return descriptors;\n };\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n};\n\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nexports.deprecate = function(fn, msg) {\n if (typeof process !== 'undefined' && process.noDeprecation === true) {\n return fn;\n }\n\n // Allow for deprecating things in the process of starting up.\n if (typeof process === 'undefined') {\n return function() {\n return exports.deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n};\n\n\nvar debugs = {};\nvar debugEnviron;\nexports.debuglog = function(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = process.pid;\n debugs[set] = function() {\n var msg = exports.format.apply(exports, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n};\n\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n exports._extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\nexports.inspect = inspect;\n\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== exports.inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\nexports.isArray = isArray;\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\nexports.isBoolean = isBoolean;\n\nfunction isNull(arg) {\n return arg === null;\n}\nexports.isNull = isNull;\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\nexports.isNullOrUndefined = isNullOrUndefined;\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\nexports.isNumber = isNumber;\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\nexports.isString = isString;\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\nexports.isSymbol = isSymbol;\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\nexports.isUndefined = isUndefined;\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\nexports.isRegExp = isRegExp;\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\nexports.isObject = isObject;\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\nexports.isDate = isDate;\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\nexports.isError = isError;\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\nexports.isFunction = isFunction;\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\nexports.isPrimitive = isPrimitive;\n\nexports.isBuffer = require('./support/isBuffer');\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nexports.log = function() {\n console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));\n};\n\n\n/**\n * Inherit the prototype methods from one constructor into another.\n *\n * The Function.prototype.inherits from lang.js rewritten as a standalone\n * function (not on Function.prototype). NOTE: If this file is to be loaded\n * during bootstrapping this function needs to be rewritten using some native\n * functions as prototype setup using normal JavaScript does not work as\n * expected during bootstrapping (see mirror.js in r114903).\n *\n * @param {function} ctor Constructor function which needs to inherit the\n * prototype.\n * @param {function} superCtor Constructor function to inherit prototype from.\n */\nexports.inherits = require('inherits');\n\nexports._extend = function(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n};\n\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nvar kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;\n\nexports.promisify = function promisify(original) {\n if (typeof original !== 'function')\n throw new TypeError('The \"original\" argument must be of type Function');\n\n if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {\n var fn = original[kCustomPromisifiedSymbol];\n if (typeof fn !== 'function') {\n throw new TypeError('The \"util.promisify.custom\" argument must be of type Function');\n }\n Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return fn;\n }\n\n function fn() {\n var promiseResolve, promiseReject;\n var promise = new Promise(function (resolve, reject) {\n promiseResolve = resolve;\n promiseReject = reject;\n });\n\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n args.push(function (err, value) {\n if (err) {\n promiseReject(err);\n } else {\n promiseResolve(value);\n }\n });\n\n try {\n original.apply(this, args);\n } catch (err) {\n promiseReject(err);\n }\n\n return promise;\n }\n\n Object.setPrototypeOf(fn, Object.getPrototypeOf(original));\n\n if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {\n value: fn, enumerable: false, writable: false, configurable: true\n });\n return Object.defineProperties(\n fn,\n getOwnPropertyDescriptors(original)\n );\n}\n\nexports.promisify.custom = kCustomPromisifiedSymbol\n\nfunction callbackifyOnRejected(reason, cb) {\n // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).\n // Because `null` is a special error value in callbacks which means \"no error\n // occurred\", we error-wrap so the callback consumer can distinguish between\n // \"the promise rejected with null\" or \"the promise fulfilled with undefined\".\n if (!reason) {\n var newReason = new Error('Promise was rejected with a falsy value');\n newReason.reason = reason;\n reason = newReason;\n }\n return cb(reason);\n}\n\nfunction callbackify(original) {\n if (typeof original !== 'function') {\n throw new TypeError('The \"original\" argument must be of type Function');\n }\n\n // We DO NOT return the promise as it gives the user a false sense that\n // the promise is actually somehow related to the callback's execution\n // and that the callback throwing will reject the promise.\n function callbackified() {\n var args = [];\n for (var i = 0; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n\n var maybeCb = args.pop();\n if (typeof maybeCb !== 'function') {\n throw new TypeError('The last argument must be of type Function');\n }\n var self = this;\n var cb = function() {\n return maybeCb.apply(self, arguments);\n };\n // In true node style we process the callback on `nextTick` with all the\n // implications (stack, `uncaughtException`, `async_hooks`)\n original.apply(this, args)\n .then(function(ret) { process.nextTick(cb, null, ret) },\n function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });\n }\n\n Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));\n Object.defineProperties(callbackified,\n getOwnPropertyDescriptors(original));\n return callbackified;\n}\nexports.callbackify = callbackify;\n","import ZeroClient, { Logger } from './ZeroClient';\nimport * as starry from '../../src/starry';\nimport PyProcessor from './PyProcessor';\nimport { destructPromise } from './async-queue';\nimport { getPort } from 'portfinder';\nimport util from 'util';\nimport { Options } from 'python-shell';\n\nconst getPortPromise = util.promisify(getPort);\n\nexport interface LayoutResult {\n\tdetection: starry.PageLayout;\n\ttheta: number;\n\tinterval: number;\n\tsourceSize?: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n}\n\nexport interface PredictorInterface {\n\tlayout: (streams: Buffer[]) => LayoutResult[];\n\tlayout$reinforce: (streams: Buffer[], baseLayouts: LayoutResult[]) => LayoutResult[];\n\tgauge: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tmask: (streams: Buffer[]) => {\n\t\timage: Buffer;\n\t}[];\n\tsemantic: (streams: Buffer[]) => any[];\n\ttextLoc: (streams: Buffer[]) => any[];\n\ttextOcr: (params: { buffers: Buffer[]; location: any[] }) => any[];\n\tbrackets: (params: { buffers: Buffer[] }) => any[];\n\ttopo: (params: { clusters: starry.EventCluster[] }) => any[];\n\tgaugeRenderer: (params: [Buffer, Buffer, number]) => { buffer: Buffer; size: { width: number; height: number } };\n\tjianpu: (params: { buffers: Buffer[] }) => any[];\n\t// [source: Buffer, gauge: Buffer, baseY: number]\n}\n\ntype PredictorType = keyof PredictorInterface;\n\nexport type PyClientsConstructOptions = Partial>;\n\nexport class PyClients {\n\tclients = new Map>();\n\n\tconstructor(public readonly options: PyClientsConstructOptions, public readonly logger: Logger = console) {}\n\n\tasync getClient(type: PredictorType) {\n\t\tif (this.clients.has(type)) {\n\t\t\treturn this.clients.get(type);\n\t\t}\n\n\t\tconst [promise, resolve, reject] = destructPromise();\n\n\t\tconst opt = this.options[type];\n\n\t\tif (!opt) {\n\t\t\tthrow new Error(`no config for client \\`${type}\\` found`);\n\t\t}\n\n\t\ttry {\n\t\t\tif (typeof opt === 'string') {\n\t\t\t\tconst client = new ZeroClient();\n\t\t\t\tclient.bind(opt);\n\t\t\t\tresolve(client);\n\t\t\t} else {\n\t\t\t\tconst { scriptPath, ...option } = opt;\n\t\t\t\tconst client = new PyProcessor(scriptPath, option, this.logger);\n\t\t\t\tawait client.bind(`${await getPortPromise()}`);\n\t\t\t\tresolve(client);\n\t\t\t}\n\n\t\t\tthis.logger.info(`PyClients: ${type} started`);\n\t\t} catch (err) {\n\t\t\tthis.logger.error(`PyClients: ${type} start fail: ${JSON.stringify(err)}`);\n\t\t\treject(err);\n\t\t}\n\n\t\tthis.clients.set(type, promise);\n\n\t\treturn promise;\n\t}\n\n\tasync checkHost(type: PredictorType): Promise {\n\t\tconst client = await this.getClient(type);\n\n\t\treturn client.request('checkHost');\n\t}\n\n\tasync warmup() {\n\t\tconst opts = Object.keys(this.options) as PredictorType[];\n\t\tawait Promise.all(opts.map((type) => this.getClient(type)));\n\t}\n\n\t/**\n\t * 模型预测\n\t * @param type layout | mask | gauge | semantic\n\t * @param args\n\t */\n\tasync predictScoreImages(type: T, ...args: Parameters): Promise> {\n\t\tconst clientType = type.split('$')[0] as PredictorType;\n\t\tconst client = await this.getClient(clientType);\n\t\tlet res = null;\n\n\t\tthis.logger.info(`[predictor]: ${type} py start..`);\n\t\tconst start = Date.now();\n\n\t\tswitch (type) {\n\t\t\tcase 'layout':\n\t\t\t\tres = await client.request('predictDetection', args);\n\t\t\t\tbreak;\n\t\t\tcase 'layout$reinforce':\n\t\t\t\tres = await client.request('predictReinforce', args);\n\t\t\t\tbreak;\n\t\t\tcase 'gauge':\n\t\t\tcase 'mask':\n\t\t\t\tres = await client.request('predict', args, { by_buffer: true });\n\t\t\t\tbreak;\n\t\t\tcase 'semantic':\n\t\t\tcase 'textLoc':\n\t\t\t\tres = await client.request('predict', args);\n\t\t\t\tbreak;\n\t\t\tcase 'textOcr':\n\t\t\tcase 'brackets':\n\t\t\tcase 'topo':\n\t\t\tcase 'gaugeRenderer':\n\t\t\tcase 'jianpu':\n\t\t\t\tres = await client.request('predict', ...args);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthis.logger.error(`[predictor]: no predictor ${type}`);\n\t\t}\n\n\t\tthis.logger.info(`[predictor]: ${type} py duration: ${Date.now() - start}ms`);\n\n\t\treturn res;\n\t}\n}\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Term, EventTerm, ContextedTerm, ChordmodeTerm, MarkTerm, Accessory, GraceType, TremoloLink } from './term';\nimport { HashVector } from './hashVector';\nimport { StaffLayout } from '../staffLayout';\nimport * as measureLayout from '../measureLayout';\n\ninterface Rect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\ninterface ChordRect {\n\tx: number;\n\tstemX: number;\n\twidth: number;\n\ttop: number;\n\tbottom: number;\n\tstemDirection: string;\n\ttip?: { x: number; y: number };\n}\n\ninterface VLine {\n\tx: number;\n\ty1: number;\n\ty2: number;\n}\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ntype DivisionVecotor = [number, number, number, number, number, number, number, number, number]; // [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\ntype MeasureBarType = null | 'Terminal' | 'Segment' | 'VoltaRight';\n\ninterface EventFeature {\n\tdivisions: DivisionVecotor;\n\tdots: [number, number]; // [1, 2]\n\tbeams: [number, number, number]; // ['Open', 'Continue', 'Close']\n\tstemDirections: [number, number]; // ['u', 'd']\n\tgrace: number;\n\ttremoloCatcher: number;\n}\n\ninterface EventPredisposition {\n\tgrace: boolean;\n\ttimeWarped: number;\n\tfullMeasure: number;\n\tfake: number;\n\tfakeP: number;\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tdivisionVector: DivisionVecotor;\n\tdotsVector: [number, number, number]; // [0, 1, 2]\n\tbeamVector: [number, number, number, number]; // [null, open, continue, close]\n\tstemDirectionVector: [number, number, number]; // [null, up, down]\n}\n\ninterface ChordColumn {\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\tys: number[];\n\tnoteIds: string[]; // order by upwards\n\tdivision: number;\n\tdots: number;\n\trest: boolean;\n\tstemDirection: string;\n\taccessories?: Accessory[];\n\tgrace?: GraceType;\n\ttremolo?: number;\n\ttremoloLink?: TremoloLink;\n\tbeam?: string;\n\ttip?: { x: number; y: number };\n\n\t//stemTipY?: number;\n\n\t// for topology\n\tstaff?: number;\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature?: EventFeature;\n}\n\ninterface EventMeasure {\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[];\n}\n\ninterface StaffBasic {\n\ttimeSignature: Fraction;\n\ttimeSigNumeric: boolean;\n\tkeySignature: number;\n\tdoubtfulTimesig: boolean;\n}\n\ninterface EventMeasureColumn {\n\tmeasureIndex: number;\n\t//startX: number;\n\t//width: number;\n\n\trows: EventMeasure[]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\txMap?: Map;\n\tregularLoss?: number;\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n}\n\ninterface EventSystem {\n\tstaffMask: number;\n\tcolumns: EventMeasureColumn[]; // [measure]\n}\n\ninterface TermMeasure extends Partial {\n\tterms: Term[];\n\tduration: number;\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n}\n\ntype TermRow = TermMeasure[];\n\ninterface TermStaff {\n\trows: TermRow[]; // [system]\n}\n\ninterface Pitch {\n\tnote: number;\n\talter: number;\n}\n\nenum PageLayoutMethod {\n\tByLines = 'ByLines',\n\tByBlocks = 'ByBlocks',\n}\n\ninterface RecognitionSettings {\n\tenabledGauge: boolean; // staves straighten\n\tpageLayoutMethod: PageLayoutMethod;\n\tsemanticConfidenceThreshold: number;\n}\n\ninterface Crop {\n\taspect?: number | undefined;\n\tx?: number | undefined;\n\ty?: number | undefined;\n\twidth?: number | undefined;\n\theight?: number | undefined;\n\tunit?: 'px' | '%' | undefined;\n}\n\n//\t0 2 4\t\t\tr r tx\n//\t1 3 5\t\t\tr r ty\ntype Matrix2x3 = [number, number, number, number, number, number];\n\ninterface SourceImageFile {\n\tname: string;\n\tsize: number;\n\turl: string;\n\tcrop?: Crop;\n\tmatrix: Matrix2x3;\n\tdimensions: {\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tinterval: number;\n\tneedGauge?: boolean;\n}\n\ninterface Area extends Rect {\n\tstaves: {\n\t\tinterval: number;\n\t\tmiddleRhos: number[];\n\t\tphi1: number;\n\t\tphi2: number;\n\t};\n}\n\ninterface PageLayout {\n\tareas: Area[];\n}\n\ninterface MeasureBrief {\n\ttimeSignature: Fraction;\n}\n\ninterface VoiceMeasure {\n\ttickMap: { [key: number]: EventTerm | ChordmodeTerm };\n\tduration: number;\n\n\ttimeSignature?: Fraction;\n\ttimeSigNumeric?: boolean;\n\tkeySignature?: number;\n\n\tcontextedTerms: ContextedTerm[];\n\tmarks: MarkTerm[];\n\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbar?: string;\n\n\tempty?: boolean;\n\n\theadStaff?: number;\n\ttailStaff?: number;\n\n\ttrait?: HashVector;\n\tvoiceIndex?: number;\n}\n\ninterface TermVoice {\n\tmode: string;\n\tmeasures: VoiceMeasure[];\n}\n\ninterface VoicesStaff {\n\tcontext?: string;\n\tname?: string;\n\tvoices: TermVoice[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n\tslashSystemSeparator: boolean;\n}\n\ninterface MusicHeaders {\n\ttitle: string;\n\tsubtitle: string;\n\tsubsubtitle: string;\n\tcomposer: string;\n\tpoet: string;\n\tarranger: string;\n\topus: string;\n\tcopyright: string;\n\tinstrument: string;\n\tdedication: string;\n\ttagline: string;\n}\n\ninterface MusicSheet {\n\ttitle: string;\n\tpageSize: {\n\t\t// in pixels\n\t\twidth: number;\n\t\theight: number;\n\t};\n\tunitSize: number;\n\tmeasureLayout?: measureLayout.MeasureLayout;\n\tstaffLayout: StaffLayout;\n\tpaperOptions?: Partial;\n\theaders: Partial;\n\n\tvoiceStaves: VoicesStaff[];\n\tinstrumentDict: { [key: string]: string };\n}\n\ninterface Performing {\n\tnotation: MetaNotation;\n\ttokenMap: Map;\n}\n\ntype RegulationPolicy = 'test' | 'simple' | 'equations' | 'advanced';\n\ninterface RegulationOptions {\n\tpolicy?: RegulationPolicy;\n\tquota?: number;\n\t[key: string]: any;\n}\n\ninterface ScoreData {\n\tversion?: number;\n\t[key: string]: any;\n}\n\ninterface AdditionalLineStack {\n\tleft: number;\n\tright: number;\n\tn: number;\n}\n\ninterface RegulationSolutionEvent {\n\tid: number;\n\ttick: number;\n\ttickGroup: number;\n\ttimeWarp: Fraction;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: string;\n\tgrace?: boolean;\n\tfullMeasure?: boolean;\n}\n\ninterface RegulationSolution {\n\tevents: RegulationSolutionEvent[];\n\tvoices: number[][];\n\tduration: number;\n\tpriority?: number;\n\testimatedDuration?: number;\n\ttimeSignature?: Fraction;\n}\n\ninterface BackgroundImage {\n\turl: string;\n\tposition: Rect;\n\toriginal?: boolean;\n}\n\nenum TextType { //\tLEVEL\t\t\tCHARSET\n\tTitle = 'Title', // page\t\t\t\tgeneral\n\tAuthor = 'Author', // page\t\t\t\tgeneral\n\tTempoText = 'TempoText', // measure\t\t\tspecific vocabulary\n\tTempoNumeral = 'TempoNumeral', // measure\t\t\tsymbolic and numeric\n\tTextualMark = 'TextualMark', // term\t\t\t\tspecific vocabulary\n\tLyric = 'Lyric', // term\t\t\t\tgeneral\n\tInstrument = 'Instrument', // system\t\t\tspecific vocabulary\n\tMeasureNumber = 'MeasureNumber', // system\t\t\tnumeric\n\tTimes = 'Times', // staff\t\t\tnumeric\n\tAlternation1 = 'Alternation1', // measure\t\t\tnumeric\n\tAlternation2 = 'Alternation2', // measure\t\t\tnumeric\n\tChord = 'Chord', // measure\t\t\tspecific domian\n\tPageMargin = 'PageMargin', // page\t\t\t\tgeneral\n\tOther = 'Other', // page\t\t\t\tgeneral\n}\n\nexport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tFraction,\n\tMeasureBarType,\n\tEventFeature,\n\tEventPredisposition,\n\tChordColumn,\n\tEventMeasure,\n\tEventMeasureColumn,\n\tEventSystem,\n\tTermMeasure,\n\tTermRow,\n\tTermStaff,\n\tPitch,\n\tPageLayoutMethod,\n\tRecognitionSettings,\n\tSourceImageFile,\n\tPageLayout,\n\tStaffBasic,\n\tVoiceMeasure,\n\tVoicesStaff,\n\tTermVoice,\n\tMeasureBrief,\n\tAdditionalLineStack,\n\tTextType,\n\tMusicSheet,\n\tPerforming,\n\tRegulationOptions,\n\tScoreData,\n\tMusicHeaders,\n\tMatrix2x3,\n\tRegulationSolutionEvent,\n\tRegulationSolution,\n\tBackgroundImage,\n};\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","import { TextType } from './interfaces';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\n\nenum TokenType {\n\t// clefs\n\tClefG = 'clefs-G', // clefs.G_change\n\tClefF = 'clefs-F', // clefs.F_change\n\tClefC = 'clefs-C', // clefs.C_change\n\n\t// time signature\n\tTimesigC44 = 'timesig-C44',\n\tTimesigC22 = 'timesig-C22',\n\tTimesigZero = 'zero|timesig0',\n\tTimesigOne = 'one|timesig1',\n\tTimesigTwo = 'two|timesig2',\n\tTimesigThree = 'three|timesig3',\n\tTimesigFour = 'four|timesig4',\n\tTimesigFive = 'five|timesig5',\n\tTimesigSix = 'six|timesig6',\n\tTimesigSeven = 'seven|timesig7',\n\tTimesigEight = 'eight|timesig8',\n\tTimesigNine = 'nine|timesig9',\n\n\t// octave shifts\n\tOctaveShift8va = 'octave-a',\n\tOctaveShift8vb = 'octave-b',\n\tOctaveShift0 = 'octave-0',\n\n\t// numbers\n\tZero = 'zero|n0',\n\tOne = 'one|n1',\n\tTwo = 'two|n2',\n\tThree = 'three|n3',\n\tFour = 'four|n4',\n\tFive = 'five|n5',\n\tSix = 'six|n6',\n\tSeven = 'seven|n7',\n\tEight = 'eight|n8',\n\tNine = 'nine|n9',\n\n\t// accidentals\n\tAccNatural = 'accidentals-natural',\n\tAccSharp = 'accidentals-sharp',\n\tAccDoublesharp = 'accidentals-doublesharp',\n\tAccFlat = 'accidentals-flat',\n\tAccFlatflat = 'accidentals-flatflat',\n\tKeyNatural = 'accidentals-natural|key-natural',\n\tKeySharp = 'accidentals-sharp|key-sharp',\n\tKeyFlat = 'accidentals-flat|key-flat',\n\n\t// noteheads\n\tNoteheadS0 = 'noteheads-s0',\n\tNoteheadS1 = 'noteheads-s1',\n\tNoteheadS2 = 'noteheads-s2',\n\tNoteheadS1stemU = 'noteheads-s1|noteheads-s1-u',\n\tNoteheadS1stemD = 'noteheads-s1|noteheads-s1-d',\n\tNoteheadS2stemU = 'noteheads-s2|noteheads-s2-u',\n\tNoteheadS2stemD = 'noteheads-s2|noteheads-s2-d',\n\n\t// rests\n\tRest0 = 'rests-0o',\n\tRest1 = 'rests-1o',\n\tRest2 = 'rests-2',\n\tRest3 = 'rests-3',\n\tRest4 = 'rests-4',\n\tRest5 = 'rests-5',\n\tRest6 = 'rests-6',\n\tRest0W = 'rests-0',\n\tRestM1 = 'rests-M1',\n\n\t// flags\n\tFlag3 = 'flags-u3', // flags.d3\n\tFlag4 = 'flags-u4', // flags.d4\n\tFlag5 = 'flags-u5', // flags.d5\n\tFlag6 = 'flags-u6', // flags.d6\n\tFlag7 = 'flags-u7', // flags.d7\n\tFlag8 = 'flags-u8', // flags.d8\n\n\t// beams\n\tBeamLeft = '|beam-left',\n\tBeamRight = '|beam-right',\n\tBeamContinue = '|beam-continue',\n\n\t// tremolos\n\tTremoloLeft = '|tremolo-left',\n\tTremoloRight = '|tremolo-right',\n\tTremoloMiddle = '|tremolo-middle',\n\n\t// slur & tie\n\tSlurBegin = '|slur-begin',\n\tSlurEnd = '|slur-end',\n\tTieBegin = '|tie-begin',\n\tTieEnd = '|tie-end',\n\n\t// volta\n\tVoltaLeft = '|volta-left',\n\tVoltaRight = '|volta-right',\n\n\tVoltaAlternativeBegin = '|volta-alter-begin',\n\t//VoltaAlternativeEnd = \"|volta-alter-end\",\n\n\t// vertical bars\n\t//BarMeasure = \"|bar-measure\",\n\tBarTerminal = '|bar-terminal',\n\tBarSegment = '|bar-segment',\n\n\t// dots (duration)\n\tDot = '|dot',\n\tDotDot = '|dotdot',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\t//\n\tWedgeCrescendo = '|wedge-crescendo',\n\tWedgeDiminuendo = '|wedge-diminuendo',\n\tWedgeClose = '|wedge-close',\n\n\tCrescendoBegin = '|wedge-crescendo',\n\tDecrescendoBegin = '|wedge-diminuendo',\n\tCrescendoEnd = '|wedge-close',\n\tDecrescendoEnd = '|wedge-close',\n\n\t// scripts\n\tScriptFermata = 'scripts-ufermata', // scripts.dfermata\n\tScriptShortFermata = 'scripts-ushortfermata', // scripts.dshortfermata\n\tScriptSforzato = 'scripts-sforzato',\n\tScriptStaccato = 'scripts-staccato',\n\tScriptStaccatissimo = 'scripts-ustaccatissimo', // scripts.dstaccatissimo\n\tScriptTurn = 'scripts-turn',\n\tScriptTrill = 'scripts-trill',\n\tScriptSegno = 'scripts-segno',\n\tScriptCoda = 'scripts-coda',\n\tScriptArpeggio = 'scripts-arpeggio',\n\tScriptPrall = 'scripts-prall',\n\tScriptMordent = 'scripts-mordent',\n\tScriptMarcato = 'scripts-umarcato', // scripts.dmarcato\n\tScriptTenuto = 'scripts-tenuto',\n\tScriptPortato = 'scripts-uportato', // scripts.dportato\n\n\t// pedal\n\tPedalStar = 'pedal-star',\n\tPedalPed = 'pedal-Ped',\n\n\tText = '|text',\n\tGraceNotehead = '|grace-notehead',\n}\n\n// alias\nconst tt = TokenType;\n\nexport const TokenTypes = Object.values(TokenType);\nexport const TokenClefs = TokenTypes.filter((t) => /clefs-/.test(t));\nexport const TokenTimesigs = TokenTypes.filter((t) => /timesig/.test(t));\nexport const TokenTimesigsC = TokenTypes.filter((t) => /timesig-/.test(t));\nexport const TokenTimesigsN = TokenTypes.filter((t) => /timesig\\d/.test(t));\nexport const TokenOctshifts = TokenTypes.filter((t) => /octave-/.test(t));\nexport const TokenNumbers = TokenTypes.filter((t) => /n\\d/.test(t));\nexport const TokenAccidentals = TokenTypes.filter((t) => /accidentals-/.test(t));\nexport const TokenNoteheads = TokenTypes.filter((t) => /noteheads-/.test(t));\nexport const TokenBareNoteheads = [tt.NoteheadS0, tt.NoteheadS1, tt.NoteheadS2];\nexport const TokenDirectionalNoteheads = TokenTypes.filter((t) => /noteheads-.+-[ud]/.test(t));\nexport const TokenRests = TokenTypes.filter((t) => /rests-/.test(t));\nexport const TokenFlags = TokenTypes.filter((t) => /flags-/.test(t));\nexport const TokenVolta = TokenTypes.filter((t) => /volta-/.test(t));\nexport const TokenDynamics = TokenTypes.filter((t) => /^[a-z]$/.test(t));\nexport const TokenScripts = TokenTypes.filter((t) => /scripts-/.test(t));\nexport const TokenPedals = TokenTypes.filter((t) => /pedal-/.test(t));\nexport const TokenDots = [tt.Dot, tt.DotDot];\nexport const TokenArcs = [tt.SlurBegin, tt.SlurEnd, tt.TieBegin, tt.TieEnd];\nexport const TokenBeams = TokenTypes.filter((t) => /beam-/.test(t));\nexport const TokenWedges = TokenTypes.filter((t) => /wedge-/.test(t));\n\nexport const TokenAccessories = [\n\t...TokenNumbers,\n\t...TokenDynamics,\n\t...TokenWedges,\n\t...TokenPedals,\n\t...TokenArcs,\n\n\ttt.ScriptFermata,\n\ttt.ScriptShortFermata,\n\ttt.ScriptSforzato,\n\ttt.ScriptStaccato,\n\ttt.ScriptStaccatissimo,\n\ttt.ScriptTurn,\n\ttt.ScriptTrill,\n\ttt.ScriptPrall,\n\ttt.ScriptMordent,\n\ttt.ScriptMarcato,\n\ttt.ScriptTenuto,\n\ttt.ScriptPortato,\n];\n\nexport const TokenDirectionless = [...TokenPedals];\n\nexport const TokenGlyphs = [\n\t...TokenClefs,\n\t...TokenTimesigs,\n\t...TokenNumbers,\n\t...TokenAccidentals,\n\ttt.NoteheadS0,\n\ttt.NoteheadS1,\n\ttt.NoteheadS2,\n\t...TokenRests,\n\t...TokenDynamics,\n\t...TokenScripts,\n\t...TokenPedals,\n\t...TokenDots,\n];\n\nconst TOKEN_Y_ROUND = {} as Record;\nTokenClefs.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenTimesigsN.forEach((t) => (TOKEN_Y_ROUND[t] = 1));\nTokenAccidentals.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenNoteheads.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenRests.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\nTokenDots.forEach((t) => (TOKEN_Y_ROUND[t] = 0.5));\n\nconst TOKEN_Y_FIXED = {} as Record;\nTokenTimesigsC.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\nTokenVolta.forEach((t) => (TOKEN_Y_FIXED[t] = 0));\n\nclass Token {\n\tstatic className = 'Token';\n\n\tid: string;\n\ttype: TokenType;\n\tx: number;\n\ty: number;\n\tpivotX?: number;\n\n\tconfidence: number;\n\n\ttip?: { x: number; y: number };\n\n\tvoice?: number; // integer, every bit stand for a voice\n\ttimeWarped?: boolean;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tget typeId(): string {\n\t\treturn this.type.split('|').reverse()[0];\n\t}\n\n\tget isPredicted(): boolean {\n\t\treturn Number.isFinite(this.confidence);\n\t}\n\n\tget isNotehead(): boolean {\n\t\treturn TokenDirectionalNoteheads.includes(this.type) || this.type === TokenType.NoteheadS0;\n\t}\n\n\tget isContexted(): boolean {\n\t\treturn (\n\t\t\tTokenClefs.includes(this.type) || TokenTimesigs.includes(this.type) || TokenOctshifts.includes(this.type) || TokenAccidentals.includes(this.type)\n\t\t);\n\t}\n\n\tget isAccessory(): boolean {\n\t\treturn TokenNumbers.includes(this.type) || TokenDynamics.includes(this.type) || TokenScripts.includes(this.type) || TokenPedals.includes(this.type);\n\t}\n\n\tget division(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Flag3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Flag4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Flag5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Flag6:\n\t\t\t\treturn 6;\n\n\t\t\tcase tt.Flag7:\n\t\t\t\treturn 7;\n\n\t\t\tcase tt.Flag8:\n\t\t\t\treturn 8;\n\n\t\t\tcase tt.RestM1:\n\t\t\t\treturn -1;\n\n\t\t\tcase tt.Rest0:\n\t\t\t\treturn 0;\n\n\t\t\tcase tt.Rest1:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.Rest2:\n\t\t\t\treturn 2;\n\n\t\t\tcase tt.Rest3:\n\t\t\t\treturn 3;\n\n\t\t\tcase tt.Rest4:\n\t\t\t\treturn 4;\n\n\t\t\tcase tt.Rest5:\n\t\t\t\treturn 5;\n\n\t\t\tcase tt.Rest6:\n\t\t\t\treturn 6;\n\n\t\t\t// TODO:\n\t\t\t//case tt.Rest0W:\n\t\t\t//\treturn 0;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget dots(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.Dot:\n\t\t\t\treturn 1;\n\n\t\t\tcase tt.DotDot:\n\t\t\t\treturn 2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget direction(): 'u' | 'd' | null {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn 'u';\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn 'd';\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget width(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn NOTEHEAD_WIDTHS.NoteheadS2;\n\t\t}\n\t}\n\n\tget left(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x - this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x - this.width;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget right(): number {\n\t\tswitch (this.type) {\n\t\t\tcase tt.NoteheadS0:\n\t\t\t\treturn this.x + this.width / 2;\n\n\t\t\tcase tt.NoteheadS1stemU:\n\t\t\tcase tt.NoteheadS2stemU:\n\t\t\t\treturn this.x;\n\n\t\t\tcase tt.NoteheadS1stemD:\n\t\t\tcase tt.NoteheadS2stemD:\n\t\t\t\treturn this.x + this.width;\n\t\t}\n\n\t\treturn this.x;\n\t}\n\n\tget voiceIndices(): number[] {\n\t\tif (!this.voice || this.voice < 0) return [];\n\n\t\treturn Array(Math.floor(Math.log2(this.voice)) + 1)\n\t\t\t.fill(null)\n\t\t\t.reduce((indices, _, i) => (this.voice & (1 << i) ? [i + 1, ...indices] : indices), []);\n\t}\n}\n\nclass TextToken extends Token {\n\ttextType: TextType;\n\ttext: string;\n\ttextFeature?: Record;\n\twidth_: number;\n\tfontSize: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t\tObject.assign(this, data);\n\t}\n\n\tget width(): number {\n\t\treturn this.width_;\n\t}\n\n\tset width(value: number) {\n\t\tthis.width_ = value;\n\t}\n}\n\nexport { TokenType, Token, TextToken, TOKEN_Y_ROUND, TOKEN_Y_FIXED };\n","import pick from 'lodash/pick';\n\nconst recoverJSON = (json: string | object, classDict): T => {\n\tif (typeof json === 'object') json = JSON.stringify(json);\n\n\treturn JSON.parse(json, (_, value) => {\n\t\tif (value && typeof value === 'object' && value.__prototype) {\n\t\t\tconst Class = classDict[value.__prototype];\n\t\t\tif (Class) {\n\t\t\t\tconst { __prototype, ...fields } = value;\n\t\t\t\treturn new Class(fields);\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t});\n};\n\nconst deepCopy = (o: any, dict: Map = null): any => {\n\tdict = dict || new Map();\n\tif (dict.get(o)) return dict.get(o);\n\n\tif (Array.isArray(o)) {\n\t\tconst result = [];\n\t\tdict.set(o, result);\n\n\t\to.forEach((e) => result.push(deepCopy(e, dict)));\n\n\t\treturn result;\n\t} else if (o && typeof o === 'object') {\n\t\tconst result = {};\n\t\tdict.set(o, result);\n\n\t\tObject.entries(o).forEach(([key, value]) => (result[key] = deepCopy(value, dict)));\n\t\tObject.setPrototypeOf(result, o.__proto__);\n\n\t\treturn result;\n\t}\n\n\treturn o;\n};\n\nclass SimpleClass {\n\tassign(data?: object) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\ttoJSON() {\n\t\tconst cls = this.constructor as any;\n\n\t\tconst serializedKeys = cls.serializedKeys || (cls.blackKeys && Object.keys(this).filter((key) => !cls.blackKeys.includes(key)));\n\t\tconst fields = serializedKeys ? pick(this, serializedKeys) : this;\n\n\t\treturn {\n\t\t\t__prototype: cls.className,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tdeepCopy(): this {\n\t\treturn deepCopy(this);\n\t}\n}\n\nexport { recoverJSON, SimpleClass };\n","import { SimpleClass } from '../starry/aux_/typedJSON';\n\nenum LayoutType {\n\tOrdinary = 'ordinary',\n\tFull = 'full',\n\tConservative = 'conservative',\n\tOnce = 'once',\n}\n\ninterface MeasureLayout {\n\tserialize(type: LayoutType): number[];\n\n\tseq: MeasureSeq;\n\tcode: string;\n}\n\nexport type MeasureSeq = MeasureLayout[];\n\nconst spreadMeasureSeq = (seq: MeasureSeq, type: LayoutType = LayoutType.Ordinary): number[] => [].concat(...seq.map((layout) => layout.serialize(type)));\n\nconst seqToCode = (seq: MeasureSeq, { withBrackets = false }: { withBrackets?: boolean } = {}): string => {\n\t//const code = seq.map(layout => layout.code).join(\", \");\n\tlet code = '';\n\tlet inRange = false;\n\n\tfor (let i = 0; i < seq.length; ++i) {\n\t\tconst middle = seq[i - 1] instanceof SingleMLayout && seq[i] instanceof SingleMLayout && seq[i + 1] instanceof SingleMLayout;\n\t\tif (middle) {\n\t\t\tif (!inRange) {\n\t\t\t\tcode += '..';\n\t\t\t\tinRange = true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (i > 0 && !inRange) code += ', ';\n\n\t\t\tinRange = false;\n\n\t\t\tcode += seq[i].code;\n\t\t}\n\t}\n\n\treturn withBrackets ? `[${code}]` : code;\n};\n\nclass SingleMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'SingleMLayout';\n\n\tmeasure: number;\n\n\tstatic from(measure: number) {\n\t\tconst layout = new SingleMLayout();\n\t\tlayout.measure = measure;\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(): number[] {\n\t\treturn [this.measure];\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this];\n\t}\n\n\tget code(): string {\n\t\treturn this.measure.toString();\n\t}\n}\n\nclass BlockMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'BlockMLayout';\n\n\tseq: MeasureSeq;\n\n\tstatic trimSeq(seq: MeasureSeq): MeasureSeq {\n\t\tconst seq2 = [];\n\t\tfor (const layout of seq) {\n\t\t\tif (layout instanceof BlockMLayout) {\n\t\t\t\tfor (const sub of layout.seq) seq2.push(sub);\n\t\t\t} else seq2.push(layout);\n\t\t}\n\n\t\t// reduce duplicated or backwards single measures\n\t\tconst seq3 = [];\n\t\tlet measure = null;\n\t\tfor (const layout of seq2) {\n\t\t\tif (layout instanceof SingleMLayout) {\n\t\t\t\tif (layout.measure > measure) {\n\t\t\t\t\tseq3.push(layout);\n\t\t\t\t\tmeasure = layout.measure;\n\t\t\t\t}\n\t\t\t} else seq3.push(layout);\n\t\t}\n\n\t\treturn seq3;\n\t}\n\n\tstatic fromSeq(seq: MeasureSeq): BlockMLayout {\n\t\tconst layout = new BlockMLayout();\n\t\tlayout.seq = BlockMLayout.trimSeq(seq);\n\n\t\treturn layout;\n\t}\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\treturn spreadMeasureSeq(this.seq, type);\n\t}\n\n\tget code(): string {\n\t\treturn seqToCode(this.seq, { withBrackets: true });\n\t}\n}\n\nclass VoltaMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'VoltaMLayout';\n\n\ttimes: number;\n\tbody: MeasureSeq;\n\talternates: MeasureSeq[];\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst bodySeq = spreadMeasureSeq(this.body);\n\n\t\tif (this.alternates) {\n\t\t\tconst alternateSeqs = this.alternates.map((seq) => spreadMeasureSeq(seq));\n\t\t\tconst lastAlternateSeq = alternateSeqs[alternateSeqs.length - 1];\n\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\t\treturn bodySeq.concat(...alternateSeqs);\n\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Full: {\n\t\t\t\t\tconst priorSeq = [].concat(\n\t\t\t\t\t\t...Array(this.times - 1)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map((_, i) => [...bodySeq, ...alternateSeqs[i % (this.times - 1)]])\n\t\t\t\t\t);\n\n\t\t\t\t\treturn [...priorSeq, ...bodySeq, ...lastAlternateSeq];\n\t\t\t\t}\n\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn [...bodySeq, ...lastAlternateSeq];\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (type) {\n\t\t\t\tcase LayoutType.Ordinary:\n\t\t\t\tcase LayoutType.Conservative:\n\t\t\t\tcase LayoutType.Once:\n\t\t\t\t\treturn bodySeq;\n\n\t\t\t\tcase LayoutType.Full:\n\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t...Array(this.times)\n\t\t\t\t\t\t\t.fill(null)\n\t\t\t\t\t\t\t.map(() => bodySeq)\n\t\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconsole.warn('the current case not handled:', type, this);\n\t}\n\n\tget seq(): MeasureSeq {\n\t\tconst alternates = this.alternates ? this.alternates[this.alternates.length - 1] : [];\n\n\t\treturn [...this.body, ...alternates];\n\t}\n\n\tget code(): string {\n\t\tconst body = seqToCode(this.body, { withBrackets: true });\n\n\t\tlet code = `${this.times}*${body}`;\n\t\tif (this.alternates) code += '{' + this.alternates.map((seq) => seqToCode(seq, { withBrackets: seq.length > 1 })).join(', ') + '}';\n\n\t\treturn code;\n\t}\n}\n\nclass ABAMLayout extends SimpleClass implements MeasureLayout {\n\tstatic className = 'ABAMLayout';\n\n\tmain: MeasureLayout;\n\trest: MeasureSeq;\n\n\tconstructor(data: any = undefined) {\n\t\tsuper();\n\t\tthis.assign(data);\n\t}\n\n\tserialize(type: LayoutType): number[] {\n\t\tconst seqA = this.main.serialize(type);\n\t\tconst seqA_ = spreadMeasureSeq(this.main.seq, LayoutType.Once);\n\t\tconst seqB = spreadMeasureSeq(this.rest, type);\n\n\t\tswitch (type) {\n\t\t\tcase LayoutType.Ordinary: // A B\n\t\t\t\treturn [...seqA, ...seqB];\n\n\t\t\tcase LayoutType.Once: // B A'\n\t\t\t\treturn [...seqB, ...seqA_];\n\n\t\t\tcase LayoutType.Conservative: // A B A'\n\t\t\tcase LayoutType.Full: // A B A'\n\t\t\t\treturn [...seqA, ...seqB, ...seqA_];\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('the current case not handled:', type, this);\n\t\t}\n\t}\n\n\tget seq(): MeasureSeq {\n\t\treturn [this.main, ...this.rest];\n\t}\n\n\tget code(): string {\n\t\treturn '<' + this.main.code + ', ' + seqToCode(this.rest) + '>';\n\t}\n}\n\nexport { LayoutType, MeasureLayout, SingleMLayout, BlockMLayout, VoltaMLayout, ABAMLayout };\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 13],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 15],\n\t\t$V3 = [1, 26],\n\t\t$V4 = [1, 29],\n\t\t$V5 = [1, 28],\n\t\t$V6 = [1, 30],\n\t\t$V7 = [5, 13, 22, 27, 29],\n\t\t$V8 = [2, 15],\n\t\t$V9 = [1, 32],\n\t\t$Va = [5, 14, 21, 22, 27, 28, 29];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tmeasure_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tindex_wise_measure_layout: 6,\n\t\t\t'i:': 7,\n\t\t\t's:': 8,\n\t\t\tsegment_wise_measure_layout: 9,\n\t\t\tiw_sequence: 10,\n\t\t\tiw_item: 11,\n\t\t\trange: 12,\n\t\t\t',': 13,\n\t\t\tUNSIGNED: 14,\n\t\t\t'..': 15,\n\t\t\tsingle: 16,\n\t\t\tiw_block_item: 17,\n\t\t\tiw_volta: 18,\n\t\t\tiw_aba: 19,\n\t\t\tiw_block: 20,\n\t\t\t'[': 21,\n\t\t\t']': 22,\n\t\t\t'*': 23,\n\t\t\tiw_optional_alternates: 24,\n\t\t\tiw_alternates: 25,\n\t\t\t'{': 26,\n\t\t\t'}': 27,\n\t\t\t'<': 28,\n\t\t\t'>': 29,\n\t\t\tsw_sequence: 30,\n\t\t\tsw_item: 31,\n\t\t\tsegment: 32,\n\t\t\tsw_block_item: 33,\n\t\t\tsw_volta: 34,\n\t\t\tsw_aba: 35,\n\t\t\tsw_block: 36,\n\t\t\tsw_optional_alternates: 37,\n\t\t\tsw_alternates: 38,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: {\n\t\t\t2: 'error',\n\t\t\t5: 'EOF',\n\t\t\t7: 'i:',\n\t\t\t8: 's:',\n\t\t\t13: ',',\n\t\t\t14: 'UNSIGNED',\n\t\t\t15: '..',\n\t\t\t21: '[',\n\t\t\t22: ']',\n\t\t\t23: '*',\n\t\t\t26: '{',\n\t\t\t27: '}',\n\t\t\t28: '<',\n\t\t\t29: '>',\n\t\t},\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[4, 2],\n\t\t\t[4, 2],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 3],\n\t\t\t[10, 3],\n\t\t\t[12, 3],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[11, 1],\n\t\t\t[16, 1],\n\t\t\t[17, 1],\n\t\t\t[20, 3],\n\t\t\t[18, 4],\n\t\t\t[24, 0],\n\t\t\t[24, 1],\n\t\t\t[25, 3],\n\t\t\t[19, 5],\n\t\t\t[9, 1],\n\t\t\t[30, 1],\n\t\t\t[30, 2],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[31, 1],\n\t\t\t[32, 1],\n\t\t\t[33, 1],\n\t\t\t[36, 3],\n\t\t\t[34, 4],\n\t\t\t[37, 0],\n\t\t\t[37, 1],\n\t\t\t[38, 3],\n\t\t\t[35, 4],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.$ = root(null, $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = root('index-wise', $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 4:\n\t\t\t\t\tthis.$ = root('segment-wise', serialize($$[$0]));\n\t\t\t\t\tbreak;\n\t\t\t\tcase 5:\n\t\t\t\tcase 23:\n\t\t\t\t\tif ($$[$0].length === 1 && $$[$0][0].__prototype === 'BlockMLayout') this.$ = $$[$0][0];\n\t\t\t\t\telse this.$ = blockLayout($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\tcase 24:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 7:\n\t\t\t\tcase 11:\n\t\t\t\tcase 12:\n\t\t\t\tcase 13:\n\t\t\t\tcase 14:\n\t\t\t\tcase 20:\n\t\t\t\tcase 27:\n\t\t\t\tcase 28:\n\t\t\t\tcase 29:\n\t\t\t\tcase 35:\n\t\t\t\t\tthis.$ = $$[$0];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 8:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 9:\n\t\t\t\t\tthis.$ = [...$$[$0 - 2], ...$$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 10:\n\t\t\t\t\tthis.$ = range($$[$0 - 2], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = singleLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 16:\n\t\t\t\tcase 31:\n\t\t\t\t\tthis.$ = blockLayout($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 17:\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 18:\n\t\t\t\tcase 33:\n\t\t\t\t\tthis.$ = voltaBlock($$[$0 - 3], $$[$0 - 1], $$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 19:\n\t\t\t\tcase 34:\n\t\t\t\t\tthis.$ = null;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 36:\n\t\t\t\t\tthis.$ = alternates($$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 3], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\t\tthis.$ = blockLayout([$$[$0]]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 30:\n\t\t\t\t\tthis.$ = segment($$[$0]);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 37:\n\t\t\t\t\tthis.$ = abaBlock($$[$0 - 2], $$[$0 - 1]);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 6: 3, 7: [1, 4], 8: [1, 5], 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 17] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 6: 18, 10: 6, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 9: 19, 14: $V3, 21: $V4, 28: $V5, 30: 20, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 5: [2, 5], 13: $V6 },\n\t\t\to($V7, [2, 6]),\n\t\t\to($V7, [2, 7]),\n\t\t\to($V7, [2, 11]),\n\t\t\to($V7, [2, 12]),\n\t\t\to($V7, [2, 13]),\n\t\t\to($V7, [2, 14]),\n\t\t\to($V7, $V8, { 15: [1, 31], 23: $V9 }),\n\t\t\to($V7, [2, 16]),\n\t\t\t{ 11: 33, 14: [1, 34], 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 10: 35, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 1: [2, 1] },\n\t\t\t{ 5: [2, 3] },\n\t\t\t{ 5: [2, 4] },\n\t\t\t{ 5: [2, 23], 14: $V3, 21: $V4, 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 24]),\n\t\t\to($Va, [2, 26]),\n\t\t\to($Va, [2, 27]),\n\t\t\to($Va, [2, 28]),\n\t\t\to($Va, [2, 29]),\n\t\t\to($Va, [2, 30], { 23: [1, 37] }),\n\t\t\to($Va, [2, 31]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 31: 38, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 39, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 11: 40, 12: 41, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 14: [1, 42] },\n\t\t\t{ 20: 43, 21: $V1 },\n\t\t\t{ 13: [1, 44] },\n\t\t\t{ 13: $V8, 23: $V9 },\n\t\t\t{ 13: $V6, 22: [1, 45] },\n\t\t\to($Va, [2, 25]),\n\t\t\t{ 21: $V4, 36: 46 },\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 47, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\t{ 14: $V3, 21: $V4, 22: [1, 48], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 8]),\n\t\t\to($V7, [2, 9]),\n\t\t\to($V7, [2, 10]),\n\t\t\to($V7, [2, 19], { 24: 49, 25: 50, 26: [1, 51] }),\n\t\t\t{ 10: 52, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\to([5, 13, 22, 26, 27, 29], [2, 17]),\n\t\t\to($Va, [2, 34], { 37: 53, 38: 54, 26: [1, 55] }),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 29: [1, 56], 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to([5, 14, 21, 22, 26, 27, 28, 29], [2, 32]),\n\t\t\to($V7, [2, 18]),\n\t\t\to($V7, [2, 20]),\n\t\t\t{ 10: 57, 11: 7, 12: 8, 14: $V0, 16: 9, 17: 10, 18: 11, 19: 12, 20: 14, 21: $V1, 28: $V2 },\n\t\t\t{ 13: $V6, 29: [1, 58] },\n\t\t\to($Va, [2, 33]),\n\t\t\to($Va, [2, 35]),\n\t\t\t{ 14: $V3, 21: $V4, 28: $V5, 30: 59, 31: 21, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($Va, [2, 37]),\n\t\t\t{ 13: $V6, 27: [1, 60] },\n\t\t\to($V7, [2, 22]),\n\t\t\t{ 14: $V3, 21: $V4, 27: [1, 61], 28: $V5, 31: 36, 32: 22, 33: 23, 34: 24, 35: 25, 36: 27 },\n\t\t\to($V7, [2, 21]),\n\t\t\to($Va, [2, 36]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 17: [2, 1], 18: [2, 3], 19: [2, 4] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tconst root = (type, data) => ({ __prototype: 'MesaureLayout', type, data });\n\n\tconst singleLayout = (n) => ({ __prototype: 'SingleMLayout', measure: Number(n) });\n\tconst blockLayout = (seq) => ({ __prototype: 'BlockMLayout', seq });\n\tconst voltaBlock = (times, body, alternates) => ({ __prototype: 'VoltaMLayout', times: Number(times), body, alternates });\n\tconst abaBlock = (main, rest) => ({ __prototype: 'ABAMLayout', main, rest });\n\n\tconst segment = (n) => ({ segment: true, length: Number(n) });\n\n\tconst alternates = (items) =>\n\t\titems.map((item) => {\n\t\t\tif (item.__prototype === 'BlockMLayout') return item.seq;\n\n\t\t\treturn [item];\n\t\t});\n\n\tconst range = (start, end) => {\n\t\tstart = Number(start);\n\t\tend = Number(end);\n\n\t\tif (!(end >= start)) throw new Error(`invalid measure range: ${start}..${end}`);\n\n\t\treturn Array(end + 1 - start)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => singleLayout(start + i));\n\t};\n\n\tconst serializeSeq = (item, options) => {\n\t\tif (item.segment) {\n\t\t\tconst index = options.index;\n\t\t\toptions.index += item.length;\n\n\t\t\treturn Array(item.length)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => singleLayout(index + i));\n\t\t}\n\n\t\treturn [serialize(item, options)];\n\t};\n\n\tconst serialize = (item, options = { index: 1 }) => {\n\t\tconst speard = (seq) => [].concat(...seq.map((it) => serializeSeq(it, options)));\n\n\t\tswitch (item.__prototype) {\n\t\t\tcase 'BlockMLayout':\n\t\t\t\titem.seq = speard(item.seq);\n\n\t\t\t\tbreak;\n\t\t\tcase 'VoltaMLayout':\n\t\t\t\titem.body = speard(item.body);\n\t\t\t\titem.alternates = item.alternates && item.alternates.map(speard);\n\n\t\t\t\tbreak;\n\t\t\tcase 'ABAMLayout':\n\t\t\t\titem.main = serialize(item.main, options);\n\t\t\t\titem.rest = speard(item.rest);\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn item;\n\t};\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 14;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 4:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 5:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([*,\\[\\]<>{}]))/, /^(?:(([1-9])([0-9])*))/, /^(?:(([a-z])+):)/, /^(?:\\.\\.)/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3, 4, 5], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import type { MeasureLayout } from './measureLayout';\nimport * as measureLayout from './measureLayout';\nimport grammar from './grammar.jison';\nimport { recoverJSON } from '../starry/aux_/typedJSON';\n\nconst parseCode = (code: string): MeasureLayout => {\n\tconst raw = grammar.parse(code);\n\n\tif (raw?.data) return recoverJSON(raw.data, measureLayout);\n\n\treturn null;\n};\n\nexport { parseCode };\n","export interface RawItem {\n\tid: string;\n\tleftBounds: string[];\n\trightBounds: string[];\n\tconjunction: string;\n}\n\nexport enum StaffGroupType {\n\tDefault,\n\tBrace, // {}\n\tBracket, // <>\n\tSquare, // []\n}\n\nexport enum StaffConjunctionType {\n\tBlank,\n\tDashed,\n\tSolid,\n}\n\ntype StaffID = string;\n\nexport interface StaffGroup {\n\ttype: StaffGroupType;\n\tsubs?: StaffGroup[];\n\tstaff?: StaffID;\n\tlevel?: number;\n\tgrand?: boolean;\n}\n\ninterface StaffGroupTrait {\n\tgroup: StaffGroup;\n\trange: [number, number];\n\tkey: string;\n}\n\nconst singleGroup = (id: string) => ({ type: StaffGroupType.Default, staff: id });\n\nconst BOUNDS_TO_GROUPTYPE: { [bound: string]: StaffGroupType } = {\n\t'{': StaffGroupType.Brace,\n\t'}': StaffGroupType.Brace,\n\t'<': StaffGroupType.Bracket,\n\t'>': StaffGroupType.Bracket,\n\t'[': StaffGroupType.Square,\n\t']': StaffGroupType.Square,\n};\n\nconst OPEN_BOUNDS = '{<[';\nconst CLOSE_BOUNDS = '}>]';\n\nconst CONJUNCTIONS_MAP: { [conj: string]: StaffConjunctionType } = {\n\t',': StaffConjunctionType.Blank,\n\t'-': StaffConjunctionType.Solid,\n\t'.': StaffConjunctionType.Dashed,\n};\n\nconst bracketCode = (type: StaffGroupType, partial: boolean = false): ((inner: string) => string) => {\n\tif (type === StaffGroupType.Default) return (inner) => inner;\n\n\tif (partial) {\n\t\tswitch (type) {\n\t\t\tcase StaffGroupType.Brace:\n\t\t\t\treturn (inner) => `{${inner}`;\n\t\t\tcase StaffGroupType.Bracket:\n\t\t\t\treturn (inner) => `<${inner}`;\n\t\t\tcase StaffGroupType.Square:\n\t\t\t\treturn (inner) => `[${inner}`;\n\t\t\tdefault:\n\t\t\t\treturn (inner) => inner;\n\t\t}\n\t}\n\n\tswitch (type) {\n\t\tcase StaffGroupType.Brace:\n\t\t\treturn (inner) => `{${inner}}`;\n\t\tcase StaffGroupType.Bracket:\n\t\t\treturn (inner) => `<${inner}>`;\n\t\tcase StaffGroupType.Square:\n\t\t\treturn (inner) => `[${inner}]`;\n\t\tdefault:\n\t\t\treturn (inner) => inner;\n\t}\n};\n\nconst randomB64 = (): string => {\n\tconst code = btoa(Math.random().toString().substr(2)).replace(/=/g, '');\n\n\treturn code.split('').reverse().slice(0, 6).join('');\n};\n\nconst makeUniqueName = (set: Set, index: number, prefix?: string): string => {\n\tlet name = prefix;\n\tif (!name) name = index.toString();\n\telse if (set.has(name)) name += '_' + index.toString();\n\n\twhile (set.has(name)) name += '_' + randomB64();\n\n\treturn name;\n};\n\nconst makeGroupsFromRaw = (parent: StaffGroup, seq: string[]): string[] => {\n\tlet remains = seq;\n\twhile (remains.length) {\n\t\tconst word = remains.shift();\n\t\tconst bound = BOUNDS_TO_GROUPTYPE[word];\n\t\tif (bound) {\n\t\t\tif (CLOSE_BOUNDS.includes(word) && bound === parent.type) break;\n\n\t\t\tif (OPEN_BOUNDS.includes(word)) {\n\t\t\t\tconst group = { type: bound, level: Number.isFinite(parent.level) ? parent.level + 1 : 0 };\n\t\t\t\tremains = makeGroupsFromRaw(group, remains);\n\n\t\t\t\tparent.subs = parent.subs || [];\n\t\t\t\tparent.subs.push(group);\n\t\t\t}\n\t\t} else {\n\t\t\tparent.subs = parent.subs || [];\n\t\t\tparent.subs.push(singleGroup(word));\n\t\t}\n\t}\n\n\twhile (parent.type === StaffGroupType.Default && parent.subs && parent.subs.length === 1) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.type = sub.type;\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t\tparent.level = sub.level;\n\t}\n\n\twhile (parent.subs && parent.subs.length === 1 && parent.subs[0].type === StaffGroupType.Default) {\n\t\tconst sub = parent.subs[0];\n\t\tparent.subs = sub.subs;\n\t\tparent.staff = sub.staff;\n\t}\n\n\tparent.grand = parent.type === StaffGroupType.Brace && parent.subs && parent.subs.every((sub) => sub.staff);\n\n\treturn remains;\n};\n\nconst groupHead = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupHead(group.subs[0]);\n};\n\nconst groupTail = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return groupTail(group.subs[group.subs.length - 1]);\n};\n\nexport const groupKey = (group: StaffGroup): string => {\n\tif (group.staff) return group.staff;\n\telse if (group.subs) return `${groupHead(group)}-${groupTail(group)}`;\n};\n\nconst groupDict = (group: StaffGroup, dict: { [key: string]: StaffGroup }): void => {\n\tdict[groupKey(group)] = group;\n\n\tif (group.subs) group.subs.forEach((sub) => groupDict(sub, dict));\n};\n\nexport interface MaskedStaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroups: StaffGroupTrait[];\n}\n\nclass StaffLayout {\n\tstaffIds: string[];\n\tconjunctions: StaffConjunctionType[];\n\tgroup: StaffGroup;\n\tgroups: StaffGroupTrait[];\n\n\tmaskCache: Map;\n\n\tconstructor(raw: RawItem[]) {\n\t\t// make unique ids\n\t\tconst ids = new Set();\n\t\traw.forEach((item, i) => {\n\t\t\titem.id = makeUniqueName(ids, i + 1, item.id);\n\t\t\tids.add(item.id);\n\t\t});\n\t\tthis.staffIds = raw.map((item) => item.id);\n\t\tthis.conjunctions = raw.slice(0, raw.length - 1).map((item) => (item.conjunction ? CONJUNCTIONS_MAP[item.conjunction] : StaffConjunctionType.Blank));\n\n\t\t// make groups\n\t\tconst seq = [].concat(...raw.map((item) => [...item.leftBounds, item.id, ...item.rightBounds]));\n\t\tthis.group = { type: StaffGroupType.Default };\n\t\tmakeGroupsFromRaw(this.group, seq);\n\n\t\tconst dict = {};\n\t\tgroupDict(this.group, dict);\n\t\tthis.groups = Object.entries(dict).map(([key, group]) => {\n\t\t\tlet ids = key.split('-');\n\t\t\tif (ids.length === 1) ids = [ids[0], ids[0]];\n\t\t\tconst range = ids.map((id) => this.staffIds.indexOf(id));\n\n\t\t\treturn {\n\t\t\t\tgroup,\n\t\t\t\trange,\n\t\t\t\tkey,\n\t\t\t} as StaffGroupTrait;\n\t\t});\n\n\t\tthis.maskCache = new Map();\n\t}\n\n\tget stavesCount(): number {\n\t\tif (!this.staffIds) return null;\n\n\t\treturn this.staffIds.length;\n\t}\n\n\tget partGroups(): StaffGroupTrait[] {\n\t\tconst grands = this.groups.filter((g) => g.group.grand);\n\t\tconst parts = this.groups.filter((g) => {\n\t\t\tif (g.group.grand) return true;\n\n\t\t\tif (g.range[0] === g.range[1]) {\n\t\t\t\tconst index = g.range[0];\n\t\t\t\treturn !grands.some((g) => g.range[0] <= index && g.range[1] >= index);\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\n\t\treturn parts;\n\t}\n\n\tget standaloneGroups(): string[][] {\n\t\tconst groups: string[][] = [];\n\t\tconst collect = (group: StaffGroup): void => {\n\t\t\tif (group.grand) groups.push(group.subs.map((sub) => sub.staff));\n\t\t\telse if (group.staff) groups.push([group.staff]);\n\t\t\telse if (group.subs) group.subs.forEach((sub) => collect(sub));\n\t\t};\n\t\tcollect(this.group);\n\n\t\treturn groups;\n\t}\n\n\tconjunctionBetween(upStaff: number, downStaff: number): StaffConjunctionType {\n\t\tif (downStaff <= upStaff) return null;\n\n\t\tlet con = StaffConjunctionType.Solid;\n\t\tfor (let i = upStaff; i < downStaff; i++) con = Math.min(con, this.conjunctions[i]);\n\n\t\treturn con;\n\t}\n\n\tstatic makeMaskLayout(layout: StaffLayout, mask: number): MaskedStaffLayout {\n\t\tconst staffIds = layout.staffIds.filter((_, i) => mask & (1 << i));\n\t\tif (staffIds.length === layout.staffIds.length) {\n\t\t\treturn {\n\t\t\t\tstaffIds: layout.staffIds,\n\t\t\t\tconjunctions: layout.conjunctions,\n\t\t\t\tgroups: layout.groups,\n\t\t\t};\n\t\t}\n\n\t\tconst groups = layout.groups\n\t\t\t.map((g) => ({ ids: layout.staffIds.slice(g.range[0], g.range[1] + 1).filter((id) => staffIds.includes(id)), ...g }))\n\t\t\t.filter(({ ids }) => ids.length)\n\t\t\t.map(\n\t\t\t\t({ ids, ...g }) =>\n\t\t\t\t\t({\n\t\t\t\t\t\tkey: g.key,\n\t\t\t\t\t\tgroup: g.group,\n\t\t\t\t\t\trange: [staffIds.indexOf(ids[0]), staffIds.indexOf(ids[ids.length - 1])],\n\t\t\t\t\t} as StaffGroupTrait)\n\t\t\t);\n\n\t\tconst conjunctions = staffIds.slice(0, staffIds.length - 1).map((id, i) => {\n\t\t\tconst nextId = staffIds[i + 1];\n\t\t\treturn layout.conjunctionBetween(layout.staffIds.indexOf(id), layout.staffIds.indexOf(nextId));\n\t\t});\n\n\t\treturn {\n\t\t\tstaffIds,\n\t\t\tconjunctions,\n\t\t\tgroups,\n\t\t};\n\t}\n\n\tmask(mask: number): MaskedStaffLayout {\n\t\tif (!this.maskCache.get(mask)) this.maskCache.set(mask, StaffLayout.makeMaskLayout(this, mask));\n\n\t\treturn this.maskCache.get(mask);\n\t}\n\n\t// {,}\t*\t1,1\t\t=> {,}\n\t// {,}\t*\t1,x\t\t=> {\n\t// {,}\t*\t0,x\t\t=>\n\t// {,}\t*\t0,1\t\t=> {}\n\tpartialMaskCode(bits: (1 | 0)[], withIds = false): string {\n\t\ttype Attendance = 0 | 1 | null;\n\t\tconst staffStatus = this.staffIds\n\t\t\t.map((_, i) => (i < bits.length ? bits[i] : null))\n\t\t\t.reduce((status, x, i) => {\n\t\t\t\tstatus[this.staffIds[i]] = x;\n\t\t\t\treturn status;\n\t\t\t}, {} as { [id: string]: Attendance });\n\n\t\tconst joinGroup = (group: StaffGroup): [string, boolean] => {\n\t\t\tif (group.staff) return [staffStatus[group.staff] ? group.staff : null, staffStatus[group.staff] === null];\n\n\t\t\tconst subs = group.subs.map((sub) => joinGroup(sub));\n\t\t\tconst subStr = subs\n\t\t\t\t.map((pair) => pair[0])\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(',');\n\t\t\tconst partial = subs.some(([_, partial]) => partial);\n\n\t\t\tconst code = subStr ? bracketCode(group.type, partial)(subStr) : null;\n\n\t\t\treturn [code, partial];\n\t\t};\n\n\t\tlet [code] = joinGroup(this.group);\n\t\tcode = code || '';\n\t\tif (!withIds) code = code.replace(/[_\\w]+/g, '');\n\n\t\treturn code;\n\t}\n}\n\nexport default StaffLayout;\n","/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function () {\n\tvar o = function (k, v, o, l) {\n\t\t\tfor (o = o || {}, l = k.length; l--; o[k[l]] = v);\n\t\t\treturn o;\n\t\t},\n\t\t$V0 = [1, 15],\n\t\t$V1 = [1, 16],\n\t\t$V2 = [1, 17],\n\t\t$V3 = [1, 11],\n\t\t$V4 = [1, 12],\n\t\t$V5 = [1, 13],\n\t\t$V6 = [1, 24],\n\t\t$V7 = [1, 25],\n\t\t$V8 = [1, 26],\n\t\t$V9 = [5, 11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Va = [15, 16, 17, 21, 22, 23, 24],\n\t\t$Vb = [11, 12, 13, 15, 16, 17, 21, 22, 23, 24],\n\t\t$Vc = [5, 11, 12, 13, 21, 22, 23, 24];\n\tvar parser = {\n\t\ttrace: function trace() {},\n\t\tyy: {},\n\t\tsymbols_: {\n\t\t\terror: 2,\n\t\t\tstart_symbol: 3,\n\t\t\tstaff_layout: 4,\n\t\t\tEOF: 5,\n\t\t\tseq: 6,\n\t\t\tseq_id: 7,\n\t\t\tseq_br: 8,\n\t\t\tseq_con: 9,\n\t\t\tbound_left: 10,\n\t\t\t'<': 11,\n\t\t\t'[': 12,\n\t\t\t'{': 13,\n\t\t\tbound_right: 14,\n\t\t\t'>': 15,\n\t\t\t']': 16,\n\t\t\t'}': 17,\n\t\t\tbound_lefts: 18,\n\t\t\tbound_rights: 19,\n\t\t\tconjunction: 20,\n\t\t\t'-': 21,\n\t\t\t',': 22,\n\t\t\t'.': 23,\n\t\t\tID: 24,\n\t\t\tseq_bl: 25,\n\t\t\t$accept: 0,\n\t\t\t$end: 1,\n\t\t},\n\t\tterminals_: { 2: 'error', 5: 'EOF', 11: '<', 12: '[', 13: '{', 15: '>', 16: ']', 17: '}', 21: '-', 22: ',', 23: '.', 24: 'ID' },\n\t\tproductions_: [\n\t\t\t0,\n\t\t\t[3, 2],\n\t\t\t[4, 1],\n\t\t\t[6, 0],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[6, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[10, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[14, 1],\n\t\t\t[18, 1],\n\t\t\t[18, 2],\n\t\t\t[19, 1],\n\t\t\t[19, 2],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[20, 1],\n\t\t\t[7, 1],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[7, 2],\n\t\t\t[25, 1],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[25, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[8, 2],\n\t\t\t[9, 1],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t\t[9, 2],\n\t\t],\n\t\tperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n\t\t\t/* this == yyval */\n\n\t\t\tvar $0 = $$.length - 1;\n\t\t\tswitch (yystate) {\n\t\t\t\tcase 1:\n\t\t\t\t\treturn $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\t$$[$0].next();\n\n\t\t\t\t\tthis.$ = $$[$0].toJSON();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.$ = new Seq();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 13:\n\t\t\t\tcase 15:\n\t\t\t\t\tthis.$ = [$$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 14:\n\t\t\t\tcase 16:\n\t\t\t\t\tthis.$ = [...$$[$0 - 1], $$[$0]];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 20:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.i($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 21:\n\t\t\t\tcase 23:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 22:\n\t\t\t\tcase 24:\n\t\t\t\t\t$$[$0 - 1].tip.i($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 25:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.bl($$[$0]);\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 26:\n\t\t\t\tcase 27:\n\t\t\t\t\t$$[$0 - 1].next();\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 28:\n\t\t\t\t\t$$[$0 - 1].tip.bl($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 29:\n\t\t\t\tcase 30:\n\t\t\t\tcase 31:\n\t\t\t\t\t$$[$0 - 1].tip.br($$[$0]);\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 32:\n\t\t\t\t\tthis.$ = new Seq();\n\t\t\t\t\tthis.$.tip.con($$[$0]);\n\t\t\t\t\tthis.$.next();\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 33:\n\t\t\t\tcase 34:\n\t\t\t\tcase 35:\n\t\t\t\tcase 36:\n\t\t\t\t\t$$[$0 - 1].tip.con($$[$0]);\n\t\t\t\t\t$$[$0 - 1].next();\n\n\t\t\t\t\tthis.$ = $$[$0 - 1];\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\ttable: [\n\t\t\t{ 3: 1, 4: 2, 5: [2, 3], 6: 3, 7: 4, 8: 5, 9: 6, 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 10, 20: 9, 21: $V3, 22: $V4, 23: $V5, 24: [1, 7], 25: 8 },\n\t\t\t{ 1: [3] },\n\t\t\t{ 5: [1, 18] },\n\t\t\t{ 5: [2, 2] },\n\t\t\t{ 5: [2, 4], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 22, 19: 20, 20: 21, 21: $V3, 22: $V4, 23: $V5, 24: [1, 19] },\n\t\t\t{ 5: [2, 5], 10: 14, 11: $V0, 12: $V1, 13: $V2, 18: 29, 20: 28, 21: $V3, 22: $V4, 23: $V5, 24: [1, 27] },\n\t\t\t{ 5: [2, 6], 10: 14, 11: $V0, 12: $V1, 13: $V2, 14: 23, 15: $V6, 16: $V7, 17: $V8, 18: 33, 19: 31, 20: 32, 21: $V3, 22: $V4, 23: $V5, 24: [1, 30] },\n\t\t\to($V9, [2, 20]),\n\t\t\t{ 14: 23, 15: $V6, 16: $V7, 17: $V8, 19: 35, 20: 36, 21: $V3, 22: $V4, 23: $V5, 24: [1, 34] },\n\t\t\to($V9, [2, 32]),\n\t\t\to($Va, [2, 25], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 17]),\n\t\t\to($V9, [2, 18]),\n\t\t\to($V9, [2, 19]),\n\t\t\to($Vb, [2, 13]),\n\t\t\to($Vb, [2, 7]),\n\t\t\to($Vb, [2, 8]),\n\t\t\to($Vb, [2, 9]),\n\t\t\t{ 1: [2, 1] },\n\t\t\to($V9, [2, 21]),\n\t\t\to($Vc, [2, 29], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 33]),\n\t\t\to($Va, [2, 26], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 15]),\n\t\t\to($V9, [2, 10]),\n\t\t\to($V9, [2, 11]),\n\t\t\to($V9, [2, 12]),\n\t\t\to($V9, [2, 23]),\n\t\t\to($V9, [2, 35]),\n\t\t\to($Va, [2, 27], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 24]),\n\t\t\to($Vc, [2, 31], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 36]),\n\t\t\to($Va, [2, 28], { 10: 37, 11: $V0, 12: $V1, 13: $V2 }),\n\t\t\to($V9, [2, 22]),\n\t\t\to($Vc, [2, 30], { 14: 38, 15: $V6, 16: $V7, 17: $V8 }),\n\t\t\to($V9, [2, 34]),\n\t\t\to($Vb, [2, 14]),\n\t\t\to($V9, [2, 16]),\n\t\t],\n\t\tdefaultActions: { 3: [2, 2], 18: [2, 1] },\n\t\tparseError: function parseError(str, hash) {\n\t\t\tif (hash.recoverable) {\n\t\t\t\tthis.trace(str);\n\t\t\t} else {\n\t\t\t\tvar error = new Error(str);\n\t\t\t\terror.hash = hash;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tparse: function parse(input) {\n\t\t\tvar self = this,\n\t\t\t\tstack = [0],\n\t\t\t\ttstack = [],\n\t\t\t\tvstack = [null],\n\t\t\t\tlstack = [],\n\t\t\t\ttable = this.table,\n\t\t\t\tyytext = '',\n\t\t\t\tyylineno = 0,\n\t\t\t\tyyleng = 0,\n\t\t\t\trecovering = 0,\n\t\t\t\tTERROR = 2,\n\t\t\t\tEOF = 1;\n\t\t\tvar args = lstack.slice.call(arguments, 1);\n\t\t\tvar lexer = Object.create(this.lexer);\n\t\t\tvar sharedState = { yy: {} };\n\t\t\tfor (var k in this.yy) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(this.yy, k)) {\n\t\t\t\t\tsharedState.yy[k] = this.yy[k];\n\t\t\t\t}\n\t\t\t}\n\t\t\tlexer.setInput(input, sharedState.yy);\n\t\t\tsharedState.yy.lexer = lexer;\n\t\t\tsharedState.yy.parser = this;\n\t\t\tif (typeof lexer.yylloc == 'undefined') {\n\t\t\t\tlexer.yylloc = {};\n\t\t\t}\n\t\t\tvar yyloc = lexer.yylloc;\n\t\t\tlstack.push(yyloc);\n\t\t\tvar ranges = lexer.options && lexer.options.ranges;\n\t\t\tif (typeof sharedState.yy.parseError === 'function') {\n\t\t\t\tthis.parseError = sharedState.yy.parseError;\n\t\t\t} else {\n\t\t\t\tthis.parseError = Object.getPrototypeOf(this).parseError;\n\t\t\t}\n\t\t\tfunction popStack(n) {\n\t\t\t\tstack.length = stack.length - 2 * n;\n\t\t\t\tvstack.length = vstack.length - n;\n\t\t\t\tlstack.length = lstack.length - n;\n\t\t\t}\n\t\t\t_token_stack: var lex = function () {\n\t\t\t\tvar token;\n\t\t\t\ttoken = lexer.lex() || EOF;\n\t\t\t\tif (typeof token !== 'number') {\n\t\t\t\t\ttoken = self.symbols_[token] || token;\n\t\t\t\t}\n\t\t\t\treturn token;\n\t\t\t};\n\t\t\tvar symbol,\n\t\t\t\tpreErrorSymbol,\n\t\t\t\tstate,\n\t\t\t\taction,\n\t\t\t\ta,\n\t\t\t\tr,\n\t\t\t\tyyval = {},\n\t\t\t\tp,\n\t\t\t\tlen,\n\t\t\t\tnewState,\n\t\t\t\texpected;\n\t\t\twhile (true) {\n\t\t\t\tstate = stack[stack.length - 1];\n\t\t\t\tif (this.defaultActions[state]) {\n\t\t\t\t\taction = this.defaultActions[state];\n\t\t\t\t} else {\n\t\t\t\t\tif (symbol === null || typeof symbol == 'undefined') {\n\t\t\t\t\t\tsymbol = lex();\n\t\t\t\t\t}\n\t\t\t\t\taction = table[state] && table[state][symbol];\n\t\t\t\t}\n\t\t\t\tif (typeof action === 'undefined' || !action.length || !action[0]) {\n\t\t\t\t\tvar errStr = '';\n\t\t\t\t\texpected = [];\n\t\t\t\t\tfor (p in table[state]) {\n\t\t\t\t\t\tif (this.terminals_[p] && p > TERROR) {\n\t\t\t\t\t\t\texpected.push(\"'\" + this.terminals_[p] + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (lexer.showPosition) {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t':\\n' +\n\t\t\t\t\t\t\tlexer.showPosition() +\n\t\t\t\t\t\t\t'\\nExpecting ' +\n\t\t\t\t\t\t\texpected.join(', ') +\n\t\t\t\t\t\t\t\", got '\" +\n\t\t\t\t\t\t\t(this.terminals_[symbol] || symbol) +\n\t\t\t\t\t\t\t\"'\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\terrStr =\n\t\t\t\t\t\t\t'Parse error on line ' +\n\t\t\t\t\t\t\t(yylineno + 1) +\n\t\t\t\t\t\t\t': Unexpected ' +\n\t\t\t\t\t\t\t(symbol == EOF ? 'end of input' : \"'\" + (this.terminals_[symbol] || symbol) + \"'\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.parseError(errStr, {\n\t\t\t\t\t\ttext: lexer.match,\n\t\t\t\t\t\ttoken: this.terminals_[symbol] || symbol,\n\t\t\t\t\t\tline: lexer.yylineno,\n\t\t\t\t\t\tloc: yyloc,\n\t\t\t\t\t\texpected: expected,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (action[0] instanceof Array && action.length > 1) {\n\t\t\t\t\tthrow new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);\n\t\t\t\t}\n\t\t\t\tswitch (action[0]) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tstack.push(symbol);\n\t\t\t\t\t\tvstack.push(lexer.yytext);\n\t\t\t\t\t\tlstack.push(lexer.yylloc);\n\t\t\t\t\t\tstack.push(action[1]);\n\t\t\t\t\t\tsymbol = null;\n\t\t\t\t\t\tif (!preErrorSymbol) {\n\t\t\t\t\t\t\tyyleng = lexer.yyleng;\n\t\t\t\t\t\t\tyytext = lexer.yytext;\n\t\t\t\t\t\t\tyylineno = lexer.yylineno;\n\t\t\t\t\t\t\tyyloc = lexer.yylloc;\n\t\t\t\t\t\t\tif (recovering > 0) {\n\t\t\t\t\t\t\t\trecovering--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsymbol = preErrorSymbol;\n\t\t\t\t\t\t\tpreErrorSymbol = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tlen = this.productions_[action[1]][1];\n\t\t\t\t\t\tyyval.$ = vstack[vstack.length - len];\n\t\t\t\t\t\tyyval._$ = {\n\t\t\t\t\t\t\tfirst_line: lstack[lstack.length - (len || 1)].first_line,\n\t\t\t\t\t\t\tlast_line: lstack[lstack.length - 1].last_line,\n\t\t\t\t\t\t\tfirst_column: lstack[lstack.length - (len || 1)].first_column,\n\t\t\t\t\t\t\tlast_column: lstack[lstack.length - 1].last_column,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (ranges) {\n\t\t\t\t\t\t\tyyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = this.performAction.apply(yyval, [yytext, yyleng, yylineno, sharedState.yy, action[1], vstack, lstack].concat(args));\n\t\t\t\t\t\tif (typeof r !== 'undefined') {\n\t\t\t\t\t\t\treturn r;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (len) {\n\t\t\t\t\t\t\tstack = stack.slice(0, -1 * len * 2);\n\t\t\t\t\t\t\tvstack = vstack.slice(0, -1 * len);\n\t\t\t\t\t\t\tlstack = lstack.slice(0, -1 * len);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstack.push(this.productions_[action[1]][0]);\n\t\t\t\t\t\tvstack.push(yyval.$);\n\t\t\t\t\t\tlstack.push(yyval._$);\n\t\t\t\t\t\tnewState = table[stack[stack.length - 2]][stack[stack.length - 1]];\n\t\t\t\t\t\tstack.push(newState);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n\n\tclass Item {\n\t\tconstructor() {\n\t\t\tthis.id = null;\n\t\t\tthis.leftBounds = [];\n\t\t\tthis.rightBounds = [];\n\t\t\tthis.conjunction = null;\n\t\t}\n\n\t\ti(id) {\n\t\t\tthis.id = id;\n\t\t\treturn this;\n\t\t}\n\n\t\tbl(leftBounds) {\n\t\t\tthis.leftBounds = leftBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tbr(rightBounds) {\n\t\t\tthis.rightBounds = rightBounds;\n\t\t\treturn this;\n\t\t}\n\n\t\tcon(conjunction) {\n\t\t\tthis.conjunction = conjunction;\n\t\t\treturn this;\n\t\t}\n\t}\n\n\tclass Seq {\n\t\tconstructor() {\n\t\t\tthis.body = [];\n\t\t\tthis.tip = new Item();\n\t\t}\n\n\t\tnext() {\n\t\t\tthis.body.push(this.tip);\n\t\t\tthis.tip = new Item();\n\t\t\treturn this;\n\t\t}\n\n\t\ttoJSON() {\n\t\t\treturn this.body;\n\t\t}\n\t}\n\t/* generated by jison-lex 0.3.4 */\n\tvar lexer = (function () {\n\t\tvar lexer = {\n\t\t\tEOF: 1,\n\n\t\t\tparseError: function parseError(str, hash) {\n\t\t\t\tif (this.yy.parser) {\n\t\t\t\t\tthis.yy.parser.parseError(str, hash);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(str);\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// resets the lexer, sets new input\n\t\t\tsetInput: function (input, yy) {\n\t\t\t\tthis.yy = yy || this.yy || {};\n\t\t\t\tthis._input = input;\n\t\t\t\tthis._more = this._backtrack = this.done = false;\n\t\t\t\tthis.yylineno = this.yyleng = 0;\n\t\t\t\tthis.yytext = this.matched = this.match = '';\n\t\t\t\tthis.conditionStack = ['INITIAL'];\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: 1,\n\t\t\t\t\tfirst_column: 0,\n\t\t\t\t\tlast_line: 1,\n\t\t\t\t\tlast_column: 0,\n\t\t\t\t};\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [0, 0];\n\t\t\t\t}\n\t\t\t\tthis.offset = 0;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// consumes and returns one char from the input\n\t\t\tinput: function () {\n\t\t\t\tvar ch = this._input[0];\n\t\t\t\tthis.yytext += ch;\n\t\t\t\tthis.yyleng++;\n\t\t\t\tthis.offset++;\n\t\t\t\tthis.match += ch;\n\t\t\t\tthis.matched += ch;\n\t\t\t\tvar lines = ch.match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno++;\n\t\t\t\t\tthis.yylloc.last_line++;\n\t\t\t\t} else {\n\t\t\t\t\tthis.yylloc.last_column++;\n\t\t\t\t}\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range[1]++;\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._input.slice(1);\n\t\t\t\treturn ch;\n\t\t\t},\n\n\t\t\t// unshifts one char (or a string) into the input\n\t\t\tunput: function (ch) {\n\t\t\t\tvar len = ch.length;\n\t\t\t\tvar lines = ch.split(/(?:\\r\\n?|\\n)/g);\n\n\t\t\t\tthis._input = ch + this._input;\n\t\t\t\tthis.yytext = this.yytext.substr(0, this.yytext.length - len);\n\t\t\t\t//this.yyleng -= len;\n\t\t\t\tthis.offset -= len;\n\t\t\t\tvar oldLines = this.match.split(/(?:\\r\\n?|\\n)/g);\n\t\t\t\tthis.match = this.match.substr(0, this.match.length - 1);\n\t\t\t\tthis.matched = this.matched.substr(0, this.matched.length - 1);\n\n\t\t\t\tif (lines.length - 1) {\n\t\t\t\t\tthis.yylineno -= lines.length - 1;\n\t\t\t\t}\n\t\t\t\tvar r = this.yylloc.range;\n\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length\n\t\t\t\t\t\t: this.yylloc.first_column - len,\n\t\t\t\t};\n\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [r[0], r[0] + this.yyleng - len];\n\t\t\t\t}\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, caches matched text and appends it on next action\n\t\t\tmore: function () {\n\t\t\t\tthis._more = true;\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.\n\t\t\treject: function () {\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\tthis._backtrack = true;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError(\n\t\t\t\t\t\t'Lexical error on line ' +\n\t\t\t\t\t\t\t(this.yylineno + 1) +\n\t\t\t\t\t\t\t'. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\\n' +\n\t\t\t\t\t\t\tthis.showPosition(),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\n\t\t\t// retain first n characters of the match\n\t\t\tless: function (n) {\n\t\t\t\tthis.unput(this.match.slice(n));\n\t\t\t},\n\n\t\t\t// displays already matched input, i.e. for error messages\n\t\t\tpastInput: function () {\n\t\t\t\tvar past = this.matched.substr(0, this.matched.length - this.match.length);\n\t\t\t\treturn (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays upcoming input, i.e. for error messages\n\t\t\tupcomingInput: function () {\n\t\t\t\tvar next = this.match;\n\t\t\t\tif (next.length < 20) {\n\t\t\t\t\tnext += this._input.substr(0, 20 - next.length);\n\t\t\t\t}\n\t\t\t\treturn (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\\n/g, '');\n\t\t\t},\n\n\t\t\t// displays the character position where the lexing error occurred, i.e. for error messages\n\t\t\tshowPosition: function () {\n\t\t\t\tvar pre = this.pastInput();\n\t\t\t\tvar c = new Array(pre.length + 1).join('-');\n\t\t\t\treturn pre + this.upcomingInput() + '\\n' + c + '^';\n\t\t\t},\n\n\t\t\t// test the lexed token: return FALSE when not a match, otherwise return token\n\t\t\ttest_match: function (match, indexed_rule) {\n\t\t\t\tvar token, lines, backup;\n\n\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t// save context\n\t\t\t\t\tbackup = {\n\t\t\t\t\t\tyylineno: this.yylineno,\n\t\t\t\t\t\tyylloc: {\n\t\t\t\t\t\t\tfirst_line: this.yylloc.first_line,\n\t\t\t\t\t\t\tlast_line: this.last_line,\n\t\t\t\t\t\t\tfirst_column: this.yylloc.first_column,\n\t\t\t\t\t\t\tlast_column: this.yylloc.last_column,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyytext: this.yytext,\n\t\t\t\t\t\tmatch: this.match,\n\t\t\t\t\t\tmatches: this.matches,\n\t\t\t\t\t\tmatched: this.matched,\n\t\t\t\t\t\tyyleng: this.yyleng,\n\t\t\t\t\t\toffset: this.offset,\n\t\t\t\t\t\t_more: this._more,\n\t\t\t\t\t\t_input: this._input,\n\t\t\t\t\t\tyy: this.yy,\n\t\t\t\t\t\tconditionStack: this.conditionStack.slice(0),\n\t\t\t\t\t\tdone: this.done,\n\t\t\t\t\t};\n\t\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\t\tbackup.yylloc.range = this.yylloc.range.slice(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlines = match[0].match(/(?:\\r\\n?|\\n).*/g);\n\t\t\t\tif (lines) {\n\t\t\t\t\tthis.yylineno += lines.length;\n\t\t\t\t}\n\t\t\t\tthis.yylloc = {\n\t\t\t\t\tfirst_line: this.yylloc.last_line,\n\t\t\t\t\tlast_line: this.yylineno + 1,\n\t\t\t\t\tfirst_column: this.yylloc.last_column,\n\t\t\t\t\tlast_column: lines\n\t\t\t\t\t\t? lines[lines.length - 1].length - lines[lines.length - 1].match(/\\r?\\n?/)[0].length\n\t\t\t\t\t\t: this.yylloc.last_column + match[0].length,\n\t\t\t\t};\n\t\t\t\tthis.yytext += match[0];\n\t\t\t\tthis.match += match[0];\n\t\t\t\tthis.matches = match;\n\t\t\t\tthis.yyleng = this.yytext.length;\n\t\t\t\tif (this.options.ranges) {\n\t\t\t\t\tthis.yylloc.range = [this.offset, (this.offset += this.yyleng)];\n\t\t\t\t}\n\t\t\t\tthis._more = false;\n\t\t\t\tthis._backtrack = false;\n\t\t\t\tthis._input = this._input.slice(match[0].length);\n\t\t\t\tthis.matched += match[0];\n\t\t\t\ttoken = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);\n\t\t\t\tif (this.done && this._input) {\n\t\t\t\t\tthis.done = false;\n\t\t\t\t}\n\t\t\t\tif (token) {\n\t\t\t\t\treturn token;\n\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t// recover context\n\t\t\t\t\tfor (var k in backup) {\n\t\t\t\t\t\tthis[k] = backup[k];\n\t\t\t\t\t}\n\t\t\t\t\treturn false; // rule action called reject() implying the next rule should be tested instead.\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\t// return next match in input\n\t\t\tnext: function () {\n\t\t\t\tif (this.done) {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t}\n\t\t\t\tif (!this._input) {\n\t\t\t\t\tthis.done = true;\n\t\t\t\t}\n\n\t\t\t\tvar token, match, tempMatch, index;\n\t\t\t\tif (!this._more) {\n\t\t\t\t\tthis.yytext = '';\n\t\t\t\t\tthis.match = '';\n\t\t\t\t}\n\t\t\t\tvar rules = this._currentRules();\n\t\t\t\tfor (var i = 0; i < rules.length; i++) {\n\t\t\t\t\ttempMatch = this._input.match(this.rules[rules[i]]);\n\t\t\t\t\tif (tempMatch && (!match || tempMatch[0].length > match[0].length)) {\n\t\t\t\t\t\tmatch = tempMatch;\n\t\t\t\t\t\tindex = i;\n\t\t\t\t\t\tif (this.options.backtrack_lexer) {\n\t\t\t\t\t\t\ttoken = this.test_match(tempMatch, rules[i]);\n\t\t\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\t\t\treturn token;\n\t\t\t\t\t\t\t} else if (this._backtrack) {\n\t\t\t\t\t\t\t\tmatch = false;\n\t\t\t\t\t\t\t\tcontinue; // rule action called reject() implying a rule MISmatch.\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (!this.options.flex) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (match) {\n\t\t\t\t\ttoken = this.test_match(match, rules[index]);\n\t\t\t\t\tif (token !== false) {\n\t\t\t\t\t\treturn token;\n\t\t\t\t\t}\n\t\t\t\t\t// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (this._input === '') {\n\t\t\t\t\treturn this.EOF;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\\n' + this.showPosition(), {\n\t\t\t\t\t\ttext: '',\n\t\t\t\t\t\ttoken: null,\n\t\t\t\t\t\tline: this.yylineno,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return next match that has a token\n\t\t\tlex: function lex() {\n\t\t\t\tvar r = this.next();\n\t\t\t\tif (r) {\n\t\t\t\t\treturn r;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.lex();\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)\n\t\t\tbegin: function begin(condition) {\n\t\t\t\tthis.conditionStack.push(condition);\n\t\t\t},\n\n\t\t\t// pop the previously active lexer condition state off the condition stack\n\t\t\tpopState: function popState() {\n\t\t\t\tvar n = this.conditionStack.length - 1;\n\t\t\t\tif (n > 0) {\n\t\t\t\t\treturn this.conditionStack.pop();\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditionStack[0];\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// produce the lexer rule set which is active for the currently active lexer condition state\n\t\t\t_currentRules: function _currentRules() {\n\t\t\t\tif (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {\n\t\t\t\t\treturn this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;\n\t\t\t\t} else {\n\t\t\t\t\treturn this.conditions['INITIAL'].rules;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available\n\t\t\ttopState: function topState(n) {\n\t\t\t\tn = this.conditionStack.length - 1 - Math.abs(n || 0);\n\t\t\t\tif (n >= 0) {\n\t\t\t\t\treturn this.conditionStack[n];\n\t\t\t\t} else {\n\t\t\t\t\treturn 'INITIAL';\n\t\t\t\t}\n\t\t\t},\n\n\t\t\t// alias for begin(condition)\n\t\t\tpushState: function pushState(condition) {\n\t\t\t\tthis.begin(condition);\n\t\t\t},\n\n\t\t\t// return the number of states currently on the stack\n\t\t\tstateStackSize: function stateStackSize() {\n\t\t\t\treturn this.conditionStack.length;\n\t\t\t},\n\t\t\toptions: {},\n\t\t\tperformAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {\n\t\t\t\tvar YYSTATE = YY_START;\n\t\t\t\tswitch ($avoiding_name_collisions) {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\treturn yy_.yytext;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\treturn 24;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 3:\n\t\t\t\t\t\treturn 5;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t},\n\t\t\trules: [/^(?:\\s+)/, /^(?:([-,.\\[\\]<>{}]))/, /^(?:([a-zA-Z_0-9]+))/, /^(?:$)/],\n\t\t\tconditions: { INITIAL: { rules: [0, 1, 2, 3], inclusive: true } },\n\t\t};\n\t\treturn lexer;\n\t})();\n\tparser.lexer = lexer;\n\tfunction Parser() {\n\t\tthis.yy = {};\n\t}\n\tParser.prototype = parser;\n\tparser.Parser = Parser;\n\treturn new Parser();\n})();\n\n// if (typeof require !== 'undefined' && typeof exports !== 'undefined') {\nexport { parser };\nexport var Parser = parser.Parser;\nexport var parse = function () {\n\treturn parser.parse.apply(parser, arguments);\n};\nexport default { parser: parser, Parser: parser.Parser, parse: parse };\n","import StaffLayout from './staffLayout';\nimport grammar from './grammar.jison';\n\nconst parseCode = (code: string): StaffLayout => {\n\tconst raw = grammar.parse(code);\n\n\treturn new StaffLayout(raw);\n};\n\nexport { parseCode };\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","import { Fraction, Pitch, EventFeature, EventPredisposition } from './interfaces';\nimport { gcd, reducedFraction } from './utils';\nimport { TokenType } from './token';\nimport * as Token from './token';\nimport { SimpleClass } from './aux_/typedJSON';\n\nconst WHOLE_DURATION = 128 * 3 * 5;\nconst WHOLE_EXP2 = WHOLE_DURATION / 15;\n\nenum AccessoryDirection {\n\tUp = '^',\n\tDown = '_',\n\tMiddle = '-',\n}\n\nenum GraceType {\n\tGrace = 'grace',\n\tAfterGrace = 'afterGrace',\n\tAcciaccatura = 'acciaccatura',\n\tAppoggiatura = 'appoggiatura',\n\tSlashedGrace = 'slashedGrace',\n}\n\nenum StemBeam {\n\tOpen = 'Open',\n\tClose = 'Close',\n\tContinue = 'Continue',\n}\n\nenum TremoloLink {\n\tPitcher = 'Pitcher',\n\tCatcher = 'Catcher',\n\tPierced = 'Pierced',\n}\n\nenum GlissandoStyle {\n\tNormal = 'normal',\n\tDashedLine = 'dashed-line',\n\tDottedLine = 'dotted-line',\n\tZigzag = 'zigzag',\n\tTrill = 'trill',\n}\n\nenum ArpeggioStyle {\n\tNormal = 'Normal',\n\tBracket = 'Bracket',\n\tParenthesis = 'Parenthesis',\n\tParenthesisDashed = 'ParenthesisDashed',\n\tArrowDown = 'ArrowDown',\n}\n\ninterface Accessory {\n\tdirection?: AccessoryDirection;\n\tparenthesized?: boolean;\n\ttype: TokenType;\n\tid?: string;\n\tx: number;\n}\n\ninterface TermPitch extends Pitch {\n\ttying?: boolean;\n\ttied?: boolean;\n\tparenthesized?: boolean;\n\toctaveShift?: number;\n}\n\nclass Term extends SimpleClass {\n\tx: number;\n\tstaff?: number;\n}\n\ntype RestType = 'r' | 'R' | 's' | null;\n\ninterface DurationalTerm {\n\tdivision: number;\n\tdots: number;\n\tmultiplier?: Fraction;\n}\n\nconst SCALE_NAMES = 'CDEFGAB';\n\nclass EventTerm extends Term implements DurationalTerm {\n\tstatic className = 'EventTerm';\n\n\tleft: number;\n\tright: number;\n\tpivotX: number;\n\n\tsystem: number;\n\troundX: number; // for tick map, scheduler\n\tintX: number; // for measure hash\n\tintY: number;\n\tys: number[]; // order by ascending pitch, low (greater Y) to high (less Y)\n\tpitches?: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\taccessories: Accessory[];\n\tmultiplier: Fraction;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\trepetitionChord: boolean;\n\tgrace?: GraceType;\n\tbeam?: StemBeam;\n\ttimeWarp?: Fraction;\n\tparenthesized?: boolean;\n\ttremolo?: number; // like division, 'number of beams' + 2\n\ttremoloLink?: TremoloLink;\n\tglissando?: boolean;\n\tglissandoStyle?: GlissandoStyle;\n\tarpeggioStyle?: ArpeggioStyle;\n\ttip?: { x: number; y: number };\n\n\ttick: number;\n\n\t// for topology\n\tid?: number;\n\tprevId?: number;\n\ttickGroup?: number;\n\n\tfeature: EventFeature;\n\tpredisposition: EventPredisposition;\n\n\tgraceIds?: number[];\n\tcatcherId?: number; // tremolo catcher event ID for tremolo pitcher event\n\n\tnoteIds?: string[]; // order by upwards\n\n\tstatic space({ tick, duration }: { tick: number; duration: number }): EventTerm {\n\t\tconst term = new EventTerm({\n\t\t\trest: 's',\n\t\t\ttick,\n\t\t\taccessories: [],\n\t\t});\n\t\tterm.duration = Math.round(duration);\n\n\t\treturn term;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tObject.assign(this, data);\n\n\t\tif (Number.isFinite(data.left) && Number.isFinite(data.right)) this.x = (this.left + this.right) / 2;\n\t\tif (!Number.isFinite(this.pivotX)) this.pivotX = this.x;\n\t\t//console.assert(Number.isFinite(this.x), \"EventTerm: invalid x,\", data);\n\t}\n\n\tget alignedTick(): number {\n\t\treturn this.grace ? this.tick + this.duration : this.tick;\n\t}\n\n\tget mainDuration(): number {\n\t\treturn WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t}\n\n\tget duration(): number {\n\t\tlet value = this.mainDuration;\n\t\tif (this.multiplier) value *= this.multiplier.numerator / this.multiplier.denominator;\n\t\tif (this.timeWarp) value *= this.timeWarp.numerator / this.timeWarp.denominator;\n\n\t\treturn this.grace ? value / 8 : value;\n\t}\n\n\tset duration(value: number) {\n\t\tconsole.assert(Number.isFinite(value), 'invalid duration value:', value);\n\n\t\tconst divider = gcd(value, WHOLE_EXP2);\n\t\tconst division = Math.log2(WHOLE_EXP2 / divider);\n\t\tconst multiplier = reducedFraction(value * 2 ** division, WHOLE_DURATION);\n\n\t\tthis.division = division;\n\t\tthis.dots = 0;\n\n\t\tif (multiplier.numerator !== multiplier.denominator) this.multiplier = multiplier;\n\t\telse this.multiplier = undefined;\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget times(): string {\n\t\tif (!this.timeWarp) return null;\n\n\t\treturn `${this.timeWarp.numerator}/${this.timeWarp.denominator}`;\n\t}\n\n\tget fullMeasureRest(): boolean {\n\t\treturn this.rest === 'R';\n\t}\n\n\tget tipX(): number {\n\t\treturn this.tip ? this.tip.x : this.x;\n\t}\n\n\tget tipY(): number {\n\t\treturn this.tip ? this.tip.y : this.ys ? this.ys[0] : 0;\n\t}\n\n\tget tremoloCatcher(): boolean {\n\t\treturn this.tremoloLink === TremoloLink.Catcher;\n\t}\n\n\tget scaleChord(): string {\n\t\treturn this.pitches.map((pitch) => SCALE_NAMES[(pitch.note + 700) % 7]).join('');\n\t}\n\n\tget zeroHolder(): boolean {\n\t\treturn !!this.grace || this.tremoloCatcher;\n\t}\n}\n\nenum ContextType {\n\tClef,\n\tKeyAcc,\n\tAcc,\n\tOctaveShift,\n\tTimeSignatureC,\n\tTimeSignatureN,\n}\n\nclass ContextedTerm extends Term {\n\tstatic className = 'ContextedTerm';\n\n\ty: number;\n\ttokenType: TokenType;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget type(): ContextType {\n\t\tif (Token.TokenClefs.includes(this.tokenType)) return ContextType.Clef;\n\t\tif (/\\|key-/.test(this.tokenType)) return ContextType.KeyAcc;\n\t\tif (/accidentals-/.test(this.tokenType)) return ContextType.Acc;\n\t\tif (Token.TokenOctshifts.includes(this.tokenType)) return ContextType.OctaveShift;\n\t\tif (Token.TokenTimesigsC.includes(this.tokenType)) return ContextType.TimeSignatureC;\n\t\tif (Token.TokenTimesigsN.includes(this.tokenType)) return ContextType.TimeSignatureN;\n\n\t\treturn null;\n\t}\n\n\tget staffLevel(): boolean {\n\t\treturn [ContextType.OctaveShift, ContextType.Clef, ContextType.KeyAcc].includes(this.type);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.1;\n\t}\n\n\tget clef(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.ClefG:\n\t\t\t\treturn -this.y - 2;\n\n\t\t\tcase TokenType.ClefF:\n\t\t\t\treturn -this.y + 2;\n\n\t\t\tcase TokenType.ClefC:\n\t\t\t\treturn -this.y;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget alter() {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.AccNatural:\n\t\t\tcase TokenType.KeyNatural:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.AccSharp:\n\t\t\tcase TokenType.KeySharp:\n\t\t\t\treturn 1;\n\n\t\t\tcase TokenType.AccFlat:\n\t\t\tcase TokenType.KeyFlat:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.AccDoublesharp:\n\t\t\t\treturn 2;\n\n\t\t\tcase TokenType.AccFlatflat:\n\t\t\t\treturn -2;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget octaveShift(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.OctaveShift8va:\n\t\t\t\treturn -1;\n\n\t\t\tcase TokenType.OctaveShift0:\n\t\t\t\treturn 0;\n\n\t\t\tcase TokenType.OctaveShift8vb:\n\t\t\t\treturn 1;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget number(): number {\n\t\tswitch (this.tokenType) {\n\t\t\tcase TokenType.TimesigZero:\n\t\t\t\treturn 0;\n\t\t\tcase TokenType.TimesigOne:\n\t\t\t\treturn 1;\n\t\t\tcase TokenType.TimesigTwo:\n\t\t\t\treturn 2;\n\t\t\tcase TokenType.TimesigThree:\n\t\t\t\treturn 3;\n\t\t\tcase TokenType.TimesigFour:\n\t\t\t\treturn 4;\n\t\t\tcase TokenType.TimesigFive:\n\t\t\t\treturn 5;\n\t\t\tcase TokenType.TimesigSix:\n\t\t\t\treturn 6;\n\t\t\tcase TokenType.TimesigSeven:\n\t\t\t\treturn 7;\n\t\t\tcase TokenType.TimesigEight:\n\t\t\t\treturn 8;\n\t\t\tcase TokenType.TimesigNine:\n\t\t\t\treturn 9;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n//class BreakTerm extends Term {\n//};\n\nclass MarkTerm extends Term {\n\tstatic className = 'MarkTerm';\n\n\ttick: number;\n\n\tget prior(): number {\n\t\treturn this.tick + 0.01;\n\t}\n}\n\nconst MUSIC_NOTES = Array(7)\n\t.fill(0)\n\t.map((_, i) => String.fromCodePoint(0x1d15d + i));\n\nclass TempoTerm extends MarkTerm {\n\tstatic className = 'TempoTerm';\n\n\tduration: string;\n\tbeats: string;\n\n\tstatic fromNumeralText(text: string): TempoTerm {\n\t\tif (/.+=.*\\d+/.test(text)) {\n\t\t\tconst [symbol, value] = text.split('=');\n\t\t\tlet division = MUSIC_NOTES.findIndex((n) => symbol.includes(n));\n\t\t\tdivision = division >= 0 ? division : 2;\n\t\t\tlet duration = (2 ** division).toString();\n\t\t\tif (symbol.includes('.')) duration += '.';\n\n\t\t\treturn new TempoTerm({ tick: 0, duration, beats: value });\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick - 0.01;\n\t}\n\n\t// a whole note equal to 1920\n\tget durationMagnitude(): number {\n\t\tconst [_, den, dot] = this.duration.match(/^(\\d+)(\\.)?$/);\n\t\tconst magnitude = (WHOLE_DURATION / Number(den)) * (dot ? 1.5 : 1);\n\n\t\treturn magnitude;\n\t}\n\n\t// beats per minute, suppose 1 beat = 480 ticks\n\tget bpm(): number {\n\t\tconst [number] = this.beats.match(/\\d+/) || [90];\n\t\tconst beats = Number(number);\n\n\t\treturn (beats * this.durationMagnitude * 4) / WHOLE_DURATION;\n\t}\n\n\tisValid(range = [10, 400]): boolean {\n\t\tconst bpm = this.bpm;\n\n\t\treturn Number.isFinite(this.bpm) && bpm >= range[0] && bpm < range[1];\n\t}\n}\n\nclass GlyphTerm extends MarkTerm {\n\tstatic className = 'GlyphTerm';\n\n\tglyph: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass TextTerm extends MarkTerm {\n\tstatic className = 'TextTerm';\n\n\tdirection?: AccessoryDirection;\n\ttext: string;\n\tbold: boolean;\n\titalic: boolean;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass LyricTerm extends MarkTerm {\n\tstatic className = 'LyricTerm';\n\n\ttext: string;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass CommandTerm extends MarkTerm {\n\tstatic className = 'CommandTerm';\n\n\tcommand: string;\n\tparameters: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n}\n\nclass ChordmodeTerm extends Term implements DurationalTerm {\n\tstatic className = 'ChordmodeTerm';\n\n\tpitch: Pitch;\n\tbasePitch?: Pitch;\n\tmodifier?: string;\n\n\tdivision: number;\n\tdots: number;\n\tmultiplier: Fraction;\n\n\ttick: number;\n\n\tconstructor(data: any) {\n\t\tsuper();\n\n\t\tObject.assign(this, data);\n\t}\n\n\tget prior(): number {\n\t\treturn this.tick;\n\t}\n\n\tget duration(): number {\n\t\tconst value = WHOLE_DURATION * 2 ** -this.division * (2 - 2 ** -this.dots);\n\t\tif (this.multiplier) return (value * this.multiplier.numerator) / this.multiplier.denominator;\n\n\t\treturn value;\n\t}\n}\n\nexport {\n\tTerm,\n\tEventTerm,\n\tContextedTerm,\n\t//BreakTerm,\n\tMarkTerm,\n\tTempoTerm,\n\tGlyphTerm,\n\tTextTerm,\n\tLyricTerm,\n\tCommandTerm,\n\tChordmodeTerm,\n\tDurationalTerm,\n\tContextType,\n\tGraceType,\n\tTermPitch,\n\tRestType,\n\tGlissandoStyle,\n\tArpeggioStyle,\n\tAccessory,\n\tAccessoryDirection,\n\tWHOLE_DURATION,\n\tStemBeam,\n\tTremoloLink,\n};\n","import { fractionMul, gcd } from './utils';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { StemBeam, WHOLE_DURATION } from './term';\n\nexport interface MeasureEvaluation {\n\tevents: number;\n\tvalidEvents: number;\n\tvoiceRugged: boolean;\n\tnullEvents: number;\n\tfakeEvents: number;\n\twarpedEvents: number;\n\tcomplicatedTimewarp: boolean;\n\tspaceTime: number;\n\tsurplusTime: number;\n\tdurationRate: number;\n\tbeamBroken: boolean;\n\tfractionalWarp: boolean;\n\tirregularWarpsN: number;\n\tirregularTick: boolean;\n\ttickTwist: number;\n\ttickOverlapped: boolean;\n\tgraceInVoice: boolean;\n\tgraceN: number;\n\tgraceDominant: boolean;\n\tperfect: boolean;\n\tfine: boolean;\n\terror: boolean;\n\tqualityScore: number;\n}\n\nconst BEAM_STATUS = {\n\t[StemBeam.Open]: 1,\n\t[StemBeam.Continue]: 0,\n\t[StemBeam.Close]: -1,\n};\n\nexport const evaluateMeasure = (measure: SpartitoMeasure): MeasureEvaluation => {\n\tif (!measure.regulated) return undefined;\n\n\tconst eventMap = measure.eventMap;\n\n\tconst events = measure.events.length;\n\tconst validEvents = measure.voices.flat(1).length;\n\tconst warpedEvents = measure.events.filter((e) => e.timeWarp).length;\n\tconst warps = new Set(\n\t\tmeasure.events.filter((e) => e.timeWarp && !(e.rest && e.division === 0)).map((e) => `${e.timeWarp!.numerator}/${e.timeWarp!.denominator}`)\n\t);\n\tconst irregularWarps = new Set(warps);\n\tirregularWarps.delete('2/3');\n\n\tconst fractionalWarp = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tif (!events.some((e) => e.timeWarp)) return false;\n\n\t\tlet denominator = 0;\n\t\tlet tickSum = 0;\n\t\tlet eventN = 0;\n\t\treturn events.some((event, i) => {\n\t\t\tconst d = event.timeWarp ? event.timeWarp.denominator : 0;\n\t\t\tif (d !== denominator) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\n\t\t\t\ttickSum = 0;\n\t\t\t\teventN = 0;\n\t\t\t}\n\n\t\t\tdenominator = d;\n\t\t\ttickSum += event.duration;\n\t\t\t++eventN;\n\n\t\t\tif (i === events.length - 1) {\n\t\t\t\tif (denominator > 0 && (tickSum % denominator || eventN < 2)) return true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst tickOverlapped = measure.voices.some((voice) => {\n\t\tconst events = voice.map((id) => eventMap[id]);\n\t\tlet tick = 0;\n\t\treturn events.some((event) => {\n\t\t\tif (event.grace) return false;\n\n\t\t\tif (event.tick < tick) return true;\n\t\t\ttick = event.tick + event.duration;\n\n\t\t\treturn false;\n\t\t});\n\t});\n\n\tconst fractionalTimes = new Set(measure.events.filter((e) => e.timeWarp && e.timeWarp.denominator > 3).map((e) => e.duration));\n\tconst complicatedTimewarp = fractionalTimes.size > 1;\n\n\tconst literalDuration = fractionMul(WHOLE_DURATION, measure.timeSignature);\n\tconst sigDuration = measure.doubtfulTimesig ? measure.duration : literalDuration;\n\n\tconst inVoiceEvents = measure.voices.flat(1).map((id) => eventMap[id]);\n\n\t// Guard: detect corrupted event data in voices (e.g. missing division, NaN tick)\n\tconst corruptedVoiceEvent = inVoiceEvents.some(\n\t\t(event) =>\n\t\t\t!event ||\n\t\t\t!Number.isFinite(event.tick) ||\n\t\t\t!Number.isFinite(event.division) ||\n\t\t\tevent.division < 0 ||\n\t\t\t!Number.isFinite(event.duration) ||\n\t\t\tevent.duration <= 0\n\t);\n\n\tconst overranged = inVoiceEvents.reduce((over, event) => over || event.tick < 0 || event.tick + event.duration > sigDuration, false);\n\tconst overDuration = measure.duration > literalDuration;\n\tconst graceInVoice = inVoiceEvents.some((event) => event.grace);\n\tconst graceN = measure.events.filter((e) => e.grace).length;\n\tconst graceDominant = graceN >= inVoiceEvents.length;\n\n\tconst irregularTick = inVoiceEvents.some((event) => {\n\t\tlet t = event.tick * 2 ** (event.division + 2);\n\t\tif (event.timeWarp) t *= event.timeWarp.denominator;\n\n\t\tif (!Number.isFinite(t)) return true;\n\n\t\tconst fragment = gcd(Math.round(t), WHOLE_DURATION);\n\t\t//if (fragment < WHOLE_DURATION)\n\t\t//\tconsole.log(\"irregularTick:\", event.tick, fragment);\n\t\treturn fragment < WHOLE_DURATION;\n\t});\n\n\tconst beamStatus = measure.voices!.map((voice) =>\n\t\tvoice.reduce(\n\t\t\t({ status, broken }, ei) => {\n\t\t\t\tconst event = eventMap[ei];\n\t\t\t\tif (event.beam) {\n\t\t\t\t\tstatus += BEAM_STATUS[event.beam];\n\t\t\t\t\tbroken = broken || !(status >= 0 && status <= 1);\n\t\t\t\t}\n\n\t\t\t\treturn { status, broken };\n\t\t\t},\n\t\t\t{ status: 0, broken: false }\n\t\t)\n\t);\n\tconst beamBroken = beamStatus.some(({ status, broken }) => status || broken);\n\tlet spaceTime = 0;\n\tlet surplusTime = 0;\n\tmeasure.voices!.forEach((voice) => {\n\t\tconst eventDuration = voice.reduce((sum, ei) => sum + eventMap[ei].duration, 0);\n\t\tspaceTime += Math.max(0, measure.duration - eventDuration);\n\t\tsurplusTime += Math.max(0, eventDuration - measure.duration);\n\t});\n\tspaceTime /= WHOLE_DURATION;\n\tconst nullEvents = measure.events.filter(\n\t\t(e) => !e.grace && !e.fullMeasureRest && !e.tremoloCatcher && (!e.predisposition || e.predisposition.fakeP < 0.1) && !Number.isFinite(e.tick)\n\t).length;\n\n\tconst fakeEvents = measure.events.filter(\n\t\t(event) => !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !inVoiceEvents.includes(event)\n\t).length;\n\n\tconst { voiceRugged } = measure.voices!.flat(1).reduce(\n\t\t(result, ei) => {\n\t\t\tif (!result.voiceRugged) {\n\t\t\t\tif (result.es.has(ei)) return { voiceRugged: true, es: result.es };\n\t\t\t}\n\n\t\t\tresult.es.add(ei);\n\n\t\t\treturn result;\n\t\t},\n\t\t{ voiceRugged: false, es: new Set() }\n\t);\n\n\tconst tickTwist = measure.tickTwist || 0;\n\n\tconst error =\n\t\tcorruptedVoiceEvent ||\n\t\ttickTwist >= 1 ||\n\t\ttickOverlapped ||\n\t\tvoiceRugged ||\n\t\tmeasure.tickRatesInStaves.some((rate) => rate < 0) ||\n\t\tnullEvents > 2 ||\n\t\t!measure.timeSignature ||\n\t\toverranged ||\n\t\tmeasure.duration > sigDuration ||\n\t\tmeasure.events.some((event) => event.timeWarp && event.timeWarp.numerator / event.timeWarp.denominator <= 0.5);\n\tconst perfect =\n\t\t!error &&\n\t\t!overDuration &&\n\t\ttickTwist < 0.2 &&\n\t\t!fractionalWarp &&\n\t\t!irregularWarps.size &&\n\t\t!irregularTick &&\n\t\t!spaceTime &&\n\t\t!surplusTime &&\n\t\t!!measure.voices!.length &&\n\t\t!beamBroken &&\n\t\t!graceInVoice &&\n\t\t!graceDominant &&\n\t\t(measure.duration === sigDuration || (Number.isFinite(measure.estimatedDuration) && measure.estimatedDuration <= sigDuration * 0.75));\n\tconst fine = !error && !overDuration && tickTwist < 0.3 && !fractionalWarp && !irregularTick && !surplusTime && !beamBroken && !graceInVoice;\n\n\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\tconst durationRate = measure.duration / expectDuration;\n\n\tlet qualityScore = 0;\n\tif (measure.patched && !corruptedVoiceEvent) qualityScore = 1;\n\telse if (!error) {\n\t\tconst spaceLoss = Math.tanh(Math.abs(spaceTime / Math.max(1, measure.voices.length)) * 1);\n\n\t\tlet expectDuration = Math.min(sigDuration, WHOLE_DURATION * 2);\n\t\tif (Number.isFinite(measure.estimatedDuration)) expectDuration = Math.max(0, Math.min(expectDuration, measure.estimatedDuration));\n\t\tconst durationLoss = expectDuration ? Math.max(0, 1 - durationRate) ** 2 : 0;\n\t\tconst warpsLoss = Math.tanh(irregularWarps.size);\n\n\t\tqualityScore = (1 - spaceLoss) * (1 - durationLoss) * (1 - warpsLoss) * (1 - tickTwist ** 2);\n\t}\n\n\treturn {\n\t\tevents,\n\t\tvalidEvents,\n\t\tvoiceRugged,\n\t\tnullEvents,\n\t\tfakeEvents,\n\t\twarpedEvents,\n\t\tcomplicatedTimewarp,\n\t\tspaceTime,\n\t\tsurplusTime,\n\t\tdurationRate,\n\t\tbeamBroken,\n\t\tfractionalWarp,\n\t\tirregularWarpsN: irregularWarps.size,\n\t\tirregularTick,\n\t\ttickTwist,\n\t\ttickOverlapped,\n\t\tgraceInVoice,\n\t\tgraceN,\n\t\tgraceDominant,\n\t\tperfect,\n\t\tfine,\n\t\terror,\n\t\tqualityScore,\n\t};\n};\n","//import { staffSvg } from \"@kelvinnxu/lotus\";\n\nimport { SemanticType, SemanticPoint, /*glyphSemanticMapping, glyphCenters,*/ SYSTEM_SEMANTIC_TYPES, Point } from './semanticPoint';\nimport { SimpleClass } from './aux_/typedJSON';\n\nclass SemanticGraph extends SimpleClass {\n\tstatic className = 'SemanticGraph';\n\n\tpoints: SemanticPoint[];\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\t/*static fromSheetStaff(staff: staffSvg.SheetStaff, hashTable: {[key: string]: any}): SemanticGraph {\n\t\tconst tokens = [].concat(...staff.measures.map(measure => measure.tokens));\n\n\t\tconst voltaRightXs = [];\n\n\t\tconst points = [];\n\t\ttokens.forEach(token => {\n\t\t\tconst def = hashTable[token.hash];\n\n\t\t\tif (token.glyph) {\n\t\t\t\tconst glyph = token.glyph as string;\n\t\t\t\tlet semantic = null;\n\n\t\t\t\tconst isKey = /^\\\\key/.test(token.source) || token.is(\"KEY\");\n\t\t\t\tlet { x: cx = 0, y: cy = 0 } = glyphCenters[glyph] || { x: 0, y: 0 };\n\t\t\t\tif (token.scale2) {\n\t\t\t\t\tcx *= token.scale2.x;\n\t\t\t\t\tcy *= token.scale2.y;\n\t\t\t\t}\n\n\t\t\t\tlet x = token.x + cx;\n\t\t\t\tconst y = token.y + cy;\n\n\t\t\t\tswitch (glyph) {\n\t\t\t\tcase \"rests.0\":\n\t\t\t\t\tif (/^R/.test(token.source))\n\t\t\t\t\t\tsemantic = \"Rest0W\";\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Rest0\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.flat\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.natural\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"accidentals.sharp\":\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t\tif (isKey) {\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.KeyAcc,\n\t\t\t\t\t\t\tx,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"dots.dot\":\n\t\t\t\t\tif (token.is(\"VOLTA\")) {\n\t\t\t\t\t\tx += 0.24;\t// dot glyph center X offset\n\t\t\t\t\t\tif (token.is(\"LEFT\"))\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaLeft;\n\t\t\t\t\t\telse if (token.is(\"RIGHT\")) {\n\t\t\t\t\t\t\tvoltaRightXs.push(x);\n\t\t\t\t\t\t\tsemantic = SemanticType.VoltaRight;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tsemantic = \"Dot\";\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"zero\":\n\t\t\t\tcase \"one\":\n\t\t\t\tcase \"two\":\n\t\t\t\tcase \"three\":\n\t\t\t\tcase \"four\":\n\t\t\t\tcase \"five\":\n\t\t\t\tcase \"six\":\n\t\t\t\tcase \"seven\":\n\t\t\t\tcase \"eight\":\n\t\t\t\tcase \"nine\": {\n\t\t\t\t\tconst upper = glyph[0].toUpperCase() + glyph.substr(1);\n\t\t\t\t\tsemantic = token.is(\"TIME_SIG\") ? \"Timesig\" + upper : upper;\n\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tsemantic = glyphSemanticMapping[glyph];\n\t\t\t\t}\n\n\t\t\t\tif (semantic) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (token.is(\"TEMPO_NOTEHEAD\")) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.TempoNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// grace noteheads\n\t\t\t\tif (token.is(\"NOTEHEAD\") && Number.isFinite(token.scale) && token.scale < 0.75) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.GraceNotehead,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// semantic from token symbol\n\t\t\tlet semantic = null;\n\t\t\tconst cx = 0;\n\t\t\tlet cy = 0;\n\t\t\tif (token.is(\"OCTAVE\")) {\n\t\t\t\tif (token.is(\"_8\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift8;\n\t\t\t\t\tcy = token.is(\"B\") ? -0.7512 : -0.7256;\n\t\t\t\t}\n\t\t\t\telse if (token.is(\"CLOSE\")) {\n\t\t\t\t\tsemantic = SemanticType.OctaveShift0;\n\t\t\t\t\tcy = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (/^flags/.test(token.glyph)) {\n\t\t\t\tlet direction = 0;\n\t\t\t\tif (/\\.u\\d/.test(token.glyph))\n\t\t\t\t\tdirection = 1;\n\t\t\t\tif (/\\.d\\d/.test(token.glyph))\n\t\t\t\t\tdirection = -1;\n\t\t\t\tif (direction) {\n\t\t\t\t\tconst [n] = token.glyph.match(/\\d+/);\n\t\t\t\t\tconst flagCount = Number(n) - 2;\n\t\t\t\t\t//console.log(\"flags:\", token.glyph, flagCount);\n\t\t\t\t\tfor (let i = 0; i < flagCount; ++i) {\n\t\t\t\t\t\tconst y = token.y + (i + 0.5) * direction;\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t});\n\t\t\t\t\t\t//console.log(\"flags.1:\", token.x, y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"SLUR\")) {\n\t\t\t\tconst d = def && def.d;\n\t\t\t\tif (d) {\n\t\t\t\t\tconst numbers = d.match(/-?[\\d.]+/g).map(Number);\n\t\t\t\t\t//console.log(\"slur:\", numbers);\n\t\t\t\t\tconst x1 = token.x + numbers[0];\n\t\t\t\t\tconst y1 = token.y + numbers[1];\n\t\t\t\t\tconst x2 = token.x + numbers[6];\n\t\t\t\t\tconst y2 = token.y + numbers[7];\n\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurBegin,\n\t\t\t\t\t\tx: x1,\n\t\t\t\t\t\ty: y1,\n\t\t\t\t\t});\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.SlurEnd,\n\t\t\t\t\t\tx: x2,\n\t\t\t\t\t\ty: y2,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (token.is(\"NOTE_STEM\")) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.vline_Stem,\n\t\t\t\t\tx: token.x + def.width / 2,\n\t\t\t\t\ty: token.y,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: token.y,\n\t\t\t\t\t\ty2: token.y + token.height,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\telse if (token.is(\"TEXT\") || token.is(\"CHORD_TEXT\")) {\n\t\t\t\tif (/\\S/.test(token.text)) {\n\t\t\t\t\t// NOTE: text rect computation is delayed to sheet rendering\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\tindex: token.index,\n\t\t\t\t\t\t\ttext: token.text,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx: token.x + cx,\n\t\t\t\t\ty: token.y + cy,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\t// beams\n\t\tconst stems = tokens.filter(token => token.is(\"NOTE_STEM\")).map(stem => ({\n\t\t\tx: stem.x + stem.width / 2,\n\t\t\ty1: stem.y,\n\t\t\ty2: stem.y + stem.height,\n\t\t}));\n\t\tconst beams = tokens.filter(token => token.is(\"NOTETAIL\") && token.is(\"JOINT\"))\n\t\t\t.map(beam => {\n\t\t\t\tconst def = hashTable[beam.hash];\n\t\t\t\tconst points = def && def.points;\n\t\t\t\tif (points) {\n\t\t\t\t\tconst floats = points.split(\" \").map(Number);\n\t\t\t\t\tconst x1 = beam.x + floats[4];\n\t\t\t\t\tconst x2 = beam.x + floats[0];\n\t\t\t\t\tconst y1 = beam.y + (floats[5] + floats[7]) / 2;\n\t\t\t\t\tconst y2 = beam.y + (floats[1] + floats[3]) / 2;\n\t\t\t\t\tconst k = (y2 - y1) / (x2 - x1);\n\n\t\t\t\t\treturn { x1, x2, y1, y2, k, capital: beam.is(\"CAPITAL_BEAM\") };\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}).filter(Boolean);\n\t\t//console.log(\"beams:\", beams);\n\t\tbeams.forEach(beam => {\n\t\t\tconst innerStems = stems.filter(stem => stem.x > beam.x1 - 0.2 && stem.x < beam.x2 + 0.2);\n\t\t\t//console.log(\"innerStems:\", beam, innerStems);\n\n\t\t\tlet lines = 0;\n\t\t\tinnerStems.forEach(stem => {\n\t\t\t\tconst beamY = beam.y1 + (stem.x - beam.x1) * beam.k;\n\t\t\t\t//console.log(\"beamY:\", beamY, Math.min(Math.abs(beamY - beam.y1), Math.abs(beamY - beam.y2)));\n\t\t\t\tif (beamY >= stem.y1 - 0.1 && beamY <= stem.y2 + 0.1) {\n\t\t\t\t\tpoints.push({\n\t\t\t\t\t\tsemantic: SemanticType.Flag3,\n\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t});\n\n\t\t\t\t\t++lines;\n\n\t\t\t\t\t// beam semantics\n\t\t\t\t\tif (beam.capital) {\n\t\t\t\t\t\tlet semantic = SemanticType.BeamContinue;\n\t\t\t\t\t\tif (Math.abs(stem.x - beam.x1) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamLeft;\n\t\t\t\t\t\telse if (Math.abs(stem.x - beam.x2) < 0.2)\n\t\t\t\t\t\t\tsemantic = SemanticType.BeamRight;\n\n\t\t\t\t\t\tpoints.push({\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x,\n\t\t\t\t\t\t\ty: beamY,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!lines)\n\t\t\t\tconsole.warn(\"empty beam:\", beam, innerStems, stems);\n\t\t\t//else if (lines < 2)\n\t\t\t//\tconsole.debug(\"single beam:\", beam, innerStems, stems);\n\t\t});\n\n\t\t// wedges (crescendo & decrescendo)\n\t\tconst crescendos = tokens.filter(token => token.is(\"WEDGE CRESCENDO TOP\"));\n\t\tconst crescendoBottoms = tokens.filter(token => token.is(\"WEDGE CRESCENDO BOTTOM\"));\n\t\tconst decrescendos = tokens.filter(token => token.is(\"WEDGE DECRESCENDO TOP\"));\n\t\tconst decrescendoBottoms = tokens.filter(token => token.is(\"WEDGE DECRESCENDO BOTTOM\"));\n\t\tcrescendos.forEach(line => {\n\t\t\tconst partner = crescendoBottoms.find(b => b.x === line.x && Math.abs(b.y - line.y) < 0.06);\n\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.CrescendoBegin,\n\t\t\t\t\tx: line.x,\n\t\t\t\t\ty: line.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired crescendo:\", line, crescendoBottoms);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.CrescendoEnd,\n\t\t\t\tx: line.x + line.target.x,\n\t\t\t\ty: line.y + line.target.y,\n\t\t\t});\n\t\t});\n\t\tdecrescendos.forEach(line => {\n\t\t\tconst partner = decrescendoBottoms.find(b => b.x + b.target.x === line.x + line.target.x && Math.abs(b.y + b.target.y - (line.y + line.target.y)) < 0.06);\n\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.DecrescendoBegin,\n\t\t\t\tx: line.x,\n\t\t\t\ty: line.y,\n\t\t\t});\n\t\t\tif (partner) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic: SemanticType.DecrescendoEnd,\n\t\t\t\t\tx: line.x + line.target.x,\n\t\t\t\t\ty: line.y + line.target.y,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.log(\"unpaired decrescendo:\", line, decrescendoBottoms);\n\t\t});\n\n\t\t// TODO: volta alternative\n\n\t\t// measure bars\n\t\tconst measureSeparators = staff.tokens.filter(token => token.is(\"MEASURE_SEPARATOR\"));\n\t\tconst singleBars = [];\n\t\tconst groupBars = [];\n\n\t\tfor (let i = 0; i < measureSeparators.length; ++i) {\n\t\t\tconst bar = measureSeparators[i];\n\t\t\tconst nextBar = measureSeparators[i + 1];\n\t\t\tconst inteval = nextBar ? nextBar.x - bar.x : Infinity;\n\n\t\t\tif (inteval < 1) {\n\t\t\t\tgroupBars.push([bar, nextBar]);\n\t\t\t\t++i;\n\t\t\t}\n\t\t\telse\n\t\t\t\tsingleBars.push(bar);\n\t\t};\n\t\t//console.log(\"bars:\", singleBars, groupBars);\n\n\t\tsingleBars.forEach(bar => {\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx: bar.x + bar.sw / 2,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\tgroupBars.forEach(group => {\n\t\t\tlet x = (group[0].x + group[1].x) / 2;\n\t\t\tconst bold0 = group[0].is(\"BOLD\");\n\t\t\tconst bold1 = group[1].is(\"BOLD\");\n\n\t\t\tlet semantic = null;\n\t\t\tif (!bold0 && bold1) {\n\t\t\t\tx = group[0].x;\n\n\t\t\t\tif (!voltaRightXs.some(vx => x - vx < 2))\n\t\t\t\t\tsemantic = SemanticType.vline_BarTerminal;\n\t\t\t}\n\t\t\telse if (bold0 && !bold1)\n\t\t\t\tx = group[1].x;\n\t\t\telse if (!bold0 && !bold1)\n\t\t\t\tsemantic = SemanticType.vline_BarSegment;\n\n\t\t\t//console.log(\"group:\", group[0].x, group[1].x, x);\n\t\t\tpoints.push({\n\t\t\t\tsemantic: SemanticType.vline_BarMeasure,\n\t\t\t\tx,\n\t\t\t\ty: 0,\n\t\t\t\textension: {\n\t\t\t\t\ty1: -2,\n\t\t\t\t\ty2: 2,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (semantic) {\n\t\t\t\tpoints.push({\n\t\t\t\t\tsemantic,\n\t\t\t\t\tx,\n\t\t\t\t\ty: 0,\n\t\t\t\t\textension: {\n\t\t\t\t\t\ty1: -2,\n\t\t\t\t\t\ty2: 2,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}*/\n\n\tstatic fromPoints(points: SemanticPoint[] = []): SemanticGraph {\n\t\tconst graph = new SemanticGraph();\n\t\tgraph.points = points;\n\n\t\treturn graph;\n\t}\n\n\tgetLayer(semantic: SemanticType): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic);\n\t}\n\n\tgetConfidentLayer(semantic: SemanticType, threshold: number): Point[] {\n\t\treturn this.points.filter((p) => p.semantic === semantic && (!Number.isFinite(p.confidence) || p.confidence >= threshold));\n\t}\n\n\tgetSystemPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\tgetStaffPoints(): SemanticPoint[] {\n\t\treturn this.points.filter((point) => !SYSTEM_SEMANTIC_TYPES.includes(point.semantic));\n\t}\n\n\toffset(x: number, y: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x += x;\n\t\t\tpoint.y += y;\n\t\t});\n\t}\n\n\tscale(factor: number): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tpoint.x *= factor;\n\t\t\tpoint.y *= factor;\n\t\t});\n\t}\n\n\t// multipy 3x2 matrix\n\ttransform(matrix: [number, number][]): void {\n\t\tthis.points.forEach((point) => {\n\t\t\tlet x = point.x * matrix[0][0] + point.y * matrix[1][0] + matrix[2][0];\n\t\t\tconst y = point.x * matrix[0][1] + point.y * matrix[1][1] + matrix[2][1];\n\n\t\t\tif (point.extension) {\n\t\t\t\tif (Number.isFinite(point.extension.y1)) {\n\t\t\t\t\tconst y1 = point.x * matrix[0][1] + point.extension.y1 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tconst y2 = point.x * matrix[0][1] + point.extension.y2 * matrix[1][1] + matrix[2][1];\n\t\t\t\t\tx = point.x * matrix[0][0] + (point.extension.y1 + point.extension.y2) * 0.5 * matrix[1][0] + matrix[2][0];\n\n\t\t\t\t\tpoint.extension.y1 = y1;\n\t\t\t\t\tpoint.extension.y2 = y2;\n\t\t\t\t}\n\n\t\t\t\tif (Number.isFinite(point.extension.width)) {\n\t\t\t\t\tconst scaling = Math.sqrt(matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]);\n\t\t\t\t\tpoint.extension.width *= scaling;\n\t\t\t\t\tpoint.extension.height *= scaling;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpoint.x = x;\n\t\t\tpoint.y = y;\n\t\t});\n\t}\n}\n\nexport { SemanticGraph };\n","import { SimpleClass } from './aux_/typedJSON';\nimport {\n\tRect,\n\tChordRect,\n\tVLine,\n\tChordColumn,\n\tEventMeasureColumn,\n\tEventSystem,\n\tSourceImageFile,\n\tPageLayout,\n\tAdditionalLineStack,\n\tTextType,\n\tEventFeature,\n} from './interfaces';\nimport { distance2D, solveOverlapping, roundNumber, trans23 } from './utils';\nimport {\n\tToken,\n\tTextToken,\n\tTokenType,\n\tTokenNoteheads,\n\tTokenFlags,\n\tTokenDots,\n\tTokenRests,\n\tTokenAccessories,\n\tTokenDirectionless,\n\tTokenClefs,\n\tTokenBeams,\n\tTokenTimesigs,\n\tTOKEN_Y_FIXED,\n\tTOKEN_Y_ROUND,\n} from './token';\nimport { EventTerm, ContextedTerm, MarkTerm, TempoTerm, AccessoryDirection, GraceType, ContextType, TremoloLink } from './term';\nimport { SemanticGraph } from './semanticGraph';\nimport { SemanticType, SemanticPoint, NOTEHEAD_WIDTHS, hashSemanticPoint, hashPageSemanticPoint } from './semanticPoint';\nimport { Logger, DummyLogger } from './logger';\n\ntype ChordsFeeder = (si: number, mi: number) => ChordColumn[];\ntype ColumnProcessor = (column: EventMeasureColumn) => EventMeasureColumn;\n\nconst CHORD_X_TOLERANCE = 0.2;\n//const EVENT_X_TOLERANCE = 0.8;\n\nconst STEM_LENGTH_MAX = 6;\n\nconst INDENT_THRESHOLD = 2;\n\nconst MEASURE_SEMANTICS = [\n\tSemanticType.ClefG,\n\tSemanticType.ClefF,\n\tSemanticType.ClefC,\n\tSemanticType.TimesigC44,\n\tSemanticType.TimesigC22,\n\tSemanticType.TimesigZero,\n\tSemanticType.TimesigOne,\n\tSemanticType.TimesigTwo,\n\tSemanticType.TimesigThree,\n\tSemanticType.TimesigFour,\n\tSemanticType.TimesigFive,\n\tSemanticType.TimesigSix,\n\tSemanticType.TimesigSeven,\n\tSemanticType.TimesigEight,\n\tSemanticType.TimesigNine,\n\tSemanticType.OctaveShift8va,\n\tSemanticType.OctaveShift8vb,\n\tSemanticType.OctaveShift0,\n\tSemanticType.Zero,\n\tSemanticType.One,\n\tSemanticType.Two,\n\tSemanticType.Three,\n\tSemanticType.Four,\n\tSemanticType.Five,\n\tSemanticType.Six,\n\tSemanticType.Seven,\n\tSemanticType.Eight,\n\tSemanticType.Nine,\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n\tSemanticType.Rest0W,\n\tSemanticType.RestM1,\n\tSemanticType.SlurBegin,\n\tSemanticType.SlurEnd,\n\tSemanticType.Dot,\n\tSemanticType.f,\n\tSemanticType.p,\n\tSemanticType.m,\n\tSemanticType.n,\n\tSemanticType.r,\n\tSemanticType.s,\n\tSemanticType.z,\n\tSemanticType.ScriptFermata,\n\tSemanticType.ScriptShortFermata,\n\tSemanticType.ScriptSforzato,\n\tSemanticType.ScriptStaccato,\n\tSemanticType.ScriptStaccatissimo,\n\tSemanticType.ScriptTurn,\n\tSemanticType.ScriptTrill,\n\tSemanticType.ScriptSegno,\n\tSemanticType.ScriptCoda,\n\tSemanticType.ScriptArpeggio,\n\tSemanticType.ScriptPrall,\n\tSemanticType.ScriptMordent,\n\tSemanticType.ScriptMarcato,\n\tSemanticType.ScriptTenuto,\n\tSemanticType.ScriptPortato,\n\tSemanticType.PedalStar,\n\tSemanticType.PedalPed,\n\tSemanticType.GraceNotehead,\n\tSemanticType.BeamLeft,\n\tSemanticType.BeamRight,\n\tSemanticType.BeamContinue,\n\tSemanticType.CrescendoBegin,\n\tSemanticType.CrescendoEnd,\n\tSemanticType.DecrescendoBegin,\n\tSemanticType.DecrescendoEnd,\n\tSemanticType.TremoloLeft,\n\tSemanticType.TremoloRight,\n\tSemanticType.TremoloMiddle,\n];\n\nconst STAFF_LINED_SEMANTICS = [\n\tSemanticType.AccNatural,\n\tSemanticType.AccSharp,\n\tSemanticType.AccDoublesharp,\n\tSemanticType.AccFlat,\n\tSemanticType.AccFlatflat,\n\tSemanticType.NoteheadS0,\n\tSemanticType.NoteheadS1,\n\tSemanticType.NoteheadS2,\n\tSemanticType.NoteheadS1stemU,\n\tSemanticType.NoteheadS1stemD,\n\tSemanticType.NoteheadS2stemU,\n\tSemanticType.NoteheadS2stemD,\n];\n\nconst LINED_INTERVAL_SEMANTICS = [SemanticType.SignLined, SemanticType.SignInterval];\n\nconst NOTEHEAD_FOR_STEM_SEMANTICS = [SemanticType.NoteheadS1, SemanticType.NoteheadS2];\n\nconst KEYACC_CANDIDATE_SEMANTICS = {\n\tAccSharp: TokenType.KeySharp,\n\tAccNatural: TokenType.KeyNatural,\n\tAccFlat: TokenType.KeyFlat,\n};\n\nconst NOTEHEAD_TABLE: { [key: string]: { [key: string]: SemanticType } } = {\n\t[SemanticType.NoteheadS1]: {\n\t\tup: SemanticType.NoteheadS1stemU,\n\t\tdown: SemanticType.NoteheadS1stemD,\n\t},\n\t[SemanticType.NoteheadS2]: {\n\t\tup: SemanticType.NoteheadS2stemU,\n\t\tdown: SemanticType.NoteheadS2stemD,\n\t},\n};\n\nconst REST_SEMANTICS = [\n\tSemanticType.Rest0,\n\tSemanticType.Rest1,\n\tSemanticType.Rest2,\n\tSemanticType.Rest3,\n\tSemanticType.Rest4,\n\tSemanticType.Rest5,\n\tSemanticType.Rest6,\n];\n\nconst TOKEN_TO_STEMBEAM = {\n\t[TokenType.BeamLeft]: 'Open',\n\t[TokenType.BeamRight]: 'Close',\n\t[TokenType.BeamContinue]: 'Continue',\n};\n\nconst TEXT_TYPE_ALIAS = {\n\tAlter1: TextType.Alternation1,\n\tAlter2: TextType.Alternation2,\n};\n\ninterface StaffPosition {\n\ty: number;\n\tradius: number;\n}\n\ninterface TextArea {\n\tscore: number;\n\tcx: number;\n\tcy: number;\n\twidth: number;\n\theight: number;\n\ttext: string;\n\ttype: string;\n\ttheta: number;\n\tfeature_dict: Record;\n}\n\ntype Stem = VLine & { direction: 'u' | 'd' };\n\nconst noteheadsXPivot = (xs: number[], direction: 'u' | 'd' | null): number => {\n\tswitch (xs.length) {\n\t\tcase 0:\n\t\t\treturn undefined;\n\n\t\tcase 1:\n\t\t\treturn xs[0];\n\n\t\tcase 2:\n\t\t\treturn direction === 'u' ? Math.min(...xs) : Math.max(...xs);\n\n\t\tdefault: {\n\t\t\tconst mean = xs.reduce((sum, x) => sum + x, 0) / xs.length;\n\t\t\txs.sort((x1, x2) => Math.abs(x1 - mean) - Math.abs(x2 - mean));\n\n\t\t\treturn noteheadsXPivot(xs.slice(0, xs.length - 1), direction);\n\t\t}\n\t}\n};\n\nconst noteheadsPivot = (nhs: Token[]): number =>\n\tnoteheadsXPivot(\n\t\tnhs.map((nh) => (Number.isFinite(nh.pivotX) ? nh.pivotX : nh.x)),\n\t\tnhs[0].direction\n\t);\n\nclass Measure extends SimpleClass {\n\tstatic className = 'Measure';\n\tstatic blackKeys = ['tokens', 'antiTokens'];\n\n\tleft: number;\n\twidth: number;\n\theight: number;\n\n\talternative: boolean;\n\n\ttokens: Token[];\n\tantiTokens: Token[];\n\n\tbarTypes: Record;\n\n\tconstructor(data?: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.tokens = this.tokens || [];\n\t\tthis.antiTokens = this.antiTokens || [];\n\t\tthis.barTypes = this.barTypes || {};\n\t}\n\n\tget right(): number {\n\t\treturn this.left + this.width;\n\t}\n\n\tget noteheads(): Token[] {\n\t\treturn this.tokens.filter((t) => t.isNotehead).sort((n1, n2) => n1.x - n2.x);\n\t}\n\n\tget chordRects(): ChordRect[] {\n\t\tconst noteheads = this.noteheads.filter((nh) =>\n\t\t\t[TokenType.NoteheadS0, TokenType.NoteheadS1stemU, TokenType.NoteheadS2stemU, TokenType.NoteheadS1stemD, TokenType.NoteheadS2stemD].includes(nh.type)\n\t\t);\n\n\t\tlet nulN = 0;\n\n\t\tconst nhmap: Record = noteheads.reduce((map, nh) => {\n\t\t\tconst tip = nh.tip ? `${nh.tip.x}|${nh.tip.y}` : `nul${nulN}`;\n\t\t\tlet key = `${nh.type}|${tip}`;\n\n\t\t\tif (!nh.tip && map[key]) {\n\t\t\t\tif (!map[key].some((hh) => Math.abs(hh.x - nh.x) < NOTEHEAD_WIDTHS.NoteheadS0)) {\n\t\t\t\t\t++nulN;\n\t\t\t\t\tkey = `${nh.type}|nul${nulN}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tmap[key] = map[key] || [];\n\t\t\tmap[key].push(nh);\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(nhmap).map((nhs) => {\n\t\t\tconst left = Math.min(...nhs.map((nh) => nh.x));\n\t\t\tconst right = Math.max(...nhs.map((nh) => nh.x));\n\t\t\tconst top = Math.min(...nhs.map((nh) => nh.y));\n\t\t\tconst bottom = Math.max(...nhs.map((nh) => nh.y));\n\n\t\t\tconst nh0 = nhs[0];\n\n\t\t\tconst stemX = nh0 && nh0.tip ? nh0.tip.x : left;\n\n\t\t\tlet x = left;\n\t\t\tlet width = right - left;\n\t\t\tlet stemDirection = null;\n\n\t\t\tswitch (nh0.type) {\n\t\t\t\tcase TokenType.NoteheadS0:\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS0 / 2;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemU:\n\t\t\t\tcase TokenType.NoteheadS2stemU:\n\t\t\t\t\tstemDirection = 'u';\n\t\t\t\t\tx -= NOTEHEAD_WIDTHS.NoteheadS1;\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase TokenType.NoteheadS1stemD:\n\t\t\t\tcase TokenType.NoteheadS2stemD:\n\t\t\t\t\tstemDirection = 'd';\n\t\t\t\t\twidth += NOTEHEAD_WIDTHS.NoteheadS1;\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tx,\n\t\t\t\twidth,\n\t\t\t\tstemX,\n\t\t\t\tstemDirection,\n\t\t\t\ttop,\n\t\t\t\tbottom,\n\t\t\t\ttip: nh0.tip,\n\t\t\t};\n\t\t});\n\t}\n\n\tget timeWarped(): boolean {\n\t\treturn this.tokens && this.tokens.some((token) => token.timeWarped);\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\tconst chords = this.getChords();\n\t\tconst up = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y <= -3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.ceil(Math.min(...chord.ys)) + 2,\n\t\t\t}));\n\t\tconst down = chords\n\t\t\t.filter((chord) => chord.ys.some((y) => y >= 3))\n\t\t\t.map((chord) => ({\n\t\t\t\tleft: chord.left,\n\t\t\t\tright: chord.right,\n\t\t\t\tn: Math.floor(Math.max(...chord.ys)) - 2,\n\t\t\t}));\n\n\t\treturn [...up, ...down].map((stack) => ({\n\t\t\tleft: stack.left - 0.28,\n\t\t\tright: stack.right + 0.28,\n\t\t\tn: stack.n,\n\t\t}));\n\t}\n\n\tgetChords(): ChordColumn[] {\n\t\tconst flags = this.tokens.filter((t) => TokenFlags.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\t\tconst beams = this.tokens.filter((t) => TokenBeams.includes(t.type));\n\n\t\tconst chordRcs = this.chordRects\n\t\t\t.map((rect) => {\n\t\t\t\tconst noteheads = this.noteheads.filter(\n\t\t\t\t\t(nh) =>\n\t\t\t\t\t\tnh.direction === rect.stemDirection &&\n\t\t\t\t\t\tnh.left >= rect.x &&\n\t\t\t\t\t\tnh.right <= rect.x + rect.width + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tnh.y >= rect.top &&\n\t\t\t\t\t\tnh.y <= rect.bottom\n\t\t\t\t);\n\t\t\t\tnoteheads.sort((n1, n2) => n2.y - n1.y);\n\t\t\t\tconst ys = noteheads.map((nh) => nh.y);\n\t\t\t\tconst noteIds = noteheads.map((nh) => nh.id);\n\n\t\t\t\tconst division = noteheads.reduce((d, nh) => Math.max(d, nh.division), 0);\n\n\t\t\t\treturn {\n\t\t\t\t\trect,\n\t\t\t\t\tleft: rect.x,\n\t\t\t\t\tright: rect.x + rect.width,\n\t\t\t\t\tpivotX: noteheadsPivot(noteheads),\n\t\t\t\t\tys,\n\t\t\t\t\ttip: rect.tip,\n\t\t\t\t\tnoteIds,\n\t\t\t\t\tdivision,\n\t\t\t\t\tdots: null,\n\t\t\t\t\trest: false,\n\t\t\t\t\tstemDirection: rect.stemDirection,\n\t\t\t\t\tbeam: null,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.sort((c1, c2) => c2.left - c1.left);\n\n\t\tconst accs = new Set();\n\n\t\tconst chords = chordRcs.map(({ rect, ...chord }) => {\n\t\t\tif (chord.division >= 1) {\n\t\t\t\t// NOTE: notehead-s1 may have flags too\n\t\t\t\tconst flagRange = [rect.bottom, rect.top];\n\t\t\t\tswitch (rect.stemDirection) {\n\t\t\t\t\tcase 'u':\n\t\t\t\t\t\tflagRange[0] = rect.tip ? rect.tip.y - 0.2 : rect.top - STEM_LENGTH_MAX - 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'd':\n\t\t\t\t\t\tflagRange[1] = rect.tip ? rect.tip.y + 0.2 : rect.bottom + STEM_LENGTH_MAX + 0.5;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst nearbyFlags = flags.filter(\n\t\t\t\t\t(flag) =>\n\t\t\t\t\t\t!accs.has(flag.id) &&\n\t\t\t\t\t\tflag.x > rect.stemX - CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.x < rect.stemX + CHORD_X_TOLERANCE &&\n\t\t\t\t\t\tflag.y > flagRange[0] &&\n\t\t\t\t\t\tflag.y < flagRange[1]\n\t\t\t\t);\n\t\t\t\tchord.division = nearbyFlags.reduce((d, flag) => Math.max(d, flag.division), chord.division);\n\n\t\t\t\tnearbyFlags.forEach((flag) => accs.add(flag.id));\n\n\t\t\t\tconst beamToken = rect.tip && beams.find((t) => Math.abs(rect.tip.x - t.x) < 0.3 && Math.abs(rect.tip.y - t.y) < 0.7);\n\t\t\t\tif (beamToken) chord.beam = TOKEN_TO_STEMBEAM[beamToken.type];\n\t\t\t}\n\n\t\t\tconst nearbyDots = dots.filter(\n\t\t\t\t(dot) =>\n\t\t\t\t\t!accs.has(dot.id) &&\n\t\t\t\t\tdot.x > rect.x + rect.width - 0.2 &&\n\t\t\t\t\tdot.x < rect.x + rect.width + 1.2 &&\n\t\t\t\t\tdot.y > rect.top - 1 &&\n\t\t\t\t\tdot.y <= rect.bottom + 0.5\n\t\t\t);\n\t\t\tchord.dots = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\tnearbyDots.forEach((dot) => accs.add(dot.id));\n\n\t\t\treturn chord;\n\t\t});\n\n\t\tchords.reverse();\n\n\t\treturn chords;\n\t}\n\n\tgetRests(): ChordColumn[] {\n\t\tconst rests = this.tokens.filter((t) => TokenRests.includes(t.type));\n\t\tconst dots = this.tokens.filter((t) => TokenDots.includes(t.type));\n\n\t\treturn rests.map((rest) => {\n\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > rest.x + 0.5 && dot.x < rest.x + 2 && dot.y > rest.y - 1 && dot.y < rest.y + 0.5);\n\t\t\tconst dotValue = nearbyDots.reduce((v, dot) => Math.max(v, dot.dots), 0);\n\n\t\t\treturn {\n\t\t\t\tleft: rest.x - 0.75,\n\t\t\t\tright: rest.x + 0.75,\n\t\t\t\tpivotX: rest.x,\n\t\t\t\trest: true,\n\t\t\t\tys: [rest.y],\n\t\t\t\tnoteIds: [rest.id],\n\t\t\t\tdots: dotValue,\n\t\t\t\tdivision: rest.division,\n\t\t\t\tstemDirection: null,\n\t\t\t};\n\t\t});\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\treturn [...this.getChords(), ...this.getRests()].sort((e1, e2) => e1.left - e2.left);\n\t}\n\n\tgetContexts(fields = {}): ContextedTerm[] {\n\t\treturn this.tokens\n\t\t\t.filter((t) => t.isContexted)\n\t\t\t.sort((n1, n2) => n1.x - n2.x)\n\t\t\t.map(\n\t\t\t\t(token) =>\n\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\tx: token.x,\n\t\t\t\t\t\ty: token.y,\n\t\t\t\t\t\ttokenType: token.type,\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t})\n\t\t\t);\n\t}\n\n\tassignAccessoriesOnEvents(events: ChordColumn[]): void {\n\t\tevents.forEach((event) => (event.accessories = event.accessories || []));\n\n\t\tconst accessories = this.tokens.filter((token) => TokenAccessories.includes(token.type));\n\t\t//console.log(\"accessories:\", accessories);\n\t\taccessories.forEach((accessory) => {\n\t\t\tconst relatedEvents = events.filter((event) => accessory.x > event.left - 1 && accessory.x < event.right + 1);\n\n\t\t\tif (relatedEvents.length > 0) {\n\t\t\t\tlet owner = relatedEvents[0];\n\t\t\t\tif (relatedEvents.length > 1) {\n\t\t\t\t\towner = relatedEvents\n\t\t\t\t\t\t.map((event) => ({ event, d: Math.min(...event.ys.map((y) => Math.abs(y - accessory.y))) }))\n\t\t\t\t\t\t.sort(({ d: d1 }, { d: d2 }) => d1 - d2)\n\t\t\t\t\t\t.map(({ event }) => event)[0];\n\t\t\t\t}\n\t\t\t\t//console.log(\"relatedEvents:\", accessory, owner);\n\n\t\t\t\tlet direction = accessory.y > Math.max(...owner.ys) ? AccessoryDirection.Down : AccessoryDirection.Up;\n\t\t\t\tif (TokenDirectionless.includes(accessory.type)) direction = null;\n\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: accessory.type,\n\t\t\t\t\tid: accessory.id,\n\t\t\t\t\tdirection,\n\t\t\t\t\tx: accessory.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone accessory:\", accessory.type);\n\t\t});\n\n\t\t// arpeggio\n\t\tconst sortEvents = [...events];\n\t\tsortEvents.sort((e1, e2) => e1.left - e2.left);\n\n\t\tconst arpeggios = this.tokens.filter((token) => token.type === TokenType.ScriptArpeggio);\n\t\tarpeggios.forEach((arpeggio) => {\n\t\t\tconst owner = sortEvents.find(\n\t\t\t\t(event) => arpeggio.x < event.left && event.ys.some((y) => y < arpeggio.y + 0.25) && event.ys.some((y) => y > arpeggio.y)\n\t\t\t);\n\t\t\t//const owner = sortEvents.find(event => event.left - leftMost.left < 2 && event.ys.some(y => Math.abs(y - arpeggio.y + 0.25) < 0.5));\n\t\t\tif (owner) {\n\t\t\t\towner.accessories.push({\n\t\t\t\t\ttype: TokenType.ScriptArpeggio,\n\t\t\t\t\tid: arpeggio.id,\n\t\t\t\t\tx: arpeggio.x - owner.left,\n\t\t\t\t});\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"alone arpeggio:\", arpeggio);\n\t\t});\n\n\t\t// grace noteheads\n\t\tconst graceNhs = this.tokens.filter((token) => token.type === TokenType.GraceNotehead);\n\t\tgraceNhs.forEach((grace) => {\n\t\t\tconst event = events.find((event) => grace.x > event.left && grace.x < event.right && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tif (event) event.grace = GraceType.Grace;\n\t\t});\n\n\t\t// tremolos\n\t\tconst tremolsLs = this.tokens.filter((token) => token.type === TokenType.TremoloLeft);\n\t\tconst tremolsRs = this.tokens.filter((token) => token.type === TokenType.TremoloRight);\n\t\tconst tremolsMs = this.tokens.filter((token) => token.type === TokenType.TremoloMiddle);\n\n\t\tconst tevents = events\n\t\t\t.filter((event) => !event.rest)\n\t\t\t.map((event) => {\n\t\t\t\tconst ys = [...event.ys];\n\t\t\t\tif (event.tip) ys.push(event.tip.y);\n\t\t\t\telse {\n\t\t\t\t\tys.push(event.ys[0] + 2);\n\t\t\t\t\tys.push(event.ys[event.ys.length - 1] - 2);\n\t\t\t\t}\n\n\t\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\t\t\t\tconst stemR = event.tip ? event.tip.x : event.right;\n\n\t\t\t\treturn {\n\t\t\t\t\tevent,\n\t\t\t\t\ttop: Math.min(...ys),\n\t\t\t\t\tbottom: Math.max(...ys),\n\t\t\t\t\tstemL,\n\t\t\t\t\tstemR,\n\t\t\t\t};\n\t\t\t});\n\n\t\ttremolsMs.forEach((tm) => {\n\t\t\tconst te = tevents.find((te) => {\n\t\t\t\tif (te.event.tip) return tm.y > te.top && tm.y < te.bottom && Math.abs(tm.x - te.event.tip.x) < 0.3;\n\n\t\t\t\treturn false;\n\t\t\t});\n\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t}\n\t\t});\n\t\ttremolsLs.forEach((tl) => {\n\t\t\tconst te = tevents.find((te) => tl.y > te.top && tl.y < te.bottom && tl.x > te.stemR && tl.x < te.stemR + 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Pitcher;\n\t\t\t}\n\t\t});\n\t\ttremolsRs.forEach((tr) => {\n\t\t\tconst te = tevents.find((te) => tr.y > te.top && tr.y < te.bottom && tr.x < te.stemL && tr.x > te.stemL - 1.6);\n\t\t\tif (te) {\n\t\t\t\tte.event.tremolo = te.event.tremolo || 2;\n\t\t\t\t++te.event.tremolo;\n\t\t\t\tte.event.tremoloLink = TremoloLink.Catcher;\n\t\t\t}\n\t\t});\n\t}\n\n\tassignFeaturesOnEvents(events: ChordColumn[], semantics: SemanticPoint[]): void {\n\t\tconst points = semantics.filter((point) => point.x > this.left && point.x < this.right);\n\t\tconst rests = points.filter((point) => REST_SEMANTICS.includes(point.semantic));\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tconst dotPs = points.filter((point) => point.semantic === SemanticType.Dot);\n\t\tconst beamLs = points.filter((points) => points.semantic === SemanticType.BeamLeft);\n\t\tconst beamMs = points.filter((points) => points.semantic === SemanticType.BeamContinue);\n\t\tconst beamRs = points.filter((points) => points.semantic === SemanticType.BeamRight);\n\t\tconst gracePs = points.filter((point) => point.semantic === SemanticType.GraceNotehead);\n\t\tconst tremoloRs = points.filter((point) => point.semantic === SemanticType.TremoloRight);\n\t\tconst stems = points.filter((point) => point.semantic === SemanticType.vline_Stem);\n\t\tconst s0 = points.filter((point) => point.semantic === SemanticType.NoteheadS0);\n\t\tconst s1 = points.filter((point) => point.semantic === SemanticType.NoteheadS1);\n\t\tconst s2 = points.filter((point) => point.semantic === SemanticType.NoteheadS2);\n\n\t\tevents.forEach((event) => {\n\t\t\tconst cx = event.tip ? event.tip.x : (event.left + event.right) / 2;\n\t\t\tconst top = event.tip ? Math.min(event.tip.y, event.ys[event.ys.length - 1]) : event.ys[event.ys.length - 1];\n\t\t\tconst bottom = event.tip ? Math.max(event.tip.y, event.ys[0]) : event.ys[0];\n\t\t\tconst stemL = event.tip ? event.tip.x : event.left;\n\n\t\t\tconst divisions = [0, 0, 0, 0, 0, 0, 0];\n\t\t\tif (event.rest) {\n\t\t\t\tconst i_rests = rests.filter((point) => distance2D(point, { x: cx, y: event.ys[0] }) < 0.5);\n\t\t\t\ti_rests.forEach((r) => {\n\t\t\t\t\tconst d = REST_SEMANTICS.indexOf(r.semantic);\n\t\t\t\t\tdivisions[d] = Math.max(divisions[d], r.confidence);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst nhs = [s0, s1, s2]\n\t\t\t\t\t.map((ss) => ss.filter((nh) => nh.x > event.left && nh.x < event.right && nh.y > top - 0.25 && nh.y < bottom + 0.25))\n\t\t\t\t\t.map((ss) => Math.max(0, ...ss.map((nh) => nh.confidence)));\n\n\t\t\t\tconst i_flags = flags.filter((flag) => flag.y > top - 0.2 && flag.y < bottom + 0.2 && Math.abs(flag.x - cx) < 0.2);\n\t\t\t\ti_flags.sort((f1, f2) => f2.confidence - f1.confidence);\n\n\t\t\t\tdivisions[0] = nhs[0];\n\t\t\t\tdivisions[1] = nhs[1];\n\t\t\t\tdivisions[2] = nhs[2];\n\t\t\t\tArray(divisions.length - 3)\n\t\t\t\t\t.fill(0)\n\t\t\t\t\t.forEach((_, i) => (divisions[3 + i] = i_flags[i] ? i_flags[i].confidence : 0));\n\t\t\t}\n\n\t\t\tconst i_dots = dotPs.filter((dot) => dot.x > cx && dot.x < event.right + 2.6);\n\t\t\tconst dots2 = i_dots.filter((dot) => i_dots.some((d) => dot.x > d.x && Math.abs(dot.y - d.y) < 0.2));\n\t\t\tconst dots = [Math.max(0, ...i_dots.map((dot) => dot.confidence)), Math.max(0, ...dots2.map((dot) => dot.confidence))];\n\n\t\t\tconst beams = [beamLs, beamMs, beamRs]\n\t\t\t\t.map((bs) => bs.filter((b) => Math.abs(b.x - cx) < 0.2 && b.y > top - 0.2 && b.y < bottom + 0.2))\n\t\t\t\t.map((bs) => Math.max(0, ...bs.map((b) => b.confidence)));\n\n\t\t\tconst u_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[0] }, { x: stem.x, y: stem.extension.y2 }) < 0.5);\n\t\t\tconst d_stems = stems.filter((stem) => distance2D({ x: cx, y: event.ys[event.ys.length - 1] }, { x: stem.x, y: stem.extension.y1 }) < 0.5);\n\t\t\tconst stemDirections = [Math.max(0, ...u_stems.map((stem) => stem.confidence)), Math.max(0, ...d_stems.map((stem) => stem.confidence))];\n\n\t\t\tconst graces = gracePs.filter((grace) => Math.abs(grace.x - cx) < 0.6 && event.ys.some((y) => Math.abs(grace.y - y) < 0.4));\n\t\t\tconst grace = Math.max(0, ...graces.map((grace) => grace.confidence));\n\n\t\t\tconst tremolos =\n\t\t\t\tevent.division === 0\n\t\t\t\t\t? tremoloRs.filter((tremolo) => tremolo.x > event.left - 2 && tremolo.x < event.right)\n\t\t\t\t\t: tremoloRs.filter((tremolo) => tremolo.y > top - 0.04 && tremolo.y < bottom + 0.04 && tremolo.x > stemL - 2 && tremolo.x < stemL);\n\t\t\tconst tremoloCatcher = Math.max(0, ...tremolos.map((tremolo) => tremolo.confidence));\n\n\t\t\tevent.feature = {\n\t\t\t\tdivisions,\n\t\t\t\tdots,\n\t\t\t\tbeams,\n\t\t\t\tstemDirections,\n\t\t\t\tgrace,\n\t\t\t\ttremoloCatcher,\n\t\t\t} as EventFeature;\n\t\t});\n\t}\n}\n\nclass Staff extends SimpleClass {\n\tstatic className = 'Staff';\n\tstatic blackKeys = ['index', 'semanticTop', 'semanticBttom'];\n\n\tindex?: number; // staff index in full staff layout\n\n\t// in units\n\ttop: number;\n\theight: number;\n\tstaffY: number;\n\n\tsemanticTop: number;\n\tsemanticBottom: number;\n\n\tbackgroundImage: string | Buffer;\n\tmaskImage: string | Buffer;\n\timagePosition: Rect;\n\n\tmeasures: Measure[];\n\n\tsemantics: SemanticPoint[];\n\n\tconstructor({ measureCount = null, measureBars = null, ...data }: Record = {}) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.height = this.height || 10;\n\t\tthis.staffY = this.staffY || 5;\n\n\t\tif (measureBars) {\n\t\t\tlet left = 0;\n\t\t\tthis.measures = measureBars.map((endX) => {\n\t\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\t\tleft = endX;\n\n\t\t\t\treturn measure;\n\t\t\t});\n\t\t} else if (measureCount)\n\t\t\tthis.measures = Array(measureCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Measure());\n\t\telse this.measures = [];\n\t}\n\n\t// relative to staffY\n\tget noteRange(): { top: number; bottom: number } {\n\t\tconst noteheads: Token[] = [].concat(...this.measures.map((measure) => measure.noteheads));\n\t\tconst ys = noteheads.map((note) => note.y);\n\t\tconst top = Math.min(-2, ...ys);\n\t\tconst bottom = Math.max(2, ...ys);\n\n\t\treturn { top, bottom };\n\t}\n\n\tget additionalLines(): AdditionalLineStack[] {\n\t\treturn [].concat(...this.measures.map((measure) => measure.additionalLines));\n\t}\n\n\trearrangeMeasures(measureBars: number[]): void {\n\t\tif (!measureBars.length) {\n\t\t\tconsole.warn('rearrangeMeasures error, measureBars are empty.');\n\t\t\treturn;\n\t\t}\n\n\t\tconst tokens = this.measures?.map((measure) => measure.tokens).flat(1) || [];\n\n\t\tlet left = 0;\n\t\tthis.measures = measureBars.map((endX) => {\n\t\t\tconst measure = new Measure({ left, width: endX - left, height: this.height });\n\t\t\tleft = endX;\n\n\t\t\treturn measure;\n\t\t});\n\n\t\tthis.reassignTokens(tokens);\n\t}\n\n\treassignTokens(tokens: Token[] = null): void {\n\t\tif (!tokens) tokens = [].concat(...this.measures.map((measure) => measure.tokens));\n\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\n\t\ttokens.forEach((token) => {\n\t\t\tfor (const measure of this.measures) {\n\t\t\t\tif (token.x < measure.right) {\n\t\t\t\t\tmeasure.tokens.push(token);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tassignSemantics(graph: SemanticGraph): void {\n\t\tthis.semantics = graph.getStaffPoints();\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, system: System, logger: Logger = new DummyLogger()): void {\n\t\tif (!this.semantics) return;\n\n\t\tlet points = system.qualifiedSemantics(this.semantics, threshold);\n\t\tpoints = solveOverlapping(points);\n\n\t\t// tempo noteheads\n\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t//console.log(\"temponh:\", tempoNh, index, points[index]);\n\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t// TODO: construct tempo term\n\t\t});\n\n\t\tconst antiP = (id: string): SemanticPoint | null => {\n\t\t\tif (system.displacementSemantics?.[id]) return this.semantics.find((p) => p.id === id);\n\n\t\t\treturn null;\n\t\t};\n\n\t\tpoints.filter((point) => MEASURE_SEMANTICS.includes(point.semantic)).forEach((point) => this.appendPoint(point, { points }));\n\n\t\t// noteheads with stem from noteheads & stems\n\t\tconst stems: Stem[] = points\n\t\t\t.filter((point) => point.semantic === SemanticType.vline_Stem)\n\t\t\t.filter((stem) => stem.extension.y2 - stem.extension.y1 > 1.5) // exclude too short stems\n\t\t\t.map((p) => ({\n\t\t\t\tx: p.x,\n\t\t\t\ty1: p.extension.y1,\n\t\t\t\ty2: p.extension.y2,\n\t\t\t\tdirection: null,\n\t\t\t}));\n\t\tconst noteheads = points.filter(\n\t\t\t(point) => NOTEHEAD_FOR_STEM_SEMANTICS.includes(point.semantic) && point.y > this.semanticTop && point.y < this.semanticBottom\n\t\t);\n\t\tconst rootNhs = new Set();\n\n\t\t// for 2nd degree chord notes\n\t\tconst nhOffsetX = (nh: SemanticPoint, stem: Stem, down: boolean): number => {\n\t\t\tif ((down ? 1 : 0) ^ (nh.x < stem.x ? 1 : 0)) return 0;\n\n\t\t\tconst offset = NOTEHEAD_WIDTHS[nh.semantic];\n\n\t\t\treturn down ? -offset : offset;\n\t\t};\n\n\t\t// find root noteheads on stem\n\t\tstems.forEach((stem) => {\n\t\t\tconst attachedHeads = noteheads.filter(\n\t\t\t\t(nh) =>\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 < 0.28 &&\n\t\t\t\t\tMath.abs(nh.x - stem.x) - NOTEHEAD_WIDTHS[nh.semantic] / 2 > -0.44 && // for grace noteheads, more close to their stem\n\t\t\t\t\tnh.y > stem.y1 - 0.5 &&\n\t\t\t\t\tnh.y < stem.y2 + 0.5 &&\n\t\t\t\t\t!(nh.x > stem.x && nh.y > stem.y2) &&\n\t\t\t\t\t!(nh.x < stem.x && nh.y < stem.y1)\n\t\t\t);\n\t\t\t//if (stem.x===102.0625 && stem.y2===1.875)\n\t\t\t//\tdebugger;\n\t\t\tif (attachedHeads.length) {\n\t\t\t\tattachedHeads.sort((n1, n2) => n1.y - n2.y);\n\n\t\t\t\tconst topDist = Math.min(...attachedHeads.map((nh) => nh.y - stem.y1));\n\t\t\t\tconst bottomDist = Math.min(...attachedHeads.map((nh) => stem.y2 - nh.y));\n\t\t\t\tif (Math.min(topDist, bottomDist) > 0.5) return; // no root notehead on this stem\n\n\t\t\t\tconst down = topDist < bottomDist;\n\t\t\t\tstem.direction = down ? 'd' : 'u';\n\n\t\t\t\tif (!down) attachedHeads.reverse();\n\t\t\t\tconst root = attachedHeads[0];\n\n\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[root.semantic].down : NOTEHEAD_TABLE[root.semantic].up;\n\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: root.id,\n\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\tx: stem.x + nhOffsetX(root, stem, down),\n\t\t\t\t\t\ty: root.y,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tconfidence: root.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\tantiPoint: antiP(root.id),\n\t\t\t\t\t\tpoints,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\trootNhs.add(root.id);\n\t\t\t}\n\t\t});\n\n\t\t// non-root noteheads\n\t\tnoteheads\n\t\t\t.filter((nh) => !rootNhs.has(nh.id))\n\t\t\t.forEach((nh) => {\n\t\t\t\tconst nearStems = stems\n\t\t\t\t\t.filter((stem) => Math.abs(stem.x - nh.x) < 2 && nh.y > stem.y1 && nh.y < stem.y2)\n\t\t\t\t\t.sort((s1, s2) => Math.abs(s1.x - nh.x) - Math.abs(s2.x - nh.x));\n\t\t\t\tconst stem = nearStems[0];\n\t\t\t\tif (stem) {\n\t\t\t\t\tconst down = stem.direction === 'd';\n\t\t\t\t\tconst semantic = down ? NOTEHEAD_TABLE[nh.semantic].down : NOTEHEAD_TABLE[nh.semantic].up;\n\n\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: nh.id,\n\t\t\t\t\t\t\tsemantic,\n\t\t\t\t\t\t\tx: stem.x + nhOffsetX(nh, stem, down),\n\t\t\t\t\t\t\ty: nh.y,\n\t\t\t\t\t\t\tpivotX: nh.x,\n\t\t\t\t\t\t\tconfidence: nh.confidence,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttip: { x: stem.x, y: down ? stem.y2 : stem.y1 },\n\t\t\t\t\t\t\tantiPoint: antiP(nh.id),\n\t\t\t\t\t\t\tpoints,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else logger.debug('isolated notehead:', system.index, this.index, nh);\n\t\t\t});\n\n\t\t// group flags\n\t\tconst flags = points.filter((point) => point.semantic === SemanticType.Flag3);\n\t\tflags.sort((f1, f2) => f1.x - f2.x);\n\t\tthis.appendFlags(flags, stems);\n\n\t\t// group dots\n\t\tconst dots = points\n\t\t\t.filter((point) => point.semantic === SemanticType.Dot)\n\t\t\t.map((dot) => {\n\t\t\t\tconst y = roundNumber(dot.y, 0.5);\n\t\t\t\treturn { x: dot.x, y };\n\t\t\t});\n\t\tconst dotLines: { [key: number]: SemanticPoint[] } = dots.reduce((table, dot) => {\n\t\t\ttable[dot.y] = table[dot.y] || [];\n\t\t\ttable[dot.y].push(dot);\n\t\t\treturn table;\n\t\t}, {});\n\t\tObject.entries(dotLines).forEach(([sy, line]) => {\n\t\t\tconst y = Number(sy);\n\t\t\tif (line.length > 1) {\n\t\t\t\tline.sort((d1, d2) => d1.x - d2.x);\n\t\t\t\tfor (let i = 0; i < line.length - 1; i++) {\n\t\t\t\t\tconst dot = line[i];\n\t\t\t\t\tif (line.find((d) => d.x > dot.x && d.x - dot.x < 1.2)) {\n\t\t\t\t\t\tthis.appendPoint(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: dot.id,\n\t\t\t\t\t\t\t\tx: dot.x,\n\t\t\t\t\t\t\t\ty,\n\t\t\t\t\t\t\t\tconfidence: dot.confidence,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: TokenType.DotDot, antiPoint: antiP(dot.id), points }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// pair key accidentals\n\t\tconst keyaccs = points.filter((point) => point.semantic === SemanticType.KeyAcc);\n\t\tconst accs = points.filter((point) => KEYACC_CANDIDATE_SEMANTICS[point.semantic]);\n\t\taccs.forEach((acc) => {\n\t\t\tif (keyaccs.some((key) => Math.abs(acc.x - key.x) < 0.5 && Math.abs(acc.y - key.y) < 1)) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: acc.id,\n\t\t\t\t\t\tx: acc.x,\n\t\t\t\t\t\ty: acc.y,\n\t\t\t\t\t\tconfidence: acc.confidence,\n\t\t\t\t\t},\n\t\t\t\t\t{ type: KEYACC_CANDIDATE_SEMANTICS[acc.semantic], points }\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\t// octave shift heads\n\t\tconst octs = points.filter((point) => point.semantic === SemanticType.OctaveShift8);\n\t\tocts.forEach((oct) => {\n\t\t\tconst type = oct.y < 0 ? TokenType.OctaveShift8va : TokenType.OctaveShift8vb;\n\t\t\tthis.appendPoint(\n\t\t\t\t{\n\t\t\t\t\tid: oct.id,\n\t\t\t\t\tx: oct.x,\n\t\t\t\t\ty: oct.y,\n\t\t\t\t\tconfidence: oct.confidence,\n\t\t\t\t},\n\t\t\t\t{ type, points }\n\t\t\t);\n\t\t});\n\n\t\t// group volta dots\n\t\tconst voltaDots = this.semantics.filter((point) => [SemanticType.VoltaLeft, SemanticType.VoltaRight].includes(point.semantic));\n\t\tvoltaDots.sort((d1, d2) => d1.x - d2.x);\n\t\tconst voltaGroups: Record> = voltaDots.reduce(\n\t\t\t(groups, dot) => {\n\t\t\t\tconst group = groups[dot.semantic];\n\t\t\t\tconst xs = Array.from(Object.keys(group)).map(Number);\n\t\t\t\tconst x = xs.find((x) => dot.x < x + 0.2) || dot.x;\n\n\t\t\t\tgroup[x] = groups[dot.semantic][x] || [];\n\t\t\t\tgroup[x].push(dot);\n\n\t\t\t\treturn groups;\n\t\t\t},\n\t\t\t{ [SemanticType.VoltaLeft]: {}, [SemanticType.VoltaRight]: {} }\n\t\t);\n\t\tfor (const [type, group] of Object.entries(voltaGroups)) {\n\t\t\tObject.values(group).forEach((dots) => {\n\t\t\t\tif (dots.length > 1) {\n\t\t\t\t\tconst confidence = dots.reduce((sum, dot) => sum + dot.confidence, 0);\n\t\t\t\t\tif (dots[0].y * dots[1].y < 0 && confidence >= threshold * 2) this.appendPoint(dots[0], { type: TokenType[type] });\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\tappendPoint(\n\t\tpoint: Partial,\n\t\t{ type, points = null, antiPoint, ...fields }: { type?: TokenType; antiPoint?: SemanticPoint; [key: string]: any } = {}\n\t): void {\n\t\t//console.log(\"appendPoint.0:\", point, point.x, point.y);\n\t\tconst x = point.x;\n\t\tconst measure = this.measures.find((measure) => x < measure.left + measure.width);\n\t\tif (!measure)\n\t\t\t// drop tokens out of measures range\n\t\t\treturn;\n\n\t\t// lined or interval\n\t\tlet lined = false;\n\t\tlet interval = false;\n\t\tif (STAFF_LINED_SEMANTICS.includes(point.semantic)) {\n\t\t\tconsole.assert(points, 'argument of points for this semantic is required:', point.semantic);\n\t\t\tconst signs = points.filter((p) => LINED_INTERVAL_SEMANTICS.includes(p.semantic) && Math.abs(p.y - point.y) < 0.2 && Math.abs(p.x - point.x) < 1.2);\n\t\t\tif (signs.some((s) => s.semantic === SemanticType.SignLined)) lined = true;\n\t\t\telse if (signs.some((s) => s.semantic === SemanticType.SignInterval)) interval = true;\n\t\t}\n\n\t\ttype = type || TokenType[point.semantic];\n\t\tconst fixedY = TOKEN_Y_FIXED[type];\n\t\tlet roundY = TOKEN_Y_ROUND[type];\n\n\t\tif (lined || interval) roundY = Math.max(roundY, 1);\n\n\t\tlet y = point.y;\n\t\tif (Number.isFinite(fixedY)) y = fixedY;\n\t\telse if (roundY) {\n\t\t\tif (interval) y = roundNumber(y + 0.5, roundY) - 0.5;\n\t\t\telse y = roundNumber(y, roundY);\n\t\t}\n\t\t//if (lined || interval)\n\t\t//\tconsole.log(\"round sign:\", point.semantic, y, lined, interval);\n\n\t\tconst holder = measure.tokens.find((token) => token.type === type && Math.abs(token.x - x) < 0.1 && Math.abs(token.y - y) < 0.1);\n\t\tif (holder) {\n\t\t\tif (Number.isFinite(holder.confidence) && holder.confidence < point.confidence) {\n\t\t\t\tholder.x = x;\n\t\t\t\tholder.y = y;\n\t\t\t\tholder.confidence = point.confidence;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// exlude clef out of pitch range\n\t\tif (TokenClefs.includes(type)) {\n\t\t\tif (Math.abs(y) > 3) return;\n\t\t}\n\n\t\t// TODO: exclude overlapped pair by a token prior table\n\n\t\tmeasure.tokens.push(\n\t\t\tnew Token({\n\t\t\t\tid: point.id,\n\t\t\t\ttype,\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tpivotX: point.pivotX,\n\t\t\t\tconfidence: point.confidence,\n\t\t\t\t...fields,\n\t\t\t})\n\t\t);\n\n\t\tif (antiPoint) {\n\t\t\tmeasure.antiTokens.push(\n\t\t\t\tnew Token({\n\t\t\t\t\tid: antiPoint.id,\n\t\t\t\t\ttype,\n\t\t\t\t\tx,\n\t\t\t\t\ty: antiPoint.y,\n\t\t\t\t\tconfidence: antiPoint.confidence,\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tappendFlags(flags: SemanticPoint[], stems: Stem[]): void {\n\t\t//console.log(\"flags:\", flags);\n\t\tconst stemGroups = stems\n\t\t\t.map((stem) => ({\n\t\t\t\t...stem,\n\t\t\t\tflags: flags.filter((flag) => Math.abs(flag.x - stem.x) < 0.3 && flag.y > stem.y1 - 0.5 && flag.y < stem.y2 + 0.5),\n\t\t\t}))\n\t\t\t.filter((group) => group.flags.length);\n\n\t\tstemGroups.forEach((group) => {\n\t\t\tconst mainFlag = group.flags.reduce((main, flag) => (main && main.confidence > flag.confidence ? main : flag), null);\n\n\t\t\t//const upDistance = mainFlag.y - group.y1;\n\t\t\t//const downDistance = group.y2 - mainFlag.y;\n\t\t\t//const downward = downDistance < upDistance;\n\t\t\tconst downward = group.direction === 'd';\n\n\t\t\tconst tailY = downward ? Math.min(group.y2, group.y1 + STEM_LENGTH_MAX) : Math.max(group.y1, group.y2 - STEM_LENGTH_MAX);\n\n\t\t\tconst flagTips = group.flags.map((flag) => ({\n\t\t\t\ttip: (tailY - flag.y) * (downward ? 1 : -1),\n\t\t\t\tconfidence: flag.confidence,\n\t\t\t}));\n\t\t\tconst count = flagTips.filter((f) => f.tip < 2 || f.confidence > mainFlag.confidence * 0.7).length;\n\n\t\t\tconst type = TokenFlags[count - 1];\n\t\t\tif (type) {\n\t\t\t\tthis.appendPoint(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: group.flags[0].id,\n\t\t\t\t\t\tx: group.x,\n\t\t\t\t\t\ty: tailY,\n\t\t\t\t\t\tconfidence: Math.min(...group.flags.map((flag) => flag.confidence)),\n\t\t\t\t\t},\n\t\t\t\t\t{ type }\n\t\t\t\t);\n\t\t\t\t//console.log(\"flag:\", type);\n\t\t\t}\n\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = []));\n\t\tthis.semantics = [];\n\t}\n\n\tclearPredictedTokens(): void {\n\t\tthis.measures.forEach((measure) => (measure.tokens = measure.tokens.filter((token) => !token.isPredicted)));\n\t}\n}\n\nclass System extends SimpleClass {\n\tstatic className = 'System';\n\tstatic blackKeys = ['index', 'pageIndex', 'prev', 'next', 'headMeasureIndex', 'tokens', 'indent'];\n\n\tindex?: number;\n\tpageIndex?: number;\n\tprev?: System;\n\tnext?: System;\n\theadMeasureIndex?: number; // zero based\n\n\t// in units\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\tindent: boolean;\n\n\tmeasureCount: number;\n\tstaves: Staff[];\n\n\tmeasureBars: number[];\n\n\tbackgroundImage: string;\n\timagePosition: Rect;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tsidBlackList: string[];\n\tsidWhiteList: string[];\n\n\tdisplacementSemantics?: { [id: string]: Partial };\n\n\tstaffMaskChanged: number;\n\tbracketsAppearance: string; // the staff layout code by prediction\n\n\tconstructor({ stavesCount, ...fields }: any) {\n\t\tsuper();\n\t\tsuper.assign(fields);\n\n\t\tif (!this.measureBars) {\n\t\t\tconst HEAD_WIDTH = 5;\n\t\t\tconst segmentLength = (this.width - HEAD_WIDTH) / this.measureCount;\n\t\t\tthis.measureBars = Array(this.measureCount)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => HEAD_WIDTH + segmentLength * (i + 1));\n\t\t}\n\n\t\tif (!fields.staves && stavesCount)\n\t\t\tthis.staves = Array(stavesCount)\n\t\t\t\t.fill(null)\n\t\t\t\t.map(() => new Staff({ measureBars: this.measureBars }));\n\n\t\tthis.arrangePosition();\n\n\t\tthis.measureCount = this.measureCount || this.measureBars.length;\n\n\t\tthis.sidBlackList = this.sidBlackList || [];\n\t\tthis.sidWhiteList = this.sidWhiteList || [];\n\t}\n\n\tget noteRange(): { top: number; bottom: number } {\n\t\tif (!this.staves.length) return null;\n\n\t\tconst staffTop = this.staves[0];\n\t\tconst staffBottom = this.staves[this.staves.length - 1];\n\n\t\treturn {\n\t\t\ttop: staffTop.top + staffTop.staffY + staffTop.noteRange.top,\n\t\t\tbottom: staffBottom.top + staffBottom.staffY + staffBottom.noteRange.bottom,\n\t\t};\n\t}\n\n\tget staffPositions(): StaffPosition[] {\n\t\treturn this.staves.map((staff) => ({\n\t\t\ty: staff.top + staff.staffY,\n\t\t\tradius: 2,\n\t\t}));\n\t}\n\n\tget staffMask(): number {\n\t\tif (this.staffMaskChanged) return this.staffMaskChanged;\n\n\t\tif (this.prev && this.staves.length === this.prev.staves.length) return this.prev.staffMask;\n\n\t\treturn 2 ** this.staves.length - 1;\n\t}\n\n\tget staffTop(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[0].y - positions[0].radius : 0;\n\t}\n\n\tget staffBottom(): number {\n\t\tconst positions = this.staffPositions;\n\t\treturn positions.length ? positions[positions.length - 1].y + positions[positions.length - 1].radius : 0;\n\t}\n\n\tarrangePosition(): void {\n\t\tlet y = 0;\n\t\tfor (const staff of this.staves) {\n\t\t\tif (Number.isFinite(staff.top)) break;\n\n\t\t\tstaff.top = y;\n\t\t\ty += staff.height;\n\t\t}\n\t}\n\n\ttidyMeasureBars(): void {\n\t\tthis.measureBars = this.measureBars.filter((x) => x > 1);\n\t\tthis.measureBars.sort((b1, b2) => b1 - b2);\n\n\t\tconst restWidth = this.width - this.measureBars[this.measureBars.length - 1];\n\t\tif (restWidth > 12) this.measureBars.push(this.width);\n\t\telse if (restWidth < 2) this.measureBars[this.measureBars.length - 1] = this.width;\n\n\t\tthis.measureBars = this.measureBars.filter((x, i) => i < 1 || x - this.measureBars[i - 1] > 4);\n\t}\n\n\trearrangeMeasures(): void {\n\t\tthis.measureCount = this.measureBars.length;\n\t\tthis.staves.forEach((staff) => staff.rearrangeMeasures(this.measureBars));\n\t}\n\n\tget height(): number {\n\t\treturn this.staves.reduce((height, staff) => height + staff.height, 0);\n\t}\n\n\tget connectionLine(): { top: number; bottom: number } {\n\t\tconst staffHead = this.staves[0];\n\t\tconst staffTail = this.staves[this.staves.length - 1];\n\n\t\treturn (\n\t\t\tstaffHead && {\n\t\t\t\ttop: staffHead.top + staffHead.staffY - 2,\n\t\t\t\tbottom: staffTail.top + staffTail.staffY + 2,\n\t\t\t}\n\t\t);\n\t}\n\n\tget middleY(): number {\n\t\tif (!this.staves.length) return 0;\n\n\t\tconst sum = this.staves.reduce((sum, staff) => sum + staff.top + staff.staffY, 0);\n\n\t\treturn sum / this.staves.length;\n\t}\n\n\tget timeSignatureOnHead(): boolean {\n\t\treturn this.staves.some((staff) => staff.measures[0]?.tokens.some((token) => TokenTimesigs.includes(token.type)));\n\t}\n\n\t// an array staff or null on every position of full staff layout\n\tgetStaffArray(stavesCount: number): Staff[] {\n\t\tlet si = 0;\n\n\t\treturn Array(stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, i) => {\n\t\t\t\tconst on = this.staffMask & (1 << i);\n\t\t\t\tconst staff = on ? this.staves[si++] : null;\n\t\t\t\tconsole.assert(!on || staff, 'system staves count is less than staff mask declared:', this.staves.length, this.staffMask.toString(2));\n\n\t\t\t\treturn staff;\n\t\t\t});\n\t}\n\n\t// measureIndex: the local measure index\n\tgetMarksInMeasure(measureIndex: number): MarkTerm[] {\n\t\tconsole.assert(measureIndex < this.measureBars.length, 'measure index out of range:', measureIndex, this.measureBars.length);\n\n\t\tconst left = measureIndex > 0 ? this.measureBars[measureIndex - 1] : 0;\n\t\tconst right = this.measureBars[measureIndex];\n\n\t\tconst tempoTokens = (this.tokens ?? []).filter(\n\t\t\t(token) => token.x >= left && token.x < right && token instanceof TextToken && token.textType === TextType.TempoNumeral\n\t\t) as TextToken[];\n\n\t\treturn [...tempoTokens.map((token) => TempoTerm.fromNumeralText(token.text)).filter(Boolean)];\n\t}\n\n\tgetEvents(stavesCount: number): EventSystem {\n\t\tconsole.assert(Number.isInteger(this.headMeasureIndex), 'invalid headMeasureIndex:', this.headMeasureIndex);\n\n\t\t// Empty system (no measureBars / no staves with measures): return empty result\n\t\tif (!this.measureBars?.length && this.staves.every((s) => !s.measures?.length)) {\n\t\t\treturn { staffMask: this.staffMask, columns: [] };\n\t\t}\n\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => {\n\t\t\t\tconst events = measure.getEvents();\n\t\t\t\tmeasure.assignAccessoriesOnEvents(events);\n\t\t\t\tmeasure.assignFeaturesOnEvents(events, staff.semantics);\n\n\t\t\t\treturn {\n\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t\tcontexts: measure.getContexts({ staff: staff.index }),\n\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts?.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (row[mi] && !row[mi].contexts.length && !row[mi].events.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//onst measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: this.getMarksInMeasure(i),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i]?.voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i]?.voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row[i]?.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i]?.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\t\t//columns.forEach(computeMeasureTicks);\n\n\t\t// assign id on column events\n\t\tcolumns.forEach((column) => {\n\t\t\tconst events = [].concat(...column.rows.filter(Boolean).map((row) => row.events));\n\t\t\tevents.forEach((event, i) => (event.id = i + 1));\n\t\t});\n\n\t\tconst lastColumn = columns[columns.length - 1];\n\t\tif (lastColumn) lastColumn.break = true;\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tgetEventsFunctional(stavesCount: number, ev: ChordsFeeder, processors: ColumnProcessor[] = [], { useXMap = false } = {}): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff, si) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: [] as EventTerm[],\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure, mi) => {\n\t\t\t\tconst events = ev(si, mi);\n\n\t\t\t\treturn (\n\t\t\t\t\tevents && {\n\t\t\t\t\t\tevents: events.map(\n\t\t\t\t\t\t\t(event) =>\n\t\t\t\t\t\t\t\tnew EventTerm({\n\t\t\t\t\t\t\t\t\tsystem: this.index,\n\t\t\t\t\t\t\t\t\t...event,\n\t\t\t\t\t\t\t\t\trest: event.rest ? 'r' : null,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontexts: measure.getContexts({ staff: si }),\n\t\t\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\t\t\talternative: measure.alternative,\n\t\t\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\t// [measure, staff]\n\t\tconst columns: EventMeasureColumn[] = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => {\n\t\t\t\tconst localRows = rows.map((row) => row[mi]);\n\t\t\t\tif (localRows.some((row) => !row)) return null;\n\n\t\t\t\tlet xMap: Map = null;\n\t\t\t\tif (useXMap) {\n\t\t\t\t\tconst events: EventTerm[] = [].concat(...localRows.map((row) => row.events));\n\t\t\t\t\tconst groupMap: { [group: number]: EventTerm[] } = events.reduce((map, event) => {\n\t\t\t\t\t\tif (Number.isFinite(event.tickGroup)) map[event.tickGroup] = map[event.tickGroup] || [];\n\t\t\t\t\t\tmap[event.tickGroup].push(event);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, {});\n\n\t\t\t\t\txMap = Object.values(groupMap).reduce((map, events) => {\n\t\t\t\t\t\tconst x = Math.min(...events.map((event) => (event.left + event.right) / 2));\n\t\t\t\t\t\tmap.set(x, events);\n\n\t\t\t\t\t\treturn map;\n\t\t\t\t\t}, new Map());\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + mi,\n\t\t\t\t\t//startX: measureStartXs[mi],\n\t\t\t\t\t//width: measureWidths[mi],\n\t\t\t\t\trows: localRows, // [staff]\n\t\t\t\t\tmarks: this.getMarksInMeasure(mi),\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\txMap,\n\t\t\t\t\tvoltaBegin: localRows.some((row) => row.voltaBegin),\n\t\t\t\t\tvoltaEnd: localRows.some((row) => row.voltaEnd),\n\t\t\t\t\talternative: localRows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: localRows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row.barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\tprocessors.forEach((proc) => columns.forEach(proc));\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\t// get EventSystem contains only contexted terms\n\tgetContexts(stavesCount: number): EventSystem {\n\t\tconst staves = this.getStaffArray(stavesCount);\n\n\t\t// [staff, measure]\n\t\tconst rows = staves.map((staff) => {\n\t\t\tif (!staff) {\n\t\t\t\treturn Array(this.measureCount)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => ({\n\t\t\t\t\t\tevents: null,\n\t\t\t\t\t\tcontexts: [] as ContextedTerm[],\n\t\t\t\t\t\tvoltaBegin: false,\n\t\t\t\t\t\tvoltaEnd: false,\n\t\t\t\t\t\talternative: false,\n\t\t\t\t\t\tbarTypes: {},\n\t\t\t\t\t}));\n\t\t\t}\n\n\t\t\treturn staff.measures.map((measure) => ({\n\t\t\t\tevents: null,\n\t\t\t\tcontexts: measure.getContexts(),\n\t\t\t\tvoltaBegin: measure.tokens.some((token) => token.type === TokenType.VoltaLeft),\n\t\t\t\tvoltaEnd: measure.tokens.some((token) => token.type === TokenType.VoltaRight),\n\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\tbarTypes: measure.barTypes,\n\t\t\t}));\n\t\t});\n\n\t\t// supplement time signatures for empty staves\n\t\tfor (let mi = 0; mi < this.measureCount; ++mi) {\n\t\t\tconst tsRows = rows.map((row) => row[mi]?.contexts.filter((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type)));\n\t\t\tconst timeSigs = tsRows.find((row) => row?.length);\n\t\t\tif (timeSigs) {\n\t\t\t\trows.forEach((row) => {\n\t\t\t\t\tif (!row[mi].contexts.length) row[mi].contexts.push(...timeSigs);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t//const measureWidths = this.staves[0].measures.map(measure => measure.width);\n\t\t//const measureStartXs = [0, ...this.measureBars];\n\n\t\tconst columns = Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map(\n\t\t\t\t(_, i): EventMeasureColumn => ({\n\t\t\t\t\tmeasureIndex: this.headMeasureIndex + i,\n\t\t\t\t\t//startX: measureStartXs[i],\n\t\t\t\t\t//width: measureWidths[i],\n\t\t\t\t\trows: rows.map((row) => row[i]),\n\t\t\t\t\tmarks: [],\n\t\t\t\t\t//xToTick: {},\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tvoltaBegin: rows.some((row) => row[i].voltaBegin),\n\t\t\t\t\tvoltaEnd: rows.some((row) => row[i].voltaEnd),\n\t\t\t\t\talternative: rows.some((row) => row.alternative),\n\t\t\t\t\tbarTypes: rows.reduce(\n\t\t\t\t\t\t(ts, row) => ({\n\t\t\t\t\t\t\t...ts,\n\t\t\t\t\t\t\t...row[i].barTypes,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{} as Record\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t);\n\n\t\treturn {\n\t\t\tstaffMask: this.staffMask,\n\t\t\tcolumns,\n\t\t};\n\t}\n\n\tassignSemantics(staffIndex: number, graph: SemanticGraph): void {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff is null:', staffIndex, this.staves);\n\t\tconst oy = staff.top + staff.staffY;\n\n\t\tgraph.getSystemPoints().forEach((point) => {\n\t\t\tconst p = { ...point };\n\t\t\tp.y += oy;\n\n\t\t\tif (p.extension) {\n\t\t\t\tp.extension = { ...p.extension };\n\t\t\t\tif (Number.isFinite(p.extension.y1)) {\n\t\t\t\t\tp.extension.y1 += oy;\n\t\t\t\t\tp.extension.y2 += oy;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.semantics.push(p);\n\t\t});\n\t}\n\n\t// generate tokens from semantics\n\tassemble(threshold: number, logger: Logger = new DummyLogger()): void {\n\t\t//console.log(\"System.assignSemantics:\", graph);\n\t\tthis.measureBars = [];\n\n\t\tif (!this.semantics) return;\n\n\t\tconst graph = SemanticGraph.fromPoints(this.semantics);\n\n\t\tconst bars = graph.getConfidentLayer(SemanticType.vline_BarMeasure, threshold);\n\t\tbars.sort((b1, b2) => b1.x - b2.x);\n\n\t\tconst staffTop = this.staffTop;\n\t\tconst staffBottom = this.staffBottom;\n\n\t\tconst MERGE_WINDOW = 0.4;\n\t\tlet lastX = 0;\n\t\tconst barColumns: { [key: number]: number } = bars.reduce((columns, bar) => {\n\t\t\tconst confidence = Number.isFinite(bar.confidence) ? Math.tanh(bar.confidence) : 1;\n\n\t\t\tconst x = bar.x - lastX > MERGE_WINDOW ? bar.x : lastX;\n\t\t\tlastX = bar.x;\n\t\t\tlet intensity = columns[x] || 0;\n\t\t\tintensity += (Math.min(bar.extension.y2, staffBottom) - Math.max(bar.extension.y1, staffTop)) * confidence;\n\n\t\t\tif (bar.x !== x) delete columns[x];\n\t\t\tcolumns[bar.x] = intensity;\n\n\t\t\treturn columns;\n\t\t}, {});\n\t\tconst barXs: number[] = Object.entries(barColumns)\n\t\t\t.filter(([x, intensity]) => (void x, intensity > 3 * this.staves.length))\n\t\t\t.map(([x]) => Number(x));\n\t\tbarXs.sort((x1, x2) => x1 - x2);\n\t\tbarXs.forEach((x, i) => {\n\t\t\tif (i <= 0 || x - barXs[i - 1] > 2) this.measureBars.push(x);\n\t\t});\n\n\t\tif (!this.measureBars.length) this.measureBars.push(this.width);\n\n\t\tthis.tidyMeasureBars();\n\t\tthis.rearrangeMeasures();\n\n\t\t// measure bar type\n\t\tconst typeBars = this.semantics.filter((point) => [SemanticType.vline_BarTerminal, SemanticType.vline_BarSegment].includes(point.semantic));\n\t\ttypeBars.forEach((bar) => {\n\t\t\tconst measure = this.staves[0].measures.find((measure) => bar.x > measure.right - 2 && bar.x < measure.right + 1);\n\t\t\tif (measure) {\n\t\t\t\tconst type = bar.semantic.replace(/^vline_Bar/, '');\n\t\t\t\tmeasure.barTypes[type] = measure.barTypes[type] || 0;\n\t\t\t\tmeasure.barTypes[type] += bar.confidence;\n\t\t\t}\n\t\t});\n\n\t\tlet staffIndex = 0;\n\t\tconst staffMask = this.staffMask;\n\t\tthis.staves.forEach((staff, si) => {\n\t\t\t// staff index\n\t\t\twhile (!(staffMask & (1 << staffIndex))) ++staffIndex;\n\t\t\tstaff.index = staffIndex++;\n\n\t\t\t// assign semantic boundaries\n\t\t\tif (si === 0) staff.semanticTop = -staff.staffY;\n\t\t\telse {\n\t\t\t\tconst prevStaff = this.staves[si - 1];\n\t\t\t\tstaff.semanticTop = prevStaff.top + prevStaff.staffY + 3 - (staff.top + staff.staffY);\n\t\t\t}\n\n\t\t\tif (si < this.staves.length - 1) {\n\t\t\t\tconst nextStaff = this.staves[si + 1];\n\t\t\t\tstaff.semanticBottom = nextStaff.top + nextStaff.staffY - 3 - (staff.top + staff.staffY);\n\t\t\t} else staff.semanticBottom = this.height - (staff.top + staff.staffY);\n\n\t\t\tif (staff.semantics && staff.semantics.length) {\n\t\t\t\tstaff.semantics.forEach((point) => hashSemanticPoint(this.index, si, point));\n\n\t\t\t\tstaff.clearPredictedTokens();\n\t\t\t\tstaff.assemble(threshold, this, logger);\n\t\t\t}\n\t\t});\n\t}\n\n\tqualifiedSemantics(semantics: SemanticPoint[], threshold: number = 1): SemanticPoint[] {\n\t\treturn semantics\n\t\t\t.filter(\n\t\t\t\t(p) => this.sidWhiteList.includes(p.id) || (!this.sidBlackList.includes(p.id) && (p.confidence >= threshold || !Number.isFinite(p.confidence)))\n\t\t\t)\n\t\t\t.map((point) => {\n\t\t\t\t// displace semantic point\n\t\t\t\tif (this.displacementSemantics && this.displacementSemantics[point.id]) return { ...point, ...this.displacementSemantics[point.id] };\n\n\t\t\t\treturn point;\n\t\t\t});\n\t}\n\n\tclearTokens(): void {\n\t\tthis.staves.forEach((staff) => staff.clearTokens());\n\t\tthis.semantics = [];\n\t}\n\n\tnewPoint(staffIndex: number, data: SemanticPoint, threshold: number = 1): SemanticPoint {\n\t\tconst staff = this.staves[staffIndex];\n\t\tconsole.assert(staff, 'staff index out of bound:', staffIndex, this.staves.length);\n\n\t\tconst { semantic, x, y, confidence = 0, extension = null } = data;\n\t\tconst point = { semantic, x, y, confidence, extension };\n\t\tif (!point.extension) delete point.extension;\n\n\t\thashSemanticPoint(this.index, staffIndex, point);\n\t\tstaff.semantics.push(point);\n\t\tstaff.clearPredictedTokens();\n\t\tstaff.assemble(threshold, this);\n\n\t\treturn point;\n\t}\n\n\tappendToken(token: TextToken): void {\n\t\tthis.tokens.push(token);\n\n\t\tswitch (token.textType) {\n\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t{\n\t\t\t\t\t// remove noteheads in text area\n\t\t\t\t\tconst staff = this.staves[0];\n\t\t\t\t\tif (staff) {\n\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\t\t\t\t\t\tstaff.measures.forEach((measure) => {\n\t\t\t\t\t\t\tmeasure.tokens = measure.tokens.filter(\n\t\t\t\t\t\t\t\t(t) =>\n\t\t\t\t\t\t\t\t\t!TokenNoteheads.includes(t.type) ||\n\t\t\t\t\t\t\t\t\tMath.abs(t.x - token.x) > token.width / 2 ||\n\t\t\t\t\t\t\t\t\tMath.abs(oy + t.y - token.y) > token.fontSize / 2\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase TextType.Alternation1:\n\t\t\tcase TextType.Alternation2:\n\t\t\t\t//console.log(\"appendToken:\", token, this.staves[0].measures);\n\t\t\t\tthis.staves[0].measures.forEach((measure) => {\n\t\t\t\t\tconst overlap = Math.min(measure.left + measure.width, token.x + token.width / 2) - Math.max(measure.left, token.x - token.width / 2);\n\t\t\t\t\tmeasure.alternative = measure.alternative || overlap / measure.width > 0.5;\n\t\t\t\t});\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nclass Page extends SimpleClass {\n\tstatic className = 'Page';\n\tstatic blackKeys = ['index', 'tokens'];\n\n\tindex?: number;\n\n\t// in units\n\twidth: number;\n\theight: number;\n\n\tsystems: System[];\n\n\tsource: SourceImageFile;\n\tlayout?: PageLayout;\n\n\tsemantics: SemanticPoint[];\n\ttokens?: Token[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.systems = this.systems || [];\n\n\t\tif (this.source) {\n\t\t\tthis.source.matrix = this.source.matrix || [1, 0, 0, 1, 0, 0];\n\t\t}\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tclearTokens(): void {\n\t\tthis.semantics = null;\n\t\tthis.tokens = null;\n\n\t\tthis.systems.forEach((system) => (system.tokens = null));\n\t}\n\n\tassignTexts(areas: TextArea[], [imageHeight, imageWidth]: [number, number]): void {\n\t\tconst interval = this.source && this.source.interval ? this.source.interval * (imageHeight / this.source.dimensions.height) : imageHeight / this.height;\n\n\t\tthis.semantics = areas.map((area) => {\n\t\t\tconst p = {\n\t\t\t\tx: (area.cx - imageWidth / 2) / interval,\n\t\t\t\ty: (area.cy - imageHeight / 2) / interval,\n\t\t\t};\n\t\t\tconst rp = this.source && this.source.matrix ? trans23(p, this.source.matrix) : p;\n\n\t\t\treturn {\n\t\t\t\tconfidence: area.score,\n\t\t\t\tx: rp.x + this.width / 2,\n\t\t\t\ty: rp.y + this.height / 2,\n\t\t\t\tsemantic: SemanticType.rect_Text,\n\t\t\t\textension: {\n\t\t\t\t\ttext: area.text,\n\t\t\t\t\ttype: area.type,\n\t\t\t\t\twidth: area.width / interval,\n\t\t\t\t\theight: area.height / interval,\n\t\t\t\t\ttheta: area.theta,\n\t\t\t\t\ttextFeature: area.feature_dict,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tassemble({ textAnnotations = null }: { textAnnotations?: { [id: string]: string } } = {}, logger: Logger = new DummyLogger()): void {\n\t\tthis.tokens = [];\n\t\tthis.systems.forEach((system) => (system.tokens = []));\n\n\t\t// compute system indent\n\t\tif (this.systems.length) {\n\t\t\tconst sysXs = this.systems.map((system) => system.left);\n\t\t\tconst middleX = sysXs[Math.floor((sysXs.length - 1) / 2)];\n\t\t\tthis.systems.forEach((system) => (system.indent = system.left > middleX + INDENT_THRESHOLD));\n\t\t}\n\n\t\tif (this.semantics) {\n\t\t\tconst pageName = this.source ? this.source.name : this.index.toString();\n\n\t\t\tthis.semantics.forEach((point) => {\n\t\t\t\thashPageSemanticPoint(pageName, point);\n\n\t\t\t\tconst fields = {\n\t\t\t\t\tid: point.id,\n\t\t\t\t\ttype: TokenType.Text,\n\t\t\t\t\tconfidence: point.confidence,\n\t\t\t\t\ttextType: TEXT_TYPE_ALIAS[point.extension.type] || point.extension.type,\n\t\t\t\t\ttext: (textAnnotations && textAnnotations[point.id]) || point.extension.text,\n\t\t\t\t\ttextFeasure: point.extension.textFeature,\n\t\t\t\t\twidth: point.extension.width,\n\t\t\t\t\tfontSize: point.extension.height,\n\t\t\t\t};\n\n\t\t\t\tswitch (point.semantic) {\n\t\t\t\t\tcase SemanticType.rect_Text:\n\t\t\t\t\t\tswitch (fields.textType) {\n\t\t\t\t\t\t\t// page tokens\n\t\t\t\t\t\t\tcase TextType.Title:\n\t\t\t\t\t\t\tcase TextType.Author:\n\t\t\t\t\t\t\tcase TextType.PageMargin:\n\t\t\t\t\t\t\tcase TextType.Other:\n\t\t\t\t\t\t\t\tthis.tokens.push(\n\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\tx: point.x,\n\t\t\t\t\t\t\t\t\t\ty: point.y,\n\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens on the top of system\n\t\t\t\t\t\t\tcase TextType.TempoNumeral:\n\t\t\t\t\t\t\tcase TextType.Chord:\n\t\t\t\t\t\t\tcase TextType.MeasureNumber:\n\t\t\t\t\t\t\tcase TextType.Instrument:\n\t\t\t\t\t\t\tcase TextType.Alternation1:\n\t\t\t\t\t\t\tcase TextType.Alternation2:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = this.systems.find((system) => system.top + system.staffTop > point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tsystem.appendToken(\n\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\tx: point.x - system.left,\n\t\t\t\t\t\t\t\t\t\t\t\ty: point.y - system.top,\n\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t// tokens in staff\n\t\t\t\t\t\t\tcase TextType.TextualMark:\n\t\t\t\t\t\t\tcase TextType.Times:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tconst system = [...this.systems].reverse().find((system) => system.top < point.y);\n\t\t\t\t\t\t\t\t\tif (system) {\n\t\t\t\t\t\t\t\t\t\tconst sy = point.y - (system.top + system.staffTop);\n\t\t\t\t\t\t\t\t\t\tconst sx = point.x - system.left;\n\t\t\t\t\t\t\t\t\t\tconst staff = system.staves.find((staff) => sy >= staff.top && sy < staff.top + staff.height);\n\t\t\t\t\t\t\t\t\t\tif (staff) {\n\t\t\t\t\t\t\t\t\t\t\tconst measure = staff.measures.find((measure) => sx >= measure.left && sx < measure.left + measure.width);\n\t\t\t\t\t\t\t\t\t\t\tif (measure) {\n\t\t\t\t\t\t\t\t\t\t\t\tmeasure.tokens.push(\n\t\t\t\t\t\t\t\t\t\t\t\t\tnew TextToken({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tx: sx,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ty: sy,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport { Measure, Staff, System, Page };\n","import { ChordColumn, Fraction } from './interfaces';\nimport { GraceType } from './term';\nimport { roundNumber } from './utils';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum SemanticElementType {\n\tBOS,\n\tPAD,\n\n\tNoteheadS0,\n\tNoteheadS1,\n\tNoteheadS2,\n\tNoteheadGrace,\n\tvline_Stem,\n\tFlag3,\n\tBeamLeft,\n\tBeamContinue,\n\tBeamRight,\n\tDot,\n\tRest0,\n\tRest1,\n\tRest2,\n\tRest3,\n\tRest4,\n\tRest5,\n\tRest6,\n\n\t// measure time signature denominators & numerators\n\tTimeD2,\n\tTimeD4,\n\tTimeD8,\n\tTimeN1,\n\tTimeN2,\n\tTimeN3,\n\tTimeN4,\n\tTimeN5,\n\tTimeN6,\n\tTimeN7,\n\tTimeN8,\n\tTimeN9,\n\tTimeN10,\n\tTimeN11,\n\tTimeN12,\n}\n\nconst TIME_SIG_DENOMINATORS = Object.fromEntries([2, 4, 8].map((n) => [n, SemanticElementType[`TimeD${n}`]]));\nconst TIME_SIG_NUMERATORS = Object.fromEntries(\n\tArray(12)\n\t\t.fill(null)\n\t\t.map((_, i) => i + 1)\n\t\t.map((n) => [n, SemanticElementType[`TimeN${n}`]])\n);\n\nconst et = SemanticElementType;\n\nconst ELEMENT_TOKEN_NAMES = {\n\t[et.BOS]: 'BOS',\n\t[et.NoteheadS0]: 'noteheads-s0',\n\t[et.NoteheadS1]: 'noteheads-s1',\n\t[et.NoteheadS2]: 'noteheads-s2',\n\t[et.NoteheadGrace]: 'GraceNotehead',\n\t[et.Flag3]: 'flags-u3',\n\t[et.BeamLeft]: 'BeamLeft',\n\t[et.BeamContinue]: 'BeamContinue',\n\t[et.BeamRight]: 'BeamRight',\n\t[et.Dot]: 'dot',\n\t[et.Rest0]: 'rests-0o',\n\t[et.Rest1]: 'rests-1o',\n\t[et.Rest2]: 'rests-2',\n\t[et.Rest3]: 'rests-3',\n\t[et.Rest4]: 'rests-4',\n\t[et.Rest5]: 'rests-5',\n\t[et.Rest6]: 'rests-6',\n};\n\nconst NOTEHEAD_BASE_DIVISION = {\n\t[et.NoteheadS0]: 0,\n\t[et.NoteheadS1]: 1,\n\t[et.NoteheadS2]: 2,\n\t[et.NoteheadGrace]: 2,\n};\n\nconst NOTEHEAD_ELEMENT_TYPES = [et.NoteheadS0, et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace];\n\nconst REST_ELEMENT_TYPES = [et.Rest0, et.Rest1, et.Rest2, et.Rest3, et.Rest4, et.Rest5, et.Rest6];\n\nconst BEAM_ELEMENT_TYPES = [et.BeamLeft, et.BeamContinue, et.BeamRight];\n\nconst NOTE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES];\n\nconst SOURCE_ELEMENT_TYPES = [...NOTEHEAD_ELEMENT_TYPES, ...REST_ELEMENT_TYPES, et.vline_Stem];\n\nconst TARGET_ELEMENT_TYPES = [et.BOS, et.NoteheadS0, et.vline_Stem, ...REST_ELEMENT_TYPES];\n\nconst ROOT_NOTE_ELEMENT_TYPES = [...NOTE_ELEMENT_TYPES, et.vline_Stem];\n\nconst ELEMENT_TO_STEMBEAM = {\n\t[et.BeamLeft]: 'Open',\n\t[et.BeamRight]: 'Close',\n};\n\ninterface SemanticElement {\n\ttype: SemanticElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\n\tindex?: number;\n\ttick?: number;\n\tid?: string;\n}\n\ntype Matrix = number[][];\n\nconst metaElem = (type: SemanticElementType): SemanticElement => ({\n\ttype,\n\tstaff: -1,\n\tx: 0,\n\ty1: 0,\n\ty2: 0,\n});\n\nconst BOS_ELEMENT = metaElem(SemanticElementType.BOS);\n\nconst fractionToElems = (fraction: Fraction): SemanticElement[] => [\n\tmetaElem(TIME_SIG_NUMERATORS[fraction.numerator]),\n\tmetaElem(TIME_SIG_DENOMINATORS[fraction.denominator]),\n];\n\nconst argmax = (data: number[], mask: boolean[]): number => {\n\tconst values = data.filter((_, i) => mask[i]);\n\tconst max = Math.max(...values);\n\n\treturn data.findIndex((x) => x === max);\n};\n\nclass SemanticCluster extends SimpleClass {\n\tindex?: number;\n\n\telements: SemanticElement[];\n\tmatrixH?: Matrix; // matrix N x N\n\t_matrixV?: Matrix; // matrix N x N\n\tgroupsV?: number[][]; // ids array\n\tmasks?: [boolean[], boolean[], boolean[]]; // the masks for: [jointer source, jointer target, V]\n\n\tstatic elementToJSON(elem: SemanticElement): object {\n\t\tconst result: any = {\n\t\t\ttype: elem.type,\n\t\t\tstaff: elem.staff,\n\t\t\tx: elem.x,\n\t\t\ty1: elem.y1,\n\t\t\ty2: elem.y2,\n\t\t};\n\n\t\tif (elem.id) result.id = elem.id;\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget sourceMask(): boolean[] {\n\t\treturn this.elements.map((elem) => SOURCE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget targetMask(): boolean[] {\n\t\treturn this.elements.map((elem) => TARGET_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget vMask(): boolean[] {\n\t\treturn this.elements.map((elem) => ROOT_NOTE_ELEMENT_TYPES.includes(elem.type));\n\t}\n\n\tget compactMatrixH(): Matrix {\n\t\tif (!this.matrixH) return null;\n\n\t\tconst sourceMask = this.sourceMask;\n\t\tconst targetMask = this.targetMask;\n\n\t\treturn this.matrixH.filter((_, i) => sourceMask[i]).map((row) => row.filter((_, j) => targetMask[j]));\n\t}\n\n\tset compactMatrixH(value: Matrix) {\n\t\tthis.matrixH = expandMatrixByMasks([].concat(...value), [this.sourceMask, this.targetMask]);\n\t}\n\n\tget compactMatrixV(): number[] {\n\t\tif (!this._matrixV) return null;\n\n\t\tconst vMask = this.vMask;\n\n\t\tconst matrix = this._matrixV.filter((_, i) => vMask[i]).map((row) => row.filter((_, j) => vMask[j]));\n\n\t\treturn [].concat(...matrix.map((row, i) => row.slice(0, i)));\n\t}\n\n\tset compactMatrixV(value: number[]) {\n\t\tthis.matrixV = value && expandMatrixByMaskTriu(value, this.vMask);\n\t}\n\n\tget matrixV(): Matrix {\n\t\treturn this.groupsV && matrixFromGroups(this.elements.length, this.groupsV);\n\t}\n\n\tset matrixV(value: Matrix) {\n\t\tif (!value) {\n\t\t\tthis.groupsV = null;\n\t\t\tthis._matrixV = value;\n\t\t\treturn;\n\t\t}\n\n\t\tconst THRESHOLD = 0.5;\n\n\t\tconst groups: number[][] = [];\n\t\tconst vMask = value.map((row, i) => row.some(Number.isFinite) || value.some((row) => Number.isFinite(row[i])));\n\n\t\tvalue.forEach((row, i) => {\n\t\t\tif (vMask[i]) {\n\t\t\t\tlet found = false;\n\n\t\t\t\tfor (let j = 0; j < i; ++j) {\n\t\t\t\t\tconst cell = row[j];\n\t\t\t\t\tif (cell >= THRESHOLD) {\n\t\t\t\t\t\tconst g = groups.findIndex((group) => group.includes(j));\n\t\t\t\t\t\tgroups[g].push(i);\n\n\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!found) groups.push([i]);\n\t\t\t}\n\t\t});\n\n\t\tthis.groupsV = groups;\n\t\tthis._matrixV = value;\n\t}\n\n\ttoJSON(): any {\n\t\treturn {\n\t\t\t__prototype: 'SemanticCluster',\n\t\t\tindex: this.index,\n\t\t\telements: this.elements.map(SemanticCluster.elementToJSON),\n\t\t\tcompactMatrixH: this.compactMatrixH,\n\t\t\tcompactMatrixV: this.compactMatrixV,\n\t\t\t//groupsV: this.groupsV,\n\t\t};\n\t}\n\n\tstatic mapMatrix(matrix: number[][], x2i: number[], i2x: number[]): number[][] {\n\t\tconst rows = x2i.reduce((rows, i, x) => {\n\t\t\tif (rows[i]) rows[i] = rows[i].map((v, xi) => (v + matrix[x][xi] ? 1 : 0));\n\t\t\telse rows[i] = matrix[x];\n\n\t\t\treturn rows;\n\t\t}, [] as number[][]);\n\n\t\treturn rows.map((row) => i2x.map((x) => row[x]));\n\t}\n\n\tmergeOverlapping() {\n\t\tconst overlaps = this.overlappedNoteheads();\n\t\tif (overlaps.length) {\n\t\t\tconst x2i = this.elements.map((_, index) => {\n\t\t\t\tconst pair = overlaps.find((ij) => index === ij[1]);\n\t\t\t\tconst i = pair ? pair[0] : index;\n\n\t\t\t\treturn i - overlaps.filter((ij) => ij[1] < i).length;\n\t\t\t});\n\t\t\tconst i2x = Array(this.elements.length - overlaps.length)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, i) => x2i.findIndex((ii) => ii === i));\n\n\t\t\tthis.elements = i2x.map((x) => this.elements[x]);\n\t\t\tconsole.assert(this.elements.every(Boolean), 'null element found:', this, x2i, i2x);\n\n\t\t\tthis.matrixH = SemanticCluster.mapMatrix(this.matrixH, x2i, i2x);\n\t\t\tthis.groupsV = this.groupsV.map((group) => Array.from(new Set(group.map((x) => x2i[x]))));\n\t\t}\n\t}\n\n\toverlappedNoteheads(): [number, number][] {\n\t\tconst indices = [];\n\n\t\tconst noteheads = this.elements.filter((elem) => NOTEHEAD_ELEMENT_TYPES.includes(elem.type));\n\t\tfor (let i = 0; i < noteheads.length; ++i) {\n\t\t\tconst nh1 = noteheads[i];\n\t\t\tfor (let j = i + 1; j < noteheads.length; ++j) {\n\t\t\t\tconst nh2 = noteheads[j];\n\t\t\t\tif ((nh1.x - nh2.x) * (nh1.x - nh2.x) + (nh1.y1 - nh2.y1) * (nh1.y1 - nh2.y1) < 0.2 ** 2) indices.push([nh1.index, nh2.index]);\n\t\t\t}\n\t\t}\n\n\t\treturn indices;\n\t}\n\n\tgetEvents(): ChordColumn[] {\n\t\tconsole.assert(this.matrixH, '[SemanticCluster.getEvents]\tmatrixH is null.');\n\n\t\tconst NOTE_STEM_CONFIDENCE = 0.5;\n\n\t\tconst ids = Array(this.elements.length)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => index);\n\n\t\tconst targetMask = this.masks ? this.masks[1] : ids.map((id) => TARGET_ELEMENT_TYPES.includes(this.elements[id].type));\n\n\t\t//const stems = ids.filter(i => this.elements[i].type === et.vline_Stem);\n\t\tconst stemMasks = ids.map((id) => this.elements[id].type === et.vline_Stem && this.elements[id].y2 - this.elements[id].y1 > 2); // TODO: sift out too short stems by rectification model\n\t\tconst stemNotes = ids.filter((i) => [et.NoteheadS1, et.NoteheadS2, et.NoteheadGrace].includes(this.elements[i].type));\n\t\tconst s0s = ids.filter((i) => this.elements[i].type === et.NoteheadS0);\n\t\tconst subS0Masks = ids.map(() => false);\n\n\t\t// root elements: top NoteheadS0, Rests, stem with noteheads\n\t\tconst stemMap: { [stem: number]: number[] } = {};\n\t\tstemNotes.forEach((id) => {\n\t\t\tconst note = this.elements[id];\n\t\t\tconst stems = ids\n\t\t\t\t.filter((i) => stemMasks[i])\n\t\t\t\t.filter((stemId) => this.elements[stemId].y1 - 0.5 < note.y1 && this.elements[stemId].y2 + 0.5 > note.y1) // filter by stem Y range\n\t\t\t\t.sort((i1, i2) => this.matrixH[id][i2] - this.matrixH[id][i1]) // sort by confidence\n\t\t\t\t.slice(0, 2)\n\t\t\t\t.filter((i, ii) => ii === 0 || this.matrixH[id][i] >= NOTE_STEM_CONFIDENCE);\n\t\t\tstems.forEach((stem) => {\n\t\t\t\tstemMap[stem] = stemMap[stem] || [];\n\t\t\t\tstemMap[stem].push(id);\n\t\t\t});\n\t\t});\n\n\t\ts0s.forEach((id) => {\n\t\t\tconst s0 = this.elements[id];\n\t\t\tconst prevId = argmax(this.matrixH[id], targetMask);\n\t\t\tconst prev = this.elements[prevId];\n\t\t\tif (prev.type === et.NoteheadS0 && Math.abs(s0.x - prev.x) < 2.6) {\n\t\t\t\tsubS0Masks[id] = true;\n\t\t\t\tstemMap[prevId] = stemMap[prevId] || [prevId];\n\t\t\t\tstemMap[prevId].push(id);\n\t\t\t} else stemMap[id] = stemMap[id] || [id];\n\t\t});\n\n\t\t// setup linkings\n\t\tconst linkings: { [key: number]: number } = {};\n\n\t\tconst roots = ids.filter((id) => stemMap[id] || REST_ELEMENT_TYPES.includes(this.elements[id].type));\n\t\troots.sort((i1, i2) => this.elements[i1].x - this.elements[i2].x); // traverse roots from left to right later\n\n\t\tconst parentMasks = ids.map((id) => id === et.BOS);\n\t\troots.forEach((id) => {\n\t\t\tconst parentId = argmax(this.matrixH[id], parentMasks);\n\t\t\tlinkings[id] = parentId;\n\n\t\t\tif (parentId && !REST_ELEMENT_TYPES.includes(this.elements[parentId].type)) parentMasks[parentId] = false;\n\n\t\t\tparentMasks[id] = true;\n\t\t});\n\t\t//console.log(\"topology:\", stemMap, linkings);\n\n\t\tconst dots = this.elements.filter((elem) => elem.type === et.Dot);\n\t\tconst flags = this.elements.filter((elem) => elem.type === et.Flag3);\n\t\tconst beams = this.elements.filter((elem) => BEAM_ELEMENT_TYPES.includes(elem.type));\n\n\t\tconst groupsV = this.groupsV;\n\n\t\treturn roots\n\t\t\t.map((rootId): ChordColumn => {\n\t\t\t\tconst root = this.elements[rootId];\n\n\t\t\t\tconst tickGroup = groupsV ? groupsV.findIndex((group) => group.includes(rootId)) : null;\n\n\t\t\t\tif (REST_ELEMENT_TYPES.includes(root.type)) {\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > root.x + 0.5 && dot.x < root.x + 0.75 + 1.2 && dot.y1 > root.y1 - 1 && dot.y1 < root.y1);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft: root.x - 0.75,\n\t\t\t\t\t\tright: root.x + 0.75,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\trest: true,\n\t\t\t\t\t\tys: [root.y1],\n\t\t\t\t\t\tnoteIds: [root.id],\n\t\t\t\t\t\tdots: nearbyDots.length,\n\t\t\t\t\t\tdivision: root.type - et.Rest0,\n\t\t\t\t\t\tstemDirection: null,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: root.staff,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t} else if (stemMap[rootId]) {\n\t\t\t\t\tconst subNotes = stemMap[rootId].map((id) => this.elements[id]);\n\t\t\t\t\tconst left = Math.min(...subNotes.map((n) => n.x - 0.7));\n\t\t\t\t\tconst right = Math.max(...subNotes.map((n) => n.x + 0.7));\n\t\t\t\t\tsubNotes.sort((n1, n2) => n2.y1 - n1.y1);\n\n\t\t\t\t\tconst ys = subNotes.map((note) => note.y1);\n\n\t\t\t\t\tconst noteIds = subNotes.map((note) => note.id);\n\n\t\t\t\t\tconst top = ys[0];\n\t\t\t\t\tconst bottom = ys[ys.length - 1];\n\n\t\t\t\t\tconst nearbyDots = dots.filter((dot) => dot.x > right && dot.x < right + 1.2 && dot.y1 > top - 1 && dot.y1 < bottom + 0.5);\n\t\t\t\t\tconst dotGroups: { [key: number]: SemanticElement[] } = nearbyDots.reduce((groups, dot) => {\n\t\t\t\t\t\tconst y = roundNumber(dot.y1, 0.5);\n\t\t\t\t\t\tgroups[y] = groups[y] || [];\n\t\t\t\t\t\tgroups[y].push(dot);\n\n\t\t\t\t\t\treturn groups;\n\t\t\t\t\t}, {});\n\t\t\t\t\tconst dotValue = Math.max(...Object.values(dotGroups).map((group) => group.length), 0);\n\n\t\t\t\t\tlet division = NOTEHEAD_BASE_DIVISION[subNotes[0].type];\n\n\t\t\t\t\tlet stemDirection = null;\n\t\t\t\t\tlet beam: string = null;\n\t\t\t\t\tlet tip = null;\n\t\t\t\t\tif (root.type === et.vline_Stem) {\n\t\t\t\t\t\tconst topTip = top - root.y1;\n\t\t\t\t\t\tconst bottomTip = root.y2 - bottom;\n\t\t\t\t\t\tstemDirection = topTip > bottomTip ? 'u' : 'd';\n\n\t\t\t\t\t\ttip = { x: root.x, y: stemDirection === 'u' ? root.y1 : root.y2 };\n\n\t\t\t\t\t\tif (division === 2) {\n\t\t\t\t\t\t\tconst flagRange = stemDirection === 'u' ? [root.y1 - 0.4, root.y2 - 1] : [root.y1 + 1, root.y2 + 0.4];\n\t\t\t\t\t\t\tconst nearbyFlags = flags.filter((flag) => Math.abs(flag.x - root.x) < 0.2 && flag.y1 > flagRange[0] && flag.y1 < flagRange[1]);\n\t\t\t\t\t\t\tdivision += nearbyFlags.length;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//const tipY = stemDirection === \"u\" ? root.y1 : root.y2;\n\t\t\t\t\t\tconst tipRange = stemDirection === 'u' ? [root.y1 - 0.2, root.y1 + 0.9] : [root.y2 - 0.9, root.y2 + 0.2];\n\t\t\t\t\t\tconst beamElem = beams.find((beam) => Math.abs(beam.x - root.x) < 0.2 && beam.y1 > tipRange[0] && beam.y1 < tipRange[1]);\n\t\t\t\t\t\tbeam = beamElem ? ELEMENT_TO_STEMBEAM[beamElem.type] : null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst grace = subNotes[0].type === SemanticElementType.NoteheadGrace ? GraceType.Grace : null;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tleft,\n\t\t\t\t\t\tright,\n\t\t\t\t\t\tpivotX: root.x,\n\t\t\t\t\t\tys,\n\t\t\t\t\t\ttip,\n\t\t\t\t\t\tnoteIds,\n\t\t\t\t\t\tdivision,\n\t\t\t\t\t\tdots: dotValue,\n\t\t\t\t\t\trest: false,\n\t\t\t\t\t\tstemDirection,\n\t\t\t\t\t\tbeam,\n\t\t\t\t\t\tid: rootId,\n\t\t\t\t\t\tprevId: linkings[rootId],\n\t\t\t\t\t\tstaff: subNotes[0].staff,\n\t\t\t\t\t\tgrace,\n\t\t\t\t\t\ttickGroup,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n}\n\ninterface SemanticClusterSetData {\n\tvocab?: string[];\n\tclusters: SemanticCluster[];\n}\n\nclass SemanticClusterSet {\n\tclusters: SemanticCluster[];\n\n\tconstructor(data?: SemanticClusterSetData) {\n\t\tif (data) {\n\t\t\tthis.clusters = data.clusters;\n\n\t\t\t// upgrade vocab\n\t\t\tif (data.vocab) {\n\t\t\t\tconst converts = data.vocab\n\t\t\t\t\t.map((name, i) => [i, SemanticElementType[name]])\n\t\t\t\t\t.filter(([x, y]) => x !== y)\n\t\t\t\t\t.reduce((table, [x, y]) => ((table[x] = y), table), {});\n\t\t\t\tthis.clusters.forEach((connection) =>\n\t\t\t\t\tconnection.elements.forEach((elem) => {\n\t\t\t\t\t\tif (Number.isFinite(converts[elem.type])) elem.type = converts[elem.type];\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoJSON() {\n\t\tconst vocab = Object.entries(SemanticElementType)\n\t\t\t.filter((entry) => Number.isFinite(entry[1]))\n\t\t\t.map((entry) => entry[0]);\n\n\t\treturn {\n\t\t\t__prototype: 'SemanticClusterSet',\n\t\t\tvocab,\n\t\t\tclusters: this.clusters.map((c) => c.toJSON()),\n\t\t};\n\t}\n}\n\nconst expandMatrixByMasks = (matrix: number[], masks: [boolean[], boolean[]]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\tconst [maskSrc, maskTar] = masks;\n\n\treturn maskSrc.map((src) => maskTar.map((tar) => (src && tar ? iter.next().value : null)));\n};\n\nconst expandMatrixByMaskTriu = (matrix: number[], mask: boolean[]): Matrix => {\n\tconst gen = function* (): Generator {\n\t\tfor (const x of matrix) yield x;\n\t};\n\tconst iter = gen();\n\n\treturn mask.map((row, i) => mask.map((column, j) => (row && column && j < i ? iter.next().value : null)));\n};\n\nconst matrixFromGroups = (len: number, groups: number[][]): Matrix => {\n\tconst groupIds = Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) => groups.findIndex((group) => group.includes(i)));\n\n\treturn Array(len)\n\t\t.fill(null)\n\t\t.map((_, i) =>\n\t\t\tArray(len)\n\t\t\t\t.fill(null)\n\t\t\t\t.map((_, j) => {\n\t\t\t\t\tif (j >= i) return null;\n\n\t\t\t\t\tconst id1 = groupIds[i];\n\t\t\t\t\tconst id2 = groupIds[j];\n\n\t\t\t\t\tif (id1 < 0 || id2 < 0) return null;\n\n\t\t\t\t\treturn id1 === id2 ? 1 : 0;\n\t\t\t\t})\n\t\t);\n};\n\nexport {\n\tSemanticElementType,\n\tSemanticElement,\n\tSemanticCluster,\n\tSemanticClusterSet,\n\tELEMENT_TOKEN_NAMES,\n\tNOTEHEAD_ELEMENT_TYPES,\n\tNOTE_ELEMENT_TYPES,\n\tBOS_ELEMENT,\n\tfractionToElems,\n\texpandMatrixByMasks,\n\texpandMatrixByMaskTriu,\n\tmatrixFromGroups,\n};\n","import { MusicNotation } from '@k-l-lambda/music-widgets';\n\n// implicit note (from expressive marks) types\nenum ImplicitType {\n\tNone = 0,\n\n\tMordent = 'mordent',\n\tPrall = 'prall',\n\tTurn = 'turn',\n\tTrill = 'trill',\n\tTremolo = 'tremolo',\n\tArpeggio = 'arpeggio',\n}\n\ninterface ChordPosition {\n\tindex: number;\n\tcount: number;\n}\n\nclass TokenPosition {\n\tsystem?: number;\n\tmeasure?: number;\n\tx: number;\n\tendX?: number;\n}\n\ninterface Note extends MusicNotation.Note {\n\tchordPosition?: ChordPosition;\n\tmeasure?: number;\n}\n\ninterface Notation {\n\tnotes: Note[];\n\tendTick: number;\n}\n\ninterface SheetPosition {\n\tsystem: number;\n\tx: number;\n}\n\nexport { ChordPosition, ImplicitType, TokenPosition, Note, Notation, SheetPosition };\n","\n/* Wrapper for accessing buffer through sequential reads */\n\n\n\nmodule.exports = class Stream {\n\tconstructor (buffer) {\n\t\tthis.array = new Uint8Array(buffer);\n\t\tthis.position = 0;\n\t}\n\n\n\teof () {\n\t\treturn this.position >= this.array.length;\n\t}\n\n\n\tread (length) {\n\t\tconst result = this.array.slice(this.position, this.position + length);\n\t\tthis.position += length;\n\n\t\treturn result;\n\t}\n\n\n\treadString (length) {\n\t\tconst data = Array.from(this.read(length));\n\n\t\treturn data.map(c => String.fromCharCode(c)).join(\"\");\n\t}\n\n\n\t// read a big-endian 32-bit integer\n\treadInt32 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 24) +\n\t\t\t(this.array[this.position + 1] << 16) +\n\t\t\t(this.array[this.position + 2] << 8) +\n\t\t\tthis.array[this.position + 3]);\n\t\tthis.position += 4;\n\n\t\treturn result;\n\t}\n\n\n\t// read a big-endian 16-bit integer\n\treadInt16 () {\n\t\tconst result = (\n\t\t\t(this.array[this.position] << 8) +\n\t\t\tthis.array[this.position + 1]);\n\t\tthis.position += 2;\n\n\t\treturn result;\n\t}\n\n\n\t// read an 8-bit integer\n\treadInt8 (signed) {\n\t\tlet result = this.array[this.position];\n\t\tif (signed && result > 127)\n\t\t\tresult -= 256;\n\t\tthis.position += 1;\n\n\t\treturn result;\n\t}\n\n\n\t/* read a MIDI-style variable-length integer\n\t\t(big-endian value in groups of 7 bits,\n\t\twith top bit set to signify that another byte follows)\n\t*/\n\treadVarInt () {\n\t\tlet result = 0;\n\t\twhile (true) {\n\t\t\tconst b = this.readInt8();\n\t\t\tif (b & 0x80) {\n\t\t\t\tresult += (b & 0x7f);\n\t\t\t\tresult <<= 7;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// b is the last byte\n\t\t\t\treturn result + b;\n\t\t\t}\n\t\t}\n\t}\n};\n","/*\nclass to parse the .mid file format\n(depends on stream.js)\n*/\n\nconst Stream = require(\"./stream.js\");\n\n\n\nmodule.exports = function MidiFile (data) {\n\tfunction readChunk (stream) {\n\t\tconst id = stream.readString(4);\n\t\tconst length = stream.readInt32();\n\n\t\treturn {\n\t\t\tid,\n\t\t\tlength,\n\t\t\tdata: stream.read(length),\n\t\t};\n\t}\n\n\tlet lastEventTypeByte;\n\n\tfunction readEvent (stream) {\n\t\tconst event = {};\n\t\tevent.deltaTime = stream.readVarInt();\n\t\tlet eventTypeByte = stream.readInt8();\n\t\tif ((eventTypeByte & 0xf0) === 0xf0) {\n\t\t\t// system / meta event\n\t\t\tif (eventTypeByte === 0xff) {\n\t\t\t\t// meta event\n\t\t\t\tevent.type = \"meta\";\n\t\t\t\tconst subtypeByte = stream.readInt8();\n\t\t\t\tconst length = stream.readVarInt();\n\n\t\t\t\tswitch (subtypeByte) {\n\t\t\t\tcase 0x00:\n\t\t\t\t\tevent.subtype = \"sequenceNumber\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for sequenceNumber event is 2, got \" + length);\n\t\t\t\t\tevent.number = stream.readInt16();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x01:\n\t\t\t\t\tevent.subtype = \"text\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x02:\n\t\t\t\t\tevent.subtype = \"copyrightNotice\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x03:\n\t\t\t\t\tevent.subtype = \"trackName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x04:\n\t\t\t\t\tevent.subtype = \"instrumentName\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x05:\n\t\t\t\t\tevent.subtype = \"lyrics\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x06:\n\t\t\t\t\tevent.subtype = \"marker\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x07:\n\t\t\t\t\tevent.subtype = \"cuePoint\";\n\t\t\t\t\tevent.text = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x20:\n\t\t\t\t\tevent.subtype = \"midiChannelPrefix\";\n\t\t\t\t\tif (length !== 1)\n\t\t\t\t\t\tthrow new Error(\"Expected length for midiChannelPrefix event is 1, got \" + length);\n\t\t\t\t\tevent.channel = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x2f:\n\t\t\t\t\tevent.subtype = \"endOfTrack\";\n\t\t\t\t\tif (length !== 0)\n\t\t\t\t\t\tthrow new Error(\"Expected length for endOfTrack event is 0, got \" + length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x51:\n\t\t\t\t\tevent.subtype = \"setTempo\";\n\t\t\t\t\tif (length !== 3)\n\t\t\t\t\t\tthrow new Error(\"Expected length for setTempo event is 3, got \" + length);\n\t\t\t\t\tevent.microsecondsPerBeat = (\n\t\t\t\t\t\t(stream.readInt8() << 16) +\n\t\t\t\t\t\t\t(stream.readInt8() << 8) +\n\t\t\t\t\t\t\tstream.readInt8()\n\t\t\t\t\t);\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x54:\n\t\t\t\t\tevent.subtype = \"smpteOffset\";\n\t\t\t\t\tif (length !== 5)\n\t\t\t\t\t\tthrow new Error(\"Expected length for smpteOffset event is 5, got \" + length);\n\t\t\t\t\tconst hourByte = stream.readInt8();\n\t\t\t\t\tevent.frameRate = {\n\t\t\t\t\t\t0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30,\n\t\t\t\t\t}[hourByte & 0x60];\n\t\t\t\t\tevent.hour = hourByte & 0x1f;\n\t\t\t\t\tevent.min = stream.readInt8();\n\t\t\t\t\tevent.sec = stream.readInt8();\n\t\t\t\t\tevent.frame = stream.readInt8();\n\t\t\t\t\tevent.subframe = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x58:\n\t\t\t\t\tevent.subtype = \"timeSignature\";\n\t\t\t\t\tif (length !== 4)\n\t\t\t\t\t\tthrow new Error(\"Expected length for timeSignature event is 4, got \" + length);\n\t\t\t\t\tevent.numerator = stream.readInt8();\n\t\t\t\t\tevent.denominator = Math.pow(2, stream.readInt8());\n\t\t\t\t\tevent.metronome = stream.readInt8();\n\t\t\t\t\tevent.thirtyseconds = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x59:\n\t\t\t\t\tevent.subtype = \"keySignature\";\n\t\t\t\t\tif (length !== 2)\n\t\t\t\t\t\tthrow new Error(\"Expected length for keySignature event is 2, got \" + length);\n\t\t\t\t\tevent.key = stream.readInt8(true);\n\t\t\t\t\tevent.scale = stream.readInt8();\n\n\t\t\t\t\treturn event;\n\t\t\t\tcase 0x7f:\n\t\t\t\t\tevent.subtype = \"sequencerSpecific\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\tdefault:\n\t\t\t\t\t// console.log(\"Unrecognised meta event subtype: \" + subtypeByte);\n\t\t\t\t\tevent.subtype = \"unknown\";\n\t\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\t\treturn event;\n\t\t\t\t}\n\n\t\t\t\t//event.data = stream.readString(length);\n\t\t\t\t//return event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf0) {\n\t\t\t\tevent.type = \"sysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse if (eventTypeByte === 0xf7) {\n\t\t\t\tevent.type = \"dividedSysEx\";\n\t\t\t\tconst length = stream.readVarInt();\n\t\t\t\tevent.data = stream.readString(length);\n\n\t\t\t\treturn event;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type byte: \" + eventTypeByte);\n\t\t}\n\t\telse {\n\t\t\t/* channel event */\n\t\t\tlet param1;\n\t\t\tif ((eventTypeByte & 0x80) === 0) {\n\t\t\t\t/* running status - reuse lastEventTypeByte as the event type.\n\t\t\t\t\teventTypeByte is actually the first parameter\n\t\t\t\t*/\n\t\t\t\tparam1 = eventTypeByte;\n\t\t\t\teventTypeByte = lastEventTypeByte;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tparam1 = stream.readInt8();\n\t\t\t\tlastEventTypeByte = eventTypeByte;\n\t\t\t}\n\n\t\t\tconst eventType = eventTypeByte >> 4;\n\t\t\tevent.channel = eventTypeByte & 0x0f;\n\t\t\tevent.type = \"channel\";\n\n\t\t\tswitch (eventType) {\n\t\t\tcase 0x08:\n\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x09:\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.velocity = stream.readInt8();\n\t\t\t\tif (event.velocity === 0)\n\t\t\t\t\tevent.subtype = \"noteOff\";\n\t\t\t\telse\n\t\t\t\t\tevent.subtype = \"noteOn\";\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0a:\n\t\t\t\tevent.subtype = \"noteAftertouch\";\n\t\t\t\tevent.noteNumber = param1;\n\t\t\t\tevent.amount = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0b:\n\t\t\t\tevent.subtype = \"controller\";\n\t\t\t\tevent.controllerType = param1;\n\t\t\t\tevent.value = stream.readInt8();\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0c:\n\t\t\t\tevent.subtype = \"programChange\";\n\t\t\t\tevent.programNumber = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0d:\n\t\t\t\tevent.subtype = \"channelAftertouch\";\n\t\t\t\tevent.amount = param1;\n\n\t\t\t\treturn event;\n\t\t\tcase 0x0e:\n\t\t\t\tevent.subtype = \"pitchBend\";\n\t\t\t\tevent.value = param1 + (stream.readInt8() << 7);\n\n\t\t\t\treturn event;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unrecognised MIDI event type: \" + eventType);\n\n\t\t\t\t/*\n\t\t\t\tconsole.log(\"Unrecognised MIDI event type: \" + eventType);\n\t\t\t\tstream.readInt8();\n\t\t\t\tevent.subtype = 'unknown';\n\t\t\t\treturn event;\n\t\t\t\t*/\n\t\t\t}\n\t\t}\n\t}\n\n\n\tlet source = data;\n\tif (typeof data === \"string\")\n\t\tsource = data.split(\"\").map(c => c.charCodeAt(0));\n\n\tconst stream = new Stream(source);\n\tconst headerChunk = readChunk(stream);\n\tif (headerChunk.id !== \"MThd\" || headerChunk.length !== 6)\n\t\tthrow new Error(\"Bad .mid file - header not found\");\n\n\tconst headerStream = new Stream(headerChunk.data);\n\tconst formatType = headerStream.readInt16();\n\tconst trackCount = headerStream.readInt16();\n\tconst timeDivision = headerStream.readInt16();\n\n\tlet ticksPerBeat;\n\tif (timeDivision & 0x8000)\n\t\tthrow new Error(\"Expressing time division in SMTPE frames is not supported yet\");\n\telse\n\t\tticksPerBeat = timeDivision;\n\n\n\tconst header = {\n\t\tformatType,\n\t\ttrackCount,\n\t\tticksPerBeat,\n\t};\n\tconst tracks = [];\n\tfor (let i = 0; i < header.trackCount; i++) {\n\t\ttracks[i] = [];\n\t\tconst trackChunk = readChunk(stream);\n\t\tif (trackChunk.id !== \"MTrk\")\n\t\t\tthrow new Error(\"Unexpected chunk - expected MTrk, got \" + trackChunk.id);\n\n\t\tconst trackStream = new Stream(trackChunk.data);\n\t\twhile (!trackStream.eof()) {\n\t\t\tconst event = readEvent(trackStream);\n\t\t\ttracks[i].push(event);\n\t\t}\n\t}\n\n\treturn {\n\t\theader,\n\t\ttracks,\n\t};\n};\n","\r\n/* Wrapper for accessing strings through sequential writes */\r\n\r\n\r\n\r\nmodule.exports = class OStream {\r\n\tconstructor () {\r\n\t\tthis.buffer = \"\";\r\n\t}\r\n\r\n\twrite (str) {\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\t/* write a big-endian 32-bit integer */\r\n\twriteInt32 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 24) & 0xff) + String.fromCharCode((i >> 16) & 0xff) +\r\n\t\t\tString.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a big-endian 16-bit integer */\r\n\twriteInt16 (i) {\r\n\t\tthis.buffer += String.fromCharCode((i >> 8) & 0xff) + String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write an 8-bit integer */\r\n\twriteInt8 (i) {\r\n\t\tthis.buffer += String.fromCharCode(i & 0xff);\r\n\t}\r\n\r\n\t/* write a MIDI-style variable-length integer\r\n\t\t(big-endian value in groups of 7 bits,\r\n\t\twith top bit set to signify that another byte follows)\r\n\t*/\r\n\twriteVarInt (i) {\r\n\t\tif (i < 0)\r\n\t\t\tthrow new Error(\"OStream.writeVarInt minus number: \" + i);\r\n\r\n\t\tconst b = i & 0x7f;\r\n\t\ti >>= 7;\r\n\t\tlet str = String.fromCharCode(b);\r\n\r\n\t\twhile (i) {\r\n\t\t\tconst b = i & 0x7f;\r\n\t\t\ti >>= 7;\r\n\t\t\tstr = String.fromCharCode(b | 0x80) + str;\r\n\t\t}\r\n\r\n\t\tthis.buffer += str;\r\n\t}\r\n\r\n\tgetBuffer () {\r\n\t\treturn this.buffer;\r\n\t}\r\n\r\n\tgetArrayBuffer () {\r\n\t\treturn Uint8Array.from(this.buffer.split(\"\").map(c => c.charCodeAt(0))).buffer;\r\n\t}\r\n};\r\n","/*\r\nclass to encode the .mid file format\r\n(depends on streamEx.js)\r\n*/\r\n\r\nconst OStream = require(\"./streamEx.js\");\r\n\r\n\r\n\r\nmodule.exports = function OMidiFile ({ header, tracks }) {\r\n\tfunction writeChunk (stream, id, data) {\r\n\t\tconsole.assert(id.length === 4, \"chunk id must be 4 byte\");\r\n\r\n\t\tstream.write(id);\r\n\t\tstream.writeInt32(data.length);\r\n\t\tstream.write(data);\r\n\t}\r\n\r\n\tfunction writeEvent (stream, event) {\r\n\t\tif (event.subtype === \"unknown\")\r\n\t\t\treturn;\r\n\r\n\t\tstream.writeVarInt(event.deltaTime);\r\n\r\n\t\tswitch (event.type) {\r\n\t\tcase \"meta\":\r\n\t\t\tstream.writeInt8(0xff);\r\n\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"sequenceNumber\":\r\n\t\t\t\tstream.writeInt8(0x00);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt16(event.number);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"text\":\r\n\t\t\t\tstream.writeInt8(0x01);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"copyrightNotice\":\r\n\t\t\t\tstream.writeInt8(0x02);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"trackName\":\r\n\t\t\t\tstream.writeInt8(0x03);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"instrumentName\":\r\n\t\t\t\tstream.writeInt8(0x04);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"lyrics\":\r\n\t\t\t\tstream.writeInt8(0x05);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"marker\":\r\n\t\t\t\tstream.writeInt8(0x06);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"cuePoint\":\r\n\t\t\t\tstream.writeInt8(0x07);\r\n\t\t\t\tstream.writeVarInt(event.text.length);\r\n\r\n\t\t\t\tstream.write(event.text);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"midiChannelPrefix\":\r\n\t\t\t\tstream.writeInt8(0x20);\r\n\t\t\t\tstream.writeVarInt(1);\r\n\r\n\t\t\t\tstream.writeInt8(event.channel);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"endOfTrack\":\r\n\t\t\t\tstream.writeInt8(0x2f);\r\n\t\t\t\tstream.writeVarInt(0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"setTempo\":\r\n\t\t\t\tstream.writeInt8(0x51);\r\n\t\t\t\tstream.writeVarInt(3);\r\n\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 16) & 0xff);\r\n\t\t\t\tstream.writeInt8((event.microsecondsPerBeat >> 8) & 0xff);\r\n\t\t\t\tstream.writeInt8(event.microsecondsPerBeat & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"smpteOffset\":\r\n\t\t\t\tstream.writeInt8(0x54);\r\n\t\t\t\tstream.writeVarInt(5);\r\n\r\n\t\t\t\tvar frameByte = { 24: 0x00, 25: 0x20, 29: 0x40, 30: 0x60 }[event.frameRate];\r\n\t\t\t\tstream.writeInt8(event.hour | frameByte);\r\n\t\t\t\tstream.writeInt8(event.min);\r\n\t\t\t\tstream.writeInt8(event.sec);\r\n\t\t\t\tstream.writeInt8(event.frame);\r\n\t\t\t\tstream.writeInt8(event.subframe);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"timeSignature\":\r\n\t\t\t\tstream.writeInt8(0x58);\r\n\t\t\t\tstream.writeVarInt(4);\r\n\r\n\t\t\t\tstream.writeInt8(event.numerator);\r\n\t\t\t\tstream.writeInt8(Math.log2(event.denominator));\r\n\t\t\t\tstream.writeInt8(event.metronome);\r\n\t\t\t\tstream.writeInt8(event.thirtyseconds);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"keySignature\":\r\n\t\t\t\tstream.writeInt8(0x59);\r\n\t\t\t\tstream.writeVarInt(2);\r\n\r\n\t\t\t\tstream.writeInt8(event.key);\r\n\t\t\t\tstream.writeInt8(event.scale);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"sequencerSpecific\":\r\n\t\t\t\tstream.writeInt8(0x7f);\r\n\t\t\t\tstream.writeVarInt(event.data.length);\r\n\r\n\t\t\t\tstream.write(event.data);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"sysEx\":\r\n\t\t\tstream.writeInt8(0xf0);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"dividedSysEx\":\r\n\t\t\tstream.writeInt8(0xf7);\r\n\t\t\tstream.writeVarInt(event.data.length);\r\n\t\t\tstream.write(event.data);\r\n\r\n\t\t\tbreak;\r\n\t\tcase \"channel\":\r\n\t\t\tswitch (event.subtype) {\r\n\t\t\tcase \"noteOn\":\r\n\t\t\t\tstream.writeInt8(0x90 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteOff\":\r\n\t\t\t\tstream.writeInt8(0x80 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.velocity ? event.velocity : 0);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"noteAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xa0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.noteNumber);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"controller\":\r\n\t\t\t\tstream.writeInt8(0xb0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.controllerType);\r\n\t\t\t\tstream.writeInt8(event.value);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"programChange\":\r\n\t\t\t\tstream.writeInt8(0xc0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.programNumber);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"channelAftertouch\":\r\n\t\t\t\tstream.writeInt8(0xd0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.amount);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"pitchBend\":\r\n\t\t\t\tstream.writeInt8(0xe0 | event.channel);\r\n\t\t\t\tstream.writeInt8(event.value & 0xff);\r\n\t\t\t\tstream.writeInt8((event.value >> 7) & 0xff);\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\"unhandled event subtype:\" + event.subtype);\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tthrow new Error(\"unhandled event type:\" + event.type);\r\n\t\t}\r\n\t}\r\n\r\n\tconst stream = new OStream();\r\n\r\n\tconst headerChunk = new OStream();\r\n\theaderChunk.writeInt16(header.formatType);\r\n\theaderChunk.writeInt16(tracks.length);\r\n\theaderChunk.writeInt16(header.ticksPerBeat);\r\n\r\n\twriteChunk(stream, \"MThd\", headerChunk.getBuffer());\r\n\r\n\tfor (let i = 0; i < tracks.length; ++i) {\r\n\t\tconst trackChunk = new OStream();\r\n\r\n\t\tfor (let ei = 0; ei < tracks[i].length; ++ei)\r\n\t\t\twriteEvent(trackChunk, tracks[i][ei]);\r\n\r\n\t\twriteChunk(stream, \"MTrk\", trackChunk.getBuffer());\r\n\t}\r\n\r\n\treturn stream.getArrayBuffer();\r\n};\r\n","\nmodule.exports = {\n\tparseMidiData: require(\"./midifile.js\"),\n\tencodeMidiFile: require(\"./midifileEx.js\"),\n};\n","\nconst midiToSequence = (midiFile, {timeWarp = 1} = {}) => {\n\tconst trackStates = [];\n\tlet beatsPerMinute = 120;\n\tconst ticksPerBeat = midiFile.header.ticksPerBeat;\n\n\tfor (let i = 0; i < midiFile.tracks.length; i++) {\n\t\ttrackStates[i] = {\n\t\t\tnextEventIndex: 0,\n\t\t\tticksToNextEvent: (\n\t\t\t\tmidiFile.tracks[i].length ?\n\t\t\t\t\tmidiFile.tracks[i][0].deltaTime :\n\t\t\t\t\tnull\n\t\t\t),\n\t\t};\n\t}\n\n\tfunction getNextEvent () {\n\t\tlet ticksToNextEvent = null;\n\t\tlet nextEventTrack = null;\n\t\tlet nextEventIndex = null;\n\n\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\tif (\n\t\t\t\ttrackStates[i].ticksToNextEvent != null\n\t\t\t\t&& (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent)\n\t\t\t) {\n\t\t\t\tticksToNextEvent = trackStates[i].ticksToNextEvent;\n\t\t\t\tnextEventTrack = i;\n\t\t\t\tnextEventIndex = trackStates[i].nextEventIndex;\n\t\t\t}\n\t\t}\n\t\tif (nextEventTrack != null) {\n\t\t\t/* consume event from that track */\n\t\t\tconst nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex];\n\t\t\tif (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime;\n\t\t\telse \n\t\t\t\ttrackStates[nextEventTrack].ticksToNextEvent = null;\n\n\t\t\ttrackStates[nextEventTrack].nextEventIndex += 1;\n\t\t\t/* advance timings on all tracks by ticksToNextEvent */\n\t\t\tfor (let i = 0; i < trackStates.length; i++) {\n\t\t\t\tif (trackStates[i].ticksToNextEvent != null) \n\t\t\t\t\ttrackStates[i].ticksToNextEvent -= ticksToNextEvent;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tticksToEvent: ticksToNextEvent,\n\t\t\t\tevent: nextEvent,\n\t\t\t\ttrack: nextEventTrack,\n\t\t\t};\n\t\t}\n\t\telse \n\t\t\treturn null;\n\t\t\n\t};\n\t//\n\tlet midiEvent;\n\tconst events = [];\n\t//\n\tfunction processEvents () {\n\t\tfunction processNext () {\n\t\t\tlet secondsToGenerate = 0;\n\t\t\tif (midiEvent.ticksToEvent > 0) {\n\t\t\t\tconst beatsToGenerate = midiEvent.ticksToEvent / ticksPerBeat;\n\t\t\t\tsecondsToGenerate = beatsToGenerate / (beatsPerMinute / 60);\n\t\t\t}\n\n\t\t\t// beatsPerMinute must be changed after secondsToGenerate calculation\n\t\t\tif ( midiEvent.event.type == \"meta\" && midiEvent.event.subtype == \"setTempo\" ) {\n\t\t\t\t// tempo change events can occur anywhere in the middle and affect events that follow\n\t\t\t\tbeatsPerMinute = 60e+6 / midiEvent.event.microsecondsPerBeat;\n\t\t\t}\n\n\t\t\tconst time = (secondsToGenerate * 1000 * timeWarp) || 0;\n\t\t\tevents.push([ midiEvent, time ]);\n\t\t\tmidiEvent = getNextEvent();\n\t\t};\n\t\t//\n\t\tif (midiEvent = getNextEvent()) {\n\t\t\twhile (midiEvent)\n\t\t\t\tprocessNext();\n\t\t}\n\t};\n\n\tprocessEvents();\n\n\treturn events;\n};\n\n\nconst trimSequence = seq => {\n\tconst status = new Map();\n\n\treturn seq.filter(([{event, ticksToEvent}]) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tstatus.clear();\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn true;\n\n\t\tconst key = `${event.subtype}|${event.channel}|${event.noteNumber}`;\n\n\t\tif (status.get(key)) {\n\t\t\t//console.debug(\"event trimmed:\", event, ticksToEvent);\n\t\t\treturn false;\n\t\t}\n\n\t\tstatus.set(key, event);\n\n\t\treturn true;\n\t});\n};\n\n\nconst fixOverlapNotes = seq => {\n\tconst noteMap = new Map();\n\tconst overlapMap = new Map();\n\tconst swaps = [];\n\n\tlet leapIndex = -1;\n\n\tseq.forEach(([{event, ticksToEvent}], index) => {\n\t\tif (ticksToEvent > 0)\n\t\t\tleapIndex = index;\n\n\t\tif (event.type !== \"channel\")\n\t\t\treturn;\n\n\t\tconst key = `${event.channel}|${event.noteNumber}`;\n\n\t\tswitch (event.subtype) {\n\t\tcase \"noteOn\":\n\t\t\tif (noteMap.get(key))\n\t\t\t\toverlapMap.set(key, leapIndex);\n\t\t\telse\n\t\t\t\tnoteMap.set(key, leapIndex);\n\n\t\t\tbreak;\n\t\tcase \"noteOff\":\n\t\t\tif (overlapMap.get(key)) {\n\t\t\t\tswaps.push([overlapMap.get(key), index]);\n\t\t\t\toverlapMap.delete(key);\n\t\t\t}\n\t\t\telse\n\t\t\t\tnoteMap.delete(key);\n\n\t\t\tbreak;\n\t\t}\n\t});\n\n\t// shift overlapped swaps\n\tswaps.forEach((swap, i) => {\n\t\tfor (let ii = i - 1; ii >= 0; --ii) {\n\t\t\tconst pre = swaps[ii];\n\t\t\tif (pre[1] < swap[0])\n\t\t\t\tbreak;\n\n\t\t\tif (swap[0] > pre[0])\n\t\t\t\t++swap[0];\n\t\t}\n\t});\n\n\t//console.debug(\"swaps:\", swaps);\n\tswaps.forEach(([front, back]) => {\n\t\tif (back >= seq.length - 1 || front < 0)\n\t\t\treturn;\n\n\t\tconst offEvent = seq[back];\n\t\tconst nextEvent = seq[back + 1];\n\t\tconst leapEvent = seq[front];\n\n\t\tif (!leapEvent[0].ticksToEvent) {\n\t\t\tconsole.warn(\"invalid front index:\", front, back, leapEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t// ms per tick\n\t\tconst tempo = leapEvent[1] / leapEvent[0].ticksToEvent;\n\n\t\tnextEvent[1] += offEvent[1];\n\t\tnextEvent[0].ticksToEvent += offEvent[0].ticksToEvent;\n\n\t\toffEvent[0].ticksToEvent = leapEvent[0].ticksToEvent - 1;\n\t\tleapEvent[0].ticksToEvent = 1;\n\n\t\toffEvent[1] = offEvent[0].ticksToEvent * tempo;\n\t\tleapEvent[1] = leapEvent[0].ticksToEvent * tempo;\n\t\t//console.debug(\"swap:\", [front, back], offEvent, nextEvent, leapEvent);\n\n\t\tseq.splice(back, 1);\n\t\tseq.splice(front, 0, offEvent);\n\t});\n\n\treturn seq;\n};\n\n\n\nmodule.exports = {\n\tmidiToSequence,\n\ttrimSequence,\n\tfixOverlapNotes,\n};\n","\nconst MidiSequence = require(\"./MidiSequence.js\");\n\n\n\nconst PedalControllerTypes = {\n\t64: \"Sustain\",\n\t65: \"Portamento\",\n\t66: \"Sostenuto\",\n\t67: \"Soft\",\n};\n\n\n\nclass Notation {\n\tstatic parseMidi (data, {fixOverlap = true} = {}) {\n\t\tconst channelStatus = [];\n\t\tconst pedalStatus = {};\n\t\tconst pedals = {};\n\t\tconst channels = [];\n\t\tconst bars = [];\n\t\tlet time = 0;\n\t\tlet millisecondsPerBeat = 600000 / 120;\n\t\tlet beats = 0;\n\t\tlet numerator = 4;\n\t\tlet barIndex = 0;\n\t\tconst keyRange = {};\n\t\tlet rawTicks = 0;\n\t\tlet ticks = 0;\n\t\tlet correspondences;\n\t\tconst tempos = [];\n\n\t\tconst ticksPerBeat = data.header.ticksPerBeat;\n\n\t\tlet rawEvents = MidiSequence.midiToSequence(data);\n\n\t\tif (fixOverlap)\n\t\t\trawEvents = MidiSequence.trimSequence(MidiSequence.fixOverlapNotes(rawEvents));\n\n\t\tconst events = rawEvents.map(d => ({\n\t\t\tdata: d[0].event,\n\t\t\ttrack: d[0].track,\n\t\t\tdeltaTime: d[1],\n\t\t\tdeltaTicks: d[0].ticksToEvent,\n\t\t}));\n\n\t\tlet index = 0;\n\n\t\tconst ticksNormal = 1;\n\n\t\tfor (const ev of events) {\n\t\t\trawTicks += ev.deltaTicks;\n\t\t\tticks = Math.round(rawTicks * ticksNormal);\n\n\t\t\tif (ev.deltaTicks > 0) {\n\t\t\t\t// append bars\n\t\t\t\tconst deltaBeats = ev.deltaTicks / ticksPerBeat;\n\t\t\t\tfor (let b = Math.ceil(beats); b < beats + deltaBeats; ++b) {\n\t\t\t\t\tconst t = time + (b - beats) * millisecondsPerBeat;\n\t\t\t\t\tbars.push({time: t, index: barIndex % numerator});\n\n\t\t\t\t\t++barIndex;\n\t\t\t\t}\n\n\t\t\t\tbeats += deltaBeats;\n\t\t\t}\n\n\t\t\ttime += ev.deltaTime;\n\n\t\t\t//const ticksTime = beats * millisecondsPerBeat;\n\t\t\t//console.log(\"time:\", time, ticksTime, ticksTime - time);\n\n\t\t\tev.time = time;\n\t\t\tev.ticks = ticks;\n\n\t\t\tconst event = ev.data;\n\t\t\tswitch (event.type) {\n\t\t\tcase \"channel\":\n\t\t\t\t//channelStatus[event.channel] = channelStatus[event.channel] || [];\n\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"noteOn\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\t\t\t\t\t\t//channelStatus[event.channel][pitch] = {\n\t\t\t\t\t\tchannelStatus.push({\n\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\tstartTick: ticks,\n\t\t\t\t\t\t\tstart: time,\n\t\t\t\t\t\t\tvelocity: event.velocity,\n\t\t\t\t\t\t\tbeats: beats,\n\t\t\t\t\t\t\ttrack: ev.track,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tkeyRange.low = Math.min(keyRange.low || pitch, pitch);\n\n\t\t\t\t\t\tev.index = index;\n\t\t\t\t\t\t++index;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"noteOff\":\n\t\t\t\t\t{\n\t\t\t\t\t\tconst pitch = event.noteNumber;\n\n\t\t\t\t\t\tchannels[event.channel] = channels[event.channel] || [];\n\n\t\t\t\t\t\tconst statusIndex = channelStatus.findIndex(status => status.channel == event.channel && status.pitch == pitch);\n\t\t\t\t\t\tif (statusIndex >= 0) {\n\t\t\t\t\t\t\tconst status = channelStatus.splice(statusIndex, 1)[0];\n\n\t\t\t\t\t\t\tchannels[event.channel].push({\n\t\t\t\t\t\t\t\tchannel: event.channel,\n\t\t\t\t\t\t\t\tstartTick: status.startTick,\n\t\t\t\t\t\t\t\tendTick: ticks,\n\t\t\t\t\t\t\t\tpitch,\n\t\t\t\t\t\t\t\tstart: status.start,\n\t\t\t\t\t\t\t\tduration: time - status.start,\n\t\t\t\t\t\t\t\tvelocity: status.velocity,\n\t\t\t\t\t\t\t\tbeats: status.beats,\n\t\t\t\t\t\t\t\ttrack: status.track,\n\t\t\t\t\t\t\t\tfinger: status.finger,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tconsole.debug(\"unexpected noteOff: \", time, event);\n\n\t\t\t\t\t\tkeyRange.high = Math.max(keyRange.high || pitch, pitch);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"controller\":\n\t\t\t\t\tswitch (event.controllerType) {\n\t\t\t\t\t// pedal controllers\n\t\t\t\t\tcase 64:\n\t\t\t\t\tcase 65:\n\t\t\t\t\tcase 66:\n\t\t\t\t\tcase 67:\n\t\t\t\t\t\tconst pedalType = PedalControllerTypes[event.controllerType];\n\n\t\t\t\t\t\tpedalStatus[event.channel] = pedalStatus[event.channel] || {};\n\t\t\t\t\t\tpedals[event.channel] = pedals[event.channel] || [];\n\n\t\t\t\t\t\tconst status = pedalStatus[event.channel][pedalType];\n\n\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\tpedals[event.channel].push({type: pedalType, start: status.start, duration: time - status.start, value: status.value});\n\t\t\t\t\t\tpedalStatus[event.channel][pedalType] = {start: time, value: event.value};\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase \"meta\":\n\t\t\t\tswitch (event.subtype) {\n\t\t\t\tcase \"setTempo\":\n\t\t\t\t\tmillisecondsPerBeat = event.microsecondsPerBeat / 1000;\n\t\t\t\t\t//beats = Math.round(beats);\n\t\t\t\t\t//console.assert(Number.isFinite(time), \"invalid time:\", time);\n\t\t\t\t\ttempos.push({tempo: event.microsecondsPerBeat, tick: ticks, time});\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"timeSignature\":\n\t\t\t\t\tnumerator = event.numerator;\n\t\t\t\t\tbarIndex = 0;\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"text\":\n\t\t\t\t\tif (!correspondences && /^find-corres:/.test(event.text)) {\n\t\t\t\t\t\tconst captures = event.text.match(/:([\\d\\,-]+)/);\n\t\t\t\t\t\tconst str = captures && captures[1] || \"\";\n\t\t\t\t\t\tcorrespondences = str.split(\",\").map(s => Number(s));\n\t\t\t\t\t}\n\t\t\t\t\telse if (/fingering\\(.*\\)/.test(event.text)) {\n\t\t\t\t\t\tconst [_, fingers] = event.text.match(/\\((.+)\\)/);\n\t\t\t\t\t\tconst finger = Number(fingers);\n\t\t\t\t\t\tif (!Number.isNaN(finger)) {\n\t\t\t\t\t\t\tconst status = channelStatus[channelStatus.length - 1];\n\t\t\t\t\t\t\tif (status)\n\t\t\t\t\t\t\t\tstatus.finger = finger;\n\n\t\t\t\t\t\t\tconst event = events.find(e => e.index == index - 1);\n\t\t\t\t\t\t\tif (event)\n\t\t\t\t\t\t\t\tevent.data.finger = finger;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"copyrightNotice\":\n\t\t\t\t\tconsole.log(\"MIDI copyright:\", event.text);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tchannelStatus.forEach(status => {\n\t\t\tconsole.debug(\"unclosed noteOn event at\", status.startTick, status);\n\n\t\t\tchannels[status.channel].push({\n\t\t\t\tstartTick: status.startTick,\n\t\t\t\tendTick: ticks,\n\t\t\t\tpitch: status.pitch,\n\t\t\t\tstart: status.start,\n\t\t\t\tduration: time - status.start,\n\t\t\t\tvelocity: status.velocity,\n\t\t\t\tbeats: status.beats,\n\t\t\t\ttrack: status.track,\n\t\t\t\tfinger: status.finger,\n\t\t\t});\n\t\t});\n\n\t\treturn new Notation({\n\t\t\tchannels,\n\t\t\tkeyRange,\n\t\t\tpedals,\n\t\t\tbars,\n\t\t\tendTime: time,\n\t\t\tendTick: ticks,\n\t\t\tcorrespondences,\n\t\t\tevents,\n\t\t\ttempos,\n\t\t\tticksPerBeat,\n\t\t\tmeta: {},\n\t\t});\n\t}\n\n\n\tconstructor (fields) {\n\t\tObject.assign(this, fields);\n\n\t\t// channels to notes\n\t\tthis.notes = [];\n\t\tfor (const channel of this.channels) {\n\t\t\tif (channel) {\n\t\t\t\tfor (const note of channel)\n\t\t\t\t\tthis.notes.push(note);\n\t\t\t}\n\t\t}\n\t\tthis.notes.sort(function (n1, n2) {\n\t\t\treturn n1.start - n2.start;\n\t\t});\n\n\t\tfor (const i in this.notes)\n\t\t\tthis.notes[i].index = Number(i);\n\n\n\t\t// duration\n\t\tthis.duration = this.notes.length > 0 ? (this.endTime - this.notes[0].start) : 0,\n\n\t\t//this.endSoftIndex = this.notes.length ? this.notes[this.notes.length - 1].softIndex : 0;\n\n\n\t\t// pitch map\n\t\tthis.pitchMap = [];\n\t\tfor (const c in this.channels) {\n\t\t\tfor (const n in this.channels[c]) {\n\t\t\t\tconst pitch = this.channels[c][n].pitch;\n\t\t\t\tthis.pitchMap[pitch] = this.pitchMap[pitch] || [];\n\n\t\t\t\tthis.pitchMap[pitch].push(this.channels[c][n]);\n\t\t\t}\n\t\t}\n\n\t\tthis.pitchMap.forEach(notes => notes.sort((n1, n2) => n1.start - n2.start));\n\n\n\t\t/*// setup measure notes index\n\t\tif (this.measures) {\n\t\t\tconst measure_list = [];\n\n\t\t\tlet last_measure = null;\n\t\t\tconst measure_entries = Object.entries(this.measures).sort((e1, e2) => Number(e1[0]) - Number(e2[0]));\n\t\t\tfor (const [t, measure] of measure_entries) {\n\t\t\t\t//console.log(\"measure time:\", Number(t));\n\t\t\t\tmeasure.startTick = Number(t);\n\t\t\t\tmeasure.notes = [];\n\n\t\t\t\tif (last_measure)\n\t\t\t\t\tlast_measure.endTick = measure.startTick;\n\n\t\t\t\tconst m = measure.measure;\n\t\t\t\tmeasure_list[m] = measure_list[m] || [];\n\t\t\t\tmeasure_list[m].push(measure);\n\n\t\t\t\tlast_measure = measure;\n\t\t\t}\n\t\t\tif (last_measure)\n\t\t\t\tlast_measure.endTick = this.notes[this.notes.length - 1].endTick;\n\t\t\tfor (const i in this.notes) {\n\t\t\t\tconst note = this.notes[i];\n\t\t\t\tfor (const t in this.measures) {\n\t\t\t\t\tconst measure = this.measures[t];\n\t\t\t\t\tif (note.startTick >= measure.startTick && note.startTick < measure.endTick || note.endTick > measure.startTick && note.endTick <= measure.endTick)\n\t\t\t\t\t\tmeasure.notes.push(note);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.measure_list = measure_list;\n\t\t}*/\n\n\n\t\t// prepare beats info\n\t\tif (this.meta.beatInfos) {\n\t\t\tfor (let i = 0; i < this.meta.beatInfos.length; ++i) {\n\t\t\t\tconst info = this.meta.beatInfos[i];\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tconst lastInfo = this.meta.beatInfos[i - 1];\n\t\t\t\t\tinfo.beatIndex = lastInfo.beatIndex + Math.ceil((info.tick - lastInfo.tick) / this.ticksPerBeat);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tinfo.beatIndex = 0;\n\t\t\t}\n\t\t}\n\n\n\t\t// compute tempos tick -> time\n\t\t{\n\t\t\tlet time = 0;\n\t\t\tlet ticks = 0;\n\t\t\tlet tempo = 500000;\n\t\t\tfor (const entry of this.tempos) {\n\t\t\t\tconst deltaTicks = entry.tick - ticks;\n\t\t\t\ttime += (tempo / 1000) * deltaTicks / this.ticksPerBeat;\n\n\t\t\t\tticks = entry.tick;\n\t\t\t\ttempo = entry.tempo;\n\n\t\t\t\tentry.time = time;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tfindChordBySoftindex (softIndex, radius = 0.8) {\n\t\treturn this.notes.filter(note => Math.abs(note.softIndex - softIndex) < radius);\n\t}\n\n\n\taverageTempo (tickRange) {\n\t\ttickRange = tickRange || {from: 0, to: this.endtick};\n\n\t\tconsole.assert(this.tempos, \"no tempos.\");\n\t\tconsole.assert(tickRange.to > tickRange.from, \"range is invalid:\", tickRange);\n\n\t\tconst span = index => {\n\t\t\tconst from = Math.max(tickRange.from, this.tempos[index].tick);\n\t\t\tconst to = (index < this.tempos.length - 1) ? Math.min(this.tempos[index + 1].tick, tickRange.to) : tickRange.to;\n\n\t\t\treturn Math.max(0, to - from);\n\t\t};\n\n\t\tconst tempo_sum = this.tempos.reduce((sum, tempo, index) => sum + tempo.tempo * span(index), 0);\n\n\t\tconst average = tempo_sum / (tickRange.to - tickRange.from);\n\n\t\t// convert microseconds per beat to beats per minute\n\t\treturn 60e+6 / average;\n\t}\n\n\n\tticksToTime (tick) {\n\t\tconsole.assert(Number.isFinite(tick), \"invalid tick value:\", tick);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.tick > tick);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.time + (tick - tempo.tick) * tempo.tempo * 1e-3 / this.ticksPerBeat;\n\t}\n\n\n\ttimeToTicks (time) {\n\t\tconsole.assert(Number.isFinite(time), \"invalid time value:\", time);\n\t\tconsole.assert(this.tempos && this.tempos.length, \"no tempos.\");\n\n\t\tconst next_tempo_index = this.tempos.findIndex(tempo => tempo.time > time);\n\t\tconst tempo_index = next_tempo_index < 0 ? this.tempos.length - 1 : Math.max(next_tempo_index - 1, 0);\n\n\t\tconst tempo = this.tempos[tempo_index];\n\n\t\treturn tempo.tick + (time - tempo.time) * this.ticksPerBeat / (tempo.tempo * 1e-3);\n\t}\n\n\n\ttickRangeToTimeRange (tickRange) {\n\t\tconsole.assert(tickRange.to >= tickRange.from, \"invalid tick range:\", tickRange);\n\n\t\treturn {\n\t\t\tfrom: this.ticksToTime(tickRange.from),\n\t\t\tto: this.ticksToTime(tickRange.to),\n\t\t};\n\t}\n\n\n\t/*getMeasureRange (measureRange) {\n\t\tconsole.assert(Number.isInteger(measureRange.start) && Number.isInteger(measureRange.end), \"invalid measure range:\", measureRange);\n\t\tconsole.assert(this.measure_list && this.measure_list[measureRange.start] && this.measure_list[measureRange.end], \"no measure data for specific index:\", this.measure_list, measureRange);\n\n\t\tconst startMeasure = this.measure_list[measureRange.start][0];\n\t\tlet endMeasure = null;\n\t\tfor (const measure of this.measure_list[measureRange.end]) {\n\t\t\tif (measure.endTick > startMeasure.startTick) {\n\t\t\t\tendMeasure = measure;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// there no path between start measure and end measure.\n\t\tif (!endMeasure)\n\t\t\treturn null;\n\n\t\tconst tickRange = {from: startMeasure.startTick, to: endMeasure.endTick, duration: endMeasure.endTick - startMeasure.startTick};\n\t\tconst timeRange = this.tickRangeToTimeRange(tickRange);\n\t\ttimeRange.duration = timeRange.to - timeRange.from;\n\n\t\treturn {\n\t\t\ttickRange,\n\t\t\ttimeRange,\n\t\t};\n\t}*/\n\n\n\tscaleTempo ({factor, headTempo}) {\n\t\tconsole.assert(this.tempos && this.tempos.length, \"[Notation.scaleTempo] tempos is empty.\");\n\n\t\tif (headTempo)\n\t\t\tfactor = headTempo / this.tempos[0].tempo;\n\n\t\tconsole.assert(Number.isFinite(factor) && factor > 0, \"[Notation.scaleTempo] invalid factor:\", factor);\n\n\t\tthis.tempos.forEach(tempo => {\n\t\t\ttempo.tempo *= factor;\n\t\t\ttempo.time *= factor;\n\t\t});\n\t\tthis.events.forEach(event => {\n\t\t\tevent.deltaTime *= factor;\n\t\t\tevent.time *= factor;\n\t\t});\n\t\tthis.notes.forEach(note => {\n\t\t\tnote.start *= factor;\n\t\t\tnote.duration *= factor;\n\t\t});\n\n\t\tthis.endTime *= factor;\n\t}\n};\n\n\n\nmodule.exports = {\n\tNotation,\n};\n","\nconst { Notation } = require(\"./MusicNotation.js\");\n\n\n\n//const msDelay = ms => new Promise(resolve => setTimeout(resolve, ms));\nconst animationDelay = () => new Promise(resolve => requestAnimationFrame(resolve));\n\n\nclass MidiPlayer {\n\tconstructor (midiData, {cacheSpan = 600, onMidi, onPlayFinish, onTurnCursor} = {}) {\n\t\tthis.cacheSpan = cacheSpan;\n\t\tthis.onMidi = onMidi;\n\t\tthis.onPlayFinish = onPlayFinish;\n\t\tthis.onTurnCursor = onTurnCursor;\n\n\t\tlet notation;\n\t\tif (midiData.notes && Number.isFinite(midiData.endTime))\n\t\t\tnotation = midiData;\n\t\telse\n\t\t\tnotation = Notation.parseMidi(midiData);\n\n\t\tthis.notation = notation;\n\t\tthis.events = notation.events;\n\t\t//console.log(\"events:\", this.events);\n\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t\tthis.startTime = performance.now();\n\t\tthis.duration = notation.endTime;\n\t\tthis.cursorTurnDelta = 0;\n\n\t\tconsole.assert(notation.tempos && notation.tempos.length, \"[MidiPlayer] invalid notation, tempos is empty.\");\n\t}\n\n\n\tdispose () {\n\t\tthis.isPlaying = false;\n\t\tthis.progressTime = 0;\n\t}\n\n\n\tget progressTicks () {\n\t\treturn this.notation.timeToTicks(this.progressTime);\n\t}\n\n\n\tset progressTicks (value) {\n\t\tthis.progressTime = this.notation.ticksToTime(value);\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(this.progressTime);\n\t}\n\n\n\tasync play ({nextFrame = animationDelay} = {}) {\n\t\tif (this.progressTime >= this.duration)\n\t\t\tthis.progressTime = 0;\n\n\t\tlet now = performance.now();\n\t\tthis.startTime = now - this.progressTime;\n\n\t\tthis.isPlaying = true;\n\n\t\tlet currentEventIndex = this.events.findIndex(event => event.time >= now - this.startTime);\n\n\t\twhile (this.isPlaying) {\n\t\t\tfor (; currentEventIndex < this.events.length; ++currentEventIndex) {\n\t\t\t\tconst event = this.events[currentEventIndex];\n\t\t\t\t//console.log(\"play event:\", currentEventIndex, event.time, this.progressTime + this.cacheSpan);\n\t\t\t\tif (!event || event.time > this.progressTime + this.cacheSpan)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif (event.data.type === \"channel\" && this.startTime + event.time >= now)\n\t\t\t\t\tif (this.onMidi)\n\t\t\t\t\t\tthis.onMidi(event.data, this.startTime + event.time);\n\t\t\t}\n\n\t\t\tawait nextFrame();\n\n\t\t\tif (!this.isPlaying)\n\t\t\t\tbreak;\n\n\t\t\tif (this.cursorTurnDelta !== 0) {\n\t\t\t\tconst backturn = this.cursorTurnDelta < 0;\n\n\t\t\t\tthis.startTime -= this.cursorTurnDelta;\n\t\t\t\tthis.cursorTurnDelta = 0;\n\n\t\t\t\tif (backturn) {\n\t\t\t\t\tfor (; currentEventIndex > 0; --currentEventIndex) {\n\t\t\t\t\t\tconst eventTime = this.events[currentEventIndex].time;\n\t\t\t\t\t\tif (this.startTime + eventTime < now)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnow = performance.now();\n\n\t\t\tthis.progressTime = now - this.startTime;\n\n\t\t\tif (this.progressTime > this.duration) {\n\t\t\t\tthis.isPlaying = false;\n\n\t\t\t\tif (this.onPlayFinish)\n\t\t\t\t\tthis.onPlayFinish();\n\t\t\t}\n\t\t}\n\t}\n\n\n\tpause () {\n\t\tthis.isPlaying = false;\n\t}\n\n\n\tturnCursor (time) {\n\t\t//console.log(\"onTurnCursor:\", time, oldTime);\n\t\tif (this.isPlaying)\n\t\t\tthis.cursorTurnDelta += time - this.progressTime;\n\t\telse\n\t\t\tthis.progressTime = time;\n\n\t\tif (this.onTurnCursor)\n\t\t\tthis.onTurnCursor(time);\n\t}\n};\n\n\n\nmodule.exports = MidiPlayer;\n","\nmodule.exports = {\n\tCostStepAttenuation: 0.6,\n\tSkipDeep: 3,\n\tPriorDistanceSigmoidFactor: 0.1,\n\tPriorValueSigmoidFactor: 0.12,\n\n\tSkipCost: 0.5,\n\tLagOffsetCost: 1,\n\tLeadOffsetCost: 1.6,\n\tZeroOffsetCost: 0.58,\n\n\tRelocationThreshold: 6,\n};\n","\nconst {pick} = require(\"lodash\");\n\nconst Config = require(\"./config.js\");\n\n\n\nclass Node {\n\tconstructor (s_note, c_note) {\n\t\tthis.s_note = s_note;\n\t\tthis.c_note = c_note;\n\n\t\tconsole.assert(this.s_note.softIndex != null, \"s_note softIndex is null\");\n\t\tthis.offset = this.s_note.softIndex - this.c_note.softIndex;\n\n\t\tthis._prev = null;\n\t\tthis._totalCost = 0;\n\t\tthis._value = 0;\n\t\tthis.cacheDirty = true;\n\n\t\t//this.evaluatePrev(Node.Zero);\n\t}\n\n\n\tget prev () {\n\t\treturn this._prev;\n\t}\n\n\n\tset prev (value) {\n\t\tif (value != this._prev) {\n\t\t\tthis._prev = value;\n\t\t\tthis.cacheDirty = true;\n\t\t}\n\t}\n\n\n\tget si () {\n\t\treturn this.s_note.index;\n\t}\n\n\n\tget ci () {\n\t\treturn this.c_note.index;\n\t}\n\n\n\tget root () {\n\t\treturn this.prev.root || this;\n\t}\n\n\n\tget rootSi () {\n\t\treturn !this.prev.zero ? this.prev.rootSi : this.si;\n\t}\n\n\n\tget id () {\n\t\treturn `${this.s_note.index},${this.c_note.index}`;\n\t}\n\n\n\tstatic cost (prev, skip, self) {\n\t\treturn prev * Config.CostStepAttenuation + Math.tanh(skip * Config.SkipCost) + Math.tanh(self * 0.5);\n\t}\n\n\n\tupdateCache () {\n\t\tif (this.cacheDirty) {\n\t\t\tthis._totalCost = Node.cost(this.prev.totalCost, this.si - this.prev.si - 1, this.selfCost);\n\t\t\tthis._value = this.prev.value + 1 - Math.tanh(this.selfCost * 0.5);\n\n\t\t\tthis.cacheDirty = false;\n\t\t}\n\t}\n\n\n\tget totalCost () {\n\t\tthis.updateCache();\n\n\t\treturn this._totalCost;\n\t}\n\n\n\tget value () {\n\t\tthis.updateCache();\n\n\t\treturn this._value;\n\t}\n\n\n\tget deep () {\n\t\treturn this.prev.deep + 1;\n\t}\n\n\n\tget path () {\n\t\tconst path = [];\n\t\tfor (let node = this; !node.zero; node = node.prev) {\n\t\t\tpath[node.si] = node.ci;\n\t\t}\n\n\t\tfor (let i = 0; i < path.length; ++i)\n\t\t\tif (typeof path[i] != \"number\")\n\t\t\t\tpath[i] = -1;\n\n\t\treturn path;\n\t}\n\n\n\tdump () {\n\t\treturn pick(this, [\"id\", \"si\", \"ci\", \"rootSi\", \"value\", \"deep\", \"rootSi\", \"offset\", \"prior\", \"selfCost\", \"totalCost\"]);\n\t}\n\n\n\tevaluatePrev (node) {\n\t\tconst cost = this.evaluatePrevCost(node);\n\n\t\tconsole.assert(this.si - node.si >= 1, \"node index error:\", this, node/*, {get [Symbol.toStringTag]() {debugger}}*/);\n\t\t//if (this.si - node.si < 1)\n\t\t//\tdebugger;\n\n\t\tconst totalCost = Node.cost(node.totalCost, this.si - node.si - 1, cost);\n\n\t\tif (!this.prev || totalCost < this.totalCost) {\n\t\t\tthis.prev = node;\n\t\t\tthis.selfCost = cost;\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tevaluatePrevCost (node) {\n\t\tlet cost = 0;\n\n\t\tif (node.offset != null) {\n\t\t\tconst bias = this.offset - node.offset;\n\t\t\tconst costCoeff = node.zero ? Config.ZeroOffsetCost : (bias > 0 ? Config.LagOffsetCost : Config.LeadOffsetCost);\n\t\t\tcost += (bias * costCoeff) ** 2;\n\t\t}\n\n\t\treturn cost;\n\t}\n\n\n\tpriorByOffset (offset) {\n\t\tconst distance = Math.abs(this.offset - offset) / 1;//(this.s_note.deltaSi + 0.04);\n\n\t\treturn Math.tanh(this.value * Config.PriorValueSigmoidFactor) - Math.tanh(distance * Config.PriorDistanceSigmoidFactor);\n\t\t//return Math.log(this.value) * Math.tanh(4 / distance);\n\t\t//return this.value - distance;\n\t}\n\n\n\tstatic zero () {\n\t\treturn {\n\t\t\tzero: true,\n\t\t\ttotalCost: 0,\n\t\t\tvalue: 0,\n\t\t\tsi: -1,\n\t\t\tci: -1,\n\t\t\tdeep: 0,\n\t\t\toffset: 0,\n\t\t};\n\t}\n};\n\n\n\nmodule.exports = Node;\n","\nconst Config = require(\"./config.js\");\nconst Node = require(\"./node.js\");\n\n\n\nclass Navigator {\n\tconstructor (criterion, sample, options = {}) {\n\t\tthis.criterion = criterion;\n\t\tthis.sample = sample;\n\n\t\tthis.getCursorOffset = options.getCursorOffset || (() => null);\n\t\tthis.outOfPage = options.outOfPage;\n\n\t\tthis.bestNode = null;\n\t\tthis.fineCursor = null;\n\n\t\tthis.breakingSI = sample.notes.length - 1;\n\n\t\tthis.zeroNode = Node.zero();\n\t\tthis.zeroNode.offset = this.getCursorOffset() || 0;\n\n\t\tthis.relocationThreshold = options.relocationThreshold || Config.RelocationThreshold;\n\t}\n\n\n\tstep (index) {\n\t\t//console.log(\"step:\", this.zeroNode.offset);\n\t\tconst note = this.sample.notes[index];\n\n\t\tif (note.matches.length > 0) {\n\t\t\t//console.log(\"zeroNode.offset:\", index, this.zeroNode.offset);\n\t\t\tnote.matches.forEach(node => {\n\t\t\t\tnode.evaluatePrev(this.zeroNode);\n\t\t\t\t//console.log(\"node:\", node, node.evaluatePrevCost(this.zeroNode), node.offset, this.zeroNode.offset);\n\n\t\t\t\tfor (let si = index - 1; si >= Math.max(this.breakingSI + 1, index - Config.SkipDeep); --si) {\n\t\t\t\t\t//const skipCost = Config.SkipCost * (index - 1 - si);\n\n\t\t\t\t\tconst prevNote = this.sample.notes[si];\n\t\t\t\t\tconsole.assert(prevNote, \"prevNote is null:\", si, index, this.sample.notes);\n\t\t\t\t\tprevNote.matches.forEach(prevNode => {\n\t\t\t\t\t\tconst bias = node.offset - prevNode.offset;\n\t\t\t\t\t\tif (/*prevNode.totalCost + skipCost < node.totalCost\n\t\t\t\t\t\t\t&&*/ (bias < 2 / Config.LagOffsetCost && bias > -2 / Config.LeadOffsetCost))\n\t\t\t\t\t\t\tnode.evaluatePrev(prevNode);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tnode.prior = node.totalCost > 1.99 ? -1 : node.priorByOffset(this.zeroNode.offset);\n\n\t\t\t\tif (node.prior > 0 && this.outOfPage) {\n\t\t\t\t\tconst tick = this.criterion.notes[node.ci].startTick;\n\t\t\t\t\tif (this.outOfPage(tick))\n\t\t\t\t\t\tnode.prior -= 0.7;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tnote.matches.sort((c1, c2) => c2.prior - c1.prior);\n\t\t\tthis.cursors = note.matches;\n\t\t\t//console.log(\"navigator cursors:\", this.cursors);\n\n\t\t\tlet fineCursor = null;\n\t\t\tconst nullLength = this.nullSteps(index);\n\n\t\t\tconst cursor = this.cursors[0];\n\t\t\tif (cursor && cursor.totalCost < 1) {\n\t\t\t\t//console.log(\"nullLength:\", nullLength, nullLength * Math.log(cursor.value / 4));\n\t\t\t\tif (cursor.prior > 0 || (cursor.totalCost < 0.4 && Math.log(Math.max(nullLength * cursor.value, 1e-3)) > this.relocationThreshold)) {\n\t\t\t\t\tthis.zeroNode.offset = cursor.offset;\n\n\t\t\t\t\tfineCursor = cursor;\n\n\t\t\t\t\tif (!this.bestNode || cursor.value > this.bestNode.value)\n\t\t\t\t\t\tthis.bestNode = cursor;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fineCursor)\n\t\t\t\tthis.fineCursor = fineCursor;\n\t\t\telse {\n\t\t\t\tif (!this.resetCursor(index, {breaking: false/*nullLength > Config.SkipDeep*/})) {\n\t\t\t\t\tthis.zeroNode.offset += note.deltaSi * Math.tanh(nullLength);\n\t\t\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", note.deltaSi, nullLength);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tthis.cursors = [];\n\t}\n\n\n\tpath ({fromIndex = 0, toIndex = this.sample.notes.length - 1} = {}) {\n\t\tconst path = [];\n\n\t\tlet offset = null;\n\n\t\tfor (let si = toIndex; si >= fromIndex;) {\n\t\t\tconst note = this.sample.notes[si];\n\n\t\t\tif (!note.matches.length || note.matches[0].prior < -0.01 || note.matches[0].totalCost >= 1) {\n\t\t\t\t//if (note.matches.length)\n\t\t\t\t//\tconsole.log(\"path -1:\", si, note.matches[0].prior, note.matches[0].totalCost);\n\t\t\t\tpath[si] = -1;\n\t\t\t\t--si;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// sort nodes by backwards heuristic offset\n\t\t\tif (offset != null) {\n\t\t\t\tnote.matches.forEach(node => node.backPrior = (node.totalCost < 1.99 ? node.priorByOffset(offset) : -1));\n\t\t\t\tnote.matches.sort((n1, n2) => n2.backPrior - n1.backPrior);\n\t\t\t}\n\n\t\t\tconst node = note.matches[0];\n\t\t\tnode.path.forEach((ci, si) => path[si] = ci);\n\t\t\t//console.log(\"node path:\", si, node.path);\n\n\t\t\toffset = node.root.offset;\n\n\t\t\tsi = node.rootSi - 1;\n\t\t}\n\n\t\tconsole.assert(path.length == toIndex + 1, \"path length error:\", path, fromIndex, toIndex + 1,\n\t\t\tthis.sample.notes.length, this.sample.notes.length ? this.sample.notes[this.sample.notes.length - 1].index : null);\n\n\t\treturn path;\n\t}\n\n\n\tnullSteps (index) {\n\t\treturn index - (this.fineCursor ? this.fineCursor.si : -1) - 1;\n\t}\n\n\n\tresetCursor (index, {breaking = true} = {}) {\n\t\tif (breaking)\n\t\t\tthis.breakingSI = index;\n\n\t\tconst cursorOffset = this.getCursorOffset();\n\t\tif (cursorOffset != null) {\n\t\t\t//console.log(\"cursorOffset:\", cursorOffset);\n\n\t\t\tthis.zeroNode.offset = cursorOffset;\n\t\t\t//this.breaking = this.nullSteps(index) > Config.SkipDeep;\n\t\t\t//if (this.breaking)\t// trivial zero node si resets result in focus path interruption\n\t\t\tthis.zeroNode.si = index;\n\t\t\tthis.fineCursor = null;\n\n\t\t\tconsole.assert(!Number.isNaN(this.zeroNode.offset), \"zeroNode.offset is NaN.\", cursorOffset);\n\t\t\t//console.log(\"cursor offset reset:\", cursorOffset);\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\n\tget relocationTendency () {\n\t\tconst cursor = this.cursors && this.cursors[0];\n\t\tif (!cursor)\n\t\t\treturn null;\n\n\t\tconst nullLength = this.nullSteps(cursor.si);\n\t\tif (nullLength <= 0)\n\t\t\treturn 0;\n\n\t\treturn Math.log(Math.max(nullLength * cursor.value, 1e-3)) / this.relocationThreshold;\n\t}\n};\n\n\n\nmodule.exports = Navigator;\n","\nconst Node = require(\"./node.js\");\nconst Navigator = require(\"./navigator.js\");\n\n\n\nconst HEART_BEAT = 800;\t// in ms\nconst SIMULTANEOUS_INTERVAL = HEART_BEAT * 0.24;\n\n\nconst normalizeInterval = interval => Math.tanh(interval / SIMULTANEOUS_INTERVAL);\n\n\n// greater softIndexFactor make 'harder' soft index\nconst makeNoteSoftIndex = function (notes, index, {softIndexFactor = 1} = {}) {\n\tindex = Number(index);\n\n\tconst note = notes[index];\n\n\t// make soft index\n\tif (index > 0) {\n\t\tconst lastNote = notes[index - 1];\n\n\t\tconsole.assert(note.start != null, \"note.start is null\", note);\n\t\tconsole.assert(lastNote.start != null, \"lastNote.start is null\", lastNote);\n\n\t\tnote.deltaSi = normalizeInterval((note.start - lastNote.start) * softIndexFactor);\n\t\tnote.softIndex = lastNote.softIndex + note.deltaSi;\n\n\t\tconsole.assert(!Number.isNaN(note.deltaSi), \"note.deltaSi is NaN.\", note.start, lastNote.start);\n\t}\n\telse {\n\t\tnote.softIndex = 0;\n\t\tnote.deltaSi = 0;\n\t}\n};\n\n\nconst makeMatchNodes = function (note, criterion, zeroNode = Node.zero()) {\n\tnote.matches = [];\n\n\tconst targetList = criterion.pitchMap[note.pitch];\n\tif (targetList) {\n\t\tfor (const targetNote of targetList) {\n\t\t\tconst node = new Node(note, targetNote);\n\t\t\tif (zeroNode)\n\t\t\t\tnode.evaluatePrev(zeroNode);\n\n\t\t\tnote.matches.push(node);\n\t\t}\n\t}\n};\n\n\nconst genNotationContext = function (notation, {softIndexFactor = 1} = {}) {\n\tfor (let i = 0; i < notation.notes.length; ++i)\n\t\tmakeNoteSoftIndex(notation.notes, i, {softIndexFactor});\n};\n\n\nconst runNavigation = async function(criterion, sample, onStep) {\n\tconst navigator = new Navigator(criterion, sample);\n\tnavigator.resetCursor(-1);\n\n\tfor (let i = 0; i < sample.notes.length; ++i) {\n\t\tnavigator.step(i);\n\n\t\tconst next = await (onStep && onStep(i, navigator));\n\t\tif (next === Symbol.for(\"end\")) {\n\t\t\tconsole.log(\"Navigation interrupted.\");\n\n\t\t\treturn;\n\t\t}\n\t}\n\n\t//console.log(\"Navigation accomplished.\");\n\n\treturn navigator;\n};\n\n\n\nmodule.exports = {\n\tnormalizeInterval,\n\tmakeNoteSoftIndex,\n\tmakeMatchNodes,\n\tgenNotationContext,\n\trunNavigation,\n\tNavigator,\n\tNode,\n};\n","\nconst MIDI = require(\"./MIDI\");\n\n\n\nconst trackDeltaToAbs = events => {\n\tlet tick = 0;\n\n\tevents.forEach(event => {\n\t\ttick += event.deltaTime;\n\t\tevent.tick = tick;\n\t});\n};\n\n\nconst trackAbsToDelta = events => {\n\tlet lastTick = 0;\n\n\tevents.sort((e1, e2) => e1.tick - e2.tick).forEach(event => {\n\t\tevent.deltaTime = event.tick - lastTick;\n\t\tlastTick = event.tick;\n\t});\n};\n\n\nconst sliceTrack = (track, startTick, endTick) => {\n\ttrackDeltaToAbs(track);\n\n\tconst events = [];\n\tconst status = {};\n\n\ttrack.forEach(event => {\n\t\tif (event.tick >= startTick && event.tick <= endTick && event.subtype !== \"endOfTrack\")\n\t\t\tevents.push({\n\t\t\t\t...event,\n\t\t\t\ttick: event.tick - startTick,\n\t\t\t});\n\t\telse if (event.tick < startTick) {\n\t\t\tswitch (event.type) {\n\t\t\tcase \"meta\":\n\t\t\t\tstatus[event.subtype] = event;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t});\n\n\tObject.values(status).forEach(event => events.push({\n\t\t...event,\n\t\ttick: 0,\n\t}));\n\n\tevents.push({\n\t\ttick: endTick - startTick,\n\t\ttype: \"meta\",\n\t\tsubtype: \"endOfTrack\",\n\t});\n\n\ttrackAbsToDelta(events);\n\n\treturn events;\n};\n\n\nconst sliceMidi = (midi, startTick, endTick) => ({\n\theader: midi.header,\n\ttracks: midi.tracks.map(track => sliceTrack(track, startTick, endTick)),\n});\n\n\nconst TICKS_PER_BEATS = 480;\n\nconst EXCLUDE_MIDI_EVENT_SUBTYPES = [\n\t\"endOfTrack\", \"trackName\",\n\t\"noteOn\", \"noteOff\",\n];\n\n\nfunction encodeToMIDIData(notation, {startTime, unclosedNoteDuration = 30e+3} = {}) {\n\tnotation.microsecondsPerBeat = notation.microsecondsPerBeat || 500000;\n\n\tconst ticksPerBeat = TICKS_PER_BEATS;\n\tconst msToTicks = ticksPerBeat * 1000 / notation.microsecondsPerBeat;\n\n\tconst header = { formatType: 0, ticksPerBeat };\n\tconst track = [];\n\n\tif (!Number.isFinite(startTime)) {\n\t\tif (!notation.notes || !notation.notes[0])\n\t\t\tthrow new Error(\"encodeToMidiData: no start time specificed\");\n\n\t\tstartTime = notation.notes[0].start;\n\t}\n\n\ttrack.push({ time: startTime, type: \"meta\", subtype: \"copyrightNotice\", text: `Composed by MusicWdigets. BUILT on ${new Date(Number(process.env.VUE_APP_BUILD_TIME)).toDateString()}` });\n\n\tconst containsTempo = notation.events && notation.events.find(event => event.subtype == \"setTempo\");\n\tif (!containsTempo) {\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"timeSignature\", numerator: 4, denominator: 4, thirtyseconds: 8 });\n\t\ttrack.push({ time: startTime, type: \"meta\", subtype: \"setTempo\", microsecondsPerBeat: notation.microsecondsPerBeat });\n\t}\n\n\t//if (notation.correspondences)\n\t//\ttrack.push({ time: startTime, type: \"meta\", subtype: \"text\", text: \"find-corres:\" + notation.correspondences.join(\",\") });\n\n\tlet endTime = startTime || 0;\n\n\tif (notation.notes) {\n\t\tfor (const note of notation.notes) {\n\t\t\ttrack.push({\n\t\t\t\ttime: note.start,\n\t\t\t\ttype: \"channel\",\n\t\t\t\tsubtype: \"noteOn\",\n\t\t\t\tchannel: note.channel || 0,\n\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\tvelocity: note.velocity,\n\t\t\t\tfinger: note.finger,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, note.start);\n\n\t\t\tif (Number.isFinite(unclosedNoteDuration))\n\t\t\t\tnote.duration = note.duration || unclosedNoteDuration;\n\t\t\tif (note.duration) {\n\t\t\t\ttrack.push({\n\t\t\t\t\ttime: note.start + note.duration,\n\t\t\t\t\ttype: \"channel\",\n\t\t\t\t\tsubtype: \"noteOff\",\n\t\t\t\t\tchannel: note.channel || 0,\n\t\t\t\t\tnoteNumber: note.pitch,\n\t\t\t\t\tvelocity: 0,\n\t\t\t\t});\n\n\t\t\t\tendTime = Math.max(endTime, note.start + note.duration);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (notation.events) {\n\t\tconst events = notation.events.filter(event => !EXCLUDE_MIDI_EVENT_SUBTYPES.includes(event.data.subtype));\n\t\tfor (const event of events) {\n\t\t\ttrack.push({\n\t\t\t\ttime: event.time,\n\t\t\t\t...event.data,\n\t\t\t});\n\n\t\t\tendTime = Math.max(endTime, event.time);\n\t\t}\n\t}\n\n\ttrack.push({ time: endTime + 100, type: \"meta\", subtype: \"endOfTrack\" });\n\n\ttrack.sort(function (e1, e2) { return e1.time - e2.time; });\n\n\t// append finger event after every noteOn event\n\ttrack.map((event, index) => ({event, index}))\n\t\t.filter(({event}) => event.subtype == \"noteOn\" && event.finger != null)\n\t\t.reverse()\n\t\t.forEach(({event, index}) => track.splice(index + 1, 0, {\n\t\t\ttime: event.time,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `fingering(${event.finger})`,\n\t\t}));\n\n\ttrack.forEach(event => event.ticks = Math.round((event.time - startTime) * msToTicks));\n\ttrack.forEach((event, i) => event.deltaTime = (event.ticks - (i > 0 ? track[i - 1].ticks : 0)));\n\n\treturn {header, tracks: [track]};\n};\n\n\nfunction encodeToMIDI(notation, options) {\n\tconst data = encodeToMIDIData(notation, options);\n\treturn MIDI.encodeMidiFile(data);\n};\n\n\n\nmodule.exports = {\n\tsliceMidi,\n\tencodeToMIDIData,\n\tencodeToMIDI,\n};\n","\nconst MIDI = require(\"./source/inc/MIDI\");\nconst MusicNotation = require(\"./source/inc/MusicNotation\");\nconst MidiPlayer = require(\"./source/inc/MidiPlayer.js\");\nconst Matcher = require(\"./source/inc/Matcher\");\nconst MidiUtils = require(\"./source/inc/MidiUtils.js\");\n\n\n\nmodule.exports = {\n\tMIDI,\n\tMusicNotation,\n\tMidiPlayer,\n\tMatcher,\n\tMidiUtils,\n};\n","import pick from 'lodash/pick';\n\nimport { MusicNotation, MIDI } from '@k-l-lambda/music-widgets';\n\n//import {MeasureLayout, LayoutType} from\nimport { ImplicitType, ChordPosition } from './types';\n\nconst WHOLE_DURATION_MAGNITUDE = 1920;\nconst TICKS_PER_BEAT = WHOLE_DURATION_MAGNITUDE / 4;\n\ninterface Fraction {\n\tnumerator: number;\n\tdenominator: number;\n}\n\ninterface StaffNoteProperties {\n\trest: boolean;\n\ttied: boolean;\n\toverlapped: boolean;\n\timplicitType: ImplicitType;\n\tafterGrace: boolean;\n\tchordPosition: ChordPosition;\n\tdivision: number;\n\n\tcontextIndex: number;\n\tstaffTrack: number;\n}\n\ninterface MetaNote extends MusicNotation.Note, Partial {\n\tid: string;\n\tmeasure: number;\n\tendTick: number;\n}\n\ninterface SubNote {\n\tstartTick: number;\n\tendTick: number;\n\tpitch: number;\n\tvelocity?: number;\n}\n\ninterface MeasureNote extends Partial {\n\ttick: number;\n\tpitch: number;\n\tduration: number;\n\tchordPosition: ChordPosition;\n\tstaff: number;\n\n\ttrack: number;\n\tchannel: number;\n\tid: string;\n\tids: string[];\n\n\tsubNotes: SubNote[];\n}\n\ninterface MeasureEvent {\n\tdata: any;\n\ttrack: number;\n\tticks?: number;\n}\n\ninterface Measure {\n\ttick: number;\n\tduration: number;\n\n\tnotes: MeasureNote[];\n\tevents?: MeasureEvent[];\n\ttimeSignature?: Fraction;\n\tkeySignature?: number;\n}\n\ninterface PerformOptions {\n\twithRestTied?: boolean;\n}\n\ninterface MidiEvent extends MIDI.MidiEvent {\n\tticks?: number;\n\tmeasure?: number;\n\tids?: string[];\n\tstaffTrack?: number;\n\tstaff?: number;\n}\ntype MidiTrack = MidiEvent[];\n\nconst EXTRA_NOTE_FIELDS = ['rest', 'tied', 'overlapped', 'implicitType', 'afterGrace', 'contextIndex', 'staffTrack', 'chordPosition', 'division'];\nconst COMMON_NOTE_FIELDS = ['id', 'ids', 'pitch', 'velocity', 'track', 'channel', ...EXTRA_NOTE_FIELDS];\n\nclass MetaNotation {\n\t//pitchContextGroup: PitchContextTable[];\n\t//measureLayout: MeasureLayout;\n\tmeasures: Measure[];\n\n\ttrackNames: string[];\n\tidTrackMap: { [key: string]: number };\n\n\tripe: boolean = false;\n\n\tstatic fromAbsoluteNotes(notes: MetaNote[], measureHeads: number[], data?: Partial): MetaNotation {\n\t\tconst notation = new MetaNotation(data);\n\n\t\tnotation.measures = Array(measureHeads.length)\n\t\t\t.fill(null)\n\t\t\t.map((__, i) => {\n\t\t\t\tconst tick = measureHeads[i];\n\t\t\t\tconst duration = measureHeads[i + 1] ? measureHeads[i + 1] - tick : 0;\n\n\t\t\t\tconst mnotes = notes\n\t\t\t\t\t.filter((note) => note.measure === i + 1)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(note) =>\n\t\t\t\t\t\t\t({\n\t\t\t\t\t\t\t\ttick: note.startTick - tick,\n\t\t\t\t\t\t\t\tduration: note.endTick - note.startTick,\n\t\t\t\t\t\t\t\t...pick(note, COMMON_NOTE_FIELDS),\n\t\t\t\t\t\t\t\tsubNotes: [],\n\t\t\t\t\t\t\t} as MeasureNote)\n\t\t\t\t\t);\n\n\t\t\t\t// reduce note data size\n\t\t\t\tmnotes.forEach((mn) =>\n\t\t\t\t\t['rest', 'tied', 'implicitType', 'afterGrace'].forEach((field) => {\n\t\t\t\t\t\tif (!mn[field]) delete mn[field];\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes: mnotes,\n\t\t\t\t};\n\t\t\t});\n\n\t\tnotation.idTrackMap = notes.reduce((map, note) => {\n\t\t\tif (note.id) map[note.id] = note.track;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn notation;\n\t}\n\n\tstatic performAbsoluteNotes(abNotes: MetaNote[], { withRestTied = false }: PerformOptions = {}): MusicNotation.Note[] {\n\t\tconst notes = abNotes\n\t\t\t.filter((note) => (withRestTied || (!note.rest && !note.tied)) && !note.overlapped)\n\t\t\t.map((note) => ({\n\t\t\t\tmeasure: note.measure,\n\t\t\t\tchannel: note.channel,\n\t\t\t\ttrack: note.track,\n\t\t\t\tstart: note.start,\n\t\t\t\tstartTick: note.startTick,\n\t\t\t\tendTick: note.endTick,\n\t\t\t\tpitch: note.pitch,\n\t\t\t\tduration: note.duration,\n\t\t\t\tvelocity: note.velocity || 127,\n\t\t\t\tid: note.id,\n\t\t\t\tids: note.ids,\n\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\tcontextIndex: note.contextIndex,\n\t\t\t\timplicitType: note.implicitType,\n\t\t\t\tchordPosition: note.chordPosition,\n\t\t\t}));\n\n\t\tconst noteMap = notes.reduce((map, note) => {\n\t\t\tconst key = `${note.channel}|${note.start}|${note.pitch}`;\n\t\t\tconst priorNote = map[key];\n\t\t\tif (priorNote) priorNote.ids.push(...note.ids);\n\t\t\telse map[key] = note;\n\n\t\t\treturn map;\n\t\t}, {});\n\n\t\treturn Object.values(noteMap);\n\t}\n\n\tconstructor(data?: Partial) {\n\t\tif (data) Object.assign(this, data);\n\t}\n\n\t/*get ordinaryMeasureIndices (): number[] {\n\t\tif (this.measureLayout)\n\t\t\treturn this.measureLayout.serialize(LayoutType.Ordinary);\n\n\t\treturn Array(this.measures.length).fill(null).map((_, i) => i + 1);\n\t}*/\n\n\t// In Lilypond 2.20.0, minus tick value at the head of a track result in MIDI event time bias,\n\t//\tSo store the bias values to correct MIDI time from lilyond.\n\tget trackTickBias(): { [key: string]: number } {\n\t\tconst headMeasure = this.measures[0];\n\t\treturn this.trackNames.reduce((map, name, track) => {\n\t\t\tmap[name] = 0;\n\t\t\tif (headMeasure) {\n\t\t\t\tconst note = headMeasure.notes.find((note) => note.track === track);\n\t\t\t\tif (note) map[name] = Math.min(note.tick, 0);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget idSet(): Set {\n\t\treturn this.measures.reduce(\n\t\t\t(set, measure) => (measure.notes.filter((note) => !note.rest).forEach((note) => note.ids.forEach((id) => set.add(id))), set),\n\t\t\tnew Set()\n\t\t);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\t__prototype: 'LilyNotation',\n\t\t\t//pitchContextGroup: this.pitchContextGroup,\n\t\t\t//measureLayout: this.measureLayout,\n\t\t\tmeasures: this.measures,\n\t\t\tidTrackMap: this.idTrackMap,\n\t\t\ttrackNames: this.trackNames,\n\t\t\tripe: this.ripe,\n\t\t};\n\t}\n\n\ttoAbsoluteNotes(measureIndices: number[] /*= this.ordinaryMeasureIndices*/): MetaNote[] {\n\t\tlet measureTick = 0;\n\t\tconst measureNotes: MetaNote[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst notes = measure.notes.map((mnote) => {\n\t\t\t\treturn {\n\t\t\t\t\tstartTick: measureTick + mnote.tick,\n\t\t\t\t\tendTick: measureTick + mnote.tick + mnote.duration,\n\t\t\t\t\tstart: measureTick + mnote.tick,\n\t\t\t\t\tduration: mnote.duration,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t\t...pick(mnote, COMMON_NOTE_FIELDS),\n\t\t\t\t} as MetaNote;\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn notes;\n\t\t});\n\n\t\treturn [].concat(...measureNotes);\n\t}\n\n\t/*getMeasureIndices (type: LayoutType) {\n\t\treturn this.measureLayout.serialize(type);\n\t}*/\n\n\ttoPerformingNotation(measureIndices: number[] /*= this.ordinaryMeasureIndices*/, options: PerformOptions = {}): MusicNotation.Notation {\n\t\t//console.debug(\"toPerformingNotation:\", this, measureIndices);\n\t\tconst abNotes = this.toAbsoluteNotes(measureIndices);\n\t\tconst notes = MetaNotation.performAbsoluteNotes(abNotes, options);\n\n\t\t//const lastNote = notes[notes.length - 1];\n\t\tconst endTime = Math.max(...notes.map((note) => note.start + note.duration));\n\n\t\tconst endTick = measureIndices.reduce((tick, index) => tick + this.measures[index - 1].duration, 0);\n\n\t\tconst notation = new MusicNotation.Notation({\n\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\tmeta: {},\n\t\t\ttempos: [], // TODO\n\t\t\tchannels: [notes],\n\t\t\tendTime,\n\t\t\tendTick,\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\ttoPerformingMIDI(measureIndices: number[], { trackList }: { trackList?: boolean[] } = {}): MIDI.MidiData & { zeroTick: number } {\n\t\tif (!measureIndices.length) return null;\n\n\t\t// to avoid begin minus tick\n\t\tconst zeroTick = -Math.min(0, ...(this.measures[0]?.events.map((e) => e.ticks) || []), ...(this.measures[0]?.notes.map((note) => note.tick) || []));\n\n\t\tlet measureTick = zeroTick;\n\t\tconst measureEvents: MeasureEvent[][] = measureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\n\t\t\tconst events = measure.events.map((mevent) => ({\n\t\t\t\tticks: measureTick + mevent.ticks,\n\t\t\t\ttrack: mevent.track,\n\t\t\t\tdata: {\n\t\t\t\t\t...mevent.data,\n\t\t\t\t\tmeasure: index,\n\t\t\t\t},\n\t\t\t}));\n\n\t\t\tmeasureTick += measure.duration;\n\n\t\t\treturn events;\n\t\t});\n\n\t\tconst eventPriority = (event: MidiEvent): number => event.ticks + (event.subtype === 'noteOff' ? -1e-8 : 0);\n\n\t\tconst tracks: MidiTrack[] = [].concat(...measureEvents).reduce((tracks, mevent) => {\n\t\t\ttracks[mevent.track] = tracks[mevent.track] || [];\n\t\t\ttracks[mevent.track].push({\n\t\t\t\tticks: mevent.ticks,\n\t\t\t\t...mevent.data,\n\t\t\t});\n\n\t\t\treturn tracks;\n\t\t}, []);\n\n\t\ttracks[0] = tracks[0] || [];\n\t\t/*tracks[0].push({\n\t\t\tticks: 0,\n\t\t\ttype: \"meta\",\n\t\t\tsubtype: \"text\",\n\t\t\ttext: `${npmPackage.name} ${npmPackage.version}`,\n\t\t});*/\n\n\t\t// append note events\n\t\tmeasureTick = zeroTick;\n\t\tmeasureIndices.map((index) => {\n\t\t\tconst measure = this.measures[index - 1];\n\t\t\tconsole.assert(!!measure, 'invalid measure index:', index, this.measures.length);\n\t\t\tif (!Number.isFinite(measure.duration)) return;\n\n\t\t\tmeasure.notes.forEach((note) => {\n\t\t\t\tif (trackList && !trackList[note.track]) return;\n\n\t\t\t\tif (note.rest) return;\n\n\t\t\t\tconst tick = measureTick + note.tick;\n\n\t\t\t\tconst track = (tracks[note.track] = tracks[note.track] || []);\n\n\t\t\t\tnote.subNotes.forEach((subnote) => {\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.startTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: subnote.velocity,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\n\t\t\t\t\ttrack.push({\n\t\t\t\t\t\tticks: tick + subnote.endTick,\n\t\t\t\t\t\tmeasure: index,\n\t\t\t\t\t\tids: note.ids,\n\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\tchannel: note.channel,\n\t\t\t\t\t\tnoteNumber: subnote.pitch,\n\t\t\t\t\t\tvelocity: 0,\n\t\t\t\t\t\tstaffTrack: note.staffTrack,\n\t\t\t\t\t\tstaff: note.staff,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tmeasureTick += measure.duration;\n\t\t});\n\n\t\tconst finalTick = measureTick;\n\n\t\t// ensure no empty track\n\t\tfor (let t = 0; t < tracks.length; ++t) tracks[t] = tracks[t] || [];\n\n\t\t// sort & make deltaTime\n\t\ttracks.forEach((events) => {\n\t\t\tevents.sort((e1, e2) => eventPriority(e1) - eventPriority(e2));\n\n\t\t\tlet ticks = 0;\n\t\t\tevents.forEach((event) => {\n\t\t\t\tevent.deltaTime = event.ticks - ticks;\n\t\t\t\tif (!Number.isFinite(event.deltaTime)) event.deltaTime = 0;\n\t\t\t\telse ticks = event.ticks;\n\t\t\t});\n\n\t\t\tevents.push({ deltaTime: Math.max(finalTick - ticks, 0), type: 'meta', subtype: 'endOfTrack' });\n\t\t});\n\n\t\treturn {\n\t\t\theader: {\n\t\t\t\tformatType: 0,\n\t\t\t\tticksPerBeat: TICKS_PER_BEAT,\n\t\t\t},\n\t\t\ttracks,\n\t\t\tzeroTick,\n\t\t};\n\t}\n\n\ttoPerformingNotationWithEvents(measureIndices: number[], options: { trackList?: boolean[] } = {}): MusicNotation.Notation {\n\t\tif (!measureIndices.length) return null;\n\n\t\tconst { zeroTick, ...midi } = this.toPerformingMIDI(measureIndices, options);\n\t\tconst notation = MusicNotation.Notation.parseMidi(midi);\n\n\t\tassignNotationNoteDataFromEvents(notation);\n\n\t\tlet tick = zeroTick;\n\n\t\tnotation.measures = measureIndices.map((index) => {\n\t\t\tconst startTick = tick;\n\t\t\ttick += this.measures[index - 1].duration;\n\n\t\t\treturn {\n\t\t\t\tindex,\n\t\t\t\tstartTick,\n\t\t\t\tendTick: tick,\n\t\t\t};\n\t\t});\n\n\t\treturn notation;\n\t}\n\n\t// find the MIDI event of setTempo in measures data, and change the value of microsecondsPerBeat\n\tsetTempo(bpm: number): boolean {\n\t\tlet found = false;\n\t\tfor (const measure of this.measures) {\n\t\t\tfor (const event of measure.events) {\n\t\t\t\tif (event.data.subtype === 'setTempo') {\n\t\t\t\t\tevent.data.microsecondsPerBeat = 60e6 / bpm;\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn found;\n\t}\n}\n\nconst assignNotationNoteDataFromEvents = (midiNotation: MusicNotation.NotationData, fields = ['ids', 'measure', 'staffTrack']) => {\n\tconst noteId = (channel: number, pitch: number, tick: number): string => `${channel}|${pitch}|${tick}`;\n\n\tconst noteMap = midiNotation.notes.reduce((map, note) => {\n\t\tmap[noteId(note.channel, note.pitch, note.startTick)] = note;\n\n\t\treturn map;\n\t}, {});\n\n\tmidiNotation.events.forEach((event) => {\n\t\tif (event.data.subtype === 'noteOn') {\n\t\t\tconst id = noteId(event.data.channel, event.data.noteNumber, event.ticks);\n\t\t\tconst note = noteMap[id];\n\t\t\tconsole.assert(!!note, 'cannot find note of', id);\n\n\t\t\tif (note) Object.assign(note, pick(event.data, fields));\n\t\t}\n\t});\n};\n\nexport { MetaNote, MetaNotation, MidiEvent };\n",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory();\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\troot.CryptoJS = factory();\n\t}\n}(this, function () {\n\n\t/*globals window, global, require*/\n\n\t/**\n\t * CryptoJS core components.\n\t */\n\tvar CryptoJS = CryptoJS || (function (Math, undefined) {\n\n\t var crypto;\n\n\t // Native crypto from window (Browser)\n\t if (typeof window !== 'undefined' && window.crypto) {\n\t crypto = window.crypto;\n\t }\n\n\t // Native crypto in web worker (Browser)\n\t if (typeof self !== 'undefined' && self.crypto) {\n\t crypto = self.crypto;\n\t }\n\n\t // Native crypto from worker\n\t if (typeof globalThis !== 'undefined' && globalThis.crypto) {\n\t crypto = globalThis.crypto;\n\t }\n\n\t // Native (experimental IE 11) crypto from window (Browser)\n\t if (!crypto && typeof window !== 'undefined' && window.msCrypto) {\n\t crypto = window.msCrypto;\n\t }\n\n\t // Native crypto from global (NodeJS)\n\t if (!crypto && typeof global !== 'undefined' && global.crypto) {\n\t crypto = global.crypto;\n\t }\n\n\t // Native crypto import via require (NodeJS)\n\t if (!crypto && typeof require === 'function') {\n\t try {\n\t crypto = require('crypto');\n\t } catch (err) {}\n\t }\n\n\t /*\n\t * Cryptographically secure pseudorandom number generator\n\t *\n\t * As Math.random() is cryptographically not safe to use\n\t */\n\t var cryptoSecureRandomInt = function () {\n\t if (crypto) {\n\t // Use getRandomValues method (Browser)\n\t if (typeof crypto.getRandomValues === 'function') {\n\t try {\n\t return crypto.getRandomValues(new Uint32Array(1))[0];\n\t } catch (err) {}\n\t }\n\n\t // Use randomBytes method (NodeJS)\n\t if (typeof crypto.randomBytes === 'function') {\n\t try {\n\t return crypto.randomBytes(4).readInt32LE();\n\t } catch (err) {}\n\t }\n\t }\n\n\t throw new Error('Native crypto module could not be used to get secure random number.');\n\t };\n\n\t /*\n\t * Local polyfill of Object.create\n\n\t */\n\t var create = Object.create || (function () {\n\t function F() {}\n\n\t return function (obj) {\n\t var subtype;\n\n\t F.prototype = obj;\n\n\t subtype = new F();\n\n\t F.prototype = null;\n\n\t return subtype;\n\t };\n\t }());\n\n\t /**\n\t * CryptoJS namespace.\n\t */\n\t var C = {};\n\n\t /**\n\t * Library namespace.\n\t */\n\t var C_lib = C.lib = {};\n\n\t /**\n\t * Base object for prototypal inheritance.\n\t */\n\t var Base = C_lib.Base = (function () {\n\n\n\t return {\n\t /**\n\t * Creates a new object that inherits from this object.\n\t *\n\t * @param {Object} overrides Properties to copy into the new object.\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * field: 'value',\n\t *\n\t * method: function () {\n\t * }\n\t * });\n\t */\n\t extend: function (overrides) {\n\t // Spawn\n\t var subtype = create(this);\n\n\t // Augment\n\t if (overrides) {\n\t subtype.mixIn(overrides);\n\t }\n\n\t // Create default initializer\n\t if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {\n\t subtype.init = function () {\n\t subtype.$super.init.apply(this, arguments);\n\t };\n\t }\n\n\t // Initializer's prototype is the subtype object\n\t subtype.init.prototype = subtype;\n\n\t // Reference supertype\n\t subtype.$super = this;\n\n\t return subtype;\n\t },\n\n\t /**\n\t * Extends this object and runs the init method.\n\t * Arguments to create() will be passed to init().\n\t *\n\t * @return {Object} The new object.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var instance = MyType.create();\n\t */\n\t create: function () {\n\t var instance = this.extend();\n\t instance.init.apply(instance, arguments);\n\n\t return instance;\n\t },\n\n\t /**\n\t * Initializes a newly created object.\n\t * Override this method to add some logic when your objects are created.\n\t *\n\t * @example\n\t *\n\t * var MyType = CryptoJS.lib.Base.extend({\n\t * init: function () {\n\t * // ...\n\t * }\n\t * });\n\t */\n\t init: function () {\n\t },\n\n\t /**\n\t * Copies properties into this object.\n\t *\n\t * @param {Object} properties The properties to mix in.\n\t *\n\t * @example\n\t *\n\t * MyType.mixIn({\n\t * field: 'value'\n\t * });\n\t */\n\t mixIn: function (properties) {\n\t for (var propertyName in properties) {\n\t if (properties.hasOwnProperty(propertyName)) {\n\t this[propertyName] = properties[propertyName];\n\t }\n\t }\n\n\t // IE won't copy toString using the loop above\n\t if (properties.hasOwnProperty('toString')) {\n\t this.toString = properties.toString;\n\t }\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = instance.clone();\n\t */\n\t clone: function () {\n\t return this.init.prototype.extend(this);\n\t }\n\t };\n\t }());\n\n\t /**\n\t * An array of 32-bit words.\n\t *\n\t * @property {Array} words The array of 32-bit words.\n\t * @property {number} sigBytes The number of significant bytes in this word array.\n\t */\n\t var WordArray = C_lib.WordArray = Base.extend({\n\t /**\n\t * Initializes a newly created word array.\n\t *\n\t * @param {Array} words (Optional) An array of 32-bit words.\n\t * @param {number} sigBytes (Optional) The number of significant bytes in the words.\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.create();\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);\n\t * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);\n\t */\n\t init: function (words, sigBytes) {\n\t words = this.words = words || [];\n\n\t if (sigBytes != undefined) {\n\t this.sigBytes = sigBytes;\n\t } else {\n\t this.sigBytes = words.length * 4;\n\t }\n\t },\n\n\t /**\n\t * Converts this word array to a string.\n\t *\n\t * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex\n\t *\n\t * @return {string} The stringified word array.\n\t *\n\t * @example\n\t *\n\t * var string = wordArray + '';\n\t * var string = wordArray.toString();\n\t * var string = wordArray.toString(CryptoJS.enc.Utf8);\n\t */\n\t toString: function (encoder) {\n\t return (encoder || Hex).stringify(this);\n\t },\n\n\t /**\n\t * Concatenates a word array to this word array.\n\t *\n\t * @param {WordArray} wordArray The word array to append.\n\t *\n\t * @return {WordArray} This word array.\n\t *\n\t * @example\n\t *\n\t * wordArray1.concat(wordArray2);\n\t */\n\t concat: function (wordArray) {\n\t // Shortcuts\n\t var thisWords = this.words;\n\t var thatWords = wordArray.words;\n\t var thisSigBytes = this.sigBytes;\n\t var thatSigBytes = wordArray.sigBytes;\n\n\t // Clamp excess bits\n\t this.clamp();\n\n\t // Concat\n\t if (thisSigBytes % 4) {\n\t // Copy one byte at a time\n\t for (var i = 0; i < thatSigBytes; i++) {\n\t var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);\n\t }\n\t } else {\n\t // Copy one word at a time\n\t for (var j = 0; j < thatSigBytes; j += 4) {\n\t thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];\n\t }\n\t }\n\t this.sigBytes += thatSigBytes;\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Removes insignificant bits.\n\t *\n\t * @example\n\t *\n\t * wordArray.clamp();\n\t */\n\t clamp: function () {\n\t // Shortcuts\n\t var words = this.words;\n\t var sigBytes = this.sigBytes;\n\n\t // Clamp\n\t words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);\n\t words.length = Math.ceil(sigBytes / 4);\n\t },\n\n\t /**\n\t * Creates a copy of this word array.\n\t *\n\t * @return {WordArray} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = wordArray.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone.words = this.words.slice(0);\n\n\t return clone;\n\t },\n\n\t /**\n\t * Creates a word array filled with random bytes.\n\t *\n\t * @param {number} nBytes The number of random bytes to generate.\n\t *\n\t * @return {WordArray} The random word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.lib.WordArray.random(16);\n\t */\n\t random: function (nBytes) {\n\t var words = [];\n\n\t for (var i = 0; i < nBytes; i += 4) {\n\t words.push(cryptoSecureRandomInt());\n\t }\n\n\t return new WordArray.init(words, nBytes);\n\t }\n\t });\n\n\t /**\n\t * Encoder namespace.\n\t */\n\t var C_enc = C.enc = {};\n\n\t /**\n\t * Hex encoding strategy.\n\t */\n\t var Hex = C_enc.Hex = {\n\t /**\n\t * Converts a word array to a hex string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The hex string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hexString = CryptoJS.enc.Hex.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var hexChars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t hexChars.push((bite >>> 4).toString(16));\n\t hexChars.push((bite & 0x0f).toString(16));\n\t }\n\n\t return hexChars.join('');\n\t },\n\n\t /**\n\t * Converts a hex string to a word array.\n\t *\n\t * @param {string} hexStr The hex string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Hex.parse(hexString);\n\t */\n\t parse: function (hexStr) {\n\t // Shortcut\n\t var hexStrLength = hexStr.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < hexStrLength; i += 2) {\n\t words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);\n\t }\n\n\t return new WordArray.init(words, hexStrLength / 2);\n\t }\n\t };\n\n\t /**\n\t * Latin1 encoding strategy.\n\t */\n\t var Latin1 = C_enc.Latin1 = {\n\t /**\n\t * Converts a word array to a Latin1 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The Latin1 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t // Shortcuts\n\t var words = wordArray.words;\n\t var sigBytes = wordArray.sigBytes;\n\n\t // Convert\n\t var latin1Chars = [];\n\t for (var i = 0; i < sigBytes; i++) {\n\t var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;\n\t latin1Chars.push(String.fromCharCode(bite));\n\t }\n\n\t return latin1Chars.join('');\n\t },\n\n\t /**\n\t * Converts a Latin1 string to a word array.\n\t *\n\t * @param {string} latin1Str The Latin1 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);\n\t */\n\t parse: function (latin1Str) {\n\t // Shortcut\n\t var latin1StrLength = latin1Str.length;\n\n\t // Convert\n\t var words = [];\n\t for (var i = 0; i < latin1StrLength; i++) {\n\t words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);\n\t }\n\n\t return new WordArray.init(words, latin1StrLength);\n\t }\n\t };\n\n\t /**\n\t * UTF-8 encoding strategy.\n\t */\n\t var Utf8 = C_enc.Utf8 = {\n\t /**\n\t * Converts a word array to a UTF-8 string.\n\t *\n\t * @param {WordArray} wordArray The word array.\n\t *\n\t * @return {string} The UTF-8 string.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);\n\t */\n\t stringify: function (wordArray) {\n\t try {\n\t return decodeURIComponent(escape(Latin1.stringify(wordArray)));\n\t } catch (e) {\n\t throw new Error('Malformed UTF-8 data');\n\t }\n\t },\n\n\t /**\n\t * Converts a UTF-8 string to a word array.\n\t *\n\t * @param {string} utf8Str The UTF-8 string.\n\t *\n\t * @return {WordArray} The word array.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);\n\t */\n\t parse: function (utf8Str) {\n\t return Latin1.parse(unescape(encodeURIComponent(utf8Str)));\n\t }\n\t };\n\n\t /**\n\t * Abstract buffered block algorithm template.\n\t *\n\t * The property blockSize must be implemented in a concrete subtype.\n\t *\n\t * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0\n\t */\n\t var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({\n\t /**\n\t * Resets this block algorithm's data buffer to its initial state.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm.reset();\n\t */\n\t reset: function () {\n\t // Initial values\n\t this._data = new WordArray.init();\n\t this._nDataBytes = 0;\n\t },\n\n\t /**\n\t * Adds new data to this block algorithm's buffer.\n\t *\n\t * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.\n\t *\n\t * @example\n\t *\n\t * bufferedBlockAlgorithm._append('data');\n\t * bufferedBlockAlgorithm._append(wordArray);\n\t */\n\t _append: function (data) {\n\t // Convert string to WordArray, else assume WordArray already\n\t if (typeof data == 'string') {\n\t data = Utf8.parse(data);\n\t }\n\n\t // Append\n\t this._data.concat(data);\n\t this._nDataBytes += data.sigBytes;\n\t },\n\n\t /**\n\t * Processes available data blocks.\n\t *\n\t * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.\n\t *\n\t * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.\n\t *\n\t * @return {WordArray} The processed data.\n\t *\n\t * @example\n\t *\n\t * var processedData = bufferedBlockAlgorithm._process();\n\t * var processedData = bufferedBlockAlgorithm._process(!!'flush');\n\t */\n\t _process: function (doFlush) {\n\t var processedWords;\n\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\t var dataSigBytes = data.sigBytes;\n\t var blockSize = this.blockSize;\n\t var blockSizeBytes = blockSize * 4;\n\n\t // Count blocks ready\n\t var nBlocksReady = dataSigBytes / blockSizeBytes;\n\t if (doFlush) {\n\t // Round up to include partial blocks\n\t nBlocksReady = Math.ceil(nBlocksReady);\n\t } else {\n\t // Round down to include only full blocks,\n\t // less the number of blocks that must remain in the buffer\n\t nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);\n\t }\n\n\t // Count words ready\n\t var nWordsReady = nBlocksReady * blockSize;\n\n\t // Count bytes ready\n\t var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);\n\n\t // Process blocks\n\t if (nWordsReady) {\n\t for (var offset = 0; offset < nWordsReady; offset += blockSize) {\n\t // Perform concrete-algorithm logic\n\t this._doProcessBlock(dataWords, offset);\n\t }\n\n\t // Remove processed words\n\t processedWords = dataWords.splice(0, nWordsReady);\n\t data.sigBytes -= nBytesReady;\n\t }\n\n\t // Return processed words\n\t return new WordArray.init(processedWords, nBytesReady);\n\t },\n\n\t /**\n\t * Creates a copy of this object.\n\t *\n\t * @return {Object} The clone.\n\t *\n\t * @example\n\t *\n\t * var clone = bufferedBlockAlgorithm.clone();\n\t */\n\t clone: function () {\n\t var clone = Base.clone.call(this);\n\t clone._data = this._data.clone();\n\n\t return clone;\n\t },\n\n\t _minBufferSize: 0\n\t });\n\n\t /**\n\t * Abstract hasher template.\n\t *\n\t * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)\n\t */\n\t var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({\n\t /**\n\t * Configuration options.\n\t */\n\t cfg: Base.extend(),\n\n\t /**\n\t * Initializes a newly created hasher.\n\t *\n\t * @param {Object} cfg (Optional) The configuration options to use for this hash computation.\n\t *\n\t * @example\n\t *\n\t * var hasher = CryptoJS.algo.SHA256.create();\n\t */\n\t init: function (cfg) {\n\t // Apply config defaults\n\t this.cfg = this.cfg.extend(cfg);\n\n\t // Set initial values\n\t this.reset();\n\t },\n\n\t /**\n\t * Resets this hasher to its initial state.\n\t *\n\t * @example\n\t *\n\t * hasher.reset();\n\t */\n\t reset: function () {\n\t // Reset data buffer\n\t BufferedBlockAlgorithm.reset.call(this);\n\n\t // Perform concrete-hasher logic\n\t this._doReset();\n\t },\n\n\t /**\n\t * Updates this hasher with a message.\n\t *\n\t * @param {WordArray|string} messageUpdate The message to append.\n\t *\n\t * @return {Hasher} This hasher.\n\t *\n\t * @example\n\t *\n\t * hasher.update('message');\n\t * hasher.update(wordArray);\n\t */\n\t update: function (messageUpdate) {\n\t // Append\n\t this._append(messageUpdate);\n\n\t // Update the hash\n\t this._process();\n\n\t // Chainable\n\t return this;\n\t },\n\n\t /**\n\t * Finalizes the hash computation.\n\t * Note that the finalize operation is effectively a destructive, read-once operation.\n\t *\n\t * @param {WordArray|string} messageUpdate (Optional) A final message update.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @example\n\t *\n\t * var hash = hasher.finalize();\n\t * var hash = hasher.finalize('message');\n\t * var hash = hasher.finalize(wordArray);\n\t */\n\t finalize: function (messageUpdate) {\n\t // Final message update\n\t if (messageUpdate) {\n\t this._append(messageUpdate);\n\t }\n\n\t // Perform concrete-hasher logic\n\t var hash = this._doFinalize();\n\n\t return hash;\n\t },\n\n\t blockSize: 512/32,\n\n\t /**\n\t * Creates a shortcut function to a hasher's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to create a helper for.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHelper: function (hasher) {\n\t return function (message, cfg) {\n\t return new hasher.init(cfg).finalize(message);\n\t };\n\t },\n\n\t /**\n\t * Creates a shortcut function to the HMAC's object interface.\n\t *\n\t * @param {Hasher} hasher The hasher to use in this HMAC helper.\n\t *\n\t * @return {Function} The shortcut function.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);\n\t */\n\t _createHmacHelper: function (hasher) {\n\t return function (message, key) {\n\t return new C_algo.HMAC.init(hasher, key).finalize(message);\n\t };\n\t }\n\t });\n\n\t /**\n\t * Algorithm namespace.\n\t */\n\t var C_algo = C.algo = {};\n\n\t return C;\n\t}(Math));\n\n\n\treturn CryptoJS;\n\n}));",";(function (root, factory) {\n\tif (typeof exports === \"object\") {\n\t\t// CommonJS\n\t\tmodule.exports = exports = factory(require(\"./core\"));\n\t}\n\telse if (typeof define === \"function\" && define.amd) {\n\t\t// AMD\n\t\tdefine([\"./core\"], factory);\n\t}\n\telse {\n\t\t// Global (browser)\n\t\tfactory(root.CryptoJS);\n\t}\n}(this, function (CryptoJS) {\n\n\t(function (Math) {\n\t // Shortcuts\n\t var C = CryptoJS;\n\t var C_lib = C.lib;\n\t var WordArray = C_lib.WordArray;\n\t var Hasher = C_lib.Hasher;\n\t var C_algo = C.algo;\n\n\t // Initialization and round constants tables\n\t var H = [];\n\t var K = [];\n\n\t // Compute constants\n\t (function () {\n\t function isPrime(n) {\n\t var sqrtN = Math.sqrt(n);\n\t for (var factor = 2; factor <= sqrtN; factor++) {\n\t if (!(n % factor)) {\n\t return false;\n\t }\n\t }\n\n\t return true;\n\t }\n\n\t function getFractionalBits(n) {\n\t return ((n - (n | 0)) * 0x100000000) | 0;\n\t }\n\n\t var n = 2;\n\t var nPrime = 0;\n\t while (nPrime < 64) {\n\t if (isPrime(n)) {\n\t if (nPrime < 8) {\n\t H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));\n\t }\n\t K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));\n\n\t nPrime++;\n\t }\n\n\t n++;\n\t }\n\t }());\n\n\t // Reusable object\n\t var W = [];\n\n\t /**\n\t * SHA-256 hash algorithm.\n\t */\n\t var SHA256 = C_algo.SHA256 = Hasher.extend({\n\t _doReset: function () {\n\t this._hash = new WordArray.init(H.slice(0));\n\t },\n\n\t _doProcessBlock: function (M, offset) {\n\t // Shortcut\n\t var H = this._hash.words;\n\n\t // Working variables\n\t var a = H[0];\n\t var b = H[1];\n\t var c = H[2];\n\t var d = H[3];\n\t var e = H[4];\n\t var f = H[5];\n\t var g = H[6];\n\t var h = H[7];\n\n\t // Computation\n\t for (var i = 0; i < 64; i++) {\n\t if (i < 16) {\n\t W[i] = M[offset + i] | 0;\n\t } else {\n\t var gamma0x = W[i - 15];\n\t var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^\n\t ((gamma0x << 14) | (gamma0x >>> 18)) ^\n\t (gamma0x >>> 3);\n\n\t var gamma1x = W[i - 2];\n\t var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^\n\t ((gamma1x << 13) | (gamma1x >>> 19)) ^\n\t (gamma1x >>> 10);\n\n\t W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];\n\t }\n\n\t var ch = (e & f) ^ (~e & g);\n\t var maj = (a & b) ^ (a & c) ^ (b & c);\n\n\t var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));\n\t var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));\n\n\t var t1 = h + sigma1 + ch + K[i] + W[i];\n\t var t2 = sigma0 + maj;\n\n\t h = g;\n\t g = f;\n\t f = e;\n\t e = (d + t1) | 0;\n\t d = c;\n\t c = b;\n\t b = a;\n\t a = (t1 + t2) | 0;\n\t }\n\n\t // Intermediate hash value\n\t H[0] = (H[0] + a) | 0;\n\t H[1] = (H[1] + b) | 0;\n\t H[2] = (H[2] + c) | 0;\n\t H[3] = (H[3] + d) | 0;\n\t H[4] = (H[4] + e) | 0;\n\t H[5] = (H[5] + f) | 0;\n\t H[6] = (H[6] + g) | 0;\n\t H[7] = (H[7] + h) | 0;\n\t },\n\n\t _doFinalize: function () {\n\t // Shortcuts\n\t var data = this._data;\n\t var dataWords = data.words;\n\n\t var nBitsTotal = this._nDataBytes * 8;\n\t var nBitsLeft = data.sigBytes * 8;\n\n\t // Add padding\n\t dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);\n\t dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;\n\t data.sigBytes = dataWords.length * 4;\n\n\t // Hash final blocks\n\t this._process();\n\n\t // Return final computed hash\n\t return this._hash;\n\t },\n\n\t clone: function () {\n\t var clone = Hasher.clone.call(this);\n\t clone._hash = this._hash.clone();\n\n\t return clone;\n\t }\n\t });\n\n\t /**\n\t * Shortcut function to the hasher's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t *\n\t * @return {WordArray} The hash.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hash = CryptoJS.SHA256('message');\n\t * var hash = CryptoJS.SHA256(wordArray);\n\t */\n\t C.SHA256 = Hasher._createHelper(SHA256);\n\n\t /**\n\t * Shortcut function to the HMAC's object interface.\n\t *\n\t * @param {WordArray|string} message The message to hash.\n\t * @param {WordArray|string} key The secret key.\n\t *\n\t * @return {WordArray} The HMAC.\n\t *\n\t * @static\n\t *\n\t * @example\n\t *\n\t * var hmac = CryptoJS.HmacSHA256(message, key);\n\t */\n\t C.HmacSHA256 = Hasher._createHmacHelper(SHA256);\n\t}(Math));\n\n\n\treturn CryptoJS.SHA256;\n\n}));","import _SHA256 from 'crypto-js/sha256';\n\nconst SHA256 = (source: string): Uint8Array => {\n\tconst { words, sigBytes } = _SHA256(source);\n\tconst uwords = words.map((x) => (x < 0 ? x + 0x100000000 : x));\n\tconst word_len = sigBytes / words.length;\n\n\treturn new Uint8Array(sigBytes).map((_, i) => (uwords[Math.floor(i / word_len)] >> ((3 - (i % word_len)) * 8)) & 0xff);\n};\n\ntype Hash = Uint8Array;\nconst HASH_LEN = 256;\n\nclass HashVector {\n\tfields: number[];\n\n\tstatic fromHash(hash: Hash): HashVector {\n\t\tconst fields = [];\n\t\tfor (const byte of hash) {\n\t\t\tfor (let b = 0; b < 8; ++b) fields.push((byte >> b) & 1 ? 1 : -1);\n\t\t}\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic fromString(source: string): HashVector {\n\t\tconst hash = SHA256(source);\n\t\treturn HashVector.fromHash(hash);\n\t}\n\n\tstatic fromWords(words: string[]): HashVector {\n\t\tconst vs = words.map((word) => HashVector.fromString(word));\n\t\treturn vs.reduce((sum, v) => sum.add(v), HashVector.zero);\n\t}\n\n\tstatic concat(...vectors: HashVector[]): HashVector {\n\t\tconst fields = vectors.map((v) => v.fields).flat(1);\n\n\t\treturn new HashVector(fields);\n\t}\n\n\tconstructor(fields: number[] | null = null) {\n\t\tthis.fields = fields || Array(HASH_LEN).fill(0);\n\t}\n\n\tget length(): number {\n\t\treturn this.fields.length;\n\t}\n\n\ttoHash(): Hash {\n\t\treturn Uint8Array.from(\n\t\t\tArray(this.length / 8)\n\t\t\t\t.fill(0)\n\t\t\t\t.map((_, i) => {\n\t\t\t\t\tconst bits = this.fields.slice(i * 8, (i + 1) * 8);\n\n\t\t\t\t\treturn bits.reduce((byte, bit, b) => byte | ((bit > 0 ? 1 : 0) << b), 0);\n\t\t\t\t})\n\t\t) as Hash;\n\t}\n\n\tadd(vec: HashVector): this {\n\t\tthis.fields.forEach((value, i) => (this.fields[i] = value + vec.fields[i]));\n\n\t\treturn this;\n\t}\n\n\tscale(factor: number): this {\n\t\tthis.fields = this.fields.map((value) => value * factor);\n\n\t\treturn this;\n\t}\n\n\tsub(crop: number): HashVector {\n\t\tconst fields = crop > 0 ? this.fields.slice(0, crop) : this.fields.slice(crop);\n\t\treturn new HashVector(fields);\n\t}\n\n\tstatic get zero(): HashVector {\n\t\treturn new HashVector();\n\t}\n}\n\nconst odds = (byte: number): number => {\n\tlet result = 0;\n\tfor (let b = byte; b > 0; b >>= 1) {\n\t\tif (b % 2) ++result;\n\t}\n\n\treturn result;\n};\nconst ODDS = Array(2 ** 8)\n\t.fill(0)\n\t.map((_, i) => odds(i));\nconst ODDS_HEX = ODDS.reduce((table, odd, i) => ({ ...table, [('0' + i.toString(16)).slice(-2)]: odd }), {});\n\nconst countOnes = (hash: Hash): number => hash.reduce((sum, byte) => sum + ODDS[byte], 0);\n\nconst xorHashes = (hash1: Hash, hash2: Hash): Hash => hash1.map((byte, i) => byte ^ hash2[i]) as Hash;\n\nconst cosHashes = (hash1: Hash, hash2: Hash): number => {\n\tconst len = hash1.length * 8;\n\n\tconst xor = xorHashes(hash1, hash2);\n\tconst ones = countOnes(xor);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst cosBigInts = (hash1: bigint, hash2: bigint, len: number = HASH_LEN): number => {\n\tconst xor = hash1 ^ hash2;\n\tconst xor_hex = '0'.repeat(len / 4) + xor.toString(16);\n\n\tconst ones = Array(len / 8)\n\t\t.fill(0)\n\t\t.reduce((ones, _, i) => ones + ODDS_HEX[xor_hex.slice((i + 1) * -2, i ? i * -2 : undefined)], 0);\n\n\treturn (len - ones * 2) / len;\n};\n\nconst i2hex = (i) => ('0' + i.toString(16)).slice(-2);\nconst hashToHex = (hash: Hash): string => Array.from(hash).map(i2hex).join('');\n\nconst hexToHash = (hex: string): Hash =>\n\tUint8Array.from(\n\t\tArray(hex.length / 2)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => hex.substring(i * 2, (i + 1) * 2))\n\t\t\t.map((x) => parseInt(x, 16))\n\t);\n\nconst hashToBigInt = (hash: Hash): bigint => {\n\t// __NOT_FOR_BROWSER_\n\treturn Array.from(hash).reduce((r, x) => r * 0x100n + BigInt(x), 0n);\n\t/*\n\t// _NOT_FOR_BROWSER__\n\tthrow new Error('BigInt not supported');\n\t//*/\n};\n\nconst hashFromWords = (words: string[]): Hash => HashVector.fromWords(words).toHash();\n\nexport { Hash, HashVector, cosHashes, cosBigInts, hashToHex, hexToHash, hashToBigInt, hashFromWords };\n","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import { SimpleClass } from './aux_/typedJSON';\nimport { StaffBasic } from './interfaces';\nimport { SemanticPoint } from './semanticPoint';\nimport { EventTerm, ContextedTerm, MarkTerm } from './term';\n\nclass PatchMeasure extends SimpleClass {\n\tstatic className = 'PatchMeasure';\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tbasic: StaffBasic;\n\n\t//points: SemanticPoint[];\n\tevents: EventTerm[];\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tvoices: number[][]; // [voice, id]\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tObject.assign(this, data);\n\t}\n\n\tget staffN(): number {\n\t\treturn Math.floor(Math.log2(this.staffMask)) + 1;\n\t}\n\n\tget basics(): StaffBasic[] {\n\t\treturn Array(this.staffN).fill(this.basic);\n\t}\n\n\tget duration(): number {\n\t\treturn Math.max(\n\t\t\t0,\n\t\t\t...this.voices.map((ids) => {\n\t\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\n\t\t\t\treturn events.reduce((duration, event) => duration + event.duration, 0);\n\t\t\t})\n\t\t);\n\t}\n}\n\nexport { PatchMeasure };\n","import { EventFeature, BackgroundImage, EventPredisposition } from './interfaces';\nimport { StemBeam } from './term';\nimport { SimpleClass } from './aux_/typedJSON';\n\nenum EventElementType {\n\tPAD,\n\tBOS,\n\tEOS,\n\n\tCHORD,\n\tREST,\n}\n\ninterface EventElement {\n\thref?: string;\n\tdisposed?: boolean;\n\tindex?: number;\n\tvoice?: number;\n\n\ttype: EventElementType;\n\tstaff: number;\n\tx: number;\n\ty1: number;\n\ty2: number;\n\tfeature: EventFeature;\n\tpivotX?: number;\n\theadY?: number;\n\n\t// targets\n\ttick?: number;\n\tdivision?: number;\n\tdots?: number;\n\tbeam?: StemBeam;\n\tstemDirection?: string;\n\tgrace?: boolean;\n\ttremoloCatcher?: boolean;\n\ttimeWarped?: boolean;\n\tfullMeasure?: boolean; // full measure rest\n\tfake?: boolean;\n\n\torder?: number;\n\n\tpredisposition?: EventPredisposition;\n}\n\ntype Matrix = number[][];\n\ninterface Annotation {\n\tloss: number;\n\tgrant: boolean;\n\tpatched: boolean; // from manually solved measure\n}\n\nclass EventCluster extends SimpleClass {\n\tstatic className = 'EventCluster';\n\tstatic blackKeys = ['id'];\n\n\tid?: string; // for db access\n\tindex?: number;\n\tduration?: number;\n\tstaffY0?: number; // the first staff top + staffY\n\n\tsignatureDuration: number;\n\telements: EventElement[];\n\tmatrixH?: Matrix; // matrix N x N, [next][prev]\n\n\tbackgroundImages?: BackgroundImage[];\n\n\tannotation?: Annotation;\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\tget regular(): boolean {\n\t\treturn (\n\t\t\tthis.elements.some((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !elem.fake) &&\n\t\t\tthis.elements.every((elem) => [elem.x, elem.y1, elem.y2, elem.tick].every(Number.isFinite)) &&\n\t\t\tthis.elements\n\t\t\t\t.slice(1)\n\t\t\t\t.every(\n\t\t\t\t\t(elem, ei) =>\n\t\t\t\t\t\telem.fake ||\n\t\t\t\t\t\tthis.elements[ei].fake ||\n\t\t\t\t\t\telem.grace ||\n\t\t\t\t\t\tthis.elements[ei].grace ||\n\t\t\t\t\t\telem.fullMeasure ||\n\t\t\t\t\t\tthis.elements[ei].fullMeasure ||\n\t\t\t\t\t\telem.tick <= this.elements[ei].tick ||\n\t\t\t\t\t\telem.x > this.elements[ei].x\n\t\t\t\t)\n\t\t);\n\t}\n\n\tget grant(): boolean {\n\t\treturn this.annotation && this.annotation.grant;\n\t}\n\n\tget feature(): Partial {\n\t\treturn {\n\t\t\tindex: this.index,\n\t\t\telements: this.elements,\n\t\t};\n\t}\n\n\tget estimatedDuration(): number {\n\t\tconst endElem = this.elements.find((elem) => elem.type === EventElementType.EOS);\n\n\t\tconst tick = endElem?.predisposition ? endElem.predisposition?.tick : endElem?.tick;\n\n\t\treturn Number.isFinite(tick) ? tick : this.duration;\n\t}\n\n\tassignPrediction(prediction: any): void {\n\t\tconsole.assert(prediction.index === this.index, 'index mismatch:', prediction.index, this.index);\n\n\t\tthis.matrixH = prediction.matrixH;\n\t\tprediction.elements.forEach((pe) => {\n\t\t\tconst { index, ...predisposition } = pe;\n\t\t\tconst elem = this.elements.find((elem) => elem.index === index);\n\t\t\tconsole.assert(elem, 'element not found:', index);\n\n\t\t\tif (elem) elem.predisposition = predisposition;\n\t\t});\n\t}\n}\n\nclass EventClusterSet extends SimpleClass {\n\tstatic className = 'EventClusterSet';\n\n\tname?: string;\n\n\tclusters: EventCluster[];\n\n\tconstructor(data: object) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\t}\n\n\ttrimIrregular(): number {\n\t\tlet ir = 0;\n\n\t\tthis.clusters = this.clusters.filter((cluster) => {\n\t\t\tconst regular = cluster.regular;\n\t\t\tif (!regular) {\n\t\t\t\tconsole.debug('irregular cluster:', cluster);\n\t\t\t\t++ir;\n\t\t\t}\n\n\t\t\treturn regular;\n\t\t});\n\n\t\tif (ir) console.debug('Irregular clusters trimmed:', `${ir}/${this.clusters.length + ir}`);\n\t\telse console.debug(`The EventClusterSet (${this.clusters.length}) is fine.`);\n\n\t\treturn ir;\n\t}\n}\n\nexport { EventElementType, EventElement, EventCluster, EventClusterSet };\n","import erf from 'math-erf';\nimport sha1 from 'js-sha1';\n\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventTerm, ContextedTerm, MarkTerm, WHOLE_DURATION, StemBeam, GraceType, ContextType, TremoloLink } from './term';\nimport {\n\tFraction,\n\tStaffBasic,\n\tEventMeasure,\n\tRegulationOptions,\n\tRegulationSolution,\n\tRegulationSolutionEvent,\n\tBackgroundImage,\n\tMeasureBarType,\n} from './interfaces';\nimport { frac, fractionMul, roundNumber, argmax } from './utils';\nimport { NOTEHEAD_WIDTHS } from './semanticPoint';\nimport * as EquationSolver from './equationSolver';\nimport { PatchMeasure } from './patch';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport type { MeasureRectification } from './measureRectification';\nimport type { GraphMeasure } from './timewiseGraph';\n\nnamespace SimplePolicy {\n\tconst constructXMap = (measure: SpartitoMeasure): Map => {\n\t\tconst xMap = new Map();\n\n\t\t// mark full measure rests\n\t\tmeasure.rows.forEach((row) => {\n\t\t\tif (row.events.length === 1) {\n\t\t\t\tconst event = row.events[0];\n\t\t\t\tif (event.rest && event.division === 0) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst x = Math.round(event.pivotX * 10) / 10;\n\t\t\tlet key = 0;\n\t\t\tif (event.fullMeasureRest) key = Math.min(x, ...xMap.keys());\n\t\t\telse {\n\t\t\t\tkey =\n\t\t\t\t\t[...xMap.keys()].find((k) => {\n\t\t\t\t\t\t// check if the event is aligned with the current chord\n\t\t\t\t\t\tconst es = xMap.get(k);\n\t\t\t\t\t\tconst left = Math.min(...es.map((e) => e.left));\n\t\t\t\t\t\tconst right = Math.max(...es.map((e) => e.right));\n\n\t\t\t\t\t\tconst overlaySize = Math.min(right, event.right) - Math.max(left, event.left);\n\n\t\t\t\t\t\treturn overlaySize > NOTEHEAD_WIDTHS.NoteheadS1 * 0.62;\n\t\t\t\t\t}) || x;\n\t\t\t}\n\t\t\tevent.roundX = key;\n\n\t\t\tconst es = xMap.get(key) || [];\n\t\t\txMap.set(key, es);\n\n\t\t\tes.push(event);\n\t\t});\n\n\t\treturn xMap;\n\t};\n\n\texport const computeMeasureTicks = (measure: SpartitoMeasure): void => {\n\t\tconst xMap = constructXMap(measure);\n\n\t\tlet tick = 0;\n\t\tconst ts = new Set([tick]);\n\t\tconst eventGroups = [...xMap.entries()].sort(([x1], [x2]) => x1 - x2); //.map(entry => entry[1]);\n\t\tfor (const [x, events] of eventGroups) {\n\t\t\tvoid x;\n\n\t\t\tevents.forEach((event: EventTerm) => {\n\t\t\t\tif (event.predisposition) {\n\t\t\t\t\tevent.rest = event.rest && event.predisposition.fullMeasure > 0.5 ? 'R' : event.rest;\n\t\t\t\t\tevent.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t\tevent.division = argmax(event.predisposition.divisionVector);\n\t\t\t\t\tevent.dots = argmax(event.predisposition.dotsVector);\n\t\t\t\t\tif (event.predisposition.timeWarped > 0.5) event.timeWarp = frac(2, 3);\n\t\t\t\t}\n\n\t\t\t\tif (event.fullMeasureRest) event.tick = 0;\n\t\t\t\telse {\n\t\t\t\t\tif (event.zeroHolder) tick -= event.duration;\n\n\t\t\t\t\tif (!event.zeroHolder && event.predisposition && Number.isInteger(event.predisposition.tick)) event.tick = event.predisposition.tick;\n\t\t\t\t\telse event.tick = tick;\n\t\t\t\t\tts.add(event.tick + event.duration);\n\t\t\t\t}\n\t\t\t\t//console.log(\"append tick:\", event.tick + event.duration, event);\n\t\t\t});\n\t\t\tts.delete(tick);\n\n\t\t\t//column.xToTick[x] = tick;\n\n\t\t\tif (ts.size) tick = Math.min(...ts);\n\t\t}\n\n\t\tif (Number.isInteger(measure.estimatedDuration)) measure.duration = measure.estimatedDuration;\n\t\telse measure.duration = Math.max(...ts, 0);\n\t};\n\n\texport const computeMeasureVoices = (measure: SpartitoMeasure): void => {\n\t\tmeasure.voices = [];\n\t\tfor (const row of measure.rows) {\n\t\t\tconst events = row.events.filter(\n\t\t\t\t(event) => !event.grace && !event.tremoloCatcher && !event.fullMeasureRest && !(event.predisposition && event.predisposition.fake > 0.5)\n\t\t\t);\n\t\t\tconst eventSet = new Set(events);\n\n\t\t\twhile (eventSet.size) {\n\t\t\t\tlet tick = 0;\n\n\t\t\t\tconst voice = [];\n\t\t\t\tconst pushEvent = (e: EventTerm) => {\n\t\t\t\t\tvoice.push(e.id);\n\t\t\t\t\tif (!e.zeroHolder) tick += e.duration;\n\t\t\t\t\teventSet.delete(e);\n\t\t\t\t};\n\n\t\t\t\tconst e0 = events.find((e) => eventSet.has(e));\n\t\t\t\tif (e0.alignedTick > 0) {\n\t\t\t\t\t//voice.tickMap[tick] = EventTerm.space({ tick, duration: e0.alignedTick });\n\t\t\t\t\ttick = e0.alignedTick;\n\t\t\t\t}\n\t\t\t\tpushEvent(e0);\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// TODO: consider slur pair\n\t\t\t\t\tconst e = events.find((e) => eventSet.has(e) && e.alignedTick === tick);\n\t\t\t\t\tif (!e) break;\n\n\t\t\t\t\tpushEvent(e);\n\t\t\t\t}\n\n\t\t\t\t//if (tick < measure.duration)\n\t\t\t\t//\tvoice.tickMap[tick] = EventTerm.space({ tick, duration: staff.duration - tick });\n\n\t\t\t\tmeasure.voices.push(voice);\n\t\t\t}\n\t\t}\n\t};\n}\n\nconst solveGraceEvents = (measure: SpartitoMeasure): void => {\n\tconst graceEvents = measure.events.filter((event) => event.grace /*&& !Number.isFinite(event.tick)*/);\n\tif (!graceEvents.length) return;\n\n\tconst tickMap = measure.tickMap;\n\tconst staffMap = [...tickMap.entries()].reduce((smap, [tick, events]) => {\n\t\tevents.forEach((event) => {\n\t\t\tif (!event.grace) {\n\t\t\t\tsmap[event.staff] = smap[event.staff] || {};\n\n\t\t\t\tconst oldEvent = smap[event.staff][tick];\n\t\t\t\tsmap[event.staff][tick] = !oldEvent || oldEvent.x > event.x ? event : oldEvent;\n\t\t\t}\n\t\t});\n\n\t\treturn smap;\n\t}, {} as { [staff: number]: { [tick: number]: EventTerm } });\n\n\ttype Position = { tick: number; preTick: number; graces: EventTerm[]; event: EventTerm };\n\tconst staffPositions = Object.entries(staffMap).reduce((map, [staff, emap]) => {\n\t\tmap[staff] = Object.entries(emap)\n\t\t\t.map(([t, event]) => ({ event, tick: Number(t), preTick: -240, graces: [] }))\n\t\t\t.sort((p1, p2) => p1.event.x - p2.event.x);\n\t\tmap[staff].push({ tick: measure.duration, event: measure.endEvent, preTick: 0, graces: [] }); // terminal bar\n\n\t\tlet tick = 0;\n\t\tmap[staff].forEach((position) => {\n\t\t\tif (position.tick > tick) {\n\t\t\t\tposition.preTick = tick;\n\t\t\t\ttick = position.tick;\n\t\t\t}\n\t\t});\n\n\t\treturn map;\n\t}, {} as { [staff: number]: Position[] });\n\n\t// append grace events into positions\n\tgraceEvents.forEach((event) => {\n\t\tconst staff = staffPositions[event.staff];\n\t\tif (staff) {\n\t\t\tconst position = staff.find((p) => p.event.x > event.x);\n\t\t\tif (position) position.graces.push(event);\n\t\t\tevent.roundX = event.x;\n\t\t\t//if (position.tick >= measure.duration)\n\t\t\t//\tevent.grace = GraceType.AfterGrace;\n\t\t}\n\t});\n\n\tObject.values(staffPositions).forEach((staff) =>\n\t\tstaff.forEach((position) => {\n\t\t\tif (position.graces.length) {\n\t\t\t\tposition.event.graceIds = position.graces.map((e) => e.id);\n\n\t\t\t\tconst totalDuration = position.graces.reduce((t, e) => t + e.duration, 0);\n\t\t\t\tconst duration = Math.min(totalDuration, position.tick - position.preTick);\n\t\t\t\tconst warp = duration / totalDuration;\n\n\t\t\t\tlet tick = position.tick;\n\t\t\t\t[...position.graces].reverse().forEach((event) => {\n\t\t\t\t\tevent.tick = Math.round(tick - event.duration * warp);\n\t\t\t\t\ttick = event.tick;\n\t\t\t\t});\n\t\t\t}\n\t\t})\n\t);\n};\n\nconst solveTremoloPairs = (measure: SpartitoMeasure): void => {\n\tconst catchers = measure.events.filter((event) => event.tremoloCatcher && !event.grace);\n\tconst pitchers = measure.events.filter((event) => event.tremoloLink === TremoloLink.Pitcher && !event.grace);\n\n\tcatchers.forEach((catcher) => {\n\t\tlet candidates = pitchers.filter((event) => event.division === catcher.division && event.x < catcher.x);\n\t\tif (!candidates.length)\n\t\t\tcandidates = measure.events.filter(\n\t\t\t\t(event) =>\n\t\t\t\t\tNumber.isFinite(event.tick) &&\n\t\t\t\t\t!event.grace &&\n\t\t\t\t\t!event.rest &&\n\t\t\t\t\tevent.division === catcher.division &&\n\t\t\t\t\tevent.dots === catcher.dots &&\n\t\t\t\t\tevent.x < catcher.x\n\t\t\t);\n\t\tcandidates.sort((c1, c2) => c2.x - c1.x);\n\t\tif (candidates.length) {\n\t\t\tconst pitcher = candidates[0];\n\t\t\tpitcher.catcherId = catcher.id;\n\t\t\tconst tremolo = Math.max(pitcher.tremolo || 3, catcher.tremolo || 3);\n\t\t\tpitcher.tremolo = tremolo;\n\t\t\tcatcher.tremolo = tremolo;\n\n\t\t\tif (!catcher.tick) catcher.tick = pitcher.tick + pitcher.duration / 2;\n\n\t\t\tconst pi = pitchers.indexOf(pitcher);\n\t\t\tif (pi >= 0) pitchers.splice(pi, 1);\n\t\t}\n\t});\n};\n\nnamespace EquationPolicy {\n\ttype EventID = number;\n\ttype Time = number;\n\n\tconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\n\tconst CHORDS_SEAM_SIGMA = 0.6;\n\tconst NEIGHBOR_CHORDS_SIGMA = 1.6;\n\tconst Y_DECAY_SIGMA = 16;\n\tconst STAFF_DECAY_FACTOR = 2;\n\tconst STEM_DIRECTION_DECAY = 0.9;\n\tconst ILL_BEAMS_PENALTY = 0.2;\n\n\tconst INVERT_SQRT2 = 0.7071067811865475;\n\n\tconst MATRIX_H_WEIGHT = 3;\n\n\tconst FINE_BEAMS = [\n\t\t[null, null],\n\t\t[null, StemBeam.Open],\n\t\t[StemBeam.Open, StemBeam.Continue],\n\t\t[StemBeam.Open, StemBeam.Close],\n\t\t[StemBeam.Continue, StemBeam.Continue],\n\t\t[StemBeam.Continue, StemBeam.Close],\n\t\t[StemBeam.Close, null],\n\t\t[StemBeam.Close, StemBeam.Open],\n\t].map((bb) => bb.join('-'));\n\n\tinterface Event {\n\t\tid: EventID;\n\t\tstaff: number;\n\t\tx: number;\n\t\ty: number;\n\t\tduration: Time;\n\t\tconfidence: number;\n\t\tshrinkness: number;\n\t}\n\n\texport interface StaffGroup {\n\t\tevents: Event[];\n\t\texpectedDuration: Time;\n\t\tmeasureShrinkness: number;\n\t\tendX: number;\n\t\tmatrixH: Matrix;\n\t\tmatrixV: Matrix;\n\n\t\tids?: EventID[];\n\t}\n\n\tinterface EventResult {\n\t\tid: EventID;\n\t\ttick: Time;\n\t\tendTick: Time;\n\t\ttickGroup: number;\n\t\ttimeWarp?: Fraction;\n\t}\n\n\texport interface StaffGroupSolution {\n\t\tevents: EventResult[];\n\t\tvoices: EventID[][];\n\t\tduration: number;\n\n\t\tloss?: number;\n\t\tcredits?: number;\n\t\ttimes?: number;\n\t}\n\n\texport interface RegulatorOptions extends EquationSolver.SolverOptions {\n\t\tsolver?: (staffGroup: StaffGroup, options: EquationSolver.SolverOptions) => Promise;\n\t}\n\n\tconst solveStaffGroup = (staffGroup: StaffGroup, options: EquationSolver.SolverOptions): StaffGroupSolution => {\n\t\tif (!staffGroup.events.length) {\n\t\t\treturn {\n\t\t\t\tevents: [],\n\t\t\t\tvoices: [],\n\t\t\t\tduration: 0,\n\t\t\t};\n\t\t}\n\n\t\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\t\treturn solver.solve();\n\t};\n\n\texport const estiamteMeasure = (measure: SpartitoMeasure): StaffGroup => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => ({\n\t\t\t\tid: event.id,\n\t\t\t\tstaff: event.staff,\n\t\t\t\tx: event.x,\n\t\t\t\ttickEstimated: event.predisposition && Number.isFinite(event.predisposition.tick) ? event.predisposition.tick : event.x,\n\t\t\t\ttipX: event.tipX,\n\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\tduration: (event.mainDuration * DURATION_MULTIPLIER) / WHOLE_DURATION,\n\t\t\t\tdivision: event.division,\n\t\t\t\tdots: event.dots,\n\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\tbeam: event.beam,\n\t\t\t\trest: event.rest,\n\t\t\t\t// the possibility of full measure rest\n\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\tshrinkness: event.predisposition ? event.predisposition.timeWarped : null,\n\t\t\t}));\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: Number.isFinite(e.shrinkness) ? e.shrinkness : Math.tanh((e.division - e.dots * 0.1) / 4),\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\t//const hp = (dx: number): number => 1 - erf(((dx / NEIGHBOR_CHORDS_SIGMA) ** 0.6) * INVERT_SQRT2);\n\t\tconst hp = (dx: number): number => erf(dx / NEIGHBOR_CHORDS_SIGMA) * erf(NEIGHBOR_CHORDS_SIGMA / dx);\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\tif (e1.staffGroup !== e2.staffGroup) matrixH[e1.id][e2.id] = 0;\n\t\t\t\t// prohibit voice crossing staff groups\n\t\t\t\telse if (e1.x <= e2.x) matrixH[e1.id][e2.id] = 0;\n\t\t\t\telse {\n\t\t\t\t\tconst staffDecay = Math.exp(-Math.abs(e1.staff - e2.staff) * STAFF_DECAY_FACTOR);\n\t\t\t\t\tconst yDecay = e1.staff === e2.staff ? Math.exp(-Math.abs(e1.y - e2.y) / Y_DECAY_SIGMA) : 1;\n\t\t\t\t\tconst dx = e1.x - e2.x;\n\t\t\t\t\tconst dtx = e1.tipX - e2.tipX;\n\t\t\t\t\tmatrixH[e1.id][e2.id] = (staffDecay * yDecay * Math.min(hp(dx), hp(dtx))) ** (1 / MATRIX_H_WEIGHT);\n\t\t\t\t}\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\t\t\t\tmatrixH[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\n\t\t\t\t// weaken inconsistent stem directions\n\t\t\t\tif (e1.stemDirection && e2.stemDirection && e1.stemDirection !== e2.stemDirection) matrixH[e1.id][e2.id] *= STEM_DIRECTION_DECAY;\n\n\t\t\t\t// ill beams penalty\n\t\t\t\tif (!e1.rest && !e2.rest && !FINE_BEAMS.includes([e2.beam, e1.beam].join('-'))) matrixH[e1.id][e2.id] *= ILL_BEAMS_PENALTY;\n\t\t\t}\n\n\t\t\t// H possibility of e1 and end of measure\n\t\t\tmatrixH[ids.length][e1.id] = hp(measure.width - e1.x) ** (1 / MATRIX_H_WEIGHT);\n\t\t}\n\n\t\treturn {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness: 0,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t};\n\n\texport const regulateMeasure = async (measure: SpartitoMeasure, { solver = null, ...options }: RegulatorOptions): Promise => {\n\t\tconst env = estiamteMeasure(measure);\n\t\tconst { ids, matrixH, matrixV } = env;\n\n\t\t// copy matrices values from measure topology data\n\t\tif (measure.matrixH) {\n\t\t\tconsole.assert(\n\t\t\t\tmeasure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t\t'matrix shape mismatch:',\n\t\t\t\tids.length,\n\t\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t\t);\n\t\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t\t}\n\t\t}\n\t\tif (measure.matrixV) {\n\t\t\tmatrixV.forEach((row, i) =>\n\t\t\t\trow.forEach((_, j) => {\n\t\t\t\t\tconst mp = measure.matrixV[ids[i]][ids[j]];\n\t\t\t\t\tif (Number.isFinite(mp)) matrixV[i][j] = mp;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\tenv.measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tif (options.logger) options.logger.info('--- MEASURE', measure.measureIndex, '---', env);\n\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\t\tconst resultEvents = solution.events.map((e) => ({\n\t\t\t...e,\n\t\t\tid: env.ids[e.id], // decode compact ids\n\t\t}));\n\t\tresultEvents.forEach((e) => {\n\t\t\tconst event = measure.events.find((e0) => e0.id === e.id);\n\t\t\tevent.tick = Number.isFinite(e.tick) ? Math.round((e.tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : null;\n\t\t\tevent.tickGroup = e.tickGroup;\n\t\t\tevent.timeWarp = e.timeWarp;\n\t\t});\n\n\t\tmeasure.duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\t\tmeasure.voices = solution.voices.map((voice) => voice.map((id) => env.ids[id]));\n\n\t\tmeasure.solutionStat = {\n\t\t\tloss: solution.loss,\n\t\t\tsolverCredits: solution.credits,\n\t\t\tsolverTimes: solution.times,\n\t\t};\n\n\t\t// full measure rests\n\t\tmeasure.events.forEach((event) => {\n\t\t\tconst result = resultEvents.find((e) => e.id === event.id);\n\t\t\tif (!result) return;\n\t\t\telse if (!Number.isFinite(result.tick) && event.rest === 'r' && event.division === 0) {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.rest = 'R';\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t} else if (event.rest === 'R') {\n\t\t\t\tevent.tick = 0;\n\t\t\t\tevent.tickGroup = 0;\n\t\t\t\tevent.duration = measure.duration;\n\t\t\t\tmeasure.voices.push([event.id]);\n\t\t\t}\n\t\t});\n\t};\n\n\texport const regulateMeasureWithRectification = async (\n\t\tmeasure: SpartitoMeasure,\n\t\trectification: MeasureRectification,\n\t\t{ solver = null, ...options }: RegulatorOptions\n\t): Promise => {\n\t\tconst allEvents = measure.events\n\t\t\t.filter((event) => !event.zeroHolder)\n\t\t\t.map((event) => {\n\t\t\t\tconst re = rectification.events.find((e) => e && e.id === event.id);\n\t\t\t\tconst division = Number.isFinite(re?.division) ? re.division : event.division;\n\t\t\t\tconst dots = Number.isFinite(re?.dots) ? re.dots : event.dots;\n\t\t\t\tconst duration = DURATION_MULTIPLIER * 2 ** -division * (2 - 2 ** -dots);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: event.id,\n\t\t\t\t\tstaff: event.staff,\n\t\t\t\t\tx: event.x,\n\t\t\t\t\ttickEstimated: event.predisposition?.tick,\n\t\t\t\t\ty: event.tipY + event.staff * 100, // TODO: refine y by event term tipY\n\t\t\t\t\tduration,\n\t\t\t\t\t// the possibility of full measure rest\n\t\t\t\t\tpR: event.rest === 'R' ? 1 : event.rest === 'r' && event.division === 0 ? Math.tanh(event.x - measure.eventStartX) : 0,\n\t\t\t\t\tfakeP: event.predisposition ? event.predisposition.fakeP || 0 : 0,\n\t\t\t\t\tshrinkness: event.predisposition?.timeWarped || 0,\n\t\t\t\t};\n\t\t\t});\n\t\tlet expectedDuration = (DURATION_MULTIPLIER * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\t\tif (Number.isFinite(measure.estimatedDuration))\n\t\t\texpectedDuration = Math.max(expectedDuration, roundNumber(measure.estimatedDuration, DURATION_MULTIPLIER / 4));\n\n\t\tconst staffGroupMap = measure.staffGroups.reduce((map, staves, group) => {\n\t\t\tstaves.forEach((staff) => (map[staff] = group));\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst ids = [0, ...allEvents.map((e) => e.id)]; // compact ids\n\t\tconst ievents = allEvents.map((e) => ({\n\t\t\t...e,\n\t\t\tid: ids.indexOf(e.id),\n\t\t\tx: e.x - measure.startX,\n\t\t\tconfidence: (1 - e.pR) * (1 - e.fakeP),\n\t\t\tshrinkness: e.shrinkness,\n\t\t\tstaffGroup: staffGroupMap[e.staff],\n\t\t}));\n\n\t\t// estimate topology matrices\n\t\tconst matrixH = Array(ids.length + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\t\tconst matrixV = Array(ids.length)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(ids.length).fill(0));\n\n\t\tfor (const e1 of ievents) {\n\t\t\tfor (const e2 of ievents) {\n\t\t\t\tmatrixV[e1.id][e2.id] =\n\t\t\t\t\te1 !== e2 && e1.tickEstimated >= e2.tickEstimated ? 1 - erf(((e1.tickEstimated - e2.tickEstimated) * INVERT_SQRT2) / CHORDS_SEAM_SIGMA) : 0;\n\n\t\t\t\t// weaken full measure rest connections\n\t\t\t\tconst nR = (1 - e1.pR) * (1 - e2.pR);\n\t\t\t\tmatrixV[e1.id][e2.id] *= nR;\n\n\t\t\t\tif (matrixV[e1.id][e2.id] < 1e-2) matrixV[e1.id][e2.id] = 0;\n\t\t\t}\n\t\t}\n\n\t\t// copy matrices values from measure topology data\n\t\tconsole.assert(\n\t\t\tmeasure.matrixH && measure.matrixH.length > ids[ids.length - 1] && measure.matrixH[0].length > ids[ids.length - 1],\n\t\t\t'matrix shape mismatch:',\n\t\t\tids.length,\n\t\t\t`${measure.matrixH.length}x${measure.matrixH[0].length}`,\n\t\t\t`${matrixH.length}x${matrixH[0].length}`\n\t\t);\n\t\tfor (let i = 0; i < ids.length + 1; i++) {\n\t\t\tconst ii = i < ids.length ? ids[i] : measure.matrixH.length - 1;\n\t\t\tfor (let j = 1; j < ids.length; j++) matrixH[i][j] = measure.matrixH[ii][ids[j]];\n\t\t}\n\n\t\tlet measureShrinkness = 0;\n\t\tif (Number.isFinite(measure.estimatedDuration)) measureShrinkness = Math.tanh(Math.log(Math.min(1, measure.estimatedDuration / measure.duration)) * -3);\n\n\t\tconst env = {\n\t\t\tids,\n\t\t\tevents: ievents,\n\t\t\texpectedDuration,\n\t\t\tmeasureShrinkness,\n\t\t\tendX: measure.position.right,\n\t\t\tmatrixH,\n\t\t\tmatrixV,\n\t\t};\n\t\tconst solution = solver ? await solver(env, options) : solveStaffGroup(env, options);\n\n\t\tconst priority = -solution.loss;\n\n\t\tconst events = solution.events.map(({ id, tick, tickGroup, timeWarp }) => {\n\t\t\tconst re = rectification.events.find((e) => e && e.id === id);\n\t\t\tconst tickN = Number.isFinite(tick) ? Math.round((tick * WHOLE_DURATION) / DURATION_MULTIPLIER) : tick;\n\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\ttick: tickN,\n\t\t\t\ttickGroup,\n\t\t\t\ttimeWarp,\n\t\t\t\tdivision: re?.division,\n\t\t\t\tdots: re?.dots,\n\t\t\t};\n\t\t});\n\n\t\tconst duration = Math.round((solution.duration * WHOLE_DURATION) / DURATION_MULTIPLIER);\n\n\t\treturn {\n\t\t\tevents,\n\t\t\tvoices: solution.voices,\n\t\t\tduration,\n\t\t\tpriority,\n\t\t};\n\t};\n}\n\ntype Matrix = number[][];\n\ntype TickMap = Map;\n\ninterface SolutionStatistics {\n\tloss?: number;\n\tsolverCredits?: number;\n\tsolverTimes?: number;\n}\n\nclass SpartitoMeasure extends SimpleClass {\n\tstatic className = 'SpartitoMeasure';\n\tstatic blackKeys = ['staffGroups', 'solutionStat', 'measureNumber', 'deposit'];\n\n\tmeasureIndex: number;\n\tstaffMask: number;\n\tstaffGroups: number[][];\n\toriginalRegulationHash?: string;\n\tmeasureNumber?: number; // count from the last indent measure, head partial measure is zero, skip empty measures\n\n\tpatched: boolean;\n\tdiscard: boolean;\n\n\tposition: {\n\t\tsystemIndex: number;\n\t\tlocalIndex: number; // the measure local index in its system\n\t\tleft: number;\n\t\tright: number;\n\t\tstaffYs?: number[];\n\t\tstaffYsFull?: number[];\n\t};\n\n\tbackgroundImages: BackgroundImage[];\n\n\tevents: EventTerm[];\n\tendEvent: Partial; // the placeholder for end tick\n\tcontexts: ContextedTerm[][]; // [staff]\n\tmarks: MarkTerm[];\n\tduration: number;\n\n\tvoices?: number[][]; // [voice, id]\n\tbreak?: boolean;\n\tpageBreak?: boolean;\n\tbasics?: StaffBasic[]; // [staff]\n\tvoltaBegin: boolean;\n\tvoltaEnd: boolean;\n\talternative: boolean;\n\tbarTypes: Record;\n\tindent: boolean;\n\n\tsolutionStat?: SolutionStatistics;\n\n\tmatrixH: Matrix; // matrix N x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n\testimatedDuration: number;\n\n\tgraph: GraphMeasure;\n\n\tdeposit: Record;\n\n\tstatic reorderEvents(events: EventTerm[], staffYsFull: number[]): EventTerm[] {\n\t\tconst HALF_NOTEHEAD = 0.7;\n\n\t\tconst ys = [];\n\n\t\tconst es = events.map((e) => ({\n\t\t\tid: e.id,\n\t\t\tstaff: e.staff,\n\t\t\tx: e.x / HALF_NOTEHEAD,\n\t\t\trx: 0,\n\t\t\try: staffYsFull[e.staff] + e.tipY,\n\t\t\ttipY: e.tipY,\n\t\t\tprior: 0,\n\t\t}));\n\t\tes.sort((e1, e2) => e1.x - e2.x);\n\t\tes.slice(1).forEach((e, i) => {\n\t\t\tconst dx = Math.min(Math.round(e.x - es[i].x), 2);\n\t\t\te.rx = es[i].rx + dx;\n\t\t});\n\t\tes.forEach((e) => {\n\t\t\te.prior = e.staff * 1e4 + e.rx + e.tipY * 0.01;\n\n\t\t\tif (!ys.includes(e.ry)) ys.push(e.ry);\n\t\t});\n\t\tes.sort((e1, e2) => e1.prior - e2.prior);\n\t\tys.sort((y1, y2) => y1 - y2);\n\n\t\tlet yi = 0;\n\t\tconst yis = ys.map((y, i) => {\n\t\t\tif (!i || ys[i] - ys[i - 1] < 0.5) return yi;\n\n\t\t\t++yi;\n\t\t\treturn yi;\n\t\t});\n\n\t\tconst result = es.map((e) => new EventTerm({ ...events.find((ev) => ev.id === e.id), intX: e.rx, intY: yis[ys.indexOf(e.ry)] }));\n\t\tresult.forEach((e, i) => (e.id = i + 1));\n\n\t\treturn result;\n\t}\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tif (!this.originalRegulationHash && !this.regulated) this.originalRegulationHash = this.regulationHash;\n\n\t\tthis.barTypes = this.barTypes || {};\n\n\t\t// Ensure postRegulate runs for measures deserialized with voices (e.g. from patches/JSON)\n\t\t// to set endEvent and roundX needed for playback cursor positioning.\n\t\tif (this.regulated && this.position) this.postRegulate();\n\t}\n\n\tget timeSignature(): Fraction {\n\t\treturn this.basics && this.basics[0].timeSignature;\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.basics && this.basics[0].keySignature;\n\t}\n\n\tget timeSignatureChanged(): boolean {\n\t\treturn this.contexts.filter(Boolean)[0].some((term) => [ContextType.TimeSignatureC, ContextType.TimeSignatureN].includes(term.type));\n\t}\n\n\tget doubtfulTimesig(): boolean {\n\t\treturn this.basics && this.basics[0].doubtfulTimesig;\n\t}\n\n\tget regulated(): boolean {\n\t\treturn !!this.voices;\n\t}\n\n\tget validRegulated(): boolean {\n\t\tif (!this.voices) return false;\n\n\t\treturn this.voices.flat(1).every((id) => Number.isFinite(this.events.find((e) => e.id === id)?.tick));\n\t}\n\n\tget rows(): EventMeasure[] {\n\t\treturn this.contexts.map((contexts, si) => {\n\t\t\tconst events = this.events.filter((e) => e.staff === si);\n\n\t\t\treturn {\n\t\t\t\tevents,\n\t\t\t\tcontexts,\n\t\t\t};\n\t\t});\n\t}\n\n\tget eventStartX(): number {\n\t\treturn this.events.length ? Math.min(...this.events.map((e) => e.x)) : this.startX;\n\t}\n\n\tget startX(): number {\n\t\treturn this.position.left;\n\t}\n\n\tget width(): number {\n\t\treturn this.position.right - this.position.left;\n\t}\n\n\tget tickMap(): TickMap {\n\t\treturn this.events\n\t\t\t.concat([this.endEvent as EventTerm])\n\t\t\t.filter(Boolean)\n\t\t\t.reduce((map, event) => {\n\t\t\t\tif (Number.isFinite(event.tick)) {\n\t\t\t\t\tif (!map.has(event.tick)) map.set(event.tick, []);\n\n\t\t\t\t\tmap.get(event.tick).push(event);\n\t\t\t\t}\n\n\t\t\t\treturn map;\n\t\t\t}, new Map());\n\t}\n\n\tget tickToX(): { [tick: number]: number } {\n\t\treturn [...this.tickMap.entries()].reduce((map, [tick, events]) => {\n\t\t\tevents = events.filter((e) => !e.fullMeasureRest && !e.grace);\n\t\t\tif (events.length) {\n\t\t\t\tconst x = Math.min(...events.map((e) => e.x));\n\t\t\t\tmap[tick] = x;\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget tickRates(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tevents.sort((e1, e2) => e1.x - e2.x);\n\n\t\treturn events.slice(0, events.length - 1).map((e1, i) => {\n\t\t\tconst e2 = events[i + 1];\n\n\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t});\n\t}\n\n\tget tickRatesInStaves(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(sevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickRatesInGroups(): number[] {\n\t\tconst events = this.events.filter((event) => Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst rates = Object.values(gevents).map((es) =>\n\t\t\tes\n\t\t\t\t.sort((e1, e2) => e1.x - e2.x)\n\t\t\t\t.slice(0, es.length - 1)\n\t\t\t\t.map((e1, i) => {\n\t\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\t\treturn (e2.tick - e1.tick) / Math.max(e2.x - e1.x, 1e-3);\n\t\t\t\t})\n\t\t);\n\n\t\treturn [].concat(...rates);\n\t}\n\n\tget tickTwist(): number {\n\t\tif (!this.duration || !this.staffGroups) return undefined;\n\n\t\tconst events = this.events.filter(\n\t\t\t(event) => Number.isFinite(event.tick) && !event.fullMeasureRest && !event.grace && !event.tremoloCatcher && !(event.rest && event.division === 0)\n\t\t); // ignore rest0\n\t\tconst gevents: Record = events.reduce((map, event) => {\n\t\t\tconst groupIndex = this.staffGroups.findIndex((group) => group.includes(event.staff));\n\t\t\tmap[groupIndex] = map[groupIndex] || [];\n\t\t\tmap[groupIndex].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\n\t\tconst twists = Object.values(gevents).map((es) => {\n\t\t\tconst eventsXOrder = [...es].sort((e1, e2) => e1.pivotX - e2.pivotX);\n\t\t\tconst xSpan = this.position.right - eventsXOrder[0].x;\n\t\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\t\tconst e1 = eventsXOrder[i];\n\t\t\t\tconst dx = e2.pivotX - e1.pivotX;\n\t\t\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\t\t\tif (!dt) return dx / xSpan;\n\n\t\t\t\tconst rate = Math.atan2(dt / this.duration, dx / xSpan);\n\n\t\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t\t});\n\n\t\t\treturn Math.max(0, ...tickTwists);\n\t\t});\n\n\t\treturn Math.max(0, ...twists);\n\t}\n\n\tget eventMap(): Record {\n\t\treturn this.events.reduce((map, event) => {\n\t\t\tmap[event.id] = event;\n\t\t\treturn map;\n\t\t}, {});\n\t}\n\n\tget empty(): boolean {\n\t\treturn !this.events?.length || !this.voices?.length;\n\t}\n\n\tget hasIllEvent(): boolean {\n\t\treturn this.regulated && this.events.some((event) => !event.zeroHolder && !Number.isFinite(event.tick) && !event.fullMeasureRest);\n\t}\n\n\tget brief(): string {\n\t\tconst timesig = `${this.timeSignature.numerator}/${this.timeSignature.denominator}`;\n\t\tconst eventBrieves = this.events.map((e) =>\n\t\t\t[\n\t\t\t\te.staff,\n\t\t\t\te.intX,\n\t\t\t\tMath.round(e.tip ? e.tip.y : e.ys?.[0] ?? 0),\n\t\t\t\te.fullMeasureRest ? 0 : e.division,\n\t\t\t\te.fullMeasureRest ? 0 : e.dots,\n\t\t\t\te.rest ? 'r' : '',\n\t\t\t\te.grace || '',\n\t\t\t\te.stemDirection,\n\t\t\t\te.beam || '',\n\t\t\t].join('|')\n\t\t);\n\n\t\treturn [timesig, ...eventBrieves].join('\\n');\n\t}\n\n\tget regulationHash(): string {\n\t\treturn sha1(this.brief);\n\t}\n\n\t// prefer use originalRegulationHash\n\tget regulationHash0(): string {\n\t\treturn this.originalRegulationHash || this.regulationHash;\n\t}\n\n\tget regulationHashes(): string[] {\n\t\treturn Array.from(new Set([this.originalRegulationHash, this.regulationHash].filter(Boolean)));\n\t}\n\n\tget featureWords(): string[][] | null {\n\t\tif (!this.regulated || !this.voices || !this.voices.length) return null;\n\n\t\tconst invalid = this.tickRatesInStaves.some((rate) => rate < 0);\n\n\t\tconst mainEvents = this.events.filter((event) => !event.zeroHolder && !event.rest);\n\n\t\tconst ys = mainEvents\n\t\t\t.map((event) => event.ys)\n\t\t\t.flat(1)\n\t\t\t.map((y) => `Y${-y * 2}`);\n\t\tconst uys = Array.from(new Set(ys));\n\t\tif (this.keySignature) uys.push(`K${this.keySignature}`);\n\n\t\tconst voices = this.voices\n\t\t\t.map((ids) => ids.map((id) => this.events.find((e) => e.id === id)).filter((event) => !event.zeroHolder && !event.rest))\n\t\t\t.filter((voice) => voice.length);\n\n\t\tconst melodies = invalid ? [] : voices.map((es) => es.map((e) => e.scaleChord).join('-'));\n\n\t\tconst rhythm = invalid ? [] : voices.map((es) => es.map((e) => e.division).join(''));\n\t\tif (this.timeSignature) rhythm.push(`T${this.timeSignature.numerator}/${this.timeSignature.denominator}`);\n\n\t\treturn [uys, melodies, rhythm];\n\t}\n\n\tget barType(): MeasureBarType {\n\t\tif (this.voltaEnd) return 'VoltaRight';\n\n\t\tconst typeEntris = Object.entries(this.barTypes).sort((e1, e2) => e2[1] - e1[1]);\n\t\tif (typeEntris[0] && typeEntris[0][1] >= 1) return typeEntris[0][0] as MeasureBarType;\n\n\t\treturn null;\n\t}\n\n\tget partialDuration(): boolean {\n\t\tif (!Number.isFinite(this.duration)) return false;\n\n\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\treturn this.duration < signatureDuration;\n\t}\n\n\tpostRegulate(): void {\n\t\tthis.endEvent = new EventTerm({ tick: this.duration, x: this.position.right });\n\n\t\tthis.updateRoundX();\n\t\tsolveGraceEvents(this);\n\t\tsolveTremoloPairs(this);\n\t\tthis.updateContextTick();\n\t}\n\n\tupdateRoundX(): void {\n\t\tconst tickToX = this.tickToX;\n\t\tif (tickToX)\n\t\t\tthis.events.forEach((event) => {\n\t\t\t\tconst x = tickToX[event.tick];\n\t\t\t\tif (Number.isFinite(x)) event.roundX = x;\n\t\t\t});\n\t}\n\n\tupdateContextTick(): void {\n\t\tif (!this.staffGroups) return;\n\t\tconst contexts = this.contexts.flat(1);\n\t\tthis.staffGroups.flat(1).forEach((staffIndex) => {\n\t\t\tconst terms = [...this.events.filter((e) => e.staff === staffIndex), ...contexts.filter((c) => c.staff === staffIndex)];\n\t\t\tterms.sort((t1, t2) => t2.x - t1.x); // order by x from right to left\n\n\t\t\tlet tick = this.duration;\n\t\t\tterms.forEach((term) => {\n\t\t\t\tif (term instanceof EventTerm) {\n\t\t\t\t\tif (!term.fullMeasureRest && !term.zeroHolder) tick = term.tick;\n\t\t\t\t} else if (term instanceof ContextedTerm) term.tick = tick;\n\t\t\t});\n\t\t});\n\t}\n\n\tasSolution(ref: SpartitoMeasure = undefined): RegulationSolution {\n\t\tif (!this.regulated) return null;\n\n\t\t//let timeSignature = undefined;\n\t\t//if (ref && printFraction(ref.timeSignature) !== printFraction(this.timeSignature)) timeSignature = this.timeSignature;\n\n\t\treturn {\n\t\t\t//timeSignature,\n\t\t\tevents: this.events.map((e) => {\n\t\t\t\tconst se = {\n\t\t\t\t\tid: e.id,\n\t\t\t\t\ttick: e.tick,\n\t\t\t\t\ttickGroup: e.tickGroup,\n\t\t\t\t\ttimeWarp: e.timeWarp,\n\t\t\t\t} as RegulationSolutionEvent;\n\n\t\t\t\tif (ref) {\n\t\t\t\t\tconst refEvent = ref.events.find((re) => re.id === e.id);\n\t\t\t\t\tif (refEvent) {\n\t\t\t\t\t\tif (e.division !== refEvent.division) se.division = e.division;\n\t\t\t\t\t\tif (e.dots !== refEvent.dots) se.dots = e.dots;\n\t\t\t\t\t\tif (e.grace !== refEvent.grace) se.grace = !!e.grace;\n\t\t\t\t\t\tif (e.beam !== refEvent.beam) se.beam = e.beam;\n\t\t\t\t\t\tif (e.fullMeasureRest !== refEvent.fullMeasureRest) se.fullMeasure = e.fullMeasureRest;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn se;\n\t\t\t}),\n\t\t\tvoices: this.voices,\n\t\t\tduration: this.duration,\n\t\t\tpriority: -this.solutionStat?.loss,\n\t\t};\n\t}\n\n\tapplySolution(solution: RegulationSolution): void {\n\t\tif (solution.timeSignature) {\n\t\t\tthis.basics.forEach((basic) => {\n\t\t\t\tbasic.timeSignature = solution.timeSignature;\n\t\t\t\tbasic.doubtfulTimesig = false;\n\t\t\t});\n\t\t}\n\n\t\tthis.voices = solution.voices;\n\t\tthis.duration = solution.duration;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.timeWarp = null;\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\n\t\t\tconst se = solution.events?.find((e) => e.id === event.id);\n\t\t\tif (se) {\n\t\t\t\tevent.tick = se.tick;\n\t\t\t\tevent.timeWarp = se.timeWarp;\n\t\t\t\tevent.tickGroup = se.tickGroup;\n\n\t\t\t\tif (Number.isFinite(se.division)) event.division = se.division;\n\t\t\t\tif (Number.isFinite(se.dots)) event.dots = se.dots;\n\t\t\t\tif (se.beam) event.beam = se.beam as StemBeam;\n\t\t\t\tif (se.grace !== undefined) event.grace = se.grace ? GraceType.Grace : undefined;\n\t\t\t\tif (se.fullMeasure) event.rest = 'R';\n\t\t\t}\n\t\t});\n\n\t\tif (Number.isFinite(solution.priority)) this.solutionStat = { loss: -solution.priority };\n\n\t\tthis.postRegulate();\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.voices = null;\n\t\tthis.duration = null;\n\t\tthis.events.forEach((event) => {\n\t\t\tevent.tick = null;\n\t\t\tevent.tickGroup = null;\n\t\t\tevent.timeWarp = null;\n\t\t});\n\t}\n\n\tregulateTest(): void {\n\t\tthis.duration = 0;\n\t\tthis.voices = this.rows.map((row) => row.events.map((e) => e.id));\n\t\tthis.voices.forEach((ids) => {\n\t\t\tlet tick = 0;\n\t\t\tconst events = ids.map((id) => this.events.find((e) => e.id === id));\n\t\t\tevents.forEach((e, index) => {\n\t\t\t\te.tickGroup = index;\n\t\t\t\te.tick = tick;\n\n\t\t\t\ttick += e.duration;\n\t\t\t});\n\n\t\t\tthis.duration = Math.max(this.duration, tick);\n\t\t});\n\t}\n\n\tregulateSimple(): void {\n\t\tSimplePolicy.computeMeasureTicks(this);\n\t\tSimplePolicy.computeMeasureVoices(this);\n\t}\n\n\tasync regulateEquations(options: EquationPolicy.RegulatorOptions): Promise {\n\t\tawait EquationPolicy.regulateMeasure(this, options);\n\t}\n\n\t// compute event.tick, event.tickGroup, event.timeWarp, voices, duration\n\tasync regulate({ policy = 'advanced', ...options }: RegulationOptions = {}): Promise {\n\t\tswitch (policy) {\n\t\t\tcase 'test':\n\t\t\t\tthis.regulateTest();\n\n\t\t\t\tbreak;\n\t\t\tcase 'equations':\n\t\t\tcase 'advanced':\n\t\t\t\tawait this.regulateEquations(options);\n\n\t\t\t\tbreak;\n\t\t\tcase 'simple':\n\t\t\tdefault:\n\t\t\t\tthis.regulateSimple();\n\t\t}\n\n\t\tthis.postRegulate();\n\t}\n\n\tcreatePatch(): PatchMeasure {\n\t\treturn new PatchMeasure({\n\t\t\tmeasureIndex: this.measureIndex,\n\t\t\tstaffMask: this.staffMask,\n\t\t\tbasic: this.basics[0],\n\t\t\t//points: [],\n\t\t\tevents: this.events,\n\t\t\tcontexts: this.contexts,\n\t\t\tmarks: this.marks,\n\t\t\tvoices: this.voices,\n\t\t});\n\t}\n\n\tcreateClusters(): EventCluster[] {\n\t\tconst trueEventIds = this.voices && new Set(this.voices.flat(1));\n\n\t\treturn this.staffGroups\n\t\t\t.filter((idx) => idx.length)\n\t\t\t.map((staffIndices) => {\n\t\t\t\tconst staffY0 = this.position.staffYs[0];\n\t\t\t\tconst staffYn = (n) => this.position.staffYs[staffIndices.indexOf(n)] - staffY0;\n\n\t\t\t\tconst events = this.events.filter((event) => staffIndices.includes(event.staff));\n\t\t\t\tif (!events.length) return null;\n\n\t\t\t\tconst elements: EventElement[] = events.map((event) => ({\n\t\t\t\t\tindex: event.id,\n\t\t\t\t\tvoice: (this.voices || []).findIndex((voice) => voice.includes(event.id)),\n\t\t\t\t\ttype: event.rest ? EventElementType.REST : EventElementType.CHORD,\n\t\t\t\t\tstaff: staffIndices.indexOf(event.staff),\n\t\t\t\t\tx: event.tipX,\n\t\t\t\t\tpivotX: event.pivotX,\n\t\t\t\t\ty1: staffYn(event.staff) + (event.stemDirection === 'u' ? event.tipY : event.ys[event.ys.length - 1]),\n\t\t\t\t\ty2: staffYn(event.staff) + (event.stemDirection === 'u' ? event.ys[0] : event.tipY),\n\t\t\t\t\theadY: event.stemDirection === 'u' ? event.ys[0] : event.ys[event.ys.length - 1],\n\t\t\t\t\tfeature: event.feature,\n\t\t\t\t\tdivision: event.division,\n\t\t\t\t\tdots: event.dots,\n\t\t\t\t\tbeam: event.beam || null,\n\t\t\t\t\tstemDirection: event.stemDirection,\n\t\t\t\t\tgrace: !!event.grace,\n\t\t\t\t\ttremoloCatcher: event.tremoloCatcher,\n\t\t\t\t\ttimeWarped: !!event.timeWarp,\n\t\t\t\t\tfullMeasure: event.fullMeasureRest,\n\t\t\t\t\ttick: event.tick || 0,\n\t\t\t\t\tfake: !event.fullMeasureRest && !event.grace && this.voices && !trueEventIds.has(event.id), // tremoloCatcher deemed as fake\n\t\t\t\t}));\n\t\t\t\tif (!elements.some((elem) => !elem.fake)) return null;\n\n\t\t\t\tconst signatureDuration = fractionMul(WHOLE_DURATION, this.timeSignature);\n\n\t\t\t\t// BOS & EOS\n\t\t\t\telements.unshift({\n\t\t\t\t\tindex: 0,\n\t\t\t\t\ttype: EventElementType.BOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.left,\n\t\t\t\t\tpivotX: this.position.left,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: this.duration < signatureDuration,\n\t\t\t\t\ttick: 0,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\t\t\t\telements.push({\n\t\t\t\t\tindex: -1,\n\t\t\t\t\ttype: EventElementType.EOS,\n\t\t\t\t\tstaff: null,\n\t\t\t\t\tdivision: null,\n\t\t\t\t\tbeam: null,\n\t\t\t\t\tdots: null,\n\t\t\t\t\tstemDirection: null,\n\t\t\t\t\tgrace: false,\n\t\t\t\t\ttremoloCatcher: false,\n\t\t\t\t\tfullMeasure: false,\n\t\t\t\t\tx: this.position.right,\n\t\t\t\t\tpivotX: this.position.right,\n\t\t\t\t\ty1: 0,\n\t\t\t\t\ty2: 0,\n\t\t\t\t\theadY: 0,\n\t\t\t\t\tfeature: null,\n\t\t\t\t\ttimeWarped: false,\n\t\t\t\t\ttick: this.duration,\n\t\t\t\t\tfake: false,\n\t\t\t\t});\n\n\t\t\t\tlet matrixH = null;\n\t\t\t\tif (this.voices) {\n\t\t\t\t\tmatrixH = elements.map(() => elements.map(() => 0));\n\n\t\t\t\t\tthis.voices.forEach((voice) => {\n\t\t\t\t\t\tlet tar = 0;\n\t\t\t\t\t\tvoice.forEach((id) => {\n\t\t\t\t\t\t\tconst src = elements.findIndex((e) => e.index === id);\n\t\t\t\t\t\t\tif (src > 0 && tar >= 0) matrixH[src][tar] = 1;\n\t\t\t\t\t\t\ttar = src;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (tar >= 0) matrixH[elements.length - 1][tar] = 1;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst annotation = { ...this.solutionStat, patched: this.patched };\n\n\t\t\t\tconst backgroundImages =\n\t\t\t\t\tthis.backgroundImages &&\n\t\t\t\t\tthis.backgroundImages.map(({ url, position }) => ({\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t...position,\n\t\t\t\t\t\t\ty: position.y - staffY0,\n\t\t\t\t\t\t},\n\t\t\t\t\t}));\n\n\t\t\t\treturn new EventCluster({\n\t\t\t\t\tindex: this.measureIndex,\n\t\t\t\t\tduration: this.duration,\n\t\t\t\t\tsignatureDuration,\n\t\t\t\t\tstaffY0,\n\t\t\t\t\telements,\n\t\t\t\t\tmatrixH,\n\t\t\t\t\tannotation,\n\t\t\t\t\tbackgroundImages,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t}\n\n\tapplyClusters(clusters: EventCluster[]): void {\n\t\tconst id_max = this.events.reduce((max, event) => Math.max(max, event.id), 0) + 1;\n\t\tthis.matrixH = Array(id_max + 1)\n\t\t\t.fill(null)\n\t\t\t.map(() => Array(id_max).fill(0));\n\n\t\tclusters.forEach((cluster) => {\n\t\t\tconst ids = cluster.elements.map((e) => e.index);\n\t\t\tconsole.assert(cluster.matrixH.length === ids.length - 1, 'unexpected matrixH size:', cluster.matrixH.length, ids.length);\n\n\t\t\tfor (let is = 1; is < ids.length; ++is) {\n\t\t\t\tfor (let it = 0; it < ids.length - 1; ++it) {\n\t\t\t\t\tconst srcId = ids[is] < 0 ? id_max : ids[is];\n\t\t\t\t\tconst tarId = ids[it];\n\n\t\t\t\t\tthis.matrixH[srcId][tarId] = cluster.matrixH[is - 1][it];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// event predisposition\n\t\t\tcluster.elements.forEach((elem) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === elem.index);\n\t\t\t\tif (event) {\n\t\t\t\t\tevent.predisposition = elem.predisposition;\n\t\t\t\t\tif (event.predisposition.grace !== undefined) event.grace = event.predisposition.grace ? GraceType.Grace : null;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t// estimated measure duration\n\t\tthis.estimatedDuration = clusters.reduce((sum, cluster) => sum + cluster.estimatedDuration, 0) / clusters.length;\n\t}\n}\n\nexport { SpartitoMeasure, EquationPolicy };\n","import { MetaNotation, TokenPosition } from '../performer';\nimport { Hash, HashVector, cosHashes, hashToHex, hashToBigInt } from './hashVector';\nimport { EventTerm, ContextedTerm, TermPitch, TempoTerm, WHOLE_DURATION } from './term';\nimport { VoicesStaff, VoiceMeasure, TermMeasure, TermVoice, Performing, RegulationOptions } from './interfaces';\nimport { reducedFraction, argmax, noteToPitch, frac, printFraction, fractionMul } from './utils';\nimport { TokenType } from './token';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { Logger, DummyLogger } from './logger';\n\nexport const emptyVoiceFromStaffMeasure = (staff: TermMeasure, chiefVoice: boolean = false): VoiceMeasure => {\n\treturn {\n\t\tempty: true,\n\t\tduration: staff.duration,\n\t\ttickMap: {\n\t\t\t[0]: EventTerm.space({ duration: staff.duration, tick: 0 }),\n\t\t},\n\t\ttimeSignature: staff.timeSignature,\n\t\ttimeSigNumeric: staff.timeSigNumeric,\n\t\tkeySignature: staff.keySignature,\n\t\tcontextedTerms: staff.terms.filter((term) => term instanceof ContextedTerm && (!term.staffLevel || chiefVoice)) as ContextedTerm[],\n\t\tmarks: [],\n\t};\n};\n\nconst removeEmptyMeasuresInVoicesStaves = (staves: VoicesStaff[]): void => {\n\t//console.assert(staves[0] && staves[0].voices[0], 'voices is empty:', staves);\n\tif (!(staves[0] && staves[0].voices[0])) {\n\t\tconsole.warn('empty voices:', staves);\n\t\treturn;\n\t}\n\n\tconst measureCount = staves[0].voices[0].measures.length;\n\tconst measureEmpties = Array(measureCount)\n\t\t.fill(null)\n\t\t.map((_, m) => {\n\t\t\tfor (const staff of staves) {\n\t\t\t\tfor (const voice of staff.voices) {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tif (!measure.empty) return false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\tmeasureEmpties.forEach((empty, m) => {\n\t\tif (empty) {\n\t\t\tstaves.forEach((staff) =>\n\t\t\t\tstaff.voices.forEach((voice) => {\n\t\t\t\t\tconst measure = voice.measures[m];\n\t\t\t\t\tmeasure.tickMap = {};\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t});\n};\n\nconst markingTiesInVoice = (voice: TermVoice) => {\n\tconst events = [].concat(...voice.measures.map((m) => Object.values(m.tickMap).filter((event) => event instanceof EventTerm)));\n\t//console.log(\"events:\", events);\n\n\tfor (let i = 1; i < events.length; ++i) {\n\t\tconst event0 = events[i - 1];\n\t\tconst event1 = events[i];\n\t\tif (!event0.rest && !event1.rest) {\n\t\t\tif (event0.accessories.some((acc) => acc.type === TokenType.SlurBegin) && event1.accessories.some((acc) => acc.type === TokenType.SlurEnd)) {\n\t\t\t\tconst pitches = event0.pitches.filter((p0) => event1.pitches.some((p1) => p1.note === p0.note && p1.alter === p0.alter));\n\t\t\t\tif (pitches.length > 0) {\n\t\t\t\t\tevent0.tying = true;\n\t\t\t\t\tevent1.tied = true;\n\n\t\t\t\t\tpitches.forEach((p0) => {\n\t\t\t\t\t\tp0.tying = true;\n\t\t\t\t\t\tconst p1 = event1.pitches.find((p1) => p1.note === p0.note && p1.alter === p0.alter);\n\t\t\t\t\t\tp1.tied = true;\n\t\t\t\t\t});\n\n\t\t\t\t\t// remove slurs from accessories\n\t\t\t\t\tpitches.forEach(() => {\n\t\t\t\t\t\tconst si0 = event0.accessories.findIndex((acc) => acc.type === TokenType.SlurBegin);\n\t\t\t\t\t\tif (si0 >= 0) event0.accessories.splice(si0, 1);\n\n\t\t\t\t\t\tconst si1 = event1.accessories.findIndex((acc) => acc.type === TokenType.SlurEnd);\n\t\t\t\t\t\tif (si1 >= 0) event1.accessories.splice(si1, 1);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nclass Spartito extends SimpleClass {\n\tstatic className = 'Spartito';\n\n\tstavesCount: number;\n\tstaffGroups: number[][];\n\tmeasures: SpartitoMeasure[];\n\n\ttags: string[];\n\n\tconstructor(data: any) {\n\t\tsuper();\n\t\tsuper.assign(data);\n\n\t\tthis.measures.forEach((measure) => (measure.staffGroups = this.staffGroups));\n\t}\n\n\tget regulated(): boolean {\n\t\treturn this.measures.every((m) => m.regulated);\n\t}\n\n\tget solidMeasureCount(): number {\n\t\treturn this.measures.filter((measure) => !measure.empty).length;\n\t}\n\n\tget measureIndexMapping(): number[] {\n\t\tlet n = 0;\n\t\treturn this.measures.map((measure) => {\n\t\t\treturn !measure.empty ? n++ : null;\n\t\t});\n\t}\n\n\tget headBPM(): number {\n\t\tfor (const measure of this.measures) {\n\t\t\tif (measure.marks) {\n\t\t\t\tconst tempoMark = measure.marks.find((mark) => mark instanceof TempoTerm && mark.isValid()) as TempoTerm;\n\t\t\t\tif (tempoMark) return tempoMark.bpm;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tget measureLayoutCode(): string {\n\t\tconst ms = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure, i) => ({\n\t\t\t\tindex: i + 1,\n\t\t\t\tvb: measure.voltaBegin,\n\t\t\t\tve: measure.voltaEnd,\n\t\t\t\talter: measure.alternative,\n\t\t\t\tleftSign: '',\n\t\t\t\trightSign: '',\n\t\t\t}));\n\t\tms.forEach((m, i) => {\n\t\t\tif (m.vb) {\n\t\t\t\tconst nextI = ms.slice(i + 1).findIndex((mm) => mm.vb);\n\t\t\t\tconst nextVBI = nextI >= 0 ? i + nextI : ms.length;\n\t\t\t\tif (ms.slice(i, nextVBI - 1).some((mm) => mm.ve))\n\t\t\t\t\t// check if volta range closed\n\t\t\t\t\tm.leftSign = '2*[';\n\t\t\t}\n\n\t\t\tif (m.ve) {\n\t\t\t\tconst pms = ms.slice(0, i + 1).reverse();\n\t\t\t\tconst lastVEI = pms.slice(1).findIndex((mm) => mm.ve);\n\t\t\t\tif (lastVEI >= 0) {\n\t\t\t\t\tif (!pms.slice(1, lastVEI + 1).some((mm) => mm.vb))\n\t\t\t\t\t\t// ignore unclosed right volta\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (m.alter) {\n\t\t\t\t\tconst lastMI = pms.findIndex((m) => !m.alter);\n\t\t\t\t\tif (lastMI > 0) {\n\t\t\t\t\t\tpms[lastMI].rightSign = ']';\n\t\t\t\t\t\tpms[lastMI - 1].leftSign = '{[';\n\n\t\t\t\t\t\tm.rightSign = '],';\n\n\t\t\t\t\t\tif (ms[i + 1]) ms[i + 1].rightSign = '},';\n\t\t\t\t\t}\n\t\t\t\t} else m.rightSign = '],';\n\n\t\t\t\tif (!pms.some((m) => m.vb)) ms[0].leftSign = '2*[';\n\t\t\t}\n\t\t});\n\n\t\treturn ms\n\t\t\t.map((m) => m.leftSign + m.index.toString() + m.rightSign + (m.rightSign ? '' : ','))\n\t\t\t.join(' ')\n\t\t\t.replace(/,$/, '');\n\t}\n\n\tget qualityScore(): number {\n\t\tconst measures = this.measures.filter((measure) => !measure.empty);\n\t\tconst qss = measures.map(evaluateMeasure).map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\t//console.log('qss:', qss);\n\n\t\treturn measures.length ? sum / measures.length : null;\n\t}\n\n\tdumpEvaluations(): void {\n\t\tconst es = this.measures.filter((measure) => !measure.empty).map((m) => ({ measureIndex: m.measureIndex, ...evaluateMeasure(m) }));\n\t\tconst qss = es.map((e) => e.qualityScore);\n\t\tconst sum = qss.reduce((a, b) => a + b, 0);\n\t\tconsole.log('qualityScore:', sum / es.length);\n\n\t\tconsole.table(es);\n\t}\n\n\tregulate(options: RegulationOptions = {}): void {\n\t\tthis.measures.forEach((m) => m.regulated || m.regulate(options));\n\t}\n\n\tcleanupRegulation(): void {\n\t\tthis.measures.forEach((m) => (m.voices = null));\n\t}\n\n\t// measures' estimatedDuration should be valid\n\trectifyTimeSignatures(logger: Logger = new DummyLogger()): void {\n\t\tconst mis = this.measures\n\t\t\t.map((measure, index) => ({ measure, index }))\n\t\t\t.filter(({ measure, index }) => !index || measure.timeSignatureChanged)\n\t\t\t.map(({ index }) => index);\n\t\tconst segments = mis\n\t\t\t.map((index, si) => this.measures.slice(index, si < mis.length - 1 ? mis[si + 1] : this.measures.length))\n\t\t\t.map((ms) => ms.filter((m) => m.estimatedDuration > 0))\n\t\t\t.filter((seg) => seg.length >= 3 || seg.some((measure) => measure.doubtfulTimesig));\n\t\t//console.log(\"segments:\", segments.map(ms => ms.map(m => m.measureIndex)));\n\n\t\tsegments.forEach((measures) => {\n\t\t\tif (measures[0].patched) {\n\t\t\t\t// rectify according to patched head measure\n\t\t\t\tconst newTimeSignature = measures[0].timeSignature;\n\t\t\t\tconst measuresToFix = measures\n\t\t\t\t\t.slice(1)\n\t\t\t\t\t.filter((measure) => !measure.patched && printFraction(measure.timeSignature) !== printFraction(newTimeSignature));\n\t\t\t\tif (measuresToFix.length) {\n\t\t\t\t\tconst originTimeSignature = measuresToFix[0].timeSignature;\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by patched head:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${printFraction(newTimeSignature)}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst originTimeSignature = measures[0].timeSignature;\n\t\t\tconst regularD = Number.isInteger(Math.log2(originTimeSignature.denominator));\n\n\t\t\tlet denominator = regularD ? 4 : 8;\n\t\t\tif (regularD) denominator = Math.max(denominator, measures[0].timeSignature.denominator);\n\n\t\t\tconst numerators = measures.map((measure) => Math.round((measure.estimatedDuration * denominator) / WHOLE_DURATION));\n\t\t\tconst countings = Object.entries(numerators.reduce((c, n) => ((c[n] = (c[n] || 0) + 1), c), {} as Record)).sort(\n\t\t\t\t(p1, p2) => p2[1] - p1[1]\n\t\t\t);\n\t\t\tconst peakCount = countings[0][1];\n\t\t\tconst candidateNumerators = countings.filter(([_, c]) => c > peakCount * 0.6);\n\t\t\tconst bestCounting = candidateNumerators.reduce((best, c) => (Number(c[0]) > Number(best[0]) ? c : best));\n\t\t\tif (bestCounting[1] > 1) {\n\t\t\t\t//console.log(\"countings:\", countings, bestCounting[0]);\n\t\t\t\tlet numerator = Number(bestCounting[0]);\n\t\t\t\tif (!regularD || originTimeSignature.denominator * numerator !== originTimeSignature.numerator * denominator) {\n\t\t\t\t\tif (regularD && denominator !== originTimeSignature.denominator) {\n\t\t\t\t\t\tconst reducedN = (numerator * originTimeSignature.denominator) / denominator;\n\t\t\t\t\t\tif (Number.isInteger(reducedN)) {\n\t\t\t\t\t\t\tnumerator = reducedN;\n\t\t\t\t\t\t\tdenominator = originTimeSignature.denominator;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst measuresToFix = measures.filter((measure) => !measure.patched);\n\n\t\t\t\t\tconst newTimeSignature = frac(numerator, denominator);\n\t\t\t\t\tmeasuresToFix.forEach((measure) => measure.basics.forEach((basic) => (basic.timeSignature = newTimeSignature)));\n\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t'[rectifyTimeSignatures]\ttimesignator overwrote by estimation:',\n\t\t\t\t\t\t`${printFraction(originTimeSignature)} -> ${numerator}/${denominator}`,\n\t\t\t\t\t\tmeasuresToFix.map((m) => m.measureIndex)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tmakeVoiceStaves(): VoicesStaff[] {\n\t\tthis.regulate();\n\n\t\tconst voiceCount = Math.max(...this.measures.map((measure) => measure.voices.length));\n\t\tif (!voiceCount || !Number.isFinite(voiceCount)) return null;\n\n\t\t// mark tied pitches for patched measues\n\t\tthis.measures\n\t\t\t.filter((measure) => measure.patched)\n\t\t\t.forEach((measure) => {\n\t\t\t\tmeasure.events.forEach((event) => {\n\t\t\t\t\tif (event.tied) event.pitches.forEach((pitch) => (pitch.tied = true));\n\t\t\t\t});\n\t\t\t});\n\n\t\t// [measure, voice]\n\t\tconst measures: VoiceMeasure[][] = this.measures.map((measure /*, mi*/) => {\n\t\t\tconsole.assert(measure.validRegulated, '[makeVoiceStaves] measure is invalid:', measure);\n\n\t\t\tconst eventMap: { [key: number]: EventTerm } = {};\n\t\t\tmeasure.events.forEach((event) => (eventMap[event.id] = event));\n\n\t\t\tconst leftStaves = new Set(\n\t\t\t\tArray(measure.contexts.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map((_, i) => i)\n\t\t\t);\n\n\t\t\tlet bar = null;\n\t\t\tif (measure.barType) {\n\t\t\t\tswitch (measure.barType) {\n\t\t\t\t\tcase 'Segment':\n\t\t\t\t\t\tbar = '||';\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Terminal':\n\t\t\t\t\t\tbar = '|.';\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst voices: VoiceMeasure[] = measure.voices.map((ids /*, vi*/) => {\n\t\t\t\tconst events = ids.map((id) => eventMap[id]);\n\t\t\t\tevents.sort((e1, e2) => e1.tick - e2.tick);\n\n\t\t\t\tconst tickMap = {};\n\t\t\t\tlet tick = 0;\n\t\t\t\tlet lastEvent = null;\n\t\t\t\tfor (const event of events) {\n\t\t\t\t\tif (!Number.isFinite(event?.tick)) {\n\t\t\t\t\t\tconsole.warn('invalid event tick:', event);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (event.tick > tick) tickMap[tick] = EventTerm.space({ tick, duration: event.tick - tick });\n\t\t\t\t\telse if (!event.grace && event.tick < tick && lastEvent)\n\t\t\t\t\t\tlastEvent.timeWarp = reducedFraction(event.tick - lastEvent.tick, lastEvent.duration);\n\t\t\t\t\t//console.log(\"timewarp:\", event.tick - lastEvent.tick, lastEvent.duration, lastEvent.timeWarp);\n\n\t\t\t\t\ttickMap[event.tick] = event;\n\n\t\t\t\t\tif (!event.zeroHolder) {\n\t\t\t\t\t\ttick = Math.round(event.tick + event.duration);\n\t\t\t\t\t\tlastEvent = event;\n\n\t\t\t\t\t\t// sub grace events\n\t\t\t\t\t\tif (event.graceIds) {\n\t\t\t\t\t\t\tevent.graceIds.forEach((id) => {\n\t\t\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\t\t\tif (grace) tickMap[grace.tick] = grace;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (measure.endEvent && measure.endEvent.graceIds) {\n\t\t\t\t\tmeasure.endEvent.graceIds.forEach((id) => {\n\t\t\t\t\t\tconst grace = measure.eventMap[id];\n\t\t\t\t\t\tif (grace && (!lastEvent || grace.staff === lastEvent.staff)) tickMap[grace.tick] = grace;\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (tick < measure.duration) tickMap[tick] = EventTerm.space({ tick, duration: measure.duration - tick });\n\t\t\t\telse if (tick > measure.duration && Number.isFinite(measure.duration))\n\t\t\t\t\t//console.warn(\"duration out of range:\", tick, column.duration, mi, vi);\n\t\t\t\t\tlastEvent.timeWarp = reducedFraction(measure.duration - lastEvent.tick, lastEvent.duration);\n\n\t\t\t\tconsole.assert(\n\t\t\t\t\t!lastEvent || !lastEvent.timeWarp || (Number.isInteger(lastEvent.timeWarp.numerator) && Number.isInteger(lastEvent.timeWarp.denominator)),\n\t\t\t\t\t'invalid time warp:',\n\t\t\t\t\tlastEvent\n\t\t\t\t);\n\n\t\t\t\tconst staffIndex = events[0] ? events[0].staff : 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\n\t\t\t\t//const row = measure.rows[staffIndex];\n\t\t\t\tconst contextedTerms = measure.contexts[staffIndex];\n\n\t\t\t\tconst tailEvent = events[events.length - 1];\n\t\t\t\tconst tailStaff = tailEvent ? tailEvent.staff : 0;\n\n\t\t\t\t// TODO: modify full measure rests duration\n\n\t\t\t\treturn {\n\t\t\t\t\ttickMap,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t...basic,\n\t\t\t\t\t// TODO: consider staff altered voice\n\t\t\t\t\tcontextedTerms,\n\t\t\t\t\tmarks: [],\n\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\theadStaff: staffIndex,\n\t\t\t\t\ttailStaff,\n\t\t\t\t\tbar,\n\t\t\t\t};\n\t\t\t});\n\n\t\t\twhile (voices.length < voiceCount) {\n\t\t\t\tconst staffIndex = leftStaves.values().next().value || 0;\n\t\t\t\tleftStaves.delete(staffIndex);\n\n\t\t\t\tconst basic = measure.basics[staffIndex];\n\t\t\t\tconst terms = measure.contexts[staffIndex];\n\n\t\t\t\tconst chiefVoice = voices.every((voice) => voice.headStaff !== staffIndex);\n\n\t\t\t\tconst voice = emptyVoiceFromStaffMeasure(\n\t\t\t\t\t{\n\t\t\t\t\t\tterms,\n\t\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\t\t...basic,\n\t\t\t\t\t\tbreak: measure.break,\n\t\t\t\t\t\tpageBreak: measure.pageBreak,\n\t\t\t\t\t},\n\t\t\t\t\tchiefVoice\n\t\t\t\t);\n\t\t\t\tvoice.headStaff = staffIndex;\n\t\t\t\tvoice.tailStaff = staffIndex;\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\n\t\t\treturn voices;\n\t\t});\n\t\t//console.log(\"measures:\", measures);\n\n\t\t// compute traits for voice-measures\n\t\tmeasures.forEach((voices) =>\n\t\t\tvoices.forEach((measure) => {\n\t\t\t\tconst words = [];\n\n\t\t\t\tif (!measure.empty) {\n\t\t\t\t\twords.push(`s${measure.headStaff}`);\n\t\t\t\t\twords.push(`s${measure.tailStaff}`);\n\t\t\t\t}\n\n\t\t\t\tObject.values(measure.tickMap).forEach((event) => {\n\t\t\t\t\tif (event instanceof EventTerm) {\n\t\t\t\t\t\twords.push(`s${event.staff}`);\n\n\t\t\t\t\t\tif (event.stemDirection) {\n\t\t\t\t\t\t\tconst sd = `st${event.staff}-${event.stemDirection}`;\n\t\t\t\t\t\t\twords.push(sd, sd);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (event.grace) words.push(`gd${event.mainDuration}`);\n\t\t\t\t\t\telse words.push(`d${event.mainDuration}`);\n\n\t\t\t\t\t\tif (event.rest) words.push('r-' + event.rest);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tevent.pitches.forEach((pitch) => {\n\t\t\t\t\t\t\t\twords.push(`p1-${pitch.note}`);\n\t\t\t\t\t\t\t\twords.push(`p8-${Math.round(pitch.note / 8)}`);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tmeasure.trait = HashVector.fromWords(words);\n\t\t\t})\n\t\t);\n\t\t//console.log(\"measure traits:\");\n\t\t//console.table(measures.map(voices => voices.map(measure => hashToHex(measure.trait.toHash()))));\n\n\t\tconst staffToGroup: Record = this.staffGroups\n\t\t\t.flat(1)\n\t\t\t.reduce((map, si) => ((map[si] = this.staffGroups.findIndex((group) => group.includes(si))), map), {});\n\n\t\t// sort voices to connect voices between neighhoring measures\n\t\tconst voiceTraits = Array(voiceCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, index) => ({ vector: HashVector.zero, index, weight: 0, headStaff: null }));\n\t\tmeasures.forEach((voices, mi) => {\n\t\t\tvoiceTraits.sort((v1, v2) => v2.weight - v1.weight);\n\n\t\t\tconst leftVoices = new Set(voices);\n\t\t\tvoiceTraits.forEach((voiceTrait) => {\n\t\t\t\tconst vs = [...leftVoices];\n\t\t\t\tlet measure = vs[0];\n\t\t\t\tif (mi > 0 && vs.length > 1) {\n\t\t\t\t\tconst consistencies = vs.map((measure) =>\n\t\t\t\t\t\tstaffToGroup[measure.headStaff] === staffToGroup[voiceTrait.headStaff]\n\t\t\t\t\t\t\t? cosHashes(voiceTrait.vector.toHash(), measure.trait.toHash())\n\t\t\t\t\t\t\t: -1\n\t\t\t\t\t);\n\t\t\t\t\tmeasure = vs[argmax(consistencies)];\n\t\t\t\t}\n\t\t\t\tleftVoices.delete(measure);\n\n\t\t\t\tmeasure.voiceIndex = voiceTrait.index;\n\t\t\t\tvoiceTrait.vector.scale(0.4).add(measure.trait);\n\n\t\t\t\tvoiceTrait.weight = Object.keys(measure.tickMap).length;\n\n\t\t\t\tif (mi === 0) voiceTrait.headStaff = measure.headStaff;\n\t\t\t});\n\n\t\t\tvoices.sort((m1, m2) => m1.voiceIndex - m2.voiceIndex);\n\t\t});\n\n\t\t//const staffTraits = Array(this.stavesCount).fill(null).map((_, si) => HashVector.fromString(`s${si}`).toHash());\n\t\tconst staffVoiceIndices = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map(() => []);\n\t\tvoiceTraits.forEach((trait) => {\n\t\t\t//const consistencies = staffTraits.map(staff => cosHashes(trait.vector.toHash(), staff));\n\t\t\t//staffVoiceIndices[argmax(consistencies)].push(trait.index);\n\t\t\tstaffVoiceIndices[trait.headStaff].push(trait.index);\n\t\t});\n\n\t\tconst staves = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, si) => {\n\t\t\t\tif (!measures[0]) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tvoices: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t//const voiceIndicies = measures[0].map((voice, vi) => ({ voice, vi })).filter(({ voice }) => voice.headStaff === si).map(({ vi }) => vi);\n\t\t\t\tconst voiceIndicies = staffVoiceIndices[si];\n\n\t\t\t\tconst voices = voiceIndicies.map((vi): TermVoice => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tmode: 'relative',\n\t\t\t\t\t\tmeasures: measures.map((m) => m[vi]),\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\treturn { voices };\n\t\t\t});\n\n\t\tremoveEmptyMeasuresInVoicesStaves(staves);\n\t\tstaves.forEach((staff) => staff.voices.forEach(markingTiesInVoice));\n\n\t\treturn staves;\n\t}\n\n\tperform(): Performing {\n\t\tconst staves = this.makeVoiceStaves();\n\t\tif (!staves) return null;\n\n\t\tconst tokenMap = new Map();\n\n\t\t// TODO: store staff channels in score\n\t\tconst staffToChannel = Array(this.stavesCount)\n\t\t\t.fill(null)\n\t\t\t.reduce((map, _, i) => {\n\t\t\t\tmap[i] = i;\n\t\t\t\treturn map;\n\t\t\t}, {});\n\n\t\tconst voiceChannels = [].concat(...staves.map((staff, si) => staff.voices.map(() => staffToChannel[si])));\n\n\t\tlet hasTempo = false;\n\n\t\tlet nextTick = 0;\n\t\tlet events0 = null;\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => !measure.empty)\n\t\t\t.map((measure) => {\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst voices: VoiceMeasure[] = [].concat(...staves.map((staff) => staff.voices.map((voice) => voice.measures[measureIndex])));\n\t\t\t\tconst voice0 = voices[0];\n\t\t\t\tconst tick = nextTick;\n\n\t\t\t\t//const signatureDuration = (WHOLE_DURATION * voice0.timeSignature.numerator) / voice0.timeSignature.denominator;\n\n\t\t\t\tnextTick += voice0.duration;\n\n\t\t\t\tconst notes = [].concat(\n\t\t\t\t\t...voices.map((measure, vi) => {\n\t\t\t\t\t\tconst tickFactor = 1; //measure.duration ? signatureDuration / measure.duration : 1;\n\n\t\t\t\t\t\tconst channel = voiceChannels[vi];\n\n\t\t\t\t\t\tconst chords = Object.values(measure.tickMap)\n\t\t\t\t\t\t\t.filter((term) => term instanceof EventTerm && !term.rest)\n\t\t\t\t\t\t\t.map((term: EventTerm) => {\n\t\t\t\t\t\t\t\tconst duration = Math.round(term.duration * tickFactor);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(term.tick), 'invalid event term tick:', term);\n\t\t\t\t\t\t\t\tconsole.assert(Number.isFinite(duration), 'invalid event term duration:', term);\n\n\t\t\t\t\t\t\t\tif (term.tick >= 0) {\n\t\t\t\t\t\t\t\t\t// exclude minus tick tokens\n\t\t\t\t\t\t\t\t\tterm.noteIds.forEach((id) => {\n\t\t\t\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: term.roundX,\n\t\t\t\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(term.staff));\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttick: Math.round(term.tick * tickFactor),\n\t\t\t\t\t\t\t\t\tduration,\n\t\t\t\t\t\t\t\t\tpitches: term.pitches,\n\t\t\t\t\t\t\t\t\tnoteIds: term.noteIds,\n\t\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\t\tstaff: term.staff,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn [].concat(\n\t\t\t\t\t\t\t...chords.map((chord) => {\n\t\t\t\t\t\t\t\t// exclude repeated pitches\n\t\t\t\t\t\t\t\tconst pitchMap: { [pitch: number]: TermPitch } = chord.pitches.reduce((map, pitch) => {\n\t\t\t\t\t\t\t\t\tmap[noteToPitch(pitch)] = pitch;\n\t\t\t\t\t\t\t\t\treturn map;\n\t\t\t\t\t\t\t\t}, {});\n\t\t\t\t\t\t\t\tconst pitches = Object.values(pitchMap).sort((p1, p2) => p1.note - p2.note);\n\n\t\t\t\t\t\t\t\treturn pitches\n\t\t\t\t\t\t\t\t\t.filter((pitch) => !pitch.tied)\n\t\t\t\t\t\t\t\t\t.map((pitch, i) => {\n\t\t\t\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\ttick: chord.tick,\n\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\t\t\t\ttrack: chord.part,\n\t\t\t\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\t\t\t\tchannel,\n\t\t\t\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst events = [];\n\t\t\t\tevents0 = events0 || events;\n\n\t\t\t\tif (measure.marks)\n\t\t\t\t\tmeasure.marks.forEach((mark) => {\n\t\t\t\t\t\tif (mark instanceof TempoTerm) {\n\t\t\t\t\t\t\tconst bpm = mark.bpm;\n\t\t\t\t\t\t\tif (mark.isValid()) {\n\t\t\t\t\t\t\t\tconst es = hasTempo ? events : events0; // set the first tempo to the beginning of the track\n\t\t\t\t\t\t\t\tconst tick = hasTempo ? mark.tick : 0;\n\t\t\t\t\t\t\t\tes.push({\n\t\t\t\t\t\t\t\t\ttrack: 0,\n\t\t\t\t\t\t\t\t\tticks: tick,\n\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\t\t\t\t\t\tmicrosecondsPerBeat: Math.round(60e6 / bpm),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\thasTempo = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration: measure.duration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents,\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tif (!hasTempo) {\n\t\t\tmeasures[0].events.push({\n\t\t\t\ttrack: 0,\n\t\t\t\tticks: 0,\n\t\t\t\tdata: {\n\t\t\t\t\ttype: 'meta',\n\t\t\t\t\tsubtype: 'setTempo',\n\t\t\t\t\tmicrosecondsPerBeat: 0.5e6, // TODO\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tperformByEstimation(): Performing {\n\t\tconst tokenMap = new Map();\n\t\tlet nextTick = 0;\n\n\t\tconst measures = this.measures\n\t\t\t.filter((measure) => measure.events.some((event) => event.predisposition))\n\t\t\t.map((measure) => {\n\t\t\t\tconst tick = nextTick;\n\t\t\t\tconst duration = Math.round(measure.estimatedDuration || fractionMul(WHOLE_DURATION, measure.timeSignature));\n\t\t\t\tconst basic = measure.basics[0];\n\n\t\t\t\tnextTick += duration;\n\n\t\t\t\tconst { systemIndex, right: endX } = measure.position;\n\t\t\t\tconst measureIndex = measure.measureIndex;\n\n\t\t\t\tconst chords = measure.events.filter((event) => event.predisposition && event.predisposition.fake < 0.5 && !event.rest);\n\t\t\t\tconst notes = chords\n\t\t\t\t\t.map((chord) => {\n\t\t\t\t\t\tconst noteTick = Math.round(chord.predisposition.tick);\n\n\t\t\t\t\t\tchord.noteIds.forEach((id) => {\n\t\t\t\t\t\t\ttokenMap.set(id, {\n\t\t\t\t\t\t\t\tsystem: systemIndex,\n\t\t\t\t\t\t\t\tmeasure: measureIndex,\n\t\t\t\t\t\t\t\tx: chord.roundX,\n\t\t\t\t\t\t\t\tendX,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn chord.pitches.map((pitch, i) => {\n\t\t\t\t\t\t\tconst pitchValue = noteToPitch(pitch);\n\t\t\t\t\t\t\tconst id = chord.noteIds && chord.noteIds[i];\n\t\t\t\t\t\t\tconst part = this.staffGroups.findIndex((group) => group.includes(chord.staff));\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttick: noteTick,\n\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\tduration: chord.duration,\n\t\t\t\t\t\t\t\tchordPosition: {\n\t\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\t\tcount: chord.pitches.length,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ttied: pitch.tied,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tids: [id],\n\t\t\t\t\t\t\t\ttrack: part,\n\t\t\t\t\t\t\t\tstaff: chord.staff,\n\t\t\t\t\t\t\t\tchannel: 0,\n\t\t\t\t\t\t\t\tsubNotes: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstartTick: 0,\n\t\t\t\t\t\t\t\t\t\tendTick: chord.duration,\n\t\t\t\t\t\t\t\t\t\tpitch: pitchValue,\n\t\t\t\t\t\t\t\t\t\tvelocity: 127,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t})\n\t\t\t\t\t.flat(1);\n\n\t\t\t\treturn {\n\t\t\t\t\ttick,\n\t\t\t\t\tduration,\n\t\t\t\t\tnotes,\n\t\t\t\t\tevents: [],\n\t\t\t\t\ttimeSignature: basic && basic.timeSignature,\n\t\t\t\t\tkeySignature: basic && basic.keySignature,\n\t\t\t\t};\n\t\t\t});\n\n\t\tconst notation = new MetaNotation({ measures });\n\n\t\treturn {\n\t\t\tnotation,\n\t\t\ttokenMap,\n\t\t};\n\t}\n\n\tfeatureHash(): Hash {\n\t\tconst headMeasures = this.measures.slice(0, 16);\n\t\tconst measureWords = headMeasures.map((measure) => measure.featureWords);\n\n\t\tconst levels = [1, 4, 16].map((len) => {\n\t\t\tconst meaures = measureWords.slice(0, len).filter(Boolean);\n\t\t\tconst ys = meaures.map((words) => words[0]).flat(1);\n\t\t\tconst melodies = meaures.map((words) => words[1]).flat(1);\n\t\t\tconst rhythm = meaures.map((words) => words[2]).flat(1);\n\n\t\t\tconst [vecY, vecMelody, vecRhythm] = [ys, melodies, rhythm].map(HashVector.fromWords);\n\n\t\t\treturn HashVector.concat(vecY, vecMelody.sub(128), vecRhythm.sub(128));\n\t\t});\n\n\t\treturn HashVector.concat(...levels).toHash();\n\t}\n\n\tfeatureHashHex(): string {\n\t\treturn hashToHex(this.featureHash());\n\t}\n\n\tfeatureHashBigInt(): bigint {\n\t\treturn hashToBigInt(this.featureHash());\n\t}\n\n\tassignMeasureNumbers(): void {\n\t\tlet n = null as any;\n\t\tfor (const measure of this.measures) {\n\t\t\tif (!measure.discard && !measure.events.length) continue;\n\n\t\t\tif (measure.indent) n = null;\n\n\t\t\tif (!Number.isFinite(n)) n = measure.partialDuration ? 0 : 1;\n\n\t\t\tmeasure.measureNumber = n++;\n\t\t}\n\t}\n}\n\nexport { SpartitoMeasure, Spartito };\n","import { Fraction } from './interfaces';\nimport { ContextedTerm, ContextType } from './term';\nimport { Logger, DummyLogger } from './logger';\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nexport const mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst PHONETS = 'CDEFGAB';\n\nconst ALTER_NAMES = {\n\t[-2]: '\\u266D\\u266D',\n\t[-1]: '\\u266D',\n\t[0]: '\\u266E',\n\t[1]: '\\u266F',\n\t[2]: '\\uD834\\uDD2A',\n};\n\n/*\n\tCoordinates:\n\n\t\tnote:\n\t\t\tzero: the middle C line (maybe altered)\n\t\t\tpositive: high (right on piano keyboard)\n\t\t\tunit: a step in scales of the current staff key\n\n\t\tstaff Y:\n\t\t\tzero: the third (middle) line among 5 staff lines\n\t\t\tpositive: down\n\t\t\tunit: a interval between 2 neighbor staff lines\n*/\n\nexport default class StaffContext {\n\tlogger: Logger = new DummyLogger();\n\n\tclef: number = -3;\n\tkeyAlters: number[] = [];\n\toctaveShift: number = 0;\n\talters: number[] = [];\n\n\ttimeSignature: Fraction = {\n\t\tnumerator: 4,\n\t\tdenominator: 4,\n\t};\n\ttimeSigNumeric: boolean = false;\n\ttimeSigNumSet: boolean = false;\n\ttimeSigDenSet: boolean = false;\n\tdoubtingTimesig: boolean = true;\n\n\tchange(term: ContextedTerm) {\n\t\tswitch (term.type) {\n\t\t\tcase ContextType.Clef:\n\t\t\t\tthis.clef = term.clef;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.KeyAcc:\n\t\t\t\tthis.keyAlters[mod7(this.yToNote(term.y))] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.Acc:\n\t\t\t\tthis.alters[this.yToNote(term.y)] = term.alter;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.OctaveShift:\n\t\t\t\tthis.octaveShift = term.octaveShift;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureC:\n\t\t\t\tthis.timeSigNumeric = false;\n\t\t\t\tswitch (term.tokenType) {\n\t\t\t\t\tcase 'timesig-C44':\n\t\t\t\t\t\tthis.timeSignature.numerator = 4;\n\t\t\t\t\t\tthis.timeSignature.denominator = 4;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'timesig-C22':\n\t\t\t\t\t\tthis.timeSignature.numerator = 2;\n\t\t\t\t\t\tthis.timeSignature.denominator = 2;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t\tcase ContextType.TimeSignatureN:\n\t\t\t\tthis.timeSigNumeric = true;\n\t\t\t\tswitch (term.y) {\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tif (this.timeSigDenSet) this.timeSignature.denominator = this.timeSignature.denominator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.denominator = term.number;\n\n\t\t\t\t\t\tthis.timeSigDenSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase -1:\n\t\t\t\t\t\tif (this.timeSigNumSet) this.timeSignature.numerator = this.timeSignature.numerator * 10 + term.number;\n\t\t\t\t\t\telse this.timeSignature.numerator = term.number;\n\n\t\t\t\t\t\tthis.timeSigNumSet = true;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.logger.warn('unexpected time signature Y:', term.y);\n\t\t\t\t}\n\t\t\t\tthis.doubtingTimesig = this.partialTimeSignature;\n\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tresetMeasure() {\n\t\tthis.alters = [];\n\n\t\tthis.timeSigNumSet = false;\n\t\tthis.timeSigDenSet = false;\n\t}\n\n\tresetSystem() {\n\t\tthis.keyAlters = [];\n\t}\n\n\tget keySignature(): number {\n\t\treturn this.keyAlters.filter((a) => Number.isInteger(a)).reduce((sum, a) => sum + a, 0);\n\t}\n\n\tget partialTimeSignature(): boolean {\n\t\treturn !this.timeSigNumSet !== !this.timeSigDenSet;\n\t}\n\n\tnoteToY(note: number): number {\n\t\treturn -note / 2 - this.clef - this.octaveShift * 3.5;\n\t}\n\n\tpitchToNote(pitch: number, { preferredAlter = null } = {}): { note: number; alter: number } {\n\t\tif (!preferredAlter) preferredAlter = this.keySignature < 0 ? -1 : 1;\n\n\t\tconst group = Math.floor((pitch - MIDDLE_C) / 12);\n\t\tconst gp = mod12(pitch);\n\t\tconst alteredGp = GROUP_N_TO_PITCH.includes(gp) ? gp : mod12(gp - preferredAlter);\n\t\tconst gn = GROUP_N_TO_PITCH.indexOf(alteredGp);\n\t\tthis.logger.assert(gn >= 0, 'invalid preferredAlter:', pitch, preferredAlter, alteredGp);\n\n\t\tconst naturalNote = group * 7 + gn;\n\n\t\tconst alterValue = gp - alteredGp;\n\t\tconst keyAlterValue = this.keyAlters[gn] || 0;\n\t\tconst onAcc = Number.isInteger(this.alters[naturalNote]);\n\n\t\tconst alter = onAcc ? alterValue : alterValue === keyAlterValue ? null : alterValue;\n\n\t\treturn { note: naturalNote, alter };\n\t}\n\n\tpitchToY(pitch: number, { preferredAlter = null } = {}): { y: number; alter: number } {\n\t\tconst { note, alter } = this.pitchToNote(pitch, { preferredAlter });\n\t\tconst y = this.noteToY(note);\n\n\t\treturn { y, alter };\n\t}\n\n\tyToNote(y: number): number {\n\t\tthis.logger.assert(Number.isInteger(y * 2), 'invalid y:', y);\n\n\t\treturn (-y - this.octaveShift * 3.5 - this.clef) * 2;\n\t}\n\n\talterOnNote(note: number): number {\n\t\tif (Number.isInteger(this.alters[note])) return this.alters[note];\n\n\t\tconst gn = mod7(note);\n\t\tif (Number.isInteger(this.keyAlters[gn])) return this.keyAlters[gn];\n\n\t\treturn 0;\n\t}\n\n\tnoteToPitch(note: number): number {\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tconst pitch = MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + this.alterOnNote(note);\n\t\tif (!Number.isFinite(pitch)) {\n\t\t\tthis.logger.warn('invalid pitch value:', pitch, note, group, gn);\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn pitch;\n\t}\n\n\tyToPitch(y: number): number {\n\t\treturn this.noteToPitch(this.yToNote(y));\n\t}\n\n\tyToPitchName(y: number): string {\n\t\tconst note = this.yToNote(y);\n\t\tconst group = Math.floor(note / 7);\n\t\tconst gn = mod7(note);\n\n\t\tlet alter = this.alterOnNote(note);\n\t\tif (!alter && !Number.isInteger(this.alters[note])) alter = null;\n\n\t\treturn `${ALTER_NAMES[alter] ? ALTER_NAMES[alter] : ''}${PHONETS[gn]}${group + 4}`;\n\t}\n}\n","import sha1 from 'js-sha1';\n\nimport * as measureLayout from '../measureLayout';\nimport * as staffLayout from '../staffLayout';\nimport { SimpleClass } from './aux_/typedJSON';\nimport { EventSystem, MeasureBrief, MusicSheet, RecognitionSettings, ScoreData, TermMeasure, TermStaff, VoicesStaff } from './interfaces';\nimport { DummyLogger, Logger } from './logger';\nimport { evaluateMeasure } from './measureEvaluator';\nimport { PatchMeasure } from './patch';\nimport { Measure, Page, Staff, System } from './scoreComponents';\nimport { hashSemanticPoint, SemanticPoint, SemanticType } from './semanticPoint';\nimport { BOS_ELEMENT, fractionToElems, SemanticCluster, SemanticElement, SemanticElementType } from './semanticTopology';\nimport { Spartito, SpartitoMeasure } from './spartito';\nimport StaffContext from './staffContext';\nimport { ContextedTerm, ContextType, EventTerm, WHOLE_DURATION } from './term';\nimport type { SemanticPointInMeasure } from './timewiseGraph';\nimport { TimewiseGraph } from './timewiseGraph';\nimport { Token, TokenType } from './token';\nimport { distance2D, solveOverlapping } from './utils';\n\nexport const VERSION = 14;\n\ninterface Topology {\n\tclusters: SemanticCluster[];\n}\n\ninterface PaperOptions {\n\traggedLast: boolean;\n\traggedBottom: boolean;\n\traggedLastBottom: boolean;\n}\n\nconst GRAND_STAFF_LAYOUT = '{-}';\n\nconst processStaffContext = (staff: TermStaff, logger: Logger = new DummyLogger()): void => {\n\tconst context = new StaffContext();\n\tcontext.logger = logger;\n\n\tfor (const row of staff.rows) {\n\t\tfor (const measure of row) {\n\t\t\tconst startEvent = measure.terms.find((term) => term instanceof EventTerm) as EventTerm;\n\t\t\tlet tick = startEvent ? Math.min(startEvent.tick, 0) : 0;\n\n\t\t\tmeasure.terms.forEach((term) => {\n\t\t\t\tif (term instanceof ContextedTerm) {\n\t\t\t\t\tterm.tick = tick; // TODO: not working here because measure not regulated yet\n\t\t\t\t\tcontext.change(term);\n\t\t\t\t} else if (term instanceof EventTerm) {\n\t\t\t\t\tconst endTick = term.tick + (term.duration || 0);\n\t\t\t\t\tif (endTick > tick) tick = endTick;\n\n\t\t\t\t\tif (term.ys) {\n\t\t\t\t\t\tterm.pitches = term.ys.map((y) => {\n\t\t\t\t\t\t\tconst note = context.yToNote(y);\n\t\t\t\t\t\t\tconst alter = context.alterOnNote(note);\n\n\t\t\t\t\t\t\treturn { note, alter, octaveShift: context.octaveShift };\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tmeasure.timeSignature = { ...context.timeSignature };\n\t\t\tmeasure.timeSigNumeric = context.timeSigNumeric;\n\t\t\tmeasure.doubtfulTimesig =\n\t\t\t\tcontext.doubtingTimesig ||\n\t\t\t\t!Number.isInteger(Math.log2(measure.timeSignature.denominator)) ||\n\t\t\t\tmeasure.timeSignature.numerator <= measure.timeSignature.denominator / 4;\n\n\t\t\tmeasure.keySignature = context.keySignature;\n\n\t\t\t// fill empty measure duration\n\t\t\tif (measure.duration === 0) measure.duration = (WHOLE_DURATION * measure.timeSignature.numerator) / measure.timeSignature.denominator;\n\n\t\t\tcontext.resetMeasure();\n\t\t}\n\n\t\tcontext.resetSystem();\n\t}\n};\n\nconst upgradeScoreData = (data: ScoreData): ScoreData => {\n\tif (data.version < 3) {\n\t\tconst { version, stavesCount, layoutTemplate, ...fields } = data;\n\t\tvoid version;\n\t\tvoid layoutTemplate;\n\n\t\tlet staffLayoutCode =\n\t\t\tstavesCount > 1\n\t\t\t\t? Array(stavesCount - 1)\n\t\t\t\t\t\t.fill(',')\n\t\t\t\t\t\t.join('')\n\t\t\t\t: '';\n\n\t\t// use graph staff by default for 2 staves score\n\t\tif (stavesCount === 2) staffLayoutCode = '{-}';\n\n\t\tdata = {\n\t\t\tversion: 3,\n\t\t\tstaffLayoutCode,\n\t\t\t...fields,\n\t\t};\n\t}\n\n\tif (data.version < 8) {\n\t\t// upgrade system measure bar semantics\n\t\tdata.pages.forEach((page) => {\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tif (system.semantics) {\n\t\t\t\t\tconst bars = system.semantics.filter((point) => point.semantic === SemanticType.vline_BarMeasure);\n\n\t\t\t\t\tsystem.semantics = [].concat(\n\t\t\t\t\t\t...system.staves.map((staff) => {\n\t\t\t\t\t\t\tconst oy = staff.top + staff.staffY;\n\n\t\t\t\t\t\t\treturn bars.map((point) => ({\n\t\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\t\ty: point.y + oy,\n\t\t\t\t\t\t\t\textension: {\n\t\t\t\t\t\t\t\t\t...point.extension,\n\t\t\t\t\t\t\t\t\ty1: point.extension.y1 + oy,\n\t\t\t\t\t\t\t\t\ty2: point.extension.y2 + oy,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\tdata.version = 8;\n\t}\n\n\tif (data.version < 9) {\n\t\t// remove old format spartito\n\t\tdata.spartito = null;\n\n\t\tdata.version = 9;\n\t}\n\n\treturn data;\n};\n\nconst bitsToMask = (bits: number[]): number => bits.reduce((mask, bit, i) => (bit ? mask | (1 << i) : mask), 0);\n\ninterface PointPosition {\n\tpoint: SemanticPoint;\n\tpageIndex: number;\n\tsystemIndex: number;\n\tstaffIndex: number;\n}\n\ninterface MeasureValidation {\n\ttickMap: { [tick: number]: number };\n}\n\ninterface Size {\n\twidth: number;\n\theight: number;\n}\n\nclass Score extends SimpleClass {\n\tstatic className = 'Score';\n\n\tversion = VERSION;\n\n\ttitle: string;\n\t// in pixels\n\tpageSize: Size;\n\tunitSize: number;\n\tstaffLayoutCode: string;\n\n\tpaperOptions?: Partial;\n\n\theaders: { [key: string]: string };\n\n\ttextAnnotations: { [id: string]: string };\n\n\ttags?: string[];\n\n\tinstrumentDict: { [key: string]: string };\n\n\tpages: Page[];\n\ttopology: Topology;\n\tspartito?: Spartito;\n\n\tpatches?: PatchMeasure[];\n\n\tsettings: RecognitionSettings;\n\n\tconstructor(data: ScoreData) {\n\t\tsuper();\n\t\tsuper.assign(upgradeScoreData(data));\n\n\t\tthis.pages = this.pages || [];\n\t\tthis.headers = this.headers || {};\n\t\tthis.instrumentDict = this.instrumentDict || {};\n\n\t\tthis.pageSize = this.pageSize || {\n\t\t\t// A4 paper\n\t\t\twidth: 794,\n\t\t\theight: 1122,\n\t\t};\n\n\t\tthis.unitSize = this.unitSize || null;\n\n\t\tthis.staffLayoutCode = this.staffLayoutCode || (this.maxStavesCount === 2 ? GRAND_STAFF_LAYOUT : Array(this.maxStavesCount).fill('').join(','));\n\t}\n\n\tget systems(): System[] {\n\t\treturn [].concat(...this.pages.map((page) => page.systems));\n\t}\n\n\tget measureCount(): number {\n\t\treturn this.systems.reduce((sum, system) => sum + (system.measureCount || 0), 0);\n\t}\n\n\tget imageKeys(): string[] {\n\t\treturn [\n\t\t\t...this.pages.map((page) => page.source?.url),\n\t\t\t...this.systems.map((system) => system.backgroundImage),\n\t\t\t...[].concat(\n\t\t\t\t...this.systems.map((system) =>\n\t\t\t\t\t[...system.staves.map((staff) => staff.backgroundImage), ...system.staves.map((staff) => staff.maskImage)].filter(Boolean)\n\t\t\t\t)\n\t\t\t),\n\t\t].filter(Boolean);\n\t}\n\n\tget breakSystemIndices(): number[] {\n\t\tconst indices = [];\n\t\tlet systemCount = 0;\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tif (i < this.pages.length - 1) {\n\t\t\t\tsystemCount += page.systems.length;\n\t\t\t\tindices.push(systemCount - 1);\n\t\t\t}\n\t\t});\n\n\t\treturn indices;\n\t}\n\n\tget staffLayout(): staffLayout.StaffLayout {\n\t\treturn staffLayout.parseCode(this.staffLayoutCode);\n\t}\n\n\tget measureLayoutCode(): string {\n\t\treturn this.spartito?.measureLayoutCode;\n\t}\n\n\tget maxStavesCount(): number {\n\t\treturn Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t}\n\n\tget sidBlackList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidBlackList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget sidWhiteList(): Set {\n\t\tconst ids = [].concat(...this.systems.map((system) => system.sidWhiteList));\n\n\t\treturn new Set(ids);\n\t}\n\n\tget semanticHash(): string {\n\t\tconst ids = [].concat(\n\t\t\t...this.systems.map((system) =>\n\t\t\t\t[].concat(...system.staves.map((staff) => (staff.semantics ? system.qualifiedSemantics(staff.semantics).map((s) => s.id) : [])))\n\t\t\t)\n\t\t);\n\t\treturn sha1(ids.join(''));\n\t}\n\n\teventSystemsToTermStaves(eventSystems: EventSystem[], logger: Logger = new DummyLogger()): TermStaff[] {\n\t\t// [staff]\n\t\tconst termStaves: TermStaff[] = Array(this.maxStavesCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, staffIndex): TermStaff => {\n\t\t\t\treturn {\n\t\t\t\t\t// [system, measure]\n\t\t\t\t\trows: eventSystems.map((sys, i) =>\n\t\t\t\t\t\tsys.columns.map((column, ii): TermMeasure => {\n\t\t\t\t\t\t\tconst measure = column.rows[staffIndex];\n\t\t\t\t\t\t\tconsole.assert(measure, '[eventSystemsToTermStaves] measure is null:', staffIndex, column.rows);\n\n\t\t\t\t\t\t\tconst contexts = measure.contexts;\n\n\t\t\t\t\t\t\t// prepend octave shift 0 at begin of every system\n\t\t\t\t\t\t\tif (ii === 0) {\n\t\t\t\t\t\t\t\tif (!contexts.some((term) => term.type === ContextType.OctaveShift)) {\n\t\t\t\t\t\t\t\t\tcontexts.unshift(\n\t\t\t\t\t\t\t\t\t\tnew ContextedTerm({\n\t\t\t\t\t\t\t\t\t\t\tstaff: staffIndex,\n\t\t\t\t\t\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\t\t\t\t\t\ttokenType: TokenType.OctaveShift0,\n\t\t\t\t\t\t\t\t\t\t\ttick: 0,\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst terms = [...(measure.events || []), ...contexts].sort((t1, t2) => t1.x - t2.x);\n\n\t\t\t\t\t\t\tconst pageBreak = staffIndex === 0 && ii === sys.columns.length - 1 && this.breakSystemIndices.includes(i);\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tterms,\n\t\t\t\t\t\t\t\t//xToTick: column.xToTick,\n\t\t\t\t\t\t\t\tduration: column.duration,\n\t\t\t\t\t\t\t\tpageBreak,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t});\n\t\ttermStaves.forEach((staff) => processStaffContext(staff, logger));\n\n\t\treturn termStaves;\n\t}\n\n\tresetPageLayout(parameters: { unitSize?: number; pageSize?: Size }) {\n\t\tconst { unitSize = this.unitSize, pageSize = this.pageSize } = parameters;\n\n\t\tconst newCenter = {\n\t\t\tx: (pageSize.width * 0.5) / unitSize,\n\t\t\ty: (pageSize.height * 0.5) / unitSize,\n\t\t};\n\n\t\tthis.pages.forEach((page) => {\n\t\t\tconst offsetX = newCenter.x - page.width / 2;\n\t\t\tconst offsetY = newCenter.y - page.height / 2;\n\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tsystem.left += offsetX;\n\t\t\t\tsystem.top += offsetY;\n\t\t\t});\n\n\t\t\tif (page.semantics) {\n\t\t\t\tpage.semantics.forEach((point) => {\n\t\t\t\t\tpoint.x += offsetX;\n\t\t\t\t\tpoint.y += offsetY;\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tpage.width = pageSize.width / unitSize;\n\t\t\tpage.height = pageSize.height / unitSize;\n\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations });\n\t\t});\n\n\t\tthis.unitSize = unitSize;\n\t\tthis.pageSize = pageSize;\n\t}\n\n\tgetMeasure(measureIndex: number): {\n\t\tmeasureIndex: number;\n\t\tsystem: System;\n\t\tlocalIndex: number;\n\t\tleft: number;\n\t\tright: number;\n\t\tmeasures: Measure[];\n\t} {\n\t\tlet index = measureIndex;\n\t\tfor (const system of this.systems) {\n\t\t\tif (index < system.measureCount) {\n\t\t\t\tconst staff = system.staves[0];\n\t\t\t\tconst measure = staff.measures[index];\n\t\t\t\tconsole.assert(measure, 'measure is null:', system.measureCount, index, staff.measures);\n\t\t\t\tconst measures = system.getStaffArray(this.maxStavesCount).map((staff) => staff && staff.measures[index]);\n\n\t\t\t\treturn {\n\t\t\t\t\tmeasureIndex,\n\t\t\t\t\tsystem,\n\t\t\t\t\tlocalIndex: index,\n\t\t\t\t\tleft: measure.left,\n\t\t\t\t\tright: measure.right,\n\t\t\t\t\tmeasures,\n\t\t\t\t};\n\t\t\t}\n\t\t\tindex -= system.measureCount;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetRawCluster(measureIndex: number, threshold: number, { timeSignature }: Partial = {}): SemanticCluster {\n\t\tconst position = this.getMeasure(measureIndex);\n\t\tif (!position) return null;\n\n\t\tconst { system, left, right } = position;\n\t\t//console.log(\"measure:\", system, left, right);\n\n\t\tconst elements: SemanticElement[] = [BOS_ELEMENT];\n\n\t\tif (timeSignature) elements.push(...fractionToElems(timeSignature));\n\n\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tlet points = system.qualifiedSemantics(staff.semantics, threshold).filter((point) => point.x > left && point.x < right);\n\t\t\tpoints = solveOverlapping(points);\n\n\t\t\t// exlude tempo noteheads\n\t\t\tconst tempoNhs = points.filter((point) => point.semantic === SemanticType.TempoNotehead);\n\t\t\ttempoNhs.forEach((tempoNh) => {\n\t\t\t\tconst index = points.findIndex((point) => /^Notehead/.test(point.semantic) && distance2D(tempoNh, point) < 0.3);\n\t\t\t\tif (index >= 0) points.splice(index, 1);\n\t\t\t});\n\n\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\n\t\t\tpoints.forEach((point) => {\n\t\t\t\tconst type = SemanticElementType[point.semantic];\n\t\t\t\tif (type) {\n\t\t\t\t\tlet y1 = point.y;\n\t\t\t\t\tlet y2 = point.y;\n\t\t\t\t\tif (type === SemanticElementType.vline_Stem) {\n\t\t\t\t\t\ty1 = point.extension.y1;\n\t\t\t\t\t\ty2 = point.extension.y2;\n\t\t\t\t\t}\n\n\t\t\t\t\telements.push({\n\t\t\t\t\t\tid: point.id,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tstaff: staff.index,\n\t\t\t\t\t\tx: point.x - left,\n\t\t\t\t\t\ty1: y1 + y0,\n\t\t\t\t\t\ty2: y2 + y0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new SemanticCluster({\n\t\t\tindex: measureIndex,\n\t\t\telements,\n\t\t});\n\t}\n\n\tgetRawClusters(threshold: number = 1): SemanticCluster[] {\n\t\t//const times = this.getMeasuresTime();\n\n\t\treturn Array(this.measureCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, mi) => this.getRawCluster(mi, threshold /*, times[mi]*/));\n\t}\n\n\tmakeSpartito(logger: Logger = new DummyLogger()): Spartito {\n\t\tlet eventSystems: EventSystem[] = this.systems.map((system) => system.getEvents(this.maxStavesCount));\n\n\t\t/*if (this.topology) {\n\t\t\tconst clusters = this.topology.clusters;\n\n\t\t\t// [measure, staff, event]\n\t\t\tconst eventsColumns: ChordColumn[][][] = clusters\n\t\t\t\t.filter((cluster) => cluster.index < this.measureCount)\n\t\t\t\t.reduce((columns, cluster) => {\n\t\t\t\t\tconst { system, measures } = this.getMeasure(cluster.index);\n\t\t\t\t\tconst events = cluster.getEvents();\n\n\t\t\t\t\tconst systemY0 = system.staves[0].top + system.staves[0].staffY - 2;\n\t\t\t\t\tconst x0 = measures.filter(Boolean)[0].left;\n\n\t\t\t\t\tconst staves = system.getStaffArray(this.maxStavesCount);\n\n\t\t\t\t\t// translate by staff & measure relative offset\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst staff = staves[event.staff];\n\t\t\t\t\t\tconst y0 = staff.top + staff.staffY - systemY0;\n\t\t\t\t\t\tevent.ys = event.ys.map((y) => roundNumber(y - y0, 0.5));\n\n\t\t\t\t\t\tevent.left += x0;\n\t\t\t\t\t\tevent.right += x0;\n\t\t\t\t\t});\n\n\t\t\t\t\tconst column = measures.map((measure, staffIndex) => {\n\t\t\t\t\t\tif (!measure) return [];\n\n\t\t\t\t\t\t//console.log(\"m:\", mi, \"s:\", staffIndex);\n\t\t\t\t\t\tconst localEvents = events.filter((event) => event.staff === staffIndex);\n\t\t\t\t\t\t//measure.assignModifiersOnEvents(localEvents);\n\t\t\t\t\t\tmeasure.assignAccessoriesOnEvents(localEvents);\n\n\t\t\t\t\t\treturn localEvents;\n\t\t\t\t\t});\n\n\t\t\t\t\tcolumns[cluster.index] = column;\n\n\t\t\t\t\treturn columns;\n\t\t\t\t}, []);\n\n\t\t\tconst breakSystemIndices = this.breakSystemIndices;\n\n\t\t\tconst basicEventSystems = eventSystems;\n\t\t\teventSystems = [];\n\n\t\t\tlet measures = 0;\n\t\t\tfor (const system of this.systems) {\n\t\t\t\tconst esys = system.getEventsFunctional(this.maxStavesCount, (si, mi) => eventsColumns[measures + mi] && eventsColumns[measures + mi][si], [], {\n\t\t\t\t\tuseXMap: false,\n\t\t\t\t});\n\n\t\t\t\tconst basicSys = basicEventSystems[system.index];\n\t\t\t\t//onst nullN = esys.columns.filter(c => !c).length;\n\t\t\t\t//if (nullN)\n\t\t\t\t//\tconsole.log(\"null:\", nullN, esys.columns.length);\n\t\t\t\tesys.columns = esys.columns.map((column, i) => (column ? column : basicSys.columns[i]));\n\n\t\t\t\tconst sysIndex = this.systems.indexOf(system);\n\t\t\t\tconst pageBreak = breakSystemIndices.includes(sysIndex);\n\t\t\t\tconst lastColumn = esys.columns[esys.columns.length - 1];\n\t\t\t\tif (lastColumn) {\n\t\t\t\t\tlastColumn.break = true;\n\t\t\t\t\tlastColumn.pageBreak = pageBreak;\n\t\t\t\t}\n\n\t\t\t\teventSystems.push(esys);\n\t\t\t\tmeasures += system.measureCount;\n\t\t\t}\n\t\t}*/\n\n\t\tconst staves = this.eventSystemsToTermStaves(eventSystems, logger);\n\n\t\t// assign staff basics for columns\n\t\teventSystems.forEach((sys, ri) => {\n\t\t\tsys.columns.forEach((column, mi) => {\n\t\t\t\tcolumn.basics = staves.map((staff) => {\n\t\t\t\t\tconst { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig } = staff.rows[ri][mi];\n\n\t\t\t\t\treturn { timeSignature, timeSigNumeric, keySignature, doubtfulTimesig };\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tconst clusters = null; //this.topology && this.topology.clusters;\n\n\t\tconst measures = [].concat(\n\t\t\t...eventSystems.map((esys) =>\n\t\t\t\tesys.columns.map((column) => {\n\t\t\t\t\tconst measureIndex = column.measureIndex;\n\t\t\t\t\tconst { system, localIndex, left, right } = this.getMeasure(measureIndex);\n\n\t\t\t\t\tconst cluster = clusters && clusters.find((cluster) => cluster.index === measureIndex);\n\n\t\t\t\t\tconst staffYsFull = [];\n\t\t\t\t\tsystem.staves.forEach((staff) => (staffYsFull[staff.index] = staff.top + staff.staffY));\n\n\t\t\t\t\tconst patch = this.patches && this.patches.find((patch) => patch.measureIndex === measureIndex);\n\t\t\t\t\tconst events = patch ? patch.events : SpartitoMeasure.reorderEvents([].concat(...column.rows.map((row) => row.events)), staffYsFull);\n\n\t\t\t\t\tconst barTypes = Object.fromEntries(Object.entries(column.barTypes).map(([k, v]) => [k, v / system.staves.length]));\n\t\t\t\t\tconst indent = localIndex === 0 && system.indent;\n\n\t\t\t\t\treturn new SpartitoMeasure({\n\t\t\t\t\t\tmeasureIndex,\n\t\t\t\t\t\tstaffMask: esys.staffMask,\n\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\t\tlocalIndex,\n\t\t\t\t\t\t\tleft,\n\t\t\t\t\t\t\tright,\n\t\t\t\t\t\t\tstaffYs: system.staves.map((staff) => staff.top + staff.staffY),\n\t\t\t\t\t\t\tstaffYsFull,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t//startX: column.startX,\n\t\t\t\t\t\t//width: column.width,\n\t\t\t\t\t\tduration: patch ? patch.duration : column.duration,\n\t\t\t\t\t\tevents,\n\t\t\t\t\t\tcontexts: column.rows.map((row) => row.contexts),\n\t\t\t\t\t\tmarks: column.marks,\n\t\t\t\t\t\tbreak: column.break,\n\t\t\t\t\t\tpageBreak: column.pageBreak,\n\t\t\t\t\t\tvoltaBegin: column.voltaBegin,\n\t\t\t\t\t\tvoltaEnd: column.voltaEnd,\n\t\t\t\t\t\talternative: column.alternative,\n\t\t\t\t\t\tbarTypes,\n\t\t\t\t\t\tindent,\n\t\t\t\t\t\tbasics: patch ? patch.basics : column.basics,\n\t\t\t\t\t\tmatrixH: cluster && cluster.matrixH,\n\t\t\t\t\t\tmatrixV: cluster && cluster.matrixV,\n\t\t\t\t\t\tvoices: patch ? patch.voices : null,\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\n\t\tconst staffLayout = this.staffLayout;\n\t\tconst staffGroups = staffLayout.standaloneGroups.map((ids) => ids.map((id) => staffLayout.staffIds.indexOf(id)));\n\n\t\tthis.spartito = new Spartito({\n\t\t\tstavesCount: this.maxStavesCount,\n\t\t\tstaffGroups,\n\t\t\tmeasures,\n\t\t});\n\n\t\treturn this.spartito;\n\t}\n\n\tmakeMusicSheet(): MusicSheet {\n\t\tconst spartito = this.spartito || this.makeSpartito();\n\n\t\tif (!spartito.regulated) console.warn('[makeMusicSheet]\tspartito not regulated.');\n\n\t\tconst voiceStaves = spartito.makeVoiceStaves();\n\n\t\tconst { title, pageSize, unitSize, staffLayout, paperOptions, headers, instrumentDict } = this;\n\t\tconst measureLayout = this.getMeasureLayout();\n\n\t\treturn {\n\t\t\ttitle,\n\t\t\tpageSize,\n\t\t\tunitSize,\n\t\t\tmeasureLayout,\n\t\t\tstaffLayout,\n\t\t\tpaperOptions,\n\t\t\theaders,\n\t\t\tvoiceStaves,\n\t\t\tinstrumentDict,\n\t\t};\n\t}\n\n\tfindPoint(sid: string): PointPosition {\n\t\tfor (const system of this.systems) {\n\t\t\tfor (let si = 0; si < system.staves.length; ++si) {\n\t\t\t\tconst point = system.staves[si].semantics.find((point) => point.id === sid);\n\t\t\t\tif (point) {\n\t\t\t\t\tconst pageIndex = this.pages.findIndex((page) => page.systems.includes(system));\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpoint,\n\t\t\t\t\t\tpageIndex,\n\t\t\t\t\t\tsystemIndex: system.index,\n\t\t\t\t\t\tstaffIndex: si,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetMeasureSemantics(systemIndex: number, localIndex: number): SemanticPointInMeasure[] {\n\t\tconst system = this.systems[systemIndex];\n\t\tif (!system) return null;\n\n\t\tconst left = localIndex ? system.measureBars[localIndex - 1] : 0;\n\t\tconst right = system.measureBars[localIndex] || system.width;\n\n\t\treturn system.staves\n\t\t\t.map((staff, si) => {\n\t\t\t\tconst staffY = staff.top + staff.staffY;\n\t\t\t\treturn staff.semantics\n\t\t\t\t\t.filter((point) => point.x >= left && point.x < right)\n\t\t\t\t\t.map((point) => {\n\t\t\t\t\t\tconst [y1, y2] = Number.isFinite(point.extension?.y1) ? [point.extension.y1, point.extension.y2] : [point.y, point.y];\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\tstaff: si,\n\t\t\t\t\t\t\tsy1: y1 + staffY,\n\t\t\t\t\t\t\tsy2: y2 + staffY,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\t\t\t})\n\t\t\t.flat(1);\n\t}\n\n\tmakeTimewiseGraph({ store = false }: { store?: boolean } = {}): TimewiseGraph {\n\t\tif (!this.spartito) return null;\n\n\t\tconst measures = this.spartito.measures\n\t\t\t.filter((measure) => measure.events.length > 0)\n\t\t\t.map((measure) => {\n\t\t\t\tconst points = this.getMeasureSemantics(measure.position.systemIndex, measure.position.localIndex);\n\n\t\t\t\tconst graph = {\n\t\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\t\tleft: measure.position.left,\n\t\t\t\t\tright: measure.position.right,\n\t\t\t\t\tpoints,\n\t\t\t\t};\n\n\t\t\t\tif (store) measure.graph = graph;\n\n\t\t\t\treturn graph;\n\t\t\t});\n\n\t\treturn { measures };\n\t}\n\n\tgetTokenMap(): Map {\n\t\tconst map = new Map();\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => staff.measures.forEach((measure) => measure.tokens.forEach((token) => map.set(token.id, token))))\n\t\t);\n\n\t\treturn map;\n\t}\n\n\tassemble(confidenceThreshold: number = 1, logger: Logger = new DummyLogger()) {\n\t\tconst ids = new Map();\n\n\t\tconst append = (systemIndex, staffIndex, point) => {\n\t\t\tconst id = hashSemanticPoint(systemIndex, staffIndex, point);\n\t\t\tlogger.assert(!ids.has(id), 'semantic point hash conflicted:', id, point, ids.get(id));\n\n\t\t\tids.set(id, point);\n\t\t};\n\n\t\tthis.pages.forEach((page, index) => (page.index = index));\n\n\t\tlet measureIndex = 0;\n\t\tthis.systems.forEach((system, systemIndex) => {\n\t\t\tsystem.index = systemIndex;\n\t\t\tsystem.headMeasureIndex = measureIndex;\n\t\t\tsystem.prev = this.systems[systemIndex - 1] || null;\n\t\t\tsystem.next = this.systems[systemIndex + 1] || null;\n\n\t\t\tif (system.semantics && system.semantics.length) system.semantics.forEach((point) => append(systemIndex, null, point));\n\n\t\t\tsystem.assemble(confidenceThreshold, logger);\n\t\t\tmeasureIndex += system.measureCount;\n\t\t});\n\n\t\tthis.pages.forEach((page, i) => {\n\t\t\tpage.systems.forEach((system) => (system.pageIndex = i));\n\t\t\tpage.assemble({ textAnnotations: this.textAnnotations }, logger);\n\t\t});\n\t}\n\n\tassembleSystem(system: System, confidenceThreshold: number = 1) {\n\t\tthis.systems.forEach((system, si) => (system.index = si));\n\t\tconst systemIndex = system.index;\n\n\t\tif (system.semantics && system.semantics.length) {\n\t\t\tsystem.semantics.forEach((point) => hashSemanticPoint(systemIndex, null, point));\n\t\t\tsystem.assemble(confidenceThreshold);\n\t\t}\n\t}\n\n\tmarkVoices(staves: VoicesStaff[]): void {\n\t\tconst tokenMap = this.getTokenMap();\n\t\tfor (const token of tokenMap.values()) token.voice = 0;\n\n\t\tconst vis = []\n\t\t\t.concat(...staves.map((staff, s) => (staff.voices || []).map((_, v) => [s, v])))\n\t\t\t.sort(([s1, v1], [s2, v2]) => v1 - v2 || s1 - s2)\n\t\t\t.map(([s, v]) => `${s}|${v}`);\n\n\t\tstaves.forEach((staff, si) =>\n\t\t\t(staff.voices || []).forEach((voice, vi) =>\n\t\t\t\tvoice.measures.forEach((measure) => {\n\t\t\t\t\tconst voiceIndex = vis.indexOf(`${si}|${vi}`);\n\n\t\t\t\t\tconst events = Object.values(measure.tickMap).filter((event) => event instanceof EventTerm) as EventTerm[];\n\t\t\t\t\tevents.forEach((event) => {\n\t\t\t\t\t\tconst notes = event.noteIds ? event.noteIds.map((id) => tokenMap.get(id)).filter(Boolean) : [];\n\t\t\t\t\t\tconst accessories = event.accessories ? event.accessories.map((acc) => tokenMap.get(acc.id)).filter(Boolean) : [];\n\t\t\t\t\t\t//console.log(\"notes:\", si, vi, mi, event.noteIds, notes, accessories);\n\n\t\t\t\t\t\t[...notes, ...accessories].forEach((token) => (token.voice |= 1 << voiceIndex));\n\n\t\t\t\t\t\tif (event.timeWarp) notes.forEach((note) => (note.timeWarped = true));\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t)\n\t\t);\n\t}\n\n\tasync replaceImageKeys(proc: (x: string | Buffer) => Promise): Promise {\n\t\tawait Promise.all([\n\t\t\t...(this.pages.map(async (page) => {\n\t\t\t\tif (page.source) page.source.url = await proc(page.source.url);\n\t\t\t}) as Promise[]),\n\t\t\t...this.systems.map((system) =>\n\t\t\t\tPromise.all([\n\t\t\t\t\tproc(system.backgroundImage).then((key) => (system.backgroundImage = key)),\n\t\t\t\t\t...(system.staves.map(async (staff) => {\n\t\t\t\t\t\tstaff.backgroundImage = await proc(staff.backgroundImage);\n\t\t\t\t\t\tstaff.maskImage = await proc(staff.maskImage);\n\t\t\t\t\t}) as Promise[]),\n\t\t\t\t])\n\t\t\t),\n\t\t]);\n\t}\n\n\tinferenceStaffLayout(): void {\n\t\t// inference the complete layout\n\t\tconst staffTotal = Math.max(...this.systems.map((system) => system.staves.length), 0);\n\t\tthis.staffLayoutCode = Array(staffTotal).fill('').join(',');\n\n\t\tconst completeSystems = this.systems.filter((system) => system.staves.length === staffTotal && system.bracketsAppearance);\n\t\tif (!completeSystems.length) return; // no enough evidence\n\n\t\tconst candidateCodes = completeSystems\n\t\t\t.map((system) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst layout = staffLayout.parseCode(system.bracketsAppearance);\n\t\t\t\t\tif (layout.staffIds.length !== system.staves.length) return null;\n\n\t\t\t\t\treturn system.bracketsAppearance;\n\t\t\t\t} catch (_) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t\tif (!candidateCodes.length) return; // no valid layout\n\n\t\tconst codeCounting = candidateCodes.reduce((acc, code) => {\n\t\t\tconst count = acc[code] || 0;\n\t\t\tacc[code] = count + 1;\n\t\t\treturn acc;\n\t\t}, {} as { [code: string]: number });\n\t\tconst maxCount = Math.max(...Object.values(codeCounting));\n\t\tconst code = Object.entries(codeCounting).find(([_, count]) => count === maxCount)[0];\n\n\t\t// added connection lines between braces {-}\n\t\tconst connectedCode = code.replace(/\\{,*\\}/g, (match) => match.replace(/,/g, '-'));\n\t\tconst layout = staffLayout.parseCode(connectedCode);\n\n\t\tthis.staffLayoutCode = connectedCode;\n\t\t//console.log(\"complete code:\", code);\n\n\t\t// inference systems' mask\n\t\tlet lastSys: System = null;\n\t\tfor (const system of this.systems) {\n\t\t\tif (lastSys && system.staves.length === lastSys.staves.length && system.bracketsAppearance === lastSys.bracketsAppearance) {\n\t\t\t\tsystem.staffMaskChanged = null;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (system.staves.length < staffTotal && system.bracketsAppearance) {\n\t\t\t\t// validate the system brackets code\n\t\t\t\ttry {\n\t\t\t\t\tif (!staffLayout.parseCode(system.bracketsAppearance)) continue;\n\t\t\t\t} catch (_) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst search = (bits: (0 | 1)[]): number => {\n\t\t\t\t\tif (bits.length > layout.staffIds.length) return null;\n\n\t\t\t\t\tif (bits.reduce((sum, bit) => sum + bit, 0) === system.staves.length) return bitsToMask(bits);\n\n\t\t\t\t\tfor (const bit of [1, 0]) {\n\t\t\t\t\t\tconst bb = [...bits, bit] as (0 | 1)[];\n\t\t\t\t\t\tconst code1 = layout.partialMaskCode(bb);\n\t\t\t\t\t\tif (code1 === system.bracketsAppearance) return bitsToMask(bb);\n\t\t\t\t\t\telse if (system.bracketsAppearance.startsWith(code1)) {\n\t\t\t\t\t\t\tconst result = search(bb);\n\t\t\t\t\t\t\tif (result) return result;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t};\n\t\t\t\tconst mask = search([]);\n\t\t\t\t//console.log(\"mask:\", system.bracketsAppearance, mask.toString(2));\n\n\t\t\t\tsystem.staffMaskChanged = !lastSys || mask !== lastSys.staffMask ? mask : null;\n\t\t\t}\n\n\t\t\tlastSys = system;\n\t\t}\n\t}\n\n\tassignBackgroundForMeasure(measure: SpartitoMeasure): void {\n\t\tmeasure.backgroundImages = [];\n\n\t\tconst system = this.systems[measure.position.systemIndex];\n\t\tif (system.backgroundImage) {\n\t\t\tmeasure.backgroundImages.push({\n\t\t\t\turl: system.backgroundImage,\n\t\t\t\tposition: system.imagePosition,\n\t\t\t\toriginal: true,\n\t\t\t});\n\t\t}\n\n\t\tsystem.staves.forEach((staff) => {\n\t\t\tif (!system.backgroundImage && staff.backgroundImage)\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.backgroundImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t\toriginal: true,\n\t\t\t\t});\n\n\t\t\tif (staff.maskImage) {\n\t\t\t\tmeasure.backgroundImages.push({\n\t\t\t\t\turl: staff.maskImage.toString(),\n\t\t\t\t\tposition: {\n\t\t\t\t\t\t...staff.imagePosition,\n\t\t\t\t\t\ty: staff.imagePosition.y + staff.top,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tblackoutFakeNotes(scope: 'patched' | 'perfect' | 'all' = 'patched'): string[] {\n\t\tif (!this.spartito) return;\n\n\t\tlet inScope = (_) => true;\n\t\tswitch (scope) {\n\t\t\tcase 'patched':\n\t\t\t\tinScope = (measure) => measure.patched;\n\t\t\t\tbreak;\n\t\t\tcase 'perfect':\n\t\t\t\tinScope = (measure) => measure.patched || (measure.regulated && evaluateMeasure(measure).perfect);\n\t\t\t\tbreak;\n\t\t}\n\t\tconst measures = this.spartito.measures.filter(inScope);\n\n\t\tconst fakeIds = measures.reduce((ids, measure) => {\n\t\t\tif (!measure.regulated) return;\n\n\t\t\tconst voicedIds = measure.voices.flat(1);\n\t\t\tconst fakeChords = measure.events.filter((event) => !event.rest && !event.grace && !voicedIds.includes(event.id));\n\n\t\t\tfakeChords.forEach((event) => event.noteIds && ids.push(...event.noteIds));\n\n\t\t\treturn ids;\n\t\t}, [] as string[]);\n\t\tconst fakeIdSet = new Set(fakeIds);\n\n\t\tthis.systems.forEach((system) =>\n\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\tconst blackIds = staff.semantics.filter((point) => fakeIdSet.has(point.id)).map((point) => point.id);\n\t\t\t\tsystem.sidBlackList.push(...blackIds);\n\t\t\t})\n\t\t);\n\n\t\treturn fakeIds;\n\t}\n\n\tgetMeasureLayout(): measureLayout.MeasureLayout {\n\t\tconst code = this.spartito && this.spartito.measureLayoutCode;\n\t\tif (code) {\n\t\t\ttry {\n\t\t\t\treturn measureLayout.parseCode(code);\n\t\t\t} catch (err) {\n\t\t\t\tconsole.debug('invalid measure layout code:', err);\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t*splitToSingleScoresGen(): Generator {\n\t\tthis.assemble();\n\t\tconst startSysIndices = this.systems.filter((system) => system.index > 0 && system.indent && system.timeSignatureOnHead).map((system) => system.index);\n\n\t\tif (!startSysIndices.length) {\n\t\t\tyield this.deepCopy();\n\t\t\treturn;\n\t\t}\n\n\t\tconst templateScore = new Score({ ...this, pages: [], topology: undefined, spartito: undefined, patches: undefined });\n\n\t\t// clear temporary objects before deep dopy\n\t\tthis.pages.forEach((page) => {\n\t\t\tdelete page.tokens;\n\t\t\tpage.systems.forEach((system) => {\n\t\t\t\tdelete system.tokens;\n\t\t\t\tsystem.staves.forEach((staff) => {\n\t\t\t\t\tstaff.measures = [];\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tlet startSysIndex = 0;\n\t\tfor (const endSysIndex of [...startSysIndices, this.systems.length]) {\n\t\t\tconst sysInRange = (system) => system.index >= startSysIndex && system.index < endSysIndex;\n\t\t\tconst pages = this.pages\n\t\t\t\t.filter((page) => page.systems.some(sysInRange))\n\t\t\t\t.map((page) => {\n\t\t\t\t\tconst { systems, ...fields } = page;\n\t\t\t\t\treturn new Page({ ...fields, systems: systems.filter(sysInRange).map((system) => new System({ ...system })) });\n\t\t\t\t});\n\n\t\t\tconst newScore = templateScore.deepCopy();\n\t\t\tnewScore.headers.SubScoreSystem = `${startSysIndex}-${endSysIndex - 1}`;\n\t\t\tnewScore.headers.SubScorePage = `${pages[0].index}-${pages[pages.length - 1].index}`;\n\n\t\t\t//newScore.pages = pages.map((page) => page.deepCopy());\n\t\t\tnewScore.pages = pages;\n\t\t\tnewScore.assemble();\n\t\t\tnewScore.inferenceStaffLayout();\n\n\t\t\tstartSysIndex = endSysIndex;\n\n\t\t\tyield newScore;\n\t\t}\n\t}\n\n\tsplitToSingleScores(): Score[] {\n\t\treturn [...this.splitToSingleScoresGen()];\n\t}\n}\n\nexport { PaperOptions, Score, Page, System, Staff, Measure, MeasureValidation };\nexport type { SemanticPointInMeasure };\n","import { MIDI } from '@k-l-lambda/music-widgets';\n\nimport { Fraction } from './interfaces';\nimport { noteToPitch } from './utils';\nimport { EventTerm, RestType, GraceType, StemBeam, ArpeggioStyle, TermPitch, TremoloLink } from './term';\nimport { SpartitoMeasure } from './spartitoMeasure';\n\n// NOTE: 'JSONEditor.onEditable' determine whether a field is editable, here 'readonly' modifier has no effect to UI\n\ninterface EventUIAgent {\n\treadonly id: number;\n\treadonly duration: number;\n\n\t//ys: number[];\n\tpitches: TermPitch[];\n\trest: RestType;\n\tdivision: number;\n\tdots: number;\n\tstemDirection: string;\n\ttying: boolean;\n\ttied: boolean;\n\tgrace: boolean; //\n\tbeam: StemBeam;\n\ttimeWarp: string; //\n\ttremolo: number;\n\ttremoloLink: TremoloLink;\n\tglissando: boolean;\n\tarpeggioStyle: ArpeggioStyle;\n\ttick: number;\n}\n\ninterface MeasureUIAgent {\n\treadonly measureIndex: number;\n\ttimeSignature: Fraction;\n\tdoubtfulTimesig: boolean;\n\tkeySignature: number;\n\t//readonly events: EventUIAgent[];\n\tduration: number;\n\treadonly voices: number[][];\n}\n\nclass EditableEvent extends EventTerm {\n\tvoice: number;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\t}\n\n\tget agent(): EventUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget(target, key): any {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'arpeggioStyle': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? null : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'glissando': {\n\t\t\t\t\t\tconst value = self[key];\n\t\t\t\t\t\treturn value === undefined ? false : value;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\treturn !!self.grace;\n\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\treturn self.timeWarp ? `${self.timeWarp.numerator}/${self.timeWarp.denominator}` : null;\n\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn self.pitches;\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\tconst self = target as any as EditableEvent;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'tick':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\tcase 'rest':\n\t\t\t\t\tcase 'division':\n\t\t\t\t\tcase 'dots':\n\t\t\t\t\tcase 'stemDirection':\n\t\t\t\t\tcase 'tying':\n\t\t\t\t\tcase 'tied':\n\t\t\t\t\tcase 'beam':\n\t\t\t\t\tcase 'tremolo':\n\t\t\t\t\tcase 'tremoloLink':\n\t\t\t\t\tcase 'glissando':\n\t\t\t\t\tcase 'arpeggioStyle':\n\t\t\t\t\t\t(self as any)[key] = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'grace':\n\t\t\t\t\t\tself.grace = value ? GraceType.Grace : null;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'timeWarp':\n\t\t\t\t\t\tself.timeWarp = null;\n\t\t\t\t\t\tif (value && typeof value === 'string') {\n\t\t\t\t\t\t\tconst captures = value.match(/^(\\d+)\\/(\\d+)/);\n\t\t\t\t\t\t\tif (captures) {\n\t\t\t\t\t\t\t\tself.timeWarp = {\n\t\t\t\t\t\t\t\t\tnumerator: parseInt(captures[1]),\n\t\t\t\t\t\t\t\t\tdenominator: parseInt(captures[2]),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'id':\n\t\t\t\t\tcase 'pitches':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => [\n\t\t\t\t'id',\n\t\t\t\t'duration',\n\t\t\t\t'rest',\n\t\t\t\t'division',\n\t\t\t\t'dots',\n\t\t\t\t'stemDirection',\n\t\t\t\t'tying',\n\t\t\t\t'tied',\n\t\t\t\t'beam',\n\t\t\t\t'timeWarp',\n\t\t\t\t'tremolo',\n\t\t\t\t'tremoloLink',\n\t\t\t\t'glissando',\n\t\t\t\t'arpeggioStyle',\n\t\t\t\t'tick',\n\t\t\t\t'grace',\n\t\t\t\t'pitches',\n\t\t\t],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n}\n\nclass EditableMeasure extends SpartitoMeasure {\n\tstatic className = 'EditableMeasure';\n\tstatic blackKeys = [];\n\n\tevents: EditableEvent[] = null;\n\n\tconstructor(data: any) {\n\t\tsuper(data);\n\n\t\tthis.events = data.events;\n\t\tif (this.events?.some((event) => !(event instanceof EditableEvent))) this.events = this.events.map((event) => new EditableEvent(event));\n\n\t\tif (this.voices) this.syncVoiceToEvents();\n\t}\n\n\tsyncVoiceToEvents(): void {\n\t\tthis.events.forEach((event) => (event.voice = -1));\n\t\tthis.voices.forEach((voice, voiceIndex) => {\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\tif (event) event.voice = voiceIndex;\n\t\t\t\telse console.warn('no event with id:', id, this.events.length);\n\t\t\t});\n\t\t});\n\t}\n\n\tsyncVoiceFromEvents(): void {\n\t\tconst voices: EditableEvent[][] = [];\n\t\tthis.events.forEach((event) => {\n\t\t\tif (event?.voice >= 0) {\n\t\t\t\tvoices[event.voice] = voices[event.voice] || [];\n\t\t\t\tvoices[event.voice].push(event);\n\t\t\t}\n\t\t});\n\n\t\tvoices.forEach((voice) => voice.sort((e1, e2) => e1.tick - e2.tick));\n\n\t\tthis.voices = voices.map((voice) => voice.map((event) => event.id));\n\t}\n\n\tget agent(): MeasureUIAgent {\n\t\treturn new Proxy(this as any, {\n\t\t\tget: (target, key): any => {\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\treturn self[key];\n\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn self.voices?.map((voice) => voice.join(',')) || null;\n\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\treturn self.basics[0][key];\n\t\t\t\t\t//case 'events':\n\t\t\t\t\t//\treturn self.events.map(eventUIAgent);\n\t\t\t\t\tcase 'toJSON':\n\t\t\t\t\t\treturn () => ({\n\t\t\t\t\t\t\tmeasureIndex: self.measureIndex,\n\t\t\t\t\t\t\tvoices: self.voices,\n\t\t\t\t\t\t\tduration: self.duration,\n\t\t\t\t\t\t\ttimeSignature: self.basics[0].timeSignature,\n\t\t\t\t\t\t\tkeySignature: self.basics[0].keySignature,\n\t\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t},\n\n\t\t\tset: (target, key, value): boolean => {\n\t\t\t\t//console.log('set:', key, value);\n\t\t\t\tconst self = target as any as EditableMeasure;\n\n\t\t\t\tswitch (key) {\n\t\t\t\t\tcase 'timeSignature':\n\t\t\t\t\tcase 'keySignature':\n\t\t\t\t\tcase 'doubtfulTimesig':\n\t\t\t\t\t\t(self.basics[0][key] as any) = value;\n\t\t\t\t\t\tself.basics = self.basics.map(() => self.basics[0]);\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'duration':\n\t\t\t\t\t\tself.duration = value;\n\n\t\t\t\t\t\treturn true;\n\t\t\t\t\tcase 'measureIndex':\n\t\t\t\t\tcase 'voices':\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t},\n\n\t\t\townKeys: (): string[] => ['measureIndex', 'timeSignature', 'doubtfulTimesig', 'keySignature', 'duration', 'voices'],\n\n\t\t\tgetOwnPropertyDescriptor() {\n\t\t\t\treturn { enumerable: true, configurable: true };\n\t\t\t},\n\t\t});\n\t}\n\n\tmakeMIDI(bpm: number = 120): MIDI.MidiData {\n\t\tif (!this.regulated) return null;\n\n\t\tconst microsecondsPerBeat = 60e6 / bpm;\n\n\t\tconst header = { formatType: 0, ticksPerBeat: 480 };\n\t\tconst tracks = this.voices.map((ids, vi) => {\n\t\t\tconst events = ids\n\t\t\t\t.map((id) => {\n\t\t\t\t\tconst event = this.events.find((event) => event.id === id);\n\t\t\t\t\tif (event) {\n\t\t\t\t\t\tconst subEvents = event.graceIds ? event.graceIds.map((id) => this.events.find((event) => event.id === id)) : [];\n\n\t\t\t\t\t\treturn [...subEvents, event];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [];\n\t\t\t\t})\n\t\t\t\t.flat(1);\n\n\t\t\tconst startTime = 0;\n\n\t\t\ttype Event = MIDI.MidiEvent & { [key: string]: any };\n\t\t\tconst midiEvents: Event[] = events\n\t\t\t\t.filter((event) => !event.rest && Number.isFinite(event.tick) && event.tick >= 0 && Number.isFinite(event.duration))\n\t\t\t\t.map((event) =>\n\t\t\t\t\tevent.pitches.map((pitch) => [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOn',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t\tvelocity: 96,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: event.id,\n\t\t\t\t\t\t\ttime: event.tick + event.duration,\n\t\t\t\t\t\t\ttype: 'channel',\n\t\t\t\t\t\t\tsubtype: 'noteOff',\n\t\t\t\t\t\t\tchannel: event.staff,\n\t\t\t\t\t\t\tnoteNumber: noteToPitch(pitch),\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t)\n\t\t\t\t.flat(2);\n\n\t\t\tmidiEvents.sort(function (e1, e2) {\n\t\t\t\treturn e1.time - e2.time;\n\t\t\t});\n\n\t\t\tif (vi === 0) {\n\t\t\t\tmidiEvents.unshift(\n\t\t\t\t\t{\n\t\t\t\t\t\ttime: startTime,\n\t\t\t\t\t\ttype: 'meta',\n\t\t\t\t\t\tsubtype: 'timeSignature',\n\t\t\t\t\t\tnumerator: this.timeSignature.numerator,\n\t\t\t\t\t\tdenominator: this.timeSignature.denominator,\n\t\t\t\t\t\tthirtyseconds: 8,\n\t\t\t\t\t},\n\t\t\t\t\t{ time: startTime, type: 'meta', subtype: 'setTempo', microsecondsPerBeat }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tmidiEvents.forEach((event) => {\n\t\t\t\tevent.ticks = Math.round(event.time - startTime);\n\t\t\t});\n\t\t\tmidiEvents.forEach((event, i) => {\n\t\t\t\tevent.deltaTime = event.ticks - (i > 0 ? midiEvents[i - 1].ticks : 0);\n\t\t\t});\n\n\t\t\tmidiEvents.push({ deltaTime: 0, type: 'meta', subtype: 'endOfTrack' });\n\n\t\t\treturn midiEvents;\n\t\t});\n\n\t\treturn {\n\t\t\theader,\n\t\t\ttracks,\n\t\t};\n\t}\n}\n\nexport { EditableEvent, EditableMeasure };\n","import { RegulationSolution, RegulationSolutionEvent, EventPredisposition } from './interfaces';\nimport { SpartitoMeasure } from './spartitoMeasure';\nimport { EventCluster, EventElement, EventElementType } from './eventTopology';\nimport { argmax, frac } from './utils';\nimport { WHOLE_DURATION, StemBeam } from './term';\nimport { Logger, DummyLogger } from './logger';\n\ninterface BeadPicker {\n\tn_seq: number;\n\tquota: number;\n\tcost: number; // duration in milliseconds\n\n\tpredictCluster(cluster: EventCluster, tip: number): Promise;\n}\n\nenum BeadType {\n\tPass = 'i',\n\tDivision = 'd',\n\tDots = 'o',\n}\n\nconst DIVISION_NAMES = ['whole', 'half', 'quarter', 'eighth', 'sixteenth', 'thirtysecond', 'sixtyfourth', '128th', '256th'];\n\ninterface BeadNodeInitData {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n}\n\nconst RESIDUE_LOSS_WEIGHT = 0.2;\nconst VOICEN_LOSS_WEIGHT = 0.002;\nconst SPACE_LOSS_WEIGHT = 0.4 / WHOLE_DURATION;\nconst PRETENTIOUSNESS_LOSS_WEIGHT = 0.02;\n\nconst POSSIBILITY_LOW_BOUNDARY = 1e-12;\n\nconst PRETENTIOUSNESS_CLIP = 100;\n\ninterface ClusterEvaluation {\n\ttickErr: number;\n\ttwist: number;\n\tresidue: number;\n\tendTick: number;\n\tfatalError: boolean;\n\tvoiceN: number;\n\tspaceDuration: number;\n\tpretentiousness: number;\n\tloss: number;\n}\n\ninterface ElementState {\n\ttick: number;\n\tdivision: number;\n\tdots: number;\n\tbeam: StemBeam;\n\tstemDirection: string;\n\tgrace: boolean;\n\ttimeWarped: boolean;\n\tfullMeasure: boolean; // full measure rest\n\tfake: boolean;\n\torder: number;\n\tpredisposition: EventPredisposition;\n}\n\ninterface ClusterState {\n\telements: ElementState[];\n}\n\nconst STEM_DIRECTION_OPTIONS = [undefined, 'u', 'd'];\n\nconst BEAM_OPTIONS = [undefined, StemBeam.Open, StemBeam.Continue, StemBeam.Close];\n\nconst saveClusterState = (cluster: EventCluster): ClusterState => ({\n\telements: cluster.elements.map((elem) => ({\n\t\ttick: elem.tick!,\n\t\tdivision: elem.division!,\n\t\tdots: elem.dots!,\n\t\tbeam: elem.beam!,\n\t\tstemDirection: elem.stemDirection!,\n\t\tgrace: elem.grace!,\n\t\ttimeWarped: elem.timeWarped!,\n\t\tfullMeasure: elem.fullMeasure!,\n\t\tfake: elem.fake!,\n\t\torder: elem.order!,\n\t\tpredisposition: elem.predisposition!,\n\t})),\n});\n\nconst restoreClusterState = (cluster: EventCluster, state: ClusterState): void => cluster.elements.forEach((elem, i) => Object.assign(elem, state.elements[i]));\n\nconst measurePretentious = (p) => Math.min(PRETENTIOUSNESS_CLIP, -Math.log(p));\n\ninterface BeadDeductionContext {\n\tpicker: BeadPicker;\n\tlogger: Logger;\n\tptFactor: number; // pretentiousness tolerance factor\n}\n\nclass BeadNode {\n\tcluster: EventCluster;\n\telemIndex: number;\n\ttype: BeadType;\n\tpossibilities: number[];\n\tpretentiousness: number;\n\n\tchildren: Record;\n\taccessCount: number;\n\n\tconstructor(data: BeadNodeInitData) {\n\t\tObject.assign(this, data);\n\n\t\t//this.possibilities = this.possibilities.map((x, i) => (this.type === BeadType.Pass && !i) ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\n\t\tthis.children = {};\n\t\tthis.accessCount = 0;\n\t}\n\n\tnextBranch(): number | null {\n\t\tconst ps = this.possibilities.map((p, i) => p / (this.children[i] ? this.children[i].accessCount + 1 : 1));\n\t\t//const ps = this.possibilities.map((p, i) => p * (this.children[i] ? (2 ** -this.children[i].accessCount) : 1));\n\n\t\tif (ps.every((p) => !p)) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn null;\n\t\t}\n\n\t\treturn argmax(ps);\n\t}\n\n\tget currentElem(): EventElement {\n\t\treturn this.cluster.elements[this.elemIndex];\n\t}\n\n\tbranchID(ni: number): string {\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\treturn `i_${ni}`;\n\t\t\tcase BeadType.Division:\n\t\t\t\treturn DIVISION_NAMES[ni];\n\t\t\tcase BeadType.Dots:\n\t\t\t\treturn 'o' + '.'.repeat(ni);\n\t\t}\n\n\t\treturn '';\n\t}\n\n\tasync deduce({ picker, logger, ptFactor }: BeadDeductionContext, deep: number = 0): Promise {\n\t\t++this.accessCount;\n\n\t\tconst ni = this.nextBranch()!;\n\t\tlogger.debug(String.fromCodePoint(0x1f349) + ' '.repeat(deep), this.branchID(ni), this.accessCount > 1 ? `[${this.accessCount}]` : '');\n\n\t\tif (!Number.isInteger(ni) || ni < 0) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tthis.pretentiousness += measurePretentious(this.possibilities[ni]);\n\t\tif (this.pretentiousness > PRETENTIOUSNESS_CLIP * ptFactor) {\n\t\t\tthis.accessCount = Infinity;\n\t\t\treturn evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t}\n\n\t\tlet selfEval: null | ClusterEvaluation = null;\n\n\t\tswitch (this.type) {\n\t\t\tcase BeadType.Pass:\n\t\t\t\t{\n\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\tconst element = this.cluster.elements[ni];\n\t\t\t\t\tconsole.assert(element, 'null element:', ni, this.cluster.elements.length);\n\t\t\t\t\tif (element.type === EventElementType.EOS) {\n\t\t\t\t\t\tselfEval = evaluateCluster(this.cluster, tip, this.pretentiousness);\n\t\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.cluster.elements[0].order = tip;\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip + 1)).map((x, i) =>\n\t\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 || i === this.cluster.elements.length - 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: 0,\n\t\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.order = tip;\n\n\t\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\t\tconsole.assert(element.predisposition, 'no predisposition:', ni, this.possibilities);\n\t\t\t\t\t\t\tconst possibilities = element.predisposition!.divisionVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\t\telemIndex: ni,\n\t\t\t\t\t\t\t\ttype: BeadType.Division,\n\t\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Division:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.division = ni;\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tconst possibilities = this.currentElem.predisposition!.dotsVector.map((x) => Math.max(POSSIBILITY_LOW_BOUNDARY, x));\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Dots,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase BeadType.Dots:\n\t\t\t\t{\n\t\t\t\t\tthis.currentElem.dots = ni;\n\n\t\t\t\t\tselfEval = evaluateCluster(this.cluster, this.currentElem.order! + 1, this.pretentiousness);\n\t\t\t\t\tif (!selfEval.residue || selfEval.fatalError) {\n\t\t\t\t\t\tthis.accessCount = Infinity;\n\t\t\t\t\t\treturn selfEval!;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!this.children[ni]) {\n\t\t\t\t\t\tif (!picker.quota) return selfEval;\n\n\t\t\t\t\t\tconst tip = this.currentElem.order! + 1;\n\t\t\t\t\t\tconst possibilities = (await picker.predictCluster(this.cluster, tip)).map((x, i) =>\n\t\t\t\t\t\t\tthis.cluster.elements[i].order! < tip + 1 ? 0 : Math.max(POSSIBILITY_LOW_BOUNDARY, x)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.children[ni] = new BeadNode({\n\t\t\t\t\t\t\tcluster: this.cluster,\n\t\t\t\t\t\t\telemIndex: this.elemIndex,\n\t\t\t\t\t\t\ttype: BeadType.Pass,\n\t\t\t\t\t\t\tpossibilities,\n\t\t\t\t\t\t\tpretentiousness: this.pretentiousness,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\tconst evaluation = await this.children[ni].deduce({ picker, logger, ptFactor }, deep + 1);\n\t\tif (selfEval && evaluation.fatalError) {\n\t\t\tconst tip = this.currentElem.order!;\n\t\t\tthis.cluster.elements.forEach((elem) => {\n\t\t\t\tif (elem.order! > tip) elem.order = undefined;\n\t\t\t});\n\n\t\t\t// clear children data\n\t\t\tthis.cluster.elements.forEach((elem) => (elem.order = elem.order! > this.currentElem.order! ? undefined : elem.order));\n\t\t\tthis.cluster.elements[this.cluster.elements.length - 1].tick = selfEval.endTick;\n\n\t\t\treturn selfEval;\n\t\t}\n\n\t\treturn evaluation;\n\t}\n}\n\nconst estimateElementDuration = (elem: EventElement) => WHOLE_DURATION * 2 ** -elem.division! * (2 - 2 ** -elem.dots!);\n\nconst evaluateCluster = (cluster: EventCluster, tip: number, pretentiousness: number): ClusterEvaluation => {\n\tconst events = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order) && elem.order! < tip\n\t);\n\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\tconst eos = cluster.elements[cluster.elements.length - 1];\n\n\tlet tick = 0;\n\tlet lastOrder = 0;\n\tlet endTick = 0;\n\tlet voiceN = 1;\n\n\t// [x, tick, estimated tick]\n\tconst scales: [number, number, number][] = [[eos.x, cluster.signatureDuration, cluster.signatureDuration]];\n\n\tlet totalDuration = 0;\n\n\t// assign tick for events\n\tevents.forEach((event) => {\n\t\tif (event.order! > lastOrder + 1) {\n\t\t\ttick = 0;\n\t\t\t++voiceN;\n\t\t}\n\n\t\tconst referenceScale = scales.find((s) => s[1] >= tick);\n\t\tif (referenceScale && event.x > referenceScale[0] + 3) {\n\t\t\tconst nearScale = scales.reduce((n, s) => (Math.abs(event.predisposition!.tick - s[2]) < Math.abs(event.predisposition!.tick - n[2]) ? s : n));\n\t\t\tif (Math.abs(nearScale[0] - event.x) < 2) tick = Math.max(tick, nearScale[1]);\n\t\t}\n\n\t\tevent.tick = tick;\n\n\t\tconst si = Math.max(\n\t\t\t0,\n\t\t\tscales.findIndex((s) => s[0] > event.x)\n\t\t);\n\t\tscales.splice(si, 0, [event.x, event.tick, event.predisposition!.tick]);\n\n\t\t//let duration = WHOLE_DURATION * (2 ** -event.division!) * (2 - 2 ** -event.dots!);\n\t\tlet duration = estimateElementDuration(event);\n\t\tif (event.predisposition!.timeWarped > 0.5) duration = (duration * 2) / 3;\n\n\t\ttick += duration;\n\t\ttotalDuration += duration;\n\t\tendTick = Math.max(endTick, tick);\n\t\tlastOrder = event.order!;\n\t});\n\n\t/*const pretentiousness = events.reduce((p, event) => p +\n\t\tmeasurePretentious(event.predisposition!.divisionVector![event.division!]) +\n\t\tmeasurePretentious(event.predisposition!.dotsVector![event.dots!]), 0);*/\n\n\tif (endTick > 0) cluster.elements[cluster.elements.length - 1].tick = endTick;\n\n\tconst xSpan = cluster.elements[cluster.elements.length - 1].pivotX! - cluster.elements[1].pivotX!;\n\tconst tickSpan = Math.max(...events.map((e) => e.tick!), endTick);\n\n\t// tick twist loss\n\tconst eventsXOrder = [...events].sort((e1, e2) => e1.pivotX! - e2.pivotX!);\n\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\tconst e1 = eventsXOrder[i];\n\t\tconst dx = e2.pivotX! - e1.pivotX!;\n\t\tconst dt = e2.tick! - e1.tick!;\n\n\t\tif (!dt) return dx / xSpan;\n\n\t\tconst rate = Math.atan2(dt / tickSpan, dx / xSpan);\n\n\t\t//if (dt < 0)\n\t\t//\tconsole.log(\"minus dt:\", dt, dx, rate);\n\n\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t});\n\t//console.debug(\"tickTwists:\", tickTwists, eventsXOrder);\n\n\tconst twist = Math.max(...tickTwists, 0);\n\n\tconst tickMSE = events.map((event) => (event.tick! - event.predisposition!.tick) ** 2);\n\t//console.debug(\"tickMSE:\", tickMSE.map(Math.sqrt));\n\tconst tickErr = tickMSE.length ? Math.sqrt(tickMSE.reduce((sum, mse) => sum + mse, 0) / tickMSE.length) : 0;\n\t//console.debug(\"tick/twist:\", tickErr / WHOLE_DURATION, twist);\n\n\tconst residueElements = cluster.elements.filter(\n\t\t(elem) =>\n\t\t\t[EventElementType.CHORD, EventElementType.REST].includes(elem.type) &&\n\t\t\t!(Number.isInteger(elem.order) && elem.order! < tip) &&\n\t\t\t!(elem.predisposition && elem.predisposition.fakeP > 0.5)\n\t);\n\tconst residue = residueElements.length;\n\n\tconst fatalError = twist >= 1 || endTick > cluster.signatureDuration;\n\n\t//const spaceDuration = Math.max(0, cluster.signatureDuration - endTick);\n\tconst spaceDuration = Math.max(0, cluster.signatureDuration - totalDuration / voiceN);\n\n\tconst loss =\n\t\ttickErr / WHOLE_DURATION +\n\t\ttwist +\n\t\tresidue * RESIDUE_LOSS_WEIGHT +\n\t\tvoiceN * VOICEN_LOSS_WEIGHT +\n\t\tspaceDuration * SPACE_LOSS_WEIGHT +\n\t\tpretentiousness * PRETENTIOUSNESS_LOSS_WEIGHT;\n\n\treturn {\n\t\ttickErr,\n\t\ttwist,\n\t\tresidue,\n\t\tendTick,\n\t\tfatalError,\n\t\tvoiceN,\n\t\tspaceDuration,\n\t\tpretentiousness,\n\t\tloss,\n\t};\n};\n\nconst solveCluster = async (\n\tcluster: EventCluster,\n\tpicker: BeadPicker,\n\tlogger: Logger,\n\tquota: number = 200,\n\tstopLoss: number = 0,\n\tptFactor: number = 1\n): Promise => {\n\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\tconst suc0 = await picker.predictCluster(cluster, 1);\n\n\tconst root = new BeadNode({ cluster, elemIndex: 0, pretentiousness: 0, type: BeadType.Pass, possibilities: suc0 });\n\n\tlet bestEvaluation: ClusterEvaluation | null = null;\n\tlet bestState: ClusterState | null = null;\n\n\tpicker.quota = quota;\n\twhile (picker.quota) {\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\n\t\tconst evaluation = await root.deduce({ picker, logger, ptFactor });\n\n\t\tlogger.debug('loss:', evaluation);\n\n\t\tif (!bestEvaluation || evaluation.loss < bestEvaluation.loss) {\n\t\t\tbestEvaluation = evaluation;\n\n\t\t\tcluster.duration = bestEvaluation.endTick;\n\t\t\tbestState = saveClusterState(cluster);\n\n\t\t\tif (Number.isFinite(stopLoss) && bestEvaluation.loss <= stopLoss!) break;\n\t\t}\n\n\t\tif (!Number.isFinite(root.accessCount)) break;\n\t}\n\tlogger.debug('bestEvaluation:', bestEvaluation);\n\n\trestoreClusterState(cluster, bestState!);\n\n\t// solve residue elements\n\tconst fixedEvents = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\tconst pendingEvents = cluster.elements.filter(\n\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && !Number.isInteger(elem.order)\n\t);\n\tif (fixedEvents.length) {\n\t\tpendingEvents.forEach((event) => {\n\t\t\t// exclude fake events (includes grace, fullMeasure) from voices\n\t\t\tevent.tick = undefined;\n\n\t\t\tif (event.predisposition!.fakeP < 0.5) {\n\t\t\t\t//const near = fixedEvents.reduce((n, e) => Math.abs(e.predisposition!.tick - event.predisposition!.tick) < Math.abs(n.predisposition!.tick - event.predisposition!.tick) ? e : n);\n\t\t\t\tconst duration = estimateElementDuration(event);\n\t\t\t\tconst candidates = fixedEvents.filter((e) => e.tick! + duration <= bestEvaluation!.endTick);\n\t\t\t\tif (candidates.length) {\n\t\t\t\t\tconst near = candidates.reduce((n, e) => (Math.abs(e.x - event.x) < Math.abs(n.x - event.x) ? e : n));\n\t\t\t\t\tevent.tick = near.tick;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tfixedEvents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t// properties\n\t[...fixedEvents, ...pendingEvents].forEach((event) => {\n\t\tevent.grace = !Number.isFinite(event.tick) && event.predisposition!.grace;\n\t\tevent.timeWarped = event.predisposition!.timeWarped > 0.5;\n\t\tevent.fullMeasure = event.predisposition!.fullMeasure > 0.5;\n\t\tevent.stemDirection = STEM_DIRECTION_OPTIONS[argmax(event.predisposition!.stemDirectionVector)];\n\t\tevent.beam = BEAM_OPTIONS[argmax(event.predisposition!.beamVector)];\n\t});\n\n\t// construct matrixH\n\tconst ids = cluster.elements.map((e) => e.index);\n\tconst idx = (id: number): number => ids.indexOf(id);\n\tcluster.matrixH = cluster.elements.map(() => Array(cluster.elements.length).fill(0));\n\tfixedEvents.forEach((event, i) => {\n\t\tconst lastEvent = fixedEvents[i - 1];\n\t\tif (!lastEvent || lastEvent.order! < event.order! - 1) {\n\t\t\tcluster.matrixH![idx(event.index!)][0] = 1;\n\t\t\tif (lastEvent) cluster.matrixH![cluster.elements.length - 1][idx(lastEvent.index!)] = 1;\n\t\t} else {\n\t\t\tconsole.assert(\n\t\t\t\tcluster.matrixH![idx(event.index!)] && Number.isFinite(cluster.matrixH![idx(event.index!)][idx(lastEvent.index!)]),\n\t\t\t\t'matrixH out of range:',\n\t\t\t\tevent.index,\n\t\t\t\tlastEvent.index,\n\t\t\t\tcluster.matrixH!.length\n\t\t\t);\n\n\t\t\tcluster.matrixH![idx(event.index!)][idx(lastEvent.index!)] = 1;\n\t\t}\n\t});\n\tif (!pendingEvents.length && fixedEvents.length) cluster.matrixH![cluster.elements.length - 1][idx(fixedEvents[fixedEvents.length - 1].index!)] = 1;\n\n\treturn bestEvaluation!;\n};\n\ninterface BeadSolverOptions {\n\tpicker: BeadPicker;\n\tstopLoss?: number;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tptFactor?: number;\n\tlogger?: Logger;\n}\n\nconst solveMeasure = async (measure: SpartitoMeasure, options: BeadSolverOptions): Promise => {\n\tconst { stopLoss = 0.09, quotaMax = 1000, quotaFactor = 5, ptFactor = 1, logger = new DummyLogger() } = options;\n\n\tlet worstLoss = 0;\n\n\tconst clusters = measure.createClusters();\n\tfor (const cluster of clusters) {\n\t\tconst quota = Math.min(quotaMax, Math.ceil(cluster.elements.length * quotaFactor));\n\t\tlogger.info(`[measure-${measure.measureIndex}]`, quota);\n\t\tconst { loss } = await solveCluster(cluster, options.picker, logger, quota, stopLoss, ptFactor);\n\t\tworstLoss = Math.max(worstLoss, loss);\n\t}\n\n\tconst voices = [] as number[][];\n\n\tconst durations = [] as number[];\n\n\tconst solutionEvents = [] as RegulationSolutionEvent[];\n\n\tclusters.forEach((cluster) => {\n\t\tconst events = cluster.elements.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isInteger(elem.order));\n\t\tevents.sort((e1, e2) => e1.order! - e2.order!);\n\n\t\tif (!events.length) return;\n\n\t\tlet voice = [] as number[];\n\t\tvoices.push(voice);\n\t\tlet lastOrder = 0;\n\t\tevents.forEach((event) => {\n\t\t\tif (event.fullMeasure || event.grace || event.tremoloCatcher) return;\n\n\t\t\tif (event.order! > lastOrder + 1) {\n\t\t\t\tvoice = [event.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t} else voice.push(event.index!);\n\n\t\t\tlastOrder = event.order!;\n\t\t});\n\n\t\tlet tipElem = events[events.length - 1];\n\n\t\t// complete voices from pending events\n\t\tconst pendingEvents = cluster.elements.filter(\n\t\t\t(elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type) && Number.isFinite(elem.tick) && !Number.isInteger(elem.order)\n\t\t);\n\t\twhile (pendingEvents.length) {\n\t\t\tconst ei = pendingEvents.findIndex((e) => e.tick! >= tipElem.tick! + estimateElementDuration(tipElem));\n\t\t\tif (ei >= 0) voice.push(pendingEvents.splice(ei, 1)[0].index!);\n\t\t\telse {\n\t\t\t\ttipElem = pendingEvents.splice(0, 1)[0];\n\t\t\t\tvoice = [tipElem.index!];\n\t\t\t\tvoices.push(voice);\n\t\t\t}\n\t\t}\n\n\t\tif (events.some((elem) => !elem.fullMeasure && Number.isInteger(elem.order))) {\n\t\t\tconst eos = cluster.elements.find((elem) => elem.type === EventElementType.EOS);\n\t\t\tdurations.push(eos!.tick!);\n\t\t}\n\n\t\tconst eventMap = measure.eventMap;\n\n\t\tconst tickSet = cluster.elements.reduce((set, elem) => {\n\t\t\tif (Number.isFinite(elem.tick)) set.add(elem.tick!);\n\t\t\treturn set;\n\t\t}, new Set());\n\t\tconst ticks = Array.from(tickSet).sort((t1, t2) => t1 - t2);\n\n\t\t// fill solutionEvents\n\t\tevents.forEach((elem) => {\n\t\t\tconst event = eventMap[elem.index!];\n\t\t\tif (event) {\n\t\t\t\tsolutionEvents.push({\n\t\t\t\t\tid: event.id!,\n\t\t\t\t\ttick: elem.tick!,\n\t\t\t\t\ttickGroup: ticks.indexOf(elem.tick!),\n\t\t\t\t\tdivision: elem.division !== event.division ? elem.division : undefined,\n\t\t\t\t\tdots: elem.dots !== event.dots ? elem.dots : undefined,\n\t\t\t\t\ttimeWarp: elem.timeWarped ? frac(2, 3) : undefined, // TODO:\n\t\t\t\t\tbeam: elem.beam !== event.beam ? elem.beam : undefined,\n\t\t\t\t\tgrace: elem.grace !== !!event.grace ? elem.grace : undefined,\n\t\t\t\t\tfullMeasure: elem.fullMeasure || undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n\n\tconst estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n\n\treturn {\n\t\tvoices: voices.filter((voice) => voice.length),\n\t\tduration: Math.max(...durations),\n\t\tevents: solutionEvents,\n\t\tpriority: -worstLoss,\n\t\testimatedDuration,\n\t};\n};\n\ninterface GlimpseMeasureOptions {\n\tpicker: BeadPicker;\n\tresetSignatureForDoubtfulOnly?: boolean;\n}\n\nconst glimpseMeasure = async (measure: SpartitoMeasure, { picker, resetSignatureForDoubtfulOnly }: GlimpseMeasureOptions): Promise => {\n\tconst clusters = measure.createClusters();\n\tconst eventMap = measure.eventMap;\n\n\tfor (const cluster of clusters) {\n\t\tif (!resetSignatureForDoubtfulOnly || measure.doubtfulTimesig) cluster.signatureDuration = 0; // re-estimate measure duration\n\t\tcluster.elements.forEach((elem, i) => (elem.order = i ? undefined : 0));\n\t\tawait picker.predictCluster(cluster, 1);\n\n\t\tcluster.elements\n\t\t\t.filter((elem) => [EventElementType.CHORD, EventElementType.REST].includes(elem.type))\n\t\t\t.forEach((elem) => {\n\t\t\t\tconst event = eventMap[elem.index!];\n\t\t\t\tevent.predisposition = elem.predisposition!;\n\t\t\t});\n\t}\n\n\tmeasure.estimatedDuration = Math.max(...clusters.map((c) => c.estimatedDuration));\n};\n\nconst estimateMeasure = async (measure: SpartitoMeasure, picker: BeadPicker): Promise =>\n\tglimpseMeasure(measure, { picker, resetSignatureForDoubtfulOnly: true });\n\nexport { BeadPicker, solveCluster, solveMeasure, estimateMeasure, glimpseMeasure };\n","import { EventTerm } from './term';\nimport type { SpartitoMeasure } from './spartitoMeasure';\n\ninterface EventRectification {\n\tid: number;\n\tdivision?: number;\n\tdots?: number;\n}\n\n// Here suppose sum of pvals equal to 1.\nconst multinomial_1 = (pvals: number[]): number => {\n\tconst n = Math.random();\n\n\tlet s = 0;\n\tfor (let i = 0; i < pvals.length; ++i) {\n\t\ts += pvals[i];\n\t\tif (s > n) return i;\n\t}\n\n\treturn pvals.length - 1;\n};\n\nconst looseVector = (ns: number[], factor = 0.9): number[] => {\n\tconst logits = ns.map((n) => Math.log(n) * factor);\n\tconst n2 = logits.map(Math.exp);\n\n\tconst sum = n2.reduce((sum, x) => sum + x, 0);\n\n\treturn n2.map((x) => x / sum);\n};\n\nconst looseEvent = (event: EventTerm): EventTerm => {\n\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return event;\n\n\tconst divisionVector = event.predisposition?.divisionVector ? looseVector(event.predisposition.divisionVector) : null;\n\tconst dotsVector = event.predisposition?.dotsVector ? looseVector(event.predisposition.dotsVector) : null;\n\n\treturn new EventTerm({\n\t\t...event,\n\t\tpredisposition: {\n\t\t\t...event.predisposition,\n\t\t\tdivisionVector,\n\t\t\tdotsVector,\n\t\t},\n\t});\n};\n\nclass MeasureRectification {\n\tevents: EventRectification[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\ttoString(): string {\n\t\treturn this.events\n\t\t\t.map((event) => {\n\t\t\t\tif (!event) return '';\n\n\t\t\t\tconst { division = '', dots = '' } = event;\n\t\t\t\treturn `${division}|${dots}`;\n\t\t\t})\n\t\t\t.join(',');\n\t}\n\n\tstatic default(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tconst division = event.predisposition.divisionVector ? event.division : undefined;\n\t\t\t\tconst dots = event.predisposition.dotsVector ? event.dots : undefined;\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n\n\tstatic roll(events: EventTerm[]): MeasureRectification {\n\t\treturn new MeasureRectification({\n\t\t\tevents: events.map((event) => {\n\t\t\t\tif (!event.predisposition?.divisionVector && !event.predisposition?.dotsVector) return null;\n\n\t\t\t\tlet division = undefined;\n\t\t\t\tlet dots = undefined;\n\n\t\t\t\tif (event.predisposition.divisionVector) division = multinomial_1(event.predisposition.divisionVector);\n\n\t\t\t\tif (event.predisposition.dotsVector) dots = multinomial_1(event.predisposition.dotsVector);\n\n\t\t\t\treturn { id: event.id, division, dots };\n\t\t\t}),\n\t\t});\n\t}\n}\n\nconst genMeasureRectifications = function* (measure: SpartitoMeasure): Generator {\n\tconst keys = new Set();\n\n\tconst origin = MeasureRectification.default(measure.events);\n\tkeys.add(origin.toString());\n\n\tyield origin;\n\n\tlet stale = 0;\n\tlet events = measure.events;\n\n\twhile (stale < 100) {\n\t\tif (stale && stale % 10 === 0) events = events.map(looseEvent);\n\n\t\tconst rectification = MeasureRectification.roll(events);\n\t\tconst key = rectification.toString();\n\n\t\tif (keys.has(key)) {\n\t\t\t++stale;\n\t\t\tcontinue;\n\t\t}\n\n\t\tstale = 0;\n\n\t\tkeys.add(key);\n\t\tyield rectification;\n\t}\n};\n\nexport { MeasureRectification, genMeasureRectifications };\n","import { WeakLRUCache } from 'weak-lru-cache';\n\nimport { RegulationSolution, SpartitoMeasure } from '../../src/starry';\n\nconst lruCache = new WeakLRUCache();\n\ninterface SolutionStore {\n\tget: (key: string) => Promise;\n\tset: (key: string, val: RegulationSolution) => Promise;\n\tbatchGet: (keys: string[]) => Promise;\n}\n\n// 默认store\nconst DefaultSolutionStore: SolutionStore = {\n\tasync get(key: string) {\n\t\treturn lruCache.getValue(key) as RegulationSolution;\n\t},\n\tasync set(key: string, val: RegulationSolution) {\n\t\tlruCache.setValue(key, val);\n\t},\n\tasync batchGet(keys: string[]) {\n\t\treturn keys.map((key) => lruCache.getValue(key) as RegulationSolution);\n\t},\n};\n\nconst enum MeasureStatus {\n\tDiscard = -1,\n\tSolved = 0,\n\tIssue = 1,\n\tFatal = 2,\n}\n\ninterface IssueMeasure {\n\tscoreId: string;\n\tmeasureIndex: number;\n\tmeasure: SpartitoMeasure;\n\tstatus: MeasureStatus;\n}\n\ntype SaveIssueMeasure = (data: Omit) => void;\n\nexport { SolutionStore, DefaultSolutionStore, MeasureStatus, IssueMeasure, SaveIssueMeasure };\n","import * as starry from '../../src/starry';\nimport { Logger } from './ZeroClient';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure, MeasureStatus } from './store';\n\ninterface BeadRegulationCounting {\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface RegulationBeadStat {\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tmeasures: BeadRegulationCounting;\n\tqualityScore: number;\n}\n\ninterface RegulationBeadSummary {\n\tscoreN: number;\n\n\ttotalCost: number; // in milliseconds\n\tpickerCost: number; // in milliseconds\n\tcostPerMeasure: number | null; // in milliseconds\n\tcostPerTime: number | null; // in milliseconds\n\n\tcached: number;\n\tsimple: number;\n\tcomputed: number;\n\ttryTimes: number;\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\ninterface ProgressInfo {\n\tpass: number;\n\tremaining: number;\n\ttotal: number;\n}\n\ninterface RegulateBeadOption {\n\tlogger?: Logger;\n\tpickers: starry.BeadPicker[];\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tfreshOnly?: boolean;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n\tonProgress?: (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => void;\n\tonPassStart?: (pass: number, conditionName: string, pendingCount: number) => void;\n}\n\ninterface MeasureReord {\n\torigin: starry.SpartitoMeasure;\n\tcurrent: starry.SpartitoMeasure;\n\tevaluation?: starry.MeasureEvaluation;\n\tbaseQuality: number;\n\tpicker: starry.BeadPicker;\n}\n\ninterface BeadSolverOptions {\n\tstopLoss: number;\n\tquotaMax: number;\n\tquotaFactor: number;\n\tptFactor: number;\n}\n\nenum PendingCondition {\n\tErrorOnly,\n\tNotFine,\n\tImperfect,\n}\n\nconst isPending = (evaluation: starry.MeasureEvaluation, condition: PendingCondition) => {\n\tswitch (condition) {\n\t\tcase PendingCondition.ErrorOnly:\n\t\t\treturn evaluation.error;\n\n\t\tcase PendingCondition.Imperfect:\n\t\t\treturn !evaluation.perfect;\n\t}\n\n\treturn !evaluation.fine;\n};\n\ntype OnUpdate = (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean) => void;\n\nconst solveMeasureRecords = async (\n\trecords: MeasureReord[],\n\tonUpdate: OnUpdate,\n\tstdout: NodeJS.WritableStream | null,\n\toptions: Partial,\n\tpendingCondition: PendingCondition = PendingCondition.NotFine,\n\tpass: number = 0,\n\tonProgress?: RegulateBeadOption['onProgress']\n): Promise => {\n\tconst pendingRecords = records.filter(({ evaluation }) => !evaluation || isPending(evaluation, pendingCondition));\n\tstdout?.write('.'.repeat(pendingRecords.length));\n\tstdout?.write('\\b'.repeat(pendingRecords.length));\n\n\tconst total = pendingRecords.length;\n\tlet done = 0;\n\n\tfor (const record of pendingRecords) {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tconst solution = await starry.beadSolver.solveMeasure(measure, { picker: record.picker, ...options });\n\t\tmeasure.applySolution(solution);\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better =\n\t\t\t!record.evaluation ||\n\t\t\tevaluation.fine > record.evaluation.fine ||\n\t\t\t(evaluation.qualityScore > record.evaluation.qualityScore && evaluation.fine === record.evaluation.fine);\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\t\t}\n\n\t\tonUpdate(record.current, evaluation, better);\n\n\t\tdone++;\n\t\tonProgress?.(record.current, evaluation, better, { pass, remaining: total - done, total });\n\t}\n\n\tif (pendingRecords.length) stdout?.write('\\n');\n\n\treturn pendingRecords.length;\n};\n\nconst regulateWithBeadSolver = async (\n\tscore: starry.Score,\n\t{ logger, pickers, solutionStore = DefaultSolutionStore, ignoreCache, freshOnly, onSaveIssueMeasure, onProgress, onPassStart }: RegulateBeadOption\n): Promise => {\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\tlogger?.info(`[regulateWithBeadSolver] begin, measure total: ${spartito.measures.length}.`, ignoreCache ? 'ignoreCache' : '', freshOnly ? 'freshOnly' : '');\n\n\tconst records = spartito.measures\n\t\t.filter((measure) => measure.events?.length && !measure.patched)\n\t\t.map(\n\t\t\t(measure) =>\n\t\t\t\t({\n\t\t\t\t\torigin: measure.deepCopy(),\n\t\t\t\t\tcurrent: measure,\n\t\t\t\t\tevaluation: undefined,\n\t\t\t\t\tbaseQuality: 0,\n\t\t\t\t} as MeasureReord)\n\t\t);\n\n\t// rectify time signature\n\tfor (const measure of spartito.measures.filter((measure) => measure.events?.length)) {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > measure.events.length + 1);\n\t\tif (picker) await starry.beadSolver.estimateMeasure(measure, picker);\n\t}\n\tspartito.rectifyTimeSignatures(logger as any);\n\n\t// zero pickers' cost\n\tpickers.forEach((picker) => (picker.cost = 0));\n\n\tconst counting = {\n\t\tcached: 0,\n\t\tsimple: 0,\n\t\tcomputed: 0,\n\t\ttryTimes: 0,\n\t\tsolved: 0,\n\t\tissue: 0,\n\t\tfatal: 0,\n\t};\n\n\tlogger?.info(`[regulateWithBeadSolver] measures estimation finished.`);\n\n\t// apply solutions\n\tif (solutionStore && !ignoreCache)\n\t\tfor (const record of records) {\n\t\t\tconst solution = await solutionStore.get(record.origin.regulationHash0);\n\t\t\tif (solution) {\n\t\t\t\trecord.current.applySolution(solution);\n\t\t\t\t++counting.cached;\n\n\t\t\t\trecord.evaluation = starry.evaluateMeasure(record.current);\n\t\t\t\trecord.baseQuality = record.evaluation.qualityScore;\n\t\t\t}\n\t\t}\n\n\tlogger?.info('[regulateWithBeadSolver]', `${counting.cached}/${records.length}`, 'solutions loaded.');\n\n\tconst stdout = logger ? null : process.stdout;\n\tif (counting.cached) stdout?.write(`${counting.cached}c`);\n\n\trecords.forEach((record) => {\n\t\tconst picker = pickers.find((picker) => picker.n_seq > record.current.events.length + 1);\n\t\tif (!picker) {\n\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] size out of range:`, record.current.events.length);\n\t\t} else record.picker = picker;\n\t});\n\n\tconst pendingRecords = records.filter((record) => record.picker && (!record.evaluation || (!record.evaluation.fine && !freshOnly))) as (MeasureReord & {\n\t\tevaluation: starry.MeasureEvaluation;\n\t})[];\n\n\t// solve by simple policy\n\tpendingRecords.forEach((record) => {\n\t\tconst measure = record.current.deepCopy();\n\t\tmeasure.staffGroups = record.current.staffGroups;\n\n\t\tmeasure.regulate({ policy: 'simple' });\n\n\t\tconst evaluation = starry.evaluateMeasure(measure);\n\t\tconst better = !record.evaluation || evaluation.qualityScore > record.evaluation.qualityScore;\n\t\tif (better) {\n\t\t\trecord.evaluation = evaluation;\n\t\t\tObject.assign(record.current, measure);\n\n\t\t\tif (evaluation.perfect) {\n\t\t\t\tlogger?.info(`[regulateWithBeadSolver] measure[${record.current.measureIndex}] regulated by simple policy.`);\n\t\t\t\t++counting.simple;\n\t\t\t}\n\t\t}\n\t});\n\tcounting.computed = pendingRecords.length - counting.simple;\n\n\tif (counting.simple) stdout?.write(`${counting.simple}s`);\n\n\tconst onUpdate = (measure, evaluation, better) => {\n\t\tlogger?.info(\n\t\t\t`[regulateWithBeadSolver] measure[${measure.measureIndex}/${spartito.measures.length}] regulated${\n\t\t\t\tbetter ? '+' : '-'\n\t\t\t}: ${evaluation.qualityScore.toFixed(3)}, ${evaluation.fine ? 'solved' : evaluation.error ? 'error' : 'issue'}, ${measure.regulationHash}`\n\t\t);\n\n\t\tstdout?.write(`\\x1b[${evaluation.fine ? '32' : evaluation.error ? '31' : '33'}m${better ? '+' : '-'}\\x1b[0m`);\n\t};\n\n\t// Global progress: total = all measures, remaining = non-fine measures across all passes\n\tconst totalMeasures = spartito.measures.length;\n\tconst computeRemaining = () => pendingRecords.filter((r) => !r.evaluation?.fine).length;\n\tconst wrappedOnProgress = onProgress\n\t\t? (measure: starry.SpartitoMeasure, evaluation: starry.MeasureEvaluation, better: boolean, progress: ProgressInfo) => {\n\t\t\t\tonProgress(measure, evaluation, better, { pass: progress.pass, remaining: computeRemaining(), total: totalMeasures });\n\t\t }\n\t\t: undefined;\n\n\tonPassStart?.(1, 'Imperfect', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.05, quotaMax: 200, quotaFactor: 3, ptFactor: 1 },\n\t\tPendingCondition.Imperfect,\n\t\t1,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(2, 'NotFine', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 20, ptFactor: 1.6 },\n\t\tPendingCondition.NotFine,\n\t\t2,\n\t\twrappedOnProgress\n\t);\n\tonPassStart?.(3, 'ErrorOnly', computeRemaining());\n\tcounting.tryTimes += await solveMeasureRecords(\n\t\tpendingRecords,\n\t\tonUpdate,\n\t\tstdout,\n\t\t{ stopLoss: 0.08, quotaMax: 1000, quotaFactor: 40, ptFactor: 3 },\n\t\tPendingCondition.ErrorOnly,\n\t\t3,\n\t\twrappedOnProgress\n\t);\n\n\tpendingRecords.forEach(({ evaluation, baseQuality, current, origin }) => {\n\t\tif (evaluation.fine) ++counting.solved;\n\t\telse if (evaluation.error) ++counting.fatal;\n\t\telse ++counting.issue;\n\n\t\tif (evaluation.qualityScore > baseQuality || !baseQuality) {\n\t\t\tsolutionStore.set(origin.regulationHash0, { ...current.asSolution(origin), priority: -current?.solutionStat?.loss! });\n\t\t\tif (current.regulationHash !== origin.regulationHash0)\n\t\t\t\tsolutionStore.set(current.regulationHash, { ...current.asSolution(), priority: -current?.solutionStat?.loss! });\n\t\t\t//console.log('better:', current.measureIndex, evaluation.qualityScore, baseQuality);\n\t\t}\n\n\t\tif (!evaluation.fine) {\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: current.measureIndex,\n\t\t\t\tmeasure: new starry.EditableMeasure(current),\n\t\t\t\tstatus: evaluation.error ? MeasureStatus.Fatal : MeasureStatus.Issue,\n\t\t\t});\n\t\t}\n\t});\n\n\tconst t1 = Date.now();\n\tconst pickerCost = pickers.reduce((cost, picker) => cost + picker.cost, 0);\n\n\tconst qualityScore = spartito.qualityScore;\n\tconst totalCost = t1 - t0;\n\n\tlogger?.info('[regulateWithBeadSolver] done in ', totalCost, 'ms, qualityScore:', qualityScore);\n\n\t// zero 'cached' statistics for freshOnly mode\n\tif (freshOnly) counting.cached = 0;\n\n\treturn {\n\t\ttotalCost: t1 - t0,\n\t\tpickerCost,\n\t\tmeasures: counting,\n\t\tqualityScore,\n\t};\n};\n\nconst abstractRegulationBeadStats = (stats: RegulationBeadStat[]): RegulationBeadSummary => {\n\tconst { totalCost, pickerCost, measureN, timeN } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\ttotalCost: sum.totalCost + stat.totalCost,\n\t\t\tpickerCost: sum.pickerCost + stat.pickerCost,\n\t\t\tmeasureN: sum.measureN + stat.measures.computed,\n\t\t\ttimeN: sum.timeN + stat.measures.tryTimes,\n\t\t}),\n\t\t{\n\t\t\ttotalCost: 0,\n\t\t\tpickerCost: 0,\n\t\t\tmeasureN: 0,\n\t\t\ttimeN: 0,\n\t\t}\n\t);\n\n\tconst costPerMeasure = measureN > 0 ? totalCost / measureN : null;\n\tconst costPerTime = timeN > 0 ? totalCost / timeN : null;\n\n\tconst { cached, simple, computed, tryTimes, solved, issue, fatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.measures.cached,\n\t\t\tsimple: sum.simple + stat.measures.simple,\n\t\t\tcomputed: sum.computed + stat.measures.computed,\n\t\t\ttryTimes: sum.tryTimes + stat.measures.tryTimes,\n\t\t\tsolved: sum.solved + stat.measures.solved,\n\t\t\tissue: sum.issue + stat.measures.issue,\n\t\t\tfatal: sum.fatal + stat.measures.fatal,\n\t\t}),\n\t\t{ cached: 0, simple: 0, computed: 0, tryTimes: 0, solved: 0, issue: 0, fatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\ttotalCost,\n\t\tpickerCost,\n\t\tcostPerMeasure,\n\t\tcostPerTime,\n\t\tcached,\n\t\tsimple,\n\t\tcomputed,\n\t\ttryTimes,\n\t\tsolved,\n\t\tissue,\n\t\tfatal,\n\t};\n};\n\nexport { regulateWithBeadSolver, abstractRegulationBeadStats, RegulationBeadStat, ProgressInfo };\n","import * as starry from '../../src/starry';\nimport { PyClients } from './predictors';\nimport { Logger } from './ZeroClient';\nimport { SpartitoMeasure, EditableMeasure, evaluateMeasure } from '../../src/starry';\nimport { EquationPolicy } from '../../src/starry/spartitoMeasure';\nimport { genMeasureRectifications } from '../../src/starry/measureRectification';\nimport { SolutionStore, DefaultSolutionStore, SaveIssueMeasure } from './store';\nexport * from './regulationBead';\n\nglobalThis.btoa = globalThis.btoa || ((str) => Buffer.from(str, 'binary').toString('base64'));\n\nconst RECTIFICATION_SEARCH_ITERATIONS = parseInt(process.env.RECTIFICATION_SEARCH_ITERATIONS || '30');\nconst BASE_QUOTA_FACTOR = parseInt(process.env.BASE_QUOTA_FACTOR || '40');\nconst RECTIFICATION_QUOTA_FACTOR = parseInt(process.env.RECTIFICATION_QUOTA_FACTOR || '80');\n\nconst MATRIXH_INTERPOLATION_K = 0.9;\n\ninterface SolveMeasureOptions {\n\tsolver?: (...args: any[]) => any;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n\tsolutionStore?: SolutionStore;\n\tignoreCache?: boolean;\n\tlogger?: Logger;\n}\n\nconst computeQuota = (n: number, factor: number, limit: number) =>\n\tMath.min(Math.ceil((n + 1) * factor * Math.log(n + 2)), Math.ceil(limit * Math.min(1, (24 / (n + 1)) ** 2)));\n\ninterface BaseRegulationStat {\n\tcached: number;\n\tcomputed: number;\n\tsolved: number;\n}\n\nasync function solveMeasures(\n\tmeasures: SpartitoMeasure[],\n\t{ solver, quotaMax = 1000, quotaFactor = BASE_QUOTA_FACTOR, solutionStore = DefaultSolutionStore, ignoreCache = false, logger }: SolveMeasureOptions = {}\n): Promise {\n\tlet cached = 0;\n\tlet solved = 0;\n\n\tlogger?.info(`[solveMeasures] begin, measure total: ${measures.length}.`);\n\n\tawait Promise.all(\n\t\tmeasures.map(async (measure) => {\n\t\t\tif (!ignoreCache) {\n\t\t\t\tconst solution = await solutionStore.get(measure.regulationHash);\n\t\t\t\tif (solution) {\n\t\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\t\t++cached;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst quota = computeQuota(measure.events.length, quotaFactor, quotaMax);\n\n\t\t\tawait measure.regulate({\n\t\t\t\tpolicy: 'equations',\n\t\t\t\tquota,\n\t\t\t\tsolver,\n\t\t\t});\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tif (!stat.error) solutionStore.set(measure.regulationHash0, { ...measure.asSolution(), priority: -measure?.solutionStat?.loss! });\n\t\t\tif (stat.perfect) ++solved;\n\n\t\t\tlogger?.info(\n\t\t\t\t`[solveMeasures] measure[${measure.measureIndex}/${measures.length}] regulated: ${stat.perfect ? 'solved' : stat.error ? 'error' : 'issue'}, ${\n\t\t\t\t\tmeasure.regulationHash\n\t\t\t\t}`\n\t\t\t);\n\t\t})\n\t);\n\n\tlogger?.info(`[solveMeasures] ${cached}/${measures.length} cache hit, ${solved} solved.`);\n\n\treturn {\n\t\tcached,\n\t\tcomputed: measures.length - cached,\n\t\tsolved,\n\t};\n}\n\nconst solveMeasuresWithRectifications = async (\n\tmeasure: SpartitoMeasure,\n\t{ solver, quotaMax = 4000 }: SolveMeasureOptions\n): Promise => {\n\tlet best = evaluateMeasure(measure);\n\tlet bestSolution: starry.RegulationSolution = measure.asSolution();\n\tconst quota = computeQuota(measure.events.length, RECTIFICATION_QUOTA_FACTOR, quotaMax);\n\tlet n_rec = 0;\n\n\t// @ts-ignore\n\tfor (const rec of genMeasureRectifications(measure)) {\n\t\tconst solution = await EquationPolicy.regulateMeasureWithRectification(measure, rec, { solver, quota });\n\n\t\tconst testMeasure = measure.deepCopy() as SpartitoMeasure;\n\t\ttestMeasure.applySolution(solution);\n\t\tconst result = evaluateMeasure(testMeasure);\n\n\t\tif (\n\t\t\tresult.perfect > best.perfect ||\n\t\t\tresult.error < best.error ||\n\t\t\t(!result.error && result.perfect >= best.perfect && solution.priority! > bestSolution.priority!)\n\t\t) {\n\t\t\tbest = result;\n\t\t\tbestSolution = solution;\n\t\t}\n\n\t\tif (result.perfect) break;\n\n\t\t++n_rec;\n\t\tif (n_rec > RECTIFICATION_SEARCH_ITERATIONS) break;\n\t}\n\n\treturn bestSolution;\n};\n\ninterface RegulateWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateMaybeWithTopoOption {\n\tsolutionStore: SolutionStore;\n\tpyClients?: PyClients;\n\tsolver: (...args: any[]) => any;\n\tonSaveIssueMeasure?: SaveIssueMeasure;\n}\n\ninterface RegulateSimpleOption {\n\tsolutionStore: SolutionStore;\n\tsolver: (...args: any[]) => any;\n\tlogger?: Logger;\n\tquotaMax?: number;\n\tquotaFactor?: number;\n}\n\ninterface TopoRegulationStat {\n\tsolved: number;\n\tissue: number;\n\tfatal: number;\n}\n\nasync function doRegulateWithTopo(\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateWithTopoOption\n): Promise {\n\tpyClients.logger.info(`[RegulateWithTopo] regulate score: ${score.title}, measures: ${score.spartito!.measures.length}`);\n\n\tconst issueMeasures = score.spartito!.measures.filter((measure) => {\n\t\tconst stat = evaluateMeasure(measure);\n\t\treturn !stat.perfect;\n\t});\n\tpyClients.logger.info(`[RegulateWithTopo] basic issues: ${issueMeasures.length}`);\n\n\tif (issueMeasures.length === 0) {\n\t\treturn {\n\t\t\tsolved: 0,\n\t\t\tissue: 0,\n\t\t\tfatal: 0,\n\t\t};\n\t}\n\n\tconst clusters = ([] as starry.EventCluster[]).concat(...issueMeasures.map((measure) => measure.createClusters()));\n\tconst results = await pyClients.predictScoreImages('topo', { clusters });\n\tconsole.assert(results.length === clusters.length, 'prediction number mismatch:', clusters.length, results.length);\n\n\tclusters.forEach((cluster, index) => {\n\t\tconst result = results[index];\n\t\tconsole.assert(result, 'no result for cluster:', cluster.index);\n\n\t\tcluster.assignPrediction(result);\n\t});\n\n\tissueMeasures.forEach((measure) => {\n\t\tconst cs = clusters.filter((c) => c.index === measure.measureIndex);\n\t\tmeasure.applyClusters(cs);\n\n\t\t// intepolate matrixH\n\t\tconst { matrixH } = EquationPolicy.estiamteMeasure(measure);\n\t\tmatrixH.forEach((row, i) =>\n\t\t\trow.forEach((v, j) => {\n\t\t\t\tmeasure.matrixH[i][j] = measure.matrixH[i][j] * MATRIXH_INTERPOLATION_K + v * (1 - MATRIXH_INTERPOLATION_K);\n\t\t\t})\n\t\t);\n\t});\n\n\tconst solvedIndices: number[] = [];\n\tconst errorIndices: number[] = [];\n\n\t// rectification search\n\tawait Promise.all(\n\t\tissueMeasures.map(async (measure) => {\n\t\t\tconst hash = measure.regulationHash0;\n\t\t\tconst solution = await solveMeasuresWithRectifications(measure, { solver });\n\t\t\tif (solution) {\n\t\t\t\tmeasure.applySolution(solution);\n\t\t\t\tsolutionStore.set(hash, solution);\n\t\t\t\tsolutionStore.set(measure.regulationHash, measure.asSolution());\n\t\t\t\tpyClients.logger.info(`[RegulateWithTopo] solutionStore set: ${measure.measureIndex}, ${hash}, ${measure.regulationHash}`);\n\t\t\t}\n\n\t\t\tconst stat = evaluateMeasure(measure);\n\t\t\tonSaveIssueMeasure?.({\n\t\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\t\tmeasure: new EditableMeasure(measure),\n\t\t\t\tstatus: stat.error ? 2 : 1,\n\t\t\t});\n\t\t\tif (stat.perfect) solvedIndices.push(measure.measureIndex);\n\t\t\telse if (stat.error) errorIndices.push(measure.measureIndex);\n\t\t})\n\t);\n\n\tconst n_issues = issueMeasures.length - solvedIndices.length - errorIndices.length;\n\tpyClients.logger.info(`[RegulateWithTopo] score: ${score.title}, solved/issue/fatal: ${solvedIndices.length}/${n_issues}/${errorIndices.length}`);\n\tif (solvedIndices.length) pyClients.logger.info(`[RegulateWithTopo] solved measures: ${solvedIndices.join(', ')}`);\n\tif (errorIndices.length) pyClients.logger.info(`[RegulateWithTopo] error measures: ${errorIndices.join(', ')}`);\n\n\treturn {\n\t\tsolved: solvedIndices.length,\n\t\tissue: n_issues,\n\t\tfatal: errorIndices.length,\n\t};\n}\n\ninterface RegulationStat {\n\tbaseCost: number; // in milliseconds\n\ttopoCost: number; // in milliseconds\n\tbaseMeasures: BaseRegulationStat;\n\ttopoMeasures?: TopoRegulationStat;\n\tqualityScore: number;\n}\n\nconst doRegulate = async (\n\tscore: starry.Score,\n\t{ pyClients, solver, solutionStore = DefaultSolutionStore, onSaveIssueMeasure }: RegulateMaybeWithTopoOption\n): Promise => {\n\tpyClients?.logger?.info(`[doRegulate] score: ${score.title}`);\n\n\tscore.spartito = undefined;\n\tscore.assemble();\n\tconst spartito = score.makeSpartito();\n\n\tspartito.measures.forEach((measure) => score.assignBackgroundForMeasure(measure));\n\n\tconst t0 = Date.now();\n\n\tconst baseMeasures = await solveMeasures(spartito.measures, { solver, quotaMax: 1000, solutionStore, logger: pyClients?.logger });\n\n\tconst t1 = Date.now();\n\n\tconst topoMeasures = pyClients ? await doRegulateWithTopo(score, { pyClients, solver, solutionStore, onSaveIssueMeasure }) : undefined;\n\n\tconst t2 = Date.now();\n\n\treturn {\n\t\tbaseCost: t1 - t0,\n\t\ttopoCost: t2 - t1,\n\t\tbaseMeasures,\n\t\ttopoMeasures,\n\t\tqualityScore: spartito.qualityScore,\n\t};\n};\n\nconst doSimpleRegulate = async (\n\tscore: starry.Score,\n\t{ solver, solutionStore = DefaultSolutionStore, logger, quotaMax = 240, quotaFactor = 16 }: RegulateSimpleOption\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\tconst measures = spartito.measures.filter((measure) => !measure.regulated);\n\n\tawait solveMeasures(measures, { solver, quotaMax, quotaFactor, solutionStore, logger });\n\n\tconsole.assert(score.spartito?.regulated, 'doSimpleRegulate: regulation incomplete:', spartito.measures.filter((measure) => !measure.regulated).length);\n};\n\nconst evaluateScoreQuality = async (score: starry.Score, options: RegulateSimpleOption): Promise => {\n\tif (!score.spartito?.regulated) await doSimpleRegulate(score, options);\n\n\treturn score.spartito!.regulated ? score.spartito!.qualityScore : null;\n};\n\ninterface RegulationSummary {\n\tscoreN: number;\n\n\tbaseCostTotal: number; // in milliseconds\n\ttopoCostTotal: number; // in milliseconds\n\tbaseCostPerMeasure: number | null; // in milliseconds\n\ttopoCostPerMeasure: number | null; // in milliseconds\n\n\tcached: number;\n\tbaseComputed: number;\n\tbaseSolved: number;\n\ttopoSolved: number;\n\ttopoIssue: number;\n\ttopoFatal: number;\n}\n\nconst abstractRegulationStats = (stats: RegulationStat[]): RegulationSummary => {\n\tconst { baseCostTotal, topoCostTotal, baseMeasures, topoMeasures } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tbaseCostTotal: sum.baseCostTotal + stat.baseCost,\n\t\t\ttopoCostTotal: sum.topoCostTotal + stat.topoCost,\n\t\t\tbaseMeasures: sum.baseMeasures + stat.baseMeasures.computed,\n\t\t\ttopoMeasures: sum.topoMeasures + (stat.topoMeasures!.solved + stat.topoMeasures!.issue + stat.topoMeasures!.fatal),\n\t\t}),\n\t\t{\n\t\t\tbaseCostTotal: 0,\n\t\t\ttopoCostTotal: 0,\n\t\t\tbaseMeasures: 0,\n\t\t\ttopoMeasures: 0,\n\t\t}\n\t);\n\n\tconst baseCostPerMeasure = baseMeasures > 0 ? baseCostTotal / baseMeasures : null;\n\tconst topoCostPerMeasure = topoMeasures > 0 ? topoCostTotal / topoMeasures : null;\n\n\tconst { cached, baseComputed, baseSolved, topoSolved, topoIssue, topoFatal } = stats.reduce(\n\t\t(sum, stat) => ({\n\t\t\tcached: sum.cached + stat.baseMeasures.cached,\n\t\t\tbaseComputed: sum.baseComputed + stat.baseMeasures.computed,\n\t\t\tbaseSolved: sum.baseSolved + stat.baseMeasures.solved,\n\t\t\ttopoSolved: sum.topoSolved + stat.topoMeasures!.solved,\n\t\t\ttopoIssue: sum.topoIssue + stat.topoMeasures!.issue,\n\t\t\ttopoFatal: sum.topoFatal + stat.topoMeasures!.fatal,\n\t\t}),\n\t\t{ cached: 0, baseComputed: 0, baseSolved: 0, topoSolved: 0, topoIssue: 0, topoFatal: 0 }\n\t);\n\n\treturn {\n\t\tscoreN: stats.length,\n\t\tbaseCostTotal,\n\t\ttopoCostTotal,\n\t\tbaseCostPerMeasure,\n\t\ttopoCostPerMeasure,\n\t\tcached,\n\t\tbaseComputed,\n\t\tbaseSolved,\n\t\ttopoSolved,\n\t\ttopoIssue,\n\t\ttopoFatal,\n\t};\n};\n\nexport { doRegulate, doSimpleRegulate, evaluateScoreQuality, abstractRegulationStats };\n","import SparkMD5 from 'spark-md5';\n//import JSZip from 'jszip';\nimport * as starry from '../../src/starry';\n//import { encodeFindResource } from '../../src/isomorphic/converter';\nimport sharp, { FormatEnum } from 'sharp';\nimport got from 'got';\n//import { Logger } from './ZeroClient';\nimport type { SolutionStore, SaveIssueMeasure } from './store';\nimport { ScoreJSON } from '../../src/isomorphic/types';\n\nconst SYSTEM_MARGIN = 4;\n\nexport const constructSystem = ({ page, backgroundImage, detection, imageSize, position }) => {\n\tconst systemWidth = (detection.phi2 - detection.phi1) / detection.interval;\n\tconst systemHeight = imageSize.height / detection.interval;\n\n\tconst lastSystem = page.systems[page.systems.length - 1];\n\tconst top = position ? position.y : (lastSystem ? lastSystem.top + lastSystem.height : 0) + SYSTEM_MARGIN;\n\tconst left = position ? position.x : SYSTEM_MARGIN;\n\n\tconst stavesTops = [\n\t\t0,\n\t\t...Array(detection.middleRhos.length - 1)\n\t\t\t.fill(0)\n\t\t\t.map((_, i) => (detection.middleRhos[i] + detection.middleRhos[i + 1]) / 2 / detection.interval),\n\t];\n\n\tconst measureBars = [systemWidth];\n\n\tconst staves = stavesTops.map(\n\t\t(top, i) =>\n\t\t\tnew starry.Staff({\n\t\t\t\ttop,\n\t\t\t\theight: (stavesTops[i + 1] || systemHeight) - top,\n\t\t\t\tstaffY: detection.middleRhos[i] / detection.interval - top,\n\t\t\t\tmeasureBars,\n\t\t\t})\n\t);\n\n\t//console.log(\"detection:\", detection, options, stavesTops);\n\n\tconst imagePosition = {\n\t\tx: -detection.phi1 / detection.interval,\n\t\ty: 0,\n\t\twidth: imageSize.width / detection.interval,\n\t\theight: imageSize.height / detection.interval,\n\t};\n\n\treturn new starry.System({\n\t\tstaves,\n\t\tleft,\n\t\ttop,\n\t\twidth: systemWidth,\n\t\tbackgroundImage,\n\t\timagePosition,\n\t\tmeasureBars,\n\t});\n};\n\nexport interface ConvertOption {\n\tformat?: keyof FormatEnum;\n\tquality?: number;\n\tmaxHeight?: number;\n}\n\nconst toBuffer = async (url: string | Buffer): Promise => {\n\tif (typeof url === 'string') {\n\t\tif (/^https?:\\/\\//.test(url)) {\n\t\t\treturn (await got(url, { responseType: 'buffer', decompress: true, https: { rejectUnauthorized: false } })).body;\n\t\t}\n\n\t\tif (/^data:image\\//.test(url)) {\n\t\t\treturn Buffer.from(url.split(',')[1], 'base64');\n\t\t}\n\n\t\treturn Buffer.from(url);\n\t}\n\n\treturn url;\n};\n\n/**\n * 转换图片格式,默认webp、最大高度1080,高度小于1080自动不做尺寸变换\n * @param url\n * @param format\n * @param maxHeight\n * @param quality\n */\nexport async function convertImage(url: string | Buffer, { format = 'webp', maxHeight = 1080, quality = 80 }: ConvertOption = {}) {\n\tlet buf = await toBuffer(url);\n\n\tconst webpBuffer = await new Promise((resolve) => {\n\t\tsharp(buf)\n\t\t\t.resize({\n\t\t\t\twidth: maxHeight,\n\t\t\t\theight: maxHeight,\n\t\t\t\tfit: 'inside',\n\t\t\t\twithoutEnlargement: true,\n\t\t\t})\n\t\t\t.toFormat(format, { quality })\n\t\t\t.toBuffer((err, buf) => {\n\t\t\t\tresolve(buf);\n\t\t\t});\n\t});\n\n\tconst md5 = SparkMD5.ArrayBuffer.hash(webpBuffer);\n\n\treturn {\n\t\tbuffer: webpBuffer,\n\t\tfilename: `${md5}.${format}`,\n\t};\n}\n\n/**\n * 替换scoreJson图片地址\n * @param scoreJson\n * @param onReplaceImage\n */\nexport const replaceScoreJsonImages = (scoreJson: ScoreJSON, onReplaceImage: (src: string) => string = (src) => src) => {\n\tconst json = JSON.parse(JSON.stringify(scoreJson));\n\n\tjson.pages.forEach((page) => {\n\t\tpage?.src && (page.src = onReplaceImage(page?.src));\n\t});\n\n\tjson.lines.forEach((system) => {\n\t\tsystem.lineStaves.forEach((line) => {\n\t\t\tline.imgs.forEach((staff) => {\n\t\t\t\tstaff?.src && (staff.src = onReplaceImage(staff.src));\n\t\t\t});\n\t\t});\n\t});\n\n\treturn json;\n};\n\n/**\n * 获取scoreJson图片资源列表\n * @param scoreJson\n */\nexport const getScoreJsonImages = (scoreJson: ScoreJSON) => {\n\treturn [\n\t\t...scoreJson.pages.map((page) => page?.src),\n\t\t...scoreJson.lines\n\t\t\t.map((system) => system.lineStaves.map((staff) => staff.imgs))\n\t\t\t.flat(2)\n\t\t\t.map((staff) => staff?.src)\n\t\t\t.filter(Boolean),\n\t];\n};\n\ninterface ScorePatchesUpdateOptions {\n\tsolutionStore?: SolutionStore;\n}\n\nexport const updateScorePatches = (score: starry.Score, measures: starry.SpartitoMeasure[], options: ScorePatchesUpdateOptions = {}): void => {\n\tconsole.assert(\n\t\tmeasures.every((measure) => measure.validRegulated),\n\t\t'[updateScorePatches] some measures not valid regulated:',\n\t\tmeasures.filter((measure) => !measure.validRegulated)\n\t);\n\n\tscore.patches = measures.map((measure) => measure.createPatch());\n\n\tif (options?.solutionStore) {\n\t\tscore.assemble();\n\t\tconst spartito = score.makeSpartito();\n\n\t\tmeasures.forEach((measure) => {\n\t\t\toptions.solutionStore!.set(measure.regulationHash, { ...measure.asSolution(), priority: 1 });\n\t\t\tif (measure.regulationHash0 !== measure.regulationHash) {\n\t\t\t\tconst originMeasure = spartito.measures.find((m) => m.measureIndex === measure.measureIndex);\n\t\t\t\toptions.solutionStore!.set(measure.regulationHash0, { ...measure.asSolution(originMeasure), priority: 1 });\n\t\t\t}\n\t\t});\n\t}\n};\n\ninterface EditableMeasuresSaveOptions {\n\tstatus?: number;\n\tsolutionStore?: SolutionStore;\n}\n\nexport const saveEditableMeasures = async (\n\tscore: starry.Score,\n\tmeasureIndices: number[],\n\tsaveMeasure: SaveIssueMeasure,\n\t{ status = 2, solutionStore }: EditableMeasuresSaveOptions = {}\n): Promise => {\n\tscore.assemble();\n\tconst spartito = score.spartito || score.makeSpartito();\n\n\tconst measures = measureIndices\n\t\t.map((index) => spartito.measures.find((measure) => measure.measureIndex === index))\n\t\t.filter(Boolean) as starry.SpartitoMeasure[];\n\n\tif (solutionStore) {\n\t\tconst solutions = await solutionStore.batchGet(measures.map((measure) => measure.regulationHash0));\n\t\tmeasures.forEach((measure, i) => {\n\t\t\tconst solution = solutions[i];\n\t\t\tif (solution) measure.applySolution(solution);\n\t\t});\n\t}\n\n\tmeasures.forEach((measure) => {\n\t\tsaveMeasure({\n\t\t\tmeasureIndex: measure.measureIndex,\n\t\t\tmeasure: new starry.EditableMeasure(measure),\n\t\t\tstatus,\n\t\t});\n\t});\n};\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T15:17:01.645Z`, '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;');\nimport '../../libs/browserComponents';\n\nexport * from '../../libs/predictors';\nexport * from '../../libs/regulation';\nexport * from '../../libs/util';\nexport * as starry from '../../../src/starry';\n"],"names":["eventsModule","events","EventEmitter","Request","pack","unpack","getPortPromise","defaultsDeep","PythonShell","inherits_browserModule","inheritsModule","require$$0","require$$1","util","getPort","sha1","pick","parser","parse","parseCode","grammar","GROUP_N_TO_PITCH","MIDDLE_C","mod7","argmax","Token.TokenClefs","Token.TokenOctshifts","Token.TokenTimesigsC","Token.TokenTimesigsN","MIDI","MidiSequence","Notation","MusicNotation","MidiPlayer","Config","Node","Navigator","Matcher","MidiUtils","require$$2","require$$3","require$$4","undefined","require","EquationSolver.Solver","erf","staffLayout.parseCode","measureLayout.parseCode","WeakLRUCache","starry.beadSolver.solveMeasure","starry.evaluateMeasure","starry.beadSolver.estimateMeasure","starry.EditableMeasure","starry.Staff","starry.System","got","sharp","SparkMD5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,UAAU,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzE,UAAU,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;;;;;;ACsBxE,IAAI,CAAC,GAAG,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,KAAI;AACpD,IAAI,YAAY,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,UAAU;AACrD,IAAI,CAAC,CAAC,KAAK;AACX,IAAI,SAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;AAClD,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACjE,IAAG;AACH;AACA,IAAI,eAAc;AAClB,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,EAAE;AAC1C,EAAE,cAAc,GAAG,CA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OAAO,KAAI;AAC5B,QAAA,WAAW,CAAC;YACX,YAAY,EAAE,OAAO,CAAC,YAAY;AAClC,YAAA,OAAO,EAAE,IAAIL,eAAsB,CAAC,OAAO,CAAC;YAC5C,MAAM;AACN,SAAA,CAAC,CAAC;AACJ,KAAC,CAAC,CAAC;AACJ;;ACnNA,OAAO,CAAC,IAAI,CAAC,CAAA,+CAAA,CAAiD,EAAE,6EAA6E,EAAE,iFAAiF,CAAC;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/backend/omr/dist/worker.js b/backend/omr/dist/worker.js index 80266381ee3cbc1d984c0154af4795c063b80835..5333b3a25c1775091ce0b33f5d7402cbf7d3b7a8 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(e){return function(t){return new Sha1(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod("hex");NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Sha1},e.update=function(t){return e.create().update(t)};for(var t=0;t>2]|=e[s]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(o[n>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=64?(this.block=o[16],this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var e,t,r=this.h0,n=this.h1,s=this.h2,i=this.h3,o=this.h4,a=this.blocks;for(e=16;e<80;++e)t=a[e-3]^a[e-8]^a[e-14]^a[e-16],a[e]=t<<1|t>>>31;for(e=0;e<20;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n&s|~n&i)+o+1518500249+a[e]|0)<<5|o>>>27)+(r&(n=n<<30|n>>>2)|~r&s)+i+1518500249+a[e+1]|0)<<5|i>>>27)+(o&(r=r<<30|r>>>2)|~o&n)+s+1518500249+a[e+2]|0)<<5|s>>>27)+(i&(o=o<<30|o>>>2)|~i&r)+n+1518500249+a[e+3]|0)<<5|n>>>27)+(s&(i=i<<30|i>>>2)|~s&o)+r+1518500249+a[e+4]|0,s=s<<30|s>>>2;for(;e<40;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n^s^i)+o+1859775393+a[e]|0)<<5|o>>>27)+(r^(n=n<<30|n>>>2)^s)+i+1859775393+a[e+1]|0)<<5|i>>>27)+(o^(r=r<<30|r>>>2)^n)+s+1859775393+a[e+2]|0)<<5|s>>>27)+(i^(o=o<<30|o>>>2)^r)+n+1859775393+a[e+3]|0)<<5|n>>>27)+(s^(i=i<<30|i>>>2)^o)+r+1859775393+a[e+4]|0,s=s<<30|s>>>2;for(;e<60;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n&s|n&i|s&i)+o-1894007588+a[e]|0)<<5|o>>>27)+(r&(n=n<<30|n>>>2)|r&s|n&s)+i-1894007588+a[e+1]|0)<<5|i>>>27)+(o&(r=r<<30|r>>>2)|o&n|r&n)+s-1894007588+a[e+2]|0)<<5|s>>>27)+(i&(o=o<<30|o>>>2)|i&r|o&r)+n-1894007588+a[e+3]|0)<<5|n>>>27)+(s&(i=i<<30|i>>>2)|s&o|i&o)+r-1894007588+a[e+4]|0,s=s<<30|s>>>2;for(;e<80;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n^s^i)+o-899497514+a[e]|0)<<5|o>>>27)+(r^(n=n<<30|n>>>2)^s)+i-899497514+a[e+1]|0)<<5|i>>>27)+(o^(r=r<<30|r>>>2)^n)+s-899497514+a[e+2]|0)<<5|s>>>27)+(i^(o=o<<30|o>>>2)^r)+n-899497514+a[e+3]|0)<<5|n>>>27)+(s^(i=i<<30|i>>>2)^o)+r-899497514+a[e+4]|0,s=s<<30|s>>>2;this.h0=this.h0+r|0,this.h1=this.h1+n|0,this.h2=this.h2+s|0,this.h3=this.h3+i|0,this.h4=this.h4+o|0},Sha1.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,s=this.h4;return 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[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[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+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]+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]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,s=this.h4;return[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(20),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),e};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()})(sha1),function(e){e.ClefG="ClefG",e.ClefF="ClefF",e.ClefC="ClefC",e.NoteheadS0="NoteheadS0",e.NoteheadS1="NoteheadS1",e.NoteheadS2="NoteheadS2",e.NoteheadS1stemU="NoteheadS1stemU",e.NoteheadS1stemD="NoteheadS1stemD",e.NoteheadS2stemU="NoteheadS2stemU",e.NoteheadS2stemD="NoteheadS2stemD",e.vline_Stem="vline_Stem",e.Flag3="Flag3",e.BeamLeft="BeamLeft",e.BeamContinue="BeamContinue",e.BeamRight="BeamRight",e.TremoloLeft="TremoloLeft",e.TremoloRight="TremoloRight",e.TremoloMiddle="TremoloMiddle",e.Dot="Dot",e.Rest0="Rest0",e.Rest1="Rest1",e.Rest2="Rest2",e.Rest3="Rest3",e.Rest4="Rest4",e.Rest5="Rest5",e.Rest6="Rest6",e.Rest0W="Rest0W",e.RestM1="RestM1",e.AccNatural="AccNatural",e.AccSharp="AccSharp",e.AccDoublesharp="AccDoublesharp",e.AccFlat="AccFlat",e.AccFlatflat="AccFlatflat",e.vline_VoltaLeft="vline_VoltaLeft",e.vline_VoltaRight="vline_VoltaRight",e.VoltaLeft="VoltaLeft",e.VoltaRight="VoltaRight",e.VoltaAlternativeBegin="VoltaAlternativeBegin",e.BarMeasure="BarMeasure",e.vline_BarMeasure="vline_BarMeasure",e.vline_BarTerminal="vline_BarTerminal",e.vline_BarSegment="vline_BarSegment",e.SlurBegin="SlurBegin",e.SlurEnd="SlurEnd",e.TimesigC44="TimesigC44",e.TimesigC22="TimesigC22",e.TimesigZero="TimesigZero",e.TimesigOne="TimesigOne",e.TimesigTwo="TimesigTwo",e.TimesigThree="TimesigThree",e.TimesigFour="TimesigFour",e.TimesigFive="TimesigFive",e.TimesigSix="TimesigSix",e.TimesigSeven="TimesigSeven",e.TimesigEight="TimesigEight",e.TimesigNine="TimesigNine",e.OctaveShift8va="OctaveShift8va",e.OctaveShift8vb="OctaveShift8vb",e.OctaveShift8="OctaveShift8",e.OctaveShift0="OctaveShift0",e.Zero="Zero",e.One="One",e.Two="Two",e.Three="Three",e.Four="Four",e.Five="Five",e.Six="Six",e.Seven="Seven",e.Eight="Eight",e.Nine="Nine",e.f="f",e.p="p",e.m="m",e.n="n",e.r="r",e.s="s",e.z="z",e.CrescendoBegin="CrescendoBegin",e.CrescendoEnd="CrescendoEnd",e.DecrescendoBegin="DecrescendoBegin",e.DecrescendoEnd="DecrescendoEnd",e.ScriptFermata="ScriptFermata",e.ScriptShortFermata="ScriptShortFermata",e.ScriptSforzato="ScriptSforzato",e.ScriptStaccato="ScriptStaccato",e.ScriptStaccatissimo="ScriptStaccatissimo",e.ScriptTurn="ScriptTurn",e.ScriptTrill="ScriptTrill",e.ScriptSegno="ScriptSegno",e.ScriptCoda="ScriptCoda",e.ScriptArpeggio="ScriptArpeggio",e.ScriptPrall="ScriptPrall",e.ScriptMordent="ScriptMordent",e.ScriptMarcato="ScriptMarcato",e.ScriptTenuto="ScriptTenuto",e.ScriptPortato="ScriptPortato",e.PedalStar="PedalStar",e.PedalPed="PedalPed",e.KeyAcc="KeyAcc",e.TempoNotehead="TempoNotehead",e.GraceNotehead="GraceNotehead",e.SignLined="SignLined",e.SignInterval="SignInterval",e.rect_Text="rect_Text",e.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=(e,t,r=-1/0)=>Math.max(Math.round(e/t)*t,r),gcd=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:gcd(t,e%t):(console.error("non-integer gcd:",e,t),1),frac=(e,t)=>({numerator:e,denominator:t}),reducedFraction=(e,t)=>{e=Math.round(e),t=Math.round(t);const r=0!==e?gcd(e,t):t;return frac(e/r,t/r)},fractionMul=(e,t)=>t?e*t.numerator/t.denominator:e;class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const EOM=-1,GREAT_NUMBER=1920,DURATION_MULTIPLIER=1921920,floatToFrac=e=>{const t=Math.round(e*GREAT_NUMBER);return reducedFraction(t,GREAT_NUMBER)},floatToTimeWarp=e=>1===e?null:floatToFrac(e);var ActionType;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(ActionType||(ActionType={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:ActionType.PLACE,e1:e})}static V(e,t,r=1){return new Action({type:ActionType.VERTICAL,e1:r>0?e:t,e2:r>0?t:e})}static H(e,t){return new Action({type:ActionType.HORIZONTAL,e1:e,e2:t})}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(e,t){const r=Array(e.stages.length).fill(null).map(()=>Array(e.stages.length).fill(null).map(()=>new Set));e.actions.filter(e=>e.type===ActionType.HORIZONTAL).forEach(t=>{const n=e.stages.findIndex(e=>e.events.includes(t.e1)),s=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(n>=0&&s>=0,"invalid stages for H action:",e.id,e.stages,t),r[n][s].add(t.e1)}),r[0][e.stages.length-1].add(0);const n=e.stagedEvents,s=t.matrixH[t.matrixH.length-1].filter((e,t)=>!n.has(t)),i=Math.max(0,Math.max(...s)-.01),o=e.actions.filter(e=>e.type===ActionType.HORIZONTAL),a=Object.keys(t.eventMap).map(Number).filter(e=>!o.find(t=>t.e2===e));return e.stages.forEach(n=>{n.events.forEach(s=>{if(s>0){!o.find(e=>e.e1===s)&&t.matrixH[t.matrixH.length-1][s]>=i&&(a.some(e=>t.matrixH[e][s]>0)||r[n.index][e.stages.length-1].add(s))}})}),new StageMatrix({matrix:r})}constructor(e){Object.assign(this,e)}pathOf(e,t,r,n=0){if(this.matrix[e][t].size){const s=[...this.matrix[e][t]][n];if(t===r)return[s];for(let e=t+1;e<=r;++e){const n=this.pathOf(t,e,r);if(n)return[s,...n]}}return null}findDoublePath(e,t){const r=[];for(let n=t;n>=e+1;--n)for(let s=0;st.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let r=1;ri[e]=1),s.forEach(e=>i[e]=-1),t.push(i),this.reducePath(n.length>s.length?n:s)}}}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:[EOM]}];for(const t of this.actions)switch(t.type){case ActionType.PLACE:this.stages.unshift({events:[t.e1]});break;case ActionType.VERTICAL:{const e=this.stages.find(e=>e.events.includes(t.e1)),r=this.stages.find(e=>e.events.includes(t.e2));console.assert(e||r,"invalid V action:",this.stages,t),e&&r?(e.events.push(...r.events),r.events=null,this.stages=this.stages.filter(e=>e.events)):e?r||e.events.push(t.e2):r.events.unshift(t.e1)}break;case ActionType.HORIZONTAL:{const r=this.stages.find(e=>e.events.includes(t.e1)),n=this.stages.find(e=>e.events.includes(t.e2));console.assert(r||n,"invalid H action:",this.stages,t);const s=r=>{console.assert(e.eventMap[r],"invalid event id:",t.id,r,e.eventMap);const n=e.eventMap[r].x,s=this.stages.find(t=>t.events.some(t=>t>0&&e.eventMap[t].x<=n)&&t.events.some(t=>t>0&&e.eventMap[t].x>=n));if(s)s.events.push(r);else{const t={events:[r]},s=this.stages.findIndex(t=>t.events[0]===EOM||e.eventMap[t.events[0]].x>=n);this.stages.splice(s,0,t)}};r||s(t.e1),n||s(t.e2)}}this.stages.forEach((e,t)=>e.index=t)}constructConstraints(e){const t=Object.keys(e.eventMap).length,r=StageMatrix.fromNode(this,e).toEquations(t),n=Array(t).fill(null).map((t,r)=>e.eventMap[r].duration);this.constraints=r.map(e=>e.map((e,t)=>e*n[t]))}inbalancesConstraints(e){console.assert(this.constraints,"constraints not constructed.");const t=Object.keys(e.eventMap).length,r=Array(t).fill(!0),n=Array(t).fill(!1),s=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const i=t<0?e.map(e=>-e):e;if(i[0]>0)continue;s.push(i),i.forEach((e,t)=>{n[t]=n[t]||e<0,e&&(r[t]=e<0||n[t])})}}return this.constraints.forEach(e=>{0!==e.reduce((e,t)=>e+t,0)||e[0]||e.some((e,t)=>e&&!r[t])&&(e.forEach((e,t)=>e&&(r[t]=!1)),s.push(e))}),{ones:r,inbalances:s}}solveEquations({ones:e,inbalances:t}){if(!t.length)return e.map(()=>1);const r=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(!r.length)return e.map(()=>1);const n=r.map(e=>Math.abs(t.find(t=>0!==t[e])[e])),s=new Map;let i=!1;const o=t.map(e=>({line:e.filter((e,t)=>r.includes(t)),bias:-e.reduce((e,t,n)=>e+(r.includes(n)?0:t),0)})).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const r=e.join(",");return s.has(r)?(i=s.get(r)!==t,!1):(s.set(r,t),!0)});if(i)return null;const a=o.slice(0,r.length),c=o.slice(r.length);if(a.lengthr===t?1:r===s?-1:0),bias:0,prior:(n[t]+n[s])/DURATION_MULTIPLIER};a.some(e=>e.line[t]&&e.line[s])&&(i.prior-=10),a.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[s]))&&(i.prior+=1),e.push(i)}e.sort((e,t)=>e.prior-t.prior),a.push(...e.slice(0,r.length-a.length))}const l=a.map(({line:e})=>e),u=a.map(({bias:e})=>e),h=matrixInverse(l);if(!h)return this.logger.warn("null invert:",l),null;const d=h.map(e=>e.reduce((e,t,r)=>e+t*u[r],0));if(c.length&&c.some(e=>Math.abs(e.line.reduce((e,t,r)=>e+t*d[r],0))>.001))return null;const f=e.map(()=>1);return r.forEach((e,t)=>f[e]=d[t]),f}optimallySolve(e){const{ones:t,inbalances:r}=this.inbalancesConstraints(e),n=t.map((t,r)=>t?-1:roundNumber(e.eventMap[r].shrinkness,.01)).reduce((e,t,r)=>(t>=0&&(e[t]=e[t]||[],e[t].push(r)),e),{}),s=Object.entries(n).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let n=1;n!i.includes(t)),a=this.solveEquations({ones:o,inbalances:r});if(a&&a.every((t,r)=>t<=1&&t>e.eventMap[r].lowWarp))return a}return this.solveEquations({ones:t,inbalances:r})}isConflicted(e){const{ones:t,inbalances:r}=this.inbalancesConstraints(e);for(const n of r){if(n.reduce((r,n,s)=>r+n*(t[s]||n<=0?1:e.eventMap[s].lowWarp),0)>=0)return n.forEach((t,r)=>{t&&(e.eventTendencies[r]+=t>0?1:-1)}),!0}if(!r.length)return!1;const n=this.solveEquations({ones:t,inbalances:r});return!n||!n.every((t,r)=>t>e.eventMap[r].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,r=this.actions.filter(e=>e.type===ActionType.HORIZONTAL).sort((e,r)=>t(e)-t(r)),n=r.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),s=new Set([...Object.keys(n)].map(Number));r.forEach(e=>s.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&s.add(e));let i=[...s].map(e=>{const t=[e];let r=e;for(;n[r]&&(r=n[r],!(r<0||t.includes(r)));)t.push(r);return t});const o=Object.values(e.eventMap).filter(e=>e.id>0).map(e=>({id:e.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),a=o.filter(e=>i.some(t=>t.includes(e.id))||r.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=>a[e]&&(a[e].tickGroup=t))),this.stages[0].tick=0,this.stages[0].events.forEach(e=>a[e]&&(a[e].tick=0));const c=this.optimallySolve(e);o.forEach(e=>e.timeWarp=floatToTimeWarp(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 r.forEach(r=>{const n=this.stages.find(e=>e.events.includes(r.e1)),s=this.stages.find(e=>e.events.includes(r.e2));Number.isFinite(n.tick)&&!Number.isFinite(s.tick)&&(s.tick=n.tick+fractionMul(e.eventMap[r.e1].duration,a[r.e1].timeWarp),s.events.forEach(e=>a[e]&&(a[e].tick=s.tick)),t=!0)}),[...r].reverse().forEach(r=>{const n=this.stages.find(e=>e.events.includes(r.e1)),s=this.stages.find(e=>e.events.includes(r.e2));!Number.isFinite(n.tick)&&Number.isFinite(s.tick)&&(n.tick=s.tick-fractionMul(e.eventMap[r.e1].duration,a[r.e1].timeWarp),n.events.forEach(e=>a[e]&&(a[e].tick=n.tick)),t=!0)}),t};for(;u(););console.assert(l.every(e=>Number.isFinite(e.tick)),"stage ticks not all solved:",this.stages,this.id),o.filter(e=>Number.isFinite(e.tick)).forEach(t=>t.endTick=t.tick+fractionMul(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;i.forEach(e=>{const t=e.findIndex(e=>a[e].endTick>h);if(t>=0){e.splice(t,e.length-t).forEach(e=>{a[e].tick=null,a[e].endTick=null})}}),i=i.filter(e=>e.length);const d=Math.max(0,...o.map(e=>e.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:i,events:o,duration:d,actions:this.actions.map(e=>e.id).join(" ")}}deduce(e,t){this.stages||this.constructStages(e);const r=e.actionAccessing.get(this.id)||{times:0};if(++r.times,e.actionAccessing.set(this.id,r),this.constructConstraints(e),this.isConflicted(e))return r.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 r=t=>t.possibility/((e.actionAccessing.get(t.id)||{times:0}).times+1);this.children.sort((e,t)=>r(t)-r(e));for(const r of this.children){const n=r.deduce(e,t);if(n)return this.logger.groupEnd(),n;if(t.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),r.closed=!0,this.getSolution(e)}expand(e){this.constructStages(e);const{eventMap:t,matrixV:r,matrixH:n}=e,s=this.stagedEvents,i=[],o=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!i.some(t=>t.action.id===e.action.id)){const t=this.stages.find(t=>t.events.includes(e.action.e1)),n=this.stages.find(t=>t.events.includes(e.action.e2));if(t===n||t&&n&&t.index>=n.index)return;if(t&&n)if(e.action.type===ActionType.VERTICAL){if(n.index-t.index>1)return;if(this.actions.some(e=>t.events.includes(e.e1)&&n.events.includes(e.e2)))return}else if(e.action.type===ActionType.HORIZONTAL&&t.index>n.index)return;if(e.action.type===ActionType.HORIZONTAL&&this.actions.some(t=>t.type===ActionType.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===ActionType.VERTICAL){if(t&&(e.possibility=Math.min(e.possibility,...t.events.map(t=>r[e.action.e2][t])),e.possibility<=0))return;if(n&&(e.possibility=Math.min(e.possibility,...n.events.map(t=>r[t][e.action.e1])),e.possibility<=0))return}i.push(e)}};for(const e of s)e<0||(r[e].forEach((t,r)=>{t>0&&e!==r&&o({action:Action.V(r,e),possibility:t})}),r.forEach((t,r)=>{const n=t[e];n>0&&o({action:Action.V(e,r),possibility:n})}),n[e].forEach((t,r)=>{t>0&&o({action:Action.H(r,e),possibility:t})}),n.forEach((r,n)=>{n=n>=Object.keys(t).length?-1:n;const s=r[e];s>0&&o({action:Action.H(e,n),possibility:s})}));i.some(e=>[ActionType.HORIZONTAL,ActionType.PLACE].includes(e.action.type)||!s.has(e.action.e1)||!s.has(e.action.e2))?this.children=i.map(e=>new PathNode({logger:this.logger,parent:this,...e})):this.children=[]}}class Solver{constructor(e,{quota:t=1e3,logger:r=new DummyLogger}={}){this.quota=t,this.logger=r;const n={id:0,x:0,confidence:1,shrinkness:e.measureShrinkness,duration:e.expectedDuration,lowWarp:0};this.events=[n,...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),r={credits:this.quota,times:0};for(;r.credits>0;){++r.times;const n={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:t},s=this.pathRoot.deduce(n,r);if(s.credits=this.quota-r.credits,s.times=r.times,this.evaluateSolution(s),this.logger.debug("loss:",s.loss),e=!e||s.losse/r.times)),e}evaluateSolution(e){e.loss=0;const t=e.events.reduce((e,t)=>({...e,[t.id]:{...t,...this.eventMap[t.id]}}),{}),r=e.events.filter(e=>Number.isFinite(e.tick)).map(e=>t[e.id]),n=r.reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{});Object.values(n).forEach(t=>{t.sort((e,t)=>e.x-t.x).slice(0,t.length-1).forEach((r,n)=>{t[n+1].tick{if(Number.isFinite(r.tick)&&!e.voices.every(e=>!e.includes(r.id))||(e.loss+=100*t[r.id].confidence),r.timeWarp){const{numerator:e,denominator:n}=r.timeWarp,i=t[r.id].shrinkness;s.set(e,Math.max(s.get(e)||0,1-i)),s.set(n,Math.max(s.get(n)||0,1-i))}});const i=reducedFraction(e.duration,this.eventMap[0].duration);s.set(i.numerator,Math.max(s.get(i.numerator)||0,1-this.eventMap[0].shrinkness)),s.set(i.denominator,Math.max(s.get(i.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,r]of s.entries())t>1&&(e.loss+=Math.log(t)*r);let o=0,a=0;e.voices.forEach(r=>{console.assert(t[r[0]],"invalid voice:",r,Object.keys(t));const n=Math.abs(t[r[0]].tick),s=t[r[r.length-1]].endTick;o+=Math.max(0,n+e.duration-s);let i=null;r.forEach(e=>{const r=t[e];r.staff!==i&&(null!==i&&++a,i=r.staff)})}),e.loss+=10*o/DURATION_MULTIPLIER,e.loss+=5**a-1;const c=[...r].sort((e,t)=>e.x-t.x),l=c.slice(1).map((t,r)=>{const n=c[r],s=t.x-n.x,i=t.tick-n.tick;if(!i)return s/this.xSpan;return(4*Math.atan2(i/e.duration,s/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,s,o,a),e.loss<0&&(e.loss=1/0)}}const solveStaffGroup=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};worker({solveStaffGroup:solveStaffGroup}),console.info("%cstarry-omr%c v1.0.0 2026-02-17T12:40:35.385Z","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(e){return function(t){return new Sha1(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod("hex");NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Sha1},e.update=function(t){return e.create().update(t)};for(var t=0;t>2]|=e[s]<>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(o[n>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=64?(this.block=o[16],this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Sha1.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block,e[t>>2]|=EXTRA[3&t],this.block=e[16],t>=56&&(this.hashed||this.hash(),e[0]=this.block,e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.hBytes<<3|this.bytes>>>29,e[15]=this.bytes<<3,this.hash()}},Sha1.prototype.hash=function(){var e,t,r=this.h0,n=this.h1,s=this.h2,i=this.h3,o=this.h4,a=this.blocks;for(e=16;e<80;++e)t=a[e-3]^a[e-8]^a[e-14]^a[e-16],a[e]=t<<1|t>>>31;for(e=0;e<20;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n&s|~n&i)+o+1518500249+a[e]|0)<<5|o>>>27)+(r&(n=n<<30|n>>>2)|~r&s)+i+1518500249+a[e+1]|0)<<5|i>>>27)+(o&(r=r<<30|r>>>2)|~o&n)+s+1518500249+a[e+2]|0)<<5|s>>>27)+(i&(o=o<<30|o>>>2)|~i&r)+n+1518500249+a[e+3]|0)<<5|n>>>27)+(s&(i=i<<30|i>>>2)|~s&o)+r+1518500249+a[e+4]|0,s=s<<30|s>>>2;for(;e<40;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n^s^i)+o+1859775393+a[e]|0)<<5|o>>>27)+(r^(n=n<<30|n>>>2)^s)+i+1859775393+a[e+1]|0)<<5|i>>>27)+(o^(r=r<<30|r>>>2)^n)+s+1859775393+a[e+2]|0)<<5|s>>>27)+(i^(o=o<<30|o>>>2)^r)+n+1859775393+a[e+3]|0)<<5|n>>>27)+(s^(i=i<<30|i>>>2)^o)+r+1859775393+a[e+4]|0,s=s<<30|s>>>2;for(;e<60;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n&s|n&i|s&i)+o-1894007588+a[e]|0)<<5|o>>>27)+(r&(n=n<<30|n>>>2)|r&s|n&s)+i-1894007588+a[e+1]|0)<<5|i>>>27)+(o&(r=r<<30|r>>>2)|o&n|r&n)+s-1894007588+a[e+2]|0)<<5|s>>>27)+(i&(o=o<<30|o>>>2)|i&r|o&r)+n-1894007588+a[e+3]|0)<<5|n>>>27)+(s&(i=i<<30|i>>>2)|s&o|i&o)+r-1894007588+a[e+4]|0,s=s<<30|s>>>2;for(;e<80;e+=5)r=(t=(n=(t=(s=(t=(i=(t=(o=(t=r<<5|r>>>27)+(n^s^i)+o-899497514+a[e]|0)<<5|o>>>27)+(r^(n=n<<30|n>>>2)^s)+i-899497514+a[e+1]|0)<<5|i>>>27)+(o^(r=r<<30|r>>>2)^n)+s-899497514+a[e+2]|0)<<5|s>>>27)+(i^(o=o<<30|o>>>2)^r)+n-899497514+a[e+3]|0)<<5|n>>>27)+(s^(i=i<<30|i>>>2)^o)+r-899497514+a[e+4]|0,s=s<<30|s>>>2;this.h0=this.h0+r|0,this.h1=this.h1+n|0,this.h2=this.h2+s|0,this.h3=this.h3+i|0,this.h4=this.h4+o|0},Sha1.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,s=this.h4;return 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[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[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+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]+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]},Sha1.prototype.toString=Sha1.prototype.hex,Sha1.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,r=this.h2,n=this.h3,s=this.h4;return[e>>24&255,e>>16&255,e>>8&255,255&e,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,n>>24&255,n>>16&255,n>>8&255,255&n,s>>24&255,s>>16&255,s>>8&255,255&s]},Sha1.prototype.array=Sha1.prototype.digest,Sha1.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(20),t=new DataView(e);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),e};var exports=createMethod();COMMON_JS?module.exports=exports:root.sha1=exports})()})(sha1),function(e){e.ClefG="ClefG",e.ClefF="ClefF",e.ClefC="ClefC",e.NoteheadS0="NoteheadS0",e.NoteheadS1="NoteheadS1",e.NoteheadS2="NoteheadS2",e.NoteheadS1stemU="NoteheadS1stemU",e.NoteheadS1stemD="NoteheadS1stemD",e.NoteheadS2stemU="NoteheadS2stemU",e.NoteheadS2stemD="NoteheadS2stemD",e.vline_Stem="vline_Stem",e.Flag3="Flag3",e.BeamLeft="BeamLeft",e.BeamContinue="BeamContinue",e.BeamRight="BeamRight",e.TremoloLeft="TremoloLeft",e.TremoloRight="TremoloRight",e.TremoloMiddle="TremoloMiddle",e.Dot="Dot",e.Rest0="Rest0",e.Rest1="Rest1",e.Rest2="Rest2",e.Rest3="Rest3",e.Rest4="Rest4",e.Rest5="Rest5",e.Rest6="Rest6",e.Rest0W="Rest0W",e.RestM1="RestM1",e.AccNatural="AccNatural",e.AccSharp="AccSharp",e.AccDoublesharp="AccDoublesharp",e.AccFlat="AccFlat",e.AccFlatflat="AccFlatflat",e.vline_VoltaLeft="vline_VoltaLeft",e.vline_VoltaRight="vline_VoltaRight",e.VoltaLeft="VoltaLeft",e.VoltaRight="VoltaRight",e.VoltaAlternativeBegin="VoltaAlternativeBegin",e.BarMeasure="BarMeasure",e.vline_BarMeasure="vline_BarMeasure",e.vline_BarTerminal="vline_BarTerminal",e.vline_BarSegment="vline_BarSegment",e.SlurBegin="SlurBegin",e.SlurEnd="SlurEnd",e.TimesigC44="TimesigC44",e.TimesigC22="TimesigC22",e.TimesigZero="TimesigZero",e.TimesigOne="TimesigOne",e.TimesigTwo="TimesigTwo",e.TimesigThree="TimesigThree",e.TimesigFour="TimesigFour",e.TimesigFive="TimesigFive",e.TimesigSix="TimesigSix",e.TimesigSeven="TimesigSeven",e.TimesigEight="TimesigEight",e.TimesigNine="TimesigNine",e.OctaveShift8va="OctaveShift8va",e.OctaveShift8vb="OctaveShift8vb",e.OctaveShift8="OctaveShift8",e.OctaveShift0="OctaveShift0",e.Zero="Zero",e.One="One",e.Two="Two",e.Three="Three",e.Four="Four",e.Five="Five",e.Six="Six",e.Seven="Seven",e.Eight="Eight",e.Nine="Nine",e.f="f",e.p="p",e.m="m",e.n="n",e.r="r",e.s="s",e.z="z",e.CrescendoBegin="CrescendoBegin",e.CrescendoEnd="CrescendoEnd",e.DecrescendoBegin="DecrescendoBegin",e.DecrescendoEnd="DecrescendoEnd",e.ScriptFermata="ScriptFermata",e.ScriptShortFermata="ScriptShortFermata",e.ScriptSforzato="ScriptSforzato",e.ScriptStaccato="ScriptStaccato",e.ScriptStaccatissimo="ScriptStaccatissimo",e.ScriptTurn="ScriptTurn",e.ScriptTrill="ScriptTrill",e.ScriptSegno="ScriptSegno",e.ScriptCoda="ScriptCoda",e.ScriptArpeggio="ScriptArpeggio",e.ScriptPrall="ScriptPrall",e.ScriptMordent="ScriptMordent",e.ScriptMarcato="ScriptMarcato",e.ScriptTenuto="ScriptTenuto",e.ScriptPortato="ScriptPortato",e.PedalStar="PedalStar",e.PedalPed="PedalPed",e.KeyAcc="KeyAcc",e.TempoNotehead="TempoNotehead",e.GraceNotehead="GraceNotehead",e.SignLined="SignLined",e.SignInterval="SignInterval",e.rect_Text="rect_Text",e.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=(e,t,r=-1/0)=>Math.max(Math.round(e/t)*t,r),gcd=(e,t)=>Number.isInteger(e)&&Number.isInteger(t)?0===t?e:gcd(t,e%t):(console.error("non-integer gcd:",e,t),1),frac=(e,t)=>({numerator:e,denominator:t}),reducedFraction=(e,t)=>{e=Math.round(e),t=Math.round(t);const r=0!==e?gcd(e,t):t;return frac(e/r,t/r)},fractionMul=(e,t)=>t?e*t.numerator/t.denominator:e;class DummyLogger{debug(...e){}group(...e){}groupCollapsed(...e){}groupEnd(){}info(...e){}warn(...e){}assert(...e){}}const EOM=-1,GREAT_NUMBER=1920,DURATION_MULTIPLIER=1921920,floatToFrac=e=>{const t=Math.round(e*GREAT_NUMBER);return reducedFraction(t,GREAT_NUMBER)},floatToTimeWarp=e=>1===e?null:floatToFrac(e);var ActionType;!function(e){e[e.PLACE=0]="PLACE",e[e.VERTICAL=1]="VERTICAL",e[e.HORIZONTAL=2]="HORIZONTAL"}(ActionType||(ActionType={}));class Action{constructor(e){Object.assign(this,e)}static P(e){return new Action({type:ActionType.PLACE,e1:e})}static V(e,t,r=1){return new Action({type:ActionType.VERTICAL,e1:r>0?e:t,e2:r>0?t:e})}static H(e,t){return new Action({type:ActionType.HORIZONTAL,e1:e,e2:t})}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(e,t){const r=Array(e.stages.length).fill(null).map(()=>Array(e.stages.length).fill(null).map(()=>new Set));e.actions.filter(e=>e.type===ActionType.HORIZONTAL).forEach(t=>{const n=e.stages.findIndex(e=>e.events.includes(t.e1)),s=e.stages.findIndex(e=>e.events.includes(t.e2));console.assert(n>=0&&s>=0,"invalid stages for H action:",e.id,e.stages,t),r[n][s].add(t.e1)}),r[0][e.stages.length-1].add(0);const n=e.stagedEvents,s=t.matrixH[t.matrixH.length-1].filter((e,t)=>!n.has(t)),i=Math.max(0,Math.max(...s)-.01),o=e.actions.filter(e=>e.type===ActionType.HORIZONTAL),a=Object.keys(t.eventMap).map(Number).filter(e=>!o.find(t=>t.e2===e));return e.stages.forEach(n=>{n.events.forEach(s=>{if(s>0){!o.find(e=>e.e1===s)&&t.matrixH[t.matrixH.length-1][s]>=i&&(a.some(e=>t.matrixH[e][s]>0)||r[n.index][e.stages.length-1].add(s))}})}),new StageMatrix({matrix:r})}constructor(e){Object.assign(this,e)}pathOf(e,t,r,n=0){if(this.matrix[e][t].size){const s=[...this.matrix[e][t]][n];if(t===r)return[s];for(let e=t+1;e<=r;++e){const n=this.pathOf(t,e,r);if(n)return[s,...n]}}return null}findDoublePath(e,t){const r=[];for(let n=t;n>=e+1;--n)for(let s=0;st.forEach(t=>e.forEach(e=>t.delete(e))))}toEquations(e){const t=[];for(let r=1;ri[e]=1),s.forEach(e=>i[e]=-1),t.push(i),this.reducePath(n.length>s.length?n:s)}}}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:[EOM]}];for(const t of this.actions)switch(t.type){case ActionType.PLACE:this.stages.unshift({events:[t.e1]});break;case ActionType.VERTICAL:{const e=this.stages.find(e=>e.events.includes(t.e1)),r=this.stages.find(e=>e.events.includes(t.e2));console.assert(e||r,"invalid V action:",this.stages,t),e&&r?(e.events.push(...r.events),r.events=null,this.stages=this.stages.filter(e=>e.events)):e?r||e.events.push(t.e2):r.events.unshift(t.e1)}break;case ActionType.HORIZONTAL:{const r=this.stages.find(e=>e.events.includes(t.e1)),n=this.stages.find(e=>e.events.includes(t.e2));console.assert(r||n,"invalid H action:",this.stages,t);const s=r=>{console.assert(e.eventMap[r],"invalid event id:",t.id,r,e.eventMap);const n=e.eventMap[r].x,s=this.stages.find(t=>t.events.some(t=>t>0&&e.eventMap[t].x<=n)&&t.events.some(t=>t>0&&e.eventMap[t].x>=n));if(s)s.events.push(r);else{const t={events:[r]},s=this.stages.findIndex(t=>t.events[0]===EOM||e.eventMap[t.events[0]].x>=n);this.stages.splice(s,0,t)}};r||s(t.e1),n||s(t.e2)}}this.stages.forEach((e,t)=>e.index=t)}constructConstraints(e){const t=Object.keys(e.eventMap).length,r=StageMatrix.fromNode(this,e).toEquations(t),n=Array(t).fill(null).map((t,r)=>e.eventMap[r].duration);this.constraints=r.map(e=>e.map((e,t)=>e*n[t]))}inbalancesConstraints(e){console.assert(this.constraints,"constraints not constructed.");const t=Object.keys(e.eventMap).length,r=Array(t).fill(!0),n=Array(t).fill(!1),s=[];for(const e of this.constraints){const t=e.reduce((e,t)=>e+t,0);if(0!==t){const i=t<0?e.map(e=>-e):e;if(i[0]>0)continue;s.push(i),i.forEach((e,t)=>{n[t]=n[t]||e<0,e&&(r[t]=e<0||n[t])})}}return this.constraints.forEach(e=>{0!==e.reduce((e,t)=>e+t,0)||e[0]||e.some((e,t)=>e&&!r[t])&&(e.forEach((e,t)=>e&&(r[t]=!1)),s.push(e))}),{ones:r,inbalances:s}}solveEquations({ones:e,inbalances:t}){if(!t.length)return e.map(()=>1);const r=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(!r.length)return e.map(()=>1);const n=r.map(e=>Math.abs(t.find(t=>0!==t[e])[e])),s=new Map;let i=!1;const o=t.map(e=>({line:e.filter((e,t)=>r.includes(t)),bias:-e.reduce((e,t,n)=>e+(r.includes(n)?0:t),0)})).filter(({line:e,bias:t})=>{if(e.every(e=>0===e))return!1;const r=e.join(",");return s.has(r)?(i=s.get(r)!==t,!1):(s.set(r,t),!0)});if(i)return null;const a=o.slice(0,r.length),c=o.slice(r.length);if(a.lengthr===t?1:r===s?-1:0),bias:0,prior:(n[t]+n[s])/DURATION_MULTIPLIER};a.some(e=>e.line[t]&&e.line[s])&&(i.prior-=10),a.some(e=>1===e.line.filter(Number).length&&(e.line[t]||e.line[s]))&&(i.prior+=1),e.push(i)}e.sort((e,t)=>e.prior-t.prior),a.push(...e.slice(0,r.length-a.length))}const l=a.map(({line:e})=>e),u=a.map(({bias:e})=>e),h=matrixInverse(l);if(!h)return this.logger.warn("null invert:",l),null;const d=h.map(e=>e.reduce((e,t,r)=>e+t*u[r],0));if(c.length&&c.some(e=>Math.abs(e.line.reduce((e,t,r)=>e+t*d[r],0))>.001))return null;const f=e.map(()=>1);return r.forEach((e,t)=>f[e]=d[t]),f}optimallySolve(e){const{ones:t,inbalances:r}=this.inbalancesConstraints(e),n=t.map((t,r)=>t?-1:roundNumber(e.eventMap[r].shrinkness,.01)).reduce((e,t,r)=>(t>=0&&(e[t]=e[t]||[],e[t].push(r)),e),{}),s=Object.entries(n).sort((e,t)=>Number(t[0])-Number(e[0])).map(e=>e[1]);for(let n=1;n!i.includes(t)),a=this.solveEquations({ones:o,inbalances:r});if(a&&a.every((t,r)=>t<=1&&t>e.eventMap[r].lowWarp))return a}return this.solveEquations({ones:t,inbalances:r})}isConflicted(e){const{ones:t,inbalances:r}=this.inbalancesConstraints(e);for(const n of r){if(n.reduce((r,n,s)=>r+n*(t[s]||n<=0?1:e.eventMap[s].lowWarp),0)>=0)return n.forEach((t,r)=>{t&&(e.eventTendencies[r]+=t>0?1:-1)}),!0}if(!r.length)return!1;const n=this.solveEquations({ones:t,inbalances:r});return!n||!n.every((t,r)=>t>e.eventMap[r].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,r=this.actions.filter(e=>e.type===ActionType.HORIZONTAL).sort((e,r)=>t(e)-t(r)),n=r.reduce((e,t)=>({...e,[t.e1]:t.e2}),{}),s=new Set([...Object.keys(n)].map(Number));r.forEach(e=>s.delete(e.e2)),this.stages[0].events.forEach(e=>e>0&&s.add(e));let i=[...s].map(e=>{const t=[e];let r=e;for(;n[r]&&(r=n[r],!(r<0||t.includes(r)));)t.push(r);return t});const o=Object.values(e.eventMap).filter(e=>e.id>0).map(e=>({id:e.id,tick:null,endTick:null,tickGroup:null,timeWarp:null})),a=o.filter(e=>i.some(t=>t.includes(e.id))||r.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=>a[e]&&(a[e].tickGroup=t))),this.stages[0].tick=0,this.stages[0].events.forEach(e=>a[e]&&(a[e].tick=0));const c=this.optimallySolve(e);o.forEach(e=>e.timeWarp=floatToTimeWarp(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 r.forEach(r=>{const n=this.stages.find(e=>e.events.includes(r.e1)),s=this.stages.find(e=>e.events.includes(r.e2));Number.isFinite(n.tick)&&!Number.isFinite(s.tick)&&(s.tick=n.tick+fractionMul(e.eventMap[r.e1].duration,a[r.e1].timeWarp),s.events.forEach(e=>a[e]&&(a[e].tick=s.tick)),t=!0)}),[...r].reverse().forEach(r=>{const n=this.stages.find(e=>e.events.includes(r.e1)),s=this.stages.find(e=>e.events.includes(r.e2));!Number.isFinite(n.tick)&&Number.isFinite(s.tick)&&(n.tick=s.tick-fractionMul(e.eventMap[r.e1].duration,a[r.e1].timeWarp),n.events.forEach(e=>a[e]&&(a[e].tick=n.tick)),t=!0)}),t};for(;u(););console.assert(l.every(e=>Number.isFinite(e.tick)),"stage ticks not all solved:",this.stages,this.id),o.filter(e=>Number.isFinite(e.tick)).forEach(t=>t.endTick=t.tick+fractionMul(e.eventMap[t.id].duration,t.timeWarp));const h=e.eventMap[0].duration;i.forEach(e=>{const t=e.findIndex(e=>a[e].endTick>h);if(t>=0){e.splice(t,e.length-t).forEach(e=>{a[e].tick=null,a[e].endTick=null})}}),i=i.filter(e=>e.length);const d=Math.max(0,...o.map(e=>e.endTick).filter(Number.isFinite));return this.logger.debug(String.fromCodePoint(127822),this.id,c),{voices:i,events:o,duration:d,actions:this.actions.map(e=>e.id).join(" ")}}deduce(e,t){this.stages||this.constructStages(e);const r=e.actionAccessing.get(this.id)||{times:0};if(++r.times,e.actionAccessing.set(this.id,r),this.constructConstraints(e),this.isConflicted(e))return r.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 r=t=>t.possibility/((e.actionAccessing.get(t.id)||{times:0}).times+1);this.children.sort((e,t)=>r(t)-r(e));for(const r of this.children){const n=r.deduce(e,t);if(n)return this.logger.groupEnd(),n;if(t.credits<=0)break}}}else this.logger.debug("quota exhausted.");return this.logger.groupEnd(),r.closed=!0,this.getSolution(e)}expand(e){this.constructStages(e);const{eventMap:t,matrixV:r,matrixH:n}=e,s=this.stagedEvents,i=[],o=e=>{if(!this.actions.some(t=>t.id===e.action.id)&&!i.some(t=>t.action.id===e.action.id)){const t=this.stages.find(t=>t.events.includes(e.action.e1)),n=this.stages.find(t=>t.events.includes(e.action.e2));if(t===n||t&&n&&t.index>=n.index)return;if(t&&n)if(e.action.type===ActionType.VERTICAL){if(n.index-t.index>1)return;if(this.actions.some(e=>t.events.includes(e.e1)&&n.events.includes(e.e2)))return}else if(e.action.type===ActionType.HORIZONTAL&&t.index>n.index)return;if(e.action.type===ActionType.HORIZONTAL&&this.actions.some(t=>t.type===ActionType.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===ActionType.VERTICAL){if(t&&(e.possibility=Math.min(e.possibility,...t.events.map(t=>r[e.action.e2][t])),e.possibility<=0))return;if(n&&(e.possibility=Math.min(e.possibility,...n.events.map(t=>r[t][e.action.e1])),e.possibility<=0))return}i.push(e)}};for(const e of s)e<0||(r[e].forEach((t,r)=>{t>0&&e!==r&&o({action:Action.V(r,e),possibility:t})}),r.forEach((t,r)=>{const n=t[e];n>0&&o({action:Action.V(e,r),possibility:n})}),n[e].forEach((t,r)=>{t>0&&o({action:Action.H(r,e),possibility:t})}),n.forEach((r,n)=>{n=n>=Object.keys(t).length?-1:n;const s=r[e];s>0&&o({action:Action.H(e,n),possibility:s})}));i.some(e=>[ActionType.HORIZONTAL,ActionType.PLACE].includes(e.action.type)||!s.has(e.action.e1)||!s.has(e.action.e2))?this.children=i.map(e=>new PathNode({logger:this.logger,parent:this,...e})):this.children=[]}}class Solver{constructor(e,{quota:t=1e3,logger:r=new DummyLogger}={}){this.quota=t,this.logger=r;const n={id:0,x:0,confidence:1,shrinkness:e.measureShrinkness,duration:e.expectedDuration,lowWarp:0};this.events=[n,...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),r={credits:this.quota,times:0};for(;r.credits>0;){++r.times;const n={eventMap:this.eventMap,matrixH:this.matrixH,matrixV:this.matrixV,actionAccessing:this.actionAccessing,eventTendencies:t},s=this.pathRoot.deduce(n,r);if(s.credits=this.quota-r.credits,s.times=r.times,this.evaluateSolution(s),this.logger.debug("loss:",s.loss),e=!e||s.losse/r.times)),e}evaluateSolution(e){e.loss=0;const t=e.events.reduce((e,t)=>({...e,[t.id]:{...t,...this.eventMap[t.id]}}),{}),r=e.events.filter(e=>Number.isFinite(e.tick)).map(e=>t[e.id]),n=r.reduce((e,t)=>(e[t.staff]=e[t.staff]||[],e[t.staff].push(t),e),{});Object.values(n).forEach(t=>{t.sort((e,t)=>e.x-t.x).slice(0,t.length-1).forEach((r,n)=>{t[n+1].tick{if(Number.isFinite(r.tick)&&!e.voices.every(e=>!e.includes(r.id))||(e.loss+=100*t[r.id].confidence),r.timeWarp){const{numerator:e,denominator:n}=r.timeWarp,i=t[r.id].shrinkness;s.set(e,Math.max(s.get(e)||0,1-i)),s.set(n,Math.max(s.get(n)||0,1-i))}});const i=reducedFraction(e.duration,this.eventMap[0].duration);s.set(i.numerator,Math.max(s.get(i.numerator)||0,1-this.eventMap[0].shrinkness)),s.set(i.denominator,Math.max(s.get(i.denominator)||0,1-this.eventMap[0].shrinkness));for(const[t,r]of s.entries())t>1&&(e.loss+=Math.log(t)*r);let o=0,a=0;e.voices.forEach(r=>{console.assert(t[r[0]],"invalid voice:",r,Object.keys(t));const n=Math.abs(t[r[0]].tick),s=t[r[r.length-1]].endTick;o+=Math.max(0,n+e.duration-s);let i=null;r.forEach(e=>{const r=t[e];r.staff!==i&&(null!==i&&++a,i=r.staff)})}),e.loss+=10*o/DURATION_MULTIPLIER,e.loss+=5**a-1;const c=[...r].sort((e,t)=>e.x-t.x),l=c.slice(1).map((t,r)=>{const n=c[r],s=t.x-n.x,i=t.tick-n.tick;if(!i)return s/this.xSpan;return(4*Math.atan2(i/e.duration,s/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,s,o,a),e.loss<0&&(e.loss=1/0)}}const solveStaffGroup=(e,t)=>{if(!e.events.length)return{events:[],voices:[],duration:0};return new Solver(e,t).solve()};worker({solveStaffGroup:solveStaffGroup}),console.info("%cstarry-omr%c v1.0.0 2026-02-17T15:16:54.807Z","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/backend/omr/dist/worker.js.map b/backend/omr/dist/worker.js.map index 975e2bafd79449543f9e38651ab610fd816c30f9..a08ac5b294b5ac8192f195af965390a95e8b6b47 100644 --- a/backend/omr/dist/worker.js.map +++ b/backend/omr/dist/worker.js.map @@ -1 +1 @@ -{"version":3,"file":"worker.js","sources":["../../../node_modules/workerpool/src/requireFoolWebpack.js","../../../node_modules/workerpool/src/Promise.js","../../../node_modules/workerpool/src/environment.js","../../../node_modules/workerpool/src/generated/embeddedWorker.js","../../../node_modules/workerpool/src/WorkerHandler.js","../../../node_modules/workerpool/src/transfer.js","../../../node_modules/workerpool/src/worker.js","../../../node_modules/workerpool/src/index.js","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/semanticPoint.ts","../../../node_modules/js-sha1/src/sha1.js","../../../src/starry/utils.ts","../../../src/starry/logger.ts","../../../src/starry/equationSolver.ts","../../../src/starry/solveStaffGroup.worker.ts","../src/worker.ts"],"sourcesContent":["// source of inspiration: https://github.com/sindresorhus/require-fool-webpack\nvar requireFoolWebpack = eval(\n 'typeof require !== \\'undefined\\' ' +\n '? require ' +\n ': function (module) { throw new Error(\\'Module \" + module + \" not found.\\') }'\n);\n\nmodule.exports = requireFoolWebpack;\n","'use strict';\n\n/**\n * Promise\n *\n * Inspired by https://gist.github.com/RubaXa/8501359 from RubaXa \n *\n * @param {Function} handler Called as handler(resolve: Function, reject: Function)\n * @param {Promise} [parent] Parent promise for propagation of cancel and timeout\n */\nfunction Promise(handler, parent) {\n var me = this;\n\n if (!(this instanceof Promise)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n\n if (typeof handler !== 'function') {\n throw new SyntaxError('Function parameter handler(resolve, reject) missing');\n }\n\n var _onSuccess = [];\n var _onFail = [];\n\n // status\n this.resolved = false;\n this.rejected = false;\n this.pending = true;\n\n /**\n * Process onSuccess and onFail callbacks: add them to the queue.\n * Once the promise is resolve, the function _promise is replace.\n * @param {Function} onSuccess\n * @param {Function} onFail\n * @private\n */\n var _process = function (onSuccess, onFail) {\n _onSuccess.push(onSuccess);\n _onFail.push(onFail);\n };\n\n /**\n * Add an onSuccess callback and optionally an onFail callback to the Promise\n * @param {Function} onSuccess\n * @param {Function} [onFail]\n * @returns {Promise} promise\n */\n this.then = function (onSuccess, onFail) {\n return new Promise(function (resolve, reject) {\n var s = onSuccess ? _then(onSuccess, resolve, reject) : resolve;\n var f = onFail ? _then(onFail, resolve, reject) : reject;\n\n _process(s, f);\n }, me);\n };\n\n /**\n * Resolve the promise\n * @param {*} result\n * @type {Function}\n */\n var _resolve = function (result) {\n // update status\n me.resolved = true;\n me.rejected = false;\n me.pending = false;\n\n _onSuccess.forEach(function (fn) {\n fn(result);\n });\n\n _process = function (onSuccess, onFail) {\n onSuccess(result);\n };\n\n _resolve = _reject = function () { };\n\n return me;\n };\n\n /**\n * Reject the promise\n * @param {Error} error\n * @type {Function}\n */\n var _reject = function (error) {\n // update status\n me.resolved = false;\n me.rejected = true;\n me.pending = false;\n\n _onFail.forEach(function (fn) {\n fn(error);\n });\n\n _process = function (onSuccess, onFail) {\n onFail(error);\n };\n\n _resolve = _reject = function () { }\n\n return me;\n };\n\n /**\n * Cancel te promise. This will reject the promise with a CancellationError\n * @returns {Promise} self\n */\n this.cancel = function () {\n if (parent) {\n parent.cancel();\n }\n else {\n _reject(new CancellationError());\n }\n\n return me;\n };\n\n /**\n * Set a timeout for the promise. If the promise is not resolved within\n * the time, the promise will be cancelled and a TimeoutError is thrown.\n * If the promise is resolved in time, the timeout is removed.\n * @param {number} delay Delay in milliseconds\n * @returns {Promise} self\n */\n this.timeout = function (delay) {\n if (parent) {\n parent.timeout(delay);\n }\n else {\n var timer = setTimeout(function () {\n _reject(new TimeoutError('Promise timed out after ' + delay + ' ms'));\n }, delay);\n\n me.always(function () {\n clearTimeout(timer);\n });\n }\n\n return me;\n };\n\n // attach handler passing the resolve and reject functions\n handler(function (result) {\n _resolve(result);\n }, function (error) {\n _reject(error);\n });\n}\n\n/**\n * Execute given callback, then call resolve/reject based on the returned result\n * @param {Function} callback\n * @param {Function} resolve\n * @param {Function} reject\n * @returns {Function}\n * @private\n */\nfunction _then(callback, resolve, reject) {\n return function (result) {\n try {\n var res = callback(result);\n if (res && typeof res.then === 'function' && typeof res['catch'] === 'function') {\n // method returned a promise\n res.then(resolve, reject);\n }\n else {\n resolve(res);\n }\n }\n catch (error) {\n reject(error);\n }\n }\n}\n\n/**\n * Add an onFail callback to the Promise\n * @param {Function} onFail\n * @returns {Promise} promise\n */\nPromise.prototype['catch'] = function (onFail) {\n return this.then(null, onFail);\n};\n\n// TODO: add support for Promise.catch(Error, callback)\n// TODO: add support for Promise.catch(Error, Error, callback)\n\n/**\n * Execute given callback when the promise either resolves or rejects.\n * @param {Function} fn\n * @returns {Promise} promise\n */\nPromise.prototype.always = function (fn) {\n return this.then(fn, fn);\n};\n\n/**\n * Create a promise which resolves when all provided promises are resolved,\n * and fails when any of the promises resolves.\n * @param {Promise[]} promises\n * @returns {Promise} promise\n */\nPromise.all = function (promises){\n return new Promise(function (resolve, reject) {\n var remaining = promises.length,\n results = [];\n\n if (remaining) {\n promises.forEach(function (p, i) {\n p.then(function (result) {\n results[i] = result;\n remaining--;\n if (remaining == 0) {\n resolve(results);\n }\n }, function (error) {\n remaining = 0;\n reject(error);\n });\n });\n }\n else {\n resolve(results);\n }\n });\n};\n\n/**\n * Create a promise resolver\n * @returns {{promise: Promise, resolve: Function, reject: Function}} resolver\n */\nPromise.defer = function () {\n var resolver = {};\n\n resolver.promise = new Promise(function (resolve, reject) {\n resolver.resolve = resolve;\n resolver.reject = reject;\n });\n\n return resolver;\n};\n\n/**\n * Create a cancellation error\n * @param {String} [message]\n * @extends Error\n */\nfunction CancellationError(message) {\n this.message = message || 'promise cancelled';\n this.stack = (new Error()).stack;\n}\n\nCancellationError.prototype = new Error();\nCancellationError.prototype.constructor = Error;\nCancellationError.prototype.name = 'CancellationError';\n\nPromise.CancellationError = CancellationError;\n\n\n/**\n * Create a timeout error\n * @param {String} [message]\n * @extends Error\n */\nfunction TimeoutError(message) {\n this.message = message || 'timeout exceeded';\n this.stack = (new Error()).stack;\n}\n\nTimeoutError.prototype = new Error();\nTimeoutError.prototype.constructor = Error;\nTimeoutError.prototype.name = 'TimeoutError';\n\nPromise.TimeoutError = TimeoutError;\n\n\nmodule.exports = Promise;\n","var requireFoolWebpack = require('./requireFoolWebpack');\n\n// source: https://github.com/flexdinesh/browser-or-node\nvar isNode = function (nodeProcess) {\n return (\n typeof nodeProcess !== 'undefined' &&\n nodeProcess.versions != null &&\n nodeProcess.versions.node != null\n );\n}\nmodule.exports.isNode = isNode\n\n// determines the JavaScript platform: browser or node\nmodule.exports.platform = typeof process !== 'undefined' && isNode(process)\n ? 'node'\n : 'browser';\n\n// determines whether the code is running in main thread or not\n// note that in node.js we have to check both worker_thread and child_process\nvar worker_threads = tryRequireFoolWebpack('worker_threads');\nmodule.exports.isMainThread = module.exports.platform === 'node'\n ? ((!worker_threads || worker_threads.isMainThread) && !process.connected)\n : typeof Window !== 'undefined';\n\n// determines the number of cpus available\nmodule.exports.cpus = module.exports.platform === 'browser'\n ? self.navigator.hardwareConcurrency\n : requireFoolWebpack('os').cpus().length;\n\nfunction tryRequireFoolWebpack (module) {\n try {\n return requireFoolWebpack(module);\n } catch(err) {\n return null\n }\n}\n","/**\n * embeddedWorker.js contains an embedded version of worker.js.\n * This file is automatically generated,\n * changes made in this file will be overwritten.\n */\nmodule.exports = \"!function(){var __webpack_modules__={577:function(e){e.exports=function(e,r){this.message=e,this.transfer=r}}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];return void 0!==r||(r=__webpack_module_cache__[e]={exports:{}},__webpack_modules__[e](r,r.exports,__webpack_require__)),r.exports}var __webpack_exports__={};!function(){var exports=__webpack_exports__,__webpack_unused_export__;function _typeof(e){return(_typeof=\\\"function\\\"==typeof Symbol&&\\\"symbol\\\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\\\"function\\\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\\\"symbol\\\":typeof e})(e)}var Transfer=__webpack_require__(577),requireFoolWebpack=eval(\\\"typeof require !== 'undefined' ? require : function (module) { throw new Error('Module \\\\\\\" + module + \\\\\\\" not found.') }\\\"),TERMINATE_METHOD_ID=\\\"__workerpool-terminate__\\\",worker={exit:function(){}},WorkerThreads,parentPort;if(\\\"undefined\\\"!=typeof self&&\\\"function\\\"==typeof postMessage&&\\\"function\\\"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if(\\\"undefined\\\"==typeof process)throw new Error(\\\"Script must be executed as a worker\\\");try{WorkerThreads=requireFoolWebpack(\\\"worker_threads\\\")}catch(error){if(\\\"object\\\"!==_typeof(error)||null===error||\\\"MODULE_NOT_FOUND\\\"!==error.code)throw error}WorkerThreads&&null!==WorkerThreads.parentPort?(parentPort=WorkerThreads.parentPort,worker.send=parentPort.postMessage.bind(parentPort),worker.on=parentPort.on.bind(parentPort)):(worker.on=process.on.bind(process),worker.send=function(e){process.send(e)},worker.on(\\\"disconnect\\\",function(){process.exit(1)})),worker.exit=process.exit.bind(process)}function convertError(o){return Object.getOwnPropertyNames(o).reduce(function(e,r){return Object.defineProperty(e,r,{value:o[r],enumerable:!0})},{})}function isPromise(e){return e&&\\\"function\\\"==typeof e.then&&\\\"function\\\"==typeof e.catch}worker.methods={},worker.methods.run=function(e,r){e=new Function(\\\"return (\\\"+e+\\\").apply(null, arguments);\\\");return e.apply(e,r)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.terminationHandler=void 0,worker.cleanupAndExit=function(e){function r(){worker.exit(e)}if(!worker.terminationHandler)return r();var o=worker.terminationHandler(e);isPromise(o)?o.then(r,r):r()};var currentRequestId=null;worker.on(\\\"message\\\",function(r){if(r===TERMINATE_METHOD_ID)return worker.cleanupAndExit(0);try{var e=worker.methods[r.method];if(!e)throw new Error('Unknown method \\\"'+r.method+'\\\"');currentRequestId=r.id;var o=e.apply(e,r.params);isPromise(o)?o.then(function(e){e instanceof Transfer?worker.send({id:r.id,result:e.message,error:null},e.transfer):worker.send({id:r.id,result:e,error:null}),currentRequestId=null}).catch(function(e){worker.send({id:r.id,result:null,error:convertError(e)}),currentRequestId=null}):(o instanceof Transfer?worker.send({id:r.id,result:o.message,error:null},o.transfer):worker.send({id:r.id,result:o,error:null}),currentRequestId=null)}catch(e){worker.send({id:r.id,result:null,error:convertError(e)})}}),worker.register=function(e,r){if(e)for(var o in e)e.hasOwnProperty(o)&&(worker.methods[o]=e[o]);r&&(worker.terminationHandler=r.onTerminate),worker.send(\\\"ready\\\")},worker.emit=function(e){currentRequestId&&(e instanceof Transfer?worker.send({id:currentRequestId,isEvent:!0,payload:e.message},e.transfer):worker.send({id:currentRequestId,isEvent:!0,payload:e}))},__webpack_unused_export__=worker.register,worker.emit}()}();\";\n","'use strict';\n\nvar Promise = require('./Promise');\nvar environment = require('./environment');\nvar requireFoolWebpack = require('./requireFoolWebpack');\n\n/**\n * Special message sent by parent which causes a child process worker to terminate itself.\n * Not a \"message object\"; this string is the entire message.\n */\nvar TERMINATE_METHOD_ID = '__workerpool-terminate__';\n\nfunction ensureWorkerThreads() {\n var WorkerThreads = tryRequireWorkerThreads()\n if (!WorkerThreads) {\n throw new Error('WorkerPool: workerType = \\'thread\\' is not supported, Node >= 11.7.0 required')\n }\n\n return WorkerThreads;\n}\n\n// check whether Worker is supported by the browser\nfunction ensureWebWorker() {\n // Workaround for a bug in PhantomJS (Or QtWebkit): https://github.com/ariya/phantomjs/issues/14534\n if (typeof Worker !== 'function' && (typeof Worker !== 'object' || typeof Worker.prototype.constructor !== 'function')) {\n throw new Error('WorkerPool: Web Workers not supported');\n }\n}\n\nfunction tryRequireWorkerThreads() {\n try {\n return requireFoolWebpack('worker_threads');\n } catch(error) {\n if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {\n // no worker_threads available (old version of node.js)\n return null;\n } else {\n throw error;\n }\n }\n}\n\n// get the default worker script\nfunction getDefaultWorker() {\n if (environment.platform === 'browser') {\n // test whether the browser supports all features that we need\n if (typeof Blob === 'undefined') {\n throw new Error('Blob not supported by the browser');\n }\n if (!window.URL || typeof window.URL.createObjectURL !== 'function') {\n throw new Error('URL.createObjectURL not supported by the browser');\n }\n\n // use embedded worker.js\n var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});\n return window.URL.createObjectURL(blob);\n }\n else {\n // use external worker.js in current directory\n return __dirname + '/worker.js';\n }\n}\n\nfunction setupWorker(script, options) {\n if (options.workerType === 'web') { // browser only\n ensureWebWorker();\n return setupBrowserWorker(script, options.workerOpts, Worker);\n } else if (options.workerType === 'thread') { // node.js only\n WorkerThreads = ensureWorkerThreads();\n return setupWorkerThreadWorker(script, WorkerThreads, options.workerThreadOpts);\n } else if (options.workerType === 'process' || !options.workerType) { // node.js only\n return setupProcessWorker(script, resolveForkOptions(options), requireFoolWebpack('child_process'));\n } else { // options.workerType === 'auto' or undefined\n if (environment.platform === 'browser') {\n ensureWebWorker();\n return setupBrowserWorker(script, options.workerOpts, Worker);\n }\n else { // environment.platform === 'node'\n var WorkerThreads = tryRequireWorkerThreads();\n if (WorkerThreads) {\n return setupWorkerThreadWorker(script, WorkerThreads, options.workerThreadOpts);\n } else {\n return setupProcessWorker(script, resolveForkOptions(options), requireFoolWebpack('child_process'));\n }\n }\n }\n}\n\nfunction setupBrowserWorker(script, workerOpts, Worker) {\n // create the web worker\n var worker = new Worker(script, workerOpts);\n\n worker.isBrowserWorker = true;\n // add node.js API to the web worker\n worker.on = function (event, callback) {\n this.addEventListener(event, function (message) {\n callback(message.data);\n });\n };\n worker.send = function (message, transfer) {\n this.postMessage(message, transfer);\n };\n return worker;\n}\n\nfunction setupWorkerThreadWorker(script, WorkerThreads, workerThreadOptions) {\n var worker = new WorkerThreads.Worker(script, {\n stdout: false, // automatically pipe worker.STDOUT to process.STDOUT\n stderr: false, // automatically pipe worker.STDERR to process.STDERR\n ...workerThreadOptions\n });\n worker.isWorkerThread = true;\n worker.send = function(message, transfer) {\n this.postMessage(message, transfer);\n };\n\n worker.kill = function() {\n this.terminate();\n return true;\n };\n\n worker.disconnect = function() {\n this.terminate();\n };\n\n return worker;\n}\n\nfunction setupProcessWorker(script, options, child_process) {\n // no WorkerThreads, fallback to sub-process based workers\n var worker = child_process.fork(\n script,\n options.forkArgs,\n options.forkOpts\n );\n\n // ignore transfer argument since it is not supported by process\n var send = worker.send;\n worker.send = function (message) {\n return send.call(worker, message);\n };\n\n worker.isChildProcess = true;\n return worker;\n}\n\n// add debug flags to child processes if the node inspector is active\nfunction resolveForkOptions(opts) {\n opts = opts || {};\n\n var processExecArgv = process.execArgv.join(' ');\n var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;\n var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;\n\n var execArgv = [];\n if (inspectorActive) {\n execArgv.push('--inspect=' + opts.debugPort);\n\n if (debugBrk) {\n execArgv.push('--debug-brk');\n }\n }\n\n process.execArgv.forEach(function(arg) {\n if (arg.indexOf('--max-old-space-size') > -1) {\n execArgv.push(arg)\n }\n })\n\n return Object.assign({}, opts, {\n forkArgs: opts.forkArgs,\n forkOpts: Object.assign({}, opts.forkOpts, {\n execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])\n .concat(execArgv)\n })\n });\n}\n\n/**\n * Converts a serialized error to Error\n * @param {Object} obj Error that has been serialized and parsed to object\n * @return {Error} The equivalent Error.\n */\nfunction objectToError (obj) {\n var temp = new Error('')\n var props = Object.keys(obj)\n\n for (var i = 0; i < props.length; i++) {\n temp[props[i]] = obj[props[i]]\n }\n\n return temp\n}\n\n/**\n * A WorkerHandler controls a single worker. This worker can be a child process\n * on node.js or a WebWorker in a browser environment.\n * @param {String} [script] If no script is provided, a default worker with a\n * function run will be created.\n * @param {WorkerPoolOptions} _options See docs\n * @constructor\n */\nfunction WorkerHandler(script, _options) {\n var me = this;\n var options = _options || {};\n\n this.script = script || getDefaultWorker();\n this.worker = setupWorker(this.script, options);\n this.debugPort = options.debugPort;\n this.forkOpts = options.forkOpts;\n this.forkArgs = options.forkArgs;\n this.workerOpts = options.workerOpts;\n this.workerThreadOpts = options.workerThreadOpts\n this.workerTerminateTimeout = options.workerTerminateTimeout;\n\n // The ready message is only sent if the worker.add method is called (And the default script is not used)\n if (!script) {\n this.worker.ready = true;\n }\n\n // queue for requests that are received before the worker is ready\n this.requestQueue = [];\n this.worker.on('message', function (response) {\n if (me.terminated) {\n return;\n }\n if (typeof response === 'string' && response === 'ready') {\n me.worker.ready = true;\n dispatchQueuedRequests();\n } else {\n // find the task from the processing queue, and run the tasks callback\n var id = response.id;\n var task = me.processing[id];\n if (task !== undefined) {\n if (response.isEvent) {\n if (task.options && typeof task.options.on === 'function') {\n task.options.on(response.payload);\n }\n } else {\n // remove the task from the queue\n delete me.processing[id];\n\n // test if we need to terminate\n if (me.terminating === true) {\n // complete worker termination if all tasks are finished\n me.terminate();\n }\n\n // resolve the task's promise\n if (response.error) {\n task.resolver.reject(objectToError(response.error));\n }\n else {\n task.resolver.resolve(response.result);\n }\n }\n }\n }\n });\n\n // reject all running tasks on worker error\n function onError(error) {\n me.terminated = true;\n\n for (var id in me.processing) {\n if (me.processing[id] !== undefined) {\n me.processing[id].resolver.reject(error);\n }\n }\n me.processing = Object.create(null);\n }\n\n // send all queued requests to worker\n function dispatchQueuedRequests()\n {\n for(const request of me.requestQueue.splice(0)) {\n me.worker.send(request.message, request.transfer);\n }\n }\n\n var worker = this.worker;\n // listen for worker messages error and exit\n this.worker.on('error', onError);\n this.worker.on('exit', function (exitCode, signalCode) {\n var message = 'Workerpool Worker terminated Unexpectedly\\n';\n\n message += ' exitCode: `' + exitCode + '`\\n';\n message += ' signalCode: `' + signalCode + '`\\n';\n\n message += ' workerpool.script: `' + me.script + '`\\n';\n message += ' spawnArgs: `' + worker.spawnargs + '`\\n';\n message += ' spawnfile: `' + worker.spawnfile + '`\\n'\n\n message += ' stdout: `' + worker.stdout + '`\\n'\n message += ' stderr: `' + worker.stderr + '`\\n'\n\n onError(new Error(message));\n });\n\n this.processing = Object.create(null); // queue with tasks currently in progress\n\n this.terminating = false;\n this.terminated = false;\n this.cleaning = false;\n this.terminationHandler = null;\n this.lastId = 0;\n}\n\n/**\n * Get a list with methods available on the worker.\n * @return {Promise.} methods\n */\nWorkerHandler.prototype.methods = function () {\n return this.exec('methods');\n};\n\n/**\n * Execute a method with given parameters on the worker\n * @param {String} method\n * @param {Array} [params]\n * @param {{resolve: Function, reject: Function}} [resolver]\n * @param {ExecOptions} [options]\n * @return {Promise.<*, Error>} result\n */\nWorkerHandler.prototype.exec = function(method, params, resolver, options) {\n if (!resolver) {\n resolver = Promise.defer();\n }\n\n // generate a unique id for the task\n var id = ++this.lastId;\n\n // register a new task as being in progress\n this.processing[id] = {\n id: id,\n resolver: resolver,\n options: options\n };\n\n // build a JSON-RPC request\n var request = {\n message: {\n id: id,\n method: method,\n params: params\n },\n transfer: options && options.transfer\n };\n\n if (this.terminated) {\n resolver.reject(new Error('Worker is terminated'));\n } else if (this.worker.ready) {\n // send the request to the worker\n this.worker.send(request.message, request.transfer);\n } else {\n this.requestQueue.push(request);\n }\n\n // on cancellation, force the worker to terminate\n var me = this;\n return resolver.promise.catch(function (error) {\n if (error instanceof Promise.CancellationError || error instanceof Promise.TimeoutError) {\n // remove this task from the queue. It is already rejected (hence this\n // catch event), and else it will be rejected again when terminating\n delete me.processing[id];\n\n // terminate worker\n return me.terminateAndNotify(true)\n .then(function() {\n throw error;\n }, function(err) {\n throw err;\n });\n } else {\n throw error;\n }\n })\n};\n\n/**\n * Test whether the worker is processing any tasks or cleaning up before termination.\n * @return {boolean} Returns true if the worker is busy\n */\nWorkerHandler.prototype.busy = function () {\n return this.cleaning || Object.keys(this.processing).length > 0;\n};\n\n/**\n * Terminate the worker.\n * @param {boolean} [force=false] If false (default), the worker is terminated\n * after finishing all tasks currently in\n * progress. If true, the worker will be\n * terminated immediately.\n * @param {function} [callback=null] If provided, will be called when process terminates.\n */\nWorkerHandler.prototype.terminate = function (force, callback) {\n var me = this;\n if (force) {\n // cancel all tasks in progress\n for (var id in this.processing) {\n if (this.processing[id] !== undefined) {\n this.processing[id].resolver.reject(new Error('Worker terminated'));\n }\n }\n this.processing = Object.create(null);\n }\n\n if (typeof callback === 'function') {\n this.terminationHandler = callback;\n }\n if (!this.busy()) {\n // all tasks are finished. kill the worker\n var cleanup = function(err) {\n me.terminated = true;\n me.cleaning = false;\n if (me.worker != null && me.worker.removeAllListeners) {\n // removeAllListeners is only available for child_process\n me.worker.removeAllListeners('message');\n }\n me.worker = null;\n me.terminating = false;\n if (me.terminationHandler) {\n me.terminationHandler(err, me);\n } else if (err) {\n throw err;\n }\n }\n\n if (this.worker) {\n if (typeof this.worker.kill === 'function') {\n if (this.worker.killed) {\n cleanup(new Error('worker already killed!'));\n return;\n }\n\n // child process and worker threads\n var cleanExitTimeout = setTimeout(function() {\n if (me.worker) {\n me.worker.kill();\n }\n }, this.workerTerminateTimeout);\n\n this.worker.once('exit', function() {\n clearTimeout(cleanExitTimeout);\n if (me.worker) {\n me.worker.killed = true;\n }\n cleanup();\n });\n\n if (this.worker.ready) {\n this.worker.send(TERMINATE_METHOD_ID);\n } else {\n this.requestQueue.push({ message: TERMINATE_METHOD_ID });\n }\n\n // mark that the worker is cleaning up resources\n // to prevent new tasks from being executed\n this.cleaning = true;\n return;\n }\n else if (typeof this.worker.terminate === 'function') {\n this.worker.terminate(); // web worker\n this.worker.killed = true;\n }\n else {\n throw new Error('Failed to terminate worker');\n }\n }\n cleanup();\n }\n else {\n // we can't terminate immediately, there are still tasks being executed\n this.terminating = true;\n }\n};\n\n/**\n * Terminate the worker, returning a Promise that resolves when the termination has been done.\n * @param {boolean} [force=false] If false (default), the worker is terminated\n * after finishing all tasks currently in\n * progress. If true, the worker will be\n * terminated immediately.\n * @param {number} [timeout] If provided and non-zero, worker termination promise will be rejected\n * after timeout if worker process has not been terminated.\n * @return {Promise.}\n */\nWorkerHandler.prototype.terminateAndNotify = function (force, timeout) {\n var resolver = Promise.defer();\n if (timeout) {\n resolver.promise.timeout(timeout);\n }\n this.terminate(force, function(err, worker) {\n if (err) {\n resolver.reject(err);\n } else {\n resolver.resolve(worker);\n }\n });\n return resolver.promise;\n};\n\nmodule.exports = WorkerHandler;\nmodule.exports._tryRequireWorkerThreads = tryRequireWorkerThreads;\nmodule.exports._setupProcessWorker = setupProcessWorker;\nmodule.exports._setupBrowserWorker = setupBrowserWorker;\nmodule.exports._setupWorkerThreadWorker = setupWorkerThreadWorker;\nmodule.exports.ensureWorkerThreads = ensureWorkerThreads;\n","/**\n * The helper class for transferring data from the worker to the main thread.\n *\n * @param {Object} message The object to deliver to the main thread.\n * @param {Object[]} transfer An array of transferable Objects to transfer ownership of.\n */\nfunction Transfer(message, transfer) {\n this.message = message;\n this.transfer = transfer;\n}\n\nmodule.exports = Transfer;\n","/**\n * worker must be started as a child process or a web worker.\n * It listens for RPC messages from the parent process.\n */\nvar Transfer = require('./transfer');\n\n// source of inspiration: https://github.com/sindresorhus/require-fool-webpack\nvar requireFoolWebpack = eval(\n 'typeof require !== \\'undefined\\'' +\n ' ? require' +\n ' : function (module) { throw new Error(\\'Module \" + module + \" not found.\\') }'\n);\n\n/**\n * Special message sent by parent which causes the worker to terminate itself.\n * Not a \"message object\"; this string is the entire message.\n */\nvar TERMINATE_METHOD_ID = '__workerpool-terminate__';\n\n// var nodeOSPlatform = require('./environment').nodeOSPlatform;\n\n// create a worker API for sending and receiving messages which works both on\n// node.js and in the browser\nvar worker = {\n exit: function() {}\n};\nif (typeof self !== 'undefined' && typeof postMessage === 'function' && typeof addEventListener === 'function') {\n // worker in the browser\n worker.on = function (event, callback) {\n addEventListener(event, function (message) {\n callback(message.data);\n })\n };\n worker.send = function (message) {\n postMessage(message);\n };\n}\nelse if (typeof process !== 'undefined') {\n // node.js\n\n var WorkerThreads;\n try {\n WorkerThreads = requireFoolWebpack('worker_threads');\n } catch(error) {\n if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {\n // no worker_threads, fallback to sub-process based workers\n } else {\n throw error;\n }\n }\n\n if (WorkerThreads &&\n /* if there is a parentPort, we are in a WorkerThread */\n WorkerThreads.parentPort !== null) {\n var parentPort = WorkerThreads.parentPort;\n worker.send = parentPort.postMessage.bind(parentPort);\n worker.on = parentPort.on.bind(parentPort);\n worker.exit = process.exit.bind(process);\n } else {\n worker.on = process.on.bind(process);\n // ignore transfer argument since it is not supported by process\n worker.send = function (message) {\n process.send(message);\n };\n // register disconnect handler only for subprocess worker to exit when parent is killed unexpectedly\n worker.on('disconnect', function () {\n process.exit(1);\n });\n worker.exit = process.exit.bind(process);\n }\n}\nelse {\n throw new Error('Script must be executed as a worker');\n}\n\nfunction convertError(error) {\n return Object.getOwnPropertyNames(error).reduce(function(product, name) {\n return Object.defineProperty(product, name, {\n\tvalue: error[name],\n\tenumerable: true\n });\n }, {});\n}\n\n/**\n * Test whether a value is a Promise via duck typing.\n * @param {*} value\n * @returns {boolean} Returns true when given value is an object\n * having functions `then` and `catch`.\n */\nfunction isPromise(value) {\n return value && (typeof value.then === 'function') && (typeof value.catch === 'function');\n}\n\n// functions available externally\nworker.methods = {};\n\n/**\n * Execute a function with provided arguments\n * @param {String} fn Stringified function\n * @param {Array} [args] Function arguments\n * @returns {*}\n */\nworker.methods.run = function run(fn, args) {\n var f = new Function('return (' + fn + ').apply(null, arguments);');\n return f.apply(f, args);\n};\n\n/**\n * Get a list with methods available on this worker\n * @return {String[]} methods\n */\nworker.methods.methods = function methods() {\n return Object.keys(worker.methods);\n};\n\n/**\n * Custom handler for when the worker is terminated.\n */\nworker.terminationHandler = undefined;\n\n/**\n * Cleanup and exit the worker.\n * @param {Number} code \n * @returns \n */\nworker.cleanupAndExit = function(code) {\n var _exit = function() {\n worker.exit(code);\n }\n\n if(!worker.terminationHandler) {\n return _exit();\n }\n\n var result = worker.terminationHandler(code);\n if (isPromise(result)) {\n result.then(_exit, _exit);\n } else {\n _exit();\n }\n}\n\nvar currentRequestId = null;\n\nworker.on('message', function (request) {\n if (request === TERMINATE_METHOD_ID) {\n return worker.cleanupAndExit(0);\n }\n try {\n var method = worker.methods[request.method];\n\n if (method) {\n currentRequestId = request.id;\n \n // execute the function\n var result = method.apply(method, request.params);\n\n if (isPromise(result)) {\n // promise returned, resolve this and then return\n result\n .then(function (result) {\n if (result instanceof Transfer) {\n worker.send({\n id: request.id,\n result: result.message,\n error: null\n }, result.transfer);\n } else {\n worker.send({\n id: request.id,\n result: result,\n error: null\n });\n }\n currentRequestId = null;\n })\n .catch(function (err) {\n worker.send({\n id: request.id,\n result: null,\n error: convertError(err)\n });\n currentRequestId = null;\n });\n }\n else {\n // immediate result\n if (result instanceof Transfer) {\n worker.send({\n id: request.id,\n result: result.message,\n error: null\n }, result.transfer);\n } else {\n worker.send({\n id: request.id,\n result: result,\n error: null\n });\n }\n\n currentRequestId = null;\n }\n }\n else {\n throw new Error('Unknown method \"' + request.method + '\"');\n }\n }\n catch (err) {\n worker.send({\n id: request.id,\n result: null,\n error: convertError(err)\n });\n }\n});\n\n/**\n * Register methods to the worker\n * @param {Object} [methods]\n * @param {WorkerRegisterOptions} [options]\n */\nworker.register = function (methods, options) {\n\n if (methods) {\n for (var name in methods) {\n if (methods.hasOwnProperty(name)) {\n worker.methods[name] = methods[name];\n }\n }\n }\n\n if (options) {\n worker.terminationHandler = options.onTerminate;\n }\n\n worker.send('ready');\n};\n\nworker.emit = function (payload) {\n if (currentRequestId) {\n if (payload instanceof Transfer) {\n worker.send({\n id: currentRequestId,\n isEvent: true,\n payload: payload.message\n }, payload.transfer);\n return;\n }\n\n worker.send({\n id: currentRequestId,\n isEvent: true,\n payload\n });\n }\n};\n\nif (typeof exports !== 'undefined') {\n exports.add = worker.register;\n exports.emit = worker.emit;\n}\n","var environment = require('./environment');\n\n/**\n * Create a new worker pool\n * @param {string} [script]\n * @param {WorkerPoolOptions} [options]\n * @returns {Pool} pool\n */\nexports.pool = function pool(script, options) {\n var Pool = require('./Pool');\n\n return new Pool(script, options);\n};\n\n/**\n * Create a worker and optionally register a set of methods to the worker.\n * @param {Object} [methods]\n * @param {WorkerRegisterOptions} [options]\n */\nexports.worker = function worker(methods, options) {\n var worker = require('./worker');\n worker.add(methods, options);\n};\n\n/**\n * Sends an event to the parent worker pool.\n * @param {any} payload \n */\nexports.workerEmit = function workerEmit(payload) {\n var worker = require('./worker');\n worker.emit(payload);\n};\n\n/**\n * Create a promise.\n * @type {Promise} promise\n */\nexports.Promise = require('./Promise');\n\n/**\n * Create a transfer object.\n * @type {Transfer} transfer\n */\nexports.Transfer = require('./transfer');\n\nexports.platform = environment.platform;\nexports.isMainThread = environment.isMainThread;\nexports.cpus = environment.cpus;","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","/*\n * [js-sha1]{@link https://github.com/emn178/js-sha1}\n *\n * @version 0.6.0\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2017\n * @license MIT\n */\n/*jslint bitwise: true */\n(function() {\n 'use strict';\n\n var root = typeof window === 'object' ? window : {};\n var NODE_JS = !root.JS_SHA1_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;\n if (NODE_JS) {\n root = global;\n }\n var COMMON_JS = !root.JS_SHA1_NO_COMMON_JS && typeof module === 'object' && module.exports;\n var AMD = typeof define === 'function' && define.amd;\n var HEX_CHARS = '0123456789abcdef'.split('');\n var EXTRA = [-2147483648, 8388608, 32768, 128];\n var SHIFT = [24, 16, 8, 0];\n var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];\n\n var blocks = [];\n\n var createOutputMethod = function (outputType) {\n return function (message) {\n return new Sha1(true).update(message)[outputType]();\n };\n };\n\n var createMethod = function () {\n var method = createOutputMethod('hex');\n if (NODE_JS) {\n method = nodeWrap(method);\n }\n method.create = function () {\n return new Sha1();\n };\n method.update = function (message) {\n return method.create().update(message);\n };\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createOutputMethod(type);\n }\n return method;\n };\n\n var nodeWrap = function (method) {\n var crypto = eval(\"require('crypto')\");\n var Buffer = eval(\"require('buffer').Buffer\");\n var nodeMethod = function (message) {\n if (typeof message === 'string') {\n return crypto.createHash('sha1').update(message, 'utf8').digest('hex');\n } else if (message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n } else if (message.length === undefined) {\n return method(message);\n }\n return crypto.createHash('sha1').update(new Buffer(message)).digest('hex');\n };\n return nodeMethod;\n };\n\n function Sha1(sharedMemory) {\n if (sharedMemory) {\n blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n this.blocks = blocks;\n } else {\n this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n }\n\n this.h0 = 0x67452301;\n this.h1 = 0xEFCDAB89;\n this.h2 = 0x98BADCFE;\n this.h3 = 0x10325476;\n this.h4 = 0xC3D2E1F0;\n\n this.block = this.start = this.bytes = this.hBytes = 0;\n this.finalized = this.hashed = false;\n this.first = true;\n }\n\n Sha1.prototype.update = function (message) {\n if (this.finalized) {\n return;\n }\n var notString = typeof(message) !== 'string';\n if (notString && message.constructor === root.ArrayBuffer) {\n message = new Uint8Array(message);\n }\n var code, index = 0, i, length = message.length || 0, blocks = this.blocks;\n\n while (index < length) {\n if (this.hashed) {\n this.hashed = false;\n blocks[0] = this.block;\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n\n if(notString) {\n for (i = this.start; index < length && i < 64; ++index) {\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n\n this.lastByteIndex = i;\n this.bytes += i - this.start;\n if (i >= 64) {\n this.block = blocks[16];\n this.start = i - 64;\n this.hash();\n this.hashed = true;\n } else {\n this.start = i;\n }\n }\n if (this.bytes > 4294967295) {\n this.hBytes += this.bytes / 4294967296 << 0;\n this.bytes = this.bytes % 4294967296;\n }\n return this;\n };\n\n Sha1.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks, i = this.lastByteIndex;\n blocks[16] = this.block;\n blocks[i >> 2] |= EXTRA[i & 3];\n this.block = blocks[16];\n if (i >= 56) {\n if (!this.hashed) {\n this.hash();\n }\n blocks[0] = this.block;\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n blocks[14] = this.hBytes << 3 | this.bytes >>> 29;\n blocks[15] = this.bytes << 3;\n this.hash();\n };\n\n Sha1.prototype.hash = function () {\n var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4;\n var f, j, t, blocks = this.blocks;\n\n for(j = 16; j < 80; ++j) {\n t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16];\n blocks[j] = (t << 1) | (t >>> 31);\n }\n\n for(j = 0; j < 20; j += 5) {\n f = (b & c) | ((~b) & d);\n t = (a << 5) | (a >>> 27);\n e = t + f + e + 1518500249 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = (a & b) | ((~a) & c);\n t = (e << 5) | (e >>> 27);\n d = t + f + d + 1518500249 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = (e & a) | ((~e) & b);\n t = (d << 5) | (d >>> 27);\n c = t + f + c + 1518500249 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = (d & e) | ((~d) & a);\n t = (c << 5) | (c >>> 27);\n b = t + f + b + 1518500249 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = (c & d) | ((~c) & e);\n t = (b << 5) | (b >>> 27);\n a = t + f + a + 1518500249 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 40; j += 5) {\n f = b ^ c ^ d;\n t = (a << 5) | (a >>> 27);\n e = t + f + e + 1859775393 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = a ^ b ^ c;\n t = (e << 5) | (e >>> 27);\n d = t + f + d + 1859775393 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = e ^ a ^ b;\n t = (d << 5) | (d >>> 27);\n c = t + f + c + 1859775393 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = d ^ e ^ a;\n t = (c << 5) | (c >>> 27);\n b = t + f + b + 1859775393 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = c ^ d ^ e;\n t = (b << 5) | (b >>> 27);\n a = t + f + a + 1859775393 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 60; j += 5) {\n f = (b & c) | (b & d) | (c & d);\n t = (a << 5) | (a >>> 27);\n e = t + f + e - 1894007588 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = (a & b) | (a & c) | (b & c);\n t = (e << 5) | (e >>> 27);\n d = t + f + d - 1894007588 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = (e & a) | (e & b) | (a & b);\n t = (d << 5) | (d >>> 27);\n c = t + f + c - 1894007588 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = (d & e) | (d & a) | (e & a);\n t = (c << 5) | (c >>> 27);\n b = t + f + b - 1894007588 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = (c & d) | (c & e) | (d & e);\n t = (b << 5) | (b >>> 27);\n a = t + f + a - 1894007588 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 80; j += 5) {\n f = b ^ c ^ d;\n t = (a << 5) | (a >>> 27);\n e = t + f + e - 899497514 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = a ^ b ^ c;\n t = (e << 5) | (e >>> 27);\n d = t + f + d - 899497514 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = e ^ a ^ b;\n t = (d << 5) | (d >>> 27);\n c = t + f + c - 899497514 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = d ^ e ^ a;\n t = (c << 5) | (c >>> 27);\n b = t + f + b - 899497514 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = c ^ d ^ e;\n t = (b << 5) | (b >>> 27);\n a = t + f + a - 899497514 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n this.h0 = this.h0 + a << 0;\n this.h1 = this.h1 + b << 0;\n this.h2 = this.h2 + c << 0;\n this.h3 = this.h3 + d << 0;\n this.h4 = this.h4 + e << 0;\n };\n\n Sha1.prototype.hex = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;\n\n return HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +\n HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +\n HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +\n HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +\n HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +\n HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +\n HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +\n HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +\n HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +\n HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +\n HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +\n HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +\n HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +\n HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +\n HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +\n HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +\n HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +\n HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +\n HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +\n HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F];\n };\n\n Sha1.prototype.toString = Sha1.prototype.hex;\n\n Sha1.prototype.digest = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;\n\n return [\n (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,\n (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,\n (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,\n (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,\n (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF\n ];\n };\n\n Sha1.prototype.array = Sha1.prototype.digest;\n\n Sha1.prototype.arrayBuffer = function () {\n this.finalize();\n\n var buffer = new ArrayBuffer(20);\n var dataView = new DataView(buffer);\n dataView.setUint32(0, this.h0);\n dataView.setUint32(4, this.h1);\n dataView.setUint32(8, this.h2);\n dataView.setUint32(12, this.h3);\n dataView.setUint32(16, this.h4);\n return buffer;\n };\n\n var exports = createMethod();\n\n if (COMMON_JS) {\n module.exports = exports;\n } else {\n root.sha1 = exports;\n if (AMD) {\n define(function () {\n return exports;\n });\n }\n }\n})();\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import * as workerpool from 'workerpool';\nimport * as EquationSolver from './equationSolver';\nimport { EquationPolicy } from './spartitoMeasure';\n\nconst solveStaffGroup = (staffGroup: EquationPolicy.StaffGroup, options: EquationPolicy.RegulatorOptions): EquationPolicy.StaffGroupSolution => {\n\tif (!staffGroup.events.length) {\n\t\treturn {\n\t\t\tevents: [],\n\t\t\tvoices: [],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\treturn solver.solve();\n};\n\n// create a worker and register public functions\nworkerpool.worker({\n\tsolveStaffGroup,\n});\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T12:40:35.385Z`, '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;');\nimport '../../../src/starry/solveStaffGroup.worker';\n"],"names":["requireFoolWebpack","eval","requireFoolWebpack_1","Promise","handler","parent","me","this","SyntaxError","_onSuccess","_onFail","resolved","rejected","pending","_process","onSuccess","onFail","push","then","resolve","reject","s","_then","f","_resolve","result","forEach","fn","_reject","error","cancel","CancellationError","timeout","delay","timer","setTimeout","TimeoutError","always","clearTimeout","callback","res","message","stack","Error","require$$0","isNode","nodeProcess","versions","node","module","exports","platform","process","worker_threads","err","tryRequireFoolWebpack","isMainThread","connected","Window","cpus","self","navigator","hardwareConcurrency","length","Promise$2","prototype","all","promises","remaining","results","p","i","defer","resolver","promise","constructor","name","_Promise","embeddedWorker","environment","require$$1","require$$2","TERMINATE_METHOD_ID","ensureWorkerThreads","WorkerThreads","tryRequireWorkerThreads","ensureWebWorker","Worker","code","getDefaultWorker","Blob","window","URL","createObjectURL","blob","require$$3","type","__dirname","setupWorker","script","options","workerType","setupBrowserWorker","workerOpts","setupWorkerThreadWorker","workerThreadOpts","setupProcessWorker","resolveForkOptions","worker","isBrowserWorker","on","event","addEventListener","data","send","transfer","postMessage","workerThreadOptions","stdout","stderr","isWorkerThread","kill","terminate","disconnect","child_process","fork","forkArgs","forkOpts","call","isChildProcess","opts","processExecArgv","execArgv","join","inspectorActive","indexOf","debugBrk","debugPort","arg","Object","assign","concat","objectToError","obj","temp","props","keys","WorkerHandler","_options","onError","id","terminated","processing","undefined","create","workerTerminateTimeout","ready","requestQueue","response","request","splice","dispatchQueuedRequests","task","isEvent","payload","terminating","exitCode","signalCode","spawnargs","spawnfile","cleaning","terminationHandler","lastId","methods","exec","method","params","catch","terminateAndNotify","busy","force","cleanup","removeAllListeners","killed","cleanExitTimeout","once","WorkerHandlerModule","WorkerHandler$1","_tryRequireWorkerThreads","_setupProcessWorker","_setupBrowserWorker","_setupWorkerThreadWorker","Transfer","exit","parentPort","bind","convertError","getOwnPropertyNames","reduce","product","defineProperty","value","enumerable","isPromise","run","args","Function","apply","cleanupAndExit","_exit","currentRequestId","register","hasOwnProperty","onTerminate","emit","add","Sylvester","Matrix","elements","setElements","I","n","j","els","dup","isSquare","cols","toRightTriangular","M","np","multiplier","determinant","det","isSingular","augment","matrix","T","nj","inverse","divisor","new_element","inverse_elements","matrixInverse","mat","SemanticType","root","NODE_JS","JS_SHA1_NO_NODE_JS","global","COMMON_JS","JS_SHA1_NO_COMMON_JS","HEX_CHARS","split","EXTRA","SHIFT","OUTPUT_TYPES","blocks","createOutputMethod","outputType","Sha1","update","createMethod","nodeWrap","crypto","Buffer","nodeMethod","createHash","digest","ArrayBuffer","Uint8Array","sharedMemory","h0","h1","h2","h3","h4","block","start","bytes","hBytes","finalized","hashed","first","notString","index","charCodeAt","lastByteIndex","hash","finalize","t","a","b","c","d","e","hex","toString","array","arrayBuffer","buffer","dataView","DataView","setUint32","sha1","BarMeasure","vline_BarMeasure","vline_BarTerminal","vline_BarSegment","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","st","NoteheadS0","NoteheadS1","NoteheadS2","Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","ScriptStaccatissimo","TimesigZero","TimesigOne","TimesigTwo","TimesigThree","TimesigFour","TimesigFive","TimesigSix","TimesigSeven","TimesigEight","TimesigNine","Rest0","Rest1","Rest2","Rest3","Rest4","Rest5","Rest6","Rest0W","RestM1","SignInterval","SignLined","BeamLeft","BeamContinue","BeamRight","ClefG","ClefF","ClefC","Dot","AccNatural","AccSharp","AccDoublesharp","AccFlat","AccFlatflat","TimesigC44","TimesigC22","OctaveShift8","OctaveShift0","m","r","z","ScriptFermata","ScriptShortFermata","ScriptSforzato","ScriptStaccato","ScriptTurn","ScriptTrill","ScriptSegno","ScriptCoda","ScriptArpeggio","ScriptPrall","ScriptMordent","ScriptMarcato","ScriptTenuto","ScriptPortato","PedalStar","PedalPed","roundNumber","x","precision","min","Infinity","Math","max","round","gcd","Number","isInteger","console","frac","numerator","denominator","reducedFraction","g","fractionMul","fraction","DummyLogger","debug","_","group","groupCollapsed","groupEnd","info","warn","assert","EOM","GREAT_NUMBER","DURATION_MULTIPLIER","floatToFrac","floatToTimeWarp","ActionType","Action","P","PLACE","e1","V","e2","order","VERTICAL","H","HORIZONTAL","events","filter","isFinite","StageMatrix","fromNode","status","Array","stages","fill","map","Set","actions","action","stage1","findIndex","stage","includes","stage2","stagedEvents","endHs","matrixH","has","endHP","hActions","pendingHeads","eventMap","eid","find","some","pathOf","y","target","ei","size","yy","sub","findDoublePath","s1","s2","paths","path","reducePath","column","set","delete","toEquations","eventCount","equations","path1","path2","equation","PathNode","logger","last","sort","like","ids","constructStages","unshift","newStage","si","constructConstraints","factors","duration","constraints","it","inbalancesConstraints","ones","fixed","inbalances","constraint","sum","solveEquations","xis","items","abs","equationMap","Map","conflicted","lines","line","bias","every","get","squareLines","slice","restLines","candidateLines","i1","i2","prior","sl","c1","c2","invert","solution","row","xi","optimallySolve","shrinkMap","shrinkness","groups","entries","p1","p2","pair","released","releasedIds","warps","lowWarp","isConflicted","eventTendencies","timeWarps","getSolution","actionKey","hacts","a1","a2","hmap","act","startEs","voices","se","voice","values","tick","endTick","tickGroup","timeWarp","estages","solveStages","changed","reverse","measureDuration","outEI","String","fromCodePoint","deduce","quota","access","actionAccessing","times","closed","credits","children","expand","possibility","n1","n2","child","matrixV","branches","appendBranch","branch","ps","Solver","env","event0","confidence","measureShrinkness","expectedDuration","staff","xSpan","endX","solve","pathRoot","bestSolution","evaluateSolution","loss","sevents","es","partialFrac","weight","log","spaceTime","staffAlters","end","eventsXOrder","tickTwists","dx","dt","atan2","PI","tickTwist","solveStaffGroup","staffGroup","EquationSolver.Solver","workerpool.worker"],"mappings":"wDACIA,qBAAqBC,KACrB,0HAKJC,qBAAiBF,qBCGjB,SAASG,UAAQC,EAASC,GACxB,IAAIC,EAAKC,KAET,KAAMA,gBAAgBJ,WACpB,MAAM,IAAIK,YAAY,oDAGxB,GAAuB,mBAAZJ,EACT,MAAM,IAAII,YAAY,uDAGxB,IAAIC,EAAa,GACbC,EAAU,GAGdH,KAAKI,UAAW,EAChBJ,KAAKK,UAAW,EAChBL,KAAKM,SAAU,EASf,IAAIC,EAAW,SAAUC,EAAWC,GAClCP,EAAWQ,KAAKF,GAChBL,EAAQO,KAAKD,EACjB,EAQET,KAAKW,KAAO,SAAUH,EAAWC,GAC/B,OAAO,IAAIb,UAAQ,SAAUgB,EAASC,GACpC,IAAIC,EAAIN,EAAYO,MAAMP,EAAWI,EAASC,GAAUD,EACpDI,EAAIP,EAAYM,MAAMN,EAAWG,EAASC,GAAUA,EAExDN,EAASO,EAAGE,EACb,EAAEjB,EACP,EAOE,IAAIkB,EAAW,SAAUC,GAgBvB,OAdAn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AAI,EAAG/G,EAAQoP,EAAShC,SAAWiH,GAGrD,IAAIf,EAAQ,KACZtC,EAAM3gB,QAAS4H,IACd,MAAMvC,EAAQoV,EAAS7S,GACnBvC,EAAM4d,QAAUA,IACL,OAAVA,KAAkBc,EACtBd,EAAQ5d,EAAM4d,WAKjBlE,EAASyE,MAAqB,GAAZM,EAAkB5L,oBACpC6G,EAASyE,MAAQ,GAAKO,EAAc,EAGpC,MAAME,EAAe,IAAIjL,GAAQsD,KAAK,CAAC7D,EAAIE,IAAOF,EAAGpC,EAAIsC,EAAGtC,GACtD6N,EAAaD,EAAa5F,MAAM,GAAG5E,IAAI,CAACd,EAAI9V,KACjD,MAAM4V,EAAKwL,EAAaphB,GAClBshB,EAAKxL,EAAGtC,EAAIoC,EAAGpC,EACf+N,EAAKzL,EAAGkI,KAAOpI,EAAGoI,KAExB,IAAKuD,EAAI,OAAOD,EAAKtlB,KAAKqkB,MAI1B,OAAgB,EAFHzM,KAAK4N,MAAMD,EAAKrF,EAAShC,SAAUoH,EAAKtlB,KAAKqkB,OAErCzM,KAAK6N,GAAK,IAAM,IAEhCC,EAAY9N,KAAKC,OAAOwN,EAAY,GAC1CnF,EAASyE,MAAQe,GAAa,EAE9BxN,QAAQgB,OAAOgH,EAASyE,MAAQ,EAAG,2BAA4BzE,EAASyE,KAAM3B,EAAOiC,EAAWC,GAC5FhF,EAASyE,KAAO,IAAGzE,EAASyE,KAAOhN,IACvC,ECpgCF,MAAMgO,gBAAkB,CAACC,EAAuC/f,KAC/D,IAAK+f,EAAWzL,OAAO3W,OACtB,MAAO,CACN2W,OAAQ,GACRyH,OAAQ,GACR1D,SAAU,GAMZ,OAFe,IAAI2H,OAAsBD,EAAY/f,GAEvC0e,SAIfuB,OAAkB,CACjBH,kCCpBDzN,QAAQc,KAAK,kDAAmD,8EAA+E"} \ No newline at end of file +{"version":3,"file":"worker.js","sources":["../../../node_modules/workerpool/src/requireFoolWebpack.js","../../../node_modules/workerpool/src/Promise.js","../../../node_modules/workerpool/src/environment.js","../../../node_modules/workerpool/src/generated/embeddedWorker.js","../../../node_modules/workerpool/src/WorkerHandler.js","../../../node_modules/workerpool/src/transfer.js","../../../node_modules/workerpool/src/worker.js","../../../node_modules/workerpool/src/index.js","../../../node_modules/matrix-inverse/matrix-inverse.js","../../../src/starry/semanticPoint.ts","../../../node_modules/js-sha1/src/sha1.js","../../../src/starry/utils.ts","../../../src/starry/logger.ts","../../../src/starry/equationSolver.ts","../../../src/starry/solveStaffGroup.worker.ts","../src/worker.ts"],"sourcesContent":["// source of inspiration: https://github.com/sindresorhus/require-fool-webpack\nvar requireFoolWebpack = eval(\n 'typeof require !== \\'undefined\\' ' +\n '? require ' +\n ': function (module) { throw new Error(\\'Module \" + module + \" not found.\\') }'\n);\n\nmodule.exports = requireFoolWebpack;\n","'use strict';\n\n/**\n * Promise\n *\n * Inspired by https://gist.github.com/RubaXa/8501359 from RubaXa \n *\n * @param {Function} handler Called as handler(resolve: Function, reject: Function)\n * @param {Promise} [parent] Parent promise for propagation of cancel and timeout\n */\nfunction Promise(handler, parent) {\n var me = this;\n\n if (!(this instanceof Promise)) {\n throw new SyntaxError('Constructor must be called with the new operator');\n }\n\n if (typeof handler !== 'function') {\n throw new SyntaxError('Function parameter handler(resolve, reject) missing');\n }\n\n var _onSuccess = [];\n var _onFail = [];\n\n // status\n this.resolved = false;\n this.rejected = false;\n this.pending = true;\n\n /**\n * Process onSuccess and onFail callbacks: add them to the queue.\n * Once the promise is resolve, the function _promise is replace.\n * @param {Function} onSuccess\n * @param {Function} onFail\n * @private\n */\n var _process = function (onSuccess, onFail) {\n _onSuccess.push(onSuccess);\n _onFail.push(onFail);\n };\n\n /**\n * Add an onSuccess callback and optionally an onFail callback to the Promise\n * @param {Function} onSuccess\n * @param {Function} [onFail]\n * @returns {Promise} promise\n */\n this.then = function (onSuccess, onFail) {\n return new Promise(function (resolve, reject) {\n var s = onSuccess ? _then(onSuccess, resolve, reject) : resolve;\n var f = onFail ? _then(onFail, resolve, reject) : reject;\n\n _process(s, f);\n }, me);\n };\n\n /**\n * Resolve the promise\n * @param {*} result\n * @type {Function}\n */\n var _resolve = function (result) {\n // update status\n me.resolved = true;\n me.rejected = false;\n me.pending = false;\n\n _onSuccess.forEach(function (fn) {\n fn(result);\n });\n\n _process = function (onSuccess, onFail) {\n onSuccess(result);\n };\n\n _resolve = _reject = function () { };\n\n return me;\n };\n\n /**\n * Reject the promise\n * @param {Error} error\n * @type {Function}\n */\n var _reject = function (error) {\n // update status\n me.resolved = false;\n me.rejected = true;\n me.pending = false;\n\n _onFail.forEach(function (fn) {\n fn(error);\n });\n\n _process = function (onSuccess, onFail) {\n onFail(error);\n };\n\n _resolve = _reject = function () { }\n\n return me;\n };\n\n /**\n * Cancel te promise. This will reject the promise with a CancellationError\n * @returns {Promise} self\n */\n this.cancel = function () {\n if (parent) {\n parent.cancel();\n }\n else {\n _reject(new CancellationError());\n }\n\n return me;\n };\n\n /**\n * Set a timeout for the promise. If the promise is not resolved within\n * the time, the promise will be cancelled and a TimeoutError is thrown.\n * If the promise is resolved in time, the timeout is removed.\n * @param {number} delay Delay in milliseconds\n * @returns {Promise} self\n */\n this.timeout = function (delay) {\n if (parent) {\n parent.timeout(delay);\n }\n else {\n var timer = setTimeout(function () {\n _reject(new TimeoutError('Promise timed out after ' + delay + ' ms'));\n }, delay);\n\n me.always(function () {\n clearTimeout(timer);\n });\n }\n\n return me;\n };\n\n // attach handler passing the resolve and reject functions\n handler(function (result) {\n _resolve(result);\n }, function (error) {\n _reject(error);\n });\n}\n\n/**\n * Execute given callback, then call resolve/reject based on the returned result\n * @param {Function} callback\n * @param {Function} resolve\n * @param {Function} reject\n * @returns {Function}\n * @private\n */\nfunction _then(callback, resolve, reject) {\n return function (result) {\n try {\n var res = callback(result);\n if (res && typeof res.then === 'function' && typeof res['catch'] === 'function') {\n // method returned a promise\n res.then(resolve, reject);\n }\n else {\n resolve(res);\n }\n }\n catch (error) {\n reject(error);\n }\n }\n}\n\n/**\n * Add an onFail callback to the Promise\n * @param {Function} onFail\n * @returns {Promise} promise\n */\nPromise.prototype['catch'] = function (onFail) {\n return this.then(null, onFail);\n};\n\n// TODO: add support for Promise.catch(Error, callback)\n// TODO: add support for Promise.catch(Error, Error, callback)\n\n/**\n * Execute given callback when the promise either resolves or rejects.\n * @param {Function} fn\n * @returns {Promise} promise\n */\nPromise.prototype.always = function (fn) {\n return this.then(fn, fn);\n};\n\n/**\n * Create a promise which resolves when all provided promises are resolved,\n * and fails when any of the promises resolves.\n * @param {Promise[]} promises\n * @returns {Promise} promise\n */\nPromise.all = function (promises){\n return new Promise(function (resolve, reject) {\n var remaining = promises.length,\n results = [];\n\n if (remaining) {\n promises.forEach(function (p, i) {\n p.then(function (result) {\n results[i] = result;\n remaining--;\n if (remaining == 0) {\n resolve(results);\n }\n }, function (error) {\n remaining = 0;\n reject(error);\n });\n });\n }\n else {\n resolve(results);\n }\n });\n};\n\n/**\n * Create a promise resolver\n * @returns {{promise: Promise, resolve: Function, reject: Function}} resolver\n */\nPromise.defer = function () {\n var resolver = {};\n\n resolver.promise = new Promise(function (resolve, reject) {\n resolver.resolve = resolve;\n resolver.reject = reject;\n });\n\n return resolver;\n};\n\n/**\n * Create a cancellation error\n * @param {String} [message]\n * @extends Error\n */\nfunction CancellationError(message) {\n this.message = message || 'promise cancelled';\n this.stack = (new Error()).stack;\n}\n\nCancellationError.prototype = new Error();\nCancellationError.prototype.constructor = Error;\nCancellationError.prototype.name = 'CancellationError';\n\nPromise.CancellationError = CancellationError;\n\n\n/**\n * Create a timeout error\n * @param {String} [message]\n * @extends Error\n */\nfunction TimeoutError(message) {\n this.message = message || 'timeout exceeded';\n this.stack = (new Error()).stack;\n}\n\nTimeoutError.prototype = new Error();\nTimeoutError.prototype.constructor = Error;\nTimeoutError.prototype.name = 'TimeoutError';\n\nPromise.TimeoutError = TimeoutError;\n\n\nmodule.exports = Promise;\n","var requireFoolWebpack = require('./requireFoolWebpack');\n\n// source: https://github.com/flexdinesh/browser-or-node\nvar isNode = function (nodeProcess) {\n return (\n typeof nodeProcess !== 'undefined' &&\n nodeProcess.versions != null &&\n nodeProcess.versions.node != null\n );\n}\nmodule.exports.isNode = isNode\n\n// determines the JavaScript platform: browser or node\nmodule.exports.platform = typeof process !== 'undefined' && isNode(process)\n ? 'node'\n : 'browser';\n\n// determines whether the code is running in main thread or not\n// note that in node.js we have to check both worker_thread and child_process\nvar worker_threads = tryRequireFoolWebpack('worker_threads');\nmodule.exports.isMainThread = module.exports.platform === 'node'\n ? ((!worker_threads || worker_threads.isMainThread) && !process.connected)\n : typeof Window !== 'undefined';\n\n// determines the number of cpus available\nmodule.exports.cpus = module.exports.platform === 'browser'\n ? self.navigator.hardwareConcurrency\n : requireFoolWebpack('os').cpus().length;\n\nfunction tryRequireFoolWebpack (module) {\n try {\n return requireFoolWebpack(module);\n } catch(err) {\n return null\n }\n}\n","/**\n * embeddedWorker.js contains an embedded version of worker.js.\n * This file is automatically generated,\n * changes made in this file will be overwritten.\n */\nmodule.exports = \"!function(){var __webpack_modules__={577:function(e){e.exports=function(e,r){this.message=e,this.transfer=r}}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];return void 0!==r||(r=__webpack_module_cache__[e]={exports:{}},__webpack_modules__[e](r,r.exports,__webpack_require__)),r.exports}var __webpack_exports__={};!function(){var exports=__webpack_exports__,__webpack_unused_export__;function _typeof(e){return(_typeof=\\\"function\\\"==typeof Symbol&&\\\"symbol\\\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\\\"function\\\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\\\"symbol\\\":typeof e})(e)}var Transfer=__webpack_require__(577),requireFoolWebpack=eval(\\\"typeof require !== 'undefined' ? require : function (module) { throw new Error('Module \\\\\\\" + module + \\\\\\\" not found.') }\\\"),TERMINATE_METHOD_ID=\\\"__workerpool-terminate__\\\",worker={exit:function(){}},WorkerThreads,parentPort;if(\\\"undefined\\\"!=typeof self&&\\\"function\\\"==typeof postMessage&&\\\"function\\\"==typeof addEventListener)worker.on=function(e,r){addEventListener(e,function(e){r(e.data)})},worker.send=function(e){postMessage(e)};else{if(\\\"undefined\\\"==typeof process)throw new Error(\\\"Script must be executed as a worker\\\");try{WorkerThreads=requireFoolWebpack(\\\"worker_threads\\\")}catch(error){if(\\\"object\\\"!==_typeof(error)||null===error||\\\"MODULE_NOT_FOUND\\\"!==error.code)throw error}WorkerThreads&&null!==WorkerThreads.parentPort?(parentPort=WorkerThreads.parentPort,worker.send=parentPort.postMessage.bind(parentPort),worker.on=parentPort.on.bind(parentPort)):(worker.on=process.on.bind(process),worker.send=function(e){process.send(e)},worker.on(\\\"disconnect\\\",function(){process.exit(1)})),worker.exit=process.exit.bind(process)}function convertError(o){return Object.getOwnPropertyNames(o).reduce(function(e,r){return Object.defineProperty(e,r,{value:o[r],enumerable:!0})},{})}function isPromise(e){return e&&\\\"function\\\"==typeof e.then&&\\\"function\\\"==typeof e.catch}worker.methods={},worker.methods.run=function(e,r){e=new Function(\\\"return (\\\"+e+\\\").apply(null, arguments);\\\");return e.apply(e,r)},worker.methods.methods=function(){return Object.keys(worker.methods)},worker.terminationHandler=void 0,worker.cleanupAndExit=function(e){function r(){worker.exit(e)}if(!worker.terminationHandler)return r();var o=worker.terminationHandler(e);isPromise(o)?o.then(r,r):r()};var currentRequestId=null;worker.on(\\\"message\\\",function(r){if(r===TERMINATE_METHOD_ID)return worker.cleanupAndExit(0);try{var e=worker.methods[r.method];if(!e)throw new Error('Unknown method \\\"'+r.method+'\\\"');currentRequestId=r.id;var o=e.apply(e,r.params);isPromise(o)?o.then(function(e){e instanceof Transfer?worker.send({id:r.id,result:e.message,error:null},e.transfer):worker.send({id:r.id,result:e,error:null}),currentRequestId=null}).catch(function(e){worker.send({id:r.id,result:null,error:convertError(e)}),currentRequestId=null}):(o instanceof Transfer?worker.send({id:r.id,result:o.message,error:null},o.transfer):worker.send({id:r.id,result:o,error:null}),currentRequestId=null)}catch(e){worker.send({id:r.id,result:null,error:convertError(e)})}}),worker.register=function(e,r){if(e)for(var o in e)e.hasOwnProperty(o)&&(worker.methods[o]=e[o]);r&&(worker.terminationHandler=r.onTerminate),worker.send(\\\"ready\\\")},worker.emit=function(e){currentRequestId&&(e instanceof Transfer?worker.send({id:currentRequestId,isEvent:!0,payload:e.message},e.transfer):worker.send({id:currentRequestId,isEvent:!0,payload:e}))},__webpack_unused_export__=worker.register,worker.emit}()}();\";\n","'use strict';\n\nvar Promise = require('./Promise');\nvar environment = require('./environment');\nvar requireFoolWebpack = require('./requireFoolWebpack');\n\n/**\n * Special message sent by parent which causes a child process worker to terminate itself.\n * Not a \"message object\"; this string is the entire message.\n */\nvar TERMINATE_METHOD_ID = '__workerpool-terminate__';\n\nfunction ensureWorkerThreads() {\n var WorkerThreads = tryRequireWorkerThreads()\n if (!WorkerThreads) {\n throw new Error('WorkerPool: workerType = \\'thread\\' is not supported, Node >= 11.7.0 required')\n }\n\n return WorkerThreads;\n}\n\n// check whether Worker is supported by the browser\nfunction ensureWebWorker() {\n // Workaround for a bug in PhantomJS (Or QtWebkit): https://github.com/ariya/phantomjs/issues/14534\n if (typeof Worker !== 'function' && (typeof Worker !== 'object' || typeof Worker.prototype.constructor !== 'function')) {\n throw new Error('WorkerPool: Web Workers not supported');\n }\n}\n\nfunction tryRequireWorkerThreads() {\n try {\n return requireFoolWebpack('worker_threads');\n } catch(error) {\n if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {\n // no worker_threads available (old version of node.js)\n return null;\n } else {\n throw error;\n }\n }\n}\n\n// get the default worker script\nfunction getDefaultWorker() {\n if (environment.platform === 'browser') {\n // test whether the browser supports all features that we need\n if (typeof Blob === 'undefined') {\n throw new Error('Blob not supported by the browser');\n }\n if (!window.URL || typeof window.URL.createObjectURL !== 'function') {\n throw new Error('URL.createObjectURL not supported by the browser');\n }\n\n // use embedded worker.js\n var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});\n return window.URL.createObjectURL(blob);\n }\n else {\n // use external worker.js in current directory\n return __dirname + '/worker.js';\n }\n}\n\nfunction setupWorker(script, options) {\n if (options.workerType === 'web') { // browser only\n ensureWebWorker();\n return setupBrowserWorker(script, options.workerOpts, Worker);\n } else if (options.workerType === 'thread') { // node.js only\n WorkerThreads = ensureWorkerThreads();\n return setupWorkerThreadWorker(script, WorkerThreads, options.workerThreadOpts);\n } else if (options.workerType === 'process' || !options.workerType) { // node.js only\n return setupProcessWorker(script, resolveForkOptions(options), requireFoolWebpack('child_process'));\n } else { // options.workerType === 'auto' or undefined\n if (environment.platform === 'browser') {\n ensureWebWorker();\n return setupBrowserWorker(script, options.workerOpts, Worker);\n }\n else { // environment.platform === 'node'\n var WorkerThreads = tryRequireWorkerThreads();\n if (WorkerThreads) {\n return setupWorkerThreadWorker(script, WorkerThreads, options.workerThreadOpts);\n } else {\n return setupProcessWorker(script, resolveForkOptions(options), requireFoolWebpack('child_process'));\n }\n }\n }\n}\n\nfunction setupBrowserWorker(script, workerOpts, Worker) {\n // create the web worker\n var worker = new Worker(script, workerOpts);\n\n worker.isBrowserWorker = true;\n // add node.js API to the web worker\n worker.on = function (event, callback) {\n this.addEventListener(event, function (message) {\n callback(message.data);\n });\n };\n worker.send = function (message, transfer) {\n this.postMessage(message, transfer);\n };\n return worker;\n}\n\nfunction setupWorkerThreadWorker(script, WorkerThreads, workerThreadOptions) {\n var worker = new WorkerThreads.Worker(script, {\n stdout: false, // automatically pipe worker.STDOUT to process.STDOUT\n stderr: false, // automatically pipe worker.STDERR to process.STDERR\n ...workerThreadOptions\n });\n worker.isWorkerThread = true;\n worker.send = function(message, transfer) {\n this.postMessage(message, transfer);\n };\n\n worker.kill = function() {\n this.terminate();\n return true;\n };\n\n worker.disconnect = function() {\n this.terminate();\n };\n\n return worker;\n}\n\nfunction setupProcessWorker(script, options, child_process) {\n // no WorkerThreads, fallback to sub-process based workers\n var worker = child_process.fork(\n script,\n options.forkArgs,\n options.forkOpts\n );\n\n // ignore transfer argument since it is not supported by process\n var send = worker.send;\n worker.send = function (message) {\n return send.call(worker, message);\n };\n\n worker.isChildProcess = true;\n return worker;\n}\n\n// add debug flags to child processes if the node inspector is active\nfunction resolveForkOptions(opts) {\n opts = opts || {};\n\n var processExecArgv = process.execArgv.join(' ');\n var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;\n var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;\n\n var execArgv = [];\n if (inspectorActive) {\n execArgv.push('--inspect=' + opts.debugPort);\n\n if (debugBrk) {\n execArgv.push('--debug-brk');\n }\n }\n\n process.execArgv.forEach(function(arg) {\n if (arg.indexOf('--max-old-space-size') > -1) {\n execArgv.push(arg)\n }\n })\n\n return Object.assign({}, opts, {\n forkArgs: opts.forkArgs,\n forkOpts: Object.assign({}, opts.forkOpts, {\n execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])\n .concat(execArgv)\n })\n });\n}\n\n/**\n * Converts a serialized error to Error\n * @param {Object} obj Error that has been serialized and parsed to object\n * @return {Error} The equivalent Error.\n */\nfunction objectToError (obj) {\n var temp = new Error('')\n var props = Object.keys(obj)\n\n for (var i = 0; i < props.length; i++) {\n temp[props[i]] = obj[props[i]]\n }\n\n return temp\n}\n\n/**\n * A WorkerHandler controls a single worker. This worker can be a child process\n * on node.js or a WebWorker in a browser environment.\n * @param {String} [script] If no script is provided, a default worker with a\n * function run will be created.\n * @param {WorkerPoolOptions} _options See docs\n * @constructor\n */\nfunction WorkerHandler(script, _options) {\n var me = this;\n var options = _options || {};\n\n this.script = script || getDefaultWorker();\n this.worker = setupWorker(this.script, options);\n this.debugPort = options.debugPort;\n this.forkOpts = options.forkOpts;\n this.forkArgs = options.forkArgs;\n this.workerOpts = options.workerOpts;\n this.workerThreadOpts = options.workerThreadOpts\n this.workerTerminateTimeout = options.workerTerminateTimeout;\n\n // The ready message is only sent if the worker.add method is called (And the default script is not used)\n if (!script) {\n this.worker.ready = true;\n }\n\n // queue for requests that are received before the worker is ready\n this.requestQueue = [];\n this.worker.on('message', function (response) {\n if (me.terminated) {\n return;\n }\n if (typeof response === 'string' && response === 'ready') {\n me.worker.ready = true;\n dispatchQueuedRequests();\n } else {\n // find the task from the processing queue, and run the tasks callback\n var id = response.id;\n var task = me.processing[id];\n if (task !== undefined) {\n if (response.isEvent) {\n if (task.options && typeof task.options.on === 'function') {\n task.options.on(response.payload);\n }\n } else {\n // remove the task from the queue\n delete me.processing[id];\n\n // test if we need to terminate\n if (me.terminating === true) {\n // complete worker termination if all tasks are finished\n me.terminate();\n }\n\n // resolve the task's promise\n if (response.error) {\n task.resolver.reject(objectToError(response.error));\n }\n else {\n task.resolver.resolve(response.result);\n }\n }\n }\n }\n });\n\n // reject all running tasks on worker error\n function onError(error) {\n me.terminated = true;\n\n for (var id in me.processing) {\n if (me.processing[id] !== undefined) {\n me.processing[id].resolver.reject(error);\n }\n }\n me.processing = Object.create(null);\n }\n\n // send all queued requests to worker\n function dispatchQueuedRequests()\n {\n for(const request of me.requestQueue.splice(0)) {\n me.worker.send(request.message, request.transfer);\n }\n }\n\n var worker = this.worker;\n // listen for worker messages error and exit\n this.worker.on('error', onError);\n this.worker.on('exit', function (exitCode, signalCode) {\n var message = 'Workerpool Worker terminated Unexpectedly\\n';\n\n message += ' exitCode: `' + exitCode + '`\\n';\n message += ' signalCode: `' + signalCode + '`\\n';\n\n message += ' workerpool.script: `' + me.script + '`\\n';\n message += ' spawnArgs: `' + worker.spawnargs + '`\\n';\n message += ' spawnfile: `' + worker.spawnfile + '`\\n'\n\n message += ' stdout: `' + worker.stdout + '`\\n'\n message += ' stderr: `' + worker.stderr + '`\\n'\n\n onError(new Error(message));\n });\n\n this.processing = Object.create(null); // queue with tasks currently in progress\n\n this.terminating = false;\n this.terminated = false;\n this.cleaning = false;\n this.terminationHandler = null;\n this.lastId = 0;\n}\n\n/**\n * Get a list with methods available on the worker.\n * @return {Promise.} methods\n */\nWorkerHandler.prototype.methods = function () {\n return this.exec('methods');\n};\n\n/**\n * Execute a method with given parameters on the worker\n * @param {String} method\n * @param {Array} [params]\n * @param {{resolve: Function, reject: Function}} [resolver]\n * @param {ExecOptions} [options]\n * @return {Promise.<*, Error>} result\n */\nWorkerHandler.prototype.exec = function(method, params, resolver, options) {\n if (!resolver) {\n resolver = Promise.defer();\n }\n\n // generate a unique id for the task\n var id = ++this.lastId;\n\n // register a new task as being in progress\n this.processing[id] = {\n id: id,\n resolver: resolver,\n options: options\n };\n\n // build a JSON-RPC request\n var request = {\n message: {\n id: id,\n method: method,\n params: params\n },\n transfer: options && options.transfer\n };\n\n if (this.terminated) {\n resolver.reject(new Error('Worker is terminated'));\n } else if (this.worker.ready) {\n // send the request to the worker\n this.worker.send(request.message, request.transfer);\n } else {\n this.requestQueue.push(request);\n }\n\n // on cancellation, force the worker to terminate\n var me = this;\n return resolver.promise.catch(function (error) {\n if (error instanceof Promise.CancellationError || error instanceof Promise.TimeoutError) {\n // remove this task from the queue. It is already rejected (hence this\n // catch event), and else it will be rejected again when terminating\n delete me.processing[id];\n\n // terminate worker\n return me.terminateAndNotify(true)\n .then(function() {\n throw error;\n }, function(err) {\n throw err;\n });\n } else {\n throw error;\n }\n })\n};\n\n/**\n * Test whether the worker is processing any tasks or cleaning up before termination.\n * @return {boolean} Returns true if the worker is busy\n */\nWorkerHandler.prototype.busy = function () {\n return this.cleaning || Object.keys(this.processing).length > 0;\n};\n\n/**\n * Terminate the worker.\n * @param {boolean} [force=false] If false (default), the worker is terminated\n * after finishing all tasks currently in\n * progress. If true, the worker will be\n * terminated immediately.\n * @param {function} [callback=null] If provided, will be called when process terminates.\n */\nWorkerHandler.prototype.terminate = function (force, callback) {\n var me = this;\n if (force) {\n // cancel all tasks in progress\n for (var id in this.processing) {\n if (this.processing[id] !== undefined) {\n this.processing[id].resolver.reject(new Error('Worker terminated'));\n }\n }\n this.processing = Object.create(null);\n }\n\n if (typeof callback === 'function') {\n this.terminationHandler = callback;\n }\n if (!this.busy()) {\n // all tasks are finished. kill the worker\n var cleanup = function(err) {\n me.terminated = true;\n me.cleaning = false;\n if (me.worker != null && me.worker.removeAllListeners) {\n // removeAllListeners is only available for child_process\n me.worker.removeAllListeners('message');\n }\n me.worker = null;\n me.terminating = false;\n if (me.terminationHandler) {\n me.terminationHandler(err, me);\n } else if (err) {\n throw err;\n }\n }\n\n if (this.worker) {\n if (typeof this.worker.kill === 'function') {\n if (this.worker.killed) {\n cleanup(new Error('worker already killed!'));\n return;\n }\n\n // child process and worker threads\n var cleanExitTimeout = setTimeout(function() {\n if (me.worker) {\n me.worker.kill();\n }\n }, this.workerTerminateTimeout);\n\n this.worker.once('exit', function() {\n clearTimeout(cleanExitTimeout);\n if (me.worker) {\n me.worker.killed = true;\n }\n cleanup();\n });\n\n if (this.worker.ready) {\n this.worker.send(TERMINATE_METHOD_ID);\n } else {\n this.requestQueue.push({ message: TERMINATE_METHOD_ID });\n }\n\n // mark that the worker is cleaning up resources\n // to prevent new tasks from being executed\n this.cleaning = true;\n return;\n }\n else if (typeof this.worker.terminate === 'function') {\n this.worker.terminate(); // web worker\n this.worker.killed = true;\n }\n else {\n throw new Error('Failed to terminate worker');\n }\n }\n cleanup();\n }\n else {\n // we can't terminate immediately, there are still tasks being executed\n this.terminating = true;\n }\n};\n\n/**\n * Terminate the worker, returning a Promise that resolves when the termination has been done.\n * @param {boolean} [force=false] If false (default), the worker is terminated\n * after finishing all tasks currently in\n * progress. If true, the worker will be\n * terminated immediately.\n * @param {number} [timeout] If provided and non-zero, worker termination promise will be rejected\n * after timeout if worker process has not been terminated.\n * @return {Promise.}\n */\nWorkerHandler.prototype.terminateAndNotify = function (force, timeout) {\n var resolver = Promise.defer();\n if (timeout) {\n resolver.promise.timeout(timeout);\n }\n this.terminate(force, function(err, worker) {\n if (err) {\n resolver.reject(err);\n } else {\n resolver.resolve(worker);\n }\n });\n return resolver.promise;\n};\n\nmodule.exports = WorkerHandler;\nmodule.exports._tryRequireWorkerThreads = tryRequireWorkerThreads;\nmodule.exports._setupProcessWorker = setupProcessWorker;\nmodule.exports._setupBrowserWorker = setupBrowserWorker;\nmodule.exports._setupWorkerThreadWorker = setupWorkerThreadWorker;\nmodule.exports.ensureWorkerThreads = ensureWorkerThreads;\n","/**\n * The helper class for transferring data from the worker to the main thread.\n *\n * @param {Object} message The object to deliver to the main thread.\n * @param {Object[]} transfer An array of transferable Objects to transfer ownership of.\n */\nfunction Transfer(message, transfer) {\n this.message = message;\n this.transfer = transfer;\n}\n\nmodule.exports = Transfer;\n","/**\n * worker must be started as a child process or a web worker.\n * It listens for RPC messages from the parent process.\n */\nvar Transfer = require('./transfer');\n\n// source of inspiration: https://github.com/sindresorhus/require-fool-webpack\nvar requireFoolWebpack = eval(\n 'typeof require !== \\'undefined\\'' +\n ' ? require' +\n ' : function (module) { throw new Error(\\'Module \" + module + \" not found.\\') }'\n);\n\n/**\n * Special message sent by parent which causes the worker to terminate itself.\n * Not a \"message object\"; this string is the entire message.\n */\nvar TERMINATE_METHOD_ID = '__workerpool-terminate__';\n\n// var nodeOSPlatform = require('./environment').nodeOSPlatform;\n\n// create a worker API for sending and receiving messages which works both on\n// node.js and in the browser\nvar worker = {\n exit: function() {}\n};\nif (typeof self !== 'undefined' && typeof postMessage === 'function' && typeof addEventListener === 'function') {\n // worker in the browser\n worker.on = function (event, callback) {\n addEventListener(event, function (message) {\n callback(message.data);\n })\n };\n worker.send = function (message) {\n postMessage(message);\n };\n}\nelse if (typeof process !== 'undefined') {\n // node.js\n\n var WorkerThreads;\n try {\n WorkerThreads = requireFoolWebpack('worker_threads');\n } catch(error) {\n if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {\n // no worker_threads, fallback to sub-process based workers\n } else {\n throw error;\n }\n }\n\n if (WorkerThreads &&\n /* if there is a parentPort, we are in a WorkerThread */\n WorkerThreads.parentPort !== null) {\n var parentPort = WorkerThreads.parentPort;\n worker.send = parentPort.postMessage.bind(parentPort);\n worker.on = parentPort.on.bind(parentPort);\n worker.exit = process.exit.bind(process);\n } else {\n worker.on = process.on.bind(process);\n // ignore transfer argument since it is not supported by process\n worker.send = function (message) {\n process.send(message);\n };\n // register disconnect handler only for subprocess worker to exit when parent is killed unexpectedly\n worker.on('disconnect', function () {\n process.exit(1);\n });\n worker.exit = process.exit.bind(process);\n }\n}\nelse {\n throw new Error('Script must be executed as a worker');\n}\n\nfunction convertError(error) {\n return Object.getOwnPropertyNames(error).reduce(function(product, name) {\n return Object.defineProperty(product, name, {\n\tvalue: error[name],\n\tenumerable: true\n });\n }, {});\n}\n\n/**\n * Test whether a value is a Promise via duck typing.\n * @param {*} value\n * @returns {boolean} Returns true when given value is an object\n * having functions `then` and `catch`.\n */\nfunction isPromise(value) {\n return value && (typeof value.then === 'function') && (typeof value.catch === 'function');\n}\n\n// functions available externally\nworker.methods = {};\n\n/**\n * Execute a function with provided arguments\n * @param {String} fn Stringified function\n * @param {Array} [args] Function arguments\n * @returns {*}\n */\nworker.methods.run = function run(fn, args) {\n var f = new Function('return (' + fn + ').apply(null, arguments);');\n return f.apply(f, args);\n};\n\n/**\n * Get a list with methods available on this worker\n * @return {String[]} methods\n */\nworker.methods.methods = function methods() {\n return Object.keys(worker.methods);\n};\n\n/**\n * Custom handler for when the worker is terminated.\n */\nworker.terminationHandler = undefined;\n\n/**\n * Cleanup and exit the worker.\n * @param {Number} code \n * @returns \n */\nworker.cleanupAndExit = function(code) {\n var _exit = function() {\n worker.exit(code);\n }\n\n if(!worker.terminationHandler) {\n return _exit();\n }\n\n var result = worker.terminationHandler(code);\n if (isPromise(result)) {\n result.then(_exit, _exit);\n } else {\n _exit();\n }\n}\n\nvar currentRequestId = null;\n\nworker.on('message', function (request) {\n if (request === TERMINATE_METHOD_ID) {\n return worker.cleanupAndExit(0);\n }\n try {\n var method = worker.methods[request.method];\n\n if (method) {\n currentRequestId = request.id;\n \n // execute the function\n var result = method.apply(method, request.params);\n\n if (isPromise(result)) {\n // promise returned, resolve this and then return\n result\n .then(function (result) {\n if (result instanceof Transfer) {\n worker.send({\n id: request.id,\n result: result.message,\n error: null\n }, result.transfer);\n } else {\n worker.send({\n id: request.id,\n result: result,\n error: null\n });\n }\n currentRequestId = null;\n })\n .catch(function (err) {\n worker.send({\n id: request.id,\n result: null,\n error: convertError(err)\n });\n currentRequestId = null;\n });\n }\n else {\n // immediate result\n if (result instanceof Transfer) {\n worker.send({\n id: request.id,\n result: result.message,\n error: null\n }, result.transfer);\n } else {\n worker.send({\n id: request.id,\n result: result,\n error: null\n });\n }\n\n currentRequestId = null;\n }\n }\n else {\n throw new Error('Unknown method \"' + request.method + '\"');\n }\n }\n catch (err) {\n worker.send({\n id: request.id,\n result: null,\n error: convertError(err)\n });\n }\n});\n\n/**\n * Register methods to the worker\n * @param {Object} [methods]\n * @param {WorkerRegisterOptions} [options]\n */\nworker.register = function (methods, options) {\n\n if (methods) {\n for (var name in methods) {\n if (methods.hasOwnProperty(name)) {\n worker.methods[name] = methods[name];\n }\n }\n }\n\n if (options) {\n worker.terminationHandler = options.onTerminate;\n }\n\n worker.send('ready');\n};\n\nworker.emit = function (payload) {\n if (currentRequestId) {\n if (payload instanceof Transfer) {\n worker.send({\n id: currentRequestId,\n isEvent: true,\n payload: payload.message\n }, payload.transfer);\n return;\n }\n\n worker.send({\n id: currentRequestId,\n isEvent: true,\n payload\n });\n }\n};\n\nif (typeof exports !== 'undefined') {\n exports.add = worker.register;\n exports.emit = worker.emit;\n}\n","var environment = require('./environment');\n\n/**\n * Create a new worker pool\n * @param {string} [script]\n * @param {WorkerPoolOptions} [options]\n * @returns {Pool} pool\n */\nexports.pool = function pool(script, options) {\n var Pool = require('./Pool');\n\n return new Pool(script, options);\n};\n\n/**\n * Create a worker and optionally register a set of methods to the worker.\n * @param {Object} [methods]\n * @param {WorkerRegisterOptions} [options]\n */\nexports.worker = function worker(methods, options) {\n var worker = require('./worker');\n worker.add(methods, options);\n};\n\n/**\n * Sends an event to the parent worker pool.\n * @param {any} payload \n */\nexports.workerEmit = function workerEmit(payload) {\n var worker = require('./worker');\n worker.emit(payload);\n};\n\n/**\n * Create a promise.\n * @type {Promise} promise\n */\nexports.Promise = require('./Promise');\n\n/**\n * Create a transfer object.\n * @type {Transfer} transfer\n */\nexports.Transfer = require('./transfer');\n\nexports.platform = environment.platform;\nexports.isMainThread = environment.isMainThread;\nexports.cpus = environment.cpus;","var Sylvester = {}\n\nSylvester.Matrix = function () {}\n\nSylvester.Matrix.create = function (elements) {\n var M = new Sylvester.Matrix()\n return M.setElements(elements)\n}\n\nSylvester.Matrix.I = function (n) {\n var els = [],\n i = n,\n j\n while (i--) {\n j = n\n els[i] = []\n while (j--) {\n els[i][j] = i === j ? 1 : 0\n }\n }\n return Sylvester.Matrix.create(els)\n}\n\nSylvester.Matrix.prototype = {\n dup: function () {\n return Sylvester.Matrix.create(this.elements)\n },\n\n isSquare: function () {\n var cols = this.elements.length === 0 ? 0 : this.elements[0].length\n return this.elements.length === cols\n },\n\n toRightTriangular: function () {\n if (this.elements.length === 0) return Sylvester.Matrix.create([])\n var M = this.dup(),\n els\n var n = this.elements.length,\n i,\n j,\n np = this.elements[0].length,\n p\n for (i = 0; i < n; i++) {\n if (M.elements[i][i] === 0) {\n for (j = i + 1; j < n; j++) {\n if (M.elements[j][i] !== 0) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[i][p] + M.elements[j][p])\n }\n M.elements[i] = els\n break\n }\n }\n }\n if (M.elements[i][i] !== 0) {\n for (j = i + 1; j < n; j++) {\n var multiplier = M.elements[j][i] / M.elements[i][i]\n els = []\n for (p = 0; p < np; p++) {\n // Elements with column numbers up to an including the number of the\n // row that we're subtracting can safely be set straight to zero,\n // since that's the point of this routine and it avoids having to\n // loop over and correct rounding errors later\n els.push(\n p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier\n )\n }\n M.elements[j] = els\n }\n }\n }\n return M\n },\n\n determinant: function () {\n if (this.elements.length === 0) {\n return 1\n }\n if (!this.isSquare()) {\n return null\n }\n var M = this.toRightTriangular()\n var det = M.elements[0][0],\n n = M.elements.length\n for (var i = 1; i < n; i++) {\n det = det * M.elements[i][i]\n }\n return det\n },\n\n isSingular: function () {\n return this.isSquare() && this.determinant() === 0\n },\n\n augment: function (matrix) {\n if (this.elements.length === 0) {\n return this.dup()\n }\n var M = matrix.elements || matrix\n if (typeof M[0][0] === 'undefined') {\n M = Sylvester.Matrix.create(M).elements\n }\n var T = this.dup(),\n cols = T.elements[0].length\n var i = T.elements.length,\n nj = M[0].length,\n j\n if (i !== M.length) {\n return null\n }\n while (i--) {\n j = nj\n while (j--) {\n T.elements[i][cols + j] = M[i][j]\n }\n }\n return T\n },\n\n inverse: function () {\n if (this.elements.length === 0) {\n return null\n }\n if (!this.isSquare() || this.isSingular()) {\n return null\n }\n var n = this.elements.length,\n i = n,\n j\n var M = this.augment(Sylvester.Matrix.I(n)).toRightTriangular()\n var np = M.elements[0].length,\n p,\n els,\n divisor\n var inverse_elements = [],\n new_element\n // Sylvester.Matrix is non-singular so there will be no zeros on the\n // diagonal. Cycle through rows from last to first.\n while (i--) {\n // First, normalise diagonal elements to 1\n els = []\n inverse_elements[i] = []\n divisor = M.elements[i][i]\n for (p = 0; p < np; p++) {\n new_element = M.elements[i][p] / divisor\n els.push(new_element)\n // Shuffle off the current row of the right hand side into the results\n // array as it will not be modified by later runs through this loop\n if (p >= n) {\n inverse_elements[i].push(new_element)\n }\n }\n M.elements[i] = els\n // Then, subtract this row from those above it to give the identity matrix\n // on the left hand side\n j = i\n while (j--) {\n els = []\n for (p = 0; p < np; p++) {\n els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i])\n }\n M.elements[j] = els\n }\n }\n return Sylvester.Matrix.create(inverse_elements)\n },\n\n setElements: function (els) {\n var i,\n j,\n elements = els.elements || els\n if (elements[0] && typeof elements[0][0] !== 'undefined') {\n i = elements.length\n this.elements = []\n while (i--) {\n j = elements[i].length\n this.elements[i] = []\n while (j--) {\n this.elements[i][j] = elements[i][j]\n }\n }\n return this\n }\n var n = elements.length\n this.elements = []\n for (i = 0; i < n; i++) {\n this.elements.push([elements[i]])\n }\n return this\n },\n}\n\nmodule.exports = function (elements) {\n const mat = Sylvester.Matrix.create(elements).inverse()\n if (mat !== null) {\n return mat.elements\n } else {\n return null\n }\n}\n","import sha1 from 'js-sha1';\n\nenum SemanticType {\n\t// clefs\n\tClefG = 'ClefG',\n\tClefF = 'ClefF',\n\tClefC = 'ClefC',\n\n\t// noteheads\n\tNoteheadS0 = 'NoteheadS0',\n\tNoteheadS1 = 'NoteheadS1',\n\tNoteheadS2 = 'NoteheadS2',\n\tNoteheadS1stemU = 'NoteheadS1stemU',\n\tNoteheadS1stemD = 'NoteheadS1stemD',\n\tNoteheadS2stemU = 'NoteheadS2stemU',\n\tNoteheadS2stemD = 'NoteheadS2stemD',\n\n\tvline_Stem = 'vline_Stem',\n\n\t// flags\n\tFlag3 = 'Flag3',\n\n\t// beams\n\tBeamLeft = 'BeamLeft',\n\tBeamContinue = 'BeamContinue',\n\tBeamRight = 'BeamRight',\n\n\t// tremolos\n\tTremoloLeft = 'TremoloLeft',\n\tTremoloRight = 'TremoloRight',\n\tTremoloMiddle = 'TremoloMiddle',\n\n\t// dots (duration)\n\tDot = 'Dot',\n\n\t// rests\n\tRest0 = 'Rest0',\n\tRest1 = 'Rest1',\n\tRest2 = 'Rest2',\n\tRest3 = 'Rest3',\n\tRest4 = 'Rest4',\n\tRest5 = 'Rest5',\n\tRest6 = 'Rest6',\n\tRest0W = 'Rest0W', // capital 'R' in lilypond\n\tRestM1 = 'RestM1',\n\n\t// accidentals\n\tAccNatural = 'AccNatural',\n\tAccSharp = 'AccSharp',\n\tAccDoublesharp = 'AccDoublesharp',\n\tAccFlat = 'AccFlat',\n\tAccFlatflat = 'AccFlatflat',\n\n\t// volta\n\tvline_VoltaLeft = 'vline_VoltaLeft',\n\tvline_VoltaRight = 'vline_VoltaRight',\n\tVoltaLeft = 'VoltaLeft',\n\tVoltaRight = 'VoltaRight',\n\n\tVoltaAlternativeBegin = 'VoltaAlternativeBegin',\n\t//VoltaAlternativeEnd\t= \"VoltaAlternativeEnd\",\n\n\t// vertical bars\n\tBarMeasure = 'BarMeasure',\n\tvline_BarMeasure = 'vline_BarMeasure',\n\tvline_BarTerminal = 'vline_BarTerminal',\n\tvline_BarSegment = 'vline_BarSegment',\n\n\t// slur & tie\n\tSlurBegin = 'SlurBegin',\n\tSlurEnd = 'SlurEnd',\n\n\t// time signature\n\tTimesigC44 = 'TimesigC44',\n\tTimesigC22 = 'TimesigC22',\n\tTimesigZero = 'TimesigZero',\n\tTimesigOne = 'TimesigOne',\n\tTimesigTwo = 'TimesigTwo',\n\tTimesigThree = 'TimesigThree',\n\tTimesigFour = 'TimesigFour',\n\tTimesigFive = 'TimesigFive',\n\tTimesigSix = 'TimesigSix',\n\tTimesigSeven = 'TimesigSeven',\n\tTimesigEight = 'TimesigEight',\n\tTimesigNine = 'TimesigNine',\n\n\t// octave shifts\n\tOctaveShift8va = 'OctaveShift8va',\n\tOctaveShift8vb = 'OctaveShift8vb',\n\tOctaveShift8 = 'OctaveShift8',\n\tOctaveShift0 = 'OctaveShift0',\n\n\t// numbers\n\tZero = 'Zero',\n\tOne = 'One',\n\tTwo = 'Two',\n\tThree = 'Three',\n\tFour = 'Four',\n\tFive = 'Five',\n\tSix = 'Six',\n\tSeven = 'Seven',\n\tEight = 'Eight',\n\tNine = 'Nine',\n\n\t// dynamics\n\tf = 'f',\n\tp = 'p',\n\tm = 'm',\n\tn = 'n',\n\tr = 'r',\n\ts = 's',\n\tz = 'z',\n\n\tCrescendoBegin = 'CrescendoBegin',\n\tCrescendoEnd = 'CrescendoEnd',\n\tDecrescendoBegin = 'DecrescendoBegin',\n\tDecrescendoEnd = 'DecrescendoEnd',\n\n\t// scripts\n\tScriptFermata = 'ScriptFermata',\n\tScriptShortFermata = 'ScriptShortFermata',\n\tScriptSforzato = 'ScriptSforzato',\n\tScriptStaccato = 'ScriptStaccato',\n\tScriptStaccatissimo = 'ScriptStaccatissimo',\n\tScriptTurn = 'ScriptTurn',\n\tScriptTrill = 'ScriptTrill',\n\tScriptSegno = 'ScriptSegno',\n\tScriptCoda = 'ScriptCoda',\n\tScriptArpeggio = 'ScriptArpeggio',\n\tScriptPrall = 'ScriptPrall',\n\tScriptMordent = 'ScriptMordent',\n\tScriptMarcato = 'ScriptMarcato',\n\tScriptTenuto = 'ScriptTenuto',\n\tScriptPortato = 'ScriptPortato',\n\n\t// pedal\n\tPedalStar = 'PedalStar',\n\tPedalPed = 'PedalPed',\n\n\t// additional annotation\n\tKeyAcc = 'KeyAcc',\n\tTempoNotehead = 'TempoNotehead',\n\tGraceNotehead = 'GraceNotehead',\n\tSignLined = 'SignLined',\n\tSignInterval = 'SignInterval',\n\n\trect_Text = 'rect_Text',\n\trect_Lyric = 'rect_Lyric',\n}\n\nconst glyphSemanticMapping: { [key: string]: string } = {\n\t'rests.1': 'Rest1',\n\t'rests.0o': 'Rest0',\n\t'rests.1o': 'Rest1',\n\t'rests.M1': 'RestM1',\n\t'rests.2': 'Rest2',\n\t'rests.3': 'Rest3',\n\t'rests.4': 'Rest4',\n\t'rests.5': 'Rest5',\n\t'rests.6': 'Rest6',\n\t'accidentals.sharp': 'AccSharp',\n\t'accidentals.doublesharp': 'AccDoublesharp',\n\t'accidentals.natural': 'AccNatural',\n\t'accidentals.flat': 'AccFlat',\n\t'accidentals.flatflat': 'AccFlatflat',\n\t'dots.dot': 'Dot',\n\t'scripts.ufermata': 'ScriptFermata',\n\t'scripts.dfermata': 'ScriptFermata',\n\t'scripts.ushortfermata': 'ScriptShortFermata',\n\t'scripts.dshortfermata': 'ScriptShortFermata',\n\t'scripts.staccato': 'ScriptStaccato',\n\t'scripts.ustaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.dstaccatissimo': 'ScriptStaccatissimo',\n\t'scripts.turn': 'ScriptTurn',\n\t'scripts.trill': 'ScriptTrill',\n\t'scripts.segno': 'ScriptSegno',\n\t'scripts.coda': 'ScriptCoda',\n\t'scripts.arpeggio': 'ScriptArpeggio',\n\t'scripts.prall': 'ScriptPrall',\n\t'scripts.mordent': 'ScriptMordent',\n\t'scripts.umarcato': 'ScriptMarcato',\n\t'scripts.dmarcato': 'ScriptMarcato',\n\t'scripts.uportato': 'ScriptPortato',\n\t'scripts.dportato': 'ScriptPortato',\n\t'scripts.tenuto': 'ScriptTenuto',\n\t'scripts.sforzato': 'ScriptSforzato',\n\t'clefs.C': 'ClefC',\n\t'clefs.F': 'ClefF',\n\t'clefs.G': 'ClefG',\n\t'clefs.F_change': 'ClefF',\n\t'clefs.G_change': 'ClefG',\n\t'timesig.C44': 'TimesigC44',\n\t'timesig.C22': 'TimesigC22',\n\t'pedal.*': 'PedalStar',\n\t'pedal.Ped': 'PedalPed',\n\t'noteheads.s0': 'NoteheadS0',\n\t'noteheads.s1': 'NoteheadS1',\n\t'noteheads.s2': 'NoteheadS2',\n\tf: 'f',\n\tm: 'm',\n\tp: 'p',\n\tr: 'r',\n\ts: 's',\n\tz: 'z',\n};\n\nconst semanticPriorities: { [key: string]: number } = {\n\tClefG: 0,\n\tClefF: 0,\n\tTimesigFour: 0,\n\tTimesigThree: 0,\n\tTimesigTwo: 0,\n\tNoteheadS0: 0,\n\tNoteheadS1: 0,\n\tNoteheadS2: 0,\n\tDot: 0,\n\tvline_BarMeasure: 0,\n\tvline_Stem: 0,\n\tFlag3: 0,\n\n\tTimesigC44: 1,\n\tTimesigC22: 1,\n\tTimesigEight: 1,\n\tTimesigSix: 1,\n\tAccNatural: 1,\n\tAccSharp: 1,\n\tAccFlat: 1,\n\tKeyAcc: 1,\n\tRest0: 1,\n\tRest1: 1,\n\tRest2: 1,\n\tRest3: 1,\n\tRest4: 1,\n\tOctaveShift8: 1,\n\tOctaveShift0: 1,\n\n\tAccDoublesharp: 2,\n\tAccFlatflat: 2,\n\tTimesigOne: 2,\n\tTimesigNine: 2,\n\tRest5: 2,\n\tRest6: 2,\n\tSlurBegin: 2,\n\tSlurEnd: 2,\n\tVoltaLeft: 2,\n\tVoltaRight: 2,\n\t//VoltaAlternativeBegin: 2,\n\tvline_BarTerminal: 2,\n\tvline_BarSegment: 2,\n\tTempoNotehead: 2,\n\tGraceNotehead: 2,\n\tSignLined: 2,\n\tSignInterval: 2,\n\tBeamLeft: 2,\n\tBeamRight: 2,\n\tBeamContinue: 2,\n\tTremoloLeft: 2,\n\tTremoloRight: 2,\n\tTremoloMiddle: 2,\n\tStemTip: 2,\n\tStemHead: 2,\n\n\t//Rest0W: 3,\n\tf: 3,\n\tp: 3,\n\tm: 3,\n\tScriptFermata: 3,\n\tScriptSforzato: 3,\n\tScriptStaccato: 3,\n\tScriptStaccatissimo: 3,\n\tScriptTurn: 3,\n\tScriptTrill: 3,\n\tScriptSegno: 3,\n\tScriptCoda: 3,\n\tScriptArpeggio: 3,\n\tScriptPrall: 3,\n\tScriptMordent: 3,\n\tScriptTenuto: 3,\n\tPedalStar: 3,\n\tPedalPed: 3,\n\tTimesigFive: 3,\n\tTimesigSeven: 3,\n\tTimesigZero: 3,\n\tOne: 3,\n\tTwo: 3,\n\tThree: 3,\n\tFour: 3,\n\tFive: 3,\n\trect_Text: 3,\n\trect_Lyric: 3,\n\tCrescendoBegin: 3,\n\tCrescendoEnd: 3,\n\tDecrescendoBegin: 3,\n\tDecrescendoEnd: 3,\n\n\tRestM1: 4,\n\tClefC: 4,\n\tScriptShortFermata: 4,\n\tScriptMarcato: 4,\n\tScriptPortato: 4,\n\ts: 4,\n\tr: 4,\n\tz: 4,\n\tZero: 4,\n\tSix: 4,\n\tSeven: 4,\n\tEight: 4,\n\tNine: 4,\n};\n\ninterface Position {\n\tx?: number;\n\ty?: number;\n}\n\nconst NOTEHEAD_WIDTHS = {\n\tNoteheadS0: 0.913 * 2,\n\tNoteheadS1: 0.632 * 2,\n\tNoteheadS2: 0.599 * 2,\n};\n\nconst glyphCenters: { [key: string]: Position } = {\n\t//\"clefs.C\": { x: 1.3 },\n\t'clefs.F': { x: 1.06 },\n\t'clefs.G': { x: 1.3 },\n\t'clefs.F_change': { x: 0.87 },\n\t'clefs.G_change': { x: 1.07 },\n\t'timesig.C44': { x: 0.9 },\n\t'timesig.C22': { x: 0.9 },\n\tzero: { x: 0.7, y: -1 },\n\tone: { x: 0.7, y: -1 },\n\ttwo: { x: 0.7, y: -1 },\n\tthree: { x: 0.7, y: -1 },\n\tfour: { x: 0.7, y: -1 },\n\tfive: { x: 0.7, y: -1 },\n\tsix: { x: 0.7, y: -1 },\n\tseven: { x: 0.7, y: -1 },\n\teight: { x: 0.7, y: -1 },\n\tnine: { x: 0.7, y: -1 },\n\t'accidentals.sharp': { x: 0.55 },\n\t'accidentals.doublesharp': { x: 0.5 },\n\t'accidentals.natural': { x: 0.3 },\n\t'accidentals.flat': { x: 0.3 },\n\t'accidentals.flatflat': { x: 0.5 },\n\t'noteheads.s0': { x: NOTEHEAD_WIDTHS.NoteheadS0 / 2 },\n\t'noteheads.s1': { x: NOTEHEAD_WIDTHS.NoteheadS1 / 2 },\n\t'noteheads.s2': { x: NOTEHEAD_WIDTHS.NoteheadS2 / 2 },\n\t'rests.0': { x: 0.75, y: 1 },\n\t'rests.1': { x: 0.75 },\n\t'rests.0o': { x: 0.75, y: 1 },\n\t'rests.1o': { x: 0.75 },\n\t'rests.M1': { x: 0.75, y: 1 },\n\t'rests.2': { x: 0.5 },\n\t'rests.3': { x: 0.5 },\n\t'rests.4': { x: 0.5 },\n\t'rests.5': { x: 0.5 },\n\t'rests.6': { x: 0.5 },\n\tf: { x: 0.6, y: -0.5 },\n\tm: { x: 0.9, y: -0.5 },\n\tp: { x: 0.5, y: -0.5 },\n\tr: { x: 0.5, y: -0.5 },\n\ts: { x: 0.5, y: -0.5 },\n\tz: { x: 0.5, y: -0.5 },\n\t'scripts.trill': { y: -0.5 },\n\t'scripts.segno': { x: 0, y: 0 },\n\t'scripts.coda': { x: 0, y: 0 },\n\t'scripts.arpeggio': { x: 0.5, y: -0.5 },\n\t'pedal.*': { x: 0.78, y: -0.78 },\n\t'pedal.Ped': { x: 1.6, y: -0.7 },\n};\n\ninterface Point {\n\t// in staff unit coordinates\n\tx: number;\n\ty: number;\n\n\tpivotX?: number;\n\n\t// for prediction\n\tconfidence?: number;\n\n\t// sheet token index in page\n\tindex?: number;\n\ttag?: string;\n\n\textension?: {\n\t\ty1?: number;\n\t\ty2?: number;\n\n\t\thref?: string;\n\t\twidth?: number;\n\t\theight?: number;\n\n\t\ttext?: string;\n\t\ttheta?: number;\n\t\ttype?: string;\n\t\ttextFeature?: Record;\n\t};\n}\n\ninterface SemanticPoint extends Point {\n\tid?: string;\n\tsemantic: SemanticType;\n}\n\nconst ONE_D_SEMANTICS = [\n\t'OctaveShift8va',\n\t'OctaveShift8vb',\n\t'OctaveShift8',\n\t'OctaveShift0',\n\t'vline_VoltaLeft',\n\t'vline_VoltaRight',\n\t'VoltaAlternativeBegin',\n\t'vline_BarMeasure',\n\t'vline_BarTerminal',\n\t'vline_BarSegment',\n];\n\nconst SYSTEM_SEMANTIC_TYPES = [\n\tSemanticType.BarMeasure,\n\tSemanticType.vline_BarMeasure,\n\tSemanticType.vline_BarTerminal,\n\tSemanticType.vline_BarSegment,\n\tSemanticType.vline_VoltaLeft,\n\tSemanticType.vline_VoltaRight,\n\tSemanticType.VoltaAlternativeBegin,\n];\n\nconst st = SemanticType;\nconst CONFLICTION_GROUPS = [\n\t[st.NoteheadS0, st.NoteheadS1, st.NoteheadS2],\n\t[st.Zero, st.One, st.Two, st.Three, st.Four, st.Five, st.Six, st.Seven, st.Eight, st.Nine, st.ScriptStaccatissimo],\n\t[\n\t\tst.TimesigZero,\n\t\tst.TimesigOne,\n\t\tst.TimesigTwo,\n\t\tst.TimesigThree,\n\t\tst.TimesigFour,\n\t\tst.TimesigFive,\n\t\tst.TimesigSix,\n\t\tst.TimesigSeven,\n\t\tst.TimesigEight,\n\t\tst.TimesigNine,\n\t],\n\t[st.Rest0, st.Rest1, st.Rest2, st.Rest3, st.Rest4, st.Rest5, st.Rest6, st.Rest0W, st.RestM1],\n\t[st.SignInterval, st.SignLined],\n\t[st.BeamLeft, st.BeamContinue, st.BeamRight],\n];\n\nconst STAMP_SEMANTICS = [\n\tst.ClefG,\n\tst.ClefF,\n\tst.ClefC,\n\tst.NoteheadS0,\n\tst.NoteheadS1,\n\tst.NoteheadS2,\n\tst.Dot,\n\tst.Rest0,\n\tst.Rest1,\n\tst.Rest2,\n\tst.Rest3,\n\tst.Rest4,\n\tst.Rest5,\n\tst.Rest6,\n\tst.RestM1,\n\tst.AccNatural,\n\tst.AccSharp,\n\tst.AccDoublesharp,\n\tst.AccFlat,\n\tst.AccFlatflat,\n\tst.TimesigC44,\n\tst.TimesigC22,\n\tst.TimesigZero,\n\tst.TimesigOne,\n\tst.TimesigTwo,\n\tst.TimesigThree,\n\tst.TimesigFour,\n\tst.TimesigFive,\n\tst.TimesigSix,\n\tst.TimesigSeven,\n\tst.TimesigEight,\n\tst.TimesigNine,\n\tst.One,\n\tst.Two,\n\tst.Three,\n\tst.Four,\n\tst.Five,\n\tst.OctaveShift8,\n\t//st.OctaveShift15,\n\tst.OctaveShift0,\n\tst.f,\n\tst.p,\n\tst.m,\n\tst.n,\n\tst.r,\n\tst.s,\n\tst.z,\n\tst.ScriptFermata,\n\tst.ScriptShortFermata,\n\tst.ScriptSforzato,\n\tst.ScriptStaccato,\n\tst.ScriptStaccatissimo,\n\tst.ScriptTurn,\n\tst.ScriptTrill,\n\tst.ScriptSegno,\n\tst.ScriptCoda,\n\tst.ScriptArpeggio,\n\tst.ScriptPrall,\n\tst.ScriptMordent,\n\tst.ScriptMarcato,\n\tst.ScriptTenuto,\n\tst.ScriptPortato,\n\tst.PedalStar,\n\tst.PedalPed,\n];\n\n// [cx, cy, width, height]\nconst STAMP_RECTS = {\n\tClefG: [-0.0625, -1.125, 3.6, 8.6],\n\tClefF: [0.25, 0.5625, 3.6, 3.8],\n\tClefC: [0.25, 0, 3.25, 4.5],\n\tNoteheadS0: [0.0625, 0, 2.55, 1.4],\n\tNoteheadS1: [0.0625, 0, 1.8, 1.4],\n\tNoteheadS2: [0.0625, -0.0625, 1.65, 1.35],\n\tDot: [0.25, 0, 0.6, 0.6],\n\tRest0: [0, -0.75, 3.25, 0.9],\n\tRest1: [0, -0.25, 3.25, 0.9],\n\tRest2: [-0.0625, -0.1875, 1.6, 3.375],\n\tRest3: [0, 0.0625, 1.2, 2.25],\n\tRest4: [0.0625, 0.5625, 1.65, 3.375],\n\tRest5: [0.0625, 0.0625, 1.95, 4.375],\n\tRest6: [0.0625, 0.5625, 1.95, 5.375],\n\tRestM1: [-0.4375, -1.5, 0.75, 1.2],\n\tAccNatural: [0, 0, 0.9, 3.5],\n\tAccSharp: [0, 0, 1.5, 3.5],\n\tAccDoublesharp: [0, 0, 1.5, 1.5],\n\tAccFlat: [0, -0.5625, 1.2, 3.125],\n\tAccFlatflat: [0.1875, -0.5625, 1.95, 3.125],\n\tTimesigC44: [-0.0625, 0, 2.25, 2.3],\n\tTimesigC22: [-0.0625, 0, 2.25, 3.2],\n\tTimesigZero: [0, 0, 1.8, 2.2],\n\tTimesigOne: [-0.125, 0, 1.5, 2.2],\n\tTimesigTwo: [0, 0, 2.2, 2.2],\n\tTimesigThree: [-0.0625, 0, 1.9, 2.4],\n\tTimesigFour: [0.0625, 0, 1.95, 2.2],\n\tTimesigFive: [0, 0, 1.8, 2.3],\n\tTimesigSix: [0, 0, 2.0, 2.4],\n\tTimesigSeven: [0, 0, 1.8, 2.2],\n\tTimesigEight: [0, 0, 1.9, 2.2],\n\tTimesigNine: [0, 0, 1.9, 2.2],\n\tOne: [-0.0625, 0, 0.75, 1.6],\n\tTwo: [0, 0, 1.2, 1.6],\n\tThree: [0, 0, 1.2, 1.6],\n\tFour: [0, 0, 1.2, 1.6],\n\tFive: [0, 0, 1.2, 1.6],\n\tOctaveShift8: [2.125, -0.1875, 4.75, 3.6],\n\tOctaveShift0: [-0.4, 0, 1.8, 4.2],\n\tf: [0.0625, -0.125, 2.55, 3],\n\tp: [-0.0625, 0.25, 2.55, 2.1],\n\tm: [-0.125, -0.0625, 2.4, 1.35],\n\tn: [-0.3125, -0.0625, 1.95, 1.35],\n\tr: [0, -0.125, 1.5, 1.5],\n\ts: [0, -0.0625, 1.2, 1.35],\n\tz: [0.0625, 0, 1.35, 1.5],\n\tScriptFermata: [0, 0, 3.25, 3.9],\n\tScriptShortFermata: [0, 0, 2.4, 4.95],\n\tScriptSforzato: [-0.0625, 0, 2.5, 1.2],\n\tScriptStaccato: [0, -0.0625, 0.6, 0.45],\n\tScriptStaccatissimo: [0, 0, 1.2, 2.6],\n\tScriptTurn: [0, 0, 2.7, 1.5],\n\tScriptTrill: [-0.125, -0.5, 3, 2.7],\n\tScriptSegno: [0, 0, 2.4, 3.5],\n\tScriptCoda: [0, 0, 2.7, 3.25],\n\tScriptArpeggio: [-0.0625, 0, 1.05, 1.8],\n\tScriptPrall: [0, 0, 2.4, 1.2],\n\tScriptMordent: [0, 0, 2.4, 1.5],\n\tScriptMarcato: [0, 0, 1.2, 2.475],\n\tScriptTenuto: [0, -0.0625, 1.5, 0.15],\n\tScriptPortato: [0, 0, 1.5, 1.65],\n\tPedalStar: [0, 0, 3.2, 3.2],\n\tPedalPed: [0, -0.25, 4.7, 2.4],\n};\n\nconst hashSemanticPoint = (systemIndex: number, staffIndex: number, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x * 10);\n\tconst y = Math.round(point.y * 10);\n\tconst source = `${systemIndex}|${staffIndex}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nconst hashPageSemanticPoint = (pageName: string, point: SemanticPoint): string => {\n\tconst x = Math.round(point.x);\n\tconst y = Math.round(point.y);\n\tconst source = `p-${pageName}|${point.semantic}|${x}|${y}`;\n\tconst hash = (sha1 as any).array(source).slice(12); // clip to 12 bytes\n\tconst id = (globalThis as any).btoa(String.fromCharCode(...hash)).substring(0, 11);\n\tpoint.id = id;\n\n\treturn id;\n};\n\nexport {\n\tSemanticType,\n\tglyphSemanticMapping,\n\tsemanticPriorities,\n\tPoint,\n\tSemanticPoint,\n\tNOTEHEAD_WIDTHS,\n\tglyphCenters,\n\tONE_D_SEMANTICS,\n\tSYSTEM_SEMANTIC_TYPES,\n\tCONFLICTION_GROUPS,\n\tSTAMP_SEMANTICS,\n\tSTAMP_RECTS,\n\thashSemanticPoint,\n\thashPageSemanticPoint,\n};\n","/*\n * [js-sha1]{@link https://github.com/emn178/js-sha1}\n *\n * @version 0.6.0\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2017\n * @license MIT\n */\n/*jslint bitwise: true */\n(function() {\n 'use strict';\n\n var root = typeof window === 'object' ? window : {};\n var NODE_JS = !root.JS_SHA1_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;\n if (NODE_JS) {\n root = global;\n }\n var COMMON_JS = !root.JS_SHA1_NO_COMMON_JS && typeof module === 'object' && module.exports;\n var AMD = typeof define === 'function' && define.amd;\n var HEX_CHARS = '0123456789abcdef'.split('');\n var EXTRA = [-2147483648, 8388608, 32768, 128];\n var SHIFT = [24, 16, 8, 0];\n var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];\n\n var blocks = [];\n\n var createOutputMethod = function (outputType) {\n return function (message) {\n return new Sha1(true).update(message)[outputType]();\n };\n };\n\n var createMethod = function () {\n var method = createOutputMethod('hex');\n if (NODE_JS) {\n method = nodeWrap(method);\n }\n method.create = function () {\n return new Sha1();\n };\n method.update = function (message) {\n return method.create().update(message);\n };\n for (var i = 0; i < OUTPUT_TYPES.length; ++i) {\n var type = OUTPUT_TYPES[i];\n method[type] = createOutputMethod(type);\n }\n return method;\n };\n\n var nodeWrap = function (method) {\n var crypto = eval(\"require('crypto')\");\n var Buffer = eval(\"require('buffer').Buffer\");\n var nodeMethod = function (message) {\n if (typeof message === 'string') {\n return crypto.createHash('sha1').update(message, 'utf8').digest('hex');\n } else if (message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n } else if (message.length === undefined) {\n return method(message);\n }\n return crypto.createHash('sha1').update(new Buffer(message)).digest('hex');\n };\n return nodeMethod;\n };\n\n function Sha1(sharedMemory) {\n if (sharedMemory) {\n blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n this.blocks = blocks;\n } else {\n this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n }\n\n this.h0 = 0x67452301;\n this.h1 = 0xEFCDAB89;\n this.h2 = 0x98BADCFE;\n this.h3 = 0x10325476;\n this.h4 = 0xC3D2E1F0;\n\n this.block = this.start = this.bytes = this.hBytes = 0;\n this.finalized = this.hashed = false;\n this.first = true;\n }\n\n Sha1.prototype.update = function (message) {\n if (this.finalized) {\n return;\n }\n var notString = typeof(message) !== 'string';\n if (notString && message.constructor === root.ArrayBuffer) {\n message = new Uint8Array(message);\n }\n var code, index = 0, i, length = message.length || 0, blocks = this.blocks;\n\n while (index < length) {\n if (this.hashed) {\n this.hashed = false;\n blocks[0] = this.block;\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n\n if(notString) {\n for (i = this.start; index < length && i < 64; ++index) {\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n\n this.lastByteIndex = i;\n this.bytes += i - this.start;\n if (i >= 64) {\n this.block = blocks[16];\n this.start = i - 64;\n this.hash();\n this.hashed = true;\n } else {\n this.start = i;\n }\n }\n if (this.bytes > 4294967295) {\n this.hBytes += this.bytes / 4294967296 << 0;\n this.bytes = this.bytes % 4294967296;\n }\n return this;\n };\n\n Sha1.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks, i = this.lastByteIndex;\n blocks[16] = this.block;\n blocks[i >> 2] |= EXTRA[i & 3];\n this.block = blocks[16];\n if (i >= 56) {\n if (!this.hashed) {\n this.hash();\n }\n blocks[0] = this.block;\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;\n }\n blocks[14] = this.hBytes << 3 | this.bytes >>> 29;\n blocks[15] = this.bytes << 3;\n this.hash();\n };\n\n Sha1.prototype.hash = function () {\n var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4;\n var f, j, t, blocks = this.blocks;\n\n for(j = 16; j < 80; ++j) {\n t = blocks[j - 3] ^ blocks[j - 8] ^ blocks[j - 14] ^ blocks[j - 16];\n blocks[j] = (t << 1) | (t >>> 31);\n }\n\n for(j = 0; j < 20; j += 5) {\n f = (b & c) | ((~b) & d);\n t = (a << 5) | (a >>> 27);\n e = t + f + e + 1518500249 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = (a & b) | ((~a) & c);\n t = (e << 5) | (e >>> 27);\n d = t + f + d + 1518500249 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = (e & a) | ((~e) & b);\n t = (d << 5) | (d >>> 27);\n c = t + f + c + 1518500249 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = (d & e) | ((~d) & a);\n t = (c << 5) | (c >>> 27);\n b = t + f + b + 1518500249 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = (c & d) | ((~c) & e);\n t = (b << 5) | (b >>> 27);\n a = t + f + a + 1518500249 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 40; j += 5) {\n f = b ^ c ^ d;\n t = (a << 5) | (a >>> 27);\n e = t + f + e + 1859775393 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = a ^ b ^ c;\n t = (e << 5) | (e >>> 27);\n d = t + f + d + 1859775393 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = e ^ a ^ b;\n t = (d << 5) | (d >>> 27);\n c = t + f + c + 1859775393 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = d ^ e ^ a;\n t = (c << 5) | (c >>> 27);\n b = t + f + b + 1859775393 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = c ^ d ^ e;\n t = (b << 5) | (b >>> 27);\n a = t + f + a + 1859775393 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 60; j += 5) {\n f = (b & c) | (b & d) | (c & d);\n t = (a << 5) | (a >>> 27);\n e = t + f + e - 1894007588 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = (a & b) | (a & c) | (b & c);\n t = (e << 5) | (e >>> 27);\n d = t + f + d - 1894007588 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = (e & a) | (e & b) | (a & b);\n t = (d << 5) | (d >>> 27);\n c = t + f + c - 1894007588 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = (d & e) | (d & a) | (e & a);\n t = (c << 5) | (c >>> 27);\n b = t + f + b - 1894007588 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = (c & d) | (c & e) | (d & e);\n t = (b << 5) | (b >>> 27);\n a = t + f + a - 1894007588 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n for(; j < 80; j += 5) {\n f = b ^ c ^ d;\n t = (a << 5) | (a >>> 27);\n e = t + f + e - 899497514 + blocks[j] << 0;\n b = (b << 30) | (b >>> 2);\n\n f = a ^ b ^ c;\n t = (e << 5) | (e >>> 27);\n d = t + f + d - 899497514 + blocks[j + 1] << 0;\n a = (a << 30) | (a >>> 2);\n\n f = e ^ a ^ b;\n t = (d << 5) | (d >>> 27);\n c = t + f + c - 899497514 + blocks[j + 2] << 0;\n e = (e << 30) | (e >>> 2);\n\n f = d ^ e ^ a;\n t = (c << 5) | (c >>> 27);\n b = t + f + b - 899497514 + blocks[j + 3] << 0;\n d = (d << 30) | (d >>> 2);\n\n f = c ^ d ^ e;\n t = (b << 5) | (b >>> 27);\n a = t + f + a - 899497514 + blocks[j + 4] << 0;\n c = (c << 30) | (c >>> 2);\n }\n\n this.h0 = this.h0 + a << 0;\n this.h1 = this.h1 + b << 0;\n this.h2 = this.h2 + c << 0;\n this.h3 = this.h3 + d << 0;\n this.h4 = this.h4 + e << 0;\n };\n\n Sha1.prototype.hex = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;\n\n return HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +\n HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +\n HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +\n HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +\n HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +\n HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +\n HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +\n HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +\n HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +\n HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +\n HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +\n HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +\n HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +\n HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +\n HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +\n HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +\n HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +\n HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +\n HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +\n HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F];\n };\n\n Sha1.prototype.toString = Sha1.prototype.hex;\n\n Sha1.prototype.digest = function () {\n this.finalize();\n\n var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4;\n\n return [\n (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,\n (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,\n (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,\n (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,\n (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF\n ];\n };\n\n Sha1.prototype.array = Sha1.prototype.digest;\n\n Sha1.prototype.arrayBuffer = function () {\n this.finalize();\n\n var buffer = new ArrayBuffer(20);\n var dataView = new DataView(buffer);\n dataView.setUint32(0, this.h0);\n dataView.setUint32(4, this.h1);\n dataView.setUint32(8, this.h2);\n dataView.setUint32(12, this.h3);\n dataView.setUint32(16, this.h4);\n return buffer;\n };\n\n var exports = createMethod();\n\n if (COMMON_JS) {\n module.exports = exports;\n } else {\n root.sha1 = exports;\n if (AMD) {\n define(function () {\n return exports;\n });\n }\n }\n})();\n","import { Fraction, Pitch, Matrix2x3 } from './interfaces';\nimport { SemanticPoint, CONFLICTION_GROUPS } from './semanticPoint';\n\ntype Point2D = { x: number; y: number };\ntype PointSegment = Point2D[];\n\nconst POINT_CONFLICTION_DISTANCE = 0.4;\n\nconst roundNumber = (x: number, precision: number, min = -Infinity): number => Math.max(Math.round(x / precision) * precision, min);\n\nconst distance2D = (p1: Point2D, p2: Point2D): number => {\n\tconst dx = p1.x - p2.x;\n\tconst dy = p1.y - p2.y;\n\n\treturn Math.sqrt(dx * dx + dy * dy);\n};\n\nconst trans23 = (point: Point2D, matrix: Matrix2x3): Point2D => ({\n\tx: matrix[0] * point.x + matrix[2] * point.y + matrix[4],\n\ty: matrix[1] * point.x + matrix[3] * point.y + matrix[5],\n});\n\nconst gcd = (a: number, b: number): number => {\n\tif (!(Number.isInteger(a) && Number.isInteger(b))) {\n\t\tconsole.error('non-integer gcd:', a, b);\n\t\treturn 1;\n\t}\n\n\treturn b === 0 ? a : gcd(b, a % b);\n};\n\nconst frac = (numerator: number, denominator: number): Fraction => ({ numerator, denominator });\n\nconst reducedFraction = (n: number, d: number): Fraction => {\n\tn = Math.round(n);\n\td = Math.round(d);\n\n\tconst g = n !== 0 ? gcd(n, d) : d;\n\n\treturn frac(n / g, d / g);\n};\n\nconst printFraction = (f: Fraction): string => `${f.numerator}/${f.denominator}`;\n\nconst fractionMul = (value: number, fraction: Fraction): number => (fraction ? (value * fraction.numerator) / fraction.denominator : value);\n\nconst segmentPoints = (points: Point2D[], axis: 'x' | 'y'): PointSegment[] => {\n\tconst sorted = [...points].sort((p1, p2) => p1[axis] - p2[axis]);\n\n\tlet seg: Point2D[] = null;\n\tlet lastP = null;\n\n\treturn sorted.reduce((segments, p, i) => {\n\t\tif (!lastP) {\n\t\t\tlastP = p;\n\t\t\tseg = [p];\n\t\t} else {\n\t\t\tif (p[axis] - lastP[axis] < POINT_CONFLICTION_DISTANCE) seg.push(p);\n\t\t\telse {\n\t\t\t\tif (seg.length > 1) segments.push(seg);\n\t\t\t\tlastP = p;\n\t\t\t\tseg = [p];\n\t\t\t}\n\t\t}\n\n\t\tif (seg.length > 1 && i === sorted.length - 1) segments.push(seg);\n\n\t\treturn segments;\n\t}, []);\n};\n\nconst filterWeekPoints = (points: SemanticPoint[]): SemanticPoint[] => {\n\t//console.log(\"filterWeekPoints:\", points.map(p => `${p.semantic}, ${p.x}, ${p.y}`));\n\t//console.table(points.map(p => ({ ...p })));\n\n\tif (points.length <= 1) return [];\n\n\tlet rests = points.slice(1);\n\tconst group = CONFLICTION_GROUPS.find((group) => group.includes(points[0].semantic));\n\tif (!group) return filterWeekPoints(rests);\n\n\tconst weeks = rests.filter((p) => group.includes(p.semantic));\n\trests = rests.filter((p) => !group.includes(p.semantic));\n\n\treturn [...weeks, ...filterWeekPoints(rests)];\n};\n\nconst solveOverlapping = (points: SemanticPoint[]): SemanticPoint[] => {\n\tconst pset = new Set(points);\n\n\tconst xClusters = segmentPoints(points, 'x');\n\tconst clusters: SemanticPoint[][] = [].concat(...xClusters.map((c) => segmentPoints(c, 'y')));\n\tclusters.forEach((ps) => ps.sort((p1, p2) => p2.confidence - p1.confidence));\n\n\tclusters.forEach((ps) => {\n\t\tfilterWeekPoints(ps).forEach((p) => pset.delete(p));\n\t});\n\n\treturn Array.from(pset);\n};\n\nconst GROUP_N_TO_PITCH = [0, 2, 4, 5, 7, 9, 11];\nconst MIDDLE_C = 60;\n\nconst mod7 = (x) => {\n\tlet y = x % 7;\n\twhile (y < 0) y += 7;\n\n\treturn y;\n};\n\nconst mod12 = (x) => {\n\tlet y = x % 12;\n\twhile (y < 0) y += 12;\n\n\treturn y;\n};\n\nconst noteToPitch = ({ note, alter }: Pitch): number => {\n\tconst group = Math.floor(note / 7);\n\tconst gn = mod7(note);\n\n\treturn MIDDLE_C + group * 12 + GROUP_N_TO_PITCH[gn] + alter;\n};\n\nconst argmax = (data: number[]): number => {\n\tconst max = Math.max(...data);\n\n\treturn data.indexOf(max);\n};\n\nexport {\n\tPoint2D,\n\troundNumber,\n\tdistance2D,\n\ttrans23,\n\tsolveOverlapping,\n\tgcd,\n\tfrac,\n\treducedFraction,\n\tprintFraction,\n\tfractionMul,\n\tGROUP_N_TO_PITCH,\n\tMIDDLE_C,\n\tmod7,\n\tmod12,\n\tnoteToPitch,\n\targmax,\n};\n","interface Logger {\n\tdebug(message?: any, ...optionalParams: any[]): void;\n\tinfo(message?: any, ...optionalParams: any[]): void;\n\twarn(message?: any, ...optionalParams: any[]): void;\n\tgroup(...label: any[]): void;\n\tgroupCollapsed(...label: any[]): void;\n\tgroupEnd(): void;\n\tassert(expr: boolean, ...optionalParams: any[]): void;\n}\n\nclass DummyLogger implements Logger {\n\tdebug(..._: any[]): void {}\n\tgroup(..._: any[]): void {}\n\tgroupCollapsed(..._: any[]): void {}\n\tgroupEnd(): void {}\n\tinfo(..._: any[]): void {}\n\twarn(..._: any[]): void {}\n\tassert(..._: any[]): void {}\n}\n\nexport { Logger, DummyLogger };\n","import matrixInverse from 'matrix-inverse';\n\nimport { Fraction } from './interfaces';\nimport { fractionMul, reducedFraction, roundNumber } from './utils';\nimport { Logger, DummyLogger } from './logger';\n\ntype Matrix = number[][];\ntype EventID = number;\ntype Time = number;\ntype EventSet = Set;\ntype Equation = number[];\n\nconst EOM = -1; // end event id of measure\n\n//const GREAT_NUMBER = 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 * 23;\nconst GREAT_NUMBER = 1920;\n\nconst DURATION_MULTIPLIER = 128 * 3 * 5 * 7 * 11 * 13;\n\nconst floatToFrac = (x: number): Fraction => {\n\tconst n = Math.round(x * GREAT_NUMBER);\n\n\treturn reducedFraction(n, GREAT_NUMBER);\n};\n\nconst floatToTimeWarp = (x: number): Fraction => {\n\tif (x === 1) return null;\n\n\treturn floatToFrac(x);\n};\n\ninterface Stage {\n\tevents: EventID[];\n\tindex?: number;\n\ttick?: Time;\n}\n\nenum ActionType {\n\tPLACE,\n\tVERTICAL,\n\tHORIZONTAL,\n}\n\nclass Action {\n\ttype: ActionType;\n\te1: EventID;\n\te2?: EventID;\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tstatic P(e: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.PLACE,\n\t\t\te1: e,\n\t\t});\n\t}\n\n\tstatic V(e1: EventID, e2: EventID, order: number = 1): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.VERTICAL,\n\t\t\te1: order > 0 ? e1 : e2,\n\t\t\te2: order > 0 ? e2 : e1,\n\t\t});\n\t}\n\n\tstatic H(e1: EventID, e2: EventID): Action {\n\t\treturn new Action({\n\t\t\ttype: ActionType.HORIZONTAL,\n\t\t\te1,\n\t\t\te2,\n\t\t});\n\t}\n\n\tget id(): string {\n\t\tswitch (this.type) {\n\t\t\tcase ActionType.PLACE:\n\t\t\t\treturn this.e1.toString();\n\n\t\t\tcase ActionType.VERTICAL:\n\t\t\t\treturn `${this.e1}|${this.e2}`;\n\n\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\treturn `${this.e1}-${this.e2 >= 0 ? this.e2 : '.'}`;\n\t\t}\n\t}\n\n\tget events(): EventID[] {\n\t\treturn [this.e1, this.e2].filter(Number.isFinite);\n\t}\n}\n\ninterface Quota {\n\tcredits: number;\n}\n\ninterface BasicEvent {\n\tid: EventID;\n\tconfidence: number;\n\tshrinkness: number; // the possibility of time warp\n\tx: number;\n\tstaff?: number;\n\tduration: Time;\n}\n\ninterface Event extends BasicEvent {\n\tlowWarp: number;\n}\n\ninterface EventResult {\n\tid: EventID;\n\ttick: Time;\n\tendTick: Time;\n\ttickGroup: number;\n\ttimeWarp?: Fraction;\n}\n\ninterface Environment {\n\tevents: BasicEvent[];\n\texpectedDuration: Time;\n\tmeasureShrinkness: number;\n\tendX: number;\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n}\n\ninterface Solution {\n\tevents: EventResult[];\n\tvoices: EventID[][];\n\tduration: number;\n\n\tloss?: number;\n\tactions?: string;\n\tcredits?: number;\n\ttimes?: number;\n}\n\ninterface Status {\n\tactionAccessing: Map;\n\teventMap: { [id: number]: Event };\n\teventTendencies: number[];\n\tmatrixH: Matrix; // matrix N+1 x N\t\t[right][left]\n\tmatrixV: Matrix; // matrix N x N\n}\n\ninterface NodeBranch {\n\taction: Action;\n\tpossibility: number;\n}\n\ntype Path = EventID[];\n\ninterface InbalanceEquations {\n\tones: boolean[];\n\tinbalances: Equation[];\n}\n\ninterface SolverOptions {\n\tquota?: number;\n\tlogger?: Logger;\n}\n\nclass StageMatrix {\n\tmatrix: EventSet[][];\n\n\tstatic fromNode(node: PathNode, status: Status): StageMatrix {\n\t\tconst matrix = Array(node.stages.length)\n\t\t\t.fill(null)\n\t\t\t.map(() =>\n\t\t\t\tArray(node.stages.length)\n\t\t\t\t\t.fill(null)\n\t\t\t\t\t.map(() => new Set())\n\t\t\t);\n\n\t\tnode.actions\n\t\t\t.filter((action) => action.type === ActionType.HORIZONTAL)\n\t\t\t.forEach((action) => {\n\t\t\t\tconst stage1 = node.stages.findIndex((stage) => stage.events.includes(action.e1));\n\t\t\t\tconst stage2 = node.stages.findIndex((stage) => stage.events.includes(action.e2));\n\t\t\t\tconsole.assert(stage1 >= 0 && stage2 >= 0, 'invalid stages for H action:', node.id, node.stages, action);\n\n\t\t\t\tmatrix[stage1][stage2].add(action.e1);\n\t\t\t});\n\t\tmatrix[0][node.stages.length - 1].add(0); // the entire measure edge\n\n\t\tconst stagedEvents = node.stagedEvents;\n\t\tconst endHs = status.matrixH[status.matrixH.length - 1].filter((_, i) => !stagedEvents.has(i));\n\t\tconst endHP = Math.max(0, Math.max(...endHs) - 0.01);\n\n\t\tconst hActions = node.actions.filter((action) => action.type === ActionType.HORIZONTAL);\n\n\t\tconst pendingHeads = Object.keys(status.eventMap)\n\t\t\t.map(Number)\n\t\t\t.filter((eid) => !hActions.find((action) => action.e2 === eid));\n\n\t\t// edges to end stage\n\t\tnode.stages.forEach((stage) => {\n\t\t\tstage.events.forEach((eid) => {\n\t\t\t\tif (eid > 0) {\n\t\t\t\t\tconst act = hActions.find((action) => action.e1 === eid);\n\t\t\t\t\tif (!act && status.matrixH[status.matrixH.length - 1][eid] >= endHP) {\n\t\t\t\t\t\tif (!pendingHeads.some((id) => status.matrixH[id][eid] > 0)) matrix[stage.index][node.stages.length - 1].add(eid);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn new StageMatrix({ matrix });\n\t}\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\t}\n\n\tpathOf(x: number, y: number, target: number, ei: number = 0): Path {\n\t\tif (this.matrix[x][y].size) {\n\t\t\tconst eid = [...this.matrix[x][y]][ei];\n\t\t\tif (y === target) return [eid];\n\n\t\t\tfor (let yy = y + 1; yy <= target; ++yy) {\n\t\t\t\tconst sub = this.pathOf(y, yy, target);\n\t\t\t\tif (sub) return [eid, ...sub];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfindDoublePath(s1: number, s2: number): [Path, Path] {\n\t\tconst paths = [];\n\t\tfor (let t = s2; t >= s1 + 1; --t) {\n\t\t\tfor (let ei = 0; ei < this.matrix[s1][t].size; ++ei) {\n\t\t\t\tconst path = this.pathOf(s1, t, s2, ei);\n\t\t\t\tif (path) {\n\t\t\t\t\tpaths.push(path);\n\t\t\t\t\tif (paths.length === 2) return [paths[0], paths[1]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\treducePath(path: Path): void {\n\t\tthis.matrix.forEach((column) => column.forEach((set) => path.forEach((id) => set.delete(id))));\n\t}\n\n\ttoEquations(eventCount: number): Equation[] {\n\t\tconst equations: Equation[] = [];\n\n\t\tfor (let d = 1; d < this.matrix.length; d++) {\n\t\t\tfor (let s1 = 0; s1 < this.matrix.length - d; s1++) {\n\t\t\t\tconst s2 = s1 + d;\n\n\t\t\t\twhile (true) {\n\t\t\t\t\t// find closed loop from s1 to s2\n\t\t\t\t\tconst paths = this.findDoublePath(s1, s2);\n\t\t\t\t\tif (paths) {\n\t\t\t\t\t\tconst [path1, path2] = paths;\n\t\t\t\t\t\tconst equation = Array(eventCount).fill(0);\n\t\t\t\t\t\tpath1.forEach((eid) => (equation[eid] = 1));\n\t\t\t\t\t\tpath2.forEach((eid) => (equation[eid] = -1));\n\t\t\t\t\t\tequations.push(equation);\n\n\t\t\t\t\t\tthis.reducePath(path1.length > path2.length ? path1 : path2);\n\t\t\t\t\t} else break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn equations;\n\t}\n}\n\nclass PathNode {\n\tlogger: Logger;\n\n\tparent: PathNode;\n\taction: Action;\n\tpossibility: number;\n\tchildren: PathNode[];\n\n\tstages: Stage[];\n\t//stageMatrix: StageMatrix;\n\tconstraints: Equation[];\n\n\tconstructor(data: any) {\n\t\tObject.assign(this, data);\n\n\t\tconsole.assert(this.logger, 'logger is null:', data);\n\t}\n\n\tget actions(): Action[] {\n\t\tconst last = this.parent ? this.parent.actions : [];\n\t\treturn this.action ? [...last, this.action] : last;\n\t}\n\n\tget id(): string {\n\t\tconst actionIds = this.actions.map((action) => action.id).sort();\n\t\treturn actionIds.join(' ');\n\t}\n\n\tget stagedEvents(): Set {\n\t\tconst set = new Set();\n\t\tif (this.stages) this.stages.forEach((stage) => stage.events.forEach((eid) => eid >= 0 && set.add(eid)));\n\n\t\treturn set;\n\t}\n\n\tlike(ids: string): boolean {\n\t\tconst actionIds = ids.split(' ').sort();\n\t\treturn actionIds.join(' ') === this.id;\n\t}\n\n\tconstructStages(status: Status): void {\n\t\tthis.stages = [{ events: [EOM] }];\n\n\t\tfor (const action of this.actions) {\n\t\t\tswitch (action.type) {\n\t\t\t\tcase ActionType.PLACE:\n\t\t\t\t\tthis.stages.unshift({ events: [action.e1] });\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.VERTICAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid V action:', this.stages, action);\n\n\t\t\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\t\t\tstage1.events.push(...stage2.events);\n\t\t\t\t\t\t\tstage2.events = null;\n\t\t\t\t\t\t\tthis.stages = this.stages.filter((stage) => stage.events);\n\t\t\t\t\t\t} else if (!stage1) stage2.events.unshift(action.e1);\n\t\t\t\t\t\telse if (!stage2) stage1.events.push(action.e2);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase ActionType.HORIZONTAL:\n\t\t\t\t\t{\n\t\t\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(action.e1));\n\t\t\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(action.e2));\n\t\t\t\t\t\tconsole.assert(stage1 || stage2, 'invalid H action:', this.stages, action);\n\n\t\t\t\t\t\tconst newStage = (eid) => {\n\t\t\t\t\t\t\tconsole.assert(status.eventMap[eid], 'invalid event id:', action.id, eid, status.eventMap);\n\t\t\t\t\t\t\tconst x = status.eventMap[eid].x;\n\n\t\t\t\t\t\t\tconst stage = this.stages.find(\n\t\t\t\t\t\t\t\t(s) => s.events.some((e) => e > 0 && status.eventMap[e].x <= x) && s.events.some((e) => e > 0 && status.eventMap[e].x >= x)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (stage) stage.events.push(eid);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconst newStage = { events: [eid] };\n\t\t\t\t\t\t\t\tconst si = this.stages.findIndex((s) => s.events[0] === EOM || status.eventMap[s.events[0]].x >= x);\n\t\t\t\t\t\t\t\tthis.stages.splice(si, 0, newStage);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (!stage1) newStage(action.e1);\n\t\t\t\t\t\tif (!stage2) newStage(action.e2);\n\n\t\t\t\t\t\t/*if (this.stages.some((s, si) => si < this.stages.length - 2\n\t\t\t\t\t&& s.events.some(e1 => this.stages[si + 1].events.some(e2 => status.eventMap[e2].x <= status.eventMap[e1].x))))\n\t\t\t\t\tdebugger;*/\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis.stages.forEach((stage, i) => (stage.index = i));\n\t}\n\n\tconstructConstraints(status: Status): void {\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst stageMatrix = StageMatrix.fromNode(this, status);\n\t\tconst equations = stageMatrix.toEquations(eventCount);\n\n\t\tconst factors = Array(eventCount)\n\t\t\t.fill(null)\n\t\t\t.map((_, id) => status.eventMap[id].duration);\n\t\tthis.constraints = equations.map((equation) => equation.map((it, i) => it * factors[i]));\n\t}\n\n\tinbalancesConstraints(status: Status): InbalanceEquations {\n\t\tconsole.assert(this.constraints, 'constraints not constructed.');\n\n\t\tconst eventCount = Object.keys(status.eventMap).length;\n\t\tconst ones = Array(eventCount).fill(true);\n\t\tconst fixed = Array(eventCount).fill(false);\n\n\t\tconst inbalances: Equation[] = [];\n\n\t\tfor (const constraint of this.constraints) {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum !== 0) {\n\t\t\t\tconst c = sum < 0 ? constraint.map((it) => -it) : constraint;\n\t\t\t\tif (c[0] > 0) continue; // entire measure edge usually is larger than others, no effect\n\n\t\t\t\tinbalances.push(c);\n\n\t\t\t\t// set ones for tight items\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tfixed[i] = fixed[i] || it < 0;\n\t\t\t\t\tif (it) ones[i] = it < 0 || fixed[i];\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// pick out influenced equations\n\t\tthis.constraints.forEach((constraint) => {\n\t\t\tconst sum = constraint.reduce((sum, it) => sum + it, 0);\n\t\t\tif (sum === 0 && !constraint[0]) {\n\t\t\t\tif (constraint.some((it, i) => it && !ones[i])) {\n\t\t\t\t\tconstraint.forEach((it, i) => it && (ones[i] = false));\n\t\t\t\t\tinbalances.push(constraint);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treturn { ones, inbalances };\n\t}\n\n\tsolveEquations({ ones, inbalances }: InbalanceEquations): number[] {\n\t\tif (!inbalances.length) return ones.map(() => 1);\n\n\t\tconst xis = ones\n\t\t\t.map((fixed, i) => ({ fixed, i }))\n\t\t\t.filter(({ fixed }) => !fixed)\n\t\t\t.map(({ i }) => i)\n\t\t\t.filter((i) => inbalances.some((items) => items[i] !== 0));\n\t\tif (!xis.length) return ones.map(() => 1);\n\n\t\tconst factors = xis.map((i) => Math.abs(inbalances.find((items) => items[i] !== 0)[i]));\n\n\t\ttype Line = { line: number[]; bias: number };\n\n\t\tconst equationMap = new Map();\n\t\tlet conflicted = false;\n\n\t\tconst lines: Line[] = inbalances\n\t\t\t.map((items) => {\n\t\t\t\tconst line = items.filter((_, i) => xis.includes(i));\n\t\t\t\tconst bias = -items.reduce((sum, it, i) => sum + (xis.includes(i) ? 0 : it), 0);\n\n\t\t\t\treturn { line, bias };\n\t\t\t\t// remove duplicated equations\n\t\t\t})\n\t\t\t.filter(({ line, bias }) => {\n\t\t\t\tif (line.every((it) => it === 0)) return false;\n\n\t\t\t\tconst id = line.join(',');\n\t\t\t\tif (equationMap.has(id)) {\n\t\t\t\t\tconflicted = equationMap.get(id) !== bias;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tequationMap.set(id, bias);\n\n\t\t\t\treturn true;\n\t\t\t});\n\n\t\tif (conflicted) return null;\n\n\t\tconst squareLines = lines.slice(0, xis.length);\n\t\tconst restLines = lines.slice(xis.length);\n\t\tif (squareLines.length < xis.length) {\n\t\t\tconst candidateLines = [];\n\t\t\tfor (let i1 = 0; i1 < xis.length - 1; ++i1) {\n\t\t\t\tconst i2 = i1 + 1;\n\t\t\t\tconst line = {\n\t\t\t\t\tline: xis.map((_, i) => (i === i1 ? 1 : i === i2 ? -1 : 0)),\n\t\t\t\t\tbias: 0,\n\t\t\t\t\tprior: (factors[i1] + factors[i2]) / DURATION_MULTIPLIER,\n\t\t\t\t};\n\t\t\t\tif (squareLines.some((sl) => sl.line[i1] && sl.line[i2])) line.prior -= 10;\n\t\t\t\tif (squareLines.some((sl) => sl.line.filter(Number).length === 1 && (sl.line[i1] || sl.line[i2]))) line.prior += 1;\n\t\t\t\tcandidateLines.push(line);\n\t\t\t}\n\t\t\tcandidateLines.sort((c1, c2) => c1.prior - c2.prior);\n\n\t\t\tsquareLines.push(...candidateLines.slice(0, xis.length - squareLines.length));\n\t\t}\n\t\t//console.assert(squareLines.length, \"squareLines is empty.\", lines, xis, equationMap, inbalances);\n\n\t\tconst matrix = squareLines.map(({ line }) => line);\n\t\tconst bias = squareLines.map(({ bias }) => bias);\n\n\t\tconst invert = matrixInverse(matrix);\n\t\tif (!invert) {\n\t\t\tthis.logger.warn('null invert:', matrix);\n\t\t\t//debugger;\n\t\t\treturn null;\n\t\t}\n\t\tconst solution = invert.map((row) => row.reduce((sum, it, i) => sum + it * bias[i], 0));\n\t\t//console.log(\"solution:\", matrix, invert, solution);\n\n\t\tif (restLines.length) {\n\t\t\tif (restLines.some((line) => Math.abs(line.line.reduce((sum, it, i) => sum + it * solution[i], 0)) > 1e-3)) {\n\t\t\t\t//console.debug(\"rest lines not satisfied:\", restLines, solution);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tconst result = ones.map(() => 1);\n\t\txis.forEach((xi, i) => (result[xi] = solution[i]));\n\n\t\treturn result;\n\t}\n\n\toptimallySolve(status: Status): number[] {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 1-2 9|1 2-3 3-4 9-10 4-5 5-6 6-7 7-8 8-. 12|6 11-12 10-11\"))\n\t\t//\tdebugger;\n\n\t\tconst shrinknesses = ones.map((fixed, id) => (fixed ? -1 : roundNumber(status.eventMap[id].shrinkness, 0.01)));\n\t\tconst shrinkMap = shrinknesses.reduce((map, shrinkness, id) => {\n\t\t\tif (shrinkness >= 0) {\n\t\t\t\tmap[shrinkness] = map[shrinkness] || [];\n\t\t\t\tmap[shrinkness].push(id);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}, {});\n\t\tconst groups = Object.entries(shrinkMap)\n\t\t\t.sort((p1, p2) => Number(p2[0]) - Number(p1[0]))\n\t\t\t.map((pair) => pair[1]);\n\t\t//console.log(\"groups:\", groups, shrinknesses);\n\n\t\tfor (let released = 1; released < groups.length; ++released) {\n\t\t\tconst releasedIds = [].concat(...groups.slice(0, released));\n\t\t\tconst fixed = ones.map((_, id) => !releasedIds.includes(id));\n\t\t\tconst warps = this.solveEquations({ ones: fixed, inbalances });\n\n\t\t\tif (warps && warps.every((it, i) => it <= 1 && it > status.eventMap[i].lowWarp)) return warps;\n\t\t}\n\n\t\treturn this.solveEquations({ ones, inbalances });\n\t}\n\n\tisConflicted(status: Status): boolean {\n\t\tconst { ones, inbalances } = this.inbalancesConstraints(status);\n\n\t\t//if (this.like(\"2 8|2 8-9 3|9 2-3 3-4 10|4 4-5 5|11 11-12 6|12 5-6 10-11 9-10 6-7\"))\n\t\t//\tdebugger;\n\n\t\tfor (const c of inbalances) {\n\t\t\t// sum with low warps\n\t\t\tconst lowSum = c.reduce((sum, it, i) => sum + it * (ones[i] || it <= 0 ? 1 : status.eventMap[i].lowWarp), 0);\n\n\t\t\tif (lowSum >= 0) {\n\t\t\t\t// mark events' broken tendency\n\t\t\t\tc.forEach((it, i) => {\n\t\t\t\t\tif (it) status.eventTendencies[i] += it > 0 ? 1 : -1;\n\t\t\t\t});\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!inbalances.length) return false;\n\n\t\tconst timeWarps = this.solveEquations({ ones, inbalances });\n\t\tif (!timeWarps) return true;\n\n\t\treturn !timeWarps.every((it, i) => it > status.eventMap[i].lowWarp && it <= 1);\n\t}\n\n\tgetSolution(status: Status): Solution {\n\t\tconst actionKey = (action) =>\n\t\t\tstatus.eventMap[action.e2]\n\t\t\t\t? status.eventMap[action.e2].x + Math.abs(status.eventMap[action.e2].x - status.eventMap[action.e1].x) * 0.06\n\t\t\t\t: status.eventMap[action.e1].x + 1e4;\n\t\tconst hacts = this.actions.filter((action) => action.type === ActionType.HORIZONTAL).sort((a1, a2) => actionKey(a1) - actionKey(a2));\n\t\tconst hmap = hacts.reduce((map, act) => ({ ...map, [act.e1]: act.e2 }), {});\n\t\tconst startEs = new Set([...Object.keys(hmap)].map(Number));\n\t\thacts.forEach((act) => startEs.delete(act.e2));\n\t\tthis.stages[0].events.forEach((eid) => eid > 0 && startEs.add(eid));\n\n\t\tlet voices = [...startEs].map((se) => {\n\t\t\tconst voice = [se];\n\n\t\t\tlet x = se;\n\t\t\twhile (hmap[x]) {\n\t\t\t\tx = hmap[x];\n\t\t\t\tif (x < 0 || voice.includes(x)) break;\n\n\t\t\t\tvoice.push(x);\n\t\t\t}\n\n\t\t\treturn voice;\n\t\t});\n\n\t\tconst events: EventResult[] = Object.values(status.eventMap)\n\t\t\t.filter((e) => e.id > 0)\n\t\t\t.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\ttick: null,\n\t\t\t\tendTick: null,\n\t\t\t\ttickGroup: null,\n\t\t\t\ttimeWarp: null,\n\t\t\t}));\n\t\tconst eventMap: { [id: number]: EventResult } = events\n\t\t\t.filter((e) => voices.some((voice) => voice.includes(e.id)) || hacts.some((act) => [act.e1, act.e2].includes(e.id)))\n\t\t\t.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.stages.forEach((stage, si) => stage.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tickGroup = si)));\n\n\t\tthis.stages[0].tick = 0;\n\t\tthis.stages[0].events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = 0));\n\n\t\t// solve time warps\n\t\tconst timeWarps = this.optimallySolve(status);\n\t\tevents.forEach((e) => (e.timeWarp = floatToTimeWarp(timeWarps[e.id])));\n\n\t\t//if (this.like(\"1 12|1 1-2 9|2 2-3 13|3 3-4 4-5 10|5 14|10 10-11 8-9 14-15 15|6 6-7 7-. 13-14 5-6 12-13 9-10\"))\n\t\t//\tdebugger;\n\n\t\t// solve stage ticks\n\t\tconst estages = this.stages.slice(0, this.stages.length - 1);\n\t\tconst solveStages = (): boolean => {\n\t\t\tif (estages.every((stage) => Number.isFinite(stage.tick))) return false;\n\n\t\t\tlet changed = false;\n\n\t\t\t// forward\n\t\t\thacts.forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (Number.isFinite(stage1.tick) && !Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage2.tick = stage1.tick + fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage2.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage2.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// backward\n\t\t\t[...hacts].reverse().forEach((act) => {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(act.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(act.e2));\n\t\t\t\tif (!Number.isFinite(stage1.tick) && Number.isFinite(stage2.tick)) {\n\t\t\t\t\tstage1.tick = stage2.tick - fractionMul(status.eventMap[act.e1].duration, eventMap[act.e1].timeWarp);\n\t\t\t\t\tstage1.events.forEach((eid) => eventMap[eid] && (eventMap[eid].tick = stage1.tick));\n\n\t\t\t\t\tchanged = true;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\treturn changed;\n\t\t};\n\t\twhile (solveStages());\n\n\t\tconsole.assert(\n\t\t\testages.every((stage) => Number.isFinite(stage.tick)),\n\t\t\t'stage ticks not all solved:',\n\t\t\tthis.stages,\n\t\t\tthis.id\n\t\t);\n\t\tevents\n\t\t\t.filter((event) => Number.isFinite(event.tick))\n\t\t\t.forEach((event) => (event.endTick = event.tick + fractionMul(status.eventMap[event.id].duration, event.timeWarp)));\n\n\t\t// clip out of bound events\n\t\tconst measureDuration = status.eventMap[0].duration;\n\t\tvoices.forEach((voice) => {\n\t\t\tconst outEI = voice.findIndex((eid) => eventMap[eid].endTick > measureDuration);\n\t\t\tif (outEI >= 0) {\n\t\t\t\tconst es = voice.splice(outEI, voice.length - outEI);\n\t\t\t\tes.forEach((eid) => {\n\t\t\t\t\teventMap[eid].tick = null;\n\t\t\t\t\teventMap[eid].endTick = null;\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tvoices = voices.filter((voice) => voice.length);\n\n\t\tconst duration = Math.max(0, ...events.map((e) => e.endTick).filter(Number.isFinite));\n\t\t//console.log(\"getSolution:\", this);\n\t\tthis.logger.debug(String.fromCodePoint(0x1f34e), this.id, timeWarps);\n\n\t\treturn {\n\t\t\tvoices,\n\t\t\tevents,\n\t\t\tduration,\n\t\t\tactions: this.actions.map((action) => action.id).join(' '),\n\t\t};\n\t}\n\n\tdeduce(status: Status, quota: Quota): Solution {\n\t\tif (!this.stages) this.constructStages(status);\n\t\t//console.log(\"deduce:\", status);\n\n\t\t// increase access counting\n\t\tconst access = status.actionAccessing.get(this.id) || { times: 0 };\n\t\t++access.times;\n\t\tstatus.actionAccessing.set(this.id, access);\n\n\t\tthis.constructConstraints(status);\n\t\t//console.log(\"constraints:\", this.id, this.stages, this.constraints);\n\n\t\tif (this.isConflicted(status)) {\n\t\t\taccess.closed = true;\n\t\t\tthis.logger.info(this.action.id, '\\u274c');\n\t\t\treturn null;\n\t\t}\n\n\t\t//const newStatus = status;\n\t\tthis.logger.group(this.action && this.action.id);\n\n\t\tif (quota.credits > 0) {\n\t\t\t--quota.credits;\n\n\t\t\tif (!this.children) this.expand(status);\n\n\t\t\tthis.children = this.children.filter((node) => !status.actionAccessing.get(node.id) || !status.actionAccessing.get(node.id).closed);\n\t\t\tif (this.children.length) {\n\t\t\t\tconst p = (node: PathNode): number => node.possibility / ((status.actionAccessing.get(node.id) || { times: 0 }).times + 1);\n\t\t\t\tthis.children.sort((n1, n2) => p(n2) - p(n1));\n\n\t\t\t\tfor (const child of this.children) {\n\t\t\t\t\tconst solution = child.deduce(status, quota);\n\t\t\t\t\tif (solution) {\n\t\t\t\t\t\tthis.logger.groupEnd();\n\t\t\t\t\t\treturn solution;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (quota.credits <= 0) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//else\n\t\t\t//\tconsole.debug(\"got the leaf:\", this, status);\n\t\t} else this.logger.debug('quota exhausted.');\n\n\t\tthis.logger.groupEnd();\n\n\t\taccess.closed = true;\n\n\t\treturn this.getSolution(status);\n\t}\n\n\texpand(status: Status): void {\n\t\t//this.action.events.forEach(eid => status.pendingEvents.delete(eid));\n\t\tthis.constructStages(status);\n\n\t\tconst { eventMap, matrixV, matrixH } = status;\n\t\tconst stagedEvents = this.stagedEvents;\n\n\t\tconst branches: NodeBranch[] = [];\n\t\tconst appendBranch = (branch: NodeBranch): void => {\n\t\t\tif (!this.actions.some((a) => a.id === branch.action.id) && !branches.some((b) => b.action.id === branch.action.id)) {\n\t\t\t\tconst stage1 = this.stages.find((stage) => stage.events.includes(branch.action.e1));\n\t\t\t\tconst stage2 = this.stages.find((stage) => stage.events.includes(branch.action.e2));\n\t\t\t\tif (stage1 === stage2 || (stage1 && stage2 && stage1.index >= stage2.index)) return;\n\n\t\t\t\tif (stage1 && stage2) {\n\t\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\t\tif (stage2.index - stage1.index > 1) return;\n\t\t\t\t\t\tif (this.actions.some((a) => stage1.events.includes(a.e1) && stage2.events.includes(a.e2))) return;\n\t\t\t\t\t} else if (branch.action.type === ActionType.HORIZONTAL) {\n\t\t\t\t\t\tif (stage1.index > stage2.index) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tbranch.action.type === ActionType.HORIZONTAL &&\n\t\t\t\t\tthis.actions.some(\n\t\t\t\t\t\t(a) =>\n\t\t\t\t\t\t\ta.type === ActionType.HORIZONTAL &&\n\t\t\t\t\t\t\t(a.e1 === branch.action.e1 || a.e2 === branch.action.e2 || (a.e1 === branch.action.e2 && a.e2 === branch.action.e1))\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\n\t\t\t\t// exclude 2 too far away events by vertical\n\t\t\t\tif (branch.action.type === ActionType.VERTICAL) {\n\t\t\t\t\tif (stage1) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage1.events.map((e) => matrixV[branch.action.e2][e]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (stage2) {\n\t\t\t\t\t\tbranch.possibility = Math.min(branch.possibility, ...stage2.events.map((e) => matrixV[e][branch.action.e1]));\n\t\t\t\t\t\tif (branch.possibility <= 0) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbranches.push(branch);\n\t\t\t}\n\t\t};\n\n\t\tfor (const eid of stagedEvents) {\n\t\t\tif (eid < 0) continue;\n\n\t\t\tmatrixV[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0 && eid !== id) appendBranch({ action: Action.V(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixV.forEach((ps, id) => {\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.V(eid, id), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH[eid].forEach((p, id) => {\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(id, eid), possibility: p });\n\t\t\t});\n\n\t\t\tmatrixH.forEach((ps, id) => {\n\t\t\t\tid = id >= Object.keys(eventMap).length ? -1 : id;\n\t\t\t\tconst p = ps[eid];\n\t\t\t\tif (p > 0) appendBranch({ action: Action.H(eid, id), possibility: p });\n\t\t\t});\n\t\t}\n\n\t\t// If branches not contains extending actions, clear it.\n\t\t//\tBecause pure inner vertical action may be harmful\n\t\tif (\n\t\t\t!branches.some(\n\t\t\t\t(branch) =>\n\t\t\t\t\t[ActionType.HORIZONTAL, ActionType.PLACE].includes(branch.action.type) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e1) ||\n\t\t\t\t\t!stagedEvents.has(branch.action.e2)\n\t\t\t)\n\t\t) {\n\t\t\tthis.children = [];\n\t\t\treturn;\n\t\t}\n\n\t\t//console.table(branches.map(b => [b.action.id, b.possibility]));\n\t\t//console.log(\"branches:\", branches.map(b => b.action.id).join(\", \"), \"\\n\", this.actions.map(a => a.id).join(\", \"));\n\t\tthis.children = branches.map((branch) => new PathNode({ logger: this.logger, parent: this, ...branch }));\n\t}\n}\n\nclass Solver {\n\tquota: number;\n\tlogger: Logger;\n\n\tevents: Event[];\n\tmatrixH: Matrix;\n\tmatrixV: Matrix;\n\txSpan: number;\n\n\teventMap: { [id: number]: Event };\n\tactionAccessing: Map;\n\n\tpathRoot: PathNode;\n\n\tconstructor(env: Environment, { quota = 1000, logger = new DummyLogger() }: SolverOptions = {}) {\n\t\tthis.quota = quota;\n\t\tthis.logger = logger;\n\n\t\tconst event0 = {\n\t\t\tid: 0,\n\t\t\tx: 0,\n\t\t\tconfidence: 1,\n\t\t\tshrinkness: env.measureShrinkness,\n\t\t\tduration: env.expectedDuration,\n\t\t\tlowWarp: 0,\n\t\t};\n\n\t\tthis.events = [\n\t\t\tevent0,\n\t\t\t...env.events.map((e) => ({\n\t\t\t\tid: e.id,\n\t\t\t\tx: e.x,\n\t\t\t\tconfidence: e.confidence,\n\t\t\t\tshrinkness: e.shrinkness,\n\t\t\t\tstaff: e.staff,\n\t\t\t\tduration: e.duration,\n\t\t\t\tlowWarp: 0.5,\n\t\t\t})),\n\t\t];\n\t\tthis.eventMap = this.events.reduce((map, e) => ({ ...map, [e.id]: e }), {});\n\n\t\tthis.matrixH = env.matrixH;\n\t\tthis.matrixV = env.matrixV;\n\n\t\tthis.xSpan = env.endX - Math.min(env.endX - 1, ...env.events.map((e) => e.x));\n\n\t\tthis.actionAccessing = new Map();\n\t}\n\n\tsolve(): Solution {\n\t\t// construct path root\n\t\tthis.pathRoot = new PathNode({\n\t\t\tlogger: this.logger,\n\t\t\taction: null,\n\t\t});\n\t\tthis.pathRoot.children = this.events.slice(1).map(\n\t\t\t(event) =>\n\t\t\t\tnew PathNode({\n\t\t\t\t\tlogger: this.logger,\n\t\t\t\t\tparent: this.pathRoot,\n\t\t\t\t\taction: Action.P(event.id),\n\t\t\t\t\tpossibility: this.matrixV[event.id].reduce((sum, p) => sum + p, 0),\n\t\t\t\t})\n\t\t);\n\n\t\tlet bestSolution: Solution = null;\n\n\t\tthis.logger.groupCollapsed('solve');\n\n\t\tconst eventTendencies = Array(this.events.length).fill(0);\n\n\t\tconst quota = { credits: this.quota, times: 0 };\n\t\twhile (quota.credits > 0) {\n\t\t\t++quota.times;\n\n\t\t\tconst status = {\n\t\t\t\teventMap: this.eventMap,\n\t\t\t\tmatrixH: this.matrixH,\n\t\t\t\tmatrixV: this.matrixV,\n\t\t\t\tactionAccessing: this.actionAccessing,\n\t\t\t\teventTendencies,\n\t\t\t};\n\n\t\t\tconst solution = this.pathRoot.deduce(status, quota);\n\t\t\tsolution.credits = this.quota - quota.credits;\n\t\t\tsolution.times = quota.times;\n\t\t\tthis.evaluateSolution(solution);\n\t\t\tthis.logger.debug('loss:', solution.loss);\n\n\t\t\tbestSolution = !bestSolution || solution.loss < bestSolution.loss ? solution : bestSolution;\n\t\t\tif (!bestSolution.loss) break;\n\n\t\t\t// check if searching tree traversed\n\t\t\tif (this.actionAccessing.get('').closed) break;\n\t\t}\n\n\t\tthis.logger.groupEnd();\n\t\tthis.logger.debug('solution', bestSolution && bestSolution.loss, bestSolution);\n\t\tthis.logger.debug('cost:', this.quota - quota.credits);\n\n\t\tthis.logger.debug(\n\t\t\t'eventTendencies:',\n\t\t\teventTendencies.map((t) => t / quota.times)\n\t\t);\n\n\t\treturn bestSolution;\n\t}\n\n\tevaluateSolution(solution: Solution): void {\n\t\tsolution.loss = 0;\n\n\t\ttype EventR = Event & EventResult;\n\t\tconst eventMap: Record = solution.events.reduce((map, e) => ({ ...map, [e.id]: { ...e, ...this.eventMap[e.id] } }), {});\n\n\t\t/*// minus tick\n\t\tconst minuses = solution.events.filter((e) => e.tick < 0).length;\n\t\tsolution.loss += minuses * 1000;*/\n\n\t\t// minus tick rates penalty\n\t\tconst events = solution.events.filter((event) => Number.isFinite(event.tick)).map((event) => eventMap[event.id]);\n\t\tconst sevents: Record = events.reduce((map, event) => {\n\t\t\tmap[event.staff] = map[event.staff] || [];\n\t\t\tmap[event.staff].push(event);\n\t\t\treturn map;\n\t\t}, {});\n\t\tObject.values(sevents).forEach((es) => {\n\t\t\tconst ses = es.sort((e1, e2) => e1.x - e2.x).slice(0, es.length - 1);\n\t\t\tses.forEach((e1, i) => {\n\t\t\t\tconst e2 = es[i + 1];\n\t\t\t\tif (e2.tick < e1.tick) solution.loss += 1000;\n\t\t\t});\n\t\t});\n\n\t\tconst times = new Map();\n\t\tsolution.events.forEach((event) => {\n\t\t\tif (!Number.isFinite(event.tick) || solution.voices.every((voice) => !voice.includes(event.id)))\n\t\t\t\tsolution.loss += 100 * eventMap[event.id].confidence;\n\n\t\t\tif (event.timeWarp) {\n\t\t\t\tconst { numerator, denominator } = event.timeWarp;\n\t\t\t\tconst shrinkness = eventMap[event.id].shrinkness;\n\t\t\t\ttimes.set(numerator, Math.max(times.get(numerator) || 0, 1 - shrinkness));\n\t\t\t\ttimes.set(denominator, Math.max(times.get(denominator) || 0, 1 - shrinkness));\n\t\t\t}\n\t\t});\n\n\t\t// partial measure penalty\n\t\tconst partialFrac = reducedFraction(solution.duration, this.eventMap[0].duration);\n\t\ttimes.set(partialFrac.numerator, Math.max(times.get(partialFrac.numerator) || 0, 1 - this.eventMap[0].shrinkness));\n\t\ttimes.set(partialFrac.denominator, Math.max(times.get(partialFrac.denominator) || 0, 1 - this.eventMap[0].shrinkness));\n\n\t\tfor (const [n, weight] of times.entries()) {\n\t\t\tif (n > 1) solution.loss += Math.log(n) * weight;\n\t\t}\n\n\t\tlet spaceTime = 0;\n\t\tlet staffAlters = 0;\n\t\tsolution.voices.forEach((voice) => {\n\t\t\tconsole.assert(eventMap[voice[0]], 'invalid voice:', voice, Object.keys(eventMap));\n\n\t\t\tconst start = Math.abs(eventMap[voice[0]].tick); // abs: penalty for minus start\n\t\t\tconst end = eventMap[voice[voice.length - 1]].endTick;\n\n\t\t\tspaceTime += Math.max(0, start + solution.duration - end);\n\n\t\t\t// staff alternation penalty\n\t\t\tlet staff = null;\n\t\t\tvoice.forEach((id) => {\n\t\t\t\tconst event = eventMap[id];\n\t\t\t\tif (event.staff !== staff) {\n\t\t\t\t\tif (staff !== null) ++staffAlters;\n\t\t\t\t\tstaff = event.staff;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tsolution.loss += (spaceTime * 10) / DURATION_MULTIPLIER;\n\t\tsolution.loss += 5 ** staffAlters - 1;\n\n\t\t// tick twist\n\t\tconst eventsXOrder = [...events].sort((e1, e2) => e1.x - e2.x);\n\t\tconst tickTwists = eventsXOrder.slice(1).map((e2, i) => {\n\t\t\tconst e1 = eventsXOrder[i];\n\t\t\tconst dx = e2.x - e1.x;\n\t\t\tconst dt = e2.tick - e1.tick;\n\n\t\t\tif (!dt) return dx / this.xSpan;\n\n\t\t\tconst rate = Math.atan2(dt / solution.duration, dx / this.xSpan);\n\n\t\t\treturn ((rate * 4) / Math.PI - 1) ** 2;\n\t\t});\n\t\tconst tickTwist = Math.max(...tickTwists, 0);\n\t\tsolution.loss += tickTwist ** 2;\n\n\t\tconsole.assert(solution.loss >= 0, 'Invalid solution loss!!!', solution.loss, times, spaceTime, staffAlters);\n\t\tif (solution.loss < 0) solution.loss = Infinity;\n\t}\n}\n\nexport { SolverOptions, Solver };\n","import * as workerpool from 'workerpool';\nimport * as EquationSolver from './equationSolver';\nimport { EquationPolicy } from './spartitoMeasure';\n\nconst solveStaffGroup = (staffGroup: EquationPolicy.StaffGroup, options: EquationPolicy.RegulatorOptions): EquationPolicy.StaffGroupSolution => {\n\tif (!staffGroup.events.length) {\n\t\treturn {\n\t\t\tevents: [],\n\t\t\tvoices: [],\n\t\t\tduration: 0,\n\t\t};\n\t}\n\n\tconst solver = new EquationSolver.Solver(staffGroup, options);\n\n\treturn solver.solve();\n};\n\n// create a worker and register public functions\nworkerpool.worker({\n\tsolveStaffGroup,\n});\n","console.info(`%cstarry-omr%c v1.0.0 2026-02-17T15:16:54.807Z`, '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;');\nimport '../../../src/starry/solveStaffGroup.worker';\n"],"names":["requireFoolWebpack","eval","requireFoolWebpack_1","Promise","handler","parent","me","this","SyntaxError","_onSuccess","_onFail","resolved","rejected","pending","_process","onSuccess","onFail","push","then","resolve","reject","s","_then","f","_resolve","result","forEach","fn","_reject","error","cancel","CancellationError","timeout","delay","timer","setTimeout","TimeoutError","always","clearTimeout","callback","res","message","stack","Error","require$$0","isNode","nodeProcess","versions","node","module","exports","platform","process","worker_threads","err","tryRequireFoolWebpack","isMainThread","connected","Window","cpus","self","navigator","hardwareConcurrency","length","Promise$2","prototype","all","promises","remaining","results","p","i","defer","resolver","promise","constructor","name","_Promise","embeddedWorker","environment","require$$1","require$$2","TERMINATE_METHOD_ID","ensureWorkerThreads","WorkerThreads","tryRequireWorkerThreads","ensureWebWorker","Worker","code","getDefaultWorker","Blob","window","URL","createObjectURL","blob","require$$3","type","__dirname","setupWorker","script","options","workerType","setupBrowserWorker","workerOpts","setupWorkerThreadWorker","workerThreadOpts","setupProcessWorker","resolveForkOptions","worker","isBrowserWorker","on","event","addEventListener","data","send","transfer","postMessage","workerThreadOptions","stdout","stderr","isWorkerThread","kill","terminate","disconnect","child_process","fork","forkArgs","forkOpts","call","isChildProcess","opts","processExecArgv","execArgv","join","inspectorActive","indexOf","debugBrk","debugPort","arg","Object","assign","concat","objectToError","obj","temp","props","keys","WorkerHandler","_options","onError","id","terminated","processing","undefined","create","workerTerminateTimeout","ready","requestQueue","response","request","splice","dispatchQueuedRequests","task","isEvent","payload","terminating","exitCode","signalCode","spawnargs","spawnfile","cleaning","terminationHandler","lastId","methods","exec","method","params","catch","terminateAndNotify","busy","force","cleanup","removeAllListeners","killed","cleanExitTimeout","once","WorkerHandlerModule","WorkerHandler$1","_tryRequireWorkerThreads","_setupProcessWorker","_setupBrowserWorker","_setupWorkerThreadWorker","Transfer","exit","parentPort","bind","convertError","getOwnPropertyNames","reduce","product","defineProperty","value","enumerable","isPromise","run","args","Function","apply","cleanupAndExit","_exit","currentRequestId","register","hasOwnProperty","onTerminate","emit","add","Sylvester","Matrix","elements","setElements","I","n","j","els","dup","isSquare","cols","toRightTriangular","M","np","multiplier","determinant","det","isSingular","augment","matrix","T","nj","inverse","divisor","new_element","inverse_elements","matrixInverse","mat","SemanticType","root","NODE_JS","JS_SHA1_NO_NODE_JS","global","COMMON_JS","JS_SHA1_NO_COMMON_JS","HEX_CHARS","split","EXTRA","SHIFT","OUTPUT_TYPES","blocks","createOutputMethod","outputType","Sha1","update","createMethod","nodeWrap","crypto","Buffer","nodeMethod","createHash","digest","ArrayBuffer","Uint8Array","sharedMemory","h0","h1","h2","h3","h4","block","start","bytes","hBytes","finalized","hashed","first","notString","index","charCodeAt","lastByteIndex","hash","finalize","t","a","b","c","d","e","hex","toString","array","arrayBuffer","buffer","dataView","DataView","setUint32","sha1","BarMeasure","vline_BarMeasure","vline_BarTerminal","vline_BarSegment","vline_VoltaLeft","vline_VoltaRight","VoltaAlternativeBegin","st","NoteheadS0","NoteheadS1","NoteheadS2","Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","ScriptStaccatissimo","TimesigZero","TimesigOne","TimesigTwo","TimesigThree","TimesigFour","TimesigFive","TimesigSix","TimesigSeven","TimesigEight","TimesigNine","Rest0","Rest1","Rest2","Rest3","Rest4","Rest5","Rest6","Rest0W","RestM1","SignInterval","SignLined","BeamLeft","BeamContinue","BeamRight","ClefG","ClefF","ClefC","Dot","AccNatural","AccSharp","AccDoublesharp","AccFlat","AccFlatflat","TimesigC44","TimesigC22","OctaveShift8","OctaveShift0","m","r","z","ScriptFermata","ScriptShortFermata","ScriptSforzato","ScriptStaccato","ScriptTurn","ScriptTrill","ScriptSegno","ScriptCoda","ScriptArpeggio","ScriptPrall","ScriptMordent","ScriptMarcato","ScriptTenuto","ScriptPortato","PedalStar","PedalPed","roundNumber","x","precision","min","Infinity","Math","max","round","gcd","Number","isInteger","console","frac","numerator","denominator","reducedFraction","g","fractionMul","fraction","DummyLogger","debug","_","group","groupCollapsed","groupEnd","info","warn","assert","EOM","GREAT_NUMBER","DURATION_MULTIPLIER","floatToFrac","floatToTimeWarp","ActionType","Action","P","PLACE","e1","V","e2","order","VERTICAL","H","HORIZONTAL","events","filter","isFinite","StageMatrix","fromNode","status","Array","stages","fill","map","Set","actions","action","stage1","findIndex","stage","includes","stage2","stagedEvents","endHs","matrixH","has","endHP","hActions","pendingHeads","eventMap","eid","find","some","pathOf","y","target","ei","size","yy","sub","findDoublePath","s1","s2","paths","path","reducePath","column","set","delete","toEquations","eventCount","equations","path1","path2","equation","PathNode","logger","last","sort","like","ids","constructStages","unshift","newStage","si","constructConstraints","factors","duration","constraints","it","inbalancesConstraints","ones","fixed","inbalances","constraint","sum","solveEquations","xis","items","abs","equationMap","Map","conflicted","lines","line","bias","every","get","squareLines","slice","restLines","candidateLines","i1","i2","prior","sl","c1","c2","invert","solution","row","xi","optimallySolve","shrinkMap","shrinkness","groups","entries","p1","p2","pair","released","releasedIds","warps","lowWarp","isConflicted","eventTendencies","timeWarps","getSolution","actionKey","hacts","a1","a2","hmap","act","startEs","voices","se","voice","values","tick","endTick","tickGroup","timeWarp","estages","solveStages","changed","reverse","measureDuration","outEI","String","fromCodePoint","deduce","quota","access","actionAccessing","times","closed","credits","children","expand","possibility","n1","n2","child","matrixV","branches","appendBranch","branch","ps","Solver","env","event0","confidence","measureShrinkness","expectedDuration","staff","xSpan","endX","solve","pathRoot","bestSolution","evaluateSolution","loss","sevents","es","partialFrac","weight","log","spaceTime","staffAlters","end","eventsXOrder","tickTwists","dx","dt","atan2","PI","tickTwist","solveStaffGroup","staffGroup","EquationSolver.Solver","workerpool.worker"],"mapp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,MAAMD,EAAKrF,EAAShC,SAAUoH,EAAKtlB,KAAKqkB,OAErCzM,KAAK6N,GAAK,IAAM,IAEhCC,EAAY9N,KAAKC,OAAOwN,EAAY,GAC1CnF,EAASyE,MAAQe,GAAa,EAE9BxN,QAAQgB,OAAOgH,EAASyE,MAAQ,EAAG,2BAA4BzE,EAASyE,KAAM3B,EAAOiC,EAAWC,GAC5FhF,EAASyE,KAAO,IAAGzE,EAASyE,KAAOhN,IACvC,ECpgCF,MAAMgO,gBAAkB,CAACC,EAAuC/f,KAC/D,IAAK+f,EAAWzL,OAAO3W,OACtB,MAAO,CACN2W,OAAQ,GACRyH,OAAQ,GACR1D,SAAU,GAMZ,OAFe,IAAI2H,OAAsBD,EAAY/f,GAEvC0e,SAIfuB,OAAkB,CACjBH,kCCpBDzN,QAAQc,KAAK,kDAAmD,8EAA+E"} \ No newline at end of file diff --git a/backend/python-services/.env.example b/backend/python-services/.env.example new file mode 100644 index 0000000000000000000000000000000000000000..1e48f494050ee2590833afa9d399d9da17c36045 --- /dev/null +++ b/backend/python-services/.env.example @@ -0,0 +1,21 @@ +# STARRY ML Services Docker Environment +# Generate from models.yaml: ./gen-env.sh /path/to/models +# Or copy this file to .env and modify manually + +# Model directory root (contains starry-dist/ and ocr-dist/) +MODELS_ROOT=/path/to/models/starry + +# Model paths (from starry-dist/models.yaml) +LAYOUT_MODEL_PATH=20221125-scorelayout-1121-residue-u-d4-w64-d4-w64 +MASK_MODEL_PATH=20210918-scorewidgets.mask-unet-5-32 +SEMANTIC_MODEL_PATH=202302-semanticCluster +GAUGE_MODEL_PATH=scoregauge-unet-d6-w32-0611 +LOC_MODEL_PATH=DB_gc_loc/v6/model_epoch_88_minibatch_15300 +OCR_CONFIG=ocr.yaml +BRACKETS_CONFIG=brackets.yaml + +# GPU device selection (for multi-GPU systems) +# CUDA_VISIBLE_DEVICES=0 + +# Log directory (inside container) +# LOG_DIR=/tmp/starry-logs diff --git a/backend/python-services/Dockerfile b/backend/python-services/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..29007b244cc30dd25f453046d578b888b5d2ea4d --- /dev/null +++ b/backend/python-services/Dockerfile @@ -0,0 +1,167 @@ +# STARRY Python ML Services Dockerfile +# Multi-stage build for PyTorch + TensorFlow services + +# ============================================================ +# Stage 1: Base image with CUDA support +# ============================================================ +# Use CUDA 12.1 runtime - PyTorch wheel includes cudnn +FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 AS base + +ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + python3.11 \ + python3.11-dev \ + python3-pip \ + libgl1-mesa-glx \ + libglib2.0-0 \ + libsm6 \ + libxext6 \ + libxrender-dev \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Set Python 3.11 as default +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 \ + && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 + +# Upgrade pip +RUN python -m pip install --upgrade pip + +# ============================================================ +# Stage 2: PyTorch services (layout, mask, semantic, gauge, loc) +# ============================================================ +FROM base AS pytorch-services + +WORKDIR /app + +# Install PyTorch with CUDA support +# Using cu121 for compatibility with CUDA driver 12.4 +RUN pip install --no-cache-dir \ + "numpy>=1.26.0,<2.0.0" \ + torch==2.5.1 \ + torchvision==0.20.1 \ + --index-url https://download.pytorch.org/whl/cu121 + +# Install common dependencies +RUN pip install --no-cache-dir \ + "opencv-python-headless<4.11" \ + Pillow>=8.0.0 \ + PyYAML>=5.4.0 \ + pyzmq>=22.0.0 \ + msgpack>=1.0.0 \ + dill \ + scipy \ + imgaug \ + scikit-image \ + python-dotenv \ + fs \ + tqdm \ + einops \ + lmdb + +# Source code should be mounted as volume at runtime: +# -v /path/to/deep-starry:/app/deep-starry:ro +ENV PYTHONPATH=/app/deep-starry + +# Default command (override with docker-compose) +CMD ["python", "--help"] + + +# ============================================================ +# Stage 3: TensorFlow services (ocr, brackets) +# ============================================================ +FROM base AS tensorflow-services + +WORKDIR /app + +# Install TensorFlow with legacy Keras support +RUN pip install --no-cache-dir \ + "numpy==1.26.4" \ + tensorflow==2.20.0 \ + tf_keras==2.20.1 \ + "opencv-python-headless<4.11" \ + Pillow>=8.0.0 \ + PyYAML>=5.4.0 \ + pyzmq>=22.0.0 \ + msgpack>=1.0.0 \ + zhon \ + nltk \ + distance \ + anyconfig \ + munch \ + tensorboardX \ + scipy \ + scikit-image \ + python-dotenv + +# Set legacy Keras environment +ENV TF_USE_LEGACY_KERAS=1 + +# Source code should be mounted as volume at runtime: +# -v /path/to/starry-ocr:/app/starry-ocr:ro +ENV PYTHONPATH=/app/starry-ocr + +# Default command +CMD ["python", "--help"] + + +# ============================================================ +# Stage 4: All-in-one image (for convenience) +# ============================================================ +FROM base AS all-in-one + +WORKDIR /app + +# Install all dependencies (larger image but simpler deployment) +# Using cu121 for compatibility with CUDA driver 12.4 +# Note: numpy<2.0 required for imgaug compatibility +RUN pip install --no-cache-dir \ + "numpy>=1.26.0,<2.0.0" \ + torch==2.5.1 \ + torchvision==0.20.1 \ + --index-url https://download.pytorch.org/whl/cu121 + +RUN pip install --no-cache-dir \ + "numpy>=1.26.0,<2.0.0" \ + tensorflow==2.20.0 \ + tf_keras==2.20.1 \ + "opencv-python-headless<4.11" \ + Pillow>=8.0.0 \ + PyYAML>=5.4.0 \ + pyzmq>=22.0.0 \ + msgpack>=1.0.0 \ + dill \ + scipy \ + imgaug \ + scikit-image \ + zhon \ + nltk \ + distance \ + anyconfig \ + munch \ + tensorboardX \ + python-dotenv \ + pyclipper \ + shapely \ + polygon3 \ + Polygon3 \ + tqdm \ + fs \ + einops \ + lmdb + +ENV TF_USE_LEGACY_KERAS=1 + +# Source code should be mounted as volumes at runtime: +# -v /path/to/deep-starry:/app/deep-starry:ro +# -v /path/to/starry-ocr:/app/starry-ocr:ro +ENV PYTHONPATH=/app/deep-starry:/app/starry-ocr + +# Default working directory +WORKDIR /app + +CMD ["python", "--help"] diff --git a/backend/python-services/README.md b/backend/python-services/README.md new file mode 100644 index 0000000000000000000000000000000000000000..29361c408e683fea0ec347feb9ad0e98ec684d50 --- /dev/null +++ b/backend/python-services/README.md @@ -0,0 +1,218 @@ +# STARRY Python ML Services + +Unified ML inference services for STARRY music notation recognition system. + +## Architecture + +This module provides lightweight wrappers around serialized ML models: +- **TorchScript** (.pt) for PyTorch models (layout, mask, semantic, gauge, loc) +- **SavedModel** for TensorFlow models (ocr, brackets) + +## Services + +| Service | Port | Framework | Description | +|---------|------|-----------|-------------| +| layout | 12022 | PyTorch | Page layout detection (intervals, rotation) | +| gauge | 12023 | PyTorch | Staff gauge prediction (height, slope) | +| mask | 12024 | PyTorch | Staff foreground/background mask | +| semantic | 12025 | PyTorch | Symbol semantic detection (77 classes) | +| loc | 12026 | PyTorch | Text location detection (13 categories) | +| ocr | 12027 | TensorFlow | Text recognition (DenseNet-CTC) | +| brackets | 12028 | TensorFlow | Bracket sequence recognition | + +## Installation + +```bash +pip install -r requirements.txt +``` + +## Model Export + +Before using the services, models need to be exported from the original projects. + +### PyTorch Models (TorchScript) + +Run in the deep-starry environment: + +```bash +cd /home/camus/work/deep-starry +python /path/to/scripts/export_torchscript.py \ + --mode layout \ + --config configs/your-config \ + --output models/layout.pt +``` + +### TensorFlow Models (SavedModel) + +Run in the starry-ocr environment: + +```bash +cd /home/camus/work/starry-ocr +python /path/to/scripts/export_tensorflow.py \ + --mode ocr \ + --config pretrained/OCR_Test/config.yaml \ + --output models/ocr_savedmodel +``` + +## Usage + +### Start a Service + +```bash +python main.py -m layout -w models/layout.pt -p 12022 -dv cuda +``` + +### With Configuration File + +```bash +python main.py -m semantic -w models/semantic.pt -p 12025 --config config/semantic.yaml +``` + +### Client Example (Python) + +```python +import zmq +from msgpack import packb, unpackb + +# Connect +ctx = zmq.Context() +sock = ctx.socket(zmq.REQ) +sock.connect("tcp://localhost:12022") + +# Send request +with open('image.png', 'rb') as f: + image_buffer = f.read() + +sock.send(packb({ + 'method': 'predict', + 'args': [[image_buffer]], + 'kwargs': {} +})) + +# Receive response +result = unpackb(sock.recv()) +print(result) +``` + +## Directory Structure + +``` +python-services/ +├── common/ +│ ├── __init__.py +│ ├── zero_server.py # ZeroMQ server +│ ├── image_utils.py # Image processing utilities +│ └── transform.py # Data transformation pipeline +├── predictors/ +│ ├── __init__.py +│ ├── torchscript_predictor.py # PyTorch loader +│ └── tensorflow_predictor.py # TensorFlow loader +├── services/ +│ ├── __init__.py +│ ├── layout_service.py +│ ├── mask_service.py +│ ├── semantic_service.py +│ ├── gauge_service.py +│ ├── loc_service.py +│ ├── ocr_service.py +│ └── brackets_service.py +├── config/ +│ └── semantic.yaml # Example configuration +├── scripts/ +│ ├── export_torchscript.py +│ └── export_tensorflow.py +├── main.py # Unified entry point +├── requirements.txt +└── README.md +``` + +## Docker Deployment + +### Prerequisites + +1. Docker with NVIDIA GPU support (nvidia-docker2 / nvidia-container-toolkit) +2. User must be in the `docker` group: + ```bash + sudo usermod -aG docker $USER + # Re-login to apply group membership + ``` + +### Quick Start + +```bash +cd backend/python-services + +# Build all-in-one image +docker build -f Dockerfile --target all-in-one -t starry-ml:latest ../../.. + +# Run layout service (example) +docker run --gpus all -p 12022:12022 \ + -v /path/to/models/starry-dist:/models/starry-dist:ro \ + -v /path/to/deep-starry:/app/deep-starry:ro \ + starry-ml:latest \ + python /app/deep-starry/streamPredictor.py \ + /models/starry-dist/20221125-scorelayout-1121-residue-u-d4-w64-d4-w64 \ + -p 12022 -dv cuda -m layout +``` + +### Using Docker Compose + +```bash +# Test single service +docker compose -f docker-compose.test.yml up layout + +# Production: all services +docker compose up -d +``` + +### Model Volumes + +Mount the following directories to the container: +- `starry-dist/` - PyTorch model weights (layout, mask, semantic, gauge) +- `ocr-dist/` - TensorFlow/PyTorch weights (loc, ocr, brackets) + +### Build Targets + +The Dockerfile provides multiple build targets: + +| Target | Description | Size | +|--------|-------------|------| +| `pytorch-services` | PyTorch only (layout, mask, semantic, gauge) | ~5GB | +| `tensorflow-services` | TensorFlow only (ocr, brackets) | ~4GB | +| `all-in-one` | Both frameworks (all services) | ~9GB | + +### Example Dockerfile (lightweight) + +## Protocol + +Communication uses ZeroMQ REP/REQ pattern with MessagePack serialization. + +### Request Format + +```python +{ + 'method': 'predict', + 'args': [[buffer1, buffer2, ...]], # List of image byte buffers + 'kwargs': {} # Optional keyword arguments +} +``` + +### Response Format + +```python +{ + 'code': 0, # 0 for success, -1 for error + 'msg': 'success', + 'data': [...] # List of prediction results +} +``` + +## Notes + +1. **TorchScript Compatibility**: Some dynamic operations may not be supported. Test models after export. + +2. **Preprocessing Consistency**: Ensure preprocessing matches the original implementation exactly. + +3. **TensorFlow Version**: SavedModel format requires compatible TF version for loading. + +4. **GPU Memory**: TensorFlow models use memory growth to prevent OOM. Configure as needed. diff --git a/backend/python-services/common/__init__.py b/backend/python-services/common/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..5c0eb65a969aa7cad88b43c3daa9f5c7d1e27451 --- /dev/null +++ b/backend/python-services/common/__init__.py @@ -0,0 +1 @@ +# Common utilities for python-services diff --git a/backend/python-services/common/image_utils.py b/backend/python-services/common/image_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..b7d3d9cadbe36d229d953507eb3d43583ac45f18 --- /dev/null +++ b/backend/python-services/common/image_utils.py @@ -0,0 +1,185 @@ +""" +Image processing utilities for ML services. +""" + +import io +import math +import base64 +import numpy as np +import cv2 +import PIL.Image + + +MARGIN_DIVIDER = 8 + + +def array_from_image_stream(buffer): + """Convert image bytes to numpy array (H, W, C).""" + if not isinstance(buffer, bytes): + return None + + stream = io.BytesIO(buffer) + image = PIL.Image.open(stream) + + arr = np.array(image) + if len(arr.shape) >= 3: + return arr[:, :, :3] # RGB only + + arr = np.expand_dims(arr, -1) + return arr + + +def slice_feature(source, width, overlapping=0.25, padding=False): + """ + Slice image horizontally into overlapping pieces. + source: (height, width, channel) + yields: (height, width, channel) pieces + """ + step = math.floor(width - source.shape[0] * overlapping) + + if padding: + margin = math.floor(source.shape[0] * overlapping) // 2 + center = source + source = np.zeros((source.shape[0], source.shape[1] + margin * 2, source.shape[2])) + source[:, margin:-margin, :] = center + source[:, :margin, :] = center[:, :1, :] + source[:, -margin:, :] = center[:, -1:, :] + + for x in range(0, source.shape[1], step): + if x + width <= source.shape[1]: + yield source[:, x:x + width, :] + else: + sliced = np.ones((source.shape[0], width, source.shape[2]), dtype=np.float32) * 255 + sliced[:, :source.shape[1] - x, :] = source[:, x:, :] + yield sliced + + +def splice_pieces(pieces, margin_divider, keep_margin=False): + """ + Splice output tensor pieces back together. + pieces: (batch, channel, height, width) + returns: (channel, height, width) + """ + piece_height, piece_width = pieces.shape[2:] + margin_width = piece_height // margin_divider + patch_width = piece_width - margin_width * 2 + result = np.zeros((pieces.shape[1], pieces.shape[2], patch_width * pieces.shape[0]), dtype=np.float32) + + for i, piece in enumerate(pieces): + result[:, :, i * patch_width : (i + 1) * patch_width] = piece[:, :, margin_width:-margin_width] + + if keep_margin: + return np.concatenate((pieces[0, :, :, :margin_width], result, pieces[-1, :, :, -margin_width:]), axis=2) + + return result + + +def soft_splice_pieces(pieces, margin_divider): + """ + Splice pieces with soft blending at overlaps. + pieces: (batch, channel, height, width) + returns: (channel, height, width) + """ + batches, channels, piece_height, piece_width = pieces.shape + overlap_width = piece_height * 2 // margin_divider + segment_width = piece_width - overlap_width + + slope = np.arange(overlap_width, dtype=np.float32) / overlap_width + slope = slope.reshape((1, 1, overlap_width)) + inv_slope = 1 - slope + + result = np.zeros((channels, piece_height, segment_width * batches + overlap_width), dtype=np.float32) + + for i, piece in enumerate(pieces): + if i > 0: + piece[:, :, :overlap_width] *= slope + + if i < batches - 1: + piece[:, :, -overlap_width:] *= inv_slope + + result[:, :, segment_width * i:segment_width * i + piece_width] += piece + + return result + + +def splice_output_tensor(tensor, keep_margin=False, soft=False, margin_divider=MARGIN_DIVIDER): + """ + Splice PyTorch tensor output back together. + tensor: PyTorch tensor or numpy array + """ + if tensor is None: + return None + + arr = tensor.cpu().numpy() if hasattr(tensor, 'cpu') else tensor + + if soft: + return soft_splice_pieces(arr, margin_divider) + + return splice_pieces(arr, margin_divider, keep_margin=keep_margin) + + +def mask_to_alpha(mask, frac_y=False): + """ + Convert mask to LA (grayscale + alpha) format. + mask: [fore(h, w), back(h, w)] + """ + fore = mask[0] * 255 + fore = np.stack([np.zeros(mask[0].shape, np.float32), fore], axis=2) + fore = np.uint8(np.clip(fore, 0, 255)) + return fore + + +def gauge_to_rgb(gauge, frac_y=False): + """ + Convert gauge map to RGB. + gauge: [Y(h, w), K(h, w)] + """ + mapy = gauge[0] * 8 + 128 + mapk = gauge[1] * 127 + 128 + + if frac_y: + B, R = np.modf(mapy) + result = np.stack([B * 256, mapk, R], axis=2) + else: + result = np.stack([np.zeros(mapy.shape, np.float32), mapk, mapy], axis=2) + + return np.uint8(np.clip(result, 0, 255)) + + +def encode_image_bytes(image, ext='.png', quality=80): + """Encode PIL Image to bytes.""" + fp = io.BytesIO() + image.save(fp, PIL.Image.registered_extensions()[ext], quality=quality) + return fp.getvalue() + + +def encode_image_base64(image, ext='.png', quality=80): + """Encode PIL Image to base64 data URI.""" + image_bytes = encode_image_bytes(image, ext, quality=quality) + b64 = base64.b64encode(image_bytes) + fmt = ext.replace('.', '') + return f'data:image/{fmt};base64,' + b64.decode('ascii') + + +def resize_page_image(img, size): + """Resize page image maintaining aspect ratio, padding with white.""" + w, h = size + filled_height = img.shape[0] * w // img.shape[1] + img = cv2.resize(img, (w, filled_height), interpolation=cv2.INTER_AREA) + if len(img.shape) < 3: + img = np.expand_dims(img, -1) + + if filled_height < h: + result = np.ones((h, w, img.shape[2]), dtype=np.uint8) * 255 + result[:filled_height] = img + return result + + return img[:h] + + +def normalize_image_dimension(image): + """Ensure image dimensions are divisible by 4 (for UNet).""" + n, h, w, c = image.shape + if (h % 4 != 0) | (w % 4 != 0): + return image[:, :h - h % 4, :w - w % 4, :] + return image diff --git a/backend/python-services/common/transform.py b/backend/python-services/common/transform.py new file mode 100644 index 0000000000000000000000000000000000000000..16defa057c99b043aefb74259be79cd129429d60 --- /dev/null +++ b/backend/python-services/common/transform.py @@ -0,0 +1,141 @@ +""" +Data transformation pipeline for model preprocessing. +""" + +import numpy as np +import cv2 + + +def half_down(feature, label): + """Downsample feature by 2x using pyrDown.""" + h, w, c = feature.shape[-3:] + h = h // 2 + w = w // 2 + b = feature.shape[0] + down = np.zeros((b, h, w, c), dtype=feature.dtype) + for i in range(b): + down[i] = cv2.pyrDown(feature[i]).reshape((h, w, c)) + return down, label + + +def mono(feature, label): + """Convert to grayscale and normalize to 0-1.""" + monos = [] + for temp in feature: + gray = temp + if len(temp.shape) == 3: + if temp.shape[2] == 3: + gray = cv2.cvtColor(temp, cv2.COLOR_RGB2GRAY) + gray = np.expand_dims(gray, -1) + gray = (gray / 255.0).astype(np.float32) + elif gray.dtype == np.uint8: + gray = (gray / 255.0).astype(np.float32) + monos.append(gray) + return np.stack(monos), label + + +def normalize(feature, label): + """Normalize uint8 to float32 0-1.""" + result = [] + for temp in feature: + layer = (temp / 255.0).astype(np.float32) + result.append(layer) + return np.stack(result), label + + +def invert(feature, label): + """Invert colors.""" + return 1 - feature, label + + +def img_std_nor(feature, label): + """ImageNet standard normalization.""" + mean = np.array([0.485, 0.456, 0.406], dtype=np.float32) + std = np.array([0.229, 0.224, 0.225], dtype=np.float32) + feature = feature.astype(np.float32) + feature = (feature / 255.0 - mean) / std + return feature, label + + +def hwc2chw(feature, label): + """Convert (N, H, W, C) to (N, C, H, W).""" + feature = np.moveaxis(feature, -1, 1) + return feature, label + + +def to_float32(feature, label): + """Convert to float32.""" + return feature.astype(np.float32), label + + +class TransWrapper: + def __init__(self, fn): + self.trans_fn = fn + + def __call__(self, feature, label): + return self.trans_fn(feature, label) + + +class Half_Down(TransWrapper): + def __init__(self): + super().__init__(half_down) + + +class Img_std_N(TransWrapper): + def __init__(self): + super().__init__(img_std_nor) + + +class Mono(TransWrapper): + def __init__(self): + super().__init__(mono) + + +class Normalize(TransWrapper): + def __init__(self): + super().__init__(normalize) + + +class Invert(TransWrapper): + def __init__(self): + super().__init__(invert) + + +class HWC2CHW(TransWrapper): + def __init__(self): + super().__init__(hwc2chw) + + +class To_Float32(TransWrapper): + def __init__(self): + super().__init__(to_float32) + + +class TransformFactory: + def __init__(self): + trans_classes = [ + Half_Down, Img_std_N, HWC2CHW, + To_Float32, Mono, Normalize, Invert, + ] + self.trans_dict = {c.__name__: c() for c in trans_classes} + + def get_transfn(self, name): + return self.trans_dict.get(name) + + +transform_factory = TransformFactory() + + +class Composer: + """Compose multiple transforms into a pipeline.""" + + def __init__(self, trans): + self.trans_name = trans + + def __call__(self, feature, target): + newf, newl = feature, target + for name in self.trans_name: + trans = transform_factory.get_transfn(name) + if trans: + newf, newl = trans(newf, newl) + return newf, newl diff --git a/backend/python-services/common/zero_server.py b/backend/python-services/common/zero_server.py new file mode 100644 index 0000000000000000000000000000000000000000..7b2fb5d66dc0cfcccf9665bb391703733394adf3 --- /dev/null +++ b/backend/python-services/common/zero_server.py @@ -0,0 +1,60 @@ +import sys +import logging +import zmq +import types +from msgpack import unpackb, packb +from operator import methodcaller +import traceback + + +class ZeroServer: + def __init__(self, obj): + self.obj = obj + context = zmq.Context() + self.socket = context.socket(zmq.REP) + + def __del__(self): + self.socket.close() + + def res_success(self, ret): + self.socket.send(packb({ + 'code': 0, + 'msg': 'success', + 'data': ret + }, use_bin_type=True)) + + def res_error(self, err_type=None): + err_info = sys.exc_info() + err_msg = f"{str(err_info[0])} {str(err_info[1])} \n {''.join(traceback.format_tb(err_info[2]))}" + self.socket.send(packb({ + 'code': -1, + 'msg': (err_type and (err_type + '\n\n')) + err_msg + }, use_bin_type=True)) + + logging.error('[ZeroServer.res_error] %s\n%s', err_type, err_msg) + + def bind(self, port): + address = f'tcp://*:{port}' + self.socket.bind(address) + logging.info('ZeroServer is online: %s', address) + + while True: + logging.info('Waiting for request...') + buf = self.socket.recv() + try: + logging.info('Got request.') + msg = unpackb(buf, raw=False, use_list=False) + + method = msg.get('method') + args = msg.get('args', []) + kwargs = msg.get('kwargs', {}) + + try: + ret = methodcaller(method, *args, **kwargs)(self.obj) + ret = [*ret] if isinstance(ret, types.GeneratorType) else ret + self.res_success(ret) + logging.info('Response sent.') + except: + self.res_error('Server handler error:') + except: + self.res_error('Parse request params error:') diff --git a/backend/python-services/config/semantic.yaml b/backend/python-services/config/semantic.yaml new file mode 100644 index 0000000000000000000000000000000000000000..35d9019576ad82fb5cf7e18a687c7f8033a85f7c --- /dev/null +++ b/backend/python-services/config/semantic.yaml @@ -0,0 +1,92 @@ +# Semantic service configuration +# This file should contain the labels from the original scorewidgets model + +# Example labels (77-class model) +# Update this list based on your actual model configuration +labels: + - ClefG + - ClefF + - ClefC + - ClefG8va + - ClefG8vb + - ClefF8va + - ClefF8vb + - NoteheadS0 + - NoteheadS1 + - NoteheadS2 + - Rest0 + - Rest1 + - Rest2 + - Rest3 + - Rest4 + - Rest5 + - Rest6 + - Rest7 + - Dot + - Augmentation + - Accidental1 + - Accidental2 + - Accidental3 + - Accidental4 + - Accidental5 + - Tuplet3 + - Tuplet5 + - Tuplet6 + - Tuplet7 + - Tuplet9 + - Ornament1 + - Ornament2 + - Ornament3 + - Ornament4 + - Ornament5 + - Ornament6 + - Articulation1 + - Articulation2 + - Articulation3 + - Articulation4 + - Articulation5 + - Articulation6 + - Articulation7 + - Articulation8 + - Dynamic1 + - Dynamic2 + - Dynamic3 + - Dynamic4 + - Dynamic5 + - Dynamic6 + - Dynamic7 + - Dynamic8 + - TimeSig_C + - TimeSig_C2 + - TimeSig_N + - KeySig + - Clef8Line + - Fermata + - Breath + - Caesura + - GraceNote + - Arpeggio + - Glissando + - Pedal1 + - Pedal2 + - Pedal3 + - Ottava + - vline_BarMeasure + - vline_BarDouble + - vline_BarFinal + - vline_BarRepeatL + - vline_BarRepeatR + - vline_BarDashed + - vline_BarTick + - vline_BarShort + - rect_Text + - box_SystemBracket + - box_PartBrace + +# Transform pipeline +trans: + - Mono + - HWC2CHW + +# Slicing width for inference +slicing_width: 512 diff --git a/backend/python-services/docker-compose.test.yml b/backend/python-services/docker-compose.test.yml new file mode 100644 index 0000000000000000000000000000000000000000..a24ba7c91e14d31703364cda1c095463dcbba0ec --- /dev/null +++ b/backend/python-services/docker-compose.test.yml @@ -0,0 +1,157 @@ +# STARRY ML Services - Test Docker Compose +# +# Simplified configuration for testing individual services. +# Uses a single all-in-one image to minimize build time. +# +# Usage: +# docker compose -f docker-compose.test.yml build +# docker compose -f docker-compose.test.yml up layout +# docker compose -f docker-compose.test.yml up ocr + +services: + layout: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-layout-test + ports: + - "12022:12022" + volumes: + - /home/camus/data/models/starry/starry-dist:/models/starry-dist:ro + - /home/camus/work/deep-starry:/app/deep-starry:ro + environment: + - CUDA_VISIBLE_DEVICES=0 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + working_dir: /app/deep-starry + command: > + python streamPredictor.py + /models/starry-dist/20221125-scorelayout-1121-residue-u-d4-w64-d4-w64 + -p 12022 -dv cuda -m layout + + mask: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-mask-test + ports: + - "12024:12024" + volumes: + - /home/camus/data/models/starry/starry-dist:/models/starry-dist:ro + - /home/camus/work/deep-starry:/app/deep-starry:ro + environment: + - CUDA_VISIBLE_DEVICES=0 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + working_dir: /app/deep-starry + command: > + python streamPredictor.py + /models/starry-dist/20210918-scorewidgets.mask-unet-5-32 + -p 12024 -dv cuda -m mask + + semantic: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-semantic-test + ports: + - "12025:12025" + volumes: + - /home/camus/data/models/starry/starry-dist:/models/starry-dist:ro + - /home/camus/work/deep-starry:/app/deep-starry:ro + environment: + - CUDA_VISIBLE_DEVICES=0 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + working_dir: /app/deep-starry + command: > + python streamPredictor.py + /models/starry-dist/202302-semanticCluster + -p 12025 -dv cuda -m semanticCluster + + loc: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-loc-test + ports: + - "12026:12026" + volumes: + - /home/camus/data/models/starry/ocr-dist:/models/ocr-dist:ro + - /home/camus/work/starry-ocr:/app/starry-ocr:ro + environment: + - CUDA_VISIBLE_DEVICES=0 + - LOG_DIR=/tmp/starry-logs + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + working_dir: /app/starry-ocr + command: > + python locPredictor.py + -w /models/ocr-dist/DB_gc_loc/v6/model_epoch_88_minibatch_15300 + -p 12026 -dv cuda + + ocr: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-ocr-test + ports: + - "12027:12027" + volumes: + - /home/camus/data/models/starry/ocr-dist:/models/ocr-dist:ro + - /home/camus/work/starry-ocr:/app/starry-ocr:ro + environment: + - CUDA_VISIBLE_DEVICES=-1 + - TF_USE_LEGACY_KERAS=1 + - LOG_DIR=/tmp/starry-logs + working_dir: /app/starry-ocr + command: > + python ocrPredictor.py + /models/ocr-dist/ocr.yaml + -p 12027 + + brackets: + build: + context: ../../.. + dockerfile: backend/python-services/Dockerfile + target: all-in-one + container_name: starry-brackets-test + ports: + - "12028:12028" + volumes: + - /home/camus/data/models/starry/ocr-dist:/models/ocr-dist:ro + - /home/camus/work/starry-ocr:/app/starry-ocr:ro + environment: + - CUDA_VISIBLE_DEVICES=-1 + - TF_USE_LEGACY_KERAS=1 + - LOG_DIR=/tmp/starry-logs + working_dir: /app/starry-ocr + command: > + python bracketsPredictor.py + /models/ocr-dist/brackets.yaml + -p 12028 diff --git a/backend/python-services/docker-compose.yml b/backend/python-services/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..0d78ce8134d72db226762c41c46b049e2d4eeed1 --- /dev/null +++ b/backend/python-services/docker-compose.yml @@ -0,0 +1,152 @@ +# STARRY Python ML Services - Docker Compose +# +# Setup: +# ./gen-env.sh /path/to/models # Generate .env from models.yaml +# docker compose up -d # Start all services +# docker compose up layout semantic ocr # Start specific services +# docker compose logs -f layout # Follow logs for a service + +x-common-settings: &common-settings + restart: unless-stopped + networks: + - starry-ml + +x-pytorch-service: &pytorch-service + <<: *common-settings + image: starry-pytorch:test + volumes: + - ${DEEP_STARRY_PATH:-/home/camus/work/deep-starry}:/app/deep-starry:ro + - ${MODELS_ROOT}/starry-dist:/models/starry-dist:ro + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + +x-tensorflow-service: &tensorflow-service + <<: *common-settings + image: starry-tensorflow:test + volumes: + - ${STARRY_OCR_PATH:-/home/camus/work/starry-ocr}:/app/starry-ocr:ro + - ${MODELS_ROOT}/ocr-dist:/models/ocr-dist:ro + - /tmp/starry-logs:/tmp/starry-logs + environment: + - TF_USE_LEGACY_KERAS=1 + - LOG_DIR=/tmp/starry-logs + +services: + # ============================================================ + # PyTorch Services (GPU) + # ============================================================ + + layout: + <<: *pytorch-service + container_name: starry-layout + ports: + - "12022:12022" + environment: + - CUDA_VISIBLE_DEVICES=0 + command: > + python /app/deep-starry/streamPredictor.py + /models/starry-dist/${LAYOUT_MODEL_PATH} + -p 12022 -dv cuda -m layout + + mask: + <<: *pytorch-service + container_name: starry-mask + ports: + - "12024:12024" + environment: + - CUDA_VISIBLE_DEVICES=0 + command: > + python /app/deep-starry/streamPredictor.py + /models/starry-dist/${MASK_MODEL_PATH} + -p 12024 -dv cuda -m mask + + semantic: + <<: *pytorch-service + container_name: starry-semantic + ports: + - "12025:12025" + environment: + - CUDA_VISIBLE_DEVICES=0 + command: > + python /app/deep-starry/streamPredictor.py + /models/starry-dist/${SEMANTIC_MODEL_PATH} + -p 12025 -dv cuda -m semanticCluster + + gauge: + <<: *pytorch-service + container_name: starry-gauge + ports: + - "12023:12023" + environment: + - CUDA_VISIBLE_DEVICES=0 + command: > + python /app/deep-starry/streamPredictor.py + /models/starry-dist/${GAUGE_MODEL_PATH} + -p 12023 -dv cuda -m gauge + + # ============================================================ + # TensorFlow Services (CPU) + # ============================================================ + + loc: + <<: *common-settings + image: starry-all:test + container_name: starry-loc + ports: + - "12026:12026" + volumes: + - ${STARRY_OCR_PATH:-/home/camus/work/starry-ocr}:/app/starry-ocr + - ${MODELS_ROOT}/ocr-dist:/models/ocr-dist:ro + - /tmp/starry-logs:/tmp/starry-logs + working_dir: /app/starry-ocr + environment: + - CUDA_VISIBLE_DEVICES=0 + - LOG_DIR=/tmp/starry-logs + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + command: > + python locPredictor.py + -w /models/ocr-dist/${LOC_MODEL_PATH} + -p 12026 -dv cuda + + ocr: + <<: *tensorflow-service + container_name: starry-ocr + ports: + - "12027:12027" + environment: + - CUDA_VISIBLE_DEVICES=-1 + - TF_USE_LEGACY_KERAS=1 + - LOG_DIR=/tmp/starry-logs + command: > + python /app/starry-ocr/ocrPredictor.py + /models/ocr-dist/${OCR_CONFIG} + -p 12027 + + brackets: + <<: *tensorflow-service + container_name: starry-brackets + ports: + - "12028:12028" + environment: + - CUDA_VISIBLE_DEVICES=-1 + - TF_USE_LEGACY_KERAS=1 + - LOG_DIR=/tmp/starry-logs + command: > + python /app/starry-ocr/bracketsPredictor.py + /models/ocr-dist/${BRACKETS_CONFIG} + -p 12028 + +networks: + starry-ml: + driver: bridge diff --git a/backend/python-services/gen-env.sh b/backend/python-services/gen-env.sh new file mode 100755 index 0000000000000000000000000000000000000000..215f5ba74015f84af3bd362cd9640df9bae44864 --- /dev/null +++ b/backend/python-services/gen-env.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# Parse models.yaml and generate .env for docker-compose +# Usage: ./gen-env.sh [MODELS_ROOT] +# MODELS_ROOT defaults to $MODELS_ROOT env var + +MODELS_ROOT="${1:-${MODELS_ROOT:-}}" +if [ -z "$MODELS_ROOT" ]; then + echo "Usage: ./gen-env.sh " >&2 + echo " or set MODELS_ROOT env var" >&2 + exit 1 +fi + +YAML="$MODELS_ROOT/starry-dist/models.yaml" +if [ ! -f "$YAML" ]; then + echo "Error: $YAML not found" >&2 + exit 1 +fi + +ENV_FILE="$(dirname "$0")/.env" + +# Extract values by parsing the simple YAML structure +# Each top-level key block: read path/config fields +current_key="" +{ + echo "# Auto-generated from models.yaml — do not edit manually" + echo "# Regenerate with: ./gen-env.sh $MODELS_ROOT" + echo "" + echo "MODELS_ROOT=$MODELS_ROOT" + + while IFS= read -r line; do + # Skip comments and empty lines + case "$line" in \#*|"") continue ;; esac + + # Top-level key (no leading whitespace) + if echo "$line" | grep -qE '^[a-z][a-z0-9_]*:'; then + current_key=$(echo "$line" | sed 's/:.*//' | tr 'a-z' 'A-Z') + continue + fi + + [ -z "$current_key" ] && continue + + # Extract path: value + val=$(echo "$line" | sed -n 's/^ *path: *//p') + if [ -n "$val" ]; then + echo "${current_key}_MODEL_PATH=$val" + fi + + # Extract config: value + val=$(echo "$line" | sed -n 's/^ *config: *//p') + if [ -n "$val" ]; then + echo "${current_key}_CONFIG=$val" + fi + done < "$YAML" +} > "$ENV_FILE" + +echo "Generated $ENV_FILE" +cat "$ENV_FILE" diff --git a/backend/python-services/main.py b/backend/python-services/main.py new file mode 100644 index 0000000000000000000000000000000000000000..7b4d30b1abe63bb485b2bd3174e2e19f920378e8 --- /dev/null +++ b/backend/python-services/main.py @@ -0,0 +1,312 @@ +#!/usr/bin/env python3 +""" +Unified entry point for STARRY ML prediction services. + +Usage: + python main.py -m layout -w models/layout.pt -p 12022 -dv cuda + python main.py -m semantic -w models/semantic.pt -p 12025 -dv cuda --config config.yaml + +Available modes: + layout - Page layout detection (port 12022) + mask - Staff mask generation (port 12024) + semantic - Symbol semantic detection (port 12025) + gauge - Staff gauge prediction (port 12023) + loc - Text location detection (port 12026) + ocr - Text recognition (port 12027) + brackets - Bracket recognition (port 12028) +""" + +import argparse +import importlib +import logging +import yaml +import os + + +# Service class mapping +SERVICE_MAP = { + 'layout': 'services.layout_service.LayoutService', + 'mask': 'services.mask_service.MaskService', + 'semantic': 'services.semantic_service.SemanticService', + 'gauge': 'services.gauge_service.GaugeService', + 'loc': 'services.loc_service.LocService', + 'ocr': 'services.ocr_service.OcrService', + 'brackets': 'services.brackets_service.BracketsService', +} + +# Default ports +DEFAULT_PORTS = { + 'layout': 12022, + 'gauge': 12023, + 'mask': 12024, + 'semantic': 12025, + 'loc': 12026, + 'ocr': 12027, + 'brackets': 12028, +} + + +def import_class(class_path): + """Dynamically import a class from module path.""" + module_path, class_name = class_path.rsplit('.', 1) + module = importlib.import_module(module_path) + return getattr(module, class_name) + + +def load_config(config_path): + """Load configuration from YAML file.""" + if config_path and os.path.exists(config_path): + with open(config_path, 'r', encoding='utf-8') as f: + return yaml.safe_load(f) + return {} + + +def resolve_ocr_config(yaml_path): + """Parse OCR/brackets config YAML and resolve model/alphabet paths. + + The config YAML may contain: + generalOCR_weight_path, generalOCR_alphabet_path, + temponumOCR_weight_path, temponumOCR_alphabet_path, + bracket_weight_path, bracket_alphabet_path, + chord_config_weight_path + Paths are relative to the YAML file's directory. + """ + base_dir = os.path.dirname(os.path.abspath(yaml_path)) + with open(yaml_path, 'r', encoding='utf-8') as f: + cfg = yaml.safe_load(f) or {} + + def abs_path(rel): + if rel and not os.path.isabs(rel): + return os.path.join(base_dir, rel) + return rel + + def read_alphabet(path): + if path and os.path.exists(path): + with open(path, 'r', encoding='utf-8') as f: + return f.readline().strip() + return None + + result = {} + + # General OCR model + gen_weight = abs_path(cfg.get('generalOCR_weight_path')) + if not gen_weight: + # Auto-detect h5 model file alongside alphabet + alpha_path = abs_path(cfg.get('generalOCR_alphabet_path')) + if alpha_path: + alpha_dir = os.path.dirname(alpha_path) + h5_files = [f for f in os.listdir(alpha_dir) if f.endswith('.h5')] + if h5_files: + gen_weight = os.path.join(alpha_dir, h5_files[0]) + if gen_weight: + result['model_path'] = gen_weight + + gen_alpha = abs_path(cfg.get('generalOCR_alphabet_path')) + alpha = read_alphabet(gen_alpha) + if alpha: + result['alphabet'] = alpha + + # Tempo numeral model + tempo_weight = abs_path(cfg.get('temponumOCR_weight_path')) + if tempo_weight: + result['tempo_model_path'] = tempo_weight + tempo_alpha_path = abs_path(cfg.get('temponumOCR_alphabet_path')) + tempo_alpha = read_alphabet(tempo_alpha_path) + if tempo_alpha: + result['tempo_alphabet'] = tempo_alpha + + # Chord model + chord_weight = abs_path(cfg.get('chord_config_weight_path')) + if chord_weight: + result['chord_model_path'] = chord_weight + + return result + + +def resolve_brackets_config(yaml_path): + """Parse brackets config YAML and resolve model/alphabet paths.""" + base_dir = os.path.dirname(os.path.abspath(yaml_path)) + with open(yaml_path, 'r', encoding='utf-8') as f: + cfg = yaml.safe_load(f) or {} + + def abs_path(rel): + if rel and not os.path.isabs(rel): + return os.path.join(base_dir, rel) + return rel + + result = {} + + bracket_weight = abs_path(cfg.get('bracket_weight_path')) + if bracket_weight: + result['model_path'] = bracket_weight + + bracket_alpha_path = abs_path(cfg.get('bracket_alphabet_path')) + if bracket_alpha_path and os.path.exists(bracket_alpha_path): + with open(bracket_alpha_path, 'r', encoding='utf-8') as f: + result['alphabet'] = f.readline().strip() + + return result + + +def setup_logging(mode, level='INFO'): + """Configure logging.""" + logging.basicConfig( + level=getattr(logging, level.upper()), + format=f'[%(asctime)s] [{mode}] %(levelname)s: %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + ) + + +def main(): + parser = argparse.ArgumentParser( + description='STARRY ML prediction service', + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=__doc__ + ) + + parser.add_argument( + '-m', '--mode', + type=str, + required=True, + choices=list(SERVICE_MAP.keys()), + help='Service mode to run' + ) + parser.add_argument( + '-w', '--weights', + type=str, + required=True, + help='Path to model weights file (TorchScript .pt or SavedModel directory)' + ) + parser.add_argument( + '-p', '--port', + type=int, + default=None, + help='ZeroMQ server port (default: mode-specific)' + ) + parser.add_argument( + '-dv', '--device', + type=str, + default='cuda', + help='Device to use: cuda or cpu (default: cuda)' + ) + parser.add_argument( + '--config', + type=str, + default=None, + help='Path to service configuration YAML file' + ) + parser.add_argument( + '--log-level', + type=str, + default='INFO', + choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'], + help='Logging level (default: INFO)' + ) + + # Service-specific arguments + parser.add_argument( + '--slicing-width', + type=int, + default=512, + help='Slicing width for mask/semantic/gauge services' + ) + parser.add_argument( + '--labels', + type=str, + nargs='+', + default=None, + help='Semantic labels (for semantic service)' + ) + parser.add_argument( + '--image-short-side', + type=int, + default=736, + help='Image short side for loc service' + ) + parser.add_argument( + '--alphabet', + type=str, + default=None, + help='Character alphabet file for OCR/brackets services' + ) + + args = parser.parse_args() + + # Setup logging + setup_logging(args.mode, args.log_level) + + # Load config if provided + config = load_config(args.config) + + # Determine port + port = args.port or DEFAULT_PORTS.get(args.mode, 12020) + + # Get service class + if args.mode not in SERVICE_MAP: + logging.error('Unknown service mode: %s', args.mode) + return 1 + + ServiceClass = import_class(SERVICE_MAP[args.mode]) + + # Build service kwargs + service_kwargs = { + 'model_path': args.weights, + 'device': args.device, + } + + # Handle OCR/brackets YAML config passed via -w + if args.mode == 'ocr' and args.weights.endswith('.yaml'): + logging.info('Resolving OCR config from: %s', args.weights) + ocr_cfg = resolve_ocr_config(args.weights) + service_kwargs.update(ocr_cfg) + elif args.mode == 'brackets' and args.weights.endswith('.yaml'): + logging.info('Resolving brackets config from: %s', args.weights) + br_cfg = resolve_brackets_config(args.weights) + service_kwargs.update(br_cfg) + + # Add service-specific kwargs + if args.mode in ['mask', 'semantic', 'gauge']: + service_kwargs['slicing_width'] = args.slicing_width + + if args.mode == 'semantic': + if args.labels: + service_kwargs['labels'] = args.labels + elif 'labels' in config: + service_kwargs['labels'] = config['labels'] + + if args.mode == 'loc': + service_kwargs['image_short_side'] = args.image_short_side + + if args.mode in ['ocr', 'brackets'] and not args.weights.endswith('.yaml'): + if args.alphabet: + with open(args.alphabet, 'r', encoding='utf-8') as f: + service_kwargs['alphabet'] = f.readline().strip() + elif 'alphabet' in config: + service_kwargs['alphabet'] = config['alphabet'] + + # Merge config + for key, value in config.items(): + if key not in service_kwargs: + service_kwargs[key] = value + + # Create service instance + logging.info('Initializing %s service...', args.mode) + logging.info('Model path: %s', args.weights) + logging.info('Device: %s', args.device) + + try: + service = ServiceClass(**service_kwargs) + except Exception as e: + logging.error('Failed to initialize service: %s', str(e)) + raise + + # Start ZeroMQ server + from common.zero_server import ZeroServer + + logging.info('Starting ZeroMQ server on port %d...', port) + server = ZeroServer(service) + server.bind(port) + + +if __name__ == '__main__': + main() diff --git a/backend/python-services/predictors/__init__.py b/backend/python-services/predictors/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..703d5be123e99c74022cc0b392ff6dc7931483b8 --- /dev/null +++ b/backend/python-services/predictors/__init__.py @@ -0,0 +1 @@ +# Predictors module - model loading and inference diff --git a/backend/python-services/predictors/densenet_ctc.py b/backend/python-services/predictors/densenet_ctc.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9b86f0b87c28990760777843b7f5e2c08ce416 --- /dev/null +++ b/backend/python-services/predictors/densenet_ctc.py @@ -0,0 +1,180 @@ +""" +DenseNet-CTC model builder for OCR/brackets recognition. + +Ports the DenseNet-CTC architecture from starry-ocr to TF 2.x Keras. +Builds the model graph, loads weights-only .h5 files, and provides +numpy-based CTC greedy decoding (no tf.Session needed). +""" + +import os +import logging +import numpy as np + +os.environ.setdefault('TF_USE_LEGACY_KERAS', '1') + +import tensorflow as tf + +# Default architecture config (matches starry-ocr training) +DEFAULT_DENSENET_CONFIG = { + 'first_conv_filters': 64, + 'first_conv_size': 5, + 'first_conv_stride': 2, + 'dense_block_layers': [8, 8, 8], + 'dense_block_growth_rate': 8, + 'trans_block_filters': 128, + 'first_pool_size': 0, + 'first_pool_stride': 2, + 'last_conv_size': 0, + 'last_conv_filters': 0, + 'last_pool_size': 2, +} + +DEFAULT_IMAGE_CONFIG = { + 'height': 32, + 'channel': 1, +} + + +def _conv_block(x, growth_rate): + """Single dense block convolution: BN → ReLU → Conv2D(3×3).""" + x = tf.keras.layers.BatchNormalization(axis=-1, epsilon=1.1e-5)(x) + x = tf.keras.layers.Activation('relu')(x) + x = tf.keras.layers.Conv2D(growth_rate, (3, 3), kernel_initializer='he_normal', padding='same')(x) + return x + + +def _dense_block(x, nb_layers, nb_filter, growth_rate): + """Dense block: stack of conv_blocks with concatenation.""" + for _ in range(nb_layers): + cb = _conv_block(x, growth_rate) + x = tf.keras.layers.Concatenate()([x, cb]) + nb_filter += growth_rate + return x, nb_filter + + +def _transition_block(x, nb_filter, weight_decay=1e-4): + """Transition block: BN → ReLU → 1×1 Conv → AvgPool(2×2).""" + x = tf.keras.layers.BatchNormalization(axis=-1, epsilon=1.1e-5)(x) + x = tf.keras.layers.Activation('relu')(x) + x = tf.keras.layers.Conv2D( + nb_filter, (1, 1), kernel_initializer='he_normal', padding='same', + use_bias=False, kernel_regularizer=tf.keras.regularizers.l2(weight_decay) + )(x) + x = tf.keras.layers.AveragePooling2D((2, 2), strides=(2, 2))(x) + return x, nb_filter + + +def build_densenet_ctc(nclass, cfg=None, img_cfg=None): + """ + Build the DenseNet-CTC model matching the starry-ocr architecture. + + Returns a Keras Model: input (B, H, W?, 1) → softmax (B, T, nclass) + """ + cfg = cfg or DEFAULT_DENSENET_CONFIG + img_cfg = img_cfg or DEFAULT_IMAGE_CONFIG + + height = img_cfg['height'] + channels = img_cfg['channel'] + weight_decay = 1e-4 + + inp = tf.keras.Input(shape=(height, None, channels), name='the_input') + x = inp + + # Attention module + a = tf.keras.layers.Permute((2, 1, 3), name='permute_first')(x) + attention_ratio = 64 if height > 64 else height + a = tf.keras.layers.Dense(attention_ratio, activation='softmax')(a) + a = tf.keras.layers.Permute((2, 1, 3), name='attention_vec')(a) + x = tf.keras.layers.Multiply(name='attention_mul')([x, a]) + + # Initial convolution + nb_filter = cfg['first_conv_filters'] + x = tf.keras.layers.Conv2D( + nb_filter, cfg['first_conv_size'], strides=cfg['first_conv_stride'], + padding='same', use_bias=False, + kernel_regularizer=tf.keras.regularizers.l2(weight_decay) + )(x) + + if cfg['first_pool_size']: + x = tf.keras.layers.AveragePooling2D( + cfg['first_pool_size'], strides=cfg['first_pool_stride'] + )(x) + + # Dense blocks + transitions + nb_layers = cfg['dense_block_layers'] + growth_rate = cfg['dense_block_growth_rate'] + + for n_layer in nb_layers[:-1]: + x, nb_filter = _dense_block(x, n_layer, nb_filter, growth_rate) + trans_filters = cfg['trans_block_filters'] or nb_filter // 2 + x, nb_filter = _transition_block(x, trans_filters) + + x, nb_filter = _dense_block(x, nb_layers[-1], nb_filter, growth_rate) + + if cfg['last_conv_size']: + conv_filters = cfg['last_conv_filters'] or nb_filter + x = tf.keras.layers.BatchNormalization(axis=-1, epsilon=1.1e-5)(x) + x = tf.keras.layers.Conv2D( + conv_filters, cfg['last_conv_size'], kernel_initializer='he_normal', + padding='same', use_bias=False, + kernel_regularizer=tf.keras.regularizers.l2(weight_decay) + )(x) + x = tf.keras.layers.AveragePooling2D(cfg['last_pool_size'], strides=2)(x) + + # Final BN + ReLU + x = tf.keras.layers.BatchNormalization(axis=-1, epsilon=1.1e-5)(x) + x = tf.keras.layers.Activation('relu')(x) + + # Reshape to sequence: (B, W, H*C) → time-distributed flatten + x = tf.keras.layers.Permute((2, 1, 3), name='permute')(x) + x = tf.keras.layers.TimeDistributed(tf.keras.layers.Flatten(), name='flatten')(x) + + # Softmax output + y_pred = tf.keras.layers.Dense(nclass, name='out', activation='softmax')(x) + + model = tf.keras.Model(inputs=inp, outputs=y_pred, name='densenet_ctc') + return model + + +def load_densenet_ctc(model_path, nclass, cfg=None, img_cfg=None): + """ + Build model and load weights from .h5 file. + + The .h5 files from starry-ocr are weights-only (no model_config). + The original model had additional input_length + CtcDecodeLayer, + but those layers have no trainable weights, so by_name loading works. + """ + model = build_densenet_ctc(nclass, cfg, img_cfg) + + if not os.path.exists(model_path): + raise FileNotFoundError(f'Model weights not found: {model_path}') + + model.load_weights(model_path, by_name=True, skip_mismatch=True) + logging.info('DenseNet-CTC weights loaded: %s (%d classes)', model_path, nclass) + + return model + + +def greedy_ctc_decode(pred, alphabet): + """ + Greedy CTC decoding on raw softmax output. + + pred: (B, T, nclass) numpy array + alphabet: string of characters (len = nclass - 1, last class is blank) + + Returns decoded string. + """ + # pred shape: (1, T, nclass) — take first batch + pred_indices = np.argmax(pred[0], axis=-1) # (T,) + nclass = pred.shape[-1] + + chars = [] + prev = -1 + for idx in pred_indices: + # Skip blank (last class) and repeated indices + if idx != nclass - 1 and idx != prev: + if idx < len(alphabet): + chars.append(alphabet[idx]) + prev = idx + + return ''.join(chars) diff --git a/backend/python-services/predictors/tensorflow_predictor.py b/backend/python-services/predictors/tensorflow_predictor.py new file mode 100644 index 0000000000000000000000000000000000000000..dd0627ca556a63fa779236d952dd4445b62f5c70 --- /dev/null +++ b/backend/python-services/predictors/tensorflow_predictor.py @@ -0,0 +1,80 @@ +""" +TensorFlow SavedModel predictor base class. +Loads and runs inference on TensorFlow SavedModel format. +""" + +import logging +import numpy as np + +try: + import tensorflow as tf + # Limit GPU memory growth + gpus = tf.config.experimental.list_physical_devices('GPU') + if gpus: + for gpu in gpus: + tf.config.experimental.set_memory_growth(gpu, True) +except ImportError: + tf = None + logging.warning('TensorFlow not available') + + +class TensorFlowPredictor: + """Base class for TensorFlow SavedModel predictors.""" + + def __init__(self, model_path, device='gpu'): + if tf is None: + raise ImportError('TensorFlow is required for this predictor') + + self.device = device + self.model = self._load_model(model_path) + logging.info('TensorFlow SavedModel loaded: %s', model_path) + + def _load_model(self, model_path): + """Load SavedModel from directory.""" + return tf.saved_model.load(model_path) + + def preprocess(self, images): + """ + Preprocess images before inference. + Override in subclass. + """ + raise NotImplementedError + + def postprocess(self, outputs): + """ + Postprocess model outputs. + Override in subclass. + """ + raise NotImplementedError + + def predict(self, streams, **kwargs): + """ + Run prediction on input streams. + Override in subclass. + """ + raise NotImplementedError + + +class KerasPredictor: + """Base class for Keras model predictors (for .h5 or SavedModel).""" + + def __init__(self, model_path, device='gpu'): + if tf is None: + raise ImportError('TensorFlow is required for this predictor') + + self.device = device + self.model = self._load_model(model_path) + logging.info('Keras model loaded: %s', model_path) + + def _load_model(self, model_path): + """Load Keras model.""" + return tf.keras.models.load_model(model_path, compile=False) + + def preprocess(self, images): + raise NotImplementedError + + def postprocess(self, outputs): + raise NotImplementedError + + def predict(self, streams, **kwargs): + raise NotImplementedError diff --git a/backend/python-services/predictors/torchscript_predictor.py b/backend/python-services/predictors/torchscript_predictor.py new file mode 100644 index 0000000000000000000000000000000000000000..5cbb0ea19940f6300f8122356630d68b53f1e0b5 --- /dev/null +++ b/backend/python-services/predictors/torchscript_predictor.py @@ -0,0 +1,102 @@ +""" +TorchScript model predictor base class. +Loads and runs inference on TorchScript (.pt) models. +""" + +import os +import torch +import yaml +import logging + + +def resolve_model_path(model_path): + """Resolve model path from directory using .state.yaml if needed. + + If model_path is a file, return as-is. + If model_path is a directory, read .state.yaml 'best' field to find the model file. + """ + if os.path.isfile(model_path): + return model_path + + if not os.path.isdir(model_path): + raise ValueError(f'Model path not found: {model_path}') + + state_file = os.path.join(model_path, '.state.yaml') + if os.path.exists(state_file): + with open(state_file, 'r') as f: + state = yaml.safe_load(f) + + best = state.get('best') + if best: + # Strip extension from best to get base name + base = best + for ext in ['.chkpt', '.pt']: + if best.endswith(ext): + base = best[:-len(ext)] + break + + # Prefer .pt (TorchScript) over .chkpt (checkpoint) + for ext in ['.pt', '.chkpt', '']: + candidate = os.path.join(model_path, base + ext) + if os.path.isfile(candidate): + return candidate + + # Fallback: find .pt files first, then any model file + pt_files = [f for f in os.listdir(model_path) + if f.endswith('.pt') and not f.startswith('.')] + if len(pt_files) == 1: + return os.path.join(model_path, pt_files[0]) + + model_files = [f for f in os.listdir(model_path) + if f.endswith(('.pt', '.chkpt')) and not f.startswith('.')] + if len(model_files) == 1: + return os.path.join(model_path, model_files[0]) + + raise ValueError(f'Cannot resolve model file in directory: {model_path}') + + +class TorchScriptPredictor: + """Base class for TorchScript model predictors.""" + + def __init__(self, model_path, device='cuda'): + self.device = device + resolved_path = resolve_model_path(model_path) + self.model = self._load_model(resolved_path) + logging.info('TorchScript model loaded: %s (device: %s)', resolved_path, device) + + def _load_model(self, model_path): + """Load TorchScript model from file.""" + model = torch.jit.load(model_path, map_location=self.device) + model.eval() + return model + + def preprocess(self, images): + """ + Preprocess images before inference. + Override in subclass. + images: list of numpy arrays + returns: torch.Tensor + """ + raise NotImplementedError + + def postprocess(self, outputs): + """ + Postprocess model outputs. + Override in subclass. + outputs: torch.Tensor + returns: processed results + """ + raise NotImplementedError + + def predict(self, streams, **kwargs): + """ + Run prediction on input streams. + streams: list of image byte buffers + yields: prediction results + """ + raise NotImplementedError + + def run_inference(self, batch): + """Run model inference with no_grad context.""" + with torch.no_grad(): + return self.model(batch) diff --git a/backend/python-services/requirements.txt b/backend/python-services/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..2afdf68aca9fe3d3530f5b96b666491afcff1eb3 --- /dev/null +++ b/backend/python-services/requirements.txt @@ -0,0 +1,21 @@ +# Core dependencies +numpy>=1.21.0 +opencv-python>=4.5.0 +Pillow>=8.0.0 +PyYAML>=5.4.0 + +# Communication +pyzmq>=22.0.0 +msgpack>=1.0.0 + +# PyTorch (for layout, mask, semantic, gauge, loc services) +torch>=1.9.0 +torchvision>=0.10.0 + +# TensorFlow (for ocr, brackets services) +# Note: TensorFlow 2.x required for Keras SavedModel support +tensorflow>=2.6.0 + +# Optional: GPU support +# Install with: pip install tensorflow[and-cuda] for TF GPU support +# PyTorch GPU support comes with the default torch installation from pytorch.org diff --git a/backend/python-services/scripts/export_tensorflow.py b/backend/python-services/scripts/export_tensorflow.py new file mode 100644 index 0000000000000000000000000000000000000000..bba6e6b08067c37b17476122d87f19330a7ecd63 --- /dev/null +++ b/backend/python-services/scripts/export_tensorflow.py @@ -0,0 +1,247 @@ +#!/usr/bin/env python3 +""" +Export TensorFlow/Keras models to SavedModel format. + +This script should be run in the original starry-ocr environment +where the model definitions and weights are available. + +Usage: + cd /home/camus/work/starry-ocr + python /path/to/export_tensorflow.py --mode ocr --config config.yaml --output ocr_savedmodel + +Modes: + ocr - General OCR model (DenseNet-CTC) + tempo - Tempo numeral OCR model + brackets - Bracket recognition model + chord - Chord recognition model (Seq2Seq) +""" + +import argparse +import os +import sys + +# Add starry-ocr to path +STARRY_OCR_PATH = '/home/camus/work/starry-ocr' +if STARRY_OCR_PATH not in sys.path: + sys.path.insert(0, STARRY_OCR_PATH) + + +def export_ocr(config_path, output_path): + """Export general OCR model to SavedModel.""" + import yaml + import tensorflow as tf + + # Limit GPU memory + gpus = tf.config.experimental.list_physical_devices('GPU') + if gpus: + for gpu in gpus: + tf.config.experimental.set_memory_growth(gpu, True) + + from OCR_Test.densenet.model import Densenet + + with open(config_path, 'r', encoding='utf-8') as f: + config = yaml.safe_load(f) + + config_dir = os.path.dirname(config_path) + + # Load alphabet + alphabet_path = config['generalOCR_alphabet_path'] + if not os.path.isabs(alphabet_path): + alphabet_path = os.path.join(config_dir, alphabet_path) + alphabet = open(alphabet_path, 'r', encoding='utf-8').readline().strip() + + # Load weights + weights_path = config['generalOCR_weight_path'] + if not os.path.isabs(weights_path): + weights_path = os.path.join(config_dir, weights_path) + + # Model config + densenetconfig = { + 'first_conv_filters': 64, + 'first_conv_size': 5, + 'first_conv_stride': 2, + 'dense_block_layers': [8, 8, 8], + 'dense_block_growth_rate': 8, + 'trans_block_filters': 128, + 'first_pool_size': 0, + 'first_pool_stride': 2, + 'last_conv_size': 0, + 'last_conv_filters': 0, + 'last_pool_size': 2, + 'need_feature_vector': False, # Disable for export + } + + imageconfig = { + 'hight': 32, + 'width': 400, + 'channel': 1, + } + + # Create model + model = Densenet( + alphabet=alphabet, + modelPath=weights_path, + imageconfig=imageconfig, + densenetconfig=densenetconfig + ) + + # Get the underlying Keras model + keras_model = model.model + + # Save as SavedModel + keras_model.save(output_path, save_format='tf') + print(f'OCR model exported to: {output_path}') + + # Also save alphabet + with open(os.path.join(output_path, 'alphabet.txt'), 'w', encoding='utf-8') as f: + f.write(alphabet) + print(f'Alphabet saved to: {output_path}/alphabet.txt') + + +def export_tempo(config_path, output_path): + """Export tempo numeral OCR model to SavedModel.""" + import yaml + import tensorflow as tf + + gpus = tf.config.experimental.list_physical_devices('GPU') + if gpus: + for gpu in gpus: + tf.config.experimental.set_memory_growth(gpu, True) + + from OCR_Test.densenet.model import Densenet + + with open(config_path, 'r', encoding='utf-8') as f: + config = yaml.safe_load(f) + + config_dir = os.path.dirname(config_path) + + alphabet_path = config['temponumOCR_alphabet_path'] + if not os.path.isabs(alphabet_path): + alphabet_path = os.path.join(config_dir, alphabet_path) + alphabet = open(alphabet_path, 'r', encoding='utf-8').readline().strip() + + weights_path = config['temponumOCR_weight_path'] + if not os.path.isabs(weights_path): + weights_path = os.path.join(config_dir, weights_path) + + densenetconfig = { + 'first_conv_filters': 64, + 'first_conv_size': 5, + 'first_conv_stride': 2, + 'dense_block_layers': [8, 8, 8], + 'dense_block_growth_rate': 8, + 'trans_block_filters': 128, + 'first_pool_size': 0, + 'first_pool_stride': 2, + 'last_conv_size': 0, + 'last_conv_filters': 0, + 'last_pool_size': 2, + 'need_feature_vector': False, + } + + imageconfig = { + 'hight': 32, + 'width': 400, + 'channel': 1, + } + + model = Densenet( + alphabet=alphabet, + modelPath=weights_path, + imageconfig=imageconfig, + densenetconfig=densenetconfig + ) + + keras_model = model.model + keras_model.save(output_path, save_format='tf') + print(f'Tempo OCR model exported to: {output_path}') + + with open(os.path.join(output_path, 'alphabet.txt'), 'w', encoding='utf-8') as f: + f.write(alphabet) + + +def export_brackets(config_path, output_path): + """Export brackets OCR model to SavedModel.""" + import yaml + import tensorflow as tf + + gpus = tf.config.experimental.list_physical_devices('GPU') + if gpus: + for gpu in gpus: + tf.config.experimental.set_memory_growth(gpu, True) + + from OCR_Test.densenet.model import Densenet + + with open(config_path, 'r', encoding='utf-8') as f: + config = yaml.safe_load(f) + + config_dir = os.path.dirname(config_path) + + alphabet_path = config['bracket_alphabet_path'] + if not os.path.isabs(alphabet_path): + alphabet_path = os.path.join(config_dir, alphabet_path) + alphabet = open(alphabet_path, 'r', encoding='utf-8').readline().strip() + + weights_path = config['bracket_weight_path'] + if not os.path.isabs(weights_path): + weights_path = os.path.join(config_dir, weights_path) + + densenetconfig = { + 'first_conv_filters': 64, + 'first_conv_size': 5, + 'first_conv_stride': 2, + 'dense_block_layers': [8, 8, 8], + 'dense_block_growth_rate': 8, + 'trans_block_filters': 128, + 'first_pool_size': 0, + 'first_pool_stride': 2, + 'last_conv_size': 0, + 'last_conv_filters': 0, + 'last_pool_size': 2, + } + + imageconfig = { + 'hight': 32, + 'width': 400, + 'channel': 1, + } + + model = Densenet( + alphabet=alphabet, + modelPath=weights_path, + imageconfig=imageconfig, + densenetconfig=densenetconfig + ) + + keras_model = model.model + keras_model.save(output_path, save_format='tf') + print(f'Brackets model exported to: {output_path}') + + with open(os.path.join(output_path, 'alphabet.txt'), 'w', encoding='utf-8') as f: + f.write(alphabet) + + +EXPORTERS = { + 'ocr': export_ocr, + 'tempo': export_tempo, + 'brackets': export_brackets, +} + + +def main(): + parser = argparse.ArgumentParser(description='Export TensorFlow models to SavedModel') + parser.add_argument('--mode', type=str, required=True, choices=list(EXPORTERS.keys()), + help='Model type to export') + parser.add_argument('--config', type=str, required=True, + help='Path to configuration YAML file') + parser.add_argument('--output', type=str, required=True, + help='Output SavedModel directory path') + + args = parser.parse_args() + + exporter = EXPORTERS[args.mode] + exporter(args.config, args.output) + + +if __name__ == '__main__': + main() diff --git a/backend/python-services/scripts/export_torchscript.py b/backend/python-services/scripts/export_torchscript.py new file mode 100644 index 0000000000000000000000000000000000000000..fda47e802eb518877040a46b2740a18d30803934 --- /dev/null +++ b/backend/python-services/scripts/export_torchscript.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python3 +""" +Export PyTorch models to TorchScript format. + +This script should be run in the original deep-starry environment +where the model definitions are available. + +Usage: + cd /home/camus/work/deep-starry + python /path/to/export_torchscript.py --mode layout --config configs/your-config.yaml --output layout.pt + +Modes: + layout - LayoutPredictor (ScoreResidue model) + mask - MaskPredictor (ScoreWidgetsMask model) + semantic - SemanticPredictor (ScoreWidgets model) + gauge - GaugePredictor (ScoreRegression model) +""" + +import argparse +import torch +import numpy as np +import os +import sys + +# Add deep-starry to path +DEEP_STARRY_PATH = '/home/camus/work/deep-starry' +if DEEP_STARRY_PATH not in sys.path: + sys.path.insert(0, DEEP_STARRY_PATH) + + +def export_layout(config_path, output_path, device='cuda'): + """Export layout model to TorchScript.""" + from starry.utils.config import Configuration + from starry.utils.model_factory import loadModel + + config = Configuration.createOrLoad(config_path, volatile=True) + + model = loadModel(config['model']) + checkpoint_path = config.localPath('weights.chkpt') + if os.path.exists(checkpoint_path): + checkpoint = torch.load(checkpoint_path, map_location=device) + model.load_state_dict(checkpoint['model']) + + model.to(device) + model.eval() + + # Create example input: (batch, channel, height, width) + # Layout model expects grayscale input + example_input = torch.randn(1, 1, 600, 800).to(device) + + # Trace the model + with torch.no_grad(): + traced = torch.jit.trace(model, example_input) + + # Save + traced.save(output_path) + print(f'Layout model exported to: {output_path}') + + +def export_mask(config_path, output_path, device='cuda'): + """Export mask model to TorchScript.""" + from starry.utils.config import Configuration + from starry.utils.model_factory import loadModel + + config = Configuration.createOrLoad(config_path, volatile=True) + + model = loadModel(config['model']) + checkpoint_path = config.localPath('weights.chkpt') + if os.path.exists(checkpoint_path): + checkpoint = torch.load(checkpoint_path, map_location=device) + model.load_state_dict(checkpoint['model']) + + model.to(device) + model.eval() + + # Mask model input: (batch, channel, height, width) + # Usually 512x256 slices + example_input = torch.randn(1, 1, 256, 512).to(device) + + with torch.no_grad(): + traced = torch.jit.trace(model, example_input) + + traced.save(output_path) + print(f'Mask model exported to: {output_path}') + + +def export_semantic(config_path, output_path, device='cuda'): + """Export semantic model to TorchScript.""" + from starry.utils.config import Configuration + from starry.utils.model_factory import loadModel + + config = Configuration.createOrLoad(config_path, volatile=True) + + model = loadModel(config['model']) + checkpoint_path = config.localPath('weights.chkpt') + if os.path.exists(checkpoint_path): + checkpoint = torch.load(checkpoint_path, map_location=device) + model.load_state_dict(checkpoint['model']) + + model.to(device) + model.eval() + + # Semantic model input: (batch, channel, height, width) + example_input = torch.randn(1, 1, 256, 512).to(device) + + with torch.no_grad(): + traced = torch.jit.trace(model, example_input) + + traced.save(output_path) + print(f'Semantic model exported to: {output_path}') + + +def export_gauge(config_path, output_path, device='cuda'): + """Export gauge model to TorchScript.""" + from starry.utils.config import Configuration + from starry.utils.model_factory import loadModel + + config = Configuration.createOrLoad(config_path, volatile=True) + + model = loadModel(config['model']) + checkpoint_path = config.localPath('weights.chkpt') + if os.path.exists(checkpoint_path): + checkpoint = torch.load(checkpoint_path, map_location=device) + model.load_state_dict(checkpoint['model']) + + model.to(device) + model.eval() + + # Gauge model input + example_input = torch.randn(1, 1, 256, 512).to(device) + + with torch.no_grad(): + traced = torch.jit.trace(model, example_input) + + traced.save(output_path) + print(f'Gauge model exported to: {output_path}') + + +EXPORTERS = { + 'layout': export_layout, + 'mask': export_mask, + 'semantic': export_semantic, + 'gauge': export_gauge, +} + + +def main(): + parser = argparse.ArgumentParser(description='Export PyTorch models to TorchScript') + parser.add_argument('--mode', type=str, required=True, choices=list(EXPORTERS.keys()), + help='Model type to export') + parser.add_argument('--config', type=str, required=True, + help='Path to model configuration directory') + parser.add_argument('--output', type=str, required=True, + help='Output TorchScript file path') + parser.add_argument('--device', type=str, default='cuda', + help='Device to use for export') + + args = parser.parse_args() + + exporter = EXPORTERS[args.mode] + exporter(args.config, args.output, args.device) + + +if __name__ == '__main__': + main() diff --git a/backend/python-services/scripts/start-all.sh b/backend/python-services/scripts/start-all.sh new file mode 100755 index 0000000000000000000000000000000000000000..b9c306d65bf714133223c881500941dcb1e2e42e --- /dev/null +++ b/backend/python-services/scripts/start-all.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# Start all STARRY ML prediction services in a single container. +# Usage: docker run ... starry-ml:latest bash /app/scripts/start-all.sh + +set -e + +echo "=== Starting all STARRY prediction services ===" + +export TF_USE_LEGACY_KERAS=1 +export PYTHONPATH=/app/deep-starry:/app/starry-ocr +export LOG_DIR=${LOG_DIR:-/tmp/starry-logs} +export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-0} +mkdir -p "$LOG_DIR" + +PIDS=() + +# --- PyTorch services (GPU) - start sequentially to avoid CUDA init race --- + +echo "[layout] Starting on port 12022..." +python /app/deep-starry/streamPredictor.py \ + /models/starry-dist/20221125-scorelayout-1121-residue-u-d4-w64-d4-w64 \ + -p 12022 -dv cuda -m layout & +PIDS+=($!) +sleep 3 + +echo "[mask] Starting on port 12024..." +python /app/deep-starry/streamPredictor.py \ + /models/starry-dist/20210918-scorewidgets.mask-unet-5-32 \ + -p 12024 -dv cuda -m mask & +PIDS+=($!) +sleep 3 + +echo "[semantic] Starting on port 12025..." +python /app/deep-starry/streamPredictor.py \ + /models/starry-dist/202302-semanticCluster \ + -p 12025 -dv cuda -m semanticCluster & +PIDS+=($!) +sleep 3 + +echo "[gauge] Starting on port 12023..." +python /app/deep-starry/streamPredictor.py \ + /models/starry-dist/scoregauge-unet-d6-w32-0611 \ + -p 12023 -dv cuda -m gauge & +PIDS+=($!) +sleep 3 + +echo "[loc] Starting on port 12026..." +cd /app/starry-ocr && python locPredictor.py \ + -w /models/ocr-dist/DB_gc_loc/v6/model_epoch_88_minibatch_15300 \ + -p 12026 -dv cuda & +PIDS+=($!) +cd /app +sleep 2 + +# --- TensorFlow services (CPU) --- + +echo "[ocr] Starting on port 12027 (CPU)..." +CUDA_VISIBLE_DEVICES=-1 python /app/starry-ocr/ocrPredictor.py \ + /models/ocr-dist/ocr.yaml \ + -p 12027 & +PIDS+=($!) +sleep 1 + +echo "[brackets] Starting on port 12028 (CPU)..." +CUDA_VISIBLE_DEVICES=-1 python /app/starry-ocr/bracketsPredictor.py \ + /models/ocr-dist/brackets.yaml \ + -p 12028 & +PIDS+=($!) + +echo "" +echo "=== All ${#PIDS[@]} services started (PIDs: ${PIDS[*]}) ===" +echo " Ports: 12022(layout) 12023(gauge) 12024(mask) 12025(semantic) 12026(loc) 12027(ocr) 12028(brackets)" +echo "" + +# Handle shutdown +trap 'echo "Stopping all services..."; kill "${PIDS[@]}" 2>/dev/null; wait' SIGTERM SIGINT + +# Wait for all children +wait diff --git a/backend/python-services/services/__init__.py b/backend/python-services/services/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..dd6c052b02bcaf1bedb50be7c18b3356e9b18ddc --- /dev/null +++ b/backend/python-services/services/__init__.py @@ -0,0 +1 @@ +# Services module - ML service implementations diff --git a/backend/python-services/services/brackets_service.py b/backend/python-services/services/brackets_service.py new file mode 100644 index 0000000000000000000000000000000000000000..17059b310efef978b59ef0221f4ac09d4ac0da66 --- /dev/null +++ b/backend/python-services/services/brackets_service.py @@ -0,0 +1,201 @@ +""" +Brackets prediction service. +Recognizes bracket sequences from staff bracket images. + +Note: This service requires Keras/TensorFlow models (DenseNet-CTC). +""" + +import numpy as np +import cv2 +import logging + +from predictors.densenet_ctc import load_densenet_ctc, greedy_ctc_decode +from common.image_utils import array_from_image_stream + + +class BracketCorrector: + """ + Corrects unpaired and nested parentheses in bracket sequences. + """ + + pair_dict = { + '{': '}', + '<': '>', + '[': ']', + } + reverse_dict = {v: k for k, v in pair_dict.items()} + pair_dict.update(reverse_dict) + + def __init__(self, vib='<', vvib='[', vvvib='{'): + """ + Define bracket priority. + vvvib > vvib > vib (curly > square > angle) + """ + self.vib = vib + self.vvib = vvib + self.vvvib = vvvib + self.right_symbol = ['{', '[', '<'] + self.left_symbol = ['}', ']', '>'] + + def find_cp(self, string): + """Find paired brackets at each priority level.""" + str_len = len(string) + cp_his = [] + vvvib_cp, vvib_cp, vib_cp = [], [], [] + + for cp_sym in [self.vvvib, self.vvib, self.vib]: + cur_cp = [] + for index in range(str_len): + if index not in cp_his and string[index] == cp_sym: + for i in range(index + 1, str_len): + cur_sym = string[i] + if cur_sym == self.pair_dict.get(cp_sym): + for j in range(i - 1, -1, -1): + if j not in cp_his and string[j] == cp_sym: + if i > j: + cur_cp.append((j, i)) + else: + cur_cp.append((i, j)) + cp_his.append(i) + cp_his.append(j) + break + + if cp_sym == self.vvvib: + vvvib_cp = cur_cp + elif cp_sym == self.vvib: + vvib_cp = cur_cp + elif cp_sym == self.vib: + vib_cp = cur_cp + + return vvvib_cp, vvib_cp, vib_cp + + def clean_up(self, string): + """Remove nested conflicts based on priority.""" + vvvib, vvib, vib = self.find_cp(string) + + # Check curly vs square and angle brackets + for x in vvvib: + x_begin, x_end = x[0], x[1] + + for y in list(vvib): + y_begin, y_end = y[0], y[1] + if (x_begin < y_begin < x_end < y_end) or \ + (y_begin < x_begin < y_end < x_end): + vvib.remove(y) + + for z in list(vib): + z_begin, z_end = z[0], z[1] + if (x_begin < z_begin < x_end < z_end) or \ + (z_begin < x_begin < z_end < x_end): + vib.remove(z) + + # Check square vs angle brackets + for x in vvib: + x_begin, x_end = x[0], x[1] + + for y in list(vib): + y_begin, y_end = y[0], y[1] + if (x_begin < y_begin < x_end < y_end) or \ + (y_begin < x_begin < y_end < x_end): + vib.remove(y) + + # Collect all valid indices + all_cp = vvvib + vvib + vib + new_cp_list = [] + for pair in all_cp: + new_cp_list.append(pair[0]) + new_cp_list.append(pair[1]) + + return new_cp_list + + def correct(self, string): + """ + Correct bracket sequence. + Returns only properly paired brackets and commas. + """ + all_cp = self.clean_up(string) + corrected = '' + + for index, char in enumerate(string): + if char == ',': + corrected += char + elif index in all_cp: + corrected += char + + return corrected + + +class BracketsService: + """ + Bracket recognition service using DenseNet-CTC. + + Uses DenseNet-CTC architecture for bracket sequence recognition. + """ + + def __init__(self, model_path, device='gpu', alphabet=None, **kwargs): + """ + Initialize brackets service. + + model_path: path to bracket OCR weights (.h5) + alphabet: character set for the model + """ + self.alphabet = alphabet or '<>[]{},-.0123456789' + nclass = len(self.alphabet) + 1 + self.model = load_densenet_ctc(model_path, nclass) + self.corrector = BracketCorrector() + + def preprocess_image(self, image, target_height=32): + """Preprocess bracket image for OCR model.""" + # Convert to grayscale + if len(image.shape) == 3: + image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) + + # Rotate 90 degrees (brackets are vertical) + image = np.rot90(image) + + h, w = image.shape[:2] + + # Resize to target height + scale = target_height / h + new_w = int(w * scale) + image = cv2.resize(image, (new_w, target_height)) + + # Normalize + image = image.astype(np.float32) / 255.0 - 0.5 + + # Add batch and channel dimensions + image = np.expand_dims(image, axis=(0, -1)) # (1, H, W, 1) + + return image + + def predict(self, buffers, **kwargs): + """ + Recognize bracket sequence from images. + + buffers: list of bracket image buffers + yields: corrected bracket strings + """ + for buffer in buffers: + image = array_from_image_stream(buffer) + if image is None: + yield None + continue + + try: + # Preprocess + processed = self.preprocess_image(image) + + # Predict + pred = self.model.predict(processed, verbose=0) + + # Decode using greedy CTC + content = greedy_ctc_decode(pred, self.alphabet) + + # Correct bracket pairing + content = self.corrector.correct(content) + + yield content + + except Exception as e: + logging.warning('Bracket prediction error: %s', str(e)) + yield None diff --git a/backend/python-services/services/gauge_service.py b/backend/python-services/services/gauge_service.py new file mode 100644 index 0000000000000000000000000000000000000000..009e0abb355d5ac715528b64a8463e716461d0a2 --- /dev/null +++ b/backend/python-services/services/gauge_service.py @@ -0,0 +1,85 @@ +""" +Gauge prediction service. +Predicts staff gauge (height and slope) map. +""" + +import numpy as np +import torch +import PIL.Image + +from predictors.torchscript_predictor import TorchScriptPredictor +from common.image_utils import ( + array_from_image_stream, slice_feature, splice_output_tensor, + gauge_to_rgb, encode_image_base64, encode_image_bytes, + MARGIN_DIVIDER +) +from common.transform import Composer + + +class StaffGauge: + """Staff gauge representation.""" + + def __init__(self, hotmap): + """ + hotmap: (2, H, W) - channels: [Y (height), K (slope)] + """ + hotmap = gauge_to_rgb(hotmap, frac_y=True) + self.image = PIL.Image.fromarray(hotmap[:, :, ::-1], 'RGB') + + def json(self): + return { + 'image': encode_image_base64(self.image), + } + + +class GaugeService(TorchScriptPredictor): + """Gauge prediction service using TorchScript model.""" + + DEFAULT_TRANS = ['Mono', 'HWC2CHW'] + DEFAULT_SLICING_WIDTH = 512 + + def __init__(self, model_path, device='cuda', trans=None, slicing_width=None): + super().__init__(model_path, device) + self.composer = Composer(trans or self.DEFAULT_TRANS) + self.slicing_width = slicing_width or self.DEFAULT_SLICING_WIDTH + + def predict(self, streams, by_buffer=False, **kwargs): + """ + Predict staff gauge from image streams. + streams: list of image byte buffers + by_buffer: if True, return raw bytes instead of base64 + yields: gauge results + """ + for stream in streams: + image = array_from_image_stream(stream) + if image is None: + yield {'error': 'Invalid image'} + continue + + # Slice image + pieces = list(slice_feature( + image, + width=self.slicing_width, + overlapping=2 / MARGIN_DIVIDER, + padding=False + )) + pieces = np.array(pieces, dtype=np.float32) + + # Transform + staves, _ = self.composer(pieces, np.ones((1, 4, 4, 2))) + batch = torch.from_numpy(staves).to(self.device) + + # Inference + output = self.run_inference(batch) # (batch, channel, height, width) + + # Splice output + hotmap = splice_output_tensor(output, soft=True) # (channel, height, width) + if hotmap.shape[2] > image.shape[1]: + hotmap = hotmap[:, :, :image.shape[1]] + + gauge = StaffGauge(hotmap) + encoder = encode_image_bytes if by_buffer else encode_image_base64 + + yield { + 'image': encoder(gauge.image), + } diff --git a/backend/python-services/services/layout_service.py b/backend/python-services/services/layout_service.py new file mode 100644 index 0000000000000000000000000000000000000000..8eecae24b3d9b138c1c4c22b57135754bb05366f --- /dev/null +++ b/backend/python-services/services/layout_service.py @@ -0,0 +1,391 @@ +""" +Layout prediction service. +Detects page layout: staff boxes, lines, intervals, rotation angle. +Includes system/staff detection for the full prediction pipeline. +""" + +import numpy as np +import torch +import cv2 +import PIL.Image +import hashlib +import io +import logging + +from predictors.torchscript_predictor import TorchScriptPredictor +from common.image_utils import ( + array_from_image_stream, resize_page_image, normalize_image_dimension, + encode_image_base64 +) +from common.transform import Composer + + +RESIZE_WIDTH = 600 +CANVAS_WIDTH_MIN = 1024 + +SYSTEM_HEIGHT_ENLARGE = 0.02 +SYSTEM_LEFT_ENLARGE = 0.03 +SYSTEM_RIGHT_ENLARGE = 0.01 + +STAFF_PADDING_LEFT = 32 +STAFF_HEIGHT_UNITS = 24 +UNIT_SIZE = 8 + + +def _detect_systems(image): + """Detect musical systems (staff groups) from max-channel heatmap.""" + height, width = image.shape + + blur = cv2.GaussianBlur(image, (5, 5), 0) + thresh = cv2.adaptiveThreshold(blur, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 201, -40) + contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + marginLeft = SYSTEM_LEFT_ENLARGE * width + marginRight = SYSTEM_RIGHT_ENLARGE * width + + areas = [] + for contour in contours: + x, y, w, h = cv2.boundingRect(contour) + rw = w / width + rh = h / width + if (rw > 0.6 and rh > 0.02) or (rw > 0.12 and rh > 0.2): + left = max(x - marginLeft, 0) + right = min(x + w + marginRight, width) + areas.append({'x': left, 'y': y, 'width': right - left, 'height': h}) + areas.sort(key=lambda a: a['y']) + + # Enlarge heights to include surrounding space + marginY = SYSTEM_HEIGHT_ENLARGE * width + marginYMax = marginY * 8 + ctx = {'lastMargin': 0} + + def enlarge(i, area, ctx): + top = area['y'] + bottom = top + area['height'] + if i > 0: + lastArea = areas[i - 1] + ctx['lastMargin'] = max(ctx['lastMargin'], lastArea['y'] + lastArea['height'], top - marginYMax) + top = max(0, min(top - marginY, ctx['lastMargin'])) + else: + top = min(top, max(marginY, top - marginYMax)) + if i < len(areas) - 1: + nextArea = areas[i + 1] + bottom = min(height, max(bottom + marginY, nextArea['y']), bottom + marginYMax) + else: + bottom = min(height, bottom + marginYMax) + return {'top': top, 'bottom': bottom} + + enlarges = [enlarge(i, area, ctx) for i, area in enumerate(areas)] + for i, area in enumerate(areas): + area['y'] = enlarges[i]['top'] + area['height'] = enlarges[i]['bottom'] - enlarges[i]['top'] + + return {'areas': areas} + + +def _detect_staves_from_hbl(HB, HL, interval): + """Detect individual staves within a system using staff-box and horizontal-line heatmaps.""" + _, HB = cv2.threshold(HB, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU) + contours, _ = cv2.findContours(HB, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + height, width = HB.shape + STAFF_HEIGHT_MIN = interval * 3 + STAFF_WIDTH_MIN = max(width * 0.6, width - interval * 12) + UPSCALE = 4 + upInterval = interval * UPSCALE + + rects = map(cv2.boundingRect, contours) + rects = filter(lambda rect: rect[2] > STAFF_WIDTH_MIN and rect[3] > STAFF_HEIGHT_MIN, rects) + rects = sorted(rects, key=lambda rect: rect[1]) + + # Merge overlapping rectangles + preRects = [] + for rect in rects: + x, y, w, h = rect + ri = next((i for i, rc in enumerate(preRects) + if (y + h / 2) - (rc[1] + rc[3] / 2) < (h + rc[3]) / 2), -1) + if ri < 0: + preRects.append(rect) + else: + rc = list(preRects[ri]) + if w > rc[2]: + preRects[ri] = (min(x, rc[0]), rect[1], max(x + w, rc[0] + rc[2]) - x, rect[3]) + else: + rc[0] = min(x, rc[0]) + rc[2] = max(x + w, rc[0] + rc[2]) - rc[0] + + if len(preRects) == 0: + return {'reason': 'no block rectangles detected'} + + phi1 = min(rc[0] for rc in preRects) + phi2 = min(rc[0] + rc[2] for rc in preRects) + + middleRhos = [] + for rect in preRects: + rx, ry, rw, rh = rect + x = max(rx, 0) + y = max(round(ry - interval), 0) + roi = (x, y, min(rw, width - x), min(round(rh + interval + ry - y), height - y)) + staffLines = HL[roi[1]:roi[1] + roi[3], roi[0]:roi[0] + roi[2]] + + hlineColumn = cv2.resize(staffLines, (1, staffLines.shape[0] * UPSCALE), 0, 0, cv2.INTER_LINEAR).flatten() + i1 = round(upInterval) + kernel = np.zeros(i1 * 4 + 1) + kernel[::i1] = 1 + convolutionLine = np.convolve(hlineColumn, kernel) + convolutionLineMax = np.max(convolutionLine) + middleY = np.where(convolutionLine == convolutionLineMax)[0][0] - round(upInterval * 2) + middleRhos.append(y + middleY / UPSCALE) + + return { + 'interval': interval, + 'phi1': phi1, + 'phi2': phi2, + 'middleRhos': middleRhos, + } + + +def _scale_detection(detection, scale): + """Scale detection coordinates by given factor.""" + areas = [{ + 'x': a['x'] * scale, + 'y': a['y'] * scale, + 'width': a['width'] * scale, + 'height': a['height'] * scale, + 'staff_images': a.get('staff_images'), + 'staves': { + 'interval': a['staves']['interval'] * scale, + 'phi1': a['staves']['phi1'] * scale, + 'phi2': a['staves']['phi2'] * scale, + 'middleRhos': [rho * scale for rho in a['staves']['middleRhos']], + } if (a.get('staves') and a['staves'].get('middleRhos') is not None) else None, + } for a in detection['areas']] + return {'areas': areas} + + +class PageLayout: + """Process layout heatmap to extract page parameters.""" + + def __init__(self, heatmap): + """ + heatmap: (3, H, W) - channels: [VL, StaffBox, HL] + """ + lines_map = heatmap[2] + self.interval = self.measure_interval(lines_map) + + heatmap_uint8 = np.uint8(heatmap * 255) + heatmap_uint8 = np.moveaxis(heatmap_uint8, 0, -1) + self.image = PIL.Image.fromarray(heatmap_uint8, 'RGB') + self.heatmap = heatmap_uint8 + + staves_map = heatmap_uint8[:, :, 1] + self.theta = self.measure_theta(staves_map) + + def json(self): + return { + 'image': encode_image_base64(self.image), + 'theta': self.theta, + 'interval': self.interval, + } + + def detect(self, image, ratio): + """Full detection: systems, staves, staff images.""" + if self.theta is None: + return { + 'theta': self.theta, + 'interval': self.interval * image.shape[1] / RESIZE_WIDTH, + 'detection': None, + } + + original_size = (image.shape[1], image.shape[0]) + aligned_height = int(image.shape[1] * ratio) + if image.shape[0] < aligned_height: + image = np.pad(image, ((0, aligned_height - image.shape[0]), (0, 0), (0, 0)), mode='constant') + elif image.shape[0] > aligned_height: + image = image[:aligned_height] + + canvas_size = (original_size[0], aligned_height) + while canvas_size[0] < CANVAS_WIDTH_MIN: + canvas_size = (canvas_size[0] * 2, canvas_size[1] * 2) + if canvas_size[0] > original_size[0]: + image = cv2.resize(image, canvas_size) + + rot_mat = cv2.getRotationMatrix2D((canvas_size[0] / 2, canvas_size[1] / 2), self.theta * 180 / np.pi, 1) + image = cv2.warpAffine(image, rot_mat, canvas_size, flags=cv2.INTER_CUBIC) + if len(image.shape) < 3: + image = np.expand_dims(image, -1) + + heatmap = cv2.resize(self.heatmap, (canvas_size[0], round(canvas_size[0] * self.heatmap.shape[0] / self.heatmap.shape[1])), interpolation=cv2.INTER_CUBIC) + if heatmap.shape[0] > canvas_size[1]: + heatmap = heatmap[:canvas_size[1]] + elif heatmap.shape[0] < canvas_size[1]: + heatmap = np.pad(heatmap, ((0, canvas_size[1] - heatmap.shape[0]), (0, 0), (0, 0)), mode='constant') + heatmap = cv2.warpAffine(heatmap, rot_mat, canvas_size, flags=cv2.INTER_LINEAR) + + HB = heatmap[:, :, 1] + HL = heatmap[:, :, 2] + block = heatmap.max(axis=2) + detection = _detect_systems(block) + + canvas_interval = self.interval * canvas_size[0] / RESIZE_WIDTH + + for si, area in enumerate(detection['areas']): + l, r, t, b = map(round, (area['x'], area['x'] + area['width'], area['y'], area['y'] + area['height'])) + system_image = image[t:b, l:r, :] + hb = HB[t:b, l:r] + hl = HL[t:b, l:r] + + area['staves'] = _detect_staves_from_hbl(hb, hl, canvas_interval) + + if not area.get('staves') or area['staves'].get('middleRhos') is None: + continue + + area['staff_images'] = [] + interval = area['staves']['interval'] + unit_scaling = UNIT_SIZE / interval + padding_left = round(STAFF_PADDING_LEFT * UNIT_SIZE / interval / unit_scaling) + staff_width = round(system_image.shape[1] * unit_scaling) + STAFF_PADDING_LEFT + staff_size = (staff_width, STAFF_HEIGHT_UNITS * UNIT_SIZE) + + for ssi, rho in enumerate(area['staves']['middleRhos']): + map_x = (np.tile(np.arange(staff_size[0], dtype=np.float32), (staff_size[1], 1)) - STAFF_PADDING_LEFT) / unit_scaling + map_y = (np.tile(np.arange(staff_size[1], dtype=np.float32), (staff_size[0], 1)).T - staff_size[1] / 2) / unit_scaling + rho + map_x, map_y = map_x.astype(np.float32), map_y.astype(np.float32) + + staff_image = cv2.remap(system_image, map_x, map_y, cv2.INTER_CUBIC, borderMode=cv2.BORDER_CONSTANT, borderValue=(255, 255, 255)) + + # Encode staff image as PNG bytes for downstream predictors + _, png_data = cv2.imencode('.png', staff_image) + staff_bytes = png_data.tobytes() + + area['staff_images'].append({ + 'hash': None, + 'image': staff_bytes, + 'position': { + 'x': -STAFF_PADDING_LEFT / UNIT_SIZE, + 'y': -STAFF_HEIGHT_UNITS / 2, + 'width': staff_size[0] / UNIT_SIZE, + 'height': staff_size[1] / UNIT_SIZE, + }, + }) + + page_interval = self.interval * original_size[0] / RESIZE_WIDTH + return { + 'sourceSize': { + 'width': original_size[0], + 'height': original_size[1], + }, + 'theta': self.theta, + 'interval': page_interval, + 'detection': _scale_detection(detection, original_size[0] / canvas_size[0]), + } + + @staticmethod + def measure_theta(heatmap): + """Measure page rotation angle using Hough lines.""" + edges = cv2.Canny(heatmap, 50, 150, apertureSize=3) + lines = cv2.HoughLines( + edges, 1, np.pi / 18000, + round(heatmap.shape[1] * 0.4), + min_theta=np.pi * 0.48, + max_theta=np.pi * 0.52 + ) + if lines is None: + return None + + avg_theta = sum(line[0][1] for line in lines) / len(lines) + return float(avg_theta - np.pi / 2) + + @staticmethod + def measure_interval(heatmap): + """Measure staff line interval using autocorrelation.""" + UPSCALE = 4 + width = heatmap.shape[1] + + heatmap = cv2.resize( + heatmap, + (heatmap.shape[1] // UPSCALE, heatmap.shape[0] * UPSCALE), + interpolation=cv2.INTER_LINEAR + ) + + interval_min = round(width * 0.002 * UPSCALE) + interval_max = round(width * 0.025 * UPSCALE) + + brights = [] + for y in range(interval_min, interval_max): + m1, m2 = heatmap[y:], heatmap[:-y] + p = np.multiply(m1, m2) + brights.append(np.mean(p)) + + # Subtract 2x interval to weaken harmonics + brights = np.array([brights]) + brights2 = cv2.resize(brights, (brights.shape[1] * 2, 1)) + + brights = brights.flatten()[interval_min:] + brights2 = brights2.flatten()[:len(brights)] + + brights -= brights2 * 0.5 + + return (interval_min * 2 + int(np.argmax(brights))) / UPSCALE + + +class LayoutService(TorchScriptPredictor): + """Layout prediction service using TorchScript model.""" + + # Default transform pipeline + DEFAULT_TRANS = ['Mono', 'HWC2CHW'] + + def __init__(self, model_path, device='cuda', trans=None, **kwargs): + super().__init__(model_path, device) + self.composer = Composer(trans or self.DEFAULT_TRANS) + + def predict(self, streams, **kwargs): + """ + Predict page layout from image streams (basic mode). + streams: list of image byte buffers + yields: layout JSON results + """ + for stream in streams: + image = array_from_image_stream(stream) + if image is None: + yield {'error': 'Invalid image'} + continue + + image = np.expand_dims(image, 0) # (1, H, W, C) + image = normalize_image_dimension(image) + + batch, _ = self.composer(image, np.ones((1, 4, 4, 2))) + batch = torch.from_numpy(batch).to(self.device) + + output = self.run_inference(batch) + output = output.cpu().numpy() + hotmap = output[0] # (C, H, W) + + yield PageLayout(hotmap).json() + + def predictDetection(self, streams): + """ + Predict layout with full system/staff detection. + streams: list of image byte buffers + yields: detection results with sourceSize, theta, interval, detection.areas + """ + images = [array_from_image_stream(stream) for stream in streams] + + ratio = max(img.shape[0] / img.shape[1] for img in images) + height = int(RESIZE_WIDTH * ratio) + height += -height % 4 + unified_images = [resize_page_image(img, (RESIZE_WIDTH, height)) for img in images] + image_array = np.stack(unified_images, axis=0) + + batch, _ = self.composer(image_array, np.ones((1, 4, 4, 2))) + batch = torch.from_numpy(batch).to(self.device) + + with torch.no_grad(): + output = self.run_inference(batch) + output = output.cpu().numpy() + + for i, heatmap in enumerate(output): + image = images[i] + layout = PageLayout(heatmap) + result = layout.detect(image, ratio) + yield result diff --git a/backend/python-services/services/loc_service.py b/backend/python-services/services/loc_service.py new file mode 100644 index 0000000000000000000000000000000000000000..aaad42191fb1825ec10a7d182750702fddcc089c --- /dev/null +++ b/backend/python-services/services/loc_service.py @@ -0,0 +1,374 @@ +""" +Location detection service. +Detects text regions and classifies them into 13 categories. + +Uses DB_gc_loc architecture: ResNet-18 backbone + SegDetector decoder. +Supports both TorchScript (.pt) models and state_dict checkpoints. +""" + +import os +import math +import numpy as np +import torch +import torch.nn as nn +import torch.nn.functional as F +import cv2 +import logging +from collections import OrderedDict + +from predictors.torchscript_predictor import resolve_model_path +from common.image_utils import array_from_image_stream + + +# RGB mean for normalization (from original implementation) +RGB_MEAN = np.array([122.67891434, 116.66876762, 104.00698793]) + +# Text type categories +TYPE_NAMES = [ + 'Title', # 0 + 'Author', # 1 + 'TextualMark', # 2 + 'TempoNumeral', # 3 + 'MeasureNumber', # 4 + 'Times', # 5 + 'Chord', # 6 + 'PageMargin', # 7 + 'Instrument', # 8 + 'Other', # 9 + 'Lyric', # 10 + 'Alter1', # 11 + 'Alter2', # 12 +] + + +# ===================== ResNet-18 Backbone ===================== + +def _conv3x3(in_planes, out_planes, stride=1): + return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, + padding=1, bias=False) + + +class _BasicBlock(nn.Module): + expansion = 1 + + def __init__(self, inplanes, planes, stride=1, downsample=None): + super().__init__() + self.conv1 = _conv3x3(inplanes, planes, stride) + self.bn1 = nn.BatchNorm2d(planes) + self.relu = nn.ReLU(inplace=True) + self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, padding=1, bias=False) + self.bn2 = nn.BatchNorm2d(planes) + self.downsample = downsample + + def forward(self, x): + residual = x + out = self.relu(self.bn1(self.conv1(x))) + out = self.bn2(self.conv2(out)) + if self.downsample is not None: + residual = self.downsample(x) + out += residual + return self.relu(out) + + +class _ResNet(nn.Module): + def __init__(self, block, layers): + super().__init__() + self.inplanes = 64 + self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False) + self.bn1 = nn.BatchNorm2d(64) + self.relu = nn.ReLU(inplace=True) + self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) + self.layer1 = self._make_layer(block, 64, layers[0]) + self.layer2 = self._make_layer(block, 128, layers[1], stride=2) + self.layer3 = self._make_layer(block, 256, layers[2], stride=2) + self.layer4 = self._make_layer(block, 512, layers[3], stride=2) + # Not used in forward but exist in original model (needed for weight loading) + self.avgpool = nn.AvgPool2d(7, stride=1) + self.fc = nn.Linear(512, 1000) + self.smooth = nn.Conv2d(2048, 256, kernel_size=1, stride=1, padding=1) + + def _make_layer(self, block, planes, blocks, stride=1): + downsample = None + if stride != 1 or self.inplanes != planes * block.expansion: + downsample = nn.Sequential( + nn.Conv2d(self.inplanes, planes * block.expansion, + kernel_size=1, stride=stride, bias=False), + nn.BatchNorm2d(planes * block.expansion), + ) + layers = [block(self.inplanes, planes, stride, downsample)] + self.inplanes = planes * block.expansion + for _ in range(1, blocks): + layers.append(block(self.inplanes, planes)) + return nn.Sequential(*layers) + + def forward(self, x): + x = self.maxpool(self.relu(self.bn1(self.conv1(x)))) + x2 = self.layer1(x) + x3 = self.layer2(x2) + x4 = self.layer3(x3) + x5 = self.layer4(x4) + return x2, x3, x4, x5 + + +# ===================== SegDetector Decoder ===================== + +class _SegDetector(nn.Module): + def __init__(self, n_cls=13, in_channels=(64, 128, 256, 512), + inner_channels=256, k=50, bias=False, adaptive=True): + super().__init__() + self.k = k + self.up5 = nn.Upsample(scale_factor=2, mode='nearest') + self.up4 = nn.Upsample(scale_factor=2, mode='nearest') + self.up3 = nn.Upsample(scale_factor=2, mode='nearest') + + self.in5 = nn.Conv2d(in_channels[-1], inner_channels, 1, bias=bias) + self.in4 = nn.Conv2d(in_channels[-2], inner_channels, 1, bias=bias) + self.in3 = nn.Conv2d(in_channels[-3], inner_channels, 1, bias=bias) + self.in2 = nn.Conv2d(in_channels[-4], inner_channels, 1, bias=bias) + + self.out5 = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.Upsample(scale_factor=8, mode='nearest')) + self.out4 = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.Upsample(scale_factor=4, mode='nearest')) + self.out3 = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.Upsample(scale_factor=2, mode='nearest')) + self.out2 = nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias) + + self.binarize = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, inner_channels // 4, 2, 2), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, 1, 2, 2), + nn.Sigmoid()) + + self.mulclass = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, inner_channels // 4, 2, 2), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, n_cls, 2, 2)) + + if adaptive: + self.thresh = nn.Sequential( + nn.Conv2d(inner_channels, inner_channels // 4, 3, padding=1, bias=bias), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, inner_channels // 4, 2, 2), + nn.BatchNorm2d(inner_channels // 4), + nn.ReLU(inplace=True), + nn.ConvTranspose2d(inner_channels // 4, 1, 2, 2), + nn.Sigmoid()) + + def forward(self, features): + c2, c3, c4, c5 = features + in5 = self.in5(c5) + in4 = self.in4(c4) + in3 = self.in3(c3) + in2 = self.in2(c2) + + out4 = self.up5(in5) + in4 + out3 = self.up4(out4) + in3 + out2 = self.up3(out3) + in2 + + p5 = self.out5(in5) + p4 = self.out4(out4) + p3 = self.out3(out3) + p2 = self.out2(out2) + + fuse = torch.cat((p5, p4, p3, p2), 1) + binary = self.binarize(fuse) + mcls = self.mulclass(fuse) + return binary, mcls + + +class _LocModel(nn.Module): + """ResNet-18 + SegDetector combined model for text localization.""" + + def __init__(self): + super().__init__() + self.backbone = _ResNet(_BasicBlock, [2, 2, 2, 2]) + self.decoder = _SegDetector(n_cls=13, adaptive=True, k=50) + + def forward(self, x): + return self.decoder(self.backbone(x)) + + +def _load_loc_model(model_path, device): + """Load loc model, handling both TorchScript and state_dict formats. + + First tries TorchScript loading; on failure, builds architecture and loads state_dict. + """ + resolved = resolve_model_path(model_path) + + # Try TorchScript first + try: + model = torch.jit.load(resolved, map_location=device) + model.eval() + logging.info('LocService: TorchScript model loaded: %s', resolved) + return model + except Exception as e: + logging.info('LocService: not TorchScript (%s), trying state_dict...', str(e)[:60]) + + # Fall back to state_dict loading with embedded architecture + checkpoint = torch.load(resolved, map_location=device, weights_only=False) + + if isinstance(checkpoint, dict) and 'model' in checkpoint: + state_dict = checkpoint['model'] + elif isinstance(checkpoint, OrderedDict): + state_dict = checkpoint + else: + state_dict = checkpoint + + # Strip 'model.module.' prefix (SegDetectorModel → DataParallel wrapping) + new_state_dict = OrderedDict() + for key, value in state_dict.items(): + new_key = key + if new_key.startswith('model.module.'): + new_key = new_key[len('model.module.'):] + elif new_key.startswith('module.'): + new_key = new_key[len('module.'):] + new_state_dict[new_key] = value + + model = _LocModel() + model.load_state_dict(new_state_dict, strict=False) + model.eval() + model.to(device) + + # Log key loading stats + model_keys = set(model.state_dict().keys()) + loaded_keys = set(new_state_dict.keys()) + matched = model_keys & loaded_keys + logging.info('LocService: state_dict loaded: %s (%d/%d keys matched)', + resolved, len(matched), len(model_keys)) + + return model + + +class LocService: + """ + Location detection service. + + Uses DB_gc_loc architecture (ResNet-18 + SegDetector). + Supports both TorchScript models and state_dict checkpoints. + """ + + def __init__(self, model_path, device='cuda', image_short_side=736, + box_thresh=0.01, class_num=13, **kwargs): + self.device = device + self.model = _load_loc_model(model_path, device) + self.image_short_side = image_short_side + self.box_thresh = box_thresh + self.class_num = class_num + + def resize_image(self, img): + """Resize image keeping aspect ratio, with short side = image_short_side.""" + height, width = img.shape[:2] + if height < width: + new_height = self.image_short_side + new_width = int(math.ceil(new_height / height * width / 32) * 32) + else: + new_width = self.image_short_side + new_height = int(math.ceil(new_width / width * height / 32) * 32) + return cv2.resize(img, (new_width, new_height)) + + def preprocess(self, image): + """Preprocess image for model input.""" + img = image.astype('float32') + original_shape = img.shape[:2] + img = self.resize_image(img) + img -= RGB_MEAN + img /= 255. + img = torch.from_numpy(img).permute(2, 0, 1).float().unsqueeze(0) + return img.to(self.device), original_shape + + def represent_boxes(self, pred, out_class, original_shape, resized_shape): + """Post-process model output to extract bounding boxes.""" + pred_np = pred.cpu().numpy()[0, 0] + class_np = out_class.cpu().numpy()[0, 0] + + binary = (pred_np > self.box_thresh).astype(np.uint8) * 255 + contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + boxes = [] + h_scale = original_shape[0] / resized_shape[0] + w_scale = original_shape[1] / resized_shape[1] + + for contour in contours: + if len(contour) < 4: + continue + + rect = cv2.minAreaRect(contour) + box_points = cv2.boxPoints(rect) + box_points = np.int0(box_points) + + mask = np.zeros(pred_np.shape, dtype=np.uint8) + cv2.drawContours(mask, [contour], -1, 1, -1) + class_region = class_np * mask + if mask.sum() > 0: + box_class = int(np.argmax(np.bincount(class_region[mask > 0].astype(int)))) + else: + box_class = 0 + + score_region = pred_np * mask + score = score_region.sum() / max(mask.sum(), 1) + + scaled_points = box_points.astype(float) + scaled_points[:, 0] *= w_scale + scaled_points[:, 1] *= h_scale + + boxes.append({ + 'x0': float(scaled_points[0, 0]), + 'y0': float(scaled_points[0, 1]), + 'x1': float(scaled_points[1, 0]), + 'y1': float(scaled_points[1, 1]), + 'x2': float(scaled_points[2, 0]), + 'y2': float(scaled_points[2, 1]), + 'x3': float(scaled_points[3, 0]), + 'y3': float(scaled_points[3, 1]), + 'score': float(score), + 'class': box_class, + }) + + return boxes + + def predict(self, buffers, **kwargs): + """Detect text regions in images.""" + for buffer in buffers: + image = array_from_image_stream(buffer) + if image is None: + yield [] + continue + + img_tensor, original_shape = self.preprocess(image) + resized_shape = (img_tensor.shape[2], img_tensor.shape[3]) + + with torch.no_grad(): + output = self.model(img_tensor) + + if isinstance(output, tuple) and len(output) == 2: + pred, mcls = output + else: + pred = output + mcls = torch.zeros_like(pred) + + b, c, h, w = mcls.shape + out_class = mcls.permute(0, 2, 3, 1).reshape(-1, self.class_num) + out_class = F.softmax(out_class, -1) + out_class = out_class.max(1)[1].reshape(b, h, w).unsqueeze(1) + + boxes = self.represent_boxes(pred, out_class, original_shape, resized_shape) + + valid_boxes = [] + for box in boxes: + if not (box['x0'] == box['x1'] and box['x2'] == box['x1']): + valid_boxes.append(box) + + yield valid_boxes diff --git a/backend/python-services/services/mask_service.py b/backend/python-services/services/mask_service.py new file mode 100644 index 0000000000000000000000000000000000000000..cb04d91f1ae0db840b1c605e9c1834f8ce4936e7 --- /dev/null +++ b/backend/python-services/services/mask_service.py @@ -0,0 +1,85 @@ +""" +Mask prediction service. +Generates staff foreground/background mask. +""" + +import numpy as np +import torch +import PIL.Image + +from predictors.torchscript_predictor import TorchScriptPredictor +from common.image_utils import ( + array_from_image_stream, slice_feature, splice_output_tensor, + mask_to_alpha, encode_image_base64, encode_image_bytes, + MARGIN_DIVIDER +) +from common.transform import Composer + + +class StaffMask: + """Staff mask representation.""" + + def __init__(self, hotmap): + """ + hotmap: (2, H, W) - channels: [foreground, background] + """ + hotmap = mask_to_alpha(hotmap, frac_y=True) + self.image = PIL.Image.fromarray(hotmap, 'LA') + + def json(self): + return { + 'image': encode_image_base64(self.image), + } + + +class MaskService(TorchScriptPredictor): + """Mask prediction service using TorchScript model.""" + + DEFAULT_TRANS = ['Mono', 'HWC2CHW'] + DEFAULT_SLICING_WIDTH = 512 + + def __init__(self, model_path, device='cuda', trans=None, slicing_width=None): + super().__init__(model_path, device) + self.composer = Composer(trans or self.DEFAULT_TRANS) + self.slicing_width = slicing_width or self.DEFAULT_SLICING_WIDTH + + def predict(self, streams, by_buffer=False, **kwargs): + """ + Predict staff mask from image streams. + streams: list of image byte buffers + by_buffer: if True, return raw bytes instead of base64 + yields: mask results + """ + for stream in streams: + image = array_from_image_stream(stream) + if image is None: + yield {'error': 'Invalid image'} + continue + + # Slice image into overlapping pieces + pieces = list(slice_feature( + image, + width=self.slicing_width, + overlapping=2 / MARGIN_DIVIDER, + padding=False + )) + pieces = np.array(pieces, dtype=np.float32) + + # Transform + staves, _ = self.composer(pieces, np.ones((1, 4, 4, 2))) + batch = torch.from_numpy(staves).to(self.device) + + # Inference + output = self.run_inference(batch) # (batch, channel, height, width) + + # Splice output + hotmap = splice_output_tensor(output, soft=True) # (channel, height, width) + if hotmap.shape[2] > image.shape[1]: + hotmap = hotmap[:, :, :image.shape[1]] + + mask = StaffMask(hotmap) + encoder = encode_image_bytes if by_buffer else encode_image_base64 + + yield { + 'image': encoder(mask.image), + } diff --git a/backend/python-services/services/ocr_service.py b/backend/python-services/services/ocr_service.py new file mode 100644 index 0000000000000000000000000000000000000000..afb9c087a4826920fa4c09c2814fa196f4ec70be --- /dev/null +++ b/backend/python-services/services/ocr_service.py @@ -0,0 +1,207 @@ +""" +OCR prediction service. +Recognizes text content from detected regions using DenseNet-CTC. +""" + +import math +import numpy as np +import cv2 +import logging + +from predictors.densenet_ctc import load_densenet_ctc, greedy_ctc_decode +from common.image_utils import array_from_image_stream + + +# Text type categories (same as loc_service) +TYPE_NAMES = [ + 'Title', # 0 + 'Author', # 1 + 'TextualMark', # 2 + 'TempoNumeral', # 3 + 'MeasureNumber', # 4 + 'Times', # 5 + 'Chord', # 6 + 'PageMargin', # 7 + 'Instrument', # 8 + 'Other', # 9 + 'Lyric', # 10 + 'Alter1', # 11 + 'Alter2', # 12 +] + +# Tempo character mapping (musical note symbols) +TEMPO_CHAR_DICT = { + 'a': '\U0001d15d', # Whole Note + 'b': '\U0001d15e', # Half Note + 'c': '\U0001d15f', # Quarter Note + 'd': '\U0001d160', # Eighth Note + 'e': '\U0001d161', # Sixteenth Note + 'f': '\U0001d162', # Thirty-Second Note +} + + +def translate_string_by_dict(s, d): + """Translate characters in string using dictionary.""" + return ''.join(d.get(c, c) for c in s) + + +class OcrService: + """ + OCR service using DenseNet-CTC architecture. + """ + + def __init__(self, model_path, device='gpu', alphabet=None, + tempo_model_path=None, tempo_alphabet=None, + chord_model_path=None, **kwargs): + self.alphabet = alphabet or '' + self.tempo_alphabet = tempo_alphabet or '' + + # nclass = alphabet length + 1 (blank token '卍') + nclass = len(self.alphabet) + 1 + self.model = load_densenet_ctc(model_path, nclass) + + # Load tempo model + self.tempo_model = None + if tempo_model_path: + tempo_nclass = len(self.tempo_alphabet) + 1 + self.tempo_model = load_densenet_ctc(tempo_model_path, tempo_nclass) + + # Chord model (SavedModel directory, different architecture) + self.chord_model = None + if chord_model_path and chord_model_path.endswith('/'): + try: + import tensorflow as tf + self.chord_model = tf.keras.models.load_model(chord_model_path, compile=False) + logging.info('Chord model loaded: %s', chord_model_path) + except Exception as e: + logging.warning('Failed to load chord model: %s', e) + + def preprocess_image(self, image, target_height=32): + """Preprocess image for DenseNet-CTC model.""" + h, w = image.shape[:2] + if len(image.shape) == 3: + image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) + + scale = target_height / h + new_w = int(w * scale) + if new_w < 9: + return None + + image = cv2.resize(image, (new_w, target_height)) + image = image.astype(np.float32) / 255.0 - 0.5 + image = np.expand_dims(image, axis=(0, -1)) # (1, H, W, 1) + + return image + + def perspective_transform(self, image, box): + """Apply perspective transform to extract text region.""" + pts1 = np.float32([ + [box['x0'], box['y0']], + [box['x1'], box['y1']], + [box['x2'], box['y2']], + [box['x3'], box['y3']] + ]) + + trans_width = round(math.sqrt( + (box['x0'] - box['x1']) ** 2 + (box['y0'] - box['y1']) ** 2 + )) + trans_height = round(math.sqrt( + (box['x0'] - box['x3']) ** 2 + (box['y0'] - box['y3']) ** 2 + )) + + if trans_width < 1 or trans_height < 1: + return None + + pts2 = np.float32([ + [0, 0], + [trans_width, 0], + [trans_width, trans_height], + [0, trans_height] + ]) + + M = cv2.getPerspectiveTransform(pts1, pts2) + dst = cv2.warpPerspective(image, M, (trans_width, trans_height)) + + return dst + + def predict(self, buffers, location=None, **kwargs): + """ + Recognize text from image with location info. + + buffers: list containing single image buffer + location: list of detected boxes from loc_service + yields: recognition results + """ + if not buffers: + yield {'error': 'No image provided'} + return + + image = array_from_image_stream(buffers[0]) + if image is None: + yield {'error': 'Invalid image'} + return + + if not location: + yield {'imageSize': list(image.shape[:2]), 'areas': []} + return + + areas = [] + + for box in location: + dst_pic = self.perspective_transform(image, box) + if dst_pic is None: + continue + + cx = (box['x0'] + box['x1'] + box['x2'] + box['x3']) / 4 + cy = (box['y0'] + box['y1'] + box['y2'] + box['y3']) / 4 + width = (box['x1'] + box['x2'] - box['x0'] - box['x3']) / 2 + height = (box['y2'] + box['y3'] - box['y0'] - box['y1']) / 2 + theta = math.atan2( + box['y1'] - box['y0'] + box['y2'] - box['y3'], + box['x1'] - box['x0'] + box['x2'] - box['x3'] + ) + text_type = TYPE_NAMES[box.get('class', 0)] + + text = '' + feature_dict = None + + try: + if text_type == 'TempoNumeral' and self.tempo_model is not None: + processed = self.preprocess_image(dst_pic) + if processed is not None: + pred = self.tempo_model.predict(processed, verbose=0) + text = greedy_ctc_decode(pred, self.tempo_alphabet) + text = translate_string_by_dict(text, TEMPO_CHAR_DICT) + + elif text_type == 'Chord' and self.chord_model is not None: + processed = self.preprocess_image(dst_pic) + if processed is not None: + pred = self.chord_model.predict(processed, verbose=0) + text = greedy_ctc_decode(pred, self.alphabet) + + else: + processed = self.preprocess_image(dst_pic) + if processed is not None: + pred = self.model.predict(processed, verbose=0) + text = greedy_ctc_decode(pred, self.alphabet) + + except Exception as e: + logging.warning('OCR prediction error: %s', str(e)) + text = '' + + areas.append({ + 'score': box.get('score', 0), + 'text': text, + 'feature_dict': feature_dict, + 'cx': cx, + 'cy': cy, + 'width': width, + 'height': height, + 'theta': theta, + 'type': text_type, + }) + + yield { + 'imageSize': list(image.shape[:2]), + 'areas': areas, + } diff --git a/backend/python-services/services/semantic_service.py b/backend/python-services/services/semantic_service.py new file mode 100644 index 0000000000000000000000000000000000000000..8b6f651f69c5ce81bf8fe63944ce7533c5e68e6a --- /dev/null +++ b/backend/python-services/services/semantic_service.py @@ -0,0 +1,390 @@ +""" +Semantic prediction service. +Detects and classifies musical symbols (notes, rests, clefs, etc.). +Supports both single-model and multi-model cluster directories. +""" + +import os +import re +import math +import numpy as np +import torch +import cv2 +import yaml +import logging + +from predictors.torchscript_predictor import TorchScriptPredictor, resolve_model_path +from common.image_utils import ( + array_from_image_stream, slice_feature, splice_output_tensor, + MARGIN_DIVIDER +) +from common.transform import Composer + + +VERTICAL_UNITS = 24. +POINT_RADIUS_MAX = 8 + + +def detect_points(heatmap, vertical_units=24): + """Detect point features (notes, symbols) in heatmap.""" + unit = heatmap.shape[0] / vertical_units + y0 = heatmap.shape[0] / 2.0 + + blur_kernel = (heatmap.shape[0] // 128) * 2 + 1 + if blur_kernel > 1: + heatmap_blur = cv2.GaussianBlur(heatmap, (blur_kernel, blur_kernel), 0) + else: + heatmap_blur = heatmap + + thresh = cv2.adaptiveThreshold( + heatmap_blur, 255, + cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 3, 0 + ) + contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + points = [] + for c in contours: + (x, y), radius = cv2.minEnclosingCircle(c) + + confidence = 0 + for px in range(max(math.floor(x - radius), 0), min(math.ceil(x + radius), heatmap.shape[1])): + for py in range(max(math.floor(y - radius), 0), min(math.ceil(y + radius), heatmap.shape[0])): + confidence += heatmap[py, px] / 255. + + if radius < POINT_RADIUS_MAX: + points.append({ + 'mark': (x, y, radius), + 'x': x / unit, + 'y': (y - y0) / unit, + 'confidence': float(confidence), + }) + + return points + + +def detect_vlines(heatmap, vertical_units=24): + """Detect vertical line features (barlines, stems) in heatmap.""" + unit = heatmap.shape[0] / vertical_units + y0 = heatmap.shape[0] / 2.0 + + blur_kernel = (heatmap.shape[0] // 128) * 2 + 1 + if blur_kernel > 1: + heatmap_blur = cv2.GaussianBlur(heatmap, (blur_kernel, blur_kernel), 0) + else: + heatmap_blur = heatmap + + thresh = cv2.adaptiveThreshold( + heatmap_blur, 255, + cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 3, 0 + ) + contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + lines = [] + for contour in contours: + left, top, width, height = cv2.boundingRect(contour) + x = (left + width / 2) / unit + y1 = (top - y0) / unit + y2 = (top + height - y0) / unit + + confidence = 0 + for px in range(left, left + width): + for py in range(top, top + height): + confidence += heatmap[py, px] / 255. + + length = max(height, 2.5) + confidence /= length * 0.8 + + lines.append({ + 'x': x, + 'y': y1, + 'extension': {'y1': y1, 'y2': y2}, + 'confidence': float(confidence), + 'mark': (left + width / 2, top, top + height), + }) + + return lines + + +def detect_rectangles(heatmap, vertical_units=24): + """Detect rectangular features (text boxes) in heatmap.""" + unit = heatmap.shape[0] / vertical_units + y0 = heatmap.shape[0] / 2.0 + + _, thresh = cv2.threshold(heatmap, 92, 255, cv2.THRESH_BINARY) + contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + rects = [] + for contour in contours: + left, top, width, height = cv2.boundingRect(contour) + if width * height / unit / unit < 2: + continue + + x = (left + width / 2) / unit + y = (top + height / 2) / unit + + confidence = 0 + for px in range(left, left + width): + for py in range(top, top + height): + confidence += heatmap[py, px] / 255. + confidence /= width * height + + rects.append({ + 'x': x, + 'y': y - y0 / unit, + 'extension': {'width': width / unit, 'height': height / unit}, + 'confidence': float(confidence), + 'mark': (left, top, width, height), + }) + + return rects + + +def detect_boxes(heatmap, vertical_units=24): + """Detect rotated box features in heatmap.""" + unit = heatmap.shape[0] / vertical_units + + _, thresh = cv2.threshold(heatmap, 92, 255, cv2.THRESH_BINARY) + contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + + rects = [] + for contour in contours: + rect = cv2.minAreaRect(contour) + pos, size, theta = rect + confidence = math.sqrt(size[0] * size[1]) + + if min(*size) / unit < 8: + continue + + rects.append({ + 'x': pos[0], + 'y': pos[1], + 'extension': {'width': size[0], 'height': size[1], 'theta': theta}, + 'confidence': confidence, + 'mark': rect, + }) + + return rects + + +class ScoreSemantic: + """Score semantic analysis results.""" + + def __init__(self, heatmaps, labels, confidence_table=None): + self.data = { + '__prototype': 'SemanticGraph', + 'points': [], + 'staffY': None, + } + + assert len(labels) == len(heatmaps), \ + f'classes - heatmaps count mismatch: {len(labels)} - {len(heatmaps)}' + + for i, semantic in enumerate(labels): + mean_confidence = 1 + if confidence_table is not None: + item = confidence_table[i] + assert item['semantic'] == semantic + mean_confidence = max(item['mean_confidence'], 1e-4) + + if re.match(r'^vline_', semantic): + lines = detect_vlines(heatmaps[i], vertical_units=VERTICAL_UNITS) + for line in lines: + self.data['points'].append({ + 'semantic': semantic, + 'x': line['x'], + 'y': line['y'], + 'extension': line['extension'], + 'confidence': line['confidence'] / mean_confidence, + }) + elif re.match(r'^rect_', semantic): + rectangles = detect_rectangles(heatmaps[i], vertical_units=VERTICAL_UNITS) + for rect in rectangles: + self.data['points'].append({ + 'semantic': semantic, + 'x': rect['x'], + 'y': rect['y'], + 'extension': rect['extension'], + 'confidence': rect['confidence'] / mean_confidence, + }) + elif re.match(r'^box_', semantic): + boxes = detect_boxes(heatmaps[i], vertical_units=VERTICAL_UNITS) + for rect in boxes: + self.data['points'].append({ + 'semantic': semantic, + 'x': rect['x'], + 'y': rect['y'], + 'extension': rect['extension'], + 'confidence': rect['confidence'] / mean_confidence, + }) + else: + points = detect_points(heatmaps[i], vertical_units=VERTICAL_UNITS) + for point in points: + self.data['points'].append({ + 'semantic': semantic, + 'x': point['x'], + 'y': point['y'], + 'confidence': point['confidence'] / mean_confidence, + }) + + def json(self): + return self.data + + +def _is_cluster_dir(model_path): + """Check if model_path is a semantic cluster directory (has 'subs' in .state.yaml).""" + if not os.path.isdir(model_path): + return False + state_file = os.path.join(model_path, '.state.yaml') + if not os.path.exists(state_file): + return False + with open(state_file, 'r') as f: + state = yaml.safe_load(f) + return 'subs' in state + + +class SemanticService: + """Semantic prediction service. + + Handles both single TorchScript models and multi-model cluster directories. + A cluster directory has a .state.yaml with 'subs' listing sub-model directories. + """ + + DEFAULT_TRANS = ['Mono', 'HWC2CHW'] + DEFAULT_SLICING_WIDTH = 512 + + def __init__(self, model_path, device='cuda', trans=None, slicing_width=None, + labels=None, confidence_table=None, **kwargs): + self.device = device + + if _is_cluster_dir(model_path): + self._init_cluster(model_path, device, trans, slicing_width) + else: + self._init_single(model_path, device, trans, slicing_width, labels, confidence_table) + + def _init_single(self, model_path, device, trans, slicing_width, labels, confidence_table): + """Initialize with a single TorchScript model.""" + resolved = resolve_model_path(model_path) + self.model = torch.jit.load(resolved, map_location=device) + self.model.eval() + self.sub_models = None + self.composer = Composer(trans or self.DEFAULT_TRANS) + self.slicing_width = slicing_width or self.DEFAULT_SLICING_WIDTH + self.labels = labels or [] + self.confidence_table = confidence_table + logging.info('SemanticService: single model loaded: %s', resolved) + + def _init_cluster(self, model_path, device, trans, slicing_width): + """Initialize with a multi-model cluster directory.""" + state_file = os.path.join(model_path, '.state.yaml') + with open(state_file, 'r') as f: + cluster_state = yaml.safe_load(f) + + # Get predictor config from cluster .state.yaml + predictor_config = cluster_state.get('predictor', {}) + self.composer = Composer( + trans or predictor_config.get('trans') or self.DEFAULT_TRANS + ) + self.slicing_width = ( + slicing_width + or predictor_config.get('slicing_width') + or self.DEFAULT_SLICING_WIDTH + ) + + # Confidence table dict from cluster config + ct_dict = predictor_config.get('confidence_table', {}) + + # Load each sub-model + self.sub_models = [] + self.labels = [] + subs = cluster_state.get('subs', []) + + for sub_name in subs: + sub_dir = os.path.join(model_path, sub_name) + sub_state_file = os.path.join(sub_dir, '.state.yaml') + with open(sub_state_file, 'r') as f: + sub_state = yaml.safe_load(f) + + sub_labels = sub_state.get('data', {}).get('args', {}).get('labels', []) + sub_model_file = resolve_model_path(sub_dir) + + model = torch.jit.load(sub_model_file, map_location=device) + model.eval() + + self.sub_models.append(model) + self.labels.extend(sub_labels) + logging.info(' sub-model %s: %d labels, file=%s', + sub_name, len(sub_labels), os.path.basename(sub_model_file)) + + # Build confidence table list matching label order + self.confidence_table = None + if ct_dict: + self.confidence_table = [] + for label in self.labels: + mean_conf = ct_dict.get(label, 1.0) + self.confidence_table.append({ + 'semantic': label, + 'mean_confidence': mean_conf, + }) + + self.model = None # not used for cluster + logging.info('SemanticService: cluster loaded with %d sub-models, %d total labels', + len(self.sub_models), len(self.labels)) + + def run_inference(self, batch): + """Run model inference with no_grad context.""" + with torch.no_grad(): + if self.sub_models is not None: + # Cluster: run each sub-model and concatenate channels + outputs = [] + for model in self.sub_models: + output = model(batch) + if isinstance(output, tuple): + _, semantic = output + else: + semantic = output + outputs.append(semantic) + return torch.cat(outputs, dim=1) + else: + return self.model(batch) + + def predict(self, streams, **kwargs): + """ + Predict semantic symbols from image streams. + streams: list of image byte buffers + yields: semantic graph results + """ + for stream in streams: + image = array_from_image_stream(stream) + if image is None: + yield {'error': 'Invalid image'} + continue + + # Slice image + pieces = list(slice_feature( + image, + width=self.slicing_width, + overlapping=2 / MARGIN_DIVIDER, + padding=True + )) + pieces = np.array(pieces, dtype=np.uint8) + + # Transform + staves, _ = self.composer(pieces, np.ones((1, 4, 4, 2))) + batch = torch.from_numpy(staves).to(self.device) + + # Inference + output = self.run_inference(batch) + + # Handle tuple output (single model case) + if isinstance(output, tuple): + _, output = output + + semantic = splice_output_tensor(output) + + # Build semantic result + ss = ScoreSemantic( + np.uint8(semantic * 255), + self.labels, + confidence_table=self.confidence_table + ) + yield ss.json() diff --git a/dist/assets/index-76aea0c0.js b/dist/assets/index-76aea0c0.js index 9e5eb21fa249fe5d79f381470c507ddb22df7ffd..37bf698a69fb44c47c89e8d924d77886bdc3e2f8 100644 --- a/dist/assets/index-76aea0c0.js +++ b/dist/assets/index-76aea0c0.js @@ -1570,4 +1570,4 @@ https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof e.getDerivedStat * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - */var Fo=typeof window<"u"&&typeof document<"u"&&typeof navigator<"u",lA=function(){for(var e=["Edge","Trident","Firefox"],t=0;t=0)return 1;return 0}();function cA(e){var t=!1;return function(){t||(t=!0,window.Promise.resolve().then(function(){t=!1,e()}))}}function uA(e){var t=!1;return function(){t||(t=!0,setTimeout(function(){t=!1,e()},lA))}}var hA=Fo&&window.Promise,dA=hA?cA:uA;function g2(e){var t={};return e&&t.toString.call(e)==="[object Function]"}function fi(e,t){if(e.nodeType!==1)return[];var n=e.ownerDocument.defaultView,r=n.getComputedStyle(e,null);return t?r[t]:r}function uc(e){return e.nodeName==="HTML"?e:e.parentNode||e.host}function Wo(e){if(!e)return document.body;switch(e.nodeName){case"HTML":case"BODY":return e.ownerDocument.body;case"#document":return e.body}var t=fi(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/(auto|scroll|overlay)/.test(n+o+r)?e:Wo(uc(e))}function m2(e){return e&&e.referenceNode?e.referenceNode:e}var Ou=Fo&&!!(window.MSInputMethodContext&&document.documentMode),Pu=Fo&&/MSIE 10/.test(navigator.userAgent);function Wi(e){return e===11?Ou:e===10?Pu:Ou||Pu}function Ni(e){if(!e)return document.documentElement;for(var t=Wi(10)?document.body:null,n=e.offsetParent||null;n===t&&e.nextElementSibling;)n=(e=e.nextElementSibling).offsetParent;var r=n&&n.nodeName;return!r||r==="BODY"||r==="HTML"?e?e.ownerDocument.documentElement:document.documentElement:["TH","TD","TABLE"].indexOf(n.nodeName)!==-1&&fi(n,"position")==="static"?Ni(n):n}function pA(e){var t=e.nodeName;return t==="BODY"?!1:t==="HTML"||Ni(e.firstElementChild)===e}function Da(e){return e.parentNode!==null?Da(e.parentNode):e}function F1(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return document.documentElement;var n=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,r=n?e:t,o=n?t:e,s=document.createRange();s.setStart(r,0),s.setEnd(o,0);var i=s.commonAncestorContainer;if(e!==i&&t!==i||r.contains(o))return pA(i)?i:Ni(i);var d=Da(e);return d.host?F1(d.host,t):F1(e,Da(t).host)}function Oi(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"top",n=t==="top"?"scrollTop":"scrollLeft",r=e.nodeName;if(r==="BODY"||r==="HTML"){var o=e.ownerDocument.documentElement,s=e.ownerDocument.scrollingElement||o;return s[n]}return e[n]}function fA(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=Oi(t,"top"),o=Oi(t,"left"),s=n?-1:1;return e.top+=r*s,e.bottom+=r*s,e.left+=o*s,e.right+=o*s,e}function Du(e,t){var n=t==="x"?"Left":"Top",r=n==="Left"?"Right":"Bottom";return parseFloat(e["border"+n+"Width"])+parseFloat(e["border"+r+"Width"])}function $u(e,t,n,r){return Math.max(t["offset"+e],t["scroll"+e],n["client"+e],n["offset"+e],n["scroll"+e],Wi(10)?parseInt(n["offset"+e])+parseInt(r["margin"+(e==="Height"?"Top":"Left")])+parseInt(r["margin"+(e==="Height"?"Bottom":"Right")]):0)}function v2(e){var t=e.body,n=e.documentElement,r=Wi(10)&&getComputedStyle(n);return{height:$u("Height",t,n,r),width:$u("Width",t,n,r)}}var gA=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},mA=function(){function e(t,n){for(var r=0;r2&&arguments[2]!==void 0?arguments[2]:!1,r=Wi(10),o=t.nodeName==="HTML",s=$a(e),i=$a(t),d=Wo(e),S=fi(t),g=parseFloat(S.borderTopWidth),w=parseFloat(S.borderLeftWidth);n&&o&&(i.top=Math.max(i.top,0),i.left=Math.max(i.left,0));var M=Br({top:s.top-i.top-g,left:s.left-i.left-w,width:s.width,height:s.height});if(M.marginTop=0,M.marginLeft=0,!r&&o){var R=parseFloat(S.marginTop),V=parseFloat(S.marginLeft);M.top-=g-R,M.bottom-=g-R,M.left-=w-V,M.right-=w-V,M.marginTop=R,M.marginLeft=V}return(r&&!n?t.contains(d):t===d&&d.nodeName!=="BODY")&&(M=fA(M,t)),M}function vA(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=e.ownerDocument.documentElement,r=hc(e,n),o=Math.max(n.clientWidth,window.innerWidth||0),s=Math.max(n.clientHeight,window.innerHeight||0),i=t?0:Oi(n),d=t?0:Oi(n,"left"),S={top:i-r.top+r.marginTop,left:d-r.left+r.marginLeft,width:o,height:s};return Br(S)}function y2(e){var t=e.nodeName;if(t==="BODY"||t==="HTML")return!1;if(fi(e,"position")==="fixed")return!0;var n=uc(e);return n?y2(n):!1}function C2(e){if(!e||!e.parentElement||Wi())return document.documentElement;for(var t=e.parentElement;t&&fi(t,"transform")==="none";)t=t.parentElement;return t||document.documentElement}function dc(e,t,n,r){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,s={top:0,left:0},i=o?C2(e):F1(e,m2(t));if(r==="viewport")s=vA(i,o);else{var d=void 0;r==="scrollParent"?(d=Wo(uc(t)),d.nodeName==="BODY"&&(d=e.ownerDocument.documentElement)):r==="window"?d=e.ownerDocument.documentElement:d=r;var S=hc(d,i,o);if(d.nodeName==="HTML"&&!y2(i)){var g=v2(e.ownerDocument),w=g.height,M=g.width;s.top+=S.top-S.marginTop,s.bottom=w+S.top,s.left+=S.left-S.marginLeft,s.right=M+S.left}else s=S}n=n||0;var R=typeof n=="number";return s.left+=R?n:n.left||0,s.top+=R?n:n.top||0,s.right-=R?n:n.right||0,s.bottom-=R?n:n.bottom||0,s}function yA(e){var t=e.width,n=e.height;return t*n}function b2(e,t,n,r,o){var s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;if(e.indexOf("auto")===-1)return e;var i=dc(n,r,s,o),d={top:{width:i.width,height:t.top-i.top},right:{width:i.right-t.right,height:i.height},bottom:{width:i.width,height:i.bottom-t.bottom},left:{width:t.left-i.left,height:i.height}},S=Object.keys(d).map(function(R){return Yn({key:R},d[R],{area:yA(d[R])})}).sort(function(R,V){return V.area-R.area}),g=S.filter(function(R){var V=R.width,_=R.height;return V>=n.clientWidth&&_>=n.clientHeight}),w=g.length>0?g[0].key:S[0].key,M=e.split("-")[1];return w+(M?"-"+M:"")}function I2(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=r?C2(t):F1(t,m2(n));return hc(n,o,r)}function w2(e){var t=e.ownerDocument.defaultView,n=t.getComputedStyle(e),r=parseFloat(n.marginTop||0)+parseFloat(n.marginBottom||0),o=parseFloat(n.marginLeft||0)+parseFloat(n.marginRight||0),s={width:e.offsetWidth+o,height:e.offsetHeight+r};return s}function W1(e){var t={left:"right",right:"left",bottom:"top",top:"bottom"};return e.replace(/left|right|bottom|top/g,function(n){return t[n]})}function A2(e,t,n){n=n.split("-")[0];var r=w2(e),o={width:r.width,height:r.height},s=["right","left"].indexOf(n)!==-1,i=s?"top":"left",d=s?"left":"top",S=s?"height":"width",g=s?"width":"height";return o[i]=t[i]+t[S]/2-r[S]/2,n===d?o[d]=t[d]-r[g]:o[d]=t[W1(d)],o}function Go(e,t){return Array.prototype.find?e.find(t):e.filter(t)[0]}function CA(e,t,n){if(Array.prototype.findIndex)return e.findIndex(function(o){return o[t]===n});var r=Go(e,function(o){return o[t]===n});return e.indexOf(r)}function S2(e,t,n){var r=n===void 0?e:e.slice(0,CA(e,"name",n));return r.forEach(function(o){o.function&&console.warn("`modifier.function` is deprecated, use `modifier.fn`!");var s=o.function||o.fn;o.enabled&&g2(s)&&(t.offsets.popper=Br(t.offsets.popper),t.offsets.reference=Br(t.offsets.reference),t=s(t,o))}),t}function bA(){if(!this.state.isDestroyed){var e={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:!1,offsets:{}};e.offsets.reference=I2(this.state,this.popper,this.reference,this.options.positionFixed),e.placement=b2(this.options.placement,e.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),e.originalPlacement=e.placement,e.positionFixed=this.options.positionFixed,e.offsets.popper=A2(this.popper,e.offsets.reference,e.placement),e.offsets.popper.position=this.options.positionFixed?"fixed":"absolute",e=S2(this.modifiers,e),this.state.isCreated?this.options.onUpdate(e):(this.state.isCreated=!0,this.options.onCreate(e))}}function x2(e,t){return e.some(function(n){var r=n.name,o=n.enabled;return o&&r===t})}function pc(e){for(var t=[!1,"ms","Webkit","Moz","O"],n=e.charAt(0).toUpperCase()+e.slice(1),r=0;ri[V]&&(e.offsets.popper[M]+=d[M]+_-i[V]),e.offsets.popper=Br(e.offsets.popper);var k=d[M]+d[g]/2-_/2,z=fi(e.instance.popper),I=parseFloat(z["margin"+w]),H=parseFloat(z["border"+w+"Width"]),A=k-e.offsets.popper[M]-I-H;return A=Math.max(Math.min(i[g]-_,A),0),e.arrowElement=r,e.offsets.arrow=(n={},Pi(n,M,Math.round(A)),Pi(n,R,""),n),e}function HA(e){return e==="end"?"start":e==="start"?"end":e}var k2=["auto-start","auto","auto-end","top-start","top","top-end","right-start","right","right-end","bottom-end","bottom","bottom-start","left-end","left","left-start"],ta=k2.slice(3);function Bu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=ta.indexOf(e),r=ta.slice(n+1).concat(ta.slice(0,n));return t?r.reverse():r}var na={FLIP:"flip",CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise"};function VA(e,t){if(x2(e.instance.modifiers,"inner")||e.flipped&&e.placement===e.originalPlacement)return e;var n=dc(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),r=e.placement.split("-")[0],o=W1(r),s=e.placement.split("-")[1]||"",i=[];switch(t.behavior){case na.FLIP:i=[r,o];break;case na.CLOCKWISE:i=Bu(r);break;case na.COUNTERCLOCKWISE:i=Bu(r,!0);break;default:i=t.behavior}return i.forEach(function(d,S){if(r!==d||i.length===S+1)return e;r=e.placement.split("-")[0],o=W1(r);var g=e.offsets.popper,w=e.offsets.reference,M=Math.floor,R=r==="left"&&M(g.right)>M(w.left)||r==="right"&&M(g.left)M(w.top)||r==="bottom"&&M(g.top)M(n.right),k=M(g.top)M(n.bottom),I=r==="left"&&V||r==="right"&&_||r==="top"&&k||r==="bottom"&&z,H=["top","bottom"].indexOf(r)!==-1,A=!!t.flipVariations&&(H&&s==="start"&&V||H&&s==="end"&&_||!H&&s==="start"&&k||!H&&s==="end"&&z),x=!!t.flipVariationsByContent&&(H&&s==="start"&&_||H&&s==="end"&&V||!H&&s==="start"&&z||!H&&s==="end"&&k),p=A||x;(R||I||p)&&(e.flipped=!0,(R||I)&&(r=i[S+1]),p&&(s=HA(s)),e.placement=r+(s?"-"+s:""),e.offsets.popper=Yn({},e.offsets.popper,A2(e.instance.popper,e.offsets.reference,e.placement)),e=S2(e.instance.modifiers,e,"flip"))}),e}function _A(e){var t=e.offsets,n=t.popper,r=t.reference,o=e.placement.split("-")[0],s=Math.floor,i=["top","bottom"].indexOf(o)!==-1,d=i?"right":"bottom",S=i?"left":"top",g=i?"width":"height";return n[d]s(r[d])&&(e.offsets.popper[S]=s(r[d])),e}function NA(e,t,n,r){var o=e.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),s=+o[1],i=o[2];if(!s)return e;if(i.indexOf("%")===0){var d=void 0;switch(i){case"%p":d=n;break;case"%":case"%r":default:d=r}var S=Br(d);return S[t]/100*s}else if(i==="vh"||i==="vw"){var g=void 0;return i==="vh"?g=Math.max(document.documentElement.clientHeight,window.innerHeight||0):g=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g/100*s}else return s}function OA(e,t,n,r){var o=[0,0],s=["right","left"].indexOf(r)!==-1,i=e.split(/(\+|\-)/).map(function(w){return w.trim()}),d=i.indexOf(Go(i,function(w){return w.search(/,|\s/)!==-1}));i[d]&&i[d].indexOf(",")===-1&&console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");var S=/\s*,\s*|\s+/,g=d!==-1?[i.slice(0,d).concat([i[d].split(S)[0]]),[i[d].split(S)[1]].concat(i.slice(d+1))]:[i];return g=g.map(function(w,M){var R=(M===1?!s:s)?"height":"width",V=!1;return w.reduce(function(_,k){return _[_.length-1]===""&&["+","-"].indexOf(k)!==-1?(_[_.length-1]=k,V=!0,_):V?(_[_.length-1]+=k,V=!1,_):_.concat(k)},[]).map(function(_){return NA(_,R,t,n)})}),g.forEach(function(w,M){w.forEach(function(R,V){fc(R)&&(o[M]+=R*(w[V-1]==="-"?-1:1))})}),o}function PA(e,t){var n=t.offset,r=e.placement,o=e.offsets,s=o.popper,i=o.reference,d=r.split("-")[0],S=void 0;return fc(+n)?S=[+n,0]:S=OA(n,s,i,d),d==="left"?(s.top+=S[0],s.left-=S[1]):d==="right"?(s.top+=S[0],s.left+=S[1]):d==="top"?(s.left+=S[0],s.top-=S[1]):d==="bottom"&&(s.left+=S[0],s.top+=S[1]),e.popper=s,e}function DA(e,t){var n=t.boundariesElement||Ni(e.instance.popper);e.instance.reference===n&&(n=Ni(n));var r=pc("transform"),o=e.instance.popper.style,s=o.top,i=o.left,d=o[r];o.top="",o.left="",o[r]="";var S=dc(e.instance.popper,e.instance.reference,t.padding,n,e.positionFixed);o.top=s,o.left=i,o[r]=d,t.boundaries=S;var g=t.priority,w=e.offsets.popper,M={primary:function(V){var _=w[V];return w[V]S[V]&&!t.escapeWithReference&&(k=Math.min(w[_],S[V]-(V==="right"?w.width:w.height))),Pi({},_,k)}};return g.forEach(function(R){var V=["left","top"].indexOf(R)!==-1?"primary":"secondary";w=Yn({},w,M[V](R))}),e.offsets.popper=w,e}function $A(e){var t=e.placement,n=t.split("-")[0],r=t.split("-")[1];if(r){var o=e.offsets,s=o.reference,i=o.popper,d=["bottom","top"].indexOf(n)!==-1,S=d?"left":"top",g=d?"width":"height",w={start:Pi({},S,s[S]),end:Pi({},S,s[S]+s[g]-i[g])};e.offsets.popper=Yn({},i,w[r])}return e}function BA(e){if(!z2(e.instance.modifiers,"hide","preventOverflow"))return e;var t=e.offsets.reference,n=Go(e.instance.modifiers,function(r){return r.name==="preventOverflow"}).boundaries;if(t.bottomn.right||t.top>n.bottom||t.right2&&arguments[2]!==void 0?arguments[2]:{};gA(this,e),this.scheduleUpdate=function(){return requestAnimationFrame(r.update)},this.update=dA(this.update.bind(this)),this.options=Yn({},e.Defaults,o),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=t&&t.jquery?t[0]:t,this.popper=n&&n.jquery?n[0]:n,this.options.modifiers={},Object.keys(Yn({},e.Defaults.modifiers,o.modifiers)).forEach(function(i){r.options.modifiers[i]=Yn({},e.Defaults.modifiers[i]||{},o.modifiers?o.modifiers[i]:{})}),this.modifiers=Object.keys(this.options.modifiers).map(function(i){return Yn({name:i},r.options.modifiers[i])}).sort(function(i,d){return i.order-d.order}),this.modifiers.forEach(function(i){i.enabled&&g2(i.onLoad)&&i.onLoad(r.reference,r.popper,r.options,i,r.state)}),this.update();var s=this.options.eventsEnabled;s&&this.enableEventListeners(),this.state.eventsEnabled=s}return mA(e,[{key:"update",value:function(){return bA.call(this)}},{key:"destroy",value:function(){return IA.call(this)}},{key:"enableEventListeners",value:function(){return AA.call(this)}},{key:"disableEventListeners",value:function(){return xA.call(this)}}]),e}();Cs.Utils=(typeof window<"u"?window:global).PopperUtils;Cs.placements=k2;Cs.Defaults=GA;const L2=Cs;var Fa={exports:{}},Wa={exports:{}},Fu="__global_unique_id__",jA=function(){return po[Fu]=(po[Fu]||0)+1};(function(e,t){t.__esModule=!0;var n=de;S(n);var r=Mo,o=S(r),s=jA,i=S(s),d=lp;S(d);function S(I){return I&&I.__esModule?I:{default:I}}function g(I,H){if(!(I instanceof H))throw new TypeError("Cannot call a class as a function")}function w(I,H){if(!I)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return H&&(typeof H=="object"||typeof H=="function")?H:I}function M(I,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof H);I.prototype=Object.create(H&&H.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),H&&(Object.setPrototypeOf?Object.setPrototypeOf(I,H):I.__proto__=H)}var R=1073741823;function V(I,H){return I===H?I!==0||1/I===1/H:I!==I&&H!==H}function _(I){var H=[];return{on:function(x){H.push(x)},off:function(x){H=H.filter(function(p){return p!==x})},get:function(){return I},set:function(x,p){I=x,H.forEach(function(v){return v(I,p)})}}}function k(I){return Array.isArray(I)?I[0]:I}function z(I,H){var A,x,p="__create-react-context-"+(0,i.default)()+"__",v=function(a){M(h,a);function h(){var u,b,m;g(this,h);for(var l=arguments.length,c=Array(l),f=0;f1?n-1:0),o=1;o=0)&&(n[o]=e[o]);return n}function lS(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var io="unmounted";Sn.UNMOUNTED=io;var qr="exited";Sn.EXITED=qr;var ei="entering";Sn.ENTERING=ei;var wi="entered";Sn.ENTERED=wi;var Za="exiting";Sn.EXITING=Za;var yr=function(e){lS(t,e);function t(r,o){var s;s=e.call(this,r,o)||this;var i=o.transitionGroup,d=i&&!i.isMounting?r.enter:r.appear,S;return s.appearStatus=null,r.in?d?(S=qr,s.appearStatus=ei):S=wi:r.unmountOnExit||r.mountOnEnter?S=io:S=qr,s.state={status:S},s.nextCallback=null,s}var n=t.prototype;return n.getChildContext=function(){return{transitionGroup:null}},t.getDerivedStateFromProps=function(o,s){var i=o.in;return i&&s.status===io?{status:qr}:null},n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var s=null;if(o!==this.props){var i=this.state.status;this.props.in?i!==ei&&i!==wi&&(s=ei):(i===ei||i===wi)&&(s=Za)}this.updateStatus(!1,s)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,s,i,d;return s=i=d=o,o!=null&&typeof o!="number"&&(s=o.exit,i=o.enter,d=o.appear!==void 0?o.appear:i),{exit:s,enter:i,appear:d}},n.updateStatus=function(o,s){if(o===void 0&&(o=!1),s!==null){this.cancelNextCallback();var i=iS.default.findDOMNode(this);s===ei?this.performEnter(i,o):this.performExit(i)}else this.props.unmountOnExit&&this.state.status===qr&&this.setState({status:io})},n.performEnter=function(o,s){var i=this,d=this.props.enter,S=this.context.transitionGroup?this.context.transitionGroup.isMounting:s,g=this.getTimeouts(),w=S?g.appear:g.enter;if(!s&&!d){this.safeSetState({status:wi},function(){i.props.onEntered(o)});return}this.props.onEnter(o,S),this.safeSetState({status:ei},function(){i.props.onEntering(o,S),i.onTransitionEnd(o,w,function(){i.safeSetState({status:wi},function(){i.props.onEntered(o,S)})})})},n.performExit=function(o){var s=this,i=this.props.exit,d=this.getTimeouts();if(!i){this.safeSetState({status:qr},function(){s.props.onExited(o)});return}this.props.onExit(o),this.safeSetState({status:Za},function(){s.props.onExiting(o),s.onTransitionEnd(o,d.exit,function(){s.safeSetState({status:qr},function(){s.props.onExited(o)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,s){s=this.setNextCallback(s),this.setState(o,s)},n.setNextCallback=function(o){var s=this,i=!0;return this.nextCallback=function(d){i&&(i=!1,s.nextCallback=null,o(d))},this.nextCallback.cancel=function(){i=!1},this.nextCallback},n.onTransitionEnd=function(o,s,i){this.setNextCallback(i);var d=s==null&&!this.props.addEndListener;if(!o||d){setTimeout(this.nextCallback,0);return}this.props.addEndListener&&this.props.addEndListener(o,this.nextCallback),s!=null&&setTimeout(this.nextCallback,s)},n.render=function(){var o=this.state.status;if(o===io)return null;var s=this.props,i=s.children,d=aS(s,["children"]);if(delete d.in,delete d.mountOnEnter,delete d.unmountOnExit,delete d.appear,delete d.enter,delete d.exit,delete d.timeout,delete d.addEndListener,delete d.onEnter,delete d.onEntering,delete d.onEntered,delete d.onExit,delete d.onExiting,delete d.onExited,typeof i=="function")return i(o,d);var S=ra.default.Children.only(i);return ra.default.cloneElement(S,d)},t}(ra.default.Component);yr.contextTypes={transitionGroup:rS.object};yr.childContextTypes={transitionGroup:function(){}};yr.propTypes={};function Ii(){}yr.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ii,onEntering:Ii,onEntered:Ii,onExit:Ii,onExiting:Ii,onExited:Ii};yr.UNMOUNTED=0;yr.EXITED=1;yr.ENTERING=2;yr.ENTERED=3;yr.EXITING=4;var cS=(0,oS.polyfill)(yr);Sn.default=cS;(function(e,t){t.__esModule=!0,t.default=void 0,d(Mo);var n=i(tS),r=i(nS),o=i(de),s=i(Sn);function i(_){return _&&_.__esModule?_:{default:_}}function d(_){if(_&&_.__esModule)return _;var k={};if(_!=null){for(var z in _)if(Object.prototype.hasOwnProperty.call(_,z)){var I=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(_,z):{};I.get||I.set?Object.defineProperty(k,z,I):k[z]=_[z]}}return k.default=_,k}function S(){return S=Object.assign||function(_){for(var k=1;k=0)&&(I[A]=k[A]);return I}function S(){return S=Object.assign||function(k){for(var z=1;z=0)&&(R[_]=w[_]);return R}function d(w,M){w.prototype=Object.create(M.prototype),w.prototype.constructor=w,w.__proto__=M}var S=function(w){d(M,w);function M(){for(var V,_=arguments.length,k=new Array(_),z=0;z<_;z++)k[z]=arguments[z];return V=w.call.apply(w,[this].concat(k))||this,V.handleEnter=function(){for(var I=arguments.length,H=new Array(I),A=0;A"u"||!this.state.hasMounted||this.portalElement===null?null:Mr.createPortal(this.props.children,this.portalElement)},t.prototype.componentDidMount=function(){this.props.container&&(this.portalElement=this.createContainerElement(),this.props.container.appendChild(this.portalElement),this.setState({hasMounted:!0},this.props.onChildrenMount),s1&&this.unstableRenderNoPortal())},t.prototype.componentDidUpdate=function(n){this.portalElement!=null&&n.className!==this.props.className&&(bS(this.portalElement.classList,n.className),ia(this.portalElement.classList,this.props.className)),s1&&this.unstableRenderNoPortal()},t.prototype.componentWillUnmount=function(){this.portalElement!=null&&(s1&&Mr.unmountComponentAtNode(this.portalElement),this.portalElement.remove())},t.prototype.createContainerElement=function(){var n=document.createElement("div");return n.classList.add(uI),ia(n.classList,this.props.className),this.context!=null&&ia(n.classList,this.context.blueprintPortalClassName),n},t.prototype.unstableRenderNoPortal=function(){this.portalElement!==null&&Mr.unstable_renderSubtreeIntoContainer(this,de.createElement("div",null,this.props.children),this.portalElement)},t.displayName="".concat(En,".Portal"),t.contextTypes=yS,t.defaultProps={container:typeof document<"u"?document.body:void 0},t}(de.Component);function bS(e,t){t!=null&&t!==""&&e.remove.apply(e,t.split(" "))}function ia(e,t){t!=null&&t!==""&&e.add.apply(e,t.split(" "))}var B2=function(e){wn(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.isAutoFocusing=!1,r.state={hasEverOpened:r.props.isOpen},r.containerElement=null,r.startFocusTrapElement=null,r.endFocusTrapElement=null,r.refHandlers={container:function(o){return r.containerElement=Mr.findDOMNode(o)},endFocusTrap:function(o){return r.endFocusTrapElement=o},startFocusTrap:function(o){return r.startFocusTrapElement=o}},r.maybeRenderChild=function(o){if(hi(o)&&(o=o()),o==null)return null;var s=typeof o=="object"?de.cloneElement(o,{className:vt(o.props.className,ru)}):de.createElement("span",{className:ru},o),i=r.props,d=i.onOpening,S=i.onOpened,g=i.onClosing,w=i.transitionDuration,M=i.transitionName,R=o1.CSSTransition;return de.createElement(R,{classNames:M,onEntering:d,onEntered:S,onExiting:g,onExited:r.handleTransitionExited,timeout:w,addEndListener:r.handleTransitionAddEnd},s)},r.handleStartFocusTrapElementFocus=function(o){var s;!r.props.enforceFocus||r.isAutoFocusing||o.relatedTarget!=null&&r.containerElement.contains(o.relatedTarget)&&o.relatedTarget!==r.endFocusTrapElement&&((s=r.endFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0}))},r.handleStartFocusTrapElementKeyDown=function(o){var s;if(r.props.enforceFocus&&o.shiftKey&&o.which===DI){var i=r.getKeyboardFocusableElements().pop();i!=null?i.focus():(s=r.endFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0})}},r.handleEndFocusTrapElementFocus=function(o){var s,i;if(o.relatedTarget!=null&&r.containerElement.contains(o.relatedTarget)&&o.relatedTarget!==r.startFocusTrapElement){var d=r.getKeyboardFocusableElements().shift();!r.isAutoFocusing&&d!=null&&d!==o.relatedTarget?d.focus():(s=r.startFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0})}else{var S=r.getKeyboardFocusableElements().pop();S!=null?S.focus():(i=r.startFocusTrapElement)===null||i===void 0||i.focus({preventScroll:!0})}},r.handleTransitionExited=function(o){var s,i;r.props.shouldReturnFocusOnClose&&r.lastActiveElementBeforeOpened instanceof HTMLElement&&r.lastActiveElementBeforeOpened.focus(),(i=(s=r.props).onClosed)===null||i===void 0||i.call(s,o)},r.handleBackdropMouseDown=function(o){var s,i=r.props,d=i.backdropProps,S=i.canOutsideClickClose,g=i.enforceFocus,w=i.onClose;S&&(w==null||w(o)),g&&r.bringFocusInsideOverlay(),(s=d==null?void 0:d.onMouseDown)===null||s===void 0||s.call(d,o)},r.handleDocumentClick=function(o){var s=r.props,i=s.canOutsideClickClose,d=s.isOpen,S=s.onClose,g=o.composed?o.composedPath()[0]:o.target,w=n.openStack.indexOf(r),M=n.openStack.slice(w).some(function(R){var V=R.containerElement;return V&&V.contains(g)&&!V.isSameNode(g)});d&&!M&&i&&(S==null||S(o))},r.handleDocumentFocus=function(o){var s=o.composed?o.composedPath()[0]:o.target;r.props.enforceFocus&&r.containerElement!=null&&s instanceof Node&&!r.containerElement.contains(s)&&(o.preventDefault(),o.stopImmediatePropagation(),r.bringFocusInsideOverlay())},r.handleKeyDown=function(o){var s=r.props,i=s.canEscapeKeyClose,d=s.onClose;o.which===$I&&i&&(d==null||d(o),o.preventDefault())},r.handleTransitionAddEnd=function(){},r}n=t,t.getDerivedStateFromProps=function(r){var o=r.isOpen;return o?{hasEverOpened:o}:null},t.prototype.render=function(){var r,o;if(this.props.lazy&&!this.state.hasEverOpened)return null;var s=this.props,i=s.autoFocus,d=s.children,S=s.className,g=s.enforceFocus,w=s.usePortal,M=s.isOpen,R=M?(o=de.Children.map(d,this.maybeRenderChild))!==null&&o!==void 0?o:[]:[],V=this.maybeRenderBackdrop();V!==null&&R.unshift(V),M&&(i||g)&&R.length>0&&(R.unshift(this.renderDummyElement("__start",{className:iu,onFocus:this.handleStartFocusTrapElementFocus,onKeyDown:this.handleStartFocusTrapElementKeyDown,ref:this.refHandlers.startFocusTrap})),g&&R.push(this.renderDummyElement("__end",{className:ou,onFocus:this.handleEndFocusTrapElementFocus,ref:this.refHandlers.endFocusTrap})));var _=vt($r,(r={},r[Ys]=M,r[tI]=!w,r),S),k=de.createElement(o1.TransitionGroup,{appear:!0,"aria-live":"polite",className:_,component:"div",onKeyDown:this.handleKeyDown,ref:this.refHandlers.container},R);return w?de.createElement(CS,{className:this.props.portalClassName,container:this.props.portalContainer},k):k},t.prototype.componentDidMount=function(){this.props.isOpen&&this.overlayWillOpen()},t.prototype.componentDidUpdate=function(r){r.isOpen&&!this.props.isOpen?this.overlayWillClose():!r.isOpen&&this.props.isOpen&&this.overlayWillOpen()},t.prototype.componentWillUnmount=function(){this.overlayWillClose()},t.prototype.bringFocusInsideOverlay=function(){var r=this;return this.requestAnimationFrame(function(){var o;if(!(r.containerElement==null||document.activeElement==null||!r.props.isOpen)){var s=!r.containerElement.contains(document.activeElement);s&&((o=r.startFocusTrapElement)===null||o===void 0||o.focus({preventScroll:!0}),r.isAutoFocusing=!1)}})},t.prototype.maybeRenderBackdrop=function(){var r=this.props,o=r.backdropClassName,s=r.backdropProps,i=r.hasBackdrop,d=r.isOpen,S=r.transitionDuration,g=r.transitionName;return i&&d?de.createElement(o1.CSSTransition,{classNames:g,key:"__backdrop",timeout:S,addEndListener:this.handleTransitionAddEnd},de.createElement("div",Nt({},s,{className:vt(eI,o,s==null?void 0:s.className),onMouseDown:this.handleBackdropMouseDown}))):null},t.prototype.renderDummyElement=function(r,o){var s=this.props,i=s.transitionDuration,d=s.transitionName;return de.createElement(o1.CSSTransition,{classNames:d,key:r,addEndListener:this.handleTransitionAddEnd,timeout:i,unmountOnExit:!0},de.createElement("div",Nt({tabIndex:0},o)))},t.prototype.getKeyboardFocusableElements=function(){var r=this.containerElement!==null?Array.from(this.containerElement.querySelectorAll(['a[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','details:not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])'].join(","))):[];return r.filter(function(o){return!o.classList.contains(iu)&&!o.classList.contains(ou)})},t.prototype.overlayWillClose=function(){document.removeEventListener("focus",this.handleDocumentFocus,!0),document.removeEventListener("mousedown",this.handleDocumentClick);var r=n.openStack,o=r.indexOf(this);if(o!==-1){if(r.splice(o,1),r.length>0){var s=n.getLastOpened();s.props.autoFocus&&s.props.enforceFocus&&(s.bringFocusInsideOverlay(),document.addEventListener("focus",s.handleDocumentFocus,!0))}r.filter(function(i){return i.props.usePortal&&i.props.hasBackdrop}).length===0&&document.body.classList.remove(Ys)}},t.prototype.overlayWillOpen=function(){var r=n.getLastOpened,o=n.openStack;o.length>0&&document.removeEventListener("focus",r().handleDocumentFocus,!0),o.push(this),this.props.autoFocus&&(this.isAutoFocusing=!0,this.bringFocusInsideOverlay()),this.props.enforceFocus&&document.addEventListener("focus",this.handleDocumentFocus,!0),this.props.canOutsideClickClose&&!this.props.hasBackdrop&&document.addEventListener("mousedown",this.handleDocumentClick),this.props.hasBackdrop&&this.props.usePortal&&document.body.classList.add(Ys),this.lastActiveElementBeforeOpened=document.activeElement};var n;return t.displayName="".concat(En,".Overlay"),t.defaultProps={autoFocus:!0,backdropProps:{},canEscapeKeyClose:!0,canOutsideClickClose:!0,enforceFocus:!0,hasBackdrop:!0,isOpen:!1,lazy:!0,shouldReturnFocusOnClose:!0,transitionDuration:300,transitionName:$r,usePortal:!0},t.openStack=[],t.getLastOpened=function(){return n.openStack[n.openStack.length-1]},t=n=mr([sr],t),t}(vr),oi=[],IS=function(){return oi.some(function(e){return e.activeTargets.length>0})},wS=function(){return oi.some(function(e){return e.skippedTargets.length>0})},ju="ResizeObserver loop completed with undelivered notifications.",AS=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:ju}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=ju),window.dispatchEvent(e)},xo;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(xo||(xo={}));var si=function(e){return Object.freeze(e)},SS=function(){function e(t,n){this.inlineSize=t,this.blockSize=n,si(this)}return e}(),F2=function(){function e(t,n,r,o){return this.x=t,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,si(this)}return e.prototype.toJSON=function(){var t=this,n=t.x,r=t.y,o=t.top,s=t.right,i=t.bottom,d=t.left,S=t.width,g=t.height;return{x:n,y:r,top:o,right:s,bottom:i,left:d,width:S,height:g}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),mc=function(e){return e instanceof SVGElement&&"getBBox"in e},W2=function(e){if(mc(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,s=o.offsetWidth,i=o.offsetHeight;return!(s||i||e.getClientRects().length)},Zu=function(e){var t;if(e instanceof Element)return!0;var n=(t=e==null?void 0:e.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},xS=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},ho=typeof window<"u"?window:{},a1=new WeakMap,Ku=/auto|scroll/,MS=/^tb|vertical/,ES=/msie|trident/i.test(ho.navigator&&ho.navigator.userAgent),lr=function(e){return parseFloat(e||"0")},Li=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new SS((n?t:e)||0,(n?e:t)||0)},Uu=si({devicePixelContentBoxSize:Li(),borderBoxSize:Li(),contentBoxSize:Li(),contentRect:new F2(0,0,0,0)}),G2=function(e,t){if(t===void 0&&(t=!1),a1.has(e)&&!t)return a1.get(e);if(W2(e))return a1.set(e,Uu),Uu;var n=getComputedStyle(e),r=mc(e)&&e.ownerSVGElement&&e.getBBox(),o=!ES&&n.boxSizing==="border-box",s=MS.test(n.writingMode||""),i=!r&&Ku.test(n.overflowY||""),d=!r&&Ku.test(n.overflowX||""),S=r?0:lr(n.paddingTop),g=r?0:lr(n.paddingRight),w=r?0:lr(n.paddingBottom),M=r?0:lr(n.paddingLeft),R=r?0:lr(n.borderTopWidth),V=r?0:lr(n.borderRightWidth),_=r?0:lr(n.borderBottomWidth),k=r?0:lr(n.borderLeftWidth),z=M+g,I=S+w,H=k+V,A=R+_,x=d?e.offsetHeight-A-e.clientHeight:0,p=i?e.offsetWidth-H-e.clientWidth:0,v=o?z+H:0,y=o?I+A:0,a=r?r.width:lr(n.width)-v-p,h=r?r.height:lr(n.height)-y-x,u=a+z+p+H,b=h+I+x+A,m=si({devicePixelContentBoxSize:Li(Math.round(a*devicePixelRatio),Math.round(h*devicePixelRatio),s),borderBoxSize:Li(u,b,s),contentBoxSize:Li(a,h,s),contentRect:new F2(M,S,a,h)});return a1.set(e,m),m},j2=function(e,t,n){var r=G2(e,n),o=r.borderBoxSize,s=r.contentBoxSize,i=r.devicePixelContentBoxSize;switch(t){case xo.DEVICE_PIXEL_CONTENT_BOX:return i;case xo.BORDER_BOX:return o;default:return s}},zS=function(){function e(t){var n=G2(t);this.target=t,this.contentRect=n.contentRect,this.borderBoxSize=si([n.borderBoxSize]),this.contentBoxSize=si([n.contentBoxSize]),this.devicePixelContentBoxSize=si([n.devicePixelContentBoxSize])}return e}(),Z2=function(e){if(W2(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},kS=function(){var e=1/0,t=[];oi.forEach(function(i){if(i.activeTargets.length!==0){var d=[];i.activeTargets.forEach(function(g){var w=new zS(g.target),M=Z2(g.target);d.push(w),g.lastReportedSize=j2(g.target,g.observedBox),Me?n.activeTargets.push(o):n.skippedTargets.push(o))})})},LS=function(){var e=0;for(Xu(e);IS();)e=kS(),Xu(e);return wS()&&AS(),e>0},oa,K2=[],TS=function(){return K2.splice(0).forEach(function(e){return e()})},RS=function(e){if(!oa){var t=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return TS()}).observe(n,r),oa=function(){n.textContent="".concat(t?t--:t++)}}K2.push(e),oa()},HS=function(e){RS(function(){requestAnimationFrame(e)})},w1=0,VS=function(){return!!w1},_S=250,NS={attributes:!0,characterData:!0,childList:!0,subtree:!0},Yu=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Ju=function(e){return e===void 0&&(e=0),Date.now()+e},sa=!1,OS=function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var n=this;if(t===void 0&&(t=_S),!sa){sa=!0;var r=Ju(t);HS(function(){var o=!1;try{o=LS()}finally{if(sa=!1,t=r-Ju(),!VS())return;o?n.run(1e3):t>0?n.run(t):n.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,n=function(){return t.observer&&t.observer.observe(document.body,NS)};document.body?n():ho.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Yu.forEach(function(n){return ho.addEventListener(n,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),Yu.forEach(function(n){return ho.removeEventListener(n,t.listener,!0)}),this.stopped=!0)},e}(),Xa=new OS,Qu=function(e){!w1&&e>0&&Xa.start(),w1+=e,!w1&&Xa.stop()},PS=function(e){return!mc(e)&&!xS(e)&&getComputedStyle(e).display==="inline"},DS=function(){function e(t,n){this.target=t,this.observedBox=n||xo.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=j2(this.target,this.observedBox,!0);return PS(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),$S=function(){function e(t,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=n}return e}(),l1=new WeakMap,qu=function(e,t){for(var n=0;n=0&&(s&&oi.splice(oi.indexOf(r),1),r.observationTargets.splice(o,1),Qu(-1))},e.disconnect=function(t){var n=this,r=l1.get(t);r.observationTargets.slice().forEach(function(o){return n.unobserve(t,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},e}(),BS=function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");c1.connect(this,t)}return e.prototype.observe=function(t,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Zu(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");c1.observe(this,t,n)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Zu(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");c1.unobserve(this,t)},e.prototype.disconnect=function(){c1.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}(),eh=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.element=null,n.observer=new BS(function(r){var o,s;return(s=(o=n.props).onResize)===null||s===void 0?void 0:s.call(o,r)}),n}return t.prototype.render=function(){return de.Children.only(this.props.children)},t.prototype.componentDidMount=function(){this.observeElement()},t.prototype.componentDidUpdate=function(n){this.observeElement(this.props.observeParents!==n.observeParents)},t.prototype.componentWillUnmount=function(){this.observer.disconnect()},t.prototype.observeElement=function(n){n===void 0&&(n=!1);var r=this.getElement();if(!(r instanceof Element)){this.observer.disconnect();return}if(!(r===this.element&&!n)&&(this.observer.disconnect(),this.element=r,this.observer.observe(r),this.props.observeParents))for(var o=r.parentElement;o!=null;)this.observer.observe(o),o=o.parentElement},t.prototype.getElement=function(){try{return Mr.findDOMNode(this)}catch{return null}},t.displayName="".concat(En,".ResizeSensor"),t=mr([sr],t),t}(vr),FS=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.popover=null,n}return t.prototype.render=function(){var n,r=this,o=this.props,s=o.children,i=o.intent,d=o.popoverClassName,S=kr(o,["children","intent","popoverClassName"]),g=vt(hI,(n={},n[Z5]=this.props.minimal,n),Gr(i),d);return de.createElement(X2,Nt({interactionKind:ur.HOVER_TARGET_ONLY,modifiers:{arrow:{enabled:!this.props.minimal}}},S,{autoFocus:!1,canEscapeKeyClose:!1,enforceFocus:!1,lazy:!0,popoverClassName:g,portalContainer:this.props.portalContainer,ref:function(w){return r.popover=w}}),s)},t.prototype.reposition=function(){this.popover!=null&&this.popover.reposition()},t.displayName="".concat(En,".Tooltip"),t.defaultProps={hoverCloseDelay:0,hoverOpenDelay:100,minimal:!1,transitionDuration:100},t=mr([sr],t),t}(vr);function vc(e){return e.split("-")[0]}function Ya(e){return["left","right"].indexOf(e)!==-1}function u1(e){switch(e){case"top":return"bottom";case"left":return"right";case"bottom":return"top";default:return"left"}}function th(e){var t=e.split("-")[1];switch(t){case"start":return"left";case"end":return"right";default:return"center"}}function WS(e){var t=vc(e.placement);if(e.arrowElement==null)return Ya(t)?"".concat(u1(t)," ").concat(th(t)):"".concat(th(t)," ").concat(u1(t));var n=e.arrowElement.clientHeight/2,r=e.offsets.arrow;return Ya(t)?"".concat(u1(t)," ").concat(r.top+n,"px"):"".concat(r.left+n,"px ").concat(u1(t))}var nh=4,GS=function(e){if(e.arrowElement==null)return e;var t=e.arrowElement.clientWidth,n=vc(e.placement),r=Ya(n),o=r?"width":"height",s=r?"left":"top",i=Math.round(t/2/Math.sqrt(2));return n==="top"||n==="left"?(e.offsets.popper[s]-=i+nh,e.offsets.arrow[s]=e.offsets.popper[o]-t+i):(e.offsets.popper[s]+=i+nh,e.offsets.arrow[s]=-i),e},jS="M8.11 6.302c1.015-.936 1.887-2.922 1.887-4.297v26c0-1.378-.868-3.357-1.888-4.297L.925 17.09c-1.237-1.14-1.233-3.034 0-4.17L8.11 6.302z",ZS="M8.787 7.036c1.22-1.125 2.21-3.376 2.21-5.03V0v30-2.005c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z";function KS(e){if(e==null)return 0;switch(vc(e)){case"top":return-90;case"left":return 180;case"bottom":return 90;default:return 0}}var U2=function(e){var t=e.arrowProps,n=t.ref,r=t.style,o=e.placement;return de.createElement("div",{className:Js,ref:n,style:r.left==null||isNaN(+r.left)?{}:r},de.createElement("svg",{viewBox:"0 0 30 30",style:{transform:"rotate(".concat(KS(o),"deg)")}},de.createElement("path",{className:Js+"-border",d:jS}),de.createElement("path",{className:Js+"-fill",d:ZS})))};U2.displayName="".concat(En,".PopoverArrow");function US(e){switch(e){case Pn.TOP_LEFT:return"top-start";case Pn.TOP:return"top";case Pn.TOP_RIGHT:return"top-end";case Pn.RIGHT_TOP:return"right-start";case Pn.RIGHT:return"right";case Pn.RIGHT_BOTTOM:return"right-end";case Pn.BOTTOM_RIGHT:return"bottom-end";case Pn.BOTTOM:return"bottom";case Pn.BOTTOM_LEFT:return"bottom-start";case Pn.LEFT_BOTTOM:return"left-end";case Pn.LEFT:return"left";case Pn.LEFT_TOP:return"left-start";case"auto":case"auto-start":case"auto-end":return e;default:return XS(e)}}function XS(e){throw new Error("Unexpected position: "+e)}var ur={CLICK:"click",CLICK_TARGET_ONLY:"click-target",HOVER:"hover",HOVER_TARGET_ONLY:"hover-target"},X2=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.popoverRef=VI(),n.popoverElement=null,n.targetElement=null,n.state={hasDarkParent:!1,isOpen:n.getIsOpen(n.props),transformOrigin:""},n.isMouseInTargetOrPopover=!1,n.lostFocusOnSamePage=!0,n.handlePopoverRef=lu(n,"popoverElement",n.props.popoverRef),n.handleTargetRef=function(r){return n.targetElement=r},n.reposition=function(){var r;return(r=n.popperScheduleUpdate)===null||r===void 0?void 0:r.call(n)},n.renderPopover=function(r){var o,s=n.props,i=s.interactionKind,d=s.usePortal,S=n.state.transformOrigin;n.popperScheduleUpdate=r.scheduleUpdate;var g={onClick:n.handlePopoverClick};(i===ur.HOVER||!d&&i===ur.HOVER_TARGET_ONLY)&&(g.onMouseEnter=n.handleMouseEnter,g.onMouseLeave=n.handleMouseLeave);var w=vt(Qn,(o={},o[tu]=n.props.inheritDarkTheme&&n.state.hasDarkParent,o[Z5]=n.props.minimal,o[su]=n.props.captureDismiss,o[sI]=r.outOfBoundaries===!0,o),n.props.popoverClassName);return de.createElement("div",{className:cI,ref:r.ref,style:r.style},de.createElement(eh,{onResize:n.reposition},de.createElement("div",Nt({className:w,style:{transformOrigin:S},ref:n.popoverRef},g),n.isArrowEnabled()&&de.createElement(U2,{arrowProps:r.arrowProps,placement:r.placement}),de.createElement("div",{className:rI},n.understandChildren().content))))},n.renderTarget=function(r){var o,s,i=n.props,d=i.fill,S=i.openOnTargetFocus,g=i.targetClassName,w=i.targetProps,M=w===void 0?{}:w,R=n.state.isOpen,V=n.isControlled(),_=n.isHoverInteractionKind(),k=n.props.targetTagName;d&&(k="div");var z=_?{onBlur:n.handleTargetBlur,onFocus:n.handleTargetFocus,onMouseEnter:n.handleMouseEnter,onMouseLeave:n.handleMouseLeave}:{onClick:n.handleTargetClick};z["aria-haspopup"]="true",z.className=vt(aI,(o={},o[oI]=R,o),M.className,g),z.ref=r.ref;var I=au(n.understandChildren().target);if(I===void 0)return null;var H=I.props.tabIndex,A=H==null&&S&&_?0:H,x=de.cloneElement(I,{className:vt(I.props.className,(s={},s[G5]=R&&!V&&!_,s)),disabled:R&&HI(I,FS)?!0:I.props.disabled,tabIndex:A}),p=de.createElement(k,Nt(Nt({},M),z),x);return de.createElement(eh,{onResize:n.reposition},p)},n.isControlled=function(){return n.props.isOpen!==void 0},n.handleTargetFocus=function(r){var o,s;if(n.props.openOnTargetFocus&&n.isHoverInteractionKind()){if(r.relatedTarget==null&&!n.lostFocusOnSamePage)return;n.handleMouseEnter(r)}(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onFocus)===null||s===void 0||s.call(o,r)},n.handleTargetBlur=function(r){var o,s;n.props.openOnTargetFocus&&n.isHoverInteractionKind()&&r.relatedTarget!=null&&!n.isElementInPopover(r.relatedTarget)&&n.handleMouseLeave(r),n.lostFocusOnSamePage=r.relatedTarget!=null,(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onBlur)===null||s===void 0||s.call(o,r)},n.handleMouseEnter=function(r){var o,s;n.isMouseInTargetOrPopover=!0,!n.props.usePortal&&n.isElementInPopover(r.target)&&n.props.interactionKind===ur.HOVER_TARGET_ONLY&&!n.props.openOnTargetFocus?n.handleMouseLeave(r):n.props.disabled||n.setOpenState(!0,r,n.props.hoverOpenDelay),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onMouseEnter)===null||s===void 0||s.call(o,r)},n.handleMouseLeave=function(r){var o,s;n.isMouseInTargetOrPopover=!1,n.setTimeout(function(){n.isMouseInTargetOrPopover||n.setOpenState(!1,r,n.props.hoverCloseDelay)}),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onMouseLeave)===null||s===void 0||s.call(o,r)},n.handlePopoverClick=function(r){var o=r.target,s=o.closest(".".concat(Qn)),i=s===n.popoverRef.current,d=s==null?void 0:s.classList.contains(su),S=o.closest(".".concat(B1,", .").concat(iI)),g=S!=null&&S.classList.contains(B1),w=o.closest(":disabled, .".concat(oc))!=null;g&&!w&&(!d||i)&&n.setOpenState(!1,r)},n.handleOverlayClose=function(r){if(!(n.targetElement===null||r===void 0)){var o=r.target;(!bI(n.targetElement,o)||r.nativeEvent instanceof KeyboardEvent)&&n.setOpenState(!1,r)}},n.handleTargetClick=function(r){var o,s;!n.props.disabled&&!n.isElementInPopover(r.target)&&(n.props.isOpen==null?n.setState(function(i){return{isOpen:!i.isOpen}}):n.setOpenState(!n.props.isOpen,r)),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onClick)===null||s===void 0||s.call(o,r)},n.updatePopoverState=function(r){return n.setState({transformOrigin:WS(r)}),r},n}return t.prototype.render=function(){var n,r,o=this.props,s=o.className,i=o.disabled,d=o.fill,S=o.placement,g=o.position,w=g===void 0?"auto":g,M=o.shouldReturnFocusOnClose,R=this.state.isOpen,V=this.props.wrapperTagName;d&&(V="div");var _=au(this.understandChildren().content)==null;_&&!i&&R!==!1&&!Ao("production")&&console.warn(EI);var k=vt(lI,s,(n={},n[sc]=d,n)),z=this.isHoverInteractionKind()?!1:void 0,I=de.createElement(V,{className:k},de.createElement(qA,{innerRef:this.handleTargetRef},this.renderTarget),de.createElement(B2,{autoFocus:(r=this.props.autoFocus)!==null&&r!==void 0?r:z,backdropClassName:nI,backdropProps:this.props.backdropProps,canEscapeKeyClose:this.props.canEscapeKeyClose,canOutsideClickClose:this.props.interactionKind===ur.CLICK,className:this.props.portalClassName,enforceFocus:this.props.enforceFocus,hasBackdrop:this.props.hasBackdrop,isOpen:R&&!_,onClose:this.handleOverlayClose,onClosed:this.props.onClosed,onClosing:this.props.onClosing,onOpened:this.props.onOpened,onOpening:this.props.onOpening,transitionDuration:this.props.transitionDuration,transitionName:Qn,usePortal:this.props.usePortal,portalContainer:this.props.portalContainer,shouldReturnFocusOnClose:this.isHoverInteractionKind()?!1:M},de.createElement(JA,{innerRef:this.handlePopoverRef,placement:S??US(w),modifiers:this.getPopperModifiers()},this.renderPopover)));return de.createElement(UA,null,I)},t.prototype.componentDidMount=function(){this.updateDarkParent()},t.prototype.componentDidUpdate=function(n,r){e.prototype.componentDidUpdate.call(this,n,r),n.popoverRef!==this.props.popoverRef&&(_a(n.popoverRef,null),this.handlePopoverRef=lu(this,"popoverElement",this.props.popoverRef),_a(this.props.popoverRef,this.popoverElement)),this.updateDarkParent();var o=this.getIsOpen(this.props);this.props.isOpen!=null&&o!==this.state.isOpen?(this.setOpenState(o),this.setState({isOpen:o})):this.props.disabled&&this.state.isOpen&&this.props.isOpen==null&&this.setOpenState(!1)},t.prototype.validateProps=function(n){n.isOpen==null&&n.onInteraction!=null&&console.warn(LI),n.hasBackdrop&&!n.usePortal&&console.warn(zI),n.hasBackdrop&&n.interactionKind!==ur.CLICK&&console.error(AI),n.placement!==void 0&&n.position!==void 0&&console.warn(kI);var r=de.Children.count(n.children),o=n.content!==void 0,s=n.target!==void 0;r===0&&!s&&console.error(wI),r>2&&console.warn(SI),r>0&&s&&console.warn(MI),r===2&&o&&console.warn(xI)},t.prototype.updateDarkParent=function(){if(this.props.usePortal&&this.state.isOpen){var n=this.targetElement!=null&&this.targetElement.closest(".".concat(tu))!=null;this.setState({hasDarkParent:n})}},t.prototype.understandChildren=function(){var n=this.props,r=n.children,o=n.content,s=n.target,i=de.Children.toArray(r),d=i[0],S=i[1];return{content:S??o,target:d??s}},t.prototype.getIsOpen=function(n){return n.disabled?!1:n.isOpen!=null?n.isOpen:n.defaultIsOpen},t.prototype.getPopperModifiers=function(){var n=this.props,r=n.boundary,o=n.modifiers,s=o,i=s.flip,d=i===void 0?{}:i,S=s.preventOverflow,g=S===void 0?{}:S;return Nt(Nt({},o),{arrowOffset:{enabled:this.isArrowEnabled(),fn:GS,order:510},flip:Nt({boundariesElement:r},d),preventOverflow:Nt({boundariesElement:r},g),updatePopoverState:{enabled:!0,fn:this.updatePopoverState,order:900}})},t.prototype.setOpenState=function(n,r,o){var s=this,i,d,S,g,w;(i=this.cancelOpenTimeout)===null||i===void 0||i.call(this),o!==void 0&&o>0?this.cancelOpenTimeout=this.setTimeout(function(){return s.setOpenState(n,r)},o):(this.props.isOpen==null?this.setState({isOpen:n}):(S=(d=this.props).onInteraction)===null||S===void 0||S.call(d,n,r),n||(w=(g=this.props).onClose)===null||w===void 0||w.call(g,r))},t.prototype.isArrowEnabled=function(){var n=this.props,r=n.minimal,o=n.modifiers;return!r&&((o==null?void 0:o.arrow)==null||o.arrow.enabled)},t.prototype.isElementInPopover=function(n){var r;return(r=this.popoverElement)===null||r===void 0?void 0:r.contains(n)},t.prototype.isHoverInteractionKind=function(){return this.props.interactionKind===ur.HOVER||this.props.interactionKind===ur.HOVER_TARGET_ONLY},t.displayName="".concat(En,".Popover"),t.defaultProps={boundary:"scrollParent",captureDismiss:!1,defaultIsOpen:!1,disabled:!1,fill:!1,hasBackdrop:!1,hoverCloseDelay:300,hoverOpenDelay:150,inheritDarkTheme:!0,interactionKind:ur.CLICK,minimal:!1,modifiers:{},openOnTargetFocus:!0,shouldReturnFocusOnClose:!1,targetTagName:"span",transitionDuration:300,usePortal:!0,wrapperTagName:"span"},t=mr([sr],t),t}(vr),YS={add:["M10.99 6.99h-2v-2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1zm-3-7c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],"add-clip":["M12 0a1 1 0 00-1 1v2H9a1 1 0 000 2h2v2a1 1 0 102 0V5h2a1 1 0 100-2h-2V1a1 1 0 00-1-1zM0 4a1 1 0 011-1h3.5a1 1 0 010 2H2v2a1 1 0 01-2 0V4zm1 12a1 1 0 01-1-1v-3a1 1 0 112 0v2h2.5a1 1 0 110 2H1zm11 0a1 1 0 001-1v-3a1 1 0 10-2 0v2H9a1 1 0 100 2h3zm-5.5-4a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"],"add-column-left":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 14H2V2h8v12zm4 0h-3V2h3v12zM4 9h1v1c0 .55.45 1 1 1s1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1H7V6c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-column-right":["M8 9h1v1c0 .55.45 1 1 1s1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V6c0-.55-.45-1-1-1s-1 .45-1 1v1H8c-.55 0-1 .45-1 1s.45 1 1 1zm7-9H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 14H2V2h3v12zm9 0H6V2h8v12z"],"add-location":["M8 0a1 1 0 110 2 6 6 0 106 6 1 1 0 012 0 8 8 0 11-8-8zm0 5a3 3 0 110 6 3 3 0 010-6zm5-5a1 1 0 011 1v.999L15 2a1 1 0 010 2h-1v1a1 1 0 01-2 0V4h-1a1 1 0 010-2h1V1a1 1 0 011-1z"],"add-row-bottom":["M6 11h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1H9V8c0-.55-.45-1-1-1s-1 .45-1 1v1H6c-.55 0-1 .45-1 1s.45 1 1 1zm9-11H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V6h12v8zm0-9H2V2h12v3z"],"add-row-top":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2v-3h12v3zm0-4H2V2h12v8zM6 7h1v1c0 .55.45 1 1 1s1-.45 1-1V7h1c.55 0 1-.45 1-1s-.45-1-1-1H9V4c0-.55-.45-1-1-1s-1 .45-1 1v1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-to-artifact":["M14 4.01h-1v-1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1 0-.56-.45-1-1-1zm-13 2h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm8 6H1c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1 0-.56-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1 0-.56-.45-1-1-1z"],"add-to-folder":["M.01 7V5H16v7c0 .55-.45 1-1 1H9.005v-2.99C8.974 8.332 7.644 7 5.996 7H.01zM15 2H7.416L5.706.29a.996.996 0 00-.71-.29H1C.45 0 0 .45 0 1v3h15.99V3c.01-.55-.44-1-.99-1zM5.997 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.589L.3 14.29a1.003 1.003 0 001.42 1.42l3.287-3.29v1.59c0 .55.45 1 1 1 .549 0 .999-.45.999-1v-4A1.02 1.02 0 005.996 9z"],airplane:["M16 1.5A1.498 1.498 0 0013.44.44L9.91 3.97 2 1 1 3l5.93 3.95L3.88 10H1l-1 1 3 2 2 3 1-1v-2.88l3.05-3.05L13 15l2-1-2.97-7.91 3.53-3.53c.27-.27.44-.65.44-1.06z"],"align-center":["M4 4c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H4zM1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm13 10H2c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm1-6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-5 5c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h4z"],"align-justify":["M15 12.98H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-14-10h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1 0 .56.45 1 1 1zm14 4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-3H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0 6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-left":["M13 13H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 3h8c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 12h4c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"align-right":["M15 12.98H3c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm-14-10h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1 0 .56.45 1 1 1zm14 1H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0 6h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1zm0-3H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-bottom":["M10 12h3c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm5 2H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h3c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1z"],"alignment-horizontal-center":["M15 7h-1V6c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v1H7V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4H1c-.55 0-1 .45-1 1s.45 1 1 1h1v4c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V9h2v1c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-left":["M9 9H5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zM1 0C.45 0 0 .45 0 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm13 2H5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"alignment-right":["M11 9H7c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zm4-9c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-4 2H2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"alignment-top":["M15 0H1C.45 0 0 .45 0 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM6 4H3c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm7 0h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"alignment-vertical-center":["M13 2H9V1c0-.55-.45-1-1-1S7 .45 7 1v1H3c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4v2H6c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1H9V7h4c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],annotation:["M15.52 2.77c.3-.29.48-.7.48-1.15C16 .73 15.27 0 14.38 0c-.45 0-.85.18-1.15.48l-1.34 1.34 2.3 2.3 1.33-1.35zM7.4 10.9l6.21-6.21-2.3-2.3L5.1 8.6l2.3 2.3zM14 14H2V2h6.34l2-2H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5.66l-2 2V14zM3 13l3.58-1.29-2.29-2.27L3 13z"],antenna:["M2.673 10.758a1.396 1.396 0 01.093.234c.127.442.012.932-.362 1.212-.441.332-1.075.246-1.349-.233a8 8 0 1114.014-.225c-.259.488-.889.594-1.341.277-.382-.269-.513-.755-.4-1.2a1.259 1.259 0 01.085-.238 6 6 0 10-10.74.173zm2.464-1.862a1.783 1.783 0 01.076.404c.03.415-.096.831-.43 1.078-.444.328-1.08.237-1.314-.264a5.003 5.003 0 01-.24-.62l-.004-.011a5 5 0 119.574-.08l-.003.011c-.063.213-.14.422-.23.625-.226.504-.861.606-1.31.285-.338-.241-.47-.654-.448-1.07a1.737 1.737 0 01.07-.405 2.99 2.99 0 00-.216-2.233 3 3 0 00-5.525 2.28zM8 7a1 1 0 011 1v3.586l2.707 2.707a1 1 0 01-1.414 1.414L8 13.414l-2.293 2.293a1 1 0 01-1.414-1.414L7 11.586V8a1 1 0 011-1z"],"app-header":["M15 0a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h14zM6 4a1 1 0 00-1.993-.117L4 4v8a1 1 0 001.993.117L6 12V9h4v3a1 1 0 001.993.117L12 12V4a1 1 0 00-1.993-.117L10 4v3H6V4z"],application:["M3.5 7h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5zM15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm-1 12H2V5h12v8zM3.5 9h4c.28 0 .5-.22.5-.5S7.78 8 7.5 8h-4c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5z"],applications:["M3.5 11h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-2c-.28 0-.5.22-.5.5s.22.5.5.5zm0-2h5c.28 0 .5-.22.5-.5S8.78 8 8.5 8h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM11 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 10H2V7h8v7zm5-14H5c-.55 0-1 .45-1 1v2h2V2h8v7h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM3.5 13h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-3c-.28 0-.5.22-.5.5s.22.5.5.5z"],archive:["M13.382 0a1 1 0 01.894.553L16 4v11a1 1 0 01-1 1H1a1 1 0 01-1-1V4L1.724.553A1 1 0 012.618 0h10.764zM8 6c-.55 0-1 .45-1 1v2.59l-.29-.29-.081-.076A.97.97 0 006 9a1.003 1.003 0 00-.71 1.71l2 2 .096.084c.168.13.38.206.614.206.28 0 .53-.11.71-.29l2-2 .084-.096A1.003 1.003 0 009.29 9.29l-.29.3V7l-.007-.116A1.004 1.004 0 008 6zm5-4H3L2 4h12l-1-2z"],"area-of-interest":["M4 3.664C4 1.644 5.793 0 8 0s3.993 1.643 4 3.664C12 5.692 8 11 8 11S4 5.692 4 3.664zM6 4a2 2 0 104.001-.001A2 2 0 006 4zm7.504 6.269l-2.68-1.609.021-.033c.34-.538.688-1.115 1-1.687l3.67 2.202a1 1 0 01.266 1.482l-4 5A1 1 0 0111 16H5a1 1 0 01-.78-.376l-4-5a1 1 0 01.266-1.482l3.67-2.202a30.46 30.46 0 00.999 1.687l.021.033-2.68 1.609 2.985 3.73h5.038l2.985-3.73z"],array:["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm4 7a1 1 0 110 2 1 1 0 010-2zM5 7a1 1 0 110 2 1 1 0 010-2zm6 0a1 1 0 110 2 1 1 0 010-2z"],"array-boolean":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm7 6a1 1 0 01.993.883L12 7v2a1 1 0 01-.883.993L11 10H5a1 1 0 01-.993-.883L4 9V7a1 1 0 01.883-.993L5 6h6zm0 1H8v2h3V7z"],"array-date":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm6.5 4a.5.5 0 01.5.5V5a1 1 0 01.993.883L12 6v5a1 1 0 01-.883.993L11 12H5a1 1 0 01-.993-.883L4 11V6a1 1 0 01.883-.993L5 5v-.5a.5.5 0 011 0V5h4v-.5a.5.5 0 01.5-.5zm.5 3H5v4h6V7z"],"array-numeric":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm6.904 5c.256 0 .483.037.68.112a1.343 1.343 0 01.812.788c.072.184.108.385.108.604 0 .23-.05.441-.152.636a1.314 1.314 0 01-.456.492v.016l.08.04c.055.031.111.072.168.124.085.077.163.172.232.284a1.673 1.673 0 01.24.872c0 .25-.043.477-.128.68a1.518 1.518 0 01-.896.852 1.937 1.937 0 01-.68.116c-.427 0-.792-.101-1.096-.304a1.362 1.362 0 01-.584-.864c-.01-.053.01-.088.064-.104l.696-.16.033-.002c.03.002.051.022.063.058.059.16.155.296.288.408.133.112.312.168.536.168.256 0 .453-.076.592-.228a.827.827 0 00.208-.58c0-.277-.08-.495-.24-.652-.16-.157-.376-.236-.648-.236h-.232l-.035-.005c-.03-.01-.045-.035-.045-.075v-.632l.005-.035c.01-.03.035-.045.075-.045h.216l.138-.009a.734.734 0 00.438-.207c.144-.144.216-.336.216-.576a.745.745 0 00-.192-.532c-.128-.136-.307-.204-.536-.204-.203 0-.363.05-.48.152a.815.815 0 00-.248.408c-.016.048-.048.067-.096.056l-.68-.16-.034-.012c-.028-.016-.038-.044-.03-.084a1.347 1.347 0 01.516-.828c.136-.104.296-.185.48-.244A1.98 1.98 0 0110.904 5zm-6.152.088l.035.005c.03.01.045.035.045.075v5.28l-.005.035c-.01.03-.035.045-.075.045h-.736l-.035-.005c-.03-.01-.045-.035-.045-.075V6.16H3.92l-.832.584-.032.016C3.02 6.773 3 6.751 3 6.696V5.88l.006-.04a.157.157 0 01.05-.072l.872-.632.04-.027a.236.236 0 01.104-.021h.68zM7.344 5c.256 0 .483.04.68.12.197.08.364.188.5.324s.24.296.312.48c.072.184.108.383.108.596 0 .245-.045.47-.136.676-.09.205-.216.404-.376.596l-1.584 1.92v.016h2.016l.035.005c.03.01.045.035.045.075v.64l-.005.035c-.01.03-.035.045-.075.045H5.808l-.035-.005c-.03-.01-.045-.035-.045-.075v-.6l.004-.04a.132.132 0 01.036-.064l1.92-2.392.1-.133a1.95 1.95 0 00.156-.267.985.985 0 00.096-.432.736.736 0 00-.188-.512c-.125-.139-.303-.208-.532-.208-.219 0-.39.061-.512.184a.826.826 0 00-.224.496c-.01.053-.04.075-.088.064L5.792 6.4l-.034-.012c-.028-.016-.038-.044-.03-.084a1.425 1.425 0 01.94-1.192A1.88 1.88 0 017.344 5z"],"array-string":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm1.61 5c.514 0 .962.212 1.343.637.382.425.573.997.573 1.716 0 .838-.258 1.588-.773 2.252-.514.663-1.327 1.2-2.437 1.609v-.465l.233-.095a3.09 3.09 0 001.274-1.017c.366-.505.55-1.03.55-1.577a.478.478 0 00-.057-.26c-.018-.037-.043-.056-.074-.056s-.08.025-.149.075c-.198.142-.446.214-.744.214-.36 0-.675-.145-.944-.433A1.453 1.453 0 014 6.572c0-.422.155-.79.465-1.102.31-.313.692-.47 1.144-.47zm4.474 0c.514 0 .963.212 1.344.637.381.425.572.997.572 1.716 0 .838-.257 1.588-.772 2.252-.515.663-1.327 1.2-2.437 1.609v-.465l.233-.095a3.09 3.09 0 001.274-1.017c.366-.505.549-1.03.549-1.577a.478.478 0 00-.056-.26c-.019-.037-.044-.056-.075-.056-.03 0-.08.025-.149.075-.198.142-.446.214-.744.214-.36 0-.674-.145-.944-.433a1.453 1.453 0 01-.405-1.028c0-.422.155-.79.466-1.102.31-.313.691-.47 1.144-.47z"],"array-timestamp":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm4 3a5 5 0 110 10A5 5 0 018 3zm0 1a4 4 0 100 8 4 4 0 000-8zm2.354 1.646a.5.5 0 01.057.638l-.057.07-2 2a.5.5 0 01-.638.057l-.07-.057-1-1a.5.5 0 01.638-.765l.07.057.646.647 1.646-1.647a.5.5 0 01.708 0z"],"arrow-bottom-left":["M14 3a1.003 1.003 0 00-1.71-.71L4 10.59V6c0-.55-.45-1-1-1s-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1H5.41l8.29-8.29c.19-.18.3-.43.3-.71z"],"arrow-bottom-right":["M13 5c-.55 0-1 .45-1 1v4.59l-8.29-8.3a1.003 1.003 0 00-1.42 1.42l8.3 8.29H6c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],"arrow-down":["M13 8c-.3 0-.5.1-.7.3L9 11.6V2c0-.5-.4-1-1-1s-1 .5-1 1v9.6L3.7 8.3C3.5 8.1 3.3 8 3 8c-.5 0-1 .5-1 1 0 .3.1.5.3.7l5 5c.2.2.4.3.7.3s.5-.1.7-.3l5-5c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1z"],"arrow-left":["M13.99 6.99H4.41L7.7 3.7a1.003 1.003 0 00-1.42-1.42l-5 5a1.014 1.014 0 000 1.42l5 5a1.003 1.003 0 001.42-1.42L4.41 8.99H14c.55 0 1-.45 1-1s-.46-1-1.01-1z"],"arrow-right":["M14.7 7.29l-5-5a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l3.29 3.29H1.99c-.55 0-1 .45-1 1s.45 1 1 1h9.59l-3.29 3.29a1.003 1.003 0 001.42 1.42l5-5c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z"],"arrow-top-left":["M13.71 12.29L5.41 4H10c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V5.41l8.29 8.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"arrow-top-right":["M13 2H6c-.55 0-1 .45-1 1s.45 1 1 1h4.59L2.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L12 5.41V10c0 .55.45 1 1 1s1-.45 1-1V3c0-.55-.45-1-1-1z"],"arrow-up":["M13.7 6.3l-5-5C8.5 1.1 8.3 1 8 1s-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L7 4.4V14c0 .6.4 1 1 1s1-.4 1-1V4.4l3.3 3.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7z"],"arrows-horizontal":["M15.7 7.3l-4-4c-.2-.2-.4-.3-.7-.3-.6 0-1 .5-1 1 0 .3.1.5.3.7L12.6 7H3.4l2.3-2.3c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1-.3 0-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7s.1.5.3.7l4 4c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7L3.4 9h9.2l-2.3 2.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l4-4c.2-.2.3-.4.3-.7s-.1-.5-.3-.7z"],"arrows-vertical":["M12 10c-.3 0-.5.1-.7.3L9 12.6V3.4l2.3 2.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7l-4-4C8.5.1 8.3 0 8 0s-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L7 3.4v9.2l-2.3-2.3c-.2-.2-.4-.3-.7-.3-.5 0-1 .4-1 1 0 .3.1.5.3.7l4 4c.2.2.4.3.7.3s.5-.1.7-.3l4-4c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1z"],asterisk:["M14.54 11.18l.01-.02L9.8 8l4.75-3.17-.01-.02c.27-.17.46-.46.46-.81 0-.55-.45-1-1-1-.21 0-.39.08-.54.18l-.01-.02L9 6.13V1c0-.55-.45-1-1-1S7 .45 7 1v5.13L2.55 3.17l-.01.01A.969.969 0 002 3c-.55 0-1 .45-1 1 0 .35.19.64.46.82l-.01.01L6.2 8l-4.75 3.17.01.02c-.27.17-.46.46-.46.81 0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02L7 9.87V15c0 .55.45 1 1 1s1-.45 1-1V9.87l4.45 2.96.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1 0-.35-.19-.64-.46-.82z"],"automatic-updates":["M8 14c-3.31 0-6-2.69-6-6 0-1.77.78-3.36 2-4.46V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1h1.74A7.95 7.95 0 000 8c0 4.42 3.58 8 8 8 .55 0 1-.45 1-1s-.45-1-1-1zM8 2a5.9 5.9 0 012.95.81l1.47-1.47A7.893 7.893 0 008 0c-.55 0-1 .45-1 1s.45 1 1 1zm2.71 6.71l5-5a1.003 1.003 0 00-1.42-1.42L10 6.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29s.53-.11.71-.29zM16 8c0-.55-.06-1.08-.16-1.6l-1.87 1.87A5.966 5.966 0 0112 12.45V11c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-1.74A7.95 7.95 0 0016 8z"],backlink:["M14 10a1 1 0 110 2h-.585l2.292 2.293a1 1 0 01-1.32 1.497l-.094-.083L12 13.415V14a1 1 0 11-2 0l.003-3.075.012-.1.012-.059.033-.108.034-.081.052-.098.067-.096.08-.09a1.01 1.01 0 01.112-.097l.11-.071.143-.065.076-.024.091-.02.116-.014L14 10zM6.036 6.136l-3.45 3.45-.117.127a2 2 0 002.818 2.818l.127-.117 3.45-3.449a4 4 0 01-.885 3.704l-.15.16-1 1A4 4 0 011.02 8.33l.15-.16 1-1a3.998 3.998 0 013.865-1.035zm4.671-1.843a1 1 0 01.083 1.32l-.083.094-5 5a1 1 0 01-1.497-1.32l.083-.094 5-5a1 1 0 011.414 0zm3.121-3.121a4 4 0 01.151 5.497l-.15.16-1 1a3.998 3.998 0 01-3.864 1.036l3.45-3.45.116-.128a2 2 0 00-2.818-2.818l-.127.117-3.45 3.45A4 4 0 017.02 2.33l.15-.16 1-1a4 4 0 015.657 0z"],badge:["M13.36 4.59c-.15-1.13.5-2.01 1.1-2.87L13.43.53c-1.72.88-4.12.65-5.63-.53-1.51 1.18-3.91 1.41-5.63.52l-1.03 1.2c.61.86 1.25 1.74 1.1 2.87-.3 2.29-2.45 4.17-1.32 6.68.45 1.14 1.44 1.9 2.72 2.2 1.56.36 3.52.72 4.16 2.53.64-1.81 2.6-2.16 4.16-2.54 1.28-.3 2.27-1.06 2.72-2.2 1.12-2.5-1.03-4.38-1.32-6.67z"],"ban-circle":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm3 9H5c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1z"],"bank-account":["M15.36 6.46l-.62-.14c-.31-1.12-.98-2.15-1.87-2.99l.4-1.77a.438.438 0 00-.49-.56c-.85.09-1.6.42-2.14.98-.84-.32-1.87-.51-2.85-.51-2.49 0-4.63 1.17-5.92 2.89-.18-.04-.36-.09-.53-.09-.76 0-1.34.61-1.34 1.4 0 .56.31 1.03.76 1.26-.05.33-.09.7-.09 1.07 0 1.68.71 3.17 1.83 4.34l-.27 1.59c-.09.56.35 1.07.89 1.07h.58c.45 0 .8-.33.89-.79l.04-.37c.94.42 2 .7 3.16.7 1.11 0 2.23-.23 3.16-.7l.05.37c.09.47.45.79.89.79h.58c.53 0 .98-.51.89-1.07l-.27-1.54c.62-.61 1.07-1.35 1.38-2.15l.8-.19c.4-.09.71-.47.71-.93V7.4c.09-.47-.22-.84-.62-.94zM12 8c-.6 0-1-.7-1-1.5S11.4 5 12 5s1 .7 1 1.5S12.6 8 12 8zM6.21 4.92c-.41.2-.91.04-1.12-.36-.21-.4-.04-.88.37-1.07 1.35-.65 2.73-.65 4.08 0 .41.2.58.68.37 1.07-.21.4-.71.56-1.12.36-.87-.43-1.71-.43-2.58 0z"],barcode:["M0 14h2V2H0v12zm6 0h1V2H6v12zm2 0h1V2H8v12zm-5 0h2V2H3v12zM15 2v12h1V2h-1zm-5 12h1V2h-1v12zm2 0h2V2h-2v12z"],blank:[],"blocked-person":["M9.39 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.07-.01-.13-.02-.2.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.13-.39.27-.06.43-.36.5-.63.01-.03.03-.08.05-.12C8.18 7.8 6.94 6.04 6.94 4c0-.32.04-.62.09-.92-.17-.03-.35-.08-.51-.08-.65 0-1.37.2-1.88.59-.5.38-.87.92-1.05 1.51-.04.14-.07.27-.09.41-.09.48-.14 1.23-.14 1.74v.06c-.19.08-.36.27-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.12 15.5.03 16 .03 16h12.96s.15-.5-.22-1.36c-.37-.85-2.18-1.42-3.38-1.95zM11.97 0C9.75 0 7.94 1.79 7.94 4s1.8 4 4.03 4S16 6.21 16 4s-1.8-4-4.03-4zM9.96 4c0-1.1.9-2 2.01-2 .37 0 .72.11 1.02.28l-2.75 2.73c-.17-.3-.28-.64-.28-1.01zm2.01 2c-.37 0-.72-.11-1.02-.28l2.75-2.73c.18.3.28.64.28 1.01.01 1.1-.9 2-2.01 2z"],bold:["M11.7 7c.2-.4.3-1 .3-1.5v-.4V5c0-.1 0-.2-.1-.3v-.1C11.4 3.1 10.1 2 8.5 2H4c-.5 0-1 .4-1 1v10c0 .5.4 1 1 1h5c2.2 0 4-1.8 4-4 0-1.2-.5-2.3-1.3-3zM6 5h2c.6 0 1 .4 1 1s-.4 1-1 1H6V5zm3 6H6V9h3c.6 0 1 .4 1 1s-.4 1-1 1z"],book:["M2 1v14c0 .55.45 1 1 1h1V0H3c-.55 0-1 .45-1 1zm11-1h-1v7l-2-2-2 2V0H5v16h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],bookmark:["M11.2.01h-.15C11.03.01 11.02 0 11 0H5c-.02 0-.03.01-.05.01H4.8c-.44 0-.8.37-.8.82v14.75c0 .45.25.56.57.24l2.87-2.94c.31-.32.82-.32 1.13 0l2.87 2.94c.31.32.57.21.57-.24V.83C12 .38 11.64.01 11.2.01z"],box:["M6 10h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1zm9.93-4.37v-.02L13.94.63C13.78.26 13.42 0 13 0H3c-.42 0-.78.26-.93.63L.08 5.61l-.01.02C.03 5.74 0 5.87 0 6v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.13-.03-.26-.07-.37zM9 2h3.32l1.2 3H9V2zM3.68 2H7v3H2.48l1.2-3zM14 14H2V7h12v7z"],briefcase:["M15 3.98h-3v-2c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v2H1c-.55 0-1 .45-1 1v4h3v-1h2v1h6v-1h2v1h3v-4c0-.55-.45-1-1-1zm-5 0H6v-1h4v1zm3 7h-2v-1H5v1H3v-1H0v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-4h-3v1z"],"bring-data":["M14 14a1 1 0 010 2H2a1 1 0 010-2h12zM7.995 3.005c.55 0 1 .45 1 .999v5.584l1.29-1.288a1.002 1.002 0 011.42 1.419l-3 2.996a1.015 1.015 0 01-1.42 0l-3-2.997A1.002 1.002 0 015.705 8.3l1.29 1.29V4.013c0-.55.45-1.009 1-1.009zM14 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zM8 0a1 1 0 110 2 1 1 0 010-2zM5 0a1 1 0 110 2 1 1 0 010-2zM2 0a1 1 0 110 2 1 1 0 010-2z"],buggy:["M13.928.629A1 1 0 0012.89.006l-9 1a1 1 0 00-.747.48L.431 6.005A.5.5 0 000 6.5v3a.5.5 0 00.5.5h2.798c.341 0 .672.116.938.329l1.952 1.561A.5.5 0 006.5 12H10a.5.5 0 00.4-.2l.9-1.2a1.5 1.5 0 011.2-.6h3a.5.5 0 00.5-.5v-4a.5.5 0 00-.308-.462L13.928.628zM12.36 2.094l-.006-.016-3.166.352 1.121 3.083 2.052-3.419zm.467 1.166l-1.649 2.748 2.51-.594-.861-2.154zM9.603 6.496L8.166 2.543l-3.563.396L2.766 6H3.5a.5.5 0 01.367.16L6.218 8.7h1.914l1.452-2.177a.5.5 0 01.019-.027zM2.5 16a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm11 0a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"],build:["M15.39 12.41L7.7 6l1.07-1.1c.34-.34-.12-.63.12-1.26.88-2.17 3.41-2.35 3.41-2.35s.36-.37.71-.72C9.74-.81 7.53.53 6.54 1.4L3.12 4.9l-.71.72c-.39.4-.39 1.05 0 1.45l-.7.72c-.39-.4-1.02-.4-1.41 0s-.39 1.05 0 1.45l1.41 1.45c.39.4 1.02.4 1.41 0s.39-1.05 0-1.45l.71-.72c.39.4 1.02.4 1.41 0l.8-.82 6.39 7.67c.82.82 2.14.82 2.96 0 .81-.82.81-2.15 0-2.96z"],calculator:["M13 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM6 14H4v-2h2v2zm0-3H4V9h2v2zm0-3H4V6h2v2zm3 6H7v-2h2v2zm0-3H7V9h2v2zm0-3H7V6h2v2zm3 6h-2V9h2v5zm0-6h-2V6h2v2zm0-3H4V2h8v3z"],calendar:["M11 3c.6 0 1-.5 1-1V1c0-.6-.4-1-1-1s-1 .4-1 1v1c0 .5.4 1 1 1zm3-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H6v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h13c.6 0 1-.4 1-1V2c0-.6-.5-1-1-1zM5 13H2v-3h3v3zm0-4H2V6h3v3zm4 4H6v-3h3v3zm0-4H6V6h3v3zm4 4h-3v-3h3v3zm0-4h-3V6h3v3zM4 3c.6 0 1-.5 1-1V1c0-.6-.4-1-1-1S3 .4 3 1v1c0 .5.4 1 1 1z"],camera:["M15 3h-2.59L10.7 1.29A.956.956 0 0010 1H6c-.28 0-.53.11-.71.29L3.59 3H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h2.56c1.1 1.22 2.67 2 4.44 2s3.34-.78 4.44-2H15c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zM3 6H1V5h2v1zm5 6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"caret-down":["M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"],"caret-left":["M9.5 4c-.13 0-.24.05-.33.13l-4 3.5c-.1.09-.17.22-.17.37s.07.28.17.37l4 3.5a.495.495 0 00.83-.37v-7c0-.28-.22-.5-.5-.5z"],"caret-right":["M11 8c0-.15-.07-.28-.17-.37l-4-3.5A.495.495 0 006 4.5v7a.495.495 0 00.83.37l4-3.5c.1-.09.17-.22.17-.37z"],"caret-up":["M11.87 9.17s.01 0 0 0l-3.5-4C8.28 5.07 8.15 5 8 5s-.28.07-.37.17l-3.5 4a.495.495 0 00.37.83h7a.495.495 0 00.37-.83z"],"cargo-ship":["M10 1h3a1 1 0 011 1v2h-4V1zM2.25 4a.25.25 0 00-.25.25V9H.883a.5.5 0 00-.429.757l1.072 1.787c.207.344.477.638.791.87A9.76 9.76 0 011 12.5a.5.5 0 000 1c2.067 0 3.414-.543 4.161-.917.55.373 1.505.917 2.839.917 1.32 0 2.27-.533 2.822-.905l.004.002c.196.105.48.24.856.374.75.268 1.857.529 3.318.529a.5.5 0 000-1c-.326 0-.63-.014-.916-.039.47-.328.848-.79 1.07-1.347l.572-1.428A.5.5 0 0015.26 9H4V4.25A.25.25 0 003.75 4h-1.5zm2.714 9.56a.5.5 0 01.527.033c.455.325 1.277.907 2.509.907s2.054-.582 2.51-.907a.5.5 0 01.579-.001l.006.004.036.023c.034.022.09.055.168.097.154.082.394.197.72.313.649.232 1.642.471 2.981.471a.5.5 0 010 1c-1.46 0-2.568-.261-3.318-.53a6.316 6.316 0 01-.856-.373l-.004-.002c-.552.372-1.502.905-2.822.905-1.334 0-2.289-.544-2.839-.917-.747.374-2.094.917-4.161.917a.5.5 0 010-1c2.129 0 3.384-.63 3.964-.94zM14 5h-4v3h3a1 1 0 001-1V5zM5 2a1 1 0 011-1h3v3H5V2zm4 3H5v2a1 1 0 001 1h3V5z"],"cell-tower":["M8.97 6.76c-.01-.05-.04-.08-.06-.13-.02-.05-.03-.1-.05-.15.08-.14.14-.3.14-.48 0-.55-.45-1-1-1s-1 .45-1 1c0 .18.06.34.14.48-.03.05-.03.1-.05.15-.02.05-.05.08-.06.13l-2 8c-.13.54.19 1.08.73 1.21a.995.995 0 001.21-.73L7.53 13h.94l.56 2.24a1 1 0 001.94-.48l-2-8zM3.72 1.7C4.1 1.3 4.09.67 3.7.28S2.67-.09 2.28.3c-3.05 3.12-3.05 8.28 0 11.4a.996.996 0 101.43-1.39c-2.28-2.35-2.28-6.27.01-8.61zM11.6 3.2c-.44-.33-1.07-.24-1.4.2-.33.44-.24 1.07.2 1.4.43.32.53 1.96-.04 2.43-.42.35-.48.98-.13 1.41.35.42.98.48 1.41.13 1.59-1.33 1.39-4.5-.04-5.57z","M13.72.3c-.39-.4-1.02-.4-1.41-.02s-.41 1.02-.03 1.42c2.29 2.34 2.29 6.26 0 8.6-.39.39-.38 1.03.02 1.41s1.03.38 1.41-.02c3.05-3.11 3.05-8.27.01-11.39zM5.4 7.23c-.57-.47-.47-2.11-.04-2.43.44-.33.53-.96.2-1.4s-.96-.53-1.4-.2c-1.44 1.07-1.63 4.24-.04 5.57.42.35 1.05.3 1.41-.13.35-.42.29-1.06-.13-1.41z"],changes:["M8.29 7.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L13 7.59V1c0-.55-.45-1-1-1s-1 .45-1 1v6.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42zM14.5 13h-13c-.83 0-1.5.67-1.5 1.5S.67 16 1.5 16h13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5zM1 5c.28 0 .53-.11.71-.29L3 3.41V10c0 .55.45 1 1 1s1-.45 1-1V3.41L6.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C4.53.11 4.28 0 4 0s-.53.11-.71.29l-3 3A1.003 1.003 0 001 5z"],chart:["M0 15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V9.4L0 11v4zm6-5.5V15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-5l-1 1-3-1.5zM13 7l-1 1v7c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V7.88c-.26.07-.58.12-1 .12-1.96 0-2-1-2-1zm2-6h-3c-.55 0-1 .45-1 1s.45 1 1 1h.59L8.8 6.78 5.45 5.11v.01C5.31 5.05 5.16 5 5 5s-.31.05-.44.11V5.1l-4 2v.01C.23 7.28 0 7.61 0 8c0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L5 7.12 8.55 8.9v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L14 4.41V5c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],chat:["M6 10c-1.1 0-2-.9-2-2V3H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1v2a1.003 1.003 0 001.71.71L5.41 13H10c.55 0 1-.45 1-1v-1.17l-.83-.83H6zm9-10H6c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"chevron-backward":["M7.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L6 6.59V4c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1s1-.45 1-1V9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L7.41 8z"],"chevron-down":["M12 5c-.28 0-.53.11-.71.29L8 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 5z"],"chevron-forward":["M10 3c-.55 0-1 .45-1 1v2.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L7.59 8 4.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L9 9.41V12c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],"chevron-left":["M7.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C5.11 7.47 5 7.72 5 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L7.41 8z"],"chevron-right":["M10.71 7.29l-4-4a1.003 1.003 0 00-1.42 1.42L8.59 8 5.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"chevron-up":["M12.71 9.29l-4-4C8.53 5.11 8.28 5 8 5s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 7.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],circle:["M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z"],"circle-arrow-down":["M11 7c-.28 0-.53.11-.71.29L9 8.59V5c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 7zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-left":["M11 7H7.41L8.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C4.11 7.47 4 7.72 4 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L7.41 9H11c.55 0 1-.45 1-1s-.45-1-1-1zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-right":["M8.71 4.29a1.003 1.003 0 00-1.42 1.42L8.59 7H5c-.55 0-1 .45-1 1s.45 1 1 1h3.59L7.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-up":["M8.71 4.29C8.53 4.11 8.28 4 8 4s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L7 7.41V11c0 .55.45 1 1 1s1-.45 1-1V7.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],citation:["M15.02 5c0-1.66-1.34-3-3-3s-3 1.34-3 3a2.996 2.996 0 003.6 2.94C12.1 9.76 11.14 11 10.02 11c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5-3.13 5-7 0-.2-.02-.39-.04-.58.01-.14.04-.28.04-.42zm-11-3c-1.66 0-3 1.34-3 3a2.996 2.996 0 003.6 2.94C4.1 9.76 3.14 11 2.02 11c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5-3.13 5-7 0-.2-.02-.39-.04-.58.01-.14.04-.28.04-.42 0-1.66-1.35-3-3-3z"],clean:["M12 8l-1.2 2.796-2.8 1.2 2.8 1.197L12 16l1.2-2.807L16 12l-2.8-1.204zM5 0L3.5 3.5 0 4.995 3.5 6.5 5 10l1.5-3.5L10 5 6.5 3.5z"],clip:["M0 1a1 1 0 011-1h4a1 1 0 010 2H2v3a1 1 0 01-2 0V1zm1 15a1 1 0 01-1-1v-4a1 1 0 112 0v3h3a1 1 0 110 2H1zm14 0a1 1 0 001-1v-4a1 1 0 10-2 0v3h-3a1 1 0 100 2h4zm0-16a1 1 0 011 1v4a1 1 0 11-2 0V2h-3a1 1 0 110-2h4zM8 11a3 3 0 100-6 3 3 0 000 6z"],clipboard:["M11 2c0-.55-.45-1-1-1h.22C9.88.4 9.24 0 8.5 0S7.12.4 6.78 1H7c-.55 0-1 .45-1 1v1h5V2zm2 0h-1v2H5V2H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],cloud:["M12 6c-.03 0-.07 0-.1.01A5 5 0 002 7c0 .11.01.22.02.33A3.51 3.51 0 000 10.5C0 12.43 1.57 14 3.5 14H12c2.21 0 4-1.79 4-4s-1.79-4-4-4z"],"cloud-download":["M11 11c-.28 0-.53.11-.71.29L9 12.59V8c0-.55-.45-1-1-1s-1 .45-1 1v4.59L5.71 11.3A.965.965 0 005 11a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 11zm1-7c-.03 0-.07 0-.1.01A5 5 0 002 5c0 .11.01.22.02.33A3.51 3.51 0 000 8.5c0 1.41.84 2.61 2.03 3.17C2.2 10.17 3.46 9 5 9c.06 0 .13.02.19.02C5.07 8.7 5 8.36 5 8c0-1.66 1.34-3 3-3s3 1.34 3 3c0 .36-.07.7-.19 1.02.06 0 .13-.02.19-.02 1.48 0 2.7 1.07 2.95 2.47A3.964 3.964 0 0016 8c0-2.21-1.79-4-4-4z"],"cloud-upload":["M8.71 7.29C8.53 7.11 8.28 7 8 7s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L7 10.41V15c0 .55.45 1 1 1s1-.45 1-1v-4.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM12 4c-.03 0-.07 0-.1.01A5 5 0 002 5c0 .11.01.22.02.33a3.495 3.495 0 00.07 6.37c-.05-.23-.09-.46-.09-.7 0-.83.34-1.58.88-2.12l3-3a2.993 2.993 0 014.24 0l3 3c.54.54.88 1.29.88 2.12 0 .16-.02.32-.05.47C15.17 10.78 16 9.5 16 8c0-2.21-1.79-4-4-4z"],code:["M15.71 7.29l-3-3a1.003 1.003 0 00-1.42 1.42L13.59 8l-2.29 2.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM5 5a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L2.41 8 4.7 5.71c.19-.18.3-.43.3-.71zm4-3c-.48 0-.87.35-.96.81l-2 10c-.01.06-.04.12-.04.19 0 .55.45 1 1 1 .48 0 .87-.35.96-.81l2-10c.01-.06.04-.12.04-.19 0-.55-.45-1-1-1z"],"code-block":["M15 3h-2V2c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v1H7V2c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-8.29 8.29a1.003 1.003 0 01-1.42 1.42l-3-3C2.11 9.53 2 9.28 2 9s.11-.53.29-.71l3-3a1.003 1.003 0 011.42 1.42L4.41 9l2.3 2.29zm7-1.58l-3 3a1.003 1.003 0 01-1.42-1.42L11.59 9l-2.3-2.29a1.003 1.003 0 011.42-1.42l3 3c.18.18.29.43.29.71s-.11.53-.29.71z"],cog:["M15.19 6.39h-1.85c-.11-.37-.27-.71-.45-1.04l1.36-1.36c.31-.31.31-.82 0-1.13l-1.13-1.13a.803.803 0 00-1.13 0l-1.36 1.36c-.33-.17-.67-.33-1.04-.44V.79c0-.44-.36-.8-.8-.8h-1.6c-.44 0-.8.36-.8.8v1.86c-.39.12-.75.28-1.1.47l-1.3-1.3c-.3-.3-.79-.3-1.09 0L1.82 2.91c-.3.3-.3.79 0 1.09l1.3 1.3c-.2.34-.36.7-.48 1.09H.79c-.44 0-.8.36-.8.8v1.6c0 .44.36.8.8.8h1.85c.11.37.27.71.45 1.04l-1.36 1.36c-.31.31-.31.82 0 1.13l1.13 1.13c.31.31.82.31 1.13 0l1.36-1.36c.33.18.67.33 1.04.44v1.86c0 .44.36.8.8.8h1.6c.44 0 .8-.36.8-.8v-1.86c.39-.12.75-.28 1.1-.47l1.3 1.3c.3.3.79.3 1.09 0l1.09-1.09c.3-.3.3-.79 0-1.09l-1.3-1.3c.19-.35.36-.71.48-1.1h1.85c.44 0 .8-.36.8-.8v-1.6a.816.816 0 00-.81-.79zm-7.2 4.6c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"collapse-all":["M7.29 6.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L8 4.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4zm1.42 2.58C8.53 9.11 8.28 9 8 9s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 11.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],"column-layout":["M15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 13H2V3h2v10zm3 0H5V3h2v10zm7 0H8V3h6v10z"],comment:["M14 1H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2v3a1.003 1.003 0 001.71.71L8.41 12H14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM3.5 8C2.67 8 2 7.33 2 6.5S2.67 5 3.5 5 5 5.67 5 6.5 4.33 8 3.5 8zm4 0C6.67 8 6 7.33 6 6.5S6.67 5 7.5 5 9 5.67 9 6.5 8.33 8 7.5 8zm4 0c-.83 0-1.5-.67-1.5-1.5S10.67 5 11.5 5s1.5.67 1.5 1.5S12.33 8 11.5 8z"],comparison:["M7.99-.01c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1v-14c0-.55-.45-1-1-1zm-3 3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm10 0h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-4v-2h4v2zm0 3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-4v-2h4v2zm-10-3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],compass:["M12 8c0 .14-.03.27-.08.39l-3 6.99c-.15.37-.51.62-.92.62s-.77-.25-.92-.61l-3-6.99a1.006 1.006 0 010-.79l3-6.99C7.23.25 7.59 0 8 0s.77.25.92.61l3 6.99c.05.13.08.26.08.4zM8 3.54L6.09 8h3.82L8 3.54z"],compressed:["M15.93 5.63v-.02L13.94.63C13.78.26 13.42 0 13 0H3c-.42 0-.78.26-.93.63L.08 5.61l-.01.02C.03 5.74 0 5.87 0 6v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.13-.03-.26-.07-.37zM9 2h3.32l1.2 3H9V2zM3.68 2H7v3H2.48l1.2-3zM14 14H2V7h5v2.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L9 9.59V7h5v7z"],confirm:["M8.7 4.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l5-5a1.003 1.003 0 00-1.42-1.42l-4.29 4.3L8.7 4.29zm5.22 3.01c.03.23.07.45.07.69 0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6c.81 0 1.59.17 2.3.46l1.5-1.5A7.998 7.998 0 00-.01 7.99c0 4.42 3.58 8 8 8s8-3.58 8-8c0-.83-.13-1.64-.36-2.39l-1.71 1.7z"],console:["M15 15H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1zM14 5H2v8h12V5zM4 6c.28 0 .53.11.71.29l2 2c.18.18.29.43.29.71s-.11.53-.29.71l-2 2a1.003 1.003 0 01-1.42-1.42L4.59 9l-1.3-1.29A1.003 1.003 0 014 6zm5 4h3c.55 0 1 .45 1 1s-.45 1-1 1H9c-.55 0-1-.45-1-1s.45-1 1-1z"],contrast:["M15.2 6.4h-1.44c-.13-.47-.32-.92-.56-1.34L14.26 4c.31-.31.31-.82 0-1.13l-1.13-1.13a.803.803 0 00-1.13 0L10.94 2.8c-.42-.24-.86-.42-1.34-.56V.8c0-.44-.36-.8-.8-.8H7.2c-.44 0-.8.36-.8.8v1.44c-.5.14-.96.34-1.4.59l-1-1c-.3-.3-.79-.3-1.09 0L1.83 2.91c-.3.3-.3.79 0 1.09l1 1c-.25.44-.45.9-.59 1.4H.8c-.44 0-.8.36-.8.8v1.6c0 .44.36.8.8.8h1.44c.13.47.32.92.56 1.34L1.74 12c-.31.31-.31.82 0 1.13l1.13 1.13c.31.31.82.31 1.13 0l1.06-1.06c.42.24.86.42 1.34.56v1.44c0 .44.36.8.8.8h1.6c.44 0 .8-.36.8-.8v-1.44c.5-.14.96-.33 1.4-.59l1 1c.3.3.79.3 1.09 0l1.09-1.09c.3-.3.3-.79 0-1.09l-1-1c.25-.43.45-.9.59-1.4h1.44c.44 0 .8-.36.8-.8V7.2a.818.818 0 00-.81-.8zM8 12c-2.21 0-4-1.79-4-4s1.79-4 4-4v8z"],control:["M13 8H8v5h5V8zm0-5H8v4h5V3zm2-3H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V2h12v12zM7 3H3v10h4V3z"],"credit-card":["M14.99 2.95h-14c-.55 0-1 .45-1 1v1h16v-1c0-.55-.45-1-1-1zm-15 10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-6h-16v6zm5.5-2h5c.28 0 .5.22.5.5s-.22.5-.5.5h-5c-.28 0-.5-.22-.5-.5s.23-.5.5-.5zm-3 0h1c.28 0 .5.22.5.5s-.22.5-.5.5h-1c-.28 0-.5-.22-.5-.5s.23-.5.5-.5z"],cross:["M9.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z"],crown:["M2 6l3 2 3-4 3 4 3-2-1 6H3L2 6zm6-5a1 1 0 110 2 1 1 0 010-2zM1 3a1 1 0 110 2 1 1 0 010-2zm14 0a1 1 0 110 2 1 1 0 010-2zM3 13h10v2H3v-2z"],cube:["M14.194 3.54L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l5.698 3.255zm.75.71a1 1 0 01.056.33v6.84a1 1 0 01-.504.868L8.5 15.714V8.277l6.444-4.027zm-13.888 0L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33z"],"cube-add":["M14 2h1a1 1 0 010 2h-1v1a1 1 0 01-2 0V4h-1a1 1 0 010-2h1V1a1 1 0 012 0v1zM9.136.65a3.001 3.001 0 00.992 5.222c.018.058.038.115.059.172L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l.64.365zM15 7.235v4.184a1 1 0 01-.504.868L8.5 15.714V8.277l2.187-1.367A2.994 2.994 0 0013 8c.768 0 1.47-.289 2-.764zM1.056 4.25L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33z"],"cube-remove":["M10.365 5.933L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l.64.365a3.001 3.001 0 001.228 5.283zM15 6v5.42a1 1 0 01-.504.868L8.5 15.714V8.277L12.143 6H15zM1.056 4.25L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33zM11 2h4a1 1 0 010 2h-4a1 1 0 010-2z"],"curved-range-chart":["M15 12H3.12l1.81-1.39c1.73 1.01 5.53-.03 9.08-2.61l-1.22-1.5C10.3 8.3 7.86 9.37 6.65 9.29L14.3 3.4l-.6-.8-7.83 6.03c-.01-1.07 1.8-3.19 4.47-5.13L9.12 2C5.38 4.7 3.34 8.1 4.25 9.87L2 11.6V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],cut:["M13 2s.71-1.29 0-2L8.66 5.07l1.05 1.32L13 2zm.07 8c-.42 0-.82.09-1.18.26L3.31 0c-.69.71 0 2 0 2l3.68 5.02-2.77 3.24A2.996 2.996 0 000 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-.46-.11-.89-.29-1.27L8.1 8.54l2.33 3.19c-.18.39-.29.82-.29 1.27 0 1.66 1.31 3 2.93 3S16 14.66 16 13s-1.31-3-2.93-3zM3 14c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm10.07 0c-.54 0-.98-.45-.98-1s.44-1 .98-1 .98.45.98 1-.44 1-.98 1z"],cycle:["M13 9a3 3 0 110 6 3 3 0 010-6zM3 9a3 3 0 110 6 3 3 0 010-6zm6.169-5.27l.087.09 1.51 1.746 1.589.549a1 1 0 01.65 1.16l-.032.112a1 1 0 01-1.159.65l-.112-.032-1.843-.636a1 1 0 01-.337-.198l-.092-.093-.959-1.109L7.041 7.5l1.691 1.819a1 1 0 01.26.556L9 10v3a1 1 0 01-1.993.117L7 13l-.001-2.608-2.056-2.211a1 1 0 01-.081-1.264l.082-.1 2.825-3.026a1 1 0 011.4-.061zM13 10.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm-10 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM11 1a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],dashboard:["M5 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM4 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-2c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-2 6c0 1.1.9 2 2 2s2-.9 2-2c0-.53-2-5-2-5s-2 4.47-2 5zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm4-9c0-.55-.45-1-1-1s-1 .45-1 1 .45 1 1 1 1-.45 1-1zm0 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"data-connection":["M1 9.52c.889.641 2.308 1.133 4.003 1.354L5 11a5.994 5.994 0 002.664 4.988c-.217.008-.44.012-.664.012-3.215 0-5.846-.85-5.993-1.906L1 14V9.52zM11 6c2.762 0 5 2.238 5 5s-2.238 5-5 5-5-2.238-5-5 2.238-5 5-5zm1 1l-4 5h2.5l-.5 3 4-5h-2.5l.5-3zm1-3.48v1.822a6.002 6.002 0 00-7.9 4.556l-.248-.03c-2.168-.28-3.733-.966-3.845-1.774L1 8V3.52C2.22 4.4 4.44 5 7 5s4.78-.6 6-1.48zM7 0c3.31 0 6 .9 6 2s-2.69 2-6 2c-3.32 0-6-.9-6-2s2.68-2 6-2z"],"data-lineage":["M1.067 0C.477 0 0 .478 0 1.067V3.2c0 .59.478 1.067 1.067 1.067h2.24a5.342 5.342 0 002.9 3.734 5.337 5.337 0 00-2.9 3.733h-2.24C.477 11.733 0 12.21 0 12.8v2.133C0 15.523.478 16 1.067 16H6.4c.59 0 1.067-.478 1.067-1.067V12.8c0-.59-.478-1.067-1.067-1.067H4.401a4.27 4.27 0 013.92-3.194l.212-.006V9.6c0 .59.478 1.067 1.067 1.067h5.333c.59 0 1.067-.478 1.067-1.067V6.4c0-.59-.478-1.067-1.067-1.067H9.6c-.59 0-1.067.478-1.067 1.067v1.067a4.268 4.268 0 01-4.132-3.2H6.4c.59 0 1.067-.478 1.067-1.067V1.067C7.467.477 6.989 0 6.4 0H1.067z"],database:["M8 4c3.31 0 6-.9 6-2s-2.69-2-6-2C4.68 0 2 .9 2 2s2.68 2 6 2zm-6-.48V8c0 1.1 2.69 2 6 2s6-.9 6-2V3.52C12.78 4.4 10.56 5 8 5s-4.78-.6-6-1.48zm0 6V14c0 1.1 2.69 2 6 2s6-.9 6-2V9.52C12.78 10.4 10.56 11 8 11s-4.78-.6-6-1.48z"],delete:["M11.99 4.99a1.003 1.003 0 00-1.71-.71l-2.29 2.3L5.7 4.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2.29 2.29-2.29 2.29A1.003 1.003 0 005.7 11.7l2.29-2.29 2.29 2.29a1.003 1.003 0 001.42-1.42L9.41 7.99 11.7 5.7c.18-.18.29-.43.29-.71zm-4-5c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],delta:["M8 0L0 16h16L8 0zM7 5l5 10H2L7 5z"],"derive-column":["M6.08 6.67h-.84c.24-.92.56-1.6.96-2.03.24-.27.48-.4.71-.4.05 0 .08.01.11.04s.04.06.04.1c0 .04-.03.11-.1.21-.06.1-.1.2-.1.29 0 .13.05.24.15.33.1.09.23.14.39.14.17 0 .31-.06.42-.17A.58.58 0 008 4.73c0-.22-.09-.39-.26-.53-.17-.13-.44-.2-.81-.2-.59 0-1.12.16-1.59.48-.48.32-.93.85-1.36 1.59-.15.26-.29.42-.42.49s-.35.11-.64.1l-.19.65h.81l-1.19 4.37c-.2.72-.33 1.16-.4 1.33-.1.24-.26.45-.46.62-.08.07-.18.1-.3.1-.03 0-.06-.01-.08-.03l-.03-.04c0-.02.03-.06.09-.11.06-.06.09-.14.09-.26 0-.13-.05-.23-.14-.32a.6.6 0 00-.4-.13c-.21 0-.38.05-.51.16s-.21.25-.21.4c0 .16.08.3.23.42.16.12.4.18.74.18.53 0 .99-.13 1.4-.39.41-.26.76-.65 1.07-1.19.3-.54.62-1.4.94-2.59l.68-2.53h.82l.2-.63zM15 0H8c-.55 0-1 .45-1 1v2h2V2h5v12H9v-1H7v2c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM8.3 9.94c.18.52.33.89.46 1.13.13.24.28.4.44.51.17.1.37.16.62.16.24 0 .49-.08.74-.25.33-.21.66-.58 1.01-1.09l-.21-.11c-.23.31-.41.5-.52.57a.44.44 0 01-.26.07c-.12 0-.24-.07-.36-.21-.2-.24-.46-.91-.8-2 .3-.49.55-.81.75-.96.15-.11.3-.16.47-.16.06 0 .17.02.34.06.16.04.31.06.43.06.17 0 .31-.06.43-.17.1-.11.16-.25.16-.43 0-.19-.06-.33-.17-.44-.12-.11-.28-.16-.49-.16-.19 0-.37.04-.54.13-.17.09-.39.27-.65.56-.2.21-.48.58-.87 1.11-.15-.66-.41-1.26-.78-1.81l-2.05.33-.04.21c.15-.03.28-.04.39-.04.2 0 .37.08.5.25.21.26.5 1.03.88 2.33-.29.37-.49.61-.6.72-.18.18-.33.3-.44.36-.09.04-.19.07-.3.07-.09 0-.23-.04-.42-.13a.866.866 0 00-.36-.09c-.2 0-.36.06-.49.18a.59.59 0 00-.19.46c0 .17.06.32.18.43.12.11.28.16.48.16.2 0 .38-.04.55-.11.17-.08.39-.24.65-.49.24-.27.6-.66 1.06-1.21z"],desktop:["M15 0H1C.45 0 0 .45 0 1v10c0 .55.45 1 1 1h4.75l-.5 2H4c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1h-1.25l-.5-2H15c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 10H2V2h12v8z"],diagnosis:["M3.2 1a1 1 0 01.117 1.993L3.2 3H3v3a2 2 0 001.85 1.995L5 8a2 2 0 001.995-1.85L7 6V3h-.2a1 1 0 01-.993-.883L5.8 2a1 1 0 01.883-.993L6.8 1H8a1 1 0 01.993.883L9 2v4a4.002 4.002 0 01-3.007 3.876v.007L6 10a3 3 0 005.995.176L12 10V7.792a2.5 2.5 0 112 0V10a5 5 0 01-10 0c0-.042.003-.084.008-.125A4 4 0 011.005 6.2L1 6V2a1 1 0 01.883-.993L2 1h1.2z"],"diagram-tree":["M15 8v3h-2V9H9v2H7V9H3v2H1V8a1 1 0 011-1h5V5h2v2h5a1 1 0 011 1zM1 12h2a1 1 0 011 1v2a1 1 0 01-1 1H1a1 1 0 01-1-1v-2a1 1 0 011-1zm12 0h2a1 1 0 011 1v2a1 1 0 01-1 1h-2a1 1 0 01-1-1v-2a1 1 0 011-1zm-6 0h2a1 1 0 011 1v2a1 1 0 01-1 1H7a1 1 0 01-1-1v-2a1 1 0 011-1zM7 0h2a1 1 0 011 1v2a1 1 0 01-1 1H7a1 1 0 01-1-1V1a1 1 0 011-1z"],"direction-left":["M16 1.99l-16 6 16 6-4-6z"],"direction-right":["M16 7.99l-16-6 4 6-4 6z"],disable:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm-6 8c0-3.31 2.69-6 6-6 1.3 0 2.49.42 3.47 1.12l-8.35 8.35c-.7-.98-1.12-2.17-1.12-3.47zm6 6c-1.3 0-2.49-.42-3.47-1.12l8.35-8.35c.7.98 1.12 2.17 1.12 3.47 0 3.32-2.68 6-6 6z"],document:["M9 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5L9 0zm3 14H4V2h4v4h4v8z"],"document-open":["M6 12c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1s.45 1 1 1h1.59L1.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L6 10.41V12zm4-12H4c-.55 0-1 .45-1 1v4h2V2h4v4h4v8H5.24l-1.8 1.8c.16.12.35.2.56.2h10c.55 0 1-.45 1-1V5l-5-5z"],"document-share":["M10 14H2V2h4v4h1c0-.83.36-1.55.91-2.09l-.03-.03.9-.9C8.3 2.45 8 1.77 8 1L7 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V8.22c-.53.48-1.23.78-2 .78v5zm5-14h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 3.41V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],dollar:["M12.83 9.51c-.1-.3-.25-.58-.45-.84s-.45-.49-.75-.7c-.3-.2-.65-.36-1.05-.48-.16-.04-.43-.11-.8-.2-.35-.09-.73-.18-1.12-.28-.39-.1-.74-.19-1.06-.27-.31-.08-.49-.12-.54-.13-.43-.12-.78-.29-1.05-.52-.27-.23-.4-.55-.4-.95 0-.29.07-.53.21-.72.14-.19.32-.34.54-.46.22-.11.46-.19.72-.24.26-.05.52-.08.77-.08.74 0 1.35.15 1.83.46.48.3.75.83.81 1.56h2.14c0-.6-.13-1.13-.38-1.58-.25-.45-.59-.84-1.02-1.15-.43-.31-.93-.54-1.49-.7-.24-.06-.49-.1-.75-.14V1c0-.55-.45-1-1-1s-1 .45-1 1v1.08c-.23.03-.46.07-.68.13-.54.13-1.02.34-1.44.61-.42.28-.76.63-1.02 1.05-.26.43-.39.93-.39 1.5 0 .3.04.59.13.88.09.29.23.56.44.82.21.26.48.49.83.7.35.21.79.38 1.31.51.85.21 1.56.38 2.14.52.58.13 1.08.28 1.52.42.25.09.48.23.69.44.21.21.32.53.32.97 0 .21-.05.42-.14.63-.09.21-.24.39-.45.55-.21.16-.47.29-.81.39-.33.1-.73.15-1.2.15-.43 0-.84-.05-1.21-.14-.37-.09-.7-.24-.99-.43-.29-.2-.51-.45-.67-.76-.16-.31-.24-.68-.24-1.12H3c.01.71.15 1.32.43 1.84.27.52.64.94 1.1 1.27.46.33.99.58 1.61.74.27.07.56.12.85.16V15c0 .55.45 1 1 1s1-.45 1-1v-1.05c.3-.03.61-.08.9-.15.58-.13 1.1-.34 1.56-.63.46-.29.83-.66 1.11-1.11.28-.45.42-1 .42-1.64 0-.31-.05-.61-.15-.91z"],dot:["M8 5a3 3 0 100 6 3 3 0 100-6z"],"double-caret-horizontal":["M13.71 7.29l-3-3A1.003 1.003 0 009 5v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM6 4c-.28 0-.53.11-.71.29l-3 3C2.11 7.47 2 7.72 2 8c0 .28.11.53.29.71l3 3A1.003 1.003 0 007 11V5c0-.55-.45-1-1-1z"],"double-caret-vertical":["M5 7h6a1.003 1.003 0 00.71-1.71l-3-3C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-3 3A1.003 1.003 0 005 7zm6 2H5a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 9z"],"double-chevron-down":["M7.29 8.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4zM12 8c-.28 0-.53.11-.71.29L8 11.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 8z"],"double-chevron-left":["M4.41 8L7.7 4.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C2.11 7.47 2 7.72 2 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.41 8zm5 0l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C7.11 7.47 7 7.72 7 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L9.41 8z"],"double-chevron-right":["M9 8c0-.28-.11-.53-.29-.71l-4-4a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4C8.89 8.53 9 8.28 9 8zm4.71-.71l-4-4a1.003 1.003 0 00-1.42 1.42L11.59 8 8.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"double-chevron-up":["M4 8c.28 0 .53-.11.71-.29L8 4.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-4 4A1.003 1.003 0 004 8zm4.71-.71C8.53 7.11 8.28 7 8 7s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],"doughnut-chart":["M11.86 7h4.05C15.45 3.39 12.61.52 9 .07v4.07A4 4 0 0111.86 7zM12 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4V0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8h-4z"],download:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM11.7 9.7l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-3-3A1.003 1.003 0 015.7 8.28l1.29 1.29V3.99c0-.55.45-1 1-1s1 .45 1 1v5.59l1.29-1.29a1.003 1.003 0 011.71.71c0 .27-.11.52-.29.7z"],"drag-handle-horizontal":["M2 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm8-2c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-4-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"drag-handle-vertical":["M6 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-6c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zM6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4 8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],draw:["M14.9 11c-.3 0-.5.1-.7.3l-3 3c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1zm-1-1v-.2l-1-5c-.1-.3-.3-.6-.6-.7l-11-4-.3.3 5.8 5.8c.2-.1.4-.2.6-.2.8 0 1.5.7 1.5 1.5S8.3 9 7.4 9s-1.5-.7-1.5-1.5c0-.2.1-.4.2-.6L.3 1.1l-.3.3 4 11c.1.3.4.6.7.6l5 1h.2c.3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7z"],"drawer-left":["M7 0a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h6zM6 2H2v12h4V2zm2 5h4.59L11.3 5.71A.965.965 0 0111 5a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42L12.59 9H8V7z"],"drawer-left-filled":["M1 0h6a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1zm7 7h4.59L11.3 5.71A.965.965 0 0111 5a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42L12.59 9H8V7z"],"drawer-right":["M15 0a1 1 0 011 1v14a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1h6zm-1 2h-4v12h4V2zM8 7H3.41L4.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 9H8V7z"],"drawer-right-filled":["M9 0h6a1 1 0 011 1v14a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1zM8 7H3.41L4.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 9H8V7z"],"drive-time":["M15.12 4.76h-1.05l-.76-2.12c-.19-.53-.76-1.08-1.27-1.24 0 0-1.32-.4-4.04-.4-2.72 0-4.04.4-4.04.4-.5.16-1.07.71-1.26 1.24l-.77 2.12H.88c-.48 0-.88.42-.88.94s.4.94.88.94h.38L1 7c-.03.69 0 1.44 0 2v5c0 .66.38 1 1 1s1-.34 1-1v-1h10v1c0 .66.38 1 1 1s1-.34 1-1V9c0-.56-.01-1.37 0-2l-.26-.37h.38c.48 0 .88-.42.88-.93 0-.52-.4-.94-.88-.94zM5 10H3V8h2v2zm8 0h-2V8h2v2zm0-4H3c-.18 0-.06-.82 0-1l.73-1.63C3.79 3.19 3.82 3 4 3h8c.18 0 .21.19.27.37L13 5c.06.18.18 1 0 1z"],duplicate:["M15 0H5c-.55 0-1 .45-1 1v2h2V2h8v7h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 10H2V6h8v8z"],edit:["M3.25 10.26l2.47 2.47 6.69-6.69-2.46-2.48-6.7 6.7zM.99 14.99l3.86-1.39-2.46-2.44-1.4 3.83zm12.25-14c-.48 0-.92.2-1.24.51l-1.44 1.44 2.47 2.47 1.44-1.44c.32-.32.51-.75.51-1.24.01-.95-.77-1.74-1.74-1.74z"],eject:["M4 9h8a1.003 1.003 0 00.71-1.71l-4-4C8.53 3.11 8.28 3 8 3s-.53.11-.71.29l-4 4A1.003 1.003 0 004 9zm8 1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1z"],emoji:["M8 0a8 8 0 110 16A8 8 0 018 0zm0 1a7 7 0 100 14A7 7 0 008 1zM4 8c.228 2.262 2 4 4 4 1.938 0 3.77-1.738 3.984-3.8L12 8h1c-.128 2.888-2.317 5-5 5a5 5 0 01-4.995-4.783L3 8h1zm2-3a1 1 0 110 2 1 1 0 010-2zm4 0a1 1 0 110 2 1 1 0 010-2z"],endorsed:["M15.86 7.5l-.81-1.42V4.5c0-.36-.19-.68-.49-.87l-1.37-.8-.81-1.41c-.19-.31-.51-.49-.86-.49H9.89L8.5.14a.948.948 0 00-1 0l-1.39.8H4.52a1 1 0 00-.86.49l-.8 1.37-1.44.83c-.3.19-.49.51-.49.87v1.65l-.8 1.37c-.08.15-.13.32-.13.49s.05.34.14.49l.8 1.37v1.65c0 .36.19.68.49.87l1.42.81.8 1.37c.19.31.51.49.86.49H6.1l1.39.8c.15.09.32.14.48.14s.34-.05.49-.14l1.39-.8h1.63a1 1 0 00.86-.49l.81-1.41 1.37-.8c.3-.19.49-.51.49-.87V9.93l.81-1.42a.89.89 0 00.04-1.01zm-4.12-.82l-4.01 4.01c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-2-2c-.18-.19-.3-.44-.3-.71a1.003 1.003 0 011.71-.71l1.3 1.3 3.3-3.3a1.003 1.003 0 011.71.71.95.95 0 01-.29.7z"],envelope:["M0 3.06v9.88L4.94 8 0 3.06zM14.94 2H1.06L8 8.94 14.94 2zm-6.41 8.53c-.14.14-.32.22-.53.22s-.39-.08-.53-.22L6 9.06 1.06 14h13.88L10 9.06l-1.47 1.47zM11.06 8L16 12.94V3.06L11.06 8z"],equals:["M3 5h10a1 1 0 010 2H3a1 1 0 110-2zm0 4h10a1 1 0 010 2H3a1 1 0 010-2z"],eraser:["M8.06 13.91l7.63-7.44c.41-.4.41-1.05 0-1.45L10.86.3c-.41-.4-1.08-.4-1.49 0L.31 9.13c-.41.4-.41 1.05 0 1.45l5.58 5.44h8.12v-.01c.55 0 1-.45 1-1s-.45-1-1-1H7.96l.1-.1zm-2.17.06L1.67 9.85l4.22-4.11 4.22 4.11-4.22 4.12z"],error:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13h-2v-2h2v2zm0-3h-2v-7h2v7z"],euro:["M6.52 3.18c.51-.27 1.12-.4 1.83-.4.48 0 .91.06 1.27.18.37.12.68.29.96.51.18.14.3.33.44.51l1.53-1.53c-.12-.11-.23-.22-.36-.32a5.61 5.61 0 00-1.74-.83c-.66-.2-1.36-.3-2.1-.3-.99 0-1.88.18-2.66.53-.79.35-1.45.82-2 1.41-.55.58-.96 1.27-1.26 2.06H2c-.55 0-1 .45-1 1s.45 1 1 1h.04c-.01.17-.04.33-.04.5 0 .17.03.33.04.5H2c-.55 0-1 .45-1 1s.45 1 1 1h.43c0 .01 0 .02.01.02a6.2 6.2 0 001.25 2.07 5.77 5.77 0 002 1.4c.78.34 1.67.51 2.66.51.81 0 1.54-.12 2.21-.36.67-.24 1.25-.59 1.75-1.03l.03-.03-1.55-1.33c-.01.01-.02.03-.03.04-.29.3-.63.53-1.02.69-.4.17-.85.25-1.37.25-.71 0-1.32-.13-1.83-.4s-.93-.62-1.25-1.07c-.19-.24-.34-.49-.46-.76H9c.55 0 1-.45 1-1s-.45-1-1-1H4.35c-.01-.17-.03-.33-.03-.5 0-.17.02-.34.03-.5H10c.55 0 1-.45 1-1s-.45-1-1-1H4.83c.13-.27.27-.52.44-.76.32-.44.74-.8 1.25-1.06zM14 8.98v0z"],exchange:["M1.99 5.99c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zm4.15 1.86a.495.495 0 10.7-.7L5.7 5.99h5.79c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H5.7l1.15-1.15a.495.495 0 10-.7-.7l-2 2c-.1.09-.16.21-.16.35s.06.26.15.35l2 2.01zm7.85-1.86c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zM9.85 8.14a.533.533 0 00-.36-.15.495.495 0 00-.35.85l1.15 1.15h-5.8c-.28 0-.5.22-.5.5s.22.5.5.5h5.79l-1.15 1.15a.495.495 0 10.7.7l2-2c.09-.09.15-.22.15-.35s-.06-.26-.15-.35l-1.98-2z"],"exclude-row":["M0 10a1.003 1.003 0 001.71.71L3 9.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 8 5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L3 6.59l-1.29-1.3A1.003 1.003 0 00.29 6.71L1.59 8 .29 9.29C.11 9.47 0 9.72 0 10zm1-7h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 10H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-1-7H9c-1.1 0-2 .9-2 2s.9 2 2 2h5c1.1 0 2-.9 2-2s-.9-2-2-2z"],"expand-all":["M4 7c.28 0 .53-.11.71-.29L8 3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-4 4A1.003 1.003 0 004 7zm8 2c-.28 0-.53.11-.71.29L8 12.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 9z"],export:["M4 6c.28 0 .53-.11.71-.29L7 3.41V11c0 .55.45 1 1 1s1-.45 1-1V3.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53.11 8.28 0 8 0s-.53.11-.71.29l-4 4A1.003 1.003 0 004 6zm11 5c-.55 0-1 .45-1 1v2H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],"eye-off":["M16 7.97v-.02-.01-.02-.02a.672.672 0 00-.17-.36c-.49-.63-1.07-1.2-1.65-1.72l-3.16 2.26a2.978 2.978 0 01-2.98 2.9c-.31 0-.6-.06-.88-.15L5.09 12.3c.44.19.9.36 1.37.47.97.23 1.94.24 2.92.05.88-.17 1.74-.54 2.53-.98 1.25-.7 2.39-1.67 3.38-2.75.18-.2.37-.41.53-.62.09-.1.15-.22.17-.36v-.02-.02-.01-.02-.03c.01-.02.01-.03.01-.04zm-.43-4.17c.25-.18.43-.46.43-.8 0-.55-.45-1-1-1-.22 0-.41.08-.57.2l-.01-.01-2.67 1.91c-.69-.38-1.41-.69-2.17-.87a6.8 6.8 0 00-2.91-.05c-.88.18-1.74.54-2.53.99-1.25.7-2.39 1.67-3.38 2.75-.18.2-.37.41-.53.62-.23.29-.23.63-.01.92.51.66 1.11 1.25 1.73 1.79.18.16.38.29.56.44l-2.09 1.5.01.01c-.25.18-.43.46-.43.8 0 .55.45 1 1 1 .22 0 .41-.08.57-.2l.01.01 14-10-.01-.01zm-10.41 5a3.03 3.03 0 01-.11-.8 2.99 2.99 0 012.99-2.98c.62 0 1.19.21 1.66.53L5.16 8.8z"],"eye-on":["M10.29 6.7c.18.18.43.29.71.29s.53-.11.71-.29l4-4c.17-.18.29-.43.29-.7a1.003 1.003 0 00-1.71-.71L11 4.58 9.71 3.29A.997.997 0 009 3c-.55 0-1 .44-1 1a1 1 0 00.3.7l1.99 2zM16 7.96v-.02-.01-.02-.02a.64.64 0 00-.17-.36c-.3-.4-.65-.76-1-1.12l-1.7 1.7c-.55.55-1.3.88-2.13.88-.06 0-.11-.01-.17-.02C10.42 10.15 9.32 11 8.01 11A3.005 3.005 0 016.4 5.46c-.24-.43-.39-.93-.39-1.46 0-.26.04-.5.1-.74-.7.2-1.37.5-2.01.86-1.26.7-2.4 1.68-3.4 2.77-.18.21-.36.41-.53.63-.22.29-.22.64 0 .93.51.67 1.12 1.27 1.73 1.81 1.33 1.17 2.85 2.15 4.53 2.55.97.23 1.95.24 2.92.05.89-.18 1.74-.54 2.54-.99 1.25-.71 2.4-1.69 3.39-2.78.18-.2.37-.41.54-.63.09-.1.15-.23.17-.37v-.02-.02-.01-.02-.03c.01-.01.01-.02.01-.03zM8.01 9c.48 0 .87-.35.96-.81a.55.55 0 01-.07-.09l-.02.01L7.8 7.03c-.45.1-.79.48-.79.96 0 .56.45 1.01 1 1.01z"],"eye-open":["M8.002 7.003a1.003 1.003 0 000 2.005 1.003 1.003 0 000-2.005zm7.988.972v-.02-.01-.02-.02a.675.675 0 00-.17-.36c-.509-.673-1.118-1.264-1.737-1.806-1.328-1.173-2.846-2.155-4.523-2.546a6.702 6.702 0 00-2.925-.06c-.889.18-1.738.541-2.546.992C2.84 4.837 1.692 5.81.694 6.902c-.18.211-.36.411-.53.632a.742.742 0 000 .932c.51.672 1.119 1.264 1.738 1.805 1.328 1.173 2.846 2.156 4.523 2.547.968.23 1.947.24 2.925.04.889-.18 1.738-.542 2.546-.993 1.248-.712 2.397-1.684 3.395-2.777.18-.2.37-.411.54-.632.09-.1.149-.23.169-.36v-.02-.02-.01-.02-.03c0-.01-.01-.01-.01-.02zm-7.988 3.038a2.998 2.998 0 01-2.995-3.008 2.998 2.998 0 012.995-3.008 2.998 2.998 0 012.996 3.008 2.998 2.998 0 01-2.996 3.008z"],"fast-backward":["M14 3c-.24 0-.44.09-.62.23l-.01-.01L9 6.72V4c0-.55-.45-1-1-1-.24 0-.44.09-.62.23v-.01l-5 4 .01.01C2.16 7.41 2 7.68 2 8s.16.59.38.77v.01l5 4 .01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V9.28l4.38 3.5.01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"fast-forward":["M15 8c0-.32-.16-.59-.38-.77l.01-.01-5-4-.01.01A.987.987 0 009 3c-.55 0-1 .45-1 1v2.72l-4.38-3.5v.01A.987.987 0 003 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01L8 9.28V12c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01 5-4-.01-.01c.22-.18.38-.45.38-.77z"],feed:["M1.99 11.99c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zm1-4c-.55 0-1 .45-1 1s.45 1 1 1c1.66 0 3 1.34 3 3 0 .55.45 1 1 1s1-.45 1-1c0-2.76-2.24-5-5-5zm0-4c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7 3.13 7 7 0 .55.45 1 1 1s1-.45 1-1a9 9 0 00-9-9zm0-4c-.55 0-1 .45-1 1s.45 1 1 1c6.08 0 11 4.92 11 11 0 .55.45 1 1 1s1-.45 1-1c0-7.18-5.82-13-13-13z"],"feed-subscribed":["M3 2c1.06 0 2.08.16 3.06.45.13-.71.52-1.32 1.05-1.76C5.82.25 4.44 0 3 0c-.55 0-1 .45-1 1s.45 1 1 1zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm8.32-6.33a.99.99 0 001.4 0l3.98-3.98c.19-.18.3-.42.3-.7 0-.55-.45-.99-1-.99-.28 0-.52.11-.7.29l-3.28 3.28-1.29-1.29a.99.99 0 00-.7-.29 1 1 0 00-1 .99c0 .27.11.52.29.7l2 1.99zm3.73.53l-.93.93-.02-.02c-.17.17-.35.33-.56.45C13.47 9.16 14 11.02 14 13c0 .55.45 1 1 1s1-.45 1-1c0-2.5-.73-4.82-1.95-6.8zM3 8c-.55 0-1 .45-1 1s.45 1 1 1c1.66 0 3 1.34 3 3 0 .55.45 1 1 1s1-.45 1-1c0-2.76-2.24-5-5-5zm5.91-.91l-.03.03-2-2 .03-.03c-.11-.11-.23-.2-.33-.33A8.9 8.9 0 003 4c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7 3.13 7 7 0 .55.45 1 1 1s1-.45 1-1c0-1.87-.57-3.61-1.55-5.06-.61-.11-1.13-.42-1.54-.85z"],film:["M15 1h-5v2H6V1H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h5v-2h4v2h5c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 13H2v-2h2v2zm0-3H2V8h2v2zm0-3H2V5h2v2zm0-3H2V2h2v2zm6 6H6V5h4v5zm4 3h-2v-2h2v2zm0-3h-2V8h2v2zm0-3h-2V5h2v2zm0-3h-2V2h2v2z"],filter:["M13.99.99h-12a1.003 1.003 0 00-.71 1.71l4.71 4.71V14a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V7.41L14.7 2.7a1.003 1.003 0 00-.71-1.71z"],"filter-keep":["M15 10c-.28 0-.53.11-.71.29L12 12.59l-1.29-1.29A.965.965 0 0010 11a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0015 10zm-3-8c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7z"],"filter-list":["M9 8c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1h-5c-.55 0-1 .45-1 1zm3-6c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7zm3 8h-5c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0 3h-5c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"filter-open":["M15.707 10.293a1 1 0 010 1.414l-3 3c-.63.63-1.707.184-1.707-.707V8c0-.89 1.077-1.337 1.707-.707l3 3zM12 2c0 .28-.11.53-.29.7L8 6.41V10c0 .28-.11.53-.29.71l-2 2A1.003 1.003 0 014 12V6.41L.29 2.71A1.003 1.003 0 011 1h10c.55 0 1 .45 1 1z"],"filter-remove":["M12 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7zm2.41 10l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L13 10.59 11.71 9.3A.965.965 0 0011 9a1.003 1.003 0 00-.71 1.71l1.3 1.29-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l1.29-1.3 1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L14.41 12z"],flag:["M2.99 2.99c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1s1-.45 1-1v-11c0-.55-.45-1-1-1zm0-3c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm2 3.03v7.23c2.07-2.11 5.92 1.75 9 0V3.02c-3 2.07-6.94-2.03-9 0z"],flame:["M9.217 0c0 1.368.368 2.462 1.104 3.282C12.774 5.197 14 7.385 14 9.846c0 2.735-1.472 4.786-4.415 6.154 2.165-2.4 1.84-3.385-.368-6.4-2.342 1.2-1.967 2-1.592 3.6-.786 0-1.5 0-1.875-.4 0 .547.898 2 1.464 3.2-2.943-.82-6.092-5.744-4.988-6.154.736-.273 1.594-.137 2.575.41C3.575 5.333 5.047 1.915 9.217 0z"],flash:["M4 8c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1zm4-4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S7 .45 7 1v2c0 .55.45 1 1 1zM3.79 5.21a1.003 1.003 0 001.42-1.42l-1.5-1.5a1.003 1.003 0 00-1.42 1.42l1.5 1.5zm.71 5.29c-.28 0-.53.11-.71.29l-1.5 1.5a1.003 1.003 0 001.42 1.42l1.5-1.5a1.003 1.003 0 00-.71-1.71zm7-5c.28 0 .53-.11.71-.29l1.5-1.5a1.003 1.003 0 00-1.42-1.42l-1.5 1.5a1.003 1.003 0 00.71 1.71zm.71 5.29a1.003 1.003 0 00-1.42 1.42l1.5 1.5a1.003 1.003 0 001.42-1.42l-1.5-1.5zM15 7h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1s-.45-1-1-1zM8 5C6.34 5 5 6.34 5 8s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm0 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0 3c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1z"],"floppy-disk":["M15.71 2.29l-2-2A.997.997 0 0013 0h-1v6H4V0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V3c0-.28-.11-.53-.29-.71zM14 15H2V9c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v6zM11 1H9v4h2V1z"],"flow-branch":["M10.643 6.595c.22.418.344.894.344 1.399 0 .439-.094.855-.263 1.231l3.265 3.462-.002-1.75a.973.973 0 01.314-.68.99.99 0 011.388.048c.186.2.316.46.3.715l-.009 4.03a.959.959 0 01-.3.68.972.972 0 01-.698.266l-4.053.002a.97.97 0 01-.679-.314 1.031 1.031 0 01.05-1.42.972.972 0 01.698-.266l1.7-.001-3.305-3.35a2.998 2.998 0 01-4.228-1.653H.999a1 1 0 010-2h4.166a2.998 2.998 0 014.06-1.735l3.449-3.268-1.745.002a.979.979 0 01-.631-1.692c.199-.186.459-.316.713-.3l4.025.009c.247.008.493.1.679.3.186.2.274.451.265.7l.002 4.046a.972.972 0 01-.313.68 1.03 1.03 0 01-1.42-.05.973.973 0 01-.266-.7V3.295l-3.34 3.301z"],"flow-end":["M9.702 7.31c.176.176.293.41.293.684a.976.976 0 01-.283.695c-1.888 1.91-2.892 2.918-3.011 3.027-.179.164-.42.284-.693.284a.995.995 0 01-.997-.985c0-.274.112-.541.292-.72.12-.12.624-.551 1.514-1.293H.98c-.536 0-.975-.47-.975-1.008 0-.537.439-.996.975-.996h5.837c-.895-.752-1.4-1.187-1.514-1.304a1.03 1.03 0 01-.292-.705C5.01 4.45 5.464 4 6 4c.272 0 .52.108.695.294A535.7 535.7 0 009.702 7.31zM13 11.002c-1.657 0-3-1.347-3-3.008a3.004 3.004 0 013-3.007c1.657 0 3 1.346 3 3.007a3.004 3.004 0 01-3 3.008z"],"flow-linear":["M4.16 9.002H.977C.44 9.002 0 8.532 0 7.994c0-.537.44-.99.978-.99h3.18A3.01 3.01 0 016.995 5a3.01 3.01 0 012.839 2.004h2.98c-.898-.756-1.404-1.193-1.518-1.31a1.03 1.03 0 01-.293-.705c0-.538.454-.989.992-.989.274 0 .521.108.697.294.118.124 1.122 1.13 3.014 3.016a.96.96 0 01.293.684.975.975 0 01-.284.695l-3.018 3.027a.974.974 0 01-.694.284c-.553 0-1-.447-1-.985 0-.274.117-.545.293-.72l1.518-1.293H9.833A3.01 3.01 0 016.996 11 3.01 3.01 0 014.16 9.002z"],"flow-review":["M5.175 7.004a3.003 3.003 0 012.83-2.001c1.305 0 2.416.835 2.83 2.001h1.985c-.896-.756-1.401-1.193-1.515-1.31a1.03 1.03 0 01-.292-.705c0-.538.453-.989.99-.989a.95.95 0 01.696.294c.117.124 1.12 1.13 3.008 3.016.176.176.293.41.293.684a.976.976 0 01-.283.695l-3.013 3.027a.995.995 0 01-1.691-.702c0-.273.116-.544.292-.72l1.515-1.292h-1.98a3.003 3.003 0 01-2.835 2.016A3.003 3.003 0 015.17 9.002H3.18l1.515 1.292c.176.176.292.447.292.72a.995.995 0 01-1.69.702L.282 8.69A.976.976 0 010 7.994c0-.273.117-.508.293-.684A535.858 535.858 0 003.3 4.294.95.95 0 013.997 4c.537 0 .99.45.99.989 0 .273-.12.528-.292.705-.114.117-.62.554-1.515 1.31h1.995z"],"flow-review-branch":["M10.392 10.647A3.002 3.002 0 016.16 8.995H3.37l1.338 1.318c.172.178.287.41.282.683-.01.536-.524.995-.99.995-.465 0-.63-.187-.747-.294L.281 8.682A.956.956 0 010 7.994a.971.971 0 01.294-.687l3.01-3.028a.973.973 0 01.697-.27c.536.01.998.485.989 1.021a.971.971 0 01-.295.687L3.37 6.997h2.79a3.002 3.002 0 014.106-1.716l2.416-2.277-1.732.004a.99.99 0 01-.679-.329.978.978 0 01.05-1.378c.199-.186.459-.315.714-.3l4.012.005c.248.009.493.1.68.3.185.2.273.45.264.699L15.99 6.05a.973.973 0 01-.314.679 1.03 1.03 0 01-1.421-.048.971.971 0 01-.265-.699V4.29L11.65 6.602c.219.416.343.89.343 1.394 0 .451-.1.88-.279 1.263L14 11.68l-.004-1.73a.982.982 0 01.323-.68.978.978 0 011.378.049c.187.2.316.46.3.714l-.004 4.011a.983.983 0 01-.3.691.972.972 0 01-.7.265l-4.046-.001a.987.987 0 01-.679-.326 1.017 1.017 0 01.048-1.41.972.972 0 01.699-.265h1.693l-2.315-2.35z"],flows:["M13.5 6a2.5 2.5 0 00-2.45 2h-1.3L5.74 4l-.75.75L8.25 8h-3.3a2.5 2.5 0 100 1h3.3l-3.26 3.25.75.75 4.01-4h1.3a2.5 2.5 0 102.45-3z"],"folder-close":["M-.01 14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7h-16v7zm15-10H7.41L5.7 2.3a.965.965 0 00-.71-.3h-4c-.55 0-1 .45-1 1v3h16V5c0-.55-.45-1-1-1z"],"folder-new":["M10.165 7a3.003 3.003 0 002.827 2 3.003 3.003 0 002.827-2H16v7c0 .55-.45 1-1 1H1.01c-.55 0-1-.45-1-1V7h10.155zM8.76 6H0V3c0-.55.45-1 1-1h1.998c.28 0 .53.11.71.29L5.417 4h2.578c0 .768.29 1.469.765 2zm6.23-3c.55 0 1 .45 1 1s-.45 1-1 1h-.999v1c0 .55-.45 1-1 1-.549 0-.998-.45-.998-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 .999-1 .55 0 1 .45 1 1v1h.999z"],"folder-open":["M2.06 6.69c.14-.4.5-.69.94-.69h11V5c0-.55-.45-1-1-1H6.41l-1.7-1.71A.997.997 0 004 2H1c-.55 0-1 .45-1 1v9.84l2.05-6.15h.01zM16 8c0-.55-.45-1-1-1H4a.99.99 0 00-.94.69l-2 6c-.04.09-.06.2-.06.31 0 .55.45 1 1 1h11c.44 0 .81-.29.94-.69l2-6c.04-.09.06-.2.06-.31z"],"folder-shared":["M8.76 5.98c-.47-.53-.77-1.22-.77-1.99h-.58L5.7 2.29a.965.965 0 00-.71-.3h-4c-.55 0-1 .45-1 1v3h8.76l.01-.01zm6.23-2.99h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V8c0 .55.45 1 1 1s1-.45 1-1V4c0-.56-.45-1.01-1-1.01zm-1.98 7.23l-.9.9-.01-.01c-.54.55-1.28.89-2.11.89-1.66 0-3-1.34-3-3 0-.77.3-1.47.78-2H-.01v7c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.18c-.31.11-.65.18-1 .18-.76-.01-1.45-.31-1.98-.78z"],"folder-shared-open":["M13.02 10.22l-.9.9-.01-.01c-.54.55-1.28.89-2.11.89-1.66 0-3-1.34-3-3 0-.77.3-1.47.78-2H4a.99.99 0 00-.94.69l-2 6c-.04.09-.06.2-.06.31 0 .55.45 1 1 1h11c.44 0 .81-.29.94-.69l1.11-3.32c-.01 0-.03.01-.05.01-.77 0-1.45-.3-1.98-.78zM2.06 6.69c.14-.4.5-.69.94-.69h5.76l.01-.01C8.3 5.46 8 4.77 8 4H6.41l-1.7-1.71A.997.997 0 004 2H1c-.55 0-1 .45-1 1v9.84l2.05-6.15h.01zM15 3h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 6.41V8c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],follower:["M9.37 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.06-.01-.12-.01-.19.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.12-.39.28-.06.44-.36.5-.63.06-.11.19-.39.16-.7-.04-.4-.2-.59-.38-.67v-.07c0-.52-.05-1.26-.14-1.74a2.72 2.72 0 00-.09-.43 3.02 3.02 0 00-1.04-1.51C7.87 3.2 7.15 3 6.5 3c-.64 0-1.36.2-1.87.59-.5.38-.87.92-1.05 1.51-.04.13-.07.27-.09.4-.09.49-.14 1.24-.14 1.75v.06c-.19.07-.36.26-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.13 15.5.02 16 .02 16h12.96s.15-.5-.22-1.36c-.38-.85-2.19-1.42-3.39-1.95zm6.33-10.4l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9.99c-.55 0-1 .45-1 1s.45 1 1 1h2.58l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],following:["M9.37 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.06-.01-.12-.01-.19.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.12-.39.28-.06.44-.36.5-.63.06-.11.19-.39.16-.7-.04-.4-.2-.59-.38-.67v-.07c0-.52-.05-1.26-.14-1.74a2.72 2.72 0 00-.09-.43 3.02 3.02 0 00-1.04-1.51C7.87 3.2 7.15 3 6.5 3c-.64 0-1.36.2-1.87.59-.5.38-.87.92-1.05 1.51-.04.13-.07.27-.09.4-.09.49-.14 1.24-.14 1.75v.06c-.19.07-.36.26-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.13 15.5.02 16 .02 16h12.96s.15-.5-.22-1.36c-.38-.85-2.19-1.42-3.39-1.95zM14.99 2h-2.58l.29-.29A1.003 1.003 0 0011.28.29l-2 2c-.17.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L12.41 4h2.58c.55 0 1-.45 1-1s-.45-1-1-1z"],font:["M13.93 14.67L8.94.67h-.01C8.79.28 8.43 0 8 0s-.79.28-.93.67h-.01l-5 14h.01c-.04.1-.07.21-.07.33 0 .55.45 1 1 1 .43 0 .79-.28.93-.67h.01L5.49 11h5.02l1.55 4.34h.01c.14.38.5.66.93.66.55 0 1-.45 1-1 0-.12-.03-.23-.07-.33zM6.2 9L8 3.97 9.8 9H6.2z"],fork:["M13.7 9.29a1.003 1.003 0 00-1.42 1.42l.29.29H11.4l-5-5h6.17l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.29.29H.99c-.55 0-1 .45-1 1s.45 1 1 1h2.59l6.71 6.71c.18.18.43.29.71.29h1.59l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2.02-2z"],form:["M2 11v2h2v-2H2zM1 9h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1zm9-6h5c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1zM6 1a1.003 1.003 0 01.71 1.71l-3 4C3.53 6.89 3.28 7 3 7s-.53-.11-.71-.29l-2-2a1.003 1.003 0 011.42-1.42L3 4.59l2.29-3.3C5.47 1.11 5.72 1 6 1zm4 10h5c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1z"],"full-circle":["M8 0a8 8 0 100 16A8 8 0 108 0z"],"full-stacked-chart":["M13 12h1c.55 0 1-.45 1-1V8h-3v3c0 .55.45 1 1 1zM10 2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3h3V2zm0 4H7v3h3V6zm5-4c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v2h3V2zm0 3h-3v2h3V5zM5 5H2v3h3V5zm-2 7h1c.55 0 1-.45 1-1V9H2v2c0 .55.45 1 1 1zm12 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM5 2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h3V2zm3 10h1c.55 0 1-.45 1-1v-1H7v1c0 .55.45 1 1 1z"],fullscreen:["M3.41 2H5c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v4c0 .55.45 1 1 1s1-.45 1-1V3.41L5.29 6.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L3.41 2zM6 9c-.28 0-.53.11-.71.29L2 12.59V11c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41l3.29-3.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1zm9 1c-.55 0-1 .45-1 1v1.59L10.71 9.3A.965.965 0 0010 9a1.003 1.003 0 00-.71 1.71l3.3 3.29H11c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm0-10h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 3.41V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],function:["M8.12 4.74H6.98c.33-1.29.75-2.24 1.28-2.84.33-.37.64-.56.95-.56.06 0 .11.02.15.05.04.04.06.09.06.15 0 .05-.04.15-.13.29-.09.14-.13.28-.13.4 0 .18.07.33.2.46.14.13.31.19.52.19.22 0 .41-.08.56-.23.15-.16.23-.37.23-.63 0-.3-.11-.55-.34-.74C10.1 1.09 9.74 1 9.24 1c-.78 0-1.49.22-2.12.67-.64.45-1.24 1.2-1.81 2.23-.2.36-.38.59-.56.69-.18.1-.46.15-.85.15l-.26.9h1.08l-1.59 6.12c-.27 1.01-.44 1.63-.54 1.86-.14.34-.34.63-.62.87-.11.1-.24.15-.4.15a.15.15 0 01-.11-.04l-.04-.05c0-.03.04-.08.12-.16.08-.08.12-.2.12-.36 0-.18-.06-.33-.19-.44-.12-.12-.3-.18-.54-.18-.28 0-.51.08-.68.23-.16.14-.25.32-.25.53 0 .22.1.42.31.59.21.17.53.25.97.25.7 0 1.32-.18 1.87-.54.54-.36 1.02-.92 1.42-1.67.41-.75.82-1.96 1.25-3.63l.91-3.54h1.1l.29-.89zm5.43 1.52c.2-.15.41-.23.62-.23.08 0 .23.03.45.09s.41.09.57.09c.23 0 .42-.08.57-.23.16-.16.24-.36.24-.61 0-.26-.08-.47-.23-.62-.15-.15-.37-.23-.66-.23-.25 0-.5.06-.72.18-.23.12-.51.38-.86.78-.26.3-.64.81-1.15 1.55-.2-.91-.55-1.75-1.05-2.51l-2.72.46-.06.29c.2-.04.37-.06.51-.06.27 0 .49.11.67.34.28.36.67 1.45 1.17 3.26-.39.52-.66.85-.8 1.01-.24.26-.44.42-.59.5-.12.06-.25.09-.41.09-.11 0-.3-.06-.56-.18-.18-.08-.34-.12-.48-.12-.27 0-.48.08-.66.25-.17.17-.26.38-.26.64 0 .25.08.44.24.6.16.15.37.23.64.23.26 0 .5-.05.73-.16.23-.11.52-.34.86-.69.35-.35.82-.9 1.43-1.67.23.73.44 1.25.61 1.58s.37.57.59.71c.22.15.5.22.83.22.32 0 .65-.11.98-.34.44-.3.88-.81 1.34-1.53l-.26-.15c-.31.43-.54.7-.69.8-.1.07-.22.1-.35.1-.16 0-.32-.1-.48-.3-.27-.34-.62-1.27-1.06-2.8.4-.68.73-1.13 1-1.34z"],"gantt-chart":["M10 10c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1zM6 7c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1zm9 5H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM4 5h3c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1z"],geofence:["M6 9c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1v-1.59l-3.29 3.3A1.003 1.003 0 010 15c0-.28.11-.53.3-.71L3.59 11H2c-.55 0-1-.45-1-1s.45-1 1-1zM9.088.004l.097.013.097.024.057.018.1.042.054.029.095.061.052.04 6 5 .05.046.076.08.053.07.06.095.051.11c.056.141.079.294.067.446l-.014.105-.037.143-.035.087-.043.083-4 7-.034.056-.059.08-.038.044-.096.092-.114.082-.116.062-.086.034-.109.03-.1.017-.069.006H8.83c.088-.25.144-.515.163-.79L9 13v-3a3 3 0 00-2.824-2.995L6 7H3c-.351 0-.689.06-1.002.171L2 5l.002-.07.013-.1.015-.073.025-.085.043-.104.056-.101.045-.066.079-.093.084-.078.083-.062 6-4 .07-.043.12-.056.111-.036.108-.022.083-.01h.031c.046-.002.083 0 .12.003z"],geolocation:["M-.01 6.66l7.34 2 2 7.33 6.66-16z"],geosearch:["M8.82 12.4h.66c.23 0 .36-.17.36-.4v-1.48l.19-.18c-.27.03-.55.06-.83.06-.28 0-.56-.03-.84-.07.02.04.05.08.07.13V12c0 .23.15.4.39.4zM6.4 15.1A5.51 5.51 0 01.9 9.6c0-.49.06-.98.18-1.43.03 0 .05-.01.08-.01h.08v.44c0 .19.17.34.36.34.03 0 .07-.01.1-.01l.71.7c.07.07.19.07.26 0s.07-.19 0-.26l-.7-.72c0-.02.03-.03.03-.05v-.11c0-.15.08-.2.23-.33h.42c.08 0 .15-.01.22-.04h.02c.02-.02.03-.02.04-.04.01-.01.01-.01.02-.01l.02-.01.9-.9c-.13-.26-.24-.52-.34-.8h-.5v-.43c0-.01.05.05.04-.08h.31c-.03-.13-.06-.26-.08-.39h-.57c.16-.12.34-.24.51-.36-.02-.23-.04-.46-.04-.7 0-.12.01-.23.02-.34A6.385 6.385 0 000 9.6C0 13.13 2.87 16 6.4 16c3.1 0 5.67-2.22 6.26-5.15l-.78-.88c-.21 2.85-2.58 5.13-5.48 5.13zm-1.7-2.93v-.28h.12c.23 0 .39-.19.39-.42v-.54s.01-.01 0-.01L3.77 9.45h-.62c-.23 0-.38.19-.38.42v1.6c0 .23.14.42.38.42h.26v1.61c0 .23.22.41.45.41s.45-.18.45-.41v-.97H4.3c.24 0 .4-.13.4-.36zm11.07-2.34l-2.94-2.94c.11-.17.21-.34.3-.52.01-.03.03-.06.04-.09.08-.18.16-.36.22-.55v-.01c.06-.19.1-.38.14-.58.01-.05.01-.09.02-.14.03-.2.05-.4.05-.61a4.4 4.4 0 00-4.4-4.4C6.77 0 4.8 1.97 4.8 4.4s1.97 4.4 4.4 4.4c.21 0 .41-.02.61-.05.04 0 .09-.01.14-.02.2-.03.39-.08.58-.14h.01c.19-.06.37-.14.55-.22.03-.01.06-.03.09-.04.18-.09.35-.19.52-.3l2.94 2.94a.8.8 0 00.57.23c.44 0 .8-.36.8-.8a.895.895 0 00-.24-.57zM9.2 7.6C7.43 7.6 6 6.17 6 4.4c0-1.77 1.43-3.2 3.2-3.2s3.2 1.43 3.2 3.2c0 1.77-1.43 3.2-3.2 3.2zm1.54 4.26v-.52c0-.09-.1-.17-.19-.17s-.19.07-.19.17v.52c0 .09.1.17.19.17s.19-.07.19-.17z"],"git-branch":["M12 1c-1.66 0-3 1.34-3 3 0 1.25.76 2.32 1.85 2.77A2.02 2.02 0 019 8H7c-.73 0-1.41.2-2 .55V5.82C6.16 5.4 7 4.3 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.82v4.37c-1.16.4-2 1.51-2 2.81 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.04-.53-1.95-1.32-2.49.35-.31.81-.51 1.32-.51h2c1.92 0 3.52-1.35 3.91-3.15A2.996 2.996 0 0012 1zM4 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 12c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm8-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-commit":["M15 7h-3.14c-.45-1.72-2-3-3.86-3S4.59 5.28 4.14 7H1c-.55 0-1 .45-1 1s.45 1 1 1h3.14c.45 1.72 2 3 3.86 3s3.41-1.28 3.86-3H15c.55 0 1-.45 1-1s-.45-1-1-1zm-7 3c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"git-merge":["M12 6c-1.3 0-2.4.84-2.82 2H9c-1.62 0-3-.96-3.63-2.34C6.33 5.16 7 4.16 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.81v4.37C1.84 10.6 1 11.7 1 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V8.43A5.89 5.89 0 009 10h.18A2.996 2.996 0 0015 9c0-1.66-1.34-3-3-3zm-8 8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm8 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-new-branch":["M14 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3.18 4.8C10.51 7.51 9.82 8 9 8H7c-.73 0-1.41.2-2 .55V5.82C6.16 5.4 7 4.3 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.82v4.37c-1.16.4-2 1.51-2 2.81 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.04-.53-1.95-1.32-2.49.35-.31.81-.51 1.32-.51h2c1.9 0 3.49-1.33 3.89-3.11-.29.07-.58.11-.89.11-.41 0-.8-.08-1.18-.2zM4 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 12c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-pull":["M3 1C1.34 1 0 2.34 0 4c0 1.3.84 2.4 2 2.82v3.37C.84 10.6 0 11.7 0 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V6.82C5.16 6.4 6 5.3 6 4c0-1.66-1.34-3-3-3zm0 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm11 5.18V6c0-1.66-1.34-3-3-3H9.41l1.29-1.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-3 3C6.11 3.47 6 3.72 6 4c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L9.41 5H11c.55 0 1 .45 1 1v4.18A2.996 2.996 0 0013 16c1.66 0 3-1.34 3-3 0-1.3-.84-2.4-2-2.82zM13 14c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-push":["M4 6h1V5H4v1zm9 3c0-.28-.11-.53-.29-.71l-3-3C9.53 5.11 9.28 5 9 5s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L8 8.41V15c0 .55.45 1 1 1s1-.45 1-1V8.41l1.29 1.29c.18.19.43.3.71.3.55 0 1-.45 1-1zM5 3H4v1h1V3zm10-3H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h5v-2H2v-1h4v-1H3V2h11v9h-2v1h2v1h-2v2h3c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"git-repo":["M5 9H4v1h1V9zm10-9H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h3v1l2-1 2 1v-1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM4 13H2v-1h2v1zm10 0H8v-1h6v1zm0-2H3V2h11v9zM5 3H4v1h1V3zm0 4H4v1h1V7zm0-2H4v1h1V5z"],glass:["M2 0v4c0 2.97 2.16 5.43 5 5.91V14H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9V9.91c2.84-.48 5-2.94 5-5.91V0H2z"],globe:["M4.45 7.83c-.26 0-.41.21-.41.46v1.75c0 .26.16.46.41.46h.29v1.77c0 .25.24.45.49.45s.49-.2.49-.45V11.2h-.01c.26 0 .44-.14.44-.4v-.3h.14c.26 0 .43-.2.43-.46v-.59s.01-.01 0-.01l-1.58-1.6h-.69zM8.51 3.9h.22c.06 0 .12-.01.12-.07 0-.06-.05-.07-.12-.07h-.22c-.06 0-.12.01-.12.07.01.06.06.07.12.07zm-2.33-.05c.07-.07.07-.19 0-.26l-.5-.5a.187.187 0 00-.26 0c-.07.07-.07.19 0 .26l.5.5c.07.07.19.07.26 0zm3.06.89c.07 0 .14-.06.14-.12v-.31c0-.07-.07-.12-.14-.12s-.14.06-.14.12v.31c0 .07.07.12.14.12zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-.55.1-1.07.23-1.57h.11v.47c0 .2.18.37.39.37.03 0 .08-.01.11-.02l.78.77c.08.08.2.08.28 0 .08-.08.08-.2 0-.28l-.75-.78c0-.02.04-.04.04-.06v-.12c0-.16.09-.22.25-.36h.46c.09 0 .17-.01.24-.05h.02c.02-.01.03-.02.05-.03.01-.01.01-.01.02-.01l.02-.02 1.59-1.58c.18-.18.18-.46 0-.64s-.47-.15-.65.03l-.3.34h-.57v-.48c0-.01.05.05.05-.09h.64c.12 0 .22-.09.22-.21s-.1-.21-.22-.21H4.1c.18-.15.34-.31.54-.44l.01-.01c.21-.14.45-.25.68-.37.15-.07.29-.15.44-.21.17-.07.35-.11.53-.17.18-.05.35-.12.53-.16a6.05 6.05 0 013.47.35c.05.02.1.05.16.08.25.11.48.24.71.39.25.16.49.34.71.55H10.6s0-.03-.01-.03c-.04 0-.09 0-.13.03l-.51.51a.17.17 0 000 .23c.06.06.17.06.23 0l.42-.44.01-.02h.25c0 .14-.07.09-.07.12v.07c0 .22-.15.37-.36.37h-.38c-.19 0-.38.21-.38.4v.17h-.1c-.12 0-.2.06-.2.18v.25h-.23c-.17 0-.3.11-.3.28 0 .17.13.26.3.26.07 0 .14.03.19-.11l.04.01.49-.46h.17l.39.37c.03.03.08.02.12-.01.03-.03.03-.12 0-.15l-.32-.35h.23l.09.12c.18.18.48.17.66-.01l.09-.1h.4c.02 0 .08.05.08.05v.24l-.05-.01h-.36c-.11 0-.21.1-.21.21 0 .11.09.21.21.21h.41v.15c-.14.21-.24.42-.45.42h-.94v-.01l-.44-.44a.47.47 0 00-.66 0l-.42.43v.01H8.6c-.26 0-.49.21-.49.46v.92c0 .26.23.45.49.45h.9c.34.14.57.35.72.69v1.68c0 .26.17.44.42.44h.72c.26 0 .4-.18.4-.44V9l.89-.86.03-.02.02-.01h.03c.07-.08.15-.19.15-.31v-.91c0-.18-.16-.32-.31-.46H13c.01.28.21.42.46.42h.42c.08.37.12.76.12 1.15 0 3.31-2.69 6-6 6zm4.54-4.27c-.1 0-.21.08-.21.18v.57c0 .1.11.18.21.18.1 0 .21-.08.21-.18v-.57c0-.1-.11-.18-.21-.18zM8.37 3.19c0-.25-.2-.42-.46-.42h-.54c-.25 0-.42.18-.42.43 0 .03-.1.04.05.08v.47c0 .15.06.27.21.27s.21-.12.21-.27v-.14h.5c.24 0 .45-.16.45-.42z"],"globe-network":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm5.17 5h-2.44c-.21-1.11-.51-2.03-.91-2.69 1.43.46 2.61 1.43 3.35 2.69zM10 8c0 .73-.05 1.39-.12 2H6.12C6.05 9.39 6 8.73 6 8s.05-1.39.12-2h3.76c.07.61.12 1.27.12 2zM8 2c.67 0 1.36 1.1 1.73 3H6.27C6.64 3.1 7.33 2 8 2zm-1.82.31c-.4.66-.71 1.58-.91 2.69H2.83a6.025 6.025 0 013.35-2.69zM2 8c0-.7.13-1.37.35-2h2.76C5.04 6.62 5 7.28 5 8s.04 1.38.11 2H2.35C2.13 9.37 2 8.7 2 8zm.83 3h2.44c.21 1.11.51 2.03.91 2.69A6.025 6.025 0 012.83 11zM8 14c-.67 0-1.36-1.1-1.73-3h3.46c-.37 1.9-1.06 3-1.73 3zm1.82-.31c.4-.66.7-1.58.91-2.69h2.44a6.025 6.025 0 01-3.35 2.69zM13.65 10h-2.76c.07-.62.11-1.28.11-2s-.04-1.38-.11-2h2.76c.22.63.35 1.3.35 2s-.13 1.37-.35 2z"],graph:["M14 3c-1.06 0-1.92.83-1.99 1.88l-1.93.97A2.95 2.95 0 008 5c-.56 0-1.08.16-1.52.43L3.97 3.34C3.98 3.23 4 3.12 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.24 0 .47-.05.68-.13l2.51 2.09C5.08 7.29 5 7.63 5 8c0 .96.46 1.81 1.16 2.35l-.56 1.69c-.91.19-1.6.99-1.6 1.96 0 1.1.9 2 2 2s2-.9 2-2c0-.51-.2-.97-.51-1.32l.56-1.69A2.99 2.99 0 0011 8c0-.12-.02-.24-.04-.36l1.94-.97c.32.21.69.33 1.1.33 1.1 0 2-.9 2-2s-.9-2-2-2z"],"graph-remove":["M12.89 8.11l-.01.01-.38-.38-.38.38-.02-.02c-.54.55-1.27.9-2.1.9-1.66 0-3-1.34-3-3 0-.83.35-1.56.9-2.1l-.02-.02.38-.38-.38-.38.01-.01C7.35 2.57 7 1.83 7 1c0-.34.07-.65.17-.96A8.004 8.004 0 000 8c0 4.42 3.58 8 8 8 4.14 0 7.54-3.14 7.96-7.17-.31.1-.62.17-.96.17-.83 0-1.57-.35-2.11-.89zm1.02-4.61l1.79-1.79c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-1.79 1.8L10.71.3A.965.965 0 0010 0a1.003 1.003 0 00-.71 1.71l1.79 1.79-1.79 1.79a1.003 1.003 0 001.42 1.42l1.79-1.79 1.79 1.79a1.003 1.003 0 001.42-1.42l-1.8-1.79z"],"greater-than":["M2.713 5.958a1 1 0 01.574-1.916l10 3c.95.285.95 1.63 0 1.916l-10 3a1 1 0 01-.574-1.916L9.52 8 2.713 5.958z"],"greater-than-or-equal-to":["M2.713 3.958a1 1 0 01.574-1.916l10 3c.95.285.95 1.63 0 1.916l-10 3a1 1 0 01-.574-1.916L9.52 6 2.713 3.958zM3 12h10a1 1 0 010 2H3a1 1 0 010-2z"],grid:["M15 9c.55 0 1-.45 1-1s-.45-1-1-1h-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1H9V1c0-.55-.45-1-1-1S7 .45 7 1v1H4V1c0-.55-.45-1-1-1S2 .45 2 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v3H1c-.55 0-1 .45-1 1s.45 1 1 1h1v3H1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h3v1c0 .55.45 1 1 1s1-.45 1-1v-1h3v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V9h1zm-8 3H4V9h3v3zm0-5H4V4h3v3zm5 5H9V9h3v3zm0-5H9V4h3v3z"],"grid-view":["M0 1v6h7V0H1C.45 0 0 .45 0 1zm0 14c0 .55.45 1 1 1h6V9H0v6zM15 0H9v7h7V1c0-.55-.45-1-1-1zM9 16h6c.55 0 1-.45 1-1V9H9v7z"],"group-objects":["M5 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6-3H5C2.24 3 0 5.24 0 8s2.24 5 5 5h6c2.76 0 5-2.24 5-5s-2.24-5-5-5zm0 9H5c-2.21 0-4-1.79-4-4s1.79-4 4-4h6c2.21 0 4 1.79 4 4s-1.79 4-4 4zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"grouped-bar-chart":["M10 12c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1zm3 0c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1zm2 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-9-1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1zm-3 0c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1v9c0 .55.45 1 1 1z"],hand:["M15 5c0-.55-.45-1-1-1-.41 0-.76.24-.91.59v.01s0 .01-.01.01L11.57 8h-.36l.78-4.84C12 3.11 12 3.05 12 3a1 1 0 00-1.99-.16v.01L9.18 8H9V1c0-.55-.45-1-1-1S7 .45 7 1v7h-.09l-.93-5.18A1 1 0 005 2c-.55 0-1 .45-1 1 0 .05 0 .11.01.16L5.26 11h-.04L2.83 7.44C2.65 7.18 2.35 7 2 7c-.55 0-1 .45-1 1 0 .17.04.33.12.47l3 5.69h.01v.01A5.002 5.002 0 0013 11v-.59l1.93-5.05c.05-.11.07-.23.07-.36z"],"hand-down":["M14.72 7.87c-1.54-.67-2.99-2.68-3.7-3.95C10.11 1.95 9.93 0 6.14 0 4.05 0 2.71.61 1.92 2.12 1.27 3.36 1 5.21 1 7.83v.79c0 .65.6 1.18 1.35 1.18.34 0 .64-.11.88-.29.17.48.68.84 1.29.84.41 0 .78-.16 1.03-.42.23.37.67.63 1.19.63.57 0 1.05-.31 1.25-.74l.01.63v4.05c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V7.9c.58.41 1.55 1.21 2.47 1.29 1.57.14 1.82-1.07 1.25-1.32z"],"hand-left":["M12.08 4.97c-1.26-.71-3.27-2.15-3.95-3.7C7.88.7 6.67.96 6.81 2.52c.09.93.89 1.9 1.3 2.48H1.5C.67 5 0 5.67 0 6.5S.67 8 1.5 8h4.05l.63.01c-.44.2-.75.69-.75 1.25 0 .52.26.96.63 1.19-.26.25-.42.61-.42 1.03 0 .61.35 1.12.84 1.29-.18.24-.29.54-.29.88 0 .75.54 1.35 1.19 1.35h.79c2.62 0 4.47-.28 5.71-.92 1.51-.79 2.12-2.14 2.12-4.22 0-3.79-1.95-3.97-3.92-4.89z"],"hand-right":["M14.5 5H7.89c.41-.58 1.21-1.55 1.3-2.47C9.34.97 8.12.71 7.87 1.28c-.67 1.54-2.68 2.99-3.95 3.7C1.95 5.89 0 6.07 0 9.86c0 2.09.61 3.43 2.12 4.22 1.24.65 3.09.92 5.71.92h.79c.65 0 1.18-.6 1.18-1.35 0-.34-.11-.64-.29-.88.48-.17.84-.68.84-1.29 0-.41-.16-.78-.42-1.03.37-.23.63-.67.63-1.19 0-.57-.31-1.05-.74-1.25l.63-.01h4.05c.83 0 1.5-.67 1.5-1.5S15.33 5 14.5 5z"],"hand-up":["M13.65 6.19c-.34 0-.64.11-.88.29-.17-.48-.68-.84-1.29-.84-.41 0-.78.16-1.03.42-.23-.37-.67-.63-1.19-.63-.57 0-1.05.31-1.25.74L8 5.55V1.5C8 .67 7.33 0 6.5 0S5 .67 5 1.5v6.61c-.58-.41-1.55-1.21-2.48-1.3C.96 6.67.7 7.88 1.28 8.13c1.54.67 2.99 2.68 3.7 3.95C5.89 14.05 6.07 16 9.86 16c2.09 0 3.43-.61 4.22-2.12.64-1.24.92-3.09.92-5.71v-.79c0-.65-.6-1.19-1.35-1.19z"],hat:["M15 10c.495 0 .933.379.993.882L16 11v.505c0 1.461-3.524 2.45-7.707 2.493L8 14c-4.31 0-8-1-8-2.495V11c0-.561.466-1 1-1 .895 0 3 1 7 1l.381-.003C12.135 10.937 14.134 10 15 10zm-4-8c1.13 0 2.02 2.153 2.671 6.46-1.063.266-2.644.652-4.887.727l-.403.01L8 9.2c-2.664 0-4.488-.444-5.673-.74C2.98 4.153 3.87 2 5 2c2 0 1.329 2 3 2s1-2 3-2z"],header:["M13 1c-.55 0-1 .45-1 1v5H4V2c0-.55-.45-1-1-1s-1 .45-1 1v12c0 .55.45 1 1 1s1-.45 1-1V9h8v5c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"header-one":["M14.06 8c-.04.23-.12.44-.25.61-.13.17-.29.3-.48.41-.18.11-.39.18-.62.23-.23.04-.46.07-.71.07v1.03h1.74V16H15V8h-.94zM7 0c-.56 0-1 .45-1 1v4H2V1c0-.55-.45-1-1-1-.56 0-1 .45-1 1v10c0 .55.45 1 1 1 .56 0 1-.45 1-1V7h4v4c0 .55.45 1 1 1 .56 0 1-.45 1-1V1c0-.54-.45-1-1-1z"],"header-three":["M1 0C.44 0 0 .45 0 1v10c0 .54.45 1 1 1 .56 0 1-.45 1-1V7h4v4c0 .54.45 1 1 1 .56 0 1-.45 1-1V1c0-.54-.45-1-1-1-.56 0-1 .45-1 1v4H2V1c0-.54-.45-1-1-1zm13.71 11.72c.41.08.72.3.95.65.23.35.34.77.34 1.27 0 .37-.07.7-.2.97-.14.29-.32.54-.55.74-.23.2-.5.36-.8.47-.3.11-.62.16-.96.16-.41 0-.77-.06-1.08-.19-.31-.12-.56-.31-.77-.54-.21-.24-.36-.52-.47-.85-.11-.33-.16-.7-.17-1.1h1.14c-.01.47.09.86.32 1.17.23.31.57.47 1.02.47.39 0 .71-.12.97-.36s.39-.58.39-1.02c0-.3-.05-.53-.16-.71-.11-.17-.25-.31-.43-.4-.17-.09-.37-.15-.59-.17-.22-.02-.44-.03-.67-.02v-.93c.19.01.38 0 .57-.04.19-.03.36-.1.51-.19.14-.09.26-.22.35-.38.09-.16.14-.36.14-.59 0-.33-.1-.59-.31-.79-.2-.2-.47-.3-.79-.3-.21 0-.38.04-.53.13-.15.09-.27.21-.37.36-.1.15-.17.32-.22.51-.05.19-.07.38-.06.58h-1.15c.01-.38.08-.72.19-1.04.11-.32.27-.6.47-.83.19-.23.44-.42.72-.55.28-.13.6-.2.96-.2.28 0 .55.04.82.13.27.08.51.21.72.38.21.17.38.38.51.64s.19.56.19.9c0 .39-.08.73-.24 1.02-.16.29-.42.5-.76.63v.02z"],"header-two":["M13.17 13.93c-.17.15-.33.29-.46.44-.13.16-.22.32-.27.49h3.55V16H11c.01-.65.16-1.22.44-1.71s.67-.91 1.17-1.27c.24-.18.49-.36.75-.54.25-.18.49-.36.71-.57.21-.2.39-.42.53-.65.14-.24.21-.51.22-.82 0-.14-.02-.29-.05-.45-.03-.16-.09-.31-.18-.45a1.13 1.13 0 00-.37-.35c-.16-.09-.37-.14-.63-.14-.24 0-.43.05-.59.15-.16.1-.29.24-.38.42-.1.17-.17.38-.21.62-.05.24-.07.5-.08.77h-1.19c0-.43.05-.83.16-1.2s.27-.69.49-.96c.21-.25.48-.46.79-.62.31-.15.67-.23 1.07-.23.45 0 .82.08 1.11.23.3.16.55.36.73.6.19.24.32.5.39.79.08.28.12.54.12.79 0 .31-.04.6-.13.85s-.22.49-.37.7c-.15.21-.32.41-.52.59s-.4.35-.61.51l-.63.45c-.21.14-.39.28-.57.42zM0 1c0-.55.44-1 1-1 .55 0 1 .46 1 1v10c0 .55-.44 1-1 1-.55 0-1-.46-1-1V1zm6 0c0-.55.44-1 1-1 .55 0 1 .46 1 1v10c0 .55-.44 1-1 1-.55 0-1-.46-1-1V1zM2 5h4v2H2V5z"],headset:["M14.85 6.34C14.18 2.72 11.37 0 8 0S1.82 2.72 1.15 6.34C.47 6.9 0 8.1 0 9.5 0 11.43.9 13 2 13c0 1.1.9 2 2 2h2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1H4c-.55 0-1-.45-1-1 .55 0 1-.45 1-1V7c0-.45-.3-.81-.71-.94C3.97 3.7 5.81 2 8 2s4.03 1.7 4.71 4.06c-.41.13-.71.49-.71.94v5c0 .55.45 1 1 1h1c1.1 0 2-1.57 2-3.5 0-1.4-.47-2.6-1.15-3.16z"],heart:["M16 5.095c0-2.255-1.88-4.083-4.2-4.083-1.682 0-3.13.964-3.8 2.352a4.206 4.206 0 00-3.8-2.352C1.88 1.012 0 2.84 0 5.095c0 .066.007.13.01.194H.004c.001.047.01.096.014.143l.013.142c.07.8.321 1.663.824 2.573C2.073 10.354 4.232 12.018 8 15c3.767-2.982 5.926-4.647 7.144-6.854.501-.905.752-1.766.823-2.562.007-.055.012-.11.016-.164.003-.043.012-.088.013-.13h-.006c.003-.066.01-.13.01-.195z"],"heart-broken":["M7.71 8.87L6.17 6.55l.02-.01A.906.906 0 016 6c0-.07.03-.13.04-.19h-.02l.78-3.92C6.09 1.34 5.19 1 4.2 1 1.88 1 0 2.83 0 5.09c0 .07.01.13.01.19H0c0 .05.01.1.01.14 0 .05.01.1.01.14.07.8.32 1.66.82 2.57 1.07 1.94 2.88 3.47 5.86 5.84l-.68-2.74h.02C6.03 11.16 6 11.08 6 11c0-.28.11-.53.29-.71l1.42-1.42zM16 5.09C16 2.83 14.12 1 11.8 1c-1.2 0-2.27.5-3.04 1.28l-.7 3.51 1.77 2.66-.01.01c.1.15.18.33.18.54 0 .28-.11.53-.29.71l-1.6 1.6.75 3.01c3.23-2.56 5.16-4.15 6.28-6.18.5-.91.75-1.77.82-2.56.01-.05.01-.11.02-.16 0-.04.01-.09.01-.13h-.01c.01-.07.02-.14.02-.2z"],"heat-grid":["M0 10h5V7H0v3zm1-2h3v1H1V8zm14-5h-4v3h5V4c0-.55-.45-1-1-1zm0 2h-3V4h3v1zM0 4v2h5V3H1c-.55 0-1 .45-1 1zm0 9c0 .55.45 1 1 1h4v-3H0v2zm6-7h4V3H6v3zm0 8h4v-3H6v3zm1-2h2v1H7v-1zm4 2h4c.55 0 1-.45 1-1v-2h-5v3zm0-4h5V7h-5v3zm-5 0h4V7H6v3z"],heatmap:["M2 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm11-7c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm3 4.5A2.5 2.5 0 0013.5 6c-.98 0-1.82.57-2.23 1.39-.6-.78-1.51-1.3-2.56-1.36.18-.49.29-.99.29-1.53C9 2.01 6.99 0 4.5 0S0 2.01 0 4.5 2.01 9 4.5 9c.19 0 .37-.03.56-.06-.03.19-.06.37-.06.56C5 11.43 6.57 13 8.5 13c1.63 0 2.98-1.11 3.37-2.62.44.38 1 .62 1.63.62A2.5 2.5 0 0016 8.5zM14.5 13c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],helicopter:["M.5 2a.5.5 0 01.5.5V4h7V3H2.5a.5.5 0 010-1h13a.5.5 0 010 1H10v1h1c2.26 0 4 1.79 4 4 0 1.87-1.247 3.44-3 3.878V13h.382l1.894-.947a.5.5 0 11.448.894L12.618 14H4.5a.5.5 0 010-1H7v-2.306C5.749 9.736 5 8.368 5 7L1 6v1.5a.5.5 0 01-1 0v-5A.5.5 0 01.5 2zM8 11.316V13h3v-1a6.73 6.73 0 01-3-.684zM11 5v3h3a3 3 0 00-3-3z"],help:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13H7v-2h2v2zm1.93-6.52c-.14.32-.35.64-.62.97L9.25 8.83c-.12.15-.24.29-.28.42-.04.13-.09.3-.09.52V10H7.12V8.88s.05-.51.21-.71L8.4 6.73c.22-.26.35-.49.44-.68.09-.19.12-.38.12-.58 0-.3-.1-.55-.28-.75-.18-.19-.44-.28-.76-.28-.33 0-.59.1-.78.29-.19.19-.33.46-.4.81-.03.11-.1.15-.2.14l-1.7-.25c-.12-.01-.16-.08-.14-.19.12-.82.46-1.47 1.03-1.94.57-.48 1.32-.72 2.25-.72.47 0 .9.07 1.29.22s.72.34 1 .59c.28.25.49.55.65.89.15.35.22.72.22 1.12s-.07.75-.21 1.08z"],"helper-management":["M13 5h-2v2h2V5zm0 6h-2v2h2v-2zm0-3h-2v2h2V8zm2-8H1C.4 0 0 .4 0 1v14c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1zm-1 14H2V2h12v12zm-7-3H5v2h2v-2zm3 0H8v2h2v-2z"],"high-priority":["M9 14v2H7v-2h2zm1-14L9 12H7L6 0h4z"],highlight:["M9.12 11.07l2-2.02.71.71 4-4.04L10.17 0l-4 4.04.71.71-2 2.02 4.24 4.3zM2 12.97h4c.28 0 .53-.11.71-.3l1-1.01-3.42-3.45-3 3.03c-.18.18-.29.44-.29.72 0 .55.45 1.01 1 1.01zm13 1.01H1c-.55 0-1 .45-1 1.01S.45 16 1 16h14c.55 0 1-.45 1-1.01s-.45-1.01-1-1.01z"],history:["M8 3c-.55 0-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L9 7.59V4c0-.55-.45-1-1-1zm0-3a7.95 7.95 0 00-6 2.74V1c0-.55-.45-1-1-1S0 .45 0 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.54C4.64 2.78 6.23 2 8 2c3.31 0 6 2.69 6 6 0 2.61-1.67 4.81-4 5.63v-.01c-.63.23-1.29.38-2 .38-3.31 0-6-2.69-6-6 0-.55-.45-1-1-1s-1 .45-1 1c0 4.42 3.58 8 8 8 .34 0 .67-.03 1-.07.02 0 .04-.01.06-.01C12.98 15.4 16 12.06 16 8c0-4.42-3.58-8-8-8z"],home:["M2 10v5c0 .55.45 1 1 1h3v-5h4v5h3c.55 0 1-.45 1-1v-5L8 4l-6 6zm13.71-2.71L14 5.59V2c0-.55-.45-1-1-1s-1 .45-1 1v1.59L8.71.29C8.53.11 8.28 0 8 0s-.53.11-.71.29l-7 7a1.003 1.003 0 001.42 1.42L8 2.41l6.29 6.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"horizontal-bar-chart":["M4 5h7c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zM1 1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1zm14 6H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-6 5H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1z"],"horizontal-bar-chart-asc":["M1 3h5c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h7c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 11h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"horizontal-bar-chart-desc":["M15 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM8 9H1c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm-2 4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm5-8H1c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"horizontal-distribution":["M2 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm13 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-5 2H7c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],hurricane:["M3.5 12c-.86 0-2.5-.5-3.5-1 1 3.5 4.506 4 7 4a7 7 0 007-7l-.006-.004a5.974 5.974 0 00-1.29-3.988c.896.066 2.37.53 3.296.992-1-3.5-4.506-4-7-4a6.998 6.998 0 00-6.14 3.635 5.972 5.972 0 00-.859 3.226L2 8l.006.005a5.98 5.98 0 001.771 3.99A7.469 7.469 0 013.5 12zM8 6a2 2 0 100 4 2 2 0 000-4z","M0 0h16v16H0z"],"id-number":["M2 5v7h12V5H2zm0-2h12c1.1 0 2 .9 2 2v7c0 1.1-.9 2-2 2H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2z","M7.9 10.48c-.14-.33-.84-.55-1.3-.75-.46-.2-.4-.33-.42-.5v-.07c.16-.14.29-.33.37-.56 0 0 0-.01.01-.02.02-.05.03-.1.05-.15.1-.01.16-.13.19-.23.03-.04.07-.15.06-.27-.02-.16-.08-.24-.15-.26v-.03c0-.2-.02-.48-.05-.67-.01-.05-.02-.1-.03-.16-.07-.23-.21-.44-.4-.58-.2-.15-.48-.23-.73-.23s-.53.08-.72.23c-.19.14-.33.35-.4.58-.02.05-.03.1-.03.16-.05.18-.06.47-.06.67v.03c-.07.03-.14.1-.15.26-.02.12.03.22.06.27.02.1.09.22.2.24.01.05.03.1.05.15v.01c.08.23.22.42.38.56v.07c-.02.17.03.29-.43.5-.46.2-1.16.42-1.3.75s-.09.52-.09.52H8c-.01 0 .05-.19-.1-.52zM10 6h2c.55 0 1 .45 1 1s-.45 1-1 1h-2c-.55 0-1-.45-1-1s.45-1 1-1zM10 9h2c.55 0 1 .45 1 1s-.45 1-1 1h-2c-.55 0-1-.45-1-1s.45-1 1-1z"],"image-rotate-left":["M13 2h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C8.11 2.47 8 2.72 8 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H13c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3zm-5.5 9c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 6.33L7 12l-1 1-2-3-2 2.67V9h7v4.33z"],"image-rotate-right":["M5.71 5.71l2-2C7.89 3.53 8 3.28 8 3c0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H3C1.34 2 0 3.34 0 5v3c0 .55.45 1 1 1s1-.45 1-1V5c0-.55.45-1 1-1h1.59l-.3.29a1.003 1.003 0 001.42 1.42zM12.5 11c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM15 7H6c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 6.33L12 12l-1 1-2-3-2 2.67V9h7v4.33z"],import:["M7.29 11.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L9 8.59V1c0-.55-.45-1-1-1S7 .45 7 1v7.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l4 4zM15 11c-.55 0-1 .45-1 1v2H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],inbox:["M13.91 2.6c-.16-.36-.51-.61-.92-.61h-10c-.41 0-.77.25-.92.61L-.01 7.45v5.54c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7.45L13.91 2.6zm-1.92 5.39c-.55 0-1 .45-1 1v1h-6v-1c0-.55-.45-1-1-1H1.94l1.71-4h8.68l1.71 4h-2.05z"],"inbox-filtered":["M6.432 2c.094.14.202.273.324.394L8.42 4H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6.557c.693 0 1.363-.262 1.837-.736l.103-.102.85-1.14a2.564 2.564 0 00.623-1.682V5.058L16 7.46V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h3.432zm9.048-2c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V3.71L8.17.98A.566.566 0 018 .57c0-.31.26-.57.57-.57h6.91z"],"inbox-geo":["M6.341 2A5.99 5.99 0 006 4H3.66L1.95 8H4c.55 0 1 .45 1 1v1h7a5.978 5.978 0 004-1.528V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h3.341zm3.679 2.145c0-.125.075-.23.205-.225h.345l.79.8c.005 0 0 .005 0 .005v.295c0 .13-.085.23-.215.23h-.07v.15c0 .13-.09.2-.215.2v.535c0 .125-.12.225-.245.225s-.245-.1-.245-.225V5.25h-.145c-.125 0-.205-.1-.205-.23v-.875zm2.235-2.195c-.03 0-.055-.005-.06-.035 0-.03.03-.035.06-.035h.11c.035 0 .06.005.06.035 0 .03-.03.035-.06.035h-.11zm-1.165-.025a.094.094 0 01-.13 0l-.25-.25a.094.094 0 010-.13.094.094 0 01.13 0l.25.25a.094.094 0 010 .13zm1.53.445c-.035 0-.07-.025-.07-.06v-.155c0-.03.035-.06.07-.06s.07.025.07.06v.155c0 .03-.035.06-.07.06zM12 0c2.21 0 4 1.79 4 4s-1.79 4-4 4-4-1.79-4-4 1.79-4 4-4zm0 7c1.655 0 3-1.345 3-3 0-.195-.02-.39-.06-.575h-.21c-.125 0-.225-.07-.23-.21h-.215c.075.07.155.14.155.23V3.9c0 .06-.04.115-.075.155h-.015l-.01.005-.015.01-.445.43v.815c0 .13-.07.22-.2.22h-.36c-.125 0-.21-.09-.21-.22v-.84a.627.627 0 00-.36-.345h-.45c-.13 0-.245-.095-.245-.225v-.46c0-.125.115-.23.245-.23l.13-.005.21-.215c.09-.09.24-.09.33 0l.22.225h.47c.105 0 .155-.105.225-.21v-.075h-.205a.106.106 0 01-.105-.105.11.11 0 01.105-.105h.18l.025.005v-.12s-.03-.025-.04-.025h-.2l-.045.05a.235.235 0 01-.33.005l-.045-.06h-.115l.16.175c.015.015.015.06 0 .075-.02.015-.045.02-.06.005l-.195-.185h-.085l-.245.23-.02-.005c-.025.07-.06.055-.095.055-.085 0-.15-.045-.15-.13s.065-.14.15-.14h.115v-.125c0-.06.04-.09.1-.09h.05V2.36c0-.095.095-.2.19-.2h.19c.105 0 .18-.075.18-.185V1.94c0-.015.035.01.035-.06h-.125l-.005.01-.21.22a.085.085 0 01-.115 0 .085.085 0 010-.115l.255-.255c.02-.015.045-.015.065-.015.005 0 .005.015.005.015h.64a2.327 2.327 0 00-.355-.275 2.452 2.452 0 00-.355-.195c-.03-.015-.055-.03-.08-.04a3.025 3.025 0 00-1.735-.175c-.09.02-.175.055-.265.08-.09.03-.18.05-.265.085-.075.03-.145.07-.22.105-.115.06-.235.115-.34.185l-.005.005c-.1.065-.18.145-.27.22h.455c.06 0 .11.045.11.105s-.05.105-.11.105h-.32c0 .07-.025.04-.025.045v.24h.285l.15-.17c.09-.09.235-.105.325-.015.09.09.09.23 0 .32l-.795.79-.01.01c-.005 0-.005 0-.01.005l-.025.015h-.01a.235.235 0 01-.12.025h-.23c-.08.07-.125.1-.125.18v.06c0 .01-.02.02-.02.03l.375.39c.04.04.04.1 0 .14-.04.04-.1.04-.14 0l-.39-.385a.213.213 0 01-.055.01c-.105 0-.195-.085-.195-.185v-.235h-.055A3.1 3.1 0 009 4c0 1.655 1.345 3 3 3zm2.27-2.135c.05 0 .105.04.105.09v.285c0 .05-.055.09-.105.09-.05 0-.105-.04-.105-.09v-.285c0-.05.055-.09.105-.09zm-2.085-3.27c0 .13-.105.21-.225.21h-.25v.07c0 .075-.03.135-.105.135s-.105-.06-.105-.135V1.64c-.075-.02-.025-.025-.025-.04 0-.125.085-.215.21-.215h.27c.13 0 .23.085.23.21z"],"inbox-search":["M5.639 2a5.391 5.391 0 00-.144 2H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6V9c0-.088.012-.174.033-.255.12-.007.238-.019.39-.038.154-.008.252-.03.442-.077a5.34 5.34 0 00.24-.05h.05l.122-.04 1.266 1.271c.425.47 1.116.769 1.847.769.21 0 .414-.025.61-.071V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h2.639zM15.82 7.53c.1.12.17.27.18.44 0 .34-.27.61-.61.61a.57.57 0 01-.43-.18l-2.24-2.25c-.13.08-.26.16-.4.23-.02.01-.05.02-.07.03-.14.06-.27.12-.42.17h-.01c-.14.05-.29.08-.44.11-.04.01-.08.02-.11.02-.15.02-.3.04-.46.04-1.85 0-3.35-1.51-3.35-3.37S8.96.01 10.81 0c1.85 0 3.35 1.51 3.35 3.37 0 .16-.02.31-.04.47-.01.04-.01.07-.02.11-.02.15-.05.29-.1.44v.01c-.05.15-.11.28-.17.42-.01.02-.02.05-.03.07-.07.14-.14.27-.23.4l2.25 2.24zm-5.01-1.94c1.22 0 2.21-.99 2.21-2.22 0-1.23-.99-2.22-2.21-2.22S8.6 2.14 8.6 3.37c0 1.22.99 2.22 2.21 2.22z"],"inbox-update":["M8.1 2a5.023 5.023 0 000 2H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6V9c0-.55.45-1 1-1h2.05c.708 0 1.352-.241 1.905-.645L16 7.46V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h5.1zM13 6a3 3 0 110-6 3 3 0 010 6z"],"info-sign":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM7 3h2v2H7V3zm3 10H6v-1h1V7H6V6h3v6h1v1z"],inheritance:["M5 8c0 1.66 1.34 3 3 3h4.59L11.3 9.71A.965.965 0 0111 9a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42l1.3-1.29H8c-2.76 0-5-2.24-5-5H1a1 1 0 01-1-1V1a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5zM2 2v4h4V2H2z"],"inherited-group":["M1 7c.51 0 .935.388.993.884L2 8v3c0 .51.388.935.884.993L3 12h1.59l-.3-.29a1.003 1.003 0 011.324-1.504l.096.084 2 2c.18.18.29.43.29.71 0 .233-.076.446-.206.614l-.084.096-2 2A1.003 1.003 0 014 15c0-.24.08-.458.224-.629l.076-.081.29-.29H3a2.996 2.996 0 01-2.995-2.823L0 11V8c0-.55.45-1 1-1zm5.388-7c.629 0 1.338.21 1.838.6.48.38.85.91 1.019 1.52.04.13.07.27.09.4.09.48.14 1.22.14 1.73v.07c.18.08.34.27.37.67.03.32-.09.59-.16.71-.06.28-.21.58-.48.63-.03.13-.07.26-.12.39 0 .01-.01.04-.01.04-.22.58-.55 1.08-.949 1.45v.18c.04.45-.12.77 1.059 1.3 1.179.53 2.947 1.09 3.307 1.95.37.86.22 1.36.22 1.36H9c0-.539-.21-1.045-.583-1.417l-2-2A1.997 1.997 0 005 9c-.149 0-.296-.015-.442-.045.099-.19.082-.37.101-.575 0-.05.01-.11.01-.17-.41-.35-.75-.86-.969-1.45v-.01s-.01-.01-.01-.02c-.04-.12-.09-.26-.12-.39-.28-.05-.44-.36-.5-.64-.06-.12-.19-.39-.16-.71.04-.41.21-.6.39-.68v-.06c0-.51.05-1.26.14-1.74.02-.13.05-.27.09-.4.17-.6.54-1.13 1.02-1.51C5.048.21 5.757 0 6.387 0zm4.625 2.04c.49 0 1.05.16 1.439.46.38.29.67.7.8 1.17.03.1.05.21.07.31.07.37.11.94.11 1.33v.05c.139.06.269.21.289.51.02.25-.07.45-.13.54-.05.21-.16.44-.38.48a1.711 1.711 0 01-.1.33c-.17.44-.43.83-.749 1.11v.14c.03.35-.09.59.83 1 .929.41 2.317.84 2.597 1.5.29.66.17 1.04.17 1.04H13.66v.01c-.05-.24-.14-.5-.25-.76-.36-.86-1.119-1.33-2.687-2-.14-.06-.59-.25-.6-.25-.21-.09-.36-.15-.5-.22.02-.1.02-.2.03-.31 0-.04.01-.08.01-.13-.07-.06-.13-.12-.19-.19.22-.32.4-.67.54-1.05.02-.06.02-.06.03-.1.29-.23.48-.57.59-.96.16-.33.25-.73.21-1.16-.03-.4-.16-.76-.37-1.03-.02-.53-.07-1.13-.15-1.54-.01-.06-.02-.12-.03-.19.23-.06.48-.09.72-.09z"],"inner-join":["M6.6 3.3C5.3 4.4 4.5 6.1 4.5 8s.8 3.6 2.1 4.7c-.5.2-1 .3-1.6.3-2.8 0-5-2.2-5-5s2.2-5 5-5c.6 0 1.1.1 1.6.3zm-1.96 8.68C3.92 10.83 3.5 9.46 3.5 8s.42-2.83 1.14-3.98C2.6 4.2 1 5.91 1 8s1.6 3.8 3.64 3.98zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3zm.35 1.02c.73 1.15 1.14 2.52 1.14 3.98s-.42 2.83-1.14 3.98c2.04-.18 3.64-1.9 3.64-3.98s-1.6-3.8-3.64-3.98z"],insert:["M5 9h2v2c0 .6.4 1 1 1s1-.4 1-1V9h2c.6 0 1-.4 1-1s-.4-1-1-1H9V5c0-.6-.4-1-1-1s-1 .4-1 1v2H5c-.6 0-1 .4-1 1s.4 1 1 1zm10-9H1C.4 0 0 .4 0 1v14c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1zm-1 14H2V2h12v12z"],intersection:["M10 3c-.92 0-1.76.26-2.5.69C6.76 3.26 5.92 3 5 3 2.24 3 0 5.24 0 8s2.24 5 5 5c.92 0 1.76-.26 2.5-.69.74.43 1.58.69 2.5.69 2.76 0 5-2.24 5-5s-2.24-5-5-5zm-4.1 7.85c-.29.09-.59.15-.9.15-1.66 0-3-1.34-3-3s1.34-3 3-3c.31 0 .61.06.9.15C5.33 5.96 5 6.94 5 8s.33 2.04.9 2.85zM10 11c-.31 0-.61-.06-.9-.15.57-.81.9-1.79.9-2.85s-.33-2.04-.9-2.85c.29-.09.59-.15.9-.15 1.66 0 3 1.34 3 3s-1.34 3-3 3z"],"ip-address":["M5 2.66C5 4.14 8 8 8 8s3-3.86 3-5.34C10.99 1.2 9.66 0 8 0S5 1.2 5 2.66zM7 3c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1zM10.5 10H8v5h1v-4h1v1H9v1h2v-3h-.5zM2 9h12c.55 0 1 .45 1 1v5c0 .55-.45 1-1 1H2c-.55 0-1-.45-1-1v-5c0-.55.45-1 1-1zm4 1v5h1v-5H6z"],issue:["M8 16A8 8 0 118 0a8 8 0 010 16zm0-2A6 6 0 108 2a6 6 0 000 12zm1-2H7v-2h2v2zm0-3H7V4h2v5z"],"issue-closed":["M9.296.104a2.99 2.99 0 00-1.003.664 2.987 2.987 0 00-.75 1.25 6 6 0 106.28 4.527c.043-.039.085-.079.127-.12l1.456-1.456A8 8 0 119.296.105zm2.532 5.2a.997.997 0 01-.707-.294L9.707 3.596a1 1 0 011.414-1.414l.707.707 1.768-1.768a1 1 0 111.414 1.415L12.536 5.01a.997.997 0 01-.708.293zM9 12H7v-2h2v2zm0-3H7V4h2v5z"],"issue-new":["M10.568.421c-.01.04-.018.08-.026.121-.837.156-1.53.73-1.85 1.497a6 6 0 105.27 5.273 2.51 2.51 0 001.496-1.854c.04-.008.081-.016.121-.026A8 8 0 1110.568.421zM9 12H7v-2h2v2zm0-3H7V4h2v5zm1-6c0-.55.45-1 1-1h1V1c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1h-1v1.005c0 .55-.45 1-1 1s-1-.45-1-1V4h-1c-.55 0-1-.45-1-1z"],italic:["M9.8 4H11c.5 0 1-.4 1-1s-.4-1-1-1H7c-.5 0-1 .4-1 1s.4 1 1 1h.8l-1.6 8H5c-.5 0-1 .4-1 1s.4 1 1 1h4c.5 0 1-.4 1-1s-.4-1-1-1h-.8l1.6-8z"],"join-table":["M15 5h-3V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h3v3c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-5-1v2H6V4h4zm0 6H6V7h4v3zM2 4h3v2H2V4zm0 5V7h3v2H2zm4 4v-2h4v2H6zm8 0h-3v-2h3v2zm0-3h-3V8h3v2z"],key:["M11 0C8.24 0 6 2.24 6 5c0 1.02.31 1.96.83 2.75L.29 14.29a1.003 1.003 0 001.42 1.42L3 14.41l1.29 1.29c.18.19.43.3.71.3s.53-.11.71-.29l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71L6.41 11l1.83-1.83c.8.52 1.74.83 2.76.83 2.76 0 5-2.24 5-5s-2.24-5-5-5zm0 8c-.23 0-.45-.03-.66-.08-.01 0-.02-.01-.03-.01-.21-.05-.41-.12-.6-.21a3.014 3.014 0 01-1.62-2c0-.01-.01-.02-.01-.03C8.03 5.45 8 5.23 8 5c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3z"],"key-backspace":["M15 2H6c-.28 0-.53.11-.71.29l-5 5C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l5 5c.18.18.43.29.71.29h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-2.29 7.29a1.003 1.003 0 01-1.42 1.42L10 9.41 8.71 10.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L8.59 8l-1.3-1.29a1.003 1.003 0 011.42-1.42L10 6.59l1.29-1.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L11.41 8l1.3 1.29z"],"key-command":["M12 9h-1V7h1c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3v1H7V4c0-1.66-1.34-3-3-3S1 2.34 1 4s1.34 3 3 3h1v2H4c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3v-1h2v1c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3zm0-6c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM4 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0-8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm5 4H7V7h2v2zm3 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"key-control":["M12.71 5.29l-4-4C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"key-delete":["M15.71 7.29l-5-5A.997.997 0 0010 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h9c.28 0 .53-.11.71-.29l5-5c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zm-7 2a1.003 1.003 0 01-1.42 1.42L6 9.41 4.71 10.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L4.59 8l-1.3-1.29a1.003 1.003 0 011.42-1.42L6 6.59 7.29 5.3c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L7.41 8l1.3 1.29z"],"key-enter":["M14 2c-.55 0-1 .45-1 1v3c0 1.66-1.34 3-3 3H4.41L5.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L4.41 11H10c2.76 0 5-2.24 5-5V3c0-.55-.45-1-1-1z"],"key-escape":["M2 7c.55 0 1-.45 1-1V4.41L7.29 8.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 3H6c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm7-5.9v2A5 5 0 113.1 9h-2c.49 3.39 3.38 6 6.9 6 3.87 0 7-3.13 7-7 0-3.52-2.61-6.41-6-6.9z"],"key-option":["M11 4h4c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1s.45 1 1 1zm4 8h-3.43L5.86 2.49h-.02A.975.975 0 005 2H1c-.55 0-1 .45-1 1s.45 1 1 1h3.43l5.71 9.51.01-.01c.18.3.49.5.85.5h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"key-shift":["M13.71 7.29l-5-5C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-5 5A1.003 1.003 0 003 9h2v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V9h2a1.003 1.003 0 00.71-1.71z"],"key-tab":["M15 10H4.41L5.7 8.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L2 9.59V8c0-.55-.45-1-1-1s-1 .45-1 1v6c0 .55.45 1 1 1s1-.45 1-1v-1.59l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 12H15c.55 0 1-.45 1-1s-.45-1-1-1zm0-9c-.55 0-1 .45-1 1v1.59L11.71 1.3A.965.965 0 0011 1a1.003 1.003 0 00-.71 1.71L11.59 4H1c-.55 0-1 .45-1 1s.45 1 1 1h10.59L10.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L14 6.41V8c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"known-vehicle":["M15 3a.997.997 0 00-.707.293L12 5.586l-1.293-1.293a1 1 0 10-1.414 1.414l2 2a.997.997 0 001.414 0l3-3A1 1 0 0015 3zm-.879 6.121l-.007-.007c-.313.309-.69.552-1.114.702V10h-.998H12h-1v-.184c-.424-.15-.8-.395-1.112-.704l-.01.01-2-2 .012-.012A2.978 2.978 0 017.184 6H3c-.176 0-.06-.824 0-1l.73-1.63C3.79 3.192 3.823 3 4 3H7.78C8.328 2.39 9.115 2 10 2c.768 0 1.461.293 1.987.77l.844-.844c-.238-.244-.524-.442-.794-.524C12.037 1.402 10.72 1 8 1c-2.72 0-4.037.402-4.037.402-.508.155-1.078.711-1.268 1.237l-.763 2.117H.88c-.484 0-.88.423-.88.939s.396.939.88.939h.375L1 7c-.034.685 0 1.436 0 2v5c0 .657.384 1 1 1s1-.343 1-1v-1h10v1c0 .657.384 1 1 1s1-.343 1-1V9l-.003-.754-.876.875zM5.001 10H3V8h2v2z"],"lab-test":["M11 1a1 1 0 010 2v3l3 7v1.25a.75.75 0 01-.75.75H2.75a.75.75 0 01-.75-.75V13l3-7V3a1 1 0 110-2h6zM9 3H7v3l-1.714 4h5.428L9 6V3z"],label:["M11 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7l-5-5zm3 10H2V4h8v2H3v1h7v1h4v4zm-3-5V4l3 3h-3zm-8 3h10V9H3v1z"],layer:["M16 8c0-.37-.21-.68-.51-.85l.01-.01-7-4-.01.01C8.34 3.06 8.18 3 8 3s-.34.06-.49.15l-.01-.02-7 4 .01.01C.21 7.32 0 7.63 0 8s.21.68.51.85l-.01.01 7 4 .01-.01c.15.09.31.15.49.15s.34-.06.49-.15l.01.01 7-4-.01-.01c.3-.17.51-.48.51-.85z"],"layer-outline":["M7.504 3.132l-7 4a1 1 0 000 1.736l7 4a1 1 0 00.992 0l7-4a1 1 0 000-1.736l-7-4a1 1 0 00-.992 0zM8 5.152L12.983 8 8 10.847 3.016 8 8 5.152z"],layers:["M.55 4.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5a.998.998 0 00-.06-1.81L8.4.08a1.006 1.006 0 00-.79 0l-6.99 3a.992.992 0 00-.07 1.81zM15 10c-.16 0-.31.04-.45.11L8 13.38 1.45 10.1c-.14-.06-.29-.1-.45-.1-.55 0-1 .45-1 1 0 .39.23.73.55.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5c.32-.16.55-.5.55-.89 0-.55-.45-1-1-1zm0-3.5c-.16 0-.31.04-.45.11L8 9.88 1.45 6.61A.997.997 0 001 6.5c-.55 0-1 .45-1 1 0 .39.23.73.55.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5c.32-.16.55-.5.55-.89 0-.55-.45-1-1-1z"],layout:["M14 4c-1.1 0-2 .9-2 2 0 .47.17.9.44 1.24l-.68.91A1.996 1.996 0 009.07 9.5H7.93C7.71 8.64 6.93 8 6 8c-.47 0-.9.17-1.24.44l-.91-.68c.1-.23.15-.49.15-.76 0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .37.11.71.28 1.01L3.01 5.28C2.71 5.11 2.37 5 2 5 .9 5 0 5.9 0 7s.9 2 2 2c.47 0 .9-.17 1.24-.44l.91.68c-.1.23-.15.49-.15.76 0 .37.11.71.28 1.01l-1.27 1.27C2.71 12.11 2.37 12 2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.37-.11-.71-.28-1.01l1.27-1.27c.3.17.64.28 1.01.28.93 0 1.71-.64 1.93-1.5h1.14c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2 0-.47-.17-.9-.44-1.24l.68-.91c.23.1.49.15.76.15 1.1 0 2-.9 2-2s-.9-2-2-2z"],"layout-auto":["M14 9.5c-.56 0-1.06.23-1.42.59L8.99 8l3.59-2.09A2.002 2.002 0 0016 4.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .19.03.37.08.54L8.5 7.13v-3.2c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v3.2L3.92 5.04c.05-.17.08-.35.08-.54 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.56 0 1.06-.23 1.42-.59L7.01 8l-3.59 2.09A2.002 2.002 0 000 11.5c0 1.1.9 2 2 2s2-.9 2-2c0-.19-.03-.37-.08-.54L7.5 8.87v3.2c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-3.2l3.58 2.09c-.05.17-.08.35-.08.54 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-balloon":["M14 11c-.2 0-.38.04-.56.09L12.42 9.4c.36-.36.58-.85.58-1.4 0-.55-.22-1.04-.58-1.4l1.01-1.69c.19.05.37.09.57.09 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .55.22 1.04.58 1.4l-1.01 1.69C11.38 6.04 11.2 6 11 6c-.93 0-1.71.64-1.93 1.5H6.93C6.71 6.64 5.93 6 5 6c-.2 0-.38.04-.56.09L3.42 4.4C3.78 4.04 4 3.55 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.2 0 .38-.04.56-.09L3.58 6.6C3.22 6.96 3 7.45 3 8c0 .55.22 1.04.58 1.4l-1.01 1.69C2.38 11.04 2.2 11 2 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.55-.22-1.04-.58-1.4l1.01-1.69c.19.05.37.09.57.09.93 0 1.71-.64 1.93-1.5h2.14c.22.86 1 1.5 1.93 1.5.2 0 .38-.04.56-.09l1.01 1.69c-.35.36-.57.85-.57 1.4 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-circle":["M14.16 6.02c-.12-.36-.26-.7-.43-1.03.17-.29.27-.63.27-.99 0-1.1-.9-2-2-2-.36 0-.7.1-.99.27-.33-.17-.67-.31-1.03-.43A1.987 1.987 0 008 0C6.95 0 6.1.81 6.02 1.84c-.36.12-.7.26-1.03.43C4.7 2.1 4.36 2 4 2c-1.1 0-2 .9-2 2 0 .36.1.7.27.99-.17.33-.31.67-.43 1.03C.81 6.1 0 6.95 0 8c0 1.05.81 1.9 1.84 1.98.12.36.26.7.43 1.03-.17.29-.27.63-.27.99 0 1.1.9 2 2 2 .36 0 .7-.1.99-.27.33.17.67.32 1.03.43C6.1 15.19 6.95 16 8 16c1.05 0 1.9-.81 1.98-1.84.36-.12.7-.26 1.03-.43.29.17.63.27.99.27 1.1 0 2-.9 2-2 0-.36-.1-.7-.27-.99.17-.33.31-.67.43-1.03C15.19 9.9 16 9.05 16 8c0-1.05-.81-1.9-1.84-1.98zm-.99 3.79c-.05.16-.11.31-.17.46-.3-.17-.64-.27-1-.27-1.1 0-2 .9-2 2 0 .36.1.7.27 1-.15.07-.3.12-.46.17C9.5 12.48 8.81 12 8 12s-1.5.48-1.81 1.17c-.16-.06-.32-.11-.46-.17.17-.3.27-.64.27-1 0-1.1-.9-2-2-2-.36 0-.7.1-1 .27-.07-.15-.12-.3-.17-.46C3.52 9.5 4 8.81 4 8s-.48-1.5-1.17-1.81c.06-.16.11-.32.17-.46.3.17.64.27 1 .27 1.1 0 2-.9 2-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.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2-.93 0-1.71.64-1.93 1.5H9.93c-.18-.7-.73-1.25-1.43-1.43V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v2.14c-.7.18-1.25.73-1.43 1.43H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8c0 .93.64 1.71 1.5 1.93v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93V9.93c.7-.18 1.25-.73 1.43-1.43h2.14c.18.7.73 1.25 1.43 1.43v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93V9.93c.7-.18 1.25-.73 1.43-1.43h2.14c.18.7.73 1.25 1.43 1.43v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93z"],"layout-linear":["M14 6c-.93 0-1.71.64-1.93 1.5H9.93C9.71 6.64 8.93 6 8 6s-1.71.64-1.93 1.5H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.93 0 1.71-.64 1.93-1.5h2.13C6.29 9.36 7.07 10 8 10s1.71-.64 1.93-1.5h2.13c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2C16 6.9 15.1 6 14 6z"],"layout-skew-grid":["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12-2c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6-3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM8 3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"layout-sorted-clusters":["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM8 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],learning:["M8.441 1.104a.985.985 0 00-.882 0L.365 5c-.487.253-.487.747 0 1L7.56 9.896a.985.985 0 00.882 0L15.635 6c.487-.253.487-.747 0-1L8.44 1.104z","M14 5.5l.016 4.514c.002.548.447.99.994.99a.99.99 0 00.99-.99V5.5h-2zM3.371 9.047l4.387 2.432a.5.5 0 00.485 0l4.39-2.432a.25.25 0 01.371.218v2.955a.25.25 0 01-.134.222l-4.635 2.436a.5.5 0 01-.466 0l-4.635-2.436A.25.25 0 013 12.22V9.265a.25.25 0 01.371-.218z"],"left-join":["M6.6 3.3C6.1 3.1 5.6 3 5 3 2.2 3 0 5.2 0 8s2.2 5 5 5c.6 0 1.1-.1 1.6-.3C5.3 11.6 4.5 9.9 4.5 8s.8-3.6 2.1-4.7zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3zm.35 1.02c.73 1.15 1.14 2.52 1.14 3.98s-.42 2.83-1.14 3.98c2.04-.18 3.64-1.9 3.64-3.98s-1.6-3.8-3.64-3.98z"],"less-than":["M13.287 5.958a1 1 0 00-.574-1.916l-10 3c-.95.285-.95 1.631 0 1.916l10 3a1 1 0 00.574-1.916L6.48 8l6.807-2.042z"],"less-than-or-equal-to":["M13.287 3.958a1 1 0 00-.575-1.916l-10 3c-.95.285-.95 1.63 0 1.916l10 3a1 1 0 00.575-1.916L6.48 6l6.807-2.042zM13 12H3a1 1 0 000 2h10a1 1 0 000-2z"],lifesaver:["M9.405 11.746C8.968 11.91 8.495 12 8 12c-.494 0-.968-.09-1.405-.254l-.702 1.873C6.548 13.865 7.258 14 8 14c.742 0 1.452-.135 2.107-.38l-.702-1.874zm2.341-2.341l1.873.702C13.865 9.452 14 8.742 14 8c0-.742-.135-1.452-.38-2.107l-1.874.702c.164.437.254.91.254 1.405 0 .494-.09.968-.254 1.405zM9.405 4.254l.702-1.873A5.987 5.987 0 008 2c-.742 0-1.452.135-2.107.38l.702 1.874C7.032 4.09 7.505 4 8 4c.494 0 .968.09 1.405.254zM4.254 6.595L2.38 5.893A5.987 5.987 0 002 8c0 .742.135 1.452.38 2.107l1.874-.702A3.991 3.991 0 014 8c0-.494.09-.968.254-1.405zM8 16A8 8 0 118 0a8 8 0 010 16zm0-6a2 2 0 100-4 2 2 0 000 4z"],lightbulb:["M9.01 14h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1s-.44-1-1-1zm1-3h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.44-1-1-1zm-2-11C5.26 0 3.03 1.95 3.03 4.35c0 2.37 1.63 2.64 1.94 5.22 0 .24.22.44.5.44h5.09c.28 0 .5-.19.5-.44C11.37 6.99 13 6.72 13 4.35 13 1.95 10.77 0 8.01 0z"],lightning:["M7 9H5a1 1 0 01-1-1L4.89.876A1 1 0 015.884 0h4.27a.847.847 0 01.793 1.144L9.125 6h2.05a.825.825 0 01.754 1.16L8.16 15.64A.606.606 0 017 15.394V9z"],link:["M4.99 11.99c.28 0 .53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42l-6 6a1.003 1.003 0 00.71 1.71zm3.85-2.02L6.4 12.41l-1 1-.01-.01c-.36.36-.85.6-1.4.6-1.1 0-2-.9-2-2 0-.55.24-1.04.6-1.4l-.01-.01 1-1 2.44-2.44c-.33-.1-.67-.16-1.03-.16-1.1 0-2.09.46-2.81 1.19l-.02-.02-1 1 .02.02c-.73.72-1.19 1.71-1.19 2.81 0 2.21 1.79 4 4 4 1.1 0 2.09-.46 2.81-1.19l.02.02 1-1-.02-.02c.73-.72 1.19-1.71 1.19-2.81 0-.35-.06-.69-.15-1.02zm7.15-5.98c0-2.21-1.79-4-4-4-1.1 0-2.09.46-2.81 1.19l-.02-.02-1 1 .02.02c-.72.72-1.19 1.71-1.19 2.81 0 .36.06.69.15 1.02l2.44-2.44 1-1 .01.01c.36-.36.85-.6 1.4-.6 1.1 0 2 .9 2 2 0 .55-.24 1.04-.6 1.4l.01.01-1 1-2.43 2.45c.33.09.67.15 1.02.15 1.1 0 2.09-.46 2.81-1.19l.02.02 1-1-.02-.02a3.92 3.92 0 001.19-2.81z"],list:["M1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 10H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"list-columns":["M6 1c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm9-12c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5z"],"list-detail-view":["M6 9H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm9-12h-5c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM6 5H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z"],locate:["M15 7h-.09A6.98 6.98 0 009 1.1V1c0-.55-.45-1-1-1S7 .45 7 1v.09A6.98 6.98 0 001.1 7H1c-.55 0-1 .45-1 1s.45 1 1 1h.1A6.969 6.969 0 007 14.91V15c0 .55.45 1 1 1s1-.45 1-1v-.09A6.98 6.98 0 0014.9 9h.1c.55 0 1-.45 1-1s-.45-1-1-1zm-6.02 5.9c-.05-.5-.46-.9-.98-.9s-.93.4-.98.9A5.017 5.017 0 013.1 8.98c.5-.05.9-.46.9-.98s-.4-.93-.9-.98A5.017 5.017 0 017.02 3.1c.05.5.46.9.98.9s.93-.4.98-.9c1.97.39 3.52 1.95 3.92 3.92-.5.05-.9.46-.9.98s.4.93.9.98a5.017 5.017 0 01-3.92 3.92zM8 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],lock:["M13.96 7H12V3.95C12 1.77 10.21 0 8 0S4 1.77 4 3.95V7H1.96c-.55 0-.96.35-.96.9v6.91c0 .54.41 1.19.96 1.19h12c.55 0 1.04-.65 1.04-1.19V7.9c0-.55-.49-.9-1.04-.9zM6 7V3.95c0-1.09.9-1.97 2-1.97s2 .88 2 1.97V7H6z"],"log-in":["M11 8c0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L7.59 7H1c-.55 0-1 .45-1 1s.45 1 1 1h6.59L6.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71zm4-8H9c-.55 0-1 .45-1 1s.45 1 1 1h5v12H9c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"log-out":["M7 14H2V2h5c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm8.71-6.71l-3-3a1.003 1.003 0 00-1.42 1.42L12.59 7H6c-.55 0-1 .45-1 1s.45 1 1 1h6.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],manual:["M15.99 1.13c-.02-.41-.33-.77-.78-.87C12.26-.36 9.84.13 8 1.7 6.16.13 3.74-.36.78.26.33.35.03.72.01 1.13H0v12c0 .08 0 .17.02.26.12.51.65.82 1.19.71 2.63-.55 4.59-.04 6.01 1.57.02.03.06.04.08.06.02.02.03.04.05.06.04.03.09.04.13.07.05.03.09.05.14.07.11.04.23.07.35.07h.04c.12 0 .24-.03.35-.07.05-.02.09-.05.14-.07.04-.02.09-.04.13-.07.02-.02.03-.04.05-.06.03-.02.06-.03.08-.06 1.42-1.6 3.39-2.12 6.01-1.57.54.11 1.07-.21 1.19-.71.04-.09.04-.18.04-.26l-.01-12zM7 12.99c-1.4-.83-3.07-1.14-5-.93V1.96c2.11-.28 3.75.2 5 1.46v9.57zm7-.92c-1.93-.21-3.6.1-5 .93V3.42c1.25-1.26 2.89-1.74 5-1.46v10.11z"],"manually-entered-data":["M1 8h3.76l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm14.49-4.01c.31-.32.51-.76.51-1.24C16 1.78 15.22 1 14.25 1c-.48 0-.92.2-1.24.51l-1.44 1.44 2.47 2.47 1.45-1.43zM1 4h7.76l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 6c-.55 0-1 .45-1 1 0 .48.35.86.8.96L2.76 10H1zm9.95-6.43l-6.69 6.69 2.47 2.47 6.69-6.69-2.47-2.47zm4.25 2.47L13.24 8H15c.55 0 1-.45 1-1 0-.48-.35-.86-.8-.96zM2 15l3.86-1.39-2.46-2.44L2 15zm13-5h-3.76l-2 2H15c.55 0 1-.45 1-1s-.45-1-1-1z"],"many-to-many":["M3 3a1 1 0 100 2 1 1 0 000-2zm3 1c0 .047-.001.094-.003.14.255.081.538.209.832.41.406.28.8.676 1.171 1.225.37-.549.765-.945 1.171-1.224a3.14 3.14 0 01.832-.411 3 3 0 11.77 1.87 1.038 1.038 0 00-.47.19c-.291.2-.752.672-1.227 1.8.475 1.128.936 1.6 1.227 1.8.183.126.336.173.47.19a3 3 0 11-.77 1.87 3.141 3.141 0 01-.832-.41c-.406-.28-.8-.676-1.171-1.225-.37.549-.765.945-1.171 1.224-.294.202-.577.33-.832.411a3 3 0 11-.77-1.87c.134-.017.287-.064.47-.19.291-.2.752-.672 1.227-1.8-.475-1.128-.936-1.6-1.227-1.8a1.038 1.038 0 00-.47-.19A3 3 0 116 4zm6 0a1 1 0 112 0 1 1 0 01-2 0zm-9 7a1 1 0 100 2 1 1 0 000-2zm9 1a1 1 0 112 0 1 1 0 01-2 0z"],"many-to-one":["M3 2a1 1 0 100 2 1 1 0 000-2zm0-2c1.385 0 2.551.94 2.896 2.215.168.044.34.096.51.158 1.076.394 2.237 1.242 2.575 2.93.161.809.664 1.211 1.293 1.443a3 3 0 110 2.508c-.629.232-1.132.634-1.293 1.442-.338 1.69-1.499 2.537-2.575 2.93a5.436 5.436 0 01-.51.159A3.001 3.001 0 010 13a3 3 0 015.726-1.254c.629-.232 1.132-.634 1.293-1.442.216-1.076.765-1.81 1.413-2.304-.648-.493-1.197-1.228-1.413-2.304-.161-.808-.664-1.21-1.293-1.442A3 3 0 113 0zm1 13a1 1 0 10-2 0 1 1 0 002 0zm8-5a1 1 0 102 0 1 1 0 00-2 0z"],map:["M15.55 3.17l-4.49-3A.975.975 0 009.99.15L5.53 2.82 1.56.17A1.003 1.003 0 000 1v11c0 .35.18.65.45.83l4.49 3a.975.975 0 001.07.02l4.46-2.67 3.97 2.65A1.003 1.003 0 0016 15V4c0-.35-.18-.65-.45-.83zM5 13.46l-3-2v-8.6l2.94 1.96c.02.02.04.03.06.04v8.6zm5-2.32s-.01 0-.01.01L6 13.53V4.86s.01 0 .01-.01L10 2.47v8.67zm4 1.99l-2.94-1.96c-.02-.01-.04-.02-.05-.03v-8.6l3 2v8.59z"],"map-create":["M14 6.82v6.32l-2.94-1.96c-.02-.01-.04-.02-.05-.03V6.22c-.08-.07-.15-.16-.22-.24-.28-.02-.54-.08-.79-.16v5.32s-.01 0-.01.01L6 13.53V4.86s.01 0 .01-.01l2.05-1.23C8.02 3.42 8 3.21 8 3c0-.98.47-1.84 1.2-2.39l-3.67 2.2L1.56.17A1.003 1.003 0 000 1v11c0 .35.18.65.45.83l4.49 3a.975.975 0 001.07.02l4.46-2.67 3.97 2.65A1.003 1.003 0 0016 15V5.82c-.25.09-.52.14-.8.16-.33.36-.73.67-1.2.84zm-9 6.64l-3-2v-8.6l2.94 1.96c.02.02.04.03.06.04v8.6zM11 4h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1z"],"map-marker":["M8.46 0C5.42 0 2.95 2.39 2.95 5.33 2.95 8.28 8.46 16 8.46 16s5.51-7.72 5.51-10.67C13.96 2.39 11.5 0 8.46 0zm0 8a2.5 2.5 0 010-5 2.5 2.5 0 010 5z"],maximize:["M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"],media:["M11.99 6.99c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm3-5h-14c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-10c0-.55-.45-1-1-1zm-1 9l-5-3-1 2-3-4-3 5v-7h12v7z"],menu:["M1 4h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 8H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-5H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-closed":["M14.99 6.99h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm-12-2c-.28 0-.53.11-.71.29l-2 2a1.014 1.014 0 000 1.42l2 2a1.003 1.003 0 001.71-.71v-4c0-.55-.45-1-1-1zm3-1h9c.55 0 1-.45 1-1s-.45-1-1-1h-9c-.55 0-1 .45-1 1s.45 1 1 1zm9 8h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-open":["M9.99 11.99h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm5.71 5.3l-2-2a1.003 1.003 0 00-1.71.71v4a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71z"],"merge-columns":["M5.71 5.29a1.003 1.003 0 00-1.42 1.42l.3.29H2V2h3v1.51c.52.06.99.29 1.34.65l.66.66V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-3.82l-.66.66c-.35.35-.82.59-1.34.65V14H2V9h2.59l-.3.29a1.003 1.003 0 001.42 1.42l2-2C7.89 8.53 8 8.28 8 8c0-.28-.11-.53-.29-.71l-2-2zM15 0h-5c-.55 0-1 .45-1 1v3.82l.66-.66c.35-.35.82-.59 1.34-.65V2h3v5h-2.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C8.11 7.47 8 7.72 8 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14v5h-3v-1.51c-.52-.06-.99-.29-1.34-.65L9 11.18V15c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"merge-links":["M8 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6 3c-.93 0-1.71.64-1.93 1.5H11V3c0-1.66-1.34-3-3-3S5 1.34 5 3v4.5H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.93 0 1.71-.64 1.93-1.5H5V13c0 1.66 1.34 3 3 3s3-1.34 3-3V8.5h1.07c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2s-.9-2-2-2zm-4 7c0 1.1-.9 2-2 2s-2-.9-2-2V3c0-1.1.9-2 2-2s2 .9 2 2v10z"],minimize:["M15.99.99a1.003 1.003 0 00-1.71-.71l-3.29 3.29V1.99c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H12.4l3.3-3.29c.18-.18.29-.43.29-.71zm-10 8h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.29 14.28a1.003 1.003 0 001.42 1.42L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4a1.02 1.02 0 00-1.01-1.01z"],minus:["M13 7H3c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"mobile-phone":["M12 0H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM8 15c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3-3H5V3h6v9z"],"mobile-video":["M15 4c-.28 0-.53.11-.71.29L12 6.59V4c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V9.41l2.29 2.29c.18.19.43.3.71.3.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],modal:["M15 1a1 1 0 011 1v12a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1h14zm-1 4H2v8h12V5zm-3-3H9v2h2V2zm3 0h-2v2h2V2z"],"modal-filled":["M15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm1 4H0V3h16v2zm-3-2h-2V1h2v2z"],moon:["M15 11.38A7.835 7.835 0 017.85 16C3.51 16 0 12.49 0 8.15 0 4.97 1.89 2.23 4.62 1c-.45.99-.7 2.08-.7 3.23a7.85 7.85 0 007.85 7.85c1.15 0 2.24-.25 3.23-.7z"],more:["M2 6.03a2 2 0 100 4 2 2 0 100-4zM14 6.03a2 2 0 100 4 2 2 0 100-4zM8 6.03a2 2 0 100 4 2 2 0 100-4z"],mountain:["M16 13H3l6-9h1l2 2h1l3 7zm-2.5-3.5l-1-2.5h-1l-2-2-3 4.5L9 8l1 1 1-1 2.5 1.5zM5.94 7l-4.122 6H0l5-6h.94z"],move:["M15.71 7.29l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9V3.41l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C8.53.11 8.28 0 8 0s-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V7H3.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 9H7v3.59l-.29-.29A.965.965 0 006 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2a1.003 1.003 0 00-1.42-1.42l-.29.3V9h3.59l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],mugshot:["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14h-.15c-.03-.09-.04-.16-.08-.25-.34-.79-2.01-1.31-3.12-1.8-1.11-.49-.96-.79-1-1.2-.01-.06-.01-.12-.01-.18.38-.34.69-.8.89-1.33 0 0 .01-.03.01-.04.04-.12.08-.24.11-.36.25-.05.4-.33.46-.59.06-.1.18-.36.15-.65-.04-.37-.19-.55-.35-.62v-.06c0-.48-.04-1.16-.13-1.61-.02-.12-.05-.25-.08-.37-.16-.55-.51-1.05-.96-1.39C9.26 3.19 8.6 3 8 3c-.59 0-1.26.19-1.73.55-.45.35-.8.84-.96 1.39-.04.13-.06.25-.08.38-.09.45-.13 1.13-.13 1.61v.06c-.18.06-.33.24-.37.62-.03.29.09.54.15.65.06.26.21.54.47.59.03.12.07.25.11.36 0 .01.01.02.01.02v.01c.21.54.53 1.01.92 1.35 0 .05-.01.11-.01.16-.04.41.08.7-1.03 1.2-1.11.49-2.77 1.01-3.12 1.8-.04.09-.05.16-.08.25H2V2h12v12z"],"multi-select":["M12 3.98H4c-.55 0-1 .45-1 1v1h8v5h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm3-3H7c-.55 0-1 .45-1 1v1h8v5h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm-6 6H1c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm-1 5H2v-3h6v3z"],music:["M15 0c-.07 0-.13.03-.19.04V.02l-10 2v.02C4.35 2.13 4 2.52 4 3v9.12c-.31-.07-.65-.12-1-.12-1.66 0-3 .9-3 2s1.34 2 3 2 3-.9 3-2V6.32l8-1.6v5.4c-.31-.07-.65-.12-1-.12-1.66 0-3 .9-3 2s1.34 2 3 2 3-.9 3-2V1c0-.55-.45-1-1-1z"],nest:["M2 2c.55 0 1 .45 1 1v3c0 1.66 1.34 3 3 3h5.59L10.3 7.71A.965.965 0 0110 7a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42l1.3-1.29H6c-2.76 0-5-2.24-5-5V3c0-.55.45-1 1-1z"],"new-drawing":["M14.9 11c.6 0 1 .5 1 1 0 .257-.073.44-.22.614l-.08.086-3 3c-.2.2-.4.3-.7.3-.5 0-1-.4-1-1 0-.257.073-.44.22-.614l.08-.086 3-3c.2-.2.4-.3.7-.3zM1.3.1l6.734 2.45a3.005 3.005 0 002.095 3.322 3.005 3.005 0 003.401 2.081L13.9 9.8v.2c0 .257-.073.44-.22.614l-.08.086-3 3c-.171.171-.343.27-.577.294L9.9 14h-.2l-5-1-.1-.01c-.231-.05-.45-.26-.56-.49L4 12.4l-4-11 .3-.3 5.8 5.8c-.1.2-.2.4-.2.6 0 .8.6 1.5 1.5 1.5s1.5-.7 1.5-1.5S8.2 6 7.4 6c-.16 0-.32.064-.48.14l-.12.06L1 .4l.3-.3zM13 0c.55 0 1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .503-.376.922-.861.99l-.013.002A.999.999 0 0113 6l.097-.006-.027.004a1 1 0 01-.037.001L13 6c-.55 0-1-.45-1-1V4h-1a.993.993 0 01-.855-.482A1 1 0 0110 3c0-.55.45-1 1-1h1V1c0-.55.45-1 1-1z"],"new-grid-item":["M6 0H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm5 14c0-.55-.45-1-1-1s-1 .45-1 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM6 9H1c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm9 4c-.55 0-1 .45-1 1-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm-4-4h-1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1s1-.45 1-1c.55 0 1-.45 1-1s-.45-1-1-1zm4-9h-5c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm0 9h-1c-.55 0-1 .45-1 1s.45 1 1 1c0 .55.45 1 1 1s1-.45 1-1v-1c0-.55-.45-1-1-1z"],"new-layer":["M13.982 6.272l1.518.868-.01.01c.3.17.51.48.51.85s-.21.68-.51.85l.01.01-7 4-.01-.01A.94.94 0 018 13a.94.94 0 01-.49-.15l-.01.01-7-4 .01-.01A.977.977 0 010 8c0-.37.21-.68.51-.86L.5 7.13l7-4 .01.02A.94.94 0 018 3c.086 0 .168.014.246.038a2 2 0 105.736 3.234zM14 3c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 1-1s1 .45 1 1v1h1z"],"new-layers":["M13 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5H9a1 1 0 110-2h2V1a1 1 0 012 0v2zm-3-1.983V2H9a2 2 0 100 4h1v1c0 .279.057.544.16.785l-1.71.855c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5a.992.992 0 01.07-1.81l6.99-3a1.006 1.006 0 01.79 0l1.6.687zm.91 7.66a2 2 0 003.085-1.54l.555-.277c.14-.07.29-.11.45-.11.55 0 1 .45 1 1 0 .39-.23.73-.55.89l-7 3.5c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5C.23 8.48 0 8.14 0 7.75c0-.55.45-1 1-1 .16 0 .31.04.45.11L8 10.13l2.91-1.453zM15 10.25c.55 0 1 .45 1 1 0 .39-.23.73-.55.89l-7 3.5c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5c-.32-.16-.55-.5-.55-.89 0-.55.45-1 1-1 .16 0 .31.04.45.1L8 13.63l6.55-3.27c.14-.07.29-.11.45-.11z"],"new-link":["M15 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3.5 6a2.5 2.5 0 00-2.45 2h-4.1a2.5 2.5 0 100 1h4.1a2.5 2.5 0 102.45-3z"],"new-object":["M8 4c0 .6.4 1 1 1h2v2c0 .6.4 1 1 1s1-.4 1-1V5h2c.6 0 1-.4 1-1s-.4-1-1-1h-2V1c0-.6-.4-1-1-1s-1 .4-1 1v2H9c-.6 0-1 .5-1 1zm6.5 2.5V7c0 1.4-1.1 2.5-2.5 2.5S9.5 8.4 9.5 7v-.5H9C7.6 6.5 6.5 5.4 6.5 4S7.6 1.5 9 1.5h.5V1c0-.3.1-.6.1-.8C9.1.1 8.6 0 8 0 3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8c0-.6-.1-1.3-.2-1.9-.4.3-.8.4-1.3.4z"],"new-person":["M9.12 12.69c-1.17-.53-1.01-.85-1.05-1.29-.01-.06-.01-.12-.01-.19.4-.37.73-.87.94-1.44 0 0 .01-.03.01-.04.05-.14.09-.27.12-.4.27-.06.43-.36.49-.63.06-.11.19-.39.16-.7-.04-.41-.2-.6-.38-.68v-.07c0-.51-.05-1.25-.14-1.74-.02-.13-.05-.27-.09-.4-.17-.6-.53-1.14-1.01-1.52C7.66 3.2 6.96 3 6.33 3c-.62 0-1.33.2-1.82.59-.49.38-.85.92-1.02 1.52-.04.13-.07.26-.09.4-.09.49-.13 1.23-.13 1.74v.06c-.19.08-.35.27-.39.68-.03.31.1.59.16.7.06.28.22.59.5.64.03.14.07.27.11.4 0 .01.01.02.01.02v.01c.22.59.55 1.1.96 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.09 1.29-1.17.53-2.93 1.1-3.29 1.95-.35.87-.2 1.37-.2 1.37h12.6s.15-.5-.22-1.36c-.36-.85-2.12-1.42-3.29-1.95zM14.89 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-prescription":["M9.82 11.66l2.48-2.87c.12-.2.13-.37.04-.53-.11-.19-.3-.26-.52-.26h-1.29c-.27 0-.49.13-.63.34L8.44 9.9 6.95 8a.482.482 0 00-.08-.1L5.82 6.55c.57-.24 1.04-.57 1.42-1.01.49-.57.74-1.27.74-2.08 0-.51-.1-.99-.32-1.42-.21-.43-.51-.8-.89-1.11A4.1 4.1 0 005.42.24C4.91.08 4.34 0 3.72 0H.61C.26 0 0 .23 0 .56v9.89c0 .33.26.55.61.55h.8c.36 0 .61-.23.61-.56V6.99H3.3l3.73 4.74-2.71 3.48c-.12.2-.13.37-.04.53.11.19.3.26.52.26h1.27c.27 0 .51-.12.64-.34l1.69-2.15 1.66 2.14c.12.21.34.35.62.35h1.43c.2 0 .39-.08.5-.25.12-.18.09-.38-.02-.55l-2.77-3.54zM4.18 5H1.99V2.02h2.19c.62 0 1.08.13 1.38.37.29.22.44.62.44 1.08 0 .45-.15.94-.44 1.17-.31.23-.76.36-1.38.36zM15 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zM9.99 3.01c0 .02.01.04.01.06V2.95c0 .02-.01.04-.01.06z"],"new-text-box":["M5 6.5c0 .28.22.5.5.5H7v3.5c0 .28.22.5.5.5s.5-.22.5-.5V7h1.5c.28 0 .5-.22.5-.5S9.78 6 9.5 6h-4c-.28 0-.5.22-.5.5zM15 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zm-2 5c-.55 0-1 .45-1 1v5H3V4h5c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1z"],ninja:["M16 5s-2.52 2.11-4.96 1.99C11.03 4.89 10.39.23 5 0c0 0 2.11 2.54 1.96 4.99C4.86 5.01.23 5.65 0 11c0 0 2.56-2.12 5.02-1.95.02 2.11.67 6.72 5.98 6.95 0 0-2.09-2.54-1.94-4.99 2.11-.02 6.71-.68 6.94-6.01zM8 9.5c-.83 0-1.5-.67-1.5-1.5S7.17 6.5 8 6.5s1.5.67 1.5 1.5S8.83 9.5 8 9.5z"],"not-equal-to":["M7.58 5l.44-2.196a1 1 0 011.96.392L9.62 5H13a1 1 0 010 2H9.22l-.4 2H13a1 1 0 010 2H8.42l-.44 2.196a1 1 0 01-1.96-.392L6.38 11H3a1 1 0 010-2h3.78l.4-2H3a1 1 0 110-2h4.58z"],notifications:["M8 16c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zm6-5c-.55 0-1-.45-1-1V6c0-2.43-1.73-4.45-4.02-4.9 0-.04.02-.06.02-.1 0-.55-.45-1-1-1S7 .45 7 1c0 .04.02.06.02.1A4.992 4.992 0 003 6v4c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],"notifications-snooze":["M9 14c0 1.1-.9 2-2 2s-2-.9-2-2zM7 0c.404 0 .755.243.912.59L7.9.6c-.7.6-.9 1.36-.9 1.9 0 .8.267 1.433.8 1.9-.533.6-.795 1.222-.784 1.867l.004.358A2.8 2.8 0 009.82 9.4L12 9.399V10c0 .51.388.935.884.993L13 11c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V6c0-2.43 1.73-4.45 4.02-4.9L6 1c0-.55.45-1 1-1z","M13 6.702a.632.632 0 00-.632-.632h-1.743l2.208-2.734A.75.75 0 0013 2.864v-.3A.565.565 0 0012.435 2H9.561a.561.561 0 100 1.123h1.814L9.221 5.795A1 1 0 009 6.423v.279c0 .349.283.631.632.631h2.736A.632.632 0 0013 6.702z"],"notifications-updated":["M8 16c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zm3.399-13.667l-.413.412A2.99 2.99 0 009 1.99a3 3 0 00-3 2.99c0 .8.32 1.558.876 2.114l2.002 1.992A2.99 2.99 0 0013 9.184V10c0 .55.45 1 1 1s1 .45 1 1-.45 1-1 1H2c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V6c0-2.43 1.73-4.45 4.02-4.9 0-.04-.02-.06-.02-.1 0-.55.45-1 1-1s1 .45 1 1c0 .04-.02.06-.02.1a4.97 4.97 0 012.419 1.233zM10.29 7.67l-2-1.99a.99.99 0 01-.29-.7 1 1 0 011-.99c.27 0 .52.11.7.29l1.29 1.29 3.28-3.28c.18-.18.42-.29.7-.29.55 0 1 .44 1 .99 0 .28-.11.52-.3.7l-3.98 3.98a.99.99 0 01-1.4 0z"],"numbered-list":["M2.76 7h1.26V0h-.94c-.04.21-.12.39-.25.54-.13.15-.29.27-.48.36-.18.09-.39.16-.62.2-.23.04-.46.06-.71.06v.9h1.74V7zm-.59 7.17c.18-.12.37-.25.58-.37a10.763 10.763 0 001.24-.83c.2-.16.37-.33.52-.51.15-.19.28-.39.37-.61.09-.22.14-.47.14-.74 0-.22-.04-.45-.12-.7-.08-.26-.21-.49-.4-.69-.18-.21-.43-.39-.72-.52-.3-.14-.68-.21-1.12-.21-.41 0-.77.07-1.08.2-.32.14-.58.32-.8.56-.22.23-.38.51-.49.84-.11.32-.16.67-.16 1.05h1.19c.01-.24.03-.47.08-.67.05-.21.11-.39.21-.54.09-.15.22-.27.38-.36.16-.09.35-.13.59-.13.26 0 .47.04.63.12.16.08.29.18.38.3.09.12.15.25.18.39s.05.27.05.4c-.01.27-.08.5-.22.71-.14.21-.32.4-.53.57-.22.18-.45.34-.71.49-.26.15-.51.31-.74.47-.5.31-.89.68-1.17 1.11-.3.41-.44.91-.45 1.48h5v-1H1.43c.05-.15.14-.29.27-.43.14-.13.29-.26.47-.38zM15.01 1.99h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.44-1-1-1zm0 9h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.44-1-1-1z"],numerical:["M2.79 4.61c-.13.17-.29.3-.48.41-.18.11-.39.18-.62.23-.23.04-.46.07-.71.07v1.03h1.74V12h1.26V4h-.94c-.04.23-.12.44-.25.61zm4.37 5.31c.18-.14.37-.28.58-.42l.63-.45c.21-.16.41-.33.61-.51s.37-.38.52-.59c.15-.21.28-.45.37-.7.09-.25.13-.54.13-.85 0-.25-.04-.52-.12-.8-.07-.29-.2-.55-.39-.79a2.18 2.18 0 00-.73-.6c-.29-.15-.66-.23-1.11-.23-.41 0-.77.08-1.08.23-.31.16-.58.37-.79.64-.22.27-.38.59-.49.96-.11.37-.16.77-.16 1.2h1.19c.01-.27.03-.53.08-.77.04-.24.11-.45.21-.62.09-.18.22-.32.38-.42.16-.1.35-.15.59-.15.26 0 .47.05.63.14.15.09.28.21.37.35.09.14.15.29.18.45.03.16.05.31.05.45-.01.31-.08.58-.22.82-.14.23-.32.45-.53.65-.22.21-.46.39-.71.57-.26.18-.51.36-.75.54-.5.36-.89.78-1.17 1.27-.28.49-.43 1.06-.44 1.71h5v-1.15H6.43c.05-.17.14-.33.27-.49.13-.15.29-.29.46-.44zm8.5-1.56c-.23-.35-.54-.57-.95-.65v-.02c.34-.13.6-.34.76-.63.16-.29.24-.63.24-1.02 0-.34-.06-.64-.19-.9s-.3-.47-.51-.64c-.21-.17-.45-.3-.72-.38-.27-.09-.54-.13-.82-.13-.36 0-.68.07-.96.2-.28.13-.53.32-.72.55-.2.23-.36.51-.47.83-.11.32-.18.66-.19 1.04h1.15c-.01-.2.01-.39.06-.58.05-.19.12-.36.22-.51.1-.15.22-.27.37-.36.15-.09.32-.13.53-.13.32 0 .59.1.79.3.21.2.31.46.31.79 0 .23-.05.43-.14.59-.09.16-.21.29-.35.38-.15.09-.32.16-.51.19-.19.04-.38.05-.57.04v.93c.23-.01.45 0 .67.02.22.02.42.08.59.17.18.09.32.23.43.4.11.18.16.41.16.71 0 .44-.13.78-.39 1.02s-.58.36-.97.36c-.45 0-.79-.16-1.02-.47-.23-.31-.33-.7-.32-1.17H11c.01.4.06.77.17 1.1.11.33.26.61.47.85.21.23.46.42.77.54.31.13.67.19 1.08.19.34 0 .66-.05.96-.16.3-.11.57-.27.8-.47.23-.2.41-.45.55-.74.13-.27.2-.6.2-.97 0-.5-.11-.92-.34-1.27z"],office:["M15 5h-3V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h3v-4h4v4h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM5 10H2V7h3v3zm0-5H2V2h3v3zm5 5H7V7h3v3zm0-5H7V2h3v3zm4 9h-2v-2h2v2zm0-4h-2V7h2v3z"],offline:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM6 14l1-5H4l6-7-1 5h3l-6 7z"],"oil-field":["M15 14h-1.35l-3.34-7.51 2.46-.95 1.45 3.21c.09.2.36.3.6.23.1-.03.18-.08.24-.15.05-.08 1.23-1.56.87-4.2-.11-.79-.52-4.62-3.26-4.62-.93 0-1.68.62-1.67 1.37 0 .14.03.28.09.42l.87 1.92L.64 8.07v.01A.98.98 0 000 9c0 .55.45 1 1 1 .13 0 .25-.03.36-.07v.01l1.04-.4L3.67 14H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM4.27 8.81L7.14 7.7 5.2 12.08l-.93-3.27zM6.54 14L9 8.46 11.46 14H6.54z"],"one-column":["M11.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1zm-6 5c-.28 0-.53.11-.71.29l-2 2a1.014 1.014 0 000 1.42l2 2a1.003 1.003 0 001.71-.71v-4c0-.55-.45-1-1-1z"],"one-to-many":["M14 3a1 1 0 11-2 0 1 1 0 012 0zm-3.726 1.254a3 3 0 10-.17-2.039 5.467 5.467 0 00-.51.158c-1.076.394-2.237 1.242-2.575 2.93-.161.809-.664 1.211-1.293 1.443a3 3 0 100 2.508c.629.232 1.132.634 1.293 1.442.338 1.69 1.499 2.537 2.575 2.93.17.063.342.115.51.159a3.001 3.001 0 10.17-2.04c-.629-.231-1.132-.633-1.293-1.441C8.765 9.228 8.216 8.494 7.568 8c.648-.493 1.197-1.228 1.413-2.304.161-.808.664-1.21 1.293-1.442zM13 14a1 1 0 110-2 1 1 0 010 2zM4 8a1 1 0 10-2 0 1 1 0 002 0z"],"one-to-one":["M2 8a1 1 0 112 0 1 1 0 01-2 0zm3.83-1a3.001 3.001 0 100 2h4.34a3.001 3.001 0 100-2H5.83zM13 7a1 1 0 100 2 1 1 0 000-2z"],outdated:["M8 0c4.42 0 8 3.58 8 8 0 4.06-3.02 7.4-6.94 7.92-.02 0-.04.01-.06.01-.33.04-.66.07-1 .07-4.42 0-8-3.58-8-8 0-.55.45-1 1-1s1 .45 1 1c0 3.31 2.69 6 6 6 .71 0 1.37-.15 2-.38v.01c2.33-.82 4-3.02 4-5.63 0-3.31-2.69-6-6-6-1.78 0-3.36.78-4.46 2H5c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v1.74A7.95 7.95 0 018 0zm1 12H7v-2h2v2zm0-3H7V4h2v5z"],"page-layout":["M15 .95H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-12c0-.55-.45-1-1-1zm-9 12H2v-6h4v6zm8 0H7v-6h7v6zm0-7H2v-3h12v3z"],"panel-stats":["M10 4h3v1h-3zM10 6h3v1h-3zM10 8h3v1h-3zM10 10h3v1h-3z","M15 1H1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zM8 12H2V3h6v9zm6 0H9V3h5v9z"],"panel-table":["M15 1H1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zM8 9H6V7h2v2zm0-3H6V4h2v2zm-6 6V3h3v9H2zm4 0v-2h2v2H6zm8 0H9v-2h5v2zm0-3H9V7h5v2zm0-3H9V4h5v2z"],paperclip:["M14.68 2.31A4.54 4.54 0 0011.46.99c-1.15 0-2.31.44-3.19 1.32L.95 9.63c-.63.63-.95 1.46-.95 2.28a3.21 3.21 0 003.23 3.22c.83 0 1.66-.31 2.3-.95l7.31-7.32c.76-.77.76-1.98.01-2.73s-1.99-.76-2.75 0l-6.07 6.08c-.24.25-.24.65.01.9s.65.25.91.01l6.07-6.08c.25-.25.67-.25.91-.01.25.25.25.67 0 .92l-7.31 7.32c-.75.75-2.04.74-2.76.01-.75-.75-.73-2.02.01-2.76L9.2 3.21c1.24-1.24 3.35-1.26 4.58-.03 1.24 1.24 1.24 3.36 0 4.6l-7.12 7.13c-.24.25-.24.64.01.88.24.24.63.24.88.01v.01l7.13-7.13A4.41 4.41 0 0016 5.51c0-1.16-.44-2.32-1.32-3.2z"],paragraph:["M13 1H6C3.8 1 2 2.8 2 5s1.8 4 4 4v5c0 .6.4 1 1 1s1-.5 1-1V3h2v11c0 .6.4 1 1 1s1-.5 1-1V3h1c.5 0 1-.4 1-1s-.4-1-1-1z"],path:["M14.5 0h-13C.67 0 0 .67 0 1.5S.67 3 1.5 3H7v3H3.5C2.67 6 2 6.67 2 7.5S2.67 9 3.5 9H7v3H5.5c-.83 0-1.5.67-1.5 1.5S4.67 15 5.5 15h5c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5H9V9h3.5c.83 0 1.5-.67 1.5-1.5S13.33 6 12.5 6H9V3h5.5c.83 0 1.5-.67 1.5-1.5S15.33 0 14.5 0z"],"path-search":["M15 14.62l-4-2.4V9.77c-.32.09-.66.15-1 .18v2.27l-4 2.4V8.71c-.38-.31-.72-.66-1-1.06v6.97l-4-2.4V8c.55 0 1-.45 1-1s-.45-1-1-1V1.38l3.15 1.89c.08-.34.18-.66.32-.97L.76.07v.01A.496.496 0 00.5 0C.22 0 0 .22 0 .5v12c0 .18.1.33.25.42v.01l5 3v-.01c.07.05.16.08.25.08s.18-.03.25-.08v.01l4.74-2.85 4.74 2.85v-.01c.09.05.18.08.27.08.28 0 .5-.22.5-.5v-3.78c-.3.17-.63.28-1 .28v2.62zM2 5c0 .55.45 1 1 1s1-.45 1-1-.45-1-1-1-1 .45-1 1zm6-1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm7.75-.92l-1.19-.72c.18.43.29.9.36 1.38l.08.04v3.39l1 1V3.5c0-.18-.1-.33-.25-.42zM10 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3.3 4.89c.44-.7.7-1.51.7-2.39C14 2.01 11.99 0 9.5 0S5 2.01 5 4.5 7.01 9 9.5 9c.88 0 1.69-.26 2.39-.7l2.41 2.41c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71l-2.41-2.4zM9.5 8C7.57 8 6 6.43 6 4.5S7.57 1 9.5 1 13 2.57 13 4.5 11.43 8 9.5 8z"],pause:["M6 3H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm6 0h-2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],people:["M13.69 13.98c-.05-.24-.14-.5-.25-.76-.36-.86-1.12-1.33-2.69-2-.14-.06-.59-.25-.6-.25-.21-.09-.36-.15-.5-.22.02-.1.02-.2.03-.31 0-.04.01-.08.01-.13-.07-.06-.13-.12-.19-.19.22-.32.4-.67.54-1.05.02-.06.02-.06.03-.1.29-.23.48-.57.59-.96.16-.33.25-.73.21-1.16-.03-.4-.16-.76-.37-1.03-.02-.53-.07-1.13-.15-1.54-.01-.06-.02-.12-.03-.19.23-.06.48-.09.72-.09.49 0 1.05.16 1.44.46.38.29.67.7.8 1.17.03.1.05.21.07.31.07.37.11.94.11 1.33v.05c.14.06.27.21.29.51.02.25-.07.45-.13.54-.05.21-.16.44-.38.48-.02.1-.05.2-.09.3 0 .01-.01.03-.01.03-.17.44-.43.83-.75 1.11v.14c.03.35-.09.59.83 1 .93.41 2.32.84 2.6 1.5.29.66.17 1.04.17 1.04h-2.3zm-1.17-.38c.37.86.22 1.36.22 1.36H.06s-.14-.5.22-1.36 2.13-1.43 3.31-1.96c1.17-.54 1.05-.86 1.09-1.3 0-.05.01-.11.01-.17-.41-.35-.75-.86-.97-1.45v-.01s-.01-.01-.01-.02c-.04-.12-.09-.26-.12-.39-.28-.05-.44-.36-.5-.64-.06-.12-.19-.39-.16-.71.04-.41.21-.6.39-.68v-.06c0-.51.05-1.26.14-1.74.02-.13.05-.27.09-.4.17-.6.54-1.13 1.02-1.51.5-.39 1.21-.6 1.84-.6s1.34.21 1.84.6c.48.38.85.91 1.02 1.52.04.13.07.27.09.4.09.48.14 1.22.14 1.73v.07c.18.08.34.27.37.67.03.32-.09.59-.16.71-.06.28-.21.58-.48.63-.03.13-.07.26-.12.39 0 .01-.01.04-.01.04-.22.58-.55 1.08-.95 1.45v.18c.04.45-.12.77 1.06 1.3 1.18.53 2.95 1.09 3.31 1.95z"],percentage:["M6 6V4c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v2c0 1.1.9 2 2 2h1c1.1 0 2-.9 2-2zM3.5 6c-.28 0-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5s.5.22.5.5v1c0 .28-.22.5-.5.5zM13 8h-1c-1.1 0-2 .9-2 2v2c0 1.1.9 2 2 2h1c1.1 0 2-.9 2-2v-2c0-1.1-.9-2-2-2zm0 3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5s.5.22.5.5v1zM12 3a1.003 1.003 0 00-1.87-.5l-5.99 9.98c-.09.15-.14.33-.14.52a1.003 1.003 0 001.87.5l5.99-9.98c.09-.15.14-.33.14-.52z"],person:["M15.68 14.32c-.46-1.05-2.68-1.75-4.16-2.4-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15A3.671 3.671 0 0010.32.72C9.68.25 8.79-.01 8-.01c-.79 0-1.68.25-2.31.73-.61.47-1.06 1.13-1.28 1.86-.05.17-.09.33-.11.5-.12.6-.17 1.51-.17 2.15v.08c-.24.09-.45.32-.5.83-.03.38.13.72.2.86.08.35.28.72.63.78.04.17.09.33.15.49 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.37 1.59-1.48.65-3.7 1.35-4.16 2.4-.46 1.05-.27 1.67-.27 1.67h15.92c-.01.01.18-.61-.28-1.66z"],phone:["M15.9 12.41c-.06-.06-3.37-2-3.48-2.05a.794.794 0 00-.32-.08c-.15 0-.34.11-.57.32-.23.22-.94 1.19-1.15 1.4-.21.22-.38.32-.52.32-.07 0-.15-.02-.25-.06-.1-.04-1.16-.58-3.36-2.52-2.2-1.93-2.49-3.2-2.5-3.55 0-.14.11-.31.32-.52.22-.21.45-.41.7-.6.25-.19.49-.4.7-.62.22-.23.32-.42.32-.57 0-.11-.03-.21-.08-.32C5.66 3.46 3.66.15 3.59.08 3.44-.07 2.85 0 2.55.16.16 1.46-.03 3.2 0 3.89c.04.71.49 4.46 4.16 7.95C8.72 16.17 11.89 16 12.1 16c.69 0 2.82-.38 3.72-2.55.13-.32.25-.87.08-1.04z"],"pie-chart":["M7 1.08c-3.37.5-5.97 3.4-5.97 6.92 0 3.87 3.13 7 6.98 7 3.52 0 6.42-2.61 6.91-6H7V1.08z","M8 0v8h8c0-4.42-3.58-8-8-8z"],pin:["M9.41.92c-.51.51-.41 1.5.15 2.56L4.34 7.54C2.8 6.48 1.45 6.05.92 6.58l3.54 3.54-3.54 4.95 4.95-3.54 3.54 3.54c.53-.53.1-1.88-.96-3.42l4.06-5.22c1.06.56 2.04.66 2.55.15L9.41.92z"],pivot:["M4.57 7.02L.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4.27-4.27c-.58-.35-1.07-.84-1.41-1.42zM15 8c-.55 0-1 .45-1 1v.59l-2.57-2.57c-.34.58-.83 1.07-1.41 1.41L12.59 11H12c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-4-3c0-1.66-1.34-3-3-3S5 3.34 5 5s1.34 3 3 3 3-1.34 3-3zM8 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"pivot-table":["M2 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm0-4H1C.45 0 0 .45 0 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm11.71 4.29C13.53 4.11 13.28 4 13 4s-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V9c0 1.66-1.34 3-3 3H7.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H9c2.76 0 5-2.24 5-5V7.41l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2zM15 0H5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],play:["M12 8c0-.35-.19-.64-.46-.82l.01-.02-6-4-.01.02A.969.969 0 005 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 6-4-.01-.02c.27-.18.46-.47.46-.82z"],plus:["M13 7H9V3c0-.55-.45-1-1-1s-1 .45-1 1v4H3c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1V9h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"polygon-filter":["M14 5c-.24 0-.47.05-.68.13L9.97 2.34c.01-.11.03-.22.03-.34 0-1.1-.9-2-2-2S6 .9 6 2c0 .04.01.08.01.12L2.88 4.21C2.61 4.08 2.32 4 2 4 .9 4 0 4.9 0 6c0 .74.4 1.38 1 1.72v4.55c-.6.35-1 .99-1 1.73 0 1.1.9 2 2 2 .74 0 1.38-.4 1.72-1h4.55c.35.6.98 1 1.72 1 1.1 0 2-.9 2-2 0-.37-.11-.7-.28-1L14 9c1.11-.01 2-.9 2-2s-.9-2-2-2zm-4.01 7c-.73 0-1.37.41-1.71 1H3.73c-.18-.3-.43-.55-.73-.72V7.72c.6-.34 1-.98 1-1.72 0-.04-.01-.08-.01-.12l3.13-2.09c.27.13.56.21.88.21.24 0 .47-.05.68-.13l3.35 2.79c-.01.11-.03.22-.03.34 0 .37.11.7.28 1l-2.29 4z"],power:["M8 8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S7 .45 7 1v6c0 .55.45 1 1 1zm3-5.32v2.34c1.21.91 2 2.35 2 3.98 0 2.76-2.24 5-5 5s-5-2.24-5-5c0-1.63.79-3.06 2-3.98V2.68C2.64 3.81 1 6.21 1 9c0 3.87 3.13 7 7 7s7-3.13 7-7c0-2.79-1.64-5.19-4-6.32z"],"predictive-analysis":["M16 6.41c0-1.01-.49-1.94-1.29-2.49-.43-1.92-2.07-3.28-4-3.28-.46 0-.92.08-1.35.24C8.83.31 8.11 0 7.34 0c-.9 0-1.74.44-2.28 1.16-.12-.01-.24-.02-.36-.02-1.31 0-2.42.89-2.77 2.17C.78 3.72 0 4.84 0 6.13c0 .38.07.76.21 1.12C.07 7.6 0 7.98 0 8.36c0 1.11.58 2.11 1.51 2.63.54.56 1.27.87 2.03.87.49 0 .95-.12 1.37-.36a2.85 2.85 0 002.18 1.04c.52 0 1.03-.14 1.47-.42.49.39 1.07.65 1.69.73 1.04 1.15 1.84 2.63 1.84 2.64 0 0 .28.49.26.49.77 0 1.41-.16 1.32-1.04 0 .02-.73-2.31-.73-2.31.41-.21.75-.55.97-.98.9-.52 1.47-1.53 1.47-2.61 0-.24-.03-.48-.08-.71.45-.52.7-1.21.7-1.92zm-1.23 1.02l-.15-.16-.61-.67c-.27-.29-.54-.94-.58-1.39l-.1-1.01c-.05-.59-.94-.58-.91.11 0 .02.1 1.01.1 1.01.03.29.12.62.24.93-.06-.01-.12-.02-.18-.02 0 0-2.06-.1-2.05-.11-.58-.02-.71.97-.04 1l2.05.11c.42.02 1.04.3 1.29.58l.49.54.02.05c.08.21.12.44.12.66 0 .74-.41 1.41-1.07 1.75l-.16.08-.07.18c-.15.38-.48.66-.88.74l-.54.11.7 2.2c-.38-.61-.95-1.43-1.62-2.14l-.12-.13-.17-.01c-.41-.03-.8-.17-1.14-.38l1.36-1.18c.35-.31.83-.44.99-.39 0 0 .63.17.62.18.63.16.83-.74.23-.97l-.62-.18c-.55-.16-1.33.18-1.79.58l-1.53 1.33-.31.26c-.35.29-.75.44-1.2.44-.64 0-1.23-.33-1.58-.86V9.15c0-.4.17-.79.27-.85 0 0 .52-.34.51-.35.71-.53.18-1.23-.49-.89 0-.01-.52.35-.52.35-.26.15-.45.44-.58.77-.11-.11-.22-.2-.34-.28 0 0-1.53-1.01-1.53-1.02-.65-.45-1.2.51-.49.89 0-.01 1.51 1.02 1.51 1.02.37.24.62.78.62 1.09v.67c-.34.19-.63.29-.99.29-.54 0-1.05-.23-1.41-.63l-.05-.06-.07-.04c-.65-.34-1.05-1-1.05-1.73 0-.3.07-.6.2-.87l.12-.25L1.15 7c-.13-.27-.2-.56-.2-.87 0-.9.61-1.68 1.48-1.89l.31-.08.05-.34a1.926 1.926 0 012.38-1.58l.32.08.18-.31c.35-.6.99-.97 1.67-.97.44 0 .86.15 1.2.42l-.36.36v-.01l-.25.26c-.33.27-.74.42-.89.4 0 0-.67-.1-.67-.11-.67-.13-.87.86-.14 1.02.01 0 .67.11.67.11.02 0 .05 0 .07.01-.11.37-.15.77-.1 1.12 0 0 .17.99.15.99.11.52 1.06.36.93-.18 0-.01-.15-.99-.15-.99-.05-.37.12-.94.36-1.19l.39-.4c.05-.05.1-.09.15-.14l.74-.76c.4-.18.83-.27 1.27-.27 1.55 0 2.86 1.12 3.11 2.67l.04.25.21.12c.61.35.98 1 .98 1.7 0 .36-.1.7-.28 1.01z"],prescription:["M10.91 8.34c.14-.21.36-.34.63-.34h1.29c.22 0 .41.07.52.26.09.16.08.33-.04.53l-2.49 2.87 2.77 3.54c.12.17.14.37.02.55-.11.17-.3.25-.5.25h-1.44a.69.69 0 01-.61-.35L9.4 13.51l-1.69 2.15c-.13.21-.36.34-.63.34H5.8c-.22 0-.41-.07-.52-.26-.09-.16-.08-.33.04-.53l2.71-3.48L4.3 6.99H3.03v3.47c0 .33-.26.56-.62.56h-.8c-.35-.01-.61-.23-.61-.56V.56c0-.33.26-.56.62-.56h3.11c.62 0 1.19.08 1.7.24.51.16.96.39 1.34.69a3.194 3.194 0 011.21 2.53c0 .81-.25 1.5-.74 2.08-.37.44-.84.77-1.42 1.01L7.88 7.9c.04.04.07.08.08.1l1.49 1.9 1.46-1.56zM5.18 5c.62 0 1.08-.13 1.39-.37.29-.23.44-.71.44-1.16s-.15-.87-.44-1.1C6.26 2.12 5.8 2 5.18 2H2.99v3h2.19z"],presentation:["M15 1H9c0-.55-.45-1-1-1S7 .45 7 1H1c-.55 0-1 .45-1 1s.45 1 1 1v8c0 .55.45 1 1 1h3.59L3.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 13.41V15c0 .55.45 1 1 1s1-.45 1-1v-1.59l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L10.41 12H14c.55 0 1-.45 1-1V3c.55 0 1-.45 1-1s-.45-1-1-1zm-2 9H3V3h10v7z"],print:["M12 2.02c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h8v-1zm3 2H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h1v-3h12v3h1c.55 0 1-.45 1-1v-6c0-.56-.45-1-1-1zm-1 3h-2v-1h2v1zm-3 6H5v-3H3v4c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-4h-2v3z"],projects:["M14 3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v1h12V3zm-2-3H4c-.55 0-1 .45-1 1h10c0-.55-.45-1-1-1zm3 5H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-3 6c0 .55-.45 1-1 1H5c-.55 0-1-.45-1-1V9h1v2h6V9h1v2z"],properties:["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm4-3h9c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1zm-4 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm13-5H6c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0 6H6c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],property:["M3 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-.5-6.5a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM7 3h8c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zm8 10H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zM3 0C1.9 0 1 .9 1 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 6H7c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"publish-function":["M12.16 3.76c.15-.11.3-.16.47-.16.06 0 .17.02.34.06.16.04.31.06.43.06a.58.58 0 00.6-.6c0-.19-.06-.33-.17-.44-.11-.11-.28-.16-.49-.16-.19 0-.37.04-.54.13-.17.09-.39.27-.65.55-.2.21-.48.58-.87 1.11a5.22 5.22 0 00-.78-1.79l-2.05.32-.04.21c.15-.03.28-.04.39-.04.2 0 .37.08.5.25.21.26.5 1.03.88 2.33-.29.36-.49.6-.6.71-.18.19-.33.31-.45.36-.09.04-.19.07-.3.07-.09 0-.23-.04-.42-.13a.904.904 0 00-.36-.09c-.2 0-.36.06-.49.18a.59.59 0 00-.19.46c0 .18.06.32.18.43.12.11.28.16.48.16.2 0 .38-.04.55-.12.17-.08.39-.24.65-.49s.62-.65 1.07-1.19c.18.52.33.89.46 1.13.13.24.28.4.44.51.17.1.37.16.62.16.24 0 .49-.08.74-.25.33-.21.66-.58 1.01-1.09l-.21-.11c-.23.31-.41.5-.52.57a.44.44 0 01-.26.07c-.12 0-.24-.07-.36-.21-.2-.24-.46-.91-.8-2 .29-.49.54-.81.74-.96zM6.37 5.83l.68-2.53h.83l.2-.64h-.84c.24-.91.56-1.59.96-2.01.24-.27.48-.4.71-.4.05 0 .08.01.11.04s.04.06.04.1c0 .04-.03.11-.1.21-.06.1-.1.2-.1.29 0 .13.05.24.15.33.1.09.23.14.39.14.17 0 .31-.06.42-.17.12-.12.18-.27.18-.46 0-.21-.08-.39-.25-.52C9.57.07 9.3 0 8.93 0c-.59 0-1.12.16-1.59.48-.48.32-.93.85-1.36 1.59-.15.26-.29.42-.42.49s-.35.11-.64.1l-.19.65h.81L4.35 7.68c-.2.72-.33 1.16-.4 1.33-.1.24-.26.45-.46.62a.48.48 0 01-.31.1c-.03 0-.06-.01-.08-.03l-.03-.03c0-.02.03-.06.09-.11.06-.06.09-.15.09-.26 0-.13-.05-.23-.14-.32-.1-.09-.23-.13-.41-.13-.21 0-.38.05-.51.16A.52.52 0 002 9.4c0 .16.08.3.23.42.16.12.4.18.74.18.53 0 .99-.13 1.4-.39.41-.26.76-.65 1.07-1.19.3-.53.61-1.39.93-2.59zm2.34 3.46A.997.997 0 008 9c-.28 0-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V15c0 .55.45 1 1 1s1-.45 1-1v-2.59l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2z"],pulse:["M15 8h-1.46l-1.7-2.55-.02.01A.984.984 0 0011 5c-.43 0-.79.27-.93.65h-.01l-1.69 4.51-1.38-8.32h-.02A.989.989 0 006 1c-.41 0-.77.25-.92.61L2.34 8H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.41 0 .77-.25.92-.61l1.65-3.86 1.44 8.63h.02c.08.47.47.84.97.84.43 0 .79-.27.93-.65h.01l2.31-6.17.92 1.38.02-.01c.17.26.46.45.81.45h2c.55 0 1-.45 1-1s-.45-1-1-1z"],rain:["M3.5 8a2.5 2.5 0 11.608-4.926 4.002 4.002 0 017.381-1.03A3 3 0 1112 8H3.501zM3 10a1 1 0 012 0v4a1 1 0 11-2 0v-4zm7-1a1 1 0 00-1 1v5a1 1 0 102 0v-5a1 1 0 00-1-1zm2 1a1 1 0 112 0v2a1 1 0 11-2 0v-2zM7 9a1 1 0 00-1 1v2a1 1 0 102 0v-2a1 1 0 00-1-1z"],random:["M11.48 4h1.11l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H11c-.32 0-.59.16-.77.38l-.01-.01L8.28 4.8l1.28 1.6L11.48 4zm2.23 6.29a1.003 1.003 0 00-1.42 1.42l.3.29h-1.11l-7.7-9.62h-.01A.996.996 0 003 2H1c-.55 0-1 .45-1 1s.45 1 1 1h1.52l7.7 9.62.01-.01c.18.23.45.39.77.39h1.59l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2zM2.52 12H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.32 0 .59-.16.77-.38l.01.01 1.94-2.42L4.44 9.6 2.52 12z"],record:["M8 3a5 5 0 100 10A5 5 0 108 3z"],rectangle:["M1 3h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1zm1 2v6h12V5H2z"],redo:["M12 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3.71-6.71l-3-3a1.003 1.003 0 00-1.42 1.42L12.59 4H5C2.24 4 0 6.24 0 9s2.24 5 5 5h4v-2H5c-1.66 0-3-1.34-3-3s1.34-3 3-3h7.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],refresh:["M14.99 6.99c-.55 0-1 .45-1 1 0 3.31-2.69 6-6 6-1.77 0-3.36-.78-4.46-2h1.46c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-1.74a7.95 7.95 0 006 2.74c4.42 0 8-3.58 8-8 0-.55-.45-1-1-1zm0-7c-.55 0-1 .45-1 1v1.74a7.95 7.95 0 00-6-2.74c-4.42 0-8 3.58-8 8 0 .55.45 1 1 1s1-.45 1-1c0-3.31 2.69-6 6-6 1.77 0 3.36.78 4.46 2h-1.46c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"regression-chart":["M13 6.5c0 .83.67 1.5 1.5 1.5S16 7.33 16 6.5 15.33 5 14.5 5 13 5.67 13 6.5zM8.5 5c.83 0 1.5-.67 1.5-1.5S9.33 2 8.5 2 7 2.67 7 3.5 7.67 5 8.5 5zM9 9.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5S11.33 8 10.5 8 9 8.67 9 9.5zM4.5 8C5.33 8 6 7.33 6 6.5S5.33 5 4.5 5 3 5.67 3 6.5 3.67 8 4.5 8zM15 12H3.26l12.03-8.59-.58-.81L2 11.67V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],remove:["M10.99 6.99h-6c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm-3-7c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],"remove-column":["M14 0H4c-.55 0-1 .45-1 1v3h2V2h3v12H5v-2H3v3c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14h-3V2h3v12zm-8.71-3.29a1.003 1.003 0 001.42-1.42L4.41 8 5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L3 6.59l-1.29-1.3A1.003 1.003 0 00.29 6.71L1.59 8 .29 9.29a1.003 1.003 0 001.42 1.42L3 9.41l1.29 1.3z"],"remove-column-left":["M4 9h4c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm11-9H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 14H2V2h8v12zm4 0h-3V2h3v12z"],"remove-column-right":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 14H2V2h3v12zm9 0H6V2h8v12zM8 9h4c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-bottom":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V6h12v8zm0-9H2V2h12v3zm-8 6h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-top":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2v-3h12v3zm0-4H2V2h12v8zM6 7h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],repeat:["M10 5c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1.74A7.95 7.95 0 008 0C3.58 0 0 3.58 0 8c0 4.06 3.02 7.4 6.94 7.92.02 0 .04.01.06.01.33.04.66.07 1 .07 4.42 0 8-3.58 8-8 0-.55-.45-1-1-1s-1 .45-1 1c0 3.31-2.69 6-6 6-.71 0-1.37-.15-2-.38v.01C3.67 12.81 2 10.61 2 8c0-3.31 2.69-6 6-6 1.77 0 3.36.78 4.46 2H11c-.55 0-1 .45-1 1z"],reset:["M6 5c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v1.74A7.95 7.95 0 018 0c4.42 0 8 3.58 8 8 0 4.06-3.02 7.4-6.94 7.92-.02 0-.04.01-.06.01-.33.04-.66.07-1 .07-4.42 0-8-3.58-8-8 0-.55.45-1 1-1s1 .45 1 1c0 3.31 2.69 6 6 6 .71 0 1.37-.15 2-.38v.01c2.33-.82 4-3.02 4-5.63 0-3.31-2.69-6-6-6-1.77 0-3.36.78-4.46 2H5c.55 0 1 .45 1 1z"],resolve:["M6.6 3.3C6.1 3.1 5.6 3 5 3 2.2 3 0 5.2 0 8s2.2 5 5 5c.6 0 1.1-.1 1.6-.3C5.3 11.6 4.5 9.9 4.5 8s.8-3.6 2.1-4.7zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c-.6 0-1.1.1-1.6.3 1.3 1.2 2.1 2.9 2.1 4.7s-.8 3.6-2.1 4.7c.5.2 1 .3 1.6.3 2.8 0 5-2.2 5-5s-2.2-5-5-5z"],rig:["M5.71 3c0 1.1.96 2 2.14 2C9.04 5 10 3.96 10 3c0-1.96-1.47-3-2.14-3H5c0 1.96 2.68 1.4.71 3zm2.5 3l.01.01s0-.01-.01-.01zm6.5 8.29L10 9.59V7c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v2.58l-4.71 4.7c-.18.19-.29.44-.29.72a1.003 1.003 0 001.71.71L6 12.42V15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.58l3.29 3.29a1.003 1.003 0 001.42-1.42z"],"right-join":["M6.6 3.3C5.3 4.4 4.5 6.1 4.5 8s.8 3.6 2.1 4.7c-.5.2-1 .3-1.6.3-2.8 0-5-2.2-5-5s2.2-5 5-5c.6 0 1.1.1 1.6.3zm-1.96 8.68C3.92 10.83 3.5 9.46 3.5 8s.42-2.83 1.14-3.98C2.6 4.2 1 5.91 1 8s1.6 3.8 3.64 3.98zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3z"],ring:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 12c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],rocket:["M6 12C4.397 7.46 4.415 4.465 8 0c3.585 4.485 3.602 7.48 2 12H6zm3-7a1 1 0 11-2 0 1 1 0 012 0zm-7 8.022l3-1-.054-.158C4.636 10.954 4.076 9.317 4 8L3 9l-1 4.022zm9-1l3 1L13 9l-1-1c-.076 1.317-.635 2.954-.946 3.864l-.054.158zM7 13h2c0 1.5-.5 2.5-1 3-.5-.5-1-1.5-1-3z"],"rocket-slant":["M3.992 10c2-5 5-9 11-9 0 6-4 9-9 11l-2-2zm7.714-4.285a1 1 0 11-1.414-1.414 1 1 0 011.414 1.414zm-6.555-.218L2.992 6l-3 2L3.24 9.195c.542-1.301 1.166-2.556 1.911-3.698zM7.992 16l-1.236-3.232c1.3-.539 2.552-1.158 3.694-1.898L9.992 13l-2 3zm-4.931-4.94L5 13c-.992.991-2.186 1.154-3.001 1-.154-.815.07-1.948 1.06-2.94z"],"rotate-document":["M12 2h-1.59l.29-.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-2 2C7.11 2.47 7 2.72 7 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H12c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3zM5.71 5.29A.997.997 0 005 5H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V9c0-.28-.11-.53-.29-.71l-3-3zM7 14H2V7h2v2c0 .55.45 1 1 1h2v4z"],"rotate-page":["M8 6H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm-1 8H3V8h4v6zm5-12h-1.59l.29-.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-2 2C7.11 2.47 7 2.72 7 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H12c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3z"],route:["M11.669 5.066l.099.189c.113.213.236.434.367.661.226.39.468.78.709 1.151l-.198-.004-.48-.004c-1.745.003-2.369.233-2.369.688 0 .053.226.19 1.038.436l.84.24C13.9 9.064 15 9.83 15 11.63c0 2.123-1.607 3.122-4.027 3.366-.651.065-1.266.075-2.043.05l-.958-.035H5.196l.268-.406c.336-.517.672-1.052.998-1.593h1.636l.572.023c.857.036 1.475.034 2.103-.03 1.526-.153 2.227-.59 2.227-1.375 0-.531-.402-.84-1.66-1.22l-.691-.198c-1.04-.293-1.764-.562-2.222-.946C8.8 8.366 9 7.612 9 6.997a5.03 5.03 0 00-.184-1.334c.645-.395 1.598-.562 2.853-.597zM4 3a4.007 4.007 0 014 3.997C8 9.21 4 15 4 15l-.416-.62C2.56 12.827 0 8.767 0 6.997A4.002 4.002 0 014 3zm0 2a2 2 0 10.001 4.001A2 2 0 004 5zm10-4c1.103 0 1.996.896 2 1.999C16 4.105 14 7 14 7l-.293-.44C13.15 5.707 12 3.838 12 2.999 12 1.896 12.897 1 14 1z"],satellite:["M3 9c0-.6.4-1 1-1s1 .4 1 1c0 1.1.9 2 2 2 .6 0 1 .4 1 1s-.4 1-1 1c-2.2 0-4-1.8-4-4zM0 9c0-.6.4-1 1-1s1 .4 1 1c0 2.8 2.2 5 5 5 .6 0 1 .4 1 1s-.4 1-1 1c-3.9 0-7-3.1-7-7zm7 1c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1.3-2.8c-.4-.4-.4-1 0-1.4l4.5-4.5c.4-.4 1-.4 1.4 0l.5.5c.4.4.4 1 0 1.4l-4.5 4.5c-.4.4-1 .4-1.4 0l-.5-.5zM5.2.3c.4-.4 1-.4 1.4 0l2.1 2.1c.4.4.4 1 0 1.4l-.9.9c-.4.4-1 .4-1.4 0L4.3 2.6c-.4-.4-.4-1 0-1.4l.9-.9zm7 7c.4-.4 1-.4 1.4 0l2.1 2.1c.4.4.4 1 0 1.4l-.9.9c-.4.4-1 .4-1.4 0l-2.1-2.1c-.4-.4-.4-1 0-1.4l.9-.9z"],saved:["M6.71 9.29a1.003 1.003 0 00-1.42 1.42l2 2a.997.997 0 001.6-.27h.01l2-4h-.01c.06-.13.11-.28.11-.44 0-.55-.45-1-1-1-.39 0-.72.23-.89.56H9.1l-1.38 2.76-1.01-1.03zM9 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5L9 0zm3 14H4V2h4v4h4v8z"],"scatter-plot":["M15 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-.5-7c.83 0 1.5-.67 1.5-1.5S15.33 2 14.5 2 13 2.67 13 3.5 13.67 5 14.5 5zm-3 4c.83 0 1.5-.67 1.5-1.5S12.33 6 11.5 6 10 6.67 10 7.5 10.67 9 11.5 9zm-4-2C8.33 7 9 6.33 9 5.5S8.33 4 7.5 4 6 4.67 6 5.5 6.67 7 7.5 7zm-3 4c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"],search:["M15.55 13.43l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"search-around":["M13.5 11c-.51 0-.98.15-1.38.42l-2.4-2.41c.17-.3.28-.64.28-1.01s-.11-.71-.28-1.01l2.41-2.41c.39.27.86.42 1.37.42a2.5 2.5 0 000-5A2.5 2.5 0 0011 2.5c0 .51.15.98.42 1.38l-2.41 2.4C8.71 6.11 8.37 6 8 6s-.71.11-1.01.28l-2.41-2.4c.27-.4.42-.87.42-1.38a2.5 2.5 0 00-5 0A2.5 2.5 0 002.5 5c.51 0 .98-.15 1.38-.42l2.41 2.41C6.11 7.29 6 7.63 6 8s.11.71.28 1.01l-2.41 2.41c-.39-.27-.86-.42-1.37-.42a2.5 2.5 0 000 5A2.5 2.5 0 005 13.5c0-.51-.15-.98-.42-1.38l2.41-2.41c.3.18.64.29 1.01.29s.71-.11 1.01-.28l2.41 2.41c-.27.39-.42.86-.42 1.37a2.5 2.5 0 005 0 2.5 2.5 0 00-2.5-2.5zm0-10c.83 0 1.5.67 1.5 1.5S14.33 4 13.5 4 12 3.33 12 2.5 12.67 1 13.5 1zm-11 3C1.67 4 1 3.33 1 2.5S1.67 1 2.5 1 4 1.67 4 2.5 3.33 4 2.5 4zm0 11c-.83 0-1.5-.67-1.5-1.5S1.67 12 2.5 12s1.5.67 1.5 1.5S3.33 15 2.5 15zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],"search-template":["M15.55 13.43l-2.67-2.67c.7-1.09 1.11-2.38 1.11-3.77 0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.41 3.77-1.11l2.67 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm2.5-6h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm0-2h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm0 4h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5z"],"search-text":["M9 4H5c-.55 0-1 .45-1 1s.45 1 1 1h1v3c0 .55.45 1 1 1s1-.45 1-1V6h1c.55 0 1-.45 1-1s-.45-1-1-1zm6.56 9.44l-2.67-2.67C13.59 9.68 14 8.39 14 7c0-3.87-3.13-7-7-7S0 3.13 0 7s3.13 7 7 7c1.39 0 2.68-.41 3.77-1.11l2.67 2.67a1.498 1.498 0 102.12-2.12zM7 12c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"segmented-control":["M15 4H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 6H8V6h6v4z"],select:["M16 15c0-.28-.12-.52-.31-.69l.02-.02-3.12-3.12 3.41-.84-8.05-2.86c.03-.09.05-.17.05-.27V2c0-.55-.45-1-1-1H3c0-.55-.45-1-1-1S1 .45 1 1c-.55 0-1 .45-1 1s.45 1 1 1v4c0 .55.45 1 1 1h5.2c.1 0 .18-.02.27-.05L10.33 16l.85-3.41 3.12 3.12.02-.02c.16.19.4.31.68.31.04 0 .07-.02.1-.02s.06.02.1.02c.44 0 .8-.36.8-.8 0-.04-.02-.07-.02-.1s.02-.06.02-.1zM6 6H3V3h3v3z"],selection:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm0-9C6.34 5 5 6.34 5 8s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"send-message":["M15.399 9.01L1.527 15.875c-.535.267-1.175.081-1.421-.427A.953.953 0 010 15V10l8-2-8-2V1c0-.528.407-1 1.004-1 .169 0 .416.04.567.116L15.403 7.07a1.084 1.084 0 01-.005 1.939z"],"send-to":["M15 7.5c-.8 0-1.5-.4-2-1l-1.2 1.2c-.4.5-1.1.7-1.8.7-1.4.1-2.5-1-2.5-2.4 0-.7.3-1.3.7-1.8L9.5 3c-.6-.5-1-1.2-1-2 0-.3.1-.7.2-1H8C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8v-.7c-.3.1-.6.2-1 .2zM15 0h-4c-.6 0-1 .5-1 1s.4 1 1 1h1.6L9.3 5.3c-.2.2-.3.4-.3.7 0 .5.4 1 1 1 .3 0 .5-.1.7-.3L14 3.4V5c0 .6.4 1 1 1 .5 0 1-.4 1-1V1c0-.5-.4-1-1-1z"],"send-to-graph":["M6 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zm8 .5c-.56 0-1.06.23-1.42.59l-2.13-1.24L8.99 8l3.59-2.09A2.002 2.002 0 0016 4.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .19.03.37.08.54L8.5 7.13v-3.2c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v3.2l-.88-.52-2.7-1.57c.05-.17.08-.35.08-.54 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.56 0 1.06-.23 1.42-.59l2.13 1.24 3.84 2.24 2.7 1.57c-.06.17-.09.35-.09.54 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"send-to-map":["M6 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zm9.55-5.83l-4.49-3A.975.975 0 009.99.15L5.53 2.82 1.56.17A1.003 1.003 0 000 1v6h2V2.87l2.94 1.96.06.03V7h1V4.86s.01 0 .01-.01L10 2.47v8.67s-.01 0-.01.01l-.99.58v2.33l1.47-.88 3.97 2.65A1.003 1.003 0 0016 15V4c0-.35-.18-.65-.45-.83zM14 13.13l-2.94-1.96c-.02-.01-.04-.02-.05-.03v-8.6l3 2v8.59z"],"series-add":["M10.68 7.9c.44.54 1.07.92 1.79 1.05l-2.76 2.76c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l1.68-1.69zM15 3c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 1-1s1 .45 1 1v1h1z"],"series-configuration":["M9.94 9.64c.65.23 1.34.36 2.06.36.14 0 .29-.01.43-.01L9.7 12.71c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.3L5 9.41l-3 3V14h12.99c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 7.11 4.72 7 5 7c.28 0 .53.11.71.29L9 10.59l.94-.95zm4.73-6.44h.92c.22 0 .4.18.4.4v.8c0 .22-.18.4-.4.4h-.93c-.06.2-.14.38-.24.55l.66.65c.15.15.15.4 0 .55l-.54.55c-.15.15-.4.15-.55 0l-.65-.65c-.17.1-.36.18-.55.24v.91c0 .22-.18.4-.4.4h-.8c-.22 0-.4-.18-.4-.4v-.93c-.18-.06-.36-.13-.52-.22l-.68.68c-.15.16-.41.16-.57 0l-.56-.56a.417.417 0 010-.57l.68-.68c-.08-.16-.16-.33-.22-.52h-.93c-.22 0-.4-.18-.4-.4v-.8c0-.22.18-.4.4-.4h.93c.06-.2.14-.38.24-.55l-.65-.64a.392.392 0 010-.55l.54-.55a.38.38 0 01.54 0l.65.65c.18-.1.36-.18.55-.24V.4c0-.22.18-.4.4-.4h.8c.22 0 .4.18.4.4v.93c.18.06.35.14.52.22l.68-.68c.15-.16.41-.16.57 0l.57.57c.15.16.15.41 0 .57l-.68.68c.09.16.16.33.22.51zm-4.18.8c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5-.67-1.5-1.5-1.5c-.82 0-1.5.67-1.5 1.5z"],"series-derived":["M10.66 7.92c.44.54 1.07.91 1.8 1.03L9.71 11.7c-.18.19-.43.3-.71.3s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l1.66-1.67zM12.3 5.3l.3-.3H8c-.6 0-1-.4-1-1s.4-1 1-1h4.6l-.3-.3c-.2-.2-.3-.4-.3-.7 0-.6.5-1 1-1 .3 0 .5.1.7.3l2 2c.2.2.3.4.3.7s-.1.5-.3.7l-2 2c-.2.2-.4.3-.7.3-.6 0-1-.4-1-1 0-.3.1-.5.3-.7z"],"series-filtered":["M9.29 9.3c.3.62.8 1.12 1.42 1.41l-1 1c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l.29-.29zM15.48 1c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V4.71L8.17 1.98A.566.566 0 018 1.57c0-.31.26-.57.57-.57h6.91z"],"series-search":["M9.6 8.94a4.937 4.937 0 001.82.01c.1-.01.22-.04.39-.08l.23-.07c.04-.01.08-.02.11-.04l.22.22-2.7 2.72c-.18.19-.43.3-.71.3s-.53-.11-.71-.3L4.98 8.41l-2.99 3V13h12.94c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V3.99c0-.55.45-1 1-1s1 .45 1 1v4.59l2.28-2.3c.17-.18.42-.29.7-.29s.53.11.7.29l3.28 3.3.64-.64zm6.22-.41c.1.12.17.27.18.44 0 .34-.27.61-.61.61a.57.57 0 01-.43-.18l-2.24-2.25c-.13.08-.26.16-.4.23-.02.01-.05.02-.07.03-.14.06-.27.12-.42.17h-.01c-.14.05-.29.08-.44.11-.04.01-.08.02-.11.02-.15.02-.3.04-.46.04-1.85 0-3.35-1.51-3.35-3.37S8.96 1.01 10.81 1c1.85 0 3.35 1.51 3.35 3.37 0 .16-.02.31-.04.47-.01.04-.01.07-.02.11-.02.15-.05.29-.1.44v.01c-.05.15-.11.28-.17.42-.01.02-.02.05-.03.07-.07.14-.14.27-.23.4l2.25 2.24zm-5.01-1.94c1.22 0 2.21-.99 2.21-2.22 0-1.23-.99-2.22-2.21-2.22S8.6 3.14 8.6 4.37c0 1.22.99 2.22 2.21 2.22z"],settings:["M3 1c0-.55-.45-1-1-1S1 .45 1 1v3h2V1zm0 4H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm12-4c0-.55-.45-1-1-1s-1 .45-1 1v2h2V1zM9 1c0-.55-.45-1-1-1S7 .45 7 1v6h2V1zM1 15c0 .55.45 1 1 1s1-.45 1-1v-5H1v5zM15 4h-2c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-2 11c0 .55.45 1 1 1s1-.45 1-1V9h-2v6zM9 8H7c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-2 7c0 .55.45 1 1 1s1-.45 1-1v-2H7v2z"],shapes:["M5.92 8.139c.44-.282 1.006-.121 1.264.358l2.689 4.988c.083.155.127.33.127.51C10 14.55 9.587 15 9.077 15H3.924a.864.864 0 01-.438-.12c-.449-.263-.617-.873-.376-1.362l2.465-4.989c.08-.162.2-.297.346-.39zM12 4a3 3 0 110 6 3 3 0 010-6zM6 1a1 1 0 011 1v4a1 1 0 01-1 1H2a1 1 0 01-1-1V2a1 1 0 011-1h4z"],share:["M10.99 13.99h-9v-9h4.76l2-2H.99c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V7.24l-2 2v4.75zm4-14h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L7.29 7.28a1 1 0 00-.3.71 1.003 1.003 0 001.71.71l5.29-5.29V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"],"shared-filter":["M13.843 15.163c.232.53.138.837.138.837H6.017s-.088-.308.138-.837c.226-.53 1.338-.88 2.079-1.206.735-.332.66-.53.685-.8 0-.03.006-.068.006-.105a2.171 2.171 0 01-.61-.892v-.006s-.006-.006-.006-.012c-.025-.074-.056-.16-.075-.24-.176-.031-.276-.222-.314-.394a.8.8 0 01-.1-.437c.025-.253.131-.37.244-.419v-.037c0-.313.032-.775.088-1.07A1.835 1.835 0 018.85 8.37c.315-.24.76-.37 1.156-.37.396 0 .842.13 1.156.37.301.233.534.56.64.935.026.08.045.166.057.246.057.295.088.75.088 1.064v.043c.113.05.214.167.232.413a.75.75 0 01-.1.437c-.038.172-.132.357-.301.387a1.77 1.77 0 01-.076.24.136.136 0 01-.006.025 2.346 2.346 0 01-.597.892v.111c.025.277-.075.474.666.8.741.326 1.853.67 2.079 1.2z","M14.852 15h1.131s.083-.27-.12-.732c-.16-.373-.82-.641-1.411-.88a15.328 15.328 0 01-.409-.17c-.565-.25-.57-.412-.577-.61-.001-.03-.002-.06-.005-.09v-.097c.22-.2.401-.469.522-.781 0 0 .005-.016.005-.022.028-.07.05-.14.066-.21.149-.026.231-.188.264-.339a.655.655 0 00.088-.382c-.016-.215-.104-.318-.203-.36v-.039c0-.274-.028-.673-.077-.931a1.598 1.598 0 00-.61-1.034 1.736 1.736 0 00-1.285-.3c.236.285.42.622.529.996.038.124.065.248.083.36.048.257.079.578.093.867a1.736 1.736 0 01.08 1.624 1.65 1.65 0 01-.217.453 1.42 1.42 0 01-.176.209c-.08.204-.178.4-.292.585l.202.083c.285.117.64.261.9.387.226.11.475.245.698.414.213.161.476.408.63.764.034.08.065.159.091.235zM12.14 14.12l.09.037zM11 1c.55 0 1 .45 1 1 0 .28-.11.53-.29.7L8 6.41v1.374a2.813 2.813 0 00-.833 1.589 6.925 6.925 0 00-.092.86 1.64 1.64 0 00-.25.739l-.001.004c-.02.217.006.413.046.573L5.71 12.71A1.003 1.003 0 014 12V6.41L.29 2.71A1.003 1.003 0 011 1h10z"],shield:["M8 16c4.667-3.048 7-7.238 7-12.571-1.556 0-3.889-1.143-7-3.429-3.111 2.286-5.444 3.429-7 3.429C1 8.762 3.333 12.952 8 16zM8 2.121c2.005 1.388 3.715 2.304 5.186 2.735-.342 3.702-2.05 6.683-5.186 9.038V2.121z"],ship:["M5.44.804L5.2 2H3a1 1 0 00-1 1v3.714l-1.08.309a.988.988 0 00-.69 1.192c.366 1.432.897 3.324 1.309 4.26a.644.644 0 00.005.01c-.175.01-.356.015-.544.015a.5.5 0 000 1c2.067 0 3.414-.543 4.161-.917.55.373 1.505.917 2.839.917 1.32 0 2.27-.533 2.822-.905l.004.002c.196.105.48.24.856.374.75.268 1.857.529 3.318.529a.5.5 0 000-1c-.295 0-.572-.012-.834-.032a.995.995 0 00.308-.458l1.208-3.74a1 1 0 00-.677-1.269L14 6.714V3a1 1 0 00-1-1h-2.2L10.56.804A1 1 0 009.58 0H6.42a1 1 0 00-.98.804zM4 6.143l3-.857V4H4v2.143zm5-.857l3 .857V4H9v1.286zm-4.036 8.273a.5.5 0 01.527.034c.455.325 1.277.907 2.509.907s2.054-.582 2.51-.907a.5.5 0 01.579-.001l.006.004.036.023c.034.022.09.055.168.097.154.082.394.197.72.313.649.232 1.642.471 2.981.471a.5.5 0 010 1c-1.46 0-2.568-.261-3.318-.53a6.316 6.316 0 01-.856-.373l-.004-.002c-.552.372-1.502.905-2.822.905-1.334 0-2.289-.544-2.839-.917-.747.374-2.094.917-4.161.917a.5.5 0 010-1c2.129 0 3.384-.63 3.964-.94z"],shop:["M3 2h10c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1s.45 1 1 1zm9 11H4v-3H2v5c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-5h-2v3zm4-6l-1.01-3.17C14.9 3.36 14.49 3 14 3H2c-.49 0-.9.36-.98.83L.01 7H0c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2z"],"shopping-cart":["M14 10H7.72l-.33-1H13c.39 0 .72-.23.89-.56h.01l2-4h-.01c.06-.13.11-.28.11-.44 0-.55-.45-1-1-1H5.39l-.44-1.32h-.01C4.8 1.29 4.44 1 4 1H1c-.55 0-1 .45-1 1s.45 1 1 1h2.28l2.33 7H4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2h6c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zM6.05 5h7.33l-1 2H6.72l-.67-2z"],"signal-search":["M5.474 7.971A5.31 5.31 0 006.66 8.9l.007.019.018.056c.015.038.038.06.045.098l1.5 5.999a.75.75 0 01-1.455.36l-.42-1.68h-.704l-.42 1.68a.746.746 0 01-.907.547.746.746 0 01-.547-.907l1.5-6c.007-.037.03-.06.044-.097.015-.037.015-.075.038-.112a.722.722 0 01-.105-.36c0-.207.084-.394.22-.53zM2.795 5.277a.763.763 0 00-.015-1.065.756.756 0 00-1.065.015c-2.286 2.34-2.286 6.21 0 8.549a.747.747 0 101.072-1.042c-1.709-1.763-1.709-4.702.008-6.457zM7.808 9.388a5.318 5.318 0 001.58.211 2.236 2.236 0 01-.656.98.756.756 0 01-1.057-.098.756.756 0 01.097-1.057l.036-.036zM11.544 9.105l.378.378a6.02 6.02 0 01-1.638 3.285c-.285.3-.757.3-1.057.015a.74.74 0 01-.015-1.057 4.52 4.52 0 001.185-2.24c.4-.083.785-.212 1.147-.381z","M4.054 9.424c-.427-.352-.352-1.582-.03-1.822a.752.752 0 00.15-1.05.752.752 0 00-1.05-.15c-1.079.802-1.221 3.18-.03 4.177a.75.75 0 10.96-1.155zM9.318 0a4.318 4.318 0 014.317 4.318c0 .206-.02.402-.049.598-.01.05-.01.088-.02.138-.039.196-.078.382-.137.569v.01c-.059.186-.137.363-.216.54l-.039.087a5.285 5.285 0 01-.294.51l2.884 2.886a.878.878 0 01.236.559.787.787 0 01-.785.785.785.785 0 01-.56-.226L11.772 7.89a5.285 5.285 0 01-.51.295l-.089.039c-.176.079-.353.157-.54.216h-.01a3.701 3.701 0 01-.568.137c-.05.01-.099.02-.138.02-.196.03-.392.049-.598.049A4.318 4.318 0 015 4.327 4.332 4.332 0 019.318 0zm-.02 1.1A3.195 3.195 0 006.1 4.298a3.195 3.195 0 003.198 3.198 3.195 3.195 0 003.198-3.198A3.195 3.195 0 009.298 1.1z"],"sim-card":["M13.71 4.29l-4-4A.997.997 0 009 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.28-.11-.53-.29-.71zM7 6h2v2H7V6zM4 6h2v2H4V6zm2 8H4v-2h2v2zm3 0H7v-2h2v2zm3 0h-2v-2h2v2zm0-3H4V9h8v2zm0-3h-2V6h2v2z"],slash:["M10 2a.99.99 0 00-.96.73l-2.99 9.96A1.003 1.003 0 007 14c.46 0 .85-.31.96-.73l2.99-9.96A1.003 1.003 0 0010 2z"],"small-cross":["M9.41 8l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42L6.59 8 4.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z"],"small-minus":["M11 7H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-plus":["M11 7H9V5c0-.55-.45-1-1-1s-1 .45-1 1v2H5c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V9h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-square":["M5 5v6h6V5H5zM4 3a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V4a1 1 0 00-1-1H4z"],"small-tick":["M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z"],snowflake:["M13.364 9l.879.879a1 1 0 11-1.415 1.414l-2.12-2.121A1.003 1.003 0 0110.568 9H9v1.604c.042.03.083.065.121.103l2.122 2.121a1 1 0 01-1.415 1.415L9 13.414V15a1 1 0 01-2 0v-1.636l-.879.879a1 1 0 11-1.414-1.415l2.121-2.12c.054-.054.111-.1.172-.139V9H5.38c-.038.06-.084.118-.137.172l-2.122 2.12A1 1 0 111.707 9.88L2.586 9H1a1 1 0 110-2h1.536l-.829-.828a1 1 0 011.414-1.415L5.243 6.88c.038.038.072.079.103.121H7V5.38a1.003 1.003 0 01-.172-.137L4.708 3.12A1 1 0 016.12 1.707L7 2.586V1a1 1 0 112 0v1.536l.828-.829a1 1 0 011.415 1.414L9.12 5.243A1.007 1.007 0 019 5.346V7h1.604c.03-.042.065-.083.103-.121l2.121-2.122a1 1 0 011.415 1.415L13.414 7H15a1 1 0 010 2h-1.636z"],"social-media":["M9.5 4c.4 0 .8-.1 1.1-.3C12 4.5 12.9 6 13 7.6c0 .5.5.9 1 .9.6 0 1-.4 1-1v-.2c-.2-2.4-1.5-4.4-3.5-5.5-.1-1-.9-1.8-2-1.8s-2 .9-2 2 .9 2 2 2zM4 8.5c0-.7-.4-1.3-.9-1.7.3-1.4 1.2-2.6 2.5-3.3.3-.1.6-.4.6-.9s-.4-1-1-1c-.2 0-.3 0-.5.1-1.9 1-3.2 2.8-3.6 5C.4 7.1 0 7.8 0 8.5c0 1.1.9 2 2 2s2-.9 2-2zm8.8 1.2c-1.1 0-2 .9-2 2v.3c-.8.6-1.8.9-2.8.9-1.2 0-2.3-.4-3.2-1.1-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.6.3.8C4.6 14.4 6.2 15 8 15c1.5 0 3-.5 4.1-1.3.2.1.5.1.7.1 1.1 0 2-.9 2-2s-.9-2.1-2-2.1z"],sort:["M5 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm3-9h7c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm7 2H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0 8H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-alphabetical":["M6 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 002 12a1.003 1.003 0 00-.71 1.71l2 2c.19.18.44.29.71.29.28 0 .53-.11.71-.29l2-2c.18-.18.29-.43.29-.71a.99.99 0 00-1-1zm7.93-.95v-1.04H9.25v1.11h2.94L9 14.96V16h5.02v-1.11h-3.27l3.18-3.84zm-1.42-4.84l.62 1.78H15L11.94.01H10.1L7 7.99h1.81l.64-1.78h3.06zm-1.52-4.24h.02l1.03 2.93H9.92l1.07-2.93z"],"sort-alphabetical-desc":["M5.99 11.99c-.28 0-.53.11-.71.29l-.29.29V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l2-2c.18-.18.29-.43.29-.71 0-.56-.45-1.01-1-1.01zM12.7 10h-1.38L9 15.99h1.36l.48-1.33h2.3l.46 1.33H15L12.7 10zm-1.51 3.67l.8-2.2h.02l.77 2.2h-1.59zm3.8-7.17h-4.57l4.45-5.12V0H8.34v1.48h4.1L7.99 6.59v1.39h7V6.5z"],"sort-asc":["M8 7h3c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h1c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm0 8h5c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm-3 1c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm10 1H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-desc":["M5 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm4 1H8c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H8c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm-2 4H8c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-numerical":["M6 11.99c-.28 0-.53.11-.71.29l-.29.3V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l2-2A1.003 1.003 0 006 11.99zm7.91-.08c-.06-.36-.17-.68-.33-.96-.16-.28-.37-.51-.64-.69-.27-.17-.61-.26-1.03-.26-.28 0-.54.06-.78.17-.23.11-.43.26-.6.45-.17.19-.3.41-.39.67a2.492 2.492 0 00-.04 1.52 1.623 1.623 0 00.89 1.03c.22.11.45.16.68.16.26 0 .5-.05.7-.15s.38-.26.53-.5l.02.02c-.01.16-.03.34-.07.54-.03.2-.09.4-.17.57-.08.18-.18.33-.31.45s-.29.19-.5.19a.63.63 0 01-.48-.21c-.13-.14-.21-.31-.25-.5H10.1c.03.25.1.48.19.68.1.2.22.37.38.5.16.14.33.24.54.31s.42.1.65.1c.39 0 .72-.09.99-.27.27-.18.49-.41.66-.7.17-.29.29-.61.37-.97.08-.36.12-.72.12-1.07 0-.36-.03-.72-.09-1.08zm-1.14.54c-.04.13-.09.24-.16.34a.78.78 0 01-.27.24c-.11.06-.24.09-.39.09a.75.75 0 01-.37-.09.777.777 0 01-.26-.25c-.07-.1-.12-.22-.15-.35-.03-.13-.05-.26-.05-.4 0-.13.02-.26.05-.39.04-.13.09-.24.16-.34.07-.1.16-.18.26-.24s.22-.09.35-.09c.14 0 .26.03.37.09.11.06.2.14.28.24a1.32 1.32 0 01.23.74c0 .15-.02.28-.05.41zm-1.56-4.47H13V0h-1.42c-.05.3-.16.56-.31.76-.16.21-.35.37-.58.5-.23.13-.49.21-.78.26-.3.05-.6.07-.91.06V2.8h2.21v5.18z"],"sort-numerical-desc":["M6 11.99c-.28 0-.53.11-.71.29l-.29.3V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29a.982.982 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 006 11.99zm7.86-9.45c-.09-.48-.26-.9-.5-1.28S12.8.58 12.4.35C12 .12 11.49 0 10.86 0c-.43 0-.82.07-1.17.22s-.65.35-.9.6-.44.55-.58.89c-.14.34-.2.71-.2 1.11 0 .31.05.61.15.91.1.3.26.57.48.8.23.24.52.43.85.58.33.14.68.21 1.03.21.4 0 .75-.07 1.05-.2.3-.13.57-.35.79-.66l.02.02c-.02.21-.05.45-.1.73-.05.27-.13.53-.25.76-.12.24-.27.44-.47.6-.19.16-.44.25-.75.25a.98.98 0 01-.72-.29c-.19-.18-.31-.4-.37-.66H8.15c.05.34.14.64.29.9.15.26.34.49.57.67.23.18.5.32.8.41.31.1.63.15.98.15.58 0 1.08-.12 1.48-.36.4-.24.73-.55.99-.93.26-.39.44-.82.56-1.29.12-.48.18-.96.18-1.44s-.05-.96-.14-1.44zm-1.71.72c-.05.17-.14.32-.24.46-.11.13-.24.24-.41.31-.16.08-.36.12-.58.12-.21 0-.39-.04-.55-.13-.16-.08-.29-.19-.39-.33-.12-.14-.19-.29-.24-.46-.05-.17-.08-.35-.08-.54 0-.18.03-.35.08-.52.06-.16.14-.31.25-.44.11-.13.24-.24.4-.32.16-.08.33-.12.52-.12.21 0 .4.04.56.12.16.08.3.19.41.32.11.14.2.29.26.46.06.17.09.35.09.52 0 .2-.03.38-.08.55zm-.46 7.31c-.12.15-.26.28-.44.37-.17.09-.37.16-.58.2-.22.04-.44.05-.67.05v.92h1.65v3.88h1.33V10h-1.06c-.03.23-.11.42-.23.57z"],"split-columns":["M12 10a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9V2h3v1.71c.31-.13.64-.21 1-.21s.69.08 1 .21V1c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2.71c.31-.13.64-.21 1-.21s.69.08 1 .21V2h3v5H3.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 9H7v5H4v-1.71c-.31.13-.64.21-1 .21s-.69-.08-1-.21V15c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-2.71c-.31.13-.64.21-1 .21s-.69-.08-1-.21V14H9V9h3.59l-.29.29c-.19.18-.3.43-.3.71z"],square:["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V2h12v12z"],"stacked-chart":["M10 2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3h3V2zm3 10h1c.55 0 1-.45 1-1V8h-3v3c0 .55.45 1 1 1zm2-7c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v2h3V5zm-5 1H7v3h3V6zM5 7c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v1h3V7zm3 5h1c.55 0 1-.45 1-1v-1H7v1c0 .55.45 1 1 1zm7 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h1c.55 0 1-.45 1-1V9H2v2c0 .55.45 1 1 1z"],"stadium-geometry":["M12 6H4a2 2 0 100 4h8a2 2 0 100-4zM4 4a4 4 0 100 8h8a4 4 0 000-8H4z"],star:["M8 0l2.5 5.3 5.5.8-4 4.1.9 5.8L8 13.3 3.1 16l.9-5.8-4-4.1 5.5-.8z"],"star-empty":["M16 6.11l-5.53-.84L8 0 5.53 5.27 0 6.11l4 4.1L3.06 16 8 13.27 12.94 16 12 10.21l4-4.1zM4.91 13.2l.59-3.62L3 7.02l3.45-.53L8 3.2l1.55 3.29 3.45.53-2.5 2.56.59 3.62L8 11.49 4.91 13.2z"],"step-backward":["M12 3c-.24 0-.44.09-.62.23l-.01-.01L7 6.72V4c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V9.28l4.38 3.5.01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"step-chart":["M15 12H2v-2h3c.55 0 1-.45 1-1V7h2v1c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h-2V6c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v2H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"step-forward":["M12 3h-1c-.55 0-1 .45-1 1v2.72l-4.38-3.5v.01A.987.987 0 005 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01L10 9.28V12c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stop:["M12 3H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stopwatch:["M9 2v1.083A6.002 6.002 0 018 15 6 6 0 017 3.083V2H6a1 1 0 110-2h4a1 1 0 010 2H9zM8 5a4 4 0 104 4H8V5z"],strikethrough:["M14 7H8.65c-.38-.09-.73-.18-1.04-.26-.31-.08-.49-.13-.54-.14-.43-.11-.79-.29-1.05-.52-.27-.23-.4-.55-.4-.95 0-.29.07-.53.21-.72s.32-.34.54-.46c.22-.11.46-.19.72-.24.26-.05.52-.07.77-.07.74 0 1.36.15 1.84.46.32.2.55.5.68.9h2.22c-.06-.33-.17-.64-.32-.92-.25-.45-.59-.84-1.02-1.15-.43-.31-.93-.54-1.49-.7S8.59 2 7.95 2c-.55 0-1.1.07-1.63.2-.54.13-1.02.34-1.45.62-.42.28-.76.63-1.02 1.05-.26.42-.39.92-.39 1.5 0 .3.04.59.13.88.08.26.21.51.39.75H2c-.55 0-1 .45-1 1s.45 1 1 1h7.13c.25.07.49.14.71.22.25.09.48.23.7.44.21.21.32.53.32.97 0 .21-.05.43-.14.63-.09.21-.24.39-.45.55-.21.16-.48.29-.81.39-.33.1-.73.15-1.2.15-.44 0-.84-.05-1.21-.14-.37-.09-.7-.24-.99-.43-.29-.2-.51-.45-.67-.76-.01 0-.01-.01-.02-.02H3.14a3.68 3.68 0 001.39 2.03c.46.34 1 .58 1.62.74.61.15 1.27.23 1.97.23.61 0 1.2-.07 1.79-.2.58-.13 1.11-.34 1.56-.63.46-.29.83-.66 1.11-1.11.28-.45.42-1 .42-1.64 0-.3-.05-.6-.15-.9-.05-.19-.13-.36-.22-.52H14c.55 0 1-.45 1-1s-.45-1-1-1z"],style:["M14 14H2V2h8.76l2-2H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6.24l-2 2V14zm1.4-14L9.7 5.7l2.1 2.1L16 3.6V0h-.6zM4 11.92c2.33.15 4.42.15 6.15-1.5.82-.83.82-2.25 0-3.08-.45-.38-.98-.6-1.5-.6-.53 0-1.05.22-1.43.6-.82.91-1.27 3.38-3.22 4.58z"],"swap-horizontal":["M0 7.02L.05 7H0v.02zm2-2.03h9.57l-1.29 1.29A1.003 1.003 0 0011.7 7.7l2.99-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2.99-3a1.07 1.07 0 00-.71-.28 1.003 1.003 0 00-.71 1.71L11.57 3H2c-.55 0-1 .45-1 1a1 1 0 001 .99zM15.96 9H16v-.02l-.04.02zM14 11.01H4.43l1.29-1.29A1.003 1.003 0 004.3 8.3l-2.99 3a.99.99 0 00-.29.7c0 .28.11.53.29.71l2.99 3a1.003 1.003 0 001.42-1.42L4.43 13H14c.55 0 1-.45 1-1s-.45-.99-1-.99z"],"swap-vertical":["M9 0h-.02L9 .04V0zM7 16h.02L7 15.95V16zM4.7 1.31c-.18-.18-.43-.29-.7-.29s-.53.11-.71.29l-3 2.99a1.003 1.003 0 001.42 1.42L3 4.43V14c0 .55.45 1 1 1s1-.45 1-1V4.43l1.29 1.29c.18.18.43.29.7.29A1.003 1.003 0 007.7 4.3l-3-2.99zM15 9.99c-.28 0-.53.11-.71.29L13 11.57V2c0-.55-.45-1-1-1s-1 .45-1 1v9.57l-1.29-1.29a.99.99 0 00-.7-.29 1.003 1.003 0 00-.71 1.71l3 2.99c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-2.99c.18-.18.29-.43.29-.71-.01-.55-.46-1-1.01-1z"],switch:["M9.293 2.293l1.414 1.414-4.999 5a3 3 0 11-1.415-1.415l5-5zM13 7a3 3 0 110 6 3 3 0 010-6zM3 9a1 1 0 100 2 1 1 0 000-2zm10 0a1 1 0 100 2 1 1 0 000-2z"],"symbol-circle":["M8 3.01a5 5 0 100 10 5 5 0 100-10z"],"symbol-cross":["M12 6.01h-2v-2c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v2H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2h2c.55 0 1-.45 1-1v-2c0-.56-.45-1-1-1z"],"symbol-diamond":["M12 8.01c0-.19-.07-.36-.16-.51l.01-.01-3-5-.01.01c-.17-.29-.48-.49-.84-.49s-.67.2-.84.49l-.02-.01-3 5 .02.01c-.09.15-.16.32-.16.51s.07.36.16.51h-.02l3 5 .01-.01c.18.29.49.5.85.5s.67-.2.84-.49l.01.01 3-5-.01-.01c.09-.16.16-.32.16-.51z"],"symbol-rectangle":["M13 4H3c-.5 0-1 .5-1 1v6c0 .5.5 1 1 1h10c.5 0 1-.5 1-1V5c0-.5-.5-1-1-1z"],"symbol-square":["M12 3.01H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-8c0-.56-.45-1-1-1z"],"symbol-triangle-down":["M13 4.01c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 .16.05.31.11.44H3.1l4 8h.01c.16.33.49.56.89.56s.72-.23.89-.56h.01l4-8h-.01c.06-.14.11-.28.11-.44z"],"symbol-triangle-up":["M12.89 11.56l-3.99-8h-.01c-.17-.32-.5-.55-.89-.55s-.72.23-.89.55H7.1l-4 8h.01c-.06.14-.11.29-.11.45 0 .55.45 1 1 1h8c.55 0 1-.45 1-1 0-.16-.05-.31-.11-.45z"],syringe:["M11.146.146a.5.5 0 000 .708l.647.646L10.5 2.793 8.854 1.146a.5.5 0 10-.708.708l.647.646-1.146 1.146-5.5 5.5a.5.5 0 000 .708l.646.646-1.647 1.646a.5.5 0 000 .708l.647.646-1.647 1.646a.5.5 0 00.708.708L2.5 14.207l.646.647a.5.5 0 00.708 0L5.5 13.207l.646.647a.5.5 0 00.708 0l5.5-5.5L13.5 7.207l.646.647a.5.5 0 00.708-.708L13.207 5.5 14.5 4.207l.646.647a.5.5 0 00.708-.708l-4-4a.5.5 0 00-.708 0zM11.293 8l-.793.793-1.646-1.647a.5.5 0 10-.708.708L9.793 9.5 8.5 10.793 6.854 9.146a.5.5 0 10-.708.708L7.793 11.5 6.5 12.793 3.207 9.5 8 4.707 11.293 8zM8.707 4L12 7.293l.793-.793L9.5 3.207 8.707 4zm-6.5 8.5L3.5 13.793 4.793 12.5 3.5 11.207 2.207 12.5zm11.586-9L12.5 2.207 11.207 3.5 12.5 4.793 13.793 3.5z"],tag:["M1 3a2 2 0 012-2h4.584a2 2 0 011.414.586l5.413 5.412a2 2 0 010 2.829L9.827 14.41a2 2 0 01-2.829 0L1.586 8.998A2 2 0 011 7.584V3zm3.487-.007a1.494 1.494 0 100 2.988 1.494 1.494 0 000-2.988z"],"take-action":["M9 11a1.003 1.003 0 001.71.71l4-4a1.003 1.003 0 00-1.42-1.42l-4 4c-.18.18-.29.43-.29.71zM4 6c.28 0 .53-.11.71-.29l4-4A1.003 1.003 0 007.29.29l-4 4A1.003 1.003 0 004 6zm4 4l5-5-.79-.79.5-.5a1.003 1.003 0 00-1.42-1.42l-.5.5L10 2 5 7l.79.79-5.5 5.5a1.003 1.003 0 001.42 1.42l5.5-5.5L8 10zm7 4H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],tank:["M3.7 3.4a1 1 0 01.8-.4h5.086a1 1 0 01.707.293L11 4h3a1 1 0 110 2h-3v1h2.5a2.5 2.5 0 010 5h-11a2.5 2.5 0 010-5H3V4.667a1 1 0 01.2-.6l.5-.667zM2.5 9h11a.5.5 0 010 1h-11a.5.5 0 110-1z"],target:["M7 4a1 1 0 012 0v2a1 1 0 01-2 0V4zM10 7a1 1 0 000 2h2a1 1 0 000-2h-2zM3 8a1 1 0 011-1h2a1 1 0 010 2H4a1 1 0 01-1-1zM8 9a1 1 0 00-1 1v2a1 1 0 002 0v-2a1 1 0 00-1-1z","M8 16A8 8 0 108 0a8 8 0 000 16zm0-2A6 6 0 108 2a6 6 0 000 12z"],taxi:["M15.12 6.63h-.38L15 7c-.01.3-.01.64 0 .98V8c0 .07-.03.13-.04.19h.02L14 13.1v.9c0 .55-.45 1-1 1s-1-.45-1-1v-1H4v1c0 .55-.45 1-1 1s-1-.45-1-1v-.9l-.98-4.9h.02C1.03 8.13 1 8.07 1 8H.99c0-.33 0-.67.01-1l.26-.37H.88C.4 6.63 0 6.21 0 5.69s.4-.94.88-.94h1.05l.77-2.11c.19-.53.76-1.08 1.26-1.24 0 0 .68-.2 2.05-.32C6.01 1.05 6 1.03 6 1c0-.55.45-1 1-1h2c.55 0 1 .45 1 1 0 .03-.01.05-.02.08 1.37.12 2.05.32 2.05.32.51.15 1.08.71 1.27 1.24l.76 2.12h1.05c.49 0 .89.42.89.93 0 .52-.4.94-.88.94zM11 10h2V8h-2v2zm-8 0h2V8H3v2zm10-5l-.73-1.63C12.21 3.19 12.18 3 12 3H4c-.18 0-.21.19-.27.37L3 5c-.06.18-.18 1 0 1h10c.18 0 .06-.82 0-1z"],temperature:["M8.5 0A1.5 1.5 0 007 1.5v7.837a3.5 3.5 0 103 0V1.5A1.5 1.5 0 008.5 0zM2 5.5a.5.5 0 01.5-.5h3a.5.5 0 010 1h-3a.5.5 0 01-.5-.5zM2.5 1a.5.5 0 000 1h3a.5.5 0 000-1h-3zM4 3.5a.5.5 0 01.5-.5h1a.5.5 0 010 1h-1a.5.5 0 01-.5-.5zM4.5 7a.5.5 0 000 1h1a.5.5 0 000-1h-1z"],"text-highlight":["M9 10H2V6h7V4H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h8v-2zm4 3h-1V3h1c.55 0 1-.45 1-1s-.45-1-1-1h-1c-.37 0-.7.11-1 .28-.3-.17-.63-.28-1-.28H9c-.55 0-1 .45-1 1s.45 1 1 1h1v10H9c-.55 0-1 .45-1 1s.45 1 1 1h1c.37 0 .7-.11 1-.28.3.17.63.28 1 .28h1c.55 0 1-.45 1-1s-.45-1-1-1zm2-9h-2v2h1v4h-1v2h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],th:["M15 1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1zM6 13H2v-2h4v2zm0-3H2V8h4v2zm0-3H2V5h4v2zm8 6H7v-2h7v2zm0-3H7V8h7v2zm0-3H7V5h7v2z"],"th-derived":["M5.6 10l-.3.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l2-2c.2-.2.3-.4.3-.7s-.1-.5-.3-.7l-2-2C6.5 6.1 6.3 6 6 6c-.5 0-1 .4-1 1 0 .3.1.5.3.7l.3.3H1c-.6 0-1 .4-1 1s.4 1 1 1h4.6zM15 1H2c-.5 0-1 .5-1 1v5h2V5h11v2H8.8l.6.6c.1.1.2.3.3.4H14v2H9.7c-.1.1-.2.3-.3.4l-.6.6H14v2H3v-2H1v3c0 .5.5 1 1 1h13c.6 0 1-.5 1-1V2c0-.5-.4-1-1-1z"],"th-disconnect":["M12 1h3c.6 0 1 .5 1 1v12c0 .6-.4 1-1 1h-4.97l.286-2H14v-2h-3.398l.143-1H14V8h-2.97l.143-1H14V5h-2.541l.51-3.576C11.99 1.282 12 1.14 12 1zM5.97 1l-.572 4H2v2h3.112L4.97 8H2v2h2.684l-.143 1H2v2h2.255l-.225 1.576c-.02.142-.03.284-.03.424H1c-.6 0-1-.4-1-1V2c0-.5.4-1 1-1h4.97zM8.01.859a1 1 0 111.98.282l-2 14a1 1 0 11-1.98-.282l2-14z"],"th-filtered":["M10 10h3l1.78-2.226a1 1 0 00.22-.625V4.3l1-.9V14c0 .6-.4 1-1 1H1c-.6 0-1-.4-1-1V2c0-.5.4-1 1-1h4.333L9 4.3V5H7v2h2v1H7v2h3zm-4 3v-2H2v2h4zm0-3V8H2v2h4zm0-3V5H2v2h4zm8 6v-2H7v2h7z","M15.48 0c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V3.71L8.17.98A.566.566 0 018 .57c0-.31.26-.57.57-.57h6.91z"],"th-list":["M15 1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1zm-1 12H2v-2h12v2zm0-3H2V8h12v2zm0-3H2V5h12v2z"],"third-party":["M4.448 9h.573c.025-.044.051-.088.079-.13A9.43 9.43 0 015.183 8h-.995A10.424 10.424 0 014 6c0-.717.068-1.391.188-2h3.624c.065.33.114.678.146 1.042A3.42 3.42 0 018.46 5c.168 0 .336.013.502.037A11.089 11.089 0 008.829 4h1.755c.148.338.26.696.33 1.068l.176-.028a2.74 2.74 0 01.5 0c.113 0 .225.006.336.018A6.001 6.001 0 000 6a6 6 0 005.672 5.991 4 4 0 01-.202-.441 1.842 1.842 0 01-.24-.26 1.82 1.82 0 01-.26-.55 2 2 0 01-.185-.92l-.012-.025A6.036 6.036 0 014.448 9zM3.171 8H1.416A4.983 4.983 0 011 6c0-.711.148-1.388.416-2h1.755C3.06 4.626 3 5.299 3 6c0 .701.06 1.374.17 2zM2 9H3.4c.18.618.412 1.167.685 1.62A5.015 5.015 0 012 9zm2.448-6h3.104a6.036 6.036 0 00-.325-.795C6.737 1.225 6.246 1 6 1c-.246 0-.737.225-1.227 1.205-.119.238-.228.504-.325.795zm4.15 0H10a5.016 5.016 0 00-2.086-1.62c.273.453.506 1.002.685 1.62zM4.087 1.38A6.834 6.834 0 003.401 3H2a5.015 5.015 0 012.086-1.62zM13.476 16s.118-.385-.172-1.046c-.228-.533-1.172-.915-2.015-1.257a22.113 22.113 0 01-.584-.243c-.808-.356-.816-.588-.825-.872-.002-.041-.003-.084-.007-.128v-.139c.314-.284.573-.669.745-1.115 0 0 .008-.023.008-.03.04-.1.071-.2.095-.3.212-.04.33-.27.377-.485.054-.093.149-.3.125-.547-.024-.307-.15-.453-.29-.515v-.054c0-.392-.04-.961-.11-1.33a2.16 2.16 0 00-.071-.308 2.283 2.283 0 00-.8-1.17C9.558 6.162 9.001 6 8.506 6c-.495 0-1.052.162-1.445.462A2.294 2.294 0 006.19 7.93c-.07.369-.11.946-.11 1.338v.046c-.14.062-.274.208-.306.523a1 1 0 00.126.547c.047.215.173.453.393.492.02.083.05.172.078.253l.016.047c0 .008.008.015.008.015v.008c.172.454.44.846.761 1.115a.804.804 0 01-.004.072c-.002.02-.004.04-.004.06l-.007.105c-.016.287-.028.523-.848.894-.176.078-.37.156-.568.237-.847.345-1.802.735-2.031 1.27C3.41 15.616 3.52 16 3.52 16h9.955zm2.503-1.25h-1.413a4.05 4.05 0 00-.116-.294c-.192-.445-.52-.753-.787-.955-.278-.21-.59-.38-.873-.517a21.373 21.373 0 00-1.122-.483l-.02-.008-.235-.097c.144-.23.266-.476.366-.731.089-.087.162-.177.22-.26.132-.192.217-.391.271-.568.117-.251.24-.64.199-1.105a2.025 2.025 0 00-.299-.925 8.626 8.626 0 00-.116-1.083 3.426 3.426 0 00-.104-.45 3.476 3.476 0 00-.661-1.246A2.18 2.18 0 0111.63 6c.432 0 .92.141 1.264.404.33.256.584.612.7 1.023.028.087.049.182.062.27.062.322.097.82.097 1.163v.048c.123.053.233.181.254.45a.82.82 0 01-.11.478c-.041.189-.144.391-.33.425a1.92 1.92 0 01-.082.262c0 .007-.007.027-.007.027-.151.39-.378.727-.653.976v.121c.004.038.005.075.006.111v.002c.008.247.015.451.722.762.158.07.332.14.51.213.739.299 1.565.634 1.764 1.1.254.579.151.915.151.915z"],"thumbs-down":["M2 2H0v7h2c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm13.99 4.38c.08-.58-.44-1.02-1.15-1.05-.25-.01-.52-.03-.81-.05.02 0 .05-.01.07-.01.7-.1 1.34-.49 1.41-1.07.06-.58-.46-.97-1.17-1.04-.25-.02-.52-.04-.79-.06.47-.15.84-.42.87-.93.04-.58-.79-1.03-1.5-1.09-.27-.02-.51-.04-.73-.05h-.09c-.23-.02-.43-.02-.62-.03C8.35.95 5.66 1.47 4 2.51v6c2.14 1.29 4.76 3.59 4.21 5.51-.18.59.31 1.05.98.98.81-.09 1.37-.91 1.4-1.78.04-1-.15-2.01-.5-2.91-.04-.25.01-.5.37-.53.49-.03 1.11-.06 1.59-.08.26 0 .51-.01.75-.02h.01c.41-.02.8-.05 1.13-.09.7-.09 1.35-.47 1.43-1.05.08-.58-.44-.97-1.15-1.05-.05-.01-.11-.01-.16-.02.17-.01.33-.03.49-.05.72-.08 1.37-.46 1.44-1.04z"],"thumbs-up":["M15.99 9.62c-.08-.58-.73-.96-1.43-1.05-.15-.02-.32-.04-.49-.05.06-.01.11-.01.16-.02.71-.08 1.23-.47 1.15-1.05-.08-.58-.73-.96-1.43-1.05-.34-.04-.72-.07-1.13-.09h-.01c-.24-.01-.49-.02-.75-.02-.48-.02-1.11-.04-1.59-.08-.36-.03-.41-.28-.37-.53.35-.9.54-1.91.5-2.91-.04-.85-.6-1.68-1.41-1.77-.67-.07-1.16.39-.99.98C8.76 3.91 6.13 6.2 4 7.49v6c1.66 1.03 4.35 1.56 7.48 1.5.19 0 .39-.01.62-.02h.09c.22-.01.46-.03.73-.05.71-.06 1.54-.51 1.5-1.09-.03-.51-.4-.79-.87-.93.27-.02.54-.04.79-.06.71-.06 1.24-.45 1.17-1.04-.06-.58-.7-.97-1.41-1.07-.02 0-.05-.01-.07-.01.29-.02.57-.03.81-.05.71-.03 1.23-.47 1.15-1.05zM2 7H0v7h2c.55 0 1-.45 1-1V8c0-.56-.45-1-1-1z"],tick:["M14 3c-.28 0-.53.11-.71.29L6 10.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l8-8A1.003 1.003 0 0014 3z"],"tick-circle":["M8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm4-11c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z"],time:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm1-6.41V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L9 7.59z"],"timeline-area-chart":["M15 2.59L9.91 7.68 6.6 5.2l-.01.01C6.42 5.09 6.23 5 6 5c-.24 0-.44.09-.62.23v-.01L3 7.12V11h12V2.59zM15 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"timeline-bar-chart":["M8 12h1c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1zm5 0h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm2 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h1c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1z"],"timeline-events":["M8 11H7v1h1v-1zm-4 0H3v1h1v-1zm7-8c.6 0 1-.5 1-1V1c0-.5-.4-1-1-1s-1 .5-1 1v1c0 .5.5 1 1 1zM4 3c.5 0 1-.5 1-1V1c0-.5-.5-1-1-1S3 .5 3 1v1c0 .5.5 1 1 1zm10-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H6v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H1c-.5 0-1 .5-1 1v12c0 .5.5 1 1 1h13c.6 0 1-.5 1-1V2c0-.5-.4-1-1-1zM5 13H2v-3h3v3zm0-4H2V6h3v3zm4 4H6v-3h3v3zm0-4H6V6h3v3zm4 4h-3v-3h3v3zm0-4h-3V6h3v3zm-1-2h-1v1h1V7z"],"timeline-line-chart":["M15 12H2V9.41l3-3L8.29 9.7c.18.19.43.3.71.3s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L9 7.59l-3.29-3.3C5.53 4.11 5.28 4 5 4s-.53.11-.71.29L2 6.59V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],tint:["M7.88 1s-4.9 6.28-4.9 8.9c.01 2.82 2.34 5.1 4.99 5.1 2.65-.01 5.03-2.3 5.03-5.13C12.99 7.17 7.88 1 7.88 1z"],torch:["M5 15c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H5v1zm7-15H4c-.55 0-1 .45-1 1v1h10V1c0-.55-.45-1-1-1zM5 7v6h6V7l2-4H3l2 4zm2 0c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1V7z"],tractor:["M3.5 9a3.5 3.5 0 110 7 3.5 3.5 0 010-7zm9.5 1a3 3 0 110 6 3 3 0 010-6zm-9.5 1a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm9.5 1a1 1 0 100 2 1 1 0 000-2zM5 0c1.46 0 2.527.668 3 2l.815 3.255a78.9 78.9 0 012.186.195L11 2h2l.001 3.688c.698.095 1.37.198 2.013.312.623.11.986.479.986 1v3.354a4.001 4.001 0 00-6.873 1.645H7.999l-.026-.002A4.5 4.5 0 00.659 9.01l-.654.001v-.829C.003 7.386.002 6.423 0 6.022 0 5.5.376 4.99 1 4.99V1a1 1 0 011-1h3zm1 2H3v2.99c1.29.024 2.554.069 3.781.135L6 2z"],train:["M13 14h-1l1 2H3l1-2H3c-1.1 0-2-.9-2-2V2C1 .9 4.13 0 8 0s7 .9 7 2v10c0 1.1-.9 2-2 2zm-2-2h2v-2h-2v2zM9 7h4V3H9v4zm-6 5h2v-2H3v2zm0-5h4V3H3v4z"],translate:["M15.89 14.56l-3.99-8h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56h-.01L9 8.76 7.17 7.38l.23-.18C8.37 6.47 9 5.31 9 4V3h1c.55 0 1-.45 1-1s-.45-1-1-1H7c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H1c-.55 0-1 .45-1 1s.45 1 1 1h6v1c0 .66-.32 1.25-.82 1.61l-.68.51-.68-.5C4.32 5.25 4 4.66 4 4H2c0 1.31.63 2.47 1.6 3.2l.23.17L1.4 9.2l.01.01C1.17 9.4 1 9.67 1 10c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01 2.9-2.17 2.6 1.95-1.99 3.98h.01c-.07.13-.12.28-.12.44 0 .55.45 1 1 1 .39 0 .72-.23.89-.56h.01L8.62 14h4.76l.72 1.45h.01c.17.32.5.55.89.55.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44zM9.62 12L11 9.24 12.38 12H9.62z"],trash:["M14.49 3.99h-13c-.28 0-.5.22-.5.5s.22.5.5.5h.5v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10h.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm-8.5 9c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm3 0c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm3 0c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm2-12h-4c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1h-4c-.55 0-1 .45-1 1v1h14v-1c0-.55-.45-1-1-1z"],tree:["M9 11.857V16H7v-4.143L1 13l3.885-4.44L3 9l3.07-4.297L5 5l3-5 3 5-1.07-.297L13 9l-1.885-.44L15 13l-6-1.143z"],"trending-down":["M15 7c-.55 0-1 .45-1 1v.59l-4.29-4.3A.997.997 0 009 4c-.16 0-.31.05-.44.11V4.1L5 5.88 1.45 4.11v.01C1.31 4.05 1.16 4 1 4c-.55 0-1 .45-1 1 0 .39.23.72.56.89v.01l4 2v-.01c.13.06.28.11.44.11s.31-.05.44-.11v.01L8.8 6.22 12.59 10H12c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1z"],"trending-up":["M15 4h-3c-.55 0-1 .45-1 1s.45 1 1 1h.59L8.8 9.78 5.45 8.11v.01C5.31 8.05 5.16 8 5 8s-.31.05-.44.11V8.1l-4 2v.01c-.33.17-.56.5-.56.89 0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L5 10.12l3.55 1.78v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L14 7.41V8c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1z"],truck:["M12.5 0a.5.5 0 01.5.5V9a1 1 0 011 1v2h.5a.5.5 0 01.5.5v1a.5.5 0 01-.5.5H13v1a1 1 0 01-2 0v-1H5v1a1 1 0 01-2 0v-1H1.5a.5.5 0 01-.5-.5v-1a.5.5 0 01.5-.5H2v-2a1 1 0 011-1V.5a.5.5 0 011 0V3a2 2 0 012-2h4a2 2 0 012 2V.5a.5.5 0 01.5-.5zM9 8H7a1 1 0 00-1 1v2a1 1 0 001 1h2a1 1 0 001-1V9a1 1 0 00-1-1zm3.5 3h-1a.5.5 0 100 1h1a.5.5 0 100-1zm-8 0h-1a.5.5 0 100 1h1a.5.5 0 100-1zM9 9a.5.5 0 01.5.5v1l-.008.09A.5.5 0 019 11H7l-.09-.008a.5.5 0 01-.41-.492v-1l.008-.09A.5.5 0 017 9zm2-5H5v2h6V4z"],"two-columns":["M3.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1zm11.71 7.3l-2-2a1.003 1.003 0 00-1.71.71v4a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71zM9.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1z"],unarchive:["M13.382 0a1 1 0 01.894.553L16 4v11a1 1 0 01-1 1H1a1 1 0 01-1-1V4L1.724.553A1 1 0 012.618 0h10.764zM8 6c-.28 0-.53.11-.71.29l-2 2-.084.096A1.003 1.003 0 006.71 9.71l.29-.3V12l.007.116c.058.496.482.884.993.884.55 0 1-.45 1-1V9.41l.29.29.081.076A.97.97 0 0010 10a1.003 1.003 0 00.71-1.71l-2-2-.096-.084A1.002 1.002 0 008 6zm5-4H3L2 4h12l-1-2z"],underline:["M8 14c2.8 0 5-2.2 5-5V3c0-.6-.4-1-1-1s-1 .4-1 1v6c0 1.7-1.3 3-3 3s-3-1.3-3-3V3c0-.6-.4-1-1-1s-1 .4-1 1v6c0 2.8 2.2 5 5 5zM13.5 15h-11c-.3 0-.5.2-.5.5s.2.5.5.5h11c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"],undo:["M4 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm7-7H3.41L4.7 2.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 4.47 0 4.72 0 5c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 6H11c1.66 0 3 1.34 3 3s-1.34 3-3 3H7v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"],"ungroup-objects":["M3.5 5C1.57 5 0 6.57 0 8.5S1.57 12 3.5 12 7 10.43 7 8.5 5.43 5 3.5 5zm9 0C10.57 5 9 6.57 9 8.5s1.57 3.5 3.5 3.5S16 10.43 16 8.5 14.43 5 12.5 5z"],"unknown-vehicle":["M10.507 9.75v-3.5c0-.089.023-.171.051-.25h-7.55c-.176 0-.061-.824 0-1l.729-1.63c.06-.177.095-.37.27-.37h4.5V1.01c-.166-.003-.32-.01-.5-.01-2.72 0-4.036.402-4.036.402-.508.155-1.079.711-1.268 1.237L1.94 4.756H.887c-.483 0-.88.423-.88.939s.397.939.88.939h.376L1.008 7c-.034.685 0 1.436 0 2v5c0 .657.384 1 1 1s1-.343 1-1v-1h10v1c0 .657.383 1 1 1s1-.343 1-1v-3.5h-3.75a.75.75 0 01-.75-.75zm-5.5.25h-2V8h2v2zm11-4.305zM15.34.826a2.807 2.807 0 00-.932-.598c-.386-.16-.868-.241-1.445-.241-.447 0-.851.076-1.213.228-.362.153-.67.364-.926.636s-.456.592-.598.963a3.535 3.535 0 00-.218 1.144V3h1.789c.003-.208.023-.405.069-.588.049-.193.124-.362.225-.506.102-.144.232-.259.39-.345.159-.087.348-.13.567-.13.325 0 .58.09.762.272.183.18.275.46.275.839.008.222-.031.407-.116.555a1.654 1.654 0 01-.335.408 7.4 7.4 0 01-.452.37c-.162.123-.316.27-.463.438a2.556 2.556 0 00-.384.611c-.11.239-.177.535-.2.889V6h1.645v-.1c.032-.248.111-.453.237-.618.126-.164.27-.31.433-.438.163-.128.335-.255.518-.383a2.413 2.413 0 00.878-1.117c.102-.255.152-.58.152-.975A2.241 2.241 0 0015.34.826zM12.007 7v2h2V7h-2z"],unlock:["M11.99-.01c-2.21 0-4 1.79-4 4v3h-7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1h-3v-3c0-1.1.9-2 2-2s2 .9 2 2v1c0 .55.45 1 1 1s1-.45 1-1v-1c0-2.21-1.79-4-4-4z"],unpin:["M9.39 1c-.5.5-.4 1.48.15 2.53L4.38 7.54C2.85 6.5 1.52 6.07 1 6.59l3.5 3.5c-.02.02-1.4 2.8-1.4 2.8l2.8-1.4 3.5 3.5c.53-.53.1-1.86-.95-3.38l4.02-5.16c1.04.55 2.01.65 2.51.14L9.39 1z"],unresolve:["M11 3c-.55 0-1.07.09-1.57.26a6.46 6.46 0 010 9.48c.5.17 1.02.26 1.57.26 2.76 0 5-2.24 5-5s-2.24-5-5-5zM9.78 9.38l.09-.27c.08-.36.13-.73.13-1.11s-.05-.75-.13-1.11l-.09-.27a5.32 5.32 0 00-.29-.79l-.12-.21c-.14-.27-.31-.52-.51-.76a.7.7 0 00-.08-.1c-.24-.27-.49-.52-.78-.74-.43-.32-.92-.58-1.45-.75l.01-.01c-.1-.03-.2-.05-.3-.08-.12-.03-.23-.07-.36-.09A5.28 5.28 0 005 3C2.24 3 0 5.24 0 8s2.24 5 5 5c.31 0 .61-.04.9-.09.12-.02.24-.06.36-.09.1-.03.21-.04.3-.08l-.01-.01c.88-.29 1.64-.8 2.22-1.49.03-.03.06-.07.09-.1.19-.24.36-.49.51-.76.04-.07.08-.14.11-.21.13-.25.23-.52.3-.79z"],updated:["M8 0a7.95 7.95 0 00-6 2.74V1c0-.55-.45-1-1-1S0 .45 0 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.54C4.64 2.78 6.22 2 8 2c3.31 0 6 2.69 6 6 0 2.61-1.67 4.81-4 5.63-.63.22-1.29.37-2 .37-3.31 0-6-2.69-6-6 0-.55-.45-1-1-1s-1 .45-1 1c0 4.42 3.58 8 8 8 .34 0 .67-.03 1-.07.02 0 .04-.01.06-.01C12.98 15.4 16 12.06 16 8c0-4.42-3.58-8-8-8zm3 5c-.28 0-.53.11-.71.29L7 8.58 5.71 7.29a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l4-4A1.003 1.003 0 0011 5z"],upload:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm3 8c-.28 0-.53-.11-.71-.29L9 6.41V12c0 .55-.45 1-1 1s-1-.45-1-1V6.41l-1.29 1.3a1.003 1.003 0 01-1.42-1.42l3-3C7.47 3.11 7.72 3 8 3s.53.11.71.29l3 3A1.003 1.003 0 0111 8z"],user:["M7.99-.01A7.998 7.998 0 00.03 8.77c.01.09.03.18.04.28.02.15.04.31.07.47.02.11.05.22.08.34.03.13.06.26.1.38.04.12.08.25.12.37.04.11.08.21.12.32a6.583 6.583 0 00.3.65c.07.14.14.27.22.4.04.07.08.13.12.2l.27.42.1.13a7.973 7.973 0 003.83 2.82c.03.01.05.02.07.03.37.12.75.22 1.14.29l.2.03c.39.06.79.1 1.2.1s.81-.04 1.2-.1l.2-.03c.39-.07.77-.16 1.14-.29.03-.01.05-.02.07-.03a8.037 8.037 0 003.83-2.82c.03-.04.06-.08.09-.13.1-.14.19-.28.28-.42.04-.07.08-.13.12-.2.08-.13.15-.27.22-.41.04-.08.08-.17.12-.26.06-.13.11-.26.17-.39.04-.1.08-.21.12-.32.04-.12.08-.24.12-.37.04-.13.07-.25.1-.38.03-.11.06-.22.08-.34.03-.16.05-.31.07-.47.01-.09.03-.18.04-.28.02-.26.04-.51.04-.78-.03-4.41-3.61-7.99-8.03-7.99zm0 14.4c-1.98 0-3.75-.9-4.92-2.31.67-.36 1.49-.66 2.14-.95 1.16-.52 1.04-.84 1.08-1.27.01-.06.01-.11.01-.17-.41-.36-.74-.86-.96-1.44v-.01c0-.01-.01-.02-.01-.02-.05-.13-.09-.26-.12-.39-.28-.05-.44-.35-.5-.63-.06-.11-.18-.38-.15-.69.04-.41.2-.59.38-.67v-.06c0-.51.05-1.24.14-1.72.02-.13.05-.26.09-.39.17-.59.53-1.12 1.01-1.49.49-.38 1.19-.59 1.82-.59.62 0 1.32.2 1.82.59.48.37.84.9 1.01 1.49.04.13.07.26.09.4.09.48.14 1.21.14 1.72v.07c.18.08.33.26.37.66.03.31-.1.58-.16.69-.06.27-.21.57-.48.62-.03.13-.07.26-.12.38 0 .01-.01.04-.01.04-.21.57-.54 1.06-.94 1.42 0 .06.01.13.01.19.04.43-.12.75 1.05 1.27.65.29 1.47.6 2.14.95a6.415 6.415 0 01-4.93 2.31z"],variable:["M3.94 3.15c.47-.66 1.05-1.24 1.76-1.73l.13-.4c-1.11.45-2.05 1.01-2.84 1.7-1.02.88-1.8 1.9-2.32 3.05C.22 6.76 0 7.75 0 8.75c0 1.75.66 3.5 1.99 5.25l.13-.42c-.39-.94-.59-1.82-.59-2.63 0-1.28.22-2.64.67-4.1.45-1.45 1.03-2.69 1.74-3.7zm7.51 6.41l-.27-.15c-.3.41-.52.66-.66.77-.09.06-.21.1-.33.1-.15 0-.3-.1-.45-.28-.25-.33-.59-1.22-1.01-2.69.38-.65.69-1.08.95-1.28.19-.15.39-.22.59-.22.08 0 .22.03.43.08.2.06.39.08.54.08.22 0 .4-.07.54-.22.15-.15.22-.34.22-.57 0-.25-.07-.45-.22-.59-.15-.15-.35-.22-.63-.22-.24 0-.47.06-.69.17-.21.11-.49.36-.82.74-.25.28-.61.78-1.1 1.48a6.72 6.72 0 00-.97-2.38l-2.59.44-.05.27c.19-.04.36-.06.49-.06.26 0 .47.11.64.33.26.34.63 1.38 1.11 3.12-.37.49-.63.81-.77.96-.23.24-.41.4-.56.47-.11.06-.24.09-.39.09-.11 0-.29-.06-.53-.18-.17-.07-.32-.11-.45-.11-.25 0-.46.08-.62.24-.16.16-.24.37-.24.61 0 .23.08.42.23.57.15.15.35.22.61.22.25 0 .48-.05.7-.15.22-.1.49-.32.82-.65.33-.33.78-.86 1.36-1.59.22.69.42 1.19.58 1.51.16.31.35.54.56.68.21.14.47.21.79.21.31 0 .62-.11.93-.33.4-.29.82-.77 1.26-1.47zm2.56-8.54l-.12.42c.39.95.59 1.82.59 2.64 0 1.09-.17 2.26-.5 3.51-.26.96-.6 1.87-1.02 2.71-.42.85-.82 1.51-1.21 1.98-.39.48-.87.92-1.44 1.32l-.14.4c1.11-.45 2.05-1.02 2.84-1.7 1.03-.89 1.81-1.91 2.33-3.05.44-.99.66-1.99.66-3 0-1.73-.66-3.48-1.99-5.23z"],"vertical-bar-chart-asc":["M6 7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1zM2 9c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm8-5c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1zm4-4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],"vertical-bar-chart-desc":["M6 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1zM2 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm8 7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1zm4 2c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1z"],"vertical-distribution":["M1 2h14c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1zm14 11H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM3 5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1H3z"],video:["M15 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM5 11V5l6 3-6 3z"],virus:["M11.918 11.107l.737.737.052-.051A1 1 0 0114.2 13.12l-.078.087-1.414 1.414a1 1 0 01-1.492-1.327l.029-.033-.863-.863c-.426.231-.89.402-1.38.502L9 14l.117.007A1 1 0 019 16H7l-.117-.007A1 1 0 017 14v-1.1a4.967 4.967 0 01-1.447-.539l-.846.846.078.087a1 1 0 01-1.492 1.327l-1.414-1.414-.078-.087a1 1 0 011.492-1.327l.744-.744A4.986 4.986 0 013.23 9.5H2a1 1 0 01-1.993.117L0 9.5v-2a1 1 0 011.993-.117L2 7.5h1.025a4.973 4.973 0 01.905-2.405l-.512-.513-.125.125A1 1 0 011.8 3.38l.078-.087 1.414-1.414a1 1 0 011.529 1.277l.573.575a4.969 4.969 0 011.604-.63V2l-.116-.007a1 1 0 010-1.986L7 0h2a1 1 0 01.117 1.993L9 2l.001 1.1c.639.13 1.233.381 1.757.73l.535-.537-.078-.087a1 1 0 011.492-1.327l1.414 1.414.078.087a1 1 0 01-1.492 1.327l-.535.536a4.97 4.97 0 01.803 2.257H14l.007-.117A1 1 0 0116 7.5v2l-.007.117A1 1 0 0114 9.5h-1.229a4.987 4.987 0 01-.853 1.607zM10 9a1 1 0 100 2 1 1 0 000-2zM6.5 5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"],"volume-down":["M9 2c-.28 0-.53.11-.71.29L5.59 5H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm3.57 1.44l-1.59 1.22C11.62 5.61 12 6.76 12 8s-.38 2.39-1.02 3.34l1.59 1.22C13.47 11.27 14 9.7 14 8c0-1.7-.53-3.27-1.43-4.56z"],"volume-off":["M11 2c-.28 0-.53.11-.71.29L7.59 5H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"volume-up":["M7 1.86c-.28 0-.53.11-.71.29l-2.7 2.71H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71a1.003 1.003 0 001.71-.71v-10c-.01-.55-.46-1-1.01-1zm6.74-.99l-1.58 1.22A9.985 9.985 0 0114 7.86c0 2.16-.69 4.15-1.85 5.78l1.58 1.22c1.42-1.97 2.26-4.38 2.26-7 .01-2.61-.84-5.02-2.25-6.99zM8.98 4.52C9.62 5.48 10 6.63 10 7.86s-.38 2.39-1.02 3.34l1.59 1.22c.9-1.29 1.43-2.86 1.43-4.56 0-1.7-.53-3.27-1.43-4.56L8.98 4.52z"],walk:["M13 8h-2c-.16 0-.31-.05-.44-.11v.01l-1.02-.51-.37 1.86 1.38.92-.01.02c.27.17.46.46.46.81v4c0 .55-.45 1-1 1s-1-.45-1-1v-3.46l-1.27-.85-1.8 4.67h-.01A.98.98 0 015 16c-.55 0-1-.45-1-1 0-.13.03-.25.07-.36h-.01L7.39 6H5.62l-.73 1.45h-.01C4.72 7.77 4.39 8 4 8c-.55 0-1-.45-1-1 0-.16.05-.31.11-.44H3.1l1-2h.01c.17-.33.5-.56.89-.56h3.16l.29-.75C8.17 2.9 8 2.47 8 2c0-1.1.9-2 2-2s2 .9 2 2c0 1-.73 1.82-1.69 1.97l-.5 1.32 1.43.71H13c.55 0 1 .45 1 1s-.45 1-1 1z"],"warning-sign":["M15.84 13.5l.01-.01-7-12-.01.01c-.17-.3-.48-.5-.85-.5s-.67.2-.85.5l-.01-.01-7 12 .01.01c-.09.15-.15.31-.15.5 0 .55.45 1 1 1h14c.55 0 1-.45 1-1 0-.19-.06-.35-.15-.5zm-6.85-.51h-2v-2h2v2zm0-3h-2v-5h2v5z"],"waterfall-chart":["M8 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-4 4h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1zm7-6c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1s-1 .45-1 1v1c0 .55.45 1 1 1zm4-3h-1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 10H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],waves:["M3 1a1 1 0 01.894.553c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.173.344.38.75.637 1.072.277.347.437.375.469.375a1 1 0 110 2c-.968 0-1.642-.64-2.03-1.125a4.755 4.755 0 01-.076-.097 6.093 6.093 0 01-.221.212C12.175 4.442 11.393 5 10.5 5c-.892 0-1.675-.558-2.173-1.01A6.243 6.243 0 018 3.67c-.105.11-.214.217-.327.32C7.175 4.442 6.393 5 5.5 5c-.892 0-1.675-.558-2.173-1.01a6.119 6.119 0 01-.221-.212l-.075.097C2.64 4.36 1.968 5 1 5a1 1 0 010-2c.032 0 .191-.028.47-.375.256-.321.463-.728.636-1.072A1 1 0 013 1zm0 5a1 1 0 01.894.553c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.173.344.38.75.637 1.072.277.347.437.375.469.375a1 1 0 110 2c-.968 0-1.642-.639-2.03-1.125a4.726 4.726 0 01-.076-.097 6.093 6.093 0 01-.221.212c-.498.452-1.28 1.01-2.173 1.01-.892 0-1.675-.558-2.173-1.01A6.243 6.243 0 018 8.67c-.105.11-.214.217-.327.32C7.175 9.442 6.393 10 5.5 10c-.892 0-1.675-.558-2.173-1.01a6.119 6.119 0 01-.221-.212l-.075.097C2.64 9.36 1.968 10 1 10a1 1 0 010-2c.032 0 .191-.028.47-.375.256-.321.463-.728.636-1.072A1 1 0 013 6zm.894 5.553a1 1 0 00-1.788 0c-.173.344-.38.75-.637 1.072-.278.347-.437.375-.469.375a1 1 0 100 2c.968 0 1.642-.639 2.03-1.125a4.9 4.9 0 00.076-.097c.072.073.146.143.221.212.498.452 1.28 1.01 2.173 1.01.892 0 1.675-.558 2.173-1.01.113-.103.222-.21.327-.32.105.11.214.217.327.32.498.452 1.28 1.01 2.173 1.01.892 0 1.675-.558 2.173-1.01.075-.069.149-.14.221-.212a4.9 4.9 0 00.075.097C13.36 14.36 14.032 15 15 15a1 1 0 100-2c-.032 0-.191-.028-.47-.375-.256-.321-.463-.728-.636-1.072a1 1 0 00-1.788 0c-.102.202-.393.607-.779.957-.419.381-.72.49-.827.49-.108 0-.408-.109-.827-.49-.386-.35-.677-.755-.779-.957a1 1 0 00-1.788 0c-.102.202-.393.607-.779.957-.419.381-.72.49-.827.49-.108 0-.408-.109-.827-.49-.386-.35-.677-.755-.779-.957z"],widget:["M13 11h2V5h-2v6zM3 5H1v6h2V5zm11-1c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM5 3h6V1H5v2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3 15h6v-2H5v2z"],"widget-button":["M1 3h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1zm1 2v6h12V5H2zm3 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"widget-footer":["M14 0H2c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H3v-3h10v3zm0-4H3V2h10v8z"],"widget-header":["M14 0H2c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H3V6h10v8zm0-9H3V2h10v3z"],wind:["M10 4a2 2 0 112 2H4a1 1 0 000 2h8a4 4 0 10-4-4 1 1 0 002 0zM1 9a1 1 0 100 2h7.5a1.5 1.5 0 010 3c-.749 0-1.386-.538-1.52-1.199a1 1 0 10-1.96.398C5.35 14.82 6.83 16 8.5 16a3.5 3.5 0 100-7H1z"],wrench:["M15.83 3.7l-3.06 3.05-2.84-.7-.7-2.83L12.29.17a5.004 5.004 0 00-4.83 1.29 4.967 4.967 0 00-1.12 5.36L.58 12.58c-.36.36-.58.86-.58 1.41 0 1.1.9 2 2 2 .55 0 1.05-.22 1.41-.59l5.77-5.77c1.79.69 3.91.33 5.35-1.12 1.32-1.3 1.74-3.15 1.3-4.81z"],"zoom-in":["M7.99 5.99v-2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2zm7.56 7.44l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"zoom-out":["M3.99 5.99c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1h-6zm11.56 7.44l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"zoom-to-fit":["M11 10a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42L12.59 8 11.3 9.29c-.19.18-.3.43-.3.71zM1 5c.55 0 1-.45 1-1V2h2c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v3c0 .55.45 1 1 1zm4 1a1.003 1.003 0 00-1.71-.71l-2 2C1.11 7.47 1 7.72 1 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 8 4.7 6.71c.19-.18.3-.43.3-.71zm1-1c.28 0 .53-.11.71-.29L8 3.41 9.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-2 2A1.003 1.003 0 006 5zm9 6c-.55 0-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zm0-11h-3c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zM4 14H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm6-3c-.28 0-.53.11-.71.29L8 12.59 6.71 11.3A.965.965 0 006 11a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 0010 11z"]},JS={add:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm5-9h-4V5c0-.55-.45-1-1-1s-1 .45-1 1v4H5c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"add-clip":["M15 0a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0V6h-3a1 1 0 110-2h3V1a1 1 0 011-1zM1 4a1 1 0 00-1 1v4a1 1 0 002 0V6h3a1 1 0 000-2H1zM0 19a1 1 0 001 1h4a1 1 0 100-2H2v-3a1 1 0 10-2 0v4zm15 1h-4a1 1 0 110-2h3v-3a1 1 0 112 0v4a1 1 0 01-1 1zm-7-5a3 3 0 100-6 3 3 0 000 6z"],"add-column-left":["M4 11h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1H8V7c0-.55-.45-1-1-1s-1 .45-1 1v2H4c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-7 18H2V2h10v16zm6 0h-5V2h5v16z"],"add-column-right":["M10 11h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V7c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1zm9-11H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H2V2h5v16zm11 0H8V2h10v16z"],"add-location":["M10 0a1 1 0 010 2 8 8 0 108 8 1 1 0 012 0c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0zm0 6a4 4 0 110 8 4 4 0 010-8zm6-6c.6 0 1 .4 1 1v2h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v2c0 .6-.4 1-1 1s-1-.4-1-1V5h-2c-.6 0-1-.4-1-1 0-.5.4-1 1-1h2V1c0-.6.4-1 1-1z"],"add-row-bottom":["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V8h16v10zm0-11H2V2h16v5zM7 14h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2v-2c0-.55-.45-1-1-1s-1 .45-1 1v2H7c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-row-top":["M7 8h2v2c0 .55.45 1 1 1s1-.45 1-1V8h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v2H7c-.55 0-1 .45-1 1s.45 1 1 1zm12-8H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2v-5h16v5zm0-6H2V2h16v10z"],"add-to-artifact":["M13 12H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM1 6h9c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm12 2H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm6-4h-2V2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V6h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"add-to-folder":["M.01 10V6H20v10c0 .55-.45 1-1 1H9.995v-3.99C9.965 11.332 8.635 10 6.987 10H.01zM19 3c.55 0 1 .45.99 1v1H0V2c0-.55.45-1 1-1h5.997c.28 0 .53.11.71.29L9.414 3H19zM6.987 12c.55 0 .999.45 1.009 1.01v5c0 .55-.45 1-1 1s-.999-.45-.999-1v-2.59l-4.288 4.29a1.003 1.003 0 01-1.42-1.42L4.579 14H1.989c-.55 0-1-.45-1-1s.45-1 1-1h4.998z"],airplane:["M20 2c0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-4.84 4.84L2 1 1 3l7.53 5.64L4.17 13H1l-1 1 4 2 2 4 1-1v-3.17l4.36-4.36L17 19l2-1-4.43-9.74 4.84-4.84c.37-.37.59-.87.59-1.42z"],"align-center":["M5 5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1H5zM1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm12 12c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h6zm4 2H3c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm2-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-justify":["M1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 14H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-12H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-left":["M1 7h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 14H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM1 15h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"align-right":["M19 17H5c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 10h-6c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H9c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-bottom":["M12 16h4c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1zm7 2H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM4 16h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1z"],"alignment-horizontal-center":["M19 9h-2V7c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v2H9V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v6H1c-.55 0-1 .45-1 1s.45 1 1 1h2v6c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-6h2v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-left":["M1 0C.45 0 0 .45 0 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm11 11H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm7-8H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"alignment-right":["M19 0c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-4 11H8c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm0-8H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"alignment-top":["M8 4H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm11-4H1C.45 0 0 .45 0 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-3 4h-4c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"alignment-vertical-center":["M17 3h-6V1c0-.55-.45-1-1-1S9 .45 9 1v2H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h6v2H7c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1h-2V9h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],annotation:["M9.41 13.41l7.65-7.65-2.83-2.83-7.65 7.65 2.83 2.83zm10-10c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.83 1.64-1.66zM18 18H2V2h8.93l2-2H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7.07l-2 2V18zM4 16l4.41-1.59-2.81-2.79L4 16z"],antenna:["M2.01 10.758a8.025 8.025 0 001.01 3.204l.02.035c.034.058.061.117.084.178.163.44.054.951-.33 1.239-.435.328-1.059.242-1.342-.224a9.797 9.797 0 01-.221-.383 10 10 0 1117.48.106c-.269.474-.89.58-1.335.267-.392-.275-.518-.783-.37-1.228a1.19 1.19 0 01.078-.18l.019-.036A8.026 8.026 0 102.01 10.758zm4.272.772a1.464 1.464 0 01.091.32c.07.425-.052.87-.402 1.128-.44.325-1.068.235-1.316-.252a6 6 0 1110.734-.09c-.24.492-.867.593-1.312.275-.354-.253-.483-.695-.42-1.122a1.462 1.462 0 01.085-.321 4.021 4.021 0 00-5.87-4.878 4.02 4.02 0 00-1.59 4.94zm4.712 2.583A.999.999 0 0011 14v-4a1 1 0 10-2 0v4c0 .038.002.076.006.113l-3.753 4.223a1 1 0 001.494 1.328L10 16.005l3.252 3.66a1 1 0 101.495-1.33l-3.753-4.222z"],"app-header":["M19 0a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h18zM8 6a1 1 0 00-1.993-.117L6 6v8a1 1 0 001.993.117L8 14v-3h4v3a1 1 0 001.993.117L14 14V6a1 1 0 00-1.993-.117L12 6v3H8V6z"],application:["M3.5 9h9c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-9c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm-1 16H2V6h16v11zM3.5 13h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5z"],applications:["M15 5H1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 13H2V8h12v10zM3.5 10h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-3c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM19 0H5c-.55 0-1 .45-1 1v3h2V3h12v10h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],archive:["M16.434 0a1 1 0 01.857.486L20 5v14a1 1 0 01-1 1H1a1 1 0 01-1-1V5L2.709.486A1 1 0 013.566 0h12.868zM10 8c-.55 0-1 .45-1 1v4.58l-1.29-1.29-.081-.073A.996.996 0 007 11.99a1.003 1.003 0 00-.71 1.71l3 3 .096.084c.168.13.38.206.614.206.28 0 .53-.11.71-.29l3-3 .084-.096a1.003 1.003 0 00-1.504-1.324L11 13.58V9l-.007-.116A1.004 1.004 0 0010 8zm6-6H4L2 5.002h16L16 2z"],"area-of-interest":["M5 4.664C5 2.09 7.241 0 10 0s4.99 2.091 5 4.664C15 7.245 10 14 10 14S5 7.245 5 4.664zM8 5a2 2 0 104.001-.001A2 2 0 008 5zM.504 12.132l4.302-2.458c.322.576.662 1.145.995 1.681l.025.04-3.294 1.881L6.468 18h7.064l3.936-4.724-3.293-1.882.024-.039c.333-.536.673-1.105.995-1.681l4.302 2.458a1 1 0 01.272 1.508l-5 6A1 1 0 0114 20H6a1 1 0 01-.768-.36l-5-6a1 1 0 01.272-1.508z"],array:["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm5 9a1 1 0 110 2 1 1 0 010-2zM6 9a1 1 0 110 2 1 1 0 010-2zm8 0a1 1 0 110 2 1 1 0 010-2z"],"array-boolean":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm10 7a1 1 0 01.993.883L16 8v4a1 1 0 01-.883.993L15 13H5a1 1 0 01-.993-.883L4 12V8a1 1 0 01.883-.993L5 7h10zm0 1h-5v4h5V8z"],"array-date":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm2.5 5a.5.5 0 01.5.5V6h4v-.5a.5.5 0 01.5-.5h1a.5.5 0 01.5.5V6h1a1 1 0 01.993.883L16 7v7a1 1 0 01-.883.993L15 15H5a1 1 0 01-.993-.883L4 14V7a1 1 0 01.883-.993L5 6h1v-.5a.5.5 0 01.5-.5h1zM15 9H5v5h10V9z"],"array-numeric":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm8.995 6.09c.32 0 .603.047.85.14a1.679 1.679 0 011.015.985c.09.23.135.482.135.755 0 .287-.063.552-.19.795a1.642 1.642 0 01-.57.615v.02l.101.05c.068.039.138.09.209.155.107.097.203.215.29.355a2.09 2.09 0 01.3 1.09c0 .313-.053.597-.16.85a1.898 1.898 0 01-1.12 1.065 2.42 2.42 0 01-.85.145c-.533 0-.99-.127-1.37-.38a1.702 1.702 0 01-.73-1.08c-.013-.067.013-.11.08-.13l.87-.2.041-.003c.038.004.064.028.079.073.073.2.193.37.36.51.167.14.39.21.67.21.32 0 .567-.095.74-.285.173-.19.26-.432.26-.725 0-.347-.1-.618-.3-.815-.2-.197-.47-.295-.81-.295h-.29l-.044-.006c-.037-.013-.056-.044-.056-.094V9.1l.006-.044c.013-.037.044-.056.094-.056h.27l.145-.008a.925.925 0 00.575-.262c.18-.18.27-.42.27-.72 0-.273-.08-.495-.24-.665-.16-.17-.383-.255-.67-.255-.253 0-.453.063-.6.19-.147.127-.25.297-.31.51-.02.06-.06.083-.12.07l-.85-.2-.042-.015c-.035-.02-.048-.055-.038-.105a1.684 1.684 0 01.645-1.035c.17-.13.37-.232.6-.305.23-.073.482-.11.755-.11zm-7.99.11l.044.006c.037.013.056.044.056.094v6.6l-.006.044c-.013.037-.044.056-.094.056h-.92l-.044-.006c-.037-.013-.056-.044-.056-.094V7.54h-.02l-1.04.73-.04.02c-.047.016-.07-.01-.07-.08V7.19l.008-.051a.196.196 0 01.062-.089l1.09-.79.051-.033a.295.295 0 01.129-.027h.85zm3.34-.11c.32 0 .603.05.85.15.247.1.455.235.625.405.17.17.3.37.39.6.09.23.135.478.135.745 0 .307-.057.588-.17.845a3.16 3.16 0 01-.47.745l-1.98 2.4V12h2.52l.044.006c.037.013.056.044.056.094v.8l-.006.044c-.013.037-.044.056-.094.056h-3.82l-.044-.006c-.037-.013-.056-.044-.056-.094v-.75l.006-.05a.165.165 0 01.044-.08l2.4-2.99.124-.167c.077-.11.143-.222.196-.333.08-.167.12-.347.12-.54a.92.92 0 00-.235-.64c-.157-.173-.378-.26-.665-.26-.273 0-.487.077-.64.23-.153.153-.247.36-.28.62-.013.067-.05.093-.11.08l-.88-.18-.043-.015c-.035-.02-.047-.055-.037-.105a1.78 1.78 0 01.56-1.115c.167-.157.372-.282.615-.375a2.35 2.35 0 01.845-.14z"],"array-string":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm2.012 6c.643 0 1.203.266 1.68.797.477.53.715 1.246.715 2.145a4.472 4.472 0 01-.965 2.814c-.644.83-1.66 1.5-3.047 2.011v-.581l.26-.104a3.87 3.87 0 001.624-1.285c.457-.632.686-1.29.686-1.971 0-.148-.023-.256-.07-.326-.023-.047-.054-.07-.093-.07-.038 0-.1.031-.186.093-.248.179-.558.268-.93.268-.45 0-.843-.18-1.18-.541A1.817 1.817 0 015 7.965c0-.527.194-.986.581-1.378A1.934 1.934 0 017.011 6zm5.593 0c.643 0 1.203.266 1.68.797.477.53.715 1.246.715 2.145a4.472 4.472 0 01-.965 2.814c-.644.83-1.659 1.5-3.047 2.011v-.581l.26-.104a3.87 3.87 0 001.624-1.285c.457-.632.686-1.29.686-1.971 0-.148-.023-.256-.07-.326-.023-.047-.054-.07-.093-.07-.038 0-.1.031-.186.093-.248.179-.558.268-.93.268-.45 0-.843-.18-1.18-.541a1.817 1.817 0 01-.506-1.285c0-.527.194-.986.581-1.378A1.934 1.934 0 0112.604 6z"],"array-timestamp":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm5 4a6 6 0 110 12 6 6 0 010-12zm0 1a5 5 0 100 10 5 5 0 000-10zm2.854 2.146a.5.5 0 01.057.638l-.057.07-2.5 2.5a.5.5 0 01-.638.057l-.07-.057-1.5-1.5a.5.5 0 01.638-.765l.07.057L10 9.293l2.146-2.147a.5.5 0 01.708 0z"],"arrow-bottom-left":["M18 3a1.003 1.003 0 00-1.71-.71L4 14.59V7c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1H5.41l12.3-12.29c.18-.18.29-.43.29-.71z"],"arrow-bottom-right":["M17 6c-.55 0-1 .45-1 1v7.59L3.71 2.29a1.003 1.003 0 00-1.42 1.42L14.59 16H7c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"arrow-down":["M16 11c-.3 0-.5.1-.7.3L11 15.6V2c0-.5-.4-1-1-1s-1 .5-1 1v13.6l-4.3-4.3c-.2-.2-.4-.3-.7-.3-.5 0-1 .4-1 1 0 .3.1.5.3.7l6 6c.2.2.4.3.7.3s.5-.1.7-.3l6-6c.2-.2.3-.4.3-.7 0-.6-.5-1-1-1z"],"arrow-left":["M18 9H4.41L8.7 4.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L4.41 11H18c.55 0 1-.45 1-1s-.45-1-1-1z"],"arrow-right":["M18.71 9.29l-6-6a1.003 1.003 0 00-1.42 1.42L15.59 9H2c-.55 0-1 .45-1 1s.45 1 1 1h13.59l-4.29 4.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"arrow-top-left":["M17.71 16.29L5.41 4H13c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5.41L16.29 17.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"arrow-top-right":["M17 2H7c-.55 0-1 .45-1 1s.45 1 1 1h7.59L2.29 16.29a1.003 1.003 0 001.42 1.42L16 5.41V13c0 .55.45 1 1 1s1-.45 1-1V3c0-.55-.45-1-1-1z"],"arrow-up":["M16.7 7.3l-6-6c-.2-.2-.4-.3-.7-.3s-.5.1-.7.3l-6 6c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L9 4.4V18c0 .5.4 1 1 1s1-.5 1-1V4.4l4.3 4.3c.2.2.4.3.7.3.5 0 1-.4 1-1 0-.3-.1-.5-.3-.7z"],"arrows-horizontal":["M19.7 9.3l-5-5c-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.5.3.7L16.6 9H3.4l3.3-3.3c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1-.3 0-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7s.1.5.3.7l5 5c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7L3.4 11h13.2l-3.3 3.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l5-5c.2-.2.3-.4.3-.7s-.1-.5-.3-.7z"],"arrows-vertical":["M15 13c-.3 0-.5.1-.7.3L11 16.6V3.4l3.3 3.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7l-5-5c-.2-.2-.4-.3-.7-.3s-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3L9 3.4v13.2l-3.3-3.3c-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.5.3.7l5 5c.2.2.4.3.7.3s.5-.1.7-.3l5-5c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1z"],asterisk:["M18.52 14.17l.01-.02L11.89 10l6.64-4.15-.01-.02A.97.97 0 0019 5c0-.55-.45-1-1-1-.2 0-.37.07-.52.17l-.01-.02L11 8.2V1c0-.55-.45-1-1-1S9 .45 9 1v7.2L2.53 4.15l-.01.02A.922.922 0 002 4c-.55 0-1 .45-1 1 0 .36.2.66.48.83l-.01.02L8.11 10l-6.64 4.15.01.02A.97.97 0 001 15c0 .55.45 1 1 1 .2 0 .37-.07.52-.17l.01.02L9 11.8V19c0 .55.45 1 1 1s1-.45 1-1v-7.2l6.47 4.04.01-.02c.15.11.32.18.52.18.55 0 1-.45 1-1 0-.36-.2-.66-.48-.83z"],"automatic-updates":["M10 18c-4.42 0-8-3.58-8-8 0-2.52 1.18-4.76 3-6.22V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1h2.06C1.61 3.82 0 6.71 0 10c0 5.52 4.48 10 10 10 .55 0 1-.45 1-1s-.45-1-1-1zm0-16c1.64 0 3.15.49 4.42 1.34l1.43-1.43A9.869 9.869 0 0010 0c-.55 0-1 .45-1 1s.45 1 1 1zm10 8c0-1.13-.2-2.21-.54-3.22L17.84 8.4A7.962 7.962 0 0115 16.22V15c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-2.06c2.45-1.82 4.06-4.71 4.06-8zm0-7a1.003 1.003 0 00-1.71-.71L12 8.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7c.18-.18.29-.43.29-.71z"],backlink:["M18.387 19.79l-.094-.083L14 15.415V18a1 1 0 01-2 0l.003-5.075.017-.126.03-.111.044-.111.052-.098.067-.096.08-.09a1.01 1.01 0 01.112-.097l.11-.071.114-.054.105-.035.15-.03L13 12h5a1 1 0 110 2h-2.585l4.292 4.293a1 1 0 01-1.32 1.497zM7.036 9.136l-4.45 4.45-.117.127a2 2 0 002.818 2.818l.127-.117 4.45-4.449a4 4 0 01-.885 3.704l-.15.16-2 2A4 4 0 011.02 12.33l.15-.16 2-2a3.998 3.998 0 013.865-1.035zm6.671-3.843a1 1 0 01.083 1.32l-.083.094-7 7a1 1 0 01-1.497-1.32l.083-.094 7-7a1 1 0 011.414 0zm4.121-4.121a4 4 0 01.151 5.497l-.15.16-2 2a3.998 3.998 0 01-3.864 1.036l4.45-4.45.116-.128a2 2 0 00-2.818-2.818l-.127.117-4.45 4.45a4 4 0 01.885-3.705l.15-.16 2-2a4 4 0 015.657 0z"],badge:["M16.94 5.73c-.19-1.41.62-2.52 1.38-3.59L17.03.65C14.89 1.76 11.88 1.48 10 0 8.12 1.48 5.11 1.76 2.97.65L1.68 2.14c.76 1.07 1.57 2.18 1.38 3.59C2.68 8.59 0 10.94 1.4 14.08c.56 1.43 1.81 2.37 3.4 2.75 1.95.46 4.4.91 5.2 3.17.8-2.26 3.25-2.71 5.2-3.17 1.6-.38 2.84-1.32 3.4-2.75 1.4-3.14-1.28-5.49-1.66-8.35z"],"ban-circle":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm5 11H5c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"],"bank-account":["M19.2 8.02l-.78-.18C18.03 6.4 17.2 5.08 16.08 4l.5-2.28c.11-.42-.22-.78-.61-.72-1.06.12-2 .54-2.67 1.26-1.06-.42-2.34-.66-3.56-.66-3.12 0-5.79 1.5-7.4 3.72-.23-.05-.45-.11-.67-.11C.72 5.21 0 5.98 0 7c0 .72.39 1.32.95 1.62-.06.42-.12.9-.12 1.38 0 2.16.89 4.08 2.28 5.58l-.33 2.04c-.11.72.45 1.38 1.12 1.38h.72c.56 0 1-.42 1.11-1.02l.06-.48c1.17.54 2.5.9 3.95.9 1.39 0 2.78-.3 3.95-.9l.06.48c.11.6.56 1.02 1.11 1.02h.72c.67 0 1.22-.66 1.11-1.38l-.33-1.98c.78-.78 1.34-1.74 1.73-2.76l1-.24c.5-.12.89-.6.89-1.2V9.22c.11-.6-.28-1.08-.78-1.2zM15 10c-.6 0-1-.7-1-1.5S14.4 7 15 7s1 .7 1 1.5-.4 1.5-1 1.5zM7.55 5.83a.99.99 0 01-1.38-.28.99.99 0 01.28-1.38c2.34-1.56 4.77-1.56 7.11 0 .46.31.58.93.28 1.39-.31.46-.93.58-1.39.28-1.67-1.12-3.23-1.12-4.9-.01z"],barcode:["M6 16.98h2v-14H6v14zm3 0h1v-14H9v14zm-6 0h2v-14H3v14zm-3 0h2v-14H0v14zm16 0h2v-14h-2v14zm-4 0h1v-14h-1v14zm7-14v14h1v-14h-1zm-5 14h1v-14h-1v14z"],blank:[],"blocked-person":["M11.55 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.06-.11.14-.35.17-.62C10.33 9.42 8.92 7.38 8.92 5c0-.3.05-.58.09-.87-.33-.08-.67-.13-.99-.13-.79 0-1.68.25-2.31.73-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.17 1.51-.17 2.14v.08c-.24.09-.45.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59C3 16.56.77 17.26.32 18.31-.15 19.38.04 20 .04 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.69-1.75-4.17-2.41zM14.97 0c-2.78 0-5.03 2.24-5.03 5s2.25 5 5.03 5S20 7.76 20 5s-2.25-5-5.03-5zm-3.03 5c0-1.66 1.35-3 3.02-3 .47 0 .9.11 1.29.3l-4.01 3.99c-.18-.4-.3-.83-.3-1.29zm3.03 3c-.47 0-.9-.11-1.29-.3l4.01-3.99c.19.39.3.82.3 1.29 0 1.66-1.36 3-3.02 3z"],bold:["M14.3 9c.4-.8.7-1.6.7-2.5C15 4 13 2 10.5 2H5c-.6 0-1 .4-1 1v13c0 .6.4 1 1 1h6.5c2.5 0 4.5-2 4.5-4.5 0-1.4-.7-2.7-1.7-3.5zM7 5h3.5c.8 0 1.5.7 1.5 1.5S11.3 8 10.5 8H7V5zm4.5 9H7v-3h4.5c.8 0 1.5.7 1.5 1.5s-.7 1.5-1.5 1.5z"],book:["M3 1v18c0 .55.45 1 1 1h2V0H4c-.55 0-1 .45-1 1zm14-1h-2v8l-2-2-2 2V0H7v20h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],bookmark:["M6 0c-.55 0-1 .45-1 1v18c0 .55.32.68.71.29L9.3 15.7a.996.996 0 011.41 0l3.59 3.59c.38.39.7.26.7-.29v-8-4.5V1c0-.55-.45-1-1-1H6z"],box:["M19.89 6.56l-2.99-6h-.01C16.72.23 16.39 0 16 0H4c-.39 0-.72.23-.89.56H3.1l-3 6h.01C.05 6.69 0 6.84 0 7v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7c0-.16-.05-.31-.11-.44zM11 2h4.38l2 4H11V2zM4.62 2H9v4H2.62l2-4zM18 18H2V8h16v10zM8 12h4c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1z"],briefcase:["M19 5h-4V2c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v3H1c-.55 0-1 .45-1 1v5h4v-1h2v1h8v-1h2v1h4V6c0-.55-.45-1-1-1zm-6 0H7V3h6v2zm3 8h-2v-1H6v1H4v-1H0v6c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-6h-4v1z"],"bring-data":["M18 18a1 1 0 010 2H2a1 1 0 010-2h16zM9.995 3.005c.55 0 1 .45 1 .999v9.584l1.29-1.288a1.002 1.002 0 011.42 1.419l-3 2.996a1.015 1.015 0 01-1.42 0l-3-2.997a1.002 1.002 0 011.42-1.419l1.29 1.29V4.013c0-.55.45-1.009 1-1.009zM16 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zM7 0a1 1 0 110 2 1 1 0 010-2zM4 0a1 1 0 110 2 1 1 0 010-2z"],buggy:["M15.836 1.014a1 1 0 011.058.539l2.482 4.962.02-.004a.5.5 0 01.604.49v4.5a.5.5 0 01-.5.5h-3.93a1.5 1.5 0 00-1.248.667l-1.406 2.11A.5.5 0 0112.5 15H8a.5.5 0 01-.354-.146l-2.414-2.415A1.5 1.5 0 004.172 12H.5a.5.5 0 01-.5-.5v-3A.5.5 0 01.5 8h.823L3.072 3.63a1 1 0 01.764-.615l12-2zm.289 3.472l1.231 2.462-2.758.591 1.527-3.053zM14.5 3.264l-1.56 3.12-.252-.638-.825-2.043 2.637-.44zm-9.78 1.63l5.122-.854.988 2.445.899 2.27L10.232 11H7.707L4.854 8.147A.5.5 0 004.5 8H3.477l1.242-3.106zM3 19a3 3 0 100-6 3 3 0 000 6zm14 0a3 3 0 100-6 3 3 0 000 6z"],build:["M19.43 16.67L9.31 7.81l1.47-1.56c.41-.44-.15-.8.15-1.6 1.08-2.76 4.19-2.99 4.19-2.99s.45-.47.87-.92C11.98-1 9.26.7 8.04 1.8L3.83 6.25l-.86.92c-.48.51-.48 1.33 0 1.84l-.87.92c-.48-.51-1.26-.51-1.74 0s-.48 1.33 0 1.84l1.74 1.84c.48.51 1.26.51 1.74 0s.48-1.33 0-1.84l.87-.92c.48.51 1.26.51 1.74 0l1.41-1.49 8.81 10.07c.76.76 2 .76 2.76 0 .76-.76.76-2 0-2.76z"],calculator:["M16 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H5v-2h2v2zm0-4H5v-2h2v2zm0-4H5V8h2v2zm4 8H9v-2h2v2zm0-4H9v-2h2v2zm0-4H9V8h2v2zm4 8h-2v-6h2v6zm0-8h-2V8h2v2zm0-4H5V2h10v4z"],calendar:["M15 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zM5 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm13-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H7v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H2c-.5 0-1 .5-1 1v14c0 .5.5 1 1 1h16c.5 0 1-.5 1-1V4c0-.5-.5-1-1-1zM7 17H3v-4h4v4zm0-5H3V8h4v4zm5 5H8v-4h4v4zm0-5H8V8h4v4zm5 5h-4v-4h4v4zm0-5h-4V8h4v4z"],camera:["M10 8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm9-4h-3.59L13.7 2.29A.956.956 0 0013 2H7c-.28 0-.53.11-.71.29L4.59 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h4.11c1.26 1.24 2.99 2 4.89 2s3.63-.76 4.89-2H19c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM4 8H2V6h2v2zm6 8c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"caret-down":["M16 7c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1 0 .24.1.46.24.63l-.01.01 5 6 .01-.01c.19.22.45.37.76.37s.57-.15.76-.37l.01.01 5-6-.01-.01c.14-.17.24-.39.24-.63z"],"caret-left":["M13 4c-.24 0-.46.1-.63.24l-.01-.01-6 5 .01.01c-.22.19-.37.45-.37.76s.15.57.37.76l-.01.01 6 5 .01-.01c.17.14.39.24.63.24.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"caret-right":["M14 10c0-.31-.15-.57-.37-.76l.01-.01-6-5-.01.01C7.46 4.1 7.24 4 7 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1 .24 0 .46-.1.63-.24l.01.01 6-5-.01-.01c.22-.19.37-.45.37-.76z"],"caret-up":["M15.76 12.37l.01-.01-5-6-.01.01C10.57 6.15 10.31 6 10 6s-.57.15-.76.37l-.01-.01-5 6 .01.01c-.14.17-.24.39-.24.63 0 .55.45 1 1 1h10c.55 0 1-.45 1-1 0-.24-.1-.46-.24-.63z"],"cargo-ship":["M12.5 1.25h4a1 1 0 011 1V5h-5V1.25zM2.75 5a.25.25 0 00-.25.25v6H.883a.5.5 0 00-.429.757l1.672 2.787c.17.284.384.533.63.741-.458.057-.959.09-1.506.09a.625.625 0 100 1.25c2.583 0 4.268-.68 5.202-1.146.687.466 1.88 1.146 3.548 1.146 1.65 0 2.837-.666 3.528-1.132l.005.003c.244.131.6.3 1.07.468.938.335 2.321.661 4.147.661a.625.625 0 100-1.25c-.319 0-.622-.01-.91-.03.398-.318.717-.738.914-1.23l.972-2.43a.5.5 0 00-.464-.685H5v-6A.25.25 0 004.75 5h-2zm3.455 11.95a.625.625 0 01.658.041c.569.407 1.597 1.134 3.137 1.134s2.568-.727 3.137-1.134a.625.625 0 01.724-.001l.007.005.045.029c.044.027.114.069.21.12.194.104.493.247.9.392.812.29 2.053.589 3.727.589a.625.625 0 110 1.25c-1.826 0-3.21-.326-4.148-.661a7.894 7.894 0 01-1.069-.468l-.005-.003c-.691.466-1.878 1.132-3.528 1.132-1.667 0-2.861-.68-3.548-1.146-.934.467-2.619 1.146-5.202 1.146a.625.625 0 110-1.25c2.66 0 4.23-.787 4.955-1.176zM17.5 6.25h-5V10h4a1 1 0 001-1V6.25zm-11.25-4a1 1 0 011-1h4V5h-5V2.25zm5 4h-5V9a1 1 0 001 1h4V6.25z"],"cell-tower":["M11.5 8.32c.31-.35.51-.81.51-1.32 0-1.1-.9-2-2-2s-2 .9-2 2c0 .51.2.97.51 1.32L5.06 18.69c-.17.52.11 1.09.63 1.26s1.09-.11 1.26-.63L8.39 15h3.23l1.44 4.32c.17.52.74.81 1.26.63s.81-.74.63-1.26L11.5 8.32zM10.95 13H9.06l.95-2.84.94 2.84zM5.31 10.73a.996.996 0 101.37-1.45c-1.4-1.33-1.28-3.35-.01-4.54.4-.38.43-1.01.05-1.41-.36-.41-1-.43-1.4-.06-2.09 1.95-2.28 5.3-.01 7.46z","M4.6 12.2C3 11.1 2 9 2 7c0-2.1.9-3.9 2.6-5.2.5-.3.5-1 .2-1.4-.3-.5-1-.5-1.4-.2C1.2 1.9-.1 4.2 0 7c.1 2.7 1.4 5.3 3.4 6.8.2.1.4.2.6.2.3 0 .6-.1.8-.4.4-.5.3-1.1-.2-1.4zM13.27 10.69c.38.4 1.01.42 1.41.04 2.27-2.16 2.08-5.51-.01-7.46a.996.996 0 10-1.36 1.46c1.28 1.19 1.39 3.21-.01 4.54-.39.39-.41 1.02-.03 1.42z","M16.6.2c-.4-.3-1.1-.3-1.4.2-.3.4-.3 1.1.2 1.4C17.1 3.1 18 4.9 18 7c0 2-1 4.1-2.6 5.2-.5.3-.6.9-.2 1.4.2.3.5.4.8.4.2 0 .4-.1.6-.2C18.7 12.3 20 9.7 20 7c.09-2.8-1.2-5.1-3.4-6.8z"],changes:["M18 16H2c-1.1 0-2 .9-2 2s.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2zM3 5c.28 0 .53-.11.71-.29L5 3.41V13c0 .55.45 1 1 1s1-.45 1-1V3.41L8.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C6.53.11 6.28 0 6 0s-.53.11-.71.29l-3 3A1.003 1.003 0 003 5zm7.29 5.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L15 10.59V1c0-.55-.45-1-1-1s-1 .45-1 1v9.59L11.71 9.3A.965.965 0 0011 9a1.003 1.003 0 00-.71 1.71z"],chart:["M7 11v8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-8l-2 2-4-2zm-7 8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-8l-6 3v5zM17 7l-3 3v9c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V8.74c-.26.15-.58.26-1 .26-1.92 0-2-2-2-2zm2-6h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59L10.8 8.78 7.45 7.11v.01C7.31 7.05 7.16 7 7 7s-.31.05-.44.11V7.1l-6 3v.01c-.33.17-.56.5-.56.89 0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L7 9.12l3.55 1.78v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L18 4.41V6c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],chat:["M19 0H7c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h5.59l3.71 3.71c.17.18.42.29.7.29.55 0 1-.45 1-1v-3h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 13c-1.1 0-2-.9-2-2V4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h1v3a1.003 1.003 0 001.71.71L7.41 16H13c.55 0 1-.45 1-1v-.17L12.17 13H7z"],"chevron-backward":["M8.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L7 8.59V4c0-.55-.45-1-1-1s-1 .45-1 1v12c0 .55.45 1 1 1s1-.45 1-1v-4.59l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L8.41 10z"],"chevron-down":["M16 6c-.28 0-.53.11-.71.29L10 11.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 6z"],"chevron-forward":["M13 3c-.55 0-1 .45-1 1v4.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5.29-5.3V16c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],"chevron-left":["M8.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L8.41 10z"],"chevron-right":["M13.71 9.29l-6-6a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"chevron-up":["M16.71 12.29l-6-6C10.53 6.11 10.28 6 10 6s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42L10 8.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],circle:["M10 0C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10S15.5 0 10 0zm0 18c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8z"],"circle-arrow-down":["M14 10c-.28 0-.53.11-.71.29L11 12.59V5c0-.55-.45-1-1-1s-1 .45-1 1v7.59L6.71 10.3A.965.965 0 006 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0014 10zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-left":["M15 9H7.41L9.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L7.41 11H15c.55 0 1-.45 1-1s-.45-1-1-1zm-5-9C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-right":["M15.71 9.29l-4-4a1.003 1.003 0 00-1.42 1.42L12.59 9H5c-.55 0-1 .45-1 1s.45 1 1 1h7.59l-2.29 2.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-up":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.71-13.71C10.53 4.11 10.28 4 10 4s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L9 7.41V15c0 .55.45 1 1 1s1-.45 1-1V7.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],citation:["M4 1C1.79 1 0 2.79 0 5s1.79 4 4 4c.1 0 .2-.01.3-.02C3.82 11.32 2.53 13 1 13c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7-4.48 7-10 0-2.21-1.79-4-4-4zM16 1c-2.21 0-4 1.79-4 4s1.79 4 4 4c.1 0 .2-.01.3-.02C15.82 11.32 14.53 13 13 13c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7-4.48 7-10 0-2.21-1.79-4-4-4z"],clean:["M7 0L5 5 0 6.998 5 9l2 5 2-5 5-1.995L9 5zM15 10l-1.5 3.496-3.5 1.499 3.5 1.498L15 20l1.5-3.507L20 15l-3.5-1.504z"],clip:["M0 1a1 1 0 011-1h5a1 1 0 010 2H2v4a1 1 0 01-2 0V1zm1 19a1 1 0 01-1-1v-5a1 1 0 112 0v4h4a1 1 0 110 2H1zm18 0a1 1 0 001-1v-5a1 1 0 10-2 0v4h-4a1 1 0 100 2h5zm0-20a1 1 0 011 1v5a1 1 0 11-2 0V2h-4a1 1 0 110-2h5zm-9 14a4 4 0 100-8 4 4 0 000 8z"],clipboard:["M13 2c0-.55-.45-1-1-1h-.78a1.98 1.98 0 00-3.44 0H7c-.55 0-1 .45-1 1v2h7V2z","M16 2h-2v3H5V2H3c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],cloud:["M15 7c-.12 0-.24.03-.36.04C13.83 4.69 11.62 3 9 3 5.69 3 3 5.69 3 9c0 .05.01.09.01.14A3.98 3.98 0 000 13c0 2.21 1.79 4 4 4h11c2.76 0 5-2.24 5-5s-2.24-5-5-5z"],"cloud-download":["M15 4c-.12 0-.24.03-.36.04C13.83 1.69 11.62 0 9 0 5.69 0 3 2.69 3 6c0 .05.01.09.01.14A3.98 3.98 0 000 10c0 2.21 1.79 4 4 4h.78c.55-.61 1.34-1 2.22-1v-2c0-1.66 1.34-3 3-3s3 1.34 3 3v2c.88 0 1.66.38 2.2.98C17.87 13.87 20 11.69 20 9c0-2.76-2.24-5-5-5zm-2 11c-.28 0-.53.11-.71.29L11 16.59V11c0-.55-.45-1-1-1s-1 .45-1 1v5.59L7.71 15.3A.965.965 0 007 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0013 15z"],"cloud-upload":["M10.71 10.29c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 13.41V19c0 .55.45 1 1 1s1-.45 1-1v-5.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM15 4c-.12 0-.24.03-.36.04C13.83 1.69 11.62 0 9 0 5.69 0 3 2.69 3 6c0 .05.01.09.01.14A3.98 3.98 0 000 10c0 2.21 1.79 4 4 4 0-.83.34-1.58.88-2.12l3-3a2.993 2.993 0 014.24 0l3 3-.01.01c.52.52.85 1.23.87 2.02C18.28 13.44 20 11.42 20 9c0-2.76-2.24-5-5-5z"],code:["M6 6a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L2.41 10 5.7 6.71c.19-.18.3-.43.3-.71zm6-4c-.46 0-.83.31-.95.73l-4 14c-.02.09-.05.17-.05.27 0 .55.45 1 1 1 .46 0 .83-.31.95-.73l4-14c.02-.09.05-.17.05-.27 0-.55-.45-1-1-1zm7.71 7.29l-4-4a1.003 1.003 0 00-1.42 1.42l3.3 3.29-3.29 3.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"code-block":["M19 5h-2V3c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v2H9V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM8.71 15.29a1.003 1.003 0 01-1.42 1.42l-4-4C3.11 12.53 3 12.28 3 12s.11-.53.29-.71l4-4a1.003 1.003 0 011.42 1.42L5.41 12l3.3 3.29zm8-2.58l-4 4a1.003 1.003 0 01-1.42-1.42l3.3-3.29-3.29-3.29A.965.965 0 0111 8a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71s-.11.53-.29.71z"],cog:["M19 8h-2.31c-.14-.46-.33-.89-.56-1.3l1.7-1.7a.996.996 0 000-1.41l-1.41-1.41a.996.996 0 00-1.41 0l-1.7 1.7c-.41-.22-.84-.41-1.3-.55V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v2.33c-.48.14-.94.34-1.37.58L5 2.28a.972.972 0 00-1.36 0L2.28 3.64c-.37.38-.37.99 0 1.36L3.9 6.62c-.24.44-.44.89-.59 1.38H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2.31c.14.46.33.89.56 1.3L2.17 15a.996.996 0 000 1.41l1.41 1.41c.39.39 1.02.39 1.41 0l1.7-1.7c.41.22.84.41 1.3.55V19c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.33c.48-.14.94-.35 1.37-.59L15 17.72c.37.37.98.37 1.36 0l1.36-1.36c.37-.37.37-.98 0-1.36l-1.62-1.62c.24-.43.45-.89.6-1.38H19c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-9 6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],"collapse-all":["M9.29 8.71c.18.18.43.29.71.29s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L10 6.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6zm1.42 2.58c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42l5.29-5.3 5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6z"],"column-layout":["M19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM5 17H2V3h3v14zm4 0H6V3h3v14zm9 0h-8V3h8v14z"],comment:["M19 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3v4a1.003 1.003 0 001.71.71l4.7-4.71H19c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 10c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm6 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm6 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],comparison:["M6 8H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm13-6h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 3h-5V3h5v2zM6 14H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM6 2H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm4-2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm9 14h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-5v-2h5v2zm0-9h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm0 3h-5V9h5v2z"],compass:["M15 10c0 .14-.03.28-.09.4l-3.99 8.98-.01.02a.991.991 0 01-1.82 0l-.01-.02-3.99-8.98c-.06-.12-.09-.26-.09-.4s.03-.28.09-.4L9.08.62 9.09.6a.991.991 0 011.82 0l.01.02 3.99 8.98c.06.12.09.26.09.4zm-5-6.54L7.09 10h5.81L10 3.46z"],compressed:["M19.89 6.56l-2.99-6h-.01C16.72.23 16.39 0 16 0H4c-.39 0-.72.23-.89.56H3.1l-3 6h.01C.05 6.69 0 6.84 0 7v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7c0-.16-.05-.31-.11-.44zM11 2h4.38l2 4H11V2zM4.62 2H9v4H2.62l2-4zM18 18H2V8h7v4.59L6.71 10.3A.965.965 0 006 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L11 12.59V8h7v10z"],confirm:["M9.71 5.29a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7a1.003 1.003 0 00-1.42-1.42L12 7.59l-2.29-2.3zm7.93 2.32c.23.75.36 1.56.36 2.39 0 4.42-3.58 8-8 8s-8-3.58-8-8a7.998 7.998 0 0111.8-7.04l1.46-1.46C13.73.56 11.93 0 10 0 4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-1.4-.29-2.73-.81-3.95l-1.55 1.56z"],console:["M19 19H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h18c.55 0 1 .45 1 1v16c0 .55-.45 1-1 1zM18 6H2v11h16V6zM4 8c.28 0 .53.11.71.29l2 2c.18.18.29.43.29.71s-.11.53-.29.71l-2 2a1.003 1.003 0 01-1.42-1.42L4.59 11l-1.3-1.29A1.003 1.003 0 014 8zm5 4h3c.55 0 1 .45 1 1s-.45 1-1 1H9c-.55 0-1-.45-1-1s.45-1 1-1z"],contrast:["M19 8h-1.26c-.19-.73-.48-1.42-.85-2.06l.94-.94a.996.996 0 000-1.41l-1.41-1.41a.996.996 0 00-1.41 0l-.94.94c-.65-.38-1.34-.67-2.07-.86V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v1.26c-.76.2-1.47.5-2.13.89L5 2.28a.972.972 0 00-1.36 0L2.28 3.64c-.37.38-.37.98 0 1.36l.87.87c-.39.66-.69 1.37-.89 2.13H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h1.26c.19.73.48 1.42.85 2.06l-.94.94a.996.996 0 000 1.41l1.41 1.41c.39.39 1.02.39 1.41 0l.94-.94c.64.38 1.33.66 2.06.85V19c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-1.26c.76-.2 1.47-.5 2.13-.89l.88.87c.37.37.98.37 1.36 0l1.36-1.36c.37-.38.37-.98 0-1.36l-.87-.87c.4-.65.7-1.37.89-2.13H19c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-9 7c-2.76 0-5-2.24-5-5s2.24-5 5-5v10z"],control:["M17 10h-7v7h7v-7zm0-7h-7v6h7V3zM9 3H3v14h6V3zm10-3H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V2h16v16z"],"credit-card":["M19 3H1c-.55 0-1 .45-1 1v2h20V4c0-.55-.45-1-1-1zM0 16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V8H0v8zm6.5-2h7c.28 0 .5.22.5.5s-.22.5-.5.5h-7c-.28 0-.5-.22-.5-.5s.22-.5.5-.5zm-4 0h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5z"],cross:["M11.41 10l4.29-4.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-4.29-4.3a1.003 1.003 0 00-1.42 1.42L8.59 10 4.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4.29-4.3 4.29 4.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z"],crown:["M2 8l4 2 4-5 4 5 4-2-1 7H3L2 8zm8-6a1 1 0 110 2 1 1 0 010-2zM1 5a1 1 0 110 2 1 1 0 010-2zm18 0a1 1 0 110 2 1 1 0 010-2zM3 16h14v2H3v-2z"],cube:["M1.953 4.481l7.41-4.02c.394-.215.88-.215 1.275 0l7.409 4.02L10 9.22 1.953 4.48zm-.817.68L9.5 10.085v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547zm17.728 0c.088.166.136.353.136.546v8.35c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281l8.364-4.926z"],"cube-add":["M17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2zm-3.969 4.435L10 9.22 1.953 4.48l7.41-4.02c.394-.215.88-.215 1.275 0l1.33.721A3.001 3.001 0 0013 7c0 .148.01.293.031.435zm.319.972A3 3 0 0019 7v7.057c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281l2.85-1.679zM1.136 5.16L9.5 10.086v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547z"],"cube-remove":["M11.968 1.182A3.001 3.001 0 0013 7h.77L10 9.22 1.953 4.48l7.41-4.02c.394-.215.88-.215 1.275 0l1.33.721zM19 7v7.057c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281L15.74 7H19zM1.136 5.16L9.5 10.086v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547zM13 3h6a1 1 0 010 2h-6a1 1 0 010-2z"],"curved-range-chart":["M19 16H3.02l2.14-1.74c2.25 1.7 7.33.46 11.83-2.99l-1.29-1.5c-3.56 2.74-7.31 4.03-8.93 3.19l10.55-8.57-.63-.78-10.59 8.6c-.64-1.64 1.46-4.91 5.09-7.7L9.9 3.01c-4.6 3.54-6.91 8.12-5.41 10.51L2 15.54V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],cut:["M16 2s.72-1.28 0-2l-5.29 6.25 1.28 1.54L16 2zm.08 10c-.55 0-1.07.12-1.54.32L4.31 0c-.7.72 0 2 0 2l4.45 6.56-3.19 3.77C5.09 12.12 4.56 12 4 12c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.65-.17-1.26-.45-1.8l2.54-3.67 2.49 3.67c-.27.54-.44 1.15-.44 1.8 0 2.21 1.76 4 3.92 4 2.17 0 3.92-1.79 3.92-4 .02-2.21-1.74-4-3.9-4zM4 18c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm12.08 0c-1.08 0-1.96-.9-1.96-2s.88-2 1.96-2 1.96.9 1.96 2-.88 2-1.96 2z"],cycle:["M16 10a4 4 0 110 8 4 4 0 010-8zM4 10a4 4 0 110 8 4 4 0 010-8zm7.299-5.543l.087.089 1.93 2.232 2.048.708a1 1 0 01.65 1.16l-.031.112a1 1 0 01-1.16.65l-.112-.031-2.302-.796a1 1 0 01-.337-.197l-.092-.094-1.387-1.603-1.891 1.982 2.046 2.274a1 1 0 01.25.547l.007.122v4.24a1 1 0 01-1.993.117l-.007-.117-.001-3.857-2.408-2.676a1 1 0 01-.063-1.26l.082-.099 3.29-3.45a1 1 0 011.394-.053zM16 12a2 2 0 100 4 2 2 0 000-4zM4 12a2 2 0 100 4 2 2 0 000-4zm9.5-10a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],dashboard:["M6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM4 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-5C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm6-9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-8 5c0 1.1.9 2 2 2s2-.9 2-2c0-.33-2-8-2-8s-2 7.67-2 8zm6-9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"data-connection":["M2 11.9c.935.674 2.339 1.217 4.023 1.536A6.996 6.996 0 009.393 20c-3.988-.019-7.231-1.083-7.387-2.4L2 17.5v-5.6zM13 8c3.315 0 6 2.685 6 6s-2.685 6-6 6-6-2.685-6-6 2.685-6 6-6zm1 1l-4 6h2.5l-.5 4 4-6h-2.5l.5-4zm3-4.6v3.855a7.003 7.003 0 00-10.779 3.992c-2.408-.391-4.097-1.202-4.214-2.142L2 10V4.4c1.525 1.1 4.3 1.85 7.5 1.85S15.475 5.5 17 4.4zM9.5 0C13.637 0 17 1.125 17 2.5S13.637 5 9.5 5C5.35 5 2 3.875 2 2.5S5.35 0 9.5 0z"],"data-lineage":["M1.053 0C.47 0 0 .471 0 1.053V4.21c0 .58.471 1.052 1.053 1.052h3.275a6.332 6.332 0 003.728 4.738 6.33 6.33 0 00-3.728 4.737l-3.275-.001C.47 14.737 0 15.208 0 15.789v3.158C0 19.53.471 20 1.053 20h7.435c.581 0 1.053-.471 1.053-1.053V15.79c0-.58-.472-1.052-1.053-1.052H5.406a5.293 5.293 0 015.195-4.21v2.105c0 .58.471 1.052 1.052 1.052h7.294c.582 0 1.053-.471 1.053-1.052V7.368c0-.58-.471-1.052-1.053-1.052h-7.294c-.581 0-1.052.471-1.052 1.052v2.106a5.293 5.293 0 01-5.194-4.21h3.081c.581 0 1.053-.472 1.053-1.053V1.053C9.54.47 9.069 0 8.488 0H1.053z"],database:["M2.01 5.1v5.4c0 1.38 3.58 2.5 8 2.5s8-1.12 8-2.5V5.1c-1.49 1.13-4.51 1.9-8 1.9-3.48 0-6.5-.77-8-1.9zm8 .9c4.42 0 8-1.12 8-2.5s-3.58-2.5-8-2.5-8 1.12-8 2.5S5.6 6 10.01 6zm-8 6.1v5.4c0 1.38 3.58 2.5 8 2.5s8-1.12 8-2.5v-5.4c-1.49 1.13-4.51 1.9-8 1.9-3.48 0-6.5-.77-8-1.9z"],delete:["M15 6a1.003 1.003 0 00-1.71-.71L10 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L8.59 10 5.3 13.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3.29-3.3 3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10l3.29-3.29c.19-.18.3-.43.3-.71zm-5-6C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],delta:["M10 0L0 20h20L10 0zM9 6l6 12H3L9 6z"],"derive-column":["M7.1 8.2h-.99c.28-1.11.66-1.92 1.12-2.43.28-.32.56-.48.83-.48.05 0 .1.02.13.05.03.03.05.07.05.12 0 .04-.04.13-.11.25a.64.64 0 00-.12.35c0 .15.06.28.18.39.12.11.27.16.45.16.2 0 .36-.07.49-.2s.2-.31.2-.54c0-.26-.1-.47-.3-.63-.19-.16-.51-.24-.95-.24-.68 0-1.3.19-1.85.58-.56.38-1.09 1.02-1.59 1.91-.17.3-.34.5-.49.59-.15.08-.4.13-.74.12l-.23.77h.95l-1.39 5.24c-.23.86-.39 1.39-.47 1.59-.12.29-.3.54-.54.75-.1.08-.21.12-.35.12-.04 0-.07-.01-.1-.03l-.03-.04c0-.02.03-.07.1-.13.07-.07.1-.17.1-.31 0-.15-.05-.28-.16-.38-.11-.1-.27-.15-.47-.15-.25 0-.44.07-.59.2-.15.12-.23.28-.23.46 0 .19.09.36.27.5.19.14.47.21.86.21.61 0 1.16-.15 1.63-.46.48-.31.89-.78 1.25-1.43.35-.64.72-1.68 1.09-3.11l.8-3.03h.96l.24-.77zM19 0h-9c-.55 0-1 .45-1 1v3h2V2h7v16h-7v-2H9v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-8.79 13.49c.15.28.32.49.52.61.19.12.44.19.73.19.28 0 .57-.1.86-.3.38-.25.77-.69 1.17-1.31l-.25-.14c-.27.37-.48.6-.61.69-.09.06-.19.09-.31.09-.14 0-.28-.09-.42-.26-.23-.29-.54-1.09-.93-2.4.35-.59.64-.97.87-1.15.17-.13.35-.2.55-.2.07 0 .2.03.39.08s.36.08.5.08c.2 0 .37-.07.5-.2.15-.14.22-.31.22-.52 0-.22-.07-.4-.2-.53s-.33-.2-.58-.2c-.22 0-.43.05-.63.15-.2.1-.45.32-.75.67-.23.25-.56.7-1.01 1.33a6.52 6.52 0 00-.91-2.15l-2.39.39-.05.25c.18-.03.33-.05.45-.05.24 0 .43.1.59.3.25.31.59 1.24 1.02 2.8-.34.44-.58.73-.7.87-.21.22-.38.36-.52.43-.1.05-.22.08-.35.08-.1 0-.26-.05-.49-.16a1.01 1.01 0 00-.42-.11c-.23 0-.42.07-.57.22-.15.14-.23.33-.23.55 0 .21.07.38.21.51.14.13.33.2.56.2.23 0 .44-.05.64-.14.2-.09.45-.29.75-.59s.72-.78 1.25-1.43c.21.61.39 1.06.54 1.35z"],desktop:["M19 0H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h5.67l-.5 3H5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1h-1.17l-.5-3H19c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 13H2V2h16v11z"],diagnosis:["M4 2a1 1 0 01.117 1.993L4 4v5a2 2 0 001.85 1.995L6 11a2 2 0 001.995-1.85L8 9V4a1 1 0 01-.117-1.993L8 2h1a1 1 0 01.993.883L10 3v6a4.002 4.002 0 01-3 3.874V13a3 3 0 003 3 4 4 0 003.995-3.8L14 12V8.792a2.5 2.5 0 112 0V12a6 6 0 01-6 6 5 5 0 01-4.995-4.783L5 13v-.126A4.002 4.002 0 012.005 9.2L2 9V3a1 1 0 01.883-.993L3 2h1z"],"diagram-tree":["M19 10v5h-2v-4h-6v4H9v-4H3v4H1v-5a1 1 0 011-1h7V5h2v4h7a1 1 0 011 1zM1 16h2a1 1 0 011 1v2a1 1 0 01-1 1H1a1 1 0 01-1-1v-2a1 1 0 011-1zm16 0h2a1 1 0 011 1v2a1 1 0 01-1 1h-2a1 1 0 01-1-1v-2a1 1 0 011-1zm-8 0h2a1 1 0 011 1v2a1 1 0 01-1 1H9a1 1 0 01-1-1v-2a1 1 0 011-1zM9 0h2a1 1 0 011 1v2a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1z"],"direction-left":["M20 3.02l-20 7 20 7-5-7z"],"direction-right":["M20 10.02l-20-7 5 7-5 7z"],disable:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM2 10c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L3.69 14.9A7.902 7.902 0 012 10zm8 8c-1.85 0-3.55-.63-4.9-1.69L16.31 5.1A7.902 7.902 0 0118 10c0 4.42-3.58 8-8 8z"],document:["M11.98 0h-8c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V6l-6-6zm4 18h-11V2h6v5h5v11z"],"document-open":["M8 15c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1h2.59L1.3 16.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 12.41V15zm5-15H5c-.55 0-1 .45-1 1v6h2V2h6v5h5v11H6v-.76L4.04 19.2c.1.45.48.8.96.8h13c.55 0 1-.45 1-1V6l-6-6z"],"document-share":["M14.09 10.09c-.31.31-.67.57-1.09.72V18H2V2h6v5h1.18c.15-.42.39-.8.7-1.11v-.01l2.45-2.45c-.42-.29-.78-.65-1.01-1.11L9 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V9.24l-.88.88-.03-.03zM19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],dollar:["M15.57 11.19c-.27-.51-.63-.93-1.07-1.26-.44-.33-.95-.6-1.51-.79-.56-.2-1.14-.36-1.72-.5-.6-.14-1.19-.26-1.75-.38-.57-.13-1.07-.27-1.51-.44-.44-.17-.8-.38-1.07-.63s-.41-.59-.41-1c0-.33.09-.6.28-.81.19-.21.42-.36.69-.47.27-.11.57-.18.88-.22.31-.04.58-.06.8-.06.71 0 1.35.14 1.9.41.55.27.91.81 1.06 1.62h3.36c-.09-.84-.32-1.56-.69-2.16-.37-.6-.83-1.08-1.38-1.45-.56-.37-1.18-.64-1.86-.81-.19-.05-.38-.07-.57-.1V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v1.1c-.22.03-.43.05-.66.1-.73.13-1.39.37-1.98.71-.6.34-1.09.8-1.47 1.35-.39.56-.58 1.25-.58 2.08 0 .76.13 1.41.4 1.93.26.52.62.95 1.06 1.28.44.33.94.6 1.5.79.55.2 1.13.36 1.74.5.58.14 1.16.26 1.72.38s1.07.26 1.51.43c.44.17.8.39 1.09.66.28.27.43.63.45 1.06.02.43-.08.78-.3 1.04-.22.26-.49.47-.83.6-.34.14-.7.23-1.09.28-.39.05-.73.07-1.03.07-.87 0-1.61-.2-2.23-.59-.62-.39-.98-1.08-1.07-2.06H3c.02.9.19 1.68.52 2.34.33.66.78 1.21 1.35 1.65.57.44 1.25.77 2.03.98.35.1.71.16 1.08.21V19c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1.13c.25-.04.5-.07.76-.13.77-.18 1.47-.46 2.1-.85.63-.39 1.14-.9 1.54-1.53.4-.63.59-1.39.59-2.29.01-.75-.13-1.37-.4-1.88z"],dot:["M10 6a4 4 0 100 8 4 4 0 100-8z"],"double-caret-horizontal":["M8 4c-.24 0-.46.1-.63.24l-.01-.01-6 5 .01.01c-.22.19-.37.45-.37.76s.15.57.37.76l-.01.01 6 5 .01-.01c.17.14.39.24.63.24.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm11 6c0-.31-.15-.57-.37-.76l.01-.01-6-5-.01.01C12.46 4.1 12.24 4 12 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1 .24 0 .46-.1.63-.24l.01.01 6-5-.01-.01c.22-.19.37-.45.37-.76z"],"double-caret-vertical":["M5 9h10c.55 0 1-.45 1-1 0-.24-.1-.46-.24-.63l.01-.01-5-6-.01.01C10.57 1.15 10.31 1 10 1s-.57.15-.76.37l-.01-.01-5 6 .01.01C4.1 7.54 4 7.76 4 8c0 .55.45 1 1 1zm10 2H5c-.55 0-1 .45-1 1 0 .24.1.46.24.63l-.01.01 5 6 .01-.01c.19.22.45.37.76.37s.57-.15.76-.37l.01.01 5-6-.01-.01c.14-.17.24-.39.24-.63 0-.55-.45-1-1-1z"],"double-chevron-down":["M9.29 10.71c.18.18.43.29.71.29s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L10 8.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6zM16 9c-.28 0-.53.11-.71.29L10 14.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 9z"],"double-chevron-left":["M5.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L5.41 10zm6 0l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L11.41 10z"],"double-chevron-right":["M11 10c0-.28-.11-.53-.29-.71l-6-6a1.003 1.003 0 00-1.42 1.42L8.59 10 3.3 15.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71zm5.71-.71l-6-6a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"double-chevron-up":["M4 11c.28 0 .53-.11.71-.29L10 5.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6A.997.997 0 0010 3c-.28 0-.53.11-.71.29l-6 6A1.003 1.003 0 004 11zm6.71-1.71A.997.997 0 0010 9c-.28 0-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42l5.29-5.3 5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6z"],"doughnut-chart":["M16 10c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6V0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10h-4zm-.09-1h4.04C19.48 4.28 15.72.52 11 .05V4.1A5.98 5.98 0 0115.91 9z"],download:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm4.71 11.71l-4 4c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-4-4a1.003 1.003 0 011.42-1.42L9 12.59V5c0-.55.45-1 1-1s1 .45 1 1v7.59l2.29-2.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71z"],"drag-handle-horizontal":["M7.5 11c-.83 0-1.5.67-1.5 1.5S6.67 14 7.5 14 9 13.33 9 12.5 8.33 11 7.5 11zm-5-5C1.67 6 1 6.67 1 7.5S1.67 9 2.5 9 4 8.33 4 7.5 3.33 6 2.5 6zm0 5c-.83 0-1.5.67-1.5 1.5S1.67 14 2.5 14 4 13.33 4 12.5 3.33 11 2.5 11zm15-2c.83 0 1.5-.67 1.5-1.5S18.33 6 17.5 6 16 6.67 16 7.5 16.67 9 17.5 9zm-5 2c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm5 0c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm-10-5C6.67 6 6 6.67 6 7.5S6.67 9 7.5 9 9 8.33 9 7.5 8.33 6 7.5 6zm5 0c-.83 0-1.5.67-1.5 1.5S11.67 9 12.5 9 14 8.33 14 7.5 13.33 6 12.5 6z"],"drag-handle-vertical":["M7.5 6C6.67 6 6 6.67 6 7.5S6.67 9 7.5 9 9 8.33 9 7.5 8.33 6 7.5 6zm0 5c-.83 0-1.5.67-1.5 1.5S6.67 14 7.5 14 9 13.33 9 12.5 8.33 11 7.5 11zm0 5c-.83 0-1.5.67-1.5 1.5S6.67 19 7.5 19 9 18.33 9 17.5 8.33 16 7.5 16zm5-12c.83 0 1.5-.67 1.5-1.5S13.33 1 12.5 1 11 1.67 11 2.5 11.67 4 12.5 4zm-5-3C6.67 1 6 1.67 6 2.5S6.67 4 7.5 4 9 3.33 9 2.5 8.33 1 7.5 1zm5 10c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-10c-.83 0-1.5.67-1.5 1.5S11.67 9 12.5 9 14 8.33 14 7.5 13.33 6 12.5 6z"],draw:["M17.7 12.7c0-.1 0-.2-.1-.3l-2-7c-.1-.3-.3-.6-.6-.7L1.8 0l-.6.5L7.7 7c.3-.2.6-.3 1-.3 1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2c0-.4.1-.7.3-1L.5 1.2l-.5.6L4.7 15c.1.3.4.5.7.6l7 2c.1 0 .2.1.3.1.3 0 .5-.1.7-.3l4-4c.2-.2.3-.5.3-.7zm1 1c-.3 0-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7 0 .5.4 1 1 1 .3 0 .5-.1.7-.3l4-4c.2-.2.3-.4.3-.7 0-.6-.5-1-1-1z"],"drawer-left":["M9 0a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h8zM8 2H2v16h6V2zm2 7h6.59L14.3 6.71A.965.965 0 0114 6a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10V9z"],"drawer-left-filled":["M1 0h8a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1zm9 9h6.59L14.3 6.71A.965.965 0 0114 6a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10V9z"],"drawer-right":["M19 0a1 1 0 011 1v18a1 1 0 01-1 1h-8a1 1 0 01-1-1V1a1 1 0 011-1h8zm-1 2h-6v16h6V2zm-8 7H3.41L5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 11H10V9z"],"drawer-right-filled":["M11 0h8a1 1 0 011 1v18a1 1 0 01-1 1h-8a1 1 0 01-1-1V1a1 1 0 011-1zm-1 9H3.41L5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 11H10V9z"],"drive-time":["M20.01 7.7c0-.63-.5-1.14-1.1-1.14h-1.32l-.95-2.57c-.24-.64-.95-1.31-1.59-1.5 0 0-1.65-.49-5.05-.49s-5.04.49-5.04.49c-.63.19-1.35.86-1.59 1.5l-.95 2.57H1.1C.5 6.56 0 7.07 0 7.7c0 .63.5 1.14 1.1 1.14h.47l-.34.91c-.24.64-.43 1.72-.43 2.4v5.39c0 .8.63 1.45 1.4 1.45.77 0 1.4-.65 1.4-1.45v-.83h12.8v.83c0 .8.63 1.45 1.4 1.45s1.4-.65 1.4-1.45v-5.39c0-.68-.19-1.77-.43-2.4l-.34-.91h.47c.61 0 1.11-.51 1.11-1.14zm-16.47.34l1.12-3.16c.08-.22.32-.39.54-.39h9.6c.22 0 .46.17.54.39l1.12 3.16c.08.21-.04.39-.26.39H3.8c-.22-.01-.34-.18-.26-.39zm.96 4.94c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.68 1.5 1.5c0 .83-.67 1.5-1.5 1.5zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],duplicate:["M15 4H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 14H2V6h12v12zm5-18H5c-.55 0-1 .45-1 1v2h2V2h12v12h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],edit:["M4.59 12.59l2.83 2.83 7.65-7.65-2.83-2.83-7.65 7.65zM2 18l4.41-1.59-2.81-2.79L2 18zM16 2c-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.83 1.65-1.65A2.006 2.006 0 0016 2z"],eject:["M4 12h12c.55 0 1-.45 1-1 0-.25-.1-.47-.25-.64l.01-.01-6-7-.01.01C10.57 3.14 10.3 3 10 3s-.57.14-.75.36l-.01-.01-6 7 .01.01c-.15.17-.25.39-.25.64 0 .55.45 1 1 1zm12 1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],emoji:["M10 0c5.523 0 10 4.477 10 10s-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0zm0 2a8 8 0 100 16 8 8 0 000-16zm-4 8l.015.215C6.219 12.42 7.925 14 10 14a4 4 0 003.995-3.8L14 10h2l-.013.238C15.754 13.552 13.163 16 10 16a6 6 0 01-5.996-5.775L4 10h2zm1.5-4a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm5 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],endorsed:["M19.83 9.38L18.81 7.6V5.62c0-.45-.23-.85-.61-1.08l-1.71-1-1.02-1.76a1.25 1.25 0 00-1.08-.61h-2.03l-1.74-1c-.38-.23-.87-.23-1.25 0l-1.74 1H5.65c-.44 0-.85.23-1.08.61L3.58 3.5l-1.8 1.04c-.38.24-.62.64-.62 1.08v2.06L.17 9.4c-.11.19-.17.4-.17.61s.06.42.17.61l.99 1.72v2.06c0 .45.23.85.61 1.08l1.78 1.02.99 1.72c.23.38.63.61 1.08.61h1.99l1.74 1c.19.11.41.17.62.17.21 0 .42-.06.61-.17l1.74-1h2.03c.44 0 .85-.23 1.08-.61l1.02-1.76 1.71-1c.38-.23.61-.64.61-1.08v-1.97l1.02-1.78c.27-.38.27-.85.04-1.25zm-5.08-.71l-5.01 5.01c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.29l-3.01-3.01a1.003 1.003 0 011.42-1.42l2.3 2.3 4.31-4.3a1.003 1.003 0 011.71.71c0 .28-.12.53-.3.71z"],envelope:["M0 4.01v11.91l6.27-6.27L0 4.01zm18.91-1.03H1.09L10 10.97l8.91-7.99zm-5.18 6.66L20 15.92V4.01l-6.27 5.63zm-3.23 2.9c-.13.12-.31.19-.5.19s-.37-.07-.5-.19l-2.11-1.89-6.33 6.33h17.88l-6.33-6.33-2.11 1.89z"],equals:["M4 7h12a1 1 0 010 2H4a1 1 0 110-2zm0 4h12a1 1 0 010 2H4a1 1 0 010-2z"],eraser:["M18.71 8.43c.39-.4.39-1.05 0-1.45l-5.53-5.72a.967.967 0 00-1.4 0L1.29 12.1c-.39.4-.39 1.05 0 1.45l4.25 4.39 2.13 2.05h9.27c.02 0 .03.01.05.01.55 0 1-.45 1-1s-.45-1-1-1H9.46l.05-.05h.01l.81-.84 8.38-8.68zM7.52 17.94l-4.95-5.12 4.46-4.61 4.95 5.12-4.46 4.61z"],error:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm1 16H9v-2h2v2zm0-3H9V4h2v9z"],euro:["M8.89 4.47c.56-.31 1.23-.47 2.03-.47.44 0 .85.07 1.25.22.4.14.76.35 1.07.6.17.14.33.3.47.47l2.32-2.32c-.16-.15-.3-.32-.47-.46-.62-.49-1.33-.87-2.12-1.13-.8-.25-1.64-.38-2.52-.38-1.24 0-2.35.22-3.33.66-.99.44-1.82 1.05-2.49 1.82-.68.78-1.2 1.68-1.56 2.72-.09.26-.13.54-.2.8H2c-.55 0-1 .45-1 1s.45 1 1 1h1.04c-.01.2-.04.38-.04.58 0 .15.03.28.03.42H2c-.55 0-1 .45-1 1s.45 1 1 1h1.31c.07.3.13.6.23.89.36 1.02.88 1.92 1.56 2.67.68.76 1.51 1.35 2.49 1.79.98.43 2.09.65 3.33.65.99 0 1.9-.15 2.73-.46.83-.3 1.55-.74 2.17-1.32.03-.03.05-.06.08-.09l-2.41-2.15c-.01.01-.02.02-.02.03-.61.67-1.46 1-2.54 1-.8 0-1.47-.16-2.03-.47-.56-.31-1.01-.72-1.35-1.24-.28-.38-.47-.83-.63-1.3H12c.55 0 1-.45 1-1s-.45-1-1-1H6.56c0-.14-.02-.28-.02-.42 0-.2.02-.39.03-.58H13c.55 0 1-.45 1-1s-.45-1-1-1H6.94c.15-.46.34-.9.59-1.28.35-.52.8-.94 1.36-1.25zM18 11.38v0z"],exchange:["M2.5 8a2.5 2.5 0 000 5 2.5 2.5 0 000-5zm10.35 3.15a.495.495 0 10-.7.7L13.3 13H5.5c-.28 0-.5.22-.5.5s.22.5.5.5h7.79l-1.15 1.15c-.08.09-.14.21-.14.35a.495.495 0 00.85.35l2-2c.09-.09.15-.21.15-.35s-.06-.26-.15-.35l-2-2zM17.5 8a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM7.15 9.85a.495.495 0 10.7-.7L6.71 8h7.79c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H6.71l1.15-1.15c.08-.09.14-.21.14-.35a.495.495 0 00-.85-.35l-2 2c-.09.09-.15.21-.15.35s.06.26.15.35l2 2z"],"exclude-row":["M1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zM0 13a1.003 1.003 0 001.71.71L4 11.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L5.41 10 7.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L4 8.59l-2.29-2.3A1.003 1.003 0 00.29 7.71L2.59 10 .3 12.29c-.19.18-.3.43-.3.71zm18-5h-7c-1.1 0-2 .9-2 2s.9 2 2 2h7c1.1 0 2-.9 2-2s-.9-2-2-2zm1 9H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"expand-all":["M4 9c.28 0 .53-.11.71-.29L10 3.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6C10.53 1.11 10.28 1 10 1s-.53.11-.71.29l-6 6A1.003 1.003 0 004 9zm12 2c-.28 0-.53.11-.71.29L10 16.59 4.71 11.3A.965.965 0 004 11a1.003 1.003 0 00-.71 1.71l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 11z"],export:["M5 7c.28 0 .53-.11.71-.29L9 3.41V15c0 .55.45 1 1 1s1-.45 1-1V3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-5-5C10.53.11 10.28 0 10 0s-.53.11-.71.29l-5 5A1.003 1.003 0 005 7zm14 7c-.55 0-1 .45-1 1v3H2v-3c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"eye-off":["M20 9.96v-.03-.01-.02-.02a.794.794 0 00-.21-.43c-.55-.69-1.19-1.3-1.85-1.87l-3.93 2.62a3.966 3.966 0 01-3.96 3.77c-.47 0-.91-.1-1.33-.24l-2.24 1.49c.52.21 1.05.39 1.6.51 1.21.27 2.43.28 3.64.05 1.11-.21 2.17-.64 3.17-1.18 1.56-.84 2.99-2 4.23-3.3.23-.24.46-.49.67-.75a.87.87 0 00.21-.43v-.02-.02-.01-.03V10v-.04zm-.46-5.14c.27-.18.46-.47.46-.82 0-.55-.45-1-1-1-.21 0-.39.08-.54.18l-.01-.02L15 5.46c-.95-.53-1.95-.96-3.01-1.2a9.158 9.158 0 00-3.65-.04c-1.11.21-2.17.64-3.17 1.18-1.56.84-2.99 2-4.23 3.3-.23.24-.46.48-.67.75-.27.34-.27.76 0 1.1.64.79 1.39 1.5 2.16 2.15.26.21.52.41.79.61L.44 15.16l.01.02A1 1 0 000 16c0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 18-12-.01-.02zm-8.67 3.4c-.25-.12-.53-.2-.83-.2-1.1 0-1.99.89-1.99 1.99 0 .03.02.06.02.09l-1.78 1.19c-.14-.4-.22-.83-.22-1.28 0-2.19 1.78-3.97 3.98-3.97 1.01 0 1.91.38 2.61 1l-1.79 1.18z"],"eye-on":["M13.3 8.71c.18.18.43.29.71.29s.53-.11.71-.29l4.99-5a1.003 1.003 0 00-1.42-1.42L14 6.58l-2.29-2.29a.956.956 0 00-.7-.29 1.003 1.003 0 00-.71 1.71l3 3zM20 9.96v-.03-.01-.02-.02a.823.823 0 00-.21-.44c-.44-.55-.94-1.05-1.46-1.52l-2.2 2.2c-.55.54-1.3.88-2.12.88-.05 0-.09-.01-.14-.01a3.978 3.978 0 01-3.86 3.02 4.007 4.007 0 01-1.66-7.65A2.97 2.97 0 018.02 5c0-.28.05-.54.12-.8-1.05.22-2.07.64-3.02 1.15-1.57.85-3 2.02-4.24 3.33-.23.25-.46.5-.67.76-.28.35-.28.77 0 1.12.64.8 1.4 1.52 2.17 2.17 1.66 1.41 3.56 2.58 5.66 3.06 1.21.27 2.43.29 3.65.05 1.11-.21 2.18-.65 3.18-1.19 1.57-.85 3-2.02 4.24-3.33.23-.24.46-.49.67-.76.11-.12.18-.27.21-.44v-.02-.02-.01-.03V10c.01-.01.01-.03.01-.04zm-9.99 2.05c1.03 0 1.87-.79 1.98-1.8l-.09-.09-.01.01-2.1-2.11c-1 .11-1.77.95-1.77 1.98-.01 1.11.89 2.01 1.99 2.01z"],"eye-open":["M10.01 7.984A2.008 2.008 0 008.012 9.99c0 1.103.9 2.006 1.998 2.006a2.008 2.008 0 001.998-2.006c0-1.103-.9-2.006-1.998-2.006zM20 9.96v-.03-.01-.02-.02a.827.827 0 00-.21-.442c-.64-.802-1.398-1.514-2.168-2.166-1.658-1.404-3.566-2.587-5.664-3.058a8.982 8.982 0 00-3.656-.05c-1.11.2-2.178.641-3.177 1.183-1.569.852-2.997 2.016-4.246 3.33-.23.25-.46.49-.67.761-.279.351-.279.773 0 1.124.64.802 1.4 1.514 2.169 2.166 1.658 1.404 3.566 2.577 5.664 3.058 1.209.271 2.438.281 3.656.05 1.11-.21 2.178-.651 3.177-1.193 1.569-.852 2.997-2.016 4.246-3.33.23-.24.46-.49.67-.751.11-.12.179-.271.209-.442v-.02-.02-.01-.03V10v-.04zM10.01 14A4.003 4.003 0 016.014 9.99a4.003 4.003 0 013.996-4.011 4.003 4.003 0 013.996 4.011 4.003 4.003 0 01-3.996 4.011z"],"fast-backward":["M18 3c-.23 0-.42.09-.59.21l-.01-.01L11 8V4c0-.55-.45-1-1-1-.23 0-.42.09-.59.21L9.4 3.2l-8 6 .01.01C1.17 9.4 1 9.67 1 10s.17.6.41.79l-.01.01 8 6 .01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1v-4l6.4 4.8.01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"fast-forward":["M19 10c0-.33-.17-.6-.41-.79l.01-.01-8-6-.01.01C10.42 3.09 10.23 3 10 3c-.55 0-1 .45-1 1v4L2.6 3.2l-.01.01C2.42 3.09 2.23 3 2 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01L9 12v4c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01 8-6-.01-.01c.24-.19.41-.46.41-.79z"],feed:["M2.5 15a2.5 2.5 0 000 5 2.5 2.5 0 000-5zm.5-5c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5 2.24 5 5 0 .55.45 1 1 1s1-.45 1-1c0-3.87-3.13-7-7-7zM3 0c-.55 0-1 .45-1 1s.45 1 1 1c8.28 0 15 6.72 15 15 0 .55.45 1 1 1s1-.45 1-1C20 7.61 12.39 0 3 0zm0 5c-.55 0-1 .45-1 1s.45 1 1 1c5.52 0 10 4.48 10 10 0 .55.45 1 1 1s1-.45 1-1C15 10.37 9.63 5 3 5z"],"feed-subscribed":["M2.5 15a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM3 2c1.76 0 3.44.31 5.01.87.03-.71.31-1.35.75-1.85C6.96.37 5.03 0 3 0c-.55 0-1 .45-1 1s.45 1 1 1zm10.32 4.67a.99.99 0 001.4 0l4.98-4.98c.19-.17.3-.42.3-.7 0-.55-.45-1-1-1a.99.99 0 00-.7.29l-4.27 4.27-2.28-2.28a.99.99 0 00-.7-.29c-.55 0-.99.45-.99 1 0 .28.11.52.29.7l2.97 2.99zM3 10c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5 2.24 5 5 0 .55.45 1 1 1s1-.45 1-1c0-3.87-3.13-7-7-7zm13.94-2.69l-.82.82-.02-.02c-.2.2-.42.37-.67.51A14.8 14.8 0 0118 17c0 .55.45 1 1 1s1-.45 1-1c0-3.61-1.14-6.94-3.06-9.69zM3 5c-.55 0-1 .45-1 1s.45 1 1 1c5.52 0 10 4.48 10 10 0 .55.45 1 1 1s1-.45 1-1C15 10.37 9.63 5 3 5z"],film:["M19 2h-5v3H6V2H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h5v-3h8v3h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM4 17H2v-2h2v2zm0-3H2v-2h2v2zm0-3H2V9h2v2zm0-3H2V6h2v2zm0-3H2V3h2v2zm10 8H6V7h8v6zm4 4h-2v-2h2v2zm0-3h-2v-2h2v2zm0-3h-2V9h2v2zm0-3h-2V6h2v2zm0-3h-2V3h2v2z"],filter:["M18 1H2a1.003 1.003 0 00-.71 1.71L7 8.41V18a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71V8.41l5.71-5.71c.18-.17.29-.42.29-.7 0-.55-.45-1-1-1z"],"filter-keep":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm4 11c-.28 0-.53.11-.71.29L15 16.59l-1.29-1.29A.965.965 0 0013 15a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0019 13z"],"filter-list":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm-4 8c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7c-.55 0-1 .45-1 1zm8 7h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0-4h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"filter-open":["M15 2c0 .28-.11.53-.29.7L10 7.41V13c0 .28-.11.53-.29.71l-3 3A1.003 1.003 0 015 16V7.41L.29 2.71A1.003 1.003 0 011 1h13c.55 0 1 .45 1 1zm4.707 11.293a1 1 0 010 1.414l-4 4c-.63.63-1.707.184-1.707-.707v-8c0-.89 1.077-1.337 1.707-.707l4 4z"],"filter-remove":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm2.91 13.5l1.79-1.79c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-1.79 1.79-1.79-1.79a1.003 1.003 0 00-1.42 1.42l1.79 1.79-1.79 1.79a1.003 1.003 0 001.42 1.42l1.79-1.79 1.79 1.79a1.003 1.003 0 001.42-1.42l-1.8-1.79z"],flag:["M3 3c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1zm0-3c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm2 4.08v8.28c3.01-2.41 8.67 2.64 13 0V4.08C13.61 7.14 8.01 1 5 4.08z"],flame:["M11.622 0c0 1.71.49 3.077 1.472 4.103C16.364 6.496 18 9.23 18 12.308c0 3.418-1.962 5.983-5.887 7.692 2.887-3 2.453-4.23-.49-8C8.5 13.5 9 14.5 9.5 16.5c-1.048 0-2 0-2.5-.5 0 .684 1.197 2.5 1.952 4-3.924-1.026-8.123-7.18-6.651-7.692.981-.342 2.126-.171 3.434.513C4.1 6.667 6.062 2.393 11.622 0z"],flash:["M4.96 6.37a1.003 1.003 0 001.42-1.42l-2-2a1.07 1.07 0 00-.71-.28 1.003 1.003 0 00-.71 1.71l2 1.99zm9.37.3c.28 0 .53-.11.71-.29l2-2a1.003 1.003 0 00-1.42-1.42l-2 2a1.003 1.003 0 00.71 1.71zM10 5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S9 .45 9 1v3c0 .55.45 1 1 1zm-5 5c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1zm14-1h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm-9-3c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm5.04 1.63a1.003 1.003 0 00-1.42 1.42l2 2a1.003 1.003 0 001.42-1.42l-2-2zM10 15c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1s1-.45 1-1v-3c0-.55-.45-1-1-1zm-4.33-1.67c-.28 0-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l2-2a1.003 1.003 0 00-.71-1.71z"],"floppy-disk":["M14 1h-3v5h3V1zm5.71 2.29l-3-3A.997.997 0 0016 0h-1v7H5V0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V4c0-.28-.11-.53-.29-.71zM17 19H3v-8c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v8z"],"flow-branch":["M14.425 7.953a3.98 3.98 0 01.562 2.045 3.98 3.98 0 01-.583 2.08L18 15.671V12.98c0-.248.097-.496.29-.689.379-.379 1.047-.38 1.426 0a.94.94 0 01.283.696l-.001 5.049a.957.957 0 01-.276.69.955.955 0 01-.69.273h-5.059a.971.971 0 01-.689-.289 1.026 1.026 0 010-1.417.972.972 0 01.69-.29h2.702l-3.634-3.573a3.998 3.998 0 01-5.924-2.431H1a1 1 0 010-2h6.12a3.998 3.998 0 015.96-2.409L16.665 3l-2.694-.001a.972.972 0 01-.689-.29 1.035 1.035 0 010-1.425.94.94 0 01.696-.283l5.05.001c.248 0 .497.083.69.276a.954.954 0 01.272.69l.001 5.052a.971.971 0 01-.29.689 1.028 1.028 0 01-1.419 0 .972.972 0 01-.29-.69V4.323l-3.567 3.63z"],"flow-end":["M12 9.919a3.998 3.998 0 014-3.92c2.21 0 4 1.79 4 3.997a3.998 3.998 0 01-4 3.996 3.998 3.998 0 01-4-3.916.967.967 0 01-.28.612L7.685 14.71a.958.958 0 01-.686.285c-.536 0-.994-.461-.994-.997 0-.273.107-.528.283-.704l2.379-2.302H.98c-.537 0-.976-.46-.976-.996s.44-.992.976-.992h7.676L6.287 6.687a.957.957 0 01-.283-.686c0-.536.458-.996.994-.996.274 0 .51.1.686.285l4.027 4.024c.159.158.27.365.29.605z"],"flow-linear":["M5.125 10.997H.976C.439 10.997 0 10.537 0 10c0-.536.44-.993.976-.993h4.148a4.002 4.002 0 017.752 0h3.776L14.293 6.69a.962.962 0 01-.285-.687c0-.537.46-1.001.996-1.001a.96.96 0 01.698.3l4.005 4.015c.176.176.293.41.293.683a.972.972 0 01-.283.693L15.702 14.7a.997.997 0 01-.698.297c-.537 0-.996-.453-.996-.99 0-.273.107-.517.283-.692l2.371-2.318h-3.787a4.002 4.002 0 01-7.75 0z"],"flow-review":["M6.13 9.004A4.005 4.005 0 0110.012 6c1.87 0 3.44 1.278 3.881 3.005h2.768l-2.354-2.317a.97.97 0 01-.283-.691c0-.536.462-.995 1-.995.273 0 .517.107.693.283l4 4.041a.97.97 0 01.284.692.956.956 0 01-.293.682l-3.991 3.997a.944.944 0 01-.694.292c-.537 0-1-.46-1-.997a.97.97 0 01.284-.692l2.345-2.29h-2.765a4.005 4.005 0 01-3.875 2.981 4.005 4.005 0 01-3.874-2.981H3.349l2.376 2.308a.97.97 0 01.283.691 1 1 0 01-.994.983.989.989 0 01-.713-.291L.293 10.699A.956.956 0 010 10.017a.97.97 0 01.283-.692l4.03-4.037a.996.996 0 01.701-.283c.537 0 .994.464.994 1a.97.97 0 01-.283.691L3.34 9.004h2.79z"],"flow-review-branch":["M13.04 13.424c-.6.36-1.302.568-2.052.568a4 4 0 01-3.868-2.999H3.342l2.372 2.31c.176.176.283.42.283.694 0 .537-.452.998-.988.998a.935.935 0 01-.691-.289L.292 10.683A.96.96 0 010 9.999c0-.274.107-.518.283-.694l4.035-4.04a.973.973 0 01.691-.288c.536 0 .988.47.988 1.007a.975.975 0 01-.283.694L3.332 8.984h3.786a4 4 0 013.87-3.006c.771 0 1.492.22 2.102.599l3.565-3.57-2.538-.003a.974.974 0 01-.69-.29c-.38-.38-.38-1.052-.002-1.431A.94.94 0 0114.122 1l4.896.005a.96.96 0 01.69.277c.193.193.27.442.27.69l.005 4.9a.971.971 0 01-.289.69 1.023 1.023 0 01-1.416 0 .975.975 0 01-.29-.691l-.003-2.54-3.554 3.62c.351.596.553 1.291.553 2.034 0 .763-.213 1.477-.583 2.084l3.595 3.595.003-2.54c0-.249.097-.497.29-.69.38-.38 1.05-.381 1.429-.002a.94.94 0 01.282.697l-.005 4.9a.927.927 0 01-.277.675.974.974 0 01-.69.291L13.974 19a.97.97 0 01-.69-.29 1.03 1.03 0 01.002-1.42.974.974 0 01.69-.29l2.696-.003-3.632-3.573z"],flows:["M17.5 7.93a2.5 2.5 0 00-2.45 2h-2.3l-4.01-4-.75.75 3.26 3.25h-6.3a2.5 2.5 0 100 1h6.3l-3.26 3.25.75.75 4.01-4h2.3a2.5 2.5 0 102.45-3z"],"folder-close":["M0 17c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7H0v10zM19 4H9.41l-1.7-1.71A.997.997 0 007 2H1c-.55 0-1 .45-1 1v3h20V5c0-.55-.45-1-1-1z"],"folder-new":["M12.994 7c0 1.655 1.344 3 2.998 3a3.002 3.002 0 002.999-3H20v10c0 .55-.45 1-1 1H1.01c-.55 0-1-.45-1-1V7h12.984zM10.76 6H0V3c0-.55.45-1 1-1h3.998c.28 0 .53.11.71.29L7.415 4h2.579c0 .768.29 1.469.765 2zm8.23-3c.55 0 1 .45 1 1s-.45 1-1 1h-1.998v2c0 .55-.45 1-1 1s-1-.45-1-1V5h-1.998c-.55 0-1-.45-1-1s.45-1 1-1h1.999V1c0-.55.45-1 .999-1 .55 0 1 .45 1 1v2h1.999z"],"folder-open":["M20 9c0-.55-.45-1-1-1H5c-.43 0-.79.27-.93.65h-.01l-3 8h.01c-.04.11-.07.23-.07.35 0 .55.45 1 1 1h14c.43 0 .79-.27.93-.65h.01l3-8h-.01c.04-.11.07-.23.07-.35zM3.07 7.63C3.22 7.26 3.58 7 4 7h14V5c0-.55-.45-1-1-1H8.41l-1.7-1.71A.997.997 0 006 2H1c-.55 0-1 .45-1 1v12.31l3.07-7.68z"],"folder-shared":["M11 4H9.41l-1.7-1.71A.997.997 0 007 2H1c-.55 0-1 .45-1 1v3h11.78C11.3 5.47 11 4.77 11 4zm8-1h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L12.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 6.41V9c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1zm-2.46 7.7l-1.42 1.42a2.996 2.996 0 11-4.24-4.24l.88-.88H0v10c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-5.18c-.31.11-.65.18-1 .18-1.02 0-1.92-.52-2.46-1.3z"],"folder-shared-open":["M3.07 7.63C3.22 7.26 3.58 7 4 7h7.76l.54-.54A2.97 2.97 0 0111 4H8.41l-1.7-1.71A.997.997 0 006 2H1c-.55 0-1 .45-1 1v12.31l3.07-7.68zm13.47 3.07l-1.42 1.42A2.996 2.996 0 0110 10c0-.77.3-1.47.78-2H5c-.43 0-.79.27-.93.65h-.01l-3 8h.01c-.04.11-.07.23-.07.35 0 .55.45 1 1 1h14c.43 0 .79-.27.93-.65h.01l2.01-5.36c-1-.01-1.88-.52-2.41-1.29zM19 3h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L12.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 6.41V9c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],follower:["M11.54 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.69 3.69 0 00-1.29-1.86C9.69 4.25 8.8 4 8.01 4c-.8 0-1.69.25-2.32.73-.61.47-1.06 1.13-1.28 1.86-.05.17-.09.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.44.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59-1.48.65-3.71 1.35-4.16 2.4C-.16 19.38.02 20 .02 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.68-1.75-4.16-2.41zm8.15-12.63l-3-3a.956.956 0 00-.7-.29 1.003 1.003 0 00-.71 1.71L16.58 3H13c-.55 0-1 .45-1 1s.45 1 1 1h3.58l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.3-.71z"],following:["M11.55 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.69 3.69 0 00-1.29-1.86C9.7 4.25 8.81 4 8.02 4c-.79 0-1.68.25-2.31.73-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.44.32-.48.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59C3 16.56.77 17.26.32 18.31-.15 19.38.04 20 .04 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.69-1.75-4.17-2.41zM19 3h-3.58l1.29-1.29A1.003 1.003 0 0015.29.29l-3 3c-.17.18-.28.43-.28.71 0 .28.11.53.29.71l3 3c.18.18.43.29.7.29a1.003 1.003 0 00.71-1.71L15.42 5H19c.55 0 1-.45 1-1s-.45-1-1-1z"],font:["M17.93 18.64l-7-18C10.78.27 10.42 0 10 0s-.78.27-.93.64l-7 18c-.04.11-.07.23-.07.36 0 .55.45 1 1 1 .42 0 .78-.27.93-.64L6.41 13h7.19l2.47 6.36c.15.37.51.64.93.64.55 0 1-.45 1-1 0-.13-.03-.25-.07-.36zM7.18 11L10 3.76 12.82 11H7.18z"],fork:["M16.71 11.29a1.003 1.003 0 00-1.42 1.42l1.3 1.29h-2.17l-8-8h10.17L15.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 4H1c-.55 0-1 .45-1 1s.45 1 1 1h2.59l9.71 9.71c.17.18.42.29.7.29h2.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3z"],form:["M2 13v4h4v-4H2zm-1-2h6c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6c0-.55.45-1 1-1zm11-7h7c.55 0 1 .45 1 1s-.45 1-1 1h-7c-.55 0-1-.45-1-1s.45-1 1-1zM8 1a1.003 1.003 0 01.71 1.71l-5 6C3.53 8.89 3.28 9 3 9s-.53-.11-.71-.29l-2-2a1.003 1.003 0 011.42-1.42L3 6.59l4.29-5.3C7.47 1.11 7.72 1 8 1zm4 13h7c.55 0 1 .45 1 1s-.45 1-1 1h-7c-.55 0-1-.45-1-1s.45-1 1-1z"],"full-circle":["M9.96 0a10 10 0 100 20 10 10 0 100-20z"],"full-stacked-chart":["M15 16h2c.55 0 1-.45 1-1v-5h-4v5c0 .55.45 1 1 1zM12 2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v4h4V2zm6 4h-4v3h4V6zm0-4c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h4V2zm-6 5H8v5h4V7zm-9 9h2c.55 0 1-.45 1-1v-3H2v3c0 .55.45 1 1 1zm6 0h2c.55 0 1-.45 1-1v-2H8v2c0 .55.45 1 1 1zm10 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM6 2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v3h4V2zm0 4H2v5h4V6z"],fullscreen:["M3.41 2H6c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1s1-.45 1-1V3.41L7.29 8.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L3.41 2zM8 11c-.28 0-.53.11-.71.29L2 16.59V14c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1H3.41l5.29-5.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1zM19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm0 13c-.55 0-1 .45-1 1v2.59l-5.29-5.29A.965.965 0 0012 11a1.003 1.003 0 00-.71 1.71l5.3 5.29H14c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1z"],function:["M10.14 5.82H8.73c.4-1.66.94-2.87 1.6-3.64.4-.48.8-.72 1.18-.72.08 0 .14.02.19.07.05.05.07.1.07.18 0 .07-.05.19-.16.37s-.16.36-.16.52c0 .23.08.43.25.59a.9.9 0 00.64.25c.28 0 .51-.1.7-.3.19-.2.28-.47.28-.81 0-.39-.14-.7-.42-.94-.28-.24-.74-.36-1.36-.36-.97 0-1.86.29-2.65.87-.79.56-1.54 1.52-2.26 2.85-.24.46-.48.75-.7.88-.22.13-.57.19-1.06.19l-.32 1.15H5.9l-1.99 7.85c-.33 1.29-.56 2.09-.67 2.39-.17.44-.43.81-.77 1.12a.74.74 0 01-.5.19c-.05 0-.1-.02-.14-.05l-.04-.07c0-.03.05-.1.15-.2.1-.1.15-.26.15-.47 0-.23-.08-.42-.23-.57-.16-.15-.38-.23-.67-.23-.35 0-.63.1-.85.29-.21.2-.32.43-.32.7 0 .29.13.54.39.75.25.22.65.33 1.2.33.88 0 1.66-.23 2.33-.69.68-.46 1.27-1.17 1.78-2.14.51-.96 1.03-2.52 1.56-4.66l1.14-4.54H9.8l.34-1.15zm6.8 1.95c.25-.2.51-.29.78-.29.1 0 .29.04.56.11.27.08.51.11.72.11.29 0 .52-.1.72-.3.18-.19.28-.45.28-.77 0-.33-.1-.6-.29-.8-.19-.2-.47-.29-.82-.29-.32 0-.62.08-.9.23-.28.15-.64.49-1.08 1-.33.38-.81 1.05-1.44 2a9.712 9.712 0 00-1.31-3.22l-3.4.59-.07.37c.25-.05.47-.08.64-.08.34 0 .62.15.84.44.35.46.84 1.85 1.46 4.19-.49.66-.82 1.09-1 1.3-.3.33-.55.54-.74.64-.15.08-.32.12-.51.12-.14 0-.38-.08-.7-.24-.22-.1-.42-.16-.59-.16-.33 0-.6.11-.82.32-.21.22-.32.49-.32.83 0 .31.1.57.3.77.2.2.47.29.8.29.32 0 .63-.07.92-.21.29-.14.64-.43 1.08-.88.43-.45 1.03-1.16 1.79-2.14.29.93.55 1.61.76 2.03.21.42.46.73.74.91.28.19.62.28 1.04.28.4 0 .81-.15 1.23-.44.55-.38 1.1-1.04 1.68-1.97l-.35-.21c-.39.55-.68.89-.87 1.03-.12.09-.27.13-.44.13-.2 0-.4-.13-.59-.38-.33-.43-.77-1.63-1.33-3.6.47-.86.89-1.44 1.23-1.71z"],"gantt-chart":["M4 7h5c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm3 2v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1zm12 3h-6c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0 4H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],geofence:["M8 11l.075.003.126.017.111.03.111.044.098.052.096.067.09.08c.036.035.068.073.097.112l.071.11.054.114.035.105.03.148L9 12V18a1 1 0 01-1.993.117L7 18v-3.586l-5.293 5.293a1 1 0 01-1.497-1.32l.083-.094L5.584 13h-3.58a1 1 0 01-.117-1.993L2.004 11H8zm3.018-11a1.003 1.003 0 01.39.087l.12.063.031.02.1.078 8.027 7.026.062.064.068.086.044.068.064.128.04.117.024.113.011.108v.1l-.007.073-.019.103-.037.121-.039.09-.05.087-4.996 7.994c-.06.097-.137.183-.226.254l-.093.067-.095.053-.087.037-.125.037a1.018 1.018 0 01-.218.026H11v-5a3 3 0 00-2.824-2.995L8 9H3V6a1 1 0 01.321-.734l.098-.08 7-5a1.01 1.01 0 01.45-.178L11.018 0z"],geolocation:["M0 8.33l9.17 2.5 2.5 9.17L20 0z"],geosearch:["M8 18.88c-3.79 0-6.88-3.09-6.88-6.88 0-.61.08-1.22.23-1.79.03.01.06-.01.1-.01h.09v.55c0 .23.21.42.44.42.04 0 .09-.01.12-.02l.9.88c.09.09.23.09.32 0s.09-.23 0-.32l-.86-.9c0-.02.05-.04.05-.07v-.13c0-.18.1-.25.29-.41h.53c.1 0 .19-.01.27-.05.01-.01.02 0 .03-.01.02-.01.03-.02.05-.04.01-.01.02-.01.02-.02l.02-.02 1.13-1.13c-.16-.32-.3-.65-.42-.99h-.64v-.53c0-.01.06.06.06-.1h.38c-.04-.16-.08-.32-.1-.48h-.71c.2-.16.42-.31.64-.45C4.02 6.09 4 5.8 4 5.5c0-.14.01-.28.02-.43C1.62 6.46 0 9.04 0 12c0 4.41 3.59 8 8 8 3.87 0 7.09-2.77 7.82-6.44l-.97-1.1c-.26 3.57-3.23 6.42-6.85 6.42zm-2.12-3.67v-.35h.15c.29 0 .49-.23.49-.53v-.68c0-.01.01-.01 0-.02L4.71 11.8h-.77c-.29 0-.47.24-.47.53v2c0 .29.18.53.47.53h.33v2.02c0 .28.28.51.56.51s.56-.23.56-.51v-1.22h-.01c.29 0 .5-.16.5-.45zm13.83-2.92l-3.68-3.68c.14-.21.27-.42.38-.65.02-.04.04-.07.05-.11.11-.22.2-.45.28-.69v-.01c.07-.24.13-.48.17-.73l.03-.17c.04-.24.06-.49.06-.75C17 2.46 14.54 0 11.5 0S6 2.46 6 5.5 8.46 11 11.5 11c.26 0 .51-.02.76-.06l.17-.03c.25-.04.49-.1.73-.17h.01c.24-.08.47-.17.69-.28.04-.02.07-.04.11-.05.23-.11.44-.24.65-.38l3.68 3.68c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71zM11.5 9.5c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm1.93 5.33v-.65c0-.11-.13-.21-.24-.21-.11 0-.24.09-.24.21v.65c0 .11.13.21.24.21.11 0 .24-.1.24-.21zm-2.41.67h.83c.29 0 .46-.21.46-.5v-1.86l.23-.22c-.34.05-.69.08-1.04.08-.36 0-.7-.03-1.05-.08.03.05.06.1.08.16V15c.01.29.2.5.49.5z"],"git-branch":["M15 2c-1.66 0-3 1.34-3 3 0 1.3.84 2.4 2 2.82V9c0 1.1-.9 2-2 2H8c-.73 0-1.41.21-2 .55V5.82C7.16 5.4 8 4.3 8 3c0-1.66-1.34-3-3-3S2 1.34 2 3c0 1.3.84 2.4 2 2.82v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.25-.77-2.3-1.85-2.75C6.45 13.52 7.16 13 8 13h4c2.21 0 4-1.79 4-4V7.82C17.16 7.4 18 6.3 18 5c0-1.66-1.34-3-3-3zM5 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 16c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM15 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-commit":["M19 9h-4.1a5 5 0 00-9.8 0H1c-.55 0-1 .45-1 1s.45 1 1 1h4.1a5 5 0 009.8 0H19c.55 0 1-.45 1-1s-.45-1-1-1zm-9 4c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"git-merge":["M15 8c-1.3 0-2.4.84-2.82 2H11c-2.49 0-4.54-1.83-4.92-4.21A2.995 2.995 0 005 0C3.34 0 2 1.34 2 3c0 1.3.84 2.4 2 2.81v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V9.86C7.27 11.17 9.03 12 11 12h1.18A2.996 2.996 0 0018 11c0-1.66-1.34-3-3-3zM5 18c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM5 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm10 8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-new-branch":["M17 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3 4.86V9c0 1.1-.9 2-2 2H8c-.73 0-1.41.21-2 .55V5.82C7.16 5.4 8 4.3 8 3c0-1.66-1.34-3-3-3S2 1.34 2 3c0 1.3.84 2.4 2 2.82v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.25-.77-2.3-1.85-2.75C6.45 13.52 7.16 13 8 13h4c2.21 0 4-1.79 4-4V7.86c-.32.08-.65.14-1 .14s-.68-.06-1-.14zM5 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 16c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-pull":["M17 14.18V7c0-2.21-1.79-4-4-4h-2.59l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C7.11 3.47 7 3.72 7 4c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L10.41 5H13c1.1 0 2 .9 2 2v7.18A2.996 2.996 0 0016 20c1.66 0 3-1.34 3-3 0-1.3-.84-2.4-2-2.82zM16 18c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 1C2.34 1 1 2.34 1 4c0 1.3.84 2.4 2 2.82v7.37C1.84 14.6 1 15.7 1 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V6.82C6.16 6.4 7 5.3 7 4c0-1.66-1.34-3-3-3zm0 17c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-push":["M15 11c0-.28-.11-.53-.29-.71l-3-3C11.53 7.11 11.28 7 11 7s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42l1.29-1.3V19c0 .55.45 1 1 1s1-.45 1-1v-8.59l1.29 1.29c.18.19.43.3.71.3.55 0 1-.45 1-1zm4-11H1C.45 0 0 .45 0 1v16c0 .55.45 1 1 1h7v-2H2v-2h6v-1H4V2h14v11h-4v1h4v2h-4v2h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 8h2V6H5v2zm2-5H5v2h2V3z"],"git-repo":["M7 3H5v2h2V3zm0 6H5v2h2V9zm0-3H5v2h2V6zm12-6H1C.45 0 0 .45 0 1v16c0 .55.45 1 1 1h4v2l2-1 2 1v-2h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 16H9v-1H5v1H2v-2h16v2zm0-3H4V2h14v11z"],glass:["M17 6V0H3v6c0 3.53 2.61 6.43 6 6.92V18H6c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1h-3v-5.08c3.39-.49 6-3.39 6-6.92z"],globe:["M7.53 4.37c.1-.1.1-.26 0-.35l-.68-.68c-.1-.1-.25-.1-.35 0-.1.1-.1.26 0 .35l.68.68c.1.1.25.1.35 0zm3.17.06h.3c.09 0 .16-.01.16-.1 0-.09-.07-.1-.16-.1h-.3c-.09 0-.16.01-.16.1s.07.1.16.1zm.98 1.15c.09 0 .19-.08.19-.17v-.42c0-.09-.1-.17-.19-.17s-.19.08-.19.17v.42c0 .09.1.17.19.17zm-6.5 4.19c-.35 0-.56.28-.56.63v2.37c0 .35.21.62.56.62h.39v2.4c0 .34.33.61.67.61s.67-.27.67-.61v-1.44h-.02c.35 0 .6-.19.6-.54v-.41h.18c.35 0 .58-.28.58-.62v-.81c0-.01.01-.01 0-.02L6.1 9.77h-.92zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8 0-.74.11-1.46.3-2.14h.03v.65c0 .28.25.5.53.5.05 0 .1-.01.15-.02l1.05 1.05c.1.11.28.11.38 0 .1-.1.11-.27 0-.38L3.42 8.59c0-.03.05-.05.05-.08v-.16c0-.22.12-.3.34-.49h.63c.12 0 .23-.01.32-.07.01-.01.02 0 .03-.01.02-.02.04-.03.06-.04.01-.01.02-.01.03-.02l.02-.02 2.15-2.15c.24-.24.24-.63 0-.86-.23-.24-.62-.19-.86.04l-.41.46H5v-.64c0-.01.07.07.07-.12h.87c.17 0 .3-.12.3-.29 0-.17-.13-.29-.3-.29H4.88C6.27 2.7 8.05 2 10 2s3.73.7 5.12 1.86h-1.58l-.01-.04c-.06 0-.12 0-.17.04l-.71.7c-.09.09-.09.23 0 .31.09.09.23.09.32 0l.56-.6.01-.03h.34c0 .19-.1.13-.1.16v.1c0 .29-.2.5-.49.5h-.51c-.25 0-.52.28-.52.54v.23h-.12c-.16 0-.27.08-.27.24v.33h-.32c-.23 0-.41.15-.41.38 0 .22.18.35.41.35.1 0 .19.04.26-.16l.06.01.66-.59h.23l.53.5c.04.04.11.03.16-.01.04-.04.04-.16 0-.2L13 6.15h.32l.12.16c.25.25.65.23.89-.02l.12-.14H15c.02 0 .11.07.11.07v.33s-.06-.01-.07-.01h-.49c-.16 0-.28.13-.28.29 0 .16.13.29.28.29h.49c.01 0 .07-.01.07-.01v.2c-.19.28-.33.57-.62.57h-1.28s0-.01-.01-.01l-.58-.58a.622.622 0 00-.89 0l-.58.58s0 .01-.01.01h-.34c-.35 0-.67.28-.67.63v1.25c0 .35.32.61.67.61h1.22c.46.19.78.48.97.94v2.28c0 .35.23.6.58.6h.98c.35 0 .54-.25.54-.6v-2.2l1.21-1.17.04-.02.02-.01h.04c.1-.11.2-.26.2-.42V8.49c0-.25-.22-.44-.42-.63h.58c.02.38.29.57.63.57h.43c.13.51.18 1.03.18 1.57 0 4.42-3.58 8-8 8zm6.16-5.65c-.14 0-.29.11-.29.25v.77c0 .14.15.25.29.25.14 0 .29-.11.29-.25v-.77c0-.14-.15-.25-.29-.25zM10.5 3.48c0-.34-.28-.57-.62-.57h-.74c-.34 0-.57.25-.57.59 0 .05-.13.06.06.1v.64c0 .2.09.36.29.36.2 0 .29-.16.29-.36v-.19h.68c.33 0 .61-.23.61-.57z"],"globe-network":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm7.39 7h-3.63c-.31-1.99-.92-3.66-1.72-4.73 2.45.65 4.41 2.42 5.35 4.73zM13 10c0 .69-.04 1.36-.11 2H7.11a18.419 18.419 0 010-4h5.77c.08.64.12 1.31.12 2zm-3-8c1.07 0 2.25 2.05 2.75 5h-5.5c.5-2.95 1.68-5 2.75-5zm-2.04.27C7.16 3.34 6.55 5.01 6.24 7H2.61c.94-2.31 2.9-4.08 5.35-4.73zM2 10c0-.69.11-1.36.28-2h3.83a18.419 18.419 0 000 4H2.28c-.17-.64-.28-1.31-.28-2zm.61 3h3.63c.31 1.99.92 3.66 1.72 4.73A7.996 7.996 0 012.61 13zM10 18c-1.07 0-2.25-2.05-2.75-5h5.5c-.5 2.95-1.68 5-2.75 5zm2.04-.27c.79-1.07 1.4-2.74 1.72-4.73h3.63a7.996 7.996 0 01-5.35 4.73zM13.89 12a18.419 18.419 0 000-4h3.83c.17.64.28 1.31.28 2s-.11 1.36-.28 2h-3.83z"],graph:["M17.5 4A2.5 2.5 0 0015 6.5c0 .06.01.12.02.18l-1.9.84C12.38 6.6 11.27 6 10 6c-.83 0-1.59.25-2.23.68L4.91 4.14c.05-.21.09-.42.09-.64a2.5 2.5 0 00-5 0A2.5 2.5 0 002.5 6c.42 0 .81-.11 1.16-.3l2.79 2.48C6.17 8.73 6 9.34 6 10c0 1.41.73 2.64 1.83 3.35l-.56 1.67A2.498 2.498 0 005 17.5a2.5 2.5 0 005 0c0-.74-.32-1.39-.83-1.85l.56-1.68c.09.01.18.03.27.03 2.21 0 4-1.79 4-4 0-.22-.03-.44-.07-.65l2.02-.9c.43.34.96.55 1.55.55a2.5 2.5 0 000-5z"],"graph-remove":["M17.41 4l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L16 2.59 13.71.3A.965.965 0 0013 0a1.003 1.003 0 00-.71 1.71L14.59 4 12.3 6.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L16 5.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L17.41 4zM19 10c-.83 0-1.55-.36-2.09-.91l-.03.03-.88-.88-.88.88a2.996 2.996 0 11-4.24-4.24l.88-.88-.88-.88.03-.03C10.36 2.55 10 1.83 10 1c0-.35.07-.68.18-.99-.06 0-.12-.01-.18-.01C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-.06-.01-.12-.01-.18-.31.11-.64.18-.99.18z"],"greater-than":["M12.838 10l-9.154 3.051a1 1 0 00.632 1.898l12-4c.912-.304.912-1.594 0-1.898l-12-4a1 1 0 00-.632 1.898L12.838 10z"],"greater-than-or-equal-to":["M3.684 11.051a1 1 0 00.632 1.898l12-4c.912-.304.912-1.594 0-1.898l-12-4a1 1 0 00-.632 1.898L12.838 8l-9.154 3.051zM4 15h12a1 1 0 110 2H4a1 1 0 010-2z"],grid:["M19 11c.55 0 1-.45 1-1s-.45-1-1-1h-2V5h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-4V1c0-.55-.45-1-1-1S9 .45 9 1v2H5V1c0-.55-.45-1-1-1S3 .45 3 1v2H1c-.55 0-1 .45-1 1s.45 1 1 1h2v4H1c-.55 0-1 .45-1 1s.45 1 1 1h2v4H1c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h4v2c0 .55.45 1 1 1s1-.45 1-1v-2h4v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2v-4h2zM9 15H5v-4h4v4zm0-6H5V5h4v4zm6 6h-4v-4h4v4zm0-6h-4V5h4v4z"],"grid-view":["M0 19c0 .55.45 1 1 1h8v-9H0v8zM0 1v8h9V0H1C.45 0 0 .45 0 1zm19-1h-8v9h9V1c0-.55-.45-1-1-1zm-8 20h8c.55 0 1-.45 1-1v-8h-9v9z"],"group-objects":["M6 7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm8-3H6c-3.31 0-6 2.69-6 6s2.69 6 6 6h8c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 11H6c-2.76 0-5-2.24-5-5s2.24-5 5-5h8c2.76 0 5 2.24 5 5s-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"grouped-bar-chart":["M12 16h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1zm7 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-3-1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1zm-9 0h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1zm-4 0h1c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1z"],hand:["M17 5c-.42 0-.79.27-.93.64L14.38 10h-.77l1.34-6.67c.03-.1.05-.21.05-.33a.998.998 0 00-1.98-.19h-.01L11.57 10H11V1c0-.55-.45-1-1-1S9 .45 9 1v9h-.2L6.97 2.76a.997.997 0 00-1.73-.41l-.03.03c-.01.02-.02.03-.03.04-.01.02-.01.03-.02.04v.01c-.01.01-.02.02-.02.03v.01c-.02.01-.02.02-.03.03 0 0 0 .01-.01.01 0 .01 0 .02-.01.03 0 0 0 .01-.01.01 0 .01-.01.02-.01.03 0 0 0 .01-.01.01 0 .01-.01.02-.01.03 0 .01 0 .01-.01.02 0 .01-.01.02-.01.03 0 .01 0 .01-.01.02 0 .01-.01.02-.01.03v.02c0 .01 0 .02-.01.03V3c0 .05 0 .09.01.14l1.45 10.25L6 12.7v.01L3.84 9.45h-.01A.98.98 0 003 9c-.55 0-1 .45-1 1 0 .2.06.39.17.55L6 18.44C7.06 19.4 8.46 20 10 20c3.31 0 6-2.69 6-6v-1.84l.01-.03v-.06l1.94-5.75A1.003 1.003 0 0017 5z"],"hand-down":["M17.68 9.84C15.91 9 14.27 6.49 13.45 4.9 12.41 2.43 12.21 0 7.87 0 5.49 0 3.95.76 3.05 2.65 2.31 4.2 2 5.48 2 9.79v.99c0 .82.69 1.48 1.54 1.48.38 0 .73-.14 1-.36.19.6.78 1.05 1.47 1.05.47 0 .89-.2 1.17-.52.26.47.77.79 1.36.79.65 0 1.2-.39 1.43-.93l.03.77v5.44c0 .48.23.91.59 1.18.21.19.5.32.85.32h.06c.83 0 1.5-.67 1.5-1.5v-8.24l.01-.67c.85.98 1.92 1.76 3.24 1.89 1.79.19 2.09-1.33 1.43-1.64z"],"hand-left":["M15.1 6.54c-1.58-.81-4.09-2.46-4.94-4.23-.31-.65-1.82-.35-1.64 1.43.13 1.33.91 2.4 1.89 3.24L9.74 7H1.5C.67 7 0 7.67 0 8.5v.06c0 .36.13.64.32.85.27.36.7.59 1.18.59h5.44l.78.01c-.54.23-.93.78-.93 1.43 0 .59.32 1.1.79 1.36-.32.28-.52.7-.52 1.17 0 .69.44 1.28 1.05 1.47-.22.27-.36.62-.36 1 0 .85.66 1.54 1.48 1.54h.99c4.31 0 5.59-.31 7.14-1.05 1.89-.9 2.65-2.44 2.65-4.82-.01-4.32-2.44-4.52-4.91-5.57z"],"hand-right":["M20 8.5c0-.83-.67-1.5-1.5-1.5h-8.24l-.67-.01c.98-.85 1.76-1.92 1.89-3.24.18-1.79-1.33-2.08-1.65-1.43-.84 1.76-3.35 3.41-4.93 4.23C2.43 7.59 0 7.79 0 12.13c0 2.38.76 3.92 2.65 4.82C4.2 17.69 5.48 18 9.79 18h.99c.82 0 1.48-.69 1.48-1.54 0-.38-.14-.73-.36-1 .6-.19 1.05-.78 1.05-1.47 0-.47-.2-.89-.52-1.17.47-.26.79-.77.79-1.36 0-.65-.39-1.2-.93-1.43l.77-.03h5.44c.48 0 .91-.23 1.18-.59.19-.21.32-.49.32-.85v-.03-.03z"],"hand-up":["M16.46 7.74c-.38 0-.73.14-1 .36-.19-.6-.78-1.05-1.47-1.05-.47 0-.89.2-1.17.52-.26-.47-.77-.79-1.36-.79-.65 0-1.2.39-1.43.93L10 6.94V1.5c0-.48-.23-.91-.59-1.18C9.2.13 8.92 0 8.56 0H8.5C7.67 0 7 .67 7 1.5v8.24l-.01.67c-.84-.98-1.92-1.76-3.24-1.89-1.79-.18-2.08 1.33-1.43 1.65 1.77.84 3.41 3.35 4.23 4.94 1.05 2.47 1.25 4.9 5.58 4.9 2.38 0 3.92-.76 4.82-2.65.74-1.56 1.05-2.84 1.05-7.15v-.99c0-.81-.69-1.48-1.54-1.48z"],hat:["M18.5 13c1.118 0 1.466.534 1.498 1.366L20 14.5v.5c0 1.945-5.69 3-10 3S0 16.945 0 15v-.5c0-.908.323-1.5 1.5-1.5.895 0 3.5 1.2 8.5 1.2l.411-.003C15.143 14.134 17.631 13 18.5 13zm-5-10c1.725 0 2.954 2.729 3.688 8.186-1.455.263-3.805.72-6.392.801l-.434.01L10 12c-2.896 0-5.585-.524-7.189-.814C3.546 5.73 4.775 3 6.5 3 8.6 3 8.329 5.5 10 5.5S11.5 3 13.5 3z"],header:["M16 1c-.55 0-1 .45-1 1v7H5V2c0-.55-.45-1-1-1s-1 .45-1 1v16c0 .55.45 1 1 1s1-.45 1-1v-7h10v7c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"header-one":["M10 0c.55 0 1 .45 1 1v14c0 .55-.45 1-1 1s-1-.45-1-1V9H2v6c0 .55-.45 1-1 1s-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v6h7V1c0-.55.45-1 1-1zm7.4 10.77c.17-.2.29-.46.34-.77H19v10h-1.5v-7.11H15v-1.24c.32 0 .63-.03.93-.08.31-.06.58-.16.83-.29.26-.12.47-.3.64-.51z"],"header-three":["M10.989 1c0-.55-.45-1-.999-1-.55 0-.999.45-.999 1v6H1.998V1c0-.55-.45-1-.999-1C.449 0 0 .45 0 1v14c0 .55.45 1 .999 1 .55 0 .999-.45.999-1V9h6.993v6c0 .55.45 1 .999 1 .55 0 .999-.45.999-1V1zm7.461 13.645c.49.11.87.38 1.14.82.27.44.41.97.41 1.61a3 3 0 01-.24 1.23c-.16.36-.38.67-.66.92-.27.25-.59.44-.96.58-.37.14-.75.21-1.16.21-.5 0-.93-.08-1.3-.24a2.55 2.55 0 01-.93-.68c-.25-.29-.44-.65-.57-1.06-.13-.42-.2-.88-.21-1.38h1.39c-.02.58.11 1.07.38 1.46.28.39.68.58 1.23.58.47 0 .86-.15 1.17-.45.31-.3.47-.72.47-1.27 0-.37-.07-.67-.2-.89-.13-.22-.3-.39-.51-.5-.21-.11-.45-.18-.71-.21-.26-.03-.53-.04-.81-.03v-1.17c.22.01.45 0 .68-.05.23-.05.43-.13.61-.24.18-.11.32-.27.43-.47.11-.2.16-.45.16-.74 0-.41-.12-.74-.37-.99s-.57-.37-.96-.37c-.24 0-.45.06-.63.17-.18.11-.33.26-.45.45s-.2.4-.26.63c-.05.23-.08.47-.07.72h-1.39c.01-.47.09-.9.23-1.3s.33-.75.57-1.04c.24-.3.53-.53.87-.69.34-.17.73-.25 1.16-.25.33 0 .66.05.98.16.32.11.61.27.87.48.26.21.47.47.62.8.15.32.23.7.23 1.12 0 .48-.09.91-.29 1.27-.2.36-.5.63-.92.79v.02z"],"header-two":["M16.6 17.41c-.22.17-.4.36-.56.55-.16.19-.27.4-.33.61h4.28V20H14c.01-.81.18-1.52.53-2.13.35-.6.81-1.13 1.41-1.58.28-.23.58-.46.89-.68.31-.22.59-.46.85-.71.26-.26.48-.53.63-.83.16-.3.25-.64.26-1.02 0-.18-.02-.37-.06-.57-.04-.2-.11-.39-.22-.56s-.26-.31-.45-.43-.44-.18-.75-.18c-.28 0-.52.06-.71.19s-.34.3-.45.52c-.11.22-.2.48-.25.78-.05.3-.08.62-.09.97h-1.43c0-.54.07-1.04.2-1.5.13-.47.32-.87.58-1.2.26-.34.58-.6.95-.78.37-.19.81-.29 1.3-.29.54 0 .99.09 1.35.29.36.19.65.44.87.74.22.29.38.62.47.97.09.35.14.68.14 1 0 .4-.05.75-.16 1.07-.11.32-.26.61-.44.88-.19.27-.4.52-.63.74-.24.22-.48.43-.73.63s-.5.38-.75.56c-.26.17-.5.35-.71.53zM10 0c.55 0 1 .45 1 1v14c0 .55-.45 1-1 1s-1-.45-1-1V9H2v6c0 .55-.45 1-1 1s-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v6h7V1c0-.55.45-1 1-1z"],headset:["M18.97 9H19A9 9 0 001 9h.03C.41 9.73 0 10.8 0 12c0 1.74.84 3.2 2 3.76V16c0 1.66 1.34 3 3 3h3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1H5c-.55 0-1-.45-1-1 .55 0 1-.45 1-1V9c0-.55-.45-1-1-1h-.92C3.57 4.61 6.47 2 10 2s6.43 2.61 6.92 6H16c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h1c1.66 0 3-1.79 3-4 0-1.2-.41-2.27-1.03-3z"],heart:["M20 6.25C20 3.35 17.65 1 14.75 1c-1.02 0-1.95.31-2.75.82v-.04c-.09.06-.17.12-.26.19-.04.03-.09.06-.14.1-.68.51-1.24 1.18-1.6 1.96-.4-.86-1.04-1.57-1.8-2.1-.04-.02-.07-.05-.1-.08a7 7 0 00-.6-.33c-.13-.04-.23-.1-.35-.15-.05-.02-.1-.05-.15-.07v.02C6.45 1.13 5.87 1 5.25 1A5.25 5.25 0 000 6.25c0 .09.01.17.01.25H0c0 .06.01.12.02.18s.01.12.02.18C.13 7.89.44 9 1.07 10.17 2.23 12.33 4.1 14.11 7 16.53v.01c.9.75 1.89 1.55 3 2.46.71-.58 1.38-1.12 2-1.63 3.48-2.86 5.64-4.78 6.93-7.18.63-1.17.94-2.27 1.03-3.3.01-.07.01-.14.02-.21 0-.06.01-.11.02-.17h-.01c0-.09.01-.17.01-.26z"],"heart-broken":["M8.11 7.45C8.05 7.31 8 7.16 8 7c0-.07.03-.13.04-.19h-.02l.86-4.32A5.159 5.159 0 005.25 1 5.25 5.25 0 000 6.25c0 .09.01.17.01.25H0c0 .06.01.12.02.18s.01.12.02.18C.13 7.89.44 9 1.07 10.17c1.38 2.58 3.76 4.6 7.71 7.83l-.76-3.8h.02c-.01-.07-.04-.13-.04-.2 0-.21.08-.39.18-.54l-.02-.01 1.68-2.52-1.73-3.48zM20 6.25C20 3.35 17.65 1 14.75 1c-1.54 0-2.92.67-3.88 1.73l-.83 4.13 1.85 3.69h-.01c.07.14.12.29.12.45 0 .21-.08.39-.18.54l.02.01-1.77 2.66.81 4.07c4.16-3.39 6.63-5.45 8.05-8.1.63-1.17.94-2.27 1.03-3.3.01-.07.01-.14.02-.21 0-.06.01-.11.02-.17h-.01c0-.08.01-.16.01-.25z"],"heat-grid":["M14 12h6V8h-6v4zM0 12h6V8H0v4zm1-3h4v2H1V9zm-1 7c0 .55.45 1 1 1h5v-4H0v3zM19 3h-5v4h6V4c0-.55-.45-1-1-1zm0 3h-4V4h4v2zM0 4v3h6V3H1c-.55 0-1 .45-1 1zm7 3h6V3H7v4zm7 10h5c.55 0 1-.45 1-1v-3h-6v4zm-7 0h6v-4H7v4zm1-3h4v2H8v-2zm-1-2h6V8H7v4z"],heatmap:["M6 0a6 6 0 100 12A6 6 0 106 0z","M10.5 8a4.5 4.5 0 100 9 4.5 4.5 0 100-9z","M16.5 7a3.5 3.5 0 100 7 3.5 3.5 0 100-7zM18 16a2 2 0 100 4 2 2 0 100-4zM2.5 14a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM16.5 0a2.5 2.5 0 100 5 2.5 2.5 0 100-5z"],helicopter:["M10 3v2H1V3.5a.5.5 0 00-1 0v5a.5.5 0 001 0V7l5 2c0 1.54.824 3.575 3 4.835V16H5.5a.5.5 0 100 1H16.5a.5.5 0 00.224-.053l2-1a.5.5 0 10-.448-.894L16.382 16H15v-1.1A5.002 5.002 0 0014 5h-1V3h6.5a.5.5 0 000-1h-16a.5.5 0 000 1H10zm4 13v-1c-1.608 0-2.928-.258-4-.683V16h4zm0-6V6a4 4 0 014 4h-4z"],help:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM7.41 4.62c.65-.54 1.51-.82 2.56-.82.54 0 1.03.08 1.48.25.44.17.83.39 1.14.68.32.29.56.63.74 1.02.17.39.26.82.26 1.27s-.08.87-.24 1.23c-.16.37-.4.73-.71 1.11l-1.21 1.58c-.14.17-.28.33-.32.48-.05.15-.11.35-.11.6v.97H9v-2s.06-.58.24-.81l1.21-1.64c.25-.3.41-.56.51-.77s.14-.44.14-.67c0-.35-.11-.63-.32-.85s-.5-.33-.88-.33c-.37 0-.67.11-.89.33-.22.23-.37.54-.46.94-.03.12-.11.17-.23.16l-1.95-.29c-.12-.01-.16-.08-.14-.22.13-.93.52-1.67 1.18-2.22zM9 14h2.02L11 16H9v-2z"],"helper-management":["M17 10h-3v3h3v-3zm0 4h-3v3h3v-3zm0-8h-3v3h3V6zm2-6H1C.4 0 0 .4 0 1v18c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V1c0-.6-.5-1-1-1zm-1 18H2V2h16v16zm-9-4H6v3h3v-3zm4 0h-3v3h3v-3z"],"high-priority":["M12 16v4H8v-4h4zm1-16l-1 14H8L7 0h6z"],highlight:["M11.22 14.09l3.03-3.03.71.71L20 6.73l-5.71-5.71-5.04 5.04.71.71-3.02 3.04 4.28 4.28zm6.8 3.91h-16c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1zm-15-1h4.04c.28 0 .53-.11.71-.3l2.02-2.02-3.44-3.45-4.04 4.04c-.18.18-.3.44-.3.71.01.57.46 1.02 1.01 1.02z"],history:["M10 0C6.71 0 3.82 1.6 2 4.05V2c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.76C5.23 3.17 7.47 2 10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8c0-.55-.45-1-1-1s-1 .45-1 1c0 5.52 4.48 10 10 10s10-4.48 10-10S15.52 0 10 0zm0 3c-.55 0-1 .45-1 1v6c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L11 9.59V4c0-.55-.45-1-1-1z"],home:["M2 12v7c0 .55.45 1 1 1h5v-7h4v7h5c.55 0 1-.45 1-1v-7l-8-8-8 8zm17.71-2.71L17 6.59V3c0-.55-.45-1-1-1s-1 .45-1 1v1.59L10.71.3C10.53.11 10.28 0 10 0s-.53.11-.71.29l-9 9a1.003 1.003 0 001.42 1.42L10 2.41l8.29 8.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"horizontal-bar-chart":["M1 1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1zm3 5h11c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1zm8 8H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm7-6H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h15c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1z"],"horizontal-bar-chart-asc":["M1 9h11c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0-5h9c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm18 12H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM1 14h14c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1z"],"horizontal-bar-chart-desc":["M10 16H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm2-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h11c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm3-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm4-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1z"],"horizontal-distribution":["M12 2H8c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM1 0C.45 0 0 .45 0 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm18 0c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],hurricane:["M0 14c1.648.775 3 1 4 1-1-1-2-3.112-2-5a5.098 5.098 0 000-.045C2 5.17 6.201 1 11.172 1c3.206 0 6.9.667 8.828 5-1.648-.775-3-1-4-1 1 1 2 3.112 2 5v.045C18 14.83 13.799 19 8.828 19c-3.206 0-6.9-.667-8.828-5zm10-7a3 3 0 100 6 3 3 0 000-6z"],"id-number":["M2 5v10h16V5H2zm0-2h16c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2z","M8.88 12.38c-.17-.39-1.01-.66-1.56-.9-.56-.24-.48-.39-.5-.6v-.09c.19-.17.35-.4.45-.67 0 0 0-.02.01-.02l.06-.18c.13-.03.2-.17.23-.29.03-.05.09-.18.08-.33-.04-.18-.11-.27-.2-.3v-.03c0-.24-.02-.58-.06-.81-.01-.06-.02-.12-.04-.19-.08-.27-.25-.52-.48-.7C6.63 7.09 6.3 7 6 7s-.63.09-.87.27c-.23.17-.4.42-.48.7-.02.06-.03.13-.04.19-.04.22-.06.57-.06.81V9c-.09.03-.17.12-.19.31-.01.14.05.27.08.32.03.14.1.27.23.3.02.06.03.12.06.18v.01c.11.27.27.51.47.68v.08c-.02.2.04.35-.51.6-.56.24-1.39.51-1.56.9-.19.39-.12.62-.12.62h5.98c-.01 0 .06-.23-.11-.62zM12 7h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1zM12 11h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1z"],"image-rotate-left":["M10.5 13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM14 7H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 10l-5-3-1 2-2-4-3 4.5V9h11v8zm3-15h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H16c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4z"],"image-rotate-right":["M5.29 4.29a1.003 1.003 0 001.42 1.42l2-2C8.89 3.53 9 3.28 9 3c0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H4C1.79 2 0 3.79 0 6v3c0 .55.45 1 1 1s1-.45 1-1V6c0-1.1.9-2 2-2h1.59l-.3.29zM15.5 13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM19 7H6c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 10l-5-3-1 2-2-4-3 4.5V9h11v8z"],import:["M9.29 15.71c.18.18.43.29.71.29s.53-.11.71-.29l5-5a1.003 1.003 0 00-1.42-1.42L11 12.59V1c0-.55-.45-1-1-1S9 .45 9 1v11.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l5 5zM19 14c-.55 0-1 .45-1 1v3H2v-3c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],inbox:["M16.92 3.56l-.01-.02c-.16-.35-.5-.6-.91-.6H4c-.41 0-.76.25-.91.6l-.01.02L0 10.49v6.46c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-6.46l-3.08-6.93zM15 10.95c-.55 0-1 .45-1 1v1H6v-1c0-.55-.45-1-1-1H1.98l2.67-6h10.7l2.67 6H15z"],"inbox-filtered":["M10.262 3l1.958 1.958v.05H4.65l-2.67 5.997H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h3.02l-.635-1.426.625-.63c.354-.353.598-.8.707-1.289L20 10.545v6.456c0 .55-.45.999-1 .999H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h6.262zm9.088-3a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V4.13L11.19 1.1a.642.642 0 01.45-1.1h7.71z"],"inbox-geo":["M7.427 3a7.467 7.467 0 00-.411 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8V13c.165.01.332 0 .5 0a7.48 7.48 0 005.5-2.4V17c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h3.427zm5.715-.596a.133.133 0 01-.193 0l-.374-.374a.133.133 0 010-.193.133.133 0 01.193 0l.373.374a.133.133 0 010 .193zm1.743.033c-.05 0-.088-.006-.088-.055 0-.05.038-.056.088-.056h.165c.05 0 .088.006.088.055 0 .05-.038.056-.088.056h-.165zm.539.632c-.05 0-.104-.044-.104-.094v-.23c0-.05.054-.094.104-.094.05 0 .104.044.104.094v.23c0 .05-.055.094-.104.094zm-3.575 2.304h.506l1.182 1.2c.006.005 0 .005 0 .01v.446c0 .187-.126.341-.319.341h-.098v.226c0 .192-.138.296-.33.296h.01v.792c0 .188-.181.336-.368.336s-.369-.149-.369-.335v-1.32h-.214c-.193 0-.308-.149-.308-.341V5.72c0-.192.115-.346.308-.346zM14.5 0C17.536 0 20 2.464 20 5.5S17.536 11 14.5 11A5.502 5.502 0 019 5.5C9 2.464 11.464 0 14.5 0zm0 9.9c2.431 0 4.4-1.969 4.4-4.4 0-.297-.027-.583-.099-.864h-.236c-.188 0-.336-.104-.347-.313h-.319c.11.104.231.209.231.346v.705c0 .088-.055.17-.11.23h-.022l-.011.006-.022.011-.666.643v1.21c0 .193-.104.33-.296.33h-.54c-.192 0-.319-.137-.319-.33V6.221a.915.915 0 00-.533-.518h-.671c-.192 0-.368-.143-.368-.335V4.68c0-.192.176-.346.368-.346l.193-.005.319-.32a.342.342 0 01.489 0l.319.32c.005 0 .005.005.005.005h.704c.16 0 .237-.16.341-.313v-.11l-.038.005h-.27a.159.159 0 01-.153-.16c0-.087.066-.159.154-.159h.269l.039.006V3.42s-.05-.038-.061-.038h-.302l-.067.076a.342.342 0 01-.489.011l-.066-.088h-.176l.248.259c.021.022.021.088 0 .11-.028.022-.067.028-.088.006l-.292-.276h-.127l-.363.325-.033-.006c-.038.11-.087.089-.143.089-.126 0-.225-.072-.225-.193 0-.127.099-.209.225-.209h.176v-.182c0-.088.061-.131.149-.131h.066v-.127c0-.143.149-.297.286-.297h.28c.16 0 .27-.115.27-.275V2.42c0-.016.055.017.055-.088h-.187l-.005.017-.308.33a.123.123 0 01-.177 0c-.049-.044-.049-.121 0-.171l.391-.385c.027-.022.06-.022.094-.022l.005.022h.869A4.376 4.376 0 0014.5 1.1a4.402 4.402 0 00-2.816 1.018h.583c.094 0 .165.066.165.159s-.072.16-.165.16h-.478c0 .104-.039.06-.039.066v.351h.429l.226-.252c.132-.127.346-.155.473-.022a.332.332 0 010 .473l-1.183 1.182-.011.011c-.005.005-.011.005-.016.011a.115.115 0 00-.034.022c-.005.006-.01 0-.016.006a.309.309 0 01-.176.038h-.347c-.12.104-.187.148-.187.27v.088c0 .016-.027.027-.027.043l.561.589c.06.06.055.154 0 .209a.143.143 0 01-.209 0l-.578-.578a.425.425 0 01-.082.011c-.154 0-.292-.12-.292-.274v-.358h-.016c-.104.374-.165.77-.165 1.177 0 2.431 1.969 4.4 4.4 4.4zm3.388-3.107c.077 0 .16.06.16.137v.424c0 .077-.083.137-.16.137s-.16-.06-.16-.137V6.93c0-.077.083-.137.16-.137zm-3.113-4.879c0 .187-.154.314-.335.314h-.374v.104c0 .11-.05.198-.16.198s-.16-.088-.16-.198V1.98c-.104-.022-.033-.028-.033-.055 0-.187.127-.325.314-.325h.407c.187 0 .341.127.341.314z"],"inbox-search":["M7.136 3a6.327 6.327 0 00-.098 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h1.076l1.14 1.14a2.767 2.767 0 001.974.806c.282 0 .554-.042.81-.12V17c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h3.136zm3.244 1.33c0 1.62 1.31 2.93 2.93 2.93s2.93-1.31 2.93-2.93-1.31-2.93-2.93-2.93-2.93 1.31-2.93 2.93zm6.47 2.43l2.89 2.85c.13.15.22.35.23.56 0 .43-.35.78-.78.78-.23 0-.42-.08-.56-.22l-2.87-2.87c-.17.1-.33.2-.51.29-.03.01-.06.03-.09.04-.18.07-.35.15-.55.21-.19.06-.37.11-.57.14-.05.01-.1.02-.14.02-.2.03-.39.05-.6.05A4.3 4.3 0 019 4.31C9 1.93 10.93.01 13.3 0c2.37 0 4.3 1.93 4.3 4.3 0 .21-.02.4-.05.6-.01.05-.01.09-.02.14-.04.2-.08.38-.14.58-.05.19-.13.36-.21.54-.01.03-.03.06-.04.09-.08.18-.18.34-.29.51z"],"inbox-update":["M10.083 3a6.04 6.04 0 00.001 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h3.02l-.53-1.19a5.97 5.97 0 001.824-.811L20 10.545v6.456c0 .55-.45.999-1 .999H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h6.083zM16 8a4 4 0 110-8 4 4 0 010 8z"],"info-sign":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM9 4h2v2H9V4zm4 12H7v-1h2V8H8V7h3v8h2v1z"],inheritance:["M6 10c0 2.21 1.79 4 4 4h6.59l-2.29-2.29A.965.965 0 0114 11a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10c-3.31 0-6-2.69-6-6H1a1 1 0 01-1-1V1a1 1 0 011-1h8a1 1 0 011 1v8a1 1 0 01-1 1H6zM2 2v6h6V2H2z"],"inherited-group":["M1 9c.55 0 1 .45 1 1v4c0 1.1.9 2 2 2h2.59l-.3-.29a1.003 1.003 0 011.42-1.42l2 2c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2 2A1.003 1.003 0 016 19c0-.28.11-.53.3-.71l.29-.29H4c-2.21 0-4-1.79-4-4v-4c0-.55.45-1 1-1zm6.996-9c.79 0 1.68.25 2.309.73a3.63 3.63 0 011.4 2.36c.11.6.17 1.52.17 2.15v.09c.22.09.42.32.47.82.03.39-.12.73-.2.87-.07.34-.27.71-.61.78-.04.16-.09.33-.15.48-.01.01-.02.05-.02.05-.27.71-.68 1.33-1.19 1.78 0 .08 0 .16.01.23.05.55-.15.95 1.33 1.6 1.469.66 3.698 1.35 4.178 2.39.45 1.05.27 1.67.27 1.67h-5.227a1.982 1.982 0 00-.319-.417l-2-2A2.003 2.003 0 005 15H4c-.548 0-1-.452-1-1v-1.462c.511-.213 1.023-.413 1.468-.608 1.479-.65 1.329-1.05 1.379-1.59l.01-.21c-.52-.45-.95-1.08-1.22-1.8l-.01-.01-.01-.03c-.07-.15-.12-.32-.16-.49-.34-.06-.54-.43-.62-.78-.08-.14-.24-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.64.05-1.55.17-2.15a3.648 3.648 0 011.4-2.36C6.317.25 7.207 0 7.996 0zm5.997 3c.59 0 1.26.19 1.73.55.46.35.8.85.97 1.4.04.13.07.25.08.38.08.45.13 1.14.13 1.61v.07c.16.07.31.24.35.62.02.29-.09.55-.15.65-.05.26-.2.53-.46.59-.03.12-.07.25-.11.36-.01.01-.01.04-.01.04-.2.53-.51 1-.89 1.34 0 .06 0 .12.01.17.04.41-.11.71 1 1.19 1.099.5 2.768 1.01 3.128 1.79.34.79.2 1.25.2 1.25h-3.039V15c-.06-.33-.17-.69-.33-1.06-.45-.97-1.37-1.52-3.238-2.3-.17-.07-.76-.31-.77-.32-.1-.04-.2-.08-.28-.12.05-.14.04-.29.06-.45l.01-.16c-.25-.21-.47-.48-.65-.79.22-.34.41-.71.56-1.12l.028-.078-.002.013-.006.035.06-.15c.36-.26.6-.67.72-1.13.18-.37.29-.82.25-1.3-.05-.5-.21-.92-.47-1.22-.02-.53-.06-1.11-.12-1.59.38-.17.83-.26 1.24-.26z"],"inner-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zm-3.34 9.25c-.55-1.2-.86-2.54-.86-3.95s.31-2.75.86-3.95a4.001 4.001 0 000 7.9zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm.6 2.05c.55 1.2.86 2.54.86 3.95s-.31 2.75-.86 3.95c1.9-.31 3.36-1.96 3.36-3.95S16.5 6.36 14.6 6.05zM10 5.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],insert:["M19 0H1C.4 0 0 .4 0 1v18c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V1c0-.6-.5-1-1-1zm-1 18H2V2h16v16zM5 11h4v4c0 .6.4 1 1 1s1-.4 1-1v-4h4c.6 0 1-.4 1-1s-.4-1-1-1h-4V5c0-.6-.4-1-1-1s-1 .4-1 1v4H5c-.6 0-1 .4-1 1s.4 1 1 1z"],intersection:["M13 4c-1.31 0-2.51.43-3.5 1.14A5.977 5.977 0 006 4c-3.31 0-6 2.69-6 6s2.69 6 6 6c1.31 0 2.51-.43 3.5-1.14.99.71 2.19 1.14 3.5 1.14 3.31 0 6-2.69 6-6s-2.69-6-6-6zm-4.93 9.41c-.61.37-1.31.59-2.07.59-2.21 0-4-1.79-4-4s1.79-4 4-4c.76 0 1.46.22 2.07.59C7.4 7.56 7 8.73 7 10s.4 2.44 1.07 3.41zM13 14c-.76 0-1.46-.22-2.07-.59C11.6 12.44 12 11.27 12 10s-.4-2.44-1.07-3.41C11.54 6.22 12.24 6 13 6c2.21 0 4 1.79 4 4s-1.79 4-4 4z"],"ip-address":["M6 3.66C6 5.69 10 11 10 11s4-5.31 4-7.34C13.99 1.64 12.21 0 10 0S6 1.64 6 3.66zM8 4c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2zM14 13.5V13h-4v1h3v2h-2v1h3v-3.5zM3 12h14c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1H3c-.55 0-1-.45-1-1v-6c0-.55.45-1 1-1zm4 1v6h1v-6H7zm3 1v5h1v-5h-1z"],issue:["M10 20C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 100-16 8 8 0 000 16zm1-2H9v-2h2v2zm0-3H9V4h2v9z"],"issue-closed":["M15.364 5.9a.997.997 0 01-.707-.293l-2.121-2.122a1 1 0 111.414-1.414l1.414 1.414L18.192.657a1 1 0 011.414 1.414l-3.535 3.536a.997.997 0 01-.707.292zM11.78.157a3.002 3.002 0 00-1.437 1.85 8 8 0 107.1 5.055l.042-.042 1.472-1.472A9.959 9.959 0 0120 10c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0c.608 0 1.202.054 1.78.158zM11 16H9v-2h2v2zm0-3H9V4h2v9z"],"issue-new":["M13.167.512a2.98 2.98 0 00-.131.524c-.74.115-1.39.5-1.848 1.052a8 8 0 106.724 6.724 2.997 2.997 0 001.052-1.848 2.98 2.98 0 00.524-.13A9.99 9.99 0 0120 10c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0a9.99 9.99 0 013.167.512zM11 16H9v-2h2v2zm0-3H9V4h2v9zm6-10h1.5a1 1 0 010 2H17v1.5a1 1 0 01-2 0V5h-1.5a1 1 0 010-2H15V1.5a1 1 0 012 0V3z"],italic:["M11.7 4H14c.6 0 1-.4 1-1s-.4-1-1-1H7c-.6 0-1 .4-1 1s.4 1 1 1h2.2L7.3 15H5c-.6 0-1 .4-1 1s.4 1 1 1h7c.6 0 1-.4 1-1s-.4-1-1-1H9.8l1.9-11z"],"join-table":["M19 6h-4V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h4v4c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zM6 12H2V9h4v3zm0-4H2V5h4v3zm7 9H7v-3h6v3zm0-4H7V9h6v4zm0-5H7V5h6v3zm5 9h-4v-3h4v3zm0-4h-4v-3h4v3z"],key:["M14 0c-3.31 0-6 2.69-6 6 0 1.11.32 2.14.85 3.03L.44 17.44a1.498 1.498 0 102.12 2.12l.79-.79.94.94c.18.18.43.29.71.29s.53-.11.71-.29l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-.94-.94 3.2-3.2A5.9 5.9 0 0014 12c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 9c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"key-backspace":["M19 3H7c-.28 0-.53.11-.71.29l-6 6C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l6 6c.18.18.43.29.71.29h12c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-2.29 9.29a1.003 1.003 0 01-1.42 1.42L13 11.41l-2.29 2.29c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71l2.3-2.29-2.3-2.29a1.003 1.003 0 011.42-1.42L13 8.59l2.29-2.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L14.41 10l2.3 2.29z"],"key-command":["M15.5 12H14V8h1.5C17.43 8 19 6.43 19 4.5S17.43 1 15.5 1 12 2.57 12 4.5V6H8V4.5C8 2.57 6.43 1 4.5 1S1 2.57 1 4.5 2.57 8 4.5 8H6v4H4.5C2.57 12 1 13.57 1 15.5S2.57 19 4.5 19 8 17.43 8 15.5V14h4v1.5c0 1.93 1.57 3.5 3.5 3.5s3.5-1.57 3.5-3.5-1.57-3.5-3.5-3.5zm0-9c.83 0 1.5.67 1.5 1.5S16.33 6 15.5 6 14 5.33 14 4.5 14.67 3 15.5 3zm-11 14c-.83 0-1.5-.67-1.5-1.5S3.67 14 4.5 14s1.5.67 1.5 1.5S5.33 17 4.5 17zm0-11C3.67 6 3 5.33 3 4.5S3.67 3 4.5 3 6 3.67 6 4.5 5.33 6 4.5 6zm7.5 6H8V8h4v4zm3.5 5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],"key-control":["M16.71 7.29l-6-6C10.53 1.11 10.28 1 10 1s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42L10 3.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"key-delete":["M19.71 9.29l-6-6A.997.997 0 0013 3H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.28 0 .53-.11.71-.29l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zm-9 3a1.003 1.003 0 01-1.42 1.42L7 11.41 4.71 13.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L5.59 10l-2.3-2.29a1.003 1.003 0 011.42-1.42L7 8.59 9.29 6.3c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L8.41 10l2.3 2.29z"],"key-enter":["M18 2c-.55 0-1 .45-1 1v5c0 2.21-1.79 4-4 4H4.41L6.7 9.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.41 14H13c3.31 0 6-2.69 6-6V3c0-.55-.45-1-1-1z"],"key-escape":["M2 8c.55 0 1-.45 1-1V4.41l6.29 6.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 3H7c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1zm9-6.94V3.1c3.39.49 6 3.38 6 6.9 0 3.87-3.13 7-7 7-3.52 0-6.41-2.61-6.9-6H1.06c.5 4.5 4.31 8 8.94 8a9 9 0 009-9c0-4.63-3.5-8.44-8-8.94z"],"key-option":["M13 4h6c.55 0 1-.45 1-1s-.45-1-1-1h-6c-.55 0-1 .45-1 1s.45 1 1 1zm6 12h-4.42L6.87 2.5l-.02.01A.977.977 0 006 2H1c-.55 0-1 .45-1 1s.45 1 1 1h4.42l7.71 13.5.01-.01c.18.3.49.51.86.51h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"key-shift":["M17.74 10.35l-6.99-8.01-.01.01C10.56 2.14 10.3 2 10 2s-.56.14-.74.35l-.01-.01-7 8 .01.01A.95.95 0 002 11c0 .55.45 1 1 1h3v5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-5h3c.55 0 1-.45 1-1 0-.25-.1-.48-.26-.65z"],"key-tab":["M19 13H4.41l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L2 12.59V10c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1s1-.45 1-1v-2.59l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 15H19c.55 0 1-.45 1-1s-.45-1-1-1zm0-12c-.55 0-1 .45-1 1v2.59L14.71 1.3A.965.965 0 0014 1a1.003 1.003 0 00-.71 1.71L15.59 5H1c-.55 0-1 .45-1 1s.45 1 1 1h14.59L13.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 7.41V10c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"known-vehicle":["M19 4a.997.997 0 00-.707.293L14 8.586l-2.293-2.293a1 1 0 00-1.414 1.414l3 3a.997.997 0 001.414 0l5-5A1 1 0 0019 4zm-2.048 7.291c.011.072.048.134.048.209a1.5 1.5 0 01-1.5 1.5c-.225 0-.433-.057-.624-.145-.279.085-.57.145-.876.145a2.99 2.99 0 01-2.121-.879l-3-3 .007-.007A3.027 3.027 0 018.184 8H4V7l1-3h10l.19.568 1.307-1.308c-.336-.356-.758-.658-1.165-.772 0 0-1.74-.488-5.332-.488s-5.332.488-5.332.488c-.67.188-1.424.864-1.674 1.502L2.99 4H3L2 7H1a1 1 0 000 2h.333l-.28.84L1 10v7.5a1.5 1.5 0 103 0V17h12v.5a1.5 1.5 0 003 0V10l-.19-.568-1.858 1.86zM4.5 13a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"],"lab-test":["M13 2a1 1 0 010 2v4l4 8v1a1 1 0 01-1 1H4a1 1 0 01-1-1v-1l4-8V4a1 1 0 110-2h6zm-2 2H9v4l-2 4h6l-2-4V4z"],label:["M3 12h14v-1H3v1zm11-9H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V9l-6-6zm4 12H2V5h11v3H3v1h10v1h5v5zm-4-6V5l4 4h-4z"],layer:["M19.5 9.1l-9-5c-.2-.1-.3-.1-.5-.1s-.3 0-.5.1l-9 5c-.3.2-.5.5-.5.9s.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9s-.2-.7-.5-.9z"],"layer-outline":["M9.514 4.126l-9 5a1 1 0 000 1.748l9 5a1 1 0 00.972 0l9-5a1 1 0 000-1.748l-9-5a1 1 0 00-.972 0zM10 6.144l6.94 3.855L10 13.855 3.059 9.999 10 6.144z"],layers:["M.5 6.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9s-.2-.7-.5-.9l-9-5c-.2-.1-.3-.1-.5-.1s-.3 0-.5.1l-9 5c-.3.2-.5.5-.5.9s.2.7.5.9z","M19 9c-.2 0-.3 0-.5.1L10 13.9 1.5 9.1C1.3 9 1.2 9 1 9c-.6 0-1 .4-1 1 0 .4.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9 0-.6-.4-1-1-1z","M19 13c-.2 0-.3 0-.5.1L10 17.9l-8.5-4.7c-.2-.2-.3-.2-.5-.2-.6 0-1 .4-1 1 0 .4.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9 0-.6-.4-1-1-1z"],layout:["M18 6c-1.1 0-2 .9-2 2 0 .37.11.71.28 1.01l-2.27 2.27c-.3-.17-.64-.28-1.01-.28-.93 0-1.71.64-1.93 1.5H8.93c-.22-.86-1-1.5-1.93-1.5-.37 0-.71.11-1.01.28L3.72 9.01C3.89 8.71 4 8.37 4 8c0-.34-.09-.66-.24-.94l3.66-3.38c.31.2.68.32 1.08.32 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .34.09.66.24.94L3.08 6.32C2.77 6.12 2.4 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.37 0 .71-.11 1.01-.28l2.27 2.27c-.17.3-.28.64-.28 1.01s.11.71.28 1.01l-2.27 2.27C2.71 16.11 2.37 16 2 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28.93 0 1.71-.64 1.93-1.5h2.14c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2 0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28 1.1 0 2-.9 2-2s-.9-2-2-2z"],"layout-auto":["M18 13c-.53 0-1.01.21-1.37.55L11.9 10.6c.06-.19.1-.39.1-.6s-.04-.41-.1-.6l4.72-2.95c.37.34.85.55 1.38.55 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .21.04.41.1.6l-4.73 2.96c-.24-.23-.54-.4-.87-.48V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.33.09-.63.26-.87.48L3.9 5.6c.06-.19.1-.39.1-.6 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.53 0 1.01-.21 1.37-.55L8.1 9.4c-.06.19-.1.39-.1.6s.04.41.1.6l-4.72 2.95C3.01 13.21 2.53 13 2 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.21-.04-.41-.1-.6l4.73-2.96c.24.23.54.4.87.48v4.14C8.64 16.29 8 17.07 8 18c0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.33-.09.63-.26.87-.48l4.73 2.96c-.06.18-.1.38-.1.59 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-balloon":["M18 16c-.14 0-.28.02-.42.05l-1.73-3.45c.69-.45 1.14-1.22 1.14-2.1s-.46-1.65-1.14-2.1l1.73-3.45c.14.03.28.05.42.05 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .6.27 1.13.69 1.5l-1.77 3.54c-.14-.02-.28-.04-.42-.04a2.5 2.5 0 00-2.45 2h-4.1A2.5 2.5 0 005.5 8c-.14 0-.28.02-.42.04L3.31 4.5C3.73 4.13 4 3.6 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.14 0 .28-.02.42-.05L4.14 8.4C3.46 8.85 3 9.62 3 10.5s.46 1.65 1.14 2.1l-1.73 3.45A1.84 1.84 0 002 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.6-.27-1.13-.69-1.5l1.77-3.54c.14.02.28.04.42.04a2.5 2.5 0 002.45-2h4.1a2.5 2.5 0 002.45 2c.14 0 .28-.02.42-.04l1.77 3.54c-.42.37-.69.9-.69 1.5 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-circle":["M18.3 8c-.2-.9-.6-1.7-1.1-2.5.2-.3.3-.7.3-1 0-1.1-.9-2-2-2-.4 0-.7.1-1 .3-.8-.5-1.6-.8-2.5-1.1-.1-1-1-1.7-2-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8a2 2 0 100 4 2 2 0 100-4zM10 8a2 2 0 100 4 2 2 0 100-4z"],"layout-group-by":["M2 2a2 2 0 100 4 2 2 0 100-4zM18 0a2 2 0 100 4 2 2 0 100-4zM18 8a2 2 0 100 4 2 2 0 100-4zM18 16a2 2 0 100 4 2 2 0 100-4zM2 14a2 2 0 100 4 2 2 0 100-4zM2 8a2 2 0 100 4 2 2 0 100-4zM13 12a2 2 0 100 4 2 2 0 100-4zM13 4a2 2 0 100 4 2 2 0 100-4z"],"layout-hierarchy":["M18.5 16.07v-4.14c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2-.93 0-1.71.64-1.93 1.5h-4.14c-.18-.7-.73-1.25-1.43-1.43V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.7.18-1.25.73-1.43 1.43H3.93C3.71 8.64 2.93 8 2 8c-1.1 0-2 .9-2 2 0 .93.64 1.71 1.5 1.93v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.7-.18 1.25-.73 1.43-1.43h4.14c.18.7.73 1.25 1.43 1.43v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.7-.18 1.25-.73 1.43-1.43h4.14c.18.7.73 1.25 1.43 1.43v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93z"],"layout-linear":["M16.5 7a2.5 2.5 0 00-2.45 2h-2.1a2.5 2.5 0 00-4.9 0h-2.1a2.5 2.5 0 100 1h2.1a2.5 2.5 0 004.9 0h2.1a2.5 2.5 0 102.45-3z"],"layout-skew-grid":["M2 0a2 2 0 100 4 2 2 0 100-4zM18 0a2 2 0 100 4 2 2 0 100-4zM18 8a2 2 0 100 4 2 2 0 100-4zM18 16a2 2 0 100 4 2 2 0 100-4zM2 16a2 2 0 100 4 2 2 0 100-4zM2 8a2 2 0 100 4 2 2 0 100-4zM10 12a2 2 0 100 4 2 2 0 100-4zM10 4a2 2 0 100 4 2 2 0 100-4z"],"layout-sorted-clusters":["M2 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm16 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-8 4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],learning:["M10.551 1.127a1.256 1.256 0 00-1.102 0L.456 5.89c-.608.309-.608.913 0 1.222l8.993 4.762c.334.17.767.17 1.102 0l8.992-4.762c.61-.309.61-.913 0-1.222l-8.992-4.762z","M18 6.5l.016 4.514c.002.548.447.99.994.99a.99.99 0 00.99-.99V6.5h-2zM3.366 10.033l6.401 3.358a.5.5 0 00.465 0l6.406-3.358a.25.25 0 01.366.221v5.109a.25.25 0 01-.139.224l-6.64 3.302a.5.5 0 01-.446 0l-6.64-3.302A.25.25 0 013 15.363v-5.108a.25.25 0 01.366-.222z"],"left-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm.6 2.05c.55 1.2.86 2.54.86 3.95s-.31 2.75-.86 3.95c1.9-.31 3.36-1.96 3.36-3.95S16.5 6.36 14.6 6.05zM10 5.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],"less-than":["M7.162 10l9.154 3.052a1 1 0 01-.632 1.897l-12-4c-.912-.304-.912-1.594 0-1.897l12-4a1 1 0 01.632 1.897L7.162 10z"],"less-than-or-equal-to":["M16.316 11.051L7.162 8l9.154-3.051a1 1 0 10-.632-1.898l-12 4c-.912.304-.912 1.594 0 1.898l12 4a1 1 0 10.632-1.898zM16 15H4a1 1 0 100 2h12a1 1 0 100-2z"],lifesaver:["M8.143 14.644L7.028 17.43c.919.368 1.922.57 2.972.57s2.053-.202 2.972-.57l-1.115-2.786A4.986 4.986 0 0110 15a4.986 4.986 0 01-1.857-.356zm-2.787-2.787A4.986 4.986 0 015 10c0-.656.126-1.283.356-1.857L2.57 7.028A7.978 7.978 0 002 10c0 1.05.202 2.053.57 2.972l2.786-1.115zm2.787-6.5A4.986 4.986 0 0110 5c.656 0 1.283.126 1.857.356l1.115-2.786A7.978 7.978 0 0010 2c-1.05 0-2.053.202-2.972.57l1.115 2.786zm6.5 2.786c.23.574.357 1.2.357 1.857 0 .656-.126 1.283-.356 1.857l2.786 1.115c.368-.919.57-1.922.57-2.972s-.202-2.053-.57-2.972l-2.786 1.115zM10 13a3 3 0 100-6 3 3 0 000 6zm0 7C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10z"],lightbulb:["M6.33 13.39c0 .34.27.61.6.61h6.13c.33 0 .6-.27.6-.61C14.03 9.78 16 9.4 16 6.09 16 2.72 13.31 0 10 0S4 2.72 4 6.09c0 3.31 1.97 3.69 2.33 7.3zM13 15H7c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm-1 3H8c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1z"],lightning:["M9 11H6a1 1 0 01-1-1L5.91.9a1 1 0 01.995-.9h6.256a.839.839 0 01.779 1.15L11.2 8h2.978a.822.822 0 01.748 1.162l-4.764 10.481A.608.608 0 019 19.392V11z"],link:["M10.85 11.98l-4.44 4.44-1 1c-.36.36-.86.58-1.41.58-1.1 0-2-.9-2-2 0-.55.22-1.05.59-1.41l5.44-5.44C7.69 9.06 7.36 9 7 9c-1.11 0-2.09.46-2.82 1.18l-.01-.01-3 3 .01.01C.46 13.91 0 14.89 0 16c0 2.21 1.79 4 4 4 1.11 0 2.09-.46 2.82-1.18l.01.01 3-3-.01-.01C10.54 15.09 11 14.11 11 13c0-.36-.06-.69-.15-1.02zM20 4c0-2.21-1.79-4-4-4-1.11 0-2.09.46-2.82 1.18l-.01-.01-3 3 .01.01C9.46 4.91 9 5.89 9 7c0 .36.06.69.15 1.02l4.44-4.44 1-1c.36-.36.86-.58 1.41-.58 1.1 0 2 .9 2 2 0 .55-.22 1.05-.59 1.41l-5.44 5.44c.34.09.67.15 1.03.15 1.11 0 2.09-.46 2.82-1.18l.01.01 3-3-.01-.01C19.54 6.09 20 5.11 20 4zM5 14a1.003 1.003 0 001.71.71l8-8a1.003 1.003 0 00-1.42-1.42l-2 2-2 2-2 2-2 2c-.18.18-.29.43-.29.71z"],list:["M1.03 1C.46 1 0 1.46 0 2.03v.95C0 3.54.46 4 1.03 4h17.95C19.54 4 20 3.54 20 2.97v-.94C20 1.46 19.54 1 18.97 1H1.03zM0 17.97C0 18.54.46 19 1.03 19h17.95c.56 0 1.03-.46 1.03-1.03v-.95c0-.56-.46-1.03-1.03-1.03H1.03C.46 16 0 16.46 0 17.03v.94zM0 12.97C0 13.54.46 14 1.03 14h17.95c.56 0 1.03-.46 1.03-1.03v-.95c0-.56-.46-1.03-1.03-1.03H1.03C.46 11 0 11.46 0 12.03v.94zM0 7.97C0 8.54.46 9 1.03 9h17.95C19.54 9 20 8.54 20 7.97v-.94C20 6.46 19.54 6 18.97 6H1.03C.46 6 0 6.46 0 7.03v.94z"],"list-columns":["M0 2.973v-.936C0 1.468.46 1.01 1.029 1H7.97C8.541 1 9 1.468 9 2.027v.946C9 3.542 8.53 4 7.971 4H1.03C.459 4 0 3.542 0 2.973zm0 5v-.936C0 6.468.46 6.01 1.029 6H7.97C8.541 6 9 6.468 9 7.027v.946C9 8.542 8.53 9 7.971 9H1.03C.459 9 0 8.542 0 7.973zm0 5v-.936C0 11.468.46 11.01 1.029 11H7.97C8.541 11 9 11.468 9 12.027v.946C9 13.542 8.53 14 7.971 14H1.03C.459 14 0 13.542 0 12.973zm0 5v-.936C0 16.468.46 16.01 1.029 16H7.97C8.541 16 9 16.468 9 17.027v.946C9 18.542 8.53 19 7.971 19H1.03C.459 19 0 18.542 0 17.973zm11-15v-.936c0-.569.46-1.027 1.029-1.037h6.942C19.541 1 20 1.468 20 2.027v.946C20 3.542 19.53 4 18.971 4H12.03C11.459 4 11 3.542 11 2.973zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942C19.541 6 20 6.468 20 7.027v.946C20 8.542 19.53 9 18.971 9H12.03C11.459 9 11 8.542 11 7.973zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942c.57 0 1.029.468 1.029 1.027v.946c0 .569-.47 1.027-1.029 1.027H12.03c-.57 0-1.029-.458-1.029-1.027zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942c.57 0 1.029.468 1.029 1.027v.946c0 .569-.47 1.027-1.029 1.027H12.03c-.57 0-1.029-.458-1.029-1.027z"],"list-detail-view":["M8 6H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM8 1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm11 0h-7c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1z"],locate:["M10 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm9 1h-1.07c-.45-3.61-3.32-6.45-6.93-6.91V1c0-.55-.45-1-1-1S9 .45 9 1v1.09C5.39 2.55 2.52 5.39 2.07 9H1c-.55 0-1 .45-1 1s.45 1 1 1h1.07c.45 3.61 3.32 6.45 6.93 6.91V19c0 .55.45 1 1 1s1-.45 1-1v-1.09c3.61-.46 6.48-3.29 6.93-6.91H19c.55 0 1-.45 1-1s-.45-1-1-1zm-4 2h.9a5.98 5.98 0 01-4.9 4.91V15c0-.55-.45-1-1-1s-1 .45-1 1v.91A5.98 5.98 0 014.1 11H5c.55 0 1-.45 1-1s-.45-1-1-1h-.9A5.98 5.98 0 019 4.09V5c0 .55.45 1 1 1s1-.45 1-1v-.91A5.98 5.98 0 0115.9 9H15c-.55 0-1 .45-1 1s.45 1 1 1z"],lock:["M15.93 9H14V4.99c0-2.21-1.79-4-4-4s-4 1.79-4 4V9H3.93c-.55 0-.93.44-.93.99v8c0 .55.38 1.01.93 1.01h12c.55 0 1.07-.46 1.07-1.01v-8c0-.55-.52-.99-1.07-.99zM8 9V4.99c0-1.1.9-2 2-2s2 .9 2 2V9H8z"],"log-in":["M19 0h-8c-.55 0-1 .45-1 1s.45 1 1 1h7v16h-7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 10c0-.28-.11-.53-.29-.71l-5-5a1.003 1.003 0 00-1.42 1.42L11.59 9H1c-.55 0-1 .45-1 1s.45 1 1 1h10.59L8.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5-5c.18-.18.29-.43.29-.71z"],"log-out":["M19.71 9.29l-5-5a1.003 1.003 0 00-1.42 1.42L16.59 9H6c-.55 0-1 .45-1 1s.45 1 1 1h10.59l-3.29 3.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5-5c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM9 18H2V2h7c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],manual:["M20 1.1a.976.976 0 00-.83-.88C15.15-.43 12.07.34 10 2.5 7.93.34 4.85-.43.84.22.37.3.03.67 0 1.1v15.01c0 .07 0 .14.01.21.09.52.61.88 1.15.79 3.85-.62 6.4.16 8 2.46.02.02.03.04.05.07.02.02.04.04.06.07l.01.01a1.07 1.07 0 00.28.19c.01 0 .01.01.02.01.03.01.07.03.1.04.01 0 .02.01.04.01.03.01.07.02.1.02.01 0 .02 0 .04.01H10c.04 0 .09 0 .13-.01.01 0 .03 0 .04-.01.03-.01.06-.01.1-.02.01 0 .03-.01.04-.01.03-.01.07-.02.1-.04.01 0 .02-.01.03-.01.07-.03.13-.07.19-.11.01 0 .01-.01.02-.01.02-.02.04-.03.06-.05.01-.01.02-.02.03-.02l.05-.05c.01-.01.02-.02.02-.03.01-.02.02-.03.04-.05 1.61-2.3 4.15-3.09 8-2.46.54.09 1.06-.26 1.15-.79-.01-.05 0-.09 0-.13V1.1zM9 16.63c-1.78-1.31-4.12-1.83-7-1.55V2c3.26-.37 5.51.39 7 2.35v12.28zm9-1.56c-2.88-.28-5.22.24-7 1.55V4.34c1.49-1.96 3.74-2.71 7-2.35v13.08z"],"manually-entered-data":["M1 12h4.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm16.77-3.94l1.65-1.65c.36-.36.58-.86.58-1.41 0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.82zM1 4h12.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zM0 15c0 .55.45 1 1 1h.34l2-2H1c-.55 0-1 .45-1 1zm1-7h8.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 2h-.34l-2 2H19c.55 0 1-.45 1-1s-.45-1-1-1zm0 4h-4.34l-2 2H19c.55 0 1-.45 1-1s-.45-1-1-1zM4 19l4.41-1.59-2.81-2.79L4 19zM14.23 5.94l-7.65 7.65 2.83 2.83 7.65-7.65-2.83-2.83z"],"many-to-many":["M17 6a1 1 0 100-2 1 1 0 000 2zm0 2a3 3 0 01-2.73-1.754c-.2.068-.408.154-.617.264-.884.465-1.92 1.418-2.605 3.49.685 2.072 1.721 3.025 2.605 3.49.21.11.416.196.617.264a3 3 0 11-.165 2.034 6.262 6.262 0 01-1.383-.528c-.983-.518-1.948-1.364-2.722-2.705-.774 1.34-1.739 2.187-2.722 2.705-.48.252-.95.419-1.383.528A3.001 3.001 0 010 15a3 3 0 015.73-1.246c.2-.068.408-.154.617-.264.884-.465 1.92-1.418 2.605-3.49-.685-2.072-1.721-3.025-2.605-3.49a4.21 4.21 0 00-.617-.264 3 3 0 11.165-2.034c.433.11.904.276 1.383.528.983.518 1.948 1.364 2.722 2.705.774-1.34 1.739-2.187 2.722-2.705.48-.252.95-.419 1.383-.528A3.001 3.001 0 0120 5a3 3 0 01-3 3zM4 5a1 1 0 10-2 0 1 1 0 002 0zm12 10a1 1 0 102 0 1 1 0 00-2 0zM3 14a1 1 0 110 2 1 1 0 010-2z"],"many-to-one":["M3 2a1 1 0 100 2 1 1 0 000-2zm0 4c1.296 0 2.4-.821 2.82-1.972.487.039 1.086.13 1.667.347.947.352 1.773 1 2.032 2.318.323 1.644 1.234 2.675 2.264 3.307-1.03.632-1.941 1.663-2.264 3.307-.259 1.318-1.085 1.966-2.032 2.318a6.244 6.244 0 01-1.668.347 3.001 3.001 0 10.019 2.004c.633-.042 1.491-.158 2.347-.476 1.402-.523 2.867-1.625 3.296-3.807.259-1.318 1.085-1.966 2.032-2.318.24-.09.484-.158.722-.21a3 3 0 100-2.33 5.329 5.329 0 01-.722-.21c-.947-.352-1.773-1-2.032-2.318-.428-2.182-1.894-3.284-3.296-3.807-.856-.318-1.714-.434-2.347-.476A3.001 3.001 0 000 3a3 3 0 003 3zm13 4a1 1 0 102 0 1 1 0 00-2 0zM2 17a1 1 0 112 0 1 1 0 01-2 0z"],map:["M19.54 4.18l.01-.02-6-4-.01.02C13.39.08 13.21 0 13 0s-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v14c0 .35.19.64.46.82l-.01.02 6 4 .01-.02c.15.1.33.18.54.18s.39-.08.54-.18l.01.02L13 16.2l5.45 3.63.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1V5c0-.35-.19-.64-.46-.82zM6 17.13l-4-2.67V2.87l4 2.67v11.59zm6-2.67l-4 2.67V5.54l4-2.67v11.59zm6 2.67l-4-2.67V2.87l4 2.67v11.59z"],"map-create":["M18 9.22v7.91l-4-2.67V9.22c-.61-.55-1-1.33-1-2.22-.35 0-.69-.07-1-.18v7.65l-4 2.67V5.54l2.02-1.35c0-.06-.02-.13-.02-.19 0-1.66 1.34-3 3-3 0-.34.07-.66.17-.97C13.12.02 13.06 0 13 0c-.21 0-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v14c0 .35.19.64.46.82l-.01.02 6 4 .01-.02c.15.1.33.18.54.18s.39-.08.54-.18l.01.02L13 16.2l5.45 3.63.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1V6.82c-.31.11-.65.18-1 .18 0 .89-.39 1.67-1 2.22zM6 17.13l-4-2.67V2.87l4 2.67v11.59zM12 4c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1z"],"map-marker":["M9.98 0c-3.87 0-7 2.98-7 6.67 0 3.68 7 13.33 7 13.33s7-9.65 7-13.33c0-3.68-3.14-6.67-7-6.67zm0 10c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],maximize:["M19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zM8 11c-.28 0-.53.11-.71.29L2 16.59V14c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1H3.41l5.29-5.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1z"],media:["M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z"],menu:["M1 6h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 3H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-closed":["M8 6h11c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM4 6c-.28 0-.53.11-.71.29l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3A1.003 1.003 0 005 13V7c0-.55-.45-1-1-1zm15 8H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0-5H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-open":["M12 9H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0-10H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm7.71 5.29l-3-3A1.003 1.003 0 0015 7v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"merge-columns":["M6.71 6.29a1.003 1.003 0 00-1.42 1.42L6.59 9H2V2h5v2.18c.42.15.8.39 1.11.7l.01-.01.88.89V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4.76l-.88.88-.01-.01c-.31.31-.69.56-1.11.71V18H2v-7h4.59L5.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM19 0h-7c-.55 0-1 .45-1 1v4.76l.88-.88.01.01c.31-.31.69-.55 1.11-.7V2h5v7h-4.59l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L13.41 11H18v7h-5v-2.18c-.42-.15-.8-.39-1.11-.7l-.01.01-.88-.89V19c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"merge-links":["M10 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm8-5c-.93 0-1.71.64-1.93 1.5H14V4c0-2.21-1.79-4-4-4S6 1.79 6 4v5.5H3.93C3.71 8.64 2.93 8 2 8c-1.1 0-2 .9-2 2s.9 2 2 2c.93 0 1.71-.64 1.93-1.5H6V16c0 2.21 1.79 4 4 4s4-1.79 4-4v-5.5h2.07c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2s-.9-2-2-2zm-5 8c0 1.66-1.34 3-3 3s-3-1.34-3-3V4c0-1.66 1.34-3 3-3s3 1.34 3 3v12zM10 3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],minimize:["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zM20 1a1.003 1.003 0 00-1.71-.71L13 5.59V3c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1h-2.59l5.29-5.29c.19-.18.3-.43.3-.71z"],minus:["M16 9H4c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],"mobile-phone":["M15 0H5c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 19c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4-3H6V3h8v13z"],"mobile-video":["M19 5c-.28 0-.53.11-.71.29L15 8.59V5c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h13c.55 0 1-.45 1-1v-3.59l3.29 3.29c.18.19.43.3.71.3.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],modal:["M19 1a1 1 0 011 1v16a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1h18zm-1 4H2v12h16V5zm-3-3h-2v2h2V2zm3 0h-2v2h2V2z"],"modal-filled":["M20 5v13a1 1 0 01-1 1H1a1 1 0 01-1-1V5h20zm-3-4h2a1 1 0 011 1v1h-3V1zm-2 2H0V2a1 1 0 011-1h14v2z"],moon:["M19 14.15A9.94 9.94 0 019.94 20C4.45 20 0 15.55 0 10.06 0 6.03 2.4 2.56 5.85 1a9.811 9.811 0 00-.88 4.09c0 5.49 4.45 9.94 9.94 9.94 1.46 0 2.84-.31 4.09-.88z"],more:["M3.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM17.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM10.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5z"],mountain:["M20 16H4l7-11h1l2 2h1l5 9zm-4-5l-1.5-3h-1l-1-1-1-1L8 11.5l3-1.5 1 1 1-1 3 1zM8.055 8L2.79 16H0l7-8h1.055z"],move:["M19.71 9.29l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 9H11V3.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C10.53.11 10.28 0 10 0s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 3.41V9H3.41L4.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 11H9v5.59L7.71 15.3A.965.965 0 007 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L11 16.59V11h5.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],mugshot:["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18h-.07c-.05-.2-.12-.42-.22-.67-.46-1.05-2.68-1.75-4.16-2.4-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.67 3.67 0 00-1.29-1.86C11.7 3.25 10.81 3 10.02 3s-1.68.25-2.31.73c-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.17 1.51-.17 2.14v.08c-.24.09-.44.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59-1.48.65-3.7 1.35-4.16 2.4-.12.27-.18.49-.23.69H2V2h16v16z"],"multi-select":["M19 3H7c-.55 0-1 .45-1 1v1h12v6h1c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-6 6H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm-1 6H2v-4h10v4zm4-9H4c-.55 0-1 .45-1 1v1h12v6h1c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],music:["M19 0c-.08 0-.16.03-.24.05V.03l-12 3v.02C6.33 3.16 6 3.53 6 4v11.35c-.59-.22-1.27-.35-2-.35-2.21 0-4 1.12-4 2.5S1.79 20 4 20c1.94 0 3.55-.86 3.92-2H8V7.78l10-2.5v7.07c-.59-.22-1.27-.35-2-.35-2.21 0-4 1.12-4 2.5s1.79 2.5 4 2.5c1.94 0 3.55-.86 3.92-2H20V1c0-.55-.45-1-1-1z"],nest:["M2 2c.55 0 1 .45 1 1v5c0 2.21 1.79 4 4 4h8.59L13.3 9.71A.965.965 0 0113 9a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H7c-3.31 0-6-2.69-6-6V3c0-.55.45-1 1-1z"],"new-drawing":["M18.7 13.7c.5 0 1 .4 1 1 0 .257-.073.44-.22.614l-.08.086-4 4c-.2.2-.4.3-.7.3-.6 0-1-.5-1-1 0-.257.073-.44.22-.614L14 18l4-4c.2-.2.4-.3.7-.3zM1.8 0l8.378 2.982A3.003 3.003 0 0013 7a3.003 3.003 0 003.877 2.87l.723 2.53.049.06a.41.41 0 01.051.24c0 .167-.07.403-.208.593l-.092.107-4 4c-.2.2-.4.3-.7.3-.075 0-.15-.056-.225-.084L12.4 17.6l-7-2-.112-.042c-.223-.094-.431-.244-.542-.45L4.7 15 0 1.8l.5-.6L7 7.7c-.2.3-.3.6-.3 1 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2a1.68 1.68 0 00-.871.22L7.7 7 1.2.5l.6-.5zM16 0c.55 0 1 .45 1 1v2h2c.55 0 1 .45 1 1s-.45 1-1 1h-2v2c0 .432-.278.803-.664.941l-.01.004A.989.989 0 0116 8c-.55 0-1-.45-1-1V5h-2c-.55 0-1-.45-1-1l.007-.116C12.065 3.388 12.489 3 13 3h2V1c0-.55.45-1 1-1z"],"new-grid-item":["M8 0H1C.45 0 0 .45 0 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm0 11H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1zm6 7h-1v-1c0-.55-.45-1-1-1s-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1s-.45-1-1-1zm5-7h-2c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1zm0-11h-7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 11h-2c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1zm5 5c-.55 0-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],"new-layer":["M11.513 2.663A2 2 0 0013 6h1v1a2 2 0 104 0v-.733l1.5.833c.3.2.5.5.5.9s-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5C.2 8.7 0 8.4 0 8s.2-.7.5-.9l9-5c.2-.1.3-.1.5-.1s.3 0 .5.1l1.013.563zM17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2z"],"new-layers":["M17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2zm-1.252 5.984L10.5 11.9c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5C.2 6.7 0 6.4 0 6s.2-.7.5-.9l9-5c.2-.1.3-.1.5-.1s.3 0 .5.1L13.92 2H13a2 2 0 100 4h1v1a2 2 0 001.748 1.984zm2.07-1.15C17.935 7.58 18 7.298 18 7V6h1c.353 0 .684-.091.972-.251.018.078.028.162.028.251 0 .4-.2.7-.5.9l-1.682.934zM19 9c.6 0 1 .4 1 1 0 .4-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5c-.3-.2-.5-.5-.5-.9 0-.6.4-1 1-1 .2 0 .3 0 .5.1l8.5 4.8 8.5-4.8c.2-.1.3-.1.5-.1zm0 4c.6 0 1 .4 1 1 0 .4-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5c-.3-.2-.5-.5-.5-.9 0-.6.4-1 1-1 .2 0 .3 0 .5.2l8.5 4.7 8.5-4.8c.2-.1.3-.1.5-.1z"],"new-link":["M14.5 12a2.5 2.5 0 00-2.45 2h-7.1a2.5 2.5 0 100 1h7.1a2.5 2.5 0 102.45-3zM19 5h-2V3c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V7h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-object":["M12 4c0 .6.4 1 1 1h2v2c0 .6.4 1 1 1 .5 0 1-.4 1-1V5h2c.5 0 1-.4 1-1s-.5-1-1-1h-2V1c0-.6-.5-1-1-1-.6 0-1 .4-1 1v2h-2c-.6 0-1 .5-1 1zm7 3c0 1.7-1.3 3-3 3s-3-1.3-3-3c-1.7 0-3-1.3-3-3s1.3-3 3-3c0-.2 0-.4.1-.5-1-.3-2-.5-3.1-.5C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10c0-1.1-.2-2.1-.5-3H19z"],"new-person":["M11.41 15.92c-1.46-.65-1.26-1.05-1.31-1.59-.01-.07-.01-.15-.01-.23.5-.45.91-1.07 1.18-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.33-.07.53-.44.6-.78.08-.14.23-.48.2-.87-.05-.5-.24-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5-.22-.73-.67-1.4-1.27-1.86C9.58 4.25 8.7 4 7.92 4c-.78 0-1.66.25-2.28.73-.61.47-1.06 1.13-1.27 1.86-.05.16-.08.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.43.32-.48.83-.04.39.12.73.2.87.08.35.28.72.62.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.69 1.35 1.21 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.36 1.59-1.46.65-3.66 1.35-4.11 2.4C-.14 19.38.04 20 .04 20h15.75s.18-.62-.27-1.67c-.45-1.06-2.65-1.75-4.11-2.41zM18.87 3h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-prescription":["M11.95 10.23c.16-.18.22-.22.46-.22h1.48c.25 0 .47.08.59.33.1.2.09.41-.05.66l-2.71 3.58L14.88 19c.13.21.16.46.03.69-.12.21-.34.31-.57.31H12.7c-.31 0-.56-.17-.7-.44l-1.9-2.67-1.93 2.68c-.15.27-.42.43-.73.43H5.98c-.25 0-.47-.08-.59-.33-.1-.2-.09-.41.05-.66l3.09-4.35L4.26 9H3v4.32c0 .41-.3.69-.7.69H.7c-.41 0-.7-.28-.7-.69V.69C0 .28.3 0 .7 0h4.42c.71 0 1.36.1 1.94.3.59.2 1.11.49 1.54.87.44.38.78.84 1.02 1.39.25.54.37 1.13.37 1.77 0 1.01-.28 1.88-.84 2.6-.43.54-1.35 1.29-2 1.59l3.09 3.94 1.71-2.23zM4.71 6.04c.71 0 1.45-.16 1.81-.46.33-.28.5-.69.5-1.25s-.17-.97-.5-1.25c-.35-.3-1.1-.46-1.81-.46h-1.7v3.42h1.7zM19 3c.55 0 1 .45 1 1s-.45 1-1 1h-2v2c0 .55-.45 1-1 1s-1-.45-1-1V5h-2c-.55 0-1-.45-1-1s.45-1 1-1h2V1c0-.55.45-1 1-1s1 .45 1 1v2h2z"],"new-text-box":["M19 3h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1zM5 7.5v1c0 .28.22.5.5.5s.5-.22.5-.5V8h2v7h-.5c-.28 0-.5.22-.5.5s.22.5.5.5h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H9V8h2v.5c0 .28.22.5.5.5s.5-.22.5-.5v-1c0-.28-.22-.5-.5-.5h-6c-.28 0-.5.22-.5.5zM16 9c-.55 0-1 .45-1 1v8H2V5h8c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1h15c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1z"],ninja:["M20 6s-2.98 2.43-6.12 2.19C13.52 5.31 12.05 0 6 0c0 0 2.41 2.99 2.16 6.12C5.27 6.49 0 7.97 0 14c0 0 2.98-2.43 6.11-2.19C6.47 14.69 7.94 20 14 20c0 0-2.42-2.99-2.16-6.13C14.73 13.51 20 12.02 20 6zm-10 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"not-equal-to":["M9.487 7l.532-3.196a1 1 0 011.962.392L11.513 7H16a1 1 0 010 2h-4.82l-.333 2H16a1 1 0 010 2h-5.487l-.532 3.196a1 1 0 01-1.962-.392L8.487 13H4a1 1 0 010-2h4.82l.333-2H4a1 1 0 110-2h5.487z"],notifications:["M10 20c1.1 0 2-.9 2-2H8c0 1.1.9 2 2 2zm7-5c-.55 0-1-.45-1-1V8c0-2.61-1.67-4.81-4-5.63V2c0-1.1-.9-2-2-2S8 .9 8 2v.37C5.67 3.19 4 5.39 4 8v6c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"notifications-snooze":["M10 18c0 1.1-.9 2-2 2s-2-.9-2-2zM8 0c.476 0 .914.168 1.258.448C8.508.878 8.09 1.562 8 2.5c-.133 1.4.4 2.367 1.6 2.9C8.533 6.6 8 7.467 8 8v1.2a2.8 2.8 0 002.8 2.8H14v2c0 .51.388.935.884.993L15 15c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V8c0-2.61 1.67-4.81 4-5.63V2c0-1.1.9-2 2-2z","M16 9.25v-.395a.75.75 0 00-.75-.75h-2.813L15.834 3.9A.75.75 0 0016 3.43v-.68a.75.75 0 00-.75-.75h-4.5a.75.75 0 00-.75.75v.184c0 .414.336.75.75.75h2.813L10.22 7.831a1 1 0 00-.221.627v.792c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75z"],"notifications-updated":["M10 20c1.1 0 2-.9 2-2H8c0 1.1.9 2 2 2zm2-17.834A2.994 2.994 0 008 4.99c0 .808.319 1.557.876 2.114l2.97 2.99a2.99 2.99 0 004.154.072V14c0 .55.45 1 1 1s1 .45 1 1-.45 1-1 1H3c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V8c0-2.61 1.67-4.81 4-5.63V2c0-1.1.9-2 2-2s2 .9 2 2v.166zm1.26 6.514l-2.97-2.99a.973.973 0 01-.29-.7c0-.55.44-1 .99-1 .27 0 .52.11.7.29l2.28 2.28 4.27-4.27a.99.99 0 01.7-.29c.55 0 1 .45 1 1 0 .28-.11.53-.3.7l-4.98 4.98a.99.99 0 01-1.4 0z"],"numbered-list":["M1.74 9.01h1.27V1h-.95c-.04.24-.12.45-.26.62-.13.17-.29.3-.47.41-.19.11-.4.18-.63.23-.23.04-.46.07-.71.07v1.03h1.75v5.65zm.43 7.93c.18-.14.37-.28.58-.43.21-.14.42-.29.63-.45.21-.16.41-.33.61-.5.2-.18.37-.38.52-.59.15-.21.28-.45.37-.7.09-.25.14-.54.14-.85 0-.25-.04-.52-.12-.8-.08-.28-.21-.54-.39-.78-.19-.24-.43-.44-.73-.59-.3-.17-.68-.25-1.12-.25-.41 0-.77.08-1.08.23-.32.16-.58.37-.8.64-.22.27-.38.59-.49.96-.11.37-.16.77-.16 1.21h1.19c.01-.28.03-.53.08-.77s.12-.45.21-.62c.09-.18.22-.31.38-.42.16-.1.35-.15.59-.15.26 0 .47.05.63.14.16.09.29.21.38.35.09.14.15.29.18.45.03.16.05.31.05.45-.01.31-.08.58-.22.81-.14.24-.32.45-.53.66-.22.2-.45.39-.71.57-.26.18-.51.36-.74.54-.5.36-.89.78-1.17 1.27-.3.47-.45 1.04-.46 1.69H5v-1.14H1.43c.05-.17.14-.33.27-.49.13-.15.29-.3.47-.44zM18 4.02H8c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-1c0-.56-.45-1-1-1zm0 9H8c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-1c0-.56-.45-1-1-1z"],numerical:["M2.39 5.75c-.17.21-.38.39-.63.52s-.52.23-.83.29c-.3.05-.61.08-.93.08v1.24h2.49V15h1.49V4.98H2.73c-.05.31-.17.57-.34.77zm17.2 4.71c-.27-.44-.65-.71-1.14-.82v-.02c.42-.16.72-.43.92-.79.2-.36.29-.79.29-1.27 0-.42-.08-.8-.23-1.12-.15-.33-.36-.59-.62-.8-.26-.21-.55-.37-.87-.48-.32-.11-.65-.16-.98-.16-.43 0-.82.08-1.16.25-.34.16-.63.39-.87.69-.24.29-.43.64-.57 1.04-.14.4-.22.83-.23 1.3h1.39c-.01-.25.02-.49.07-.72.06-.23.14-.44.26-.63s.27-.34.45-.45c.18-.11.39-.17.63-.17.39 0 .71.12.96.37s.37.58.37.99c0 .29-.05.54-.16.74-.11.2-.25.36-.43.47-.18.11-.38.19-.61.24-.23.05-.46.06-.68.05v1.17c.28-.01.55 0 .81.03s.5.1.71.21c.21.11.38.28.51.5.13.22.2.52.2.89 0 .55-.16.97-.47 1.27-.31.3-.7.45-1.17.45-.55 0-.95-.19-1.23-.58-.27-.39-.4-.88-.38-1.46h-1.39c.01.5.08.96.21 1.38.13.41.32.77.57 1.06.25.29.56.52.93.68.37.16.8.24 1.3.24.41 0 .79-.07 1.16-.21.37-.14.69-.33.96-.58.28-.25.5-.56.66-.92a3 3 0 00.24-1.23c0-.64-.14-1.17-.41-1.61zM8.58 12.41c.21-.18.45-.36.7-.53.25-.18.5-.36.75-.56.25-.2.49-.41.73-.63.23-.22.44-.47.63-.74.18-.27.33-.56.44-.88.11-.32.16-.67.16-1.07 0-.32-.05-.65-.14-1-.09-.35-.25-.68-.47-.97-.22-.3-.51-.55-.87-.74-.36-.2-.81-.29-1.35-.29-.49 0-.93.1-1.3.29-.37.18-.69.44-.95.78-.26.33-.45.73-.58 1.2-.13.46-.2.96-.2 1.5h1.43c.01-.35.04-.67.09-.97.05-.3.14-.56.25-.78.11-.22.26-.39.45-.52s.43-.19.71-.19c.31 0 .56.06.75.18.19.12.34.26.45.43.11.17.18.36.22.56.04.2.06.39.06.57-.01.38-.1.72-.26 1.02-.15.3-.37.57-.63.83-.26.25-.54.49-.85.71-.31.22-.61.45-.89.68-.6.45-1.06.98-1.41 1.58-.35.61-.52 1.32-.53 2.13h6.01v-1.43H7.69c.06-.21.17-.42.33-.61s.34-.38.56-.55z"],office:["M19 6h-5V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h4v-6h4v6h10c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zM6 12H2V8h4v4zm0-6H2V2h4v4zm6 6H8V8h4v4zm0-6H8V2h4v4zm6 11h-4v-3h4v3zm0-5h-4V8h4v4z"],offline:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM7 18l2-7H5l8-9-2 7h4l-8 9z"],"oil-field":["M19 17.99h-1.36l-4.35-9.57 2.91-.86 1.66 4.1c.11.27.43.4.72.31.12-.04.22-.11.28-.2.06-.11 1.47-2.08 1.05-5.6C19.79 5.12 19.3 0 16.01 0 14.89.01 13.99.83 14 1.84c0 .19.04.38.1.56l1.34 3.31L.72 10.03v.02c-.41.12-.72.49-.72.94 0 .55.45 1 1 1 .1 0 .19-.03.28-.06v.02l2-.59 1.47 6.63H3c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1zM5.2 10.8l3.95-1.16-2.83 6.22L5.2 10.8zm2.35 7.19l3.95-8.68 3.95 8.68h-7.9z"],"one-column":["M14.94 0h-4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-8 6c-.28 0-.53.11-.71.29l-3 3c-.18.18-.29.43-.29.71s.11.53.29.71l3 3A1.003 1.003 0 007.94 13V7c0-.55-.45-1-1-1z"],"one-to-many":["M18 3a1 1 0 11-2 0 1 1 0 012 0zm-3.82 1.028a6.243 6.243 0 00-1.667.347c-.947.352-1.773 1-2.032 2.318C10.158 8.337 9.247 9.368 8.217 10c1.03.632 1.941 1.663 2.264 3.307.259 1.318 1.085 1.966 2.032 2.318.581.217 1.18.308 1.668.347a3.001 3.001 0 11-.019 2.004c-.633-.042-1.491-.158-2.347-.476-1.402-.523-2.868-1.625-3.296-3.807-.259-1.318-1.085-1.966-2.032-2.318a5.314 5.314 0 00-.722-.21 3 3 0 110-2.33c.238-.052.481-.12.722-.21.947-.352 1.773-1 2.032-2.318.428-2.182 1.894-3.284 3.296-3.807.856-.318 1.714-.434 2.347-.476A3.001 3.001 0 0120 3a3 3 0 01-5.82 1.028zM4 10a1 1 0 100 .002v-.002zM17 18a1 1 0 100-2 1 1 0 000 2z"],"one-to-one":["M2 10a1 1 0 112 0 1 1 0 01-2 0zm3.83-1a3.001 3.001 0 100 2h8.34a3.001 3.001 0 100-2H5.83zM17 9a1 1 0 100 2 1 1 0 000-2z"],outdated:["M10 0c5.52 0 10 4.48 10 10s-4.48 10-10 10S0 15.52 0 10c0-.55.45-1 1-1s1 .45 1 1c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8C7.47 2 5.22 3.17 3.76 5H5c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1s1 .45 1 1v2.05C3.82 1.6 6.71 0 10 0zm1 16H9v-2h2v2zm0-3H9V4h2v9z"],"page-layout":["M19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM7 17H2V8h5v9zm11 0H8V8h10v9zm0-10H2V3h16v4z"],"panel-stats":["M1 1h18a1 1 0 011 1v15a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1zm1 2v13h16V3H2zm9 0h1v13h-1V3zm2 7h3.952v1H13v-1zm0 2h3.952v1H13v-1zm0 2h3.952v1H13v-1zm0-6h3.952v1H13V8zm0-2h3.952v1H13V6zm0-2h3.952v1H13V4z"],"panel-table":["M19 1H1c-.6 0-1 .4-1 1v15c0 .6.4 1 1 1h18c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zm-9 11H7V9h3v3zm0-4H7V5h3v3zm-8 8V3h4v13H2zm5 0v-3h3v3H7zm11 0h-7v-3h7v3zm0-4h-7V9h7v3zm0-4h-7V5h7v3z"],paperclip:["M18.35 2.67A5.664 5.664 0 0014.33 1c-1.44 0-2.89.56-3.99 1.67l-9.16 9.27C.4 12.73 0 13.78 0 14.83s.39 2.1 1.18 2.9c.78.79 1.82 1.18 2.85 1.18 1.04 0 2.07-.39 2.87-1.2l9.14-9.27c.96-.96.96-2.5.02-3.45-.94-.95-2.49-.96-3.44 0l-7.59 7.69c-.31.32-.3.83.01 1.14.31.31.81.31 1.13.02l7.59-7.69c.31-.31.84-.31 1.13-.02.31.31.31.85 0 1.16l-9.14 9.27c-.93.95-2.54.93-3.45.02-.94-.95-.92-2.55.02-3.49l9.16-9.25c1.55-1.56 4.18-1.59 5.72-.03 1.56 1.57 1.55 4.26 0 5.82l-8.89 9.02c-.3.31-.3.81.01 1.11.3.3.79.31 1.1.01v.01l8.91-9.02A5.645 5.645 0 0020 6.73c0-1.48-.55-2.94-1.65-4.06z"],paragraph:["M16.5 1H7C4.2 1 2 3.2 2 6s2.2 5 5 5v6.5c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V4h2v13.5c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V4h1.5c.8 0 1.5-.7 1.5-1.5S17.3 1 16.5 1z"],path:["M18 0H2C.9 0 0 .9 0 2s.9 2 2 2h7v4H4c-1.1 0-2 .9-2 2s.9 2 2 2h5v4H6c-1.1 0-2 .9-2 2s.9 2 2 2h8c1.1 0 2-.9 2-2s-.9-2-2-2h-3v-4h5c1.1 0 2-.9 2-2s-.9-2-2-2h-5V4h7c1.1 0 2-.9 2-2s-.9-2-2-2z"],"path-search":["M4 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 11.69l-5-2.5v-3.63c-.32.11-.66.22-1 .29v3.32l-6 2.57v-7.25c-.36-.27-.69-.57-1-.9v8.1l-5-2.5V10c.55 0 1-.45 1-1s-.45-1-1-1V1.31l3.43 1.71c.11-.31.24-.62.39-.92L.72.05A.545.545 0 00.5 0C.22 0 0 .22 0 .5v16c0 .2.12.36.28.44l6 3c.07.04.14.06.22.06.07 0 .14-.01.2-.04l6.79-2.91 5.79 2.9c.07.03.14.05.22.05.28 0 .5-.22.5-.5v-4.21c-.31.13-.64.21-1 .21v3.19zM10 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3-1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6.72-.94l-1.43-.72c.2.43.36.89.48 1.36l.23.11V5.5c-.55 0-1 .45-1 1s.45 1 1 1v1.96l1 1V3.5c0-.2-.12-.36-.28-.44zm-3.69 5.56c.14-.21.27-.42.38-.65.02-.04.04-.07.05-.11.11-.22.2-.45.28-.69v-.01c.07-.24.13-.48.17-.73l.03-.17c.04-.25.06-.5.06-.76C17 2.46 14.54 0 11.5 0S6 2.46 6 5.5 8.46 11 11.5 11c.26 0 .51-.02.76-.06l.17-.03c.25-.04.49-.1.73-.17h.01c.24-.08.47-.17.69-.28.04-.02.07-.03.11-.05.23-.11.44-.24.65-.38l.18.18 3.5 3.5c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71l-3.68-3.67zm-4.53.88c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],pause:["M7 3H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm9 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],people:["M16.94 17a4.92 4.92 0 00-.33-1.06c-.45-.97-1.37-1.52-3.24-2.3-.17-.07-.76-.31-.77-.32-.1-.04-.2-.08-.28-.12.05-.14.04-.29.06-.45 0-.05.01-.11.01-.16-.25-.21-.47-.48-.65-.79.22-.34.41-.71.56-1.12l.04-.11c-.01.02-.01.02-.02.08l.06-.15c.36-.26.6-.67.72-1.13.18-.37.29-.82.25-1.3-.05-.5-.21-.92-.47-1.22-.02-.53-.06-1.11-.12-1.59.38-.17.83-.26 1.24-.26.59 0 1.26.19 1.73.55.46.35.8.85.97 1.4.04.13.07.25.08.38.08.45.13 1.14.13 1.61v.07c.16.07.31.24.35.62.02.29-.09.55-.15.65-.05.26-.2.53-.46.59-.03.12-.07.25-.11.36-.01.01-.01.04-.01.04-.2.53-.51 1-.89 1.34 0 .06 0 .12.01.17.04.41-.11.71 1 1.19 1.1.5 2.77 1.01 3.13 1.79.34.79.2 1.25.2 1.25h-3.04zm-5.42-3.06c1.47.66 3.7 1.35 4.18 2.39.45 1.05.27 1.67.27 1.67H.04s-.19-.62.27-1.67c.46-1.05 2.68-1.75 4.16-2.4 1.48-.65 1.33-1.05 1.38-1.59 0-.07.01-.14.01-.21-.52-.45-.95-1.08-1.22-1.8l-.01-.01c0-.01-.01-.02-.01-.03-.07-.15-.12-.32-.16-.49-.34-.06-.54-.43-.62-.78-.08-.14-.24-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.64.05-1.55.17-2.15a3.648 3.648 0 011.4-2.36C6.32 2.25 7.21 2 8 2s1.68.25 2.31.73a3.63 3.63 0 011.4 2.36c.11.6.17 1.52.17 2.15v.09c.22.09.42.32.47.82.03.39-.12.73-.2.87-.07.34-.27.71-.61.78-.04.16-.09.33-.15.48-.01.01-.02.05-.02.05-.27.71-.68 1.33-1.19 1.78 0 .08 0 .16.01.23.05.55-.15.95 1.33 1.6z"],percentage:["M15 10c-1.66 0-3 1.34-3 3v2c0 1.66 1.34 3 3 3s3-1.34 3-3v-2c0-1.66-1.34-3-3-3zm1 5c0 .55-.45 1-1 1s-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2zM8 7V5c0-1.66-1.34-3-3-3S2 3.34 2 5v2c0 1.66 1.34 3 3 3s3-1.34 3-3zM4 7V5c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1zm11-4a1.003 1.003 0 00-1.88-.48L5.14 16.49a1.003 1.003 0 101.74.99l7.99-13.97c.08-.15.13-.32.13-.51z"],person:["M19.61 17.91c-.57-1.32-3.35-2.19-5.19-3.01-1.85-.82-1.59-1.31-1.66-1.99-.01-.09-.01-.19-.02-.29.63-.56 1.15-1.33 1.49-2.22 0 0 .02-.05.02-.06.07-.19.13-.39.19-.6.42-.09.67-.55.76-.98.1-.17.29-.6.25-1.08-.06-.62-.31-.91-.59-1.03v-.11c0-.79-.07-1.93-.22-2.68A4.55 4.55 0 0012.9.92C12.11.32 11 0 10.01 0s-2.1.32-2.89.92a4.55 4.55 0 00-1.74 2.94c-.14.75-.22 1.89-.22 2.68v.1c-.29.11-.55.4-.61 1.04-.04.48.15.91.25 1.08.1.44.35.91.79.98.05.21.12.41.19.6 0 .01.01.03.01.04l.01.02c.34.91.87 1.69 1.52 2.25 0 .09-.01.18-.02.26-.07.68.13 1.17-1.72 1.99S.96 16.59.39 17.91C-.18 19.23.05 20 .05 20h19.9s.23-.77-.34-2.09z"],phone:["M19.91 15.51c-.08-.08-4.21-2.5-4.35-2.57a.876.876 0 00-.4-.1c-.19 0-.42.13-.71.4-.28.27-1.17 1.49-1.43 1.76s-.48.4-.65.4c-.08 0-.19-.02-.32-.07s-1.45-.73-4.2-3.15-3.11-4-3.13-4.44c0-.17.13-.39.4-.65.28-.25.57-.51.89-.74.32-.24.61-.5.88-.78s.4-.52.4-.71c0-.13-.03-.27-.1-.4C7.12 4.32 4.62.19 4.53.1c-.19-.18-.92-.1-1.29.1C.25 1.82 0 4 .05 4.86c.05.89.61 5.58 5.2 9.93 5.7 5.41 9.66 5.2 9.92 5.2.87 0 3.52-.48 4.65-3.19.16-.38.31-1.07.09-1.29z"],"pie-chart":["M9 .98c-4.5.5-8 4.31-8 8.94 0 4.97 4.03 9.04 9 9.04 4.63 0 8.44-3.96 8.94-7.96H9V.98z","M10-.08V10h10C20 4 15.52-.08 10-.08z"],pin:["M11.77 1.16c-.81.81-.74 2.28.02 3.76L6.1 8.71c-2.17-1.46-4.12-2-4.94-1.18l4.95 4.95-4.95 6.36 6.36-4.95 4.95 4.95c.82-.82.27-2.77-1.19-4.94l3.8-5.69c1.47.76 2.94.84 3.76.02l-7.07-7.07z"],pivot:["M5.83 9.75L.29 15.29a1.003 1.003 0 001.42 1.42l5.54-5.54c-.57-.37-1.05-.85-1.42-1.42zM19 11c-.55 0-1 .45-1 1v1.59l-3.83-3.83c-.37.56-.85 1.04-1.41 1.41L16.59 15H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm-5-4c0-2.21-1.79-4-4-4S6 4.79 6 7s1.79 4 4 4 4-1.79 4-4zm-4 2c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"pivot-table":["M3 5H1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm0-5H1C.45 0 0 .45 0 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm13.71 5.29C16.53 5.11 16.28 5 16 5s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L15 8.41V11c0 2.21-1.79 4-4 4H8.41l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L8.41 17H11c3.31 0 6-2.69 6-6V8.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM19 0H6c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],play:["M16 10c0-.36-.2-.67-.49-.84l.01-.01-10-6-.01.01A.991.991 0 005 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .19 0 .36-.07.51-.16l.01.01 10-6-.01-.01c.29-.17.49-.48.49-.84z"],plus:["M16 9h-5V4c0-.55-.45-1-1-1s-1 .45-1 1v5H4c-.55 0-1 .45-1 1s.45 1 1 1h5v5c0 .55.45 1 1 1s1-.45 1-1v-5h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"polygon-filter":["M18 7c-.27 0-.52.05-.75.15l-6.28-4.88c.01-.09.03-.18.03-.27 0-1.1-.9-2-2-2S7 .9 7 2c0 .06.01.12.02.19l-4.19 3C2.57 5.07 2.29 5 2 5 .9 5 0 5.9 0 7c0 .74.4 1.38 1 1.72v7.55c-.6.35-1 .99-1 1.73 0 1.1.9 2 2 2 .74 0 1.38-.4 1.72-1h7.55c.35.6.98 1 1.72 1 1.1 0 2-.9 2-2 0-.37-.11-.72-.29-1.02L18.03 11A2 2 0 0018 7zm-5.03 9c-.72.01-1.35.41-1.69 1H3.72c-.17-.3-.42-.55-.72-.72V8.72c.6-.34 1-.98 1-1.72 0-.06-.01-.12-.02-.19l4.19-3c.26.12.54.19.83.19.27 0 .52-.05.75-.15l6.28 4.88c-.01.09-.03.18-.03.27 0 .37.11.72.29 1.02L12.97 16z"],power:["M10 10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S9 .45 9 1v8c0 .55.45 1 1 1zm3-7.45v2.16c2.36 1.12 4 3.5 4 6.29 0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.79 1.64-5.17 4-6.29V2.55C3.51 3.79 1 7.09 1 11a9 9 0 0018 0c0-3.91-2.51-7.21-6-8.45z"],"predictive-analysis":["M20 8.01c0-1.26-.61-2.43-1.61-3.12C17.86 2.5 15.8.79 13.4.79c-.58 0-1.14.1-1.69.29A3.533 3.533 0 009.17 0C8.05 0 7 .55 6.32 1.45c-.15-.02-.3-.03-.45-.03-1.63 0-3.03 1.12-3.46 2.71C.97 4.65 0 6.05 0 7.66c0 .48.09.95.26 1.4-.17.44-.26.91-.26 1.39 0 1.38.72 2.64 1.89 3.29.67.7 1.59 1.09 2.54 1.09.61 0 1.19-.15 1.71-.45.68.82 1.68 1.3 2.73 1.3.66 0 1.28-.18 1.83-.52.61.49 1.34.81 2.11.91 1.3 1.43 2.3 3.28 2.31 3.3 0 0 .35.61.33.61.96-.01 1.77-.2 1.64-1.3.01.02-.92-2.89-.92-2.89.52-.26.94-.69 1.21-1.23 1.12-.66 1.84-1.91 1.84-3.26 0-.3-.03-.6-.1-.89.57-.64.88-1.51.88-2.4zm-1.54 1.28l-.18-.2-.77-.84c-.33-.37-.67-1.17-.73-1.73 0 0-.13-1.25-.13-1.26-.06-.74-1.17-.73-1.13.14 0 .02.13 1.26.13 1.26.04.36.15.77.3 1.17-.08-.01-.15-.02-.22-.02 0 0-2.57-.12-2.57-.13-.73-.03-.89 1.22-.05 1.25l2.57.13c.53.03 1.29.37 1.61.72l.61.67.02.06c.1.27.14.55.14.83 0 .93-.51 1.77-1.34 2.18l-.2.1-.09.23c-.19.48-.6.82-1.1.93l-.67.14.87 2.75c-.48-.76-1.19-1.79-2.02-2.67l-.15-.16-.21-.02c-.51-.04-.99-.21-1.42-.48l1.7-1.48c.44-.39 1.04-.55 1.24-.49 0 0 .78.22.78.23.78.2 1.03-.92.29-1.21l-.78-.23c-.69-.2-1.67.22-2.24.72l-1.91 1.66-.39.32c-.44.36-.93.55-1.5.55-.8 0-1.54-.41-1.97-1.07v-1.88c0-.5.21-.98.34-1.07 0 0 .65-.43.64-.43.87-.69.21-1.57-.64-1.14 0-.01-.65.43-.65.43-.31.2-.54.56-.7.97-.13-.13-.28-.25-.43-.35 0 0-1.91-1.26-1.91-1.28-.81-.56-1.5.63-.61 1.11 0-.02 1.89 1.28 1.89 1.28.46.31.77.97.77 1.36v.84c-.43.24-.78.36-1.24.36-.67 0-1.31-.29-1.77-.79l-.07-.08-.09-.05a2.425 2.425 0 01-1.31-2.16c0-.38.09-.74.25-1.08l.15-.31-.14-.33c-.17-.34-.25-.7-.25-1.08 0-1.13.76-2.1 1.85-2.37l.39-.09.07-.43a2.41 2.41 0 012.39-2.05c.19 0 .39.02.58.07l.4.1.22-.38A2.41 2.41 0 019.17 1.3c.55 0 1.08.19 1.5.53l-.44.45-.01-.01-.31.31c-.41.35-.92.53-1.11.5 0 0-.84-.13-.84-.14-.83-.15-1.09 1.08-.18 1.29.01 0 .84.14.84.14.03 0 .06 0 .09.01-.14.46-.18.96-.12 1.4 0 0 .21 1.24.19 1.23.13.65 1.32.44 1.16-.22 0-.01-.19-1.23-.19-1.23-.07-.48.15-1.19.45-1.5l.48-.5c.07-.06.13-.12.19-.18l.93-.95c.5-.23 1.04-.34 1.59-.34 1.93 0 3.57 1.4 3.89 3.34l.05.31.26.15a2.445 2.445 0 01.87 3.4z"],prescription:["M13.95 10.23c.16-.18.22-.22.46-.22h1.48c.25 0 .47.08.59.33.1.2.09.41-.05.66l-2.71 3.58L16.88 19c.13.21.16.46.03.69-.12.21-.34.31-.57.31H14.7c-.31 0-.56-.17-.7-.44l-1.9-2.67-1.93 2.68c-.15.27-.42.43-.73.43H7.98c-.25 0-.47-.08-.59-.33-.1-.2-.09-.41.05-.66l3.09-4.35L6.26 9H5v4.32c0 .41-.3.69-.7.69H2.7c-.41 0-.7-.28-.7-.69V.69c0-.41.3-.69.7-.69h4.42c.71 0 1.36.1 1.94.3.59.2 1.11.49 1.54.87.44.38.78.84 1.02 1.39.24.54.36 1.14.36 1.78 0 1.01-.28 1.88-.84 2.6-.43.54-1.35 1.29-2 1.59l3.09 3.94 1.72-2.24zM6.71 6.04c.71 0 1.45-.16 1.81-.46.33-.28.5-.69.5-1.25s-.17-.97-.5-1.25c-.35-.3-1.1-.46-1.81-.46h-1.7v3.42h1.7z"],presentation:["M19 1h-8c0-.55-.45-1-1-1S9 .45 9 1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v11c0 .55.45 1 1 1h4.59L4.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L9 16.41V19c0 .55.45 1 1 1s1-.45 1-1v-2.59l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L12.41 15H17c.55 0 1-.45 1-1V3h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3 12H4V3h12v10z"],print:["M14 16H6v-4H4v5c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-5h-2v4zm2-13c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h12V3zm3 2H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h2v-3h14v3h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 4h-2V7h2v2z"],projects:["M18 4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h16V4zm-2-3c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h12V1zm3 6H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-5 7c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-2h1v2h6v-2h1v2z"],properties:["M2 15c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm5-4h12c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zM2 1C.9 1 0 1.9 0 3s.9 2 2 2 2-.9 2-2-.9-2-2-2zm17 8H7c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0 7H7c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],property:["M3 5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm5-1h11c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM3 15c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm16 1H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm-1-8H9c-1.1 0-2 .9-2 2s.9 2 2 2h9c1.1 0 2-.9 2-2s-.9-2-2-2zM3 7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"publish-function":["M7.01 10.11c.35-.64.72-1.68 1.09-3.11l.8-3.03h.96l.24-.77h-.99c.28-1.11.66-1.92 1.12-2.43.28-.32.56-.48.83-.48.05 0 .1.02.13.05.03.03.05.07.05.12 0 .04-.04.13-.11.25-.08.12-.11.24-.11.35 0 .15.06.28.18.39.12.11.27.16.45.16.2 0 .36-.07.49-.2s.2-.31.2-.54c0-.26-.1-.47-.3-.63-.2-.16-.52-.24-.96-.24-.68 0-1.3.19-1.86.58-.55.38-1.08 1.02-1.58 1.91-.17.3-.34.5-.49.59-.15.08-.4.13-.74.12l-.23.77h.95L5.74 9.21c-.23.86-.39 1.39-.47 1.59-.12.29-.3.54-.54.75-.1.08-.21.12-.35.12-.04 0-.07-.01-.1-.03l-.03-.04c0-.02.03-.07.1-.13.07-.07.1-.17.1-.31 0-.15-.05-.28-.16-.38-.11-.1-.27-.15-.47-.15-.25 0-.44.07-.59.2-.15.12-.23.28-.23.46 0 .19.09.36.27.5.19.14.47.21.86.21.61 0 1.16-.15 1.63-.46.48-.31.89-.79 1.25-1.43zm3.7 1.18c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 14.41V19c0 .55.45 1 1 1s1-.45 1-1v-4.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zm4.15-6.78c.17-.13.36-.2.55-.2.07 0 .2.03.39.08s.36.08.5.08c.2 0 .37-.07.5-.2.13-.14.2-.31.2-.52 0-.22-.07-.4-.2-.53s-.33-.2-.58-.2c-.22 0-.43.05-.63.15-.2.1-.45.32-.75.67-.23.25-.56.7-1.01 1.33a6.52 6.52 0 00-.91-2.15l-2.38.39-.05.25c.18-.03.33-.05.45-.05.24 0 .43.1.59.3.25.31.59 1.24 1.02 2.79-.34.44-.58.73-.7.87-.21.22-.38.36-.52.43-.1.05-.22.08-.35.08-.1 0-.26-.05-.49-.16a1.01 1.01 0 00-.42-.11c-.23 0-.42.07-.57.22-.17.14-.24.32-.24.55 0 .21.07.38.21.51.14.13.33.2.56.2.23 0 .44-.05.64-.14.2-.09.45-.29.75-.59s.72-.78 1.25-1.43c.2.62.38 1.07.53 1.35.15.28.32.49.52.61.19.12.44.19.73.19.28 0 .57-.1.86-.3.38-.25.77-.69 1.17-1.31l-.25-.14c-.27.37-.48.6-.61.69-.09.06-.19.09-.31.09-.14 0-.28-.09-.42-.26-.23-.29-.54-1.09-.93-2.4.37-.58.66-.96.9-1.14z"],pulse:["M19 10h-2.38L14.9 6.55h-.01c-.17-.32-.5-.55-.89-.55-.43 0-.79.28-.93.66h-.01l-2.75 7.57L7.98 1.82h-.02A.978.978 0 007 1c-.44 0-.8.29-.94.69h-.01L3.28 10H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.44 0 .8-.29.94-.69h.01l1.78-5.34 2.29 12.21h.02c.08.46.47.82.96.82.43 0 .79-.28.93-.66h.01l3.21-8.82.96 1.92h.01c.16.33.49.56.88.56h3c.55 0 1-.45 1-1s-.45-1-1-1z"],rain:["M4 10a3 3 0 111.065-5.806A5.001 5.001 0 0114.63 3.11 3.5 3.5 0 1115.5 10H4zm0 2a1 1 0 011 1v5a1 1 0 11-2 0v-5a1 1 0 011-1zm9 1a1 1 0 10-2 0v6a1 1 0 102 0v-6zm3-1a1 1 0 011 1v3a1 1 0 11-2 0v-3a1 1 0 011-1zm-7 1a1 1 0 10-2 0v3a1 1 0 102 0v-3z"],random:["M14.47 5h2.12L15.3 6.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 3H14c-.31 0-.57.15-.76.37l-.01-.01-2.93 3.52 1.3 1.56L14.47 5zm2.24 7.29a1.003 1.003 0 00-1.42 1.42l1.3 1.29h-2.12L4.77 3.36l-.01.01A.998.998 0 004 3H1c-.55 0-1 .45-1 1s.45 1 1 1h2.53l9.7 11.64.01-.01c.19.22.45.37.76.37h2.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM3.53 15H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.31 0 .57-.15.76-.37l.01.01 2.93-3.52-1.3-1.56L3.53 15z"],record:["M10 3a7 7 0 100 14 7 7 0 100-14z"],rectangle:["M1 4h18c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1zm1 2v8h16V6H2z"],redo:["M19.71 5.29l-4-4a1.003 1.003 0 00-1.42 1.42L16.59 5H6c-3.31 0-6 2.69-6 6s2.69 6 6 6h5v-2H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h10.59L14.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM15 14c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],refresh:["M19 1c-.55 0-1 .45-1 1v2.06C16.18 1.61 13.29 0 10 0 4.48 0 0 4.48 0 10c0 .55.45 1 1 1s1-.45 1-1c0-4.42 3.58-8 8-8 2.52 0 4.76 1.18 6.22 3H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 8c-.55 0-1 .45-1 1 0 4.42-3.58 8-8 8-2.52 0-4.76-1.18-6.22-3H5c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-2.06C3.82 18.39 6.71 20 10 20c5.52 0 10-4.48 10-10 0-.55-.45-1-1-1z"],"regression-chart":["M19 16H3.1L19.31 3.39l-.61-.79L2 15.59V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-9-9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-5 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm10-2c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2zm-5 4c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2z"],remove:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm5-9H5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"remove-column":["M19 0H5c-.55 0-1 .45-1 1v4h2V2h5v16H6v-3H4v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18h-5V2h5v16zM6.29 13.71a1.003 1.003 0 001.42-1.42L5.41 10 7.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L4 8.59l-2.29-2.3A1.003 1.003 0 00.29 7.71L2.59 10 .3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L4 11.41l2.29 2.3z"],"remove-column-left":["M4 11h6c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-7 18H2V2h10v16zm6 0h-5V2h5v16z"],"remove-column-right":["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H2V2h5v16zm11 0H8V2h10v16zm-8-7h6c.55 0 1-.45 1-1s-.45-1-1-1h-6c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-bottom":["M7 14h6c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V8h16v10zm0-11H2V2h16v5z"],"remove-row-top":["M7 8h6c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zm12-8H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2v-5h16v5zm0-6H2V2h16v10z"],repeat:["M14 6c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1v2.05C16.18 1.6 13.29 0 10 0 4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-.55-.45-1-1-1s-1 .45-1 1c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8c2.53 0 4.77 1.17 6.24 3H15c-.55 0-1 .45-1 1z"],reset:["M6 6c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1s1 .45 1 1v2.05C3.82 1.6 6.71 0 10 0c5.52 0 10 4.48 10 10s-4.48 10-10 10S0 15.52 0 10c0-.55.45-1 1-1s1 .45 1 1c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8C7.47 2 5.23 3.17 3.76 5H5c.55 0 1 .45 1 1z"],resolve:["M8.7 4.7C7.9 4.2 7 4 6 4c-3.3 0-6 2.7-6 6s2.7 6 6 6c1 0 1.9-.2 2.7-.7C7.3 14 6.5 12.1 6.5 10s.9-4 2.2-5.3zM14 4c-1 0-1.9.2-2.7.7 1.4 1.4 2.2 3.2 2.2 5.3s-.9 4-2.2 5.3c.8.5 1.7.7 2.7.7 3.3 0 6-2.7 6-6s-2.7-6-6-6zm-4 1.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],rig:["M7 4.2C7 5.75 8.34 7 10 7s3-1.46 3-2.8C13 1.45 10.94 0 10 0H6c0 2.74 3.76 1.96 1 4.2zm11.71 14.09L13 12.59V9.01c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3.58l-5.71 5.7a1.003 1.003 0 001.42 1.42L7 15.42V19c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3.58l4.29 4.29a1.003 1.003 0 001.42-1.42zM10.21 8c.01 0 .01.01 0 0 .01.01.01 0 0 0z"],"right-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zm-3.34 9.25c-.55-1.2-.86-2.54-.86-3.95s.31-2.75.86-3.95a4.001 4.001 0 000 7.9zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm-4 1.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],ring:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],rocket:["M7 7.5c0-3 1.857-6.25 3-7.5 1.143 1.25 3 4.5 3 7.5s-.714 6.25-1 7.5H8c-.286-1.25-1-4.5-1-7.5zm6.84 2.5c-.139 1.62-.47 3.405-.84 5.01l4 .99-1-4-2.16-2zm-4.832 6C9 16.139 9 16.284 9 16.429 9 17.143 9 17.5 10 20c1-2.5 1-2.857 1-3.571 0-.145 0-.29-.008-.429H9.008zM7 15.011c-.37-1.605-.701-3.39-.84-5.011L4 12l-1 4 4-.989zM10 5a1 1 0 100 2 1 1 0 000-2z"],"rocket-slant":["M10 5c2.121-2.121 6.308-2.924 8-3-.076 1.692-.879 5.879-3 8-1.192 1.192-2.543 1.823-3.748 2.384-.442.207-.865.404-1.252.616-.203.111-.597.302-.986.49-.444.215-.88.426-1.014.51l-2-2c.158-.252 1-2 1-2s1.37-3.37 3-5zm5 1a1 1 0 11-2 0 1 1 0 012 0zM3 17s0-2 2-4l2 2c-2 2-4 2-4 2zm11-2l-4 4-1.298-4.233c1.033-.56 1.881-.962 2.643-1.322 1.275-.604 2.307-1.092 3.554-2.015L14 15zM1 10l4-4 3.557-.899c-.923 1.247-1.412 2.28-2.015 3.554-.36.762-.762 1.61-1.322 2.643L1 10z"],"rotate-document":["M8.71 6.29A.997.997 0 008 6H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-8c0-.28-.11-.53-.29-.71l-4-4zM11 18H4V8h3v3c0 .55.45 1 1 1h3v6zm3-16h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C9.11 2.47 9 2.72 9 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4z"],"rotate-page":["M14 2h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C9.11 2.47 9 2.72 9 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4zm-2 5H3c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 11H4V9h7v9z"],route:["M14.028 6.016c.146.275.31.57.485.872.304.524.628 1.047.952 1.545l.118.178-.208-.006-.577-.005c-2.093.004-2.841.303-2.841.895 0 .069.271.248 1.245.567l1.008.313c2.671.831 3.99 1.827 3.99 4.167 0 2.76-1.928 4.059-4.832 4.376-.782.085-1.52.098-2.452.066l-1.15-.046H6.221l.535-.811a67.46 67.46 0 001.122-1.787h2.04l.686.03c1.028.046 1.77.043 2.523-.039 1.832-.2 2.673-.767 2.673-1.789 0-.69-.483-1.09-1.992-1.585l-.83-.257c-1.192-.364-2.037-.7-2.59-1.165.399-1 .612-1.844.612-2.538a6.018 6.018 0 00-.382-2.098c.745-.573 1.884-.822 3.41-.883zM5 4.2c2.648 0 4.791 2.151 4.8 4.797C9.8 11.652 5 18.6 5 18.6l-.5-.744C3.273 15.993.2 11.121.2 8.997A4.802 4.802 0 015 4.2zm0 2.4a2.4 2.4 0 10.002 4.802A2.4 2.4 0 005 6.6zM17 .333a2.671 2.671 0 012.667 2.665C19.667 4.473 17 8.333 17 8.333l-.391-.587c-.741-1.137-2.276-3.629-2.276-4.748A2.668 2.668 0 0117 .333z"],satellite:["M9 18c.6 0 1 .4 1 1s-.4 1-1 1c-5 0-9-4-9-9 0-.6.4-1 1-1s1 .4 1 1c0 3.9 3.1 7 7 7zm0-4c.6 0 1 .4 1 1s-.4 1-1 1c-2.8 0-5-2.2-5-5 0-.6.4-1 1-1s1 .4 1 1c0 1.7 1.3 3 3 3zm5.7-3.7c.4-.4 1-.4 1.4 0l3.6 3.6c.4.4.4 1 0 1.4l-1.4 1.4c-.4.4-1 .4-1.4 0l-3.6-3.6c-.4-.4-.4-1 0-1.4l1.4-1.4zM4.7.3c.4-.4 1-.4 1.4 0l3.6 3.6c.4.4.4 1 0 1.4L8.3 6.7c-.4.4-1 .4-1.4 0L3.3 3.1c-.4-.4-.4-1 0-1.4L4.7.3zm11.1 1c.4-.4 1-.4 1.4 0l1.6 1.6c.4.4.4 1 0 1.4l-6.5 6.5c-.4.4-1 .4-1.4 0L9.3 9.2c-.4-.4-.4-1 0-1.4l6.5-6.5zM9 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z"],saved:["M12 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V6l-6-6zm4 18H5V2h6v5h5v11zm-8.29-6.71a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.32 0 .59-.16.77-.38l.01.01 4-5-.01-.01c.14-.18.23-.38.23-.62 0-.55-.45-1-1-1-.32 0-.59.16-.77.38l-.01-.01-3.3 4.13-2.21-2.21z"],"scatter-plot":["M9 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm5 2c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm1 10H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM5 15c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"],search:["M19.56 17.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"search-around":["M9.9 6.9a3 3 0 100 6 3 3 0 100-6zM3 14c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM17 14c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM17 0c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM10 10L5 5","M5.379 4.671l5.02 5.02-.707.708-5.02-5.02zM10 10l5-5","M14.621 4.671l.707.708-5.02 5.02-.707-.707z","M10 10l5 5M10.379 9.671l5.02 5.02-.707.708-5.02-5.02z","M10 10l-5 5M9.621 9.671l.707.708-5.02 5.02-.707-.707z"],"search-template":["M13 8H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0 3H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0-6H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm6.56 12.44l-3.23-3.23A8.939 8.939 0 0018 9a9 9 0 10-9 9c1.94 0 3.74-.62 5.21-1.67l3.23 3.23a1.498 1.498 0 102.12-2.12zM9 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"],"search-text":["M19.56 17.44l-3.23-3.23A8.939 8.939 0 0018 9a9 9 0 10-9 9c1.94 0 3.74-.62 5.21-1.67l3.23 3.23a1.498 1.498 0 102.12-2.12zM9 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm3.5-11h-7c-.28 0-.5.22-.5.5v2c0 .28.22.5.5.5s.5-.22.5-.5V7h2v6h-.5c-.28 0-.5.22-.5.5s.22.5.5.5h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H10V7h2v.5c0 .28.22.5.5.5s.5-.22.5-.5v-2c0-.28-.22-.5-.5-.5z"],"segmented-control":["M19 5H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 8h-8V7h8v6z"],select:["M19.71 18.29l-4.25-4.25L20 12.91 9.93 9.33c.04-.1.07-.21.07-.33V3c0-.55-.45-1-1-1H4V1c0-.55-.45-1-1-1S2 .45 2 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 .55.45 1 1 1h6c.12 0 .23-.03.34-.07L12.91 20l1.14-4.54 4.25 4.25c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71zM8 8H4V4h4v4z"],selection:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z","M10 6a4 4 0 100 8 4 4 0 100-8z"],"send-message":["M1.754.135L19.393 9.06c.57.288.775.943.458 1.462-.107.176-.266.32-.458.418l-17.64 8.925c-.57.288-1.288.1-1.604-.418C.05 19.287 0 19.183 0 19v-7l11-2L0 8V1.075C0 .481.529 0 1.18 0c.201 0 .399.047.574.135z"],"send-to":["M19 0h-5c-.6 0-1 .4-1 1s.4 1 1 1h2.6l-4.3 4.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3L18 3.4V6c0 .5.5 1 1 1s1-.5 1-1V1c0-.6-.5-1-1-1zm0 9c-1 0-1.9-.5-2.5-1.3l-1.4 1.4c-.5.6-1.3.9-2.1.9-1.7 0-3-1.3-3-3 0-.8.3-1.6.9-2.1l1.4-1.4C11.5 2.9 11 2 11 1c0-.3.1-.6.2-.9-.4-.1-.8-.1-1.2-.1C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10c0-.4 0-.8-.1-1.2-.3.1-.6.2-.9.2z"],"send-to-graph":["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm10 2c-.53 0-1.01.21-1.37.55L11.9 10.6c.06-.19.1-.39.1-.6 0-.21-.04-.41-.1-.6l4.72-2.95c.37.34.85.55 1.38.55 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .21.04.41.1.6l-4.73 2.96c-.24-.23-.54-.4-.87-.48V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.33.09-.63.26-.87.48L7.6 7.91 5.42 6.55 3.9 5.6c.06-.19.1-.39.1-.6 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.53 0 1.01-.21 1.37-.55L9 9.96V10h.06L12 11.84l.4.25 1.51.94 2.19 1.37c-.06.19-.1.39-.1.6 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zm-7-2.96l-.06-.04H11v.04z"],"send-to-map":["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm11.54-6.82l.01-.02-6-4-.01.02C13.39.08 13.21 0 13 0s-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v9c0-.55.45-1 1-1h1V2.87l4 2.67V9h2V5.54l4-2.67v11.6l-1 .67v2.4l2-1.33 5.45 3.63.01-.02c.15.1.33.18.54.18.55 0 1-.45 1-1V5c0-.35-.19-.64-.46-.82zM18 17.13l-4-2.67V2.87l4 2.67v11.59z"],"series-add":["M13.29 9.29c.3.62.8 1.12 1.42 1.42l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 2.29-2.3zM12 5c0-.5.4-1 1-1h2V2c0-.6.4-1 1-1 .5 0 1 .4 1 1v2h2c.5 0 1 .4 1 1s-.5 1-1 1h-2v2c0 .6-.5 1-1 1-.6 0-1-.4-1-1V6h-2c-.6 0-1-.4-1-1z"],"series-configuration":["M11.91 10.67c.52.45 1.13.8 1.8 1.03l-2.01 2.01c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.3L7 10.41l-5 5V17h16.99c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8c.28 0 .53.11.71.29l3.29 3.3.91-.92zM18.5 4.6h1.04c.25 0 .45.2.46.44v.9c0 .25-.2.45-.45.45h-1.04c-.07.22-.16.42-.27.62l.73.73c.17.17.17.44 0 .61l-.61.61c-.17.17-.44.17-.61 0l-.73-.73c-.2.11-.4.2-.62.26v1.05c0 .25-.2.45-.45.45h-.9c-.25 0-.45-.2-.45-.45V8.51c-.21-.06-.4-.15-.58-.25l-.76.77c-.17.17-.46.17-.64 0l-.64-.64a.465.465 0 010-.64l.76-.77c-.1-.19-.19-.38-.25-.59h-1.04c-.25 0-.45-.2-.45-.45v-.9c0-.25.2-.45.45-.45h1.04c.07-.22.16-.42.27-.61l-.73-.73a.429.429 0 010-.61l.61-.61c.17-.17.44-.17.61 0l.73.73c.2-.11.4-.2.62-.26V1.45a.44.44 0 01.44-.45h.9c.25 0 .45.2.45.45V2.5c.21.06.4.15.58.25l.76-.77c.17-.17.46-.17.64 0l.64.64c.17.17.17.46 0 .64l-.76.77c.1.17.19.36.25.57zm-4.69.9c0 .93.75 1.69 1.69 1.69.93 0 1.69-.75 1.69-1.69s-.75-1.69-1.69-1.69-1.69.76-1.69 1.69z"],"series-derived":["M18.82 6.58c-.03.05-.07.09-.11.13 0 0 0-.01-.01-.01l-2 2c-.2.2-.4.3-.7.3-.6 0-1-.4-1-1 0-.3.1-.5.3-.7L16.6 6H11c-.6 0-1-.4-1-1s.4-1 1-1h5.6l-1.3-1.3c-.2-.2-.3-.4-.3-.7 0-.6.4-1 1-1 .3 0 .5.1.7.3l3 3c.2.2.3.4.3.7s-.1.5-.3.7l-.88.88zm-5.53 2.71c.3.62.8 1.12 1.42 1.42l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 2.29-2.3z"],"series-filtered":["M12.14 10.45c.21.67.65 1.23 1.22 1.61l-1.65 1.65c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 1.14-1.14zM19.35 1a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V5.13L11.19 2.1a.642.642 0 01.45-1.1h7.71z"],"series-search":["M11.28 11.31l-.28.28-3.29-3.3C7.53 8.11 7.28 8 7 8s-.53.11-.71.29L2 12.59V4c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1H2v-1.59l5-5 3.29 3.29c.18.19.43.3.71.3s.53-.11.71-.29l2.09-2.09c-.17.02-.34.02-.51.02-.7 0-1.38-.12-2.01-.33zm-.93-6c0-1.62 1.31-2.93 2.93-2.93s2.93 1.31 2.93 2.93-1.31 2.93-2.93 2.93-2.93-1.31-2.93-2.93zm6.47 2.43c.11-.17.21-.33.29-.51.01-.03.03-.06.04-.09.08-.18.16-.35.21-.54.06-.2.1-.38.14-.58.01-.05.01-.09.02-.14.03-.2.05-.39.05-.6 0-2.37-1.93-4.3-4.3-4.3-2.37.01-4.3 1.93-4.3 4.31s1.93 4.3 4.3 4.3c.21 0 .4-.02.6-.05.04 0 .09-.01.14-.02.2-.03.38-.08.57-.14.2-.06.37-.14.55-.21.03-.01.06-.03.09-.04.18-.09.34-.19.51-.29l2.87 2.87c.14.14.33.22.56.22.43 0 .78-.35.78-.78a.938.938 0 00-.23-.56l-2.89-2.85z"],settings:["M4 1c0-.55-.45-1-1-1S2 .45 2 1v5h2V1zM2 19c0 .55.45 1 1 1s1-.45 1-1v-6H2v6zm9-18c0-.55-.45-1-1-1S9 .45 9 1v8h2V1zm7 0c0-.55-.45-1-1-1s-1 .45-1 1v3h2V1zM9 19c0 .55.45 1 1 1s1-.45 1-1v-3H9v3zm9-14h-2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-2 14c0 .55.45 1 1 1s1-.45 1-1v-8h-2v8zM4 7H2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm7 3H9c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],shapes:["M7.88 11.12a.958.958 0 011.277.33l3.719 6.207c.081.136.124.29.124.447 0 .495-.419.896-.936.896H4.936a.969.969 0 01-.436-.103.878.878 0 01-.392-1.21l3.409-6.208a.915.915 0 01.362-.36zM15 5a4 4 0 110 8 4 4 0 010-8zM8 1a1 1 0 011 1v6a1 1 0 01-1 1H2a1 1 0 01-1-1V2a1 1 0 011-1h6z"],share:["M15 18H2V5h8.76l2-2H1c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1h15c.55 0 1-.45 1-1V7.24l-2 2V18zm4-18h-7c-.55 0-1 .45-1 1s.45 1 1 1h4.59l-7.3 7.29a1.003 1.003 0 001.42 1.42L18 3.41V8c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],"shared-filter":["M13.917 17.209c1.01.454 2.543.928 2.873 1.643.31.722.186 1.148.186 1.148H6.026s-.13-.426.186-1.148 1.842-1.203 2.86-1.65c1.017-.447.914-.722.948-1.093 0-.048.007-.097.007-.145a3.067 3.067 0 01-.839-1.237l-.007-.007c0-.007-.006-.014-.006-.02a1.757 1.757 0 01-.11-.337c-.234-.042-.372-.296-.426-.537a1.045 1.045 0 01-.138-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478a2.508 2.508 0 01.962-1.623c.426-.33 1.038-.501 1.58-.501.544 0 1.155.172 1.588.502a2.496 2.496 0 01.963 1.622c.075.413.117 1.045.117 1.478v.062c.15.062.288.22.323.564.02.268-.083.502-.138.598-.048.234-.185.488-.42.537a2.635 2.635 0 01-.116.364 3.094 3.094 0 01-.818 1.224c0 .055 0 .11.007.158.034.378-.103.653.914 1.1z","M14.976 16.57c-.24-.099-.455-.186-.65-.273l-.007-.004a3.801 3.801 0 01-.194-.091c.224-.288.41-.609.554-.946l.001-.002.013-.033c.018-.043.036-.087.052-.13l.011-.027.016-.04c.105-.092.19-.19.256-.284.129-.184.213-.38.265-.563.105-.226.225-.592.192-1.026l-.001-.011-.002-.011a1.854 1.854 0 00-.325-.91 9.924 9.924 0 00-.12-1.246 3.09 3.09 0 00-.106-.475l-.001-.006a3.543 3.543 0 00-.763-1.353c.27-.092.56-.139.83-.139.495 0 1.05.156 1.444.456a2.269 2.269 0 01.875 1.475c.069.375.106.95.106 1.344v.056c.138.056.263.2.294.513.019.244-.075.456-.125.543-.044.213-.169.444-.381.488-.025.1-.056.206-.094.3a2.815 2.815 0 01-.756 1.144c0 .05 0 .1.006.144.004.043.006.086.007.127.01.283.018.518.824.872.192.087.404.173.623.263.83.34 1.752.717 1.99 1.231.28.657.168 1.044.168 1.044h-2.081a3.864 3.864 0 00-.188-.542l-.005-.013-.006-.012c-.183-.397-.491-.681-.76-.88a5.614 5.614 0 00-.896-.522 17.36 17.36 0 00-.916-.4l-.15-.061zM14 1c.55 0 1 .45 1 1 0 .28-.11.53-.29.7L10 7.41v.897a3.182 3.182 0 00-.69.4 3.508 3.508 0 00-1.343 2.259c-.07.37-.107.836-.122 1.237a1.836 1.836 0 00-.339.926c-.046.458.09.84.195 1.06.053.178.138.376.27.56.055.08.125.162.21.242v.143l.053.052L6.71 16.71A1.003 1.003 0 015 16V7.41L.29 2.71A1.003 1.003 0 011 1h13z","M9.059 14.361c-.23-.044-.366-.296-.42-.535a1.045 1.045 0 01-.138-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478A2.508 2.508 0 0110 9.441V13c0 .28-.11.53-.29.71l-.651.651z"],shield:["M10 20c6-3.81 9-9.048 9-15.714-2 0-5-1.429-9-4.286-4 2.857-7 4.286-9 4.286C1 10.952 4 16.19 10 20zm0-17.348c2.577 1.734 4.776 2.88 6.667 3.419-.44 4.627-2.636 8.353-6.667 11.297V2.652z"],ship:["M6.84.804L6.5 2.5h-3a1 1 0 00-1 1v4.893l-1.58.451a.99.99 0 00-.691 1.192c.46 1.82 1.163 4.356 1.701 5.571-.218.012-.445.018-.68.018a.625.625 0 100 1.25c2.583 0 4.268-.68 5.202-1.146.687.466 1.88 1.146 3.548 1.146 1.65 0 2.837-.666 3.528-1.132l.005.003c.244.131.6.3 1.07.468.938.335 2.321.661 4.147.661a.625.625 0 100-1.25c-.323 0-.63-.011-.922-.031a.996.996 0 00.184-.334l1.67-5.168a1 1 0 00-.677-1.27l-1.505-.43V3.5a1 1 0 00-1-1h-3L13.16.804A1 1 0 0012.18 0H7.82a1 1 0 00-.98.804zM5 7.679l3.75-1.072V5H5v2.679zm6.25-1.072L15 7.68V5h-3.75v1.607zM6.205 16.95a.625.625 0 01.658.042c.569.407 1.597 1.134 3.137 1.134s2.568-.727 3.137-1.134a.625.625 0 01.724-.001l.007.005.045.029c.044.027.114.069.21.12.194.104.493.247.9.392.811.29 2.053.589 3.727.589a.625.625 0 110 1.25c-1.826 0-3.21-.326-4.148-.661a7.894 7.894 0 01-1.069-.468l-.005-.003c-.691.466-1.878 1.132-3.528 1.132-1.667 0-2.861-.68-3.548-1.146-.934.467-2.619 1.146-5.202 1.146a.625.625 0 110-1.25c2.66 0 4.23-.787 4.955-1.176z"],shop:["M17.94 3.63c-.01-.02-.01-.03-.02-.04l-.03-.09h-.01c-.18-.3-.49-.5-.86-.5h-14c-.42 0-.77.25-.92.61L0 8.5h.02a2.5 2.5 0 005 0 2.5 2.5 0 005 0 2.5 2.5 0 005 0 2.5 2.5 0 005 0l-2.08-4.87zM3.02 2h14c.55 0 1-.45 1-1s-.45-1-1-1h-14c-.55 0-1 .45-1 1s.44 1 1 1zm13 14h-12v-4h-2v7c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-7h-2v4z"],"shopping-cart":["M18 14H8.72l-.67-2H17c.44 0 .8-.29.94-.69h.01l2-6h-.01c.03-.1.06-.2.06-.31 0-.55-.45-1-1-1H5.39l-.44-1.32h-.01C4.8 2.29 4.44 2 4 2H1c-.55 0-1 .45-1 1s.45 1 1 1h2.28l3.33 10H5c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2h9c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zM6.05 6h11.56l-1.33 4H7.39L6.05 6z"],"signal-search":["M7.15 10.33c.888.8 1.999 1.36 3.228 1.574l2.326 6.98a.846.846 0 01-.535 1.07.844.844 0 01-1.072-.535l-1.225-3.671H7.125L5.9 19.419a.85.85 0 01-1.072.536.85.85 0 01-.536-1.071l2.857-8.555zm1.353 1.305l-.808 2.413h1.607l-.8-2.413zM5 5.5c0 .76.13 1.49.37 2.17-.496 1.056-.313 2.356.704 3.29.385.353.404.94.038 1.311a.982.982 0 01-1.356.038c-2.183-2.01-2-5.125.01-6.94a.95.95 0 01.24-.156A6.421 6.421 0 005 5.5z","M3.874 13.185c-1.346-.918-2.187-2.67-2.187-4.34 0-1.752.757-3.254 2.187-4.339.42-.25.42-.834.168-1.168-.252-.418-.84-.418-1.177-.167C1.014 4.59-.08 6.509.005 8.846c.084 2.253 1.177 4.423 2.86 5.675.168.083.336.166.504.166.253 0 .505-.083.673-.333.337-.418.253-.918-.168-1.169zM12.246 12.309a.98.98 0 01-1.354-.037.917.917 0 01-.206-.324 6.54 6.54 0 001.959-.049 5.125 5.125 0 01-.399.41zM14.631 11.476l1.228 1.229a6.6 6.6 0 01-1.723 1.816c-.169.083-.337.166-.505.166-.253 0-.505-.083-.673-.333-.337-.418-.253-.918.168-1.169.62-.422 1.133-1.022 1.505-1.709z","M11.5 0C14.54 0 17 2.46 17 5.5c0 .26-.02.51-.06.75l-.03.17c-.04.25-.1.49-.17.73v.01c-.08.24-.17.47-.28.69-.01.04-.03.07-.05.11-.11.23-.24.44-.38.65l3.68 3.68A1.003 1.003 0 0119 14c-.28 0-.53-.11-.7-.29l-3.68-3.68c-.21.14-.42.27-.65.38-.04.01-.07.03-.11.05-.22.11-.45.2-.69.28h-.01c-.24.07-.48.13-.73.17l-.17.03c-.25.04-.5.06-.76.06C8.46 11 6 8.54 6 5.5S8.46 0 11.5 0zm0 1.5c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"],"sim-card":["M16.71 5.29l-5-5A.997.997 0 0011 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.28-.11-.53-.29-.71zM9 7h2v3H9V7zM6 7h2v3H6V7zm2 11H6v-3h2v3zm3 0H9v-3h2v3zm3 0h-2v-3h2v3zm0-4H6v-3h8v3zm0-4h-2V7h2v3z"],slash:["M12 2c-.46 0-.85.32-.97.74L7.04 16.7c-.02.1-.04.2-.04.3 0 .55.45 1 1 1 .46 0 .85-.32.97-.74L12.96 3.3c.02-.1.04-.2.04-.3 0-.55-.45-1-1-1z"],"small-cross":["M11.41 10l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L8.59 10 5.3 13.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3.29-3.3 3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z"],"small-minus":["M14 9H6c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-plus":["M14 9h-3V6c0-.55-.45-1-1-1s-1 .45-1 1v3H6c-.55 0-1 .45-1 1s.45 1 1 1h3v3c0 .55.45 1 1 1s1-.45 1-1v-3h3c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-square":["M5 5v10h10V5H5zM4 3a1 1 0 00-1 1v12a1 1 0 001 1h12a1 1 0 001-1V4a1 1 0 00-1-1H4z"],"small-tick":["M15 5c-.28 0-.53.11-.71.29L8 11.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7A1.003 1.003 0 0015 5z"],snowflake:["M11 11.776v2.81l2.31 2.242a.987.987 0 010 1.415c-.399.39-1.044.39-1.442 0L11 17.414V19a.99.99 0 01-.996 1A.996.996 0 019 19v-1.636l-.912.879c-.398.39-1.043.39-1.441 0a.987.987 0 010-1.415L9 14.536v-2.79l-2.548 1.435-.837 3.063c-.146.534-.705.85-1.248.707a.998.998 0 01-.721-1.224l.309-1.132-1.4.793a1.03 1.03 0 01-1.393-.366.99.99 0 01.373-1.366l1.445-.818-1.224-.322a.998.998 0 01-.72-1.225c.145-.533.704-.85 1.248-.707l3.193.84 2.462-1.395-2.532-1.434-3.123.82a1.022 1.022 0 01-1.249-.706.998.998 0 01.721-1.225L2.91 7.18l-1.4-.793a.99.99 0 01-.373-1.366 1.03 1.03 0 011.392-.366l1.445.818-.328-1.2a.998.998 0 01.72-1.225 1.022 1.022 0 011.25.707l.855 3.132L9 8.311V5.414L6.647 3.121a.987.987 0 010-1.414 1.033 1.033 0 011.441 0L9 2.586V1c0-.552.44-1 1.004-1A.99.99 0 0111 1l-.007 1.536.875-.829a1.033 1.033 0 011.441 0 .987.987 0 010 1.414L11 5.364v2.918l2.53-1.42.855-3.131c.146-.534.705-.85 1.249-.707a.998.998 0 01.72 1.224l-.327 1.2 1.4-.792a1.03 1.03 0 011.392.366.99.99 0 01-.373 1.366l-1.355.768 1.153.303a.998.998 0 01.721 1.225c-.146.533-.705.85-1.249.707l-3.123-.821-2.576 1.459 2.506 1.42 3.193-.84a1.022 1.022 0 011.249.707.998.998 0 01-.72 1.225l-1.224.322 1.4.793a.99.99 0 01.373 1.366 1.03 1.03 0 01-1.393.366l-1.356-.768.31 1.132a.998.998 0 01-.721 1.224 1.022 1.022 0 01-1.249-.707l-.837-3.063L11 11.776z"],"social-media":["M11.5 5c.8 0 1.6-.4 2-1 2 1.2 3.3 3.3 3.5 5.7 0 .5.5.9 1 .9.6 0 1-.5 1-1v-.1c-.2-3.3-2.2-6.2-5.1-7.6C13.7.8 12.7 0 11.5 0 10.1 0 9 1.1 9 2.5S10.1 5 11.5 5zm5 7c-1.4 0-2.5 1.1-2.5 2.5 0 .4.1.7.2 1.1-1.1.9-2.6 1.4-4.2 1.4-1.9 0-3.6-.8-4.9-2-.2-.2-.5-.4-.8-.4-.5 0-1 .5-1 1 0 .3.1.5.3.7C5.3 18 7.5 19 10 19c2.2 0 4.2-.8 5.8-2.1.2.1.5.1.7.1 1.4 0 2.5-1.1 2.5-2.5S17.9 12 16.5 12zM5 10.5c0-1.1-.7-2.1-1.7-2.4.5-1.9 1.9-3.5 3.6-4.4.3-.2.6-.5.6-.9 0-.5-.4-1-1-1-.2 0-.4.1-.6.2-2.4 1.2-4.2 3.6-4.7 6.4C.5 8.9 0 9.6 0 10.5 0 11.9 1.1 13 2.5 13S5 11.9 5 10.5z"],sort:["M19 16h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM7 15c-.28 0-.53.11-.71.29L5 16.59V11c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 15.3A.965.965 0 001 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 15zM19 1h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 5h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"sort-alphabetical":["M8 15c-.28 0-.53.11-.71.29L6 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L2.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 008 15zm8.89-.79v-1.22H11.3v1.3h3.51L11 18.78V20h5.99v-1.3h-3.91l3.81-4.49zM14.97 0h-1.95L9.01 11.01h1.89l.98-2.92h4.17l.98 2.92h1.96L14.97 0zm-2.59 6.63l1.58-4.74H14l1.57 4.74h-3.19z"],"sort-alphabetical-desc":["M8.01 15c-.28 0-.53.11-.71.29L6 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L2.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3a1.014 1.014 0 001.42 0l3-3c.18-.18.29-.43.29-.71.01-.55-.44-1-.99-1zm4.44-5.65l6.4-7.88V0H10.5v1.67h5.91L10 9.44v1.57h9V9.35h-6.55zm1.27 3.64L11 20h1.59l.56-1.56h2.68l.55 1.56h1.64l-2.68-7.01h-1.62zm-.16 4.3l.93-2.57h.02l.9 2.57h-1.85z"],"sort-asc":["M10 8h5c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1h-5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0 5h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0-10h3c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm9 12h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM7 14c-.28 0-.53.11-.71.29L5 15.59V10c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 14.3A.965.965 0 001 14a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 14z"],"sort-desc":["M13 15h-3c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm-6-1c-.28 0-.53.11-.71.29L5 15.59V10c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 14.3A.965.965 0 001 14a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 14zM19 0h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 10h-5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm2-5h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],"sort-numerical":["M9 14.99c-.28 0-.53.11-.71.29L7 16.58v-5.59c0-.55-.45-1-1-1s-1 .45-1 1v5.59l-1.29-1.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-3c.18-.18.29-.43.29-.71a.99.99 0 00-1-1zm8.88.23c-.08-.42-.22-.79-.42-1.12-.2-.33-.47-.6-.8-.8-.33-.2-.76-.3-1.28-.3a2.333 2.333 0 00-1.72.71c-.21.22-.37.48-.49.78-.11.3-.17.62-.17.97 0 .27.04.54.13.8.08.26.22.5.4.7.19.21.43.38.71.5a2.142 2.142 0 001.72.02c.25-.12.47-.31.66-.58l.02.02c-.01.19-.04.4-.08.63-.04.24-.11.46-.21.67-.1.21-.23.38-.39.53a.92.92 0 01-.62.22c-.24 0-.44-.08-.6-.25-.16-.17-.27-.36-.31-.59h-1.31c.04.29.12.56.24.79.12.23.28.43.48.59.19.16.42.28.67.36.25.08.52.12.82.12.49 0 .9-.1 1.23-.31.34-.21.61-.48.82-.82.21-.34.37-.71.47-1.13.1-.42.15-.83.15-1.25 0-.43-.04-.85-.12-1.26zm-1.42.63c-.05.15-.11.28-.2.4-.09.12-.2.21-.34.27s-.3.1-.49.1c-.17 0-.33-.04-.46-.11s-.24-.17-.33-.29c-.08-.12-.15-.25-.19-.4-.04-.15-.06-.31-.06-.47 0-.15.02-.3.07-.45.05-.15.11-.28.2-.39.09-.12.2-.21.33-.28.13-.07.27-.11.44-.11.17 0 .33.04.47.11.14.07.25.17.34.28a1.387 1.387 0 01.28.86c.01.17-.02.33-.06.48zM15.32 11H17V0h-1.25c-.05.34-.17.62-.34.85-.17.23-.39.42-.63.57-.25.15-.52.25-.83.31-.3.06-.62.09-.94.09v1.41h2.31V11z"],"sort-numerical-desc":["M9 15c-.28 0-.53.11-.71.29L7 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L3.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-3A1.003 1.003 0 009 15zm6.7-1.33a1.5 1.5 0 01-.44.43c-.17.11-.37.19-.58.23-.22.04-.44.06-.67.05v1.07h1.66V20H17v-6.99h-1.06c-.04.26-.12.48-.24.66zm3.15-10.3c-.11-.68-.29-1.26-.55-1.76-.26-.5-.62-.89-1.08-1.18C16.75.14 16.17 0 15.46 0c-.54 0-1.03.09-1.46.27-.43.18-.79.44-1.09.76-.3.33-.52.71-.67 1.15-.16.44-.24.92-.24 1.43 0 .54.08 1.04.23 1.47.15.44.37.81.65 1.12.28.31.61.55 1 .72.39.17.82.26 1.3.26.46 0 .88-.11 1.26-.33.38-.22.68-.53.9-.94l.03.03c-.03.35-.07.74-.12 1.16-.05.42-.15.81-.29 1.18-.14.37-.35.68-.61.92-.26.25-.62.37-1.06.37-.43 0-.77-.13-1.03-.4-.25-.27-.4-.62-.44-1.05h-1.64c.02.43.11.83.29 1.18.17.35.39.66.67.91a3.027 3.027 0 002.07.8c.71 0 1.3-.17 1.79-.5.48-.33.87-.76 1.17-1.29.3-.53.51-1.12.64-1.76.13-.64.19-1.28.19-1.92.01-.77-.05-1.49-.15-2.17zM17.1 4.44c-.08.27-.19.5-.34.71-.15.21-.34.37-.57.49-.23.12-.5.18-.8.18-.3 0-.56-.06-.78-.19-.22-.13-.4-.29-.55-.49-.14-.2-.25-.44-.32-.7-.07-.27-.11-.55-.11-.84 0-.28.04-.55.11-.82.07-.26.18-.49.32-.7.14-.2.33-.36.55-.48.22-.12.48-.17.78-.17.31 0 .57.06.8.18.23.12.42.28.57.48.15.2.26.43.34.69.08.26.11.53.11.82 0 .29-.04.57-.11.84z"],"split-columns":["M15 13a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 9H11V2h5v2c.77 0 1.47.3 2 .78V1c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v3.78C2.53 4.3 3.23 4 4 4V2h5v7H3.41L4.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 11H9v7H4v-2c-.77 0-1.47-.3-2-.78V19c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.78c-.53.48-1.23.78-2 .78v2h-5v-7h5.59l-1.29 1.29c-.19.18-.3.43-.3.71z"],square:["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V2h16v16z"],"stacked-chart":["M12 2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v4h4V2zm3 14h2c.55 0 1-.45 1-1v-5h-4v5c0 .55.45 1 1 1zm3-10c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h4V6zm-6 1H8v5h4V7zm-9 9h2c.55 0 1-.45 1-1v-3H2v3c0 .55.45 1 1 1zm16 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM6 9c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h4V9zm3 7h2c.55 0 1-.45 1-1v-2H8v2c0 .55.45 1 1 1z"],"stadium-geometry":["M15 7H5a3 3 0 000 6h10a3 3 0 100-6zM5 5a5 5 0 000 10h10a5 5 0 000-10H5z"],star:["M10 0l3.1 6.6 6.9 1-5 5.1 1.2 7.3-6.2-3.4L3.8 20 5 12.7 0 7.6l6.9-1z"],"star-empty":["M20 7.6l-6.9-1.1L10 0 6.9 6.6 0 7.6l5 5.1L3.8 20l6.2-3.4 6.2 3.4-1.2-7.2 5-5.2zM10 15l-4.5 2.4.9-5.2-3.6-3.6 5-.8L10 3.1l2.2 4.7 5 .8-3.6 3.7.9 5.2L10 15z"],"step-backward":["M15 3c-.23 0-.42.09-.59.21l-.01-.01L8 8V4c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-4l6.4 4.8.01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"step-chart":["M19 16H2v-3h4c.55 0 1-.45 1-1V8h3v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V6h2c.55 0 1-.45 1-1s-.45-1-1-1h-3c-.55 0-1 .45-1 1v4h-3V7c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v4H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"step-forward":["M15 3h-2c-.55 0-1 .45-1 1v4L5.6 3.2l-.01.01C5.42 3.09 5.23 3 5 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01L12 12v4c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stop:["M16 3H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stopwatch:["M10 6a6 6 0 106 6h-6V6zm-.998-1.938A1.015 1.015 0 019 4V2H7a1 1 0 110-2h6a1 1 0 010 2h-2v2c0 .02 0 .041-.002.062A8.001 8.001 0 0110 20a8 8 0 01-.998-15.938z"],strikethrough:["M18 9h-4.46a4.7 4.7 0 00-.4-.14c-.19-.05-.51-.14-.96-.25-.45-.11-.9-.23-1.37-.35-.47-.12-.89-.23-1.27-.33s-.6-.16-.65-.17c-.53-.15-.95-.37-1.27-.66-.32-.28-.49-.68-.49-1.19 0-.36.09-.66.26-.9s.39-.43.65-.57c.26-.14.55-.24.87-.3s.63-.09.93-.09c.89 0 1.63.19 2.21.57.45.3.75.76.89 1.38h2.63c-.06-.52-.2-.98-.42-1.4-.3-.57-.71-1.05-1.23-1.43a5.33 5.33 0 00-1.79-.87c-.7-.2-1.42-.3-2.19-.3-.66 0-1.31.08-1.96.25s-1.22.43-1.73.77-.92.79-1.23 1.32c-.31.52-.46 1.15-.46 1.87 0 .37.05.74.15 1.1.1.36.28.7.53 1.02.18.24.41.47.69.67H2c-.55 0-1 .45-1 1s.45 1 1 1h10.14c.02.01.05.02.07.02.3.11.58.29.84.55.25.26.38.67.38 1.21 0 .27-.06.53-.17.79-.11.26-.29.49-.54.69-.25.2-.57.36-.97.49s-.88.19-1.44.19c-.52 0-1.01-.06-1.45-.17-.45-.11-.84-.29-1.19-.54s-.61-.56-.8-.95c-.05-.08-.09-.18-.12-.28H4.11c.09.43.22.82.4 1.18.33.65.77 1.18 1.32 1.59.55.41 1.2.72 1.94.92.74.2 1.53.3 2.37.3.73 0 1.44-.08 2.14-.25.7-.17 1.33-.43 1.88-.79.55-.36.99-.83 1.33-1.39.34-.56.51-1.25.51-2.05 0-.37-.06-.75-.18-1.12a3.12 3.12 0 00-.15-.39H18c.55 0 1-.45 1-1s-.45-1-1-1z"],style:["M18 18H2V2h12.3l2-2H1C.4 0 0 .4 0 1v18c0 .6.4 1 1 1h18c.6 0 1-.4 1-1V7.7l-2 2V18zm1.2-18l-7.6 7.6 2.8 2.8L20 4.8V0h-.8zM4 15.9c3.1.2 5.9.2 8.2-2 1.1-1.1 1.1-3 0-4.1-.6-.5-1.3-.8-2-.8s-1.4.3-1.9.8C7.2 11 6.6 14.3 4 15.9z"],"swap-horizontal":["M16.02 10c-.01 0-.01 0 0 0H16h.02zM2 6h13.58l-2.29 2.29a1 1 0 00-.3.71 1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-4-4a1.003 1.003 0 00-1.42 1.42L15.58 4H2c-.55 0-1 .45-1 1s.45 1 1 1zm2 4h-.02H4zm14 4H4.42l2.29-2.29a1 1 0 00.3-.71 1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.42 16H18c.55 0 1-.45 1-1s-.45-1-1-1z"],"swap-vertical":["M9.71 5.3l-4-4A.997.997 0 005 1.01c-.28 0-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L4 4.42V18c0 .55.45 1 1 1s1-.45 1-1V4.42l2.29 2.29a1 1 0 00.71.3 1.003 1.003 0 00.71-1.71zM10 3.98c0 .01 0 .01 0 0V4v-.02zm0 12.04c0-.01 0-.01 0 0V16v.02zm9-3.03c-.28 0-.53.11-.71.29L16 15.58V2c0-.55-.45-1-1-1s-1 .45-1 1v13.58l-2.29-2.29a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29.28 0 .53-.11.71-.29l4-4c.18-.18.29-.43.29-.71 0-.56-.45-1.01-1-1.01z"],switch:["M12.293 2.293l1.414 1.414-7.127 7.129a3.5 3.5 0 11-1.415-1.415l7.128-7.128zM16.5 9a3.5 3.5 0 110 7 3.5 3.5 0 010-7zm-13 2a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm13 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"],"symbol-circle":["M10 4.01a6 6 0 100 12 6 6 0 100-12z"],"symbol-cross":["M15 8.01h-3v-3c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v3H5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h3v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-3h3c.55 0 1-.45 1-1v-2c0-.56-.45-1-1-1z"],"symbol-diamond":["M15 10.01c0-.21-.08-.39-.18-.54l.02-.01-4-6-.02.01c-.18-.28-.47-.46-.82-.46s-.64.18-.82.45l-.01-.01-4 6 .02.01c-.11.16-.19.34-.19.55s.08.39.18.54l-.02.01 4 6 .02-.01c.18.27.47.46.82.46s.64-.19.82-.46l.02.01 4-6-.02-.01c.1-.16.18-.34.18-.54z"],"symbol-rectangle":["M16 5H4c-.5 0-1 .5-1 1v8c0 .5.5 1 1 1h12c.5 0 1-.5 1-1V6c0-.5-.5-1-1-1z"],"symbol-square":["M15 4.01H5c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10c0-.56-.45-1-1-1z"],"symbol-triangle-down":["M16 5c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1 0 .16.05.31.11.44H4.1l5 10h.01c.17.33.5.56.89.56s.72-.23.89-.56h.01l5-10h-.01c.06-.13.11-.28.11-.44z"],"symbol-triangle-up":["M15.89 14.56l-4.99-10h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56H9.1l-5 10h.01c-.06.13-.11.28-.11.44 0 .55.45 1 1 1h10c.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44z"],syringe:["M15.146.854a.5.5 0 01.708-.708l4 4a.5.5 0 01-.708.708l-.646-.647L17.207 5.5l1.647 1.646a.5.5 0 01-.708.708l-.646-.647-1.146 1.146-7.5 7.5a.5.5 0 01-.708 0l-.646-.646-2.646 2.647a.5.5 0 01-.708 0l-.646-.647-2.646 2.647a.5.5 0 01-.708-.708L2.793 16.5l-.647-.646a.5.5 0 010-.708L4.793 12.5l-.647-.646a.5.5 0 010-.708l7.5-7.5L12.794 2.5l-.647-.646a.5.5 0 01.708-.708L14.5 2.793 15.793 1.5l-.647-.646zM12.707 4l.793-.793L16.793 6.5 16 7.293 12.707 4zm2.586 4l-.793.793-1.646-1.647a.5.5 0 00-.708.708L13.793 9.5 12.5 10.793l-1.646-1.647a.5.5 0 00-.708.708l1.647 1.646-1.293 1.293-1.646-1.647a.5.5 0 00-.708.708L9.793 13.5 8.5 14.793 5.207 11.5 12 4.707 15.293 8zM3.207 15.5L5.5 13.207 6.793 14.5 4.5 16.793 3.207 15.5zM16.5 2.207L17.793 3.5 16.5 4.793 15.207 3.5 16.5 2.207z"],tag:["M2 4a2 2 0 012-2h4.588a2 2 0 011.414.586l7.41 7.41a2 2 0 010 2.828l-4.588 4.588a2 2 0 01-2.829 0l-7.41-7.41A2 2 0 012 8.588V4zm3.489-.006a1.495 1.495 0 100 2.99 1.495 1.495 0 000-2.99z"],"take-action":["M5 7c.28 0 .53-.11.71-.29l5-5A1.003 1.003 0 009.29.29l-5 5A1.003 1.003 0 005 7zm6 6a1.003 1.003 0 001.71.71l5-5a1.003 1.003 0 00-1.42-1.42l-5 5c-.18.18-.29.43-.29.71zm8 5h-1c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm-9-6l6-6-1.29-1.29a1.003 1.003 0 00-1.42-1.42L12 2 6 8l1.29 1.29-7 7a1.003 1.003 0 001.42 1.42l7-7L10 12z"],tank:["M3.956 4.47A1 1 0 014.804 4h6.392a1 1 0 01.848.47L13 6h5a1 1 0 010 2h-5v1h4a3 3 0 110 6H3a3 3 0 010-6V6.287a1 1 0 01.152-.53l.804-1.287zM3 11h14a1 1 0 110 2H3a1 1 0 110-2z"],target:["M9 5a1 1 0 012 0v3a1 1 0 01-2 0V5zM12 9a1 1 0 000 2h3a1 1 0 000-2h-3zM4 10a1 1 0 011-1h3a1 1 0 010 2H5a1 1 0 01-1-1zM10 11a1 1 0 00-1 1v3a1 1 0 002 0v-3a1 1 0 00-1-1z","M10 20c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10zm0-2a8 8 0 100-16 8 8 0 000 16z"],taxi:["M19 9h-.33l.33 1v.5c0 .15-.03.3-.07.44h.01L17 17.23v.27c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5V17H6v.5c0 .83-.67 1.5-1.5 1.5S3 18.33 3 17.5v-.27l-1.93-6.28h.01c-.05-.15-.08-.3-.08-.45V10s.02-.06.05-.16c.06-.17.16-.47.28-.84H1c-.55 0-1-.45-1-1s.45-1 1-1h1l1-3h-.01v-.01c.25-.64 1-1.31 1.67-1.5 0 0 .78-.21 2.33-.36V1c0-.55.45-1 1-1h4c.55 0 1 .45 1 1v1.13c1.55.14 2.33.36 2.33.36.67.19 1.42.86 1.67 1.5V4H17l1 3h1c.55 0 1 .45 1 1s-.45 1-1 1zM3 11.5c0 .83.67 1.5 1.5 1.5S6 12.33 6 11.5 5.33 10 4.5 10 3 10.67 3 11.5zM16 7l-1-3H5L4 7v1h12V7zm-.5 3c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],temperature:["M11 0a2 2 0 00-2 2v10.535a4 4 0 104 0V2a2 2 0 00-2-2zM3 2.5a.5.5 0 01.5-.5h4a.5.5 0 010 1h-4a.5.5 0 01-.5-.5zM3.5 8a.5.5 0 000 1h4a.5.5 0 000-1h-4zM5 5.5a.5.5 0 01.5-.5h2a.5.5 0 010 1h-2a.5.5 0 01-.5-.5zm.5 5.5a.5.5 0 000 1h2a.5.5 0 000-1h-2z"],"text-highlight":["M16 17c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1-.45 1-1-.45-1-1-1c-.77 0-1.47.3-2 .78-.53-.48-1.23-.78-2-.78-.55 0-1 .45-1 1s.45 1 1 1 1 .45 1 1v12c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1c.77 0 1.47-.3 2-.78.53.48 1.23.78 2 .78.55 0 1-.45 1-1s-.45-1-1-1zm-4-4H2V7h10V5H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h11v-2zm7-8h-3v2h2v6h-2v2h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],th:["M19 1H1c-.6 0-1 .5-1 1v16c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V2c0-.5-.5-1-1-1zM7 17H2v-3h5v3zm0-4H2v-3h5v3zm0-4H2V6h5v3zm11 8H8v-3h10v3zm0-4H8v-3h10v3zm0-4H8V6h10v3z"],"th-derived":["M5.3 13.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7s-.1-.5-.3-.7l-3-3C6.5 7.1 6.3 7 6 7c-.6 0-1 .4-1 1 0 .3.1.5.3.7L6.6 10H1c-.6 0-1 .4-1 1s.4 1 1 1h5.6l-1.3 1.3zM19 1H3c-.5 0-1 .5-1 1v6h1c0-1.7 1.3-3 3-3 .8 0 1.6.3 2.1.9l.1.1H9v.8l1 1V6h8v3h-6.8c.3.3.5.6.6 1H18v3h-6.8l-.1.1-.9.9H18v3h-8v-2.8l-1 1V17H4v-.8c-.6-.5-1-1.3-1-2.2H2v4c0 .5.5 1 1 1h16c.6 0 1-.5 1-1V2c0-.5-.5-1-1-1z"],"th-disconnect":["M14.25 1H19c.5 0 1 .5 1 1v16c0 .5-.5 1-1 1h-7.221l.278-2H18v-3h-5.527l.14-1H18v-3h-4.971l.139-1H18V6h-4.416l.637-4.587c.02-.139.03-.277.03-.413zM8.221 1l-.694 5H2v3h5.11l-.139 1H2v3h4.555l-.14 1H2v3h3.999l-.22 1.587c-.02.139-.03.277-.03.413H1c-.6 0-1-.5-1-1V2c0-.5.4-1 1-1h7.221zM10.26.862a1 1 0 011.98.276l-2.5 18a1 1 0 01-1.98-.276l2.5-18z"],"th-filtered":["M17.333 10l1.435-1.722a1 1 0 00.232-.64V4.85l1-.9V18c0 .5-.5 1-1 1H1c-.6 0-1-.5-1-1V2c0-.5.4-1 1-1h6.722L12 4.85V6H8v3h4v1H8v3h10v-3h-.667zM7 17v-3H2v3h5zm0-4v-3H2v3h5zm0-4V6H2v3h5zm11 8v-3H8v3h10z","M19.35 0a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V4.13L11.19 1.1a.642.642 0 01.45-1.1h7.71z"],"th-list":["M19 1H1c-.6 0-1 .5-1 1v16c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V2c0-.5-.5-1-1-1zm-1 16H2v-3h16v3zm0-4H2v-3h16v3zm0-4H2V6h16v3z"],"third-party":["M8 0C3.58 0 0 3.58 0 8a8 8 0 005.856 7.71c.064-.057.129-.109.19-.156.278-.209.595-.383.896-.53.358-.174.81-.358 1.193-.515.206-.084.393-.16.534-.223a3.93 3.93 0 00.203-.095 4.1 4.1 0 01-.305-.45C8.382 13.911 8.19 14 8 14c-.67 0-1.36-1.1-1.73-3h1.252c.047-.296.153-.571.323-.797l.01-.203H6.12C6.05 9.39 6 8.73 6 8s.05-1.39.12-2h3.76l.037.344c.315-.145.65-.242.979-.295L10.89 6h2.76c.027.077.052.155.076.233l.118-.04A3.62 3.62 0 0114.998 6c.247 0 .51.028.772.086A8 8 0 008 0zm5.17 5h-2.44c-.21-1.11-.51-2.03-.91-2.69 1.43.46 2.61 1.43 3.35 2.69zM8 2c.67 0 1.36 1.1 1.73 3H6.27C6.64 3.1 7.33 2 8 2zm-1.82.31c-.4.66-.71 1.58-.91 2.69H2.83a6.025 6.025 0 013.35-2.69zM2 8c0-.7.13-1.37.35-2h2.76C5.04 6.62 5 7.28 5 8s.04 1.38.11 2H2.35C2.13 9.37 2 8.7 2 8zm.83 3h2.44c.21 1.11.51 2.03.91 2.69A6.025 6.025 0 012.83 11z","M13.917 15.209c.21.094.444.19.685.288.912.374 1.927.789 2.188 1.355.31.722.186 1.148.186 1.148H6.026s-.13-.426.186-1.148c.256-.584 1.305-1.011 2.234-1.39.22-.088.432-.175.626-.26.909-.4.923-.662.94-.978.002-.037.004-.076.008-.115l.003-.072c.002-.025.004-.049.004-.073a3.067 3.067 0 01-.839-1.237l-.007-.007a.024.024 0 00-.003-.01 1.757 1.757 0 01-.113-.347c-.234-.042-.372-.296-.427-.537a1.045 1.045 0 01-.137-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478a2.508 2.508 0 01.962-1.623c.426-.33 1.038-.501 1.58-.501.544 0 1.155.172 1.588.502a2.496 2.496 0 01.963 1.622c.075.413.117 1.045.117 1.478v.062c.15.062.288.22.323.564.02.268-.083.502-.138.598-.048.234-.185.488-.42.537a2.635 2.635 0 01-.116.364 3.094 3.094 0 01-.818 1.224c0 .055 0 .11.007.158.004.048.006.095.007.14.011.311.02.57.907.96z","M14.976 14.57c-.24-.098-.455-.186-.65-.274l-.007-.003a3.801 3.801 0 01-.194-.091c.224-.288.41-.609.554-.946l.001-.002.013-.033c.018-.043.036-.087.052-.13l.011-.027.016-.04c.105-.092.19-.19.256-.284.129-.184.213-.38.265-.563.105-.226.225-.592.192-1.026l-.001-.011-.002-.011a1.855 1.855 0 00-.325-.91 9.924 9.924 0 00-.12-1.246 3.088 3.088 0 00-.106-.474l-.001-.007a3.543 3.543 0 00-.763-1.353c.27-.092.56-.139.83-.139.495 0 1.05.156 1.444.456a2.269 2.269 0 01.875 1.475c.069.375.106.95.106 1.344v.056c.138.056.263.2.294.513.019.244-.075.456-.125.543-.044.213-.169.444-.381.488-.025.1-.056.206-.094.3a2.815 2.815 0 01-.756 1.144c0 .05 0 .1.006.144.004.043.006.086.007.127.01.283.018.518.824.873.192.086.404.172.623.262.83.34 1.752.717 1.99 1.231.28.657.168 1.044.168 1.044h-2.081a3.864 3.864 0 00-.188-.542l-.005-.013-.006-.012c-.183-.397-.491-.681-.76-.88a5.614 5.614 0 00-.896-.522 17.36 17.36 0 00-.916-.4l-.15-.061z"],"thumbs-down":["M18.55 6.56c-.31-.01-.65-.03-1.02-.06.03 0 .06-.01.09-.01.88-.12 1.68-.63 1.76-1.37.08-.75-.58-1.25-1.46-1.33-.32-.03-.65-.05-.99-.08.59-.19 1.05-.54 1.09-1.2.05-.75-.99-1.32-1.87-1.41-.34-.03-.64-.05-.91-.07h-.11c-.28-.02-.54-.02-.77-.02-3.92-.08-7.29.6-9.36 1.93v7.72c2.67 1.66 5.95 4.61 5.26 7.08-.21.76.39 1.35 1.23 1.26 1.01-.11 1.71-1.18 1.75-2.28.05-1.29-.19-2.59-.62-3.74-.05-.32.01-.65.47-.68.61-.04 1.39-.08 1.99-.1.32 0 .64-.01.94-.03h.01c.52-.03 1-.07 1.42-.12.88-.11 1.69-.6 1.79-1.35.1-.75-.55-1.25-1.44-1.35-.07-.01-.13-.02-.2-.02.21-.02.42-.04.61-.06.88-.11 1.69-.6 1.79-1.35.09-.75-.56-1.31-1.45-1.36zM3 3H0v8h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"thumbs-up":["M3 9H0v8h3c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm16.99 3.09c-.1-.75-.91-1.24-1.79-1.35-.19-.02-.4-.05-.61-.06.07-.01.14-.01.2-.02.88-.1 1.53-.61 1.44-1.35-.1-.74-.91-1.24-1.79-1.35-.42-.05-.9-.09-1.42-.12h-.01l-.94-.03c-.6-.02-1.39-.05-1.99-.1-.45-.03-.51-.36-.47-.68.43-1.15.67-2.45.62-3.74-.04-1.11-.74-2.17-1.75-2.28-.84-.09-1.45.5-1.23 1.26.7 2.47-2.58 5.43-5.25 7.08v7.72c2.08 1.33 5.44 2.01 9.35 1.93.24 0 .49-.01.77-.02h.11c.27-.02.57-.04.91-.07.88-.08 1.92-.66 1.87-1.41-.04-.65-.5-1.01-1.09-1.2.34-.03.67-.05.99-.08.89-.08 1.55-.58 1.46-1.33-.08-.75-.88-1.25-1.76-1.37-.03 0-.06-.01-.09-.01.37-.02.71-.04 1.02-.06.91-.05 1.55-.61 1.45-1.36z"],tick:["M17 4c-.28 0-.53.11-.71.29L7 13.59 3.71 10.3A.965.965 0 003 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l10-10A1.003 1.003 0 0017 4z"],"tick-circle":["M10 20C4.48 20 0 15.52 0 10S4.48 0 10 0s10 4.48 10 10-4.48 10-10 10zm5-14c-.28 0-.53.11-.71.29L8 12.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l7-7A1.003 1.003 0 0015 6z"],time:["M11 9.59V4c0-.55-.45-1-1-1s-1 .45-1 1v6c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L11 9.59zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"timeline-area-chart":["M19 16H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-13.41l-7.07 7.07-4.3-3.44-.01.01A.987.987 0 007 6c-.24 0-.46.1-.63.24l-.01-.01L3 9.03V15h16V2.59z"],"timeline-bar-chart":["M19 17H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM9 16h2c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1zm6 0h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1zM3 16h2c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1z"],"timeline-events":["M5 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm10 0c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm-9 9H4v2h2v-2zM17 3v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H7v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H2c-.5 0-1 .5-1 1v14c0 .5.5 1 1 1h16c.5 0 1-.5 1-1V4c0-.5-.5-1-1-1h-1zM7 17H3v-4h4v4zm0-5H3V8h4v4zm5 5H8v-4h4v4zm0-5H8V8h4v4zm5 5h-4v-4h4v4zm0-5h-4V8h4v4zm-6 2H9v2h2v-2zm5-5h-2v2h2V9z"],"timeline-line-chart":["M19 16H2v-1.59l5-5 3.29 3.29c.18.19.43.3.71.3s.53-.11.71-.29l7-7a1.003 1.003 0 00-1.42-1.42L11 10.59l-3.29-3.3C7.53 7.11 7.28 7 7 7s-.53.11-.71.29L2 11.59V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],tint:["M9.86 2S3.98 9.18 3.98 12.17C3.99 15.4 6.78 18 9.96 18c3.18-.01 6.04-2.63 6.03-5.86C15.99 9.05 9.86 2 9.86 2z"],torch:["M6.97 19c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2h-6v2zm-3-15l3 4v8h6V8l3-4h-12zm5 5c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1V9zm6-9h-10c-.55 0-1 .45-1 1v2h12V1c0-.55-.45-1-1-1z"],tractor:["M4.5 11a4.5 4.5 0 110 9 4.5 4.5 0 010-9zm11.499 1a4 4 0 110 8 4 4 0 010-8zm-11.5 1.571a1.928 1.928 0 100 3.857 1.928 1.928 0 000-3.857zM16 14.667a1.333 1.333 0 100 2.666 1.333 1.333 0 000-2.666zM5.999 0C7.46 0 8.527.668 9 2l.851 4.256c1.433.096 2.82.217 4.147.362V2h2L16 6.862c.962.13 1.886.275 2.767.435.779.141 1.232.614 1.232 1.284L20 13a4.995 4.995 0 00-4-1.997A5.001 5.001 0 0011.099 15h-1.12a5.499 5.499 0 00-5.478-4.994 5.482 5.482 0 00-3.377 1.157H.004v-1.18L0 7.327c-.002-.597.37-1.18.999-1.302V1a1 1 0 011-1h4zm1 2H3v4h.75c1.386.027 2.749.073 4.079.139L6.999 2z"],train:["M16 18h-2l2 2H4l.12-.12L6 18H4c-1.1 0-2-.9-2-2V2c0-1.1 3.58-2 8-2s8 .9 8 2v14c0 1.1-.9 2-2 2zM5.5 15c.83 0 1.5-.67 1.5-1.5S6.33 12 5.5 12 4 12.67 4 13.5 4.67 15 5.5 15zM9 3H4v6h5V3zm7 0h-5v6h5V3zm-1.5 9c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],translate:["M19.89 18.56l-4.99-10h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56h-.01l-1.73 3.46-2.8-2.3 1.99-1.64C11.44 7.34 12 6.23 12 5V4h1c.55 0 1-.45 1-1s-.45-1-1-1H8V1c0-.55-.45-1-1-1S6 .45 6 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h9v1c0 .62-.28 1.18-.73 1.54L7 8.42 4.73 6.54C4.28 6.18 4 5.62 4 5H2c0 1.23.56 2.34 1.44 3.07l1.99 1.64-3.06 2.52.01.01c-.23.18-.38.45-.38.76 0 .55.45 1 1 1 .24 0 .45-.1.63-.24l.01.01L7 11l3.36 2.77.01-.01c.02.02.05.03.08.05.01 0 .01.01.02.02l-2.36 4.73h.01c-.07.13-.12.28-.12.44 0 .55.45 1 1 1 .39 0 .72-.23.89-.56h.01L11.12 17h5.76l1.22 2.45h.01c.17.32.5.55.89.55.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44zM12.12 15L14 11.24 15.88 15h-3.76z"],trash:["M17 1h-5c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1H3c-.55 0-1 .45-1 1v1h16V2c0-.55-.45-1-1-1zm.5 3h-15c-.28 0-.5.22-.5.5s.22.5.5.5H3v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5h.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zM7 16c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8zm4 0c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8zm4 0c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8z"],tree:["M11 15.542V20H9v-4.458L2 17l4.5-5.625L4 12l3.655-5.483L6 7l4-7 4 7-1.655-.483L16 12l-2.5-.625L18 17l-7-1.458z"],"trending-down":["M19 10c-.55 0-1 .45-1 1v1.37l-6.25-7.03-.01.01A.971.971 0 0011 5c-.23 0-.42.09-.59.21l-.01-.01-3.43 2.58-5.42-3.61-.01.01A.969.969 0 001 4c-.55 0-1 .45-1 1 0 .35.19.64.46.82l-.01.01 6 4 .01-.02c.15.11.33.19.54.19.23 0 .42-.09.59-.21l.01.01 3.26-2.45L16.77 14H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"trending-up":["M19 4h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.77l-5.91 6.65L7.6 10.2l-.01.01C7.42 10.09 7.23 10 7 10c-.21 0-.39.08-.54.18l-.01-.02-6 4 .01.02c-.27.18-.46.47-.46.82 0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 5.41-3.61 3.43 2.58.01-.01c.18.11.37.2.6.2.3 0 .56-.14.74-.34l.01.01L18 7.63V9c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1z"],truck:["M16 0a1 1 0 011 1v11a1 1 0 011 1v3h.5a.5.5 0 01.5.5v1a.5.5 0 01-.5.5H17v1a1 1 0 01-1 1h-1a1 1 0 01-1-1v-1H6v1a1 1 0 01-1 1H4a1 1 0 01-1-1v-1H1.5a.5.5 0 01-.5-.5v-1a.5.5 0 01.5-.5H2v-3a1 1 0 011-1V1a1 1 0 112 0v3a2 2 0 012-2h6a2 2 0 012 2V1a1 1 0 011-1zm-4 10H8a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1v-4a1 1 0 00-1-1zm-7 4H4a1 1 0 000 2h1a1 1 0 000-2zm11 0h-1a1 1 0 000 2h1a1 1 0 000-2zm-4.5 0a.5.5 0 110 1h-3l-.09-.008A.5.5 0 018.5 14zm0-1.5a.5.5 0 110 1h-3l-.09-.008a.5.5 0 01.09-.992zm0-1.5a.5.5 0 110 1h-3l-.09-.008A.5.5 0 018.5 11zM14 5H6v3h8V5z"],"two-columns":["M5 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm14.71 9.29l-3-3A1.003 1.003 0 0015 7v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM12 0H8c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],unarchive:["M16.434 0a1 1 0 01.857.486L20 5v14a1 1 0 01-1 1H1a1 1 0 01-1-1V5L2.709.486A1 1 0 013.566 0h12.868zM10 8c-.28 0-.53.11-.71.29l-3 3-.084.096A1.003 1.003 0 007.71 12.71L9 11.41v4.58l.007.116c.058.496.482.884.993.884.55 0 1-.45 1-1v-4.58l1.29 1.29.081.073c.171.139.389.227.629.227a1.003 1.003 0 00.71-1.71l-3-3-.096-.084A1.002 1.002 0 0010 8zm6-6H4L2 5.002h16L16 2z"],underline:["M10 17c3.3 0 6-2.7 6-6V3.5c0-.8-.7-1.5-1.5-1.5S13 2.7 13 3.5V11c0 1.7-1.3 3-3 3s-3-1.3-3-3V3.5C7 2.7 6.3 2 5.5 2S4 2.7 4 3.5V11c0 3.3 2.7 6 6 6zM16.5 19h-13c-.3 0-.5.2-.5.5s.2.5.5.5h13c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"],undo:["M5 14c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm9-9H3.41L5.7 2.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 5.47 0 5.72 0 6c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 7H14c2.21 0 4 1.79 4 4s-1.79 4-4 4H9v2h5c3.31 0 6-2.69 6-6s-2.69-6-6-6z"],"ungroup-objects":["M4.5 6C2.01 6 0 8.01 0 10.5S2.01 15 4.5 15 9 12.99 9 10.5 6.99 6 4.5 6zm11 0C13.01 6 11 8.01 11 10.5s2.01 4.5 4.5 4.5 4.5-2.01 4.5-4.5S17.99 6 15.5 6z"],"unknown-vehicle":["M13 11.988v-4H4v-1l1-3h6V2.003a35.867 35.867 0 00-1-.015c-3.593 0-5.332.488-5.332.488-.67.188-1.424.864-1.674 1.503l-.004.009H3l-1 3H1a1 1 0 100 2h.333l-.28.84-.053.16v7.5a1.5 1.5 0 103 0v-.5h12v.5a1.5 1.5 0 103 0v-4.5h-5a1 1 0 01-1-1zm-8.5 1a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM19.83 2.782a2.392 2.392 0 00-.592-.853c-.276-.264-.64-.485-1.09-.663C17.695 1.09 17.132 1 16.457 1c-.523 0-.996.084-1.418.253a3.157 3.157 0 00-1.084.703c-.299.3-.532.656-.698 1.065-.166.41-.254.861-.264 1.353h2.096c0-.246.028-.476.085-.69.057-.214.145-.4.264-.56.119-.16.27-.287.456-.383.185-.095.406-.143.663-.143.38 0 .677.1.89.3.215.2.321.51.321.93.01.245-.035.45-.135.614-.1.164-.23.314-.392.45a8.598 8.598 0 01-.527.41 3.53 3.53 0 00-.542.485c-.171.187-.32.412-.45.676-.127.265-.206.592-.234.984v.614h1.924v-.519c.038-.273.13-.5.278-.683.147-.182.316-.343.506-.484a13.5 13.5 0 01.606-.424c.214-.14.408-.312.584-.512s.323-.442.442-.724.178-.642.178-1.079c0-.264-.059-.548-.178-.854zm-4.54 6.099v2.103h2.237V8.881H15.29z"],unlock:["M14 1c-2.21 0-4 1.79-4 4v4H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-2V5c0-1.1.9-2 2-2s2 .9 2 2v2c0 .55.45 1 1 1s1-.45 1-1V5c0-2.21-1.79-4-4-4z"],unpin:["M11.77 1.16c-.81.81-.74 2.28.02 3.76L6.1 8.71c-2.17-1.46-4.12-2-4.94-1.18l4.95 4.95-2.12 3.54 3.54-2.12 4.95 4.95c.82-.82.27-2.77-1.19-4.94l3.8-5.69c1.47.76 2.94.84 3.76.02l-7.08-7.08z"],unresolve:["M11.47 12.46c.16-.36.29-.74.38-1.14 0-.02.01-.04.01-.06.09-.4.14-.82.14-1.26 0-.44-.05-.86-.14-1.27 0-.02-.01-.04-.01-.06-.09-.4-.22-.78-.38-1.14-.01-.02-.02-.03-.02-.05a5.94 5.94 0 00-.61-1.03c0-.01-.01-.01-.01-.02a6.308 6.308 0 00-2.1-1.77c-.19-.1-.39-.18-.59-.26-.03-.01-.06-.02-.1-.03-.17-.07-.34-.12-.52-.17-.05-.01-.1-.03-.15-.04a4.34 4.34 0 00-.52-.09c-.05-.01-.11-.02-.17-.03C6.46 4.02 6.23 4 6 4c-3.31 0-6 2.69-6 6s2.69 6 6 6c.23 0 .46-.02.68-.04l.17-.03c.17-.02.34-.06.51-.09.05-.01.1-.03.15-.04.18-.05.36-.1.53-.17l.09-.03a5.973 5.973 0 002.68-2.04c0-.01.01-.01.01-.02.24-.32.44-.66.61-1.03.02-.01.03-.03.04-.05zM14 4c-.99 0-1.91.24-2.73.66a7.51 7.51 0 010 10.68c.82.42 1.74.66 2.73.66 3.31 0 6-2.69 6-6s-2.69-6-6-6z"],updated:["M10 0C6.71 0 3.82 1.6 2 4.05V2c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.76C5.22 3.17 7.47 2 10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8c0-.55-.45-1-1-1s-1 .45-1 1c0 5.52 4.48 10 10 10s10-4.48 10-10S15.52 0 10 0zm4 7c-.28 0-.53.11-.71.29L9 11.58 6.71 9.29a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l5-5A1.003 1.003 0 0014 7z"],upload:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm4 10c-.28 0-.53-.11-.71-.29L11 7.41V15c0 .55-.45 1-1 1s-1-.45-1-1V7.41l-2.29 2.3a1.003 1.003 0 01-1.42-1.42l4-4c.18-.18.43-.29.71-.29s.53.11.71.29l4 4A1.003 1.003 0 0114 10z"],user:["M10 0C4.48 0 0 4.48 0 10c0 .33.02.65.05.97.01.12.03.23.05.35.03.2.05.4.09.59.03.14.06.28.1.42l.12.48c.05.16.1.31.15.46.05.13.09.27.15.4.06.16.13.32.21.48.05.11.1.22.16.33.09.17.17.34.27.5.05.09.1.17.15.25.11.18.22.35.34.52.04.06.08.11.12.17 1.19 1.62 2.85 2.86 4.78 3.53l.09.03c.46.15.93.27 1.42.36.08.01.17.03.25.04.49.07.99.12 1.5.12s1.01-.05 1.5-.12c.08-.01.17-.02.25-.04.49-.09.96-.21 1.42-.36l.09-.03c1.93-.67 3.59-1.91 4.78-3.53.04-.05.08-.1.12-.16.12-.17.23-.35.34-.53.05-.08.1-.16.15-.25.1-.17.19-.34.27-.51.05-.11.1-.21.15-.32.07-.16.14-.32.21-.49.05-.13.1-.26.14-.39.05-.15.11-.31.15-.46.05-.16.08-.32.12-.48.03-.14.07-.28.1-.42.04-.19.06-.39.09-.59.02-.12.04-.23.05-.35.05-.32.07-.64.07-.97 0-5.52-4.48-10-10-10zm0 18a7.94 7.94 0 01-6.15-2.89c.84-.44 1.86-.82 2.67-1.19 1.45-.65 1.3-1.05 1.35-1.59.01-.07.01-.14.01-.21-.51-.45-.93-1.08-1.2-1.8l-.01-.01c0-.01-.01-.02-.01-.03a4.42 4.42 0 01-.15-.48c-.33-.07-.53-.44-.61-.79-.08-.14-.23-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.63.06-1.55.17-2.15.02-.17.06-.33.11-.5.21-.73.66-1.4 1.26-1.86.62-.47 1.5-.72 2.28-.72.78 0 1.65.25 2.27.73.6.46 1.05 1.12 1.26 1.86.05.16.08.33.11.5.11.6.17 1.51.17 2.15v.09c.22.1.42.33.46.82.04.39-.12.73-.2.87-.07.34-.27.71-.6.78-.04.16-.09.33-.15.48 0 .01-.02.05-.02.05-.26.71-.67 1.33-1.17 1.78 0 .08.01.16.01.23.05.54-.15.94 1.31 1.59.81.36 1.84.74 2.68 1.19A7.958 7.958 0 0110 18z"],variable:["M4.93 3.79a9.1 9.1 0 012.2-2.27L7.29 1c-1.38.59-2.57 1.33-3.55 2.22C2.46 4.39 1.49 5.72.83 7.23.28 8.51 0 9.81 0 11.12c0 2.28.83 4.57 2.49 6.86l.16-.55c-.49-1.23-.73-2.38-.73-3.44 0-1.67.28-3.46.84-5.36.55-1.9 1.28-3.51 2.17-4.84zm9.38 8.39l-.33-.2c-.37.54-.65.87-.82 1a.74.74 0 01-.42.12c-.19 0-.38-.12-.57-.37-.31-.42-.73-1.59-1.26-3.5.47-.85.86-1.41 1.19-1.67.23-.19.48-.29.74-.29.1 0 .28.04.53.11.26.07.48.11.68.11.27 0 .5-.1.68-.29.18-.19.27-.44.27-.75 0-.33-.09-.58-.27-.77-.18-.19-.44-.29-.78-.29-.3 0-.59.07-.86.22s-.61.47-1.02.97c-.31.37-.77 1.02-1.37 1.94a9.683 9.683 0 00-1.24-3.14l-3.24.59-.06.36c.24-.05.44-.07.61-.07.32 0 .59.14.8.43.33.45.8 1.8 1.39 4.07-.47.64-.78 1.06-.96 1.26-.28.32-.52.53-.7.62-.14.08-.3.11-.48.11-.14 0-.36-.08-.67-.23-.21-.1-.4-.15-.57-.15-.31 0-.57.11-.78.32s-.31.48-.31.8c0 .31.09.55.28.75.19.19.44.29.76.29.31 0 .6-.07.87-.2s.61-.42 1.02-.86c.41-.44.98-1.13 1.7-2.08.28.9.52 1.56.72 1.97.2.41.44.71.7.89.26.18.59.27.99.27.38 0 .77-.14 1.17-.43.54-.36 1.07-1 1.61-1.91zM17.51 1l-.15.54c.49 1.24.73 2.39.73 3.45 0 1.43-.21 2.96-.63 4.6-.33 1.26-.75 2.45-1.27 3.55-.52 1.11-1.02 1.97-1.51 2.6-.49.62-1.09 1.2-1.8 1.72l-.17.53c1.38-.59 2.57-1.34 3.55-2.23 1.29-1.17 2.26-2.5 2.91-4 .55-1.28.83-2.59.83-3.91 0-2.27-.83-4.56-2.49-6.85z"],"vertical-bar-chart-asc":["M8 7H7c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zM3 9H2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1zm10-5h-1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm5-4h-1c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"vertical-bar-chart-desc":["M3 0H2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm5 4H7c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm5 3h-1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm5 2h-1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1z"],"vertical-distribution":["M1 2h18c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1zm2 5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1H3zm16 11H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],video:["M19 2H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM7 14V6l6 4-6 4z"],virus:["M15.249 13.835l1.251 1.251.354-.354.087-.077a1 1 0 011.327 1.491l-2.122 2.122-.087.077a1 1 0 01-1.327-1.491l.354-.354-1.251-1.251A6.466 6.466 0 0111 16.424L10.999 18h.501a1 1 0 01.117 1.993L11.5 20h-3a1 1 0 01-.117-1.993L8.5 18h.499v-1.577a6.46 6.46 0 01-2.538-.97L5.414 16.5l.354.354a1 1 0 01-1.327 1.491l-.087-.077-2.122-2.122a1 1 0 011.327-1.491l.087.077.354.354.97-.97a6.472 6.472 0 01-1.384-3.057l-.025.002L2 11.06v.44a1 1 0 01-1.993.117L0 11.5v-3a1 1 0 011.993-.117L2 8.5v.56h1.567A6.471 6.471 0 014.97 5.883l-.971-.969-.353.354-.087.077a1 1 0 01-1.327-1.491l2.122-2.122.087-.077a1 1 0 011.327 1.491l-.354.353 1.047 1.048A6.46 6.46 0 019 3.577L9 2h-.5A1 1 0 018.383.007L8.5 0h3a1 1 0 01.117 1.993L11.5 2H11v1.577a6.466 6.466 0 012.838 1.176l.04-.046L15.086 3.5l-.353-.353a1 1 0 011.327-1.491l.087.077 2.122 2.122a1 1 0 01-1.327 1.491l-.087-.077-.354-.354-1.207 1.207-.046.041a6.467 6.467 0 011.16 2.733H18V8.5a1 1 0 011.993-.117L20 8.5v3a1 1 0 01-1.993.117L18 11.5v-.605h-1.561a6.466 6.466 0 01-1.19 2.94zM12.5 11a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM8 6a2 2 0 100 4 2 2 0 000-4z"],"volume-down":["M15.92 3.93l-1.6 1.18A7.948 7.948 0 0116 10c0 1.84-.63 3.54-1.68 4.89l1.6 1.18A9.878 9.878 0 0018 10c0-2.29-.78-4.39-2.08-6.07zM11 3c-.28 0-.53.11-.71.29L7.59 6H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"volume-off":["M14 3c-.28 0-.53.11-.71.29L10.59 6H6c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"volume-up":["M9 3.43c-.28 0-.53.11-.71.29l-2.7 2.71H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71a1.003 1.003 0 001.71-.71v-12c-.01-.55-.46-1-1.01-1zm8.31-1.56l-1.62 1.2C17.14 5.16 18 7.69 18 10.43s-.86 5.27-2.31 7.37l1.62 1.2C19 16.57 20 13.62 20 10.43c0-3.18-1-6.13-2.69-8.56zm-3.39 2.49l-1.6 1.18A7.948 7.948 0 0114 10.43c0 1.84-.63 3.54-1.68 4.89l1.6 1.18A9.94 9.94 0 0016 10.43c0-2.28-.78-4.38-2.08-6.07z"],walk:["M16 10h-2c-.23 0-.42-.09-.59-.21l-.01.01-1.69-1.27-.63 3.14 2.62 2.62c.19.18.3.43.3.71v4c0 .55-.45 1-1 1s-1-.45-1-1v-3.59L9.39 12.8l-2.45 6.55h-.01c-.14.38-.5.65-.93.65-.55 0-1-.45-1-1 0-.12.03-.24.07-.35h-.01L9.43 7h-2.9l-1.7 2.55-.01-.01c-.18.27-.47.46-.82.46-.55 0-1-.45-1-1 0-.21.08-.39.18-.54l-.01-.01 2-3 .02.01C5.36 5.19 5.65 5 6 5h4.18l.36-.96c-.33-.43-.54-.96-.54-1.54a2.5 2.5 0 015 0A2.5 2.5 0 0112.5 5c-.06 0-.12-.01-.18-.02l-.44 1.18L14.33 8H16c.55 0 1 .45 1 1s-.45 1-1 1z"],"warning-sign":["M19.86 17.52l.01-.01-9-16-.01.01C10.69 1.21 10.37 1 10 1s-.69.21-.86.52l-.01-.01-9 16 .01.01c-.08.14-.14.3-.14.48 0 .55.45 1 1 1h18c.55 0 1-.45 1-1 0-.18-.06-.34-.14-.48zM11 17H9v-2h2v2zm0-3H9V6h2v8z"],"waterfall-chart":["M13 7h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm-9 8h1c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm4-6h2c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm11-5h-1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm0 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],waves:["M4.948 2.682a1 1 0 00-1.897.001l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172C1.958 4.635 1.468 5 .999 5a1 1 0 000 2c1.457 0 2.442-1.027 3-1.825C4.558 5.973 5.543 7 7 7s2.442-1.027 3-1.825C10.558 5.973 11.543 7 13 7s2.442-1.027 3-1.825C16.558 5.973 17.544 7 19 7a1 1 0 100-2c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.896 0l-.006.016a5.868 5.868 0 01-.147.364c-.11.246-.272.568-.481.882C13.958 4.635 13.469 5 13 5c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.897 0l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172C7.958 4.635 7.468 5 6.999 5c-.47 0-.958-.365-1.418-1.055A6.05 6.05 0 014.954 2.7l-.006-.016v-.001zm0 6a1 1 0 00-1.897.001l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172c-.46.69-.95 1.055-1.419 1.055a1 1 0 100 2c1.457 0 2.442-1.027 3-1.825C4.558 11.973 5.543 13 7 13s2.442-1.027 3-1.825c.558.798 1.543 1.825 3 1.825s2.442-1.027 3-1.825c.558.798 1.544 1.825 3 1.825a1 1 0 100-2c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.896 0l-.006.016a5.868 5.868 0 01-.147.364c-.11.246-.272.568-.481.882-.46.69-.949 1.055-1.418 1.055-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.897 0l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172c-.46.69-.95 1.055-1.419 1.055-.47 0-.958-.365-1.418-1.055A6.05 6.05 0 014.954 8.7l-.006-.016zm-1.896-6zm1.896 12l.006.017.027.074a6.053 6.053 0 00.6 1.172c.46.69.95 1.055 1.419 1.055.47 0 .958-.365 1.418-1.055a6.053 6.053 0 00.628-1.246l.005-.016a1 1 0 011.897 0l.006.016.027.074a6.051 6.051 0 00.6 1.172c.46.69.95 1.055 1.419 1.055.47 0 .958-.365 1.418-1.055a6.051 6.051 0 00.628-1.246l.006-.016a1 1 0 011.896 0l.006.016.027.074a6.051 6.051 0 00.6 1.172c.46.69.95 1.055 1.419 1.055a1 1 0 110 2c-1.456 0-2.442-1.027-3-1.825-.558.798-1.543 1.825-3 1.825s-2.442-1.027-3-1.825C9.442 17.973 8.457 19 7 19s-2.442-1.027-3-1.825C3.442 17.973 2.457 19 1 19a1 1 0 110-2c.47 0 .958-.365 1.418-1.055a6.053 6.053 0 00.628-1.246l.005-.016a1 1 0 011.897-.001z"],widget:["M18 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm15-1h2V5h-2v10zM3 5H1v10h2V5zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3 3h10V1H5v2zm13 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM5 19h10v-2H5v2z"],"widget-button":["M1 4h18c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1zm1 2v8h16V6H2zm4 5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"widget-footer":["M17 0H3c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H4v-4h12v4zm0-5H4V2h12v11z"],"widget-header":["M17 0H3c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H4V7h12v11zm0-12H4V2h12v4z"],wind:["M12 6a3 3 0 113 3H4a1 1 0 000 2h11a5 5 0 10-5-5 1 1 0 102 0zM1 12a1 1 0 100 2h10a2 2 0 110 4c-.934 0-1.803-.614-2.057-1.333a1 1 0 10-1.886.666C7.627 18.944 9.321 20 11 20a4 4 0 000-8H1z"],wrench:["M19.8 4.44L16.13 8.1l-3.55-.71-.71-3.53L15.54.21c-2.01-.53-4.23-.03-5.8 1.53-1.86 1.85-2.23 4.6-1.14 6.83L.59 16.59C.22 16.95 0 17.45 0 18a2 2 0 002 2c.55 0 1.05-.22 1.41-.59l8.03-8.04c2.23 1.05 4.97.67 6.82-1.16 1.57-1.56 2.07-3.77 1.54-5.77z"],"zoom-in":["M19.56 17.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm3-7H9V5c0-.55-.45-1-1-1s-1 .45-1 1v2H5c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V9h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"zoom-out":["M11 7H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm8.56 10.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"zoom-to-fit":["M1 7c.55 0 1-.45 1-1V2h4c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1zm5 1a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L4.41 10 5.7 8.71c.19-.18.3-.43.3-.71zm2-2c.28 0 .53-.11.71-.29L10 4.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C10.53 2.11 10.28 2 10 2s-.53.11-.71.29l-2 2A1.003 1.003 0 008 6zM6 18H2v-4c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm8-6a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l1.3 1.29-1.29 1.29c-.19.18-.3.43-.3.71zm5-12h-5c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-7 14c-.28 0-.53.11-.71.29L10 15.59 8.71 14.3A.965.965 0 008 14a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 0012 14zm7-1c-.55 0-1 .45-1 1v4h-4c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1z"]},Ir;(function(e){e[e.STANDARD=16]="STANDARD",e[e.LARGE=20]="LARGE"})(Ir||(Ir={}));var Ja=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n=this.props.icon;if(n==null||typeof n=="boolean")return null;if(typeof n!="string")return n;var r=this.props,o=r.className,s=r.color,i=r.htmlTitle,d=r.iconSize,S=r.intent,g=r.size,w=g===void 0?d??Ir.STANDARD:g,M=r.title,R=r.tagName,V=R===void 0?"span":R,_=kr(r,["className","color","htmlTitle","iconSize","intent","size","title","tagName"]),k=w>=Ir.LARGE?Ir.LARGE:Ir.STANDARD,z=this.renderSvgPaths(k,n),I=vt(dI,fI(n),Gr(S),o),H="0 0 ".concat(k," ").concat(k);return de.createElement(V,Nt(Nt({},_),{"aria-hidden":M?void 0:!0,className:I,title:i}),de.createElement("svg",{fill:s,"data-icon":n,width:w,height:w,viewBox:H},M&&de.createElement("desc",null,M),z))},t.prototype.renderSvgPaths=function(n,r){var o=n===Ir.STANDARD?YS:JS,s=o[r];return s==null?null:s.map(function(i,d){return de.createElement("path",{key:d,d:i,fillRule:"evenodd"})})},t.displayName="".concat(En,".Icon"),t.SIZE_STANDARD=Ir.STANDARD,t.SIZE_LARGE=Ir.LARGE,t=mr([sr],t),t}(vr);function QS(e,t){return function(n){var r=n.className,o=n.elementRef,s=kr(n,["className","elementRef"]);return de.createElement(e,Nt(Nt({},s),{className:vt(t,r),ref:o}))}}var qS=QS("h6",Kb),ex=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n=this.props,r=n.className,o=n.title;return o==null?de.createElement("li",{className:vt(Qb,r)}):de.createElement("li",{className:vt(qb,r)},de.createElement(qS,null,o))},t.displayName="".concat(En,".MenuDivider"),t}(de.Component),tx=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.state={isContentOverflowing:!1,textContent:""},n.textRef=null,n}return t.prototype.componentDidMount=function(){this.update()},t.prototype.componentDidUpdate=function(){this.update()},t.prototype.render=function(){var n,r=this,o=this.props,s=o.children,i=o.className,d=o.ellipsize,S=o.tagName,g=S===void 0?"div":S,w=o.title,M=kr(o,["children","className","ellipsize","tagName","title"]),R=vt(i,(n={},n[Zb]=d,n));return de.createElement(g,Nt(Nt({},M),{className:R,ref:function(V){return r.textRef=V},title:w??(this.state.isContentOverflowing?this.state.textContent:void 0)}),s)},t.prototype.update=function(){var n;if(((n=this.textRef)===null||n===void 0?void 0:n.textContent)!=null){var r={isContentOverflowing:this.props.ellipsize&&this.textRef.scrollWidth>this.textRef.clientWidth,textContent:this.textRef.textContent};this.setState(r)}},t.displayName="".concat(En,".Text"),t.defaultProps={ellipsize:!1},t=mr([sr],t),t}(vr),nx=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n,r,o=this.props,s=o.active,i=o.className,d=o.children,S=o.disabled,g=o.icon,w=o.intent;o.labelClassName;var M=o.labelElement,R=o.multiline;o.popoverProps;var V=o.shouldDismissPopover,_=o.text,k=o.textClassName,z=o.tagName,I=z===void 0?"a":z,H=o.htmlTitle,A=kr(o,["active","className","children","disabled","icon","intent","labelClassName","labelElement","multiline","popoverProps","shouldDismissPopover","text","textClassName","tagName","htmlTitle"]),x=d!=null,p=Gr(w),v=vt(K5,p,(n={},n[G5]=s,n[jb]=s&&p==null,n[oc]=S,n[B1]=V&&!S&&!x,n),i),y=de.createElement(I,Nt(Nt(Nt({tabIndex:0},A),S?ix:{}),{className:v}),de.createElement(Ja,{icon:g,"aria-hidden":!0,tabIndex:-1}),de.createElement(tx,{className:vt(sc,k),ellipsize:!R,title:H},_),this.maybeRenderLabel(M),x?de.createElement(Ja,{title:"Open sub menu",icon:"caret-right"}):void 0),a=vt((r={},r[nu]=x,r));return de.createElement("li",{className:a},this.maybeRenderPopover(y,d))},t.prototype.maybeRenderLabel=function(n){var r=this.props,o=r.label,s=r.labelClassName;return o==null&&n==null?null:de.createElement("span",{className:vt(Jb,s)},o,n)},t.prototype.maybeRenderPopover=function(n,r){if(r==null)return n;var o=this.props,s=o.disabled,i=o.popoverProps;return de.createElement(X2,Nt({autoFocus:!1,captureDismiss:!1,disabled:s,enforceFocus:!1,hoverCloseDelay:0,interactionKind:ur.HOVER,modifiers:rx,position:Pn.RIGHT_TOP,usePortal:!1},i,{content:de.createElement(Y2,null,r),minimal:!0,popoverClassName:vt(nu,i==null?void 0:i.popoverClassName),target:n}))},t.defaultProps={disabled:!1,multiline:!1,popoverProps:{},shouldDismissPopover:!0,text:""},t.displayName="".concat(En,".MenuItem"),t=mr([sr],t),t}(vr),rx={flip:{boundariesElement:"viewport",padding:20},offset:{offset:-5},preventOverflow:{boundariesElement:"viewport",padding:20}},ix={href:void 0,onClick:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,tabIndex:-1},Y2=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n,r=this.props,o=r.className,s=r.children,i=r.large,d=r.ulRef,S=kr(r,["className","children","large","ulRef"]),g=vt(vs,(n={},n[j5]=i,n),o);return de.createElement("ul",Nt({},S,{className:g,ref:d}),s)},t.displayName="".concat(En,".Menu"),t.Divider=ex,t.Item=nx,t=mr([sr],t),t}(vr),ox=function(e){wn(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.state={hasPendingUpdate:!1,isComposing:!1,nextValue:r.props.value,value:r.props.value},r.cancelPendingCompositionEnd=null,r.handleCompositionStart=function(o){var s,i,d;(s=r.cancelPendingCompositionEnd)===null||s===void 0||s.call(r),r.setState({isComposing:!0}),(d=(i=r.props).onCompositionStart)===null||d===void 0||d.call(i,o)},r.handleCompositionEnd=function(o){var s,i;r.cancelPendingCompositionEnd=r.setTimeout(function(){return r.setState({isComposing:!1})},n.COMPOSITION_END_DELAY),(i=(s=r.props).onCompositionEnd)===null||i===void 0||i.call(s,o)},r.handleChange=function(o){var s,i,d=o.target.value;r.setState({nextValue:d}),(i=(s=r.props).onChange)===null||i===void 0||i.call(s,o)},r}n=t,t.getDerivedStateFromProps=function(r,o){if(o.isComposing||r.value===void 0)return null;var s=o.nextValue!==o.value;return s?r.value===o.nextValue?o.hasPendingUpdate?{value:r.value,hasPendingUpdate:!1}:{value:o.nextValue}:r.value===o.value?{hasPendingUpdate:!0}:{value:r.value,nextValue:r.value,hasPendingUpdate:!1}:{value:r.value,nextValue:r.value,hasPendingUpdate:!1}},t.prototype.render=function(){var r=this.state,o=r.isComposing,s=r.hasPendingUpdate,i=r.value,d=r.nextValue,S=this.props,g=S.inputRef,w=kr(S,["inputRef"]);return de.createElement("input",Nt({},w,{ref:g,value:o||s?d:i,onCompositionStart:this.handleCompositionStart,onCompositionEnd:this.handleCompositionEnd,onChange:this.handleChange}))};var n;return t.displayName="".concat(En,".AsyncControllableInput"),t.COMPOSITION_END_DELAY=10,t=n=mr([sr],t),t}(vr),sx=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.state={},n.leftElement=null,n.rightElement=null,n.refHandlers={leftElement:function(r){return n.leftElement=r},rightElement:function(r){return n.rightElement=r}},n}return t.prototype.render=function(){var n,r=this.props,o=r.asyncControl,s=o===void 0?!1:o,i=r.className,d=r.disabled,S=r.fill,g=r.inputRef,w=r.intent,M=r.large,R=r.small,V=r.round,_=vt(Ub,Gr(w),(n={},n[oc]=d,n[sc]=S,n[j5]=M,n[Gb]=R,n[Wb]=V,n),i),k=Nt(Nt({},this.props.style),{paddingLeft:this.state.leftElementWidth,paddingRight:this.state.rightElementWidth}),z=Nt(Nt({type:"text"},PI(this.props)),{className:ms,style:k});return de.createElement("div",{className:_},this.maybeRenderLeftElement(),s?de.createElement(ox,Nt({},z,{inputRef:g})):de.createElement("input",Nt({},z,{ref:g})),this.maybeRenderRightElement())},t.prototype.componentDidMount=function(){this.updateInputWidth()},t.prototype.componentDidUpdate=function(n){var r=this.props,o=r.leftElement,s=r.rightElement;(n.leftElement!==o||n.rightElement!==s)&&this.updateInputWidth()},t.prototype.validateProps=function(n){n.leftElement!=null&&n.leftIcon!=null&&console.warn(II)},t.prototype.maybeRenderLeftElement=function(){var n=this.props,r=n.leftElement,o=n.leftIcon;if(r!=null)return de.createElement("span",{className:Xb,ref:this.refHandlers.leftElement},r);if(o!=null)return de.createElement(Ja,{icon:o,"aria-hidden":!0,tabIndex:-1})},t.prototype.maybeRenderRightElement=function(){var n=this.props.rightElement;if(n!=null)return de.createElement("span",{className:Yb,ref:this.refHandlers.rightElement},n)},t.prototype.updateInputWidth=function(){var n=this.state,r=n.leftElementWidth,o=n.rightElementWidth;if(this.leftElement!=null){var s=this.leftElement.clientWidth;(r===void 0||Math.abs(s-r)>2)&&this.setState({leftElementWidth:s})}else this.setState({leftElementWidth:void 0});if(this.rightElement!=null){var s=this.rightElement.clientWidth;(o===void 0||Math.abs(s-o)>2)&&this.setState({rightElementWidth:s})}else this.setState({rightElementWidth:void 0})},t.displayName="".concat(En,".InputGroup"),t=mr([sr],t),t}(vr),ax=pI(),J2="".concat(ax,"-omnibar"),lx="".concat(J2,"-overlay");function cx(e,t,n){if(e.query.length===0&&n!==void 0)return n;var r=e.filteredItems.map(e.renderItem).filter(function(o){return o!=null});return r.length>0?r:t}function h1(e,t,n){return e===void 0||t==null||n==null?t===n:hi(e)?e(t,n):t[e]===n[e]}function rh(){return{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}}function Ai(e){if(e==null)return!1;var t=Object.keys(e);return t.length!==1||t[0]!=="__blueprintCreateNewItemBrand"?!1:e.__blueprintCreateNewItemBrand==="blueprint-create-new-item"}function d1(e){return e==null||Ai(e)?null:e}var ux=function(e){wn(t,e);function t(n,r){var o=this,s,i;o=e.call(this,n,r)||this,o.refHandlers={itemsParent:function(M){return o.itemsParentRef=M}},o.shouldCheckActiveItemInViewport=!1,o.expectedNextActiveItem=null,o.isEnterKeyPressed=!1,o.renderItemList=function(M){var R=o.props,V=R.initialContent,_=R.noResults,k=M.renderCreateItem(),z=k!=null?null:_,I=cx(M,z,V);if(I==null&&k==null)return null;var H=o.isCreateItemFirst();return de.createElement(Y2,{ulRef:M.itemsParentRef},H&&k,I,!H&&k)},o.renderItem=function(M,R){if(o.props.disabled!==!0){var V=o.state,_=V.activeItem,k=V.query,z=o.state.filteredItems.indexOf(M)>=0,I={active:h1(o.props.itemsEqual,d1(_),M),disabled:Qa(M,R,o.props.itemDisabled),matchesPredicate:z};return o.props.itemRenderer(M,{handleClick:function(H){return o.handleItemSelect(M,H)},index:R,modifiers:I,query:k})}return null},o.renderCreateItemMenuItem=function(){if(o.isCreateItemRendered()){var M=o.state,R=M.activeItem,V=M.query,_=V.trim(),k=function(I){o.handleItemCreate(_,I)},z=Ai(R);return o.props.createNewItemRenderer(_,z,k)}return null},o.handleItemCreate=function(M,R){var V,_,k,z,I=(_=(V=o.props).createNewItemFromQuery)===null||_===void 0?void 0:_.call(V,M);I!=null&&((z=(k=o.props).onItemSelect)===null||z===void 0||z.call(k,I,R),o.maybeResetQuery())},o.handleItemSelect=function(M,R){var V,_;o.setActiveItem(M),(_=(V=o.props).onItemSelect)===null||_===void 0||_.call(V,M,R),o.maybeResetQuery()},o.handlePaste=function(M){for(var R=o.props,V=R.createNewItemFromQuery,_=R.onItemsPaste,k,z=[],I=[],H=0,A=M;H=g+w?this.itemsParentRef.scrollTop=_+i-w:k<=g&&(this.itemsParentRef.scrollTop=k-i)}}},t.prototype.setQuery=function(n,r,o){var s;r===void 0&&(r=this.props.resetOnQuery),o===void 0&&(o=this.props);var i=o.createNewItemFromQuery;this.shouldCheckActiveItemInViewport=!0;var d=n!==this.state.query;d&&((s=o.onQueryChange)===null||s===void 0||s.call(o,n));var S=n.trim(),g=oh(S,o),w=i!=null&&S!==""?i(S):void 0;this.setState({createNewItem:w,filteredItems:g,query:n});var M=this.getActiveIndex(g),R=r||M<0||Qa(d1(this.state.activeItem),M,o.itemDisabled);R&&(this.isCreateItemRendered()&&this.isCreateItemFirst()?this.setActiveItem(rh()):this.setActiveItem(aa(g,o.itemDisabled)))},t.prototype.setActiveItem=function(n){var r,o,s,i;this.expectedNextActiveItem=n,this.props.activeItem===void 0&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:n})),Ai(n)?(o=(r=this.props).onActiveItemChange)===null||o===void 0||o.call(r,null,!0):(i=(s=this.props).onActiveItemChange)===null||i===void 0||i.call(s,n,!1)},t.prototype.getActiveElement=function(){var n=this.state.activeItem;if(this.itemsParentRef!=null)if(Ai(n)){var r=this.isCreateItemFirst()?0:this.state.filteredItems.length;return this.itemsParentRef.children.item(r)}else{var o=this.getActiveIndex();return this.itemsParentRef.children.item(o)}},t.prototype.getActiveIndex=function(n){n===void 0&&(n=this.state.filteredItems);var r=this.state.activeItem;if(r==null||Ai(r))return-1;for(var o=0;on?t:e}function Qa(e,t,n){return n==null||e==null?!1:hi(n)?n(e,t):!!e[n]}function aa(e,t,n,r){if(n===void 0&&(n=1),r===void 0&&(r=e.length-1),e.length===0)return null;var o=r,s=e.length-1;do if(o=dx(o+n,0,s),!Qa(e[o],o,t))return e[o];while(o!==r&&r!==-1);return null}var px=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.TypedQueryList=ux.ofType(),n.renderQueryList=function(r){var o=n.props,s=o.inputProps,i=s===void 0?{}:s,d=o.isOpen,S=o.overlayProps,g=S===void 0?{}:S,w=r.handleKeyDown,M=r.handleKeyUp,R=d?{onKeyDown:w,onKeyUp:M}:{};return de.createElement(B2,Nt({hasBackdrop:!0},g,{isOpen:d,className:vt(lx,g.className),onClose:n.handleOverlayClose}),de.createElement("div",Nt({className:vt(J2,r.className)},R),de.createElement(sx,Nt({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},i,{onChange:r.handleQueryChange,value:r.query})),r.itemList))},n.handleOverlayClose=function(r){var o,s,i,d;(s=(o=n.props.overlayProps)===null||o===void 0?void 0:o.onClose)===null||s===void 0||s.call(o,r),(d=(i=n.props).onClose)===null||d===void 0||d.call(i,r)},n}return t.ofType=function(){return t},t.prototype.render=function(){var n=this.props;n.isOpen,n.inputProps,n.overlayProps;var r=kr(n,["isOpen","inputProps","overlayProps"]),o="initialContent"in this.props?this.props.initialContent:null;return de.createElement(this.TypedQueryList,Nt({},r,{initialContent:o,renderer:this.renderQueryList}))},t.displayName="".concat(En,".Omnibar"),t}(de.PureComponent);function Er(e){return Array.isArray?Array.isArray(e):ep(e)==="[object Array]"}const fx=1/0;function gx(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-fx?"-0":t}function mx(e){return e==null?"":gx(e)}function pr(e){return typeof e=="string"}function Q2(e){return typeof e=="number"}function vx(e){return e===!0||e===!1||yx(e)&&ep(e)=="[object Boolean]"}function q2(e){return typeof e=="object"}function yx(e){return q2(e)&&e!==null}function $n(e){return e!=null}function la(e){return!e.trim().length}function ep(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Cx="Incorrect 'index' type",bx=e=>`Invalid value for key ${e}`,Ix=e=>`Pattern length exceeds max of ${e}.`,wx=e=>`Missing ${e} property in key`,Ax=e=>`Property 'weight' in key '${e}' must be a positive integer`,sh=Object.prototype.hasOwnProperty;class Sx{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=tp(r);n+=o.weight,this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function tp(e){let t=null,n=null,r=null,o=1,s=null;if(pr(e)||Er(e))r=e,t=ah(e),n=qa(e);else{if(!sh.call(e,"name"))throw new Error(wx("name"));const i=e.name;if(r=i,sh.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(Ax(i));t=ah(i),n=qa(i),s=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:s}}function ah(e){return Er(e)?e:e.split(".")}function qa(e){return Er(e)?e.join("."):e}function xx(e,t){let n=[],r=!1;const o=(s,i,d)=>{if($n(s))if(!i[d])n.push(s);else{let S=i[d];const g=s[S];if(!$n(g))return;if(d===i.length-1&&(pr(g)||Q2(g)||vx(g)))n.push(mx(g));else if(Er(g)){r=!0;for(let w=0,M=g.length;we.score===t.score?e.idx{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,pr(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();pr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,r=this.size();n{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if($n(i)){if(Er(i)){let d=[];const S=[{nestedArrIndex:-1,value:i}];for(;S.length;){const{nestedArrIndex:g,value:w}=S.pop();if($n(w))if(pr(w)&&!la(w)){let M={v:w,i:g,n:this.norm.get(w)};d.push(M)}else Er(w)&&w.forEach((M,R)=>{S.push({nestedArrIndex:R,value:M})})}r.$[s]=d}else if(pr(i)&&!la(i)){let d={v:i,n:this.norm.get(i)};r.$[s]=d}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function np(e,t,{getFn:n=Tt.getFn,fieldNormWeight:r=Tt.fieldNormWeight}={}){const o=new yc({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(tp)),o.setSources(t),o.create(),o}function Rx(e,{getFn:t=Tt.getFn,fieldNormWeight:n=Tt.fieldNormWeight}={}){const{keys:r,records:o}=e,s=new yc({getFn:t,fieldNormWeight:n});return s.setKeys(r),s.setIndexRecords(o),s}function p1(e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=Tt.distance,ignoreLocation:s=Tt.ignoreLocation}={}){const i=t/e.length;if(s)return i;const d=Math.abs(r-n);return o?i+d/o:d?1:i}function Hx(e=[],t=Tt.minMatchCharLength){let n=[],r=-1,o=-1,s=0;for(let i=e.length;s=t&&n.push([r,o]),r=-1)}return e[s-1]&&s-r>=t&&n.push([r,s-1]),n}const ti=32;function Vx(e,t,n,{location:r=Tt.location,distance:o=Tt.distance,threshold:s=Tt.threshold,findAllMatches:i=Tt.findAllMatches,minMatchCharLength:d=Tt.minMatchCharLength,includeMatches:S=Tt.includeMatches,ignoreLocation:g=Tt.ignoreLocation}={}){if(t.length>ti)throw new Error(Ix(ti));const w=t.length,M=e.length,R=Math.max(0,Math.min(r,M));let V=s,_=R;const k=d>1||S,z=k?Array(M):[];let I;for(;(I=e.indexOf(t,_))>-1;){let y=p1(t,{currentLocation:I,expectedLocation:R,distance:o,ignoreLocation:g});if(V=Math.min(y,V),_=I+w,k){let a=0;for(;a=u;c-=1){let f=c-1,C=n[e.charAt(f)];if(k&&(z[f]=+!!C),m[c]=(m[c+1]<<1|1)&C,y&&(m[c]|=(H[c+1]|H[c])<<1|1|H[c+1]),m[c]&p&&(A=p1(t,{errors:y,currentLocation:f,expectedLocation:R,distance:o,ignoreLocation:g}),A<=V)){if(V=A,_=f,_<=R)break;u=Math.max(1,2*R-_)}}if(p1(t,{errors:y+1,currentLocation:R,expectedLocation:R,distance:o,ignoreLocation:g})>V)break;H=m}const v={isMatch:_>=0,score:Math.max(.001,A)};if(k){const y=Hx(z,d);y.length?S&&(v.indices=y):v.isMatch=!1}return v}function _x(e){let t={};for(let n=0,r=e.length;n{this.chunks.push({pattern:R,alphabet:_x(R),startIndex:V})},M=this.pattern.length;if(M>ti){let R=0;const V=M%ti,_=M-V;for(;R<_;)w(this.pattern.substr(R,ti),R),R+=ti;if(V){const k=M-ti;w(this.pattern.substr(k),k)}}else w(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,includeMatches:r}=this.options;if(n||(t=t.toLowerCase()),this.pattern===t){let _={isMatch:!0,score:0};return r&&(_.indices=[[0,t.length-1]]),_}const{location:o,distance:s,threshold:i,findAllMatches:d,minMatchCharLength:S,ignoreLocation:g}=this.options;let w=[],M=0,R=!1;this.chunks.forEach(({pattern:_,alphabet:k,startIndex:z})=>{const{isMatch:I,score:H,indices:A}=Vx(t,_,k,{location:o+z,distance:s,threshold:i,findAllMatches:d,minMatchCharLength:S,includeMatches:r,ignoreLocation:g});I&&(R=!0),M+=H,I&&A&&(w=[...w,...A])});let V={isMatch:R,score:R?M/this.chunks.length:1};return R&&r&&(V.indices=w),V}}class jr{constructor(t){this.pattern=t}static isMultiMatch(t){return lh(t,this.multiRegex)}static isSingleMatch(t){return lh(t,this.singleRegex)}search(){}}function lh(e,t){const n=e.match(t);return n?n[1]:null}class Nx extends jr{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Ox extends jr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class Px extends jr{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Dx extends jr{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class $x extends jr{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Bx extends jr{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ip extends jr{constructor(t,{location:n=Tt.location,threshold:r=Tt.threshold,distance:o=Tt.distance,includeMatches:s=Tt.includeMatches,findAllMatches:i=Tt.findAllMatches,minMatchCharLength:d=Tt.minMatchCharLength,isCaseSensitive:S=Tt.isCaseSensitive,ignoreLocation:g=Tt.ignoreLocation}={}){super(t),this._bitapSearch=new rp(t,{location:n,threshold:r,distance:o,includeMatches:s,findAllMatches:i,minMatchCharLength:d,isCaseSensitive:S,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class op extends jr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,r;const o=[],s=this.pattern.length;for(;(r=t.indexOf(this.pattern,n))>-1;)n=r+s,o.push([r,n-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const el=[Nx,op,Px,Dx,Bx,$x,Ox,ip],ch=el.length,Fx=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Wx="|";function Gx(e,t={}){return e.split(Wx).map(n=>{let r=n.trim().split(Fx).filter(s=>s&&!!s.trim()),o=[];for(let s=0,i=r.length;s!!(e[j1.AND]||e[j1.OR]),Ux=e=>!!e[rl.PATH],Xx=e=>!Er(e)&&q2(e)&&!il(e),uh=e=>({[j1.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function sp(e,t,{auto:n=!0}={}){const r=o=>{let s=Object.keys(o);const i=Ux(o);if(!i&&s.length>1&&!il(o))return r(uh(o));if(Xx(o)){const S=i?o[rl.PATH]:s[0],g=i?o[rl.PATTERN]:o[S];if(!pr(g))throw new Error(bx(S));const w={keyId:qa(S),pattern:g};return n&&(w.searcher=nl(g,t)),w}let d={children:[],operator:s[0]};return s.forEach(S=>{const g=o[S];Er(g)&&g.forEach(w=>{d.children.push(r(w))})}),d};return il(e)||(e=uh(e)),r(e)}function Yx(e,{ignoreFieldNorm:t=Tt.ignoreFieldNorm}){e.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:s,score:i})=>{const d=o?o.weight:null;r*=Math.pow(i===0&&d?Number.EPSILON:i,(d||1)*(t?1:s))}),n.score=r})}function Jx(e,t){const n=e.matches;t.matches=[],$n(n)&&n.forEach(r=>{if(!$n(r.indices)||!r.indices.length)return;const{indices:o,value:s}=r;let i={indices:o,value:s};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function Qx(e,t){t.score=e.score}function qx(e,t,{includeMatches:n=Tt.includeMatches,includeScore:r=Tt.includeScore}={}){const o=[];return n&&o.push(Jx),r&&o.push(Qx),e.map(s=>{const{idx:i}=s,d={item:t[i],refIndex:i};return o.length&&o.forEach(S=>{S(s,d)}),d})}class ji{constructor(t,n={},r){this.options={...Tt,...n},this.options.useExtendedSearch,this._keyStore=new Sx(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof yc))throw new Error(Cx);this._myIndex=n||np(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){$n(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let r=0,o=this._docs.length;r-1&&(S=S.slice(0,n)),qx(S,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=nl(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:s,i,n:d})=>{if(!$n(s))return;const{isMatch:S,score:g,indices:w}=n.searchIn(s);S&&o.push({item:s,idx:i,matches:[{score:g,value:s,norm:d,indices:w}]})}),o}_searchLogical(t){const n=sp(t,this.options),r=(d,S,g)=>{if(!d.children){const{keyId:M,searcher:R}=d,V=this._findMatches({key:this._keyStore.get(M),value:this._myIndex.getValueForItemAtKeyId(S,M),searcher:R});return V&&V.length?[{idx:g,item:S,matches:V}]:[]}const w=[];for(let M=0,R=d.children.length;M{if($n(d)){let g=r(n,d,S);g.length&&(s[S]||(s[S]={idx:S,item:d,matches:[]},i.push(s[S])),g.forEach(({matches:w})=>{s[S].matches.push(...w)}))}}),i}_searchObjectList(t){const n=nl(t,this.options),{keys:r,records:o}=this._myIndex,s=[];return o.forEach(({$:i,i:d})=>{if(!$n(i))return;let S=[];r.forEach((g,w)=>{S.push(...this._findMatches({key:g,value:i[w],searcher:n}))}),S.length&&s.push({idx:d,item:i,matches:S})}),s}_findMatches({key:t,value:n,searcher:r}){if(!$n(n))return[];let o=[];if(Er(n))n.forEach(({v:s,i,n:d})=>{if(!$n(s))return;const{isMatch:S,score:g,indices:w}=r.searchIn(s);S&&o.push({score:g,key:t,value:s,idx:i,norm:d,indices:w})});else{const{v:s,n:i}=n,{isMatch:d,score:S,indices:g}=r.searchIn(s);d&&o.push({score:S,key:t,value:s,norm:i,indices:g})}return o}}ji.version="6.6.2";ji.createIndex=np;ji.parseIndex=Rx;ji.config=Tt;ji.parseQuery=sp;Kx(Zx);const Z1=Object.values(sl),hh=Z1.map(e=>mt[e]||xd[e]).map((e,t)=>e?e.split("|").reverse()[0]:Z1[t]),eM=({onClose:e})=>{const t=de.useRef(new ji(hh)),[n,r]=de.useState("");li("Enter");const o=de.useMemo(()=>{const s=t.current.search(n);return s.length>0?s:hh.map((i,d)=>({item:i,refIndex:d}))},[n]);return se.jsx(px,{isOpen:!0,itemsEqual:(s,i)=>s.refIndex===i.refIndex,items:o,itemRenderer:(s,i)=>se.jsxs("div",{className:vt(eu.semanticSelectItem,{[eu.semanticSelectItemActive]:i.modifiers.active}),onClick:()=>{e(Z1[s.refIndex])},children:[se.jsx("svg",{style:{width:"80px",height:"80px"},viewBox:"0 0 10 10",onClick:()=>{},children:se.jsx("g",{transform:"translate(5, 5)",children:se.jsx("use",{color:"black",fill:"black",xlinkHref:`#score-token-def-${s.item}`})})}),se.jsx("div",{children:Z1[s.refIndex]})]},s.refIndex),onItemSelect:()=>{},onQueryChange:s=>{r(s)},onClose:()=>{e()}})},tM=e=>{var n;if(!((n=e==null?void 0:e.extension)!=null&&n.text))return null;const t=Math.max(Math.ceil(e.extension.width*4/e.extension.height),3);return e.extension.text.length>t?e.extension.text.substring(0,t-2)+"...":e.extension.text},nM=({score:e,pageIndex:t,show:n,width:r,height:o})=>{var m,l,c,f;const s=e.pages[t],[i,d]=pi(),[S,g]=ml(),[w,M]=de.useState({x:-10,y:-10}),[R]=Y1(),[V,_]=cl(),[k]=li("Shift"),[z,I]=de.useState(!1),H=de.useRef(null),[A]=dl(),[x]=pl();de.useState(!1);const[p,v]=de.useState(null);if(!s)return null;const y=5/R,[a,h]=de.useState([null,null,null,null]),u=de.useMemo(()=>{if(!V)return null;let C=null;return s.systems.forEach(T=>{var L;T.staves.forEach(O=>{var P;(P=O.semantics)!=null&&P.some(F=>F.id===(V==null?void 0:V.point.id))&&(C={x:(V==null?void 0:V.point.x)+T.left,y:(V==null?void 0:V.point.y)+O.top+O.staffY+T.top})}),(L=T.semantics)!=null&&L.some(O=>O.id===(V==null?void 0:V.point.id))&&(C={x:(V==null?void 0:V.point.x)+T.left,y:(V==null?void 0:V.point.y)+T.top})}),C},[V]),b=C=>{v(null),C.target.value!==p.token.text&&(e.textAnnotations=e.textAnnotations||{},e.textAnnotations[p.token.id]=C.target.value,e.assemble(),d(Pt(e,{modify:!0})))};return se.jsxs(se.Fragment,{children:[se.jsxs("svg",{className:vt("graph",{}),style:{objectFit:"contain"},viewBox:`0 0 ${r} ${o}`,onContextMenu:C=>{const T=so(C.currentTarget,B=>B.nodeName==="svg"),L=T.createSVGPoint();L.x=C.clientX,L.y=C.clientY;const O=T.getScreenCTM(),P=L.matrixTransform(O.inverse());if(k){if(C.preventDefault(),C.stopPropagation(),a&&a.slice(0,3).every(Number.isFinite)){const B=e.pages[a[0]].systems[a[1]],W=B.staves[a[2]];if(W){const Q=P.x-B.left,j=P.y-B.top-W.top-W.staffY;console.debug("xy:",a,Q,j,B),H.current={x:Q,y:j,pointer:[...a]}}}I(!0);return}const F=[];s.systems.forEach(B=>{B.staves.forEach(W=>{W.semantics&&F.push(...W.semantics.filter(Q=>Ec({x:P.x,y:P.y},{x:Q.x+B.left,y:Q.y+W.top+W.staffY+B.top},y)))}),B.semantics&&F.push(...B.semantics.filter(W=>Ec({x:P.x,y:P.y},{x:W.x+B.left,y:W.y+B.top})))}),M({x:P.x,y:P.y}),F.sort((B,W)=>W.confidence-B.confidence),g(F)},onClick:()=>_(null),children:[S.length>0&&se.jsx("circle",{cx:w.x,cy:w.y,r:y,strokeWidth:"0.1",stroke:"black",strokeDasharray:"0.2 0.2",fill:"transparent"}),n&&((m=s==null?void 0:s.systems)==null?void 0:m.map((C,T)=>se.jsx($b,{score:e,page:s,pageIndex:t,system:C,systemIndex:T,pointer:a,setPointer:h},T))),u&&se.jsxs("g",{children:[se.jsxs("circle",{id:`anchor-${V==null?void 0:V.point.id}`,cx:u.x,cy:u.y,r:"0",fillOpacity:"0",stroke:"#f44336",strokeWidth:"0.4",strokeOpacity:"1",children:[se.jsx("animate",{attributeName:"r",from:"0",to:y,dur:"1.5s",repeatCount:"indefinite",begin:"0s"}),se.jsx("animate",{attributeName:"stroke-opacity",from:"1",to:"0",dur:"1.5s",repeatCount:"indefinite",begin:"0s"})]}),se.jsxs("circle",{id:`anchor-${V==null?void 0:V.point.id}`,cx:u.x,cy:u.y,r:"0",fillOpacity:"0",stroke:"#f44336",strokeWidth:"0.4",strokeOpacity:"1",children:[se.jsx("animate",{attributeName:"r",from:"0",to:y,dur:"1.5s",repeatCount:"indefinite",begin:"0.5s"}),se.jsx("animate",{attributeName:"stroke-opacity",from:"1",to:"0",dur:"1.5s",repeatCount:"indefinite",begin:"0.5s"})]})]}),n&&A&&(s==null?void 0:s.semantics)&&se.jsx("g",{children:(l=s==null?void 0:s.semantics)==null?void 0:l.map((C,T)=>{var L,O,P,F,B,W,Q,j,E;if(C.semantic===sl.rect_Text)return se.jsxs("g",{transform:`translate(${C.x}, ${C.y}) ${(L=C.extension)!=null&&L.theta?`rotate(${((O=C.extension)==null?void 0:O.theta)*180/Math.PI})`:""}`,color:"rgba(25, 175, 230, 0.6)",className:"semantic",onClick:()=>console.log(C),children:[se.jsx("rect",{x:-((P=C.extension)==null?void 0:P.width)/2,y:-((F=C.extension)==null?void 0:F.height)/2,width:(B=C.extension)==null?void 0:B.width,height:(W=C.extension)==null?void 0:W.height}),se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-((Q=C.extension)==null?void 0:Q.height)/2,textAnchor:"middle",style:{fontSize:(j=C.extension)==null?void 0:j.height},children:[tM(C),se.jsx("title",{children:((E=C.extension)==null?void 0:E.type)||C.semantic})]})]},T)})}),n&&x&&(s==null?void 0:s.tokens)&&se.jsx("g",{children:(c=s==null?void 0:s.tokens)==null?void 0:c.map((C,T)=>{var L;if(C.type===mt.Text)return se.jsx("g",{transform:`translate(${C.x}, ${C.y})`,color:"rgba(25, 175, 230, 0.6)",className:"token",children:se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-C.fontSize/2,textAnchor:"middle",style:{fontSize:C.fontSize},className:vt({[C.textType]:!0,annotated:(L=e==null?void 0:e.textAnnotations)==null?void 0:L[C.id]}),onClick:O=>{const P=so(O.currentTarget,W=>W.nodeName==="svg"),F=O.currentTarget.getBoundingClientRect(),B=P.getBoundingClientRect();v({token:C,left:F.left-B.left,top:F.top-B.top,width:F.width,height:F.height})},children:[C.text,se.jsx("title",{children:C.textType})]})},T)})}),n&&x&&((f=s==null?void 0:s.systems)==null?void 0:f.map((C,T)=>{var L;return se.jsx("g",{transform:`translate(${C.left}, ${C.top})`,children:(L=C.tokens)==null?void 0:L.filter(O=>O.type===mt.Text&&!["Chord"].includes(O.textType)).map((O,P)=>{var F;return se.jsx("g",{transform:`translate(${O.x}, ${O.y})`,className:"token",children:se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-O.fontSize/2,textAnchor:"middle",style:{fontSize:O.fontSize},className:vt({[O.textType]:!0,annotated:(F=e==null?void 0:e.textAnnotations)==null?void 0:F[O.id]}),onClick:B=>{const W=so(B.currentTarget,E=>E.nodeName==="svg"),Q=B.currentTarget.getBoundingClientRect(),j=W.getBoundingClientRect();v({token:O,left:Q.left-j.left,top:Q.top-j.top,width:Q.width,height:Q.height})},children:[O.text,se.jsx("title",{children:O.textType})]})},P)})},T)}))]}),z&&se.jsx(eM,{onClose:C=>{if(C&&H.current){const{x:T,y:L,pointer:O}=H.current;e.pages[O[0]].systems[O[1]].newPoint(O[2],{x:T,y:L,semantic:C}),d(Pt(e,{modify:!0}))}I(!1)}}),p&&se.jsx(Hr,{autoFocus:!0,style:{position:"absolute",left:p.left-10+"px",top:p.top+"px",width:p.width+20+"px",height:p.height+"px",zIndex:100,fontSize:p.height*.8+"px"},defaultValue:p.token.text,onBlur:b,onPressEnter:b})]})},rM=de.memo(nM);const f1=Object.freeze({unit:"%",x:0,y:0,width:0,height:0}),iM=de.forwardRef(({pageIndex:e,onSeekPosition:t,disableScoreLevelControls:n=!1,disableRecognization:r=!1},o)=>{var K,X,Y,oe,ce,re,fe,U,q,ee,D,$,G,J,ne,me,Le,_e,De,Fe,Ze;const s=zr(),[i]=Y1(),[d,S]=pi(),g=de.useRef(null),w=de.useRef(null),[M,R]=de.useState(!1),[V,_]=de.useState(!1),[k,z]=de.useState(null),[I,H]=de.useState(!0),A=de.useRef(null),[x]=gl(),[p,v]=de.useState([null,null,null,null]),y=de.useRef(!1),a=(K=d==null?void 0:d.pages)==null?void 0:K[e],[h,u]=de.useState(f1),[b]=li(navigator.userAgent.indexOf("Mac")>=0?"Alt":"Control"),[m]=li("Escape"),[l,c]=ml(),[f,C]=Ch(),T=wf(),L=Zf(A,{root:null,rootMargin:"0px",threshold:0}),O=de.useMemo(()=>d.pages.length<10?!0:!L||(L==null?void 0:L.isIntersecting),[d,L]),P=de.useRef({break:!0});de.useEffect(()=>{x==="play"&&H(!1)},[x]),de.useEffect(()=>{I&&R(b)},[b]),de.useEffect(()=>{m&&u(f1)},[m]),de.useEffect(()=>{var He;(He=d.pages[e])!=null&&He.layout&&H(!1)},[]);const[F,B]=gh(async({sheet:He=d,sourceImage:Ye=w.current,noLayout:be=!1,clipPoints:$e=null})=>{var Re,ge,Ce,Te,Ke;P.current.break=!1,A.current.scrollIntoView({block:"center",behavior:"smooth"}),H(!0),R(!1);const Ne=!!$e;(ge=(Re=He.pages[e])==null?void 0:Re.systems)==null||ge.forEach((Qe,lt)=>{if(Ne&&(Ve!=null&&Ve.changedSystems.includes(lt))){Qe.clearTokens();return}}),S(Pt(He,{modify:!0}));let Ve=null,et=!1;if(console.log(be,He.pages[e].layout),!He.pages[e].layout||Ne){if(_(!0),Ve=await N9(He,e,{sourceImage:Ye,pageLayoutByBlock:He.settings.pageLayoutMethod===Mp.ByBlocks,croppedAreaCanvas:g.current,clipPoints:$e}),S(Pt(He,{modify:!0})),_(!1),!Ve){Un.error(s.formatMessage({id:"playground.pageEditor.noScoreDetected"}));return}et=!0}H(!1);const ht=await T9(He.pages[e]);He.pages[e].semantics||D9(ht,He.pages[e]).then(()=>S(Pt(He,{modify:!0})));for await(const[Qe,lt]of(Te=(Ce=He.pages[e])==null?void 0:Ce.systems)==null?void 0:Te.entries()){if(((Ke=lt==null?void 0:lt.semantics)==null?void 0:Ke.length)>0||Ne&&!(Ve!=null&&Ve.changedSystems.includes(Qe)))continue;if(P.current.break)break;z(Qe);const ve=[];lt.staves.forEach((Oe,Xe)=>{ve.push([e,Qe,Xe])}),He.settings.enabledGauge&&et&&await H9({score:He,staves:ve}),S(Pt(He,{modify:!0})),et&&await R9({score:He,staves:ve,withCache:!0}),S(Pt(He,{modify:!0})),await V9({score:He,staves:ve}),z(null),S(Pt(He,{modify:!0}))}P.current.break?oo.warn({placement:"bottomRight",message:s.formatMessage({id:"playground.pageEditor.recognitionResult"}),description:s.formatMessage({id:"playground.pageEditor.pageInterrupted"},{page:e+1})}):oo.success({placement:"bottomRight",message:s.formatMessage({id:"playground.pageEditor.recognitionResult"}),description:s.formatMessage({id:"playground.pageEditor.pageCompleted"},{page:e+1})}),P.current.break=!1},[JSON.stringify(d.settings),e]);de.useEffect(()=>{var He,Ye,be,$e,Ne;g.current&&w.current&&a&&(d.pages[e].source.dimensions=d.pages[e].source.dimensions||{width:w.current.naturalWidth,height:w.current.naturalHeight},d.pages[e].source.interval=d.pages[e].source.interval||((Ne=($e=(be=(Ye=(He=d.pages[e])==null?void 0:He.layout)==null?void 0:Ye.areas)==null?void 0:be[0])==null?void 0:$e.staves)==null?void 0:Ne.interval))},[e,g.current,w.current]),de.useImperativeHandle(o,()=>({predict:async He=>{await B({sheet:He})},break:()=>P.current.break=!0,setLayoutMode:H}),[]),window.score=d;const W=(Y=(X=d.pages)==null?void 0:X[e])==null?void 0:Y.layout;(oe=W==null?void 0:W.pageSize)!=null&&oe.width||((ce=g.current)==null||ce.width),(re=W==null?void 0:W.pageSize)!=null&&re.height||((fe=g.current)==null||fe.height),de.useEffect(()=>{w.current&&(w.current.style.opacity=I?"1":"0")},[I,w.current]);const Q=de.useMemo(()=>({width:d.pageSize.width*i,height:d.pageSize.height*i}),[i,d.pageSize]),j=(He,Ye)=>{var be,$e,Ne;return(Ne=($e=(be=d.pages)==null?void 0:be[e])==null?void 0:$e[He])==null?void 0:Ne.has(Ye.id)},E=(U=a==null?void 0:a.source)!=null&&U.dimensions&&((q=a==null?void 0:a.source)!=null&&q.interval)?{width:a.source.dimensions.width*i*d.unitSize/a.source.interval+"px",height:a.source.dimensions.height*i*d.unitSize/a.source.interval+"px"}:{width:`${d.pageSize.width*i}px`,height:`${d.pageSize.height*i}px`},Z=d.unitSize/(((ee=a==null?void 0:a.source)==null?void 0:ee.interval)??d.unitSize)*i,N=de.useMemo(()=>{var He;return se.jsx("div",{className:"hud",style:{pointerEvents:M||!I?"none":"auto",...E,position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:(He=W==null?void 0:W.areas)==null?void 0:He.map((Ye,be)=>{var $e,Ne,Ve,et,ht,Re,ge,Ce;return se.jsxs("div",{style:{position:"absolute",left:Ye.x*Z+"px",top:Ye.y*Z+"px",width:Ye.width*Z+"px",height:Ye.height*Z+"px",display:!I&&((ht=(et=(Ve=(Ne=($e=d==null?void 0:d.pages)==null?void 0:$e[e])==null?void 0:Ne.systems)==null?void 0:Ve[be])==null?void 0:et.semantics)==null?void 0:ht.length)>0?"none":"block"},className:vt("system",{active:p.slice(0,2).join(",")===[e,be].join(","),loading:k===be}),onMouseLeave:()=>{!y.current&&v([e,null])},onMouseMove:()=>{if(!y.current){const Te=[e,be];p.join(",")!==Te.join(",")&&v(Te)}},"data-level":"system",children:[k===be&&se.jsx(S1,{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},size:"large",spinning:!0}),(Ce=(ge=(Re=Ye.staves)==null?void 0:Re.middleRhos)==null?void 0:ge.map)==null?void 0:Ce.call(ge,(Te,Ke)=>se.jsx("div",{className:vt("stave",{active:p.slice(0,3).join(",")===[e,be,Ke].join(",")}),style:{position:"absolute",transform:`rotate(${-Ye.staves.theta}deg)`,left:Ye.staves.phi1*Z+"px",top:(Ye.staves.interval*-2+Te)*Z+"px",width:(Ye.staves.phi2-Ye.staves.phi1)*Z+"px",height:Ye.staves.interval*4*Z+"px"},onMouseLeave:Qe=>{Qe.stopPropagation(),!y.current&&v([e,be,null])},onMouseMove:Qe=>{if(Qe.stopPropagation(),!y.current){const lt=[e,be,Ke];p.join(",")!==lt.join(",")&&v(lt),v(lt)}},children:se.jsx("span",{className:"index",children:String.fromCharCode(9312+Ke)})},Ke))]},be)})})},[M,I,y,p,k,W]);return se.jsx("div",{ref:A,style:{width:Q.width,minHeight:Q.height,backgroundColor:"#ffffff"},children:O?se.jsxs(S1,{spinning:V,tip:s.formatMessage({id:"playground.pageEditor.recognizingLayout"}),children:[se.jsxs("div",{style:{...Q,overflow:"hidden"},children:[se.jsxs("div",{style:{overflow:"hidden",position:"absolute",top:0,left:0,...Q,pointerEvents:M?"none":"initial"},children:[se.jsx("div",{style:{display:I?"block":"none",position:"absolute",top:"50%",left:"50%"},children:se.jsx("div",{style:{transformOrigin:"left top",transform:`matrix(${(D=a==null?void 0:a.source)==null?void 0:D.matrix.join(",")})`},children:se.jsx("div",{style:{...E,transform:"translate(-50%, -50%)"},children:se.jsx("img",{style:{...E},src:($=a==null?void 0:a.source)==null?void 0:$.url,crossOrigin:"anonymous",onLoad:He=>{w.current=He.target}})})})}),se.jsxs("div",{style:{position:"absolute",...E,top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[se.jsx("canvas",{style:{...E,position:"absolute",pointerEvents:"none",display:"none",top:"50%",left:"50%",transform:"translate(-50%, -50%)",outline:"2px solid red"},ref:g}),(I&&g.current&&(W==null?void 0:W.areas)&&x!=="play"||!I&&k!==null)&&(r?N:se.jsx(da,{onOpenChange:He=>{y.current=He},menu:{items:[typeof p[1]=="number"&&typeof p[2]!="number"&&{key:"1",label:`${s.formatMessage({id:"playground.pageEditor.deleteBlock"})}(system: ${p[1]+1})`,onClick:()=>{var Ye,be,$e,Ne;const He=Pt(d,{modify:!0});($e=(be=(Ye=He.pages[e])==null?void 0:Ye.layout)==null?void 0:be.areas)==null||$e.splice(p[1],1),(Ne=He.pages[e])==null||Ne.systems.splice(p[1],1),S(He),y.current=!1}},typeof p[2]=="number"&&{key:"2",label:`${s.formatMessage({id:"playground.pageEditor.deleteLine"})}(system: ${p[1]+1}, staff: ${p[2]+1})`,onClick:()=>{var Ye,be,$e,Ne,Ve,et,ht,Re,ge,Ce,Te,Ke,Qe,lt,ve,Me;const He=Pt(d,{modify:!0});(Ve=(Ne=($e=(be=(Ye=He.pages[e])==null?void 0:Ye.layout)==null?void 0:be.areas)==null?void 0:$e[p[1]])==null?void 0:Ne.staves)==null||Ve.middleRhos.splice(p[2],1),(Re=(ht=(et=He.pages[e])==null?void 0:et.systems)==null?void 0:ht[p[1]])==null||Re.staves.splice(p[2],1),(Ke=(Te=(Ce=(ge=He.pages[e])==null?void 0:ge.layout)==null?void 0:Ce.areas)==null?void 0:Te[p[1]])!=null&&Ke.staves||((ve=(lt=(Qe=He.pages[e])==null?void 0:Qe.layout)==null?void 0:lt.areas)==null||ve.splice(p[1],1),(Me=He.pages[e])==null||Me.systems.splice(p[1],1)),S(He),y.current=!1}}].filter(Boolean)},trigger:r?null:["contextMenu"],children:N}))]})]}),I&&se.jsx(_b,{src:(G=a==null?void 0:a.source)==null?void 0:G.url,crop:h,keepSelection:!h,crossorigin:"anonymous",onChange:(He,Ye)=>u(Ye),disabled:!M,className:vt({"pointer-events-none":!M&&!(h!=null&&h.width)}),renderComponent:se.jsx("div",{style:{...Q}}),renderSelectionAddon:()=>{var be,$e;let He="0",Ye="0";if(a&&w.current){const Ne=(h==null?void 0:h.width)>0?h.width/100:1,Ve=(h==null?void 0:h.height)>0?h.height/100:1;He=d.pageSize.width*i*Ne+"px",Ye=d.pageSize.height*i*(((be=a.source.dimensions)==null?void 0:be.height)||w.current.naturalHeight)/((($e=a.source.dimensions)==null?void 0:$e.width)||w.current.naturalWidth)*Ve+"px"}return se.jsx("div",{style:{position:"relative",width:He,height:Ye,padding:"10px"},children:se.jsx(Jt,{children:se.jsx(kt,{icon:se.jsx(Vh,{}),onClick:async()=>{const Ne=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];await B({sheet:d,sourceImage:w.current,clipPoints:Ne}),u(f1)}})})})}}),!M&&!I&&((J=a==null?void 0:a.systems)==null?void 0:J.length)>0&&se.jsx(da,{disabled:x==="play",onOpenChange:He=>{He||(c([]),C(null))},menu:{items:l.length===0?[{key:"0",label:s.formatMessage({id:"playground.pageEditor.empty"}),style:{color:"#ccc",minWidth:"8em",textAlign:"center"}}]:l.map(He=>{var Ne,Ve,et,ht;const Ye=j("sidWhiteList",He),be=j("sidBlackList",He),$e=d.settings.semanticConfidenceThreshold;return{key:He.id,label:se.jsx("div",{className:"menu-item",onClick:Re=>{Re.stopPropagation()},onMouseEnter:()=>{C(He)},onMouseLeave:()=>{C(null)},children:se.jsxs(yl,{className:vt({whitelist:Ye,blacklist:be}),defaultChecked:Ye||!be&&He.confidence>=$e,onChange:Re=>{d.pages[e].systems.forEach((ge,Ce)=>{if(ge.staves.some(Ke=>Ke.semantics.some(Qe=>Qe.id===He.id))){if(He.confidence>=$e){const Ke=ge.sidBlackList.findIndex(Qe=>Qe===He.id);Ke>-1?ge.sidBlackList.splice(Ke,1):ge.sidBlackList.push(f.id)}else{const Ke=ge.sidWhiteList.findIndex(Qe=>Qe===He.id);Ke>-1?ge.sidWhiteList.splice(Ke,1):ge.sidWhiteList.push(f.id)}ge.assemble($e),S(Pt(d,{modify:!0}))}}),T()},children:[" ",se.jsx("i",{className:vt("emmentaler","glyph-"+((ht=(et=(Ve=(Ne=mt)==null?void 0:Ne[He.semantic])==null?void 0:Ve.split("|"))==null?void 0:et.reverse())==null?void 0:ht[0]))})," ",se.jsx("span",{className:"name",children:He.semantic})," ",se.jsx("span",{className:"confidence",children:He.confidence.toFixed(2)})]})})}})},trigger:["contextMenu"],children:se.jsxs("div",{className:"page",children:[se.jsx(rM,{score:d,pageIndex:e,show:O,width:a.width,height:a.height}),x==="play"&&se.jsx(Ob,{score:d,page:a,pageIndex:e,onSeekPosition:t})]})}),se.jsx(Ki,{style:{pointerEvents:"none",color:"#ccc"},className:"pageNum",orientation:"center",plain:!0,children:e+1})]}),x==="edit"&&se.jsx(q1,{style:{padding:"10px 20px",color:"#ccc"},children:se.jsx("a",{onClick:()=>{const He=document.createElement("img");He.src=a.source.url,He.crossOrigin="anonymous",He.onload=()=>{const Ye=new window.OffscreenCanvas(He.naturalWidth,He.naturalHeight);Ye.getContext("2d").drawImage(He,0,0),Ye.convertToBlob().then($e=>{var Ne;to($e,(Ne=a==null?void 0:a.source)==null?void 0:Ne.name)})}},children:(ne=a==null?void 0:a.source)==null?void 0:ne.name})}),x==="edit"&&se.jsxs(Jt,{style:{padding:"10px 20px",display:"flex",justifyContent:"space-between"},children:[se.jsx(ga,{disabled:I&&!((me=a==null?void 0:a.systems)!=null&&me.length),checkedChildren:s.formatMessage({id:"playground.pageEditor.preview"}),unCheckedChildren:s.formatMessage({id:"playground.pageEditor.layout"}),checked:!I,onChange:He=>{H(!He),He&&M&&R(!1)}}),I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsx(kt,{icon:se.jsx(Rh,{}),size:"small",type:M?"primary":"dashed",onClick:()=>{u(f1),R(!M)},title:s.formatMessage({id:"playground.pageEditor.selection"}),children:s.formatMessage({id:"playground.pageEditor.selection"})})]}),I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{size:"small",onClick:async He=>{await B({sheet:d})},children:s.formatMessage({id:"playground.pageEditor.startRecognition"})}),se.jsx(kt,{size:"small",icon:se.jsx(ma,{}),onClick:()=>{d.pages[e].layout=null,d.pages[e].systems=[],d.spartito=null,S(Pt(d,{modify:!0}))}})]})]}),!I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{size:"small",onClick:async He=>{await B({sheet:d,noLayout:!0})},disabled:((_e=(Le=d.pages)==null?void 0:Le[e])==null?void 0:_e.semantics)&&((Ze=(Fe=(De=d.pages)==null?void 0:De[e])==null?void 0:Fe.systems)==null?void 0:Ze.every(He=>{var Ye;return((Ye=He.semantics)==null?void 0:Ye.length)>0})),children:s.formatMessage({id:"playground.pageEditor.recognizeSemantic"})}),se.jsx(kt,{title:s.formatMessage({id:"playground.pageEditor.clearPage"}),size:"small",icon:se.jsx(ma,{}),onClick:()=>{var He;d.pages[e].layout=null,d.pages[e].systems=[],(He=d.pages[e])==null||He.clearTokens(),d.spartito=null,S(Pt(d,{modify:!0}))}})]})]}),se.jsx(Ki,{type:"vertical"}),!n&&se.jsxs(Jt,{size:"small",children:[se.jsx(kt,{size:"small",title:s.formatMessage({id:"playground.pageEditor.moveForward"}),disabled:e===0,icon:se.jsx(Yp,{}),onClick:()=>{const He=Pt(d,{modify:!0}),Ye=He.pages.splice(e,1);He.pages.splice(e-1,0,Ye[0]),S(He)}}),se.jsx(kt,{size:"small",title:s.formatMessage({id:"playground.pageEditor.moveBackward"}),disabled:e===d.pages.length-1,icon:se.jsx(Jp,{}),onClick:()=>{const He=Pt(d,{modify:!0}),Ye=He.pages.splice(e,1);He.pages.splice(e+1,0,Ye[0]),S(He)}}),se.jsx(Af,{title:s.formatMessage({id:"playground.pageEditor.confirmDeletePage"}),okText:s.formatMessage({id:"common.confirm"}),cancelText:s.formatMessage({id:"common.cancel"}),icon:se.jsx(Mh,{}),onConfirm:async()=>{const He=Pt(d,{modify:!0});He.pages.splice(e,1),S(He)},children:se.jsx(kt,{title:s.formatMessage({id:"playground.pageEditor.deletePage"}),type:"ghost",size:"small",children:s.formatMessage({id:"playground.pageEditor.deletePage"})})},"delete")]})]})]}):null})}),oM=de.memo(iM),{Header:sM,Content:aM}=Eh,lM=/Windows/.test(navigator.userAgent)?600:240,ca=8,ua=.6,EM=e=>{var Se,Ae,ke,Pe,je,nt,ot;const t=zr(),n=hp(),r=dp(),o=de.useRef(),[s,i]=de.useState(!1),[d,S]=de.useState(""),[g,w]=pi(),[M,R]=de.useState(!1),[V,_]=de.useState(!1),[k,z]=de.useState(!1),I=de.useRef([]),[H,A]=de.useState(!1),[x,p]=Qp(),[v,y]=Y1(),[a,h]=dl(),[u,b]=pl(),[m,l]=fl(),c=de.useRef(null),f=de.useRef(null),C=de.useRef(new Sh(performance)),[T,L]=gl(),[O,P]=vh(),[F,{inc:B,dec:W,set:Q,reset:j}]=qp(90,300,10),E=de.useRef(!1),[Z]=li("Alt"),N=de.useRef({break:!1}),[K,X]=de.useState(""),[Y,oe]=de.useState({}),[ce,re]=Ih(),[fe,U]=hl(),[q,ee]=de.useState(!1),D=de.useRef(null),[$,G]=mh(),[J,ne]=de.useState([]),[me,Le]=yh(),[_e,De]=wh(),[Fe,Ze]=de.useState(null),[He,Ye]=ef(),[be,$e]=de.useState(1e3),[Ne,Ve]=de.useState({status:"idle",pass:0,remaining:0,total:0}),[et,ht]=tf(),[Re,ge]=de.useState(!1),[Ce,Te]=de.useState(!1),[Ke,Qe]=de.useState(null),[lt,ve]=kg(),Me=de.useRef(null),Oe=de.useRef(null),[Xe,it]=de.useState("mask"),[[ct,ft],[Ot,Wt],Zt]=bh(),[xe,ye]=de.useState(Object.entries(g.headers||{})),Ie=de.useMemo(()=>{var Ge,qe;const Ee=Sf.parse(window.location.search);return(Ee==null?void 0:Ee.type)==="admin"?{type:"admin",env:Ee.env,id:Ee.id,edit:Ee.edit==="1"}:{type:"user",id:(r==null?void 0:r.id)||((qe=(Ge=e==null?void 0:e.match)==null?void 0:Ge.params)==null?void 0:qe.id)}},[r,e]),Be=de.useMemo(()=>{if(Ie.type==="admin"){const Ee=location.pathname.split(":")[0],{edit:Ge,...qe}=Ie,Je=Object.entries({edit:Ge?0:1,...qe});return`${Ee}?`+Je.map(([at,At])=>`${at}=${At}`).join("&")}return null},[Ie]);Pc("s",Ee=>{if(Ee.ctrlKey||Ee.metaKey)return Ee.preventDefault(),xt(g),!1}),Pc("F9",()=>{G(!$)});const We=nf({onFiles:async(Ee,Ge)=>{var Je;const qe=Ge.dataTransfer.items;if(qe.length===1&&qe[0].webkitGetAsEntry().isDirectory){const At=qe[0].webkitGetAsEntry().createReader();async function Ct(pt){const Vt=await new Promise((St,Bt)=>{pt.readEntries(async hn=>{St(await Promise.all(hn.map(async sn=>new Promise(Zr=>sn.file(Cr=>Zr(Cr))))))},Bt)});return Vt.length>0?[...Vt,...await Ct(pt)]:Vt}S(t.formatMessage({id:"common.loading"}));const dt=await Ct(At),bt=await mf(dt);bt&&(bt.assemble(),w(bt)),S("");return}switch(Ee[0].type){case"application/zip":case"application/x-zip-compressed":case"application/json":const at=Ee[0];S(t.formatMessage({id:"common.loading"}));const At=await vf(at);At&&(At.assemble(),w(At)),S("");break;case"application/pdf":await((Je=D.current)==null?void 0:Je.onReceivePDF(Ee));break;default:console.debug("drop file type:",Ee[0].type),Ee[0].type.startsWith("image")&&await Yt(Ee)}},onUri:Ee=>console.log("uri",Ee),onText:Ee=>console.log("text",Ee)}),ut=de.useCallback(()=>g.modified,[g.modified]);de.useEffect(()=>{g.modified&&As.hash!==g.semanticHash&&(As.hash=g.semanticHash,g.spartito=null,Le(!1))},[g]),dg(ut,t.formatMessage({id:"common.beforeLeave"})),Nh("keydown",Ee=>{if(Ee.metaKey||Ee.ctrlKey){let Ge=!0;switch(Ee.code){case"Minus":y(Math.max(v/1.2,ua));break;case"Equal":y(Math.min(ca,v*1.2));break;case"Digit0":y(1);break;default:Ge=!1}Ge&&Ee.preventDefault()}}),xg(Z);const rt=()=>{f.current.play({nextFrame:()=>(c.current&&P(c.current.lookupPosition(f.current.progressTicks)),new Promise(Ee=>setTimeout(Ee,0)))})},yt=async Ee=>{if(!Ee.systems.length)return;await te(Ee);const{notation:Ge,tokenMap:qe}=Ee.spartito.perform(),Je=g.getMeasureLayout(),at=Je?Je.serialize(Ep.Full):Array(Ge.measures.length).fill(null).map((dt,bt)=>bt+1),At=Ge.toPerformingNotationWithEvents(at);At.scaleTempo({headTempo:6e7/F}),c.current=df.createFromNotation(At,qe);const Ct=f.current?f.current.progressTicks:0;f.current&&f.current.dispose(),f.current=new er.MidiPlayer(At,{cacheSpan:200,onMidi:(dt,bt)=>{let pt=null;switch(dt.subtype){case"noteOn":er.MidiAudio.noteOn(dt.channel,dt.noteNumber,dt.velocity,bt),pt=()=>{var Vt;return(Vt=dt==null?void 0:dt.ids)==null?void 0:Vt.map(St=>{const Bt=document.getElementById(St);Bt&&Bt.classList.add("notePlayOn")})};break;case"noteOff":er.MidiAudio.noteOff(dt.channel,dt.noteNumber,bt),pt=()=>{var Vt;return(Vt=dt==null?void 0:dt.ids)==null?void 0:Vt.map(St=>{const Bt=document.getElementById(St);Bt&&Bt.classList.remove("notePlayOn")})};break}pt&&C.current.appendTask(bt,pt)},onPlayFinish(){p(!1),f.current&&(f.current.progressTicks=0)},onTurnCursor(){f.current&&c.current&&P(c.current.lookupPosition(f.current.progressTicks))}}),f.current.progressTicks=Ct,E.current=!1};de.useEffect(()=>{x?(async()=>{var Ee;(!f.current||E.current)&&(E.current=!1,await yt(g)),(Ee=f.current)!=null&&Ee.isPlaying||rt()})():f.current&&f.current.pause()},[x,g]),de.useEffect(()=>{Dt(),er.MidiAudio.WebAudio.empty()&&er.MidiAudio.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>console.debug("Soundfont loaded."))},[]),de.useEffect(()=>eo.subscribe(Ve),[]),de.useEffect(()=>{Ne.status==="completed"&&Ie.id&&(Dt(),eo.reset())},[Ne.status]),de.useEffect(()=>{var Ee;switch(T){case"edit":f.current&&f.current.pause(),document.querySelectorAll(".notePlayOn").forEach(Ge=>Ge.classList.remove("notePlayOn"));break;case"play":Le(!1);{const Ge=(Ee=g==null?void 0:g.spartito)==null?void 0:Ee.headBPM;Number.isFinite(Ge)&&Q(Ge)}yt(g);break}},[T]),de.useEffect(()=>{let Ee=Ie.type==="admin"?"#":"";Ee+=Ie!=null&&Ie.edit?"✎":"",lt&&(Ee+=` ${lt}`),Ee=Ee?` ${Ee}`:"",document.title=g.title+Ee},[g,lt,Ie==null?void 0:Ie.edit]);const zt=de.useCallback(async Ee=>{var qe;if(!(c!=null&&c.current)){console.log("scheduler is null:",c==null?void 0:c.current);return}const Ge=(qe=f.current)==null?void 0:qe.isPlaying;Ge&&(f.current.pause(),await new Promise(Je=>setTimeout(Je,0)),document.querySelectorAll(".notePlayOn").forEach(Je=>Je.classList.remove("notePlayOn"))),f.current.progressTicks=c.current.lookupTick(Ee),Ge&&rt()},[]),Gt=async(Ee,Ge)=>{Ee?(await te(Ge),Ge.spartito.assignMeasureNumbers(),Ge.markVoices(Ge.spartito.makeVoiceStaves()),De(Ge.spartito.measures.map(qe=>({tickMap:qe.tickToX})))):(Ge.assemble(),De([])),w(Pt(Ge)),Le(Ee)},[Ht,Dt]=gh(async()=>{var Ee,Ge,qe,Je,at,At;try{if(!Ie.id)return Ss({title:t.formatMessage({id:"playground.newScore"})});S(t.formatMessage({id:"common.loading"}));let Ct=[],dt=null,bt;if(Ie.type==="admin"&&!Sc){const pt=await Hn(`/torch/musicSet/manage/${Ie.id}`,{params:{env:Ie.env}});Qe(pt.lastUpdate);const Vt=await jf(pt.preview);Oe.current=pt.previewKey,Me.current=Vt,bt=Ur(Vt,Xr),await jo(bt,{solutionStore:ze,onlyFetchCache:!0})}if(Ie.type==="user"&&!Sc){const pt=await Hn.get(`/api/musicSets/${Ie.id}`);let Vt=!1;try{const St=await Hn.get(`/api/scores/${Ie.id}/data`);St&&(bt=Ur(St,Xr),Vt=!0)}catch(St){console.debug("scores table not found, falling back to file:",St==null?void 0:St.message)}if(Vt||(dt=ws((Ee=pt==null?void 0:pt.content)==null?void 0:Ee.scoreURL),dt&&(bt=Ur(await(await fetch(dt)).text(),Xr))),bt)await bt.replaceImageKeys(async St=>/https?:\/\/|data:/.test(St)?ws(St):St!=null&&St.startsWith("md5:")?rf((await Fp()).omrDomain,St.replace("md5:","")):St),bt.assemble(((Ge=bt.settings)==null?void 0:Ge.semanticConfidenceThreshold)??1);else if((Je=(qe=pt==null?void 0:pt.content)==null?void 0:qe.images)!=null&&Je.length){bt=Ss({title:pt.name||t.formatMessage({id:"playground.untitledScore"})});const St=pt.content.images.map(sn=>({...sn,url:ws(sn.url)})),Bt=await Promise.all(St.map(sn=>new Promise(Zr=>{const Cr=new globalThis.Image;Cr.src=sn.url,Cr.onload=()=>Zr({width:Cr.naturalWidth,height:Cr.naturalHeight,ratio:Cr.naturalHeight/Cr.naturalWidth}),Cr.onerror=()=>Zr({width:0,height:0,ratio:0})}))),hn=Math.max(...Bt.map(sn=>sn.ratio));bt.pageSize={width:794,height:Math.round(794*hn)},bt.pages.push(...St.map((sn,Zr)=>new wc({source:{name:sn.name||`page-${Zr+1}`,size:sn.size||0,url:sn.url,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:Bt[Zr]},width:bt.pageSize.width/bt.unitSize,height:bt.pageSize.height/bt.unitSize}))),Ct=pt.tagList||[]}}if(bt){w(bt),As.hash=bt.semanticHash,me&&((at=bt.spartito)!=null&&at.regulated)?Gt(me,bt):Le(!1);try{const pt=await Hn.get(`/api/scores/${Ie.id}/issueMeasures`,{params:{offset:0,limit:1e3}});ft(((At=pt==null?void 0:pt.rows)==null?void 0:At.length)>0?Ur(pt.rows,Xr):[])}catch(pt){console.warn("failed to load issue measures:",pt),ft([])}ne(Ct||[])}else Un.error(t.formatMessage({id:"common.scoreNotFound"}));S("")}catch(Ct){console.error(Ct)}},[]),Yt=async Ee=>{var Ct,dt,bt;S(t.formatMessage({id:"common.uploadingImages"}));const Ge=Array.from(Ee).map(async pt=>{const Vt=await Gp(pt);return pt.url=Vt.url,g.pages.find(St=>St.source.url===Vt.url)?(Un.warn(t.formatMessage({id:"common.imageExists"},{name:pt.name})),null):(await jp(pt,{key:Vt.key,uploadUrl:Vt.uploadUrl}),pt)}),qe=(await Promise.all(Ge)).filter(Boolean),Je=await Promise.all(qe.map(pt=>new Promise(Vt=>{const St=new globalThis.Image;St.src=pt.url,St.onload=()=>{pt.dimensions={width:St.naturalWidth,height:St.naturalHeight},Vt(St.naturalHeight/St.naturalWidth)}}))),at=g.pageSize.height/g.pageSize.width;typeof at=="number"&&at&&Je.push(at);const At=Math.max(...Je);g.pageSize={width:794,height:Math.round(794*At)},g.pages.push(...qe.map(pt=>new wc({source:{name:pt.name,size:pt.size,url:pt.url,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:pt.dimensions},width:g.pageSize.width/g.unitSize,height:g.pageSize.height/g.unitSize}))),(Ct=qe==null?void 0:qe[0])!=null&&Ct.name&&(g.title=qe[0].name.replace(/-*\d+\.\w+$/,"")),w(Pt(g)),S(""),(bt=(dt=o.current)==null?void 0:dt.scrollTo)==null||bt.call(dt,{left:1e5,behavior:"smooth"})};of(()=>{f.current&&f.current.dispose(),S(""),A(!1),p(!1),L("edit"),P(null),j(),w(Ss({title:t.formatMessage({id:"playground.newScore"})}))});const xt=async Ee=>{var Ge,qe;if(R(!0),delete Ee.modified,Ie.type==="admin"){const Je=JSON.parse(Me.current),at=Ee.deepCopy();delete Je.patches,delete at.patches,Je.spartito||delete at.spartito;const At=JSON.parse(JSON.stringify(at)),Ct=Tg.diff(Je,At);Ct&&(await Hn.put(`/torch/musicSet/manage/${Ie.id}/increment`,{data:{env:Ie.env,patch:Ct,key:Oe.current}}),R(!1),await Dt());try{await Hn.put(`/torch/musicSet/manage/${Ie.id}/updateScorePatches`,{data:{env:Ie.env}})}catch(dt){console.error(dt)}R(!1);return}Ee.tags=J.map(Je=>Je.name),await Ee.replaceImageKeys(async Je=>Je&&await yf(Je));try{let Je=Ee.title;const at=g.pages[0].tokens;!Je&&Array.isArray(at)&&at.length>0&&(Je=(qe=(Ge=at.filter(dt=>dt.type===mt.Text&&dt.textType==="Title").sort((dt,bt)=>bt.fontSize-dt.fontSize))==null?void 0:Ge[0])==null?void 0:qe.text),Je=Je||t.formatMessage({id:"common.untitled"});const At={name:Je,content:{images:Ee.pages.map(dt=>dt.source?{name:dt.source.name,size:dt.source.size,url:dt.source.url}:null)},tagIdList:J.map(dt=>dt.id)};let Ct;Ie.id?(await Hn.put(`/api/scores/${Ie.id}/data`,{data:Ee.toJSON()}),Ct=await Hn.put(`/api/musicSets/${Ie.id}`,{data:At})):(Ct=await Hn.post("/api/musicSets",{data:At}),await Hn.put(`/api/scores/${Ct.id}/data`,{data:Ee.toJSON()})),String(Ct==null?void 0:Ct.id)!==Ie.id&&n(`/playground/${Ct==null?void 0:Ct.id}`),w(Pt(Ee)),oo.success({placement:"bottomRight",message:t.formatMessage({id:"common.saveResult"}),description:t.formatMessage({id:"common.saveSuccess"})})}catch(Je){console.log(Je)}R(!1)},jt=async(Ee=!0)=>{_(!0);const Ge=Ur(g.toJSON(),Xr);g.tags=J.map(at=>at.name),Ee&&await Ge.replaceImageKeys(async at=>await Cf(at));const qe=new Blob([JSON.stringify(Ge.toJSON())],{type:"application/json"}),Je=Zp(qe,`${Date.now()}.json`);to(Je,`${Ge.title}-${Date.now()}.json`,Je.type),_(!1)},Rt=async Ee=>{_(!0),await te(Ee);const Ge=new Hf({score:g,...g.makeMusicSheet(),workTitle:Ee.title}).toString();to(Ge,`${Ee.title}-${Date.now()}.xml`,"application/xml"),_(!1)},Kt=async Ee=>{_(!0);const Ge=Ee.makeMusicSheet(),qe=await A3(Ge);to(qe,`${Ge.title}-${Date.now()}.ly`,"text/lilypond-source"),_(!1)},Gn=async Ee=>{var Ge;try{_(!0),Ee.assemble(((Ge=Ee.settings)==null?void 0:Ge.semanticConfidenceThreshold)??1),(!Ee.spartito||!Ee.spartito.regulated)&&await te(Ee);const qe=Ee.makeMusicSheet(),Je=$g(qe),at=s3(Je);to(at,`${qe.title}-${Date.now()}.lyl`,"text/plain")}catch(qe){Un.error((qe==null?void 0:qe.message)||t.formatMessage({id:"common.exportFailed"}))}finally{_(!1)}},zn=async()=>{await te(g),await bf(g)},kn=async()=>{var Ge,qe;z(!0),N.current.break=!1;const Ee=Pt(g);for await(const[Je,at]of I.current.entries()){if(N.current.break){(Ge=at==null?void 0:at.break)==null||Ge.call(at);break}await((qe=at==null?void 0:at.predict)==null?void 0:qe.call(at,Ee))}z(!1),N.current.break||(Ie.id&&eo.prepare(Ie.id),await xt(Ee),Ie.id&&eo.startRegulation(Ie.id)),N.current.break=!1};kh(async()=>{Ie.type==="user"&&g.modified&&await xt(g)},12e3,[g]);const jn=de.useCallback(Wf(Ee=>{g.resetPageLayout(Ee),w(Pt(g,{modify:!0}))},300),[g]),ze=de.useMemo(()=>Ie.type==="admin"?new Lf:new Tf,[Ie]);window.solutionStore=ze;const te=Ee=>{if(!Ee.spartito||!Ee.spartito.regulated)return jo(Ee,{policy:He,quota:be,solutionStore:ze,onProgress:Ge=>{Ze(Ge),Ge===100&&Ze(null)}})},le=async()=>{Te(!0);try{const Ge=await(await fetch("/regulate-score",{method:"POST",mode:"cors",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify({score:g})})).json();if(Ge.code!==0)throw new Error(Ge.message||"Regulation failed");const qe=Ur(Ge.data.score,Xr);w(Pt(qe,{modify:!0}))}catch(Ee){console.error("[callRegulator]",Ee)}Te(!1)},ae=async()=>{var Ge;(Ge=g.spartito)!=null&&Ge.regulated||await jo(g,{forceUpdate:!1,solutionStore:ze,policy:He,quota:be,onProgress:qe=>{Ze(qe),qe===100&&Ze(null)}});const Ee=g.blackoutFakeNotes(et);console.debug("black out semantics:",Ee),g.assemble()},he=async()=>{if(!g.spartito||!g.spartito.regulated){alert(t.formatMessage({id:"playground.regulation.notCompleted"}));return}ge(!0);const Ee=[].concat(...g.spartito.measures.map(Je=>(g.assignBackgroundForMeasure(Je),Je.createClusters()))).filter(Je=>Je.regular),Ge=new zp({clusters:Ee});console.log("cluster set:",Ge);const qe=await fetch(`/api/score/${Ie.id}`);if(qe!=null&&qe.ok){const Je=await qe.json();if(Je!=null&&Je.data){console.warn("ClusterSet with this ID has been created:",Ie.id),oo.warn({placement:"bottomRight",message:t.formatMessage({id:"playground.export.topologyFailed"}),description:`${t.formatMessage({id:"playground.export.topologyExists"})}:${Ie.id}`}),ge(!1);return}}await fetch(`/api/score/${Ie.id}`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify({name:g.title,measures:Ee.map((Je,at)=>({index:at,cluster:Je}))})}),console.log("ClusterSet created:",Ie.id),oo.success({placement:"bottomRight",message:t.formatMessage({id:"playground.export.topology"}),description:t.formatMessage({id:"playground.export.topologySuccess"})}),ge(!1)},ie=de.useMemo(()=>{var Ee,Ge,qe,Je;return((Ge=(Ee=g.spartito)==null?void 0:Ee.measures)==null?void 0:Ge.length)>0?se.jsx(pa,{title:Zt?se.jsx("div",{children:se.jsxs(Jt,{size:20,children:[se.jsxs("div",{children:[t.formatMessage({id:"playground.measure"}),"#",(Zt==null?void 0:Zt.measureIndex)+1]}),se.jsx("div",{children:(Je=(qe=Zt.measure.basics)==null?void 0:qe[0])!=null&&Je.timeSignature?Object.values(Zt.measure.basics[0].timeSignature).join("/")+t.formatMessage({id:"playground.beat"}):""}),se.jsx(ga,{checked:Xe==="mask",onChange:at=>it(Xe==="mask"?"origin":"mask"),checkedChildren:t.formatMessage({id:"playground.background"}),unCheckedChildren:t.formatMessage({id:"common.originalImage"})})]})}):null,open:!!Zt,closable:!0,footer:null,mask:!0,width:"98vw",onClose:()=>Wt(null),children:Zt?se.jsx(Eb,{bgMode:Xe,style:{width:"300px"},score:g,record:Zt,onClose:()=>Wt(null)}):null}):null},[g,Zt,Xe]),ue=de.useMemo(()=>se.jsx(g1,{title:t.formatMessage({id:"playground.regulation"}),zIndex:2e3,open:Fe!==null,closable:!1,footer:null,mask:!0,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"200px",height:"200px"},children:se.jsx(fa,{type:"circle",strokeColor:{"0%":"#108ee9","100%":"#87d068"},percent:Fe??0})}),[Fe]),pe=de.useMemo(()=>se.jsx(g1,{title:se.jsxs("span",{children:[t.formatMessage({id:"playground.selectTrackTemplate"})," ",se.jsx(yl,{checked:q,onChange:Ee=>ee(!q),style:{color:"#999999"},children:t.formatMessage({id:"playground.showAllTemplates"})})]}),zIndex:2e3,open:fe,onOk:()=>{U(!1)},forceRender:!0,onCancel:()=>U(!1),footer:null,children:se.jsx(Rb,{score:g,showAll:q,onChange:Ee=>{g.staffLayoutCode=Ee.staffLayoutCode,g.instrumentDict=Ee.instrumentDict,w(Pt(g,{modify:!0})),U(!1),oe(Ee.instrumentDict),X(Ee.staffLayoutCode)}})}),[g,q,fe]),we=de.useMemo(()=>se.jsx(g1,{title:t.formatMessage({id:"playground.editTrack"}),zIndex:2e3,open:ce,okText:t.formatMessage({id:"common.confirm"}),cancelText:t.formatMessage({id:"common.cancel"}),onOk:()=>{g.staffLayoutCode=K,g.instrumentDict=Y,w(Pt(g,{modify:!0})),re(!1)},forceRender:!0,onCancel:()=>re(!1),okButtonProps:{disabled:!1},children:se.jsx(Tb,{staffLayoutCode:g.staffLayoutCode,instrumentDict:g.instrumentDict,onChange:Ee=>{X(Ee.staffLayoutCode),oe(Ee.instrumentDict)}})}),[g,ce,K,Y]);return se.jsx(ul.Provider,{value:Ie,children:se.jsxs(se.Fragment,{children:[se.jsxs("svg",{width:"0",height:"0",style:{position:"absolute",visibility:"hidden"},children:[se.jsx(Gf,{}),se.jsxs("defs",{children:[se.jsx("path",{id:"svg-icon-exclamation",d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z",transform:"scale(0.003)",color:"orange"}),se.jsxs("g",{id:"svg-icon-info",transform:"scale(0.003)",color:"green",children:[se.jsx("path",{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"}),se.jsx("path",{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"})]})]})]}),se.jsx(S1,{spinning:!!d,tip:d,style:{backgroundColor:We.over?"red":"initial"},children:se.jsxs(Eh,{className:vt({[Nn.playground]:!0,[Nn.hover]:s}),style:{height:"100vh",overflow:"hidden",display:"flex",flexDirection:"column"},onDragOver:Ee=>{Ee.preventDefault(),i(s)},onDragLeave:()=>i(!1),children:[se.jsx(sM,{className:vt(Nn.header,{[Nn[Ie.type]]:!0,[Nn.edit]:Ie==null?void 0:Ie.edit}),children:se.jsxs(q1,{style:{width:"100%",display:"flex",justifyContent:"space-between"},gutter:16,children:[se.jsxs(Sr,{style:{display:"flex",alignItems:"center"},children:[se.jsx(zc,{to:Ie.type==="admin"?"/admin/":"/",className:Nn.logo,onClick:()=>G(!1),children:"STARRY"}),se.jsx(sf,{placeholder:t.formatMessage({id:"playground.titlePlaceholder"}),defaultValue:t.formatMessage({id:"playground.defaultTitle"}),style:{height:"30px"},value:g==null?void 0:g.title,onChange:Ee=>{const Ge=Pt(g,{modify:!0});Ge.title=Ee.target.value,w(Ge)}})]}),Ke&&se.jsxs(Sr,{className:Nn.updateTime,children:[se.jsx("em",{children:Ke})," ",t.formatMessage({id:"playground.lastUpdate"}),se.jsx(kt,{size:"small",type:"link",icon:se.jsx(_c,{spin:Ht.loading}),onClick:Dt})]}),se.jsxs(Sr,{children:[T==="edit"&&se.jsx(kt,{title:t.formatMessage({id:"playground.switchToPlay"}),disabled:!((Se=g==null?void 0:g.pages)!=null&&Se.length),style:{verticalAlign:"middle",color:"#999999"},icon:se.jsx(ff,{}),onClick:()=>{if(!g.pages.some(Ee=>{var Ge;return((Ge=Ee.systems)==null?void 0:Ge.length)>0})){Un.warn(t.formatMessage({id:"playground.recognizeFirst"}));return}L("play")}}),T==="play"&&se.jsx(kt,{title:t.formatMessage({id:"playground.switchToEdit"}),disabled:!((Ae=g==null?void 0:g.pages)!=null&&Ae.length),style:{verticalAlign:"middle",color:"#999999"},icon:se.jsx(xf,{}),onClick:()=>{L("edit"),p(!1)}})]}),T==="play"&&se.jsxs(Jt,{style:{flex:1,paddingLeft:"10px"},children:[se.jsx(af,{title:t.formatMessage({id:"playground.goToStart"}),className:Nn.playControlBtn,onClick:()=>zt({system:0,x:0})}),x?se.jsx(gf,{title:t.formatMessage({id:"common.pause"}),className:vt(Nn.playControlBtn,{[Nn.playControlBtnActive]:x}),onClick:()=>{p(!x)}}):se.jsx(lf,{title:t.formatMessage({id:"common.play"}),className:Nn.playControlBtn,onClick:()=>{p(!x)}}),se.jsxs("div",{children:["𝅘𝅥 =",se.jsx("input",{value:F,style:{padding:"0 5px",display:"inline",border:"none",width:"50px"},type:"number",step:10,onChange:Ee=>{Q(+Ee.target.value),E.current=!0}})]})]}),T==="edit"&&Ie.type!=="admin"&&se.jsx(Sr,{style:{flex:1},children:se.jsx(cf,{ref:D,onChange:Yt})}),Ie.type==="admin"&&se.jsx(Sr,{children:se.jsxs(zc,{to:Be,children:["#",Ie.edit?t.formatMessage({id:"playground.preview"}):t.formatMessage({id:"playground.edit"})]})}),se.jsxs(Jt,{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{type:m?"primary":"ghost",onClick:()=>{l(!m)},children:t.formatMessage({id:"common.originalImage"})}),se.jsx(kt,{type:u?"primary":"ghost",onClick:()=>{b(!u)},children:t.formatMessage({id:"common.symbols"})}),se.jsx(kt,{type:a?"primary":"ghost",onClick:()=>{h(!a)},children:t.formatMessage({id:"playground.semanticDots"})}),se.jsx(kt,{type:me?"primary":"ghost",onClick:()=>Gt(!me,g),children:t.formatMessage({id:"playground.verify"})})]}),T==="edit"&&Ie.type!=="admin"&&se.jsx(kt,{icon:k?se.jsx(xc,{}):se.jsx(Vh,{}),onClick:async()=>{k?(N.current.break=!0,I.current.forEach(Ee=>{var Ge;(Ge=Ee.break)==null||Ge.call(Ee)})):await kn()},children:k?N.current.break?t.formatMessage({id:"playground.stoppingRecognition"}):t.formatMessage({id:"playground.stopRecognition"}):t.formatMessage({id:"playground.recognizeAll"})}),T==="edit"&&Ie.type!=="admin"&&se.jsx(kt,{size:"small",icon:se.jsx(ma,{}),onClick:()=>{g.pages.forEach(Ee=>{Ee.layout=null,Ee.rotation=null,Ee.systems=[]});for(const[Ee,Ge]of I.current.entries())Ge.setLayoutMode(!0);w(Pt(g))}}),se.jsxs(kt.Group,{children:[se.jsxs(kt,{icon:se.jsx(uf,{}),loading:M,onClick:()=>xt(g),disabled:!((ke=g==null?void 0:g.pages)!=null&&ke.length)&&(Ie.type!=="admin"||Ie.edit),children:[M?t.formatMessage({id:"common.saving"}):t.formatMessage({id:"common.save"})," ",g.modified?"*":""]}),se.jsx(da.Button,{disabled:!((Pe=g==null?void 0:g.pages)!=null&&Pe.length),icon:V?se.jsx(xc,{}):se.jsx(Rf,{}),trigger:["click"],menu:{items:[{key:"json",label:`${t.formatMessage({id:"playground.export"})} JSON`},{key:"json_noimg",label:`${t.formatMessage({id:"playground.export"})} JSON (${t.formatMessage({id:"playground.export.noImage"})})`},{key:"xml",label:`${t.formatMessage({id:"playground.export"})} MusicXML`},{key:"ly",label:`${t.formatMessage({id:"playground.export"})} LilyPond`},{key:"lyl",label:`${t.formatMessage({id:"playground.export"})} Lilylet`},{key:"find",label:`${t.formatMessage({id:"playground.export"})} Find Score`}],onClick:async Ee=>{switch(Ee.key){case"xml":await Rt(g);break;case"json":await jt();break;case"json_noimg":await jt(!1);break;case"find":await zn();break;case"ly":await Kt(g);break;case"lyl":await Gn(g);break}}}})]}),se.jsx(kt,{title:t.formatMessage({id:"playground.globalConfig"}),icon:se.jsx(Bf,{}),onClick:()=>{A(!0)}}),se.jsx(Vf,{id:Ie.id,tagList:J,onChange:Ee=>ne(Ee)}),se.jsx(kt,{title:t.formatMessage({id:"playground.annotation"}),icon:se.jsx(m4,{}),onClick:()=>{G(!$)}}),se.jsx(kt,{title:t.formatMessage({id:"playground.export.topology"}),icon:se.jsx(Rh,{}),loading:Re,onClick:he}),se.jsx(kt,{title:`${t.formatMessage({id:"playground.regulation"})} (Ctrl+click: ${t.formatMessage({id:"playground.regulation.backend"})})`,type:(je=g.spartito)!=null&&je.regulated?"primary":"default",icon:Ne.status==="regulating"||Ne.status==="connecting"?se.jsx(_c,{spin:!0}):se.jsx(Vc,{}),onClick:Ee=>{var Ge;(Ge=g.spartito)!=null&&Ge.regulated?(g.spartito=null,Le(!1),w(Pt(g,{modify:!0}))):Ee.ctrlKey&&Ie.id?eo.startRegulation(Ie.id):jo(g,{forceUpdate:Z,solutionStore:ze,policy:He,quota:be,onProgress:qe=>{Ze(qe),qe===100&&Ze(null)}})},children:Ne.status==="regulating"?Ne.total>0?`${Ne.total-Ne.remaining}/${Ne.total}`:"...":null}),se.jsx(Mf,{})]})]})}),se.jsx(aM,{style:{flex:1,flexShrink:0,paddingRight:$?"50%":"0",overflow:"scroll"},onWheel:Ee=>{if(Ee.altKey){let Ge=v*Math.exp(-Ee.deltaY/lM);Ge=Math.min(Math.max(Ge,ua),ca),y(Ge)}},children:(nt=g==null?void 0:g.pages)!=null&&nt.length?se.jsx(Jt,{wrap:!0,style:{padding:"8px"},children:(ot=g==null?void 0:g.pages)==null?void 0:ot.map((Ee,Ge)=>{var qe;return se.jsx(oM,{ref:Je=>{I.current[Ge]=Je},pageIndex:Ge,onSeekPosition:zt,disableScoreLevelControls:Ie.type==="admin",disableRecognization:Ie.type==="admin"&&!Ie.edit},((qe=Ee.source)==null?void 0:qe.url)||`page-${Ge}`)})}):se.jsx(Ef,{style:{marginTop:"200px"},description:t.formatMessage({id:"playground.empty"})})})]})}),se.jsxs(Jt,{className:Nn.zoomControl,direction:"horizontal",children:[se.jsx(Hc,{title:`${t.formatMessage({id:"playground.zoomOut"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + -)`,onClick:()=>y(Math.max(v/1.2,ua)),size:36}),se.jsxs("div",{title:`${t.formatMessage({id:"playground.zoomReset"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + 0)`,className:Nn.percentText,onClick:()=>y(1),children:[Math.round(v*100),"%"]}),se.jsx(_f,{title:`${t.formatMessage({id:"playground.zoomIn"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + +)`,onClick:()=>y(Math.min(ca,v*1.2)),size:36})]}),se.jsx(pa,{title:t.formatMessage({id:"playground.globalConfig"}),width:300,closeIcon:se.jsx(Wp,{}),onClose:()=>{A(!1)},open:H,children:se.jsxs(Ln,{layout:"horizontal",size:"small",initialValues:g.settings,onValuesChange:(Ee,Ge)=>{g.settings=Ge,w(Pt(g))},children:[se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.layoutMethod"}),name:"pageLayoutMethod",children:se.jsxs(qn.Group,{buttonStyle:"solid",children:[se.jsx(qn.Button,{value:"ByBlocks",children:t.formatMessage({id:"playground.layoutByBlocks"})}),se.jsx(qn.Button,{value:"ByLines",children:t.formatMessage({id:"playground.layoutByLines"})})]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.enableDistortionCorrection"}),name:"enabledGauge",valuePropName:"checked",children:se.jsx(ga,{})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.semanticThreshold"}),name:"semanticConfidenceThreshold",valuePropName:"value",children:se.jsx(Ff,{step:.1,min:0,max:2,onAfterChange:Ee=>{const Ge=Pt(g,{modify:!0});Ge.assemble(Ee),w(Ge)}})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.track"}),children:se.jsxs("div",{children:[se.jsx(kt,{title:t.formatMessage({id:"playground.selectTemplate"}),style:{margin:"0 10px"},onClick:()=>{U(!0)},children:(()=>{const Ee=B5.find(Ge=>Ge.code===g.staffLayoutCode);return Ee?t.formatMessage({id:Ee.nameKey}):t.formatMessage({id:"playground.custom"})})()}),se.jsx(hf,{title:t.formatMessage({id:"playground.edit"}),style:{color:"#1890ff"},onClick:()=>{re(!0),X(g.staffLayoutCode)}})]})}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:["Headers:",xe.map(([Ee,Ge],qe)=>se.jsxs(Jt,{align:"baseline",children:[se.jsx(Tc,{style:{width:"120px"},placeholder:"Key",options:[{label:`title(${t.formatMessage({id:"playground.metadata.title"})})`,value:"title"},{value:"subtitle"},{label:`composer(${t.formatMessage({id:"playground.metadata.composer"})})`,value:"composer"},{label:`lyricist(${t.formatMessage({id:"playground.metadata.lyricist"})})`,value:"lyricist"},{label:`arranger(${t.formatMessage({id:"playground.metadata.arranger"})})`,value:"arranger"},{label:`copyright(${t.formatMessage({id:"playground.metadata.copyright"})})`,value:"copyright"},{label:`dedication(${t.formatMessage({id:"playground.metadata.credits"})})`,value:"dedication"},{value:"work-title"},{value:"creator"},{value:"rights"},{value:"source"},{value:"relation"},{value:"subsubtitle"},{value:"opus"}],filterOption:(Je,at)=>at.value.toUpperCase().indexOf(Je.toUpperCase())!==-1,onChange:Je=>{xe[qe]=[Je,Ge],ye([...xe])},onBlur:()=>{g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}}),se.jsx(Tc,{style:{width:"120px"},placeholder:"Value",options:[].concat(...g.pages.map(Je=>Je.tokens)).map(Je=>({value:Je.text})),filterOption:(Je,at)=>at.value.toUpperCase().indexOf(Je.toUpperCase())!==-1,onChange:Je=>{xe[qe]=[Ee,Je],ye([...xe])},onBlur:()=>{g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}}),se.jsx(Hc,{onClick:()=>{xe.splice(qe,1),ye([...xe]),g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}})]},qe)),se.jsx(Ln.Item,{children:se.jsx(kt,{type:"dashed",block:!0,icon:se.jsx(zh,{}),onClick:()=>{ye([...xe,[null,null]])},children:t.formatMessage({id:"playground.metadata.addField"})})}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.pageSettings"}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.paper"}),children:se.jsxs(Jt,{children:[se.jsx(Hr,{defaultValue:g.pageSize.width,type:"number",step:10,onChange:Ee=>{jn({pageSize:Object.assign({},g.pageSize,{width:+Ee.target.value})})}}),"px",se.jsx("span",{children:"×"}),se.jsx(Hr,{defaultValue:g.pageSize.height,type:"number",step:10,onChange:Ee=>{jn({pageSize:Object.assign({},g.pageSize,{height:+Ee.target.value})})}}),"px"]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.font"}),children:se.jsxs(Jt,{children:[se.jsx(Hr,{defaultValue:g.unitSize,type:"number",step:.1,onChange:Ee=>{jn({unitSize:+Ee.target.value})}}),"px"]})})]}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.regulation"}),":",se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.regulation.strategy"}),children:se.jsxs(qn.Group,{value:He,onChange:Ee=>{var Ge;(Ge=g.spartito)==null||Ge.cleanupRegulation(),Ye(Ee.target.value),Le(!1)},children:[se.jsx(qn.Button,{value:"equations",children:"Equations"}),se.jsx(qn.Button,{value:"simple",children:"Simple"}),se.jsx(qn.Button,{value:"test",children:"Test"})]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.regulation.quota"}),children:se.jsx(Hr,{defaultValue:be,type:"number",step:100,onChange:Ee=>{var Ge;(Ge=g.spartito)==null||Ge.cleanupRegulation(),$e(+Ee.target.value),Le(!1)}})}),se.jsx(Ln.Item,{children:se.jsx(kt,{icon:se.jsx(Vc,{}),onClick:le,loading:Ce,children:"call regulator"})})]}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.cleanFalseNoteheads"}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.cleanScope"}),children:se.jsxs(qn.Group,{value:et,onChange:Ee=>{ht(Ee.target.value)},children:[se.jsx(qn.Button,{value:"patched",children:t.formatMessage({id:"playground.cleanAnnotated"})}),se.jsx(qn.Button,{value:"perfect",children:t.formatMessage({id:"playground.cleanCorrect"})}),se.jsx(qn.Button,{value:"all",children:t.formatMessage({id:"playground.cleanAll"})})]})}),se.jsx(Ln.Item,{children:se.jsx(kt,{icon:se.jsx(J4,{}),onClick:ae,children:"cleanup"})})]})]}),se.jsx(Ln.Item,{children:se.jsx(Hh,{title:"inspect spartito evaluation",style:{cursor:"pointer"},onClick:()=>{var Ee;return(Ee=g.spartito)==null?void 0:Ee.dumpEvaluations()}})})]})}),se.jsx(B9,{}),we,pe,ue,ie]})})};export{EM as default}; + */var Fo=typeof window<"u"&&typeof document<"u"&&typeof navigator<"u",lA=function(){for(var e=["Edge","Trident","Firefox"],t=0;t=0)return 1;return 0}();function cA(e){var t=!1;return function(){t||(t=!0,window.Promise.resolve().then(function(){t=!1,e()}))}}function uA(e){var t=!1;return function(){t||(t=!0,setTimeout(function(){t=!1,e()},lA))}}var hA=Fo&&window.Promise,dA=hA?cA:uA;function g2(e){var t={};return e&&t.toString.call(e)==="[object Function]"}function fi(e,t){if(e.nodeType!==1)return[];var n=e.ownerDocument.defaultView,r=n.getComputedStyle(e,null);return t?r[t]:r}function uc(e){return e.nodeName==="HTML"?e:e.parentNode||e.host}function Wo(e){if(!e)return document.body;switch(e.nodeName){case"HTML":case"BODY":return e.ownerDocument.body;case"#document":return e.body}var t=fi(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/(auto|scroll|overlay)/.test(n+o+r)?e:Wo(uc(e))}function m2(e){return e&&e.referenceNode?e.referenceNode:e}var Ou=Fo&&!!(window.MSInputMethodContext&&document.documentMode),Pu=Fo&&/MSIE 10/.test(navigator.userAgent);function Wi(e){return e===11?Ou:e===10?Pu:Ou||Pu}function Ni(e){if(!e)return document.documentElement;for(var t=Wi(10)?document.body:null,n=e.offsetParent||null;n===t&&e.nextElementSibling;)n=(e=e.nextElementSibling).offsetParent;var r=n&&n.nodeName;return!r||r==="BODY"||r==="HTML"?e?e.ownerDocument.documentElement:document.documentElement:["TH","TD","TABLE"].indexOf(n.nodeName)!==-1&&fi(n,"position")==="static"?Ni(n):n}function pA(e){var t=e.nodeName;return t==="BODY"?!1:t==="HTML"||Ni(e.firstElementChild)===e}function Da(e){return e.parentNode!==null?Da(e.parentNode):e}function F1(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return document.documentElement;var n=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,r=n?e:t,o=n?t:e,s=document.createRange();s.setStart(r,0),s.setEnd(o,0);var i=s.commonAncestorContainer;if(e!==i&&t!==i||r.contains(o))return pA(i)?i:Ni(i);var d=Da(e);return d.host?F1(d.host,t):F1(e,Da(t).host)}function Oi(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"top",n=t==="top"?"scrollTop":"scrollLeft",r=e.nodeName;if(r==="BODY"||r==="HTML"){var o=e.ownerDocument.documentElement,s=e.ownerDocument.scrollingElement||o;return s[n]}return e[n]}function fA(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=Oi(t,"top"),o=Oi(t,"left"),s=n?-1:1;return e.top+=r*s,e.bottom+=r*s,e.left+=o*s,e.right+=o*s,e}function Du(e,t){var n=t==="x"?"Left":"Top",r=n==="Left"?"Right":"Bottom";return parseFloat(e["border"+n+"Width"])+parseFloat(e["border"+r+"Width"])}function $u(e,t,n,r){return Math.max(t["offset"+e],t["scroll"+e],n["client"+e],n["offset"+e],n["scroll"+e],Wi(10)?parseInt(n["offset"+e])+parseInt(r["margin"+(e==="Height"?"Top":"Left")])+parseInt(r["margin"+(e==="Height"?"Bottom":"Right")]):0)}function v2(e){var t=e.body,n=e.documentElement,r=Wi(10)&&getComputedStyle(n);return{height:$u("Height",t,n,r),width:$u("Width",t,n,r)}}var gA=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},mA=function(){function e(t,n){for(var r=0;r2&&arguments[2]!==void 0?arguments[2]:!1,r=Wi(10),o=t.nodeName==="HTML",s=$a(e),i=$a(t),d=Wo(e),S=fi(t),g=parseFloat(S.borderTopWidth),w=parseFloat(S.borderLeftWidth);n&&o&&(i.top=Math.max(i.top,0),i.left=Math.max(i.left,0));var M=Br({top:s.top-i.top-g,left:s.left-i.left-w,width:s.width,height:s.height});if(M.marginTop=0,M.marginLeft=0,!r&&o){var R=parseFloat(S.marginTop),V=parseFloat(S.marginLeft);M.top-=g-R,M.bottom-=g-R,M.left-=w-V,M.right-=w-V,M.marginTop=R,M.marginLeft=V}return(r&&!n?t.contains(d):t===d&&d.nodeName!=="BODY")&&(M=fA(M,t)),M}function vA(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=e.ownerDocument.documentElement,r=hc(e,n),o=Math.max(n.clientWidth,window.innerWidth||0),s=Math.max(n.clientHeight,window.innerHeight||0),i=t?0:Oi(n),d=t?0:Oi(n,"left"),S={top:i-r.top+r.marginTop,left:d-r.left+r.marginLeft,width:o,height:s};return Br(S)}function y2(e){var t=e.nodeName;if(t==="BODY"||t==="HTML")return!1;if(fi(e,"position")==="fixed")return!0;var n=uc(e);return n?y2(n):!1}function C2(e){if(!e||!e.parentElement||Wi())return document.documentElement;for(var t=e.parentElement;t&&fi(t,"transform")==="none";)t=t.parentElement;return t||document.documentElement}function dc(e,t,n,r){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,s={top:0,left:0},i=o?C2(e):F1(e,m2(t));if(r==="viewport")s=vA(i,o);else{var d=void 0;r==="scrollParent"?(d=Wo(uc(t)),d.nodeName==="BODY"&&(d=e.ownerDocument.documentElement)):r==="window"?d=e.ownerDocument.documentElement:d=r;var S=hc(d,i,o);if(d.nodeName==="HTML"&&!y2(i)){var g=v2(e.ownerDocument),w=g.height,M=g.width;s.top+=S.top-S.marginTop,s.bottom=w+S.top,s.left+=S.left-S.marginLeft,s.right=M+S.left}else s=S}n=n||0;var R=typeof n=="number";return s.left+=R?n:n.left||0,s.top+=R?n:n.top||0,s.right-=R?n:n.right||0,s.bottom-=R?n:n.bottom||0,s}function yA(e){var t=e.width,n=e.height;return t*n}function b2(e,t,n,r,o){var s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;if(e.indexOf("auto")===-1)return e;var i=dc(n,r,s,o),d={top:{width:i.width,height:t.top-i.top},right:{width:i.right-t.right,height:i.height},bottom:{width:i.width,height:i.bottom-t.bottom},left:{width:t.left-i.left,height:i.height}},S=Object.keys(d).map(function(R){return Yn({key:R},d[R],{area:yA(d[R])})}).sort(function(R,V){return V.area-R.area}),g=S.filter(function(R){var V=R.width,_=R.height;return V>=n.clientWidth&&_>=n.clientHeight}),w=g.length>0?g[0].key:S[0].key,M=e.split("-")[1];return w+(M?"-"+M:"")}function I2(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,o=r?C2(t):F1(t,m2(n));return hc(n,o,r)}function w2(e){var t=e.ownerDocument.defaultView,n=t.getComputedStyle(e),r=parseFloat(n.marginTop||0)+parseFloat(n.marginBottom||0),o=parseFloat(n.marginLeft||0)+parseFloat(n.marginRight||0),s={width:e.offsetWidth+o,height:e.offsetHeight+r};return s}function W1(e){var t={left:"right",right:"left",bottom:"top",top:"bottom"};return e.replace(/left|right|bottom|top/g,function(n){return t[n]})}function A2(e,t,n){n=n.split("-")[0];var r=w2(e),o={width:r.width,height:r.height},s=["right","left"].indexOf(n)!==-1,i=s?"top":"left",d=s?"left":"top",S=s?"height":"width",g=s?"width":"height";return o[i]=t[i]+t[S]/2-r[S]/2,n===d?o[d]=t[d]-r[g]:o[d]=t[W1(d)],o}function Go(e,t){return Array.prototype.find?e.find(t):e.filter(t)[0]}function CA(e,t,n){if(Array.prototype.findIndex)return e.findIndex(function(o){return o[t]===n});var r=Go(e,function(o){return o[t]===n});return e.indexOf(r)}function S2(e,t,n){var r=n===void 0?e:e.slice(0,CA(e,"name",n));return r.forEach(function(o){o.function&&console.warn("`modifier.function` is deprecated, use `modifier.fn`!");var s=o.function||o.fn;o.enabled&&g2(s)&&(t.offsets.popper=Br(t.offsets.popper),t.offsets.reference=Br(t.offsets.reference),t=s(t,o))}),t}function bA(){if(!this.state.isDestroyed){var e={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:!1,offsets:{}};e.offsets.reference=I2(this.state,this.popper,this.reference,this.options.positionFixed),e.placement=b2(this.options.placement,e.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),e.originalPlacement=e.placement,e.positionFixed=this.options.positionFixed,e.offsets.popper=A2(this.popper,e.offsets.reference,e.placement),e.offsets.popper.position=this.options.positionFixed?"fixed":"absolute",e=S2(this.modifiers,e),this.state.isCreated?this.options.onUpdate(e):(this.state.isCreated=!0,this.options.onCreate(e))}}function x2(e,t){return e.some(function(n){var r=n.name,o=n.enabled;return o&&r===t})}function pc(e){for(var t=[!1,"ms","Webkit","Moz","O"],n=e.charAt(0).toUpperCase()+e.slice(1),r=0;ri[V]&&(e.offsets.popper[M]+=d[M]+_-i[V]),e.offsets.popper=Br(e.offsets.popper);var k=d[M]+d[g]/2-_/2,z=fi(e.instance.popper),I=parseFloat(z["margin"+w]),H=parseFloat(z["border"+w+"Width"]),A=k-e.offsets.popper[M]-I-H;return A=Math.max(Math.min(i[g]-_,A),0),e.arrowElement=r,e.offsets.arrow=(n={},Pi(n,M,Math.round(A)),Pi(n,R,""),n),e}function HA(e){return e==="end"?"start":e==="start"?"end":e}var k2=["auto-start","auto","auto-end","top-start","top","top-end","right-start","right","right-end","bottom-end","bottom","bottom-start","left-end","left","left-start"],ta=k2.slice(3);function Bu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=ta.indexOf(e),r=ta.slice(n+1).concat(ta.slice(0,n));return t?r.reverse():r}var na={FLIP:"flip",CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise"};function VA(e,t){if(x2(e.instance.modifiers,"inner")||e.flipped&&e.placement===e.originalPlacement)return e;var n=dc(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement,e.positionFixed),r=e.placement.split("-")[0],o=W1(r),s=e.placement.split("-")[1]||"",i=[];switch(t.behavior){case na.FLIP:i=[r,o];break;case na.CLOCKWISE:i=Bu(r);break;case na.COUNTERCLOCKWISE:i=Bu(r,!0);break;default:i=t.behavior}return i.forEach(function(d,S){if(r!==d||i.length===S+1)return e;r=e.placement.split("-")[0],o=W1(r);var g=e.offsets.popper,w=e.offsets.reference,M=Math.floor,R=r==="left"&&M(g.right)>M(w.left)||r==="right"&&M(g.left)M(w.top)||r==="bottom"&&M(g.top)M(n.right),k=M(g.top)M(n.bottom),I=r==="left"&&V||r==="right"&&_||r==="top"&&k||r==="bottom"&&z,H=["top","bottom"].indexOf(r)!==-1,A=!!t.flipVariations&&(H&&s==="start"&&V||H&&s==="end"&&_||!H&&s==="start"&&k||!H&&s==="end"&&z),x=!!t.flipVariationsByContent&&(H&&s==="start"&&_||H&&s==="end"&&V||!H&&s==="start"&&z||!H&&s==="end"&&k),p=A||x;(R||I||p)&&(e.flipped=!0,(R||I)&&(r=i[S+1]),p&&(s=HA(s)),e.placement=r+(s?"-"+s:""),e.offsets.popper=Yn({},e.offsets.popper,A2(e.instance.popper,e.offsets.reference,e.placement)),e=S2(e.instance.modifiers,e,"flip"))}),e}function _A(e){var t=e.offsets,n=t.popper,r=t.reference,o=e.placement.split("-")[0],s=Math.floor,i=["top","bottom"].indexOf(o)!==-1,d=i?"right":"bottom",S=i?"left":"top",g=i?"width":"height";return n[d]s(r[d])&&(e.offsets.popper[S]=s(r[d])),e}function NA(e,t,n,r){var o=e.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),s=+o[1],i=o[2];if(!s)return e;if(i.indexOf("%")===0){var d=void 0;switch(i){case"%p":d=n;break;case"%":case"%r":default:d=r}var S=Br(d);return S[t]/100*s}else if(i==="vh"||i==="vw"){var g=void 0;return i==="vh"?g=Math.max(document.documentElement.clientHeight,window.innerHeight||0):g=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g/100*s}else return s}function OA(e,t,n,r){var o=[0,0],s=["right","left"].indexOf(r)!==-1,i=e.split(/(\+|\-)/).map(function(w){return w.trim()}),d=i.indexOf(Go(i,function(w){return w.search(/,|\s/)!==-1}));i[d]&&i[d].indexOf(",")===-1&&console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");var S=/\s*,\s*|\s+/,g=d!==-1?[i.slice(0,d).concat([i[d].split(S)[0]]),[i[d].split(S)[1]].concat(i.slice(d+1))]:[i];return g=g.map(function(w,M){var R=(M===1?!s:s)?"height":"width",V=!1;return w.reduce(function(_,k){return _[_.length-1]===""&&["+","-"].indexOf(k)!==-1?(_[_.length-1]=k,V=!0,_):V?(_[_.length-1]+=k,V=!1,_):_.concat(k)},[]).map(function(_){return NA(_,R,t,n)})}),g.forEach(function(w,M){w.forEach(function(R,V){fc(R)&&(o[M]+=R*(w[V-1]==="-"?-1:1))})}),o}function PA(e,t){var n=t.offset,r=e.placement,o=e.offsets,s=o.popper,i=o.reference,d=r.split("-")[0],S=void 0;return fc(+n)?S=[+n,0]:S=OA(n,s,i,d),d==="left"?(s.top+=S[0],s.left-=S[1]):d==="right"?(s.top+=S[0],s.left+=S[1]):d==="top"?(s.left+=S[0],s.top-=S[1]):d==="bottom"&&(s.left+=S[0],s.top+=S[1]),e.popper=s,e}function DA(e,t){var n=t.boundariesElement||Ni(e.instance.popper);e.instance.reference===n&&(n=Ni(n));var r=pc("transform"),o=e.instance.popper.style,s=o.top,i=o.left,d=o[r];o.top="",o.left="",o[r]="";var S=dc(e.instance.popper,e.instance.reference,t.padding,n,e.positionFixed);o.top=s,o.left=i,o[r]=d,t.boundaries=S;var g=t.priority,w=e.offsets.popper,M={primary:function(V){var _=w[V];return w[V]S[V]&&!t.escapeWithReference&&(k=Math.min(w[_],S[V]-(V==="right"?w.width:w.height))),Pi({},_,k)}};return g.forEach(function(R){var V=["left","top"].indexOf(R)!==-1?"primary":"secondary";w=Yn({},w,M[V](R))}),e.offsets.popper=w,e}function $A(e){var t=e.placement,n=t.split("-")[0],r=t.split("-")[1];if(r){var o=e.offsets,s=o.reference,i=o.popper,d=["bottom","top"].indexOf(n)!==-1,S=d?"left":"top",g=d?"width":"height",w={start:Pi({},S,s[S]),end:Pi({},S,s[S]+s[g]-i[g])};e.offsets.popper=Yn({},i,w[r])}return e}function BA(e){if(!z2(e.instance.modifiers,"hide","preventOverflow"))return e;var t=e.offsets.reference,n=Go(e.instance.modifiers,function(r){return r.name==="preventOverflow"}).boundaries;if(t.bottomn.right||t.top>n.bottom||t.right2&&arguments[2]!==void 0?arguments[2]:{};gA(this,e),this.scheduleUpdate=function(){return requestAnimationFrame(r.update)},this.update=dA(this.update.bind(this)),this.options=Yn({},e.Defaults,o),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=t&&t.jquery?t[0]:t,this.popper=n&&n.jquery?n[0]:n,this.options.modifiers={},Object.keys(Yn({},e.Defaults.modifiers,o.modifiers)).forEach(function(i){r.options.modifiers[i]=Yn({},e.Defaults.modifiers[i]||{},o.modifiers?o.modifiers[i]:{})}),this.modifiers=Object.keys(this.options.modifiers).map(function(i){return Yn({name:i},r.options.modifiers[i])}).sort(function(i,d){return i.order-d.order}),this.modifiers.forEach(function(i){i.enabled&&g2(i.onLoad)&&i.onLoad(r.reference,r.popper,r.options,i,r.state)}),this.update();var s=this.options.eventsEnabled;s&&this.enableEventListeners(),this.state.eventsEnabled=s}return mA(e,[{key:"update",value:function(){return bA.call(this)}},{key:"destroy",value:function(){return IA.call(this)}},{key:"enableEventListeners",value:function(){return AA.call(this)}},{key:"disableEventListeners",value:function(){return xA.call(this)}}]),e}();Cs.Utils=(typeof window<"u"?window:global).PopperUtils;Cs.placements=k2;Cs.Defaults=GA;const L2=Cs;var Fa={exports:{}},Wa={exports:{}},Fu="__global_unique_id__",jA=function(){return po[Fu]=(po[Fu]||0)+1};(function(e,t){t.__esModule=!0;var n=de;S(n);var r=Mo,o=S(r),s=jA,i=S(s),d=lp;S(d);function S(I){return I&&I.__esModule?I:{default:I}}function g(I,H){if(!(I instanceof H))throw new TypeError("Cannot call a class as a function")}function w(I,H){if(!I)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return H&&(typeof H=="object"||typeof H=="function")?H:I}function M(I,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof H);I.prototype=Object.create(H&&H.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}}),H&&(Object.setPrototypeOf?Object.setPrototypeOf(I,H):I.__proto__=H)}var R=1073741823;function V(I,H){return I===H?I!==0||1/I===1/H:I!==I&&H!==H}function _(I){var H=[];return{on:function(x){H.push(x)},off:function(x){H=H.filter(function(p){return p!==x})},get:function(){return I},set:function(x,p){I=x,H.forEach(function(v){return v(I,p)})}}}function k(I){return Array.isArray(I)?I[0]:I}function z(I,H){var A,x,p="__create-react-context-"+(0,i.default)()+"__",v=function(a){M(h,a);function h(){var u,b,m;g(this,h);for(var l=arguments.length,c=Array(l),f=0;f1?n-1:0),o=1;o=0)&&(n[o]=e[o]);return n}function lS(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var io="unmounted";Sn.UNMOUNTED=io;var qr="exited";Sn.EXITED=qr;var ei="entering";Sn.ENTERING=ei;var wi="entered";Sn.ENTERED=wi;var Za="exiting";Sn.EXITING=Za;var yr=function(e){lS(t,e);function t(r,o){var s;s=e.call(this,r,o)||this;var i=o.transitionGroup,d=i&&!i.isMounting?r.enter:r.appear,S;return s.appearStatus=null,r.in?d?(S=qr,s.appearStatus=ei):S=wi:r.unmountOnExit||r.mountOnEnter?S=io:S=qr,s.state={status:S},s.nextCallback=null,s}var n=t.prototype;return n.getChildContext=function(){return{transitionGroup:null}},t.getDerivedStateFromProps=function(o,s){var i=o.in;return i&&s.status===io?{status:qr}:null},n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var s=null;if(o!==this.props){var i=this.state.status;this.props.in?i!==ei&&i!==wi&&(s=ei):(i===ei||i===wi)&&(s=Za)}this.updateStatus(!1,s)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,s,i,d;return s=i=d=o,o!=null&&typeof o!="number"&&(s=o.exit,i=o.enter,d=o.appear!==void 0?o.appear:i),{exit:s,enter:i,appear:d}},n.updateStatus=function(o,s){if(o===void 0&&(o=!1),s!==null){this.cancelNextCallback();var i=iS.default.findDOMNode(this);s===ei?this.performEnter(i,o):this.performExit(i)}else this.props.unmountOnExit&&this.state.status===qr&&this.setState({status:io})},n.performEnter=function(o,s){var i=this,d=this.props.enter,S=this.context.transitionGroup?this.context.transitionGroup.isMounting:s,g=this.getTimeouts(),w=S?g.appear:g.enter;if(!s&&!d){this.safeSetState({status:wi},function(){i.props.onEntered(o)});return}this.props.onEnter(o,S),this.safeSetState({status:ei},function(){i.props.onEntering(o,S),i.onTransitionEnd(o,w,function(){i.safeSetState({status:wi},function(){i.props.onEntered(o,S)})})})},n.performExit=function(o){var s=this,i=this.props.exit,d=this.getTimeouts();if(!i){this.safeSetState({status:qr},function(){s.props.onExited(o)});return}this.props.onExit(o),this.safeSetState({status:Za},function(){s.props.onExiting(o),s.onTransitionEnd(o,d.exit,function(){s.safeSetState({status:qr},function(){s.props.onExited(o)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,s){s=this.setNextCallback(s),this.setState(o,s)},n.setNextCallback=function(o){var s=this,i=!0;return this.nextCallback=function(d){i&&(i=!1,s.nextCallback=null,o(d))},this.nextCallback.cancel=function(){i=!1},this.nextCallback},n.onTransitionEnd=function(o,s,i){this.setNextCallback(i);var d=s==null&&!this.props.addEndListener;if(!o||d){setTimeout(this.nextCallback,0);return}this.props.addEndListener&&this.props.addEndListener(o,this.nextCallback),s!=null&&setTimeout(this.nextCallback,s)},n.render=function(){var o=this.state.status;if(o===io)return null;var s=this.props,i=s.children,d=aS(s,["children"]);if(delete d.in,delete d.mountOnEnter,delete d.unmountOnExit,delete d.appear,delete d.enter,delete d.exit,delete d.timeout,delete d.addEndListener,delete d.onEnter,delete d.onEntering,delete d.onEntered,delete d.onExit,delete d.onExiting,delete d.onExited,typeof i=="function")return i(o,d);var S=ra.default.Children.only(i);return ra.default.cloneElement(S,d)},t}(ra.default.Component);yr.contextTypes={transitionGroup:rS.object};yr.childContextTypes={transitionGroup:function(){}};yr.propTypes={};function Ii(){}yr.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ii,onEntering:Ii,onEntered:Ii,onExit:Ii,onExiting:Ii,onExited:Ii};yr.UNMOUNTED=0;yr.EXITED=1;yr.ENTERING=2;yr.ENTERED=3;yr.EXITING=4;var cS=(0,oS.polyfill)(yr);Sn.default=cS;(function(e,t){t.__esModule=!0,t.default=void 0,d(Mo);var n=i(tS),r=i(nS),o=i(de),s=i(Sn);function i(_){return _&&_.__esModule?_:{default:_}}function d(_){if(_&&_.__esModule)return _;var k={};if(_!=null){for(var z in _)if(Object.prototype.hasOwnProperty.call(_,z)){var I=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(_,z):{};I.get||I.set?Object.defineProperty(k,z,I):k[z]=_[z]}}return k.default=_,k}function S(){return S=Object.assign||function(_){for(var k=1;k=0)&&(I[A]=k[A]);return I}function S(){return S=Object.assign||function(k){for(var z=1;z=0)&&(R[_]=w[_]);return R}function d(w,M){w.prototype=Object.create(M.prototype),w.prototype.constructor=w,w.__proto__=M}var S=function(w){d(M,w);function M(){for(var V,_=arguments.length,k=new Array(_),z=0;z<_;z++)k[z]=arguments[z];return V=w.call.apply(w,[this].concat(k))||this,V.handleEnter=function(){for(var I=arguments.length,H=new Array(I),A=0;A"u"||!this.state.hasMounted||this.portalElement===null?null:Mr.createPortal(this.props.children,this.portalElement)},t.prototype.componentDidMount=function(){this.props.container&&(this.portalElement=this.createContainerElement(),this.props.container.appendChild(this.portalElement),this.setState({hasMounted:!0},this.props.onChildrenMount),s1&&this.unstableRenderNoPortal())},t.prototype.componentDidUpdate=function(n){this.portalElement!=null&&n.className!==this.props.className&&(bS(this.portalElement.classList,n.className),ia(this.portalElement.classList,this.props.className)),s1&&this.unstableRenderNoPortal()},t.prototype.componentWillUnmount=function(){this.portalElement!=null&&(s1&&Mr.unmountComponentAtNode(this.portalElement),this.portalElement.remove())},t.prototype.createContainerElement=function(){var n=document.createElement("div");return n.classList.add(uI),ia(n.classList,this.props.className),this.context!=null&&ia(n.classList,this.context.blueprintPortalClassName),n},t.prototype.unstableRenderNoPortal=function(){this.portalElement!==null&&Mr.unstable_renderSubtreeIntoContainer(this,de.createElement("div",null,this.props.children),this.portalElement)},t.displayName="".concat(En,".Portal"),t.contextTypes=yS,t.defaultProps={container:typeof document<"u"?document.body:void 0},t}(de.Component);function bS(e,t){t!=null&&t!==""&&e.remove.apply(e,t.split(" "))}function ia(e,t){t!=null&&t!==""&&e.add.apply(e,t.split(" "))}var B2=function(e){wn(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.isAutoFocusing=!1,r.state={hasEverOpened:r.props.isOpen},r.containerElement=null,r.startFocusTrapElement=null,r.endFocusTrapElement=null,r.refHandlers={container:function(o){return r.containerElement=Mr.findDOMNode(o)},endFocusTrap:function(o){return r.endFocusTrapElement=o},startFocusTrap:function(o){return r.startFocusTrapElement=o}},r.maybeRenderChild=function(o){if(hi(o)&&(o=o()),o==null)return null;var s=typeof o=="object"?de.cloneElement(o,{className:vt(o.props.className,ru)}):de.createElement("span",{className:ru},o),i=r.props,d=i.onOpening,S=i.onOpened,g=i.onClosing,w=i.transitionDuration,M=i.transitionName,R=o1.CSSTransition;return de.createElement(R,{classNames:M,onEntering:d,onEntered:S,onExiting:g,onExited:r.handleTransitionExited,timeout:w,addEndListener:r.handleTransitionAddEnd},s)},r.handleStartFocusTrapElementFocus=function(o){var s;!r.props.enforceFocus||r.isAutoFocusing||o.relatedTarget!=null&&r.containerElement.contains(o.relatedTarget)&&o.relatedTarget!==r.endFocusTrapElement&&((s=r.endFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0}))},r.handleStartFocusTrapElementKeyDown=function(o){var s;if(r.props.enforceFocus&&o.shiftKey&&o.which===DI){var i=r.getKeyboardFocusableElements().pop();i!=null?i.focus():(s=r.endFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0})}},r.handleEndFocusTrapElementFocus=function(o){var s,i;if(o.relatedTarget!=null&&r.containerElement.contains(o.relatedTarget)&&o.relatedTarget!==r.startFocusTrapElement){var d=r.getKeyboardFocusableElements().shift();!r.isAutoFocusing&&d!=null&&d!==o.relatedTarget?d.focus():(s=r.startFocusTrapElement)===null||s===void 0||s.focus({preventScroll:!0})}else{var S=r.getKeyboardFocusableElements().pop();S!=null?S.focus():(i=r.startFocusTrapElement)===null||i===void 0||i.focus({preventScroll:!0})}},r.handleTransitionExited=function(o){var s,i;r.props.shouldReturnFocusOnClose&&r.lastActiveElementBeforeOpened instanceof HTMLElement&&r.lastActiveElementBeforeOpened.focus(),(i=(s=r.props).onClosed)===null||i===void 0||i.call(s,o)},r.handleBackdropMouseDown=function(o){var s,i=r.props,d=i.backdropProps,S=i.canOutsideClickClose,g=i.enforceFocus,w=i.onClose;S&&(w==null||w(o)),g&&r.bringFocusInsideOverlay(),(s=d==null?void 0:d.onMouseDown)===null||s===void 0||s.call(d,o)},r.handleDocumentClick=function(o){var s=r.props,i=s.canOutsideClickClose,d=s.isOpen,S=s.onClose,g=o.composed?o.composedPath()[0]:o.target,w=n.openStack.indexOf(r),M=n.openStack.slice(w).some(function(R){var V=R.containerElement;return V&&V.contains(g)&&!V.isSameNode(g)});d&&!M&&i&&(S==null||S(o))},r.handleDocumentFocus=function(o){var s=o.composed?o.composedPath()[0]:o.target;r.props.enforceFocus&&r.containerElement!=null&&s instanceof Node&&!r.containerElement.contains(s)&&(o.preventDefault(),o.stopImmediatePropagation(),r.bringFocusInsideOverlay())},r.handleKeyDown=function(o){var s=r.props,i=s.canEscapeKeyClose,d=s.onClose;o.which===$I&&i&&(d==null||d(o),o.preventDefault())},r.handleTransitionAddEnd=function(){},r}n=t,t.getDerivedStateFromProps=function(r){var o=r.isOpen;return o?{hasEverOpened:o}:null},t.prototype.render=function(){var r,o;if(this.props.lazy&&!this.state.hasEverOpened)return null;var s=this.props,i=s.autoFocus,d=s.children,S=s.className,g=s.enforceFocus,w=s.usePortal,M=s.isOpen,R=M?(o=de.Children.map(d,this.maybeRenderChild))!==null&&o!==void 0?o:[]:[],V=this.maybeRenderBackdrop();V!==null&&R.unshift(V),M&&(i||g)&&R.length>0&&(R.unshift(this.renderDummyElement("__start",{className:iu,onFocus:this.handleStartFocusTrapElementFocus,onKeyDown:this.handleStartFocusTrapElementKeyDown,ref:this.refHandlers.startFocusTrap})),g&&R.push(this.renderDummyElement("__end",{className:ou,onFocus:this.handleEndFocusTrapElementFocus,ref:this.refHandlers.endFocusTrap})));var _=vt($r,(r={},r[Ys]=M,r[tI]=!w,r),S),k=de.createElement(o1.TransitionGroup,{appear:!0,"aria-live":"polite",className:_,component:"div",onKeyDown:this.handleKeyDown,ref:this.refHandlers.container},R);return w?de.createElement(CS,{className:this.props.portalClassName,container:this.props.portalContainer},k):k},t.prototype.componentDidMount=function(){this.props.isOpen&&this.overlayWillOpen()},t.prototype.componentDidUpdate=function(r){r.isOpen&&!this.props.isOpen?this.overlayWillClose():!r.isOpen&&this.props.isOpen&&this.overlayWillOpen()},t.prototype.componentWillUnmount=function(){this.overlayWillClose()},t.prototype.bringFocusInsideOverlay=function(){var r=this;return this.requestAnimationFrame(function(){var o;if(!(r.containerElement==null||document.activeElement==null||!r.props.isOpen)){var s=!r.containerElement.contains(document.activeElement);s&&((o=r.startFocusTrapElement)===null||o===void 0||o.focus({preventScroll:!0}),r.isAutoFocusing=!1)}})},t.prototype.maybeRenderBackdrop=function(){var r=this.props,o=r.backdropClassName,s=r.backdropProps,i=r.hasBackdrop,d=r.isOpen,S=r.transitionDuration,g=r.transitionName;return i&&d?de.createElement(o1.CSSTransition,{classNames:g,key:"__backdrop",timeout:S,addEndListener:this.handleTransitionAddEnd},de.createElement("div",Nt({},s,{className:vt(eI,o,s==null?void 0:s.className),onMouseDown:this.handleBackdropMouseDown}))):null},t.prototype.renderDummyElement=function(r,o){var s=this.props,i=s.transitionDuration,d=s.transitionName;return de.createElement(o1.CSSTransition,{classNames:d,key:r,addEndListener:this.handleTransitionAddEnd,timeout:i,unmountOnExit:!0},de.createElement("div",Nt({tabIndex:0},o)))},t.prototype.getKeyboardFocusableElements=function(){var r=this.containerElement!==null?Array.from(this.containerElement.querySelectorAll(['a[href]:not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','details:not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"])'].join(","))):[];return r.filter(function(o){return!o.classList.contains(iu)&&!o.classList.contains(ou)})},t.prototype.overlayWillClose=function(){document.removeEventListener("focus",this.handleDocumentFocus,!0),document.removeEventListener("mousedown",this.handleDocumentClick);var r=n.openStack,o=r.indexOf(this);if(o!==-1){if(r.splice(o,1),r.length>0){var s=n.getLastOpened();s.props.autoFocus&&s.props.enforceFocus&&(s.bringFocusInsideOverlay(),document.addEventListener("focus",s.handleDocumentFocus,!0))}r.filter(function(i){return i.props.usePortal&&i.props.hasBackdrop}).length===0&&document.body.classList.remove(Ys)}},t.prototype.overlayWillOpen=function(){var r=n.getLastOpened,o=n.openStack;o.length>0&&document.removeEventListener("focus",r().handleDocumentFocus,!0),o.push(this),this.props.autoFocus&&(this.isAutoFocusing=!0,this.bringFocusInsideOverlay()),this.props.enforceFocus&&document.addEventListener("focus",this.handleDocumentFocus,!0),this.props.canOutsideClickClose&&!this.props.hasBackdrop&&document.addEventListener("mousedown",this.handleDocumentClick),this.props.hasBackdrop&&this.props.usePortal&&document.body.classList.add(Ys),this.lastActiveElementBeforeOpened=document.activeElement};var n;return t.displayName="".concat(En,".Overlay"),t.defaultProps={autoFocus:!0,backdropProps:{},canEscapeKeyClose:!0,canOutsideClickClose:!0,enforceFocus:!0,hasBackdrop:!0,isOpen:!1,lazy:!0,shouldReturnFocusOnClose:!0,transitionDuration:300,transitionName:$r,usePortal:!0},t.openStack=[],t.getLastOpened=function(){return n.openStack[n.openStack.length-1]},t=n=mr([sr],t),t}(vr),oi=[],IS=function(){return oi.some(function(e){return e.activeTargets.length>0})},wS=function(){return oi.some(function(e){return e.skippedTargets.length>0})},ju="ResizeObserver loop completed with undelivered notifications.",AS=function(){var e;typeof ErrorEvent=="function"?e=new ErrorEvent("error",{message:ju}):(e=document.createEvent("Event"),e.initEvent("error",!1,!1),e.message=ju),window.dispatchEvent(e)},xo;(function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(xo||(xo={}));var si=function(e){return Object.freeze(e)},SS=function(){function e(t,n){this.inlineSize=t,this.blockSize=n,si(this)}return e}(),F2=function(){function e(t,n,r,o){return this.x=t,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,si(this)}return e.prototype.toJSON=function(){var t=this,n=t.x,r=t.y,o=t.top,s=t.right,i=t.bottom,d=t.left,S=t.width,g=t.height;return{x:n,y:r,top:o,right:s,bottom:i,left:d,width:S,height:g}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),mc=function(e){return e instanceof SVGElement&&"getBBox"in e},W2=function(e){if(mc(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,s=o.offsetWidth,i=o.offsetHeight;return!(s||i||e.getClientRects().length)},Zu=function(e){var t;if(e instanceof Element)return!0;var n=(t=e==null?void 0:e.ownerDocument)===null||t===void 0?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},xS=function(e){switch(e.tagName){case"INPUT":if(e.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},ho=typeof window<"u"?window:{},a1=new WeakMap,Ku=/auto|scroll/,MS=/^tb|vertical/,ES=/msie|trident/i.test(ho.navigator&&ho.navigator.userAgent),lr=function(e){return parseFloat(e||"0")},Li=function(e,t,n){return e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=!1),new SS((n?t:e)||0,(n?e:t)||0)},Uu=si({devicePixelContentBoxSize:Li(),borderBoxSize:Li(),contentBoxSize:Li(),contentRect:new F2(0,0,0,0)}),G2=function(e,t){if(t===void 0&&(t=!1),a1.has(e)&&!t)return a1.get(e);if(W2(e))return a1.set(e,Uu),Uu;var n=getComputedStyle(e),r=mc(e)&&e.ownerSVGElement&&e.getBBox(),o=!ES&&n.boxSizing==="border-box",s=MS.test(n.writingMode||""),i=!r&&Ku.test(n.overflowY||""),d=!r&&Ku.test(n.overflowX||""),S=r?0:lr(n.paddingTop),g=r?0:lr(n.paddingRight),w=r?0:lr(n.paddingBottom),M=r?0:lr(n.paddingLeft),R=r?0:lr(n.borderTopWidth),V=r?0:lr(n.borderRightWidth),_=r?0:lr(n.borderBottomWidth),k=r?0:lr(n.borderLeftWidth),z=M+g,I=S+w,H=k+V,A=R+_,x=d?e.offsetHeight-A-e.clientHeight:0,p=i?e.offsetWidth-H-e.clientWidth:0,v=o?z+H:0,y=o?I+A:0,a=r?r.width:lr(n.width)-v-p,h=r?r.height:lr(n.height)-y-x,u=a+z+p+H,b=h+I+x+A,m=si({devicePixelContentBoxSize:Li(Math.round(a*devicePixelRatio),Math.round(h*devicePixelRatio),s),borderBoxSize:Li(u,b,s),contentBoxSize:Li(a,h,s),contentRect:new F2(M,S,a,h)});return a1.set(e,m),m},j2=function(e,t,n){var r=G2(e,n),o=r.borderBoxSize,s=r.contentBoxSize,i=r.devicePixelContentBoxSize;switch(t){case xo.DEVICE_PIXEL_CONTENT_BOX:return i;case xo.BORDER_BOX:return o;default:return s}},zS=function(){function e(t){var n=G2(t);this.target=t,this.contentRect=n.contentRect,this.borderBoxSize=si([n.borderBoxSize]),this.contentBoxSize=si([n.contentBoxSize]),this.devicePixelContentBoxSize=si([n.devicePixelContentBoxSize])}return e}(),Z2=function(e){if(W2(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},kS=function(){var e=1/0,t=[];oi.forEach(function(i){if(i.activeTargets.length!==0){var d=[];i.activeTargets.forEach(function(g){var w=new zS(g.target),M=Z2(g.target);d.push(w),g.lastReportedSize=j2(g.target,g.observedBox),Me?n.activeTargets.push(o):n.skippedTargets.push(o))})})},LS=function(){var e=0;for(Xu(e);IS();)e=kS(),Xu(e);return wS()&&AS(),e>0},oa,K2=[],TS=function(){return K2.splice(0).forEach(function(e){return e()})},RS=function(e){if(!oa){var t=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return TS()}).observe(n,r),oa=function(){n.textContent="".concat(t?t--:t++)}}K2.push(e),oa()},HS=function(e){RS(function(){requestAnimationFrame(e)})},w1=0,VS=function(){return!!w1},_S=250,NS={attributes:!0,characterData:!0,childList:!0,subtree:!0},Yu=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Ju=function(e){return e===void 0&&(e=0),Date.now()+e},sa=!1,OS=function(){function e(){var t=this;this.stopped=!0,this.listener=function(){return t.schedule()}}return e.prototype.run=function(t){var n=this;if(t===void 0&&(t=_S),!sa){sa=!0;var r=Ju(t);HS(function(){var o=!1;try{o=LS()}finally{if(sa=!1,t=r-Ju(),!VS())return;o?n.run(1e3):t>0?n.run(t):n.start()}})}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var t=this,n=function(){return t.observer&&t.observer.observe(document.body,NS)};document.body?n():ho.addEventListener("DOMContentLoaded",n)},e.prototype.start=function(){var t=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Yu.forEach(function(n){return ho.addEventListener(n,t.listener,!0)}))},e.prototype.stop=function(){var t=this;this.stopped||(this.observer&&this.observer.disconnect(),Yu.forEach(function(n){return ho.removeEventListener(n,t.listener,!0)}),this.stopped=!0)},e}(),Xa=new OS,Qu=function(e){!w1&&e>0&&Xa.start(),w1+=e,!w1&&Xa.stop()},PS=function(e){return!mc(e)&&!xS(e)&&getComputedStyle(e).display==="inline"},DS=function(){function e(t,n){this.target=t,this.observedBox=n||xo.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var t=j2(this.target,this.observedBox,!0);return PS(this.target)&&(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),$S=function(){function e(t,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=t,this.callback=n}return e}(),l1=new WeakMap,qu=function(e,t){for(var n=0;n=0&&(s&&oi.splice(oi.indexOf(r),1),r.observationTargets.splice(o,1),Qu(-1))},e.disconnect=function(t){var n=this,r=l1.get(t);r.observationTargets.slice().forEach(function(o){return n.unobserve(t,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},e}(),BS=function(){function e(t){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof t!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");c1.connect(this,t)}return e.prototype.observe=function(t,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Zu(t))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");c1.observe(this,t,n)},e.prototype.unobserve=function(t){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Zu(t))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");c1.unobserve(this,t)},e.prototype.disconnect=function(){c1.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}(),eh=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.element=null,n.observer=new BS(function(r){var o,s;return(s=(o=n.props).onResize)===null||s===void 0?void 0:s.call(o,r)}),n}return t.prototype.render=function(){return de.Children.only(this.props.children)},t.prototype.componentDidMount=function(){this.observeElement()},t.prototype.componentDidUpdate=function(n){this.observeElement(this.props.observeParents!==n.observeParents)},t.prototype.componentWillUnmount=function(){this.observer.disconnect()},t.prototype.observeElement=function(n){n===void 0&&(n=!1);var r=this.getElement();if(!(r instanceof Element)){this.observer.disconnect();return}if(!(r===this.element&&!n)&&(this.observer.disconnect(),this.element=r,this.observer.observe(r),this.props.observeParents))for(var o=r.parentElement;o!=null;)this.observer.observe(o),o=o.parentElement},t.prototype.getElement=function(){try{return Mr.findDOMNode(this)}catch{return null}},t.displayName="".concat(En,".ResizeSensor"),t=mr([sr],t),t}(vr),FS=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.popover=null,n}return t.prototype.render=function(){var n,r=this,o=this.props,s=o.children,i=o.intent,d=o.popoverClassName,S=kr(o,["children","intent","popoverClassName"]),g=vt(hI,(n={},n[Z5]=this.props.minimal,n),Gr(i),d);return de.createElement(X2,Nt({interactionKind:ur.HOVER_TARGET_ONLY,modifiers:{arrow:{enabled:!this.props.minimal}}},S,{autoFocus:!1,canEscapeKeyClose:!1,enforceFocus:!1,lazy:!0,popoverClassName:g,portalContainer:this.props.portalContainer,ref:function(w){return r.popover=w}}),s)},t.prototype.reposition=function(){this.popover!=null&&this.popover.reposition()},t.displayName="".concat(En,".Tooltip"),t.defaultProps={hoverCloseDelay:0,hoverOpenDelay:100,minimal:!1,transitionDuration:100},t=mr([sr],t),t}(vr);function vc(e){return e.split("-")[0]}function Ya(e){return["left","right"].indexOf(e)!==-1}function u1(e){switch(e){case"top":return"bottom";case"left":return"right";case"bottom":return"top";default:return"left"}}function th(e){var t=e.split("-")[1];switch(t){case"start":return"left";case"end":return"right";default:return"center"}}function WS(e){var t=vc(e.placement);if(e.arrowElement==null)return Ya(t)?"".concat(u1(t)," ").concat(th(t)):"".concat(th(t)," ").concat(u1(t));var n=e.arrowElement.clientHeight/2,r=e.offsets.arrow;return Ya(t)?"".concat(u1(t)," ").concat(r.top+n,"px"):"".concat(r.left+n,"px ").concat(u1(t))}var nh=4,GS=function(e){if(e.arrowElement==null)return e;var t=e.arrowElement.clientWidth,n=vc(e.placement),r=Ya(n),o=r?"width":"height",s=r?"left":"top",i=Math.round(t/2/Math.sqrt(2));return n==="top"||n==="left"?(e.offsets.popper[s]-=i+nh,e.offsets.arrow[s]=e.offsets.popper[o]-t+i):(e.offsets.popper[s]+=i+nh,e.offsets.arrow[s]=-i),e},jS="M8.11 6.302c1.015-.936 1.887-2.922 1.887-4.297v26c0-1.378-.868-3.357-1.888-4.297L.925 17.09c-1.237-1.14-1.233-3.034 0-4.17L8.11 6.302z",ZS="M8.787 7.036c1.22-1.125 2.21-3.376 2.21-5.03V0v30-2.005c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z";function KS(e){if(e==null)return 0;switch(vc(e)){case"top":return-90;case"left":return 180;case"bottom":return 90;default:return 0}}var U2=function(e){var t=e.arrowProps,n=t.ref,r=t.style,o=e.placement;return de.createElement("div",{className:Js,ref:n,style:r.left==null||isNaN(+r.left)?{}:r},de.createElement("svg",{viewBox:"0 0 30 30",style:{transform:"rotate(".concat(KS(o),"deg)")}},de.createElement("path",{className:Js+"-border",d:jS}),de.createElement("path",{className:Js+"-fill",d:ZS})))};U2.displayName="".concat(En,".PopoverArrow");function US(e){switch(e){case Pn.TOP_LEFT:return"top-start";case Pn.TOP:return"top";case Pn.TOP_RIGHT:return"top-end";case Pn.RIGHT_TOP:return"right-start";case Pn.RIGHT:return"right";case Pn.RIGHT_BOTTOM:return"right-end";case Pn.BOTTOM_RIGHT:return"bottom-end";case Pn.BOTTOM:return"bottom";case Pn.BOTTOM_LEFT:return"bottom-start";case Pn.LEFT_BOTTOM:return"left-end";case Pn.LEFT:return"left";case Pn.LEFT_TOP:return"left-start";case"auto":case"auto-start":case"auto-end":return e;default:return XS(e)}}function XS(e){throw new Error("Unexpected position: "+e)}var ur={CLICK:"click",CLICK_TARGET_ONLY:"click-target",HOVER:"hover",HOVER_TARGET_ONLY:"hover-target"},X2=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.popoverRef=VI(),n.popoverElement=null,n.targetElement=null,n.state={hasDarkParent:!1,isOpen:n.getIsOpen(n.props),transformOrigin:""},n.isMouseInTargetOrPopover=!1,n.lostFocusOnSamePage=!0,n.handlePopoverRef=lu(n,"popoverElement",n.props.popoverRef),n.handleTargetRef=function(r){return n.targetElement=r},n.reposition=function(){var r;return(r=n.popperScheduleUpdate)===null||r===void 0?void 0:r.call(n)},n.renderPopover=function(r){var o,s=n.props,i=s.interactionKind,d=s.usePortal,S=n.state.transformOrigin;n.popperScheduleUpdate=r.scheduleUpdate;var g={onClick:n.handlePopoverClick};(i===ur.HOVER||!d&&i===ur.HOVER_TARGET_ONLY)&&(g.onMouseEnter=n.handleMouseEnter,g.onMouseLeave=n.handleMouseLeave);var w=vt(Qn,(o={},o[tu]=n.props.inheritDarkTheme&&n.state.hasDarkParent,o[Z5]=n.props.minimal,o[su]=n.props.captureDismiss,o[sI]=r.outOfBoundaries===!0,o),n.props.popoverClassName);return de.createElement("div",{className:cI,ref:r.ref,style:r.style},de.createElement(eh,{onResize:n.reposition},de.createElement("div",Nt({className:w,style:{transformOrigin:S},ref:n.popoverRef},g),n.isArrowEnabled()&&de.createElement(U2,{arrowProps:r.arrowProps,placement:r.placement}),de.createElement("div",{className:rI},n.understandChildren().content))))},n.renderTarget=function(r){var o,s,i=n.props,d=i.fill,S=i.openOnTargetFocus,g=i.targetClassName,w=i.targetProps,M=w===void 0?{}:w,R=n.state.isOpen,V=n.isControlled(),_=n.isHoverInteractionKind(),k=n.props.targetTagName;d&&(k="div");var z=_?{onBlur:n.handleTargetBlur,onFocus:n.handleTargetFocus,onMouseEnter:n.handleMouseEnter,onMouseLeave:n.handleMouseLeave}:{onClick:n.handleTargetClick};z["aria-haspopup"]="true",z.className=vt(aI,(o={},o[oI]=R,o),M.className,g),z.ref=r.ref;var I=au(n.understandChildren().target);if(I===void 0)return null;var H=I.props.tabIndex,A=H==null&&S&&_?0:H,x=de.cloneElement(I,{className:vt(I.props.className,(s={},s[G5]=R&&!V&&!_,s)),disabled:R&&HI(I,FS)?!0:I.props.disabled,tabIndex:A}),p=de.createElement(k,Nt(Nt({},M),z),x);return de.createElement(eh,{onResize:n.reposition},p)},n.isControlled=function(){return n.props.isOpen!==void 0},n.handleTargetFocus=function(r){var o,s;if(n.props.openOnTargetFocus&&n.isHoverInteractionKind()){if(r.relatedTarget==null&&!n.lostFocusOnSamePage)return;n.handleMouseEnter(r)}(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onFocus)===null||s===void 0||s.call(o,r)},n.handleTargetBlur=function(r){var o,s;n.props.openOnTargetFocus&&n.isHoverInteractionKind()&&r.relatedTarget!=null&&!n.isElementInPopover(r.relatedTarget)&&n.handleMouseLeave(r),n.lostFocusOnSamePage=r.relatedTarget!=null,(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onBlur)===null||s===void 0||s.call(o,r)},n.handleMouseEnter=function(r){var o,s;n.isMouseInTargetOrPopover=!0,!n.props.usePortal&&n.isElementInPopover(r.target)&&n.props.interactionKind===ur.HOVER_TARGET_ONLY&&!n.props.openOnTargetFocus?n.handleMouseLeave(r):n.props.disabled||n.setOpenState(!0,r,n.props.hoverOpenDelay),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onMouseEnter)===null||s===void 0||s.call(o,r)},n.handleMouseLeave=function(r){var o,s;n.isMouseInTargetOrPopover=!1,n.setTimeout(function(){n.isMouseInTargetOrPopover||n.setOpenState(!1,r,n.props.hoverCloseDelay)}),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onMouseLeave)===null||s===void 0||s.call(o,r)},n.handlePopoverClick=function(r){var o=r.target,s=o.closest(".".concat(Qn)),i=s===n.popoverRef.current,d=s==null?void 0:s.classList.contains(su),S=o.closest(".".concat(B1,", .").concat(iI)),g=S!=null&&S.classList.contains(B1),w=o.closest(":disabled, .".concat(oc))!=null;g&&!w&&(!d||i)&&n.setOpenState(!1,r)},n.handleOverlayClose=function(r){if(!(n.targetElement===null||r===void 0)){var o=r.target;(!bI(n.targetElement,o)||r.nativeEvent instanceof KeyboardEvent)&&n.setOpenState(!1,r)}},n.handleTargetClick=function(r){var o,s;!n.props.disabled&&!n.isElementInPopover(r.target)&&(n.props.isOpen==null?n.setState(function(i){return{isOpen:!i.isOpen}}):n.setOpenState(!n.props.isOpen,r)),(s=(o=n.props.targetProps)===null||o===void 0?void 0:o.onClick)===null||s===void 0||s.call(o,r)},n.updatePopoverState=function(r){return n.setState({transformOrigin:WS(r)}),r},n}return t.prototype.render=function(){var n,r,o=this.props,s=o.className,i=o.disabled,d=o.fill,S=o.placement,g=o.position,w=g===void 0?"auto":g,M=o.shouldReturnFocusOnClose,R=this.state.isOpen,V=this.props.wrapperTagName;d&&(V="div");var _=au(this.understandChildren().content)==null;_&&!i&&R!==!1&&!Ao("production")&&console.warn(EI);var k=vt(lI,s,(n={},n[sc]=d,n)),z=this.isHoverInteractionKind()?!1:void 0,I=de.createElement(V,{className:k},de.createElement(qA,{innerRef:this.handleTargetRef},this.renderTarget),de.createElement(B2,{autoFocus:(r=this.props.autoFocus)!==null&&r!==void 0?r:z,backdropClassName:nI,backdropProps:this.props.backdropProps,canEscapeKeyClose:this.props.canEscapeKeyClose,canOutsideClickClose:this.props.interactionKind===ur.CLICK,className:this.props.portalClassName,enforceFocus:this.props.enforceFocus,hasBackdrop:this.props.hasBackdrop,isOpen:R&&!_,onClose:this.handleOverlayClose,onClosed:this.props.onClosed,onClosing:this.props.onClosing,onOpened:this.props.onOpened,onOpening:this.props.onOpening,transitionDuration:this.props.transitionDuration,transitionName:Qn,usePortal:this.props.usePortal,portalContainer:this.props.portalContainer,shouldReturnFocusOnClose:this.isHoverInteractionKind()?!1:M},de.createElement(JA,{innerRef:this.handlePopoverRef,placement:S??US(w),modifiers:this.getPopperModifiers()},this.renderPopover)));return de.createElement(UA,null,I)},t.prototype.componentDidMount=function(){this.updateDarkParent()},t.prototype.componentDidUpdate=function(n,r){e.prototype.componentDidUpdate.call(this,n,r),n.popoverRef!==this.props.popoverRef&&(_a(n.popoverRef,null),this.handlePopoverRef=lu(this,"popoverElement",this.props.popoverRef),_a(this.props.popoverRef,this.popoverElement)),this.updateDarkParent();var o=this.getIsOpen(this.props);this.props.isOpen!=null&&o!==this.state.isOpen?(this.setOpenState(o),this.setState({isOpen:o})):this.props.disabled&&this.state.isOpen&&this.props.isOpen==null&&this.setOpenState(!1)},t.prototype.validateProps=function(n){n.isOpen==null&&n.onInteraction!=null&&console.warn(LI),n.hasBackdrop&&!n.usePortal&&console.warn(zI),n.hasBackdrop&&n.interactionKind!==ur.CLICK&&console.error(AI),n.placement!==void 0&&n.position!==void 0&&console.warn(kI);var r=de.Children.count(n.children),o=n.content!==void 0,s=n.target!==void 0;r===0&&!s&&console.error(wI),r>2&&console.warn(SI),r>0&&s&&console.warn(MI),r===2&&o&&console.warn(xI)},t.prototype.updateDarkParent=function(){if(this.props.usePortal&&this.state.isOpen){var n=this.targetElement!=null&&this.targetElement.closest(".".concat(tu))!=null;this.setState({hasDarkParent:n})}},t.prototype.understandChildren=function(){var n=this.props,r=n.children,o=n.content,s=n.target,i=de.Children.toArray(r),d=i[0],S=i[1];return{content:S??o,target:d??s}},t.prototype.getIsOpen=function(n){return n.disabled?!1:n.isOpen!=null?n.isOpen:n.defaultIsOpen},t.prototype.getPopperModifiers=function(){var n=this.props,r=n.boundary,o=n.modifiers,s=o,i=s.flip,d=i===void 0?{}:i,S=s.preventOverflow,g=S===void 0?{}:S;return Nt(Nt({},o),{arrowOffset:{enabled:this.isArrowEnabled(),fn:GS,order:510},flip:Nt({boundariesElement:r},d),preventOverflow:Nt({boundariesElement:r},g),updatePopoverState:{enabled:!0,fn:this.updatePopoverState,order:900}})},t.prototype.setOpenState=function(n,r,o){var s=this,i,d,S,g,w;(i=this.cancelOpenTimeout)===null||i===void 0||i.call(this),o!==void 0&&o>0?this.cancelOpenTimeout=this.setTimeout(function(){return s.setOpenState(n,r)},o):(this.props.isOpen==null?this.setState({isOpen:n}):(S=(d=this.props).onInteraction)===null||S===void 0||S.call(d,n,r),n||(w=(g=this.props).onClose)===null||w===void 0||w.call(g,r))},t.prototype.isArrowEnabled=function(){var n=this.props,r=n.minimal,o=n.modifiers;return!r&&((o==null?void 0:o.arrow)==null||o.arrow.enabled)},t.prototype.isElementInPopover=function(n){var r;return(r=this.popoverElement)===null||r===void 0?void 0:r.contains(n)},t.prototype.isHoverInteractionKind=function(){return this.props.interactionKind===ur.HOVER||this.props.interactionKind===ur.HOVER_TARGET_ONLY},t.displayName="".concat(En,".Popover"),t.defaultProps={boundary:"scrollParent",captureDismiss:!1,defaultIsOpen:!1,disabled:!1,fill:!1,hasBackdrop:!1,hoverCloseDelay:300,hoverOpenDelay:150,inheritDarkTheme:!0,interactionKind:ur.CLICK,minimal:!1,modifiers:{},openOnTargetFocus:!0,shouldReturnFocusOnClose:!1,targetTagName:"span",transitionDuration:300,usePortal:!0,wrapperTagName:"span"},t=mr([sr],t),t}(vr),YS={add:["M10.99 6.99h-2v-2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1zm-3-7c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],"add-clip":["M12 0a1 1 0 00-1 1v2H9a1 1 0 000 2h2v2a1 1 0 102 0V5h2a1 1 0 100-2h-2V1a1 1 0 00-1-1zM0 4a1 1 0 011-1h3.5a1 1 0 010 2H2v2a1 1 0 01-2 0V4zm1 12a1 1 0 01-1-1v-3a1 1 0 112 0v2h2.5a1 1 0 110 2H1zm11 0a1 1 0 001-1v-3a1 1 0 10-2 0v2H9a1 1 0 100 2h3zm-5.5-4a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"],"add-column-left":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 14H2V2h8v12zm4 0h-3V2h3v12zM4 9h1v1c0 .55.45 1 1 1s1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1H7V6c0-.55-.45-1-1-1s-1 .45-1 1v1H4c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-column-right":["M8 9h1v1c0 .55.45 1 1 1s1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V6c0-.55-.45-1-1-1s-1 .45-1 1v1H8c-.55 0-1 .45-1 1s.45 1 1 1zm7-9H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 14H2V2h3v12zm9 0H6V2h8v12z"],"add-location":["M8 0a1 1 0 110 2 6 6 0 106 6 1 1 0 012 0 8 8 0 11-8-8zm0 5a3 3 0 110 6 3 3 0 010-6zm5-5a1 1 0 011 1v.999L15 2a1 1 0 010 2h-1v1a1 1 0 01-2 0V4h-1a1 1 0 010-2h1V1a1 1 0 011-1z"],"add-row-bottom":["M6 11h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1H9V8c0-.55-.45-1-1-1s-1 .45-1 1v1H6c-.55 0-1 .45-1 1s.45 1 1 1zm9-11H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V6h12v8zm0-9H2V2h12v3z"],"add-row-top":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2v-3h12v3zm0-4H2V2h12v8zM6 7h1v1c0 .55.45 1 1 1s1-.45 1-1V7h1c.55 0 1-.45 1-1s-.45-1-1-1H9V4c0-.55-.45-1-1-1s-1 .45-1 1v1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-to-artifact":["M14 4.01h-1v-1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1 0-.56-.45-1-1-1zm-13 2h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm8 6H1c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1 0-.56-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1 0-.56-.45-1-1-1z"],"add-to-folder":["M.01 7V5H16v7c0 .55-.45 1-1 1H9.005v-2.99C8.974 8.332 7.644 7 5.996 7H.01zM15 2H7.416L5.706.29a.996.996 0 00-.71-.29H1C.45 0 0 .45 0 1v3h15.99V3c.01-.55-.44-1-.99-1zM5.997 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.589L.3 14.29a1.003 1.003 0 001.42 1.42l3.287-3.29v1.59c0 .55.45 1 1 1 .549 0 .999-.45.999-1v-4A1.02 1.02 0 005.996 9z"],airplane:["M16 1.5A1.498 1.498 0 0013.44.44L9.91 3.97 2 1 1 3l5.93 3.95L3.88 10H1l-1 1 3 2 2 3 1-1v-2.88l3.05-3.05L13 15l2-1-2.97-7.91 3.53-3.53c.27-.27.44-.65.44-1.06z"],"align-center":["M4 4c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H4zM1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm13 10H2c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm1-6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-5 5c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h4z"],"align-justify":["M15 12.98H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-14-10h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1 0 .56.45 1 1 1zm14 4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-3H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0 6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-left":["M13 13H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 3h8c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 12h4c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"align-right":["M15 12.98H3c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm-14-10h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1 0 .56.45 1 1 1zm14 1H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0 6h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1zm0-3H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-bottom":["M10 12h3c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm5 2H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h3c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1z"],"alignment-horizontal-center":["M15 7h-1V6c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v1H7V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4H1c-.55 0-1 .45-1 1s.45 1 1 1h1v4c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V9h2v1c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V9h1c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-left":["M9 9H5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zM1 0C.45 0 0 .45 0 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm13 2H5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"alignment-right":["M11 9H7c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zm4-9c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-4 2H2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"alignment-top":["M15 0H1C.45 0 0 .45 0 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM6 4H3c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm7 0h-3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"alignment-vertical-center":["M13 2H9V1c0-.55-.45-1-1-1S7 .45 7 1v1H3c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h4v2H6c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1H9V7h4c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],annotation:["M15.52 2.77c.3-.29.48-.7.48-1.15C16 .73 15.27 0 14.38 0c-.45 0-.85.18-1.15.48l-1.34 1.34 2.3 2.3 1.33-1.35zM7.4 10.9l6.21-6.21-2.3-2.3L5.1 8.6l2.3 2.3zM14 14H2V2h6.34l2-2H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5.66l-2 2V14zM3 13l3.58-1.29-2.29-2.27L3 13z"],antenna:["M2.673 10.758a1.396 1.396 0 01.093.234c.127.442.012.932-.362 1.212-.441.332-1.075.246-1.349-.233a8 8 0 1114.014-.225c-.259.488-.889.594-1.341.277-.382-.269-.513-.755-.4-1.2a1.259 1.259 0 01.085-.238 6 6 0 10-10.74.173zm2.464-1.862a1.783 1.783 0 01.076.404c.03.415-.096.831-.43 1.078-.444.328-1.08.237-1.314-.264a5.003 5.003 0 01-.24-.62l-.004-.011a5 5 0 119.574-.08l-.003.011c-.063.213-.14.422-.23.625-.226.504-.861.606-1.31.285-.338-.241-.47-.654-.448-1.07a1.737 1.737 0 01.07-.405 2.99 2.99 0 00-.216-2.233 3 3 0 00-5.525 2.28zM8 7a1 1 0 011 1v3.586l2.707 2.707a1 1 0 01-1.414 1.414L8 13.414l-2.293 2.293a1 1 0 01-1.414-1.414L7 11.586V8a1 1 0 011-1z"],"app-header":["M15 0a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h14zM6 4a1 1 0 00-1.993-.117L4 4v8a1 1 0 001.993.117L6 12V9h4v3a1 1 0 001.993.117L12 12V4a1 1 0 00-1.993-.117L10 4v3H6V4z"],application:["M3.5 7h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5zM15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm-1 12H2V5h12v8zM3.5 9h4c.28 0 .5-.22.5-.5S7.78 8 7.5 8h-4c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5z"],applications:["M3.5 11h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-2c-.28 0-.5.22-.5.5s.22.5.5.5zm0-2h5c.28 0 .5-.22.5-.5S8.78 8 8.5 8h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM11 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 10H2V7h8v7zm5-14H5c-.55 0-1 .45-1 1v2h2V2h8v7h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM3.5 13h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-3c-.28 0-.5.22-.5.5s.22.5.5.5z"],archive:["M13.382 0a1 1 0 01.894.553L16 4v11a1 1 0 01-1 1H1a1 1 0 01-1-1V4L1.724.553A1 1 0 012.618 0h10.764zM8 6c-.55 0-1 .45-1 1v2.59l-.29-.29-.081-.076A.97.97 0 006 9a1.003 1.003 0 00-.71 1.71l2 2 .096.084c.168.13.38.206.614.206.28 0 .53-.11.71-.29l2-2 .084-.096A1.003 1.003 0 009.29 9.29l-.29.3V7l-.007-.116A1.004 1.004 0 008 6zm5-4H3L2 4h12l-1-2z"],"area-of-interest":["M4 3.664C4 1.644 5.793 0 8 0s3.993 1.643 4 3.664C12 5.692 8 11 8 11S4 5.692 4 3.664zM6 4a2 2 0 104.001-.001A2 2 0 006 4zm7.504 6.269l-2.68-1.609.021-.033c.34-.538.688-1.115 1-1.687l3.67 2.202a1 1 0 01.266 1.482l-4 5A1 1 0 0111 16H5a1 1 0 01-.78-.376l-4-5a1 1 0 01.266-1.482l3.67-2.202a30.46 30.46 0 00.999 1.687l.021.033-2.68 1.609 2.985 3.73h5.038l2.985-3.73z"],array:["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm4 7a1 1 0 110 2 1 1 0 010-2zM5 7a1 1 0 110 2 1 1 0 010-2zm6 0a1 1 0 110 2 1 1 0 010-2z"],"array-boolean":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm7 6a1 1 0 01.993.883L12 7v2a1 1 0 01-.883.993L11 10H5a1 1 0 01-.993-.883L4 9V7a1 1 0 01.883-.993L5 6h6zm0 1H8v2h3V7z"],"array-date":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm6.5 4a.5.5 0 01.5.5V5a1 1 0 01.993.883L12 6v5a1 1 0 01-.883.993L11 12H5a1 1 0 01-.993-.883L4 11V6a1 1 0 01.883-.993L5 5v-.5a.5.5 0 011 0V5h4v-.5a.5.5 0 01.5-.5zm.5 3H5v4h6V7z"],"array-numeric":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm6.904 5c.256 0 .483.037.68.112a1.343 1.343 0 01.812.788c.072.184.108.385.108.604 0 .23-.05.441-.152.636a1.314 1.314 0 01-.456.492v.016l.08.04c.055.031.111.072.168.124.085.077.163.172.232.284a1.673 1.673 0 01.24.872c0 .25-.043.477-.128.68a1.518 1.518 0 01-.896.852 1.937 1.937 0 01-.68.116c-.427 0-.792-.101-1.096-.304a1.362 1.362 0 01-.584-.864c-.01-.053.01-.088.064-.104l.696-.16.033-.002c.03.002.051.022.063.058.059.16.155.296.288.408.133.112.312.168.536.168.256 0 .453-.076.592-.228a.827.827 0 00.208-.58c0-.277-.08-.495-.24-.652-.16-.157-.376-.236-.648-.236h-.232l-.035-.005c-.03-.01-.045-.035-.045-.075v-.632l.005-.035c.01-.03.035-.045.075-.045h.216l.138-.009a.734.734 0 00.438-.207c.144-.144.216-.336.216-.576a.745.745 0 00-.192-.532c-.128-.136-.307-.204-.536-.204-.203 0-.363.05-.48.152a.815.815 0 00-.248.408c-.016.048-.048.067-.096.056l-.68-.16-.034-.012c-.028-.016-.038-.044-.03-.084a1.347 1.347 0 01.516-.828c.136-.104.296-.185.48-.244A1.98 1.98 0 0110.904 5zm-6.152.088l.035.005c.03.01.045.035.045.075v5.28l-.005.035c-.01.03-.035.045-.075.045h-.736l-.035-.005c-.03-.01-.045-.035-.045-.075V6.16H3.92l-.832.584-.032.016C3.02 6.773 3 6.751 3 6.696V5.88l.006-.04a.157.157 0 01.05-.072l.872-.632.04-.027a.236.236 0 01.104-.021h.68zM7.344 5c.256 0 .483.04.68.12.197.08.364.188.5.324s.24.296.312.48c.072.184.108.383.108.596 0 .245-.045.47-.136.676-.09.205-.216.404-.376.596l-1.584 1.92v.016h2.016l.035.005c.03.01.045.035.045.075v.64l-.005.035c-.01.03-.035.045-.075.045H5.808l-.035-.005c-.03-.01-.045-.035-.045-.075v-.6l.004-.04a.132.132 0 01.036-.064l1.92-2.392.1-.133a1.95 1.95 0 00.156-.267.985.985 0 00.096-.432.736.736 0 00-.188-.512c-.125-.139-.303-.208-.532-.208-.219 0-.39.061-.512.184a.826.826 0 00-.224.496c-.01.053-.04.075-.088.064L5.792 6.4l-.034-.012c-.028-.016-.038-.044-.03-.084a1.425 1.425 0 01.94-1.192A1.88 1.88 0 017.344 5z"],"array-string":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm1.61 5c.514 0 .962.212 1.343.637.382.425.573.997.573 1.716 0 .838-.258 1.588-.773 2.252-.514.663-1.327 1.2-2.437 1.609v-.465l.233-.095a3.09 3.09 0 001.274-1.017c.366-.505.55-1.03.55-1.577a.478.478 0 00-.057-.26c-.018-.037-.043-.056-.074-.056s-.08.025-.149.075c-.198.142-.446.214-.744.214-.36 0-.675-.145-.944-.433A1.453 1.453 0 014 6.572c0-.422.155-.79.465-1.102.31-.313.692-.47 1.144-.47zm4.474 0c.514 0 .963.212 1.344.637.381.425.572.997.572 1.716 0 .838-.257 1.588-.772 2.252-.515.663-1.327 1.2-2.437 1.609v-.465l.233-.095a3.09 3.09 0 001.274-1.017c.366-.505.549-1.03.549-1.577a.478.478 0 00-.056-.26c-.019-.037-.044-.056-.075-.056-.03 0-.08.025-.149.075-.198.142-.446.214-.744.214-.36 0-.674-.145-.944-.433a1.453 1.453 0 01-.405-1.028c0-.422.155-.79.466-1.102.31-.313.691-.47 1.144-.47z"],"array-timestamp":["M15 0a1 1 0 01.993.883L16 1v14a1 1 0 01-.883.993L15 16h-3a1 1 0 01-.117-1.993L12 14h2V2h-2a1 1 0 01-.993-.883L11 1a1 1 0 01.883-.993L12 0h3zM4 0a1 1 0 01.117 1.993L4 2H2v12h2a1 1 0 01.993.883L5 15a1 1 0 01-.883.993L4 16H1a1 1 0 01-.993-.883L0 15V1A1 1 0 01.883.007L1 0h3zm4 3a5 5 0 110 10A5 5 0 018 3zm0 1a4 4 0 100 8 4 4 0 000-8zm2.354 1.646a.5.5 0 01.057.638l-.057.07-2 2a.5.5 0 01-.638.057l-.07-.057-1-1a.5.5 0 01.638-.765l.07.057.646.647 1.646-1.647a.5.5 0 01.708 0z"],"arrow-bottom-left":["M14 3a1.003 1.003 0 00-1.71-.71L4 10.59V6c0-.55-.45-1-1-1s-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1H5.41l8.29-8.29c.19-.18.3-.43.3-.71z"],"arrow-bottom-right":["M13 5c-.55 0-1 .45-1 1v4.59l-8.29-8.3a1.003 1.003 0 00-1.42 1.42l8.3 8.29H6c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],"arrow-down":["M13 8c-.3 0-.5.1-.7.3L9 11.6V2c0-.5-.4-1-1-1s-1 .5-1 1v9.6L3.7 8.3C3.5 8.1 3.3 8 3 8c-.5 0-1 .5-1 1 0 .3.1.5.3.7l5 5c.2.2.4.3.7.3s.5-.1.7-.3l5-5c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1z"],"arrow-left":["M13.99 6.99H4.41L7.7 3.7a1.003 1.003 0 00-1.42-1.42l-5 5a1.014 1.014 0 000 1.42l5 5a1.003 1.003 0 001.42-1.42L4.41 8.99H14c.55 0 1-.45 1-1s-.46-1-1.01-1z"],"arrow-right":["M14.7 7.29l-5-5a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l3.29 3.29H1.99c-.55 0-1 .45-1 1s.45 1 1 1h9.59l-3.29 3.29a1.003 1.003 0 001.42 1.42l5-5c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z"],"arrow-top-left":["M13.71 12.29L5.41 4H10c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V5.41l8.29 8.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"arrow-top-right":["M13 2H6c-.55 0-1 .45-1 1s.45 1 1 1h4.59L2.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L12 5.41V10c0 .55.45 1 1 1s1-.45 1-1V3c0-.55-.45-1-1-1z"],"arrow-up":["M13.7 6.3l-5-5C8.5 1.1 8.3 1 8 1s-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L7 4.4V14c0 .6.4 1 1 1s1-.4 1-1V4.4l3.3 3.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7z"],"arrows-horizontal":["M15.7 7.3l-4-4c-.2-.2-.4-.3-.7-.3-.6 0-1 .5-1 1 0 .3.1.5.3.7L12.6 7H3.4l2.3-2.3c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1-.3 0-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7s.1.5.3.7l4 4c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7L3.4 9h9.2l-2.3 2.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l4-4c.2-.2.3-.4.3-.7s-.1-.5-.3-.7z"],"arrows-vertical":["M12 10c-.3 0-.5.1-.7.3L9 12.6V3.4l2.3 2.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7l-4-4C8.5.1 8.3 0 8 0s-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L7 3.4v9.2l-2.3-2.3c-.2-.2-.4-.3-.7-.3-.5 0-1 .4-1 1 0 .3.1.5.3.7l4 4c.2.2.4.3.7.3s.5-.1.7-.3l4-4c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1z"],asterisk:["M14.54 11.18l.01-.02L9.8 8l4.75-3.17-.01-.02c.27-.17.46-.46.46-.81 0-.55-.45-1-1-1-.21 0-.39.08-.54.18l-.01-.02L9 6.13V1c0-.55-.45-1-1-1S7 .45 7 1v5.13L2.55 3.17l-.01.01A.969.969 0 002 3c-.55 0-1 .45-1 1 0 .35.19.64.46.82l-.01.01L6.2 8l-4.75 3.17.01.02c-.27.17-.46.46-.46.81 0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02L7 9.87V15c0 .55.45 1 1 1s1-.45 1-1V9.87l4.45 2.96.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1 0-.35-.19-.64-.46-.82z"],"automatic-updates":["M8 14c-3.31 0-6-2.69-6-6 0-1.77.78-3.36 2-4.46V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1h1.74A7.95 7.95 0 000 8c0 4.42 3.58 8 8 8 .55 0 1-.45 1-1s-.45-1-1-1zM8 2a5.9 5.9 0 012.95.81l1.47-1.47A7.893 7.893 0 008 0c-.55 0-1 .45-1 1s.45 1 1 1zm2.71 6.71l5-5a1.003 1.003 0 00-1.42-1.42L10 6.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29s.53-.11.71-.29zM16 8c0-.55-.06-1.08-.16-1.6l-1.87 1.87A5.966 5.966 0 0112 12.45V11c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-1.74A7.95 7.95 0 0016 8z"],backlink:["M14 10a1 1 0 110 2h-.585l2.292 2.293a1 1 0 01-1.32 1.497l-.094-.083L12 13.415V14a1 1 0 11-2 0l.003-3.075.012-.1.012-.059.033-.108.034-.081.052-.098.067-.096.08-.09a1.01 1.01 0 01.112-.097l.11-.071.143-.065.076-.024.091-.02.116-.014L14 10zM6.036 6.136l-3.45 3.45-.117.127a2 2 0 002.818 2.818l.127-.117 3.45-3.449a4 4 0 01-.885 3.704l-.15.16-1 1A4 4 0 011.02 8.33l.15-.16 1-1a3.998 3.998 0 013.865-1.035zm4.671-1.843a1 1 0 01.083 1.32l-.083.094-5 5a1 1 0 01-1.497-1.32l.083-.094 5-5a1 1 0 011.414 0zm3.121-3.121a4 4 0 01.151 5.497l-.15.16-1 1a3.998 3.998 0 01-3.864 1.036l3.45-3.45.116-.128a2 2 0 00-2.818-2.818l-.127.117-3.45 3.45A4 4 0 017.02 2.33l.15-.16 1-1a4 4 0 015.657 0z"],badge:["M13.36 4.59c-.15-1.13.5-2.01 1.1-2.87L13.43.53c-1.72.88-4.12.65-5.63-.53-1.51 1.18-3.91 1.41-5.63.52l-1.03 1.2c.61.86 1.25 1.74 1.1 2.87-.3 2.29-2.45 4.17-1.32 6.68.45 1.14 1.44 1.9 2.72 2.2 1.56.36 3.52.72 4.16 2.53.64-1.81 2.6-2.16 4.16-2.54 1.28-.3 2.27-1.06 2.72-2.2 1.12-2.5-1.03-4.38-1.32-6.67z"],"ban-circle":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm3 9H5c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1z"],"bank-account":["M15.36 6.46l-.62-.14c-.31-1.12-.98-2.15-1.87-2.99l.4-1.77a.438.438 0 00-.49-.56c-.85.09-1.6.42-2.14.98-.84-.32-1.87-.51-2.85-.51-2.49 0-4.63 1.17-5.92 2.89-.18-.04-.36-.09-.53-.09-.76 0-1.34.61-1.34 1.4 0 .56.31 1.03.76 1.26-.05.33-.09.7-.09 1.07 0 1.68.71 3.17 1.83 4.34l-.27 1.59c-.09.56.35 1.07.89 1.07h.58c.45 0 .8-.33.89-.79l.04-.37c.94.42 2 .7 3.16.7 1.11 0 2.23-.23 3.16-.7l.05.37c.09.47.45.79.89.79h.58c.53 0 .98-.51.89-1.07l-.27-1.54c.62-.61 1.07-1.35 1.38-2.15l.8-.19c.4-.09.71-.47.71-.93V7.4c.09-.47-.22-.84-.62-.94zM12 8c-.6 0-1-.7-1-1.5S11.4 5 12 5s1 .7 1 1.5S12.6 8 12 8zM6.21 4.92c-.41.2-.91.04-1.12-.36-.21-.4-.04-.88.37-1.07 1.35-.65 2.73-.65 4.08 0 .41.2.58.68.37 1.07-.21.4-.71.56-1.12.36-.87-.43-1.71-.43-2.58 0z"],barcode:["M0 14h2V2H0v12zm6 0h1V2H6v12zm2 0h1V2H8v12zm-5 0h2V2H3v12zM15 2v12h1V2h-1zm-5 12h1V2h-1v12zm2 0h2V2h-2v12z"],blank:[],"blocked-person":["M9.39 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.07-.01-.13-.02-.2.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.13-.39.27-.06.43-.36.5-.63.01-.03.03-.08.05-.12C8.18 7.8 6.94 6.04 6.94 4c0-.32.04-.62.09-.92-.17-.03-.35-.08-.51-.08-.65 0-1.37.2-1.88.59-.5.38-.87.92-1.05 1.51-.04.14-.07.27-.09.41-.09.48-.14 1.23-.14 1.74v.06c-.19.08-.36.27-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.12 15.5.03 16 .03 16h12.96s.15-.5-.22-1.36c-.37-.85-2.18-1.42-3.38-1.95zM11.97 0C9.75 0 7.94 1.79 7.94 4s1.8 4 4.03 4S16 6.21 16 4s-1.8-4-4.03-4zM9.96 4c0-1.1.9-2 2.01-2 .37 0 .72.11 1.02.28l-2.75 2.73c-.17-.3-.28-.64-.28-1.01zm2.01 2c-.37 0-.72-.11-1.02-.28l2.75-2.73c.18.3.28.64.28 1.01.01 1.1-.9 2-2.01 2z"],bold:["M11.7 7c.2-.4.3-1 .3-1.5v-.4V5c0-.1 0-.2-.1-.3v-.1C11.4 3.1 10.1 2 8.5 2H4c-.5 0-1 .4-1 1v10c0 .5.4 1 1 1h5c2.2 0 4-1.8 4-4 0-1.2-.5-2.3-1.3-3zM6 5h2c.6 0 1 .4 1 1s-.4 1-1 1H6V5zm3 6H6V9h3c.6 0 1 .4 1 1s-.4 1-1 1z"],book:["M2 1v14c0 .55.45 1 1 1h1V0H3c-.55 0-1 .45-1 1zm11-1h-1v7l-2-2-2 2V0H5v16h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],bookmark:["M11.2.01h-.15C11.03.01 11.02 0 11 0H5c-.02 0-.03.01-.05.01H4.8c-.44 0-.8.37-.8.82v14.75c0 .45.25.56.57.24l2.87-2.94c.31-.32.82-.32 1.13 0l2.87 2.94c.31.32.57.21.57-.24V.83C12 .38 11.64.01 11.2.01z"],box:["M6 10h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1zm9.93-4.37v-.02L13.94.63C13.78.26 13.42 0 13 0H3c-.42 0-.78.26-.93.63L.08 5.61l-.01.02C.03 5.74 0 5.87 0 6v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.13-.03-.26-.07-.37zM9 2h3.32l1.2 3H9V2zM3.68 2H7v3H2.48l1.2-3zM14 14H2V7h12v7z"],briefcase:["M15 3.98h-3v-2c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v2H1c-.55 0-1 .45-1 1v4h3v-1h2v1h6v-1h2v1h3v-4c0-.55-.45-1-1-1zm-5 0H6v-1h4v1zm3 7h-2v-1H5v1H3v-1H0v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-4h-3v1z"],"bring-data":["M14 14a1 1 0 010 2H2a1 1 0 010-2h12zM7.995 3.005c.55 0 1 .45 1 .999v5.584l1.29-1.288a1.002 1.002 0 011.42 1.419l-3 2.996a1.015 1.015 0 01-1.42 0l-3-2.997A1.002 1.002 0 015.705 8.3l1.29 1.29V4.013c0-.55.45-1.009 1-1.009zM14 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zM8 0a1 1 0 110 2 1 1 0 010-2zM5 0a1 1 0 110 2 1 1 0 010-2zM2 0a1 1 0 110 2 1 1 0 010-2z"],buggy:["M13.928.629A1 1 0 0012.89.006l-9 1a1 1 0 00-.747.48L.431 6.005A.5.5 0 000 6.5v3a.5.5 0 00.5.5h2.798c.341 0 .672.116.938.329l1.952 1.561A.5.5 0 006.5 12H10a.5.5 0 00.4-.2l.9-1.2a1.5 1.5 0 011.2-.6h3a.5.5 0 00.5-.5v-4a.5.5 0 00-.308-.462L13.928.628zM12.36 2.094l-.006-.016-3.166.352 1.121 3.083 2.052-3.419zm.467 1.166l-1.649 2.748 2.51-.594-.861-2.154zM9.603 6.496L8.166 2.543l-3.563.396L2.766 6H3.5a.5.5 0 01.367.16L6.218 8.7h1.914l1.452-2.177a.5.5 0 01.019-.027zM2.5 16a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm11 0a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"],build:["M15.39 12.41L7.7 6l1.07-1.1c.34-.34-.12-.63.12-1.26.88-2.17 3.41-2.35 3.41-2.35s.36-.37.71-.72C9.74-.81 7.53.53 6.54 1.4L3.12 4.9l-.71.72c-.39.4-.39 1.05 0 1.45l-.7.72c-.39-.4-1.02-.4-1.41 0s-.39 1.05 0 1.45l1.41 1.45c.39.4 1.02.4 1.41 0s.39-1.05 0-1.45l.71-.72c.39.4 1.02.4 1.41 0l.8-.82 6.39 7.67c.82.82 2.14.82 2.96 0 .81-.82.81-2.15 0-2.96z"],calculator:["M13 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM6 14H4v-2h2v2zm0-3H4V9h2v2zm0-3H4V6h2v2zm3 6H7v-2h2v2zm0-3H7V9h2v2zm0-3H7V6h2v2zm3 6h-2V9h2v5zm0-6h-2V6h2v2zm0-3H4V2h8v3z"],calendar:["M11 3c.6 0 1-.5 1-1V1c0-.6-.4-1-1-1s-1 .4-1 1v1c0 .5.4 1 1 1zm3-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H6v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h13c.6 0 1-.4 1-1V2c0-.6-.5-1-1-1zM5 13H2v-3h3v3zm0-4H2V6h3v3zm4 4H6v-3h3v3zm0-4H6V6h3v3zm4 4h-3v-3h3v3zm0-4h-3V6h3v3zM4 3c.6 0 1-.5 1-1V1c0-.6-.4-1-1-1S3 .4 3 1v1c0 .5.4 1 1 1z"],camera:["M15 3h-2.59L10.7 1.29A.956.956 0 0010 1H6c-.28 0-.53.11-.71.29L3.59 3H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h2.56c1.1 1.22 2.67 2 4.44 2s3.34-.78 4.44-2H15c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zM3 6H1V5h2v1zm5 6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"caret-down":["M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z"],"caret-left":["M9.5 4c-.13 0-.24.05-.33.13l-4 3.5c-.1.09-.17.22-.17.37s.07.28.17.37l4 3.5a.495.495 0 00.83-.37v-7c0-.28-.22-.5-.5-.5z"],"caret-right":["M11 8c0-.15-.07-.28-.17-.37l-4-3.5A.495.495 0 006 4.5v7a.495.495 0 00.83.37l4-3.5c.1-.09.17-.22.17-.37z"],"caret-up":["M11.87 9.17s.01 0 0 0l-3.5-4C8.28 5.07 8.15 5 8 5s-.28.07-.37.17l-3.5 4a.495.495 0 00.37.83h7a.495.495 0 00.37-.83z"],"cargo-ship":["M10 1h3a1 1 0 011 1v2h-4V1zM2.25 4a.25.25 0 00-.25.25V9H.883a.5.5 0 00-.429.757l1.072 1.787c.207.344.477.638.791.87A9.76 9.76 0 011 12.5a.5.5 0 000 1c2.067 0 3.414-.543 4.161-.917.55.373 1.505.917 2.839.917 1.32 0 2.27-.533 2.822-.905l.004.002c.196.105.48.24.856.374.75.268 1.857.529 3.318.529a.5.5 0 000-1c-.326 0-.63-.014-.916-.039.47-.328.848-.79 1.07-1.347l.572-1.428A.5.5 0 0015.26 9H4V4.25A.25.25 0 003.75 4h-1.5zm2.714 9.56a.5.5 0 01.527.033c.455.325 1.277.907 2.509.907s2.054-.582 2.51-.907a.5.5 0 01.579-.001l.006.004.036.023c.034.022.09.055.168.097.154.082.394.197.72.313.649.232 1.642.471 2.981.471a.5.5 0 010 1c-1.46 0-2.568-.261-3.318-.53a6.316 6.316 0 01-.856-.373l-.004-.002c-.552.372-1.502.905-2.822.905-1.334 0-2.289-.544-2.839-.917-.747.374-2.094.917-4.161.917a.5.5 0 010-1c2.129 0 3.384-.63 3.964-.94zM14 5h-4v3h3a1 1 0 001-1V5zM5 2a1 1 0 011-1h3v3H5V2zm4 3H5v2a1 1 0 001 1h3V5z"],"cell-tower":["M8.97 6.76c-.01-.05-.04-.08-.06-.13-.02-.05-.03-.1-.05-.15.08-.14.14-.3.14-.48 0-.55-.45-1-1-1s-1 .45-1 1c0 .18.06.34.14.48-.03.05-.03.1-.05.15-.02.05-.05.08-.06.13l-2 8c-.13.54.19 1.08.73 1.21a.995.995 0 001.21-.73L7.53 13h.94l.56 2.24a1 1 0 001.94-.48l-2-8zM3.72 1.7C4.1 1.3 4.09.67 3.7.28S2.67-.09 2.28.3c-3.05 3.12-3.05 8.28 0 11.4a.996.996 0 101.43-1.39c-2.28-2.35-2.28-6.27.01-8.61zM11.6 3.2c-.44-.33-1.07-.24-1.4.2-.33.44-.24 1.07.2 1.4.43.32.53 1.96-.04 2.43-.42.35-.48.98-.13 1.41.35.42.98.48 1.41.13 1.59-1.33 1.39-4.5-.04-5.57z","M13.72.3c-.39-.4-1.02-.4-1.41-.02s-.41 1.02-.03 1.42c2.29 2.34 2.29 6.26 0 8.6-.39.39-.38 1.03.02 1.41s1.03.38 1.41-.02c3.05-3.11 3.05-8.27.01-11.39zM5.4 7.23c-.57-.47-.47-2.11-.04-2.43.44-.33.53-.96.2-1.4s-.96-.53-1.4-.2c-1.44 1.07-1.63 4.24-.04 5.57.42.35 1.05.3 1.41-.13.35-.42.29-1.06-.13-1.41z"],changes:["M8.29 7.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L13 7.59V1c0-.55-.45-1-1-1s-1 .45-1 1v6.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42zM14.5 13h-13c-.83 0-1.5.67-1.5 1.5S.67 16 1.5 16h13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5zM1 5c.28 0 .53-.11.71-.29L3 3.41V10c0 .55.45 1 1 1s1-.45 1-1V3.41L6.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C4.53.11 4.28 0 4 0s-.53.11-.71.29l-3 3A1.003 1.003 0 001 5z"],chart:["M0 15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V9.4L0 11v4zm6-5.5V15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-5l-1 1-3-1.5zM13 7l-1 1v7c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V7.88c-.26.07-.58.12-1 .12-1.96 0-2-1-2-1zm2-6h-3c-.55 0-1 .45-1 1s.45 1 1 1h.59L8.8 6.78 5.45 5.11v.01C5.31 5.05 5.16 5 5 5s-.31.05-.44.11V5.1l-4 2v.01C.23 7.28 0 7.61 0 8c0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L5 7.12 8.55 8.9v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L14 4.41V5c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],chat:["M6 10c-1.1 0-2-.9-2-2V3H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1v2a1.003 1.003 0 001.71.71L5.41 13H10c.55 0 1-.45 1-1v-1.17l-.83-.83H6zm9-10H6c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"chevron-backward":["M7.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L6 6.59V4c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1s1-.45 1-1V9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L7.41 8z"],"chevron-down":["M12 5c-.28 0-.53.11-.71.29L8 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 5z"],"chevron-forward":["M10 3c-.55 0-1 .45-1 1v2.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L7.59 8 4.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L9 9.41V12c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],"chevron-left":["M7.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C5.11 7.47 5 7.72 5 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L7.41 8z"],"chevron-right":["M10.71 7.29l-4-4a1.003 1.003 0 00-1.42 1.42L8.59 8 5.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"chevron-up":["M12.71 9.29l-4-4C8.53 5.11 8.28 5 8 5s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 7.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],circle:["M8 0C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6z"],"circle-arrow-down":["M11 7c-.28 0-.53.11-.71.29L9 8.59V5c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 7zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-left":["M11 7H7.41L8.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C4.11 7.47 4 7.72 4 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L7.41 9H11c.55 0 1-.45 1-1s-.45-1-1-1zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-right":["M8.71 4.29a1.003 1.003 0 00-1.42 1.42L8.59 7H5c-.55 0-1 .45-1 1s.45 1 1 1h3.59L7.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"circle-arrow-up":["M8.71 4.29C8.53 4.11 8.28 4 8 4s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L7 7.41V11c0 .55.45 1 1 1s1-.45 1-1V7.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],citation:["M15.02 5c0-1.66-1.34-3-3-3s-3 1.34-3 3a2.996 2.996 0 003.6 2.94C12.1 9.76 11.14 11 10.02 11c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5-3.13 5-7 0-.2-.02-.39-.04-.58.01-.14.04-.28.04-.42zm-11-3c-1.66 0-3 1.34-3 3a2.996 2.996 0 003.6 2.94C4.1 9.76 3.14 11 2.02 11c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5-3.13 5-7 0-.2-.02-.39-.04-.58.01-.14.04-.28.04-.42 0-1.66-1.35-3-3-3z"],clean:["M12 8l-1.2 2.796-2.8 1.2 2.8 1.197L12 16l1.2-2.807L16 12l-2.8-1.204zM5 0L3.5 3.5 0 4.995 3.5 6.5 5 10l1.5-3.5L10 5 6.5 3.5z"],clip:["M0 1a1 1 0 011-1h4a1 1 0 010 2H2v3a1 1 0 01-2 0V1zm1 15a1 1 0 01-1-1v-4a1 1 0 112 0v3h3a1 1 0 110 2H1zm14 0a1 1 0 001-1v-4a1 1 0 10-2 0v3h-3a1 1 0 100 2h4zm0-16a1 1 0 011 1v4a1 1 0 11-2 0V2h-3a1 1 0 110-2h4zM8 11a3 3 0 100-6 3 3 0 000 6z"],clipboard:["M11 2c0-.55-.45-1-1-1h.22C9.88.4 9.24 0 8.5 0S7.12.4 6.78 1H7c-.55 0-1 .45-1 1v1h5V2zm2 0h-1v2H5V2H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],cloud:["M12 6c-.03 0-.07 0-.1.01A5 5 0 002 7c0 .11.01.22.02.33A3.51 3.51 0 000 10.5C0 12.43 1.57 14 3.5 14H12c2.21 0 4-1.79 4-4s-1.79-4-4-4z"],"cloud-download":["M11 11c-.28 0-.53.11-.71.29L9 12.59V8c0-.55-.45-1-1-1s-1 .45-1 1v4.59L5.71 11.3A.965.965 0 005 11a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 11zm1-7c-.03 0-.07 0-.1.01A5 5 0 002 5c0 .11.01.22.02.33A3.51 3.51 0 000 8.5c0 1.41.84 2.61 2.03 3.17C2.2 10.17 3.46 9 5 9c.06 0 .13.02.19.02C5.07 8.7 5 8.36 5 8c0-1.66 1.34-3 3-3s3 1.34 3 3c0 .36-.07.7-.19 1.02.06 0 .13-.02.19-.02 1.48 0 2.7 1.07 2.95 2.47A3.964 3.964 0 0016 8c0-2.21-1.79-4-4-4z"],"cloud-upload":["M8.71 7.29C8.53 7.11 8.28 7 8 7s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L7 10.41V15c0 .55.45 1 1 1s1-.45 1-1v-4.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM12 4c-.03 0-.07 0-.1.01A5 5 0 002 5c0 .11.01.22.02.33a3.495 3.495 0 00.07 6.37c-.05-.23-.09-.46-.09-.7 0-.83.34-1.58.88-2.12l3-3a2.993 2.993 0 014.24 0l3 3c.54.54.88 1.29.88 2.12 0 .16-.02.32-.05.47C15.17 10.78 16 9.5 16 8c0-2.21-1.79-4-4-4z"],code:["M15.71 7.29l-3-3a1.003 1.003 0 00-1.42 1.42L13.59 8l-2.29 2.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM5 5a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L2.41 8 4.7 5.71c.19-.18.3-.43.3-.71zm4-3c-.48 0-.87.35-.96.81l-2 10c-.01.06-.04.12-.04.19 0 .55.45 1 1 1 .48 0 .87-.35.96-.81l2-10c.01-.06.04-.12.04-.19 0-.55-.45-1-1-1z"],"code-block":["M15 3h-2V2c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v1H7V2c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-8.29 8.29a1.003 1.003 0 01-1.42 1.42l-3-3C2.11 9.53 2 9.28 2 9s.11-.53.29-.71l3-3a1.003 1.003 0 011.42 1.42L4.41 9l2.3 2.29zm7-1.58l-3 3a1.003 1.003 0 01-1.42-1.42L11.59 9l-2.3-2.29a1.003 1.003 0 011.42-1.42l3 3c.18.18.29.43.29.71s-.11.53-.29.71z"],cog:["M15.19 6.39h-1.85c-.11-.37-.27-.71-.45-1.04l1.36-1.36c.31-.31.31-.82 0-1.13l-1.13-1.13a.803.803 0 00-1.13 0l-1.36 1.36c-.33-.17-.67-.33-1.04-.44V.79c0-.44-.36-.8-.8-.8h-1.6c-.44 0-.8.36-.8.8v1.86c-.39.12-.75.28-1.1.47l-1.3-1.3c-.3-.3-.79-.3-1.09 0L1.82 2.91c-.3.3-.3.79 0 1.09l1.3 1.3c-.2.34-.36.7-.48 1.09H.79c-.44 0-.8.36-.8.8v1.6c0 .44.36.8.8.8h1.85c.11.37.27.71.45 1.04l-1.36 1.36c-.31.31-.31.82 0 1.13l1.13 1.13c.31.31.82.31 1.13 0l1.36-1.36c.33.18.67.33 1.04.44v1.86c0 .44.36.8.8.8h1.6c.44 0 .8-.36.8-.8v-1.86c.39-.12.75-.28 1.1-.47l1.3 1.3c.3.3.79.3 1.09 0l1.09-1.09c.3-.3.3-.79 0-1.09l-1.3-1.3c.19-.35.36-.71.48-1.1h1.85c.44 0 .8-.36.8-.8v-1.6a.816.816 0 00-.81-.79zm-7.2 4.6c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"collapse-all":["M7.29 6.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L8 4.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4zm1.42 2.58C8.53 9.11 8.28 9 8 9s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 11.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],"column-layout":["M15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 13H2V3h2v10zm3 0H5V3h2v10zm7 0H8V3h6v10z"],comment:["M14 1H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h2v3a1.003 1.003 0 001.71.71L8.41 12H14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM3.5 8C2.67 8 2 7.33 2 6.5S2.67 5 3.5 5 5 5.67 5 6.5 4.33 8 3.5 8zm4 0C6.67 8 6 7.33 6 6.5S6.67 5 7.5 5 9 5.67 9 6.5 8.33 8 7.5 8zm4 0c-.83 0-1.5-.67-1.5-1.5S10.67 5 11.5 5s1.5.67 1.5 1.5S12.33 8 11.5 8z"],comparison:["M7.99-.01c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1v-14c0-.55-.45-1-1-1zm-3 3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm10 0h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-4v-2h4v2zm0 3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-4v-2h4v2zm-10-3h-4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],compass:["M12 8c0 .14-.03.27-.08.39l-3 6.99c-.15.37-.51.62-.92.62s-.77-.25-.92-.61l-3-6.99a1.006 1.006 0 010-.79l3-6.99C7.23.25 7.59 0 8 0s.77.25.92.61l3 6.99c.05.13.08.26.08.4zM8 3.54L6.09 8h3.82L8 3.54z"],compressed:["M15.93 5.63v-.02L13.94.63C13.78.26 13.42 0 13 0H3c-.42 0-.78.26-.93.63L.08 5.61l-.01.02C.03 5.74 0 5.87 0 6v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.13-.03-.26-.07-.37zM9 2h3.32l1.2 3H9V2zM3.68 2H7v3H2.48l1.2-3zM14 14H2V7h5v2.59l-1.29-1.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L9 9.59V7h5v7z"],confirm:["M8.7 4.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l5-5a1.003 1.003 0 00-1.42-1.42l-4.29 4.3L8.7 4.29zm5.22 3.01c.03.23.07.45.07.69 0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6c.81 0 1.59.17 2.3.46l1.5-1.5A7.998 7.998 0 00-.01 7.99c0 4.42 3.58 8 8 8s8-3.58 8-8c0-.83-.13-1.64-.36-2.39l-1.71 1.7z"],console:["M15 15H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1zM14 5H2v8h12V5zM4 6c.28 0 .53.11.71.29l2 2c.18.18.29.43.29.71s-.11.53-.29.71l-2 2a1.003 1.003 0 01-1.42-1.42L4.59 9l-1.3-1.29A1.003 1.003 0 014 6zm5 4h3c.55 0 1 .45 1 1s-.45 1-1 1H9c-.55 0-1-.45-1-1s.45-1 1-1z"],contrast:["M15.2 6.4h-1.44c-.13-.47-.32-.92-.56-1.34L14.26 4c.31-.31.31-.82 0-1.13l-1.13-1.13a.803.803 0 00-1.13 0L10.94 2.8c-.42-.24-.86-.42-1.34-.56V.8c0-.44-.36-.8-.8-.8H7.2c-.44 0-.8.36-.8.8v1.44c-.5.14-.96.34-1.4.59l-1-1c-.3-.3-.79-.3-1.09 0L1.83 2.91c-.3.3-.3.79 0 1.09l1 1c-.25.44-.45.9-.59 1.4H.8c-.44 0-.8.36-.8.8v1.6c0 .44.36.8.8.8h1.44c.13.47.32.92.56 1.34L1.74 12c-.31.31-.31.82 0 1.13l1.13 1.13c.31.31.82.31 1.13 0l1.06-1.06c.42.24.86.42 1.34.56v1.44c0 .44.36.8.8.8h1.6c.44 0 .8-.36.8-.8v-1.44c.5-.14.96-.33 1.4-.59l1 1c.3.3.79.3 1.09 0l1.09-1.09c.3-.3.3-.79 0-1.09l-1-1c.25-.43.45-.9.59-1.4h1.44c.44 0 .8-.36.8-.8V7.2a.818.818 0 00-.81-.8zM8 12c-2.21 0-4-1.79-4-4s1.79-4 4-4v8z"],control:["M13 8H8v5h5V8zm0-5H8v4h5V3zm2-3H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V2h12v12zM7 3H3v10h4V3z"],"credit-card":["M14.99 2.95h-14c-.55 0-1 .45-1 1v1h16v-1c0-.55-.45-1-1-1zm-15 10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-6h-16v6zm5.5-2h5c.28 0 .5.22.5.5s-.22.5-.5.5h-5c-.28 0-.5-.22-.5-.5s.23-.5.5-.5zm-3 0h1c.28 0 .5.22.5.5s-.22.5-.5.5h-1c-.28 0-.5-.22-.5-.5s.23-.5.5-.5z"],cross:["M9.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z"],crown:["M2 6l3 2 3-4 3 4 3-2-1 6H3L2 6zm6-5a1 1 0 110 2 1 1 0 010-2zM1 3a1 1 0 110 2 1 1 0 010-2zm14 0a1 1 0 110 2 1 1 0 010-2zM3 13h10v2H3v-2z"],cube:["M14.194 3.54L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l5.698 3.255zm.75.71a1 1 0 01.056.33v6.84a1 1 0 01-.504.868L8.5 15.714V8.277l6.444-4.027zm-13.888 0L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33z"],"cube-add":["M14 2h1a1 1 0 010 2h-1v1a1 1 0 01-2 0V4h-1a1 1 0 010-2h1V1a1 1 0 012 0v1zM9.136.65a3.001 3.001 0 00.992 5.222c.018.058.038.115.059.172L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l.64.365zM15 7.235v4.184a1 1 0 01-.504.868L8.5 15.714V8.277l2.187-1.367A2.994 2.994 0 0013 8c.768 0 1.47-.289 2-.764zM1.056 4.25L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33z"],"cube-remove":["M10.365 5.933L8 7.41 1.806 3.54 7.504.283a1 1 0 01.992 0l.64.365a3.001 3.001 0 001.228 5.283zM15 6v5.42a1 1 0 01-.504.868L8.5 15.714V8.277L12.143 6H15zM1.056 4.25L7.5 8.277v7.437l-5.996-3.426A1 1 0 011 11.42V4.58a1 1 0 01.056-.33zM11 2h4a1 1 0 010 2h-4a1 1 0 010-2z"],"curved-range-chart":["M15 12H3.12l1.81-1.39c1.73 1.01 5.53-.03 9.08-2.61l-1.22-1.5C10.3 8.3 7.86 9.37 6.65 9.29L14.3 3.4l-.6-.8-7.83 6.03c-.01-1.07 1.8-3.19 4.47-5.13L9.12 2C5.38 4.7 3.34 8.1 4.25 9.87L2 11.6V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],cut:["M13 2s.71-1.29 0-2L8.66 5.07l1.05 1.32L13 2zm.07 8c-.42 0-.82.09-1.18.26L3.31 0c-.69.71 0 2 0 2l3.68 5.02-2.77 3.24A2.996 2.996 0 000 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-.46-.11-.89-.29-1.27L8.1 8.54l2.33 3.19c-.18.39-.29.82-.29 1.27 0 1.66 1.31 3 2.93 3S16 14.66 16 13s-1.31-3-2.93-3zM3 14c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm10.07 0c-.54 0-.98-.45-.98-1s.44-1 .98-1 .98.45.98 1-.44 1-.98 1z"],cycle:["M13 9a3 3 0 110 6 3 3 0 010-6zM3 9a3 3 0 110 6 3 3 0 010-6zm6.169-5.27l.087.09 1.51 1.746 1.589.549a1 1 0 01.65 1.16l-.032.112a1 1 0 01-1.159.65l-.112-.032-1.843-.636a1 1 0 01-.337-.198l-.092-.093-.959-1.109L7.041 7.5l1.691 1.819a1 1 0 01.26.556L9 10v3a1 1 0 01-1.993.117L7 13l-.001-2.608-2.056-2.211a1 1 0 01-.081-1.264l.082-.1 2.825-3.026a1 1 0 011.4-.061zM13 10.5a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm-10 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM11 1a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],dashboard:["M5 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM4 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-2c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-2 6c0 1.1.9 2 2 2s2-.9 2-2c0-.53-2-5-2-5s-2 4.47-2 5zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm4-9c0-.55-.45-1-1-1s-1 .45-1 1 .45 1 1 1 1-.45 1-1zm0 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"data-connection":["M1 9.52c.889.641 2.308 1.133 4.003 1.354L5 11a5.994 5.994 0 002.664 4.988c-.217.008-.44.012-.664.012-3.215 0-5.846-.85-5.993-1.906L1 14V9.52zM11 6c2.762 0 5 2.238 5 5s-2.238 5-5 5-5-2.238-5-5 2.238-5 5-5zm1 1l-4 5h2.5l-.5 3 4-5h-2.5l.5-3zm1-3.48v1.822a6.002 6.002 0 00-7.9 4.556l-.248-.03c-2.168-.28-3.733-.966-3.845-1.774L1 8V3.52C2.22 4.4 4.44 5 7 5s4.78-.6 6-1.48zM7 0c3.31 0 6 .9 6 2s-2.69 2-6 2c-3.32 0-6-.9-6-2s2.68-2 6-2z"],"data-lineage":["M1.067 0C.477 0 0 .478 0 1.067V3.2c0 .59.478 1.067 1.067 1.067h2.24a5.342 5.342 0 002.9 3.734 5.337 5.337 0 00-2.9 3.733h-2.24C.477 11.733 0 12.21 0 12.8v2.133C0 15.523.478 16 1.067 16H6.4c.59 0 1.067-.478 1.067-1.067V12.8c0-.59-.478-1.067-1.067-1.067H4.401a4.27 4.27 0 013.92-3.194l.212-.006V9.6c0 .59.478 1.067 1.067 1.067h5.333c.59 0 1.067-.478 1.067-1.067V6.4c0-.59-.478-1.067-1.067-1.067H9.6c-.59 0-1.067.478-1.067 1.067v1.067a4.268 4.268 0 01-4.132-3.2H6.4c.59 0 1.067-.478 1.067-1.067V1.067C7.467.477 6.989 0 6.4 0H1.067z"],database:["M8 4c3.31 0 6-.9 6-2s-2.69-2-6-2C4.68 0 2 .9 2 2s2.68 2 6 2zm-6-.48V8c0 1.1 2.69 2 6 2s6-.9 6-2V3.52C12.78 4.4 10.56 5 8 5s-4.78-.6-6-1.48zm0 6V14c0 1.1 2.69 2 6 2s6-.9 6-2V9.52C12.78 10.4 10.56 11 8 11s-4.78-.6-6-1.48z"],delete:["M11.99 4.99a1.003 1.003 0 00-1.71-.71l-2.29 2.3L5.7 4.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2.29 2.29-2.29 2.29A1.003 1.003 0 005.7 11.7l2.29-2.29 2.29 2.29a1.003 1.003 0 001.42-1.42L9.41 7.99 11.7 5.7c.18-.18.29-.43.29-.71zm-4-5c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],delta:["M8 0L0 16h16L8 0zM7 5l5 10H2L7 5z"],"derive-column":["M6.08 6.67h-.84c.24-.92.56-1.6.96-2.03.24-.27.48-.4.71-.4.05 0 .08.01.11.04s.04.06.04.1c0 .04-.03.11-.1.21-.06.1-.1.2-.1.29 0 .13.05.24.15.33.1.09.23.14.39.14.17 0 .31-.06.42-.17A.58.58 0 008 4.73c0-.22-.09-.39-.26-.53-.17-.13-.44-.2-.81-.2-.59 0-1.12.16-1.59.48-.48.32-.93.85-1.36 1.59-.15.26-.29.42-.42.49s-.35.11-.64.1l-.19.65h.81l-1.19 4.37c-.2.72-.33 1.16-.4 1.33-.1.24-.26.45-.46.62-.08.07-.18.1-.3.1-.03 0-.06-.01-.08-.03l-.03-.04c0-.02.03-.06.09-.11.06-.06.09-.14.09-.26 0-.13-.05-.23-.14-.32a.6.6 0 00-.4-.13c-.21 0-.38.05-.51.16s-.21.25-.21.4c0 .16.08.3.23.42.16.12.4.18.74.18.53 0 .99-.13 1.4-.39.41-.26.76-.65 1.07-1.19.3-.54.62-1.4.94-2.59l.68-2.53h.82l.2-.63zM15 0H8c-.55 0-1 .45-1 1v2h2V2h5v12H9v-1H7v2c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM8.3 9.94c.18.52.33.89.46 1.13.13.24.28.4.44.51.17.1.37.16.62.16.24 0 .49-.08.74-.25.33-.21.66-.58 1.01-1.09l-.21-.11c-.23.31-.41.5-.52.57a.44.44 0 01-.26.07c-.12 0-.24-.07-.36-.21-.2-.24-.46-.91-.8-2 .3-.49.55-.81.75-.96.15-.11.3-.16.47-.16.06 0 .17.02.34.06.16.04.31.06.43.06.17 0 .31-.06.43-.17.1-.11.16-.25.16-.43 0-.19-.06-.33-.17-.44-.12-.11-.28-.16-.49-.16-.19 0-.37.04-.54.13-.17.09-.39.27-.65.56-.2.21-.48.58-.87 1.11-.15-.66-.41-1.26-.78-1.81l-2.05.33-.04.21c.15-.03.28-.04.39-.04.2 0 .37.08.5.25.21.26.5 1.03.88 2.33-.29.37-.49.61-.6.72-.18.18-.33.3-.44.36-.09.04-.19.07-.3.07-.09 0-.23-.04-.42-.13a.866.866 0 00-.36-.09c-.2 0-.36.06-.49.18a.59.59 0 00-.19.46c0 .17.06.32.18.43.12.11.28.16.48.16.2 0 .38-.04.55-.11.17-.08.39-.24.65-.49.24-.27.6-.66 1.06-1.21z"],desktop:["M15 0H1C.45 0 0 .45 0 1v10c0 .55.45 1 1 1h4.75l-.5 2H4c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1h-1.25l-.5-2H15c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 10H2V2h12v8z"],diagnosis:["M3.2 1a1 1 0 01.117 1.993L3.2 3H3v3a2 2 0 001.85 1.995L5 8a2 2 0 001.995-1.85L7 6V3h-.2a1 1 0 01-.993-.883L5.8 2a1 1 0 01.883-.993L6.8 1H8a1 1 0 01.993.883L9 2v4a4.002 4.002 0 01-3.007 3.876v.007L6 10a3 3 0 005.995.176L12 10V7.792a2.5 2.5 0 112 0V10a5 5 0 01-10 0c0-.042.003-.084.008-.125A4 4 0 011.005 6.2L1 6V2a1 1 0 01.883-.993L2 1h1.2z"],"diagram-tree":["M15 8v3h-2V9H9v2H7V9H3v2H1V8a1 1 0 011-1h5V5h2v2h5a1 1 0 011 1zM1 12h2a1 1 0 011 1v2a1 1 0 01-1 1H1a1 1 0 01-1-1v-2a1 1 0 011-1zm12 0h2a1 1 0 011 1v2a1 1 0 01-1 1h-2a1 1 0 01-1-1v-2a1 1 0 011-1zm-6 0h2a1 1 0 011 1v2a1 1 0 01-1 1H7a1 1 0 01-1-1v-2a1 1 0 011-1zM7 0h2a1 1 0 011 1v2a1 1 0 01-1 1H7a1 1 0 01-1-1V1a1 1 0 011-1z"],"direction-left":["M16 1.99l-16 6 16 6-4-6z"],"direction-right":["M16 7.99l-16-6 4 6-4 6z"],disable:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm-6 8c0-3.31 2.69-6 6-6 1.3 0 2.49.42 3.47 1.12l-8.35 8.35c-.7-.98-1.12-2.17-1.12-3.47zm6 6c-1.3 0-2.49-.42-3.47-1.12l8.35-8.35c.7.98 1.12 2.17 1.12 3.47 0 3.32-2.68 6-6 6z"],document:["M9 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5L9 0zm3 14H4V2h4v4h4v8z"],"document-open":["M6 12c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1s.45 1 1 1h1.59L1.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L6 10.41V12zm4-12H4c-.55 0-1 .45-1 1v4h2V2h4v4h4v8H5.24l-1.8 1.8c.16.12.35.2.56.2h10c.55 0 1-.45 1-1V5l-5-5z"],"document-share":["M10 14H2V2h4v4h1c0-.83.36-1.55.91-2.09l-.03-.03.9-.9C8.3 2.45 8 1.77 8 1L7 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V8.22c-.53.48-1.23.78-2 .78v5zm5-14h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 3.41V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],dollar:["M12.83 9.51c-.1-.3-.25-.58-.45-.84s-.45-.49-.75-.7c-.3-.2-.65-.36-1.05-.48-.16-.04-.43-.11-.8-.2-.35-.09-.73-.18-1.12-.28-.39-.1-.74-.19-1.06-.27-.31-.08-.49-.12-.54-.13-.43-.12-.78-.29-1.05-.52-.27-.23-.4-.55-.4-.95 0-.29.07-.53.21-.72.14-.19.32-.34.54-.46.22-.11.46-.19.72-.24.26-.05.52-.08.77-.08.74 0 1.35.15 1.83.46.48.3.75.83.81 1.56h2.14c0-.6-.13-1.13-.38-1.58-.25-.45-.59-.84-1.02-1.15-.43-.31-.93-.54-1.49-.7-.24-.06-.49-.1-.75-.14V1c0-.55-.45-1-1-1s-1 .45-1 1v1.08c-.23.03-.46.07-.68.13-.54.13-1.02.34-1.44.61-.42.28-.76.63-1.02 1.05-.26.43-.39.93-.39 1.5 0 .3.04.59.13.88.09.29.23.56.44.82.21.26.48.49.83.7.35.21.79.38 1.31.51.85.21 1.56.38 2.14.52.58.13 1.08.28 1.52.42.25.09.48.23.69.44.21.21.32.53.32.97 0 .21-.05.42-.14.63-.09.21-.24.39-.45.55-.21.16-.47.29-.81.39-.33.1-.73.15-1.2.15-.43 0-.84-.05-1.21-.14-.37-.09-.7-.24-.99-.43-.29-.2-.51-.45-.67-.76-.16-.31-.24-.68-.24-1.12H3c.01.71.15 1.32.43 1.84.27.52.64.94 1.1 1.27.46.33.99.58 1.61.74.27.07.56.12.85.16V15c0 .55.45 1 1 1s1-.45 1-1v-1.05c.3-.03.61-.08.9-.15.58-.13 1.1-.34 1.56-.63.46-.29.83-.66 1.11-1.11.28-.45.42-1 .42-1.64 0-.31-.05-.61-.15-.91z"],dot:["M8 5a3 3 0 100 6 3 3 0 100-6z"],"double-caret-horizontal":["M13.71 7.29l-3-3A1.003 1.003 0 009 5v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM6 4c-.28 0-.53.11-.71.29l-3 3C2.11 7.47 2 7.72 2 8c0 .28.11.53.29.71l3 3A1.003 1.003 0 007 11V5c0-.55-.45-1-1-1z"],"double-caret-vertical":["M5 7h6a1.003 1.003 0 00.71-1.71l-3-3C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-3 3A1.003 1.003 0 005 7zm6 2H5a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 9z"],"double-chevron-down":["M7.29 8.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4zM12 8c-.28 0-.53.11-.71.29L8 11.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 8z"],"double-chevron-left":["M4.41 8L7.7 4.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C2.11 7.47 2 7.72 2 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.41 8zm5 0l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C7.11 7.47 7 7.72 7 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L9.41 8z"],"double-chevron-right":["M9 8c0-.28-.11-.53-.29-.71l-4-4a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4C8.89 8.53 9 8.28 9 8zm4.71-.71l-4-4a1.003 1.003 0 00-1.42 1.42L11.59 8 8.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"double-chevron-up":["M4 8c.28 0 .53-.11.71-.29L8 4.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-4 4A1.003 1.003 0 004 8zm4.71-.71C8.53 7.11 8.28 7 8 7s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],"doughnut-chart":["M11.86 7h4.05C15.45 3.39 12.61.52 9 .07v4.07A4 4 0 0111.86 7zM12 8c0 2.21-1.79 4-4 4s-4-1.79-4-4 1.79-4 4-4V0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8h-4z"],download:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM11.7 9.7l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-3-3A1.003 1.003 0 015.7 8.28l1.29 1.29V3.99c0-.55.45-1 1-1s1 .45 1 1v5.59l1.29-1.29a1.003 1.003 0 011.71.71c0 .27-.11.52-.29.7z"],"drag-handle-horizontal":["M2 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm8-2c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-4-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"drag-handle-vertical":["M6 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-6c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zM6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4 8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],draw:["M14.9 11c-.3 0-.5.1-.7.3l-3 3c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1zm-1-1v-.2l-1-5c-.1-.3-.3-.6-.6-.7l-11-4-.3.3 5.8 5.8c.2-.1.4-.2.6-.2.8 0 1.5.7 1.5 1.5S8.3 9 7.4 9s-1.5-.7-1.5-1.5c0-.2.1-.4.2-.6L.3 1.1l-.3.3 4 11c.1.3.4.6.7.6l5 1h.2c.3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7z"],"drawer-left":["M7 0a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h6zM6 2H2v12h4V2zm2 5h4.59L11.3 5.71A.965.965 0 0111 5a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42L12.59 9H8V7z"],"drawer-left-filled":["M1 0h6a1 1 0 011 1v14a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1zm7 7h4.59L11.3 5.71A.965.965 0 0111 5a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42L12.59 9H8V7z"],"drawer-right":["M15 0a1 1 0 011 1v14a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1h6zm-1 2h-4v12h4V2zM8 7H3.41L4.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 9H8V7z"],"drawer-right-filled":["M9 0h6a1 1 0 011 1v14a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1zM8 7H3.41L4.7 5.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 9H8V7z"],"drive-time":["M15.12 4.76h-1.05l-.76-2.12c-.19-.53-.76-1.08-1.27-1.24 0 0-1.32-.4-4.04-.4-2.72 0-4.04.4-4.04.4-.5.16-1.07.71-1.26 1.24l-.77 2.12H.88c-.48 0-.88.42-.88.94s.4.94.88.94h.38L1 7c-.03.69 0 1.44 0 2v5c0 .66.38 1 1 1s1-.34 1-1v-1h10v1c0 .66.38 1 1 1s1-.34 1-1V9c0-.56-.01-1.37 0-2l-.26-.37h.38c.48 0 .88-.42.88-.93 0-.52-.4-.94-.88-.94zM5 10H3V8h2v2zm8 0h-2V8h2v2zm0-4H3c-.18 0-.06-.82 0-1l.73-1.63C3.79 3.19 3.82 3 4 3h8c.18 0 .21.19.27.37L13 5c.06.18.18 1 0 1z"],duplicate:["M15 0H5c-.55 0-1 .45-1 1v2h2V2h8v7h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 10H2V6h8v8z"],edit:["M3.25 10.26l2.47 2.47 6.69-6.69-2.46-2.48-6.7 6.7zM.99 14.99l3.86-1.39-2.46-2.44-1.4 3.83zm12.25-14c-.48 0-.92.2-1.24.51l-1.44 1.44 2.47 2.47 1.44-1.44c.32-.32.51-.75.51-1.24.01-.95-.77-1.74-1.74-1.74z"],eject:["M4 9h8a1.003 1.003 0 00.71-1.71l-4-4C8.53 3.11 8.28 3 8 3s-.53.11-.71.29l-4 4A1.003 1.003 0 004 9zm8 1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1z"],emoji:["M8 0a8 8 0 110 16A8 8 0 018 0zm0 1a7 7 0 100 14A7 7 0 008 1zM4 8c.228 2.262 2 4 4 4 1.938 0 3.77-1.738 3.984-3.8L12 8h1c-.128 2.888-2.317 5-5 5a5 5 0 01-4.995-4.783L3 8h1zm2-3a1 1 0 110 2 1 1 0 010-2zm4 0a1 1 0 110 2 1 1 0 010-2z"],endorsed:["M15.86 7.5l-.81-1.42V4.5c0-.36-.19-.68-.49-.87l-1.37-.8-.81-1.41c-.19-.31-.51-.49-.86-.49H9.89L8.5.14a.948.948 0 00-1 0l-1.39.8H4.52a1 1 0 00-.86.49l-.8 1.37-1.44.83c-.3.19-.49.51-.49.87v1.65l-.8 1.37c-.08.15-.13.32-.13.49s.05.34.14.49l.8 1.37v1.65c0 .36.19.68.49.87l1.42.81.8 1.37c.19.31.51.49.86.49H6.1l1.39.8c.15.09.32.14.48.14s.34-.05.49-.14l1.39-.8h1.63a1 1 0 00.86-.49l.81-1.41 1.37-.8c.3-.19.49-.51.49-.87V9.93l.81-1.42a.89.89 0 00.04-1.01zm-4.12-.82l-4.01 4.01c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-2-2c-.18-.19-.3-.44-.3-.71a1.003 1.003 0 011.71-.71l1.3 1.3 3.3-3.3a1.003 1.003 0 011.71.71.95.95 0 01-.29.7z"],envelope:["M0 3.06v9.88L4.94 8 0 3.06zM14.94 2H1.06L8 8.94 14.94 2zm-6.41 8.53c-.14.14-.32.22-.53.22s-.39-.08-.53-.22L6 9.06 1.06 14h13.88L10 9.06l-1.47 1.47zM11.06 8L16 12.94V3.06L11.06 8z"],equals:["M3 5h10a1 1 0 010 2H3a1 1 0 110-2zm0 4h10a1 1 0 010 2H3a1 1 0 010-2z"],eraser:["M8.06 13.91l7.63-7.44c.41-.4.41-1.05 0-1.45L10.86.3c-.41-.4-1.08-.4-1.49 0L.31 9.13c-.41.4-.41 1.05 0 1.45l5.58 5.44h8.12v-.01c.55 0 1-.45 1-1s-.45-1-1-1H7.96l.1-.1zm-2.17.06L1.67 9.85l4.22-4.11 4.22 4.11-4.22 4.12z"],error:["M7.99-.01c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13h-2v-2h2v2zm0-3h-2v-7h2v7z"],euro:["M6.52 3.18c.51-.27 1.12-.4 1.83-.4.48 0 .91.06 1.27.18.37.12.68.29.96.51.18.14.3.33.44.51l1.53-1.53c-.12-.11-.23-.22-.36-.32a5.61 5.61 0 00-1.74-.83c-.66-.2-1.36-.3-2.1-.3-.99 0-1.88.18-2.66.53-.79.35-1.45.82-2 1.41-.55.58-.96 1.27-1.26 2.06H2c-.55 0-1 .45-1 1s.45 1 1 1h.04c-.01.17-.04.33-.04.5 0 .17.03.33.04.5H2c-.55 0-1 .45-1 1s.45 1 1 1h.43c0 .01 0 .02.01.02a6.2 6.2 0 001.25 2.07 5.77 5.77 0 002 1.4c.78.34 1.67.51 2.66.51.81 0 1.54-.12 2.21-.36.67-.24 1.25-.59 1.75-1.03l.03-.03-1.55-1.33c-.01.01-.02.03-.03.04-.29.3-.63.53-1.02.69-.4.17-.85.25-1.37.25-.71 0-1.32-.13-1.83-.4s-.93-.62-1.25-1.07c-.19-.24-.34-.49-.46-.76H9c.55 0 1-.45 1-1s-.45-1-1-1H4.35c-.01-.17-.03-.33-.03-.5 0-.17.02-.34.03-.5H10c.55 0 1-.45 1-1s-.45-1-1-1H4.83c.13-.27.27-.52.44-.76.32-.44.74-.8 1.25-1.06zM14 8.98v0z"],exchange:["M1.99 5.99c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zm4.15 1.86a.495.495 0 10.7-.7L5.7 5.99h5.79c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H5.7l1.15-1.15a.495.495 0 10-.7-.7l-2 2c-.1.09-.16.21-.16.35s.06.26.15.35l2 2.01zm7.85-1.86c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zM9.85 8.14a.533.533 0 00-.36-.15.495.495 0 00-.35.85l1.15 1.15h-5.8c-.28 0-.5.22-.5.5s.22.5.5.5h5.79l-1.15 1.15a.495.495 0 10.7.7l2-2c.09-.09.15-.22.15-.35s-.06-.26-.15-.35l-1.98-2z"],"exclude-row":["M0 10a1.003 1.003 0 001.71.71L3 9.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 8 5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L3 6.59l-1.29-1.3A1.003 1.003 0 00.29 6.71L1.59 8 .29 9.29C.11 9.47 0 9.72 0 10zm1-7h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 10H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-1-7H9c-1.1 0-2 .9-2 2s.9 2 2 2h5c1.1 0 2-.9 2-2s-.9-2-2-2z"],"expand-all":["M4 7c.28 0 .53-.11.71-.29L8 3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-4 4A1.003 1.003 0 004 7zm8 2c-.28 0-.53.11-.71.29L8 12.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0012 9z"],export:["M4 6c.28 0 .53-.11.71-.29L7 3.41V11c0 .55.45 1 1 1s1-.45 1-1V3.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4C8.53.11 8.28 0 8 0s-.53.11-.71.29l-4 4A1.003 1.003 0 004 6zm11 5c-.55 0-1 .45-1 1v2H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],"eye-off":["M16 7.97v-.02-.01-.02-.02a.672.672 0 00-.17-.36c-.49-.63-1.07-1.2-1.65-1.72l-3.16 2.26a2.978 2.978 0 01-2.98 2.9c-.31 0-.6-.06-.88-.15L5.09 12.3c.44.19.9.36 1.37.47.97.23 1.94.24 2.92.05.88-.17 1.74-.54 2.53-.98 1.25-.7 2.39-1.67 3.38-2.75.18-.2.37-.41.53-.62.09-.1.15-.22.17-.36v-.02-.02-.01-.02-.03c.01-.02.01-.03.01-.04zm-.43-4.17c.25-.18.43-.46.43-.8 0-.55-.45-1-1-1-.22 0-.41.08-.57.2l-.01-.01-2.67 1.91c-.69-.38-1.41-.69-2.17-.87a6.8 6.8 0 00-2.91-.05c-.88.18-1.74.54-2.53.99-1.25.7-2.39 1.67-3.38 2.75-.18.2-.37.41-.53.62-.23.29-.23.63-.01.92.51.66 1.11 1.25 1.73 1.79.18.16.38.29.56.44l-2.09 1.5.01.01c-.25.18-.43.46-.43.8 0 .55.45 1 1 1 .22 0 .41-.08.57-.2l.01.01 14-10-.01-.01zm-10.41 5a3.03 3.03 0 01-.11-.8 2.99 2.99 0 012.99-2.98c.62 0 1.19.21 1.66.53L5.16 8.8z"],"eye-on":["M10.29 6.7c.18.18.43.29.71.29s.53-.11.71-.29l4-4c.17-.18.29-.43.29-.7a1.003 1.003 0 00-1.71-.71L11 4.58 9.71 3.29A.997.997 0 009 3c-.55 0-1 .44-1 1a1 1 0 00.3.7l1.99 2zM16 7.96v-.02-.01-.02-.02a.64.64 0 00-.17-.36c-.3-.4-.65-.76-1-1.12l-1.7 1.7c-.55.55-1.3.88-2.13.88-.06 0-.11-.01-.17-.02C10.42 10.15 9.32 11 8.01 11A3.005 3.005 0 016.4 5.46c-.24-.43-.39-.93-.39-1.46 0-.26.04-.5.1-.74-.7.2-1.37.5-2.01.86-1.26.7-2.4 1.68-3.4 2.77-.18.21-.36.41-.53.63-.22.29-.22.64 0 .93.51.67 1.12 1.27 1.73 1.81 1.33 1.17 2.85 2.15 4.53 2.55.97.23 1.95.24 2.92.05.89-.18 1.74-.54 2.54-.99 1.25-.71 2.4-1.69 3.39-2.78.18-.2.37-.41.54-.63.09-.1.15-.23.17-.37v-.02-.02-.01-.02-.03c.01-.01.01-.02.01-.03zM8.01 9c.48 0 .87-.35.96-.81a.55.55 0 01-.07-.09l-.02.01L7.8 7.03c-.45.1-.79.48-.79.96 0 .56.45 1.01 1 1.01z"],"eye-open":["M8.002 7.003a1.003 1.003 0 000 2.005 1.003 1.003 0 000-2.005zm7.988.972v-.02-.01-.02-.02a.675.675 0 00-.17-.36c-.509-.673-1.118-1.264-1.737-1.806-1.328-1.173-2.846-2.155-4.523-2.546a6.702 6.702 0 00-2.925-.06c-.889.18-1.738.541-2.546.992C2.84 4.837 1.692 5.81.694 6.902c-.18.211-.36.411-.53.632a.742.742 0 000 .932c.51.672 1.119 1.264 1.738 1.805 1.328 1.173 2.846 2.156 4.523 2.547.968.23 1.947.24 2.925.04.889-.18 1.738-.542 2.546-.993 1.248-.712 2.397-1.684 3.395-2.777.18-.2.37-.411.54-.632.09-.1.149-.23.169-.36v-.02-.02-.01-.02-.03c0-.01-.01-.01-.01-.02zm-7.988 3.038a2.998 2.998 0 01-2.995-3.008 2.998 2.998 0 012.995-3.008 2.998 2.998 0 012.996 3.008 2.998 2.998 0 01-2.996 3.008z"],"fast-backward":["M14 3c-.24 0-.44.09-.62.23l-.01-.01L9 6.72V4c0-.55-.45-1-1-1-.24 0-.44.09-.62.23v-.01l-5 4 .01.01C2.16 7.41 2 7.68 2 8s.16.59.38.77v.01l5 4 .01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V9.28l4.38 3.5.01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"fast-forward":["M15 8c0-.32-.16-.59-.38-.77l.01-.01-5-4-.01.01A.987.987 0 009 3c-.55 0-1 .45-1 1v2.72l-4.38-3.5v.01A.987.987 0 003 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01L8 9.28V12c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01 5-4-.01-.01c.22-.18.38-.45.38-.77z"],feed:["M1.99 11.99c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.89-2-2-2zm1-4c-.55 0-1 .45-1 1s.45 1 1 1c1.66 0 3 1.34 3 3 0 .55.45 1 1 1s1-.45 1-1c0-2.76-2.24-5-5-5zm0-4c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7 3.13 7 7 0 .55.45 1 1 1s1-.45 1-1a9 9 0 00-9-9zm0-4c-.55 0-1 .45-1 1s.45 1 1 1c6.08 0 11 4.92 11 11 0 .55.45 1 1 1s1-.45 1-1c0-7.18-5.82-13-13-13z"],"feed-subscribed":["M3 2c1.06 0 2.08.16 3.06.45.13-.71.52-1.32 1.05-1.76C5.82.25 4.44 0 3 0c-.55 0-1 .45-1 1s.45 1 1 1zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm8.32-6.33a.99.99 0 001.4 0l3.98-3.98c.19-.18.3-.42.3-.7 0-.55-.45-.99-1-.99-.28 0-.52.11-.7.29l-3.28 3.28-1.29-1.29a.99.99 0 00-.7-.29 1 1 0 00-1 .99c0 .27.11.52.29.7l2 1.99zm3.73.53l-.93.93-.02-.02c-.17.17-.35.33-.56.45C13.47 9.16 14 11.02 14 13c0 .55.45 1 1 1s1-.45 1-1c0-2.5-.73-4.82-1.95-6.8zM3 8c-.55 0-1 .45-1 1s.45 1 1 1c1.66 0 3 1.34 3 3 0 .55.45 1 1 1s1-.45 1-1c0-2.76-2.24-5-5-5zm5.91-.91l-.03.03-2-2 .03-.03c-.11-.11-.23-.2-.33-.33A8.9 8.9 0 003 4c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7 3.13 7 7 0 .55.45 1 1 1s1-.45 1-1c0-1.87-.57-3.61-1.55-5.06-.61-.11-1.13-.42-1.54-.85z"],film:["M15 1h-5v2H6V1H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h5v-2h4v2h5c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 13H2v-2h2v2zm0-3H2V8h2v2zm0-3H2V5h2v2zm0-3H2V2h2v2zm6 6H6V5h4v5zm4 3h-2v-2h2v2zm0-3h-2V8h2v2zm0-3h-2V5h2v2zm0-3h-2V2h2v2z"],filter:["M13.99.99h-12a1.003 1.003 0 00-.71 1.71l4.71 4.71V14a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V7.41L14.7 2.7a1.003 1.003 0 00-.71-1.71z"],"filter-keep":["M15 10c-.28 0-.53.11-.71.29L12 12.59l-1.29-1.29A.965.965 0 0010 11a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0015 10zm-3-8c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7z"],"filter-list":["M9 8c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1h-5c-.55 0-1 .45-1 1zm3-6c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7zm3 8h-5c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0 3h-5c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"filter-open":["M15.707 10.293a1 1 0 010 1.414l-3 3c-.63.63-1.707.184-1.707-.707V8c0-.89 1.077-1.337 1.707-.707l3 3zM12 2c0 .28-.11.53-.29.7L8 6.41V10c0 .28-.11.53-.29.71l-2 2A1.003 1.003 0 014 12V6.41L.29 2.71A1.003 1.003 0 011 1h10c.55 0 1 .45 1 1z"],"filter-remove":["M12 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L4 6.41V12a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71V6.41l3.71-3.71c.18-.17.29-.42.29-.7zm2.41 10l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L13 10.59 11.71 9.3A.965.965 0 0011 9a1.003 1.003 0 00-.71 1.71l1.3 1.29-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l1.29-1.3 1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L14.41 12z"],flag:["M2.99 2.99c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1s1-.45 1-1v-11c0-.55-.45-1-1-1zm0-3c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm2 3.03v7.23c2.07-2.11 5.92 1.75 9 0V3.02c-3 2.07-6.94-2.03-9 0z"],flame:["M9.217 0c0 1.368.368 2.462 1.104 3.282C12.774 5.197 14 7.385 14 9.846c0 2.735-1.472 4.786-4.415 6.154 2.165-2.4 1.84-3.385-.368-6.4-2.342 1.2-1.967 2-1.592 3.6-.786 0-1.5 0-1.875-.4 0 .547.898 2 1.464 3.2-2.943-.82-6.092-5.744-4.988-6.154.736-.273 1.594-.137 2.575.41C3.575 5.333 5.047 1.915 9.217 0z"],flash:["M4 8c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1zm4-4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S7 .45 7 1v2c0 .55.45 1 1 1zM3.79 5.21a1.003 1.003 0 001.42-1.42l-1.5-1.5a1.003 1.003 0 00-1.42 1.42l1.5 1.5zm.71 5.29c-.28 0-.53.11-.71.29l-1.5 1.5a1.003 1.003 0 001.42 1.42l1.5-1.5a1.003 1.003 0 00-.71-1.71zm7-5c.28 0 .53-.11.71-.29l1.5-1.5a1.003 1.003 0 00-1.42-1.42l-1.5 1.5a1.003 1.003 0 00.71 1.71zm.71 5.29a1.003 1.003 0 00-1.42 1.42l1.5 1.5a1.003 1.003 0 001.42-1.42l-1.5-1.5zM15 7h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1s-.45-1-1-1zM8 5C6.34 5 5 6.34 5 8s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm0 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0 3c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1z"],"floppy-disk":["M15.71 2.29l-2-2A.997.997 0 0013 0h-1v6H4V0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V3c0-.28-.11-.53-.29-.71zM14 15H2V9c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v6zM11 1H9v4h2V1z"],"flow-branch":["M10.643 6.595c.22.418.344.894.344 1.399 0 .439-.094.855-.263 1.231l3.265 3.462-.002-1.75a.973.973 0 01.314-.68.99.99 0 011.388.048c.186.2.316.46.3.715l-.009 4.03a.959.959 0 01-.3.68.972.972 0 01-.698.266l-4.053.002a.97.97 0 01-.679-.314 1.031 1.031 0 01.05-1.42.972.972 0 01.698-.266l1.7-.001-3.305-3.35a2.998 2.998 0 01-4.228-1.653H.999a1 1 0 010-2h4.166a2.998 2.998 0 014.06-1.735l3.449-3.268-1.745.002a.979.979 0 01-.631-1.692c.199-.186.459-.316.713-.3l4.025.009c.247.008.493.1.679.3.186.2.274.451.265.7l.002 4.046a.972.972 0 01-.313.68 1.03 1.03 0 01-1.42-.05.973.973 0 01-.266-.7V3.295l-3.34 3.301z"],"flow-end":["M9.702 7.31c.176.176.293.41.293.684a.976.976 0 01-.283.695c-1.888 1.91-2.892 2.918-3.011 3.027-.179.164-.42.284-.693.284a.995.995 0 01-.997-.985c0-.274.112-.541.292-.72.12-.12.624-.551 1.514-1.293H.98c-.536 0-.975-.47-.975-1.008 0-.537.439-.996.975-.996h5.837c-.895-.752-1.4-1.187-1.514-1.304a1.03 1.03 0 01-.292-.705C5.01 4.45 5.464 4 6 4c.272 0 .52.108.695.294A535.7 535.7 0 009.702 7.31zM13 11.002c-1.657 0-3-1.347-3-3.008a3.004 3.004 0 013-3.007c1.657 0 3 1.346 3 3.007a3.004 3.004 0 01-3 3.008z"],"flow-linear":["M4.16 9.002H.977C.44 9.002 0 8.532 0 7.994c0-.537.44-.99.978-.99h3.18A3.01 3.01 0 016.995 5a3.01 3.01 0 012.839 2.004h2.98c-.898-.756-1.404-1.193-1.518-1.31a1.03 1.03 0 01-.293-.705c0-.538.454-.989.992-.989.274 0 .521.108.697.294.118.124 1.122 1.13 3.014 3.016a.96.96 0 01.293.684.975.975 0 01-.284.695l-3.018 3.027a.974.974 0 01-.694.284c-.553 0-1-.447-1-.985 0-.274.117-.545.293-.72l1.518-1.293H9.833A3.01 3.01 0 016.996 11 3.01 3.01 0 014.16 9.002z"],"flow-review":["M5.175 7.004a3.003 3.003 0 012.83-2.001c1.305 0 2.416.835 2.83 2.001h1.985c-.896-.756-1.401-1.193-1.515-1.31a1.03 1.03 0 01-.292-.705c0-.538.453-.989.99-.989a.95.95 0 01.696.294c.117.124 1.12 1.13 3.008 3.016.176.176.293.41.293.684a.976.976 0 01-.283.695l-3.013 3.027a.995.995 0 01-1.691-.702c0-.273.116-.544.292-.72l1.515-1.292h-1.98a3.003 3.003 0 01-2.835 2.016A3.003 3.003 0 015.17 9.002H3.18l1.515 1.292c.176.176.292.447.292.72a.995.995 0 01-1.69.702L.282 8.69A.976.976 0 010 7.994c0-.273.117-.508.293-.684A535.858 535.858 0 003.3 4.294.95.95 0 013.997 4c.537 0 .99.45.99.989 0 .273-.12.528-.292.705-.114.117-.62.554-1.515 1.31h1.995z"],"flow-review-branch":["M10.392 10.647A3.002 3.002 0 016.16 8.995H3.37l1.338 1.318c.172.178.287.41.282.683-.01.536-.524.995-.99.995-.465 0-.63-.187-.747-.294L.281 8.682A.956.956 0 010 7.994a.971.971 0 01.294-.687l3.01-3.028a.973.973 0 01.697-.27c.536.01.998.485.989 1.021a.971.971 0 01-.295.687L3.37 6.997h2.79a3.002 3.002 0 014.106-1.716l2.416-2.277-1.732.004a.99.99 0 01-.679-.329.978.978 0 01.05-1.378c.199-.186.459-.315.714-.3l4.012.005c.248.009.493.1.68.3.185.2.273.45.264.699L15.99 6.05a.973.973 0 01-.314.679 1.03 1.03 0 01-1.421-.048.971.971 0 01-.265-.699V4.29L11.65 6.602c.219.416.343.89.343 1.394 0 .451-.1.88-.279 1.263L14 11.68l-.004-1.73a.982.982 0 01.323-.68.978.978 0 011.378.049c.187.2.316.46.3.714l-.004 4.011a.983.983 0 01-.3.691.972.972 0 01-.7.265l-4.046-.001a.987.987 0 01-.679-.326 1.017 1.017 0 01.048-1.41.972.972 0 01.699-.265h1.693l-2.315-2.35z"],flows:["M13.5 6a2.5 2.5 0 00-2.45 2h-1.3L5.74 4l-.75.75L8.25 8h-3.3a2.5 2.5 0 100 1h3.3l-3.26 3.25.75.75 4.01-4h1.3a2.5 2.5 0 102.45-3z"],"folder-close":["M-.01 14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7h-16v7zm15-10H7.41L5.7 2.3a.965.965 0 00-.71-.3h-4c-.55 0-1 .45-1 1v3h16V5c0-.55-.45-1-1-1z"],"folder-new":["M10.165 7a3.003 3.003 0 002.827 2 3.003 3.003 0 002.827-2H16v7c0 .55-.45 1-1 1H1.01c-.55 0-1-.45-1-1V7h10.155zM8.76 6H0V3c0-.55.45-1 1-1h1.998c.28 0 .53.11.71.29L5.417 4h2.578c0 .768.29 1.469.765 2zm6.23-3c.55 0 1 .45 1 1s-.45 1-1 1h-.999v1c0 .55-.45 1-1 1-.549 0-.998-.45-.998-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 .999-1 .55 0 1 .45 1 1v1h.999z"],"folder-open":["M2.06 6.69c.14-.4.5-.69.94-.69h11V5c0-.55-.45-1-1-1H6.41l-1.7-1.71A.997.997 0 004 2H1c-.55 0-1 .45-1 1v9.84l2.05-6.15h.01zM16 8c0-.55-.45-1-1-1H4a.99.99 0 00-.94.69l-2 6c-.04.09-.06.2-.06.31 0 .55.45 1 1 1h11c.44 0 .81-.29.94-.69l2-6c.04-.09.06-.2.06-.31z"],"folder-shared":["M8.76 5.98c-.47-.53-.77-1.22-.77-1.99h-.58L5.7 2.29a.965.965 0 00-.71-.3h-4c-.55 0-1 .45-1 1v3h8.76l.01-.01zm6.23-2.99h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V8c0 .55.45 1 1 1s1-.45 1-1V4c0-.56-.45-1.01-1-1.01zm-1.98 7.23l-.9.9-.01-.01c-.54.55-1.28.89-2.11.89-1.66 0-3-1.34-3-3 0-.77.3-1.47.78-2H-.01v7c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.18c-.31.11-.65.18-1 .18-.76-.01-1.45-.31-1.98-.78z"],"folder-shared-open":["M13.02 10.22l-.9.9-.01-.01c-.54.55-1.28.89-2.11.89-1.66 0-3-1.34-3-3 0-.77.3-1.47.78-2H4a.99.99 0 00-.94.69l-2 6c-.04.09-.06.2-.06.31 0 .55.45 1 1 1h11c.44 0 .81-.29.94-.69l1.11-3.32c-.01 0-.03.01-.05.01-.77 0-1.45-.3-1.98-.78zM2.06 6.69c.14-.4.5-.69.94-.69h5.76l.01-.01C8.3 5.46 8 4.77 8 4H6.41l-1.7-1.71A.997.997 0 004 2H1c-.55 0-1 .45-1 1v9.84l2.05-6.15h.01zM15 3h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 6.41V8c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],follower:["M9.37 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.06-.01-.12-.01-.19.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.12-.39.28-.06.44-.36.5-.63.06-.11.19-.39.16-.7-.04-.4-.2-.59-.38-.67v-.07c0-.52-.05-1.26-.14-1.74a2.72 2.72 0 00-.09-.43 3.02 3.02 0 00-1.04-1.51C7.87 3.2 7.15 3 6.5 3c-.64 0-1.36.2-1.87.59-.5.38-.87.92-1.05 1.51-.04.13-.07.27-.09.4-.09.49-.14 1.24-.14 1.75v.06c-.19.07-.36.26-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.13 15.5.02 16 .02 16h12.96s.15-.5-.22-1.36c-.38-.85-2.19-1.42-3.39-1.95zm6.33-10.4l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9.99c-.55 0-1 .45-1 1s.45 1 1 1h2.58l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],following:["M9.37 12.69c-1.2-.53-1.04-.85-1.08-1.29-.01-.06-.01-.12-.01-.19.41-.37.75-.87.97-1.44 0 0 .01-.03.01-.04.05-.13.09-.26.12-.39.28-.06.44-.36.5-.63.06-.11.19-.39.16-.7-.04-.4-.2-.59-.38-.67v-.07c0-.52-.05-1.26-.14-1.74a2.72 2.72 0 00-.09-.43 3.02 3.02 0 00-1.04-1.51C7.87 3.2 7.15 3 6.5 3c-.64 0-1.36.2-1.87.59-.5.38-.87.92-1.05 1.51-.04.13-.07.27-.09.4-.09.49-.14 1.24-.14 1.75v.06c-.19.07-.36.26-.4.68-.03.31.1.59.16.7.06.28.23.59.51.64.04.14.08.27.13.39 0 .01.01.02.01.02v.01c.22.59.57 1.1.99 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.12 1.29-1.2.53-3.01 1.1-3.38 1.95C-.13 15.5.02 16 .02 16h12.96s.15-.5-.22-1.36c-.38-.85-2.19-1.42-3.39-1.95zM14.99 2h-2.58l.29-.29A1.003 1.003 0 0011.28.29l-2 2c-.17.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L12.41 4h2.58c.55 0 1-.45 1-1s-.45-1-1-1z"],font:["M13.93 14.67L8.94.67h-.01C8.79.28 8.43 0 8 0s-.79.28-.93.67h-.01l-5 14h.01c-.04.1-.07.21-.07.33 0 .55.45 1 1 1 .43 0 .79-.28.93-.67h.01L5.49 11h5.02l1.55 4.34h.01c.14.38.5.66.93.66.55 0 1-.45 1-1 0-.12-.03-.23-.07-.33zM6.2 9L8 3.97 9.8 9H6.2z"],fork:["M13.7 9.29a1.003 1.003 0 00-1.42 1.42l.29.29H11.4l-5-5h6.17l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.29.29H.99c-.55 0-1 .45-1 1s.45 1 1 1h2.59l6.71 6.71c.18.18.43.29.71.29h1.59l-.29.29a1.003 1.003 0 001.42 1.42l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71l-2.02-2z"],form:["M2 11v2h2v-2H2zM1 9h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1zm9-6h5c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1zM6 1a1.003 1.003 0 01.71 1.71l-3 4C3.53 6.89 3.28 7 3 7s-.53-.11-.71-.29l-2-2a1.003 1.003 0 011.42-1.42L3 4.59l2.29-3.3C5.47 1.11 5.72 1 6 1zm4 10h5c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1z"],"full-circle":["M8 0a8 8 0 100 16A8 8 0 108 0z"],"full-stacked-chart":["M13 12h1c.55 0 1-.45 1-1V8h-3v3c0 .55.45 1 1 1zM10 2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3h3V2zm0 4H7v3h3V6zm5-4c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v2h3V2zm0 3h-3v2h3V5zM5 5H2v3h3V5zm-2 7h1c.55 0 1-.45 1-1V9H2v2c0 .55.45 1 1 1zm12 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM5 2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h3V2zm3 10h1c.55 0 1-.45 1-1v-1H7v1c0 .55.45 1 1 1z"],fullscreen:["M3.41 2H5c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v4c0 .55.45 1 1 1s1-.45 1-1V3.41L5.29 6.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L3.41 2zM6 9c-.28 0-.53.11-.71.29L2 12.59V11c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41l3.29-3.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1zm9 1c-.55 0-1 .45-1 1v1.59L10.71 9.3A.965.965 0 0010 9a1.003 1.003 0 00-.71 1.71l3.3 3.29H11c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm0-10h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.29a1.003 1.003 0 001.42 1.42L14 3.41V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],function:["M8.12 4.74H6.98c.33-1.29.75-2.24 1.28-2.84.33-.37.64-.56.95-.56.06 0 .11.02.15.05.04.04.06.09.06.15 0 .05-.04.15-.13.29-.09.14-.13.28-.13.4 0 .18.07.33.2.46.14.13.31.19.52.19.22 0 .41-.08.56-.23.15-.16.23-.37.23-.63 0-.3-.11-.55-.34-.74C10.1 1.09 9.74 1 9.24 1c-.78 0-1.49.22-2.12.67-.64.45-1.24 1.2-1.81 2.23-.2.36-.38.59-.56.69-.18.1-.46.15-.85.15l-.26.9h1.08l-1.59 6.12c-.27 1.01-.44 1.63-.54 1.86-.14.34-.34.63-.62.87-.11.1-.24.15-.4.15a.15.15 0 01-.11-.04l-.04-.05c0-.03.04-.08.12-.16.08-.08.12-.2.12-.36 0-.18-.06-.33-.19-.44-.12-.12-.3-.18-.54-.18-.28 0-.51.08-.68.23-.16.14-.25.32-.25.53 0 .22.1.42.31.59.21.17.53.25.97.25.7 0 1.32-.18 1.87-.54.54-.36 1.02-.92 1.42-1.67.41-.75.82-1.96 1.25-3.63l.91-3.54h1.1l.29-.89zm5.43 1.52c.2-.15.41-.23.62-.23.08 0 .23.03.45.09s.41.09.57.09c.23 0 .42-.08.57-.23.16-.16.24-.36.24-.61 0-.26-.08-.47-.23-.62-.15-.15-.37-.23-.66-.23-.25 0-.5.06-.72.18-.23.12-.51.38-.86.78-.26.3-.64.81-1.15 1.55-.2-.91-.55-1.75-1.05-2.51l-2.72.46-.06.29c.2-.04.37-.06.51-.06.27 0 .49.11.67.34.28.36.67 1.45 1.17 3.26-.39.52-.66.85-.8 1.01-.24.26-.44.42-.59.5-.12.06-.25.09-.41.09-.11 0-.3-.06-.56-.18-.18-.08-.34-.12-.48-.12-.27 0-.48.08-.66.25-.17.17-.26.38-.26.64 0 .25.08.44.24.6.16.15.37.23.64.23.26 0 .5-.05.73-.16.23-.11.52-.34.86-.69.35-.35.82-.9 1.43-1.67.23.73.44 1.25.61 1.58s.37.57.59.71c.22.15.5.22.83.22.32 0 .65-.11.98-.34.44-.3.88-.81 1.34-1.53l-.26-.15c-.31.43-.54.7-.69.8-.1.07-.22.1-.35.1-.16 0-.32-.1-.48-.3-.27-.34-.62-1.27-1.06-2.8.4-.68.73-1.13 1-1.34z"],"gantt-chart":["M10 10c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1zM6 7c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1zm9 5H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM4 5h3c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1z"],geofence:["M6 9c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1v-1.59l-3.29 3.3A1.003 1.003 0 010 15c0-.28.11-.53.3-.71L3.59 11H2c-.55 0-1-.45-1-1s.45-1 1-1zM9.088.004l.097.013.097.024.057.018.1.042.054.029.095.061.052.04 6 5 .05.046.076.08.053.07.06.095.051.11c.056.141.079.294.067.446l-.014.105-.037.143-.035.087-.043.083-4 7-.034.056-.059.08-.038.044-.096.092-.114.082-.116.062-.086.034-.109.03-.1.017-.069.006H8.83c.088-.25.144-.515.163-.79L9 13v-3a3 3 0 00-2.824-2.995L6 7H3c-.351 0-.689.06-1.002.171L2 5l.002-.07.013-.1.015-.073.025-.085.043-.104.056-.101.045-.066.079-.093.084-.078.083-.062 6-4 .07-.043.12-.056.111-.036.108-.022.083-.01h.031c.046-.002.083 0 .12.003z"],geolocation:["M-.01 6.66l7.34 2 2 7.33 6.66-16z"],geosearch:["M8.82 12.4h.66c.23 0 .36-.17.36-.4v-1.48l.19-.18c-.27.03-.55.06-.83.06-.28 0-.56-.03-.84-.07.02.04.05.08.07.13V12c0 .23.15.4.39.4zM6.4 15.1A5.51 5.51 0 01.9 9.6c0-.49.06-.98.18-1.43.03 0 .05-.01.08-.01h.08v.44c0 .19.17.34.36.34.03 0 .07-.01.1-.01l.71.7c.07.07.19.07.26 0s.07-.19 0-.26l-.7-.72c0-.02.03-.03.03-.05v-.11c0-.15.08-.2.23-.33h.42c.08 0 .15-.01.22-.04h.02c.02-.02.03-.02.04-.04.01-.01.01-.01.02-.01l.02-.01.9-.9c-.13-.26-.24-.52-.34-.8h-.5v-.43c0-.01.05.05.04-.08h.31c-.03-.13-.06-.26-.08-.39h-.57c.16-.12.34-.24.51-.36-.02-.23-.04-.46-.04-.7 0-.12.01-.23.02-.34A6.385 6.385 0 000 9.6C0 13.13 2.87 16 6.4 16c3.1 0 5.67-2.22 6.26-5.15l-.78-.88c-.21 2.85-2.58 5.13-5.48 5.13zm-1.7-2.93v-.28h.12c.23 0 .39-.19.39-.42v-.54s.01-.01 0-.01L3.77 9.45h-.62c-.23 0-.38.19-.38.42v1.6c0 .23.14.42.38.42h.26v1.61c0 .23.22.41.45.41s.45-.18.45-.41v-.97H4.3c.24 0 .4-.13.4-.36zm11.07-2.34l-2.94-2.94c.11-.17.21-.34.3-.52.01-.03.03-.06.04-.09.08-.18.16-.36.22-.55v-.01c.06-.19.1-.38.14-.58.01-.05.01-.09.02-.14.03-.2.05-.4.05-.61a4.4 4.4 0 00-4.4-4.4C6.77 0 4.8 1.97 4.8 4.4s1.97 4.4 4.4 4.4c.21 0 .41-.02.61-.05.04 0 .09-.01.14-.02.2-.03.39-.08.58-.14h.01c.19-.06.37-.14.55-.22.03-.01.06-.03.09-.04.18-.09.35-.19.52-.3l2.94 2.94a.8.8 0 00.57.23c.44 0 .8-.36.8-.8a.895.895 0 00-.24-.57zM9.2 7.6C7.43 7.6 6 6.17 6 4.4c0-1.77 1.43-3.2 3.2-3.2s3.2 1.43 3.2 3.2c0 1.77-1.43 3.2-3.2 3.2zm1.54 4.26v-.52c0-.09-.1-.17-.19-.17s-.19.07-.19.17v.52c0 .09.1.17.19.17s.19-.07.19-.17z"],"git-branch":["M12 1c-1.66 0-3 1.34-3 3 0 1.25.76 2.32 1.85 2.77A2.02 2.02 0 019 8H7c-.73 0-1.41.2-2 .55V5.82C6.16 5.4 7 4.3 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.82v4.37c-1.16.4-2 1.51-2 2.81 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.04-.53-1.95-1.32-2.49.35-.31.81-.51 1.32-.51h2c1.92 0 3.52-1.35 3.91-3.15A2.996 2.996 0 0012 1zM4 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 12c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm8-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-commit":["M15 7h-3.14c-.45-1.72-2-3-3.86-3S4.59 5.28 4.14 7H1c-.55 0-1 .45-1 1s.45 1 1 1h3.14c.45 1.72 2 3 3.86 3s3.41-1.28 3.86-3H15c.55 0 1-.45 1-1s-.45-1-1-1zm-7 3c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"git-merge":["M12 6c-1.3 0-2.4.84-2.82 2H9c-1.62 0-3-.96-3.63-2.34C6.33 5.16 7 4.16 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.81v4.37C1.84 10.6 1 11.7 1 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V8.43A5.89 5.89 0 009 10h.18A2.996 2.996 0 0015 9c0-1.66-1.34-3-3-3zm-8 8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm8 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-new-branch":["M14 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3.18 4.8C10.51 7.51 9.82 8 9 8H7c-.73 0-1.41.2-2 .55V5.82C6.16 5.4 7 4.3 7 3c0-1.66-1.34-3-3-3S1 1.34 1 3c0 1.3.84 2.4 2 2.82v4.37c-1.16.4-2 1.51-2 2.81 0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.04-.53-1.95-1.32-2.49.35-.31.81-.51 1.32-.51h2c1.9 0 3.49-1.33 3.89-3.11-.29.07-.58.11-.89.11-.41 0-.8-.08-1.18-.2zM4 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 12c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-pull":["M3 1C1.34 1 0 2.34 0 4c0 1.3.84 2.4 2 2.82v3.37C.84 10.6 0 11.7 0 13c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V6.82C5.16 6.4 6 5.3 6 4c0-1.66-1.34-3-3-3zm0 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0-9c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm11 5.18V6c0-1.66-1.34-3-3-3H9.41l1.29-1.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-3 3C6.11 3.47 6 3.72 6 4c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L9.41 5H11c.55 0 1 .45 1 1v4.18A2.996 2.996 0 0013 16c1.66 0 3-1.34 3-3 0-1.3-.84-2.4-2-2.82zM13 14c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-push":["M4 6h1V5H4v1zm9 3c0-.28-.11-.53-.29-.71l-3-3C9.53 5.11 9.28 5 9 5s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L8 8.41V15c0 .55.45 1 1 1s1-.45 1-1V8.41l1.29 1.29c.18.19.43.3.71.3.55 0 1-.45 1-1zM5 3H4v1h1V3zm10-3H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h5v-2H2v-1h4v-1H3V2h11v9h-2v1h2v1h-2v2h3c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"git-repo":["M5 9H4v1h1V9zm10-9H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h3v1l2-1 2 1v-1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM4 13H2v-1h2v1zm10 0H8v-1h6v1zm0-2H3V2h11v9zM5 3H4v1h1V3zm0 4H4v1h1V7zm0-2H4v1h1V5z"],glass:["M2 0v4c0 2.97 2.16 5.43 5 5.91V14H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1H9V9.91c2.84-.48 5-2.94 5-5.91V0H2z"],globe:["M4.45 7.83c-.26 0-.41.21-.41.46v1.75c0 .26.16.46.41.46h.29v1.77c0 .25.24.45.49.45s.49-.2.49-.45V11.2h-.01c.26 0 .44-.14.44-.4v-.3h.14c.26 0 .43-.2.43-.46v-.59s.01-.01 0-.01l-1.58-1.6h-.69zM8.51 3.9h.22c.06 0 .12-.01.12-.07 0-.06-.05-.07-.12-.07h-.22c-.06 0-.12.01-.12.07.01.06.06.07.12.07zm-2.33-.05c.07-.07.07-.19 0-.26l-.5-.5a.187.187 0 00-.26 0c-.07.07-.07.19 0 .26l.5.5c.07.07.19.07.26 0zm3.06.89c.07 0 .14-.06.14-.12v-.31c0-.07-.07-.12-.14-.12s-.14.06-.14.12v.31c0 .07.07.12.14.12zM8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-.55.1-1.07.23-1.57h.11v.47c0 .2.18.37.39.37.03 0 .08-.01.11-.02l.78.77c.08.08.2.08.28 0 .08-.08.08-.2 0-.28l-.75-.78c0-.02.04-.04.04-.06v-.12c0-.16.09-.22.25-.36h.46c.09 0 .17-.01.24-.05h.02c.02-.01.03-.02.05-.03.01-.01.01-.01.02-.01l.02-.02 1.59-1.58c.18-.18.18-.46 0-.64s-.47-.15-.65.03l-.3.34h-.57v-.48c0-.01.05.05.05-.09h.64c.12 0 .22-.09.22-.21s-.1-.21-.22-.21H4.1c.18-.15.34-.31.54-.44l.01-.01c.21-.14.45-.25.68-.37.15-.07.29-.15.44-.21.17-.07.35-.11.53-.17.18-.05.35-.12.53-.16a6.05 6.05 0 013.47.35c.05.02.1.05.16.08.25.11.48.24.71.39.25.16.49.34.71.55H10.6s0-.03-.01-.03c-.04 0-.09 0-.13.03l-.51.51a.17.17 0 000 .23c.06.06.17.06.23 0l.42-.44.01-.02h.25c0 .14-.07.09-.07.12v.07c0 .22-.15.37-.36.37h-.38c-.19 0-.38.21-.38.4v.17h-.1c-.12 0-.2.06-.2.18v.25h-.23c-.17 0-.3.11-.3.28 0 .17.13.26.3.26.07 0 .14.03.19-.11l.04.01.49-.46h.17l.39.37c.03.03.08.02.12-.01.03-.03.03-.12 0-.15l-.32-.35h.23l.09.12c.18.18.48.17.66-.01l.09-.1h.4c.02 0 .08.05.08.05v.24l-.05-.01h-.36c-.11 0-.21.1-.21.21 0 .11.09.21.21.21h.41v.15c-.14.21-.24.42-.45.42h-.94v-.01l-.44-.44a.47.47 0 00-.66 0l-.42.43v.01H8.6c-.26 0-.49.21-.49.46v.92c0 .26.23.45.49.45h.9c.34.14.57.35.72.69v1.68c0 .26.17.44.42.44h.72c.26 0 .4-.18.4-.44V9l.89-.86.03-.02.02-.01h.03c.07-.08.15-.19.15-.31v-.91c0-.18-.16-.32-.31-.46H13c.01.28.21.42.46.42h.42c.08.37.12.76.12 1.15 0 3.31-2.69 6-6 6zm4.54-4.27c-.1 0-.21.08-.21.18v.57c0 .1.11.18.21.18.1 0 .21-.08.21-.18v-.57c0-.1-.11-.18-.21-.18zM8.37 3.19c0-.25-.2-.42-.46-.42h-.54c-.25 0-.42.18-.42.43 0 .03-.1.04.05.08v.47c0 .15.06.27.21.27s.21-.12.21-.27v-.14h.5c.24 0 .45-.16.45-.42z"],"globe-network":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm5.17 5h-2.44c-.21-1.11-.51-2.03-.91-2.69 1.43.46 2.61 1.43 3.35 2.69zM10 8c0 .73-.05 1.39-.12 2H6.12C6.05 9.39 6 8.73 6 8s.05-1.39.12-2h3.76c.07.61.12 1.27.12 2zM8 2c.67 0 1.36 1.1 1.73 3H6.27C6.64 3.1 7.33 2 8 2zm-1.82.31c-.4.66-.71 1.58-.91 2.69H2.83a6.025 6.025 0 013.35-2.69zM2 8c0-.7.13-1.37.35-2h2.76C5.04 6.62 5 7.28 5 8s.04 1.38.11 2H2.35C2.13 9.37 2 8.7 2 8zm.83 3h2.44c.21 1.11.51 2.03.91 2.69A6.025 6.025 0 012.83 11zM8 14c-.67 0-1.36-1.1-1.73-3h3.46c-.37 1.9-1.06 3-1.73 3zm1.82-.31c.4-.66.7-1.58.91-2.69h2.44a6.025 6.025 0 01-3.35 2.69zM13.65 10h-2.76c.07-.62.11-1.28.11-2s-.04-1.38-.11-2h2.76c.22.63.35 1.3.35 2s-.13 1.37-.35 2z"],graph:["M14 3c-1.06 0-1.92.83-1.99 1.88l-1.93.97A2.95 2.95 0 008 5c-.56 0-1.08.16-1.52.43L3.97 3.34C3.98 3.23 4 3.12 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.24 0 .47-.05.68-.13l2.51 2.09C5.08 7.29 5 7.63 5 8c0 .96.46 1.81 1.16 2.35l-.56 1.69c-.91.19-1.6.99-1.6 1.96 0 1.1.9 2 2 2s2-.9 2-2c0-.51-.2-.97-.51-1.32l.56-1.69A2.99 2.99 0 0011 8c0-.12-.02-.24-.04-.36l1.94-.97c.32.21.69.33 1.1.33 1.1 0 2-.9 2-2s-.9-2-2-2z"],"graph-remove":["M12.89 8.11l-.01.01-.38-.38-.38.38-.02-.02c-.54.55-1.27.9-2.1.9-1.66 0-3-1.34-3-3 0-.83.35-1.56.9-2.1l-.02-.02.38-.38-.38-.38.01-.01C7.35 2.57 7 1.83 7 1c0-.34.07-.65.17-.96A8.004 8.004 0 000 8c0 4.42 3.58 8 8 8 4.14 0 7.54-3.14 7.96-7.17-.31.1-.62.17-.96.17-.83 0-1.57-.35-2.11-.89zm1.02-4.61l1.79-1.79c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-1.79 1.8L10.71.3A.965.965 0 0010 0a1.003 1.003 0 00-.71 1.71l1.79 1.79-1.79 1.79a1.003 1.003 0 001.42 1.42l1.79-1.79 1.79 1.79a1.003 1.003 0 001.42-1.42l-1.8-1.79z"],"greater-than":["M2.713 5.958a1 1 0 01.574-1.916l10 3c.95.285.95 1.63 0 1.916l-10 3a1 1 0 01-.574-1.916L9.52 8 2.713 5.958z"],"greater-than-or-equal-to":["M2.713 3.958a1 1 0 01.574-1.916l10 3c.95.285.95 1.63 0 1.916l-10 3a1 1 0 01-.574-1.916L9.52 6 2.713 3.958zM3 12h10a1 1 0 010 2H3a1 1 0 010-2z"],grid:["M15 9c.55 0 1-.45 1-1s-.45-1-1-1h-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1H9V1c0-.55-.45-1-1-1S7 .45 7 1v1H4V1c0-.55-.45-1-1-1S2 .45 2 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v3H1c-.55 0-1 .45-1 1s.45 1 1 1h1v3H1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-1h3v1c0 .55.45 1 1 1s1-.45 1-1v-1h3v1c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V9h1zm-8 3H4V9h3v3zm0-5H4V4h3v3zm5 5H9V9h3v3zm0-5H9V4h3v3z"],"grid-view":["M0 1v6h7V0H1C.45 0 0 .45 0 1zm0 14c0 .55.45 1 1 1h6V9H0v6zM15 0H9v7h7V1c0-.55-.45-1-1-1zM9 16h6c.55 0 1-.45 1-1V9H9v7z"],"group-objects":["M5 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6-3H5C2.24 3 0 5.24 0 8s2.24 5 5 5h6c2.76 0 5-2.24 5-5s-2.24-5-5-5zm0 9H5c-2.21 0-4-1.79-4-4s1.79-4 4-4h6c2.21 0 4 1.79 4 4s-1.79 4-4 4zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"grouped-bar-chart":["M10 12c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1zm3 0c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1zm2 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-9-1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1zm-3 0c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1v9c0 .55.45 1 1 1z"],hand:["M15 5c0-.55-.45-1-1-1-.41 0-.76.24-.91.59v.01s0 .01-.01.01L11.57 8h-.36l.78-4.84C12 3.11 12 3.05 12 3a1 1 0 00-1.99-.16v.01L9.18 8H9V1c0-.55-.45-1-1-1S7 .45 7 1v7h-.09l-.93-5.18A1 1 0 005 2c-.55 0-1 .45-1 1 0 .05 0 .11.01.16L5.26 11h-.04L2.83 7.44C2.65 7.18 2.35 7 2 7c-.55 0-1 .45-1 1 0 .17.04.33.12.47l3 5.69h.01v.01A5.002 5.002 0 0013 11v-.59l1.93-5.05c.05-.11.07-.23.07-.36z"],"hand-down":["M14.72 7.87c-1.54-.67-2.99-2.68-3.7-3.95C10.11 1.95 9.93 0 6.14 0 4.05 0 2.71.61 1.92 2.12 1.27 3.36 1 5.21 1 7.83v.79c0 .65.6 1.18 1.35 1.18.34 0 .64-.11.88-.29.17.48.68.84 1.29.84.41 0 .78-.16 1.03-.42.23.37.67.63 1.19.63.57 0 1.05-.31 1.25-.74l.01.63v4.05c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5V7.9c.58.41 1.55 1.21 2.47 1.29 1.57.14 1.82-1.07 1.25-1.32z"],"hand-left":["M12.08 4.97c-1.26-.71-3.27-2.15-3.95-3.7C7.88.7 6.67.96 6.81 2.52c.09.93.89 1.9 1.3 2.48H1.5C.67 5 0 5.67 0 6.5S.67 8 1.5 8h4.05l.63.01c-.44.2-.75.69-.75 1.25 0 .52.26.96.63 1.19-.26.25-.42.61-.42 1.03 0 .61.35 1.12.84 1.29-.18.24-.29.54-.29.88 0 .75.54 1.35 1.19 1.35h.79c2.62 0 4.47-.28 5.71-.92 1.51-.79 2.12-2.14 2.12-4.22 0-3.79-1.95-3.97-3.92-4.89z"],"hand-right":["M14.5 5H7.89c.41-.58 1.21-1.55 1.3-2.47C9.34.97 8.12.71 7.87 1.28c-.67 1.54-2.68 2.99-3.95 3.7C1.95 5.89 0 6.07 0 9.86c0 2.09.61 3.43 2.12 4.22 1.24.65 3.09.92 5.71.92h.79c.65 0 1.18-.6 1.18-1.35 0-.34-.11-.64-.29-.88.48-.17.84-.68.84-1.29 0-.41-.16-.78-.42-1.03.37-.23.63-.67.63-1.19 0-.57-.31-1.05-.74-1.25l.63-.01h4.05c.83 0 1.5-.67 1.5-1.5S15.33 5 14.5 5z"],"hand-up":["M13.65 6.19c-.34 0-.64.11-.88.29-.17-.48-.68-.84-1.29-.84-.41 0-.78.16-1.03.42-.23-.37-.67-.63-1.19-.63-.57 0-1.05.31-1.25.74L8 5.55V1.5C8 .67 7.33 0 6.5 0S5 .67 5 1.5v6.61c-.58-.41-1.55-1.21-2.48-1.3C.96 6.67.7 7.88 1.28 8.13c1.54.67 2.99 2.68 3.7 3.95C5.89 14.05 6.07 16 9.86 16c2.09 0 3.43-.61 4.22-2.12.64-1.24.92-3.09.92-5.71v-.79c0-.65-.6-1.19-1.35-1.19z"],hat:["M15 10c.495 0 .933.379.993.882L16 11v.505c0 1.461-3.524 2.45-7.707 2.493L8 14c-4.31 0-8-1-8-2.495V11c0-.561.466-1 1-1 .895 0 3 1 7 1l.381-.003C12.135 10.937 14.134 10 15 10zm-4-8c1.13 0 2.02 2.153 2.671 6.46-1.063.266-2.644.652-4.887.727l-.403.01L8 9.2c-2.664 0-4.488-.444-5.673-.74C2.98 4.153 3.87 2 5 2c2 0 1.329 2 3 2s1-2 3-2z"],header:["M13 1c-.55 0-1 .45-1 1v5H4V2c0-.55-.45-1-1-1s-1 .45-1 1v12c0 .55.45 1 1 1s1-.45 1-1V9h8v5c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"header-one":["M14.06 8c-.04.23-.12.44-.25.61-.13.17-.29.3-.48.41-.18.11-.39.18-.62.23-.23.04-.46.07-.71.07v1.03h1.74V16H15V8h-.94zM7 0c-.56 0-1 .45-1 1v4H2V1c0-.55-.45-1-1-1-.56 0-1 .45-1 1v10c0 .55.45 1 1 1 .56 0 1-.45 1-1V7h4v4c0 .55.45 1 1 1 .56 0 1-.45 1-1V1c0-.54-.45-1-1-1z"],"header-three":["M1 0C.44 0 0 .45 0 1v10c0 .54.45 1 1 1 .56 0 1-.45 1-1V7h4v4c0 .54.45 1 1 1 .56 0 1-.45 1-1V1c0-.54-.45-1-1-1-.56 0-1 .45-1 1v4H2V1c0-.54-.45-1-1-1zm13.71 11.72c.41.08.72.3.95.65.23.35.34.77.34 1.27 0 .37-.07.7-.2.97-.14.29-.32.54-.55.74-.23.2-.5.36-.8.47-.3.11-.62.16-.96.16-.41 0-.77-.06-1.08-.19-.31-.12-.56-.31-.77-.54-.21-.24-.36-.52-.47-.85-.11-.33-.16-.7-.17-1.1h1.14c-.01.47.09.86.32 1.17.23.31.57.47 1.02.47.39 0 .71-.12.97-.36s.39-.58.39-1.02c0-.3-.05-.53-.16-.71-.11-.17-.25-.31-.43-.4-.17-.09-.37-.15-.59-.17-.22-.02-.44-.03-.67-.02v-.93c.19.01.38 0 .57-.04.19-.03.36-.1.51-.19.14-.09.26-.22.35-.38.09-.16.14-.36.14-.59 0-.33-.1-.59-.31-.79-.2-.2-.47-.3-.79-.3-.21 0-.38.04-.53.13-.15.09-.27.21-.37.36-.1.15-.17.32-.22.51-.05.19-.07.38-.06.58h-1.15c.01-.38.08-.72.19-1.04.11-.32.27-.6.47-.83.19-.23.44-.42.72-.55.28-.13.6-.2.96-.2.28 0 .55.04.82.13.27.08.51.21.72.38.21.17.38.38.51.64s.19.56.19.9c0 .39-.08.73-.24 1.02-.16.29-.42.5-.76.63v.02z"],"header-two":["M13.17 13.93c-.17.15-.33.29-.46.44-.13.16-.22.32-.27.49h3.55V16H11c.01-.65.16-1.22.44-1.71s.67-.91 1.17-1.27c.24-.18.49-.36.75-.54.25-.18.49-.36.71-.57.21-.2.39-.42.53-.65.14-.24.21-.51.22-.82 0-.14-.02-.29-.05-.45-.03-.16-.09-.31-.18-.45a1.13 1.13 0 00-.37-.35c-.16-.09-.37-.14-.63-.14-.24 0-.43.05-.59.15-.16.1-.29.24-.38.42-.1.17-.17.38-.21.62-.05.24-.07.5-.08.77h-1.19c0-.43.05-.83.16-1.2s.27-.69.49-.96c.21-.25.48-.46.79-.62.31-.15.67-.23 1.07-.23.45 0 .82.08 1.11.23.3.16.55.36.73.6.19.24.32.5.39.79.08.28.12.54.12.79 0 .31-.04.6-.13.85s-.22.49-.37.7c-.15.21-.32.41-.52.59s-.4.35-.61.51l-.63.45c-.21.14-.39.28-.57.42zM0 1c0-.55.44-1 1-1 .55 0 1 .46 1 1v10c0 .55-.44 1-1 1-.55 0-1-.46-1-1V1zm6 0c0-.55.44-1 1-1 .55 0 1 .46 1 1v10c0 .55-.44 1-1 1-.55 0-1-.46-1-1V1zM2 5h4v2H2V5z"],headset:["M14.85 6.34C14.18 2.72 11.37 0 8 0S1.82 2.72 1.15 6.34C.47 6.9 0 8.1 0 9.5 0 11.43.9 13 2 13c0 1.1.9 2 2 2h2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1H4c-.55 0-1-.45-1-1 .55 0 1-.45 1-1V7c0-.45-.3-.81-.71-.94C3.97 3.7 5.81 2 8 2s4.03 1.7 4.71 4.06c-.41.13-.71.49-.71.94v5c0 .55.45 1 1 1h1c1.1 0 2-1.57 2-3.5 0-1.4-.47-2.6-1.15-3.16z"],heart:["M16 5.095c0-2.255-1.88-4.083-4.2-4.083-1.682 0-3.13.964-3.8 2.352a4.206 4.206 0 00-3.8-2.352C1.88 1.012 0 2.84 0 5.095c0 .066.007.13.01.194H.004c.001.047.01.096.014.143l.013.142c.07.8.321 1.663.824 2.573C2.073 10.354 4.232 12.018 8 15c3.767-2.982 5.926-4.647 7.144-6.854.501-.905.752-1.766.823-2.562.007-.055.012-.11.016-.164.003-.043.012-.088.013-.13h-.006c.003-.066.01-.13.01-.195z"],"heart-broken":["M7.71 8.87L6.17 6.55l.02-.01A.906.906 0 016 6c0-.07.03-.13.04-.19h-.02l.78-3.92C6.09 1.34 5.19 1 4.2 1 1.88 1 0 2.83 0 5.09c0 .07.01.13.01.19H0c0 .05.01.1.01.14 0 .05.01.1.01.14.07.8.32 1.66.82 2.57 1.07 1.94 2.88 3.47 5.86 5.84l-.68-2.74h.02C6.03 11.16 6 11.08 6 11c0-.28.11-.53.29-.71l1.42-1.42zM16 5.09C16 2.83 14.12 1 11.8 1c-1.2 0-2.27.5-3.04 1.28l-.7 3.51 1.77 2.66-.01.01c.1.15.18.33.18.54 0 .28-.11.53-.29.71l-1.6 1.6.75 3.01c3.23-2.56 5.16-4.15 6.28-6.18.5-.91.75-1.77.82-2.56.01-.05.01-.11.02-.16 0-.04.01-.09.01-.13h-.01c.01-.07.02-.14.02-.2z"],"heat-grid":["M0 10h5V7H0v3zm1-2h3v1H1V8zm14-5h-4v3h5V4c0-.55-.45-1-1-1zm0 2h-3V4h3v1zM0 4v2h5V3H1c-.55 0-1 .45-1 1zm0 9c0 .55.45 1 1 1h4v-3H0v2zm6-7h4V3H6v3zm0 8h4v-3H6v3zm1-2h2v1H7v-1zm4 2h4c.55 0 1-.45 1-1v-2h-5v3zm0-4h5V7h-5v3zm-5 0h4V7H6v3z"],heatmap:["M2 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm11-7c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm3 4.5A2.5 2.5 0 0013.5 6c-.98 0-1.82.57-2.23 1.39-.6-.78-1.51-1.3-2.56-1.36.18-.49.29-.99.29-1.53C9 2.01 6.99 0 4.5 0S0 2.01 0 4.5 2.01 9 4.5 9c.19 0 .37-.03.56-.06-.03.19-.06.37-.06.56C5 11.43 6.57 13 8.5 13c1.63 0 2.98-1.11 3.37-2.62.44.38 1 .62 1.63.62A2.5 2.5 0 0016 8.5zM14.5 13c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],helicopter:["M.5 2a.5.5 0 01.5.5V4h7V3H2.5a.5.5 0 010-1h13a.5.5 0 010 1H10v1h1c2.26 0 4 1.79 4 4 0 1.87-1.247 3.44-3 3.878V13h.382l1.894-.947a.5.5 0 11.448.894L12.618 14H4.5a.5.5 0 010-1H7v-2.306C5.749 9.736 5 8.368 5 7L1 6v1.5a.5.5 0 01-1 0v-5A.5.5 0 01.5 2zM8 11.316V13h3v-1a6.73 6.73 0 01-3-.684zM11 5v3h3a3 3 0 00-3-3z"],help:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm1 13H7v-2h2v2zm1.93-6.52c-.14.32-.35.64-.62.97L9.25 8.83c-.12.15-.24.29-.28.42-.04.13-.09.3-.09.52V10H7.12V8.88s.05-.51.21-.71L8.4 6.73c.22-.26.35-.49.44-.68.09-.19.12-.38.12-.58 0-.3-.1-.55-.28-.75-.18-.19-.44-.28-.76-.28-.33 0-.59.1-.78.29-.19.19-.33.46-.4.81-.03.11-.1.15-.2.14l-1.7-.25c-.12-.01-.16-.08-.14-.19.12-.82.46-1.47 1.03-1.94.57-.48 1.32-.72 2.25-.72.47 0 .9.07 1.29.22s.72.34 1 .59c.28.25.49.55.65.89.15.35.22.72.22 1.12s-.07.75-.21 1.08z"],"helper-management":["M13 5h-2v2h2V5zm0 6h-2v2h2v-2zm0-3h-2v2h2V8zm2-8H1C.4 0 0 .4 0 1v14c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1zm-1 14H2V2h12v12zm-7-3H5v2h2v-2zm3 0H8v2h2v-2z"],"high-priority":["M9 14v2H7v-2h2zm1-14L9 12H7L6 0h4z"],highlight:["M9.12 11.07l2-2.02.71.71 4-4.04L10.17 0l-4 4.04.71.71-2 2.02 4.24 4.3zM2 12.97h4c.28 0 .53-.11.71-.3l1-1.01-3.42-3.45-3 3.03c-.18.18-.29.44-.29.72 0 .55.45 1.01 1 1.01zm13 1.01H1c-.55 0-1 .45-1 1.01S.45 16 1 16h14c.55 0 1-.45 1-1.01s-.45-1.01-1-1.01z"],history:["M8 3c-.55 0-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L9 7.59V4c0-.55-.45-1-1-1zm0-3a7.95 7.95 0 00-6 2.74V1c0-.55-.45-1-1-1S0 .45 0 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.54C4.64 2.78 6.23 2 8 2c3.31 0 6 2.69 6 6 0 2.61-1.67 4.81-4 5.63v-.01c-.63.23-1.29.38-2 .38-3.31 0-6-2.69-6-6 0-.55-.45-1-1-1s-1 .45-1 1c0 4.42 3.58 8 8 8 .34 0 .67-.03 1-.07.02 0 .04-.01.06-.01C12.98 15.4 16 12.06 16 8c0-4.42-3.58-8-8-8z"],home:["M2 10v5c0 .55.45 1 1 1h3v-5h4v5h3c.55 0 1-.45 1-1v-5L8 4l-6 6zm13.71-2.71L14 5.59V2c0-.55-.45-1-1-1s-1 .45-1 1v1.59L8.71.29C8.53.11 8.28 0 8 0s-.53.11-.71.29l-7 7a1.003 1.003 0 001.42 1.42L8 2.41l6.29 6.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"horizontal-bar-chart":["M4 5h7c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zM1 1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1zm14 6H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-6 5H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1z"],"horizontal-bar-chart-asc":["M1 3h5c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 4h7c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 6H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 11h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"horizontal-bar-chart-desc":["M15 1H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM8 9H1c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm-2 4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm5-8H1c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"horizontal-distribution":["M2 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm13 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-5 2H7c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],hurricane:["M3.5 12c-.86 0-2.5-.5-3.5-1 1 3.5 4.506 4 7 4a7 7 0 007-7l-.006-.004a5.974 5.974 0 00-1.29-3.988c.896.066 2.37.53 3.296.992-1-3.5-4.506-4-7-4a6.998 6.998 0 00-6.14 3.635 5.972 5.972 0 00-.859 3.226L2 8l.006.005a5.98 5.98 0 001.771 3.99A7.469 7.469 0 013.5 12zM8 6a2 2 0 100 4 2 2 0 000-4z","M0 0h16v16H0z"],"id-number":["M2 5v7h12V5H2zm0-2h12c1.1 0 2 .9 2 2v7c0 1.1-.9 2-2 2H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2z","M7.9 10.48c-.14-.33-.84-.55-1.3-.75-.46-.2-.4-.33-.42-.5v-.07c.16-.14.29-.33.37-.56 0 0 0-.01.01-.02.02-.05.03-.1.05-.15.1-.01.16-.13.19-.23.03-.04.07-.15.06-.27-.02-.16-.08-.24-.15-.26v-.03c0-.2-.02-.48-.05-.67-.01-.05-.02-.1-.03-.16-.07-.23-.21-.44-.4-.58-.2-.15-.48-.23-.73-.23s-.53.08-.72.23c-.19.14-.33.35-.4.58-.02.05-.03.1-.03.16-.05.18-.06.47-.06.67v.03c-.07.03-.14.1-.15.26-.02.12.03.22.06.27.02.1.09.22.2.24.01.05.03.1.05.15v.01c.08.23.22.42.38.56v.07c-.02.17.03.29-.43.5-.46.2-1.16.42-1.3.75s-.09.52-.09.52H8c-.01 0 .05-.19-.1-.52zM10 6h2c.55 0 1 .45 1 1s-.45 1-1 1h-2c-.55 0-1-.45-1-1s.45-1 1-1zM10 9h2c.55 0 1 .45 1 1s-.45 1-1 1h-2c-.55 0-1-.45-1-1s.45-1 1-1z"],"image-rotate-left":["M13 2h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C8.11 2.47 8 2.72 8 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H13c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3zm-5.5 9c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 6.33L7 12l-1 1-2-3-2 2.67V9h7v4.33z"],"image-rotate-right":["M5.71 5.71l2-2C7.89 3.53 8 3.28 8 3c0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H3C1.34 2 0 3.34 0 5v3c0 .55.45 1 1 1s1-.45 1-1V5c0-.55.45-1 1-1h1.59l-.3.29a1.003 1.003 0 001.42 1.42zM12.5 11c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM15 7H6c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 6.33L12 12l-1 1-2-3-2 2.67V9h7v4.33z"],import:["M7.29 11.71c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L9 8.59V1c0-.55-.45-1-1-1S7 .45 7 1v7.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l4 4zM15 11c-.55 0-1 .45-1 1v2H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],inbox:["M13.91 2.6c-.16-.36-.51-.61-.92-.61h-10c-.41 0-.77.25-.92.61L-.01 7.45v5.54c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7.45L13.91 2.6zm-1.92 5.39c-.55 0-1 .45-1 1v1h-6v-1c0-.55-.45-1-1-1H1.94l1.71-4h8.68l1.71 4h-2.05z"],"inbox-filtered":["M6.432 2c.094.14.202.273.324.394L8.42 4H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6.557c.693 0 1.363-.262 1.837-.736l.103-.102.85-1.14a2.564 2.564 0 00.623-1.682V5.058L16 7.46V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h3.432zm9.048-2c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V3.71L8.17.98A.566.566 0 018 .57c0-.31.26-.57.57-.57h6.91z"],"inbox-geo":["M6.341 2A5.99 5.99 0 006 4H3.66L1.95 8H4c.55 0 1 .45 1 1v1h7a5.978 5.978 0 004-1.528V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h3.341zm3.679 2.145c0-.125.075-.23.205-.225h.345l.79.8c.005 0 0 .005 0 .005v.295c0 .13-.085.23-.215.23h-.07v.15c0 .13-.09.2-.215.2v.535c0 .125-.12.225-.245.225s-.245-.1-.245-.225V5.25h-.145c-.125 0-.205-.1-.205-.23v-.875zm2.235-2.195c-.03 0-.055-.005-.06-.035 0-.03.03-.035.06-.035h.11c.035 0 .06.005.06.035 0 .03-.03.035-.06.035h-.11zm-1.165-.025a.094.094 0 01-.13 0l-.25-.25a.094.094 0 010-.13.094.094 0 01.13 0l.25.25a.094.094 0 010 .13zm1.53.445c-.035 0-.07-.025-.07-.06v-.155c0-.03.035-.06.07-.06s.07.025.07.06v.155c0 .03-.035.06-.07.06zM12 0c2.21 0 4 1.79 4 4s-1.79 4-4 4-4-1.79-4-4 1.79-4 4-4zm0 7c1.655 0 3-1.345 3-3 0-.195-.02-.39-.06-.575h-.21c-.125 0-.225-.07-.23-.21h-.215c.075.07.155.14.155.23V3.9c0 .06-.04.115-.075.155h-.015l-.01.005-.015.01-.445.43v.815c0 .13-.07.22-.2.22h-.36c-.125 0-.21-.09-.21-.22v-.84a.627.627 0 00-.36-.345h-.45c-.13 0-.245-.095-.245-.225v-.46c0-.125.115-.23.245-.23l.13-.005.21-.215c.09-.09.24-.09.33 0l.22.225h.47c.105 0 .155-.105.225-.21v-.075h-.205a.106.106 0 01-.105-.105.11.11 0 01.105-.105h.18l.025.005v-.12s-.03-.025-.04-.025h-.2l-.045.05a.235.235 0 01-.33.005l-.045-.06h-.115l.16.175c.015.015.015.06 0 .075-.02.015-.045.02-.06.005l-.195-.185h-.085l-.245.23-.02-.005c-.025.07-.06.055-.095.055-.085 0-.15-.045-.15-.13s.065-.14.15-.14h.115v-.125c0-.06.04-.09.1-.09h.05V2.36c0-.095.095-.2.19-.2h.19c.105 0 .18-.075.18-.185V1.94c0-.015.035.01.035-.06h-.125l-.005.01-.21.22a.085.085 0 01-.115 0 .085.085 0 010-.115l.255-.255c.02-.015.045-.015.065-.015.005 0 .005.015.005.015h.64a2.327 2.327 0 00-.355-.275 2.452 2.452 0 00-.355-.195c-.03-.015-.055-.03-.08-.04a3.025 3.025 0 00-1.735-.175c-.09.02-.175.055-.265.08-.09.03-.18.05-.265.085-.075.03-.145.07-.22.105-.115.06-.235.115-.34.185l-.005.005c-.1.065-.18.145-.27.22h.455c.06 0 .11.045.11.105s-.05.105-.11.105h-.32c0 .07-.025.04-.025.045v.24h.285l.15-.17c.09-.09.235-.105.325-.015.09.09.09.23 0 .32l-.795.79-.01.01c-.005 0-.005 0-.01.005l-.025.015h-.01a.235.235 0 01-.12.025h-.23c-.08.07-.125.1-.125.18v.06c0 .01-.02.02-.02.03l.375.39c.04.04.04.1 0 .14-.04.04-.1.04-.14 0l-.39-.385a.213.213 0 01-.055.01c-.105 0-.195-.085-.195-.185v-.235h-.055A3.1 3.1 0 009 4c0 1.655 1.345 3 3 3zm2.27-2.135c.05 0 .105.04.105.09v.285c0 .05-.055.09-.105.09-.05 0-.105-.04-.105-.09v-.285c0-.05.055-.09.105-.09zm-2.085-3.27c0 .13-.105.21-.225.21h-.25v.07c0 .075-.03.135-.105.135s-.105-.06-.105-.135V1.64c-.075-.02-.025-.025-.025-.04 0-.125.085-.215.21-.215h.27c.13 0 .23.085.23.21z"],"inbox-search":["M5.639 2a5.391 5.391 0 00-.144 2H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6V9c0-.088.012-.174.033-.255.12-.007.238-.019.39-.038.154-.008.252-.03.442-.077a5.34 5.34 0 00.24-.05h.05l.122-.04 1.266 1.271c.425.47 1.116.769 1.847.769.21 0 .414-.025.61-.071V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h2.639zM15.82 7.53c.1.12.17.27.18.44 0 .34-.27.61-.61.61a.57.57 0 01-.43-.18l-2.24-2.25c-.13.08-.26.16-.4.23-.02.01-.05.02-.07.03-.14.06-.27.12-.42.17h-.01c-.14.05-.29.08-.44.11-.04.01-.08.02-.11.02-.15.02-.3.04-.46.04-1.85 0-3.35-1.51-3.35-3.37S8.96.01 10.81 0c1.85 0 3.35 1.51 3.35 3.37 0 .16-.02.31-.04.47-.01.04-.01.07-.02.11-.02.15-.05.29-.1.44v.01c-.05.15-.11.28-.17.42-.01.02-.02.05-.03.07-.07.14-.14.27-.23.4l2.25 2.24zm-5.01-1.94c1.22 0 2.21-.99 2.21-2.22 0-1.23-.99-2.22-2.21-2.22S8.6 2.14 8.6 3.37c0 1.22.99 2.22 2.21 2.22z"],"inbox-update":["M8.1 2a5.023 5.023 0 000 2H3.66L1.95 8H4c.55 0 1 .45 1 1v1h6V9c0-.55.45-1 1-1h2.05c.708 0 1.352-.241 1.905-.645L16 7.46V13c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V7.46l2.08-4.85C2.23 2.25 2.59 2 3 2h5.1zM13 6a3 3 0 110-6 3 3 0 010 6z"],"info-sign":["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM7 3h2v2H7V3zm3 10H6v-1h1V7H6V6h3v6h1v1z"],inheritance:["M5 8c0 1.66 1.34 3 3 3h4.59L11.3 9.71A.965.965 0 0111 9a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42l1.3-1.29H8c-2.76 0-5-2.24-5-5H1a1 1 0 01-1-1V1a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5zM2 2v4h4V2H2z"],"inherited-group":["M1 7c.51 0 .935.388.993.884L2 8v3c0 .51.388.935.884.993L3 12h1.59l-.3-.29a1.003 1.003 0 011.324-1.504l.096.084 2 2c.18.18.29.43.29.71 0 .233-.076.446-.206.614l-.084.096-2 2A1.003 1.003 0 014 15c0-.24.08-.458.224-.629l.076-.081.29-.29H3a2.996 2.996 0 01-2.995-2.823L0 11V8c0-.55.45-1 1-1zm5.388-7c.629 0 1.338.21 1.838.6.48.38.85.91 1.019 1.52.04.13.07.27.09.4.09.48.14 1.22.14 1.73v.07c.18.08.34.27.37.67.03.32-.09.59-.16.71-.06.28-.21.58-.48.63-.03.13-.07.26-.12.39 0 .01-.01.04-.01.04-.22.58-.55 1.08-.949 1.45v.18c.04.45-.12.77 1.059 1.3 1.179.53 2.947 1.09 3.307 1.95.37.86.22 1.36.22 1.36H9c0-.539-.21-1.045-.583-1.417l-2-2A1.997 1.997 0 005 9c-.149 0-.296-.015-.442-.045.099-.19.082-.37.101-.575 0-.05.01-.11.01-.17-.41-.35-.75-.86-.969-1.45v-.01s-.01-.01-.01-.02c-.04-.12-.09-.26-.12-.39-.28-.05-.44-.36-.5-.64-.06-.12-.19-.39-.16-.71.04-.41.21-.6.39-.68v-.06c0-.51.05-1.26.14-1.74.02-.13.05-.27.09-.4.17-.6.54-1.13 1.02-1.51C5.048.21 5.757 0 6.387 0zm4.625 2.04c.49 0 1.05.16 1.439.46.38.29.67.7.8 1.17.03.1.05.21.07.31.07.37.11.94.11 1.33v.05c.139.06.269.21.289.51.02.25-.07.45-.13.54-.05.21-.16.44-.38.48a1.711 1.711 0 01-.1.33c-.17.44-.43.83-.749 1.11v.14c.03.35-.09.59.83 1 .929.41 2.317.84 2.597 1.5.29.66.17 1.04.17 1.04H13.66v.01c-.05-.24-.14-.5-.25-.76-.36-.86-1.119-1.33-2.687-2-.14-.06-.59-.25-.6-.25-.21-.09-.36-.15-.5-.22.02-.1.02-.2.03-.31 0-.04.01-.08.01-.13-.07-.06-.13-.12-.19-.19.22-.32.4-.67.54-1.05.02-.06.02-.06.03-.1.29-.23.48-.57.59-.96.16-.33.25-.73.21-1.16-.03-.4-.16-.76-.37-1.03-.02-.53-.07-1.13-.15-1.54-.01-.06-.02-.12-.03-.19.23-.06.48-.09.72-.09z"],"inner-join":["M6.6 3.3C5.3 4.4 4.5 6.1 4.5 8s.8 3.6 2.1 4.7c-.5.2-1 .3-1.6.3-2.8 0-5-2.2-5-5s2.2-5 5-5c.6 0 1.1.1 1.6.3zm-1.96 8.68C3.92 10.83 3.5 9.46 3.5 8s.42-2.83 1.14-3.98C2.6 4.2 1 5.91 1 8s1.6 3.8 3.64 3.98zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3zm.35 1.02c.73 1.15 1.14 2.52 1.14 3.98s-.42 2.83-1.14 3.98c2.04-.18 3.64-1.9 3.64-3.98s-1.6-3.8-3.64-3.98z"],insert:["M5 9h2v2c0 .6.4 1 1 1s1-.4 1-1V9h2c.6 0 1-.4 1-1s-.4-1-1-1H9V5c0-.6-.4-1-1-1s-1 .4-1 1v2H5c-.6 0-1 .4-1 1s.4 1 1 1zm10-9H1C.4 0 0 .4 0 1v14c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1zm-1 14H2V2h12v12z"],intersection:["M10 3c-.92 0-1.76.26-2.5.69C6.76 3.26 5.92 3 5 3 2.24 3 0 5.24 0 8s2.24 5 5 5c.92 0 1.76-.26 2.5-.69.74.43 1.58.69 2.5.69 2.76 0 5-2.24 5-5s-2.24-5-5-5zm-4.1 7.85c-.29.09-.59.15-.9.15-1.66 0-3-1.34-3-3s1.34-3 3-3c.31 0 .61.06.9.15C5.33 5.96 5 6.94 5 8s.33 2.04.9 2.85zM10 11c-.31 0-.61-.06-.9-.15.57-.81.9-1.79.9-2.85s-.33-2.04-.9-2.85c.29-.09.59-.15.9-.15 1.66 0 3 1.34 3 3s-1.34 3-3 3z"],"ip-address":["M5 2.66C5 4.14 8 8 8 8s3-3.86 3-5.34C10.99 1.2 9.66 0 8 0S5 1.2 5 2.66zM7 3c0-.55.45-1 1-1s1 .45 1 1-.45 1-1 1-1-.45-1-1zM10.5 10H8v5h1v-4h1v1H9v1h2v-3h-.5zM2 9h12c.55 0 1 .45 1 1v5c0 .55-.45 1-1 1H2c-.55 0-1-.45-1-1v-5c0-.55.45-1 1-1zm4 1v5h1v-5H6z"],issue:["M8 16A8 8 0 118 0a8 8 0 010 16zm0-2A6 6 0 108 2a6 6 0 000 12zm1-2H7v-2h2v2zm0-3H7V4h2v5z"],"issue-closed":["M9.296.104a2.99 2.99 0 00-1.003.664 2.987 2.987 0 00-.75 1.25 6 6 0 106.28 4.527c.043-.039.085-.079.127-.12l1.456-1.456A8 8 0 119.296.105zm2.532 5.2a.997.997 0 01-.707-.294L9.707 3.596a1 1 0 011.414-1.414l.707.707 1.768-1.768a1 1 0 111.414 1.415L12.536 5.01a.997.997 0 01-.708.293zM9 12H7v-2h2v2zm0-3H7V4h2v5z"],"issue-new":["M10.568.421c-.01.04-.018.08-.026.121-.837.156-1.53.73-1.85 1.497a6 6 0 105.27 5.273 2.51 2.51 0 001.496-1.854c.04-.008.081-.016.121-.026A8 8 0 1110.568.421zM9 12H7v-2h2v2zm0-3H7V4h2v5zm1-6c0-.55.45-1 1-1h1V1c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1h-1v1.005c0 .55-.45 1-1 1s-1-.45-1-1V4h-1c-.55 0-1-.45-1-1z"],italic:["M9.8 4H11c.5 0 1-.4 1-1s-.4-1-1-1H7c-.5 0-1 .4-1 1s.4 1 1 1h.8l-1.6 8H5c-.5 0-1 .4-1 1s.4 1 1 1h4c.5 0 1-.4 1-1s-.4-1-1-1h-.8l1.6-8z"],"join-table":["M15 5h-3V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h3v3c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-5-1v2H6V4h4zm0 6H6V7h4v3zM2 4h3v2H2V4zm0 5V7h3v2H2zm4 4v-2h4v2H6zm8 0h-3v-2h3v2zm0-3h-3V8h3v2z"],key:["M11 0C8.24 0 6 2.24 6 5c0 1.02.31 1.96.83 2.75L.29 14.29a1.003 1.003 0 001.42 1.42L3 14.41l1.29 1.29c.18.19.43.3.71.3s.53-.11.71-.29l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71L6.41 11l1.83-1.83c.8.52 1.74.83 2.76.83 2.76 0 5-2.24 5-5s-2.24-5-5-5zm0 8c-.23 0-.45-.03-.66-.08-.01 0-.02-.01-.03-.01-.21-.05-.41-.12-.6-.21a3.014 3.014 0 01-1.62-2c0-.01-.01-.02-.01-.03C8.03 5.45 8 5.23 8 5c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3z"],"key-backspace":["M15 2H6c-.28 0-.53.11-.71.29l-5 5C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l5 5c.18.18.43.29.71.29h9c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-2.29 7.29a1.003 1.003 0 01-1.42 1.42L10 9.41 8.71 10.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L8.59 8l-1.3-1.29a1.003 1.003 0 011.42-1.42L10 6.59l1.29-1.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L11.41 8l1.3 1.29z"],"key-command":["M12 9h-1V7h1c1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3v1H7V4c0-1.66-1.34-3-3-3S1 2.34 1 4s1.34 3 3 3h1v2H4c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3v-1h2v1c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3zm0-6c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM4 13c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm0-8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm5 4H7V7h2v2zm3 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"key-control":["M12.71 5.29l-4-4C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L8 3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"key-delete":["M15.71 7.29l-5-5A.997.997 0 0010 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h9c.28 0 .53-.11.71-.29l5-5c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zm-7 2a1.003 1.003 0 01-1.42 1.42L6 9.41 4.71 10.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L4.59 8l-1.3-1.29a1.003 1.003 0 011.42-1.42L6 6.59 7.29 5.3c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L7.41 8l1.3 1.29z"],"key-enter":["M14 2c-.55 0-1 .45-1 1v3c0 1.66-1.34 3-3 3H4.41L5.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L4.41 11H10c2.76 0 5-2.24 5-5V3c0-.55-.45-1-1-1z"],"key-escape":["M2 7c.55 0 1-.45 1-1V4.41L7.29 8.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 3H6c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm7-5.9v2A5 5 0 113.1 9h-2c.49 3.39 3.38 6 6.9 6 3.87 0 7-3.13 7-7 0-3.52-2.61-6.41-6-6.9z"],"key-option":["M11 4h4c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1s.45 1 1 1zm4 8h-3.43L5.86 2.49h-.02A.975.975 0 005 2H1c-.55 0-1 .45-1 1s.45 1 1 1h3.43l5.71 9.51.01-.01c.18.3.49.5.85.5h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"key-shift":["M13.71 7.29l-5-5C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-5 5A1.003 1.003 0 003 9h2v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V9h2a1.003 1.003 0 00.71-1.71z"],"key-tab":["M15 10H4.41L5.7 8.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L2 9.59V8c0-.55-.45-1-1-1s-1 .45-1 1v6c0 .55.45 1 1 1s1-.45 1-1v-1.59l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 12H15c.55 0 1-.45 1-1s-.45-1-1-1zm0-9c-.55 0-1 .45-1 1v1.59L11.71 1.3A.965.965 0 0011 1a1.003 1.003 0 00-.71 1.71L11.59 4H1c-.55 0-1 .45-1 1s.45 1 1 1h10.59L10.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L14 6.41V8c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"known-vehicle":["M15 3a.997.997 0 00-.707.293L12 5.586l-1.293-1.293a1 1 0 10-1.414 1.414l2 2a.997.997 0 001.414 0l3-3A1 1 0 0015 3zm-.879 6.121l-.007-.007c-.313.309-.69.552-1.114.702V10h-.998H12h-1v-.184c-.424-.15-.8-.395-1.112-.704l-.01.01-2-2 .012-.012A2.978 2.978 0 017.184 6H3c-.176 0-.06-.824 0-1l.73-1.63C3.79 3.192 3.823 3 4 3H7.78C8.328 2.39 9.115 2 10 2c.768 0 1.461.293 1.987.77l.844-.844c-.238-.244-.524-.442-.794-.524C12.037 1.402 10.72 1 8 1c-2.72 0-4.037.402-4.037.402-.508.155-1.078.711-1.268 1.237l-.763 2.117H.88c-.484 0-.88.423-.88.939s.396.939.88.939h.375L1 7c-.034.685 0 1.436 0 2v5c0 .657.384 1 1 1s1-.343 1-1v-1h10v1c0 .657.384 1 1 1s1-.343 1-1V9l-.003-.754-.876.875zM5.001 10H3V8h2v2z"],"lab-test":["M11 1a1 1 0 010 2v3l3 7v1.25a.75.75 0 01-.75.75H2.75a.75.75 0 01-.75-.75V13l3-7V3a1 1 0 110-2h6zM9 3H7v3l-1.714 4h5.428L9 6V3z"],label:["M11 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7l-5-5zm3 10H2V4h8v2H3v1h7v1h4v4zm-3-5V4l3 3h-3zm-8 3h10V9H3v1z"],layer:["M16 8c0-.37-.21-.68-.51-.85l.01-.01-7-4-.01.01C8.34 3.06 8.18 3 8 3s-.34.06-.49.15l-.01-.02-7 4 .01.01C.21 7.32 0 7.63 0 8s.21.68.51.85l-.01.01 7 4 .01-.01c.15.09.31.15.49.15s.34-.06.49-.15l.01.01 7-4-.01-.01c.3-.17.51-.48.51-.85z"],"layer-outline":["M7.504 3.132l-7 4a1 1 0 000 1.736l7 4a1 1 0 00.992 0l7-4a1 1 0 000-1.736l-7-4a1 1 0 00-.992 0zM8 5.152L12.983 8 8 10.847 3.016 8 8 5.152z"],layers:["M.55 4.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5a.998.998 0 00-.06-1.81L8.4.08a1.006 1.006 0 00-.79 0l-6.99 3a.992.992 0 00-.07 1.81zM15 10c-.16 0-.31.04-.45.11L8 13.38 1.45 10.1c-.14-.06-.29-.1-.45-.1-.55 0-1 .45-1 1 0 .39.23.73.55.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5c.32-.16.55-.5.55-.89 0-.55-.45-1-1-1zm0-3.5c-.16 0-.31.04-.45.11L8 9.88 1.45 6.61A.997.997 0 001 6.5c-.55 0-1 .45-1 1 0 .39.23.73.55.89l7 3.5c.14.07.29.11.45.11s.31-.04.45-.11l7-3.5c.32-.16.55-.5.55-.89 0-.55-.45-1-1-1z"],layout:["M14 4c-1.1 0-2 .9-2 2 0 .47.17.9.44 1.24l-.68.91A1.996 1.996 0 009.07 9.5H7.93C7.71 8.64 6.93 8 6 8c-.47 0-.9.17-1.24.44l-.91-.68c.1-.23.15-.49.15-.76 0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .37.11.71.28 1.01L3.01 5.28C2.71 5.11 2.37 5 2 5 .9 5 0 5.9 0 7s.9 2 2 2c.47 0 .9-.17 1.24-.44l.91.68c-.1.23-.15.49-.15.76 0 .37.11.71.28 1.01l-1.27 1.27C2.71 12.11 2.37 12 2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.37-.11-.71-.28-1.01l1.27-1.27c.3.17.64.28 1.01.28.93 0 1.71-.64 1.93-1.5h1.14c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2 0-.47-.17-.9-.44-1.24l.68-.91c.23.1.49.15.76.15 1.1 0 2-.9 2-2s-.9-2-2-2z"],"layout-auto":["M14 9.5c-.56 0-1.06.23-1.42.59L8.99 8l3.59-2.09A2.002 2.002 0 0016 4.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .19.03.37.08.54L8.5 7.13v-3.2c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v3.2L3.92 5.04c.05-.17.08-.35.08-.54 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.56 0 1.06-.23 1.42-.59L7.01 8l-3.59 2.09A2.002 2.002 0 000 11.5c0 1.1.9 2 2 2s2-.9 2-2c0-.19-.03-.37-.08-.54L7.5 8.87v3.2c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-3.2l3.58 2.09c-.05.17-.08.35-.08.54 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-balloon":["M14 11c-.2 0-.38.04-.56.09L12.42 9.4c.36-.36.58-.85.58-1.4 0-.55-.22-1.04-.58-1.4l1.01-1.69c.19.05.37.09.57.09 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .55.22 1.04.58 1.4l-1.01 1.69C11.38 6.04 11.2 6 11 6c-.93 0-1.71.64-1.93 1.5H6.93C6.71 6.64 5.93 6 5 6c-.2 0-.38.04-.56.09L3.42 4.4C3.78 4.04 4 3.55 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.2 0 .38-.04.56-.09L3.58 6.6C3.22 6.96 3 7.45 3 8c0 .55.22 1.04.58 1.4l-1.01 1.69C2.38 11.04 2.2 11 2 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.55-.22-1.04-.58-1.4l1.01-1.69c.19.05.37.09.57.09.93 0 1.71-.64 1.93-1.5h2.14c.22.86 1 1.5 1.93 1.5.2 0 .38-.04.56-.09l1.01 1.69c-.35.36-.57.85-.57 1.4 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-circle":["M14.16 6.02c-.12-.36-.26-.7-.43-1.03.17-.29.27-.63.27-.99 0-1.1-.9-2-2-2-.36 0-.7.1-.99.27-.33-.17-.67-.31-1.03-.43A1.987 1.987 0 008 0C6.95 0 6.1.81 6.02 1.84c-.36.12-.7.26-1.03.43C4.7 2.1 4.36 2 4 2c-1.1 0-2 .9-2 2 0 .36.1.7.27.99-.17.33-.31.67-.43 1.03C.81 6.1 0 6.95 0 8c0 1.05.81 1.9 1.84 1.98.12.36.26.7.43 1.03-.17.29-.27.63-.27.99 0 1.1.9 2 2 2 .36 0 .7-.1.99-.27.33.17.67.32 1.03.43C6.1 15.19 6.95 16 8 16c1.05 0 1.9-.81 1.98-1.84.36-.12.7-.26 1.03-.43.29.17.63.27.99.27 1.1 0 2-.9 2-2 0-.36-.1-.7-.27-.99.17-.33.31-.67.43-1.03C15.19 9.9 16 9.05 16 8c0-1.05-.81-1.9-1.84-1.98zm-.99 3.79c-.05.16-.11.31-.17.46-.3-.17-.64-.27-1-.27-1.1 0-2 .9-2 2 0 .36.1.7.27 1-.15.07-.3.12-.46.17C9.5 12.48 8.81 12 8 12s-1.5.48-1.81 1.17c-.16-.06-.32-.11-.46-.17.17-.3.27-.64.27-1 0-1.1-.9-2-2-2-.36 0-.7.1-1 .27-.07-.15-.12-.3-.17-.46C3.52 9.5 4 8.81 4 8s-.48-1.5-1.17-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 2 2 2-.9 2-2-.9-2-2-2z"],"layout-hierarchy":["M14.5 12.07V9.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2-.93 0-1.71.64-1.93 1.5H9.93c-.18-.7-.73-1.25-1.43-1.43V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v2.14c-.7.18-1.25.73-1.43 1.43H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8c0 .93.64 1.71 1.5 1.93v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93V9.93c.7-.18 1.25-.73 1.43-1.43h2.14c.18.7.73 1.25 1.43 1.43v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93V9.93c.7-.18 1.25-.73 1.43-1.43h2.14c.18.7.73 1.25 1.43 1.43v2.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93z"],"layout-linear":["M14 6c-.93 0-1.71.64-1.93 1.5H9.93C9.71 6.64 8.93 6 8 6s-1.71.64-1.93 1.5H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.93 0 1.71-.64 1.93-1.5h2.13C6.29 9.36 7.07 10 8 10s1.71-.64 1.93-1.5h2.13c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2C16 6.9 15.1 6 14 6z"],"layout-skew-grid":["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12-2c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6-3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM8 3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],"layout-sorted-clusters":["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM8 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],learning:["M8.441 1.104a.985.985 0 00-.882 0L.365 5c-.487.253-.487.747 0 1L7.56 9.896a.985.985 0 00.882 0L15.635 6c.487-.253.487-.747 0-1L8.44 1.104z","M14 5.5l.016 4.514c.002.548.447.99.994.99a.99.99 0 00.99-.99V5.5h-2zM3.371 9.047l4.387 2.432a.5.5 0 00.485 0l4.39-2.432a.25.25 0 01.371.218v2.955a.25.25 0 01-.134.222l-4.635 2.436a.5.5 0 01-.466 0l-4.635-2.436A.25.25 0 013 12.22V9.265a.25.25 0 01.371-.218z"],"left-join":["M6.6 3.3C6.1 3.1 5.6 3 5 3 2.2 3 0 5.2 0 8s2.2 5 5 5c.6 0 1.1-.1 1.6-.3C5.3 11.6 4.5 9.9 4.5 8s.8-3.6 2.1-4.7zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3zm.35 1.02c.73 1.15 1.14 2.52 1.14 3.98s-.42 2.83-1.14 3.98c2.04-.18 3.64-1.9 3.64-3.98s-1.6-3.8-3.64-3.98z"],"less-than":["M13.287 5.958a1 1 0 00-.574-1.916l-10 3c-.95.285-.95 1.631 0 1.916l10 3a1 1 0 00.574-1.916L6.48 8l6.807-2.042z"],"less-than-or-equal-to":["M13.287 3.958a1 1 0 00-.575-1.916l-10 3c-.95.285-.95 1.63 0 1.916l10 3a1 1 0 00.575-1.916L6.48 6l6.807-2.042zM13 12H3a1 1 0 000 2h10a1 1 0 000-2z"],lifesaver:["M9.405 11.746C8.968 11.91 8.495 12 8 12c-.494 0-.968-.09-1.405-.254l-.702 1.873C6.548 13.865 7.258 14 8 14c.742 0 1.452-.135 2.107-.38l-.702-1.874zm2.341-2.341l1.873.702C13.865 9.452 14 8.742 14 8c0-.742-.135-1.452-.38-2.107l-1.874.702c.164.437.254.91.254 1.405 0 .494-.09.968-.254 1.405zM9.405 4.254l.702-1.873A5.987 5.987 0 008 2c-.742 0-1.452.135-2.107.38l.702 1.874C7.032 4.09 7.505 4 8 4c.494 0 .968.09 1.405.254zM4.254 6.595L2.38 5.893A5.987 5.987 0 002 8c0 .742.135 1.452.38 2.107l1.874-.702A3.991 3.991 0 014 8c0-.494.09-.968.254-1.405zM8 16A8 8 0 118 0a8 8 0 010 16zm0-6a2 2 0 100-4 2 2 0 000 4z"],lightbulb:["M9.01 14h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1s-.44-1-1-1zm1-3h-4c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.44-1-1-1zm-2-11C5.26 0 3.03 1.95 3.03 4.35c0 2.37 1.63 2.64 1.94 5.22 0 .24.22.44.5.44h5.09c.28 0 .5-.19.5-.44C11.37 6.99 13 6.72 13 4.35 13 1.95 10.77 0 8.01 0z"],lightning:["M7 9H5a1 1 0 01-1-1L4.89.876A1 1 0 015.884 0h4.27a.847.847 0 01.793 1.144L9.125 6h2.05a.825.825 0 01.754 1.16L8.16 15.64A.606.606 0 017 15.394V9z"],link:["M4.99 11.99c.28 0 .53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42l-6 6a1.003 1.003 0 00.71 1.71zm3.85-2.02L6.4 12.41l-1 1-.01-.01c-.36.36-.85.6-1.4.6-1.1 0-2-.9-2-2 0-.55.24-1.04.6-1.4l-.01-.01 1-1 2.44-2.44c-.33-.1-.67-.16-1.03-.16-1.1 0-2.09.46-2.81 1.19l-.02-.02-1 1 .02.02c-.73.72-1.19 1.71-1.19 2.81 0 2.21 1.79 4 4 4 1.1 0 2.09-.46 2.81-1.19l.02.02 1-1-.02-.02c.73-.72 1.19-1.71 1.19-2.81 0-.35-.06-.69-.15-1.02zm7.15-5.98c0-2.21-1.79-4-4-4-1.1 0-2.09.46-2.81 1.19l-.02-.02-1 1 .02.02c-.72.72-1.19 1.71-1.19 2.81 0 .36.06.69.15 1.02l2.44-2.44 1-1 .01.01c.36-.36.85-.6 1.4-.6 1.1 0 2 .9 2 2 0 .55-.24 1.04-.6 1.4l.01.01-1 1-2.43 2.45c.33.09.67.15 1.02.15 1.1 0 2.09-.46 2.81-1.19l.02.02 1-1-.02-.02a3.92 3.92 0 001.19-2.81z"],list:["M1 3h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 10H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"list-columns":["M6 1c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1h5zm9-12c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5zm0 4c.55 0 1 .45 1 1s-.45 1-1 1h-5c-.55 0-1-.45-1-1s.45-1 1-1h5z"],"list-detail-view":["M6 9H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm9-12h-5c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM6 5H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1z"],locate:["M15 7h-.09A6.98 6.98 0 009 1.1V1c0-.55-.45-1-1-1S7 .45 7 1v.09A6.98 6.98 0 001.1 7H1c-.55 0-1 .45-1 1s.45 1 1 1h.1A6.969 6.969 0 007 14.91V15c0 .55.45 1 1 1s1-.45 1-1v-.09A6.98 6.98 0 0014.9 9h.1c.55 0 1-.45 1-1s-.45-1-1-1zm-6.02 5.9c-.05-.5-.46-.9-.98-.9s-.93.4-.98.9A5.017 5.017 0 013.1 8.98c.5-.05.9-.46.9-.98s-.4-.93-.9-.98A5.017 5.017 0 017.02 3.1c.05.5.46.9.98.9s.93-.4.98-.9c1.97.39 3.52 1.95 3.92 3.92-.5.05-.9.46-.9.98s.4.93.9.98a5.017 5.017 0 01-3.92 3.92zM8 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],lock:["M13.96 7H12V3.95C12 1.77 10.21 0 8 0S4 1.77 4 3.95V7H1.96c-.55 0-.96.35-.96.9v6.91c0 .54.41 1.19.96 1.19h12c.55 0 1.04-.65 1.04-1.19V7.9c0-.55-.49-.9-1.04-.9zM6 7V3.95c0-1.09.9-1.97 2-1.97s2 .88 2 1.97V7H6z"],"log-in":["M11 8c0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L7.59 7H1c-.55 0-1 .45-1 1s.45 1 1 1h6.59L6.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71zm4-8H9c-.55 0-1 .45-1 1s.45 1 1 1h5v12H9c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"log-out":["M7 14H2V2h5c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm8.71-6.71l-3-3a1.003 1.003 0 00-1.42 1.42L12.59 7H6c-.55 0-1 .45-1 1s.45 1 1 1h6.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],manual:["M15.99 1.13c-.02-.41-.33-.77-.78-.87C12.26-.36 9.84.13 8 1.7 6.16.13 3.74-.36.78.26.33.35.03.72.01 1.13H0v12c0 .08 0 .17.02.26.12.51.65.82 1.19.71 2.63-.55 4.59-.04 6.01 1.57.02.03.06.04.08.06.02.02.03.04.05.06.04.03.09.04.13.07.05.03.09.05.14.07.11.04.23.07.35.07h.04c.12 0 .24-.03.35-.07.05-.02.09-.05.14-.07.04-.02.09-.04.13-.07.02-.02.03-.04.05-.06.03-.02.06-.03.08-.06 1.42-1.6 3.39-2.12 6.01-1.57.54.11 1.07-.21 1.19-.71.04-.09.04-.18.04-.26l-.01-12zM7 12.99c-1.4-.83-3.07-1.14-5-.93V1.96c2.11-.28 3.75.2 5 1.46v9.57zm7-.92c-1.93-.21-3.6.1-5 .93V3.42c1.25-1.26 2.89-1.74 5-1.46v10.11z"],"manually-entered-data":["M1 8h3.76l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm14.49-4.01c.31-.32.51-.76.51-1.24C16 1.78 15.22 1 14.25 1c-.48 0-.92.2-1.24.51l-1.44 1.44 2.47 2.47 1.45-1.43zM1 4h7.76l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm0 6c-.55 0-1 .45-1 1 0 .48.35.86.8.96L2.76 10H1zm9.95-6.43l-6.69 6.69 2.47 2.47 6.69-6.69-2.47-2.47zm4.25 2.47L13.24 8H15c.55 0 1-.45 1-1 0-.48-.35-.86-.8-.96zM2 15l3.86-1.39-2.46-2.44L2 15zm13-5h-3.76l-2 2H15c.55 0 1-.45 1-1s-.45-1-1-1z"],"many-to-many":["M3 3a1 1 0 100 2 1 1 0 000-2zm3 1c0 .047-.001.094-.003.14.255.081.538.209.832.41.406.28.8.676 1.171 1.225.37-.549.765-.945 1.171-1.224a3.14 3.14 0 01.832-.411 3 3 0 11.77 1.87 1.038 1.038 0 00-.47.19c-.291.2-.752.672-1.227 1.8.475 1.128.936 1.6 1.227 1.8.183.126.336.173.47.19a3 3 0 11-.77 1.87 3.141 3.141 0 01-.832-.41c-.406-.28-.8-.676-1.171-1.225-.37.549-.765.945-1.171 1.224-.294.202-.577.33-.832.411a3 3 0 11-.77-1.87c.134-.017.287-.064.47-.19.291-.2.752-.672 1.227-1.8-.475-1.128-.936-1.6-1.227-1.8a1.038 1.038 0 00-.47-.19A3 3 0 116 4zm6 0a1 1 0 112 0 1 1 0 01-2 0zm-9 7a1 1 0 100 2 1 1 0 000-2zm9 1a1 1 0 112 0 1 1 0 01-2 0z"],"many-to-one":["M3 2a1 1 0 100 2 1 1 0 000-2zm0-2c1.385 0 2.551.94 2.896 2.215.168.044.34.096.51.158 1.076.394 2.237 1.242 2.575 2.93.161.809.664 1.211 1.293 1.443a3 3 0 110 2.508c-.629.232-1.132.634-1.293 1.442-.338 1.69-1.499 2.537-2.575 2.93a5.436 5.436 0 01-.51.159A3.001 3.001 0 010 13a3 3 0 015.726-1.254c.629-.232 1.132-.634 1.293-1.442.216-1.076.765-1.81 1.413-2.304-.648-.493-1.197-1.228-1.413-2.304-.161-.808-.664-1.21-1.293-1.442A3 3 0 113 0zm1 13a1 1 0 10-2 0 1 1 0 002 0zm8-5a1 1 0 102 0 1 1 0 00-2 0z"],map:["M15.55 3.17l-4.49-3A.975.975 0 009.99.15L5.53 2.82 1.56.17A1.003 1.003 0 000 1v11c0 .35.18.65.45.83l4.49 3a.975.975 0 001.07.02l4.46-2.67 3.97 2.65A1.003 1.003 0 0016 15V4c0-.35-.18-.65-.45-.83zM5 13.46l-3-2v-8.6l2.94 1.96c.02.02.04.03.06.04v8.6zm5-2.32s-.01 0-.01.01L6 13.53V4.86s.01 0 .01-.01L10 2.47v8.67zm4 1.99l-2.94-1.96c-.02-.01-.04-.02-.05-.03v-8.6l3 2v8.59z"],"map-create":["M14 6.82v6.32l-2.94-1.96c-.02-.01-.04-.02-.05-.03V6.22c-.08-.07-.15-.16-.22-.24-.28-.02-.54-.08-.79-.16v5.32s-.01 0-.01.01L6 13.53V4.86s.01 0 .01-.01l2.05-1.23C8.02 3.42 8 3.21 8 3c0-.98.47-1.84 1.2-2.39l-3.67 2.2L1.56.17A1.003 1.003 0 000 1v11c0 .35.18.65.45.83l4.49 3a.975.975 0 001.07.02l4.46-2.67 3.97 2.65A1.003 1.003 0 0016 15V5.82c-.25.09-.52.14-.8.16-.33.36-.73.67-1.2.84zm-9 6.64l-3-2v-8.6l2.94 1.96c.02.02.04.03.06.04v8.6zM11 4h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1z"],"map-marker":["M8.46 0C5.42 0 2.95 2.39 2.95 5.33 2.95 8.28 8.46 16 8.46 16s5.51-7.72 5.51-10.67C13.96 2.39 11.5 0 8.46 0zm0 8a2.5 2.5 0 010-5 2.5 2.5 0 010 5z"],maximize:["M5.99 8.99c-.28 0-.53.11-.71.29l-3.29 3.29v-1.59c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.41L6.7 10.7a1.003 1.003 0 00-.71-1.71zm9-9h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59l-3.3 3.3a.99.99 0 00-.29.7 1.003 1.003 0 001.71.71l3.29-3.29V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"],media:["M11.99 6.99c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm3-5h-14c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-10c0-.55-.45-1-1-1zm-1 9l-5-3-1 2-3-4-3 5v-7h12v7z"],menu:["M1 4h14c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 8H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm0-5H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-closed":["M14.99 6.99h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm-12-2c-.28 0-.53.11-.71.29l-2 2a1.014 1.014 0 000 1.42l2 2a1.003 1.003 0 001.71-.71v-4c0-.55-.45-1-1-1zm3-1h9c.55 0 1-.45 1-1s-.45-1-1-1h-9c-.55 0-1 .45-1 1s.45 1 1 1zm9 8h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-open":["M9.99 11.99h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm5.71 5.3l-2-2a1.003 1.003 0 00-1.71.71v4a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71z"],"merge-columns":["M5.71 5.29a1.003 1.003 0 00-1.42 1.42l.3.29H2V2h3v1.51c.52.06.99.29 1.34.65l.66.66V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-3.82l-.66.66c-.35.35-.82.59-1.34.65V14H2V9h2.59l-.3.29a1.003 1.003 0 001.42 1.42l2-2C7.89 8.53 8 8.28 8 8c0-.28-.11-.53-.29-.71l-2-2zM15 0h-5c-.55 0-1 .45-1 1v3.82l.66-.66c.35-.35.82-.59 1.34-.65V2h3v5h-2.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C8.11 7.47 8 7.72 8 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14v5h-3v-1.51c-.52-.06-.99-.29-1.34-.65L9 11.18V15c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"merge-links":["M8 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6 3c-.93 0-1.71.64-1.93 1.5H11V3c0-1.66-1.34-3-3-3S5 1.34 5 3v4.5H3.93C3.71 6.64 2.93 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.93 0 1.71-.64 1.93-1.5H5V13c0 1.66 1.34 3 3 3s3-1.34 3-3V8.5h1.07c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2s-.9-2-2-2zm-4 7c0 1.1-.9 2-2 2s-2-.9-2-2V3c0-1.1.9-2 2-2s2 .9 2 2v10z"],minimize:["M15.99.99a1.003 1.003 0 00-1.71-.71l-3.29 3.29V1.99c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H12.4l3.3-3.29c.18-.18.29-.43.29-.71zm-10 8h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.29 14.28a1.003 1.003 0 001.42 1.42L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4a1.02 1.02 0 00-1.01-1.01z"],minus:["M13 7H3c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"mobile-phone":["M12 0H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM8 15c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3-3H5V3h6v9z"],"mobile-video":["M15 4c-.28 0-.53.11-.71.29L12 6.59V4c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V9.41l2.29 2.29c.18.19.43.3.71.3.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],modal:["M15 1a1 1 0 011 1v12a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1h14zm-1 4H2v8h12V5zm-3-3H9v2h2V2zm3 0h-2v2h2V2z"],"modal-filled":["M15 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm1 4H0V3h16v2zm-3-2h-2V1h2v2z"],moon:["M15 11.38A7.835 7.835 0 017.85 16C3.51 16 0 12.49 0 8.15 0 4.97 1.89 2.23 4.62 1c-.45.99-.7 2.08-.7 3.23a7.85 7.85 0 007.85 7.85c1.15 0 2.24-.25 3.23-.7z"],more:["M2 6.03a2 2 0 100 4 2 2 0 100-4zM14 6.03a2 2 0 100 4 2 2 0 100-4zM8 6.03a2 2 0 100 4 2 2 0 100-4z"],mountain:["M16 13H3l6-9h1l2 2h1l3 7zm-2.5-3.5l-1-2.5h-1l-2-2-3 4.5L9 8l1 1 1-1 2.5 1.5zM5.94 7l-4.122 6H0l5-6h.94z"],move:["M15.71 7.29l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9V3.41l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C8.53.11 8.28 0 8 0s-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V7H3.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 9H7v3.59l-.29-.29A.965.965 0 006 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2a1.003 1.003 0 00-1.42-1.42l-.29.3V9h3.59l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],mugshot:["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14h-.15c-.03-.09-.04-.16-.08-.25-.34-.79-2.01-1.31-3.12-1.8-1.11-.49-.96-.79-1-1.2-.01-.06-.01-.12-.01-.18.38-.34.69-.8.89-1.33 0 0 .01-.03.01-.04.04-.12.08-.24.11-.36.25-.05.4-.33.46-.59.06-.1.18-.36.15-.65-.04-.37-.19-.55-.35-.62v-.06c0-.48-.04-1.16-.13-1.61-.02-.12-.05-.25-.08-.37-.16-.55-.51-1.05-.96-1.39C9.26 3.19 8.6 3 8 3c-.59 0-1.26.19-1.73.55-.45.35-.8.84-.96 1.39-.04.13-.06.25-.08.38-.09.45-.13 1.13-.13 1.61v.06c-.18.06-.33.24-.37.62-.03.29.09.54.15.65.06.26.21.54.47.59.03.12.07.25.11.36 0 .01.01.02.01.02v.01c.21.54.53 1.01.92 1.35 0 .05-.01.11-.01.16-.04.41.08.7-1.03 1.2-1.11.49-2.77 1.01-3.12 1.8-.04.09-.05.16-.08.25H2V2h12v12z"],"multi-select":["M12 3.98H4c-.55 0-1 .45-1 1v1h8v5h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm3-3H7c-.55 0-1 .45-1 1v1h8v5h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm-6 6H1c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm-1 5H2v-3h6v3z"],music:["M15 0c-.07 0-.13.03-.19.04V.02l-10 2v.02C4.35 2.13 4 2.52 4 3v9.12c-.31-.07-.65-.12-1-.12-1.66 0-3 .9-3 2s1.34 2 3 2 3-.9 3-2V6.32l8-1.6v5.4c-.31-.07-.65-.12-1-.12-1.66 0-3 .9-3 2s1.34 2 3 2 3-.9 3-2V1c0-.55-.45-1-1-1z"],nest:["M2 2c.55 0 1 .45 1 1v3c0 1.66 1.34 3 3 3h5.59L10.3 7.71A.965.965 0 0110 7a1.003 1.003 0 011.71-.71l3 3c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-3 3a1.003 1.003 0 01-1.42-1.42l1.3-1.29H6c-2.76 0-5-2.24-5-5V3c0-.55.45-1 1-1z"],"new-drawing":["M14.9 11c.6 0 1 .5 1 1 0 .257-.073.44-.22.614l-.08.086-3 3c-.2.2-.4.3-.7.3-.5 0-1-.4-1-1 0-.257.073-.44.22-.614l.08-.086 3-3c.2-.2.4-.3.7-.3zM1.3.1l6.734 2.45a3.005 3.005 0 002.095 3.322 3.005 3.005 0 003.401 2.081L13.9 9.8v.2c0 .257-.073.44-.22.614l-.08.086-3 3c-.171.171-.343.27-.577.294L9.9 14h-.2l-5-1-.1-.01c-.231-.05-.45-.26-.56-.49L4 12.4l-4-11 .3-.3 5.8 5.8c-.1.2-.2.4-.2.6 0 .8.6 1.5 1.5 1.5s1.5-.7 1.5-1.5S8.2 6 7.4 6c-.16 0-.32.064-.48.14l-.12.06L1 .4l.3-.3zM13 0c.55 0 1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .503-.376.922-.861.99l-.013.002A.999.999 0 0113 6l.097-.006-.027.004a1 1 0 01-.037.001L13 6c-.55 0-1-.45-1-1V4h-1a.993.993 0 01-.855-.482A1 1 0 0110 3c0-.55.45-1 1-1h1V1c0-.55.45-1 1-1z"],"new-grid-item":["M6 0H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm5 14c0-.55-.45-1-1-1s-1 .45-1 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zM6 9H1c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1zm9 4c-.55 0-1 .45-1 1-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm-4-4h-1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1s1-.45 1-1c.55 0 1-.45 1-1s-.45-1-1-1zm4-9h-5c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm0 9h-1c-.55 0-1 .45-1 1s.45 1 1 1c0 .55.45 1 1 1s1-.45 1-1v-1c0-.55-.45-1-1-1z"],"new-layer":["M13.982 6.272l1.518.868-.01.01c.3.17.51.48.51.85s-.21.68-.51.85l.01.01-7 4-.01-.01A.94.94 0 018 13a.94.94 0 01-.49-.15l-.01.01-7-4 .01-.01A.977.977 0 010 8c0-.37.21-.68.51-.86L.5 7.13l7-4 .01.02A.94.94 0 018 3c.086 0 .168.014.246.038a2 2 0 105.736 3.234zM14 3c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 1-1s1 .45 1 1v1h1z"],"new-layers":["M13 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5H9a1 1 0 110-2h2V1a1 1 0 012 0v2zm-3-1.983V2H9a2 2 0 100 4h1v1c0 .279.057.544.16.785l-1.71.855c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5a.992.992 0 01.07-1.81l6.99-3a1.006 1.006 0 01.79 0l1.6.687zm.91 7.66a2 2 0 003.085-1.54l.555-.277c.14-.07.29-.11.45-.11.55 0 1 .45 1 1 0 .39-.23.73-.55.89l-7 3.5c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5C.23 8.48 0 8.14 0 7.75c0-.55.45-1 1-1 .16 0 .31.04.45.11L8 10.13l2.91-1.453zM15 10.25c.55 0 1 .45 1 1 0 .39-.23.73-.55.89l-7 3.5c-.14.07-.29.11-.45.11-.16 0-.31-.04-.45-.11l-7-3.5c-.32-.16-.55-.5-.55-.89 0-.55.45-1 1-1 .16 0 .31.04.45.1L8 13.63l6.55-3.27c.14-.07.29-.11.45-.11z"],"new-link":["M15 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3.5 6a2.5 2.5 0 00-2.45 2h-4.1a2.5 2.5 0 100 1h4.1a2.5 2.5 0 102.45-3z"],"new-object":["M8 4c0 .6.4 1 1 1h2v2c0 .6.4 1 1 1s1-.4 1-1V5h2c.6 0 1-.4 1-1s-.4-1-1-1h-2V1c0-.6-.4-1-1-1s-1 .4-1 1v2H9c-.6 0-1 .5-1 1zm6.5 2.5V7c0 1.4-1.1 2.5-2.5 2.5S9.5 8.4 9.5 7v-.5H9C7.6 6.5 6.5 5.4 6.5 4S7.6 1.5 9 1.5h.5V1c0-.3.1-.6.1-.8C9.1.1 8.6 0 8 0 3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8c0-.6-.1-1.3-.2-1.9-.4.3-.8.4-1.3.4z"],"new-person":["M9.12 12.69c-1.17-.53-1.01-.85-1.05-1.29-.01-.06-.01-.12-.01-.19.4-.37.73-.87.94-1.44 0 0 .01-.03.01-.04.05-.14.09-.27.12-.4.27-.06.43-.36.49-.63.06-.11.19-.39.16-.7-.04-.41-.2-.6-.38-.68v-.07c0-.51-.05-1.25-.14-1.74-.02-.13-.05-.27-.09-.4-.17-.6-.53-1.14-1.01-1.52C7.66 3.2 6.96 3 6.33 3c-.62 0-1.33.2-1.82.59-.49.38-.85.92-1.02 1.52-.04.13-.07.26-.09.4-.09.49-.13 1.23-.13 1.74v.06c-.19.08-.35.27-.39.68-.03.31.1.59.16.7.06.28.22.59.5.64.03.14.07.27.11.4 0 .01.01.02.01.02v.01c.22.59.55 1.1.96 1.46 0 .06-.01.12-.01.17-.04.44.08.76-1.09 1.29-1.17.53-2.93 1.1-3.29 1.95-.35.87-.2 1.37-.2 1.37h12.6s.15-.5-.22-1.36c-.36-.85-2.12-1.42-3.29-1.95zM14.89 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-prescription":["M9.82 11.66l2.48-2.87c.12-.2.13-.37.04-.53-.11-.19-.3-.26-.52-.26h-1.29c-.27 0-.49.13-.63.34L8.44 9.9 6.95 8a.482.482 0 00-.08-.1L5.82 6.55c.57-.24 1.04-.57 1.42-1.01.49-.57.74-1.27.74-2.08 0-.51-.1-.99-.32-1.42-.21-.43-.51-.8-.89-1.11A4.1 4.1 0 005.42.24C4.91.08 4.34 0 3.72 0H.61C.26 0 0 .23 0 .56v9.89c0 .33.26.55.61.55h.8c.36 0 .61-.23.61-.56V6.99H3.3l3.73 4.74-2.71 3.48c-.12.2-.13.37-.04.53.11.19.3.26.52.26h1.27c.27 0 .51-.12.64-.34l1.69-2.15 1.66 2.14c.12.21.34.35.62.35h1.43c.2 0 .39-.08.5-.25.12-.18.09-.38-.02-.55l-2.77-3.54zM4.18 5H1.99V2.02h2.19c.62 0 1.08.13 1.38.37.29.22.44.62.44 1.08 0 .45-.15.94-.44 1.17-.31.23-.76.36-1.38.36zM15 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zM9.99 3.01c0 .02.01.04.01.06V2.95c0 .02-.01.04-.01.06z"],"new-text-box":["M5 6.5c0 .28.22.5.5.5H7v3.5c0 .28.22.5.5.5s.5-.22.5-.5V7h1.5c.28 0 .5-.22.5-.5S9.78 6 9.5 6h-4c-.28 0-.5.22-.5.5zM15 2h-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V4h1c.55 0 1-.45 1-1s-.45-1-1-1zm-2 5c-.55 0-1 .45-1 1v5H3V4h5c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1z"],ninja:["M16 5s-2.52 2.11-4.96 1.99C11.03 4.89 10.39.23 5 0c0 0 2.11 2.54 1.96 4.99C4.86 5.01.23 5.65 0 11c0 0 2.56-2.12 5.02-1.95.02 2.11.67 6.72 5.98 6.95 0 0-2.09-2.54-1.94-4.99 2.11-.02 6.71-.68 6.94-6.01zM8 9.5c-.83 0-1.5-.67-1.5-1.5S7.17 6.5 8 6.5s1.5.67 1.5 1.5S8.83 9.5 8 9.5z"],"not-equal-to":["M7.58 5l.44-2.196a1 1 0 011.96.392L9.62 5H13a1 1 0 010 2H9.22l-.4 2H13a1 1 0 010 2H8.42l-.44 2.196a1 1 0 01-1.96-.392L6.38 11H3a1 1 0 010-2h3.78l.4-2H3a1 1 0 110-2h4.58z"],notifications:["M8 16c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zm6-5c-.55 0-1-.45-1-1V6c0-2.43-1.73-4.45-4.02-4.9 0-.04.02-.06.02-.1 0-.55-.45-1-1-1S7 .45 7 1c0 .04.02.06.02.1A4.992 4.992 0 003 6v4c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],"notifications-snooze":["M9 14c0 1.1-.9 2-2 2s-2-.9-2-2zM7 0c.404 0 .755.243.912.59L7.9.6c-.7.6-.9 1.36-.9 1.9 0 .8.267 1.433.8 1.9-.533.6-.795 1.222-.784 1.867l.004.358A2.8 2.8 0 009.82 9.4L12 9.399V10c0 .51.388.935.884.993L13 11c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V6c0-2.43 1.73-4.45 4.02-4.9L6 1c0-.55.45-1 1-1z","M13 6.702a.632.632 0 00-.632-.632h-1.743l2.208-2.734A.75.75 0 0013 2.864v-.3A.565.565 0 0012.435 2H9.561a.561.561 0 100 1.123h1.814L9.221 5.795A1 1 0 009 6.423v.279c0 .349.283.631.632.631h2.736A.632.632 0 0013 6.702z"],"notifications-updated":["M8 16c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zm3.399-13.667l-.413.412A2.99 2.99 0 009 1.99a3 3 0 00-3 2.99c0 .8.32 1.558.876 2.114l2.002 1.992A2.99 2.99 0 0013 9.184V10c0 .55.45 1 1 1s1 .45 1 1-.45 1-1 1H2c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V6c0-2.43 1.73-4.45 4.02-4.9 0-.04-.02-.06-.02-.1 0-.55.45-1 1-1s1 .45 1 1c0 .04-.02.06-.02.1a4.97 4.97 0 012.419 1.233zM10.29 7.67l-2-1.99a.99.99 0 01-.29-.7 1 1 0 011-.99c.27 0 .52.11.7.29l1.29 1.29 3.28-3.28c.18-.18.42-.29.7-.29.55 0 1 .44 1 .99 0 .28-.11.52-.3.7l-3.98 3.98a.99.99 0 01-1.4 0z"],"numbered-list":["M2.76 7h1.26V0h-.94c-.04.21-.12.39-.25.54-.13.15-.29.27-.48.36-.18.09-.39.16-.62.2-.23.04-.46.06-.71.06v.9h1.74V7zm-.59 7.17c.18-.12.37-.25.58-.37a10.763 10.763 0 001.24-.83c.2-.16.37-.33.52-.51.15-.19.28-.39.37-.61.09-.22.14-.47.14-.74 0-.22-.04-.45-.12-.7-.08-.26-.21-.49-.4-.69-.18-.21-.43-.39-.72-.52-.3-.14-.68-.21-1.12-.21-.41 0-.77.07-1.08.2-.32.14-.58.32-.8.56-.22.23-.38.51-.49.84-.11.32-.16.67-.16 1.05h1.19c.01-.24.03-.47.08-.67.05-.21.11-.39.21-.54.09-.15.22-.27.38-.36.16-.09.35-.13.59-.13.26 0 .47.04.63.12.16.08.29.18.38.3.09.12.15.25.18.39s.05.27.05.4c-.01.27-.08.5-.22.71-.14.21-.32.4-.53.57-.22.18-.45.34-.71.49-.26.15-.51.31-.74.47-.5.31-.89.68-1.17 1.11-.3.41-.44.91-.45 1.48h5v-1H1.43c.05-.15.14-.29.27-.43.14-.13.29-.26.47-.38zM15.01 1.99h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.44-1-1-1zm0 9h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.44-1-1-1z"],numerical:["M2.79 4.61c-.13.17-.29.3-.48.41-.18.11-.39.18-.62.23-.23.04-.46.07-.71.07v1.03h1.74V12h1.26V4h-.94c-.04.23-.12.44-.25.61zm4.37 5.31c.18-.14.37-.28.58-.42l.63-.45c.21-.16.41-.33.61-.51s.37-.38.52-.59c.15-.21.28-.45.37-.7.09-.25.13-.54.13-.85 0-.25-.04-.52-.12-.8-.07-.29-.2-.55-.39-.79a2.18 2.18 0 00-.73-.6c-.29-.15-.66-.23-1.11-.23-.41 0-.77.08-1.08.23-.31.16-.58.37-.79.64-.22.27-.38.59-.49.96-.11.37-.16.77-.16 1.2h1.19c.01-.27.03-.53.08-.77.04-.24.11-.45.21-.62.09-.18.22-.32.38-.42.16-.1.35-.15.59-.15.26 0 .47.05.63.14.15.09.28.21.37.35.09.14.15.29.18.45.03.16.05.31.05.45-.01.31-.08.58-.22.82-.14.23-.32.45-.53.65-.22.21-.46.39-.71.57-.26.18-.51.36-.75.54-.5.36-.89.78-1.17 1.27-.28.49-.43 1.06-.44 1.71h5v-1.15H6.43c.05-.17.14-.33.27-.49.13-.15.29-.29.46-.44zm8.5-1.56c-.23-.35-.54-.57-.95-.65v-.02c.34-.13.6-.34.76-.63.16-.29.24-.63.24-1.02 0-.34-.06-.64-.19-.9s-.3-.47-.51-.64c-.21-.17-.45-.3-.72-.38-.27-.09-.54-.13-.82-.13-.36 0-.68.07-.96.2-.28.13-.53.32-.72.55-.2.23-.36.51-.47.83-.11.32-.18.66-.19 1.04h1.15c-.01-.2.01-.39.06-.58.05-.19.12-.36.22-.51.1-.15.22-.27.37-.36.15-.09.32-.13.53-.13.32 0 .59.1.79.3.21.2.31.46.31.79 0 .23-.05.43-.14.59-.09.16-.21.29-.35.38-.15.09-.32.16-.51.19-.19.04-.38.05-.57.04v.93c.23-.01.45 0 .67.02.22.02.42.08.59.17.18.09.32.23.43.4.11.18.16.41.16.71 0 .44-.13.78-.39 1.02s-.58.36-.97.36c-.45 0-.79-.16-1.02-.47-.23-.31-.33-.7-.32-1.17H11c.01.4.06.77.17 1.1.11.33.26.61.47.85.21.23.46.42.77.54.31.13.67.19 1.08.19.34 0 .66-.05.96-.16.3-.11.57-.27.8-.47.23-.2.41-.45.55-.74.13-.27.2-.6.2-.97 0-.5-.11-.92-.34-1.27z"],office:["M15 5h-3V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h3v-4h4v4h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM5 10H2V7h3v3zm0-5H2V2h3v3zm5 5H7V7h3v3zm0-5H7V2h3v3zm4 9h-2v-2h2v2zm0-4h-2V7h2v3z"],offline:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zM6 14l1-5H4l6-7-1 5h3l-6 7z"],"oil-field":["M15 14h-1.35l-3.34-7.51 2.46-.95 1.45 3.21c.09.2.36.3.6.23.1-.03.18-.08.24-.15.05-.08 1.23-1.56.87-4.2-.11-.79-.52-4.62-3.26-4.62-.93 0-1.68.62-1.67 1.37 0 .14.03.28.09.42l.87 1.92L.64 8.07v.01A.98.98 0 000 9c0 .55.45 1 1 1 .13 0 .25-.03.36-.07v.01l1.04-.4L3.67 14H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM4.27 8.81L7.14 7.7 5.2 12.08l-.93-3.27zM6.54 14L9 8.46 11.46 14H6.54z"],"one-column":["M11.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1zm-6 5c-.28 0-.53.11-.71.29l-2 2a1.014 1.014 0 000 1.42l2 2a1.003 1.003 0 001.71-.71v-4c0-.55-.45-1-1-1z"],"one-to-many":["M14 3a1 1 0 11-2 0 1 1 0 012 0zm-3.726 1.254a3 3 0 10-.17-2.039 5.467 5.467 0 00-.51.158c-1.076.394-2.237 1.242-2.575 2.93-.161.809-.664 1.211-1.293 1.443a3 3 0 100 2.508c.629.232 1.132.634 1.293 1.442.338 1.69 1.499 2.537 2.575 2.93.17.063.342.115.51.159a3.001 3.001 0 10.17-2.04c-.629-.231-1.132-.633-1.293-1.441C8.765 9.228 8.216 8.494 7.568 8c.648-.493 1.197-1.228 1.413-2.304.161-.808.664-1.21 1.293-1.442zM13 14a1 1 0 110-2 1 1 0 010 2zM4 8a1 1 0 10-2 0 1 1 0 002 0z"],"one-to-one":["M2 8a1 1 0 112 0 1 1 0 01-2 0zm3.83-1a3.001 3.001 0 100 2h4.34a3.001 3.001 0 100-2H5.83zM13 7a1 1 0 100 2 1 1 0 000-2z"],outdated:["M8 0c4.42 0 8 3.58 8 8 0 4.06-3.02 7.4-6.94 7.92-.02 0-.04.01-.06.01-.33.04-.66.07-1 .07-4.42 0-8-3.58-8-8 0-.55.45-1 1-1s1 .45 1 1c0 3.31 2.69 6 6 6 .71 0 1.37-.15 2-.38v.01c2.33-.82 4-3.02 4-5.63 0-3.31-2.69-6-6-6-1.78 0-3.36.78-4.46 2H5c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v1.74A7.95 7.95 0 018 0zm1 12H7v-2h2v2zm0-3H7V4h2v5z"],"page-layout":["M15 .95H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-12c0-.55-.45-1-1-1zm-9 12H2v-6h4v6zm8 0H7v-6h7v6zm0-7H2v-3h12v3z"],"panel-stats":["M10 4h3v1h-3zM10 6h3v1h-3zM10 8h3v1h-3zM10 10h3v1h-3z","M15 1H1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zM8 12H2V3h6v9zm6 0H9V3h5v9z"],"panel-table":["M15 1H1c-.6 0-1 .4-1 1v11c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zM8 9H6V7h2v2zm0-3H6V4h2v2zm-6 6V3h3v9H2zm4 0v-2h2v2H6zm8 0H9v-2h5v2zm0-3H9V7h5v2zm0-3H9V4h5v2z"],paperclip:["M14.68 2.31A4.54 4.54 0 0011.46.99c-1.15 0-2.31.44-3.19 1.32L.95 9.63c-.63.63-.95 1.46-.95 2.28a3.21 3.21 0 003.23 3.22c.83 0 1.66-.31 2.3-.95l7.31-7.32c.76-.77.76-1.98.01-2.73s-1.99-.76-2.75 0l-6.07 6.08c-.24.25-.24.65.01.9s.65.25.91.01l6.07-6.08c.25-.25.67-.25.91-.01.25.25.25.67 0 .92l-7.31 7.32c-.75.75-2.04.74-2.76.01-.75-.75-.73-2.02.01-2.76L9.2 3.21c1.24-1.24 3.35-1.26 4.58-.03 1.24 1.24 1.24 3.36 0 4.6l-7.12 7.13c-.24.25-.24.64.01.88.24.24.63.24.88.01v.01l7.13-7.13A4.41 4.41 0 0016 5.51c0-1.16-.44-2.32-1.32-3.2z"],paragraph:["M13 1H6C3.8 1 2 2.8 2 5s1.8 4 4 4v5c0 .6.4 1 1 1s1-.5 1-1V3h2v11c0 .6.4 1 1 1s1-.5 1-1V3h1c.5 0 1-.4 1-1s-.4-1-1-1z"],path:["M14.5 0h-13C.67 0 0 .67 0 1.5S.67 3 1.5 3H7v3H3.5C2.67 6 2 6.67 2 7.5S2.67 9 3.5 9H7v3H5.5c-.83 0-1.5.67-1.5 1.5S4.67 15 5.5 15h5c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5H9V9h3.5c.83 0 1.5-.67 1.5-1.5S13.33 6 12.5 6H9V3h5.5c.83 0 1.5-.67 1.5-1.5S15.33 0 14.5 0z"],"path-search":["M15 14.62l-4-2.4V9.77c-.32.09-.66.15-1 .18v2.27l-4 2.4V8.71c-.38-.31-.72-.66-1-1.06v6.97l-4-2.4V8c.55 0 1-.45 1-1s-.45-1-1-1V1.38l3.15 1.89c.08-.34.18-.66.32-.97L.76.07v.01A.496.496 0 00.5 0C.22 0 0 .22 0 .5v12c0 .18.1.33.25.42v.01l5 3v-.01c.07.05.16.08.25.08s.18-.03.25-.08v.01l4.74-2.85 4.74 2.85v-.01c.09.05.18.08.27.08.28 0 .5-.22.5-.5v-3.78c-.3.17-.63.28-1 .28v2.62zM2 5c0 .55.45 1 1 1s1-.45 1-1-.45-1-1-1-1 .45-1 1zm6-1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm7.75-.92l-1.19-.72c.18.43.29.9.36 1.38l.08.04v3.39l1 1V3.5c0-.18-.1-.33-.25-.42zM10 2c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3.3 4.89c.44-.7.7-1.51.7-2.39C14 2.01 11.99 0 9.5 0S5 2.01 5 4.5 7.01 9 9.5 9c.88 0 1.69-.26 2.39-.7l2.41 2.41c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71l-2.41-2.4zM9.5 8C7.57 8 6 6.43 6 4.5S7.57 1 9.5 1 13 2.57 13 4.5 11.43 8 9.5 8z"],pause:["M6 3H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm6 0h-2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],people:["M13.69 13.98c-.05-.24-.14-.5-.25-.76-.36-.86-1.12-1.33-2.69-2-.14-.06-.59-.25-.6-.25-.21-.09-.36-.15-.5-.22.02-.1.02-.2.03-.31 0-.04.01-.08.01-.13-.07-.06-.13-.12-.19-.19.22-.32.4-.67.54-1.05.02-.06.02-.06.03-.1.29-.23.48-.57.59-.96.16-.33.25-.73.21-1.16-.03-.4-.16-.76-.37-1.03-.02-.53-.07-1.13-.15-1.54-.01-.06-.02-.12-.03-.19.23-.06.48-.09.72-.09.49 0 1.05.16 1.44.46.38.29.67.7.8 1.17.03.1.05.21.07.31.07.37.11.94.11 1.33v.05c.14.06.27.21.29.51.02.25-.07.45-.13.54-.05.21-.16.44-.38.48-.02.1-.05.2-.09.3 0 .01-.01.03-.01.03-.17.44-.43.83-.75 1.11v.14c.03.35-.09.59.83 1 .93.41 2.32.84 2.6 1.5.29.66.17 1.04.17 1.04h-2.3zm-1.17-.38c.37.86.22 1.36.22 1.36H.06s-.14-.5.22-1.36 2.13-1.43 3.31-1.96c1.17-.54 1.05-.86 1.09-1.3 0-.05.01-.11.01-.17-.41-.35-.75-.86-.97-1.45v-.01s-.01-.01-.01-.02c-.04-.12-.09-.26-.12-.39-.28-.05-.44-.36-.5-.64-.06-.12-.19-.39-.16-.71.04-.41.21-.6.39-.68v-.06c0-.51.05-1.26.14-1.74.02-.13.05-.27.09-.4.17-.6.54-1.13 1.02-1.51.5-.39 1.21-.6 1.84-.6s1.34.21 1.84.6c.48.38.85.91 1.02 1.52.04.13.07.27.09.4.09.48.14 1.22.14 1.73v.07c.18.08.34.27.37.67.03.32-.09.59-.16.71-.06.28-.21.58-.48.63-.03.13-.07.26-.12.39 0 .01-.01.04-.01.04-.22.58-.55 1.08-.95 1.45v.18c.04.45-.12.77 1.06 1.3 1.18.53 2.95 1.09 3.31 1.95z"],percentage:["M6 6V4c0-1.1-.9-2-2-2H3c-1.1 0-2 .9-2 2v2c0 1.1.9 2 2 2h1c1.1 0 2-.9 2-2zM3.5 6c-.28 0-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5s.5.22.5.5v1c0 .28-.22.5-.5.5zM13 8h-1c-1.1 0-2 .9-2 2v2c0 1.1.9 2 2 2h1c1.1 0 2-.9 2-2v-2c0-1.1-.9-2-2-2zm0 3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5s.5.22.5.5v1zM12 3a1.003 1.003 0 00-1.87-.5l-5.99 9.98c-.09.15-.14.33-.14.52a1.003 1.003 0 001.87.5l5.99-9.98c.09-.15.14-.33.14-.52z"],person:["M15.68 14.32c-.46-1.05-2.68-1.75-4.16-2.4-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15A3.671 3.671 0 0010.32.72C9.68.25 8.79-.01 8-.01c-.79 0-1.68.25-2.31.73-.61.47-1.06 1.13-1.28 1.86-.05.17-.09.33-.11.5-.12.6-.17 1.51-.17 2.15v.08c-.24.09-.45.32-.5.83-.03.38.13.72.2.86.08.35.28.72.63.78.04.17.09.33.15.49 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.37 1.59-1.48.65-3.7 1.35-4.16 2.4-.46 1.05-.27 1.67-.27 1.67h15.92c-.01.01.18-.61-.28-1.66z"],phone:["M15.9 12.41c-.06-.06-3.37-2-3.48-2.05a.794.794 0 00-.32-.08c-.15 0-.34.11-.57.32-.23.22-.94 1.19-1.15 1.4-.21.22-.38.32-.52.32-.07 0-.15-.02-.25-.06-.1-.04-1.16-.58-3.36-2.52-2.2-1.93-2.49-3.2-2.5-3.55 0-.14.11-.31.32-.52.22-.21.45-.41.7-.6.25-.19.49-.4.7-.62.22-.23.32-.42.32-.57 0-.11-.03-.21-.08-.32C5.66 3.46 3.66.15 3.59.08 3.44-.07 2.85 0 2.55.16.16 1.46-.03 3.2 0 3.89c.04.71.49 4.46 4.16 7.95C8.72 16.17 11.89 16 12.1 16c.69 0 2.82-.38 3.72-2.55.13-.32.25-.87.08-1.04z"],"pie-chart":["M7 1.08c-3.37.5-5.97 3.4-5.97 6.92 0 3.87 3.13 7 6.98 7 3.52 0 6.42-2.61 6.91-6H7V1.08z","M8 0v8h8c0-4.42-3.58-8-8-8z"],pin:["M9.41.92c-.51.51-.41 1.5.15 2.56L4.34 7.54C2.8 6.48 1.45 6.05.92 6.58l3.54 3.54-3.54 4.95 4.95-3.54 3.54 3.54c.53-.53.1-1.88-.96-3.42l4.06-5.22c1.06.56 2.04.66 2.55.15L9.41.92z"],pivot:["M4.57 7.02L.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4.27-4.27c-.58-.35-1.07-.84-1.41-1.42zM15 8c-.55 0-1 .45-1 1v.59l-2.57-2.57c-.34.58-.83 1.07-1.41 1.41L12.59 11H12c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-4-3c0-1.66-1.34-3-3-3S5 3.34 5 5s1.34 3 3 3 3-1.34 3-3zM8 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"pivot-table":["M2 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm0-4H1C.45 0 0 .45 0 1v1c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm11.71 4.29C13.53 4.11 13.28 4 13 4s-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V9c0 1.66-1.34 3-3 3H7.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H9c2.76 0 5-2.24 5-5V7.41l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2zM15 0H5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],play:["M12 8c0-.35-.19-.64-.46-.82l.01-.02-6-4-.01.02A.969.969 0 005 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 6-4-.01-.02c.27-.18.46-.47.46-.82z"],plus:["M13 7H9V3c0-.55-.45-1-1-1s-1 .45-1 1v4H3c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1V9h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"polygon-filter":["M14 5c-.24 0-.47.05-.68.13L9.97 2.34c.01-.11.03-.22.03-.34 0-1.1-.9-2-2-2S6 .9 6 2c0 .04.01.08.01.12L2.88 4.21C2.61 4.08 2.32 4 2 4 .9 4 0 4.9 0 6c0 .74.4 1.38 1 1.72v4.55c-.6.35-1 .99-1 1.73 0 1.1.9 2 2 2 .74 0 1.38-.4 1.72-1h4.55c.35.6.98 1 1.72 1 1.1 0 2-.9 2-2 0-.37-.11-.7-.28-1L14 9c1.11-.01 2-.9 2-2s-.9-2-2-2zm-4.01 7c-.73 0-1.37.41-1.71 1H3.73c-.18-.3-.43-.55-.73-.72V7.72c.6-.34 1-.98 1-1.72 0-.04-.01-.08-.01-.12l3.13-2.09c.27.13.56.21.88.21.24 0 .47-.05.68-.13l3.35 2.79c-.01.11-.03.22-.03.34 0 .37.11.7.28 1l-2.29 4z"],power:["M8 8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S7 .45 7 1v6c0 .55.45 1 1 1zm3-5.32v2.34c1.21.91 2 2.35 2 3.98 0 2.76-2.24 5-5 5s-5-2.24-5-5c0-1.63.79-3.06 2-3.98V2.68C2.64 3.81 1 6.21 1 9c0 3.87 3.13 7 7 7s7-3.13 7-7c0-2.79-1.64-5.19-4-6.32z"],"predictive-analysis":["M16 6.41c0-1.01-.49-1.94-1.29-2.49-.43-1.92-2.07-3.28-4-3.28-.46 0-.92.08-1.35.24C8.83.31 8.11 0 7.34 0c-.9 0-1.74.44-2.28 1.16-.12-.01-.24-.02-.36-.02-1.31 0-2.42.89-2.77 2.17C.78 3.72 0 4.84 0 6.13c0 .38.07.76.21 1.12C.07 7.6 0 7.98 0 8.36c0 1.11.58 2.11 1.51 2.63.54.56 1.27.87 2.03.87.49 0 .95-.12 1.37-.36a2.85 2.85 0 002.18 1.04c.52 0 1.03-.14 1.47-.42.49.39 1.07.65 1.69.73 1.04 1.15 1.84 2.63 1.84 2.64 0 0 .28.49.26.49.77 0 1.41-.16 1.32-1.04 0 .02-.73-2.31-.73-2.31.41-.21.75-.55.97-.98.9-.52 1.47-1.53 1.47-2.61 0-.24-.03-.48-.08-.71.45-.52.7-1.21.7-1.92zm-1.23 1.02l-.15-.16-.61-.67c-.27-.29-.54-.94-.58-1.39l-.1-1.01c-.05-.59-.94-.58-.91.11 0 .02.1 1.01.1 1.01.03.29.12.62.24.93-.06-.01-.12-.02-.18-.02 0 0-2.06-.1-2.05-.11-.58-.02-.71.97-.04 1l2.05.11c.42.02 1.04.3 1.29.58l.49.54.02.05c.08.21.12.44.12.66 0 .74-.41 1.41-1.07 1.75l-.16.08-.07.18c-.15.38-.48.66-.88.74l-.54.11.7 2.2c-.38-.61-.95-1.43-1.62-2.14l-.12-.13-.17-.01c-.41-.03-.8-.17-1.14-.38l1.36-1.18c.35-.31.83-.44.99-.39 0 0 .63.17.62.18.63.16.83-.74.23-.97l-.62-.18c-.55-.16-1.33.18-1.79.58l-1.53 1.33-.31.26c-.35.29-.75.44-1.2.44-.64 0-1.23-.33-1.58-.86V9.15c0-.4.17-.79.27-.85 0 0 .52-.34.51-.35.71-.53.18-1.23-.49-.89 0-.01-.52.35-.52.35-.26.15-.45.44-.58.77-.11-.11-.22-.2-.34-.28 0 0-1.53-1.01-1.53-1.02-.65-.45-1.2.51-.49.89 0-.01 1.51 1.02 1.51 1.02.37.24.62.78.62 1.09v.67c-.34.19-.63.29-.99.29-.54 0-1.05-.23-1.41-.63l-.05-.06-.07-.04c-.65-.34-1.05-1-1.05-1.73 0-.3.07-.6.2-.87l.12-.25L1.15 7c-.13-.27-.2-.56-.2-.87 0-.9.61-1.68 1.48-1.89l.31-.08.05-.34a1.926 1.926 0 012.38-1.58l.32.08.18-.31c.35-.6.99-.97 1.67-.97.44 0 .86.15 1.2.42l-.36.36v-.01l-.25.26c-.33.27-.74.42-.89.4 0 0-.67-.1-.67-.11-.67-.13-.87.86-.14 1.02.01 0 .67.11.67.11.02 0 .05 0 .07.01-.11.37-.15.77-.1 1.12 0 0 .17.99.15.99.11.52 1.06.36.93-.18 0-.01-.15-.99-.15-.99-.05-.37.12-.94.36-1.19l.39-.4c.05-.05.1-.09.15-.14l.74-.76c.4-.18.83-.27 1.27-.27 1.55 0 2.86 1.12 3.11 2.67l.04.25.21.12c.61.35.98 1 .98 1.7 0 .36-.1.7-.28 1.01z"],prescription:["M10.91 8.34c.14-.21.36-.34.63-.34h1.29c.22 0 .41.07.52.26.09.16.08.33-.04.53l-2.49 2.87 2.77 3.54c.12.17.14.37.02.55-.11.17-.3.25-.5.25h-1.44a.69.69 0 01-.61-.35L9.4 13.51l-1.69 2.15c-.13.21-.36.34-.63.34H5.8c-.22 0-.41-.07-.52-.26-.09-.16-.08-.33.04-.53l2.71-3.48L4.3 6.99H3.03v3.47c0 .33-.26.56-.62.56h-.8c-.35-.01-.61-.23-.61-.56V.56c0-.33.26-.56.62-.56h3.11c.62 0 1.19.08 1.7.24.51.16.96.39 1.34.69a3.194 3.194 0 011.21 2.53c0 .81-.25 1.5-.74 2.08-.37.44-.84.77-1.42 1.01L7.88 7.9c.04.04.07.08.08.1l1.49 1.9 1.46-1.56zM5.18 5c.62 0 1.08-.13 1.39-.37.29-.23.44-.71.44-1.16s-.15-.87-.44-1.1C6.26 2.12 5.8 2 5.18 2H2.99v3h2.19z"],presentation:["M15 1H9c0-.55-.45-1-1-1S7 .45 7 1H1c-.55 0-1 .45-1 1s.45 1 1 1v8c0 .55.45 1 1 1h3.59L3.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 13.41V15c0 .55.45 1 1 1s1-.45 1-1v-1.59l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L10.41 12H14c.55 0 1-.45 1-1V3c.55 0 1-.45 1-1s-.45-1-1-1zm-2 9H3V3h10v7z"],print:["M12 2.02c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h8v-1zm3 2H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h1v-3h12v3h1c.55 0 1-.45 1-1v-6c0-.56-.45-1-1-1zm-1 3h-2v-1h2v1zm-3 6H5v-3H3v4c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-4h-2v3z"],projects:["M14 3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v1h12V3zm-2-3H4c-.55 0-1 .45-1 1h10c0-.55-.45-1-1-1zm3 5H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-3 6c0 .55-.45 1-1 1H5c-.55 0-1-.45-1-1V9h1v2h6V9h1v2z"],properties:["M2 6C.9 6 0 6.9 0 8s.9 2 2 2 2-.9 2-2-.9-2-2-2zm4-3h9c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1zm-4 9c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm13-5H6c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zm0 6H6c-.55 0-1 .45-1 1s.45 1 1 1h9c.55 0 1-.45 1-1s-.45-1-1-1zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],property:["M3 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-.5-6.5a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM7 3h8c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zm8 10H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zM3 0C1.9 0 1 .9 1 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 6H7c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"publish-function":["M12.16 3.76c.15-.11.3-.16.47-.16.06 0 .17.02.34.06.16.04.31.06.43.06a.58.58 0 00.6-.6c0-.19-.06-.33-.17-.44-.11-.11-.28-.16-.49-.16-.19 0-.37.04-.54.13-.17.09-.39.27-.65.55-.2.21-.48.58-.87 1.11a5.22 5.22 0 00-.78-1.79l-2.05.32-.04.21c.15-.03.28-.04.39-.04.2 0 .37.08.5.25.21.26.5 1.03.88 2.33-.29.36-.49.6-.6.71-.18.19-.33.31-.45.36-.09.04-.19.07-.3.07-.09 0-.23-.04-.42-.13a.904.904 0 00-.36-.09c-.2 0-.36.06-.49.18a.59.59 0 00-.19.46c0 .18.06.32.18.43.12.11.28.16.48.16.2 0 .38-.04.55-.12.17-.08.39-.24.65-.49s.62-.65 1.07-1.19c.18.52.33.89.46 1.13.13.24.28.4.44.51.17.1.37.16.62.16.24 0 .49-.08.74-.25.33-.21.66-.58 1.01-1.09l-.21-.11c-.23.31-.41.5-.52.57a.44.44 0 01-.26.07c-.12 0-.24-.07-.36-.21-.2-.24-.46-.91-.8-2 .29-.49.54-.81.74-.96zM6.37 5.83l.68-2.53h.83l.2-.64h-.84c.24-.91.56-1.59.96-2.01.24-.27.48-.4.71-.4.05 0 .08.01.11.04s.04.06.04.1c0 .04-.03.11-.1.21-.06.1-.1.2-.1.29 0 .13.05.24.15.33.1.09.23.14.39.14.17 0 .31-.06.42-.17.12-.12.18-.27.18-.46 0-.21-.08-.39-.25-.52C9.57.07 9.3 0 8.93 0c-.59 0-1.12.16-1.59.48-.48.32-.93.85-1.36 1.59-.15.26-.29.42-.42.49s-.35.11-.64.1l-.19.65h.81L4.35 7.68c-.2.72-.33 1.16-.4 1.33-.1.24-.26.45-.46.62a.48.48 0 01-.31.1c-.03 0-.06-.01-.08-.03l-.03-.03c0-.02.03-.06.09-.11.06-.06.09-.15.09-.26 0-.13-.05-.23-.14-.32-.1-.09-.23-.13-.41-.13-.21 0-.38.05-.51.16A.52.52 0 002 9.4c0 .16.08.3.23.42.16.12.4.18.74.18.53 0 .99-.13 1.4-.39.41-.26.76-.65 1.07-1.19.3-.53.61-1.39.93-2.59zm2.34 3.46A.997.997 0 008 9c-.28 0-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l.29-.3V15c0 .55.45 1 1 1s1-.45 1-1v-2.59l.29.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2z"],pulse:["M15 8h-1.46l-1.7-2.55-.02.01A.984.984 0 0011 5c-.43 0-.79.27-.93.65h-.01l-1.69 4.51-1.38-8.32h-.02A.989.989 0 006 1c-.41 0-.77.25-.92.61L2.34 8H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.41 0 .77-.25.92-.61l1.65-3.86 1.44 8.63h.02c.08.47.47.84.97.84.43 0 .79-.27.93-.65h.01l2.31-6.17.92 1.38.02-.01c.17.26.46.45.81.45h2c.55 0 1-.45 1-1s-.45-1-1-1z"],rain:["M3.5 8a2.5 2.5 0 11.608-4.926 4.002 4.002 0 017.381-1.03A3 3 0 1112 8H3.501zM3 10a1 1 0 012 0v4a1 1 0 11-2 0v-4zm7-1a1 1 0 00-1 1v5a1 1 0 102 0v-5a1 1 0 00-1-1zm2 1a1 1 0 112 0v2a1 1 0 11-2 0v-2zM7 9a1 1 0 00-1 1v2a1 1 0 102 0v-2a1 1 0 00-1-1z"],random:["M11.48 4h1.11l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H11c-.32 0-.59.16-.77.38l-.01-.01L8.28 4.8l1.28 1.6L11.48 4zm2.23 6.29a1.003 1.003 0 00-1.42 1.42l.3.29h-1.11l-7.7-9.62h-.01A.996.996 0 003 2H1c-.55 0-1 .45-1 1s.45 1 1 1h1.52l7.7 9.62.01-.01c.18.23.45.39.77.39h1.59l-.29.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2zM2.52 12H1c-.55 0-1 .45-1 1s.45 1 1 1h2c.32 0 .59-.16.77-.38l.01.01 1.94-2.42L4.44 9.6 2.52 12z"],record:["M8 3a5 5 0 100 10A5 5 0 108 3z"],rectangle:["M1 3h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1zm1 2v6h12V5H2z"],redo:["M12 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3.71-6.71l-3-3a1.003 1.003 0 00-1.42 1.42L12.59 4H5C2.24 4 0 6.24 0 9s2.24 5 5 5h4v-2H5c-1.66 0-3-1.34-3-3s1.34-3 3-3h7.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],refresh:["M14.99 6.99c-.55 0-1 .45-1 1 0 3.31-2.69 6-6 6-1.77 0-3.36-.78-4.46-2h1.46c.55 0 1-.45 1-1s-.45-1-1-1h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-1.74a7.95 7.95 0 006 2.74c4.42 0 8-3.58 8-8 0-.55-.45-1-1-1zm0-7c-.55 0-1 .45-1 1v1.74a7.95 7.95 0 00-6-2.74c-4.42 0-8 3.58-8 8 0 .55.45 1 1 1s1-.45 1-1c0-3.31 2.69-6 6-6 1.77 0 3.36.78 4.46 2h-1.46c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"regression-chart":["M13 6.5c0 .83.67 1.5 1.5 1.5S16 7.33 16 6.5 15.33 5 14.5 5 13 5.67 13 6.5zM8.5 5c.83 0 1.5-.67 1.5-1.5S9.33 2 8.5 2 7 2.67 7 3.5 7.67 5 8.5 5zM9 9.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5S11.33 8 10.5 8 9 8.67 9 9.5zM4.5 8C5.33 8 6 7.33 6 6.5S5.33 5 4.5 5 3 5.67 3 6.5 3.67 8 4.5 8zM15 12H3.26l12.03-8.59-.58-.81L2 11.67V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],remove:["M10.99 6.99h-6c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm-3-7c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.68 6-6 6z"],"remove-column":["M14 0H4c-.55 0-1 .45-1 1v3h2V2h3v12H5v-2H3v3c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14h-3V2h3v12zm-8.71-3.29a1.003 1.003 0 001.42-1.42L4.41 8 5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L3 6.59l-1.29-1.3A1.003 1.003 0 00.29 6.71L1.59 8 .29 9.29a1.003 1.003 0 001.42 1.42L3 9.41l1.29 1.3z"],"remove-column-left":["M4 9h4c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zm11-9H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 14H2V2h8v12zm4 0h-3V2h3v12z"],"remove-column-right":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 14H2V2h3v12zm9 0H6V2h8v12zM8 9h4c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-bottom":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V6h12v8zm0-9H2V2h12v3zm-8 6h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-top":["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2v-3h12v3zm0-4H2V2h12v8zM6 7h4c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1z"],repeat:["M10 5c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1s-1 .45-1 1v1.74A7.95 7.95 0 008 0C3.58 0 0 3.58 0 8c0 4.06 3.02 7.4 6.94 7.92.02 0 .04.01.06.01.33.04.66.07 1 .07 4.42 0 8-3.58 8-8 0-.55-.45-1-1-1s-1 .45-1 1c0 3.31-2.69 6-6 6-.71 0-1.37-.15-2-.38v.01C3.67 12.81 2 10.61 2 8c0-3.31 2.69-6 6-6 1.77 0 3.36.78 4.46 2H11c-.55 0-1 .45-1 1z"],reset:["M6 5c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v1.74A7.95 7.95 0 018 0c4.42 0 8 3.58 8 8 0 4.06-3.02 7.4-6.94 7.92-.02 0-.04.01-.06.01-.33.04-.66.07-1 .07-4.42 0-8-3.58-8-8 0-.55.45-1 1-1s1 .45 1 1c0 3.31 2.69 6 6 6 .71 0 1.37-.15 2-.38v.01c2.33-.82 4-3.02 4-5.63 0-3.31-2.69-6-6-6-1.77 0-3.36.78-4.46 2H5c.55 0 1 .45 1 1z"],resolve:["M6.6 3.3C6.1 3.1 5.6 3 5 3 2.2 3 0 5.2 0 8s2.2 5 5 5c.6 0 1.1-.1 1.6-.3C5.3 11.6 4.5 9.9 4.5 8s.8-3.6 2.1-4.7zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c-.6 0-1.1.1-1.6.3 1.3 1.2 2.1 2.9 2.1 4.7s-.8 3.6-2.1 4.7c.5.2 1 .3 1.6.3 2.8 0 5-2.2 5-5s-2.2-5-5-5z"],rig:["M5.71 3c0 1.1.96 2 2.14 2C9.04 5 10 3.96 10 3c0-1.96-1.47-3-2.14-3H5c0 1.96 2.68 1.4.71 3zm2.5 3l.01.01s0-.01-.01-.01zm6.5 8.29L10 9.59V7c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v2.58l-4.71 4.7c-.18.19-.29.44-.29.72a1.003 1.003 0 001.71.71L6 12.42V15c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.58l3.29 3.29a1.003 1.003 0 001.42-1.42z"],"right-join":["M6.6 3.3C5.3 4.4 4.5 6.1 4.5 8s.8 3.6 2.1 4.7c-.5.2-1 .3-1.6.3-2.8 0-5-2.2-5-5s2.2-5 5-5c.6 0 1.1.1 1.6.3zm-1.96 8.68C3.92 10.83 3.5 9.46 3.5 8s.42-2.83 1.14-3.98C2.6 4.2 1 5.91 1 8s1.6 3.8 3.64 3.98zM8 4c-1.2.9-2 2.4-2 4s.8 3.1 2 4c1.2-.9 2-2.3 2-4s-.8-3.1-2-4zm3-1c2.8 0 5 2.2 5 5s-2.2 5-5 5c-.6 0-1.1-.1-1.6-.3 1.3-1.1 2.1-2.9 2.1-4.7s-.8-3.5-2.1-4.7c.5-.2 1-.3 1.6-.3z"],ring:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 12c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],rocket:["M6 12C4.397 7.46 4.415 4.465 8 0c3.585 4.485 3.602 7.48 2 12H6zm3-7a1 1 0 11-2 0 1 1 0 012 0zm-7 8.022l3-1-.054-.158C4.636 10.954 4.076 9.317 4 8L3 9l-1 4.022zm9-1l3 1L13 9l-1-1c-.076 1.317-.635 2.954-.946 3.864l-.054.158zM7 13h2c0 1.5-.5 2.5-1 3-.5-.5-1-1.5-1-3z"],"rocket-slant":["M3.992 10c2-5 5-9 11-9 0 6-4 9-9 11l-2-2zm7.714-4.285a1 1 0 11-1.414-1.414 1 1 0 011.414 1.414zm-6.555-.218L2.992 6l-3 2L3.24 9.195c.542-1.301 1.166-2.556 1.911-3.698zM7.992 16l-1.236-3.232c1.3-.539 2.552-1.158 3.694-1.898L9.992 13l-2 3zm-4.931-4.94L5 13c-.992.991-2.186 1.154-3.001 1-.154-.815.07-1.948 1.06-2.94z"],"rotate-document":["M12 2h-1.59l.29-.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-2 2C7.11 2.47 7 2.72 7 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H12c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3zM5.71 5.29A.997.997 0 005 5H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V9c0-.28-.11-.53-.29-.71l-3-3zM7 14H2V7h2v2c0 .55.45 1 1 1h2v4z"],"rotate-page":["M8 6H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm-1 8H3V8h4v6zm5-12h-1.59l.29-.29c.19-.18.3-.43.3-.71A1.003 1.003 0 009.29.29l-2 2C7.11 2.47 7 2.72 7 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H12c.55 0 1 .45 1 1v3c0 .55.45 1 1 1s1-.45 1-1V5c0-1.66-1.34-3-3-3z"],route:["M11.669 5.066l.099.189c.113.213.236.434.367.661.226.39.468.78.709 1.151l-.198-.004-.48-.004c-1.745.003-2.369.233-2.369.688 0 .053.226.19 1.038.436l.84.24C13.9 9.064 15 9.83 15 11.63c0 2.123-1.607 3.122-4.027 3.366-.651.065-1.266.075-2.043.05l-.958-.035H5.196l.268-.406c.336-.517.672-1.052.998-1.593h1.636l.572.023c.857.036 1.475.034 2.103-.03 1.526-.153 2.227-.59 2.227-1.375 0-.531-.402-.84-1.66-1.22l-.691-.198c-1.04-.293-1.764-.562-2.222-.946C8.8 8.366 9 7.612 9 6.997a5.03 5.03 0 00-.184-1.334c.645-.395 1.598-.562 2.853-.597zM4 3a4.007 4.007 0 014 3.997C8 9.21 4 15 4 15l-.416-.62C2.56 12.827 0 8.767 0 6.997A4.002 4.002 0 014 3zm0 2a2 2 0 10.001 4.001A2 2 0 004 5zm10-4c1.103 0 1.996.896 2 1.999C16 4.105 14 7 14 7l-.293-.44C13.15 5.707 12 3.838 12 2.999 12 1.896 12.897 1 14 1z"],satellite:["M3 9c0-.6.4-1 1-1s1 .4 1 1c0 1.1.9 2 2 2 .6 0 1 .4 1 1s-.4 1-1 1c-2.2 0-4-1.8-4-4zM0 9c0-.6.4-1 1-1s1 .4 1 1c0 2.8 2.2 5 5 5 .6 0 1 .4 1 1s-.4 1-1 1c-3.9 0-7-3.1-7-7zm7 1c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1zm1.3-2.8c-.4-.4-.4-1 0-1.4l4.5-4.5c.4-.4 1-.4 1.4 0l.5.5c.4.4.4 1 0 1.4l-4.5 4.5c-.4.4-1 .4-1.4 0l-.5-.5zM5.2.3c.4-.4 1-.4 1.4 0l2.1 2.1c.4.4.4 1 0 1.4l-.9.9c-.4.4-1 .4-1.4 0L4.3 2.6c-.4-.4-.4-1 0-1.4l.9-.9zm7 7c.4-.4 1-.4 1.4 0l2.1 2.1c.4.4.4 1 0 1.4l-.9.9c-.4.4-1 .4-1.4 0l-2.1-2.1c-.4-.4-.4-1 0-1.4l.9-.9z"],saved:["M6.71 9.29a1.003 1.003 0 00-1.42 1.42l2 2a.997.997 0 001.6-.27h.01l2-4h-.01c.06-.13.11-.28.11-.44 0-.55-.45-1-1-1-.39 0-.72.23-.89.56H9.1l-1.38 2.76-1.01-1.03zM9 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5L9 0zm3 14H4V2h4v4h4v8z"],"scatter-plot":["M15 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm-.5-7c.83 0 1.5-.67 1.5-1.5S15.33 2 14.5 2 13 2.67 13 3.5 13.67 5 14.5 5zm-3 4c.83 0 1.5-.67 1.5-1.5S12.33 6 11.5 6 10 6.67 10 7.5 10.67 9 11.5 9zm-4-2C8.33 7 9 6.33 9 5.5S8.33 4 7.5 4 6 4.67 6 5.5 6.67 7 7.5 7zm-3 4c.83 0 1.5-.67 1.5-1.5S5.33 8 4.5 8 3 8.67 3 9.5 3.67 11 4.5 11z"],search:["M15.55 13.43l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"search-around":["M13.5 11c-.51 0-.98.15-1.38.42l-2.4-2.41c.17-.3.28-.64.28-1.01s-.11-.71-.28-1.01l2.41-2.41c.39.27.86.42 1.37.42a2.5 2.5 0 000-5A2.5 2.5 0 0011 2.5c0 .51.15.98.42 1.38l-2.41 2.4C8.71 6.11 8.37 6 8 6s-.71.11-1.01.28l-2.41-2.4c.27-.4.42-.87.42-1.38a2.5 2.5 0 00-5 0A2.5 2.5 0 002.5 5c.51 0 .98-.15 1.38-.42l2.41 2.41C6.11 7.29 6 7.63 6 8s.11.71.28 1.01l-2.41 2.41c-.39-.27-.86-.42-1.37-.42a2.5 2.5 0 000 5A2.5 2.5 0 005 13.5c0-.51-.15-.98-.42-1.38l2.41-2.41c.3.18.64.29 1.01.29s.71-.11 1.01-.28l2.41 2.41c-.27.39-.42.86-.42 1.37a2.5 2.5 0 005 0 2.5 2.5 0 00-2.5-2.5zm0-10c.83 0 1.5.67 1.5 1.5S14.33 4 13.5 4 12 3.33 12 2.5 12.67 1 13.5 1zm-11 3C1.67 4 1 3.33 1 2.5S1.67 1 2.5 1 4 1.67 4 2.5 3.33 4 2.5 4zm0 11c-.83 0-1.5-.67-1.5-1.5S1.67 12 2.5 12s1.5.67 1.5 1.5S3.33 15 2.5 15zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],"search-template":["M15.55 13.43l-2.67-2.67c.7-1.09 1.11-2.38 1.11-3.77 0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.41 3.77-1.11l2.67 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm2.5-6h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm0-2h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm0 4h-5c-.28 0-.5.22-.5.5s.22.5.5.5h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5z"],"search-text":["M9 4H5c-.55 0-1 .45-1 1s.45 1 1 1h1v3c0 .55.45 1 1 1s1-.45 1-1V6h1c.55 0 1-.45 1-1s-.45-1-1-1zm6.56 9.44l-2.67-2.67C13.59 9.68 14 8.39 14 7c0-3.87-3.13-7-7-7S0 3.13 0 7s3.13 7 7 7c1.39 0 2.68-.41 3.77-1.11l2.67 2.67a1.498 1.498 0 102.12-2.12zM7 12c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"segmented-control":["M15 4H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 6H8V6h6v4z"],select:["M16 15c0-.28-.12-.52-.31-.69l.02-.02-3.12-3.12 3.41-.84-8.05-2.86c.03-.09.05-.17.05-.27V2c0-.55-.45-1-1-1H3c0-.55-.45-1-1-1S1 .45 1 1c-.55 0-1 .45-1 1s.45 1 1 1v4c0 .55.45 1 1 1h5.2c.1 0 .18-.02.27-.05L10.33 16l.85-3.41 3.12 3.12.02-.02c.16.19.4.31.68.31.04 0 .07-.02.1-.02s.06.02.1.02c.44 0 .8-.36.8-.8 0-.04-.02-.07-.02-.1s.02-.06.02-.1zM6 6H3V3h3v3z"],selection:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm0-9C6.34 5 5 6.34 5 8s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"send-message":["M15.399 9.01L1.527 15.875c-.535.267-1.175.081-1.421-.427A.953.953 0 010 15V10l8-2-8-2V1c0-.528.407-1 1.004-1 .169 0 .416.04.567.116L15.403 7.07a1.084 1.084 0 01-.005 1.939z"],"send-to":["M15 7.5c-.8 0-1.5-.4-2-1l-1.2 1.2c-.4.5-1.1.7-1.8.7-1.4.1-2.5-1-2.5-2.4 0-.7.3-1.3.7-1.8L9.5 3c-.6-.5-1-1.2-1-2 0-.3.1-.7.2-1H8C3.6 0 0 3.6 0 8s3.6 8 8 8 8-3.6 8-8v-.7c-.3.1-.6.2-1 .2zM15 0h-4c-.6 0-1 .5-1 1s.4 1 1 1h1.6L9.3 5.3c-.2.2-.3.4-.3.7 0 .5.4 1 1 1 .3 0 .5-.1.7-.3L14 3.4V5c0 .6.4 1 1 1 .5 0 1-.4 1-1V1c0-.5-.4-1-1-1z"],"send-to-graph":["M6 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zm8 .5c-.56 0-1.06.23-1.42.59l-2.13-1.24L8.99 8l3.59-2.09A2.002 2.002 0 0016 4.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .19.03.37.08.54L8.5 7.13v-3.2c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S6 .9 6 2c0 .93.64 1.71 1.5 1.93v3.2l-.88-.52-2.7-1.57c.05-.17.08-.35.08-.54 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.56 0 1.06-.23 1.42-.59l2.13 1.24 3.84 2.24 2.7 1.57c-.06.17-.09.35-.09.54 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"send-to-map":["M6 9H2c-.55 0-1 .45-1 1s.45 1 1 1h1.59L.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L5 12.41V14c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1zm9.55-5.83l-4.49-3A.975.975 0 009.99.15L5.53 2.82 1.56.17A1.003 1.003 0 000 1v6h2V2.87l2.94 1.96.06.03V7h1V4.86s.01 0 .01-.01L10 2.47v8.67s-.01 0-.01.01l-.99.58v2.33l1.47-.88 3.97 2.65A1.003 1.003 0 0016 15V4c0-.35-.18-.65-.45-.83zM14 13.13l-2.94-1.96c-.02-.01-.04-.02-.05-.03v-8.6l3 2v8.59z"],"series-add":["M10.68 7.9c.44.54 1.07.92 1.79 1.05l-2.76 2.76c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l1.68-1.69zM15 3c.55 0 1 .45 1 1s-.45 1-1 1h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V5h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V2c0-.55.45-1 1-1s1 .45 1 1v1h1z"],"series-configuration":["M9.94 9.64c.65.23 1.34.36 2.06.36.14 0 .29-.01.43-.01L9.7 12.71c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.3L5 9.41l-3 3V14h12.99c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 7.11 4.72 7 5 7c.28 0 .53.11.71.29L9 10.59l.94-.95zm4.73-6.44h.92c.22 0 .4.18.4.4v.8c0 .22-.18.4-.4.4h-.93c-.06.2-.14.38-.24.55l.66.65c.15.15.15.4 0 .55l-.54.55c-.15.15-.4.15-.55 0l-.65-.65c-.17.1-.36.18-.55.24v.91c0 .22-.18.4-.4.4h-.8c-.22 0-.4-.18-.4-.4v-.93c-.18-.06-.36-.13-.52-.22l-.68.68c-.15.16-.41.16-.57 0l-.56-.56a.417.417 0 010-.57l.68-.68c-.08-.16-.16-.33-.22-.52h-.93c-.22 0-.4-.18-.4-.4v-.8c0-.22.18-.4.4-.4h.93c.06-.2.14-.38.24-.55l-.65-.64a.392.392 0 010-.55l.54-.55a.38.38 0 01.54 0l.65.65c.18-.1.36-.18.55-.24V.4c0-.22.18-.4.4-.4h.8c.22 0 .4.18.4.4v.93c.18.06.35.14.52.22l.68-.68c.15-.16.41-.16.57 0l.57.57c.15.16.15.41 0 .57l-.68.68c.09.16.16.33.22.51zm-4.18.8c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5-.67-1.5-1.5-1.5c-.82 0-1.5.67-1.5 1.5z"],"series-derived":["M10.66 7.92c.44.54 1.07.91 1.8 1.03L9.71 11.7c-.18.19-.43.3-.71.3s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l1.66-1.67zM12.3 5.3l.3-.3H8c-.6 0-1-.4-1-1s.4-1 1-1h4.6l-.3-.3c-.2-.2-.3-.4-.3-.7 0-.6.5-1 1-1 .3 0 .5.1.7.3l2 2c.2.2.3.4.3.7s-.1.5-.3.7l-2 2c-.2.2-.4.3-.7.3-.6 0-1-.4-1-1 0-.3.1-.5.3-.7z"],"series-filtered":["M9.29 9.3c.3.62.8 1.12 1.42 1.41l-1 1c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L5 8.41l-3 3V13h13c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1 .45 1 1v4.59l2.29-2.3C4.47 6.11 4.72 6 5 6s.53.11.71.29L9 9.59l.29-.29zM15.48 1c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V4.71L8.17 1.98A.566.566 0 018 1.57c0-.31.26-.57.57-.57h6.91z"],"series-search":["M9.6 8.94a4.937 4.937 0 001.82.01c.1-.01.22-.04.39-.08l.23-.07c.04-.01.08-.02.11-.04l.22.22-2.7 2.72c-.18.19-.43.3-.71.3s-.53-.11-.71-.3L4.98 8.41l-2.99 3V13h12.94c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V3.99c0-.55.45-1 1-1s1 .45 1 1v4.59l2.28-2.3c.17-.18.42-.29.7-.29s.53.11.7.29l3.28 3.3.64-.64zm6.22-.41c.1.12.17.27.18.44 0 .34-.27.61-.61.61a.57.57 0 01-.43-.18l-2.24-2.25c-.13.08-.26.16-.4.23-.02.01-.05.02-.07.03-.14.06-.27.12-.42.17h-.01c-.14.05-.29.08-.44.11-.04.01-.08.02-.11.02-.15.02-.3.04-.46.04-1.85 0-3.35-1.51-3.35-3.37S8.96 1.01 10.81 1c1.85 0 3.35 1.51 3.35 3.37 0 .16-.02.31-.04.47-.01.04-.01.07-.02.11-.02.15-.05.29-.1.44v.01c-.05.15-.11.28-.17.42-.01.02-.02.05-.03.07-.07.14-.14.27-.23.4l2.25 2.24zm-5.01-1.94c1.22 0 2.21-.99 2.21-2.22 0-1.23-.99-2.22-2.21-2.22S8.6 3.14 8.6 4.37c0 1.22.99 2.22 2.21 2.22z"],settings:["M3 1c0-.55-.45-1-1-1S1 .45 1 1v3h2V1zm0 4H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm12-4c0-.55-.45-1-1-1s-1 .45-1 1v2h2V1zM9 1c0-.55-.45-1-1-1S7 .45 7 1v6h2V1zM1 15c0 .55.45 1 1 1s1-.45 1-1v-5H1v5zM15 4h-2c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-2 11c0 .55.45 1 1 1s1-.45 1-1V9h-2v6zM9 8H7c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-2 7c0 .55.45 1 1 1s1-.45 1-1v-2H7v2z"],shapes:["M5.92 8.139c.44-.282 1.006-.121 1.264.358l2.689 4.988c.083.155.127.33.127.51C10 14.55 9.587 15 9.077 15H3.924a.864.864 0 01-.438-.12c-.449-.263-.617-.873-.376-1.362l2.465-4.989c.08-.162.2-.297.346-.39zM12 4a3 3 0 110 6 3 3 0 010-6zM6 1a1 1 0 011 1v4a1 1 0 01-1 1H2a1 1 0 01-1-1V2a1 1 0 011-1h4z"],share:["M10.99 13.99h-9v-9h4.76l2-2H.99c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h11c.55 0 1-.45 1-1V7.24l-2 2v4.75zm4-14h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L7.29 7.28a1 1 0 00-.3.71 1.003 1.003 0 001.71.71l5.29-5.29V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.56-.45-1.01-1-1.01z"],"shared-filter":["M13.843 15.163c.232.53.138.837.138.837H6.017s-.088-.308.138-.837c.226-.53 1.338-.88 2.079-1.206.735-.332.66-.53.685-.8 0-.03.006-.068.006-.105a2.171 2.171 0 01-.61-.892v-.006s-.006-.006-.006-.012c-.025-.074-.056-.16-.075-.24-.176-.031-.276-.222-.314-.394a.8.8 0 01-.1-.437c.025-.253.131-.37.244-.419v-.037c0-.313.032-.775.088-1.07A1.835 1.835 0 018.85 8.37c.315-.24.76-.37 1.156-.37.396 0 .842.13 1.156.37.301.233.534.56.64.935.026.08.045.166.057.246.057.295.088.75.088 1.064v.043c.113.05.214.167.232.413a.75.75 0 01-.1.437c-.038.172-.132.357-.301.387a1.77 1.77 0 01-.076.24.136.136 0 01-.006.025 2.346 2.346 0 01-.597.892v.111c.025.277-.075.474.666.8.741.326 1.853.67 2.079 1.2z","M14.852 15h1.131s.083-.27-.12-.732c-.16-.373-.82-.641-1.411-.88a15.328 15.328 0 01-.409-.17c-.565-.25-.57-.412-.577-.61-.001-.03-.002-.06-.005-.09v-.097c.22-.2.401-.469.522-.781 0 0 .005-.016.005-.022.028-.07.05-.14.066-.21.149-.026.231-.188.264-.339a.655.655 0 00.088-.382c-.016-.215-.104-.318-.203-.36v-.039c0-.274-.028-.673-.077-.931a1.598 1.598 0 00-.61-1.034 1.736 1.736 0 00-1.285-.3c.236.285.42.622.529.996.038.124.065.248.083.36.048.257.079.578.093.867a1.736 1.736 0 01.08 1.624 1.65 1.65 0 01-.217.453 1.42 1.42 0 01-.176.209c-.08.204-.178.4-.292.585l.202.083c.285.117.64.261.9.387.226.11.475.245.698.414.213.161.476.408.63.764.034.08.065.159.091.235zM12.14 14.12l.09.037zM11 1c.55 0 1 .45 1 1 0 .28-.11.53-.29.7L8 6.41v1.374a2.813 2.813 0 00-.833 1.589 6.925 6.925 0 00-.092.86 1.64 1.64 0 00-.25.739l-.001.004c-.02.217.006.413.046.573L5.71 12.71A1.003 1.003 0 014 12V6.41L.29 2.71A1.003 1.003 0 011 1h10z"],shield:["M8 16c4.667-3.048 7-7.238 7-12.571-1.556 0-3.889-1.143-7-3.429-3.111 2.286-5.444 3.429-7 3.429C1 8.762 3.333 12.952 8 16zM8 2.121c2.005 1.388 3.715 2.304 5.186 2.735-.342 3.702-2.05 6.683-5.186 9.038V2.121z"],ship:["M5.44.804L5.2 2H3a1 1 0 00-1 1v3.714l-1.08.309a.988.988 0 00-.69 1.192c.366 1.432.897 3.324 1.309 4.26a.644.644 0 00.005.01c-.175.01-.356.015-.544.015a.5.5 0 000 1c2.067 0 3.414-.543 4.161-.917.55.373 1.505.917 2.839.917 1.32 0 2.27-.533 2.822-.905l.004.002c.196.105.48.24.856.374.75.268 1.857.529 3.318.529a.5.5 0 000-1c-.295 0-.572-.012-.834-.032a.995.995 0 00.308-.458l1.208-3.74a1 1 0 00-.677-1.269L14 6.714V3a1 1 0 00-1-1h-2.2L10.56.804A1 1 0 009.58 0H6.42a1 1 0 00-.98.804zM4 6.143l3-.857V4H4v2.143zm5-.857l3 .857V4H9v1.286zm-4.036 8.273a.5.5 0 01.527.034c.455.325 1.277.907 2.509.907s2.054-.582 2.51-.907a.5.5 0 01.579-.001l.006.004.036.023c.034.022.09.055.168.097.154.082.394.197.72.313.649.232 1.642.471 2.981.471a.5.5 0 010 1c-1.46 0-2.568-.261-3.318-.53a6.316 6.316 0 01-.856-.373l-.004-.002c-.552.372-1.502.905-2.822.905-1.334 0-2.289-.544-2.839-.917-.747.374-2.094.917-4.161.917a.5.5 0 010-1c2.129 0 3.384-.63 3.964-.94z"],shop:["M3 2h10c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1s.45 1 1 1zm9 11H4v-3H2v5c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-5h-2v3zm4-6l-1.01-3.17C14.9 3.36 14.49 3 14 3H2c-.49 0-.9.36-.98.83L.01 7H0c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2c0 1.1.9 2 2 2s2-.9 2-2z"],"shopping-cart":["M14 10H7.72l-.33-1H13c.39 0 .72-.23.89-.56h.01l2-4h-.01c.06-.13.11-.28.11-.44 0-.55-.45-1-1-1H5.39l-.44-1.32h-.01C4.8 1.29 4.44 1 4 1H1c-.55 0-1 .45-1 1s.45 1 1 1h2.28l2.33 7H4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2h6c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zM6.05 5h7.33l-1 2H6.72l-.67-2z"],"signal-search":["M5.474 7.971A5.31 5.31 0 006.66 8.9l.007.019.018.056c.015.038.038.06.045.098l1.5 5.999a.75.75 0 01-1.455.36l-.42-1.68h-.704l-.42 1.68a.746.746 0 01-.907.547.746.746 0 01-.547-.907l1.5-6c.007-.037.03-.06.044-.097.015-.037.015-.075.038-.112a.722.722 0 01-.105-.36c0-.207.084-.394.22-.53zM2.795 5.277a.763.763 0 00-.015-1.065.756.756 0 00-1.065.015c-2.286 2.34-2.286 6.21 0 8.549a.747.747 0 101.072-1.042c-1.709-1.763-1.709-4.702.008-6.457zM7.808 9.388a5.318 5.318 0 001.58.211 2.236 2.236 0 01-.656.98.756.756 0 01-1.057-.098.756.756 0 01.097-1.057l.036-.036zM11.544 9.105l.378.378a6.02 6.02 0 01-1.638 3.285c-.285.3-.757.3-1.057.015a.74.74 0 01-.015-1.057 4.52 4.52 0 001.185-2.24c.4-.083.785-.212 1.147-.381z","M4.054 9.424c-.427-.352-.352-1.582-.03-1.822a.752.752 0 00.15-1.05.752.752 0 00-1.05-.15c-1.079.802-1.221 3.18-.03 4.177a.75.75 0 10.96-1.155zM9.318 0a4.318 4.318 0 014.317 4.318c0 .206-.02.402-.049.598-.01.05-.01.088-.02.138-.039.196-.078.382-.137.569v.01c-.059.186-.137.363-.216.54l-.039.087a5.285 5.285 0 01-.294.51l2.884 2.886a.878.878 0 01.236.559.787.787 0 01-.785.785.785.785 0 01-.56-.226L11.772 7.89a5.285 5.285 0 01-.51.295l-.089.039c-.176.079-.353.157-.54.216h-.01a3.701 3.701 0 01-.568.137c-.05.01-.099.02-.138.02-.196.03-.392.049-.598.049A4.318 4.318 0 015 4.327 4.332 4.332 0 019.318 0zm-.02 1.1A3.195 3.195 0 006.1 4.298a3.195 3.195 0 003.198 3.198 3.195 3.195 0 003.198-3.198A3.195 3.195 0 009.298 1.1z"],"sim-card":["M13.71 4.29l-4-4A.997.997 0 009 0H3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V5c0-.28-.11-.53-.29-.71zM7 6h2v2H7V6zM4 6h2v2H4V6zm2 8H4v-2h2v2zm3 0H7v-2h2v2zm3 0h-2v-2h2v2zm0-3H4V9h8v2zm0-3h-2V6h2v2z"],slash:["M10 2a.99.99 0 00-.96.73l-2.99 9.96A1.003 1.003 0 007 14c.46 0 .85-.31.96-.73l2.99-9.96A1.003 1.003 0 0010 2z"],"small-cross":["M9.41 8l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42L6.59 8 4.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z"],"small-minus":["M11 7H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-plus":["M11 7H9V5c0-.55-.45-1-1-1s-1 .45-1 1v2H5c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V9h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-square":["M5 5v6h6V5H5zM4 3a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V4a1 1 0 00-1-1H4z"],"small-tick":["M12 5c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z"],snowflake:["M13.364 9l.879.879a1 1 0 11-1.415 1.414l-2.12-2.121A1.003 1.003 0 0110.568 9H9v1.604c.042.03.083.065.121.103l2.122 2.121a1 1 0 01-1.415 1.415L9 13.414V15a1 1 0 01-2 0v-1.636l-.879.879a1 1 0 11-1.414-1.415l2.121-2.12c.054-.054.111-.1.172-.139V9H5.38c-.038.06-.084.118-.137.172l-2.122 2.12A1 1 0 111.707 9.88L2.586 9H1a1 1 0 110-2h1.536l-.829-.828a1 1 0 011.414-1.415L5.243 6.88c.038.038.072.079.103.121H7V5.38a1.003 1.003 0 01-.172-.137L4.708 3.12A1 1 0 016.12 1.707L7 2.586V1a1 1 0 112 0v1.536l.828-.829a1 1 0 011.415 1.414L9.12 5.243A1.007 1.007 0 019 5.346V7h1.604c.03-.042.065-.083.103-.121l2.121-2.122a1 1 0 011.415 1.415L13.414 7H15a1 1 0 010 2h-1.636z"],"social-media":["M9.5 4c.4 0 .8-.1 1.1-.3C12 4.5 12.9 6 13 7.6c0 .5.5.9 1 .9.6 0 1-.4 1-1v-.2c-.2-2.4-1.5-4.4-3.5-5.5-.1-1-.9-1.8-2-1.8s-2 .9-2 2 .9 2 2 2zM4 8.5c0-.7-.4-1.3-.9-1.7.3-1.4 1.2-2.6 2.5-3.3.3-.1.6-.4.6-.9s-.4-1-1-1c-.2 0-.3 0-.5.1-1.9 1-3.2 2.8-3.6 5C.4 7.1 0 7.8 0 8.5c0 1.1.9 2 2 2s2-.9 2-2zm8.8 1.2c-1.1 0-2 .9-2 2v.3c-.8.6-1.8.9-2.8.9-1.2 0-2.3-.4-3.2-1.1-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.6.3.8C4.6 14.4 6.2 15 8 15c1.5 0 3-.5 4.1-1.3.2.1.5.1.7.1 1.1 0 2-.9 2-2s-.9-2.1-2-2.1z"],sort:["M5 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm3-9h7c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm7 2H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0 8H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-alphabetical":["M6 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 002 12a1.003 1.003 0 00-.71 1.71l2 2c.19.18.44.29.71.29.28 0 .53-.11.71-.29l2-2c.18-.18.29-.43.29-.71a.99.99 0 00-1-1zm7.93-.95v-1.04H9.25v1.11h2.94L9 14.96V16h5.02v-1.11h-3.27l3.18-3.84zm-1.42-4.84l.62 1.78H15L11.94.01H10.1L7 7.99h1.81l.64-1.78h3.06zm-1.52-4.24h.02l1.03 2.93H9.92l1.07-2.93z"],"sort-alphabetical-desc":["M5.99 11.99c-.28 0-.53.11-.71.29l-.29.29V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l2-2c.18-.18.29-.43.29-.71 0-.56-.45-1.01-1-1.01zM12.7 10h-1.38L9 15.99h1.36l.48-1.33h2.3l.46 1.33H15L12.7 10zm-1.51 3.67l.8-2.2h.02l.77 2.2h-1.59zm3.8-7.17h-4.57l4.45-5.12V0H8.34v1.48h4.1L7.99 6.59v1.39h7V6.5z"],"sort-asc":["M8 7h3c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h1c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm0 8h5c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm-3 1c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm10 1H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-desc":["M5 12c-.28 0-.53.11-.71.29l-.29.3V9c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29A.965.965 0 001 12a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 005 12zm4 1H8c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H8c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm-2 4H8c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H8c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"sort-numerical":["M6 11.99c-.28 0-.53.11-.71.29l-.29.3V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l2-2A1.003 1.003 0 006 11.99zm7.91-.08c-.06-.36-.17-.68-.33-.96-.16-.28-.37-.51-.64-.69-.27-.17-.61-.26-1.03-.26-.28 0-.54.06-.78.17-.23.11-.43.26-.6.45-.17.19-.3.41-.39.67a2.492 2.492 0 00-.04 1.52 1.623 1.623 0 00.89 1.03c.22.11.45.16.68.16.26 0 .5-.05.7-.15s.38-.26.53-.5l.02.02c-.01.16-.03.34-.07.54-.03.2-.09.4-.17.57-.08.18-.18.33-.31.45s-.29.19-.5.19a.63.63 0 01-.48-.21c-.13-.14-.21-.31-.25-.5H10.1c.03.25.1.48.19.68.1.2.22.37.38.5.16.14.33.24.54.31s.42.1.65.1c.39 0 .72-.09.99-.27.27-.18.49-.41.66-.7.17-.29.29-.61.37-.97.08-.36.12-.72.12-1.07 0-.36-.03-.72-.09-1.08zm-1.14.54c-.04.13-.09.24-.16.34a.78.78 0 01-.27.24c-.11.06-.24.09-.39.09a.75.75 0 01-.37-.09.777.777 0 01-.26-.25c-.07-.1-.12-.22-.15-.35-.03-.13-.05-.26-.05-.4 0-.13.02-.26.05-.39.04-.13.09-.24.16-.34.07-.1.16-.18.26-.24s.22-.09.35-.09c.14 0 .26.03.37.09.11.06.2.14.28.24a1.32 1.32 0 01.23.74c0 .15-.02.28-.05.41zm-1.56-4.47H13V0h-1.42c-.05.3-.16.56-.31.76-.16.21-.35.37-.58.5-.23.13-.49.21-.78.26-.3.05-.6.07-.91.06V2.8h2.21v5.18z"],"sort-numerical-desc":["M6 11.99c-.28 0-.53.11-.71.29l-.29.3V8.99c0-.55-.45-1-1-1s-1 .45-1 1v3.59l-.29-.29a.982.982 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 006 11.99zm7.86-9.45c-.09-.48-.26-.9-.5-1.28S12.8.58 12.4.35C12 .12 11.49 0 10.86 0c-.43 0-.82.07-1.17.22s-.65.35-.9.6-.44.55-.58.89c-.14.34-.2.71-.2 1.11 0 .31.05.61.15.91.1.3.26.57.48.8.23.24.52.43.85.58.33.14.68.21 1.03.21.4 0 .75-.07 1.05-.2.3-.13.57-.35.79-.66l.02.02c-.02.21-.05.45-.1.73-.05.27-.13.53-.25.76-.12.24-.27.44-.47.6-.19.16-.44.25-.75.25a.98.98 0 01-.72-.29c-.19-.18-.31-.4-.37-.66H8.15c.05.34.14.64.29.9.15.26.34.49.57.67.23.18.5.32.8.41.31.1.63.15.98.15.58 0 1.08-.12 1.48-.36.4-.24.73-.55.99-.93.26-.39.44-.82.56-1.29.12-.48.18-.96.18-1.44s-.05-.96-.14-1.44zm-1.71.72c-.05.17-.14.32-.24.46-.11.13-.24.24-.41.31-.16.08-.36.12-.58.12-.21 0-.39-.04-.55-.13-.16-.08-.29-.19-.39-.33-.12-.14-.19-.29-.24-.46-.05-.17-.08-.35-.08-.54 0-.18.03-.35.08-.52.06-.16.14-.31.25-.44.11-.13.24-.24.4-.32.16-.08.33-.12.52-.12.21 0 .4.04.56.12.16.08.3.19.41.32.11.14.2.29.26.46.06.17.09.35.09.52 0 .2-.03.38-.08.55zm-.46 7.31c-.12.15-.26.28-.44.37-.17.09-.37.16-.58.2-.22.04-.44.05-.67.05v.92h1.65v3.88h1.33V10h-1.06c-.03.23-.11.42-.23.57z"],"split-columns":["M12 10a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H9V2h3v1.71c.31-.13.64-.21 1-.21s.69.08 1 .21V1c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2.71c.31-.13.64-.21 1-.21s.69.08 1 .21V2h3v5H3.41l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C.11 7.47 0 7.72 0 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 9H7v5H4v-1.71c-.31.13-.64.21-1 .21s-.69-.08-1-.21V15c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-2.71c-.31.13-.64.21-1 .21s-.69-.08-1-.21V14H9V9h3.59l-.29.29c-.19.18-.3.43-.3.71z"],square:["M15 0H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H2V2h12v12z"],"stacked-chart":["M10 2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3h3V2zm3 10h1c.55 0 1-.45 1-1V8h-3v3c0 .55.45 1 1 1zm2-7c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v2h3V5zm-5 1H7v3h3V6zM5 7c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v1h3V7zm3 5h1c.55 0 1-.45 1-1v-1H7v1c0 .55.45 1 1 1zm7 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h1c.55 0 1-.45 1-1V9H2v2c0 .55.45 1 1 1z"],"stadium-geometry":["M12 6H4a2 2 0 100 4h8a2 2 0 100-4zM4 4a4 4 0 100 8h8a4 4 0 000-8H4z"],star:["M8 0l2.5 5.3 5.5.8-4 4.1.9 5.8L8 13.3 3.1 16l.9-5.8-4-4.1 5.5-.8z"],"star-empty":["M16 6.11l-5.53-.84L8 0 5.53 5.27 0 6.11l4 4.1L3.06 16 8 13.27 12.94 16 12 10.21l4-4.1zM4.91 13.2l.59-3.62L3 7.02l3.45-.53L8 3.2l1.55 3.29 3.45.53-2.5 2.56.59 3.62L8 11.49 4.91 13.2z"],"step-backward":["M12 3c-.24 0-.44.09-.62.23l-.01-.01L7 6.72V4c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V9.28l4.38 3.5.01-.01c.17.14.37.23.61.23.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"step-chart":["M15 12H2v-2h3c.55 0 1-.45 1-1V7h2v1c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h-2V6c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v2H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"step-forward":["M12 3h-1c-.55 0-1 .45-1 1v2.72l-4.38-3.5v.01A.987.987 0 005 3c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1 .24 0 .44-.09.62-.23l.01.01L10 9.28V12c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stop:["M12 3H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h8c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stopwatch:["M9 2v1.083A6.002 6.002 0 018 15 6 6 0 017 3.083V2H6a1 1 0 110-2h4a1 1 0 010 2H9zM8 5a4 4 0 104 4H8V5z"],strikethrough:["M14 7H8.65c-.38-.09-.73-.18-1.04-.26-.31-.08-.49-.13-.54-.14-.43-.11-.79-.29-1.05-.52-.27-.23-.4-.55-.4-.95 0-.29.07-.53.21-.72s.32-.34.54-.46c.22-.11.46-.19.72-.24.26-.05.52-.07.77-.07.74 0 1.36.15 1.84.46.32.2.55.5.68.9h2.22c-.06-.33-.17-.64-.32-.92-.25-.45-.59-.84-1.02-1.15-.43-.31-.93-.54-1.49-.7S8.59 2 7.95 2c-.55 0-1.1.07-1.63.2-.54.13-1.02.34-1.45.62-.42.28-.76.63-1.02 1.05-.26.42-.39.92-.39 1.5 0 .3.04.59.13.88.08.26.21.51.39.75H2c-.55 0-1 .45-1 1s.45 1 1 1h7.13c.25.07.49.14.71.22.25.09.48.23.7.44.21.21.32.53.32.97 0 .21-.05.43-.14.63-.09.21-.24.39-.45.55-.21.16-.48.29-.81.39-.33.1-.73.15-1.2.15-.44 0-.84-.05-1.21-.14-.37-.09-.7-.24-.99-.43-.29-.2-.51-.45-.67-.76-.01 0-.01-.01-.02-.02H3.14a3.68 3.68 0 001.39 2.03c.46.34 1 .58 1.62.74.61.15 1.27.23 1.97.23.61 0 1.2-.07 1.79-.2.58-.13 1.11-.34 1.56-.63.46-.29.83-.66 1.11-1.11.28-.45.42-1 .42-1.64 0-.3-.05-.6-.15-.9-.05-.19-.13-.36-.22-.52H14c.55 0 1-.45 1-1s-.45-1-1-1z"],style:["M14 14H2V2h8.76l2-2H1C.45 0 0 .45 0 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6.24l-2 2V14zm1.4-14L9.7 5.7l2.1 2.1L16 3.6V0h-.6zM4 11.92c2.33.15 4.42.15 6.15-1.5.82-.83.82-2.25 0-3.08-.45-.38-.98-.6-1.5-.6-.53 0-1.05.22-1.43.6-.82.91-1.27 3.38-3.22 4.58z"],"swap-horizontal":["M0 7.02L.05 7H0v.02zm2-2.03h9.57l-1.29 1.29A1.003 1.003 0 0011.7 7.7l2.99-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2.99-3a1.07 1.07 0 00-.71-.28 1.003 1.003 0 00-.71 1.71L11.57 3H2c-.55 0-1 .45-1 1a1 1 0 001 .99zM15.96 9H16v-.02l-.04.02zM14 11.01H4.43l1.29-1.29A1.003 1.003 0 004.3 8.3l-2.99 3a.99.99 0 00-.29.7c0 .28.11.53.29.71l2.99 3a1.003 1.003 0 001.42-1.42L4.43 13H14c.55 0 1-.45 1-1s-.45-.99-1-.99z"],"swap-vertical":["M9 0h-.02L9 .04V0zM7 16h.02L7 15.95V16zM4.7 1.31c-.18-.18-.43-.29-.7-.29s-.53.11-.71.29l-3 2.99a1.003 1.003 0 001.42 1.42L3 4.43V14c0 .55.45 1 1 1s1-.45 1-1V4.43l1.29 1.29c.18.18.43.29.7.29A1.003 1.003 0 007.7 4.3l-3-2.99zM15 9.99c-.28 0-.53.11-.71.29L13 11.57V2c0-.55-.45-1-1-1s-1 .45-1 1v9.57l-1.29-1.29a.99.99 0 00-.7-.29 1.003 1.003 0 00-.71 1.71l3 2.99c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-2.99c.18-.18.29-.43.29-.71-.01-.55-.46-1-1.01-1z"],switch:["M9.293 2.293l1.414 1.414-4.999 5a3 3 0 11-1.415-1.415l5-5zM13 7a3 3 0 110 6 3 3 0 010-6zM3 9a1 1 0 100 2 1 1 0 000-2zm10 0a1 1 0 100 2 1 1 0 000-2z"],"symbol-circle":["M8 3.01a5 5 0 100 10 5 5 0 100-10z"],"symbol-cross":["M12 6.01h-2v-2c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v2H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2h2c.55 0 1-.45 1-1v-2c0-.56-.45-1-1-1z"],"symbol-diamond":["M12 8.01c0-.19-.07-.36-.16-.51l.01-.01-3-5-.01.01c-.17-.29-.48-.49-.84-.49s-.67.2-.84.49l-.02-.01-3 5 .02.01c-.09.15-.16.32-.16.51s.07.36.16.51h-.02l3 5 .01-.01c.18.29.49.5.85.5s.67-.2.84-.49l.01.01 3-5-.01-.01c.09-.16.16-.32.16-.51z"],"symbol-rectangle":["M13 4H3c-.5 0-1 .5-1 1v6c0 .5.5 1 1 1h10c.5 0 1-.5 1-1V5c0-.5-.5-1-1-1z"],"symbol-square":["M12 3.01H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-8c0-.56-.45-1-1-1z"],"symbol-triangle-down":["M13 4.01c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1 0 .16.05.31.11.44H3.1l4 8h.01c.16.33.49.56.89.56s.72-.23.89-.56h.01l4-8h-.01c.06-.14.11-.28.11-.44z"],"symbol-triangle-up":["M12.89 11.56l-3.99-8h-.01c-.17-.32-.5-.55-.89-.55s-.72.23-.89.55H7.1l-4 8h.01c-.06.14-.11.29-.11.45 0 .55.45 1 1 1h8c.55 0 1-.45 1-1 0-.16-.05-.31-.11-.45z"],syringe:["M11.146.146a.5.5 0 000 .708l.647.646L10.5 2.793 8.854 1.146a.5.5 0 10-.708.708l.647.646-1.146 1.146-5.5 5.5a.5.5 0 000 .708l.646.646-1.647 1.646a.5.5 0 000 .708l.647.646-1.647 1.646a.5.5 0 00.708.708L2.5 14.207l.646.647a.5.5 0 00.708 0L5.5 13.207l.646.647a.5.5 0 00.708 0l5.5-5.5L13.5 7.207l.646.647a.5.5 0 00.708-.708L13.207 5.5 14.5 4.207l.646.647a.5.5 0 00.708-.708l-4-4a.5.5 0 00-.708 0zM11.293 8l-.793.793-1.646-1.647a.5.5 0 10-.708.708L9.793 9.5 8.5 10.793 6.854 9.146a.5.5 0 10-.708.708L7.793 11.5 6.5 12.793 3.207 9.5 8 4.707 11.293 8zM8.707 4L12 7.293l.793-.793L9.5 3.207 8.707 4zm-6.5 8.5L3.5 13.793 4.793 12.5 3.5 11.207 2.207 12.5zm11.586-9L12.5 2.207 11.207 3.5 12.5 4.793 13.793 3.5z"],tag:["M1 3a2 2 0 012-2h4.584a2 2 0 011.414.586l5.413 5.412a2 2 0 010 2.829L9.827 14.41a2 2 0 01-2.829 0L1.586 8.998A2 2 0 011 7.584V3zm3.487-.007a1.494 1.494 0 100 2.988 1.494 1.494 0 000-2.988z"],"take-action":["M9 11a1.003 1.003 0 001.71.71l4-4a1.003 1.003 0 00-1.42-1.42l-4 4c-.18.18-.29.43-.29.71zM4 6c.28 0 .53-.11.71-.29l4-4A1.003 1.003 0 007.29.29l-4 4A1.003 1.003 0 004 6zm4 4l5-5-.79-.79.5-.5a1.003 1.003 0 00-1.42-1.42l-.5.5L10 2 5 7l.79.79-5.5 5.5a1.003 1.003 0 001.42 1.42l5.5-5.5L8 10zm7 4H7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],tank:["M3.7 3.4a1 1 0 01.8-.4h5.086a1 1 0 01.707.293L11 4h3a1 1 0 110 2h-3v1h2.5a2.5 2.5 0 010 5h-11a2.5 2.5 0 010-5H3V4.667a1 1 0 01.2-.6l.5-.667zM2.5 9h11a.5.5 0 010 1h-11a.5.5 0 110-1z"],target:["M7 4a1 1 0 012 0v2a1 1 0 01-2 0V4zM10 7a1 1 0 000 2h2a1 1 0 000-2h-2zM3 8a1 1 0 011-1h2a1 1 0 010 2H4a1 1 0 01-1-1zM8 9a1 1 0 00-1 1v2a1 1 0 002 0v-2a1 1 0 00-1-1z","M8 16A8 8 0 108 0a8 8 0 000 16zm0-2A6 6 0 108 2a6 6 0 000 12z"],taxi:["M15.12 6.63h-.38L15 7c-.01.3-.01.64 0 .98V8c0 .07-.03.13-.04.19h.02L14 13.1v.9c0 .55-.45 1-1 1s-1-.45-1-1v-1H4v1c0 .55-.45 1-1 1s-1-.45-1-1v-.9l-.98-4.9h.02C1.03 8.13 1 8.07 1 8H.99c0-.33 0-.67.01-1l.26-.37H.88C.4 6.63 0 6.21 0 5.69s.4-.94.88-.94h1.05l.77-2.11c.19-.53.76-1.08 1.26-1.24 0 0 .68-.2 2.05-.32C6.01 1.05 6 1.03 6 1c0-.55.45-1 1-1h2c.55 0 1 .45 1 1 0 .03-.01.05-.02.08 1.37.12 2.05.32 2.05.32.51.15 1.08.71 1.27 1.24l.76 2.12h1.05c.49 0 .89.42.89.93 0 .52-.4.94-.88.94zM11 10h2V8h-2v2zm-8 0h2V8H3v2zm10-5l-.73-1.63C12.21 3.19 12.18 3 12 3H4c-.18 0-.21.19-.27.37L3 5c-.06.18-.18 1 0 1h10c.18 0 .06-.82 0-1z"],temperature:["M8.5 0A1.5 1.5 0 007 1.5v7.837a3.5 3.5 0 103 0V1.5A1.5 1.5 0 008.5 0zM2 5.5a.5.5 0 01.5-.5h3a.5.5 0 010 1h-3a.5.5 0 01-.5-.5zM2.5 1a.5.5 0 000 1h3a.5.5 0 000-1h-3zM4 3.5a.5.5 0 01.5-.5h1a.5.5 0 010 1h-1a.5.5 0 01-.5-.5zM4.5 7a.5.5 0 000 1h1a.5.5 0 000-1h-1z"],"text-highlight":["M9 10H2V6h7V4H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h8v-2zm4 3h-1V3h1c.55 0 1-.45 1-1s-.45-1-1-1h-1c-.37 0-.7.11-1 .28-.3-.17-.63-.28-1-.28H9c-.55 0-1 .45-1 1s.45 1 1 1h1v10H9c-.55 0-1 .45-1 1s.45 1 1 1h1c.37 0 .7-.11 1-.28.3.17.63.28 1 .28h1c.55 0 1-.45 1-1s-.45-1-1-1zm2-9h-2v2h1v4h-1v2h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],th:["M15 1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1zM6 13H2v-2h4v2zm0-3H2V8h4v2zm0-3H2V5h4v2zm8 6H7v-2h7v2zm0-3H7V8h7v2zm0-3H7V5h7v2z"],"th-derived":["M5.6 10l-.3.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l2-2c.2-.2.3-.4.3-.7s-.1-.5-.3-.7l-2-2C6.5 6.1 6.3 6 6 6c-.5 0-1 .4-1 1 0 .3.1.5.3.7l.3.3H1c-.6 0-1 .4-1 1s.4 1 1 1h4.6zM15 1H2c-.5 0-1 .5-1 1v5h2V5h11v2H8.8l.6.6c.1.1.2.3.3.4H14v2H9.7c-.1.1-.2.3-.3.4l-.6.6H14v2H3v-2H1v3c0 .5.5 1 1 1h13c.6 0 1-.5 1-1V2c0-.5-.4-1-1-1z"],"th-disconnect":["M12 1h3c.6 0 1 .5 1 1v12c0 .6-.4 1-1 1h-4.97l.286-2H14v-2h-3.398l.143-1H14V8h-2.97l.143-1H14V5h-2.541l.51-3.576C11.99 1.282 12 1.14 12 1zM5.97 1l-.572 4H2v2h3.112L4.97 8H2v2h2.684l-.143 1H2v2h2.255l-.225 1.576c-.02.142-.03.284-.03.424H1c-.6 0-1-.4-1-1V2c0-.5.4-1 1-1h4.97zM8.01.859a1 1 0 111.98.282l-2 14a1 1 0 11-1.98-.282l2-14z"],"th-filtered":["M10 10h3l1.78-2.226a1 1 0 00.22-.625V4.3l1-.9V14c0 .6-.4 1-1 1H1c-.6 0-1-.4-1-1V2c0-.5.4-1 1-1h4.333L9 4.3V5H7v2h2v1H7v2h3zm-4 3v-2H2v2h4zm0-3V8H2v2h4zm0-3V5H2v2h4zm8 6v-2H7v2h7z","M15.48 0c.31 0 .52.26.52.57 0 .16-.06.3-.17.41l-2.86 2.73v2.63c0 .16-.06.3-.17.41l-.82 1.1c-.1.1-.25.17-.41.17-.31 0-.57-.26-.57-.57V3.71L8.17.98A.566.566 0 018 .57c0-.31.26-.57.57-.57h6.91z"],"th-list":["M15 1H1c-.6 0-1 .5-1 1v12c0 .6.4 1 1 1h14c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1zm-1 12H2v-2h12v2zm0-3H2V8h12v2zm0-3H2V5h12v2z"],"third-party":["M4.448 9h.573c.025-.044.051-.088.079-.13A9.43 9.43 0 015.183 8h-.995A10.424 10.424 0 014 6c0-.717.068-1.391.188-2h3.624c.065.33.114.678.146 1.042A3.42 3.42 0 018.46 5c.168 0 .336.013.502.037A11.089 11.089 0 008.829 4h1.755c.148.338.26.696.33 1.068l.176-.028a2.74 2.74 0 01.5 0c.113 0 .225.006.336.018A6.001 6.001 0 000 6a6 6 0 005.672 5.991 4 4 0 01-.202-.441 1.842 1.842 0 01-.24-.26 1.82 1.82 0 01-.26-.55 2 2 0 01-.185-.92l-.012-.025A6.036 6.036 0 014.448 9zM3.171 8H1.416A4.983 4.983 0 011 6c0-.711.148-1.388.416-2h1.755C3.06 4.626 3 5.299 3 6c0 .701.06 1.374.17 2zM2 9H3.4c.18.618.412 1.167.685 1.62A5.015 5.015 0 012 9zm2.448-6h3.104a6.036 6.036 0 00-.325-.795C6.737 1.225 6.246 1 6 1c-.246 0-.737.225-1.227 1.205-.119.238-.228.504-.325.795zm4.15 0H10a5.016 5.016 0 00-2.086-1.62c.273.453.506 1.002.685 1.62zM4.087 1.38A6.834 6.834 0 003.401 3H2a5.015 5.015 0 012.086-1.62zM13.476 16s.118-.385-.172-1.046c-.228-.533-1.172-.915-2.015-1.257a22.113 22.113 0 01-.584-.243c-.808-.356-.816-.588-.825-.872-.002-.041-.003-.084-.007-.128v-.139c.314-.284.573-.669.745-1.115 0 0 .008-.023.008-.03.04-.1.071-.2.095-.3.212-.04.33-.27.377-.485.054-.093.149-.3.125-.547-.024-.307-.15-.453-.29-.515v-.054c0-.392-.04-.961-.11-1.33a2.16 2.16 0 00-.071-.308 2.283 2.283 0 00-.8-1.17C9.558 6.162 9.001 6 8.506 6c-.495 0-1.052.162-1.445.462A2.294 2.294 0 006.19 7.93c-.07.369-.11.946-.11 1.338v.046c-.14.062-.274.208-.306.523a1 1 0 00.126.547c.047.215.173.453.393.492.02.083.05.172.078.253l.016.047c0 .008.008.015.008.015v.008c.172.454.44.846.761 1.115a.804.804 0 01-.004.072c-.002.02-.004.04-.004.06l-.007.105c-.016.287-.028.523-.848.894-.176.078-.37.156-.568.237-.847.345-1.802.735-2.031 1.27C3.41 15.616 3.52 16 3.52 16h9.955zm2.503-1.25h-1.413a4.05 4.05 0 00-.116-.294c-.192-.445-.52-.753-.787-.955-.278-.21-.59-.38-.873-.517a21.373 21.373 0 00-1.122-.483l-.02-.008-.235-.097c.144-.23.266-.476.366-.731.089-.087.162-.177.22-.26.132-.192.217-.391.271-.568.117-.251.24-.64.199-1.105a2.025 2.025 0 00-.299-.925 8.626 8.626 0 00-.116-1.083 3.426 3.426 0 00-.104-.45 3.476 3.476 0 00-.661-1.246A2.18 2.18 0 0111.63 6c.432 0 .92.141 1.264.404.33.256.584.612.7 1.023.028.087.049.182.062.27.062.322.097.82.097 1.163v.048c.123.053.233.181.254.45a.82.82 0 01-.11.478c-.041.189-.144.391-.33.425a1.92 1.92 0 01-.082.262c0 .007-.007.027-.007.027-.151.39-.378.727-.653.976v.121c.004.038.005.075.006.111v.002c.008.247.015.451.722.762.158.07.332.14.51.213.739.299 1.565.634 1.764 1.1.254.579.151.915.151.915z"],"thumbs-down":["M2 2H0v7h2c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm13.99 4.38c.08-.58-.44-1.02-1.15-1.05-.25-.01-.52-.03-.81-.05.02 0 .05-.01.07-.01.7-.1 1.34-.49 1.41-1.07.06-.58-.46-.97-1.17-1.04-.25-.02-.52-.04-.79-.06.47-.15.84-.42.87-.93.04-.58-.79-1.03-1.5-1.09-.27-.02-.51-.04-.73-.05h-.09c-.23-.02-.43-.02-.62-.03C8.35.95 5.66 1.47 4 2.51v6c2.14 1.29 4.76 3.59 4.21 5.51-.18.59.31 1.05.98.98.81-.09 1.37-.91 1.4-1.78.04-1-.15-2.01-.5-2.91-.04-.25.01-.5.37-.53.49-.03 1.11-.06 1.59-.08.26 0 .51-.01.75-.02h.01c.41-.02.8-.05 1.13-.09.7-.09 1.35-.47 1.43-1.05.08-.58-.44-.97-1.15-1.05-.05-.01-.11-.01-.16-.02.17-.01.33-.03.49-.05.72-.08 1.37-.46 1.44-1.04z"],"thumbs-up":["M15.99 9.62c-.08-.58-.73-.96-1.43-1.05-.15-.02-.32-.04-.49-.05.06-.01.11-.01.16-.02.71-.08 1.23-.47 1.15-1.05-.08-.58-.73-.96-1.43-1.05-.34-.04-.72-.07-1.13-.09h-.01c-.24-.01-.49-.02-.75-.02-.48-.02-1.11-.04-1.59-.08-.36-.03-.41-.28-.37-.53.35-.9.54-1.91.5-2.91-.04-.85-.6-1.68-1.41-1.77-.67-.07-1.16.39-.99.98C8.76 3.91 6.13 6.2 4 7.49v6c1.66 1.03 4.35 1.56 7.48 1.5.19 0 .39-.01.62-.02h.09c.22-.01.46-.03.73-.05.71-.06 1.54-.51 1.5-1.09-.03-.51-.4-.79-.87-.93.27-.02.54-.04.79-.06.71-.06 1.24-.45 1.17-1.04-.06-.58-.7-.97-1.41-1.07-.02 0-.05-.01-.07-.01.29-.02.57-.03.81-.05.71-.03 1.23-.47 1.15-1.05zM2 7H0v7h2c.55 0 1-.45 1-1V8c0-.56-.45-1-1-1z"],tick:["M14 3c-.28 0-.53.11-.71.29L6 10.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29s.53-.11.71-.29l8-8A1.003 1.003 0 0014 3z"],"tick-circle":["M8 16c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm4-11c-.28 0-.53.11-.71.29L7 9.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l5-5A1.003 1.003 0 0012 5z"],time:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm1-6.41V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L9 7.59z"],"timeline-area-chart":["M15 2.59L9.91 7.68 6.6 5.2l-.01.01C6.42 5.09 6.23 5 6 5c-.24 0-.44.09-.62.23v-.01L3 7.12V11h12V2.59zM15 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"timeline-bar-chart":["M8 12h1c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1zm5 0h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm2 1H2c-.55 0-1 .45-1 1s.45 1 1 1h13c.55 0 1-.45 1-1s-.45-1-1-1zM3 12h1c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1z"],"timeline-events":["M8 11H7v1h1v-1zm-4 0H3v1h1v-1zm7-8c.6 0 1-.5 1-1V1c0-.5-.4-1-1-1s-1 .5-1 1v1c0 .5.5 1 1 1zM4 3c.5 0 1-.5 1-1V1c0-.5-.5-1-1-1S3 .5 3 1v1c0 .5.5 1 1 1zm10-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H6v1c0 1.1-.9 2-2 2s-2-.9-2-2V1H1c-.5 0-1 .5-1 1v12c0 .5.5 1 1 1h13c.6 0 1-.5 1-1V2c0-.5-.4-1-1-1zM5 13H2v-3h3v3zm0-4H2V6h3v3zm4 4H6v-3h3v3zm0-4H6V6h3v3zm4 4h-3v-3h3v3zm0-4h-3V6h3v3zm-1-2h-1v1h1V7z"],"timeline-line-chart":["M15 12H2V9.41l3-3L8.29 9.7c.18.19.43.3.71.3s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L9 7.59l-3.29-3.3C5.53 4.11 5.28 4 5 4s-.53.11-.71.29L2 6.59V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],tint:["M7.88 1s-4.9 6.28-4.9 8.9c.01 2.82 2.34 5.1 4.99 5.1 2.65-.01 5.03-2.3 5.03-5.13C12.99 7.17 7.88 1 7.88 1z"],torch:["M5 15c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H5v1zm7-15H4c-.55 0-1 .45-1 1v1h10V1c0-.55-.45-1-1-1zM5 7v6h6V7l2-4H3l2 4zm2 0c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1V7z"],tractor:["M3.5 9a3.5 3.5 0 110 7 3.5 3.5 0 010-7zm9.5 1a3 3 0 110 6 3 3 0 010-6zm-9.5 1a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm9.5 1a1 1 0 100 2 1 1 0 000-2zM5 0c1.46 0 2.527.668 3 2l.815 3.255a78.9 78.9 0 012.186.195L11 2h2l.001 3.688c.698.095 1.37.198 2.013.312.623.11.986.479.986 1v3.354a4.001 4.001 0 00-6.873 1.645H7.999l-.026-.002A4.5 4.5 0 00.659 9.01l-.654.001v-.829C.003 7.386.002 6.423 0 6.022 0 5.5.376 4.99 1 4.99V1a1 1 0 011-1h3zm1 2H3v2.99c1.29.024 2.554.069 3.781.135L6 2z"],train:["M13 14h-1l1 2H3l1-2H3c-1.1 0-2-.9-2-2V2C1 .9 4.13 0 8 0s7 .9 7 2v10c0 1.1-.9 2-2 2zm-2-2h2v-2h-2v2zM9 7h4V3H9v4zm-6 5h2v-2H3v2zm0-5h4V3H3v4z"],translate:["M15.89 14.56l-3.99-8h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56h-.01L9 8.76 7.17 7.38l.23-.18C8.37 6.47 9 5.31 9 4V3h1c.55 0 1-.45 1-1s-.45-1-1-1H7c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1H1c-.55 0-1 .45-1 1s.45 1 1 1h6v1c0 .66-.32 1.25-.82 1.61l-.68.51-.68-.5C4.32 5.25 4 4.66 4 4H2c0 1.31.63 2.47 1.6 3.2l.23.17L1.4 9.2l.01.01C1.17 9.4 1 9.67 1 10c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01 2.9-2.17 2.6 1.95-1.99 3.98h.01c-.07.13-.12.28-.12.44 0 .55.45 1 1 1 .39 0 .72-.23.89-.56h.01L8.62 14h4.76l.72 1.45h.01c.17.32.5.55.89.55.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44zM9.62 12L11 9.24 12.38 12H9.62z"],trash:["M14.49 3.99h-13c-.28 0-.5.22-.5.5s.22.5.5.5h.5v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10h.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zm-8.5 9c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm3 0c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm3 0c0 .55-.45 1-1 1s-1-.45-1-1v-6c0-.55.45-1 1-1s1 .45 1 1v6zm2-12h-4c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1h-4c-.55 0-1 .45-1 1v1h14v-1c0-.55-.45-1-1-1z"],tree:["M9 11.857V16H7v-4.143L1 13l3.885-4.44L3 9l3.07-4.297L5 5l3-5 3 5-1.07-.297L13 9l-1.885-.44L15 13l-6-1.143z"],"trending-down":["M15 7c-.55 0-1 .45-1 1v.59l-4.29-4.3A.997.997 0 009 4c-.16 0-.31.05-.44.11V4.1L5 5.88 1.45 4.11v.01C1.31 4.05 1.16 4 1 4c-.55 0-1 .45-1 1 0 .39.23.72.56.89v.01l4 2v-.01c.13.06.28.11.44.11s.31-.05.44-.11v.01L8.8 6.22 12.59 10H12c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1z"],"trending-up":["M15 4h-3c-.55 0-1 .45-1 1s.45 1 1 1h.59L8.8 9.78 5.45 8.11v.01C5.31 8.05 5.16 8 5 8s-.31.05-.44.11V8.1l-4 2v.01c-.33.17-.56.5-.56.89 0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L5 10.12l3.55 1.78v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L14 7.41V8c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1z"],truck:["M12.5 0a.5.5 0 01.5.5V9a1 1 0 011 1v2h.5a.5.5 0 01.5.5v1a.5.5 0 01-.5.5H13v1a1 1 0 01-2 0v-1H5v1a1 1 0 01-2 0v-1H1.5a.5.5 0 01-.5-.5v-1a.5.5 0 01.5-.5H2v-2a1 1 0 011-1V.5a.5.5 0 011 0V3a2 2 0 012-2h4a2 2 0 012 2V.5a.5.5 0 01.5-.5zM9 8H7a1 1 0 00-1 1v2a1 1 0 001 1h2a1 1 0 001-1V9a1 1 0 00-1-1zm3.5 3h-1a.5.5 0 100 1h1a.5.5 0 100-1zm-8 0h-1a.5.5 0 100 1h1a.5.5 0 100-1zM9 9a.5.5 0 01.5.5v1l-.008.09A.5.5 0 019 11H7l-.09-.008a.5.5 0 01-.41-.492v-1l.008-.09A.5.5 0 017 9zm2-5H5v2h6V4z"],"two-columns":["M3.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1zm11.71 7.3l-2-2a1.003 1.003 0 00-1.71.71v4a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71s-.11-.53-.29-.71zM9.99-.01h-3c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-14c0-.55-.45-1-1-1z"],unarchive:["M13.382 0a1 1 0 01.894.553L16 4v11a1 1 0 01-1 1H1a1 1 0 01-1-1V4L1.724.553A1 1 0 012.618 0h10.764zM8 6c-.28 0-.53.11-.71.29l-2 2-.084.096A1.003 1.003 0 006.71 9.71l.29-.3V12l.007.116c.058.496.482.884.993.884.55 0 1-.45 1-1V9.41l.29.29.081.076A.97.97 0 0010 10a1.003 1.003 0 00.71-1.71l-2-2-.096-.084A1.002 1.002 0 008 6zm5-4H3L2 4h12l-1-2z"],underline:["M8 14c2.8 0 5-2.2 5-5V3c0-.6-.4-1-1-1s-1 .4-1 1v6c0 1.7-1.3 3-3 3s-3-1.3-3-3V3c0-.6-.4-1-1-1s-1 .4-1 1v6c0 2.8 2.2 5 5 5zM13.5 15h-11c-.3 0-.5.2-.5.5s.2.5.5.5h11c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"],undo:["M4 11c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm7-7H3.41L4.7 2.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 4.47 0 4.72 0 5c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 6H11c1.66 0 3 1.34 3 3s-1.34 3-3 3H7v2h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"],"ungroup-objects":["M3.5 5C1.57 5 0 6.57 0 8.5S1.57 12 3.5 12 7 10.43 7 8.5 5.43 5 3.5 5zm9 0C10.57 5 9 6.57 9 8.5s1.57 3.5 3.5 3.5S16 10.43 16 8.5 14.43 5 12.5 5z"],"unknown-vehicle":["M10.507 9.75v-3.5c0-.089.023-.171.051-.25h-7.55c-.176 0-.061-.824 0-1l.729-1.63c.06-.177.095-.37.27-.37h4.5V1.01c-.166-.003-.32-.01-.5-.01-2.72 0-4.036.402-4.036.402-.508.155-1.079.711-1.268 1.237L1.94 4.756H.887c-.483 0-.88.423-.88.939s.397.939.88.939h.376L1.008 7c-.034.685 0 1.436 0 2v5c0 .657.384 1 1 1s1-.343 1-1v-1h10v1c0 .657.383 1 1 1s1-.343 1-1v-3.5h-3.75a.75.75 0 01-.75-.75zm-5.5.25h-2V8h2v2zm11-4.305zM15.34.826a2.807 2.807 0 00-.932-.598c-.386-.16-.868-.241-1.445-.241-.447 0-.851.076-1.213.228-.362.153-.67.364-.926.636s-.456.592-.598.963a3.535 3.535 0 00-.218 1.144V3h1.789c.003-.208.023-.405.069-.588.049-.193.124-.362.225-.506.102-.144.232-.259.39-.345.159-.087.348-.13.567-.13.325 0 .58.09.762.272.183.18.275.46.275.839.008.222-.031.407-.116.555a1.654 1.654 0 01-.335.408 7.4 7.4 0 01-.452.37c-.162.123-.316.27-.463.438a2.556 2.556 0 00-.384.611c-.11.239-.177.535-.2.889V6h1.645v-.1c.032-.248.111-.453.237-.618.126-.164.27-.31.433-.438.163-.128.335-.255.518-.383a2.413 2.413 0 00.878-1.117c.102-.255.152-.58.152-.975A2.241 2.241 0 0015.34.826zM12.007 7v2h2V7h-2z"],unlock:["M11.99-.01c-2.21 0-4 1.79-4 4v3h-7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1h-3v-3c0-1.1.9-2 2-2s2 .9 2 2v1c0 .55.45 1 1 1s1-.45 1-1v-1c0-2.21-1.79-4-4-4z"],unpin:["M9.39 1c-.5.5-.4 1.48.15 2.53L4.38 7.54C2.85 6.5 1.52 6.07 1 6.59l3.5 3.5c-.02.02-1.4 2.8-1.4 2.8l2.8-1.4 3.5 3.5c.53-.53.1-1.86-.95-3.38l4.02-5.16c1.04.55 2.01.65 2.51.14L9.39 1z"],unresolve:["M11 3c-.55 0-1.07.09-1.57.26a6.46 6.46 0 010 9.48c.5.17 1.02.26 1.57.26 2.76 0 5-2.24 5-5s-2.24-5-5-5zM9.78 9.38l.09-.27c.08-.36.13-.73.13-1.11s-.05-.75-.13-1.11l-.09-.27a5.32 5.32 0 00-.29-.79l-.12-.21c-.14-.27-.31-.52-.51-.76a.7.7 0 00-.08-.1c-.24-.27-.49-.52-.78-.74-.43-.32-.92-.58-1.45-.75l.01-.01c-.1-.03-.2-.05-.3-.08-.12-.03-.23-.07-.36-.09A5.28 5.28 0 005 3C2.24 3 0 5.24 0 8s2.24 5 5 5c.31 0 .61-.04.9-.09.12-.02.24-.06.36-.09.1-.03.21-.04.3-.08l-.01-.01c.88-.29 1.64-.8 2.22-1.49.03-.03.06-.07.09-.1.19-.24.36-.49.51-.76.04-.07.08-.14.11-.21.13-.25.23-.52.3-.79z"],updated:["M8 0a7.95 7.95 0 00-6 2.74V1c0-.55-.45-1-1-1S0 .45 0 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.54C4.64 2.78 6.22 2 8 2c3.31 0 6 2.69 6 6 0 2.61-1.67 4.81-4 5.63-.63.22-1.29.37-2 .37-3.31 0-6-2.69-6-6 0-.55-.45-1-1-1s-1 .45-1 1c0 4.42 3.58 8 8 8 .34 0 .67-.03 1-.07.02 0 .04-.01.06-.01C12.98 15.4 16 12.06 16 8c0-4.42-3.58-8-8-8zm3 5c-.28 0-.53.11-.71.29L7 8.58 5.71 7.29a1.003 1.003 0 00-1.42 1.42l2 2c.18.18.43.29.71.29.28 0 .53-.11.71-.29l4-4A1.003 1.003 0 0011 5z"],upload:["M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm3 8c-.28 0-.53-.11-.71-.29L9 6.41V12c0 .55-.45 1-1 1s-1-.45-1-1V6.41l-1.29 1.3a1.003 1.003 0 01-1.42-1.42l3-3C7.47 3.11 7.72 3 8 3s.53.11.71.29l3 3A1.003 1.003 0 0111 8z"],user:["M7.99-.01A7.998 7.998 0 00.03 8.77c.01.09.03.18.04.28.02.15.04.31.07.47.02.11.05.22.08.34.03.13.06.26.1.38.04.12.08.25.12.37.04.11.08.21.12.32a6.583 6.583 0 00.3.65c.07.14.14.27.22.4.04.07.08.13.12.2l.27.42.1.13a7.973 7.973 0 003.83 2.82c.03.01.05.02.07.03.37.12.75.22 1.14.29l.2.03c.39.06.79.1 1.2.1s.81-.04 1.2-.1l.2-.03c.39-.07.77-.16 1.14-.29.03-.01.05-.02.07-.03a8.037 8.037 0 003.83-2.82c.03-.04.06-.08.09-.13.1-.14.19-.28.28-.42.04-.07.08-.13.12-.2.08-.13.15-.27.22-.41.04-.08.08-.17.12-.26.06-.13.11-.26.17-.39.04-.1.08-.21.12-.32.04-.12.08-.24.12-.37.04-.13.07-.25.1-.38.03-.11.06-.22.08-.34.03-.16.05-.31.07-.47.01-.09.03-.18.04-.28.02-.26.04-.51.04-.78-.03-4.41-3.61-7.99-8.03-7.99zm0 14.4c-1.98 0-3.75-.9-4.92-2.31.67-.36 1.49-.66 2.14-.95 1.16-.52 1.04-.84 1.08-1.27.01-.06.01-.11.01-.17-.41-.36-.74-.86-.96-1.44v-.01c0-.01-.01-.02-.01-.02-.05-.13-.09-.26-.12-.39-.28-.05-.44-.35-.5-.63-.06-.11-.18-.38-.15-.69.04-.41.2-.59.38-.67v-.06c0-.51.05-1.24.14-1.72.02-.13.05-.26.09-.39.17-.59.53-1.12 1.01-1.49.49-.38 1.19-.59 1.82-.59.62 0 1.32.2 1.82.59.48.37.84.9 1.01 1.49.04.13.07.26.09.4.09.48.14 1.21.14 1.72v.07c.18.08.33.26.37.66.03.31-.1.58-.16.69-.06.27-.21.57-.48.62-.03.13-.07.26-.12.38 0 .01-.01.04-.01.04-.21.57-.54 1.06-.94 1.42 0 .06.01.13.01.19.04.43-.12.75 1.05 1.27.65.29 1.47.6 2.14.95a6.415 6.415 0 01-4.93 2.31z"],variable:["M3.94 3.15c.47-.66 1.05-1.24 1.76-1.73l.13-.4c-1.11.45-2.05 1.01-2.84 1.7-1.02.88-1.8 1.9-2.32 3.05C.22 6.76 0 7.75 0 8.75c0 1.75.66 3.5 1.99 5.25l.13-.42c-.39-.94-.59-1.82-.59-2.63 0-1.28.22-2.64.67-4.1.45-1.45 1.03-2.69 1.74-3.7zm7.51 6.41l-.27-.15c-.3.41-.52.66-.66.77-.09.06-.21.1-.33.1-.15 0-.3-.1-.45-.28-.25-.33-.59-1.22-1.01-2.69.38-.65.69-1.08.95-1.28.19-.15.39-.22.59-.22.08 0 .22.03.43.08.2.06.39.08.54.08.22 0 .4-.07.54-.22.15-.15.22-.34.22-.57 0-.25-.07-.45-.22-.59-.15-.15-.35-.22-.63-.22-.24 0-.47.06-.69.17-.21.11-.49.36-.82.74-.25.28-.61.78-1.1 1.48a6.72 6.72 0 00-.97-2.38l-2.59.44-.05.27c.19-.04.36-.06.49-.06.26 0 .47.11.64.33.26.34.63 1.38 1.11 3.12-.37.49-.63.81-.77.96-.23.24-.41.4-.56.47-.11.06-.24.09-.39.09-.11 0-.29-.06-.53-.18-.17-.07-.32-.11-.45-.11-.25 0-.46.08-.62.24-.16.16-.24.37-.24.61 0 .23.08.42.23.57.15.15.35.22.61.22.25 0 .48-.05.7-.15.22-.1.49-.32.82-.65.33-.33.78-.86 1.36-1.59.22.69.42 1.19.58 1.51.16.31.35.54.56.68.21.14.47.21.79.21.31 0 .62-.11.93-.33.4-.29.82-.77 1.26-1.47zm2.56-8.54l-.12.42c.39.95.59 1.82.59 2.64 0 1.09-.17 2.26-.5 3.51-.26.96-.6 1.87-1.02 2.71-.42.85-.82 1.51-1.21 1.98-.39.48-.87.92-1.44 1.32l-.14.4c1.11-.45 2.05-1.02 2.84-1.7 1.03-.89 1.81-1.91 2.33-3.05.44-.99.66-1.99.66-3 0-1.73-.66-3.48-1.99-5.23z"],"vertical-bar-chart-asc":["M6 7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1zM2 9c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm8-5c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1zm4-4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],"vertical-bar-chart-desc":["M6 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1zM2 0c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm8 7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1s1-.45 1-1V8c0-.55-.45-1-1-1zm4 2c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1z"],"vertical-distribution":["M1 2h14c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1zm14 11H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM3 5c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1H3z"],video:["M15 2H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM5 11V5l6 3-6 3z"],virus:["M11.918 11.107l.737.737.052-.051A1 1 0 0114.2 13.12l-.078.087-1.414 1.414a1 1 0 01-1.492-1.327l.029-.033-.863-.863c-.426.231-.89.402-1.38.502L9 14l.117.007A1 1 0 019 16H7l-.117-.007A1 1 0 017 14v-1.1a4.967 4.967 0 01-1.447-.539l-.846.846.078.087a1 1 0 01-1.492 1.327l-1.414-1.414-.078-.087a1 1 0 011.492-1.327l.744-.744A4.986 4.986 0 013.23 9.5H2a1 1 0 01-1.993.117L0 9.5v-2a1 1 0 011.993-.117L2 7.5h1.025a4.973 4.973 0 01.905-2.405l-.512-.513-.125.125A1 1 0 011.8 3.38l.078-.087 1.414-1.414a1 1 0 011.529 1.277l.573.575a4.969 4.969 0 011.604-.63V2l-.116-.007a1 1 0 010-1.986L7 0h2a1 1 0 01.117 1.993L9 2l.001 1.1c.639.13 1.233.381 1.757.73l.535-.537-.078-.087a1 1 0 011.492-1.327l1.414 1.414.078.087a1 1 0 01-1.492 1.327l-.535.536a4.97 4.97 0 01.803 2.257H14l.007-.117A1 1 0 0116 7.5v2l-.007.117A1 1 0 0114 9.5h-1.229a4.987 4.987 0 01-.853 1.607zM10 9a1 1 0 100 2 1 1 0 000-2zM6.5 5a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"],"volume-down":["M9 2c-.28 0-.53.11-.71.29L5.59 5H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm3.57 1.44l-1.59 1.22C11.62 5.61 12 6.76 12 8s-.38 2.39-1.02 3.34l1.59 1.22C13.47 11.27 14 9.7 14 8c0-1.7-.53-3.27-1.43-4.56z"],"volume-off":["M11 2c-.28 0-.53.11-.71.29L7.59 5H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],"volume-up":["M7 1.86c-.28 0-.53.11-.71.29l-2.7 2.71H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2.59l2.71 2.71a1.003 1.003 0 001.71-.71v-10c-.01-.55-.46-1-1.01-1zm6.74-.99l-1.58 1.22A9.985 9.985 0 0114 7.86c0 2.16-.69 4.15-1.85 5.78l1.58 1.22c1.42-1.97 2.26-4.38 2.26-7 .01-2.61-.84-5.02-2.25-6.99zM8.98 4.52C9.62 5.48 10 6.63 10 7.86s-.38 2.39-1.02 3.34l1.59 1.22c.9-1.29 1.43-2.86 1.43-4.56 0-1.7-.53-3.27-1.43-4.56L8.98 4.52z"],walk:["M13 8h-2c-.16 0-.31-.05-.44-.11v.01l-1.02-.51-.37 1.86 1.38.92-.01.02c.27.17.46.46.46.81v4c0 .55-.45 1-1 1s-1-.45-1-1v-3.46l-1.27-.85-1.8 4.67h-.01A.98.98 0 015 16c-.55 0-1-.45-1-1 0-.13.03-.25.07-.36h-.01L7.39 6H5.62l-.73 1.45h-.01C4.72 7.77 4.39 8 4 8c-.55 0-1-.45-1-1 0-.16.05-.31.11-.44H3.1l1-2h.01c.17-.33.5-.56.89-.56h3.16l.29-.75C8.17 2.9 8 2.47 8 2c0-1.1.9-2 2-2s2 .9 2 2c0 1-.73 1.82-1.69 1.97l-.5 1.32 1.43.71H13c.55 0 1 .45 1 1s-.45 1-1 1z"],"warning-sign":["M15.84 13.5l.01-.01-7-12-.01.01c-.17-.3-.48-.5-.85-.5s-.67.2-.85.5l-.01-.01-7 12 .01.01c-.09.15-.15.31-.15.5 0 .55.45 1 1 1h14c.55 0 1-.45 1-1 0-.19-.06-.35-.15-.5zm-6.85-.51h-2v-2h2v2zm0-3h-2v-5h2v5z"],"waterfall-chart":["M8 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm-4 4h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1zm7-6c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1s-1 .45-1 1v1c0 .55.45 1 1 1zm4-3h-1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 10H2V3c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],waves:["M3 1a1 1 0 01.894.553c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.173.344.38.75.637 1.072.277.347.437.375.469.375a1 1 0 110 2c-.968 0-1.642-.64-2.03-1.125a4.755 4.755 0 01-.076-.097 6.093 6.093 0 01-.221.212C12.175 4.442 11.393 5 10.5 5c-.892 0-1.675-.558-2.173-1.01A6.243 6.243 0 018 3.67c-.105.11-.214.217-.327.32C7.175 4.442 6.393 5 5.5 5c-.892 0-1.675-.558-2.173-1.01a6.119 6.119 0 01-.221-.212l-.075.097C2.64 4.36 1.968 5 1 5a1 1 0 010-2c.032 0 .191-.028.47-.375.256-.321.463-.728.636-1.072A1 1 0 013 1zm0 5a1 1 0 01.894.553c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.102.202.393.607.779.957.419.381.72.49.827.49.108 0 .408-.109.827-.49.386-.35.677-.755.779-.957a1 1 0 011.788 0c.173.344.38.75.637 1.072.277.347.437.375.469.375a1 1 0 110 2c-.968 0-1.642-.639-2.03-1.125a4.726 4.726 0 01-.076-.097 6.093 6.093 0 01-.221.212c-.498.452-1.28 1.01-2.173 1.01-.892 0-1.675-.558-2.173-1.01A6.243 6.243 0 018 8.67c-.105.11-.214.217-.327.32C7.175 9.442 6.393 10 5.5 10c-.892 0-1.675-.558-2.173-1.01a6.119 6.119 0 01-.221-.212l-.075.097C2.64 9.36 1.968 10 1 10a1 1 0 010-2c.032 0 .191-.028.47-.375.256-.321.463-.728.636-1.072A1 1 0 013 6zm.894 5.553a1 1 0 00-1.788 0c-.173.344-.38.75-.637 1.072-.278.347-.437.375-.469.375a1 1 0 100 2c.968 0 1.642-.639 2.03-1.125a4.9 4.9 0 00.076-.097c.072.073.146.143.221.212.498.452 1.28 1.01 2.173 1.01.892 0 1.675-.558 2.173-1.01.113-.103.222-.21.327-.32.105.11.214.217.327.32.498.452 1.28 1.01 2.173 1.01.892 0 1.675-.558 2.173-1.01.075-.069.149-.14.221-.212a4.9 4.9 0 00.075.097C13.36 14.36 14.032 15 15 15a1 1 0 100-2c-.032 0-.191-.028-.47-.375-.256-.321-.463-.728-.636-1.072a1 1 0 00-1.788 0c-.102.202-.393.607-.779.957-.419.381-.72.49-.827.49-.108 0-.408-.109-.827-.49-.386-.35-.677-.755-.779-.957a1 1 0 00-1.788 0c-.102.202-.393.607-.779.957-.419.381-.72.49-.827.49-.108 0-.408-.109-.827-.49-.386-.35-.677-.755-.779-.957z"],widget:["M13 11h2V5h-2v6zM3 5H1v6h2V5zm11-1c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM5 3h6V1H5v2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3 15h6v-2H5v2z"],"widget-button":["M1 3h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1zm1 2v6h12V5H2zm3 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm3 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"widget-footer":["M14 0H2c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H3v-3h10v3zm0-4H3V2h10v8z"],"widget-header":["M14 0H2c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 14H3V6h10v8zm0-9H3V2h10v3z"],wind:["M10 4a2 2 0 112 2H4a1 1 0 000 2h8a4 4 0 10-4-4 1 1 0 002 0zM1 9a1 1 0 100 2h7.5a1.5 1.5 0 010 3c-.749 0-1.386-.538-1.52-1.199a1 1 0 10-1.96.398C5.35 14.82 6.83 16 8.5 16a3.5 3.5 0 100-7H1z"],wrench:["M15.83 3.7l-3.06 3.05-2.84-.7-.7-2.83L12.29.17a5.004 5.004 0 00-4.83 1.29 4.967 4.967 0 00-1.12 5.36L.58 12.58c-.36.36-.58.86-.58 1.41 0 1.1.9 2 2 2 .55 0 1.05-.22 1.41-.59l5.77-5.77c1.79.69 3.91.33 5.35-1.12 1.32-1.3 1.74-3.15 1.3-4.81z"],"zoom-in":["M7.99 5.99v-2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2zm7.56 7.44l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"zoom-out":["M3.99 5.99c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1h-6zm11.56 7.44l-2.67-2.68a6.94 6.94 0 001.11-3.76c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.39 0 2.68-.42 3.76-1.11l2.68 2.67a1.498 1.498 0 102.12-2.12zm-8.56-1.44c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"zoom-to-fit":["M11 10a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42L12.59 8 11.3 9.29c-.19.18-.3.43-.3.71zM1 5c.55 0 1-.45 1-1V2h2c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v3c0 .55.45 1 1 1zm4 1a1.003 1.003 0 00-1.71-.71l-2 2C1.11 7.47 1 7.72 1 8c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L3.41 8 4.7 6.71c.19-.18.3-.43.3-.71zm1-1c.28 0 .53-.11.71-.29L8 3.41 9.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C8.53 1.11 8.28 1 8 1s-.53.11-.71.29l-2 2A1.003 1.003 0 006 5zm9 6c-.55 0-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1zm0-11h-3c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zM4 14H2v-2c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .55.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm6-3c-.28 0-.53.11-.71.29L8 12.59 6.71 11.3A.965.965 0 006 11a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 0010 11z"]},JS={add:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm5-9h-4V5c0-.55-.45-1-1-1s-1 .45-1 1v4H5c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1v-4h4c.55 0 1-.45 1-1s-.45-1-1-1z"],"add-clip":["M15 0a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0V6h-3a1 1 0 110-2h3V1a1 1 0 011-1zM1 4a1 1 0 00-1 1v4a1 1 0 002 0V6h3a1 1 0 000-2H1zM0 19a1 1 0 001 1h4a1 1 0 100-2H2v-3a1 1 0 10-2 0v4zm15 1h-4a1 1 0 110-2h3v-3a1 1 0 112 0v4a1 1 0 01-1 1zm-7-5a3 3 0 100-6 3 3 0 000 6z"],"add-column-left":["M4 11h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1H8V7c0-.55-.45-1-1-1s-1 .45-1 1v2H4c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-7 18H2V2h10v16zm6 0h-5V2h5v16z"],"add-column-right":["M10 11h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V7c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1zm9-11H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H2V2h5v16zm11 0H8V2h10v16z"],"add-location":["M10 0a1 1 0 010 2 8 8 0 108 8 1 1 0 012 0c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0zm0 6a4 4 0 110 8 4 4 0 010-8zm6-6c.6 0 1 .4 1 1v2h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v2c0 .6-.4 1-1 1s-1-.4-1-1V5h-2c-.6 0-1-.4-1-1 0-.5.4-1 1-1h2V1c0-.6.4-1 1-1z"],"add-row-bottom":["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V8h16v10zm0-11H2V2h16v5zM7 14h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2v-2c0-.55-.45-1-1-1s-1 .45-1 1v2H7c-.55 0-1 .45-1 1s.45 1 1 1z"],"add-row-top":["M7 8h2v2c0 .55.45 1 1 1s1-.45 1-1V8h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v2H7c-.55 0-1 .45-1 1s.45 1 1 1zm12-8H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2v-5h16v5zm0-6H2V2h16v10z"],"add-to-artifact":["M13 12H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM1 6h9c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm12 2H1c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm6-4h-2V2c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V6h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"add-to-folder":["M.01 10V6H20v10c0 .55-.45 1-1 1H9.995v-3.99C9.965 11.332 8.635 10 6.987 10H.01zM19 3c.55 0 1 .45.99 1v1H0V2c0-.55.45-1 1-1h5.997c.28 0 .53.11.71.29L9.414 3H19zM6.987 12c.55 0 .999.45 1.009 1.01v5c0 .55-.45 1-1 1s-.999-.45-.999-1v-2.59l-4.288 4.29a1.003 1.003 0 01-1.42-1.42L4.579 14H1.989c-.55 0-1-.45-1-1s.45-1 1-1h4.998z"],airplane:["M20 2c0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-4.84 4.84L2 1 1 3l7.53 5.64L4.17 13H1l-1 1 4 2 2 4 1-1v-3.17l4.36-4.36L17 19l2-1-4.43-9.74 4.84-4.84c.37-.37.59-.87.59-1.42z"],"align-center":["M5 5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1H5zM1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm12 12c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h6zm4 2H3c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm2-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-justify":["M1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 14H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-12H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"align-left":["M1 7h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 14H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM1 15h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"],"align-right":["M19 17H5c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zM1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 10h-6c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-4H9c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-bottom":["M12 16h4c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1zm7 2H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM4 16h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1z"],"alignment-horizontal-center":["M19 9h-2V7c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v2H9V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v6H1c-.55 0-1 .45-1 1s.45 1 1 1h2v6c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-6h2v2c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"alignment-left":["M1 0C.45 0 0 .45 0 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm11 11H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm7-8H5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"alignment-right":["M19 0c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-4 11H8c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm0-8H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"alignment-top":["M8 4H4c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm11-4H1C.45 0 0 .45 0 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-3 4h-4c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"alignment-vertical-center":["M17 3h-6V1c0-.55-.45-1-1-1S9 .45 9 1v2H3c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h6v2H7c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1h-2V9h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],annotation:["M9.41 13.41l7.65-7.65-2.83-2.83-7.65 7.65 2.83 2.83zm10-10c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.83 1.64-1.66zM18 18H2V2h8.93l2-2H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7.07l-2 2V18zM4 16l4.41-1.59-2.81-2.79L4 16z"],antenna:["M2.01 10.758a8.025 8.025 0 001.01 3.204l.02.035c.034.058.061.117.084.178.163.44.054.951-.33 1.239-.435.328-1.059.242-1.342-.224a9.797 9.797 0 01-.221-.383 10 10 0 1117.48.106c-.269.474-.89.58-1.335.267-.392-.275-.518-.783-.37-1.228a1.19 1.19 0 01.078-.18l.019-.036A8.026 8.026 0 102.01 10.758zm4.272.772a1.464 1.464 0 01.091.32c.07.425-.052.87-.402 1.128-.44.325-1.068.235-1.316-.252a6 6 0 1110.734-.09c-.24.492-.867.593-1.312.275-.354-.253-.483-.695-.42-1.122a1.462 1.462 0 01.085-.321 4.021 4.021 0 00-5.87-4.878 4.02 4.02 0 00-1.59 4.94zm4.712 2.583A.999.999 0 0011 14v-4a1 1 0 10-2 0v4c0 .038.002.076.006.113l-3.753 4.223a1 1 0 001.494 1.328L10 16.005l3.252 3.66a1 1 0 101.495-1.33l-3.753-4.222z"],"app-header":["M19 0a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h18zM8 6a1 1 0 00-1.993-.117L6 6v8a1 1 0 001.993.117L8 14v-3h4v3a1 1 0 001.993.117L14 14V6a1 1 0 00-1.993-.117L12 6v3H8V6z"],application:["M3.5 9h9c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-9c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm-1 16H2V6h16v11zM3.5 13h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5z"],applications:["M15 5H1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 13H2V8h12v10zM3.5 10h7c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-7c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-3c-.28 0-.5.22-.5.5s.22.5.5.5zm0 2h5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5h-5c-.28 0-.5.22-.5.5s.22.5.5.5zM19 0H5c-.55 0-1 .45-1 1v3h2V3h12v10h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],archive:["M16.434 0a1 1 0 01.857.486L20 5v14a1 1 0 01-1 1H1a1 1 0 01-1-1V5L2.709.486A1 1 0 013.566 0h12.868zM10 8c-.55 0-1 .45-1 1v4.58l-1.29-1.29-.081-.073A.996.996 0 007 11.99a1.003 1.003 0 00-.71 1.71l3 3 .096.084c.168.13.38.206.614.206.28 0 .53-.11.71-.29l3-3 .084-.096a1.003 1.003 0 00-1.504-1.324L11 13.58V9l-.007-.116A1.004 1.004 0 0010 8zm6-6H4L2 5.002h16L16 2z"],"area-of-interest":["M5 4.664C5 2.09 7.241 0 10 0s4.99 2.091 5 4.664C15 7.245 10 14 10 14S5 7.245 5 4.664zM8 5a2 2 0 104.001-.001A2 2 0 008 5zM.504 12.132l4.302-2.458c.322.576.662 1.145.995 1.681l.025.04-3.294 1.881L6.468 18h7.064l3.936-4.724-3.293-1.882.024-.039c.333-.536.673-1.105.995-1.681l4.302 2.458a1 1 0 01.272 1.508l-5 6A1 1 0 0114 20H6a1 1 0 01-.768-.36l-5-6a1 1 0 01.272-1.508z"],array:["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm5 9a1 1 0 110 2 1 1 0 010-2zM6 9a1 1 0 110 2 1 1 0 010-2zm8 0a1 1 0 110 2 1 1 0 010-2z"],"array-boolean":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm10 7a1 1 0 01.993.883L16 8v4a1 1 0 01-.883.993L15 13H5a1 1 0 01-.993-.883L4 12V8a1 1 0 01.883-.993L5 7h10zm0 1h-5v4h5V8z"],"array-date":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm2.5 5a.5.5 0 01.5.5V6h4v-.5a.5.5 0 01.5-.5h1a.5.5 0 01.5.5V6h1a1 1 0 01.993.883L16 7v7a1 1 0 01-.883.993L15 15H5a1 1 0 01-.993-.883L4 14V7a1 1 0 01.883-.993L5 6h1v-.5a.5.5 0 01.5-.5h1zM15 9H5v5h10V9z"],"array-numeric":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm8.995 6.09c.32 0 .603.047.85.14a1.679 1.679 0 011.015.985c.09.23.135.482.135.755 0 .287-.063.552-.19.795a1.642 1.642 0 01-.57.615v.02l.101.05c.068.039.138.09.209.155.107.097.203.215.29.355a2.09 2.09 0 01.3 1.09c0 .313-.053.597-.16.85a1.898 1.898 0 01-1.12 1.065 2.42 2.42 0 01-.85.145c-.533 0-.99-.127-1.37-.38a1.702 1.702 0 01-.73-1.08c-.013-.067.013-.11.08-.13l.87-.2.041-.003c.038.004.064.028.079.073.073.2.193.37.36.51.167.14.39.21.67.21.32 0 .567-.095.74-.285.173-.19.26-.432.26-.725 0-.347-.1-.618-.3-.815-.2-.197-.47-.295-.81-.295h-.29l-.044-.006c-.037-.013-.056-.044-.056-.094V9.1l.006-.044c.013-.037.044-.056.094-.056h.27l.145-.008a.925.925 0 00.575-.262c.18-.18.27-.42.27-.72 0-.273-.08-.495-.24-.665-.16-.17-.383-.255-.67-.255-.253 0-.453.063-.6.19-.147.127-.25.297-.31.51-.02.06-.06.083-.12.07l-.85-.2-.042-.015c-.035-.02-.048-.055-.038-.105a1.684 1.684 0 01.645-1.035c.17-.13.37-.232.6-.305.23-.073.482-.11.755-.11zm-7.99.11l.044.006c.037.013.056.044.056.094v6.6l-.006.044c-.013.037-.044.056-.094.056h-.92l-.044-.006c-.037-.013-.056-.044-.056-.094V7.54h-.02l-1.04.73-.04.02c-.047.016-.07-.01-.07-.08V7.19l.008-.051a.196.196 0 01.062-.089l1.09-.79.051-.033a.295.295 0 01.129-.027h.85zm3.34-.11c.32 0 .603.05.85.15.247.1.455.235.625.405.17.17.3.37.39.6.09.23.135.478.135.745 0 .307-.057.588-.17.845a3.16 3.16 0 01-.47.745l-1.98 2.4V12h2.52l.044.006c.037.013.056.044.056.094v.8l-.006.044c-.013.037-.044.056-.094.056h-3.82l-.044-.006c-.037-.013-.056-.044-.056-.094v-.75l.006-.05a.165.165 0 01.044-.08l2.4-2.99.124-.167c.077-.11.143-.222.196-.333.08-.167.12-.347.12-.54a.92.92 0 00-.235-.64c-.157-.173-.378-.26-.665-.26-.273 0-.487.077-.64.23-.153.153-.247.36-.28.62-.013.067-.05.093-.11.08l-.88-.18-.043-.015c-.035-.02-.047-.055-.037-.105a1.78 1.78 0 01.56-1.115c.167-.157.372-.282.615-.375a2.35 2.35 0 01.845-.14z"],"array-string":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm2.012 6c.643 0 1.203.266 1.68.797.477.53.715 1.246.715 2.145a4.472 4.472 0 01-.965 2.814c-.644.83-1.66 1.5-3.047 2.011v-.581l.26-.104a3.87 3.87 0 001.624-1.285c.457-.632.686-1.29.686-1.971 0-.148-.023-.256-.07-.326-.023-.047-.054-.07-.093-.07-.038 0-.1.031-.186.093-.248.179-.558.268-.93.268-.45 0-.843-.18-1.18-.541A1.817 1.817 0 015 7.965c0-.527.194-.986.581-1.378A1.934 1.934 0 017.011 6zm5.593 0c.643 0 1.203.266 1.68.797.477.53.715 1.246.715 2.145a4.472 4.472 0 01-.965 2.814c-.644.83-1.659 1.5-3.047 2.011v-.581l.26-.104a3.87 3.87 0 001.624-1.285c.457-.632.686-1.29.686-1.971 0-.148-.023-.256-.07-.326-.023-.047-.054-.07-.093-.07-.038 0-.1.031-.186.093-.248.179-.558.268-.93.268-.45 0-.843-.18-1.18-.541a1.817 1.817 0 01-.506-1.285c0-.527.194-.986.581-1.378A1.934 1.934 0 0112.604 6z"],"array-timestamp":["M19 0a1 1 0 01.993.883L20 1v18a1 1 0 01-.883.993L19 20h-4a1 1 0 01-.117-1.993L15 18h3V2h-3a1 1 0 01-.993-.883L14 1a1 1 0 01.883-.993L15 0h4zM5 0a1 1 0 01.117 1.993L5 2H2v16h3a1 1 0 01.993.883L6 19a1 1 0 01-.883.993L5 20H1a1 1 0 01-.993-.883L0 19V1A1 1 0 01.883.007L1 0h4zm5 4a6 6 0 110 12 6 6 0 010-12zm0 1a5 5 0 100 10 5 5 0 000-10zm2.854 2.146a.5.5 0 01.057.638l-.057.07-2.5 2.5a.5.5 0 01-.638.057l-.07-.057-1.5-1.5a.5.5 0 01.638-.765l.07.057L10 9.293l2.146-2.147a.5.5 0 01.708 0z"],"arrow-bottom-left":["M18 3a1.003 1.003 0 00-1.71-.71L4 14.59V7c0-.55-.45-1-1-1s-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1H5.41l12.3-12.29c.18-.18.29-.43.29-.71z"],"arrow-bottom-right":["M17 6c-.55 0-1 .45-1 1v7.59L3.71 2.29a1.003 1.003 0 00-1.42 1.42L14.59 16H7c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"arrow-down":["M16 11c-.3 0-.5.1-.7.3L11 15.6V2c0-.5-.4-1-1-1s-1 .5-1 1v13.6l-4.3-4.3c-.2-.2-.4-.3-.7-.3-.5 0-1 .4-1 1 0 .3.1.5.3.7l6 6c.2.2.4.3.7.3s.5-.1.7-.3l6-6c.2-.2.3-.4.3-.7 0-.6-.5-1-1-1z"],"arrow-left":["M18 9H4.41L8.7 4.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L4.41 11H18c.55 0 1-.45 1-1s-.45-1-1-1z"],"arrow-right":["M18.71 9.29l-6-6a1.003 1.003 0 00-1.42 1.42L15.59 9H2c-.55 0-1 .45-1 1s.45 1 1 1h13.59l-4.29 4.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"arrow-top-left":["M17.71 16.29L5.41 4H13c.55 0 1-.45 1-1s-.45-1-1-1H3c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1s1-.45 1-1V5.41L16.29 17.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"arrow-top-right":["M17 2H7c-.55 0-1 .45-1 1s.45 1 1 1h7.59L2.29 16.29a1.003 1.003 0 001.42 1.42L16 5.41V13c0 .55.45 1 1 1s1-.45 1-1V3c0-.55-.45-1-1-1z"],"arrow-up":["M16.7 7.3l-6-6c-.2-.2-.4-.3-.7-.3s-.5.1-.7.3l-6 6c-.2.2-.3.4-.3.7 0 .6.5 1 1 1 .3 0 .5-.1.7-.3L9 4.4V18c0 .5.4 1 1 1s1-.5 1-1V4.4l4.3 4.3c.2.2.4.3.7.3.5 0 1-.4 1-1 0-.3-.1-.5-.3-.7z"],"arrows-horizontal":["M19.7 9.3l-5-5c-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.5.3.7L16.6 9H3.4l3.3-3.3c.2-.2.3-.4.3-.7 0-.6-.4-1-1-1-.3 0-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7s.1.5.3.7l5 5c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7L3.4 11h13.2l-3.3 3.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l5-5c.2-.2.3-.4.3-.7s-.1-.5-.3-.7z"],"arrows-vertical":["M15 13c-.3 0-.5.1-.7.3L11 16.6V3.4l3.3 3.3c.2.2.4.3.7.3.6 0 1-.4 1-1 0-.3-.1-.5-.3-.7l-5-5c-.2-.2-.4-.3-.7-.3s-.5.1-.7.3l-5 5c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3L9 3.4v13.2l-3.3-3.3c-.2-.2-.4-.3-.7-.3-.6 0-1 .4-1 1 0 .3.1.5.3.7l5 5c.2.2.4.3.7.3s.5-.1.7-.3l5-5c.2-.2.3-.4.3-.7 0-.5-.4-1-1-1z"],asterisk:["M18.52 14.17l.01-.02L11.89 10l6.64-4.15-.01-.02A.97.97 0 0019 5c0-.55-.45-1-1-1-.2 0-.37.07-.52.17l-.01-.02L11 8.2V1c0-.55-.45-1-1-1S9 .45 9 1v7.2L2.53 4.15l-.01.02A.922.922 0 002 4c-.55 0-1 .45-1 1 0 .36.2.66.48.83l-.01.02L8.11 10l-6.64 4.15.01.02A.97.97 0 001 15c0 .55.45 1 1 1 .2 0 .37-.07.52-.17l.01.02L9 11.8V19c0 .55.45 1 1 1s1-.45 1-1v-7.2l6.47 4.04.01-.02c.15.11.32.18.52.18.55 0 1-.45 1-1 0-.36-.2-.66-.48-.83z"],"automatic-updates":["M10 18c-4.42 0-8-3.58-8-8 0-2.52 1.18-4.76 3-6.22V5c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1h2.06C1.61 3.82 0 6.71 0 10c0 5.52 4.48 10 10 10 .55 0 1-.45 1-1s-.45-1-1-1zm0-16c1.64 0 3.15.49 4.42 1.34l1.43-1.43A9.869 9.869 0 0010 0c-.55 0-1 .45-1 1s.45 1 1 1zm10 8c0-1.13-.2-2.21-.54-3.22L17.84 8.4A7.962 7.962 0 0115 16.22V15c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1h-2.06c2.45-1.82 4.06-4.71 4.06-8zm0-7a1.003 1.003 0 00-1.71-.71L12 8.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7c.18-.18.29-.43.29-.71z"],backlink:["M18.387 19.79l-.094-.083L14 15.415V18a1 1 0 01-2 0l.003-5.075.017-.126.03-.111.044-.111.052-.098.067-.096.08-.09a1.01 1.01 0 01.112-.097l.11-.071.114-.054.105-.035.15-.03L13 12h5a1 1 0 110 2h-2.585l4.292 4.293a1 1 0 01-1.32 1.497zM7.036 9.136l-4.45 4.45-.117.127a2 2 0 002.818 2.818l.127-.117 4.45-4.449a4 4 0 01-.885 3.704l-.15.16-2 2A4 4 0 011.02 12.33l.15-.16 2-2a3.998 3.998 0 013.865-1.035zm6.671-3.843a1 1 0 01.083 1.32l-.083.094-7 7a1 1 0 01-1.497-1.32l.083-.094 7-7a1 1 0 011.414 0zm4.121-4.121a4 4 0 01.151 5.497l-.15.16-2 2a3.998 3.998 0 01-3.864 1.036l4.45-4.45.116-.128a2 2 0 00-2.818-2.818l-.127.117-4.45 4.45a4 4 0 01.885-3.705l.15-.16 2-2a4 4 0 015.657 0z"],badge:["M16.94 5.73c-.19-1.41.62-2.52 1.38-3.59L17.03.65C14.89 1.76 11.88 1.48 10 0 8.12 1.48 5.11 1.76 2.97.65L1.68 2.14c.76 1.07 1.57 2.18 1.38 3.59C2.68 8.59 0 10.94 1.4 14.08c.56 1.43 1.81 2.37 3.4 2.75 1.95.46 4.4.91 5.2 3.17.8-2.26 3.25-2.71 5.2-3.17 1.6-.38 2.84-1.32 3.4-2.75 1.4-3.14-1.28-5.49-1.66-8.35z"],"ban-circle":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm5 11H5c-.55 0-1-.45-1-1s.45-1 1-1h10c.55 0 1 .45 1 1s-.45 1-1 1z"],"bank-account":["M19.2 8.02l-.78-.18C18.03 6.4 17.2 5.08 16.08 4l.5-2.28c.11-.42-.22-.78-.61-.72-1.06.12-2 .54-2.67 1.26-1.06-.42-2.34-.66-3.56-.66-3.12 0-5.79 1.5-7.4 3.72-.23-.05-.45-.11-.67-.11C.72 5.21 0 5.98 0 7c0 .72.39 1.32.95 1.62-.06.42-.12.9-.12 1.38 0 2.16.89 4.08 2.28 5.58l-.33 2.04c-.11.72.45 1.38 1.12 1.38h.72c.56 0 1-.42 1.11-1.02l.06-.48c1.17.54 2.5.9 3.95.9 1.39 0 2.78-.3 3.95-.9l.06.48c.11.6.56 1.02 1.11 1.02h.72c.67 0 1.22-.66 1.11-1.38l-.33-1.98c.78-.78 1.34-1.74 1.73-2.76l1-.24c.5-.12.89-.6.89-1.2V9.22c.11-.6-.28-1.08-.78-1.2zM15 10c-.6 0-1-.7-1-1.5S14.4 7 15 7s1 .7 1 1.5-.4 1.5-1 1.5zM7.55 5.83a.99.99 0 01-1.38-.28.99.99 0 01.28-1.38c2.34-1.56 4.77-1.56 7.11 0 .46.31.58.93.28 1.39-.31.46-.93.58-1.39.28-1.67-1.12-3.23-1.12-4.9-.01z"],barcode:["M6 16.98h2v-14H6v14zm3 0h1v-14H9v14zm-6 0h2v-14H3v14zm-3 0h2v-14H0v14zm16 0h2v-14h-2v14zm-4 0h1v-14h-1v14zm7-14v14h1v-14h-1zm-5 14h1v-14h-1v14z"],blank:[],"blocked-person":["M11.55 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.06-.11.14-.35.17-.62C10.33 9.42 8.92 7.38 8.92 5c0-.3.05-.58.09-.87-.33-.08-.67-.13-.99-.13-.79 0-1.68.25-2.31.73-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.17 1.51-.17 2.14v.08c-.24.09-.45.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59C3 16.56.77 17.26.32 18.31-.15 19.38.04 20 .04 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.69-1.75-4.17-2.41zM14.97 0c-2.78 0-5.03 2.24-5.03 5s2.25 5 5.03 5S20 7.76 20 5s-2.25-5-5.03-5zm-3.03 5c0-1.66 1.35-3 3.02-3 .47 0 .9.11 1.29.3l-4.01 3.99c-.18-.4-.3-.83-.3-1.29zm3.03 3c-.47 0-.9-.11-1.29-.3l4.01-3.99c.19.39.3.82.3 1.29 0 1.66-1.36 3-3.02 3z"],bold:["M14.3 9c.4-.8.7-1.6.7-2.5C15 4 13 2 10.5 2H5c-.6 0-1 .4-1 1v13c0 .6.4 1 1 1h6.5c2.5 0 4.5-2 4.5-4.5 0-1.4-.7-2.7-1.7-3.5zM7 5h3.5c.8 0 1.5.7 1.5 1.5S11.3 8 10.5 8H7V5zm4.5 9H7v-3h4.5c.8 0 1.5.7 1.5 1.5s-.7 1.5-1.5 1.5z"],book:["M3 1v18c0 .55.45 1 1 1h2V0H4c-.55 0-1 .45-1 1zm14-1h-2v8l-2-2-2 2V0H7v20h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],bookmark:["M6 0c-.55 0-1 .45-1 1v18c0 .55.32.68.71.29L9.3 15.7a.996.996 0 011.41 0l3.59 3.59c.38.39.7.26.7-.29v-8-4.5V1c0-.55-.45-1-1-1H6z"],box:["M19.89 6.56l-2.99-6h-.01C16.72.23 16.39 0 16 0H4c-.39 0-.72.23-.89.56H3.1l-3 6h.01C.05 6.69 0 6.84 0 7v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7c0-.16-.05-.31-.11-.44zM11 2h4.38l2 4H11V2zM4.62 2H9v4H2.62l2-4zM18 18H2V8h16v10zM8 12h4c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1z"],briefcase:["M19 5h-4V2c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v3H1c-.55 0-1 .45-1 1v5h4v-1h2v1h8v-1h2v1h4V6c0-.55-.45-1-1-1zm-6 0H7V3h6v2zm3 8h-2v-1H6v1H4v-1H0v6c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-6h-4v1z"],"bring-data":["M18 18a1 1 0 010 2H2a1 1 0 010-2h16zM9.995 3.005c.55 0 1 .45 1 .999v9.584l1.29-1.288a1.002 1.002 0 011.42 1.419l-3 2.996a1.015 1.015 0 01-1.42 0l-3-2.997a1.002 1.002 0 011.42-1.419l1.29 1.29V4.013c0-.55.45-1.009 1-1.009zM16 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zm-3 0a1 1 0 110 2 1 1 0 010-2zM7 0a1 1 0 110 2 1 1 0 010-2zM4 0a1 1 0 110 2 1 1 0 010-2z"],buggy:["M15.836 1.014a1 1 0 011.058.539l2.482 4.962.02-.004a.5.5 0 01.604.49v4.5a.5.5 0 01-.5.5h-3.93a1.5 1.5 0 00-1.248.667l-1.406 2.11A.5.5 0 0112.5 15H8a.5.5 0 01-.354-.146l-2.414-2.415A1.5 1.5 0 004.172 12H.5a.5.5 0 01-.5-.5v-3A.5.5 0 01.5 8h.823L3.072 3.63a1 1 0 01.764-.615l12-2zm.289 3.472l1.231 2.462-2.758.591 1.527-3.053zM14.5 3.264l-1.56 3.12-.252-.638-.825-2.043 2.637-.44zm-9.78 1.63l5.122-.854.988 2.445.899 2.27L10.232 11H7.707L4.854 8.147A.5.5 0 004.5 8H3.477l1.242-3.106zM3 19a3 3 0 100-6 3 3 0 000 6zm14 0a3 3 0 100-6 3 3 0 000 6z"],build:["M19.43 16.67L9.31 7.81l1.47-1.56c.41-.44-.15-.8.15-1.6 1.08-2.76 4.19-2.99 4.19-2.99s.45-.47.87-.92C11.98-1 9.26.7 8.04 1.8L3.83 6.25l-.86.92c-.48.51-.48 1.33 0 1.84l-.87.92c-.48-.51-1.26-.51-1.74 0s-.48 1.33 0 1.84l1.74 1.84c.48.51 1.26.51 1.74 0s.48-1.33 0-1.84l.87-.92c.48.51 1.26.51 1.74 0l1.41-1.49 8.81 10.07c.76.76 2 .76 2.76 0 .76-.76.76-2 0-2.76z"],calculator:["M16 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H5v-2h2v2zm0-4H5v-2h2v2zm0-4H5V8h2v2zm4 8H9v-2h2v2zm0-4H9v-2h2v2zm0-4H9V8h2v2zm4 8h-2v-6h2v6zm0-8h-2V8h2v2zm0-4H5V2h10v4z"],calendar:["M15 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zM5 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm13-2h-1v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H7v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H2c-.5 0-1 .5-1 1v14c0 .5.5 1 1 1h16c.5 0 1-.5 1-1V4c0-.5-.5-1-1-1zM7 17H3v-4h4v4zm0-5H3V8h4v4zm5 5H8v-4h4v4zm0-5H8V8h4v4zm5 5h-4v-4h4v4zm0-5h-4V8h4v4z"],camera:["M10 8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm9-4h-3.59L13.7 2.29A.956.956 0 0013 2H7c-.28 0-.53.11-.71.29L4.59 4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h4.11c1.26 1.24 2.99 2 4.89 2s3.63-.76 4.89-2H19c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zM4 8H2V6h2v2zm6 8c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],"caret-down":["M16 7c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1 0 .24.1.46.24.63l-.01.01 5 6 .01-.01c.19.22.45.37.76.37s.57-.15.76-.37l.01.01 5-6-.01-.01c.14-.17.24-.39.24-.63z"],"caret-left":["M13 4c-.24 0-.46.1-.63.24l-.01-.01-6 5 .01.01c-.22.19-.37.45-.37.76s.15.57.37.76l-.01.01 6 5 .01-.01c.17.14.39.24.63.24.55 0 1-.45 1-1V5c0-.55-.45-1-1-1z"],"caret-right":["M14 10c0-.31-.15-.57-.37-.76l.01-.01-6-5-.01.01C7.46 4.1 7.24 4 7 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1 .24 0 .46-.1.63-.24l.01.01 6-5-.01-.01c.22-.19.37-.45.37-.76z"],"caret-up":["M15.76 12.37l.01-.01-5-6-.01.01C10.57 6.15 10.31 6 10 6s-.57.15-.76.37l-.01-.01-5 6 .01.01c-.14.17-.24.39-.24.63 0 .55.45 1 1 1h10c.55 0 1-.45 1-1 0-.24-.1-.46-.24-.63z"],"cargo-ship":["M12.5 1.25h4a1 1 0 011 1V5h-5V1.25zM2.75 5a.25.25 0 00-.25.25v6H.883a.5.5 0 00-.429.757l1.672 2.787c.17.284.384.533.63.741-.458.057-.959.09-1.506.09a.625.625 0 100 1.25c2.583 0 4.268-.68 5.202-1.146.687.466 1.88 1.146 3.548 1.146 1.65 0 2.837-.666 3.528-1.132l.005.003c.244.131.6.3 1.07.468.938.335 2.321.661 4.147.661a.625.625 0 100-1.25c-.319 0-.622-.01-.91-.03.398-.318.717-.738.914-1.23l.972-2.43a.5.5 0 00-.464-.685H5v-6A.25.25 0 004.75 5h-2zm3.455 11.95a.625.625 0 01.658.041c.569.407 1.597 1.134 3.137 1.134s2.568-.727 3.137-1.134a.625.625 0 01.724-.001l.007.005.045.029c.044.027.114.069.21.12.194.104.493.247.9.392.812.29 2.053.589 3.727.589a.625.625 0 110 1.25c-1.826 0-3.21-.326-4.148-.661a7.894 7.894 0 01-1.069-.468l-.005-.003c-.691.466-1.878 1.132-3.528 1.132-1.667 0-2.861-.68-3.548-1.146-.934.467-2.619 1.146-5.202 1.146a.625.625 0 110-1.25c2.66 0 4.23-.787 4.955-1.176zM17.5 6.25h-5V10h4a1 1 0 001-1V6.25zm-11.25-4a1 1 0 011-1h4V5h-5V2.25zm5 4h-5V9a1 1 0 001 1h4V6.25z"],"cell-tower":["M11.5 8.32c.31-.35.51-.81.51-1.32 0-1.1-.9-2-2-2s-2 .9-2 2c0 .51.2.97.51 1.32L5.06 18.69c-.17.52.11 1.09.63 1.26s1.09-.11 1.26-.63L8.39 15h3.23l1.44 4.32c.17.52.74.81 1.26.63s.81-.74.63-1.26L11.5 8.32zM10.95 13H9.06l.95-2.84.94 2.84zM5.31 10.73a.996.996 0 101.37-1.45c-1.4-1.33-1.28-3.35-.01-4.54.4-.38.43-1.01.05-1.41-.36-.41-1-.43-1.4-.06-2.09 1.95-2.28 5.3-.01 7.46z","M4.6 12.2C3 11.1 2 9 2 7c0-2.1.9-3.9 2.6-5.2.5-.3.5-1 .2-1.4-.3-.5-1-.5-1.4-.2C1.2 1.9-.1 4.2 0 7c.1 2.7 1.4 5.3 3.4 6.8.2.1.4.2.6.2.3 0 .6-.1.8-.4.4-.5.3-1.1-.2-1.4zM13.27 10.69c.38.4 1.01.42 1.41.04 2.27-2.16 2.08-5.51-.01-7.46a.996.996 0 10-1.36 1.46c1.28 1.19 1.39 3.21-.01 4.54-.39.39-.41 1.02-.03 1.42z","M16.6.2c-.4-.3-1.1-.3-1.4.2-.3.4-.3 1.1.2 1.4C17.1 3.1 18 4.9 18 7c0 2-1 4.1-2.6 5.2-.5.3-.6.9-.2 1.4.2.3.5.4.8.4.2 0 .4-.1.6-.2C18.7 12.3 20 9.7 20 7c.09-2.8-1.2-5.1-3.4-6.8z"],changes:["M18 16H2c-1.1 0-2 .9-2 2s.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2zM3 5c.28 0 .53-.11.71-.29L5 3.41V13c0 .55.45 1 1 1s1-.45 1-1V3.41L8.29 4.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C6.53.11 6.28 0 6 0s-.53.11-.71.29l-3 3A1.003 1.003 0 003 5zm7.29 5.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L15 10.59V1c0-.55-.45-1-1-1s-1 .45-1 1v9.59L11.71 9.3A.965.965 0 0011 9a1.003 1.003 0 00-.71 1.71z"],chart:["M7 11v8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-8l-2 2-4-2zm-7 8c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-8l-6 3v5zM17 7l-3 3v9c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V8.74c-.26.15-.58.26-1 .26-1.92 0-2-2-2-2zm2-6h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.59L10.8 8.78 7.45 7.11v.01C7.31 7.05 7.16 7 7 7s-.31.05-.44.11V7.1l-6 3v.01c-.33.17-.56.5-.56.89 0 .55.45 1 1 1 .16 0 .31-.05.44-.11v.01L7 9.12l3.55 1.78v-.01c.14.06.29.11.45.11.28 0 .53-.11.71-.29L18 4.41V6c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],chat:["M19 0H7c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h5.59l3.71 3.71c.17.18.42.29.7.29.55 0 1-.45 1-1v-3h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 13c-1.1 0-2-.9-2-2V4H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h1v3a1.003 1.003 0 001.71.71L7.41 16H13c.55 0 1-.45 1-1v-.17L12.17 13H7z"],"chevron-backward":["M8.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L7 8.59V4c0-.55-.45-1-1-1s-1 .45-1 1v12c0 .55.45 1 1 1s1-.45 1-1v-4.59l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L8.41 10z"],"chevron-down":["M16 6c-.28 0-.53.11-.71.29L10 11.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 6z"],"chevron-forward":["M13 3c-.55 0-1 .45-1 1v4.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5.29-5.3V16c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],"chevron-left":["M8.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L8.41 10z"],"chevron-right":["M13.71 9.29l-6-6a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"chevron-up":["M16.71 12.29l-6-6C10.53 6.11 10.28 6 10 6s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42L10 8.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],circle:["M10 0C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10S15.5 0 10 0zm0 18c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8z"],"circle-arrow-down":["M14 10c-.28 0-.53.11-.71.29L11 12.59V5c0-.55-.45-1-1-1s-1 .45-1 1v7.59L6.71 10.3A.965.965 0 006 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0014 10zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-left":["M15 9H7.41L9.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L7.41 11H15c.55 0 1-.45 1-1s-.45-1-1-1zm-5-9C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-right":["M15.71 9.29l-4-4a1.003 1.003 0 00-1.42 1.42L12.59 9H5c-.55 0-1 .45-1 1s.45 1 1 1h7.59l-2.29 2.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"circle-arrow-up":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.71-13.71C10.53 4.11 10.28 4 10 4s-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L9 7.41V15c0 .55.45 1 1 1s1-.45 1-1V7.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-4-4z"],citation:["M4 1C1.79 1 0 2.79 0 5s1.79 4 4 4c.1 0 .2-.01.3-.02C3.82 11.32 2.53 13 1 13c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7-4.48 7-10 0-2.21-1.79-4-4-4zM16 1c-2.21 0-4 1.79-4 4s1.79 4 4 4c.1 0 .2-.01.3-.02C15.82 11.32 14.53 13 13 13c-.55 0-1 .45-1 1s.45 1 1 1c3.87 0 7-4.48 7-10 0-2.21-1.79-4-4-4z"],clean:["M7 0L5 5 0 6.998 5 9l2 5 2-5 5-1.995L9 5zM15 10l-1.5 3.496-3.5 1.499 3.5 1.498L15 20l1.5-3.507L20 15l-3.5-1.504z"],clip:["M0 1a1 1 0 011-1h5a1 1 0 010 2H2v4a1 1 0 01-2 0V1zm1 19a1 1 0 01-1-1v-5a1 1 0 112 0v4h4a1 1 0 110 2H1zm18 0a1 1 0 001-1v-5a1 1 0 10-2 0v4h-4a1 1 0 100 2h5zm0-20a1 1 0 011 1v5a1 1 0 11-2 0V2h-4a1 1 0 110-2h5zm-9 14a4 4 0 100-8 4 4 0 000 8z"],clipboard:["M13 2c0-.55-.45-1-1-1h-.78a1.98 1.98 0 00-3.44 0H7c-.55 0-1 .45-1 1v2h7V2z","M16 2h-2v3H5V2H3c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1z"],cloud:["M15 7c-.12 0-.24.03-.36.04C13.83 4.69 11.62 3 9 3 5.69 3 3 5.69 3 9c0 .05.01.09.01.14A3.98 3.98 0 000 13c0 2.21 1.79 4 4 4h11c2.76 0 5-2.24 5-5s-2.24-5-5-5z"],"cloud-download":["M15 4c-.12 0-.24.03-.36.04C13.83 1.69 11.62 0 9 0 5.69 0 3 2.69 3 6c0 .05.01.09.01.14A3.98 3.98 0 000 10c0 2.21 1.79 4 4 4h.78c.55-.61 1.34-1 2.22-1v-2c0-1.66 1.34-3 3-3s3 1.34 3 3v2c.88 0 1.66.38 2.2.98C17.87 13.87 20 11.69 20 9c0-2.76-2.24-5-5-5zm-2 11c-.28 0-.53.11-.71.29L11 16.59V11c0-.55-.45-1-1-1s-1 .45-1 1v5.59L7.71 15.3A.965.965 0 007 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0013 15z"],"cloud-upload":["M10.71 10.29c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 13.41V19c0 .55.45 1 1 1s1-.45 1-1v-5.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM15 4c-.12 0-.24.03-.36.04C13.83 1.69 11.62 0 9 0 5.69 0 3 2.69 3 6c0 .05.01.09.01.14A3.98 3.98 0 000 10c0 2.21 1.79 4 4 4 0-.83.34-1.58.88-2.12l3-3a2.993 2.993 0 014.24 0l3 3-.01.01c.52.52.85 1.23.87 2.02C18.28 13.44 20 11.42 20 9c0-2.76-2.24-5-5-5z"],code:["M6 6a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L2.41 10 5.7 6.71c.19-.18.3-.43.3-.71zm6-4c-.46 0-.83.31-.95.73l-4 14c-.02.09-.05.17-.05.27 0 .55.45 1 1 1 .46 0 .83-.31.95-.73l4-14c.02-.09.05-.17.05-.27 0-.55-.45-1-1-1zm7.71 7.29l-4-4a1.003 1.003 0 00-1.42 1.42l3.3 3.29-3.29 3.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"code-block":["M19 5h-2V3c0-.55-.45-1-1-1h-4c-.55 0-1 .45-1 1v2H9V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zM8.71 15.29a1.003 1.003 0 01-1.42 1.42l-4-4C3.11 12.53 3 12.28 3 12s.11-.53.29-.71l4-4a1.003 1.003 0 011.42 1.42L5.41 12l3.3 3.29zm8-2.58l-4 4a1.003 1.003 0 01-1.42-1.42l3.3-3.29-3.29-3.29A.965.965 0 0111 8a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71s-.11.53-.29.71z"],cog:["M19 8h-2.31c-.14-.46-.33-.89-.56-1.3l1.7-1.7a.996.996 0 000-1.41l-1.41-1.41a.996.996 0 00-1.41 0l-1.7 1.7c-.41-.22-.84-.41-1.3-.55V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v2.33c-.48.14-.94.34-1.37.58L5 2.28a.972.972 0 00-1.36 0L2.28 3.64c-.37.38-.37.99 0 1.36L3.9 6.62c-.24.44-.44.89-.59 1.38H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h2.31c.14.46.33.89.56 1.3L2.17 15a.996.996 0 000 1.41l1.41 1.41c.39.39 1.02.39 1.41 0l1.7-1.7c.41.22.84.41 1.3.55V19c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2.33c.48-.14.94-.35 1.37-.59L15 17.72c.37.37.98.37 1.36 0l1.36-1.36c.37-.37.37-.98 0-1.36l-1.62-1.62c.24-.43.45-.89.6-1.38H19c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-9 6c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],"collapse-all":["M9.29 8.71c.18.18.43.29.71.29s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L10 6.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6zm1.42 2.58c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42l5.29-5.3 5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6z"],"column-layout":["M19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM5 17H2V3h3v14zm4 0H6V3h3v14zm9 0h-8V3h8v14z"],comment:["M19 1H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3v4a1.003 1.003 0 001.71.71l4.7-4.71H19c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM4 10c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm6 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm6 0c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],comparison:["M6 8H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm13-6h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 3h-5V3h5v2zM6 14H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM6 2H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm4-2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm9 14h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-5v-2h5v2zm0-9h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm0 3h-5V9h5v2z"],compass:["M15 10c0 .14-.03.28-.09.4l-3.99 8.98-.01.02a.991.991 0 01-1.82 0l-.01-.02-3.99-8.98c-.06-.12-.09-.26-.09-.4s.03-.28.09-.4L9.08.62 9.09.6a.991.991 0 011.82 0l.01.02 3.99 8.98c.06.12.09.26.09.4zm-5-6.54L7.09 10h5.81L10 3.46z"],compressed:["M19.89 6.56l-2.99-6h-.01C16.72.23 16.39 0 16 0H4c-.39 0-.72.23-.89.56H3.1l-3 6h.01C.05 6.69 0 6.84 0 7v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7c0-.16-.05-.31-.11-.44zM11 2h4.38l2 4H11V2zM4.62 2H9v4H2.62l2-4zM18 18H2V8h7v4.59L6.71 10.3A.965.965 0 006 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l4-4a1.003 1.003 0 00-1.42-1.42L11 12.59V8h7v10z"],confirm:["M9.71 5.29a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7a1.003 1.003 0 00-1.42-1.42L12 7.59l-2.29-2.3zm7.93 2.32c.23.75.36 1.56.36 2.39 0 4.42-3.58 8-8 8s-8-3.58-8-8a7.998 7.998 0 0111.8-7.04l1.46-1.46C13.73.56 11.93 0 10 0 4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-1.4-.29-2.73-.81-3.95l-1.55 1.56z"],console:["M19 19H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1h18c.55 0 1 .45 1 1v16c0 .55-.45 1-1 1zM18 6H2v11h16V6zM4 8c.28 0 .53.11.71.29l2 2c.18.18.29.43.29.71s-.11.53-.29.71l-2 2a1.003 1.003 0 01-1.42-1.42L4.59 11l-1.3-1.29A1.003 1.003 0 014 8zm5 4h3c.55 0 1 .45 1 1s-.45 1-1 1H9c-.55 0-1-.45-1-1s.45-1 1-1z"],contrast:["M19 8h-1.26c-.19-.73-.48-1.42-.85-2.06l.94-.94a.996.996 0 000-1.41l-1.41-1.41a.996.996 0 00-1.41 0l-.94.94c-.65-.38-1.34-.67-2.07-.86V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v1.26c-.76.2-1.47.5-2.13.89L5 2.28a.972.972 0 00-1.36 0L2.28 3.64c-.37.38-.37.98 0 1.36l.87.87c-.39.66-.69 1.37-.89 2.13H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h1.26c.19.73.48 1.42.85 2.06l-.94.94a.996.996 0 000 1.41l1.41 1.41c.39.39 1.02.39 1.41 0l.94-.94c.64.38 1.33.66 2.06.85V19c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-1.26c.76-.2 1.47-.5 2.13-.89l.88.87c.37.37.98.37 1.36 0l1.36-1.36c.37-.38.37-.98 0-1.36l-.87-.87c.4-.65.7-1.37.89-2.13H19c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm-9 7c-2.76 0-5-2.24-5-5s2.24-5 5-5v10z"],control:["M17 10h-7v7h7v-7zm0-7h-7v6h7V3zM9 3H3v14h6V3zm10-3H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V2h16v16z"],"credit-card":["M19 3H1c-.55 0-1 .45-1 1v2h20V4c0-.55-.45-1-1-1zM0 16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V8H0v8zm6.5-2h7c.28 0 .5.22.5.5s-.22.5-.5.5h-7c-.28 0-.5-.22-.5-.5s.22-.5.5-.5zm-4 0h2c.28 0 .5.22.5.5s-.22.5-.5.5h-2c-.28 0-.5-.22-.5-.5s.22-.5.5-.5z"],cross:["M11.41 10l4.29-4.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-4.29-4.3a1.003 1.003 0 00-1.42 1.42L8.59 10 4.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4.29-4.3 4.29 4.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z"],crown:["M2 8l4 2 4-5 4 5 4-2-1 7H3L2 8zm8-6a1 1 0 110 2 1 1 0 010-2zM1 5a1 1 0 110 2 1 1 0 010-2zm18 0a1 1 0 110 2 1 1 0 010-2zM3 16h14v2H3v-2z"],cube:["M1.953 4.481l7.41-4.02c.394-.215.88-.215 1.275 0l7.409 4.02L10 9.22 1.953 4.48zm-.817.68L9.5 10.085v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547zm17.728 0c.088.166.136.353.136.546v8.35c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281l8.364-4.926z"],"cube-add":["M17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2zm-3.969 4.435L10 9.22 1.953 4.48l7.41-4.02c.394-.215.88-.215 1.275 0l1.33.721A3.001 3.001 0 0013 7c0 .148.01.293.031.435zm.319.972A3 3 0 0019 7v7.057c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281l2.85-1.679zM1.136 5.16L9.5 10.086v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547z"],"cube-remove":["M11.968 1.182A3.001 3.001 0 0013 7h.77L10 9.22 1.953 4.48l7.41-4.02c.394-.215.88-.215 1.275 0l1.33.721zM19 7v7.057c0 .438-.247.842-.648 1.06l-7.714 4.186c-.045.024-.091.046-.138.064v-9.281L15.74 7H19zM1.136 5.16L9.5 10.086v9.281a1.316 1.316 0 01-.138-.064l-7.714-4.186A1.211 1.211 0 011 14.057v-8.35c0-.193.048-.38.136-.547zM13 3h6a1 1 0 010 2h-6a1 1 0 010-2z"],"curved-range-chart":["M19 16H3.02l2.14-1.74c2.25 1.7 7.33.46 11.83-2.99l-1.29-1.5c-3.56 2.74-7.31 4.03-8.93 3.19l10.55-8.57-.63-.78-10.59 8.6c-.64-1.64 1.46-4.91 5.09-7.7L9.9 3.01c-4.6 3.54-6.91 8.12-5.41 10.51L2 15.54V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],cut:["M16 2s.72-1.28 0-2l-5.29 6.25 1.28 1.54L16 2zm.08 10c-.55 0-1.07.12-1.54.32L4.31 0c-.7.72 0 2 0 2l4.45 6.56-3.19 3.77C5.09 12.12 4.56 12 4 12c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.65-.17-1.26-.45-1.8l2.54-3.67 2.49 3.67c-.27.54-.44 1.15-.44 1.8 0 2.21 1.76 4 3.92 4 2.17 0 3.92-1.79 3.92-4 .02-2.21-1.74-4-3.9-4zM4 18c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm12.08 0c-1.08 0-1.96-.9-1.96-2s.88-2 1.96-2 1.96.9 1.96 2-.88 2-1.96 2z"],cycle:["M16 10a4 4 0 110 8 4 4 0 010-8zM4 10a4 4 0 110 8 4 4 0 010-8zm7.299-5.543l.087.089 1.93 2.232 2.048.708a1 1 0 01.65 1.16l-.031.112a1 1 0 01-1.16.65l-.112-.031-2.302-.796a1 1 0 01-.337-.197l-.092-.094-1.387-1.603-1.891 1.982 2.046 2.274a1 1 0 01.25.547l.007.122v4.24a1 1 0 01-1.993.117l-.007-.117-.001-3.857-2.408-2.676a1 1 0 01-.063-1.26l.082-.099 3.29-3.45a1 1 0 011.394-.053zM16 12a2 2 0 100 4 2 2 0 000-4zM4 12a2 2 0 100 4 2 2 0 000-4zm9.5-10a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],dashboard:["M6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zM4 9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6-4c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-5C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm6-9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-8 5c0 1.1.9 2 2 2s2-.9 2-2c0-.33-2-8-2-8s-2 7.67-2 8zm6-9c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"],"data-connection":["M2 11.9c.935.674 2.339 1.217 4.023 1.536A6.996 6.996 0 009.393 20c-3.988-.019-7.231-1.083-7.387-2.4L2 17.5v-5.6zM13 8c3.315 0 6 2.685 6 6s-2.685 6-6 6-6-2.685-6-6 2.685-6 6-6zm1 1l-4 6h2.5l-.5 4 4-6h-2.5l.5-4zm3-4.6v3.855a7.003 7.003 0 00-10.779 3.992c-2.408-.391-4.097-1.202-4.214-2.142L2 10V4.4c1.525 1.1 4.3 1.85 7.5 1.85S15.475 5.5 17 4.4zM9.5 0C13.637 0 17 1.125 17 2.5S13.637 5 9.5 5C5.35 5 2 3.875 2 2.5S5.35 0 9.5 0z"],"data-lineage":["M1.053 0C.47 0 0 .471 0 1.053V4.21c0 .58.471 1.052 1.053 1.052h3.275a6.332 6.332 0 003.728 4.738 6.33 6.33 0 00-3.728 4.737l-3.275-.001C.47 14.737 0 15.208 0 15.789v3.158C0 19.53.471 20 1.053 20h7.435c.581 0 1.053-.471 1.053-1.053V15.79c0-.58-.472-1.052-1.053-1.052H5.406a5.293 5.293 0 015.195-4.21v2.105c0 .58.471 1.052 1.052 1.052h7.294c.582 0 1.053-.471 1.053-1.052V7.368c0-.58-.471-1.052-1.053-1.052h-7.294c-.581 0-1.052.471-1.052 1.052v2.106a5.293 5.293 0 01-5.194-4.21h3.081c.581 0 1.053-.472 1.053-1.053V1.053C9.54.47 9.069 0 8.488 0H1.053z"],database:["M2.01 5.1v5.4c0 1.38 3.58 2.5 8 2.5s8-1.12 8-2.5V5.1c-1.49 1.13-4.51 1.9-8 1.9-3.48 0-6.5-.77-8-1.9zm8 .9c4.42 0 8-1.12 8-2.5s-3.58-2.5-8-2.5-8 1.12-8 2.5S5.6 6 10.01 6zm-8 6.1v5.4c0 1.38 3.58 2.5 8 2.5s8-1.12 8-2.5v-5.4c-1.49 1.13-4.51 1.9-8 1.9-3.48 0-6.5-.77-8-1.9z"],delete:["M15 6a1.003 1.003 0 00-1.71-.71L10 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L8.59 10 5.3 13.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3.29-3.3 3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10l3.29-3.29c.19-.18.3-.43.3-.71zm-5-6C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],delta:["M10 0L0 20h20L10 0zM9 6l6 12H3L9 6z"],"derive-column":["M7.1 8.2h-.99c.28-1.11.66-1.92 1.12-2.43.28-.32.56-.48.83-.48.05 0 .1.02.13.05.03.03.05.07.05.12 0 .04-.04.13-.11.25a.64.64 0 00-.12.35c0 .15.06.28.18.39.12.11.27.16.45.16.2 0 .36-.07.49-.2s.2-.31.2-.54c0-.26-.1-.47-.3-.63-.19-.16-.51-.24-.95-.24-.68 0-1.3.19-1.85.58-.56.38-1.09 1.02-1.59 1.91-.17.3-.34.5-.49.59-.15.08-.4.13-.74.12l-.23.77h.95l-1.39 5.24c-.23.86-.39 1.39-.47 1.59-.12.29-.3.54-.54.75-.1.08-.21.12-.35.12-.04 0-.07-.01-.1-.03l-.03-.04c0-.02.03-.07.1-.13.07-.07.1-.17.1-.31 0-.15-.05-.28-.16-.38-.11-.1-.27-.15-.47-.15-.25 0-.44.07-.59.2-.15.12-.23.28-.23.46 0 .19.09.36.27.5.19.14.47.21.86.21.61 0 1.16-.15 1.63-.46.48-.31.89-.78 1.25-1.43.35-.64.72-1.68 1.09-3.11l.8-3.03h.96l.24-.77zM19 0h-9c-.55 0-1 .45-1 1v3h2V2h7v16h-7v-2H9v3c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-8.79 13.49c.15.28.32.49.52.61.19.12.44.19.73.19.28 0 .57-.1.86-.3.38-.25.77-.69 1.17-1.31l-.25-.14c-.27.37-.48.6-.61.69-.09.06-.19.09-.31.09-.14 0-.28-.09-.42-.26-.23-.29-.54-1.09-.93-2.4.35-.59.64-.97.87-1.15.17-.13.35-.2.55-.2.07 0 .2.03.39.08s.36.08.5.08c.2 0 .37-.07.5-.2.15-.14.22-.31.22-.52 0-.22-.07-.4-.2-.53s-.33-.2-.58-.2c-.22 0-.43.05-.63.15-.2.1-.45.32-.75.67-.23.25-.56.7-1.01 1.33a6.52 6.52 0 00-.91-2.15l-2.39.39-.05.25c.18-.03.33-.05.45-.05.24 0 .43.1.59.3.25.31.59 1.24 1.02 2.8-.34.44-.58.73-.7.87-.21.22-.38.36-.52.43-.1.05-.22.08-.35.08-.1 0-.26-.05-.49-.16a1.01 1.01 0 00-.42-.11c-.23 0-.42.07-.57.22-.15.14-.23.33-.23.55 0 .21.07.38.21.51.14.13.33.2.56.2.23 0 .44-.05.64-.14.2-.09.45-.29.75-.59s.72-.78 1.25-1.43c.21.61.39 1.06.54 1.35z"],desktop:["M19 0H1C.45 0 0 .45 0 1v13c0 .55.45 1 1 1h5.67l-.5 3H5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1h-1.17l-.5-3H19c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 13H2V2h16v11z"],diagnosis:["M4 2a1 1 0 01.117 1.993L4 4v5a2 2 0 001.85 1.995L6 11a2 2 0 001.995-1.85L8 9V4a1 1 0 01-.117-1.993L8 2h1a1 1 0 01.993.883L10 3v6a4.002 4.002 0 01-3 3.874V13a3 3 0 003 3 4 4 0 003.995-3.8L14 12V8.792a2.5 2.5 0 112 0V12a6 6 0 01-6 6 5 5 0 01-4.995-4.783L5 13v-.126A4.002 4.002 0 012.005 9.2L2 9V3a1 1 0 01.883-.993L3 2h1z"],"diagram-tree":["M19 10v5h-2v-4h-6v4H9v-4H3v4H1v-5a1 1 0 011-1h7V5h2v4h7a1 1 0 011 1zM1 16h2a1 1 0 011 1v2a1 1 0 01-1 1H1a1 1 0 01-1-1v-2a1 1 0 011-1zm16 0h2a1 1 0 011 1v2a1 1 0 01-1 1h-2a1 1 0 01-1-1v-2a1 1 0 011-1zm-8 0h2a1 1 0 011 1v2a1 1 0 01-1 1H9a1 1 0 01-1-1v-2a1 1 0 011-1zM9 0h2a1 1 0 011 1v2a1 1 0 01-1 1H9a1 1 0 01-1-1V1a1 1 0 011-1z"],"direction-left":["M20 3.02l-20 7 20 7-5-7z"],"direction-right":["M20 10.02l-20-7 5 7-5 7z"],disable:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM2 10c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L3.69 14.9A7.902 7.902 0 012 10zm8 8c-1.85 0-3.55-.63-4.9-1.69L16.31 5.1A7.902 7.902 0 0118 10c0 4.42-3.58 8-8 8z"],document:["M11.98 0h-8c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V6l-6-6zm4 18h-11V2h6v5h5v11z"],"document-open":["M8 15c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1h2.59L1.3 16.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 12.41V15zm5-15H5c-.55 0-1 .45-1 1v6h2V2h6v5h5v11H6v-.76L4.04 19.2c.1.45.48.8.96.8h13c.55 0 1-.45 1-1V6l-6-6z"],"document-share":["M14.09 10.09c-.31.31-.67.57-1.09.72V18H2V2h6v5h1.18c.15-.42.39-.8.7-1.11v-.01l2.45-2.45c-.42-.29-.78-.65-1.01-1.11L9 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V9.24l-.88.88-.03-.03zM19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],dollar:["M15.57 11.19c-.27-.51-.63-.93-1.07-1.26-.44-.33-.95-.6-1.51-.79-.56-.2-1.14-.36-1.72-.5-.6-.14-1.19-.26-1.75-.38-.57-.13-1.07-.27-1.51-.44-.44-.17-.8-.38-1.07-.63s-.41-.59-.41-1c0-.33.09-.6.28-.81.19-.21.42-.36.69-.47.27-.11.57-.18.88-.22.31-.04.58-.06.8-.06.71 0 1.35.14 1.9.41.55.27.91.81 1.06 1.62h3.36c-.09-.84-.32-1.56-.69-2.16-.37-.6-.83-1.08-1.38-1.45-.56-.37-1.18-.64-1.86-.81-.19-.05-.38-.07-.57-.1V1c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v1.1c-.22.03-.43.05-.66.1-.73.13-1.39.37-1.98.71-.6.34-1.09.8-1.47 1.35-.39.56-.58 1.25-.58 2.08 0 .76.13 1.41.4 1.93.26.52.62.95 1.06 1.28.44.33.94.6 1.5.79.55.2 1.13.36 1.74.5.58.14 1.16.26 1.72.38s1.07.26 1.51.43c.44.17.8.39 1.09.66.28.27.43.63.45 1.06.02.43-.08.78-.3 1.04-.22.26-.49.47-.83.6-.34.14-.7.23-1.09.28-.39.05-.73.07-1.03.07-.87 0-1.61-.2-2.23-.59-.62-.39-.98-1.08-1.07-2.06H3c.02.9.19 1.68.52 2.34.33.66.78 1.21 1.35 1.65.57.44 1.25.77 2.03.98.35.1.71.16 1.08.21V19c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-1.13c.25-.04.5-.07.76-.13.77-.18 1.47-.46 2.1-.85.63-.39 1.14-.9 1.54-1.53.4-.63.59-1.39.59-2.29.01-.75-.13-1.37-.4-1.88z"],dot:["M10 6a4 4 0 100 8 4 4 0 100-8z"],"double-caret-horizontal":["M8 4c-.24 0-.46.1-.63.24l-.01-.01-6 5 .01.01c-.22.19-.37.45-.37.76s.15.57.37.76l-.01.01 6 5 .01-.01c.17.14.39.24.63.24.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm11 6c0-.31-.15-.57-.37-.76l.01-.01-6-5-.01.01C12.46 4.1 12.24 4 12 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1 .24 0 .46-.1.63-.24l.01.01 6-5-.01-.01c.22-.19.37-.45.37-.76z"],"double-caret-vertical":["M5 9h10c.55 0 1-.45 1-1 0-.24-.1-.46-.24-.63l.01-.01-5-6-.01.01C10.57 1.15 10.31 1 10 1s-.57.15-.76.37l-.01-.01-5 6 .01.01C4.1 7.54 4 7.76 4 8c0 .55.45 1 1 1zm10 2H5c-.55 0-1 .45-1 1 0 .24.1.46.24.63l-.01.01 5 6 .01-.01c.19.22.45.37.76.37s.57-.15.76-.37l.01.01 5-6-.01-.01c.14-.17.24-.39.24-.63 0-.55-.45-1-1-1z"],"double-chevron-down":["M9.29 10.71c.18.18.43.29.71.29s.53-.11.71-.29l6-6a1.003 1.003 0 00-1.42-1.42L10 8.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6zM16 9c-.28 0-.53.11-.71.29L10 14.59l-5.29-5.3a1.003 1.003 0 00-1.42 1.42l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 9z"],"double-chevron-left":["M5.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L5.41 10zm6 0l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L11.41 10z"],"double-chevron-right":["M11 10c0-.28-.11-.53-.29-.71l-6-6a1.003 1.003 0 00-1.42 1.42L8.59 10 3.3 15.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71zm5.71-.71l-6-6a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"double-chevron-up":["M4 11c.28 0 .53-.11.71-.29L10 5.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6A.997.997 0 0010 3c-.28 0-.53.11-.71.29l-6 6A1.003 1.003 0 004 11zm6.71-1.71A.997.997 0 0010 9c-.28 0-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42l5.29-5.3 5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6z"],"doughnut-chart":["M16 10c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6V0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10h-4zm-.09-1h4.04C19.48 4.28 15.72.52 11 .05V4.1A5.98 5.98 0 0115.91 9z"],download:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm4.71 11.71l-4 4c-.18.18-.43.29-.71.29s-.53-.11-.71-.29l-4-4a1.003 1.003 0 011.42-1.42L9 12.59V5c0-.55.45-1 1-1s1 .45 1 1v7.59l2.29-2.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71z"],"drag-handle-horizontal":["M7.5 11c-.83 0-1.5.67-1.5 1.5S6.67 14 7.5 14 9 13.33 9 12.5 8.33 11 7.5 11zm-5-5C1.67 6 1 6.67 1 7.5S1.67 9 2.5 9 4 8.33 4 7.5 3.33 6 2.5 6zm0 5c-.83 0-1.5.67-1.5 1.5S1.67 14 2.5 14 4 13.33 4 12.5 3.33 11 2.5 11zm15-2c.83 0 1.5-.67 1.5-1.5S18.33 6 17.5 6 16 6.67 16 7.5 16.67 9 17.5 9zm-5 2c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm5 0c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm-10-5C6.67 6 6 6.67 6 7.5S6.67 9 7.5 9 9 8.33 9 7.5 8.33 6 7.5 6zm5 0c-.83 0-1.5.67-1.5 1.5S11.67 9 12.5 9 14 8.33 14 7.5 13.33 6 12.5 6z"],"drag-handle-vertical":["M7.5 6C6.67 6 6 6.67 6 7.5S6.67 9 7.5 9 9 8.33 9 7.5 8.33 6 7.5 6zm0 5c-.83 0-1.5.67-1.5 1.5S6.67 14 7.5 14 9 13.33 9 12.5 8.33 11 7.5 11zm0 5c-.83 0-1.5.67-1.5 1.5S6.67 19 7.5 19 9 18.33 9 17.5 8.33 16 7.5 16zm5-12c.83 0 1.5-.67 1.5-1.5S13.33 1 12.5 1 11 1.67 11 2.5 11.67 4 12.5 4zm-5-3C6.67 1 6 1.67 6 2.5S6.67 4 7.5 4 9 3.33 9 2.5 8.33 1 7.5 1zm5 10c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-10c-.83 0-1.5.67-1.5 1.5S11.67 9 12.5 9 14 8.33 14 7.5 13.33 6 12.5 6z"],draw:["M17.7 12.7c0-.1 0-.2-.1-.3l-2-7c-.1-.3-.3-.6-.6-.7L1.8 0l-.6.5L7.7 7c.3-.2.6-.3 1-.3 1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2c0-.4.1-.7.3-1L.5 1.2l-.5.6L4.7 15c.1.3.4.5.7.6l7 2c.1 0 .2.1.3.1.3 0 .5-.1.7-.3l4-4c.2-.2.3-.5.3-.7zm1 1c-.3 0-.5.1-.7.3l-4 4c-.2.2-.3.4-.3.7 0 .5.4 1 1 1 .3 0 .5-.1.7-.3l4-4c.2-.2.3-.4.3-.7 0-.6-.5-1-1-1z"],"drawer-left":["M9 0a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1h8zM8 2H2v16h6V2zm2 7h6.59L14.3 6.71A.965.965 0 0114 6a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10V9z"],"drawer-left-filled":["M1 0h8a1 1 0 011 1v18a1 1 0 01-1 1H1a1 1 0 01-1-1V1a1 1 0 011-1zm9 9h6.59L14.3 6.71A.965.965 0 0114 6a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10V9z"],"drawer-right":["M19 0a1 1 0 011 1v18a1 1 0 01-1 1h-8a1 1 0 01-1-1V1a1 1 0 011-1h8zm-1 2h-6v16h6V2zm-8 7H3.41L5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 11H10V9z"],"drawer-right-filled":["M11 0h8a1 1 0 011 1v18a1 1 0 01-1 1h-8a1 1 0 01-1-1V1a1 1 0 011-1zm-1 9H3.41L5.7 6.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 11H10V9z"],"drive-time":["M20.01 7.7c0-.63-.5-1.14-1.1-1.14h-1.32l-.95-2.57c-.24-.64-.95-1.31-1.59-1.5 0 0-1.65-.49-5.05-.49s-5.04.49-5.04.49c-.63.19-1.35.86-1.59 1.5l-.95 2.57H1.1C.5 6.56 0 7.07 0 7.7c0 .63.5 1.14 1.1 1.14h.47l-.34.91c-.24.64-.43 1.72-.43 2.4v5.39c0 .8.63 1.45 1.4 1.45.77 0 1.4-.65 1.4-1.45v-.83h12.8v.83c0 .8.63 1.45 1.4 1.45s1.4-.65 1.4-1.45v-5.39c0-.68-.19-1.77-.43-2.4l-.34-.91h.47c.61 0 1.11-.51 1.11-1.14zm-16.47.34l1.12-3.16c.08-.22.32-.39.54-.39h9.6c.22 0 .46.17.54.39l1.12 3.16c.08.21-.04.39-.26.39H3.8c-.22-.01-.34-.18-.26-.39zm.96 4.94c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.68 1.5 1.5c0 .83-.67 1.5-1.5 1.5zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],duplicate:["M15 4H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm-1 14H2V6h12v12zm5-18H5c-.55 0-1 .45-1 1v2h2V2h12v12h-1v2h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],edit:["M4.59 12.59l2.83 2.83 7.65-7.65-2.83-2.83-7.65 7.65zM2 18l4.41-1.59-2.81-2.79L2 18zM16 2c-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.83 1.65-1.65A2.006 2.006 0 0016 2z"],eject:["M4 12h12c.55 0 1-.45 1-1 0-.25-.1-.47-.25-.64l.01-.01-6-7-.01.01C10.57 3.14 10.3 3 10 3s-.57.14-.75.36l-.01-.01-6 7 .01.01c-.15.17-.25.39-.25.64 0 .55.45 1 1 1zm12 1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],emoji:["M10 0c5.523 0 10 4.477 10 10s-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0zm0 2a8 8 0 100 16 8 8 0 000-16zm-4 8l.015.215C6.219 12.42 7.925 14 10 14a4 4 0 003.995-3.8L14 10h2l-.013.238C15.754 13.552 13.163 16 10 16a6 6 0 01-5.996-5.775L4 10h2zm1.5-4a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm5 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3z"],endorsed:["M19.83 9.38L18.81 7.6V5.62c0-.45-.23-.85-.61-1.08l-1.71-1-1.02-1.76a1.25 1.25 0 00-1.08-.61h-2.03l-1.74-1c-.38-.23-.87-.23-1.25 0l-1.74 1H5.65c-.44 0-.85.23-1.08.61L3.58 3.5l-1.8 1.04c-.38.24-.62.64-.62 1.08v2.06L.17 9.4c-.11.19-.17.4-.17.61s.06.42.17.61l.99 1.72v2.06c0 .45.23.85.61 1.08l1.78 1.02.99 1.72c.23.38.63.61 1.08.61h1.99l1.74 1c.19.11.41.17.62.17.21 0 .42-.06.61-.17l1.74-1h2.03c.44 0 .85-.23 1.08-.61l1.02-1.76 1.71-1c.38-.23.61-.64.61-1.08v-1.97l1.02-1.78c.27-.38.27-.85.04-1.25zm-5.08-.71l-5.01 5.01c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.29l-3.01-3.01a1.003 1.003 0 011.42-1.42l2.3 2.3 4.31-4.3a1.003 1.003 0 011.71.71c0 .28-.12.53-.3.71z"],envelope:["M0 4.01v11.91l6.27-6.27L0 4.01zm18.91-1.03H1.09L10 10.97l8.91-7.99zm-5.18 6.66L20 15.92V4.01l-6.27 5.63zm-3.23 2.9c-.13.12-.31.19-.5.19s-.37-.07-.5-.19l-2.11-1.89-6.33 6.33h17.88l-6.33-6.33-2.11 1.89z"],equals:["M4 7h12a1 1 0 010 2H4a1 1 0 110-2zm0 4h12a1 1 0 010 2H4a1 1 0 010-2z"],eraser:["M18.71 8.43c.39-.4.39-1.05 0-1.45l-5.53-5.72a.967.967 0 00-1.4 0L1.29 12.1c-.39.4-.39 1.05 0 1.45l4.25 4.39 2.13 2.05h9.27c.02 0 .03.01.05.01.55 0 1-.45 1-1s-.45-1-1-1H9.46l.05-.05h.01l.81-.84 8.38-8.68zM7.52 17.94l-4.95-5.12 4.46-4.61 4.95 5.12-4.46 4.61z"],error:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm1 16H9v-2h2v2zm0-3H9V4h2v9z"],euro:["M8.89 4.47c.56-.31 1.23-.47 2.03-.47.44 0 .85.07 1.25.22.4.14.76.35 1.07.6.17.14.33.3.47.47l2.32-2.32c-.16-.15-.3-.32-.47-.46-.62-.49-1.33-.87-2.12-1.13-.8-.25-1.64-.38-2.52-.38-1.24 0-2.35.22-3.33.66-.99.44-1.82 1.05-2.49 1.82-.68.78-1.2 1.68-1.56 2.72-.09.26-.13.54-.2.8H2c-.55 0-1 .45-1 1s.45 1 1 1h1.04c-.01.2-.04.38-.04.58 0 .15.03.28.03.42H2c-.55 0-1 .45-1 1s.45 1 1 1h1.31c.07.3.13.6.23.89.36 1.02.88 1.92 1.56 2.67.68.76 1.51 1.35 2.49 1.79.98.43 2.09.65 3.33.65.99 0 1.9-.15 2.73-.46.83-.3 1.55-.74 2.17-1.32.03-.03.05-.06.08-.09l-2.41-2.15c-.01.01-.02.02-.02.03-.61.67-1.46 1-2.54 1-.8 0-1.47-.16-2.03-.47-.56-.31-1.01-.72-1.35-1.24-.28-.38-.47-.83-.63-1.3H12c.55 0 1-.45 1-1s-.45-1-1-1H6.56c0-.14-.02-.28-.02-.42 0-.2.02-.39.03-.58H13c.55 0 1-.45 1-1s-.45-1-1-1H6.94c.15-.46.34-.9.59-1.28.35-.52.8-.94 1.36-1.25zM18 11.38v0z"],exchange:["M2.5 8a2.5 2.5 0 000 5 2.5 2.5 0 000-5zm10.35 3.15a.495.495 0 10-.7.7L13.3 13H5.5c-.28 0-.5.22-.5.5s.22.5.5.5h7.79l-1.15 1.15c-.08.09-.14.21-.14.35a.495.495 0 00.85.35l2-2c.09-.09.15-.21.15-.35s-.06-.26-.15-.35l-2-2zM17.5 8a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM7.15 9.85a.495.495 0 10.7-.7L6.71 8h7.79c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H6.71l1.15-1.15c.08-.09.14-.21.14-.35a.495.495 0 00-.85-.35l-2 2c-.09.09-.15.21-.15.35s.06.26.15.35l2 2z"],"exclude-row":["M1 3h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zM0 13a1.003 1.003 0 001.71.71L4 11.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L5.41 10 7.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L4 8.59l-2.29-2.3A1.003 1.003 0 00.29 7.71L2.59 10 .3 12.29c-.19.18-.3.43-.3.71zm18-5h-7c-1.1 0-2 .9-2 2s.9 2 2 2h7c1.1 0 2-.9 2-2s-.9-2-2-2zm1 9H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"expand-all":["M4 9c.28 0 .53-.11.71-.29L10 3.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-6-6C10.53 1.11 10.28 1 10 1s-.53.11-.71.29l-6 6A1.003 1.003 0 004 9zm12 2c-.28 0-.53.11-.71.29L10 16.59 4.71 11.3A.965.965 0 004 11a1.003 1.003 0 00-.71 1.71l6 6c.18.18.43.29.71.29s.53-.11.71-.29l6-6A1.003 1.003 0 0016 11z"],export:["M5 7c.28 0 .53-.11.71-.29L9 3.41V15c0 .55.45 1 1 1s1-.45 1-1V3.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-5-5C10.53.11 10.28 0 10 0s-.53.11-.71.29l-5 5A1.003 1.003 0 005 7zm14 7c-.55 0-1 .45-1 1v3H2v-3c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"eye-off":["M20 9.96v-.03-.01-.02-.02a.794.794 0 00-.21-.43c-.55-.69-1.19-1.3-1.85-1.87l-3.93 2.62a3.966 3.966 0 01-3.96 3.77c-.47 0-.91-.1-1.33-.24l-2.24 1.49c.52.21 1.05.39 1.6.51 1.21.27 2.43.28 3.64.05 1.11-.21 2.17-.64 3.17-1.18 1.56-.84 2.99-2 4.23-3.3.23-.24.46-.49.67-.75a.87.87 0 00.21-.43v-.02-.02-.01-.03V10v-.04zm-.46-5.14c.27-.18.46-.47.46-.82 0-.55-.45-1-1-1-.21 0-.39.08-.54.18l-.01-.02L15 5.46c-.95-.53-1.95-.96-3.01-1.2a9.158 9.158 0 00-3.65-.04c-1.11.21-2.17.64-3.17 1.18-1.56.84-2.99 2-4.23 3.3-.23.24-.46.48-.67.75-.27.34-.27.76 0 1.1.64.79 1.39 1.5 2.16 2.15.26.21.52.41.79.61L.44 15.16l.01.02A1 1 0 000 16c0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 18-12-.01-.02zm-8.67 3.4c-.25-.12-.53-.2-.83-.2-1.1 0-1.99.89-1.99 1.99 0 .03.02.06.02.09l-1.78 1.19c-.14-.4-.22-.83-.22-1.28 0-2.19 1.78-3.97 3.98-3.97 1.01 0 1.91.38 2.61 1l-1.79 1.18z"],"eye-on":["M13.3 8.71c.18.18.43.29.71.29s.53-.11.71-.29l4.99-5a1.003 1.003 0 00-1.42-1.42L14 6.58l-2.29-2.29a.956.956 0 00-.7-.29 1.003 1.003 0 00-.71 1.71l3 3zM20 9.96v-.03-.01-.02-.02a.823.823 0 00-.21-.44c-.44-.55-.94-1.05-1.46-1.52l-2.2 2.2c-.55.54-1.3.88-2.12.88-.05 0-.09-.01-.14-.01a3.978 3.978 0 01-3.86 3.02 4.007 4.007 0 01-1.66-7.65A2.97 2.97 0 018.02 5c0-.28.05-.54.12-.8-1.05.22-2.07.64-3.02 1.15-1.57.85-3 2.02-4.24 3.33-.23.25-.46.5-.67.76-.28.35-.28.77 0 1.12.64.8 1.4 1.52 2.17 2.17 1.66 1.41 3.56 2.58 5.66 3.06 1.21.27 2.43.29 3.65.05 1.11-.21 2.18-.65 3.18-1.19 1.57-.85 3-2.02 4.24-3.33.23-.24.46-.49.67-.76.11-.12.18-.27.21-.44v-.02-.02-.01-.03V10c.01-.01.01-.03.01-.04zm-9.99 2.05c1.03 0 1.87-.79 1.98-1.8l-.09-.09-.01.01-2.1-2.11c-1 .11-1.77.95-1.77 1.98-.01 1.11.89 2.01 1.99 2.01z"],"eye-open":["M10.01 7.984A2.008 2.008 0 008.012 9.99c0 1.103.9 2.006 1.998 2.006a2.008 2.008 0 001.998-2.006c0-1.103-.9-2.006-1.998-2.006zM20 9.96v-.03-.01-.02-.02a.827.827 0 00-.21-.442c-.64-.802-1.398-1.514-2.168-2.166-1.658-1.404-3.566-2.587-5.664-3.058a8.982 8.982 0 00-3.656-.05c-1.11.2-2.178.641-3.177 1.183-1.569.852-2.997 2.016-4.246 3.33-.23.25-.46.49-.67.761-.279.351-.279.773 0 1.124.64.802 1.4 1.514 2.169 2.166 1.658 1.404 3.566 2.577 5.664 3.058 1.209.271 2.438.281 3.656.05 1.11-.21 2.178-.651 3.177-1.193 1.569-.852 2.997-2.016 4.246-3.33.23-.24.46-.49.67-.751.11-.12.179-.271.209-.442v-.02-.02-.01-.03V10v-.04zM10.01 14A4.003 4.003 0 016.014 9.99a4.003 4.003 0 013.996-4.011 4.003 4.003 0 013.996 4.011 4.003 4.003 0 01-3.996 4.011z"],"fast-backward":["M18 3c-.23 0-.42.09-.59.21l-.01-.01L11 8V4c0-.55-.45-1-1-1-.23 0-.42.09-.59.21L9.4 3.2l-8 6 .01.01C1.17 9.4 1 9.67 1 10s.17.6.41.79l-.01.01 8 6 .01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1v-4l6.4 4.8.01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"fast-forward":["M19 10c0-.33-.17-.6-.41-.79l.01-.01-8-6-.01.01C10.42 3.09 10.23 3 10 3c-.55 0-1 .45-1 1v4L2.6 3.2l-.01.01C2.42 3.09 2.23 3 2 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01L9 12v4c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01 8-6-.01-.01c.24-.19.41-.46.41-.79z"],feed:["M2.5 15a2.5 2.5 0 000 5 2.5 2.5 0 000-5zm.5-5c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5 2.24 5 5 0 .55.45 1 1 1s1-.45 1-1c0-3.87-3.13-7-7-7zM3 0c-.55 0-1 .45-1 1s.45 1 1 1c8.28 0 15 6.72 15 15 0 .55.45 1 1 1s1-.45 1-1C20 7.61 12.39 0 3 0zm0 5c-.55 0-1 .45-1 1s.45 1 1 1c5.52 0 10 4.48 10 10 0 .55.45 1 1 1s1-.45 1-1C15 10.37 9.63 5 3 5z"],"feed-subscribed":["M2.5 15a2.5 2.5 0 000 5 2.5 2.5 0 000-5zM3 2c1.76 0 3.44.31 5.01.87.03-.71.31-1.35.75-1.85C6.96.37 5.03 0 3 0c-.55 0-1 .45-1 1s.45 1 1 1zm10.32 4.67a.99.99 0 001.4 0l4.98-4.98c.19-.17.3-.42.3-.7 0-.55-.45-1-1-1a.99.99 0 00-.7.29l-4.27 4.27-2.28-2.28a.99.99 0 00-.7-.29c-.55 0-.99.45-.99 1 0 .28.11.52.29.7l2.97 2.99zM3 10c-.55 0-1 .45-1 1s.45 1 1 1c2.76 0 5 2.24 5 5 0 .55.45 1 1 1s1-.45 1-1c0-3.87-3.13-7-7-7zm13.94-2.69l-.82.82-.02-.02c-.2.2-.42.37-.67.51A14.8 14.8 0 0118 17c0 .55.45 1 1 1s1-.45 1-1c0-3.61-1.14-6.94-3.06-9.69zM3 5c-.55 0-1 .45-1 1s.45 1 1 1c5.52 0 10 4.48 10 10 0 .55.45 1 1 1s1-.45 1-1C15 10.37 9.63 5 3 5z"],film:["M19 2h-5v3H6V2H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h5v-3h8v3h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM4 17H2v-2h2v2zm0-3H2v-2h2v2zm0-3H2V9h2v2zm0-3H2V6h2v2zm0-3H2V3h2v2zm10 8H6V7h8v6zm4 4h-2v-2h2v2zm0-3h-2v-2h2v2zm0-3h-2V9h2v2zm0-3h-2V6h2v2zm0-3h-2V3h2v2z"],filter:["M18 1H2a1.003 1.003 0 00-.71 1.71L7 8.41V18a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71V8.41l5.71-5.71c.18-.17.29-.42.29-.7 0-.55-.45-1-1-1z"],"filter-keep":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm4 11c-.28 0-.53.11-.71.29L15 16.59l-1.29-1.29A.965.965 0 0013 15a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l4-4A1.003 1.003 0 0019 13z"],"filter-list":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm-4 8c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7c-.55 0-1 .45-1 1zm8 7h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1zm0-4h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1z"],"filter-open":["M15 2c0 .28-.11.53-.29.7L10 7.41V13c0 .28-.11.53-.29.71l-3 3A1.003 1.003 0 015 16V7.41L.29 2.71A1.003 1.003 0 011 1h13c.55 0 1 .45 1 1zm4.707 11.293a1 1 0 010 1.414l-4 4c-.63.63-1.707.184-1.707-.707v-8c0-.89 1.077-1.337 1.707-.707l4 4z"],"filter-remove":["M15 2c0-.55-.45-1-1-1H1a1.003 1.003 0 00-.71 1.71L5 7.41V16a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71V7.41l4.71-4.71c.18-.17.29-.42.29-.7zm2.91 13.5l1.79-1.79c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-1.79 1.79-1.79-1.79a1.003 1.003 0 00-1.42 1.42l1.79 1.79-1.79 1.79a1.003 1.003 0 001.42 1.42l1.79-1.79 1.79 1.79a1.003 1.003 0 001.42-1.42l-1.8-1.79z"],flag:["M3 3c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1zm0-3c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm2 4.08v8.28c3.01-2.41 8.67 2.64 13 0V4.08C13.61 7.14 8.01 1 5 4.08z"],flame:["M11.622 0c0 1.71.49 3.077 1.472 4.103C16.364 6.496 18 9.23 18 12.308c0 3.418-1.962 5.983-5.887 7.692 2.887-3 2.453-4.23-.49-8C8.5 13.5 9 14.5 9.5 16.5c-1.048 0-2 0-2.5-.5 0 .684 1.197 2.5 1.952 4-3.924-1.026-8.123-7.18-6.651-7.692.981-.342 2.126-.171 3.434.513C4.1 6.667 6.062 2.393 11.622 0z"],flash:["M4.96 6.37a1.003 1.003 0 001.42-1.42l-2-2a1.07 1.07 0 00-.71-.28 1.003 1.003 0 00-.71 1.71l2 1.99zm9.37.3c.28 0 .53-.11.71-.29l2-2a1.003 1.003 0 00-1.42-1.42l-2 2a1.003 1.003 0 00.71 1.71zM10 5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S9 .45 9 1v3c0 .55.45 1 1 1zm-5 5c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1zm14-1h-3c-.55 0-1 .45-1 1s.45 1 1 1h3c.55 0 1-.45 1-1s-.45-1-1-1zm-9-3c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm5.04 1.63a1.003 1.003 0 00-1.42 1.42l2 2a1.003 1.003 0 001.42-1.42l-2-2zM10 15c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1s1-.45 1-1v-3c0-.55-.45-1-1-1zm-4.33-1.67c-.28 0-.53.11-.71.29l-2 2a1.003 1.003 0 001.42 1.42l2-2a1.003 1.003 0 00-.71-1.71z"],"floppy-disk":["M14 1h-3v5h3V1zm5.71 2.29l-3-3A.997.997 0 0016 0h-1v7H5V0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V4c0-.28-.11-.53-.29-.71zM17 19H3v-8c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v8z"],"flow-branch":["M14.425 7.953a3.98 3.98 0 01.562 2.045 3.98 3.98 0 01-.583 2.08L18 15.671V12.98c0-.248.097-.496.29-.689.379-.379 1.047-.38 1.426 0a.94.94 0 01.283.696l-.001 5.049a.957.957 0 01-.276.69.955.955 0 01-.69.273h-5.059a.971.971 0 01-.689-.289 1.026 1.026 0 010-1.417.972.972 0 01.69-.29h2.702l-3.634-3.573a3.998 3.998 0 01-5.924-2.431H1a1 1 0 010-2h6.12a3.998 3.998 0 015.96-2.409L16.665 3l-2.694-.001a.972.972 0 01-.689-.29 1.035 1.035 0 010-1.425.94.94 0 01.696-.283l5.05.001c.248 0 .497.083.69.276a.954.954 0 01.272.69l.001 5.052a.971.971 0 01-.29.689 1.028 1.028 0 01-1.419 0 .972.972 0 01-.29-.69V4.323l-3.567 3.63z"],"flow-end":["M12 9.919a3.998 3.998 0 014-3.92c2.21 0 4 1.79 4 3.997a3.998 3.998 0 01-4 3.996 3.998 3.998 0 01-4-3.916.967.967 0 01-.28.612L7.685 14.71a.958.958 0 01-.686.285c-.536 0-.994-.461-.994-.997 0-.273.107-.528.283-.704l2.379-2.302H.98c-.537 0-.976-.46-.976-.996s.44-.992.976-.992h7.676L6.287 6.687a.957.957 0 01-.283-.686c0-.536.458-.996.994-.996.274 0 .51.1.686.285l4.027 4.024c.159.158.27.365.29.605z"],"flow-linear":["M5.125 10.997H.976C.439 10.997 0 10.537 0 10c0-.536.44-.993.976-.993h4.148a4.002 4.002 0 017.752 0h3.776L14.293 6.69a.962.962 0 01-.285-.687c0-.537.46-1.001.996-1.001a.96.96 0 01.698.3l4.005 4.015c.176.176.293.41.293.683a.972.972 0 01-.283.693L15.702 14.7a.997.997 0 01-.698.297c-.537 0-.996-.453-.996-.99 0-.273.107-.517.283-.692l2.371-2.318h-3.787a4.002 4.002 0 01-7.75 0z"],"flow-review":["M6.13 9.004A4.005 4.005 0 0110.012 6c1.87 0 3.44 1.278 3.881 3.005h2.768l-2.354-2.317a.97.97 0 01-.283-.691c0-.536.462-.995 1-.995.273 0 .517.107.693.283l4 4.041a.97.97 0 01.284.692.956.956 0 01-.293.682l-3.991 3.997a.944.944 0 01-.694.292c-.537 0-1-.46-1-.997a.97.97 0 01.284-.692l2.345-2.29h-2.765a4.005 4.005 0 01-3.875 2.981 4.005 4.005 0 01-3.874-2.981H3.349l2.376 2.308a.97.97 0 01.283.691 1 1 0 01-.994.983.989.989 0 01-.713-.291L.293 10.699A.956.956 0 010 10.017a.97.97 0 01.283-.692l4.03-4.037a.996.996 0 01.701-.283c.537 0 .994.464.994 1a.97.97 0 01-.283.691L3.34 9.004h2.79z"],"flow-review-branch":["M13.04 13.424c-.6.36-1.302.568-2.052.568a4 4 0 01-3.868-2.999H3.342l2.372 2.31c.176.176.283.42.283.694 0 .537-.452.998-.988.998a.935.935 0 01-.691-.289L.292 10.683A.96.96 0 010 9.999c0-.274.107-.518.283-.694l4.035-4.04a.973.973 0 01.691-.288c.536 0 .988.47.988 1.007a.975.975 0 01-.283.694L3.332 8.984h3.786a4 4 0 013.87-3.006c.771 0 1.492.22 2.102.599l3.565-3.57-2.538-.003a.974.974 0 01-.69-.29c-.38-.38-.38-1.052-.002-1.431A.94.94 0 0114.122 1l4.896.005a.96.96 0 01.69.277c.193.193.27.442.27.69l.005 4.9a.971.971 0 01-.289.69 1.023 1.023 0 01-1.416 0 .975.975 0 01-.29-.691l-.003-2.54-3.554 3.62c.351.596.553 1.291.553 2.034 0 .763-.213 1.477-.583 2.084l3.595 3.595.003-2.54c0-.249.097-.497.29-.69.38-.38 1.05-.381 1.429-.002a.94.94 0 01.282.697l-.005 4.9a.927.927 0 01-.277.675.974.974 0 01-.69.291L13.974 19a.97.97 0 01-.69-.29 1.03 1.03 0 01.002-1.42.974.974 0 01.69-.29l2.696-.003-3.632-3.573z"],flows:["M17.5 7.93a2.5 2.5 0 00-2.45 2h-2.3l-4.01-4-.75.75 3.26 3.25h-6.3a2.5 2.5 0 100 1h6.3l-3.26 3.25.75.75 4.01-4h2.3a2.5 2.5 0 102.45-3z"],"folder-close":["M0 17c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V7H0v10zM19 4H9.41l-1.7-1.71A.997.997 0 007 2H1c-.55 0-1 .45-1 1v3h20V5c0-.55-.45-1-1-1z"],"folder-new":["M12.994 7c0 1.655 1.344 3 2.998 3a3.002 3.002 0 002.999-3H20v10c0 .55-.45 1-1 1H1.01c-.55 0-1-.45-1-1V7h12.984zM10.76 6H0V3c0-.55.45-1 1-1h3.998c.28 0 .53.11.71.29L7.415 4h2.579c0 .768.29 1.469.765 2zm8.23-3c.55 0 1 .45 1 1s-.45 1-1 1h-1.998v2c0 .55-.45 1-1 1s-1-.45-1-1V5h-1.998c-.55 0-1-.45-1-1s.45-1 1-1h1.999V1c0-.55.45-1 .999-1 .55 0 1 .45 1 1v2h1.999z"],"folder-open":["M20 9c0-.55-.45-1-1-1H5c-.43 0-.79.27-.93.65h-.01l-3 8h.01c-.04.11-.07.23-.07.35 0 .55.45 1 1 1h14c.43 0 .79-.27.93-.65h.01l3-8h-.01c.04-.11.07-.23.07-.35zM3.07 7.63C3.22 7.26 3.58 7 4 7h14V5c0-.55-.45-1-1-1H8.41l-1.7-1.71A.997.997 0 006 2H1c-.55 0-1 .45-1 1v12.31l3.07-7.68z"],"folder-shared":["M11 4H9.41l-1.7-1.71A.997.997 0 007 2H1c-.55 0-1 .45-1 1v3h11.78C11.3 5.47 11 4.77 11 4zm8-1h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L12.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 6.41V9c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1zm-2.46 7.7l-1.42 1.42a2.996 2.996 0 11-4.24-4.24l.88-.88H0v10c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-5.18c-.31.11-.65.18-1 .18-1.02 0-1.92-.52-2.46-1.3z"],"folder-shared-open":["M3.07 7.63C3.22 7.26 3.58 7 4 7h7.76l.54-.54A2.97 2.97 0 0111 4H8.41l-1.7-1.71A.997.997 0 006 2H1c-.55 0-1 .45-1 1v12.31l3.07-7.68zm13.47 3.07l-1.42 1.42A2.996 2.996 0 0110 10c0-.77.3-1.47.78-2H5c-.43 0-.79.27-.93.65h-.01l-3 8h.01c-.04.11-.07.23-.07.35 0 .55.45 1 1 1h14c.43 0 .79-.27.93-.65h.01l2.01-5.36c-1-.01-1.88-.52-2.41-1.29zM19 3h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L12.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 6.41V9c0 .55.45 1 1 1s1-.45 1-1V4c0-.55-.45-1-1-1z"],follower:["M11.54 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.69 3.69 0 00-1.29-1.86C9.69 4.25 8.8 4 8.01 4c-.8 0-1.69.25-2.32.73-.61.47-1.06 1.13-1.28 1.86-.05.17-.09.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.44.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59-1.48.65-3.71 1.35-4.16 2.4C-.16 19.38.02 20 .02 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.68-1.75-4.16-2.41zm8.15-12.63l-3-3a.956.956 0 00-.7-.29 1.003 1.003 0 00-.71 1.71L16.58 3H13c-.55 0-1 .45-1 1s.45 1 1 1h3.58l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.3-.71z"],following:["M11.55 15.92c-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.69 3.69 0 00-1.29-1.86C9.7 4.25 8.81 4 8.02 4c-.79 0-1.68.25-2.31.73-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.44.32-.48.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59C3 16.56.77 17.26.32 18.31-.15 19.38.04 20 .04 20h15.95s.18-.62-.27-1.67c-.46-1.06-2.69-1.75-4.17-2.41zM19 3h-3.58l1.29-1.29A1.003 1.003 0 0015.29.29l-3 3c-.17.18-.28.43-.28.71 0 .28.11.53.29.71l3 3c.18.18.43.29.7.29a1.003 1.003 0 00.71-1.71L15.42 5H19c.55 0 1-.45 1-1s-.45-1-1-1z"],font:["M17.93 18.64l-7-18C10.78.27 10.42 0 10 0s-.78.27-.93.64l-7 18c-.04.11-.07.23-.07.36 0 .55.45 1 1 1 .42 0 .78-.27.93-.64L6.41 13h7.19l2.47 6.36c.15.37.51.64.93.64.55 0 1-.45 1-1 0-.13-.03-.25-.07-.36zM7.18 11L10 3.76 12.82 11H7.18z"],fork:["M16.71 11.29a1.003 1.003 0 00-1.42 1.42l1.3 1.29h-2.17l-8-8h10.17L15.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 4H1c-.55 0-1 .45-1 1s.45 1 1 1h2.59l9.71 9.71c.17.18.42.29.7.29h2.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3z"],form:["M2 13v4h4v-4H2zm-1-2h6c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6c0-.55.45-1 1-1zm11-7h7c.55 0 1 .45 1 1s-.45 1-1 1h-7c-.55 0-1-.45-1-1s.45-1 1-1zM8 1a1.003 1.003 0 01.71 1.71l-5 6C3.53 8.89 3.28 9 3 9s-.53-.11-.71-.29l-2-2a1.003 1.003 0 011.42-1.42L3 6.59l4.29-5.3C7.47 1.11 7.72 1 8 1zm4 13h7c.55 0 1 .45 1 1s-.45 1-1 1h-7c-.55 0-1-.45-1-1s.45-1 1-1z"],"full-circle":["M9.96 0a10 10 0 100 20 10 10 0 100-20z"],"full-stacked-chart":["M15 16h2c.55 0 1-.45 1-1v-5h-4v5c0 .55.45 1 1 1zM12 2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v4h4V2zm6 4h-4v3h4V6zm0-4c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h4V2zm-6 5H8v5h4V7zm-9 9h2c.55 0 1-.45 1-1v-3H2v3c0 .55.45 1 1 1zm6 0h2c.55 0 1-.45 1-1v-2H8v2c0 .55.45 1 1 1zm10 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM6 2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v3h4V2zm0 4H2v5h4V6z"],fullscreen:["M3.41 2H6c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1s1-.45 1-1V3.41L7.29 8.7c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L3.41 2zM8 11c-.28 0-.53.11-.71.29L2 16.59V14c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1H3.41l5.29-5.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1zM19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm0 13c-.55 0-1 .45-1 1v2.59l-5.29-5.29A.965.965 0 0012 11a1.003 1.003 0 00-.71 1.71l5.3 5.29H14c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1z"],function:["M10.14 5.82H8.73c.4-1.66.94-2.87 1.6-3.64.4-.48.8-.72 1.18-.72.08 0 .14.02.19.07.05.05.07.1.07.18 0 .07-.05.19-.16.37s-.16.36-.16.52c0 .23.08.43.25.59a.9.9 0 00.64.25c.28 0 .51-.1.7-.3.19-.2.28-.47.28-.81 0-.39-.14-.7-.42-.94-.28-.24-.74-.36-1.36-.36-.97 0-1.86.29-2.65.87-.79.56-1.54 1.52-2.26 2.85-.24.46-.48.75-.7.88-.22.13-.57.19-1.06.19l-.32 1.15H5.9l-1.99 7.85c-.33 1.29-.56 2.09-.67 2.39-.17.44-.43.81-.77 1.12a.74.74 0 01-.5.19c-.05 0-.1-.02-.14-.05l-.04-.07c0-.03.05-.1.15-.2.1-.1.15-.26.15-.47 0-.23-.08-.42-.23-.57-.16-.15-.38-.23-.67-.23-.35 0-.63.1-.85.29-.21.2-.32.43-.32.7 0 .29.13.54.39.75.25.22.65.33 1.2.33.88 0 1.66-.23 2.33-.69.68-.46 1.27-1.17 1.78-2.14.51-.96 1.03-2.52 1.56-4.66l1.14-4.54H9.8l.34-1.15zm6.8 1.95c.25-.2.51-.29.78-.29.1 0 .29.04.56.11.27.08.51.11.72.11.29 0 .52-.1.72-.3.18-.19.28-.45.28-.77 0-.33-.1-.6-.29-.8-.19-.2-.47-.29-.82-.29-.32 0-.62.08-.9.23-.28.15-.64.49-1.08 1-.33.38-.81 1.05-1.44 2a9.712 9.712 0 00-1.31-3.22l-3.4.59-.07.37c.25-.05.47-.08.64-.08.34 0 .62.15.84.44.35.46.84 1.85 1.46 4.19-.49.66-.82 1.09-1 1.3-.3.33-.55.54-.74.64-.15.08-.32.12-.51.12-.14 0-.38-.08-.7-.24-.22-.1-.42-.16-.59-.16-.33 0-.6.11-.82.32-.21.22-.32.49-.32.83 0 .31.1.57.3.77.2.2.47.29.8.29.32 0 .63-.07.92-.21.29-.14.64-.43 1.08-.88.43-.45 1.03-1.16 1.79-2.14.29.93.55 1.61.76 2.03.21.42.46.73.74.91.28.19.62.28 1.04.28.4 0 .81-.15 1.23-.44.55-.38 1.1-1.04 1.68-1.97l-.35-.21c-.39.55-.68.89-.87 1.03-.12.09-.27.13-.44.13-.2 0-.4-.13-.59-.38-.33-.43-.77-1.63-1.33-3.6.47-.86.89-1.44 1.23-1.71z"],"gantt-chart":["M4 7h5c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm3 2v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1zm12 3h-6c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0 4H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],geofence:["M8 11l.075.003.126.017.111.03.111.044.098.052.096.067.09.08c.036.035.068.073.097.112l.071.11.054.114.035.105.03.148L9 12V18a1 1 0 01-1.993.117L7 18v-3.586l-5.293 5.293a1 1 0 01-1.497-1.32l.083-.094L5.584 13h-3.58a1 1 0 01-.117-1.993L2.004 11H8zm3.018-11a1.003 1.003 0 01.39.087l.12.063.031.02.1.078 8.027 7.026.062.064.068.086.044.068.064.128.04.117.024.113.011.108v.1l-.007.073-.019.103-.037.121-.039.09-.05.087-4.996 7.994c-.06.097-.137.183-.226.254l-.093.067-.095.053-.087.037-.125.037a1.018 1.018 0 01-.218.026H11v-5a3 3 0 00-2.824-2.995L8 9H3V6a1 1 0 01.321-.734l.098-.08 7-5a1.01 1.01 0 01.45-.178L11.018 0z"],geolocation:["M0 8.33l9.17 2.5 2.5 9.17L20 0z"],geosearch:["M8 18.88c-3.79 0-6.88-3.09-6.88-6.88 0-.61.08-1.22.23-1.79.03.01.06-.01.1-.01h.09v.55c0 .23.21.42.44.42.04 0 .09-.01.12-.02l.9.88c.09.09.23.09.32 0s.09-.23 0-.32l-.86-.9c0-.02.05-.04.05-.07v-.13c0-.18.1-.25.29-.41h.53c.1 0 .19-.01.27-.05.01-.01.02 0 .03-.01.02-.01.03-.02.05-.04.01-.01.02-.01.02-.02l.02-.02 1.13-1.13c-.16-.32-.3-.65-.42-.99h-.64v-.53c0-.01.06.06.06-.1h.38c-.04-.16-.08-.32-.1-.48h-.71c.2-.16.42-.31.64-.45C4.02 6.09 4 5.8 4 5.5c0-.14.01-.28.02-.43C1.62 6.46 0 9.04 0 12c0 4.41 3.59 8 8 8 3.87 0 7.09-2.77 7.82-6.44l-.97-1.1c-.26 3.57-3.23 6.42-6.85 6.42zm-2.12-3.67v-.35h.15c.29 0 .49-.23.49-.53v-.68c0-.01.01-.01 0-.02L4.71 11.8h-.77c-.29 0-.47.24-.47.53v2c0 .29.18.53.47.53h.33v2.02c0 .28.28.51.56.51s.56-.23.56-.51v-1.22h-.01c.29 0 .5-.16.5-.45zm13.83-2.92l-3.68-3.68c.14-.21.27-.42.38-.65.02-.04.04-.07.05-.11.11-.22.2-.45.28-.69v-.01c.07-.24.13-.48.17-.73l.03-.17c.04-.24.06-.49.06-.75C17 2.46 14.54 0 11.5 0S6 2.46 6 5.5 8.46 11 11.5 11c.26 0 .51-.02.76-.06l.17-.03c.25-.04.49-.1.73-.17h.01c.24-.08.47-.17.69-.28.04-.02.07-.04.11-.05.23-.11.44-.24.65-.38l3.68 3.68c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71zM11.5 9.5c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm1.93 5.33v-.65c0-.11-.13-.21-.24-.21-.11 0-.24.09-.24.21v.65c0 .11.13.21.24.21.11 0 .24-.1.24-.21zm-2.41.67h.83c.29 0 .46-.21.46-.5v-1.86l.23-.22c-.34.05-.69.08-1.04.08-.36 0-.7-.03-1.05-.08.03.05.06.1.08.16V15c.01.29.2.5.49.5z"],"git-branch":["M15 2c-1.66 0-3 1.34-3 3 0 1.3.84 2.4 2 2.82V9c0 1.1-.9 2-2 2H8c-.73 0-1.41.21-2 .55V5.82C7.16 5.4 8 4.3 8 3c0-1.66-1.34-3-3-3S2 1.34 2 3c0 1.3.84 2.4 2 2.82v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.25-.77-2.3-1.85-2.75C6.45 13.52 7.16 13 8 13h4c2.21 0 4-1.79 4-4V7.82C17.16 7.4 18 6.3 18 5c0-1.66-1.34-3-3-3zM5 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 16c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM15 6c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-commit":["M19 9h-4.1a5 5 0 00-9.8 0H1c-.55 0-1 .45-1 1s.45 1 1 1h4.1a5 5 0 009.8 0H19c.55 0 1-.45 1-1s-.45-1-1-1zm-9 4c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"git-merge":["M15 8c-1.3 0-2.4.84-2.82 2H11c-2.49 0-4.54-1.83-4.92-4.21A2.995 2.995 0 005 0C3.34 0 2 1.34 2 3c0 1.3.84 2.4 2 2.81v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V9.86C7.27 11.17 9.03 12 11 12h1.18A2.996 2.996 0 0018 11c0-1.66-1.34-3-3-3zM5 18c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM5 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm10 8c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-new-branch":["M17 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1V5h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3 4.86V9c0 1.1-.9 2-2 2H8c-.73 0-1.41.21-2 .55V5.82C7.16 5.4 8 4.3 8 3c0-1.66-1.34-3-3-3S2 1.34 2 3c0 1.3.84 2.4 2 2.82v8.37C2.84 14.6 2 15.7 2 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.25-.77-2.3-1.85-2.75C6.45 13.52 7.16 13 8 13h4c2.21 0 4-1.79 4-4V7.86c-.32.08-.65.14-1 .14s-.68-.06-1-.14zM5 2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 16c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-pull":["M17 14.18V7c0-2.21-1.79-4-4-4h-2.59l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C7.11 3.47 7 3.72 7 4c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L10.41 5H13c1.1 0 2 .9 2 2v7.18A2.996 2.996 0 0016 20c1.66 0 3-1.34 3-3 0-1.3-.84-2.4-2-2.82zM16 18c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 1C2.34 1 1 2.34 1 4c0 1.3.84 2.4 2 2.82v7.37C1.84 14.6 1 15.7 1 17c0 1.66 1.34 3 3 3s3-1.34 3-3c0-1.3-.84-2.4-2-2.82V6.82C6.16 6.4 7 5.3 7 4c0-1.66-1.34-3-3-3zm0 17c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zM4 5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"git-push":["M15 11c0-.28-.11-.53-.29-.71l-3-3C11.53 7.11 11.28 7 11 7s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42l1.29-1.3V19c0 .55.45 1 1 1s1-.45 1-1v-8.59l1.29 1.29c.18.19.43.3.71.3.55 0 1-.45 1-1zm4-11H1C.45 0 0 .45 0 1v16c0 .55.45 1 1 1h7v-2H2v-2h6v-1H4V2h14v11h-4v1h4v2h-4v2h5c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM5 8h2V6H5v2zm2-5H5v2h2V3z"],"git-repo":["M7 3H5v2h2V3zm0 6H5v2h2V9zm0-3H5v2h2V6zm12-6H1C.45 0 0 .45 0 1v16c0 .55.45 1 1 1h4v2l2-1 2 1v-2h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 16H9v-1H5v1H2v-2h16v2zm0-3H4V2h14v11z"],glass:["M17 6V0H3v6c0 3.53 2.61 6.43 6 6.92V18H6c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1h-3v-5.08c3.39-.49 6-3.39 6-6.92z"],globe:["M7.53 4.37c.1-.1.1-.26 0-.35l-.68-.68c-.1-.1-.25-.1-.35 0-.1.1-.1.26 0 .35l.68.68c.1.1.25.1.35 0zm3.17.06h.3c.09 0 .16-.01.16-.1 0-.09-.07-.1-.16-.1h-.3c-.09 0-.16.01-.16.1s.07.1.16.1zm.98 1.15c.09 0 .19-.08.19-.17v-.42c0-.09-.1-.17-.19-.17s-.19.08-.19.17v.42c0 .09.1.17.19.17zm-6.5 4.19c-.35 0-.56.28-.56.63v2.37c0 .35.21.62.56.62h.39v2.4c0 .34.33.61.67.61s.67-.27.67-.61v-1.44h-.02c.35 0 .6-.19.6-.54v-.41h.18c.35 0 .58-.28.58-.62v-.81c0-.01.01-.01 0-.02L6.1 9.77h-.92zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8 0-.74.11-1.46.3-2.14h.03v.65c0 .28.25.5.53.5.05 0 .1-.01.15-.02l1.05 1.05c.1.11.28.11.38 0 .1-.1.11-.27 0-.38L3.42 8.59c0-.03.05-.05.05-.08v-.16c0-.22.12-.3.34-.49h.63c.12 0 .23-.01.32-.07.01-.01.02 0 .03-.01.02-.02.04-.03.06-.04.01-.01.02-.01.03-.02l.02-.02 2.15-2.15c.24-.24.24-.63 0-.86-.23-.24-.62-.19-.86.04l-.41.46H5v-.64c0-.01.07.07.07-.12h.87c.17 0 .3-.12.3-.29 0-.17-.13-.29-.3-.29H4.88C6.27 2.7 8.05 2 10 2s3.73.7 5.12 1.86h-1.58l-.01-.04c-.06 0-.12 0-.17.04l-.71.7c-.09.09-.09.23 0 .31.09.09.23.09.32 0l.56-.6.01-.03h.34c0 .19-.1.13-.1.16v.1c0 .29-.2.5-.49.5h-.51c-.25 0-.52.28-.52.54v.23h-.12c-.16 0-.27.08-.27.24v.33h-.32c-.23 0-.41.15-.41.38 0 .22.18.35.41.35.1 0 .19.04.26-.16l.06.01.66-.59h.23l.53.5c.04.04.11.03.16-.01.04-.04.04-.16 0-.2L13 6.15h.32l.12.16c.25.25.65.23.89-.02l.12-.14H15c.02 0 .11.07.11.07v.33s-.06-.01-.07-.01h-.49c-.16 0-.28.13-.28.29 0 .16.13.29.28.29h.49c.01 0 .07-.01.07-.01v.2c-.19.28-.33.57-.62.57h-1.28s0-.01-.01-.01l-.58-.58a.622.622 0 00-.89 0l-.58.58s0 .01-.01.01h-.34c-.35 0-.67.28-.67.63v1.25c0 .35.32.61.67.61h1.22c.46.19.78.48.97.94v2.28c0 .35.23.6.58.6h.98c.35 0 .54-.25.54-.6v-2.2l1.21-1.17.04-.02.02-.01h.04c.1-.11.2-.26.2-.42V8.49c0-.25-.22-.44-.42-.63h.58c.02.38.29.57.63.57h.43c.13.51.18 1.03.18 1.57 0 4.42-3.58 8-8 8zm6.16-5.65c-.14 0-.29.11-.29.25v.77c0 .14.15.25.29.25.14 0 .29-.11.29-.25v-.77c0-.14-.15-.25-.29-.25zM10.5 3.48c0-.34-.28-.57-.62-.57h-.74c-.34 0-.57.25-.57.59 0 .05-.13.06.06.1v.64c0 .2.09.36.29.36.2 0 .29-.16.29-.36v-.19h.68c.33 0 .61-.23.61-.57z"],"globe-network":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm7.39 7h-3.63c-.31-1.99-.92-3.66-1.72-4.73 2.45.65 4.41 2.42 5.35 4.73zM13 10c0 .69-.04 1.36-.11 2H7.11a18.419 18.419 0 010-4h5.77c.08.64.12 1.31.12 2zm-3-8c1.07 0 2.25 2.05 2.75 5h-5.5c.5-2.95 1.68-5 2.75-5zm-2.04.27C7.16 3.34 6.55 5.01 6.24 7H2.61c.94-2.31 2.9-4.08 5.35-4.73zM2 10c0-.69.11-1.36.28-2h3.83a18.419 18.419 0 000 4H2.28c-.17-.64-.28-1.31-.28-2zm.61 3h3.63c.31 1.99.92 3.66 1.72 4.73A7.996 7.996 0 012.61 13zM10 18c-1.07 0-2.25-2.05-2.75-5h5.5c-.5 2.95-1.68 5-2.75 5zm2.04-.27c.79-1.07 1.4-2.74 1.72-4.73h3.63a7.996 7.996 0 01-5.35 4.73zM13.89 12a18.419 18.419 0 000-4h3.83c.17.64.28 1.31.28 2s-.11 1.36-.28 2h-3.83z"],graph:["M17.5 4A2.5 2.5 0 0015 6.5c0 .06.01.12.02.18l-1.9.84C12.38 6.6 11.27 6 10 6c-.83 0-1.59.25-2.23.68L4.91 4.14c.05-.21.09-.42.09-.64a2.5 2.5 0 00-5 0A2.5 2.5 0 002.5 6c.42 0 .81-.11 1.16-.3l2.79 2.48C6.17 8.73 6 9.34 6 10c0 1.41.73 2.64 1.83 3.35l-.56 1.67A2.498 2.498 0 005 17.5a2.5 2.5 0 005 0c0-.74-.32-1.39-.83-1.85l.56-1.68c.09.01.18.03.27.03 2.21 0 4-1.79 4-4 0-.22-.03-.44-.07-.65l2.02-.9c.43.34.96.55 1.55.55a2.5 2.5 0 000-5z"],"graph-remove":["M17.41 4l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L16 2.59 13.71.3A.965.965 0 0013 0a1.003 1.003 0 00-.71 1.71L14.59 4 12.3 6.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L16 5.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L17.41 4zM19 10c-.83 0-1.55-.36-2.09-.91l-.03.03-.88-.88-.88.88a2.996 2.996 0 11-4.24-4.24l.88-.88-.88-.88.03-.03C10.36 2.55 10 1.83 10 1c0-.35.07-.68.18-.99-.06 0-.12-.01-.18-.01C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-.06-.01-.12-.01-.18-.31.11-.64.18-.99.18z"],"greater-than":["M12.838 10l-9.154 3.051a1 1 0 00.632 1.898l12-4c.912-.304.912-1.594 0-1.898l-12-4a1 1 0 00-.632 1.898L12.838 10z"],"greater-than-or-equal-to":["M3.684 11.051a1 1 0 00.632 1.898l12-4c.912-.304.912-1.594 0-1.898l-12-4a1 1 0 00-.632 1.898L12.838 8l-9.154 3.051zM4 15h12a1 1 0 110 2H4a1 1 0 010-2z"],grid:["M19 11c.55 0 1-.45 1-1s-.45-1-1-1h-2V5h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-4V1c0-.55-.45-1-1-1S9 .45 9 1v2H5V1c0-.55-.45-1-1-1S3 .45 3 1v2H1c-.55 0-1 .45-1 1s.45 1 1 1h2v4H1c-.55 0-1 .45-1 1s.45 1 1 1h2v4H1c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1v-2h4v2c0 .55.45 1 1 1s1-.45 1-1v-2h4v2c0 .55.45 1 1 1s1-.45 1-1v-2h2c.55 0 1-.45 1-1s-.45-1-1-1h-2v-4h2zM9 15H5v-4h4v4zm0-6H5V5h4v4zm6 6h-4v-4h4v4zm0-6h-4V5h4v4z"],"grid-view":["M0 19c0 .55.45 1 1 1h8v-9H0v8zM0 1v8h9V0H1C.45 0 0 .45 0 1zm19-1h-8v9h9V1c0-.55-.45-1-1-1zm-8 20h8c.55 0 1-.45 1-1v-8h-9v9z"],"group-objects":["M6 7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zm8-3H6c-3.31 0-6 2.69-6 6s2.69 6 6 6h8c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 11H6c-2.76 0-5-2.24-5-5s2.24-5 5-5h8c2.76 0 5 2.24 5 5s-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"grouped-bar-chart":["M12 16h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1zm7 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-3-1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1h-1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1zm-9 0h1c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1H7c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1zm-4 0h1c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1z"],hand:["M17 5c-.42 0-.79.27-.93.64L14.38 10h-.77l1.34-6.67c.03-.1.05-.21.05-.33a.998.998 0 00-1.98-.19h-.01L11.57 10H11V1c0-.55-.45-1-1-1S9 .45 9 1v9h-.2L6.97 2.76a.997.997 0 00-1.73-.41l-.03.03c-.01.02-.02.03-.03.04-.01.02-.01.03-.02.04v.01c-.01.01-.02.02-.02.03v.01c-.02.01-.02.02-.03.03 0 0 0 .01-.01.01 0 .01 0 .02-.01.03 0 0 0 .01-.01.01 0 .01-.01.02-.01.03 0 0 0 .01-.01.01 0 .01-.01.02-.01.03 0 .01 0 .01-.01.02 0 .01-.01.02-.01.03 0 .01 0 .01-.01.02 0 .01-.01.02-.01.03v.02c0 .01 0 .02-.01.03V3c0 .05 0 .09.01.14l1.45 10.25L6 12.7v.01L3.84 9.45h-.01A.98.98 0 003 9c-.55 0-1 .45-1 1 0 .2.06.39.17.55L6 18.44C7.06 19.4 8.46 20 10 20c3.31 0 6-2.69 6-6v-1.84l.01-.03v-.06l1.94-5.75A1.003 1.003 0 0017 5z"],"hand-down":["M17.68 9.84C15.91 9 14.27 6.49 13.45 4.9 12.41 2.43 12.21 0 7.87 0 5.49 0 3.95.76 3.05 2.65 2.31 4.2 2 5.48 2 9.79v.99c0 .82.69 1.48 1.54 1.48.38 0 .73-.14 1-.36.19.6.78 1.05 1.47 1.05.47 0 .89-.2 1.17-.52.26.47.77.79 1.36.79.65 0 1.2-.39 1.43-.93l.03.77v5.44c0 .48.23.91.59 1.18.21.19.5.32.85.32h.06c.83 0 1.5-.67 1.5-1.5v-8.24l.01-.67c.85.98 1.92 1.76 3.24 1.89 1.79.19 2.09-1.33 1.43-1.64z"],"hand-left":["M15.1 6.54c-1.58-.81-4.09-2.46-4.94-4.23-.31-.65-1.82-.35-1.64 1.43.13 1.33.91 2.4 1.89 3.24L9.74 7H1.5C.67 7 0 7.67 0 8.5v.06c0 .36.13.64.32.85.27.36.7.59 1.18.59h5.44l.78.01c-.54.23-.93.78-.93 1.43 0 .59.32 1.1.79 1.36-.32.28-.52.7-.52 1.17 0 .69.44 1.28 1.05 1.47-.22.27-.36.62-.36 1 0 .85.66 1.54 1.48 1.54h.99c4.31 0 5.59-.31 7.14-1.05 1.89-.9 2.65-2.44 2.65-4.82-.01-4.32-2.44-4.52-4.91-5.57z"],"hand-right":["M20 8.5c0-.83-.67-1.5-1.5-1.5h-8.24l-.67-.01c.98-.85 1.76-1.92 1.89-3.24.18-1.79-1.33-2.08-1.65-1.43-.84 1.76-3.35 3.41-4.93 4.23C2.43 7.59 0 7.79 0 12.13c0 2.38.76 3.92 2.65 4.82C4.2 17.69 5.48 18 9.79 18h.99c.82 0 1.48-.69 1.48-1.54 0-.38-.14-.73-.36-1 .6-.19 1.05-.78 1.05-1.47 0-.47-.2-.89-.52-1.17.47-.26.79-.77.79-1.36 0-.65-.39-1.2-.93-1.43l.77-.03h5.44c.48 0 .91-.23 1.18-.59.19-.21.32-.49.32-.85v-.03-.03z"],"hand-up":["M16.46 7.74c-.38 0-.73.14-1 .36-.19-.6-.78-1.05-1.47-1.05-.47 0-.89.2-1.17.52-.26-.47-.77-.79-1.36-.79-.65 0-1.2.39-1.43.93L10 6.94V1.5c0-.48-.23-.91-.59-1.18C9.2.13 8.92 0 8.56 0H8.5C7.67 0 7 .67 7 1.5v8.24l-.01.67c-.84-.98-1.92-1.76-3.24-1.89-1.79-.18-2.08 1.33-1.43 1.65 1.77.84 3.41 3.35 4.23 4.94 1.05 2.47 1.25 4.9 5.58 4.9 2.38 0 3.92-.76 4.82-2.65.74-1.56 1.05-2.84 1.05-7.15v-.99c0-.81-.69-1.48-1.54-1.48z"],hat:["M18.5 13c1.118 0 1.466.534 1.498 1.366L20 14.5v.5c0 1.945-5.69 3-10 3S0 16.945 0 15v-.5c0-.908.323-1.5 1.5-1.5.895 0 3.5 1.2 8.5 1.2l.411-.003C15.143 14.134 17.631 13 18.5 13zm-5-10c1.725 0 2.954 2.729 3.688 8.186-1.455.263-3.805.72-6.392.801l-.434.01L10 12c-2.896 0-5.585-.524-7.189-.814C3.546 5.73 4.775 3 6.5 3 8.6 3 8.329 5.5 10 5.5S11.5 3 13.5 3z"],header:["M16 1c-.55 0-1 .45-1 1v7H5V2c0-.55-.45-1-1-1s-1 .45-1 1v16c0 .55.45 1 1 1s1-.45 1-1v-7h10v7c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"header-one":["M10 0c.55 0 1 .45 1 1v14c0 .55-.45 1-1 1s-1-.45-1-1V9H2v6c0 .55-.45 1-1 1s-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v6h7V1c0-.55.45-1 1-1zm7.4 10.77c.17-.2.29-.46.34-.77H19v10h-1.5v-7.11H15v-1.24c.32 0 .63-.03.93-.08.31-.06.58-.16.83-.29.26-.12.47-.3.64-.51z"],"header-three":["M10.989 1c0-.55-.45-1-.999-1-.55 0-.999.45-.999 1v6H1.998V1c0-.55-.45-1-.999-1C.449 0 0 .45 0 1v14c0 .55.45 1 .999 1 .55 0 .999-.45.999-1V9h6.993v6c0 .55.45 1 .999 1 .55 0 .999-.45.999-1V1zm7.461 13.645c.49.11.87.38 1.14.82.27.44.41.97.41 1.61a3 3 0 01-.24 1.23c-.16.36-.38.67-.66.92-.27.25-.59.44-.96.58-.37.14-.75.21-1.16.21-.5 0-.93-.08-1.3-.24a2.55 2.55 0 01-.93-.68c-.25-.29-.44-.65-.57-1.06-.13-.42-.2-.88-.21-1.38h1.39c-.02.58.11 1.07.38 1.46.28.39.68.58 1.23.58.47 0 .86-.15 1.17-.45.31-.3.47-.72.47-1.27 0-.37-.07-.67-.2-.89-.13-.22-.3-.39-.51-.5-.21-.11-.45-.18-.71-.21-.26-.03-.53-.04-.81-.03v-1.17c.22.01.45 0 .68-.05.23-.05.43-.13.61-.24.18-.11.32-.27.43-.47.11-.2.16-.45.16-.74 0-.41-.12-.74-.37-.99s-.57-.37-.96-.37c-.24 0-.45.06-.63.17-.18.11-.33.26-.45.45s-.2.4-.26.63c-.05.23-.08.47-.07.72h-1.39c.01-.47.09-.9.23-1.3s.33-.75.57-1.04c.24-.3.53-.53.87-.69.34-.17.73-.25 1.16-.25.33 0 .66.05.98.16.32.11.61.27.87.48.26.21.47.47.62.8.15.32.23.7.23 1.12 0 .48-.09.91-.29 1.27-.2.36-.5.63-.92.79v.02z"],"header-two":["M16.6 17.41c-.22.17-.4.36-.56.55-.16.19-.27.4-.33.61h4.28V20H14c.01-.81.18-1.52.53-2.13.35-.6.81-1.13 1.41-1.58.28-.23.58-.46.89-.68.31-.22.59-.46.85-.71.26-.26.48-.53.63-.83.16-.3.25-.64.26-1.02 0-.18-.02-.37-.06-.57-.04-.2-.11-.39-.22-.56s-.26-.31-.45-.43-.44-.18-.75-.18c-.28 0-.52.06-.71.19s-.34.3-.45.52c-.11.22-.2.48-.25.78-.05.3-.08.62-.09.97h-1.43c0-.54.07-1.04.2-1.5.13-.47.32-.87.58-1.2.26-.34.58-.6.95-.78.37-.19.81-.29 1.3-.29.54 0 .99.09 1.35.29.36.19.65.44.87.74.22.29.38.62.47.97.09.35.14.68.14 1 0 .4-.05.75-.16 1.07-.11.32-.26.61-.44.88-.19.27-.4.52-.63.74-.24.22-.48.43-.73.63s-.5.38-.75.56c-.26.17-.5.35-.71.53zM10 0c.55 0 1 .45 1 1v14c0 .55-.45 1-1 1s-1-.45-1-1V9H2v6c0 .55-.45 1-1 1s-1-.45-1-1V1c0-.55.45-1 1-1s1 .45 1 1v6h7V1c0-.55.45-1 1-1z"],headset:["M18.97 9H19A9 9 0 001 9h.03C.41 9.73 0 10.8 0 12c0 1.74.84 3.2 2 3.76V16c0 1.66 1.34 3 3 3h3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1H5c-.55 0-1-.45-1-1 .55 0 1-.45 1-1V9c0-.55-.45-1-1-1h-.92C3.57 4.61 6.47 2 10 2s6.43 2.61 6.92 6H16c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h1c1.66 0 3-1.79 3-4 0-1.2-.41-2.27-1.03-3z"],heart:["M20 6.25C20 3.35 17.65 1 14.75 1c-1.02 0-1.95.31-2.75.82v-.04c-.09.06-.17.12-.26.19-.04.03-.09.06-.14.1-.68.51-1.24 1.18-1.6 1.96-.4-.86-1.04-1.57-1.8-2.1-.04-.02-.07-.05-.1-.08a7 7 0 00-.6-.33c-.13-.04-.23-.1-.35-.15-.05-.02-.1-.05-.15-.07v.02C6.45 1.13 5.87 1 5.25 1A5.25 5.25 0 000 6.25c0 .09.01.17.01.25H0c0 .06.01.12.02.18s.01.12.02.18C.13 7.89.44 9 1.07 10.17 2.23 12.33 4.1 14.11 7 16.53v.01c.9.75 1.89 1.55 3 2.46.71-.58 1.38-1.12 2-1.63 3.48-2.86 5.64-4.78 6.93-7.18.63-1.17.94-2.27 1.03-3.3.01-.07.01-.14.02-.21 0-.06.01-.11.02-.17h-.01c0-.09.01-.17.01-.26z"],"heart-broken":["M8.11 7.45C8.05 7.31 8 7.16 8 7c0-.07.03-.13.04-.19h-.02l.86-4.32A5.159 5.159 0 005.25 1 5.25 5.25 0 000 6.25c0 .09.01.17.01.25H0c0 .06.01.12.02.18s.01.12.02.18C.13 7.89.44 9 1.07 10.17c1.38 2.58 3.76 4.6 7.71 7.83l-.76-3.8h.02c-.01-.07-.04-.13-.04-.2 0-.21.08-.39.18-.54l-.02-.01 1.68-2.52-1.73-3.48zM20 6.25C20 3.35 17.65 1 14.75 1c-1.54 0-2.92.67-3.88 1.73l-.83 4.13 1.85 3.69h-.01c.07.14.12.29.12.45 0 .21-.08.39-.18.54l.02.01-1.77 2.66.81 4.07c4.16-3.39 6.63-5.45 8.05-8.1.63-1.17.94-2.27 1.03-3.3.01-.07.01-.14.02-.21 0-.06.01-.11.02-.17h-.01c0-.08.01-.16.01-.25z"],"heat-grid":["M14 12h6V8h-6v4zM0 12h6V8H0v4zm1-3h4v2H1V9zm-1 7c0 .55.45 1 1 1h5v-4H0v3zM19 3h-5v4h6V4c0-.55-.45-1-1-1zm0 3h-4V4h4v2zM0 4v3h6V3H1c-.55 0-1 .45-1 1zm7 3h6V3H7v4zm7 10h5c.55 0 1-.45 1-1v-3h-6v4zm-7 0h6v-4H7v4zm1-3h4v2H8v-2zm-1-2h6V8H7v4z"],heatmap:["M6 0a6 6 0 100 12A6 6 0 106 0z","M10.5 8a4.5 4.5 0 100 9 4.5 4.5 0 100-9z","M16.5 7a3.5 3.5 0 100 7 3.5 3.5 0 100-7zM18 16a2 2 0 100 4 2 2 0 100-4zM2.5 14a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM16.5 0a2.5 2.5 0 100 5 2.5 2.5 0 100-5z"],helicopter:["M10 3v2H1V3.5a.5.5 0 00-1 0v5a.5.5 0 001 0V7l5 2c0 1.54.824 3.575 3 4.835V16H5.5a.5.5 0 100 1H16.5a.5.5 0 00.224-.053l2-1a.5.5 0 10-.448-.894L16.382 16H15v-1.1A5.002 5.002 0 0014 5h-1V3h6.5a.5.5 0 000-1h-16a.5.5 0 000 1H10zm4 13v-1c-1.608 0-2.928-.258-4-.683V16h4zm0-6V6a4 4 0 014 4h-4z"],help:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM7.41 4.62c.65-.54 1.51-.82 2.56-.82.54 0 1.03.08 1.48.25.44.17.83.39 1.14.68.32.29.56.63.74 1.02.17.39.26.82.26 1.27s-.08.87-.24 1.23c-.16.37-.4.73-.71 1.11l-1.21 1.58c-.14.17-.28.33-.32.48-.05.15-.11.35-.11.6v.97H9v-2s.06-.58.24-.81l1.21-1.64c.25-.3.41-.56.51-.77s.14-.44.14-.67c0-.35-.11-.63-.32-.85s-.5-.33-.88-.33c-.37 0-.67.11-.89.33-.22.23-.37.54-.46.94-.03.12-.11.17-.23.16l-1.95-.29c-.12-.01-.16-.08-.14-.22.13-.93.52-1.67 1.18-2.22zM9 14h2.02L11 16H9v-2z"],"helper-management":["M17 10h-3v3h3v-3zm0 4h-3v3h3v-3zm0-8h-3v3h3V6zm2-6H1C.4 0 0 .4 0 1v18c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V1c0-.6-.5-1-1-1zm-1 18H2V2h16v16zm-9-4H6v3h3v-3zm4 0h-3v3h3v-3z"],"high-priority":["M12 16v4H8v-4h4zm1-16l-1 14H8L7 0h6z"],highlight:["M11.22 14.09l3.03-3.03.71.71L20 6.73l-5.71-5.71-5.04 5.04.71.71-3.02 3.04 4.28 4.28zm6.8 3.91h-16c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1zm-15-1h4.04c.28 0 .53-.11.71-.3l2.02-2.02-3.44-3.45-4.04 4.04c-.18.18-.3.44-.3.71.01.57.46 1.02 1.01 1.02z"],history:["M10 0C6.71 0 3.82 1.6 2 4.05V2c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.76C5.23 3.17 7.47 2 10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8c0-.55-.45-1-1-1s-1 .45-1 1c0 5.52 4.48 10 10 10s10-4.48 10-10S15.52 0 10 0zm0 3c-.55 0-1 .45-1 1v6c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L11 9.59V4c0-.55-.45-1-1-1z"],home:["M2 12v7c0 .55.45 1 1 1h5v-7h4v7h5c.55 0 1-.45 1-1v-7l-8-8-8 8zm17.71-2.71L17 6.59V3c0-.55-.45-1-1-1s-1 .45-1 1v1.59L10.71.3C10.53.11 10.28 0 10 0s-.53.11-.71.29l-9 9a1.003 1.003 0 001.42 1.42L10 2.41l8.29 8.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"horizontal-bar-chart":["M1 1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1zm3 5h11c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1zm8 8H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h8c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm7-6H4c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h15c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1z"],"horizontal-bar-chart-asc":["M1 9h11c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0-5h9c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm18 12H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM1 14h14c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1z"],"horizontal-bar-chart-desc":["M10 16H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm2-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h11c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm3-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm4-5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1z"],"horizontal-distribution":["M12 2H8c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM1 0C.45 0 0 .45 0 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm18 0c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],hurricane:["M0 14c1.648.775 3 1 4 1-1-1-2-3.112-2-5a5.098 5.098 0 000-.045C2 5.17 6.201 1 11.172 1c3.206 0 6.9.667 8.828 5-1.648-.775-3-1-4-1 1 1 2 3.112 2 5v.045C18 14.83 13.799 19 8.828 19c-3.206 0-6.9-.667-8.828-5zm10-7a3 3 0 100 6 3 3 0 000-6z"],"id-number":["M2 5v10h16V5H2zm0-2h16c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2z","M8.88 12.38c-.17-.39-1.01-.66-1.56-.9-.56-.24-.48-.39-.5-.6v-.09c.19-.17.35-.4.45-.67 0 0 0-.02.01-.02l.06-.18c.13-.03.2-.17.23-.29.03-.05.09-.18.08-.33-.04-.18-.11-.27-.2-.3v-.03c0-.24-.02-.58-.06-.81-.01-.06-.02-.12-.04-.19-.08-.27-.25-.52-.48-.7C6.63 7.09 6.3 7 6 7s-.63.09-.87.27c-.23.17-.4.42-.48.7-.02.06-.03.13-.04.19-.04.22-.06.57-.06.81V9c-.09.03-.17.12-.19.31-.01.14.05.27.08.32.03.14.1.27.23.3.02.06.03.12.06.18v.01c.11.27.27.51.47.68v.08c-.02.2.04.35-.51.6-.56.24-1.39.51-1.56.9-.19.39-.12.62-.12.62h5.98c-.01 0 .06-.23-.11-.62zM12 7h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1zM12 11h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1z"],"image-rotate-left":["M10.5 13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM14 7H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 10l-5-3-1 2-2-4-3 4.5V9h11v8zm3-15h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H16c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4z"],"image-rotate-right":["M5.29 4.29a1.003 1.003 0 001.42 1.42l2-2C8.89 3.53 9 3.28 9 3c0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l.3.29H4C1.79 2 0 3.79 0 6v3c0 .55.45 1 1 1s1-.45 1-1V6c0-1.1.9-2 2-2h1.59l-.3.29zM15.5 13c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5.67 1.5 1.5 1.5zM19 7H6c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 10l-5-3-1 2-2-4-3 4.5V9h11v8z"],import:["M9.29 15.71c.18.18.43.29.71.29s.53-.11.71-.29l5-5a1.003 1.003 0 00-1.42-1.42L11 12.59V1c0-.55-.45-1-1-1S9 .45 9 1v11.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42l5 5zM19 14c-.55 0-1 .45-1 1v3H2v-3c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],inbox:["M16.92 3.56l-.01-.02c-.16-.35-.5-.6-.91-.6H4c-.41 0-.76.25-.91.6l-.01.02L0 10.49v6.46c0 .55.45 1 1 1h18c.55 0 1-.45 1-1v-6.46l-3.08-6.93zM15 10.95c-.55 0-1 .45-1 1v1H6v-1c0-.55-.45-1-1-1H1.98l2.67-6h10.7l2.67 6H15z"],"inbox-filtered":["M10.262 3l1.958 1.958v.05H4.65l-2.67 5.997H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h3.02l-.635-1.426.625-.63c.354-.353.598-.8.707-1.289L20 10.545v6.456c0 .55-.45.999-1 .999H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h6.262zm9.088-3a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V4.13L11.19 1.1a.642.642 0 01.45-1.1h7.71z"],"inbox-geo":["M7.427 3a7.467 7.467 0 00-.411 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8V13c.165.01.332 0 .5 0a7.48 7.48 0 005.5-2.4V17c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h3.427zm5.715-.596a.133.133 0 01-.193 0l-.374-.374a.133.133 0 010-.193.133.133 0 01.193 0l.373.374a.133.133 0 010 .193zm1.743.033c-.05 0-.088-.006-.088-.055 0-.05.038-.056.088-.056h.165c.05 0 .088.006.088.055 0 .05-.038.056-.088.056h-.165zm.539.632c-.05 0-.104-.044-.104-.094v-.23c0-.05.054-.094.104-.094.05 0 .104.044.104.094v.23c0 .05-.055.094-.104.094zm-3.575 2.304h.506l1.182 1.2c.006.005 0 .005 0 .01v.446c0 .187-.126.341-.319.341h-.098v.226c0 .192-.138.296-.33.296h.01v.792c0 .188-.181.336-.368.336s-.369-.149-.369-.335v-1.32h-.214c-.193 0-.308-.149-.308-.341V5.72c0-.192.115-.346.308-.346zM14.5 0C17.536 0 20 2.464 20 5.5S17.536 11 14.5 11A5.502 5.502 0 019 5.5C9 2.464 11.464 0 14.5 0zm0 9.9c2.431 0 4.4-1.969 4.4-4.4 0-.297-.027-.583-.099-.864h-.236c-.188 0-.336-.104-.347-.313h-.319c.11.104.231.209.231.346v.705c0 .088-.055.17-.11.23h-.022l-.011.006-.022.011-.666.643v1.21c0 .193-.104.33-.296.33h-.54c-.192 0-.319-.137-.319-.33V6.221a.915.915 0 00-.533-.518h-.671c-.192 0-.368-.143-.368-.335V4.68c0-.192.176-.346.368-.346l.193-.005.319-.32a.342.342 0 01.489 0l.319.32c.005 0 .005.005.005.005h.704c.16 0 .237-.16.341-.313v-.11l-.038.005h-.27a.159.159 0 01-.153-.16c0-.087.066-.159.154-.159h.269l.039.006V3.42s-.05-.038-.061-.038h-.302l-.067.076a.342.342 0 01-.489.011l-.066-.088h-.176l.248.259c.021.022.021.088 0 .11-.028.022-.067.028-.088.006l-.292-.276h-.127l-.363.325-.033-.006c-.038.11-.087.089-.143.089-.126 0-.225-.072-.225-.193 0-.127.099-.209.225-.209h.176v-.182c0-.088.061-.131.149-.131h.066v-.127c0-.143.149-.297.286-.297h.28c.16 0 .27-.115.27-.275V2.42c0-.016.055.017.055-.088h-.187l-.005.017-.308.33a.123.123 0 01-.177 0c-.049-.044-.049-.121 0-.171l.391-.385c.027-.022.06-.022.094-.022l.005.022h.869A4.376 4.376 0 0014.5 1.1a4.402 4.402 0 00-2.816 1.018h.583c.094 0 .165.066.165.159s-.072.16-.165.16h-.478c0 .104-.039.06-.039.066v.351h.429l.226-.252c.132-.127.346-.155.473-.022a.332.332 0 010 .473l-1.183 1.182-.011.011c-.005.005-.011.005-.016.011a.115.115 0 00-.034.022c-.005.006-.01 0-.016.006a.309.309 0 01-.176.038h-.347c-.12.104-.187.148-.187.27v.088c0 .016-.027.027-.027.043l.561.589c.06.06.055.154 0 .209a.143.143 0 01-.209 0l-.578-.578a.425.425 0 01-.082.011c-.154 0-.292-.12-.292-.274v-.358h-.016c-.104.374-.165.77-.165 1.177 0 2.431 1.969 4.4 4.4 4.4zm3.388-3.107c.077 0 .16.06.16.137v.424c0 .077-.083.137-.16.137s-.16-.06-.16-.137V6.93c0-.077.083-.137.16-.137zm-3.113-4.879c0 .187-.154.314-.335.314h-.374v.104c0 .11-.05.198-.16.198s-.16-.088-.16-.198V1.98c-.104-.022-.033-.028-.033-.055 0-.187.127-.325.314-.325h.407c.187 0 .341.127.341.314z"],"inbox-search":["M7.136 3a6.327 6.327 0 00-.098 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h1.076l1.14 1.14a2.767 2.767 0 001.974.806c.282 0 .554-.042.81-.12V17c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h3.136zm3.244 1.33c0 1.62 1.31 2.93 2.93 2.93s2.93-1.31 2.93-2.93-1.31-2.93-2.93-2.93-2.93 1.31-2.93 2.93zm6.47 2.43l2.89 2.85c.13.15.22.35.23.56 0 .43-.35.78-.78.78-.23 0-.42-.08-.56-.22l-2.87-2.87c-.17.1-.33.2-.51.29-.03.01-.06.03-.09.04-.18.07-.35.15-.55.21-.19.06-.37.11-.57.14-.05.01-.1.02-.14.02-.2.03-.39.05-.6.05A4.3 4.3 0 019 4.31C9 1.93 10.93.01 13.3 0c2.37 0 4.3 1.93 4.3 4.3 0 .21-.02.4-.05.6-.01.05-.01.09-.02.14-.04.2-.08.38-.14.58-.05.19-.13.36-.21.54-.01.03-.03.06-.04.09-.08.18-.18.34-.29.51z"],"inbox-update":["M10.083 3a6.04 6.04 0 00.001 2.009H4.65l-2.67 5.996H5c.55 0 1 .45 1 .999v1h8v-1c0-.55.45-1 1-1h3.02l-.53-1.19a5.97 5.97 0 001.824-.811L20 10.545v6.456c0 .55-.45.999-1 .999H1c-.55 0-1-.45-1-1v-6.455L3.08 3.62l.01-.02c.15-.35.5-.6.91-.6h6.083zM16 8a4 4 0 110-8 4 4 0 010 8z"],"info-sign":["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM9 4h2v2H9V4zm4 12H7v-1h2V8H8V7h3v8h2v1z"],inheritance:["M6 10c0 2.21 1.79 4 4 4h6.59l-2.29-2.29A.965.965 0 0114 11a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H10c-3.31 0-6-2.69-6-6H1a1 1 0 01-1-1V1a1 1 0 011-1h8a1 1 0 011 1v8a1 1 0 01-1 1H6zM2 2v6h6V2H2z"],"inherited-group":["M1 9c.55 0 1 .45 1 1v4c0 1.1.9 2 2 2h2.59l-.3-.29a1.003 1.003 0 011.42-1.42l2 2c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2 2A1.003 1.003 0 016 19c0-.28.11-.53.3-.71l.29-.29H4c-2.21 0-4-1.79-4-4v-4c0-.55.45-1 1-1zm6.996-9c.79 0 1.68.25 2.309.73a3.63 3.63 0 011.4 2.36c.11.6.17 1.52.17 2.15v.09c.22.09.42.32.47.82.03.39-.12.73-.2.87-.07.34-.27.71-.61.78-.04.16-.09.33-.15.48-.01.01-.02.05-.02.05-.27.71-.68 1.33-1.19 1.78 0 .08 0 .16.01.23.05.55-.15.95 1.33 1.6 1.469.66 3.698 1.35 4.178 2.39.45 1.05.27 1.67.27 1.67h-5.227a1.982 1.982 0 00-.319-.417l-2-2A2.003 2.003 0 005 15H4c-.548 0-1-.452-1-1v-1.462c.511-.213 1.023-.413 1.468-.608 1.479-.65 1.329-1.05 1.379-1.59l.01-.21c-.52-.45-.95-1.08-1.22-1.8l-.01-.01-.01-.03c-.07-.15-.12-.32-.16-.49-.34-.06-.54-.43-.62-.78-.08-.14-.24-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.64.05-1.55.17-2.15a3.648 3.648 0 011.4-2.36C6.317.25 7.207 0 7.996 0zm5.997 3c.59 0 1.26.19 1.73.55.46.35.8.85.97 1.4.04.13.07.25.08.38.08.45.13 1.14.13 1.61v.07c.16.07.31.24.35.62.02.29-.09.55-.15.65-.05.26-.2.53-.46.59-.03.12-.07.25-.11.36-.01.01-.01.04-.01.04-.2.53-.51 1-.89 1.34 0 .06 0 .12.01.17.04.41-.11.71 1 1.19 1.099.5 2.768 1.01 3.128 1.79.34.79.2 1.25.2 1.25h-3.039V15c-.06-.33-.17-.69-.33-1.06-.45-.97-1.37-1.52-3.238-2.3-.17-.07-.76-.31-.77-.32-.1-.04-.2-.08-.28-.12.05-.14.04-.29.06-.45l.01-.16c-.25-.21-.47-.48-.65-.79.22-.34.41-.71.56-1.12l.028-.078-.002.013-.006.035.06-.15c.36-.26.6-.67.72-1.13.18-.37.29-.82.25-1.3-.05-.5-.21-.92-.47-1.22-.02-.53-.06-1.11-.12-1.59.38-.17.83-.26 1.24-.26z"],"inner-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zm-3.34 9.25c-.55-1.2-.86-2.54-.86-3.95s.31-2.75.86-3.95a4.001 4.001 0 000 7.9zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm.6 2.05c.55 1.2.86 2.54.86 3.95s-.31 2.75-.86 3.95c1.9-.31 3.36-1.96 3.36-3.95S16.5 6.36 14.6 6.05zM10 5.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],insert:["M19 0H1C.4 0 0 .4 0 1v18c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V1c0-.6-.5-1-1-1zm-1 18H2V2h16v16zM5 11h4v4c0 .6.4 1 1 1s1-.4 1-1v-4h4c.6 0 1-.4 1-1s-.4-1-1-1h-4V5c0-.6-.4-1-1-1s-1 .4-1 1v4H5c-.6 0-1 .4-1 1s.4 1 1 1z"],intersection:["M13 4c-1.31 0-2.51.43-3.5 1.14A5.977 5.977 0 006 4c-3.31 0-6 2.69-6 6s2.69 6 6 6c1.31 0 2.51-.43 3.5-1.14.99.71 2.19 1.14 3.5 1.14 3.31 0 6-2.69 6-6s-2.69-6-6-6zm-4.93 9.41c-.61.37-1.31.59-2.07.59-2.21 0-4-1.79-4-4s1.79-4 4-4c.76 0 1.46.22 2.07.59C7.4 7.56 7 8.73 7 10s.4 2.44 1.07 3.41zM13 14c-.76 0-1.46-.22-2.07-.59C11.6 12.44 12 11.27 12 10s-.4-2.44-1.07-3.41C11.54 6.22 12.24 6 13 6c2.21 0 4 1.79 4 4s-1.79 4-4 4z"],"ip-address":["M6 3.66C6 5.69 10 11 10 11s4-5.31 4-7.34C13.99 1.64 12.21 0 10 0S6 1.64 6 3.66zM8 4c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2zM14 13.5V13h-4v1h3v2h-2v1h3v-3.5zM3 12h14c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1H3c-.55 0-1-.45-1-1v-6c0-.55.45-1 1-1zm4 1v6h1v-6H7zm3 1v5h1v-5h-1z"],issue:["M10 20C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 100-16 8 8 0 000 16zm1-2H9v-2h2v2zm0-3H9V4h2v9z"],"issue-closed":["M15.364 5.9a.997.997 0 01-.707-.293l-2.121-2.122a1 1 0 111.414-1.414l1.414 1.414L18.192.657a1 1 0 011.414 1.414l-3.535 3.536a.997.997 0 01-.707.292zM11.78.157a3.002 3.002 0 00-1.437 1.85 8 8 0 107.1 5.055l.042-.042 1.472-1.472A9.959 9.959 0 0120 10c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0c.608 0 1.202.054 1.78.158zM11 16H9v-2h2v2zm0-3H9V4h2v9z"],"issue-new":["M13.167.512a2.98 2.98 0 00-.131.524c-.74.115-1.39.5-1.848 1.052a8 8 0 106.724 6.724 2.997 2.997 0 001.052-1.848 2.98 2.98 0 00.524-.13A9.99 9.99 0 0120 10c0 5.523-4.477 10-10 10S0 15.523 0 10 4.477 0 10 0a9.99 9.99 0 013.167.512zM11 16H9v-2h2v2zm0-3H9V4h2v9zm6-10h1.5a1 1 0 010 2H17v1.5a1 1 0 01-2 0V5h-1.5a1 1 0 010-2H15V1.5a1 1 0 012 0V3z"],italic:["M11.7 4H14c.6 0 1-.4 1-1s-.4-1-1-1H7c-.6 0-1 .4-1 1s.4 1 1 1h2.2L7.3 15H5c-.6 0-1 .4-1 1s.4 1 1 1h7c.6 0 1-.4 1-1s-.4-1-1-1H9.8l1.9-11z"],"join-table":["M19 6h-4V2c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h4v4c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zM6 12H2V9h4v3zm0-4H2V5h4v3zm7 9H7v-3h6v3zm0-4H7V9h6v4zm0-5H7V5h6v3zm5 9h-4v-3h4v3zm0-4h-4v-3h4v3z"],key:["M14 0c-3.31 0-6 2.69-6 6 0 1.11.32 2.14.85 3.03L.44 17.44a1.498 1.498 0 102.12 2.12l.79-.79.94.94c.18.18.43.29.71.29s.53-.11.71-.29l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-.94-.94 3.2-3.2A5.9 5.9 0 0014 12c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 9c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],"key-backspace":["M19 3H7c-.28 0-.53.11-.71.29l-6 6C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l6 6c.18.18.43.29.71.29h12c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-2.29 9.29a1.003 1.003 0 01-1.42 1.42L13 11.41l-2.29 2.29c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71l2.3-2.29-2.3-2.29a1.003 1.003 0 011.42-1.42L13 8.59l2.29-2.29c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L14.41 10l2.3 2.29z"],"key-command":["M15.5 12H14V8h1.5C17.43 8 19 6.43 19 4.5S17.43 1 15.5 1 12 2.57 12 4.5V6H8V4.5C8 2.57 6.43 1 4.5 1S1 2.57 1 4.5 2.57 8 4.5 8H6v4H4.5C2.57 12 1 13.57 1 15.5S2.57 19 4.5 19 8 17.43 8 15.5V14h4v1.5c0 1.93 1.57 3.5 3.5 3.5s3.5-1.57 3.5-3.5-1.57-3.5-3.5-3.5zm0-9c.83 0 1.5.67 1.5 1.5S16.33 6 15.5 6 14 5.33 14 4.5 14.67 3 15.5 3zm-11 14c-.83 0-1.5-.67-1.5-1.5S3.67 14 4.5 14s1.5.67 1.5 1.5S5.33 17 4.5 17zm0-11C3.67 6 3 5.33 3 4.5S3.67 3 4.5 3 6 3.67 6 4.5 5.33 6 4.5 6zm7.5 6H8V8h4v4zm3.5 5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"],"key-control":["M16.71 7.29l-6-6C10.53 1.11 10.28 1 10 1s-.53.11-.71.29l-6 6a1.003 1.003 0 001.42 1.42L10 3.41l5.29 5.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71z"],"key-delete":["M19.71 9.29l-6-6A.997.997 0 0013 3H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.28 0 .53-.11.71-.29l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zm-9 3a1.003 1.003 0 01-1.42 1.42L7 11.41 4.71 13.7c-.18.19-.43.3-.71.3a1.003 1.003 0 01-.71-1.71L5.59 10l-2.3-2.29a1.003 1.003 0 011.42-1.42L7 8.59 9.29 6.3c.18-.19.43-.3.71-.3a1.003 1.003 0 01.71 1.71L8.41 10l2.3 2.29z"],"key-enter":["M18 2c-.55 0-1 .45-1 1v5c0 2.21-1.79 4-4 4H4.41L6.7 9.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.41 14H13c3.31 0 6-2.69 6-6V3c0-.55-.45-1-1-1z"],"key-escape":["M2 8c.55 0 1-.45 1-1V4.41l6.29 6.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 3H7c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1v5c0 .55.45 1 1 1zm9-6.94V3.1c3.39.49 6 3.38 6 6.9 0 3.87-3.13 7-7 7-3.52 0-6.41-2.61-6.9-6H1.06c.5 4.5 4.31 8 8.94 8a9 9 0 009-9c0-4.63-3.5-8.44-8-8.94z"],"key-option":["M13 4h6c.55 0 1-.45 1-1s-.45-1-1-1h-6c-.55 0-1 .45-1 1s.45 1 1 1zm6 12h-4.42L6.87 2.5l-.02.01A.977.977 0 006 2H1c-.55 0-1 .45-1 1s.45 1 1 1h4.42l7.71 13.5.01-.01c.18.3.49.51.86.51h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"key-shift":["M17.74 10.35l-6.99-8.01-.01.01C10.56 2.14 10.3 2 10 2s-.56.14-.74.35l-.01-.01-7 8 .01.01A.95.95 0 002 11c0 .55.45 1 1 1h3v5c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-5h3c.55 0 1-.45 1-1 0-.25-.1-.48-.26-.65z"],"key-tab":["M19 13H4.41l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L2 12.59V10c0-.55-.45-1-1-1s-1 .45-1 1v8c0 .55.45 1 1 1s1-.45 1-1v-2.59l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L4.41 15H19c.55 0 1-.45 1-1s-.45-1-1-1zm0-12c-.55 0-1 .45-1 1v2.59L14.71 1.3A.965.965 0 0014 1a1.003 1.003 0 00-.71 1.71L15.59 5H1c-.55 0-1 .45-1 1s.45 1 1 1h14.59L13.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 7.41V10c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1z"],"known-vehicle":["M19 4a.997.997 0 00-.707.293L14 8.586l-2.293-2.293a1 1 0 00-1.414 1.414l3 3a.997.997 0 001.414 0l5-5A1 1 0 0019 4zm-2.048 7.291c.011.072.048.134.048.209a1.5 1.5 0 01-1.5 1.5c-.225 0-.433-.057-.624-.145-.279.085-.57.145-.876.145a2.99 2.99 0 01-2.121-.879l-3-3 .007-.007A3.027 3.027 0 018.184 8H4V7l1-3h10l.19.568 1.307-1.308c-.336-.356-.758-.658-1.165-.772 0 0-1.74-.488-5.332-.488s-5.332.488-5.332.488c-.67.188-1.424.864-1.674 1.502L2.99 4H3L2 7H1a1 1 0 000 2h.333l-.28.84L1 10v7.5a1.5 1.5 0 103 0V17h12v.5a1.5 1.5 0 003 0V10l-.19-.568-1.858 1.86zM4.5 13a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"],"lab-test":["M13 2a1 1 0 010 2v4l4 8v1a1 1 0 01-1 1H4a1 1 0 01-1-1v-1l4-8V4a1 1 0 110-2h6zm-2 2H9v4l-2 4h6l-2-4V4z"],label:["M3 12h14v-1H3v1zm11-9H1c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V9l-6-6zm4 12H2V5h11v3H3v1h10v1h5v5zm-4-6V5l4 4h-4z"],layer:["M19.5 9.1l-9-5c-.2-.1-.3-.1-.5-.1s-.3 0-.5.1l-9 5c-.3.2-.5.5-.5.9s.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9s-.2-.7-.5-.9z"],"layer-outline":["M9.514 4.126l-9 5a1 1 0 000 1.748l9 5a1 1 0 00.972 0l9-5a1 1 0 000-1.748l-9-5a1 1 0 00-.972 0zM10 6.144l6.94 3.855L10 13.855 3.059 9.999 10 6.144z"],layers:["M.5 6.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9s-.2-.7-.5-.9l-9-5c-.2-.1-.3-.1-.5-.1s-.3 0-.5.1l-9 5c-.3.2-.5.5-.5.9s.2.7.5.9z","M19 9c-.2 0-.3 0-.5.1L10 13.9 1.5 9.1C1.3 9 1.2 9 1 9c-.6 0-1 .4-1 1 0 .4.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9 0-.6-.4-1-1-1z","M19 13c-.2 0-.3 0-.5.1L10 17.9l-8.5-4.7c-.2-.2-.3-.2-.5-.2-.6 0-1 .4-1 1 0 .4.2.7.5.9l9 5c.2.1.3.1.5.1s.3 0 .5-.1l9-5c.3-.2.5-.5.5-.9 0-.6-.4-1-1-1z"],layout:["M18 6c-1.1 0-2 .9-2 2 0 .37.11.71.28 1.01l-2.27 2.27c-.3-.17-.64-.28-1.01-.28-.93 0-1.71.64-1.93 1.5H8.93c-.22-.86-1-1.5-1.93-1.5-.37 0-.71.11-1.01.28L3.72 9.01C3.89 8.71 4 8.37 4 8c0-.34-.09-.66-.24-.94l3.66-3.38c.31.2.68.32 1.08.32 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .34.09.66.24.94L3.08 6.32C2.77 6.12 2.4 6 2 6 .9 6 0 6.9 0 8s.9 2 2 2c.37 0 .71-.11 1.01-.28l2.27 2.27c-.17.3-.28.64-.28 1.01s.11.71.28 1.01l-2.27 2.27C2.71 16.11 2.37 16 2 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28.93 0 1.71-.64 1.93-1.5h2.14c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2 0-.37-.11-.71-.28-1.01l2.27-2.27c.3.17.64.28 1.01.28 1.1 0 2-.9 2-2s-.9-2-2-2z"],"layout-auto":["M18 13c-.53 0-1.01.21-1.37.55L11.9 10.6c.06-.19.1-.39.1-.6s-.04-.41-.1-.6l4.72-2.95c.37.34.85.55 1.38.55 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .21.04.41.1.6l-4.73 2.96c-.24-.23-.54-.4-.87-.48V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.33.09-.63.26-.87.48L3.9 5.6c.06-.19.1-.39.1-.6 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.53 0 1.01-.21 1.37-.55L8.1 9.4c-.06.19-.1.39-.1.6s.04.41.1.6l-4.72 2.95C3.01 13.21 2.53 13 2 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.21-.04-.41-.1-.6l4.73-2.96c.24.23.54.4.87.48v4.14C8.64 16.29 8 17.07 8 18c0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.33-.09.63-.26.87-.48l4.73 2.96c-.06.18-.1.38-.1.59 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-balloon":["M18 16c-.14 0-.28.02-.42.05l-1.73-3.45c.69-.45 1.14-1.22 1.14-2.1s-.46-1.65-1.14-2.1l1.73-3.45c.14.03.28.05.42.05 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .6.27 1.13.69 1.5l-1.77 3.54c-.14-.02-.28-.04-.42-.04a2.5 2.5 0 00-2.45 2h-4.1A2.5 2.5 0 005.5 8c-.14 0-.28.02-.42.04L3.31 4.5C3.73 4.13 4 3.6 4 3c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.14 0 .28-.02.42-.05L4.14 8.4C3.46 8.85 3 9.62 3 10.5s.46 1.65 1.14 2.1l-1.73 3.45A1.84 1.84 0 002 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2c0-.6-.27-1.13-.69-1.5l1.77-3.54c.14.02.28.04.42.04a2.5 2.5 0 002.45-2h4.1a2.5 2.5 0 002.45 2c.14 0 .28-.02.42-.04l1.77 3.54c-.42.37-.69.9-.69 1.5 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2z"],"layout-circle":["M18.3 8c-.2-.9-.6-1.7-1.1-2.5.2-.3.3-.7.3-1 0-1.1-.9-2-2-2-.4 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2 0 100 4 2 2 0 100-4zM2 16a2 2 0 100 4 2 2 0 100-4zM2 8a2 2 0 100 4 2 2 0 100-4zM10 8a2 2 0 100 4 2 2 0 100-4z"],"layout-group-by":["M2 2a2 2 0 100 4 2 2 0 100-4zM18 0a2 2 0 100 4 2 2 0 100-4zM18 8a2 2 0 100 4 2 2 0 100-4zM18 16a2 2 0 100 4 2 2 0 100-4zM2 14a2 2 0 100 4 2 2 0 100-4zM2 8a2 2 0 100 4 2 2 0 100-4zM13 12a2 2 0 100 4 2 2 0 100-4zM13 4a2 2 0 100 4 2 2 0 100-4z"],"layout-hierarchy":["M18.5 16.07v-4.14c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2-.93 0-1.71.64-1.93 1.5h-4.14c-.18-.7-.73-1.25-1.43-1.43V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.7.18-1.25.73-1.43 1.43H3.93C3.71 8.64 2.93 8 2 8c-1.1 0-2 .9-2 2 0 .93.64 1.71 1.5 1.93v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.7-.18 1.25-.73 1.43-1.43h4.14c.18.7.73 1.25 1.43 1.43v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93v-4.14c.7-.18 1.25-.73 1.43-1.43h4.14c.18.7.73 1.25 1.43 1.43v4.14c-.86.22-1.5 1-1.5 1.93 0 1.1.9 2 2 2s2-.9 2-2c0-.93-.64-1.71-1.5-1.93z"],"layout-linear":["M16.5 7a2.5 2.5 0 00-2.45 2h-2.1a2.5 2.5 0 00-4.9 0h-2.1a2.5 2.5 0 100 1h2.1a2.5 2.5 0 004.9 0h2.1a2.5 2.5 0 102.45-3z"],"layout-skew-grid":["M2 0a2 2 0 100 4 2 2 0 100-4zM18 0a2 2 0 100 4 2 2 0 100-4zM18 8a2 2 0 100 4 2 2 0 100-4zM18 16a2 2 0 100 4 2 2 0 100-4zM2 16a2 2 0 100 4 2 2 0 100-4zM2 8a2 2 0 100 4 2 2 0 100-4zM10 12a2 2 0 100 4 2 2 0 100-4zM10 4a2 2 0 100 4 2 2 0 100-4z"],"layout-sorted-clusters":["M2 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm16 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-8 4c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],learning:["M10.551 1.127a1.256 1.256 0 00-1.102 0L.456 5.89c-.608.309-.608.913 0 1.222l8.993 4.762c.334.17.767.17 1.102 0l8.992-4.762c.61-.309.61-.913 0-1.222l-8.992-4.762z","M18 6.5l.016 4.514c.002.548.447.99.994.99a.99.99 0 00.99-.99V6.5h-2zM3.366 10.033l6.401 3.358a.5.5 0 00.465 0l6.406-3.358a.25.25 0 01.366.221v5.109a.25.25 0 01-.139.224l-6.64 3.302a.5.5 0 01-.446 0l-6.64-3.302A.25.25 0 013 15.363v-5.108a.25.25 0 01.366-.222z"],"left-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm.6 2.05c.55 1.2.86 2.54.86 3.95s-.31 2.75-.86 3.95c1.9-.31 3.36-1.96 3.36-3.95S16.5 6.36 14.6 6.05zM10 5.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],"less-than":["M7.162 10l9.154 3.052a1 1 0 01-.632 1.897l-12-4c-.912-.304-.912-1.594 0-1.897l12-4a1 1 0 01.632 1.897L7.162 10z"],"less-than-or-equal-to":["M16.316 11.051L7.162 8l9.154-3.051a1 1 0 10-.632-1.898l-12 4c-.912.304-.912 1.594 0 1.898l12 4a1 1 0 10.632-1.898zM16 15H4a1 1 0 100 2h12a1 1 0 100-2z"],lifesaver:["M8.143 14.644L7.028 17.43c.919.368 1.922.57 2.972.57s2.053-.202 2.972-.57l-1.115-2.786A4.986 4.986 0 0110 15a4.986 4.986 0 01-1.857-.356zm-2.787-2.787A4.986 4.986 0 015 10c0-.656.126-1.283.356-1.857L2.57 7.028A7.978 7.978 0 002 10c0 1.05.202 2.053.57 2.972l2.786-1.115zm2.787-6.5A4.986 4.986 0 0110 5c.656 0 1.283.126 1.857.356l1.115-2.786A7.978 7.978 0 0010 2c-1.05 0-2.053.202-2.972.57l1.115 2.786zm6.5 2.786c.23.574.357 1.2.357 1.857 0 .656-.126 1.283-.356 1.857l2.786 1.115c.368-.919.57-1.922.57-2.972s-.202-2.053-.57-2.972l-2.786 1.115zM10 13a3 3 0 100-6 3 3 0 000 6zm0 7C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10z"],lightbulb:["M6.33 13.39c0 .34.27.61.6.61h6.13c.33 0 .6-.27.6-.61C14.03 9.78 16 9.4 16 6.09 16 2.72 13.31 0 10 0S4 2.72 4 6.09c0 3.31 1.97 3.69 2.33 7.3zM13 15H7c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm-1 3H8c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1z"],lightning:["M9 11H6a1 1 0 01-1-1L5.91.9a1 1 0 01.995-.9h6.256a.839.839 0 01.779 1.15L11.2 8h2.978a.822.822 0 01.748 1.162l-4.764 10.481A.608.608 0 019 19.392V11z"],link:["M10.85 11.98l-4.44 4.44-1 1c-.36.36-.86.58-1.41.58-1.1 0-2-.9-2-2 0-.55.22-1.05.59-1.41l5.44-5.44C7.69 9.06 7.36 9 7 9c-1.11 0-2.09.46-2.82 1.18l-.01-.01-3 3 .01.01C.46 13.91 0 14.89 0 16c0 2.21 1.79 4 4 4 1.11 0 2.09-.46 2.82-1.18l.01.01 3-3-.01-.01C10.54 15.09 11 14.11 11 13c0-.36-.06-.69-.15-1.02zM20 4c0-2.21-1.79-4-4-4-1.11 0-2.09.46-2.82 1.18l-.01-.01-3 3 .01.01C9.46 4.91 9 5.89 9 7c0 .36.06.69.15 1.02l4.44-4.44 1-1c.36-.36.86-.58 1.41-.58 1.1 0 2 .9 2 2 0 .55-.22 1.05-.59 1.41l-5.44 5.44c.34.09.67.15 1.03.15 1.11 0 2.09-.46 2.82-1.18l.01.01 3-3-.01-.01C19.54 6.09 20 5.11 20 4zM5 14a1.003 1.003 0 001.71.71l8-8a1.003 1.003 0 00-1.42-1.42l-2 2-2 2-2 2-2 2c-.18.18-.29.43-.29.71z"],list:["M1.03 1C.46 1 0 1.46 0 2.03v.95C0 3.54.46 4 1.03 4h17.95C19.54 4 20 3.54 20 2.97v-.94C20 1.46 19.54 1 18.97 1H1.03zM0 17.97C0 18.54.46 19 1.03 19h17.95c.56 0 1.03-.46 1.03-1.03v-.95c0-.56-.46-1.03-1.03-1.03H1.03C.46 16 0 16.46 0 17.03v.94zM0 12.97C0 13.54.46 14 1.03 14h17.95c.56 0 1.03-.46 1.03-1.03v-.95c0-.56-.46-1.03-1.03-1.03H1.03C.46 11 0 11.46 0 12.03v.94zM0 7.97C0 8.54.46 9 1.03 9h17.95C19.54 9 20 8.54 20 7.97v-.94C20 6.46 19.54 6 18.97 6H1.03C.46 6 0 6.46 0 7.03v.94z"],"list-columns":["M0 2.973v-.936C0 1.468.46 1.01 1.029 1H7.97C8.541 1 9 1.468 9 2.027v.946C9 3.542 8.53 4 7.971 4H1.03C.459 4 0 3.542 0 2.973zm0 5v-.936C0 6.468.46 6.01 1.029 6H7.97C8.541 6 9 6.468 9 7.027v.946C9 8.542 8.53 9 7.971 9H1.03C.459 9 0 8.542 0 7.973zm0 5v-.936C0 11.468.46 11.01 1.029 11H7.97C8.541 11 9 11.468 9 12.027v.946C9 13.542 8.53 14 7.971 14H1.03C.459 14 0 13.542 0 12.973zm0 5v-.936C0 16.468.46 16.01 1.029 16H7.97C8.541 16 9 16.468 9 17.027v.946C9 18.542 8.53 19 7.971 19H1.03C.459 19 0 18.542 0 17.973zm11-15v-.936c0-.569.46-1.027 1.029-1.037h6.942C19.541 1 20 1.468 20 2.027v.946C20 3.542 19.53 4 18.971 4H12.03C11.459 4 11 3.542 11 2.973zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942C19.541 6 20 6.468 20 7.027v.946C20 8.542 19.53 9 18.971 9H12.03C11.459 9 11 8.542 11 7.973zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942c.57 0 1.029.468 1.029 1.027v.946c0 .569-.47 1.027-1.029 1.027H12.03c-.57 0-1.029-.458-1.029-1.027zm0 5v-.936c0-.569.46-1.027 1.029-1.037h6.942c.57 0 1.029.468 1.029 1.027v.946c0 .569-.47 1.027-1.029 1.027H12.03c-.57 0-1.029-.458-1.029-1.027z"],"list-detail-view":["M8 6H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM8 1H1c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm11 0h-7c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1z"],locate:["M10 8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm9 1h-1.07c-.45-3.61-3.32-6.45-6.93-6.91V1c0-.55-.45-1-1-1S9 .45 9 1v1.09C5.39 2.55 2.52 5.39 2.07 9H1c-.55 0-1 .45-1 1s.45 1 1 1h1.07c.45 3.61 3.32 6.45 6.93 6.91V19c0 .55.45 1 1 1s1-.45 1-1v-1.09c3.61-.46 6.48-3.29 6.93-6.91H19c.55 0 1-.45 1-1s-.45-1-1-1zm-4 2h.9a5.98 5.98 0 01-4.9 4.91V15c0-.55-.45-1-1-1s-1 .45-1 1v.91A5.98 5.98 0 014.1 11H5c.55 0 1-.45 1-1s-.45-1-1-1h-.9A5.98 5.98 0 019 4.09V5c0 .55.45 1 1 1s1-.45 1-1v-.91A5.98 5.98 0 0115.9 9H15c-.55 0-1 .45-1 1s.45 1 1 1z"],lock:["M15.93 9H14V4.99c0-2.21-1.79-4-4-4s-4 1.79-4 4V9H3.93c-.55 0-.93.44-.93.99v8c0 .55.38 1.01.93 1.01h12c.55 0 1.07-.46 1.07-1.01v-8c0-.55-.52-.99-1.07-.99zM8 9V4.99c0-1.1.9-2 2-2s2 .9 2 2V9H8z"],"log-in":["M19 0h-8c-.55 0-1 .45-1 1s.45 1 1 1h7v16h-7c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 10c0-.28-.11-.53-.29-.71l-5-5a1.003 1.003 0 00-1.42 1.42L11.59 9H1c-.55 0-1 .45-1 1s.45 1 1 1h10.59L8.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5-5c.18-.18.29-.43.29-.71z"],"log-out":["M19.71 9.29l-5-5a1.003 1.003 0 00-1.42 1.42L16.59 9H6c-.55 0-1 .45-1 1s.45 1 1 1h10.59l-3.29 3.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l5-5c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM9 18H2V2h7c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],manual:["M20 1.1a.976.976 0 00-.83-.88C15.15-.43 12.07.34 10 2.5 7.93.34 4.85-.43.84.22.37.3.03.67 0 1.1v15.01c0 .07 0 .14.01.21.09.52.61.88 1.15.79 3.85-.62 6.4.16 8 2.46.02.02.03.04.05.07.02.02.04.04.06.07l.01.01a1.07 1.07 0 00.28.19c.01 0 .01.01.02.01.03.01.07.03.1.04.01 0 .02.01.04.01.03.01.07.02.1.02.01 0 .02 0 .04.01H10c.04 0 .09 0 .13-.01.01 0 .03 0 .04-.01.03-.01.06-.01.1-.02.01 0 .03-.01.04-.01.03-.01.07-.02.1-.04.01 0 .02-.01.03-.01.07-.03.13-.07.19-.11.01 0 .01-.01.02-.01.02-.02.04-.03.06-.05.01-.01.02-.02.03-.02l.05-.05c.01-.01.02-.02.02-.03.01-.02.02-.03.04-.05 1.61-2.3 4.15-3.09 8-2.46.54.09 1.06-.26 1.15-.79-.01-.05 0-.09 0-.13V1.1zM9 16.63c-1.78-1.31-4.12-1.83-7-1.55V2c3.26-.37 5.51.39 7 2.35v12.28zm9-1.56c-2.88-.28-5.22.24-7 1.55V4.34c1.49-1.96 3.74-2.71 7-2.35v13.08z"],"manually-entered-data":["M1 12h4.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm16.77-3.94l1.65-1.65c.36-.36.58-.86.58-1.41 0-1.1-.9-2-2-2-.55 0-1.05.22-1.41.59l-1.65 1.65 2.83 2.82zM1 4h12.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zM0 15c0 .55.45 1 1 1h.34l2-2H1c-.55 0-1 .45-1 1zm1-7h8.34l2-2H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 2h-.34l-2 2H19c.55 0 1-.45 1-1s-.45-1-1-1zm0 4h-4.34l-2 2H19c.55 0 1-.45 1-1s-.45-1-1-1zM4 19l4.41-1.59-2.81-2.79L4 19zM14.23 5.94l-7.65 7.65 2.83 2.83 7.65-7.65-2.83-2.83z"],"many-to-many":["M17 6a1 1 0 100-2 1 1 0 000 2zm0 2a3 3 0 01-2.73-1.754c-.2.068-.408.154-.617.264-.884.465-1.92 1.418-2.605 3.49.685 2.072 1.721 3.025 2.605 3.49.21.11.416.196.617.264a3 3 0 11-.165 2.034 6.262 6.262 0 01-1.383-.528c-.983-.518-1.948-1.364-2.722-2.705-.774 1.34-1.739 2.187-2.722 2.705-.48.252-.95.419-1.383.528A3.001 3.001 0 010 15a3 3 0 015.73-1.246c.2-.068.408-.154.617-.264.884-.465 1.92-1.418 2.605-3.49-.685-2.072-1.721-3.025-2.605-3.49a4.21 4.21 0 00-.617-.264 3 3 0 11.165-2.034c.433.11.904.276 1.383.528.983.518 1.948 1.364 2.722 2.705.774-1.34 1.739-2.187 2.722-2.705.48-.252.95-.419 1.383-.528A3.001 3.001 0 0120 5a3 3 0 01-3 3zM4 5a1 1 0 10-2 0 1 1 0 002 0zm12 10a1 1 0 102 0 1 1 0 00-2 0zM3 14a1 1 0 110 2 1 1 0 010-2z"],"many-to-one":["M3 2a1 1 0 100 2 1 1 0 000-2zm0 4c1.296 0 2.4-.821 2.82-1.972.487.039 1.086.13 1.667.347.947.352 1.773 1 2.032 2.318.323 1.644 1.234 2.675 2.264 3.307-1.03.632-1.941 1.663-2.264 3.307-.259 1.318-1.085 1.966-2.032 2.318a6.244 6.244 0 01-1.668.347 3.001 3.001 0 10.019 2.004c.633-.042 1.491-.158 2.347-.476 1.402-.523 2.867-1.625 3.296-3.807.259-1.318 1.085-1.966 2.032-2.318.24-.09.484-.158.722-.21a3 3 0 100-2.33 5.329 5.329 0 01-.722-.21c-.947-.352-1.773-1-2.032-2.318-.428-2.182-1.894-3.284-3.296-3.807-.856-.318-1.714-.434-2.347-.476A3.001 3.001 0 000 3a3 3 0 003 3zm13 4a1 1 0 102 0 1 1 0 00-2 0zM2 17a1 1 0 112 0 1 1 0 01-2 0z"],map:["M19.54 4.18l.01-.02-6-4-.01.02C13.39.08 13.21 0 13 0s-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v14c0 .35.19.64.46.82l-.01.02 6 4 .01-.02c.15.1.33.18.54.18s.39-.08.54-.18l.01.02L13 16.2l5.45 3.63.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1V5c0-.35-.19-.64-.46-.82zM6 17.13l-4-2.67V2.87l4 2.67v11.59zm6-2.67l-4 2.67V5.54l4-2.67v11.59zm6 2.67l-4-2.67V2.87l4 2.67v11.59z"],"map-create":["M18 9.22v7.91l-4-2.67V9.22c-.61-.55-1-1.33-1-2.22-.35 0-.69-.07-1-.18v7.65l-4 2.67V5.54l2.02-1.35c0-.06-.02-.13-.02-.19 0-1.66 1.34-3 3-3 0-.34.07-.66.17-.97C13.12.02 13.06 0 13 0c-.21 0-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v14c0 .35.19.64.46.82l-.01.02 6 4 .01-.02c.15.1.33.18.54.18s.39-.08.54-.18l.01.02L13 16.2l5.45 3.63.01-.02c.15.11.33.19.54.19.55 0 1-.45 1-1V6.82c-.31.11-.65.18-1 .18 0 .89-.39 1.67-1 2.22zM6 17.13l-4-2.67V2.87l4 2.67v11.59zM12 4c0 .55.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1z"],"map-marker":["M9.98 0c-3.87 0-7 2.98-7 6.67 0 3.68 7 13.33 7 13.33s7-9.65 7-13.33c0-3.68-3.14-6.67-7-6.67zm0 10c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"],maximize:["M19 0h-5c-.55 0-1 .45-1 1s.45 1 1 1h2.59L11.3 7.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L18 3.41V6c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zM8 11c-.28 0-.53.11-.71.29L2 16.59V14c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1H3.41l5.29-5.29c.19-.18.3-.43.3-.71 0-.55-.45-1-1-1z"],media:["M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z"],menu:["M1 6h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm18 3H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-closed":["M8 6h11c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM4 6c-.28 0-.53.11-.71.29l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3A1.003 1.003 0 005 13V7c0-.55-.45-1-1-1zm15 8H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0-5H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1z"],"menu-open":["M12 9H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0 5H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm0-10H1c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm7.71 5.29l-3-3A1.003 1.003 0 0015 7v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],"merge-columns":["M6.71 6.29a1.003 1.003 0 00-1.42 1.42L6.59 9H2V2h5v2.18c.42.15.8.39 1.11.7l.01-.01.88.89V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-4.76l-.88.88-.01-.01c-.31.31-.69.56-1.11.71V18H2v-7h4.59L5.3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM19 0h-7c-.55 0-1 .45-1 1v4.76l.88-.88.01.01c.31-.31.69-.55 1.11-.7V2h5v7h-4.59l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L13.41 11H18v7h-5v-2.18c-.42-.15-.8-.39-1.11-.7l-.01.01-.88-.89V19c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"merge-links":["M10 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm8-5c-.93 0-1.71.64-1.93 1.5H14V4c0-2.21-1.79-4-4-4S6 1.79 6 4v5.5H3.93C3.71 8.64 2.93 8 2 8c-1.1 0-2 .9-2 2s.9 2 2 2c.93 0 1.71-.64 1.93-1.5H6V16c0 2.21 1.79 4 4 4s4-1.79 4-4v-5.5h2.07c.22.86 1 1.5 1.93 1.5 1.1 0 2-.9 2-2s-.9-2-2-2zm-5 8c0 1.66-1.34 3-3 3s-3-1.34-3-3V4c0-1.66 1.34-3 3-3s3 1.34 3 3v12zM10 3c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],minimize:["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zM20 1a1.003 1.003 0 00-1.71-.71L13 5.59V3c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1h-2.59l5.29-5.29c.19-.18.3-.43.3-.71z"],minus:["M16 9H4c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],"mobile-phone":["M15 0H5c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 19c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4-3H6V3h8v13z"],"mobile-video":["M19 5c-.28 0-.53.11-.71.29L15 8.59V5c0-.55-.45-1-1-1H1c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h13c.55 0 1-.45 1-1v-3.59l3.29 3.29c.18.19.43.3.71.3.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],modal:["M19 1a1 1 0 011 1v16a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1h18zm-1 4H2v12h16V5zm-3-3h-2v2h2V2zm3 0h-2v2h2V2z"],"modal-filled":["M20 5v13a1 1 0 01-1 1H1a1 1 0 01-1-1V5h20zm-3-4h2a1 1 0 011 1v1h-3V1zm-2 2H0V2a1 1 0 011-1h14v2z"],moon:["M19 14.15A9.94 9.94 0 019.94 20C4.45 20 0 15.55 0 10.06 0 6.03 2.4 2.56 5.85 1a9.811 9.811 0 00-.88 4.09c0 5.49 4.45 9.94 9.94 9.94 1.46 0 2.84-.31 4.09-.88z"],more:["M3.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM17.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5zM10.5 8a2.5 2.5 0 100 5 2.5 2.5 0 100-5z"],mountain:["M20 16H4l7-11h1l2 2h1l5 9zm-4-5l-1.5-3h-1l-1-1-1-1L8 11.5l3-1.5 1 1 1-1 3 1zM8.055 8L2.79 16H0l7-8h1.055z"],move:["M19.71 9.29l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 9H11V3.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3C10.53.11 10.28 0 10 0s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 3.41V9H3.41L4.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 11H9v5.59L7.71 15.3A.965.965 0 007 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3a1.003 1.003 0 00-1.42-1.42L11 16.59V11h5.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z"],mugshot:["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18h-.07c-.05-.2-.12-.42-.22-.67-.46-1.05-2.68-1.75-4.16-2.4-1.48-.65-1.28-1.05-1.33-1.59-.01-.07-.01-.15-.01-.23.51-.45.92-1.07 1.19-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.34-.07.54-.44.61-.78.08-.14.23-.48.2-.87-.05-.5-.25-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5a3.67 3.67 0 00-1.29-1.86C11.7 3.25 10.81 3 10.02 3s-1.68.25-2.31.73c-.61.47-1.07 1.13-1.29 1.86-.05.16-.09.33-.11.5-.12.6-.17 1.51-.17 2.14v.08c-.24.09-.44.32-.49.83-.04.39.12.73.2.87.08.35.28.72.63.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.7 1.35 1.22 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.38 1.59-1.48.65-3.7 1.35-4.16 2.4-.12.27-.18.49-.23.69H2V2h16v16z"],"multi-select":["M19 3H7c-.55 0-1 .45-1 1v1h12v6h1c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-6 6H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm-1 6H2v-4h10v4zm4-9H4c-.55 0-1 .45-1 1v1h12v6h1c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],music:["M19 0c-.08 0-.16.03-.24.05V.03l-12 3v.02C6.33 3.16 6 3.53 6 4v11.35c-.59-.22-1.27-.35-2-.35-2.21 0-4 1.12-4 2.5S1.79 20 4 20c1.94 0 3.55-.86 3.92-2H8V7.78l10-2.5v7.07c-.59-.22-1.27-.35-2-.35-2.21 0-4 1.12-4 2.5s1.79 2.5 4 2.5c1.94 0 3.55-.86 3.92-2H20V1c0-.55-.45-1-1-1z"],nest:["M2 2c.55 0 1 .45 1 1v5c0 2.21 1.79 4 4 4h8.59L13.3 9.71A.965.965 0 0113 9a1.003 1.003 0 011.71-.71l4 4c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-4 4a1.003 1.003 0 01-1.42-1.42l2.3-2.29H7c-3.31 0-6-2.69-6-6V3c0-.55.45-1 1-1z"],"new-drawing":["M18.7 13.7c.5 0 1 .4 1 1 0 .257-.073.44-.22.614l-.08.086-4 4c-.2.2-.4.3-.7.3-.6 0-1-.5-1-1 0-.257.073-.44.22-.614L14 18l4-4c.2-.2.4-.3.7-.3zM1.8 0l8.378 2.982A3.003 3.003 0 0013 7a3.003 3.003 0 003.877 2.87l.723 2.53.049.06a.41.41 0 01.051.24c0 .167-.07.403-.208.593l-.092.107-4 4c-.2.2-.4.3-.7.3-.075 0-.15-.056-.225-.084L12.4 17.6l-7-2-.112-.042c-.223-.094-.431-.244-.542-.45L4.7 15 0 1.8l.5-.6L7 7.7c-.2.3-.3.6-.3 1 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2a1.68 1.68 0 00-.871.22L7.7 7 1.2.5l.6-.5zM16 0c.55 0 1 .45 1 1v2h2c.55 0 1 .45 1 1s-.45 1-1 1h-2v2c0 .432-.278.803-.664.941l-.01.004A.989.989 0 0116 8c-.55 0-1-.45-1-1V5h-2c-.55 0-1-.45-1-1l.007-.116C12.065 3.388 12.489 3 13 3h2V1c0-.55.45-1 1-1z"],"new-grid-item":["M8 0H1C.45 0 0 .45 0 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm0 11H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1v-7c0-.55-.45-1-1-1zm6 7h-1v-1c0-.55-.45-1-1-1s-1 .45-1 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1s-.45-1-1-1zm5-7h-2c-.55 0-1 .45-1 1s.45 1 1 1h1v1c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1zm0-11h-7c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-5 11h-2c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1s1-.45 1-1v-1h1c.55 0 1-.45 1-1s-.45-1-1-1zm5 5c-.55 0-1 .45-1 1v1h-1c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1z"],"new-layer":["M11.513 2.663A2 2 0 0013 6h1v1a2 2 0 104 0v-.733l1.5.833c.3.2.5.5.5.9s-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5C.2 8.7 0 8.4 0 8s.2-.7.5-.9l9-5c.2-.1.3-.1.5-.1s.3 0 .5.1l1.013.563zM17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2z"],"new-layers":["M17 3h2a1 1 0 010 2h-2v2a1 1 0 01-2 0V5h-2a1 1 0 010-2h2V1a1 1 0 012 0v2zm-1.252 5.984L10.5 11.9c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5C.2 6.7 0 6.4 0 6s.2-.7.5-.9l9-5c.2-.1.3-.1.5-.1s.3 0 .5.1L13.92 2H13a2 2 0 100 4h1v1a2 2 0 001.748 1.984zm2.07-1.15C17.935 7.58 18 7.298 18 7V6h1c.353 0 .684-.091.972-.251.018.078.028.162.028.251 0 .4-.2.7-.5.9l-1.682.934zM19 9c.6 0 1 .4 1 1 0 .4-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5c-.3-.2-.5-.5-.5-.9 0-.6.4-1 1-1 .2 0 .3 0 .5.1l8.5 4.8 8.5-4.8c.2-.1.3-.1.5-.1zm0 4c.6 0 1 .4 1 1 0 .4-.2.7-.5.9l-9 5c-.2.1-.3.1-.5.1s-.3 0-.5-.1l-9-5c-.3-.2-.5-.5-.5-.9 0-.6.4-1 1-1 .2 0 .3 0 .5.2l8.5 4.7 8.5-4.8c.2-.1.3-.1.5-.1z"],"new-link":["M14.5 12a2.5 2.5 0 00-2.45 2h-7.1a2.5 2.5 0 100 1h7.1a2.5 2.5 0 102.45-3zM19 5h-2V3c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V7h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-object":["M12 4c0 .6.4 1 1 1h2v2c0 .6.4 1 1 1 .5 0 1-.4 1-1V5h2c.5 0 1-.4 1-1s-.5-1-1-1h-2V1c0-.6-.5-1-1-1-.6 0-1 .4-1 1v2h-2c-.6 0-1 .5-1 1zm7 3c0 1.7-1.3 3-3 3s-3-1.3-3-3c-1.7 0-3-1.3-3-3s1.3-3 3-3c0-.2 0-.4.1-.5-1-.3-2-.5-3.1-.5C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10c0-1.1-.2-2.1-.5-3H19z"],"new-person":["M11.41 15.92c-1.46-.65-1.26-1.05-1.31-1.59-.01-.07-.01-.15-.01-.23.5-.45.91-1.07 1.18-1.78 0 0 .01-.04.02-.05.06-.15.11-.32.15-.48.33-.07.53-.44.6-.78.08-.14.23-.48.2-.87-.05-.5-.24-.73-.47-.82v-.09c0-.63-.06-1.55-.17-2.15-.02-.17-.06-.33-.11-.5-.22-.73-.67-1.4-1.27-1.86C9.58 4.25 8.7 4 7.92 4c-.78 0-1.66.25-2.28.73-.61.47-1.06 1.13-1.27 1.86-.05.16-.08.33-.11.5-.12.6-.18 1.51-.18 2.14v.08c-.23.09-.43.32-.48.83-.04.39.12.73.2.87.08.35.28.72.62.78.04.17.09.33.15.48 0 .01.01.02.01.03l.01.01c.27.72.69 1.35 1.21 1.8 0 .07-.01.14-.01.21-.05.54.1.94-1.36 1.59-1.46.65-3.66 1.35-4.11 2.4C-.14 19.38.04 20 .04 20h15.75s.18-.62-.27-1.67c-.45-1.06-2.65-1.75-4.11-2.41zM18.87 3h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"new-prescription":["M11.95 10.23c.16-.18.22-.22.46-.22h1.48c.25 0 .47.08.59.33.1.2.09.41-.05.66l-2.71 3.58L14.88 19c.13.21.16.46.03.69-.12.21-.34.31-.57.31H12.7c-.31 0-.56-.17-.7-.44l-1.9-2.67-1.93 2.68c-.15.27-.42.43-.73.43H5.98c-.25 0-.47-.08-.59-.33-.1-.2-.09-.41.05-.66l3.09-4.35L4.26 9H3v4.32c0 .41-.3.69-.7.69H.7c-.41 0-.7-.28-.7-.69V.69C0 .28.3 0 .7 0h4.42c.71 0 1.36.1 1.94.3.59.2 1.11.49 1.54.87.44.38.78.84 1.02 1.39.25.54.37 1.13.37 1.77 0 1.01-.28 1.88-.84 2.6-.43.54-1.35 1.29-2 1.59l3.09 3.94 1.71-2.23zM4.71 6.04c.71 0 1.45-.16 1.81-.46.33-.28.5-.69.5-1.25s-.17-.97-.5-1.25c-.35-.3-1.1-.46-1.81-.46h-1.7v3.42h1.7zM19 3c.55 0 1 .45 1 1s-.45 1-1 1h-2v2c0 .55-.45 1-1 1s-1-.45-1-1V5h-2c-.55 0-1-.45-1-1s.45-1 1-1h2V1c0-.55.45-1 1-1s1 .45 1 1v2h2z"],"new-text-box":["M19 3h-2V1c0-.55-.45-1-1-1s-1 .45-1 1v2h-2c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V5h2c.55 0 1-.45 1-1s-.45-1-1-1zM5 7.5v1c0 .28.22.5.5.5s.5-.22.5-.5V8h2v7h-.5c-.28 0-.5.22-.5.5s.22.5.5.5h2c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H9V8h2v.5c0 .28.22.5.5.5s.5-.22.5-.5v-1c0-.28-.22-.5-.5-.5h-6c-.28 0-.5.22-.5.5zM16 9c-.55 0-1 .45-1 1v8H2V5h8c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1h15c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1z"],ninja:["M20 6s-2.98 2.43-6.12 2.19C13.52 5.31 12.05 0 6 0c0 0 2.41 2.99 2.16 6.12C5.27 6.49 0 7.97 0 14c0 0 2.98-2.43 6.11-2.19C6.47 14.69 7.94 20 14 20c0 0-2.42-2.99-2.16-6.13C14.73 13.51 20 12.02 20 6zm-10 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"not-equal-to":["M9.487 7l.532-3.196a1 1 0 011.962.392L11.513 7H16a1 1 0 010 2h-4.82l-.333 2H16a1 1 0 010 2h-5.487l-.532 3.196a1 1 0 01-1.962-.392L8.487 13H4a1 1 0 010-2h4.82l.333-2H4a1 1 0 110-2h5.487z"],notifications:["M10 20c1.1 0 2-.9 2-2H8c0 1.1.9 2 2 2zm7-5c-.55 0-1-.45-1-1V8c0-2.61-1.67-4.81-4-5.63V2c0-1.1-.9-2-2-2S8 .9 8 2v.37C5.67 3.19 4 5.39 4 8v6c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1z"],"notifications-snooze":["M10 18c0 1.1-.9 2-2 2s-2-.9-2-2zM8 0c.476 0 .914.168 1.258.448C8.508.878 8.09 1.562 8 2.5c-.133 1.4.4 2.367 1.6 2.9C8.533 6.6 8 7.467 8 8v1.2a2.8 2.8 0 002.8 2.8H14v2c0 .51.388.935.884.993L15 15c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V8c0-2.61 1.67-4.81 4-5.63V2c0-1.1.9-2 2-2z","M16 9.25v-.395a.75.75 0 00-.75-.75h-2.813L15.834 3.9A.75.75 0 0016 3.43v-.68a.75.75 0 00-.75-.75h-4.5a.75.75 0 00-.75.75v.184c0 .414.336.75.75.75h2.813L10.22 7.831a1 1 0 00-.221.627v.792c0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75z"],"notifications-updated":["M10 20c1.1 0 2-.9 2-2H8c0 1.1.9 2 2 2zm2-17.834A2.994 2.994 0 008 4.99c0 .808.319 1.557.876 2.114l2.97 2.99a2.99 2.99 0 004.154.072V14c0 .55.45 1 1 1s1 .45 1 1-.45 1-1 1H3c-.55 0-1-.45-1-1s.45-1 1-1 1-.45 1-1V8c0-2.61 1.67-4.81 4-5.63V2c0-1.1.9-2 2-2s2 .9 2 2v.166zm1.26 6.514l-2.97-2.99a.973.973 0 01-.29-.7c0-.55.44-1 .99-1 .27 0 .52.11.7.29l2.28 2.28 4.27-4.27a.99.99 0 01.7-.29c.55 0 1 .45 1 1 0 .28-.11.53-.3.7l-4.98 4.98a.99.99 0 01-1.4 0z"],"numbered-list":["M1.74 9.01h1.27V1h-.95c-.04.24-.12.45-.26.62-.13.17-.29.3-.47.41-.19.11-.4.18-.63.23-.23.04-.46.07-.71.07v1.03h1.75v5.65zm.43 7.93c.18-.14.37-.28.58-.43.21-.14.42-.29.63-.45.21-.16.41-.33.61-.5.2-.18.37-.38.52-.59.15-.21.28-.45.37-.7.09-.25.14-.54.14-.85 0-.25-.04-.52-.12-.8-.08-.28-.21-.54-.39-.78-.19-.24-.43-.44-.73-.59-.3-.17-.68-.25-1.12-.25-.41 0-.77.08-1.08.23-.32.16-.58.37-.8.64-.22.27-.38.59-.49.96-.11.37-.16.77-.16 1.21h1.19c.01-.28.03-.53.08-.77s.12-.45.21-.62c.09-.18.22-.31.38-.42.16-.1.35-.15.59-.15.26 0 .47.05.63.14.16.09.29.21.38.35.09.14.15.29.18.45.03.16.05.31.05.45-.01.31-.08.58-.22.81-.14.24-.32.45-.53.66-.22.2-.45.39-.71.57-.26.18-.51.36-.74.54-.5.36-.89.78-1.17 1.27-.3.47-.45 1.04-.46 1.69H5v-1.14H1.43c.05-.17.14-.33.27-.49.13-.15.29-.3.47-.44zM18 4.02H8c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-1c0-.56-.45-1-1-1zm0 9H8c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-1c0-.56-.45-1-1-1z"],numerical:["M2.39 5.75c-.17.21-.38.39-.63.52s-.52.23-.83.29c-.3.05-.61.08-.93.08v1.24h2.49V15h1.49V4.98H2.73c-.05.31-.17.57-.34.77zm17.2 4.71c-.27-.44-.65-.71-1.14-.82v-.02c.42-.16.72-.43.92-.79.2-.36.29-.79.29-1.27 0-.42-.08-.8-.23-1.12-.15-.33-.36-.59-.62-.8-.26-.21-.55-.37-.87-.48-.32-.11-.65-.16-.98-.16-.43 0-.82.08-1.16.25-.34.16-.63.39-.87.69-.24.29-.43.64-.57 1.04-.14.4-.22.83-.23 1.3h1.39c-.01-.25.02-.49.07-.72.06-.23.14-.44.26-.63s.27-.34.45-.45c.18-.11.39-.17.63-.17.39 0 .71.12.96.37s.37.58.37.99c0 .29-.05.54-.16.74-.11.2-.25.36-.43.47-.18.11-.38.19-.61.24-.23.05-.46.06-.68.05v1.17c.28-.01.55 0 .81.03s.5.1.71.21c.21.11.38.28.51.5.13.22.2.52.2.89 0 .55-.16.97-.47 1.27-.31.3-.7.45-1.17.45-.55 0-.95-.19-1.23-.58-.27-.39-.4-.88-.38-1.46h-1.39c.01.5.08.96.21 1.38.13.41.32.77.57 1.06.25.29.56.52.93.68.37.16.8.24 1.3.24.41 0 .79-.07 1.16-.21.37-.14.69-.33.96-.58.28-.25.5-.56.66-.92a3 3 0 00.24-1.23c0-.64-.14-1.17-.41-1.61zM8.58 12.41c.21-.18.45-.36.7-.53.25-.18.5-.36.75-.56.25-.2.49-.41.73-.63.23-.22.44-.47.63-.74.18-.27.33-.56.44-.88.11-.32.16-.67.16-1.07 0-.32-.05-.65-.14-1-.09-.35-.25-.68-.47-.97-.22-.3-.51-.55-.87-.74-.36-.2-.81-.29-1.35-.29-.49 0-.93.1-1.3.29-.37.18-.69.44-.95.78-.26.33-.45.73-.58 1.2-.13.46-.2.96-.2 1.5h1.43c.01-.35.04-.67.09-.97.05-.3.14-.56.25-.78.11-.22.26-.39.45-.52s.43-.19.71-.19c.31 0 .56.06.75.18.19.12.34.26.45.43.11.17.18.36.22.56.04.2.06.39.06.57-.01.38-.1.72-.26 1.02-.15.3-.37.57-.63.83-.26.25-.54.49-.85.71-.31.22-.61.45-.89.68-.6.45-1.06.98-1.41 1.58-.35.61-.52 1.32-.53 2.13h6.01v-1.43H7.69c.06-.21.17-.42.33-.61s.34-.38.56-.55z"],office:["M19 6h-5V1c0-.55-.45-1-1-1H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h4v-6h4v6h10c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1zM6 12H2V8h4v4zm0-6H2V2h4v4zm6 6H8V8h4v4zm0-6H8V2h4v4zm6 11h-4v-3h4v3zm0-5h-4V8h4v4z"],offline:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zM7 18l2-7H5l8-9-2 7h4l-8 9z"],"oil-field":["M19 17.99h-1.36l-4.35-9.57 2.91-.86 1.66 4.1c.11.27.43.4.72.31.12-.04.22-.11.28-.2.06-.11 1.47-2.08 1.05-5.6C19.79 5.12 19.3 0 16.01 0 14.89.01 13.99.83 14 1.84c0 .19.04.38.1.56l1.34 3.31L.72 10.03v.02c-.41.12-.72.49-.72.94 0 .55.45 1 1 1 .1 0 .19-.03.28-.06v.02l2-.59 1.47 6.63H3c-.55 0-1 .45-1 1s.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1zM5.2 10.8l3.95-1.16-2.83 6.22L5.2 10.8zm2.35 7.19l3.95-8.68 3.95 8.68h-7.9z"],"one-column":["M14.94 0h-4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-8 6c-.28 0-.53.11-.71.29l-3 3c-.18.18-.29.43-.29.71s.11.53.29.71l3 3A1.003 1.003 0 007.94 13V7c0-.55-.45-1-1-1z"],"one-to-many":["M18 3a1 1 0 11-2 0 1 1 0 012 0zm-3.82 1.028a6.243 6.243 0 00-1.667.347c-.947.352-1.773 1-2.032 2.318C10.158 8.337 9.247 9.368 8.217 10c1.03.632 1.941 1.663 2.264 3.307.259 1.318 1.085 1.966 2.032 2.318.581.217 1.18.308 1.668.347a3.001 3.001 0 11-.019 2.004c-.633-.042-1.491-.158-2.347-.476-1.402-.523-2.868-1.625-3.296-3.807-.259-1.318-1.085-1.966-2.032-2.318a5.314 5.314 0 00-.722-.21 3 3 0 110-2.33c.238-.052.481-.12.722-.21.947-.352 1.773-1 2.032-2.318.428-2.182 1.894-3.284 3.296-3.807.856-.318 1.714-.434 2.347-.476A3.001 3.001 0 0120 3a3 3 0 01-5.82 1.028zM4 10a1 1 0 100 .002v-.002zM17 18a1 1 0 100-2 1 1 0 000 2z"],"one-to-one":["M2 10a1 1 0 112 0 1 1 0 01-2 0zm3.83-1a3.001 3.001 0 100 2h8.34a3.001 3.001 0 100-2H5.83zM17 9a1 1 0 100 2 1 1 0 000-2z"],outdated:["M10 0c5.52 0 10 4.48 10 10s-4.48 10-10 10S0 15.52 0 10c0-.55.45-1 1-1s1 .45 1 1c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8C7.47 2 5.22 3.17 3.76 5H5c.55 0 1 .45 1 1s-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1s1 .45 1 1v2.05C3.82 1.6 6.71 0 10 0zm1 16H9v-2h2v2zm0-3H9V4h2v9z"],"page-layout":["M19 1H1c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zM7 17H2V8h5v9zm11 0H8V8h10v9zm0-10H2V3h16v4z"],"panel-stats":["M1 1h18a1 1 0 011 1v15a1 1 0 01-1 1H1a1 1 0 01-1-1V2a1 1 0 011-1zm1 2v13h16V3H2zm9 0h1v13h-1V3zm2 7h3.952v1H13v-1zm0 2h3.952v1H13v-1zm0 2h3.952v1H13v-1zm0-6h3.952v1H13V8zm0-2h3.952v1H13V6zm0-2h3.952v1H13V4z"],"panel-table":["M19 1H1c-.6 0-1 .4-1 1v15c0 .6.4 1 1 1h18c.6 0 1-.4 1-1V2c0-.6-.4-1-1-1zm-9 11H7V9h3v3zm0-4H7V5h3v3zm-8 8V3h4v13H2zm5 0v-3h3v3H7zm11 0h-7v-3h7v3zm0-4h-7V9h7v3zm0-4h-7V5h7v3z"],paperclip:["M18.35 2.67A5.664 5.664 0 0014.33 1c-1.44 0-2.89.56-3.99 1.67l-9.16 9.27C.4 12.73 0 13.78 0 14.83s.39 2.1 1.18 2.9c.78.79 1.82 1.18 2.85 1.18 1.04 0 2.07-.39 2.87-1.2l9.14-9.27c.96-.96.96-2.5.02-3.45-.94-.95-2.49-.96-3.44 0l-7.59 7.69c-.31.32-.3.83.01 1.14.31.31.81.31 1.13.02l7.59-7.69c.31-.31.84-.31 1.13-.02.31.31.31.85 0 1.16l-9.14 9.27c-.93.95-2.54.93-3.45.02-.94-.95-.92-2.55.02-3.49l9.16-9.25c1.55-1.56 4.18-1.59 5.72-.03 1.56 1.57 1.55 4.26 0 5.82l-8.89 9.02c-.3.31-.3.81.01 1.11.3.3.79.31 1.1.01v.01l8.91-9.02A5.645 5.645 0 0020 6.73c0-1.48-.55-2.94-1.65-4.06z"],paragraph:["M16.5 1H7C4.2 1 2 3.2 2 6s2.2 5 5 5v6.5c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V4h2v13.5c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V4h1.5c.8 0 1.5-.7 1.5-1.5S17.3 1 16.5 1z"],path:["M18 0H2C.9 0 0 .9 0 2s.9 2 2 2h7v4H4c-1.1 0-2 .9-2 2s.9 2 2 2h5v4H6c-1.1 0-2 .9-2 2s.9 2 2 2h8c1.1 0 2-.9 2-2s-.9-2-2-2h-3v-4h5c1.1 0 2-.9 2-2s-.9-2-2-2h-5V4h7c1.1 0 2-.9 2-2s-.9-2-2-2z"],"path-search":["M4 7c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 11.69l-5-2.5v-3.63c-.32.11-.66.22-1 .29v3.32l-6 2.57v-7.25c-.36-.27-.69-.57-1-.9v8.1l-5-2.5V10c.55 0 1-.45 1-1s-.45-1-1-1V1.31l3.43 1.71c.11-.31.24-.62.39-.92L.72.05A.545.545 0 00.5 0C.22 0 0 .22 0 .5v16c0 .2.12.36.28.44l6 3c.07.04.14.06.22.06.07 0 .14-.01.2-.04l6.79-2.91 5.79 2.9c.07.03.14.05.22.05.28 0 .5-.22.5-.5v-4.21c-.31.13-.64.21-1 .21v3.19zM10 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3-1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm6.72-.94l-1.43-.72c.2.43.36.89.48 1.36l.23.11V5.5c-.55 0-1 .45-1 1s.45 1 1 1v1.96l1 1V3.5c0-.2-.12-.36-.28-.44zm-3.69 5.56c.14-.21.27-.42.38-.65.02-.04.04-.07.05-.11.11-.22.2-.45.28-.69v-.01c.07-.24.13-.48.17-.73l.03-.17c.04-.25.06-.5.06-.76C17 2.46 14.54 0 11.5 0S6 2.46 6 5.5 8.46 11 11.5 11c.26 0 .51-.02.76-.06l.17-.03c.25-.04.49-.1.73-.17h.01c.24-.08.47-.17.69-.28.04-.02.07-.03.11-.05.23-.11.44-.24.65-.38l.18.18 3.5 3.5c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71l-3.68-3.67zm-4.53.88c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"],pause:["M7 3H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm9 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],people:["M16.94 17a4.92 4.92 0 00-.33-1.06c-.45-.97-1.37-1.52-3.24-2.3-.17-.07-.76-.31-.77-.32-.1-.04-.2-.08-.28-.12.05-.14.04-.29.06-.45 0-.05.01-.11.01-.16-.25-.21-.47-.48-.65-.79.22-.34.41-.71.56-1.12l.04-.11c-.01.02-.01.02-.02.08l.06-.15c.36-.26.6-.67.72-1.13.18-.37.29-.82.25-1.3-.05-.5-.21-.92-.47-1.22-.02-.53-.06-1.11-.12-1.59.38-.17.83-.26 1.24-.26.59 0 1.26.19 1.73.55.46.35.8.85.97 1.4.04.13.07.25.08.38.08.45.13 1.14.13 1.61v.07c.16.07.31.24.35.62.02.29-.09.55-.15.65-.05.26-.2.53-.46.59-.03.12-.07.25-.11.36-.01.01-.01.04-.01.04-.2.53-.51 1-.89 1.34 0 .06 0 .12.01.17.04.41-.11.71 1 1.19 1.1.5 2.77 1.01 3.13 1.79.34.79.2 1.25.2 1.25h-3.04zm-5.42-3.06c1.47.66 3.7 1.35 4.18 2.39.45 1.05.27 1.67.27 1.67H.04s-.19-.62.27-1.67c.46-1.05 2.68-1.75 4.16-2.4 1.48-.65 1.33-1.05 1.38-1.59 0-.07.01-.14.01-.21-.52-.45-.95-1.08-1.22-1.8l-.01-.01c0-.01-.01-.02-.01-.03-.07-.15-.12-.32-.16-.49-.34-.06-.54-.43-.62-.78-.08-.14-.24-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.64.05-1.55.17-2.15a3.648 3.648 0 011.4-2.36C6.32 2.25 7.21 2 8 2s1.68.25 2.31.73a3.63 3.63 0 011.4 2.36c.11.6.17 1.52.17 2.15v.09c.22.09.42.32.47.82.03.39-.12.73-.2.87-.07.34-.27.71-.61.78-.04.16-.09.33-.15.48-.01.01-.02.05-.02.05-.27.71-.68 1.33-1.19 1.78 0 .08 0 .16.01.23.05.55-.15.95 1.33 1.6z"],percentage:["M15 10c-1.66 0-3 1.34-3 3v2c0 1.66 1.34 3 3 3s3-1.34 3-3v-2c0-1.66-1.34-3-3-3zm1 5c0 .55-.45 1-1 1s-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2zM8 7V5c0-1.66-1.34-3-3-3S2 3.34 2 5v2c0 1.66 1.34 3 3 3s3-1.34 3-3zM4 7V5c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1zm11-4a1.003 1.003 0 00-1.88-.48L5.14 16.49a1.003 1.003 0 101.74.99l7.99-13.97c.08-.15.13-.32.13-.51z"],person:["M19.61 17.91c-.57-1.32-3.35-2.19-5.19-3.01-1.85-.82-1.59-1.31-1.66-1.99-.01-.09-.01-.19-.02-.29.63-.56 1.15-1.33 1.49-2.22 0 0 .02-.05.02-.06.07-.19.13-.39.19-.6.42-.09.67-.55.76-.98.1-.17.29-.6.25-1.08-.06-.62-.31-.91-.59-1.03v-.11c0-.79-.07-1.93-.22-2.68A4.55 4.55 0 0012.9.92C12.11.32 11 0 10.01 0s-2.1.32-2.89.92a4.55 4.55 0 00-1.74 2.94c-.14.75-.22 1.89-.22 2.68v.1c-.29.11-.55.4-.61 1.04-.04.48.15.91.25 1.08.1.44.35.91.79.98.05.21.12.41.19.6 0 .01.01.03.01.04l.01.02c.34.91.87 1.69 1.52 2.25 0 .09-.01.18-.02.26-.07.68.13 1.17-1.72 1.99S.96 16.59.39 17.91C-.18 19.23.05 20 .05 20h19.9s.23-.77-.34-2.09z"],phone:["M19.91 15.51c-.08-.08-4.21-2.5-4.35-2.57a.876.876 0 00-.4-.1c-.19 0-.42.13-.71.4-.28.27-1.17 1.49-1.43 1.76s-.48.4-.65.4c-.08 0-.19-.02-.32-.07s-1.45-.73-4.2-3.15-3.11-4-3.13-4.44c0-.17.13-.39.4-.65.28-.25.57-.51.89-.74.32-.24.61-.5.88-.78s.4-.52.4-.71c0-.13-.03-.27-.1-.4C7.12 4.32 4.62.19 4.53.1c-.19-.18-.92-.1-1.29.1C.25 1.82 0 4 .05 4.86c.05.89.61 5.58 5.2 9.93 5.7 5.41 9.66 5.2 9.92 5.2.87 0 3.52-.48 4.65-3.19.16-.38.31-1.07.09-1.29z"],"pie-chart":["M9 .98c-4.5.5-8 4.31-8 8.94 0 4.97 4.03 9.04 9 9.04 4.63 0 8.44-3.96 8.94-7.96H9V.98z","M10-.08V10h10C20 4 15.52-.08 10-.08z"],pin:["M11.77 1.16c-.81.81-.74 2.28.02 3.76L6.1 8.71c-2.17-1.46-4.12-2-4.94-1.18l4.95 4.95-4.95 6.36 6.36-4.95 4.95 4.95c.82-.82.27-2.77-1.19-4.94l3.8-5.69c1.47.76 2.94.84 3.76.02l-7.07-7.07z"],pivot:["M5.83 9.75L.29 15.29a1.003 1.003 0 001.42 1.42l5.54-5.54c-.57-.37-1.05-.85-1.42-1.42zM19 11c-.55 0-1 .45-1 1v1.59l-3.83-3.83c-.37.56-.85 1.04-1.41 1.41L16.59 15H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1zm-5-4c0-2.21-1.79-4-4-4S6 4.79 6 7s1.79 4 4 4 4-1.79 4-4zm-4 2c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"],"pivot-table":["M3 5H1c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm0-5H1C.45 0 0 .45 0 1v2c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm13.71 5.29C16.53 5.11 16.28 5 16 5s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L15 8.41V11c0 2.21-1.79 4-4 4H8.41l1.29-1.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L8.41 17H11c3.31 0 6-2.69 6-6V8.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zM19 0H6c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],play:["M16 10c0-.36-.2-.67-.49-.84l.01-.01-10-6-.01.01A.991.991 0 005 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .19 0 .36-.07.51-.16l.01.01 10-6-.01-.01c.29-.17.49-.48.49-.84z"],plus:["M16 9h-5V4c0-.55-.45-1-1-1s-1 .45-1 1v5H4c-.55 0-1 .45-1 1s.45 1 1 1h5v5c0 .55.45 1 1 1s1-.45 1-1v-5h5c.55 0 1-.45 1-1s-.45-1-1-1z"],"polygon-filter":["M18 7c-.27 0-.52.05-.75.15l-6.28-4.88c.01-.09.03-.18.03-.27 0-1.1-.9-2-2-2S7 .9 7 2c0 .06.01.12.02.19l-4.19 3C2.57 5.07 2.29 5 2 5 .9 5 0 5.9 0 7c0 .74.4 1.38 1 1.72v7.55c-.6.35-1 .99-1 1.73 0 1.1.9 2 2 2 .74 0 1.38-.4 1.72-1h7.55c.35.6.98 1 1.72 1 1.1 0 2-.9 2-2 0-.37-.11-.72-.29-1.02L18.03 11A2 2 0 0018 7zm-5.03 9c-.72.01-1.35.41-1.69 1H3.72c-.17-.3-.42-.55-.72-.72V8.72c.6-.34 1-.98 1-1.72 0-.06-.01-.12-.02-.19l4.19-3c.26.12.54.19.83.19.27 0 .52-.05.75-.15l6.28 4.88c-.01.09-.03.18-.03.27 0 .37.11.72.29 1.02L12.97 16z"],power:["M10 10c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1S9 .45 9 1v8c0 .55.45 1 1 1zm3-7.45v2.16c2.36 1.12 4 3.5 4 6.29 0 3.87-3.13 7-7 7s-7-3.13-7-7c0-2.79 1.64-5.17 4-6.29V2.55C3.51 3.79 1 7.09 1 11a9 9 0 0018 0c0-3.91-2.51-7.21-6-8.45z"],"predictive-analysis":["M20 8.01c0-1.26-.61-2.43-1.61-3.12C17.86 2.5 15.8.79 13.4.79c-.58 0-1.14.1-1.69.29A3.533 3.533 0 009.17 0C8.05 0 7 .55 6.32 1.45c-.15-.02-.3-.03-.45-.03-1.63 0-3.03 1.12-3.46 2.71C.97 4.65 0 6.05 0 7.66c0 .48.09.95.26 1.4-.17.44-.26.91-.26 1.39 0 1.38.72 2.64 1.89 3.29.67.7 1.59 1.09 2.54 1.09.61 0 1.19-.15 1.71-.45.68.82 1.68 1.3 2.73 1.3.66 0 1.28-.18 1.83-.52.61.49 1.34.81 2.11.91 1.3 1.43 2.3 3.28 2.31 3.3 0 0 .35.61.33.61.96-.01 1.77-.2 1.64-1.3.01.02-.92-2.89-.92-2.89.52-.26.94-.69 1.21-1.23 1.12-.66 1.84-1.91 1.84-3.26 0-.3-.03-.6-.1-.89.57-.64.88-1.51.88-2.4zm-1.54 1.28l-.18-.2-.77-.84c-.33-.37-.67-1.17-.73-1.73 0 0-.13-1.25-.13-1.26-.06-.74-1.17-.73-1.13.14 0 .02.13 1.26.13 1.26.04.36.15.77.3 1.17-.08-.01-.15-.02-.22-.02 0 0-2.57-.12-2.57-.13-.73-.03-.89 1.22-.05 1.25l2.57.13c.53.03 1.29.37 1.61.72l.61.67.02.06c.1.27.14.55.14.83 0 .93-.51 1.77-1.34 2.18l-.2.1-.09.23c-.19.48-.6.82-1.1.93l-.67.14.87 2.75c-.48-.76-1.19-1.79-2.02-2.67l-.15-.16-.21-.02c-.51-.04-.99-.21-1.42-.48l1.7-1.48c.44-.39 1.04-.55 1.24-.49 0 0 .78.22.78.23.78.2 1.03-.92.29-1.21l-.78-.23c-.69-.2-1.67.22-2.24.72l-1.91 1.66-.39.32c-.44.36-.93.55-1.5.55-.8 0-1.54-.41-1.97-1.07v-1.88c0-.5.21-.98.34-1.07 0 0 .65-.43.64-.43.87-.69.21-1.57-.64-1.14 0-.01-.65.43-.65.43-.31.2-.54.56-.7.97-.13-.13-.28-.25-.43-.35 0 0-1.91-1.26-1.91-1.28-.81-.56-1.5.63-.61 1.11 0-.02 1.89 1.28 1.89 1.28.46.31.77.97.77 1.36v.84c-.43.24-.78.36-1.24.36-.67 0-1.31-.29-1.77-.79l-.07-.08-.09-.05a2.425 2.425 0 01-1.31-2.16c0-.38.09-.74.25-1.08l.15-.31-.14-.33c-.17-.34-.25-.7-.25-1.08 0-1.13.76-2.1 1.85-2.37l.39-.09.07-.43a2.41 2.41 0 012.39-2.05c.19 0 .39.02.58.07l.4.1.22-.38A2.41 2.41 0 019.17 1.3c.55 0 1.08.19 1.5.53l-.44.45-.01-.01-.31.31c-.41.35-.92.53-1.11.5 0 0-.84-.13-.84-.14-.83-.15-1.09 1.08-.18 1.29.01 0 .84.14.84.14.03 0 .06 0 .09.01-.14.46-.18.96-.12 1.4 0 0 .21 1.24.19 1.23.13.65 1.32.44 1.16-.22 0-.01-.19-1.23-.19-1.23-.07-.48.15-1.19.45-1.5l.48-.5c.07-.06.13-.12.19-.18l.93-.95c.5-.23 1.04-.34 1.59-.34 1.93 0 3.57 1.4 3.89 3.34l.05.31.26.15a2.445 2.445 0 01.87 3.4z"],prescription:["M13.95 10.23c.16-.18.22-.22.46-.22h1.48c.25 0 .47.08.59.33.1.2.09.41-.05.66l-2.71 3.58L16.88 19c.13.21.16.46.03.69-.12.21-.34.31-.57.31H14.7c-.31 0-.56-.17-.7-.44l-1.9-2.67-1.93 2.68c-.15.27-.42.43-.73.43H7.98c-.25 0-.47-.08-.59-.33-.1-.2-.09-.41.05-.66l3.09-4.35L6.26 9H5v4.32c0 .41-.3.69-.7.69H2.7c-.41 0-.7-.28-.7-.69V.69c0-.41.3-.69.7-.69h4.42c.71 0 1.36.1 1.94.3.59.2 1.11.49 1.54.87.44.38.78.84 1.02 1.39.24.54.36 1.14.36 1.78 0 1.01-.28 1.88-.84 2.6-.43.54-1.35 1.29-2 1.59l3.09 3.94 1.72-2.24zM6.71 6.04c.71 0 1.45-.16 1.81-.46.33-.28.5-.69.5-1.25s-.17-.97-.5-1.25c-.35-.3-1.1-.46-1.81-.46h-1.7v3.42h1.7z"],presentation:["M19 1h-8c0-.55-.45-1-1-1S9 .45 9 1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v11c0 .55.45 1 1 1h4.59L4.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L9 16.41V19c0 .55.45 1 1 1s1-.45 1-1v-2.59l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L12.41 15H17c.55 0 1-.45 1-1V3h1c.55 0 1-.45 1-1s-.45-1-1-1zm-3 12H4V3h12v10z"],print:["M14 16H6v-4H4v5c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-5h-2v4zm2-13c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h12V3zm3 2H1c-.55 0-1 .45-1 1v7c0 .55.45 1 1 1h2v-3h14v3h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 4h-2V7h2v2z"],projects:["M18 4c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h16V4zm-2-3c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v1h12V1zm3 6H1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-5 7c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-2h1v2h6v-2h1v2z"],properties:["M2 15c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm5-4h12c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zM2 1C.9 1 0 1.9 0 3s.9 2 2 2 2-.9 2-2-.9-2-2-2zm17 8H7c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zm0 7H7c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"],property:["M3 5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm5-1h11c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zM3 15c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm16 1H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm-1-8H9c-1.1 0-2 .9-2 2s.9 2 2 2h9c1.1 0 2-.9 2-2s-.9-2-2-2zM3 7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"],"publish-function":["M7.01 10.11c.35-.64.72-1.68 1.09-3.11l.8-3.03h.96l.24-.77h-.99c.28-1.11.66-1.92 1.12-2.43.28-.32.56-.48.83-.48.05 0 .1.02.13.05.03.03.05.07.05.12 0 .04-.04.13-.11.25-.08.12-.11.24-.11.35 0 .15.06.28.18.39.12.11.27.16.45.16.2 0 .36-.07.49-.2s.2-.31.2-.54c0-.26-.1-.47-.3-.63-.2-.16-.52-.24-.96-.24-.68 0-1.3.19-1.86.58-.55.38-1.08 1.02-1.58 1.91-.17.3-.34.5-.49.59-.15.08-.4.13-.74.12l-.23.77h.95L5.74 9.21c-.23.86-.39 1.39-.47 1.59-.12.29-.3.54-.54.75-.1.08-.21.12-.35.12-.04 0-.07-.01-.1-.03l-.03-.04c0-.02.03-.07.1-.13.07-.07.1-.17.1-.31 0-.15-.05-.28-.16-.38-.11-.1-.27-.15-.47-.15-.25 0-.44.07-.59.2-.15.12-.23.28-.23.46 0 .19.09.36.27.5.19.14.47.21.86.21.61 0 1.16-.15 1.63-.46.48-.31.89-.79 1.25-1.43zm3.7 1.18c-.18-.18-.43-.29-.71-.29s-.53.11-.71.29l-3 3a1.003 1.003 0 001.42 1.42L9 14.41V19c0 .55.45 1 1 1s1-.45 1-1v-4.59l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-3-3zm4.15-6.78c.17-.13.36-.2.55-.2.07 0 .2.03.39.08s.36.08.5.08c.2 0 .37-.07.5-.2.13-.14.2-.31.2-.52 0-.22-.07-.4-.2-.53s-.33-.2-.58-.2c-.22 0-.43.05-.63.15-.2.1-.45.32-.75.67-.23.25-.56.7-1.01 1.33a6.52 6.52 0 00-.91-2.15l-2.38.39-.05.25c.18-.03.33-.05.45-.05.24 0 .43.1.59.3.25.31.59 1.24 1.02 2.79-.34.44-.58.73-.7.87-.21.22-.38.36-.52.43-.1.05-.22.08-.35.08-.1 0-.26-.05-.49-.16a1.01 1.01 0 00-.42-.11c-.23 0-.42.07-.57.22-.17.14-.24.32-.24.55 0 .21.07.38.21.51.14.13.33.2.56.2.23 0 .44-.05.64-.14.2-.09.45-.29.75-.59s.72-.78 1.25-1.43c.2.62.38 1.07.53 1.35.15.28.32.49.52.61.19.12.44.19.73.19.28 0 .57-.1.86-.3.38-.25.77-.69 1.17-1.31l-.25-.14c-.27.37-.48.6-.61.69-.09.06-.19.09-.31.09-.14 0-.28-.09-.42-.26-.23-.29-.54-1.09-.93-2.4.37-.58.66-.96.9-1.14z"],pulse:["M19 10h-2.38L14.9 6.55h-.01c-.17-.32-.5-.55-.89-.55-.43 0-.79.28-.93.66h-.01l-2.75 7.57L7.98 1.82h-.02A.978.978 0 007 1c-.44 0-.8.29-.94.69h-.01L3.28 10H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.44 0 .8-.29.94-.69h.01l1.78-5.34 2.29 12.21h.02c.08.46.47.82.96.82.43 0 .79-.28.93-.66h.01l3.21-8.82.96 1.92h.01c.16.33.49.56.88.56h3c.55 0 1-.45 1-1s-.45-1-1-1z"],rain:["M4 10a3 3 0 111.065-5.806A5.001 5.001 0 0114.63 3.11 3.5 3.5 0 1115.5 10H4zm0 2a1 1 0 011 1v5a1 1 0 11-2 0v-5a1 1 0 011-1zm9 1a1 1 0 10-2 0v6a1 1 0 102 0v-6zm3-1a1 1 0 011 1v3a1 1 0 11-2 0v-3a1 1 0 011-1zm-7 1a1 1 0 10-2 0v3a1 1 0 102 0v-3z"],random:["M14.47 5h2.12L15.3 6.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 3H14c-.31 0-.57.15-.76.37l-.01-.01-2.93 3.52 1.3 1.56L14.47 5zm2.24 7.29a1.003 1.003 0 00-1.42 1.42l1.3 1.29h-2.12L4.77 3.36l-.01.01A.998.998 0 004 3H1c-.55 0-1 .45-1 1s.45 1 1 1h2.53l9.7 11.64.01-.01c.19.22.45.37.76.37h2.59l-1.29 1.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3zM3.53 15H1c-.55 0-1 .45-1 1s.45 1 1 1h3c.31 0 .57-.15.76-.37l.01.01 2.93-3.52-1.3-1.56L3.53 15z"],record:["M10 3a7 7 0 100 14 7 7 0 100-14z"],rectangle:["M1 4h18c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1zm1 2v8h16V6H2z"],redo:["M19.71 5.29l-4-4a1.003 1.003 0 00-1.42 1.42L16.59 5H6c-3.31 0-6 2.69-6 6s2.69 6 6 6h5v-2H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h10.59L14.3 9.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM15 14c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"],refresh:["M19 1c-.55 0-1 .45-1 1v2.06C16.18 1.61 13.29 0 10 0 4.48 0 0 4.48 0 10c0 .55.45 1 1 1s1-.45 1-1c0-4.42 3.58-8 8-8 2.52 0 4.76 1.18 6.22 3H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 8c-.55 0-1 .45-1 1 0 4.42-3.58 8-8 8-2.52 0-4.76-1.18-6.22-3H5c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1v-2.06C3.82 18.39 6.71 20 10 20c5.52 0 10-4.48 10-10 0-.55-.45-1-1-1z"],"regression-chart":["M19 16H3.1L19.31 3.39l-.61-.79L2 15.59V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm-9-9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm-5 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm10-2c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2zm-5 4c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2-2 .9-2 2z"],remove:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm5-9H5c-.55 0-1 .45-1 1s.45 1 1 1h10c.55 0 1-.45 1-1s-.45-1-1-1z"],"remove-column":["M19 0H5c-.55 0-1 .45-1 1v4h2V2h5v16H6v-3H4v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18h-5V2h5v16zM6.29 13.71a1.003 1.003 0 001.42-1.42L5.41 10 7.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L4 8.59l-2.29-2.3A1.003 1.003 0 00.29 7.71L2.59 10 .3 12.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L4 11.41l2.29 2.3z"],"remove-column-left":["M4 11h6c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-7 18H2V2h10v16zm6 0h-5V2h5v16z"],"remove-column-right":["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zM7 18H2V2h5v16zm11 0H8V2h10v16zm-8-7h6c.55 0 1-.45 1-1s-.45-1-1-1h-6c-.55 0-1 .45-1 1s.45 1 1 1z"],"remove-row-bottom":["M7 14h6c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zM19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V8h16v10zm0-11H2V2h16v5z"],"remove-row-top":["M7 8h6c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1zm12-8H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2v-5h16v5zm0-6H2V2h16v10z"],repeat:["M14 6c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1v2.05C16.18 1.6 13.29 0 10 0 4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10c0-.55-.45-1-1-1s-1 .45-1 1c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8c2.53 0 4.77 1.17 6.24 3H15c-.55 0-1 .45-1 1z"],reset:["M6 6c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V2c0-.55.45-1 1-1s1 .45 1 1v2.05C3.82 1.6 6.71 0 10 0c5.52 0 10 4.48 10 10s-4.48 10-10 10S0 15.52 0 10c0-.55.45-1 1-1s1 .45 1 1c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8C7.47 2 5.23 3.17 3.76 5H5c.55 0 1 .45 1 1z"],resolve:["M8.7 4.7C7.9 4.2 7 4 6 4c-3.3 0-6 2.7-6 6s2.7 6 6 6c1 0 1.9-.2 2.7-.7C7.3 14 6.5 12.1 6.5 10s.9-4 2.2-5.3zM14 4c-1 0-1.9.2-2.7.7 1.4 1.4 2.2 3.2 2.2 5.3s-.9 4-2.2 5.3c.8.5 1.7.7 2.7.7 3.3 0 6-2.7 6-6s-2.7-6-6-6zm-4 1.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],rig:["M7 4.2C7 5.75 8.34 7 10 7s3-1.46 3-2.8C13 1.45 10.94 0 10 0H6c0 2.74 3.76 1.96 1 4.2zm11.71 14.09L13 12.59V9.01c0-.55-.45-1-1-1H8c-.55 0-1 .45-1 1v3.58l-5.71 5.7a1.003 1.003 0 001.42 1.42L7 15.42V19c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-3.58l4.29 4.29a1.003 1.003 0 001.42-1.42zM10.21 8c.01 0 .01.01 0 0 .01.01.01 0 0 0z"],"right-join":["M8.7 4.7C7.4 6 6.5 7.9 6.5 10s.8 4 2.2 5.3c-.8.5-1.7.7-2.7.7-3.3 0-6-2.7-6-6s2.7-6 6-6c1 0 1.9.2 2.7.7zm-3.34 9.25c-.55-1.2-.86-2.54-.86-3.95s.31-2.75.86-3.95a4.001 4.001 0 000 7.9zM14 4c3.3 0 6 2.7 6 6s-2.7 6-6 6c-1 0-1.9-.2-2.7-.7 1.3-1.3 2.2-3.2 2.2-5.3s-.8-3.9-2.2-5.3C12.1 4.2 13 4 14 4zm-4 1.5C8.8 6.7 8 8.2 8 10s.8 3.3 2 4.4c1.2-1.1 2-2.7 2-4.5s-.8-3.3-2-4.4z"],ring:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"],rocket:["M7 7.5c0-3 1.857-6.25 3-7.5 1.143 1.25 3 4.5 3 7.5s-.714 6.25-1 7.5H8c-.286-1.25-1-4.5-1-7.5zm6.84 2.5c-.139 1.62-.47 3.405-.84 5.01l4 .99-1-4-2.16-2zm-4.832 6C9 16.139 9 16.284 9 16.429 9 17.143 9 17.5 10 20c1-2.5 1-2.857 1-3.571 0-.145 0-.29-.008-.429H9.008zM7 15.011c-.37-1.605-.701-3.39-.84-5.011L4 12l-1 4 4-.989zM10 5a1 1 0 100 2 1 1 0 000-2z"],"rocket-slant":["M10 5c2.121-2.121 6.308-2.924 8-3-.076 1.692-.879 5.879-3 8-1.192 1.192-2.543 1.823-3.748 2.384-.442.207-.865.404-1.252.616-.203.111-.597.302-.986.49-.444.215-.88.426-1.014.51l-2-2c.158-.252 1-2 1-2s1.37-3.37 3-5zm5 1a1 1 0 11-2 0 1 1 0 012 0zM3 17s0-2 2-4l2 2c-2 2-4 2-4 2zm11-2l-4 4-1.298-4.233c1.033-.56 1.881-.962 2.643-1.322 1.275-.604 2.307-1.092 3.554-2.015L14 15zM1 10l4-4 3.557-.899c-.923 1.247-1.412 2.28-2.015 3.554-.36.762-.762 1.61-1.322 2.643L1 10z"],"rotate-document":["M8.71 6.29A.997.997 0 008 6H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-8c0-.28-.11-.53-.29-.71l-4-4zM11 18H4V8h3v3c0 .55.45 1 1 1h3v6zm3-16h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C9.11 2.47 9 2.72 9 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4z"],"rotate-page":["M14 2h-1.59l.29-.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-2 2C9.11 2.47 9 2.72 9 3c0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42l-.3-.29H14c1.1 0 2 .9 2 2v3c0 .55.45 1 1 1s1-.45 1-1V6c0-2.21-1.79-4-4-4zm-2 5H3c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm-1 11H4V9h7v9z"],route:["M14.028 6.016c.146.275.31.57.485.872.304.524.628 1.047.952 1.545l.118.178-.208-.006-.577-.005c-2.093.004-2.841.303-2.841.895 0 .069.271.248 1.245.567l1.008.313c2.671.831 3.99 1.827 3.99 4.167 0 2.76-1.928 4.059-4.832 4.376-.782.085-1.52.098-2.452.066l-1.15-.046H6.221l.535-.811a67.46 67.46 0 001.122-1.787h2.04l.686.03c1.028.046 1.77.043 2.523-.039 1.832-.2 2.673-.767 2.673-1.789 0-.69-.483-1.09-1.992-1.585l-.83-.257c-1.192-.364-2.037-.7-2.59-1.165.399-1 .612-1.844.612-2.538a6.018 6.018 0 00-.382-2.098c.745-.573 1.884-.822 3.41-.883zM5 4.2c2.648 0 4.791 2.151 4.8 4.797C9.8 11.652 5 18.6 5 18.6l-.5-.744C3.273 15.993.2 11.121.2 8.997A4.802 4.802 0 015 4.2zm0 2.4a2.4 2.4 0 10.002 4.802A2.4 2.4 0 005 6.6zM17 .333a2.671 2.671 0 012.667 2.665C19.667 4.473 17 8.333 17 8.333l-.391-.587c-.741-1.137-2.276-3.629-2.276-4.748A2.668 2.668 0 0117 .333z"],satellite:["M9 18c.6 0 1 .4 1 1s-.4 1-1 1c-5 0-9-4-9-9 0-.6.4-1 1-1s1 .4 1 1c0 3.9 3.1 7 7 7zm0-4c.6 0 1 .4 1 1s-.4 1-1 1c-2.8 0-5-2.2-5-5 0-.6.4-1 1-1s1 .4 1 1c0 1.7 1.3 3 3 3zm5.7-3.7c.4-.4 1-.4 1.4 0l3.6 3.6c.4.4.4 1 0 1.4l-1.4 1.4c-.4.4-1 .4-1.4 0l-3.6-3.6c-.4-.4-.4-1 0-1.4l1.4-1.4zM4.7.3c.4-.4 1-.4 1.4 0l3.6 3.6c.4.4.4 1 0 1.4L8.3 6.7c-.4.4-1 .4-1.4 0L3.3 3.1c-.4-.4-.4-1 0-1.4L4.7.3zm11.1 1c.4-.4 1-.4 1.4 0l1.6 1.6c.4.4.4 1 0 1.4l-6.5 6.5c-.4.4-1 .4-1.4 0L9.3 9.2c-.4-.4-.4-1 0-1.4l6.5-6.5zM9 12c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z"],saved:["M12 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h13c.55 0 1-.45 1-1V6l-6-6zm4 18H5V2h6v5h5v11zm-8.29-6.71a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.32 0 .59-.16.77-.38l.01.01 4-5-.01-.01c.14-.18.23-.38.23-.62 0-.55-.45-1-1-1-.32 0-.59.16-.77.38l-.01-.01-3.3 4.13-2.21-2.21z"],"scatter-plot":["M9 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm5 2c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm1 10H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM5 15c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z"],search:["M19.56 17.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"search-around":["M9.9 6.9a3 3 0 100 6 3 3 0 100-6zM3 14c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM17 14c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM17 0c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3zm0 5c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM10 10L5 5","M5.379 4.671l5.02 5.02-.707.708-5.02-5.02zM10 10l5-5","M14.621 4.671l.707.708-5.02 5.02-.707-.707z","M10 10l5 5M10.379 9.671l5.02 5.02-.707.708-5.02-5.02z","M10 10l-5 5M9.621 9.671l.707.708-5.02 5.02-.707-.707z"],"search-template":["M13 8H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0 3H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm0-6H5c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1zm6.56 12.44l-3.23-3.23A8.939 8.939 0 0018 9a9 9 0 10-9 9c1.94 0 3.74-.62 5.21-1.67l3.23 3.23a1.498 1.498 0 102.12-2.12zM9 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"],"search-text":["M19.56 17.44l-3.23-3.23A8.939 8.939 0 0018 9a9 9 0 10-9 9c1.94 0 3.74-.62 5.21-1.67l3.23 3.23a1.498 1.498 0 102.12-2.12zM9 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7zm3.5-11h-7c-.28 0-.5.22-.5.5v2c0 .28.22.5.5.5s.5-.22.5-.5V7h2v6h-.5c-.28 0-.5.22-.5.5s.22.5.5.5h3c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H10V7h2v.5c0 .28.22.5.5.5s.5-.22.5-.5v-2c0-.28-.22-.5-.5-.5z"],"segmented-control":["M19 5H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-1 8h-8V7h8v6z"],select:["M19.71 18.29l-4.25-4.25L20 12.91 9.93 9.33c.04-.1.07-.21.07-.33V3c0-.55-.45-1-1-1H4V1c0-.55-.45-1-1-1S2 .45 2 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 .55.45 1 1 1h6c.12 0 .23-.03.34-.07L12.91 20l1.14-4.54 4.25 4.25c.17.18.42.29.7.29a1.003 1.003 0 00.71-1.71zM8 8H4V4h4v4z"],selection:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z","M10 6a4 4 0 100 8 4 4 0 100-8z"],"send-message":["M1.754.135L19.393 9.06c.57.288.775.943.458 1.462-.107.176-.266.32-.458.418l-17.64 8.925c-.57.288-1.288.1-1.604-.418C.05 19.287 0 19.183 0 19v-7l11-2L0 8V1.075C0 .481.529 0 1.18 0c.201 0 .399.047.574.135z"],"send-to":["M19 0h-5c-.6 0-1 .4-1 1s.4 1 1 1h2.6l-4.3 4.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3L18 3.4V6c0 .5.5 1 1 1s1-.5 1-1V1c0-.6-.5-1-1-1zm0 9c-1 0-1.9-.5-2.5-1.3l-1.4 1.4c-.5.6-1.3.9-2.1.9-1.7 0-3-1.3-3-3 0-.8.3-1.6.9-2.1l1.4-1.4C11.5 2.9 11 2 11 1c0-.3.1-.6.2-.9-.4-.1-.8-.1-1.2-.1C4.5 0 0 4.5 0 10s4.5 10 10 10 10-4.5 10-10c0-.4 0-.8-.1-1.2-.3.1-.6.2-.9.2z"],"send-to-graph":["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm10 2c-.53 0-1.01.21-1.37.55L11.9 10.6c.06-.19.1-.39.1-.6 0-.21-.04-.41-.1-.6l4.72-2.95c.37.34.85.55 1.38.55 1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2c0 .21.04.41.1.6l-4.73 2.96c-.24-.23-.54-.4-.87-.48V3.93c.86-.22 1.5-1 1.5-1.93 0-1.1-.9-2-2-2S8 .9 8 2c0 .93.64 1.71 1.5 1.93v4.14c-.33.09-.63.26-.87.48L7.6 7.91 5.42 6.55 3.9 5.6c.06-.19.1-.39.1-.6 0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2c.53 0 1.01-.21 1.37-.55L9 9.96V10h.06L12 11.84l.4.25 1.51.94 2.19 1.37c-.06.19-.1.39-.1.6 0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zm-7-2.96l-.06-.04H11v.04z"],"send-to-map":["M8 11H3c-.55 0-1 .45-1 1s.45 1 1 1h2.59L.3 18.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L7 14.41V17c0 .55.45 1 1 1s1-.45 1-1v-5c0-.55-.45-1-1-1zm11.54-6.82l.01-.02-6-4-.01.02C13.39.08 13.21 0 13 0s-.39.08-.54.18l-.01-.02L7 3.8 1.55.17l-.01.01A.969.969 0 001 0C.45 0 0 .45 0 1v9c0-.55.45-1 1-1h1V2.87l4 2.67V9h2V5.54l4-2.67v11.6l-1 .67v2.4l2-1.33 5.45 3.63.01-.02c.15.1.33.18.54.18.55 0 1-.45 1-1V5c0-.35-.19-.64-.46-.82zM18 17.13l-4-2.67V2.87l4 2.67v11.59z"],"series-add":["M13.29 9.29c.3.62.8 1.12 1.42 1.42l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 2.29-2.3zM12 5c0-.5.4-1 1-1h2V2c0-.6.4-1 1-1 .5 0 1 .4 1 1v2h2c.5 0 1 .4 1 1s-.5 1-1 1h-2v2c0 .6-.5 1-1 1-.6 0-1-.4-1-1V6h-2c-.6 0-1-.4-1-1z"],"series-configuration":["M11.91 10.67c.52.45 1.13.8 1.8 1.03l-2.01 2.01c-.18.18-.43.29-.71.29-.28 0-.53-.11-.71-.3L7 10.41l-5 5V17h16.99c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8c.28 0 .53.11.71.29l3.29 3.3.91-.92zM18.5 4.6h1.04c.25 0 .45.2.46.44v.9c0 .25-.2.45-.45.45h-1.04c-.07.22-.16.42-.27.62l.73.73c.17.17.17.44 0 .61l-.61.61c-.17.17-.44.17-.61 0l-.73-.73c-.2.11-.4.2-.62.26v1.05c0 .25-.2.45-.45.45h-.9c-.25 0-.45-.2-.45-.45V8.51c-.21-.06-.4-.15-.58-.25l-.76.77c-.17.17-.46.17-.64 0l-.64-.64a.465.465 0 010-.64l.76-.77c-.1-.19-.19-.38-.25-.59h-1.04c-.25 0-.45-.2-.45-.45v-.9c0-.25.2-.45.45-.45h1.04c.07-.22.16-.42.27-.61l-.73-.73a.429.429 0 010-.61l.61-.61c.17-.17.44-.17.61 0l.73.73c.2-.11.4-.2.62-.26V1.45a.44.44 0 01.44-.45h.9c.25 0 .45.2.45.45V2.5c.21.06.4.15.58.25l.76-.77c.17-.17.46-.17.64 0l.64.64c.17.17.17.46 0 .64l-.76.77c.1.17.19.36.25.57zm-4.69.9c0 .93.75 1.69 1.69 1.69.93 0 1.69-.75 1.69-1.69s-.75-1.69-1.69-1.69-1.69.76-1.69 1.69z"],"series-derived":["M18.82 6.58c-.03.05-.07.09-.11.13 0 0 0-.01-.01-.01l-2 2c-.2.2-.4.3-.7.3-.6 0-1-.4-1-1 0-.3.1-.5.3-.7L16.6 6H11c-.6 0-1-.4-1-1s.4-1 1-1h5.6l-1.3-1.3c-.2-.2-.3-.4-.3-.7 0-.6.4-1 1-1 .3 0 .5.1.7.3l3 3c.2.2.3.4.3.7s-.1.5-.3.7l-.88.88zm-5.53 2.71c.3.62.8 1.12 1.42 1.42l-3 3c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 2.29-2.3z"],"series-filtered":["M12.14 10.45c.21.67.65 1.23 1.22 1.61l-1.65 1.65c-.18.18-.43.29-.71.29s-.53-.11-.71-.3L7 10.41l-5 5V17h17c.55 0 1 .45 1 1s-.45 1-1 1H1a.998.998 0 01-1-1V4c0-.55.45-1 1-1s1 .45 1 1v8.59l4.29-4.3C6.47 8.11 6.72 8 7 8s.53.11.71.29l3.29 3.3 1.14-1.14zM19.35 1a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V5.13L11.19 2.1a.642.642 0 01.45-1.1h7.71z"],"series-search":["M11.28 11.31l-.28.28-3.29-3.3C7.53 8.11 7.28 8 7 8s-.53.11-.71.29L2 12.59V4c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1H2v-1.59l5-5 3.29 3.29c.18.19.43.3.71.3s.53-.11.71-.29l2.09-2.09c-.17.02-.34.02-.51.02-.7 0-1.38-.12-2.01-.33zm-.93-6c0-1.62 1.31-2.93 2.93-2.93s2.93 1.31 2.93 2.93-1.31 2.93-2.93 2.93-2.93-1.31-2.93-2.93zm6.47 2.43c.11-.17.21-.33.29-.51.01-.03.03-.06.04-.09.08-.18.16-.35.21-.54.06-.2.1-.38.14-.58.01-.05.01-.09.02-.14.03-.2.05-.39.05-.6 0-2.37-1.93-4.3-4.3-4.3-2.37.01-4.3 1.93-4.3 4.31s1.93 4.3 4.3 4.3c.21 0 .4-.02.6-.05.04 0 .09-.01.14-.02.2-.03.38-.08.57-.14.2-.06.37-.14.55-.21.03-.01.06-.03.09-.04.18-.09.34-.19.51-.29l2.87 2.87c.14.14.33.22.56.22.43 0 .78-.35.78-.78a.938.938 0 00-.23-.56l-2.89-2.85z"],settings:["M4 1c0-.55-.45-1-1-1S2 .45 2 1v5h2V1zM2 19c0 .55.45 1 1 1s1-.45 1-1v-6H2v6zm9-18c0-.55-.45-1-1-1S9 .45 9 1v8h2V1zm7 0c0-.55-.45-1-1-1s-1 .45-1 1v3h2V1zM9 19c0 .55.45 1 1 1s1-.45 1-1v-3H9v3zm9-14h-2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-2 14c0 .55.45 1 1 1s1-.45 1-1v-8h-2v8zM4 7H2c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm7 3H9c-.55 0-1 .45-1 1v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-3c0-.55-.45-1-1-1z"],shapes:["M7.88 11.12a.958.958 0 011.277.33l3.719 6.207c.081.136.124.29.124.447 0 .495-.419.896-.936.896H4.936a.969.969 0 01-.436-.103.878.878 0 01-.392-1.21l3.409-6.208a.915.915 0 01.362-.36zM15 5a4 4 0 110 8 4 4 0 010-8zM8 1a1 1 0 011 1v6a1 1 0 01-1 1H2a1 1 0 01-1-1V2a1 1 0 011-1h6z"],share:["M15 18H2V5h8.76l2-2H1c-.55 0-1 .45-1 1v15c0 .55.45 1 1 1h15c.55 0 1-.45 1-1V7.24l-2 2V18zm4-18h-7c-.55 0-1 .45-1 1s.45 1 1 1h4.59l-7.3 7.29a1.003 1.003 0 001.42 1.42L18 3.41V8c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1z"],"shared-filter":["M13.917 17.209c1.01.454 2.543.928 2.873 1.643.31.722.186 1.148.186 1.148H6.026s-.13-.426.186-1.148 1.842-1.203 2.86-1.65c1.017-.447.914-.722.948-1.093 0-.048.007-.097.007-.145a3.067 3.067 0 01-.839-1.237l-.007-.007c0-.007-.006-.014-.006-.02a1.757 1.757 0 01-.11-.337c-.234-.042-.372-.296-.426-.537a1.045 1.045 0 01-.138-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478a2.508 2.508 0 01.962-1.623c.426-.33 1.038-.501 1.58-.501.544 0 1.155.172 1.588.502a2.496 2.496 0 01.963 1.622c.075.413.117 1.045.117 1.478v.062c.15.062.288.22.323.564.02.268-.083.502-.138.598-.048.234-.185.488-.42.537a2.635 2.635 0 01-.116.364 3.094 3.094 0 01-.818 1.224c0 .055 0 .11.007.158.034.378-.103.653.914 1.1z","M14.976 16.57c-.24-.099-.455-.186-.65-.273l-.007-.004a3.801 3.801 0 01-.194-.091c.224-.288.41-.609.554-.946l.001-.002.013-.033c.018-.043.036-.087.052-.13l.011-.027.016-.04c.105-.092.19-.19.256-.284.129-.184.213-.38.265-.563.105-.226.225-.592.192-1.026l-.001-.011-.002-.011a1.854 1.854 0 00-.325-.91 9.924 9.924 0 00-.12-1.246 3.09 3.09 0 00-.106-.475l-.001-.006a3.543 3.543 0 00-.763-1.353c.27-.092.56-.139.83-.139.495 0 1.05.156 1.444.456a2.269 2.269 0 01.875 1.475c.069.375.106.95.106 1.344v.056c.138.056.263.2.294.513.019.244-.075.456-.125.543-.044.213-.169.444-.381.488-.025.1-.056.206-.094.3a2.815 2.815 0 01-.756 1.144c0 .05 0 .1.006.144.004.043.006.086.007.127.01.283.018.518.824.872.192.087.404.173.623.263.83.34 1.752.717 1.99 1.231.28.657.168 1.044.168 1.044h-2.081a3.864 3.864 0 00-.188-.542l-.005-.013-.006-.012c-.183-.397-.491-.681-.76-.88a5.614 5.614 0 00-.896-.522 17.36 17.36 0 00-.916-.4l-.15-.061zM14 1c.55 0 1 .45 1 1 0 .28-.11.53-.29.7L10 7.41v.897a3.182 3.182 0 00-.69.4 3.508 3.508 0 00-1.343 2.259c-.07.37-.107.836-.122 1.237a1.836 1.836 0 00-.339.926c-.046.458.09.84.195 1.06.053.178.138.376.27.56.055.08.125.162.21.242v.143l.053.052L6.71 16.71A1.003 1.003 0 015 16V7.41L.29 2.71A1.003 1.003 0 011 1h13z","M9.059 14.361c-.23-.044-.366-.296-.42-.535a1.045 1.045 0 01-.138-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478A2.508 2.508 0 0110 9.441V13c0 .28-.11.53-.29.71l-.651.651z"],shield:["M10 20c6-3.81 9-9.048 9-15.714-2 0-5-1.429-9-4.286-4 2.857-7 4.286-9 4.286C1 10.952 4 16.19 10 20zm0-17.348c2.577 1.734 4.776 2.88 6.667 3.419-.44 4.627-2.636 8.353-6.667 11.297V2.652z"],ship:["M6.84.804L6.5 2.5h-3a1 1 0 00-1 1v4.893l-1.58.451a.99.99 0 00-.691 1.192c.46 1.82 1.163 4.356 1.701 5.571-.218.012-.445.018-.68.018a.625.625 0 100 1.25c2.583 0 4.268-.68 5.202-1.146.687.466 1.88 1.146 3.548 1.146 1.65 0 2.837-.666 3.528-1.132l.005.003c.244.131.6.3 1.07.468.938.335 2.321.661 4.147.661a.625.625 0 100-1.25c-.323 0-.63-.011-.922-.031a.996.996 0 00.184-.334l1.67-5.168a1 1 0 00-.677-1.27l-1.505-.43V3.5a1 1 0 00-1-1h-3L13.16.804A1 1 0 0012.18 0H7.82a1 1 0 00-.98.804zM5 7.679l3.75-1.072V5H5v2.679zm6.25-1.072L15 7.68V5h-3.75v1.607zM6.205 16.95a.625.625 0 01.658.042c.569.407 1.597 1.134 3.137 1.134s2.568-.727 3.137-1.134a.625.625 0 01.724-.001l.007.005.045.029c.044.027.114.069.21.12.194.104.493.247.9.392.811.29 2.053.589 3.727.589a.625.625 0 110 1.25c-1.826 0-3.21-.326-4.148-.661a7.894 7.894 0 01-1.069-.468l-.005-.003c-.691.466-1.878 1.132-3.528 1.132-1.667 0-2.861-.68-3.548-1.146-.934.467-2.619 1.146-5.202 1.146a.625.625 0 110-1.25c2.66 0 4.23-.787 4.955-1.176z"],shop:["M17.94 3.63c-.01-.02-.01-.03-.02-.04l-.03-.09h-.01c-.18-.3-.49-.5-.86-.5h-14c-.42 0-.77.25-.92.61L0 8.5h.02a2.5 2.5 0 005 0 2.5 2.5 0 005 0 2.5 2.5 0 005 0 2.5 2.5 0 005 0l-2.08-4.87zM3.02 2h14c.55 0 1-.45 1-1s-.45-1-1-1h-14c-.55 0-1 .45-1 1s.44 1 1 1zm13 14h-12v-4h-2v7c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-7h-2v4z"],"shopping-cart":["M18 14H8.72l-.67-2H17c.44 0 .8-.29.94-.69h.01l2-6h-.01c.03-.1.06-.2.06-.31 0-.55-.45-1-1-1H5.39l-.44-1.32h-.01C4.8 2.29 4.44 2 4 2H1c-.55 0-1 .45-1 1s.45 1 1 1h2.28l3.33 10H5c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2h9c0 1.1.9 2 2 2s2-.9 2-2-.9-2-2-2zM6.05 6h11.56l-1.33 4H7.39L6.05 6z"],"signal-search":["M7.15 10.33c.888.8 1.999 1.36 3.228 1.574l2.326 6.98a.846.846 0 01-.535 1.07.844.844 0 01-1.072-.535l-1.225-3.671H7.125L5.9 19.419a.85.85 0 01-1.072.536.85.85 0 01-.536-1.071l2.857-8.555zm1.353 1.305l-.808 2.413h1.607l-.8-2.413zM5 5.5c0 .76.13 1.49.37 2.17-.496 1.056-.313 2.356.704 3.29.385.353.404.94.038 1.311a.982.982 0 01-1.356.038c-2.183-2.01-2-5.125.01-6.94a.95.95 0 01.24-.156A6.421 6.421 0 005 5.5z","M3.874 13.185c-1.346-.918-2.187-2.67-2.187-4.34 0-1.752.757-3.254 2.187-4.339.42-.25.42-.834.168-1.168-.252-.418-.84-.418-1.177-.167C1.014 4.59-.08 6.509.005 8.846c.084 2.253 1.177 4.423 2.86 5.675.168.083.336.166.504.166.253 0 .505-.083.673-.333.337-.418.253-.918-.168-1.169zM12.246 12.309a.98.98 0 01-1.354-.037.917.917 0 01-.206-.324 6.54 6.54 0 001.959-.049 5.125 5.125 0 01-.399.41zM14.631 11.476l1.228 1.229a6.6 6.6 0 01-1.723 1.816c-.169.083-.337.166-.505.166-.253 0-.505-.083-.673-.333-.337-.418-.253-.918.168-1.169.62-.422 1.133-1.022 1.505-1.709z","M11.5 0C14.54 0 17 2.46 17 5.5c0 .26-.02.51-.06.75l-.03.17c-.04.25-.1.49-.17.73v.01c-.08.24-.17.47-.28.69-.01.04-.03.07-.05.11-.11.23-.24.44-.38.65l3.68 3.68A1.003 1.003 0 0119 14c-.28 0-.53-.11-.7-.29l-3.68-3.68c-.21.14-.42.27-.65.38-.04.01-.07.03-.11.05-.22.11-.45.2-.69.28h-.01c-.24.07-.48.13-.73.17l-.17.03c-.25.04-.5.06-.76.06C8.46 11 6 8.54 6 5.5S8.46 0 11.5 0zm0 1.5c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4z"],"sim-card":["M16.71 5.29l-5-5A.997.997 0 0011 0H4c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V6c0-.28-.11-.53-.29-.71zM9 7h2v3H9V7zM6 7h2v3H6V7zm2 11H6v-3h2v3zm3 0H9v-3h2v3zm3 0h-2v-3h2v3zm0-4H6v-3h8v3zm0-4h-2V7h2v3z"],slash:["M12 2c-.46 0-.85.32-.97.74L7.04 16.7c-.02.1-.04.2-.04.3 0 .55.45 1 1 1 .46 0 .85-.32.97-.74L12.96 3.3c.02-.1.04-.2.04-.3 0-.55-.45-1-1-1z"],"small-cross":["M11.41 10l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L8.59 10 5.3 13.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3.29-3.3 3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z"],"small-minus":["M14 9H6c-.55 0-1 .45-1 1s.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-plus":["M14 9h-3V6c0-.55-.45-1-1-1s-1 .45-1 1v3H6c-.55 0-1 .45-1 1s.45 1 1 1h3v3c0 .55.45 1 1 1s1-.45 1-1v-3h3c.55 0 1-.45 1-1s-.45-1-1-1z"],"small-square":["M5 5v10h10V5H5zM4 3a1 1 0 00-1 1v12a1 1 0 001 1h12a1 1 0 001-1V4a1 1 0 00-1-1H4z"],"small-tick":["M15 5c-.28 0-.53.11-.71.29L8 11.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29s.53-.11.71-.29l7-7A1.003 1.003 0 0015 5z"],snowflake:["M11 11.776v2.81l2.31 2.242a.987.987 0 010 1.415c-.399.39-1.044.39-1.442 0L11 17.414V19a.99.99 0 01-.996 1A.996.996 0 019 19v-1.636l-.912.879c-.398.39-1.043.39-1.441 0a.987.987 0 010-1.415L9 14.536v-2.79l-2.548 1.435-.837 3.063c-.146.534-.705.85-1.248.707a.998.998 0 01-.721-1.224l.309-1.132-1.4.793a1.03 1.03 0 01-1.393-.366.99.99 0 01.373-1.366l1.445-.818-1.224-.322a.998.998 0 01-.72-1.225c.145-.533.704-.85 1.248-.707l3.193.84 2.462-1.395-2.532-1.434-3.123.82a1.022 1.022 0 01-1.249-.706.998.998 0 01.721-1.225L2.91 7.18l-1.4-.793a.99.99 0 01-.373-1.366 1.03 1.03 0 011.392-.366l1.445.818-.328-1.2a.998.998 0 01.72-1.225 1.022 1.022 0 011.25.707l.855 3.132L9 8.311V5.414L6.647 3.121a.987.987 0 010-1.414 1.033 1.033 0 011.441 0L9 2.586V1c0-.552.44-1 1.004-1A.99.99 0 0111 1l-.007 1.536.875-.829a1.033 1.033 0 011.441 0 .987.987 0 010 1.414L11 5.364v2.918l2.53-1.42.855-3.131c.146-.534.705-.85 1.249-.707a.998.998 0 01.72 1.224l-.327 1.2 1.4-.792a1.03 1.03 0 011.392.366.99.99 0 01-.373 1.366l-1.355.768 1.153.303a.998.998 0 01.721 1.225c-.146.533-.705.85-1.249.707l-3.123-.821-2.576 1.459 2.506 1.42 3.193-.84a1.022 1.022 0 011.249.707.998.998 0 01-.72 1.225l-1.224.322 1.4.793a.99.99 0 01.373 1.366 1.03 1.03 0 01-1.393.366l-1.356-.768.31 1.132a.998.998 0 01-.721 1.224 1.022 1.022 0 01-1.249-.707l-.837-3.063L11 11.776z"],"social-media":["M11.5 5c.8 0 1.6-.4 2-1 2 1.2 3.3 3.3 3.5 5.7 0 .5.5.9 1 .9.6 0 1-.5 1-1v-.1c-.2-3.3-2.2-6.2-5.1-7.6C13.7.8 12.7 0 11.5 0 10.1 0 9 1.1 9 2.5S10.1 5 11.5 5zm5 7c-1.4 0-2.5 1.1-2.5 2.5 0 .4.1.7.2 1.1-1.1.9-2.6 1.4-4.2 1.4-1.9 0-3.6-.8-4.9-2-.2-.2-.5-.4-.8-.4-.5 0-1 .5-1 1 0 .3.1.5.3.7C5.3 18 7.5 19 10 19c2.2 0 4.2-.8 5.8-2.1.2.1.5.1.7.1 1.4 0 2.5-1.1 2.5-2.5S17.9 12 16.5 12zM5 10.5c0-1.1-.7-2.1-1.7-2.4.5-1.9 1.9-3.5 3.6-4.4.3-.2.6-.5.6-.9 0-.5-.4-1-1-1-.2 0-.4.1-.6.2-2.4 1.2-4.2 3.6-4.7 6.4C.5 8.9 0 9.6 0 10.5 0 11.9 1.1 13 2.5 13S5 11.9 5 10.5z"],sort:["M19 16h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm0-5h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM7 15c-.28 0-.53.11-.71.29L5 16.59V11c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 15.3A.965.965 0 001 15a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 15zM19 1h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1zm0 5h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V7c0-.55-.45-1-1-1z"],"sort-alphabetical":["M8 15c-.28 0-.53.11-.71.29L6 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L2.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 008 15zm8.89-.79v-1.22H11.3v1.3h3.51L11 18.78V20h5.99v-1.3h-3.91l3.81-4.49zM14.97 0h-1.95L9.01 11.01h1.89l.98-2.92h4.17l.98 2.92h1.96L14.97 0zm-2.59 6.63l1.58-4.74H14l1.57 4.74h-3.19z"],"sort-alphabetical-desc":["M8.01 15c-.28 0-.53.11-.71.29L6 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L2.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3a1.014 1.014 0 001.42 0l3-3c.18-.18.29-.43.29-.71.01-.55-.44-1-.99-1zm4.44-5.65l6.4-7.88V0H10.5v1.67h5.91L10 9.44v1.57h9V9.35h-6.55zm1.27 3.64L11 20h1.59l.56-1.56h2.68l.55 1.56h1.64l-2.68-7.01h-1.62zm-.16 4.3l.93-2.57h.02l.9 2.57h-1.85z"],"sort-asc":["M10 8h5c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1h-5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0 5h7c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm0-10h3c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1h-3c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm9 12h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zM7 14c-.28 0-.53.11-.71.29L5 15.59V10c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 14.3A.965.965 0 001 14a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 14z"],"sort-desc":["M13 15h-3c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm-6-1c-.28 0-.53.11-.71.29L5 15.59V10c0-.55-.45-1-1-1s-1 .45-1 1v5.59L1.71 14.3A.965.965 0 001 14a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 007 14zM19 0h-9c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h9c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-4 10h-5c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-1c0-.55-.45-1-1-1zm2-5h-7c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1h7c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],"sort-numerical":["M9 14.99c-.28 0-.53.11-.71.29L7 16.58v-5.59c0-.55-.45-1-1-1s-1 .45-1 1v5.59l-1.29-1.29a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-3c.18-.18.29-.43.29-.71a.99.99 0 00-1-1zm8.88.23c-.08-.42-.22-.79-.42-1.12-.2-.33-.47-.6-.8-.8-.33-.2-.76-.3-1.28-.3a2.333 2.333 0 00-1.72.71c-.21.22-.37.48-.49.78-.11.3-.17.62-.17.97 0 .27.04.54.13.8.08.26.22.5.4.7.19.21.43.38.71.5a2.142 2.142 0 001.72.02c.25-.12.47-.31.66-.58l.02.02c-.01.19-.04.4-.08.63-.04.24-.11.46-.21.67-.1.21-.23.38-.39.53a.92.92 0 01-.62.22c-.24 0-.44-.08-.6-.25-.16-.17-.27-.36-.31-.59h-1.31c.04.29.12.56.24.79.12.23.28.43.48.59.19.16.42.28.67.36.25.08.52.12.82.12.49 0 .9-.1 1.23-.31.34-.21.61-.48.82-.82.21-.34.37-.71.47-1.13.1-.42.15-.83.15-1.25 0-.43-.04-.85-.12-1.26zm-1.42.63c-.05.15-.11.28-.2.4-.09.12-.2.21-.34.27s-.3.1-.49.1c-.17 0-.33-.04-.46-.11s-.24-.17-.33-.29c-.08-.12-.15-.25-.19-.4-.04-.15-.06-.31-.06-.47 0-.15.02-.3.07-.45.05-.15.11-.28.2-.39.09-.12.2-.21.33-.28.13-.07.27-.11.44-.11.17 0 .33.04.47.11.14.07.25.17.34.28a1.387 1.387 0 01.28.86c.01.17-.02.33-.06.48zM15.32 11H17V0h-1.25c-.05.34-.17.62-.34.85-.17.23-.39.42-.63.57-.25.15-.52.25-.83.31-.3.06-.62.09-.94.09v1.41h2.31V11z"],"sort-numerical-desc":["M9 15c-.28 0-.53.11-.71.29L7 16.59v-5.58c0-.55-.45-1-1-1s-1 .45-1 1v5.58L3.71 15.3c-.18-.18-.43-.3-.71-.3a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l3-3A1.003 1.003 0 009 15zm6.7-1.33a1.5 1.5 0 01-.44.43c-.17.11-.37.19-.58.23-.22.04-.44.06-.67.05v1.07h1.66V20H17v-6.99h-1.06c-.04.26-.12.48-.24.66zm3.15-10.3c-.11-.68-.29-1.26-.55-1.76-.26-.5-.62-.89-1.08-1.18C16.75.14 16.17 0 15.46 0c-.54 0-1.03.09-1.46.27-.43.18-.79.44-1.09.76-.3.33-.52.71-.67 1.15-.16.44-.24.92-.24 1.43 0 .54.08 1.04.23 1.47.15.44.37.81.65 1.12.28.31.61.55 1 .72.39.17.82.26 1.3.26.46 0 .88-.11 1.26-.33.38-.22.68-.53.9-.94l.03.03c-.03.35-.07.74-.12 1.16-.05.42-.15.81-.29 1.18-.14.37-.35.68-.61.92-.26.25-.62.37-1.06.37-.43 0-.77-.13-1.03-.4-.25-.27-.4-.62-.44-1.05h-1.64c.02.43.11.83.29 1.18.17.35.39.66.67.91a3.027 3.027 0 002.07.8c.71 0 1.3-.17 1.79-.5.48-.33.87-.76 1.17-1.29.3-.53.51-1.12.64-1.76.13-.64.19-1.28.19-1.92.01-.77-.05-1.49-.15-2.17zM17.1 4.44c-.08.27-.19.5-.34.71-.15.21-.34.37-.57.49-.23.12-.5.18-.8.18-.3 0-.56-.06-.78-.19-.22-.13-.4-.29-.55-.49-.14-.2-.25-.44-.32-.7-.07-.27-.11-.55-.11-.84 0-.28.04-.55.11-.82.07-.26.18-.49.32-.7.14-.2.33-.36.55-.48.22-.12.48-.17.78-.17.31 0 .57.06.8.18.23.12.42.28.57.48.15.2.26.43.34.69.08.26.11.53.11.82 0 .29-.04.57-.11.84z"],"split-columns":["M15 13a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-3-3a1.003 1.003 0 00-1.42 1.42L16.59 9H11V2h5v2c.77 0 1.47.3 2 .78V1c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v3.78C2.53 4.3 3.23 4 4 4V2h5v7H3.41L4.7 7.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-3 3C.11 9.47 0 9.72 0 10c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L3.41 11H9v7H4v-2c-.77 0-1.47-.3-2-.78V19c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-3.78c-.53.48-1.23.78-2 .78v2h-5v-7h5.59l-1.29 1.29c-.19.18-.3.43-.3.71z"],square:["M19 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H2V2h16v16z"],"stacked-chart":["M12 2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v4h4V2zm3 14h2c.55 0 1-.45 1-1v-5h-4v5c0 .55.45 1 1 1zm3-10c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v3h4V6zm-6 1H8v5h4V7zm-9 9h2c.55 0 1-.45 1-1v-3H2v3c0 .55.45 1 1 1zm16 1H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM6 9c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v2h4V9zm3 7h2c.55 0 1-.45 1-1v-2H8v2c0 .55.45 1 1 1z"],"stadium-geometry":["M15 7H5a3 3 0 000 6h10a3 3 0 100-6zM5 5a5 5 0 000 10h10a5 5 0 000-10H5z"],star:["M10 0l3.1 6.6 6.9 1-5 5.1 1.2 7.3-6.2-3.4L3.8 20 5 12.7 0 7.6l6.9-1z"],"star-empty":["M20 7.6l-6.9-1.1L10 0 6.9 6.6 0 7.6l5 5.1L3.8 20l6.2-3.4 6.2 3.4-1.2-7.2 5-5.2zM10 15l-4.5 2.4.9-5.2-3.6-3.6 5-.8L10 3.1l2.2 4.7 5 .8-3.6 3.7.9 5.2L10 15z"],"step-backward":["M15 3c-.23 0-.42.09-.59.21l-.01-.01L8 8V4c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-4l6.4 4.8.01-.01c.17.12.36.21.59.21.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"step-chart":["M19 16H2v-3h4c.55 0 1-.45 1-1V8h3v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V6h2c.55 0 1-.45 1-1s-.45-1-1-1h-3c-.55 0-1 .45-1 1v4h-3V7c0-.55-.45-1-1-1H6c-.55 0-1 .45-1 1v4H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],"step-forward":["M15 3h-2c-.55 0-1 .45-1 1v4L5.6 3.2l-.01.01C5.42 3.09 5.23 3 5 3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1 .23 0 .42-.09.59-.21l.01.01L12 12v4c0 .55.45 1 1 1h2c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stop:["M16 3H4c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],stopwatch:["M10 6a6 6 0 106 6h-6V6zm-.998-1.938A1.015 1.015 0 019 4V2H7a1 1 0 110-2h6a1 1 0 010 2h-2v2c0 .02 0 .041-.002.062A8.001 8.001 0 0110 20a8 8 0 01-.998-15.938z"],strikethrough:["M18 9h-4.46a4.7 4.7 0 00-.4-.14c-.19-.05-.51-.14-.96-.25-.45-.11-.9-.23-1.37-.35-.47-.12-.89-.23-1.27-.33s-.6-.16-.65-.17c-.53-.15-.95-.37-1.27-.66-.32-.28-.49-.68-.49-1.19 0-.36.09-.66.26-.9s.39-.43.65-.57c.26-.14.55-.24.87-.3s.63-.09.93-.09c.89 0 1.63.19 2.21.57.45.3.75.76.89 1.38h2.63c-.06-.52-.2-.98-.42-1.4-.3-.57-.71-1.05-1.23-1.43a5.33 5.33 0 00-1.79-.87c-.7-.2-1.42-.3-2.19-.3-.66 0-1.31.08-1.96.25s-1.22.43-1.73.77-.92.79-1.23 1.32c-.31.52-.46 1.15-.46 1.87 0 .37.05.74.15 1.1.1.36.28.7.53 1.02.18.24.41.47.69.67H2c-.55 0-1 .45-1 1s.45 1 1 1h10.14c.02.01.05.02.07.02.3.11.58.29.84.55.25.26.38.67.38 1.21 0 .27-.06.53-.17.79-.11.26-.29.49-.54.69-.25.2-.57.36-.97.49s-.88.19-1.44.19c-.52 0-1.01-.06-1.45-.17-.45-.11-.84-.29-1.19-.54s-.61-.56-.8-.95c-.05-.08-.09-.18-.12-.28H4.11c.09.43.22.82.4 1.18.33.65.77 1.18 1.32 1.59.55.41 1.2.72 1.94.92.74.2 1.53.3 2.37.3.73 0 1.44-.08 2.14-.25.7-.17 1.33-.43 1.88-.79.55-.36.99-.83 1.33-1.39.34-.56.51-1.25.51-2.05 0-.37-.06-.75-.18-1.12a3.12 3.12 0 00-.15-.39H18c.55 0 1-.45 1-1s-.45-1-1-1z"],style:["M18 18H2V2h12.3l2-2H1C.4 0 0 .4 0 1v18c0 .6.4 1 1 1h18c.6 0 1-.4 1-1V7.7l-2 2V18zm1.2-18l-7.6 7.6 2.8 2.8L20 4.8V0h-.8zM4 15.9c3.1.2 5.9.2 8.2-2 1.1-1.1 1.1-3 0-4.1-.6-.5-1.3-.8-2-.8s-1.4.3-1.9.8C7.2 11 6.6 14.3 4 15.9z"],"swap-horizontal":["M16.02 10c-.01 0-.01 0 0 0H16h.02zM2 6h13.58l-2.29 2.29a1 1 0 00-.3.71 1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-4-4a1.003 1.003 0 00-1.42 1.42L15.58 4H2c-.55 0-1 .45-1 1s.45 1 1 1zm2 4h-.02H4zm14 4H4.42l2.29-2.29a1 1 0 00.3-.71 1.003 1.003 0 00-1.71-.71l-4 4c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L4.42 16H18c.55 0 1-.45 1-1s-.45-1-1-1z"],"swap-vertical":["M9.71 5.3l-4-4A.997.997 0 005 1.01c-.28 0-.53.11-.71.29l-4 4a1.003 1.003 0 001.42 1.42L4 4.42V18c0 .55.45 1 1 1s1-.45 1-1V4.42l2.29 2.29a1 1 0 00.71.3 1.003 1.003 0 00.71-1.71zM10 3.98c0 .01 0 .01 0 0V4v-.02zm0 12.04c0-.01 0-.01 0 0V16v.02zm9-3.03c-.28 0-.53.11-.71.29L16 15.58V2c0-.55-.45-1-1-1s-1 .45-1 1v13.58l-2.29-2.29a1.003 1.003 0 00-1.42 1.42l4 4c.18.18.43.29.71.29.28 0 .53-.11.71-.29l4-4c.18-.18.29-.43.29-.71 0-.56-.45-1.01-1-1.01z"],switch:["M12.293 2.293l1.414 1.414-7.127 7.129a3.5 3.5 0 11-1.415-1.415l7.128-7.128zM16.5 9a3.5 3.5 0 110 7 3.5 3.5 0 010-7zm-13 2a1.5 1.5 0 100 3 1.5 1.5 0 000-3zm13 0a1.5 1.5 0 100 3 1.5 1.5 0 000-3z"],"symbol-circle":["M10 4.01a6 6 0 100 12 6 6 0 100-12z"],"symbol-cross":["M15 8.01h-3v-3c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v3H5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h3v3c0 .55.45 1 1 1h2c.55 0 1-.45 1-1v-3h3c.55 0 1-.45 1-1v-2c0-.56-.45-1-1-1z"],"symbol-diamond":["M15 10.01c0-.21-.08-.39-.18-.54l.02-.01-4-6-.02.01c-.18-.28-.47-.46-.82-.46s-.64.18-.82.45l-.01-.01-4 6 .02.01c-.11.16-.19.34-.19.55s.08.39.18.54l-.02.01 4 6 .02-.01c.18.27.47.46.82.46s.64-.19.82-.46l.02.01 4-6-.02-.01c.1-.16.18-.34.18-.54z"],"symbol-rectangle":["M16 5H4c-.5 0-1 .5-1 1v8c0 .5.5 1 1 1h12c.5 0 1-.5 1-1V6c0-.5-.5-1-1-1z"],"symbol-square":["M15 4.01H5c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h10c.55 0 1-.45 1-1v-10c0-.56-.45-1-1-1z"],"symbol-triangle-down":["M16 5c0-.55-.45-1-1-1H5c-.55 0-1 .45-1 1 0 .16.05.31.11.44H4.1l5 10h.01c.17.33.5.56.89.56s.72-.23.89-.56h.01l5-10h-.01c.06-.13.11-.28.11-.44z"],"symbol-triangle-up":["M15.89 14.56l-4.99-10h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56H9.1l-5 10h.01c-.06.13-.11.28-.11.44 0 .55.45 1 1 1h10c.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44z"],syringe:["M15.146.854a.5.5 0 01.708-.708l4 4a.5.5 0 01-.708.708l-.646-.647L17.207 5.5l1.647 1.646a.5.5 0 01-.708.708l-.646-.647-1.146 1.146-7.5 7.5a.5.5 0 01-.708 0l-.646-.646-2.646 2.647a.5.5 0 01-.708 0l-.646-.647-2.646 2.647a.5.5 0 01-.708-.708L2.793 16.5l-.647-.646a.5.5 0 010-.708L4.793 12.5l-.647-.646a.5.5 0 010-.708l7.5-7.5L12.794 2.5l-.647-.646a.5.5 0 01.708-.708L14.5 2.793 15.793 1.5l-.647-.646zM12.707 4l.793-.793L16.793 6.5 16 7.293 12.707 4zm2.586 4l-.793.793-1.646-1.647a.5.5 0 00-.708.708L13.793 9.5 12.5 10.793l-1.646-1.647a.5.5 0 00-.708.708l1.647 1.646-1.293 1.293-1.646-1.647a.5.5 0 00-.708.708L9.793 13.5 8.5 14.793 5.207 11.5 12 4.707 15.293 8zM3.207 15.5L5.5 13.207 6.793 14.5 4.5 16.793 3.207 15.5zM16.5 2.207L17.793 3.5 16.5 4.793 15.207 3.5 16.5 2.207z"],tag:["M2 4a2 2 0 012-2h4.588a2 2 0 011.414.586l7.41 7.41a2 2 0 010 2.828l-4.588 4.588a2 2 0 01-2.829 0l-7.41-7.41A2 2 0 012 8.588V4zm3.489-.006a1.495 1.495 0 100 2.99 1.495 1.495 0 000-2.99z"],"take-action":["M5 7c.28 0 .53-.11.71-.29l5-5A1.003 1.003 0 009.29.29l-5 5A1.003 1.003 0 005 7zm6 6a1.003 1.003 0 001.71.71l5-5a1.003 1.003 0 00-1.42-1.42l-5 5c-.18.18-.29.43-.29.71zm8 5h-1c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1H8c-.55 0-1 .45-1 1s.45 1 1 1h11c.55 0 1-.45 1-1s-.45-1-1-1zm-9-6l6-6-1.29-1.29a1.003 1.003 0 00-1.42-1.42L12 2 6 8l1.29 1.29-7 7a1.003 1.003 0 001.42 1.42l7-7L10 12z"],tank:["M3.956 4.47A1 1 0 014.804 4h6.392a1 1 0 01.848.47L13 6h5a1 1 0 010 2h-5v1h4a3 3 0 110 6H3a3 3 0 010-6V6.287a1 1 0 01.152-.53l.804-1.287zM3 11h14a1 1 0 110 2H3a1 1 0 110-2z"],target:["M9 5a1 1 0 012 0v3a1 1 0 01-2 0V5zM12 9a1 1 0 000 2h3a1 1 0 000-2h-3zM4 10a1 1 0 011-1h3a1 1 0 010 2H5a1 1 0 01-1-1zM10 11a1 1 0 00-1 1v3a1 1 0 002 0v-3a1 1 0 00-1-1z","M10 20c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10zm0-2a8 8 0 100-16 8 8 0 000 16z"],taxi:["M19 9h-.33l.33 1v.5c0 .15-.03.3-.07.44h.01L17 17.23v.27c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5V17H6v.5c0 .83-.67 1.5-1.5 1.5S3 18.33 3 17.5v-.27l-1.93-6.28h.01c-.05-.15-.08-.3-.08-.45V10s.02-.06.05-.16c.06-.17.16-.47.28-.84H1c-.55 0-1-.45-1-1s.45-1 1-1h1l1-3h-.01v-.01c.25-.64 1-1.31 1.67-1.5 0 0 .78-.21 2.33-.36V1c0-.55.45-1 1-1h4c.55 0 1 .45 1 1v1.13c1.55.14 2.33.36 2.33.36.67.19 1.42.86 1.67 1.5V4H17l1 3h1c.55 0 1 .45 1 1s-.45 1-1 1zM3 11.5c0 .83.67 1.5 1.5 1.5S6 12.33 6 11.5 5.33 10 4.5 10 3 10.67 3 11.5zM16 7l-1-3H5L4 7v1h12V7zm-.5 3c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],temperature:["M11 0a2 2 0 00-2 2v10.535a4 4 0 104 0V2a2 2 0 00-2-2zM3 2.5a.5.5 0 01.5-.5h4a.5.5 0 010 1h-4a.5.5 0 01-.5-.5zM3.5 8a.5.5 0 000 1h4a.5.5 0 000-1h-4zM5 5.5a.5.5 0 01.5-.5h2a.5.5 0 010 1h-2a.5.5 0 01-.5-.5zm.5 5.5a.5.5 0 000 1h2a.5.5 0 000-1h-2z"],"text-highlight":["M16 17c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1s1-.45 1-1-.45-1-1-1c-.77 0-1.47.3-2 .78-.53-.48-1.23-.78-2-.78-.55 0-1 .45-1 1s.45 1 1 1 1 .45 1 1v12c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1c.77 0 1.47-.3 2-.78.53.48 1.23.78 2 .78.55 0 1-.45 1-1s-.45-1-1-1zm-4-4H2V7h10V5H1c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h11v-2zm7-8h-3v2h2v6h-2v2h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z"],th:["M19 1H1c-.6 0-1 .5-1 1v16c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V2c0-.5-.5-1-1-1zM7 17H2v-3h5v3zm0-4H2v-3h5v3zm0-4H2V6h5v3zm11 8H8v-3h10v3zm0-4H8v-3h10v3zm0-4H8V6h10v3z"],"th-derived":["M5.3 13.3c-.2.2-.3.4-.3.7 0 .6.4 1 1 1 .3 0 .5-.1.7-.3l3-3c.2-.2.3-.4.3-.7s-.1-.5-.3-.7l-3-3C6.5 7.1 6.3 7 6 7c-.6 0-1 .4-1 1 0 .3.1.5.3.7L6.6 10H1c-.6 0-1 .4-1 1s.4 1 1 1h5.6l-1.3 1.3zM19 1H3c-.5 0-1 .5-1 1v6h1c0-1.7 1.3-3 3-3 .8 0 1.6.3 2.1.9l.1.1H9v.8l1 1V6h8v3h-6.8c.3.3.5.6.6 1H18v3h-6.8l-.1.1-.9.9H18v3h-8v-2.8l-1 1V17H4v-.8c-.6-.5-1-1.3-1-2.2H2v4c0 .5.5 1 1 1h16c.6 0 1-.5 1-1V2c0-.5-.5-1-1-1z"],"th-disconnect":["M14.25 1H19c.5 0 1 .5 1 1v16c0 .5-.5 1-1 1h-7.221l.278-2H18v-3h-5.527l.14-1H18v-3h-4.971l.139-1H18V6h-4.416l.637-4.587c.02-.139.03-.277.03-.413zM8.221 1l-.694 5H2v3h5.11l-.139 1H2v3h4.555l-.14 1H2v3h3.999l-.22 1.587c-.02.139-.03.277-.03.413H1c-.6 0-1-.5-1-1V2c0-.5.4-1 1-1h7.221zM10.26.862a1 1 0 011.98.276l-2.5 18a1 1 0 01-1.98-.276l2.5-18z"],"th-filtered":["M17.333 10l1.435-1.722a1 1 0 00.232-.64V4.85l1-.9V18c0 .5-.5 1-1 1H1c-.6 0-1-.5-1-1V2c0-.5.4-1 1-1h6.722L12 4.85V6H8v3h4v1H8v3h10v-3h-.667zM7 17v-3H2v3h5zm0-4v-3H2v3h5zm0-4V6H2v3h5zm11 8v-3H8v3h10z","M19.35 0a.642.642 0 01.46 1.1l-3.03 3.03v2.95c0 .18-.07.34-.19.46l-1.28 1.29c-.11.1-.27.17-.45.17-.35 0-.64-.29-.64-.64V4.13L11.19 1.1a.642.642 0 01.45-1.1h7.71z"],"th-list":["M19 1H1c-.6 0-1 .5-1 1v16c0 .5.4 1 1 1h18c.5 0 1-.5 1-1V2c0-.5-.5-1-1-1zm-1 16H2v-3h16v3zm0-4H2v-3h16v3zm0-4H2V6h16v3z"],"third-party":["M8 0C3.58 0 0 3.58 0 8a8 8 0 005.856 7.71c.064-.057.129-.109.19-.156.278-.209.595-.383.896-.53.358-.174.81-.358 1.193-.515.206-.084.393-.16.534-.223a3.93 3.93 0 00.203-.095 4.1 4.1 0 01-.305-.45C8.382 13.911 8.19 14 8 14c-.67 0-1.36-1.1-1.73-3h1.252c.047-.296.153-.571.323-.797l.01-.203H6.12C6.05 9.39 6 8.73 6 8s.05-1.39.12-2h3.76l.037.344c.315-.145.65-.242.979-.295L10.89 6h2.76c.027.077.052.155.076.233l.118-.04A3.62 3.62 0 0114.998 6c.247 0 .51.028.772.086A8 8 0 008 0zm5.17 5h-2.44c-.21-1.11-.51-2.03-.91-2.69 1.43.46 2.61 1.43 3.35 2.69zM8 2c.67 0 1.36 1.1 1.73 3H6.27C6.64 3.1 7.33 2 8 2zm-1.82.31c-.4.66-.71 1.58-.91 2.69H2.83a6.025 6.025 0 013.35-2.69zM2 8c0-.7.13-1.37.35-2h2.76C5.04 6.62 5 7.28 5 8s.04 1.38.11 2H2.35C2.13 9.37 2 8.7 2 8zm.83 3h2.44c.21 1.11.51 2.03.91 2.69A6.025 6.025 0 012.83 11z","M13.917 15.209c.21.094.444.19.685.288.912.374 1.927.789 2.188 1.355.31.722.186 1.148.186 1.148H6.026s-.13-.426.186-1.148c.256-.584 1.305-1.011 2.234-1.39.22-.088.432-.175.626-.26.909-.4.923-.662.94-.978.002-.037.004-.076.008-.115l.003-.072c.002-.025.004-.049.004-.073a3.067 3.067 0 01-.839-1.237l-.007-.007a.024.024 0 00-.003-.01 1.757 1.757 0 01-.113-.347c-.234-.042-.372-.296-.427-.537a1.045 1.045 0 01-.137-.598c.034-.35.179-.509.337-.57v-.056c0-.44.034-1.065.117-1.478a2.508 2.508 0 01.962-1.623c.426-.33 1.038-.501 1.58-.501.544 0 1.155.172 1.588.502a2.496 2.496 0 01.963 1.622c.075.413.117 1.045.117 1.478v.062c.15.062.288.22.323.564.02.268-.083.502-.138.598-.048.234-.185.488-.42.537a2.635 2.635 0 01-.116.364 3.094 3.094 0 01-.818 1.224c0 .055 0 .11.007.158.004.048.006.095.007.14.011.311.02.57.907.96z","M14.976 14.57c-.24-.098-.455-.186-.65-.274l-.007-.003a3.801 3.801 0 01-.194-.091c.224-.288.41-.609.554-.946l.001-.002.013-.033c.018-.043.036-.087.052-.13l.011-.027.016-.04c.105-.092.19-.19.256-.284.129-.184.213-.38.265-.563.105-.226.225-.592.192-1.026l-.001-.011-.002-.011a1.855 1.855 0 00-.325-.91 9.924 9.924 0 00-.12-1.246 3.088 3.088 0 00-.106-.474l-.001-.007a3.543 3.543 0 00-.763-1.353c.27-.092.56-.139.83-.139.495 0 1.05.156 1.444.456a2.269 2.269 0 01.875 1.475c.069.375.106.95.106 1.344v.056c.138.056.263.2.294.513.019.244-.075.456-.125.543-.044.213-.169.444-.381.488-.025.1-.056.206-.094.3a2.815 2.815 0 01-.756 1.144c0 .05 0 .1.006.144.004.043.006.086.007.127.01.283.018.518.824.873.192.086.404.172.623.262.83.34 1.752.717 1.99 1.231.28.657.168 1.044.168 1.044h-2.081a3.864 3.864 0 00-.188-.542l-.005-.013-.006-.012c-.183-.397-.491-.681-.76-.88a5.614 5.614 0 00-.896-.522 17.36 17.36 0 00-.916-.4l-.15-.061z"],"thumbs-down":["M18.55 6.56c-.31-.01-.65-.03-1.02-.06.03 0 .06-.01.09-.01.88-.12 1.68-.63 1.76-1.37.08-.75-.58-1.25-1.46-1.33-.32-.03-.65-.05-.99-.08.59-.19 1.05-.54 1.09-1.2.05-.75-.99-1.32-1.87-1.41-.34-.03-.64-.05-.91-.07h-.11c-.28-.02-.54-.02-.77-.02-3.92-.08-7.29.6-9.36 1.93v7.72c2.67 1.66 5.95 4.61 5.26 7.08-.21.76.39 1.35 1.23 1.26 1.01-.11 1.71-1.18 1.75-2.28.05-1.29-.19-2.59-.62-3.74-.05-.32.01-.65.47-.68.61-.04 1.39-.08 1.99-.1.32 0 .64-.01.94-.03h.01c.52-.03 1-.07 1.42-.12.88-.11 1.69-.6 1.79-1.35.1-.75-.55-1.25-1.44-1.35-.07-.01-.13-.02-.2-.02.21-.02.42-.04.61-.06.88-.11 1.69-.6 1.79-1.35.09-.75-.56-1.31-1.45-1.36zM3 3H0v8h3c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"thumbs-up":["M3 9H0v8h3c.55 0 1-.45 1-1v-6c0-.55-.45-1-1-1zm16.99 3.09c-.1-.75-.91-1.24-1.79-1.35-.19-.02-.4-.05-.61-.06.07-.01.14-.01.2-.02.88-.1 1.53-.61 1.44-1.35-.1-.74-.91-1.24-1.79-1.35-.42-.05-.9-.09-1.42-.12h-.01l-.94-.03c-.6-.02-1.39-.05-1.99-.1-.45-.03-.51-.36-.47-.68.43-1.15.67-2.45.62-3.74-.04-1.11-.74-2.17-1.75-2.28-.84-.09-1.45.5-1.23 1.26.7 2.47-2.58 5.43-5.25 7.08v7.72c2.08 1.33 5.44 2.01 9.35 1.93.24 0 .49-.01.77-.02h.11c.27-.02.57-.04.91-.07.88-.08 1.92-.66 1.87-1.41-.04-.65-.5-1.01-1.09-1.2.34-.03.67-.05.99-.08.89-.08 1.55-.58 1.46-1.33-.08-.75-.88-1.25-1.76-1.37-.03 0-.06-.01-.09-.01.37-.02.71-.04 1.02-.06.91-.05 1.55-.61 1.45-1.36z"],tick:["M17 4c-.28 0-.53.11-.71.29L7 13.59 3.71 10.3A.965.965 0 003 10a1.003 1.003 0 00-.71 1.71l4 4c.18.18.43.29.71.29s.53-.11.71-.29l10-10A1.003 1.003 0 0017 4z"],"tick-circle":["M10 20C4.48 20 0 15.52 0 10S4.48 0 10 0s10 4.48 10 10-4.48 10-10 10zm5-14c-.28 0-.53.11-.71.29L8 12.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l7-7A1.003 1.003 0 0015 6z"],time:["M11 9.59V4c0-.55-.45-1-1-1s-1 .45-1 1v6c0 .28.11.53.29.71l3 3a1.003 1.003 0 001.42-1.42L11 9.59zM10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"],"timeline-area-chart":["M19 16H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zm0-13.41l-7.07 7.07-4.3-3.44-.01.01A.987.987 0 007 6c-.24 0-.46.1-.63.24l-.01-.01L3 9.03V15h16V2.59z"],"timeline-bar-chart":["M19 17H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM9 16h2c.55 0 1-.45 1-1V2c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v13c0 .55.45 1 1 1zm6 0h2c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1zM3 16h2c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1z"],"timeline-events":["M5 5c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm10 0c.6 0 1-.4 1-1V2c0-.5-.4-1-1-1s-1 .5-1 1v2c0 .6.4 1 1 1zm-9 9H4v2h2v-2zM17 3v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H7v1c0 1.1-.9 2-2 2s-2-.9-2-2V3H2c-.5 0-1 .5-1 1v14c0 .5.5 1 1 1h16c.5 0 1-.5 1-1V4c0-.5-.5-1-1-1h-1zM7 17H3v-4h4v4zm0-5H3V8h4v4zm5 5H8v-4h4v4zm0-5H8V8h4v4zm5 5h-4v-4h4v4zm0-5h-4V8h4v4zm-6 2H9v2h2v-2zm5-5h-2v2h2V9z"],"timeline-line-chart":["M19 16H2v-1.59l5-5 3.29 3.29c.18.19.43.3.71.3s.53-.11.71-.29l7-7a1.003 1.003 0 00-1.42-1.42L11 10.59l-3.29-3.3C7.53 7.11 7.28 7 7 7s-.53.11-.71.29L2 11.59V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],tint:["M9.86 2S3.98 9.18 3.98 12.17C3.99 15.4 6.78 18 9.96 18c3.18-.01 6.04-2.63 6.03-5.86C15.99 9.05 9.86 2 9.86 2z"],torch:["M6.97 19c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-2h-6v2zm-3-15l3 4v8h6V8l3-4h-12zm5 5c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1s-1-.45-1-1V9zm6-9h-10c-.55 0-1 .45-1 1v2h12V1c0-.55-.45-1-1-1z"],tractor:["M4.5 11a4.5 4.5 0 110 9 4.5 4.5 0 010-9zm11.499 1a4 4 0 110 8 4 4 0 010-8zm-11.5 1.571a1.928 1.928 0 100 3.857 1.928 1.928 0 000-3.857zM16 14.667a1.333 1.333 0 100 2.666 1.333 1.333 0 000-2.666zM5.999 0C7.46 0 8.527.668 9 2l.851 4.256c1.433.096 2.82.217 4.147.362V2h2L16 6.862c.962.13 1.886.275 2.767.435.779.141 1.232.614 1.232 1.284L20 13a4.995 4.995 0 00-4-1.997A5.001 5.001 0 0011.099 15h-1.12a5.499 5.499 0 00-5.478-4.994 5.482 5.482 0 00-3.377 1.157H.004v-1.18L0 7.327c-.002-.597.37-1.18.999-1.302V1a1 1 0 011-1h4zm1 2H3v4h.75c1.386.027 2.749.073 4.079.139L6.999 2z"],train:["M16 18h-2l2 2H4l.12-.12L6 18H4c-1.1 0-2-.9-2-2V2c0-1.1 3.58-2 8-2s8 .9 8 2v14c0 1.1-.9 2-2 2zM5.5 15c.83 0 1.5-.67 1.5-1.5S6.33 12 5.5 12 4 12.67 4 13.5 4.67 15 5.5 15zM9 3H4v6h5V3zm7 0h-5v6h5V3zm-1.5 9c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"],translate:["M19.89 18.56l-4.99-10h-.01c-.17-.33-.5-.56-.89-.56s-.72.23-.89.56h-.01l-1.73 3.46-2.8-2.3 1.99-1.64C11.44 7.34 12 6.23 12 5V4h1c.55 0 1-.45 1-1s-.45-1-1-1H8V1c0-.55-.45-1-1-1S6 .45 6 1v1H1c-.55 0-1 .45-1 1s.45 1 1 1h9v1c0 .62-.28 1.18-.73 1.54L7 8.42 4.73 6.54C4.28 6.18 4 5.62 4 5H2c0 1.23.56 2.34 1.44 3.07l1.99 1.64-3.06 2.52.01.01c-.23.18-.38.45-.38.76 0 .55.45 1 1 1 .24 0 .45-.1.63-.24l.01.01L7 11l3.36 2.77.01-.01c.02.02.05.03.08.05.01 0 .01.01.02.02l-2.36 4.73h.01c-.07.13-.12.28-.12.44 0 .55.45 1 1 1 .39 0 .72-.23.89-.56h.01L11.12 17h5.76l1.22 2.45h.01c.17.32.5.55.89.55.55 0 1-.45 1-1 0-.16-.05-.31-.11-.44zM12.12 15L14 11.24 15.88 15h-3.76z"],trash:["M17 1h-5c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1H3c-.55 0-1 .45-1 1v1h16V2c0-.55-.45-1-1-1zm.5 3h-15c-.28 0-.5.22-.5.5s.22.5.5.5H3v14c0 .55.45 1 1 1h12c.55 0 1-.45 1-1V5h.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5zM7 16c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8zm4 0c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8zm4 0c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v8z"],tree:["M11 15.542V20H9v-4.458L2 17l4.5-5.625L4 12l3.655-5.483L6 7l4-7 4 7-1.655-.483L16 12l-2.5-.625L18 17l-7-1.458z"],"trending-down":["M19 10c-.55 0-1 .45-1 1v1.37l-6.25-7.03-.01.01A.971.971 0 0011 5c-.23 0-.42.09-.59.21l-.01-.01-3.43 2.58-5.42-3.61-.01.01A.969.969 0 001 4c-.55 0-1 .45-1 1 0 .35.19.64.46.82l-.01.01 6 4 .01-.02c.15.11.33.19.54.19.23 0 .42-.09.59-.21l.01.01 3.26-2.45L16.77 14H15c-.55 0-1 .45-1 1s.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1z"],"trending-up":["M19 4h-4c-.55 0-1 .45-1 1s.45 1 1 1h1.77l-5.91 6.65L7.6 10.2l-.01.01C7.42 10.09 7.23 10 7 10c-.21 0-.39.08-.54.18l-.01-.02-6 4 .01.02c-.27.18-.46.47-.46.82 0 .55.45 1 1 1 .21 0 .39-.08.54-.18l.01.02 5.41-3.61 3.43 2.58.01-.01c.18.11.37.2.6.2.3 0 .56-.14.74-.34l.01.01L18 7.63V9c0 .55.45 1 1 1s1-.45 1-1V5c0-.55-.45-1-1-1z"],truck:["M16 0a1 1 0 011 1v11a1 1 0 011 1v3h.5a.5.5 0 01.5.5v1a.5.5 0 01-.5.5H17v1a1 1 0 01-1 1h-1a1 1 0 01-1-1v-1H6v1a1 1 0 01-1 1H4a1 1 0 01-1-1v-1H1.5a.5.5 0 01-.5-.5v-1a.5.5 0 01.5-.5H2v-3a1 1 0 011-1V1a1 1 0 112 0v3a2 2 0 012-2h6a2 2 0 012 2V1a1 1 0 011-1zm-4 10H8a1 1 0 00-1 1v4a1 1 0 001 1h4a1 1 0 001-1v-4a1 1 0 00-1-1zm-7 4H4a1 1 0 000 2h1a1 1 0 000-2zm11 0h-1a1 1 0 000 2h1a1 1 0 000-2zm-4.5 0a.5.5 0 110 1h-3l-.09-.008A.5.5 0 018.5 14zm0-1.5a.5.5 0 110 1h-3l-.09-.008a.5.5 0 01.09-.992zm0-1.5a.5.5 0 110 1h-3l-.09-.008A.5.5 0 018.5 11zM14 5H6v3h8V5z"],"two-columns":["M5 0H1C.45 0 0 .45 0 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm14.71 9.29l-3-3A1.003 1.003 0 0015 7v6a1.003 1.003 0 001.71.71l3-3c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71zM12 0H8c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h4c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],unarchive:["M16.434 0a1 1 0 01.857.486L20 5v14a1 1 0 01-1 1H1a1 1 0 01-1-1V5L2.709.486A1 1 0 013.566 0h12.868zM10 8c-.28 0-.53.11-.71.29l-3 3-.084.096A1.003 1.003 0 007.71 12.71L9 11.41v4.58l.007.116c.058.496.482.884.993.884.55 0 1-.45 1-1v-4.58l1.29 1.29.081.073c.171.139.389.227.629.227a1.003 1.003 0 00.71-1.71l-3-3-.096-.084A1.002 1.002 0 0010 8zm6-6H4L2 5.002h16L16 2z"],underline:["M10 17c3.3 0 6-2.7 6-6V3.5c0-.8-.7-1.5-1.5-1.5S13 2.7 13 3.5V11c0 1.7-1.3 3-3 3s-3-1.3-3-3V3.5C7 2.7 6.3 2 5.5 2S4 2.7 4 3.5V11c0 3.3 2.7 6 6 6zM16.5 19h-13c-.3 0-.5.2-.5.5s.2.5.5.5h13c.3 0 .5-.2.5-.5s-.2-.5-.5-.5z"],undo:["M5 14c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm9-9H3.41L5.7 2.71c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C.11 5.47 0 5.72 0 6c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L3.41 7H14c2.21 0 4 1.79 4 4s-1.79 4-4 4H9v2h5c3.31 0 6-2.69 6-6s-2.69-6-6-6z"],"ungroup-objects":["M4.5 6C2.01 6 0 8.01 0 10.5S2.01 15 4.5 15 9 12.99 9 10.5 6.99 6 4.5 6zm11 0C13.01 6 11 8.01 11 10.5s2.01 4.5 4.5 4.5 4.5-2.01 4.5-4.5S17.99 6 15.5 6z"],"unknown-vehicle":["M13 11.988v-4H4v-1l1-3h6V2.003a35.867 35.867 0 00-1-.015c-3.593 0-5.332.488-5.332.488-.67.188-1.424.864-1.674 1.503l-.004.009H3l-1 3H1a1 1 0 100 2h.333l-.28.84-.053.16v7.5a1.5 1.5 0 103 0v-.5h12v.5a1.5 1.5 0 103 0v-4.5h-5a1 1 0 01-1-1zm-8.5 1a1.5 1.5 0 110-3 1.5 1.5 0 010 3zM19.83 2.782a2.392 2.392 0 00-.592-.853c-.276-.264-.64-.485-1.09-.663C17.695 1.09 17.132 1 16.457 1c-.523 0-.996.084-1.418.253a3.157 3.157 0 00-1.084.703c-.299.3-.532.656-.698 1.065-.166.41-.254.861-.264 1.353h2.096c0-.246.028-.476.085-.69.057-.214.145-.4.264-.56.119-.16.27-.287.456-.383.185-.095.406-.143.663-.143.38 0 .677.1.89.3.215.2.321.51.321.93.01.245-.035.45-.135.614-.1.164-.23.314-.392.45a8.598 8.598 0 01-.527.41 3.53 3.53 0 00-.542.485c-.171.187-.32.412-.45.676-.127.265-.206.592-.234.984v.614h1.924v-.519c.038-.273.13-.5.278-.683.147-.182.316-.343.506-.484a13.5 13.5 0 01.606-.424c.214-.14.408-.312.584-.512s.323-.442.442-.724.178-.642.178-1.079c0-.264-.059-.548-.178-.854zm-4.54 6.099v2.103h2.237V8.881H15.29z"],unlock:["M14 1c-2.21 0-4 1.79-4 4v4H2c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-2V5c0-1.1.9-2 2-2s2 .9 2 2v2c0 .55.45 1 1 1s1-.45 1-1V5c0-2.21-1.79-4-4-4z"],unpin:["M11.77 1.16c-.81.81-.74 2.28.02 3.76L6.1 8.71c-2.17-1.46-4.12-2-4.94-1.18l4.95 4.95-2.12 3.54 3.54-2.12 4.95 4.95c.82-.82.27-2.77-1.19-4.94l3.8-5.69c1.47.76 2.94.84 3.76.02l-7.08-7.08z"],unresolve:["M11.47 12.46c.16-.36.29-.74.38-1.14 0-.02.01-.04.01-.06.09-.4.14-.82.14-1.26 0-.44-.05-.86-.14-1.27 0-.02-.01-.04-.01-.06-.09-.4-.22-.78-.38-1.14-.01-.02-.02-.03-.02-.05a5.94 5.94 0 00-.61-1.03c0-.01-.01-.01-.01-.02a6.308 6.308 0 00-2.1-1.77c-.19-.1-.39-.18-.59-.26-.03-.01-.06-.02-.1-.03-.17-.07-.34-.12-.52-.17-.05-.01-.1-.03-.15-.04a4.34 4.34 0 00-.52-.09c-.05-.01-.11-.02-.17-.03C6.46 4.02 6.23 4 6 4c-3.31 0-6 2.69-6 6s2.69 6 6 6c.23 0 .46-.02.68-.04l.17-.03c.17-.02.34-.06.51-.09.05-.01.1-.03.15-.04.18-.05.36-.1.53-.17l.09-.03a5.973 5.973 0 002.68-2.04c0-.01.01-.01.01-.02.24-.32.44-.66.61-1.03.02-.01.03-.03.04-.05zM14 4c-.99 0-1.91.24-2.73.66a7.51 7.51 0 010 10.68c.82.42 1.74.66 2.73.66 3.31 0 6-2.69 6-6s-2.69-6-6-6z"],updated:["M10 0C6.71 0 3.82 1.6 2 4.05V2c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1s-.45-1-1-1H3.76C5.22 3.17 7.47 2 10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8c0-.55-.45-1-1-1s-1 .45-1 1c0 5.52 4.48 10 10 10s10-4.48 10-10S15.52 0 10 0zm4 7c-.28 0-.53.11-.71.29L9 11.58 6.71 9.29a1.003 1.003 0 00-1.42 1.42l3 3c.18.18.43.29.71.29.28 0 .53-.11.71-.29l5-5A1.003 1.003 0 0014 7z"],upload:["M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0zm4 10c-.28 0-.53-.11-.71-.29L11 7.41V15c0 .55-.45 1-1 1s-1-.45-1-1V7.41l-2.29 2.3a1.003 1.003 0 01-1.42-1.42l4-4c.18-.18.43-.29.71-.29s.53.11.71.29l4 4A1.003 1.003 0 0114 10z"],user:["M10 0C4.48 0 0 4.48 0 10c0 .33.02.65.05.97.01.12.03.23.05.35.03.2.05.4.09.59.03.14.06.28.1.42l.12.48c.05.16.1.31.15.46.05.13.09.27.15.4.06.16.13.32.21.48.05.11.1.22.16.33.09.17.17.34.27.5.05.09.1.17.15.25.11.18.22.35.34.52.04.06.08.11.12.17 1.19 1.62 2.85 2.86 4.78 3.53l.09.03c.46.15.93.27 1.42.36.08.01.17.03.25.04.49.07.99.12 1.5.12s1.01-.05 1.5-.12c.08-.01.17-.02.25-.04.49-.09.96-.21 1.42-.36l.09-.03c1.93-.67 3.59-1.91 4.78-3.53.04-.05.08-.1.12-.16.12-.17.23-.35.34-.53.05-.08.1-.16.15-.25.1-.17.19-.34.27-.51.05-.11.1-.21.15-.32.07-.16.14-.32.21-.49.05-.13.1-.26.14-.39.05-.15.11-.31.15-.46.05-.16.08-.32.12-.48.03-.14.07-.28.1-.42.04-.19.06-.39.09-.59.02-.12.04-.23.05-.35.05-.32.07-.64.07-.97 0-5.52-4.48-10-10-10zm0 18a7.94 7.94 0 01-6.15-2.89c.84-.44 1.86-.82 2.67-1.19 1.45-.65 1.3-1.05 1.35-1.59.01-.07.01-.14.01-.21-.51-.45-.93-1.08-1.2-1.8l-.01-.01c0-.01-.01-.02-.01-.03a4.42 4.42 0 01-.15-.48c-.33-.07-.53-.44-.61-.79-.08-.14-.23-.48-.2-.87.05-.51.26-.74.49-.83v-.08c0-.63.06-1.55.17-2.15.02-.17.06-.33.11-.5.21-.73.66-1.4 1.26-1.86.62-.47 1.5-.72 2.28-.72.78 0 1.65.25 2.27.73.6.46 1.05 1.12 1.26 1.86.05.16.08.33.11.5.11.6.17 1.51.17 2.15v.09c.22.1.42.33.46.82.04.39-.12.73-.2.87-.07.34-.27.71-.6.78-.04.16-.09.33-.15.48 0 .01-.02.05-.02.05-.26.71-.67 1.33-1.17 1.78 0 .08.01.16.01.23.05.54-.15.94 1.31 1.59.81.36 1.84.74 2.68 1.19A7.958 7.958 0 0110 18z"],variable:["M4.93 3.79a9.1 9.1 0 012.2-2.27L7.29 1c-1.38.59-2.57 1.33-3.55 2.22C2.46 4.39 1.49 5.72.83 7.23.28 8.51 0 9.81 0 11.12c0 2.28.83 4.57 2.49 6.86l.16-.55c-.49-1.23-.73-2.38-.73-3.44 0-1.67.28-3.46.84-5.36.55-1.9 1.28-3.51 2.17-4.84zm9.38 8.39l-.33-.2c-.37.54-.65.87-.82 1a.74.74 0 01-.42.12c-.19 0-.38-.12-.57-.37-.31-.42-.73-1.59-1.26-3.5.47-.85.86-1.41 1.19-1.67.23-.19.48-.29.74-.29.1 0 .28.04.53.11.26.07.48.11.68.11.27 0 .5-.1.68-.29.18-.19.27-.44.27-.75 0-.33-.09-.58-.27-.77-.18-.19-.44-.29-.78-.29-.3 0-.59.07-.86.22s-.61.47-1.02.97c-.31.37-.77 1.02-1.37 1.94a9.683 9.683 0 00-1.24-3.14l-3.24.59-.06.36c.24-.05.44-.07.61-.07.32 0 .59.14.8.43.33.45.8 1.8 1.39 4.07-.47.64-.78 1.06-.96 1.26-.28.32-.52.53-.7.62-.14.08-.3.11-.48.11-.14 0-.36-.08-.67-.23-.21-.1-.4-.15-.57-.15-.31 0-.57.11-.78.32s-.31.48-.31.8c0 .31.09.55.28.75.19.19.44.29.76.29.31 0 .6-.07.87-.2s.61-.42 1.02-.86c.41-.44.98-1.13 1.7-2.08.28.9.52 1.56.72 1.97.2.41.44.71.7.89.26.18.59.27.99.27.38 0 .77-.14 1.17-.43.54-.36 1.07-1 1.61-1.91zM17.51 1l-.15.54c.49 1.24.73 2.39.73 3.45 0 1.43-.21 2.96-.63 4.6-.33 1.26-.75 2.45-1.27 3.55-.52 1.11-1.02 1.97-1.51 2.6-.49.62-1.09 1.2-1.8 1.72l-.17.53c1.38-.59 2.57-1.34 3.55-2.23 1.29-1.17 2.26-2.5 2.91-4 .55-1.28.83-2.59.83-3.91 0-2.27-.83-4.56-2.49-6.85z"],"vertical-bar-chart-asc":["M8 7H7c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zM3 9H2c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1zm10-5h-1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm5-4h-1c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1z"],"vertical-bar-chart-desc":["M3 0H2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm5 4H7c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm5 3h-1c-.55 0-1 .45-1 1v11c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1zm5 2h-1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1z"],"vertical-distribution":["M1 2h18c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1s.45 1 1 1zm2 5c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V8c0-.55-.45-1-1-1H3zm16 11H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],video:["M19 2H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM7 14V6l6 4-6 4z"],virus:["M15.249 13.835l1.251 1.251.354-.354.087-.077a1 1 0 011.327 1.491l-2.122 2.122-.087.077a1 1 0 01-1.327-1.491l.354-.354-1.251-1.251A6.466 6.466 0 0111 16.424L10.999 18h.501a1 1 0 01.117 1.993L11.5 20h-3a1 1 0 01-.117-1.993L8.5 18h.499v-1.577a6.46 6.46 0 01-2.538-.97L5.414 16.5l.354.354a1 1 0 01-1.327 1.491l-.087-.077-2.122-2.122a1 1 0 011.327-1.491l.087.077.354.354.97-.97a6.472 6.472 0 01-1.384-3.057l-.025.002L2 11.06v.44a1 1 0 01-1.993.117L0 11.5v-3a1 1 0 011.993-.117L2 8.5v.56h1.567A6.471 6.471 0 014.97 5.883l-.971-.969-.353.354-.087.077a1 1 0 01-1.327-1.491l2.122-2.122.087-.077a1 1 0 011.327 1.491l-.354.353 1.047 1.048A6.46 6.46 0 019 3.577L9 2h-.5A1 1 0 018.383.007L8.5 0h3a1 1 0 01.117 1.993L11.5 2H11v1.577a6.466 6.466 0 012.838 1.176l.04-.046L15.086 3.5l-.353-.353a1 1 0 011.327-1.491l.087.077 2.122 2.122a1 1 0 01-1.327 1.491l-.087-.077-.354-.354-1.207 1.207-.046.041a6.467 6.467 0 011.16 2.733H18V8.5a1 1 0 011.993-.117L20 8.5v3a1 1 0 01-1.993.117L18 11.5v-.605h-1.561a6.466 6.466 0 01-1.19 2.94zM12.5 11a1.5 1.5 0 100 3 1.5 1.5 0 000-3zM8 6a2 2 0 100 4 2 2 0 000-4z"],"volume-down":["M15.92 3.93l-1.6 1.18A7.948 7.948 0 0116 10c0 1.84-.63 3.54-1.68 4.89l1.6 1.18A9.878 9.878 0 0018 10c0-2.29-.78-4.39-2.08-6.07zM11 3c-.28 0-.53.11-.71.29L7.59 6H3c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"volume-off":["M14 3c-.28 0-.53.11-.71.29L10.59 6H6c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71c.17.18.42.29.7.29.55 0 1-.45 1-1V4c0-.55-.45-1-1-1z"],"volume-up":["M9 3.43c-.28 0-.53.11-.71.29l-2.7 2.71H1c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1h4.59l2.71 2.71a1.003 1.003 0 001.71-.71v-12c-.01-.55-.46-1-1.01-1zm8.31-1.56l-1.62 1.2C17.14 5.16 18 7.69 18 10.43s-.86 5.27-2.31 7.37l1.62 1.2C19 16.57 20 13.62 20 10.43c0-3.18-1-6.13-2.69-8.56zm-3.39 2.49l-1.6 1.18A7.948 7.948 0 0114 10.43c0 1.84-.63 3.54-1.68 4.89l1.6 1.18A9.94 9.94 0 0016 10.43c0-2.28-.78-4.38-2.08-6.07z"],walk:["M16 10h-2c-.23 0-.42-.09-.59-.21l-.01.01-1.69-1.27-.63 3.14 2.62 2.62c.19.18.3.43.3.71v4c0 .55-.45 1-1 1s-1-.45-1-1v-3.59L9.39 12.8l-2.45 6.55h-.01c-.14.38-.5.65-.93.65-.55 0-1-.45-1-1 0-.12.03-.24.07-.35h-.01L9.43 7h-2.9l-1.7 2.55-.01-.01c-.18.27-.47.46-.82.46-.55 0-1-.45-1-1 0-.21.08-.39.18-.54l-.01-.01 2-3 .02.01C5.36 5.19 5.65 5 6 5h4.18l.36-.96c-.33-.43-.54-.96-.54-1.54a2.5 2.5 0 015 0A2.5 2.5 0 0112.5 5c-.06 0-.12-.01-.18-.02l-.44 1.18L14.33 8H16c.55 0 1 .45 1 1s-.45 1-1 1z"],"warning-sign":["M19.86 17.52l.01-.01-9-16-.01.01C10.69 1.21 10.37 1 10 1s-.69.21-.86.52l-.01-.01-9 16 .01.01c-.08.14-.14.3-.14.48 0 .55.45 1 1 1h18c.55 0 1-.45 1-1 0-.18-.06-.34-.14-.48zM11 17H9v-2h2v2zm0-3H9V6h2v8z"],"waterfall-chart":["M13 7h2c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1h-2c-.55 0-1 .45-1 1v1c0 .55.45 1 1 1zm-9 8h1c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1zm4-6h2c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1s.45 1 1 1zm11-5h-1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h1c.55 0 1-.45 1-1V5c0-.55-.45-1-1-1zm0 12H2V3c0-.55-.45-1-1-1s-1 .45-1 1v14a.998.998 0 001 1h18c.55 0 1-.45 1-1s-.45-1-1-1z"],waves:["M4.948 2.682a1 1 0 00-1.897.001l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172C1.958 4.635 1.468 5 .999 5a1 1 0 000 2c1.457 0 2.442-1.027 3-1.825C4.558 5.973 5.543 7 7 7s2.442-1.027 3-1.825C10.558 5.973 11.543 7 13 7s2.442-1.027 3-1.825C16.558 5.973 17.544 7 19 7a1 1 0 100-2c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.896 0l-.006.016a5.868 5.868 0 01-.147.364c-.11.246-.272.568-.481.882C13.958 4.635 13.469 5 13 5c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.897 0l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172C7.958 4.635 7.468 5 6.999 5c-.47 0-.958-.365-1.418-1.055A6.05 6.05 0 014.954 2.7l-.006-.016v-.001zm0 6a1 1 0 00-1.897.001l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172c-.46.69-.95 1.055-1.419 1.055a1 1 0 100 2c1.457 0 2.442-1.027 3-1.825C4.558 11.973 5.543 13 7 13s2.442-1.027 3-1.825c.558.798 1.543 1.825 3 1.825s2.442-1.027 3-1.825c.558.798 1.544 1.825 3 1.825a1 1 0 100-2c-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.896 0l-.006.016a5.868 5.868 0 01-.147.364c-.11.246-.272.568-.481.882-.46.69-.949 1.055-1.418 1.055-.47 0-.958-.365-1.418-1.055a6.048 6.048 0 01-.628-1.246l-.006-.016a1 1 0 00-1.897 0l-.005.016-.027.074a6.05 6.05 0 01-.6 1.172c-.46.69-.95 1.055-1.419 1.055-.47 0-.958-.365-1.418-1.055A6.05 6.05 0 014.954 8.7l-.006-.016zm-1.896-6zm1.896 12l.006.017.027.074a6.053 6.053 0 00.6 1.172c.46.69.95 1.055 1.419 1.055.47 0 .958-.365 1.418-1.055a6.053 6.053 0 00.628-1.246l.005-.016a1 1 0 011.897 0l.006.016.027.074a6.051 6.051 0 00.6 1.172c.46.69.95 1.055 1.419 1.055.47 0 .958-.365 1.418-1.055a6.051 6.051 0 00.628-1.246l.006-.016a1 1 0 011.896 0l.006.016.027.074a6.051 6.051 0 00.6 1.172c.46.69.95 1.055 1.419 1.055a1 1 0 110 2c-1.456 0-2.442-1.027-3-1.825-.558.798-1.543 1.825-3 1.825s-2.442-1.027-3-1.825C9.442 17.973 8.457 19 7 19s-2.442-1.027-3-1.825C3.442 17.973 2.457 19 1 19a1 1 0 110-2c.47 0 .958-.365 1.418-1.055a6.053 6.053 0 00.628-1.246l.005-.016a1 1 0 011.897-.001z"],widget:["M18 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM2 16c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm15-1h2V5h-2v10zM3 5H1v10h2V5zM2 0C.9 0 0 .9 0 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm3 3h10V1H5v2zm13 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zM5 19h10v-2H5v2z"],"widget-button":["M1 4h18c.55 0 1 .45 1 1v10c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1zm1 2v8h16V6H2zm4 5c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm4 0c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"],"widget-footer":["M17 0H3c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H4v-4h12v4zm0-5H4V2h12v11z"],"widget-header":["M17 0H3c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1h14c.55 0 1-.45 1-1V1c0-.55-.45-1-1-1zm-1 18H4V7h12v11zm0-12H4V2h12v4z"],wind:["M12 6a3 3 0 113 3H4a1 1 0 000 2h11a5 5 0 10-5-5 1 1 0 102 0zM1 12a1 1 0 100 2h10a2 2 0 110 4c-.934 0-1.803-.614-2.057-1.333a1 1 0 10-1.886.666C7.627 18.944 9.321 20 11 20a4 4 0 000-8H1z"],wrench:["M19.8 4.44L16.13 8.1l-3.55-.71-.71-3.53L15.54.21c-2.01-.53-4.23-.03-5.8 1.53-1.86 1.85-2.23 4.6-1.14 6.83L.59 16.59C.22 16.95 0 17.45 0 18a2 2 0 002 2c.55 0 1.05-.22 1.41-.59l8.03-8.04c2.23 1.05 4.97.67 6.82-1.16 1.57-1.56 2.07-3.77 1.54-5.77z"],"zoom-in":["M19.56 17.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6zm3-7H9V5c0-.55-.45-1-1-1s-1 .45-1 1v2H5c-.55 0-1 .45-1 1s.45 1 1 1h2v2c0 .55.45 1 1 1s1-.45 1-1V9h2c.55 0 1-.45 1-1s-.45-1-1-1z"],"zoom-out":["M11 7H5c-.55 0-1 .45-1 1s.45 1 1 1h6c.55 0 1-.45 1-1s-.45-1-1-1zm8.56 10.44l-4.94-4.94A8.004 8.004 0 0016 8c0-4.42-3.58-8-8-8S0 3.58 0 8s3.58 8 8 8c1.67 0 3.21-.51 4.5-1.38l4.94 4.94a1.498 1.498 0 102.12-2.12zM8 14c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"],"zoom-to-fit":["M1 7c.55 0 1-.45 1-1V2h4c.55 0 1-.45 1-1s-.45-1-1-1H1C.45 0 0 .45 0 1v5c0 .55.45 1 1 1zm5 1a1.003 1.003 0 00-1.71-.71l-2 2c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l2 2a1.003 1.003 0 001.42-1.42L4.41 10 5.7 8.71c.19-.18.3-.43.3-.71zm2-2c.28 0 .53-.11.71-.29L10 4.41l1.29 1.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71l-2-2C10.53 2.11 10.28 2 10 2s-.53.11-.71.29l-2 2A1.003 1.003 0 008 6zM6 18H2v-4c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55.45 1 1 1h5c.55 0 1-.45 1-1s-.45-1-1-1zm8-6a1.003 1.003 0 001.71.71l2-2c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71l-2-2a1.003 1.003 0 00-1.42 1.42l1.3 1.29-1.29 1.29c-.19.18-.3.43-.3.71zm5-12h-5c-.55 0-1 .45-1 1s.45 1 1 1h4v4c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm-7 14c-.28 0-.53.11-.71.29L10 15.59 8.71 14.3A.965.965 0 008 14a1.003 1.003 0 00-.71 1.71l2 2c.18.18.43.29.71.29s.53-.11.71-.29l2-2A1.003 1.003 0 0012 14zm7-1c-.55 0-1 .45-1 1v4h-4c-.55 0-1 .45-1 1s.45 1 1 1h5c.55 0 1-.45 1-1v-5c0-.55-.45-1-1-1z"]},Ir;(function(e){e[e.STANDARD=16]="STANDARD",e[e.LARGE=20]="LARGE"})(Ir||(Ir={}));var Ja=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n=this.props.icon;if(n==null||typeof n=="boolean")return null;if(typeof n!="string")return n;var r=this.props,o=r.className,s=r.color,i=r.htmlTitle,d=r.iconSize,S=r.intent,g=r.size,w=g===void 0?d??Ir.STANDARD:g,M=r.title,R=r.tagName,V=R===void 0?"span":R,_=kr(r,["className","color","htmlTitle","iconSize","intent","size","title","tagName"]),k=w>=Ir.LARGE?Ir.LARGE:Ir.STANDARD,z=this.renderSvgPaths(k,n),I=vt(dI,fI(n),Gr(S),o),H="0 0 ".concat(k," ").concat(k);return de.createElement(V,Nt(Nt({},_),{"aria-hidden":M?void 0:!0,className:I,title:i}),de.createElement("svg",{fill:s,"data-icon":n,width:w,height:w,viewBox:H},M&&de.createElement("desc",null,M),z))},t.prototype.renderSvgPaths=function(n,r){var o=n===Ir.STANDARD?YS:JS,s=o[r];return s==null?null:s.map(function(i,d){return de.createElement("path",{key:d,d:i,fillRule:"evenodd"})})},t.displayName="".concat(En,".Icon"),t.SIZE_STANDARD=Ir.STANDARD,t.SIZE_LARGE=Ir.LARGE,t=mr([sr],t),t}(vr);function QS(e,t){return function(n){var r=n.className,o=n.elementRef,s=kr(n,["className","elementRef"]);return de.createElement(e,Nt(Nt({},s),{className:vt(t,r),ref:o}))}}var qS=QS("h6",Kb),ex=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n=this.props,r=n.className,o=n.title;return o==null?de.createElement("li",{className:vt(Qb,r)}):de.createElement("li",{className:vt(qb,r)},de.createElement(qS,null,o))},t.displayName="".concat(En,".MenuDivider"),t}(de.Component),tx=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.state={isContentOverflowing:!1,textContent:""},n.textRef=null,n}return t.prototype.componentDidMount=function(){this.update()},t.prototype.componentDidUpdate=function(){this.update()},t.prototype.render=function(){var n,r=this,o=this.props,s=o.children,i=o.className,d=o.ellipsize,S=o.tagName,g=S===void 0?"div":S,w=o.title,M=kr(o,["children","className","ellipsize","tagName","title"]),R=vt(i,(n={},n[Zb]=d,n));return de.createElement(g,Nt(Nt({},M),{className:R,ref:function(V){return r.textRef=V},title:w??(this.state.isContentOverflowing?this.state.textContent:void 0)}),s)},t.prototype.update=function(){var n;if(((n=this.textRef)===null||n===void 0?void 0:n.textContent)!=null){var r={isContentOverflowing:this.props.ellipsize&&this.textRef.scrollWidth>this.textRef.clientWidth,textContent:this.textRef.textContent};this.setState(r)}},t.displayName="".concat(En,".Text"),t.defaultProps={ellipsize:!1},t=mr([sr],t),t}(vr),nx=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n,r,o=this.props,s=o.active,i=o.className,d=o.children,S=o.disabled,g=o.icon,w=o.intent;o.labelClassName;var M=o.labelElement,R=o.multiline;o.popoverProps;var V=o.shouldDismissPopover,_=o.text,k=o.textClassName,z=o.tagName,I=z===void 0?"a":z,H=o.htmlTitle,A=kr(o,["active","className","children","disabled","icon","intent","labelClassName","labelElement","multiline","popoverProps","shouldDismissPopover","text","textClassName","tagName","htmlTitle"]),x=d!=null,p=Gr(w),v=vt(K5,p,(n={},n[G5]=s,n[jb]=s&&p==null,n[oc]=S,n[B1]=V&&!S&&!x,n),i),y=de.createElement(I,Nt(Nt(Nt({tabIndex:0},A),S?ix:{}),{className:v}),de.createElement(Ja,{icon:g,"aria-hidden":!0,tabIndex:-1}),de.createElement(tx,{className:vt(sc,k),ellipsize:!R,title:H},_),this.maybeRenderLabel(M),x?de.createElement(Ja,{title:"Open sub menu",icon:"caret-right"}):void 0),a=vt((r={},r[nu]=x,r));return de.createElement("li",{className:a},this.maybeRenderPopover(y,d))},t.prototype.maybeRenderLabel=function(n){var r=this.props,o=r.label,s=r.labelClassName;return o==null&&n==null?null:de.createElement("span",{className:vt(Jb,s)},o,n)},t.prototype.maybeRenderPopover=function(n,r){if(r==null)return n;var o=this.props,s=o.disabled,i=o.popoverProps;return de.createElement(X2,Nt({autoFocus:!1,captureDismiss:!1,disabled:s,enforceFocus:!1,hoverCloseDelay:0,interactionKind:ur.HOVER,modifiers:rx,position:Pn.RIGHT_TOP,usePortal:!1},i,{content:de.createElement(Y2,null,r),minimal:!0,popoverClassName:vt(nu,i==null?void 0:i.popoverClassName),target:n}))},t.defaultProps={disabled:!1,multiline:!1,popoverProps:{},shouldDismissPopover:!0,text:""},t.displayName="".concat(En,".MenuItem"),t=mr([sr],t),t}(vr),rx={flip:{boundariesElement:"viewport",padding:20},offset:{offset:-5},preventOverflow:{boundariesElement:"viewport",padding:20}},ix={href:void 0,onClick:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,tabIndex:-1},Y2=function(e){wn(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(){var n,r=this.props,o=r.className,s=r.children,i=r.large,d=r.ulRef,S=kr(r,["className","children","large","ulRef"]),g=vt(vs,(n={},n[j5]=i,n),o);return de.createElement("ul",Nt({},S,{className:g,ref:d}),s)},t.displayName="".concat(En,".Menu"),t.Divider=ex,t.Item=nx,t=mr([sr],t),t}(vr),ox=function(e){wn(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.state={hasPendingUpdate:!1,isComposing:!1,nextValue:r.props.value,value:r.props.value},r.cancelPendingCompositionEnd=null,r.handleCompositionStart=function(o){var s,i,d;(s=r.cancelPendingCompositionEnd)===null||s===void 0||s.call(r),r.setState({isComposing:!0}),(d=(i=r.props).onCompositionStart)===null||d===void 0||d.call(i,o)},r.handleCompositionEnd=function(o){var s,i;r.cancelPendingCompositionEnd=r.setTimeout(function(){return r.setState({isComposing:!1})},n.COMPOSITION_END_DELAY),(i=(s=r.props).onCompositionEnd)===null||i===void 0||i.call(s,o)},r.handleChange=function(o){var s,i,d=o.target.value;r.setState({nextValue:d}),(i=(s=r.props).onChange)===null||i===void 0||i.call(s,o)},r}n=t,t.getDerivedStateFromProps=function(r,o){if(o.isComposing||r.value===void 0)return null;var s=o.nextValue!==o.value;return s?r.value===o.nextValue?o.hasPendingUpdate?{value:r.value,hasPendingUpdate:!1}:{value:o.nextValue}:r.value===o.value?{hasPendingUpdate:!0}:{value:r.value,nextValue:r.value,hasPendingUpdate:!1}:{value:r.value,nextValue:r.value,hasPendingUpdate:!1}},t.prototype.render=function(){var r=this.state,o=r.isComposing,s=r.hasPendingUpdate,i=r.value,d=r.nextValue,S=this.props,g=S.inputRef,w=kr(S,["inputRef"]);return de.createElement("input",Nt({},w,{ref:g,value:o||s?d:i,onCompositionStart:this.handleCompositionStart,onCompositionEnd:this.handleCompositionEnd,onChange:this.handleChange}))};var n;return t.displayName="".concat(En,".AsyncControllableInput"),t.COMPOSITION_END_DELAY=10,t=n=mr([sr],t),t}(vr),sx=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.state={},n.leftElement=null,n.rightElement=null,n.refHandlers={leftElement:function(r){return n.leftElement=r},rightElement:function(r){return n.rightElement=r}},n}return t.prototype.render=function(){var n,r=this.props,o=r.asyncControl,s=o===void 0?!1:o,i=r.className,d=r.disabled,S=r.fill,g=r.inputRef,w=r.intent,M=r.large,R=r.small,V=r.round,_=vt(Ub,Gr(w),(n={},n[oc]=d,n[sc]=S,n[j5]=M,n[Gb]=R,n[Wb]=V,n),i),k=Nt(Nt({},this.props.style),{paddingLeft:this.state.leftElementWidth,paddingRight:this.state.rightElementWidth}),z=Nt(Nt({type:"text"},PI(this.props)),{className:ms,style:k});return de.createElement("div",{className:_},this.maybeRenderLeftElement(),s?de.createElement(ox,Nt({},z,{inputRef:g})):de.createElement("input",Nt({},z,{ref:g})),this.maybeRenderRightElement())},t.prototype.componentDidMount=function(){this.updateInputWidth()},t.prototype.componentDidUpdate=function(n){var r=this.props,o=r.leftElement,s=r.rightElement;(n.leftElement!==o||n.rightElement!==s)&&this.updateInputWidth()},t.prototype.validateProps=function(n){n.leftElement!=null&&n.leftIcon!=null&&console.warn(II)},t.prototype.maybeRenderLeftElement=function(){var n=this.props,r=n.leftElement,o=n.leftIcon;if(r!=null)return de.createElement("span",{className:Xb,ref:this.refHandlers.leftElement},r);if(o!=null)return de.createElement(Ja,{icon:o,"aria-hidden":!0,tabIndex:-1})},t.prototype.maybeRenderRightElement=function(){var n=this.props.rightElement;if(n!=null)return de.createElement("span",{className:Yb,ref:this.refHandlers.rightElement},n)},t.prototype.updateInputWidth=function(){var n=this.state,r=n.leftElementWidth,o=n.rightElementWidth;if(this.leftElement!=null){var s=this.leftElement.clientWidth;(r===void 0||Math.abs(s-r)>2)&&this.setState({leftElementWidth:s})}else this.setState({leftElementWidth:void 0});if(this.rightElement!=null){var s=this.rightElement.clientWidth;(o===void 0||Math.abs(s-o)>2)&&this.setState({rightElementWidth:s})}else this.setState({rightElementWidth:void 0})},t.displayName="".concat(En,".InputGroup"),t=mr([sr],t),t}(vr),ax=pI(),J2="".concat(ax,"-omnibar"),lx="".concat(J2,"-overlay");function cx(e,t,n){if(e.query.length===0&&n!==void 0)return n;var r=e.filteredItems.map(e.renderItem).filter(function(o){return o!=null});return r.length>0?r:t}function h1(e,t,n){return e===void 0||t==null||n==null?t===n:hi(e)?e(t,n):t[e]===n[e]}function rh(){return{__blueprintCreateNewItemBrand:"blueprint-create-new-item"}}function Ai(e){if(e==null)return!1;var t=Object.keys(e);return t.length!==1||t[0]!=="__blueprintCreateNewItemBrand"?!1:e.__blueprintCreateNewItemBrand==="blueprint-create-new-item"}function d1(e){return e==null||Ai(e)?null:e}var ux=function(e){wn(t,e);function t(n,r){var o=this,s,i;o=e.call(this,n,r)||this,o.refHandlers={itemsParent:function(M){return o.itemsParentRef=M}},o.shouldCheckActiveItemInViewport=!1,o.expectedNextActiveItem=null,o.isEnterKeyPressed=!1,o.renderItemList=function(M){var R=o.props,V=R.initialContent,_=R.noResults,k=M.renderCreateItem(),z=k!=null?null:_,I=cx(M,z,V);if(I==null&&k==null)return null;var H=o.isCreateItemFirst();return de.createElement(Y2,{ulRef:M.itemsParentRef},H&&k,I,!H&&k)},o.renderItem=function(M,R){if(o.props.disabled!==!0){var V=o.state,_=V.activeItem,k=V.query,z=o.state.filteredItems.indexOf(M)>=0,I={active:h1(o.props.itemsEqual,d1(_),M),disabled:Qa(M,R,o.props.itemDisabled),matchesPredicate:z};return o.props.itemRenderer(M,{handleClick:function(H){return o.handleItemSelect(M,H)},index:R,modifiers:I,query:k})}return null},o.renderCreateItemMenuItem=function(){if(o.isCreateItemRendered()){var M=o.state,R=M.activeItem,V=M.query,_=V.trim(),k=function(I){o.handleItemCreate(_,I)},z=Ai(R);return o.props.createNewItemRenderer(_,z,k)}return null},o.handleItemCreate=function(M,R){var V,_,k,z,I=(_=(V=o.props).createNewItemFromQuery)===null||_===void 0?void 0:_.call(V,M);I!=null&&((z=(k=o.props).onItemSelect)===null||z===void 0||z.call(k,I,R),o.maybeResetQuery())},o.handleItemSelect=function(M,R){var V,_;o.setActiveItem(M),(_=(V=o.props).onItemSelect)===null||_===void 0||_.call(V,M,R),o.maybeResetQuery()},o.handlePaste=function(M){for(var R=o.props,V=R.createNewItemFromQuery,_=R.onItemsPaste,k,z=[],I=[],H=0,A=M;H=g+w?this.itemsParentRef.scrollTop=_+i-w:k<=g&&(this.itemsParentRef.scrollTop=k-i)}}},t.prototype.setQuery=function(n,r,o){var s;r===void 0&&(r=this.props.resetOnQuery),o===void 0&&(o=this.props);var i=o.createNewItemFromQuery;this.shouldCheckActiveItemInViewport=!0;var d=n!==this.state.query;d&&((s=o.onQueryChange)===null||s===void 0||s.call(o,n));var S=n.trim(),g=oh(S,o),w=i!=null&&S!==""?i(S):void 0;this.setState({createNewItem:w,filteredItems:g,query:n});var M=this.getActiveIndex(g),R=r||M<0||Qa(d1(this.state.activeItem),M,o.itemDisabled);R&&(this.isCreateItemRendered()&&this.isCreateItemFirst()?this.setActiveItem(rh()):this.setActiveItem(aa(g,o.itemDisabled)))},t.prototype.setActiveItem=function(n){var r,o,s,i;this.expectedNextActiveItem=n,this.props.activeItem===void 0&&(this.shouldCheckActiveItemInViewport=!0,this.setState({activeItem:n})),Ai(n)?(o=(r=this.props).onActiveItemChange)===null||o===void 0||o.call(r,null,!0):(i=(s=this.props).onActiveItemChange)===null||i===void 0||i.call(s,n,!1)},t.prototype.getActiveElement=function(){var n=this.state.activeItem;if(this.itemsParentRef!=null)if(Ai(n)){var r=this.isCreateItemFirst()?0:this.state.filteredItems.length;return this.itemsParentRef.children.item(r)}else{var o=this.getActiveIndex();return this.itemsParentRef.children.item(o)}},t.prototype.getActiveIndex=function(n){n===void 0&&(n=this.state.filteredItems);var r=this.state.activeItem;if(r==null||Ai(r))return-1;for(var o=0;on?t:e}function Qa(e,t,n){return n==null||e==null?!1:hi(n)?n(e,t):!!e[n]}function aa(e,t,n,r){if(n===void 0&&(n=1),r===void 0&&(r=e.length-1),e.length===0)return null;var o=r,s=e.length-1;do if(o=dx(o+n,0,s),!Qa(e[o],o,t))return e[o];while(o!==r&&r!==-1);return null}var px=function(e){wn(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.TypedQueryList=ux.ofType(),n.renderQueryList=function(r){var o=n.props,s=o.inputProps,i=s===void 0?{}:s,d=o.isOpen,S=o.overlayProps,g=S===void 0?{}:S,w=r.handleKeyDown,M=r.handleKeyUp,R=d?{onKeyDown:w,onKeyUp:M}:{};return de.createElement(B2,Nt({hasBackdrop:!0},g,{isOpen:d,className:vt(lx,g.className),onClose:n.handleOverlayClose}),de.createElement("div",Nt({className:vt(J2,r.className)},R),de.createElement(sx,Nt({autoFocus:!0,large:!0,leftIcon:"search",placeholder:"Search..."},i,{onChange:r.handleQueryChange,value:r.query})),r.itemList))},n.handleOverlayClose=function(r){var o,s,i,d;(s=(o=n.props.overlayProps)===null||o===void 0?void 0:o.onClose)===null||s===void 0||s.call(o,r),(d=(i=n.props).onClose)===null||d===void 0||d.call(i,r)},n}return t.ofType=function(){return t},t.prototype.render=function(){var n=this.props;n.isOpen,n.inputProps,n.overlayProps;var r=kr(n,["isOpen","inputProps","overlayProps"]),o="initialContent"in this.props?this.props.initialContent:null;return de.createElement(this.TypedQueryList,Nt({},r,{initialContent:o,renderer:this.renderQueryList}))},t.displayName="".concat(En,".Omnibar"),t}(de.PureComponent);function Er(e){return Array.isArray?Array.isArray(e):ep(e)==="[object Array]"}const fx=1/0;function gx(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-fx?"-0":t}function mx(e){return e==null?"":gx(e)}function pr(e){return typeof e=="string"}function Q2(e){return typeof e=="number"}function vx(e){return e===!0||e===!1||yx(e)&&ep(e)=="[object Boolean]"}function q2(e){return typeof e=="object"}function yx(e){return q2(e)&&e!==null}function $n(e){return e!=null}function la(e){return!e.trim().length}function ep(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Cx="Incorrect 'index' type",bx=e=>`Invalid value for key ${e}`,Ix=e=>`Pattern length exceeds max of ${e}.`,wx=e=>`Missing ${e} property in key`,Ax=e=>`Property 'weight' in key '${e}' must be a positive integer`,sh=Object.prototype.hasOwnProperty;class Sx{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=tp(r);n+=o.weight,this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function tp(e){let t=null,n=null,r=null,o=1,s=null;if(pr(e)||Er(e))r=e,t=ah(e),n=qa(e);else{if(!sh.call(e,"name"))throw new Error(wx("name"));const i=e.name;if(r=i,sh.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(Ax(i));t=ah(i),n=qa(i),s=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:s}}function ah(e){return Er(e)?e:e.split(".")}function qa(e){return Er(e)?e.join("."):e}function xx(e,t){let n=[],r=!1;const o=(s,i,d)=>{if($n(s))if(!i[d])n.push(s);else{let S=i[d];const g=s[S];if(!$n(g))return;if(d===i.length-1&&(pr(g)||Q2(g)||vx(g)))n.push(mx(g));else if(Er(g)){r=!0;for(let w=0,M=g.length;we.score===t.score?e.idx{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,pr(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();pr(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,r=this.size();n{let i=o.getFn?o.getFn(t):this.getFn(t,o.path);if($n(i)){if(Er(i)){let d=[];const S=[{nestedArrIndex:-1,value:i}];for(;S.length;){const{nestedArrIndex:g,value:w}=S.pop();if($n(w))if(pr(w)&&!la(w)){let M={v:w,i:g,n:this.norm.get(w)};d.push(M)}else Er(w)&&w.forEach((M,R)=>{S.push({nestedArrIndex:R,value:M})})}r.$[s]=d}else if(pr(i)&&!la(i)){let d={v:i,n:this.norm.get(i)};r.$[s]=d}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function np(e,t,{getFn:n=Tt.getFn,fieldNormWeight:r=Tt.fieldNormWeight}={}){const o=new yc({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(tp)),o.setSources(t),o.create(),o}function Rx(e,{getFn:t=Tt.getFn,fieldNormWeight:n=Tt.fieldNormWeight}={}){const{keys:r,records:o}=e,s=new yc({getFn:t,fieldNormWeight:n});return s.setKeys(r),s.setIndexRecords(o),s}function p1(e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=Tt.distance,ignoreLocation:s=Tt.ignoreLocation}={}){const i=t/e.length;if(s)return i;const d=Math.abs(r-n);return o?i+d/o:d?1:i}function Hx(e=[],t=Tt.minMatchCharLength){let n=[],r=-1,o=-1,s=0;for(let i=e.length;s=t&&n.push([r,o]),r=-1)}return e[s-1]&&s-r>=t&&n.push([r,s-1]),n}const ti=32;function Vx(e,t,n,{location:r=Tt.location,distance:o=Tt.distance,threshold:s=Tt.threshold,findAllMatches:i=Tt.findAllMatches,minMatchCharLength:d=Tt.minMatchCharLength,includeMatches:S=Tt.includeMatches,ignoreLocation:g=Tt.ignoreLocation}={}){if(t.length>ti)throw new Error(Ix(ti));const w=t.length,M=e.length,R=Math.max(0,Math.min(r,M));let V=s,_=R;const k=d>1||S,z=k?Array(M):[];let I;for(;(I=e.indexOf(t,_))>-1;){let y=p1(t,{currentLocation:I,expectedLocation:R,distance:o,ignoreLocation:g});if(V=Math.min(y,V),_=I+w,k){let a=0;for(;a=u;c-=1){let f=c-1,C=n[e.charAt(f)];if(k&&(z[f]=+!!C),m[c]=(m[c+1]<<1|1)&C,y&&(m[c]|=(H[c+1]|H[c])<<1|1|H[c+1]),m[c]&p&&(A=p1(t,{errors:y,currentLocation:f,expectedLocation:R,distance:o,ignoreLocation:g}),A<=V)){if(V=A,_=f,_<=R)break;u=Math.max(1,2*R-_)}}if(p1(t,{errors:y+1,currentLocation:R,expectedLocation:R,distance:o,ignoreLocation:g})>V)break;H=m}const v={isMatch:_>=0,score:Math.max(.001,A)};if(k){const y=Hx(z,d);y.length?S&&(v.indices=y):v.isMatch=!1}return v}function _x(e){let t={};for(let n=0,r=e.length;n{this.chunks.push({pattern:R,alphabet:_x(R),startIndex:V})},M=this.pattern.length;if(M>ti){let R=0;const V=M%ti,_=M-V;for(;R<_;)w(this.pattern.substr(R,ti),R),R+=ti;if(V){const k=M-ti;w(this.pattern.substr(k),k)}}else w(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,includeMatches:r}=this.options;if(n||(t=t.toLowerCase()),this.pattern===t){let _={isMatch:!0,score:0};return r&&(_.indices=[[0,t.length-1]]),_}const{location:o,distance:s,threshold:i,findAllMatches:d,minMatchCharLength:S,ignoreLocation:g}=this.options;let w=[],M=0,R=!1;this.chunks.forEach(({pattern:_,alphabet:k,startIndex:z})=>{const{isMatch:I,score:H,indices:A}=Vx(t,_,k,{location:o+z,distance:s,threshold:i,findAllMatches:d,minMatchCharLength:S,includeMatches:r,ignoreLocation:g});I&&(R=!0),M+=H,I&&A&&(w=[...w,...A])});let V={isMatch:R,score:R?M/this.chunks.length:1};return R&&r&&(V.indices=w),V}}class jr{constructor(t){this.pattern=t}static isMultiMatch(t){return lh(t,this.multiRegex)}static isSingleMatch(t){return lh(t,this.singleRegex)}search(){}}function lh(e,t){const n=e.match(t);return n?n[1]:null}class Nx extends jr{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Ox extends jr{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class Px extends jr{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Dx extends jr{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class $x extends jr{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Bx extends jr{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ip extends jr{constructor(t,{location:n=Tt.location,threshold:r=Tt.threshold,distance:o=Tt.distance,includeMatches:s=Tt.includeMatches,findAllMatches:i=Tt.findAllMatches,minMatchCharLength:d=Tt.minMatchCharLength,isCaseSensitive:S=Tt.isCaseSensitive,ignoreLocation:g=Tt.ignoreLocation}={}){super(t),this._bitapSearch=new rp(t,{location:n,threshold:r,distance:o,includeMatches:s,findAllMatches:i,minMatchCharLength:d,isCaseSensitive:S,ignoreLocation:g})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class op extends jr{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,r;const o=[],s=this.pattern.length;for(;(r=t.indexOf(this.pattern,n))>-1;)n=r+s,o.push([r,n-1]);const i=!!o.length;return{isMatch:i,score:i?0:1,indices:o}}}const el=[Nx,op,Px,Dx,Bx,$x,Ox,ip],ch=el.length,Fx=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Wx="|";function Gx(e,t={}){return e.split(Wx).map(n=>{let r=n.trim().split(Fx).filter(s=>s&&!!s.trim()),o=[];for(let s=0,i=r.length;s!!(e[j1.AND]||e[j1.OR]),Ux=e=>!!e[rl.PATH],Xx=e=>!Er(e)&&q2(e)&&!il(e),uh=e=>({[j1.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function sp(e,t,{auto:n=!0}={}){const r=o=>{let s=Object.keys(o);const i=Ux(o);if(!i&&s.length>1&&!il(o))return r(uh(o));if(Xx(o)){const S=i?o[rl.PATH]:s[0],g=i?o[rl.PATTERN]:o[S];if(!pr(g))throw new Error(bx(S));const w={keyId:qa(S),pattern:g};return n&&(w.searcher=nl(g,t)),w}let d={children:[],operator:s[0]};return s.forEach(S=>{const g=o[S];Er(g)&&g.forEach(w=>{d.children.push(r(w))})}),d};return il(e)||(e=uh(e)),r(e)}function Yx(e,{ignoreFieldNorm:t=Tt.ignoreFieldNorm}){e.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:s,score:i})=>{const d=o?o.weight:null;r*=Math.pow(i===0&&d?Number.EPSILON:i,(d||1)*(t?1:s))}),n.score=r})}function Jx(e,t){const n=e.matches;t.matches=[],$n(n)&&n.forEach(r=>{if(!$n(r.indices)||!r.indices.length)return;const{indices:o,value:s}=r;let i={indices:o,value:s};r.key&&(i.key=r.key.src),r.idx>-1&&(i.refIndex=r.idx),t.matches.push(i)})}function Qx(e,t){t.score=e.score}function qx(e,t,{includeMatches:n=Tt.includeMatches,includeScore:r=Tt.includeScore}={}){const o=[];return n&&o.push(Jx),r&&o.push(Qx),e.map(s=>{const{idx:i}=s,d={item:t[i],refIndex:i};return o.length&&o.forEach(S=>{S(s,d)}),d})}class ji{constructor(t,n={},r){this.options={...Tt,...n},this.options.useExtendedSearch,this._keyStore=new Sx(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof yc))throw new Error(Cx);this._myIndex=n||np(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){$n(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let r=0,o=this._docs.length;r-1&&(S=S.slice(0,n)),qx(S,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=nl(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:s,i,n:d})=>{if(!$n(s))return;const{isMatch:S,score:g,indices:w}=n.searchIn(s);S&&o.push({item:s,idx:i,matches:[{score:g,value:s,norm:d,indices:w}]})}),o}_searchLogical(t){const n=sp(t,this.options),r=(d,S,g)=>{if(!d.children){const{keyId:M,searcher:R}=d,V=this._findMatches({key:this._keyStore.get(M),value:this._myIndex.getValueForItemAtKeyId(S,M),searcher:R});return V&&V.length?[{idx:g,item:S,matches:V}]:[]}const w=[];for(let M=0,R=d.children.length;M{if($n(d)){let g=r(n,d,S);g.length&&(s[S]||(s[S]={idx:S,item:d,matches:[]},i.push(s[S])),g.forEach(({matches:w})=>{s[S].matches.push(...w)}))}}),i}_searchObjectList(t){const n=nl(t,this.options),{keys:r,records:o}=this._myIndex,s=[];return o.forEach(({$:i,i:d})=>{if(!$n(i))return;let S=[];r.forEach((g,w)=>{S.push(...this._findMatches({key:g,value:i[w],searcher:n}))}),S.length&&s.push({idx:d,item:i,matches:S})}),s}_findMatches({key:t,value:n,searcher:r}){if(!$n(n))return[];let o=[];if(Er(n))n.forEach(({v:s,i,n:d})=>{if(!$n(s))return;const{isMatch:S,score:g,indices:w}=r.searchIn(s);S&&o.push({score:g,key:t,value:s,idx:i,norm:d,indices:w})});else{const{v:s,n:i}=n,{isMatch:d,score:S,indices:g}=r.searchIn(s);d&&o.push({score:S,key:t,value:s,norm:i,indices:g})}return o}}ji.version="6.6.2";ji.createIndex=np;ji.parseIndex=Rx;ji.config=Tt;ji.parseQuery=sp;Kx(Zx);const Z1=Object.values(sl),hh=Z1.map(e=>mt[e]||xd[e]).map((e,t)=>e?e.split("|").reverse()[0]:Z1[t]),eM=({onClose:e})=>{const t=de.useRef(new ji(hh)),[n,r]=de.useState("");li("Enter");const o=de.useMemo(()=>{const s=t.current.search(n);return s.length>0?s:hh.map((i,d)=>({item:i,refIndex:d}))},[n]);return se.jsx(px,{isOpen:!0,itemsEqual:(s,i)=>s.refIndex===i.refIndex,items:o,itemRenderer:(s,i)=>se.jsxs("div",{className:vt(eu.semanticSelectItem,{[eu.semanticSelectItemActive]:i.modifiers.active}),onClick:()=>{e(Z1[s.refIndex])},children:[se.jsx("svg",{style:{width:"80px",height:"80px"},viewBox:"0 0 10 10",onClick:()=>{},children:se.jsx("g",{transform:"translate(5, 5)",children:se.jsx("use",{color:"black",fill:"black",xlinkHref:`#score-token-def-${s.item}`})})}),se.jsx("div",{children:Z1[s.refIndex]})]},s.refIndex),onItemSelect:()=>{},onQueryChange:s=>{r(s)},onClose:()=>{e()}})},tM=e=>{var n;if(!((n=e==null?void 0:e.extension)!=null&&n.text))return null;const t=Math.max(Math.ceil(e.extension.width*4/e.extension.height),3);return e.extension.text.length>t?e.extension.text.substring(0,t-2)+"...":e.extension.text},nM=({score:e,pageIndex:t,show:n,width:r,height:o})=>{var m,l,c,f;const s=e.pages[t],[i,d]=pi(),[S,g]=ml(),[w,M]=de.useState({x:-10,y:-10}),[R]=Y1(),[V,_]=cl(),[k]=li("Shift"),[z,I]=de.useState(!1),H=de.useRef(null),[A]=dl(),[x]=pl();de.useState(!1);const[p,v]=de.useState(null);if(!s)return null;const y=5/R,[a,h]=de.useState([null,null,null,null]),u=de.useMemo(()=>{if(!V)return null;let C=null;return s.systems.forEach(T=>{var L;T.staves.forEach(O=>{var P;(P=O.semantics)!=null&&P.some(F=>F.id===(V==null?void 0:V.point.id))&&(C={x:(V==null?void 0:V.point.x)+T.left,y:(V==null?void 0:V.point.y)+O.top+O.staffY+T.top})}),(L=T.semantics)!=null&&L.some(O=>O.id===(V==null?void 0:V.point.id))&&(C={x:(V==null?void 0:V.point.x)+T.left,y:(V==null?void 0:V.point.y)+T.top})}),C},[V]),b=C=>{v(null),C.target.value!==p.token.text&&(e.textAnnotations=e.textAnnotations||{},e.textAnnotations[p.token.id]=C.target.value,e.assemble(),d(Pt(e,{modify:!0})))};return se.jsxs(se.Fragment,{children:[se.jsxs("svg",{className:vt("graph",{}),style:{objectFit:"contain"},viewBox:`0 0 ${r} ${o}`,onContextMenu:C=>{const T=so(C.currentTarget,B=>B.nodeName==="svg"),L=T.createSVGPoint();L.x=C.clientX,L.y=C.clientY;const O=T.getScreenCTM(),P=L.matrixTransform(O.inverse());if(k){if(C.preventDefault(),C.stopPropagation(),a&&a.slice(0,3).every(Number.isFinite)){const B=e.pages[a[0]].systems[a[1]],W=B.staves[a[2]];if(W){const Q=P.x-B.left,j=P.y-B.top-W.top-W.staffY;console.debug("xy:",a,Q,j,B),H.current={x:Q,y:j,pointer:[...a]}}}I(!0);return}const F=[];s.systems.forEach(B=>{B.staves.forEach(W=>{W.semantics&&F.push(...W.semantics.filter(Q=>Ec({x:P.x,y:P.y},{x:Q.x+B.left,y:Q.y+W.top+W.staffY+B.top},y)))}),B.semantics&&F.push(...B.semantics.filter(W=>Ec({x:P.x,y:P.y},{x:W.x+B.left,y:W.y+B.top})))}),M({x:P.x,y:P.y}),F.sort((B,W)=>W.confidence-B.confidence),g(F)},onClick:()=>_(null),children:[S.length>0&&se.jsx("circle",{cx:w.x,cy:w.y,r:y,strokeWidth:"0.1",stroke:"black",strokeDasharray:"0.2 0.2",fill:"transparent"}),n&&((m=s==null?void 0:s.systems)==null?void 0:m.map((C,T)=>se.jsx($b,{score:e,page:s,pageIndex:t,system:C,systemIndex:T,pointer:a,setPointer:h},T))),u&&se.jsxs("g",{children:[se.jsxs("circle",{id:`anchor-${V==null?void 0:V.point.id}`,cx:u.x,cy:u.y,r:"0",fillOpacity:"0",stroke:"#f44336",strokeWidth:"0.4",strokeOpacity:"1",children:[se.jsx("animate",{attributeName:"r",from:"0",to:y,dur:"1.5s",repeatCount:"indefinite",begin:"0s"}),se.jsx("animate",{attributeName:"stroke-opacity",from:"1",to:"0",dur:"1.5s",repeatCount:"indefinite",begin:"0s"})]}),se.jsxs("circle",{id:`anchor-${V==null?void 0:V.point.id}`,cx:u.x,cy:u.y,r:"0",fillOpacity:"0",stroke:"#f44336",strokeWidth:"0.4",strokeOpacity:"1",children:[se.jsx("animate",{attributeName:"r",from:"0",to:y,dur:"1.5s",repeatCount:"indefinite",begin:"0.5s"}),se.jsx("animate",{attributeName:"stroke-opacity",from:"1",to:"0",dur:"1.5s",repeatCount:"indefinite",begin:"0.5s"})]})]}),n&&A&&(s==null?void 0:s.semantics)&&se.jsx("g",{children:(l=s==null?void 0:s.semantics)==null?void 0:l.map((C,T)=>{var L,O,P,F,B,W,Q,j,E;if(C.semantic===sl.rect_Text)return se.jsxs("g",{transform:`translate(${C.x}, ${C.y}) ${(L=C.extension)!=null&&L.theta?`rotate(${((O=C.extension)==null?void 0:O.theta)*180/Math.PI})`:""}`,color:"rgba(25, 175, 230, 0.6)",className:"semantic",onClick:()=>console.log(C),children:[se.jsx("rect",{x:-((P=C.extension)==null?void 0:P.width)/2,y:-((F=C.extension)==null?void 0:F.height)/2,width:(B=C.extension)==null?void 0:B.width,height:(W=C.extension)==null?void 0:W.height}),se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-((Q=C.extension)==null?void 0:Q.height)/2,textAnchor:"middle",style:{fontSize:(j=C.extension)==null?void 0:j.height},children:[tM(C),se.jsx("title",{children:((E=C.extension)==null?void 0:E.type)||C.semantic})]})]},T)})}),n&&x&&(s==null?void 0:s.tokens)&&se.jsx("g",{children:(c=s==null?void 0:s.tokens)==null?void 0:c.map((C,T)=>{var L;if(C.type===mt.Text)return se.jsx("g",{transform:`translate(${C.x}, ${C.y})`,color:"rgba(25, 175, 230, 0.6)",className:"token",children:se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-C.fontSize/2,textAnchor:"middle",style:{fontSize:C.fontSize},className:vt({[C.textType]:!0,annotated:(L=e==null?void 0:e.textAnnotations)==null?void 0:L[C.id]}),onClick:O=>{const P=so(O.currentTarget,W=>W.nodeName==="svg"),F=O.currentTarget.getBoundingClientRect(),B=P.getBoundingClientRect();v({token:C,left:F.left-B.left,top:F.top-B.top,width:F.width,height:F.height})},children:[C.text,se.jsx("title",{children:C.textType})]})},T)})}),n&&x&&((f=s==null?void 0:s.systems)==null?void 0:f.map((C,T)=>{var L;return se.jsx("g",{transform:`translate(${C.left}, ${C.top})`,children:(L=C.tokens)==null?void 0:L.filter(O=>O.type===mt.Text&&!["Chord"].includes(O.textType)).map((O,P)=>{var F;return se.jsx("g",{transform:`translate(${O.x}, ${O.y})`,className:"token",children:se.jsxs("text",{dominantBaseline:"hanging",x:0,y:-O.fontSize/2,textAnchor:"middle",style:{fontSize:O.fontSize},className:vt({[O.textType]:!0,annotated:(F=e==null?void 0:e.textAnnotations)==null?void 0:F[O.id]}),onClick:B=>{const W=so(B.currentTarget,E=>E.nodeName==="svg"),Q=B.currentTarget.getBoundingClientRect(),j=W.getBoundingClientRect();v({token:O,left:Q.left-j.left,top:Q.top-j.top,width:Q.width,height:Q.height})},children:[O.text,se.jsx("title",{children:O.textType})]})},P)})},T)}))]}),z&&se.jsx(eM,{onClose:C=>{if(C&&H.current){const{x:T,y:L,pointer:O}=H.current;e.pages[O[0]].systems[O[1]].newPoint(O[2],{x:T,y:L,semantic:C}),d(Pt(e,{modify:!0}))}I(!1)}}),p&&se.jsx(Hr,{autoFocus:!0,style:{position:"absolute",left:p.left-10+"px",top:p.top+"px",width:p.width+20+"px",height:p.height+"px",zIndex:100,fontSize:p.height*.8+"px"},defaultValue:p.token.text,onBlur:b,onPressEnter:b})]})},rM=de.memo(nM);const f1=Object.freeze({unit:"%",x:0,y:0,width:0,height:0}),iM=de.forwardRef(({pageIndex:e,onSeekPosition:t,disableScoreLevelControls:n=!1,disableRecognization:r=!1},o)=>{var K,X,Y,oe,ce,re,fe,U,q,ee,D,$,G,J,ne,me,Le,_e,De,Fe,Ze;const s=zr(),[i]=Y1(),[d,S]=pi(),g=de.useRef(null),w=de.useRef(null),[M,R]=de.useState(!1),[V,_]=de.useState(!1),[k,z]=de.useState(null),[I,H]=de.useState(!0),A=de.useRef(null),[x]=gl(),[p,v]=de.useState([null,null,null,null]),y=de.useRef(!1),a=(K=d==null?void 0:d.pages)==null?void 0:K[e],[h,u]=de.useState(f1),[b]=li(navigator.userAgent.indexOf("Mac")>=0?"Alt":"Control"),[m]=li("Escape"),[l,c]=ml(),[f,C]=Ch(),T=wf(),L=Zf(A,{root:null,rootMargin:"0px",threshold:0}),O=de.useMemo(()=>d.pages.length<10?!0:!L||(L==null?void 0:L.isIntersecting),[d,L]),P=de.useRef({break:!0});de.useEffect(()=>{x==="play"&&H(!1)},[x]),de.useEffect(()=>{I&&R(b)},[b]),de.useEffect(()=>{m&&u(f1)},[m]),de.useEffect(()=>{var He;(He=d.pages[e])!=null&&He.layout&&H(!1)},[]);const[F,B]=gh(async({sheet:He=d,sourceImage:Ye=w.current,noLayout:be=!1,clipPoints:$e=null})=>{var Re,ge,Ce,Te,Ke;P.current.break=!1,A.current.scrollIntoView({block:"center",behavior:"smooth"}),H(!0),R(!1);const Ne=!!$e;(ge=(Re=He.pages[e])==null?void 0:Re.systems)==null||ge.forEach((Qe,lt)=>{if(Ne&&(Ve!=null&&Ve.changedSystems.includes(lt))){Qe.clearTokens();return}}),S(Pt(He,{modify:!0}));let Ve=null,et=!1;if(console.log(be,He.pages[e].layout),!He.pages[e].layout||Ne){if(_(!0),Ve=await N9(He,e,{sourceImage:Ye,pageLayoutByBlock:He.settings.pageLayoutMethod===Mp.ByBlocks,croppedAreaCanvas:g.current,clipPoints:$e}),S(Pt(He,{modify:!0})),_(!1),!Ve){Un.error(s.formatMessage({id:"playground.pageEditor.noScoreDetected"}));return}et=!0}H(!1);const ht=await T9(He.pages[e]);He.pages[e].semantics||D9(ht,He.pages[e]).then(()=>S(Pt(He,{modify:!0})));for await(const[Qe,lt]of(Te=(Ce=He.pages[e])==null?void 0:Ce.systems)==null?void 0:Te.entries()){if(((Ke=lt==null?void 0:lt.semantics)==null?void 0:Ke.length)>0||Ne&&!(Ve!=null&&Ve.changedSystems.includes(Qe)))continue;if(P.current.break)break;z(Qe);const ve=[];lt.staves.forEach((Oe,Xe)=>{ve.push([e,Qe,Xe])}),He.settings.enabledGauge&&et&&await H9({score:He,staves:ve}),S(Pt(He,{modify:!0})),et&&await R9({score:He,staves:ve,withCache:!0}),S(Pt(He,{modify:!0})),await V9({score:He,staves:ve}),z(null),S(Pt(He,{modify:!0}))}P.current.break?oo.warn({placement:"bottomRight",message:s.formatMessage({id:"playground.pageEditor.recognitionResult"}),description:s.formatMessage({id:"playground.pageEditor.pageInterrupted"},{page:e+1})}):oo.success({placement:"bottomRight",message:s.formatMessage({id:"playground.pageEditor.recognitionResult"}),description:s.formatMessage({id:"playground.pageEditor.pageCompleted"},{page:e+1})}),P.current.break=!1},[JSON.stringify(d.settings),e]);de.useEffect(()=>{var He,Ye,be,$e,Ne;g.current&&w.current&&a&&(d.pages[e].source.dimensions=d.pages[e].source.dimensions||{width:w.current.naturalWidth,height:w.current.naturalHeight},d.pages[e].source.interval=d.pages[e].source.interval||((Ne=($e=(be=(Ye=(He=d.pages[e])==null?void 0:He.layout)==null?void 0:Ye.areas)==null?void 0:be[0])==null?void 0:$e.staves)==null?void 0:Ne.interval))},[e,g.current,w.current]),de.useImperativeHandle(o,()=>({predict:async He=>{await B({sheet:He})},break:()=>P.current.break=!0,setLayoutMode:H}),[]),window.score=d;const W=(Y=(X=d.pages)==null?void 0:X[e])==null?void 0:Y.layout;(oe=W==null?void 0:W.pageSize)!=null&&oe.width||((ce=g.current)==null||ce.width),(re=W==null?void 0:W.pageSize)!=null&&re.height||((fe=g.current)==null||fe.height),de.useEffect(()=>{w.current&&(w.current.style.opacity=I?"1":"0")},[I,w.current]);const Q=de.useMemo(()=>({width:d.pageSize.width*i,height:d.pageSize.height*i}),[i,d.pageSize]),j=(He,Ye)=>{var be,$e,Ne;return(Ne=($e=(be=d.pages)==null?void 0:be[e])==null?void 0:$e[He])==null?void 0:Ne.has(Ye.id)},E=(U=a==null?void 0:a.source)!=null&&U.dimensions&&((q=a==null?void 0:a.source)!=null&&q.interval)?{width:a.source.dimensions.width*i*d.unitSize/a.source.interval+"px",height:a.source.dimensions.height*i*d.unitSize/a.source.interval+"px"}:{width:`${d.pageSize.width*i}px`,height:`${d.pageSize.height*i}px`},Z=d.unitSize/(((ee=a==null?void 0:a.source)==null?void 0:ee.interval)??d.unitSize)*i,N=de.useMemo(()=>{var He;return se.jsx("div",{className:"hud",style:{pointerEvents:M||!I?"none":"auto",...E,position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:(He=W==null?void 0:W.areas)==null?void 0:He.map((Ye,be)=>{var $e,Ne,Ve,et,ht,Re,ge,Ce;return se.jsxs("div",{style:{position:"absolute",left:Ye.x*Z+"px",top:Ye.y*Z+"px",width:Ye.width*Z+"px",height:Ye.height*Z+"px",display:!I&&((ht=(et=(Ve=(Ne=($e=d==null?void 0:d.pages)==null?void 0:$e[e])==null?void 0:Ne.systems)==null?void 0:Ve[be])==null?void 0:et.semantics)==null?void 0:ht.length)>0?"none":"block"},className:vt("system",{active:p.slice(0,2).join(",")===[e,be].join(","),loading:k===be}),onMouseLeave:()=>{!y.current&&v([e,null])},onMouseMove:()=>{if(!y.current){const Te=[e,be];p.join(",")!==Te.join(",")&&v(Te)}},"data-level":"system",children:[k===be&&se.jsx(S1,{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},size:"large",spinning:!0}),(Ce=(ge=(Re=Ye.staves)==null?void 0:Re.middleRhos)==null?void 0:ge.map)==null?void 0:Ce.call(ge,(Te,Ke)=>se.jsx("div",{className:vt("stave",{active:p.slice(0,3).join(",")===[e,be,Ke].join(",")}),style:{position:"absolute",transform:`rotate(${-Ye.staves.theta}deg)`,left:Ye.staves.phi1*Z+"px",top:(Ye.staves.interval*-2+Te)*Z+"px",width:(Ye.staves.phi2-Ye.staves.phi1)*Z+"px",height:Ye.staves.interval*4*Z+"px"},onMouseLeave:Qe=>{Qe.stopPropagation(),!y.current&&v([e,be,null])},onMouseMove:Qe=>{if(Qe.stopPropagation(),!y.current){const lt=[e,be,Ke];p.join(",")!==lt.join(",")&&v(lt),v(lt)}},children:se.jsx("span",{className:"index",children:String.fromCharCode(9312+Ke)})},Ke))]},be)})})},[M,I,y,p,k,W]);return se.jsx("div",{ref:A,style:{width:Q.width,minHeight:Q.height,backgroundColor:"#ffffff"},children:O?se.jsxs(S1,{spinning:V,tip:s.formatMessage({id:"playground.pageEditor.recognizingLayout"}),children:[se.jsxs("div",{style:{...Q,overflow:"hidden"},children:[se.jsxs("div",{style:{overflow:"hidden",position:"absolute",top:0,left:0,...Q,pointerEvents:M?"none":"initial"},children:[se.jsx("div",{style:{display:I?"block":"none",position:"absolute",top:"50%",left:"50%"},children:se.jsx("div",{style:{transformOrigin:"left top",transform:`matrix(${(D=a==null?void 0:a.source)==null?void 0:D.matrix.join(",")})`},children:se.jsx("div",{style:{...E,transform:"translate(-50%, -50%)"},children:se.jsx("img",{style:{...E},src:($=a==null?void 0:a.source)==null?void 0:$.url,crossOrigin:"anonymous",onLoad:He=>{w.current=He.target}})})})}),se.jsxs("div",{style:{position:"absolute",...E,top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[se.jsx("canvas",{style:{...E,position:"absolute",pointerEvents:"none",display:"none",top:"50%",left:"50%",transform:"translate(-50%, -50%)",outline:"2px solid red"},ref:g}),(I&&g.current&&(W==null?void 0:W.areas)&&x!=="play"||!I&&k!==null)&&(r?N:se.jsx(da,{onOpenChange:He=>{y.current=He},menu:{items:[typeof p[1]=="number"&&typeof p[2]!="number"&&{key:"1",label:`${s.formatMessage({id:"playground.pageEditor.deleteBlock"})}(system: ${p[1]+1})`,onClick:()=>{var Ye,be,$e,Ne;const He=Pt(d,{modify:!0});($e=(be=(Ye=He.pages[e])==null?void 0:Ye.layout)==null?void 0:be.areas)==null||$e.splice(p[1],1),(Ne=He.pages[e])==null||Ne.systems.splice(p[1],1),S(He),y.current=!1}},typeof p[2]=="number"&&{key:"2",label:`${s.formatMessage({id:"playground.pageEditor.deleteLine"})}(system: ${p[1]+1}, staff: ${p[2]+1})`,onClick:()=>{var Ye,be,$e,Ne,Ve,et,ht,Re,ge,Ce,Te,Ke,Qe,lt,ve,Me;const He=Pt(d,{modify:!0});(Ve=(Ne=($e=(be=(Ye=He.pages[e])==null?void 0:Ye.layout)==null?void 0:be.areas)==null?void 0:$e[p[1]])==null?void 0:Ne.staves)==null||Ve.middleRhos.splice(p[2],1),(Re=(ht=(et=He.pages[e])==null?void 0:et.systems)==null?void 0:ht[p[1]])==null||Re.staves.splice(p[2],1),(Ke=(Te=(Ce=(ge=He.pages[e])==null?void 0:ge.layout)==null?void 0:Ce.areas)==null?void 0:Te[p[1]])!=null&&Ke.staves||((ve=(lt=(Qe=He.pages[e])==null?void 0:Qe.layout)==null?void 0:lt.areas)==null||ve.splice(p[1],1),(Me=He.pages[e])==null||Me.systems.splice(p[1],1)),S(He),y.current=!1}}].filter(Boolean)},trigger:r?null:["contextMenu"],children:N}))]})]}),I&&se.jsx(_b,{src:(G=a==null?void 0:a.source)==null?void 0:G.url,crop:h,keepSelection:!h,crossorigin:"anonymous",onChange:(He,Ye)=>u(Ye),disabled:!M,className:vt({"pointer-events-none":!M&&!(h!=null&&h.width)}),renderComponent:se.jsx("div",{style:{...Q}}),renderSelectionAddon:()=>{var be,$e;let He="0",Ye="0";if(a&&w.current){const Ne=(h==null?void 0:h.width)>0?h.width/100:1,Ve=(h==null?void 0:h.height)>0?h.height/100:1;He=d.pageSize.width*i*Ne+"px",Ye=d.pageSize.height*i*(((be=a.source.dimensions)==null?void 0:be.height)||w.current.naturalHeight)/((($e=a.source.dimensions)==null?void 0:$e.width)||w.current.naturalWidth)*Ve+"px"}return se.jsx("div",{style:{position:"relative",width:He,height:Ye,padding:"10px"},children:se.jsx(Jt,{children:se.jsx(kt,{icon:se.jsx(Vh,{}),onClick:async()=>{const Ne=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];await B({sheet:d,sourceImage:w.current,clipPoints:Ne}),u(f1)}})})})}}),!M&&!I&&((J=a==null?void 0:a.systems)==null?void 0:J.length)>0&&se.jsx(da,{disabled:x==="play",onOpenChange:He=>{He||(c([]),C(null))},menu:{items:l.length===0?[{key:"0",label:s.formatMessage({id:"playground.pageEditor.empty"}),style:{color:"#ccc",minWidth:"8em",textAlign:"center"}}]:l.map(He=>{var Ne,Ve,et,ht;const Ye=j("sidWhiteList",He),be=j("sidBlackList",He),$e=d.settings.semanticConfidenceThreshold;return{key:He.id,label:se.jsx("div",{className:"menu-item",onClick:Re=>{Re.stopPropagation()},onMouseEnter:()=>{C(He)},onMouseLeave:()=>{C(null)},children:se.jsxs(yl,{className:vt({whitelist:Ye,blacklist:be}),defaultChecked:Ye||!be&&He.confidence>=$e,onChange:Re=>{d.pages[e].systems.forEach((ge,Ce)=>{if(ge.staves.some(Ke=>Ke.semantics.some(Qe=>Qe.id===He.id))){if(He.confidence>=$e){const Ke=ge.sidBlackList.findIndex(Qe=>Qe===He.id);Ke>-1?ge.sidBlackList.splice(Ke,1):ge.sidBlackList.push(f.id)}else{const Ke=ge.sidWhiteList.findIndex(Qe=>Qe===He.id);Ke>-1?ge.sidWhiteList.splice(Ke,1):ge.sidWhiteList.push(f.id)}ge.assemble($e),S(Pt(d,{modify:!0}))}}),T()},children:[" ",se.jsx("i",{className:vt("emmentaler","glyph-"+((ht=(et=(Ve=(Ne=mt)==null?void 0:Ne[He.semantic])==null?void 0:Ve.split("|"))==null?void 0:et.reverse())==null?void 0:ht[0]))})," ",se.jsx("span",{className:"name",children:He.semantic})," ",se.jsx("span",{className:"confidence",children:He.confidence.toFixed(2)})]})})}})},trigger:["contextMenu"],children:se.jsxs("div",{className:"page",children:[se.jsx(rM,{score:d,pageIndex:e,show:O,width:a.width,height:a.height}),x==="play"&&se.jsx(Ob,{score:d,page:a,pageIndex:e,onSeekPosition:t})]})}),se.jsx(Ki,{style:{pointerEvents:"none",color:"#ccc"},className:"pageNum",orientation:"center",plain:!0,children:e+1})]}),x==="edit"&&se.jsx(q1,{style:{padding:"10px 20px",color:"#ccc"},children:se.jsx("a",{onClick:()=>{const He=document.createElement("img");He.src=a.source.url,He.crossOrigin="anonymous",He.onload=()=>{const Ye=new window.OffscreenCanvas(He.naturalWidth,He.naturalHeight);Ye.getContext("2d").drawImage(He,0,0),Ye.convertToBlob().then($e=>{var Ne;to($e,(Ne=a==null?void 0:a.source)==null?void 0:Ne.name)})}},children:(ne=a==null?void 0:a.source)==null?void 0:ne.name})}),x==="edit"&&se.jsxs(Jt,{style:{padding:"10px 20px",display:"flex",justifyContent:"space-between"},children:[se.jsx(ga,{disabled:I&&!((me=a==null?void 0:a.systems)!=null&&me.length),checkedChildren:s.formatMessage({id:"playground.pageEditor.preview"}),unCheckedChildren:s.formatMessage({id:"playground.pageEditor.layout"}),checked:!I,onChange:He=>{H(!He),He&&M&&R(!1)}}),I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsx(kt,{icon:se.jsx(Rh,{}),size:"small",type:M?"primary":"dashed",onClick:()=>{u(f1),R(!M)},title:s.formatMessage({id:"playground.pageEditor.selection"}),children:s.formatMessage({id:"playground.pageEditor.selection"})})]}),I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{size:"small",onClick:async He=>{await B({sheet:d})},children:s.formatMessage({id:"playground.pageEditor.startRecognition"})}),se.jsx(kt,{size:"small",icon:se.jsx(ma,{}),onClick:()=>{d.pages[e].layout=null,d.pages[e].systems=[],d.spartito=null,S(Pt(d,{modify:!0}))}})]})]}),!I&&!r&&se.jsxs(se.Fragment,{children:[se.jsx(Ki,{type:"vertical"}),se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{size:"small",onClick:async He=>{await B({sheet:d,noLayout:!0})},disabled:((_e=(Le=d.pages)==null?void 0:Le[e])==null?void 0:_e.semantics)&&((Ze=(Fe=(De=d.pages)==null?void 0:De[e])==null?void 0:Fe.systems)==null?void 0:Ze.every(He=>{var Ye;return((Ye=He.semantics)==null?void 0:Ye.length)>0})),children:s.formatMessage({id:"playground.pageEditor.recognizeSemantic"})}),se.jsx(kt,{title:s.formatMessage({id:"playground.pageEditor.clearPage"}),size:"small",icon:se.jsx(ma,{}),onClick:()=>{var He;d.pages[e].layout=null,d.pages[e].systems=[],(He=d.pages[e])==null||He.clearTokens(),d.spartito=null,S(Pt(d,{modify:!0}))}})]})]}),se.jsx(Ki,{type:"vertical"}),!n&&se.jsxs(Jt,{size:"small",children:[se.jsx(kt,{size:"small",title:s.formatMessage({id:"playground.pageEditor.moveForward"}),disabled:e===0,icon:se.jsx(Yp,{}),onClick:()=>{const He=Pt(d,{modify:!0}),Ye=He.pages.splice(e,1);He.pages.splice(e-1,0,Ye[0]),S(He)}}),se.jsx(kt,{size:"small",title:s.formatMessage({id:"playground.pageEditor.moveBackward"}),disabled:e===d.pages.length-1,icon:se.jsx(Jp,{}),onClick:()=>{const He=Pt(d,{modify:!0}),Ye=He.pages.splice(e,1);He.pages.splice(e+1,0,Ye[0]),S(He)}}),se.jsx(Af,{title:s.formatMessage({id:"playground.pageEditor.confirmDeletePage"}),okText:s.formatMessage({id:"common.confirm"}),cancelText:s.formatMessage({id:"common.cancel"}),icon:se.jsx(Mh,{}),onConfirm:async()=>{const He=Pt(d,{modify:!0});He.pages.splice(e,1),S(He)},children:se.jsx(kt,{title:s.formatMessage({id:"playground.pageEditor.deletePage"}),type:"ghost",size:"small",children:s.formatMessage({id:"playground.pageEditor.deletePage"})})},"delete")]})]})]}):null})}),oM=de.memo(iM),{Header:sM,Content:aM}=Eh,lM=/Windows/.test(navigator.userAgent)?600:240,ca=8,ua=.6,EM=e=>{var Se,Ae,ke,Pe,je,nt,ot;const t=zr(),n=hp(),r=dp(),o=de.useRef(),[s,i]=de.useState(!1),[d,S]=de.useState(""),[g,w]=pi(),[M,R]=de.useState(!1),[V,_]=de.useState(!1),[k,z]=de.useState(!1),I=de.useRef([]),[H,A]=de.useState(!1),[x,p]=Qp(),[v,y]=Y1(),[a,h]=dl(),[u,b]=pl(),[m,l]=fl(),c=de.useRef(null),f=de.useRef(null),C=de.useRef(new Sh(performance)),[T,L]=gl(),[O,P]=vh(),[F,{inc:B,dec:W,set:Q,reset:j}]=qp(90,300,10),E=de.useRef(!1),[Z]=li("Alt"),N=de.useRef({break:!1}),[K,X]=de.useState(""),[Y,oe]=de.useState({}),[ce,re]=Ih(),[fe,U]=hl(),[q,ee]=de.useState(!1),D=de.useRef(null),[$,G]=mh(),[J,ne]=de.useState([]),[me,Le]=yh(),[_e,De]=wh(),[Fe,Ze]=de.useState(null),[He,Ye]=ef(),[be,$e]=de.useState(1e3),[Ne,Ve]=de.useState({status:"idle",pass:0,remaining:0,total:0}),[et,ht]=tf(),[Re,ge]=de.useState(!1),[Ce,Te]=de.useState(!1),[Ke,Qe]=de.useState(null),[lt,ve]=kg(),Me=de.useRef(null),Oe=de.useRef(null),[Xe,it]=de.useState("mask"),[[ct,ft],[Ot,Wt],Zt]=bh(),[xe,ye]=de.useState(Object.entries(g.headers||{})),Ie=de.useMemo(()=>{var Ge,qe;const Ee=Sf.parse(window.location.search);return(Ee==null?void 0:Ee.type)==="admin"?{type:"admin",env:Ee.env,id:Ee.id,edit:Ee.edit==="1"}:{type:"user",id:(r==null?void 0:r.id)||((qe=(Ge=e==null?void 0:e.match)==null?void 0:Ge.params)==null?void 0:qe.id)}},[r,e]),Be=de.useMemo(()=>{if(Ie.type==="admin"){const Ee=location.pathname.split(":")[0],{edit:Ge,...qe}=Ie,Je=Object.entries({edit:Ge?0:1,...qe});return`${Ee}?`+Je.map(([at,At])=>`${at}=${At}`).join("&")}return null},[Ie]);Pc("s",Ee=>{if(Ee.ctrlKey||Ee.metaKey)return Ee.preventDefault(),xt(g),!1}),Pc("F9",()=>{G(!$)});const We=nf({onFiles:async(Ee,Ge)=>{var Je;const qe=Ge.dataTransfer.items;if(qe.length===1&&qe[0].webkitGetAsEntry().isDirectory){const At=qe[0].webkitGetAsEntry().createReader();async function Ct(pt){const Vt=await new Promise((St,Bt)=>{pt.readEntries(async hn=>{St(await Promise.all(hn.map(async sn=>new Promise(Zr=>sn.file(Cr=>Zr(Cr))))))},Bt)});return Vt.length>0?[...Vt,...await Ct(pt)]:Vt}S(t.formatMessage({id:"common.loading"}));const dt=await Ct(At),bt=await mf(dt);bt&&(bt.assemble(),w(bt)),S("");return}switch(Ee[0].type){case"application/zip":case"application/x-zip-compressed":case"application/json":const at=Ee[0];S(t.formatMessage({id:"common.loading"}));const At=await vf(at);At&&(At.assemble(),w(At)),S("");break;case"application/pdf":await((Je=D.current)==null?void 0:Je.onReceivePDF(Ee));break;default:console.debug("drop file type:",Ee[0].type),Ee[0].type.startsWith("image")&&await Yt(Ee)}},onUri:Ee=>console.log("uri",Ee),onText:Ee=>console.log("text",Ee)}),ut=de.useCallback(()=>g.modified,[g.modified]);de.useEffect(()=>{g.modified&&As.hash!==g.semanticHash&&(As.hash=g.semanticHash,g.spartito=null,Le(!1))},[g]),dg(ut,t.formatMessage({id:"common.beforeLeave"})),Nh("keydown",Ee=>{if(Ee.metaKey||Ee.ctrlKey){let Ge=!0;switch(Ee.code){case"Minus":y(Math.max(v/1.2,ua));break;case"Equal":y(Math.min(ca,v*1.2));break;case"Digit0":y(1);break;default:Ge=!1}Ge&&Ee.preventDefault()}}),xg(Z);const rt=()=>{f.current.play({nextFrame:()=>(c.current&&P(c.current.lookupPosition(f.current.progressTicks)),new Promise(Ee=>setTimeout(Ee,0)))})},yt=async Ee=>{if(!Ee.systems.length)return;await te(Ee);const{notation:Ge,tokenMap:qe}=Ee.spartito.perform(),Je=g.getMeasureLayout(),at=Je?Je.serialize(Ep.Full):Array(Ge.measures.length).fill(null).map((dt,bt)=>bt+1),At=Ge.toPerformingNotationWithEvents(at);At.scaleTempo({headTempo:6e7/F}),c.current=df.createFromNotation(At,qe);const Ct=f.current?f.current.progressTicks:0;f.current&&f.current.dispose(),f.current=new er.MidiPlayer(At,{cacheSpan:200,onMidi:(dt,bt)=>{let pt=null;switch(dt.subtype){case"noteOn":er.MidiAudio.noteOn(dt.channel,dt.noteNumber,dt.velocity,bt),pt=()=>{var Vt;return(Vt=dt==null?void 0:dt.ids)==null?void 0:Vt.map(St=>{const Bt=document.getElementById(St);Bt&&Bt.classList.add("notePlayOn")})};break;case"noteOff":er.MidiAudio.noteOff(dt.channel,dt.noteNumber,bt),pt=()=>{var Vt;return(Vt=dt==null?void 0:dt.ids)==null?void 0:Vt.map(St=>{const Bt=document.getElementById(St);Bt&&Bt.classList.remove("notePlayOn")})};break}pt&&C.current.appendTask(bt,pt)},onPlayFinish(){p(!1),f.current&&(f.current.progressTicks=0)},onTurnCursor(){f.current&&c.current&&P(c.current.lookupPosition(f.current.progressTicks))}}),f.current.progressTicks=Ct,E.current=!1};de.useEffect(()=>{x?(async()=>{var Ee;(!f.current||E.current)&&(E.current=!1,await yt(g)),(Ee=f.current)!=null&&Ee.isPlaying||rt()})():f.current&&f.current.pause()},[x,g]),de.useEffect(()=>{Dt(),er.MidiAudio.WebAudio.empty()&&er.MidiAudio.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>console.debug("Soundfont loaded."))},[]),de.useEffect(()=>eo.subscribe(Ve),[]),de.useEffect(()=>{Ne.status==="completed"&&Ie.id&&(Dt(),eo.reset())},[Ne.status]),de.useEffect(()=>{var Ee;switch(T){case"edit":f.current&&f.current.pause(),document.querySelectorAll(".notePlayOn").forEach(Ge=>Ge.classList.remove("notePlayOn"));break;case"play":Le(!1);{const Ge=(Ee=g==null?void 0:g.spartito)==null?void 0:Ee.headBPM;Number.isFinite(Ge)&&Q(Ge)}yt(g);break}},[T]),de.useEffect(()=>{let Ee=Ie.type==="admin"?"#":"";Ee+=Ie!=null&&Ie.edit?"✎":"",lt&&(Ee+=` ${lt}`),Ee=Ee?` ${Ee}`:"",document.title=g.title+Ee},[g,lt,Ie==null?void 0:Ie.edit]);const zt=de.useCallback(async Ee=>{var qe;if(!(c!=null&&c.current)){console.log("scheduler is null:",c==null?void 0:c.current);return}const Ge=(qe=f.current)==null?void 0:qe.isPlaying;Ge&&(f.current.pause(),await new Promise(Je=>setTimeout(Je,0)),document.querySelectorAll(".notePlayOn").forEach(Je=>Je.classList.remove("notePlayOn"))),f.current.progressTicks=c.current.lookupTick(Ee),Ge&&rt()},[]),Gt=async(Ee,Ge)=>{Ee?(await te(Ge),Ge.spartito.assignMeasureNumbers(),Ge.markVoices(Ge.spartito.makeVoiceStaves()),De(Ge.spartito.measures.map(qe=>({tickMap:qe.tickToX})))):(Ge.assemble(),De([])),w(Pt(Ge)),Le(Ee)},[Ht,Dt]=gh(async()=>{var Ee,Ge,qe,Je,at,At;try{if(!Ie.id)return Ss({title:t.formatMessage({id:"playground.newScore"})});S(t.formatMessage({id:"common.loading"}));let Ct=[],dt=null,bt;if(Ie.type==="admin"&&!Sc){const pt=await Hn(`/torch/musicSet/manage/${Ie.id}`,{params:{env:Ie.env}});Qe(pt.lastUpdate);const Vt=await jf(pt.preview);Oe.current=pt.previewKey,Me.current=Vt,bt=Ur(Vt,Xr),await jo(bt,{solutionStore:ze,onlyFetchCache:!0})}if(Ie.type==="user"&&!Sc){const pt=await Hn.get(`/api/musicSets/${Ie.id}`);let Vt=!1;try{const St=await Hn.get(`/api/scores/${Ie.id}/data`);St&&(bt=Ur(St,Xr),Vt=!0)}catch(St){console.debug("scores table not found, falling back to file:",St==null?void 0:St.message)}if(Vt||(dt=ws((Ee=pt==null?void 0:pt.content)==null?void 0:Ee.scoreURL),dt&&(bt=Ur(await(await fetch(dt)).text(),Xr))),bt)await bt.replaceImageKeys(async St=>/https?:\/\/|data:/.test(St)?ws(St):St!=null&&St.startsWith("md5:")?rf((await Fp()).omrDomain,St.replace("md5:","")):St),bt.assemble(((Ge=bt.settings)==null?void 0:Ge.semanticConfidenceThreshold)??1);else if((Je=(qe=pt==null?void 0:pt.content)==null?void 0:qe.images)!=null&&Je.length){bt=Ss({title:pt.name||t.formatMessage({id:"playground.untitledScore"})});const St=pt.content.images.map(sn=>({...sn,url:ws(sn.url)})),Bt=await Promise.all(St.map(sn=>new Promise(Zr=>{const Cr=new globalThis.Image;Cr.src=sn.url,Cr.onload=()=>Zr({width:Cr.naturalWidth,height:Cr.naturalHeight,ratio:Cr.naturalHeight/Cr.naturalWidth}),Cr.onerror=()=>Zr({width:0,height:0,ratio:0})}))),hn=Math.max(...Bt.map(sn=>sn.ratio));bt.pageSize={width:794,height:Math.round(794*hn)},bt.pages.push(...St.map((sn,Zr)=>new wc({source:{name:sn.name||`page-${Zr+1}`,size:sn.size||0,url:sn.url,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:Bt[Zr]},width:bt.pageSize.width/bt.unitSize,height:bt.pageSize.height/bt.unitSize}))),Ct=pt.tagList||[]}}if(bt){w(bt),As.hash=bt.semanticHash,me&&((at=bt.spartito)!=null&&at.regulated)?Gt(me,bt):Le(!1);try{const pt=await Hn.get(`/api/scores/${Ie.id}/issueMeasures`,{params:{offset:0,limit:1e3}});ft(((At=pt==null?void 0:pt.rows)==null?void 0:At.length)>0?Ur(pt.rows,Xr):[])}catch(pt){console.warn("failed to load issue measures:",pt),ft([])}ne(Ct||[])}else Un.error(t.formatMessage({id:"common.scoreNotFound"}));S("")}catch(Ct){console.error(Ct)}},[]),Yt=async Ee=>{var Ct,dt,bt;S(t.formatMessage({id:"common.uploadingImages"}));const Ge=Array.from(Ee).map(async pt=>{const Vt=await Gp(pt);return pt.url=Vt.url,g.pages.find(St=>St.source.url===Vt.url)?(Un.warn(t.formatMessage({id:"common.imageExists"},{name:pt.name})),null):(await jp(pt,{key:Vt.key,uploadUrl:Vt.uploadUrl}),pt)}),qe=(await Promise.all(Ge)).filter(Boolean),Je=await Promise.all(qe.map(pt=>new Promise(Vt=>{const St=new globalThis.Image;St.src=pt.url,St.onload=()=>{pt.dimensions={width:St.naturalWidth,height:St.naturalHeight},Vt(St.naturalHeight/St.naturalWidth)}}))),at=g.pageSize.height/g.pageSize.width;typeof at=="number"&&at&&Je.push(at);const At=Math.max(...Je);g.pageSize={width:794,height:Math.round(794*At)},g.pages.push(...qe.map(pt=>new wc({source:{name:pt.name,size:pt.size,url:pt.url,crop:{unit:"%",x:0,y:0,width:100,height:100},dimensions:pt.dimensions},width:g.pageSize.width/g.unitSize,height:g.pageSize.height/g.unitSize}))),(Ct=qe==null?void 0:qe[0])!=null&&Ct.name&&(g.title=qe[0].name.replace(/-*\d+\.\w+$/,"")),w(Pt(g)),S(""),(bt=(dt=o.current)==null?void 0:dt.scrollTo)==null||bt.call(dt,{left:1e5,behavior:"smooth"})};of(()=>{f.current&&f.current.dispose(),S(""),A(!1),p(!1),L("edit"),P(null),j(),w(Ss({title:t.formatMessage({id:"playground.newScore"})}))});const xt=async Ee=>{var Ge,qe;if(R(!0),delete Ee.modified,Ie.type==="admin"){const Je=JSON.parse(Me.current),at=Ee.deepCopy();delete Je.patches,delete at.patches,Je.spartito||delete at.spartito;const At=JSON.parse(JSON.stringify(at)),Ct=Tg.diff(Je,At);Ct&&(await Hn.put(`/torch/musicSet/manage/${Ie.id}/increment`,{data:{env:Ie.env,patch:Ct,key:Oe.current}}),R(!1),await Dt());try{await Hn.put(`/torch/musicSet/manage/${Ie.id}/updateScorePatches`,{data:{env:Ie.env}})}catch(dt){console.error(dt)}R(!1);return}Ee.tags=J.map(Je=>Je.name),await Ee.replaceImageKeys(async Je=>Je&&await yf(Je));try{let Je=Ee.title;const at=g.pages[0].tokens;!Je&&Array.isArray(at)&&at.length>0&&(Je=(qe=(Ge=at.filter(dt=>dt.type===mt.Text&&dt.textType==="Title").sort((dt,bt)=>bt.fontSize-dt.fontSize))==null?void 0:Ge[0])==null?void 0:qe.text),Je=Je||t.formatMessage({id:"common.untitled"});const At={name:Je,content:{images:Ee.pages.map(dt=>dt.source?{name:dt.source.name,size:dt.source.size,url:dt.source.url}:null)},tagIdList:J.map(dt=>dt.id)};let Ct;Ie.id?(await Hn.put(`/api/scores/${Ie.id}/data`,{data:Ee.toJSON()}),Ct=await Hn.put(`/api/musicSets/${Ie.id}`,{data:At})):(Ct=await Hn.post("/api/musicSets",{data:At}),await Hn.put(`/api/scores/${Ct.id}/data`,{data:Ee.toJSON()})),String(Ct==null?void 0:Ct.id)!==Ie.id&&n(`/playground/${Ct==null?void 0:Ct.id}`),w(Pt(Ee)),oo.success({placement:"bottomRight",message:t.formatMessage({id:"common.saveResult"}),description:t.formatMessage({id:"common.saveSuccess"})})}catch(Je){console.log(Je)}R(!1)},jt=async(Ee=!0)=>{_(!0);const Ge=Ur(g.toJSON(),Xr);g.tags=J.map(at=>at.name),Ee&&await Ge.replaceImageKeys(async at=>await Cf(at));const qe=new Blob([JSON.stringify(Ge.toJSON())],{type:"application/json"}),Je=Zp(qe,`${Date.now()}.json`);to(Je,`${Ge.title}-${Date.now()}.json`,Je.type),_(!1)},Rt=async Ee=>{_(!0),await te(Ee);const Ge=new Hf({score:g,...g.makeMusicSheet(),workTitle:Ee.title}).toString();to(Ge,`${Ee.title}-${Date.now()}.xml`,"application/xml"),_(!1)},Kt=async Ee=>{_(!0);const Ge=Ee.makeMusicSheet(),qe=await A3(Ge);to(qe,`${Ge.title}-${Date.now()}.ly`,"text/lilypond-source"),_(!1)},Gn=async Ee=>{var Ge;try{_(!0),Ee.assemble(((Ge=Ee.settings)==null?void 0:Ge.semanticConfidenceThreshold)??1),(!Ee.spartito||!Ee.spartito.regulated)&&await te(Ee);const qe=Ee.makeMusicSheet(),Je=$g(qe),at=s3(Je);to(at,`${qe.title}-${Date.now()}.lyl`,"text/plain")}catch(qe){Un.error((qe==null?void 0:qe.message)||t.formatMessage({id:"common.exportFailed"}))}finally{_(!1)}},zn=async()=>{await te(g),await bf(g)},kn=async()=>{var Ge,qe;z(!0),N.current.break=!1;const Ee=Pt(g);for await(const[Je,at]of I.current.entries()){if(N.current.break){(Ge=at==null?void 0:at.break)==null||Ge.call(at);break}await((qe=at==null?void 0:at.predict)==null?void 0:qe.call(at,Ee))}z(!1),N.current.break||(Ie.id&&eo.prepare(Ie.id),await xt(Ee),Ie.id&&eo.startRegulation(Ie.id)),N.current.break=!1};kh(async()=>{Ie.type==="user"&&g.modified&&await xt(g)},12e3,[g]);const jn=de.useCallback(Wf(Ee=>{g.resetPageLayout(Ee),w(Pt(g,{modify:!0}))},300),[g]),ze=de.useMemo(()=>Ie.type==="admin"?new Lf:new Tf,[Ie]);window.solutionStore=ze;const te=Ee=>{if(!Ee.spartito||!Ee.spartito.regulated)return jo(Ee,{policy:He,quota:be,solutionStore:ze,onProgress:Ge=>{Ze(Ge),Ge===100&&Ze(null)}})},le=async()=>{Te(!0);try{const Ge=await(await fetch(new URL("/regulate-score",location.origin).toString(),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify({score:g})})).json();if(Ge.code!==0)throw new Error(Ge.message||"Regulation failed");const qe=Ur(Ge.data.score,Xr);w(Pt(qe,{modify:!0}))}catch(Ee){console.error("[callRegulator]",Ee)}Te(!1)},ae=async()=>{var Ge;(Ge=g.spartito)!=null&&Ge.regulated||await jo(g,{forceUpdate:!1,solutionStore:ze,policy:He,quota:be,onProgress:qe=>{Ze(qe),qe===100&&Ze(null)}});const Ee=g.blackoutFakeNotes(et);console.debug("black out semantics:",Ee),g.assemble()},he=async()=>{if(!g.spartito||!g.spartito.regulated){alert(t.formatMessage({id:"playground.regulation.notCompleted"}));return}ge(!0);const Ee=[].concat(...g.spartito.measures.map(Je=>(g.assignBackgroundForMeasure(Je),Je.createClusters()))).filter(Je=>Je.regular),Ge=new zp({clusters:Ee});console.log("cluster set:",Ge);const qe=await fetch(new URL(`/api/score/${Ie.id}`,location.origin).toString());if(qe!=null&&qe.ok){const Je=await qe.json();if(Je!=null&&Je.data){console.warn("ClusterSet with this ID has been created:",Ie.id),oo.warn({placement:"bottomRight",message:t.formatMessage({id:"playground.export.topologyFailed"}),description:`${t.formatMessage({id:"playground.export.topologyExists"})}:${Ie.id}`}),ge(!1);return}}await fetch(new URL(`/api/score/${Ie.id}`,location.origin).toString(),{method:"POST",mode:"cors",headers:{"Content-Type":"application/json;charset=utf-8"},body:JSON.stringify({name:g.title,measures:Ee.map((Je,at)=>({index:at,cluster:Je}))})}),console.log("ClusterSet created:",Ie.id),oo.success({placement:"bottomRight",message:t.formatMessage({id:"playground.export.topology"}),description:t.formatMessage({id:"playground.export.topologySuccess"})}),ge(!1)},ie=de.useMemo(()=>{var Ee,Ge,qe,Je;return((Ge=(Ee=g.spartito)==null?void 0:Ee.measures)==null?void 0:Ge.length)>0?se.jsx(pa,{title:Zt?se.jsx("div",{children:se.jsxs(Jt,{size:20,children:[se.jsxs("div",{children:[t.formatMessage({id:"playground.measure"}),"#",(Zt==null?void 0:Zt.measureIndex)+1]}),se.jsx("div",{children:(Je=(qe=Zt.measure.basics)==null?void 0:qe[0])!=null&&Je.timeSignature?Object.values(Zt.measure.basics[0].timeSignature).join("/")+t.formatMessage({id:"playground.beat"}):""}),se.jsx(ga,{checked:Xe==="mask",onChange:at=>it(Xe==="mask"?"origin":"mask"),checkedChildren:t.formatMessage({id:"playground.background"}),unCheckedChildren:t.formatMessage({id:"common.originalImage"})})]})}):null,open:!!Zt,closable:!0,footer:null,mask:!0,width:"98vw",onClose:()=>Wt(null),children:Zt?se.jsx(Eb,{bgMode:Xe,style:{width:"300px"},score:g,record:Zt,onClose:()=>Wt(null)}):null}):null},[g,Zt,Xe]),ue=de.useMemo(()=>se.jsx(g1,{title:t.formatMessage({id:"playground.regulation"}),zIndex:2e3,open:Fe!==null,closable:!1,footer:null,mask:!0,style:{display:"flex",justifyContent:"center",alignItems:"center",width:"200px",height:"200px"},children:se.jsx(fa,{type:"circle",strokeColor:{"0%":"#108ee9","100%":"#87d068"},percent:Fe??0})}),[Fe]),pe=de.useMemo(()=>se.jsx(g1,{title:se.jsxs("span",{children:[t.formatMessage({id:"playground.selectTrackTemplate"})," ",se.jsx(yl,{checked:q,onChange:Ee=>ee(!q),style:{color:"#999999"},children:t.formatMessage({id:"playground.showAllTemplates"})})]}),zIndex:2e3,open:fe,onOk:()=>{U(!1)},forceRender:!0,onCancel:()=>U(!1),footer:null,children:se.jsx(Rb,{score:g,showAll:q,onChange:Ee=>{g.staffLayoutCode=Ee.staffLayoutCode,g.instrumentDict=Ee.instrumentDict,w(Pt(g,{modify:!0})),U(!1),oe(Ee.instrumentDict),X(Ee.staffLayoutCode)}})}),[g,q,fe]),we=de.useMemo(()=>se.jsx(g1,{title:t.formatMessage({id:"playground.editTrack"}),zIndex:2e3,open:ce,okText:t.formatMessage({id:"common.confirm"}),cancelText:t.formatMessage({id:"common.cancel"}),onOk:()=>{g.staffLayoutCode=K,g.instrumentDict=Y,w(Pt(g,{modify:!0})),re(!1)},forceRender:!0,onCancel:()=>re(!1),okButtonProps:{disabled:!1},children:se.jsx(Tb,{staffLayoutCode:g.staffLayoutCode,instrumentDict:g.instrumentDict,onChange:Ee=>{X(Ee.staffLayoutCode),oe(Ee.instrumentDict)}})}),[g,ce,K,Y]);return se.jsx(ul.Provider,{value:Ie,children:se.jsxs(se.Fragment,{children:[se.jsxs("svg",{width:"0",height:"0",style:{position:"absolute",visibility:"hidden"},children:[se.jsx(Gf,{}),se.jsxs("defs",{children:[se.jsx("path",{id:"svg-icon-exclamation",d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8zm475.7 440l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z",transform:"scale(0.003)",color:"orange"}),se.jsxs("g",{id:"svg-icon-info",transform:"scale(0.003)",color:"green",children:[se.jsx("path",{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"}),se.jsx("path",{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"})]})]})]}),se.jsx(S1,{spinning:!!d,tip:d,style:{backgroundColor:We.over?"red":"initial"},children:se.jsxs(Eh,{className:vt({[Nn.playground]:!0,[Nn.hover]:s}),style:{height:"100vh",overflow:"hidden",display:"flex",flexDirection:"column"},onDragOver:Ee=>{Ee.preventDefault(),i(s)},onDragLeave:()=>i(!1),children:[se.jsx(sM,{className:vt(Nn.header,{[Nn[Ie.type]]:!0,[Nn.edit]:Ie==null?void 0:Ie.edit}),children:se.jsxs(q1,{style:{width:"100%",display:"flex",justifyContent:"space-between"},gutter:16,children:[se.jsxs(Sr,{style:{display:"flex",alignItems:"center"},children:[se.jsx(zc,{to:Ie.type==="admin"?"/admin/":"/",className:Nn.logo,onClick:()=>G(!1),children:"STARRY"}),se.jsx(sf,{placeholder:t.formatMessage({id:"playground.titlePlaceholder"}),defaultValue:t.formatMessage({id:"playground.defaultTitle"}),style:{height:"30px"},value:g==null?void 0:g.title,onChange:Ee=>{const Ge=Pt(g,{modify:!0});Ge.title=Ee.target.value,w(Ge)}})]}),Ke&&se.jsxs(Sr,{className:Nn.updateTime,children:[se.jsx("em",{children:Ke})," ",t.formatMessage({id:"playground.lastUpdate"}),se.jsx(kt,{size:"small",type:"link",icon:se.jsx(_c,{spin:Ht.loading}),onClick:Dt})]}),se.jsxs(Sr,{children:[T==="edit"&&se.jsx(kt,{title:t.formatMessage({id:"playground.switchToPlay"}),disabled:!((Se=g==null?void 0:g.pages)!=null&&Se.length),style:{verticalAlign:"middle",color:"#999999"},icon:se.jsx(ff,{}),onClick:()=>{if(!g.pages.some(Ee=>{var Ge;return((Ge=Ee.systems)==null?void 0:Ge.length)>0})){Un.warn(t.formatMessage({id:"playground.recognizeFirst"}));return}L("play")}}),T==="play"&&se.jsx(kt,{title:t.formatMessage({id:"playground.switchToEdit"}),disabled:!((Ae=g==null?void 0:g.pages)!=null&&Ae.length),style:{verticalAlign:"middle",color:"#999999"},icon:se.jsx(xf,{}),onClick:()=>{L("edit"),p(!1)}})]}),T==="play"&&se.jsxs(Jt,{style:{flex:1,paddingLeft:"10px"},children:[se.jsx(af,{title:t.formatMessage({id:"playground.goToStart"}),className:Nn.playControlBtn,onClick:()=>zt({system:0,x:0})}),x?se.jsx(gf,{title:t.formatMessage({id:"common.pause"}),className:vt(Nn.playControlBtn,{[Nn.playControlBtnActive]:x}),onClick:()=>{p(!x)}}):se.jsx(lf,{title:t.formatMessage({id:"common.play"}),className:Nn.playControlBtn,onClick:()=>{p(!x)}}),se.jsxs("div",{children:["𝅘𝅥 =",se.jsx("input",{value:F,style:{padding:"0 5px",display:"inline",border:"none",width:"50px"},type:"number",step:10,onChange:Ee=>{Q(+Ee.target.value),E.current=!0}})]})]}),T==="edit"&&Ie.type!=="admin"&&se.jsx(Sr,{style:{flex:1},children:se.jsx(cf,{ref:D,onChange:Yt})}),Ie.type==="admin"&&se.jsx(Sr,{children:se.jsxs(zc,{to:Be,children:["#",Ie.edit?t.formatMessage({id:"playground.preview"}):t.formatMessage({id:"playground.edit"})]})}),se.jsxs(Jt,{style:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[se.jsxs(kt.Group,{size:"small",children:[se.jsx(kt,{type:m?"primary":"ghost",onClick:()=>{l(!m)},children:t.formatMessage({id:"common.originalImage"})}),se.jsx(kt,{type:u?"primary":"ghost",onClick:()=>{b(!u)},children:t.formatMessage({id:"common.symbols"})}),se.jsx(kt,{type:a?"primary":"ghost",onClick:()=>{h(!a)},children:t.formatMessage({id:"playground.semanticDots"})}),se.jsx(kt,{type:me?"primary":"ghost",onClick:()=>Gt(!me,g),children:t.formatMessage({id:"playground.verify"})})]}),T==="edit"&&Ie.type!=="admin"&&se.jsx(kt,{icon:k?se.jsx(xc,{}):se.jsx(Vh,{}),onClick:async()=>{k?(N.current.break=!0,I.current.forEach(Ee=>{var Ge;(Ge=Ee.break)==null||Ge.call(Ee)})):await kn()},children:k?N.current.break?t.formatMessage({id:"playground.stoppingRecognition"}):t.formatMessage({id:"playground.stopRecognition"}):t.formatMessage({id:"playground.recognizeAll"})}),T==="edit"&&Ie.type!=="admin"&&se.jsx(kt,{size:"small",icon:se.jsx(ma,{}),onClick:()=>{g.pages.forEach(Ee=>{Ee.layout=null,Ee.rotation=null,Ee.systems=[]});for(const[Ee,Ge]of I.current.entries())Ge.setLayoutMode(!0);w(Pt(g))}}),se.jsxs(kt.Group,{children:[se.jsxs(kt,{icon:se.jsx(uf,{}),loading:M,onClick:()=>xt(g),disabled:!((ke=g==null?void 0:g.pages)!=null&&ke.length)&&(Ie.type!=="admin"||Ie.edit),children:[M?t.formatMessage({id:"common.saving"}):t.formatMessage({id:"common.save"})," ",g.modified?"*":""]}),se.jsx(da.Button,{disabled:!((Pe=g==null?void 0:g.pages)!=null&&Pe.length),icon:V?se.jsx(xc,{}):se.jsx(Rf,{}),trigger:["click"],menu:{items:[{key:"json",label:`${t.formatMessage({id:"playground.export"})} JSON`},{key:"json_noimg",label:`${t.formatMessage({id:"playground.export"})} JSON (${t.formatMessage({id:"playground.export.noImage"})})`},{key:"xml",label:`${t.formatMessage({id:"playground.export"})} MusicXML`},{key:"ly",label:`${t.formatMessage({id:"playground.export"})} LilyPond`},{key:"lyl",label:`${t.formatMessage({id:"playground.export"})} Lilylet`},{key:"find",label:`${t.formatMessage({id:"playground.export"})} Find Score`}],onClick:async Ee=>{switch(Ee.key){case"xml":await Rt(g);break;case"json":await jt();break;case"json_noimg":await jt(!1);break;case"find":await zn();break;case"ly":await Kt(g);break;case"lyl":await Gn(g);break}}}})]}),se.jsx(kt,{title:t.formatMessage({id:"playground.globalConfig"}),icon:se.jsx(Bf,{}),onClick:()=>{A(!0)}}),se.jsx(Vf,{id:Ie.id,tagList:J,onChange:Ee=>ne(Ee)}),se.jsx(kt,{title:t.formatMessage({id:"playground.annotation"}),icon:se.jsx(m4,{}),onClick:()=>{G(!$)}}),se.jsx(kt,{title:t.formatMessage({id:"playground.export.topology"}),icon:se.jsx(Rh,{}),loading:Re,onClick:he}),se.jsx(kt,{title:`${t.formatMessage({id:"playground.regulation"})} (Ctrl+click: ${t.formatMessage({id:"playground.regulation.backend"})})`,type:(je=g.spartito)!=null&&je.regulated?"primary":"default",icon:Ne.status==="regulating"||Ne.status==="connecting"?se.jsx(_c,{spin:!0}):se.jsx(Vc,{}),onClick:Ee=>{var Ge;(Ge=g.spartito)!=null&&Ge.regulated?(g.spartito=null,Le(!1),w(Pt(g,{modify:!0}))):Ee.ctrlKey&&Ie.id?eo.startRegulation(Ie.id):jo(g,{forceUpdate:Z,solutionStore:ze,policy:He,quota:be,onProgress:qe=>{Ze(qe),qe===100&&Ze(null)}})},children:Ne.status==="regulating"?Ne.total>0?`${Ne.total-Ne.remaining}/${Ne.total}`:"...":null}),se.jsx(Mf,{})]})]})}),se.jsx(aM,{style:{flex:1,flexShrink:0,paddingRight:$?"50%":"0",overflow:"scroll"},onWheel:Ee=>{if(Ee.altKey){let Ge=v*Math.exp(-Ee.deltaY/lM);Ge=Math.min(Math.max(Ge,ua),ca),y(Ge)}},children:(nt=g==null?void 0:g.pages)!=null&&nt.length?se.jsx(Jt,{wrap:!0,style:{padding:"8px"},children:(ot=g==null?void 0:g.pages)==null?void 0:ot.map((Ee,Ge)=>{var qe;return se.jsx(oM,{ref:Je=>{I.current[Ge]=Je},pageIndex:Ge,onSeekPosition:zt,disableScoreLevelControls:Ie.type==="admin",disableRecognization:Ie.type==="admin"&&!Ie.edit},((qe=Ee.source)==null?void 0:qe.url)||`page-${Ge}`)})}):se.jsx(Ef,{style:{marginTop:"200px"},description:t.formatMessage({id:"playground.empty"})})})]})}),se.jsxs(Jt,{className:Nn.zoomControl,direction:"horizontal",children:[se.jsx(Hc,{title:`${t.formatMessage({id:"playground.zoomOut"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + -)`,onClick:()=>y(Math.max(v/1.2,ua)),size:36}),se.jsxs("div",{title:`${t.formatMessage({id:"playground.zoomReset"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + 0)`,className:Nn.percentText,onClick:()=>y(1),children:[Math.round(v*100),"%"]}),se.jsx(_f,{title:`${t.formatMessage({id:"playground.zoomIn"})}(${t.formatMessage({id:"playground.shortcut"})} Ctrl + +)`,onClick:()=>y(Math.min(ca,v*1.2)),size:36})]}),se.jsx(pa,{title:t.formatMessage({id:"playground.globalConfig"}),width:300,closeIcon:se.jsx(Wp,{}),onClose:()=>{A(!1)},open:H,children:se.jsxs(Ln,{layout:"horizontal",size:"small",initialValues:g.settings,onValuesChange:(Ee,Ge)=>{g.settings=Ge,w(Pt(g))},children:[se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.layoutMethod"}),name:"pageLayoutMethod",children:se.jsxs(qn.Group,{buttonStyle:"solid",children:[se.jsx(qn.Button,{value:"ByBlocks",children:t.formatMessage({id:"playground.layoutByBlocks"})}),se.jsx(qn.Button,{value:"ByLines",children:t.formatMessage({id:"playground.layoutByLines"})})]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.enableDistortionCorrection"}),name:"enabledGauge",valuePropName:"checked",children:se.jsx(ga,{})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.semanticThreshold"}),name:"semanticConfidenceThreshold",valuePropName:"value",children:se.jsx(Ff,{step:.1,min:0,max:2,onAfterChange:Ee=>{const Ge=Pt(g,{modify:!0});Ge.assemble(Ee),w(Ge)}})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.track"}),children:se.jsxs("div",{children:[se.jsx(kt,{title:t.formatMessage({id:"playground.selectTemplate"}),style:{margin:"0 10px"},onClick:()=>{U(!0)},children:(()=>{const Ee=B5.find(Ge=>Ge.code===g.staffLayoutCode);return Ee?t.formatMessage({id:Ee.nameKey}):t.formatMessage({id:"playground.custom"})})()}),se.jsx(hf,{title:t.formatMessage({id:"playground.edit"}),style:{color:"#1890ff"},onClick:()=>{re(!0),X(g.staffLayoutCode)}})]})}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:["Headers:",xe.map(([Ee,Ge],qe)=>se.jsxs(Jt,{align:"baseline",children:[se.jsx(Tc,{style:{width:"120px"},placeholder:"Key",options:[{label:`title(${t.formatMessage({id:"playground.metadata.title"})})`,value:"title"},{value:"subtitle"},{label:`composer(${t.formatMessage({id:"playground.metadata.composer"})})`,value:"composer"},{label:`lyricist(${t.formatMessage({id:"playground.metadata.lyricist"})})`,value:"lyricist"},{label:`arranger(${t.formatMessage({id:"playground.metadata.arranger"})})`,value:"arranger"},{label:`copyright(${t.formatMessage({id:"playground.metadata.copyright"})})`,value:"copyright"},{label:`dedication(${t.formatMessage({id:"playground.metadata.credits"})})`,value:"dedication"},{value:"work-title"},{value:"creator"},{value:"rights"},{value:"source"},{value:"relation"},{value:"subsubtitle"},{value:"opus"}],filterOption:(Je,at)=>at.value.toUpperCase().indexOf(Je.toUpperCase())!==-1,onChange:Je=>{xe[qe]=[Je,Ge],ye([...xe])},onBlur:()=>{g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}}),se.jsx(Tc,{style:{width:"120px"},placeholder:"Value",options:[].concat(...g.pages.map(Je=>Je.tokens)).map(Je=>({value:Je.text})),filterOption:(Je,at)=>at.value.toUpperCase().indexOf(Je.toUpperCase())!==-1,onChange:Je=>{xe[qe]=[Ee,Je],ye([...xe])},onBlur:()=>{g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}}),se.jsx(Hc,{onClick:()=>{xe.splice(qe,1),ye([...xe]),g.headers=xe.reduce((Je,[at,At])=>({...Je,[at]:At}),{}),w(Pt(g,{modify:!0}))}})]},qe)),se.jsx(Ln.Item,{children:se.jsx(kt,{type:"dashed",block:!0,icon:se.jsx(zh,{}),onClick:()=>{ye([...xe,[null,null]])},children:t.formatMessage({id:"playground.metadata.addField"})})}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.pageSettings"}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.paper"}),children:se.jsxs(Jt,{children:[se.jsx(Hr,{defaultValue:g.pageSize.width,type:"number",step:10,onChange:Ee=>{jn({pageSize:Object.assign({},g.pageSize,{width:+Ee.target.value})})}}),"px",se.jsx("span",{children:"×"}),se.jsx(Hr,{defaultValue:g.pageSize.height,type:"number",step:10,onChange:Ee=>{jn({pageSize:Object.assign({},g.pageSize,{height:+Ee.target.value})})}}),"px"]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.font"}),children:se.jsxs(Jt,{children:[se.jsx(Hr,{defaultValue:g.unitSize,type:"number",step:.1,onChange:Ee=>{jn({unitSize:+Ee.target.value})}}),"px"]})})]}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.regulation"}),":",se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.regulation.strategy"}),children:se.jsxs(qn.Group,{value:He,onChange:Ee=>{var Ge;(Ge=g.spartito)==null||Ge.cleanupRegulation(),Ye(Ee.target.value),Le(!1)},children:[se.jsx(qn.Button,{value:"equations",children:"Equations"}),se.jsx(qn.Button,{value:"simple",children:"Simple"}),se.jsx(qn.Button,{value:"test",children:"Test"})]})}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.regulation.quota"}),children:se.jsx(Hr,{defaultValue:be,type:"number",step:100,onChange:Ee=>{var Ge;(Ge=g.spartito)==null||Ge.cleanupRegulation(),$e(+Ee.target.value),Le(!1)}})}),se.jsx(Ln.Item,{children:se.jsx(kt,{icon:se.jsx(Vc,{}),onClick:le,loading:Ce,children:"call regulator"})})]}),se.jsxs(Jt,{direction:"vertical",size:10,style:{width:"100%"},children:[t.formatMessage({id:"playground.cleanFalseNoteheads"}),se.jsx(Ln.Item,{label:t.formatMessage({id:"playground.cleanScope"}),children:se.jsxs(qn.Group,{value:et,onChange:Ee=>{ht(Ee.target.value)},children:[se.jsx(qn.Button,{value:"patched",children:t.formatMessage({id:"playground.cleanAnnotated"})}),se.jsx(qn.Button,{value:"perfect",children:t.formatMessage({id:"playground.cleanCorrect"})}),se.jsx(qn.Button,{value:"all",children:t.formatMessage({id:"playground.cleanAll"})})]})}),se.jsx(Ln.Item,{children:se.jsx(kt,{icon:se.jsx(J4,{}),onClick:ae,children:"cleanup"})})]})]}),se.jsx(Ln.Item,{children:se.jsx(Hh,{title:"inspect spartito evaluation",style:{cursor:"pointer"},onClick:()=>{var Ee;return(Ee=g.spartito)==null?void 0:Ee.dumpEvaluations()}})})]})}),se.jsx(B9,{}),we,pe,ue,ie]})})};export{EM as default}; diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1b71361026ba5b0568407430837d81857982530a..57c6c79dd6ff2be1594fdf0027571562064fef48 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -20,6 +20,206 @@ done /usr/lib/postgresql/15/bin/psql -h 127.0.0.1 -p 5432 -tc "SELECT 1 FROM pg_database WHERE datname='starry_omr'" | grep -q 1 || \ /usr/lib/postgresql/15/bin/createdb -h 127.0.0.1 -p 5432 starry_omr +# ── Model path resolution from models.yaml ── +MODELS_BASE="/home/node/app/models" +MODELS_YAML="$MODELS_BASE/starry-dist/models.yaml" +HF_REPO="k-l-lambda/starry" + +CURL_PROXY="" +if [ -n "$https_proxy" ]; then + CURL_PROXY="-x $https_proxy" +fi + +# Download models.yaml from HuggingFace if not present locally +if [ ! -f "$MODELS_YAML" ] && [ -n "$HF_TOKEN" ]; then + echo "Downloading models.yaml from HuggingFace..." + mkdir -p "$MODELS_BASE/starry-dist" + curl -sfL $CURL_PROXY \ + -H "Authorization: Bearer $HF_TOKEN" \ + -o "$MODELS_YAML" \ + "https://huggingface.co/${HF_REPO}/resolve/main/starry-dist/models.yaml?download=true" +fi + +# Parse models.yaml and set env vars (only if not already set) +if [ -f "$MODELS_YAML" ]; then + echo "Parsing model paths from models.yaml..." + + # Helper: extract a field value under a section + yaml_get() { + sed -n "/^${1}:/,/^[a-z]/{ /^ ${2}:/{ s/.*${2}: *//; p; } }" "$MODELS_YAML" | head -1 + } + + # bdtopo (ONNX model for regulation) + if [ -z "$BDTOPO_MODEL_PATH" ]; then + _bdtopo_path=$(yaml_get bdtopo path) + _bdtopo_default=$(yaml_get bdtopo default) + if [ -n "$_bdtopo_path" ] && [ -n "$_bdtopo_default" ]; then + export BDTOPO_MODEL_PATH="$MODELS_BASE/starry-dist/$_bdtopo_path/$_bdtopo_default" + echo " BDTOPO_MODEL_PATH=$BDTOPO_MODEL_PATH" + fi + fi + + # PyTorch predictors (starry-dist) + if [ -z "$LAYOUT_MODEL_PATH" ]; then + export LAYOUT_MODEL_PATH=$(yaml_get layout path) + echo " LAYOUT_MODEL_PATH=$LAYOUT_MODEL_PATH" + fi + if [ -z "$MASK_MODEL_PATH" ]; then + export MASK_MODEL_PATH=$(yaml_get mask path) + echo " MASK_MODEL_PATH=$MASK_MODEL_PATH" + fi + if [ -z "$SEMANTIC_MODEL_PATH" ]; then + export SEMANTIC_MODEL_PATH=$(yaml_get semantic path) + echo " SEMANTIC_MODEL_PATH=$SEMANTIC_MODEL_PATH" + fi + if [ -z "$GAUGE_MODEL_PATH" ]; then + export GAUGE_MODEL_PATH=$(yaml_get gauge path) + echo " GAUGE_MODEL_PATH=$GAUGE_MODEL_PATH" + fi + + # OCR predictors (ocr-dist) + if [ -z "$LOC_MODEL_PATH" ]; then + export LOC_MODEL_PATH=$(yaml_get loc path) + echo " LOC_MODEL_PATH=$LOC_MODEL_PATH" + fi + if [ -z "$OCR_CONFIG" ]; then + export OCR_CONFIG=$(yaml_get ocr config) + echo " OCR_CONFIG=$OCR_CONFIG" + fi + if [ -z "$BRACKETS_CONFIG" ]; then + export BRACKETS_CONFIG=$(yaml_get brackets config) + echo " BRACKETS_CONFIG=$BRACKETS_CONFIG" + fi +fi + +# ── Download model files from HuggingFace ── +hf_download() { + local subdir="$1" + local relpath="$2" + local dest="$MODELS_BASE/$subdir/$relpath" + + if [ -z "$relpath" ]; then return; fi + if [ -e "$dest" ]; then + echo " $subdir/$relpath already present, skipping." + return + fi + + echo " Downloading $subdir/$relpath ..." + mkdir -p "$(dirname "$dest")" + curl -sfL $CURL_PROXY \ + -H "Authorization: Bearer $HF_TOKEN" \ + -o "$dest" \ + "https://huggingface.co/${HF_REPO}/resolve/main/${subdir}/${relpath}?download=true" + if [ $? -eq 0 ] && [ -f "$dest" ]; then + echo " $subdir/$relpath downloaded OK." + else + echo " WARNING: Failed to download $subdir/$relpath" + rm -f "$dest" + fi +} + +if [ -n "$HF_TOKEN" ] && [ -f "$MODELS_YAML" ]; then + echo "Downloading model files from HuggingFace..." + + # Download bdtopo ONNX models + if [ -n "$BDTOPO_MODEL_PATH" ] && [ ! -f "$BDTOPO_MODEL_PATH" ]; then + _bdtopo_path=$(yaml_get bdtopo path) + _bdtopo_dir="$MODELS_BASE/starry-dist/$_bdtopo_path" + mkdir -p "$_bdtopo_dir" + + sed -n '/^ files:/,/^[^ ]/{ /^ *- /p }' "$MODELS_YAML" | sed 's/^ *- *//' | while read -r FILE; do + hf_download "starry-dist" "$_bdtopo_path/$FILE" + done + fi + + # Download PyTorch model directories (starry-dist) + for model_var in LAYOUT_MODEL_PATH MASK_MODEL_PATH SEMANTIC_MODEL_PATH GAUGE_MODEL_PATH; do + eval model_path=\$$model_var + if [ -n "$model_path" ]; then + # Download .state.yaml which lists the actual model files + hf_download "starry-dist" "$model_path/.state.yaml" + + state_yaml="$MODELS_BASE/starry-dist/$model_path/.state.yaml" + if [ -f "$state_yaml" ]; then + # Extract model filename from .state.yaml + model_file=$(sed -n 's/^file: *//p' "$state_yaml" | head -1) + if [ -n "$model_file" ]; then + hf_download "starry-dist" "$model_path/$model_file" + fi + # Extract sub-model files if present (semantic clusters) + sed -n '/^subs:/,/^[a-z]/{ /^ - /p }' "$state_yaml" | sed 's/^ *- *//' | while read -r sub; do + if [ -n "$sub" ]; then + hf_download "starry-dist" "$model_path/$sub/.state.yaml" + sub_state="$MODELS_BASE/starry-dist/$model_path/$sub/.state.yaml" + if [ -f "$sub_state" ]; then + sub_file=$(sed -n 's/^file: *//p' "$sub_state" | head -1) + if [ -n "$sub_file" ]; then + hf_download "starry-dist" "$model_path/$sub/$sub_file" + fi + fi + fi + done + fi + fi + done + + # Download OCR/TF models (ocr-dist) — these use config YAML files + for config_var in LOC_MODEL_PATH OCR_CONFIG BRACKETS_CONFIG; do + eval config_path=\$$config_var + if [ -n "$config_path" ]; then + # For loc, the path is a directory; for ocr/brackets, it's a YAML config + if echo "$config_path" | grep -q '\.yaml$\|\.yml$'; then + # Download the config YAML + hf_download "ocr-dist" "$config_path" + config_file="$MODELS_BASE/ocr-dist/$config_path" + if [ -f "$config_file" ]; then + # Extract model paths from the config + sed -n 's/^ *model_path: *//p' "$config_file" | while read -r mpath; do + if [ -n "$mpath" ]; then + # Download all files in the model directory + _dir=$(dirname "$config_path") + hf_download "ocr-dist" "$_dir/$mpath" + fi + done + fi + else + # Directory-based model (loc) — download .state.yaml and model file + hf_download "ocr-dist" "$config_path/.state.yaml" + state_yaml="$MODELS_BASE/ocr-dist/$config_path/.state.yaml" + if [ -f "$state_yaml" ]; then + model_file=$(sed -n 's/^file: *//p' "$state_yaml" | head -1) + if [ -n "$model_file" ]; then + hf_download "ocr-dist" "$config_path/$model_file" + fi + fi + fi + fi + done + + echo "Model download complete." +fi + +# ── Set predictor addresses (internal ZMQ) ── +export PREDICTOR_LAYOUT="${PREDICTOR_LAYOUT:-tcp://127.0.0.1:12022}" +export PREDICTOR_GAUGE="${PREDICTOR_GAUGE:-tcp://127.0.0.1:12023}" +export PREDICTOR_GAUGE_RENDERER="${PREDICTOR_GAUGE_RENDERER:-tcp://127.0.0.1:15656}" +export PREDICTOR_MASK="${PREDICTOR_MASK:-tcp://127.0.0.1:12024}" +export PREDICTOR_SEMANTIC="${PREDICTOR_SEMANTIC:-tcp://127.0.0.1:12025}" +export PREDICTOR_LOC="${PREDICTOR_LOC:-tcp://127.0.0.1:12026}" +export PREDICTOR_OCR="${PREDICTOR_OCR:-tcp://127.0.0.1:12027}" +export PREDICTOR_BRACKETS="${PREDICTOR_BRACKETS:-tcp://127.0.0.1:12028}" + +# ── Start Python ML predictors via supervisord ── +if [ -f /home/node/app/supervisord.conf ] && [ -d /home/node/app/backend/python-services ]; then + if [ -n "$LAYOUT_MODEL_PATH" ]; then + echo "Starting Python ML predictors via supervisord..." + supervisord -c /home/node/app/supervisord.conf & + sleep 2 + else + echo "Skipping ML predictors (no model paths configured)." + fi +fi + # ── Run database migrations ── echo 'Running database migrations...' cd /home/node/app/backend/omr-service @@ -40,7 +240,7 @@ export DB_PORT=5432 export DB_NAME=starry_omr export DB_USER=node export DB_PASSWORD= -export REGULATION_ENABLED=false +export REGULATION_ENABLED=${REGULATION_ENABLED:-true} npx tsx src/index.ts & # Wait for omr-service to be ready diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000000000000000000000000000000000000..fbdbe57455bf2da90ff94220463c58aebeb813d3 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,91 @@ +[supervisord] +nodaemon=true +logfile=/home/node/log/supervisor/supervisord.log +pidfile=/home/node/run/supervisord.pid +user=node + +[unix_http_server] +file=/home/node/run/supervisor.sock + +[supervisorctl] +serverurl=unix:///home/node/run/supervisor.sock + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +; ── PyTorch predictors (CPU) ── + +[program:layout] +command=python3 main.py -m layout -w /home/node/app/models/starry-dist/%(ENV_LAYOUT_MODEL_PATH)s -p 12022 -dv cpu +directory=/home/node/app/backend/python-services +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:mask] +command=python3 main.py -m mask -w /home/node/app/models/starry-dist/%(ENV_MASK_MODEL_PATH)s -p 12024 -dv cpu +directory=/home/node/app/backend/python-services +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:semantic] +command=python3 main.py -m semantic -w /home/node/app/models/starry-dist/%(ENV_SEMANTIC_MODEL_PATH)s -p 12025 -dv cpu --config config/semantic.yaml +directory=/home/node/app/backend/python-services +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:gauge] +command=python3 main.py -m gauge -w /home/node/app/models/starry-dist/%(ENV_GAUGE_MODEL_PATH)s -p 12023 -dv cpu +directory=/home/node/app/backend/python-services +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +; ── TensorFlow / PyTorch predictors (CPU) ── + +[program:loc] +command=python3 main.py -m loc -w /home/node/app/models/ocr-dist/%(ENV_LOC_MODEL_PATH)s -p 12026 -dv cpu +directory=/home/node/app/backend/python-services +environment=LOG_DIR="/home/node/log/supervisor" +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:ocr] +command=python3 main.py -m ocr -w /home/node/app/models/ocr-dist/%(ENV_OCR_CONFIG)s -p 12027 +directory=/home/node/app/backend/python-services +environment=CUDA_VISIBLE_DEVICES="-1",TF_USE_LEGACY_KERAS="1",LOG_DIR="/home/node/log/supervisor" +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0 + +[program:brackets] +command=python3 main.py -m brackets -w /home/node/app/models/ocr-dist/%(ENV_BRACKETS_CONFIG)s -p 12028 +directory=/home/node/app/backend/python-services +environment=CUDA_VISIBLE_DEVICES="-1",TF_USE_LEGACY_KERAS="1",LOG_DIR="/home/node/log/supervisor" +autostart=true +autorestart=true +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/fd/2 +stderr_logfile_maxbytes=0