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EAAQ,SAAS,IACvD,GAAQ,EACR,EAAO,OAGR,OAAG,uBAAuB,OAAS,uBAAuB,KAAK,MAAM,GAC7D,cAED,IACR,GAGG,EAAO,EAAQ,mBAAmB,QACrC,EAAQ,EAAO,UAAY,cAG5B,OAAO,EAAQ,mBAAmB,YAAY,EAAM,GAAS,EAC9D,KAxFC,QAAQ,IAAI,2GAyFd,CAIA,uBAAuB,WAAa,EACpC,uBAAuB,aAAc,EACrC,uBAAuB,aAAc,EACrC,uBAAuB,SAAW,GAClC,uBAAuB,SAAW,GAClC,uBAAuB,KAIvB,OAAO,QAAU","file":"/npm/codemirror-spell-checker@1.1.2/src/js/spell-checker.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/codemirror-spell-checker@1.1.2/src/js/spell-checker.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 mode (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)\n\"use strict\";\n\n\n// Requires\nvar Typo = require(\"typo-js\");\n\n\n// Create function\nfunction CodeMirrorSpellChecker(options) {\n\t// Initialize\n\toptions = options || {};\n\n\n\t// Verify\n\tif(typeof options.codeMirrorInstance !== \"function\" || typeof options.codeMirrorInstance.defineMode !== \"function\") {\n\t\tconsole.log(\"CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`\");\n\t\treturn;\n\t}\n\n\n\t// Because some browsers don't support this functionality yet\n\tif(!String.prototype.includes) {\n\t\tString.prototype.includes = function() {\n\t\t\t\"use strict\";\n\t\t\treturn String.prototype.indexOf.apply(this, arguments) !== -1;\n\t\t};\n\t}\n\n\n\t// Define the new mode\n\toptions.codeMirrorInstance.defineMode(\"spell-checker\", function(config) {\n\t\t// Load AFF/DIC data\n\t\tif(!CodeMirrorSpellChecker.aff_loading) {\n\t\t\tCodeMirrorSpellChecker.aff_loading = true;\n\t\t\tvar xhr_aff = new XMLHttpRequest();\n\t\t\txhr_aff.open(\"GET\", \"https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff\", true);\n\t\t\txhr_aff.onload = function() {\n\t\t\t\tif(xhr_aff.readyState === 4 && xhr_aff.status === 200) {\n\t\t\t\t\tCodeMirrorSpellChecker.aff_data = xhr_aff.responseText;\n\t\t\t\t\tCodeMirrorSpellChecker.num_loaded++;\n\n\t\t\t\t\tif(CodeMirrorSpellChecker.num_loaded == 2) {\n\t\t\t\t\t\tCodeMirrorSpellChecker.typo = new Typo(\"en_US\", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {\n\t\t\t\t\t\t\tplatform: \"any\"\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\txhr_aff.send(null);\n\t\t}\n\n\t\tif(!CodeMirrorSpellChecker.dic_loading) {\n\t\t\tCodeMirrorSpellChecker.dic_loading = true;\n\t\t\tvar xhr_dic = new XMLHttpRequest();\n\t\t\txhr_dic.open(\"GET\", \"https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic\", true);\n\t\t\txhr_dic.onload = function() {\n\t\t\t\tif(xhr_dic.readyState === 4 && xhr_dic.status === 200) {\n\t\t\t\t\tCodeMirrorSpellChecker.dic_data = xhr_dic.responseText;\n\t\t\t\t\tCodeMirrorSpellChecker.num_loaded++;\n\n\t\t\t\t\tif(CodeMirrorSpellChecker.num_loaded == 2) {\n\t\t\t\t\t\tCodeMirrorSpellChecker.typo = new Typo(\"en_US\", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {\n\t\t\t\t\t\t\tplatform: \"any\"\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\txhr_dic.send(null);\n\t\t}\n\n\n\t\t// Define what separates a word\n\t\tvar rx_word = \"!\\\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~ \";\n\n\n\t\t// Create the overlay and such\n\t\tvar overlay = {\n\t\t\ttoken: function(stream) {\n\t\t\t\tvar ch = stream.peek();\n\t\t\t\tvar word = \"\";\n\n\t\t\t\tif(rx_word.includes(ch)) {\n\t\t\t\t\tstream.next();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\twhile((ch = stream.peek()) != null && !rx_word.includes(ch)) {\n\t\t\t\t\tword += ch;\n\t\t\t\t\tstream.next();\n\t\t\t\t}\n\n\t\t\t\tif(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word))\n\t\t\t\t\treturn \"spell-error\"; // CSS class: cm-spell-error\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t};\n\n\t\tvar mode = options.codeMirrorInstance.getMode(\n\t\t\tconfig, config.backdrop || \"text/plain\"\n\t\t);\n\n\t\treturn options.codeMirrorInstance.overlayMode(mode, overlay, true);\n\t});\n}\n\n\n// Initialize data globally to reduce memory consumption\nCodeMirrorSpellChecker.num_loaded = 0;\nCodeMirrorSpellChecker.aff_loading = false;\nCodeMirrorSpellChecker.dic_loading = false;\nCodeMirrorSpellChecker.aff_data = \"\";\nCodeMirrorSpellChecker.dic_data = \"\";\nCodeMirrorSpellChecker.typo;\n\n\n// Export\nmodule.exports = CodeMirrorSpellChecker;"]}