@webqit/subscript
Advanced tools
Comparing version 2.1.33 to 2.1.34
(()=>{function ee(b,t=!1){let n=b.split(/\n/g);if(n.length>1){for(;!n[0].trim().length;)n.shift();let i=n[t?1:0].split(/[^\s]/)[0].length;if(i)return n.map((e,r)=>{let l=e.substring(0,i);return l.trim().length?l.trim()==="}"&&r===n.length-1?"}":e:e.substring(i)}).join(` | ||
`)}return b}var te=b=>class extends b{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(n=>{if(n.includes("{")&&n.includes(":")&&n.includes(";")){let i=this.shadowRoot.appendChild(document.createElement("style"));i.textContent=n}else{let i=this.shadowRoot.appendChild(document.createElement("link"));i.setAttribute("rel","stylesheet"),i.setAttribute("href",n)}})}get css(){return[]}};var ae=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{},c=function(b){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,i={},e={manual:b.Prism&&b.Prism.manual,disableWorkerMessageHandler:b.Prism&&b.Prism.disableWorkerMessageHandler,util:{encode:function a(s){return s instanceof r?new r(s.type,a(s.content),s.alias):Array.isArray(s)?s.map(a):s.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(a){return Object.prototype.toString.call(a).slice(8,-1)},objId:function(a){return a.__id||Object.defineProperty(a,"__id",{value:++n}),a.__id},clone:function a(s,p){var d,u;switch(p=p||{},e.util.type(s)){case"Object":if(u=e.util.objId(s),p[u])return p[u];for(var y in d={},p[u]=d,s)s.hasOwnProperty(y)&&(d[y]=a(s[y],p));return d;case"Array":return u=e.util.objId(s),p[u]?p[u]:(d=[],p[u]=d,s.forEach(function(m,x){d[x]=a(m,p)}),d);default:return s}},getLanguage:function(a){for(;a;){var s=t.exec(a.className);if(s)return s[1].toLowerCase();a=a.parentElement}return"none"},setLanguage:function(a,s){a.className=a.className.replace(RegExp(t,"gi"),""),a.classList.add("language-"+s)},currentScript:function(){if(typeof document>"u")return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(d){var a=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(d.stack)||[])[1];if(a){var s=document.getElementsByTagName("script");for(var p in s)if(s[p].src==a)return s[p]}return null}},isActive:function(a,s,p){for(var d="no-"+s;a;){var u=a.classList;if(u.contains(s))return!0;if(u.contains(d))return!1;a=a.parentElement}return!!p}},languages:{plain:i,plaintext:i,text:i,txt:i,extend:function(a,s){var p=e.util.clone(e.languages[a]);for(var d in s)p[d]=s[d];return p},insertBefore:function(a,s,p,d){var u=(d=d||e.languages)[a],y={};for(var m in u)if(u.hasOwnProperty(m)){if(m==s)for(var x in p)p.hasOwnProperty(x)&&(y[x]=p[x]);p.hasOwnProperty(m)||(y[m]=u[m])}var A=d[a];return d[a]=y,e.languages.DFS(e.languages,function(F,T){T===A&&F!=a&&(this[F]=y)}),y},DFS:function a(s,p,d,u){u=u||{};var y=e.util.objId;for(var m in s)if(s.hasOwnProperty(m)){p.call(s,m,s[m],d||m);var x=s[m],A=e.util.type(x);A!=="Object"||u[y(x)]?A!=="Array"||u[y(x)]||(u[y(x)]=!0,a(x,p,m,u)):(u[y(x)]=!0,a(x,p,null,u))}}},plugins:{},highlightAll:function(a,s){e.highlightAllUnder(document,a,s)},highlightAllUnder:function(a,s,p){var d={callback:p,container:a,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};e.hooks.run("before-highlightall",d),d.elements=Array.prototype.slice.apply(d.container.querySelectorAll(d.selector)),e.hooks.run("before-all-elements-highlight",d);for(var u,y=0;u=d.elements[y++];)e.highlightElement(u,s===!0,d.callback)},highlightElement:function(a,s,p){var d=e.util.getLanguage(a),u=e.languages[d];e.util.setLanguage(a,d);var y=a.parentElement;y&&y.nodeName.toLowerCase()==="pre"&&e.util.setLanguage(y,d);var m={element:a,language:d,grammar:u,code:a.textContent};function x(F){m.highlightedCode=F,e.hooks.run("before-insert",m),m.element.innerHTML=m.highlightedCode,e.hooks.run("after-highlight",m),e.hooks.run("complete",m),p&&p.call(m.element)}if(e.hooks.run("before-sanity-check",m),(y=m.element.parentElement)&&y.nodeName.toLowerCase()==="pre"&&!y.hasAttribute("tabindex")&&y.setAttribute("tabindex","0"),!m.code)return e.hooks.run("complete",m),void(p&&p.call(m.element));if(e.hooks.run("before-highlight",m),m.grammar)if(s&&b.Worker){var A=new Worker(e.filename);A.onmessage=function(F){x(F.data)},A.postMessage(JSON.stringify({language:m.language,code:m.code,immediateClose:!0}))}else x(e.highlight(m.code,m.grammar,m.language));else x(e.util.encode(m.code))},highlight:function(a,s,p){var d={code:a,grammar:s,language:p};if(e.hooks.run("before-tokenize",d),!d.grammar)throw new Error('The language "'+d.language+'" has no grammar.');return d.tokens=e.tokenize(d.code,d.grammar),e.hooks.run("after-tokenize",d),r.stringify(e.util.encode(d.tokens),d.language)},tokenize:function(a,s){var p=s.rest;if(p){for(var d in p)s[d]=p[d];delete s.rest}var u=new h;return f(u,u.head,a),function y(m,x,A,F,T,_){for(var C in A)if(A.hasOwnProperty(C)&&A[C]){var E=A[C];E=Array.isArray(E)?E:[E];for(var S=0;S<E.length;++S){if(_&&_.cause==C+","+S)return;var w=E[S],N=w.inside,I=!!w.lookbehind,H=!!w.greedy,G=w.alias;if(H&&!w.pattern.global){var ne=w.pattern.toString().match(/[imsuy]*$/)[0];w.pattern=RegExp(w.pattern.source,ne+"g")}for(var Q=w.pattern||w,L=F.next,$=T;L!==x.tail&&!(_&&$>=_.reach);$+=L.value.length,L=L.next){var j=L.value;if(x.length>m.length)return;if(!(j instanceof r)){var z,q=1;if(H){if(!(z=l(Q,$,m,I))||z.index>=m.length)break;var M=z.index,re=z.index+z[0].length,B=$;for(B+=L.value.length;B<=M;)L=L.next,B+=L.value.length;if(B-=L.value.length,$=B,L.value instanceof r)continue;for(var R=L;R!==x.tail&&(B<re||typeof R.value=="string");R=R.next)q++,B+=R.value.length;q--,j=m.slice($,B),z.index-=$}else if(!(z=l(Q,0,j,I)))continue;var M=z.index,W=z[0],J=j.slice(0,M),V=j.slice(M+W.length),U=$+j.length;_&&U>_.reach&&(_.reach=U);var Z=L.prev;J&&(Z=f(x,Z,J),$+=J.length),g(x,Z,q);var ie=new r(C,N?e.tokenize(W,N):W,G,W);if(L=f(x,Z,ie),V&&f(x,L,V),1<q){var X={cause:C+","+S,reach:U};y(m,x,A,L.prev,$,X),_&&X.reach>_.reach&&(_.reach=X.reach)}}}}}}(a,u,s,u.head,0),function(y){for(var m=[],x=y.head.next;x!==y.tail;)m.push(x.value),x=x.next;return m}(u)},hooks:{all:{},add:function(a,s){var p=e.hooks.all;p[a]=p[a]||[],p[a].push(s)},run:function(a,s){var p=e.hooks.all[a];if(p&&p.length)for(var d,u=0;d=p[u++];)d(s)}},Token:r};function r(a,s,p,d){this.type=a,this.content=s,this.alias=p,this.length=0|(d||"").length}function l(a,s,p,d){a.lastIndex=s;var u=a.exec(p);if(u&&d&&u[1]){var y=u[1].length;u.index+=y,u[0]=u[0].slice(y)}return u}function h(){var a={value:null,prev:null,next:null},s={value:null,prev:a,next:null};a.next=s,this.head=a,this.tail=s,this.length=0}function f(a,s,p){var d=s.next,u={value:p,prev:s,next:d};return s.next=u,d.prev=u,a.length++,u}function g(a,s,p){for(var d=s.next,u=0;u<p&&d!==a.tail;u++)d=d.next;(s.next=d).prev=s,a.length-=u}if(b.Prism=e,r.stringify=function a(s,p){if(typeof s=="string")return s;if(Array.isArray(s)){var d="";return s.forEach(function(A){d+=a(A,p)}),d}var u={type:s.type,content:a(s.content,p),tag:"span",classes:["token",s.type],attributes:{},language:p},y=s.alias;y&&(Array.isArray(y)?Array.prototype.push.apply(u.classes,y):u.classes.push(y)),e.hooks.run("wrap",u);var m="";for(var x in u.attributes)m+=" "+x+'="'+(u.attributes[x]||"").replace(/"/g,""")+'"';return"<"+u.tag+' class="'+u.classes.join(" ")+'"'+m+">"+u.content+"</"+u.tag+">"},!b.document)return b.addEventListener&&(e.disableWorkerMessageHandler||b.addEventListener("message",function(a){var s=JSON.parse(a.data),p=s.language,d=s.code,u=s.immediateClose;b.postMessage(e.highlight(d,e.languages[p],p)),u&&b.close()},!1)),e;var v=e.util.currentScript();function o(){e.manual||e.highlightAll()}if(v&&(e.filename=v.src,v.hasAttribute("data-manual")&&(e.manual=!0)),!e.manual){var k=document.readyState;k==="loading"||k==="interactive"&&v&&v.defer?document.addEventListener("DOMContentLoaded",o):window.requestAnimationFrame?window.requestAnimationFrame(o):window.setTimeout(o,16)}return e}(ae);typeof module<"u"&&module.exports&&(module.exports=c),typeof global<"u"&&(global.Prism=c);c.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},c.languages.markup.tag.inside["attr-value"].inside.entity=c.languages.markup.entity,c.languages.markup.doctype.inside["internal-subset"].inside=c.languages.markup,c.hooks.add("wrap",function(b){b.type==="entity"&&(b.attributes.title=b.content.replace(/&/,"&"))}),Object.defineProperty(c.languages.markup.tag,"addInlined",{value:function(b,t){var n={};n["language-"+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:c.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};i["language-"+t]={pattern:/[\s\S]+/,inside:c.languages[t]};var e={};e[b]={pattern:RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[^])*?(?=</__>)".replace(/__/g,function(){return b}),"i"),lookbehind:!0,greedy:!0,inside:i},c.languages.insertBefore("markup","cdata",e)}}),Object.defineProperty(c.languages.markup.tag,"addAttribute",{value:function(b,t){c.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(`(^|["'\\s])(?:`+b+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:c.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),c.languages.html=c.languages.markup,c.languages.mathml=c.languages.markup,c.languages.svg=c.languages.markup,c.languages.xml=c.languages.extend("markup",{}),c.languages.ssml=c.languages.xml,c.languages.atom=c.languages.xml,c.languages.rss=c.languages.xml;(function(b){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;b.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+`|(?:[^\\\\\r | ||
()"']|\\\\[^])*)\\)`,"i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},b.languages.css.atrule.inside.rest=b.languages.css;var n=b.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(c);c.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};c.languages.javascript=c.languages.extend("clike",{"class-name":[c.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),c.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,c.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:c.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:c.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:c.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:c.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:c.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),c.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:c.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),c.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),c.languages.markup&&(c.languages.markup.tag.addInlined("script","javascript"),c.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)","javascript")),c.languages.js=c.languages.javascript;(function(){if(typeof c<"u"&&typeof document<"u"&&document.querySelector){var b,t="line-numbers",n="linkable-line-numbers",i=function(){if(b===void 0){var o=document.createElement("div");o.style.fontSize="13px",o.style.lineHeight="1.5",o.style.padding="0",o.style.border="0",o.innerHTML=" <br /> ",document.body.appendChild(o),b=o.offsetHeight===38,document.body.removeChild(o)}return b},e=!0;c.plugins.lineHighlight={highlightLines:function(o,k,a){var s=(k=typeof k=="string"?k:o.getAttribute("data-line")||"").replace(/\s+/g,"").split(",").filter(Boolean),p=+o.getAttribute("data-line-offset")||0,d=(i()?parseInt:parseFloat)(getComputedStyle(o).lineHeight),u=c.util.isActive(o,t),y=o.querySelector("code"),m=u?o:y||o,x=[],A=y&&m!=y?function(_,C){var E=getComputedStyle(_),S=getComputedStyle(C);function w(N){return+N.substr(0,N.length-2)}return C.offsetTop+w(S.borderTopWidth)+w(S.paddingTop)-w(E.paddingTop)}(o,y):0;s.forEach(function(_){var C=_.split("-"),E=+C[0],S=+C[1]||E,w=o.querySelector('.line-highlight[data-range="'+_+'"]')||document.createElement("div");if(x.push(function(){w.setAttribute("aria-hidden","true"),w.setAttribute("data-range",_),w.className=(a||"")+" line-highlight"}),u&&c.plugins.lineNumbers){var N=c.plugins.lineNumbers.getLine(o,E),I=c.plugins.lineNumbers.getLine(o,S);if(N){var H=N.offsetTop+A+"px";x.push(function(){w.style.top=H})}if(I){var G=I.offsetTop-N.offsetTop+I.offsetHeight+"px";x.push(function(){w.style.height=G})}}else x.push(function(){w.setAttribute("data-start",String(E)),E<S&&w.setAttribute("data-end",String(S)),w.style.top=(E-p-1)*d+A+"px",w.textContent=new Array(S-E+2).join(` | ||
`)});x.push(function(){w.style.width=o.scrollWidth+"px"}),x.push(function(){m.appendChild(w)})});var F=o.id;if(u&&c.util.isActive(o,n)&&F){h(o,n)||x.push(function(){o.classList.add(n)});var T=parseInt(o.getAttribute("data-start")||"1");l(".line-numbers-rows > span",o).forEach(function(_,C){var E=C+T;_.onclick=function(){var S=F+"."+E;e=!1,location.hash=S,setTimeout(function(){e=!0},1)}})}return function(){x.forEach(f)}}};var r=0;c.hooks.add("before-sanity-check",function(o){var k=o.element.parentElement;if(g(k)){var a=0;l(".line-highlight",k).forEach(function(s){a+=s.textContent.length,s.parentNode.removeChild(s)}),a&&/^(?: \n)+$/.test(o.code.slice(-a))&&(o.code=o.code.slice(0,-a))}}),c.hooks.add("complete",function o(k){var a=k.element.parentElement;if(g(a)){clearTimeout(r);var s=c.plugins.lineNumbers,p=k.plugins&&k.plugins.lineNumbers;h(a,t)&&s&&!p?c.hooks.add("line-numbers",o):(c.plugins.lineHighlight.highlightLines(a)(),r=setTimeout(v,1))}}),window.addEventListener("hashchange",v),window.addEventListener("resize",function(){l("pre").filter(g).map(function(o){return c.plugins.lineHighlight.highlightLines(o)}).forEach(f)})}function l(o,k){return Array.prototype.slice.call((k||document).querySelectorAll(o))}function h(o,k){return o.classList.contains(k)}function f(o){o()}function g(o){return!(!o||!/pre/i.test(o.nodeName))&&(!!o.hasAttribute("data-line")||!(!o.id||!c.util.isActive(o,n)))}function v(){var o=location.hash.slice(1);l(".temporary.line-highlight").forEach(function(p){p.parentNode.removeChild(p)});var k=(o.match(/\.([\d,-]+)$/)||[,""])[1];if(k&&!document.getElementById(o)){var a=o.slice(0,o.lastIndexOf(".")),s=document.getElementById(a);s&&(s.hasAttribute("data-line")||s.setAttribute("data-line",""),c.plugins.lineHighlight.highlightLines(s,k,"temporary ")(),e&&document.querySelector(".temporary.line-highlight").scrollIntoView())}}})();(function(){if(typeof c<"u"&&typeof document<"u"){var b="line-numbers",t=/\n(?!$)/g,n=c.plugins.lineNumbers={getLine:function(r,l){if(r.tagName==="PRE"&&r.classList.contains(b)){var h=r.querySelector(".line-numbers-rows");if(h){var f=parseInt(r.getAttribute("data-start"),10)||1,g=f+(h.children.length-1);l<f&&(l=f),g<l&&(l=g);var v=l-f;return h.children[v]}}},resize:function(r){e([r])},assumeViewportIndependence:!0},i=void 0;window.addEventListener("resize",function(){n.assumeViewportIndependence&&i===window.innerWidth||(i=window.innerWidth,e(Array.prototype.slice.call(document.querySelectorAll("pre."+b))))}),c.hooks.add("complete",function(r){if(r.code){var l=r.element,h=l.parentNode;if(h&&/pre/i.test(h.nodeName)&&!l.querySelector(".line-numbers-rows")&&c.util.isActive(l,b)){l.classList.remove(b),h.classList.add(b);var f,g=r.code.match(t),v=g?g.length+1:1,o=new Array(v+1).join("<span></span>");(f=document.createElement("span")).setAttribute("aria-hidden","true"),f.className="line-numbers-rows",f.innerHTML=o,h.hasAttribute("data-start")&&(h.style.counterReset="linenumber "+(parseInt(h.getAttribute("data-start"),10)-1)),r.element.appendChild(f),e([h]),c.hooks.run("line-numbers",r)}}}),c.hooks.add("line-numbers",function(r){r.plugins=r.plugins||{},r.plugins.lineNumbers=!0})}function e(r){if((r=r.filter(function(h){var f=function(g){return g?window.getComputedStyle?getComputedStyle(g):g.currentStyle||null:null}(h)["white-space"];return f==="pre-wrap"||f==="pre-line"})).length!=0){var l=r.map(function(h){var f=h.querySelector("code"),g=h.querySelector(".line-numbers-rows");if(f&&g){var v=h.querySelector(".line-numbers-sizer"),o=f.textContent.split(t);v||((v=document.createElement("span")).className="line-numbers-sizer",f.appendChild(v)),v.innerHTML="0",v.style.display="block";var k=v.getBoundingClientRect().height;return v.innerHTML="",{element:h,lines:o,lineHeights:[],oneLinerHeight:k,sizer:v}}}).filter(Boolean);l.forEach(function(h){var f=h.sizer,g=h.lines,v=h.lineHeights,o=h.oneLinerHeight;v[g.length-1]=void 0,g.forEach(function(k,a){if(k&&1<k.length){var s=f.appendChild(document.createElement("span"));s.style.display="block",s.textContent=k}else v[a]=o})}),l.forEach(function(h){for(var f=h.sizer,g=h.lineHeights,v=0,o=0;o<g.length;o++)g[o]===void 0&&(g[o]=f.children[v++].getBoundingClientRect().height)}),l.forEach(function(h){var f=h.sizer,g=h.element.querySelector(".line-numbers-rows");f.style.display="none",f.innerHTML="",h.lineHeights.forEach(function(v,o){g.children[o].style.height=v+"px"})})}}})();(function(){if(typeof c<"u"&&typeof document<"u"){var b=[],t={},n=function(){};c.plugins.toolbar={};var i=c.plugins.toolbar.registerButton=function(r,l){var h;h=typeof l=="function"?l:function(f){var g;return typeof l.onClick=="function"?((g=document.createElement("button")).type="button",g.addEventListener("click",function(){l.onClick.call(this,f)})):typeof l.url=="string"?(g=document.createElement("a")).href=l.url:g=document.createElement("span"),l.className&&g.classList.add(l.className),g.textContent=l.text,g},r in t?console.warn('There is a button with the key "'+r+'" registered already.'):b.push(t[r]=h)},e=c.plugins.toolbar.hook=function(r){var l=r.element.parentNode;if(l&&/pre/i.test(l.nodeName)&&!l.parentNode.classList.contains("code-toolbar")){var h=document.createElement("div");h.classList.add("code-toolbar"),l.parentNode.insertBefore(h,l),h.appendChild(l);var f=document.createElement("div");f.classList.add("toolbar");var g=b,v=function(o){for(;o;){var k=o.getAttribute("data-toolbar-order");if(k!=null)return(k=k.trim()).length?k.split(/\s*,\s*/g):[];o=o.parentElement}}(r.element);v&&(g=v.map(function(o){return t[o]||n})),g.forEach(function(o){var k=o(r);if(k){var a=document.createElement("div");a.classList.add("toolbar-item"),a.appendChild(k),f.appendChild(a)}}),h.appendChild(f)}};i("label",function(r){var l=r.element.parentNode;if(l&&/pre/i.test(l.nodeName)&&l.hasAttribute("data-label")){var h,f,g=l.getAttribute("data-label");try{f=document.querySelector("template#"+g)}catch{}return f?h=f.content:(l.hasAttribute("data-url")?(h=document.createElement("a")).href=l.getAttribute("data-url"):h=document.createElement("span"),h.textContent=g),h}}),c.hooks.add("complete",e)}})();(function(){function b(n,i){n.addEventListener("click",function(){(function(e){navigator.clipboard?navigator.clipboard.writeText(e.getText()).then(e.success,function(){t(e)}):t(e)})(i)})}function t(n){var i=document.createElement("textarea");i.value=n.getText(),i.style.top="0",i.style.left="0",i.style.position="fixed",document.body.appendChild(i),i.focus(),i.select();try{var e=document.execCommand("copy");setTimeout(function(){e?n.success():n.error()},1)}catch(r){setTimeout(function(){n.error(r)},1)}document.body.removeChild(i)}typeof c<"u"&&typeof document<"u"&&(c.plugins.toolbar?c.plugins.toolbar.registerButton("copy-to-clipboard",function(n){var i=n.element,e=function(g){var v={copy:"Copy","copy-error":"Press Ctrl+C to copy","copy-success":"Copied!","copy-timeout":5e3};for(var o in v){for(var k="data-prismjs-"+o,a=g;a&&!a.hasAttribute(k);)a=a.parentElement;a&&(v[o]=a.getAttribute(k))}return v}(i),r=document.createElement("button");r.className="copy-to-clipboard-button",r.setAttribute("type","button");var l=document.createElement("span");return r.appendChild(l),f("copy"),b(r,{getText:function(){return i.textContent},success:function(){f("copy-success"),h()},error:function(){f("copy-error"),setTimeout(function(){(function(g){window.getSelection().selectAllChildren(g)})(i)},1),h()}}),r;function h(){setTimeout(function(){f("copy")},e["copy-timeout"])}function f(g){l.textContent=e[g],r.setAttribute("data-copy-state",g)}}):console.warn("Copy to Clipboard plugin loaded before Toolbar plugin."))})();(function(){if(typeof c<"u"&&typeof document<"u"){var b={"(":")","[":"]","{":"}"},t={"(":"brace-round","[":"brace-square","{":"brace-curly"},n={"${":"{"},i=0,e=/^(pair-\d+-)(close|open)$/;c.hooks.add("complete",function(v){var o=v.element,k=o.parentElement;if(k&&k.tagName=="PRE"){var a=[];if(c.util.isActive(o,"match-braces")&&a.push("(","[","{"),a.length!=0){k.__listenerAdded||(k.addEventListener("mousedown",function(){var u=k.querySelector("code"),y=r("brace-selected");Array.prototype.slice.call(u.querySelectorAll("."+y)).forEach(function(m){m.classList.remove(y)})}),Object.defineProperty(k,"__listenerAdded",{value:!0}));var s=Array.prototype.slice.call(o.querySelectorAll("span."+r("token")+"."+r("punctuation"))),p=[];a.forEach(function(u){for(var y=b[u],m=r(t[u]),x=[],A=[],F=0;F<s.length;F++){var T=s[F];if(T.childElementCount==0){var _=T.textContent;(_=n[_]||_)===u?(p.push({index:F,open:!0,element:T}),T.classList.add(m),T.classList.add(r("brace-open")),A.push(F)):_===y&&(p.push({index:F,open:!1,element:T}),T.classList.add(m),T.classList.add(r("brace-close")),A.length&&x.push([F,A.pop()]))}}x.forEach(function(C){var E="pair-"+i+++"-",S=s[C[0]],w=s[C[1]];S.id=E+"open",w.id=E+"close",[S,w].forEach(function(N){N.addEventListener("mouseenter",h),N.addEventListener("mouseleave",f),N.addEventListener("click",g)})})});var d=0;p.sort(function(u,y){return u.index-y.index}),p.forEach(function(u){u.open?(u.element.classList.add(r("brace-level-"+(d%12+1))),d++):(d=Math.max(0,d-1),u.element.classList.add(r("brace-level-"+(d%12+1))))})}}})}function r(v){var o=c.plugins.customClass;return o?o.apply(v,"none"):v}function l(v){var o=e.exec(v.id);return document.querySelector("#"+o[1]+(o[2]=="open"?"close":"open"))}function h(){c.util.isActive(this,"brace-hover",!0)&&[this,l(this)].forEach(function(v){v.classList.add(r("brace-hover"))})}function f(){[this,l(this)].forEach(function(v){v.classList.remove(r("brace-hover"))})}function g(){c.util.isActive(this,"brace-select",!0)&&[this,l(this)].forEach(function(v){v.classList.add(r("brace-selected"))})}})();var Y=b=>class extends te(b||HTMLElement){static get observedAttributes(){return["name","editable","placeholder"]}connectedCallback(){let t=n=>n.replace(new RegExp("&","g"),"&").replace(new RegExp("<","g"),"<");this._lang="javascript",this._editable=this.getAttribute("editable"),this._styledBlock=this.getAttribute("styled-block")||"pre",this._div=document.createElement("div"),this._preBlock=this._div.appendChild(document.createElement("pre")),this._codeBlock=this._preBlock.appendChild(document.createElement("code")),this._div.classList.add("line-numbers"),this._div.classList.add("container"),this._lang&&(this._preBlock.classList.add("language-"+this._lang),this._codeBlock.classList.add("language-"+this._lang)),this._contentSlot=document.createElement("slot"),this._contentSlot.setAttribute("aria-hidden","true"),this._contentSlot.setAttribute("hidden","true"),this._initialSlotEvent=!1,this._contentSlot.addEventListener("slotchange",()=>{let n=this._contentSlot.assignedNodes().reduce((i,e)=>i+(e.outerHTML||e.nodeValue||""),"");this._initialSlotEvent||(n=ee(n),this._initialSlotEvent=!0),this._textarea&&(this._textarea.value=n),this.source=t(n)}),this._editable==="true"&&this._addEditor(),this.shadowRoot.append(this._contentSlot,this._textarea||"",this._div),super.connectedCallback()}get source(){return this._codeBlock.textContent}set source(t){t.endsWith(` | ||
`)}return b}var te=b=>class extends b{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(n=>{if(n.includes("{")&&n.includes(":")&&n.includes(";")){let i=this.shadowRoot.appendChild(document.createElement("style"));i.textContent=n}else{let i=this.shadowRoot.appendChild(document.createElement("link"));i.setAttribute("rel","stylesheet"),i.setAttribute("href",n)}})}get css(){return[]}};var ae=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{},c=function(b){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,i={},e={manual:b.Prism&&b.Prism.manual,disableWorkerMessageHandler:b.Prism&&b.Prism.disableWorkerMessageHandler,util:{encode:function a(s){return s instanceof r?new r(s.type,a(s.content),s.alias):Array.isArray(s)?s.map(a):s.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(a){return Object.prototype.toString.call(a).slice(8,-1)},objId:function(a){return a.__id||Object.defineProperty(a,"__id",{value:++n}),a.__id},clone:function a(s,p){var d,u;switch(p=p||{},e.util.type(s)){case"Object":if(u=e.util.objId(s),p[u])return p[u];for(var y in d={},p[u]=d,s)s.hasOwnProperty(y)&&(d[y]=a(s[y],p));return d;case"Array":return u=e.util.objId(s),p[u]?p[u]:(d=[],p[u]=d,s.forEach(function(m,x){d[x]=a(m,p)}),d);default:return s}},getLanguage:function(a){for(;a;){var s=t.exec(a.className);if(s)return s[1].toLowerCase();a=a.parentElement}return"none"},setLanguage:function(a,s){a.className=a.className.replace(RegExp(t,"gi"),""),a.classList.add("language-"+s)},currentScript:function(){if(typeof document>"u")return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(d){var a=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(d.stack)||[])[1];if(a){var s=document.getElementsByTagName("script");for(var p in s)if(s[p].src==a)return s[p]}return null}},isActive:function(a,s,p){for(var d="no-"+s;a;){var u=a.classList;if(u.contains(s))return!0;if(u.contains(d))return!1;a=a.parentElement}return!!p}},languages:{plain:i,plaintext:i,text:i,txt:i,extend:function(a,s){var p=e.util.clone(e.languages[a]);for(var d in s)p[d]=s[d];return p},insertBefore:function(a,s,p,d){var u=(d=d||e.languages)[a],y={};for(var m in u)if(u.hasOwnProperty(m)){if(m==s)for(var x in p)p.hasOwnProperty(x)&&(y[x]=p[x]);p.hasOwnProperty(m)||(y[m]=u[m])}var A=d[a];return d[a]=y,e.languages.DFS(e.languages,function(F,T){T===A&&F!=a&&(this[F]=y)}),y},DFS:function a(s,p,d,u){u=u||{};var y=e.util.objId;for(var m in s)if(s.hasOwnProperty(m)){p.call(s,m,s[m],d||m);var x=s[m],A=e.util.type(x);A!=="Object"||u[y(x)]?A!=="Array"||u[y(x)]||(u[y(x)]=!0,a(x,p,m,u)):(u[y(x)]=!0,a(x,p,null,u))}}},plugins:{},highlightAll:function(a,s){e.highlightAllUnder(document,a,s)},highlightAllUnder:function(a,s,p){var d={callback:p,container:a,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};e.hooks.run("before-highlightall",d),d.elements=Array.prototype.slice.apply(d.container.querySelectorAll(d.selector)),e.hooks.run("before-all-elements-highlight",d);for(var u,y=0;u=d.elements[y++];)e.highlightElement(u,s===!0,d.callback)},highlightElement:function(a,s,p){var d=e.util.getLanguage(a),u=e.languages[d];e.util.setLanguage(a,d);var y=a.parentElement;y&&y.nodeName.toLowerCase()==="pre"&&e.util.setLanguage(y,d);var m={element:a,language:d,grammar:u,code:a.textContent};function x(F){m.highlightedCode=F,e.hooks.run("before-insert",m),m.element.innerHTML=m.highlightedCode,e.hooks.run("after-highlight",m),e.hooks.run("complete",m),p&&p.call(m.element)}if(e.hooks.run("before-sanity-check",m),(y=m.element.parentElement)&&y.nodeName.toLowerCase()==="pre"&&!y.hasAttribute("tabindex")&&y.setAttribute("tabindex","0"),!m.code)return e.hooks.run("complete",m),void(p&&p.call(m.element));if(e.hooks.run("before-highlight",m),m.grammar)if(s&&b.Worker){var A=new Worker(e.filename);A.onmessage=function(F){x(F.data)},A.postMessage(JSON.stringify({language:m.language,code:m.code,immediateClose:!0}))}else x(e.highlight(m.code,m.grammar,m.language));else x(e.util.encode(m.code))},highlight:function(a,s,p){var d={code:a,grammar:s,language:p};if(e.hooks.run("before-tokenize",d),!d.grammar)throw new Error('The language "'+d.language+'" has no grammar.');return d.tokens=e.tokenize(d.code,d.grammar),e.hooks.run("after-tokenize",d),r.stringify(e.util.encode(d.tokens),d.language)},tokenize:function(a,s){var p=s.rest;if(p){for(var d in p)s[d]=p[d];delete s.rest}var u=new h;return f(u,u.head,a),function y(m,x,A,F,T,w){for(var C in A)if(A.hasOwnProperty(C)&&A[C]){var E=A[C];E=Array.isArray(E)?E:[E];for(var S=0;S<E.length;++S){if(w&&w.cause==C+","+S)return;var _=E[S],N=_.inside,j=!!_.lookbehind,H=!!_.greedy,G=_.alias;if(H&&!_.pattern.global){var ne=_.pattern.toString().match(/[imsuy]*$/)[0];_.pattern=RegExp(_.pattern.source,ne+"g")}for(var Q=_.pattern||_,L=F.next,$=T;L!==x.tail&&!(w&&$>=w.reach);$+=L.value.length,L=L.next){var I=L.value;if(x.length>m.length)return;if(!(I instanceof r)){var z,q=1;if(H){if(!(z=l(Q,$,m,j))||z.index>=m.length)break;var M=z.index,re=z.index+z[0].length,B=$;for(B+=L.value.length;B<=M;)L=L.next,B+=L.value.length;if(B-=L.value.length,$=B,L.value instanceof r)continue;for(var P=L;P!==x.tail&&(B<re||typeof P.value=="string");P=P.next)q++,B+=P.value.length;q--,I=m.slice($,B),z.index-=$}else if(!(z=l(Q,0,I,j)))continue;var M=z.index,W=z[0],J=I.slice(0,M),V=I.slice(M+W.length),U=$+I.length;w&&U>w.reach&&(w.reach=U);var Z=L.prev;J&&(Z=f(x,Z,J),$+=J.length),g(x,Z,q);var ie=new r(C,N?e.tokenize(W,N):W,G,W);if(L=f(x,Z,ie),V&&f(x,L,V),1<q){var X={cause:C+","+S,reach:U};y(m,x,A,L.prev,$,X),w&&X.reach>w.reach&&(w.reach=X.reach)}}}}}}(a,u,s,u.head,0),function(y){for(var m=[],x=y.head.next;x!==y.tail;)m.push(x.value),x=x.next;return m}(u)},hooks:{all:{},add:function(a,s){var p=e.hooks.all;p[a]=p[a]||[],p[a].push(s)},run:function(a,s){var p=e.hooks.all[a];if(p&&p.length)for(var d,u=0;d=p[u++];)d(s)}},Token:r};function r(a,s,p,d){this.type=a,this.content=s,this.alias=p,this.length=0|(d||"").length}function l(a,s,p,d){a.lastIndex=s;var u=a.exec(p);if(u&&d&&u[1]){var y=u[1].length;u.index+=y,u[0]=u[0].slice(y)}return u}function h(){var a={value:null,prev:null,next:null},s={value:null,prev:a,next:null};a.next=s,this.head=a,this.tail=s,this.length=0}function f(a,s,p){var d=s.next,u={value:p,prev:s,next:d};return s.next=u,d.prev=u,a.length++,u}function g(a,s,p){for(var d=s.next,u=0;u<p&&d!==a.tail;u++)d=d.next;(s.next=d).prev=s,a.length-=u}if(b.Prism=e,r.stringify=function a(s,p){if(typeof s=="string")return s;if(Array.isArray(s)){var d="";return s.forEach(function(A){d+=a(A,p)}),d}var u={type:s.type,content:a(s.content,p),tag:"span",classes:["token",s.type],attributes:{},language:p},y=s.alias;y&&(Array.isArray(y)?Array.prototype.push.apply(u.classes,y):u.classes.push(y)),e.hooks.run("wrap",u);var m="";for(var x in u.attributes)m+=" "+x+'="'+(u.attributes[x]||"").replace(/"/g,""")+'"';return"<"+u.tag+' class="'+u.classes.join(" ")+'"'+m+">"+u.content+"</"+u.tag+">"},!b.document)return b.addEventListener&&(e.disableWorkerMessageHandler||b.addEventListener("message",function(a){var s=JSON.parse(a.data),p=s.language,d=s.code,u=s.immediateClose;b.postMessage(e.highlight(d,e.languages[p],p)),u&&b.close()},!1)),e;var v=e.util.currentScript();function o(){e.manual||e.highlightAll()}if(v&&(e.filename=v.src,v.hasAttribute("data-manual")&&(e.manual=!0)),!e.manual){var k=document.readyState;k==="loading"||k==="interactive"&&v&&v.defer?document.addEventListener("DOMContentLoaded",o):window.requestAnimationFrame?window.requestAnimationFrame(o):window.setTimeout(o,16)}return e}(ae);typeof module<"u"&&module.exports&&(module.exports=c),typeof global<"u"&&(global.Prism=c);c.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},c.languages.markup.tag.inside["attr-value"].inside.entity=c.languages.markup.entity,c.languages.markup.doctype.inside["internal-subset"].inside=c.languages.markup,c.hooks.add("wrap",function(b){b.type==="entity"&&(b.attributes.title=b.content.replace(/&/,"&"))}),Object.defineProperty(c.languages.markup.tag,"addInlined",{value:function(b,t){var n={};n["language-"+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:c.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};i["language-"+t]={pattern:/[\s\S]+/,inside:c.languages[t]};var e={};e[b]={pattern:RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[^])*?(?=</__>)".replace(/__/g,function(){return b}),"i"),lookbehind:!0,greedy:!0,inside:i},c.languages.insertBefore("markup","cdata",e)}}),Object.defineProperty(c.languages.markup.tag,"addAttribute",{value:function(b,t){c.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(`(^|["'\\s])(?:`+b+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:c.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),c.languages.html=c.languages.markup,c.languages.mathml=c.languages.markup,c.languages.svg=c.languages.markup,c.languages.xml=c.languages.extend("markup",{}),c.languages.ssml=c.languages.xml,c.languages.atom=c.languages.xml,c.languages.rss=c.languages.xml;(function(b){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;b.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+`|(?:[^\\\\\r | ||
()"']|\\\\[^])*)\\)`,"i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},b.languages.css.atrule.inside.rest=b.languages.css;var n=b.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(c);c.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/};c.languages.javascript=c.languages.extend("clike",{"class-name":[c.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp("(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])"),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),c.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,c.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:c.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:c.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:c.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:c.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:c.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),c.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:c.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),c.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),c.languages.markup&&(c.languages.markup.tag.addInlined("script","javascript"),c.languages.markup.tag.addAttribute("on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)","javascript")),c.languages.js=c.languages.javascript;(function(){if(typeof c<"u"&&typeof document<"u"&&document.querySelector){var b,t="line-numbers",n="linkable-line-numbers",i=function(){if(b===void 0){var o=document.createElement("div");o.style.fontSize="13px",o.style.lineHeight="1.5",o.style.padding="0",o.style.border="0",o.innerHTML=" <br /> ",document.body.appendChild(o),b=o.offsetHeight===38,document.body.removeChild(o)}return b},e=!0;c.plugins.lineHighlight={highlightLines:function(o,k,a){var s=(k=typeof k=="string"?k:o.getAttribute("data-line")||"").replace(/\s+/g,"").split(",").filter(Boolean),p=+o.getAttribute("data-line-offset")||0,d=(i()?parseInt:parseFloat)(getComputedStyle(o).lineHeight),u=c.util.isActive(o,t),y=o.querySelector("code"),m=u?o:y||o,x=[],A=y&&m!=y?function(w,C){var E=getComputedStyle(w),S=getComputedStyle(C);function _(N){return+N.substr(0,N.length-2)}return C.offsetTop+_(S.borderTopWidth)+_(S.paddingTop)-_(E.paddingTop)}(o,y):0;s.forEach(function(w){var C=w.split("-"),E=+C[0],S=+C[1]||E,_=o.querySelector('.line-highlight[data-range="'+w+'"]')||document.createElement("div");if(x.push(function(){_.setAttribute("aria-hidden","true"),_.setAttribute("data-range",w),_.className=(a||"")+" line-highlight"}),u&&c.plugins.lineNumbers){var N=c.plugins.lineNumbers.getLine(o,E),j=c.plugins.lineNumbers.getLine(o,S);if(N){var H=N.offsetTop+A+"px";x.push(function(){_.style.top=H})}if(j){var G=j.offsetTop-N.offsetTop+j.offsetHeight+"px";x.push(function(){_.style.height=G})}}else x.push(function(){_.setAttribute("data-start",String(E)),E<S&&_.setAttribute("data-end",String(S)),_.style.top=(E-p-1)*d+A+"px",_.textContent=new Array(S-E+2).join(` | ||
`)});x.push(function(){_.style.width=o.scrollWidth+"px"}),x.push(function(){m.appendChild(_)})});var F=o.id;if(u&&c.util.isActive(o,n)&&F){h(o,n)||x.push(function(){o.classList.add(n)});var T=parseInt(o.getAttribute("data-start")||"1");l(".line-numbers-rows > span",o).forEach(function(w,C){var E=C+T;w.onclick=function(){var S=F+"."+E;e=!1,location.hash=S,setTimeout(function(){e=!0},1)}})}return function(){x.forEach(f)}}};var r=0;c.hooks.add("before-sanity-check",function(o){var k=o.element.parentElement;if(g(k)){var a=0;l(".line-highlight",k).forEach(function(s){a+=s.textContent.length,s.parentNode.removeChild(s)}),a&&/^(?: \n)+$/.test(o.code.slice(-a))&&(o.code=o.code.slice(0,-a))}}),c.hooks.add("complete",function o(k){var a=k.element.parentElement;if(g(a)){clearTimeout(r);var s=c.plugins.lineNumbers,p=k.plugins&&k.plugins.lineNumbers;h(a,t)&&s&&!p?c.hooks.add("line-numbers",o):(c.plugins.lineHighlight.highlightLines(a)(),r=setTimeout(v,1))}}),window.addEventListener("hashchange",v),window.addEventListener("resize",function(){l("pre").filter(g).map(function(o){return c.plugins.lineHighlight.highlightLines(o)}).forEach(f)})}function l(o,k){return Array.prototype.slice.call((k||document).querySelectorAll(o))}function h(o,k){return o.classList.contains(k)}function f(o){o()}function g(o){return!(!o||!/pre/i.test(o.nodeName))&&(!!o.hasAttribute("data-line")||!(!o.id||!c.util.isActive(o,n)))}function v(){var o=location.hash.slice(1);l(".temporary.line-highlight").forEach(function(p){p.parentNode.removeChild(p)});var k=(o.match(/\.([\d,-]+)$/)||[,""])[1];if(k&&!document.getElementById(o)){var a=o.slice(0,o.lastIndexOf(".")),s=document.getElementById(a);s&&(s.hasAttribute("data-line")||s.setAttribute("data-line",""),c.plugins.lineHighlight.highlightLines(s,k,"temporary ")(),e&&document.querySelector(".temporary.line-highlight").scrollIntoView())}}})();(function(){if(typeof c<"u"&&typeof document<"u"){var b="line-numbers",t=/\n(?!$)/g,n=c.plugins.lineNumbers={getLine:function(r,l){if(r.tagName==="PRE"&&r.classList.contains(b)){var h=r.querySelector(".line-numbers-rows");if(h){var f=parseInt(r.getAttribute("data-start"),10)||1,g=f+(h.children.length-1);l<f&&(l=f),g<l&&(l=g);var v=l-f;return h.children[v]}}},resize:function(r){e([r])},assumeViewportIndependence:!0},i=void 0;window.addEventListener("resize",function(){n.assumeViewportIndependence&&i===window.innerWidth||(i=window.innerWidth,e(Array.prototype.slice.call(document.querySelectorAll("pre."+b))))}),c.hooks.add("complete",function(r){if(r.code){var l=r.element,h=l.parentNode;if(h&&/pre/i.test(h.nodeName)&&!l.querySelector(".line-numbers-rows")&&c.util.isActive(l,b)){l.classList.remove(b),h.classList.add(b);var f,g=r.code.match(t),v=g?g.length+1:1,o=new Array(v+1).join("<span></span>");(f=document.createElement("span")).setAttribute("aria-hidden","true"),f.className="line-numbers-rows",f.innerHTML=o,h.hasAttribute("data-start")&&(h.style.counterReset="linenumber "+(parseInt(h.getAttribute("data-start"),10)-1)),r.element.appendChild(f),e([h]),c.hooks.run("line-numbers",r)}}}),c.hooks.add("line-numbers",function(r){r.plugins=r.plugins||{},r.plugins.lineNumbers=!0})}function e(r){if((r=r.filter(function(h){var f=function(g){return g?window.getComputedStyle?getComputedStyle(g):g.currentStyle||null:null}(h)["white-space"];return f==="pre-wrap"||f==="pre-line"})).length!=0){var l=r.map(function(h){var f=h.querySelector("code"),g=h.querySelector(".line-numbers-rows");if(f&&g){var v=h.querySelector(".line-numbers-sizer"),o=f.textContent.split(t);v||((v=document.createElement("span")).className="line-numbers-sizer",f.appendChild(v)),v.innerHTML="0",v.style.display="block";var k=v.getBoundingClientRect().height;return v.innerHTML="",{element:h,lines:o,lineHeights:[],oneLinerHeight:k,sizer:v}}}).filter(Boolean);l.forEach(function(h){var f=h.sizer,g=h.lines,v=h.lineHeights,o=h.oneLinerHeight;v[g.length-1]=void 0,g.forEach(function(k,a){if(k&&1<k.length){var s=f.appendChild(document.createElement("span"));s.style.display="block",s.textContent=k}else v[a]=o})}),l.forEach(function(h){for(var f=h.sizer,g=h.lineHeights,v=0,o=0;o<g.length;o++)g[o]===void 0&&(g[o]=f.children[v++].getBoundingClientRect().height)}),l.forEach(function(h){var f=h.sizer,g=h.element.querySelector(".line-numbers-rows");f.style.display="none",f.innerHTML="",h.lineHeights.forEach(function(v,o){g.children[o].style.height=v+"px"})})}}})();(function(){if(typeof c<"u"&&typeof document<"u"){var b=[],t={},n=function(){};c.plugins.toolbar={};var i=c.plugins.toolbar.registerButton=function(r,l){var h;h=typeof l=="function"?l:function(f){var g;return typeof l.onClick=="function"?((g=document.createElement("button")).type="button",g.addEventListener("click",function(){l.onClick.call(this,f)})):typeof l.url=="string"?(g=document.createElement("a")).href=l.url:g=document.createElement("span"),l.className&&g.classList.add(l.className),g.textContent=l.text,g},r in t?console.warn('There is a button with the key "'+r+'" registered already.'):b.push(t[r]=h)},e=c.plugins.toolbar.hook=function(r){var l=r.element.parentNode;if(l&&/pre/i.test(l.nodeName)&&!l.parentNode.classList.contains("code-toolbar")){var h=document.createElement("div");h.classList.add("code-toolbar"),l.parentNode.insertBefore(h,l),h.appendChild(l);var f=document.createElement("div");f.classList.add("toolbar");var g=b,v=function(o){for(;o;){var k=o.getAttribute("data-toolbar-order");if(k!=null)return(k=k.trim()).length?k.split(/\s*,\s*/g):[];o=o.parentElement}}(r.element);v&&(g=v.map(function(o){return t[o]||n})),g.forEach(function(o){var k=o(r);if(k){var a=document.createElement("div");a.classList.add("toolbar-item"),a.appendChild(k),f.appendChild(a)}}),h.appendChild(f)}};i("label",function(r){var l=r.element.parentNode;if(l&&/pre/i.test(l.nodeName)&&l.hasAttribute("data-label")){var h,f,g=l.getAttribute("data-label");try{f=document.querySelector("template#"+g)}catch{}return f?h=f.content:(l.hasAttribute("data-url")?(h=document.createElement("a")).href=l.getAttribute("data-url"):h=document.createElement("span"),h.textContent=g),h}}),c.hooks.add("complete",e)}})();(function(){function b(n,i){n.addEventListener("click",function(){(function(e){navigator.clipboard?navigator.clipboard.writeText(e.getText()).then(e.success,function(){t(e)}):t(e)})(i)})}function t(n){var i=document.createElement("textarea");i.value=n.getText(),i.style.top="0",i.style.left="0",i.style.position="fixed",document.body.appendChild(i),i.focus(),i.select();try{var e=document.execCommand("copy");setTimeout(function(){e?n.success():n.error()},1)}catch(r){setTimeout(function(){n.error(r)},1)}document.body.removeChild(i)}typeof c<"u"&&typeof document<"u"&&(c.plugins.toolbar?c.plugins.toolbar.registerButton("copy-to-clipboard",function(n){var i=n.element,e=function(g){var v={copy:"Copy","copy-error":"Press Ctrl+C to copy","copy-success":"Copied!","copy-timeout":5e3};for(var o in v){for(var k="data-prismjs-"+o,a=g;a&&!a.hasAttribute(k);)a=a.parentElement;a&&(v[o]=a.getAttribute(k))}return v}(i),r=document.createElement("button");r.className="copy-to-clipboard-button",r.setAttribute("type","button");var l=document.createElement("span");return r.appendChild(l),f("copy"),b(r,{getText:function(){return i.textContent},success:function(){f("copy-success"),h()},error:function(){f("copy-error"),setTimeout(function(){(function(g){window.getSelection().selectAllChildren(g)})(i)},1),h()}}),r;function h(){setTimeout(function(){f("copy")},e["copy-timeout"])}function f(g){l.textContent=e[g],r.setAttribute("data-copy-state",g)}}):console.warn("Copy to Clipboard plugin loaded before Toolbar plugin."))})();(function(){if(typeof c<"u"&&typeof document<"u"){var b={"(":")","[":"]","{":"}"},t={"(":"brace-round","[":"brace-square","{":"brace-curly"},n={"${":"{"},i=0,e=/^(pair-\d+-)(close|open)$/;c.hooks.add("complete",function(v){var o=v.element,k=o.parentElement;if(k&&k.tagName=="PRE"){var a=[];if(c.util.isActive(o,"match-braces")&&a.push("(","[","{"),a.length!=0){k.__listenerAdded||(k.addEventListener("mousedown",function(){var u=k.querySelector("code"),y=r("brace-selected");Array.prototype.slice.call(u.querySelectorAll("."+y)).forEach(function(m){m.classList.remove(y)})}),Object.defineProperty(k,"__listenerAdded",{value:!0}));var s=Array.prototype.slice.call(o.querySelectorAll("span."+r("token")+"."+r("punctuation"))),p=[];a.forEach(function(u){for(var y=b[u],m=r(t[u]),x=[],A=[],F=0;F<s.length;F++){var T=s[F];if(T.childElementCount==0){var w=T.textContent;(w=n[w]||w)===u?(p.push({index:F,open:!0,element:T}),T.classList.add(m),T.classList.add(r("brace-open")),A.push(F)):w===y&&(p.push({index:F,open:!1,element:T}),T.classList.add(m),T.classList.add(r("brace-close")),A.length&&x.push([F,A.pop()]))}}x.forEach(function(C){var E="pair-"+i+++"-",S=s[C[0]],_=s[C[1]];S.id=E+"open",_.id=E+"close",[S,_].forEach(function(N){N.addEventListener("mouseenter",h),N.addEventListener("mouseleave",f),N.addEventListener("click",g)})})});var d=0;p.sort(function(u,y){return u.index-y.index}),p.forEach(function(u){u.open?(u.element.classList.add(r("brace-level-"+(d%12+1))),d++):(d=Math.max(0,d-1),u.element.classList.add(r("brace-level-"+(d%12+1))))})}}})}function r(v){var o=c.plugins.customClass;return o?o.apply(v,"none"):v}function l(v){var o=e.exec(v.id);return document.querySelector("#"+o[1]+(o[2]=="open"?"close":"open"))}function h(){c.util.isActive(this,"brace-hover",!0)&&[this,l(this)].forEach(function(v){v.classList.add(r("brace-hover"))})}function f(){[this,l(this)].forEach(function(v){v.classList.remove(r("brace-hover"))})}function g(){c.util.isActive(this,"brace-select",!0)&&[this,l(this)].forEach(function(v){v.classList.add(r("brace-selected"))})}})();var Y=b=>class extends te(b||HTMLElement){static get observedAttributes(){return["name","editable","placeholder"]}connectedCallback(){let t=n=>n.replace(new RegExp("&","g"),"&").replace(new RegExp("<","g"),"<");this._lang="javascript",this._editable=this.getAttribute("editable"),this._styledBlock=this.getAttribute("styled-block")||"pre",this._div=document.createElement("div"),this._preBlock=this._div.appendChild(document.createElement("pre")),this._codeBlock=this._preBlock.appendChild(document.createElement("code")),this._div.classList.add("line-numbers"),this._div.classList.add("container"),this._lang&&(this._preBlock.classList.add("language-"+this._lang),this._codeBlock.classList.add("language-"+this._lang)),this._contentSlot=document.createElement("slot"),this._contentSlot.setAttribute("aria-hidden","true"),this._contentSlot.setAttribute("hidden","true"),this._initialSlotEvent=!1,this._contentSlot.addEventListener("slotchange",()=>{let n=this._contentSlot.assignedNodes().reduce((i,e)=>i+(e.outerHTML||e.nodeValue||""),"");this._initialSlotEvent||(n=ee(n),this._initialSlotEvent=!0),this._textarea&&(this._textarea.value=n),this.source=t(n)}),this._editable==="true"&&this._addEditor(),this.shadowRoot.append(this._contentSlot,this._textarea||"",this._div),super.connectedCallback()}get source(){return this._codeBlock.textContent}set source(t){t.endsWith(` | ||
`)&&(t+=" "),this._codeBlock.innerHTML="",this._codeBlock.innerHTML=t,this._highlightCodeBlock(),this._syncScrolling()}get name(){return this._name}set name(t){return this.setAttribute("name",t)}get placeholder(){return this._placeholder}set placeholder(t){return this.setAttribute("placeholder",t)}get editable(){return this._editable}set editable(t){return this.setAttribute("editable",t===!0?"true":t===!1?"false":t)}_addEditor(){this._placeholder=this.getAttribute("placeholder"),this._name=this.getAttribute("name"),this._textarea=this._div.appendChild(document.createElement("textarea")),this._textarea.placeholder=this._placeholder||this._lang,this._textarea.spellcheck=!1,this._textarea.name=this._name||"",this._textarea.value=this._codeBlock.textContent,this._preBlock.setAttribute("aria-hidden","true"),this._scrollBlock=this.getAttribute("scroll-block")==="code"?this._codeBlock:this._preBlock,this._textarea.addEventListener("input",t=>{this.source=t.target.value}),this._textarea.addEventListener("input",()=>this._syncScrolling()),this._textarea.addEventListener("scroll",()=>this._syncScrolling()),this._textarea.addEventListener("keydown",t=>this._handleTabKeyEvent(t))}_handleTabKeyEvent(t){if(!this._textarea||t.key!=="Tab")return;t.preventDefault();let n=this._textarea.value,i=this._textarea.selectionStart,e=this._textarea.selectionEnd;if(i===e){let r=n.slice(0,i),l=n.slice(e,n.length),h=e+1;this._textarea.value=r+" "+l,this._textarea.selectionStart=h,this._textarea.selectionEnd=h}else{let r=n.split(` | ||
@@ -116,3 +116,3 @@ `),l=0,h=0,f=0;for(let g=0;g<r.length;g++)l+=r[g].length,i<l&&e>l-r[g].length&&(t.shiftKey?r[g][0]===" "&&(r[g]=r[g].slice(1),h===0&&f--,h--):(r[g]=" "+r[g],h===0&&f++,h++));this._textarea.value=r.join(` | ||
`]}};var D=b=>class extends(b||class{}){setStateCallback(t,n,i,e=100,r){this._timeouts||(this._timeouts={}),t in this._timeouts||(this._timeouts[t]=[]),i?(this._timeouts[t].length||r(),e?this._timeouts[t].unshift(setTimeout(()=>this.setState(t,n,!1),e)):this._timeouts[t].unshift(null),this._related&&this._related.setState(t,n,!0,e)):(this._timeouts[t].shift(),this._timeouts[t].length||(r(),this._related&&this._related.setState(t,n,!1)))}};var O=class extends D(){bind(t){Object.assign(this,t),this.fullPaths=[],this.$fullPaths=[],this.ownerReference.assignee&&this.ownerReference.assignee.refs.forEach(n=>{!n.depth||this.fullPaths.push([...this.path,...n.depth])}),this.fullPaths.length||(this.fullPaths=[this.path]),this.fullPaths.forEach((n,i)=>{this.$fullPaths.push(n.map(e=>"memoId"in e?"[[computed]]":e.name).join(".")),n.forEach(e=>{e.anchor.classList.add("ref-identifier"),e.anchor.classList.add(this.subscriptions?"effect":"signal");let r=e.anchor.getAttribute("title"),l="> "+this.$fullPaths[i]+(this.subscriptions?" (Effect Ref)":" (Signal Ref)");e.anchor.setAttribute("title",r?r+` | ||
`+l:l)}),this._on(i,"mouseenter",()=>{this._setState(i,"path","hover",!0,0)})._on(i,"mouseleave",()=>{this._setState(i,"path","hover",!1)}),this.subscriptions&&this._on(i,"click",()=>{this.ownerReference.ownerContract.runThread(n)})})}_setState(t,n,i,e,r=100){this.setStateCallback(t+"|"+n,i,e,r,()=>{e?this.fullPaths[t].forEach(l=>l.anchor.classList.add(`${n}-${i}`)):this.fullPaths[t].forEach(l=>l.anchor.classList.remove(`${n}-${i}`))})}setState(t,n,i,e=100){let[r,l]=t.split("|");if(l!==void 0)return this._setState(r,l,n,i,e);this.fullPaths.forEach((h,f)=>{this._setState(f,t,n,i,e)})}_on(t,n,i){return this.fullPaths[t].forEach(e=>e.anchor.addEventListener(n,i.bind(this))),this}on(t,n){this.fullPaths.forEach((i,e)=>{this._on(e,t,n)})}};var P=class extends D(HTMLElement){bind(t){if(Object.assign(this,t),!this.graph)return;this.subContracts&&this.subContracts.forEach(i=>{i.replaceWith(...i.childNodes)}),this.subContracts=new Map,this._textNodes=this.getTextNodes();for(let i in this.graph.subContracts){let e=this.graph.subContracts[i],r=this.createSubContract({ownerContract:this,graph:e});this.subContracts.set(e.id,r)}if(this.effects=new Map,this.signals=new Map,this.refAnchors)for(let i in this.refAnchors){let e=this.refAnchors[i];e.replaceWith(...e.childNodes)}this.refAnchors={},this._textNodes=this.getTextNodes();let n=i=>{for(let e in this.graph[i]){let r=this.createReference({ownerContract:this,...this.graph[i][e]});this[i].set(e,r)}};n("effects"),n("signals"),this.setAttribute("title",this.graph.type+" Contract"),this.on("mouseenter",()=>{this.setState("block","hover",!0,0)}).on("mouseleave",()=>{this.setState("block","hover",!1)}),this.observe((i,e)=>{this.setState("block","runtime-active",!0,100),e.forEach(r=>{let l=this.signals.get(r.referenceId+"");!l||l.refs.get(r.id).setState("path","runtime-active",!0,100)})})}get program(){return this.ownerContract?this.ownerContract.program:this.runtime}runThread(...t){let n=this.program.locate(this.graph.lineage);if(!!n)return n.thread(...t)}observe(t){return this.program.observe(this.graph.lineage,t)}createSubContract(t){let n=document.createElement("subscript-contract");return this.insertNode(n,t.graph.loc,"contract"),n.bind(t),n}createReference(t){let n={...t,refs:new Map};"assignee"in t&&(n.assignee=this.effects.get(t.assignee+""));for(let i of t.refs){let e=this.createRef({ownerReference:n,...i});n.refs.set(i.id,e)}return n}createRef(t){let n=new O,i=e=>{let[r,l]=e.loc,h=r+"-"+l,f=this.refAnchors[h];return f||(f=document.createElement("span"),this.insertNode(f,[r,l],"ref"),this.refAnchors[h]=f),f};return t={...t,path:t.path.map(e=>({anchor:i(e),...e}))},t.depth&&(t.depth=t.depth.map(e=>({anchor:i(e),...e}))),n.bind(t),n}insertNode(t,n,i){let[e,r]=n,l=this.graph.loc?this.graph.loc[0]:0,[h,f]=this.resolveOffset(e-l),[g,v]=this.resolveOffset(r-l,!1),o=new Range;return i==="contract"?(f===0&&h.parentNode.nodeName==="SPAN"?o.setStartBefore(h.parentNode):o.setStart(h,f),v===(g.nodeValue||"").length&&g.parentNode.nodeName==="SPAN"?o.setEndAfter(g.parentNode):o.setEnd(g,v)):(o.setStart(h,f),o.setEnd(g,v)),o.surroundContents(t),t}resolveOffset(t,n=!0){return this._textNodes.reduce(([i,e,r],l)=>{if(e===null){let h=r+l.length;if(t<=h&&!l.isBlank){let f=t-r;if(!n&&f===0)return[i.node,i.length];if(!n||f<l.length)return[l.node,f]}[i,e,r]=[l,e,h]}return[i,e,r]},[null,null,0])}getTextNodes(t=this){let n={acceptNode:function(l){if(l.parentNode.nodeName!=="SCRIPT")return window.NodeFilter.FILTER_ACCEPT}},i=window.document.createTreeWalker(t||this,window.NodeFilter.SHOW_TEXT,n,!1),e=[],r;for(;r=i.nextNode();){let l=r.nodeValue||"";e.push({node:r,length:l.length,isBlank:l.trim().length===0})}return e}setState(t,n,i,e=100){i&&this.ownerContract&&this.ownerContract.setState(t,n,!1),this.setStateCallback(t,n,i,e,()=>{i?this.classList.add(`${t}-${n}`):this.classList.remove(`${t}-${n}`)})}on(t,n){return this.addEventListener(t,n.bind(this)),this}};var K=class extends Y(P){bind(t,n=!0){n&&(this.innerHTML=t.originalSource),setTimeout(()=>{if(!this._codeBlock.textContent.length)return;let i=t.runtime;super.bind({runtime:i,graph:i.graph})},0)}createRef(t){}getTextNodes(t=null){return super.getTextNodes(t||this._codeBlock)}get css(){return super.css.concat([` | ||
`+l:l)}),this._on(i,"mouseenter",()=>{this._setState(i,"path","hover",!0,0)})._on(i,"mouseleave",()=>{this._setState(i,"path","hover",!1)}),this.subscriptions&&this._on(i,"click",()=>{this.ownerReference.ownerContract.runThread(n)})})}_setState(t,n,i,e,r=100){this.setStateCallback(t+"|"+n,i,e,r,()=>{e?this.fullPaths[t].forEach(l=>l.anchor.classList.add(`${n}-${i}`)):this.fullPaths[t].forEach(l=>l.anchor.classList.remove(`${n}-${i}`))})}setState(t,n,i,e=100){let[r,l]=t.split("|");if(l!==void 0)return this._setState(r,l,n,i,e);this.fullPaths.forEach((h,f)=>{this._setState(f,t,n,i,e)})}_on(t,n,i){return this.fullPaths[t].forEach(e=>e.anchor.addEventListener(n,i.bind(this))),this}on(t,n){this.fullPaths.forEach((i,e)=>{this._on(e,t,n)})}};var R=class extends D(HTMLElement){bind(t){if(Object.assign(this,t),!this.graph)return;this.subContracts&&this.subContracts.forEach(i=>{i.replaceWith(...i.childNodes)}),this.subContracts=new Map,this._textNodes=this.getTextNodes();for(let i in this.graph.subContracts){let e=this.graph.subContracts[i],r=this.createSubContract({ownerContract:this,graph:e});this.subContracts.set(e.id,r)}if(this.effects=new Map,this.signals=new Map,this.refAnchors)for(let i in this.refAnchors){let e=this.refAnchors[i];e.replaceWith(...e.childNodes)}this.refAnchors={},this._textNodes=this.getTextNodes();let n=i=>{for(let e in this.graph[i]){let r=this.createReference({ownerContract:this,...this.graph[i][e]});this[i].set(e,r)}};n("effects"),n("signals"),this.setAttribute("title",this.graph.type+" Contract"),this.on("mouseenter",()=>{this.setState("block","hover",!0,0)}).on("mouseleave",()=>{this.setState("block","hover",!1)}),this.observe((i,e)=>{this.setState("block","runtime-active",!0,100),e.forEach(r=>{let l=this.signals.get(r.referenceId+"");!l||l.refs.get(r.id).setState("path","runtime-active",!0,100)})})}get program(){return this.ownerContract?this.ownerContract.program:this.runtime}runThread(...t){let n=this.program.locate(this.graph.lineage);if(!!n)return n.thread(...t)}observe(t){return this.program.observe(this.graph.lineage,t)}createSubContract(t){let n=document.createElement("subscript-contract");return this.insertNode(n,t.graph.loc,"contract"),n.bind(t),n}createReference(t){let n={...t,refs:new Map};"assignee"in t&&(n.assignee=this.effects.get(t.assignee+""));for(let i of t.refs){let e=this.createRef({ownerReference:n,...i});n.refs.set(i.id,e)}return n}createRef(t){let n=new O,i=e=>{let[r,l]=e.loc,h=r+"-"+l,f=this.refAnchors[h];return f||(f=document.createElement("span"),this.insertNode(f,[r,l],"ref"),this.refAnchors[h]=f),f};return t={...t,path:t.path.map(e=>({anchor:i(e),...e}))},t.depth&&(t.depth=t.depth.map(e=>({anchor:i(e),...e}))),n.bind(t),n}insertNode(t,n,i){let[e,r]=n,l=this.graph.loc?this.graph.loc[0]:0,[h,f]=this.resolveOffset(e-l),[g,v]=this.resolveOffset(r-l,!1),o=new Range;return i==="contract"?(f===0&&h.parentNode.nodeName==="SPAN"?o.setStartBefore(h.parentNode):o.setStart(h,f),v===(g.nodeValue||"").length&&g.parentNode.nodeName==="SPAN"?o.setEndAfter(g.parentNode):o.setEnd(g,v)):(o.setStart(h,f),o.setEnd(g,v)),o.surroundContents(t),t}resolveOffset(t,n=!0){return this._textNodes.reduce(([i,e,r],l)=>{if(e===null){let h=r+l.length;if(t<=h&&!l.isBlank){let f=t-r;if(!n&&f===0)return[i.node,i.length];if(!n||f<l.length)return[l.node,f]}[i,e,r]=[l,e,h]}return[i,e,r]},[null,null,0])}getTextNodes(t=this){let n={acceptNode:function(l){if(l.parentNode.nodeName!=="SCRIPT")return window.NodeFilter.FILTER_ACCEPT}},i=window.document.createTreeWalker(t||this,window.NodeFilter.SHOW_TEXT,n,!1),e=[],r;for(;r=i.nextNode();){let l=r.nodeValue||"";e.push({node:r,length:l.length,isBlank:l.trim().length===0})}return e}setState(t,n,i,e=100){i&&this.ownerContract&&this.ownerContract.setState(t,n,!1),this.setStateCallback(t,n,i,e,()=>{i?this.classList.add(`${t}-${n}`):this.classList.remove(`${t}-${n}`)})}on(t,n){return this.addEventListener(t,n.bind(this)),this}};var K=class extends Y(R){bind(t,n=!0){n&&(this.innerHTML=t.originalSource),setTimeout(()=>{if(!this._codeBlock.textContent.length)return;let i=t.runtime;super.bind({runtime:i,graph:i.graph})},0)}createRef(t){}getTextNodes(t=null){return super.getTextNodes(t||this._codeBlock)}get css(){return super.css.concat([` | ||
.ref-identifier.path-runtime-active { | ||
@@ -160,3 +160,3 @@ text-decoration: underline; | ||
} | ||
`])}};customElements.define("subscript-codeblock",Y());customElements.define("subscript-contract",P);customElements.define("subscript-console",K);})(); | ||
`])}};customElements.define("subscript-codeblock",Y());customElements.define("subscript-contract",R);customElements.define("subscript-console",K);})(); | ||
//# sourceMappingURL=console-element.js.map |
@@ -1,2 +0,2 @@ | ||
(()=>{var c=l=>class extends l{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(e=>{if(e.includes("{")&&e.includes(":")&&e.includes(";")){let t=this.shadowRoot.appendChild(document.createElement("style"));t.textContent=e}else{let t=this.shadowRoot.appendChild(document.createElement("link"));t.setAttribute("rel","stylesheet"),t.setAttribute("href",e)}})}get css(){return[]}};var i=class extends c(HTMLElement){connectedCallback(){this._contentSlot=document.createElement("slot"),this.shadowRoot.append(this._contentSlot),super.connectedCallback(),this._contentSlot.addEventListener("slotchange",()=>{setTimeout(()=>{let n=this._contentSlot.assignedNodes().reduce((e,t)=>e||(t.subscript instanceof Map?t:null),null);if(n){this.inspectElement(n);let e=this.getAttribute("active");e&&this.inspectFunction(e)}else console.error("No subscript element found.")},0)})}inspectElement(n){this.consoleElement&&(this.consoleElement.remove(),this.controlsElement.remove()),this.consoleElement=document.createElement("subscript-console"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.shadowRoot.append(this.consoleElement,this.controlsElement),this.buttons={},n.subscript.forEach((e,t)=>{let s=typeof t=="number"?`script:${t}`:`${t}()`;this.buttons[t]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[t].setAttribute("script-id",t),this.buttons[t].setAttribute("title",s),this.buttons[t].appendChild(document.createElement("span")).append(" ",s);let r=this.buttons[t].appendChild(document.createElement("i"));(this.getAttribute("data-icons")||`bi bi-${typeof t=="number"?"code":"braces"}`).split(" ").map(o=>o.trim()).forEach(o=>r.classList.add(o)),this.buttons[t].addEventListener("click",o=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[t],this.active.classList.add("active"),this.inspectFunction(e)})})}inspectFunction(n){if(!n||typeof n=="string"){let e=n;if(n||(e=Object.keys(this.buttons)[0]),e){let t=this.buttons[e],s=new MouseEvent("click",{view:window});t.dispatchEvent(s)}return}this.consoleElement.bind(n)}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css",` | ||
(()=>{var c=l=>class extends l{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){[].concat(this.css).forEach(e=>{if(e.includes("{")&&e.includes(":")&&e.includes(";")){let t=this.shadowRoot.appendChild(document.createElement("style"));t.textContent=e}else{let t=this.shadowRoot.appendChild(document.createElement("link"));t.setAttribute("rel","stylesheet"),t.setAttribute("href",e)}})}get css(){return[]}};var i=class extends c(HTMLElement){connectedCallback(){this._contentSlot=document.createElement("slot"),this.shadowRoot.append(this._contentSlot),super.connectedCallback(),this._contentSlot.addEventListener("slotchange",()=>{setTimeout(()=>{let n=this._contentSlot.assignedNodes().reduce((e,t)=>e||(t.subscript instanceof Map?t:null),null);if(n){this.inspectElement(n);let e=this.getAttribute("active");e&&this.inspectFunction(e)}else visualizer.error("No subscript element found.")},0)})}inspectElement(n){this.visualizerElement&&(this.visualizerElement.remove(),this.controlsElement.remove()),this.visualizerElement=document.createElement("cfunctions-visualizer"),this.controlsElement=document.createElement("div"),this.controlsElement.classList.add("controls-element"),this.shadowRoot.append(this.visualizerElement,this.controlsElement),this.buttons={},(n.scripts||[]).forEach((e,t)=>{if(!e.contract)return;let s=typeof t=="number"?`script:${t}`:`${t}()`;this.buttons[t]=this.controlsElement.appendChild(document.createElement("button")),this.buttons[t].setAttribute("script-id",t),this.buttons[t].setAttribute("title",s),this.buttons[t].appendChild(document.createElement("span")).append(" ",s);let r=this.buttons[t].appendChild(document.createElement("i"));(this.getAttribute("data-icons")||`bi bi-${typeof t=="number"?"code":"braces"}`).split(" ").map(o=>o.trim()).forEach(o=>r.classList.add(o)),this.buttons[t].addEventListener("click",o=>{this.active&&this.active.classList.remove("active"),this.active=this.buttons[t],this.active.classList.add("active"),this.inspectFunction(e)})})}inspectFunction(n){if(!n||typeof n=="string"){let e=n;if(n||(e=Object.keys(this.buttons)[0]),e){let t=this.buttons[e],s=new MouseEvent("click",{view:window});t.dispatchEvent(s)}return}this.visualizerElement.visualize(n)}get css(){return["https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css",` | ||
* { | ||
@@ -31,3 +31,3 @@ -webkit-box-sizing: border-box; | ||
} | ||
`]}};customElements.define("subscript-inspector",i);})(); | ||
`]}};customElements.define("cfunctions-inspector",i);})(); | ||
//# sourceMappingURL=inspector-element.js.map |
@@ -11,3 +11,3 @@ { | ||
"homepage": "https://webqit.io/tooling/subscript", | ||
"version": "2.1.33", | ||
"version": "2.1.34", | ||
"license": "MIT", | ||
@@ -27,3 +27,3 @@ "repository": { | ||
"test:coverage": "c8 --reporter=text-lcov npm run test | coveralls", | ||
"build": "esbuild main=src/browser-entry.js console-element=src/console/Console.js player-element=src/console/Player.js inspector-element=src/console/Inspector.js dev-elements=src/console/index.js --bundle --minify --sourcemap --outdir=dist", | ||
"build": "esbuild main=src/targets.browser.js lite=src/targets.browser.lite.js compiler=src/targets.browser.compiler.js inspector-element=src/inspector/Inspector.js sandbox-element=src/inspector/Sandbox.js visualizer-element=src/inspector/Visualizer.js dev-elements=src/inspector/index.js --bundle --minify --external:./src/compiler --sourcemap --outdir=dist", | ||
"-preversion": "npm run test && npm run build && git add -A dist", | ||
@@ -30,0 +30,0 @@ "preversion": "npm run build && git add -A dist", |
@@ -21,4 +21,5 @@ | ||
setLocation( runtimeObject, node ) { | ||
if ( this.params.locations === false || !node ) /* such as case: null / default: */ return; | ||
if ( !this.params.locations || !node ) /* such as case: null / default: */ return; | ||
let loc = [ node.start + this._locStart, node.end + this._locStart ]; | ||
if ( node.loc ) loc.push( node.loc ); | ||
if ( this.params.locations === 'detached' ) { | ||
@@ -45,3 +46,3 @@ this.locations.push( loc ); | ||
this.deferredTasks.forEach( task => task() ); | ||
return { | ||
const compilation = { | ||
source: this.serialize( ast ), | ||
@@ -53,2 +54,6 @@ graph: globalContext.toJson( false ), | ||
}; | ||
if ( this.params.originalSource === true ) { | ||
compilation.graph.originalSource = this.serialize( nodes ); | ||
} | ||
return compilation; | ||
} | ||
@@ -148,3 +153,7 @@ | ||
const generateId = ( id, context ) => !id ? [ id ] : context.effectReference( { type: node.type }, () => this.generateNodes( context, [ id ] ), false ); | ||
const generateFunction = ( id, params, body ) => context.defineContext( { type: node.type, isSubscriptFunction: node.isSubscriptFunction }, functionContract => { | ||
const def = { type: node.type, isSubscriptFunction: node.isSubscriptFunction }; | ||
if ( this.params.originalSource === true ) { | ||
def.originalSource = this.serialize( node ); | ||
} | ||
const generateFunction = ( id, params, body ) => context.defineContext( def, functionContract => { | ||
return functionContract.createScope( { type: node.type }, () => { | ||
@@ -174,8 +183,17 @@ // FunctionExpressions have their IDs in function scope | ||
let subscript$contract = Node.identifier( context.getSubscriptIdentifier( '$contract', true ) ); | ||
let contractCreate = ( generate, functionContract, funcName, params, body ) => functionContract.generate( | ||
generate.call( Node, funcName, [ subscript$contract ].concat( params ), body, node.async, node.expression, node.generator ), { | ||
const subscript$contract = Node.identifier( context.getSubscriptIdentifier( '$contract', true ) ); | ||
const spliceArgumentsObject = body => { | ||
if ( !functionContract.hoistedArgumentsKeyword || node.type === 'ArrowFunctionExpression' ) return body; | ||
const left = Node.memberExpr( subscript$contract, Node.identifier( 'args' ) ); | ||
const _right = Node.callExpr( Node.memberExpr( Node.identifier( 'Array' ), Node.identifier( 'from' ) ), [ Node.identifier( 'arguments' ) ] ); | ||
const right = Node.callExpr( Node.memberExpr( _right, Node.identifier( 'slice' ) ), [ Node.literal( 1 ) ] ); | ||
body.body.unshift( Node.exprStmt( Node.assignmentExpr( left, right ) ) ); | ||
return body; | ||
}; | ||
const contractCreate = ( generate, functionContract, funcName, params, body ) => functionContract.generate( | ||
generate.call( Node, funcName, [ subscript$contract ].concat( params ), spliceArgumentsObject( body ), node.async, node.expression, node.generator ), { | ||
args: [ Node.literal( node.type ), Node.identifier( node.isSubscriptFunction ? 'true' : 'false' ) ], | ||
isFunctionContract: true, | ||
generateForArgument: true | ||
generateForArgument: true, | ||
} | ||
@@ -189,3 +207,3 @@ ); | ||
[ functionContract, , params, body ] = generateFunction( null, node.params, node.body ); | ||
resultNode = contractCreate( Node.funcExpr, functionContract, null, params, body ); | ||
resultNode = contractCreate( Node.funcExpr, functionContract, id, params, body ); | ||
// We'll physically do hoisting | ||
@@ -196,3 +214,3 @@ let definitionRef = Node.memberExpr( subscript$contract, Node.identifier( 'functions' ) ); | ||
resultNode = [ | ||
Node.exprStmt( definitionCall( 'define', resultNode ) ), | ||
Node.exprStmt( definitionCall( 'declaration', resultNode ) ), | ||
generate.call( Node, id, params, Node.blockStmt( [ | ||
@@ -229,5 +247,2 @@ Node.returnStmt( Node.callExpr( Node.memberExpr( definitionCall( 'get' ), Node.identifier( 'call' ) ), [ | ||
this.setLocation( contract, declarator ); | ||
if ( node.kind === 'const' || !declarator.init ) { | ||
return Node.varDeclarator( declarator.id, declarator.init ); | ||
} | ||
let initReference, [ init ] = contract.signalReference( def, reference => ( initReference = reference, this.generateNodes( context, [ declarator.init ] ) ) ); | ||
@@ -237,3 +252,3 @@ let idReference, [ id ] = contract.effectReference( def, reference => ( idReference = reference, this.generateNodes( context, [ declarator.id ] ) ) ); | ||
if ( | ||
isForLoopInit | ||
isForLoopInit || node.kind === 'const' || !declarator.init | ||
// note that we're not asking initReference.refs.size | ||
@@ -749,9 +764,4 @@ || ( !this.params.devMode && !contract.references.filter( reference => reference instanceof SignalReference ).length ) | ||
generateIdentifier( context, node ) { | ||
let createNode = () => node.type === 'Identifier' ? Node.identifier( node.name ) : Node.thisExpr(); | ||
// How we'll know Identifiers within script | ||
if ( node.type === 'Identifier' ) { | ||
context.subscriptIdentifiersNoConflict( node ); | ||
} | ||
let $identifier = { | ||
name: node.type === 'Identifier' ? node.name : 'this', | ||
name: node.type !== 'Identifier' ? 'this' : node.name, | ||
}; | ||
@@ -768,3 +778,10 @@ this.setLocation( $identifier, node ); | ||
} | ||
return createNode(); | ||
if ( node.type !== 'Identifier' ) return Node.thisExpr(); | ||
// How we'll know Identifiers within script | ||
context.subscriptIdentifiersNoConflict( node ); | ||
// Substituting the keyword: arguments | ||
const subscript$contract = Node.identifier( context.getSubscriptIdentifier( '$contract', true ) ); | ||
return node.name === 'arguments' | ||
? ( context.currentContract.hoistArgumentsKeyword(), Node.memberExpr( subscript$contract, Node.identifier( 'args' ) ) ) | ||
: Node.identifier( node.name ); | ||
} | ||
@@ -771,0 +788,0 @@ |
@@ -80,7 +80,9 @@ | ||
defineSubscriptIdentifier( id, whitelist, blacklist = [] ) { | ||
this.subscriptIdentifiers[ id ] = { | ||
whitelist, | ||
blacklist, | ||
toString() { return this.whitelist[ 0 ] }, | ||
}; | ||
const idObject = {}; | ||
Object.defineProperty( idObject, 'whitelist', { value: whitelist, writable: true } ); | ||
Object.defineProperty( idObject, 'blacklist', { value: blacklist, writable: true } ); | ||
Object.defineProperty( idObject, 'toString', { value: function() { | ||
return this.whitelist[ 0 ]; | ||
} } ); | ||
this.subscriptIdentifiers[ id ] = idObject; | ||
} | ||
@@ -150,3 +152,3 @@ | ||
if ( !reference.refs.size || ( resolveInScope && !targetScope.doSubscribe( reference ) ) ) { | ||
if ( !reference.refs.size || ( this.type === 'VariableDeclaration' && this.kind === 'const' ) || ( resolveInScope && !targetScope.doSubscribe( reference ) ) ) { | ||
this.references = this.references.filter( _reference => _reference !== reference ); | ||
@@ -279,2 +281,6 @@ } | ||
get hoistedArgumentsKeyword() { | ||
return this._hoistedArgumentsKeyword; | ||
} | ||
get hoistedAwaitKeyword() { | ||
@@ -288,2 +294,10 @@ return this._hoistedAwaitKeyword; | ||
hoistArgumentsKeyword() { | ||
if ( [ 'FunctionDeclaration', 'FunctionExpression' ].includes( this.type ) ) { | ||
this._hoistedArgumentsKeyword = true; | ||
return; | ||
} | ||
this.ownerContract && this.ownerContract.hoistArgumentsKeyword(); | ||
} | ||
hoistAwaitKeyword() { | ||
@@ -345,6 +359,8 @@ if ( [ 'FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression' ].includes( this.type ) ) return; | ||
contract = Node.exprStmt( contract ); | ||
contract.comments = [ { | ||
type: 'Line', | ||
value: { toString() { return _this.lineage; }, trim() { return this.toString(); } }, | ||
} ]; | ||
const valueObject = {}; | ||
Object.defineProperty( valueObject, 'toString', { value: () => _this.lineage } ); | ||
Object.defineProperty( valueObject, 'trim', { value: function() { | ||
return this.toString(); | ||
} } ); | ||
contract.comments = [ { type: 'Line', value: valueObject, } ]; | ||
// The list of returned statements | ||
@@ -415,5 +431,8 @@ let statements = [ contract ]; | ||
hoistedAwaitKeyword: this.hoistedAwaitKeyword, | ||
hoistedArgumentsKeyword: this.hoistedArgumentsKeyword, | ||
loc: this.loc, | ||
}; | ||
if ( this.originalSource ) { json.originalSource = this.originalSource; } | ||
this.references.forEach( reference => { | ||
@@ -420,0 +439,0 @@ let target; |
@@ -5,11 +5,11 @@ | ||
*/ | ||
import SubscriptFunctionLite from './SubscriptFunctionLite.js'; | ||
import SubscriptFunction from './SubscriptFunction.js'; | ||
import Compiler from './compiler/Compiler.js'; | ||
import Runtime from './runtime/Runtime.js'; | ||
import SubscriptFunction from './SubscriptFunction.js'; | ||
import { Mixin as SubscriptClass } from './SubscriptClass.js'; | ||
import Parser from './compiler/Parser.js'; | ||
export { | ||
SubscriptFunctionLite, | ||
SubscriptFunction, | ||
SubscriptClass, | ||
Compiler, | ||
@@ -16,0 +16,0 @@ Runtime, |
@@ -5,2 +5,4 @@ | ||
*/ | ||
import { _await } from '../util.js'; | ||
import inspection from './inspect.js'; | ||
@@ -13,6 +15,7 @@ export default class Contract { | ||
this.callee = callee; | ||
this.params = params; | ||
this.params = !ownerContract ? { ...params, isSubscriptFunction: true } : params; | ||
this.exits = exits || new Map; | ||
this.$thread = $thread || { entries: new Map, sequence: [], ownerContract: this }; | ||
this.subContracts = new Map; | ||
this.observers = []; | ||
this.contract = function( contractId, arg1, arg2 = null, arg3 = null ) { | ||
@@ -61,8 +64,19 @@ if ( !this.graph.subContracts[ contractId ] ) { | ||
// Function contracts | ||
callee = arg3, returnValue = subContract = new Contract( this, subGraph, callee, subParams ); | ||
callee = arg3; | ||
const createCallback = () => new Contract( this, subGraph, callee, subParams ); | ||
if ( subParams.functionType !== 'FunctionDeclaration' ) { | ||
returnValue = callee instanceof ( async () => {} ).constructor | ||
? async function() { return subContract.call( this, ...arguments ); } | ||
: function() { return subContract.call( this, ...arguments ); }; | ||
bindFunctionToRuntime( returnValue, subContract ); | ||
returnValue = this.createFunction( createCallback ); | ||
} else { | ||
let subContract = createCallback(); | ||
if ( subParams.apiVersion > 1 ) { | ||
returnValue = function( ...args ) { | ||
let _returnValue = subContract.call( this, ...args ); | ||
_returnValue = _await( _returnValue, __returnValue => [ _returnValue, subContract.thread.bind( subContract ), subContract ] ); | ||
subContract = createCallback(); | ||
return _returnValue; | ||
} | ||
returnValue.target = subContract; | ||
} else { | ||
returnValue = subContract; | ||
} | ||
} | ||
@@ -72,9 +86,13 @@ } else { | ||
callee = arg1, subContract = new Contract( this, subGraph, callee, subParams, this.$thread, this.exits ); | ||
this.subContracts.set( contractId, subContract ); | ||
returnValue = subContract.call(); | ||
} | ||
this.subContracts.set( contractId, subContract ); | ||
return returnValue; | ||
}.bind( this ); | ||
// --------------------------- | ||
this.contract.memo = Object.create( null ); | ||
if ( this.ownerContract && ![ 'FunctionDeclaration', 'FunctionExpression' ].includes( this.graph.type ) ) { | ||
this.contract.args = this.ownerContract.contract.args; | ||
} | ||
// --------------------------- | ||
@@ -93,20 +111,6 @@ this.contract.exiting = function( keyword, arg ) { | ||
this.contract.functions = new Map; | ||
this.contract.functions.define = ( functionDeclaration, contractInstance ) => { | ||
this.contract.functions.set( functionDeclaration, contractInstance ); | ||
bindFunctionToRuntime( functionDeclaration, contractInstance, true ); | ||
this.contract.functions.declaration = ( functionDeclaration, callTarget ) => { | ||
this.contract.functions.set( functionDeclaration, callTarget ); | ||
this.applyReflection( functionDeclaration, typeof callTarget === 'function' ? callTarget.target : callTarget ); | ||
} | ||
const bindFunctionToRuntime = ( _function, runtime, isDeclaration = false ) => { | ||
if ( !isDeclaration ) { | ||
Object.defineProperty( _function, 'length', { configurable: true, value: runtime.callee.length - 1 } ); | ||
Object.defineProperty( _function, 'name', { configurable: true, value: runtime.callee.name } ); | ||
} | ||
if ( runtime.params.isSubscriptFunction ) { | ||
_function.thread = runtime.thread.bind( runtime ); | ||
_function.dispose = runtime.dispose.bind( runtime ); | ||
Object.defineProperty( _function, 'runtime', { value: runtime } ); | ||
Object.defineProperty( _function, 'sideEffects', { configurable: true, value: runtime.graph.sideEffects || '' } ); | ||
Object.defineProperty( _function, 'subscriptSource', { configurable: true, value: runtime.graph.subscriptSource || '' } ); | ||
Object.defineProperty( _function, 'originalSource', { configurable: true, value: runtime.graph.originalSource || '' } ); | ||
}; | ||
} | ||
} | ||
@@ -116,5 +120,15 @@ | ||
if ( !this.ownerContract ) return; | ||
return this.ownerContract.fire( contractUrl, event, refs ); | ||
const ret = this.ownerContract.fire( contractUrl, event, refs ); | ||
this.observers.forEach( observer => { | ||
if ( observer.contractUrl !== contractUrl ) return; | ||
observer.callback( event, refs ); | ||
} ); | ||
return ret; | ||
} | ||
observe( contractUrl, callback ) { | ||
if ( !this.params.isFunctionContract ) return; | ||
this.observers.push( { contractUrl, callback } ); | ||
} | ||
call( $this, ...$arguments ) { | ||
@@ -124,2 +138,6 @@ if ( this.disposed ) { | ||
} | ||
if ( !this.ownerContract ) { | ||
this.contract.args = $arguments; | ||
Object.defineProperty( this.contract.args, Symbol.toStringTag, { value: 'Arguments' } ); | ||
} | ||
let returnValue = this.callee.call( $this, this.contract, ...$arguments ); | ||
@@ -439,7 +457,72 @@ if ( this.graph.$sideEffects ) { | ||
} | ||
createFunction( createCallback, defaultThis = undefined ) { | ||
let contract = createCallback(); | ||
// ------------- | ||
const execute = function( _contract, ...args ) { | ||
let _returnValue = _contract.call( this === undefined ? defaultThis : this, ...args ); | ||
if ( _contract.params.isSubscriptFunction && _contract.params.apiVersion > 1 ) { | ||
_returnValue = _await( _returnValue, __returnValue => [ __returnValue, _contract.thread.bind( _contract ), _contract ] ); | ||
// Replace global for next call | ||
contract = createCallback( contract ); | ||
} | ||
return _returnValue; | ||
}; | ||
// ------------- | ||
const _function = ( contract instanceof Promise ) || ( contract.callee instanceof ( async function() {} ).constructor ) | ||
? async function() { return _await( contract, _contract => execute.call( this, _contract, ...arguments ) ); } | ||
: function() { return execute.call( this, contract, ...arguments ); }; | ||
// ------------- | ||
_await( contract, _contract => { | ||
this.applyReflection( _function, _contract ); | ||
} ); | ||
// ------------- | ||
inspection( _function, 'properties', _await( contract, _contract => { | ||
const graph = { | ||
type: _contract.params.functionType || 'Program', | ||
apiVersion: _contract.params.apiVersion || 1, | ||
isSubscriptFunction: _contract.params.isSubscriptFunction, | ||
sideEffects: _contract.graph.sideEffects || false, | ||
}; | ||
if ( _contract.params.isSubscriptFunction ) { | ||
graph.dependencies = []; | ||
for ( const [ id, effect ] of Object.entries( _contract.graph.effects ) ) { | ||
graph.dependencies.push( ...effect.refs.map( ref => ref.path.map( s => !( 'name' in s ) ? Infinity : s.name ) ) ); | ||
} | ||
} | ||
return graph; | ||
} ) ); | ||
// ------------- | ||
return _function; | ||
} | ||
applyReflection( _function, contract ) { | ||
// Hide implementation details on callee | ||
Object.defineProperty( contract.callee, 'length', { configurable: true, value: contract.callee.length - 1 } ); | ||
const compiledSourceNeat = contract.callee.toString()//.replace( /\(\$[\w]+\,([\s]*)?/, '(' ); | ||
Object.defineProperty( contract.callee, 'toString', { configurable: true, value: ( compiledSource = false ) => { | ||
if ( !compiledSource && contract.graph.originalSource ) { return contract.graph.originalSource; } | ||
return compiledSourceNeat; | ||
} } ); | ||
// Hide implementation details on main | ||
let properties = { | ||
name: contract.callee.name, | ||
length: contract.callee.length, | ||
toString: contract.callee.toString, | ||
}; | ||
if ( contract.params.isSubscriptFunction ) { | ||
if ( !( contract.params.apiVersion > 1 ) ) { | ||
properties = { | ||
...properties, | ||
thread: contract.thread.bind( contract ), | ||
dispose: contract.dispose.bind( contract ), | ||
runtime: contract, | ||
}; | ||
} | ||
} | ||
Object.keys( properties ).forEach( name => { | ||
Object.defineProperty( _function, name, { configurable: true, value: properties[ name ] } ); | ||
} ); | ||
} | ||
} | ||
const _await = ( maybePromise, callback ) => ( | ||
maybePromise instanceof Promise ? maybePromise.then( callback ) : callback() | ||
); |
@@ -5,3 +5,5 @@ | ||
*/ | ||
import { _await } from '../util.js'; | ||
import Contract from './Contract.js'; | ||
import inspection from './inspect.js'; | ||
@@ -11,30 +13,36 @@ export default class Runtime extends Contract { | ||
static create( compilation, parameters = [], runtimeParams = {} ) { | ||
const _Function = compilation.graph.hoistedAwaitKeyword ? Object.getPrototypeOf( async function() {} ).constructor : Function; | ||
const isAsync = runtimeParams.async || compilation.graph.hoistedAwaitKeyword; | ||
const _Function = isAsync ? Object.getPrototypeOf( async function() {} ).constructor : Function; | ||
const callee = runtimeParams.compileFunction | ||
? runtimeParams.compileFunction( compilation.source, [ compilation.identifier + '' ].concat( parameters ) ) | ||
: new _Function( compilation.identifier + '', ...parameters, compilation.source ); | ||
const runtime = new this( null, compilation.graph, callee, runtimeParams ); | ||
return runtime; | ||
return new this( null, compilation.graph, callee, runtimeParams ); | ||
} | ||
constructor( ownerContract, graph, callee, runtimeParams = {}, exits = null ) { | ||
super( ownerContract, graph, callee, runtimeParams = {}, exits ); | ||
this.observers = []; | ||
static createFunction( sourceName, compilation, parameters = [], runtimeParams = {}, defaultThis, originalSource = null ) { | ||
runtimeParams = { ...runtimeParams, functionType: 'Constructor', }; | ||
if ( compilation instanceof Promise ) { runtimeParams = { ...runtimeParams, async: true, }; } | ||
const createCallback = contract => { | ||
// Subsequent calls avoid recompilation | ||
if ( contract ) { return new this( null, contract.graph, contract.callee, runtimeParams ); } | ||
// Supports lazy compilation. So, input compilation may be a Promise | ||
return _await( compilation, _compilation => applyReflection( this.create( _compilation, parameters, runtimeParams ) ) ); | ||
}; | ||
const applyReflection = contract => { | ||
if ( contract.graph.originalSource && !contract.graph.originalSourceModified ) { | ||
const ownSource = `${ runtimeParams.async || contract.graph.hoistedAwaitKeyword ? 'async ' : '' }function ${ sourceName || 'anonymous' }`; | ||
const originalSourceIndented = contract.graph.originalSource.split(/\n/g).map( line => ` ${ line }` ).join( `\n` ); | ||
contract.graph.originalSource = `${ ownSource }(${ parameters.join( ', ' ) }) {\n${ originalSourceIndented }\n}`; | ||
contract.graph.originalSourceModified = true; | ||
} | ||
if ( sourceName ) { Object.defineProperty( contract.callee, 'name', { configurable: true, value: sourceName } ); } | ||
return contract; | ||
}; | ||
const _function = this.prototype.createFunction( createCallback, defaultThis ); | ||
inspection( _function, 'locations', _await( compilation, _compilation => ( { | ||
locations: _compilation.locations, | ||
} ) ) ); | ||
return _function; | ||
} | ||
observe( contractUrl, callback ) { | ||
if ( !this.params.devMode ) { | ||
// Only allow observers in dev mode | ||
//throw new Error( `Observers are allowed only in dev mode.` ); | ||
} | ||
this.observers.push( { contractUrl, callback } ); | ||
} | ||
fire( contractUrl, event, refs ) { | ||
( this.observers || [] ).forEach( observer => { | ||
if ( observer.contractUrl !== contractUrl ) return; | ||
observer.callback( event, refs ); | ||
} ); | ||
} | ||
} |
@@ -0,6 +1,10 @@ | ||
/** | ||
* @imports | ||
*/ | ||
import { resolveParams } from './params.js'; | ||
import { normalizeTabs } from './util.js'; | ||
import { Parser, Compiler, Runtime } from './index.js'; | ||
import { parse, compile, serialize } from './compiler/index.js'; | ||
import Runtime from './runtime/Runtime.js'; | ||
import inspect from './runtime/inspect.js'; | ||
@@ -11,155 +15,14 @@ /** | ||
export default function SubscriptFunction( ...args ) { | ||
let params = typeof args[ args.length - 1 ] === 'object' ? args.pop() : {}; | ||
params.compilerParams = { ...SubscriptFunction.compilerParams, ...( params.compilerParams || {} ) }; | ||
params.runtimeParams = { ...SubscriptFunction.runtimeParams, ...( params.runtimeParams || {} ) }; | ||
let source = normalizeTabs( args.pop() || '' ); | ||
let compilation, parameters = args; | ||
if ( SubscriptFunction.cache[ source ] && !params.compilerParams.devMode && compare( parameters, SubscriptFunction.cache[ source ][ 1 ] ) && deepEql( params.compilerParams, SubscriptFunction.cache[ source ][ 2 ] ) ) { | ||
// ---------------- | ||
[ compilation, parameters ] = SubscriptFunction.cache[ source ]; | ||
// ---------------- | ||
} else { | ||
let ast = parse( source ); | ||
let compiler = new Compiler( params.compilerParams ); | ||
compilation = compiler.generate( ast ); | ||
// ---------------- | ||
SubscriptFunction.cache[ source ] = [ compilation, parameters, params.compilerParams ]; | ||
// ---------------- | ||
} | ||
return create( this, compilation, args, params.runtimeParams, source ); | ||
const params = resolveParams( typeof args[ args.length - 1 ] === 'object' ? args.pop() : {} ); | ||
const source = normalizeTabs( args.pop() || '' ); | ||
const parameters = args; | ||
// -------------------- | ||
const ast = parse( source, params.parserParams ); | ||
const compilation = compile( ast, params.compilerParams ); | ||
return Runtime.createFunction( undefined, compilation, parameters, params.runtimeParams, this, source ); | ||
} | ||
SubscriptFunction.cache = {}; | ||
/** | ||
* @compilerParams | ||
* @inspect | ||
*/ | ||
SubscriptFunction.compilerParams = { | ||
globalsNoObserve: [], | ||
globalsOnlyPaths: false, | ||
compact: 2, | ||
} | ||
/** | ||
* @runtimeParams | ||
*/ | ||
SubscriptFunction.runtimeParams = {} | ||
/** | ||
* @clone | ||
*/ | ||
SubscriptFunction.cloneCache = {}; | ||
SubscriptFunction.clone = function( _function, defaultThis = null, _compilerParams = {}, _runtimeParams = {} ) { | ||
if ( typeof _function !== 'function' ) { | ||
throw new Error( `Expected argument 1 to be of type 'function' but got ${ typeof _function }.` ); | ||
} | ||
if ( !_function.name ) { | ||
throw new Error(`Function must have a name.`); | ||
} | ||
let rawSource = normalizeTabs( _function.toString(), true ); | ||
let source = rawSource, isAsync; | ||
if ( rawSource.startsWith( 'async ' ) ) { | ||
isAsync = true; | ||
source = source.substring( 6 ); | ||
} | ||
if ( !source.startsWith( 'function ' ) && !source.startsWith( 'function(' ) ) { | ||
if ( source.trim().startsWith( '[' ) ) { | ||
let computedName, roughSPlit = source.split(/\](?:[\s]+)?\(/g).filter( str => str ); | ||
[ computedName, source ] = roughSPlit.reduce( ( prev, str, i ) => { | ||
if ( Array.isArray( prev ) ) return prev; | ||
str = `${ prev }${ str || '' }]`; | ||
try { | ||
parse( str ); | ||
return [ str, `${ _function.name }(${ roughSPlit.slice( i + 1 ).join( '] (' ) }`] | ||
} catch( e ) { return `${ str } (`; } | ||
}, '' ); | ||
} | ||
source = 'function ' + source; | ||
} | ||
let compilation, parameters, originalSource; | ||
if ( SubscriptFunction.cloneCache[ source ] && !_compilerParams.devMode && deepEql( _compilerParams, SubscriptFunction.cloneCache[ source ][ 3 ] ) ) { | ||
// ---------------- | ||
[ compilation, parameters, originalSource ] = SubscriptFunction.cloneCache[ source ]; | ||
// ---------------- | ||
} else { | ||
let ast = parse( source ).body[ 0 ]; | ||
let bodyStart = ast.body.start + 1/* the opening brace */; | ||
if ( source.substr( bodyStart, 1 ) === "\n" ) { | ||
bodyStart += 1; | ||
} | ||
let compiler = new Compiler( { ..._compilerParams, ...SubscriptFunction.compilerParams, locStart: - bodyStart } ); | ||
parameters = ast.params.map( paramExpr => compiler.serialize( paramExpr ) ); | ||
compilation = compiler.generate( { type: 'Program', body: ast.body.body } ); | ||
if ( !compilation.graph.hoistedAwaitKeyword && isAsync ) { | ||
compilation.graph.hoistedAwaitKeyword = true; | ||
} | ||
originalSource = source.substring( bodyStart, ast.body.end - 1 ); | ||
// ---------------- | ||
SubscriptFunction.cloneCache[ source ] = [ compilation, parameters, originalSource, _compilerParams ]; | ||
// ---------------- | ||
} | ||
return create( defaultThis, compilation, parameters, _runtimeParams, originalSource, _function.name ); | ||
} | ||
/** | ||
* @create | ||
*/ | ||
const create = function( defaultThis, compilation, parameters = [], _runtimeParams = {}, originalSource = null, sourceName = null ) { | ||
let runtime = Runtime.create( compilation, parameters, { ..._runtimeParams, ...SubscriptFunction.runtimeParams } ); | ||
let _function = function( ...args ) { | ||
try { | ||
return runtime.call( this === undefined ? defaultThis : this, ...args ); | ||
} catch(e) { | ||
console.info('-----------------------'); | ||
console.log(originalSource || ''); | ||
console.info('-----------------------'); | ||
throw e; | ||
} | ||
}; | ||
_function.thread = runtime.thread.bind( runtime ); | ||
_function.dispose = runtime.dispose.bind( runtime ); | ||
Object.defineProperty( _function, 'runtime', { value: runtime } ); | ||
Object.defineProperty( _function, 'sideEffects', { configurable: true, value: runtime.graph.sideEffects } ); | ||
Object.defineProperty( _function, 'subscriptSource', { configurable: true, value: compilation.source } ); | ||
Object.defineProperty( _function, 'originalSource', { configurable: true, value: originalSource } ); | ||
Object.defineProperty( _function, 'length', { configurable: true, value: parameters.length } ); | ||
Object.defineProperty( _function, 'name', { configurable: true, value: sourceName } ); | ||
let ownSource = ( compilation.graph.hoistedAwaitKeyword ? 'async ' : '' ) + 'function' + ( sourceName ? ' ' + sourceName : '' ); | ||
_function.toString = () => `${ ownSource }(${ parameters.join( ', ' ) }) {${ originalSource }}`; | ||
return _function; | ||
} | ||
/** | ||
* @parse | ||
*/ | ||
const parseCache = new Map; | ||
const parse = function( source, params = {} ) { | ||
params = { | ||
ecmaVersion: '2020', | ||
allowReturnOutsideFunction: true, | ||
allowAwaitOutsideFunction: true, | ||
allowSuperOutsideMethod: true, | ||
preserveParens: false, | ||
...params | ||
}; | ||
let ast = parseCache.get( source ); | ||
if ( !ast ) { | ||
ast = Parser.parse( source, params ); | ||
parseCache.set( source, ast ); | ||
} | ||
return ast; | ||
}; | ||
/** | ||
* @deepEql | ||
*/ | ||
const compare = ( a, b ) => { | ||
if ( typeof a === 'object' && a && typeof b === 'object' && b ) return deepEql( a, b ); | ||
if ( Array.isArray( a ) && Array.isArray( b ) && a.length === b.length ) return a.every( valueA => b.some( valueB => compare( valueA, valueB ) ) ); | ||
return a === b; | ||
} | ||
const deepEql = function( a, b ) { | ||
for ( let key in a ) { | ||
if ( !compare( a[ key ], b[ key ] ) ) return false; | ||
} | ||
return true; | ||
}; | ||
Object.defineProperty( SubscriptFunction, 'inspect', { value: inspect } ); |
104
src/util.js
@@ -25,2 +25,106 @@ | ||
return rawSource; | ||
} | ||
export const _await = ( maybePromise, callback ) => ( | ||
maybePromise instanceof Promise ? maybePromise.then( callback ) : callback( maybePromise ) | ||
); | ||
export const _compare = ( a, b ) => { | ||
if ( typeof a === 'object' && a && typeof b === 'object' && b ) return _deepEql( a, b ); | ||
if ( Array.isArray( a ) && Array.isArray( b ) && a.length === b.length ) return a.every( valueA => b.some( valueB => _compare( valueA, valueB ) ) ); | ||
return a === b; | ||
}; | ||
export const _deepEql = function( a, b ) { | ||
for ( let key in a ) { | ||
if ( !_compare( a[ key ], b[ key ] ) ) return false; | ||
} | ||
return true; | ||
}; | ||
// ------------------ | ||
// Obsolete | ||
// ------------------ | ||
/** | ||
* @SubscriptFunctionClone | ||
*/ | ||
export function SubscriptFunctionClone( _function, defaultThis = null, params = {} ) { | ||
if ( typeof _function !== 'function' ) { | ||
throw new Error( `Expected argument 1 to be of type 'function' but got ${ typeof _function }.` ); | ||
} | ||
if ( !_function.name ) { | ||
throw new Error(`Function must have a name.`); | ||
} | ||
params = resolveParams( params ); | ||
const rawSource = normalizeTabs( _function.toString(), true ); | ||
let source = rawSource, isAsync; | ||
if ( rawSource.startsWith( 'async ' ) ) { | ||
params.runtimeParams.async = true; | ||
source = source.substring( 6 ); | ||
isAsync = true; | ||
} | ||
if ( !source.startsWith( 'function ' ) && !source.startsWith( 'function(' ) ) { | ||
if ( source.trim().startsWith( '[' ) ) { | ||
let computedName, roughSPlit = source.split(/\](?:[\s]+)?\(/g).filter( str => str ); | ||
[ computedName, source ] = roughSPlit.reduce( ( prev, str, i ) => { | ||
if ( Array.isArray( prev ) ) return prev; | ||
str = `${ prev }${ str || '' }]`; | ||
try { | ||
parse( str ); | ||
return [ str, `${ _function.name }(${ roughSPlit.slice( i + 1 ).join( '] (' ) }`] | ||
} catch( e ) { return `${ str } (`; } | ||
}, '' ); | ||
} | ||
source = 'function ' + source; | ||
} | ||
const ast = parse( source, params.parserParams ).body[ 0 ]; | ||
let bodyStart = ast.body.start + 1/* the opening brace */; | ||
if ( source.substr( bodyStart, 1 ) === "\n" ) { | ||
bodyStart += 1; | ||
} | ||
const originalSource = source.substring( bodyStart, ast.body.end - 1 ); | ||
const compilation = compile( { type: 'Program', body: ast.body.body }, { ...params.compilerParams, locStart: - bodyStart } ); | ||
const parameters = ast.params.map( paramExpr => serialize( paramExpr ) ); | ||
return Runtime.createFunction( _function.name, compilation, parameters, params.runtimeParams, defaultThis, originalSource ); | ||
} | ||
/** | ||
* @SubscriptClass | ||
*/ | ||
export const SubscriptClass = Class => class extends ( Class || class {} ) { | ||
constructor() { | ||
super(); | ||
const _static = this.constructor; | ||
_static.subscriptMethods.forEach( methodName => { | ||
if ( !this[ methodName ] ) { | ||
throw new Error( `${ methodName } is not a method.` ); | ||
} | ||
if ( methodName === 'constructor' ) { | ||
throw new Error( `Class constructors cannot be subscript methods.` ); | ||
} | ||
this[ methodName ] = _static.implementMethod( this[ methodName ], this ); | ||
} ); | ||
} | ||
static implementMethod( method, thisBinding = null ) { | ||
return SubscriptFunctionClone( method, thisBinding, { | ||
compilerParams: this.compilerParams, | ||
runtimeParams: this.runtimeParams, | ||
} ); | ||
} | ||
static get subscriptMethods() { | ||
return []; | ||
} | ||
static get runtimeParams() { | ||
return {}; | ||
} | ||
static get compilerParams() { | ||
return {}; | ||
} | ||
} |
@@ -87,3 +87,3 @@ | ||
// #/8 | ||
$x(6, $x => { | ||
$x(8, $x => { | ||
c = d; | ||
@@ -93,3 +93,3 @@ }); | ||
// #/12 | ||
$x(10, $x => { | ||
$x(12, $x => { | ||
e = f; | ||
@@ -96,0 +96,0 @@ }); |
@@ -5,3 +5,3 @@ | ||
*/ | ||
import { SubscriptFunction } from '../src/index.js'; | ||
import SubscriptFunction from '../src/SubscriptFunction.js'; | ||
import Observer from '../../observer/src/index.js'; | ||
@@ -14,2 +14,3 @@ | ||
for ( let propertyName in entries ) { | ||
@@ -20,8 +21,21 @@ console.log( \`Current property name is: \${ propertyName }, and its alias name is: '\${ entries[ propertyName ].name }'\` ); | ||
//const ff = console.log( '-----------------<<--->>---------------------------', arguments ); | ||
console.log( '-----------------------------------------------' ); | ||
function fun0(a, b) { | ||
} | ||
let sum = async function sum( param_1, param_2 ) { | ||
return param_1 + (await param_2); | ||
let fun00 = (a) => {a}; | ||
let sumCount = 0; | ||
let sum = async function sum( $x, param_2 ) { | ||
sumCount ++; | ||
if ( Array ) { | ||
} | ||
return $x + (await param_2); | ||
} | ||
console.log( '-------------------->>---------------------------', fun0.length, fun0.toString() ); | ||
console.log( '-----------------------------------------------' ); | ||
let l = list1; | ||
@@ -34,3 +48,2 @@ let propName = 'length'; | ||
console.log( '-----------------------------------------------' ); | ||
@@ -58,3 +71,5 @@ for ( let num of list1 ) { | ||
case 'sum': | ||
return sum( funcParam1, funcParam2 ); | ||
let result = sum( funcParam1, funcParam2 ); | ||
console.log( 'sumCount', sumCount ); | ||
return result; | ||
default: | ||
@@ -66,6 +81,6 @@ console.log( 'the end!' ) | ||
SubscriptFunction.compilerParams.globalsNoObserve.push( 'console' ); | ||
let subscriptFunction = new SubscriptFunction( 'funcTrigger', 'funcParam1', 'funcParam2', source ); | ||
//SubscriptFunction.compilerParams.globalsNoObserve.push( 'console' ); | ||
const subscriptFunction = new SubscriptFunction( 'funcTrigger', 'funcParam1', 'funcParam2', source, { runtimeParams: { apiVersion: 2 } } ); | ||
Observer.observe( globalThis, mutations => { | ||
subscriptFunction.thread( ...mutations.map( mu => mu.path ) ); | ||
sync( ...mutations.map( mu => mu.path ) ); | ||
}, { subtree: true } ); | ||
@@ -80,3 +95,3 @@ | ||
entries[ 'one' ] = { name: 'New one' }; | ||
subscriptFunction.thread( [ 'entries', 'one', 'name' ] ); | ||
sync( [ 'entries', 'one', 'name' ] ); | ||
}, 4000); | ||
@@ -93,11 +108,13 @@ | ||
console.log(''); | ||
let result = subscriptFunction( 'sum', '55', '55' ); | ||
console.log( '---result---->', await result ); | ||
setTimeout(async () => { | ||
console.log( '---thread---->', await subscriptFunction.thread( [ 'funcParam2' ] ) ); | ||
}, 5000); | ||
let result, sync = subscriptFunction.thread; | ||
[ result, sync ] = await subscriptFunction( 'sum', '55', '55' ); | ||
//result = await subscriptFunction( 'sum', '55', '55' ); | ||
console.log( '---result---->', typeof sync, result ); | ||
setTimeout( async () => { | ||
console.log( '---thread---->', await sync( [ 'funcParam2' ] ) ); | ||
}, 5000 ); | ||
console.log(''); | ||
console.log('--------------------------------------------------'); | ||
console.log(''); | ||
//0console.log( JSON.stringify( subscriptFunction.runtime.graph, null, 3 ) ); | ||
//console.log( JSON.stringify( subscriptFunction.runtime.graph, null, 3 ) ); | ||
console.log(''); | ||
@@ -110,3 +127,3 @@ console.log('--------------------------------------------------'); | ||
console.log(''); | ||
console.log( subscriptFunction.subscriptSource ); | ||
//console.log( subscriptFunction.length, subscriptFunction.toString(true) ); | ||
console.log(''); | ||
@@ -116,1 +133,8 @@ console.log('--------------------------------------------------'); | ||
/* | ||
Now that can we revisit the problems | ||
Back to the HTML kind of problems! but this is really all the way back to where we left off a decade ago! | ||
We were just ... but dropped plans! Can we revisit those ideas? | ||
Since progress in the language has stalled, we will not have to meet it where we left off! | ||
*/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3187300
69
7965