var ZeroMd=function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;rt.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:A(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}("object"===("undefined"==typeof module?"undefined":n(module))?module.exports:{});try{regeneratorRuntime=w}catch(t){"object"===("undefined"==typeof globalThis?"undefined":n(globalThis))?globalThis.regeneratorRuntime=w:Function("r","regeneratorRuntime = r")(w)}var k=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(w,t);var e,n,o,c,f,h,v,g,b=(e=w,n=l(),function(){var t,r=u(e);if(n){var o=u(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return p(this,t)});function w(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,w),(e=b.call(this)).version="2.3.1",e.config=r(r({markedUrl:"https://cdn.jsdelivr.net/gh/markedjs/marked@2/marked.min.js",prismUrl:[["https://cdn.jsdelivr.net/gh/PrismJS/prism@1/prism.min.js","data-manual"],"https://cdn.jsdelivr.net/gh/PrismJS/prism@1/plugins/autoloader/prism-autoloader.min.js"],cssUrls:["https://cdn.jsdelivr.net/gh/sindresorhus/github-markdown-css@4/github-markdown.min.css","https://cdn.jsdelivr.net/gh/PrismJS/prism@1/themes/prism.min.css"],hostCss:":host{display:block;position:relative;contain:content;}:host([hidden]){display:none;}"},t),window.ZeroMdConfig),e.cache={},e.root=e.hasAttribute("no-shadow")?d(e):e.attachShadow({mode:"open"}),e.constructor.ready||(e.constructor.ready=Promise.all([!!window.marked||e.loadScript(e.config.markedUrl),!!window.Prism||e.loadScript(e.config.prismUrl)])),e.clicked=e.clicked.bind(d(e)),e.manualRender||e.render().then((function(){return setTimeout((function(){return e.goto(location.hash)}),250)})),e.observer=new MutationObserver(i(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.observeChanges(),e.manualRender){t.next=4;break}return t.next=4,e.render();case 4:case"end":return t.stop()}}),t)})))),e.observeChanges(),e}return o=w,c=[{key:"src",get:function(){return this.getAttribute("src")},set:function(t){this.reflect("src",t)}},{key:"manualRender",get:function(){return this.hasAttribute("manual-render")},set:function(t){this.reflect("manual-render",t)}},{key:"reflect",value:function(t,e){!1===e?this.removeAttribute(t):this.setAttribute(t,!0===e?"":e)}},{key:"attributeChangedCallback",value:function(t,e,r){"src"===t&&this.connected&&!this.manualRender&&r!==e&&this.render()}},{key:"connectedCallback",value:function(){var t=this;this.connected=!0,this.fire("zero-md-connected",{},{bubbles:!1,composed:!1}),this.waitForReady().then((function(){t.fire("zero-md-ready")})),this.shadowRoot&&this.shadowRoot.addEventListener("click",this.clicked)}},{key:"disconnectedCallback",value:function(){this.connected=!1,this.shadowRoot&&this.shadowRoot.removeEventListener("click",this.clicked)}},{key:"waitForReady",value:function(){var t=this,e=this.connected||new Promise((function(e){t.addEventListener("zero-md-connected",(function t(){this.removeEventListener("zero-md-connected",t),e()}))}));return Promise.all([this.constructor.ready,e])}},{key:"fire",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{bubbles:!0,composed:!0};e.msg&&console.warn(e.msg),this.dispatchEvent(new CustomEvent(t,r({detail:r({node:this},e)},n)))}},{key:"tick",value:function(){return new Promise((function(t){return requestAnimationFrame(t)}))}},{key:"arrify",value:function(t){return t?Array.isArray(t)?t:[t]:[]}},{key:"onload",value:function(t){return new Promise((function(e,r){t.onload=e,t.onerror=function(t){return r(t.path?t.path[0]:t.composedPath()[0])}}))}},{key:"loadScript",value:function(t){var e=this;return Promise.all(this.arrify(t).map((function(t){var r=y(e.arrify(t)),n=r[0],o=r.slice(1),i=document.createElement("script");return i.src=n,i.async=!1,o.forEach((function(t){return i.setAttribute(t,"")})),e.onload(document.head.appendChild(i))})))}},{key:"goto",value:function(t){if(t){var e=this.root.getElementById(t.substring(1));e&&e.scrollIntoView()}}},{key:"clicked",value:function(t){if(!(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||t.defaultPrevented)){var e=t.target.closest("a");e&&e.hash&&e.host===location.host&&e.pathname===location.pathname&&this.goto(e.hash)}}},{key:"dedent",value:function(t){var e=(t=t.replace(/^\n/,"")).match(/^\s+/);return e?t.replace(new RegExp("^".concat(e[0]),"gm"),""):t}},{key:"getBaseUrl",value:function(t){var e=document.createElement("a");return e.href=t,e.href.substring(0,e.href.lastIndexOf("/")+1)}},{key:"highlight",value:function(t){return new Promise((function(e){t.querySelectorAll('pre>code:not([class*="language-"])').forEach((function(t){var e=t.innerText.match(/^\s*").concat(e('template[data-merge="prepend"]')).concat(e("template:not([data-merge])")||r.reduce((function(t,e){return"".concat(t,'')}),"")).concat(e('template[data-merge="append"]'),"")}},{key:"buildMd",value:(g=i(regeneratorRuntime.mark((function t(){var e,n,o,a,c=this,u=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:{},n=function(){var t=i(regeneratorRuntime.mark((function t(){var n,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.src){t.next=2;break}return t.abrupt("return","");case 2:return t.next=4,fetch(c.src);case 4:if(!(n=t.sent).ok){t.next=12;break}return t.next=8,n.text();case 8:return o=t.sent,t.abrupt("return",window.marked(o,r({baseUrl:c.getBaseUrl(c.src)},e)));case 12:return c.fire("zero-md-error",{msg:"[zero-md] HTTP error ".concat(n.status," while fetching src"),status:n.status,src:c.src}),t.abrupt("return","");case 14:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),o=function(){var t=c.querySelector('script[type="text/markdown"]');if(!t)return"";var r=t.hasAttribute("data-dedent")?c.dedent(t.text):t.text;return window.marked(r,e)},t.t0='
'),t.next=6,n();case 6:if(t.t1=t.sent,t.t1){t.next=9;break}t.t1=o();case 9:return t.t2=t.t1,a=t.t0.concat.call(t.t0,t.t2,"
"),t.abrupt("return",a);case 12:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)})},{key:"stampStyles",value:(v=i(regeneratorRuntime.mark((function t(e){var r,n,o,i=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.makeNode(e),n=m(r.querySelectorAll('link[rel="stylesheet"]')),(o=m(this.root.children).find((function(t){return t.classList.contains("markdown-styles")})))?o.replaceWith(r):this.root.prepend(r),t.next=6,Promise.all(n.map((function(t){return i.onload(t)}))).catch((function(t){i.fire("zero-md-error",{msg:"[zero-md] An external stylesheet failed to load",status:void 0,src:t.href})}));case 6:case"end":return t.stop()}}),t,this)}))),function(t){return v.apply(this,arguments)})},{key:"stampBody",value:function(t){var e=this.makeNode(t),r=m(this.root.children).find((function(t){return t.classList.contains("markdown-body")}));return r?r.replaceWith(e):this.root.append(e),e}},{key:"observeChanges",value:function(){var t=this;this.observer.observe(this,{childList:!0}),this.querySelectorAll('template,script[type="text/markdown"]').forEach((function(e){t.observer.observe(e.content||e,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}))}},{key:"render",value:(h=i(regeneratorRuntime.mark((function t(){var e,r,n,o,i,a,c=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=c.length>0&&void 0!==c[0]?c[0]:{},t.next=3,this.waitForReady();case 3:if(r={},n=this.buildMd(e),(o=this.buildStyles())===this.cache.styles){t.next=13;break}return this.cache.styles=o,t.next=10,this.stampStyles(o);case 10:return r.styles=!0,t.next=13,this.tick();case 13:return t.next=15,n;case 15:if((i=t.sent)===this.cache.body){t.next=22;break}return this.cache.body=i,a=this.stampBody(i),r.body=!0,t.next=22,this.highlight(a);case 22:this.fire("zero-md-rendered",{stamped:r});case 23:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})}],f=[{key:"observedAttributes",get:function(){return["src"]}}],c&&a(o.prototype,c),f&&a(o,f),w}(h(HTMLElement));return customElements.define("zero-md",k),t.ZeroMd=k,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); //# sourceMappingURL=zero-md.legacy.min.js.map