mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 21:24:59 +05:00
2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
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;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function s(t,e){return s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},s(t,e)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function f(t,e,r){return f=l()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&s(o,r.prototype),o},f.apply(null,arguments)}function h(t){var e="function"==typeof Map?new Map:void 0;return h=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return f(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,t)},h(t)}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return d(t)}function y(t){return function(t){if(Array.isArray(t))return t}(t)||v(t)||g(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t){return function(t){if(Array.isArray(t))return b(t)}(t)||v(t)||g(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function g(t,e){if(t){if("string"==typeof t)return b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var w=function(t){var e,r=Object.prototype,o=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),a=new R(n||[]);return i._invoke=function(t,e,r){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return _()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=P(a,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=f(t,e,r);if("normal"===u.type){if(n=r.done?y:d,u.arg===m)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=y,r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};s(w,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(A([])));x&&x!==r&&o.call(x,a)&&(w=x);var j=b.prototype=v.prototype=Object.create(w);function E(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,a,c,u){var s=f(t[i],t,a);if("throw"!==s.type){var l=s.arg,h=l.value;return h&&"object"===n(h)&&o.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(h).then((function(t){l.value=t,c(l)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}}function P(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method))return m;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var o=f(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,m;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function A(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function r(){for(;++n<t.length;)if(o.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:_}}function _(){return{value:e,done:!0}}return g.prototype=b,s(j,"constructor",b),s(b,"constructor",g),g.displayName=s(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(j),t},t.awrap=function(t){return{__await:t}},E(O.prototype),s(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(j),s(j,u,"Generator"),s(j,a,(function(){return this})),s(j,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(S),!t)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=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<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=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*</)?"markup":t.innerText.match(/^\s*(\$|#)/)?"bash":"js";t.classList.add("language-".concat(e))}));try{window.Prism.highlightAllUnder(t,!0,e())}catch(r){window.Prism.highlightAllUnder(t),e()}}))}},{key:"makeNode",value:function(t){var e=document.createElement("template");return e.innerHTML=t,e.content.firstElementChild}},{key:"buildStyles",value:function(){var t=this,e=function(e){var r=t.querySelector(e);return r?r.innerHTML||" ":""},r=this.arrify(this.config.cssUrls);return'<div class="markdown-styles"><style>'.concat(this.config.hostCss,"</style>").concat(e('template[data-merge="prepend"]')).concat(e("template:not([data-merge])")||r.reduce((function(t,e){return"".concat(t,'<link rel="stylesheet" href="').concat(e,'">')}),"")).concat(e('template[data-merge="append"]'),"</div>")}},{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='<div class="markdown-body'.concat(e.classes?this.arrify(e.classes).reduce((function(t,e){return"".concat(t," ").concat(e)})," "):"",'">'),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,"</div>"),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
|