logseq/e2e-tests/plugin/lsplugin.user.js

2 lines
88 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.user.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.LSPluginEntry=t():e.LSPluginEntry=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){}!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"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){if(e instanceof Error)return e.stack||e.message;return 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}},996:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)};var n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map((function(e){return r(e,n)}))}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function s(e,t){try{return t in e}catch(e){return!1}}function a(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach((function(t){o[t]=r(e[t],n)})),i(t).forEach((function(i){(function(e,t){return s(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(s(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(i,n)(e[i],t[i],n):o[i]=r(t[i],n))})),o}function c(e,n,i){(i=i||{}).arrayMerge=i.arrayMerge||o,i.isMergeableObject=i.isMergeableObject||t,i.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(n);return s===Array.isArray(e)?s?i.arrayMerge(e,n,i):a(e,n,i):r(n,i)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return c(e,n,t)}),{})};var l=c;e.exports=l},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 i(e)||s(e)||a(e)||l()}function i(e){if(Array.isArray(e))return c(e)}function s(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function a(e,t){if(e){if("string"==typeof e)return c(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)?c(e,t):void 0}}function c(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}function l(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=Object.hasOwnProperty,f=Object.setPrototypeOf,p=Object.isFrozen,h=Object.getPrototypeOf,d=Object.getOwnPropertyDescriptor,m=Object.freeze,g=Object.seal,y=Object.create,v="undefined"!=typeof Reflect&&Reflect,b=v.apply,_=v.construct;b||(b=function(e,t,n){return e.apply(t,n)}),m||(m=function(e){return e}),g||(g=function(e){return e}),_||(_=function(e,t){return r(e,o(t))});var w=I(Array.prototype.forEach),x=I(Array.prototype.pop),C=I(Array.prototype.push),S=I(String.prototype.toLowerCase),O=I(String.prototype.match),j=I(String.prototype.replace),A=I(String.prototype.indexOf),E=I(String.prototype.trim),k=I(RegExp.prototype.test),T=M(TypeError);function I(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 b(e,t,r)}}function M(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return _(e,n)}}function F(e,t){f&&f(e,null);for(var n=t.length;n--;){var r=t[n];if("string"==typeof r){var o=S(r);o!==r&&(p(t)||(t[n]=o),r=o)}e[r]=!0}return e}function L(e){var t,n=y(null);for(t in e)b(u,e,[t])&&(n[t]=e[t]);return n}function N(e,t){for(;null!==e;){var n=d(e,t);if(n){if(n.get)return I(n.get);if("function"==typeof n.value)return I(n.value)}e=h(e)}function r(e){return console.warn("fallback value for",e),null}return r}var P=m(["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"]),R=m(["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"]),D=m(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),U=m(["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"]),$=m(["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"]),z=m(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),H=m(["#text"]),B=m(["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"]),q=m(["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"]),W=m(["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"]),G=m(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),J=g(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Z=g(/<%[\w\W]*|[\w\W]*%>/gm),V=g(/^data-[\-\w.\u00B7-\uFFFF]/),K=g(/^aria-[\-\w]+$/),Y=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q=g(/^(?:\w+script|data):/i),X=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ee=g(/^html$/i),te=function(){return"undefined"==typeof window?null:window},ne=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}};function re(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:te(),n=function(e){return re(e)};if(n.version="2.3.8",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,i=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,c=t.Node,l=t.Element,u=t.NodeFilter,f=t.NamedNodeMap,p=void 0===f?t.NamedNodeMap||t.MozNamedAttrMap:f,h=t.HTMLFormElement,d=t.DOMParser,g=t.trustedTypes,y=l.prototype,v=N(y,"cloneNode"),b=N(y,"nextSibling"),_=N(y,"childNodes"),I=N(y,"parentNode");if("function"==typeof a){var M=i.createElement("template");M.content&&M.content.ownerDocument&&(i=M.content.ownerDocument)}var oe=ne(g,r),ie=oe?oe.createHTML(""):"",se=i,ae=se.implementation,ce=se.createNodeIterator,le=se.createDocumentFragment,ue=se.getElementsByTagName,fe=r.importNode,pe={};try{pe=L(i).documentMode?i.documentMode:{}}catch(e){}var he={};n.isSupported="function"==typeof I&&ae&&void 0!==ae.createHTMLDocument&&9!==pe;var de,me,ge=J,ye=Z,ve=V,be=K,_e=Q,we=X,xe=Y,Ce=null,Se=F({},[].concat(o(P),o(R),o(D),o($),o(H))),Oe=null,je=F({},[].concat(o(B),o(q),o(W),o(G))),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}})),Ee=null,ke=null,Te=!0,Ie=!0,Me=!1,Fe=!1,Le=!1,Ne=!1,Pe=!1,Re=!1,De=!1,Ue=!1,$e=!0,ze=!0,He=!1,Be={},qe=null,We=F({},["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=F({},["audio","video","img","source","image","track"]),Ze=null,Ve=F({},["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=i.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},st=function(t){rt&&rt===t||(t&&"object"===e(t)||(t={}),t=L(t),Ce="ALLOWED_TAGS"in t?F({},t.ALLOWED_TAGS):Se,Oe="ALLOWED_ATTR"in t?F({},t.ALLOWED_ATTR):je,Ze="ADD_URI_SAFE_ATTR"in t?F(L(Ve),t.ADD_URI_SAFE_ATTR):Ve,Ge="ADD_DATA_URI_TAGS"in t?F(L(Je),t.ADD_DATA_URI_TAGS):Je,qe="FORBID_CONTENTS"in t?F({},t.FORBID_CONTENTS):We,Ee="FORBID_TAGS"in t?F({},t.FORBID_TAGS):{},ke="FORBID_ATTR"in t?F({},t.FORBID_ATTR):{},Be="USE_PROFILES"in t&&t.USE_PROFILES,Te=!1!==t.ALLOW_ARIA_ATTR,Ie=!1!==t.ALLOW_DATA_ATTR,Me=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Fe=t.SAFE_FOR_TEMPLATES||!1,Le=t.WHOLE_DOCUMENT||!1,Re=t.RETURN_DOM||!1,De=t.RETURN_DOM_FRAGMENT||!1,Ue=t.RETURN_TRUSTED_TYPE||!1,Pe=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),de=de=-1===tt.indexOf(t.PARSER_MEDIA_TYPE)?nt:t.PARSER_MEDIA_TYPE,me="application/xhtml+xml"===de?function(e){return e}:S,Fe&&(Ie=!1),De&&(Re=!0),Be&&(Ce=F({},o(H)),Oe=[],!0===Be.html&&(F(Ce,P),F(Oe,B)),!0===Be.svg&&(F(Ce,R),F(Oe,q),F(Oe,G)),!0===Be.svgFilters&&(F(Ce,D),F(Oe,q),F(Oe,G)),!0===Be.mathMl&&(F(Ce,$),F(Oe,W),F(Oe,G))),t.ADD_TAGS&&(Ce===Se&&(Ce=L(Ce)),F(Ce,t.ADD_TAGS)),t.ADD_ATTR&&(Oe===je&&(Oe=L(Oe)),F(Oe,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&F(Ze,t.ADD_URI_SAFE_ATTR),t.FORBID_CONTENTS&&(qe===We&&(qe=L(qe)),F(qe,t.FORBID_CONTENTS)),ze&&(Ce["#text"]=!0),Le&&F(Ce,["html","head","body"]),Ce.table&&(F(Ce,["tbody"]),delete Ee.tbody),m&&m(t),rt=t)},at=F({},["mi","mo","mn","ms","mtext"]),ct=F({},["foreignobject","desc","title","annotation-xml"]),lt=F({},["title","style","font","a","script"]),ut=F({},R);F(ut,D),F(ut,U);var ft=F({},$);F(ft,z);var pt=function(e){var t=I(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});var n=S(e.tagName),r=S(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(ft[n]):e.namespaceURI===Qe&&!(t.namespaceURI===Ye&&!ct[r])&&!(t.namespaceURI===Ke&&!at[r])&&!ft[n]&&(lt[n]||!ut[n])},ht=function(e){C(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},dt=function(e,t){try{C(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){C(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Oe[e])if(Re||De)try{ht(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},mt=function(e){var t,n;if(Pe)e="<remove></remove>"+e;else{var r=O(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===de&&(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 d).parseFromString(o,de)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Xe,"template",null);try{t.documentElement.innerHTML=et?"":o}catch(e){}}var s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),Xe===Qe?ue.call(t,Le?"html":"body")[0]:Le?t.documentElement:s},gt=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},yt=function(e){return e instanceof h&&("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)},vt=function(t){return"object"===e(c)?t instanceof c:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},bt=function(e,t,r){he[e]&&w(he[e],(function(e){e.call(n,t,r,rt)}))},_t=function(e){var t;if(bt("beforeSanitizeElements",e,null),yt(e))return ht(e),!0;if(k(/[\u0080-\uFFFF]/,e.nodeName))return ht(e),!0;var r=me(e.nodeName);if(bt("uponSanitizeElement",e,{tagName:r,allowedTags:Ce}),e.hasChildNodes()&&!vt(e.firstElementChild)&&(!vt(e.content)||!vt(e.content.firstElementChild))&&k(/<[/\w]/g,e.innerHTML)&&k(/<[/\w]/g,e.textContent))return ht(e),!0;if("select"===r&&k(/<template/i,e.innerHTML))return ht(e),!0;if(!Ce[r]||Ee[r]){if(!Ee[r]&&xt(r)){if(Ae.tagNameCheck instanceof RegExp&&k(Ae.tagNameCheck,r))return!1;if(Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(r))return!1}if(ze&&!qe[r]){var o=I(e)||e.parentNode,i=_(e)||e.childNodes;if(i&&o)for(var s=i.length-1;s>=0;--s)o.insertBefore(v(i[s],!0),b(e))}return ht(e),!0}return e instanceof l&&!pt(e)?(ht(e),!0):"noscript"!==r&&"noembed"!==r||!k(/<\/no(script|embed)/i,e.innerHTML)?(Fe&&3===e.nodeType&&(t=e.textContent,t=j(t,ge," "),t=j(t,ye," "),e.textContent!==t&&(C(n.removed,{element:e.cloneNode()}),e.textContent=t)),bt("afterSanitizeElements",e,null),!1):(ht(e),!0)},wt=function(e,t,n){if($e&&("id"===t||"name"===t)&&(n in i||n in ot))return!1;if(Ie&&!ke[t]&&k(ve,t));else if(Te&&k(be,t));else if(!Oe[t]||ke[t]){if(!(xt(e)&&(Ae.tagNameCheck instanceof RegExp&&k(Ae.tagNameCheck,e)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(e))&&(Ae.attributeNameCheck instanceof RegExp&&k(Ae.attributeNameCheck,t)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(t))||"is"===t&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&k(Ae.tagNameCheck,n)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))))return!1}else if(Ze[t]);else if(k(xe,j(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==A(n,"data:")||!Ge[e])if(Me&&!k(_e,j(n,we,"")));else if(n)return!1;return!0},xt=function(e){return e.indexOf("-")>0},Ct=function(e){var t,r,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(r="value"===l?t.value:E(t.value),o=me(l),a.attrName=o,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,bt("uponSanitizeAttribute",e,a),r=a.attrValue,!a.forceKeepAttr&&(dt(l,e),a.keepAttr))if(k(/\/>/i,r))dt(l,e);else{Fe&&(r=j(r,ge," "),r=j(r,ye," "));var f=me(e.nodeName);if(wt(f,o,r))try{u?e.setAttributeNS(u,l,r):e.setAttribute(l,r),x(n.removed)}catch(e){}}}bt("afterSanitizeAttributes",e,null)}},St=function e(t){var n,r=gt(t);for(bt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)bt("uponSanitizeShadowNode",n,null),_t(n)||(n.content instanceof s&&e(n.content),Ct(n));bt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(o,i){var a,l,u,f,p;if((et=!o)&&(o="\x3c!--\x3e"),"string"!=typeof o&&!vt(o)){if("function"!=typeof o.toString)throw T("toString is not a function");if("string"!=typeof(o=o.toString()))throw T("dirty is not a string, aborting")}if(!n.isSupported){if("object"===e(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof o)return t.toStaticHTML(o);if(vt(o))return t.toStaticHTML(o.outerHTML)}return o}if(Ne||st(i),n.removed=[],"string"==typeof o&&(He=!1),He){if(o.nodeName){var h=me(o.nodeName);if(!Ce[h]||Ee[h])throw T("root node is forbidden and cannot be sanitized in-place")}}else if(o instanceof c)1===(l=(a=mt("\x3c!----\x3e")).ownerDocument.importNode(o,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!Re&&!Fe&&!Le&&-1===o.indexOf("<"))return oe&&Ue?oe.createHTML(o):o;if(!(a=mt(o)))return Re?null:Ue?ie:""}a&&Pe&&ht(a.firstChild);for(var d=gt(He?o:a);u=d.nextNode();)3===u.nodeType&&u===f||_t(u)||(u.content instanceof s&&St(u.content),Ct(u),f=u);if(f=null,He)return o;if(Re){if(De)for(p=le.call(a.ownerDocument);a.firstChild;)p.appendChild(a.firstChild);else p=a;return Oe.shadowroot&&(p=fe.call(r,p,!0)),p}var m=Le?a.outerHTML:a.innerHTML;return Le&&Ce["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&k(ee,a.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+m),Fe&&(m=j(m,ge," "),m=j(m,ye," ")),oe&&Ue?oe.createHTML(m):m},n.setConfig=function(e){st(e),Ne=!0},n.clearConfig=function(){rt=null,Ne=!1},n.isValidAttribute=function(e,t,n){rt||st({});var r=me(e),o=me(t);return wt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(he[e]=he[e]||[],C(he[e],t))},n.removeHook=function(e){if(he[e])return x(he[e])},n.removeHooks=function(e){he[e]&&(he[e]=[])},n.removeAllHooks=function(){he={}},n}return re()}()},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],f=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),f){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(f-1);l<f;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var p,h=u.length;for(l=0;l<h;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),f){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(p=1,c=new Array(f-1);p<f;p++)c[p-1]=arguments[p];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,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\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(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return 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 f(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 p(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 h(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=p(a),l=c.device,u=c.isUnc,f=c.isAbsolute,d=c.tail;if((!l||!e||l.toLowerCase()===e.toLowerCase())&&(e||(e=l),n||(t=d+"\\"+t,n=f),e&&n))break}}return u&&(e=h(e)),e+(n?"\\":"")+(t=s(t.split(/[\\\/]+/),!n).join("\\"))||"."},u.normalize=function(e){var t=p(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=h(n)),n+(o?"\\":"")+i},u.isAbsolute=function(e){return p(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,f=0;f<c;f++)if(i[f]!==s[f]){l=f;break}if(0==l)return t;var p=[];for(f=l;f<i.length;f++)p.push("..");return(p=p.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=f(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=f(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},u.extname=function(e){return f(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=f(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 d=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,m={};function g(e){return d.exec(e).slice(1)}m.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("/"))||"."},m.normalize=function(e){var t=m.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=s(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},m.isAbsolute=function(e){return"/"===e.charAt(0)},m.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 m.normalize(e)},m.relative=function(e,t){e=m.resolve(e).substr(1),t=m.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("/")},m._makeLong=function(e){return e},m.dirname=function(e){var t=g(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},m.basename=function(e,t){var n=g(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},m.extname=function(e){return g(e)[3]},m.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+m.sep:"")+(e.base||"")},m.parse=function(e){if(!i.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=g(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)}},m.sep="/",m.delimiter=":",e.exports=o?u:m,e.exports.posix=m,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 f(){l&&a&&(l=!1,a.length?c=a.concat(c):u=-1,c.length&&p())}function p(){if(!l){var e=s(f);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 h(e,t){this.fun=e,this.array=t}function d(){}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 h(e,t)),1!==c.length||l||s(p)},h.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=d,r.addListener=d,r.once=d,r.off=d,r.removeListener=d,r.removeAllListeners=d,r.emit=d,r.prependListener=d,r.prependOnceListener=d,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])m(c)||!_(c)?s+=" "+c:s+=" "+a(c);return s},t.deprecate=function(e,o){if(v(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]),d(n)?r.showHidden=n:n&&t._extend(r,n),v(r.showHidden)&&(r.showHidden=!1),v(r.depth)&&(r.depth=2),v(r.colors)&&(r.colors=!1),v(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(v(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")}if(g(t))return e.stylize(""+t,"number");if(d(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(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 f(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 f(n)}var l,_="",S=!1,O=["{","}"];(h(n)&&(S=!0,O=["[","]"]),C(n))&&(_=" [Function"+(n.name?": "+n.name:"")+"]");return b(n)&&(_=" "+RegExp.prototype.toString.call(n)),w(n)&&(_=" "+Date.prototype.toUTCString.call(n)),x(n)&&(_=" "+f(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)E(t,String(s))?i.push(p(e,t,n,r,String(s),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(p(e,t,n,r,o,!0))})),i}(e,n,r,a,s):s.map((function(t){return p(e,n,r,a,t,S)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(l,_,O)):O[0]+_+O[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function p(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")),E(r,o)||(s="["+o+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(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")),v(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 h(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function y(e){return"string"==typeof e}function v(e){return void 0===e}function b(e){return _(e)&&"[object RegExp]"===S(e)}function _(e){return"object"==typeof e&&null!==e}function w(e){return _(e)&&"[object Date]"===S(e)}function x(e){return _(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(v(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=h,t.isBoolean=d,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=b,t.isObject=_,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 j=["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(),j[e.getMonth()],t].join(" ")}function E(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||!_(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,{LSPluginUser:()=>Nr,setupPluginUserInstance:()=>Pr});var e=n(520),t=(n(856),n(996)),o=n.n(t);var i=function(){return i=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},i.apply(this,arguments)};Object.create;Object.create;function s(e){return e.toLowerCase()}var a=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],c=/[^A-Z0-9]+/gi;function l(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function u(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,r=void 0===n?a:n,o=t.stripRegexp,i=void 0===o?c:o,u=t.transform,f=void 0===u?s:u,p=t.delimiter,h=void 0===p?" ":p,d=l(l(e,r,"$1\0$2"),i,"\0"),m=0,g=d.length;"\0"===d.charAt(m);)m++;for(;"\0"===d.charAt(g-1);)g--;return d.slice(m,g).split("\0").map(f).join(h)}(e,i({delimiter:"."},t))}var f=n(729),p=n.n(f);function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const d="win32"===navigator.platform.toLowerCase()?e.win32:e.posix;const m=function(e,t){return void 0===t&&(t={}),u(e,i({delimiter:"_"},t))};class g extends(p()){constructor(e,t){super(),h(this,"_tag",void 0),h(this,"_opts",void 0),h(this,"_logs",[]),this._tag=e,this._opts=t}write(e,t,n){var r;null!=t&&t.length&&!0===t[t.length-1]&&(n=!0,t.pop());const o=t.reduce(((e,t)=>(t&&t instanceof Error?e+=`${t.message} ${t.stack}`:e+=t.toString(),e)),`[${this._tag}][${(new Date).toLocaleTimeString()}] `);var i;(this._logs.push([e,o]),n||null!==(r=this._opts)&&void 0!==r&&r.console)&&(null===(i=console)||void 0===i||i["ERROR"===e?"error":"debug"](`${e}: ${o}`));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 y(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=d.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return d.join(e,...t)}}function v(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}}}const b=new Map;window.__injectedUIEffects=b;var _=n(227),w=n.n(_);function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const C="application/x-postmate-v1+json";let S=0;const O={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},j=(e,t)=>("string"!=typeof t||e.origin===t)&&(!!e.data&&(("object"!=typeof e.data||"postmate"in e.data)&&(e.data.type===C&&!!O[e.data.postmate])));class A{constructor(e){x(this,"parent",void 0),x(this,"frame",void 0),x(this,"child",void 0),x(this,"events",{}),x(this,"childOrigin",void 0),x(this,"listener",void 0),this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.listener=e=>{if(!j(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,r)=>{const o=++S,i=e=>{e.data.uid===o&&"reply"===e.data.postmate&&(this.parent.removeEventListener("message",i,!1),e.data.error?r(e.data.error):n(e.data.value))};this.parent.addEventListener("message",i,!1),this.child.postMessage({postmate:"request",type:C,property:e,args:t,uid:o},this.childOrigin)}))}call(e,t){this.child.postMessage({postmate:"call",type:C,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 E{constructor(e){x(this,"model",void 0),x(this,"parent",void 0),x(this,"parentOrigin",void 0),x(this,"child",void 0),this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(e=>{if(!j(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:C,uid:n,value:r},e.origin)})).catch((r=>{e.source.postMessage({property:t,postmate:"reply",type:C,uid:n,error: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:C,value:{name:e,data:t}},this.parentOrigin)}}class k{constructor(e){x(this,"container",void 0),x(this,"parent",void 0),x(this,"frame",void 0),x(this,"child",void 0),x(this,"childOrigin",void 0),x(this,"url",void 0),x(this,"model",void 0),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=>!!j(e,t)&&("handshake-reply"===e.data.postmate?(clearInterval(n),this.parent.removeEventListener("message",s,!1),this.childOrigin=e.origin,o(new A(this))):i("Failed handshake"));this.parent.addEventListener("message",s,!1);const a=()=>{r++,this.child.postMessage({postmate:"handshake",type:C,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)}}x(k,"debug",!1),x(k,"Model",void 0);class T{constructor(e){x(this,"child",void 0),x(this,"model",void 0),x(this,"parent",void 0),x(this,"parentOrigin",void 0),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){0,this.child.removeEventListener("message",n,!1),r.source.postMessage({postmate:"handshake-reply",type:C},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 E(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)}))}}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const{importHTML:M,createSandboxContainer:F}=window.QSandbox||{};function L(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 N extends(p()){constructor(e){super(),I(this,"_pluginLocal",void 0),I(this,"_frame",void 0),I(this,"_root",void 0),I(this,"_loaded",!1),I(this,"_unmountFns",[]),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 M(t,{fetch:L});this._mount(n,document.body);const o=F(e,{elementGetter:()=>{var e;return null===(e=this._root)||void 0===e?void 0:e.firstChild}}).instance.proxy;o.__shadow_mode__=!0,o.LSPluginLocal=this._pluginLocal,o.LSPluginShadow=this,o.LSPluginUser=o.logseq=new Nr(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(){var e,t;null===(e=this.frame)||void 0===e||null===(t=e.parentNode)||void 0===t||t.removeChild(this.frame)}get loaded(){return this._loaded}get document(){var e;return null===(e=this._root)||void 0===e?void 0:e.firstChild}get frame(){return this._frame}}function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const R=w()("LSPlugin:caller"),D="#await#response#",U="#lspmsg#",$="#lspmsg#error#",z=e=>`#lspmsg#${e}`;class H extends(p()){constructor(e){super(),P(this,"_pluginLocal",void 0),P(this,"_connected",!1),P(this,"_parent",void 0),P(this,"_child",void 0),P(this,"_shadow",void 0),P(this,"_status",void 0),P(this,"_userModel",{}),P(this,"_call",void 0),P(this,"_callUserModel",void 0),P(this,"_debugTag",""),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=v(6e4),a=this._extendUserModel({"#lspmsg#ready#":async e=>{a[z(null==e?void 0:e.pid)]=({type:e,payload:n})=>{R(`[host (_call) -> *user] ${this._debugTag}`,e,n),t.emit(e,n)},await s.resolve()},"#lspmsg#beforeunload#":async e=>{const n=v(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},"#lspmsg#settings#":async({type:e,payload:n})=>{t.emit("settings:changed",n)},[U]:async({ns:e,type:n,payload:r})=>{R(`[host (async) -> *user] ${this._debugTag} ns=${e} type=${n}`,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},"#lspmsg#reply#":({_sync:e,result:t})=>{if(R(`[sync host -> *user] #${e}`,t),i.has(e)){const n=i.get(e);n&&(null!=t&&t.hasOwnProperty($)?n.reject(t[$]):n.resolve(t),i.delete(e))}},...e});var c;if(n)return await s.promise,JSON.parse(JSON.stringify(null===(c=this._pluginLocal)||void 0===c?void 0:c.toJSON()));const l=new T(a).sendHandshakeReply();return this._status="pending",await l.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}`),R(`async call #${e}`)}return e.emit(z(a.baseInfo.id),{type:t,payload:n}),null==r?void 0:r.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){R(`[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={}){var n;return null===(n=this._call)||void 0===n?void 0:n.call(this,e,t)}async callAsync(e,t={}){var n;const r=v(1e4);return null===(n=this._call)||void 0===n?void 0:n.call(this,e,t,r)}async callUserModel(e,...t){var n;return null===(n=this._callUserModel)||void 0===n?void 0:n.apply(this,[e,...t])}async callUserModelAsync(e,...t){var n;return e=`${D}${e}`,null===(n=this._callUserModel)||void 0===n?void 0:n.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__",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{var s;const e=null===(s=await this._pluginLocal._loadLayoutsData())||void 0===s?void 0:s.$$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 a=new k({id:t+"_iframe",container:i,url:r.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let c,l=a.sendHandshake();return this._status="pending",new Promise(((t,n)=>{c=setTimeout((()=>{n(new Error("handshake Timeout")),a.destroy()}),4e3),l.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on(z(e.id),(({type:e,payload:t})=>{var n,r;R("[user -> *host] ",e,t),null===(n=this._pluginLocal)||void 0===n||n.emit(e,t||{}),null===(r=this._pluginLocal)||void 0===r||r.caller.emit(e,t||{})})),this._call=async(...t)=>{await n.call(z(e.id),{type:t[0],payload:Object.assign(t[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,...t)=>{if(e.startsWith(D))return await n.get(e.replace(D,""),...t);n.call(e,null==t?void 0:t[0])},t(null)})).catch((e=>{n(e)})).finally((()=>{clearTimeout(c)}))})).catch((e=>{throw R("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new N(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(t,n={},r)=>{var o;return r&&(n.actor=r),null===(o=this._pluginLocal)||void 0===o||o.emit(t,Object.assign(n,{$$pid:e.id})),null==r?void 0:r.promise},this._callUserModel=async(...e)=>{var t;let n=e[0];null!==(t=n)&&void 0!==t&&t.startsWith(D)&&(n=n.replace(D,""));const r=e[1]||{},o=this._userModel[n];"function"==typeof o&&await o.call(null,r)}}catch(e){throw R("[shadow sandbox] error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){var e;return null===(e=this._parent)||void 0===e?void 0:e.frame.parentNode}_getSandboxShadowContainer(){var e;return null===(e=this._shadow)||void 0===e?void 0:e.frame.parentNode}_getSandboxIframeRoot(){var e;return null===(e=this._parent)||void 0===e?void 0:e.frame}_getSandboxShadowRoot(){var e;return null===(e=this._shadow)||void 0===e?void 0:e.frame}set debugTag(e){this._debugTag=e}async destroy(){var e;let t=null;this._parent&&(t=this._getSandboxIframeContainer(),await this._parent.destroy()),this._shadow&&(t=this._getSandboxShadowContainer(),this._shadow.destroy()),null===(e=t)||void 0===e||e.parentNode.removeChild(t)}}function B(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class q{constructor(e,t){B(this,"ctx",void 0),B(this,"opts",void 0),this.ctx=e,this.opts=t}get ctxId(){return this.ctx.baseInfo.id}setItem(e,t){var n;return this.ctx.caller.callAsync("api:call",{method:"write-plugin-storage-file",args:[this.ctxId,e,t,null===(n=this.opts)||void 0===n?void 0:n.assets]})}getItem(e){var t;return this.ctx.caller.callAsync("api:call",{method:"read-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}removeItem(e){var t;return this.ctx.caller.call("api:call",{method:"unlink-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}allKeys(){var e;return this.ctx.caller.callAsync("api:call",{method:"list-plugin-storage-files",args:[this.ctxId,null===(e=this.opts)||void 0===e?void 0:e.assets]})}clear(){var e;return this.ctx.caller.call("api:call",{method:"clear-plugin-storage-files",args:[this.ctxId,null===(e=this.opts)||void 0===e?void 0:e.assets]})}hasItem(e){var t;return this.ctx.caller.callAsync("api:call",{method:"exist-plugin-storage-file",args:[this.ctxId,e,null===(t=this.opts)||void 0===t?void 0:t.assets]})}}class W{constructor(e){var t,n,r;r=void 0,(n="ctx")in(t=this)?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,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){var n,r;const o=this.ensureHostScope();return e=null===(n=m(e))||void 0===n?void 0:n.toLowerCase(),null===(r=o.logseq.api["exper_"+e])||void 0===r?void 0:r.apply(o,t)}async loadScripts(...e){(e=e.map((e=>null!=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();if("katex"===e)n.katex&&t(n.katex).catch(console.error);return 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}}function G(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const J=e=>`task_callback_${e}`;class Z{constructor(e,t,n={}){G(this,"_client",void 0),G(this,"_requestId",void 0),G(this,"_requestOptions",void 0),G(this,"_promise",void 0),G(this,"_aborted",!1),this._client=e,this._requestId=t,this._requestOptions=n,this._promise=new Promise(((e,t)=>{if(!this._requestId)return t(null);this._client.once(J(this._requestId),(n=>{n&&n instanceof Error?t(n):e(n)}))}));const{success:r,fail:o,final:i}=this._requestOptions;this._promise.then((e=>{null==r||r(e)})).catch((e=>{null==o||o(e)})).finally((()=>{null==i||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 V extends f.EventEmitter{constructor(e){super(),G(this,"_ctx",void 0),this._ctx=e,this.ctx.caller.on("#lsp#request#callback",(e=>{const t=null==e?void 0:e.requestId;t&&this.emit(J(t),null==e?void 0:e.payload)}))}static createRequestTask(e,t,n){return new Z(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=V.createRequestTask(this.ctx.Request,s,e);return i.abortable?a:a.promise}get ctx(){return this._ctx}}const K=Array.isArray;const Y="object"==typeof global&&global&&global.Object===Object&&global;var Q="object"==typeof self&&self&&self.Object===Object&&self;const X=Y||Q||Function("return this")();const ee=X.Symbol;var te=Object.prototype,ne=te.hasOwnProperty,re=te.toString,oe=ee?ee.toStringTag:void 0;const ie=function(e){var t=ne.call(e,oe),n=e[oe];try{e[oe]=void 0;var r=!0}catch(e){}var o=re.call(e);return r&&(t?e[oe]=n:delete e[oe]),o};var se=Object.prototype.toString;const ae=function(e){return se.call(e)};var ce=ee?ee.toStringTag:void 0;const le=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ce&&ce in Object(e)?ie(e):ae(e)};const ue=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const fe=function(e){if(!ue(e))return!1;var t=le(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const pe=X["__core-js_shared__"];var he,de=(he=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+he:"";const me=function(e){return!!de&&de in e};var ge=Function.prototype.toString;const ye=function(e){if(null!=e){try{return ge.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var ve=/^\[object .+?Constructor\]$/,be=Function.prototype,_e=Object.prototype,we=be.toString,xe=_e.hasOwnProperty,Ce=RegExp("^"+we.call(xe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Se=function(e){return!(!ue(e)||me(e))&&(fe(e)?Ce:ve).test(ye(e))};const Oe=function(e,t){return null==e?void 0:e[t]};const je=function(e,t){var n=Oe(e,t);return Se(n)?n:void 0};const Ae=function(){try{var e=je(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const Ee=function(e,t,n){"__proto__"==t&&Ae?Ae(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n};const ke=function(e){return function(t,n,r){for(var o=-1,i=Object(t),s=r(t),a=s.length;a--;){var c=s[e?a:++o];if(!1===n(i[c],c,i))break}return t}}();const Te=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r};const Ie=function(e){return null!=e&&"object"==typeof e};const Me=function(e){return Ie(e)&&"[object Arguments]"==le(e)};var Fe=Object.prototype,Le=Fe.hasOwnProperty,Ne=Fe.propertyIsEnumerable;const Pe=Me(function(){return arguments}())?Me:function(e){return Ie(e)&&Le.call(e,"callee")&&!Ne.call(e,"callee")};const Re=function(){return!1};var De="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ue=De&&"object"==typeof module&&module&&!module.nodeType&&module,$e=Ue&&Ue.exports===De?X.Buffer:void 0;const ze=($e?$e.isBuffer:void 0)||Re;var He=/^(?:0|[1-9]\d*)$/;const Be=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};const qe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var We={};We["[object Float32Array]"]=We["[object Float64Array]"]=We["[object Int8Array]"]=We["[object Int16Array]"]=We["[object Int32Array]"]=We["[object Uint8Array]"]=We["[object Uint8ClampedArray]"]=We["[object Uint16Array]"]=We["[object Uint32Array]"]=!0,We["[object Arguments]"]=We["[object Array]"]=We["[object ArrayBuffer]"]=We["[object Boolean]"]=We["[object DataView]"]=We["[object Date]"]=We["[object Error]"]=We["[object Function]"]=We["[object Map]"]=We["[object Number]"]=We["[object Object]"]=We["[object RegExp]"]=We["[object Set]"]=We["[object String]"]=We["[object WeakMap]"]=!1;const Ge=function(e){return Ie(e)&&qe(e.length)&&!!We[le(e)]};const Je=function(e){return function(t){return e(t)}};var Ze="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ve=Ze&&"object"==typeof module&&module&&!module.nodeType&&module,Ke=Ve&&Ve.exports===Ze&&Y.process,Ye=function(){try{var e=Ve&&Ve.require&&Ve.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}();var Qe=Ye&&Ye.isTypedArray;const Xe=Qe?Je(Qe):Ge;var et=Object.prototype.hasOwnProperty;const tt=function(e,t){var n=K(e),r=!n&&Pe(e),o=!n&&!r&&ze(e),i=!n&&!r&&!o&&Xe(e),s=n||r||o||i,a=s?Te(e.length,String):[],c=a.length;for(var l in e)!t&&!et.call(e,l)||s&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Be(l,c))||a.push(l);return a};var nt=Object.prototype;const rt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||nt)};const ot=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object);var it=Object.prototype.hasOwnProperty;const st=function(e){if(!rt(e))return ot(e);var t=[];for(var n in Object(e))it.call(e,n)&&"constructor"!=n&&t.push(n);return t};const at=function(e){return null!=e&&qe(e.length)&&!fe(e)};const ct=function(e){return at(e)?tt(e):st(e)};const lt=function(e,t){return e&&ke(e,t,ct)};const ut=function(){this.__data__=[],this.size=0};const ft=function(e,t){return e===t||e!=e&&t!=t};const pt=function(e,t){for(var n=e.length;n--;)if(ft(e[n][0],t))return n;return-1};var ht=Array.prototype.splice;const dt=function(e){var t=this.__data__,n=pt(t,e);return!(n<0)&&(n==t.length-1?t.pop():ht.call(t,n,1),--this.size,!0)};const mt=function(e){var t=this.__data__,n=pt(t,e);return n<0?void 0:t[n][1]};const gt=function(e){return pt(this.__data__,e)>-1};const yt=function(e,t){var n=this.__data__,r=pt(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function vt(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])}}vt.prototype.clear=ut,vt.prototype.delete=dt,vt.prototype.get=mt,vt.prototype.has=gt,vt.prototype.set=yt;const bt=vt;const _t=function(){this.__data__=new bt,this.size=0};const wt=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n};const xt=function(e){return this.__data__.get(e)};const Ct=function(e){return this.__data__.has(e)};const St=je(X,"Map");const Ot=je(Object,"create");const jt=function(){this.__data__=Ot?Ot(null):{},this.size=0};const At=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t};var Et=Object.prototype.hasOwnProperty;const kt=function(e){var t=this.__data__;if(Ot){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return Et.call(t,e)?t[e]:void 0};var Tt=Object.prototype.hasOwnProperty;const It=function(e){var t=this.__data__;return Ot?void 0!==t[e]:Tt.call(t,e)};const Mt=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ot&&void 0===t?"__lodash_hash_undefined__":t,this};function Ft(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])}}Ft.prototype.clear=jt,Ft.prototype.delete=At,Ft.prototype.get=kt,Ft.prototype.has=It,Ft.prototype.set=Mt;const Lt=Ft;const Nt=function(){this.size=0,this.__data__={hash:new Lt,map:new(St||bt),string:new Lt}};const Pt=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e};const Rt=function(e,t){var n=e.__data__;return Pt(t)?n["string"==typeof t?"string":"hash"]:n.map};const Dt=function(e){var t=Rt(this,e).delete(e);return this.size-=t?1:0,t};const Ut=function(e){return Rt(this,e).get(e)};const $t=function(e){return Rt(this,e).has(e)};const zt=function(e,t){var n=Rt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function Ht(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])}}Ht.prototype.clear=Nt,Ht.prototype.delete=Dt,Ht.prototype.get=Ut,Ht.prototype.has=$t,Ht.prototype.set=zt;const Bt=Ht;const qt=function(e,t){var n=this.__data__;if(n instanceof bt){var r=n.__data__;if(!St||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Bt(r)}return n.set(e,t),this.size=n.size,this};function Wt(e){var t=this.__data__=new bt(e);this.size=t.size}Wt.prototype.clear=_t,Wt.prototype.delete=wt,Wt.prototype.get=xt,Wt.prototype.has=Ct,Wt.prototype.set=qt;const Gt=Wt;const Jt=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const Zt=function(e){return this.__data__.has(e)};function Vt(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Bt;++t<n;)this.add(e[t])}Vt.prototype.add=Vt.prototype.push=Jt,Vt.prototype.has=Zt;const Kt=Vt;const Yt=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};const Qt=function(e,t){return e.has(t)};const Xt=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 f=-1,p=!0,h=2&n?new Kt:void 0;for(i.set(e,t),i.set(t,e);++f<a;){var d=e[f],m=t[f];if(r)var g=s?r(m,d,f,t,e,i):r(d,m,f,e,t,i);if(void 0!==g){if(g)continue;p=!1;break}if(h){if(!Yt(t,(function(e,t){if(!Qt(h,t)&&(d===e||o(d,e,n,r,i)))return h.push(t)}))){p=!1;break}}else if(d!==m&&!o(d,m,n,r,i)){p=!1;break}}return i.delete(e),i.delete(t),p};const en=X.Uint8Array;const tn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n};const nn=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n};var rn=ee?ee.prototype:void 0,on=rn?rn.valueOf:void 0;const sn=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 en(e),new en(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ft(+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=tn;case"[object Set]":var c=1&r;if(a||(a=nn),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;r|=2,s.set(e,t);var u=Xt(a(e),a(t),r,o,i,s);return s.delete(e),u;case"[object Symbol]":if(on)return on.call(e)==on.call(t)}return!1};const an=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e};const cn=function(e,t,n){var r=t(e);return K(e)?r:an(r,n(e))};const ln=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};const un=function(){return[]};var fn=Object.prototype.propertyIsEnumerable,pn=Object.getOwnPropertySymbols;const hn=pn?function(e){return null==e?[]:(e=Object(e),ln(pn(e),(function(t){return fn.call(e,t)})))}:un;const dn=function(e){return cn(e,ct,hn)};var mn=Object.prototype.hasOwnProperty;const gn=function(e,t,n,r,o,i){var s=1&n,a=dn(e),c=a.length;if(c!=dn(t).length&&!s)return!1;for(var l=c;l--;){var u=a[l];if(!(s?u in t:mn.call(t,u)))return!1}var f=i.get(e),p=i.get(t);if(f&&p)return f==t&&p==e;var h=!0;i.set(e,t),i.set(t,e);for(var d=s;++l<c;){var m=e[u=a[l]],g=t[u];if(r)var y=s?r(g,m,u,t,e,i):r(m,g,u,e,t,i);if(!(void 0===y?m===g||o(m,g,n,r,i):y)){h=!1;break}d||(d="constructor"==u)}if(h&&!d){var v=e.constructor,b=t.constructor;v==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b||(h=!1)}return i.delete(e),i.delete(t),h};const yn=je(X,"DataView");const vn=je(X,"Promise");const bn=je(X,"Set");const _n=je(X,"WeakMap");var wn="[object Map]",xn="[object Promise]",Cn="[object Set]",Sn="[object WeakMap]",On="[object DataView]",jn=ye(yn),An=ye(St),En=ye(vn),kn=ye(bn),Tn=ye(_n),In=le;(yn&&In(new yn(new ArrayBuffer(1)))!=On||St&&In(new St)!=wn||vn&&In(vn.resolve())!=xn||bn&&In(new bn)!=Cn||_n&&In(new _n)!=Sn)&&(In=function(e){var t=le(e),n="[object Object]"==t?e.constructor:void 0,r=n?ye(n):"";if(r)switch(r){case jn:return On;case An:return wn;case En:return xn;case kn:return Cn;case Tn:return Sn}return t});const Mn=In;var Fn="[object Arguments]",Ln="[object Array]",Nn="[object Object]",Pn=Object.prototype.hasOwnProperty;const Rn=function(e,t,n,r,o,i){var s=K(e),a=K(t),c=s?Ln:Mn(e),l=a?Ln:Mn(t),u=(c=c==Fn?Nn:c)==Nn,f=(l=l==Fn?Nn:l)==Nn,p=c==l;if(p&&ze(e)){if(!ze(t))return!1;s=!0,u=!1}if(p&&!u)return i||(i=new Gt),s||Xe(e)?Xt(e,t,n,r,o,i):sn(e,t,c,n,r,o,i);if(!(1&n)){var h=u&&Pn.call(e,"__wrapped__"),d=f&&Pn.call(t,"__wrapped__");if(h||d){var m=h?e.value():e,g=d?t.value():t;return i||(i=new Gt),o(m,g,n,r,i)}}return!!p&&(i||(i=new Gt),gn(e,t,n,r,o,i))};const Dn=function e(t,n,r,o,i){return t===n||(null==t||null==n||!Ie(t)&&!Ie(n)?t!=t&&n!=n:Rn(t,n,r,o,e,i))};const Un=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 f=new Gt;if(r)var p=r(l,u,c,e,t,f);if(!(void 0===p?Dn(u,l,3,r,f):p))return!1}}return!0};const $n=function(e){return e==e&&!ue(e)};const zn=function(e){for(var t=ct(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,$n(o)]}return t};const Hn=function(e,t){return function(n){return null!=n&&(n[e]===t&&(void 0!==t||e in Object(n)))}};const Bn=function(e){var t=zn(e);return 1==t.length&&t[0][2]?Hn(t[0][0],t[0][1]):function(n){return n===e||Un(n,e,t)}};const qn=function(e){return"symbol"==typeof e||Ie(e)&&"[object Symbol]"==le(e)};var Wn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gn=/^\w*$/;const Jn=function(e,t){if(K(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!qn(e))||(Gn.test(e)||!Wn.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||Bt),n}Zn.Cache=Bt;const Vn=Zn;var Kn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Yn=/\\(\\)?/g;const Qn=function(e){var t=Vn(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((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}));const Xn=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};var er=ee?ee.prototype:void 0,tr=er?er.toString:void 0;const nr=function e(t){if("string"==typeof t)return t;if(K(t))return Xn(t,e)+"";if(qn(t))return tr?tr.call(t):"";var n=t+"";return"0"==n&&1/t==-Infinity?"-0":n};const rr=function(e){return null==e?"":nr(e)};const or=function(e,t){return K(e)?e:Jn(e,t)?[e]:Qn(rr(e))};const ir=function(e){if("string"==typeof e||qn(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t};const 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};const ar=function(e,t,n){var r=null==e?void 0:sr(e,t);return void 0===r?n:r};const cr=function(e,t){return null!=e&&t in Object(e)};const lr=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)&&qe(o)&&Be(s,o)&&(K(e)||Pe(e))};const ur=function(e,t){return null!=e&&lr(e,t,cr)};const fr=function(e,t){return Jn(e)&&$n(t)?Hn(ir(e),t):function(n){var r=ar(n,e);return void 0===r&&r===t?ur(n,e):Dn(t,r,3)}};const pr=function(e){return e};const hr=function(e){return function(t){return null==t?void 0:t[e]}};const dr=function(e){return function(t){return sr(t,e)}};const mr=function(e){return Jn(e)?hr(ir(e)):dr(e)};const gr=function(e){return"function"==typeof e?e:null==e?pr:"object"==typeof e?K(e)?fr(e[0],e[1]):Bn(e):mr(e)};const yr=function(e,t){var n={};return t=gr(t,3),lt(e,(function(e,r,o){Ee(n,t(e,r,o),e)})),n};function vr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class br{constructor(e,t){vr(this,"ctx",void 0),vr(this,"serviceHooks",void 0),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=>(K(null==e?void 0:e.blocks)&&(e.blocks=e.blocks.map((e=>e&&yr(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(fe(null==t?void 0: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)}}}))}))}}function _r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const wr=Symbol.for("proxy-continue"),xr=w()("LSPlugin:user"),Cr=new g("",{console:!0});function Sr(e,t,n){var r;const{key:o,label:i,desc:s,palette:a,keybinding:c,extras:l}=t;if("function"!=typeof n)return this.logger.error(`${o||i}: command action should be function.`),!1;const u=function(e){if("string"==typeof e)return e.trim().replace(/\s/g,"_").toLowerCase()}(o);if(!u)return this.logger.error(`${i}: command key is required.`),!1;const f=`SimpleCommandHook${u}${++kr}`;this.Editor["on"+f](n),null===(r=this.caller)||void 0===r||r.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:u,label:i,type:e,desc:s,keybinding:c,extras:l},["editor/hook",f]],a]})}function Or(e){return!("string"!=typeof(t=e)||36!==t.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(t))||(Cr.error(`#${e} is not a valid UUID string.`),!1);var t}let jr=null,Ar=new Map;const Er={async getInfo(e){return jr||(jr=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?jr[e]:jr},registerCommand:Sr,registerSearchService(e){if(Ar.has(e.name))throw new Error(`SearchService: #${e.name} has registered!`);Ar.set(e.name,new br(this,e))},registerCommandPalette(e,t){const{key:n,label:r,keybinding:o}=e;return Sr.call(this,"$palette$",{key:n,label:r,palette:!0,keybinding:o},t)},registerCommandShortcut(e,t,n={}){"string"==typeof e&&(e={mode:"global",binding:e});const{binding:r}=e,o="$shortcut$",i=n.key||o+m(null==r?void 0:r.toString());return Sr.call(this,o,{...n,key:i,palette:!1,keybinding:e},t)},registerUIItem(e,t){var n;const r=this.baseInfo.id;null===(n=this.caller)||void 0===n||n.call("api:call",{method:"register-plugin-ui-item",args:[r,e,t]})},registerPageMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;Sr.call(this,"page-menu-item",{key:n,label:r},t)},onBlockRendererSlotted(e,t){if(!Or(e))return;const n=this.baseInfo.id,r=`hook:editor:${m(`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){var n;if(!(e=null===(n=e)||void 0===n?void 0:n.trim()))return;let[r,o]=e.split(".");if(!["models","commands"].includes(null==o?void 0:o.toLowerCase()))throw new Error("Type only support '.models' or '.commands' currently.");const i=e.replace(`${r}.${o}.`,"");if(!r||!o||!i)throw new Error(`Illegal type of #${e} to invoke external plugin.`);return this._execCallableAPIAsync("invoke_external_plugin_cmd",r,o.toLowerCase(),i,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 kr=0;const Tr={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},registerSlashCommand(e,t){var n;xr("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=()=>{var e;null===(e=this.caller)||void 0===e||e.callUserModel(r)};"function"==typeof r&&(o=r);const i=`SlashCommandHook${t}${++kr}`;e[1]=i,this.Editor["on"+i](o)}return e})),null===(n=this.caller)||void 0===n||n.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;Sr.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;Sr.call(this,"highlight-context-menu-item",{key:r,label:e,extras:n},t)},scrollToBlockInPage(e,t,n){const r="block-content-"+t;null!=n&&n.replaceState?this.App.replaceState("page",{name:e},{anchor:r}):this.App.pushState("page",{name:e},{anchor:r})}},Ir={onBlockChanged(e,t){if(!Or(e))return;const n=this.baseInfo.id,r=`hook:db:${m(`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){if(t.pop(),null!=t&&t.some((e=>"function"==typeof e))){return this.Experiments.ensureHostScope().logseq.api.datascript_query(e,...t)}return this._execCallableAPIAsync("datascript_query",e,...t)}},Mr={},Fr={},Lr={makeSandboxStorage(){return new q(this,{assets:!0})}};class Nr extends(p()){constructor(e,t){super(),_r(this,"_baseInfo",void 0),_r(this,"_caller",void 0),_r(this,"_version","0.0.16"),_r(this,"_debugTag",""),_r(this,"_settingsSchema",void 0),_r(this,"_connected",!1),_r(this,"_ui",new Map),_r(this,"_mFileStorage",void 0),_r(this,"_mRequest",void 0),_r(this,"_mExperiments",void 0),_r(this,"_beforeunloadCallback",void 0),this._baseInfo=e,this._caller=t,t.on("sys:ui:visible",(e=>{null!=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:t,...n}=e,r=this._beforeunloadCallback;try{r&&await r(n),null==t||t.resolve(null)}catch(e){this.logger.error("[beforeunload] ",e),null==t||t.reject(e)}}))}async ready(e,t){var n,r;if(!this._connected)try{var i;"function"==typeof e&&(t=e,e={});let s=await this._caller.connectToParent(e);this._connected=!0,n=this._baseInfo,r=s,s=o()(n,r,{arrayMerge:(e,t)=>t}),this._baseInfo=s,null!==(i=s)&&void 0!==i&&i.id&&(this._debugTag=this._caller.debugTag=`#${s.id} [${s.name}]`,this.logger.setTag(this._debugTag)),this._settingsSchema&&(s.settings=function(e,t){const n=(t||[]).reduce(((e,t)=>("default"in t&&(e[t.key]=t.default),e)),{});return Object.assign(n,e)}(s.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,s)}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:null==e?void 0: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:null==e?void 0:e.autoFocus};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}toggleMainUI(){const e=0,t=this._ui.get(e);t&&t.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(e=this)&&((null===(t=e.baseInfo)||void 0===t?void 0:t.effect)||!(null!==(n=e.baseInfo)&&void 0!==n&&n.iir));var e,t,n}get logger(){return Cr}get settings(){var e;return null===(e=this.baseInfo)||void 0===e?void 0:e.settings}get caller(){return this._caller}resolveResourceFullUrl(e){if(this.ensureConnected(),e)return e=e.replace(/^[.\\/]+/,""),y(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!==wr)return r}if(t){const i=o.toString().match(/^(once|off|on)/i);if(null!=i){const o=i[0].toLowerCase(),s=i.input,a="off"===o,c=n.baseInfo.id;let l=s.slice(o.length),u=e[0],f=e[1];"string"==typeof u&&"function"==typeof f&&(u=u.replace(/^logseq./,":"),l=`${l}${u}`,u=f,f=e[2]),l=`hook:${t}:${m(l)}`,r[o](l,u);const p=()=>{r.off(l,u),r.listenerCount(l)||n.App._uninstallPluginHook(c,l)};return a?void p():(n.App._installPluginHook(c,l,f),p)}}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(Er,"app")}get Editor(){return this._makeUserProxy(Tr,"editor")}get DB(){return this._makeUserProxy(Ir,"db")}get Git(){return this._makeUserProxy(Mr,"git")}get UI(){return this._makeUserProxy(Fr,"ui")}get Assets(){return this._makeUserProxy(Lr,"assets")}get FileStorage(){let e=this._mFileStorage;return e||(e=this._mFileStorage=new q(this)),e}get Request(){let e=this._mRequest;return e||(e=this._mRequest=new V(this)),e}get Experiments(){let e=this._mExperiments;return e||(e=this._mExperiments=new W(this)),e}}function Pr(e,t){return new Nr(e,t)}if(null==window.__LSP__HOST__){const e=new H(null);window.logseq=Pr({},e)}})(),r})()));