diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index f077bfc..d8b8c73 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -30,8 +30,11 @@ jobs:
cp README.md ${{ env.PLUGIN_NAME }} || true
cp package.json ${{ env.PLUGIN_NAME }} || true
cp SynapseLogo.png ${{ env.PLUGIN_NAME }} || true
- cp LICENSE ${{ env.PLUGIN_NAME }} || true
+ cp LICENSE ${{ env.PLUGIN_NAME }} || true
+ cp index.html ${{ env.PLUGIN_NAME }} || true
+ cp lsplugin.user.min.js ${{ env.PLUGIN_NAME }} || true
cp index.js ${{ env.PLUGIN_NAME }} || true
+ cp icon.png ${{ env.PLUGIN_NAME }} || true
# Create zip
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
diff --git a/index.html b/index.html
index 7be9cab..c6bf813 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
Synapse for LogSeq
-
+
diff --git a/lsplugin.user.min.js b/lsplugin.user.min.js
new file mode 100644
index 0000000..8d077c6
--- /dev/null
+++ b/lsplugin.user.min.js
@@ -0,0 +1,8 @@
+/**
+ * Skipped minification because the original files appears to be already minified.
+ * Original file: /npm/@logseq/libs@0.2.1/dist/lsplugin.user.js
+ *
+ * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
+ */
+/*! 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{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t{"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);n1?n-1:0),o=1;o/gm),Y=g(/\${[\w\W]*}/gm),Q=g(/^data-[\-\w.\u00B7-\uFFFF]/),X=g(/^aria-[\-\w]+$/),ee=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),te=g(/^(?:\w+script|data):/i),ne=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=g(/^html$/i),oe=g(/^[a-z][.\w]*(-[.\w]+)+$/i),ie=function(){return"undefined"==typeof window?null:window},se=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},createScriptURL:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function ae(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ie(),n=function(e){return ae(e)};if(n.version="2.5.4",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,d=t.HTMLFormElement,h=t.DOMParser,g=t.trustedTypes,y=l.prototype,v=P(y,"cloneNode"),b=P(y,"nextSibling"),_=P(y,"childNodes"),M=P(y,"parentNode");if("function"==typeof a){var N=i.createElement("template");N.content&&N.content.ownerDocument&&(i=N.content.ownerDocument)}var ce=se(g,r),le=ce?ce.createHTML(""):"",ue=i,fe=ue.implementation,pe=ue.createNodeIterator,de=ue.createDocumentFragment,he=ue.getElementsByTagName,me=r.importNode,ge={};try{ge=R(i).documentMode?i.documentMode:{}}catch(e){}var ye={};n.isSupported="function"==typeof M&&fe&&void 0!==fe.createHTMLDocument&&9!==ge;var ve,be,_e=V,we=K,xe=Y,Ce=Q,Se=X,Oe=te,Ee=ne,Ae=oe,je=ee,ke=null,Te=F({},[].concat(o(D),o(U),o($),o(H),o(q))),Ie=null,Le=F({},[].concat(o(W),o(G),o(J),o(Z))),Me=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}})),Ne=null,Fe=null,Re=!0,Pe=!0,De=!1,Ue=!0,$e=!1,ze=!0,He=!1,Be=!1,qe=!1,We=!1,Ge=!1,Je=!1,Ze=!0,Ve=!1,Ke="user-content-",Ye=!0,Qe=!1,Xe={},et=null,tt=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"]),nt=null,rt=F({},["audio","video","img","source","image","track"]),ot=null,it=F({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),st="http://www.w3.org/1998/Math/MathML",at="http://www.w3.org/2000/svg",ct="http://www.w3.org/1999/xhtml",lt=ct,ut=!1,ft=null,pt=F({},[st,at,ct],O),dt=["application/xhtml+xml","text/html"],ht="text/html",mt=null,gt=255,yt=i.createElement("form"),vt=function(e){return e instanceof RegExp||e instanceof Function},bt=function(t){mt&&mt===t||(t&&"object"===e(t)||(t={}),t=R(t),ve=ve=-1===dt.indexOf(t.PARSER_MEDIA_TYPE)?ht:t.PARSER_MEDIA_TYPE,be="application/xhtml+xml"===ve?O:S,ke="ALLOWED_TAGS"in t?F({},t.ALLOWED_TAGS,be):Te,Ie="ALLOWED_ATTR"in t?F({},t.ALLOWED_ATTR,be):Le,ft="ALLOWED_NAMESPACES"in t?F({},t.ALLOWED_NAMESPACES,O):pt,ot="ADD_URI_SAFE_ATTR"in t?F(R(it),t.ADD_URI_SAFE_ATTR,be):it,nt="ADD_DATA_URI_TAGS"in t?F(R(rt),t.ADD_DATA_URI_TAGS,be):rt,et="FORBID_CONTENTS"in t?F({},t.FORBID_CONTENTS,be):tt,Ne="FORBID_TAGS"in t?F({},t.FORBID_TAGS,be):{},Fe="FORBID_ATTR"in t?F({},t.FORBID_ATTR,be):{},Xe="USE_PROFILES"in t&&t.USE_PROFILES,Re=!1!==t.ALLOW_ARIA_ATTR,Pe=!1!==t.ALLOW_DATA_ATTR,De=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Ue=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,$e=t.SAFE_FOR_TEMPLATES||!1,ze=!1!==t.SAFE_FOR_XML,He=t.WHOLE_DOCUMENT||!1,We=t.RETURN_DOM||!1,Ge=t.RETURN_DOM_FRAGMENT||!1,Je=t.RETURN_TRUSTED_TYPE||!1,qe=t.FORCE_BODY||!1,Ze=!1!==t.SANITIZE_DOM,Ve=t.SANITIZE_NAMED_PROPS||!1,Ye=!1!==t.KEEP_CONTENT,Qe=t.IN_PLACE||!1,je=t.ALLOWED_URI_REGEXP||je,lt=t.NAMESPACE||ct,Me=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&vt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Me.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&vt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Me.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Me.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$e&&(Pe=!1),Ge&&(We=!0),Xe&&(ke=F({},o(q)),Ie=[],!0===Xe.html&&(F(ke,D),F(Ie,W)),!0===Xe.svg&&(F(ke,U),F(Ie,G),F(Ie,Z)),!0===Xe.svgFilters&&(F(ke,$),F(Ie,G),F(Ie,Z)),!0===Xe.mathMl&&(F(ke,H),F(Ie,J),F(Ie,Z))),t.ADD_TAGS&&(ke===Te&&(ke=R(ke)),F(ke,t.ADD_TAGS,be)),t.ADD_ATTR&&(Ie===Le&&(Ie=R(Ie)),F(Ie,t.ADD_ATTR,be)),t.ADD_URI_SAFE_ATTR&&F(ot,t.ADD_URI_SAFE_ATTR,be),t.FORBID_CONTENTS&&(et===tt&&(et=R(et)),F(et,t.FORBID_CONTENTS,be)),Ye&&(ke["#text"]=!0),He&&F(ke,["html","head","body"]),ke.table&&(F(ke,["tbody"]),delete Ne.tbody),m&&m(t),mt=t)},_t=F({},["mi","mo","mn","ms","mtext"]),wt=F({},["foreignobject","annotation-xml"]),xt=F({},["title","style","font","a","script"]),Ct=F({},U);F(Ct,$),F(Ct,z);var St=F({},H);F(St,B);var Ot=function(e){var t=M(e);t&&t.tagName||(t={namespaceURI:lt,tagName:"template"});var n=S(e.tagName),r=S(t.tagName);return!!ft[e.namespaceURI]&&(e.namespaceURI===at?t.namespaceURI===ct?"svg"===n:t.namespaceURI===st?"svg"===n&&("annotation-xml"===r||_t[r]):Boolean(Ct[n]):e.namespaceURI===st?t.namespaceURI===ct?"math"===n:t.namespaceURI===at?"math"===n&&wt[r]:Boolean(St[n]):e.namespaceURI===ct?!(t.namespaceURI===at&&!wt[r])&&!(t.namespaceURI===st&&!_t[r])&&!St[n]&&(xt[n]||!Ct[n]):!("application/xhtml+xml"!==ve||!ft[e.namespaceURI]))},Et=function(e){C(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=le}catch(t){e.remove()}}},At=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&&!Ie[e])if(We||Ge)try{Et(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},jt=function(e){var t,n;if(qe)e=""+e;else{var r=E(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===ve&<===ct&&(e=''+e+"");var o=ce?ce.createHTML(e):e;if(lt===ct)try{t=(new h).parseFromString(o,ve)}catch(e){}if(!t||!t.documentElement){t=fe.createDocument(lt,"template",null);try{t.documentElement.innerHTML=ut?le:o}catch(e){}}var s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),lt===ct?he.call(t,He?"html":"body")[0]:He?t.documentElement:s},kt=function(e){return pe.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null,!1)},Tt=function(e){return e instanceof d&&(void 0!==e.__depth&&"number"!=typeof e.__depth||void 0!==e.__removalCount&&"number"!=typeof e.__removalCount||"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||"function"!=typeof e.hasChildNodes)},It=function(t){return"object"===e(c)?t instanceof c:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Lt=function(e,t,r){ye[e]&&w(ye[e],(function(e){e.call(n,t,r,mt)}))},Mt=function(e){var t;if(Lt("beforeSanitizeElements",e,null),Tt(e))return Et(e),!0;if(T(/[\u0080-\uFFFF]/,e.nodeName))return Et(e),!0;var r=be(e.nodeName);if(Lt("uponSanitizeElement",e,{tagName:r,allowedTags:ke}),e.hasChildNodes()&&!It(e.firstElementChild)&&(!It(e.content)||!It(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return Et(e),!0;if("select"===r&&T(/=0;--s){var a=v(i[s],!0);a.__removalCount=(e.__removalCount||0)+1,o.insertBefore(a,b(e))}}return Et(e),!0}return e instanceof l&&!Ot(e)?(Et(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!T(/<\/no(script|embed|frames)/i,e.innerHTML)?($e&&3===e.nodeType&&(t=e.textContent,t=A(t,_e," "),t=A(t,we," "),t=A(t,xe," "),e.textContent!==t&&(C(n.removed,{element:e.cloneNode()}),e.textContent=t)),Lt("afterSanitizeElements",e,null),!1):(Et(e),!0)},Nt=function(e,t,n){if(Ze&&("id"===t||"name"===t)&&(n in i||n in yt||"__depth"===n||"__removalCount"===n))return!1;if(Pe&&!Fe[t]&&T(Ce,t));else if(Re&&T(Se,t));else if(!Ie[t]||Fe[t]){if(!(Ft(e)&&(Me.tagNameCheck instanceof RegExp&&T(Me.tagNameCheck,e)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(e))&&(Me.attributeNameCheck instanceof RegExp&&T(Me.attributeNameCheck,t)||Me.attributeNameCheck instanceof Function&&Me.attributeNameCheck(t))||"is"===t&&Me.allowCustomizedBuiltInElements&&(Me.tagNameCheck instanceof RegExp&&T(Me.tagNameCheck,n)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(n))))return!1}else if(ot[t]);else if(T(je,A(n,Ee,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==j(n,"data:")||!nt[e])if(De&&!T(Oe,A(n,Ee,"")));else if(n)return!1;return!0},Ft=function(e){return"annotation-xml"!==e&&E(e,Ae)},Rt=function(t){var r,o,i,s;Lt("beforeSanitizeAttributes",t,null);var a=t.attributes;if(a){var c={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie};for(s=a.length;s--;){var l=r=a[s],u=l.name,f=l.namespaceURI;if(o="value"===u?r.value:k(r.value),i=be(u),c.attrName=i,c.attrValue=o,c.keepAttr=!0,c.forceKeepAttr=void 0,Lt("uponSanitizeAttribute",t,c),o=c.attrValue,!c.forceKeepAttr&&(At(u,t),c.keepAttr))if(Ue||!T(/\/>/i,o))if(ze&&T(/((--!?|])>)|<\/(style|title)/i,o))At(u,t);else{$e&&(o=A(o,_e," "),o=A(o,we," "),o=A(o,xe," "));var p=be(t.nodeName);if(Nt(p,i,o)){if(!Ve||"id"!==i&&"name"!==i||(At(u,t),o=Ke+o),ce&&"object"===e(g)&&"function"==typeof g.getAttributeType)if(f);else switch(g.getAttributeType(p,i)){case"TrustedHTML":o=ce.createHTML(o);break;case"TrustedScriptURL":o=ce.createScriptURL(o)}try{f?t.setAttributeNS(f,u,o):t.setAttribute(u,o),Tt(t)?Et(t):x(n.removed)}catch(e){}}}else At(u,t)}Lt("afterSanitizeAttributes",t,null)}},Pt=function e(t){var n,r=kt(t);for(Lt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)if(Lt("uponSanitizeShadowNode",n,null),!Mt(n)){var o=M(n);1===n.nodeType&&(o&&o.__depth?n.__depth=(n.__removalCount||0)+o.__depth+1:n.__depth=1),(n.__depth>=gt||L(n.__depth))&&Et(n),n.content instanceof s&&(n.content.__depth=n.__depth,e(n.content)),Rt(n)}Lt("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(o){var i,a,l,u,f,p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((ut=!o)&&(o="\x3c!--\x3e"),"string"!=typeof o&&!It(o)){if("function"!=typeof o.toString)throw I("toString is not a function");if("string"!=typeof(o=o.toString()))throw I("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(It(o))return t.toStaticHTML(o.outerHTML)}return o}if(Be||bt(p),n.removed=[],"string"==typeof o&&(Qe=!1),Qe){if(o.nodeName){var d=be(o.nodeName);if(!ke[d]||Ne[d])throw I("root node is forbidden and cannot be sanitized in-place")}}else if(o instanceof c)1===(a=(i=jt("\x3c!----\x3e")).ownerDocument.importNode(o,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?i=a:i.appendChild(a);else{if(!We&&!$e&&!He&&-1===o.indexOf("<"))return ce&&Je?ce.createHTML(o):o;if(!(i=jt(o)))return We?null:Je?le:""}i&&qe&&Et(i.firstChild);for(var h=kt(Qe?o:i);l=h.nextNode();)if((3!==l.nodeType||l!==u)&&!Mt(l)){var m=M(l);1===l.nodeType&&(m&&m.__depth?l.__depth=(l.__removalCount||0)+m.__depth+1:l.__depth=1),(l.__depth>=gt||L(l.__depth))&&Et(l),l.content instanceof s&&(l.content.__depth=l.__depth,Pt(l.content)),Rt(l),u=l}if(u=null,Qe)return o;if(We){if(Ge)for(f=de.call(i.ownerDocument);i.firstChild;)f.appendChild(i.firstChild);else f=i;return(Ie.shadowroot||Ie.shadowrootmod)&&(f=me.call(r,f,!0)),f}var g=He?i.outerHTML:i.innerHTML;return He&&ke["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&T(re,i.ownerDocument.doctype.name)&&(g="\n"+g),$e&&(g=A(g,_e," "),g=A(g,we," "),g=A(g,xe," ")),ce&&Je?ce.createHTML(g):g},n.setConfig=function(e){bt(e),Be=!0},n.clearConfig=function(){mt=null,Be=!1},n.isValidAttribute=function(e,t,n){mt||bt({});var r=be(e),o=be(t);return Nt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(ye[e]=ye[e]||[],C(ye[e],t))},n.removeHook=function(e){if(ye[e])return x(ye[e])},n.removeHooks=function(e){ye[e]&&(ye[e]=[])},n.removeAllHooks=function(){ye={}},n}return ae()}()},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{"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=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 d(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,h=c.tail;if((!l||!e||l.toLowerCase()===e.toLowerCase())&&(e||(e=l),n||(t=h+"\\"+t,n=f),e&&n))break}}return u&&(e=d(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=d(n)),n+(o?"\\":"")+i},u.isAbsolute=function(e){return p(e).isAbsolute},u.join=function(){for(var e=[],t=0;t=-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{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=[];++u1)for(var n=1;n{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=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=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),h(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(h(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=["{","}"];(d(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=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")),j(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 d(e){return Array.isArray(e)}function h(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=d,t.isBoolean=h,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 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 j(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:()=>$r,setupPluginUserInstance:()=>zr});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(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=h.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return h.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},E=(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(!E(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 j{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(!E(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=>!!E(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 j(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:L,createSandboxContainer:M}=window.QSandbox||{};function N(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 F 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 L(t,{fetch:N});this._mount(n,document.body);const o=M(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 $r(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=`${e}
`,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 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 P=w()("LSPlugin:caller"),D="#await#response#",U="#lspmsg#",$="#lspmsg#error#",z=e=>`#lspmsg#${e}`;class H extends(p()){constructor(e){super(),R(this,"_pluginLocal",void 0),R(this,"_connected",!1),R(this,"_parent",void 0),R(this,"_child",void 0),R(this,"_shadow",void 0),R(this,"_status",void 0),R(this,"_userModel",{}),R(this,"_call",void 0),R(this,"_callUserModel",void 0),R(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})=>{P(`[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})=>{P(`[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(P(`[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}`),P(`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){P(`[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()}),8e3),l.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on(z(e.id),(({type:e,payload:t})=>{var n,r;P("[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 P("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new F(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 P("[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 Components(){return{Editor:this.ensureHostScope().logseq.sdk.experiments.cp_page_editor}}get pluginLocal(){return this.ensureHostScope().LSPluginCore.ensurePlugin(this.ctx.baseInfo.id)}invokeExperMethod(e,...t){var n;const r=this.ensureHostScope();e=null===(n=m(e))||void 0===n?void 0:n.toLowerCase();const o=r.logseq.api["exper_"+e]||r.logseq.sdk.experiments[e];return null==o?void 0:o.apply(r,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.invokeExperMethod("registerFencedCodeRenderer",this.ctx.baseInfo.id,e,t)}registerDaemonRenderer(e,t){return this.invokeExperMethod("registerDaemonRenderer",this.ctx.baseInfo.id,e,t)}registerRouteRenderer(e,t){return this.invokeExperMethod("registerRouteRenderer",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 this.invokeExperMethod("registerExtensionsEnhancer",this.ctx.baseInfo.id,e,t)}ensureHostScope(){return window===top?(console.error("Can not access host scope!"),{}):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 de,he=(de=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";const me=function(e){return!!he&&he 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 Ee=function(e,t){var n=Oe(e,t);return Se(n)?n:void 0};const Ae=function(){try{var e=Ee(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const je=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-1&&e%1==0&&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&&Re(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 dt=Array.prototype.splice;const ht=function(e){var t=this.__data__,n=pt(t,e);return!(n<0)&&(n==t.length-1?t.pop():dt.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();++ta))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var f=-1,p=!0,d=2&n?new Kt:void 0;for(i.set(e,t),i.set(t,e);++f(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){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function wr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xr(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,Sr(e,t,"set"),n),n}function Cr(e,t){return function(e,t){if(t.get)return t.get.call(e);return t.value}(e,Sr(e,t,"get"))}function Sr(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}const Or=Symbol.for("proxy-continue"),Er=w()("LSPlugin:user"),Ar=new g("",{console:!0});function jr(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}${++Mr}`;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 kr(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))||(Ar.error(`#${e} is not a valid UUID string.`),!1);var t}let Tr=null,Ir=new Map;const Lr={async getInfo(e){return Tr||(Tr=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?Tr[e]:Tr},registerCommand:jr,registerSearchService(e){if(Ir.has(e.name))throw new Error(`SearchService: #${e.name} has registered!`);Ir.set(e.name,new br(this,e))},registerCommandPalette(e,t){const{key:n,label:r,keybinding:o}=e;return jr.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 jr.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;jr.call(this,"page-menu-item",{key:n,label:r},t)},onBlockRendererSlotted(e,t){if(!kr(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 Mr=0;const Nr={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},registerSlashCommand(e,t){var n;Er("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}${++Mr}`;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;jr.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;jr.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})}},Fr={onBlockChanged(e,t){if(!kr(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)}},Rr={},Pr={},Dr={makeSandboxStorage(){return new q(this,{assets:!0})}};var Ur=new WeakMap;class $r extends(p()){constructor(e,t){super(),wr(this,"_baseInfo",void 0),wr(this,"_caller",void 0),wr(this,"_version","0.2.1"),wr(this,"_debugTag",""),wr(this,"_settingsSchema",void 0),wr(this,"_connected",!1),wr(this,"_ui",new Map),wr(this,"_mFileStorage",void 0),wr(this,"_mRequest",void 0),wr(this,"_mExperiments",void 0),wr(this,"_beforeunloadCallback",void 0),_r(this,Ur,{writable:!0,value: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 Ar}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){0!==(null==e?void 0:e.length)&&e.concat(t);const r=s.apply(n,e);if(r!==Or)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 Cr(this,Ur)?Cr(this,Ur):xr(this,Ur,this._makeUserProxy(Lr,"app"))}get Editor(){return this._makeUserProxy(Nr,"editor")}get DB(){return this._makeUserProxy(Fr,"db")}get Git(){return this._makeUserProxy(Rr,"git")}get UI(){return this._makeUserProxy(Pr,"ui")}get Assets(){return this._makeUserProxy(Dr,"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 zr(e,t){return new $r(e,t)}if(null==window.__LSP__HOST__){const e=new H(null);window.logseq=zr({},e)}})(),r})()));
\ No newline at end of file