diff options
author | Alex Yatskov <alex@foosoft.net> | 2019-12-03 18:30:22 -0800 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2019-12-03 18:30:22 -0800 |
commit | f9ea6206550ceee625ea93215a6e08d45a750086 (patch) | |
tree | 803fe11a788a631076b3fb11a98e50bb8b454396 | |
parent | 08ad2779678cd447bd747c2b155ef9b5135fdf5d (diff) | |
parent | 3975aabf4dc283d49ec46d0ed7ead982b9fa7441 (diff) |
Merge branch 'master' into testing
74 files changed, 3949 insertions, 1929 deletions
diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..0e3b939a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 8 + }, + "ignorePatterns": [ + "/ext/mixed/lib/", + "/ext/bg/js/templates.js" + ], + "rules": { + "arrow-parens": ["error", "always"], + "comma-dangle": ["error", "never"], + "curly": ["error", "all"], + "dot-notation": "error", + "eqeqeq": "error", + "no-case-declarations": "error", + "no-const-assign": "error", + "no-constant-condition": "off", + "no-undef": "off", + "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], + "no-var": "error", + "prefer-const": ["error", {"destructuring": "all"}], + "quote-props": ["error", "consistent"], + "quotes": ["error", "single", "avoid-escape"], + "require-atomic-updates": "off", + "semi": "error" + } +} @@ -236,7 +236,7 @@ other developers who want to help out. I take pride in the high quality of the c following basic guidelines when creating pull requests: * Please discuss large features before writing code. -* Follow the [conventions and style](https://raw.githubusercontent.com/FooSoft/dotfiles/master/.eslintrc.json) of the existing code. +* Follow the [conventions and style](.eslintrc.json) of the existing code. * Write clean, modern ES6 code (`const`/`let`, `await`, arrow functions, etc.) * Large pull requests without a clear scope will not be merged. * Incomplete or non-standalone features will not be merged. @@ -256,12 +256,10 @@ Yomichan uses several third-party libraries to function. Below are links to home versions packaged. * Bootstrap: [homepage](https://getbootstrap.com/) - [snapshot](https://github.com/twbs/bootstrap/releases/download/v3.3.7/bootstrap-3.3.7-dist.zip) - [license](https://github.com/twbs/bootstrap/blob/v3.3.7/LICENSE) -* Bootstrap Toggle: [homepage](https://www.bootstraptoggle.com/) - [snapshot](https://github.com/minhur/bootstrap-toggle/archive/b76c094.zip) - [license](https://github.com/minhur/bootstrap-toggle/blob/2.2.0/LICENSE) -* Dexie: [homepage](https://dexie.org/) - [snapshot](https://github.com/dfahlander/Dexie.js/archive/v2.0.0-beta.10.zip) - [license](https://github.com/dfahlander/Dexie.js/blob/v2.0.0-beta.10/LICENSE) * Handlebars: [homepage](https://handlebarsjs.com/) - [snapshot](http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars.min-714a4c4.js) - [license](https://github.com/wycats/handlebars.js/blob/v4.0.6/LICENSE) * jQuery: [homepage](https://blog.jquery.com/) - [snapshot](https://code.jquery.com/jquery-3.2.1.min.js) - [license](https://github.com/jquery/jquery/blob/3.2.1/LICENSE.txt) * JSZip: [homepage](https://stuk.github.io/jszip/) - [snapshot](https://raw.githubusercontent.com/Stuk/jszip/de7f52fbcba485737bef7923a83f0fad92d9f5bc/dist/jszip.min.js) - [license](https://github.com/Stuk/jszip/blob/v3.1.3/LICENSE.markdown) -* WanaKana: [homepage](https://wanakana.com/) - [snapshot](https://raw.githubusercontent.com/WaniKani/WanaKana/7c4a052/gh-pages/assets/js/wanakana.min.js) - [license](https://github.com/WaniKani/WanaKana/blob/2.2.3/LICENSE) +* WanaKana: [homepage](https://wanakana.com/) - [snapshot](https://unpkg.com/wanakana@4.0.2/umd/wanakana.min.js) - [license](https://github.com/WaniKani/WanaKana/blob/4.0.2/LICENSE) ## Frequently Asked Questions ## diff --git a/ext/bg/background.html b/ext/bg/background.html index 3ab68639..5a6970c3 100644 --- a/ext/bg/background.html +++ b/ext/bg/background.html @@ -14,14 +14,15 @@ <body> <div id="clipboard-paste-target" contenteditable="true"></div> - <script src="/mixed/lib/dexie.min.js"></script> <script src="/mixed/lib/handlebars.min.js"></script> <script src="/mixed/lib/jszip.min.js"></script> <script src="/mixed/lib/wanakana.min.js"></script> - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> <script src="/bg/js/anki.js"></script> + <script src="/bg/js/mecab.js"></script> <script src="/bg/js/api.js"></script> <script src="/bg/js/audio.js"></script> <script src="/bg/js/backend-api-forwarder.js"></script> diff --git a/ext/bg/context.html b/ext/bg/context.html index 7e08dddd..eda09a68 100644 --- a/ext/bg/context.html +++ b/ext/bg/context.html @@ -11,7 +11,6 @@ <link rel="icon" type="image/png" href="/mixed/img/icon128.png" sizes="128x128"> <link rel="stylesheet" type="text/css" href="/mixed/lib/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="/mixed/lib/bootstrap/css/bootstrap-theme.min.css"> - <link rel="stylesheet" type="text/css" href="/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.css"> <style type="text/css"> body { padding: 10px; @@ -89,12 +88,73 @@ .link-group-label { vertical-align: middle; } + + + .toggle { + width: 60px; + height: 34px; + position: relative; + overflow: hidden; + } + .toggle-group { + position: absolute; + width: 200%; + left: 0; + top: 0; + bottom: 0; + user-select: none; + } + .toggle-group.toggle-group-animated { + transition: transform 0.35s; + } + .toggle-on, + .toggle-off { + position: absolute; + top: 0; + bottom: 0; + margin: 0; + border: 0; + border-radius: 0; + } + .toggle-on { + padding-right: 24px; + left: 0; + right: 50%; + } + .toggle-off { + padding-left: 24px; + left: 50%; + right: 0; + } + .toggle-handle { + position: relative; + margin: 0 auto; + padding-top: 0; + padding-bottom: 0; + height: 100%; + width: 0; + border-width: 0 1px; + } + + .toggle>input[type=checkbox] { + display: none; + } + .toggle>input[type=checkbox]:not(:checked)~.toggle-group { + transform: translateX(-50%); + } </style> </head> <body> <div id="mini"> <div> - <input type="checkbox" id="enable-search"> + <label class="btn btn-primary toggle"> + <input type="checkbox" id="enable-search" /> + <div class="toggle-group"> + <span class="btn btn-primary toggle-on">On</span> + <span class="btn btn-default active toggle-off">Off</span> + <span class="btn btn-default toggle-handle"></span> + </div> + </label> </div> <div class="btn-group"> <a title="Search (Alt + Insert) (Middle click to open in new tab)" class="btn btn-default btn-xs action-open-search"><span class="glyphicon glyphicon-search"></span></a> @@ -118,10 +178,8 @@ </a> </div> - <script src="/mixed/lib/jquery.min.js"></script> - <script src="/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.js"></script> - - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> <script src="/bg/js/api.js"></script> <script src="/bg/js/options.js"></script> diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css index b3d5b884..8adae47c 100644 --- a/ext/bg/css/settings.css +++ b/ext/bg/css/settings.css @@ -17,9 +17,16 @@ */ -#anki-spinner, #anki-general, #anki-error, -#dict-spinner, #dict-error, #dict-warning, #dict-purge, #dict-import-progress, -#debug, .options-advanced, .storage-hidden, #storage-spinner { +#anki-spinner, +#dict-spinner, #dict-import-progress, +.storage-hidden, #storage-spinner { + display: none; +} + +html:root:not([data-options-anki-enable=true]) #anki-general, +html:root:not([data-options-general-debug-info=true]) .debug, +html:root:not([data-options-general-show-advanced=true]) .options-advanced, +html:root:not([data-options-general-result-output-mode=merge]) #dict-main-group { display: none; } @@ -30,12 +37,6 @@ padding: 10px; } -#field-templates { - font-family: monospace; - overflow-x: hidden; - white-space: pre; -} - .bottom-links { padding-bottom: 1em; } @@ -129,14 +130,24 @@ } #custom-popup-css, -#custom-popup-outer-css { +#custom-popup-outer-css, +#field-templates { width: 100%; min-height: 34px; + line-height: 18px; height: 96px; resize: vertical; font-family: 'Courier New', Courier, monospace; white-space: pre; } +#field-templates { + height: 240px; + border-bottom-left-radius: 0; +} +#field-templates-reset { + border-top-left-radius: 0; + border-top-right-radius: 0; +} .btn-inner-middle { vertical-align: middle; @@ -158,6 +169,24 @@ input[type=checkbox].storage-button-checkbox { height: 320px; } +.dict-delete-table { + display: table; + width: 100%; +} +.dict-delete-table>*:first-child { + display: table-cell; + vertical-align: middle; + padding-right: 1em; +} +.dict-delete-table>*:nth-child(n+2) { + display: table-cell; + width: 100%; + vertical-align: middle; +} +.dict-delete-table .progress { + margin: 0; +} + [data-show-for-browser], [data-show-for-operating-system] { display: none; diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index 9f851f13..17b93620 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -74,7 +74,7 @@ class AnkiConnect { async findNoteIds(notes) { await this.checkVersion(); - const actions = notes.map(note => ({ + const actions = notes.map((note) => ({ action: 'findNotes', params: { query: `deck:"${AnkiConnect.escapeQuery(note.deckName)}" ${AnkiConnect.fieldsToQuery(note.fields)}` @@ -108,11 +108,11 @@ class AnkiConnect { */ class AnkiNull { - async addNote(note) { + async addNote() { return null; } - async canAddNotes(notes) { + async canAddNotes() { return []; } @@ -124,15 +124,15 @@ class AnkiNull { return []; } - async getModelFieldNames(modelName) { + async getModelFieldNames() { return []; } - async guiBrowse(query) { + async guiBrowse() { return []; } - async findNoteIds(notes) { + async findNoteIds() { return []; } } diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 3209cc31..b489b8d2 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -25,42 +25,36 @@ async function apiOptionsSet(changedOptions, optionsContext, source) { const options = await apiOptionsGet(optionsContext); function getValuePaths(obj) { - let valuePaths = []; - let nodes = [{ - obj, - path: [] - }]; + const valuePaths = []; + const nodes = [{obj, path: []}]; while (nodes.length > 0) { - let node = nodes.pop(); - Object.keys(node.obj).forEach((key) => { - let path = node.path.concat(key); - let value = node.obj[key]; - if (typeof value === 'object') { - nodes.unshift({ - obj: value, - path: path - }); + const node = nodes.pop(); + for (const key of Object.keys(node.obj)) { + const path = node.path.concat(key); + const obj = node.obj[key]; + if (obj !== null && typeof obj === 'object') { + nodes.unshift({obj, path}); } else { - valuePaths.push([value, path]); + valuePaths.push([obj, path]); } - }); + } } return valuePaths; } function modifyOption(path, value, options) { let pivot = options; - for (let pathKey of path.slice(0, -1)) { - if (!(pathKey in pivot)) { + for (const key of path.slice(0, -1)) { + if (!hasOwn(pivot, key)) { return false; } - pivot = pivot[pathKey]; + pivot = pivot[key]; } pivot[path[path.length - 1]] = value; return true; } - for (let [value, path] of getValuePaths(changedOptions)) { + for (const [value, path] of getValuePaths(changedOptions)) { modifyOption(path, value, options); } @@ -78,33 +72,83 @@ async function apiOptionsSave(source) { backend.onOptionsUpdated(source); } -async function apiTermsFind(text, optionsContext) { +async function apiTermsFind(text, details, optionsContext) { const options = await apiOptionsGet(optionsContext); - const translator = utilBackend().translator; + const [definitions, length] = await utilBackend().translator.findTerms(text, details, options); + definitions.splice(options.general.maxResults); + return {length, definitions}; +} - const searcher = { - 'merge': translator.findTermsMerged, - 'split': translator.findTermsSplit, - 'group': translator.findTermsGrouped - }[options.general.resultOutputMode].bind(translator); +async function apiTextParse(text, optionsContext) { + const options = await apiOptionsGet(optionsContext); + const translator = utilBackend().translator; - const {definitions, length} = await searcher( - text, - dictEnabledSet(options), - options.scanning.alphanumeric, - options - ); + const results = []; + while (text.length > 0) { + const term = []; + const [definitions, sourceLength] = await translator.findTermsInternal( + text.slice(0, options.scanning.length), + dictEnabledSet(options), + options.scanning.alphanumeric, + {} + ); + if (definitions.length > 0) { + dictTermsSort(definitions); + const {expression, reading} = definitions[0]; + const source = text.slice(0, sourceLength); + for (const {text, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) { + const reading = jpConvertReading(text, furigana, options.parsing.readingMode); + term.push({text, reading}); + } + text = text.slice(source.length); + } else { + const reading = jpConvertReading(text[0], null, options.parsing.readingMode); + term.push({text: text[0], reading}); + text = text.slice(1); + } + results.push(term); + } + return results; +} - return { - length, - definitions: definitions.slice(0, options.general.maxResults) - }; +async function apiTextParseMecab(text, optionsContext) { + const options = await apiOptionsGet(optionsContext); + const mecab = utilBackend().mecab; + + const results = {}; + const rawResults = await mecab.parseText(text); + for (const mecabName in rawResults) { + const result = []; + for (const parsedLine of rawResults[mecabName]) { + for (const {expression, reading, source} of parsedLine) { + const term = []; + if (expression !== null && reading !== null) { + for (const {text, furigana} of jpDistributeFuriganaInflected( + expression, + jpKatakanaToHiragana(reading), + source + )) { + const reading = jpConvertReading(text, furigana, options.parsing.readingMode); + term.push({text, reading}); + } + } else { + const reading = jpConvertReading(source, null, options.parsing.readingMode); + term.push({text: source, reading}); + } + result.push(term); + } + result.push([{text: '\n'}]); + } + results[mecabName] = result; + } + return results; } async function apiKanjiFind(text, optionsContext) { const options = await apiOptionsGet(optionsContext); - const definitions = await utilBackend().translator.findKanji(text, dictEnabledSet(options)); - return definitions.slice(0, options.general.maxResults); + const definitions = await utilBackend().translator.findKanji(text, options); + definitions.splice(options.general.maxResults); + return definitions; } async function apiDefinitionAdd(definition, mode, context, optionsContext) { @@ -163,7 +207,7 @@ async function apiDefinitionsAddable(definitions, modes, optionsContext) { } if (cannotAdd.length > 0) { - const noteIdsArray = await anki.findNoteIds(cannotAdd.map(e => e[0])); + const noteIdsArray = await anki.findNoteIds(cannotAdd.map((e) => e[0])); for (let i = 0, ii = Math.min(cannotAdd.length, noteIdsArray.length); i < ii; ++i) { const noteIds = noteIdsArray[i]; if (noteIds.length > 0) { @@ -192,7 +236,7 @@ async function apiTemplateRender(template, data, dynamic) { async function apiCommandExec(command, params) { const handlers = apiCommandExec.handlers; - if (handlers.hasOwnProperty(command)) { + if (hasOwn(handlers, command)) { const handler = handlers[command]; handler(params); } @@ -360,7 +404,9 @@ async function apiGetBrowser() { if (info.name === 'Fennec') { return 'firefox-mobile'; } - } catch (e) { } + } catch (e) { + // NOP + } return 'firefox'; } else { return 'chrome'; diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index 3efcce46..dc0ba5eb 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -107,12 +107,12 @@ const audioUrlBuilders = { 'custom': async (definition, optionsContext) => { const options = await apiOptionsGet(optionsContext); const customSourceUrl = options.audio.customSourceUrl; - return customSourceUrl.replace(/\{([^\}]*)\}/g, (m0, m1) => (definition.hasOwnProperty(m1) ? `${definition[m1]}` : m0)); + return customSourceUrl.replace(/\{([^}]*)\}/g, (m0, m1) => (hasOwn(definition, m1) ? `${definition[m1]}` : m0)); } }; async function audioGetUrl(definition, mode, optionsContext, download) { - if (audioUrlBuilders.hasOwnProperty(mode)) { + if (hasOwn(audioUrlBuilders, mode)) { const handler = audioUrlBuilders[mode]; try { return await handler(definition, optionsContext, download); @@ -128,12 +128,12 @@ function audioUrlNormalize(url, baseUrl, basePath) { if (url[0] === '/') { if (url.length >= 2 && url[1] === '/') { // Begins with "//" - url = baseUrl.substr(0, baseUrl.indexOf(':') + 1) + url; + url = baseUrl.substring(0, baseUrl.indexOf(':') + 1) + url; } else { // Begins with "/" url = baseUrl + url; } - } else if (!/^[a-z][a-z0-9\+\-\.]*:/i.test(url)) { + } else if (!/^[a-z][a-z0-9\-+.]*:/i.test(url)) { // No URI scheme => relative path url = baseUrl + basePath + url; } @@ -171,7 +171,7 @@ async function audioInject(definition, fields, sources, optionsContext) { try { let audioSourceDefinition = definition; - if (definition.hasOwnProperty('expressions')) { + if (hasOwn(definition, 'expressions')) { audioSourceDefinition = definition.expressions[0]; } diff --git a/ext/bg/js/backend-api-forwarder.js b/ext/bg/js/backend-api-forwarder.js index 979afd16..db4d30b9 100644 --- a/ext/bg/js/backend-api-forwarder.js +++ b/ext/bg/js/backend-api-forwarder.js @@ -37,8 +37,8 @@ class BackendApiForwarder { const forwardPort = chrome.tabs.connect(tabId, {name: 'frontend-api-receiver'}); - port.onMessage.addListener(message => forwardPort.postMessage(message)); - forwardPort.onMessage.addListener(message => port.postMessage(message)); + port.onMessage.addListener((message) => forwardPort.postMessage(message)); + forwardPort.onMessage.addListener((message) => port.postMessage(message)); port.onDisconnect.addListener(() => forwardPort.disconnect()); forwardPort.onDisconnect.addListener(() => port.disconnect()); } diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 71393467..d9f9b586 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -21,6 +21,7 @@ class Backend { constructor() { this.translator = new Translator(); this.anki = new AnkiNull(); + this.mecab = new Mecab(); this.options = null; this.optionsContext = { depth: 0, @@ -59,7 +60,7 @@ class Backend { this.applyOptions(); const callback = () => this.checkLastError(chrome.runtime.lastError); - chrome.tabs.query({}, tabs => { + chrome.tabs.query({}, (tabs) => { for (const tab of tabs) { chrome.tabs.sendMessage(tab.id, {action: 'optionsUpdate', params: {source}}, callback); } @@ -72,12 +73,12 @@ class Backend { onMessage({action, params}, sender, callback) { const handlers = Backend.messageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; const promise = handler(params, sender); promise.then( - result => callback({result}), - error => callback({error: errorToJson(error)}) + (result) => callback({result}), + (error) => callback({error: errorToJson(error)}) ); } @@ -97,6 +98,12 @@ class Backend { } this.anki = options.anki.enable ? new AnkiConnect(options.anki.server) : new AnkiNull(); + + if (options.parsing.enableMecabParser) { + this.mecab.startListener(); + } else { + this.mecab.stopListener(); + } } async getFullOptions() { @@ -170,7 +177,7 @@ class Backend { } } - checkLastError(e) { + checkLastError() { // NOP } } @@ -179,7 +186,9 @@ Backend.messageHandlers = { optionsGet: ({optionsContext}) => apiOptionsGet(optionsContext), optionsSet: ({changedOptions, optionsContext, source}) => apiOptionsSet(changedOptions, optionsContext, source), kanjiFind: ({text, optionsContext}) => apiKanjiFind(text, optionsContext), - termsFind: ({text, optionsContext}) => apiTermsFind(text, optionsContext), + termsFind: ({text, details, optionsContext}) => apiTermsFind(text, details, optionsContext), + textParse: ({text, optionsContext}) => apiTextParse(text, optionsContext), + textParseMecab: ({text, optionsContext}) => apiTextParseMecab(text, optionsContext), definitionAdd: ({definition, mode, context, optionsContext}) => apiDefinitionAdd(definition, mode, context, optionsContext), definitionsAddable: ({definitions, modes, optionsContext}) => apiDefinitionsAddable(definitions, modes, optionsContext), noteView: ({noteId}) => apiNoteView(noteId), diff --git a/ext/bg/js/conditions-ui.js b/ext/bg/js/conditions-ui.js index 43c6dc08..cc9db087 100644 --- a/ext/bg/js/conditions-ui.js +++ b/ext/bg/js/conditions-ui.js @@ -84,7 +84,7 @@ ConditionsUI.Container = class Container { createDefaultCondition(type) { let operator = ''; let value = ''; - if (this.conditionDescriptors.hasOwnProperty(type)) { + if (hasOwn(this.conditionDescriptors, type)) { const conditionDescriptor = this.conditionDescriptors[type]; operator = conditionDescriptor.defaultOperator; ({value} = this.getOperatorDefaultValue(type, operator)); @@ -96,15 +96,15 @@ ConditionsUI.Container = class Container { } getOperatorDefaultValue(type, operator) { - if (this.conditionDescriptors.hasOwnProperty(type)) { + if (hasOwn(this.conditionDescriptors, type)) { const conditionDescriptor = this.conditionDescriptors[type]; - if (conditionDescriptor.operators.hasOwnProperty(operator)) { + if (hasOwn(conditionDescriptor.operators, operator)) { const operatorDescriptor = conditionDescriptor.operators[operator]; - if (operatorDescriptor.hasOwnProperty('defaultValue')) { + if (hasOwn(operatorDescriptor, 'defaultValue')) { return {value: operatorDescriptor.defaultValue, fromOperator: true}; } } - if (conditionDescriptor.hasOwnProperty('defaultValue')) { + if (hasOwn(conditionDescriptor, 'defaultValue')) { return {value: conditionDescriptor.defaultValue, fromOperator: false}; } } @@ -219,7 +219,7 @@ ConditionsUI.Condition = class Condition { optionGroup.empty(); const type = this.condition.type; - if (conditionDescriptors.hasOwnProperty(type)) { + if (hasOwn(conditionDescriptors, type)) { const conditionDescriptor = conditionDescriptors[type]; const operators = conditionDescriptor.operators; for (const operatorName of Object.keys(operators)) { @@ -240,23 +240,23 @@ ConditionsUI.Condition = class Condition { }; const objects = []; - if (conditionDescriptors.hasOwnProperty(type)) { + if (hasOwn(conditionDescriptors, type)) { const conditionDescriptor = conditionDescriptors[type]; objects.push(conditionDescriptor); - if (conditionDescriptor.operators.hasOwnProperty(operator)) { + if (hasOwn(conditionDescriptor.operators, operator)) { const operatorDescriptor = conditionDescriptor.operators[operator]; objects.push(operatorDescriptor); } } for (const object of objects) { - if (object.hasOwnProperty('placeholder')) { + if (hasOwn(object, 'placeholder')) { props.placeholder = object.placeholder; } if (object.type === 'number') { props.type = 'number'; for (const prop of ['step', 'min', 'max']) { - if (object.hasOwnProperty(prop)) { + if (hasOwn(object, prop)) { props[prop] = object[prop]; } } diff --git a/ext/bg/js/conditions.js b/ext/bg/js/conditions.js index ed4b14f5..c0f0f301 100644 --- a/ext/bg/js/conditions.js +++ b/ext/bg/js/conditions.js @@ -18,14 +18,14 @@ function conditionsValidateOptionValue(object, value) { - if (object.hasOwnProperty('validate') && !object.validate(value)) { + if (hasOwn(object, 'validate') && !object.validate(value)) { throw new Error('Invalid value for condition'); } - if (object.hasOwnProperty('transform')) { + if (hasOwn(object, 'transform')) { value = object.transform(value); - if (object.hasOwnProperty('validateTransformed') && !object.validateTransformed(value)) { + if (hasOwn(object, 'validateTransformed') && !object.validateTransformed(value)) { throw new Error('Invalid value for condition'); } } @@ -34,12 +34,12 @@ function conditionsValidateOptionValue(object, value) { } function conditionsNormalizeOptionValue(descriptors, type, operator, optionValue) { - if (!descriptors.hasOwnProperty(type)) { + if (!hasOwn(descriptors, type)) { throw new Error('Invalid type'); } const conditionDescriptor = descriptors[type]; - if (!conditionDescriptor.operators.hasOwnProperty(operator)) { + if (!hasOwn(conditionDescriptor.operators, operator)) { throw new Error('Invalid operator'); } @@ -48,28 +48,28 @@ function conditionsNormalizeOptionValue(descriptors, type, operator, optionValue let transformedValue = conditionsValidateOptionValue(conditionDescriptor, optionValue); transformedValue = conditionsValidateOptionValue(operatorDescriptor, transformedValue); - if (operatorDescriptor.hasOwnProperty('transformReverse')) { + if (hasOwn(operatorDescriptor, 'transformReverse')) { transformedValue = operatorDescriptor.transformReverse(transformedValue); } return transformedValue; } function conditionsTestValueThrowing(descriptors, type, operator, optionValue, value) { - if (!descriptors.hasOwnProperty(type)) { + if (!hasOwn(descriptors, type)) { throw new Error('Invalid type'); } const conditionDescriptor = descriptors[type]; - if (!conditionDescriptor.operators.hasOwnProperty(operator)) { + if (!hasOwn(conditionDescriptor.operators, operator)) { throw new Error('Invalid operator'); } const operatorDescriptor = conditionDescriptor.operators[operator]; - if (operatorDescriptor.hasOwnProperty('transform')) { - if (operatorDescriptor.hasOwnProperty('transformCache')) { + if (hasOwn(operatorDescriptor, 'transform')) { + if (hasOwn(operatorDescriptor, 'transformCache')) { const key = `${optionValue}`; const transformCache = operatorDescriptor.transformCache; - if (transformCache.hasOwnProperty(key)) { + if (hasOwn(transformCache, key)) { optionValue = transformCache[key]; } else { optionValue = operatorDescriptor.transform(optionValue); @@ -93,23 +93,23 @@ function conditionsTestValue(descriptors, type, operator, optionValue, value) { function conditionsClearCaches(descriptors) { for (const type in descriptors) { - if (!descriptors.hasOwnProperty(type)) { + if (!hasOwn(descriptors, type)) { continue; } const conditionDescriptor = descriptors[type]; - if (conditionDescriptor.hasOwnProperty('transformCache')) { + if (hasOwn(conditionDescriptor, 'transformCache')) { conditionDescriptor.transformCache = {}; } const operatorDescriptors = conditionDescriptor.operators; for (const operator in operatorDescriptors) { - if (!operatorDescriptors.hasOwnProperty(operator)) { + if (!hasOwn(operatorDescriptors, operator)) { continue; } const operatorDescriptor = operatorDescriptors[operator]; - if (operatorDescriptor.hasOwnProperty('transformCache')) { + if (hasOwn(operatorDescriptor, 'transformCache')) { operatorDescriptor.transformCache = {}; } } diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 3fb27f0d..0b21f662 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -26,26 +26,28 @@ function showExtensionInfo() { } function setupButtonEvents(selector, command, url) { - const node = $(selector); - node.on('click', (e) => { - if (e.button !== 0) { return; } - apiCommandExec(command, {newTab: e.ctrlKey}); - e.preventDefault(); - }) - .on('auxclick', (e) => { - if (e.button !== 1) { return; } - apiCommandExec(command, {newTab: true}); - e.preventDefault(); - }); + const nodes = document.querySelectorAll(selector); + for (const node of nodes) { + node.addEventListener('click', (e) => { + if (e.button !== 0) { return; } + apiCommandExec(command, {newTab: e.ctrlKey}); + e.preventDefault(); + }, false); + node.addEventListener('auxclick', (e) => { + if (e.button !== 1) { return; } + apiCommandExec(command, {newTab: true}); + e.preventDefault(); + }, false); - if (typeof url === 'string') { - node.attr('href', url); - node.attr('target', '_blank'); - node.attr('rel', 'noopener'); + if (typeof url === 'string') { + node.href = url; + node.target = '_blank'; + node.rel = 'noopener'; + } } } -$(document).ready(utilAsync(() => { +window.addEventListener('DOMContentLoaded', () => { showExtensionInfo(); apiGetEnvironmentInfo().then(({browser}) => { @@ -63,14 +65,19 @@ $(document).ready(utilAsync(() => { depth: 0, url: window.location.href }; - apiOptionsGet(optionsContext).then(options => { - const toggle = $('#enable-search'); - toggle.prop('checked', options.general.enable).change(); - toggle.bootstrapToggle(); - toggle.change(() => apiCommandExec('toggle')); + apiOptionsGet(optionsContext).then((options) => { + const toggle = document.querySelector('#enable-search'); + toggle.checked = options.general.enable; + toggle.addEventListener('change', () => apiCommandExec('toggle'), false); + + const toggle2 = document.querySelector('#enable-search2'); + toggle2.checked = options.general.enable; + toggle2.addEventListener('change', () => apiCommandExec('toggle'), false); - const toggle2 = $('#enable-search2'); - toggle2.prop('checked', options.general.enable).change(); - toggle2.change(() => apiCommandExec('toggle')); + setTimeout(() => { + for (const n of document.querySelectorAll('.toggle-group')) { + n.classList.add('toggle-group-animated'); + } + }, 10); }); -})); +}); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 9f477b24..a20d5f15 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -23,63 +23,137 @@ class Database { } async prepare() { - if (this.db) { + if (this.db !== null) { throw new Error('Database already initialized'); } - this.db = new Dexie('dict'); - this.db.version(2).stores({ - terms: '++id,dictionary,expression,reading', - kanji: '++,dictionary,character', - tagMeta: '++,dictionary', - dictionaries: '++,title,version' - }); - this.db.version(3).stores({ - termMeta: '++,dictionary,expression', - kanjiMeta: '++,dictionary,character', - tagMeta: '++,dictionary,name' - }); - this.db.version(4).stores({ - terms: '++id,dictionary,expression,reading,sequence' - }); - - await this.db.open(); + try { + this.db = await Database.open('dict', 4, (db, transaction, oldVersion) => { + Database.upgrade(db, transaction, oldVersion, [ + { + version: 2, + stores: { + terms: { + primaryKey: {keyPath: 'id', autoIncrement: true}, + indices: ['dictionary', 'expression', 'reading'] + }, + kanji: { + primaryKey: {autoIncrement: true}, + indices: ['dictionary', 'character'] + }, + tagMeta: { + primaryKey: {autoIncrement: true}, + indices: ['dictionary'] + }, + dictionaries: { + primaryKey: {autoIncrement: true}, + indices: ['title', 'version'] + } + } + }, + { + version: 3, + stores: { + termMeta: { + primaryKey: {autoIncrement: true}, + indices: ['dictionary', 'expression'] + }, + kanjiMeta: { + primaryKey: {autoIncrement: true}, + indices: ['dictionary', 'character'] + }, + tagMeta: { + primaryKey: {autoIncrement: true}, + indices: ['dictionary', 'name'] + } + } + }, + { + version: 4, + stores: { + terms: { + primaryKey: {keyPath: 'id', autoIncrement: true}, + indices: ['dictionary', 'expression', 'reading', 'sequence'] + } + } + } + ]); + }); + return true; + } catch (e) { + console.error(e); + return false; + } } async purge() { this.validate(); this.db.close(); - await this.db.delete(); + await Database.deleteDatabase(this.db.name); this.db = null; await this.prepare(); } - async findTermsBulk(termList, titles) { + async deleteDictionary(dictionaryName, onProgress, progressSettings) { + this.validate(); + + const targets = [ + ['dictionaries', 'title'], + ['kanji', 'dictionary'], + ['kanjiMeta', 'dictionary'], + ['terms', 'dictionary'], + ['termMeta', 'dictionary'], + ['tagMeta', 'dictionary'] + ]; + const promises = []; + const progressData = { + count: 0, + processed: 0, + storeCount: targets.length, + storesProcesed: 0 + }; + let progressRate = (typeof progressSettings === 'object' && progressSettings !== null ? progressSettings.rate : 0); + if (typeof progressRate !== 'number' || progressRate <= 0) { + progressRate = 1000; + } + + for (const [objectStoreName, index] of targets) { + const dbTransaction = this.db.transaction([objectStoreName], 'readwrite'); + const dbObjectStore = dbTransaction.objectStore(objectStoreName); + const dbIndex = dbObjectStore.index(index); + const only = IDBKeyRange.only(dictionaryName); + promises.push(Database.deleteValues(dbObjectStore, dbIndex, only, onProgress, progressData, progressRate)); + } + + await Promise.all(promises); + } + + async findTermsBulk(termList, titles, wildcard) { this.validate(); const promises = []; const visited = {}; const results = []; const processRow = (row, index) => { - if (titles.includes(row.dictionary) && !visited.hasOwnProperty(row.id)) { + if (titles.includes(row.dictionary) && !hasOwn(visited, row.id)) { visited[row.id] = true; results.push(Database.createTerm(row, index)); } }; - const db = this.db.backendDB(); - const dbTransaction = db.transaction(['terms'], 'readonly'); + const dbTransaction = this.db.transaction(['terms'], 'readonly'); const dbTerms = dbTransaction.objectStore('terms'); const dbIndex1 = dbTerms.index('expression'); const dbIndex2 = dbTerms.index('reading'); for (let i = 0; i < termList.length; ++i) { - const only = IDBKeyRange.only(termList[i]); + const term = termList[i]; + const query = wildcard ? IDBKeyRange.bound(term, `${term}\uffff`, false, false) : IDBKeyRange.only(term); promises.push( - Database.getAll(dbIndex1, only, i, processRow), - Database.getAll(dbIndex2, only, i, processRow) + Database.getAll(dbIndex1, query, i, processRow), + Database.getAll(dbIndex2, query, i, processRow) ); } @@ -99,8 +173,7 @@ class Database { } }; - const db = this.db.backendDB(); - const dbTransaction = db.transaction(['terms'], 'readonly'); + const dbTransaction = this.db.transaction(['terms'], 'readonly'); const dbTerms = dbTransaction.objectStore('terms'); const dbIndex = dbTerms.index('expression'); @@ -125,8 +198,7 @@ class Database { } }; - const db = this.db.backendDB(); - const dbTransaction = db.transaction(['terms'], 'readonly'); + const dbTransaction = this.db.transaction(['terms'], 'readonly'); const dbTerms = dbTransaction.objectStore('terms'); const dbIndex = dbTerms.index('sequence'); @@ -163,8 +235,7 @@ class Database { } }; - const db = this.db.backendDB(); - const dbTransaction = db.transaction([tableName], 'readonly'); + const dbTransaction = this.db.transaction([tableName], 'readonly'); const dbTerms = dbTransaction.objectStore(tableName); const dbIndex = dbTerms.index(indexName); @@ -182,12 +253,11 @@ class Database { this.validate(); let result = null; - const db = this.db.backendDB(); - const dbTransaction = db.transaction(['tagMeta'], 'readonly'); + const dbTransaction = this.db.transaction(['tagMeta'], 'readonly'); const dbTerms = dbTransaction.objectStore('tagMeta'); const dbIndex = dbTerms.index('name'); const only = IDBKeyRange.only(name); - await Database.getAll(dbIndex, only, null, row => { + await Database.getAll(dbIndex, only, null, (row) => { if (title === row.dictionary) { result = row; } @@ -196,24 +266,76 @@ class Database { return result; } - async summarize() { + async getDictionaryInfo() { + this.validate(); + + const results = []; + const dbTransaction = this.db.transaction(['dictionaries'], 'readonly'); + const dbDictionaries = dbTransaction.objectStore('dictionaries'); + + await Database.getAll(dbDictionaries, null, null, (info) => results.push(info)); + + return results; + } + + async getDictionaryCounts(dictionaryNames, getTotal) { this.validate(); - return this.db.dictionaries.toArray(); + const objectStoreNames = [ + 'kanji', + 'kanjiMeta', + 'terms', + 'termMeta', + 'tagMeta' + ]; + const dbCountTransaction = this.db.transaction(objectStoreNames, 'readonly'); + + const targets = []; + for (const objectStoreName of objectStoreNames) { + targets.push([ + objectStoreName, + dbCountTransaction.objectStore(objectStoreName).index('dictionary') + ]); + } + + // Query is required for Edge, otherwise index.count throws an exception. + const query1 = IDBKeyRange.lowerBound('', false); + const totalPromise = getTotal ? Database.getCounts(targets, query1) : null; + + const counts = []; + const countPromises = []; + for (let i = 0; i < dictionaryNames.length; ++i) { + counts.push(null); + const index = i; + const query2 = IDBKeyRange.only(dictionaryNames[i]); + const countPromise = Database.getCounts(targets, query2).then((v) => counts[index] = v); + countPromises.push(countPromise); + } + await Promise.all(countPromises); + + const result = {counts}; + if (totalPromise !== null) { + result.total = await totalPromise; + } + return result; } async importDictionary(archive, progressCallback, exceptions) { this.validate(); const maxTransactionLength = 1000; - const bulkAdd = async (table, items, total, current) => { - if (items.length < maxTransactionLength) { + const bulkAdd = async (objectStoreName, items, total, current) => { + const db = this.db; + for (let i = 0; i < items.length; i += maxTransactionLength) { if (progressCallback) { - progressCallback(total, current); + progressCallback(total, current + i / items.length); } try { - await table.bulkAdd(items); + const count = Math.min(maxTransactionLength, items.length - i); + const transaction = db.transaction([objectStoreName], 'readwrite'); + const objectStore = transaction.objectStore(objectStoreName); + await Database.bulkAdd(objectStore, items, i, count); } catch (e) { if (exceptions) { exceptions.push(e); @@ -221,37 +343,27 @@ class Database { throw e; } } - } else { - for (let i = 0; i < items.length; i += maxTransactionLength) { - if (progressCallback) { - progressCallback(total, current + i / items.length); - } - - let count = Math.min(maxTransactionLength, items.length - i); - try { - await table.bulkAdd(items.slice(i, i + count)); - } catch (e) { - if (exceptions) { - exceptions.push(e); - } else { - throw e; - } - } - } } }; - const indexDataLoaded = async summary => { + const indexDataLoaded = async (summary) => { if (summary.version > 3) { throw new Error('Unsupported dictionary version'); } - const count = await this.db.dictionaries.where('title').equals(summary.title).count(); + const db = this.db; + const dbCountTransaction = db.transaction(['dictionaries'], 'readonly'); + const dbIndex = dbCountTransaction.objectStore('dictionaries').index('title'); + const only = IDBKeyRange.only(summary.title); + const count = await Database.getCount(dbIndex, only); + if (count > 0) { throw new Error('Dictionary is already imported'); } - await this.db.dictionaries.add(summary); + const transaction = db.transaction(['dictionaries'], 'readwrite'); + const objectStore = transaction.objectStore('dictionaries'); + await Database.bulkAdd(objectStore, [summary], 0, 1); }; const termDataLoaded = async (summary, entries, total, current) => { @@ -284,7 +396,7 @@ class Database { } } - await bulkAdd(this.db.terms, rows, total, current); + await bulkAdd('terms', rows, total, current); }; const termMetaDataLoaded = async (summary, entries, total, current) => { @@ -298,7 +410,7 @@ class Database { }); } - await bulkAdd(this.db.termMeta, rows, total, current); + await bulkAdd('termMeta', rows, total, current); }; const kanjiDataLoaded = async (summary, entries, total, current) => { @@ -328,7 +440,7 @@ class Database { } } - await bulkAdd(this.db.kanji, rows, total, current); + await bulkAdd('kanji', rows, total, current); }; const kanjiMetaDataLoaded = async (summary, entries, total, current) => { @@ -342,7 +454,7 @@ class Database { }); } - await bulkAdd(this.db.kanjiMeta, rows, total, current); + await bulkAdd('kanjiMeta', rows, total, current); }; const tagDataLoaded = async (summary, entries, total, current) => { @@ -360,7 +472,7 @@ class Database { rows.push(row); } - await bulkAdd(this.db.tagMeta, rows, total, current); + await bulkAdd('tagMeta', rows, total, current); }; return await Database.importDictionaryZip( @@ -410,13 +522,13 @@ class Database { await indexDataLoaded(summary); - const buildTermBankName = index => `term_bank_${index + 1}.json`; - const buildTermMetaBankName = index => `term_meta_bank_${index + 1}.json`; - const buildKanjiBankName = index => `kanji_bank_${index + 1}.json`; - const buildKanjiMetaBankName = index => `kanji_meta_bank_${index + 1}.json`; - const buildTagBankName = index => `tag_bank_${index + 1}.json`; + const buildTermBankName = (index) => `term_bank_${index + 1}.json`; + const buildTermMetaBankName = (index) => `term_meta_bank_${index + 1}.json`; + const buildKanjiBankName = (index) => `kanji_bank_${index + 1}.json`; + const buildKanjiMetaBankName = (index) => `kanji_meta_bank_${index + 1}.json`; + const buildTagBankName = (index) => `tag_bank_${index + 1}.json`; - const countBanks = namer => { + const countBanks = (namer) => { let count = 0; while (zip.files[namer(count)]) { ++count; @@ -539,4 +651,176 @@ class Database { }; }); } + + static getCounts(targets, query) { + const countPromises = []; + const counts = {}; + for (const [objectStoreName, index] of targets) { + const n = objectStoreName; + const countPromise = Database.getCount(index, query).then((count) => counts[n] = count); + countPromises.push(countPromise); + } + return Promise.all(countPromises).then(() => counts); + } + + static getCount(dbIndex, query) { + return new Promise((resolve, reject) => { + const request = dbIndex.count(query); + request.onerror = (e) => reject(e); + request.onsuccess = (e) => resolve(e.target.result); + }); + } + + static getAllKeys(dbIndex, query) { + const fn = typeof dbIndex.getAllKeys === 'function' ? Database.getAllKeysFast : Database.getAllKeysUsingCursor; + return fn(dbIndex, query); + } + + static getAllKeysFast(dbIndex, query) { + return new Promise((resolve, reject) => { + const request = dbIndex.getAllKeys(query); + request.onerror = (e) => reject(e); + request.onsuccess = (e) => resolve(e.target.result); + }); + } + + static getAllKeysUsingCursor(dbIndex, query) { + return new Promise((resolve, reject) => { + const primaryKeys = []; + const request = dbIndex.openKeyCursor(query, 'next'); + request.onerror = (e) => reject(e); + request.onsuccess = (e) => { + const cursor = e.target.result; + if (cursor) { + primaryKeys.push(cursor.primaryKey); + cursor.continue(); + } else { + resolve(primaryKeys); + } + }; + }); + } + + static async deleteValues(dbObjectStore, dbIndex, query, onProgress, progressData, progressRate) { + const hasProgress = (typeof onProgress === 'function'); + const count = await Database.getCount(dbIndex, query); + ++progressData.storesProcesed; + progressData.count += count; + if (hasProgress) { + onProgress(progressData); + } + + const onValueDeleted = ( + hasProgress ? + () => { + const p = ++progressData.processed; + if ((p % progressRate) === 0 || p === progressData.count) { + onProgress(progressData); + } + } : + () => {} + ); + + const promises = []; + const primaryKeys = await Database.getAllKeys(dbIndex, query); + for (const key of primaryKeys) { + const promise = Database.deleteValue(dbObjectStore, key).then(onValueDeleted); + promises.push(promise); + } + + await Promise.all(promises); + } + + static deleteValue(dbObjectStore, key) { + return new Promise((resolve, reject) => { + const request = dbObjectStore.delete(key); + request.onerror = (e) => reject(e); + request.onsuccess = () => resolve(); + }); + } + + static bulkAdd(objectStore, items, start, count) { + return new Promise((resolve, reject) => { + if (start + count > items.length) { + count = items.length - start; + } + + if (count <= 0) { + resolve(); + return; + } + + const end = start + count; + let completedCount = 0; + const onError = (e) => reject(e); + const onSuccess = () => { + if (++completedCount >= count) { + resolve(); + } + }; + + for (let i = start; i < end; ++i) { + const request = objectStore.add(items[i]); + request.onerror = onError; + request.onsuccess = onSuccess; + } + }); + } + + static open(name, version, onUpgradeNeeded) { + return new Promise((resolve, reject) => { + const request = window.indexedDB.open(name, version * 10); + + request.onupgradeneeded = (event) => { + try { + request.transaction.onerror = (e) => reject(e); + onUpgradeNeeded(request.result, request.transaction, event.oldVersion / 10, event.newVersion / 10); + } catch (e) { + reject(e); + } + }; + + request.onerror = (e) => reject(e); + request.onsuccess = () => resolve(request.result); + }); + } + + static upgrade(db, transaction, oldVersion, upgrades) { + for (const {version, stores} of upgrades) { + if (oldVersion >= version) { continue; } + + const objectStoreNames = Object.keys(stores); + for (const objectStoreName of objectStoreNames) { + const {primaryKey, indices} = stores[objectStoreName]; + + const objectStoreNames = transaction.objectStoreNames || db.objectStoreNames; + const objectStore = ( + Database.listContains(objectStoreNames, objectStoreName) ? + transaction.objectStore(objectStoreName) : + db.createObjectStore(objectStoreName, primaryKey) + ); + + for (const indexName of indices) { + if (Database.listContains(objectStore.indexNames, indexName)) { continue; } + + objectStore.createIndex(indexName, indexName, {}); + } + } + } + } + + static deleteDatabase(dbName) { + return new Promise((resolve, reject) => { + const request = indexedDB.deleteDatabase(dbName); + request.onerror = (e) => reject(e); + request.onsuccess = () => resolve(); + }); + } + + static listContains(list, value) { + for (let i = 0, ii = list.length; i < ii; ++i) { + if (list[i] === value) { return true; } + } + return false; + } } diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js index ce4b2961..51f4723c 100644 --- a/ext/bg/js/deinflector.js +++ b/ext/bg/js/deinflector.js @@ -44,7 +44,7 @@ class Deinflector { results.push({ source, - term: term.slice(0, -kanaIn.length) + kanaOut, + term: term.substring(0, term.length - kanaIn.length) + kanaOut, rules: rulesOut, definitions: [], reasons: [reason, ...reasons] @@ -88,5 +88,5 @@ Deinflector.ruleTypes = { 'vs': 0b0000100, // Verb suru 'vk': 0b0001000, // Verb kuru 'adj-i': 0b0010000, // Adjective i - 'iru': 0b0100000, // Intermediate -iru endings for progressive or perfect tense + 'iru': 0b0100000 // Intermediate -iru endings for progressive or perfect tense }; diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 191058c1..0b35e32e 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -55,39 +55,23 @@ function dictRowsSort(rows, options) { function dictTermsSort(definitions, dictionaries=null) { return definitions.sort((v1, v2) => { + let i; if (dictionaries !== null) { - const p1 = (dictionaries[v1.dictionary] || {}).priority || 0; - const p2 = (dictionaries[v2.dictionary] || {}).priority || 0; - if (p1 > p2) { - return -1; - } else if (p1 < p2) { - return 1; - } + i = ( + ((dictionaries[v2.dictionary] || {}).priority || 0) - + ((dictionaries[v1.dictionary] || {}).priority || 0) + ); + if (i !== 0) { return i; } } - const sl1 = v1.source.length; - const sl2 = v2.source.length; - if (sl1 > sl2) { - return -1; - } else if (sl1 < sl2) { - return 1; - } + i = v2.source.length - v1.source.length; + if (i !== 0) { return i; } - const rl1 = v1.reasons.length; - const rl2 = v2.reasons.length; - if (rl1 < rl2) { - return -1; - } else if (rl1 > rl2) { - return 1; - } + i = v2.reasons.length - v1.reasons.length; + if (i !== 0) { return i; } - const s1 = v1.score; - const s2 = v2.score; - if (s1 > s2) { - return -1; - } else if (s1 < s2) { - return 1; - } + i = v2.score - v1.score; + if (i !== 0) { return i; } return v2.expression.toString().localeCompare(v1.expression.toString()); }); @@ -97,7 +81,7 @@ function dictTermsUndupe(definitions) { const definitionGroups = {}; for (const definition of definitions) { const definitionExisting = definitionGroups[definition.id]; - if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) { + if (!hasOwn(definitionGroups, definition.id) || definition.expression.length > definitionExisting.expression.length) { definitionGroups[definition.id] = definition; } } @@ -115,8 +99,8 @@ function dictTermsCompressTags(definitions) { let lastPartOfSpeech = ''; for (const definition of definitions) { - const dictionary = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'dictionary').map(tag => tag.name).sort()); - const partOfSpeech = JSON.stringify(definition.definitionTags.filter(tag => tag.category === 'partOfSpeech').map(tag => tag.name).sort()); + const dictionary = JSON.stringify(definition.definitionTags.filter((tag) => tag.category === 'dictionary').map((tag) => tag.name).sort()); + const partOfSpeech = JSON.stringify(definition.definitionTags.filter((tag) => tag.category === 'partOfSpeech').map((tag) => tag.name).sort()); const filterOutCategories = []; @@ -133,7 +117,7 @@ function dictTermsCompressTags(definitions) { lastPartOfSpeech = partOfSpeech; } - definition.definitionTags = definition.definitionTags.filter(tag => !filterOutCategories.includes(tag.category)); + definition.definitionTags = definition.definitionTags.filter((tag) => !filterOutCategories.includes(tag.category)); } } @@ -147,7 +131,7 @@ function dictTermsGroup(definitions, dictionaries) { } const keyString = key.toString(); - if (groups.hasOwnProperty(keyString)) { + if (hasOwn(groups, keyString)) { groups[keyString].push(definition); } else { groups[keyString] = [definition]; @@ -247,7 +231,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) { result.reading.add(definition.reading); for (const tag of definition.definitionTags) { - if (!definitionsByGloss[gloss].definitionTags.find(existingTag => existingTag.name === tag.name)) { + if (!definitionsByGloss[gloss].definitionTags.find((existingTag) => existingTag.name === tag.name)) { definitionsByGloss[gloss].definitionTags.push(tag); } } @@ -262,7 +246,7 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) { } for (const tag of definition.termTags) { - if (!result.expressions.get(definition.expression).get(definition.reading).find(existingTag => existingTag.name === tag.name)) { + if (!result.expressions.get(definition.expression).get(definition.reading).find((existingTag) => existingTag.name === tag.name)) { result.expressions.get(definition.expression).get(definition.reading).push(tag); } } @@ -326,46 +310,52 @@ function dictFieldSplit(field) { return field.length === 0 ? [] : field.split(' '); } -async function dictFieldFormat(field, definition, mode, options) { - const markers = [ - 'audio', - 'character', - 'cloze-body', - 'cloze-prefix', - 'cloze-suffix', - 'dictionary', - 'expression', - 'furigana', - 'furigana-plain', - 'glossary', - 'glossary-brief', - 'kunyomi', - 'onyomi', - 'reading', - 'screenshot', - 'sentence', - 'tags', - 'url' - ]; - - for (const marker of markers) { - const data = { - marker, - definition, - group: options.general.resultOutputMode === 'group', - merge: options.general.resultOutputMode === 'merge', - modeTermKanji: mode === 'term-kanji', - modeTermKana: mode === 'term-kana', - modeKanji: mode === 'kanji', - compactGlossaries: options.general.compactGlossaries - }; - - const html = await apiTemplateRender(options.anki.fieldTemplates, data, true); - field = field.replace(`{${marker}}`, html); - } - - return field; +async function dictFieldFormat(field, definition, mode, options, exceptions) { + const data = { + marker: null, + definition, + group: options.general.resultOutputMode === 'group', + merge: options.general.resultOutputMode === 'merge', + modeTermKanji: mode === 'term-kanji', + modeTermKana: mode === 'term-kana', + modeKanji: mode === 'kanji', + compactGlossaries: options.general.compactGlossaries + }; + const markers = dictFieldFormat.markers; + const pattern = /\{([\w-]+)\}/g; + return await stringReplaceAsync(field, pattern, async (g0, marker) => { + if (!markers.has(marker)) { + return g0; + } + data.marker = marker; + try { + return await apiTemplateRender(options.anki.fieldTemplates, data, true); + } catch (e) { + if (exceptions) { exceptions.push(e); } + return `{${marker}-render-error}`; + } + }); } +dictFieldFormat.markers = new Set([ + 'audio', + 'character', + 'cloze-body', + 'cloze-prefix', + 'cloze-suffix', + 'dictionary', + 'expression', + 'furigana', + 'furigana-plain', + 'glossary', + 'glossary-brief', + 'kunyomi', + 'onyomi', + 'reading', + 'screenshot', + 'sentence', + 'tags', + 'url' +]); async function dictNoteFormat(definition, mode, options) { const note = {fields: {}, tags: options.anki.tags}; diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index fba437da..8f43cf9a 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -79,6 +79,47 @@ function handlebarsSanitizeCssClass(options) { return options.fn(this).replace(/[^_a-z0-9\u00a0-\uffff]/ig, '_'); } +function handlebarsRegexReplace(...args) { + // Usage: + // {{#regexReplace regex string [flags]}}content{{/regexReplace}} + // regex: regular expression string + // string: string to replace + // flags: optional flags for regular expression + // e.g. "i" for case-insensitive, "g" for replace all + let value = args[args.length - 1].fn(this); + if (args.length >= 3) { + try { + const flags = args.length > 3 ? args[2] : 'g'; + const regex = new RegExp(args[0], flags); + value = value.replace(regex, args[1]); + } catch (e) { + return `${e}`; + } + } + return value; +} + +function handlebarsRegexMatch(...args) { + // Usage: + // {{#regexMatch regex [flags]}}content{{/regexMatch}} + // regex: regular expression string + // flags: optional flags for regular expression + // e.g. "i" for case-insensitive, "g" for match all + let value = args[args.length - 1].fn(this); + if (args.length >= 2) { + try { + const flags = args.length > 2 ? args[1] : ''; + const regex = new RegExp(args[0], flags); + const parts = []; + value.replace(regex, (g0) => parts.push(g0)); + value = parts.join(''); + } catch (e) { + return `${e}`; + } + } + return value; +} + function handlebarsRegisterHelpers() { if (Handlebars.partials !== Handlebars.templates) { Handlebars.partials = Handlebars.templates; @@ -88,6 +129,8 @@ function handlebarsRegisterHelpers() { Handlebars.registerHelper('kanjiLinks', handlebarsKanjiLinks); Handlebars.registerHelper('multiLine', handlebarsMultiLine); Handlebars.registerHelper('sanitizeCssClass', handlebarsSanitizeCssClass); + Handlebars.registerHelper('regexReplace', handlebarsRegexReplace); + Handlebars.registerHelper('regexMatch', handlebarsRegexMatch); } } diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js new file mode 100644 index 00000000..62111f73 --- /dev/null +++ b/ext/bg/js/mecab.js @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +class Mecab { + constructor() { + this.port = null; + this.listeners = {}; + this.sequence = 0; + } + + onError(error) { + logError(error, false); + } + + async checkVersion() { + try { + const {version} = await this.invoke('get_version', {}); + if (version !== Mecab.version) { + this.stopListener(); + throw new Error(`Unsupported MeCab native messenger version ${version}. Yomichan supports version ${Mecab.version}.`); + } + } catch (error) { + this.onError(error); + } + } + + async parseText(text) { + return await this.invoke('parse_text', {text}); + } + + startListener() { + if (this.port !== null) { return; } + this.port = chrome.runtime.connectNative('yomichan_mecab'); + this.port.onMessage.addListener(this.onNativeMessage.bind(this)); + this.checkVersion(); + } + + stopListener() { + if (this.port === null) { return; } + this.port.disconnect(); + this.port = null; + this.listeners = {}; + this.sequence = 0; + } + + onNativeMessage({sequence, data}) { + if (hasOwn(this.listeners, sequence)) { + const {callback, timer} = this.listeners[sequence]; + clearTimeout(timer); + callback(data); + delete this.listeners[sequence]; + } + } + + invoke(action, params) { + if (this.port === null) { + return Promise.resolve({}); + } + return new Promise((resolve, reject) => { + const sequence = this.sequence++; + + this.listeners[sequence] = { + callback: resolve, + timer: setTimeout(() => { + delete this.listeners[sequence]; + reject(new Error(`Mecab invoke timed out in ${Mecab.timeout} ms`)); + }, Mecab.timeout) + }; + + this.port.postMessage({action, params, sequence}); + }); + } +} + +Mecab.timeout = 5000; +Mecab.version = 1; diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index be1ccfbb..e53a8a13 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -311,6 +311,13 @@ function profileOptionsCreateDefaults() { dictionaries: {}, + parsing: { + enableScanningParser: true, + enableMecabParser: false, + selectedParser: null, + readingMode: 'hiragana' + }, + anki: { enable: false, server: 'http://127.0.0.1:8765', @@ -329,7 +336,7 @@ function profileOptionsSetDefaults(options) { const combine = (target, source) => { for (const key in source) { - if (!target.hasOwnProperty(key)) { + if (!hasOwn(target, key)) { target[key] = source[key]; } } @@ -382,7 +389,7 @@ function optionsUpdateVersion(options, defaultProfileOptions) { // Remove invalid const profiles = options.profiles; for (let i = profiles.length - 1; i >= 0; --i) { - if (!utilIsObject(profiles[i])) { + if (!isObject(profiles[i])) { profiles.splice(i, 1); } } @@ -422,7 +429,7 @@ function optionsUpdateVersion(options, defaultProfileOptions) { function optionsLoad() { return new Promise((resolve, reject) => { - chrome.storage.local.get(['options'], store => { + chrome.storage.local.get(['options'], (store) => { const error = chrome.runtime.lastError; if (error) { reject(new Error(error)); @@ -430,17 +437,17 @@ function optionsLoad() { resolve(store.options); } }); - }).then(optionsStr => { + }).then((optionsStr) => { if (typeof optionsStr === 'string') { const options = JSON.parse(optionsStr); - if (utilIsObject(options)) { + if (isObject(options)) { return options; } } return {}; }).catch(() => { return {}; - }).then(options => { + }).then((options) => { return ( Array.isArray(options.profiles) ? optionsUpdateVersion(options, {}) : diff --git a/ext/bg/js/page-exit-prevention.js b/ext/bg/js/page-exit-prevention.js new file mode 100644 index 00000000..aee4e3c2 --- /dev/null +++ b/ext/bg/js/page-exit-prevention.js @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +class PageExitPrevention { + constructor() { + } + + start() { + PageExitPrevention._addInstance(this); + } + + end() { + PageExitPrevention._removeInstance(this); + } + + static _addInstance(instance) { + const size = PageExitPrevention._instances.size; + PageExitPrevention._instances.set(instance, true); + if (size === 0) { + window.addEventListener('beforeunload', PageExitPrevention._onBeforeUnload); + } + } + + static _removeInstance(instance) { + if ( + PageExitPrevention._instances.delete(instance) && + PageExitPrevention._instances.size === 0 + ) { + window.removeEventListener('beforeunload', PageExitPrevention._onBeforeUnload); + } + } + + static _onBeforeUnload(e) { + if (PageExitPrevention._instances.size === 0) { + return; + } + + e.preventDefault(); + e.returnValue = ''; + return ''; + } +} + +PageExitPrevention._instances = new Map(); diff --git a/ext/bg/js/profile-conditions.js b/ext/bg/js/profile-conditions.js index 5daa904e..ebc6680a 100644 --- a/ext/bg/js/profile-conditions.js +++ b/ext/bg/js/profile-conditions.js @@ -17,6 +17,26 @@ */ +function _profileConditionTestDomain(urlDomain, domain) { + return ( + urlDomain.endsWith(domain) && + ( + domain.length === urlDomain.length || + urlDomain[urlDomain.length - domain.length - 1] === '.' + ) + ); +} + +function _profileConditionTestDomainList(url, domainList) { + const urlDomain = new URL(url).hostname.toLowerCase(); + for (const domain of domainList) { + if (_profileConditionTestDomain(urlDomain, domain)) { + return true; + } + } + return false; +} + const profileConditionsDescriptor = { popupLevel: { name: 'Popup Level', @@ -66,10 +86,10 @@ const profileConditionsDescriptor = { placeholder: 'Comma separated list of domains', defaultValue: 'example.com', transformCache: {}, - transform: (optionValue) => optionValue.split(/[,;\s]+/).map(v => v.trim().toLowerCase()).filter(v => v.length > 0), + transform: (optionValue) => optionValue.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0), transformReverse: (transformedOptionValue) => transformedOptionValue.join(', '), validateTransformed: (transformedOptionValue) => (transformedOptionValue.length > 0), - test: ({url}, transformedOptionValue) => (transformedOptionValue.indexOf(new URL(url).hostname.toLowerCase()) >= 0) + test: ({url}, transformedOptionValue) => _profileConditionTestDomainList(url, transformedOptionValue) }, matchRegExp: { name: 'Matches RegExp', diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index 3afc1506..7d73d49b 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -29,7 +29,7 @@ function requestJson(url, action, params) { } else { xhr.send(); } - }).then(responseText => { + }).then((responseText) => { try { return JSON.parse(responseText); } diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index b21dac17..6ba8467e 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -25,7 +25,12 @@ async function searchFrontendSetup() { const options = await apiOptionsGet(optionsContext); if (!options.scanning.enableOnSearchPage) { return; } - window.frontendInitializationData = {depth: 1, proxy: false}; + const ignoreNodes = ['.scan-disable', '.scan-disable *']; + if (!options.scanning.enableOnPopupExpressions) { + ignoreNodes.push('.expression-scan-toggle', '.expression-scan-toggle *'); + } + + window.frontendInitializationData = {depth: 1, ignoreNodes, proxy: false}; const scriptSrcs = [ '/fg/js/frontend-api-receiver.js', diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js new file mode 100644 index 00000000..8dc2e30a --- /dev/null +++ b/ext/bg/js/search-query-parser.js @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +class QueryParser { + constructor(search) { + this.search = search; + this.pendingLookup = false; + this.clickScanPrevent = false; + + this.parseResults = []; + this.selectedParser = null; + + this.queryParser = document.querySelector('#query-parser'); + this.queryParserSelect = document.querySelector('#query-parser-select'); + + this.queryParser.addEventListener('mousedown', (e) => this.onMouseDown(e)); + this.queryParser.addEventListener('mouseup', (e) => this.onMouseUp(e)); + } + + onError(error) { + logError(error, false); + } + + onMouseDown(e) { + if (DOM.isMouseButtonPressed(e, 'primary')) { + this.clickScanPrevent = false; + } + } + + onMouseUp(e) { + if ( + this.search.options.scanning.enablePopupSearch && + !this.clickScanPrevent && + DOM.isMouseButtonPressed(e, 'primary') + ) { + const selectText = this.search.options.scanning.selectText; + this.onTermLookup(e, {disableScroll: true, selectText}); + } + } + + onMouseMove(e) { + if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) { + return; + } + + const scanningOptions = this.search.options.scanning; + const scanningModifier = scanningOptions.modifier; + if (!( + Frontend.isScanningModifierPressed(scanningModifier, e) || + (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary')) + )) { + return; + } + + const selectText = this.search.options.scanning.selectText; + this.onTermLookup(e, {disableScroll: true, disableHistory: true, selectText}); + } + + onMouseLeave(e) { + this.clickScanPrevent = true; + clearTimeout(e.target.dataset.timer); + delete e.target.dataset.timer; + } + + onTermLookup(e, params) { + this.pendingLookup = true; + (async () => { + await this.search.onTermLookup(e, params); + this.pendingLookup = false; + })(); + } + + onParserChange(e) { + const selectedParser = e.target.value; + this.selectedParser = selectedParser; + apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext()); + this.renderParseResult(this.getParseResult()); + } + + refreshSelectedParser() { + if (this.parseResults.length > 0) { + if (this.selectedParser === null) { + this.selectedParser = this.search.options.parsing.selectedParser; + } + if (this.selectedParser === null || !this.getParseResult()) { + const selectedParser = this.parseResults[0].id; + this.selectedParser = selectedParser; + apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext()); + } + } + } + + getParseResult() { + return this.parseResults.find((r) => r.id === this.selectedParser); + } + + async setText(text) { + this.search.setSpinnerVisible(true); + + await this.setPreview(text); + + this.parseResults = await this.parseText(text); + this.refreshSelectedParser(); + + this.renderParserSelect(); + await this.renderParseResult(); + + this.search.setSpinnerVisible(false); + } + + async parseText(text) { + const results = []; + if (this.search.options.parsing.enableScanningParser) { + results.push({ + name: 'Scanning parser', + id: 'scan', + parsedText: await apiTextParse(text, this.search.getOptionsContext()) + }); + } + if (this.search.options.parsing.enableMecabParser) { + const mecabResults = await apiTextParseMecab(text, this.search.getOptionsContext()); + for (const mecabDictName in mecabResults) { + results.push({ + name: `MeCab: ${mecabDictName}`, + id: `mecab-${mecabDictName}`, + parsedText: mecabResults[mecabDictName] + }); + } + } + return results; + } + + async setPreview(text) { + const previewTerms = []; + while (text.length > 0) { + const tempText = text.slice(0, 2); + previewTerms.push([{text: Array.from(tempText)}]); + text = text.slice(2); + } + this.queryParser.innerHTML = await apiTemplateRender('query-parser.html', { + terms: previewTerms, + preview: true + }); + + for (const charElement of this.queryParser.querySelectorAll('.query-parser-char')) { + this.activateScanning(charElement); + } + } + + renderParserSelect() { + this.queryParserSelect.innerHTML = ''; + if (this.parseResults.length > 1) { + const select = document.createElement('select'); + select.classList.add('form-control'); + for (const parseResult of this.parseResults) { + const option = document.createElement('option'); + option.value = parseResult.id; + option.innerText = parseResult.name; + option.defaultSelected = this.selectedParser === parseResult.id; + select.appendChild(option); + } + select.addEventListener('change', this.onParserChange.bind(this)); + this.queryParserSelect.appendChild(select); + } + } + + async renderParseResult() { + const parseResult = this.getParseResult(); + if (!parseResult) { + this.queryParser.innerHTML = ''; + return; + } + + this.queryParser.innerHTML = await apiTemplateRender( + 'query-parser.html', + {terms: QueryParser.processParseResultForDisplay(parseResult.parsedText)} + ); + + for (const charElement of this.queryParser.querySelectorAll('.query-parser-char')) { + this.activateScanning(charElement); + } + } + + activateScanning(element) { + element.addEventListener('mousemove', (e) => { + clearTimeout(e.target.dataset.timer); + if (this.search.options.scanning.modifier === 'none') { + e.target.dataset.timer = setTimeout(() => { + this.onMouseMove(e); + delete e.target.dataset.timer; + }, this.search.options.scanning.delay); + } else { + this.onMouseMove(e); + } + }); + element.addEventListener('mouseleave', (e) => { + this.onMouseLeave(e); + }); + } + + static processParseResultForDisplay(result) { + return result.map((term) => { + return term.filter((part) => part.text.trim()).map((part) => { + return { + text: Array.from(part.text), + reading: part.reading, + raw: !part.reading || !part.reading.trim() + }; + }); + }); + } +} diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index dbfcb15d..00b7ca4b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -32,6 +32,8 @@ class DisplaySearch extends Display { url: window.location.href }; + this.queryParser = new QueryParser(this); + this.search = document.querySelector('#search'); this.query = document.querySelector('#query'); this.intro = document.querySelector('#intro'); @@ -72,11 +74,11 @@ class DisplaySearch extends Display { const query = DisplaySearch.getSearchQueryFromLocation(window.location.href) || ''; if (e.target.checked) { window.wanakana.bind(this.query); - this.query.value = window.wanakana.toKana(query); + this.setQuery(window.wanakana.toKana(query)); apiOptionsSet({general: {enableWanakana: true}}, this.getOptionsContext()); } else { window.wanakana.unbind(this.query); - this.query.value = query; + this.setQuery(query); apiOptionsSet({general: {enableWanakana: false}}, this.getOptionsContext()); } this.onSearchQueryUpdated(this.query.value, false); @@ -86,9 +88,9 @@ class DisplaySearch extends Display { const query = DisplaySearch.getSearchQueryFromLocation(window.location.href); if (query !== null) { if (this.isWanakanaEnabled()) { - this.query.value = window.wanakana.toKana(query); + this.setQuery(window.wanakana.toKana(query)); } else { - this.query.value = query; + this.setQuery(query); } this.onSearchQueryUpdated(this.query.value, false); } @@ -159,18 +161,19 @@ class DisplaySearch extends Display { e.preventDefault(); const query = this.query.value; + this.queryParser.setText(query); const queryString = query.length > 0 ? `?query=${encodeURIComponent(query)}` : ''; window.history.pushState(null, '', `${window.location.pathname}${queryString}`); this.onSearchQueryUpdated(query, true); } - onPopState(e) { + onPopState() { const query = DisplaySearch.getSearchQueryFromLocation(window.location.href) || ''; if (this.query !== null) { if (this.isWanakanaEnabled()) { - this.query.value = window.wanakana.toKana(query); + this.setQuery(window.wanakana.toKana(query)); } else { - this.query.value = query; + this.setQuery(query); } } @@ -179,27 +182,14 @@ class DisplaySearch extends Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); + const ignoreKeys = DisplaySearch.onKeyDownIgnoreKeys; - let activeModifierMap = { + const activeModifierMap = { 'Control': e.ctrlKey, 'Meta': e.metaKey, 'ANY_MOD': true }; - const ignoreKeys = { - 'ANY_MOD': ['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End'] - .concat( - Array.from(Array(24).keys()) - .map(i => `F${i + 1}`) - ), - 'Control': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'], - 'Meta': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'], - 'OS': [], - 'Alt': [], - 'AltGraph': [], - 'Shift': [] - } - let preventFocus = false; for (const [modifier, keys] of Object.entries(ignoreKeys)) { const modifierActive = activeModifierMap[modifier]; @@ -216,19 +206,28 @@ class DisplaySearch extends Display { async onSearchQueryUpdated(query, animate) { try { + const details = {}; + const match = /[*\uff0a]+$/.exec(query); + if (match !== null) { + details.wildcard = true; + query = query.substring(0, query.length - match[0].length); + } + const valid = (query.length > 0); this.setIntroVisible(!valid, animate); this.updateSearchButton(); if (valid) { - const {definitions} = await apiTermsFind(query, this.optionsContext); + const {definitions} = await apiTermsFind(query, details, this.optionsContext); this.setContentTerms(definitions, { focus: false, - sentence: null, + disableHistory: true, + sentence: {text: query, offset: 0}, url: window.location.href }); } else { this.container.textContent = ''; } + window.parent.postMessage('popupClose', '*'); } catch (e) { this.onError(e); } @@ -236,7 +235,7 @@ class DisplaySearch extends Display { onRuntimeMessage({action, params}, sender, callback) { const handlers = DisplaySearch.runtimeMessageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; const result = handler(this, params); callback(result); @@ -247,7 +246,7 @@ class DisplaySearch extends Display { initClipboardMonitor() { // ignore copy from search page - window.addEventListener('copy', (e) => { + window.addEventListener('copy', () => { this.clipboardPrevText = document.getSelection().toString().trim(); }); } @@ -261,11 +260,11 @@ class DisplaySearch extends Display { } else if (IS_FIREFOX === false) { curText = (await apiClipboardGet()).trim(); } - if (curText && (curText !== this.clipboardPrevText)) { + if (curText && (curText !== this.clipboardPrevText) && jpIsJapaneseText(curText)) { if (this.isWanakanaEnabled()) { - this.query.value = window.wanakana.toKana(curText); + this.setQuery(window.wanakana.toKana(curText)); } else { - this.query.value = curText; + this.setQuery(curText); } const queryString = curText.length > 0 ? `?query=${encodeURIComponent(curText)}` : ''; @@ -292,8 +291,9 @@ class DisplaySearch extends Display { return this.optionsContext; } - setCustomCss() { - // No custom CSS + setQuery(query) { + this.query.value = query; + this.queryParser.setText(query); } setIntroVisible(visible, animate) { @@ -325,7 +325,7 @@ class DisplaySearch extends Display { this.intro.style.transition = ''; this.intro.style.height = ''; const size = this.intro.getBoundingClientRect(); - this.intro.style.height = `0px`; + this.intro.style.height = '0px'; this.intro.style.transition = `height ${duration}s ease-in-out 0s`; window.getComputedStyle(this.intro).getPropertyValue('height'); // Commits height so next line can start animation this.intro.style.height = `${size.height}px`; @@ -357,7 +357,7 @@ class DisplaySearch extends Display { } static getSearchQueryFromLocation(url) { - let match = /^[^\?#]*\?(?:[^&#]*&)?query=([^&#]*)/.exec(url); + const match = /^[^?#]*\?(?:[^&#]*&)?query=([^&#]*)/.exec(url); return match !== null ? decodeURIComponent(match[1]) : null; } } @@ -368,4 +368,19 @@ DisplaySearch.runtimeMessageHandlers = { } }; +DisplaySearch.onKeyDownIgnoreKeys = { + 'ANY_MOD': [ + 'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End', + 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', + 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20', + 'F21', 'F22', 'F23', 'F24' + ], + 'Control': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'], + 'Meta': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'], + 'OS': [], + 'Alt': [], + 'AltGraph': [], + 'Shift': [] +}; + window.yomichan_search = DisplaySearch.create(); diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js deleted file mode 100644 index 05a0604a..00000000 --- a/ext/bg/js/settings.js +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (C) 2016-2017 Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -async function getOptionsArray() { - const optionsFull = await apiOptionsGetFull(); - return optionsFull.profiles.map(profile => profile.options); -} - -async function formRead(options) { - options.general.enable = $('#enable').prop('checked'); - options.general.showGuide = $('#show-usage-guide').prop('checked'); - options.general.compactTags = $('#compact-tags').prop('checked'); - options.general.compactGlossaries = $('#compact-glossaries').prop('checked'); - options.general.resultOutputMode = $('#result-output-mode').val(); - options.general.debugInfo = $('#show-debug-info').prop('checked'); - options.general.showAdvanced = $('#show-advanced-options').prop('checked'); - options.general.maxResults = parseInt($('#max-displayed-results').val(), 10); - options.general.popupDisplayMode = $('#popup-display-mode').val(); - options.general.popupHorizontalTextPosition = $('#popup-horizontal-text-position').val(); - options.general.popupVerticalTextPosition = $('#popup-vertical-text-position').val(); - options.general.popupWidth = parseInt($('#popup-width').val(), 10); - options.general.popupHeight = parseInt($('#popup-height').val(), 10); - options.general.popupHorizontalOffset = parseInt($('#popup-horizontal-offset').val(), 0); - options.general.popupVerticalOffset = parseInt($('#popup-vertical-offset').val(), 10); - options.general.popupHorizontalOffset2 = parseInt($('#popup-horizontal-offset2').val(), 0); - options.general.popupVerticalOffset2 = parseInt($('#popup-vertical-offset2').val(), 10); - options.general.popupTheme = $('#popup-theme').val(); - options.general.popupOuterTheme = $('#popup-outer-theme').val(); - options.general.customPopupCss = $('#custom-popup-css').val(); - options.general.customPopupOuterCss = $('#custom-popup-outer-css').val(); - - options.audio.enabled = $('#audio-playback-enabled').prop('checked'); - options.audio.autoPlay = $('#auto-play-audio').prop('checked'); - options.audio.volume = parseFloat($('#audio-playback-volume').val()); - options.audio.customSourceUrl = $('#audio-custom-source').val(); - options.audio.textToSpeechVoice = $('#text-to-speech-voice').val(); - - options.scanning.middleMouse = $('#middle-mouse-button-scan').prop('checked'); - options.scanning.touchInputEnabled = $('#touch-input-enabled').prop('checked'); - options.scanning.selectText = $('#select-matched-text').prop('checked'); - options.scanning.alphanumeric = $('#search-alphanumeric').prop('checked'); - options.scanning.autoHideResults = $('#auto-hide-results').prop('checked'); - options.scanning.deepDomScan = $('#deep-dom-scan').prop('checked'); - options.scanning.enablePopupSearch = $('#enable-search-within-first-popup').prop('checked'); - options.scanning.enableOnPopupExpressions = $('#enable-scanning-of-popup-expressions').prop('checked'); - options.scanning.enableOnSearchPage = $('#enable-scanning-on-search-page').prop('checked'); - options.scanning.delay = parseInt($('#scan-delay').val(), 10); - options.scanning.length = parseInt($('#scan-length').val(), 10); - options.scanning.modifier = $('#scan-modifier-key').val(); - options.scanning.popupNestingMaxDepth = parseInt($('#popup-nesting-max-depth').val(), 10); - - const optionsAnkiEnableOld = options.anki.enable; - options.anki.enable = $('#anki-enable').prop('checked'); - options.anki.tags = utilBackgroundIsolate($('#card-tags').val().split(/[,; ]+/)); - options.anki.sentenceExt = parseInt($('#sentence-detection-extent').val(), 10); - options.anki.server = $('#interface-server').val(); - options.anki.screenshot.format = $('#screenshot-format').val(); - options.anki.screenshot.quality = parseInt($('#screenshot-quality').val(), 10); - options.anki.fieldTemplates = $('#field-templates').val(); - - if (optionsAnkiEnableOld && !ankiErrorShown()) { - options.anki.terms.deck = $('#anki-terms-deck').val(); - options.anki.terms.model = $('#anki-terms-model').val(); - options.anki.terms.fields = utilBackgroundIsolate(ankiFieldsToDict($('#terms .anki-field-value'))); - options.anki.kanji.deck = $('#anki-kanji-deck').val(); - options.anki.kanji.model = $('#anki-kanji-model').val(); - options.anki.kanji.fields = utilBackgroundIsolate(ankiFieldsToDict($('#kanji .anki-field-value'))); - } - - options.general.mainDictionary = $('#dict-main').val(); - $('.dict-group').each((index, element) => { - const dictionary = $(element); - options.dictionaries[dictionary.data('title')] = utilBackgroundIsolate({ - priority: parseInt(dictionary.find('.dict-priority').val(), 10), - enabled: dictionary.find('.dict-enabled').prop('checked'), - allowSecondarySearches: dictionary.find('.dict-allow-secondary-searches').prop('checked') - }); - }); -} - -async function formWrite(options) { - $('#enable').prop('checked', options.general.enable); - $('#show-usage-guide').prop('checked', options.general.showGuide); - $('#compact-tags').prop('checked', options.general.compactTags); - $('#compact-glossaries').prop('checked', options.general.compactGlossaries); - $('#result-output-mode').val(options.general.resultOutputMode); - $('#show-debug-info').prop('checked', options.general.debugInfo); - $('#show-advanced-options').prop('checked', options.general.showAdvanced); - $('#max-displayed-results').val(options.general.maxResults); - $('#popup-display-mode').val(options.general.popupDisplayMode); - $('#popup-horizontal-text-position').val(options.general.popupHorizontalTextPosition); - $('#popup-vertical-text-position').val(options.general.popupVerticalTextPosition); - $('#popup-width').val(options.general.popupWidth); - $('#popup-height').val(options.general.popupHeight); - $('#popup-horizontal-offset').val(options.general.popupHorizontalOffset); - $('#popup-vertical-offset').val(options.general.popupVerticalOffset); - $('#popup-horizontal-offset2').val(options.general.popupHorizontalOffset2); - $('#popup-vertical-offset2').val(options.general.popupVerticalOffset2); - $('#popup-theme').val(options.general.popupTheme); - $('#popup-outer-theme').val(options.general.popupOuterTheme); - $('#custom-popup-css').val(options.general.customPopupCss); - $('#custom-popup-outer-css').val(options.general.customPopupOuterCss); - - $('#audio-playback-enabled').prop('checked', options.audio.enabled); - $('#auto-play-audio').prop('checked', options.audio.autoPlay); - $('#audio-playback-volume').val(options.audio.volume); - $('#audio-custom-source').val(options.audio.customSourceUrl); - $('#text-to-speech-voice').val(options.audio.textToSpeechVoice).attr('data-value', options.audio.textToSpeechVoice); - - $('#middle-mouse-button-scan').prop('checked', options.scanning.middleMouse); - $('#touch-input-enabled').prop('checked', options.scanning.touchInputEnabled); - $('#select-matched-text').prop('checked', options.scanning.selectText); - $('#search-alphanumeric').prop('checked', options.scanning.alphanumeric); - $('#auto-hide-results').prop('checked', options.scanning.autoHideResults); - $('#deep-dom-scan').prop('checked', options.scanning.deepDomScan); - $('#enable-search-within-first-popup').prop('checked', options.scanning.enablePopupSearch); - $('#enable-scanning-of-popup-expressions').prop('checked', options.scanning.enableOnPopupExpressions); - $('#enable-scanning-on-search-page').prop('checked', options.scanning.enableOnSearchPage); - $('#scan-delay').val(options.scanning.delay); - $('#scan-length').val(options.scanning.length); - $('#scan-modifier-key').val(options.scanning.modifier); - $('#popup-nesting-max-depth').val(options.scanning.popupNestingMaxDepth); - - $('#anki-enable').prop('checked', options.anki.enable); - $('#card-tags').val(options.anki.tags.join(' ')); - $('#sentence-detection-extent').val(options.anki.sentenceExt); - $('#interface-server').val(options.anki.server); - $('#screenshot-format').val(options.anki.screenshot.format); - $('#screenshot-quality').val(options.anki.screenshot.quality); - $('#field-templates').val(options.anki.fieldTemplates); - - try { - await dictionaryGroupsPopulate(options); - await formMainDictionaryOptionsPopulate(options); - } catch (e) { - dictionaryErrorsShow([e]); - } - - try { - await ankiDeckAndModelPopulate(options); - } catch (e) { - ankiErrorShow(e); - } - - formUpdateVisibility(options); -} - -function formSetupEventListeners() { - $('#dict-purge-link').click(utilAsync(onDictionaryPurge)); - $('#dict-file').change(utilAsync(onDictionaryImport)); - $('#dict-file-button').click(onDictionaryImportButtonClick); - - $('#field-templates-reset').click(utilAsync(onAnkiFieldTemplatesReset)); - $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change(utilAsync(onFormOptionsChanged)); - $('.anki-model').change(utilAsync(onAnkiModelChanged)); -} - -function formUpdateVisibility(options) { - const general = $('#anki-general'); - if (options.anki.enable) { - general.show(); - } else { - general.hide(); - } - - const advanced = $('.options-advanced'); - if (options.general.showAdvanced) { - advanced.show(); - } else { - advanced.hide(); - } - - const mainGroup = $('#dict-main-group'); - if (options.general.resultOutputMode === 'merge') { - mainGroup.show(); - } else { - mainGroup.hide(); - } - - const debug = $('#debug'); - if (options.general.debugInfo) { - const temp = utilIsolate(options); - temp.anki.fieldTemplates = '...'; - const text = JSON.stringify(temp, null, 4); - debug.html(handlebarsEscape(text)); - debug.show(); - } else { - debug.hide(); - } -} - -async function formMainDictionaryOptionsPopulate(options) { - const select = $('#dict-main').empty(); - select.append($('<option class="text-muted" value="">Not selected</option>')); - - let mainDictionary = ''; - for (const dictRow of toIterable(await utilDatabaseSummarize())) { - if (dictRow.sequenced) { - select.append($(`<option value="${dictRow.title}">${dictRow.title}</option>`)); - if (dictRow.title === options.general.mainDictionary) { - mainDictionary = dictRow.title; - } - } - } - - select.val(mainDictionary); -} - -async function onFormOptionsChanged(e) { - if (!e.originalEvent && !e.isTrigger) { - return; - } - - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - const optionsAnkiEnableOld = options.anki.enable; - const optionsAnkiServerOld = options.anki.server; - - await formRead(options); - await settingsSaveOptions(); - formUpdateVisibility(options); - - try { - const ankiUpdated = - options.anki.enable !== optionsAnkiEnableOld || - options.anki.server !== optionsAnkiServerOld; - - if (ankiUpdated) { - ankiSpinnerShow(true); - await ankiDeckAndModelPopulate(options); - ankiErrorShow(); - } - } catch (e) { - ankiErrorShow(e); - } finally { - ankiSpinnerShow(false); - } -} - -async function onReady() { - showExtensionInformation(); - - formSetupEventListeners(); - appearanceInitialize(); - await audioSettingsInitialize(); - await profileOptionsSetup(); - - storageInfoInitialize(); - - chrome.runtime.onMessage.addListener(onMessage); -} - -$(document).ready(utilAsync(onReady)); - - -/* - * Appearance - */ - -function appearanceInitialize() { - let previewVisible = false; - $('#settings-popup-preview-button').on('click', () => { - if (previewVisible) { return; } - showAppearancePreview(); - previewVisible = true; - }); -} - -function showAppearancePreview() { - const container = $('#settings-popup-preview-container'); - const buttonContainer = $('#settings-popup-preview-button-container'); - const settings = $('#settings-popup-preview-settings'); - const text = $('#settings-popup-preview-text'); - const customCss = $('#custom-popup-css'); - const customOuterCss = $('#custom-popup-outer-css'); - - const frame = document.createElement('iframe'); - frame.src = '/bg/settings-popup-preview.html'; - frame.id = 'settings-popup-preview-frame'; - - window.wanakana.bind(text[0]); - - text.on('input', () => { - const action = 'setText'; - const params = {text: text.val()}; - frame.contentWindow.postMessage({action, params}, '*'); - }); - customCss.on('input', () => { - const action = 'setCustomCss'; - const params = {css: customCss.val()}; - frame.contentWindow.postMessage({action, params}, '*'); - }); - customOuterCss.on('input', () => { - const action = 'setCustomOuterCss'; - const params = {css: customOuterCss.val()}; - frame.contentWindow.postMessage({action, params}, '*'); - }); - - container.append(frame); - buttonContainer.remove(); - settings.css('display', ''); -} - - -/* - * Audio - */ - -let audioSourceUI = null; - -async function audioSettingsInitialize() { - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - audioSourceUI = new AudioSourceUI.Container(options.audio.sources, $('.audio-source-list'), $('.audio-source-add')); - audioSourceUI.save = () => apiOptionsSave(); - - textToSpeechInitialize(); -} - -function textToSpeechInitialize() { - if (typeof speechSynthesis === 'undefined') { return; } - - speechSynthesis.addEventListener('voiceschanged', () => updateTextToSpeechVoices(), false); - updateTextToSpeechVoices(); - - $('#text-to-speech-voice-test').on('click', () => textToSpeechTest()); -} - -function updateTextToSpeechVoices() { - const voices = Array.prototype.map.call(speechSynthesis.getVoices(), (voice, index) => ({voice, index})); - voices.sort(textToSpeechVoiceCompare); - if (voices.length > 0) { - $('#text-to-speech-voice-container').css('display', ''); - } - - const select = $('#text-to-speech-voice'); - select.empty(); - select.append($('<option>').val('').text('None')); - for (const {voice} of voices) { - select.append($('<option>').val(voice.voiceURI).text(`${voice.name} (${voice.lang})`)); - } - - select.val(select.attr('data-value')); -} - -function languageTagIsJapanese(languageTag) { - return ( - languageTag.startsWith('ja-') || - languageTag.startsWith('jpn-') - ); -} - -function textToSpeechVoiceCompare(a, b) { - const aIsJapanese = languageTagIsJapanese(a.voice.lang); - const bIsJapanese = languageTagIsJapanese(b.voice.lang); - if (aIsJapanese) { - if (!bIsJapanese) { return -1; } - } else { - if (bIsJapanese) { return 1; } - } - - const aIsDefault = a.voice.default; - const bIsDefault = b.voice.default; - if (aIsDefault) { - if (!bIsDefault) { return -1; } - } else { - if (bIsDefault) { return 1; } - } - - if (a.index < b.index) { return -1; } - if (a.index > b.index) { return 1; } - return 0; -} - -function textToSpeechTest() { - try { - const text = $('#text-to-speech-voice-test').attr('data-speech-text') || ''; - const voiceURI = $('#text-to-speech-voice').val(); - const voice = audioGetTextToSpeechVoice(voiceURI); - if (voice === null) { return; } - - const utterance = new SpeechSynthesisUtterance(text); - utterance.lang = 'ja-JP'; - utterance.voice = voice; - utterance.volume = 1.0; - - speechSynthesis.speak(utterance); - } catch (e) { - // NOP - } -} - - -/* - * Remote options updates - */ - -function settingsGetSource() { - return new Promise((resolve) => { - chrome.tabs.getCurrent((tab) => resolve(`settings${tab ? tab.id : ''}`)); - }); -} - -async function settingsSaveOptions() { - const source = await settingsGetSource(); - await apiOptionsSave(source); -} - -async function onOptionsUpdate({source}) { - const thisSource = await settingsGetSource(); - if (source === thisSource) { return; } - - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - await formWrite(options); -} - -function onMessage({action, params}, sender, callback) { - switch (action) { - case 'optionsUpdate': - onOptionsUpdate(params); - break; - case 'getUrl': - callback({url: window.location.href}); - break; - } -} - - -/* - * Dictionary - */ - -function dictionaryErrorToString(error) { - if (error.toString) { - error = error.toString(); - } else { - error = `${error}`; - } - - for (const [match, subst] of dictionaryErrorToString.overrides) { - if (error.includes(match)) { - error = subst; - break; - } - } - - return error; -} -dictionaryErrorToString.overrides = [ - [ - 'A mutation operation was attempted on a database that did not allow mutations.', - 'Access to IndexedDB appears to be restricted. Firefox seems to require that the history preference is set to "Remember history" before IndexedDB use of any kind is allowed.' - ], - [ - 'The operation failed for reasons unrelated to the database itself and not covered by any other error code.', - 'Unable to access IndexedDB due to a possibly corrupt user profile. Try using the "Refresh Firefox" feature to reset your user profile.' - ], - [ - 'BulkError', - 'Unable to finish importing dictionary data into IndexedDB. This may indicate that you do not have sufficient disk space available to complete this operation.' - ] -]; - -function dictionaryErrorsShow(errors) { - const dialog = $('#dict-error'); - dialog.show().text(''); - - if (errors !== null && errors.length > 0) { - const uniqueErrors = {}; - for (let e of errors) { - e = dictionaryErrorToString(e); - uniqueErrors[e] = uniqueErrors.hasOwnProperty(e) ? uniqueErrors[e] + 1 : 1; - } - - for (const e in uniqueErrors) { - const count = uniqueErrors[e]; - const div = document.createElement('p'); - if (count > 1) { - div.textContent = `${e} `; - const em = document.createElement('em'); - em.textContent = `(${count})`; - div.appendChild(em); - } else { - div.textContent = `${e}`; - } - dialog.append($(div)); - } - - dialog.show(); - } else { - dialog.hide(); - } -} - -function dictionarySpinnerShow(show) { - const spinner = $('#dict-spinner'); - if (show) { - spinner.show(); - } else { - spinner.hide(); - } -} - -function dictionaryGroupsSort() { - const dictGroups = $('#dict-groups'); - const dictGroupChildren = dictGroups.children('.dict-group').sort((ca, cb) => { - const pa = parseInt($(ca).find('.dict-priority').val(), 10); - const pb = parseInt($(cb).find('.dict-priority').val(), 10); - if (pa < pb) { - return 1; - } else if (pa > pb) { - return -1; - } else { - return 0; - } - }); - - dictGroups.append(dictGroupChildren); -} - -async function dictionaryGroupsPopulate(options) { - const dictGroups = $('#dict-groups').empty(); - const dictWarning = $('#dict-warning').hide(); - - const dictRows = toIterable(await utilDatabaseSummarize()); - if (dictRows.length === 0) { - dictWarning.show(); - } - - for (const dictRow of toIterable(dictRowsSort(dictRows, options))) { - const dictOptions = options.dictionaries[dictRow.title] || { - enabled: false, - priority: 0, - allowSecondarySearches: false - }; - - const dictHtml = await apiTemplateRender('dictionary.html', { - enabled: dictOptions.enabled, - priority: dictOptions.priority, - allowSecondarySearches: dictOptions.allowSecondarySearches, - title: dictRow.title, - version: dictRow.version, - revision: dictRow.revision, - outdated: dictRow.version < 3 - }); - - dictGroups.append($(dictHtml)); - } - - formUpdateVisibility(options); - - $('.dict-enabled, .dict-priority, .dict-allow-secondary-searches').change(e => { - dictionaryGroupsSort(); - onFormOptionsChanged(e); - }); -} - -async function onDictionaryPurge(e) { - e.preventDefault(); - - const dictControls = $('#dict-importer, #dict-groups, #dict-main-group').hide(); - const dictProgress = $('#dict-purge').show(); - - try { - dictionaryErrorsShow(null); - dictionarySpinnerShow(true); - - await utilDatabasePurge(); - for (const options of toIterable(await getOptionsArray())) { - options.dictionaries = utilBackgroundIsolate({}); - options.general.mainDictionary = ''; - } - await settingsSaveOptions(); - - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - await dictionaryGroupsPopulate(options); - await formMainDictionaryOptionsPopulate(options); - } catch (e) { - dictionaryErrorsShow([e]); - } finally { - dictionarySpinnerShow(false); - - dictControls.show(); - dictProgress.hide(); - - if (storageEstimate.mostRecent !== null) { - storageUpdateStats(); - } - } -} - -function onDictionaryImportButtonClick() { - const dictFile = document.querySelector('#dict-file'); - dictFile.click(); -} - -async function onDictionaryImport(e) { - const dictFile = $('#dict-file'); - const dictControls = $('#dict-importer').hide(); - const dictProgress = $('#dict-import-progress').show(); - - try { - dictionaryErrorsShow(null); - dictionarySpinnerShow(true); - - const setProgress = percent => dictProgress.find('.progress-bar').css('width', `${percent}%`); - const updateProgress = (total, current) => { - setProgress(current / total * 100.0); - if (storageEstimate.mostRecent !== null && !storageUpdateStats.isUpdating) { - storageUpdateStats(); - } - }; - setProgress(0.0); - - const exceptions = []; - const summary = await utilDatabaseImport(e.target.files[0], updateProgress, exceptions); - for (const options of toIterable(await getOptionsArray())) { - options.dictionaries[summary.title] = utilBackgroundIsolate({ - enabled: true, - priority: 0, - allowSecondarySearches: false - }); - if (summary.sequenced && options.general.mainDictionary === '') { - options.general.mainDictionary = summary.title; - } - } - await settingsSaveOptions(); - - if (exceptions.length > 0) { - exceptions.push(`Dictionary may not have been imported properly: ${exceptions.length} error${exceptions.length === 1 ? '' : 's'} reported.`); - dictionaryErrorsShow(exceptions); - } - - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - await dictionaryGroupsPopulate(options); - await formMainDictionaryOptionsPopulate(options); - } catch (e) { - dictionaryErrorsShow([e]); - } finally { - dictionarySpinnerShow(false); - - dictFile.val(''); - dictControls.show(); - dictProgress.hide(); - } -} - - -/* - * Anki - */ - -function ankiSpinnerShow(show) { - const spinner = $('#anki-spinner'); - if (show) { - spinner.show(); - } else { - spinner.hide(); - } -} - -function ankiErrorShow(error) { - const dialog = $('#anki-error'); - if (error) { - dialog.show().text(error); - } - else { - dialog.hide(); - } -} - -function ankiErrorShown() { - return $('#anki-error').is(':visible'); -} - -function ankiFieldsToDict(selection) { - const result = {}; - selection.each((index, element) => { - result[$(element).data('field')] = $(element).val(); - }); - - return result; -} - -async function ankiDeckAndModelPopulate(options) { - const ankiFormat = $('#anki-format').hide(); - - const deckNames = await utilAnkiGetDeckNames(); - const ankiDeck = $('.anki-deck'); - ankiDeck.find('option').remove(); - deckNames.sort().forEach(name => ankiDeck.append($('<option/>', {value: name, text: name}))); - - const modelNames = await utilAnkiGetModelNames(); - const ankiModel = $('.anki-model'); - ankiModel.find('option').remove(); - modelNames.sort().forEach(name => ankiModel.append($('<option/>', {value: name, text: name}))); - - $('#anki-terms-deck').val(options.anki.terms.deck); - await ankiFieldsPopulate($('#anki-terms-model').val(options.anki.terms.model), options); - - $('#anki-kanji-deck').val(options.anki.kanji.deck); - await ankiFieldsPopulate($('#anki-kanji-model').val(options.anki.kanji.model), options); - - ankiFormat.show(); -} - -async function ankiFieldsPopulate(element, options) { - const modelName = element.val(); - if (!modelName) { - return; - } - - const tab = element.closest('.tab-pane'); - const tabId = tab.attr('id'); - const container = tab.find('tbody').empty(); - - const markers = { - 'terms': [ - 'audio', - 'cloze-body', - 'cloze-prefix', - 'cloze-suffix', - 'dictionary', - 'expression', - 'furigana', - 'furigana-plain', - 'glossary', - 'glossary-brief', - 'reading', - 'screenshot', - 'sentence', - 'tags', - 'url' - ], - 'kanji': [ - 'character', - 'dictionary', - 'glossary', - 'kunyomi', - 'onyomi', - 'screenshot', - 'sentence', - 'tags', - 'url' - ] - }[tabId] || {}; - - for (const name of await utilAnkiGetModelFieldNames(modelName)) { - const value = options.anki[tabId].fields[name] || ''; - const html = Handlebars.templates['model.html']({name, markers, value}); - container.append($(html)); - } - - tab.find('.anki-field-value').change(utilAsync(onFormOptionsChanged)); - tab.find('.marker-link').click(onAnkiMarkerClicked); -} - -function onAnkiMarkerClicked(e) { - e.preventDefault(); - const link = e.target; - $(link).closest('.input-group').find('.anki-field-value').val(`{${link.text}}`).trigger('change'); -} - -async function onAnkiModelChanged(e) { - try { - if (!e.originalEvent) { - return; - } - - const element = $(this); - const tab = element.closest('.tab-pane'); - const tabId = tab.attr('id'); - - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - await formRead(options); - options.anki[tabId].fields = utilBackgroundIsolate({}); - await settingsSaveOptions(); - - ankiSpinnerShow(true); - await ankiFieldsPopulate(element, options); - ankiErrorShow(); - } catch (e) { - ankiErrorShow(e); - } finally { - ankiSpinnerShow(false); - } -} - -async function onAnkiFieldTemplatesReset(e) { - try { - e.preventDefault(); - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - const fieldTemplates = profileOptionsGetDefaultFieldTemplates(); - options.anki.fieldTemplates = fieldTemplates; - $('#field-templates').val(fieldTemplates); - await settingsSaveOptions(); - } catch (e) { - ankiErrorShow(e); - } -} - - -/* - * Storage - */ - -function storageBytesToLabeledString(size) { - const base = 1000; - const labels = [' bytes', 'KB', 'MB', 'GB']; - let labelIndex = 0; - while (size >= base) { - size /= base; - ++labelIndex; - } - const label = labelIndex === 0 ? `${size}` : size.toFixed(1); - return `${label}${labels[labelIndex]}`; -} - -async function storageEstimate() { - try { - return (storageEstimate.mostRecent = await navigator.storage.estimate()); - } catch (e) { } - return null; -} -storageEstimate.mostRecent = null; - -async function isStoragePeristent() { - try { - return await navigator.storage.persisted(); - } catch (e) { } - return false; -} - -async function storageInfoInitialize() { - storagePersistInitialize(); - const {browser, platform} = await apiGetEnvironmentInfo(); - document.documentElement.dataset.browser = browser; - document.documentElement.dataset.operatingSystem = platform.os; - - await storageShowInfo(); - - document.querySelector('#storage-refresh').addEventListener('click', () => storageShowInfo(), false); -} - -async function storageUpdateStats() { - storageUpdateStats.isUpdating = true; - - const estimate = await storageEstimate(); - const valid = (estimate !== null); - - if (valid) { - // Firefox reports usage as 0 when persistent storage is enabled. - const finite = (estimate.usage > 0 || !(await isStoragePeristent())); - if (finite) { - document.querySelector('#storage-usage').textContent = storageBytesToLabeledString(estimate.usage); - document.querySelector('#storage-quota').textContent = storageBytesToLabeledString(estimate.quota); - } - document.querySelector('#storage-use-finite').classList.toggle('storage-hidden', !finite); - document.querySelector('#storage-use-infinite').classList.toggle('storage-hidden', finite); - } - - storageUpdateStats.isUpdating = false; - return valid; -} -storageUpdateStats.isUpdating = false; - -async function storageShowInfo() { - storageSpinnerShow(true); - - const valid = await storageUpdateStats(); - document.querySelector('#storage-use').classList.toggle('storage-hidden', !valid); - document.querySelector('#storage-error').classList.toggle('storage-hidden', valid); - - storageSpinnerShow(false); -} - -function storageSpinnerShow(show) { - const spinner = $('#storage-spinner'); - if (show) { - spinner.show(); - } else { - spinner.hide(); - } -} - -async function storagePersistInitialize() { - if (!(navigator.storage && navigator.storage.persist)) { - // Not supported - return; - } - - const info = document.querySelector('#storage-persist-info'); - const button = document.querySelector('#storage-persist-button'); - const checkbox = document.querySelector('#storage-persist-button-checkbox'); - - info.classList.remove('storage-hidden'); - button.classList.remove('storage-hidden'); - - let persisted = await isStoragePeristent(); - checkbox.checked = persisted; - - button.addEventListener('click', async () => { - if (persisted) { - return; - } - let result = false; - try { - result = await navigator.storage.persist(); - } catch (e) { - // NOP - } - - if (result) { - persisted = true; - checkbox.checked = true; - storageShowInfo(); - } else { - $('.storage-persist-fail-warning').removeClass('storage-hidden'); - } - }, false); -} - - -/* - * Information - */ - -function showExtensionInformation() { - const node = document.getElementById('extension-info'); - if (node === null) { return; } - - const manifest = chrome.runtime.getManifest(); - node.textContent = `${manifest.name} v${manifest.version}`; -} diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js new file mode 100644 index 00000000..9cdfc134 --- /dev/null +++ b/ext/bg/js/settings/anki-templates.js @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +function onAnkiFieldTemplatesReset(e) { + e.preventDefault(); + $('#field-template-reset-modal').modal('show'); +} + +function onAnkiFieldTemplatesResetConfirm(e) { + e.preventDefault(); + + $('#field-template-reset-modal').modal('hide'); + + const element = document.querySelector('#field-templates'); + element.value = profileOptionsGetDefaultFieldTemplates(); + element.dispatchEvent(new Event('change')); +} + +function ankiTemplatesInitialize() { + const markers = new Set(ankiGetFieldMarkers('terms').concat(ankiGetFieldMarkers('kanji'))); + const fragment = ankiGetFieldMarkersHtml(markers); + + const list = document.querySelector('#field-templates-list'); + list.appendChild(fragment); + for (const node of list.querySelectorAll('.marker-link')) { + node.addEventListener('click', onAnkiTemplateMarkerClicked, false); + } + + $('#field-templates').on('change', (e) => onAnkiTemplatesValidateCompile(e)); + $('#field-template-render').on('click', (e) => onAnkiTemplateRender(e)); + $('#field-templates-reset').on('click', (e) => onAnkiFieldTemplatesReset(e)); + $('#field-templates-reset-confirm').on('click', (e) => onAnkiFieldTemplatesResetConfirm(e)); +} + +const ankiTemplatesValidateGetDefinition = (() => { + let cachedValue = null; + let cachedText = null; + + return async (text, optionsContext) => { + if (cachedText !== text) { + const {definitions} = await apiTermsFind(text, {}, optionsContext); + if (definitions.length === 0) { return null; } + + cachedValue = definitions[0]; + cachedText = text; + } + return cachedValue; + }; +})(); + +async function ankiTemplatesValidate(infoNode, field, mode, showSuccessResult, invalidateInput) { + const text = document.querySelector('#field-templates-preview-text').value || ''; + const exceptions = []; + let result = `No definition found for ${text}`; + try { + const optionsContext = getOptionsContext(); + const definition = await ankiTemplatesValidateGetDefinition(text, optionsContext); + if (definition !== null) { + const options = await apiOptionsGet(optionsContext); + result = await dictFieldFormat(field, definition, mode, options, exceptions); + } + } catch (e) { + exceptions.push(e); + } + + const hasException = exceptions.length > 0; + infoNode.hidden = !(showSuccessResult || hasException); + infoNode.textContent = hasException ? exceptions.map((e) => `${e}`).join('\n') : (showSuccessResult ? result : ''); + infoNode.classList.toggle('text-danger', hasException); + if (invalidateInput) { + const input = document.querySelector('#field-templates'); + input.classList.toggle('is-invalid', hasException); + } +} + +function onAnkiTemplatesValidateCompile() { + const infoNode = document.querySelector('#field-template-compile-result'); + ankiTemplatesValidate(infoNode, '{expression}', 'term-kanji', false, true); +} + +function onAnkiTemplateMarkerClicked(e) { + e.preventDefault(); + document.querySelector('#field-template-render-text').value = `{${e.target.textContent}}`; +} + +function onAnkiTemplateRender(e) { + e.preventDefault(); + + const field = document.querySelector('#field-template-render-text').value; + const infoNode = document.querySelector('#field-template-render-result'); + infoNode.hidden = true; + ankiTemplatesValidate(infoNode, field, 'term-kanji', true, false); +} diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js new file mode 100644 index 00000000..e1aabbaf --- /dev/null +++ b/ext/bg/js/settings/anki.js @@ -0,0 +1,247 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +// Private + +let _ankiDataPopulated = false; + + +function _ankiSpinnerShow(show) { + const spinner = $('#anki-spinner'); + if (show) { + spinner.show(); + } else { + spinner.hide(); + } +} + +function _ankiSetError(error) { + const node = document.querySelector('#anki-error'); + if (!node) { return; } + if (error) { + node.hidden = false; + node.textContent = `${error}`; + } + else { + node.hidden = true; + node.textContent = ''; + } +} + +function _ankiSetDropdownOptions(dropdown, optionValues) { + const fragment = document.createDocumentFragment(); + for (const optionValue of optionValues) { + const option = document.createElement('option'); + option.value = optionValue; + option.textContent = optionValue; + fragment.appendChild(option); + } + dropdown.textContent = ''; + dropdown.appendChild(fragment); +} + +async function _ankiDeckAndModelPopulate(options) { + const termsDeck = {value: options.anki.terms.deck, selector: '#anki-terms-deck'}; + const kanjiDeck = {value: options.anki.kanji.deck, selector: '#anki-kanji-deck'}; + const termsModel = {value: options.anki.terms.model, selector: '#anki-terms-model'}; + const kanjiModel = {value: options.anki.kanji.model, selector: '#anki-kanji-model'}; + try { + _ankiSpinnerShow(true); + const [deckNames, modelNames] = await Promise.all([utilAnkiGetDeckNames(), utilAnkiGetModelNames()]); + deckNames.sort(); + modelNames.sort(); + termsDeck.values = deckNames; + kanjiDeck.values = deckNames; + termsModel.values = modelNames; + kanjiModel.values = modelNames; + _ankiSetError(null); + } catch (error) { + _ankiSetError(error); + } finally { + _ankiSpinnerShow(false); + } + + for (const {value, values, selector} of [termsDeck, kanjiDeck, termsModel, kanjiModel]) { + const node = document.querySelector(selector); + _ankiSetDropdownOptions(node, Array.isArray(values) ? values : [value]); + node.value = value; + } +} + +function _ankiCreateFieldTemplate(name, value, markers) { + const template = document.querySelector('#anki-field-template').content; + const content = document.importNode(template, true).firstChild; + + content.querySelector('.anki-field-name').textContent = name; + + const field = content.querySelector('.anki-field-value'); + field.dataset.field = name; + field.value = value; + + content.querySelector('.anki-field-marker-list').appendChild(ankiGetFieldMarkersHtml(markers)); + + return content; +} + +async function _ankiFieldsPopulate(tabId, options) { + const tab = document.querySelector(`.tab-pane[data-anki-card-type=${tabId}]`); + const container = tab.querySelector('tbody'); + const markers = ankiGetFieldMarkers(tabId); + + const fragment = document.createDocumentFragment(); + const fields = options.anki[tabId].fields; + for (const name of Object.keys(fields)) { + const value = fields[name]; + const html = _ankiCreateFieldTemplate(name, value, markers); + fragment.appendChild(html); + } + + container.textContent = ''; + container.appendChild(fragment); + + for (const node of container.querySelectorAll('.anki-field-value')) { + node.addEventListener('change', (e) => onFormOptionsChanged(e), false); + } + for (const node of container.querySelectorAll('.marker-link')) { + node.addEventListener('click', (e) => _onAnkiMarkerClicked(e), false); + } +} + +function _onAnkiMarkerClicked(e) { + e.preventDefault(); + const link = e.currentTarget; + const input = $(link).closest('.input-group').find('.anki-field-value')[0]; + input.value = `{${link.textContent}}`; + input.dispatchEvent(new Event('change')); +} + +async function _onAnkiModelChanged(e) { + const node = e.currentTarget; + let fieldNames; + try { + const modelName = node.value; + fieldNames = await utilAnkiGetModelFieldNames(modelName); + _ankiSetError(null); + } catch (error) { + _ankiSetError(error); + return; + } finally { + _ankiSpinnerShow(false); + } + + const tabId = node.dataset.ankiCardType; + if (tabId !== 'terms' && tabId !== 'kanji') { return; } + + const fields = {}; + for (const name of fieldNames) { + fields[name] = ''; + } + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + options.anki[tabId].fields = utilBackgroundIsolate(fields); + await settingsSaveOptions(); + + await _ankiFieldsPopulate(tabId, options); +} + + +// Public + +function ankiErrorShown() { + const node = document.querySelector('#anki-error'); + return node && !node.hidden; +} + +function ankiFieldsToDict(elements) { + const result = {}; + for (const element of elements) { + result[element.dataset.field] = element.value; + } + return result; +} + + +function ankiGetFieldMarkersHtml(markers) { + const template = document.querySelector('#anki-field-marker-template').content; + const fragment = document.createDocumentFragment(); + for (const marker of markers) { + const markerNode = document.importNode(template, true).firstChild; + markerNode.querySelector('.marker-link').textContent = marker; + fragment.appendChild(markerNode); + } + return fragment; +} + +function ankiGetFieldMarkers(type) { + switch (type) { + case 'terms': + return [ + 'audio', + 'cloze-body', + 'cloze-prefix', + 'cloze-suffix', + 'dictionary', + 'expression', + 'furigana', + 'furigana-plain', + 'glossary', + 'glossary-brief', + 'reading', + 'screenshot', + 'sentence', + 'tags', + 'url' + ]; + case 'kanji': + return [ + 'character', + 'dictionary', + 'glossary', + 'kunyomi', + 'onyomi', + 'screenshot', + 'sentence', + 'tags', + 'url' + ]; + default: + return []; + } +} + + +function ankiInitialize() { + for (const node of document.querySelectorAll('#anki-terms-model,#anki-kanji-model')) { + node.addEventListener('change', (e) => _onAnkiModelChanged(e), false); + } +} + +async function onAnkiOptionsChanged(options) { + if (!options.anki.enable) { + _ankiDataPopulated = false; + return; + } + + if (_ankiDataPopulated) { return; } + + await _ankiDeckAndModelPopulate(options); + _ankiDataPopulated = true; + await Promise.all([_ankiFieldsPopulate('terms', options), _ankiFieldsPopulate('kanji', options)]); +} diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js new file mode 100644 index 00000000..f63551ed --- /dev/null +++ b/ext/bg/js/settings/audio.js @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +let audioSourceUI = null; + +async function audioSettingsInitialize() { + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + audioSourceUI = new AudioSourceUI.Container(options.audio.sources, $('.audio-source-list'), $('.audio-source-add')); + audioSourceUI.save = () => settingsSaveOptions(); + + textToSpeechInitialize(); +} + +function textToSpeechInitialize() { + if (typeof speechSynthesis === 'undefined') { return; } + + speechSynthesis.addEventListener('voiceschanged', () => updateTextToSpeechVoices(), false); + updateTextToSpeechVoices(); + + $('#text-to-speech-voice-test').on('click', () => textToSpeechTest()); +} + +function updateTextToSpeechVoices() { + const voices = Array.prototype.map.call(speechSynthesis.getVoices(), (voice, index) => ({voice, index})); + voices.sort(textToSpeechVoiceCompare); + if (voices.length > 0) { + $('#text-to-speech-voice-container').css('display', ''); + } + + const select = $('#text-to-speech-voice'); + select.empty(); + select.append($('<option>').val('').text('None')); + for (const {voice} of voices) { + select.append($('<option>').val(voice.voiceURI).text(`${voice.name} (${voice.lang})`)); + } + + select.val(select.attr('data-value')); +} + +function languageTagIsJapanese(languageTag) { + return ( + languageTag.startsWith('ja-') || + languageTag.startsWith('jpn-') + ); +} + +function textToSpeechVoiceCompare(a, b) { + const aIsJapanese = languageTagIsJapanese(a.voice.lang); + const bIsJapanese = languageTagIsJapanese(b.voice.lang); + if (aIsJapanese) { + if (!bIsJapanese) { return -1; } + } else { + if (bIsJapanese) { return 1; } + } + + const aIsDefault = a.voice.default; + const bIsDefault = b.voice.default; + if (aIsDefault) { + if (!bIsDefault) { return -1; } + } else { + if (bIsDefault) { return 1; } + } + + if (a.index < b.index) { return -1; } + if (a.index > b.index) { return 1; } + return 0; +} + +function textToSpeechTest() { + try { + const text = $('#text-to-speech-voice-test').attr('data-speech-text') || ''; + const voiceURI = $('#text-to-speech-voice').val(); + const voice = audioGetTextToSpeechVoice(voiceURI); + if (voice === null) { return; } + + const utterance = new SpeechSynthesisUtterance(text); + utterance.lang = 'ja-JP'; + utterance.voice = voice; + utterance.volume = 1.0; + + speechSynthesis.speak(utterance); + } catch (e) { + // NOP + } +} diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js new file mode 100644 index 00000000..065a8abc --- /dev/null +++ b/ext/bg/js/settings/dictionaries.js @@ -0,0 +1,618 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +let dictionaryUI = null; + + +class SettingsDictionaryListUI { + constructor(container, template, extraContainer, extraTemplate) { + this.container = container; + this.template = template; + this.extraContainer = extraContainer; + this.extraTemplate = extraTemplate; + this.optionsDictionaries = null; + this.dictionaries = null; + this.dictionaryEntries = []; + this.extra = null; + + document.querySelector('#dict-delete-confirm').addEventListener('click', (e) => this.onDictionaryConfirmDelete(e), false); + } + + setOptionsDictionaries(optionsDictionaries) { + this.optionsDictionaries = optionsDictionaries; + if (this.dictionaries !== null) { + this.setDictionaries(this.dictionaries); + } + } + + setDictionaries(dictionaries) { + for (const dictionaryEntry of this.dictionaryEntries) { + dictionaryEntry.cleanup(); + } + + this.dictionaryEntries = []; + this.dictionaries = toIterable(dictionaries); + + if (this.optionsDictionaries === null) { + return; + } + + let changed = false; + for (const dictionaryInfo of this.dictionaries) { + if (this.createEntry(dictionaryInfo)) { + changed = true; + } + } + + this.updateDictionaryOrder(); + + const titles = this.dictionaryEntries.map((e) => e.dictionaryInfo.title); + const removeKeys = Object.keys(this.optionsDictionaries).filter((key) => titles.indexOf(key) < 0); + if (removeKeys.length > 0) { + for (const key of toIterable(removeKeys)) { + delete this.optionsDictionaries[key]; + } + changed = true; + } + + if (changed) { + this.save(); + } + } + + createEntry(dictionaryInfo) { + const title = dictionaryInfo.title; + let changed = false; + let optionsDictionary; + const optionsDictionaries = this.optionsDictionaries; + if (hasOwn(optionsDictionaries, title)) { + optionsDictionary = optionsDictionaries[title]; + } else { + optionsDictionary = SettingsDictionaryListUI.createDictionaryOptions(); + optionsDictionaries[title] = optionsDictionary; + changed = true; + } + + const content = document.importNode(this.template.content, true).firstChild; + + this.dictionaryEntries.push(new SettingsDictionaryEntryUI(this, dictionaryInfo, content, optionsDictionary)); + + return changed; + } + + static createDictionaryOptions() { + return utilBackgroundIsolate({ + priority: 0, + enabled: false, + allowSecondarySearches: false + }); + } + + createExtra(totalCounts, remainders, totalRemainder) { + const content = document.importNode(this.extraTemplate.content, true).firstChild; + this.extraContainer.appendChild(content); + return new SettingsDictionaryExtraUI(this, totalCounts, remainders, totalRemainder, content); + } + + setCounts(dictionaryCounts, totalCounts) { + const remainders = Object.assign({}, totalCounts); + const keys = Object.keys(remainders); + + for (let i = 0, ii = Math.min(this.dictionaryEntries.length, dictionaryCounts.length); i < ii; ++i) { + const counts = dictionaryCounts[i]; + this.dictionaryEntries[i].setCounts(counts); + + for (const key of keys) { + remainders[key] -= counts[key]; + } + } + + let totalRemainder = 0; + for (const key of keys) { + totalRemainder += remainders[key]; + } + + if (this.extra !== null) { + this.extra.cleanup(); + this.extra = null; + } + + if (totalRemainder > 0) { + this.extra = this.createExtra(totalCounts, remainders, totalRemainder); + } + } + + updateDictionaryOrder() { + const sortInfo = this.dictionaryEntries.map((e, i) => [e, i]); + sortInfo.sort((a, b) => { + const i = b[0].optionsDictionary.priority - a[0].optionsDictionary.priority; + return (i !== 0 ? i : a[1] - b[1]); + }); + + for (const [e] of sortInfo) { + this.container.appendChild(e.content); + } + } + + save() { + // Overwrite + } + + onDictionaryConfirmDelete(e) { + e.preventDefault(); + const n = document.querySelector('#dict-delete-modal'); + const title = n.dataset.dict; + delete n.dataset.dict; + $(n).modal('hide'); + + const index = this.dictionaryEntries.findIndex((e) => e.dictionaryInfo.title === title); + if (index >= 0) { + this.dictionaryEntries[index].deleteDictionary(); + } + } +} + +class SettingsDictionaryEntryUI { + constructor(parent, dictionaryInfo, content, optionsDictionary) { + this.parent = parent; + this.dictionaryInfo = dictionaryInfo; + this.optionsDictionary = optionsDictionary; + this.counts = null; + this.eventListeners = []; + this.isDeleting = false; + + this.content = content; + this.enabledCheckbox = this.content.querySelector('.dict-enabled'); + this.allowSecondarySearchesCheckbox = this.content.querySelector('.dict-allow-secondary-searches'); + this.priorityInput = this.content.querySelector('.dict-priority'); + this.deleteButton = this.content.querySelector('.dict-delete-button'); + + if (this.dictionaryInfo.version < 3) { + this.content.querySelector('.dict-outdated').hidden = false; + } + + this.content.querySelector('.dict-title').textContent = this.dictionaryInfo.title; + this.content.querySelector('.dict-revision').textContent = `rev.${this.dictionaryInfo.revision}`; + + this.applyValues(); + + this.addEventListener(this.enabledCheckbox, 'change', (e) => this.onEnabledChanged(e), false); + this.addEventListener(this.allowSecondarySearchesCheckbox, 'change', (e) => this.onAllowSecondarySearchesChanged(e), false); + this.addEventListener(this.priorityInput, 'change', (e) => this.onPriorityChanged(e), false); + this.addEventListener(this.deleteButton, 'click', (e) => this.onDeleteButtonClicked(e), false); + } + + cleanup() { + if (this.content !== null) { + if (this.content.parentNode !== null) { + this.content.parentNode.removeChild(this.content); + } + this.content = null; + } + this.dictionaryInfo = null; + this.clearEventListeners(); + } + + setCounts(counts) { + this.counts = counts; + const node = this.content.querySelector('.dict-counts'); + node.textContent = JSON.stringify({ + info: this.dictionaryInfo, + counts + }, null, 4); + node.removeAttribute('hidden'); + } + + save() { + this.parent.save(); + } + + addEventListener(node, type, listener, options) { + node.addEventListener(type, listener, options); + this.eventListeners.push([node, type, listener, options]); + } + + clearEventListeners() { + for (const [node, type, listener, options] of this.eventListeners) { + node.removeEventListener(type, listener, options); + } + this.eventListeners = []; + } + + applyValues() { + this.enabledCheckbox.checked = this.optionsDictionary.enabled; + this.allowSecondarySearchesCheckbox.checked = this.optionsDictionary.allowSecondarySearches; + this.priorityInput.value = `${this.optionsDictionary.priority}`; + } + + async deleteDictionary() { + if (this.isDeleting) { + return; + } + + const progress = this.content.querySelector('.progress'); + progress.hidden = false; + const progressBar = this.content.querySelector('.progress-bar'); + this.isDeleting = true; + + const prevention = new PageExitPrevention(); + try { + prevention.start(); + + const onProgress = ({processed, count, storeCount, storesProcesed}) => { + let percent = 0.0; + if (count > 0 && storesProcesed > 0) { + percent = (processed / count) * (storesProcesed / storeCount) * 100.0; + } + progressBar.style.width = `${percent}%`; + }; + + await utilDatabaseDeleteDictionary(this.dictionaryInfo.title, onProgress, {rate: 1000}); + } catch (e) { + dictionaryErrorsShow([e]); + } finally { + prevention.end(); + this.isDeleting = false; + progress.hidden = true; + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + onDatabaseUpdated(options); + } + } + + onEnabledChanged(e) { + this.optionsDictionary.enabled = !!e.target.checked; + this.save(); + } + + onAllowSecondarySearchesChanged(e) { + this.optionsDictionary.allowSecondarySearches = !!e.target.checked; + this.save(); + } + + onPriorityChanged(e) { + let value = Number.parseFloat(e.target.value); + if (Number.isNaN(value)) { + value = this.optionsDictionary.priority; + } else { + this.optionsDictionary.priority = value; + this.save(); + } + + e.target.value = `${value}`; + + this.parent.updateDictionaryOrder(); + } + + onDeleteButtonClicked(e) { + e.preventDefault(); + + if (this.isDeleting) { + return; + } + + const title = this.dictionaryInfo.title; + const n = document.querySelector('#dict-delete-modal'); + n.dataset.dict = title; + document.querySelector('#dict-remove-modal-dict-name').textContent = title; + $(n).modal('show'); + } +} + +class SettingsDictionaryExtraUI { + constructor(parent, totalCounts, remainders, totalRemainder, content) { + this.parent = parent; + this.content = content; + + this.content.querySelector('.dict-total-count').textContent = `${totalRemainder} item${totalRemainder !== 1 ? 's' : ''}`; + + const node = this.content.querySelector('.dict-counts'); + node.textContent = JSON.stringify({ + counts: totalCounts, + remainders: remainders + }, null, 4); + node.removeAttribute('hidden'); + } + + cleanup() { + if (this.content !== null) { + if (this.content.parentNode !== null) { + this.content.parentNode.removeChild(this.content); + } + this.content = null; + } + } +} + + +async function dictSettingsInitialize() { + dictionaryUI = new SettingsDictionaryListUI( + document.querySelector('#dict-groups'), + document.querySelector('#dict-template'), + document.querySelector('#dict-groups-extra'), + document.querySelector('#dict-extra-template') + ); + dictionaryUI.save = () => settingsSaveOptions(); + + document.querySelector('#dict-purge-button').addEventListener('click', (e) => onDictionaryPurgeButtonClick(e), false); + document.querySelector('#dict-purge-confirm').addEventListener('click', (e) => onDictionaryPurge(e), false); + document.querySelector('#dict-file-button').addEventListener('click', (e) => onDictionaryImportButtonClick(e), false); + document.querySelector('#dict-file').addEventListener('change', (e) => onDictionaryImport(e), false); + document.querySelector('#dict-main').addEventListener('change', (e) => onDictionaryMainChanged(e), false); + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + onDictionaryOptionsChanged(options); + onDatabaseUpdated(options); +} + +async function onDictionaryOptionsChanged(options) { + if (dictionaryUI === null) { return; } + dictionaryUI.setOptionsDictionaries(options.dictionaries); +} + +async function onDatabaseUpdated(options) { + try { + const dictionaries = await utilDatabaseGetDictionaryInfo(); + dictionaryUI.setDictionaries(dictionaries); + + document.querySelector('#dict-warning').hidden = (dictionaries.length > 0); + + updateMainDictionarySelect(options, dictionaries); + + const {counts, total} = await utilDatabaseGetDictionaryCounts(dictionaries.map((v) => v.title), true); + dictionaryUI.setCounts(counts, total); + } catch (e) { + dictionaryErrorsShow([e]); + } +} + +async function updateMainDictionarySelect(options, dictionaries) { + const select = document.querySelector('#dict-main'); + select.textContent = ''; // Empty + + let option = document.createElement('option'); + option.className = 'text-muted'; + option.value = ''; + option.textContent = 'Not selected'; + select.appendChild(option); + + let value = ''; + const currentValue = options.general.mainDictionary; + for (const {title, sequenced} of toIterable(dictionaries)) { + if (!sequenced) { continue; } + + option = document.createElement('option'); + option.value = title; + option.textContent = title; + select.appendChild(option); + + if (title === currentValue) { + value = title; + } + } + + select.value = value; + + if (options.general.mainDictionary !== value) { + options.general.mainDictionary = value; + settingsSaveOptions(); + } +} + +async function onDictionaryMainChanged(e) { + const value = e.target.value; + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + options.general.mainDictionary = value; + settingsSaveOptions(); +} + + +function dictionaryErrorToString(error) { + if (error.toString) { + error = error.toString(); + } else { + error = `${error}`; + } + + for (const [match, subst] of dictionaryErrorToString.overrides) { + if (error.includes(match)) { + error = subst; + break; + } + } + + return error; +} +dictionaryErrorToString.overrides = [ + [ + 'A mutation operation was attempted on a database that did not allow mutations.', + 'Access to IndexedDB appears to be restricted. Firefox seems to require that the history preference is set to "Remember history" before IndexedDB use of any kind is allowed.' + ], + [ + 'The operation failed for reasons unrelated to the database itself and not covered by any other error code.', + 'Unable to access IndexedDB due to a possibly corrupt user profile. Try using the "Refresh Firefox" feature to reset your user profile.' + ], + [ + 'BulkError', + 'Unable to finish importing dictionary data into IndexedDB. This may indicate that you do not have sufficient disk space available to complete this operation.' + ] +]; + +function dictionaryErrorsShow(errors) { + const dialog = document.querySelector('#dict-error'); + dialog.textContent = ''; + + if (errors !== null && errors.length > 0) { + const uniqueErrors = {}; + for (let e of errors) { + console.error(e); + e = dictionaryErrorToString(e); + uniqueErrors[e] = hasOwn(uniqueErrors, e) ? uniqueErrors[e] + 1 : 1; + } + + for (const e in uniqueErrors) { + const count = uniqueErrors[e]; + const div = document.createElement('p'); + if (count > 1) { + div.textContent = `${e} `; + const em = document.createElement('em'); + em.textContent = `(${count})`; + div.appendChild(em); + } else { + div.textContent = `${e}`; + } + dialog.appendChild(div); + } + + dialog.hidden = false; + } else { + dialog.hidden = true; + } +} + + +function dictionarySpinnerShow(show) { + const spinner = $('#dict-spinner'); + if (show) { + spinner.show(); + } else { + spinner.hide(); + } +} + +function onDictionaryImportButtonClick() { + const dictFile = document.querySelector('#dict-file'); + dictFile.click(); +} + +function onDictionaryPurgeButtonClick(e) { + e.preventDefault(); + $('#dict-purge-modal').modal('show'); +} + +async function onDictionaryPurge(e) { + e.preventDefault(); + + $('#dict-purge-modal').modal('hide'); + + const dictControls = $('#dict-importer, #dict-groups, #dict-groups-extra, #dict-main-group').hide(); + const dictProgress = document.querySelector('#dict-purge'); + dictProgress.hidden = false; + + const prevention = new PageExitPrevention(); + + try { + prevention.start(); + dictionaryErrorsShow(null); + dictionarySpinnerShow(true); + + await utilDatabasePurge(); + for (const options of toIterable(await getOptionsArray())) { + options.dictionaries = utilBackgroundIsolate({}); + options.general.mainDictionary = ''; + } + await settingsSaveOptions(); + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + onDatabaseUpdated(options); + } catch (err) { + dictionaryErrorsShow([err]); + } finally { + prevention.end(); + + dictionarySpinnerShow(false); + + dictControls.show(); + dictProgress.hidden = true; + + if (storageEstimate.mostRecent !== null) { + storageUpdateStats(); + } + } +} + +async function onDictionaryImport(e) { + const dictFile = $('#dict-file'); + const dictControls = $('#dict-importer').hide(); + const dictProgress = $('#dict-import-progress').show(); + const dictImportInfo = document.querySelector('#dict-import-info'); + + const prevention = new PageExitPrevention(); + + try { + prevention.start(); + dictionaryErrorsShow(null); + dictionarySpinnerShow(true); + + const setProgress = (percent) => dictProgress.find('.progress-bar').css('width', `${percent}%`); + const updateProgress = (total, current) => { + setProgress(current / total * 100.0); + if (storageEstimate.mostRecent !== null && !storageUpdateStats.isUpdating) { + storageUpdateStats(); + } + }; + + const exceptions = []; + const files = [...e.target.files]; + + for (let i = 0, ii = files.length; i < ii; ++i) { + setProgress(0.0); + if (ii > 1) { + dictImportInfo.hidden = false; + dictImportInfo.textContent = `(${i + 1} of ${ii})`; + } + + const summary = await utilDatabaseImport(files[i], updateProgress, exceptions); + for (const options of toIterable(await getOptionsArray())) { + const dictionaryOptions = SettingsDictionaryListUI.createDictionaryOptions(); + dictionaryOptions.enabled = true; + options.dictionaries[summary.title] = dictionaryOptions; + if (summary.sequenced && options.general.mainDictionary === '') { + options.general.mainDictionary = summary.title; + } + } + + await settingsSaveOptions(); + + if (exceptions.length > 0) { + exceptions.push(`Dictionary may not have been imported properly: ${exceptions.length} error${exceptions.length === 1 ? '' : 's'} reported.`); + dictionaryErrorsShow(exceptions); + } + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + onDatabaseUpdated(options); + } + } catch (err) { + dictionaryErrorsShow([err]); + } finally { + prevention.end(); + dictionarySpinnerShow(false); + + dictImportInfo.hidden = false; + dictImportInfo.textContent = ''; + dictFile.val(''); + dictControls.show(); + dictProgress.hide(); + } +} diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js new file mode 100644 index 00000000..7456e7a4 --- /dev/null +++ b/ext/bg/js/settings/main.js @@ -0,0 +1,239 @@ +/* + * Copyright (C) 2016-2017 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +async function getOptionsArray() { + const optionsFull = await apiOptionsGetFull(); + return optionsFull.profiles.map((profile) => profile.options); +} + +async function formRead(options) { + options.general.enable = $('#enable').prop('checked'); + options.general.showGuide = $('#show-usage-guide').prop('checked'); + options.general.compactTags = $('#compact-tags').prop('checked'); + options.general.compactGlossaries = $('#compact-glossaries').prop('checked'); + options.general.resultOutputMode = $('#result-output-mode').val(); + options.general.debugInfo = $('#show-debug-info').prop('checked'); + options.general.showAdvanced = $('#show-advanced-options').prop('checked'); + options.general.maxResults = parseInt($('#max-displayed-results').val(), 10); + options.general.popupDisplayMode = $('#popup-display-mode').val(); + options.general.popupHorizontalTextPosition = $('#popup-horizontal-text-position').val(); + options.general.popupVerticalTextPosition = $('#popup-vertical-text-position').val(); + options.general.popupWidth = parseInt($('#popup-width').val(), 10); + options.general.popupHeight = parseInt($('#popup-height').val(), 10); + options.general.popupHorizontalOffset = parseInt($('#popup-horizontal-offset').val(), 0); + options.general.popupVerticalOffset = parseInt($('#popup-vertical-offset').val(), 10); + options.general.popupHorizontalOffset2 = parseInt($('#popup-horizontal-offset2').val(), 0); + options.general.popupVerticalOffset2 = parseInt($('#popup-vertical-offset2').val(), 10); + options.general.popupTheme = $('#popup-theme').val(); + options.general.popupOuterTheme = $('#popup-outer-theme').val(); + options.general.customPopupCss = $('#custom-popup-css').val(); + options.general.customPopupOuterCss = $('#custom-popup-outer-css').val(); + + options.audio.enabled = $('#audio-playback-enabled').prop('checked'); + options.audio.autoPlay = $('#auto-play-audio').prop('checked'); + options.audio.volume = parseFloat($('#audio-playback-volume').val()); + options.audio.customSourceUrl = $('#audio-custom-source').val(); + options.audio.textToSpeechVoice = $('#text-to-speech-voice').val(); + + options.scanning.middleMouse = $('#middle-mouse-button-scan').prop('checked'); + options.scanning.touchInputEnabled = $('#touch-input-enabled').prop('checked'); + options.scanning.selectText = $('#select-matched-text').prop('checked'); + options.scanning.alphanumeric = $('#search-alphanumeric').prop('checked'); + options.scanning.autoHideResults = $('#auto-hide-results').prop('checked'); + options.scanning.deepDomScan = $('#deep-dom-scan').prop('checked'); + options.scanning.enablePopupSearch = $('#enable-search-within-first-popup').prop('checked'); + options.scanning.enableOnPopupExpressions = $('#enable-scanning-of-popup-expressions').prop('checked'); + options.scanning.enableOnSearchPage = $('#enable-scanning-on-search-page').prop('checked'); + options.scanning.delay = parseInt($('#scan-delay').val(), 10); + options.scanning.length = parseInt($('#scan-length').val(), 10); + options.scanning.modifier = $('#scan-modifier-key').val(); + options.scanning.popupNestingMaxDepth = parseInt($('#popup-nesting-max-depth').val(), 10); + + options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked'); + options.parsing.enableMecabParser = $('#parsing-mecab-enable').prop('checked'); + options.parsing.readingMode = $('#parsing-reading-mode').val(); + + const optionsAnkiEnableOld = options.anki.enable; + options.anki.enable = $('#anki-enable').prop('checked'); + options.anki.tags = utilBackgroundIsolate($('#card-tags').val().split(/[,; ]+/)); + options.anki.sentenceExt = parseInt($('#sentence-detection-extent').val(), 10); + options.anki.server = $('#interface-server').val(); + options.anki.screenshot.format = $('#screenshot-format').val(); + options.anki.screenshot.quality = parseInt($('#screenshot-quality').val(), 10); + options.anki.fieldTemplates = $('#field-templates').val(); + + if (optionsAnkiEnableOld && !ankiErrorShown()) { + options.anki.terms.deck = $('#anki-terms-deck').val(); + options.anki.terms.model = $('#anki-terms-model').val(); + options.anki.terms.fields = utilBackgroundIsolate(ankiFieldsToDict(document.querySelectorAll('#terms .anki-field-value'))); + options.anki.kanji.deck = $('#anki-kanji-deck').val(); + options.anki.kanji.model = $('#anki-kanji-model').val(); + options.anki.kanji.fields = utilBackgroundIsolate(ankiFieldsToDict(document.querySelectorAll('#kanji .anki-field-value'))); + } +} + +async function formWrite(options) { + $('#enable').prop('checked', options.general.enable); + $('#show-usage-guide').prop('checked', options.general.showGuide); + $('#compact-tags').prop('checked', options.general.compactTags); + $('#compact-glossaries').prop('checked', options.general.compactGlossaries); + $('#result-output-mode').val(options.general.resultOutputMode); + $('#show-debug-info').prop('checked', options.general.debugInfo); + $('#show-advanced-options').prop('checked', options.general.showAdvanced); + $('#max-displayed-results').val(options.general.maxResults); + $('#popup-display-mode').val(options.general.popupDisplayMode); + $('#popup-horizontal-text-position').val(options.general.popupHorizontalTextPosition); + $('#popup-vertical-text-position').val(options.general.popupVerticalTextPosition); + $('#popup-width').val(options.general.popupWidth); + $('#popup-height').val(options.general.popupHeight); + $('#popup-horizontal-offset').val(options.general.popupHorizontalOffset); + $('#popup-vertical-offset').val(options.general.popupVerticalOffset); + $('#popup-horizontal-offset2').val(options.general.popupHorizontalOffset2); + $('#popup-vertical-offset2').val(options.general.popupVerticalOffset2); + $('#popup-theme').val(options.general.popupTheme); + $('#popup-outer-theme').val(options.general.popupOuterTheme); + $('#custom-popup-css').val(options.general.customPopupCss); + $('#custom-popup-outer-css').val(options.general.customPopupOuterCss); + + $('#audio-playback-enabled').prop('checked', options.audio.enabled); + $('#auto-play-audio').prop('checked', options.audio.autoPlay); + $('#audio-playback-volume').val(options.audio.volume); + $('#audio-custom-source').val(options.audio.customSourceUrl); + $('#text-to-speech-voice').val(options.audio.textToSpeechVoice).attr('data-value', options.audio.textToSpeechVoice); + + $('#middle-mouse-button-scan').prop('checked', options.scanning.middleMouse); + $('#touch-input-enabled').prop('checked', options.scanning.touchInputEnabled); + $('#select-matched-text').prop('checked', options.scanning.selectText); + $('#search-alphanumeric').prop('checked', options.scanning.alphanumeric); + $('#auto-hide-results').prop('checked', options.scanning.autoHideResults); + $('#deep-dom-scan').prop('checked', options.scanning.deepDomScan); + $('#enable-search-within-first-popup').prop('checked', options.scanning.enablePopupSearch); + $('#enable-scanning-of-popup-expressions').prop('checked', options.scanning.enableOnPopupExpressions); + $('#enable-scanning-on-search-page').prop('checked', options.scanning.enableOnSearchPage); + $('#scan-delay').val(options.scanning.delay); + $('#scan-length').val(options.scanning.length); + $('#scan-modifier-key').val(options.scanning.modifier); + $('#popup-nesting-max-depth').val(options.scanning.popupNestingMaxDepth); + + $('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser); + $('#parsing-mecab-enable').prop('checked', options.parsing.enableMecabParser); + $('#parsing-reading-mode').val(options.parsing.readingMode); + + $('#anki-enable').prop('checked', options.anki.enable); + $('#card-tags').val(options.anki.tags.join(' ')); + $('#sentence-detection-extent').val(options.anki.sentenceExt); + $('#interface-server').val(options.anki.server); + $('#screenshot-format').val(options.anki.screenshot.format); + $('#screenshot-quality').val(options.anki.screenshot.quality); + $('#field-templates').val(options.anki.fieldTemplates); + + onAnkiTemplatesValidateCompile(); + await onAnkiOptionsChanged(options); + await onDictionaryOptionsChanged(options); + + formUpdateVisibility(options); +} + +function formSetupEventListeners() { + $('input, select, textarea').not('.anki-model').not('.ignore-form-changes *').change((e) => onFormOptionsChanged(e)); +} + +function formUpdateVisibility(options) { + document.documentElement.dataset.optionsAnkiEnable = `${!!options.anki.enable}`; + document.documentElement.dataset.optionsGeneralDebugInfo = `${!!options.general.debugInfo}`; + document.documentElement.dataset.optionsGeneralShowAdvanced = `${!!options.general.showAdvanced}`; + document.documentElement.dataset.optionsGeneralResultOutputMode = `${options.general.resultOutputMode}`; + + if (options.general.debugInfo) { + const temp = utilIsolate(options); + temp.anki.fieldTemplates = '...'; + const text = JSON.stringify(temp, null, 4); + $('#debug').text(text); + } +} + +async function onFormOptionsChanged() { + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + + await formRead(options); + await settingsSaveOptions(); + formUpdateVisibility(options); + + await onAnkiOptionsChanged(options); +} + + +function settingsGetSource() { + return new Promise((resolve) => { + chrome.tabs.getCurrent((tab) => resolve(`settings${tab ? tab.id : ''}`)); + }); +} + +async function settingsSaveOptions() { + const source = await settingsGetSource(); + await apiOptionsSave(source); +} + +async function onOptionsUpdate({source}) { + const thisSource = await settingsGetSource(); + if (source === thisSource) { return; } + + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); + await formWrite(options); +} + +function onMessage({action, params}, sender, callback) { + switch (action) { + case 'optionsUpdate': + onOptionsUpdate(params); + break; + case 'getUrl': + callback({url: window.location.href}); + break; + } +} + + +function showExtensionInformation() { + const node = document.getElementById('extension-info'); + if (node === null) { return; } + + const manifest = chrome.runtime.getManifest(); + node.textContent = `${manifest.name} v${manifest.version}`; +} + + +async function onReady() { + showExtensionInformation(); + + formSetupEventListeners(); + appearanceInitialize(); + await audioSettingsInitialize(); + await profileOptionsSetup(); + await dictSettingsInitialize(); + ankiInitialize(); + ankiTemplatesInitialize(); + + storageInfoInitialize(); + + chrome.runtime.onMessage.addListener(onMessage); +} + +$(document).ready(() => onReady()); diff --git a/ext/bg/js/settings-popup-preview.js b/ext/bg/js/settings/popup-preview-frame.js index 7d641c46..49409968 100644 --- a/ext/bg/js/settings-popup-preview.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -106,7 +106,7 @@ class SettingsPopupPreview { onMessage(e) { const {action, params} = e.data; const handlers = SettingsPopupPreview.messageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; handler(this, params); } diff --git a/ext/bg/js/settings/popup-preview.js b/ext/bg/js/settings/popup-preview.js new file mode 100644 index 00000000..d8579eb1 --- /dev/null +++ b/ext/bg/js/settings/popup-preview.js @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +function appearanceInitialize() { + let previewVisible = false; + $('#settings-popup-preview-button').on('click', () => { + if (previewVisible) { return; } + showAppearancePreview(); + previewVisible = true; + }); +} + +function showAppearancePreview() { + const container = $('#settings-popup-preview-container'); + const buttonContainer = $('#settings-popup-preview-button-container'); + const settings = $('#settings-popup-preview-settings'); + const text = $('#settings-popup-preview-text'); + const customCss = $('#custom-popup-css'); + const customOuterCss = $('#custom-popup-outer-css'); + + const frame = document.createElement('iframe'); + frame.src = '/bg/settings-popup-preview.html'; + frame.id = 'settings-popup-preview-frame'; + + window.wanakana.bind(text[0]); + + text.on('input', () => { + const action = 'setText'; + const params = {text: text.val()}; + frame.contentWindow.postMessage({action, params}, '*'); + }); + customCss.on('input', () => { + const action = 'setCustomCss'; + const params = {css: customCss.val()}; + frame.contentWindow.postMessage({action, params}, '*'); + }); + customOuterCss.on('input', () => { + const action = 'setCustomOuterCss'; + const params = {css: customOuterCss.val()}; + frame.contentWindow.postMessage({action, params}, '*'); + }); + + container.append(frame); + buttonContainer.remove(); + settings.css('display', ''); +} diff --git a/ext/bg/js/settings-profiles.js b/ext/bg/js/settings/profiles.js index ededc998..8c218e97 100644 --- a/ext/bg/js/settings-profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -35,16 +35,16 @@ async function profileOptionsSetup() { } function profileOptionsSetupEventListeners() { - $('#profile-target').change(utilAsync(onTargetProfileChanged)); - $('#profile-name').change(onProfileNameChanged); - $('#profile-add').click(utilAsync(onProfileAdd)); - $('#profile-remove').click(utilAsync(onProfileRemove)); - $('#profile-remove-confirm').click(utilAsync(onProfileRemoveConfirm)); - $('#profile-copy').click(utilAsync(onProfileCopy)); - $('#profile-copy-confirm').click(utilAsync(onProfileCopyConfirm)); + $('#profile-target').change((e) => onTargetProfileChanged(e)); + $('#profile-name').change((e) => onProfileNameChanged(e)); + $('#profile-add').click((e) => onProfileAdd(e)); + $('#profile-remove').click((e) => onProfileRemove(e)); + $('#profile-remove-confirm').click((e) => onProfileRemoveConfirm(e)); + $('#profile-copy').click((e) => onProfileCopy(e)); + $('#profile-copy-confirm').click((e) => onProfileCopyConfirm(e)); $('#profile-move-up').click(() => onProfileMove(-1)); $('#profile-move-down').click(() => onProfileMove(1)); - $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change(utilAsync(onProfileOptionsChanged)); + $('.profile-form').find('input, select, textarea').not('.profile-form-manual').change((e) => onProfileOptionsChanged(e)); } function tryGetIntegerValue(selector, min, max) { @@ -95,7 +95,7 @@ async function profileFormWrite(optionsFull) { $('#profile-add-condition-group') ); profileConditionsContainer.save = () => { - apiOptionsSave(); + settingsSaveOptions(); conditionsClearCaches(profileConditionsDescriptor); }; profileConditionsContainer.isolate = utilBackgroundIsolate; @@ -147,7 +147,7 @@ function profileOptionsCreateCopyName(name, profiles, maxUniqueAttempts) { let i = 0; while (true) { const newName = `${prefix}${space}${index}${suffix}`; - if (i++ >= maxUniqueAttempts || profiles.findIndex(profile => profile.name === newName) < 0) { + if (i++ >= maxUniqueAttempts || profiles.findIndex((profile) => profile.name === newName) < 0) { return newName; } if (typeof index !== 'number') { @@ -166,7 +166,7 @@ async function onProfileOptionsChanged(e) { const optionsFull = await apiOptionsGetFull(); await profileFormRead(optionsFull); - await apiOptionsSave(); + await settingsSaveOptions(); } async function onTargetProfileChanged() { @@ -188,7 +188,7 @@ async function onProfileAdd() { optionsFull.profiles.push(profile); currentProfileIndex = optionsFull.profiles.length - 1; await profileOptionsUpdateTarget(optionsFull); - await apiOptionsSave(); + await settingsSaveOptions(); } async function onProfileRemove(e) { @@ -226,7 +226,7 @@ async function onProfileRemoveConfirm() { } await profileOptionsUpdateTarget(optionsFull); - await apiOptionsSave(); + await settingsSaveOptions(); } function onProfileNameChanged() { diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js new file mode 100644 index 00000000..51ca6855 --- /dev/null +++ b/ext/bg/js/settings/storage.js @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +function storageBytesToLabeledString(size) { + const base = 1000; + const labels = [' bytes', 'KB', 'MB', 'GB']; + let labelIndex = 0; + while (size >= base) { + size /= base; + ++labelIndex; + } + const label = labelIndex === 0 ? `${size}` : size.toFixed(1); + return `${label}${labels[labelIndex]}`; +} + +async function storageEstimate() { + try { + return (storageEstimate.mostRecent = await navigator.storage.estimate()); + } catch (e) { + // NOP + } + return null; +} +storageEstimate.mostRecent = null; + +async function isStoragePeristent() { + try { + return await navigator.storage.persisted(); + } catch (e) { + // NOP + } + return false; +} + +async function storageInfoInitialize() { + storagePersistInitialize(); + const {browser, platform} = await apiGetEnvironmentInfo(); + document.documentElement.dataset.browser = browser; + document.documentElement.dataset.operatingSystem = platform.os; + + await storageShowInfo(); + + document.querySelector('#storage-refresh').addEventListener('click', () => storageShowInfo(), false); +} + +async function storageUpdateStats() { + storageUpdateStats.isUpdating = true; + + const estimate = await storageEstimate(); + const valid = (estimate !== null); + + if (valid) { + // Firefox reports usage as 0 when persistent storage is enabled. + const finite = (estimate.usage > 0 || !(await isStoragePeristent())); + if (finite) { + document.querySelector('#storage-usage').textContent = storageBytesToLabeledString(estimate.usage); + document.querySelector('#storage-quota').textContent = storageBytesToLabeledString(estimate.quota); + } + document.querySelector('#storage-use-finite').classList.toggle('storage-hidden', !finite); + document.querySelector('#storage-use-infinite').classList.toggle('storage-hidden', finite); + } + + storageUpdateStats.isUpdating = false; + return valid; +} +storageUpdateStats.isUpdating = false; + +async function storageShowInfo() { + storageSpinnerShow(true); + + const valid = await storageUpdateStats(); + document.querySelector('#storage-use').classList.toggle('storage-hidden', !valid); + document.querySelector('#storage-error').classList.toggle('storage-hidden', valid); + + storageSpinnerShow(false); +} + +function storageSpinnerShow(show) { + const spinner = $('#storage-spinner'); + if (show) { + spinner.show(); + } else { + spinner.hide(); + } +} + +async function storagePersistInitialize() { + if (!(navigator.storage && navigator.storage.persist)) { + // Not supported + return; + } + + const info = document.querySelector('#storage-persist-info'); + const button = document.querySelector('#storage-persist-button'); + const checkbox = document.querySelector('#storage-persist-button-checkbox'); + + info.classList.remove('storage-hidden'); + button.classList.remove('storage-hidden'); + + let persisted = await isStoragePeristent(); + checkbox.checked = persisted; + + button.addEventListener('click', async () => { + if (persisted) { + return; + } + let result = false; + try { + result = await navigator.storage.persist(); + } catch (e) { + // NOP + } + + if (result) { + persisted = true; + checkbox.checked = true; + storageShowInfo(); + } else { + $('.storage-persist-fail-warning').removeClass('storage-hidden'); + } + }, false); +} diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 59516d97..9320477f 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -1,32 +1,5 @@ (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -templates['dictionary.html'] = template({"1":function(container,depth0,helpers,partials,data) { - return " <p class=\"text-warning\">This dictionary is outdated and may not support new extension features; please import the latest version.</p>\n"; -},"3":function(container,depth0,helpers,partials,data) { - return "checked"; -},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; - - return "<div class=\"dict-group well well-sm\" data-title=\"" - + alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper))) - + "\">\n <h4><span class=\"text-muted glyphicon glyphicon-book\"></span> " - + alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper))) - + " <small>rev." - + alias4(((helper = (helper = helpers.revision || (depth0 != null ? depth0.revision : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"revision","hash":{},"data":data}) : helper))) - + "</small></h4>\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.outdated : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "\n <div class=\"checkbox\">\n <label><input type=\"checkbox\" class=\"dict-enabled\" " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.enabled : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "> Enable search</label>\n </div>\n <div class=\"checkbox options-advanced\">\n <label><input type=\"checkbox\" class=\"dict-allow-secondary-searches\" " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.allowSecondarySearches : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + "> Allow secondary searches</label>\n </div>\n <div class=\"form-group options-advanced\">\n <label for=\"dict-" - + alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper))) - + "\">Result priority</label>\n <input type=\"number\" value=\"" - + alias4(((helper = (helper = helpers.priority || (depth0 != null ? depth0.priority : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"priority","hash":{},"data":data}) : helper))) - + "\" id=\"dict-" - + alias4(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data}) : helper))) - + "\" class=\"form-control dict-priority\">\n </div>\n</div>\n"; -},"useData":true}); templates['kanji.html'] = template({"1":function(container,depth0,helpers,partials,data) { var stack1; @@ -60,19 +33,18 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia return "<div class=\"entry\" data-type=\"kanji\">\n <div class=\"actions\">\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " <img src=\"/mixed/img/entry-current.svg\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n <div class=\"glyph\">" + + " <img src=\"/mixed/img/entry-current.svg\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n <div class=\"glyph expression-scan-toggle\">" + container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper))) + "</div>\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(18, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n <table class=\"table table-condensed glyph-data\">\n <tr>\n <th>Glossary</th>\n <th>Readings</th>\n <th>Statistics</th>\n </tr>\n <tr>\n <td class=\"glossary\">\n" - + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(21, data, 0),"inverse":container.program(24, data, 0),"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(19, data, 0),"inverse":container.program(22, data, 0),"data":data})) != null ? stack1 : "") + " </td>\n <td class=\"reading\">\n " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"if","hash":{},"fn":container.program(26, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"if","hash":{},"fn":container.program(24, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n " - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"if","hash":{},"fn":container.program(29, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"if","hash":{},"fn":container.program(27, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n </td>\n <td>" + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1.misc : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + "</td>\n </tr>\n <tr>\n <th colspan=\"3\">Classifications</th>\n </tr>\n <tr>\n <td colspan=\"3\">" @@ -82,19 +54,17 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + "</td>\n </tr>\n <tr>\n <th colspan=\"3\">Dictionary Indices</th>\n </tr>\n <tr>\n <td colspan=\"3\">" + ((stack1 = container.invokePartial(partials.table,depth0,{"name":"table","hash":{"data":((stack1 = (depth0 != null ? depth0.stats : depth0)) != null ? stack1.index : stack1)},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + "</td>\n </tr>\n </table>\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(31, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(29, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>\n"; },"11":function(container,depth0,helpers,partials,data) { return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.svg\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"kanji\"><img src=\"/mixed/img/add-term-kanji.svg\" title=\"Add Kanji (Alt + K)\" alt></a>\n"; },"13":function(container,depth0,helpers,partials,data) { - return " <a href=\"#\" class=\"source-term\"><img src=\"/mixed/img/source-term.svg\" title=\"Source term (Alt + B)\" alt></a>\n"; -},"15":function(container,depth0,helpers,partials,data) { var stack1; return " <div>\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </div>\n"; -},"16":function(container,depth0,helpers,partials,data) { +},"14":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " <span class=\"label label-default tag-frequency\">" @@ -102,13 +72,13 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + ":" + alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper))) + "</span>\n"; -},"18":function(container,depth0,helpers,partials,data) { +},"16":function(container,depth0,helpers,partials,data) { var stack1; return " <div>\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(19, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </div>\n"; -},"19":function(container,depth0,helpers,partials,data) { +},"17":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " <span class=\"label label-default tag-" @@ -118,68 +88,81 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia + "\">" + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + "</span>\n"; -},"21":function(container,depth0,helpers,partials,data) { +},"19":function(container,depth0,helpers,partials,data) { var stack1; return " <ol>" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(22, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(20, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</ol>\n"; -},"22":function(container,depth0,helpers,partials,data) { +},"20":function(container,depth0,helpers,partials,data) { return "<li><span class=\"glossary-item\">" + container.escapeExpression(container.lambda(depth0, depth0)) + "</span></li>"; -},"24":function(container,depth0,helpers,partials,data) { +},"22":function(container,depth0,helpers,partials,data) { var stack1; return " <span class=\"glossary-item\">" + container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.glossary : depth0)) != null ? stack1["0"] : stack1), depth0)) + "</span>\n"; -},"26":function(container,depth0,helpers,partials,data) { +},"24":function(container,depth0,helpers,partials,data) { var stack1; return "<dl>" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(27, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(25, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</dl>"; -},"27":function(container,depth0,helpers,partials,data) { +},"25":function(container,depth0,helpers,partials,data) { return "<dd>" + container.escapeExpression(container.lambda(depth0, depth0)) + "</dd>"; -},"29":function(container,depth0,helpers,partials,data) { +},"27":function(container,depth0,helpers,partials,data) { var stack1; return "<dl>" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(27, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(25, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</dl>"; -},"31":function(container,depth0,helpers,partials,data) { +},"29":function(container,depth0,helpers,partials,data) { var stack1, helper, options, buffer = " <pre>"; - stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(32, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); + stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(30, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); if (!helpers.dumpObject) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "</pre>\n"; -},"32":function(container,depth0,helpers,partials,data) { +},"30":function(container,depth0,helpers,partials,data) { var stack1; return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : ""); -},"34":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; +},"32":function(container,depth0,helpers,partials,data,blockParams,depths) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(35, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"35":function(container,depth0,helpers,partials,data,blockParams,depths) { + return "<div class=\"term-navigation\">\n <a href=\"#\" " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(33, data, 0, blockParams, depths),"inverse":container.program(35, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + "><img src=\"/mixed/img/source-term.svg\" title=\"Source term (Alt + B)\" alt></a>\n <a href=\"#\" " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.next : depth0),{"name":"if","hash":{},"fn":container.program(37, data, 0, blockParams, depths),"inverse":container.program(39, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + "><img src=\"/mixed/img/source-term.svg\" style=\"transform: scaleX(-1);\" title=\"Next term (Alt + F)\" alt></a>\n</div>\n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(41, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"33":function(container,depth0,helpers,partials,data) { + return "class=\"source-term\""; +},"35":function(container,depth0,helpers,partials,data) { + return "class=\"source-term term-button-fade\""; +},"37":function(container,depth0,helpers,partials,data) { + return "class=\"next-term\""; +},"39":function(container,depth0,helpers,partials,data) { + return "class=\"next-term term-button-fade\""; +},"41":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(36, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(42, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = container.invokePartial(partials.kanji,depth0,{"name":"kanji","hash":{"root":(depths[1] != null ? depths[1].root : depths[1]),"source":(depths[1] != null ? depths[1].source : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); -},"36":function(container,depth0,helpers,partials,data) { + + ((stack1 = container.invokePartial(partials.kanji,depth0,{"name":"kanji","hash":{"root":(depths[1] != null ? depths[1].root : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); +},"42":function(container,depth0,helpers,partials,data) { return "<hr>"; -},"38":function(container,depth0,helpers,partials,data) { +},"44":function(container,depth0,helpers,partials,data) { return "<p class=\"note\">No results found</p>\n"; },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return "\n\n" - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(34, data, 0, blockParams, depths),"inverse":container.program(38, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(32, data, 0, blockParams, depths),"inverse":container.program(44, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); },"main_d": function(fn, props, container, depth0, data, blockParams, depths) { var decorators = container.decorators; @@ -190,23 +173,58 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia } ,"useDecorators":true,"usePartial":true,"useData":true,"useDepths":true}); -templates['model.html'] = template({"1":function(container,depth0,helpers,partials,data) { - return " <li><a class=\"marker-link\" href=\"#\">" +templates['query-parser.html'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); + + return ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.preview : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(alias1,depth0,{"name":"each","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "</span>"; +},"2":function(container,depth0,helpers,partials,data) { + return "<span class=\"query-parser-term-preview\">"; +},"4":function(container,depth0,helpers,partials,data) { + return "<span class=\"query-parser-term\">"; +},"6":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = container.invokePartial(partials.part,depth0,{"name":"part","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); +},"8":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.raw : depth0),{"name":"if","hash":{},"fn":container.program(9, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : ""); +},"9":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.text : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"10":function(container,depth0,helpers,partials,data) { + return "<span class=\"query-parser-char\">" + container.escapeExpression(container.lambda(depth0, depth0)) - + "</a></li>\n"; -},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + "</span>"; +},"12":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - return "<tr>\n <td class=\"col-sm-2\">" - + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) - + "</td>\n <td class=\"col-sm-10\">\n <div class=\"input-group\">\n <input type=\"text\" class=\"anki-field-value form-control\" data-field=\"" - + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) - + "\" value=\"" - + alias4(((helper = (helper = helpers.value || (depth0 != null ? depth0.value : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"value","hash":{},"data":data}) : helper))) - + "\">\n <div class=\"input-group-btn\">\n <button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\">\n <span class=\"caret\"></span>\n </button>\n <ul class=\"dropdown-menu dropdown-menu-right\">\n" - + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.markers : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + " </ul>\n </div>\n </div>\n </td>\n</tr>\n"; -},"useData":true}); + return "<ruby>" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.text : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "<rt>" + + container.escapeExpression(((helper = (helper = helpers.reading || (depth0 != null ? depth0.reading : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"reading","hash":{},"data":data}) : helper))) + + "</rt></ruby>"; +},"14":function(container,depth0,helpers,partials,data,blockParams,depths) { + var stack1; + + return ((stack1 = container.invokePartial(partials.term,depth0,{"name":"term","hash":{"preview":(depths[1] != null ? depths[1].preview : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { + var stack1; + + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.terms : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"main_d": function(fn, props, container, depth0, data, blockParams, depths) { + + var decorators = container.decorators; + + fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"args":["term"],"data":data}) || fn; + fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(8, data, 0, blockParams, depths),"inverse":container.noop,"args":["part"],"data":data}) || fn; + return fn; + } + +,"useDecorators":true,"usePartial":true,"useData":true,"useDepths":true}); templates['terms.html'] = template({"1":function(container,depth0,helpers,partials,data) { var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = "<div class=\"dict-"; @@ -298,17 +316,16 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia return "<div class=\"entry\" data-type=\"term\">\n <div class=\"actions\">\n" + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.addable : depth0),{"name":"if","hash":{},"fn":container.program(25, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + ((stack1 = helpers.unless.call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"unless","hash":{},"fn":container.program(27, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(30, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " <img src=\"/mixed/img/entry-current.svg\" class=\"current\" title=\"Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)\" alt>\n </div>\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(32, data, 0, blockParams, depths),"inverse":container.program(47, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(30, data, 0, blockParams, depths),"inverse":container.program(45, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(50, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reasons : depth0),{"name":"if","hash":{},"fn":container.program(48, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(54, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(52, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n <div class=\"glossary\">\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(57, data, 0, blockParams, depths),"inverse":container.program(63, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.grouped : depth0),{"name":"if","hash":{},"fn":container.program(55, data, 0, blockParams, depths),"inverse":container.program(61, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + " </div>\n\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(66, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.debug : depth0),{"name":"if","hash":{},"fn":container.program(64, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>\n"; },"25":function(container,depth0,helpers,partials,data) { return " <a href=\"#\" class=\"action-view-note pending disabled\"><img src=\"/mixed/img/view-note.svg\" title=\"View added note (Alt + V)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kanji\"><img src=\"/mixed/img/add-term-kanji.svg\" title=\"Add expression (Alt + E)\" alt></a>\n <a href=\"#\" class=\"action-add-note pending disabled\" data-mode=\"term-kana\"><img src=\"/mixed/img/add-term-kana.svg\" title=\"Add reading (Alt + R)\" alt></a>\n"; @@ -318,47 +335,45 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.playback : depth0),{"name":"if","hash":{},"fn":container.program(28, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); },"28":function(container,depth0,helpers,partials,data) { return " <a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.svg\" title=\"Play audio (Alt + P)\" alt></a>\n"; -},"30":function(container,depth0,helpers,partials,data) { - return " <a href=\"#\" class=\"source-term\"><img src=\"/mixed/img/source-term.svg\" title=\"Source term (Alt + B)\" alt></a>\n"; -},"32":function(container,depth0,helpers,partials,data,blockParams,depths) { +},"30":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.expressions : depth0),{"name":"each","hash":{},"fn":container.program(33, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"33":function(container,depth0,helpers,partials,data,blockParams,depths) { + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.expressions : depth0),{"name":"each","hash":{},"fn":container.program(31, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"31":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", buffer = - "<div class=\"expression\"><span class=\"expression-" + "<div class=\"expression expression-scan-toggle\"><span class=\"expression-" + container.escapeExpression(((helper = (helper = helpers.termFrequency || (depth0 != null ? depth0.termFrequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"termFrequency","hash":{},"data":data}) : helper))) + "\">"; - stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : alias2),(options={"name":"kanjiLinks","hash":{},"fn":container.program(34, data, 0, blockParams, depths),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); + stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : alias2),(options={"name":"kanjiLinks","hash":{},"fn":container.program(32, data, 0, blockParams, depths),"inverse":container.noop,"data":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper)); if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "</span><div class=\"peek-wrapper\">" - + ((stack1 = helpers["if"].call(alias1,(depths[1] != null ? depths[1].playback : depths[1]),{"name":"if","hash":{},"fn":container.program(37, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(39, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(42, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depths[1] != null ? depths[1].playback : depths[1]),{"name":"if","hash":{},"fn":container.program(35, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(37, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.frequencies : depth0),{"name":"if","hash":{},"fn":container.program(40, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div><span class=\"" - + ((stack1 = helpers["if"].call(alias1,(data && data.last),{"name":"if","hash":{},"fn":container.program(45, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(data && data.last),{"name":"if","hash":{},"fn":container.program(43, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\">、</span></div>"; -},"34":function(container,depth0,helpers,partials,data) { +},"32":function(container,depth0,helpers,partials,data) { var stack1, helper, options; - stack1 = ((helper = (helper = helpers.furigana || (depth0 != null ? depth0.furigana : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"furigana","hash":{},"fn":container.program(35, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); + stack1 = ((helper = (helper = helpers.furigana || (depth0 != null ? depth0.furigana : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"furigana","hash":{},"fn":container.program(33, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); if (!helpers.furigana) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { return stack1; } else { return ''; } -},"35":function(container,depth0,helpers,partials,data) { +},"33":function(container,depth0,helpers,partials,data) { var stack1; return ((stack1 = container.lambda(depth0, depth0)) != null ? stack1 : ""); -},"37":function(container,depth0,helpers,partials,data) { +},"35":function(container,depth0,helpers,partials,data) { return "<a href=\"#\" class=\"action-play-audio\"><img src=\"/mixed/img/play-audio.svg\" title=\"Play audio\" alt></a>"; -},"39":function(container,depth0,helpers,partials,data) { +},"37":function(container,depth0,helpers,partials,data) { var stack1; return "<div class=\"tags\">" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(40, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(38, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>"; -},"40":function(container,depth0,helpers,partials,data) { +},"38":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " <span class=\"label label-default tag-" @@ -368,13 +383,13 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia + "\">" + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper))) + "</span>\n"; -},"42":function(container,depth0,helpers,partials,data) { +},"40":function(container,depth0,helpers,partials,data) { var stack1; return "<div class=\"frequencies\">" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(43, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(41, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "</div>"; -},"43":function(container,depth0,helpers,partials,data) { +},"41":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " <span class=\"label label-default tag-frequency\">" @@ -382,45 +397,45 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia + ":" + alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper))) + "</span>\n"; -},"45":function(container,depth0,helpers,partials,data) { +},"43":function(container,depth0,helpers,partials,data) { return "invisible"; -},"47":function(container,depth0,helpers,partials,data) { +},"45":function(container,depth0,helpers,partials,data) { var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), buffer = - " <div class=\"expression\">"; - stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"kanjiLinks","hash":{},"fn":container.program(34, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper)); + " <div class=\"expression expression-scan-toggle\">"; + stack1 = ((helper = (helper = helpers.kanjiLinks || (depth0 != null ? depth0.kanjiLinks : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"kanjiLinks","hash":{},"fn":container.program(32, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper)); if (!helpers.kanjiLinks) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "</div>\n" - + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(48, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"48":function(container,depth0,helpers,partials,data) { + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.termTags : depth0),{"name":"if","hash":{},"fn":container.program(46, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"46":function(container,depth0,helpers,partials,data) { var stack1; return " <div style=\"display: inline-block;\">\n" + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.termTags : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </div>\n"; -},"50":function(container,depth0,helpers,partials,data) { +},"48":function(container,depth0,helpers,partials,data) { var stack1; return " <div class=\"reasons\">\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.reasons : depth0),{"name":"each","hash":{},"fn":container.program(51, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.reasons : depth0),{"name":"each","hash":{},"fn":container.program(49, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </div>\n"; -},"51":function(container,depth0,helpers,partials,data) { +},"49":function(container,depth0,helpers,partials,data) { var stack1; return " <span class=\"reasons\">" + container.escapeExpression(container.lambda(depth0, depth0)) + "</span> " - + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(52, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.last),{"name":"unless","hash":{},"fn":container.program(50, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n"; -},"52":function(container,depth0,helpers,partials,data) { +},"50":function(container,depth0,helpers,partials,data) { return "«"; -},"54":function(container,depth0,helpers,partials,data) { +},"52":function(container,depth0,helpers,partials,data) { var stack1; return " <div>\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(55, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.frequencies : depth0),{"name":"each","hash":{},"fn":container.program(53, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </div>\n"; -},"55":function(container,depth0,helpers,partials,data) { +},"53":function(container,depth0,helpers,partials,data) { var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; return " <span class=\"label label-default tag-frequency\">" @@ -428,61 +443,74 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia + ":" + alias4(((helper = (helper = helpers.frequency || (depth0 != null ? depth0.frequency : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"frequency","hash":{},"data":data}) : helper))) + "</span>\n"; -},"57":function(container,depth0,helpers,partials,data,blockParams,depths) { +},"55":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(58, data, 0, blockParams, depths),"inverse":container.program(61, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"58":function(container,depth0,helpers,partials,data,blockParams,depths) { + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["1"] : stack1),{"name":"if","hash":{},"fn":container.program(56, data, 0, blockParams, depths),"inverse":container.program(59, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); +},"56":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return " <ol>\n" - + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(59, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(57, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + " </ol>\n"; -},"59":function(container,depth0,helpers,partials,data,blockParams,depths) { +},"57":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return " <li>" + ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + "</li>\n"; -},"61":function(container,depth0,helpers,partials,data) { +},"59":function(container,depth0,helpers,partials,data) { var stack1; return ((stack1 = container.invokePartial(partials.definition,((stack1 = (depth0 != null ? depth0.definitions : depth0)) != null ? stack1["0"] : stack1),{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); -},"63":function(container,depth0,helpers,partials,data,blockParams,depths) { +},"61":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; - return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(57, data, 0, blockParams, depths),"inverse":container.program(64, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); -},"64":function(container,depth0,helpers,partials,data) { + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.merged : depth0),{"name":"if","hash":{},"fn":container.program(55, data, 0, blockParams, depths),"inverse":container.program(62, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); +},"62":function(container,depth0,helpers,partials,data) { var stack1; return ((stack1 = container.invokePartial(partials.definition,depth0,{"name":"definition","hash":{"compactGlossaries":(depth0 != null ? depth0.compactGlossaries : depth0)},"data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "") + " "; -},"66":function(container,depth0,helpers,partials,data) { +},"64":function(container,depth0,helpers,partials,data) { var stack1, helper, options, buffer = " <pre>"; - stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(35, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); + stack1 = ((helper = (helper = helpers.dumpObject || (depth0 != null ? depth0.dumpObject : depth0)) != null ? helper : helpers.helperMissing),(options={"name":"dumpObject","hash":{},"fn":container.program(33, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),options) : helper)); if (!helpers.dumpObject) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} if (stack1 != null) { buffer += stack1; } return buffer + "</pre>\n"; -},"68":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; - - return ((stack1 = helpers.each.call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(69, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); -},"69":function(container,depth0,helpers,partials,data,blockParams,depths) { - var stack1; +},"66":function(container,depth0,helpers,partials,data,blockParams,depths) { + var stack1, alias1=depth0 != null ? depth0 : (container.nullContext || {}); - return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(70, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + return "<div class=\"term-navigation\">\n <a href=\"#\" " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.source : depth0),{"name":"if","hash":{},"fn":container.program(67, data, 0, blockParams, depths),"inverse":container.program(69, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + "><img src=\"/mixed/img/source-term.svg\" title=\"Source term (Alt + B)\" alt></a>\n <a href=\"#\" " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.next : depth0),{"name":"if","hash":{},"fn":container.program(71, data, 0, blockParams, depths),"inverse":container.program(73, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "") + + "><img src=\"/mixed/img/source-term.svg\" style=\"transform: scaleX(-1);\" title=\"Next term (Alt + F)\" alt></a>\n</div>\n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(75, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"67":function(container,depth0,helpers,partials,data) { + return "class=\"source-term\""; +},"69":function(container,depth0,helpers,partials,data) { + return "class=\"source-term term-button-fade\""; +},"71":function(container,depth0,helpers,partials,data) { + return "class=\"next-term\""; +},"73":function(container,depth0,helpers,partials,data) { + return "class=\"next-term term-button-fade\""; +},"75":function(container,depth0,helpers,partials,data,blockParams,depths) { + var stack1; + + return ((stack1 = helpers.unless.call(depth0 != null ? depth0 : (container.nullContext || {}),(data && data.first),{"name":"unless","hash":{},"fn":container.program(76, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "") + "\n" - + ((stack1 = container.invokePartial(partials.term,depth0,{"name":"term","hash":{"source":(depths[1] != null ? depths[1].source : depths[1]),"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1]),"playback":(depths[1] != null ? depths[1].playback : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"merged":(depths[1] != null ? depths[1].merged : depths[1]),"grouped":(depths[1] != null ? depths[1].grouped : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); -},"70":function(container,depth0,helpers,partials,data) { + + ((stack1 = container.invokePartial(partials.term,depth0,{"name":"term","hash":{"compactGlossaries":(depths[1] != null ? depths[1].compactGlossaries : depths[1]),"playback":(depths[1] != null ? depths[1].playback : depths[1]),"addable":(depths[1] != null ? depths[1].addable : depths[1]),"merged":(depths[1] != null ? depths[1].merged : depths[1]),"grouped":(depths[1] != null ? depths[1].grouped : depths[1]),"debug":(depths[1] != null ? depths[1].debug : depths[1])},"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : ""); +},"76":function(container,depth0,helpers,partials,data) { return "<hr>"; -},"72":function(container,depth0,helpers,partials,data) { +},"78":function(container,depth0,helpers,partials,data) { return "<p class=\"note\">No results found.</p>\n"; },"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; return "\n\n" - + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(68, data, 0, blockParams, depths),"inverse":container.program(72, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.definitions : depth0),{"name":"if","hash":{},"fn":container.program(66, data, 0, blockParams, depths),"inverse":container.program(78, data, 0, blockParams, depths),"data":data})) != null ? stack1 : ""); },"main_d": function(fn, props, container, depth0, data, blockParams, depths) { var decorators = container.decorators; diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 9d90136b..202014c9 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -42,27 +42,16 @@ class Translator { await this.database.purge(); } - async findTermsGrouped(text, dictionaries, alphanumeric, options) { - const titles = Object.keys(dictionaries); - const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric); - - const definitionsGrouped = dictTermsGroup(definitions, dictionaries); - await this.buildTermFrequencies(definitionsGrouped, titles); - - if (options.general.compactTags) { - for (const definition of definitionsGrouped) { - dictTermsCompressTags(definition.definitions); - } - } - - return {length, definitions: definitionsGrouped}; + async deleteDictionary(dictionaryName) { + this.tagCache = {}; + await this.database.deleteDictionary(dictionaryName); } async getSequencedDefinitions(definitions, mainDictionary) { const definitionsBySequence = dictTermsMergeBySequence(definitions, mainDictionary); const defaultDefinitions = definitionsBySequence['-1']; - const sequenceList = Object.keys(definitionsBySequence).map(v => Number(v)).filter(v => v >= 0); + const sequenceList = Object.keys(definitionsBySequence).map((v) => Number(v)).filter((v) => v >= 0); const sequencedDefinitions = sequenceList.map((key) => ({ definitions: definitionsBySequence[key], rawDefinitions: [] @@ -135,7 +124,7 @@ class Translator { for (const expression of result.expressions.keys()) { for (const reading of result.expressions.get(expression).keys()) { const termTags = result.expressions.get(expression).get(reading); - const score = termTags.map(tag => tag.score).reduce((p, v) => p + v, 0); + const score = termTags.map((tag) => tag.score).reduce((p, v) => p + v, 0); expressions.push({ expression: expression, reading: reading, @@ -152,10 +141,41 @@ class Translator { return result; } - async findTermsMerged(text, dictionaries, alphanumeric, options) { - const secondarySearchTitles = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].allowSecondarySearches); + async findTerms(text, details, options) { + switch (options.general.resultOutputMode) { + case 'group': + return await this.findTermsGrouped(text, details, options); + case 'merge': + return await this.findTermsMerged(text, details, options); + case 'split': + return await this.findTermsSplit(text, details, options); + default: + return [[], 0]; + } + } + + async findTermsGrouped(text, details, options) { + const dictionaries = dictEnabledSet(options); + const titles = Object.keys(dictionaries); + const [definitions, length] = await this.findTermsInternal(text, dictionaries, options.scanning.alphanumeric, details); + + const definitionsGrouped = dictTermsGroup(definitions, dictionaries); + await this.buildTermFrequencies(definitionsGrouped, titles); + + if (options.general.compactTags) { + for (const definition of definitionsGrouped) { + dictTermsCompressTags(definition.definitions); + } + } + + return [definitionsGrouped, length]; + } + + async findTermsMerged(text, details, options) { + const dictionaries = dictEnabledSet(options); + const secondarySearchTitles = Object.keys(options.dictionaries).filter((dict) => options.dictionaries[dict].allowSecondarySearches); const titles = Object.keys(dictionaries); - const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric); + const [definitions, length] = await this.findTermsInternal(text, dictionaries, options.scanning.alphanumeric, details); const {sequencedDefinitions, defaultDefinitions} = await this.getSequencedDefinitions(definitions, options.general.mainDictionary); const definitionsMerged = []; const mergedByTermIndices = new Set(); @@ -186,29 +206,33 @@ class Translator { } } - return {length, definitions: dictTermsSort(definitionsMerged)}; + return [dictTermsSort(definitionsMerged), length]; } - async findTermsSplit(text, dictionaries, alphanumeric) { + async findTermsSplit(text, details, options) { + const dictionaries = dictEnabledSet(options); const titles = Object.keys(dictionaries); - const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric); + const [definitions, length] = await this.findTermsInternal(text, dictionaries, options.scanning.alphanumeric, details); await this.buildTermFrequencies(definitions, titles); - return {length, definitions}; + return [definitions, length]; } - async findTerms(text, dictionaries, alphanumeric) { + async findTermsInternal(text, dictionaries, alphanumeric, details) { if (!alphanumeric && text.length > 0) { const c = text[0]; if (!jpIsKana(c) && !jpIsKanji(c)) { - return {length: 0, definitions: []}; + return [[], 0]; } } - const textHiragana = jpKatakanaToHiragana(text); const titles = Object.keys(dictionaries); - const deinflections = await this.findTermDeinflections(text, textHiragana, titles); + const deinflections = ( + details.wildcard ? + await this.findTermWildcard(text, titles) : + await this.findTermDeinflections(text, titles) + ); let definitions = []; for (const deinflection of deinflections) { @@ -241,10 +265,26 @@ class Translator { length = Math.max(length, definition.source.length); } - return {length, definitions}; + return [definitions, length]; } - async findTermDeinflections(text, text2, titles) { + async findTermWildcard(text, titles) { + const definitions = await this.database.findTermsBulk([text], titles, true); + if (definitions.length === 0) { + return []; + } + + return [{ + source: text, + term: text, + rules: 0, + definitions, + reasons: [] + }]; + } + + async findTermDeinflections(text, titles) { + const text2 = jpKatakanaToHiragana(text); const deinflections = (text === text2 ? this.getDeinflections(text) : this.getDeinflections2(text, text2)); if (deinflections.length === 0) { @@ -257,7 +297,7 @@ class Translator { for (const deinflection of deinflections) { const term = deinflection.term; let deinflectionArray; - if (uniqueDeinflectionsMap.hasOwnProperty(term)) { + if (hasOwn(uniqueDeinflectionsMap, term)) { deinflectionArray = uniqueDeinflectionsMap[term]; } else { deinflectionArray = []; @@ -268,7 +308,7 @@ class Translator { deinflectionArray.push(deinflection); } - const definitions = await this.database.findTermsBulk(uniqueDeinflectionTerms, titles); + const definitions = await this.database.findTermsBulk(uniqueDeinflectionTerms, titles, false); for (const definition of definitions) { const definitionRules = Deinflector.rulesToRuleFlags(definition.rules); @@ -280,41 +320,42 @@ class Translator { } } - return deinflections.filter(e => e.definitions.length > 0); + return deinflections.filter((e) => e.definitions.length > 0); } getDeinflections(text) { const deinflections = []; for (let i = text.length; i > 0; --i) { - const textSlice = text.slice(0, i); - deinflections.push(...this.deinflector.deinflect(textSlice)); + const textSubstring = text.substring(0, i); + deinflections.push(...this.deinflector.deinflect(textSubstring)); } return deinflections; } - getDeinflections2(text, text2) { + getDeinflections2(text1, text2) { const deinflections = []; - for (let i = text.length; i > 0; --i) { - const textSlice = text.slice(0, i); - const text2Slice = text2.slice(0, i); - deinflections.push(...this.deinflector.deinflect(textSlice)); - if (textSlice !== text2Slice) { - deinflections.push(...this.deinflector.deinflect(text2Slice)); + for (let i = text1.length; i > 0; --i) { + const text1Substring = text1.substring(0, i); + const text2Substring = text2.substring(0, i); + deinflections.push(...this.deinflector.deinflect(text1Substring)); + if (text1Substring !== text2Substring) { + deinflections.push(...this.deinflector.deinflect(text2Substring)); } } return deinflections; } - async findKanji(text, dictionaries) { + async findKanji(text, options) { + const dictionaries = dictEnabledSet(options); const titles = Object.keys(dictionaries); const kanjiUnique = {}; const kanjiList = []; for (const c of text) { - if (!kanjiUnique.hasOwnProperty(c)) { + if (!hasOwn(kanjiUnique, c)) { kanjiList.push(c); kanjiUnique[c] = true; } @@ -376,7 +417,7 @@ class Translator { const expression = term.expression; term.frequencies = []; - if (termsUniqueMap.hasOwnProperty(expression)) { + if (hasOwn(termsUniqueMap, expression)) { termsUniqueMap[expression].push(term); } else { const termList = [term]; @@ -423,7 +464,7 @@ class Translator { const category = meta.category; const group = ( - stats.hasOwnProperty(category) ? + hasOwn(stats, category) ? stats[category] : (stats[category] = []) ); @@ -443,7 +484,7 @@ class Translator { async getTagMetaList(names, title) { const tagMetaList = []; const cache = ( - this.tagCache.hasOwnProperty(title) ? + hasOwn(this.tagCache, title) ? this.tagCache[title] : (this.tagCache[title] = {}) ); @@ -451,7 +492,7 @@ class Translator { for (const name of names) { const base = Translator.getNameBase(name); - if (cache.hasOwnProperty(base)) { + if (hasOwn(cache, base)) { tagMetaList.push(cache[base]); } else { const tagMeta = await this.database.findTagForTitle(base, title); @@ -475,6 +516,6 @@ class Translator { static getNameBase(name) { const pos = name.indexOf(':'); - return (pos >= 0 ? name.substr(0, pos) : name); + return (pos >= 0 ? name.substring(0, pos) : name); } } diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 1ca0833b..3dd5fd55 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -16,12 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -function utilAsync(func) { - return function(...args) { - func.apply(this, args); - }; -} - function utilIsolate(data) { return JSON.parse(JSON.stringify(data)); } @@ -47,13 +41,13 @@ function utilSetEqual(setA, setB) { function utilSetIntersection(setA, setB) { return new Set( - [...setA].filter(value => setB.has(value)) + [...setA].filter((value) => setB.has(value)) ); } function utilSetDifference(setA, setB) { return new Set( - [...setA].filter(value => !setB.has(value)) + [...setA].filter((value) => !setB.has(value)) ); } @@ -80,8 +74,12 @@ function utilAnkiGetDeckNames() { return utilBackend().anki.getDeckNames(); } -function utilDatabaseSummarize() { - return utilBackend().translator.database.summarize(); +function utilDatabaseGetDictionaryInfo() { + return utilBackend().translator.database.getDictionaryInfo(); +} + +function utilDatabaseGetDictionaryCounts(dictionaryNames, getTotal) { + return utilBackend().translator.database.getDictionaryCounts(dictionaryNames, getTotal); } function utilAnkiGetModelFieldNames(modelName) { @@ -92,6 +90,10 @@ function utilDatabasePurge() { return utilBackend().translator.purgeDatabase(); } +function utilDatabaseDeleteDictionary(dictionaryName, onProgress) { + return utilBackend().translator.database.deleteDictionary(dictionaryName, onProgress); +} + async function utilDatabaseImport(data, progress, exceptions) { // Edge cannot read data on the background page due to the File object // being created from a different window. Read on the same page instead. @@ -109,7 +111,3 @@ function utilReadFile(file) { reader.readAsBinaryString(file); }); } - -function utilIsObject(value) { - return typeof value === 'object' && value !== null && !Array.isArray(value); -} diff --git a/ext/bg/legal.html b/ext/bg/legal.html index 30927da6..082239d7 100644 --- a/ext/bg/legal.html +++ b/ext/bg/legal.html @@ -41,12 +41,10 @@ and are used in conformance with the Group's <a href="https://www.edrdg.org/edrd <h3>Third-Party Software Licenses</h3> <ul> <li><a href="https://github.com/twbs/bootstrap/blob/v3.3.7/LICENSE" target="_blank" rel="noopener">Bootstrap v3.3.7</a></li> - <li><a href="https://github.com/minhur/bootstrap-toggle/blob/2.2.0/LICENSE" target="_blank" rel="noopener">Bootstrap Toggle v2.2.0</a></li> - <li><a href="https://github.com/dfahlander/Dexie.js/blob/v2.0.0-beta.10/LICENSE" target="_blank" rel="noopener">Dexie v2.0.0-beta.10</a></li> <li><a href="https://github.com/wycats/handlebars.js/blob/v4.0.6/LICENSE" target="_blank" rel="noopener">Handlebars v4.0.6</a></li> <li><a href="https://github.com/jquery/jquery/blob/3.2.1/LICENSE.txt" target="_blank" rel="noopener">jQuery v3.2.1</a></li> <li><a href="https://github.com/Stuk/jszip/blob/v3.1.3/LICENSE.markdown" target="_blank" rel="noopener">JSZip v3.1.3</a></li> - <li><a href="https://github.com/WaniKani/WanaKana/blob/2.2.3/LICENSE" target="_blank" rel="noopener">WanaKana v2.2.3</a></li> + <li><a href="https://github.com/WaniKani/WanaKana/blob/4.0.2/LICENSE" target="_blank" rel="noopener">WanaKana v4.0.2</a></li> </ul> </div> </div> diff --git a/ext/bg/search.html b/ext/bg/search.html index 91140b95..fef30456 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -25,18 +25,14 @@ <p style="margin-bottom: 0;">Search your installed dictionaries by entering a Japanese expression into the field below.</p> </div> - <div class="input-group" style="padding-top: 10px; font-size: 20px; user-select: none;"> + <div class="input-group" style="padding-top: 20px;"> <span title="Enable kana input method" class="input-group-text"> - <label> - あ - <input type="checkbox" id="wanakana-enable" /> - </label> + <input type="checkbox" id="wanakana-enable" class="icon-checkbox" /> + <label for="wanakana-enable" class="scan-disable">あ</label> </span> <span title="Enable clipboard monitor" class="input-group-text"> - <label> - <span class="glyphicon glyphicon-paste"></span> - <input type="checkbox" id="clipboard-monitor-enable" /> - </label> + <input type="checkbox" id="clipboard-monitor-enable" class="icon-checkbox" /> + <label for="clipboard-monitor-enable"><span class="glyphicon glyphicon-paste"></span></label> </span> </div> @@ -51,13 +47,21 @@ <img src="/mixed/img/spinner.gif"> </div> + <div class="scan-disable"> + <div id="query-parser-select" class="input-group"></div> + <div id="query-parser"></div> + </div> + + <hr> + <div id="content"></div> </div> <script src="/mixed/lib/handlebars.min.js"></script> <script src="/mixed/lib/wanakana.min.js"></script> - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> <script src="/bg/js/dictionary.js"></script> <script src="/bg/js/handlebars.js"></script> @@ -67,10 +71,12 @@ <script src="/fg/js/source.js"></script> <script src="/fg/js/util.js"></script> <script src="/mixed/js/audio.js"></script> + <script src="/mixed/js/display-context.js"></script> <script src="/mixed/js/display.js"></script> <script src="/mixed/js/japanese.js"></script> <script src="/mixed/js/scroll.js"></script> + <script src="/bg/js/search-query-parser.js"></script> <script src="/bg/js/search.js"></script> <script src="/bg/js/search-frontend.js"></script> </body> diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index d27a9a33..339467d4 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -117,7 +117,9 @@ </div> </div></div></div> - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> + <script src="/fg/js/api.js"></script> <script src="/fg/js/document.js"></script> <script src="/fg/js/frontend-api-receiver.js"></script> @@ -126,6 +128,6 @@ <script src="/fg/js/util.js"></script> <script src="/fg/js/popup-proxy-host.js"></script> <script src="/fg/js/frontend.js"></script> - <script src="/bg/js/settings-popup-preview.js"></script> + <script src="/bg/js/settings/popup-preview-frame.js"></script> </body> </html> diff --git a/ext/bg/settings.html b/ext/bg/settings.html index a3b75576..3c5494b8 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -272,7 +272,7 @@ <div class="form-group ignore-form-changes" style="display: none;" id="settings-popup-preview-settings"> <label for="settings-popup-preview-text">Popup preview text</label> - <input type="text" id="settings-popup-preview-text" class="form-control" value="読め"> + <input type="text" id="settings-popup-preview-text" class="form-control" value="読め" placeholder="Preview text"> </div> <div class="form-group ignore-form-changes"> @@ -401,7 +401,7 @@ </div> <div class="checkbox"> - <label><input type="checkbox" id="enable-scanning-of-popup-expressions"> Enable scanning of popup expressions</label> + <label><input type="checkbox" id="enable-scanning-of-popup-expressions"> Enable scanning of expressions in search results</label> </div> <div class="form-group"> @@ -410,18 +410,52 @@ </div> </div> - <div> + <div id="text-parsing"> + <h3>Text Parsing Options</h3> + + <p class="help-block"> + Yomichan can attempt to parse entire sentences or longer text blocks on the search page, + adding furigana above words and a small space between words. + </p> + + <p class="help-block"> + Two types of parsers are supported. The first one, enabled by default, works using the built-in + scanning functionality by automatically advancing in the sentence after a matching word. + </p> + + <p class="help-block"> + The second type is an external program called <a href="https://en.wikipedia.org/wiki/MeCab" target="_blank" rel="noopener">MeCab</a> + that uses its own dictionaries and a special parsing algorithm. To get it working, you must first + install it and <a href="https://github.com/siikamiika/yomichan-mecab-installer" target="_blank" rel="noopener">a native messaging component</a> + that acts as a bridge between the program and Yomichan. + </p> + + <div class="checkbox"> + <label><input type="checkbox" id="parsing-scan-enable"> Enable text parsing using installed dictionaries</label> + </div> + + <div class="checkbox"> + <label><input type="checkbox" id="parsing-mecab-enable"> Enable text parsing using MeCab</label> + </div> + + <div class="form-group"> + <label for="parsing-reading-mode">Reading mode</label> + <select class="form-control" id="parsing-reading-mode"> + <option value="hiragana">ひらがな</option> + <option value="katakana">カタカナ</option> + <option value="romaji">Romaji</option> + </select> + </div> + </div> + + <div class="ignore-form-changes"> <div> <img src="/mixed/img/spinner.gif" class="pull-right" id="dict-spinner" alt> <h3>Dictionaries</h3> </div> <p class="help-block"> - Yomichan can import and use a variety of dictionary formats. Unneeded dictionaries can be disabled, - or you can simply <a href="#" id="dict-purge-link">purge the database</a> to delete everything. - </p> - <p class="help-block"> - Deleting individual dictionaries is not currently feasible due to limitations of browser database technology. + Yomichan can import and use a variety of dictionary formats. Unneeded dictionaries can be disabled. </p> <div class="form-group" id="dict-main-group"> @@ -429,14 +463,16 @@ <select class="form-control" id="dict-main"></select> </div> - <div class="text-danger" id="dict-purge">Dictionary data is being purged, please be patient...</div> - <div class="alert alert-warning" id="dict-warning">No dictionaries have been installed</div> - <div class="alert alert-danger" id="dict-error"></div> + <div class="text-danger" id="dict-purge" hidden>Dictionary data is being purged, please be patient...</div> + <div class="alert alert-warning" id="dict-warning" hidden>No dictionaries have been installed</div> + <div class="alert alert-danger" id="dict-error" hidden></div> <div id="dict-groups"></div> + <div id="dict-groups-extra"></div> <div id="dict-import-progress"> Dictionary data is being imported, please be patient... + <span id="dict-import-info" hidden></span> <div class="progress"> <div class="progress-bar progress-bar-striped" style="width: 0%"></div> </div> @@ -448,9 +484,85 @@ <a href="https://foosoft.net/projects/yomichan" target="_blank" rel="noopener">download free dictionaries</a> for use with this extension and to learn about importing proprietary EPWING dictionaries. </p> - <button class="btn btn-primary" id="dict-file-button">Import Dictionary</button> - <div hidden><input type="file" id="dict-file"></div> + <div> + <button class="btn btn-primary" id="dict-file-button">Import Dictionary</button> + <button class="btn btn-danger" id="dict-purge-button">Purge Database</button> + </div> + <div hidden><input type="file" id="dict-file" accept=".zip,application/zip" multiple></div> + </div> + + <div class="modal fade" tabindex="-1" role="dialog" id="dict-purge-modal"> + <div class="modal-dialog modal-dialog-centered"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Confirm database purge</h4> + </div> + <div class="modal-body"> + Are you sure you want to delete all data in the database? + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> + <button type="button" class="btn btn-danger" id="dict-purge-confirm">Purge Database</button> + </div> + </div> + </div> + </div> + + <div class="modal fade" tabindex="-1" role="dialog" id="dict-delete-modal"> + <div class="modal-dialog modal-dialog-centered"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Confirm dictionary deletion</h4> + </div> + <div class="modal-body"> + Are you sure you want to delete the dictionary <em id="dict-remove-modal-dict-name"></em>? + This operation may take some time and the responsiveness of this browser tab may be reduced. + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> + <button type="button" class="btn btn-danger" id="dict-delete-confirm">Delete Dictionary</button> + </div> + </div> + </div> </div> + + <template id="dict-template"><div class="dict-group well well-sm"> + <h4><span class="text-muted glyphicon glyphicon-book"></span> <span class="dict-title"></span> <small class="dict-revision"></small></h4> + <p class="text-warning dict-outdated" hidden>This dictionary is outdated and may not support new extension features; please import the latest version.</p> + + <div class="checkbox"> + <label><input type="checkbox" class="dict-enabled"> Enable search</label> + </div> + <div class="checkbox options-advanced"> + <label><input type="checkbox" class="dict-allow-secondary-searches"> Allow secondary searches</label> + </div> + <div class="form-group options-advanced"> + <label class="dict-result-priority-label">Result priority</label> + <input type="number" class="form-control dict-priority"> + </div> + <div class="dict-delete-table"> + <div> + <button class="btn btn-default dict-delete-button">Delete Dictionary</button> + </div> + <div> + <div class="progress" hidden> + <div class="progress-bar progress-bar-striped" style="width: 0%"></div> + </div> + </div> + </div> + <pre class="debug dict-counts" hidden></pre> + </div></template> + + <template id="dict-extra-template"><div class="well well-sm"> + <h4><span class="text-muted glyphicon glyphicon-alert"></span> <span class="dict-title">Unassociated Data</span> <small class="dict-total-count"></small></h4> + <p class="text-warning"> + The database contains extra data which is not associated with any installed dictionary. + Purging the database can fix this issue. + </p> + <pre class="debug dict-counts" hidden></pre> + </div></template> </div> <div id="storage-info"> @@ -538,7 +650,7 @@ </div> </div> - <div class="alert alert-danger" id="anki-error"></div> + <div class="alert alert-danger" id="anki-error" hidden></div> <div class="form-group"> <label for="card-tags">Card tags <span class="label-light">(comma or space separated)</span></label> @@ -582,16 +694,16 @@ </ul> <div class="tab-content"> - <div id="terms" class="tab-pane fade in active"> + <div id="terms" class="tab-pane fade in active" data-anki-card-type="terms"> <div class="row"> <div class="form-group col-xs-6"> <label for="anki-terms-deck">Deck</label> - <select class="form-control anki-deck" id="anki-terms-deck"></select> + <select class="form-control anki-deck" id="anki-terms-deck" data-anki-card-type="terms"></select> </div> <div class="form-group col-xs-6"> <label for="anki-terms-model">Model</label> - <select class="form-control anki-model" id="anki-terms-model"></select> + <select class="form-control anki-model" id="anki-terms-model" data-anki-card-type="terms"></select> </div> </div> @@ -601,16 +713,16 @@ </table> </div> - <div id="kanji" class="tab-pane fade"> + <div id="kanji" class="tab-pane fade" data-anki-card-type="kanji"> <div class="row"> <div class="form-group col-xs-6"> <label for="anki-kanji-deck">Deck</label> - <select class="form-control anki-deck" id="anki-kanji-deck"></select> + <select class="form-control anki-deck" id="anki-kanji-deck" data-anki-card-type="kanji"></select> </div> <div class="form-group col-xs-6"> <label for="anki-kanji-model">Model</label> - <select class="form-control anki-model" id="anki-kanji-model"></select> + <select class="form-control anki-model" id="anki-kanji-model" data-anki-card-type="kanji"></select> </div> </div> @@ -625,11 +737,78 @@ <p class="help-block"> Fields are formatted using the <a href="https://handlebarsjs.com/" target="_blank" rel="noopener">Handlebars.js</a> template rendering engine. Advanced users can modify these templates for ultimate control of what information gets included in - their Anki cards. If you encounter problems with your changes you can always <a href="#" id="field-templates-reset">reset to default</a> - template settings. + their Anki cards. If you encounter problems with your changes, you can always reset to the default template settings. </p> <textarea autocomplete="off" spellcheck="false" wrap="soft" class="form-control" rows="10" id="field-templates"></textarea> + <div> + <button class="btn btn-danger" id="field-templates-reset">Reset Templates</button> + </div> + <p></p> + <pre id="field-template-compile-result" hidden></pre> + + <p>Templates can be tested using the inputs below.</p> + + <div class="form-group"> + <div class="row"> + <div class="col-xs-6"> + <label for="field-templates-preview-text">Preview text</label> + <input type="text" id="field-templates-preview-text" class="form-control" value="読め" placeholder="Preview text"> + </div> + <div class="col-xs-6"> + <label for="field-template-render-text">Test field</label> + <div class="input-group"> + <div class="input-group-btn"> + <button class="btn btn-default" id="field-template-render" title="Test"><span class="glyphicon glyphicon-play"></span></button> + </div> + <input type="text" class="form-control" id="field-template-render-text" value="{expression}" placeholder="{marker}"> + <div class="input-group-btn"> + <button class="btn btn-default dropdown-toggle" id="field-templates-dropdown" data-toggle="dropdown"><span class="caret"></span></button> + <ul class="dropdown-menu dropdown-menu-right" id="field-templates-list"></ul> + </div> + </div> + </div> + </div> + </div> + + <p></p> + <pre id="field-template-render-result" hidden></pre> + </div> + + <div class="modal fade" tabindex="-1" role="dialog" id="field-template-reset-modal"> + <div class="modal-dialog modal-dialog-centered"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Confirm template reset</h4> + </div> + <div class="modal-body"> + Are you sure you want to reset the field templates to the default value? + Any changes you made will be lost. + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> + <button type="button" class="btn btn-danger" id="field-templates-reset-confirm">Reset Templates</button> + </div> + </div> + </div> </div> + + <template id="anki-field-template"><tr> + <td class="col-sm-2 anki-field-name"></td> + <td class="col-sm-10"> + <div class="input-group"> + <input type="text" class="anki-field-value form-control" data-field="" value=""> + <div class="input-group-btn"> + <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> + <span class="caret"></span> + </button> + <ul class="dropdown-menu dropdown-menu-right anki-field-marker-list"></ul> + </div> + </div> + </td> + </tr></template> + + <template id="anki-field-marker-template"><li><a class="marker-link" href="#"></a></li></template> </div> </div> </div> @@ -673,7 +852,7 @@ </p> </div> - <pre id="debug"></pre> + <pre id="debug" class="debug"></pre> <div class="pull-right bottom-links"> <small><span id="extension-info"></span> • <a href="search.html">Search</a> • <a href="https://foosoft.net/projects/yomichan/" target="_blank" rel="noopener">Homepage</a> • <a href="legal.html">Legal</a></small> @@ -685,7 +864,9 @@ <script src="/mixed/lib/handlebars.min.js"></script> <script src="/mixed/lib/wanakana.min.js"></script> - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> + <script src="/mixed/js/japanese.js"></script> <script src="/bg/js/anki.js"></script> <script src="/bg/js/api.js"></script> @@ -695,12 +876,20 @@ <script src="/bg/js/dictionary.js"></script> <script src="/bg/js/handlebars.js"></script> <script src="/bg/js/options.js"></script> + <script src="/bg/js/page-exit-prevention.js"></script> <script src="/bg/js/profile-conditions.js"></script> <script src="/bg/js/templates.js"></script> <script src="/bg/js/util.js"></script> <script src="/mixed/js/audio.js"></script> - <script src="/bg/js/settings-profiles.js"></script> - <script src="/bg/js/settings.js"></script> + <script src="/bg/js/settings/anki.js"></script> + <script src="/bg/js/settings/anki-templates.js"></script> + <script src="/bg/js/settings/audio.js"></script> + <script src="/bg/js/settings/dictionaries.js"></script> + <script src="/bg/js/settings/popup-preview.js"></script> + <script src="/bg/js/settings/profiles.js"></script> + <script src="/bg/js/settings/storage.js"></script> + + <script src="/bg/js/settings/main.js"></script> </body> </html> diff --git a/ext/fg/float.html b/ext/fg/float.html index aec3db20..8cc5a129 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -31,15 +31,15 @@ </div> </div> - <script src="/mixed/lib/wanakana.min.js"></script> - - <script src="/mixed/js/extension.js"></script> + <script src="/mixed/js/core.js"></script> + <script src="/mixed/js/dom.js"></script> <script src="/fg/js/api.js"></script> <script src="/fg/js/util.js"></script> <script src="/fg/js/document.js"></script> <script src="/fg/js/source.js"></script> <script src="/mixed/js/audio.js"></script> + <script src="/mixed/js/display-context.js"></script> <script src="/mixed/js/display.js"></script> <script src="/mixed/js/scroll.js"></script> diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js index 54818702..0e100b59 100644 --- a/ext/fg/js/api.js +++ b/ext/fg/js/api.js @@ -18,65 +18,101 @@ function apiOptionsGet(optionsContext) { - return utilInvoke('optionsGet', {optionsContext}); + return _apiInvoke('optionsGet', {optionsContext}); } function apiOptionsSet(changedOptions, optionsContext, source) { - return utilInvoke('optionsSet', {changedOptions, optionsContext, source}); + return _apiInvoke('optionsSet', {changedOptions, optionsContext, source}); } -function apiTermsFind(text, optionsContext) { - return utilInvoke('termsFind', {text, optionsContext}); +function apiTermsFind(text, details, optionsContext) { + return _apiInvoke('termsFind', {text, details, optionsContext}); +} + +function apiTextParse(text, optionsContext) { + return _apiInvoke('textParse', {text, optionsContext}); +} + +function apiTextParseMecab(text, optionsContext) { + return _apiInvoke('textParseMecab', {text, optionsContext}); } function apiKanjiFind(text, optionsContext) { - return utilInvoke('kanjiFind', {text, optionsContext}); + return _apiInvoke('kanjiFind', {text, optionsContext}); } function apiDefinitionAdd(definition, mode, context, optionsContext) { - return utilInvoke('definitionAdd', {definition, mode, context, optionsContext}); + return _apiInvoke('definitionAdd', {definition, mode, context, optionsContext}); } function apiDefinitionsAddable(definitions, modes, optionsContext) { - return utilInvoke('definitionsAddable', {definitions, modes, optionsContext}).catch(() => null); + return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext}).catch(() => null); } function apiNoteView(noteId) { - return utilInvoke('noteView', {noteId}); + return _apiInvoke('noteView', {noteId}); } function apiTemplateRender(template, data, dynamic) { - return utilInvoke('templateRender', {data, template, dynamic}); + return _apiInvoke('templateRender', {data, template, dynamic}); } function apiAudioGetUrl(definition, source, optionsContext) { - return utilInvoke('audioGetUrl', {definition, source, optionsContext}); + return _apiInvoke('audioGetUrl', {definition, source, optionsContext}); } function apiCommandExec(command, params) { - return utilInvoke('commandExec', {command, params}); + return _apiInvoke('commandExec', {command, params}); } function apiScreenshotGet(options) { - return utilInvoke('screenshotGet', {options}); + return _apiInvoke('screenshotGet', {options}); } function apiForward(action, params) { - return utilInvoke('forward', {action, params}); + return _apiInvoke('forward', {action, params}); } function apiFrameInformationGet() { - return utilInvoke('frameInformationGet'); + return _apiInvoke('frameInformationGet'); } function apiInjectStylesheet(css) { - return utilInvoke('injectStylesheet', {css}); + return _apiInvoke('injectStylesheet', {css}); } function apiGetEnvironmentInfo() { - return utilInvoke('getEnvironmentInfo'); + return _apiInvoke('getEnvironmentInfo'); } function apiClipboardGet() { - return utilInvoke('clipboardGet'); + return _apiInvoke('clipboardGet'); +} + +function _apiInvoke(action, params={}) { + const data = {action, params}; + return new Promise((resolve, reject) => { + try { + chrome.runtime.sendMessage(data, (response) => { + _apiCheckLastError(chrome.runtime.lastError); + if (response !== null && typeof response === 'object') { + if (typeof response.error !== 'undefined') { + reject(jsonToError(response.error)); + } else { + resolve(response.result); + } + } else { + const message = response === null ? 'Unexpected null response' : `Unexpected response of type ${typeof response}`; + reject(new Error(`${message} (${JSON.stringify(data)})`)); + } + }); + } catch (e) { + window.yomichan_orphaned = true; + reject(e); + } + }); +} + +function _apiCheckLastError() { + // NOP } diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index a168705e..10dea7df 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -17,7 +17,7 @@ */ -const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^\)]*,\s*0(?:\.0+)?\s*\)/; +const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; function docSetImposterStyle(style, propertyName, value) { style.setProperty(propertyName, value, 'important'); @@ -223,7 +223,7 @@ function isPointInRange(x, y, range) { const {node, offset, content} = TextSourceRange.seekForward(range.endContainer, range.endOffset, 1); range.setEnd(node, offset); - if (!isWhitespace(content) && isPointInAnyRect(x, y, range.getClientRects())) { + if (!isWhitespace(content) && DOM.isPointInAnyRect(x, y, range.getClientRects())) { return true; } } finally { @@ -234,7 +234,7 @@ function isPointInRange(x, y, range) { const {node, offset, content} = TextSourceRange.seekBackward(range.startContainer, range.startOffset, 1); range.setStart(node, offset); - if (!isWhitespace(content) && isPointInAnyRect(x, y, range.getClientRects())) { + if (!isWhitespace(content) && DOM.isPointInAnyRect(x, y, range.getClientRects())) { // This purposefully leaves the starting offset as modified and sets the range length to 0. range.setEnd(node, offset); return true; @@ -248,21 +248,6 @@ function isWhitespace(string) { return string.trim().length === 0; } -function isPointInAnyRect(x, y, rects) { - for (const rect of rects) { - if (isPointInRect(x, y, rect)) { - return true; - } - } - return false; -} - -function isPointInRect(x, y, rect) { - return ( - x >= rect.left && x < rect.right && - y >= rect.top && y < rect.bottom); -} - const caretRangeFromPoint = (() => { if (typeof document.caretRangeFromPoint === 'function') { // Chrome, Edge @@ -359,7 +344,7 @@ function isElementTransparent(element) { } const style = window.getComputedStyle(element); return ( - parseFloat(style.opacity) < 0 || + parseFloat(style.opacity) <= 0 || style.visibility === 'hidden' || (style.backgroundImage === 'none' && isColorTransparent(style.backgroundColor)) ); diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 089c9422..ae54be00 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -49,7 +49,7 @@ class DisplayFloat extends Display { onMessage(e) { const {action, params} = e.data; const handlers = DisplayFloat.messageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; handler(this, params); } @@ -58,7 +58,7 @@ class DisplayFloat extends Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); const handlers = DisplayFloat.onKeyDownHandlers; - if (handlers.hasOwnProperty(key)) { + if (hasOwn(handlers, key)) { const handler = handlers[key]; if (handler(this, e)) { e.preventDefault(); diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js index fbfb3ab0..7d38ddd5 100644 --- a/ext/fg/js/frontend-api-receiver.js +++ b/ext/fg/js/frontend-api-receiver.js @@ -34,7 +34,7 @@ class FrontendApiReceiver { onMessage(port, {id, action, params, target, senderId}) { if ( target !== this.source || - !this.handlers.hasOwnProperty(action) + !hasOwn(this.handlers, action) ) { return; } @@ -43,10 +43,10 @@ class FrontendApiReceiver { const handler = this.handlers[action]; handler(params).then( - result => { + (result) => { this.sendResult(port, id, senderId, {result}); }, - error => { + (error) => { this.sendResult(port, id, senderId, {error: errorToJson(error)}); }); } diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js index c6eeaeb2..af998a8f 100644 --- a/ext/fg/js/frontend-api-sender.js +++ b/ext/fg/js/frontend-api-sender.js @@ -78,7 +78,7 @@ class FrontendApiSender { } onAck(id) { - if (!this.callbacks.hasOwnProperty(id)) { + if (!hasOwn(this.callbacks, id)) { console.warn(`ID ${id} not found for ack`); return; } @@ -95,7 +95,7 @@ class FrontendApiSender { } onResult(id, data) { - if (!this.callbacks.hasOwnProperty(id)) { + if (!hasOwn(this.callbacks, id)) { console.warn(`ID ${id} not found`); return; } @@ -118,7 +118,7 @@ class FrontendApiSender { } onError(id, reason) { - if (!this.callbacks.hasOwnProperty(id)) { return; } + if (!hasOwn(this.callbacks, id)) { return; } const info = this.callbacks[id]; delete this.callbacks[id]; info.timer = null; diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index e67008df..9a1d507b 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -80,7 +80,7 @@ class Frontend { onMouseMove(e) { this.popupTimerClear(); - if (this.pendingLookup || Frontend.isMouseButton('primary', e)) { + if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) { return; } @@ -88,7 +88,7 @@ class Frontend { const scanningModifier = scanningOptions.modifier; if (!( Frontend.isScanningModifierPressed(scanningModifier, e) || - (scanningOptions.middleMouse && Frontend.isMouseButton('auxiliary', e)) + (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary')) )) { return; } @@ -122,7 +122,7 @@ class Frontend { } } - onMouseOut(e) { + onMouseOut() { this.popupTimerClear(); } @@ -135,7 +135,7 @@ class Frontend { } } - onAuxClick(e) { + onAuxClick() { this.preventNextContextMenu = false; } @@ -159,7 +159,7 @@ class Frontend { this.preventNextClick = false; const primaryTouch = e.changedTouches[0]; - if (Frontend.selectionContainsPoint(window.getSelection(), primaryTouch.clientX, primaryTouch.clientY)) { + if (DOM.isPointInSelection(primaryTouch.clientX, primaryTouch.clientY, window.getSelection())) { return; } @@ -237,7 +237,7 @@ class Frontend { onWindowMessage(e) { const action = e.data; const handlers = Frontend.windowMessageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; handler(this); } @@ -245,7 +245,7 @@ class Frontend { onRuntimeMessage({action, params}, sender, callback) { const handlers = Frontend.runtimeMessageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; const result = handler(this, params); callback(result); @@ -398,7 +398,7 @@ class Frontend { textSource.getRect(), textSource.getWritingMode(), type, - {definitions, context: {sentence, url, focus}} + {definitions, context: {sentence, url, focus, disableHistory: true}} ); this.textSourceCurrent = textSource; @@ -413,7 +413,7 @@ class Frontend { const searchText = textSource.text(); if (searchText.length === 0) { return null; } - const {definitions, length} = await apiTermsFind(searchText, this.getOptionsContext()); + const {definitions, length} = await apiTermsFind(searchText, {}, this.getOptionsContext()); if (definitions.length === 0) { return null; } textSource.setEndOffset(length); @@ -447,8 +447,8 @@ class Frontend { } getIndexOfTouch(touchList, identifier) { - for (let i in touchList) { - let t = touchList[i]; + for (const i in touchList) { + const t = touchList[i]; if (t.identifier === identifier) { return i; } @@ -456,18 +456,6 @@ class Frontend { return -1; } - static selectionContainsPoint(selection, x, y) { - for (let i = 0; i < selection.rangeCount; ++i) { - const range = selection.getRangeAt(i); - for (const rect of range.getClientRects()) { - if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) { - return true; - } - } - } - return false; - } - setTextSourceScanLength(textSource, length) { textSource.setEndOffset(length); if (this.ignoreNodes === null || !textSource.range) { @@ -499,25 +487,6 @@ class Frontend { default: return false; } } - - static isMouseButton(button, mouseEvent) { - switch (mouseEvent.type) { - case 'mouseup': - case 'mousedown': - case 'click': switch (button) { - case 'primary': return mouseEvent.button === 0; - case 'secondary': return mouseEvent.button === 2; - case 'auxiliary': return mouseEvent.button === 1; - default: return false; - } - default: switch (button) { - case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0; - case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0; - case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0; - default: return false; - } - } - } } Frontend.windowMessageHandlers = { diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index cec95aea..31cb1cda 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -33,7 +33,10 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) { return; } - const ignoreNodes = options.scanning.enableOnPopupExpressions ? [] : [ '.expression', '.expression *' ]; + const ignoreNodes = ['.scan-disable', '.scan-disable *']; + if (!options.scanning.enableOnPopupExpressions) { + ignoreNodes.push('.expression-scan-toggle', '.expression-scan-toggle *'); + } window.frontendInitializationData = {id, depth, parentFrameId, ignoreNodes, url, proxy: true}; diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index d8dec4df..b2f18b97 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -50,7 +50,7 @@ class PopupProxyHost { } createPopup(parentId, depth) { - const parent = (typeof parentId === 'string' && this.popups.hasOwnProperty(parentId) ? this.popups[parentId] : null); + const parent = (typeof parentId === 'string' && hasOwn(this.popups, parentId) ? this.popups[parentId] : null); const id = `${this.nextId}`; if (parent !== null) { depth = parent.depth + 1; @@ -70,7 +70,7 @@ class PopupProxyHost { } getPopup(id) { - if (!this.popups.hasOwnProperty(id)) { + if (!hasOwn(this.popups, id)) { throw new Error('Invalid popup ID'); } diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 1f9317e0..42475d96 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -28,8 +28,8 @@ class Popup { this.childrenSupported = true; this.container = document.createElement('iframe'); this.container.className = 'yomichan-float'; - this.container.addEventListener('mousedown', e => e.stopPropagation()); - this.container.addEventListener('scroll', e => e.stopPropagation()); + this.container.addEventListener('mousedown', (e) => e.stopPropagation()); + this.container.addEventListener('scroll', (e) => e.stopPropagation()); this.container.setAttribute('src', chrome.runtime.getURL('/fg/float.html')); this.container.style.width = '0px'; this.container.style.height = '0px'; @@ -303,7 +303,7 @@ class Popup { } static getColorInfo(cssColor) { - const m = /^\s*rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d\.]+)\s*)?\)\s*$/.exec(cssColor); + const m = /^\s*rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)\s*$/.exec(cssColor); if (m === null) { return null; } const m4 = m[4]; @@ -391,7 +391,7 @@ class Popup { static isOnExtensionPage() { try { const url = chrome.runtime.getURL('/'); - return window.location.href.substr(0, url.length) === url; + return window.location.href.substring(0, url.length) === url; } catch (e) { // NOP } @@ -401,7 +401,7 @@ class Popup { if (Popup.outerStylesheet === null) { if (!css) { return; } Popup.outerStylesheet = document.createElement('style'); - Popup.outerStylesheet.id = "yomichan-popup-outer-stylesheet"; + Popup.outerStylesheet.id = 'yomichan-popup-outer-stylesheet'; } const outerStylesheet = Popup.outerStylesheet; diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index c3da9f46..a84feed4 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -99,15 +99,19 @@ class TextSourceRange { static getRubyElement(node) { node = TextSourceRange.getParentElement(node); - if (node !== null && node.nodeName.toUpperCase() === "RT") { + if (node !== null && node.nodeName.toUpperCase() === 'RT') { node = node.parentNode; - return (node !== null && node.nodeName.toUpperCase() === "RUBY") ? node : null; + return (node !== null && node.nodeName.toUpperCase() === 'RUBY') ? node : null; } return null; } static seekForward(node, offset, length) { const state = {node, offset, remainder: length, content: ''}; + if (length <= 0) { + return state; + } + const TEXT_NODE = Node.TEXT_NODE; const ELEMENT_NODE = Node.ELEMENT_NODE; let resetOffset = false; @@ -166,6 +170,10 @@ class TextSourceRange { static seekBackward(node, offset, length) { const state = {node, offset, remainder: length, content: ''}; + if (length <= 0) { + return state; + } + const TEXT_NODE = Node.TEXT_NODE; const ELEMENT_NODE = Node.ELEMENT_NODE; let resetOffset = false; @@ -353,7 +361,7 @@ class TextSourceElement { let consumed = 0; let content = ''; - for (let currentChar of this.content || '') { + for (const currentChar of this.content || '') { if (consumed >= length) { break; } else if (!currentChar.match(IGNORE_TEXT_PATTERN)) { @@ -367,7 +375,7 @@ class TextSourceElement { return this.content.length; } - setStartOffset(length) { + setStartOffset() { return 0; } diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js deleted file mode 100644 index 9a7968a7..00000000 --- a/ext/fg/js/util.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2016-2017 Alex Yatskov <alex@foosoft.net> - * Author: Alex Yatskov <alex@foosoft.net> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -function utilAsync(func) { - return function(...args) { - func.apply(this, args); - }; -} - -function utilInvoke(action, params={}) { - const data = {action, params}; - return new Promise((resolve, reject) => { - try { - chrome.runtime.sendMessage(data, (response) => { - utilCheckLastError(chrome.runtime.lastError); - if (response !== null && typeof response === 'object') { - if (typeof response.error !== 'undefined') { - reject(jsonToError(response.error)); - } else { - resolve(response.result); - } - } else { - const message = response === null ? 'Unexpected null response' : `Unexpected response of type ${typeof response}`; - reject(new Error(`${message} (${JSON.stringify(data)})`)); - } - }); - } catch (e) { - window.yomichan_orphaned = true; - reject(e); - } - }); -} - -function utilCheckLastError(e) { - // NOP -} diff --git a/ext/manifest.json b/ext/manifest.json index b9d91a81..07343822 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan (testing)", - "version": "1.9.5", + "version": "2.0.0", "description": "Japanese dictionary with Anki integration (testing)", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, @@ -18,13 +18,13 @@ "content_scripts": [{ "matches": ["http://*/*", "https://*/*", "file://*/*"], "js": [ - "mixed/js/extension.js", + "mixed/js/core.js", + "mixed/js/dom.js", "fg/js/api.js", "fg/js/document.js", "fg/js/frontend-api-receiver.js", "fg/js/popup.js", "fg/js/source.js", - "fg/js/util.js", "fg/js/popup-proxy-host.js", "fg/js/frontend.js", "fg/js/frontend-initialize.js" @@ -42,7 +42,8 @@ "<all_urls>", "storage", "clipboardWrite", - "unlimitedStorage" + "unlimitedStorage", + "nativeMessaging" ], "optional_permissions": [ "clipboardRead" diff --git a/ext/mixed/css/display-dark.css b/ext/mixed/css/display-dark.css index 34a0ccd1..681d248c 100644 --- a/ext/mixed/css/display-dark.css +++ b/ext/mixed/css/display-dark.css @@ -48,3 +48,9 @@ hr { border-top-color: #2f2f2f; } .expression-rare, .expression-rare .kanji-link { color: #666666; } + +.icon-checkbox:checked + label { + /* invert colors */ + background-color: #d4d4d4; + color: #1e1e1e; +} diff --git a/ext/mixed/css/display-default.css b/ext/mixed/css/display-default.css index 176c5387..add0a9c8 100644 --- a/ext/mixed/css/display-default.css +++ b/ext/mixed/css/display-default.css @@ -48,3 +48,9 @@ hr { border-top-color: #eeeeee; } .expression-rare, .expression-rare .kanji-link { color: #999999; } + +.icon-checkbox:checked + label { + /* invert colors */ + background-color: #333333; + color: #ffffff; +} diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css index 7793ddeb..9152216f 100644 --- a/ext/mixed/css/display.css +++ b/ext/mixed/css/display.css @@ -72,13 +72,55 @@ ol, ul { visibility: hidden; } +/* + * Navigation + */ + +.term-navigation { + position: fixed; + top: 0px; +} + +.term-button-fade { + opacity: 0.4; +} + + +/* + * Search page + */ + +.icon-checkbox { + display: none; +} + +.icon-checkbox + label { + cursor: pointer; + font-size: 22px; + padding: 2px; + user-select: none; +} + +#query-parser { + margin-top: 10px; + font-size: 24px; +} + +.query-parser-term { + margin-right: 5px; +} + +html:root[data-yomichan-page=search] body { + overflow-y: scroll; /* always show scroll bar to avoid scanning problems */ +} + /* * Entries */ .entry, .note { - padding-top: 10px; + padding-top: 20px; padding-bottom: 10px; } diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js index cf8b8d24..35f283a4 100644 --- a/ext/mixed/js/audio.js +++ b/ext/mixed/js/audio.js @@ -68,14 +68,14 @@ class TextToSpeechAudio { } static createFromUri(ttsUri) { - const m = /^tts:[^#\?]*\?([^#]*)/.exec(ttsUri); + const m = /^tts:[^#?]*\?([^#]*)/.exec(ttsUri); if (m === null) { return null; } const searchParameters = {}; for (const group of m[1].split('&')) { const sep = group.indexOf('='); if (sep < 0) { continue; } - searchParameters[decodeURIComponent(group.substr(0, sep))] = decodeURIComponent(group.substr(sep + 1)); + searchParameters[decodeURIComponent(group.substring(0, sep))] = decodeURIComponent(group.substring(sep + 1)); } if (!searchParameters.text) { return null; } @@ -88,19 +88,15 @@ class TextToSpeechAudio { } -function audioGetFromUrl(url, download) { +function audioGetFromUrl(url, willDownload) { const tts = TextToSpeechAudio.createFromUri(url); if (tts !== null) { - if (download) { - throw new Error('Download not supported for text-to-speech'); + if (willDownload) { + throw new Error('AnkiConnect does not support downloading text-to-speech audio.'); } return Promise.resolve(tts); } - if (download) { - return Promise.resolve(null); - } - return new Promise((resolve, reject) => { const audio = new Audio(url); audio.addEventListener('loadeddata', () => { @@ -115,9 +111,9 @@ function audioGetFromUrl(url, download) { }); } -async function audioGetFromSources(expression, sources, optionsContext, download, cache=null) { +async function audioGetFromSources(expression, sources, optionsContext, willDownload, cache=null) { const key = `${expression.expression}:${expression.reading}`; - if (cache !== null && cache.hasOwnProperty(expression)) { + if (cache !== null && hasOwn(cache, expression)) { return cache[key]; } @@ -129,7 +125,11 @@ async function audioGetFromSources(expression, sources, optionsContext, download } try { - const audio = await audioGetFromUrl(url, download); + let audio = await audioGetFromUrl(url, willDownload); + if (willDownload) { + // AnkiConnect handles downloading URLs into cards + audio = null; + } const result = {audio, url, source}; if (cache !== null) { cache[key] = result; diff --git a/ext/mixed/js/extension.js b/ext/mixed/js/core.js index 54862e19..b5911535 100644 --- a/ext/mixed/js/extension.js +++ b/ext/mixed/js/core.js @@ -17,27 +17,11 @@ */ -// toIterable is required on Edge for cross-window origin objects. -function toIterable(value) { - if (typeof Symbol !== 'undefined' && typeof value[Symbol.iterator] !== 'undefined') { - return value; - } - - if (value !== null && typeof value === 'object') { - const length = value.length; - if (typeof length === 'number' && Number.isFinite(length)) { - const array = []; - for (let i = 0; i < length; ++i) { - array.push(value[i]); - } - return array; - } - } - - throw new Error('Could not convert to iterable'); -} +/* + * Extension information + */ -function extensionHasChrome() { +function _extensionHasChrome() { try { return typeof chrome === 'object' && chrome !== null; } catch (e) { @@ -45,7 +29,7 @@ function extensionHasChrome() { } } -function extensionHasBrowser() { +function _extensionHasBrowser() { try { return typeof browser === 'object' && browser !== null; } catch (e) { @@ -53,6 +37,21 @@ function extensionHasBrowser() { } } +const EXTENSION_IS_BROWSER_EDGE = ( + _extensionHasBrowser() && + (!_extensionHasChrome() || (typeof chrome.runtime === 'undefined' && typeof browser.runtime !== 'undefined')) +); + +if (EXTENSION_IS_BROWSER_EDGE) { + // Edge does not have chrome defined. + chrome = browser; +} + + +/* + * Error handling + */ + function errorToJson(error) { return { name: error.name, @@ -86,16 +85,44 @@ function logError(error, alert) { } } -const EXTENSION_IS_BROWSER_EDGE = ( - extensionHasBrowser() && - (!extensionHasChrome() || (typeof chrome.runtime === 'undefined' && typeof browser.runtime !== 'undefined')) -); -if (EXTENSION_IS_BROWSER_EDGE) { - // Edge does not have chrome defined. - chrome = browser; +/* + * Common helpers + */ + +function isObject(value) { + return typeof value === 'object' && value !== null && !Array.isArray(value); } +function hasOwn(object, property) { + return Object.prototype.hasOwnProperty.call(object, property); +} + +// toIterable is required on Edge for cross-window origin objects. +function toIterable(value) { + if (typeof Symbol !== 'undefined' && typeof value[Symbol.iterator] !== 'undefined') { + return value; + } + + if (value !== null && typeof value === 'object') { + const length = value.length; + if (typeof length === 'number' && Number.isFinite(length)) { + const array = []; + for (let i = 0; i < length; ++i) { + array.push(value[i]); + } + return array; + } + } + + throw new Error('Could not convert to iterable'); +} + + +/* + * Async utilities + */ + function promiseTimeout(delay, resolveValue) { if (delay <= 0) { return Promise.resolve(resolveValue); @@ -133,3 +160,18 @@ function promiseTimeout(delay, resolveValue) { return promise; } + +function stringReplaceAsync(str, regex, replacer) { + let match; + let index = 0; + const parts = []; + while ((match = regex.exec(str)) !== null) { + parts.push(str.substring(index, match.index), replacer(...match, match.index, str)); + index = regex.lastIndex; + } + if (parts.length === 0) { + return Promise.resolve(str); + } + parts.push(str.substring(index)); + return Promise.all(parts).then((v) => v.join('')); +} diff --git a/ext/mixed/js/display-context.js b/ext/mixed/js/display-context.js new file mode 100644 index 00000000..4b399881 --- /dev/null +++ b/ext/mixed/js/display-context.js @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +class DisplayContext { + constructor(type, definitions, context) { + this.type = type; + this.definitions = definitions; + this.context = context; + } + + get(key) { + return this.context[key]; + } + + set(key, value) { + this.context[key] = value; + } + + update(data) { + Object.assign(this.context, data); + } + + get previous() { + return this.context.previous; + } + + get next() { + return this.context.next; + } + + static push(self, type, definitions, context) { + const newContext = new DisplayContext(type, definitions, context); + if (self !== null) { + newContext.update({previous: self}); + self.update({next: newContext}); + } + return newContext; + } +} diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 6d992897..c32852ad 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -42,7 +42,7 @@ class Display { this.setInteractive(true); } - onError(error) { + onError(_error) { throw new Error('Override me'); } @@ -55,93 +55,117 @@ class Display { this.sourceTermView(); } + onNextTermView(e) { + e.preventDefault(); + this.nextTermView(); + } + async onKanjiLookup(e) { try { e.preventDefault(); + if (!this.context) { return; } const link = e.target; - this.windowScroll.toY(0); + this.context.update({ + index: this.entryIndexFind(link), + scroll: this.windowScroll.y + }); const context = { - source: { - definitions: this.definitions, - index: this.entryIndexFind(link), - scroll: this.windowScroll.y - } + sentence: this.context.get('sentence'), + url: this.context.get('url') }; - if (this.context) { - context.sentence = this.context.sentence; - context.url = this.context.url; - context.source.source = this.context.source; - } - const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext()); this.setContentKanji(definitions, context); - } catch (e) { - this.onError(e); + } catch (error) { + this.onError(error); } } onGlossaryMouseDown(e) { - if (Frontend.isMouseButton('primary', e)) { + if (DOM.isMouseButtonPressed(e, 'primary')) { this.clickScanPrevent = false; } } - onGlossaryMouseMove(e) { + onGlossaryMouseMove() { this.clickScanPrevent = true; } onGlossaryMouseUp(e) { - if (!this.clickScanPrevent && Frontend.isMouseButton('primary', e)) { + if (!this.clickScanPrevent && DOM.isMouseButtonPressed(e, 'primary')) { this.onTermLookup(e); } } - async onTermLookup(e) { + async onTermLookup(e, {disableScroll, selectText, disableHistory}={}) { + try { + if (!this.context) { return; } + + const termLookupResults = await this.termLookup(e); + if (!termLookupResults) { return; } + const {textSource, definitions} = termLookupResults; + + const scannedElement = e.target; + const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt); + + this.context.update({ + index: this.entryIndexFind(scannedElement), + scroll: this.windowScroll.y + }); + const context = { + disableScroll, + disableHistory, + sentence, + url: this.context.get('url') + }; + if (disableHistory) { + Object.assign(context, { + previous: this.context.previous, + next: this.context.next + }); + } else { + Object.assign(context, { + previous: this.context + }); + } + + this.setContentTerms(definitions, context); + + if (selectText) { + textSource.select(); + } + } catch (error) { + this.onError(error); + } + } + + async termLookup(e) { try { e.preventDefault(); - const clickedElement = e.target; const textSource = docRangeFromPoint(e.clientX, e.clientY, this.options); if (textSource === null) { return false; } - let definitions, length, sentence; + let definitions, length; try { textSource.setEndOffset(this.options.scanning.length); - ({definitions, length} = await apiTermsFind(textSource.text(), this.getOptionsContext())); + ({definitions, length} = await apiTermsFind(textSource.text(), {}, this.getOptionsContext())); if (definitions.length === 0) { return false; } textSource.setEndOffset(length); - - sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt); } finally { textSource.cleanup(); } - this.windowScroll.toY(0); - const context = { - source: { - definitions: this.definitions, - index: this.entryIndexFind(clickedElement), - scroll: this.windowScroll.y - } - }; - - if (this.context) { - context.sentence = sentence; - context.url = this.context.url; - context.source.source = this.context.source; - } - - this.setContentTerms(definitions, context); - } catch (e) { - this.onError(e); + return {textSource, definitions}; + } catch (error) { + this.onError(error); } } @@ -170,7 +194,7 @@ class Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); const handlers = Display.onKeyDownHandlers; - if (handlers.hasOwnProperty(key)) { + if (hasOwn(handlers, key)) { const handler = handlers[key]; if (handler(this, e)) { e.preventDefault(); @@ -182,9 +206,17 @@ class Display { onWheel(e) { if (e.altKey) { - const delta = e.deltaY; - if (delta !== 0) { - this.entryScrollIntoView(this.index + (delta > 0 ? 1 : -1), null, true); + if (e.deltaY !== 0) { + this.entryScrollIntoView(this.index + (e.deltaY > 0 ? 1 : -1), null, true); + e.preventDefault(); + } + } else if (e.shiftKey) { + const delta = -e.deltaX || e.deltaY; + if (delta > 0) { + this.sourceTermView(); + e.preventDefault(); + } else if (delta < 0) { + this.nextTermView(); e.preventDefault(); } } @@ -192,7 +224,7 @@ class Display { onRuntimeMessage({action, params}, sender, callback) { const handlers = Display.runtimeMessageHandlers; - if (handlers.hasOwnProperty(action)) { + if (hasOwn(handlers, action)) { const handler = handlers[action]; const result = handler(this, params); callback(result); @@ -268,6 +300,7 @@ class Display { this.addEventListeners('.action-play-audio', 'click', this.onAudioPlay.bind(this)); this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this)); this.addEventListeners('.source-term', 'click', this.onSourceTermView.bind(this)); + this.addEventListeners('.next-term', 'click', this.onNextTermView.bind(this)); if (this.options.scanning.enablePopupSearch) { this.addEventListeners('.glossary-item', 'mouseup', this.onGlossaryMouseUp.bind(this)); this.addEventListeners('.glossary-item', 'mousedown', this.onGlossaryMouseDown.bind(this)); @@ -279,9 +312,9 @@ class Display { } addEventListeners(selector, type, listener, options) { - this.container.querySelectorAll(selector).forEach((node) => { + for (const node of this.container.querySelectorAll(selector)) { Display.addEventListener(this.eventListeners, node, type, listener, options); - }); + } } setContent(type, details) { @@ -298,6 +331,7 @@ class Display { } async setContentTerms(definitions, context) { + if (!context) { throw new Error('Context expected'); } if (!this.isInitialized()) { return; } try { @@ -305,17 +339,23 @@ class Display { this.setEventListenersActive(false); - if (!context || context.focus !== false) { + if (context.focus !== false) { window.focus(); } this.definitions = definitions; - this.context = context; + if (context.disableHistory) { + delete context.disableHistory; + this.context = new DisplayContext('terms', definitions, context); + } else { + this.context = DisplayContext.push(this.context, 'terms', definitions, context); + } const sequence = ++this.sequence; const params = { definitions, - source: context && context.source, + source: this.context.previous, + next: this.context.next, addable: options.anki.enable, grouped: options.general.resultOutputMode === 'group', merged: options.general.resultOutputMode === 'merge', @@ -324,20 +364,20 @@ class Display { debug: options.general.debugInfo }; - if (context) { - for (const definition of definitions) { - if (context.sentence) { - definition.cloze = Display.clozeBuild(context.sentence, definition.source); - } - - definition.url = context.url; - } + for (const definition of definitions) { + definition.cloze = Display.clozeBuild(context.sentence, definition.source); + definition.url = context.url; } const content = await apiTemplateRender('terms.html', params); this.container.innerHTML = content; - const {index, scroll} = context || {}; - this.entryScrollIntoView(index || 0, scroll); + const {index, scroll, disableScroll} = context; + if (!disableScroll) { + this.entryScrollIntoView(index || 0, scroll); + } else { + delete context.disableScroll; + this.entrySetCurrent(index || 0); + } if (options.audio.enabled && options.audio.autoPlay) { this.autoPlayAudio(); @@ -352,6 +392,7 @@ class Display { } async setContentKanji(definitions, context) { + if (!context) { throw new Error('Context expected'); } if (!this.isInitialized()) { return; } try { @@ -359,34 +400,35 @@ class Display { this.setEventListenersActive(false); - if (!context || context.focus !== false) { + if (context.focus !== false) { window.focus(); } this.definitions = definitions; - this.context = context; + if (context.disableHistory) { + delete context.disableHistory; + this.context = new DisplayContext('kanji', definitions, context); + } else { + this.context = DisplayContext.push(this.context, 'kanji', definitions, context); + } const sequence = ++this.sequence; const params = { definitions, - source: context && context.source, + source: this.context.previous, + next: this.context.next, addable: options.anki.enable, debug: options.general.debugInfo }; - if (context) { - for (const definition of definitions) { - if (context.sentence) { - definition.cloze = Display.clozeBuild(context.sentence); - } - - definition.url = context.url; - } + for (const definition of definitions) { + definition.cloze = Display.clozeBuild(context.sentence, definition.character); + definition.url = context.url; } const content = await apiTemplateRender('kanji.html', params); this.container.innerHTML = content; - const {index, scroll} = context || {}; + const {index, scroll} = context; this.entryScrollIntoView(index || 0, scroll); this.setEventListenersActive(true); @@ -446,7 +488,7 @@ class Display { } } - entryScrollIntoView(index, scroll, smooth) { + entrySetCurrent(index) { index = Math.min(index, this.definitions.length - 1); index = Math.max(index, 0); @@ -460,13 +502,20 @@ class Display { entry.classList.add('entry-current'); } + this.index = index; + + return entry; + } + + entryScrollIntoView(index, scroll, smooth) { this.windowScroll.stop(); - let target; - if (scroll) { + const entry = this.entrySetCurrent(index); + let target; + if (scroll !== null) { target = scroll; } else { - target = index === 0 || entry === null ? 0 : Display.getElementTop(entry); + target = this.index === 0 || entry === null ? 0 : Display.getElementTop(entry); } if (smooth) { @@ -474,22 +523,36 @@ class Display { } else { this.windowScroll.toY(target); } - - this.index = index; } sourceTermView() { - if (this.context && this.context.source) { - const context = { - url: this.context.source.url, - sentence: this.context.source.sentence, - index: this.context.source.index, - scroll: this.context.source.scroll, - source: this.context.source.source - }; + if (!this.context || !this.context.previous) { return; } + this.context.update({ + index: this.index, + scroll: this.windowScroll.y + }); + const previousContext = this.context.previous; + previousContext.set('disableHistory', true); + const details = { + definitions: previousContext.definitions, + context: previousContext.context + }; + this.setContent(previousContext.type, details); + } - this.setContentTerms(this.context.source.definitions, context); - } + nextTermView() { + if (!this.context || !this.context.next) { return; } + this.context.update({ + index: this.index, + scroll: this.windowScroll.y + }); + const nextContext = this.context.next; + nextContext.set('disableHistory', true); + const details = { + definitions: nextContext.definitions, + context: nextContext.context + }; + this.setContent(nextContext.type, details); } noteTryAdd(mode) { @@ -564,7 +627,7 @@ class Display { if (button !== null) { let titleDefault = button.dataset.titleDefault; if (!titleDefault) { - titleDefault = button.title || ""; + titleDefault = button.title || ''; button.dataset.titleDefault = titleDefault; } button.title = `${titleDefault}\n${info}`; @@ -623,18 +686,13 @@ class Display { return index >= 0 && index < entries.length ? entries[index] : null; } - static clozeBuild(sentence, source) { - const result = { - sentence: sentence.text.trim() + static clozeBuild({text, offset}, source) { + return { + sentence: text.trim(), + prefix: text.substring(0, offset).trim(), + body: text.substring(offset, offset + source.length), + suffix: text.substring(offset + source.length).trim() }; - - if (source) { - result.prefix = sentence.text.substring(0, sentence.offset).trim(); - result.body = source.trim(); - result.suffix = sentence.text.substring(sentence.offset + source.length).trim(); - } - - return result; } entryIndexFind(element) { @@ -765,6 +823,14 @@ Display.onKeyDownHandlers = { return false; }, + 'F': (self, e) => { + if (e.altKey) { + self.nextTermView(); + return true; + } + return false; + }, + 'E': (self, e) => { if (e.altKey) { self.noteTryAdd('term-kanji'); diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js new file mode 100644 index 00000000..4e4d49e3 --- /dev/null +++ b/ext/mixed/js/dom.js @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2019 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +class DOM { + static isPointInRect(x, y, rect) { + return ( + x >= rect.left && x < rect.right && + y >= rect.top && y < rect.bottom + ); + } + + static isPointInAnyRect(x, y, rects) { + for (const rect of rects) { + if (DOM.isPointInRect(x, y, rect)) { + return true; + } + } + return false; + } + + static isPointInSelection(x, y, selection) { + for (let i = 0; i < selection.rangeCount; ++i) { + const range = selection.getRangeAt(i); + if (DOM.isPointInAnyRect(x, y, range.getClientRects())) { + return true; + } + } + return false; + } + + static isMouseButtonPressed(mouseEvent, button) { + const mouseEventButton = mouseEvent.button; + switch (button) { + case 'primary': return mouseEventButton === 0; + case 'secondary': return mouseEventButton === 2; + case 'auxiliary': return mouseEventButton === 1; + default: return false; + } + } + + static isMouseButtonDown(mouseEvent, button) { + const mouseEventButtons = mouseEvent.buttons; + switch (button) { + case 'primary': return (mouseEventButtons & 0x1) !== 0x0; + case 'secondary': return (mouseEventButtons & 0x2) !== 0x0; + case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0; + default: return false; + } + } +} diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js index 9f401da7..8b841b2e 100644 --- a/ext/mixed/js/japanese.js +++ b/ext/mixed/js/japanese.js @@ -26,6 +26,15 @@ function jpIsKana(c) { return wanakana.isKana(c); } +function jpIsJapaneseText(text) { + for (const c of text) { + if (jpIsKanji(c) || jpIsKana(c)) { + return true; + } + } + return false; +} + function jpKatakanaToHiragana(text) { let result = ''; for (const c of text) { @@ -39,36 +48,84 @@ function jpKatakanaToHiragana(text) { return result; } +function jpHiraganaToKatakana(text) { + let result = ''; + for (const c of text) { + if (wanakana.isHiragana(c)) { + result += wanakana.toKatakana(c); + } else { + result += c; + } + } + + return result; +} + +function jpToRomaji(text) { + return wanakana.toRomaji(text); +} + +function jpConvertReading(expressionFragment, readingFragment, readingMode) { + switch (readingMode) { + case 'hiragana': + return jpKatakanaToHiragana(readingFragment || ''); + case 'katakana': + return jpHiraganaToKatakana(readingFragment || ''); + case 'romaji': + if (readingFragment) { + return jpToRomaji(readingFragment); + } else { + if (jpIsKana(expressionFragment)) { + return jpToRomaji(expressionFragment); + } + } + return readingFragment; + default: + return readingFragment; + } +} + function jpDistributeFurigana(expression, reading) { const fallback = [{furigana: reading, text: expression}]; if (!reading) { return fallback; } + let isAmbiguous = false; const segmentize = (reading, groups) => { - if (groups.length === 0) { + if (groups.length === 0 || isAmbiguous) { return []; } const group = groups[0]; if (group.mode === 'kana') { - if (reading.startsWith(group.text)) { - const readingUsed = reading.substring(0, group.text.length); + if (jpKatakanaToHiragana(reading).startsWith(jpKatakanaToHiragana(group.text))) { const readingLeft = reading.substring(group.text.length); const segs = segmentize(readingLeft, groups.splice(1)); if (segs) { - return [{text: readingUsed}].concat(segs); + return [{text: group.text}].concat(segs); } } } else { + let foundSegments = null; for (let i = reading.length; i >= group.text.length; --i) { const readingUsed = reading.substring(0, i); const readingLeft = reading.substring(i); const segs = segmentize(readingLeft, groups.slice(1)); if (segs) { - return [{text: group.text, furigana: readingUsed}].concat(segs); + if (foundSegments !== null) { + // more than one way to segmentize the tail, mark as ambiguous + isAmbiguous = true; + return null; + } + foundSegments = [{text: group.text, furigana: readingUsed}].concat(segs); + } + // there is only one way to segmentize the last non-kana group + if (groups.length === 1) { + break; } } + return foundSegments; } }; @@ -84,5 +141,36 @@ function jpDistributeFurigana(expression, reading) { } } - return segmentize(reading, groups) || fallback; + const segments = segmentize(reading, groups); + if (segments && !isAmbiguous) { + return segments; + } + return fallback; +} + +function jpDistributeFuriganaInflected(expression, reading, source) { + const output = []; + + let stemLength = 0; + const shortest = Math.min(source.length, expression.length); + const sourceHiragana = jpKatakanaToHiragana(source); + const expressionHiragana = jpKatakanaToHiragana(expression); + while (stemLength < shortest && sourceHiragana[stemLength] === expressionHiragana[stemLength]) { + ++stemLength; + } + const offset = source.length - stemLength; + + const stemExpression = source.slice(0, source.length - offset); + const stemReading = reading.slice( + 0, offset === 0 ? reading.length : reading.length - expression.length + stemLength + ); + for (const segment of jpDistributeFurigana(stemExpression, stemReading)) { + output.push(segment); + } + + if (stemLength !== source.length) { + output.push({text: source.slice(stemLength)}); + } + + return output; } diff --git a/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.css b/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.css deleted file mode 100644 index 0d42ed09..00000000 --- a/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.css +++ /dev/null @@ -1,28 +0,0 @@ -/*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 - * http://www.bootstraptoggle.com - * ======================================================================== - * Copyright 2014 Min Hur, The New York Times Company - * Licensed under MIT - * ======================================================================== */ -.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px} -.toggle{position:relative;overflow:hidden} -.toggle input[type=checkbox]{display:none} -.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none} -.toggle.off .toggle-group{left:-100%} -.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0} -.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0} -.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px} -.toggle.btn{min-width:59px;min-height:34px} -.toggle-on.btn{padding-right:24px} -.toggle-off.btn{padding-left:24px} -.toggle.btn-lg{min-width:79px;min-height:45px} -.toggle-on.btn-lg{padding-right:31px} -.toggle-off.btn-lg{padding-left:31px} -.toggle-handle.btn-lg{width:40px} -.toggle.btn-sm{min-width:50px;min-height:30px} -.toggle-on.btn-sm{padding-right:20px} -.toggle-off.btn-sm{padding-left:20px} -.toggle.btn-xs{min-width:35px;min-height:22px} -.toggle-on.btn-xs{padding-right:12px} -.toggle-off.btn-xs{padding-left:12px}
\ No newline at end of file diff --git a/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.js b/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.js deleted file mode 100644 index 37113200..00000000 --- a/ext/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! ======================================================================== - * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 - * http://www.bootstraptoggle.com - * ======================================================================== - * Copyright 2014 Min Hur, The New York Times Company - * Licensed under MIT - * ======================================================================== */ -+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.outerWidth(),d.outerWidth())+e.outerWidth()/2,i=this.options.height||Math.max(c.outerHeight(),d.outerHeight());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery); -//# sourceMappingURL=bootstrap-toggle.min.js.map
\ No newline at end of file diff --git a/ext/mixed/lib/dexie.min.js b/ext/mixed/lib/dexie.min.js deleted file mode 100644 index 81676ce2..00000000 --- a/ext/mixed/lib/dexie.min.js +++ /dev/null @@ -1,3 +0,0 @@ -!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Dexie=t()}(this,function(){"use strict";function n(n,t){return"object"!=typeof t?n:(Cn(t).forEach(function(e){n[e]=t[e]}),n)}function t(n,t){return Fn.call(n,t)}function e(n,t){"function"==typeof t&&(t=t(Bn(n))),Cn(t).forEach(function(e){r(n,e,t[e])})}function r(e,r,i,o){Mn(e,r,n(i&&t(i,"get")&&"function"==typeof i.get?{get:i.get,set:i.set,configurable:!0}:{value:i,configurable:!0,writable:!0},o))}function i(n){return{from:function(t){return n.prototype=Object.create(t.prototype),r(n.prototype,"constructor",n),{extend:e.bind(null,n.prototype)}}}}function o(n,t){var e,r=Nn(n,t);return r||(e=Bn(n))&&o(e,t)}function u(n,t,e){return qn.call(n,t,e)}function a(n,t){return t(n)}function c(n){var t=setTimeout(n,1e3);clearTimeout(t)}function s(n){if(!n)throw new Error("Assertion Failed")}function f(n){Kn.setImmediate?setImmediate(n):setTimeout(n,0)}function l(n,t){return n.reduce(function(n,e,r){var i=t(e,r);return i&&(n[i[0]]=i[1]),n},{})}function h(n,t){return function(){try{n.apply(this,arguments)}catch(n){t(n)}}}function d(n,t,e){try{n.apply(null,e)}catch(n){t&&t(n)}}function v(n,e){if(t(n,e))return n[e];if(!e)return n;if("string"!=typeof e){for(var r=[],i=0,o=e.length;i<o;++i){var u=v(n,e[i]);r.push(u)}return r}var a=e.indexOf(".");if(a!==-1){var c=n[e.substr(0,a)];return void 0===c?void 0:v(c,e.substr(a+1))}}function p(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){s("string"!=typeof e&&"length"in e);for(var r=0,i=t.length;r<i;++r)p(n,t[r],e[r])}else{var o=t.indexOf(".");if(o!==-1){var u=t.substr(0,o),a=t.substr(o+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var c=n[u];c||(c=n[u]={}),p(c,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function y(n,t){"string"==typeof t?p(n,t,void 0):"length"in t&&[].map.call(t,function(t){p(n,t,void 0)})}function m(n){var e={};for(var r in n)t(n,r)&&(e[r]=n[r]);return e}function g(n){return Rn.apply([],n)}function b(n){if(!n||"object"!=typeof n)return n;var e;if(Tn(n)){e=[];for(var r=0,i=n.length;r<i;++r)e.push(b(n[r]))}else if(Un.indexOf(n.constructor)>=0)e=n;else{e=n.constructor?Object.create(n.constructor.prototype):{};for(var o in n)t(n,o)&&(e[o]=b(n[o]))}return e}function w(n,e,r,i){return r=r||{},i=i||"",Cn(n).forEach(function(o){if(t(e,o)){var u=n[o],a=e[o];"object"==typeof u&&"object"==typeof a&&u&&a&&u.constructor===a.constructor?w(u,a,r,i+o+"."):u!==a&&(r[i+o]=e[o])}else r[i+o]=void 0}),Cn(e).forEach(function(o){t(n,o)||(r[i+o]=e[o])}),r}function _(n){var t,e,r,i;if(1===arguments.length){if(Tn(n))return n.slice();if(this===Ln&&"string"==typeof n)return[n];if(i=zn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);return e}if(null==n)return[n];if(t=n.length,"number"==typeof t){for(e=new Array(t);t--;)e[t]=n[t];return e}return[n]}for(t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return e}function k(n,t){Wn=n,Qn=t}function x(){if(Hn)try{throw x.arguments,new Error}catch(n){return n}return new Error}function j(n,t){var e=n.stack;return e?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(Qn).map(function(n){return"\n"+n}).join("")):""}function E(n,t){return function(){return console.warn(n+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+j(x(),1)),t.apply(this,arguments)}}function P(n,t){this._e=x(),this.name=n,this.message=t}function A(n,t){return n+". Errors: "+t.map(function(n){return n.toString()}).filter(function(n,t,e){return e.indexOf(n)===t}).join("\n")}function O(n,t,e,r){this._e=x(),this.failures=t,this.failedKeys=r,this.successCount=e}function S(n,t){this._e=x(),this.name="BulkError",this.failures=t,this.message=A(n,t)}function I(n,t){if(!n||n instanceof P||n instanceof TypeError||n instanceof SyntaxError||!n.name||!tt[n.name])return n;var e=new tt[n.name](t||n.message,n);return"stack"in n&&r(e,"stack",{get:function(){return this.inner.stack}}),e}function D(){}function C(n){return n}function T(n,t){return null==n||n===C?t:function(e){return t(n(e))}}function K(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function B(n,t){return n===D?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?K(r,this.onsuccess):r),i&&(this.onerror=this.onerror?K(i,this.onerror):i),void 0!==o?o:e}}function F(n,t){return n===D?t:function(){n.apply(this,arguments);var e=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?K(e,this.onsuccess):e),r&&(this.onerror=this.onerror?K(r,this.onerror):r)}}function M(t,e){return t===D?e:function(r){var i=t.apply(this,arguments);n(r,i);var o=this.onsuccess,u=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?K(o,this.onsuccess):o),u&&(this.onerror=this.onerror?K(u,this.onerror):u),void 0===i?void 0===a?void 0:a:n(i,a)}}function N(n,t){return n===D?t:function(){return t.apply(this,arguments)!==!1&&n.apply(this,arguments)}}function q(n,t){return n===D?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function R(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=D,this._lib=!1;var t=this._PSD=Et;if(Wn&&(this._stackHolder=x(),this._prev=null,this._numPrev=0),"function"!=typeof n){if(n!==rt)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&z(this,this._value))}this._state=null,this._value=null,++t.ref,V(this,n)}function U(n,t,e,r,i){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r,this.psd=i}function V(n,t){try{t(function(t){if(null===n._state){if(t===n)throw new TypeError("A promise cannot be resolved with itself.");var e=n._lib&&Y();t&&"function"==typeof t.then?V(n,function(n,e){t instanceof R?t._then(n,e):t.then(n,e)}):(n._state=!0,n._value=t,L(n)),e&&$()}},z.bind(null,n))}catch(t){z(n,t)}}function z(n,t){if(_t.push(t),null===n._state){var e=n._lib&&Y();t=xt(t),n._state=!1,n._value=t,Wn&&null!==t&&"object"==typeof t&&!t._promise&&d(function(){var e=o(t,"stack");t._promise=n,r(t,"stack",{get:function(){return pt?e&&(e.get?e.get.apply(t):e.value):n.stack}})}),nn(n),L(n),e&&$()}}function L(n){var t=n._listeners;n._listeners=[];for(var e=0,r=t.length;e<r;++e)W(n,t[e]);var i=n._PSD;--i.ref||i.finalize(),0===At&&(++At,mt(function(){0===--At&&X()},[]))}function W(n,t){if(null===n._state)return void n._listeners.push(t);var e=n._state?t.onFulfilled:t.onRejected;return null===e?(n._state?t.resolve:t.reject)(n._value):(++t.psd.ref,++At,void mt(Q,[e,n,t]))}function Q(n,t,e){try{kt=t;var r,i=t._value;t._state?r=n(i):(_t.length&&(_t=[]),r=n(i),_t.indexOf(i)===-1&&tn(t)),e.resolve(r)}catch(n){e.reject(n)}finally{kt=null,0===--At&&X(),--e.psd.ref||e.psd.finalize()}}function H(n,t,e){if(t.length===e)return t;var r="";if(n._state===!1){var i,o,u=n._value;null!=u?(i=u.name||"Error",o=u.message||u,r=j(u,0)):(i=u,o=""),t.push(i+(o?": "+o:"")+r)}return Wn&&(r=j(n._stackHolder,2),r&&t.indexOf(r)===-1&&t.push(r),n._prev&&H(n._prev,t,e)),t}function G(n,t){var e=t?t._numPrev+1:0;e<it&&(n._prev=t,n._numPrev=e)}function J(){Y()&&$()}function Y(){var n=gt;return gt=!1,bt=!1,n}function $(){var n,t,e;do for(;Pt.length>0;)for(n=Pt,Pt=[],e=n.length,t=0;t<e;++t){var r=n[t];r[0].apply(null,r[1])}while(Pt.length>0);gt=!0,bt=!0}function X(){var n=wt;wt=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var t=Ot.slice(0),e=t.length;e;)t[--e]()}function Z(n){function t(){n(),Ot.splice(Ot.indexOf(t),1)}Ot.push(t),++At,mt(function(){0===--At&&X()},[])}function nn(n){wt.some(function(t){return t._value===n._value})||wt.push(n)}function tn(n){for(var t=wt.length;t;)if(wt[--t]._value===n._value)return void wt.splice(t,1)}function en(n){return new R(rt,!1,n)}function rn(n,t){var e=Et;return function(){var r=Y(),i=Et;try{return ln(e,!0),n.apply(this,arguments)}catch(n){t&&t(n)}finally{ln(i,!1),r&&$()}}}function on(t,e,r,i){var o=Et,u=Object.create(o);u.parent=o,u.ref=0,u.global=!1,u.id=++Bt;var a=jt.env;u.env=vt?{Promise:R,all:R.all,race:R.race,resolve:R.resolve,reject:R.reject,nthen:yn(a.nthen,u),gthen:yn(a.gthen,u)}:{},e&&n(u,e),++o.ref,u.finalize=function(){--this.parent.ref||this.parent.finalize()};var c=dn(u,t,r,i);return 0===u.ref&&u.finalize(),c}function un(){return It.id||(It.id=++Dt),++It.awaits,It.echoes+=ut,It.id}function an(n){!It.awaits||n&&n!==It.id||(0===--It.awaits&&(It.id=0),It.echoes=It.awaits*ut)}function cn(n){return It.echoes&&n&&n.constructor===ht?(un(),n.then(function(n){return an(),n},function(n){return an(),Nt(n)})):n}function sn(n){++Kt,It.echoes&&0!==--It.echoes||(It.echoes=It.id=0),Ct.push(Et),ln(n,!0)}function fn(){var n=Ct[Ct.length-1];Ct.pop(),ln(n,!1)}function ln(n,t){var e=Et;if((t?!It.echoes||Tt++&&n===Et:!Tt||--Tt&&n===Et)||vn(t?sn.bind(null,n):fn),n!==Et&&(Et=n,e===jt&&(jt.env=hn()),vt)){var r=jt.env.Promise,i=n.env;st.then=i.nthen,r.prototype.then=i.gthen,(e.global||n.global)&&(Kn.Promise=i.Promise,r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject)}}function hn(){var n=Kn.Promise;return vt?{Promise:n,all:n.all,race:n.race,resolve:n.resolve,reject:n.reject,nthen:st.then,gthen:n.prototype.then}:{}}function dn(n,t,e,r,i){var o=Et;try{return ln(n,!0),t(e,r,i)}finally{ln(o,!1)}}function vn(n){lt.call(ct,n)}function pn(n,t,e){return"function"!=typeof n?n:function(){var r=Et;e&&un(),ln(t,!0);try{return n.apply(this,arguments)}finally{ln(r,!1)}}}function yn(n,t){return function(e,r){return n.call(this,pn(e,t,!1),pn(r,t,!1))}}function mn(t,e){var r;try{r=e.onuncatched(t)}catch(n){}if(r!==!1)try{var i,o={promise:e,reason:t};if(Kn.document&&document.createEvent?(i=document.createEvent("Event"),i.initEvent(Ft,!0,!0),n(i,o)):Kn.CustomEvent&&(i=new CustomEvent(Ft,{detail:o}),n(i,o)),i&&Kn.dispatchEvent&&(dispatchEvent(i),!Kn.PromiseRejectionEvent&&Kn.onunhandledrejection))try{Kn.onunhandledrejection(i)}catch(n){}i.defaultPrevented||console.warn("Unhandled rejection: "+(t.stack||t))}catch(n){}}function gn(n){function t(n,t,o){if("object"==typeof n)return e(n);t||(t=N),o||(o=D);var u={subscribers:[],fire:o,subscribe:function(n){u.subscribers.indexOf(n)===-1&&(u.subscribers.push(n),u.fire=t(u.fire,n))},unsubscribe:function(n){u.subscribers=u.subscribers.filter(function(t){return t!==n}),u.fire=u.subscribers.reduce(t,o)}};return r[n]=i[n]=u,u}function e(n){Cn(n).forEach(function(e){var r=n[e];if(Tn(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new nt.InvalidArgument("Invalid event config");var i=t(e,C,function(){for(var n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];i.subscribers.forEach(function(n){f(function(){n.apply(null,t)})})})}})}var r={},i=function(t,e){if(e){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return r[t].subscribe.apply(null,o),n}if("string"==typeof t)return r[t]};i.addEventType=t;for(var o=1,u=arguments.length;o<u;++o)t(arguments[o]);return i}function bn(i,o){function f(){et.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+et.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+et.name+"'. Closing db now to resume the delete request."),et.close()}),et.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+et.name+"') was blocked"):console.warn("Upgrade '"+et.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function y(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function k(n,t,e){var r=et._createTransaction(tt,Qn,Vn);r.create(t),r._completion.catch(e);var i=r._reject.bind(r);on(function(){Et.trans=r,0===n?(Cn(Vn).forEach(function(n){A(t,n,Vn[n].primKey,Vn[n].indexes)}),R.follow(function(){return et.on.populate.fire(r)}).catch(i)):j(n,r,t).catch(i)})}function j(n,t,e){function r(){return i.length?R.resolve(i.shift()(t.idbtrans)).then(r):R.resolve()}var i=[],o=zn.filter(function(t){return t._cfg.version===n})[0];if(!o)throw new nt.Upgrade("Dexie specification of currently installed DB version is missing");Vn=et._dbSchema=o._cfg.dbschema;var u=!1,a=zn.filter(function(t){return t._cfg.version>n});return a.forEach(function(n){i.push(function(){var r=Vn,i=n._cfg.dbschema;yn(r,e),yn(i,e),Vn=et._dbSchema=i;var o=P(r,i);if(o.add.forEach(function(n){A(e,n[0],n[1].primKey,n[1].indexes)}),o.change.forEach(function(n){if(n.recreate)throw new nt.Upgrade("Not yet support for changing primary key");var t=e.objectStore(n.name);n.add.forEach(function(n){N(t,n)}),n.change.forEach(function(n){t.deleteIndex(n.name),N(t,n)}),n.del.forEach(function(n){t.deleteIndex(n)})}),n._cfg.contentUpgrade)return u=!0,R.follow(function(){n._cfg.contentUpgrade(t)})}),i.push(function(t){if(!u||!Ht){var e=n._cfg.dbschema;K(e,t)}})}),r().then(function(){I(Vn,e)})}function P(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var i=n[r],o=t[r];if(i){var u={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var a=i.idxByName,c=o.idxByName;for(var s in a)c[s]||u.del.push(s);for(s in c){var f=a[s],l=c[s];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function A(n,t,e,r){var i=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){N(i,n)}),i}function I(n,t){Cn(n).forEach(function(e){t.db.objectStoreNames.contains(e)||A(t,e,n[e].primKey,n[e].indexes)})}function K(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null==n[r]&&t.db.deleteObjectStore(r)}}function N(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function U(n,t,e){if(Xn||Et.letThrough){var r=et._createTransaction(n,t,Vn);try{r.create()}catch(n){return Nt(n)}return r._promise(n,function(n,t){return on(function(){return Et.trans=r,e(n,t,r)})}).then(function(n){return r._completion.then(function(){return n})})}if(!Yn){if(!qn)return Nt(new nt.DatabaseClosed);et.open().catch(D)}return rt.then(function(){return U(n,t,e)})}function V(n,t,e){var r=arguments.length;if(r<2)throw new nt.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];e=i.pop();var o=g(i);return[n,o,e]}function z(n,t,e){this.name=n,this.schema=t,this._tx=e,this.hook=Hn[n]?Hn[n].hook:gn(null,{creating:[B,D],reading:[T,C],updating:[M,D],deleting:[F,D]})}function L(n,t,e){return(e?En:xn)(function(e){n.push(e),t&&t()})}function W(n,t,e,r,i){return new R(function(o,u){var a=e.length,c=a-1;if(0===a)return o();if(r){var s,f=En(u),l=kn(null);d(function(){for(var r=0;r<a;++r){s={onsuccess:null,onerror:null};var u=e[r];i.call(s,u[0],u[1],t);var h=n.delete(u[0]);h._hookCtx=s,h.onerror=f,r===c?h.onsuccess=kn(o):h.onsuccess=l}},function(n){throw s.onerror&&s.onerror(n),n})}else for(var h=0;h<a;++h){var v=n.delete(e[h]);v.onerror=xn(u),h===c&&(v.onsuccess=rn(function(){return o()}))}})}function Q(n,t,e,r){var i=this;this.db=et,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=gn(this,"complete","error","abort"),this.parent=r||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new R(function(n,t){i._resolve=n,i._reject=t}),this._completion.then(function(){i.active=!1,i.on.complete.fire()},function(n){var t=i.active;return i.active=!1,i.on.error.fire(n),i.parent?i.parent._reject(n):t&&i.idbtrans&&i.idbtrans.abort(),Nt(n)})}function H(n,t,e){this._ctx={table:n,index:":id"===t?null:t,or:e}}function G(n,t){var e=null,r=null;if(t)try{e=t()}catch(n){r=n}var i=n._ctx,o=i.table;this._ctx={table:o,index:i.index,isPrimKey:!i.index||o.schema.primKey.keyPath&&i.index===o.schema.primKey.name,range:e,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:o.hook.reading.fire}}function J(n,t){return!(n.filter||n.algorithm||n.or)&&(t?n.justLimit:!n.replayFilter)}function Y(n,t){return n._cfg.version-t._cfg.version}function $(n,t,e){t.forEach(function(t){var i=e[t];n.forEach(function(n){t in n||(n===Q.prototype||n instanceof Q?r(n,t,{get:function(){return this.table(t)}}):n[t]=new z(t,i))})})}function X(n){n.forEach(function(n){for(var t in n)n[t]instanceof z&&delete n[t]})}function Z(n,t,e,r,i,o){var u=o?function(n,t,r){return e(o(n),t,r)}:e,a=rn(u,i);n.onerror||(n.onerror=xn(i)),t?n.onsuccess=h(function(){var e=n.result;if(e){var o=function(){e.continue()};t(e,function(n){o=n},r,i)&&a(e.value,e,function(n){o=n}),o()}else r()},i):n.onsuccess=h(function(){var t=n.result;if(t){var e=function(){t.continue()};a(t.value,t,function(n){e=n}),e()}else r()},i)}function nn(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(e)?e.match(/^\[(.*)\]$/)[1].split("+"):e;t.push(new On(e,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),Tn(r),/\./.test(n)))}),t}function tn(n,t){return Rn.cmp(n,t)}function en(n,t){return tn(n,t)<0?n:t}function cn(n,t){return tn(n,t)>0?n:t}function sn(n,t){return Rn.cmp(n,t)}function fn(n,t){return Rn.cmp(t,n)}function ln(n,t){return n<t?-1:n===t?0:1}function hn(n,t){return n>t?-1:n===t?0:1}function vn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function pn(){if(et.verno=Gn.version/10,et._dbSchema=Vn={},Qn=u(Gn.objectStoreNames,0),0!==Qn.length){var n=Gn.transaction(In(Qn),"readonly");Qn.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1,o=new On(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,i=r&&"string"==typeof r&&r.indexOf(".")!==-1;var s=new On(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,i);u.push(s)}Vn[t]=new Sn(t,o,u,{})}),$([Hn],Cn(Vn),Vn)}}function yn(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r){var i=e[r],o=t.objectStore(i);Bn="getAll"in o;for(var a=0;a<o.indexNames.length;++a){var c=o.indexNames[a],s=o.index(c).keyPath,f="string"==typeof s?s:"["+u(s).join("+")+"]";if(n[i]){var l=n[i].idxByName[f];l&&(l.name=c)}}}}function mn(n){et.on("blocked").fire(n),Wt.filter(function(n){return n.name===et.name&&n!==et&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var wn,Kn,Bn,Fn=bn.dependencies,Mn=n({addons:bn.addons,autoOpen:!0,indexedDB:Fn.indexedDB,IDBKeyRange:Fn.IDBKeyRange},o),Nn=Mn.addons,qn=Mn.autoOpen,Rn=Mn.indexedDB,Un=Mn.IDBKeyRange,Vn=this._dbSchema={},zn=[],Qn=[],Hn={},Gn=null,Jn=null,Yn=!1,$n=null,Xn=!1,Zn="readonly",tt="readwrite",et=this,rt=new R(function(n){wn=n}),it=new R(function(n,t){Kn=t}),ot=!0,ut=!!Dn(Rn);this.version=function(n){if(Gn||Yn)throw new nt.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=zn.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new y(n),zn.push(t),zn.sort(Y),ot=!1,t)},n(y.prototype,{stores:function(t){this._cfg.storesSource=this._cfg.storesSource?n(this._cfg.storesSource,t):t;var e={};zn.forEach(function(t){n(e,t._cfg.storesSource)});var r=this._cfg.dbschema={};return this._parseStoresSpec(e,r),Vn=et._dbSchema=r,X([Hn,et,Q.prototype]),$([Hn,et,Q.prototype,this._cfg.tables],Cn(r),r),Qn=Cn(r),this},upgrade:function(n){var t=this;return Yt(function(){n(et._createTransaction(tt,Cn(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){Cn(n).forEach(function(e){if(null!==n[e]){var r={},i=nn(n[e]),o=i.shift();if(o.multi)throw new nt.Schema("Primary key cannot be multi-valued");o.keyPath&&p(r,o.keyPath,o.auto?0:o.keyPath),i.forEach(function(n){if(n.auto)throw new nt.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new nt.Schema("Index must have a name and cannot be an empty string");p(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new Sn(e,o,i,r)}})}}),this._allTables=Hn,this._createTransaction=function(n,t,e,r){return new Q(n,t,e,r)},this._whenReady=function(n){return $t||Xn||Et.letThrough?n():new R(function(n,t){if(!Yn){if(!qn)return void t(new nt.DatabaseClosed);et.open().catch(D)}rt.then(n,t)}).then(n)},this.verno=0,this.open=function(){if(Yn||Gn)return rt.then(function(){return Jn?Nt(Jn):et});Wn&&(it._stackHolder=x()),Yn=!0,Jn=null,Xn=!1;var n=wn,t=null;return R.race([it,new R(function(n,e){if(c(function(){return n()}),!Rn)throw new nt.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var r=ot?Rn.open(i):Rn.open(i,Math.round(10*et.verno));if(!r)throw new nt.MissingAPI("IndexedDB API not available");r.onerror=xn(e),r.onblocked=rn(mn),r.onupgradeneeded=rn(function(n){if(t=r.transaction,ot&&!et._allowEmptyDB){r.onerror=Pn,t.abort(),r.result.close();var o=Rn.deleteDatabase(i);o.onsuccess=o.onerror=rn(function(){e(new nt.NoSuchDatabase("Database "+i+" doesnt exist"))})}else{t.onerror=xn(e);var u=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;k(u/10,t,e,r)}},e),r.onsuccess=rn(function(){if(t=null,Gn=r.result,Wt.push(et),ot)pn();else if(Gn.objectStoreNames.length>0)try{yn(Vn,Gn.transaction(In(Gn.objectStoreNames),Zn))}catch(n){}Gn.onversionchange=rn(function(n){et._vcFired=!0,et.on("versionchange").fire(n)}),ut||"__dbnames"===i||Mt.dbnames.put({name:i}).catch(D),n()},e)})]).then(function(){return $n=[],R.resolve(bn.vip(et.on.ready.fire)).then(function n(){if($n.length>0){var t=$n.reduce(q,D);return $n=[],R.resolve(bn.vip(t)).then(n)}})}).finally(function(){$n=null}).then(function(){return Yn=!1,et}).catch(function(n){try{t&&t.abort()}catch(n){}return Yn=!1,et.close(),Jn=n,Nt(Jn)}).finally(function(){Xn=!0,n()})},this.close=function(){var n=Wt.indexOf(et);if(n>=0&&Wt.splice(n,1),Gn){try{Gn.close()}catch(n){}Gn=null}qn=!1,Jn=new nt.DatabaseClosed,Yn&&Kn(Jn),rt=new R(function(n){wn=n}),it=new R(function(n,t){Kn=t})},this.delete=function(){var n=arguments.length>0;return new R(function(t,e){function r(){et.close();var n=Rn.deleteDatabase(i);n.onsuccess=rn(function(){ut||Mt.dbnames.delete(i).catch(D),t()}),n.onerror=xn(e),n.onblocked=mn}if(n)throw new nt.InvalidArgument("Arguments not allowed in db.delete()");Yn?rt.then(r):r()})},this.backendDB=function(){return Gn},this.isOpen=function(){return null!==Gn},this.hasBeenClosed=function(){return Jn&&Jn instanceof nt.DatabaseClosed},this.hasFailed=function(){return null!==Jn},this.dynamicallyOpened=function(){return ot},this.name=i,e(this,{tables:{get:function(){return Cn(Hn).map(function(n){return Hn[n]})}}}),this.on=gn(this,"populate","blocked","versionchange",{ready:[q,D]}),this.on.ready.subscribe=a(this.on.ready.subscribe,function(n){return function(t,e){bn.vip(function(){Xn?(Jn||R.resolve().then(t),e&&n(t)):$n?($n.push(t),e&&n(t)):(n(t),e||n(function n(){et.on.ready.unsubscribe(t),et.on.ready.unsubscribe(n)}))})}}),Yt(function(){et.on("populate").fire(et._createTransaction(tt,Qn,Vn))}),this.transaction=function(){var n=V.apply(this,arguments);return this._transaction.apply(this,n)},this._transaction=function(n,t,e){function r(){return R.resolve().then(function(){var t=Et.transless||Et,r=et._createTransaction(n,u,Vn,i),o={trans:r,transless:t};i?r.idbtrans=i.idbtrans:r.create(),e.constructor===dt&&un();var a,c=R.follow(function(){if(a=e.call(r,r))if(a.constructor===ht){var n=an.bind(null,null);a.then(n,n)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=An(a))},o);return(a&&"function"==typeof a.then?R.resolve(a).then(function(n){return r.active?n:Nt(new nt.PrematureCommit("Transaction committed too early. See http://bit.ly/2eVASrf"))}):c.then(function(){return a})).then(function(n){return i&&r._resolve(),r._completion.then(function(){return n})}).catch(function(n){return r._reject(n),Nt(n)})})}var i=Et.trans;i&&i.db===et&&n.indexOf("!")===-1||(i=null);var o=n.indexOf("?")!==-1;n=n.replace("!","").replace("?","");try{var u=t.map(function(n){var t=n instanceof z?n.name:n;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t});if("r"==n||n==Zn)n=Zn;else{if("rw"!=n&&n!=tt)throw new nt.InvalidArgument("Invalid transaction mode: "+n);n=tt}if(i){if(i.mode===Zn&&n===tt){if(!o)throw new nt.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&u.forEach(function(n){if(i&&i.storeNames.indexOf(n)===-1){if(!o)throw new nt.SubTransaction("Table "+n+" not included in parent transaction.");i=null}}),o&&i&&!i.active&&(i=null)}}catch(n){return i?i._promise(null,function(t,e){e(n)}):Nt(n)}return i?i._promise(n,r,"lock"):Et.trans?dn(Et.transless,function(){return et._whenReady(r)}):et._whenReady(r)},this.table=function(n){if($t&&ot)return new z(n);if(!t(Hn,n))throw new nt.InvalidTable("Table "+n+" does not exist");return Hn[n]},e(z.prototype,{_trans:function(n,t,e){var r=this._tx||Et.trans;return r&&r.db===et?r===Et.trans?r._promise(n,t,e):on(function(){return r._promise(n,t,e)},{trans:r,transless:Et.transless||Et}):U(n,[this.name],t)},_idbstore:function(n,t,e){function r(n,e,r){if(r.storeNames.indexOf(i)===-1)throw new nt.NotFound("Table"+i+" not part of transaction");return t(n,e,r.idbtrans.objectStore(i),r)}if($t)return new R(t);var i=this.name;return this._trans(n,r,e)},get:function(n,t){if(n&&n.constructor===Object)return this.where(n).first(t);var e=this;return this._idbstore(Zn,function(t,r,i){$t&&t(e.schema.instanceTemplate);var o=i.get(n);o.onerror=xn(r),o.onsuccess=rn(function(){t(e.hook.reading.fire(o.result))},r)}).then(t)},where:function(n){if("string"==typeof n)return new H(this,n);if(Tn(n))return new H(this,"["+n.join("+")+"]");var t=Cn(n);if(1===t.length)return this.where(t[0]).equals(n[t[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(n){return n.compound&&t.every(function(t){return n.keyPath.indexOf(t)>=0})&&n.keyPath.every(function(n){return t.indexOf(n)>=0})})[0];if(e&&Ut!==Rt)return this.where(e.name).equals(e.keyPath.map(function(t){return n[t]}));e||console.warn("The query "+JSON.stringify(n)+" on "+this.name+" would benefit of a "+("compound index ["+t.join("+")+"]"));var r=this.schema.idxByName,i=t.reduce(function(t,e){return[t[0]||r[e],t[0]||!r[e]?vn(t[1],function(t){return""+v(t,e)==""+n[e]}):t[1]]},[null,null]),o=i[0];return o?this.where(o.name).equals(n[o.keyPath]).filter(i[1]):e?this.filter(i[1]):this.where(t).equals("")},count:function(n){return this.toCollection().count(n)},offset:function(n){return this.toCollection().offset(n)},limit:function(n){return this.toCollection().limit(n)},reverse:function(){return this.toCollection().reverse()},filter:function(n){return this.toCollection().and(n)},each:function(n){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new G(new H(this,Tn(n)?"["+n.join("+")+"]":n))},toCollection:function(){return new G(new H(this))},mapToClass:function(n,e){this.schema.mappedClass=n;var r=Object.create(n.prototype);e&&_n(r,e),this.schema.instanceTemplate=r;var i=function(e){if(!e)return e;var r=Object.create(n.prototype);for(var i in e)if(t(e,i))try{r[i]=e[i]}catch(n){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),n},defineClass:function(n){return this.mapToClass(bn.defineClass(n),n)},bulkDelete:function(n){return this.hook.deleting.fire===D?this._idbstore(tt,function(t,e,r,i){t(W(r,i,n,!1,D))}):this.where(":id").anyOf(n).delete().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(tt,function(r,i,o){if(!o.keyPath&&!e.schema.primKey.auto&&!t)throw new nt.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(o.keyPath&&t)throw new nt.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new nt.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return r();var u,a,c=function(n){0===s.length?r(n):i(new S(e.name+".bulkPut(): "+s.length+" of "+f+" operations failed",s))},s=[],f=n.length,h=e;if(e.hook.creating.fire===D&&e.hook.updating.fire===D){a=L(s);for(var d=0,p=n.length;d<p;++d)u=t?o.put(n[d],t[d]):o.put(n[d]),u.onerror=a;u.onerror=L(s,c),u.onsuccess=jn(c)}else{var y=t||o.keyPath&&n.map(function(n){return v(n,o.keyPath)}),m=y&&l(y,function(t,e){return null!=t&&[t,n[e]]}),g=y?h.where(":id").anyOf(y.filter(function(n){return null!=n})).modify(function(){this.value=m[this.primKey],m[this.primKey]=null}).catch(O,function(n){s=n.failures}).then(function(){for(var e=[],r=t&&[],i=y.length-1;i>=0;--i){var o=y[i];(null==o||m[o])&&(e.push(n[i]),t&&r.push(o),null!=o&&(m[o]=null))}return e.reverse(),t&&r.reverse(),h.bulkAdd(e,r)}).then(function(n){var t=y[y.length-1];return null!=t?t:n}):h.bulkAdd(n);g.then(c).catch(S,function(n){s=s.concat(n.failures),c()}).catch(i)}},"locked")},bulkAdd:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(tt,function(i,o,u,a){function c(n){0===h.length?i(n):o(new S(e.name+".bulkAdd(): "+h.length+" of "+y+" operations failed",h))}if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new nt.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new nt.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new nt.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return i();var s,f,l,h=[],y=n.length;if(r!==D){var m,g=u.keyPath;f=L(h,null,!0),l=kn(null),d(function(){for(var e=0,i=n.length;e<i;++e){m={onerror:null,onsuccess:null};var o=t&&t[e],c=n[e],h=t?o:g?v(c,g):void 0,d=r.call(m,h,c,a);null==h&&null!=d&&(g?(c=b(c),p(c,g,d)):o=d),s=null!=o?u.add(c,o):u.add(c),s._hookCtx=m,e<i-1&&(s.onerror=f,m.onsuccess&&(s.onsuccess=l))}},function(n){throw m.onerror&&m.onerror(n),n}),s.onerror=L(h,c,!0),s.onsuccess=kn(c)}else{f=L(h);for(var w=0,_=n.length;w<_;++w)s=t?u.add(n[w],t[w]):u.add(n[w]),s.onerror=f;s.onerror=L(h,c),s.onsuccess=jn(c)}})},add:function(n,t){var e=this.hook.creating.fire;return this._idbstore(tt,function(r,i,o,u){var a={onsuccess:null,onerror:null};if(e!==D){var c=null!=t?t:o.keyPath?v(n,o.keyPath):void 0,s=e.call(a,c,n,u);null==c&&null!=s&&(o.keyPath?p(n,o.keyPath,s):t=s)}try{var f=null!=t?o.add(n,t):o.add(n);f._hookCtx=a,f.onerror=En(i),f.onsuccess=kn(function(t){var e=o.keyPath;e&&p(n,e,t),r(t)})}catch(n){throw a.onerror&&a.onerror(n),n}})},put:function(n,t){var e=this,r=this.hook.creating.fire,i=this.hook.updating.fire;if(r!==D||i!==D){var o=this.schema.primKey.keyPath,u=void 0!==t?t:o&&v(n,o);return null==u?this.add(n):(n=b(n),this._trans(tt,function(){return e.where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?e.add(n,t):u})},"locked"))}return this._idbstore(tt,function(e,r,i){var o=void 0!==t?i.put(n,t):i.put(n);o.onerror=xn(r),o.onsuccess=rn(function(t){var r=i.keyPath;r&&p(n,r,t.target.result),e(o.result)})})},delete:function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n).delete():this._idbstore(tt,function(t,e,r){ -var i=r.delete(n);i.onerror=xn(e),i.onsuccess=rn(function(){t(i.result)})})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(tt,function(n,t,e){var r=e.clear();r.onerror=xn(t),r.onsuccess=rn(function(){n(r.result)})})},update:function(n,t){if("object"!=typeof t||Tn(t))throw new nt.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||Tn(n))return this.where(":id").equals(n).modify(t);Cn(t).forEach(function(e){p(n,e,t[e])});var e=v(n,this.schema.primKey.keyPath);return void 0===e?Nt(new nt.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)}}),e(Q.prototype,{_lock:function(){return s(!Et.global),++this._reculock,1!==this._reculock||Et.global||(Et.lockOwnerFor=this),this},_unlock:function(){if(s(!Et.global),0===--this._reculock)for(Et.global||(Et.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{dn(n[1],n[0])}catch(n){}}return this},_locked:function(){return this._reculock&&Et.lockOwnerFor!==this},create:function(n){var t=this;if(!this.mode)return this;if(s(!this.idbtrans),!n&&!Gn)switch(Jn&&Jn.name){case"DatabaseClosedError":throw new nt.DatabaseClosed(Jn);case"MissingAPIError":throw new nt.MissingAPI(Jn.message,Jn);default:throw new nt.OpenFailed(Jn)}if(!this.active)throw new nt.TransactionInactive;return s(null===this._completion._state),n=this.idbtrans=n||Gn.transaction(In(this.storeNames),this.mode),n.onerror=rn(function(e){Pn(e),t._reject(n.error)}),n.onabort=rn(function(n){Pn(n),t.active&&t._reject(new nt.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=rn(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){var r=this;if(n===tt&&this.mode!==tt)return Nt(new nt.ReadOnly("Transaction is readonly"));if(!this.active)return Nt(new nt.TransactionInactive);if(this._locked())return new R(function(i,o){r._blockedFuncs.push([function(){r._promise(n,t,e).then(i,o)},Et])});if(e)return on(function(){var n=new R(function(n,e){r._lock();var i=t(n,e,r);i&&i.then&&i.then(n,e)});return n.finally(function(){return r._unlock()}),n._lib=!0,n});var i=new R(function(n,e){var i=t(n,e,r);i&&i.then&&i.then(n,e)});return i._lib=!0,i},_root:function(){return this.parent?this.parent._root():this},waitFor:function(n){var t=this._root();if(n=R.resolve(n),t._waitingFor)t._waitingFor=t._waitingFor.then(function(){return n});else{t._waitingFor=n,t._waitingQueue=[];var e=t.idbtrans.objectStore(t.storeNames[0]);!function n(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(e.get(-(1/0)).onsuccess=n)}()}var r=t._waitingFor;return new R(function(e,i){n.then(function(n){return t._waitingQueue.push(rn(e.bind(null,n)))},function(n){return t._waitingQueue.push(rn(i.bind(null,n)))}).finally(function(){t._waitingFor===r&&(t._waitingFor=null)})})},abort:function(){this.active&&this._reject(new nt.Abort),this.active=!1},tables:{get:E("Transaction.tables",function(){return Hn})},table:function(n){var t=et.table(n);return new z(n,t.schema,this)}}),e(H.prototype,function(){function n(n,t,e){var r=n instanceof H?new G(n):n;return r._ctx.error=e?new e(t):new TypeError(t),r}function t(n){return new G(n,function(){return Un.only("")}).limit(0)}function e(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,i,o){for(var u=Math.min(n.length,r.length),a=-1,c=0;c<u;++c){var s=t[c];if(s!==r[c])return i(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):i(n[c],r[c])<0?n.substr(0,c)+r[c]+e.substr(c+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[c],s)<0&&(a=c)}return u<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):a<0?null:n.substr(0,a)+r[a]+e.substr(a+1)}function o(t,o,u,a){function c(n){s=e(n),f=r(n),l="next"===n?ln:hn;var t=u.map(function(n){return{lower:f(n),upper:s(n)}}).sort(function(n,t){return l(n.lower,t.lower)});h=t.map(function(n){return n.upper}),d=t.map(function(n){return n.lower}),v=n,p="next"===n?"":a}var s,f,l,h,d,v,p,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(t,Lt);c("next");var m=new G(t,function(){return Un.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){c(n)};var g=0;return m._addAlgorithm(function(n,t,e){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(o(u,d,g))return!0;for(var a=null,c=g;c<y;++c){var s=i(r,u,h[c],d[c],l,v);null===s&&null===a?g=c+1:(null===a||l(a,s)>0)&&(a=s)}return t(null!==a?function(){n.continue(a+p)}:e),!1}),m}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return tn(e,r)>0||0===tn(e,r)&&(i||o)&&(!i||!o)?t(this):new G(this,function(){return Un.bound(e,r,!i,!o)})}catch(t){return n(this,zt)}},equals:function(n){return new G(this,function(){return Un.only(n)})},above:function(n){return new G(this,function(){return Un.lowerBound(n,!0)})},aboveOrEqual:function(n){return new G(this,function(){return Un.lowerBound(n)})},below:function(n){return new G(this,function(){return Un.upperBound(n,!0)})},belowOrEqual:function(n){return new G(this,function(){return Un.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,Lt):this.between(t,t+Rt,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):o(this,function(n,t){return 0===n.indexOf(t[0])},[n],Rt)},equalsIgnoreCase:function(n){return o(this,function(n,t){return n===t[0]},[n],"")},anyOfIgnoreCase:function(){var n=_.apply(Ln,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.indexOf(n)!==-1},n,"")},startsWithAnyOfIgnoreCase:function(){var n=_.apply(Ln,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},n,Rt)},anyOf:function(){var e=_.apply(Ln,arguments),r=sn;try{e.sort(r)}catch(t){return n(this,zt)}if(0===e.length)return t(this);var i=new G(this,function(){return Un.bound(e[0],e[e.length-1])});i._ondirectionchange=function(n){r="next"===n?sn:fn,e.sort(r)};var o=0;return i._addAlgorithm(function(n,t,i){for(var u=n.key;r(u,e[o])>0;)if(++o,o===e.length)return t(i),!1;return 0===r(u,e[o])||(t(function(){n.continue(e[o])}),!1)}),i},notEqual:function(n){return this.inAnyRange([[Vt,n],[n,Ut]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=_.apply(Ln,arguments);if(0===t.length)return new G(this);try{t.sort(sn)}catch(t){return n(this,zt)}var e=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[Vt,t]]},null);return e.push([t[t.length-1],Ut]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(n,t){for(var e=0,r=n.length;e<r;++e){var i=n[e];if(tn(t[0],i[1])<0&&tn(t[1],i[0])>0){i[0]=en(i[0],t[0]),i[1]=cn(i[1],t[1]);break}}return e===r&&n.push(t),n}function o(n,t){return f(n[0],t[0])}function u(n){return!h(n)&&!d(n)}if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&sn(n[0],n[1])<=0}))return n(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",nt.InvalidArgument);var a,c=!r||r.includeLowers!==!1,s=r&&r.includeUppers===!0,f=sn;try{a=e.reduce(i,[]),a.sort(o)}catch(t){return n(this,zt)}var l=0,h=s?function(n){return sn(n,a[l][1])>0}:function(n){return sn(n,a[l][1])>=0},d=c?function(n){return fn(n,a[l][0])>0}:function(n){return fn(n,a[l][0])>=0},v=h,p=new G(this,function(){return Un.bound(a[0][0],a[a.length-1][1],!c,!s)});return p._ondirectionchange=function(n){"next"===n?(v=h,f=sn):(v=d,f=fn),a.sort(o)},p._addAlgorithm(function(n,t,e){for(var r=n.key;v(r);)if(++l,l===a.length)return t(e),!1;return!!u(r)||0!==tn(r,a[l][1])&&0!==tn(r,a[l][0])&&(t(function(){f===sn?n.continue(a[l][0]):n.continue(a[l][1])}),!1)}),p},startsWithAnyOf:function(){var e=_.apply(Ln,arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+Rt]})):n(this,"startsWithAnyOf() only works with strings")}}}),e(G.prototype,function(){function e(n,t){n.filter=vn(n.filter,t)}function r(n,t,e){var r=n.replayFilter;n.replayFilter=r?function(){return vn(r(),t())}:t,n.justLimit=e&&!r}function i(n,t){n.isMatch=vn(n.isMatch,t)}function o(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new nt.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function u(n,t){var e=o(n,t);return n.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(n.range||null,n.dir+n.unique):e.openCursor(n.range||null,n.dir+n.unique)}function a(n,e,r,i,o){var a=n.replayFilter?vn(n.filter,n.replayFilter()):n.filter;n.or?function(){function c(){2===++l&&r()}function s(n,r,o){if(!a||a(r,o,c,i)){var u=r.primaryKey.toString();t(f,u)||(f[u]=!0,e(n,r,o))}}var f={},l=0;n.or._iterate(s,c,i,o),Z(u(n,o),n.algorithm,s,c,i,!n.keysOnly&&n.valueMapper)}():Z(u(n,o),vn(n.algorithm,a),e,r,i,!n.keysOnly&&n.valueMapper)}function c(n){return n.table.schema.instanceTemplate}return{_read:function(n,t){var e=this._ctx;return e.error?e.table._trans(null,Nt.bind(null,e.error)):e.table._idbstore(Zn,n).then(t)},_write:function(n){var t=this._ctx;return t.error?t.table._trans(null,Nt.bind(null,t.error)):t.table._idbstore(tt,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=vn(t.algorithm,n)},_iterate:function(n,t,e,r){return a(this._ctx,n,t,e,r)},clone:function(t){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&n(r,t),e._ctx=r,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var t=this._ctx;if($t){var e=c(t),r=t.table.schema.primKey.keyPath,i=v(e,t.index?t.table.schema.idxByName[t.index].keyPath:r),o=v(e,r);n(e,{key:i,primaryKey:o})}return this._read(function(e,r,i){a(t,n,e,r,i)})},count:function(n){if($t)return R.resolve(0).then(n);var t=this._ctx;if(J(t,!0))return this._read(function(n,e,r){var i=o(t,r),u=t.range?i.count(t.range):i.count();u.onerror=xn(e),u.onsuccess=function(e){n(Math.min(e.target.result,t.limit))}},n);var e=0;return this._read(function(n,r,i){a(t,function(){return++e,!1},function(){n(e)},r,i)},n)},sortBy:function(n,t){function e(n,t){return t?e(n[i[t]],t-1):n[o]}function r(n,t){var r=e(n,u),i=e(t,u);return r<i?-a:r>i?a:0}var i=n.split(".").reverse(),o=i[0],u=i.length-1,a="next"===this._ctx.dir?1:-1;return this.toArray(function(n){return n.sort(r)}).then(t)},toArray:function(n){var t=this._ctx;return this._read(function(n,e,r){if($t&&n([c(t)]),Bn&&"next"===t.dir&&J(t,!0)&&t.limit>0){var i=t.table.hook.reading.fire,u=o(t,r),s=t.limit<1/0?u.getAll(t.range,t.limit):u.getAll(t.range);s.onerror=xn(e),s.onsuccess=jn(i===C?n:function(t){try{n(t.map(i))}catch(n){e(n)}})}else{var f=[];a(t,function(n){f.push(n)},function(){n(f)},e,r)}},n)},offset:function(n){var t=this._ctx;return n<=0?this:(t.offset+=n,J(t)?r(t,function(){var t=n;return function(n,e){return 0===t||(1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1))}}):r(t,function(){var t=n;return function(){return--t<0}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),r(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}},!0),this},until:function(n,t){var r=this._ctx;return $t&&n(c(r)),e(this._ctx,function(e,r,i){return!n(e.value)||(r(i),t)}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(n){return $t&&n(c(this._ctx)),e(this._ctx,function(t){return n(t.value)}),i(this._ctx,n),this},and:function(n){return this.filter(n)},or:function(n){return new H(this._ctx.table,n,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},eachPrimaryKey:function(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.primaryKey,e)})},keys:function(n){var t=this._ctx;t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},primaryKeys:function(n){var t=this._ctx;if(Bn&&"next"===t.dir&&J(t,!0)&&t.limit>0)return this._read(function(n,e,r){var i=o(t,r),u=t.limit<1/0?i.getAllKeys(t.range,t.limit):i.getAllKeys(t.range);u.onerror=xn(e),u.onsuccess=jn(n)}).then(n);t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.primaryKey)}).then(function(){return e}).then(n)},uniqueKeys:function(n){return this._ctx.unique="unique",this.keys(n)},firstKey:function(n){return this.limit(1).keys(function(n){return n[0]}).then(n)},lastKey:function(n){return this.reverse().firstKey(n)},distinct:function(){var n=this._ctx,r=n.index&&n.table.schema.idxByName[n.index];if(!r||!r.multi)return this;var i={};return e(this._ctx,function(n){var e=n.primaryKey.toString(),r=t(i,e);return i[e]=!0,!r}),this},modify:function(e){var r=this,i=this._ctx,o=i.table.hook,u=o.updating.fire,a=o.deleting.fire;return $t&&"function"==typeof e&&e.call({value:i.table.schema.instanceTemplate},i.table.schema.instanceTemplate),this._write(function(i,o,c,s){function f(n,e){function r(n){return P.push(n),A.push(i.primKey),h(),!0}S=e.primaryKey;var i={primKey:e.primaryKey,value:n,onsuccess:null,onerror:null};if(y.call(i,n,i)!==!1){var o=!t(i,"value");++x,d(function(){var n=o?e.delete():e.update(i.value);n._hookCtx=i,n.onerror=En(r),n.onsuccess=kn(function(){++j,h()})},r)}else i.onsuccess&&i.onsuccess(i.value)}function l(n){return n&&(P.push(n),A.push(S)),o(new O("Error modifying one or more objects",P,j,A))}function h(){E&&j+P.length===x&&(P.length>0?l():i(j))}var y;if("function"==typeof e)y=u===D&&a===D?e:function(n){var r=b(n);if(e.call(this,n,this)===!1)return!1;if(t(this,"value")){var i=w(r,this.value),o=u.call(this,i,this.primKey,r,s);o&&(n=this.value,Cn(o).forEach(function(t){p(n,t,o[t])}))}else a.call(this,this.primKey,n,s)};else if(u===D){var g=Cn(e),_=g.length;y=function(n){for(var t=!1,r=0;r<_;++r){var i=g[r],o=e[i];v(n,i)!==o&&(p(n,i,o),t=!0)}return t}}else{var k=e;e=m(k),y=function(t){var r=!1,i=u.call(this,e,this.primKey,b(t),s);return i&&n(e,i),Cn(e).forEach(function(n){var i=e[n];v(t,n)!==i&&(p(t,n,i),r=!0)}),i&&(e=m(k)),r}}var x=0,j=0,E=!1,P=[],A=[],S=null;r.clone().raw()._iterate(f,function(){E=!0,h()},l,c)})},delete:function(){var n=this,t=this._ctx,e=t.range,r=t.table.hook.deleting.fire,i=r!==D;if(!i&&J(t)&&(t.isPrimKey&&!Gt||!e))return this._write(function(n,t,r){var i=xn(t),o=e?r.count(e):r.count();o.onerror=i,o.onsuccess=function(){var u=o.result;d(function(){var t=e?r.delete(e):r.clear();t.onerror=i,t.onsuccess=function(){return n(u)}},function(n){return t(n)})}});var o=i?2e3:1e4;return this._write(function(e,u,a,c){var s=0,f=n.clone({keysOnly:!t.isMatch&&!i}).distinct().limit(o).raw(),l=[],h=function(){return f.each(i?function(n,t){l.push([t.primaryKey,t.value])}:function(n,t){l.push(t.primaryKey)}).then(function(){return i?l.sort(function(n,t){return sn(n[0],t[0])}):l.sort(sn),W(a,c,l,i,r)}).then(function(){var n=l.length;return s+=n,l=[],n<o?s:h()})};e(h())})}}}),n(this,{Collection:G,Table:z,Transaction:Q,Version:y,WhereClause:H}),f(),Nn.forEach(function(n){n(et)})}function wn(n){if("function"==typeof n)return new n;if(Tn(n))return[wn(n[0])];if(n&&"object"==typeof n){var t={};return _n(t,n),t}return n}function _n(n,t){return Cn(t).forEach(function(e){var r=wn(t[e]);n[e]=r}),n}function kn(n){return rn(function(t){var e=t.target,r=e.result,i=e._hookCtx,o=i&&i.onsuccess;o&&o(r),n&&n(r)},n)}function xn(n){return rn(function(t){return Pn(t),n(t.target.error),!1})}function jn(n){return rn(function(t){n(t.target.result)})}function En(n){return rn(function(t){var e=t.target,r=e.error,i=e._hookCtx,o=i&&i.onerror;return o&&o(r),Pn(t),n(r),!1})}function Pn(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault()}function An(n){function t(n){return function(t){var e=n(t),r=e.value;return e.done?r:r&&"function"==typeof r.then?r.then(i,o):Tn(r)?R.all(r).then(i,o):i(r)}}var e=function(t){return n.next(t)},r=function(t){return n.throw(t)},i=t(e),o=t(r);return t(e)()}function On(n,t,e,r,i,o,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=i,this.compound=o,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(i?"++":"")+a}function Sn(n,t,e,r){this.name=n,this.primKey=t||new On,this.indexes=e||[new On],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=l(e,function(n){return[n.name,n]})}function In(n){return 1===n.length?n[0]:n}function Dn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var Cn=Object.keys,Tn=Array.isArray,Kn="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Bn=Object.getPrototypeOf,Fn={}.hasOwnProperty,Mn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,qn=[].slice,Rn=[].concat,Un="Boolean,String,Date,RegExp,Blob,File,FileList,ArrayBuffer,DataView,Uint8ClampedArray,ImageData,Map,Set".split(",").concat(g([8,16,32,64].map(function(n){return["Int","Uint","Float"].map(function(t){return t+n+"Array"})}))).filter(function(n){return Kn[n]}).map(function(n){return Kn[n]}),Vn="undefined"!=typeof Symbol&&Symbol.iterator,zn=Vn?function(n){var t;return null!=n&&(t=n[Vn])&&t.apply(n)}:function(){return null},Ln={},Wn="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),Qn=function(){return!0},Hn=!new Error("").stack,Gn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],Jn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Yn=Gn.concat(Jn),$n={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};i(P).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+j(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i(O).from(P),i(S).from(P);var Xn=Yn.reduce(function(n,t){return n[t]=t+"Error",n},{}),Zn=P,nt=Yn.reduce(function(n,t){function e(n,e){this._e=x(),this.name=r,n?"string"==typeof n?(this.message=n,this.inner=e||null):"object"==typeof n&&(this.message=n.name+" "+n.message,this.inner=n):(this.message=$n[t]||r,this.inner=null)}var r=t+"Error";return i(e).from(Zn),n[t]=e,n},{});nt.Syntax=SyntaxError,nt.Type=TypeError,nt.Range=RangeError;var tt=Jn.reduce(function(n,t){return n[t+"Error"]=nt[t],n},{}),et=Yn.reduce(function(n,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(n[t+"Error"]=nt[t]),n},{});et.ModifyError=O,et.DexieError=P,et.BulkError=S;var rt={},it=100,ot=20,ut=7,at=function(){try{return new Function("let F=async ()=>{},p=F();return [p,Object.getPrototypeOf(p),Promise.resolve(),F.constructor];")()}catch(t){var n=Kn.Promise;return n?[n.resolve(),n.prototype,n.resolve()]:[]}}(),ct=at[0],st=at[1],ft=at[2],lt=st&&st.then,ht=ct&&ct.constructor,dt=at[3],vt=!!ft,pt=!1,yt=ft?function(){ft.then(J)}:Kn.setImmediate?setImmediate.bind(null,J):Kn.MutationObserver?function(){var n=document.createElement("div");new MutationObserver(function(){J(),n=null}).observe(n,{attributes:!0}),n.setAttribute("i","1")}:function(){setTimeout(J,0)},mt=function(n,t){Pt.push([n,t]),bt&&(yt(),bt=!1)},gt=!0,bt=!0,wt=[],_t=[],kt=null,xt=C,jt={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:mn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(n){try{mn(n[0],n[1])}catch(n){}})}},Et=jt,Pt=[],At=0,Ot=[],St={get:function(){function n(n,r){var i=this,o=!t.global&&(t!==Et||e!==Kt);o&&an();var u=new R(function(e,u){W(i,new U(pn(n,t,o),pn(r,t,o),e,u,t))});return Wn&&G(u,this),u}var t=Et,e=Kt;return n.prototype=rt,n},set:function(n){r(this,"then",n&&n.prototype===rt?St:{get:function(){return n},set:St.set})}};e(R.prototype,{then:St,_then:function(n,t){W(this,new U(null,null,n,t,Et))},catch:function(n){if(1===arguments.length)return this.then(null,n);var t=arguments[0],e=arguments[1];return"function"==typeof t?this.then(null,function(n){return n instanceof t?e(n):en(n)}):this.then(null,function(n){return n&&n.name===t?e(n):en(n)})},finally:function(n){return this.then(function(t){return n(),t},function(t){return n(),en(t)})},stack:{get:function(){if(this._stack)return this._stack;try{pt=!0;var n=H(this,[],ot),t=n.join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{pt=!1}}},timeout:function(n,t){var e=this;return n<1/0?new R(function(r,i){var o=setTimeout(function(){return i(new nt.Timeout(t))},n);e.then(r,i).finally(clearTimeout.bind(null,o))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&r(R.prototype,Symbol.toStringTag,"Promise"),jt.env=hn(),e(R,{all:function(){var n=_.apply(null,arguments).map(cn);return new R(function(t,e){0===n.length&&t([]);var r=n.length;n.forEach(function(i,o){return R.resolve(i).then(function(e){n[o]=e,--r||t(n)},e)})})},resolve:function(n){if(n instanceof R)return n;if(n&&"function"==typeof n.then)return new R(function(t,e){n.then(t,e)});var t=new R(rt,!0,n);return G(t,kt),t},reject:en,race:function(){var n=_.apply(null,arguments).map(cn);return new R(function(t,e){n.map(function(n){return R.resolve(n).then(t,e)})})},PSD:{get:function(){return Et},set:function(n){return Et=n}},newPSD:on,usePSD:dn,scheduler:{get:function(){return mt},set:function(n){mt=n}},rejectionMapper:{get:function(){return xt},set:function(n){xt=n}},follow:function(n,t){return new R(function(e,r){return on(function(t,e){var r=Et;r.unhandleds=[],r.onunhandled=e,r.finalize=K(function(){var n=this;Z(function(){0===n.unhandleds.length?t():e(n.unhandleds[0])})},r.finalize),n()},t,e,r)})}});var It={awaits:0,echoes:0,id:0},Dt=0,Ct=[],Tt=0,Kt=0,Bt=0,Ft="unhandledrejection";c(function(){mt=function(n,t){setTimeout(function(){n.apply(null,t)},0)}});var Mt,Nt=R.reject,qt="2.0.0-beta.10",Rt=String.fromCharCode(65535),Ut=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return Rt}}(),Vt=-(1/0),zt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Lt="String expected.",Wt=[],Qt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Ht=Qt,Gt=Qt,Jt=function(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};k(Wn,Jt);var Yt=function(){},$t=!1,Xt=Kn.idbModules&&Kn.idbModules.shimIndexedDB?Kn.idbModules:{};return e(bn,et),e(bn,{delete:function(n){var t=new bn(n),e=t.delete();return e.onblocked=function(n){return t.on("blocked",n),this},e},exists:function(n){return new bn(n).open().then(function(n){return n.close(),!0}).catch(bn.NoSuchDatabaseError,function(){return!1})},getDatabaseNames:function(n){var t=Dn(bn.dependencies.indexedDB);return t?new R(function(n,e){var r=t();r.onsuccess=function(t){n(u(t.target.result,0))},r.onerror=xn(e)}).then(n):Mt.dbnames.toCollection().primaryKeys(n)},defineClass:function(t){function e(e){e?n(this,e):$t&&_n(this,t)}return e},applyStructure:_n,ignoreTransaction:function(n){return Et.trans?dn(Et.transless,n):n()},vip:function(n){return on(function(){return Et.letThrough=!0,n()})},async:function(n){return function(){try{var t=An(n.apply(this,arguments));return t&&"function"==typeof t.then?t:R.resolve(t)}catch(n){return Nt(n)}}},spawn:function(n,t,e){try{var r=An(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:R.resolve(r)}catch(n){return Nt(n)}},currentTransaction:{get:function(){return Et.trans||null}},waitFor:function(n,t){var e=R.resolve("function"==typeof n?bn.ignoreTransaction(n):n).timeout(t||6e4);return Et.trans?Et.trans.waitFor(e):e},Promise:R,debug:{get:function(){return Wn},set:function(n){k(n,"dexie"===n?function(){return!0}:Jt)}},derive:i,extend:n,props:e,override:a,Events:gn,getByKeyPath:v,setByKeyPath:p,delByKeyPath:y,shallowClone:m,deepClone:b,getObjectDiff:w,asap:f,maxKey:Ut,minKey:Vt,addons:[],connections:Wt,MultiModifyError:nt.Modify,errnames:Xn,IndexSpec:On,TableSchema:Sn,dependencies:{indexedDB:Xt.shimIndexedDB||Kn.indexedDB||Kn.mozIndexedDB||Kn.webkitIndexedDB||Kn.msIndexedDB,IDBKeyRange:Xt.IDBKeyRange||Kn.IDBKeyRange||Kn.webkitIDBKeyRange},semVer:qt,version:qt.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),fakeAutoComplete:Yt,default:bn,Dexie:bn}),R.rejectionMapper=I,c(function(){bn.fakeAutoComplete=Yt=c,bn.fake=$t=!0}),Mt=new bn("__dbnames"),Mt.version(1).stores({dbnames:"name"}),function(){var n="Dexie.DatabaseNames";if(void 0!==typeof localStorage&&void 0!==Kn.document)try{JSON.parse(localStorage.getItem(n)||"[]").forEach(function(n){return Mt.dbnames.put({name:n}).catch(D)}),localStorage.removeItem(n)}catch(n){}}(),bn}); -//# sourceMappingURL=dist/dexie.min.js.map
\ No newline at end of file diff --git a/ext/mixed/lib/wanakana.min.js b/ext/mixed/lib/wanakana.min.js index bfc36d56..07b0d976 100644 --- a/ext/mixed/lib/wanakana.min.js +++ b/ext/mixed/lib/wanakana.min.js @@ -1 +1,2 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.wanakana=e.wanakana||{})}(this,function(e){"use strict";function n(e){return"string"!=typeof e||!e.length}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1],a=arguments[2];if(n(e))return!1;var r=e.charCodeAt(0);return r>=t&&a>=r}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return[].concat(le(e)).map(function(e,n){var a=e.charCodeAt(0),r=t(e,re,oe),o=t(e,ie,ue);return r?String.fromCharCode(a-re+V):o?String.fromCharCode(a-ie+W):e}).join("")}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[bcdfghjklmnpqrstvwxyz]/:/[bcdfghjklmnpqrstvwxz]/;return-1!==e.toLowerCase().charAt(0).search(a)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&t(e,W,Y)}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Math.min(e,n)}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments[2];return e.slice(n,t)}function y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=1>=arguments.length||void 0===arguments[1]||arguments[1];if(n(e))return!1;var a=t?/[aeiouy]/:/[aeiou]/;return-1!==e.toLowerCase().charAt(0).search(a)}function c(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===ye}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&e.charCodeAt(0)===ce}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(!!c(e)||t(e,Z,$))}function f(){var e=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("").forEach(function(n){if(c(n)||h(n))e.push(n);else if(s(n)){var t=n.charCodeAt(0)+(ee-Z),a=String.fromCharCode(t);e.push(a)}else e.push(n)}),e.join("")}function d(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",ee,ne)}function v(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(s(e)||d(e))}function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(v)}function g(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],c=Object.assign({},X,n),h=[],s=0,d=e.length,v=3,g="",w="";d>s;){var p=null;for(v=i(3,d-s);v>0;){if(g=u(e,s,s+v),w=g.toLowerCase(),se.includes(w)&&d-s>=4)w=(g=u(e,s,s+(v+=1))).toLowerCase();else{if("n"===w.charAt(0)){if(2===v){if(!c.IMEMode&&" "===w.charAt(1)){p="ん ";break}if(c.IMEMode&&"n'"===w){p="ん";break}}r(w.charAt(1),!1)&&y(w.charAt(2))&&(w=(g=u(e,s,s+(v=1))).toLowerCase())}"n"!==w.charAt(0)&&r(w.charAt(0))&&g.charAt(0)===g.charAt(1)&&(v=1,t(g.charAt(0),W,Y)?(w="ッ",g="ッ"):(w="っ",g="っ"))}if(null!=(p=fe[w]))break;v-=4===v?2:1}null==p&&(p=g),c.useObsoleteKana&&("wi"===w&&(p="ゐ"),"we"===w&&(p="ゑ")),c.IMEMode&&"n"===w.charAt(0)&&("y"===e.charAt(s+1).toLowerCase()&&!1===y(e.charAt(s+2))||s===d-1||l(e.charAt(s+1)))&&(p=g.charAt(0)),a||o(g.charAt(0))&&(p=f(p)),h.push(p),s+=v||1}return h.join("")}function w(e){var n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});if(e instanceof Element&&ge.includes(e.nodeName)){var t=be();e.setAttribute("data-wanakana-id",t),e.autocapitalize="none",e.addEventListener("compositionupdate",b),e.addEventListener("input",n),we=k(n,t)}else console.warn("Input provided to wanakana.bind was not a valid input field.")}function p(e){var n=j(e);null!=n?(e.removeAttribute("data-wanakana-id"),e.removeEventListener("compositionupdate",b),e.removeEventListener("input",n.handler),we=A(n)):console.warn("Input had no listener registered.")}function m(e){var n=Object.assign({},X,e);return function(e){var t=e.target;if(me)me=!1;else{var r=a(t.value),o=g(x(r,n.IMEMode),Object.assign({},n,{IMEMode:!0}));if(r!==o){if(t.value=o,null!=t.setSelectionRange&&"number"==typeof t.selectionStart)return void t.setSelectionRange(t.value.length,t.value.length);if(null!=t.createTextRange){t.focus();var i=t.createTextRange();i.collapse(!1),i.select()}}}}}function b(e){var n=e.data||e.detail&&e.detail.data,t=n&&n.slice(-2).split("")||[],o="n"===t[0],i=t.every(function(e){return r(a(e))});me=!o&&i}function k(e,n){return we.concat({id:n,handler:e})}function j(e){return e&&we.find(function(n){return n.id===e.getAttribute("data-wanakana-id")})}function A(e){var n=e.id;return we.filter(function(e){return e.id!==n})}function x(e,n){switch(!0){case"toHiragana"===n:return e.toLowerCase();case"toKatakana"===n:return e.toUpperCase();default:return e}}function q(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&F.test(e)}function C(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(function(e){return q(e)})}function z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(function(e){return B.test(e)})}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(s)}function M(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(d)}function K(){return t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",te,ae)}function L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&[].concat(le(e)).every(K)}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{passKanji:!0},t=[].concat(le(e)),a=!1;return n.passKanji||(a=t.some(L)),(t.some(E)||t.some(M))&&t.some(C)&&!a}function I(){for(var e=[],n="",t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(""),a=0;t.length>a;a+=1){var r=t[a],o=[h(r),c(r)],i=o[0],u=o[1];if(i||u&&1>a)e.push(r);else if(u&&a>0){var y=de[n].slice(-1);e.push(he[y])}else if(d(r)){var s=r.charCodeAt(0)+(Z-ee),f=String.fromCharCode(s);e.push(f),n=f}else e.push(r),n=""}return e.join("")}function R(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n),a=e.length,r=[],o=0,y=2,c="",h="",s=void 0;a>o;){y=i(2,a-o);for(var f=!1;y>0;){if(c=u(e,o,o+y),M(c)&&(f=t.upcaseKatakana,c=I(c)),"っ"===c.charAt(0)&&1===y&&a-1>o){s=!0,h="";break}if(null!=(h=de[c])&&s&&(h=h.charAt(0).concat(h),s=!1),null!=h)break;y-=1}null==h&&(h=c),f&&(h=h.toUpperCase()),r.push(h),o+=y||1}return r.join("")}function S(){return g(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},!0)}function T(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n);return t.passRomaji?I(e):C(e)?S(e,t):O(e,{passKanji:!0})?S(I(e),t):I(e)}function H(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=Object.assign({},X,n);return f(t.passRomaji?e:C(e)||O(e)?S(e,t):e)}function P(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&G.some(function(n){var a=ve(n,2);return t(e,a[0],a[1])})}function U(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return Q.some(function(n){var a=ve(n,2);return t(e,a[0],a[1])})}function D(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!n(e)&&(P(e)||U(e))}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{all:!1};if(n(e)||!z(e)||l(e))return e;var a=[].concat(le(e));if(t.all)return a.filter(function(e){return!v(e)}).join("");for(var r=a.reverse(),o=0,i=r.length;i>o;o+=1){var u=r[o];if(!D(u)){if(L(u))break;r[o]=""}}return r.reverse().join("")}function _(e){switch(!0){case U(e):return"japanesePunctuation";case K(e):return"kanji";case s(e):return"hiragana";case d(e):return"katakana";default:return"romaji"}}function J(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(n(e))return[""];var t=[].concat(le(e)),a=t.shift(),r=_(a);return t.reduce(function(e,n){var t=_(n)===r;if(r=_(n),t){var a=e.pop();return e.concat(a.concat(n))}return e.concat(n)},[a])}var X={useObsoleteKana:!1,passRomaji:!1,upcaseKatakana:!1,IMEMode:!1},B=/[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff01-\uff0f\u4e00-\u9faf\u3400-\u4dbf]/,F=/[\u0000-\u007f\u0100-\u0101\u0112-\u0113\u012a-\u012b\u014c-\u014d\u016a-\u016b\u2018-\u2019\u201C-\u201D]/,G=[[33,47],[58,63],[91,96],[123,126],[8216,8217],[8220,8221]],Q=[[12289,12350],[12539,12540],[65281,65295],[65306,65311],[65339,65343],[65371,65376]],V=97,W=65,Y=90,Z=12353,$=12438,ee=12449,ne=12540,te=19968,ae=40879,re=65345,oe=65370,ie=65313,ue=65338,ye=12540,ce=12539,he={a:"あ",i:"い",u:"う",e:"え",o:"う"},se=["lts","chy","shy"],fe={".":"。",",":"、",":":":","/":"・","!":"!","?":"?","~":"〜","-":"ー","‘":"「","’":"」","“":"『","”":"』","[":"[","]":"]","(":"(",")":")","{":"{","}":"}",a:"あ",i:"い",u:"う",e:"え",o:"お",yi:"い",wu:"う",whu:"う",xa:"ぁ",xi:"ぃ",xu:"ぅ",xe:"ぇ",xo:"ぉ",xyi:"ぃ",xye:"ぇ",ye:"いぇ",wha:"うぁ",whi:"うぃ",whe:"うぇ",who:"うぉ",wi:"うぃ",we:"うぇ",va:"ゔぁ",vi:"ゔぃ",vu:"ゔ",ve:"ゔぇ",vo:"ゔぉ",vya:"ゔゃ",vyi:"ゔぃ",vyu:"ゔゅ",vye:"ゔぇ",vyo:"ゔょ",ka:"か",ki:"き",ku:"く",ke:"け",ko:"こ",lka:"ヵ",lke:"ヶ",xka:"ヵ",xke:"ヶ",kya:"きゃ",kyi:"きぃ",kyu:"きゅ",kye:"きぇ",kyo:"きょ",ca:"か",ci:"き",cu:"く",ce:"け",co:"こ",lca:"ヵ",lce:"ヶ",xca:"ヵ",xce:"ヶ",qya:"くゃ",qyu:"くゅ",qyo:"くょ",qwa:"くぁ",qwi:"くぃ",qwu:"くぅ",qwe:"くぇ",qwo:"くぉ",qa:"くぁ",qi:"くぃ",qe:"くぇ",qo:"くぉ",kwa:"くぁ",qyi:"くぃ",qye:"くぇ",ga:"が",gi:"ぎ",gu:"ぐ",ge:"げ",go:"ご",gya:"ぎゃ",gyi:"ぎぃ",gyu:"ぎゅ",gye:"ぎぇ",gyo:"ぎょ",gwa:"ぐぁ",gwi:"ぐぃ",gwu:"ぐぅ",gwe:"ぐぇ",gwo:"ぐぉ",sa:"さ",si:"し",shi:"し",su:"す",se:"せ",so:"そ",za:"ざ",zi:"じ",zu:"ず",ze:"ぜ",zo:"ぞ",ji:"じ",sya:"しゃ",syi:"しぃ",syu:"しゅ",sye:"しぇ",syo:"しょ",sha:"しゃ",shu:"しゅ",she:"しぇ",sho:"しょ",shya:"しゃ",shyu:"しゅ",shye:"しぇ",shyo:"しょ",swa:"すぁ",swi:"すぃ",swu:"すぅ",swe:"すぇ",swo:"すぉ",zya:"じゃ",zyi:"じぃ",zyu:"じゅ",zye:"じぇ",zyo:"じょ",ja:"じゃ",ju:"じゅ",je:"じぇ",jo:"じょ",jya:"じゃ",jyi:"じぃ",jyu:"じゅ",jye:"じぇ",jyo:"じょ",ta:"た",ti:"ち",tu:"つ",te:"て",to:"と",chi:"ち",tsu:"つ",ltu:"っ",xtu:"っ",tya:"ちゃ",tyi:"ちぃ",tyu:"ちゅ",tye:"ちぇ",tyo:"ちょ",cha:"ちゃ",chu:"ちゅ",che:"ちぇ",cho:"ちょ",cya:"ちゃ",cyi:"ちぃ",cyu:"ちゅ",cye:"ちぇ",cyo:"ちょ",chya:"ちゃ",chyu:"ちゅ",chye:"ちぇ",chyo:"ちょ",tsa:"つぁ",tsi:"つぃ",tse:"つぇ",tso:"つぉ",tha:"てゃ",thi:"てぃ",thu:"てゅ",the:"てぇ",tho:"てょ",twa:"とぁ",twi:"とぃ",twu:"とぅ",twe:"とぇ",two:"とぉ",da:"だ",di:"ぢ",du:"づ",de:"で",do:"ど",dya:"ぢゃ",dyi:"ぢぃ",dyu:"ぢゅ",dye:"ぢぇ",dyo:"ぢょ",dha:"でゃ",dhi:"でぃ",dhu:"でゅ",dhe:"でぇ",dho:"でょ",dwa:"どぁ",dwi:"どぃ",dwu:"どぅ",dwe:"どぇ",dwo:"どぉ",na:"な",ni:"に",nu:"ぬ",ne:"ね",no:"の",nya:"にゃ",nyi:"にぃ",nyu:"にゅ",nye:"にぇ",nyo:"にょ",ha:"は",hi:"ひ",hu:"ふ",he:"へ",ho:"ほ",fu:"ふ",hya:"ひゃ",hyi:"ひぃ",hyu:"ひゅ",hye:"ひぇ",hyo:"ひょ",fya:"ふゃ",fyu:"ふゅ",fyo:"ふょ",fwa:"ふぁ",fwi:"ふぃ",fwu:"ふぅ",fwe:"ふぇ",fwo:"ふぉ",fa:"ふぁ",fi:"ふぃ",fe:"ふぇ",fo:"ふぉ",fyi:"ふぃ",fye:"ふぇ",ba:"ば",bi:"び",bu:"ぶ",be:"べ",bo:"ぼ",bya:"びゃ",byi:"びぃ",byu:"びゅ",bye:"びぇ",byo:"びょ",pa:"ぱ",pi:"ぴ",pu:"ぷ",pe:"ぺ",po:"ぽ",pya:"ぴゃ",pyi:"ぴぃ",pyu:"ぴゅ",pye:"ぴぇ",pyo:"ぴょ",ma:"ま",mi:"み",mu:"む",me:"め",mo:"も",mya:"みゃ",myi:"みぃ",myu:"みゅ",mye:"みぇ",myo:"みょ",ya:"や",yu:"ゆ",yo:"よ",xya:"ゃ",xyu:"ゅ",xyo:"ょ",ra:"ら",ri:"り",ru:"る",re:"れ",ro:"ろ",rya:"りゃ",ryi:"りぃ",ryu:"りゅ",rye:"りぇ",ryo:"りょ",la:"ら",li:"り",lu:"る",le:"れ",lo:"ろ",lya:"りゃ",lyi:"りぃ",lyu:"りゅ",lye:"りぇ",lyo:"りょ",wa:"わ",wo:"を",lwe:"ゎ",xwa:"ゎ",n:"ん",nn:"ん","n'":"ん","n ":"ん",xn:"ん",ltsu:"っ"},de={" ":" ","!":"!","?":"?","。":".",":":":","・":"/","、":",","〜":"~","ー":"-","「":"‘","」":"’","『":"“","』":"”","[":"[","]":"]","(":"(",")":")","{":"{","}":"}","あ":"a","い":"i","う":"u","え":"e","お":"o","ゔぁ":"va","ゔぃ":"vi","ゔ":"vu","ゔぇ":"ve","ゔぉ":"vo","か":"ka","き":"ki","きゃ":"kya","きぃ":"kyi","きゅ":"kyu","く":"ku","け":"ke","こ":"ko","が":"ga","ぎ":"gi","ぐ":"gu","げ":"ge","ご":"go","ぎゃ":"gya","ぎぃ":"gyi","ぎゅ":"gyu","ぎぇ":"gye","ぎょ":"gyo","さ":"sa","す":"su","せ":"se","そ":"so","ざ":"za","ず":"zu","ぜ":"ze","ぞ":"zo","し":"shi","しゃ":"sha","しゅ":"shu","しょ":"sho","じ":"ji","じゃ":"ja","じゅ":"ju","じょ":"jo","た":"ta","ち":"chi","ちゃ":"cha","ちゅ":"chu","ちょ":"cho","つ":"tsu","て":"te","と":"to","だ":"da","ぢ":"di","づ":"du","で":"de","ど":"do","な":"na","に":"ni","にゃ":"nya","にゅ":"nyu","にょ":"nyo","ぬ":"nu","ね":"ne","の":"no","は":"ha","ひ":"hi","ふ":"fu","へ":"he","ほ":"ho","ひゃ":"hya","ひゅ":"hyu","ひょ":"hyo","ふぁ":"fa","ふぃ":"fi","ふぇ":"fe","ふぉ":"fo","ば":"ba","び":"bi","ぶ":"bu","べ":"be","ぼ":"bo","びゃ":"bya","びゅ":"byu","びょ":"byo","ぱ":"pa","ぴ":"pi","ぷ":"pu","ぺ":"pe","ぽ":"po","ぴゃ":"pya","ぴゅ":"pyu","ぴょ":"pyo","ま":"ma","み":"mi","む":"mu","め":"me","も":"mo","みゃ":"mya","みゅ":"myu","みょ":"myo","や":"ya","ゆ":"yu","よ":"yo","ら":"ra","り":"ri","る":"ru","れ":"re","ろ":"ro","りゃ":"rya","りゅ":"ryu","りょ":"ryo","わ":"wa","を":"wo","ん":"n","ゐ":"wi","ゑ":"we","きぇ":"kye","きょ":"kyo","じぃ":"jyi","じぇ":"jye","ちぃ":"cyi","ちぇ":"che","ひぃ":"hyi","ひぇ":"hye","びぃ":"byi","びぇ":"bye","ぴぃ":"pyi","ぴぇ":"pye","みぇ":"mye","みぃ":"myi","りぃ":"ryi","りぇ":"rye","にぃ":"nyi","にぇ":"nye","しぃ":"syi","しぇ":"she","いぇ":"ye","うぁ":"wha","うぉ":"who","うぃ":"wi","うぇ":"we","ゔゃ":"vya","ゔゅ":"vyu","ゔょ":"vyo","すぁ":"swa","すぃ":"swi","すぅ":"swu","すぇ":"swe","すぉ":"swo","くゃ":"qya","くゅ":"qyu","くょ":"qyo","くぁ":"qwa","くぃ":"qwi","くぅ":"qwu","くぇ":"qwe","くぉ":"qwo","ぐぁ":"gwa","ぐぃ":"gwi","ぐぅ":"gwu","ぐぇ":"gwe","ぐぉ":"gwo","つぁ":"tsa","つぃ":"tsi","つぇ":"tse","つぉ":"tso","てゃ":"tha","てぃ":"thi","てゅ":"thu","てぇ":"the","てょ":"tho","とぁ":"twa","とぃ":"twi","とぅ":"twu","とぇ":"twe","とぉ":"two","ぢゃ":"dya","ぢぃ":"dyi","ぢゅ":"dyu","ぢぇ":"dye","ぢょ":"dyo","でゃ":"dha","でぃ":"dhi","でゅ":"dhu","でぇ":"dhe","でょ":"dho","どぁ":"dwa","どぃ":"dwi","どぅ":"dwu","どぇ":"dwe","どぉ":"dwo","ふぅ":"fwu","ふゃ":"fya","ふゅ":"fyu","ふょ":"fyo","ぁ":"a","ぃ":"i","ぇ":"e","ぅ":"u","ぉ":"o","ゃ":"ya","ゅ":"yu","ょ":"yo","っ":"","ゕ":"ka","ゖ":"ka","ゎ":"wa","んあ":"n'a","んい":"n'i","んう":"n'u","んえ":"n'e","んお":"n'o","んや":"n'ya","んゆ":"n'yu","んよ":"n'yo"},ve=function(){function e(e,n){var t=[],a=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(a=(i=u.next()).done)&&(t.push(i.value),!n||t.length!==n);a=!0);}catch(e){r=!0,o=e}finally{try{!a&&u.return&&u.return()}finally{if(r)throw o}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return e(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),le=function(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);e.length>n;n++)t[n]=e[n];return t}return Array.from(e)},ge=["TEXTAREA","INPUT"],we=[],pe=0,me=!1,be=function(){return pe+=1,""+Date.now()+pe};e.bind=w,e.unbind=p,e.isRomaji=C,e.isJapanese=z,e.isKana=l,e.isHiragana=E,e.isKatakana=M,e.isMixed=O,e.isKanji=L,e.toRomaji=R,e.toKana=g,e.toHiragana=T,e.toKatakana=H,e.stripOkurigana=N,e.tokenize=J,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.wanakana={})}(this,function(t){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t,e){return t(e={exports:{}},e.exports),e.exports}var r=n(function(t){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)}),o=Object.freeze({default:r,__moduleExports:r}),i=n(function(t){var e=t.exports={version:"2.5.5"};"number"==typeof __e&&(__e=e)}),u=Object.freeze({default:i,__moduleExports:i,version:i.version}),a=function(t){return"object"==typeof t?null!==t:"function"==typeof t},c=Object.freeze({default:a,__moduleExports:a}),f=c&&a||c,s=function(t){if(!f(t))throw TypeError(t+" is not an object!");return t},l=Object.freeze({default:s,__moduleExports:s}),h=function(t){try{return!!t()}catch(t){return!0}},d=Object.freeze({default:h,__moduleExports:h}),v=d&&h||d,p=!v(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),y=Object.freeze({default:p,__moduleExports:p}),g=o&&r||o,_=g.document,m=f(_)&&f(_.createElement),b=function(t){return m?_.createElement(t):{}},E=Object.freeze({default:b,__moduleExports:b}),O=y&&p||y,j=E&&b||E,w=!O&&!v(function(){return 7!=Object.defineProperty(j("div"),"a",{get:function(){return 7}}).a}),x=Object.freeze({default:w,__moduleExports:w}),S=function(t,e){if(!f(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!f(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!f(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!f(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},A=Object.freeze({default:S,__moduleExports:S}),M=l&&s||l,z=x&&w||x,N=A&&S||A,P=Object.defineProperty,k=O?Object.defineProperty:function(t,e,n){if(M(t),e=N(e,!0),M(n),z)try{return P(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t},L={f:k},F=Object.freeze({default:L,__moduleExports:L,f:k}),I=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},R=Object.freeze({default:I,__moduleExports:I}),T=F&&L||F,C=R&&I||R,W=O?function(t,e,n){return T.f(t,e,C(1,n))}:function(t,e,n){return t[e]=n,t},U=Object.freeze({default:W,__moduleExports:W}),K={}.hasOwnProperty,B=function(t,e){return K.call(t,e)},D=Object.freeze({default:B,__moduleExports:B}),V=0,G=Math.random(),J=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++V+G).toString(36))},H=Object.freeze({default:J,__moduleExports:J}),Y=U&&W||U,q=D&&B||D,X=H&&J||H,$=u&&i||u,Q=n(function(t){var e=X("src"),n=Function.toString,r=(""+n).split("toString");$.inspectSource=function(t){return n.call(t)},(t.exports=function(t,n,o,i){var u="function"==typeof o;u&&(q(o,"name")||Y(o,"name",n)),t[n]!==o&&(u&&(q(o,e)||Y(o,e,t[n]?""+t[n]:r.join(n+""))),t===g?t[n]=o:i?t[n]?t[n]=o:Y(t,n,o):(delete t[n],Y(t,n,o)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[e]||n.call(this)})}),Z=Object.freeze({default:Q,__moduleExports:Q}),tt=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t},et=Object.freeze({default:tt,__moduleExports:tt}),nt=et&&tt||et,rt=function(t,e,n){if(nt(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},ot=Object.freeze({default:rt,__moduleExports:rt}),it=Z&&Q||Z,ut=ot&&rt||ot,at=function(t,e,n){var r,o,i,u,a=t&at.F,c=t&at.G,f=t&at.P,s=t&at.B,l=c?g:t&at.S?g[e]||(g[e]={}):(g[e]||{}).prototype,h=c?$:$[e]||($[e]={}),d=h.prototype||(h.prototype={});for(r in c&&(n=e),n)i=((o=!a&&l&&void 0!==l[r])?l:n)[r],u=s&&o?ut(i,g):f&&"function"==typeof i?ut(Function.call,i):i,l&&it(l,r,i,t&at.U),h[r]!=i&&Y(h,r,u),f&&d[r]!=i&&(d[r]=i)};g.core=$,at.F=1,at.G=2,at.S=4,at.P=8,at.B=16,at.W=32,at.U=64,at.R=128;for(var ct,ft=at,st=Object.freeze({default:ft,__moduleExports:ft}),lt=X("typed_array"),ht=X("view"),dt=!(!g.ArrayBuffer||!g.DataView),vt=dt,pt=0,yt="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");9>pt;)(ct=g[yt[pt++]])?(Y(ct.prototype,lt,!0),Y(ct.prototype,ht,!0)):vt=!1;var gt={ABV:dt,CONSTR:vt,TYPED:lt,VIEW:ht},_t=Object.freeze({default:gt,__moduleExports:gt,ABV:gt.ABV,CONSTR:gt.CONSTR,TYPED:gt.TYPED,VIEW:gt.VIEW}),mt=Object.freeze({default:!1,__moduleExports:!1}),bt=function(t,e,n){for(var r in e)it(t,r,e[r],n);return t},Et=Object.freeze({default:bt,__moduleExports:bt}),Ot=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t},jt=Object.freeze({default:Ot,__moduleExports:Ot}),wt=Math.ceil,xt=Math.floor,St=function(t){return isNaN(t=+t)?0:(t>0?xt:wt)(t)},At=Object.freeze({default:St,__moduleExports:St}),Mt=At&&St||At,zt=Math.min,Nt=function(t){return t>0?zt(Mt(t),9007199254740991):0},Pt=Object.freeze({default:Nt,__moduleExports:Nt}),kt=Pt&&Nt||Pt,Lt=function(t){if(void 0===t)return 0;var e=Mt(t),n=kt(e);if(e!==n)throw RangeError("Wrong length!");return n},Ft=Object.freeze({default:Lt,__moduleExports:Lt}),It={}.toString,Rt=function(t){return It.call(t).slice(8,-1)},Tt=Object.freeze({default:Rt,__moduleExports:Rt}),Ct=Tt&&Rt||Tt,Wt=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==Ct(t)?t.split(""):Object(t)},Ut=Object.freeze({default:Wt,__moduleExports:Wt}),Kt=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t},Bt=Object.freeze({default:Kt,__moduleExports:Kt}),Dt=Ut&&Wt||Ut,Vt=Bt&&Kt||Bt,Gt=function(t){return Dt(Vt(t))},Jt=Object.freeze({default:Gt,__moduleExports:Gt}),Ht=Math.max,Yt=Math.min,qt=function(t,e){return 0>(t=Mt(t))?Ht(t+e,0):Yt(t,e)},Xt=Object.freeze({default:qt,__moduleExports:qt}),$t=Jt&&Gt||Jt,Qt=Xt&&qt||Xt,Zt=function(t){return function(e,n,r){var o,i=$t(e),u=kt(i.length),a=Qt(r,u);if(t&&n!=n){for(;u>a;)if((o=i[a++])!=o)return!0}else for(;u>a;a++)if((t||a in i)&&i[a]===n)return t||a||0;return!t&&-1}},te=Object.freeze({default:Zt,__moduleExports:Zt}),ee=g["__core-js_shared__"]||(g["__core-js_shared__"]={}),ne=function(t){return ee[t]||(ee[t]={})},re=Object.freeze({default:ne,__moduleExports:ne}),oe=re&&ne||re,ie=oe("keys"),ue=function(t){return ie[t]||(ie[t]=X(t))},ae=Object.freeze({default:ue,__moduleExports:ue}),ce=te&&Zt||te,fe=ae&&ue||ae,se=ce(!1),le=fe("IE_PROTO"),he=function(t,e){var n,r=$t(t),o=0,i=[];for(n in r)n!=le&&q(r,n)&&i.push(n);for(;e.length>o;)q(r,n=e[o++])&&(~se(i,n)||i.push(n));return i},de=Object.freeze({default:he,__moduleExports:he}),ve="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),pe=Object.freeze({default:ve,__moduleExports:ve}),ye=de&&he||de,ge=pe&&ve||pe,_e=ge.concat("length","prototype"),me=Object.getOwnPropertyNames||function(t){return ye(t,_e)},be={f:me},Ee=Object.freeze({default:be,__moduleExports:be,f:me}),Oe=function(t){return Object(Vt(t))},je=Object.freeze({default:Oe,__moduleExports:Oe}),we=je&&Oe||je,xe=function(t){for(var e=we(this),n=kt(e.length),r=arguments.length,o=Qt(r>1?arguments[1]:void 0,n),i=r>2?arguments[2]:void 0,u=void 0===i?n:Qt(i,n);u>o;)e[o++]=t;return e},Se=Object.freeze({default:xe,__moduleExports:xe}),Ae=n(function(t){var e=oe("wks"),n=g.Symbol,r="function"==typeof n;(t.exports=function(t){return e[t]||(e[t]=r&&n[t]||(r?n:X)("Symbol."+t))}).store=e}),Me=Object.freeze({default:Ae,__moduleExports:Ae}),ze=Me&&Ae||Me,Ne=T.f,Pe=ze("toStringTag"),ke=function(t,e,n){t&&!q(t=n?t:t.prototype,Pe)&&Ne(t,Pe,{configurable:!0,value:e})},Le=Object.freeze({default:ke,__moduleExports:ke}),Fe=mt,Ie=_t&>||_t,Re=Et&&bt||Et,Te=jt&&Ot||jt,Ce=Ft&&Lt||Ft,We=Ee&&be||Ee,Ue=Se&&xe||Se,Ke=Le&&ke||Le,Be=n(function(t,e){var n=We.f,r=T.f,o="prototype",i="Wrong index!",u=g.ArrayBuffer,a=g.DataView,c=g.Math,f=g.RangeError,s=g.Infinity,l=u,h=c.abs,d=c.pow,p=c.floor,y=c.log,_=c.LN2,m=O?"_b":"buffer",b=O?"_l":"byteLength",E=O?"_o":"byteOffset";function j(t,e,n){var r,o,i,u=Array(n),a=8*n-e-1,c=(1<<a)-1,f=c>>1,l=23===e?d(2,-24)-d(2,-77):0,v=0,g=0>t||0===t&&0>1/t?1:0;for((t=h(t))!=t||t===s?(o=t!=t?1:0,r=c):(r=p(y(t)/_),1>t*(i=d(2,-r))&&(r--,i*=2),2>(t+=1>r+f?l*d(2,1-f):l/i)*i||(r++,i/=2),c>r+f?1>r+f?(o=t*d(2,f-1)*d(2,e),r=0):(o=(t*i-1)*d(2,e),r+=f):(o=0,r=c));e>=8;u[v++]=255&o,o/=256,e-=8);for(r=r<<e|o,a+=e;a>0;u[v++]=255&r,r/=256,a-=8);return u[--v]|=128*g,u}function w(t,e,n){var r,o=8*n-e-1,i=(1<<o)-1,u=i>>1,a=o-7,c=n-1,f=t[c--],l=127&f;for(f>>=7;a>0;l=256*l+t[c],c--,a-=8);for(r=l&(1<<-a)-1,l>>=-a,a+=e;a>0;r=256*r+t[c],c--,a-=8);if(0===l)l=1-u;else{if(l===i)return r?NaN:f?-s:s;r+=d(2,e),l-=u}return(f?-1:1)*r*d(2,l-e)}function x(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]}function S(t){return[255&t]}function A(t){return[255&t,t>>8&255]}function M(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]}function z(t){return j(t,52,8)}function N(t){return j(t,23,4)}function P(t,e,n){r(t[o],e,{get:function(){return this[n]}})}function k(t,e,n,r){var o=Ce(+n);if(o+e>t[b])throw f(i);var u=o+t[E],a=t[m]._b.slice(u,u+e);return r?a:a.reverse()}function L(t,e,n,r,o,u){var a=Ce(+n);if(a+e>t[b])throw f(i);for(var c=t[m]._b,s=a+t[E],l=r(+o),h=0;e>h;h++)c[s+h]=l[u?h:e-h-1]}if(Ie.ABV){if(!v(function(){u(1)})||!v(function(){new u(-1)})||v(function(){return new u,new u(1.5),new u(NaN),"ArrayBuffer"!=u.name})){for(var F,I=(u=function(t){return Te(this,u),new l(Ce(t))})[o]=l[o],R=n(l),C=0;R.length>C;)(F=R[C++])in u||Y(u,F,l[F]);Fe||(I.constructor=u)}var W=new a(new u(2)),U=a[o].setInt8;W.setInt8(0,2147483648),W.setInt8(1,2147483649),!W.getInt8(0)&&W.getInt8(1)||Re(a[o],{setInt8:function(t,e){U.call(this,t,e<<24>>24)},setUint8:function(t,e){U.call(this,t,e<<24>>24)}},!0)}else u=function(t){Te(this,u,"ArrayBuffer");var e=Ce(t);this._b=Ue.call(Array(e),0),this[b]=e},a=function(t,e,n){Te(this,a,"DataView"),Te(t,u,"DataView");var r=t[b],o=Mt(e);if(0>o||o>r)throw f("Wrong offset!");if(o+(n=void 0===n?r-o:kt(n))>r)throw f("Wrong length!");this[m]=t,this[E]=o,this[b]=n},O&&(P(u,"byteLength","_l"),P(a,"buffer","_b"),P(a,"byteLength","_l"),P(a,"byteOffset","_o")),Re(a[o],{getInt8:function(t){return k(this,1,t)[0]<<24>>24},getUint8:function(t){return k(this,1,t)[0]},getInt16:function(t){var e=k(this,2,t,arguments[1]);return(e[1]<<8|e[0])<<16>>16},getUint16:function(t){var e=k(this,2,t,arguments[1]);return e[1]<<8|e[0]},getInt32:function(t){return x(k(this,4,t,arguments[1]))},getUint32:function(t){return x(k(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return w(k(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return w(k(this,8,t,arguments[1]),52,8)},setInt8:function(t,e){L(this,1,t,S,e)},setUint8:function(t,e){L(this,1,t,S,e)},setInt16:function(t,e){L(this,2,t,A,e,arguments[2])},setUint16:function(t,e){L(this,2,t,A,e,arguments[2])},setInt32:function(t,e){L(this,4,t,M,e,arguments[2])},setUint32:function(t,e){L(this,4,t,M,e,arguments[2])},setFloat32:function(t,e){L(this,4,t,N,e,arguments[2])},setFloat64:function(t,e){L(this,8,t,z,e,arguments[2])}});Ke(u,"ArrayBuffer"),Ke(a,"DataView"),Y(a[o],Ie.VIEW,!0),e.ArrayBuffer=u,e.DataView=a}),De=Object.freeze({default:Be,__moduleExports:Be}),Ve=ze("species"),Ge=function(t,e){var n,r=M(t).constructor;return void 0===r||void 0==(n=M(r)[Ve])?e:nt(n)},Je=Object.freeze({default:Ge,__moduleExports:Ge}),He=ze("species"),Ye=function(t){var e=g[t];O&&e&&!e[He]&&T.f(e,He,{configurable:!0,get:function(){return this}})},qe=Object.freeze({default:Ye,__moduleExports:Ye}),Xe=st&&ft||st,$e=De&&Be||De,Qe=Je&&Ge||Je,Ze=qe&&Ye||qe,tn=g.ArrayBuffer,en=$e.ArrayBuffer,nn=$e.DataView,rn=Ie.ABV&&tn.isView,on=en.prototype.slice,un=Ie.VIEW;Xe(Xe.G+Xe.W+Xe.F*(tn!==en),{ArrayBuffer:en}),Xe(Xe.S+Xe.F*!Ie.CONSTR,"ArrayBuffer",{isView:function(t){return rn&&rn(t)||f(t)&&un in t}}),Xe(Xe.P+Xe.U+Xe.F*v(function(){return!new en(2).slice(1,void 0).byteLength}),"ArrayBuffer",{slice:function(t,e){if(void 0!==on&&void 0===e)return on.call(M(this),t);for(var n=M(this).byteLength,r=Qt(t,n),o=Qt(void 0===e?n:e,n),i=new(Qe(this,en))(kt(o-r)),u=new nn(this),a=new nn(i),c=0;o>r;)a.setUint8(c++,u.getUint8(r++));return i}}),Ze("ArrayBuffer");var an=ze("toStringTag"),cn="Arguments"==Ct(function(){return arguments}()),fn=function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),an))?n:cn?Ct(e):"Object"==(r=Ct(e))&&"function"==typeof e.callee?"Arguments":r},sn=Object.freeze({default:fn,__moduleExports:fn}),ln={},hn=Object.freeze({default:ln,__moduleExports:ln}),dn=hn&&ln||hn,vn=ze("iterator"),pn=Array.prototype,yn=function(t){return void 0!==t&&(dn.Array===t||pn[vn]===t)},gn=Object.freeze({default:yn,__moduleExports:yn}),_n=Object.keys||function(t){return ye(t,ge)},mn=Object.freeze({default:_n,__moduleExports:_n}),bn=mn&&_n||mn,En=O?Object.defineProperties:function(t,e){M(t);for(var n,r=bn(e),o=r.length,i=0;o>i;)T.f(t,n=r[i++],e[n]);return t},On=Object.freeze({default:En,__moduleExports:En}),jn=g.document,wn=jn&&jn.documentElement,xn=Object.freeze({default:wn,__moduleExports:wn}),Sn=On&&En||On,An=xn&&wn||xn,Mn=fe("IE_PROTO"),zn=function(){},Nn=function(){var t,e=j("iframe"),n=ge.length;for(e.style.display="none",An.appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),Nn=t.F;n--;)delete Nn.prototype[ge[n]];return Nn()},Pn=Object.create||function(t,e){var n;return null!==t?(zn.prototype=M(t),n=new zn,zn.prototype=null,n[Mn]=t):n=Nn(),void 0===e?n:Sn(n,e)},kn=Object.freeze({default:Pn,__moduleExports:Pn}),Ln=fe("IE_PROTO"),Fn=Object.prototype,In=Object.getPrototypeOf||function(t){return t=we(t),q(t,Ln)?t[Ln]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Fn:null},Rn=Object.freeze({default:In,__moduleExports:In}),Tn=sn&&fn||sn,Cn=ze("iterator"),Wn=$.getIteratorMethod=function(t){if(void 0!=t)return t[Cn]||t["@@iterator"]||dn[Tn(t)]},Un=Object.freeze({default:Wn,__moduleExports:Wn}),Kn=Array.isArray||function(t){return"Array"==Ct(t)},Bn=Object.freeze({default:Kn,__moduleExports:Kn}),Dn=Bn&&Kn||Bn,Vn=ze("species"),Gn=function(t){var e;return Dn(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!Dn(e.prototype)||(e=void 0),f(e)&&null===(e=e[Vn])&&(e=void 0)),void 0===e?Array:e},Jn=Object.freeze({default:Gn,__moduleExports:Gn}),Hn=Jn&&Gn||Jn,Yn=function(t,e){return new(Hn(t))(e)},qn=Object.freeze({default:Yn,__moduleExports:Yn}),Xn=qn&&Yn||qn,$n=function(t,e){var n=1==t,r=2==t,o=3==t,i=4==t,u=6==t,a=5==t||u,c=e||Xn;return function(e,f,s){for(var l,h,d=we(e),v=Dt(d),p=ut(f,s,3),y=kt(v.length),g=0,_=n?c(e,y):r?c(e,0):void 0;y>g;g++)if((a||g in v)&&(h=p(l=v[g],g,d),t))if(n)_[g]=h;else if(h)switch(t){case 3:return!0;case 5:return l;case 6:return g;case 2:_.push(l)}else if(i)return!1;return u?-1:o||i?i:_}},Qn=Object.freeze({default:$n,__moduleExports:$n}),Zn=ze("unscopables"),tr=Array.prototype;void 0==tr[Zn]&&Y(tr,Zn,{});var er=function(t){tr[Zn][t]=!0},nr=Object.freeze({default:er,__moduleExports:er}),rr=function(t,e){return{value:e,done:!!t}},or=Object.freeze({default:rr,__moduleExports:rr}),ir=kn&&Pn||kn,ur={};Y(ur,ze("iterator"),function(){return this});var ar=function(t,e,n){t.prototype=ir(ur,{next:C(1,n)}),Ke(t,e+" Iterator")},cr=Object.freeze({default:ar,__moduleExports:ar}),fr=cr&&ar||cr,sr=Rn&&In||Rn,lr=ze("iterator"),hr=!([].keys&&"next"in[].keys()),dr=function(){return this},vr=function(t,e,n,r,o,i,u){fr(n,e,r);var a,c,f,s=function(t){if(!hr&&t in v)return v[t];switch(t){case"keys":case"values":return function(){return new n(this,t)}}return function(){return new n(this,t)}},l=e+" Iterator",h="values"==o,d=!1,v=t.prototype,p=v[lr]||v["@@iterator"]||o&&v[o],y=p||s(o),g=o?h?s("entries"):y:void 0,_="Array"==e&&v.entries||p;if(_&&(f=sr(_.call(new t)))!==Object.prototype&&f.next&&(Ke(f,l,!0),Fe||"function"==typeof f[lr]||Y(f,lr,dr)),h&&p&&"values"!==p.name&&(d=!0,y=function(){return p.call(this)}),Fe&&!u||!hr&&!d&&v[lr]||Y(v,lr,y),dn[e]=y,dn[l]=dr,o)if(a={values:h?y:s("values"),keys:i?y:s("keys"),entries:g},u)for(c in a)c in v||it(v,c,a[c]);else Xe(Xe.P+Xe.F*(hr||d),e,a);return a},pr=Object.freeze({default:vr,__moduleExports:vr}),yr=nr&&er||nr,gr=or&&rr||or,_r=pr&&vr||pr,mr=_r(Array,"Array",function(t,e){this._t=$t(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return t&&t.length>n?gr(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]]):(this._t=void 0,gr(1))},"values");dn.Arguments=dn.Array,yr("keys"),yr("values"),yr("entries");var br=ze("iterator"),Er=!1;try{[7][br]().return=function(){Er=!0}}catch(t){}var Or=function(t,e){if(!e&&!Er)return!1;var n=!1;try{var r=[7],o=r[br]();o.next=function(){return{done:n=!0}},r[br]=function(){return o},t(r)}catch(t){}return n},jr=Object.freeze({default:Or,__moduleExports:Or}),wr=[].copyWithin||function(t,e){var n=we(this),r=kt(n.length),o=Qt(t,r),i=Qt(e,r),u=arguments.length>2?arguments[2]:void 0,a=Math.min((void 0===u?r:Qt(u,r))-i,r-o),c=1;for(o>i&&i+a>o&&(c=-1,i+=a-1,o+=a-1);a-- >0;)i in n?n[o]=n[i]:delete n[o],o+=c,i+=c;return n},xr=Object.freeze({default:wr,__moduleExports:wr}),Sr={}.propertyIsEnumerable,Ar={f:Sr},Mr=Object.freeze({default:Ar,__moduleExports:Ar,f:Sr}),zr=Mr&&Ar||Mr,Nr=Object.getOwnPropertyDescriptor,Pr=O?Nr:function(t,e){if(t=$t(t),e=N(e,!0),z)try{return Nr(t,e)}catch(t){}if(q(t,e))return C(!zr.f.call(t,e),t[e])},kr={f:Pr},Lr=Object.freeze({default:kr,__moduleExports:kr,f:Pr}),Fr=gn&&yn||gn,Ir=Un&&Wn||Un,Rr=Qn&&$n||Qn,Tr=jr&&Or||jr,Cr=xr&&wr||xr,Wr=Lr&&kr||Lr,Ur=n(function(t){if(O){var e=Fe,n=g,r=v,o=Xe,i=Ie,u=ut,a=Te,c=C,s=Y,l=Re,h=Mt,d=kt,p=Ce,y=Qt,_=N,m=q,b=Tn,E=f,j=we,w=Fr,x=ir,S=sr,A=We.f,M=Ir,z=X,P=ze,k=Rr,L=ce,F=Qe,I=mr,R=dn,W=Tr,U=Ze,K=Ue,B=Cr,D=T,V=Wr,G=D.f,J=V.f,H=n.RangeError,$=n.TypeError,Q=n.Uint8Array,Z=Array.prototype,tt=$e.ArrayBuffer,et=$e.DataView,nt=k(0),rt=k(2),ot=k(3),it=k(4),at=k(5),ct=k(6),ft=L(!0),st=L(!1),lt=I.values,ht=I.keys,dt=I.entries,vt=Z.lastIndexOf,pt=Z.reduce,yt=Z.reduceRight,gt=Z.join,_t=Z.sort,mt=Z.slice,bt=Z.toString,Et=Z.toLocaleString,Ot=P("iterator"),jt=P("toStringTag"),wt=z("typed_constructor"),xt=z("def_constructor"),St=i.CONSTR,At=i.TYPED,zt=i.VIEW,Nt=k(1,function(t,e){return Rt(F(t,t[xt]),e)}),Pt=r(function(){return 1===new Q(new Uint16Array([1]).buffer)[0]}),Lt=!!Q&&!!Q.prototype.set&&r(function(){new Q(1).set({})}),Ft=function(t,e){var n=h(t);if(0>n||n%e)throw H("Wrong offset!");return n},It=function(t){if(E(t)&&At in t)return t;throw $(t+" is not a typed array!")},Rt=function(t,e){if(!(E(t)&&wt in t))throw $("It is not a typed array constructor!");return new t(e)},Tt=function(t,e){return Ct(F(t,t[xt]),e)},Ct=function(t,e){for(var n=0,r=e.length,o=Rt(t,r);r>n;)o[n]=e[n++];return o},Wt=function(t,e,n){G(t,e,{get:function(){return this._d[n]}})},Ut=function(t){var e,n,r,o,i,a,c=j(t),f=arguments.length,s=f>1?arguments[1]:void 0,l=void 0!==s,h=M(c);if(void 0!=h&&!w(h)){for(a=h.call(c),r=[],e=0;!(i=a.next()).done;e++)r.push(i.value);c=r}for(l&&f>2&&(s=u(s,arguments[2],2)),e=0,n=d(c.length),o=Rt(this,n);n>e;e++)o[e]=l?s(c[e],e):c[e];return o},Kt=function(){for(var t=0,e=arguments.length,n=Rt(this,e);e>t;)n[t]=arguments[t++];return n},Bt=!!Q&&r(function(){Et.call(new Q(1))}),Dt=function(){return Et.apply(Bt?mt.call(It(this)):It(this),arguments)},Vt={copyWithin:function(t,e){return B.call(It(this),t,e,arguments.length>2?arguments[2]:void 0)},every:function(t){return it(It(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return K.apply(It(this),arguments)},filter:function(t){return Tt(this,rt(It(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return at(It(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return ct(It(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){nt(It(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return st(It(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return ft(It(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return gt.apply(It(this),arguments)},lastIndexOf:function(t){return vt.apply(It(this),arguments)},map:function(t){return Nt(It(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return pt.apply(It(this),arguments)},reduceRight:function(t){return yt.apply(It(this),arguments)},reverse:function(){for(var t,e=It(this).length,n=Math.floor(e/2),r=0;n>r;)t=this[r],this[r++]=this[--e],this[e]=t;return this},some:function(t){return ot(It(this),t,arguments.length>1?arguments[1]:void 0)},sort:function(t){return _t.call(It(this),t)},subarray:function(t,e){var n=It(this),r=n.length,o=y(t,r);return new(F(n,n[xt]))(n.buffer,n.byteOffset+o*n.BYTES_PER_ELEMENT,d((void 0===e?r:y(e,r))-o))}},Gt=function(t,e){return Tt(this,mt.call(It(this),t,e))},Jt=function(t){It(this);var e=Ft(arguments[1],1),n=this.length,r=j(t),o=d(r.length),i=0;if(o+e>n)throw H("Wrong length!");for(;o>i;)this[e+i]=r[i++]},Ht={entries:function(){return dt.call(It(this))},keys:function(){return ht.call(It(this))},values:function(){return lt.call(It(this))}},Yt=function(t,e){return E(t)&&t[At]&&"symbol"!=typeof e&&e in t&&+e+""==e+""},qt=function(t,e){return Yt(t,e=_(e,!0))?c(2,t[e]):J(t,e)},Xt=function(t,e,n){return!(Yt(t,e=_(e,!0))&&E(n)&&m(n,"value"))||m(n,"get")||m(n,"set")||n.configurable||m(n,"writable")&&!n.writable||m(n,"enumerable")&&!n.enumerable?G(t,e,n):(t[e]=n.value,t)};St||(V.f=qt,D.f=Xt),o(o.S+o.F*!St,"Object",{getOwnPropertyDescriptor:qt,defineProperty:Xt}),r(function(){bt.call({})})&&(bt=Et=function(){return gt.call(this)});var $t=l({},Vt);l($t,Ht),s($t,Ot,Ht.values),l($t,{slice:Gt,set:Jt,constructor:function(){},toString:bt,toLocaleString:Dt}),Wt($t,"buffer","b"),Wt($t,"byteOffset","o"),Wt($t,"byteLength","l"),Wt($t,"length","e"),G($t,jt,{get:function(){return this[At]}}),t.exports=function(t,u,c,f){var l=t+((f=!!f)?"Clamped":"")+"Array",h="get"+t,v="set"+t,y=n[l],g=y||{},_=y&&S(y),m={},O=y&&y.prototype,j=function(t,e){G(t,e,{get:function(){return function(t,e){var n=t._d;return n.v[h](e*u+n.o,Pt)}(this,e)},set:function(t){return function(t,e,n){var r=t._d;f&&(n=0>(n=Math.round(n))?0:n>255?255:255&n),r.v[v](e*u+r.o,n,Pt)}(this,e,t)},enumerable:!0})};!y||!i.ABV?(y=c(function(t,e,n,r){a(t,y,l,"_d");var o,i,c,f,h=0,v=0;if(E(e)){if(!(e instanceof tt||"ArrayBuffer"==(f=b(e))||"SharedArrayBuffer"==f))return At in e?Ct(y,e):Ut.call(y,e);o=e,v=Ft(n,u);var g=e.byteLength;if(void 0===r){if(g%u)throw H("Wrong length!");if(0>(i=g-v))throw H("Wrong length!")}else if((i=d(r)*u)+v>g)throw H("Wrong length!");c=i/u}else c=p(e),o=new tt(i=c*u);for(s(t,"_d",{b:o,o:v,l:i,e:c,v:new et(o)});c>h;)j(t,h++)}),O=y.prototype=x($t),s(O,"constructor",y)):r(function(){y(1)})&&r(function(){new y(-1)})&&W(function(t){new y,new y(null),new y(1.5),new y(t)},!0)||(y=c(function(t,e,n,r){var o;return a(t,y,l),E(e)?e instanceof tt||"ArrayBuffer"==(o=b(e))||"SharedArrayBuffer"==o?void 0!==r?new g(e,Ft(n,u),r):void 0!==n?new g(e,Ft(n,u)):new g(e):At in e?Ct(y,e):Ut.call(y,e):new g(p(e))}),nt(_!==Function.prototype?A(g).concat(A(_)):A(g),function(t){t in y||s(y,t,g[t])}),y.prototype=O,e||(O.constructor=y));var w=O[Ot],M=!!w&&("values"==w.name||void 0==w.name),z=Ht.values;s(y,wt,!0),s(O,At,l),s(O,zt,!0),s(O,xt,y),(f?new y(1)[jt]==l:jt in O)||G(O,jt,{get:function(){return l}}),m[l]=y,o(o.G+o.W+o.F*(y!=g),m),o(o.S,l,{BYTES_PER_ELEMENT:u}),o(o.S+o.F*r(function(){g.of.call(y,1)}),l,{from:Ut,of:Kt}),"BYTES_PER_ELEMENT"in O||s(O,"BYTES_PER_ELEMENT",u),o(o.P,l,Vt),U(l),o(o.P+o.F*Lt,l,{set:Jt}),o(o.P+o.F*!M,l,Ht),e||O.toString==bt||(O.toString=bt),o(o.P+o.F*r(function(){new y(1).slice()}),l,{slice:Gt}),o(o.P+o.F*(r(function(){return[1,2].toLocaleString()!=new y([1,2]).toLocaleString()})||!r(function(){O.toLocaleString.call([1,2])})),l,{toLocaleString:Dt}),R[l]=M?w:z,e||M||s(O,Ot,z)}}else t.exports=function(){}}),Kr=Object.freeze({default:Ur,__moduleExports:Ur}),Br=Kr&&Ur||Kr;Br("Int8",1,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Uint8",1,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Uint8",1,function(t){return function(e,n,r){return t(this,e,n,r)}},!0),Br("Int16",2,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Uint16",2,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Int32",4,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Uint32",4,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Float32",4,function(t){return function(e,n,r){return t(this,e,n,r)}}),Br("Float64",8,function(t){return function(e,n,r){return t(this,e,n,r)}});var Dr=function(t,e,n,r){try{return r?e(M(n)[0],n[1]):e(n)}catch(e){var o=t.return;throw void 0!==o&&M(o.call(t)),e}},Vr=Object.freeze({default:Dr,__moduleExports:Dr}),Gr=Vr&&Dr||Vr,Jr=n(function(t){var e={},n={},r=t.exports=function(t,r,o,i,u){var a,c,f,s,l=u?function(){return t}:Ir(t),h=ut(o,i,r?2:1),d=0;if("function"!=typeof l)throw TypeError(t+" is not iterable!");if(Fr(l)){for(a=kt(t.length);a>d;d++)if((s=r?h(M(c=t[d])[0],c[1]):h(t[d]))===e||s===n)return s}else for(f=l.call(t);!(c=f.next()).done;)if((s=Gr(f,h,c.value,r))===e||s===n)return s};r.BREAK=e,r.RETURN=n}),Hr=Object.freeze({default:Jr,__moduleExports:Jr}),Yr=n(function(t){var e=X("meta"),n=T.f,r=0,o=Object.isExtensible||function(){return!0},i=!v(function(){return o(Object.preventExtensions({}))}),u=function(t){n(t,e,{value:{i:"O"+ ++r,w:{}}})},a=t.exports={KEY:e,NEED:!1,fastKey:function(t,n){if(!f(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!q(t,e)){if(!o(t))return"F";if(!n)return"E";u(t)}return t[e].i},getWeak:function(t,n){if(!q(t,e)){if(!o(t))return!0;if(!n)return!1;u(t)}return t[e].w},onFreeze:function(t){return i&&a.NEED&&o(t)&&!q(t,e)&&u(t),t}}}),qr=Object.freeze({default:Yr,__moduleExports:Yr,KEY:Yr.KEY,NEED:Yr.NEED,fastKey:Yr.fastKey,getWeak:Yr.getWeak,onFreeze:Yr.onFreeze}),Xr=function(t,e){if(!f(t)||t._t!==e)throw TypeError("Incompatible receiver, "+e+" required!");return t},$r=Object.freeze({default:Xr,__moduleExports:Xr}),Qr=Hr&&Jr||Hr,Zr=qr&&Yr||qr,to=$r&&Xr||$r,eo=T.f,no=Zr.fastKey,ro=O?"_s":"size",oo=function(t,e){var n,r=no(e);if("F"!==r)return t._i[r];for(n=t._f;n;n=n.n)if(n.k==e)return n},io={getConstructor:function(t,e,n,r){var o=t(function(t,i){Te(t,o,e,"_i"),t._t=e,t._i=ir(null),t._f=void 0,t._l=void 0,t[ro]=0,void 0!=i&&Qr(i,n,t[r],t)});return Re(o.prototype,{clear:function(){for(var t=to(this,e),n=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];t._f=t._l=void 0,t[ro]=0},delete:function(t){var n=to(this,e),r=oo(n,t);if(r){var o=r.n,i=r.p;delete n._i[r.i],r.r=!0,i&&(i.n=o),o&&(o.p=i),n._f==r&&(n._f=o),n._l==r&&(n._l=i),n[ro]--}return!!r},forEach:function(t){to(this,e);for(var n,r=ut(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(t){return!!oo(to(this,e),t)}}),O&&eo(o.prototype,"size",{get:function(){return to(this,e)[ro]}}),o},def:function(t,e,n){var r,o,i=oo(t,e);return i?i.v=n:(t._l=i={i:o=no(e,!0),k:e,v:n,p:r=t._l,n:void 0,r:!1},t._f||(t._f=i),r&&(r.n=i),t[ro]++,"F"!==o&&(t._i[o]=i)),t},getEntry:oo,setStrong:function(t,e,n){_r(t,e,function(t,n){this._t=to(t,e),this._k=n,this._l=void 0},function(){for(var t=this._k,e=this._l;e&&e.r;)e=e.p;return this._t&&(this._l=e=e?e.n:this._t._f)?gr(0,"keys"==t?e.k:"values"==t?e.v:[e.k,e.v]):(this._t=void 0,gr(1))},n?"entries":"values",!n,!0),Ze(e)}},uo=Object.freeze({default:io,__moduleExports:io,getConstructor:io.getConstructor,def:io.def,getEntry:io.getEntry,setStrong:io.setStrong}),ao=function(t,e){if(M(t),!f(e)&&null!==e)throw TypeError(e+": can't set as prototype!")},co={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,n){try{(n=ut(Function.call,Wr.f(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,r){return ao(t,r),e?t.__proto__=r:n(t,r),t}}({},!1):void 0),check:ao},fo=Object.freeze({default:co,__moduleExports:co,set:co.set,check:co.check}),so=fo&&co||fo,lo=so.set,ho=function(t,e,n){var r,o=e.constructor;return o!==n&&"function"==typeof o&&(r=o.prototype)!==n.prototype&&f(r)&&lo&&lo(t,r),t},vo=Object.freeze({default:ho,__moduleExports:ho}),po=vo&&ho||vo,yo=function(t,e,n,r,o,i){var u=g[t],a=u,c=o?"set":"add",s=a&&a.prototype,l={},h=function(t){var e=s[t];it(s,t,"delete"==t?function(t){return!(i&&!f(t))&&e.call(this,0===t?0:t)}:"has"==t?function(t){return!(i&&!f(t))&&e.call(this,0===t?0:t)}:"get"==t?function(t){return i&&!f(t)?void 0:e.call(this,0===t?0:t)}:"add"==t?function(t){return e.call(this,0===t?0:t),this}:function(t,n){return e.call(this,0===t?0:t,n),this})};if("function"==typeof a&&(i||s.forEach&&!v(function(){(new a).entries().next()}))){var d=new a,p=d[c](i?{}:-0,1)!=d,y=v(function(){d.has(1)}),_=Tr(function(t){new a(t)}),m=!i&&v(function(){for(var t=new a,e=5;e--;)t[c](e,e);return!t.has(-0)});_||((a=e(function(e,n){Te(e,a,t);var r=po(new u,e,a);return void 0!=n&&Qr(n,o,r[c],r),r})).prototype=s,s.constructor=a),(y||m)&&(h("delete"),h("has"),o&&h("get")),(m||p)&&h(c),i&&s.clear&&delete s.clear}else a=r.getConstructor(e,t,o,c),Re(a.prototype,n),Zr.NEED=!0;return Ke(a,t),l[t]=a,Xe(Xe.G+Xe.W+Xe.F*(a!=u),l),i||r.setStrong(a,t,o),a},go=Object.freeze({default:yo,__moduleExports:yo}),_o=uo&&io||uo,mo=go&&yo||go,bo=(mo("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{get:function(t){var e=_o.getEntry(to(this,"Map"),t);return e&&e.v},set:function(t,e){return _o.def(to(this,"Map"),0===t?0:t,e)}},_o,!0),mo("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return _o.def(to(this,"Set"),t=0===t?0:t,t)}},_o),Object.getOwnPropertySymbols),Eo={f:bo},Oo=Object.freeze({default:Eo,__moduleExports:Eo,f:bo}),jo=Oo&&Eo||Oo,wo=Object.assign,xo=!wo||v(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=wo({},t)[n]||Object.keys(wo({},e)).join("")!=r})?function(t,e){for(var n=we(t),r=arguments.length,o=1,i=jo.f,u=zr.f;r>o;)for(var a,c=Dt(arguments[o++]),f=i?bn(c).concat(i(c)):bn(c),s=f.length,l=0;s>l;)u.call(c,a=f[l++])&&(n[a]=c[a]);return n}:wo,So=Object.freeze({default:xo,__moduleExports:xo}),Ao=Zr.getWeak,Mo=Rr(5),zo=Rr(6),No=0,Po=function(t){return t._l||(t._l=new ko)},ko=function(){this.a=[]},Lo=function(t,e){return Mo(t.a,function(t){return t[0]===e})};ko.prototype={get:function(t){var e=Lo(this,t);if(e)return e[1]},has:function(t){return!!Lo(this,t)},set:function(t,e){var n=Lo(this,t);n?n[1]=e:this.a.push([t,e])},delete:function(t){var e=zo(this.a,function(e){return e[0]===t});return~e&&this.a.splice(e,1),!!~e}};var Fo={getConstructor:function(t,e,n,r){var o=t(function(t,i){Te(t,o,e,"_i"),t._t=e,t._i=No++,t._l=void 0,void 0!=i&&Qr(i,n,t[r],t)});return Re(o.prototype,{delete:function(t){if(!f(t))return!1;var n=Ao(t);return!0===n?Po(to(this,e)).delete(t):n&&q(n,this._i)&&delete n[this._i]},has:function(t){if(!f(t))return!1;var n=Ao(t);return!0===n?Po(to(this,e)).has(t):n&&q(n,this._i)}}),o},def:function(t,e,n){var r=Ao(M(e),!0);return!0===r?Po(t).set(e,n):r[t._i]=n,t},ufstore:Po},Io=Object.freeze({default:Fo,__moduleExports:Fo,getConstructor:Fo.getConstructor,def:Fo.def,ufstore:Fo.ufstore}),Ro=So&&xo||So,To=Io&&Fo||Io;n(function(t){var e,n=Rr(0),r=Zr.getWeak,o=Object.isExtensible,i=To.ufstore,u={},a=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},c={get:function(t){if(f(t)){var e=r(t);return!0===e?i(to(this,"WeakMap")).get(t):e?e[this._i]:void 0}},set:function(t,e){return To.def(to(this,"WeakMap"),t,e)}},s=t.exports=mo("WeakMap",a,c,To,!0,!0);v(function(){return 7!=(new s).set((Object.freeze||Object)(u),7).get(u)})&&(e=To.getConstructor(a,"WeakMap"),Ro(e.prototype,c),Zr.NEED=!0,n(["delete","has","get","set"],function(t){var n=s.prototype,r=n[t];it(n,t,function(n,i){if(f(n)&&!o(n)){this._f||(this._f=new e);var u=this._f[t](n,i);return"set"==t?this:u}return r.call(this,n,i)})}))});mo("WeakSet",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},{add:function(t){return To.def(to(this,"WeakSet"),t,!0)}},To,!1,!0);var Co=(g.Reflect||{}).apply,Wo=Function.apply;Xe(Xe.S+Xe.F*!v(function(){Co(function(){})}),"Reflect",{apply:function(t,e,n){var r=nt(t),o=M(n);return Co?Co(r,e,o):Wo.call(r,e,o)}});var Uo=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)},Ko=Object.freeze({default:Uo,__moduleExports:Uo}),Bo=Ko&&Uo||Ko,Do=[].slice,Vo={},Go=Function.bind||function(t){var e=nt(this),n=Do.call(arguments,1),r=function(){var o=n.concat(Do.call(arguments));return this instanceof r?function(t,e,n){if(!(e in Vo)){for(var r=[],o=0;e>o;o++)r[o]="a["+o+"]";Vo[e]=Function("F,a","return new F("+r.join(",")+")")}return Vo[e](t,n)}(e,o.length,o):Bo(e,o,t)};return f(e.prototype)&&(r.prototype=e.prototype),r},Jo=Object.freeze({default:Go,__moduleExports:Go}),Ho=Jo&&Go||Jo,Yo=(g.Reflect||{}).construct,qo=v(function(){function t(){}return!(Yo(function(){},[],t)instanceof t)}),Xo=!v(function(){Yo(function(){})});Xe(Xe.S+Xe.F*(qo||Xo),"Reflect",{construct:function(t,e){nt(t),M(e);var n=3>arguments.length?t:nt(arguments[2]);if(Xo&&!qo)return Yo(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(Ho.apply(t,r))}var o=n.prototype,i=ir(f(o)?o:Object.prototype),u=Function.apply.call(t,i,e);return f(u)?u:i}}),Xe(Xe.S+Xe.F*v(function(){Reflect.defineProperty(T.f({},1,{value:1}),1,{value:2})}),"Reflect",{defineProperty:function(t,e,n){M(t),e=N(e,!0),M(n);try{return T.f(t,e,n),!0}catch(t){return!1}}});var $o=Wr.f;Xe(Xe.S,"Reflect",{deleteProperty:function(t,e){var n=$o(M(t),e);return!(n&&!n.configurable)&&delete t[e]}}),Xe(Xe.S,"Reflect",{get:function t(e,n){var r,o,i=3>arguments.length?e:arguments[2];return M(e)===i?e[n]:(r=Wr.f(e,n))?q(r,"value")?r.value:void 0!==r.get?r.get.call(i):void 0:f(o=sr(e))?t(o,n,i):void 0}}),Xe(Xe.S,"Reflect",{getOwnPropertyDescriptor:function(t,e){return Wr.f(M(t),e)}}),Xe(Xe.S,"Reflect",{getPrototypeOf:function(t){return sr(M(t))}}),Xe(Xe.S,"Reflect",{has:function(t,e){return e in t}});var Qo=Object.isExtensible;Xe(Xe.S,"Reflect",{isExtensible:function(t){return M(t),!Qo||Qo(t)}});var Zo=g.Reflect,ti=Zo&&Zo.ownKeys||function(t){var e=We.f(M(t)),n=jo.f;return n?e.concat(n(t)):e},ei=Object.freeze({default:ti,__moduleExports:ti}),ni=ei&&ti||ei;Xe(Xe.S,"Reflect",{ownKeys:ni});var ri=Object.preventExtensions;Xe(Xe.S,"Reflect",{preventExtensions:function(t){M(t);try{return ri&&ri(t),!0}catch(t){return!1}}}),Xe(Xe.S,"Reflect",{set:function t(e,n,r){var o,i,u=4>arguments.length?e:arguments[3],a=Wr.f(M(e),n);if(!a){if(f(i=sr(e)))return t(i,n,r,u);a=C(0)}if(q(a,"value")){if(!1===a.writable||!f(u))return!1;if(o=Wr.f(u,n)){if(o.get||o.set||!1===o.writable)return!1;o.value=r,T.f(u,n,o)}else T.f(u,n,C(0,r));return!0}return void 0!==a.set&&(a.set.call(u,r),!0)}}),so&&Xe(Xe.S,"Reflect",{setPrototypeOf:function(t,e){so.check(t,e);try{return so.set(t,e),!0}catch(t){return!1}}});var oi,ii,ui,ai=g.process,ci=g.setImmediate,fi=g.clearImmediate,si=g.MessageChannel,li=g.Dispatch,hi=0,di={},vi=function(){var t=+this;if(di.hasOwnProperty(t)){var e=di[t];delete di[t],e()}},pi=function(t){vi.call(t.data)};ci&&fi||(ci=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return di[++hi]=function(){Bo("function"==typeof t?t:Function(t),e)},oi(hi),hi},fi=function(t){delete di[t]},"process"==Ct(ai)?oi=function(t){ai.nextTick(ut(vi,t,1))}:li&&li.now?oi=function(t){li.now(ut(vi,t,1))}:si?(ui=(ii=new si).port2,ii.port1.onmessage=pi,oi=ut(ui.postMessage,ui,1)):g.addEventListener&&"function"==typeof postMessage&&!g.importScripts?(oi=function(t){g.postMessage(t+"","*")},g.addEventListener("message",pi,!1)):oi="onreadystatechange"in j("script")?function(t){An.appendChild(j("script")).onreadystatechange=function(){An.removeChild(this),vi.call(t)}}:function(t){setTimeout(ut(vi,t,1),0)});var yi={set:ci,clear:fi},gi=Object.freeze({default:yi,__moduleExports:yi,set:yi.set,clear:yi.clear}),_i=gi&&yi||gi,mi=_i.set,bi=g.MutationObserver||g.WebKitMutationObserver,Ei=g.process,Oi=g.Promise,ji="process"==Ct(Ei),wi=function(){var t,e,n,r=function(){var r,o;for(ji&&(r=Ei.domain)&&r.exit();t;){o=t.fn,t=t.next;try{o()}catch(r){throw t?n():e=void 0,r}}e=void 0,r&&r.enter()};if(ji)n=function(){Ei.nextTick(r)};else if(!bi||g.navigator&&g.navigator.standalone)if(Oi&&Oi.resolve){var o=Oi.resolve();n=function(){o.then(r)}}else n=function(){mi.call(g,r)};else{var i=!0,u=document.createTextNode("");new bi(r).observe(u,{characterData:!0}),n=function(){u.data=i=!i}}return function(r){var o={fn:r,next:void 0};e&&(e.next=o),t||(t=o,n()),e=o}},xi=Object.freeze({default:wi,__moduleExports:wi});var Si,Ai,Mi,zi,Ni=function(t){return new function(t){var e,n;this.promise=new t(function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r}),this.resolve=nt(e),this.reject=nt(n)}(t)},Pi={f:Ni},ki=Object.freeze({default:Pi,__moduleExports:Pi,f:Ni}),Li=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}},Fi=Object.freeze({default:Li,__moduleExports:Li}),Ii=ki&&Pi||ki,Ri=function(t,e){if(M(t),f(e)&&e.constructor===t)return e;var n=Ii.f(t);return(0,n.resolve)(e),n.promise},Ti=Object.freeze({default:Ri,__moduleExports:Ri}),Ci=Fi&&Li||Fi,Wi=Ti&&Ri||Ti,Ui=_i.set,Ki=(xi&&wi||xi)(),Bi=g.TypeError,Di=g.process,Vi=g.Promise,Gi="process"==Tn(Di),Ji=function(){},Hi=Ai=Ii.f,Yi=!!function(){try{var t=Vi.resolve(1),e=(t.constructor={})[ze("species")]=function(t){t(Ji,Ji)};return(Gi||"function"==typeof PromiseRejectionEvent)&&t.then(Ji)instanceof e}catch(t){}}(),qi=function(t){var e;return!(!f(t)||"function"!=typeof(e=t.then))&&e},Xi=function(t,e){if(!t._n){t._n=!0;var n=t._c;Ki(function(){for(var r=t._v,o=1==t._s,i=0,u=function(e){var n,i,u,a=o?e.ok:e.fail,c=e.resolve,f=e.reject,s=e.domain;try{a?(o||(2==t._h&&Zi(t),t._h=1),!0===a?n=r:(s&&s.enter(),n=a(r),s&&(s.exit(),u=!0)),n===e.promise?f(Bi("Promise-chain cycle")):(i=qi(n))?i.call(n,c,f):c(n)):f(r)}catch(t){s&&!u&&s.exit(),f(t)}};n.length>i;)u(n[i++]);t._c=[],t._n=!1,e&&!t._h&&$i(t)})}},$i=function(t){Ui.call(g,function(){var e,n,r,o=t._v,i=Qi(t);if(i&&(e=Ci(function(){Gi?Di.emit("unhandledRejection",o,t):(n=g.onunhandledrejection)?n({promise:t,reason:o}):(r=g.console)&&r.error&&r.error("Unhandled promise rejection",o)}),t._h=Gi||Qi(t)?2:1),t._a=void 0,i&&e.e)throw e.v})},Qi=function(t){return 1!==t._h&&0===(t._a||t._c).length},Zi=function(t){Ui.call(g,function(){var e;Gi?Di.emit("rejectionHandled",t):(e=g.onrejectionhandled)&&e({promise:t,reason:t._v})})},tu=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),Xi(e,!0))},eu=function(t){var e,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===t)throw Bi("Promise can't be resolved itself");(e=qi(t))?Ki(function(){var r={_w:n,_d:!1};try{e.call(t,ut(eu,r,1),ut(tu,r,1))}catch(t){tu.call(r,t)}}):(n._v=t,n._s=1,Xi(n,!1))}catch(t){tu.call({_w:n,_d:!1},t)}}};Yi||(Vi=function(t){Te(this,Vi,"Promise","_h"),nt(t),Si.call(this);try{t(ut(eu,this,1),ut(tu,this,1))}catch(t){tu.call(this,t)}},(Si=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=Re(Vi.prototype,{then:function(t,e){var n=Hi(Qe(this,Vi));return n.ok="function"!=typeof t||t,n.fail="function"==typeof e&&e,n.domain=Gi?Di.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&Xi(this,!1),n.promise},catch:function(t){return this.then(void 0,t)}}),Mi=function(){var t=new Si;this.promise=t,this.resolve=ut(eu,t,1),this.reject=ut(tu,t,1)},Ii.f=Hi=function(t){return t===Vi||t===zi?new Mi(t):Ai(t)}),Xe(Xe.G+Xe.W+Xe.F*!Yi,{Promise:Vi}),Ke(Vi,"Promise"),Ze("Promise"),zi=$.Promise,Xe(Xe.S+Xe.F*!Yi,"Promise",{reject:function(t){var e=Hi(this);return(0,e.reject)(t),e.promise}}),Xe(Xe.S+Xe.F*(Fe||!Yi),"Promise",{resolve:function(t){return Wi(Fe&&this===zi?Vi:this,t)}}),Xe(Xe.S+Xe.F*!(Yi&&Tr(function(t){Vi.all(t).catch(Ji)})),"Promise",{all:function(t){var e=this,n=Hi(e),r=n.resolve,o=n.reject,i=Ci(function(){var n=[],i=0,u=1;Qr(t,!1,function(t){var a=i++,c=!1;n.push(void 0),u++,e.resolve(t).then(function(t){c||(c=!0,n[a]=t,--u||r(n))},o)}),--u||r(n)});return i.e&&o(i.v),n.promise},race:function(t){var e=this,n=Hi(e),r=n.reject,o=Ci(function(){Qr(t,!1,function(t){e.resolve(t).then(n.resolve,r)})});return o.e&&r(o.v),n.promise}});var nu={f:ze},ru=Object.freeze({default:nu,__moduleExports:nu,f:ze}),ou=ru&&nu||ru,iu=T.f,uu=function(t){var e=$.Symbol||($.Symbol=Fe?{}:g.Symbol||{});"_"==t.charAt(0)||t in e||iu(e,t,{value:ou.f(t)})},au=Object.freeze({default:uu,__moduleExports:uu}),cu=function(t){var e=bn(t),n=jo.f;if(n)for(var r,o=n(t),i=zr.f,u=0;o.length>u;)i.call(t,r=o[u++])&&e.push(r);return e},fu=Object.freeze({default:cu,__moduleExports:cu}),su=We.f,lu={}.toString,hu="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],du=function(t){return hu&&"[object Window]"==lu.call(t)?function(t){try{return su(t)}catch(t){return hu.slice()}}(t):su($t(t))},vu={f:du},pu=Object.freeze({default:vu,__moduleExports:vu,f:du}),yu=au&&uu||au,gu=fu&&cu||fu,_u=pu&&vu||pu,mu=Zr.KEY,bu=Wr.f,Eu=T.f,Ou=_u.f,ju=g.Symbol,wu=g.JSON,xu=wu&&wu.stringify,Su=ze("_hidden"),Au=ze("toPrimitive"),Mu={}.propertyIsEnumerable,zu=oe("symbol-registry"),Nu=oe("symbols"),Pu=oe("op-symbols"),ku=Object.prototype,Lu="function"==typeof ju,Fu=g.QObject,Iu=!Fu||!Fu.prototype||!Fu.prototype.findChild,Ru=O&&v(function(){return 7!=ir(Eu({},"a",{get:function(){return Eu(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=bu(ku,e);r&&delete ku[e],Eu(t,e,n),r&&t!==ku&&Eu(ku,e,r)}:Eu,Tu=function(t){var e=Nu[t]=ir(ju.prototype);return e._k=t,e},Cu=Lu&&"symbol"==typeof ju.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof ju},Wu=function(t,e,n){return t===ku&&Wu(Pu,e,n),M(t),e=N(e,!0),M(n),q(Nu,e)?(n.enumerable?(q(t,Su)&&t[Su][e]&&(t[Su][e]=!1),n=ir(n,{enumerable:C(0,!1)})):(q(t,Su)||Eu(t,Su,C(1,{})),t[Su][e]=!0),Ru(t,e,n)):Eu(t,e,n)},Uu=function(t,e){M(t);for(var n,r=gu(e=$t(e)),o=0,i=r.length;i>o;)Wu(t,n=r[o++],e[n]);return t},Ku=function(t){var e=Mu.call(this,t=N(t,!0));return!(this===ku&&q(Nu,t)&&!q(Pu,t))&&(!(e||!q(this,t)||!q(Nu,t)||q(this,Su)&&this[Su][t])||e)},Bu=function(t,e){if(t=$t(t),e=N(e,!0),t!==ku||!q(Nu,e)||q(Pu,e)){var n=bu(t,e);return!n||!q(Nu,e)||q(t,Su)&&t[Su][e]||(n.enumerable=!0),n}},Du=function(t){for(var e,n=Ou($t(t)),r=[],o=0;n.length>o;)q(Nu,e=n[o++])||e==Su||e==mu||r.push(e);return r},Vu=function(t){for(var e,n=t===ku,r=Ou(n?Pu:$t(t)),o=[],i=0;r.length>i;)!q(Nu,e=r[i++])||n&&!q(ku,e)||o.push(Nu[e]);return o};Lu||(it((ju=function(){if(this instanceof ju)throw TypeError("Symbol is not a constructor!");var t=X(arguments.length>0?arguments[0]:void 0),e=function(n){this===ku&&e.call(Pu,n),q(this,Su)&&q(this[Su],t)&&(this[Su][t]=!1),Ru(this,t,C(1,n))};return O&&Iu&&Ru(ku,t,{configurable:!0,set:e}),Tu(t)}).prototype,"toString",function(){return this._k}),Wr.f=Bu,T.f=Wu,We.f=_u.f=Du,zr.f=Ku,jo.f=Vu,O&&!Fe&&it(ku,"propertyIsEnumerable",Ku,!0),ou.f=function(t){return Tu(ze(t))}),Xe(Xe.G+Xe.W+Xe.F*!Lu,{Symbol:ju});for(var Gu="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Ju=0;Gu.length>Ju;)ze(Gu[Ju++]);for(var Hu=bn(ze.store),Yu=0;Hu.length>Yu;)yu(Hu[Yu++]);Xe(Xe.S+Xe.F*!Lu,"Symbol",{for:function(t){return q(zu,t+="")?zu[t]:zu[t]=ju(t)},keyFor:function(t){if(!Cu(t))throw TypeError(t+" is not a symbol!");for(var e in zu)if(zu[e]===t)return e},useSetter:function(){Iu=!0},useSimple:function(){Iu=!1}}),Xe(Xe.S+Xe.F*!Lu,"Object",{create:function(t,e){return void 0===e?ir(t):Uu(ir(t),e)},defineProperty:Wu,defineProperties:Uu,getOwnPropertyDescriptor:Bu,getOwnPropertyNames:Du,getOwnPropertySymbols:Vu}),wu&&Xe(Xe.S+Xe.F*(!Lu||v(function(){var t=ju();return"[null]"!=xu([t])||"{}"!=xu({a:t})||"{}"!=xu(Object(t))})),"JSON",{stringify:function(t){for(var e,n,r=[t],o=1;arguments.length>o;)r.push(arguments[o++]);if(n=e=r[1],(f(e)||void 0!==t)&&!Cu(t))return Dn(e)||(e=function(t,e){if("function"==typeof n&&(e=n.call(this,t,e)),!Cu(e))return e}),r[1]=e,xu.apply(wu,r)}}),ju.prototype[Au]||Y(ju.prototype,Au,ju.prototype.valueOf),Ke(ju,"Symbol"),Ke(Math,"Math",!0),Ke(g.JSON,"JSON",!0);var qu=function(t,e){var n=($.Object||{})[t]||Object[t],r={};r[t]=e(n),Xe(Xe.S+Xe.F*v(function(){n(1)}),"Object",r)},Xu=Object.freeze({default:qu,__moduleExports:qu}),$u=Xu&&qu||Xu,Qu=Zr.onFreeze;$u("freeze",function(t){return function(e){return t&&f(e)?t(Qu(e)):e}});var Zu=Zr.onFreeze;$u("seal",function(t){return function(e){return t&&f(e)?t(Zu(e)):e}});var ta=Zr.onFreeze;$u("preventExtensions",function(t){return function(e){return t&&f(e)?t(ta(e)):e}}),$u("isFrozen",function(t){return function(e){return!f(e)||!!t&&t(e)}}),$u("isSealed",function(t){return function(e){return!f(e)||!!t&&t(e)}}),$u("isExtensible",function(t){return function(e){return!!f(e)&&(!t||t(e))}});var ea=Wr.f;$u("getOwnPropertyDescriptor",function(){return function(t,e){return ea($t(t),e)}}),$u("getPrototypeOf",function(){return function(t){return sr(we(t))}}),$u("keys",function(){return function(t){return bn(we(t))}}),$u("getOwnPropertyNames",function(){return _u.f}),Xe(Xe.S+Xe.F,"Object",{assign:Ro});var na=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},ra=Object.freeze({default:na,__moduleExports:na});Xe(Xe.S,"Object",{is:ra&&na||ra}),Xe(Xe.S,"Object",{setPrototypeOf:so.set});var oa=Function.prototype,ia=/^\s*function ([^ (]*)/;"name"in oa||O&&(0,T.f)(oa,"name",{configurable:!0,get:function(){try{return(""+this).match(ia)[1]}catch(t){return""}}}),Xe(Xe.S,"String",{raw:function(t){for(var e=$t(t.raw),n=kt(e.length),r=arguments.length,o=[],i=0;n>i;)o.push(e[i++]+""),r>i&&o.push(arguments[i]+"");return o.join("")}});var ua=String.fromCharCode,aa=String.fromCodePoint;Xe(Xe.S+Xe.F*(!!aa&&1!=aa.length),"String",{fromCodePoint:function(t){for(var e,n=[],r=arguments.length,o=0;r>o;){if(e=+arguments[o++],Qt(e,1114111)!==e)throw RangeError(e+" is not a valid code point");n.push(65536>e?ua(e):ua(55296+((e-=65536)>>10),e%1024+56320))}return n.join("")}});var ca=function(t){return function(e,n){var r,o,i=Vt(e)+"",u=Mt(n),a=i.length;return 0>u||u>=a?t?"":void 0:55296>(r=i.charCodeAt(u))||r>56319||u+1===a||56320>(o=i.charCodeAt(u+1))||o>57343?t?i.charAt(u):r:t?i.slice(u,u+2):o-56320+(r-55296<<10)+65536}},fa=Object.freeze({default:ca,__moduleExports:ca}),sa=(fa&&ca||fa)(!1);Xe(Xe.P,"String",{codePointAt:function(t){return sa(this,t)}});var la=function(t){var e=Vt(this)+"",n="",r=Mt(t);if(0>r||r==1/0)throw RangeError("Count can't be negative");for(;r>0;(r>>>=1)&&(e+=e))1&r&&(n+=e);return n},ha=Object.freeze({default:la,__moduleExports:la}),da=ha&&la||ha;Xe(Xe.P,"String",{repeat:da});var va=ze("match"),pa=function(t){var e;return f(t)&&(void 0!==(e=t[va])?!!e:"RegExp"==Ct(t))},ya=Object.freeze({default:pa,__moduleExports:pa}),ga=ya&&pa||ya,_a=function(t,e,n){if(ga(e))throw TypeError("String#"+n+" doesn't accept regex!");return Vt(t)+""},ma=Object.freeze({default:_a,__moduleExports:_a}),ba=ze("match"),Ea=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[ba]=!1,!"/./"[t](e)}catch(t){}}return!0},Oa=Object.freeze({default:Ea,__moduleExports:Ea}),ja=ma&&_a||ma,wa=Oa&&Ea||Oa,xa="".startsWith;Xe(Xe.P+Xe.F*wa("startsWith"),"String",{startsWith:function(t){var e=ja(this,t,"startsWith"),n=kt(Math.min(arguments.length>1?arguments[1]:void 0,e.length)),r=t+"";return xa?xa.call(e,r,n):e.slice(n,n+r.length)===r}});var Sa="".endsWith;Xe(Xe.P+Xe.F*wa("endsWith"),"String",{endsWith:function(t){var e=ja(this,t,"endsWith"),n=arguments.length>1?arguments[1]:void 0,r=kt(e.length),o=void 0===n?r:Math.min(kt(n),r),i=t+"";return Sa?Sa.call(e,i,o):e.slice(o-i.length,o)===i}});Xe(Xe.P+Xe.F*wa("includes"),"String",{includes:function(t){return!!~ja(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0)}});var Aa=function(){var t=M(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},Ma=Object.freeze({default:Aa,__moduleExports:Aa});O&&"g"!=/./g.flags&&T.f(RegExp.prototype,"flags",{configurable:!0,get:Ma&&Aa||Ma});var za=function(t,e,n){var r=ze(t),o=n(Vt,r,""[t]),i=o[0],u=o[1];v(function(){var e={};return e[r]=function(){return 7},7!=""[t](e)})&&(it(String.prototype,t,i),Y(RegExp.prototype,r,2==e?function(t,e){return u.call(t,this,e)}:function(t){return u.call(t,this)}))},Na=Object.freeze({default:za,__moduleExports:za}),Pa=Na&&za||Na;Pa("match",1,function(t,e,n){return[function(n){var r=t(this),o=void 0==n?void 0:n[e];return void 0!==o?o.call(n,r):RegExp(n)[e](r+"")},n]}),Pa("replace",2,function(t,e,n){return[function(r,o){var i=t(this),u=void 0==r?void 0:r[e];return void 0!==u?u.call(r,i,o):n.call(i+"",r,o)},n]}),Pa("split",2,function(t,e,n){var r=ga,o=n,i=[].push;if("".split(/.?/).length){var u=void 0===/()??/.exec("")[1];n=function(t,e){var n=this+"";if(void 0===t&&0===e)return[];if(!r(t))return o.call(n,t,e);var a,c,f,s,l,h=[],d=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),v=0,p=void 0===e?4294967295:e>>>0,y=RegExp(t.source,d+"g");for(u||(a=RegExp("^"+y.source+"$(?!\\s)",d));(c=y.exec(n))&&((f=c.index+c[0].length)<=v||(h.push(n.slice(v,c.index)),!u&&c.length>1&&c[0].replace(a,function(){for(l=1;arguments.length-2>l;l++)void 0===arguments[l]&&(c[l]=void 0)}),c.length>1&&n.length>c.index&&i.apply(h,c.slice(1)),s=c[0].length,v=f,p>h.length));)y.lastIndex===c.index&&y.lastIndex++;return v===n.length?!s&&y.test("")||h.push(""):h.push(n.slice(v)),h.length>p?h.slice(0,p):h}}else 0;return[function(r,o){var i=t(this),u=void 0==r?void 0:r[e];return void 0!==u?u.call(r,i,o):n.call(i+"",r,o)},n]}),Pa("search",1,function(t,e,n){return[function(n){var r=t(this),o=void 0==n?void 0:n[e];return void 0!==o?o.call(n,r):RegExp(n)[e](r+"")},n]});var ka=function(t,e,n){e in t?T.f(t,e,C(0,n)):t[e]=n},La=Object.freeze({default:ka,__moduleExports:ka}),Fa=La&&ka||La;Xe(Xe.S+Xe.F*!Tr(function(t){}),"Array",{from:function(t){var e,n,r,o,i=we(t),u="function"==typeof this?this:Array,a=arguments.length,c=a>1?arguments[1]:void 0,f=void 0!==c,s=0,l=Ir(i);if(f&&(c=ut(c,a>2?arguments[2]:void 0,2)),void 0==l||u==Array&&Fr(l))for(n=new u(e=kt(i.length));e>s;s++)Fa(n,s,f?c(i[s],s):i[s]);else for(o=l.call(i),n=new u;!(r=o.next()).done;s++)Fa(n,s,f?Gr(o,c,[r.value,s],!0):r.value);return n.length=s,n}}),Xe(Xe.S+Xe.F*v(function(){function t(){}return!(Array.of.call(t)instanceof t)}),"Array",{of:function(){for(var t=0,e=arguments.length,n=new("function"==typeof this?this:Array)(e);e>t;)Fa(n,t,arguments[t++]);return n.length=e,n}}),Xe(Xe.P,"Array",{copyWithin:Cr}),yr("copyWithin");var Ia=Rr(5),Ra=!0;"find"in[]&&Array(1).find(function(){Ra=!1}),Xe(Xe.P+Xe.F*Ra,"Array",{find:function(t){return Ia(this,t,arguments.length>1?arguments[1]:void 0)}}),yr("find");var Ta=Rr(6),Ca=!0;"findIndex"in[]&&Array(1).findIndex(function(){Ca=!1}),Xe(Xe.P+Xe.F*Ca,"Array",{findIndex:function(t){return Ta(this,t,arguments.length>1?arguments[1]:void 0)}}),yr("findIndex"),Xe(Xe.P,"Array",{fill:Ue}),yr("fill");var Wa=g.isFinite;Xe(Xe.S,"Number",{isFinite:function(t){return"number"==typeof t&&Wa(t)}});var Ua=Math.floor,Ka=function(t){return!f(t)&&isFinite(t)&&Ua(t)===t},Ba=Object.freeze({default:Ka,__moduleExports:Ka}),Da=Ba&&Ka||Ba;Xe(Xe.S,"Number",{isInteger:Da});var Va=Math.abs;Xe(Xe.S,"Number",{isSafeInteger:function(t){return Da(t)&&9007199254740991>=Va(t)}}),Xe(Xe.S,"Number",{isNaN:function(t){return t!=t}}),Xe(Xe.S,"Number",{EPSILON:Math.pow(2,-52)}),Xe(Xe.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991}),Xe(Xe.S,"Number",{MAX_SAFE_INTEGER:9007199254740991});var Ga=Math.log1p||function(t){return(t=+t)>-1e-8&&1e-8>t?t-t*t/2:Math.log(1+t)},Ja=Object.freeze({default:Ga,__moduleExports:Ga}),Ha=Ja&&Ga||Ja,Ya=Math.sqrt,qa=Math.acosh;Xe(Xe.S+Xe.F*!(qa&&710==Math.floor(qa(Number.MAX_VALUE))&&qa(1/0)==1/0),"Math",{acosh:function(t){return 1>(t=+t)?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:Ha(t-1+Ya(t-1)*Ya(t+1))}});var Xa=Math.asinh;Xe(Xe.S+Xe.F*!(Xa&&1/Xa(0)>0),"Math",{asinh:function t(e){return isFinite(e=+e)&&0!=e?0>e?-t(-e):Math.log(e+Math.sqrt(e*e+1)):e}});var $a=Math.atanh;Xe(Xe.S+Xe.F*!($a&&0>1/$a(-0)),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}});var Qa=Math.sign||function(t){return 0==(t=+t)||t!=t?t:0>t?-1:1},Za=Object.freeze({default:Qa,__moduleExports:Qa}),tc=Za&&Qa||Za;Xe(Xe.S,"Math",{cbrt:function(t){return tc(t=+t)*Math.pow(Math.abs(t),1/3)}}),Xe(Xe.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}});var ec=Math.exp;Xe(Xe.S,"Math",{cosh:function(t){return(ec(t=+t)+ec(-t))/2}});var nc=Math.expm1,rc=!nc||nc(10)>22025.465794806718||22025.465794806718>nc(10)||-2e-17!=nc(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&1e-6>t?t+t*t/2:Math.exp(t)-1}:nc,oc=Object.freeze({default:rc,__moduleExports:rc}),ic=oc&&rc||oc;Xe(Xe.S+Xe.F*(ic!=Math.expm1),"Math",{expm1:ic});var uc=Math.pow,ac=uc(2,-52),cc=uc(2,-23),fc=uc(2,127)*(2-cc),sc=uc(2,-126),lc=Math.fround||function(t){var e,n,r=Math.abs(t),o=tc(t);return sc>r?o*(r/sc/cc+1/ac-1/ac)*sc*cc:(n=(e=(1+cc/ac)*r)-(e-r))>fc||n!=n?o*(1/0):o*n},hc=Object.freeze({default:lc,__moduleExports:lc});Xe(Xe.S,"Math",{fround:hc&&lc||hc});var dc=Math.abs;Xe(Xe.S,"Math",{hypot:function(t,e){for(var n,r,o=0,i=0,u=arguments.length,a=0;u>i;)(n=dc(arguments[i++]))>a?(o=o*(r=a/n)*r+1,a=n):o+=n>0?(r=n/a)*r:n;return a===1/0?1/0:a*Math.sqrt(o)}});var vc=Math.imul;Xe(Xe.S+Xe.F*v(function(){return-5!=vc(4294967295,5)||2!=vc.length}),"Math",{imul:function(t,e){var n=+t,r=+e,o=65535&n,i=65535&r;return 0|o*i+((65535&n>>>16)*i+o*(65535&r>>>16)<<16>>>0)}}),Xe(Xe.S,"Math",{log1p:Ha}),Xe(Xe.S,"Math",{log10:function(t){return Math.log(t)*Math.LOG10E}}),Xe(Xe.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}}),Xe(Xe.S,"Math",{sign:tc});var pc=Math.exp;Xe(Xe.S+Xe.F*v(function(){return-2e-17!=!Math.sinh(-2e-17)}),"Math",{sinh:function(t){return 1>Math.abs(t=+t)?(ic(t)-ic(-t))/2:(pc(t-1)-pc(-t-1))*(Math.E/2)}});var yc=Math.exp;Xe(Xe.S,"Math",{tanh:function(t){var e=ic(t=+t),n=ic(-t);return e==1/0?1:n==1/0?-1:(e-n)/(yc(t)+yc(-t))}}),Xe(Xe.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}});var gc=ce(!0);Xe(Xe.P,"Array",{includes:function(t){return gc(this,t,arguments.length>1?arguments[1]:void 0)}}),yr("includes");var _c=zr.f,mc=function(t){return function(e){for(var n,r=$t(e),o=bn(r),i=o.length,u=0,a=[];i>u;)_c.call(r,n=o[u++])&&a.push(t?[n,r[n]]:r[n]);return a}},bc=Object.freeze({default:mc,__moduleExports:mc}),Ec=bc&&mc||bc,Oc=Ec(!1);Xe(Xe.S,"Object",{values:function(t){return Oc(t)}});var jc=Ec(!0);Xe(Xe.S,"Object",{entries:function(t){return jc(t)}}),Xe(Xe.S,"Object",{getOwnPropertyDescriptors:function(t){for(var e,n,r=$t(t),o=Wr.f,i=ni(r),u={},a=0;i.length>a;)void 0!==(n=o(r,e=i[a++]))&&Fa(u,e,n);return u}});var wc=function(t,e,n,r){var o=Vt(t)+"",i=o.length,u=void 0===n?" ":n+"",a=kt(e);if(i>=a||""==u)return o;var c=a-i,f=da.call(u,Math.ceil(c/u.length));return f.length>c&&(f=f.slice(0,c)),r?f+o:o+f},xc=Object.freeze({default:wc,__moduleExports:wc}),Sc=g.navigator,Ac=Sc&&Sc.userAgent||"",Mc=Object.freeze({default:Ac,__moduleExports:Ac}),zc=xc&&wc||xc,Nc=Mc&&Ac||Mc;Xe(Xe.P+Xe.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(Nc),"String",{padStart:function(t){return zc(this,t,arguments.length>1?arguments[1]:void 0,!0)}}),Xe(Xe.P+Xe.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(Nc),"String",{padEnd:function(t){return zc(this,t,arguments.length>1?arguments[1]:void 0,!1)}});var Pc=[].slice,kc=function(t){return function(e,n){var r=arguments.length>2,o=!!r&&Pc.call(arguments,2);return t(r?function(){("function"==typeof e?e:Function(e)).apply(this,o)}:e,n)}};Xe(Xe.G+Xe.B+Xe.F*/MSIE .\./.test(Nc),{setTimeout:kc(g.setTimeout),setInterval:kc(g.setInterval)}),Xe(Xe.G+Xe.B,{setImmediate:_i.set,clearImmediate:_i.clear});for(var Lc=ze("iterator"),Fc=ze("toStringTag"),Ic=dn.Array,Rc={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},Tc=bn(Rc),Cc=0;Tc.length>Cc;Cc++){var Wc,Uc=Tc[Cc],Kc=Rc[Uc],Bc=g[Uc],Dc=Bc&&Bc.prototype;if(Dc&&(Dc[Lc]||Y(Dc,Lc,Ic),Dc[Fc]||Y(Dc,Fc,Uc),dn[Uc]=Ic,Kc))for(Wc in mr)Dc[Wc]||it(Dc,Wc,mr[Wc],!0)}n(function(t){!function(e){var n,r=Object.prototype,o=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag",f=e.regeneratorRuntime;if(f)t.exports=f;else{(f=e.regeneratorRuntime=t.exports).wrap=m;var s="suspendedStart",l="suspendedYield",h="executing",d="completed",v={},p={};p[u]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(N([])));g&&g!==r&&o.call(g,u)&&(p=g);var _=j.prototype=E.prototype=Object.create(p);O.prototype=_.constructor=j,j.constructor=O,j[c]=O.displayName="GeneratorFunction",f.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===O||"GeneratorFunction"===(e.displayName||e.name))},f.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,j):(t.__proto__=j,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(_),t},f.awrap=function(t){return{__await:t}},w(x.prototype),x.prototype[a]=function(){return this},f.AsyncIterator=x,f.async=function(t,e,n,r){var o=new x(m(t,e,n,r));return f.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},w(_),_[c]="Generator",_[u]=function(){return this},_.toString=function(){return"[object Generator]"},f.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},f.values=N,z.prototype={constructor:z,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,o){return a.type="throw",a.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return r("end");if(this.prev>=u.tryLoc){var c=o.call(u,"catchLoc"),f=o.call(u,"finallyLoc");if(c&&f){if(u.catchLoc>this.prev)return r(u.catchLoc,!0);if(u.finallyLoc>this.prev)return r(u.finallyLoc)}else if(c){if(u.catchLoc>this.prev)return r(u.catchLoc,!0)}else{if(!f)throw Error("try statement without catch or finally");if(u.finallyLoc>this.prev)return r(u.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(this.prev>=r.tryLoc&&o.call(r,"finallyLoc")&&r.finallyLoc>this.prev){var i=r;break}}!i||"break"!==t&&"continue"!==t||i.tryLoc>e||e>i.finallyLoc||(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),M(n),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;M(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:N(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),v}}}function m(t,e,n,r){var o=Object.create((e&&e.prototype instanceof E?e:E).prototype),i=new z(r||[]);return o._invoke=function(t,e,n){var r=s;return function(o,i){if(r===h)throw Error("Generator is already running");if(r===d){if("throw"===o)throw i;return P()}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var a=S(u,n);if(a){if(a===v)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===s)throw r=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var c=b(t,e,n);if("normal"===c.type){if(r=n.done?d:l,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=d,n.method="throw",n.arg=c.arg)}}}(t,n,i),o}function b(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function E(){}function O(){}function j(){}function w(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function x(t){function n(e,r,i,u){var a=b(t[e],t,r);if("throw"!==a.type){var c=a.arg,f=c.value;return f&&"object"==typeof f&&o.call(f,"__await")?Promise.resolve(f.__await).then(function(t){n("next",t,i,u)},function(t){n("throw",t,i,u)}):Promise.resolve(f).then(function(t){c.value=t,i(c)},u)}u(a.arg)}var r;"object"==typeof e.process&&e.process.domain&&(n=e.process.domain.bind(n)),this._invoke=function(t,e){function o(){return new Promise(function(r,o){n(t,e,r,o)})}return r=r?r.then(o,o):o()}}function S(t,e){var r=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,S(t,e),"throw"===e.method))return v;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var o=b(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function z(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function N(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=n,e.done=!0,e};return i.next=i}}return{next:P}}function P(){return{value:n,done:!0}}}("object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:e)});var Vc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gc=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Jc=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);t.length>e;e++)n[e]=t[e];return n}return Array.from(t)};function Hc(t){return null===t?"null":t!==Object(t)?void 0===t?"undefined":Vc(t):{}.toString.call(t).slice(8,-1).toLowerCase()}function Yc(t){return"string"!==Hc(t)||!t.length}function qc(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments[1],n=arguments[2];if(Yc(t))return!1;var r=t.charCodeAt(0);return r>=e&&n>=r}var Xc={HIRAGANA:"toHiragana",KATAKANA:"toKatakana"},$c={HEPBURN:"hepburn"},Qc={useObsoleteKana:!1,passRomaji:!1,upcaseKatakana:!1,ignoreCase:!1,IMEMode:!1,romanization:$c.HEPBURN},Zc=65,tf=90,ef=12353,nf=12438,rf=12449,of=12540,uf=19968,af=40879,cf=12540,ff=12539,sf=[65377,65381],lf=[[12288,12351],sf,[12539,12540],[65281,65295],[65306,65311],[65339,65343],[65371,65376],[65504,65518]],hf=[].concat([[12352,12447],[12448,12543],sf,[65382,65439]],lf,[[65313,65338],[65345,65370],[65296,65305],[19968,40959],[13312,19903]]),df=[[0,127]].concat([[256,257],[274,275],[298,299],[332,333],[362,363]]),vf=[[32,47],[58,63],[91,96],[123,126]].concat([[8216,8217],[8220,8221]]);function pf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return hf.some(function(e){var n=Gc(e,2);return qc(t,n[0],n[1])})}function yf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments[1],n="regexp"===Hc(e);return!Yc(t)&&[].concat(Jc(t)).every(function(t){var r=pf(t);return n?r||e.test(t):r})}var gf=function(){return Object.assign({},Qc,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})};function _f(t,e,n){var r=e;function o(t,e){var i=t.charAt(0);return function t(e,r,i,u){if(!r)return n||1===Object.keys(e).length?e[""]?[[i,u,e[""]]]:[]:[[i,u,null]];if(1===Object.keys(e).length)return[[i,u,e[""]]].concat(o(r,u));var a=function(t,e){if(void 0!==t[e])return Object.assign({"":t[""]+e},t[e])}(e,r.charAt(0));if(void 0===a)return[[i,u,e[""]]].concat(o(r,u));return t(a,r.slice(1),i,u+1)}(Object.assign({"":i},r[i]),t.slice(1),e,e+1)}return o(t,0)}function mf(t){return Object.entries(t).reduce(function(t,e){var n=Gc(e,2),r=n[0],o=n[1],i="string"===Hc(o);return t[r]=i?{"":o}:mf(o),t},{})}function bf(t,e){return e.split("").reduce(function(t,e){return void 0===t[e]&&(t[e]={}),t[e]},t)}function Ef(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e={};return"object"===Hc(t)&&Object.entries(t).forEach(function(t){var n=Gc(t,2),r=n[1],o=e;n[0].split("").forEach(function(t){void 0===o[t]&&(o[t]={}),o=o[t]}),o[""]=r}),function(t){return function t(e,n){return void 0===e||"string"===Hc(e)?n:Object.entries(n).reduce(function(n,r){var o=Gc(r,2),i=o[0];return n[i]=t(e[i],o[1]),n},e)}(JSON.parse(JSON.stringify(t)),e)}}function Of(t,e){return e?"function"===Hc(e)?e(t):Ef(e)(t):t}var jf={a:"あ",i:"い",u:"う",e:"え",o:"お",k:{a:"か",i:"き",u:"く",e:"け",o:"こ"},s:{a:"さ",i:"し",u:"す",e:"せ",o:"そ"},t:{a:"た",i:"ち",u:"つ",e:"て",o:"と"},n:{a:"な",i:"に",u:"ぬ",e:"ね",o:"の"},h:{a:"は",i:"ひ",u:"ふ",e:"へ",o:"ほ"},m:{a:"ま",i:"み",u:"む",e:"め",o:"も"},y:{a:"や",u:"ゆ",o:"よ"},r:{a:"ら",i:"り",u:"る",e:"れ",o:"ろ"},w:{a:"わ",i:"ゐ",e:"ゑ",o:"を"},g:{a:"が",i:"ぎ",u:"ぐ",e:"げ",o:"ご"},z:{a:"ざ",i:"じ",u:"ず",e:"ぜ",o:"ぞ"},d:{a:"だ",i:"ぢ",u:"づ",e:"で",o:"ど"},b:{a:"ば",i:"び",u:"ぶ",e:"べ",o:"ぼ"},p:{a:"ぱ",i:"ぴ",u:"ぷ",e:"ぺ",o:"ぽ"},v:{a:"ゔぁ",i:"ゔぃ",u:"ゔ",e:"ゔぇ",o:"ゔぉ"}},wf={".":"。",",":"、",":":":","/":"・","!":"!","?":"?","~":"〜","-":"ー","‘":"「","’":"」","“":"『","”":"』","[":"[","]":"]","(":"(",")":")","{":"{","}":"}"},xf={k:"き",s:"し",t:"ち",n:"に",h:"ひ",m:"み",r:"り",g:"ぎ",z:"じ",d:"ぢ",b:"び",p:"ぴ",v:"ゔ",q:"く",f:"ふ"},Sf={ya:"ゃ",yi:"ぃ",yu:"ゅ",ye:"ぇ",yo:"ょ"},Af={a:"ぁ",i:"ぃ",u:"ぅ",e:"ぇ",o:"ぉ"},Mf={sh:"sy",ch:"ty",cy:"ty",chy:"ty",shy:"sy",j:"zy",jy:"zy",shi:"si",chi:"ti",tsu:"tu",ji:"zi",fu:"hu"},zf=Object.assign({tu:"っ",wa:"ゎ",ka:"ヵ",ke:"ヶ"},Af,Sf),Nf={yi:"い",wu:"う",ye:"いぇ",wi:"うぃ",we:"うぇ",kwa:"くぁ",whu:"う",tha:"てゃ",thu:"てゅ",tho:"てょ",dha:"でゃ",dhu:"でゅ",dho:"でょ"},Pf={wh:"う",qw:"く",q:"く",gw:"ぐ",sw:"す",ts:"つ",th:"て",tw:"と",dh:"で",dw:"ど",fw:"ふ",f:"ふ"};function kf(){var t=mf(jf),e=function(e){return bf(t,e)};return Object.entries(xf).forEach(function(t){var n=Gc(t,2),r=n[0],o=n[1];Object.entries(Sf).forEach(function(t){var n=Gc(t,2),i=n[1];e(r+n[0])[""]=o+i})}),Object.entries(wf).forEach(function(t){var n=Gc(t,2),r=n[1];e(n[0])[""]=r}),Object.entries(Pf).forEach(function(t){var n=Gc(t,2),r=n[0],o=n[1];Object.entries(Af).forEach(function(t){var n=Gc(t,2),i=n[1];e(r+n[0])[""]=o+i})}),["n","n'","xn"].forEach(function(t){e(t)[""]="ん"}),t.c=JSON.parse(JSON.stringify(t.k)),Object.entries(Mf).forEach(function(t){var n=Gc(t,2),r=n[0],o=n[1],i=r.slice(0,r.length-1),u=r.charAt(r.length-1);e(i)[u]=JSON.parse(JSON.stringify(e(o)))}),Object.entries(zf).forEach(function(t){var n,r=Gc(t,2),o=r[0],i=r[1],u=function(t){return t.charAt(t.length-1)},a=function(t){return t.slice(0,t.length-1)},c=e("x"+o);c[""]=i,e("l"+a(o))[u(o)]=c,(n=o,[].concat(Jc(Object.entries(Mf)),[["c","k"]]).reduce(function(t,e){var r=Gc(e,2),o=r[0],i=r[1];return n.startsWith(i)?t.concat(n.replace(i,o)):t},[])).forEach(function(t){["l","x"].forEach(function(n){e(n+a(t))[u(t)]=e(n+o)})})}),Object.entries(Nf).forEach(function(t){var n=Gc(t,2),r=n[1];e(n[0])[""]=r}),[].concat(Jc(Object.keys(xf)),["c","y","w","j"]).forEach(function(e){var n=t[e];n[e]=function t(e){return Object.entries(e).reduce(function(e,n){var r=Gc(n,2),o=r[0],i=r[1];return e[o]=o?t(i):"っ"+i,e},{})}(n)}),delete t.n.n,Object.freeze(JSON.parse(JSON.stringify(t)))}var Lf=null;var Ff=Ef({wi:"ゐ",we:"ゑ"});function If(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&qc(t,Zc,tf)}function Rf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&t.charCodeAt(0)===cf}function Tf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&t.charCodeAt(0)===ff}function Cf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&(!!Rf(t)||qc(t,ef,nf))}function Wf(){var t=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("").forEach(function(e){if(Rf(e)||Tf(e))t.push(e);else if(Cf(e)){var n=e.charCodeAt(0)+(rf-ef);t.push(String.fromCharCode(n))}else t.push(e)}),t.join("")}function Uf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2],r=void 0;return n?r=e:n=Bf(r=gf(e)),function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments[2];n||(n=Bf(e));return _f(t.toLowerCase(),n,!e.IMEMode)}(t,r,n).map(function(e){var n=Gc(e,3),o=n[0],i=n[1],u=n[2];if(null===u)return t.slice(o);var a=r.IMEMode===Xc.HIRAGANA,c=r.IMEMode===Xc.KATAKANA||[].concat(Jc(t.slice(o,i))).every(If);return a||!c?u:Wf(u)}).join("")}var Kf=null;function Bf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=(null==Lf&&(Lf=kf()),Lf);return e=t.IMEMode?function(t){var e=JSON.parse(JSON.stringify(t));return e.n.n={"":"ん"},e.n[" "]={"":"ん"},e}(e):e,e=t.useObsoleteKana?Ff(e):e,t.customKanaMapping&&(null==Kf&&(Kf=Of(e,t.customKanaMapping)),e=Kf),e}var Df=[];function Vf(t){var e=Object.assign({},gf(t),{IMEMode:t.IMEMode||!0}),n=Bf(e),r=[].concat(Jc(Object.keys(n)),Jc(Object.keys(n).map(function(t){return t.toUpperCase()})));return function(t){var o=t.target;void 0!==o.value&&"true"!==o.dataset.ignoreComposition&&function(t,e,n,r,o){var i=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=void 0,o=void 0,i=void 0;if(0===e&&n.includes(t[0])){var u=function(t,e){return[""].concat(Jc(Jf(t,function(t){return e.includes(t)||!yf(t,/[0-9]/)})))}(t,n),a=Gc(u,3);r=a[0],o=a[1],i=a[2]}else if(e>0){var c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Jf([].concat(Jc(t.slice(0,e))).reverse(),function(t){return!yf(t)}),r=Gc(n,2),o=r[0];return[r[1].reverse().join(""),o.split("").reverse().join(""),t.slice(e)]}(t,e),f=Gc(c,3);r=f[0],o=f[1],i=f[2]}else{var s=Jf(t,function(t){return!n.includes(t)}),l=Gc(s,2);r=l[0];var h=Jf(o=l[1],function(t){return!yf(t)}),d=Gc(h,2);o=d[0],i=d[1]}return[r,o,i]}(t.value,t.selectionEnd,r),u=Gc(i,3),a=u[0],c=u[1],f=u[2],s=Uf(c,e,n);if(c!==s){var l=a.length+s.length,h=a+s+f;t.value=h,h,f.length?setTimeout(function(){return t.setSelectionRange(l,l)},1):t.setSelectionRange(l,l)}else t.value}(o,e,n,r)}}function Gf(t){var e=t.type,n=t.target,r=t.data;/Mac/.test(window.navigator&&window.navigator.platform)&&("compositionupdate"===e&&yf(r)&&(n.dataset.ignoreComposition="true"),"compositionend"===e&&(n.dataset.ignoreComposition="false"))}function Jf(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(t){return!!t},n=[],r=t.length,o=0;r>o&&e(t[o],o);)n.push(t[o]),o+=1;return[n.join(""),t.slice(o)]}var Hf={input:function(t){var e=t.target;return console.log("input:",{value:e.value,selectionStart:e.selectionStart,selectionEnd:e.selectionEnd})},compositionstart:function(){return console.log("compositionstart")},compositionupdate:function(t){var e=t.target;return console.log("compositionupdate",{data:t.data,value:e.value,selectionStart:e.selectionStart,selectionEnd:e.selectionEnd})},compositionend:function(){return console.log("compositionend")}},Yf=function(t){Object.entries(Hf).forEach(function(e){var n=Gc(e,2);return t.addEventListener(n[0],n[1])})},qf=function(t){Object.entries(Hf).forEach(function(e){var n=Gc(e,2);return t.removeEventListener(n[0],n[1])})},Xf=["TEXTAREA","INPUT"],$f=0,Qf=function(){return $f+=1,""+Date.now()+$f};function Zf(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&df.some(function(e){var n=Gc(e,2);return qc(t,n[0],n[1])})}function ts(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments[1],n="regexp"===Hc(e);return!Yc(t)&&[].concat(Jc(t)).every(function(t){var r=Zf(t);return n?r||e.test(t):r})}function es(){return qc(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",rf,of)}function ns(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&(Cf(t)||es(t))}function rs(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&[].concat(Jc(t)).every(ns)}function os(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&[].concat(Jc(t)).every(Cf)}function is(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&[].concat(Jc(t)).every(es)}function us(){return qc(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",uf,af)}function as(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&[].concat(Jc(t)).every(us)}function cs(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{passKanji:!0},e=[].concat(Jc(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")),n=!1;return t.passKanji||(n=e.some(as)),(e.some(os)||e.some(is))&&e.some(ts)&&!n}var fs=function(t,e){return Rf(t)&&1>e},ss=function(t,e){return Rf(t)&&e>0},ls=function(t){return["ヶ","ヵ"].includes(t)},hs={a:"あ",i:"い",u:"う",e:"え",o:"う"};function ds(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments[1],n=arguments[2],r="";return t.split("").reduce(function(o,i,u){if(Tf(i)||fs(i,u)||ls(i))return o.concat(i);if(r&&ss(i,u)){var a=e(r).slice(-1);return es(t[u-1])&&"o"===a&&n?o.concat("お"):o.concat(hs[a])}if(!Rf(i)&&es(i)){var c=i.charCodeAt(0)+(ef-rf),f=String.fromCharCode(c);return r=f,o.concat(f)}return r="",o.concat(i)},[]).join("")}var vs=null,ps={"あ":"a","い":"i","う":"u","え":"e","お":"o","か":"ka","き":"ki","く":"ku","け":"ke","こ":"ko","さ":"sa","し":"shi","す":"su","せ":"se","そ":"so","た":"ta","ち":"chi","つ":"tsu","て":"te","と":"to","な":"na","に":"ni","ぬ":"nu","ね":"ne","の":"no","は":"ha","ひ":"hi","ふ":"fu","へ":"he","ほ":"ho","ま":"ma","み":"mi","む":"mu","め":"me","も":"mo","ら":"ra","り":"ri","る":"ru","れ":"re","ろ":"ro","や":"ya","ゆ":"yu","よ":"yo","わ":"wa","ゐ":"wi","ゑ":"we","を":"wo","ん":"n","が":"ga","ぎ":"gi","ぐ":"gu","げ":"ge","ご":"go","ざ":"za","じ":"ji","ず":"zu","ぜ":"ze","ぞ":"zo","だ":"da","ぢ":"ji","づ":"zu","で":"de","ど":"do","ば":"ba","び":"bi","ぶ":"bu","べ":"be","ぼ":"bo","ぱ":"pa","ぴ":"pi","ぷ":"pu","ぺ":"pe","ぽ":"po","ゔぁ":"va","ゔぃ":"vi","ゔ":"vu","ゔぇ":"ve","ゔぉ":"vo"},ys={"。":".","、":",",":":":","・":"/","!":"!","?":"?","〜":"~","ー":"-","「":"‘","」":"’","『":"“","』":"”","[":"[","]":"]","(":"(",")":")","{":"{","}":"}"," ":" "},gs=["あ","い","う","え","お","や","ゆ","よ"],_s={"ゃ":"ya","ゅ":"yu","ょ":"yo"},ms={"ぃ":"yi","ぇ":"ye"},bs={"ぁ":"a","ぃ":"i","ぅ":"u","ぇ":"e","ぉ":"o"},Es=["き","に","ひ","み","り","ぎ","び","ぴ","ゔ","く","ふ"],Os={"し":"sh","ち":"ch","じ":"j","ぢ":"j"},js={"っ":"","ゃ":"ya","ゅ":"yu","ょ":"yo","ぁ":"a","ぃ":"i","ぅ":"u","ぇ":"e","ぉ":"o"},ws={b:"b",c:"t",d:"d",f:"f",g:"g",h:"h",j:"j",k:"k",m:"m",p:"p",q:"q",r:"r",s:"s",t:"t",v:"v",w:"w",x:"x",z:"z"};function xs(){var t,e,n;return null==vs&&(t=mf(ps),e=function(e){return bf(t,e)},n=function(t,n){e(t)[""]=n},Object.entries(ys).forEach(function(t){var n=Gc(t,2),r=n[1];e(n[0])[""]=r}),[].concat(Jc(Object.entries(_s)),Jc(Object.entries(bs))).forEach(function(t){var e=Gc(t,2);n(e[0],e[1])}),Es.forEach(function(t){var r=e(t)[""][0];Object.entries(_s).forEach(function(e){var o=Gc(e,2);n(t+o[0],r+o[1])}),Object.entries(ms).forEach(function(e){var o=Gc(e,2);n(t+o[0],r+o[1])})}),Object.entries(Os).forEach(function(t){var e=Gc(t,2),r=e[0],o=e[1];Object.entries(_s).forEach(function(t){var e=Gc(t,2);n(r+e[0],o+e[1][1])}),n(r+"ぃ",o+"yi"),n(r+"ぇ",o+"e")}),t["っ"]=function t(e){return Object.entries(e).reduce(function(e,n){var r=Gc(n,2),o=r[0],i=r[1];if(o)e[o]=t(i);else{var u=i.charAt(0);e[o]=Object.keys(ws).includes(u)?ws[u]+i:i}return e},{})}(t),Object.entries(js).forEach(function(t){var e=Gc(t,2);n(e[0],e[1])}),gs.forEach(function(t){n("ん"+t,"n'"+e(t)[""])}),vs=Object.freeze(JSON.parse(JSON.stringify(t)))),vs}function Ss(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=gf(e);return function(t,e){var n=function(t){switch(t.romanization){case $c.HEPBURN:return xs();default:return{}}}(e);e.customRomajiMapping&&(null==As&&(As=Of(n,e.customRomajiMapping)),n=As);return _f(ds(t,Ss,!0),n,!e.IMEMode)}(t,n).map(function(n){var r=Gc(n,3),o=r[2];return e.upcaseKatakana&&is(t.slice(r[0],r[1]))?o.toUpperCase():o}).join("")}var As=null;function Ms(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&vf.some(function(e){var n=Gc(e,2);return qc(t,n[0],n[1])})}function zs(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!Yc(t)&&lf.some(function(e){var n=Gc(e,2);return qc(t,n[0],n[1])})}var Ns=function(t){return" "===t},Ps=function(t){return" "===t},ks=function(t){return/[0-9]/.test(t)},Ls=function(t){return/[0-9]/.test(t)},Fs={EN:"en",JA:"ja",EN_NUM:"englishNumeral",JA_NUM:"japaneseNumeral",EN_PUNC:"englishPunctuation",JA_PUNC:"japanesePunctuation",KANJI:"kanji",HIRAGANA:"hiragana",KATAKANA:"katakana",SPACE:"space",OTHER:"other"};function Is(t){var e=Fs.EN,n=Fs.JA,r=Fs.EN_NUM,o=Fs.JA_NUM,i=Fs.EN_PUNC,u=Fs.JA_PUNC,a=Fs.KANJI,c=Fs.HIRAGANA,f=Fs.KATAKANA,s=Fs.SPACE,l=Fs.OTHER;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])switch(!0){case ks(t):case Ls(t):return l;case Ns(t):return e;case Ms(t):return l;case Ps(t):return n;case zs(t):return l;case pf(t):return n;case Zf(t):return e;default:return l}else switch(!0){case Ps(t):case Ns(t):return s;case ks(t):return o;case Ls(t):return r;case Ms(t):return i;case zs(t):return u;case us(t):return a;case Cf(t):return c;case es(t):return f;case pf(t):return n;case Zf(t):return e;default:return l}}function Rs(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.compact,r=void 0!==n&&n,o=e.detailed,i=void 0!==o&&o;if(null==t||Yc(t))return[];var u=[].concat(Jc(t)),a=u.shift(),c=Is(a,r);return u.reduce(function(t,e){var n=Is(e,r),o=n===c;c=n;var u=e;return o&&(u=(i?t.pop().value:t.pop())+u),t.concat(i?{type:n,value:u}:u)},[a=i?{type:c,value:a}:a])}var Ts=function(t,e){return e&&!rs(t[0])},Cs=function(t,e){return!e&&!rs(t[t.length-1])},Ws=function(t,e){return e&&![].concat(Jc(e)).some(as)||!e&&rs(t)};t.bind=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!Xf.includes(t.nodeName))throw Error("Element provided to Wanakana bind() was not a valid input or textarea element.\n Received: ("+JSON.stringify(t)+")");var r=Vf(e),o=Qf();t.setAttribute("data-wanakana-id",o),t.setAttribute("lang","ja"),t.setAttribute("autoCapitalize","none"),t.setAttribute("autoCorrect","off"),t.setAttribute("autoComplete","off"),t.setAttribute("spellCheck","false"),t.addEventListener("input",r),t.addEventListener("compositionupdate",Gf),t.addEventListener("compositionend",Gf),function(t,e,n){Df=Df.concat({id:t,inputHandler:e,compositionHandler:n})}(o,r,Gf),!0===n&&Yf(t)},t.unbind=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(e=t)&&Df.find(function(t){return t.id===e.getAttribute("data-wanakana-id")});if(null==r)throw Error("Element provided to Wanakana unbind() had no listener registered.\n Received: "+JSON.stringify(t));var o,i=r.inputHandler,u=r.compositionHandler;t.removeAttribute("data-wanakana-id"),t.removeAttribute("data-ignore-composition"),t.removeEventListener("input",i),t.removeEventListener("compositionstart",u),t.removeEventListener("compositionupdate",u),t.removeEventListener("compositionend",u),o=r.id,Df=Df.filter(function(t){return t.id!==o}),!0===n&&qf(t)},t.isRomaji=ts,t.isJapanese=yf,t.isKana=rs,t.isHiragana=os,t.isKatakana=is,t.isMixed=cs,t.isKanji=as,t.toRomaji=Ss,t.toKana=Uf,t.toHiragana=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=gf(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return e.passRomaji?ds(t,Ss):cs(t,{passKanji:!0})?Uf(ds(t,Ss).toLowerCase(),e):ts(t)||Ms(t)?Uf(t.toLowerCase(),e):ds(t,Ss)},t.toKatakana=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=gf(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return e.passRomaji?Wf(t):cs(t)||ts(t)||Ms(t)?Wf(Uf(t.toLowerCase(),e)):Wf(t)},t.stripOkurigana=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.leading,r=void 0!==n&&n,o=e.matchKanji,i=void 0===o?"":o;if(!yf(t)||Ts(t,r)||Cs(t,r)||Ws(t,i))return t;var u=i||t,a=RegExp(r?"^"+Rs(u).shift():Rs(u).pop()+"$");return t.replace(a,"")},t.tokenize=Rs,t.VERSION="4.0.2",t.TO_KANA_METHODS=Xc,t.ROMANIZATIONS=$c,Object.defineProperty(t,"__esModule",{value:!0})}); +//# sourceMappingURL=wanakana.min.js.map diff --git a/ext/mixed/lib/wanakana.min.js.map b/ext/mixed/lib/wanakana.min.js.map new file mode 100644 index 00000000..518174e1 --- /dev/null +++ b/ext/mixed/lib/wanakana.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"wanakana.min.js","sources":["../../node_modules/core-js/modules/_global.js","../../node_modules/core-js/modules/_core.js","../../node_modules/core-js/modules/_is-object.js","../../node_modules/core-js/modules/_an-object.js","../../node_modules/core-js/modules/_fails.js","../../node_modules/core-js/modules/_descriptors.js","../../node_modules/core-js/modules/_dom-create.js","../../node_modules/core-js/modules/_ie8-dom-define.js","../../node_modules/core-js/modules/_to-primitive.js","../../node_modules/core-js/modules/_object-dp.js","../../node_modules/core-js/modules/_property-desc.js","../../node_modules/core-js/modules/_hide.js","../../node_modules/core-js/modules/_has.js","../../node_modules/core-js/modules/_uid.js","../../node_modules/core-js/modules/_redefine.js","../../node_modules/core-js/modules/_a-function.js","../../node_modules/core-js/modules/_ctx.js","../../node_modules/core-js/modules/_export.js","../../node_modules/core-js/modules/_typed.js","../../node_modules/core-js/modules/_library.js","../../node_modules/core-js/modules/_redefine-all.js","../../node_modules/core-js/modules/_an-instance.js","../../node_modules/core-js/modules/_to-integer.js","../../node_modules/core-js/modules/_to-length.js","../../node_modules/core-js/modules/_to-index.js","../../node_modules/core-js/modules/_cof.js","../../node_modules/core-js/modules/_iobject.js","../../node_modules/core-js/modules/_defined.js","../../node_modules/core-js/modules/_to-iobject.js","../../node_modules/core-js/modules/_to-absolute-index.js","../../node_modules/core-js/modules/_array-includes.js","../../node_modules/core-js/modules/_shared.js","../../node_modules/core-js/modules/_shared-key.js","../../node_modules/core-js/modules/_object-keys-internal.js","../../node_modules/core-js/modules/_enum-bug-keys.js","../../node_modules/core-js/modules/_object-gopn.js","../../node_modules/core-js/modules/_to-object.js","../../node_modules/core-js/modules/_array-fill.js","../../node_modules/core-js/modules/_wks.js","../../node_modules/core-js/modules/_set-to-string-tag.js","../../node_modules/core-js/modules/_typed-buffer.js","../../node_modules/core-js/modules/_species-constructor.js","../../node_modules/core-js/modules/_set-species.js","../../node_modules/core-js/modules/es6.typed.array-buffer.js","../../node_modules/core-js/modules/_classof.js","../../node_modules/core-js/modules/_is-array-iter.js","../../node_modules/core-js/modules/_object-keys.js","../../node_modules/core-js/modules/_object-dps.js","../../node_modules/core-js/modules/_html.js","../../node_modules/core-js/modules/_object-create.js","../../node_modules/core-js/modules/_object-gpo.js","../../node_modules/core-js/modules/core.get-iterator-method.js","../../node_modules/core-js/modules/_is-array.js","../../node_modules/core-js/modules/_array-species-constructor.js","../../node_modules/core-js/modules/_array-species-create.js","../../node_modules/core-js/modules/_array-methods.js","../../node_modules/core-js/modules/_add-to-unscopables.js","../../node_modules/core-js/modules/_iter-step.js","../../node_modules/core-js/modules/_iter-create.js","../../node_modules/core-js/modules/_iter-define.js","../../node_modules/core-js/modules/es6.array.iterator.js","../../node_modules/core-js/modules/_iter-detect.js","../../node_modules/core-js/modules/_array-copy-within.js","../../node_modules/core-js/modules/_object-pie.js","../../node_modules/core-js/modules/_object-gopd.js","../../node_modules/core-js/modules/_typed-array.js","../../node_modules/core-js/modules/es6.typed.int8-array.js","../../node_modules/core-js/modules/es6.typed.uint8-array.js","../../node_modules/core-js/modules/es6.typed.uint8-clamped-array.js","../../node_modules/core-js/modules/es6.typed.int16-array.js","../../node_modules/core-js/modules/es6.typed.uint16-array.js","../../node_modules/core-js/modules/es6.typed.int32-array.js","../../node_modules/core-js/modules/es6.typed.uint32-array.js","../../node_modules/core-js/modules/es6.typed.float32-array.js","../../node_modules/core-js/modules/es6.typed.float64-array.js","../../node_modules/core-js/modules/_iter-call.js","../../node_modules/core-js/modules/_for-of.js","../../node_modules/core-js/modules/_meta.js","../../node_modules/core-js/modules/_validate-collection.js","../../node_modules/core-js/modules/_collection-strong.js","../../node_modules/core-js/modules/_set-proto.js","../../node_modules/core-js/modules/_inherit-if-required.js","../../node_modules/core-js/modules/_collection.js","../../node_modules/core-js/modules/es6.map.js","../../node_modules/core-js/modules/es6.set.js","../../node_modules/core-js/modules/_object-gops.js","../../node_modules/core-js/modules/_object-assign.js","../../node_modules/core-js/modules/_collection-weak.js","../../node_modules/core-js/modules/es6.weak-map.js","../../node_modules/core-js/modules/es6.weak-set.js","../../node_modules/core-js/modules/es6.reflect.apply.js","../../node_modules/core-js/modules/_invoke.js","../../node_modules/core-js/modules/_bind.js","../../node_modules/core-js/modules/es6.reflect.construct.js","../../node_modules/core-js/modules/es6.reflect.define-property.js","../../node_modules/core-js/modules/es6.reflect.delete-property.js","../../node_modules/core-js/modules/es6.reflect.get.js","../../node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js","../../node_modules/core-js/modules/es6.reflect.get-prototype-of.js","../../node_modules/core-js/modules/es6.reflect.has.js","../../node_modules/core-js/modules/es6.reflect.is-extensible.js","../../node_modules/core-js/modules/_own-keys.js","../../node_modules/core-js/modules/es6.reflect.own-keys.js","../../node_modules/core-js/modules/es6.reflect.prevent-extensions.js","../../node_modules/core-js/modules/es6.reflect.set.js","../../node_modules/core-js/modules/es6.reflect.set-prototype-of.js","../../node_modules/core-js/modules/_task.js","../../node_modules/core-js/modules/_microtask.js","../../node_modules/core-js/modules/_new-promise-capability.js","../../node_modules/core-js/modules/es6.promise.js","../../node_modules/core-js/modules/_perform.js","../../node_modules/core-js/modules/_promise-resolve.js","../../node_modules/core-js/modules/_wks-ext.js","../../node_modules/core-js/modules/_wks-define.js","../../node_modules/core-js/modules/_enum-keys.js","../../node_modules/core-js/modules/_object-gopn-ext.js","../../node_modules/core-js/modules/es6.symbol.js","../../node_modules/core-js/modules/_object-sap.js","../../node_modules/core-js/modules/es6.object.freeze.js","../../node_modules/core-js/modules/es6.object.seal.js","../../node_modules/core-js/modules/es6.object.prevent-extensions.js","../../node_modules/core-js/modules/es6.object.is-frozen.js","../../node_modules/core-js/modules/es6.object.is-sealed.js","../../node_modules/core-js/modules/es6.object.is-extensible.js","../../node_modules/core-js/modules/es6.object.get-own-property-descriptor.js","../../node_modules/core-js/modules/es6.object.get-prototype-of.js","../../node_modules/core-js/modules/es6.object.keys.js","../../node_modules/core-js/modules/es6.object.get-own-property-names.js","../../node_modules/core-js/modules/es6.object.assign.js","../../node_modules/core-js/modules/_same-value.js","../../node_modules/core-js/modules/es6.object.is.js","../../node_modules/core-js/modules/es6.object.set-prototype-of.js","../../node_modules/core-js/modules/es6.function.name.js","../../node_modules/core-js/modules/es6.string.raw.js","../../node_modules/core-js/modules/es6.string.from-code-point.js","../../node_modules/core-js/modules/_string-at.js","../../node_modules/core-js/modules/es6.string.code-point-at.js","../../node_modules/core-js/modules/_string-repeat.js","../../node_modules/core-js/modules/es6.string.repeat.js","../../node_modules/core-js/modules/_is-regexp.js","../../node_modules/core-js/modules/_string-context.js","../../node_modules/core-js/modules/_fails-is-regexp.js","../../node_modules/core-js/modules/es6.string.starts-with.js","../../node_modules/core-js/modules/es6.string.ends-with.js","../../node_modules/core-js/modules/es6.string.includes.js","../../node_modules/core-js/modules/_flags.js","../../node_modules/core-js/modules/es6.regexp.flags.js","../../node_modules/core-js/modules/_fix-re-wks.js","../../node_modules/core-js/modules/es6.regexp.match.js","../../node_modules/core-js/modules/es6.regexp.replace.js","../../node_modules/core-js/modules/es6.regexp.split.js","../../node_modules/core-js/modules/es6.regexp.search.js","../../node_modules/core-js/modules/_create-property.js","../../node_modules/core-js/modules/es6.array.from.js","../../node_modules/core-js/modules/es6.array.of.js","../../node_modules/core-js/modules/es6.array.copy-within.js","../../node_modules/core-js/modules/es6.array.find.js","../../node_modules/core-js/modules/es6.array.find-index.js","../../node_modules/core-js/modules/es6.array.fill.js","../../node_modules/core-js/modules/es6.number.is-finite.js","../../node_modules/core-js/modules/_is-integer.js","../../node_modules/core-js/modules/es6.number.is-integer.js","../../node_modules/core-js/modules/es6.number.is-safe-integer.js","../../node_modules/core-js/modules/es6.number.is-nan.js","../../node_modules/core-js/modules/es6.number.epsilon.js","../../node_modules/core-js/modules/es6.number.min-safe-integer.js","../../node_modules/core-js/modules/es6.number.max-safe-integer.js","../../node_modules/core-js/modules/_math-log1p.js","../../node_modules/core-js/modules/es6.math.acosh.js","../../node_modules/core-js/modules/es6.math.asinh.js","../../node_modules/core-js/modules/es6.math.atanh.js","../../node_modules/core-js/modules/_math-sign.js","../../node_modules/core-js/modules/es6.math.cbrt.js","../../node_modules/core-js/modules/es6.math.clz32.js","../../node_modules/core-js/modules/es6.math.cosh.js","../../node_modules/core-js/modules/_math-expm1.js","../../node_modules/core-js/modules/es6.math.expm1.js","../../node_modules/core-js/modules/_math-fround.js","../../node_modules/core-js/modules/es6.math.fround.js","../../node_modules/core-js/modules/es6.math.hypot.js","../../node_modules/core-js/modules/es6.math.imul.js","../../node_modules/core-js/modules/es6.math.log1p.js","../../node_modules/core-js/modules/es6.math.log10.js","../../node_modules/core-js/modules/es6.math.log2.js","../../node_modules/core-js/modules/es6.math.sign.js","../../node_modules/core-js/modules/es6.math.sinh.js","../../node_modules/core-js/modules/es6.math.tanh.js","../../node_modules/core-js/modules/es6.math.trunc.js","../../node_modules/core-js/modules/es7.array.includes.js","../../node_modules/core-js/modules/_object-to-array.js","../../node_modules/core-js/modules/es7.object.values.js","../../node_modules/core-js/modules/es7.object.entries.js","../../node_modules/core-js/modules/es7.object.get-own-property-descriptors.js","../../node_modules/core-js/modules/_string-pad.js","../../node_modules/core-js/modules/_user-agent.js","../../node_modules/core-js/modules/es7.string.pad-start.js","../../node_modules/core-js/modules/es7.string.pad-end.js","../../node_modules/core-js/modules/web.timers.js","../../node_modules/core-js/modules/web.immediate.js","../../node_modules/core-js/modules/web.dom.iterable.js","../../node_modules/regenerator-runtime/runtime.js","../../src/utils/typeOf.js","../../src/utils/isEmpty.js","../../src/utils/isCharInRange.js","../../src/constants.js","../../src/utils/isCharJapanese.js","../../src/isJapanese.js","../../src/utils/mergeWithDefaultOptions.js","../../src/utils/kanaMapping.js","../../src/utils/romajiToKanaMap.js","../../src/utils/isCharUpperCase.js","../../src/utils/isCharLongDash.js","../../src/utils/isCharSlashDot.js","../../src/utils/isCharHiragana.js","../../src/utils/hiraganaToKatakana.js","../../src/toKana.js","../../src/utils/dom.js","../../src/utils/logInputEvents.js","../../src/bind.js","../../src/utils/isCharRomaji.js","../../src/isRomaji.js","../../src/utils/isCharKatakana.js","../../src/utils/isCharKana.js","../../src/isKana.js","../../src/isHiragana.js","../../src/isKatakana.js","../../src/utils/isCharKanji.js","../../src/isKanji.js","../../src/isMixed.js","../../src/utils/katakanaToHiragana.js","../../src/utils/kanaToRomajiMap.js","../../src/toRomaji.js","../../src/utils/isCharEnglishPunctuation.js","../../src/utils/isCharJapanesePunctuation.js","../../src/tokenize.js","../../src/stripOkurigana.js","../../src/unbind.js","../../src/toHiragana.js","../../src/toKatakana.js"],"sourcesContent":["// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n ? window : typeof self != 'undefined' && self.Math == Math ? self\n // eslint-disable-next-line no-new-func\n : Function('return this')();\nif (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n","var core = module.exports = { version: '2.5.5' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n","var isObject = require('./_is-object');\nmodule.exports = function (it) {\n if (!isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n};\n","// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./_fails')(function () {\n return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;\n});\n","var isObject = require('./_is-object');\nvar document = require('./_global').document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n","module.exports = !require('./_descriptors') && !require('./_fails')(function () {\n return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;\n});\n","// 7.1.1 ToPrimitive(input [, PreferredType])\nvar isObject = require('./_is-object');\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (it, S) {\n if (!isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n","var anObject = require('./_an-object');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar toPrimitive = require('./_to-primitive');\nvar dP = Object.defineProperty;\n\nexports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return dP(O, P, Attributes);\n } catch (e) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n","var dP = require('./_object-dp');\nvar createDesc = require('./_property-desc');\nmodule.exports = require('./_descriptors') ? function (object, key, value) {\n return dP.f(object, key, createDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n","var hasOwnProperty = {}.hasOwnProperty;\nmodule.exports = function (it, key) {\n return hasOwnProperty.call(it, key);\n};\n","var id = 0;\nvar px = Math.random();\nmodule.exports = function (key) {\n return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));\n};\n","var global = require('./_global');\nvar hide = require('./_hide');\nvar has = require('./_has');\nvar SRC = require('./_uid')('src');\nvar TO_STRING = 'toString';\nvar $toString = Function[TO_STRING];\nvar TPL = ('' + $toString).split(TO_STRING);\n\nrequire('./_core').inspectSource = function (it) {\n return $toString.call(it);\n};\n\n(module.exports = function (O, key, val, safe) {\n var isFunction = typeof val == 'function';\n if (isFunction) has(val, 'name') || hide(val, 'name', key);\n if (O[key] === val) return;\n if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));\n if (O === global) {\n O[key] = val;\n } else if (!safe) {\n delete O[key];\n hide(O, key, val);\n } else if (O[key]) {\n O[key] = val;\n } else {\n hide(O, key, val);\n }\n// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative\n})(Function.prototype, TO_STRING, function toString() {\n return typeof this == 'function' && this[SRC] || $toString.call(this);\n});\n","module.exports = function (it) {\n if (typeof it != 'function') throw TypeError(it + ' is not a function!');\n return it;\n};\n","// optional / simple context binding\nvar aFunction = require('./_a-function');\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n","var global = require('./_global');\nvar core = require('./_core');\nvar hide = require('./_hide');\nvar redefine = require('./_redefine');\nvar ctx = require('./_ctx');\nvar PROTOTYPE = 'prototype';\n\nvar $export = function (type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];\n var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});\n var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});\n var key, own, out, exp;\n if (IS_GLOBAL) source = name;\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined;\n // export native or passed\n out = (own ? target : source)[key];\n // bind timers to global for call from export context\n exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n // extend global\n if (target) redefine(target, key, out, type & $export.U);\n // export\n if (exports[key] != out) hide(exports, key, exp);\n if (IS_PROTO && expProto[key] != out) expProto[key] = out;\n }\n};\nglobal.core = core;\n// type bitmap\n$export.F = 1; // forced\n$export.G = 2; // global\n$export.S = 4; // static\n$export.P = 8; // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\n$export.U = 64; // safe\n$export.R = 128; // real proto method for `library`\nmodule.exports = $export;\n","var global = require('./_global');\nvar hide = require('./_hide');\nvar uid = require('./_uid');\nvar TYPED = uid('typed_array');\nvar VIEW = uid('view');\nvar ABV = !!(global.ArrayBuffer && global.DataView);\nvar CONSTR = ABV;\nvar i = 0;\nvar l = 9;\nvar Typed;\n\nvar TypedArrayConstructors = (\n 'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'\n).split(',');\n\nwhile (i < l) {\n if (Typed = global[TypedArrayConstructors[i++]]) {\n hide(Typed.prototype, TYPED, true);\n hide(Typed.prototype, VIEW, true);\n } else CONSTR = false;\n}\n\nmodule.exports = {\n ABV: ABV,\n CONSTR: CONSTR,\n TYPED: TYPED,\n VIEW: VIEW\n};\n","module.exports = false;\n","var redefine = require('./_redefine');\nmodule.exports = function (target, src, safe) {\n for (var key in src) redefine(target, key, src[key], safe);\n return target;\n};\n","module.exports = function (it, Constructor, name, forbiddenField) {\n if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {\n throw TypeError(name + ': incorrect invocation!');\n } return it;\n};\n","// 7.1.4 ToInteger\nvar ceil = Math.ceil;\nvar floor = Math.floor;\nmodule.exports = function (it) {\n return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);\n};\n","// 7.1.15 ToLength\nvar toInteger = require('./_to-integer');\nvar min = Math.min;\nmodule.exports = function (it) {\n return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991\n};\n","// https://tc39.github.io/ecma262/#sec-toindex\nvar toInteger = require('./_to-integer');\nvar toLength = require('./_to-length');\nmodule.exports = function (it) {\n if (it === undefined) return 0;\n var number = toInteger(it);\n var length = toLength(number);\n if (number !== length) throw RangeError('Wrong length!');\n return length;\n};\n","var toString = {}.toString;\n\nmodule.exports = function (it) {\n return toString.call(it).slice(8, -1);\n};\n","// fallback for non-array-like ES3 and non-enumerable old V8 strings\nvar cof = require('./_cof');\n// eslint-disable-next-line no-prototype-builtins\nmodule.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {\n return cof(it) == 'String' ? it.split('') : Object(it);\n};\n","// 7.2.1 RequireObjectCoercible(argument)\nmodule.exports = function (it) {\n if (it == undefined) throw TypeError(\"Can't call method on \" + it);\n return it;\n};\n","// to indexed object, toObject with fallback for non-array-like ES3 strings\nvar IObject = require('./_iobject');\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return IObject(defined(it));\n};\n","var toInteger = require('./_to-integer');\nvar max = Math.max;\nvar min = Math.min;\nmodule.exports = function (index, length) {\n index = toInteger(index);\n return index < 0 ? max(index + length, 0) : min(index, length);\n};\n","// false -> Array#indexOf\n// true -> Array#includes\nvar toIObject = require('./_to-iobject');\nvar toLength = require('./_to-length');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nmodule.exports = function (IS_INCLUDES) {\n return function ($this, el, fromIndex) {\n var O = toIObject($this);\n var length = toLength(O.length);\n var index = toAbsoluteIndex(fromIndex, length);\n var value;\n // Array#includes uses SameValueZero equality algorithm\n // eslint-disable-next-line no-self-compare\n if (IS_INCLUDES && el != el) while (length > index) {\n value = O[index++];\n // eslint-disable-next-line no-self-compare\n if (value != value) return true;\n // Array#indexOf ignores holes, Array#includes - not\n } else for (;length > index; index++) if (IS_INCLUDES || index in O) {\n if (O[index] === el) return IS_INCLUDES || index || 0;\n } return !IS_INCLUDES && -1;\n };\n};\n","var global = require('./_global');\nvar SHARED = '__core-js_shared__';\nvar store = global[SHARED] || (global[SHARED] = {});\nmodule.exports = function (key) {\n return store[key] || (store[key] = {});\n};\n","var shared = require('./_shared')('keys');\nvar uid = require('./_uid');\nmodule.exports = function (key) {\n return shared[key] || (shared[key] = uid(key));\n};\n","var has = require('./_has');\nvar toIObject = require('./_to-iobject');\nvar arrayIndexOf = require('./_array-includes')(false);\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\n\nmodule.exports = function (object, names) {\n var O = toIObject(object);\n var i = 0;\n var result = [];\n var key;\n for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);\n // Don't enum bug & hidden keys\n while (names.length > i) if (has(O, key = names[i++])) {\n ~arrayIndexOf(result, key) || result.push(key);\n }\n return result;\n};\n","// IE 8- don't enum bug keys\nmodule.exports = (\n 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'\n).split(',');\n","// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)\nvar $keys = require('./_object-keys-internal');\nvar hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');\n\nexports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {\n return $keys(O, hiddenKeys);\n};\n","// 7.1.13 ToObject(argument)\nvar defined = require('./_defined');\nmodule.exports = function (it) {\n return Object(defined(it));\n};\n","// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)\n'use strict';\nvar toObject = require('./_to-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\nmodule.exports = function fill(value /* , start = 0, end = @length */) {\n var O = toObject(this);\n var length = toLength(O.length);\n var aLen = arguments.length;\n var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);\n var end = aLen > 2 ? arguments[2] : undefined;\n var endPos = end === undefined ? length : toAbsoluteIndex(end, length);\n while (endPos > index) O[index++] = value;\n return O;\n};\n","var store = require('./_shared')('wks');\nvar uid = require('./_uid');\nvar Symbol = require('./_global').Symbol;\nvar USE_SYMBOL = typeof Symbol == 'function';\n\nvar $exports = module.exports = function (name) {\n return store[name] || (store[name] =\n USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));\n};\n\n$exports.store = store;\n","var def = require('./_object-dp').f;\nvar has = require('./_has');\nvar TAG = require('./_wks')('toStringTag');\n\nmodule.exports = function (it, tag, stat) {\n if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });\n};\n","'use strict';\nvar global = require('./_global');\nvar DESCRIPTORS = require('./_descriptors');\nvar LIBRARY = require('./_library');\nvar $typed = require('./_typed');\nvar hide = require('./_hide');\nvar redefineAll = require('./_redefine-all');\nvar fails = require('./_fails');\nvar anInstance = require('./_an-instance');\nvar toInteger = require('./_to-integer');\nvar toLength = require('./_to-length');\nvar toIndex = require('./_to-index');\nvar gOPN = require('./_object-gopn').f;\nvar dP = require('./_object-dp').f;\nvar arrayFill = require('./_array-fill');\nvar setToStringTag = require('./_set-to-string-tag');\nvar ARRAY_BUFFER = 'ArrayBuffer';\nvar DATA_VIEW = 'DataView';\nvar PROTOTYPE = 'prototype';\nvar WRONG_LENGTH = 'Wrong length!';\nvar WRONG_INDEX = 'Wrong index!';\nvar $ArrayBuffer = global[ARRAY_BUFFER];\nvar $DataView = global[DATA_VIEW];\nvar Math = global.Math;\nvar RangeError = global.RangeError;\n// eslint-disable-next-line no-shadow-restricted-names\nvar Infinity = global.Infinity;\nvar BaseBuffer = $ArrayBuffer;\nvar abs = Math.abs;\nvar pow = Math.pow;\nvar floor = Math.floor;\nvar log = Math.log;\nvar LN2 = Math.LN2;\nvar BUFFER = 'buffer';\nvar BYTE_LENGTH = 'byteLength';\nvar BYTE_OFFSET = 'byteOffset';\nvar $BUFFER = DESCRIPTORS ? '_b' : BUFFER;\nvar $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;\nvar $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;\n\n// IEEE754 conversions based on https://github.com/feross/ieee754\nfunction packIEEE754(value, mLen, nBytes) {\n var buffer = new Array(nBytes);\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;\n var i = 0;\n var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;\n var e, m, c;\n value = abs(value);\n // eslint-disable-next-line no-self-compare\n if (value != value || value === Infinity) {\n // eslint-disable-next-line no-self-compare\n m = value != value ? 1 : 0;\n e = eMax;\n } else {\n e = floor(log(value) / LN2);\n if (value * (c = pow(2, -e)) < 1) {\n e--;\n c *= 2;\n }\n if (e + eBias >= 1) {\n value += rt / c;\n } else {\n value += rt * pow(2, 1 - eBias);\n }\n if (value * c >= 2) {\n e++;\n c /= 2;\n }\n if (e + eBias >= eMax) {\n m = 0;\n e = eMax;\n } else if (e + eBias >= 1) {\n m = (value * c - 1) * pow(2, mLen);\n e = e + eBias;\n } else {\n m = value * pow(2, eBias - 1) * pow(2, mLen);\n e = 0;\n }\n }\n for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);\n e = e << mLen | m;\n eLen += mLen;\n for (; eLen > 0; buffer[i++] = e & 255, e /= 256, eLen -= 8);\n buffer[--i] |= s * 128;\n return buffer;\n}\nfunction unpackIEEE754(buffer, mLen, nBytes) {\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var nBits = eLen - 7;\n var i = nBytes - 1;\n var s = buffer[i--];\n var e = s & 127;\n var m;\n s >>= 7;\n for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);\n m = e & (1 << -nBits) - 1;\n e >>= -nBits;\n nBits += mLen;\n for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);\n if (e === 0) {\n e = 1 - eBias;\n } else if (e === eMax) {\n return m ? NaN : s ? -Infinity : Infinity;\n } else {\n m = m + pow(2, mLen);\n e = e - eBias;\n } return (s ? -1 : 1) * m * pow(2, e - mLen);\n}\n\nfunction unpackI32(bytes) {\n return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];\n}\nfunction packI8(it) {\n return [it & 0xff];\n}\nfunction packI16(it) {\n return [it & 0xff, it >> 8 & 0xff];\n}\nfunction packI32(it) {\n return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];\n}\nfunction packF64(it) {\n return packIEEE754(it, 52, 8);\n}\nfunction packF32(it) {\n return packIEEE754(it, 23, 4);\n}\n\nfunction addGetter(C, key, internal) {\n dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } });\n}\n\nfunction get(view, bytes, index, isLittleEndian) {\n var numIndex = +index;\n var intIndex = toIndex(numIndex);\n if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);\n var store = view[$BUFFER]._b;\n var start = intIndex + view[$OFFSET];\n var pack = store.slice(start, start + bytes);\n return isLittleEndian ? pack : pack.reverse();\n}\nfunction set(view, bytes, index, conversion, value, isLittleEndian) {\n var numIndex = +index;\n var intIndex = toIndex(numIndex);\n if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);\n var store = view[$BUFFER]._b;\n var start = intIndex + view[$OFFSET];\n var pack = conversion(+value);\n for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];\n}\n\nif (!$typed.ABV) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer, ARRAY_BUFFER);\n var byteLength = toIndex(length);\n this._b = arrayFill.call(new Array(byteLength), 0);\n this[$LENGTH] = byteLength;\n };\n\n $DataView = function DataView(buffer, byteOffset, byteLength) {\n anInstance(this, $DataView, DATA_VIEW);\n anInstance(buffer, $ArrayBuffer, DATA_VIEW);\n var bufferLength = buffer[$LENGTH];\n var offset = toInteger(byteOffset);\n if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');\n byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);\n if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);\n this[$BUFFER] = buffer;\n this[$OFFSET] = offset;\n this[$LENGTH] = byteLength;\n };\n\n if (DESCRIPTORS) {\n addGetter($ArrayBuffer, BYTE_LENGTH, '_l');\n addGetter($DataView, BUFFER, '_b');\n addGetter($DataView, BYTE_LENGTH, '_l');\n addGetter($DataView, BYTE_OFFSET, '_o');\n }\n\n redefineAll($DataView[PROTOTYPE], {\n getInt8: function getInt8(byteOffset) {\n return get(this, 1, byteOffset)[0] << 24 >> 24;\n },\n getUint8: function getUint8(byteOffset) {\n return get(this, 1, byteOffset)[0];\n },\n getInt16: function getInt16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments[1]);\n return (bytes[1] << 8 | bytes[0]) << 16 >> 16;\n },\n getUint16: function getUint16(byteOffset /* , littleEndian */) {\n var bytes = get(this, 2, byteOffset, arguments[1]);\n return bytes[1] << 8 | bytes[0];\n },\n getInt32: function getInt32(byteOffset /* , littleEndian */) {\n return unpackI32(get(this, 4, byteOffset, arguments[1]));\n },\n getUint32: function getUint32(byteOffset /* , littleEndian */) {\n return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;\n },\n getFloat32: function getFloat32(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);\n },\n getFloat64: function getFloat64(byteOffset /* , littleEndian */) {\n return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);\n },\n setInt8: function setInt8(byteOffset, value) {\n set(this, 1, byteOffset, packI8, value);\n },\n setUint8: function setUint8(byteOffset, value) {\n set(this, 1, byteOffset, packI8, value);\n },\n setInt16: function setInt16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packI16, value, arguments[2]);\n },\n setUint16: function setUint16(byteOffset, value /* , littleEndian */) {\n set(this, 2, byteOffset, packI16, value, arguments[2]);\n },\n setInt32: function setInt32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packI32, value, arguments[2]);\n },\n setUint32: function setUint32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packI32, value, arguments[2]);\n },\n setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {\n set(this, 4, byteOffset, packF32, value, arguments[2]);\n },\n setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {\n set(this, 8, byteOffset, packF64, value, arguments[2]);\n }\n });\n} else {\n if (!fails(function () {\n $ArrayBuffer(1);\n }) || !fails(function () {\n new $ArrayBuffer(-1); // eslint-disable-line no-new\n }) || fails(function () {\n new $ArrayBuffer(); // eslint-disable-line no-new\n new $ArrayBuffer(1.5); // eslint-disable-line no-new\n new $ArrayBuffer(NaN); // eslint-disable-line no-new\n return $ArrayBuffer.name != ARRAY_BUFFER;\n })) {\n $ArrayBuffer = function ArrayBuffer(length) {\n anInstance(this, $ArrayBuffer);\n return new BaseBuffer(toIndex(length));\n };\n var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];\n for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {\n if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);\n }\n if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;\n }\n // iOS Safari 7.x bug\n var view = new $DataView(new $ArrayBuffer(2));\n var $setInt8 = $DataView[PROTOTYPE].setInt8;\n view.setInt8(0, 2147483648);\n view.setInt8(1, 2147483649);\n if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {\n setInt8: function setInt8(byteOffset, value) {\n $setInt8.call(this, byteOffset, value << 24 >> 24);\n },\n setUint8: function setUint8(byteOffset, value) {\n $setInt8.call(this, byteOffset, value << 24 >> 24);\n }\n }, true);\n}\nsetToStringTag($ArrayBuffer, ARRAY_BUFFER);\nsetToStringTag($DataView, DATA_VIEW);\nhide($DataView[PROTOTYPE], $typed.VIEW, true);\nexports[ARRAY_BUFFER] = $ArrayBuffer;\nexports[DATA_VIEW] = $DataView;\n","// 7.3.20 SpeciesConstructor(O, defaultConstructor)\nvar anObject = require('./_an-object');\nvar aFunction = require('./_a-function');\nvar SPECIES = require('./_wks')('species');\nmodule.exports = function (O, D) {\n var C = anObject(O).constructor;\n var S;\n return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);\n};\n","'use strict';\nvar global = require('./_global');\nvar dP = require('./_object-dp');\nvar DESCRIPTORS = require('./_descriptors');\nvar SPECIES = require('./_wks')('species');\n\nmodule.exports = function (KEY) {\n var C = global[KEY];\n if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {\n configurable: true,\n get: function () { return this; }\n });\n};\n","'use strict';\nvar $export = require('./_export');\nvar $typed = require('./_typed');\nvar buffer = require('./_typed-buffer');\nvar anObject = require('./_an-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\nvar isObject = require('./_is-object');\nvar ArrayBuffer = require('./_global').ArrayBuffer;\nvar speciesConstructor = require('./_species-constructor');\nvar $ArrayBuffer = buffer.ArrayBuffer;\nvar $DataView = buffer.DataView;\nvar $isView = $typed.ABV && ArrayBuffer.isView;\nvar $slice = $ArrayBuffer.prototype.slice;\nvar VIEW = $typed.VIEW;\nvar ARRAY_BUFFER = 'ArrayBuffer';\n\n$export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer });\n\n$export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {\n // 24.1.3.1 ArrayBuffer.isView(arg)\n isView: function isView(it) {\n return $isView && $isView(it) || isObject(it) && VIEW in it;\n }\n});\n\n$export($export.P + $export.U + $export.F * require('./_fails')(function () {\n return !new $ArrayBuffer(2).slice(1, undefined).byteLength;\n}), ARRAY_BUFFER, {\n // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)\n slice: function slice(start, end) {\n if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix\n var len = anObject(this).byteLength;\n var first = toAbsoluteIndex(start, len);\n var final = toAbsoluteIndex(end === undefined ? len : end, len);\n var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(final - first));\n var viewS = new $DataView(this);\n var viewT = new $DataView(result);\n var index = 0;\n while (first < final) {\n viewT.setUint8(index++, viewS.getUint8(first++));\n } return result;\n }\n});\n\nrequire('./_set-species')(ARRAY_BUFFER);\n","// getting tag from 19.1.3.6 Object.prototype.toString()\nvar cof = require('./_cof');\nvar TAG = require('./_wks')('toStringTag');\n// ES3 wrong here\nvar ARG = cof(function () { return arguments; }()) == 'Arguments';\n\n// fallback for IE11 Script Access Denied error\nvar tryGet = function (it, key) {\n try {\n return it[key];\n } catch (e) { /* empty */ }\n};\n\nmodule.exports = function (it) {\n var O, T, B;\n return it === undefined ? 'Undefined' : it === null ? 'Null'\n // @@toStringTag case\n : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T\n // builtinTag case\n : ARG ? cof(O)\n // ES3 arguments fallback\n : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;\n};\n","// check on default Array iterator\nvar Iterators = require('./_iterators');\nvar ITERATOR = require('./_wks')('iterator');\nvar ArrayProto = Array.prototype;\n\nmodule.exports = function (it) {\n return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);\n};\n","// 19.1.2.14 / 15.2.3.14 Object.keys(O)\nvar $keys = require('./_object-keys-internal');\nvar enumBugKeys = require('./_enum-bug-keys');\n\nmodule.exports = Object.keys || function keys(O) {\n return $keys(O, enumBugKeys);\n};\n","var dP = require('./_object-dp');\nvar anObject = require('./_an-object');\nvar getKeys = require('./_object-keys');\n\nmodule.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {\n anObject(O);\n var keys = getKeys(Properties);\n var length = keys.length;\n var i = 0;\n var P;\n while (length > i) dP.f(O, P = keys[i++], Properties[P]);\n return O;\n};\n","var document = require('./_global').document;\nmodule.exports = document && document.documentElement;\n","// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])\nvar anObject = require('./_an-object');\nvar dPs = require('./_object-dps');\nvar enumBugKeys = require('./_enum-bug-keys');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar Empty = function () { /* empty */ };\nvar PROTOTYPE = 'prototype';\n\n// Create object with fake `null` prototype: use iframe Object with cleared prototype\nvar createDict = function () {\n // Thrash, waste and sodomy: IE GC bug\n var iframe = require('./_dom-create')('iframe');\n var i = enumBugKeys.length;\n var lt = '<';\n var gt = '>';\n var iframeDocument;\n iframe.style.display = 'none';\n require('./_html').appendChild(iframe);\n iframe.src = 'javascript:'; // eslint-disable-line no-script-url\n // createDict = iframe.contentWindow.Object;\n // html.removeChild(iframe);\n iframeDocument = iframe.contentWindow.document;\n iframeDocument.open();\n iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);\n iframeDocument.close();\n createDict = iframeDocument.F;\n while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];\n return createDict();\n};\n\nmodule.exports = Object.create || function create(O, Properties) {\n var result;\n if (O !== null) {\n Empty[PROTOTYPE] = anObject(O);\n result = new Empty();\n Empty[PROTOTYPE] = null;\n // add \"__proto__\" for Object.getPrototypeOf polyfill\n result[IE_PROTO] = O;\n } else result = createDict();\n return Properties === undefined ? result : dPs(result, Properties);\n};\n","// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)\nvar has = require('./_has');\nvar toObject = require('./_to-object');\nvar IE_PROTO = require('./_shared-key')('IE_PROTO');\nvar ObjectProto = Object.prototype;\n\nmodule.exports = Object.getPrototypeOf || function (O) {\n O = toObject(O);\n if (has(O, IE_PROTO)) return O[IE_PROTO];\n if (typeof O.constructor == 'function' && O instanceof O.constructor) {\n return O.constructor.prototype;\n } return O instanceof Object ? ObjectProto : null;\n};\n","var classof = require('./_classof');\nvar ITERATOR = require('./_wks')('iterator');\nvar Iterators = require('./_iterators');\nmodule.exports = require('./_core').getIteratorMethod = function (it) {\n if (it != undefined) return it[ITERATOR]\n || it['@@iterator']\n || Iterators[classof(it)];\n};\n","// 7.2.2 IsArray(argument)\nvar cof = require('./_cof');\nmodule.exports = Array.isArray || function isArray(arg) {\n return cof(arg) == 'Array';\n};\n","var isObject = require('./_is-object');\nvar isArray = require('./_is-array');\nvar SPECIES = require('./_wks')('species');\n\nmodule.exports = function (original) {\n var C;\n if (isArray(original)) {\n C = original.constructor;\n // cross-realm fallback\n if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;\n if (isObject(C)) {\n C = C[SPECIES];\n if (C === null) C = undefined;\n }\n } return C === undefined ? Array : C;\n};\n","// 9.4.2.3 ArraySpeciesCreate(originalArray, length)\nvar speciesConstructor = require('./_array-species-constructor');\n\nmodule.exports = function (original, length) {\n return new (speciesConstructor(original))(length);\n};\n","// 0 -> Array#forEach\n// 1 -> Array#map\n// 2 -> Array#filter\n// 3 -> Array#some\n// 4 -> Array#every\n// 5 -> Array#find\n// 6 -> Array#findIndex\nvar ctx = require('./_ctx');\nvar IObject = require('./_iobject');\nvar toObject = require('./_to-object');\nvar toLength = require('./_to-length');\nvar asc = require('./_array-species-create');\nmodule.exports = function (TYPE, $create) {\n var IS_MAP = TYPE == 1;\n var IS_FILTER = TYPE == 2;\n var IS_SOME = TYPE == 3;\n var IS_EVERY = TYPE == 4;\n var IS_FIND_INDEX = TYPE == 6;\n var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;\n var create = $create || asc;\n return function ($this, callbackfn, that) {\n var O = toObject($this);\n var self = IObject(O);\n var f = ctx(callbackfn, that, 3);\n var length = toLength(self.length);\n var index = 0;\n var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;\n var val, res;\n for (;length > index; index++) if (NO_HOLES || index in self) {\n val = self[index];\n res = f(val, index, O);\n if (TYPE) {\n if (IS_MAP) result[index] = res; // map\n else if (res) switch (TYPE) {\n case 3: return true; // some\n case 5: return val; // find\n case 6: return index; // findIndex\n case 2: result.push(val); // filter\n } else if (IS_EVERY) return false; // every\n }\n }\n return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;\n };\n};\n","// 22.1.3.31 Array.prototype[@@unscopables]\nvar UNSCOPABLES = require('./_wks')('unscopables');\nvar ArrayProto = Array.prototype;\nif (ArrayProto[UNSCOPABLES] == undefined) require('./_hide')(ArrayProto, UNSCOPABLES, {});\nmodule.exports = function (key) {\n ArrayProto[UNSCOPABLES][key] = true;\n};\n","module.exports = function (done, value) {\n return { value: value, done: !!done };\n};\n","'use strict';\nvar create = require('./_object-create');\nvar descriptor = require('./_property-desc');\nvar setToStringTag = require('./_set-to-string-tag');\nvar IteratorPrototype = {};\n\n// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()\nrequire('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });\n\nmodule.exports = function (Constructor, NAME, next) {\n Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });\n setToStringTag(Constructor, NAME + ' Iterator');\n};\n","'use strict';\nvar LIBRARY = require('./_library');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar hide = require('./_hide');\nvar Iterators = require('./_iterators');\nvar $iterCreate = require('./_iter-create');\nvar setToStringTag = require('./_set-to-string-tag');\nvar getPrototypeOf = require('./_object-gpo');\nvar ITERATOR = require('./_wks')('iterator');\nvar BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`\nvar FF_ITERATOR = '@@iterator';\nvar KEYS = 'keys';\nvar VALUES = 'values';\n\nvar returnThis = function () { return this; };\n\nmodule.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {\n $iterCreate(Constructor, NAME, next);\n var getMethod = function (kind) {\n if (!BUGGY && kind in proto) return proto[kind];\n switch (kind) {\n case KEYS: return function keys() { return new Constructor(this, kind); };\n case VALUES: return function values() { return new Constructor(this, kind); };\n } return function entries() { return new Constructor(this, kind); };\n };\n var TAG = NAME + ' Iterator';\n var DEF_VALUES = DEFAULT == VALUES;\n var VALUES_BUG = false;\n var proto = Base.prototype;\n var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];\n var $default = $native || getMethod(DEFAULT);\n var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;\n var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;\n var methods, key, IteratorPrototype;\n // Fix native\n if ($anyNative) {\n IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));\n if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {\n // Set @@toStringTag to native iterators\n setToStringTag(IteratorPrototype, TAG, true);\n // fix for some old engines\n if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);\n }\n }\n // fix Array#{values, @@iterator}.name in V8 / FF\n if (DEF_VALUES && $native && $native.name !== VALUES) {\n VALUES_BUG = true;\n $default = function values() { return $native.call(this); };\n }\n // Define iterator\n if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {\n hide(proto, ITERATOR, $default);\n }\n // Plug for library\n Iterators[NAME] = $default;\n Iterators[TAG] = returnThis;\n if (DEFAULT) {\n methods = {\n values: DEF_VALUES ? $default : getMethod(VALUES),\n keys: IS_SET ? $default : getMethod(KEYS),\n entries: $entries\n };\n if (FORCED) for (key in methods) {\n if (!(key in proto)) redefine(proto, key, methods[key]);\n } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);\n }\n return methods;\n};\n","'use strict';\nvar addToUnscopables = require('./_add-to-unscopables');\nvar step = require('./_iter-step');\nvar Iterators = require('./_iterators');\nvar toIObject = require('./_to-iobject');\n\n// 22.1.3.4 Array.prototype.entries()\n// 22.1.3.13 Array.prototype.keys()\n// 22.1.3.29 Array.prototype.values()\n// 22.1.3.30 Array.prototype[@@iterator]()\nmodule.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {\n this._t = toIObject(iterated); // target\n this._i = 0; // next index\n this._k = kind; // kind\n// 22.1.5.2.1 %ArrayIteratorPrototype%.next()\n}, function () {\n var O = this._t;\n var kind = this._k;\n var index = this._i++;\n if (!O || index >= O.length) {\n this._t = undefined;\n return step(1);\n }\n if (kind == 'keys') return step(0, index);\n if (kind == 'values') return step(0, O[index]);\n return step(0, [index, O[index]]);\n}, 'values');\n\n// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)\nIterators.Arguments = Iterators.Array;\n\naddToUnscopables('keys');\naddToUnscopables('values');\naddToUnscopables('entries');\n","var ITERATOR = require('./_wks')('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var riter = [7][ITERATOR]();\n riter['return'] = function () { SAFE_CLOSING = true; };\n // eslint-disable-next-line no-throw-literal\n Array.from(riter, function () { throw 2; });\n} catch (e) { /* empty */ }\n\nmodule.exports = function (exec, skipClosing) {\n if (!skipClosing && !SAFE_CLOSING) return false;\n var safe = false;\n try {\n var arr = [7];\n var iter = arr[ITERATOR]();\n iter.next = function () { return { done: safe = true }; };\n arr[ITERATOR] = function () { return iter; };\n exec(arr);\n } catch (e) { /* empty */ }\n return safe;\n};\n","// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)\n'use strict';\nvar toObject = require('./_to-object');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar toLength = require('./_to-length');\n\nmodule.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {\n var O = toObject(this);\n var len = toLength(O.length);\n var to = toAbsoluteIndex(target, len);\n var from = toAbsoluteIndex(start, len);\n var end = arguments.length > 2 ? arguments[2] : undefined;\n var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);\n var inc = 1;\n if (from < to && to < from + count) {\n inc = -1;\n from += count - 1;\n to += count - 1;\n }\n while (count-- > 0) {\n if (from in O) O[to] = O[from];\n else delete O[to];\n to += inc;\n from += inc;\n } return O;\n};\n","exports.f = {}.propertyIsEnumerable;\n","var pIE = require('./_object-pie');\nvar createDesc = require('./_property-desc');\nvar toIObject = require('./_to-iobject');\nvar toPrimitive = require('./_to-primitive');\nvar has = require('./_has');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar gOPD = Object.getOwnPropertyDescriptor;\n\nexports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {\n O = toIObject(O);\n P = toPrimitive(P, true);\n if (IE8_DOM_DEFINE) try {\n return gOPD(O, P);\n } catch (e) { /* empty */ }\n if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);\n};\n","'use strict';\nif (require('./_descriptors')) {\n var LIBRARY = require('./_library');\n var global = require('./_global');\n var fails = require('./_fails');\n var $export = require('./_export');\n var $typed = require('./_typed');\n var $buffer = require('./_typed-buffer');\n var ctx = require('./_ctx');\n var anInstance = require('./_an-instance');\n var propertyDesc = require('./_property-desc');\n var hide = require('./_hide');\n var redefineAll = require('./_redefine-all');\n var toInteger = require('./_to-integer');\n var toLength = require('./_to-length');\n var toIndex = require('./_to-index');\n var toAbsoluteIndex = require('./_to-absolute-index');\n var toPrimitive = require('./_to-primitive');\n var has = require('./_has');\n var classof = require('./_classof');\n var isObject = require('./_is-object');\n var toObject = require('./_to-object');\n var isArrayIter = require('./_is-array-iter');\n var create = require('./_object-create');\n var getPrototypeOf = require('./_object-gpo');\n var gOPN = require('./_object-gopn').f;\n var getIterFn = require('./core.get-iterator-method');\n var uid = require('./_uid');\n var wks = require('./_wks');\n var createArrayMethod = require('./_array-methods');\n var createArrayIncludes = require('./_array-includes');\n var speciesConstructor = require('./_species-constructor');\n var ArrayIterators = require('./es6.array.iterator');\n var Iterators = require('./_iterators');\n var $iterDetect = require('./_iter-detect');\n var setSpecies = require('./_set-species');\n var arrayFill = require('./_array-fill');\n var arrayCopyWithin = require('./_array-copy-within');\n var $DP = require('./_object-dp');\n var $GOPD = require('./_object-gopd');\n var dP = $DP.f;\n var gOPD = $GOPD.f;\n var RangeError = global.RangeError;\n var TypeError = global.TypeError;\n var Uint8Array = global.Uint8Array;\n var ARRAY_BUFFER = 'ArrayBuffer';\n var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;\n var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';\n var PROTOTYPE = 'prototype';\n var ArrayProto = Array[PROTOTYPE];\n var $ArrayBuffer = $buffer.ArrayBuffer;\n var $DataView = $buffer.DataView;\n var arrayForEach = createArrayMethod(0);\n var arrayFilter = createArrayMethod(2);\n var arraySome = createArrayMethod(3);\n var arrayEvery = createArrayMethod(4);\n var arrayFind = createArrayMethod(5);\n var arrayFindIndex = createArrayMethod(6);\n var arrayIncludes = createArrayIncludes(true);\n var arrayIndexOf = createArrayIncludes(false);\n var arrayValues = ArrayIterators.values;\n var arrayKeys = ArrayIterators.keys;\n var arrayEntries = ArrayIterators.entries;\n var arrayLastIndexOf = ArrayProto.lastIndexOf;\n var arrayReduce = ArrayProto.reduce;\n var arrayReduceRight = ArrayProto.reduceRight;\n var arrayJoin = ArrayProto.join;\n var arraySort = ArrayProto.sort;\n var arraySlice = ArrayProto.slice;\n var arrayToString = ArrayProto.toString;\n var arrayToLocaleString = ArrayProto.toLocaleString;\n var ITERATOR = wks('iterator');\n var TAG = wks('toStringTag');\n var TYPED_CONSTRUCTOR = uid('typed_constructor');\n var DEF_CONSTRUCTOR = uid('def_constructor');\n var ALL_CONSTRUCTORS = $typed.CONSTR;\n var TYPED_ARRAY = $typed.TYPED;\n var VIEW = $typed.VIEW;\n var WRONG_LENGTH = 'Wrong length!';\n\n var $map = createArrayMethod(1, function (O, length) {\n return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);\n });\n\n var LITTLE_ENDIAN = fails(function () {\n // eslint-disable-next-line no-undef\n return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;\n });\n\n var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {\n new Uint8Array(1).set({});\n });\n\n var toOffset = function (it, BYTES) {\n var offset = toInteger(it);\n if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');\n return offset;\n };\n\n var validate = function (it) {\n if (isObject(it) && TYPED_ARRAY in it) return it;\n throw TypeError(it + ' is not a typed array!');\n };\n\n var allocate = function (C, length) {\n if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {\n throw TypeError('It is not a typed array constructor!');\n } return new C(length);\n };\n\n var speciesFromList = function (O, list) {\n return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);\n };\n\n var fromList = function (C, list) {\n var index = 0;\n var length = list.length;\n var result = allocate(C, length);\n while (length > index) result[index] = list[index++];\n return result;\n };\n\n var addGetter = function (it, key, internal) {\n dP(it, key, { get: function () { return this._d[internal]; } });\n };\n\n var $from = function from(source /* , mapfn, thisArg */) {\n var O = toObject(source);\n var aLen = arguments.length;\n var mapfn = aLen > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var iterFn = getIterFn(O);\n var i, length, values, result, step, iterator;\n if (iterFn != undefined && !isArrayIter(iterFn)) {\n for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {\n values.push(step.value);\n } O = values;\n }\n if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);\n for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {\n result[i] = mapping ? mapfn(O[i], i) : O[i];\n }\n return result;\n };\n\n var $of = function of(/* ...items */) {\n var index = 0;\n var length = arguments.length;\n var result = allocate(this, length);\n while (length > index) result[index] = arguments[index++];\n return result;\n };\n\n // iOS Safari 6.x fails here\n var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); });\n\n var $toLocaleString = function toLocaleString() {\n return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);\n };\n\n var proto = {\n copyWithin: function copyWithin(target, start /* , end */) {\n return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);\n },\n every: function every(callbackfn /* , thisArg */) {\n return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars\n return arrayFill.apply(validate(this), arguments);\n },\n filter: function filter(callbackfn /* , thisArg */) {\n return speciesFromList(this, arrayFilter(validate(this), callbackfn,\n arguments.length > 1 ? arguments[1] : undefined));\n },\n find: function find(predicate /* , thisArg */) {\n return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n },\n findIndex: function findIndex(predicate /* , thisArg */) {\n return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);\n },\n forEach: function forEach(callbackfn /* , thisArg */) {\n arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n indexOf: function indexOf(searchElement /* , fromIndex */) {\n return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n },\n includes: function includes(searchElement /* , fromIndex */) {\n return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);\n },\n join: function join(separator) { // eslint-disable-line no-unused-vars\n return arrayJoin.apply(validate(this), arguments);\n },\n lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars\n return arrayLastIndexOf.apply(validate(this), arguments);\n },\n map: function map(mapfn /* , thisArg */) {\n return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars\n return arrayReduce.apply(validate(this), arguments);\n },\n reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars\n return arrayReduceRight.apply(validate(this), arguments);\n },\n reverse: function reverse() {\n var that = this;\n var length = validate(that).length;\n var middle = Math.floor(length / 2);\n var index = 0;\n var value;\n while (index < middle) {\n value = that[index];\n that[index++] = that[--length];\n that[length] = value;\n } return that;\n },\n some: function some(callbackfn /* , thisArg */) {\n return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n },\n sort: function sort(comparefn) {\n return arraySort.call(validate(this), comparefn);\n },\n subarray: function subarray(begin, end) {\n var O = validate(this);\n var length = O.length;\n var $begin = toAbsoluteIndex(begin, length);\n return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(\n O.buffer,\n O.byteOffset + $begin * O.BYTES_PER_ELEMENT,\n toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)\n );\n }\n };\n\n var $slice = function slice(start, end) {\n return speciesFromList(this, arraySlice.call(validate(this), start, end));\n };\n\n var $set = function set(arrayLike /* , offset */) {\n validate(this);\n var offset = toOffset(arguments[1], 1);\n var length = this.length;\n var src = toObject(arrayLike);\n var len = toLength(src.length);\n var index = 0;\n if (len + offset > length) throw RangeError(WRONG_LENGTH);\n while (index < len) this[offset + index] = src[index++];\n };\n\n var $iterators = {\n entries: function entries() {\n return arrayEntries.call(validate(this));\n },\n keys: function keys() {\n return arrayKeys.call(validate(this));\n },\n values: function values() {\n return arrayValues.call(validate(this));\n }\n };\n\n var isTAIndex = function (target, key) {\n return isObject(target)\n && target[TYPED_ARRAY]\n && typeof key != 'symbol'\n && key in target\n && String(+key) == String(key);\n };\n var $getDesc = function getOwnPropertyDescriptor(target, key) {\n return isTAIndex(target, key = toPrimitive(key, true))\n ? propertyDesc(2, target[key])\n : gOPD(target, key);\n };\n var $setDesc = function defineProperty(target, key, desc) {\n if (isTAIndex(target, key = toPrimitive(key, true))\n && isObject(desc)\n && has(desc, 'value')\n && !has(desc, 'get')\n && !has(desc, 'set')\n // TODO: add validation descriptor w/o calling accessors\n && !desc.configurable\n && (!has(desc, 'writable') || desc.writable)\n && (!has(desc, 'enumerable') || desc.enumerable)\n ) {\n target[key] = desc.value;\n return target;\n } return dP(target, key, desc);\n };\n\n if (!ALL_CONSTRUCTORS) {\n $GOPD.f = $getDesc;\n $DP.f = $setDesc;\n }\n\n $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {\n getOwnPropertyDescriptor: $getDesc,\n defineProperty: $setDesc\n });\n\n if (fails(function () { arrayToString.call({}); })) {\n arrayToString = arrayToLocaleString = function toString() {\n return arrayJoin.call(this);\n };\n }\n\n var $TypedArrayPrototype$ = redefineAll({}, proto);\n redefineAll($TypedArrayPrototype$, $iterators);\n hide($TypedArrayPrototype$, ITERATOR, $iterators.values);\n redefineAll($TypedArrayPrototype$, {\n slice: $slice,\n set: $set,\n constructor: function () { /* noop */ },\n toString: arrayToString,\n toLocaleString: $toLocaleString\n });\n addGetter($TypedArrayPrototype$, 'buffer', 'b');\n addGetter($TypedArrayPrototype$, 'byteOffset', 'o');\n addGetter($TypedArrayPrototype$, 'byteLength', 'l');\n addGetter($TypedArrayPrototype$, 'length', 'e');\n dP($TypedArrayPrototype$, TAG, {\n get: function () { return this[TYPED_ARRAY]; }\n });\n\n // eslint-disable-next-line max-statements\n module.exports = function (KEY, BYTES, wrapper, CLAMPED) {\n CLAMPED = !!CLAMPED;\n var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';\n var GETTER = 'get' + KEY;\n var SETTER = 'set' + KEY;\n var TypedArray = global[NAME];\n var Base = TypedArray || {};\n var TAC = TypedArray && getPrototypeOf(TypedArray);\n var FORCED = !TypedArray || !$typed.ABV;\n var O = {};\n var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];\n var getter = function (that, index) {\n var data = that._d;\n return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);\n };\n var setter = function (that, index, value) {\n var data = that._d;\n if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;\n data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);\n };\n var addElement = function (that, index) {\n dP(that, index, {\n get: function () {\n return getter(this, index);\n },\n set: function (value) {\n return setter(this, index, value);\n },\n enumerable: true\n });\n };\n if (FORCED) {\n TypedArray = wrapper(function (that, data, $offset, $length) {\n anInstance(that, TypedArray, NAME, '_d');\n var index = 0;\n var offset = 0;\n var buffer, byteLength, length, klass;\n if (!isObject(data)) {\n length = toIndex(data);\n byteLength = length * BYTES;\n buffer = new $ArrayBuffer(byteLength);\n } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {\n buffer = data;\n offset = toOffset($offset, BYTES);\n var $len = data.byteLength;\n if ($length === undefined) {\n if ($len % BYTES) throw RangeError(WRONG_LENGTH);\n byteLength = $len - offset;\n if (byteLength < 0) throw RangeError(WRONG_LENGTH);\n } else {\n byteLength = toLength($length) * BYTES;\n if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);\n }\n length = byteLength / BYTES;\n } else if (TYPED_ARRAY in data) {\n return fromList(TypedArray, data);\n } else {\n return $from.call(TypedArray, data);\n }\n hide(that, '_d', {\n b: buffer,\n o: offset,\n l: byteLength,\n e: length,\n v: new $DataView(buffer)\n });\n while (index < length) addElement(that, index++);\n });\n TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);\n hide(TypedArrayPrototype, 'constructor', TypedArray);\n } else if (!fails(function () {\n TypedArray(1);\n }) || !fails(function () {\n new TypedArray(-1); // eslint-disable-line no-new\n }) || !$iterDetect(function (iter) {\n new TypedArray(); // eslint-disable-line no-new\n new TypedArray(null); // eslint-disable-line no-new\n new TypedArray(1.5); // eslint-disable-line no-new\n new TypedArray(iter); // eslint-disable-line no-new\n }, true)) {\n TypedArray = wrapper(function (that, data, $offset, $length) {\n anInstance(that, TypedArray, NAME);\n var klass;\n // `ws` module bug, temporarily remove validation length for Uint8Array\n // https://github.com/websockets/ws/pull/645\n if (!isObject(data)) return new Base(toIndex(data));\n if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {\n return $length !== undefined\n ? new Base(data, toOffset($offset, BYTES), $length)\n : $offset !== undefined\n ? new Base(data, toOffset($offset, BYTES))\n : new Base(data);\n }\n if (TYPED_ARRAY in data) return fromList(TypedArray, data);\n return $from.call(TypedArray, data);\n });\n arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {\n if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);\n });\n TypedArray[PROTOTYPE] = TypedArrayPrototype;\n if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;\n }\n var $nativeIterator = TypedArrayPrototype[ITERATOR];\n var CORRECT_ITER_NAME = !!$nativeIterator\n && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);\n var $iterator = $iterators.values;\n hide(TypedArray, TYPED_CONSTRUCTOR, true);\n hide(TypedArrayPrototype, TYPED_ARRAY, NAME);\n hide(TypedArrayPrototype, VIEW, true);\n hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);\n\n if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {\n dP(TypedArrayPrototype, TAG, {\n get: function () { return NAME; }\n });\n }\n\n O[NAME] = TypedArray;\n\n $export($export.G + $export.W + $export.F * (TypedArray != Base), O);\n\n $export($export.S, NAME, {\n BYTES_PER_ELEMENT: BYTES\n });\n\n $export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, {\n from: $from,\n of: $of\n });\n\n if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);\n\n $export($export.P, NAME, proto);\n\n setSpecies(NAME);\n\n $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });\n\n $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);\n\n if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;\n\n $export($export.P + $export.F * fails(function () {\n new TypedArray(1).slice();\n }), NAME, { slice: $slice });\n\n $export($export.P + $export.F * (fails(function () {\n return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();\n }) || !fails(function () {\n TypedArrayPrototype.toLocaleString.call([1, 2]);\n })), NAME, { toLocaleString: $toLocaleString });\n\n Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;\n if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);\n };\n} else module.exports = function () { /* empty */ };\n","require('./_typed-array')('Int8', 1, function (init) {\n return function Int8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint8', 1, function (init) {\n return function Uint8Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint8', 1, function (init) {\n return function Uint8ClampedArray(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n}, true);\n","require('./_typed-array')('Int16', 2, function (init) {\n return function Int16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint16', 2, function (init) {\n return function Uint16Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Int32', 4, function (init) {\n return function Int32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Uint32', 4, function (init) {\n return function Uint32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Float32', 4, function (init) {\n return function Float32Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","require('./_typed-array')('Float64', 8, function (init) {\n return function Float64Array(data, byteOffset, length) {\n return init(this, data, byteOffset, length);\n };\n});\n","// call something on iterator step with safe closing on error\nvar anObject = require('./_an-object');\nmodule.exports = function (iterator, fn, value, entries) {\n try {\n return entries ? fn(anObject(value)[0], value[1]) : fn(value);\n // 7.4.6 IteratorClose(iterator, completion)\n } catch (e) {\n var ret = iterator['return'];\n if (ret !== undefined) anObject(ret.call(iterator));\n throw e;\n }\n};\n","var ctx = require('./_ctx');\nvar call = require('./_iter-call');\nvar isArrayIter = require('./_is-array-iter');\nvar anObject = require('./_an-object');\nvar toLength = require('./_to-length');\nvar getIterFn = require('./core.get-iterator-method');\nvar BREAK = {};\nvar RETURN = {};\nvar exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {\n var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);\n var f = ctx(fn, that, entries ? 2 : 1);\n var index = 0;\n var length, step, iterator, result;\n if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');\n // fast case for arrays with default iterator\n if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {\n result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);\n if (result === BREAK || result === RETURN) return result;\n } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {\n result = call(iterator, f, step.value, entries);\n if (result === BREAK || result === RETURN) return result;\n }\n};\nexports.BREAK = BREAK;\nexports.RETURN = RETURN;\n","var META = require('./_uid')('meta');\nvar isObject = require('./_is-object');\nvar has = require('./_has');\nvar setDesc = require('./_object-dp').f;\nvar id = 0;\nvar isExtensible = Object.isExtensible || function () {\n return true;\n};\nvar FREEZE = !require('./_fails')(function () {\n return isExtensible(Object.preventExtensions({}));\n});\nvar setMeta = function (it) {\n setDesc(it, META, { value: {\n i: 'O' + ++id, // object ID\n w: {} // weak collections IDs\n } });\n};\nvar fastKey = function (it, create) {\n // return primitive with prefix\n if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;\n if (!has(it, META)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return 'F';\n // not necessary to add metadata\n if (!create) return 'E';\n // add missing metadata\n setMeta(it);\n // return object ID\n } return it[META].i;\n};\nvar getWeak = function (it, create) {\n if (!has(it, META)) {\n // can't set metadata to uncaught frozen object\n if (!isExtensible(it)) return true;\n // not necessary to add metadata\n if (!create) return false;\n // add missing metadata\n setMeta(it);\n // return hash weak collections IDs\n } return it[META].w;\n};\n// add metadata on freeze-family methods calling\nvar onFreeze = function (it) {\n if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);\n return it;\n};\nvar meta = module.exports = {\n KEY: META,\n NEED: false,\n fastKey: fastKey,\n getWeak: getWeak,\n onFreeze: onFreeze\n};\n","var isObject = require('./_is-object');\nmodule.exports = function (it, TYPE) {\n if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');\n return it;\n};\n","'use strict';\nvar dP = require('./_object-dp').f;\nvar create = require('./_object-create');\nvar redefineAll = require('./_redefine-all');\nvar ctx = require('./_ctx');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar $iterDefine = require('./_iter-define');\nvar step = require('./_iter-step');\nvar setSpecies = require('./_set-species');\nvar DESCRIPTORS = require('./_descriptors');\nvar fastKey = require('./_meta').fastKey;\nvar validate = require('./_validate-collection');\nvar SIZE = DESCRIPTORS ? '_s' : 'size';\n\nvar getEntry = function (that, key) {\n // fast case\n var index = fastKey(key);\n var entry;\n if (index !== 'F') return that._i[index];\n // frozen object case\n for (entry = that._f; entry; entry = entry.n) {\n if (entry.k == key) return entry;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, NAME, '_i');\n that._t = NAME; // collection type\n that._i = create(null); // index\n that._f = undefined; // first entry\n that._l = undefined; // last entry\n that[SIZE] = 0; // size\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n });\n redefineAll(C.prototype, {\n // 23.1.3.1 Map.prototype.clear()\n // 23.2.3.2 Set.prototype.clear()\n clear: function clear() {\n for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {\n entry.r = true;\n if (entry.p) entry.p = entry.p.n = undefined;\n delete data[entry.i];\n }\n that._f = that._l = undefined;\n that[SIZE] = 0;\n },\n // 23.1.3.3 Map.prototype.delete(key)\n // 23.2.3.4 Set.prototype.delete(value)\n 'delete': function (key) {\n var that = validate(this, NAME);\n var entry = getEntry(that, key);\n if (entry) {\n var next = entry.n;\n var prev = entry.p;\n delete that._i[entry.i];\n entry.r = true;\n if (prev) prev.n = next;\n if (next) next.p = prev;\n if (that._f == entry) that._f = next;\n if (that._l == entry) that._l = prev;\n that[SIZE]--;\n } return !!entry;\n },\n // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)\n // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)\n forEach: function forEach(callbackfn /* , that = undefined */) {\n validate(this, NAME);\n var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);\n var entry;\n while (entry = entry ? entry.n : this._f) {\n f(entry.v, entry.k, this);\n // revert to the last existing entry\n while (entry && entry.r) entry = entry.p;\n }\n },\n // 23.1.3.7 Map.prototype.has(key)\n // 23.2.3.7 Set.prototype.has(value)\n has: function has(key) {\n return !!getEntry(validate(this, NAME), key);\n }\n });\n if (DESCRIPTORS) dP(C.prototype, 'size', {\n get: function () {\n return validate(this, NAME)[SIZE];\n }\n });\n return C;\n },\n def: function (that, key, value) {\n var entry = getEntry(that, key);\n var prev, index;\n // change existing entry\n if (entry) {\n entry.v = value;\n // create new entry\n } else {\n that._l = entry = {\n i: index = fastKey(key, true), // <- index\n k: key, // <- key\n v: value, // <- value\n p: prev = that._l, // <- previous entry\n n: undefined, // <- next entry\n r: false // <- removed\n };\n if (!that._f) that._f = entry;\n if (prev) prev.n = entry;\n that[SIZE]++;\n // add to index\n if (index !== 'F') that._i[index] = entry;\n } return that;\n },\n getEntry: getEntry,\n setStrong: function (C, NAME, IS_MAP) {\n // add .keys, .values, .entries, [@@iterator]\n // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11\n $iterDefine(C, NAME, function (iterated, kind) {\n this._t = validate(iterated, NAME); // target\n this._k = kind; // kind\n this._l = undefined; // previous\n }, function () {\n var that = this;\n var kind = that._k;\n var entry = that._l;\n // revert to the last existing entry\n while (entry && entry.r) entry = entry.p;\n // get next entry\n if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {\n // or finish the iteration\n that._t = undefined;\n return step(1);\n }\n // return step by kind\n if (kind == 'keys') return step(0, entry.k);\n if (kind == 'values') return step(0, entry.v);\n return step(0, [entry.k, entry.v]);\n }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);\n\n // add [@@species], 23.1.2.2, 23.2.2.2\n setSpecies(NAME);\n }\n};\n","// Works with __proto__ only. Old v8 can't work with null proto objects.\n/* eslint-disable no-proto */\nvar isObject = require('./_is-object');\nvar anObject = require('./_an-object');\nvar check = function (O, proto) {\n anObject(O);\n if (!isObject(proto) && proto !== null) throw TypeError(proto + \": can't set as prototype!\");\n};\nmodule.exports = {\n set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line\n function (test, buggy, set) {\n try {\n set = require('./_ctx')(Function.call, require('./_object-gopd').f(Object.prototype, '__proto__').set, 2);\n set(test, []);\n buggy = !(test instanceof Array);\n } catch (e) { buggy = true; }\n return function setPrototypeOf(O, proto) {\n check(O, proto);\n if (buggy) O.__proto__ = proto;\n else set(O, proto);\n return O;\n };\n }({}, false) : undefined),\n check: check\n};\n","var isObject = require('./_is-object');\nvar setPrototypeOf = require('./_set-proto').set;\nmodule.exports = function (that, target, C) {\n var S = target.constructor;\n var P;\n if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {\n setPrototypeOf(that, P);\n } return that;\n};\n","'use strict';\nvar global = require('./_global');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar redefineAll = require('./_redefine-all');\nvar meta = require('./_meta');\nvar forOf = require('./_for-of');\nvar anInstance = require('./_an-instance');\nvar isObject = require('./_is-object');\nvar fails = require('./_fails');\nvar $iterDetect = require('./_iter-detect');\nvar setToStringTag = require('./_set-to-string-tag');\nvar inheritIfRequired = require('./_inherit-if-required');\n\nmodule.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {\n var Base = global[NAME];\n var C = Base;\n var ADDER = IS_MAP ? 'set' : 'add';\n var proto = C && C.prototype;\n var O = {};\n var fixMethod = function (KEY) {\n var fn = proto[KEY];\n redefine(proto, KEY,\n KEY == 'delete' ? function (a) {\n return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'has' ? function has(a) {\n return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'get' ? function get(a) {\n return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);\n } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }\n : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }\n );\n };\n if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {\n new C().entries().next();\n }))) {\n // create collection constructor\n C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);\n redefineAll(C.prototype, methods);\n meta.NEED = true;\n } else {\n var instance = new C();\n // early implementations not supports chaining\n var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;\n // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false\n var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });\n // most early implementations doesn't supports iterables, most modern - not close it correctly\n var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new\n // for early implementations -0 and +0 not the same\n var BUGGY_ZERO = !IS_WEAK && fails(function () {\n // V8 ~ Chromium 42- fails only with 5+ elements\n var $instance = new C();\n var index = 5;\n while (index--) $instance[ADDER](index, index);\n return !$instance.has(-0);\n });\n if (!ACCEPT_ITERABLES) {\n C = wrapper(function (target, iterable) {\n anInstance(target, C, NAME);\n var that = inheritIfRequired(new Base(), target, C);\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n return that;\n });\n C.prototype = proto;\n proto.constructor = C;\n }\n if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {\n fixMethod('delete');\n fixMethod('has');\n IS_MAP && fixMethod('get');\n }\n if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);\n // weak collections should not contains .clear method\n if (IS_WEAK && proto.clear) delete proto.clear;\n }\n\n setToStringTag(C, NAME);\n\n O[NAME] = C;\n $export($export.G + $export.W + $export.F * (C != Base), O);\n\n if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);\n\n return C;\n};\n","'use strict';\nvar strong = require('./_collection-strong');\nvar validate = require('./_validate-collection');\nvar MAP = 'Map';\n\n// 23.1 Map Objects\nmodule.exports = require('./_collection')(MAP, function (get) {\n return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.1.3.6 Map.prototype.get(key)\n get: function get(key) {\n var entry = strong.getEntry(validate(this, MAP), key);\n return entry && entry.v;\n },\n // 23.1.3.9 Map.prototype.set(key, value)\n set: function set(key, value) {\n return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);\n }\n}, strong, true);\n","'use strict';\nvar strong = require('./_collection-strong');\nvar validate = require('./_validate-collection');\nvar SET = 'Set';\n\n// 23.2 Set Objects\nmodule.exports = require('./_collection')(SET, function (get) {\n return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.2.3.1 Set.prototype.add(value)\n add: function add(value) {\n return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);\n }\n}, strong);\n","exports.f = Object.getOwnPropertySymbols;\n","'use strict';\n// 19.1.2.1 Object.assign(target, source, ...)\nvar getKeys = require('./_object-keys');\nvar gOPS = require('./_object-gops');\nvar pIE = require('./_object-pie');\nvar toObject = require('./_to-object');\nvar IObject = require('./_iobject');\nvar $assign = Object.assign;\n\n// should work with symbols and should have deterministic property order (V8 bug)\nmodule.exports = !$assign || require('./_fails')(function () {\n var A = {};\n var B = {};\n // eslint-disable-next-line no-undef\n var S = Symbol();\n var K = 'abcdefghijklmnopqrst';\n A[S] = 7;\n K.split('').forEach(function (k) { B[k] = k; });\n return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;\n}) ? function assign(target, source) { // eslint-disable-line no-unused-vars\n var T = toObject(target);\n var aLen = arguments.length;\n var index = 1;\n var getSymbols = gOPS.f;\n var isEnum = pIE.f;\n while (aLen > index) {\n var S = IObject(arguments[index++]);\n var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);\n var length = keys.length;\n var j = 0;\n var key;\n while (length > j) if (isEnum.call(S, key = keys[j++])) T[key] = S[key];\n } return T;\n} : $assign;\n","'use strict';\nvar redefineAll = require('./_redefine-all');\nvar getWeak = require('./_meta').getWeak;\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar createArrayMethod = require('./_array-methods');\nvar $has = require('./_has');\nvar validate = require('./_validate-collection');\nvar arrayFind = createArrayMethod(5);\nvar arrayFindIndex = createArrayMethod(6);\nvar id = 0;\n\n// fallback for uncaught frozen keys\nvar uncaughtFrozenStore = function (that) {\n return that._l || (that._l = new UncaughtFrozenStore());\n};\nvar UncaughtFrozenStore = function () {\n this.a = [];\n};\nvar findUncaughtFrozen = function (store, key) {\n return arrayFind(store.a, function (it) {\n return it[0] === key;\n });\n};\nUncaughtFrozenStore.prototype = {\n get: function (key) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) return entry[1];\n },\n has: function (key) {\n return !!findUncaughtFrozen(this, key);\n },\n set: function (key, value) {\n var entry = findUncaughtFrozen(this, key);\n if (entry) entry[1] = value;\n else this.a.push([key, value]);\n },\n 'delete': function (key) {\n var index = arrayFindIndex(this.a, function (it) {\n return it[0] === key;\n });\n if (~index) this.a.splice(index, 1);\n return !!~index;\n }\n};\n\nmodule.exports = {\n getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {\n var C = wrapper(function (that, iterable) {\n anInstance(that, C, NAME, '_i');\n that._t = NAME; // collection type\n that._i = id++; // collection id\n that._l = undefined; // leak store for uncaught frozen objects\n if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);\n });\n redefineAll(C.prototype, {\n // 23.3.3.2 WeakMap.prototype.delete(key)\n // 23.4.3.3 WeakSet.prototype.delete(value)\n 'delete': function (key) {\n if (!isObject(key)) return false;\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);\n return data && $has(data, this._i) && delete data[this._i];\n },\n // 23.3.3.4 WeakMap.prototype.has(key)\n // 23.4.3.4 WeakSet.prototype.has(value)\n has: function has(key) {\n if (!isObject(key)) return false;\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);\n return data && $has(data, this._i);\n }\n });\n return C;\n },\n def: function (that, key, value) {\n var data = getWeak(anObject(key), true);\n if (data === true) uncaughtFrozenStore(that).set(key, value);\n else data[that._i] = value;\n return that;\n },\n ufstore: uncaughtFrozenStore\n};\n","'use strict';\nvar each = require('./_array-methods')(0);\nvar redefine = require('./_redefine');\nvar meta = require('./_meta');\nvar assign = require('./_object-assign');\nvar weak = require('./_collection-weak');\nvar isObject = require('./_is-object');\nvar fails = require('./_fails');\nvar validate = require('./_validate-collection');\nvar WEAK_MAP = 'WeakMap';\nvar getWeak = meta.getWeak;\nvar isExtensible = Object.isExtensible;\nvar uncaughtFrozenStore = weak.ufstore;\nvar tmp = {};\nvar InternalMap;\n\nvar wrapper = function (get) {\n return function WeakMap() {\n return get(this, arguments.length > 0 ? arguments[0] : undefined);\n };\n};\n\nvar methods = {\n // 23.3.3.3 WeakMap.prototype.get(key)\n get: function get(key) {\n if (isObject(key)) {\n var data = getWeak(key);\n if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);\n return data ? data[this._i] : undefined;\n }\n },\n // 23.3.3.5 WeakMap.prototype.set(key, value)\n set: function set(key, value) {\n return weak.def(validate(this, WEAK_MAP), key, value);\n }\n};\n\n// 23.3 WeakMap Objects\nvar $WeakMap = module.exports = require('./_collection')(WEAK_MAP, wrapper, methods, weak, true, true);\n\n// IE11 WeakMap frozen keys fix\nif (fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {\n InternalMap = weak.getConstructor(wrapper, WEAK_MAP);\n assign(InternalMap.prototype, methods);\n meta.NEED = true;\n each(['delete', 'has', 'get', 'set'], function (key) {\n var proto = $WeakMap.prototype;\n var method = proto[key];\n redefine(proto, key, function (a, b) {\n // store frozen objects on internal weakmap shim\n if (isObject(a) && !isExtensible(a)) {\n if (!this._f) this._f = new InternalMap();\n var result = this._f[key](a, b);\n return key == 'set' ? this : result;\n // store all the rest on native weakmap\n } return method.call(this, a, b);\n });\n });\n}\n","'use strict';\nvar weak = require('./_collection-weak');\nvar validate = require('./_validate-collection');\nvar WEAK_SET = 'WeakSet';\n\n// 23.4 WeakSet Objects\nrequire('./_collection')(WEAK_SET, function (get) {\n return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };\n}, {\n // 23.4.3.1 WeakSet.prototype.add(value)\n add: function add(value) {\n return weak.def(validate(this, WEAK_SET), value, true);\n }\n}, weak, false, true);\n","// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)\nvar $export = require('./_export');\nvar aFunction = require('./_a-function');\nvar anObject = require('./_an-object');\nvar rApply = (require('./_global').Reflect || {}).apply;\nvar fApply = Function.apply;\n// MS Edge argumentsList argument is optional\n$export($export.S + $export.F * !require('./_fails')(function () {\n rApply(function () { /* empty */ });\n}), 'Reflect', {\n apply: function apply(target, thisArgument, argumentsList) {\n var T = aFunction(target);\n var L = anObject(argumentsList);\n return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);\n }\n});\n","// fast apply, http://jsperf.lnkit.com/fast-apply/5\nmodule.exports = function (fn, args, that) {\n var un = that === undefined;\n switch (args.length) {\n case 0: return un ? fn()\n : fn.call(that);\n case 1: return un ? fn(args[0])\n : fn.call(that, args[0]);\n case 2: return un ? fn(args[0], args[1])\n : fn.call(that, args[0], args[1]);\n case 3: return un ? fn(args[0], args[1], args[2])\n : fn.call(that, args[0], args[1], args[2]);\n case 4: return un ? fn(args[0], args[1], args[2], args[3])\n : fn.call(that, args[0], args[1], args[2], args[3]);\n } return fn.apply(that, args);\n};\n","'use strict';\nvar aFunction = require('./_a-function');\nvar isObject = require('./_is-object');\nvar invoke = require('./_invoke');\nvar arraySlice = [].slice;\nvar factories = {};\n\nvar construct = function (F, len, args) {\n if (!(len in factories)) {\n for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']';\n // eslint-disable-next-line no-new-func\n factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');\n } return factories[len](F, args);\n};\n\nmodule.exports = Function.bind || function bind(that /* , ...args */) {\n var fn = aFunction(this);\n var partArgs = arraySlice.call(arguments, 1);\n var bound = function (/* args... */) {\n var args = partArgs.concat(arraySlice.call(arguments));\n return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);\n };\n if (isObject(fn.prototype)) bound.prototype = fn.prototype;\n return bound;\n};\n","// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])\nvar $export = require('./_export');\nvar create = require('./_object-create');\nvar aFunction = require('./_a-function');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar fails = require('./_fails');\nvar bind = require('./_bind');\nvar rConstruct = (require('./_global').Reflect || {}).construct;\n\n// MS Edge supports only 2 arguments and argumentsList argument is optional\n// FF Nightly sets third argument as `new.target`, but does not create `this` from it\nvar NEW_TARGET_BUG = fails(function () {\n function F() { /* empty */ }\n return !(rConstruct(function () { /* empty */ }, [], F) instanceof F);\n});\nvar ARGS_BUG = !fails(function () {\n rConstruct(function () { /* empty */ });\n});\n\n$export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', {\n construct: function construct(Target, args /* , newTarget */) {\n aFunction(Target);\n anObject(args);\n var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);\n if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget);\n if (Target == newTarget) {\n // w/o altered newTarget, optimization for 0-4 arguments\n switch (args.length) {\n case 0: return new Target();\n case 1: return new Target(args[0]);\n case 2: return new Target(args[0], args[1]);\n case 3: return new Target(args[0], args[1], args[2]);\n case 4: return new Target(args[0], args[1], args[2], args[3]);\n }\n // w/o altered newTarget, lot of arguments case\n var $args = [null];\n $args.push.apply($args, args);\n return new (bind.apply(Target, $args))();\n }\n // with altered newTarget, not support built-in constructors\n var proto = newTarget.prototype;\n var instance = create(isObject(proto) ? proto : Object.prototype);\n var result = Function.apply.call(Target, instance, args);\n return isObject(result) ? result : instance;\n }\n});\n","// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)\nvar dP = require('./_object-dp');\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar toPrimitive = require('./_to-primitive');\n\n// MS Edge has broken Reflect.defineProperty - throwing instead of returning false\n$export($export.S + $export.F * require('./_fails')(function () {\n // eslint-disable-next-line no-undef\n Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });\n}), 'Reflect', {\n defineProperty: function defineProperty(target, propertyKey, attributes) {\n anObject(target);\n propertyKey = toPrimitive(propertyKey, true);\n anObject(attributes);\n try {\n dP.f(target, propertyKey, attributes);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","// 26.1.4 Reflect.deleteProperty(target, propertyKey)\nvar $export = require('./_export');\nvar gOPD = require('./_object-gopd').f;\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n deleteProperty: function deleteProperty(target, propertyKey) {\n var desc = gOPD(anObject(target), propertyKey);\n return desc && !desc.configurable ? false : delete target[propertyKey];\n }\n});\n","// 26.1.6 Reflect.get(target, propertyKey [, receiver])\nvar gOPD = require('./_object-gopd');\nvar getPrototypeOf = require('./_object-gpo');\nvar has = require('./_has');\nvar $export = require('./_export');\nvar isObject = require('./_is-object');\nvar anObject = require('./_an-object');\n\nfunction get(target, propertyKey /* , receiver */) {\n var receiver = arguments.length < 3 ? target : arguments[2];\n var desc, proto;\n if (anObject(target) === receiver) return target[propertyKey];\n if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')\n ? desc.value\n : desc.get !== undefined\n ? desc.get.call(receiver)\n : undefined;\n if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);\n}\n\n$export($export.S, 'Reflect', { get: get });\n","// 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)\nvar gOPD = require('./_object-gopd');\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {\n return gOPD.f(anObject(target), propertyKey);\n }\n});\n","// 26.1.8 Reflect.getPrototypeOf(target)\nvar $export = require('./_export');\nvar getProto = require('./_object-gpo');\nvar anObject = require('./_an-object');\n\n$export($export.S, 'Reflect', {\n getPrototypeOf: function getPrototypeOf(target) {\n return getProto(anObject(target));\n }\n});\n","// 26.1.9 Reflect.has(target, propertyKey)\nvar $export = require('./_export');\n\n$export($export.S, 'Reflect', {\n has: function has(target, propertyKey) {\n return propertyKey in target;\n }\n});\n","// 26.1.10 Reflect.isExtensible(target)\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar $isExtensible = Object.isExtensible;\n\n$export($export.S, 'Reflect', {\n isExtensible: function isExtensible(target) {\n anObject(target);\n return $isExtensible ? $isExtensible(target) : true;\n }\n});\n","// all object keys, includes non-enumerable and symbols\nvar gOPN = require('./_object-gopn');\nvar gOPS = require('./_object-gops');\nvar anObject = require('./_an-object');\nvar Reflect = require('./_global').Reflect;\nmodule.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {\n var keys = gOPN.f(anObject(it));\n var getSymbols = gOPS.f;\n return getSymbols ? keys.concat(getSymbols(it)) : keys;\n};\n","// 26.1.11 Reflect.ownKeys(target)\nvar $export = require('./_export');\n\n$export($export.S, 'Reflect', { ownKeys: require('./_own-keys') });\n","// 26.1.12 Reflect.preventExtensions(target)\nvar $export = require('./_export');\nvar anObject = require('./_an-object');\nvar $preventExtensions = Object.preventExtensions;\n\n$export($export.S, 'Reflect', {\n preventExtensions: function preventExtensions(target) {\n anObject(target);\n try {\n if ($preventExtensions) $preventExtensions(target);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])\nvar dP = require('./_object-dp');\nvar gOPD = require('./_object-gopd');\nvar getPrototypeOf = require('./_object-gpo');\nvar has = require('./_has');\nvar $export = require('./_export');\nvar createDesc = require('./_property-desc');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\n\nfunction set(target, propertyKey, V /* , receiver */) {\n var receiver = arguments.length < 4 ? target : arguments[3];\n var ownDesc = gOPD.f(anObject(target), propertyKey);\n var existingDescriptor, proto;\n if (!ownDesc) {\n if (isObject(proto = getPrototypeOf(target))) {\n return set(proto, propertyKey, V, receiver);\n }\n ownDesc = createDesc(0);\n }\n if (has(ownDesc, 'value')) {\n if (ownDesc.writable === false || !isObject(receiver)) return false;\n if (existingDescriptor = gOPD.f(receiver, propertyKey)) {\n if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;\n existingDescriptor.value = V;\n dP.f(receiver, propertyKey, existingDescriptor);\n } else dP.f(receiver, propertyKey, createDesc(0, V));\n return true;\n }\n return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);\n}\n\n$export($export.S, 'Reflect', { set: set });\n","// 26.1.14 Reflect.setPrototypeOf(target, proto)\nvar $export = require('./_export');\nvar setProto = require('./_set-proto');\n\nif (setProto) $export($export.S, 'Reflect', {\n setPrototypeOf: function setPrototypeOf(target, proto) {\n setProto.check(target, proto);\n try {\n setProto.set(target, proto);\n return true;\n } catch (e) {\n return false;\n }\n }\n});\n","var ctx = require('./_ctx');\nvar invoke = require('./_invoke');\nvar html = require('./_html');\nvar cel = require('./_dom-create');\nvar global = require('./_global');\nvar process = global.process;\nvar setTask = global.setImmediate;\nvar clearTask = global.clearImmediate;\nvar MessageChannel = global.MessageChannel;\nvar Dispatch = global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar defer, channel, port;\nvar run = function () {\n var id = +this;\n // eslint-disable-next-line no-prototype-builtins\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\nvar listener = function (event) {\n run.call(event.data);\n};\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!setTask || !clearTask) {\n setTask = function setImmediate(fn) {\n var args = [];\n var i = 1;\n while (arguments.length > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func\n invoke(typeof fn == 'function' ? fn : Function(fn), args);\n };\n defer(counter);\n return counter;\n };\n clearTask = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (require('./_cof')(process) == 'process') {\n defer = function (id) {\n process.nextTick(ctx(run, id, 1));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(ctx(run, id, 1));\n };\n // Browsers with MessageChannel, includes WebWorkers\n } else if (MessageChannel) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = ctx(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {\n defer = function (id) {\n global.postMessage(id + '', '*');\n };\n global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in cel('script')) {\n defer = function (id) {\n html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {\n html.removeChild(this);\n run.call(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(ctx(run, id, 1), 0);\n };\n }\n}\nmodule.exports = {\n set: setTask,\n clear: clearTask\n};\n","var global = require('./_global');\nvar macrotask = require('./_task').set;\nvar Observer = global.MutationObserver || global.WebKitMutationObserver;\nvar process = global.process;\nvar Promise = global.Promise;\nvar isNode = require('./_cof')(process) == 'process';\n\nmodule.exports = function () {\n var head, last, notify;\n\n var flush = function () {\n var parent, fn;\n if (isNode && (parent = process.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (e) {\n if (head) notify();\n else last = undefined;\n throw e;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // Node.js\n if (isNode) {\n notify = function () {\n process.nextTick(flush);\n };\n // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339\n } else if (Observer && !(global.navigator && global.navigator.standalone)) {\n var toggle = true;\n var node = document.createTextNode('');\n new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (Promise && Promise.resolve) {\n var promise = Promise.resolve();\n notify = function () {\n promise.then(flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(global, flush);\n };\n }\n\n return function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n };\n};\n","'use strict';\n// 25.4.1.5 NewPromiseCapability(C)\nvar aFunction = require('./_a-function');\n\nfunction PromiseCapability(C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = aFunction(resolve);\n this.reject = aFunction(reject);\n}\n\nmodule.exports.f = function (C) {\n return new PromiseCapability(C);\n};\n","'use strict';\nvar LIBRARY = require('./_library');\nvar global = require('./_global');\nvar ctx = require('./_ctx');\nvar classof = require('./_classof');\nvar $export = require('./_export');\nvar isObject = require('./_is-object');\nvar aFunction = require('./_a-function');\nvar anInstance = require('./_an-instance');\nvar forOf = require('./_for-of');\nvar speciesConstructor = require('./_species-constructor');\nvar task = require('./_task').set;\nvar microtask = require('./_microtask')();\nvar newPromiseCapabilityModule = require('./_new-promise-capability');\nvar perform = require('./_perform');\nvar promiseResolve = require('./_promise-resolve');\nvar PROMISE = 'Promise';\nvar TypeError = global.TypeError;\nvar process = global.process;\nvar $Promise = global[PROMISE];\nvar isNode = classof(process) == 'process';\nvar empty = function () { /* empty */ };\nvar Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;\nvar newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;\n\nvar USE_NATIVE = !!function () {\n try {\n // correct subclassing with @@species support\n var promise = $Promise.resolve(1);\n var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {\n exec(empty, empty);\n };\n // unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;\n } catch (e) { /* empty */ }\n}();\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\nvar notify = function (promise, isReject) {\n if (promise._n) return;\n promise._n = true;\n var chain = promise._c;\n microtask(function () {\n var value = promise._v;\n var ok = promise._s == 1;\n var i = 0;\n var run = function (reaction) {\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (promise._h == 2) onHandleUnhandled(promise);\n promise._h = 1;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // may throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (e) {\n if (domain && !exited) domain.exit();\n reject(e);\n }\n };\n while (chain.length > i) run(chain[i++]); // variable length - can't use forEach\n promise._c = [];\n promise._n = false;\n if (isReject && !promise._h) onUnhandled(promise);\n });\n};\nvar onUnhandled = function (promise) {\n task.call(global, function () {\n var value = promise._v;\n var unhandled = isUnhandled(promise);\n var result, handler, console;\n if (unhandled) {\n result = perform(function () {\n if (isNode) {\n process.emit('unhandledRejection', value, promise);\n } else if (handler = global.onunhandledrejection) {\n handler({ promise: promise, reason: value });\n } else if ((console = global.console) && console.error) {\n console.error('Unhandled promise rejection', value);\n }\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n promise._h = isNode || isUnhandled(promise) ? 2 : 1;\n } promise._a = undefined;\n if (unhandled && result.e) throw result.v;\n });\n};\nvar isUnhandled = function (promise) {\n return promise._h !== 1 && (promise._a || promise._c).length === 0;\n};\nvar onHandleUnhandled = function (promise) {\n task.call(global, function () {\n var handler;\n if (isNode) {\n process.emit('rejectionHandled', promise);\n } else if (handler = global.onrejectionhandled) {\n handler({ promise: promise, reason: promise._v });\n }\n });\n};\nvar $reject = function (value) {\n var promise = this;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n promise._v = value;\n promise._s = 2;\n if (!promise._a) promise._a = promise._c.slice();\n notify(promise, true);\n};\nvar $resolve = function (value) {\n var promise = this;\n var then;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n try {\n if (promise === value) throw TypeError(\"Promise can't be resolved itself\");\n if (then = isThenable(value)) {\n microtask(function () {\n var wrapper = { _w: promise, _d: false }; // wrap\n try {\n then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));\n } catch (e) {\n $reject.call(wrapper, e);\n }\n });\n } else {\n promise._v = value;\n promise._s = 1;\n notify(promise, false);\n }\n } catch (e) {\n $reject.call({ _w: promise, _d: false }, e); // wrap\n }\n};\n\n// constructor polyfill\nif (!USE_NATIVE) {\n // 25.4.3.1 Promise(executor)\n $Promise = function Promise(executor) {\n anInstance(this, $Promise, PROMISE, '_h');\n aFunction(executor);\n Internal.call(this);\n try {\n executor(ctx($resolve, this, 1), ctx($reject, this, 1));\n } catch (err) {\n $reject.call(this, err);\n }\n };\n // eslint-disable-next-line no-unused-vars\n Internal = function Promise(executor) {\n this._c = []; // <- awaiting reactions\n this._a = undefined; // <- checked in isUnhandled reactions\n this._s = 0; // <- state\n this._d = false; // <- done\n this._v = undefined; // <- value\n this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled\n this._n = false; // <- notify\n };\n Internal.prototype = require('./_redefine-all')($Promise.prototype, {\n // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)\n then: function then(onFulfilled, onRejected) {\n var reaction = newPromiseCapability(speciesConstructor(this, $Promise));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = isNode ? process.domain : undefined;\n this._c.push(reaction);\n if (this._a) this._a.push(reaction);\n if (this._s) notify(this, false);\n return reaction.promise;\n },\n // 25.4.5.1 Promise.prototype.catch(onRejected)\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n this.promise = promise;\n this.resolve = ctx($resolve, promise, 1);\n this.reject = ctx($reject, promise, 1);\n };\n newPromiseCapabilityModule.f = newPromiseCapability = function (C) {\n return C === $Promise || C === Wrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n}\n\n$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });\nrequire('./_set-to-string-tag')($Promise, PROMISE);\nrequire('./_set-species')(PROMISE);\nWrapper = require('./_core')[PROMISE];\n\n// statics\n$export($export.S + $export.F * !USE_NATIVE, PROMISE, {\n // 25.4.4.5 Promise.reject(r)\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n var $$reject = capability.reject;\n $$reject(r);\n return capability.promise;\n }\n});\n$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {\n // 25.4.4.6 Promise.resolve(x)\n resolve: function resolve(x) {\n return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);\n }\n});\n$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {\n $Promise.all(iter)['catch'](empty);\n})), PROMISE, {\n // 25.4.4.1 Promise.all(iterable)\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = perform(function () {\n var values = [];\n var index = 0;\n var remaining = 1;\n forOf(iterable, false, function (promise) {\n var $index = index++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n C.resolve(promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[$index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.e) reject(result.v);\n return capability.promise;\n },\n // 25.4.4.4 Promise.race(iterable)\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = perform(function () {\n forOf(iterable, false, function (promise) {\n C.resolve(promise).then(capability.resolve, reject);\n });\n });\n if (result.e) reject(result.v);\n return capability.promise;\n }\n});\n","module.exports = function (exec) {\n try {\n return { e: false, v: exec() };\n } catch (e) {\n return { e: true, v: e };\n }\n};\n","var anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar newPromiseCapability = require('./_new-promise-capability');\n\nmodule.exports = function (C, x) {\n anObject(C);\n if (isObject(x) && x.constructor === C) return x;\n var promiseCapability = newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n","exports.f = require('./_wks');\n","var global = require('./_global');\nvar core = require('./_core');\nvar LIBRARY = require('./_library');\nvar wksExt = require('./_wks-ext');\nvar defineProperty = require('./_object-dp').f;\nmodule.exports = function (name) {\n var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});\n if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });\n};\n","// all enumerable object keys, includes symbols\nvar getKeys = require('./_object-keys');\nvar gOPS = require('./_object-gops');\nvar pIE = require('./_object-pie');\nmodule.exports = function (it) {\n var result = getKeys(it);\n var getSymbols = gOPS.f;\n if (getSymbols) {\n var symbols = getSymbols(it);\n var isEnum = pIE.f;\n var i = 0;\n var key;\n while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);\n } return result;\n};\n","// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window\nvar toIObject = require('./_to-iobject');\nvar gOPN = require('./_object-gopn').f;\nvar toString = {}.toString;\n\nvar windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames\n ? Object.getOwnPropertyNames(window) : [];\n\nvar getWindowNames = function (it) {\n try {\n return gOPN(it);\n } catch (e) {\n return windowNames.slice();\n }\n};\n\nmodule.exports.f = function getOwnPropertyNames(it) {\n return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));\n};\n","'use strict';\n// ECMAScript 6 symbols shim\nvar global = require('./_global');\nvar has = require('./_has');\nvar DESCRIPTORS = require('./_descriptors');\nvar $export = require('./_export');\nvar redefine = require('./_redefine');\nvar META = require('./_meta').KEY;\nvar $fails = require('./_fails');\nvar shared = require('./_shared');\nvar setToStringTag = require('./_set-to-string-tag');\nvar uid = require('./_uid');\nvar wks = require('./_wks');\nvar wksExt = require('./_wks-ext');\nvar wksDefine = require('./_wks-define');\nvar enumKeys = require('./_enum-keys');\nvar isArray = require('./_is-array');\nvar anObject = require('./_an-object');\nvar isObject = require('./_is-object');\nvar toIObject = require('./_to-iobject');\nvar toPrimitive = require('./_to-primitive');\nvar createDesc = require('./_property-desc');\nvar _create = require('./_object-create');\nvar gOPNExt = require('./_object-gopn-ext');\nvar $GOPD = require('./_object-gopd');\nvar $DP = require('./_object-dp');\nvar $keys = require('./_object-keys');\nvar gOPD = $GOPD.f;\nvar dP = $DP.f;\nvar gOPN = gOPNExt.f;\nvar $Symbol = global.Symbol;\nvar $JSON = global.JSON;\nvar _stringify = $JSON && $JSON.stringify;\nvar PROTOTYPE = 'prototype';\nvar HIDDEN = wks('_hidden');\nvar TO_PRIMITIVE = wks('toPrimitive');\nvar isEnum = {}.propertyIsEnumerable;\nvar SymbolRegistry = shared('symbol-registry');\nvar AllSymbols = shared('symbols');\nvar OPSymbols = shared('op-symbols');\nvar ObjectProto = Object[PROTOTYPE];\nvar USE_NATIVE = typeof $Symbol == 'function';\nvar QObject = global.QObject;\n// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173\nvar setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;\n\n// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687\nvar setSymbolDesc = DESCRIPTORS && $fails(function () {\n return _create(dP({}, 'a', {\n get: function () { return dP(this, 'a', { value: 7 }).a; }\n })).a != 7;\n}) ? function (it, key, D) {\n var protoDesc = gOPD(ObjectProto, key);\n if (protoDesc) delete ObjectProto[key];\n dP(it, key, D);\n if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);\n} : dP;\n\nvar wrap = function (tag) {\n var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);\n sym._k = tag;\n return sym;\n};\n\nvar isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {\n return typeof it == 'symbol';\n} : function (it) {\n return it instanceof $Symbol;\n};\n\nvar $defineProperty = function defineProperty(it, key, D) {\n if (it === ObjectProto) $defineProperty(OPSymbols, key, D);\n anObject(it);\n key = toPrimitive(key, true);\n anObject(D);\n if (has(AllSymbols, key)) {\n if (!D.enumerable) {\n if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));\n it[HIDDEN][key] = true;\n } else {\n if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;\n D = _create(D, { enumerable: createDesc(0, false) });\n } return setSymbolDesc(it, key, D);\n } return dP(it, key, D);\n};\nvar $defineProperties = function defineProperties(it, P) {\n anObject(it);\n var keys = enumKeys(P = toIObject(P));\n var i = 0;\n var l = keys.length;\n var key;\n while (l > i) $defineProperty(it, key = keys[i++], P[key]);\n return it;\n};\nvar $create = function create(it, P) {\n return P === undefined ? _create(it) : $defineProperties(_create(it), P);\n};\nvar $propertyIsEnumerable = function propertyIsEnumerable(key) {\n var E = isEnum.call(this, key = toPrimitive(key, true));\n if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;\n return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;\n};\nvar $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {\n it = toIObject(it);\n key = toPrimitive(key, true);\n if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;\n var D = gOPD(it, key);\n if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;\n return D;\n};\nvar $getOwnPropertyNames = function getOwnPropertyNames(it) {\n var names = gOPN(toIObject(it));\n var result = [];\n var i = 0;\n var key;\n while (names.length > i) {\n if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);\n } return result;\n};\nvar $getOwnPropertySymbols = function getOwnPropertySymbols(it) {\n var IS_OP = it === ObjectProto;\n var names = gOPN(IS_OP ? OPSymbols : toIObject(it));\n var result = [];\n var i = 0;\n var key;\n while (names.length > i) {\n if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);\n } return result;\n};\n\n// 19.4.1.1 Symbol([description])\nif (!USE_NATIVE) {\n $Symbol = function Symbol() {\n if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');\n var tag = uid(arguments.length > 0 ? arguments[0] : undefined);\n var $set = function (value) {\n if (this === ObjectProto) $set.call(OPSymbols, value);\n if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;\n setSymbolDesc(this, tag, createDesc(1, value));\n };\n if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });\n return wrap(tag);\n };\n redefine($Symbol[PROTOTYPE], 'toString', function toString() {\n return this._k;\n });\n\n $GOPD.f = $getOwnPropertyDescriptor;\n $DP.f = $defineProperty;\n require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;\n require('./_object-pie').f = $propertyIsEnumerable;\n require('./_object-gops').f = $getOwnPropertySymbols;\n\n if (DESCRIPTORS && !require('./_library')) {\n redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);\n }\n\n wksExt.f = function (name) {\n return wrap(wks(name));\n };\n}\n\n$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });\n\nfor (var es6Symbols = (\n // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14\n 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'\n).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);\n\nfor (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);\n\n$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {\n // 19.4.2.1 Symbol.for(key)\n 'for': function (key) {\n return has(SymbolRegistry, key += '')\n ? SymbolRegistry[key]\n : SymbolRegistry[key] = $Symbol(key);\n },\n // 19.4.2.5 Symbol.keyFor(sym)\n keyFor: function keyFor(sym) {\n if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');\n for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;\n },\n useSetter: function () { setter = true; },\n useSimple: function () { setter = false; }\n});\n\n$export($export.S + $export.F * !USE_NATIVE, 'Object', {\n // 19.1.2.2 Object.create(O [, Properties])\n create: $create,\n // 19.1.2.4 Object.defineProperty(O, P, Attributes)\n defineProperty: $defineProperty,\n // 19.1.2.3 Object.defineProperties(O, Properties)\n defineProperties: $defineProperties,\n // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)\n getOwnPropertyDescriptor: $getOwnPropertyDescriptor,\n // 19.1.2.7 Object.getOwnPropertyNames(O)\n getOwnPropertyNames: $getOwnPropertyNames,\n // 19.1.2.8 Object.getOwnPropertySymbols(O)\n getOwnPropertySymbols: $getOwnPropertySymbols\n});\n\n// 24.3.2 JSON.stringify(value [, replacer [, space]])\n$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {\n var S = $Symbol();\n // MS Edge converts symbol values to JSON as {}\n // WebKit converts symbol values to JSON as null\n // V8 throws on boxed symbols\n return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';\n})), 'JSON', {\n stringify: function stringify(it) {\n var args = [it];\n var i = 1;\n var replacer, $replacer;\n while (arguments.length > i) args.push(arguments[i++]);\n $replacer = replacer = args[1];\n if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined\n if (!isArray(replacer)) replacer = function (key, value) {\n if (typeof $replacer == 'function') value = $replacer.call(this, key, value);\n if (!isSymbol(value)) return value;\n };\n args[1] = replacer;\n return _stringify.apply($JSON, args);\n }\n});\n\n// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)\n$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);\n// 19.4.3.5 Symbol.prototype[@@toStringTag]\nsetToStringTag($Symbol, 'Symbol');\n// 20.2.1.9 Math[@@toStringTag]\nsetToStringTag(Math, 'Math', true);\n// 24.3.3 JSON[@@toStringTag]\nsetToStringTag(global.JSON, 'JSON', true);\n","// most Object methods by ES6 should accept primitives\nvar $export = require('./_export');\nvar core = require('./_core');\nvar fails = require('./_fails');\nmodule.exports = function (KEY, exec) {\n var fn = (core.Object || {})[KEY] || Object[KEY];\n var exp = {};\n exp[KEY] = exec(fn);\n $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);\n};\n","// 19.1.2.5 Object.freeze(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('freeze', function ($freeze) {\n return function freeze(it) {\n return $freeze && isObject(it) ? $freeze(meta(it)) : it;\n };\n});\n","// 19.1.2.17 Object.seal(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('seal', function ($seal) {\n return function seal(it) {\n return $seal && isObject(it) ? $seal(meta(it)) : it;\n };\n});\n","// 19.1.2.15 Object.preventExtensions(O)\nvar isObject = require('./_is-object');\nvar meta = require('./_meta').onFreeze;\n\nrequire('./_object-sap')('preventExtensions', function ($preventExtensions) {\n return function preventExtensions(it) {\n return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;\n };\n});\n","// 19.1.2.12 Object.isFrozen(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isFrozen', function ($isFrozen) {\n return function isFrozen(it) {\n return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;\n };\n});\n","// 19.1.2.13 Object.isSealed(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isSealed', function ($isSealed) {\n return function isSealed(it) {\n return isObject(it) ? $isSealed ? $isSealed(it) : false : true;\n };\n});\n","// 19.1.2.11 Object.isExtensible(O)\nvar isObject = require('./_is-object');\n\nrequire('./_object-sap')('isExtensible', function ($isExtensible) {\n return function isExtensible(it) {\n return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;\n };\n});\n","// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)\nvar toIObject = require('./_to-iobject');\nvar $getOwnPropertyDescriptor = require('./_object-gopd').f;\n\nrequire('./_object-sap')('getOwnPropertyDescriptor', function () {\n return function getOwnPropertyDescriptor(it, key) {\n return $getOwnPropertyDescriptor(toIObject(it), key);\n };\n});\n","// 19.1.2.9 Object.getPrototypeOf(O)\nvar toObject = require('./_to-object');\nvar $getPrototypeOf = require('./_object-gpo');\n\nrequire('./_object-sap')('getPrototypeOf', function () {\n return function getPrototypeOf(it) {\n return $getPrototypeOf(toObject(it));\n };\n});\n","// 19.1.2.14 Object.keys(O)\nvar toObject = require('./_to-object');\nvar $keys = require('./_object-keys');\n\nrequire('./_object-sap')('keys', function () {\n return function keys(it) {\n return $keys(toObject(it));\n };\n});\n","// 19.1.2.7 Object.getOwnPropertyNames(O)\nrequire('./_object-sap')('getOwnPropertyNames', function () {\n return require('./_object-gopn-ext').f;\n});\n","// 19.1.3.1 Object.assign(target, source)\nvar $export = require('./_export');\n\n$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });\n","// 7.2.9 SameValue(x, y)\nmodule.exports = Object.is || function is(x, y) {\n // eslint-disable-next-line no-self-compare\n return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;\n};\n","// 19.1.3.10 Object.is(value1, value2)\nvar $export = require('./_export');\n$export($export.S, 'Object', { is: require('./_same-value') });\n","// 19.1.3.19 Object.setPrototypeOf(O, proto)\nvar $export = require('./_export');\n$export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set });\n","var dP = require('./_object-dp').f;\nvar FProto = Function.prototype;\nvar nameRE = /^\\s*function ([^ (]*)/;\nvar NAME = 'name';\n\n// 19.2.4.2 name\nNAME in FProto || require('./_descriptors') && dP(FProto, NAME, {\n configurable: true,\n get: function () {\n try {\n return ('' + this).match(nameRE)[1];\n } catch (e) {\n return '';\n }\n }\n});\n","var $export = require('./_export');\nvar toIObject = require('./_to-iobject');\nvar toLength = require('./_to-length');\n\n$export($export.S, 'String', {\n // 21.1.2.4 String.raw(callSite, ...substitutions)\n raw: function raw(callSite) {\n var tpl = toIObject(callSite.raw);\n var len = toLength(tpl.length);\n var aLen = arguments.length;\n var res = [];\n var i = 0;\n while (len > i) {\n res.push(String(tpl[i++]));\n if (i < aLen) res.push(String(arguments[i]));\n } return res.join('');\n }\n});\n","var $export = require('./_export');\nvar toAbsoluteIndex = require('./_to-absolute-index');\nvar fromCharCode = String.fromCharCode;\nvar $fromCodePoint = String.fromCodePoint;\n\n// length should be 1, old FF problem\n$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {\n // 21.1.2.2 String.fromCodePoint(...codePoints)\n fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars\n var res = [];\n var aLen = arguments.length;\n var i = 0;\n var code;\n while (aLen > i) {\n code = +arguments[i++];\n if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');\n res.push(code < 0x10000\n ? fromCharCode(code)\n : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)\n );\n } return res.join('');\n }\n});\n","var toInteger = require('./_to-integer');\nvar defined = require('./_defined');\n// true -> String#at\n// false -> String#codePointAt\nmodule.exports = function (TO_STRING) {\n return function (that, pos) {\n var s = String(defined(that));\n var i = toInteger(pos);\n var l = s.length;\n var a, b;\n if (i < 0 || i >= l) return TO_STRING ? '' : undefined;\n a = s.charCodeAt(i);\n return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff\n ? TO_STRING ? s.charAt(i) : a\n : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;\n };\n};\n","'use strict';\nvar $export = require('./_export');\nvar $at = require('./_string-at')(false);\n$export($export.P, 'String', {\n // 21.1.3.3 String.prototype.codePointAt(pos)\n codePointAt: function codePointAt(pos) {\n return $at(this, pos);\n }\n});\n","'use strict';\nvar toInteger = require('./_to-integer');\nvar defined = require('./_defined');\n\nmodule.exports = function repeat(count) {\n var str = String(defined(this));\n var res = '';\n var n = toInteger(count);\n if (n < 0 || n == Infinity) throw RangeError(\"Count can't be negative\");\n for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;\n return res;\n};\n","var $export = require('./_export');\n\n$export($export.P, 'String', {\n // 21.1.3.13 String.prototype.repeat(count)\n repeat: require('./_string-repeat')\n});\n","// 7.2.8 IsRegExp(argument)\nvar isObject = require('./_is-object');\nvar cof = require('./_cof');\nvar MATCH = require('./_wks')('match');\nmodule.exports = function (it) {\n var isRegExp;\n return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');\n};\n","// helper for String#{startsWith, endsWith, includes}\nvar isRegExp = require('./_is-regexp');\nvar defined = require('./_defined');\n\nmodule.exports = function (that, searchString, NAME) {\n if (isRegExp(searchString)) throw TypeError('String#' + NAME + \" doesn't accept regex!\");\n return String(defined(that));\n};\n","var MATCH = require('./_wks')('match');\nmodule.exports = function (KEY) {\n var re = /./;\n try {\n '/./'[KEY](re);\n } catch (e) {\n try {\n re[MATCH] = false;\n return !'/./'[KEY](re);\n } catch (f) { /* empty */ }\n } return true;\n};\n","// 21.1.3.18 String.prototype.startsWith(searchString [, position ])\n'use strict';\nvar $export = require('./_export');\nvar toLength = require('./_to-length');\nvar context = require('./_string-context');\nvar STARTS_WITH = 'startsWith';\nvar $startsWith = ''[STARTS_WITH];\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', {\n startsWith: function startsWith(searchString /* , position = 0 */) {\n var that = context(this, searchString, STARTS_WITH);\n var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));\n var search = String(searchString);\n return $startsWith\n ? $startsWith.call(that, search, index)\n : that.slice(index, index + search.length) === search;\n }\n});\n","// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])\n'use strict';\nvar $export = require('./_export');\nvar toLength = require('./_to-length');\nvar context = require('./_string-context');\nvar ENDS_WITH = 'endsWith';\nvar $endsWith = ''[ENDS_WITH];\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', {\n endsWith: function endsWith(searchString /* , endPosition = @length */) {\n var that = context(this, searchString, ENDS_WITH);\n var endPosition = arguments.length > 1 ? arguments[1] : undefined;\n var len = toLength(that.length);\n var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);\n var search = String(searchString);\n return $endsWith\n ? $endsWith.call(that, search, end)\n : that.slice(end - search.length, end) === search;\n }\n});\n","// 21.1.3.7 String.prototype.includes(searchString, position = 0)\n'use strict';\nvar $export = require('./_export');\nvar context = require('./_string-context');\nvar INCLUDES = 'includes';\n\n$export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String', {\n includes: function includes(searchString /* , position = 0 */) {\n return !!~context(this, searchString, INCLUDES)\n .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n","'use strict';\n// 21.2.5.3 get RegExp.prototype.flags\nvar anObject = require('./_an-object');\nmodule.exports = function () {\n var that = anObject(this);\n var result = '';\n if (that.global) result += 'g';\n if (that.ignoreCase) result += 'i';\n if (that.multiline) result += 'm';\n if (that.unicode) result += 'u';\n if (that.sticky) result += 'y';\n return result;\n};\n","// 21.2.5.3 get RegExp.prototype.flags()\nif (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', {\n configurable: true,\n get: require('./_flags')\n});\n","'use strict';\nvar hide = require('./_hide');\nvar redefine = require('./_redefine');\nvar fails = require('./_fails');\nvar defined = require('./_defined');\nvar wks = require('./_wks');\n\nmodule.exports = function (KEY, length, exec) {\n var SYMBOL = wks(KEY);\n var fns = exec(defined, SYMBOL, ''[KEY]);\n var strfn = fns[0];\n var rxfn = fns[1];\n if (fails(function () {\n var O = {};\n O[SYMBOL] = function () { return 7; };\n return ''[KEY](O) != 7;\n })) {\n redefine(String.prototype, KEY, strfn);\n hide(RegExp.prototype, SYMBOL, length == 2\n // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)\n // 21.2.5.11 RegExp.prototype[@@split](string, limit)\n ? function (string, arg) { return rxfn.call(string, this, arg); }\n // 21.2.5.6 RegExp.prototype[@@match](string)\n // 21.2.5.9 RegExp.prototype[@@search](string)\n : function (string) { return rxfn.call(string, this); }\n );\n }\n};\n","// @@match logic\nrequire('./_fix-re-wks')('match', 1, function (defined, MATCH, $match) {\n // 21.1.3.11 String.prototype.match(regexp)\n return [function match(regexp) {\n 'use strict';\n var O = defined(this);\n var fn = regexp == undefined ? undefined : regexp[MATCH];\n return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));\n }, $match];\n});\n","// @@replace logic\nrequire('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace) {\n // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)\n return [function replace(searchValue, replaceValue) {\n 'use strict';\n var O = defined(this);\n var fn = searchValue == undefined ? undefined : searchValue[REPLACE];\n return fn !== undefined\n ? fn.call(searchValue, O, replaceValue)\n : $replace.call(String(O), searchValue, replaceValue);\n }, $replace];\n});\n","// @@split logic\nrequire('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split) {\n 'use strict';\n var isRegExp = require('./_is-regexp');\n var _split = $split;\n var $push = [].push;\n var $SPLIT = 'split';\n var LENGTH = 'length';\n var LAST_INDEX = 'lastIndex';\n if (\n 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||\n 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||\n 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||\n '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||\n '.'[$SPLIT](/()()/)[LENGTH] > 1 ||\n ''[$SPLIT](/.?/)[LENGTH]\n ) {\n var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group\n // based on es5-shim implementation, need to rework it\n $split = function (separator, limit) {\n var string = String(this);\n if (separator === undefined && limit === 0) return [];\n // If `separator` is not a regex, use native split\n if (!isRegExp(separator)) return _split.call(string, separator, limit);\n var output = [];\n var flags = (separator.ignoreCase ? 'i' : '') +\n (separator.multiline ? 'm' : '') +\n (separator.unicode ? 'u' : '') +\n (separator.sticky ? 'y' : '');\n var lastLastIndex = 0;\n var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;\n // Make `global` and avoid `lastIndex` issues by working with a copy\n var separatorCopy = new RegExp(separator.source, flags + 'g');\n var separator2, match, lastIndex, lastLength, i;\n // Doesn't need flags gy, but they don't hurt\n if (!NPCG) separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\\\s)', flags);\n while (match = separatorCopy.exec(string)) {\n // `separatorCopy.lastIndex` is not reliable cross-browser\n lastIndex = match.index + match[0][LENGTH];\n if (lastIndex > lastLastIndex) {\n output.push(string.slice(lastLastIndex, match.index));\n // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG\n // eslint-disable-next-line no-loop-func\n if (!NPCG && match[LENGTH] > 1) match[0].replace(separator2, function () {\n for (i = 1; i < arguments[LENGTH] - 2; i++) if (arguments[i] === undefined) match[i] = undefined;\n });\n if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));\n lastLength = match[0][LENGTH];\n lastLastIndex = lastIndex;\n if (output[LENGTH] >= splitLimit) break;\n }\n if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop\n }\n if (lastLastIndex === string[LENGTH]) {\n if (lastLength || !separatorCopy.test('')) output.push('');\n } else output.push(string.slice(lastLastIndex));\n return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;\n };\n // Chakra, V8\n } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {\n $split = function (separator, limit) {\n return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);\n };\n }\n // 21.1.3.17 String.prototype.split(separator, limit)\n return [function split(separator, limit) {\n var O = defined(this);\n var fn = separator == undefined ? undefined : separator[SPLIT];\n return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);\n }, $split];\n});\n","// @@search logic\nrequire('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search) {\n // 21.1.3.15 String.prototype.search(regexp)\n return [function search(regexp) {\n 'use strict';\n var O = defined(this);\n var fn = regexp == undefined ? undefined : regexp[SEARCH];\n return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));\n }, $search];\n});\n","'use strict';\nvar $defineProperty = require('./_object-dp');\nvar createDesc = require('./_property-desc');\n\nmodule.exports = function (object, index, value) {\n if (index in object) $defineProperty.f(object, index, createDesc(0, value));\n else object[index] = value;\n};\n","'use strict';\nvar ctx = require('./_ctx');\nvar $export = require('./_export');\nvar toObject = require('./_to-object');\nvar call = require('./_iter-call');\nvar isArrayIter = require('./_is-array-iter');\nvar toLength = require('./_to-length');\nvar createProperty = require('./_create-property');\nvar getIterFn = require('./core.get-iterator-method');\n\n$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {\n // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)\n from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {\n var O = toObject(arrayLike);\n var C = typeof this == 'function' ? this : Array;\n var aLen = arguments.length;\n var mapfn = aLen > 1 ? arguments[1] : undefined;\n var mapping = mapfn !== undefined;\n var index = 0;\n var iterFn = getIterFn(O);\n var length, result, step, iterator;\n if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);\n // if object isn't iterable or it's array with default iterator - use simple case\n if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {\n for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {\n createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);\n }\n } else {\n length = toLength(O.length);\n for (result = new C(length); length > index; index++) {\n createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);\n }\n }\n result.length = index;\n return result;\n }\n});\n","'use strict';\nvar $export = require('./_export');\nvar createProperty = require('./_create-property');\n\n// WebKit Array.of isn't generic\n$export($export.S + $export.F * require('./_fails')(function () {\n function F() { /* empty */ }\n return !(Array.of.call(F) instanceof F);\n}), 'Array', {\n // 22.1.2.3 Array.of( ...items)\n of: function of(/* ...args */) {\n var index = 0;\n var aLen = arguments.length;\n var result = new (typeof this == 'function' ? this : Array)(aLen);\n while (aLen > index) createProperty(result, index, arguments[index++]);\n result.length = aLen;\n return result;\n }\n});\n","// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)\nvar $export = require('./_export');\n\n$export($export.P, 'Array', { copyWithin: require('./_array-copy-within') });\n\nrequire('./_add-to-unscopables')('copyWithin');\n","'use strict';\n// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)\nvar $export = require('./_export');\nvar $find = require('./_array-methods')(5);\nvar KEY = 'find';\nvar forced = true;\n// Shouldn't skip holes\nif (KEY in []) Array(1)[KEY](function () { forced = false; });\n$export($export.P + $export.F * forced, 'Array', {\n find: function find(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\nrequire('./_add-to-unscopables')(KEY);\n","'use strict';\n// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)\nvar $export = require('./_export');\nvar $find = require('./_array-methods')(6);\nvar KEY = 'findIndex';\nvar forced = true;\n// Shouldn't skip holes\nif (KEY in []) Array(1)[KEY](function () { forced = false; });\n$export($export.P + $export.F * forced, 'Array', {\n findIndex: function findIndex(callbackfn /* , that = undefined */) {\n return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\nrequire('./_add-to-unscopables')(KEY);\n","// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)\nvar $export = require('./_export');\n\n$export($export.P, 'Array', { fill: require('./_array-fill') });\n\nrequire('./_add-to-unscopables')('fill');\n","// 20.1.2.2 Number.isFinite(number)\nvar $export = require('./_export');\nvar _isFinite = require('./_global').isFinite;\n\n$export($export.S, 'Number', {\n isFinite: function isFinite(it) {\n return typeof it == 'number' && _isFinite(it);\n }\n});\n","// 20.1.2.3 Number.isInteger(number)\nvar isObject = require('./_is-object');\nvar floor = Math.floor;\nmodule.exports = function isInteger(it) {\n return !isObject(it) && isFinite(it) && floor(it) === it;\n};\n","// 20.1.2.3 Number.isInteger(number)\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { isInteger: require('./_is-integer') });\n","// 20.1.2.5 Number.isSafeInteger(number)\nvar $export = require('./_export');\nvar isInteger = require('./_is-integer');\nvar abs = Math.abs;\n\n$export($export.S, 'Number', {\n isSafeInteger: function isSafeInteger(number) {\n return isInteger(number) && abs(number) <= 0x1fffffffffffff;\n }\n});\n","// 20.1.2.4 Number.isNaN(number)\nvar $export = require('./_export');\n\n$export($export.S, 'Number', {\n isNaN: function isNaN(number) {\n // eslint-disable-next-line no-self-compare\n return number != number;\n }\n});\n","// 20.1.2.1 Number.EPSILON\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });\n","// 20.1.2.10 Number.MIN_SAFE_INTEGER\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });\n","// 20.1.2.6 Number.MAX_SAFE_INTEGER\nvar $export = require('./_export');\n\n$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });\n","// 20.2.2.20 Math.log1p(x)\nmodule.exports = Math.log1p || function log1p(x) {\n return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);\n};\n","// 20.2.2.3 Math.acosh(x)\nvar $export = require('./_export');\nvar log1p = require('./_math-log1p');\nvar sqrt = Math.sqrt;\nvar $acosh = Math.acosh;\n\n$export($export.S + $export.F * !($acosh\n // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509\n && Math.floor($acosh(Number.MAX_VALUE)) == 710\n // Tor Browser bug: Math.acosh(Infinity) -> NaN\n && $acosh(Infinity) == Infinity\n), 'Math', {\n acosh: function acosh(x) {\n return (x = +x) < 1 ? NaN : x > 94906265.62425156\n ? Math.log(x) + Math.LN2\n : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));\n }\n});\n","// 20.2.2.5 Math.asinh(x)\nvar $export = require('./_export');\nvar $asinh = Math.asinh;\n\nfunction asinh(x) {\n return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));\n}\n\n// Tor Browser bug: Math.asinh(0) -> -0\n$export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh });\n","// 20.2.2.7 Math.atanh(x)\nvar $export = require('./_export');\nvar $atanh = Math.atanh;\n\n// Tor Browser bug: Math.atanh(-0) -> 0\n$export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {\n atanh: function atanh(x) {\n return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;\n }\n});\n","// 20.2.2.28 Math.sign(x)\nmodule.exports = Math.sign || function sign(x) {\n // eslint-disable-next-line no-self-compare\n return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;\n};\n","// 20.2.2.9 Math.cbrt(x)\nvar $export = require('./_export');\nvar sign = require('./_math-sign');\n\n$export($export.S, 'Math', {\n cbrt: function cbrt(x) {\n return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);\n }\n});\n","// 20.2.2.11 Math.clz32(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n clz32: function clz32(x) {\n return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;\n }\n});\n","// 20.2.2.12 Math.cosh(x)\nvar $export = require('./_export');\nvar exp = Math.exp;\n\n$export($export.S, 'Math', {\n cosh: function cosh(x) {\n return (exp(x = +x) + exp(-x)) / 2;\n }\n});\n","// 20.2.2.14 Math.expm1(x)\nvar $expm1 = Math.expm1;\nmodule.exports = (!$expm1\n // Old FF bug\n || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168\n // Tor Browser bug\n || $expm1(-2e-17) != -2e-17\n) ? function expm1(x) {\n return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;\n} : $expm1;\n","// 20.2.2.14 Math.expm1(x)\nvar $export = require('./_export');\nvar $expm1 = require('./_math-expm1');\n\n$export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 });\n","// 20.2.2.16 Math.fround(x)\nvar sign = require('./_math-sign');\nvar pow = Math.pow;\nvar EPSILON = pow(2, -52);\nvar EPSILON32 = pow(2, -23);\nvar MAX32 = pow(2, 127) * (2 - EPSILON32);\nvar MIN32 = pow(2, -126);\n\nvar roundTiesToEven = function (n) {\n return n + 1 / EPSILON - 1 / EPSILON;\n};\n\nmodule.exports = Math.fround || function fround(x) {\n var $abs = Math.abs(x);\n var $sign = sign(x);\n var a, result;\n if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;\n a = (1 + EPSILON32 / EPSILON) * $abs;\n result = a - (a - $abs);\n // eslint-disable-next-line no-self-compare\n if (result > MAX32 || result != result) return $sign * Infinity;\n return $sign * result;\n};\n","// 20.2.2.16 Math.fround(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { fround: require('./_math-fround') });\n","// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])\nvar $export = require('./_export');\nvar abs = Math.abs;\n\n$export($export.S, 'Math', {\n hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars\n var sum = 0;\n var i = 0;\n var aLen = arguments.length;\n var larg = 0;\n var arg, div;\n while (i < aLen) {\n arg = abs(arguments[i++]);\n if (larg < arg) {\n div = larg / arg;\n sum = sum * div * div + 1;\n larg = arg;\n } else if (arg > 0) {\n div = arg / larg;\n sum += div * div;\n } else sum += arg;\n }\n return larg === Infinity ? Infinity : larg * Math.sqrt(sum);\n }\n});\n","// 20.2.2.18 Math.imul(x, y)\nvar $export = require('./_export');\nvar $imul = Math.imul;\n\n// some WebKit versions fails with big numbers, some has wrong arity\n$export($export.S + $export.F * require('./_fails')(function () {\n return $imul(0xffffffff, 5) != -5 || $imul.length != 2;\n}), 'Math', {\n imul: function imul(x, y) {\n var UINT16 = 0xffff;\n var xn = +x;\n var yn = +y;\n var xl = UINT16 & xn;\n var yl = UINT16 & yn;\n return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);\n }\n});\n","// 20.2.2.20 Math.log1p(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { log1p: require('./_math-log1p') });\n","// 20.2.2.21 Math.log10(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n log10: function log10(x) {\n return Math.log(x) * Math.LOG10E;\n }\n});\n","// 20.2.2.22 Math.log2(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n log2: function log2(x) {\n return Math.log(x) / Math.LN2;\n }\n});\n","// 20.2.2.28 Math.sign(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', { sign: require('./_math-sign') });\n","// 20.2.2.30 Math.sinh(x)\nvar $export = require('./_export');\nvar expm1 = require('./_math-expm1');\nvar exp = Math.exp;\n\n// V8 near Chromium 38 has a problem with very small numbers\n$export($export.S + $export.F * require('./_fails')(function () {\n return !Math.sinh(-2e-17) != -2e-17;\n}), 'Math', {\n sinh: function sinh(x) {\n return Math.abs(x = +x) < 1\n ? (expm1(x) - expm1(-x)) / 2\n : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);\n }\n});\n","// 20.2.2.33 Math.tanh(x)\nvar $export = require('./_export');\nvar expm1 = require('./_math-expm1');\nvar exp = Math.exp;\n\n$export($export.S, 'Math', {\n tanh: function tanh(x) {\n var a = expm1(x = +x);\n var b = expm1(-x);\n return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));\n }\n});\n","// 20.2.2.34 Math.trunc(x)\nvar $export = require('./_export');\n\n$export($export.S, 'Math', {\n trunc: function trunc(it) {\n return (it > 0 ? Math.floor : Math.ceil)(it);\n }\n});\n","'use strict';\n// https://github.com/tc39/Array.prototype.includes\nvar $export = require('./_export');\nvar $includes = require('./_array-includes')(true);\n\n$export($export.P, 'Array', {\n includes: function includes(el /* , fromIndex = 0 */) {\n return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);\n }\n});\n\nrequire('./_add-to-unscopables')('includes');\n","var getKeys = require('./_object-keys');\nvar toIObject = require('./_to-iobject');\nvar isEnum = require('./_object-pie').f;\nmodule.exports = function (isEntries) {\n return function (it) {\n var O = toIObject(it);\n var keys = getKeys(O);\n var length = keys.length;\n var i = 0;\n var result = [];\n var key;\n while (length > i) if (isEnum.call(O, key = keys[i++])) {\n result.push(isEntries ? [key, O[key]] : O[key]);\n } return result;\n };\n};\n","// https://github.com/tc39/proposal-object-values-entries\nvar $export = require('./_export');\nvar $values = require('./_object-to-array')(false);\n\n$export($export.S, 'Object', {\n values: function values(it) {\n return $values(it);\n }\n});\n","// https://github.com/tc39/proposal-object-values-entries\nvar $export = require('./_export');\nvar $entries = require('./_object-to-array')(true);\n\n$export($export.S, 'Object', {\n entries: function entries(it) {\n return $entries(it);\n }\n});\n","// https://github.com/tc39/proposal-object-getownpropertydescriptors\nvar $export = require('./_export');\nvar ownKeys = require('./_own-keys');\nvar toIObject = require('./_to-iobject');\nvar gOPD = require('./_object-gopd');\nvar createProperty = require('./_create-property');\n\n$export($export.S, 'Object', {\n getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {\n var O = toIObject(object);\n var getDesc = gOPD.f;\n var keys = ownKeys(O);\n var result = {};\n var i = 0;\n var key, desc;\n while (keys.length > i) {\n desc = getDesc(O, key = keys[i++]);\n if (desc !== undefined) createProperty(result, key, desc);\n }\n return result;\n }\n});\n","// https://github.com/tc39/proposal-string-pad-start-end\nvar toLength = require('./_to-length');\nvar repeat = require('./_string-repeat');\nvar defined = require('./_defined');\n\nmodule.exports = function (that, maxLength, fillString, left) {\n var S = String(defined(that));\n var stringLength = S.length;\n var fillStr = fillString === undefined ? ' ' : String(fillString);\n var intMaxLength = toLength(maxLength);\n if (intMaxLength <= stringLength || fillStr == '') return S;\n var fillLen = intMaxLength - stringLength;\n var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));\n if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);\n return left ? stringFiller + S : S + stringFiller;\n};\n","var global = require('./_global');\nvar navigator = global.navigator;\n\nmodule.exports = navigator && navigator.userAgent || '';\n","'use strict';\n// https://github.com/tc39/proposal-string-pad-start-end\nvar $export = require('./_export');\nvar $pad = require('./_string-pad');\nvar userAgent = require('./_user-agent');\n\n// https://github.com/zloirock/core-js/issues/280\n$export($export.P + $export.F * /Version\\/10\\.\\d+(\\.\\d+)? Safari\\//.test(userAgent), 'String', {\n padStart: function padStart(maxLength /* , fillString = ' ' */) {\n return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);\n }\n});\n","'use strict';\n// https://github.com/tc39/proposal-string-pad-start-end\nvar $export = require('./_export');\nvar $pad = require('./_string-pad');\nvar userAgent = require('./_user-agent');\n\n// https://github.com/zloirock/core-js/issues/280\n$export($export.P + $export.F * /Version\\/10\\.\\d+(\\.\\d+)? Safari\\//.test(userAgent), 'String', {\n padEnd: function padEnd(maxLength /* , fillString = ' ' */) {\n return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);\n }\n});\n","// ie9- setTimeout & setInterval additional parameters fix\nvar global = require('./_global');\nvar $export = require('./_export');\nvar userAgent = require('./_user-agent');\nvar slice = [].slice;\nvar MSIE = /MSIE .\\./.test(userAgent); // <- dirty ie9- check\nvar wrap = function (set) {\n return function (fn, time /* , ...args */) {\n var boundArgs = arguments.length > 2;\n var args = boundArgs ? slice.call(arguments, 2) : false;\n return set(boundArgs ? function () {\n // eslint-disable-next-line no-new-func\n (typeof fn == 'function' ? fn : Function(fn)).apply(this, args);\n } : fn, time);\n };\n};\n$export($export.G + $export.B + $export.F * MSIE, {\n setTimeout: wrap(global.setTimeout),\n setInterval: wrap(global.setInterval)\n});\n","var $export = require('./_export');\nvar $task = require('./_task');\n$export($export.G + $export.B, {\n setImmediate: $task.set,\n clearImmediate: $task.clear\n});\n","var $iterators = require('./es6.array.iterator');\nvar getKeys = require('./_object-keys');\nvar redefine = require('./_redefine');\nvar global = require('./_global');\nvar hide = require('./_hide');\nvar Iterators = require('./_iterators');\nvar wks = require('./_wks');\nvar ITERATOR = wks('iterator');\nvar TO_STRING_TAG = wks('toStringTag');\nvar ArrayValues = Iterators.Array;\n\nvar DOMIterables = {\n CSSRuleList: true, // TODO: Not spec compliant, should be false.\n CSSStyleDeclaration: false,\n CSSValueList: false,\n ClientRectList: false,\n DOMRectList: false,\n DOMStringList: false,\n DOMTokenList: true,\n DataTransferItemList: false,\n FileList: false,\n HTMLAllCollection: false,\n HTMLCollection: false,\n HTMLFormElement: false,\n HTMLSelectElement: false,\n MediaList: true, // TODO: Not spec compliant, should be false.\n MimeTypeArray: false,\n NamedNodeMap: false,\n NodeList: true,\n PaintRequestList: false,\n Plugin: false,\n PluginArray: false,\n SVGLengthList: false,\n SVGNumberList: false,\n SVGPathSegList: false,\n SVGPointList: false,\n SVGStringList: false,\n SVGTransformList: false,\n SourceBufferList: false,\n StyleSheetList: true, // TODO: Not spec compliant, should be false.\n TextTrackCueList: false,\n TextTrackList: false,\n TouchList: false\n};\n\nfor (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {\n var NAME = collections[i];\n var explicit = DOMIterables[NAME];\n var Collection = global[NAME];\n var proto = Collection && Collection.prototype;\n var key;\n if (proto) {\n if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);\n if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);\n Iterators[NAME] = ArrayValues;\n if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);\n }\n}\n","/**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * https://raw.github.com/facebook/regenerator/master/LICENSE file. An\n * additional grant of patent rights can be found in the PATENTS file in\n * the same directory.\n */\n\n!(function(global) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n runtime.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n if (typeof global.process === \"object\" && global.process.domain) {\n invoke = global.process.domain.bind(invoke);\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n runtime.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n if (delegate.iterator.return) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n})(\n // Among the various tricks for obtaining a reference to the global\n // object, this seems to be the most reliable technique that does not\n // use indirect eval (which violates Content Security Policy).\n typeof global === \"object\" ? global :\n typeof window === \"object\" ? window :\n typeof self === \"object\" ? self : this\n);\n","/**\n * Returns detailed type as string (instead of just 'object' for arrays etc)\n * @private\n * @param {any} value js value\n * @returns {String} type of value\n * @example\n * typeOf({}); // 'object'\n * typeOf([]); // 'array'\n * typeOf(function() {}); // 'function'\n * typeOf(/a/); // 'regexp'\n * typeOf(new Date()); // 'date'\n * typeOf(null); // 'null'\n * typeOf(undefined); // 'undefined'\n * typeOf('a'); // 'string'\n * typeOf(1); // 'number'\n * typeOf(true); // 'boolean'\n * typeOf(new Map()); // 'map'\n * typeOf(new Set()); // 'map'\n */\nfunction typeOf(value) {\n if (value === null) {\n return 'null';\n }\n if (value !== Object(value)) {\n return typeof value;\n }\n return {}.toString\n .call(value)\n .slice(8, -1)\n .toLowerCase();\n}\n\nexport default typeOf;\n","import typeOf from './typeOf';\n/**\n * Checks if input string is empty\n * @param {String} input text input\n * @return {Boolean} true if no input\n */\nfunction isEmpty(input) {\n if (typeOf(input) !== 'string') {\n return true;\n }\n return !input.length;\n}\n\nexport default isEmpty;\n","import isEmpty from './isEmpty';\n\n/**\n * Takes a character and a unicode range. Returns true if the char is in the range.\n * @param {String} char unicode character\n * @param {Number} start unicode start range\n * @param {Number} end unicode end range\n * @return {Boolean}\n */\nfunction isCharInRange(char = '', start, end) {\n if (isEmpty(char)) return false;\n const code = char.charCodeAt(0);\n return start <= code && code <= end;\n}\n\nexport default isCharInRange;\n","export const VERSION = '4.0.2';\n\nexport const TO_KANA_METHODS = {\n HIRAGANA: 'toHiragana',\n KATAKANA: 'toKatakana',\n};\n\nexport const ROMANIZATIONS = {\n HEPBURN: 'hepburn',\n};\n\n/**\n * Default config for WanaKana, user passed options will be merged with these\n * @type {DefaultOptions}\n * @name defaultOptions\n * @property {Boolean} [useObsoleteKana=false] - Set to true to use obsolete characters, such as ゐ and ゑ.\n * @example\n * toHiragana('we', { useObsoleteKana: true })\n * // => 'ゑ'\n * @property {Boolean} [passRomaji=false] - Set to true to pass romaji when using mixed syllabaries with toKatakana() or toHiragana()\n * @example\n * toHiragana('only convert the katakana: ヒラガナ', { passRomaji: true })\n * // => \"only convert the katakana: ひらがな\"\n * @property {Boolean} [upcaseKatakana=false] - Set to true to convert katakana to uppercase using toRomaji()\n * @example\n * toRomaji('ひらがな カタカナ', { upcaseKatakana: true })\n * // => \"hiragana KATAKANA\"\n * @property {Boolean|String} [IMEMode=false] - Set to true, 'toHiragana', or 'toKatakana' to handle conversion while it is being typed.\n * @property {String} [romanization='hepburn'] - choose toRomaji() romanization map (currently only 'hepburn')\n * @property {Object} [customKanaMapping] - custom map will be merged with default conversion\n * @example\n * toKana('wanakana', { customKanaMapping: { na: 'に', ka: 'Bana' }) };\n * // => 'わにBanaに'\n * @property {Object} [customRomajiMapping] - custom map will be merged with default conversion\n * @example\n * toRomaji('つじぎり', { customRomajiMapping: { じ: 'zi', つ: 'tu', り: 'li' }) };\n * // => 'tuzigili'\n */\nexport const DEFAULT_OPTIONS = {\n useObsoleteKana: false,\n passRomaji: false,\n upcaseKatakana: false,\n ignoreCase: false,\n IMEMode: false,\n romanization: ROMANIZATIONS.HEPBURN,\n};\n\n// CharCode References\n// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml\n// http://unicode-table.com\n\nexport const LATIN_LOWERCASE_START = 0x61;\nexport const LATIN_LOWERCASE_END = 0x7a;\nexport const LATIN_UPPERCASE_START = 0x41;\nexport const LATIN_UPPERCASE_END = 0x5a;\nexport const LOWERCASE_ZENKAKU_START = 0xff41;\nexport const LOWERCASE_ZENKAKU_END = 0xff5a;\nexport const UPPERCASE_ZENKAKU_START = 0xff21;\nexport const UPPERCASE_ZENKAKU_END = 0xff3a;\nexport const HIRAGANA_START = 0x3041;\nexport const HIRAGANA_END = 0x3096;\nexport const KATAKANA_START = 0x30a1;\nexport const KATAKANA_END = 0x30fc;\nexport const KANJI_START = 0x4e00;\nexport const KANJI_END = 0x9faf;\nexport const PROLONGED_SOUND_MARK = 0x30fc;\nexport const KANA_SLASH_DOT = 0x30fb;\n\nconst ZENKAKU_NUMBERS = [0xff10, 0xff19];\nconst ZENKAKU_UPPERCASE = [UPPERCASE_ZENKAKU_START, UPPERCASE_ZENKAKU_END];\nconst ZENKAKU_LOWERCASE = [LOWERCASE_ZENKAKU_START, LOWERCASE_ZENKAKU_END];\nconst ZENKAKU_PUNCTUATION_1 = [0xff01, 0xff0f];\nconst ZENKAKU_PUNCTUATION_2 = [0xff1a, 0xff1f];\nconst ZENKAKU_PUNCTUATION_3 = [0xff3b, 0xff3f];\nconst ZENKAKU_PUNCTUATION_4 = [0xff5b, 0xff60];\nconst ZENKAKU_SYMBOLS_CURRENCY = [0xffe0, 0xffee];\n\nconst HIRAGANA_CHARS = [0x3040, 0x309f];\nconst KATAKANA_CHARS = [0x30a0, 0x30ff];\nconst HANKAKU_KATAKANA = [0xff66, 0xff9f];\nconst KATAKANA_PUNCTUATION = [0x30fb, 0x30fc];\nconst KANA_PUNCTUATION = [0xff61, 0xff65];\nconst CJK_SYMBOLS_PUNCTUATION = [0x3000, 0x303f];\nconst COMMON_CJK = [0x4e00, 0x9fff];\nconst RARE_CJK = [0x3400, 0x4dbf];\n\nexport const KANA_RANGES = [HIRAGANA_CHARS, KATAKANA_CHARS, KANA_PUNCTUATION, HANKAKU_KATAKANA];\n\nexport const JA_PUNCTUATION_RANGES = [\n CJK_SYMBOLS_PUNCTUATION,\n KANA_PUNCTUATION,\n KATAKANA_PUNCTUATION,\n ZENKAKU_PUNCTUATION_1,\n ZENKAKU_PUNCTUATION_2,\n ZENKAKU_PUNCTUATION_3,\n ZENKAKU_PUNCTUATION_4,\n ZENKAKU_SYMBOLS_CURRENCY,\n];\n\n// All Japanese unicode start and end ranges\n// Includes kanji, kana, zenkaku latin chars, punctuation, and number ranges.\nexport const JAPANESE_RANGES = [\n ...KANA_RANGES,\n ...JA_PUNCTUATION_RANGES,\n ZENKAKU_UPPERCASE,\n ZENKAKU_LOWERCASE,\n ZENKAKU_NUMBERS,\n COMMON_CJK,\n RARE_CJK,\n];\n\nconst MODERN_ENGLISH = [0x0000, 0x007f];\nconst HEPBURN_MACRON_RANGES = [\n [0x0100, 0x0101], // Ā ā\n [0x0112, 0x0113], // Ē ē\n [0x012a, 0x012b], // Ī ī\n [0x014c, 0x014d], // Ō ō\n [0x016a, 0x016b], // Ū ū\n];\nconst SMART_QUOTE_RANGES = [\n [0x2018, 0x2019], // ‘ ’\n [0x201c, 0x201d], // “ ”\n];\n\nexport const ROMAJI_RANGES = [MODERN_ENGLISH, ...HEPBURN_MACRON_RANGES];\n\nexport const EN_PUNCTUATION_RANGES = [\n [0x20, 0x2f],\n [0x3a, 0x3f],\n [0x5b, 0x60],\n [0x7b, 0x7e],\n ...SMART_QUOTE_RANGES,\n];\n","import isCharInRange from './isCharInRange';\nimport { JAPANESE_RANGES } from '../constants';\n\n/**\n * Tests a character. Returns true if the character is [Katakana](https://en.wikipedia.org/wiki/Katakana).\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharJapanese(char = '') {\n return JAPANESE_RANGES.some(([start, end]) => isCharInRange(char, start, end));\n}\n\nexport default isCharJapanese;\n","import typeOf from './utils/typeOf';\nimport isEmpty from './utils/isEmpty';\nimport isCharJapanese from './utils/isCharJapanese';\n\n/**\n * Test if `input` only includes [Kanji](https://en.wikipedia.org/wiki/Kanji), [Kana](https://en.wikipedia.org/wiki/Kana), zenkaku numbers, and JA punctuation/symbols.”\n * @param {String} [input=''] text\n * @param {Regexp} [allowed] additional test allowed to pass for each char\n * @return {Boolean} true if passes checks\n * @example\n * isJapanese('泣き虫')\n * // => true\n * isJapanese('あア')\n * // => true\n * isJapanese('2月') // Zenkaku numbers allowed\n * // => true\n * isJapanese('泣き虫。!〜$') // Zenkaku/JA punctuation\n * // => true\n * isJapanese('泣き虫.!~$') // Latin punctuation fails\n * // => false\n * isJapanese('A泣き虫')\n * // => false\n * isJapanese('≪偽括弧≫', /[≪≫]/);\n * // => true\n */\nfunction isJapanese(input = '', allowed) {\n const augmented = typeOf(allowed) === 'regexp';\n return isEmpty(input)\n ? false\n : [...input].every((char) => {\n const isJa = isCharJapanese(char);\n return !augmented ? isJa : isJa || allowed.test(char);\n });\n}\n\nexport default isJapanese;\n","import { DEFAULT_OPTIONS } from '../constants';\n/**\n * Easy re-use of merging with default options\n * @param {Object} opts user options\n * @returns user options merged over default options\n */\nconst mergeWithDefaultOptions = (opts = {}) => Object.assign({}, DEFAULT_OPTIONS, opts);\n\nexport default mergeWithDefaultOptions;\n","import typeOf from './typeOf';\n\nexport function applyMapping(string, mapping, convertEnding) {\n const root = mapping;\n\n function nextSubtree(tree, nextChar) {\n const subtree = tree[nextChar];\n if (subtree === undefined) {\n return undefined;\n }\n // if the next child node does not have a node value, set its node value to the input\n return Object.assign({ '': tree[''] + nextChar }, tree[nextChar]);\n }\n\n function newChunk(remaining, currentCursor) {\n // start parsing a new chunk\n const firstChar = remaining.charAt(0);\n\n return parse(\n Object.assign({ '': firstChar }, root[firstChar]),\n remaining.slice(1),\n currentCursor,\n currentCursor + 1\n );\n }\n\n function parse(tree, remaining, lastCursor, currentCursor) {\n if (!remaining) {\n if (convertEnding || Object.keys(tree).length === 1) {\n // nothing more to consume, just commit the last chunk and return it\n // so as to not have an empty element at the end of the result\n return tree[''] ? [[lastCursor, currentCursor, tree['']]] : [];\n }\n // if we don't want to convert the ending, because there are still possible continuations\n // return null as the final node value\n return [[lastCursor, currentCursor, null]];\n }\n\n if (Object.keys(tree).length === 1) {\n return [[lastCursor, currentCursor, tree['']]].concat(newChunk(remaining, currentCursor));\n }\n\n const subtree = nextSubtree(tree, remaining.charAt(0));\n\n if (subtree === undefined) {\n return [[lastCursor, currentCursor, tree['']]].concat(newChunk(remaining, currentCursor));\n }\n // continue current branch\n return parse(subtree, remaining.slice(1), lastCursor, currentCursor + 1);\n }\n\n return newChunk(string, 0);\n}\n\n// transform the tree, so that for example hepburnTree['ゔ']['ぁ'][''] === 'va'\n// or kanaTree['k']['y']['a'][''] === 'きゃ'\nexport function transform(tree) {\n return Object.entries(tree).reduce((map, [char, subtree]) => {\n const endOfBranch = typeOf(subtree) === 'string';\n map[char] = endOfBranch ? { '': subtree } : transform(subtree);\n return map;\n }, {});\n}\n\nexport function getSubTreeOf(tree, string) {\n return string.split('').reduce((correctSubTree, char) => {\n if (correctSubTree[char] === undefined) {\n correctSubTree[char] = {};\n }\n return correctSubTree[char];\n }, tree);\n}\n\n/**\n * Creates a custom mapping tree, returns a function that accepts a defaultMap which the newly created customMapping will be merged with and returned\n * (customMap) => (defaultMap) => mergedMap\n * @param {Object} customMap { 'ka' : 'な' }\n * @return {Function} (defaultMap) => defaultMergedWithCustomMap\n * @example\n * const sillyMap = createCustomMapping({ 'ちゃ': 'time', '茎': 'cookie' });\n * // sillyMap is passed defaultMapping to merge with when called in toRomaji()\n * toRomaji(\"It's 茎 ちゃ よ\", { customRomajiMapping: sillyMap });\n * // => 'It's cookie time yo';\n */\nexport function createCustomMapping(customMap = {}) {\n const customTree = {};\n\n if (typeOf(customMap) === 'object') {\n Object.entries(customMap).forEach(([roma, kana]) => {\n let subTree = customTree;\n roma.split('').forEach((char) => {\n if (subTree[char] === undefined) {\n subTree[char] = {};\n }\n subTree = subTree[char];\n });\n subTree[''] = kana;\n });\n }\n\n return function makeMap(map) {\n const mapCopy = JSON.parse(JSON.stringify(map));\n\n function transformMap(mapSubtree, customSubtree) {\n if (mapSubtree === undefined || typeOf(mapSubtree) === 'string') {\n return customSubtree;\n }\n return Object.entries(customSubtree).reduce((newSubtree, [char, subtree]) => {\n newSubtree[char] = transformMap(mapSubtree[char], subtree);\n return newSubtree;\n }, mapSubtree);\n }\n\n return transformMap(mapCopy, customTree);\n };\n}\n\n// allow consumer to pass either function or object as customMapping\nexport function mergeCustomMapping(map, customMapping) {\n if (!customMapping) {\n return map;\n }\n return typeOf(customMapping) === 'function'\n ? customMapping(map)\n : createCustomMapping(customMapping)(map);\n}\n","import { transform, getSubTreeOf, createCustomMapping } from './kanaMapping';\n\n// NOTE: not exactly kunrei shiki, for example ぢゃ -> dya instead of zya, to avoid name clashing\n/* eslint-disable */\n// prettier-ignore\nconst BASIC_KUNREI = {\n a: 'あ', i: 'い', u: 'う', e: 'え', o: 'お',\n k: { a: 'か', i: 'き', u: 'く', e: 'け', o: 'こ', },\n s: { a: 'さ', i: 'し', u: 'す', e: 'せ', o: 'そ', },\n t: { a: 'た', i: 'ち', u: 'つ', e: 'て', o: 'と', },\n n: { a: 'な', i: 'に', u: 'ぬ', e: 'ね', o: 'の', },\n h: { a: 'は', i: 'ひ', u: 'ふ', e: 'へ', o: 'ほ', },\n m: { a: 'ま', i: 'み', u: 'む', e: 'め', o: 'も', },\n y: { a: 'や', u: 'ゆ', o: 'よ' },\n r: { a: 'ら', i: 'り', u: 'る', e: 'れ', o: 'ろ', },\n w: { a: 'わ', i: 'ゐ', e: 'ゑ', o: 'を', },\n g: { a: 'が', i: 'ぎ', u: 'ぐ', e: 'げ', o: 'ご', },\n z: { a: 'ざ', i: 'じ', u: 'ず', e: 'ぜ', o: 'ぞ', },\n d: { a: 'だ', i: 'ぢ', u: 'づ', e: 'で', o: 'ど', },\n b: { a: 'ば', i: 'び', u: 'ぶ', e: 'べ', o: 'ぼ', },\n p: { a: 'ぱ', i: 'ぴ', u: 'ぷ', e: 'ぺ', o: 'ぽ', },\n v: { a: 'ゔぁ', i: 'ゔぃ', u: 'ゔ', e: 'ゔぇ', o: 'ゔぉ', },\n};\n\nconst SPECIAL_SYMBOLS = {\n '.': '。',\n ',': '、',\n ':': ':',\n '/': '・',\n '!': '!',\n '?': '?',\n '~': '〜',\n '-': 'ー',\n '‘': '「',\n '’': '」',\n '“': '『',\n '”': '』',\n '[': '[',\n ']': ']',\n '(': '(',\n ')': ')',\n '{': '{',\n '}': '}',\n};\n\nconst CONSONANTS = {\n k: 'き',\n s: 'し',\n t: 'ち',\n n: 'に',\n h: 'ひ',\n m: 'み',\n r: 'り',\n g: 'ぎ',\n z: 'じ',\n d: 'ぢ',\n b: 'び',\n p: 'ぴ',\n v: 'ゔ',\n q: 'く',\n f: 'ふ',\n};\nconst SMALL_Y = { ya: 'ゃ', yi: 'ぃ', yu: 'ゅ', ye: 'ぇ', yo: 'ょ' };\nconst SMALL_VOWELS = { a: 'ぁ', i: 'ぃ', u: 'ぅ', e: 'ぇ', o: 'ぉ' };\n\n// typing one should be the same as having typed the other instead\nconst ALIASES = {\n sh: 'sy', // sha -> sya\n ch: 'ty', // cho -> tyo\n cy: 'ty', // cyo -> tyo\n chy: 'ty', // chyu -> tyu\n shy: 'sy', // shya -> sya\n j: 'zy', // ja -> zya\n jy: 'zy', // jye -> zye\n\n // exceptions to above rules\n shi: 'si',\n chi: 'ti',\n tsu: 'tu',\n ji: 'zi',\n fu: 'hu',\n};\n\n// xtu -> っ\nconst SMALL_LETTERS = Object.assign(\n {\n tu: 'っ',\n wa: 'ゎ',\n ka: 'ヵ',\n ke: 'ヶ',\n },\n SMALL_VOWELS,\n SMALL_Y\n);\n\n// don't follow any notable patterns\nconst SPECIAL_CASES = {\n yi: 'い',\n wu: 'う',\n ye: 'いぇ',\n wi: 'うぃ',\n we: 'うぇ',\n kwa: 'くぁ',\n whu: 'う',\n // because it's not thya for てゃ but tha\n // and tha is not てぁ, but てゃ\n tha: 'てゃ',\n thu: 'てゅ',\n tho: 'てょ',\n dha: 'でゃ',\n dhu: 'でゅ',\n dho: 'でょ',\n};\n\nconst AIUEO_CONSTRUCTIONS = {\n wh: 'う',\n qw: 'く',\n q: 'く',\n gw: 'ぐ',\n sw: 'す',\n ts: 'つ',\n th: 'て',\n tw: 'と',\n dh: 'で',\n dw: 'ど',\n fw: 'ふ',\n f: 'ふ',\n};\n\n/* eslint-enable */\nfunction createRomajiToKanaMap() {\n const kanaTree = transform(BASIC_KUNREI);\n // pseudo partial application\n const subtreeOf = (string) => getSubTreeOf(kanaTree, string);\n\n // add tya, sya, etc.\n Object.entries(CONSONANTS).forEach(([consonant, yKana]) => {\n Object.entries(SMALL_Y).forEach(([roma, kana]) => {\n // for example kyo -> き + ょ\n subtreeOf(consonant + roma)[''] = yKana + kana;\n });\n });\n\n Object.entries(SPECIAL_SYMBOLS).forEach(([symbol, jsymbol]) => {\n subtreeOf(symbol)[''] = jsymbol;\n });\n\n // things like うぃ, くぃ, etc.\n Object.entries(AIUEO_CONSTRUCTIONS).forEach(([consonant, aiueoKana]) => {\n Object.entries(SMALL_VOWELS).forEach(([vowel, kana]) => {\n const subtree = subtreeOf(consonant + vowel);\n subtree[''] = aiueoKana + kana;\n });\n });\n\n // different ways to write ん\n ['n', \"n'\", 'xn'].forEach((nChar) => {\n subtreeOf(nChar)[''] = 'ん';\n });\n\n // c is equivalent to k, but not for chi, cha, etc. that's why we have to make a copy of k\n kanaTree.c = JSON.parse(JSON.stringify(kanaTree.k));\n\n Object.entries(ALIASES).forEach(([string, alternative]) => {\n const allExceptLast = string.slice(0, string.length - 1);\n const last = string.charAt(string.length - 1);\n const parentTree = subtreeOf(allExceptLast);\n // copy to avoid recursive containment\n parentTree[last] = JSON.parse(JSON.stringify(subtreeOf(alternative)));\n });\n\n function getAlternatives(string) {\n return [...Object.entries(ALIASES), ...[['c', 'k']]].reduce(\n (list, [alt, roma]) =>\n (string.startsWith(roma) ? list.concat(string.replace(roma, alt)) : list),\n []\n );\n }\n\n Object.entries(SMALL_LETTERS).forEach(([kunreiRoma, kana]) => {\n const last = (char) => char.charAt(char.length - 1);\n const allExceptLast = (chars) => chars.slice(0, chars.length - 1);\n const xRoma = `x${kunreiRoma}`;\n const xSubtree = subtreeOf(xRoma);\n xSubtree[''] = kana;\n\n // ltu -> xtu -> っ\n const parentTree = subtreeOf(`l${allExceptLast(kunreiRoma)}`);\n parentTree[last(kunreiRoma)] = xSubtree;\n\n // ltsu -> ltu -> っ\n getAlternatives(kunreiRoma).forEach((altRoma) => {\n ['l', 'x'].forEach((prefix) => {\n const altParentTree = subtreeOf(prefix + allExceptLast(altRoma));\n altParentTree[last(altRoma)] = subtreeOf(prefix + kunreiRoma);\n });\n });\n });\n\n Object.entries(SPECIAL_CASES).forEach(([string, kana]) => {\n subtreeOf(string)[''] = kana;\n });\n\n // add kka, tta, etc.\n function addTsu(tree) {\n return Object.entries(tree).reduce((tsuTree, [key, value]) => {\n if (!key) {\n // we have reached the bottom of this branch\n tsuTree[key] = `っ${value}`;\n } else {\n // more subtrees\n tsuTree[key] = addTsu(value);\n }\n return tsuTree;\n }, {});\n }\n // have to explicitly name c here, because we made it a copy of k, not a reference\n [...Object.keys(CONSONANTS), 'c', 'y', 'w', 'j'].forEach((consonant) => {\n const subtree = kanaTree[consonant];\n subtree[consonant] = addTsu(subtree);\n });\n // nn should not be っん\n delete kanaTree.n.n;\n // solidify the results, so that there there is referential transparency within the tree\n return Object.freeze(JSON.parse(JSON.stringify(kanaTree)));\n}\n\nlet romajiToKanaMap = null;\n\nexport function getRomajiToKanaTree() {\n if (romajiToKanaMap == null) {\n romajiToKanaMap = createRomajiToKanaMap();\n }\n return romajiToKanaMap;\n}\n\nexport const USE_OBSOLETE_KANA_MAP = createCustomMapping({ wi: 'ゐ', we: 'ゑ' });\n\nexport function IME_MODE_MAP(map) {\n // in IME mode, we do not want to convert single ns\n const mapCopy = JSON.parse(JSON.stringify(map));\n mapCopy.n.n = { '': 'ん' };\n mapCopy.n[' '] = { '': 'ん' };\n return mapCopy;\n}\n","import isEmpty from './isEmpty';\nimport isCharInRange from './isCharInRange';\nimport { LATIN_UPPERCASE_START, LATIN_UPPERCASE_END } from '../constants';\n\n/**\n * Tests if char is in English unicode uppercase range\n * @param {String} char\n * @return {Boolean}\n */\nfunction isCharUpperCase(char = '') {\n if (isEmpty(char)) return false;\n return isCharInRange(char, LATIN_UPPERCASE_START, LATIN_UPPERCASE_END);\n}\n\nexport default isCharUpperCase;\n","import isEmpty from './isEmpty';\nimport { PROLONGED_SOUND_MARK } from '../constants';\n\n/**\n * Returns true if char is 'ー'\n * @param {String} char to test\n * @return {Boolean}\n */\nfunction isCharLongDash(char = '') {\n if (isEmpty(char)) return false;\n return char.charCodeAt(0) === PROLONGED_SOUND_MARK;\n}\n\nexport default isCharLongDash;\n","import isEmpty from './isEmpty';\nimport { KANA_SLASH_DOT } from '../constants';\n\n/**\n * Tests if char is '・'\n * @param {String} char\n * @return {Boolean} true if '・'\n */\nfunction isCharSlashDot(char = '') {\n if (isEmpty(char)) return false;\n return char.charCodeAt(0) === KANA_SLASH_DOT;\n}\n\nexport default isCharSlashDot;\n","import isEmpty from './isEmpty';\nimport isCharLongDash from './isCharLongDash';\nimport isCharInRange from './isCharInRange';\nimport {\n HIRAGANA_START,\n HIRAGANA_END,\n} from '../constants';\n\n/**\n * Tests a character. Returns true if the character is [Hiragana](https://en.wikipedia.org/wiki/Hiragana).\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharHiragana(char = '') {\n if (isEmpty(char)) return false;\n if (isCharLongDash(char)) return true;\n return isCharInRange(char, HIRAGANA_START, HIRAGANA_END);\n}\n\nexport default isCharHiragana;\n","import { KATAKANA_START, HIRAGANA_START } from '../constants';\n\nimport isCharLongDash from './isCharLongDash';\nimport isCharSlashDot from './isCharSlashDot';\nimport isCharHiragana from './isCharHiragana';\n\n/**\n * Convert [Hiragana](https://en.wikipedia.org/wiki/Hiragana) to [Katakana](https://en.wikipedia.org/wiki/Katakana)\n * Passes through any non-hiragana chars\n * @private\n * @param {String} [input=''] text input\n * @return {String} converted text\n * @example\n * hiraganaToKatakana('ひらがな')\n * // => \"ヒラガナ\"\n * hiraganaToKatakana('ひらがな is a type of kana')\n * // => \"ヒラガナ is a type of kana\"\n */\nfunction hiraganaToKatakana(input = '') {\n const kata = [];\n input.split('').forEach((char) => {\n // Short circuit to avoid incorrect codeshift for 'ー' and '・'\n if (isCharLongDash(char) || isCharSlashDot(char)) {\n kata.push(char);\n } else if (isCharHiragana(char)) {\n // Shift charcode.\n const code = char.charCodeAt(0) + (KATAKANA_START - HIRAGANA_START);\n const kataChar = String.fromCharCode(code);\n kata.push(kataChar);\n } else {\n // Pass non-hiragana chars through\n kata.push(char);\n }\n });\n return kata.join('');\n}\n\nexport default hiraganaToKatakana;\n","import { TO_KANA_METHODS } from './constants';\nimport mergeWithDefaultOptions from './utils/mergeWithDefaultOptions';\nimport { getRomajiToKanaTree, IME_MODE_MAP, USE_OBSOLETE_KANA_MAP } from './utils/romajiToKanaMap';\nimport { applyMapping, mergeCustomMapping } from './utils/kanaMapping';\nimport isCharUpperCase from './utils/isCharUpperCase';\nimport hiraganaToKatakana from './utils/hiraganaToKatakana';\n\n/**\n * Convert [Romaji](https://en.wikipedia.org/wiki/Romaji) to [Kana](https://en.wikipedia.org/wiki/Kana), lowercase text will result in [Hiragana](https://en.wikipedia.org/wiki/Hiragana) and uppercase text will result in [Katakana](https://en.wikipedia.org/wiki/Katakana).\n * @param {String} [input=''] text\n * @param {DefaultOptions} [options=defaultOptions]\n * @return {String} converted text\n * @example\n * toKana('onaji BUTTSUUJI')\n * // => 'おなじ ブッツウジ'\n * toKana('ONAJI buttsuuji')\n * // => 'オナジ ぶっつうじ'\n * toKana('座禅‘zazen’スタイル')\n * // => '座禅「ざぜん」スタイル'\n * toKana('batsuge-mu')\n * // => 'ばつげーむ'\n * toKana('!?.:/,~-‘’“”[](){}') // Punctuation conversion\n * // => '!?。:・、〜ー「」『』[](){}'\n * toKana('we', { useObsoleteKana: true })\n * // => 'ゑ'\n * toKana('wanakana', { customKanaMapping: { na: 'に', ka: 'bana' } });\n * // => 'わにbanaに'\n */\nexport function toKana(input = '', options = {}, map) {\n let config;\n if (!map) {\n config = mergeWithDefaultOptions(options);\n map = createRomajiToKanaMap(config);\n } else {\n config = options;\n }\n\n // throw away the substring index information and just concatenate all the kana\n return splitIntoConvertedKana(input, config, map)\n .map((kanaToken) => {\n const [start, end, kana] = kanaToken;\n if (kana === null) {\n // haven't converted the end of the string, since we are in IME mode\n return input.slice(start);\n }\n const enforceHiragana = config.IMEMode === TO_KANA_METHODS.HIRAGANA;\n const enforceKatakana =\n config.IMEMode === TO_KANA_METHODS.KATAKANA ||\n [...input.slice(start, end)].every(isCharUpperCase);\n\n return enforceHiragana || !enforceKatakana ? kana : hiraganaToKatakana(kana);\n })\n .join('');\n}\n\n/**\n *\n * @private\n * @param {String} [input=''] input text\n * @param {Object} [options={}] toKana options\n * @returns {Array[]} [[start, end, token]]\n * @example\n * splitIntoConvertedKana('buttsuuji')\n * // => [[0, 2, 'ぶ'], [2, 6, 'っつ'], [6, 7, 'う'], [7, 9, 'じ']]\n */\nexport function splitIntoConvertedKana(input = '', options = {}, map) {\n if (!map) {\n map = createRomajiToKanaMap(options);\n }\n return applyMapping(input.toLowerCase(), map, !options.IMEMode);\n}\n\nlet customMapping = null;\nexport function createRomajiToKanaMap(options = {}) {\n let map = getRomajiToKanaTree();\n\n map = options.IMEMode ? IME_MODE_MAP(map) : map;\n map = options.useObsoleteKana ? USE_OBSOLETE_KANA_MAP(map) : map;\n\n if (options.customKanaMapping) {\n if (customMapping == null) {\n customMapping = mergeCustomMapping(map, options.customKanaMapping);\n }\n map = customMapping;\n }\n\n return map;\n}\n\nexport default toKana;\n","import isJapanese from '../isJapanese';\nimport toKana, { createRomajiToKanaMap } from '../toKana';\nimport mergeWithDefaultOptions from './mergeWithDefaultOptions';\n\nlet LISTENERS = [];\n/**\n * Automagically replaces input values with converted text to kana\n * @param {defaultOptions} [options] user config overrides, default conversion is toKana()\n * @return {Function} event handler with bound options\n * @private\n */\nexport function makeOnInput(options) {\n let prevInput;\n // Enforce IMEMode if not already specified\n const mergedConfig = Object.assign({}, mergeWithDefaultOptions(options), {\n IMEMode: options.IMEMode || true,\n });\n const preConfiguredMap = createRomajiToKanaMap(mergedConfig);\n const triggers = [\n ...Object.keys(preConfiguredMap),\n ...Object.keys(preConfiguredMap).map((char) => char.toUpperCase()),\n ];\n\n return function onInput({ target }) {\n if (target.value !== prevInput && target.dataset.ignoreComposition !== 'true') {\n convertInput(target, mergedConfig, preConfiguredMap, triggers, prevInput);\n }\n };\n}\n\nexport function convertInput(target, options, map, triggers, prevInput) {\n const [head, textToConvert, tail] = splitInput(target.value, target.selectionEnd, triggers);\n const convertedText = toKana(textToConvert, options, map);\n const changed = textToConvert !== convertedText;\n\n if (changed) {\n const newCursor = head.length + convertedText.length;\n const newValue = head + convertedText + tail;\n target.value = newValue;\n prevInput = newValue;\n\n if (tail.length) {\n // push later on event loop (otherwise mid-text insertion can be 1 char too far to the right)\n setTimeout(() => target.setSelectionRange(newCursor, newCursor), 1);\n } else {\n target.setSelectionRange(newCursor, newCursor);\n }\n } else {\n prevInput = target.value;\n }\n}\n\nexport function onComposition({ type, target, data }) {\n // navigator.platform is not 100% reliable for singling out all OS,\n // but for determining desktop \"Mac OS\" it is effective enough.\n const isMacOS = /Mac/.test(window.navigator && window.navigator.platform);\n // We don't want to ignore on Android:\n // https://github.com/WaniKani/WanaKana/issues/82\n // But MacOS IME auto-closes if we don't ignore:\n // https://github.com/WaniKani/WanaKana/issues/71\n // Other platform Japanese IMEs pass through happily\n if (isMacOS) {\n if (type === 'compositionupdate' && isJapanese(data)) {\n target.dataset.ignoreComposition = 'true';\n }\n\n if (type === 'compositionend') {\n target.dataset.ignoreComposition = 'false';\n }\n }\n}\n\nexport function trackListeners(id, inputHandler, compositionHandler) {\n LISTENERS = LISTENERS.concat({\n id,\n inputHandler,\n compositionHandler,\n });\n}\n\nexport function untrackListeners({ id: targetId }) {\n LISTENERS = LISTENERS.filter(({ id }) => id !== targetId);\n}\n\nexport function findListeners(el) {\n return el && LISTENERS.find(({ id }) => id === el.getAttribute('data-wanakana-id'));\n}\n\n// Handle non-terminal inserted input conversion:\n// | -> わ| -> わび| -> わ|び -> わs|び -> わsh|び -> わshi|び -> わし|び\n// or multiple ambiguous positioning (to select which \"s\" to work from)\n// こsこs|こsこ -> こsこso|こsこ -> こsこそ|こsこ\nexport function splitInput(text = '', cursor = 0, triggers = []) {\n let head;\n let toConvert;\n let tail;\n\n if (cursor === 0 && triggers.includes(text[0])) {\n [head, toConvert, tail] = workFromStart(text, triggers);\n } else if (cursor > 0) {\n [head, toConvert, tail] = workBackwards(text, cursor);\n } else {\n [head, toConvert] = takeWhileAndSlice(text, (char) => !triggers.includes(char));\n [toConvert, tail] = takeWhileAndSlice(toConvert, (char) => !isJapanese(char));\n }\n\n return [head, toConvert, tail];\n}\n\nfunction workFromStart(text, catalystChars) {\n return [\n '',\n ...takeWhileAndSlice(\n text,\n (char) => catalystChars.includes(char) || !isJapanese(char, /[0-9]/)\n ),\n ];\n}\n\nfunction workBackwards(text = '', startIndex = 0) {\n const [toConvert, head] = takeWhileAndSlice(\n [...text.slice(0, startIndex)].reverse(),\n (char) => !isJapanese(char)\n );\n return [\n head.reverse().join(''),\n toConvert\n .split('')\n .reverse()\n .join(''),\n text.slice(startIndex),\n ];\n}\n\nfunction takeWhileAndSlice(source = {}, predicate = (x) => !!x) {\n const result = [];\n const { length } = source;\n let i = 0;\n while (i < length && predicate(source[i], i)) {\n result.push(source[i]);\n i += 1;\n }\n return [result.join(''), source.slice(i)];\n}\n","/* eslint-disable no-console */\nconst onInput = ({ target: { value, selectionStart, selectionEnd } }) =>\n console.log('input:', { value, selectionStart, selectionEnd });\nconst onCompositionStart = () => console.log('compositionstart');\nconst onCompositionUpdate = ({ target: { value, selectionStart, selectionEnd }, data }) =>\n console.log('compositionupdate', {\n data,\n value,\n selectionStart,\n selectionEnd,\n });\nconst onCompositionEnd = () => console.log('compositionend');\n\nconst events = {\n input: onInput,\n compositionstart: onCompositionStart,\n compositionupdate: onCompositionUpdate,\n compositionend: onCompositionEnd,\n};\n\nexport const addDebugListeners = (input) => {\n Object.entries(events).forEach(([event, handler]) => input.addEventListener(event, handler));\n};\n\nexport const removeDebugListeners = (input) => {\n Object.entries(events).forEach(([event, handler]) => input.removeEventListener(event, handler));\n};\n","import { makeOnInput, onComposition, trackListeners } from './utils/dom';\nimport { addDebugListeners } from './utils/logInputEvents';\n\nconst ELEMENTS = ['TEXTAREA', 'INPUT'];\n\nlet idCounter = 0;\nconst newId = () => {\n idCounter += 1;\n return `${Date.now()}${idCounter}`;\n};\n\n/**\n * Binds eventListener for 'input' events to an input field to automagically replace values with kana\n * Can pass `{ IMEMode: 'toHiragana' || 'toKatakana' }` to enforce kana conversion type\n * @param {HTMLElement} element textarea, input[type=\"text\"] etc\n * @param {DefaultOptions} [options=defaultOptions] defaults to { IMEMode: true } using `toKana`\n * @example\n * bind(document.querySelector('#myInput'));\n */\nfunction bind(element = {}, options = {}, debug = false) {\n if (!ELEMENTS.includes(element.nodeName)) {\n throw new Error(\n `Element provided to Wanakana bind() was not a valid input or textarea element.\\n Received: (${JSON.stringify(\n element\n )})`\n );\n }\n const onInput = makeOnInput(options);\n const id = newId();\n element.setAttribute('data-wanakana-id', id);\n element.setAttribute('lang', 'ja');\n element.setAttribute('autoCapitalize', 'none');\n element.setAttribute('autoCorrect', 'off');\n element.setAttribute('autoComplete', 'off');\n element.setAttribute('spellCheck', 'false');\n element.addEventListener('input', onInput);\n element.addEventListener('compositionupdate', onComposition);\n element.addEventListener('compositionend', onComposition);\n trackListeners(id, onInput, onComposition);\n if (debug === true) {\n addDebugListeners(element);\n }\n}\n\nexport default bind;\n","import isEmpty from './isEmpty';\nimport isCharInRange from './isCharInRange';\nimport { ROMAJI_RANGES } from '../constants';\n\n/**\n * Tests a character. Returns true if the character is [Romaji](https://en.wikipedia.org/wiki/Romaji) (allowing [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization))\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharRomaji(char = '') {\n if (isEmpty(char)) return false;\n return ROMAJI_RANGES.some(([start, end]) => isCharInRange(char, start, end));\n}\n\nexport default isCharRomaji;\n","import typeOf from './utils/typeOf';\nimport isEmpty from './utils/isEmpty';\nimport isCharRomaji from './utils/isCharRomaji';\n\n/**\n * Test if `input` is [Romaji](https://en.wikipedia.org/wiki/Romaji) (allowing [Hepburn romanisation](https://en.wikipedia.org/wiki/Hepburn_romanization))\n * @param {String} [input=''] text\n * @param {Regexp} [allowed] additional test allowed to pass for each char\n * @return {Boolean} true if [Romaji](https://en.wikipedia.org/wiki/Romaji)\n * @example\n * isRomaji('Tōkyō and Ōsaka')\n * // => true\n * isRomaji('12a*b&c-d')\n * // => true\n * isRomaji('あアA')\n * // => false\n * isRomaji('お願い')\n * // => false\n * isRomaji('a!b&cーd') // Zenkaku punctuation fails\n * // => false\n * isRomaji('a!b&cーd', /[!ー]/)\n * // => true\n */\nfunction isRomaji(input = '', allowed) {\n const augmented = typeOf(allowed) === 'regexp';\n return isEmpty(input)\n ? false\n : [...input].every((char) => {\n const isRoma = isCharRomaji(char);\n return !augmented ? isRoma : isRoma || allowed.test(char);\n });\n}\n\nexport default isRomaji;\n","import {\n KATAKANA_START,\n KATAKANA_END,\n} from '../constants';\n\nimport isCharInRange from './isCharInRange';\n\n/**\n * Tests a character. Returns true if the character is [Katakana](https://en.wikipedia.org/wiki/Katakana).\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharKatakana(char = '') {\n return isCharInRange(char, KATAKANA_START, KATAKANA_END);\n}\n\nexport default isCharKatakana;\n","import isEmpty from './isEmpty';\nimport isCharHiragana from './isCharHiragana';\nimport isCharKatakana from './isCharKatakana';\n\n/**\n * Tests a character. Returns true if the character is [Hiragana](https://en.wikipedia.org/wiki/Hiragana) or [Katakana](https://en.wikipedia.org/wiki/Katakana).\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharKana(char = '') {\n if (isEmpty(char)) return false;\n return isCharHiragana(char) || isCharKatakana(char);\n}\n\nexport default isCharKana;\n","import isEmpty from './utils/isEmpty';\nimport isCharKana from './utils/isCharKana';\n\n/**\n * Test if `input` is [Kana](https://en.wikipedia.org/wiki/Kana) ([Katakana](https://en.wikipedia.org/wiki/Katakana) and/or [Hiragana](https://en.wikipedia.org/wiki/Hiragana))\n * @param {String} [input=''] text\n * @return {Boolean} true if all [Kana](https://en.wikipedia.org/wiki/Kana)\n * @example\n * isKana('あ')\n * // => true\n * isKana('ア')\n * // => true\n * isKana('あーア')\n * // => true\n * isKana('A')\n * // => false\n * isKana('あAア')\n * // => false\n */\nfunction isKana(input = '') {\n if (isEmpty(input)) return false;\n return [...input].every(isCharKana);\n}\n\nexport default isKana;\n","import isEmpty from './utils/isEmpty';\nimport isCharHiragana from './utils/isCharHiragana';\n\n/**\n * Test if `input` is [Hiragana](https://en.wikipedia.org/wiki/Hiragana)\n * @param {String} [input=''] text\n * @return {Boolean} true if all [Hiragana](https://en.wikipedia.org/wiki/Hiragana)\n * @example\n * isHiragana('げーむ')\n * // => true\n * isHiragana('A')\n * // => false\n * isHiragana('あア')\n * // => false\n */\nfunction isHiragana(input = '') {\n if (isEmpty(input)) return false;\n return [...input].every(isCharHiragana);\n}\n\nexport default isHiragana;\n","import isEmpty from './utils/isEmpty';\nimport isCharKatakana from './utils/isCharKatakana';\n\n/**\n * Test if `input` is [Katakana](https://en.wikipedia.org/wiki/Katakana)\n * @param {String} [input=''] text\n * @return {Boolean} true if all [Katakana](https://en.wikipedia.org/wiki/Katakana)\n * @example\n * isKatakana('ゲーム')\n * // => true\n * isKatakana('あ')\n * // => false\n * isKatakana('A')\n * // => false\n * isKatakana('あア')\n * // => false\n */\nfunction isKatakana(input = '') {\n if (isEmpty(input)) return false;\n return [...input].every(isCharKatakana);\n}\n\nexport default isKatakana;\n","import {\n KANJI_START,\n KANJI_END,\n} from '../constants';\n\nimport isCharInRange from './isCharInRange';\n/**\n * Tests a character. Returns true if the character is a CJK ideograph (kanji).\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharKanji(char = '') {\n return isCharInRange(char, KANJI_START, KANJI_END);\n}\n\nexport default isCharKanji;\n","import isEmpty from './utils/isEmpty';\nimport isCharKanji from './utils/isCharKanji';\n\n/**\n * Tests if `input` is [Kanji](https://en.wikipedia.org/wiki/Kanji) ([Japanese CJK ideographs](https://en.wikipedia.org/wiki/CJK_Unified_Ideographs))\n * @param {String} [input=''] text\n * @return {Boolean} true if all [Kanji](https://en.wikipedia.org/wiki/Kanji)\n * @example\n * isKanji('刀')\n * // => true\n * isKanji('切腹')\n * // => true\n * isKanji('勢い')\n * // => false\n * isKanji('あAア')\n * // => false\n * isKanji('🐸')\n * // => false\n */\nfunction isKanji(input = '') {\n if (isEmpty(input)) return false;\n return [...input].every(isCharKanji);\n}\n\nexport default isKanji;\n","import isKanji from './isKanji';\nimport isHiragana from './isHiragana';\nimport isKatakana from './isKatakana';\nimport isRomaji from './isRomaji';\n\n/**\n * Test if `input` contains a mix of [Romaji](https://en.wikipedia.org/wiki/Romaji) *and* [Kana](https://en.wikipedia.org/wiki/Kana), defaults to pass through [Kanji](https://en.wikipedia.org/wiki/Kanji)\n * @param {String} input text\n * @param {Object} [options={ passKanji: true }] optional config to pass through kanji\n * @return {Boolean} true if mixed\n * @example\n * isMixed('Abあア'))\n * // => true\n * isMixed('お腹A')) // ignores kanji by default\n * // => true\n * isMixed('お腹A', { passKanji: false }))\n * // => false\n * isMixed('ab'))\n * // => false\n * isMixed('あア'))\n * // => false\n */\nfunction isMixed(input = '', options = { passKanji: true }) {\n const chars = [...input];\n let hasKanji = false;\n if (!options.passKanji) {\n hasKanji = chars.some(isKanji);\n }\n return (chars.some(isHiragana) || chars.some(isKatakana)) && chars.some(isRomaji) && !hasKanji;\n}\n\nexport default isMixed;\n","import { KATAKANA_START, HIRAGANA_START } from '../constants';\n\nimport isCharLongDash from './isCharLongDash';\nimport isCharSlashDot from './isCharSlashDot';\nimport isCharKatakana from './isCharKatakana';\nconst isCharInitialLongDash = (char, index) => isCharLongDash(char) && index < 1;\nconst isCharInnerLongDash = (char, index) => isCharLongDash(char) && index > 0;\nconst isKanaAsSymbol = (char) => ['ヶ', 'ヵ'].includes(char);\nconst LONG_VOWELS = {\n a: 'あ',\n i: 'い',\n u: 'う',\n e: 'え',\n o: 'う',\n};\n\n// inject toRomaji to avoid circular dependency between toRomaji <-> katakanaToHiragana\nfunction katakanaToHiragana(input = '', toRomaji, isDestinationRomaji) {\n let previousKana = '';\n\n return input\n .split('')\n .reduce((hira, char, index) => {\n // Short circuit to avoid incorrect codeshift for 'ー' and '・'\n if (isCharSlashDot(char) || isCharInitialLongDash(char, index) || isKanaAsSymbol(char)) {\n return hira.concat(char);\n // Transform long vowels: 'オー' to 'おう'\n } else if (previousKana && isCharInnerLongDash(char, index)) {\n // Transform previousKana back to romaji, and slice off the vowel\n const romaji = toRomaji(previousKana).slice(-1);\n // However, ensure 'オー' => 'おお' => 'oo' if this is a transform on the way to romaji\n if (isCharKatakana(input[index - 1]) && romaji === 'o' && isDestinationRomaji) {\n return hira.concat('お');\n }\n return hira.concat(LONG_VOWELS[romaji]);\n } else if (!isCharLongDash(char) && isCharKatakana(char)) {\n // Shift charcode.\n const code = char.charCodeAt(0) + (HIRAGANA_START - KATAKANA_START);\n const hiraChar = String.fromCharCode(code);\n previousKana = hiraChar;\n return hira.concat(hiraChar);\n }\n // Pass non katakana chars through\n previousKana = '';\n return hira.concat(char);\n }, [])\n .join('');\n}\n\nexport default katakanaToHiragana;\n","import { transform, getSubTreeOf } from './kanaMapping';\nimport { ROMANIZATIONS } from '../constants';\n\nlet kanaToHepburnMap = null;\n\n/* eslint-disable */\n// prettier-ignore\nconst BASIC_ROMAJI = {\n あ:'a', い:'i', う:'u', え:'e', お:'o',\n か:'ka', き:'ki', く:'ku', け:'ke', こ:'ko',\n さ:'sa', し:'shi', す:'su', せ:'se', そ:'so',\n た:'ta', ち:'chi', つ:'tsu', て:'te', と:'to',\n な:'na', に:'ni', ぬ:'nu', ね:'ne', の:'no',\n は:'ha', ひ:'hi', ふ:'fu', へ:'he', ほ:'ho',\n ま:'ma', み:'mi', む:'mu', め:'me', も:'mo',\n ら:'ra', り:'ri', る:'ru', れ:'re', ろ:'ro',\n や:'ya', ゆ:'yu', よ:'yo',\n わ:'wa', ゐ:'wi', ゑ:'we', を:'wo',\n ん: 'n',\n が:'ga', ぎ:'gi', ぐ:'gu', げ:'ge', ご:'go',\n ざ:'za', じ:'ji', ず:'zu', ぜ:'ze', ぞ:'zo',\n だ:'da', ぢ:'ji', づ:'zu', で:'de', ど:'do',\n ば:'ba', び:'bi', ぶ:'bu', べ:'be', ぼ:'bo',\n ぱ:'pa', ぴ:'pi', ぷ:'pu', ぺ:'pe', ぽ:'po',\n ゔぁ:'va', ゔぃ:'vi', ゔ:'vu', ゔぇ:'ve', ゔぉ:'vo',\n};\n/* eslint-enable */\n\nconst SPECIAL_SYMBOLS = {\n '。': '.',\n '、': ',',\n ':': ':',\n '・': '/',\n '!': '!',\n '?': '?',\n '〜': '~',\n 'ー': '-',\n '「': '‘',\n '」': '’',\n '『': '“',\n '』': '”',\n '[': '[',\n ']': ']',\n '(': '(',\n ')': ')',\n '{': '{',\n '}': '}',\n ' ': ' ',\n};\n\n// んい -> n'i\nconst AMBIGUOUS_VOWELS = ['あ', 'い', 'う', 'え', 'お', 'や', 'ゆ', 'よ'];\nconst SMALL_Y = { ゃ: 'ya', ゅ: 'yu', ょ: 'yo' };\nconst SMALL_Y_EXTRA = { ぃ: 'yi', ぇ: 'ye' };\nconst SMALL_AIUEO = {\n ぁ: 'a',\n ぃ: 'i',\n ぅ: 'u',\n ぇ: 'e',\n ぉ: 'o',\n};\nconst YOON_KANA = ['き', 'に', 'ひ', 'み', 'り', 'ぎ', 'び', 'ぴ', 'ゔ', 'く', 'ふ'];\nconst YOON_EXCEPTIONS = {\n し: 'sh',\n ち: 'ch',\n じ: 'j',\n ぢ: 'j',\n};\nconst SMALL_KANA = {\n っ: '',\n ゃ: 'ya',\n ゅ: 'yu',\n ょ: 'yo',\n ぁ: 'a',\n ぃ: 'i',\n ぅ: 'u',\n ぇ: 'e',\n ぉ: 'o',\n};\n\n// going with the intuitive (yet incorrect) solution where っや -> yya and っぃ -> ii\n// in other words, just assume the sokuon could have been applied to anything\nconst SOKUON_WHITELIST = {\n b: 'b',\n c: 't',\n d: 'd',\n f: 'f',\n g: 'g',\n h: 'h',\n j: 'j',\n k: 'k',\n m: 'm',\n p: 'p',\n q: 'q',\n r: 'r',\n s: 's',\n t: 't',\n v: 'v',\n w: 'w',\n x: 'x',\n z: 'z',\n};\n\nfunction getKanaToHepburnTree() {\n if (kanaToHepburnMap == null) {\n kanaToHepburnMap = createKanaToHepburnMap();\n }\n return kanaToHepburnMap;\n}\n\nexport function getKanaToRomajiTree(fullOptions) {\n switch (fullOptions.romanization) {\n case ROMANIZATIONS.HEPBURN:\n return getKanaToHepburnTree(fullOptions);\n default:\n return {};\n }\n}\n\nfunction createKanaToHepburnMap() {\n const romajiTree = transform(BASIC_ROMAJI);\n\n const subtreeOf = (string) => getSubTreeOf(romajiTree, string);\n const setTrans = (string, transliteration) => {\n subtreeOf(string)[''] = transliteration;\n };\n\n Object.entries(SPECIAL_SYMBOLS).forEach(([jsymbol, symbol]) => {\n subtreeOf(jsymbol)[''] = symbol;\n });\n\n [...Object.entries(SMALL_Y), ...Object.entries(SMALL_AIUEO)].forEach(([roma, kana]) => {\n setTrans(roma, kana);\n });\n\n // きゃ -> kya\n YOON_KANA.forEach((kana) => {\n const firstRomajiChar = subtreeOf(kana)[''][0];\n Object.entries(SMALL_Y).forEach(([yKana, yRoma]) => {\n setTrans(kana + yKana, firstRomajiChar + yRoma);\n });\n // きぃ -> kyi\n Object.entries(SMALL_Y_EXTRA).forEach(([yKana, yRoma]) => {\n setTrans(kana + yKana, firstRomajiChar + yRoma);\n });\n });\n\n Object.entries(YOON_EXCEPTIONS).forEach(([kana, roma]) => {\n // じゃ -> ja\n Object.entries(SMALL_Y).forEach(([yKana, yRoma]) => {\n setTrans(kana + yKana, roma + yRoma[1]);\n });\n // じぃ -> jyi, じぇ -> je\n setTrans(`${kana}ぃ`, `${roma}yi`);\n setTrans(`${kana}ぇ`, `${roma}e`);\n });\n\n romajiTree['っ'] = resolveTsu(romajiTree);\n\n Object.entries(SMALL_KANA).forEach(([kana, roma]) => {\n setTrans(kana, roma);\n });\n\n AMBIGUOUS_VOWELS.forEach((kana) => {\n setTrans(`ん${kana}`, `n'${subtreeOf(kana)['']}`);\n });\n\n // NOTE: could be re-enabled with an option?\n // // んば -> mbo\n // const LABIAL = [\n // 'ば', 'び', 'ぶ', 'べ', 'ぼ',\n // 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ',\n // 'ま', 'み', 'む', 'め', 'も',\n // ];\n // LABIAL.forEach((kana) => {\n // setTrans(`ん${kana}`, `m${subtreeOf(kana)['']}`);\n // });\n\n return Object.freeze(JSON.parse(JSON.stringify(romajiTree)));\n}\n\nfunction resolveTsu(tree) {\n return Object.entries(tree).reduce((tsuTree, [key, value]) => {\n if (!key) {\n // we have reached the bottom of this branch\n const consonant = value.charAt(0);\n tsuTree[key] = Object.keys(SOKUON_WHITELIST).includes(consonant)\n ? SOKUON_WHITELIST[consonant] + value\n : value;\n } else {\n // more subtrees\n tsuTree[key] = resolveTsu(value);\n }\n return tsuTree;\n }, {});\n}\n","import mergeWithDefaultOptions from './utils/mergeWithDefaultOptions';\nimport katakanaToHiragana from './utils/katakanaToHiragana';\nimport isKatakana from './isKatakana';\nimport { getKanaToRomajiTree } from './utils/kanaToRomajiMap';\nimport { applyMapping, mergeCustomMapping } from './utils/kanaMapping';\n\n/**\n * Convert kana to romaji\n * @param {String} kana text input\n * @param {DefaultOptions} [options=defaultOptions]\n * @return {String} converted text\n * @example\n * toRomaji('ひらがな カタカナ')\n * // => 'hiragana katakana'\n * toRomaji('げーむ ゲーム')\n * // => 'ge-mu geemu'\n * toRomaji('ひらがな カタカナ', { upcaseKatakana: true })\n * // => 'hiragana KATAKANA'\n * toRomaji('つじぎり', { customRomajiMapping: { じ: 'zi', つ: 'tu', り: 'li' } });\n * // => 'tuzigili'\n */\nexport function toRomaji(input = '', options = {}) {\n const mergedOptions = mergeWithDefaultOptions(options);\n // just throw away the substring index information and just concatenate all the kana\n return splitIntoRomaji(input, mergedOptions)\n .map((romajiToken) => {\n const [start, end, romaji] = romajiToken;\n const makeUpperCase = options.upcaseKatakana && isKatakana(input.slice(start, end));\n return makeUpperCase ? romaji.toUpperCase() : romaji;\n })\n .join('');\n}\n\nlet customMapping = null;\nfunction splitIntoRomaji(input, options) {\n let map = getKanaToRomajiTree(options);\n\n if (options.customRomajiMapping) {\n if (customMapping == null) {\n customMapping = mergeCustomMapping(map, options.customRomajiMapping);\n }\n map = customMapping;\n }\n\n return applyMapping(katakanaToHiragana(input, toRomaji, true), map, !options.IMEMode);\n}\n\nexport default toRomaji;\n","import isEmpty from './isEmpty';\nimport { EN_PUNCTUATION_RANGES } from '../constants';\nimport isCharInRange from './isCharInRange';\n\n/**\n * Tests a character. Returns true if the character is considered English punctuation.\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharEnglishPunctuation(char = '') {\n if (isEmpty(char)) return false;\n return EN_PUNCTUATION_RANGES.some(([start, end]) => isCharInRange(char, start, end));\n}\n\nexport default isCharEnglishPunctuation;\n","import isEmpty from './isEmpty';\nimport { JA_PUNCTUATION_RANGES } from '../constants';\nimport isCharInRange from './isCharInRange';\n\n/**\n * Tests a character. Returns true if the character is considered English punctuation.\n * @param {String} char character string to test\n * @return {Boolean}\n */\nfunction isCharJapanesePunctuation(char = '') {\n if (isEmpty(char)) return false;\n return JA_PUNCTUATION_RANGES.some(([start, end]) => isCharInRange(char, start, end));\n}\n\nexport default isCharJapanesePunctuation;\n","import isEmpty from './utils/isEmpty';\nimport isCharEnglishPunctuation from './utils/isCharEnglishPunctuation';\nimport isCharJapanesePunctuation from './utils/isCharJapanesePunctuation';\nimport isCharRomaji from './utils/isCharRomaji';\nimport isCharKanji from './utils/isCharKanji';\nimport isCharHiragana from './utils/isCharHiragana';\nimport isCharKatakana from './utils/isCharKatakana';\nimport isCharJapanese from './utils/isCharJapanese';\n\nconst isCharEnSpace = (x) => x === ' ';\nconst isCharJaSpace = (x) => x === ' ';\nconst isCharJaNum = (x) => /[0-9]/.test(x);\nconst isCharEnNum = (x) => /[0-9]/.test(x);\n\nexport const TOKEN_TYPES = {\n EN: 'en',\n JA: 'ja',\n EN_NUM: 'englishNumeral',\n JA_NUM: 'japaneseNumeral',\n EN_PUNC: 'englishPunctuation',\n JA_PUNC: 'japanesePunctuation',\n KANJI: 'kanji',\n HIRAGANA: 'hiragana',\n KATAKANA: 'katakana',\n SPACE: 'space',\n OTHER: 'other',\n};\n\n// prettier-ignore\nexport function getType(input, compact = false) {\n const {\n EN, JA, EN_NUM, JA_NUM, EN_PUNC, JA_PUNC, KANJI, HIRAGANA, KATAKANA, SPACE, OTHER,\n } = TOKEN_TYPES;\n\n if (compact) {\n switch (true) {\n case isCharJaNum(input): return OTHER;\n case isCharEnNum(input): return OTHER;\n case isCharEnSpace(input): return EN;\n case isCharEnglishPunctuation(input): return OTHER;\n case isCharJaSpace(input): return JA;\n case isCharJapanesePunctuation(input): return OTHER;\n case isCharJapanese(input): return JA;\n case isCharRomaji(input): return EN;\n default: return OTHER;\n }\n } else {\n switch (true) {\n case isCharJaSpace(input): return SPACE;\n case isCharEnSpace(input): return SPACE;\n case isCharJaNum(input): return JA_NUM;\n case isCharEnNum(input): return EN_NUM;\n case isCharEnglishPunctuation(input): return EN_PUNC;\n case isCharJapanesePunctuation(input): return JA_PUNC;\n case isCharKanji(input): return KANJI;\n case isCharHiragana(input): return HIRAGANA;\n case isCharKatakana(input): return KATAKANA;\n case isCharJapanese(input): return JA;\n case isCharRomaji(input): return EN;\n default: return OTHER;\n }\n }\n}\n\n/**\n * Splits input into array of strings separated by opinionated token types\n * `'en', 'ja', 'englishNumeral', 'japaneseNumeral','englishPunctuation', 'japanesePunctuation','kanji', 'hiragana', 'katakana', 'space', 'other'`.\n * If `{ compact: true }` then many same-language tokens are combined (spaces + text, kanji + kana, numeral + punctuation).\n * If `{ detailed: true }` then return array will contain `{ type, value }` instead of `'value'`\n * @param {String} input text\n * @param {Object} [options={ compact: false, detailed: false}] options to modify output style\n * @return {String|Object[]} text split into tokens containing values, or detailed object\n * @example\n * tokenize('ふふフフ')\n * // ['ふふ', 'フフ']\n *\n * tokenize('感じ')\n * // ['感', 'じ']\n *\n * tokenize('truly 私は悲しい')\n * // ['truly', ' ', '私', 'は', '悲', 'しい']\n *\n * tokenize('truly 私は悲しい', { compact: true })\n * // ['truly ', '私は悲しい']\n *\n * tokenize('5romaji here...!?漢字ひらがな4カタ カナ「SHIO」。!')\n * // [ '5', 'romaji', ' ', 'here', '...!?', '漢字', 'ひらがな', 'カタ', ' ', 'カナ', '4', '「', 'SHIO', '」。!']\n *\n * tokenize('5romaji here...!?漢字ひらがな4カタ カナ「SHIO」。!', { compact: true })\n * // [ '5', 'romaji here', '...!?', '漢字ひらがなカタ カナ', '4「', 'SHIO', '」。!']\n *\n * tokenize('5romaji here...!?漢字ひらがなカタ カナ4「SHIO」。! لنذهب', { detailed: true })\n * // [\n * { type: 'englishNumeral', value: '5' },\n * { type: 'en', value: 'romaji' },\n * { type: 'space', value: ' ' },\n * { type: 'en', value: 'here' },\n * { type: 'englishPunctuation', value: '...!?' },\n * { type: 'kanji', value: '漢字' },\n * { type: 'hiragana', value: 'ひらがな' },\n * { type: 'katakana', value: 'カタ' },\n * { type: 'space', value: ' ' },\n * { type: 'katakana', value: 'カナ' },\n * { type: 'japaneseNumeral', value: '4' },\n * { type: 'japanesePunctuation', value: '「' },\n * { type: 'ja', value: 'SHIO' },\n * { type: 'japanesePunctuation', value: '」。!' },\n * { type: 'space', value: ' ' },\n * { type: 'other', value: 'لنذهب' },\n * ]\n *\n * tokenize('5romaji here...!?漢字ひらがなカタ カナ4「SHIO」。! لنذهب', { compact: true, detailed: true})\n * // [\n * { type: 'other', value: '5' },\n * { type: 'en', value: 'romaji here' },\n * { type: 'other', value: '...!?' },\n * { type: 'ja', value: '漢字ひらがなカタ カナ' },\n * { type: 'other', value: '4「' },\n * { type: 'ja', value: 'SHIO' },\n * { type: 'other', value: '」。!' },\n * { type: 'en', value: ' ' },\n * { type: 'other', value: 'لنذهب' },\n *]\n */\nfunction tokenize(input, { compact = false, detailed = false } = {}) {\n if (input == null || isEmpty(input)) {\n return [];\n }\n const chars = [...input];\n let initial = chars.shift();\n let prevType = getType(initial, compact);\n initial = detailed ? { type: prevType, value: initial } : initial;\n\n const result = chars.reduce(\n (tokens, char) => {\n const currType = getType(char, compact);\n const sameType = currType === prevType;\n prevType = currType;\n let newValue = char;\n\n if (sameType) {\n newValue = (detailed ? tokens.pop().value : tokens.pop()) + newValue;\n }\n\n return detailed\n ? tokens.concat({ type: currType, value: newValue })\n : tokens.concat(newValue);\n },\n [initial]\n );\n return result;\n}\n\nexport default tokenize;\n","import isJapanese from './isJapanese';\nimport isKana from './isKana';\nimport isKanji from './isKanji';\nimport tokenize from './tokenize';\n\nconst isLeadingWithoutInitialKana = (input, leading) => leading && !isKana(input[0]);\nconst isTrailingWithoutFinalKana = (input, leading) => !leading && !isKana(input[input.length - 1]);\nconst isInvalidMatcher = (input, matchKanji) =>\n (matchKanji && ![...matchKanji].some(isKanji)) || (!matchKanji && isKana(input));\n\n/**\n * Strips [Okurigana](https://en.wikipedia.org/wiki/Okurigana)\n * @param {String} input text\n * @param {Object} [options={ leading: false, matchKanji: '' }] optional config\n * @return {String} text with okurigana removed\n * @example\n * stripOkurigana('踏み込む')\n * // => '踏み込'\n * stripOkurigana('お祝い')\n * // => 'お祝'\n * stripOkurigana('お腹', { leading: true });\n * // => '腹'\n * stripOkurigana('ふみこむ', { matchKanji: '踏み込む' });\n * // => 'ふみこ'\n * stripOkurigana('おみまい', { matchKanji: 'お祝い', leading: true });\n * // => 'みまい'\n */\nfunction stripOkurigana(input = '', { leading = false, matchKanji = '' } = {}) {\n if (\n !isJapanese(input) ||\n isLeadingWithoutInitialKana(input, leading) ||\n isTrailingWithoutFinalKana(input, leading) ||\n isInvalidMatcher(input, matchKanji)\n ) {\n return input;\n }\n\n const chars = matchKanji || input;\n const okuriganaRegex = new RegExp(\n leading ? `^${tokenize(chars).shift()}` : `${tokenize(chars).pop()}$`\n );\n return input.replace(okuriganaRegex, '');\n}\n\nexport default stripOkurigana;\n","import { findListeners, untrackListeners } from './utils/dom';\nimport { removeDebugListeners } from './utils/logInputEvents';\n\n/**\n * Unbinds eventListener from input field\n * @param {HTMLElement} element textarea, input\n */\nexport function unbind(element, debug = false) {\n const listeners = findListeners(element);\n if (listeners == null) {\n throw new Error(\n `Element provided to Wanakana unbind() had no listener registered.\\n Received: ${JSON.stringify(\n element\n )}`\n );\n }\n const { inputHandler, compositionHandler } = listeners;\n element.removeAttribute('data-wanakana-id');\n element.removeAttribute('data-ignore-composition');\n element.removeEventListener('input', inputHandler);\n element.removeEventListener('compositionstart', compositionHandler);\n element.removeEventListener('compositionupdate', compositionHandler);\n element.removeEventListener('compositionend', compositionHandler);\n untrackListeners(listeners);\n if (debug === true) {\n removeDebugListeners(element);\n }\n}\n\nexport default unbind;\n","import mergeWithDefaultOptions from './utils/mergeWithDefaultOptions';\nimport katakanaToHiragana from './utils/katakanaToHiragana';\nimport isCharEnglishPunctuation from './utils/isCharEnglishPunctuation';\nimport isRomaji from './isRomaji';\nimport isMixed from './isMixed';\nimport toKana from './toKana';\nimport toRomaji from './toRomaji';\n\n/**\n * Convert input to [Hiragana](https://en.wikipedia.org/wiki/Hiragana)\n * @param {String} [input=''] text\n * @param {DefaultOptions} [options=defaultOptions]\n * @return {String} converted text\n * @example\n * toHiragana('toukyou, オオサカ')\n * // => 'とうきょう、 おおさか'\n * toHiragana('only カナ', { passRomaji: true })\n * // => 'only かな'\n * toHiragana('wi')\n * // => 'うぃ'\n * toHiragana('wi', { useObsoleteKana: true })\n * // => 'ゐ'\n */\nfunction toHiragana(input = '', options = {}) {\n const config = mergeWithDefaultOptions(options);\n if (config.passRomaji) {\n return katakanaToHiragana(input, toRomaji);\n }\n\n if (isMixed(input, { passKanji: true })) {\n const convertedKatakana = katakanaToHiragana(input, toRomaji);\n return toKana(convertedKatakana.toLowerCase(), config);\n }\n\n if (isRomaji(input) || isCharEnglishPunctuation(input)) {\n return toKana(input.toLowerCase(), config);\n }\n\n return katakanaToHiragana(input, toRomaji);\n}\n\nexport default toHiragana;\n","import mergeWithDefaultOptions from './utils/mergeWithDefaultOptions';\nimport hiraganaToKatakana from './utils/hiraganaToKatakana';\nimport isCharEnglishPunctuation from './utils/isCharEnglishPunctuation';\nimport toKana from './toKana';\nimport isRomaji from './isRomaji';\nimport isMixed from './isMixed';\n\n/**\n * Convert input to [Katakana](https://en.wikipedia.org/wiki/Katakana)\n * @param {String} [input=''] text\n * @param {DefaultOptions} [options=defaultOptions]\n * @return {String} converted text\n * @example\n * toKatakana('toukyou, おおさか')\n * // => 'トウキョウ、 オオサカ'\n * toKatakana('only かな', { passRomaji: true })\n * // => 'only カナ'\n * toKatakana('wi')\n * // => 'ウィ'\n * toKatakana('wi', { useObsoleteKana: true })\n * // => 'ヰ'\n */\nfunction toKatakana(input = '', options = {}) {\n const mergedOptions = mergeWithDefaultOptions(options);\n if (mergedOptions.passRomaji) {\n return hiraganaToKatakana(input);\n }\n\n if (isMixed(input) || isRomaji(input) || isCharEnglishPunctuation(input)) {\n const hiragana = toKana(input.toLowerCase(), mergedOptions);\n return hiraganaToKatakana(hiragana);\n }\n\n return hiraganaToKatakana(input);\n}\n\nexport default toKatakana;\n"],"names":["global","module","window","Math","self","Function","__g","core","version","__e","it","isObject","TypeError","exec","e","require$$0","Object","defineProperty","get","a","document","is","createElement","require$$1","require$$2","S","fn","val","toString","call","valueOf","dP","O","P","Attributes","anObject","toPrimitive","IE8_DOM_DEFINE","value","bitmap","enumerable","configurable","writable","object","key","f","createDesc","hasOwnProperty","id","px","random","concat","undefined","SRC","$toString","TPL","split","inspectSource","safe","isFunction","has","hide","join","String","prototype","this","that","length","aFunction","b","c","apply","arguments","$export","type","name","source","own","out","exp","IS_FORCED","F","IS_GLOBAL","G","IS_PROTO","IS_BIND","B","target","exports","expProto","ctx","redefine","U","W","R","Typed","TYPED","uid","VIEW","ABV","ArrayBuffer","DataView","CONSTR","i","TypedArrayConstructors","src","Constructor","forbiddenField","ceil","floor","isNaN","min","toInteger","number","toLength","RangeError","slice","propertyIsEnumerable","cof","IObject","defined","max","index","IS_INCLUDES","$this","el","fromIndex","toIObject","toAbsoluteIndex","store","shared","arrayIndexOf","IE_PROTO","names","result","push","hiddenKeys","getOwnPropertyNames","$keys","toObject","aLen","end","endPos","Symbol","USE_SYMBOL","def","TAG","tag","stat","gOPN","PROTOTYPE","WRONG_INDEX","$ArrayBuffer","$DataView","Infinity","BaseBuffer","abs","pow","log","LN2","$BUFFER","DESCRIPTORS","$LENGTH","$OFFSET","packIEEE754","mLen","nBytes","m","buffer","Array","eLen","eMax","eBias","rt","s","unpackIEEE754","nBits","NaN","unpackI32","bytes","packI8","packI16","packI32","packF64","packF32","addGetter","C","internal","view","isLittleEndian","intIndex","toIndex","start","pack","_b","reverse","set","conversion","$typed","fails","ArrayBufferProto","anInstance","keys","j","LIBRARY","constructor","$setInt8","setInt8","getInt8","redefineAll","byteOffset","setUint8","byteLength","arrayFill","bufferLength","offset","getUint8","getInt16","getUint16","getInt32","getUint32","getFloat32","getFloat64","setInt16","setUint16","setInt32","setUint32","setFloat32","setFloat64","setToStringTag","SPECIES","D","KEY","$isView","isView","$slice","len","first","final","speciesConstructor","viewS","viewT","ARG","T","tryGet","callee","ITERATOR","ArrayProto","Iterators","enumBugKeys","defineProperties","Properties","getKeys","documentElement","Empty","createDict","iframeDocument","iframe","style","display","appendChild","contentWindow","open","write","lt","close","create","dPs","ObjectProto","getPrototypeOf","getIteratorMethod","classof","isArray","arg","original","TYPE","$create","IS_MAP","IS_FILTER","IS_SOME","IS_EVERY","IS_FIND_INDEX","NO_HOLES","asc","callbackfn","res","UNSCOPABLES","done","IteratorPrototype","NAME","next","descriptor","BUGGY","returnThis","Base","DEFAULT","IS_SET","FORCED","$iterCreate","methods","getMethod","kind","proto","DEF_VALUES","VALUES_BUG","$native","$default","$entries","$anyNative","entries","values","iterated","_t","_i","_k","step","Arguments","SAFE_CLOSING","skipClosing","arr","iter","copyWithin","to","from","count","inc","gOPD","getOwnPropertyDescriptor","pIE","require$$3","require$$4","require$$5","require$$7","require$$8","propertyDesc","require$$9","require$$10","require$$11","require$$12","require$$13","require$$14","require$$15","require$$16","require$$17","require$$18","require$$19","require$$20","isArrayIter","require$$21","require$$22","require$$23","require$$24","getIterFn","require$$25","require$$26","wks","require$$27","createArrayMethod","require$$28","createArrayIncludes","require$$29","require$$30","ArrayIterators","require$$31","require$$32","$iterDetect","require$$33","setSpecies","require$$34","require$$35","arrayCopyWithin","require$$36","$DP","require$$37","$GOPD","require$$38","Uint8Array","require$$6","arrayForEach","arrayFilter","arraySome","arrayEvery","arrayFind","arrayFindIndex","arrayIncludes","arrayValues","arrayKeys","arrayEntries","arrayLastIndexOf","lastIndexOf","arrayReduce","reduce","arrayReduceRight","reduceRight","arrayJoin","arraySort","sort","arraySlice","arrayToString","arrayToLocaleString","toLocaleString","TYPED_CONSTRUCTOR","DEF_CONSTRUCTOR","ALL_CONSTRUCTORS","TYPED_ARRAY","$map","allocate","LITTLE_ENDIAN","Uint16Array","FORCED_SET","toOffset","BYTES","validate","speciesFromList","list","fromList","_d","$from","iterator","mapfn","mapping","iterFn","$of","TO_LOCALE_BUG","$toLocaleString","every","fill","filter","find","predicate","findIndex","forEach","indexOf","searchElement","includes","separator","map","middle","some","comparefn","subarray","begin","$begin","BYTES_PER_ELEMENT","$set","arrayLike","$iterators","isTAIndex","$getDesc","$setDesc","desc","$TypedArrayPrototype$","wrapper","CLAMPED","GETTER","SETTER","TypedArray","TAC","TypedArrayPrototype","addElement","data","v","o","getter","round","setter","$offset","$length","klass","$len","l","$nativeIterator","CORRECT_ITER_NAME","$iterator","of","init","ret","BREAK","RETURN","iterable","META","setDesc","isExtensible","FREEZE","preventExtensions","setMeta","w","meta","NEED","fastKey","getWeak","onFreeze","SIZE","getEntry","entry","_f","n","k","getConstructor","ADDER","_l","forOf","clear","r","p","delete","prev","setStrong","$iterDefine","check","setPrototypeOf","test","buggy","__proto__","common","IS_WEAK","fixMethod","instance","HASNT_CHAINING","THROWS_ON_PRIMITIVES","ACCEPT_ITERABLES","BUGGY_ZERO","$instance","inheritIfRequired","strong","add","getOwnPropertySymbols","$assign","assign","A","K","getSymbols","gOPS","isEnum","uncaughtFrozenStore","UncaughtFrozenStore","findUncaughtFrozen","splice","$has","ufstore","InternalMap","each","weak","tmp","$WeakMap","freeze","method","rApply","Reflect","fApply","thisArgument","argumentsList","L","args","un","factories","bind","partArgs","bound","construct","invoke","rConstruct","NEW_TARGET_BUG","ARGS_BUG","Target","newTarget","$args","propertyKey","attributes","deleteProperty","receiver","getProto","$isExtensible","ownKeys","$preventExtensions","V","existingDescriptor","ownDesc","setProto","defer","channel","port","process","setTask","setImmediate","clearTask","clearImmediate","MessageChannel","Dispatch","counter","queue","run","listener","event","nextTick","now","port2","port1","onmessage","postMessage","addEventListener","importScripts","cel","html","removeChild","setTimeout","macrotask","Observer","MutationObserver","WebKitMutationObserver","Promise","isNode","head","last","notify","flush","parent","domain","exit","enter","navigator","standalone","resolve","promise","then","toggle","node","createTextNode","observe","characterData","task","Internal","newGenericPromiseCapability","OwnPromiseCapability","Wrapper","reject","$$resolve","$$reject","x","promiseCapability","newPromiseCapability","microtask","$Promise","empty","newPromiseCapabilityModule","USE_NATIVE","FakePromise","PromiseRejectionEvent","isThenable","isReject","_n","chain","_c","_v","ok","_s","reaction","exited","handler","fail","_h","onHandleUnhandled","onUnhandled","console","unhandled","isUnhandled","perform","emit","onunhandledrejection","reason","error","_a","onrejectionhandled","$reject","_w","$resolve","executor","err","onFulfilled","onRejected","catch","capability","promiseResolve","all","remaining","$index","alreadyCalled","race","$Symbol","charAt","wksExt","symbols","windowNames","getWindowNames","gOPNExt","$JSON","JSON","_stringify","stringify","HIDDEN","TO_PRIMITIVE","SymbolRegistry","AllSymbols","OPSymbols","QObject","findChild","setSymbolDesc","$fails","_create","protoDesc","wrap","sym","isSymbol","$defineProperty","$defineProperties","enumKeys","$propertyIsEnumerable","E","$getOwnPropertyDescriptor","$getOwnPropertyNames","$getOwnPropertySymbols","IS_OP","es6Symbols","wellKnownSymbols","wksDefine","for","keyFor","useSetter","useSimple","replacer","$replacer","$freeze","$seal","$isFrozen","$isSealed","$getPrototypeOf","y","FProto","nameRE","match","raw","callSite","tpl","fromCharCode","$fromCodePoint","fromCodePoint","code","TO_STRING","pos","charCodeAt","$at","codePointAt","str","repeat","MATCH","isRegExp","searchString","re","$startsWith","startsWith","context","search","$endsWith","endsWith","endPosition","ignoreCase","multiline","unicode","sticky","flags","RegExp","SYMBOL","fns","strfn","rxfn","string","$match","regexp","REPLACE","$replace","searchValue","replaceValue","SPLIT","$split","_split","$push","NPCG","limit","separator2","lastIndex","lastLength","output","lastLastIndex","splitLimit","separatorCopy","replace","SEARCH","$search","createProperty","$find","forced","_isFinite","isFinite","isInteger","isSafeInteger","EPSILON","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","log1p","sqrt","$acosh","acosh","Number","MAX_VALUE","$asinh","asinh","$atanh","atanh","sign","cbrt","clz32","LOG2E","cosh","$expm1","expm1","EPSILON32","MAX32","MIN32","fround","$abs","$sign","hypot","value1","value2","div","sum","larg","$imul","imul","xn","yn","xl","yl","log10","LOG10E","log2","sinh","tanh","trunc","$includes","isEntries","$values","getOwnPropertyDescriptors","getDesc","maxLength","fillString","left","stringLength","fillStr","intMaxLength","fillLen","stringFiller","userAgent","padStart","$pad","padEnd","time","boundArgs","setInterval","$task","TO_STRING_TAG","ArrayValues","DOMIterables","CSSRuleList","CSSStyleDeclaration","CSSValueList","ClientRectList","DOMRectList","DOMStringList","DOMTokenList","DataTransferItemList","FileList","HTMLAllCollection","HTMLCollection","HTMLFormElement","HTMLSelectElement","MediaList","MimeTypeArray","NamedNodeMap","NodeList","PaintRequestList","Plugin","PluginArray","SVGLengthList","SVGNumberList","SVGPathSegList","SVGPointList","SVGStringList","SVGTransformList","SourceBufferList","StyleSheetList","TextTrackCueList","TextTrackList","TouchList","collections","explicit","Collection","Op","hasOwn","iteratorSymbol","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","runtime","regeneratorRuntime","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","NativeIteratorPrototype","Gp","GeneratorFunctionPrototype","Generator","GeneratorFunction","displayName","isGeneratorFunction","genFun","ctor","mark","awrap","__await","defineIteratorMethods","AsyncIterator","async","innerFn","outerFn","tryLocsList","pop","Context","reset","skipTempReset","sent","_sent","delegate","tryEntries","resetTryEntry","stop","rootRecord","completion","rval","dispatchException","exception","handle","loc","caught","record","tryLoc","hasCatch","hasFinally","catchLoc","finallyLoc","Error","abrupt","finallyEntry","complete","afterLoc","finish","thrown","delegateYield","resultName","nextLoc","generator","_invoke","state","doneResult","delegateResult","maybeInvokeDelegate","tryCatch","makeInvokeMethod","obj","unwrapped","previousPromise","callInvokeWithMethodAndArg","return","info","pushTryEntry","locs","iteratorMethod","typeOf","toLowerCase","isEmpty","input","isCharInRange","char","TO_KANA_METHODS","ROMANIZATIONS","DEFAULT_OPTIONS","HEPBURN","LATIN_UPPERCASE_START","LATIN_UPPERCASE_END","HIRAGANA_START","HIRAGANA_END","KATAKANA_START","KATAKANA_END","KANJI_START","KANJI_END","PROLONGED_SOUND_MARK","KANA_SLASH_DOT","KANA_PUNCTUATION","JA_PUNCTUATION_RANGES","JAPANESE_RANGES","ROMAJI_RANGES","EN_PUNCTUATION_RANGES","isCharJapanese","isJapanese","allowed","augmented","isJa","mergeWithDefaultOptions","applyMapping","convertEnding","root","newChunk","currentCursor","firstChar","parse","tree","lastCursor","subtree","nextChar","nextSubtree","transform","endOfBranch","getSubTreeOf","correctSubTree","createCustomMapping","customMap","customTree","kana","subTree","transformMap","mapSubtree","customSubtree","newSubtree","mergeCustomMapping","customMapping","BASIC_KUNREI","u","SPECIAL_SYMBOLS","CONSONANTS","SMALL_Y","ya","yi","yu","ye","yo","SMALL_VOWELS","ALIASES","SMALL_LETTERS","SPECIAL_CASES","AIUEO_CONSTRUCTIONS","createRomajiToKanaMap","kanaTree","subtreeOf","consonant","yKana","jsymbol","aiueoKana","nChar","alternative","allExceptLast","kunreiRoma","chars","xSubtree","alt","roma","altRoma","prefix","addTsu","tsuTree","romajiToKanaMap","USE_OBSOLETE_KANA_MAP","wi","we","isCharUpperCase","isCharLongDash","isCharSlashDot","isCharHiragana","hiraganaToKatakana","kata","toKana","options","config","IMEMode","splitIntoConvertedKana","kanaToken","enforceHiragana","HIRAGANA","enforceKatakana","KATAKANA","mapCopy","IME_MODE_MAP","useObsoleteKana","customKanaMapping","LISTENERS","makeOnInput","mergedConfig","preConfiguredMap","triggers","toUpperCase","dataset","ignoreComposition","prevInput","text","cursor","toConvert","tail","catalystChars","takeWhileAndSlice","workFromStart","startIndex","workBackwards","splitInput","selectionEnd","textToConvert","convertedText","newCursor","newValue","setSelectionRange","onComposition","platform","events","selectionStart","addDebugListeners","removeDebugListeners","removeEventListener","ELEMENTS","idCounter","newId","Date","isCharRomaji","isRomaji","isRoma","isCharKatakana","isCharKana","isKana","isHiragana","isKatakana","isCharKanji","isKanji","isMixed","passKanji","hasKanji","isCharInitialLongDash","isCharInnerLongDash","isKanaAsSymbol","LONG_VOWELS","katakanaToHiragana","toRomaji","isDestinationRomaji","previousKana","hira","romaji","hiraChar","kanaToHepburnMap","BASIC_ROMAJI","い","う","え","お","き","く","け","こ","し","す","せ","そ","ち","つ","て","と","に","ぬ","ね","の","ひ","ふ","へ","ほ","み","む","め","も","り","る","れ","ろ","ゆ","よ","ゐ","ゑ","を","ぎ","ぐ","げ","ご","じ","ず","ぜ","ぞ","ぢ","づ","で","ど","び","ぶ","べ","ぼ","ぴ","ぷ","ぺ","ぽ","ゔぃ","ゔ","ゔぇ","ゔぉ","AMBIGUOUS_VOWELS","ゃ","ゅ","ょ","SMALL_Y_EXTRA","ぃ","ぇ","SMALL_AIUEO","YOON_KANA","YOON_EXCEPTIONS","SMALL_KANA","SOKUON_WHITELIST","getKanaToHepburnTree","romajiTree","setTrans","transliteration","symbol","firstRomajiChar","resolveTsu","mergedOptions","fullOptions","romanization","getKanaToRomajiTree","customRomajiMapping","splitIntoRomaji","romajiToken","upcaseKatakana","isCharEnglishPunctuation","isCharJapanesePunctuation","isCharEnSpace","isCharJaSpace","isCharJaNum","isCharEnNum","TOKEN_TYPES","getType","EN","JA","EN_NUM","JA_NUM","EN_PUNC","JA_PUNC","KANJI","SPACE","OTHER","tokenize","compact","detailed","initial","shift","prevType","tokens","currType","sameType","isLeadingWithoutInitialKana","leading","isTrailingWithoutFinalKana","isInvalidMatcher","matchKanji","element","debug","nodeName","onInput","setAttribute","inputHandler","compositionHandler","listeners","getAttribute","targetId","removeAttribute","passRomaji","okuriganaRegex"],"mappings":"uXACA,IAAIA,EAASC,UAAkC,oBAAVC,QAAyB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000 --- a/tmpl/dictionary.html +++ /dev/null @@ -1,17 +0,0 @@ -<div class="dict-group well well-sm" data-title="{{title}}"> - <h4><span class="text-muted glyphicon glyphicon-book"></span> {{title}} <small>rev.{{revision}}</small></h4> - {{#if outdated}} - <p class="text-warning">This dictionary is outdated and may not support new extension features; please import the latest version.</p> - {{/if}} - - <div class="checkbox"> - <label><input type="checkbox" class="dict-enabled" {{#if enabled}}checked{{/if}}> Enable search</label> - </div> - <div class="checkbox options-advanced"> - <label><input type="checkbox" class="dict-allow-secondary-searches" {{#if allowSecondarySearches}}checked{{/if}}> Allow secondary searches</label> - </div> - <div class="form-group options-advanced"> - <label for="dict-{{title}}">Result priority</label> - <input type="number" value="{{priority}}" id="dict-{{title}}" class="form-control dict-priority"> - </div> -</div> diff --git a/tmpl/kanji.html b/tmpl/kanji.html index 0888d141..bbc0fc9d 100644 --- a/tmpl/kanji.html +++ b/tmpl/kanji.html @@ -20,13 +20,10 @@ No data found <a href="#" class="action-view-note pending disabled"><img src="/mixed/img/view-note.svg" title="View added note (Alt + V)" alt></a> <a href="#" class="action-add-note pending disabled" data-mode="kanji"><img src="/mixed/img/add-term-kanji.svg" title="Add Kanji (Alt + K)" alt></a> {{/if}} - {{#if source}} - <a href="#" class="source-term"><img src="/mixed/img/source-term.svg" title="Source term (Alt + B)" alt></a> - {{/if}} <img src="/mixed/img/entry-current.svg" class="current" title="Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)" alt> </div> - <div class="glyph">{{character}}</div> + <div class="glyph expression-scan-toggle">{{character}}</div> {{#if frequencies}} <div> @@ -91,9 +88,13 @@ No data found {{/inline}} {{#if definitions}} +<div class="term-navigation"> + <a href="#" {{#if source}}class="source-term"{{else}}class="source-term term-button-fade"{{/if}}><img src="/mixed/img/source-term.svg" title="Source term (Alt + B)" alt></a> + <a href="#" {{#if next}}class="next-term"{{else}}class="next-term term-button-fade"{{/if}}><img src="/mixed/img/source-term.svg" style="transform: scaleX(-1);" title="Next term (Alt + F)" alt></a> +</div> {{#each definitions}} {{#unless @first}}<hr>{{/unless}} -{{> kanji debug=../debug addable=../addable source=../source root=../root}} +{{> kanji debug=../debug addable=../addable root=../root}} {{/each}} {{else}} <p class="note">No results found</p> diff --git a/tmpl/model.html b/tmpl/model.html deleted file mode 100644 index 94772316..00000000 --- a/tmpl/model.html +++ /dev/null @@ -1,18 +0,0 @@ -<tr> - <td class="col-sm-2">{{name}}</td> - <td class="col-sm-10"> - <div class="input-group"> - <input type="text" class="anki-field-value form-control" data-field="{{name}}" value="{{value}}"> - <div class="input-group-btn"> - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> - <span class="caret"></span> - </button> - <ul class="dropdown-menu dropdown-menu-right"> - {{#each markers}} - <li><a class="marker-link" href="#">{{.}}</a></li> - {{/each}} - </ul> - </div> - </div> - </td> -</tr> diff --git a/tmpl/query-parser.html b/tmpl/query-parser.html new file mode 100644 index 00000000..db98b5ff --- /dev/null +++ b/tmpl/query-parser.html @@ -0,0 +1,27 @@ +{{~#*inline "term"~}} +{{~#if preview~}} +<span class="query-parser-term-preview"> +{{~else~}} +<span class="query-parser-term"> +{{~/if~}} +{{~#each this~}} +{{> part }} +{{~/each~}} +</span> +{{~/inline~}} + +{{~#*inline "part"~}} +{{~#if raw~}} +{{~#each text~}} +<span class="query-parser-char">{{this}}</span> +{{~/each~}} +{{~else~}} +<ruby>{{~#each text~}} +<span class="query-parser-char">{{this}}</span> +{{~/each~}}<rt>{{reading}}</rt></ruby> +{{~/if~}} +{{~/inline~}} + +{{~#each terms~}} +{{> term preview=../preview }} +{{~/each~}} diff --git a/tmpl/terms.html b/tmpl/terms.html index 3dee43d7..9cfabc58 100644 --- a/tmpl/terms.html +++ b/tmpl/terms.html @@ -41,15 +41,12 @@ <a href="#" class="action-play-audio"><img src="/mixed/img/play-audio.svg" title="Play audio (Alt + P)" alt></a> {{/if}} {{/unless}} - {{#if source}} - <a href="#" class="source-term"><img src="/mixed/img/source-term.svg" title="Source term (Alt + B)" alt></a> - {{/if}} <img src="/mixed/img/entry-current.svg" class="current" title="Current entry (Alt + Up/Down/Home/End/PgUp/PgDn)" alt> </div> {{#if merged}} {{~#each expressions~}} - <div class="expression"><span class="expression-{{termFrequency}}">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</span><div class="peek-wrapper"> + <div class="expression expression-scan-toggle"><span class="expression-{{termFrequency}}">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</span><div class="peek-wrapper"> {{~#if ../playback~}} <a href="#" class="action-play-audio"><img src="/mixed/img/play-audio.svg" title="Play audio" alt></a> {{~/if~}} @@ -70,7 +67,7 @@ </div><span class="{{#if @last}}invisible{{/if}}">、</span></div> {{~/each~}} {{else}} - <div class="expression">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</div> + <div class="expression expression-scan-toggle">{{#kanjiLinks}}{{#furigana}}{{{.}}}{{/furigana}}{{/kanjiLinks}}</div> {{#if termTags}} <div style="display: inline-block;"> {{#each termTags}} @@ -129,9 +126,13 @@ {{/inline}} {{#if definitions}} +<div class="term-navigation"> + <a href="#" {{#if source}}class="source-term"{{else}}class="source-term term-button-fade"{{/if}}><img src="/mixed/img/source-term.svg" title="Source term (Alt + B)" alt></a> + <a href="#" {{#if next}}class="next-term"{{else}}class="next-term term-button-fade"{{/if}}><img src="/mixed/img/source-term.svg" style="transform: scaleX(-1);" title="Next term (Alt + F)" alt></a> +</div> {{#each definitions}} {{#unless @first}}<hr>{{/unless}} -{{> term debug=../debug grouped=../grouped merged=../merged addable=../addable playback=../playback compactGlossaries=../compactGlossaries source=../source}} +{{> term debug=../debug grouped=../grouped merged=../merged addable=../addable playback=../playback compactGlossaries=../compactGlossaries}} {{/each}} {{else}} <p class="note">No results found.</p> |