UNPKG

rehype-citation

Version:

rehype plugin to add citation and bibliography from bibtex files

1 lines 993 kB
{"version":3,"file":"cite.mjs","sources":["../../src/citation-js/core/Cite/log.js","../../src/citation-js/core/Cite/validate.js","../../src/citation-js/core/Cite/options.js","../../src/citation-js/core/plugins/input/dataType.js","../../src/citation-js/core/plugins/input/graph.js","../../src/citation-js/core/logger.js","../../src/citation-js/core/plugins/input/type.js","../../src/citation-js/core/plugins/input/parser.js","../../src/citation-js/core/plugins/input/csl.js","../../src/citation-js/core/util/csl.js","../../src/citation-js/core/util/deepCopy.js","../../node_modules/webidl-conversions/lib/index.js","../../node_modules/whatwg-url/lib/utils.js","../../node_modules/tr46/index.js","../../node_modules/whatwg-url/lib/url-state-machine.js","../../node_modules/whatwg-url/lib/URL-impl.js","../../node_modules/whatwg-url/lib/URL.js","../../node_modules/whatwg-url/lib/public-api.js","../../node_modules/node-fetch/lib/index.mjs","../../node_modules/sync-fetch/shared.js","../../node_modules/sync-fetch/index.js","../../node_modules/fetch-ponyfill/node_modules/node-fetch/lib/index.mjs","../../node_modules/fetch-ponyfill/fetch-node.js","../../src/citation-js/core/util/fetchFile.js","../../src/citation-js/core/util/fetchId.js","../../src/citation-js/core/util/register.js","../../src/citation-js/core/util/grammar.js","../../src/citation-js/core/util/translator.js","../../src/citation-js/core/plugins/input/chain.js","../../src/citation-js/core/plugins/input/data.js","../../src/citation-js/core/plugins/input/register.js","../../src/citation-js/core/plugins/input/index.js","../../src/citation-js/core/Cite/set.js","../../src/citation-js/core/plugin-common/output/label.js","../../src/citation-js/core/Cite/sort.js","../../src/citation-js/core/plugins/output.js","../../src/citation-js/core/Cite/get.js","../../src/citation-js/core/Cite/async.js","../../src/citation-js/core/Cite/index.js","../../src/citation-js/core/plugins/dict.js","../../src/citation-js/core/plugins/config.js","../../src/citation-js/core/plugins/index.js","../../src/citation-js/core/plugin-common/input/empty.js","../../src/citation-js/core/plugin-common/input/json.js","../../src/citation-js/core/plugin-common/input/jquery.js","../../src/citation-js/core/plugin-common/input/html.js","../../src/citation-js/core/plugin-common/input/index.js","../../src/citation-js/core/plugin-common/output/json.js","../../src/citation-js/core/plugin-common/output/index.js","../../src/citation-js/core/plugin-common/index.js","../../src/citation-js/plugin-bibjson/json.js","../../src/citation-js/plugin-bibjson/index.js","../../node_modules/moo/moo.js","../../src/citation-js/plugin-bibtex/mapping/biblatexTypes.js","../../src/citation-js/plugin-bibtex/mapping/bibtexTypes.js","../../src/citation-js/plugin-bibtex/input/required.js","../../src/citation-js/plugin-bibtex/input/fieldTypes.js","../../src/citation-js/plugin-bibtex/input/unicode.js","../../src/citation-js/plugin-bibtex/input/constants.js","../../src/citation-js/plugin-bibtex/config.js","../../src/citation-js/plugin-bibtex/input/file.js","../../src/citation-js/plugin-bibtex/input/bibtxt.js","../../src/citation-js/plugin-bibtex/mapping/shared.js","../../src/citation-js/plugin-bibtex/mapping/biblatex.js","../../src/citation-js/plugin-bibtex/mapping/bibtex.js","../../src/citation-js/plugin-bibtex/mapping/crossref.js","../../src/citation-js/plugin-bibtex/mapping/index.js","../../src/citation-js/plugin-bibtex/input/name.js","../../src/citation-js/plugin-bibtex/input/value.js","../../src/citation-js/plugin-bibtex/input/entries.js","../../src/citation-js/plugin-bibtex/input/index.js","../../src/citation-js/plugin-bibtex/output/value.js","../../src/citation-js/plugin-bibtex/output/entries.js","../../src/citation-js/plugin-bibtex/output/bibtex.js","../../src/citation-js/plugin-bibtex/output/bibtxt.js","../../src/citation-js/plugin-bibtex/output/index.js","../../src/citation-js/plugin-bibtex/index.js","../../src/citation-js/plugin-csl/locales.js","../../src/citation-js/plugin-csl/styles.js","../../src/citation-js/plugin-csl/engines.js","../../src/citation-js/plugin-csl/attr.js","../../src/citation-js/plugin-csl/bibliography.js","../../src/citation-js/plugin-csl/citation.js","../../src/citation-js/plugin-csl/index.js","../../src/citation-js/plugin-yaml/index.js","../../src/citation-js/plugin-cff/index.js","../../src/cite.js"],"sourcesContent":["function currentVersion() {\n return this.log.length\n}\nfunction retrieveVersion(versnum = 1) {\n if (versnum <= 0 || versnum > this.currentVersion()) {\n return null\n } else {\n const [data, options] = this.log[versnum - 1]\n const image = new this.constructor(JSON.parse(data), JSON.parse(options))\n image.log = this.log.slice(0, versnum)\n return image\n }\n}\nfunction undo(number = 1) {\n return this.retrieveVersion(this.currentVersion() - number)\n}\nfunction retrieveLastVersion() {\n return this.retrieveVersion(this.currentVersion())\n}\nfunction save() {\n this.log.push([JSON.stringify(this.data), JSON.stringify(this._options)])\n return this\n}\nexport { currentVersion, retrieveVersion, retrieveLastVersion, undo, save }\n","const formats = ['real', 'string']\nconst types = ['json', 'html', 'string', 'rtf']\nconst styles = ['csl', 'bibtex', 'bibtxt', 'citation-*', 'ris', 'ndjson']\nconst wrapperTypes = ['string', 'function']\nexport function validateOutputOptions(options) {\n if (typeof options !== 'object') {\n throw new TypeError('Options not an object!')\n }\n const { format, type, style, lang, append, prepend } = options\n if (format && !formats.includes(format)) {\n throw new TypeError(`Option format (\"${format}\") should be one of: ${formats}`)\n } else if (type && !types.includes(type)) {\n throw new TypeError(`Option type (\"${type}\") should be one of: ${types}`)\n } else if (style && !styles.includes(style) && !/^citation/.test(style)) {\n throw new TypeError(`Option style (\"${style}\") should be one of: ${styles}`)\n } else if (lang && typeof lang !== 'string') {\n throw new TypeError(`Option lang should be a string, but is a ${typeof lang}`)\n } else if (prepend && !wrapperTypes.includes(typeof prepend)) {\n throw new TypeError(\n `Option prepend should be a string or a function, but is a ${typeof prepend}`\n )\n } else if (append && !wrapperTypes.includes(typeof append)) {\n throw new TypeError(`Option append should be a string or a function, but is a ${typeof append}`)\n }\n if (/^citation/.test(style) && type === 'json') {\n throw new Error(`Combination type/style of json/citation-* is not valid: ${type}/${style}`)\n }\n return true\n}\nexport function validateOptions(options) {\n if (typeof options !== 'object') {\n throw new TypeError('Options should be an object')\n }\n if (options.output) {\n validateOutputOptions(options.output)\n } else if (options.maxChainLength && typeof options.maxChainLength !== 'number') {\n throw new TypeError('Option maxChainLength should be a number')\n } else if (options.forceType && typeof options.forceType !== 'string') {\n throw new TypeError('Option forceType should be a string')\n } else if (options.generateGraph != null && typeof options.generateGraph !== 'boolean') {\n throw new TypeError('Option generateGraph should be a boolean')\n } else if (options.strict != null && typeof options.strict !== 'boolean') {\n throw new TypeError('Option strict should be a boolean')\n } else if (options.target != null && typeof options.target !== 'string') {\n throw new TypeError('Option target should be a boolean')\n }\n return true\n}\n","import { validateOutputOptions as validate } from './validate.js'\nconst defaultOptions = {\n format: 'real',\n type: 'json',\n style: 'csl',\n lang: 'en-US',\n}\nfunction options(options, log) {\n validate(options)\n if (log) {\n this.save()\n }\n Object.assign(this._options, options)\n return this\n}\nexport { options, defaultOptions }\n","export function typeOf(thing) {\n switch (thing) {\n case undefined:\n return 'Undefined'\n case null:\n return 'Null'\n default:\n return thing.constructor.name\n }\n}\nexport function dataTypeOf(thing) {\n switch (typeof thing) {\n case 'string':\n return 'String'\n case 'object':\n if (Array.isArray(thing)) {\n return 'Array'\n } else if (typeOf(thing) === 'Object') {\n return 'SimpleObject'\n } else if (typeOf(thing) !== 'Null') {\n return 'ComplexObject'\n }\n default:\n return 'Primitive'\n }\n}\n","export function applyGraph(entry, graph) {\n if (entry._graph) {\n const index = graph.findIndex(({ type }) => type === '@else/list+object')\n if (index !== -1) {\n graph.splice(index + 1, 0, ...entry._graph.slice(0, -1))\n }\n }\n entry._graph = graph\n return entry\n}\nexport function removeGraph(entry) {\n delete entry._graph\n return entry\n}\n","const logger = {\n _output(level, scope, msg) {\n this._log.push(scope, msg)\n if (this._levels.indexOf(level) < this._levels.indexOf(this.level)) {\n return\n }\n this._console.log(scope, ...msg)\n },\n _console: null,\n _log: [],\n _levels: ['http', 'debug', 'unmapped', 'info', 'warn', 'error', 'silent'],\n level: 'silent',\n}\nfor (const level of logger._levels) {\n logger[level] = (scope, ...msg) => logger._output(level, scope, msg)\n}\nif (typeof console.Console === 'function') {\n logger._console = new console.Console(process.stderr)\n} else {\n logger._console = console\n}\nexport default logger\n","import logger from '../../logger.js'\nimport { dataTypeOf } from './dataType.js'\nconst types = {}\nconst dataTypes = {}\nconst unregExts = {}\nfunction parseNativeTypes(input, dataType) {\n switch (dataType) {\n case 'Array':\n if (input.length === 0 || input.every((entry) => type(entry) === '@csl/object')) {\n return '@csl/list+object'\n } else {\n return '@else/list+object'\n }\n case 'SimpleObject':\n case 'ComplexObject':\n return '@csl/object'\n default:\n return '@invalid'\n }\n}\nfunction matchType(typeList = [], data) {\n for (const type of typeList) {\n if (types[type].predicate(data)) {\n return matchType(types[type].extensions, data) || type\n }\n }\n}\nexport function type(input) {\n const dataType = dataTypeOf(input)\n if (dataType === 'Array' && input.length === 0) {\n return parseNativeTypes(input, dataType)\n }\n const match = matchType(dataTypes[dataType], input)\n return match || parseNativeTypes(input, dataType)\n}\nexport function addTypeParser(format, { dataType, predicate, extends: extend }) {\n let extensions = []\n if (format in unregExts) {\n extensions = unregExts[format]\n delete unregExts[format]\n logger.debug(\n '[core]',\n `Subclasses \"${extensions}\" finally registered to parent type \"${format}\"`\n )\n }\n const object = {\n predicate,\n extensions,\n }\n types[format] = object\n if (extend) {\n const parentTypeParser = types[extend]\n if (parentTypeParser) {\n parentTypeParser.extensions.push(format)\n } else {\n if (!unregExts[extend]) {\n unregExts[extend] = []\n }\n unregExts[extend].push(format)\n logger.debug('[core]', `Subclass \"${format}\" is waiting on parent type \"${extend}\"`)\n }\n } else {\n const typeList = dataTypes[dataType] || (dataTypes[dataType] = [])\n typeList.push(format)\n }\n}\nexport function hasTypeParser(type) {\n return Object.prototype.hasOwnProperty.call(types, type)\n}\nexport function removeTypeParser(type) {\n delete types[type]\n const typeLists = [\n ...Object.keys(dataTypes).map((key) => dataTypes[key]),\n ...Object.keys(types)\n .map((type) => types[type].extensions)\n .filter((list) => list.length > 0),\n ]\n typeLists.forEach((typeList) => {\n const index = typeList.indexOf(type)\n if (index > -1) {\n typeList.splice(index, 1)\n }\n })\n}\nexport function listTypeParser() {\n return Object.keys(types)\n}\nexport function treeTypeParser() {\n const attachNode = (name) => ({\n name,\n children: types[name].extensions.map(attachNode),\n })\n return {\n name: 'Type tree',\n children: Object.keys(dataTypes).map((name) => ({\n name,\n children: dataTypes[name].map(attachNode),\n })),\n }\n}\nexport const typeMatcher = /^(?:@(.+?))(?:\\/(?:(.+?)\\+)?(?:(.+)))?$/\n","// @ts-nocheck\nfunction _defineProperty(obj, key, value) {\n key = _toPropertyKey(key)\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true,\n })\n } else {\n obj[key] = value\n }\n return obj\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, 'string')\n return 'symbol' == typeof i ? i : i + ''\n}\nfunction _toPrimitive(t, r) {\n if ('object' != typeof t || !t) return t\n var e = t[Symbol.toPrimitive]\n if (void 0 !== e) {\n var i = e.call(t, r || 'default')\n if ('object' != typeof i) return i\n throw new TypeError('@@toPrimitive must return a primitive value.')\n }\n return ('string' === r ? String : Number)(t)\n}\nimport { type, typeMatcher } from './type.js'\nclass TypeParser {\n constructor(data) {\n _defineProperty(this, 'validDataTypes', [\n 'String',\n 'Array',\n 'SimpleObject',\n 'ComplexObject',\n 'Primitive',\n ])\n this.data = data\n }\n validateDataType() {\n const dataType = this.data.dataType\n if (dataType && !this.validDataTypes.includes(dataType)) {\n throw new RangeError(`dataType was ${dataType}; expected one of ${this.validDataTypes}`)\n }\n }\n validateParseType() {\n const predicate = this.data.predicate\n if (predicate && !(predicate instanceof RegExp || typeof predicate === 'function')) {\n throw new TypeError(`predicate was ${typeof predicate}; expected RegExp or function`)\n }\n }\n validateTokenList() {\n const tokenList = this.data.tokenList\n if (tokenList && typeof tokenList !== 'object') {\n throw new TypeError(`tokenList was ${typeof tokenList}; expected object or RegExp`)\n }\n }\n validatePropertyConstraint() {\n const propertyConstraint = this.data.propertyConstraint\n if (propertyConstraint && typeof propertyConstraint !== 'object') {\n throw new TypeError(\n `propertyConstraint was ${typeof propertyConstraint}; expected array or object`\n )\n }\n }\n validateElementConstraint() {\n const elementConstraint = this.data.elementConstraint\n if (elementConstraint && typeof elementConstraint !== 'string') {\n throw new TypeError(`elementConstraint was ${typeof elementConstraint}; expected string`)\n }\n }\n validateExtends() {\n const extend = this.data.extends\n if (extend && typeof extend !== 'string') {\n throw new TypeError(`extends was ${typeof extend}; expected string`)\n }\n }\n validate() {\n if (this.data === null || typeof this.data !== 'object') {\n throw new TypeError(`typeParser was ${typeof this.data}; expected object`)\n }\n this.validateDataType()\n this.validateParseType()\n this.validateTokenList()\n this.validatePropertyConstraint()\n this.validateElementConstraint()\n this.validateExtends()\n }\n parseTokenList() {\n let tokenList = this.data.tokenList\n if (!tokenList) {\n return []\n } else if (tokenList instanceof RegExp) {\n tokenList = {\n token: tokenList,\n }\n }\n const { token, split = /\\s+/, trim = true, every = true } = tokenList\n const trimInput = (input) => (trim ? input.trim() : input)\n const testTokens = every ? 'every' : 'some'\n const predicate = (input) =>\n trimInput(input)\n .split(split)\n [testTokens]((part) => token.test(part))\n return [predicate]\n }\n parsePropertyConstraint() {\n const constraints = [].concat(this.data.propertyConstraint || [])\n return constraints.map(({ props, match, value }) => {\n props = [].concat(props)\n switch (match) {\n case 'any':\n case 'some':\n return (input) => props.some((prop) => prop in input && (!value || value(input[prop])))\n case 'none':\n return (input) => !props.some((prop) => prop in input && (!value || value(input[prop])))\n case 'every':\n default:\n return (input) => props.every((prop) => prop in input && (!value || value(input[prop])))\n }\n })\n }\n parseElementConstraint() {\n const constraint = this.data.elementConstraint\n return !constraint ? [] : [(input) => input.every((entry) => type(entry) === constraint)]\n }\n parsePredicate() {\n if (this.data.predicate instanceof RegExp) {\n return [this.data.predicate.test.bind(this.data.predicate)]\n } else if (this.data.predicate) {\n return [this.data.predicate]\n } else {\n return []\n }\n }\n getCombinedPredicate() {\n const predicates = [\n ...this.parsePredicate(),\n ...this.parseTokenList(),\n ...this.parsePropertyConstraint(),\n ...this.parseElementConstraint(),\n ]\n if (predicates.length === 0) {\n return () => true\n } else if (predicates.length === 1) {\n return predicates[0]\n } else {\n return (input) => predicates.every((predicate) => predicate(input))\n }\n }\n getDataType() {\n if (this.data.dataType) {\n return this.data.dataType\n } else if (this.data.predicate instanceof RegExp) {\n return 'String'\n } else if (this.data.tokenList) {\n return 'String'\n } else if (this.data.elementConstraint) {\n return 'Array'\n } else {\n return 'Primitive'\n }\n }\n get dataType() {\n return this.getDataType()\n }\n get predicate() {\n return this.getCombinedPredicate()\n }\n get extends() {\n return this.data.extends\n }\n}\nclass DataParser {\n constructor(parser, { async } = {}) {\n this.parser = parser\n this.async = async\n }\n validate() {\n const parser = this.parser\n if (typeof parser !== 'function') {\n throw new TypeError(`parser was ${typeof parser}; expected function`)\n }\n }\n}\nclass FormatParser {\n constructor(format, parsers = {}) {\n this.format = format\n if (parsers.parseType) {\n this.typeParser = new TypeParser(parsers.parseType)\n }\n if (parsers.parse) {\n this.dataParser = new DataParser(parsers.parse, {\n async: false,\n })\n }\n if (parsers.parseAsync) {\n this.asyncDataParser = new DataParser(parsers.parseAsync, {\n async: true,\n })\n }\n }\n validateFormat() {\n const format = this.format\n if (!typeMatcher.test(format)) {\n throw new TypeError(`format name was \"${format}\"; didn't match expected pattern`)\n }\n }\n validate() {\n this.validateFormat()\n if (this.typeParser) {\n this.typeParser.validate()\n }\n if (this.dataParser) {\n this.dataParser.validate()\n }\n if (this.asyncDataParser) {\n this.asyncDataParser.validate()\n }\n }\n}\nexport { TypeParser, DataParser, FormatParser }\n","function ownKeys(e, r) {\n var t = Object.keys(e)\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e)\n r &&\n (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable\n })),\n t.push.apply(t, o)\n }\n return t\n}\nfunction _objectSpread(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {}\n r % 2\n ? ownKeys(Object(t), !0).forEach(function (r) {\n _defineProperty(e, r, t[r])\n })\n : Object.getOwnPropertyDescriptors\n ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))\n : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r))\n })\n }\n return e\n}\nfunction _defineProperty(obj, key, value) {\n key = _toPropertyKey(key)\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true,\n })\n } else {\n obj[key] = value\n }\n return obj\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, 'string')\n return 'symbol' == typeof i ? i : i + ''\n}\nfunction _toPrimitive(t, r) {\n if ('object' != typeof t || !t) return t\n var e = t[Symbol.toPrimitive]\n if (void 0 !== e) {\n var i = e.call(t, r || 'default')\n if ('object' != typeof i) return i\n throw new TypeError('@@toPrimitive must return a primitive value.')\n }\n return ('string' === r ? String : Number)(t)\n}\nimport { parse as parseName } from '@citation-js/name'\nconst NAME = 1\nconst NAME_LIST = 2\nconst DATE = 3\nconst TYPE = 4\nconst entryTypes = {\n article: true,\n 'article-journal': true,\n 'article-magazine': true,\n 'article-newspaper': true,\n bill: true,\n book: true,\n broadcast: true,\n chapter: true,\n classic: true,\n collection: true,\n dataset: true,\n document: true,\n entry: true,\n 'entry-dictionary': true,\n 'entry-encyclopedia': true,\n event: true,\n figure: true,\n graphic: true,\n hearing: true,\n interview: true,\n legal_case: true,\n legislation: true,\n manuscript: true,\n map: true,\n motion_picture: true,\n musical_score: true,\n pamphlet: true,\n 'paper-conference': true,\n patent: true,\n performance: true,\n periodical: true,\n personal_communication: true,\n post: true,\n 'post-weblog': true,\n regulation: true,\n report: true,\n review: true,\n 'review-book': true,\n software: true,\n song: true,\n speech: true,\n standard: true,\n thesis: true,\n treaty: true,\n webpage: true,\n 'journal-article': 'article-journal',\n 'book-chapter': 'chapter',\n 'posted-content': 'manuscript',\n 'proceedings-article': 'paper-conference',\n dissertation: 'thesis',\n}\nconst fieldTypes = {\n author: NAME_LIST,\n chair: NAME_LIST,\n 'collection-editor': NAME_LIST,\n compiler: NAME_LIST,\n composer: NAME_LIST,\n 'container-author': NAME_LIST,\n contributor: NAME_LIST,\n curator: NAME_LIST,\n director: NAME_LIST,\n editor: NAME_LIST,\n 'editorial-director': NAME_LIST,\n 'executive-producer': NAME_LIST,\n guest: NAME_LIST,\n host: NAME_LIST,\n interviewer: NAME_LIST,\n illustrator: NAME_LIST,\n narrator: NAME_LIST,\n organizer: NAME_LIST,\n 'original-author': NAME_LIST,\n performer: NAME_LIST,\n producer: NAME_LIST,\n 'reviewed-author': NAME_LIST,\n recipient: NAME_LIST,\n 'script-writer': NAME_LIST,\n 'series-creator': NAME_LIST,\n translator: NAME_LIST,\n accessed: DATE,\n 'available-date': DATE,\n container: DATE,\n 'event-date': DATE,\n issued: DATE,\n 'original-date': DATE,\n submitted: DATE,\n type: TYPE,\n categories: 'object',\n custom: 'object',\n id: ['string', 'number'],\n language: 'string',\n journalAbbreviation: 'string',\n shortTitle: 'string',\n abstract: 'string',\n annote: 'string',\n archive: 'string',\n archive_collection: 'string',\n archive_location: 'string',\n 'archive-place': 'string',\n authority: 'string',\n 'call-number': 'string',\n 'chapter-number': 'string',\n 'citation-number': 'string',\n 'citation-key': 'string',\n 'citation-label': 'string',\n 'collection-number': 'string',\n 'collection-title': 'string',\n 'container-title': 'string',\n 'container-title-short': 'string',\n dimensions: 'string',\n division: 'string',\n DOI: 'string',\n edition: ['string', 'number'],\n event: 'string',\n 'event-title': 'string',\n 'event-place': 'string',\n 'first-reference-note-number': 'string',\n genre: 'string',\n ISBN: 'string',\n ISSN: 'string',\n issue: ['string', 'number'],\n jurisdiction: 'string',\n keyword: 'string',\n locator: 'string',\n medium: 'string',\n note: 'string',\n number: ['string', 'number'],\n 'number-of-pages': 'string',\n 'number-of-volumes': ['string', 'number'],\n 'original-publisher': 'string',\n 'original-publisher-place': 'string',\n 'original-title': 'string',\n page: 'string',\n 'page-first': 'string',\n 'part-number': ['string', 'number'],\n 'part-title': 'string',\n PMCID: 'string',\n PMID: 'string',\n printing: 'string',\n publisher: 'string',\n 'publisher-place': 'string',\n references: 'string',\n 'reviewed-title': 'string',\n 'reviewed-genre': 'string',\n scale: 'string',\n section: 'string',\n source: 'string',\n status: 'string',\n supplement: ['string', 'number'],\n title: 'string',\n 'title-short': 'string',\n URL: 'string',\n version: 'string',\n volume: ['string', 'number'],\n 'volume-title': 'string',\n 'volume-title-short': 'string',\n 'year-suffix': 'string',\n}\nfunction correctName(name, bestGuessConversions) {\n if (typeof name === 'object' && name !== null && (name.literal || name.given || name.family)) {\n if (name.ORCID || name.orcid || name._ORCID) {\n name = _objectSpread(\n {\n _orcid: name.ORCID || name.orcid || name._ORCID,\n },\n name\n )\n delete name.ORCID\n delete name.orcid\n delete name._ORCID\n }\n return name\n } else if (!bestGuessConversions) {\n return undefined\n } else if (typeof name === 'string') {\n return parseName(name)\n }\n}\nfunction correctNameList(nameList, bestGuessConversions) {\n if (nameList instanceof Array) {\n const names = nameList.map((name) => correctName(name, bestGuessConversions)).filter(Boolean)\n return names.length ? names : undefined\n }\n}\nfunction correctDateParts(dateParts, bestGuessConversions) {\n if (dateParts.every((part) => typeof part === 'number')) {\n return dateParts\n } else if (!bestGuessConversions || dateParts.some((part) => isNaN(parseInt(part)))) {\n return undefined\n } else {\n return dateParts.map((part) => parseInt(part))\n }\n}\nfunction correctDate(date, bestGuessConversions) {\n const dp = 'date-parts'\n if (typeof date !== 'object' || date === null) {\n return undefined\n } else if (date[dp] instanceof Array && date[dp].every((part) => part instanceof Array)) {\n const range = date[dp]\n .map((dateParts) => correctDateParts(dateParts, bestGuessConversions))\n .filter(Boolean)\n return range.length\n ? _objectSpread(\n _objectSpread({}, date),\n {},\n {\n 'date-parts': range,\n }\n )\n : undefined\n } else if (date instanceof Array && date.every((part) => part[dp] instanceof Array)) {\n const range = date\n .map((dateParts) => correctDateParts(dateParts[dp], bestGuessConversions))\n .filter(Boolean)\n return range.length\n ? {\n 'date-parts': range,\n }\n : undefined\n } else if (date[dp] instanceof Array) {\n const dateParts = correctDateParts(date[dp], bestGuessConversions)\n return (\n dateParts && {\n 'date-parts': [dateParts],\n }\n )\n } else if ('literal' in date || 'raw' in date) {\n return date\n }\n}\nfunction correctType(type, bestGuessConversions) {\n type = correctField('language', type, bestGuessConversions)\n if (entryTypes[type] === true) {\n return type\n }\n if (bestGuessConversions) {\n if (type in entryTypes) {\n return entryTypes[type]\n } else if (type.toLowerCase() !== type) {\n return correctType(type.toLowerCase(), bestGuessConversions)\n }\n }\n return undefined\n}\nfunction correctField(fieldName, value, bestGuessConversions) {\n const fieldType = [].concat(fieldTypes[fieldName])\n switch (fieldTypes[fieldName]) {\n case NAME:\n return correctName(value, bestGuessConversions)\n case NAME_LIST:\n return correctNameList(value, bestGuessConversions)\n case DATE:\n return correctDate(value, bestGuessConversions)\n case TYPE:\n return correctType(value, bestGuessConversions)\n }\n if (bestGuessConversions) {\n if (\n typeof value === 'string' &&\n fieldType.includes('number') &&\n !fieldType.includes('string') &&\n !isNaN(+value)\n ) {\n return parseFloat(value)\n } else if (\n typeof value === 'number' &&\n fieldType.includes('string') &&\n !fieldType.includes('number')\n ) {\n return value.toString()\n } else if (Array.isArray(value) && value.length) {\n return correctField(fieldName, value[0], bestGuessConversions)\n }\n }\n if (fieldType.includes(typeof value)) {\n return value\n }\n}\nfunction parseCsl(data, bestGuessConversions = true) {\n return data.map(function (entry) {\n const clean = {}\n for (const field in entry) {\n const correction = correctField(field, entry[field], bestGuessConversions)\n if (correction !== undefined) {\n clean[field] = correction\n }\n }\n return clean\n })\n}\nexport { parseCsl as clean }\n","function ownKeys(e, r) {\n var t = Object.keys(e)\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e)\n r &&\n (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable\n })),\n t.push.apply(t, o)\n }\n return t\n}\nfunction _objectSpread(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {}\n r % 2\n ? ownKeys(Object(t), !0).forEach(function (r) {\n _defineProperty(e, r, t[r])\n })\n : Object.getOwnPropertyDescriptors\n ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))\n : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r))\n })\n }\n return e\n}\nfunction _defineProperty(obj, key, value) {\n key = _toPropertyKey(key)\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true,\n })\n } else {\n obj[key] = value\n }\n return obj\n}\nfunction _toPropertyKey(t) {\n var i = _toPrimitive(t, 'string')\n return 'symbol' == typeof i ? i : i + ''\n}\nfunction _toPrimitive(t, r) {\n if ('object' != typeof t || !t) return t\n var e = t[Symbol.toPrimitive]\n if (void 0 !== e) {\n var i = e.call(t, r || 'default')\n if ('object' != typeof i) return i\n throw new TypeError('@@toPrimitive must return a primitive value.')\n }\n return ('string' === r ? String : Number)(t)\n}\nexport function upgradeCsl(item) {\n if (Array.isArray(item)) {\n return item.map(upgradeCsl)\n }\n item = _objectSpread({}, item)\n if ('event' in item) {\n item['event-title'] = item.event\n delete item.event\n }\n if (item.type === 'book' && 'version' in item) {\n item.type = 'software'\n }\n return item\n}\nexport function downgradeCsl(item) {\n if (Array.isArray(item)) {\n return item.map(downgradeCsl)\n }\n item = _objectSpread({}, item)\n if ('event-title' in item) {\n item.event = item['event-title']\n delete item['event-title']\n }\n if (item.type === 'software') {\n item.type = 'book'\n }\n return item\n}\n","export function deepCopy(value, seen = new Set()) {\n if (\n typeof value !== 'object' ||\n value === null ||\n (value.constructor !== Object && value.constructor !== Array)\n ) {\n return value\n }\n if (seen.has(value)) {\n throw new TypeError('Recursively copying circular structure')\n }\n seen.add(value)\n let copy\n if (value.constructor === Array) {\n copy = value.map((value) => deepCopy(value, seen))\n } else {\n const object = {}\n for (const key in value) {\n object[key] = deepCopy(value[key], seen)\n }\n copy = object\n }\n seen.delete(value)\n return copy\n}\nexport default deepCopy\n","\"use strict\";\n\nvar conversions = {};\nmodule.exports = conversions;\n\nfunction sign(x) {\n return x < 0 ? -1 : 1;\n}\n\nfunction evenRound(x) {\n // Round x to the nearest integer, choosing the even integer if it lies halfway between two.\n if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor)\n return Math.floor(x);\n } else {\n return Math.round(x);\n }\n}\n\nfunction createNumberConversion(bitLength, typeOpts) {\n if (!typeOpts.unsigned) {\n --bitLength;\n }\n const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength);\n const upperBound = Math.pow(2, bitLength) - 1;\n\n const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength);\n const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1);\n\n return function(V, opts) {\n if (!opts) opts = {};\n\n let x = +V;\n\n if (opts.enforceRange) {\n if (!Number.isFinite(x)) {\n throw new TypeError(\"Argument is not a finite number\");\n }\n\n x = sign(x) * Math.floor(Math.abs(x));\n if (x < lowerBound || x > upperBound) {\n throw new TypeError(\"Argument is not in byte range\");\n }\n\n return x;\n }\n\n if (!isNaN(x) && opts.clamp) {\n x = evenRound(x);\n\n if (x < lowerBound) x = lowerBound;\n if (x > upperBound) x = upperBound;\n return x;\n }\n\n if (!Number.isFinite(x) || x === 0) {\n return 0;\n }\n\n x = sign(x) * Math.floor(Math.abs(x));\n x = x % moduloVal;\n\n if (!typeOpts.unsigned && x >= moduloBound) {\n return x - moduloVal;\n } else if (typeOpts.unsigned) {\n if (x < 0) {\n x += moduloVal;\n } else if (x === -0) { // don't return negative zero\n return 0;\n }\n }\n\n return x;\n }\n}\n\nconversions[\"void\"] = function () {\n return undefined;\n};\n\nconversions[\"boolean\"] = function (val) {\n return !!val;\n};\n\nconversions[\"byte\"] = createNumberConversion(8, { unsigned: false });\nconversions[\"octet\"] = createNumberConversion(8, { unsigned: true });\n\nconversions[\"short\"] = createNumberConversion(16, { unsigned: false });\nconversions[\"unsigned short\"] = createNumberConversion(16, { unsigned: true });\n\nconversions[\"long\"] = createNumberConversion(32, { unsigned: false });\nconversions[\"unsigned long\"] = createNumberConversion(32, { unsigned: true });\n\nconversions[\"long long\"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 });\nconversions[\"unsigned long long\"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 });\n\nconversions[\"double\"] = function (V) {\n const x = +V;\n\n if (!Number.isFinite(x)) {\n throw new TypeError(\"Argument is not a finite floating-point value\");\n }\n\n return x;\n};\n\nconversions[\"unrestricted double\"] = function (V) {\n const x = +V;\n\n if (isNaN(x)) {\n throw new TypeError(\"Argument is NaN\");\n }\n\n return x;\n};\n\n// not quite valid, but good enough for JS\nconversions[\"float\"] = conversions[\"double\"];\nconversions[\"unrestricted float\"] = conversions[\"unrestricted double\"];\n\nconversions[\"DOMString\"] = function (V, opts) {\n if (!opts) opts = {};\n\n if (opts.treatNullAsEmptyString && V === null) {\n return \"\";\n }\n\n return String(V);\n};\n\nconversions[\"ByteString\"] = function (V, opts) {\n const x = String(V);\n let c = undefined;\n for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) {\n if (c > 255) {\n throw new TypeError(\"Argument is not a valid bytestring\");\n }\n }\n\n return x;\n};\n\nconversions[\"USVString\"] = function (V) {\n const S = String(V);\n const n = S.length;\n const U = [];\n for (let i = 0; i < n; ++i) {\n const c = S.charCodeAt(i);\n if (c < 0xD800 || c > 0xDFFF) {\n U.push(String.fromCodePoint(c));\n } else if (0xDC00 <= c && c <= 0xDFFF) {\n U.push(String.fromCodePoint(0xFFFD));\n } else {\n if (i === n - 1) {\n U.push(String.fromCodePoint(0xFFFD));\n } else {\n const d = S.charCodeAt(i + 1);\n if (0xDC00 <= d && d <= 0xDFFF) {\n const a = c & 0x3FF;\n const b = d & 0x3FF;\n U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b));\n ++i;\n } else {\n U.push(String.fromCodePoint(0xFFFD));\n }\n }\n }\n }\n\n return U.join('');\n};\n\nconversions[\"Date\"] = function (V, opts) {\n if (!(V instanceof Date)) {\n throw new TypeError(\"Argument is not a Date object\");\n }\n if (isNaN(V)) {\n return undefined;\n }\n\n return V;\n};\n\nconversions[\"RegExp\"] = function (V, opts) {\n if (!(V instanceof RegExp)) {\n V = new RegExp(V);\n }\n\n return V;\n};\n","\"use strict\";\n\nmodule.exports.mixin = function mixin(target, source) {\n const keys = Object.getOwnPropertyNames(source);\n for (let i = 0; i < keys.length; ++i) {\n Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i]));\n }\n};\n\nmodule.exports.wrapperSymbol = Symbol(\"wrapper\");\nmodule.exports.implSymbol = Symbol(\"impl\");\n\nmodule.exports.wrapperForImpl = function (impl) {\n return impl[module.exports.wrapperSymbol];\n};\n\nmodule.exports.implForWrapper = function (wrapper) {\n return wrapper[module.exports.implSymbol];\n};\n\n","\"use strict\";\n\nvar punycode = require(\"punycode\");\nvar mappingTable = require(\"./lib/mappingTable.json\");\n\nvar PROCESSING_OPTIONS = {\n TRANSITIONAL: 0,\n NONTRANSITIONAL: 1\n};\n\nfunction normalize(str) { // fix bug in v8\n return str.split('\\u0000').map(function (s) { return s.normalize('NFC'); }).join('\\u0000');\n}\n\nfunction findStatus(val) {\n var start = 0;\n var end = mappingTable.length - 1;\n\n while (start <= end) {\n var mid = Math.floor((start + end) / 2);\n\n var target = mappingTable[mid];\n if (target[0][0] <= val && target[0][1] >= val) {\n return target;\n } else if (target[0][0] > val) {\n end = mid - 1;\n } else {\n start = mid + 1;\n }\n }\n\n return null;\n}\n\nvar regexAstralSymbols = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g;\n\nfunction countSymbols(string) {\n return string\n // replace every surrogate pair with a BMP symbol\n .replace(regexAstralSymbols, '_')\n // then get the length\n .length;\n}\n\nfunction mapChars(domain_name, useSTD3, processing_option) {\n var hasError = false;\n var processed = \"\";\n\n var len = countSymbols(domain_name);\n for (var i = 0; i < len; ++i) {\n var codePoint = domain_name.codePointAt(i);\n var status = findStatus(codePoint);\n\n switch (status[1]) {\n case \"disallowed\":\n hasError = true;\n processed += String.fromCodePoint(codePoint);\n break;\n case \"ignored\":\n break;\n case \"mapped\":\n processed += String.fromCodePoint.apply(String, status[2]);\n break;\n case \"deviation\":\n if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) {\n processed += String.fromCodePoint.apply(String, status[2]);\n } else {\n processed += String.fromCodePoint(codePoint);\n }\n break;\n case \"valid\":\n processed += String.fromCodePoint(codePoint);\n break;\n case \"disallowed_STD3_mapped\":\n if (useSTD3) {\n hasError = true;\n processed += String.fromCodePoint(codePoint);\n } else {\n processed += String.fromCodePoint.apply(String, status[2]);\n }\n break;\n case \"disallowed_STD3_valid\":\n if (useSTD3) {\n hasError = true;\n }\n\n processed += String.fromCodePoint(codePoint);\n break;\n }\n }\n\n return {\n string: processed,\n error: hasError\n };\n}\n\nvar combiningMarksRegex = /[\\u0300-\\u036F\\u0483-\\u0489\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065F\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0859-\\u085B\\u08E4-\\u0903\\u093A-\\u093C\\u093E-\\u094F\\u0951-\\u0957\\u0962\\u0963\\u0981-\\u0983\\u09BC\\u09BE-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CD\\u09D7\\u09E2\\u09E3\\u0A01-\\u0A03\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81-\\u0A83\\u0ABC\\u0ABE-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AE2\\u0AE3\\u0B01-\\u0B03\\u0B3C\\u0B3E-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B62\\u0B63\\u0B82\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD7\\u0C00-\\u0C03\\u0C3E-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0C81-\\u0C83\\u0CBC\\u0CBE-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CE2\\u0CE3\\u0D01-\\u0D03\\u0D3E-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4D\\u0D57\\u0D62\\u0D63\\u0D82\\u0D83\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F3E\\u0F3F\\u0F71-\\u0F84\\u0F86\\u0F87\\u0F8D-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102B-\\u103E\\u1056-\\u1059\\u105E-\\u1060\\u1062-\\u1064\\u1067-\\u106D\\u1071-\\u1074\\u1082-\\u108D\\u108F\\u109A-\\u109D\\u135D-\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B4-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u192B\\u1930-\\u193B\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A17-\\u1A1B\\u1A55-\\u1A5E\\u1A60-\\u1A7C\\u1A7F\\u1AB0-\\u1ABE\\u1B00-\\u1B04\\u1B34-\\u1B44\\u1B6B-\\u1B73\\u1B80-\\u1B82\\u1BA1-\\u1BAD\\u1BE6-\\u1BF3\\u1C24-\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE8\\u1CED\\u1CF2-\\u1CF4\\u1CF8\\u1CF9\\u1DC0-\\u1DF5\\u1DFC-\\u1DFF\\u20D0-\\u20F0\\u2CEF-\\u2CF1\\u2D7F\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F-\\uA672\\uA674-\\uA67D\\uA69F\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA823-\\uA827\\uA880\\uA881\\uA8B4-\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA953\\uA980-\\uA983\\uA9B3-\\uA9C0\\uA9E5\\uAA29-\\uAA36\\uAA43\\uAA4C\\uAA4D\\uAA7B-\\uAA7D\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uAAEB-\\uAAEF\\uAAF5\\uAAF6\\uABE3-\\uABEA\\uABEC\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE2D]|\\uD800[\\uDDFD\\uDEE0\\uDF76-\\uDF7A]|\\uD802[\\uDE01-\\uDE03\\uDE05\\uDE06\\uDE0C-\\uDE0F\\uDE38-\\uDE3A\\uDE3F\\uDEE5\\uDEE6]|\\uD804[\\uDC00-\\uDC02\\uDC38-\\uDC46\\uDC7F-\\uDC82\\uDCB0-\\uDCBA\\uDD00-\\uDD02\\uDD27-\\uDD34\\uDD73\\uDD80-\\uDD82\\uDDB3-\\uDDC0\\uDE2C-\\uDE37\\uDEDF-\\uDEEA\\uDF01-\\uDF03\\uDF3C\\uDF3E-\\uDF44\\uDF47\\uDF48\\uDF4B-\\uDF4D\\uDF57\\uDF62\\uDF63\\uDF66-\\uDF6C\\uDF70-\\uDF74]|\\uD805[\\uDCB0-\\uDCC3\\uDDAF-\\uDDB5\\uDDB8-\\uDDC0\\uDE30-\\uDE40\\uDEAB-\\uDEB7]|\\uD81A[\\uDEF0-\\uDEF4\\uDF30-\\uDF36]|\\uD81B[\\uDF51-\\uDF7E\\uDF8F-\\uDF92]|\\uD82F[\\uDC9D\\uDC9E]|\\uD834[\\uDD65-\\uDD69\\uDD6D-\\uDD72\\uDD7B-\\uDD82\\uDD85-\\uDD8B\\uDDAA-\\uDDAD\\uDE42-\\uDE44]|\\uD83A[\\uDCD0-\\uDCD6]|\\uDB40[\\uDD00-\\uDDEF]/;\n\nfunction validateLabel(label, processing_option) {\n if (label.substr(0, 4) === \"xn--\") {\n label = punycode.toUnicode(label);\n processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL;\n }\n\n var error = false;\n\n if (normalize(label) !== label ||\n (label[3] === \"-\" && label[4] === \"-\") ||\n label[0] === \"-\" || label[label.length - 1] === \"-\" ||\n label.indexOf(\".\") !== -1 ||\n label.search(combiningMarksRegex) === 0) {\n error = true;\n }\n\n var len = countSymbols(label);\n for (var i = 0; i < len; ++i) {\n var status = findStatus(label.codePointAt(i));\n if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== \"valid\") ||\n (processing === PROCESSING_OPTIONS.NONTRANSITIONAL &&\n status[1] !== \"valid\" && status[1] !== \"deviation\")) {\n error = true;\n break;\n }\n }\n\n return {\n label: label,\n error: error\n };\n}\n\nfunction processing(domain_name, useSTD3, processing_option) {\n var result = mapChars(domain_name, useSTD3, processing_option);\n result.string = normalize(result.string);\n\n var labels = result.string.split(\".\");\n for (var i = 0; i < labels.length; ++i) {\n try {\n var validation = validateLabel(labels[i]);\n labels[i] = validation.label;\n result.error = result.error || validation.error;\n } catch(e) {\n result.error = true;\n }\n }\n\n return {\n string: labels.join(\".\"),\n error: result.error\n };\n}\n\nmodule.exports.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) {\n var result = processing(domain_name, useSTD3, processing_option);\n var labels = result.string.split(\".\");\n labels = labels.map(function(l) {\n try {\n return punycode.toASCII(l);\n } catch(e) {\n result.error = true;\n return l;\n }\n });\n\n if (verifyDnsLength) {\n var total = labels.slice(0, labels.length - 1).join(\".\").length;\n if (total.length > 253 || total.length === 0) {\n result.error = true;\n }\n\n for (var i=0; i < labels.length; ++i) {\n if (labels.length > 63 || labels.length === 0) {\n result.error = true;\n break;\n }\n }\n }\n\n if (result.error) return null;\n return labels.join(\".\");\n};\n\nmodule.exports.toUnicode = function(domain_name, useSTD3) {\n var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL);\n\n return {\n domain: result.string,\n error: result.error\n };\n};\n\nmodule.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS;\n","\"use strict\";\r\nconst punycode = require(\"punycode\");\r\nconst tr46 = require(\"tr46\");\r\n\r\nconst specialSchemes = {\r\n ftp: 21,\r\n file: null,\r\n gopher: 70,\r\n http: 80,\r\n https: 443,\r\n ws: 80,\r\n wss: 443\r\n};\r\n\r\nconst failure = Symbol(\"failure\");\r\n\r\nfunction countSymbols(str) {\r\n return punycode.ucs2.decode(str).length;\r\n}\r\n\r\nfunction at(input, idx) {\r\n const c = input[idx];\r\n return isNaN(c) ? undefined : String.fromCodePoint(c);\r\n}\r\n\r\nfunction isASCIIDigit(c) {\r\n return c >= 0x30 && c <= 0x39;\r\n}\r\n\r\nfunction isASCIIAlpha(c) {\r\n return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A);\r\n}\r\n\r\nfunction isASCIIAlphanumeric(c) {\r\n return isASCIIAlpha(c) || isASCIIDigit(c);\r\n}\r\n\r\nfunction isASCIIHex(c) {\r\n return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66);\r\n}\r\n\r\nfunction isSingleDot(buffer) {\r\n return buffer === \".\" || buffer.toLowerCase() === \"%2e\";\r\n}\r\n\r\nfunction isDoubleDot(buffer) {\r\n buffer = buffer.toLowerCase();\r\n return buffer === \"..\" || buffer === \"%2e.\" || buffer === \".%2e\" || buffer === \"%2e%2e\";\r\n}\r\n\r\nfunction isWindowsDriveLetterCodePoints(cp1, cp2) {\r\n return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124);\r\n}\r\n\r\nfunction isWindowsDriveLetterString(string) {\r\n return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === \":\" || string[1] === \"|\");\r\n}\r\n\r\nfunction isNormalizedWindowsDriveLetterString(string) {\r\n return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === \":\";\r\n}\r\n\r\nfunction containsForbiddenHostCodePoint(string) {\r\n return string.search(/\\u0000|\\u0009|\\u000A|\\u000D|\\u0020|#|%|\\/|:|\\?|@|\\[|\\\\|\\]/) !== -1;\r\n}\r\n\r\nfunction containsForbiddenHostCodePointExcludingPercent(string) {\r\n return string.search(/\\u0000|\\u0009|\\u000A|\\u000D|\\u0020|#|\\/|:|\\?|@|\\[|\\\\|\\]/) !== -1;\r\n}\r\n\r\nfunction isSpecialScheme(scheme) {\r\n return specialSchemes[scheme] !== undefined;\r\n}\r\n\r\nfunction isSpecial(url) {\r\n return isSpecialScheme(url.scheme);\r\n}\r\n\r\nfunction defaultPort(scheme) {\r\n return specialSchemes[scheme];\r\n}\r\n\r\nfunction percentEncode(c) {\r\n let hex = c.toString(16).toUpperCase();\r\n if (hex.length === 1) {\r\n hex = \"0\" + hex;\r\n }\r\n\r\n return \"%\" + hex;\r\n}\r\n\r\nfunction utf8PercentEncode(c) {\r\n const buf = new Buffer(c);\r\n\r\n let str = \"\";\r\n\r\n for (let i = 0; i < buf.length; ++i) {\r\n str += percentEncode(buf[i]);\r\n }\r\n\r\n return str;\r\n}\r\n\r\nfunction utf8PercentDecode(str) {\r\n const input = new Buffer(str);\r\n const output = [];\r\n for (let i = 0; i < input.length; ++i) {\r\n if (input[i] !== 37) {\r\n output.push(input[i]);\r\n } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) {\r\n output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16));\r\n i += 2;\r\n } else {\r\n output.push(input[i]);\r\n }\r\n }\r\n return new Buffer(output).toString();\r\n}\r\n\r\nfunction isC0ControlPercentEncode(c) {\r\n return c <= 0x1F || c > 0x7E;\r\n}\r\n\r\nconst extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]);\r\nfunction isPathPercentEncode(c) {\r\n return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c);\r\n}\r\n\r\nconst extraUserinfoPercentEncodeSet =\r\n new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]);\r\nfunction isUserinfoPercentEncode(c) {\r\n return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c);\r\n}\r\n\r\nfunction percentEncodeChar(c, encodeSetPredicate) {\r\n const cStr = String.fromCodePoint(c);\r\n\r\n if (encodeSetPredicate(c)) {\r\n return utf8PercentEncode(cStr);\r\n }\r\n\r\n