digital-garden/.obsidian/plugins/obsidian-excalidraw-plugin/main.js

101 lines
5.1 MiB
JavaScript
Raw Normal View History

2024-06-13 21:01:37 +03:00
"use strict";var obsidian_module=require("obsidian"),state=require("@codemirror/state"),view=require("@codemirror/view");var LZString=function(){var r=String.fromCharCode,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={};function t(r,o){if(!e[r]){e[r]={};for(var n=0;n<r.length;n++)e[r][r.charAt(n)]=n}return e[r][o]}var i={compressToBase64:function(r){if(null==r)return"";var n=i._compress(r,6,function(r){return o.charAt(r)});switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(n){return t(o,r.charAt(n))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompressFromUTF16:function(r){return null==r?"":""==r?null:i._decompress(r.length,16384,function(o){return r.charCodeAt(o)-32})},compressToUint8Array:function(r){for(var o=i.compress(r),n=new Uint8Array(2*o.length),e=0,t=o.length;e<t;e++){var s=o.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null==o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;e<t;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return null==r?"":i._compress(r,6,function(r){return n.charAt(r)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(o){return t(n,r.charAt(o))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(r,o,n){if(null==r)return"";var e,t,i,s={},u={},a="",p="",c="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;i<r.length;i+=1)if(a=r.charAt(i),Object.prototype.hasOwnProperty.call(s,a)||(s[a]=f++,u[a]=!0),p=c+a,Object.prototype.hasOwnProperty.call(s,p))c=p;else{if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++),s[p]=f++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==o-1){d.push(n(m));break}v++}return d.join("")},decompress:function(r){return null==r?"":""==r?null:i._decompress(r.length,32768,function(o){return r.charCodeAt(o)})},_decompress:function(o,n,e){var t,i,s,u,a,p,c,l=[],f=4,h=4,d=3,m="",v=[],g={val:e(0),position:n,index:1};for(t=0;t<3;t+=1)l[t]=t;for(s=0,a=Math.pow(2,2),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;switch(s){case 0:for(s=0,a=Math.pow(2,8),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 1:for(s=0,a=Math.pow(2,16),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 2:return""}for(l[3]=c,i=c,v.push(c);;){if(g.index>o)return"";for(s=0,a=Math.pow(2,d),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.i
2024-08-09 08:39:12 +03:00
let EXCALIDRAW_PACKAGES = LZString.decompressFromBase64("PQKhCgAIUgBAbAlgYwKYDsDOrICVUCGyALlDAE6EkB0ADuQPYAmAriYg+tQLaJcBWmMmUgBhBrQCe5RAHMAFsUgAKZAEpIAMSKoARgwYBrADSQAkumTVIBdE0iJimGwDMXiJAWKpM1YdEgAFXlEZ0wGFnI0SGRmHFDIJDQsVHsWO1RySGJ5HABZM0DElAxsSBcIuwd0bNyRABkzUQBRADkAZWbyj3ianJxGBiUmREoSBnJJSAYXWoTwyOjiSlQ/aGBwZRd09k5lNQBvAHIWMsxllGIjgG4tneIOdFVjAA9DgCIGXX5UEneAXkBxEktFQM0gqBetAmTgAZLD3ukmKh3OhUu8AIRAkFg2bcZgseCoAD8L2UkOh5CcagAXO9tpYHpwAdjQeDkajUPCOXxVgRuExiTy0coANrvCkwzDvAC6r1pqn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wFBBSGIMkE8NYLMIcNCnxGINx2CO0IUIcMDlx0kGIKTBMMoPzAdwmGMGPANFCDyEqG8FxRDRv2jHP37HQGTVOVOU0AmDQAAFVdx9xkMY5+47Q8IMByjUBTl8AfFUAm4GiQ1nwYYw9WiyiKiej5ZejvBGjL9mjB5DgiZ2pExWUaBzJMA5B0BjA1xcJrgOx3whghgcQdtMBdQSBxBuBoQ0QZwtidiRwG5AZgdxjh1IN+jG1J4aUQxqxJltYK9HR3jx4C44wsQXQvlMZe9QV5DsBiAJjUBlBqBYTaRshAEfAbAagaVphZh20cB/In9dAiRnB5UwJ9xphlVyhBsOwQh5oFUNFoUUTIUlBwQMSEUZACAcSfA6FfJwB
2024-07-13 19:25:17 +03:00
let {react, reactDOM, excalidrawLib} = window.eval.call(window, `(function() {${EXCALIDRAW_PACKAGES};return {react: React, reactDOM: ReactDOM, excalidrawLib: ExcalidrawLib};})();`);
2024-08-09 08:39:12 +03:00
let PLUGIN_VERSION="2.3.0";;function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var obsidian_module__namespace=_interopNamespace(obsidian_module),React__namespace=_interopNamespace(React);let random$1=e=>crypto.getRandomValues(new Uint8Array(e)),customRandom=(e,t,n)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o="";for(;;){let t=n(i),s=i;for(;s--;)if(o+=e[t[s]&r]||"",o.length===a)return o}}},customAlphabet=(e,t=21)=>customRandom(e,t,random$1),nanoid$1=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")),""),EXCALIDRAW_PLUGIN=null;const setExcalidrawPlugin=e=>{EXCALIDRAW_PLUGIN=e},MD_EXCALIDRAW="# Excalidraw Data",MD_TEXTELEMENTS="## Text Elements",MD_ELEMENTLINKS="## Element Links",MD_EMBEDFILES="## Embedded Files",MD_DRAWING="## Drawing",MD_EX_SECTIONS=[MD_EXCALIDRAW,MD_TEXTELEMENTS,MD_ELEMENTLINKS,MD_EMBEDFILES,MD_DRAWING],ERROR_IFRAME_CONVERSION_CANCELED="iframe conversion canceled",LOCALE=obsidian_module.moment.locale(),obsidianToExcalidrawMap={en:"en-US",af:"af-ZA",am:"am-ET",ar:"ar-SA",eu:"eu-ES",be:"be-BY",bg:"bg-BG",bn:"bn-BD",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",el:"el-GR",eo:"eo-EO",es:"es-ES",fa:"fa-IR","fi-fi":"fi-FI",fr:"fr-FR",gl:"gl-ES",he:"he-IL",hi:"hi-IN",hu:"hu-HU",id:"id-ID",it:"it-IT",ja:"ja-JP",ko:"ko-KR",lv:"lv-LV",ml:"ml-IN",ms:"ms-MY",nl:"nl-NL",no:"nb-NO",oc:"oc-FR",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sr:"sr-RS",se:"sv-SE",sk:"sk-SK",sq:"sq-AL",ta:"ta-IN",te:"te-IN",th:"th-TH",tr:"tr-TR",uk:"uk-UA",ur:"ur-PK",vi:"vi-VN",zh:"zh-CN","zh-TW":"zh-TW"},{sceneCoordsToViewportCoords:sceneCoordsToViewportCoords,viewportCoordsToSceneCoords:viewportCoordsToSceneCoords,determineFocusDistance:determineFocusDistance,intersectElementWithLine:intersectElementWithLine,getCommonBoundingBox:getCommonBoundingBox,getMaximumGroups:getMaximumGroups,measureText:measureText,getLineHeight:getLineHeight,wrapText:wrapText,getFontString:getFontString,getBoundTextMaxWidth:getBoundTextMaxWidth,exportToSvg:exportToSvg,exportToBlob:exportToBlob,mutateElement:mutateElement,restore:restore,mermaidToExcalidraw:mermaidToExcalidraw,getFontFamilyString:getFontFamilyString,getContainerElement:getContainerElement,refreshTextDimensions:refreshTextDimensions,getFontDefinition:getFontDefinition}=excalidrawLib,FONTS_STYLE_ID="excalidraw-custom-fonts";function JSON_parse(e){return JSON.parse(e.replaceAll("&#91;","["))}/Mac|iPod|iPhone|iPad/.test(window.navigator.platform);const DEVICE={isDesktop:!document.body.hasClass("is-tablet")&&!document.body.hasClass("is-mobile"),isPhone:document.body.hasClass("is-phone"),isTablet:document.body.hasClass("is-tablet"),isMobile:document.body.hasClass("is-mobile"),isLinux:document.body.hasClass("mod-linux")&&!document.body.hasClass("is-android"),isMacOS:document.body.hasClass("mod-macos")&&!document.body.hasClass("is-ios"),isWindows:document.body.hasClass("mod-windows"),isIOS:document.body.hasClass("is-ios"),isAndroid:document.body.hasClass("is-android")},ROOTELEMENTSIZE=(()=>{const e=document.createElement("div");e.style.fontSize="1rem",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e),n=parseFloat(t.fontSize);return document.body.removeChild(e),n})(),nanoid=customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",8),KEYCODE={ESC:27},ROUNDNESS={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},THEME_FILTER="invert(100%) hue-rotate(180deg) saturate(1.25)",GITHUB_RELEASES="https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/",URLFETCHTIMEOUT=3e3,PLUGIN_ID="obsidian-excalidraw-plugin",SCRIPT_INSTALL_CODEBLOCK="excalidraw-script-install",SCRIPT_INSTALL_FOLDER="Downloaded",fileid=customAlphabet("1234567890abcdef",40),REG_LINKIND
2024-06-13 21:01:37 +03:00
/*!
*************************************************************************
*
* mhchemParser.ts
* 4.2.1
*
* Parser for the \ce command and \pu command for MathJax and Co.
*
* mhchem's \ce is a tool for writing beautiful chemical equations easily.
* mhchem's \pu is a tool for writing physical units easily.
*
* ----------------------------------------------------------------------
*
* Copyright (c) 2015-2023 Martin Hensel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ----------------------------------------------------------------------
*
* https://github.com/mhchem/mhchemParser
*
*/
2024-07-29 07:51:09 +03:00
Object.defineProperty(mhchemParser$1,"__esModule",{value:!0}),mhchemParser$1.mhchemParser=void 0;var mhchemParser=function(){function e(){}return e.toTex=function(e,t){return _mhchemTexify.go(_mhchemParser.go(e,t),"tex"!==t)},e}();function _mhchemCreateTransitions(e){var t,n,r={};for(t in e)for(n in e[t]){var i=n.split("|");e[t][n].stateArray=i;for(var a=0;a<i.length;a++)r[i[a]]=[]}for(t in e)for(n in e[t])for(i=e[t][n].stateArray||[],a=0;a<i.length;a++){var o=e[t][n];o.action_=[].concat(o.action_);for(var s=0;s<o.action_.length;s++)"string"==typeof o.action_[s]&&(o.action_[s]={type_:o.action_[s]});for(var l=t.split("|"),c=0;c<l.length;c++)if("*"===i[a]){var d=void 0;for(d in r)r[d].push({pattern:l[c],task:o})}else r[i[a]].push({pattern:l[c],task:o})}return r}mhchemParser$1.mhchemParser=mhchemParser;var _mhchemParser={go:function(e,t){if(!e)return[];void 0===t&&(t="ce");var n,r="0",i={parenthesisLevel:0};e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var a=10,o=[];;){n!==e?(a=10,n=e):a--;var s=_mhchemParser.stateMachines[t],l=s.transitions[r]||s.transitions["*"];e:for(var c=0;c<l.length;c++){var d=_mhchemParser.patterns.match_(l[c].pattern,e);if(d){for(var T=l[c].task,u=0;u<T.action_.length;u++){var Q=void 0;if(s.actions[T.action_[u].type_])Q=s.actions[T.action_[u].type_](i,d.match_,T.action_[u].option);else{if(!_mhchemParser.actions[T.action_[u].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+T.action_[u].type_+")"];Q=_mhchemParser.actions[T.action_[u].type_](i,d.match_,T.action_[u].option)}_mhchemParser.concatArray(o,Q)}if(r=T.nextState||r,!(e.length>0))return o;if(T.revisit||(e=d.remainder),!T.toContinue)break e}}if(a<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if(Array.isArray(t))for(var n=0;n<t.length;n++)e.push(t[n]);else e.push(t)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return t&&t[0]?{match_:t.slice(1),remainder:e.substr(t[0].length)}:null},"(-)(9)^(-9)":/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/,"state of aggregation $":function(e){var t=_mhchemParser.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))return t;var n=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return n?{match_:n[0],remainder:e.substr(n[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". __* ":/^([.\u22C5\u00B7\u2022]|[*])\s*/,"...":/^\.\.\.(?=$|[^.])/,"^{(...)}":function(e){return _mhchemParser.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return _mhchemParser.pattern
2024-06-13 21:01:37 +03:00
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
2024-08-09 08:39:12 +03:00
function isNothing(e){return null==e}function isObject(e){return"object"==typeof e&&null!==e}function toArray(e){return Array.isArray(e)?e:isNothing(e)?[]:[e]}function extend(e,t){var n,r,i,a;if(t)for(n=0,r=(a=Object.keys(t)).length;n<r;n+=1)e[i=a[n]]=t[i];return e}function repeat(e,t){var n,r="";for(n=0;n<t;n+=1)r+=e;return r}function isNegativeZero(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e}var isNothing_1=isNothing,isObject_1=isObject,toArray_1=toArray,repeat_1=repeat,isNegativeZero_1=isNegativeZero,extend_1=extend,common={isNothing:isNothing_1,isObject:isObject_1,toArray:toArray_1,repeat:repeat_1,isNegativeZero:isNegativeZero_1,extend:extend_1};function formatError(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),r+" "+n):r}function YAMLException$1(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=formatError(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}YAMLException$1.prototype=Object.create(Error.prototype),YAMLException$1.prototype.constructor=YAMLException$1,YAMLException$1.prototype.toString=function(e){return this.name+": "+formatError(this,e)};var exception=YAMLException$1;function getLine(e,t,n,r,i){var a="",o="",s=Math.floor(i/2)-1;return r-t>s&&(t=r-s+(a=" ... ").length),n-r>s&&(n=r+s-(o=" ...").length),{str:a+e.slice(t,n).replace(/\t/g,"→")+o,pos:r-t+a.length}}function padStart(e,t){return common.repeat(" ",t-e.length)+e}function makeSnippet(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,r=/\r?\n|\r|\0/g,i=[0],a=[],o=-1;n=r.exec(e.buffer);)a.push(n.index),i.push(n.index+n[0].length),e.position<=n.index&&o<0&&(o=i.length-2);o<0&&(o=i.length-1);var s,l,c="",d=Math.min(e.line+t.linesAfter,a.length).toString().length,T=t.maxLength-(t.indent+d+3);for(s=1;s<=t.linesBefore&&!(o-s<0);s++)l=getLine(e.buffer,i[o-s],a[o-s],e.position-(i[o]-i[o-s]),T),c=common.repeat(" ",t.indent)+padStart((e.line-s+1).toString(),d)+" | "+l.str+"\n"+c;for(l=getLine(e.buffer,i[o],a[o],e.position,T),c+=common.repeat(" ",t.indent)+padStart((e.line+1).toString(),d)+" | "+l.str+"\n",c+=common.repeat("-",t.indent+d+3+l.pos)+"^\n",s=1;s<=t.linesAfter&&!(o+s>=a.length);s++)l=getLine(e.buffer,i[o+s],a[o+s],e.position-(i[o]-i[o+s]),T),c+=common.repeat(" ",t.indent)+padStart((e.line+s+1).toString(),d)+" | "+l.str+"\n";return c.replace(/\n$/,"")}var snippet=makeSnippet,TYPE_CONSTRUCTOR_OPTIONS=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],YAML_NODE_KINDS=["scalar","sequence","mapping"];function compileStyleAliases(e){var t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}function Type$1(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===TYPE_CONSTRUCTOR_OPTIONS.indexOf(t))throw new exception('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=compileStyleAliases(t.styleAliases||null),-1===YAML_NODE_KINDS.indexOf(this.kind))throw new exception('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var type=Type$1;function compileList(e,t){var n=[];return e[t].forEach((function(e){var t=n.length;n.forEach((function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)})),n[t]=e})),n}function compileMap(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scala
/*! https://mths.be/codepointat v0.2.0 by @mathias */String.prototype.codePointAt||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,r=e?Number(e):0;if(r!=r&&(r=0),!(r<0||r>=n)){var i,a=t.charCodeAt(r);return a>=55296&&a<=56319&&n>r+1&&(i=t.charCodeAt(r+1))>=56320&&i<=57343?1024*(a-55296)+i-56320+65536:a}};e?e(String.prototype,"codePointAt",{value:t,configurable:!0,writable:!0}):String.prototype.codePointAt=t}();var TINF_OK=0,TINF_DATA_ERROR=-3;function Tree(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Data(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new Tree,this.dtree=new Tree}var sltree=new Tree,sdtree=new Tree,length_bits=new Uint8Array(30),length_base=new Uint16Array(30),dist_bits=new Uint8Array(30),dist_base=new Uint16Array(30),clcidx=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),code_tree=new Tree,lengths=new Uint8Array(320);function tinf_build_bits_base(e,t,n,r){var i,a;for(i=0;i<n;++i)e[i]=0;for(i=0;i<30-n;++i)e[i+n]=i/n|0;for(a=r,i=0;i<30;++i)t[i]=a,a+=1<<e[i]}function tinf_build_fixed_trees(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}var offs=new Uint16Array(16);function tinf_build_tree(e,t,n,r){var i,a;for(i=0;i<16;++i)e.table[i]=0;for(i=0;i<r;++i)e.table[t[n+i]]++;for(e.table[0]=0,a=0,i=0;i<16;++i)offs[i]=a,a+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[offs[t[n+i]]++]=i)}function tinf_getbit(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=1&e.tag;return e.tag>>>=1,t}function tinf_read_bits(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var r=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function tinf_decode_symbol(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=0,r=0,i=0,a=e.tag;do{r=2*r+(1&a),a>>>=1,++i,n+=t.table[i],r-=t.table[i]}while(r>=0);return e.tag=a,e.bitcount-=i,t.trans[n+r]}function tinf_decode_trees(e,t,n){var r,i,a,o,s,l;for(r=tinf_read_bits(e,5,257),i=tinf_read_bits(e,5,1),a=tinf_read_bits(e,4,4),o=0;o<19;++o)lengths[o]=0;for(o=0;o<a;++o){var c=tinf_read_bits(e,3,0);lengths[clcidx[o]]=c}for(tinf_build_tree(code_tree,lengths,0,19),s=0;s<r+i;){var d=tinf_decode_symbol(e,code_tree);switch(d){case 16:var T=lengths[s-1];for(l=tinf_read_bits(e,2,3);l;--l)lengths[s++]=T;break;case 17:for(l=tinf_read_bits(e,3,3);l;--l)lengths[s++]=0;break;case 18:for(l=tinf_read_bits(e,7,11);l;--l)lengths[s++]=0;break;default:lengths[s++]=d}}tinf_build_tree(t,lengths,0,r),tinf_build_tree(n,lengths,r,i)}function tinf_inflate_block_data(e,t,n){for(;;){var r,i,a,o,s=tinf_decode_symbol(e,t);if(256===s)return TINF_OK;if(s<256)e.dest[e.destLen++]=s;else for(r=tinf_read_bits(e,length_bits[s-=257],length_base[s]),i=tinf_decode_symbol(e,n),o=a=e.destLen-tinf_read_bits(e,dist_bits[i],dist_base[i]);o<a+r;++o)e.dest[e.destLen++]=e.dest[o]}}function tinf_inflate_uncompressed_block(e){for(var t,n;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return TINF_DATA_ERROR;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,TINF_OK}function tinf_uncompress(e,t){var n,r,i=new Data(e,t);do{switch(n=tinf_getbit(i),tinf_read_bits(i,2,0)){case 0:r=tinf_inflate_uncompressed_block(i);break;case 1:r=tinf_inflate_block_data(i,sltree,sdtree);break;case 2:tinf_decode_trees(i,i.ltree,i.dtree),r=tinf_inflate_block_data(i,i.ltree,i.dtree);break;default:r=TINF_DATA_ERROR}if(r!==TINF_OK)throw new Error("Data error")}while(!n);return i.destLen<i.dest.length?"function"==typeof
2024-06-13 21:01:37 +03:00
//![[link|alias]] [alias](link){num}
2024-07-29 07:51:09 +03:00
EXPR:/(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g,getResList:e=>{const t=e.matchAll(REGEX_LINK.EXPR);let n;const r=[];for(;!(n=t.next()).done;)r.push(n);return r},getRes:e=>e.matchAll(REGEX_LINK.EXPR),isTransclusion:e=>!!e.value[1],getLink:e=>e.value[3]?e.value[3]:e.value[6],isWikiLink:e=>!!e.value[3],getAliasOrLink:e=>REGEX_LINK.isWikiLink(e)?e.value[4]?e.value[4]:e.value[3]:e.value[5]?e.value[5]:e.value[6],getWrapLength:(e,t)=>{const n=parseInt(e.value[8]);return isNaN(n)?t>0?t:null:n}},DRAWING_REG=/\n##? Drawing\n[^`]*(```json\n)([\s\S]*?)```\n/gm,DRAWING_REG_FALLBACK=/\n##? Drawing\n(```json\n)?(.*)(```)?(%%)?/gm,DRAWING_COMPRESSED_REG=/(\n##? Drawing\n[^`]*(?:```compressed\-json\n))([\s\S]*?)(```\n)/gm,DRAWING_COMPRESSED_REG_FALLBACK=/(\n##? Drawing\n(?:```compressed\-json\n)?)(.*)((```)?(%%)?)/gm,REG_LINKINDEX_HYPERLINK=/^\w+:\/\//,isCompressedMD=e=>null!==e.match(/```compressed\-json\n/gm),getDecompressedScene=e=>{let t,n=e.matchAll(DRAWING_COMPRESSED_REG);return t=n.next(),t.done&&(n=e.matchAll(DRAWING_COMPRESSED_REG_FALLBACK),t=n.next()),t.value&&t.value.length>1?[decompress(t.value[2]),t]:[null,t]},changeThemeOfExcalidrawMD=e=>{const t=isCompressedMD(e);let n=t?getDecompressedScene(e)[0]:e;return n?(isObsidianThemeDark?1===(n.match(/"theme"\s*:\s*"light"\s*,/g)||[]).length&&(n=n.replace(/"theme"\s*:\s*"light"\s*,/,'"theme": "dark",')):1===(n.match(/"theme"\s*:\s*"dark"\s*,/g)||[]).length&&(n=n.replace(/"theme"\s*:\s*"dark"\s*,/,'"theme": "light",')),t?e.replace(DRAWING_COMPRESSED_REG,`$1${compress(n)}$3`):n):e};function getJSON(e){let t,n;if(isCompressedMD(e)){const[t,n]=getDecompressedScene(e);return t?{scene:t.substring(0,t.lastIndexOf("}")+1),pos:n.value.index}:{scene:e,pos:n.value?n.value.index:0}}if(t=e.matchAll(DRAWING_REG),n=t.next(),n.done&&(t=e.matchAll(DRAWING_REG_FALLBACK),n=t.next()),n.value&&n.value.length>1){const e=n.value[2];return{scene:e.substr(0,e.lastIndexOf("}")+1),pos:n.value.index}}return{scene:e,pos:n.value?n.value.index:0}}function getMarkdownDrawingSection(e,t){return t?`## Drawing\n\`\`\`compressed-json\n${compress(e)}\n\`\`\`\n%%`:`## Drawing\n\`\`\`json\n${e}\n\`\`\`\n%%`}const RE_EXCALIDRAWDATA_WITHSECTION_OK=/^(#\n+)%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_WITHSECTION_NOTOK=/#\n+%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_NOSECTION_OK=/^(%%\n+)?# Excalidraw Data(?:\n|$)/m,RE_TEXTELEMENTS_WITHSECTION_OK=/^#\n+%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_WITHSECTION_NOTOK=/#\n+%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_NOSECTION_OK=/^(%%\n+)?##? Text Elements(?:\n|$)/m,RE_EXCALIDRAWDATA_FALLBACK_1=/(.*)%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_FALLBACK_2=/(.*)# Excalidraw Data(?:\n|$)/m,RE_TEXTELEMENTS_FALLBACK_1=/(.*)%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_FALLBACK_2=/(.*)##? Text Elements(?:\n|$)/m,RE_DRAWING=/^(%%\n+)?##? Drawing\n/m,getExcalidrawMarkdownHeaderSection=(e,t)=>{var n;const r=e.search(RE_DRAWING);r>0&&(e=e.substring(0,r));const i=e.match(RE_EXCALIDRAWDATA_WITHSECTION_OK);let a=null!==(n=null==i?void 0:i.index)&&void 0!==n?n:-1,o=!1;if(a>0&&(a+=i[1].length),-1===a&&(a=e.search(RE_EXCALIDRAWDATA_WITHSECTION_NOTOK),a>0&&(o=!0)),-1===a&&(a=e.search(RE_EXCALIDRAWDATA_NOSECTION_OK)),-1===a){const t=e.match(RE_EXCALIDRAWDATA_FALLBACK_1);t&&Boolean(t[1])&&(a=t.index+t[1].length)}if(-1===a){const t=e.match(RE_EXCALIDRAWDATA_FALLBACK_2);t&&Boolean(t[1])&&(a=t.index+t[1].length)}if(-1===a&&(a=e.search(RE_TEXTELEMENTS_WITHSECTION_OK),a>0&&(a+=2)),-1===a&&(a=e.search(RE_TEXTELEMENTS_WITHSECTION_NOTOK),a>0&&(o=!0)),-1===a&&(a=e.search(RE_TEXTELEMENTS_NOSECTION_OK)),-1===a){const t=e.match(RE_TEXTELEMENTS_FALLBACK_1);t&&Boolean(t[1])&&(a=t.index+t[1].length)}if(-1===a){const t=e.match(RE_TEXTELEMENTS_FALLBACK_2);t&&Boolean(t[1])&&(a=t.index+t[1].length)}if(-1===a&&r>0&&(a=r),-1===a)return e.endsWith("\n")?e:e+"\n";let s=updateFrontmatterInString(e.substring(0,a),t);return o?s+"\n#\n":s.endsWith("\n")?s:s+"\n"};class ExcalidrawData{constructor(e){this.plugin=e,this.textElements=null,this.scene=null,this.delete
2024-06-13 21:01:37 +03:00
/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
2024-08-09 08:39:12 +03:00
*/chroma$1.exports,function(e,t){e.exports=function(){for(var e=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),e<t?t:e>n?n:e},t=e,n={},r=0,i=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];r<i.length;r+=1){var a=i[r];n["[object "+a+"]"]=a.toLowerCase()}var o=function(e){return n[Object.prototype.toString.call(e)]||"object"},s=o,l=o,c=Math.PI,d={clip_rgb:function(e){e._clipped=!1,e._unclipped=e.slice(0);for(var n=0;n<=3;n++)n<3?((e[n]<0||e[n]>255)&&(e._clipped=!0),e[n]=t(e[n],0,255)):3===n&&(e[n]=t(e[n],0,1));return e},limit:e,type:o,unpack:function(e,t){return void 0===t&&(t=null),e.length>=3?Array.prototype.slice.call(e):"object"==s(e[0])&&t?t.split("").filter((function(t){return void 0!==e[0][t]})).map((function(t){return e[0][t]})):e[0]},last:function(e){if(e.length<2)return null;var t=e.length-1;return"string"==l(e[t])?e[t].toLowerCase():null},PI:c,TWOPI:2*c,PITHIRD:c/3,DEG2RAD:c/180,RAD2DEG:180/c},T={format:{},autodetect:[]},u=d.last,Q=d.clip_rgb,p=d.type,h=T,m=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=this;if("object"===p(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];var r=u(e),i=!1;if(!r){i=!0,h.sorted||(h.autodetect=h.autodetect.sort((function(e,t){return t.p-e.p})),h.sorted=!0);for(var a=0,o=h.autodetect;a<o.length;a+=1){var s=o[a];if(r=s.test.apply(s,e))break}}if(!h.format[r])throw new Error("unknown format: "+e);var l=h.format[r].apply(null,i?e:e.slice(0,-1));n._rgb=Q(l),3===n._rgb.length&&n._rgb.push(1)};m.prototype.toString=function(){return"function"==p(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=m,g=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(g.Color,[null].concat(e)))};g.Color=f,g.version="2.4.2";var b=g,y=d.unpack,v=Math.max,_=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=y(e,"rgb"),r=n[0],i=n[1],a=n[2],o=1-v(r/=255,v(i/=255,a/=255)),s=o<1?1/(1-o):0;return[(1-r-o)*s,(1-i-o)*s,(1-a-o)*s,o]},L=d.unpack,w=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=(e=L(e,"cmyk"))[0],r=e[1],i=e[2],a=e[3],o=e.length>4?e[4]:1;return 1===a?[0,0,0,o]:[n>=1?0:255*(1-n)*(1-a),r>=1?0:255*(1-r)*(1-a),i>=1?0:255*(1-i)*(1-a),o]},E=b,x=f,M=T,S=d.unpack,H=d.type,C=_;x.prototype.cmyk=function(){return C(this._rgb)},E.cmyk=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(x,[null].concat(e,["cmyk"])))},M.format.cmyk=w,M.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=S(e,"cmyk"),"array"===H(e)&&4===e.length)return"cmyk"}});var O=d.unpack,A=d.last,k=function(e){return Math.round(100*e)/100},I=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=O(e,"hsla"),r=A(e)||"lsa";return n[0]=k(n[0]||0),n[1]=k(100*n[1])+"%",n[2]=k(100*n[2])+"%","hsla"===r||n.length>3&&n[3]<1?(n[3]=n.length>3?n[3]:1,r="hsla"):n.length=3,r+"("+n.join(",")+")"},V=d.unpack,N=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=(e=V(e,"rgba"))[0],r=e[1],i=e[2];n/=255,r/=255,i/=255;var a,o,s=Math.min(n,r,i),l=Math.max(n,r,i),c=(l+s)/2;return l===s?(a=0,o=Number.NaN):a=c<.5?(l-s)/(l+s):(l-s)/(2-l-s),n==l?o=(r-i)/(l-s):r==l?o=2+(i-n)/(l-s):i==l&&(o=4+(n-r)/(l-s)),(o*=60)<0&&(o+=360),e.length>3&&void 0!==e[3]?[o,a,c,e[3]]:[o,a,c]},P=d.unpack,R=d.last,D=I,$=N,j=Math.round,F=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=P(e,"rgba"),r=R(e)||"rgb";return"hsl"==r.substr(0,3)?D($(n),r):(n[0]=j(n[0]),n[1]=j(n[1]),n[2]=j(n[2]),("rgba"===r||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,r="rgba"),r+"("+n.slice(0,"rgb"===r?3:4).join(",")+")")},B=d.unpack,G=Math.round,U=function(){for(var e,t=[],n=arguments.length;n--;)t[n]=arguments[n];var r,i,a,o=(t=B(t,"hsl"))[0],s=t[1],l=t[2];if(0===s)r=i=a=255*l;else{var c=[0,0,0],d=[0,0,0],T=l<.5?l*(1+s):l+s-l*s,u=2*l-T,Q=o/360;c[0]=Q+1/3,c[1]=Q,c[2]=Q-1/3;for(var p=0;p<3;p++)c[p]<0&&(c[p]+=1),c[p]>1&&(c[p]-=1),6*c[p]<1?d[p]=u+6*(T-u)*c[p]:2*c[p]<1?d
2024-06-13 21:01:37 +03:00
//!Temporary hack
2024-08-09 08:39:12 +03:00
if(this.activeExcalidrawView=i,i?(this.addModalContainerObserver(),this.lastActiveExcalidrawFilePath=null===(t=i.file)||void 0===t?void 0:t.path):this.removeModalContainerObserver(),DEVICE.isMobile&&i&&!r){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="relative")}if(DEVICE.isMobile&&!i&&r){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="")}if(r&&r!==i&&(r.leaf!==e&&(null==r?void 0:r.isDirty())&&!(null===(n=r.semaphores)||void 0===n?void 0:n.viewunload)&&await r.save(!0),r.file&&this.triggerEmbedUpdates(r.file.path)),i&&(!r||r.leaf!==e)){const e=i.file;i.file&&setTimeout((()=>{var t;i&&i._loaded&&(null===(t=i.file)||void 0===t?void 0:t.path)===(null==e?void 0:e.path)&&(i.activeLoader||i.loadSceneFiles())}),2e3)}if(i&&i._loaded&&i.isLoaded&&i.excalidrawAPI&&this.ea.onCanvasColorChangeHook&&this.ea.onCanvasColorChangeHook(this.ea,i,i.excalidrawAPI.getAppState().viewBackgroundColor),this.popScope&&(this.popScope(),this.popScope=null),i){const e=this.app.keymap.getRootScope(),t=e.register(["Mod"],"Enter",(()=>!0));e.keys.unshift(e.keys.pop());const n=e.register(["Mod"],"k",(()=>!0));e.keys.unshift(e.keys.pop());const r=e.register(["Mod"],"f",(()=>{const e=this.app.workspace.getActiveViewOfType(ExcalidrawView);return!!e&&(search(e),!0)}));e.keys.unshift(e.keys.pop());const i=this.forceSaveCommand&&"s"===this.forceSaveCommand.hotkeys[0].key&&this.forceSaveCommand.hotkeys[0].modifiers.includes("Ctrl")?e.register(["Ctrl"],"s",(()=>this.forceSaveActiveView(!1))):void 0;i&&e.keys.unshift(e.keys.pop()),this.popScope=()=>{e.unregister(t),e.unregister(n),e.unregister(r),Boolean(i)&&e.unregister(i)}}}registerEventListeners(){this.app.workspace.onLayoutReady((async()=>{const e=(e,t,n)=>{var r;if(e.defaultPrevented)return;const i=e.clipboardData.getData("text/plain");if(i&&i.startsWith('{"type":"excalidraw/clipboard"')){e.preventDefault();try{const e=JSON.parse(i),a=1===e.elements.filter((e=>"text"===e.type)).length;if(!a&&1!==(null===(r=e.elements)||void 0===r?void 0:r.length))return;const o=a?e.elements.filter((e=>"text"===e.type))[0]:e.elements[0];if("image"===o.type){const e=this.filesMaster.get(o.fileId);if(e&&e.path){let r=e.path;const i=n.file,a=this.app.vault.getAbstractFileByPath(r);i&&a&&a instanceof obsidian_module.TFile&&(r=this.app.metadataCache.fileToLinktext(a,i.path)),editorInsertText(t,getLink(this,{path:r}))}return}if("text"===o.type)return void editorInsertText(t,o.rawText);if(o.link)return void editorInsertText(t,`${o.link}`)}catch(e){}}};this.registerEvent(this.app.workspace.on("editor-paste",((t,n,r)=>e(t,n,r))));const t=async(e,t)=>{e instanceof obsidian_module.TFile&&this.isExcalidrawFile(e)&&this.settings.keepInSync&&[EXPORT_TYPES,"excalidraw"].flat().forEach((async n=>{const r=getIMGFilename(t,n),i=app.vault.getAbstractFileByPath(obsidian_module.normalizePath(r));if(i&&i instanceof obsidian_module.TFile){const t=getIMGFilename(e.path,n);await this.app.fileManager.renameFile(i,t)}}))};this.registerEvent(this.app.vault.on("rename",((e,n)=>t(e,n))));const n=async e=>{this.app.workspace.getLeavesOfType("excalidraw").forEach((async t=>{var n,r,i;const a=t.view;if(!(null===(n=a.semaphores)||void 0===n?void 0:n.viewunload)&&a.file&&(a.file.path===e.path||"excalidraw"===e.extension&&`${e.path.substring(0,e.path.lastIndexOf(".excalidraw"))}.md`===a.file.path)){if(null===(r=a.semaphores)||void 0===r?void 0:r.preventReload)return void(a.semaphores.preventReload=!1);if(a.lastSaveTimestamp+3e5<Date.now())return void a.reload(!0,a.file);if("md"===e.extension){if(null===(i=a.semaphores)||void 0===i?void 0:i.embeddableIsEditingSelf)return;const t=new ExcalidrawData(this),n=await this.app.vault.read(e);await t.loadData(n,e,getTextMode(n)),a.synchronizeWithData(t),t.destroy(),(null==a?void 0:a.isDirty())&&(a.autosaveTimer&&a.autosaveFunction&&clearTimeout(a.autosaveTimer),a.autosaveFunction&&a.autosaveFunction())}else a.reload(!0,a.file)}}))};this.registerEvent(this.app.vault.on("modify