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O,CAAa,EAUrB,YAAa,GAAO,EAAI,QAAQ,qBAAqB,CAAC,EAAI,IAAO,GAAG,EAAE,IAAI,OAAO,IAAK,EAAE,IAAI,SAO5F,UAAW,GAAO,eAEjB,EAAE,IAAI,EAAI,WAAW,KAAM,QAEzB,WAAW,IAAK,IAChB,WAAW,IAAK,IAChB,cACA,OACA,WAAW,IAAK,OAAO,MAAM,IAC9B,QAAO,GAAoB,EAAI,WAAW,IAAM,IAAM,EAAI,WAAW,IAAM,KAClD,KAAtB,EAAI,WAAW,IACf,EAAI,WAAW,GAAK,KACpB,EAAI,WAAW,IAAM,IAAM,EAAI,WAAW,IAAM,KACnD,KAAK,IACL,QAAQ,KAAM","file":"/npm/gitbook-plugin-page-treeview-simple@4.0.2/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gitbook-plugin-page-treeview-simple@4.0.2/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/***********************************************************************\n *                                                                   _\n *       _____  _                           ____  _                 |_|\n *      |  _  |/ \\   ____  ____ __ ___     / ___\\/ \\   __   _  ____  _\n *      | |_| || |  / __ \\/ __ \\\\ '_  \\ _ / /    | |___\\ \\ | |/ __ \\| |\n *      |  _  || |__. ___/. ___/| | | ||_|\\ \\___ |  _  | |_| |. ___/| |\n *      |_/ \\_|\\___/\\____|\\____||_| |_|    \\____/|_| |_|_____|\\____||_|\n *\n *      ================================================================\n *                 More than a coder, More than a designer\n *      ================================================================\n *\n *\n *      - Document: index.js\n *      - Author: aleen42\n *      - Description: the main entrance for page-treeview\n *      - Create Time: Apr 11st, 2016\n *      - Update Time: Feb 12nd, 2019\n *\n *\n **********************************************************************/\n\nconst _ = require('./fn');\n\n/**\n * [removeMarkdown: convert markdown into plain text]\n * @type {Function}\n */\nconst blockFn   = x => `${x}\\n`;\nconst identity  = x => x;\nconst newlineFn = () => '\\n';\nconst emptyFn   = () => '';\n\nconst RemoveMarkdown = markdown => require('marked')(markdown, {\n\tgfm: true,\n\tpedantic: false,\n\trenderer: {\n\t\t// Block elements\n\t\tcode:       blockFn,\n\t\tblockquote: blockFn,\n\t\thtml:       emptyFn,\n\t\theading:    blockFn,\n\t\thr:         emptyFn,\n\t\tlist:       (body, ordered, start) => `${start}. ${blockFn(body)}`, // ignore list header\n\t\tlistitem:   text => blockFn(text),\n\t\tparagraph:  blockFn,\n\t\ttable:      (header, body) => blockFn(header) + blockFn(body),\n\t\ttablerow:   blockFn,\n\t\ttablecell:  blockFn,\n\t\t// Inline elements\n\t\tstrong:   identity,\n\t\tem:       identity,\n\t\tcodespan: identity,\n\t\tbr:       newlineFn,\n\t\tdel:      identity,\n\t\tlink:     (_0, _1, text) => identity(text),\n\t\timage:    (_0, _2, text) => identity(text),\n\t\ttext:     identity,\n\t},\n}).trim();\n\n/**\n * [remarkable: convert markdown into a html]\n * @type {Class}\n */\nconst Remarkable = require('remarkable');\n\n/**\n * [generateContent: method for generating whole content]\n * @param  {Object} configs   [page configurations]\n * @param  {string} [content] [page contents]\n * @return {string}           [description]\n */\nconst generateContent = (configs, content = '') => {\n\t/**\n\t * [options: options for generating]\n\t * @type {Object}\n\t */\n\tconst options = Object.assign({\n\t\t'copyright': 'Copyright &#169; aleen42',\n\t\t'minHeaderCount': '1',\n\t\t'minHeaderDeep': '1',\n\t\t'collapsed': false,\n\t}, configs || {});\n\n\tconst renderContent = pageTreeview.initHeaders(content, options);\n\n\t/** check whether the option copyright is empty */\n\tconst copyRight = options.copyright ? (`\n\t\t<div class=\"treeview__container-title\">\n\t\t\t<span class=\"treeview__main-title\">Treeview</span>\n\t\t\t<span class=\"treeview__copyright\">${options.copyright} all right reserved, powered by \n\t\t\t\t<a href=\"https://github.com/aleen42\" target=\"_blank\">aleen42</a>\n\t\t\t</span>\n\t</div>`).replace(/\\r?\\n|\\t/g, '') : '';\n\n\treturn renderContent ? `<div class=\"treeview__container\">${renderContent}</div>` : '';\n};\n\n/**\n * [main module]\n * @type {Object}\n */\nconst pageTreeview = module.exports = {\n\t/** Map of new style */\n\tbook: {\n\t\tassets: './assets',\n\t\tcss: ['style.css'],\n\t},\n\n\t/** Map of hooks */\n\thooks: {\n\t\t'page:before': function (page) {\n\t\t\tif (this.output.name !== 'website') {\n\t\t\t\treturn page;\n\t\t\t}\n\n\t\t\t// @deprecated\n\t\t\t// generateContent(this.options.pluginsConfig['page-treeview'])\n\t\t\tpage.content = `${generateContent(this.config.get('pluginsConfig')['page-treeview'], page.content)}\\n\\n${page.content}`;\n\t\t\treturn page;\n\t\t}\n\t},\n\n\t/** Map of new blocks */\n\tblocks: {},\n\n\t/** Map of new filters */\n\tfilters: {},\n\n\t/**\n\t * [test: tests function]\n\t * @param  {Object} configs  [simulated configs]\n\t * @param  {string} [content] [simulated contents]\n\t * @return {string}            [description]\n\t */\n\ttest: generateContent,\n\n\t/**\n\t * [getLevelTab: generate tab for a tree with an array]\n\t * @param  {array}  array [description]\n\t * @param  {number} index [description]\n\t * @param  {number} min   [description]\n\t * @return {string}       [description]\n\t */\n\tgetLevelTab: (array, index, min) => {\n\t\tlet ret = '';\n\n\t\tif (index === 0) {\n\t\t\tif (array[index] !== min) {\n\t\t\t\tfor (let i = min; i < array[index]; i++) {\n\t\t\t\t\tret += new Array(i - min + 1).join('\\t') + '- &nbsp; \\n';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (array[index] - array[index - 1] > 1) {\n\t\t\t\tfor (let i = array[index - 1] + 1; i < array[index]; i++) {\n\t\t\t\t\tret += new Array(i - min + 1).join('\\t') + '- &nbsp; \\n';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn ret + new Array(array[index] - min + 1).join('\\t');\n\t},\n\n\t/**\n\t * [initHeaders: get headers of a page]\n\t * @param  {string} content\n\t * @param  {object} options\n\t * @return {string}\n\t */\n\tinitHeaders: (content, {minHeaderCount: count, minHeaderDeep: deep, collapsed}) => {\n\t\tconst minHeaderCount = _.isNUM(parseInt(count)) ? parseInt(count) : 1;\n\t\tconst minHeaderDeep = _.isNUM(parseInt(deep)) ? parseInt(deep) : 1;\n\n\t\tconst res = [];\n\t\tconst levelTab = [];\n\t\tconst parentNodes = [];\n\n\t\tlet minLevel = 6;\n\n\t\tconst _calcLevel = str => (/^#+/.exec(str) || [''])[0].length;\n\t\tconst headers = [].concat(content.match(/^(#)+(\\s)*(.*)\\n/g))\n\t\t\t.concat(content.match(/\\n(#)+(\\s)*(.*)/g))\n\t\t\t.map(x => {\n\t\t\t\tif (x !== null) {\n\t\t\t\t\tlet ret = x.replaceAll('\\n', '');\n\n\t\t\t\t\t/** filter in code block and code line */\n\t\t\t\t\tconst codeBlock = content.match(/\\n```[a-zA-Z]*([\\s\\S]*?)```/g);\n\t\t\t\t\tconst codeLine = content.match(/\\n`[a-zA-Z]*([\\s\\S]*?)`/g);\n\n\t\t\t\t\tif (codeBlock !== null) {\n\t\t\t\t\t\tfor (let i = 0; i < codeBlock.length; i++) {\n\t\t\t\t\t\t\tif (codeBlock[i].indexOf(ret) >= 0) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (codeLine !== null) {\n\t\t\t\t\t\tfor (let i = 0; i < codeLine.length; i++) {\n\t\t\t\t\t\t\tif (codeLine[i].indexOf(ret) >= 0) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tret = ret.replace(/<.*?\\/>/g, '')\n\t\t\t\t\t\t.replace(/<.*?>(.*?)<\\/.*?>/g, '$1');\n\n\t\t\t\t\tconst level = _calcLevel(ret);\n\t\t\t\t\tif (level <= minLevel) {\n\t\t\t\t\t\tminLevel = level;\n\t\t\t\t\t}\n\n\t\t\t\t\tlevelTab.push(level);\n\n\t\t\t\t\treturn ret;\n\t\t\t\t} else {\n\t\t\t\t\treturn x;\n\t\t\t\t}\n\t\t\t});\n\n\t\tlet nullCount = 0;\n\t\tlet maxDeep = 0;\n\n\t\tfor (let i = 0; i < headers.length; i++) {\n\t\t\tif (headers[i] === null) {\n\t\t\t\tnullCount++;\n\t\t\t} else {\n\t\t\t\tconst value = headers[i].replace(new Array(_calcLevel(headers[i]) + 1).join('#'), '').leftTrim();\n\t\t\t\tconst tabs = pageTreeview.getLevelTab(levelTab, i - nullCount, minLevel);\n\t\t\t\tconst tabLen = levelTab[i - nullCount] - minLevel + 1;\n\n\t\t\t\tmaxDeep = maxDeep < tabLen ? tabLen : maxDeep;\n\n\t\t\t\tif (levelTab[i - nullCount] < levelTab[i + 1 - nullCount]) {\n\t\t\t\t\t/** it means that it's a current node */\n\t\t\t\t\tparentNodes.push(i - nullCount);\n\t\t\t\t}\n\n\t\t\t\tres.push(`${tabs}- [${RemoveMarkdown(pageTreeview.filterValue(value))}](#${pageTreeview.convertID(value)})`);\n\t\t\t}\n\t\t}\n\n\t\t/** check whether the number headers is greater than the value `minHeaderCount` */\n\t\tif (headers.length - nullCount < minHeaderCount && maxDeep < minHeaderDeep) {\n\t\t\treturn '';\n\t\t}\n\n\t\tlet generatedHTML = new Remarkable().render(res.join('\\n'));\n\n\t\t/** replace a tag with wrapped into a block */\n\t\tgeneratedHTML = generatedHTML.replace(/<a[\\s\\S]+?>[\\s\\S]+?<\\/a>/g, match => `<div>${match}<i></i></div>`);\n\n\t\t/** give a class name and event handler if it's parentNodes */\n\t\tlet node;\n\t\tlet currentNodeIndex = 0;\n\n\t\tconst regex = /<i[\\s\\S]+?<\\/i>/g;\n\t\twhile (node = regex.exec(generatedHTML)) {\n\t\t\tif (node.index === regex.lastIndex) {\n\t\t\t\t/** Don't let browsers get stuck in an infinite loop */\n\t\t\t\tregex.lastIndex++;\n\t\t\t}\n\n\t\t\tif (parentNodes.indexOf(currentNodeIndex++) > -1) {\n\t\t\t\t/** it's a parent node and replace it */\n\t\t\t\t/** the length of \"<div\" is 4 */\n\t\t\t\tconst separatorIndex = '<i'.length;\n\t\t\t\tconst state = collapsed ? 'hidden' : 'opened';\n\t\t\t\tgeneratedHTML = generatedHTML.substring(0, node.index + separatorIndex)\n\t\t\t\t\t+ ` class=\"level__parent level__item level__parent--${state}\" state=\"${state}\" onclick=\"`\n\t\t\t\t\t+ `var curState = this.getAttribute('state');`\n\t\t\t\t\t+ `var nextState = curState === 'opened' ? 'hidden' : 'opened';`\n\t\t\t\t\t+ `this.setAttribute('state', nextState);`\n\t\t\t\t\t+ 'this.className = this.className.split(curState).join(nextState);'\n\t\t\t\t\t+ ''\n\t\t\t\t\t+ 'var list = this.parentNode.nextElementSibling;'\n\t\t\t\t\t+ `if (nextState === 'hidden') {`\n\t\t\t\t\t+ `    list.style.display = 'none';`\n\t\t\t\t\t+ '} else {'\n\t\t\t\t\t+ `    list.style.display = 'block';`\n\t\t\t\t\t+ '}'\n\t\t\t\t\t+ '\"'\n\t\t\t\t\t+ generatedHTML.substring(node.index + separatorIndex);\n\t\t\t}\n\t\t}\n\n\t\tif (collapsed) {\n\t\t\tconst {parse: parseHtml} = require('node-html-parser');\n\t\t\tconst ast = parseHtml(generatedHTML);\n\t\t\tast.querySelectorAll('ul')\n\t\t\t\t.forEach((node => node.parentNode && node.parentNode.tagName === 'li'\n\t\t\t\t\t&& node.parentNode.childNodes[0].nodeType !== 3 // has hook for collapsing (not text node before)\n\t\t\t\t\t&& (node.rawAttrs += `style=\"display: none;\"`))) // collapse submenu\n\t\t\treturn ast.toString();\n\t\t}\n\n\t\treturn generatedHTML;\n\t},\n\n\t/**\n\t * escape cases: \"[sub] title [back]()\" => \"&#91;sub&#93; title [back]()\"\n\t * [filterValue: filter value of headers]\n\t *\n\t * @param  {string} str [description]\n\t * @return {string}     [description]\n\t */\n\tfilterValue: str => str.replace(/^\\[(.+?)](?!\\()+/g, ($0, $1) => `${_.A2U('[')}${$1}${_.A2U(']')}`),\n\n\t/**\n\t * [convertID: convert a markdown string into a id generated by gitbook]\n\t * @param  {string} str [description]\n\t * @return {string}     [description]\n\t */\n\tconvertID: str => RemoveMarkdown(\n\t\t/** convert \\t into ---- */\n\t\t_.E2A(str.replaceAll('\\t', '----')\n\t\t/** remove “ and ” */\n\t\t\t.replaceAll('“', '')\n\t\t\t.replaceAll('”', '')\n\t\t\t.toLowerCase()\n\t\t\t.trim()\n\t\t\t.replaceAll(' ', '-'))).split('')\n\t\t.filter(str => /** alpha */(str.charCodeAt(0) >= 97 && str.charCodeAt(0) <= 122)\n\t\t\t|| str.charCodeAt(0) === 45\n\t\t\t|| str.charCodeAt(0) > 126\n\t\t\t|| str.charCodeAt(0) >= 48 && str.charCodeAt(0) <= 57)\n\t\t.join('')\n\t\t.replace(/^-/, ''),\n};\n"]}