logseq/resources/js/lsplugin.core.js

2 lines
106 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

/*! For license information please see lsplugin.core.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LSPlugin=t():e.LSPlugin=t()}(self,(()=>(()=>{var e={227:(e,t,n)=>{var r=n(155);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(447)(t);const{formatters:o}=e.exports;o.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},856:function(e){e.exports=function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,i){return r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var i=new(Function.bind.apply(e,o));return r&&t(i,r.prototype),i},r.apply(null,arguments)}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=Object.hasOwnProperty,a=Object.setPrototypeOf,c=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,h=Object.freeze,d=Object.seal,f=Object.create,p="undefined"!=typeof Reflect&&Reflect,g=p.apply,m=p.construct;g||(g=function(e,t,n){return e.apply(t,n)}),h||(h=function(e){return e}),d||(d=function(e){return e}),m||(m=function(e,t){return r(e,o(t))});var y,_=k(Array.prototype.forEach),b=k(Array.prototype.pop),v=k(Array.prototype.push),w=k(String.prototype.toLowerCase),x=k(String.prototype.match),C=k(String.prototype.replace),S=k(String.prototype.indexOf),O=k(String.prototype.trim),E=k(RegExp.prototype.test),A=(y=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m(y,t)});function k(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return g(e,t,r)}}function j(e,t){a&&a(e,null);for(var n=t.length;n--;){var r=t[n];if("string"==typeof r){var o=w(r);o!==r&&(c(t)||(t[n]=o),r=o)}e[r]=!0}return e}function T(e){var t,n=f(null);for(t in e)g(s,e,[t])&&(n[t]=e[t]);return n}function I(e,t){for(;null!==e;){var n=u(e,t);if(n){if(n.get)return k(n.get);if("function"==typeof n.value)return k(n.value)}e=l(e)}return function(e){return console.warn("fallback value for",e),null}}var L=h(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),M=h(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),P=h(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),N=h(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),R=h(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),F=h(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),D=h(["#text"]),U=h(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),$=h(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),z=h(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),H=h(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),q=d(/\{\{[\w\W]*|[\w\W]*\}\}/gm),B=d(/<%[\w\W]*|[\w\W]*%>/gm),W=d(/^data-[\-\w.\u00B7-\uFFFF]/),G=d(/^aria-[\-\w]+$/),J=d(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),V=d(/^(?:\w+script|data):/i),Z=d(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),K=d(/^html$/i),Y=function(){return"undefined"==typeof window?null:window},Q=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,o="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(o)&&(r=n.currentScript.getAttribute(o));var i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Y(),r=function(e){return t(e)};if(r.version="2.3.8",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var i=n.document,s=n.document,a=n.DocumentFragment,c=n.HTMLTemplateElement,l=n.Node,u=n.Element,d=n.NodeFilter,f=n.NamedNodeMap,p=void 0===f?n.NamedNodeMap||n.MozNamedAttrMap:f,g=n.HTMLFormElement,m=n.DOMParser,y=n.trustedTypes,k=u.prototype,X=I(k,"cloneNode"),ee=I(k,"nextSibling"),te=I(k,"childNodes"),ne=I(k,"parentNode");if("function"==typeof c){var re=s.createElement("template");re.content&&re.content.ownerDocument&&(s=re.content.ownerDocument)}var oe=Q(y,i),ie=oe?oe.createHTML(""):"",se=s,ae=se.implementation,ce=se.createNodeIterator,le=se.createDocumentFragment,ue=se.getElementsByTagName,he=i.importNode,de={};try{de=T(s).documentMode?s.documentMode:{}}catch(e){}var fe={};r.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==de;var pe,ge,me=q,ye=B,_e=W,be=G,ve=V,we=Z,xe=J,Ce=null,Se=j({},[].concat(o(L),o(M),o(P),o(R),o(D))),Oe=null,Ee=j({},[].concat(o(U),o($),o(z),o(H))),Ae=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,je=null,Te=!0,Ie=!0,Le=!1,Me=!1,Pe=!1,Ne=!1,Re=!1,Fe=!1,De=!1,Ue=!1,$e=!0,ze=!0,He=!1,qe={},Be=null,We=j({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Ge=null,Je=j({},["audio","video","img","source","image","track"]),Ve=null,Ze=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ke="http://www.w3.org/1998/Math/MathML",Ye="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",Xe=Qe,et=!1,tt=["application/xhtml+xml","text/html"],nt="text/html",rt=null,ot=s.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},st=function(t){rt&&rt===t||(t&&"object"===e(t)||(t={}),t=T(t),Ce="ALLOWED_TAGS"in t?j({},t.ALLOWED_TAGS):Se,Oe="ALLOWED_ATTR"in t?j({},t.ALLOWED_ATTR):Ee,Ve="ADD_URI_SAFE_ATTR"in t?j(T(Ze),t.ADD_URI_SAFE_ATTR):Ze,Ge="ADD_DATA_URI_TAGS"in t?j(T(Je),t.ADD_DATA_URI_TAGS):Je,Be="FORBID_CONTENTS"in t?j({},t.FORBID_CONTENTS):We,ke="FORBID_TAGS"in t?j({},t.FORBID_TAGS):{},je="FORBID_ATTR"in t?j({},t.FORBID_ATTR):{},qe="USE_PROFILES"in t&&t.USE_PROFILES,Te=!1!==t.ALLOW_ARIA_ATTR,Ie=!1!==t.ALLOW_DATA_ATTR,Le=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Me=t.SAFE_FOR_TEMPLATES||!1,Pe=t.WHOLE_DOCUMENT||!1,Fe=t.RETURN_DOM||!1,De=t.RETURN_DOM_FRAGMENT||!1,Ue=t.RETURN_TRUSTED_TYPE||!1,Re=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,ze=!1!==t.KEEP_CONTENT,He=t.IN_PLACE||!1,xe=t.ALLOWED_URI_REGEXP||xe,Xe=t.NAMESPACE||Qe,t.CUSTOM_ELEMENT_HANDLING&&it(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&it(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ae.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),pe=pe=-1===tt.indexOf(t.PARSER_MEDIA_TYPE)?nt:t.PARSER_MEDIA_TYPE,ge="application/xhtml+xml"===pe?function(e){return e}:w,Me&&(Ie=!1),De&&(Fe=!0),qe&&(Ce=j({},o(D)),Oe=[],!0===qe.html&&(j(Ce,L),j(Oe,U)),!0===qe.svg&&(j(Ce,M),j(Oe,$),j(Oe,H)),!0===qe.svgFilters&&(j(Ce,P),j(Oe,$),j(Oe,H)),!0===qe.mathMl&&(j(Ce,R),j(Oe,z),j(Oe,H))),t.ADD_TAGS&&(Ce===Se&&(Ce=T(Ce)),j(Ce,t.ADD_TAGS)),t.ADD_ATTR&&(Oe===Ee&&(Oe=T(Oe)),j(Oe,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&j(Ve,t.ADD_URI_SAFE_ATTR),t.FORBID_CONTENTS&&(Be===We&&(Be=T(Be)),j(Be,t.FORBID_CONTENTS)),ze&&(Ce["#text"]=!0),Pe&&j(Ce,["html","head","body"]),Ce.table&&(j(Ce,["tbody"]),delete ke.tbody),h&&h(t),rt=t)},at=j({},["mi","mo","mn","ms","mtext"]),ct=j({},["foreignobject","desc","title","annotation-xml"]),lt=j({},["title","style","font","a","script"]),ut=j({},M);j(ut,P),j(ut,N);var ht=j({},R);j(ht,F);var dt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});var n=w(e.tagName),r=w(t.tagName);return e.namespaceURI===Ye?t.namespaceURI===Qe?"svg"===n:t.namespaceURI===Ke?"svg"===n&&("annotation-xml"===r||at[r]):Boolean(ut[n]):e.namespaceURI===Ke?t.namespaceURI===Qe?"math"===n:t.namespaceURI===Ye?"math"===n&&ct[r]:Boolean(ht[n]):e.namespaceURI===Qe&&!(t.namespaceURI===Ye&&!ct[r])&&!(t.namespaceURI===Ke&&!at[r])&&!ht[n]&&(lt[n]||!ut[n])},ft=function(e){v(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},pt=function(e,t){try{v(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){v(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Oe[e])if(Fe||De)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},gt=function(e){var t,n;if(Re)e="<remove></remove>"+e;else{var r=x(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===pe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var o=oe?oe.createHTML(e):e;if(Xe===Qe)try{t=(new m).parseFromString(o,pe)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Xe,"template",null);try{t.documentElement.innerHTML=et?"":o}catch(e){}}var i=t.body||t.documentElement;return e&&n&&i.insertBefore(s.createTextNode(n),i.childNodes[0]||null),Xe===Qe?ue.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:i},mt=function(e){return ce.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},yt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},_t=function(t){return"object"===e(l)?t instanceof l:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},bt=function(e,t,n){fe[e]&&_(fe[e],(function(e){e.call(r,t,n,rt)}))},vt=function(e){var t;if(bt("beforeSanitizeElements",e,null),yt(e))return ft(e),!0;if(E(/[\u0080-\uFFFF]/,e.nodeName))return ft(e),!0;var n=ge(e.nodeName);if(bt("uponSanitizeElement",e,{tagName:n,allowedTags:Ce}),e.hasChildNodes()&&!_t(e.firstElementChild)&&(!_t(e.content)||!_t(e.content.firstElementChild))&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return ft(e),!0;if("select"===n&&E(/<template/i,e.innerHTML))return ft(e),!0;if(!Ce[n]||ke[n]){if(!ke[n]&&xt(n)){if(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,n))return!1;if(Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))return!1}if(ze&&!Be[n]){var o=ne(e)||e.parentNode,i=te(e)||e.childNodes;if(i&&o)for(var s=i.length-1;s>=0;--s)o.insertBefore(X(i[s],!0),ee(e))}return ft(e),!0}return e instanceof u&&!dt(e)?(ft(e),!0):"noscript"!==n&&"noembed"!==n||!E(/<\/no(script|embed)/i,e.innerHTML)?(Me&&3===e.nodeType&&(t=e.textContent,t=C(t,me," "),t=C(t,ye," "),e.textContent!==t&&(v(r.removed,{element:e.cloneNode()}),e.textContent=t)),bt("afterSanitizeElements",e,null),!1):(ft(e),!0)},wt=function(e,t,n){if($e&&("id"===t||"name"===t)&&(n in s||n in ot))return!1;if(Ie&&!je[t]&&E(_e,t));else if(Te&&E(be,t));else if(!Oe[t]||je[t]){if(!(xt(e)&&(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,e)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(e))&&(Ae.attributeNameCheck instanceof RegExp&&E(Ae.attributeNameCheck,t)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(t))||"is"===t&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&E(Ae.tagNameCheck,n)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))))return!1}else if(Ve[t]);else if(E(xe,C(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==S(n,"data:")||!Ge[e])if(Le&&!E(ve,C(n,we,"")));else if(n)return!1;return!0},xt=function(e){return e.indexOf("-")>0},Ct=function(e){var t,n,o,i;bt("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Oe};for(i=s.length;i--;){var c=t=s[i],l=c.name,u=c.namespaceURI;if(n="value"===l?t.value:O(t.value),o=ge(l),a.attrName=o,a.attrValue=n,a.keepAttr=!0,a.forceKeepAttr=void 0,bt("uponSanitizeAttribute",e,a),n=a.attrValue,!a.forceKeepAttr&&(pt(l,e),a.keepAttr))if(E(/\/>/i,n))pt(l,e);else{Me&&(n=C(n,me," "),n=C(n,ye," "));var h=ge(e.nodeName);if(wt(h,o,n))try{u?e.setAttributeNS(u,l,n):e.setAttribute(l,n),b(r.removed)}catch(e){}}}bt("afterSanitizeAttributes",e,null)}},St=function e(t){var n,r=mt(t);for(bt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)bt("uponSanitizeShadowNode",n,null),vt(n)||(n.content instanceof a&&e(n.content),Ct(n));bt("afterSanitizeShadowDOM",t,null)};return r.sanitize=function(t,o){var s,c,u,h,d;if((et=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!_t(t)){if("function"!=typeof t.toString)throw A("toString is not a function");if("string"!=typeof(t=t.toString()))throw A("dirty is not a string, aborting")}if(!r.isSupported){if("object"===e(n.toStaticHTML)||"function"==typeof n.toStaticHTML){if("string"==typeof t)return n.toStaticHTML(t);if(_t(t))return n.toStaticHTML(t.outerHTML)}return t}if(Ne||st(o),r.removed=[],"string"==typeof t&&(He=!1),He){if(t.nodeName){var f=ge(t.nodeName);if(!Ce[f]||ke[f])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)1===(c=(s=gt("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===c.nodeName||"HTML"===c.nodeName?s=c:s.appendChild(c);else{if(!Fe&&!Me&&!Pe&&-1===t.indexOf("<"))return oe&&Ue?oe.createHTML(t):t;if(!(s=gt(t)))return Fe?null:Ue?ie:""}s&&Re&&ft(s.firstChild);for(var p=mt(He?t:s);u=p.nextNode();)3===u.nodeType&&u===h||vt(u)||(u.content instanceof a&&St(u.content),Ct(u),h=u);if(h=null,He)return t;if(Fe){if(De)for(d=le.call(s.ownerDocument);s.firstChild;)d.appendChild(s.firstChild);else d=s;return Oe.shadowroot&&(d=he.call(i,d,!0)),d}var g=Pe?s.outerHTML:s.innerHTML;return Pe&&Ce["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&E(K,s.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+g),Me&&(g=C(g,me," "),g=C(g,ye," ")),oe&&Ue?oe.createHTML(g):g},r.setConfig=function(e){st(e),Ne=!0},r.clearConfig=function(){rt=null,Ne=!1},r.isValidAttribute=function(e,t,n){rt||st({});var r=ge(e),o=ge(t);return wt(r,o,n)},r.addHook=function(e,t){"function"==typeof t&&(fe[e]=fe[e]||[],v(fe[e],t))},r.removeHook=function(e){if(fe[e])return b(fe[e])},r.removeHooks=function(e){fe[e]&&(fe[e]=[])},r.removeAllHooks=function(){fe={}},r}()}()},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,i),!0;case 6:return u.fn.call(u.context,t,r,o,i,s),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var d,f=u.length;for(l=0;l<f;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[i]=1===l.length?l[0]:l:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},717:e=>{"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},824:e=>{var t=1e3,n=60*t,r=60*n,o=24*r;function i(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,s){s=s||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(i){var s=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*o;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===l&&isFinite(e))return s.long?(a=e,(c=Math.abs(a))>=o?i(a,c,o,"day"):c>=r?i(a,c,r,"hour"):c>=n?i(a,c,n,"minute"):c>=t?i(a,c,t,"second"):a+" ms"):function(e){var i=Math.abs(e);return i>=o?Math.round(e/o)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},520:(e,t,n)=>{"use strict";var r=n(155),o="win32"===r.platform,i=n(539);function s(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r];o&&"."!==o&&(".."===o?n.length&&".."!==n[n.length-1]?n.pop():t&&n.push(".."):n.push(o))}return n}function a(e){for(var t=e.length-1,n=0;n<=t&&!e[n];n++);for(var r=t;r>=0&&!e[r];r--);return 0===n&&r===t?e:n>r?[]:e.slice(n,r+1)}var c=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,l=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,u={};function h(e){var t=c.exec(e),n=(t[1]||"")+(t[2]||""),r=t[3]||"",o=l.exec(r);return[n,o[1],o[2],o[3]]}function d(e){var t=c.exec(e),n=t[1]||"",r=!!n&&":"!==n[1];return{device:n,isUnc:r,isAbsolute:r||!!t[2],tail:t[3]}}function f(e){return"\\\\"+e.replace(/^[\\\/]+/,"").replace(/[\\\/]+/g,"\\")}u.resolve=function(){for(var e="",t="",n=!1,o=arguments.length-1;o>=-1;o--){var a;if(o>=0?a=arguments[o]:e?(a=r.env["="+e])&&a.substr(0,3).toLowerCase()===e.toLowerCase()+"\\"||(a=e+"\\"):a=r.cwd(),!i.isString(a))throw new TypeError("Arguments to path.resolve must be strings");if(a){var c=d(a),l=c.device,u=c.isUnc,h=c.isAbsolute,p=c.tail;if((!l||!e||l.toLowerCase()===e.toLowerCase())&&(e||(e=l),n||(t=p+"\\"+t,n=h),e&&n))break}}return u&&(e=f(e)),e+(n?"\\":"")+(t=s(t.split(/[\\\/]+/),!n).join("\\"))||"."},u.normalize=function(e){var t=d(e),n=t.device,r=t.isUnc,o=t.isAbsolute,i=t.tail,a=/[\\\/]$/.test(i);return(i=s(i.split(/[\\\/]+/),!o).join("\\"))||o||(i="."),i&&a&&(i+="\\"),r&&(n=f(n)),n+(o?"\\":"")+i},u.isAbsolute=function(e){return d(e).isAbsolute},u.join=function(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(!i.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&e.push(n)}var r=e.join("\\");return/^[\\\/]{2}[^\\\/]/.test(e[0])||(r=r.replace(/^[\\\/]{2,}/,"\\")),u.normalize(r)},u.relative=function(e,t){e=u.resolve(e),t=u.resolve(t);for(var n=e.toLowerCase(),r=t.toLowerCase(),o=a(t.split("\\")),i=a(n.split("\\")),s=a(r.split("\\")),c=Math.min(i.length,s.length),l=c,h=0;h<c;h++)if(i[h]!==s[h]){l=h;break}if(0==l)return t;var d=[];for(h=l;h<i.length;h++)d.push("..");return(d=d.concat(o.slice(l))).join("\\")},u._makeLong=function(e){if(!i.isString(e))return e;if(!e)return"";var t=u.resolve(e);return/^[a-zA-Z]\:\\/.test(t)?"\\\\?\\"+t:/^\\\\[^?.]/.test(t)?"\\\\?\\UNC\\"+t.substring(2):e},u.dirname=function(e){var t=h(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},u.basename=function(e,t){var n=h(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},u.extname=function(e){return h(e)[3]},u.format=function(e){if(!i.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!i.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var n=e.dir,r=e.base||"";return n?n[n.length-1]===u.sep?n+r:n+u.sep+r:r},u.parse=function(e){if(!i.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=h(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},u.sep="\\",u.delimiter=";";var p=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,g={};function m(e){return p.exec(e).slice(1)}g.resolve=function(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var o=n>=0?arguments[n]:r.cwd();if(!i.isString(o))throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,t="/"===o[0])}return(t?"/":"")+(e=s(e.split("/"),!t).join("/"))||"."},g.normalize=function(e){var t=g.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=s(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},g.isAbsolute=function(e){return"/"===e.charAt(0)},g.join=function(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];if(!i.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&(e+=e?"/"+n:n)}return g.normalize(e)},g.relative=function(e,t){e=g.resolve(e).substr(1),t=g.resolve(t).substr(1);for(var n=a(e.split("/")),r=a(t.split("/")),o=Math.min(n.length,r.length),i=o,s=0;s<o;s++)if(n[s]!==r[s]){i=s;break}var c=[];for(s=i;s<n.length;s++)c.push("..");return(c=c.concat(r.slice(i))).join("/")},g._makeLong=function(e){return e},g.dirname=function(e){var t=m(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},g.basename=function(e,t){var n=m(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},g.extname=function(e){return m(e)[3]},g.format=function(e){if(!i.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!i.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);return(e.dir?e.dir+g.sep:"")+(e.base||"")},g.parse=function(e){if(!i.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=m(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return t[1]=t[1]||"",t[2]=t[2]||"",t[3]=t[3]||"",{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},g.sep="/",g.delimiter=":",e.exports=o?u:g,e.exports.posix=g,e.exports.win32=u},155:e=>{var t,n,r=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var a,c=[],l=!1,u=-1;function h(){l&&a&&(l=!1,a.length?c=a.concat(c):u=-1,c.length&&d())}function d(){if(!l){var e=s(h);l=!0;for(var t=c.length;t;){for(a=c,c=[];++u<t;)a&&a[u].run();u=-1,t=c.length}a=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||s(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=p,r.addListener=p,r.once=p,r.off=p,r.removeListener=p,r.removeAllListeners=p,r.emit=p,r.prependListener=p,r.prependOnceListener=p,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},384:e=>{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},539:(e,t,n)=>{var r=n(155),o=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,s=String(e).replace(o,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n<i;c=r[++n])g(c)||!v(c)?s+=" "+c:s+=" "+a(c);return s},t.deprecate=function(e,o){if(_(n.g.process))return function(){return t.deprecate(e,o).apply(this,arguments)};if(!0===r.noDeprecation)return e;var i=!1;return function(){if(!i){if(r.throwDeprecation)throw new Error(o);r.traceDeprecation?console.trace(o):console.error(o),i=!0}return e.apply(this,arguments)}};var i,s={};function a(e,n){var r={seen:[],stylize:l};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),p(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=c),u(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function u(e,n,r){if(e.customInspect&&n&&C(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,e);return y(o)||(o=u(e,o,r)),o}var i=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):p(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,n);if(i)return i;var s=Object.keys(n),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),x(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(n);if(0===s.length){if(C(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(b(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return e.stylize(Date.prototype.toString.call(n),"date");if(x(n))return h(n)}var l,v="",S=!1,O=["{","}"];return f(n)&&(S=!0,O=["[","]"]),C(n)&&(v=" [Function"+(n.name?": "+n.name:"")+"]"),b(n)&&(v=" "+RegExp.prototype.toString.call(n)),w(n)&&(v=" "+Date.prototype.toUTCString.call(n)),x(n)&&(v=" "+h(n)),0!==s.length||S&&0!=n.length?r<0?b(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),l=S?function(e,t,n,r,o){for(var i=[],s=0,a=t.length;s<a;++s)k(t,String(s))?i.push(d(e,t,n,r,String(s),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(d(e,t,n,r,o,!0))})),i}(e,n,r,a,s):s.map((function(t){return d(e,n,r,a,t,S)})),e.seen.pop(),function(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(l,v,O)):O[0]+v+O[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,o,i){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),k(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?u(e,c.value,null):u(e,c.value,n-1)).indexOf("\n")>-1&&(a=i?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),_(s)){if(i&&o.match(/^\d+$/))return a;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function f(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function b(e){return v(e)&&"[object RegExp]"===S(e)}function v(e){return"object"==typeof e&&null!==e}function w(e){return v(e)&&"[object Date]"===S(e)}function x(e){return v(e)&&("[object Error]"===S(e)||e instanceof Error)}function C(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(_(i)&&(i=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=f,t.isBoolean=p,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=b,t.isObject=v,t.isDate=w,t.isError=x,t.isFunction=C,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(384);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(){var e=new Date,t=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":");return[e.getDate(),E[e.getMonth()],t].join(" ")}function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",A(),t.format.apply(t,arguments))},t.inherits=n(717),t._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{PluginLocal:()=>Kr,pluginHelpers:()=>t,setupPluginCore:()=>Qr});var e={};n.r(e),n.d(e,{setSDKMetadata:()=>dt});var t={};n.r(t),n.d(t,{IS_DEV:()=>pt,PROTOCOL_FILE:()=>gt,PROTOCOL_LSP:()=>mt,PluginLogger:()=>St,URL_LSP:()=>yt,cleanInjectedScripts:()=>Dt,cleanInjectedUI:()=>Ft,deepMerge:()=>Ct,deferred:()=>It,genID:()=>Et,getAppPathRoot:()=>vt,getSDKPathRoot:()=>wt,injectTheme:()=>$t,invokeHostExportedApi:()=>Lt,isObject:()=>xt,isValidUUID:()=>Ot,mergeSettingsWithSchema:()=>zt,path:()=>ft,safeSnakeCase:()=>bt,safetyPathJoin:()=>jt,safetyPathNormalize:()=>Tt,setupIframeSandbox:()=>Mt,setupInjectedStyle:()=>Pt,setupInjectedUI:()=>Rt,transformableEvent:()=>Ut,ucFirst:()=>At,withFileProtocol:()=>kt});var o=n(729),i=n.n(o),s=n(520),a=n(856),c=n.n(a);const l=function(e,t){return e===t||e!=e&&t!=t},u=function(e,t){for(var n=e.length;n--;)if(l(e[n][0],t))return n;return-1};var h=Array.prototype.splice;function d(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}d.prototype.clear=function(){this.__data__=[],this.size=0},d.prototype.delete=function(e){var t=this.__data__,n=u(t,e);return!(n<0||(n==t.length-1?t.pop():h.call(t,n,1),--this.size,0))},d.prototype.get=function(e){var t=this.__data__,n=u(t,e);return n<0?void 0:t[n][1]},d.prototype.has=function(e){return u(this.__data__,e)>-1},d.prototype.set=function(e,t){var n=this.__data__,r=u(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const f=d,p="object"==typeof global&&global&&global.Object===Object&&global;var g="object"==typeof self&&self&&self.Object===Object&&self;const m=p||g||Function("return this")(),y=m.Symbol;var _=Object.prototype,b=_.hasOwnProperty,v=_.toString,w=y?y.toStringTag:void 0;var x=Object.prototype.toString;var C=y?y.toStringTag:void 0;const S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":C&&C in Object(e)?function(e){var t=b.call(e,w),n=e[w];try{e[w]=void 0;var r=!0}catch(e){}var o=v.call(e);return r&&(t?e[w]=n:delete e[w]),o}(e):function(e){return x.call(e)}(e)},O=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},E=function(e){if(!O(e))return!1;var t=S(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},A=m["__core-js_shared__"];var k,j=(k=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var T=Function.prototype.toString;const I=function(e){if(null!=e){try{return T.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var L=/^\[object .+?Constructor\]$/,M=Function.prototype,P=Object.prototype,N=M.toString,R=P.hasOwnProperty,F=RegExp("^"+N.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const D=function(e){return!(!O(e)||(t=e,j&&j in t))&&(E(e)?F:L).test(I(e));var t},U=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return D(n)?n:void 0},$=U(m,"Map"),z=U(Object,"create");var H=Object.prototype.hasOwnProperty;var q=Object.prototype.hasOwnProperty;function B(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}B.prototype.clear=function(){this.__data__=z?z(null):{},this.size=0},B.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},B.prototype.get=function(e){var t=this.__data__;if(z){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return H.call(t,e)?t[e]:void 0},B.prototype.has=function(e){var t=this.__data__;return z?void 0!==t[e]:q.call(t,e)},B.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=z&&void 0===t?"__lodash_hash_undefined__":t,this};const W=B,G=function(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map};function J(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}J.prototype.clear=function(){this.size=0,this.__data__={hash:new W,map:new($||f),string:new W}},J.prototype.delete=function(e){var t=G(this,e).delete(e);return this.size-=t?1:0,t},J.prototype.get=function(e){return G(this,e).get(e)},J.prototype.has=function(e){return G(this,e).has(e)},J.prototype.set=function(e,t){var n=G(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const V=J;function Z(e){var t=this.__data__=new f(e);this.size=t.size}Z.prototype.clear=function(){this.__data__=new f,this.size=0},Z.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Z.prototype.get=function(e){return this.__data__.get(e)},Z.prototype.has=function(e){return this.__data__.has(e)},Z.prototype.set=function(e,t){var n=this.__data__;if(n instanceof f){var r=n.__data__;if(!$||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new V(r)}return n.set(e,t),this.size=n.size,this};const K=Z,Y=function(){try{var e=U(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Q=function(e,t,n){"__proto__"==t&&Y?Y(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},X=function(e,t,n){(void 0!==n&&!l(e[t],n)||void 0===n&&!(t in e))&&Q(e,t,n)},ee=function(e,t,n){for(var r=-1,o=Object(e),i=n(e),s=i.length;s--;){var a=i[++r];if(!1===t(o[a],a,o))break}return e};var te="object"==typeof exports&&exports&&!exports.nodeType&&exports,ne=te&&"object"==typeof module&&module&&!module.nodeType&&module,re=ne&&ne.exports===te?m.Buffer:void 0,oe=re?re.allocUnsafe:void 0;const ie=m.Uint8Array,se=function(e,t){var n,r,o=t?(n=e.buffer,r=new n.constructor(n.byteLength),new ie(r).set(new ie(n)),r):e.buffer;return new e.constructor(o,e.byteOffset,e.length)};var ae=Object.create;const ce=function(){function e(){}return function(t){if(!O(t))return{};if(ae)return ae(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),le=function(e,t){return function(n){return e(t(n))}},ue=le(Object.getPrototypeOf,Object);var he=Object.prototype;const de=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||he)},fe=function(e){return null!=e&&"object"==typeof e},pe=function(e){return fe(e)&&"[object Arguments]"==S(e)};var ge=Object.prototype,me=ge.hasOwnProperty,ye=ge.propertyIsEnumerable;const _e=pe(function(){return arguments}())?pe:function(e){return fe(e)&&me.call(e,"callee")&&!ye.call(e,"callee")},be=Array.isArray,ve=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},we=function(e){return null!=e&&ve(e.length)&&!E(e)};var xe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ce=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Se=Ce&&Ce.exports===xe?m.Buffer:void 0;const Oe=(Se?Se.isBuffer:void 0)||function(){return!1};var Ee=Function.prototype,Ae=Object.prototype,ke=Ee.toString,je=Ae.hasOwnProperty,Te=ke.call(Object);var Ie={};Ie["[object Float32Array]"]=Ie["[object Float64Array]"]=Ie["[object Int8Array]"]=Ie["[object Int16Array]"]=Ie["[object Int32Array]"]=Ie["[object Uint8Array]"]=Ie["[object Uint8ClampedArray]"]=Ie["[object Uint16Array]"]=Ie["[object Uint32Array]"]=!0,Ie["[object Arguments]"]=Ie["[object Array]"]=Ie["[object ArrayBuffer]"]=Ie["[object Boolean]"]=Ie["[object DataView]"]=Ie["[object Date]"]=Ie["[object Error]"]=Ie["[object Function]"]=Ie["[object Map]"]=Ie["[object Number]"]=Ie["[object Object]"]=Ie["[object RegExp]"]=Ie["[object Set]"]=Ie["[object String]"]=Ie["[object WeakMap]"]=!1;var Le="object"==typeof exports&&exports&&!exports.nodeType&&exports,Me=Le&&"object"==typeof module&&module&&!module.nodeType&&module,Pe=Me&&Me.exports===Le&&p.process,Ne=function(){try{return Me&&Me.require&&Me.require("util").types||Pe&&Pe.binding&&Pe.binding("util")}catch(e){}}(),Re=Ne&&Ne.isTypedArray;const Fe=Re?(De=Re,function(e){return De(e)}):function(e){return fe(e)&&ve(e.length)&&!!Ie[S(e)]};var De;const Ue=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var $e=Object.prototype.hasOwnProperty;const ze=function(e,t,n){var r=e[t];$e.call(e,t)&&l(r,n)&&(void 0!==n||t in e)||Q(e,t,n)};var He=/^(?:0|[1-9]\d*)$/;const qe=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&He.test(e))&&e>-1&&e%1==0&&e<t};var Be=Object.prototype.hasOwnProperty;const We=function(e,t){var n=be(e),r=!n&&_e(e),o=!n&&!r&&Oe(e),i=!n&&!r&&!o&&Fe(e),s=n||r||o||i,a=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],c=a.length;for(var l in e)!t&&!Be.call(e,l)||s&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||qe(l,c))||a.push(l);return a};var Ge=Object.prototype.hasOwnProperty;const Je=function(e){if(!O(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=de(e),n=[];for(var r in e)("constructor"!=r||!t&&Ge.call(e,r))&&n.push(r);return n},Ve=function(e){return we(e)?We(e,!0):Je(e)},Ze=function(e){return function(e,t,n,r){var o=!n;n||(n={});for(var i=-1,s=t.length;++i<s;){var a=t[i],c=r?r(n[a],e[a],a,n,e):void 0;void 0===c&&(c=e[a]),o?Q(n,a,c):ze(n,a,c)}return n}(e,Ve(e))},Ke=function(e,t,n,r,o,i,s){var a,c=Ue(e,n),l=Ue(t,n),u=s.get(l);if(u)X(e,n,u);else{var h=i?i(c,l,n+"",e,t,s):void 0,d=void 0===h;if(d){var f=be(l),p=!f&&Oe(l),g=!f&&!p&&Fe(l);h=l,f||p||g?be(c)?h=c:fe(a=c)&&we(a)?h=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(c):p?(d=!1,h=function(e,t){if(t)return e.slice();var n=e.length,r=oe?oe(n):new e.constructor(n);return e.copy(r),r}(l,!0)):g?(d=!1,h=se(l,!0)):h=[]:function(e){if(!fe(e)||"[object Object]"!=S(e))return!1;var t=ue(e);if(null===t)return!0;var n=je.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&ke.call(n)==Te}(l)||_e(l)?(h=c,_e(c)?h=Ze(c):O(c)&&!E(c)||(h=function(e){return"function"!=typeof e.constructor||de(e)?{}:ce(ue(e))}(l))):d=!1}d&&(s.set(l,h),o(h,l,r,i,s),s.delete(l)),X(e,n,h)}},Ye=function e(t,n,r,o,i){t!==n&&ee(n,(function(s,a){if(i||(i=new K),O(s))Ke(t,n,a,r,e,o,i);else{var c=o?o(Ue(t,a),s,a+"",t,n,i):void 0;void 0===c&&(c=s),X(t,a,c)}}),Ve)},Qe=function(e){return e},Xe=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)};var et=Math.max;const tt=Y?function(e,t){return Y(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:Qe;var nt=Date.now;const rt=function(e){var t=0,n=0;return function(){var r=nt(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(tt),ot=function(e,t){return rt(function(e,t,n){return t=et(void 0===t?e.length-1:t,0),function(){for(var r=arguments,o=-1,i=et(r.length-t,0),s=Array(i);++o<i;)s[o]=r[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=r[o];return a[t]=n(s),Xe(e,this,a)}}(e,t,Qe),e+"")},it=(st=function(e,t,n){Ye(e,t,n)},ot((function(e,t){var n=-1,r=t.length,o=r>1?t[r-1]:void 0,i=r>2?t[2]:void 0;for(o=st.length>3&&"function"==typeof o?(r--,o):void 0,i&&function(e,t,n){if(!O(n))return!1;var r=typeof t;return!!("number"==r?we(n)&&qe(t,n.length):"string"==r&&t in n)&&l(n[t],e)}(t[0],t[1],i)&&(o=r<3?void 0:o,r=1),e=Object(e);++n<r;){var s=t[n];s&&st(e,s,n)}return e})));var st,at=function(){return at=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},at.apply(this,arguments)};function ct(e){return e.toLowerCase()}Object.create,Object.create;var lt=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ut=/[^A-Z0-9]+/gi;function ht(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function dt(e){this?.sdk&&e&&(this.sdk=Object.assign({},this.sdk,e))}const ft="win32"===navigator.platform.toLowerCase()?s.win32:s.posix,pt=!1,gt="file://",mt="lsp://",yt=mt+"logseq.io/";let _t;const bt=function(e,t){return void 0===t&&(t={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,r=void 0===n?lt:n,o=t.stripRegexp,i=void 0===o?ut:o,s=t.transform,a=void 0===s?ct:s,c=t.delimiter,l=void 0===c?" ":c,u=ht(ht(e,r,"$1\0$2"),i,"\0"),h=0,d=u.length;"\0"===u.charAt(h);)h++;for(;"\0"===u.charAt(d-1);)d--;return u.slice(h,d).split("\0").map(a).join(l)}(e,at({delimiter:"."},t))}(e,at({delimiter:"_"},t))};async function vt(){return _t||(_t=await Lt("_callApplication","getAppPath"))}async function wt(){return pt?localStorage.getItem("LSP_DEV_SDK_ROOT")||"http://localhost:8080":jt(await vt(),"js")}function xt(e){return e===Object(e)&&!Array.isArray(e)}const Ct=it;class St extends(i()){_tag;_opts;_logs=[];constructor(e,t){super(),this._tag=e,this._opts=t}write(e,t,n){t?.length&&!0===t[t.length-1]&&(n=!0,t.pop());const r=t.reduce(((e,t)=>(t&&t instanceof Error?e+=`${t.message} ${t.stack}`:e+=t.toString(),e)),`[${this._tag}][${(new Date).toLocaleTimeString()}] `);this._logs.push([e,r]),(n||this._opts?.console)&&console?.["ERROR"===e?"error":"debug"](`${e}: ${r}`),this.emit("change")}clear(){this._logs=[],this.emit("change")}info(...e){this.write("INFO",e)}error(...e){this.write("ERROR",e)}warn(...e){this.write("WARN",e)}setTag(e){this._tag=e}toJSON(){return this._logs}}function Ot(e){return"string"==typeof e&&36===e.length&&/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(e)}function Et(){return"_"+Math.random().toString(36).substr(2,9)}function At(e){return e.charAt(0).toUpperCase()+e.slice(1)}function kt(e){return e?(/^(http|file|lsp)/.test(e)||(e=gt+e),e):""}function jt(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=ft.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return ft.join(e,...t)}}function Tt(e){return e?.match(/^(http?|lsp|assets):/)||(e=ft.normalize(e)),e}function It(e,t){let n,r,o=!1;const i=t=>n=>{e&&clearTimeout(e),t(n),o=!0},s=new Promise(((o,s)=>{n=i(o),r=i(s),e&&(e=setTimeout((()=>r(new Error(`[deferred timeout] ${t}`))),e))}));return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:r,promise:s,get settled(){return o}}}function Lt(t,...n){t=t?.startsWith("_call")?t:t?.replace(/^[_$]+/,"");const r=bt(t),o=Object.assign(window.logseq?.api||{},e),i=o[r]||window.apis[r]||o[t]||window.apis[t];if(!i)throw new Error(`Not existed method #${t}`);return"function"!=typeof i?i:i.apply(this,n)}function Mt(e,t){const n=document.createElement("iframe");return n.classList.add("lsp-iframe-sandbox"),Object.entries(e).forEach((([e,t])=>{n.setAttribute(e,t)})),t.appendChild(n),async()=>{t.removeChild(n)}}function Pt(e,t){const n=t["data-injected-style"];let r=n&&document.querySelector(`[data-injected-style=${n}]`);if(!r)return r=document.createElement("style"),r.textContent=e,t&&Object.entries(t).forEach((([e,t])=>{r.setAttribute(e,t)})),document.head.append(r),()=>{document.head.removeChild(r)};r.textContent=e}const Nt=new Map;function Rt(e,t,n){let r,o,i="";const s=this;"slot"in e?(i=e.slot,r=`#${i}`):"path"in e?r=e.path:o=!0;const a=`${s.id}--${e.key||Et()}`,l=a,u=o?document.body:r&&document.querySelector(r);if(!u)return void console.error(`${this.debugTag} can not resolve selector target ${r}`);if(!e.template)return void Nt.get(a)?.call(null);e.template=c().sanitize(e.template,{ADD_TAGS:["iframe"],ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_ATTR:["allow","src","allowfullscreen","frameborder","scrolling","target"]});let h,d,f=document.querySelector(`#${a}`),p=o?f?.querySelector(".ls-ui-float-content"):f;if(!p)return f=document.createElement("div"),f.id=a,f.dataset.injectedUi=l||"",o?(p=document.createElement("div"),p.classList.add("ls-ui-float-content"),f.appendChild(p)):p=f,p.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{f.setAttribute(e,t)})),e.style&&Object.entries(e.style).forEach((([e,t])=>{f.style[e]=t})),o&&(f.setAttribute("draggable","true"),f.setAttribute("resizable","true"),e.close&&(f.dataset.close=e.close),f.classList.add("lsp-ui-float-container","visible"),s._setupResizableContainer(f,l),d=s._setupDraggableContainer(f,{key:l,close:()=>h(),title:t?.title})),i&&e.reset&&Array.from(u.querySelectorAll("[data-injected-ui]")).map((e=>e.id))?.forEach((e=>{Nt.get(e)?.call(null)})),u.appendChild(f),["click","focus","focusin","focusout","blur","dblclick","keyup","keypress","keydown","change","input","contextmenu"].forEach((e=>{f.addEventListener(e,(t=>{const n=t.target.closest(`[data-on-${e}]`);if(!n)return;const{preventDefault:r}=n.dataset,o=n.dataset[`on${At(e)}`];o&&s.caller?.callUserModel(o,Ut(n,t)),"true"===r?.toLowerCase()&&t.preventDefault()}),!1)})),n?.({el:f,float:o}),h=()=>{d?.(),Nt.delete(a),u.removeChild(f)},Nt.set(a,h),h;{p.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{f.setAttribute(e,t)}));let n=null!=f.dataset.dx;e.style&&Object.entries(e.style).forEach((([e,t])=>{n&&["left","top","bottom","right","width","height"].includes(e)||(f.style[e]=t)}))}}function Ft(e){if(!Nt.has(e))return;const t=Nt.get(e);try{t()}catch(t){console.warn("[CLEAN Injected UI] ",e,t)}}function Dt(){document.head.querySelectorAll(`script[data-ref=${this.id}]`)?.forEach((e=>e.remove()))}function Ut(e,t){const n={};if(e){n.type=t.type;const r=e.dataset,o="rect";["value","id","className","dataset",o].forEach((t=>{let i;if(t===o){if(!r.hasOwnProperty(o))return;i=e.getBoundingClientRect().toJSON()}else i=e[t];"object"==typeof i&&(i={...i}),n[t]=i}))}return n}function $t(e){const t=document.createElement("link");return t.rel="stylesheet",t.href=e,document.head.appendChild(t),()=>{try{document.head.removeChild(t)}catch(e){console.error(e)}}}function zt(e,t){const n=(t||[]).reduce(((e,t)=>("default"in t&&(e[t.key]=t.default),e)),{});return Object.assign(n,e)}window.__injectedUIEffects=Nt;var Ht=n(227),qt=n.n(Ht);const Bt="application/x-postmate-v1+json";let Wt=0;const Gt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},Jt=(e,t)=>!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==Bt||!Gt[e.data.postmate]);class Vt{parent;frame;child;events={};childOrigin;listener;constructor(e){this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.listener=e=>{if(!Jt(e,this.childOrigin))return!1;const{data:t,name:n}=((e||{}).data||{}).value||{};"emit"===e.data.postmate&&n in this.events&&this.events[n].forEach((e=>{e.call(this,t)}))},this.parent.addEventListener("message",this.listener,!1)}get(e,...t){return new Promise((n=>{const r=++Wt,o=e=>{e.data.uid===r&&"reply"===e.data.postmate&&(this.parent.removeEventListener("message",o,!1),n(e.data.value))};this.parent.addEventListener("message",o,!1),this.child.postMessage({postmate:"request",type:Bt,property:e,args:t,uid:r},this.childOrigin)}))}call(e,t){this.child.postMessage({postmate:"call",type:Bt,property:e,data:t},this.childOrigin)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}destroy(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)}}class Zt{model;parent;parentOrigin;child;constructor(e){this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(e=>{if(!Jt(e,this.parentOrigin))return;const{property:t,uid:n,data:r,args:o}=e.data;"call"!==e.data.postmate?((e,t,n)=>{const r="function"==typeof e[t]?e[t].apply(null,n):e[t];return Promise.resolve(r)})(this.model,t,o).then((r=>{e.source.postMessage({property:t,postmate:"reply",type:Bt,uid:n,value:r},e.origin)})):t in this.model&&"function"==typeof this.model[t]&&this.model[t](r)}))}emit(e,t){this.parent.postMessage({postmate:"emit",type:Bt,value:{name:e,data:t}},this.parentOrigin)}}class Kt{static debug=!1;container;parent;frame;child;childOrigin;url;model;static Model;constructor(e){this.container=e.container,this.url=e.url,this.parent=window,this.frame=document.createElement("iframe"),e.id&&(this.frame.id=e.id),e.name&&(this.frame.name=e.name),this.frame.classList.add.apply(this.frame.classList,e.classListArray||[]),this.container.appendChild(this.frame),this.child=this.frame.contentWindow,this.model=e.model||{}}sendHandshake(e){const t=(e=>{const t=document.createElement("a");t.href=e;const n=t.protocol.length>4?t.protocol:window.location.protocol,r=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||`${n}//${r}`})(e=e||this.url);let n,r=0;return new Promise(((o,i)=>{const s=e=>!!Jt(e,t)&&("handshake-reply"===e.data.postmate?(clearInterval(n),this.parent.removeEventListener("message",s,!1),this.childOrigin=e.origin,o(new Vt(this))):i("Failed handshake"));this.parent.addEventListener("message",s,!1);const a=()=>{r++,this.child.postMessage({postmate:"handshake",type:Bt,model:this.model},t),5===r&&clearInterval(n)};this.frame.addEventListener("load",(()=>{a(),n=setInterval(a,500)})),this.frame.src=e}))}destroy(){this.frame.parentNode.removeChild(this.frame)}}class Yt{child;model;parent;parentOrigin;constructor(e){this.child=window,this.model=e,this.parent=this.child.parent}sendHandshakeReply(){return new Promise(((e,t)=>{const n=r=>{if(r.data.postmate){if("handshake"===r.data.postmate){this.child.removeEventListener("message",n,!1),r.source.postMessage({postmate:"handshake-reply",type:Bt},r.origin),this.parentOrigin=r.origin;const t=r.data.model;return t&&Object.keys(t).forEach((e=>{this.model[e]=t[e]})),e(new Zt(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)}))}}class Qt{ctx;opts;constructor(e,t){this.ctx=e,this.opts=t}get ctxId(){return this.ctx.baseInfo.id}setItem(e,t){return this.ctx.caller.callAsync("api:call",{method:"write-plugin-storage-file",args:[this.ctxId,e,t,this.opts?.assets]})}getItem(e){return this.ctx.caller.callAsync("api:call",{method:"read-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}removeItem(e){return this.ctx.caller.call("api:call",{method:"unlink-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}allKeys(){return this.ctx.caller.callAsync("api:call",{method:"list-plugin-storage-files",args:[this.ctxId,this.opts?.assets]})}clear(){return this.ctx.caller.call("api:call",{method:"clear-plugin-storage-files",args:[this.ctxId,this.opts?.assets]})}hasItem(e){return this.ctx.caller.callAsync("api:call",{method:"exist-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}}class Xt{ctx;constructor(e){this.ctx=e}get React(){return this.ensureHostScope().React}get ReactDOM(){return this.ensureHostScope().ReactDOM}get pluginLocal(){return this.ensureHostScope().LSPluginCore.ensurePlugin(this.ctx.baseInfo.id)}invokeExperMethod(e,...t){const n=this.ensureHostScope();return e=bt(e)?.toLowerCase(),n.logseq.api["exper_"+e]?.apply(n,t)}async loadScripts(...e){(e=e.map((e=>e?.startsWith("http")?e:this.ctx.resolveResourceFullUrl(e)))).unshift(this.ctx.baseInfo.id),await this.invokeExperMethod("loadScripts",...e)}registerFencedCodeRenderer(e,t){return this.ensureHostScope().logseq.api.exper_register_fenced_code_renderer(this.ctx.baseInfo.id,e,t)}registerExtensionsEnhancer(e,t){const n=this.ensureHostScope();return"katex"===e&&n.katex&&t(n.katex).catch(console.error),n.logseq.api.exper_register_extensions_enhancer(this.ctx.baseInfo.id,e,t)}ensureHostScope(){if(window===top)throw new Error("Can not access host scope!");return top}}const en=e=>`task_callback_${e}`;class tn{_client;_requestId;_requestOptions;_promise;_aborted=!1;constructor(e,t,n={}){this._client=e,this._requestId=t,this._requestOptions=n,this._promise=new Promise(((e,t)=>{if(!this._requestId)return t(null);this._client.once(en(this._requestId),(n=>{n&&n instanceof Error?t(n):e(n)}))}));const{success:r,fail:o,final:i}=this._requestOptions;this._promise.then((e=>{r?.(e)})).catch((e=>{o?.(e)})).finally((()=>{i?.()}))}abort(){this._requestOptions.abortable&&!this._aborted&&(this._client.ctx._execCallableAPI("http_request_abort",this._requestId),this._aborted=!0)}get promise(){return this._promise}get client(){return this._client}get requestId(){return this._requestId}}class nn extends o.EventEmitter{_ctx;constructor(e){super(),this._ctx=e,this.ctx.caller.on("#lsp#request#callback",(e=>{const t=e?.requestId;t&&this.emit(en(t),e?.payload)}))}static createRequestTask(e,t,n){return new tn(e,t,n)}async _request(e){const t=this.ctx.baseInfo.id,{success:n,fail:r,final:o,...i}=e,s=this.ctx.Experiments.invokeExperMethod("request",t,i),a=nn.createRequestTask(this.ctx.Request,s,e);return i.abortable?a:a.promise}get ctx(){return this._ctx}}const rn=le(Object.keys,Object);var on=Object.prototype.hasOwnProperty;const sn=function(e){return we(e)?We(e):function(e){if(!de(e))return rn(e);var t=[];for(var n in Object(e))on.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)};function an(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new V;++t<n;)this.add(e[t])}an.prototype.add=an.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},an.prototype.has=function(e){return this.__data__.has(e)};const cn=an,ln=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1},un=function(e,t,n,r,o,i){var s=1&n,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var h=-1,d=!0,f=2&n?new cn:void 0;for(i.set(e,t),i.set(t,e);++h<a;){var p=e[h],g=t[h];if(r)var m=s?r(g,p,h,t,e,i):r(p,g,h,e,t,i);if(void 0!==m){if(m)continue;d=!1;break}if(f){if(!ln(t,(function(e,t){if(s=t,!f.has(s)&&(p===e||o(p,e,n,r,i)))return f.push(t);var s}))){d=!1;break}}else if(p!==g&&!o(p,g,n,r,i)){d=!1;break}}return i.delete(e),i.delete(t),d},hn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n},dn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n};var fn=y?y.prototype:void 0,pn=fn?fn.valueOf:void 0;var gn=Object.prototype.propertyIsEnumerable,mn=Object.getOwnPropertySymbols;const yn=mn?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[o++]=s)}return i}(mn(e),(function(t){return gn.call(e,t)})))}:function(){return[]},_n=function(e){return function(e,t,n){var r=t(e);return be(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,sn,yn)};var bn=Object.prototype.hasOwnProperty;const vn=U(m,"DataView"),wn=U(m,"Promise"),xn=U(m,"Set"),Cn=U(m,"WeakMap");var Sn="[object Map]",On="[object Promise]",En="[object Set]",An="[object WeakMap]",kn="[object DataView]",jn=I(vn),Tn=I($),In=I(wn),Ln=I(xn),Mn=I(Cn),Pn=S;(vn&&Pn(new vn(new ArrayBuffer(1)))!=kn||$&&Pn(new $)!=Sn||wn&&Pn(wn.resolve())!=On||xn&&Pn(new xn)!=En||Cn&&Pn(new Cn)!=An)&&(Pn=function(e){var t=S(e),n="[object Object]"==t?e.constructor:void 0,r=n?I(n):"";if(r)switch(r){case jn:return kn;case Tn:return Sn;case In:return On;case Ln:return En;case Mn:return An}return t});const Nn=Pn;var Rn="[object Arguments]",Fn="[object Array]",Dn="[object Object]",Un=Object.prototype.hasOwnProperty;const $n=function(e,t,n,r,o,i){var s=be(e),a=be(t),c=s?Fn:Nn(e),u=a?Fn:Nn(t),h=(c=c==Rn?Dn:c)==Dn,d=(u=u==Rn?Dn:u)==Dn,f=c==u;if(f&&Oe(e)){if(!Oe(t))return!1;s=!0,h=!1}if(f&&!h)return i||(i=new K),s||Fe(e)?un(e,t,n,r,o,i):function(e,t,n,r,o,i,s){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!i(new ie(e),new ie(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return l(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=hn;case"[object Set]":var c=1&r;if(a||(a=dn),e.size!=t.size&&!c)return!1;var u=s.get(e);if(u)return u==t;r|=2,s.set(e,t);var h=un(a(e),a(t),r,o,i,s);return s.delete(e),h;case"[object Symbol]":if(pn)return pn.call(e)==pn.call(t)}return!1}(e,t,c,n,r,o,i);if(!(1&n)){var p=h&&Un.call(e,"__wrapped__"),g=d&&Un.call(t,"__wrapped__");if(p||g){var m=p?e.value():e,y=g?t.value():t;return i||(i=new K),o(m,y,n,r,i)}}return!!f&&(i||(i=new K),function(e,t,n,r,o,i){var s=1&n,a=_n(e),c=a.length;if(c!=_n(t).length&&!s)return!1;for(var l=c;l--;){var u=a[l];if(!(s?u in t:bn.call(t,u)))return!1}var h=i.get(e),d=i.get(t);if(h&&d)return h==t&&d==e;var f=!0;i.set(e,t),i.set(t,e);for(var p=s;++l<c;){var g=e[u=a[l]],m=t[u];if(r)var y=s?r(m,g,u,t,e,i):r(g,m,u,e,t,i);if(!(void 0===y?g===m||o(g,m,n,r,i):y)){f=!1;break}p||(p="constructor"==u)}if(f&&!p){var _=e.constructor,b=t.constructor;_==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b||(f=!1)}return i.delete(e),i.delete(t),f}(e,t,n,r,o,i))},zn=function e(t,n,r,o,i){return t===n||(null==t||null==n||!fe(t)&&!fe(n)?t!=t&&n!=n:$n(t,n,r,o,e,i))},Hn=function(e){return e==e&&!O(e)},qn=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}},Bn=function(e){var t=function(e){for(var t=sn(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,Hn(o)]}return t}(e);return 1==t.length&&t[0][2]?qn(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,r){var o=n.length,i=o,s=!r;if(null==e)return!i;for(e=Object(e);o--;){var a=n[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){var c=(a=n[o])[0],l=e[c],u=a[1];if(s&&a[2]){if(void 0===l&&!(c in e))return!1}else{var h=new K;if(r)var d=r(l,u,c,e,t,h);if(!(void 0===d?zn(u,l,3,r,h):d))return!1}}return!0}(n,e,t)}},Wn=function(e){return"symbol"==typeof e||fe(e)&&"[object Symbol]"==S(e)};var Gn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jn=/^\w*$/;const Vn=function(e,t){if(be(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!Wn(e))||Jn.test(e)||!Gn.test(e)||null!=t&&e in Object(t)};function Zn(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(Zn.Cache||V),n}Zn.Cache=V;var Kn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Yn=/\\(\\)?/g;const Qn=(Xn=Zn((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(Kn,(function(e,n,r,o){t.push(r?o.replace(Yn,"$1"):n||e)})),t}),(function(e){return 500===er.size&&er.clear(),e})),er=Xn.cache,Xn);var Xn,er;var tr=y?y.prototype:void 0,nr=tr?tr.toString:void 0;const rr=function e(t){if("string"==typeof t)return t;if(be(t))return function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}(t,e)+"";if(Wn(t))return nr?nr.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n},or=function(e,t){return be(e)?e:Vn(e,t)?[e]:Qn(function(e){return null==e?"":rr(e)}(e))},ir=function(e){if("string"==typeof e||Wn(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t},sr=function(e,t){for(var n=0,r=(t=or(t,e)).length;null!=e&&n<r;)e=e[ir(t[n++])];return n&&n==r?e:void 0},ar=function(e,t){return null!=e&&t in Object(e)},cr=function(e,t){return null!=e&&function(e,t,n){for(var r=-1,o=(t=or(t,e)).length,i=!1;++r<o;){var s=ir(t[r]);if(!(i=null!=e&&n(e,s)))break;e=e[s]}return i||++r!=o?i:!!(o=null==e?0:e.length)&&ve(o)&&qe(s,o)&&(be(e)||_e(e))}(e,t,ar)},lr=function(e,t){return Vn(e)&&Hn(t)?qn(ir(e),t):function(n){var r=function(e,t,n){var r=null==e?void 0:sr(e,t);return void 0===r?n:r}(n,e);return void 0===r&&r===t?cr(n,e):zn(t,r,3)}},ur=function(e){return Vn(e)?(t=ir(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return sr(t,e)}}(e);var t},hr=function(e,t){var n,r={};return t="function"==typeof(n=t)?n:null==n?Qe:"object"==typeof n?be(n)?lr(n[0],n[1]):Bn(n):ur(n),function(e,t){e&&ee(e,t,sn)}(e,(function(e,n,o){Q(r,t(e,n,o),e)})),r};class dr{ctx;serviceHooks;constructor(e,t){this.ctx=e,this.serviceHooks=t,e._execCallableAPI("register-search-service",e.baseInfo.id,t.name,t.options),Object.entries({query:{f:"onQuery",args:["graph","q",!0],reply:!0,transformOutput:e=>(be(e?.blocks)&&(e.blocks=e.blocks.map((e=>e&&hr(e,((e,t)=>`block/${t}`))))),e)},rebuildBlocksIndice:{f:"onIndiceInit",args:["graph","blocks"]},transactBlocks:{f:"onBlocksChanged",args:["graph","data"]},truncateBlocks:{f:"onIndiceReset",args:["graph"]},removeDb:{f:"onGraph",args:["graph"]}}).forEach((([n,r])=>{const o=(e=>`service:search:${e}:${t.name}`)(n);e.caller.on(o,(async n=>{if(E(t?.[r.f])){let i=null;try{i=await t[r.f].apply(t,(r.args||[]).map((e=>{if(n){if(!0===e)return n;if(n.hasOwnProperty(e)){const t=n[e];return delete n[e],t}}}))),r.transformOutput&&(i=r.transformOutput(i))}catch(e){console.error("[SearchService] ",e),i=e}finally{r.reply&&e.caller.call(`${o}:reply`,i)}}}))}))}}const fr=Symbol.for("proxy-continue"),pr=qt()("LSPlugin:user"),gr=new St("",{console:!0});function mr(e,t,n){if("function"!=typeof n)return!1;const{key:r,label:o,desc:i,palette:s,keybinding:a,extras:c}=t,l=`SimpleCommandHook${r}${++wr}`;this.Editor["on"+l](n),this.caller?.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:r,label:o,type:e,desc:i,keybinding:a,extras:c},["editor/hook",l]],s]})}function yr(e){return!!Ot(e)||(gr.error(`#${e} is not a valid UUID string.`),!1)}let _r=null,br=new Map;const vr={async getInfo(e){return _r||(_r=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?_r[e]:_r},registerCommand:mr,registerSearchService(e){if(br.has(e.name))throw new Error(`SearchService: #${e.name} has registered!`);br.set(e.name,new dr(this,e))},registerCommandPalette(e,t){const{key:n,label:r,keybinding:o}=e;return mr.call(this,"$palette$",{key:n,label:r,palette:!0,keybinding:o},t)},registerCommandShortcut(e,t){const{binding:n}=e,r="$shortcut$",o=r+bt(n);return mr.call(this,r,{key:o,palette:!1,keybinding:e},t)},registerUIItem(e,t){const n=this.baseInfo.id;this.caller?.call("api:call",{method:"register-plugin-ui-item",args:[n,e,t]})},registerPageMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;mr.call(this,"page-menu-item",{key:n,label:r},t)},onBlockRendererSlotted(e,t){if(!yr(e))return;const n=this.baseInfo.id,r=`hook:editor:${bt(`slot:${e}`)}`;return this.caller.on(r,t),this.App._installPluginHook(n,r),()=>{this.caller.off(r,t),this.App._uninstallPluginHook(n,r)}},invokeExternalPlugin(e,...t){if(e=e?.trim(),!e)return;let[n,r]=e.split(".");if(!["models","commands"].includes(r?.toLowerCase()))throw new Error("Type only support '.models' or '.commands' currently.");const o=e.replace(`${n}.${r}.`,"");if(!n||!r||!o)throw new Error(`Illegal type of #${e} to invoke external plugin.`);return this._execCallableAPIAsync("invoke_external_plugin_cmd",n,r.toLowerCase(),o,t)},setFullScreen(e){const t=(...e)=>this._callWin("setFullScreen",...e);"toggle"===e?this._callWin("isFullScreen").then((e=>{e?t():t(!0)})):e?t(!0):t()}};let wr=0;const xr={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},registerSlashCommand(e,t){pr("Register slash command #",this.baseInfo.id,e,t),"function"==typeof t&&(t=[["editor/clear-current-slash",!1],["editor/restore-saved-cursor"],["editor/hook",t]]),t=t.map((e=>{const[t,...n]=e;if("editor/hook"===t){let r=n[0],o=()=>{this.caller?.callUserModel(r)};"function"==typeof r&&(o=r);const i=`SlashCommandHook${t}${++wr}`;e[1]=i,this.Editor["on"+i](o)}return e})),this.caller?.call("api:call",{method:"register-plugin-slash-command",args:[this.baseInfo.id,[e,t]]})},registerBlockContextMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id;mr.call(this,"block-context-menu-item",{key:n,label:e},t)},registerHighlightContextMenuItem(e,t,n){if("function"!=typeof t)return!1;const r=e+"_"+this.baseInfo.id;mr.call(this,"highlight-context-menu-item",{key:r,label:e,extras:n},t)},scrollToBlockInPage(e,t,n){const r="block-content-"+t;n?.replaceState?this.App.replaceState("page",{name:e},{anchor:r}):this.App.pushState("page",{name:e},{anchor:r})}},Cr={onBlockChanged(e,t){if(!yr(e))return;const n=this.baseInfo.id,r=`hook:db:${bt(`block:${e}`)}`,o=({block:n,txData:r,txMeta:o})=>{n.uuid===e&&t(n,r,o)};return this.caller.on(r,o),this.App._installPluginHook(n,r),()=>{this.caller.off(r,o),this.App._uninstallPluginHook(n,r)}},datascriptQuery(e,...t){return t.pop(),t?.some((e=>"function"==typeof e))?this.Experiments.ensureHostScope().logseq.api.datascript_query(e,...t):this._execCallableAPIAsync("datascript_query",e,...t)}},Sr={},Or={},Er={makeSandboxStorage(){return new Qt(this,{assets:!0})}};class Ar extends(i()){_baseInfo;_caller;_version=LIB_VERSION;_debugTag="";_settingsSchema;_connected=!1;_ui=new Map;_mFileStorage;_mRequest;_mExperiments;_beforeunloadCallback;constructor(e,t){super(),this._baseInfo=e,this._caller=t,t.on("sys:ui:visible",(e=>{e?.toggle&&this.toggleMainUI()})),t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign(this._baseInfo.settings,e);this.emit("settings:changed",{...n},t)})),t.on("beforeunload",(async e=>{const{actor:n,...r}=e,o=this._beforeunloadCallback;try{o&&await o(r),n?.resolve(null)}catch(e){console.debug(`${t.debugTag} [beforeunload] `,e),n?.reject(e)}}))}async ready(e,t){if(!this._connected)try{"function"==typeof e&&(t=e,e={});let n=await this._caller.connectToParent(e);this._connected=!0,n=Ct(this._baseInfo,n),n?.id&&(this._debugTag=this._caller.debugTag=`#${n.id} [${n.name}]`,this.logger.setTag(this._debugTag)),this._settingsSchema&&(n.settings=zt(n.settings,this._settingsSchema),await this.useSettingsSchema(this._settingsSchema));try{await this._execCallableAPIAsync("setSDKMetadata",{version:this._version})}catch(e){console.warn(e)}t&&t.call(this,n)}catch(e){console.error(`${this._debugTag} [Ready Error]`,e)}}ensureConnected(){if(!this._connected)throw new Error("not connected")}beforeunload(e){"function"==typeof e&&(this._beforeunloadCallback=e)}provideModel(e){return this.caller._extendUserModel(e),this}provideTheme(e){return this.caller.call("provider:theme",e),this}provideStyle(e){return this.caller.call("provider:style",e),this}provideUI(e){return this.caller.call("provider:ui",e),this}useSettingsSchema(e){return this.connected&&this.caller.call("settings:schema",{schema:e,isSync:!0}),this._settingsSchema=e,this}updateSettings(e){this.caller.call("settings:update",e)}onSettingsChanged(e){const t="settings:changed";return this.on(t,e),()=>this.off(t,e)}showSettingsUI(){this.caller.call("settings:visible:changed",{visible:!0})}hideSettingsUI(){this.caller.call("settings:visible:changed",{visible:!1})}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(e){const t={key:0,visible:!1,cursor:e?.restoreEditingCursor};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}showMainUI(e){const t={key:0,visible:!0,autoFocus:e?.autoFocus};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}toggleMainUI(){const e=this._ui.get(0);e&&e.visible?this.hideMainUI():this.showMainUI()}get version(){return this._version}get isMainUIVisible(){const e=this._ui.get(0);return Boolean(e&&e.visible)}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get effect(){return this&&(this.baseInfo?.effect||!this.baseInfo?.iir)}get logger(){return gr}get settings(){return this.baseInfo?.settings}get caller(){return this._caller}resolveResourceFullUrl(e){if(this.ensureConnected(),e)return e=e.replace(/^[.\\/]+/,""),jt(this._baseInfo.lsr,e)}_makeUserProxy(e,t){const n=this,r=this.caller;return new Proxy(e,{get(e,o,i){const s=e[o];return function(...e){if(s){const r=s.apply(n,e.concat(t));if(r!==fr)return r}if(t){const i=o.toString().match(/^(once|off|on)/i);if(null!=i){const o=i[0].toLowerCase(),s=i.input.slice(o.length),a="off"===o,c=n.baseInfo.id,l=`hook:${t}:${bt(s)}`,u=e[0],h=e[1];r[o](l,u);const d=()=>{r.off(l,u),r.listenerCount(l)||n.App._uninstallPluginHook(c,l)};return a?void d():(n.App._installPluginHook(c,l,h),d)}}let i=o;return["git","ui","assets"].includes(t)&&(i=t+"_"+i),r.callAsync("api:call",{tag:t,method:i,args:e})}}})}_execCallableAPIAsync(e,...t){return this._caller.callAsync("api:call",{method:e,args:t})}_execCallableAPI(e,...t){this._caller.call("api:call",{method:e,args:t})}_callWin(...e){return this._execCallableAPIAsync("_callMainWin",...e)}get App(){return this._makeUserProxy(vr,"app")}get Editor(){return this._makeUserProxy(xr,"editor")}get DB(){return this._makeUserProxy(Cr,"db")}get Git(){return this._makeUserProxy(Sr,"git")}get UI(){return this._makeUserProxy(Or,"ui")}get Assets(){return this._makeUserProxy(Er,"assets")}get FileStorage(){let e=this._mFileStorage;return e||(e=this._mFileStorage=new Qt(this)),e}get Request(){let e=this._mRequest;return e||(e=this._mRequest=new nn(this)),e}get Experiments(){let e=this._mExperiments;return e||(e=this._mExperiments=new Xt(this)),e}}if(null==window.__LSP__HOST__){const e=new Hr(null);window.logseq=new Ar({},e)}const{importHTML:kr,createSandboxContainer:jr}=window.QSandbox||{};function Tr(e,t){return e.startsWith("http")?fetch(e,t):(e=e.replace("file://",""),new Promise((async(t,n)=>{try{const n=await window.apis.doAction(["readFile",e]);t({text:()=>n})}catch(e){console.error(e),n(e)}})))}class Ir extends(i()){_pluginLocal;_frame;_root;_loaded=!1;_unmountFns=[];constructor(e){super(),this._pluginLocal=e,e._dispose((()=>{this._unmount()}))}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:r}=await kr(t,{fetch:Tr});this._mount(n,document.body);const o=jr(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;o.__shadow_mode__=!0,o.LSPluginLocal=this._pluginLocal,o.LSPluginShadow=this,o.LSPluginUser=o.logseq=new Ar(this._pluginLocal.toJSON(),this._pluginLocal.caller);const i=await r(o,!0);this._unmountFns.push(i.unmount),this._loaded=!0}_mount(e,t){const n=this._frame=document.createElement("div");n.classList.add("lsp-shadow-sandbox"),n.id=this._pluginLocal.id,this._root=n.attachShadow({mode:"open"}),this._root.innerHTML=`<div>${e}</div>`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){this.frame?.parentNode?.removeChild(this.frame)}get loaded(){return this._loaded}get document(){return this._root?.firstChild}get frame(){return this._frame}}const Lr=qt()("LSPlugin:caller"),Mr="#await#response#",Pr="#lspmsg#",Nr="#lspmsg#error#",Rr="#lspmsg#settings#",Fr="#lspmsg#beforeunload#",Dr="#lspmsg#reply#",Ur="#lspmsg#ready#",$r=e=>`#lspmsg#${e}`,zr=e=>`${Mr}${e}`;class Hr extends(i()){_pluginLocal;_connected=!1;_parent;_child;_shadow;_status;_userModel={};_call;_callUserModel;_debugTag="";constructor(e){super(),this._pluginLocal=e,e&&(this._debugTag=e.debugTag)}async connectToChild(){if(this._connected)return;const{shadow:e}=this._pluginLocal;e?await this._setupShadowSandbox():await this._setupIframeSandbox()}async connectToParent(e={}){if(this._connected)return;const t=this,n=null!=this._pluginLocal;let r=0,o=0;const i=new Map,s=It(6e4),a=this._extendUserModel({[Ur]:async e=>{a[$r(e?.pid)]=({type:e,payload:n})=>{Lr(`[host (_call) -> *user] ${this._debugTag}`,e,n),t.emit(e,n)},await s.resolve()},[Fr]:async e=>{const n=It(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},[Rr]:async({type:e,payload:n})=>{t.emit("settings:changed",n)},[Pr]:async({ns:e,type:n,payload:r})=>{Lr(`[host (async) -> *user] ${this._debugTag} ns=${e} type=${n}`,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},[Dr]:({_sync:e,result:t})=>{if(Lr(`[sync host -> *user] #${e}`,t),i.has(e)){const n=i.get(e);n&&(t?.hasOwnProperty(Nr)?n.reject(t[Nr]):n.resolve(t),i.delete(e))}},...e});if(n)return await s.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const c=new Yt(a).sendHandshakeReply();return this._status="pending",await c.then((e=>{this._child=e,this._connected=!0,this._call=async(t,n={},r)=>{if(r){const e=++o;i.set(e,r),n._sync=e,r.setTag(`async call #${e}`),Lr(`async call #${e}`)}return e.emit($r(a.baseInfo.id),{type:t,payload:n}),r?.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){Lr(`[model method] #${e} not existed`)}},r=setInterval((()=>{if(i.size>100)for(const[e,t]of i)t.settled&&i.delete(e)}),18e5)})).finally((()=>{this._status=void 0})),await s.promise,a.baseInfo}async call(e,t={}){return this._call?.call(this,e,t)}async callAsync(e,t={}){const n=It(1e4);return this._call?.call(this,e,t,n)}async callUserModel(e,...t){return this._callUserModel?.apply(this,[e,...t])}async callUserModelAsync(e,...t){return e=zr(e),this._callUserModel?.apply(this,[e,...t])}async _setupIframeSandbox(){const e=this._pluginLocal,t=e.id,n=`${t}_lsp_main`,r=new URL(e.options.entry);r.searchParams.set("__v__",pt?Date.now().toString():e.options.version);const o=document.querySelector(`#${n}`);o&&o.parentElement.removeChild(o);const i=document.createElement("div");i.classList.add("lsp-iframe-sandbox-container"),i.id=n,i.dataset.pid=t;try{const e=(await this._pluginLocal._loadLayoutsData())?.$$0;if(e){i.dataset.inited_layout="true";let{width:t,height:n,left:r,top:o,vw:s,vh:a}=e;r=Math.max(r,0),r="number"==typeof s?`${Math.min(100*r/s,99)}%`:`${r}px`,o=Math.max(o,45),o="number"==typeof a?`${Math.min(100*o/a,99)}%`:`${o}px`,Object.assign(i.style,{width:t+"px",height:n+"px",left:r,top:o})}}catch(e){console.error("[Restore Layout Error]",e)}document.body.appendChild(i);const s=new Kt({id:t+"_iframe",container:i,url:r.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let a,c=s.sendHandshake();return this._status="pending",new Promise(((t,n)=>{a=setTimeout((()=>{n(new Error("handshake Timeout")),s.destroy()}),4e3),c.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on($r(e.id),(({type:e,payload:t})=>{Lr("[user -> *host] ",e,t),this._pluginLocal?.emit(e,t||{}),this._pluginLocal?.caller.emit(e,t||{})})),this._call=async(...t)=>{await n.call($r(e.id),{type:t[0],payload:Object.assign(t[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,...t)=>{if(e.startsWith(Mr))return await n.get(e.replace(Mr,""),...t);n.call(e,t?.[0])},t(null)})).catch((e=>{n(e)})).finally((()=>{clearTimeout(a)}))})).catch((e=>{throw Lr("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new Ir(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(t,n={},r)=>(r&&(n.actor=r),this._pluginLocal?.emit(t,Object.assign(n,{$$pid:e.id})),r?.promise),this._callUserModel=async(...e)=>{let t=e[0];t?.startsWith(Mr)&&(t=t.replace(Mr,""));const n=e[1]||{},r=this._userModel[t];"function"==typeof r&&await r.call(null,n)}}catch(e){throw Lr("[shadow sandbox] error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame.parentNode}_getSandboxShadowContainer(){return this._shadow?.frame.parentNode}_getSandboxIframeRoot(){return this._parent?.frame}_getSandboxShadowRoot(){return this._shadow?.frame}set debugTag(e){this._debugTag=e}async destroy(){let e=null;this._parent&&(e=this._getSandboxIframeContainer(),await this._parent.destroy()),this._shadow&&(e=this._getSandboxShadowContainer(),this._shadow.destroy()),e?.parentNode.removeChild(e)}}const qr=qt()("LSPlugin:core"),Br="plugins";class Wr extends(i()){_userPluginSettings;_schema;_settings={disabled:!1};constructor(e,t){super(),this._userPluginSettings=e,this._schema=t,Object.assign(this._settings,e)}get(e){return this._settings[e]}set(e,t){const n=Ct({},this._settings);if("string"==typeof e){if(this._settings[e]==t)return;this._settings[e]=t}else{if(!xt(e))return;Ct(this._settings,e)}this.emit("change",Object.assign({},this._settings),n)}set settings(e){this._settings=e}get settings(){return this._settings}setSchema(e,t){if(this._schema=e,t){const t=this._settings;this._settings=zt(t,e),this.emit("change",this._settings,t)}}reset(){const e=this.settings,t={};this._schema,this.settings=t,this.emit("reset",t,e)}toJSON(){return this._settings}}var Gr;function Jr(e,t){return t&&e.startsWith(gt+t)&&(e=jt(yt,e.substr(gt.length+t.length))),e}!function(e){e.LOADING="loading",e.UNLOADING="unloading",e.LOADED="loaded",e.UNLOADED="unload",e.ERROR="error"}(Gr||(Gr={}));class Vr extends Error{constructor(e){super(e),this.name=Vr.name}}class Zr extends Error{constructor(e){super(e),this.name=Zr.name}}class Kr extends(i()){_options;_themeMgr;_ctx;_sdk={};_disposes=[];_id;_status=Gr.UNLOADED;_loadErr;_localRoot;_dotSettingsFile;_caller;_logger;constructor(e,t,n){var r;super(),this._options=e,this._themeMgr=t,this._ctx=n,this._id=e.key||Et(),function(e){const t=e=>`settings:${e}`;e.on(t("schema"),(({schema:t,isSync:n})=>{e.settingsSchema=t,e.settings?.setSchema(t,n)})),e.on(t("update"),(t=>{t&&e.settings?.set(t)})),e.on(t("visible:changed"),(t=>{const n=t?.visible;Lt("set_focused_settings",n?e.id:null)}))}(this),function(e){const t=e=>`main-ui:${e}`;e.on(t("visible"),(({visible:t,toggle:n,cursor:r,autoFocus:o})=>{const i=e.getMainUIContainer();i?.classList[n?"toggle":t?"add":"remove"]("visible"),t?!e.shadow&&i&&!1!==o&&i.querySelector("iframe")?.contentWindow?.focus():i.ownerDocument.activeElement.blur(),r&&Lt("restore_editing_cursor")})),e.on(t("attrs"),(t=>{const n=e.getMainUIContainer();Object.entries(t).forEach((([t,r])=>{n?.setAttribute(t,r),"draggable"===t&&r&&e._dispose(e._setupDraggableContainer(n,{title:e.options.name,close:()=>{e.caller.call("sys:ui:visible",{toggle:!0})}})),"resizable"===t&&r&&e._dispose(e._setupResizableContainer(n))}))})),e.on(t("style"),(t=>{const n=e.getMainUIContainer(),r=!!n.dataset.inited_layout;Object.entries(t).forEach((([e,t])=>{r&&["left","top","bottom","right","width","height"].includes(e)||(n.style[e]=t)}))}))}(this),function(e){const t=e=>`provider:${e}`;let n=!1;e.on(t("theme"),(t=>{e.themeMgr.registerTheme(e.id,t),n||(e._dispose((()=>{e.themeMgr.unregisterTheme(e.id)})),n=!0)})),e.on(t("style"),(t=>{let n;"string"!=typeof t&&(n=t.key,t=t.style),t&&t.trim()&&e._dispose(Pt(t,{"data-injected-style":n?`${n}-${e.id}`:"","data-ref":e.id}))})),e.on(t("ui"),(t=>{e._onHostMounted((()=>{e._dispose(Rt.call(e,t,Object.assign({"data-ref":e.id},t.attrs||{}),(({el:t,float:n})=>{if(!n)return;const r=t.dataset.identity;e.layoutCore.move_container_to_top(r)})))}))}))}(this),(r=this).on("api:call",(async e=>{let t;try{t=await Lt.apply(r,[e.method,...e.args])}catch(e){t={[Nr]:e}}const{_sync:n}=e;if(r.shadow)e.actor&&e.actor.resolve(t);else if(null!=n){const e=e=>{r.caller?.callUserModel(Dr,{result:e,_sync:n})};Promise.resolve(t).then(e,e)}}))}async _setupUserSettings(e){const{_options:t}=this,n=this._logger=new St("Loader");if(!t.settings||e)try{const n=()=>Lt("load_plugin_user_settings",this.id),[r,o]=await n();this._dotSettingsFile=r;let i=t.settings;if(i||(i=t.settings=new Wr(o)),e)return void(i.settings=o);const s=async(e,t)=>{if(qr("Settings changed",this.debugTag,e),!e.disabled&&t.disabled){const[,t]=await n();t.disabled=!1,e=Object.assign(e,t),i.settings=e,await this.load()}if(e.disabled&&!t.disabled){const[,t]=await n();t.disabled=!0,e=Object.assign(e,t),await this.unload()}e&&Lt("save_plugin_user_settings",this.id,e)};return i.on("change",s),()=>{}}catch(e){qr("[load plugin user settings Error]",e),n?.error(e)}}getMainUIContainer(){return this.shadow?this.caller?._getSandboxShadowContainer():this.caller?._getSandboxIframeContainer()}_resolveResourceFullUrl(e,t){if(!e?.trim())return;t=t||this._localRoot;const n=/^(http|file)/;if(!n.test(e)){const r=ft.join(t,e);e=n.test(r)?r:gt+r}return!this.options.effect&&this.isInstalledInDotRoot?Jr(e,this.dotPluginsRoot):e}async _preparePackageConfigs(){const{url:e}=this._options;let t;try{if(!e)throw new Error("Can not resolve package config location");if(qr("prepare package root",e),t=await Lt("load_plugin_config",e),!t||(t=JSON.parse(t),!t))throw new Error(`Parse package config error #${e}/package.json`)}catch(e){throw new Vr(e.message)}const n=this._localRoot=Tt(e),r=t.logseq||{};["name","author","repository","version","description","repo","title","effect","sponsors"].concat(this.isInstalledInDotRoot?[]:["devEntry"]).forEach((e=>{this._options[e]=t[e]}));const o=r.entry||r.main||t.main;var i;(i=o)&&/\.(js|html)$/.test(i)&&(this._options.entry=this._resolveResourceFullUrl(o,n),this._options.devEntry=r.devEntry,r.mode&&(this._options.mode=r.mode));const s=r.title||t.title,a=r.icon||t.icon;if(this._options.title=s,this._options.icon=a&&this._resolveResourceFullUrl(a),this._options.theme=Boolean(r.theme||!!r.themes),this.isInstalledInDotRoot)this._id=ft.basename(n);else if(r.id)this._id=r.id;else{r.id=this.id;try{await Lt("save_plugin_config",e,{...t,logseq:r})}catch(e){qr("[save plugin ID Error] ",e)}}const{registeredPlugins:c,isRegistering:l}=this._ctx;if(l&&c.has(this.id))throw new Zr("Registered plugin package Error");return async()=>{try{const e=r.themes;e&&await this._loadConfigThemes(Array.isArray(e)?e:[e])}catch(e){qr("[prepare package effect Error]",e)}}}async _tryToNormalizeEntry(){let{entry:e,settings:t,devEntry:n}=this.options;if(n=n||t?.get("_devEntry"),n)return void(this._options.entry=n);if(!e.endsWith(".js"))return;let r=null,o="write_user_tmp_file";this.isInstalledInDotRoot&&(o="write_dotdir_file",r=this._localRoot.replace(this.dotPluginsRoot,""),r=ft.join(Br,r));const i=(new Date).getDay(),s=await wt(),a=await Lt(o,`${this._id}_index.html`,`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="UTF-8">\n <title>logseq plugin entry</title>\n ${pt?`<script src="${s}/lsplugin.user.js?v=${i}"><\/script>`:`<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${i}"><\/script>`}\n \n </head>\n <body>\n <div id="app"></div>\n <script src="${e}"><\/script>\n </body>\n</html>`,r);e=Jr(kt(ft.normalize(a)),this.dotPluginsRoot),this._options.entry=e}async _loadConfigThemes(e){e.forEach((e=>{e.url&&(!e.url.startsWith("http")&&this._localRoot&&(e.url=ft.join(this._localRoot,e.url),e.url.startsWith("file:")||(e.url="assets://"+e.url)),this.emit("provider:theme",e))}))}async _loadLayoutsData(){const e=this.id+"_layouts",[,t]=await Lt("load_plugin_user_settings",e);return t||{}}async _saveLayoutsData(e){const t=this.id+"_layouts";await Lt("save_plugin_user_settings",t,e)}async _persistMainUILayoutData(e){const t=await this._loadLayoutsData();t.$$0=e,await this._saveLayoutsData(t)}_setupDraggableContainer(e,t={}){const n=e.dataset;if(n.inited_draggable)return;n.identity||(n.identity="dd-"+Et());const r=!!t.key,o=document.createElement("div");o.classList.add("draggable-handle"),o.innerHTML=`\n <div class="th">\n <div class="l"><h3>${t.title||""}</h3></div>\n <div class="r">\n <a class="button x"><i class="ti ti-x"></i></a>\n </div>\n </div>\n `,o.querySelector(".x").addEventListener("click",(e=>{t?.close?.(),e.stopPropagation()}),!1),o.addEventListener("mousedown",(e=>{e.target?.closest(".r")&&(e.stopPropagation(),e.preventDefault())}),!1),e.prepend(o),e.addEventListener("mousedown",(e=>{this.layoutCore.move_container_to_top(n.identity)}),!0);const i=this.layoutCore.setup_draggable_container_BANG_(e,r?()=>{}:this._persistMainUILayoutData.bind(this));var s;n.inited_draggable="true",t.title&&(s=t.title,o.querySelector("h3").textContent=s);let a=null;if("outside"===n.close){const n=n=>{const r=n.target;e.contains(r)||t.close()};document.addEventListener("click",n,!1),a=()=>{document.removeEventListener("click",n)}}return()=>{i(),a?.()}}_setupResizableContainer(e,t){const n=e.dataset;if(n.inited_resizable)return;n.identity||(n.identity="dd-"+Et());const r=document.createElement("div");r.classList.add("resizable-handle"),e.prepend(r);const o=window.frontend.modules.layout.core.setup_resizable_container_BANG_(e,t?()=>{}:this._persistMainUILayoutData.bind(this));return n.inited_resizable="true",o}async load(e){if(!this.pending){this._status=Gr.LOADING,this._loadErr=void 0;try{const t=await this._preparePackageConfigs();if(this._dispose(await this._setupUserSettings(e?.reload)),this.disabled||await t.call(null),this.disabled||!this.options.entry)return;await this._tryToNormalizeEntry(),this._caller=new Hr(this),await this._caller.connectToChild();const n=()=>{this._caller?.callUserModel(Ur,{pid:this.id})};e?.indicator?e.indicator.promise.then(n):n(),this._dispose((async()=>{await(this._caller?.destroy())})),this._dispose(Dt.bind(this))}catch(e){this.logger?.error("[Load Plugin]",e,!0),this.dispose().catch(null),this._status=Gr.ERROR,this._loadErr=e}finally{this._loadErr||(this.disabled?this._status=Gr.UNLOADED:this._status=Gr.LOADED)}}}async reload(){this.pending||(this._ctx.emit("beforereload",this),await this.unload(),await this.load({reload:!0}),this._ctx.emit("reloaded",this))}async unload(e=!1){if(!this.pending){if(e)return await this.unload(),void(this.isInstalledInDotRoot&&this._ctx.emit("unlink-plugin",this.id));try{const t={unregister:e};if(this.loaded){this._status=Gr.UNLOADING;try{await(this._caller?.callUserModel(zr(Fr),t)),this.emit("beforeunload",t)}catch(e){this.logger.error("[beforeunload Error]",e)}await this.dispose()}this.emit("unloaded")}catch(e){this.logger.error("[unload Error]",e)}finally{this._status=Gr.UNLOADED}}}async dispose(){for(const e of this._disposes)try{e&&await e()}catch(e){console.error(this.debugTag,"dispose Error",e)}this._disposes=[]}_dispose(e){e&&this._disposes.push(e)}_onHostMounted(e){const t=this._ctx.hostMountedActor;!t||t.settled?e():t?.promise.then(e)}get layoutCore(){return window.frontend.modules.layout.core}get isInstalledInDotRoot(){const e=this.dotConfigRoot,t=this.localRoot;return e&&t&&t.startsWith(e)}get loaded(){return this._status===Gr.LOADED}get pending(){return[Gr.LOADING,Gr.UNLOADING].includes(this._status)}get status(){return this._status}get settings(){return this.options.settings}set settingsSchema(e){this._options.settingsSchema=e}get settingsSchema(){return this.options.settingsSchema}get logger(){return this._logger}get disabled(){return this.settings?.get("disabled")}get theme(){return this.options.theme}get caller(){return this._caller}get id(){return this._id}get shadow(){return"shadow"===this.options.mode}get options(){return this._options}get themeMgr(){return this._themeMgr}get debugTag(){const e=this._options?.name;return`#${this._id} ${e??""}`}get localRoot(){return this._localRoot||this._options.url}get loadErr(){return this._loadErr}get dotConfigRoot(){return ft.normalize(this._ctx.options.dotConfigRoot)}get dotSettingsFile(){return this._dotSettingsFile}get dotPluginsRoot(){return ft.join(this.dotConfigRoot,Br)}get sdk(){return this._sdk}set sdk(e){this._sdk=e}toJSON(){const e={...this.options};return e.id=this.id,e.err=this.loadErr,e.usf=this.dotSettingsFile,e.iir=this.isInstalledInDotRoot,e.lsr=this._resolveResourceFullUrl("/"),e.settings=e.settings?.toJSON(),e}}class Yr extends(i()){_options;_isRegistering=!1;_readyIndicator;_hostMountedActor=It();_userPreferences={theme:null,themes:{mode:"light",light:null,dark:null},externals:[]};_registeredThemes=new Map;_registeredPlugins=new Map;_currentTheme;constructor(e){super(),this._options=e}async loadUserPreferences(){try{const e=await Lt("load_user_preferences");e&&Object.assign(this._userPreferences,e)}catch(e){qr("[load user preferences Error]",e)}}async saveUserPreferences(e){try{e&&Object.assign(this._userPreferences,e),await Lt("save_user_preferences",this._userPreferences)}catch(e){qr("[save user preferences Error]",e)}}async activateUserPreferences(){const{theme:e,themes:t}=this._userPreferences,n=t[t.mode];n?await this.selectTheme(n,{effect:!1}):e&&await this.selectTheme(e,{effect:!1})}async register(e,t=!1){if(!Array.isArray(e))return void await this.register([e]);const n=new Map,r=()=>{const e=Array.from(n.values()).reduce(((e,t)=>{const{id:n,options:r,status:o,disabled:i}=t.o;return!0===i||!r.entry&&(r.name||r.entry)||(e[n]={name:r.name,entry:r.entry,status:o,enabled:"boolean"==typeof i?i?"⚫️":"🟢":"🔴",perf:t.e?`${(t.e-t.s).toFixed(2)}ms`:t.o.loadErr}),e}),{});console.table(e)};window.__debugPluginsPerfInfo=r;try{this._isRegistering=!0,this._options.dotConfigRoot;const o=this._readyIndicator=It();await this.loadUserPreferences();let i=new Set(this._userPreferences.externals);if(i?.size)try{const e=await Lt("validate_external_plugins",[...i]);i=new Set([...Object.entries(e)].reduce(((e,[t,n])=>(n&&e.push(t),e)),[]))}catch(e){console.error("[validatedExternals Error]",e)}t&&(e=e.concat([...i].filter((t=>!e.length||e.every((e=>!e.entry&&e.url!==t)))).map((e=>({url:e})))));for(const t of e){const{url:e}=t,r=new Kr(t,this,this),s={o:r,s:performance.now(),e:0};n.set(e,s),await r.load({indicator:o}),s.e=performance.now();const{loadErr:a}=r;a&&(qr("[Failed LOAD Plugin] #",t),this.emit("error",a),a instanceof Vr||a instanceof Zr)||(r.settings?.on("change",(e=>{this.emit("settings-changed",r.id,e),r.caller?.callUserModel(Rr,{payload:e})})),this._registeredPlugins.set(r.id,r),this.emit("registered",r),r.isInstalledInDotRoot||i.add(e))}await this.saveUserPreferences({externals:Array.from(i)}),await this.activateUserPreferences(),o.resolve("ready")}catch(e){console.error(e)}finally{this._isRegistering=!1,this.emit("ready",n),r()}}async reload(e){if(Array.isArray(e))for(const t of e)try{const e=this.ensurePlugin(t);await e.reload()}catch(e){qr(e)}else await this.reload([e])}async unregister(e){if(!Array.isArray(e))return void await this.unregister([e]);const t=[];for(const n of e){const e=this.ensurePlugin(n);e.isInstalledInDotRoot||t.push(e.options.url),await e.unload(!0),this._registeredPlugins.delete(n),this.emit("unregistered",n)}const n=this._userPreferences.externals;n.length&&t.length&&await this.saveUserPreferences({externals:n.filter((e=>!t.includes(e)))})}async enable(e){const t=this.ensurePlugin(e);t.pending||(this.emit("beforeenable"),t.settings?.set("disabled",!1),this.emit("enabled",t.id))}async disable(e){const t=this.ensurePlugin(e);t.pending||(this.emit("beforedisable"),t.settings?.set("disabled",!0),this.emit("disabled",t.id))}async _hook(e,t,n,r){const o=`${e}:${bt(t)}`,i="hook:db:changed"===o,s=o.startsWith("hook:db:block"),a=r=>{qr(`[call hook][#${r.id}]`,e,t),r.caller?.callUserModel(Pr,{ns:e,type:bt(t),payload:n})},c=r&&this._registeredPlugins.get(r);if(c&&!c.disabled&&c.options.entry)a(c);else for(const[e,t]of this._registeredPlugins)if(t.options.entry&&!t.disabled)if(r){if(r===t.id){a(t);break}}else{const e=t.sdk?.version;if(!e){if(i||s)continue;a(t)}e&&Lt("should_exec_plugin_hook",t.id,o)&&a(t)}}async hookApp(e,t,n){return await this._hook("hook:app",e,t,n)}async hookEditor(e,t,n){return await this._hook("hook:editor",e,t,n)}async hookDb(e,t,n){return await this._hook("hook:db",e,t,n)}ensurePlugin(e){if(e instanceof Kr)return e;const t=this._registeredPlugins.get(e);if(!t)throw new Error(`plugin #${e} not existed.`);return t}hostMounted(){this._hostMountedActor.resolve()}_forceCleanInjectedUI(e){if(e)return Ft(e)}get registeredPlugins(){return this._registeredPlugins}get options(){return this._options}get readyIndicator(){return this._readyIndicator}get hostMountedActor(){return this._hostMountedActor}get isRegistering(){return this._isRegistering}get themes(){return this._registeredThemes}get enabledPlugins(){return[...this.registeredPlugins.entries()].reduce(((e,t)=>{let n=t?.[1];return!0!==n?.disabled&&e.set(t?.[0],n),e}),new Map)}async registerTheme(e,t){if(qr("Register theme #",e,t),!e)return;let n=this._registeredThemes.get(e);n||this._registeredThemes.set(e,n=[]),n.push(t),this.emit("themes-changed",this.themes,{id:e,...t})}async selectTheme(e,t={}){const{effect:n,emit:r}=Object.assign({},{effect:!0,emit:!0},t);if(this._currentTheme&&this._currentTheme.eject(),e.url){const t=$t(e.url);this._currentTheme={pid:e.pid,opt:e,eject:t}}else this._currentTheme=null;n&&await this.saveUserPreferences(e.mode?{themes:{...this._userPreferences.themes,mode:e.mode,[e.mode]:e}}:{theme:e}),r&&this.emit("theme-selected",e)}async unregisterTheme(e,t=!0){if(qr("Unregister theme #",e),this._registeredThemes.has(e)&&(this._registeredThemes.delete(e),this.emit("themes-changed",this.themes,{id:e}),t&&this._currentTheme?.pid===e)){this._currentTheme.eject(),this._currentTheme=null;const{theme:t,themes:n}=this._userPreferences;await this.saveUserPreferences({theme:t?.pid===e?null:t,themes:{...n,light:n.light?.pid===e?null:n.light,dark:n.dark?.pid===e?null:n.dark}}),this.emit("reset-custom-theme",this._userPreferences.themes)}}}function Qr(e){const t=new Yr(e);qr("=== 🔗 Setup Logseq Plugin System 🔗 ==="),window.LSPluginCore=t}})(),r})()));