mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 06:04:42 +00:00
2 lines
113 KiB
JavaScript
2 lines
113 KiB
JavaScript
/*! For license information please see lsplugin.core.js.LICENSE.txt */
|
||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LSPlugin=t():e.LSPlugin=t()}(self,()=>(()=>{var e={833(e,t,n){var r=n(606);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,s=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(s=r))}),t.splice(s,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")||t.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),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;let e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[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(736)(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736(e,t,n){e.exports=function(e){function t(e){let n,s,i,o=null;function a(...e){if(!a.enabled)return;const r=a,s=Number(new Date),i=s-(n||s);r.diff=i,r.prev=n,r.curr=s,n=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,s)=>{if("%%"===n)return"%";o++;const i=t.formatters[s];if("function"==typeof i){const t=e[o];n=i.call(r,t),e.splice(o,1),o--}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!==o?o:(s!==t.namespaces&&(s=t.namespaces,i=t.enabled(e)),i),set:e=>{o=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 s(e,t){let n=0,r=0,s=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(s=r,i=n,r++):(n++,r++);else{if(-1===s)return!1;r=s+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(s(e,n))return!1;for(const n of t.names)if(s(e,n))return!0;return!1},t.humanize=n(585),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}},744(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)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function s(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 o(e,t){try{return t in e}catch(e){return!1}}function a(e,n,l){(l=l||{}).arrayMerge=l.arrayMerge||s,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=r;var c=Array.isArray(n);return c===Array.isArray(e)?c?l.arrayMerge(e,n,l):function(e,t,n){var s={};return n.isMergeableObject(e)&&i(e).forEach(function(t){s[t]=r(e[t],n)}),i(t).forEach(function(i){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(o(e,i)&&n.isMergeableObject(t[i])?s[i]=function(e,t){if(!t.customMerge)return a;var n=t.customMerge(e);return"function"==typeof n?n:a}(i,n)(e[i],t[i],n):s[i]=r(t[i],n))}),s}(e,n,l):r(n,l)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return a(e,n,t)},{})};var l=a;e.exports=l},228(e){"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function s(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,i||e,o),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function o(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,s=[];if(0===this._eventsCount)return s;for(r in e=this._events)t.call(e,r)&&s.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},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 s=0,i=r.length,o=new Array(i);s<i;s++)o[s]=r[s].fn;return o},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,s,i,o){var a=n?n+e:e;if(!this._events[a])return!1;var l,c,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,s),!0;case 5:return u.fn.call(u.context,t,r,s,i),!0;case 6:return u.fn.call(u.context,t,r,s,i,o),!0}for(c=1,l=new Array(h-1);c<h;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var d,p=u.length;for(c=0;c<p;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),h){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,r);break;case 4:u[c].fn.call(u[c].context,t,r,s);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];u[c].fn.apply(u[c].context,l)}}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,s){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return o(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||s&&!a.once||r&&a.context!==r||o(this,i);else{for(var l=0,c=[],u=a.length;l<u;l++)(a[l].fn!==t||s&&!a[l].once||r&&a[l].context!==r)&&c.push(a[l]);c.length?this._events[i]=1===c.length?c[0]:c:o(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&o(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},698(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}},585(e){var t=1e3,n=60*t,r=60*n,s=24*r,i=7*s;function o(e,t,n,r){var s=t>=1.5*n;return Math.round(e/n)+" "+r+(s?"s":"")}e.exports=function(e,a){a=a||{};var l,c,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\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(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*i;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&isFinite(e))return a.long?(l=e,(c=Math.abs(l))>=s?o(l,c,s,"day"):c>=r?o(l,c,r,"hour"):c>=n?o(l,c,n,"minute"):c>=t?o(l,c,t,"second"):l+" ms"):function(e){var i=Math.abs(e);return i>=s?Math.round(e/s)+"d":i>=r?Math.round(e/r)+"h":i>=n?Math.round(e/n)+"m":i>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},627(e,t,n){"use strict";var r=n(606),s="win32"===r.platform,i=n(537);function o(e,t){for(var n=[],r=0;r<e.length;r++){var s=e[r];s&&"."!==s&&(".."===s?n.length&&".."!==n[n.length-1]?n.pop():t&&n.push(".."):n.push(s))}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 l=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,c=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,u={};function h(e){var t=l.exec(e),n=(t[1]||"")+(t[2]||""),r=t[3]||"",s=c.exec(r);return[n,s[1],s[2],s[3]]}function d(e){var t=l.exec(e),n=t[1]||"",r=!!n&&":"!==n[1];return{device:n,isUnc:r,isAbsolute:r||!!t[2],tail:t[3]}}function p(e){return"\\\\"+e.replace(/^[\\\/]+/,"").replace(/[\\\/]+/g,"\\")}u.resolve=function(){for(var e="",t="",n=!1,s=arguments.length-1;s>=-1;s--){var a;if(s>=0?a=arguments[s]: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 l=d(a),c=l.device,u=l.isUnc,h=l.isAbsolute,f=l.tail;if((!c||!e||c.toLowerCase()===e.toLowerCase())&&(e||(e=c),n||(t=f+"\\"+t,n=h),e&&n))break}}return u&&(e=p(e)),e+(n?"\\":"")+(t=o(t.split(/[\\\/]+/),!n).join("\\"))||"."},u.normalize=function(e){var t=d(e),n=t.device,r=t.isUnc,s=t.isAbsolute,i=t.tail,a=/[\\\/]$/.test(i);return(i=o(i.split(/[\\\/]+/),!s).join("\\"))||s||(i="."),i&&a&&(i+="\\"),r&&(n=p(n)),n+(s?"\\":"")+i},u.isAbsolute=function(e){return d(e).isAbsolute},u.join=function(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(!i.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&e.push(n)}var r=e.join("\\");return/^[\\\/]{2}[^\\\/]/.test(e[0])||(r=r.replace(/^[\\\/]{2,}/,"\\")),u.normalize(r)},u.relative=function(e,t){e=u.resolve(e),t=u.resolve(t);for(var n=e.toLowerCase(),r=t.toLowerCase(),s=a(t.split("\\")),i=a(n.split("\\")),o=a(r.split("\\")),l=Math.min(i.length,o.length),c=l,h=0;h<l;h++)if(i[h]!==o[h]){c=h;break}if(0==c)return t;var d=[];for(h=c;h<i.length;h++)d.push("..");return(d=d.concat(s.slice(c))).join("\\")},u._makeLong=function(e){if(!i.isString(e))return e;if(!e)return"";var t=u.resolve(e);return/^[a-zA-Z]\:\\/.test(t)?"\\\\?\\"+t:/^\\\\[^?.]/.test(t)?"\\\\?\\UNC\\"+t.substring(2):e},u.dirname=function(e){var t=h(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},u.basename=function(e,t){var n=h(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},u.extname=function(e){return h(e)[3]},u.format=function(e){if(!i.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!i.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var n=e.dir,r=e.base||"";return n?n[n.length-1]===u.sep?n+r:n+u.sep+r:r},u.parse=function(e){if(!i.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=h(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},u.sep="\\",u.delimiter=";";var f=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,g={};function m(e){return f.exec(e).slice(1)}g.resolve=function(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var s=n>=0?arguments[n]:r.cwd();if(!i.isString(s))throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,t="/"===s[0])}return(t?"/":"")+(e=o(e.split("/"),!t).join("/"))||"."},g.normalize=function(e){var t=g.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=o(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},g.isAbsolute=function(e){return"/"===e.charAt(0)},g.join=function(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];if(!i.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&(e+=e?"/"+n:n)}return g.normalize(e)},g.relative=function(e,t){e=g.resolve(e).substr(1),t=g.resolve(t).substr(1);for(var n=a(e.split("/")),r=a(t.split("/")),s=Math.min(n.length,r.length),i=s,o=0;o<s;o++)if(n[o]!==r[o]){i=o;break}var l=[];for(o=i;o<n.length;o++)l.push("..");return(l=l.concat(r.slice(i))).join("/")},g._makeLong=function(e){return e},g.dirname=function(e){var t=m(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},g.basename=function(e,t){var n=m(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},g.extname=function(e){return m(e)[3]},g.format=function(e){if(!i.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!i.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);return(e.dir?e.dir+g.sep:"")+(e.base||"")},g.parse=function(e){if(!i.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=m(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return t[1]=t[1]||"",t[2]=t[2]||"",t[3]=t[3]||"",{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},g.sep="/",g.delimiter=":",e.exports=s?u:g,e.exports.posix=g,e.exports.win32=u},606(e){var t,n,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!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:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var a,l=[],c=!1,u=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):u=-1,l.length&&d())}function d(){if(!c){var e=o(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++u<t;)a&&a[u].run();u=-1,t=l.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{return n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}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];l.push(new p(e,t)),1!==l.length||c||o(d)},p.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=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,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}},135(e){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},537(e,t,n){var r=n(606),s=/%[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,o=String(e).replace(s,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}}),l=r[n];n<i;l=r[++n])g(l)||!v(l)?o+=" "+l:o+=" "+a(l);return o},t.deprecate=function(e,s){if(_(n.g.process))return function(){return t.deprecate(e,s).apply(this,arguments)};if(!0===r.noDeprecation)return e;var i=!1;return function(){if(!i){if(r.throwDeprecation)throw new Error(s);r.traceDeprecation?console.trace(s):console.error(s),i=!0}return e.apply(this,arguments)}};var i,o={};function a(e,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),f(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function c(e,t){return e}function u(e,n,r){if(e.customInspect&&n&&S(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var s=n.inspect(r,e);return y(s)||(s=u(e,s,r)),s}var i=function(e,t){if(_(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}(e,n);if(i)return i;var o=Object.keys(n),a=function(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(n)),C(n)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return h(n);if(0===o.length){if(S(n)){var l=n.name?": "+n.name:"";return e.stylize("[Function"+l+"]","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(C(n))return h(n)}var c,v="",x=!1,E=["{","}"];return p(n)&&(x=!0,E=["[","]"]),S(n)&&(v=" [Function"+(n.name?": "+n.name:"")+"]"),b(n)&&(v=" "+RegExp.prototype.toString.call(n)),w(n)&&(v=" "+Date.prototype.toUTCString.call(n)),C(n)&&(v=" "+h(n)),0!==o.length||x&&0!=n.length?r<0?b(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=x?function(e,t,n,r,s){for(var i=[],o=0,a=t.length;o<a;++o)A(t,String(o))?i.push(d(e,t,n,r,String(o),!0)):i.push("");return s.forEach(function(s){s.match(/^\d+$/)||i.push(d(e,t,n,r,s,!0))}),i}(e,n,r,a,o):o.map(function(t){return d(e,n,r,a,t,x)}),e.seen.pop(),function(e,t,n){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,v,E)):E[0]+v+E[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function d(e,t,n,r,s,i){var o,a,l;if((l=Object.getOwnPropertyDescriptor(t,s)||{value:t[s]}).get?a=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(a=e.stylize("[Setter]","special")),A(r,s)||(o="["+s+"]"),a||(e.seen.indexOf(l.value)<0?(a=g(n)?u(e,l.value,null):u(e,l.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")),_(o)){if(i&&s.match(/^\d+$/))return a;(o=JSON.stringify(""+s)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function p(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function b(e){return v(e)&&"[object RegExp]"===x(e)}function v(e){return"object"==typeof e&&null!==e}function w(e){return v(e)&&"[object Date]"===x(e)}function C(e){return v(e)&&("[object Error]"===x(e)||e instanceof Error)}function S(e){return"function"==typeof e}function x(e){return Object.prototype.toString.call(e)}function E(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(_(i)&&(i=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!o[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var n=r.pid;o[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else o[e]=function(){};return o[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=p,t.isBoolean=f,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=b,t.isObject=v,t.isDate=w,t.isError=C,t.isFunction=S,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(135);var T=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,n;console.log("%s - %s",(n=[E((e=new Date).getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":"),[e.getDate(),T[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=n(698),t._extend=function(e,t){if(!t||!v(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{PluginLocal:()=>vs,pluginHelpers:()=>t,setupPluginCore:()=>Cs});var e={};n.r(e),n.d(e,{setSDKMetadata:()=>ye});var t={};n.r(t),n.d(t,{IS_DEV:()=>be,PROTOCOL_FILE:()=>ve,PROTOCOL_LSP:()=>we,PluginLogger:()=>ke,URL_LSP:()=>Ce,cleanInjectedScripts:()=>He,cleanInjectedUI:()=>ze,deepMerge:()=>Oe,deferred:()=>De,genID:()=>Le,getAppPathRoot:()=>Ee,getSDKPathRoot:()=>Te,injectTheme:()=>qe,invokeHostExportedApi:()=>Ne,isObject:()=>Ae,isValidUUID:()=>Pe,mergeSettingsWithSchema:()=>Be,normalizeKeyStr:()=>Ge,path:()=>_e,safeSnakeCase:()=>xe,safetyPathJoin:()=>Me,safetyPathNormalize:()=>Re,setupInjectedStyle:()=>Ue,setupInjectedUI:()=>$e,transformableEvent:()=>We,ucFirst:()=>Ie,withFileProtocol:()=>je});var s=n(228);const i=s;var o=n(627);const{entries:a,setPrototypeOf:l,isFrozen:c,getPrototypeOf:u,getOwnPropertyDescriptor:h}=Object;let{freeze:d,seal:p,create:f}=Object,{apply:g,construct:m}="undefined"!=typeof Reflect&&Reflect;d||(d=function(e){return e}),p||(p=function(e){return e}),g||(g=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),s=2;s<n;s++)r[s-2]=arguments[s];return e.apply(t,r)}),m||(m=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)});const y=I(Array.prototype.forEach),_=I(Array.prototype.lastIndexOf),b=I(Array.prototype.pop),v=I(Array.prototype.push),w=I(Array.prototype.splice),C=I(String.prototype.toLowerCase),S=I(String.prototype.toString),x=I(String.prototype.match),E=I(String.prototype.replace),T=I(String.prototype.indexOf),A=I(String.prototype.trim),O=I(Object.prototype.hasOwnProperty),k=I(RegExp.prototype.test),P=(L=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m(L,t)});var L;function I(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return g(e,t,r)}}function j(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:C;l&&l(e,null);let r=t.length;for(;r--;){let s=t[r];if("string"==typeof s){const e=n(s);e!==s&&(c(t)||(t[r]=e),s=e)}e[s]=!0}return e}function M(e){for(let t=0;t<e.length;t++)O(e,t)||(e[t]=null);return e}function R(e){const t=f(null);for(const[n,r]of a(e))O(e,n)&&(Array.isArray(r)?t[n]=M(r):r&&"object"==typeof r&&r.constructor===Object?t[n]=R(r):t[n]=r);return t}function D(e,t){for(;null!==e;){const n=h(e,t);if(n){if(n.get)return I(n.get);if("function"==typeof n.value)return I(n.value)}e=u(e)}return function(){return null}}const N=d(["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","search","section","select","shadow","slot","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"]),U=d(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),F=d(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$=d(["animate","color-profile","cursor","discard","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"]),z=d(["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","mprescripts"]),H=d(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),W=d(["#text"]),q=d(["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","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","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","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),B=d(["accent-height","accumulate","additive","alignment-baseline","amplitude","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","exponent","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","intercept","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","mask-type","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","slope","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","tablevalues","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"]),G=d(["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"]),J=d(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Y=p(/\{\{[\w\W]*|[\w\W]*\}\}/gm),K=p(/<%[\w\W]*|[\w\W]*%>/gm),V=p(/\$\{[\w\W]*/gm),X=p(/^data-[\-\w.\u00B7-\uFFFF]+$/),Z=p(/^aria-[\-\w]+$/),Q=p(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ee=p(/^(?:\w+script|data):/i),te=p(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ne=p(/^html$/i),re=p(/^[a-z][.\w]*(-[.\w]+)+$/i);var se=Object.freeze({__proto__:null,ARIA_ATTR:Z,ATTR_WHITESPACE:te,CUSTOM_ELEMENT:re,DATA_ATTR:X,DOCTYPE_NAME:ne,ERB_EXPR:K,IS_ALLOWED_URI:Q,IS_SCRIPT_OR_DATA:ee,MUSTACHE_EXPR:Y,TMPLIT_EXPR:V});const ie=function(){return"undefined"==typeof window?null:window};var oe=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ie();const n=t=>e(t);if(n.version="3.3.3",n.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return n.isSupported=!1,n;let{document:r}=t;const s=r,i=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:l,Node:c,Element:u,NodeFilter:h,NamedNodeMap:p=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:g,DOMParser:m,trustedTypes:L}=t,I=u.prototype,M=D(I,"cloneNode"),Y=D(I,"remove"),K=D(I,"nextSibling"),V=D(I,"childNodes"),X=D(I,"parentNode");if("function"==typeof l){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Z,ee="";const{implementation:te,createNodeIterator:re,createDocumentFragment:oe,getElementsByTagName:ae}=r,{importNode:le}=s;let ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof a&&"function"==typeof X&&te&&void 0!==te.createHTMLDocument;const{MUSTACHE_EXPR:ue,ERB_EXPR:he,TMPLIT_EXPR:de,DATA_ATTR:pe,ARIA_ATTR:fe,IS_SCRIPT_OR_DATA:ge,ATTR_WHITESPACE:me,CUSTOM_ELEMENT:ye}=se;let{IS_ALLOWED_URI:_e}=se,be=null;const ve=j({},[...N,...U,...F,...z,...W]);let we=null;const Ce=j({},[...q,...B,...G,...J]);let Se=Object.seal(f(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}})),xe=null,Ee=null;const Te=Object.seal(f(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ae=!0,Oe=!0,ke=!1,Pe=!0,Le=!1,Ie=!0,je=!1,Me=!1,Re=!1,De=!1,Ne=!1,Ue=!1,Fe=!0,$e=!1,ze=!0,He=!1,We={},qe=null;const Be=j({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ge=null;const Je=j({},["audio","video","img","source","image","track"]);let Ye=null;const Ke=j({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",Ze="http://www.w3.org/1999/xhtml";let Qe=Ze,et=!1,tt=null;const nt=j({},[Ve,Xe,Ze],S);let rt=j({},["mi","mo","mn","ms","mtext"]),st=j({},["annotation-xml"]);const it=j({},["title","style","font","a","script"]);let ot=null;const at=["application/xhtml+xml","text/html"];let lt=null,ct=null;const ut=r.createElement("form"),ht=function(e){return e instanceof RegExp||e instanceof Function},dt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ct||ct!==e){if(e&&"object"==typeof e||(e={}),e=R(e),ot=-1===at.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,lt="application/xhtml+xml"===ot?S:C,be=O(e,"ALLOWED_TAGS")?j({},e.ALLOWED_TAGS,lt):ve,we=O(e,"ALLOWED_ATTR")?j({},e.ALLOWED_ATTR,lt):Ce,tt=O(e,"ALLOWED_NAMESPACES")?j({},e.ALLOWED_NAMESPACES,S):nt,Ye=O(e,"ADD_URI_SAFE_ATTR")?j(R(Ke),e.ADD_URI_SAFE_ATTR,lt):Ke,Ge=O(e,"ADD_DATA_URI_TAGS")?j(R(Je),e.ADD_DATA_URI_TAGS,lt):Je,qe=O(e,"FORBID_CONTENTS")?j({},e.FORBID_CONTENTS,lt):Be,xe=O(e,"FORBID_TAGS")?j({},e.FORBID_TAGS,lt):R({}),Ee=O(e,"FORBID_ATTR")?j({},e.FORBID_ATTR,lt):R({}),We=!!O(e,"USE_PROFILES")&&e.USE_PROFILES,Ae=!1!==e.ALLOW_ARIA_ATTR,Oe=!1!==e.ALLOW_DATA_ATTR,ke=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Le=e.SAFE_FOR_TEMPLATES||!1,Ie=!1!==e.SAFE_FOR_XML,je=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,Ne=e.RETURN_DOM_FRAGMENT||!1,Ue=e.RETURN_TRUSTED_TYPE||!1,Re=e.FORCE_BODY||!1,Fe=!1!==e.SANITIZE_DOM,$e=e.SANITIZE_NAMED_PROPS||!1,ze=!1!==e.KEEP_CONTENT,He=e.IN_PLACE||!1,_e=e.ALLOWED_URI_REGEXP||Q,Qe=e.NAMESPACE||Ze,rt=e.MATHML_TEXT_INTEGRATION_POINTS||rt,st=e.HTML_INTEGRATION_POINTS||st,Se=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Se.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ht(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Se.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Se.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(Oe=!1),Ne&&(De=!0),We&&(be=j({},W),we=f(null),!0===We.html&&(j(be,N),j(we,q)),!0===We.svg&&(j(be,U),j(we,B),j(we,J)),!0===We.svgFilters&&(j(be,F),j(we,B),j(we,J)),!0===We.mathMl&&(j(be,z),j(we,G),j(we,J))),O(e,"ADD_TAGS")||(Te.tagCheck=null),O(e,"ADD_ATTR")||(Te.attributeCheck=null),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?Te.tagCheck=e.ADD_TAGS:(be===ve&&(be=R(be)),j(be,e.ADD_TAGS,lt))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?Te.attributeCheck=e.ADD_ATTR:(we===Ce&&(we=R(we)),j(we,e.ADD_ATTR,lt))),e.ADD_URI_SAFE_ATTR&&j(Ye,e.ADD_URI_SAFE_ATTR,lt),e.FORBID_CONTENTS&&(qe===Be&&(qe=R(qe)),j(qe,e.FORBID_CONTENTS,lt)),e.ADD_FORBID_CONTENTS&&(qe===Be&&(qe=R(qe)),j(qe,e.ADD_FORBID_CONTENTS,lt)),ze&&(be["#text"]=!0),je&&j(be,["html","head","body"]),be.table&&(j(be,["tbody"]),delete xe.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw P('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw P('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Z=e.TRUSTED_TYPES_POLICY,ee=Z.createHTML("")}else void 0===Z&&(Z=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(L,i)),null!==Z&&"string"==typeof ee&&(ee=Z.createHTML(""));d&&d(e),ct=e}},pt=j({},[...U,...F,...$]),ft=j({},[...z,...H]),gt=function(e){v(n.removed,{element:e});try{X(e).removeChild(e)}catch(t){Y(e)}},mt=function(e,t){try{v(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){v(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(De||Ne)try{gt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},yt=function(e){let t=null,n=null;if(Re)e="<remove></remove>"+e;else{const t=x(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ot&&Qe===Ze&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=Z?Z.createHTML(e):e;if(Qe===Ze)try{t=(new m).parseFromString(s,ot)}catch(e){}if(!t||!t.documentElement){t=te.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?ee:s}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Qe===Ze?ae.call(t,je?"html":"body")[0]:je?t.documentElement:i},_t=function(e){return re.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},bt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},vt=function(e){return"function"==typeof c&&e instanceof c};function wt(e,t,r){y(e,e=>{e.call(n,t,r,ct)})}const Ct=function(e){let t=null;if(wt(ce.beforeSanitizeElements,e,null),bt(e))return gt(e),!0;const r=lt(e.nodeName);if(wt(ce.uponSanitizeElement,e,{tagName:r,allowedTags:be}),Ie&&e.hasChildNodes()&&!vt(e.firstElementChild)&&k(/<[/\w!]/g,e.innerHTML)&&k(/<[/\w!]/g,e.textContent))return gt(e),!0;if(7===e.nodeType)return gt(e),!0;if(Ie&&8===e.nodeType&&k(/<[/\w]/g,e.data))return gt(e),!0;if(!(Te.tagCheck instanceof Function&&Te.tagCheck(r))&&(!be[r]||xe[r])){if(!xe[r]&&xt(r)){if(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,r))return!1;if(Se.tagNameCheck instanceof Function&&Se.tagNameCheck(r))return!1}if(ze&&!qe[r]){const t=X(e)||e.parentNode,n=V(e)||e.childNodes;if(n&&t)for(let r=n.length-1;r>=0;--r){const s=M(n[r],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,K(e))}}return gt(e),!0}return e instanceof u&&!function(e){let t=X(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});const n=C(e.tagName),r=C(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Xe?t.namespaceURI===Ze?"svg"===n:t.namespaceURI===Ve?"svg"===n&&("annotation-xml"===r||rt[r]):Boolean(pt[n]):e.namespaceURI===Ve?t.namespaceURI===Ze?"math"===n:t.namespaceURI===Xe?"math"===n&&st[r]:Boolean(ft[n]):e.namespaceURI===Ze?!(t.namespaceURI===Xe&&!st[r])&&!(t.namespaceURI===Ve&&!rt[r])&&!ft[n]&&(it[n]||!pt[n]):!("application/xhtml+xml"!==ot||!tt[e.namespaceURI]))}(e)?(gt(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!k(/<\/no(script|embed|frames)/i,e.innerHTML)?(Le&&3===e.nodeType&&(t=e.textContent,y([ue,he,de],e=>{t=E(t,e," ")}),e.textContent!==t&&(v(n.removed,{element:e.cloneNode()}),e.textContent=t)),wt(ce.afterSanitizeElements,e,null),!1):(gt(e),!0)},St=function(e,t,n){if(Ee[t])return!1;if(Fe&&("id"===t||"name"===t)&&(n in r||n in ut))return!1;if(Oe&&!Ee[t]&&k(pe,t));else if(Ae&&k(fe,t));else if(Te.attributeCheck instanceof Function&&Te.attributeCheck(t,e));else if(!we[t]||Ee[t]){if(!(xt(e)&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&k(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t,e))||"is"===t&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&k(Se.tagNameCheck,n)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(n))))return!1}else if(Ye[t]);else if(k(_e,E(n,me,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!Ge[e])if(ke&&!k(ge,E(n,me,"")));else if(n)return!1;return!0},xt=function(e){return"annotation-xml"!==e&&x(e,ye)},Et=function(e){wt(ce.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||bt(e))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0};let s=t.length;for(;s--;){const i=t[s],{name:o,namespaceURI:a,value:l}=i,c=lt(o),u=l;let h="value"===o?u:A(u);if(r.attrName=c,r.attrValue=h,r.keepAttr=!0,r.forceKeepAttr=void 0,wt(ce.uponSanitizeAttribute,e,r),h=r.attrValue,!$e||"id"!==c&&"name"!==c||(mt(o,e),h="user-content-"+h),Ie&&k(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,h)){mt(o,e);continue}if("attributename"===c&&x(h,"href")){mt(o,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){mt(o,e);continue}if(!Pe&&k(/\/>/i,h)){mt(o,e);continue}Le&&y([ue,he,de],e=>{h=E(h,e," ")});const d=lt(e.nodeName);if(St(d,c,h)){if(Z&&"object"==typeof L&&"function"==typeof L.getAttributeType)if(a);else switch(L.getAttributeType(d,c)){case"TrustedHTML":h=Z.createHTML(h);break;case"TrustedScriptURL":h=Z.createScriptURL(h)}if(h!==u)try{a?e.setAttributeNS(a,o,h):e.setAttribute(o,h),bt(e)?gt(e):b(n.removed)}catch(t){mt(o,e)}}else mt(o,e)}wt(ce.afterSanitizeAttributes,e,null)},Tt=function e(t){let n=null;const r=_t(t);for(wt(ce.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)wt(ce.uponSanitizeShadowNode,n,null),Ct(n),Et(n),n.content instanceof o&&e(n.content);wt(ce.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,i=null,a=null,l=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!vt(e)){if("function"!=typeof e.toString)throw P("toString is not a function");if("string"!=typeof(e=e.toString()))throw P("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Me||dt(t),n.removed=[],"string"==typeof e&&(He=!1),He){if(e.nodeName){const t=lt(e.nodeName);if(!be[t]||xe[t])throw P("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)r=yt("\x3c!----\x3e"),i=r.ownerDocument.importNode(e,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?r=i:r.appendChild(i);else{if(!De&&!Le&&!je&&-1===e.indexOf("<"))return Z&&Ue?Z.createHTML(e):e;if(r=yt(e),!r)return De?null:Ue?ee:""}r&&Re&>(r.firstChild);const u=_t(He?e:r);for(;a=u.nextNode();)Ct(a),Et(a),a.content instanceof o&&Tt(a.content);if(He)return e;if(De){if(Ne)for(l=oe.call(r.ownerDocument);r.firstChild;)l.appendChild(r.firstChild);else l=r;return(we.shadowroot||we.shadowrootmode)&&(l=le.call(s,l,!0)),l}let h=je?r.outerHTML:r.innerHTML;return je&&be["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&k(ne,r.ownerDocument.doctype.name)&&(h="<!DOCTYPE "+r.ownerDocument.doctype.name+">\n"+h),Le&&y([ue,he,de],e=>{h=E(h,e," ")}),Z&&Ue?Z.createHTML(h):h},n.setConfig=function(){dt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Me=!0},n.clearConfig=function(){ct=null,Me=!1},n.isValidAttribute=function(e,t,n){ct||dt({});const r=lt(e),s=lt(t);return St(r,s,n)},n.addHook=function(e,t){"function"==typeof t&&v(ce[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=_(ce[e],t);return-1===n?void 0:w(ce[e],n,1)[0]}return b(ce[e])},n.removeHooks=function(e){ce[e]=[]},n.removeAllHooks=function(){ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}(),ae=n(744),le=n.n(ae);const ce=/([\p{Ll}\d])(\p{Lu})/gu,ue=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,he=/(\d)\p{Ll}|(\p{L})\d/u,de=/[^\p{L}\d]+/giu,pe="$1\0$2";function fe(e){let t=e.trim();t=t.replace(ce,pe).replace(ue,pe),t=t.replace(de,"\0");let n=0,r=t.length;for(;"\0"===t.charAt(n);)n++;if(n===r)return[];for(;"\0"===t.charAt(r-1);)r--;return t.slice(n,r).split(/\0/g)}function ge(e){const t=fe(e);for(let e=0;e<t.length;e++){const n=t[e],r=he.exec(n);if(r){const s=r.index+(r[1]??r[2]).length;t.splice(e,1,n.slice(0,s),n.slice(s))}}return t}function me(e,t){const[n,r,s]=function(e,t={}){const n=t.split??(t.separateNumbers?ge:fe),r=t.prefixCharacters??"",s=t.suffixCharacters??"";let i=0,o=e.length;for(;i<e.length;){const t=e.charAt(i);if(!r.includes(t))break;i++}for(;o>i;){const t=o-1,n=e.charAt(t);if(!s.includes(n))break;o=t}return[e.slice(0,i),n(e.slice(i,o)),e.slice(o)]}(e,t);return n+r.map((i=t?.locale,!1===i?e=>e.toLowerCase():e=>e.toLocaleLowerCase(i))).join(t?.delimiter??" ")+s;var i}function ye(e){this?.sdk&&e&&(this.sdk=Object.assign({},this.sdk,e))}const _e="win32"===navigator.platform.toLowerCase()?o.win32:o.posix,be=!1,ve="file://",we="lsp://",Ce=we+"logseq.io/";let Se;const xe=function(e,t){return me(e,{delimiter:"_",...t})};async function Ee(){return Se||(Se=await Ne("_callApplication","getAppPath"))}async function Te(){return be?localStorage.getItem("LSP_DEV_SDK_ROOT")||"http://localhost:8080":Me(await Ee(),"js")}function Ae(e){return e===Object(e)&&!Array.isArray(e)}function Oe(e,t){return le()(e,t,{arrayMerge:(e,t)=>t})}class ke extends i{_tag;_opts;_logs=[];constructor(e,t){super(),this._tag=e,this._opts=t}write(e,t,n){t?.length&&!0===t[t.length-1]&&(n=!0,t.pop());const r=t.reduce((e,t)=>(t&&t instanceof Error?e+=`${t.message} ${t.stack}`:e+=t.toString(),e),`[${this._tag}][${(new Date).toLocaleTimeString()}] `);this._logs.push([e,r]),(n||this._opts?.console)&&console?.["ERROR"===e?"error":"debug"](`${e}: ${r}`),this.emit("change")}clear(){this._logs=[],this.emit("change")}info(...e){this.write("INFO",e)}error(...e){this.write("ERROR",e)}warn(...e){this.write("WARN",e)}setTag(e){this._tag=e}toJSON(){return this._logs}}function Pe(e){return"string"==typeof e&&36===e.length&&/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(e)}function Le(){return"_"+Math.random().toString(36).substr(2,9)}function Ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function je(e){return e?(/^(http|file|lsp)/.test(e)||(e=ve+e),e):""}function Me(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=_e.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return _e.join(e,...t)}}function Re(e){return e?.match(/^(http?|lsp|assets):/)||(e=_e.normalize(e)),e}function De(e,t){let n,r,s=!1;const i=t=>n=>{e&&clearTimeout(e),t(n),s=!0},o=new Promise((s,o)=>{n=i(s),r=i(o),e&&(e=setTimeout(()=>r(new Error(`[deferred timeout] ${t}`)),e))});return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:r,promise:o,get settled(){return s}}}function Ne(t,...n){t=t?.startsWith("_call")?t:t?.replace(/^[_$]+/,"");let r=xe(t);const s=window.logseq?.sdk,i=s&&Object.keys(s);let o={};const a=r?.split("_")?.[0];a&&i.includes(a)&&(r=r.replace(new RegExp(`^${a}_`),""),o=s?.[a]);const l=Object.assign({},window.logseq?.api,o,e),c=l[r]||window.apis[r]||l[t]||window.apis[t];if(!c)throw new Error(`Not existed method #${t}`);return"function"!=typeof c?c:c.apply(this,n)}function Ue(e,t){const n=t["data-injected-style"];let r=n&&document.querySelector(`[data-injected-style=${n}]`);if(!r)return r=document.createElement("style"),r.textContent=e,t&&Object.entries(t).forEach(([e,t])=>{r.setAttribute(e,t)}),document.head.append(r),()=>{document.head.removeChild(r)};r.textContent=e}const Fe=new Map;function $e(e,t,n){let r,s,i="";const o=this;"slot"in e?(i=e.slot,r=`#${i}`):"path"in e?r=e.path:s=!0;const a=`${o.id}--${e.key||Le()}`,l=a,c=s?document.body:r&&document.querySelector(r);if(!c)return console.error(`${this.debugTag} can not resolve selector target ${r}`),!1;if(!e.template)return void Fe.get(a)?.call(null);e.template=oe.sanitize(e.template,{ADD_TAGS:["iframe"],ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_ATTR:["allow","src","allowfullscreen","frameborder","scrolling","target"]});let u,h,d=document.querySelector(`#${a}`),p=s?d?.querySelector(".ls-ui-float-content"):d;if(p){p.innerHTML=e.template,t&&Object.entries(t).forEach(([e,t])=>{d.setAttribute(e,t)});let n=null!=d.dataset.dx;return void(e.style&&Object.entries(e.style).forEach(([e,t])=>{n&&["left","top","bottom","right","width","height"].includes(e)||(d.style[e]=t)}))}if(d=document.createElement("div"),d.id=a,d.dataset.injectedUi=l||"",s?(p=document.createElement("div"),p.classList.add("ls-ui-float-content"),d.appendChild(p)):p=d,p.innerHTML=e.template,t&&Object.entries(t).forEach(([e,t])=>{d.setAttribute(e,t)}),e.style&&Object.entries(e.style).forEach(([e,t])=>{d.style[e]=t}),s&&(d.setAttribute("draggable","true"),d.setAttribute("resizable","true"),e.close&&(d.dataset.close=e.close),d.classList.add("lsp-ui-float-container","visible"),o._setupResizableContainer(d,l),h=o._setupDraggableContainer(d,{key:l,close:()=>u(),title:t?.title})),i&&e.reset){const e=Array.from(c.querySelectorAll("[data-injected-ui]")).map(e=>e.id);e?.forEach(e=>{Fe.get(e)?.call(null)})}return c.appendChild(d),["click","focus","focusin","focusout","blur","dblclick","keyup","keypress","keydown","change","input","contextmenu"].forEach(e=>{d.addEventListener(e,t=>{const n=t.target.closest(`[data-on-${e}]`);if(!n)return;const{preventDefault:r}=n.dataset,s=n.dataset[`on${Ie(e)}`];s&&o.caller?.callUserModel(s,We(n,t)),"true"===r?.toLowerCase()&&t.preventDefault()},!1)}),n?.({el:d,float:s}),u=()=>{h?.(),Fe.delete(a),c.removeChild(d)},Fe.set(a,u),u}function ze(e){if(!Fe.has(e))return;const t=Fe.get(e);try{t()}catch(t){console.warn("[CLEAN Injected UI] ",e,t)}}function He(){const e=document.head.querySelectorAll(`script[data-ref=${this.id}]`);e?.forEach(e=>e.remove())}function We(e,t){const n={};if(e){n.type=t.type;const r=e.dataset,s="rect";["value","id","className","dataset",s].forEach(t=>{let i;if(t===s){if(!r.hasOwnProperty(s))return;i=e.getBoundingClientRect().toJSON()}else i=e[t];"object"==typeof i&&(i={...i}),n[t]=i})}return n}function qe(e){const t=document.createElement("link");return t.rel="stylesheet",t.href=e,document.head.appendChild(t),()=>{try{document.head.removeChild(t)}catch(e){console.error(e)}}}function Be(e,t){const n=(t||[]).reduce((e,t)=>("default"in t&&(e[t.key]=t.default),e),{});return Object.assign(n,e)}function Ge(e){if("string"==typeof e)return e.trim().replace(/\s/g,"_").toLowerCase()}window.__injectedUIEffects=Fe;var Je=n(833),Ye=n.n(Je);const Ke="application/x-postmate-v1+json";let Ve=0;const Xe={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},Ze=(e,t)=>!("string"==typeof t&&"*"!==t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==Ke||!Xe[e.data.postmate]);class Qe{parent;frame;child;events={};childOrigin;listener;messagePort;addTransportListener(e){this.messagePort?(console.debug("[DEBUG] Using MessagePort for communication:",this.frame.src),this.messagePort.addEventListener("message",e),this.messagePort.start?.()):(console.debug("[DEBUG] Using postMessage for communication:",this.frame.src),this.parent.addEventListener("message",e,!1))}removeTransportListener(e){this.messagePort?this.messagePort.removeEventListener("message",e):this.parent.removeEventListener("message",e,!1)}postToChild(e){this.messagePort?this.messagePort.postMessage(e):this.child.postMessage(e,this.childOrigin)}constructor(e){this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.messagePort=e.messagePort,this.listener=e=>{if(this.messagePort){if(!e?.data)return!1;if("object"==typeof e.data&&!("postmate"in e.data))return!1;if(e.data.type!==Ke)return!1;if(!Xe[e.data.postmate])return!1}else if(!Ze(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.addTransportListener(this.listener)}get(e,...t){return new Promise((n,r)=>{const s=++Ve,i="number"==typeof tt.requestTimeout?tt.requestTimeout:1e4;let o;const a=e=>{e?.data?.uid===s&&"reply"===e.data.postmate&&(this.removeTransportListener(a),o&&clearTimeout(o),e.data.error?r(e.data.error):n(e.data.value))};this.addTransportListener(a),i>0&&(o=setTimeout(()=>{this.removeTransportListener(a),r(new Error(`Postmate: request timeout (${i}ms)`))},i)),this.postToChild({postmate:"request",type:Ke,property:e,args:t,uid:s})})}call(e,t){this.postToChild({postmate:"call",type:Ke,property:e,data:t})}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}destroy(){this.removeTransportListener(this.listener);try{this.messagePort?.close()}catch(e){}this.frame.parentNode.removeChild(this.frame)}}class et{model;parent;parentOrigin;child;messagePort;listener;addTransportListener(e){this.messagePort?(this.messagePort.addEventListener("message",e),this.messagePort.start?.()):this.child.addEventListener("message",e,!1)}postToParent(e,t){if(this.messagePort)this.messagePort.postMessage(e);else if(t?.source){const n="null"===t.origin?"*":t.origin;t.source.postMessage(e,n)}else this.parent.postMessage(e,this.parentOrigin)}constructor(e){if(this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.messagePort=e.messagePort,this.listener=e=>{if(this.messagePort){if(!e?.data)return;if("object"==typeof e.data&&!("postmate"in e.data))return;if(e.data.type!==Ke)return;if(!Xe[e.data.postmate])return}else if(!Ze(e,this.parentOrigin))return;const{property:t,uid:n,data:r,args:s}=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,s).then(r=>{this.postToParent({property:t,postmate:"reply",type:Ke,uid:n,value:r},e)}).catch(r=>{this.postToParent({property:t,postmate:"reply",type:Ke,uid:n,error:r},e)}):t in this.model&&"function"==typeof this.model[t]&&this.model[t](r)},this.addTransportListener(this.listener),!this.messagePort){const e=t=>{const n=t.detail?.port;n&&(this.child.removeEventListener("message",this.listener,!1),this.messagePort=n,this.messagePort.addEventListener("message",this.listener),this.messagePort.start?.(),this.child.removeEventListener("postmate:channel-ready",e))};this.child.addEventListener("postmate:channel-ready",e)}}emit(e,t){this.postToParent({postmate:"emit",type:Ke,value:{name:e,data:t}})}}class tt{static debug=!1;static requestTimeout=1e4;container;parent;frame;child;childOrigin;url;model;static Model;messagePort;enableMessageChannel;constructor(e){this.container=e.container,this.url=e.url,this.parent=window,this.frame=document.createElement("iframe"),e.id&&(this.frame.id=e.id),e.name&&(this.frame.name=e.name),e.allow&&(this.frame.allow=e.allow),this.frame.classList.add.apply(this.frame.classList,e.classListArray||[]),this.container.appendChild(this.frame),this.child=this.frame.contentWindow,this.model=e.model||{},this.enableMessageChannel=!!e.enableMessageChannel}sendHandshake(e){const t=(e=>{const t=document.createElement("a");if(t.href=e,"file:"===t.protocol)return"*";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((s,i)=>{const o="undefined"!=typeof MessageChannel&&"function"==typeof MessageChannel,a=this.enableMessageChannel&&o,l=e=>{if(!Ze(e,t))return!1;if("handshake-reply"===e.data.postmate){if(clearInterval(n),this.parent.removeEventListener("message",l,!1),this.childOrigin=e.origin,a)if(e?.ports?.length){const t=e.ports[0];t&&(this.messagePort=t,this.messagePort.start?.())}else if(e.data.acceptsMessageChannel){const e=new MessageChannel;this.messagePort=e.port1,this.messagePort.start?.(),this.child.postMessage({postmate:"setup-channel",type:Ke},t,[e.port2])}return s(new Qe(this))}return i("Failed handshake")};this.parent.addEventListener("message",l,!1);const c=()=>{r++;const e={postmate:"handshake",type:Ke,model:this.model,enableMessageChannel:a?1:0};this.child.postMessage(e,t),5===r&&clearInterval(n)};this.frame.addEventListener("load",()=>{c(),n=setInterval(c,500)}),this.frame.src=e})}destroy(){try{this.messagePort?.close()}catch(e){}this.frame.parentNode.removeChild(this.frame)}}class nt{child;model;parent;parentOrigin;messagePort;enableMessageChannel;constructor(e){this.child=window,this.model=e,this.parent=this.child.parent,this.enableMessageChannel=!1}sendHandshakeReply(){return new Promise((e,t)=>{const n=r=>{if(r.data.postmate){if("handshake"===r.data.postmate){this.child.removeEventListener("message",n,!1),this.enableMessageChannel=!!r.data?.enableMessageChannel,this.parentOrigin=r.origin;const t="undefined"!=typeof MessageChannel&&"function"==typeof MessageChannel;r.source.postMessage({postmate:"handshake-reply",type:Ke,acceptsMessageChannel:this.enableMessageChannel&&t?1:0},"null"===r.origin?"*":r.origin);const s=r.data.model;if(s&&Object.keys(s).forEach(e=>{this.model[e]=s[e]}),this.enableMessageChannel&&t){const e=t=>{if("setup-channel"===t.data?.postmate&&t.data?.type===Ke&&t.origin===this.parentOrigin){const n=t?.ports?.[0];n&&(this.messagePort=n,this.messagePort.start?.(),this.child.dispatchEvent(new CustomEvent("postmate:channel-ready",{detail:{port:this.messagePort}}))),this.child.removeEventListener("message",e,!1)}};this.child.addEventListener("message",e,!1)}return e(new et(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)})}}class rt{ctx;opts;constructor(e,t){this.ctx=e,this.opts=t}get ctxId(){return this.ctx.baseInfo.id}setItem(e,t){return this.ctx.caller.callAsync("api:call",{method:"write-plugin-storage-file",args:[this.ctxId,e,t,this.opts?.assets]})}getItem(e){return this.ctx.caller.callAsync("api:call",{method:"read-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}removeItem(e){return this.ctx.caller.call("api:call",{method:"unlink-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}allKeys(){return this.ctx.caller.callAsync("api:call",{method:"list-plugin-storage-files",args:[this.ctxId,this.opts?.assets]})}clear(){return this.ctx.caller.call("api:call",{method:"clear-plugin-storage-files",args:[this.ctxId,this.opts?.assets]})}hasItem(e){return this.ctx.caller.callAsync("api:call",{method:"exist-plugin-storage-file",args:[this.ctxId,e,this.opts?.assets]})}}class st{ctx;constructor(e){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 Utils(){const e=this.ensureHostScope().logseq.sdk.utils,t=t=>e[xe(t)];return{toClj:t("toClj"),jsxToClj:t("jsxToClj"),toJs:t("toJs"),toKeyword:t("toKeyword"),toSymbol:t("toSymbol")}}get pluginLocal(){return this.ensureHostScope().LSPluginCore.ensurePlugin(this.ctx.baseInfo.id)}invokeExperMethod(e,...t){const n=this.ensureHostScope();e=xe(e)?.toLowerCase();const r=n.logseq.api["exper_"+e]||n.logseq.sdk.experiments[e];return r?.apply(n,t)}async loadScripts(...e){(e=e.map(e=>e?.startsWith("http")?e:this.ctx.resolveResourceFullUrl(e))).unshift(this.ctx.baseInfo.id),await this.invokeExperMethod("loadScripts",...e)}registerFencedCodeRenderer(e,t){return this.invokeExperMethod("registerFencedCodeRenderer",this.ctx.baseInfo.id,e,t)}registerDaemonRenderer(e,t){return this.invokeExperMethod("registerDaemonRenderer",this.ctx.baseInfo.id,e,t)}registerHostedRenderer(e,t){return this.invokeExperMethod("registerHostedRenderer",this.ctx.baseInfo.id,e,t)}registerSidebarRenderer(e,t){return e=`_sidebar.${e}`,t.type="sidebar",this.registerHostedRenderer(e,t)}registerRouteRenderer(e,t){return this.invokeExperMethod("registerRouteRenderer",this.ctx.baseInfo.id,e,t)}registerExtensionsEnhancer(e,t){const n=this.ensureHostScope();return"katex"===e&&n.katex&&t(n.katex).catch(console.error),this.invokeExperMethod("registerExtensionsEnhancer",this.ctx.baseInfo.id,e,t)}ensureHostScope(){try{window.top}catch(e){console.error("Can not access host scope!")}return window.top}}const it=e=>`task_callback_${e}`;class ot{_client;_requestId;_requestOptions;_promise;_aborted=!1;constructor(e,t,n={}){this._client=e,this._requestId=t,this._requestOptions=n,this._promise=new Promise((e,t)=>{if(!this._requestId)return t(null);this._client.once(it(this._requestId),n=>{n&&n instanceof Error?t(n):e(n)})});const{success:r,fail:s,final:i}=this._requestOptions;this._promise.then(e=>{r?.(e)}).catch(e=>{s?.(e)}).finally(()=>{i?.()})}abort(){this._requestOptions.abortable&&!this._aborted&&(this._client.ctx._execCallableAPI("http_request_abort",this._requestId),this._aborted=!0)}get promise(){return this._promise}get client(){return this._client}get requestId(){return this._requestId}}class at extends s{_ctx;constructor(e){super(),this._ctx=e,this.ctx.caller.on("#lsp#request#callback",e=>{const t=e?.requestId;t&&this.emit(it(t),e?.payload)})}static createRequestTask(e,t,n){return new ot(e,t,n)}async _request(e){const t=this.ctx.baseInfo.id,{success:n,fail:r,final:s,...i}=e,o=this.ctx.Experiments.invokeExperMethod("request",t,i),a=at.createRequestTask(this.ctx.Request,o,e);return i.abortable?a:a.promise}get ctx(){return this._ctx}}const lt=Array.isArray,ct="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;var ut="object"==typeof self&&self&&self.Object===Object&&self;const ht=ct||ut||Function("return this")(),dt=ht.Symbol;var pt=Object.prototype,ft=pt.hasOwnProperty,gt=pt.toString,mt=dt?dt.toStringTag:void 0;var yt=Object.prototype.toString;var _t=dt?dt.toStringTag:void 0;const bt=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":_t&&_t in Object(e)?function(e){var t=ft.call(e,mt),n=e[mt];try{e[mt]=void 0;var r=!0}catch(e){}var s=gt.call(e);return r&&(t?e[mt]=n:delete e[mt]),s}(e):function(e){return yt.call(e)}(e)},vt=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},wt=function(e){if(!vt(e))return!1;var t=bt(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},Ct=ht["__core-js_shared__"];var St,xt=(St=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||""))?"Symbol(src)_1."+St:"";var Et=Function.prototype.toString;const Tt=function(e){if(null!=e){try{return Et.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var At=/^\[object .+?Constructor\]$/,Ot=Function.prototype,kt=Object.prototype,Pt=Ot.toString,Lt=kt.hasOwnProperty,It=RegExp("^"+Pt.call(Lt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const jt=function(e){return!(!vt(e)||(t=e,xt&&xt in t))&&(wt(e)?It:At).test(Tt(e));var t},Mt=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return jt(n)?n:void 0},Rt=function(){try{var e=Mt(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Dt=function(e,t,n){for(var r=-1,s=Object(e),i=n(e),o=i.length;o--;){var a=i[++r];if(!1===t(s[a],a,s))break}return e},Nt=function(e){return null!=e&&"object"==typeof e},Ut=function(e){return Nt(e)&&"[object Arguments]"==bt(e)};var Ft=Object.prototype,$t=Ft.hasOwnProperty,zt=Ft.propertyIsEnumerable;const Ht=Ut(function(){return arguments}())?Ut:function(e){return Nt(e)&&$t.call(e,"callee")&&!zt.call(e,"callee")};var Wt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Wt&&"object"==typeof module&&module&&!module.nodeType&&module,Bt=qt&&qt.exports===Wt?ht.Buffer:void 0;const Gt=(Bt?Bt.isBuffer:void 0)||function(){return!1};var Jt=/^(?:0|[1-9]\d*)$/;const Yt=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Jt.test(e))&&e>-1&&e%1==0&&e<t},Kt=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var Vt={};Vt["[object Float32Array]"]=Vt["[object Float64Array]"]=Vt["[object Int8Array]"]=Vt["[object Int16Array]"]=Vt["[object Int32Array]"]=Vt["[object Uint8Array]"]=Vt["[object Uint8ClampedArray]"]=Vt["[object Uint16Array]"]=Vt["[object Uint32Array]"]=!0,Vt["[object Arguments]"]=Vt["[object Array]"]=Vt["[object ArrayBuffer]"]=Vt["[object Boolean]"]=Vt["[object DataView]"]=Vt["[object Date]"]=Vt["[object Error]"]=Vt["[object Function]"]=Vt["[object Map]"]=Vt["[object Number]"]=Vt["[object Object]"]=Vt["[object RegExp]"]=Vt["[object Set]"]=Vt["[object String]"]=Vt["[object WeakMap]"]=!1;var Xt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=Xt&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=Zt&&Zt.exports===Xt&&ct.process,en=function(){try{return Zt&&Zt.require&&Zt.require("util").types||Qt&&Qt.binding&&Qt.binding("util")}catch(e){}}(),tn=en&&en.isTypedArray;const nn=tn?(rn=tn,function(e){return rn(e)}):function(e){return Nt(e)&&Kt(e.length)&&!!Vt[bt(e)]};var rn,sn=Object.prototype.hasOwnProperty;const on=function(e,t){var n=lt(e),r=!n&&Ht(e),s=!n&&!r&&Gt(e),i=!n&&!r&&!s&&nn(e),o=n||r||s||i,a=o?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],l=a.length;for(var c in e)!t&&!sn.call(e,c)||o&&("length"==c||s&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Yt(c,l))||a.push(c);return a};var an=Object.prototype;const ln=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object);var cn=Object.prototype.hasOwnProperty;const un=function(e){if(n=(t=e)&&t.constructor,t!==("function"==typeof n&&n.prototype||an))return ln(e);var t,n,r=[];for(var s in Object(e))cn.call(e,s)&&"constructor"!=s&&r.push(s);return r},hn=function(e){return null!=(t=e)&&Kt(t.length)&&!wt(t)?on(e):un(e);var t},dn=function(e,t){return e===t||e!=e&&t!=t},pn=function(e,t){for(var n=e.length;n--;)if(dn(e[n][0],t))return n;return-1};var fn=Array.prototype.splice;function gn(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])}}gn.prototype.clear=function(){this.__data__=[],this.size=0},gn.prototype.delete=function(e){var t=this.__data__,n=pn(t,e);return!(n<0||(n==t.length-1?t.pop():fn.call(t,n,1),--this.size,0))},gn.prototype.get=function(e){var t=this.__data__,n=pn(t,e);return n<0?void 0:t[n][1]},gn.prototype.has=function(e){return pn(this.__data__,e)>-1},gn.prototype.set=function(e,t){var n=this.__data__,r=pn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const mn=gn,yn=Mt(ht,"Map"),_n=Mt(Object,"create");var bn=Object.prototype.hasOwnProperty;var vn=Object.prototype.hasOwnProperty;function wn(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])}}wn.prototype.clear=function(){this.__data__=_n?_n(null):{},this.size=0},wn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},wn.prototype.get=function(e){var t=this.__data__;if(_n){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return bn.call(t,e)?t[e]:void 0},wn.prototype.has=function(e){var t=this.__data__;return _n?void 0!==t[e]:vn.call(t,e)},wn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=_n&&void 0===t?"__lodash_hash_undefined__":t,this};const Cn=wn,Sn=function(e,t){var n,r,s=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?s["string"==typeof t?"string":"hash"]:s.map};function xn(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])}}xn.prototype.clear=function(){this.size=0,this.__data__={hash:new Cn,map:new(yn||mn),string:new Cn}},xn.prototype.delete=function(e){var t=Sn(this,e).delete(e);return this.size-=t?1:0,t},xn.prototype.get=function(e){return Sn(this,e).get(e)},xn.prototype.has=function(e){return Sn(this,e).has(e)},xn.prototype.set=function(e,t){var n=Sn(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const En=xn;function Tn(e){var t=this.__data__=new mn(e);this.size=t.size}Tn.prototype.clear=function(){this.__data__=new mn,this.size=0},Tn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Tn.prototype.get=function(e){return this.__data__.get(e)},Tn.prototype.has=function(e){return this.__data__.has(e)},Tn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof mn){var r=n.__data__;if(!yn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new En(r)}return n.set(e,t),this.size=n.size,this};const An=Tn;function On(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new En;++t<n;)this.add(e[t])}On.prototype.add=On.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},On.prototype.has=function(e){return this.__data__.has(e)};const kn=On,Pn=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},Ln=function(e,t,n,r,s,i){var o=1&n,a=e.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=i.get(e),u=i.get(t);if(c&&u)return c==t&&u==e;var h=-1,d=!0,p=2&n?new kn:void 0;for(i.set(e,t),i.set(t,e);++h<a;){var f=e[h],g=t[h];if(r)var m=o?r(g,f,h,t,e,i):r(f,g,h,e,t,i);if(void 0!==m){if(m)continue;d=!1;break}if(p){if(!Pn(t,function(e,t){if(o=t,!p.has(o)&&(f===e||s(f,e,n,r,i)))return p.push(t);var o})){d=!1;break}}else if(f!==g&&!s(f,g,n,r,i)){d=!1;break}}return i.delete(e),i.delete(t),d},In=ht.Uint8Array,jn=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n},Mn=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n};var Rn=dt?dt.prototype:void 0,Dn=Rn?Rn.valueOf:void 0;var Nn=Object.prototype.propertyIsEnumerable,Un=Object.getOwnPropertySymbols;const Fn=Un?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,s=0,i=[];++n<r;){var o=e[n];t(o,n,e)&&(i[s++]=o)}return i}(Un(e),function(t){return Nn.call(e,t)}))}:function(){return[]},$n=function(e){return function(e,t,n){var r=t(e);return lt(e)?r:function(e,t){for(var n=-1,r=t.length,s=e.length;++n<r;)e[s+n]=t[n];return e}(r,n(e))}(e,hn,Fn)};var zn=Object.prototype.hasOwnProperty;const Hn=Mt(ht,"DataView"),Wn=Mt(ht,"Promise"),qn=Mt(ht,"Set"),Bn=Mt(ht,"WeakMap");var Gn="[object Map]",Jn="[object Promise]",Yn="[object Set]",Kn="[object WeakMap]",Vn="[object DataView]",Xn=Tt(Hn),Zn=Tt(yn),Qn=Tt(Wn),er=Tt(qn),tr=Tt(Bn),nr=bt;(Hn&&nr(new Hn(new ArrayBuffer(1)))!=Vn||yn&&nr(new yn)!=Gn||Wn&&nr(Wn.resolve())!=Jn||qn&&nr(new qn)!=Yn||Bn&&nr(new Bn)!=Kn)&&(nr=function(e){var t=bt(e),n="[object Object]"==t?e.constructor:void 0,r=n?Tt(n):"";if(r)switch(r){case Xn:return Vn;case Zn:return Gn;case Qn:return Jn;case er:return Yn;case tr:return Kn}return t});const rr=nr;var sr="[object Arguments]",ir="[object Array]",or="[object Object]",ar=Object.prototype.hasOwnProperty;const lr=function(e,t,n,r,s,i){var o=lt(e),a=lt(t),l=o?ir:rr(e),c=a?ir:rr(t),u=(l=l==sr?or:l)==or,h=(c=c==sr?or:c)==or,d=l==c;if(d&&Gt(e)){if(!Gt(t))return!1;o=!0,u=!1}if(d&&!u)return i||(i=new An),o||nn(e)?Ln(e,t,n,r,s,i):function(e,t,n,r,s,i,o){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 In(e),new In(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return dn(+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=jn;case"[object Set]":var l=1&r;if(a||(a=Mn),e.size!=t.size&&!l)return!1;var c=o.get(e);if(c)return c==t;r|=2,o.set(e,t);var u=Ln(a(e),a(t),r,s,i,o);return o.delete(e),u;case"[object Symbol]":if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,l,n,r,s,i);if(!(1&n)){var p=u&&ar.call(e,"__wrapped__"),f=h&&ar.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return i||(i=new An),s(g,m,n,r,i)}}return!!d&&(i||(i=new An),function(e,t,n,r,s,i){var o=1&n,a=$n(e),l=a.length;if(l!=$n(t).length&&!o)return!1;for(var c=l;c--;){var u=a[c];if(!(o?u in t:zn.call(t,u)))return!1}var h=i.get(e),d=i.get(t);if(h&&d)return h==t&&d==e;var p=!0;i.set(e,t),i.set(t,e);for(var f=o;++c<l;){var g=e[u=a[c]],m=t[u];if(r)var y=o?r(m,g,u,t,e,i):r(g,m,u,e,t,i);if(!(void 0===y?g===m||s(g,m,n,r,i):y)){p=!1;break}f||(f="constructor"==u)}if(p&&!f){var _=e.constructor,b=t.constructor;_==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b||(p=!1)}return i.delete(e),i.delete(t),p}(e,t,n,r,s,i))},cr=function e(t,n,r,s,i){return t===n||(null==t||null==n||!Nt(t)&&!Nt(n)?t!=t&&n!=n:lr(t,n,r,s,e,i))},ur=function(e){return e==e&&!vt(e)},hr=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}},dr=function(e){var t=function(e){for(var t=hn(e),n=t.length;n--;){var r=t[n],s=e[r];t[n]=[r,s,ur(s)]}return t}(e);return 1==t.length&&t[0][2]?hr(t[0][0],t[0][1]):function(n){return n===e||function(e,t,n,r){var s=n.length,i=s,o=!r;if(null==e)return!i;for(e=Object(e);s--;){var a=n[s];if(o&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++s<i;){var l=(a=n[s])[0],c=e[l],u=a[1];if(o&&a[2]){if(void 0===c&&!(l in e))return!1}else{var h=new An;if(r)var d=r(c,u,l,e,t,h);if(!(void 0===d?cr(u,c,3,r,h):d))return!1}}return!0}(n,e,t)}},pr=function(e){return"symbol"==typeof e||Nt(e)&&"[object Symbol]"==bt(e)};var fr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gr=/^\w*$/;const mr=function(e,t){if(lt(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!pr(e))||gr.test(e)||!fr.test(e)||null!=t&&e in Object(t)};function yr(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(yr.Cache||En),n}yr.Cache=En;var _r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,br=/\\(\\)?/g;const vr=(wr=yr(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(_r,function(e,n,r,s){t.push(r?s.replace(br,"$1"):n||e)}),t},function(e){return 500===Cr.size&&Cr.clear(),e}),Cr=wr.cache,wr);var wr,Cr;var Sr=dt?dt.prototype:void 0,xr=Sr?Sr.toString:void 0;const Er=function e(t){if("string"==typeof t)return t;if(lt(t))return function(e,t){for(var n=-1,r=null==e?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}(t,e)+"";if(pr(t))return xr?xr.call(t):"";var n=t+"";return"0"==n&&1/t==-1/0?"-0":n},Tr=function(e,t){return lt(e)?e:mr(e,t)?[e]:vr(function(e){return null==e?"":Er(e)}(e))},Ar=function(e){if("string"==typeof e||pr(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t},Or=function(e,t){for(var n=0,r=(t=Tr(t,e)).length;null!=e&&n<r;)e=e[Ar(t[n++])];return n&&n==r?e:void 0},kr=function(e,t){return null!=e&&t in Object(e)},Pr=function(e,t){return null!=e&&function(e,t,n){for(var r=-1,s=(t=Tr(t,e)).length,i=!1;++r<s;){var o=Ar(t[r]);if(!(i=null!=e&&n(e,o)))break;e=e[o]}return i||++r!=s?i:!!(s=null==e?0:e.length)&&Kt(s)&&Yt(o,s)&&(lt(e)||Ht(e))}(e,t,kr)},Lr=function(e,t){return mr(e)&&ur(t)?hr(Ar(e),t):function(n){var r=function(e,t,n){var r=null==e?void 0:Or(e,t);return void 0===r?n:r}(n,e);return void 0===r&&r===t?Pr(n,e):cr(t,r,3)}},Ir=function(e){return e},jr=function(e){return mr(e)?(t=Ar(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Or(t,e)}}(e);var t},Mr=function(e,t){var n,r={};return t="function"==typeof(n=t)?n:null==n?Ir:"object"==typeof n?lt(n)?Lr(n[0],n[1]):dr(n):jr(n),function(e,t){e&&Dt(e,t,hn)}(e,function(e,n,s){!function(e,t,n){"__proto__"==t&&Rt?Rt(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}(r,t(e,n,s),e)}),r};class Rr{ctx;serviceHooks;constructor(e,t){this.ctx=e,this.serviceHooks=t,e._execCallableAPI("register-search-service",e.baseInfo.id,t.name,t.options),Object.entries({query:{f:"onQuery",args:["graph","q",!0],reply:!0,transformOutput:e=>(lt(e?.blocks)&&(e.blocks=e.blocks.map(e=>e&&Mr(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 s=(e=>`service:search:${e}:${t.name}`)(n);e.caller.on(s,async n=>{if(wt(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(`${s}:reply`,i)}}})})}}const Dr=Symbol.for("proxy-continue"),Nr=Ye()("LSPlugin:user"),Ur=new ke("",{console:!0});function Fr(e,t,n){const{key:r,label:s,desc:i,palette:o,keybinding:a,extras:l}=t;if("function"!=typeof n)return this.logger.error(`${r||s}: command action should be function.`),!1;const c=Ge(r);if(!c)return this.logger.error(`${s}: command key is required.`),!1;const u=`SimpleCommandHook${c}${++qr}`;this.Editor["on"+u](n),this.caller?.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:c,label:s,type:e,desc:i,keybinding:a,extras:l},["editor/hook",u]],o]})}function $r(e){return!!Pe(e)||(Ur.error(`#${e} is not a valid UUID string.`),!1)}let zr=null,Hr=new Map;const Wr={async getInfo(e){return zr||(zr=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?zr[e]:zr},registerCommand:Fr,registerSearchService(e){if(Hr.has(e.name))throw new Error(`SearchService: #${e.name} has registered!`);Hr.set(e.name,new Rr(this,e))},registerCommandPalette(e,t){const{key:n,label:r,keybinding:s}=e;return Fr.call(this,"$palette$",{key:n,label:r,palette:!0,keybinding:s},t)},registerCommandShortcut(e,t,n={}){"string"==typeof e&&(e={mode:"global",binding:e});const{binding:r}=e,s="$shortcut$",i=n.key||s+xe(r?.toString());return Fr.call(this,s,{...n,key:i,palette:!1,keybinding:e},t)},registerUIItem(e,t){const n=this.baseInfo.id;this.caller?.call("api:call",{method:"register-plugin-ui-item",args:[n,e,t]})},registerPageMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;Fr.call(this,"page-menu-item",{key:n,label:r},t)},onBlockRendererSlotted(e,t){if(!$r(e))return;const n=this.baseInfo.id,r=`hook:editor:${xe(`slot:${e}`)}`;return this.caller.on(r,t),this.App._installPluginHook(n,r),()=>{this.caller.off(r,t),this.App._uninstallPluginHook(n,r)}},invokeExternalPlugin(e,...t){if(e=e?.trim(),!e)return;let[n,r]=e.split(".");if(!["models","commands"].includes(r?.toLowerCase()))throw new Error("Type only support '.models' or '.commands' currently.");const s=e.replace(`${n}.${r}.`,"");if(!n||!r||!s)throw new Error(`Illegal type of #${e} to invoke external plugin.`);return this._execCallableAPIAsync("invoke_external_plugin_cmd",n,r.toLowerCase(),s,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 qr=0;const Br={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},isPageBlock:e=>e.uuid&&e.hasOwnProperty("name"),registerSlashCommand(e,t){Nr("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],s=()=>{this.caller?.callUserModel(r)};"function"==typeof r&&(s=r);const i=`SlashCommandHook${t}${++qr}`;e[1]=i,this.Editor["on"+i](s)}return e}),this.caller?.call("api:call",{method:"register-plugin-slash-command",args:[this.baseInfo.id,[e,t]]})},registerBlockContextMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id;Fr.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;Fr.call(this,"highlight-context-menu-item",{key:r,label:e,extras:n},t)},scrollToBlockInPage(e,t,n){const r="block-content-"+t;n?.replaceState?this.App.replaceState("page",{name:e},{anchor:r}):this.App.pushState("page",{name:e},{anchor:r})}},Gr={onBlockChanged(e,t){if(!$r(e))return;const n=this.baseInfo.id,r=`hook:db:${xe(`block:${e}`)}`,s=({block:n,txData:r,txMeta:s})=>{n.uuid===e&&t(n,r,s)};return this.caller.on(r,s),this.App._installPluginHook(n,r),()=>{this.caller.off(r,s),this.App._uninstallPluginHook(n,r)}},datascriptQuery(e,...t){return t.pop(),t?.some(e=>"function"==typeof e)?this.Experiments.ensureHostScope().logseq.api.datascript_query(e,...t):this._execCallableAPIAsync("datascript_query",e,...t)}},Jr={},Yr={},Kr={},Vr={makeSandboxStorage(){return new rt(this,{assets:!0})}};class Xr extends i{_baseInfo;_caller;_version=LIB_VERSION;_debugTag="";_settingsSchema;_connected=!1;_ui=new Map;_mFileStorage;_mRequest;_mExperiments;_beforeunloadCallback;constructor(e,t){super(),this._baseInfo=e,this._caller=t,t.on("sys:ui:visible",e=>{e?.toggle&&this.toggleMainUI()}),t.on("settings:changed",e=>{const t={...this.settings||{}},n={...e||{}};this._baseInfo={...this._baseInfo,settings:n},this.emit("settings:changed",n,t)}),t.on("beforeunload",async e=>{const{actor:t,...n}=e,r=this._beforeunloadCallback;try{r&&await r(n),t?.resolve(null)}catch(e){this.logger.error("[beforeunload] ",e),t?.reject(e)}})}async ready(e,t){if(!this._connected)try{"function"==typeof e&&(t=e,e={});let n=await this._caller.connectToParent(e);const r=n?.settings;this._connected=!0,n=Oe(this._baseInfo,n),void 0!==r&&(n.settings=r),this._baseInfo=n,n?.id&&(this._debugTag=this._caller.debugTag=`#${n.id} [${n.name}]`,this.logger.setTag(this._debugTag)),this._settingsSchema&&(n.settings=Be(n.settings,this._settingsSchema),await this.useSettingsSchema(this._settingsSchema));try{await this._execCallableAPIAsync("setSDKMetadata",{version:this._version,runtime:"js"})}catch(e){console.warn(e)}t&&t.call(this,n)}catch(e){console.error(`${this._debugTag} [Ready Error]`,e)}}ensureConnected(){if(!this._connected)throw new Error("not connected")}beforeunload(e){"function"==typeof e&&(this._beforeunloadCallback=e)}provideModel(e){return this.caller._extendUserModel(e),this}provideTheme(e){return this.caller.call("provider:theme",e),this}provideStyle(e){return this.caller.call("provider:style",e),this}provideUI(e){return this.caller.call("provider:ui",e),this}useSettingsSchema(e){return this.connected&&this.caller.call("settings:schema",{schema:e,isSync:!0}),this._settingsSchema=e,this}updateSettings(e){this.caller.call("settings:update",e)}onSettingsChanged(e){const t="settings:changed";return this.on(t,e),()=>this.off(t,e)}showSettingsUI(){this.caller.call("settings:visible:changed",{visible:!0})}hideSettingsUI(){this.caller.call("settings:visible:changed",{visible:!1})}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(e){const t={key:0,visible:!1,cursor:e?.restoreEditingCursor};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}showMainUI(e){const t={key:0,visible:!0,autoFocus:e?.autoFocus};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}toggleMainUI(){const e=this._ui.get(0);e&&e.visible?this.hideMainUI():this.showMainUI()}get version(){return this._version}get isMainUIVisible(){const e=this._ui.get(0);return Boolean(e&&e.visible)}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get effect(){return this&&(this.baseInfo?.effect||!this.baseInfo?.iir)}get logger(){return Ur}get settings(){return this.baseInfo?.settings}get caller(){return this._caller}resolveResourceFullUrl(e){if(this.ensureConnected(),e)return e=e.replace(/^[.\\/]+/,""),Me(this._baseInfo.lsr,e)}_makeUserProxy(e,t){const n=this,r=this.caller;return new Proxy(e,{get(e,s,i){const o=e[s];return function(...e){if(o){0!==e?.length&&e.push(t);const r=o.apply(n,e);if(r!==Dr)return r}if(t){const i=s.toString().match(/^(once|off|on)/i);if(null!=i){const s=i[0].toLowerCase(),o=i.input,a="off"===s,l=n.baseInfo.id;let c=o.slice(s.length),u=e[0],h=e[1];"string"==typeof u&&"function"==typeof h&&(u=u.replace(/^logseq./,":"),c=`${c}${u}`,u=h,h=e[2]),c=`hook:${t}:${xe(c)}`,r[s](c,u);const d=()=>{r.off(c,u),r.listenerCount(c)||n.App._uninstallPluginHook(l,c)};return a?void d():(n.App._installPluginHook(l,c,h),d)}}let i=s;return["git","ui","assets","utils"].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)}#e;#t;#n;#r;#s;get App(){return this.#e?this.#e:this.#e=this._makeUserProxy(Wr,"app")}get Editor(){return this.#t?this.#t:this.#t=this._makeUserProxy(Br,"editor")}get DB(){return this.#n?this.#n:this.#n=this._makeUserProxy(Gr,"db")}get UI(){return this.#r?this.#r:this.#r=this._makeUserProxy(Yr,"ui")}get Utils(){return this.#s?this.#s:this.#s=this._makeUserProxy(Kr,"utils")}get Git(){return this._makeUserProxy(Jr,"git")}get Assets(){return this._makeUserProxy(Vr,"assets")}get FileStorage(){let e=this._mFileStorage;return e||(e=this._mFileStorage=new rt(this)),e}get Request(){let e=this._mRequest;return e||(e=this._mRequest=new at(this)),e}get Experiments(){let e=this._mExperiments;return e||(e=this._mExperiments=new st(this)),e}}if(null==window.__LSP__HOST__){const e=new ds(null);window.logseq=new Xr({},e)}const{importHTML:Zr,createSandboxContainer:Qr}=window.QSandbox||{};function es(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 ts extends i{_pluginLocal;_frame;_root;_loaded=!1;_unmountFns=[];constructor(e){super(),this._pluginLocal=e,e._dispose(()=>{this._unmount()})}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:r}=await Zr(t,{fetch:es});this._mount(n,document.body);const s=Qr(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;s.__shadow_mode__=!0,s.LSPluginLocal=this._pluginLocal,s.LSPluginShadow=this,s.LSPluginUser=s.logseq=new Xr(this._pluginLocal.toJSON(),this._pluginLocal.caller);const i=await r(s,!0);this._unmountFns.push(i.unmount),this._loaded=!0}_mount(e,t){const n=this._frame=document.createElement("div");n.classList.add("lsp-shadow-sandbox"),n.id=this._pluginLocal.id,this._root=n.attachShadow({mode:"open"}),this._root.innerHTML=`<div>${e}</div>`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){this.frame?.parentNode?.removeChild(this.frame)}get loaded(){return this._loaded}get document(){return this._root?.firstChild}get frame(){return this._frame}}const ns=Ye()("LSPlugin:caller"),rs="#await#response#",ss="#lspmsg#",is="#lspmsg#error#",os="#lspmsg#settings#",as="#lspmsg#beforeunload#",ls="#lspmsg#reply#",cs="#lspmsg#ready#",us=e=>`${ss}${e}`,hs=e=>`${rs}${e}`;class ds extends i{_pluginLocal;_connected=!1;_parent;_child;_shadow;_status;_userModel={};_syncGCTimer=null;_call;_callUserModel;_debugTag="";constructor(e){super(),this._pluginLocal=e,e&&(this._debugTag=e.debugTag)}async connectToChild(){if(this._connected)return;const{shadow:e}=this._pluginLocal;e?await this._setupShadowSandbox():await this._setupIframeSandbox()}async connectToParent(e={}){if(this._connected)return;const t=this,n=null!=this._pluginLocal;let r=0;const s=new Map,i=De(6e4),o=this._extendUserModel({[cs]:async e=>{o[us(e?.pid)]=({type:e,payload:n})=>{ns(`[host (_call) -> *user] ${this._debugTag}`,e,n),t.emit(e,n)},await i.resolve()},[as]:async e=>{const n=De(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},[os]:async({payload:e})=>{t.emit("settings:changed",e)},[ss]:async({ns:e,type:n,payload:r})=>{ns(`[host (async) -> *user] ${this._debugTag} ns=${e} type=${n}`,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},[ls]:({_sync:e,result:t})=>{if(ns(`[sync host -> *user] #${e}`,t),s.has(e)){const n=s.get(e);n&&(t?.hasOwnProperty(is)?n.reject(t[is]):n.resolve(t),s.delete(e))}},...e});if(n)return await i.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const a=new nt(o).sendHandshakeReply();return this._status="pending",await a.then(e=>{this._child=e,this._connected=!0,this._call=async(t,n={},i)=>{if(i){const e=++r;s.set(e,i),n._sync=e,i.setTag(`async call #${e}`),ns(`async call #${e}`)}return e.emit(us(o.baseInfo.id),{type:t,payload:n}),i?.promise},this._callUserModel=async(e,t)=>{try{o[e](t)}catch(t){ns(`call user model(${e}) not exist. #${this._debugTag}`)}},this._syncGCTimer=setInterval(()=>{if(s.size>100)for(const[e,t]of s)t.settled&&s.delete(e)},18e5)}).finally(()=>{this._status=void 0}),await i.promise,o.baseInfo}async call(e,t={}){return this._call?.call(this,e,t)}async callAsync(e,t={}){const n=De(1e4);return this._call?.call(this,e,t,n)}async callUserModel(e,...t){return this._callUserModel?.apply(this,[e,...t])}async callUserModelAsync(e,...t){return e=hs(e),this._callUserModel?.apply(this,[e,...t])}_calcLayoutPosition(e,t,n=0){const r=Math.max(e,n);return"number"==typeof t?`${Math.min(100*r/t,99)}%`:`${r}px`}async _applyContainerLayout(e){const t=(await(this._pluginLocal?._loadLayoutsData()))?.$$0;if(!t)return;const{width:n,height:r,left:s,top:i,vw:o,vh:a}=t;e.dataset.inited_layout="true",Object.assign(e.style,{width:`${n}px`,height:`${r}px`,left:this._calcLayoutPosition(s,o),top:this._calcLayoutPosition(i,a,45)})}async _setupIframeSandbox(){const e=this._pluginLocal,t=e.id,n=`${t}_lsp_main`,r=new URL(e.options.entry);r.searchParams.set("__v__",be?Date.now().toString():e.options.version),document.querySelector(`#${n}`)?.remove();const s=document.createElement("div");s.classList.add("lsp-iframe-sandbox-container"),s.id=n,s.dataset.pid=t;try{await this._applyContainerLayout(s)}catch(e){console.error("[Restore Layout Error]",e)}document.body.appendChild(s);const i=new tt({id:t+"_iframe",container:s,url:r.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))},allow:e.options.allow,enableMessageChannel:!0});let o;this._status="pending";const a=new Promise((e,t)=>{o=setTimeout(()=>{i.destroy(),t(new Error("handshake Timeout"))},8e3)});try{const t=await Promise.race([i.sendHandshake(),a]);this._parent=t,this._connected=!0,this.emit("connected"),t.on(us(e.id),({type:e,payload:t})=>{ns("[user -> *host] ",e,t),this._pluginLocal?.emit(e,t||{}),this._pluginLocal?.caller.emit(e,t||{})}),this._call=async(...n)=>{t.call(us(e.id),{type:n[0],payload:Object.assign(n[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,...n)=>{if(e.startsWith(rs))return await t.get(e.replace(rs,""),...n);t.call(e,n?.[0])}}catch(e){throw ns("[iframe sandbox] error",e),e}finally{clearTimeout(o),this._status=void 0}}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new ts(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(t,n={},r)=>(r&&(n.actor=r),this._pluginLocal?.emit(t,Object.assign(n,{$$pid:e.id})),r?.promise),this._callUserModel=async(...e)=>{let t=e[0];t?.startsWith(rs)&&(t=t.replace(rs,""));const n=e[1]||{},r=this._userModel[t];"function"==typeof r&&await r.call(null,n)}}catch(e){throw ns("[shadow sandbox] error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame.parentNode}_getSandboxShadowContainer(){return this._shadow?.frame}_getSandboxIframeRoot(){return this._parent?.frame}_getSandboxShadowRoot(){return this._shadow?.frame}set debugTag(e){this._debugTag=e}async destroy(){let e=null;this._parent&&(e=this._getSandboxIframeContainer(),this._parent.destroy()),this._shadow&&(e=this._getSandboxShadowContainer(),this._shadow.destroy()),e?.parentNode?.removeChild(e),this._syncGCTimer&&(clearInterval(this._syncGCTimer),this._syncGCTimer=null),this._connected=!1,this._parent=void 0,this._child=void 0,this._shadow=void 0,this._call=void 0,this._callUserModel=void 0,this._status=void 0}}const ps=Ye()("LSPlugin:core"),fs="plugins";class gs extends i{_userPluginSettings;_schema;_settings={disabled:!1};constructor(e,t){super(),this._userPluginSettings=e,this._schema=t,Object.assign(this._settings,e)}get(e){return this._settings[e]}set(e,t){const n=Oe({},this._settings);this._settings[e]!==t&&(this._settings={...this._settings,[e]:t},this.emit("change",{...this._settings},n))}patch(e){if(!Ae(e))return;const t=Oe({},this._settings);this._settings=Oe(this._settings,e),this.emit("change",{...this._settings},t)}replace(e){const t=Oe({},this._settings);this._settings={disabled:!1,...e||{}},this.emit("change",{...this._settings},t)}set settings(e){this.replace(e)}get settings(){return this._settings}setSchema(e,t){this._schema=e,t&&this.replace(Be(this._settings,e))}reset(){const e=this.settings,t={};this._schema,this.replace(t),this.emit("reset",t,e)}toJSON(){return this._settings}}var ms;function ys(e,t){return t&&e.startsWith(ve+t)&&(e=Me(Ce,e.substr(ve.length+t.length))),e}!function(e){e.LOADING="loading",e.UNLOADING="unloading",e.LOADED="loaded",e.UNLOADED="unload",e.ERROR="error"}(ms||(ms={}));class _s extends Error{url;packageJsonPath;constructor(e,t={}){super(e),this.name="IllegalPluginPackageError",Object.assign(this,t)}}class bs extends Error{constructor(e){super(e),this.name="ExistedImportedPluginPackageError"}}class vs extends i{_options;_themeMgr;_ctx;_sdk={};_runtimeDisposes=[];_registrationDisposes=[];_id;_status=ms.UNLOADED;_loadErr;_localRoot;_dotSettingsFile;_caller;_logger=new ke("PluginLocal");_disposeSettingsObserver;constructor(e,t,n){var r;super(),this._options=e,this._themeMgr=t,this._ctx=n,this._id=e.key||Le(),this._disposeRegistration(async()=>{this._disposeSettingsObserver?.(),this._disposeSettingsObserver=void 0}),function(e){const t=e=>`settings:${e}`;e.on(t("schema"),({schema:t,isSync:n})=>{e.settingsSchema=t,e.settings?.setSchema(t,n)}),e.on(t("update"),t=>{t&&e.settings?.patch(t)}),e.on(t("visible:changed"),t=>{const n=t?.visible;Ne("set_focused_settings",n?e.id:null)})}(this),function(e){const t=e=>`main-ui:${e}`;e.on(t("visible"),({visible:t,toggle:n,cursor:r,autoFocus:s})=>{const i=e.getMainUIContainer();i?.classList[n?"toggle":t?"add":"remove"]("visible"),t?!e.shadow&&i&&!1!==s&&i.querySelector("iframe")?.contentWindow?.focus():i.ownerDocument.activeElement.blur(),r&&Ne("restore_editing_cursor")}),e.on(t("attrs"),t=>{const n=e.getMainUIContainer();Object.entries(t).forEach(([t,r])=>{n?.setAttribute(t,String(r)),"draggable"===t&&r&&e._dispose(e._setupDraggableContainer(n,{title:e.options.name,close:()=>{e.caller.call("sys:ui:visible",{toggle:!0})}})),"resizable"===t&&r&&e._dispose(e._setupResizableContainer(n))})}),e.on(t("style"),t=>{const n=e.getMainUIContainer(),r=!!n.dataset.inited_layout;Object.entries(t).forEach(([e,t])=>{r&&["left","top","bottom","right","width","height"].includes(e)||(n.style[e]=t)})})}(this),function(e){const t=e=>`provider:${e}`;let n=!1;e.on(t("theme"),t=>{e.themeMgr.registerTheme(e.id,t),n||(e._dispose(()=>{e.themeMgr.unregisterTheme(e.id)}),n=!0)}),e.on(t("style"),t=>{let n;"string"!=typeof t&&(n=t.key,t=t.style),t&&t.trim()&&e._dispose(Ue(t,{"data-injected-style":n?`${n}-${e.id}`:"","data-ref":e.id}))}),e.on(t("ui"),t=>{e._onHostMounted(()=>{const n=$e.call(e,t,Object.assign({"data-ref":e.id},t.attrs||{}),({el:t,float:n})=>{if(!n)return;const r=t.dataset.identity;e.layoutCore.move_container_to_top(r)});"function"==typeof n&&e._dispose(n)})})}(this),(r=this).on("api:call",async e=>{let t;try{window.$$callerPluginID=r.id,t=await Ne.apply(r,[e.method,...e.args])}catch(e){t={[is]:e}}finally{window.$$callerPluginID=void 0}if(r.shadow)return void(e.actor&&(t?.hasOwnProperty(is)?e.actor.reject(t[is]):e.actor.resolve(t)));const{_sync:n}=e;if(null!=n){const e=e=>{r.caller?.callUserModel(ls,{result:e,_sync:n})};Promise.resolve(t).then(e,e)}})}async _setupUserSettings(e){const{_options:t}=this,n=this._logger=new ke(`Loader:${this.debugTag}`);if(!t.settings||e||!this._disposeSettingsObserver)try{const n=()=>Ne("load_plugin_user_settings",this.id),[r,s]=await n();this._dotSettingsFile=r;let i=t.settings;i||(i=t.settings=new gs(s)),this._disposeSettingsObserver?.(),this._disposeSettingsObserver=void 0,e&&i.replace(s);const o=async e=>{ps("Settings changed",this.debugTag,e),e&&Ne("save_plugin_user_settings",this.id,e)};i.on("change",o);const a=()=>{i.off("change",o),this._disposeSettingsObserver===a&&(this._disposeSettingsObserver=void 0)};this._disposeSettingsObserver=a}catch(e){ps("[load plugin user settings Error]",e),n?.error(e)}}getMainUIContainer(){return this.shadow?this.caller?._getSandboxShadowContainer():this.caller?._getSandboxIframeContainer()}_resolveResourceFullUrl(e,t){if(!e?.trim())return;if(t=t||this._localRoot,this.isWebPlugin)return this.installedFromUserWebUrl?`${this.installedFromUserWebUrl}/${e}`:`https://pub-80f42b85b62c40219354a834fcf2bbfa.r2.dev/${_e.join(t,e)}`;const n=/^(http|file)/;if(!n.test(e)){const r=_e.join(t,e);e=n.test(r)?r:ve+r}return!this.options.effect&&this.isInstalledInLocalDotRoot?ys(e,this.dotPluginsRoot):e}async _preparePackageConfigs(){const{url:e,webPkg:t}=this._options;let n=t;if(!n){let t;if(e){ps("prepare package root",e);try{n=await Ne("load_plugin_config",e),n?(n=JSON.parse(n),n||(t=`Parse package config error #${e}/package.json`)):t=`Parse package config error #${e}/package.json`}catch(e){t=e?.message||String(e)}}else t="Can not resolve package config location";if(t)throw new _s(t,{url:e,packageJsonPath:e?_e.join(e,"package.json"):void 0})}["name","author","repository","version","description","repo","title","effect","sponsors"].concat(this.isInstalledInLocalDotRoot?[]:["devEntry"]).forEach(e=>{this._options[e]=n[e]});const{repo:r,version:s}=this._options,i=this._localRoot=this.isWebPlugin?`${r||e}/${s}`:Re(e),o=n.logseq||{},a=o.entry||o.main||n.main;o.devEntry?(this._options.devEntry=o.devEntry,this._options.entry=o.devEntry):this._options.entry=this._resolveResourceFullUrl(a,i),o.mode&&(this._options.mode=o.mode);const l=o.title||n.title,c=o.icon||n.icon;if(this._options.title=l,this._options.icon=c&&this._resolveResourceFullUrl(c),this._options.theme=Boolean(o.theme||!!o.themes),this.isInstalledInLocalDotRoot)this._id=_e.basename(i);else if(!this.isWebPlugin)if(o.id)this._id=o.id;else{o.id=this.id;try{await Ne("save_plugin_package_json",e,{...n,logseq:o})}catch(e){ps("[save plugin ID Error] ",e)}}const{registeredPlugins:u,isRegistering:h}=this._ctx;if(h&&u.has(this.id))throw new bs(this.id);return async()=>{try{const e=o.themes;e&&await this._loadConfigThemes(Array.isArray(e)?e:[e])}catch(e){ps("[prepare package effect Error]",e)}}}async _tryToNormalizeEntry(){let{entry:e,settings:t,devEntry:n}=this.options;if(n=n||t?.get("_devEntry"),n)return void(this._options.entry=n);if(!e.endsWith(".js"))return;let r=null,s="write_user_tmp_file";this.isInstalledInLocalDotRoot&&(s="write_dotdir_file",r=this._localRoot.replace(this.dotPluginsRoot,""),r=_e.join(fs,r));const i=(new Date).getDay(),o=await Te(),a=await Ne(s,`${this._id}_index.html`,`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="UTF-8">\n <title>logseq plugin entry</title>\n ${this.isWebPlugin?`<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${i}"><\/script>`:`<script src="${o}/lsplugin.user.js?v=${i}"><\/script>`}\n\n </head>\n <body>\n <div id="app"></div>\n <script src="${e}"><\/script>\n </body>\n</html>`,r);e=ys(je(_e.normalize(a)),this.dotPluginsRoot),this._options.entry=e}async _loadConfigThemes(e){e.forEach(e=>{e.url&&(!e.url.startsWith("http")&&this._localRoot&&(e.url=this._resolveResourceFullUrl(e.url,this._localRoot),this.isWebPlugin||e.url.startsWith("file:")||e.url.startsWith("lsp:")||(e.url="assets://"+e.url)),this.emit("provider:theme",e))})}async _loadLayoutsData(){const e=this.id+"_layouts",[,t]=await Ne("load_plugin_user_settings",e);return t||{}}async _saveLayoutsData(e){const t=this.id+"_layouts";await Ne("save_plugin_user_settings",t,e)}async _persistMainUILayoutData(e){const t=await this._loadLayoutsData();t.$$0=e,await this._saveLayoutsData(t)}_setupDraggableContainer(e,t={}){const n=e.dataset;if(n.inited_draggable)return;n.identity||(n.identity="dd-"+Le());const r=!!t.key,s=document.createElement("div");s.classList.add("draggable-handle"),s.innerHTML=`\n <div class="th">\n <div class="l"><h3>${t.title||""}</h3></div>\n <div class="r">\n <a class="button x"><i class="ti ti-x"></i></a>\n </div>\n </div>\n `,s.querySelector(".x").addEventListener("click",e=>{t?.close?.(),e.stopPropagation()},!1),s.addEventListener("mousedown",e=>{const t=e.target;t?.closest(".r")&&(e.stopPropagation(),e.preventDefault())},!1),e.prepend(s),e.addEventListener("mousedown",e=>{this.layoutCore.move_container_to_top(n.identity)},!0);const i=this.layoutCore.setup_draggable_container_BANG_(e,r?()=>{}:this._persistMainUILayoutData.bind(this));var o;n.inited_draggable="true",t.title&&(o=t.title,s.querySelector("h3").textContent=o);let a=null;if("outside"===n.close){const n=n=>{const r=n.target;e.contains(r)||t.close()};document.addEventListener("click",n,!1),a=()=>{document.removeEventListener("click",n)}}return()=>{i(),a?.()}}_setupResizableContainer(e,t){const n=e.dataset;if(n.inited_resizable)return;n.identity||(n.identity="dd-"+Le());const r=document.createElement("div");r.classList.add("resizable-handle"),e.prepend(r);const s=window.frontend.modules.layout.core.setup_resizable_container_BANG_(e,t?()=>{}:this._persistMainUILayoutData.bind(this));return n.inited_resizable="true",s}async load(e){if(!this.pending&&!this.loaded){this._transitionStatus(ms.LOADING,[ms.UNLOADED,ms.ERROR]),this._loadErr=void 0;try{const t=await this._preparePackageConfigs();if(await this._setupUserSettings(e?.reload),this.disabled||await t.call(null),this.disabled||!this.options.entry)return;this._ctx.emit("beforeload",this),await this._tryToNormalizeEntry(),this._caller=new ds(this),await this._caller.connectToChild();const n=()=>{this._caller?.callUserModel(cs,{pid:this.id})};e?.indicator?e.indicator.promise.then(n):n(),this._dispose(async()=>{await(this._caller?.destroy())}),this._dispose(He.bind(this)),this._ctx.emit("loadeded",this)}catch(e){this.logger.error("load",e,!0),this.disposeRuntime().catch(null),this._status=ms.ERROR,this._loadErr=e}finally{this._loadErr||this._transitionStatus(this.disabled?ms.UNLOADED:ms.LOADED,[ms.LOADING])}}}async reload(){this.pending||(this._ctx.emit("beforereload",this),this.loaded&&await this.unload(),await this.load({reload:!0}),this._ctx.emit("reloaded",this))}async unload(e=!1){if(!this.pending)if(e||this.loaded){if(e)return await this.unload(),await this.disposeRegistration(),void((this.isWebPlugin||this.isInstalledInLocalDotRoot)&&this._ctx.emit("unlink-plugin",this.id));try{const t={unregister:e};if(this.loaded){this._transitionStatus(ms.UNLOADING,[ms.LOADED]);try{await(this._caller?.callUserModel(hs(as),t)),this.emit("beforeunload",t)}catch(e){this.logger.error("beforeunload",e)}await this.disposeRuntime()}this.emit("unloaded")}catch(e){this.logger.error("unload",e)}finally{this._status=ms.UNLOADED}}else this._status=ms.UNLOADED}async _runDisposers(e){for(const t of e)try{t&&await t()}catch(e){console.error(this.debugTag,"dispose Error",e)}}async disposeRuntime(){await this._runDisposers(this._runtimeDisposes),this._runtimeDisposes=[]}async disposeRegistration(){await this._runDisposers(this._registrationDisposes),this._registrationDisposes=[]}_dispose(e){e&&this._runtimeDisposes.push(e)}_disposeRegistration(e){e&&this._registrationDisposes.push(e)}_transitionStatus(e,t){if(t&&!t.includes(this._status))throw new Error(`Invalid plugin status transition: ${this._status} -> ${e}`);this._status=e}_onHostMounted(e){const t=this._ctx.hostMountedActor;!t||t.settled?e():t?.promise.then(e)}get isWebPlugin(){return this._ctx.isWebPlatform||!!this.options.webPkg}get installedFromUserWebUrl(){return this.isWebPlugin&&this.options.webPkg?.installedFromUserWebUrl}get layoutCore(){return window.frontend.modules.layout.core}get isInstalledInLocalDotRoot(){if(this.isWebPlugin)return!1;const e=this.dotConfigRoot,t=this.localRoot;return e&&t&&t.startsWith(e)}get loaded(){return this._status===ms.LOADED}get pending(){return[ms.LOADING,ms.UNLOADING].includes(this._status)}get status(){return this._status}get settings(){return this.options.settings}set settingsSchema(e){this._options.settingsSchema=e}get settingsSchema(){return this.options.settingsSchema}get logger(){return this._logger}get disabled(){return this.settings?.get("disabled")}get theme(){return this.options.theme}get caller(){return this._caller}get id(){return this._id}get shadow(){return"shadow"===this.options.mode}get options(){return this._options}get themeMgr(){return this._themeMgr}get debugTag(){const e=this._options?.name;return`#${this._id} - ${e??""}`}get localRoot(){return this._localRoot||this._options.url}get loadErr(){return this._loadErr}get dotConfigRoot(){return _e.normalize(this._ctx.options.dotConfigRoot)}get dotSettingsFile(){return this._dotSettingsFile}get dotPluginsRoot(){return _e.join(this.dotConfigRoot,fs)}get sdk(){return this._sdk}set sdk(e){this._sdk=e}toJSON(e=!0){const t={...this.options};return t.id=this.id,t.err=this.loadErr,t.usf=this.dotSettingsFile,t.iir=this.isInstalledInLocalDotRoot,t.webMode=!!this.isWebPlugin&&(this.installedFromUserWebUrl?"user":"github"),t.lsr=this._resolveResourceFullUrl("/"),!1===e?delete t.settings:t.settings=t.settings?.toJSON(),t}}class ws extends i{_options;_isRegistering=!1;_readyIndicator;_hostMountedActor=De();_userPreferences={theme:null,themes:{mode:"light",light:null,dark:null},externals:[]};_registeredThemes=new Map;_registeredPlugins=new Map;_currentTheme;constructor(e){super(),this._options=e}async loadUserPreferences(){try{const e=await Ne("load_user_preferences");e&&Object.assign(this._userPreferences,e)}catch(e){ps("[load user preferences Error]",e)}}async saveUserPreferences(e){try{e&&Object.assign(this._userPreferences,e),await Ne("save_user_preferences",this._userPreferences)}catch(e){ps("[save user preferences Error]",e)}}async activateUserPreferences(){const{theme:e,themes:t}=this._userPreferences,n=t[t.mode];n?await this.selectTheme(n,{effect:!1,emit:!1}):e&&await this.selectTheme(e,{effect:!1,emit:!1})}async register(e,t=!1){if(!Array.isArray(e))return void await this.register([e]);const n=new Map,r=()=>{const e=Array.from(n.values()).reduce((e,t)=>{const{id:n,options:r,status:s,disabled:i}=t.o;return!0===i||!r.entry&&(r.name||r.entry)||(e[n]={name:r.name,entry:r.entry,status:s,enabled:"boolean"==typeof i?i?"⚫️":"🟢":"🔴",perf:t.e?`${(t.e-t.s).toFixed(2)}ms`:t.o.loadErr}),e},{});console.table(e)};window.__debugPluginsPerfInfo=r;const s=this._readyIndicator=De();try{this._isRegistering=!0,await this.loadUserPreferences();let r=new Set(this._userPreferences.externals);if(r?.size)try{const e=await Ne("validate_external_plugins",[...r]);r=new Set([...Object.entries(e)].reduce((e,[t,n])=>(n&&e.push(t),e),[]))}catch(e){console.error("[validatedExternals Error]",e)}t&&(e=e.concat([...r].filter(t=>!e.length||e.every(e=>!e.entry&&e.url!==t)).map(e=>({url:e}))));for(const t of e){const{url:e}=t,i=new vs(t,this,this),o={o:i,s:performance.now(),e:0};n.set(e,o),await i.load({indicator:s}),o.e=performance.now();const{loadErr:a}=i;if(a&&(ps("[Failed LOAD Plugin] #",t),this.emit("error",a),a instanceof _s||a instanceof bs))continue;const l=e=>{this.emit("settings-changed",i.id,e),i.caller?.callUserModel(os,{payload:e})};i.settings?.on("change",l),i._disposeRegistration(()=>{i.settings?.off("change",l)}),this._registeredPlugins.set(i.id,i),this.emit("registered",i),i.isWebPlugin||i.isInstalledInLocalDotRoot||r.add(e)}await this.saveUserPreferences({externals:Array.from(r)}),await this.activateUserPreferences(),s.resolve("ready")}catch(e){console.error(e)}finally{s.settled||s.resolve("ready"),this._isRegistering=!1,this.emit("ready",n),r()}}async reload(e){if(Array.isArray(e))for(const t of e)try{const e=this.ensurePlugin(t);await e.reload()}catch(e){ps(e)}else await this.reload([e])}async unregister(e){if(!Array.isArray(e))return void await this.unregister([e]);const t=[];for(const n of e){const e=this.ensurePlugin(n);e.isWebPlugin||e.isInstalledInLocalDotRoot||t.push(e.options.url),await e.unload(!0),this._registeredPlugins.delete(n),this.emit("unregistered",n)}const n=this._userPreferences.externals;n.length&&t.length&&await this.saveUserPreferences({externals:n.filter(e=>!t.includes(e))})}async enable(e){const t=this.ensurePlugin(e);t.pending||!t.disabled&&t.loaded||(this.emit("beforeenable"),t.settings?.set("disabled",!1),await t.load(),this.emit("enabled",t.id))}async disable(e){const t=this.ensurePlugin(e);t.pending||t.disabled&&!t.loaded||(this.emit("beforedisable"),t.settings?.set("disabled",!0),await t.unload(),this.emit("disabled",t.id))}async _hook(e,t,n,r){const s=`${e}:${xe(t)}`,i="hook:db:changed"===s,o=s.startsWith("hook:db:block"),a=r=>{ps(`[call hook][#${r.id}]`,e,t),r.caller?.callUserModel(ss,{ns:e,type:xe(t),payload:n})},l=r&&this._registeredPlugins.get(r);if(l&&!l.disabled&&l.options.entry)a(l);else for(const[e,t]of this._registeredPlugins)if(t.options.entry&&!t.disabled)if(r){if(r===t.id){a(t);break}}else{const e=t.sdk?.version;if(!e){if(i||o)continue;a(t)}e&&Ne("should_exec_plugin_hook",t.id,s)&&a(t)}}async hookApp(e,t,n){return await this._hook("hook:app",e,t,n)}async hookEditor(e,t,n){return await this._hook("hook:editor",e,t,n)}async hookDb(e,t,n){return await this._hook("hook:db",e,t,n)}ensurePlugin(e){if(e instanceof vs)return e;const t=this._registeredPlugins.get(e);if(!t)throw new Error(`plugin #${e} not existed.`);return t}hostMounted(){this._hostMountedActor.resolve()}_forceCleanInjectedUI(e){if(e)return ze(e)}get isWebPlatform(){return this.options.dotConfigRoot?.startsWith("LSPUserDotRoot")}get registeredPlugins(){return this._registeredPlugins}get options(){return this._options}get readyIndicator(){return this._readyIndicator}get hostMountedActor(){return this._hostMountedActor}get isRegistering(){return this._isRegistering}get themes(){return this._registeredThemes}get enabledPlugins(){return[...this.registeredPlugins.entries()].reduce((e,t)=>{let n=t?.[1];return!0!==n?.disabled&&e.set(t?.[0],n),e},new Map)}async registerTheme(e,t){if(ps("Register theme #",e,t),!e)return;let n=this._registeredThemes.get(e);n||this._registeredThemes.set(e,n=[]),n.push(t),this.emit("themes-changed",this.themes,{id:e,...t})}async selectTheme(e,t={}){const{effect:n,emit:r}=Object.assign({effect:!0,emit:!0},t);if(this._currentTheme&&this._currentTheme.eject(),e.url){const t=qe(e.url);this._currentTheme={pid:e.pid,opt:e,eject:t}}else this._currentTheme=null;n&&await this.saveUserPreferences(e.mode?{themes:{...this._userPreferences.themes,mode:e.mode,[e.mode]:e}}:{theme:e}),r&&this.emit("theme-selected",e,t)}async unregisterTheme(e,t=!0){if(ps("Unregister theme #",e),this._registeredThemes.has(e)&&(this._registeredThemes.delete(e),this.emit("themes-changed",this.themes,{id:e}),t&&this._currentTheme?.pid===e)){this._currentTheme.eject(),this._currentTheme=null;const{theme:t,themes:n}=this._userPreferences;await this.saveUserPreferences({theme:t?.pid===e?null:t,themes:{...n,light:n.light?.pid===e?null:n.light,dark:n.dark?.pid===e?null:n.dark}}),this.emit("reset-custom-theme",this._userPreferences.themes)}}}function Cs(e){const t=new ws(e);ps("=== 🔗 Setup Logseq Plugin System 🔗 ==="),window.LSPluginCore=t,window.DOMPurify=oe}})(),r})()); |