{"version":3,"file":"footnote.js","names":["define","_exports","_pluginApi","_discourseI18n","_richEditorExtension","Object","defineProperty","value","default","name","initialize","withPluginApi","api","registerRichEditorExtension","addComposerToolbarPopupMenuOption","action","event","addText","i18n","group","icon","label","_core","_iconLibrary","inlineFootnotePopper","footnoteEventHandler","tooltip","document","getElementById","displayedFootnoteId","dataset","footnoteId","expandableFootnote","target","destroy","removeAttribute","classList","contains","preventDefault","stopPropagation","footnoteContent","querySelector","cooked","closest","refPostId","newContent","innerHTML","show","createPopper","modifiers","options","element","altAxis","padding","offset","container","lookup","display_footnotes_inline","body","append","template","createElement","trim","content","firstChild","buildTooltip","window","addEventListener","decorateCookedElement","elem","footnoteRefs","querySelectorAll","forEach","footnoteRef","refLink","add","iconHTML","href","role","getAttribute","after","length","applyInlineFootnotes","onlyStream","id","onPageChange","teardown","removeEventListener","remove","setup","helper","registerOptions","opts","siteSettings","features","markdownitFootnote","enable_markdown_footnotes","allowList","custom","tag","match","registerPlugin","extension","nodeViews","footnote","_ref","pmView","EditorView","pmState","EditorState","pmTransform","StepMap","constructor","node","view","getPos","this","outerView","dom","className","innerView","selectNode","open","deselectNode","close","appendChild","style","setProperty","getFootnoteCounterValue","state","create","doc","plugins","filter","plugin","test","key","dispatchTransaction","dispatchInner","bind","handleDOMEvents","mousedown","hasFocus","focus","footnotes","Array","from","indexOf","textContent","tr","transactions","applyTransaction","updateState","getMeta","outerTr","offsetMap","i","steps","j","step","map","docChanged","dispatch","update","sameMarkup","start","findDiffStart","a","endA","b","endB","findDiffEnd","overlap","Math","min","replace","slice","setMeta","stopEvent","ignoreMutation","nodeSpec","attrs","inline","atom","draggable","parseDOM","toDOM","class","parse","_ref2","pmModel","Slice","Fragment","footnote_ref","getAttrs","token","meta","footnote_block","ignore","footnote_open","tokens","top","innerTokens","footnoteCloseIndex","findIndex","t","type","pos","replacements","descendants","child","childPos","stack","openNode","schema","nodes","parseTokens","closeNode","push","to","splice","footnote_anchor","noCloseToken","serializeNode","write","renderContent","contents","footnoteContents","afterSerialize","oldDelim","delim","inputRules","handler","end","paragraph","replaceWith"],"sources":["discourse/plugins/footnote/initializers/composer.js","discourse/plugins/footnote/initializers/inline-footnotes.js","discourse/plugins/footnote/lib/discourse-markdown/footnotes.js","discourse/plugins/footnote/lib/rich-editor-extension.js"],"sourcesContent":["define(\"discourse/plugins/footnote/initializers/composer\", [\"exports\", \"discourse/lib/plugin-api\", \"discourse-i18n\", \"discourse/plugins/footnote/lib/rich-editor-extension\"], function (_exports, _pluginApi, _discourseI18n, _richEditorExtension) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports.default = void 0;\n var _default = _exports.default = {\n name: \"footnotes-composer\",\n initialize() {\n (0, _pluginApi.withPluginApi)(api => {\n api.registerRichEditorExtension(_richEditorExtension.default);\n api.addComposerToolbarPopupMenuOption({\n action(event) {\n event.addText(`^[${(0, _discourseI18n.i18n)(\"footnote.title\")}]`);\n },\n group: \"insertions\",\n icon: \"asterisk\",\n label: \"footnote.add\"\n });\n });\n }\n };\n});","define(\"discourse/plugins/footnote/initializers/inline-footnotes\", [\"exports\", \"@popperjs/core\", \"discourse/lib/icon-library\", \"discourse/lib/plugin-api\"], function (_exports, _core, _iconLibrary, _pluginApi) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports.default = void 0;\n let inlineFootnotePopper;\n function applyInlineFootnotes(elem) {\n const footnoteRefs = elem.querySelectorAll(\"sup.footnote-ref\");\n footnoteRefs.forEach(footnoteRef => {\n const refLink = footnoteRef.querySelector(\"a\");\n if (!refLink) {\n return;\n }\n const expandableFootnote = document.createElement(\"a\");\n expandableFootnote.classList.add(\"expand-footnote\");\n expandableFootnote.innerHTML = (0, _iconLibrary.iconHTML)(\"ellipsis\");\n expandableFootnote.href = \"\";\n expandableFootnote.role = \"button\";\n expandableFootnote.dataset.footnoteId = refLink.getAttribute(\"href\");\n footnoteRef.after(expandableFootnote);\n });\n if (footnoteRefs.length) {\n elem.classList.add(\"inline-footnotes\");\n }\n }\n function buildTooltip() {\n const template = document.createElement(\"template\");\n template.innerHTML = `\n