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AEX,GAAI,IAAW,EAAgB,EAAG,CAEnC,IADA,IAAI,EAAa,GACR,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CACnC,IAAI,EAAU,EAAM,GAEpB,KADgB,uBAAuB,IACtB,GAKb,MAJA,GAAc,EAAU,KACxB,GAKR,CACA,IACA,EAAa,EAAW,YACxB,EAAO,KAAK,cAAc,GAC9B,CACJ,CACA,OAAO,CACX,CACA,SAAS,6BAA6B,GAClC,OAAO,EAAM,KAAI,SAAU,GACvB,MAAsB,iBAAX,EACA,YAAY,YAAY,GAGxB,6BAA6B,EAE5C,GACJ,CACA,SAAS,aAAa,GAClB,OAAQ,EAAQ,MACZ,IAAK,MACD,OAAO,MAAM,aAAa,EAAQ,OACtC,IAAK,OACD,OAAO,OAAO,YAAY,EAAQ,OACtC,IAAK,SACD,OAAO,SAAS,cAAc,EAAQ,OAE9C,MAAO,EACX,CAIA,SAAS,uBAAuB,GAG5B,IAFA,IAAI,EAAQ,EAAK,MAAM,MACnB,EAAa,MACR,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CAGnC,IAFA,IAAI,EAAQ,EAAM,GAAG,MAAM,IACvB,EAAa,EACR,EAAI,EAAG,EAAI,EAAM,QACL,MAAb,EAAM,GADoB,IAG9B,IAEJ,IAAI,EAAc,KAAK,MAAM,EAAa,eACtC,EAAc,IACd,EAAa,EAErB,CACA,OAAO,CACX,CA1GA,QAAQ,IAAM,IA2Gd,QAAQ,uBAAyB","file":"/npm/natural-web@0.0.12/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/natural-web@0.0.12/dist/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","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar tokenizer_1 = require(\"./tokenizer\");\r\nvar script_1 = require(\"./parsers/script\");\r\nvar html_1 = require(\"./parsers/html\");\r\nvar css_1 = require(\"./parsers/css\");\r\nvar section_1 = require(\"./parsers/section\");\r\nvar renderer_1 = require(\"./renderer\");\r\nvar interpretation_1 = require(\"./interpretation\");\r\nvar SPACE_INDENTS = 4;\r\nfunction run(outline) {\r\n    var sections = extractSections(outline);\r\n    var levels = sections.map(function (section) { return extractLevels(section); });\r\n    var sectionSymbolGroups = levels.map(function (group) { return translateLevelGroupToSymbols(group); });\r\n    var sectionTypes = sectionSymbolGroups.map(function (section) { return section_1.parseSection(section); });\r\n    var intermediate = sectionTypes.map(function (section) {\r\n        return generateCode(section);\r\n    });\r\n    var sorted = intermediate.sort(function (a, b) {\r\n        if (a.type === 'script')\r\n            return -1;\r\n        return 0;\r\n    });\r\n    //fs.writeFileSync('./out.json', JSON.stringify(intermediate, null, 4));\r\n    return renderer_1.render(interpretation_1.interpret(sorted));\r\n}\r\nexports.run = run;\r\n/**\r\n * Processes a complete body (or outline) of code into sections which are processed individually\r\n */\r\nfunction extractSections(outline) {\r\n    var lines = outline.split('\\n');\r\n    var sections = [];\r\n    var inSection = false;\r\n    var entryIndentation = -1;\r\n    for (var i = 0; i < lines.length; i++) {\r\n        var line = lines[i];\r\n        if (line.trim() === '') {\r\n            inSection = false;\r\n            continue;\r\n        }\r\n        var indentation = getMinIndentationLevel(line);\r\n        if (inSection) {\r\n            if (indentation >= entryIndentation) {\r\n                sections[sections.length - 1] += \"\\n\" + line;\r\n            }\r\n            else {\r\n                inSection = false;\r\n            }\r\n        }\r\n        else {\r\n            sections.push(line);\r\n            inSection = true;\r\n            entryIndentation = indentation;\r\n        }\r\n    }\r\n    return sections;\r\n}\r\n/**\r\n * Processes an individual section of the document into an array of lines with potential recursive sub-arrays, essentially outlining the code's indentation\r\n */\r\nfunction extractLevels(section) {\r\n    var currentIndent = getMinIndentationLevel(section);\r\n    var lines = section.split('\\n');\r\n    var groups = [];\r\n    for (var i = 0; i < lines.length; i++) {\r\n        var line = lines[i];\r\n        var indent = getMinIndentationLevel(line);\r\n        if (indent === currentIndent) {\r\n            groups.push(line);\r\n        }\r\n        else if (indent === currentIndent + 1) {\r\n            var subContent = '';\r\n            for (var l = i; l < lines.length; l++) {\r\n                var subLine = lines[l];\r\n                var subIndent = getMinIndentationLevel(subLine);\r\n                if (subIndent >= indent) {\r\n                    subContent += subLine + '\\n';\r\n                    i++;\r\n                }\r\n                else {\r\n                    break;\r\n                }\r\n            }\r\n            i--;\r\n            subContent = subContent.trimRight();\r\n            groups.push(extractLevels(subContent));\r\n        }\r\n    }\r\n    return groups;\r\n}\r\nfunction translateLevelGroupToSymbols(group) {\r\n    return group.map(function (item) {\r\n        if (typeof (item) === 'string') {\r\n            return tokenizer_1.parseTokens(item);\r\n        }\r\n        else {\r\n            return translateLevelGroupToSymbols(item);\r\n        }\r\n    });\r\n}\r\nfunction generateCode(section) {\r\n    switch (section.type) {\r\n        case 'css':\r\n            return css_1.processStyle(section.lines);\r\n        case 'html':\r\n            return html_1.processHTML(section.lines);\r\n        case 'script':\r\n            return script_1.processScript(section.lines);\r\n    }\r\n    return '';\r\n}\r\n/**\r\n * Returns the base indentation level of a body of text\r\n */\r\nfunction getMinIndentationLevel(body) {\r\n    var lines = body.split('\\n');\r\n    var minIndents = 99999;\r\n    for (var i = 0; i < lines.length; i++) {\r\n        var chars = lines[i].split('');\r\n        var spaceCount = 0;\r\n        for (var l = 0; i < chars.length; l++) {\r\n            if (chars[l] !== ' ')\r\n                break;\r\n            spaceCount++;\r\n        }\r\n        var indentCount = Math.floor(spaceCount / SPACE_INDENTS);\r\n        if (indentCount < minIndents) {\r\n            minIndents = indentCount;\r\n        }\r\n    }\r\n    return minIndents;\r\n}\r\nexports.getMinIndentationLevel = getMinIndentationLevel;\r\n//fs.writeFileSync('./out.html', run(fs.readFileSync('./example.txt').toString()));\r\n"]}