Object.defineProperty(mhchemParser$1,"__esModule",{value:!0}),mhchemParser$1.mhchemParser=void0;varmhchemParser=function(){functione(){}returne.toTex=function(e,t){return_mhchemTexify.go(_mhchemParser.go(e,t),"tex"!==t)},e}();function_mhchemCreateTransitions(e){vart,n,r={};for(tine)for(nine[t]){vari=n.split("|");e[t][n].stateArray=i;for(varo=0;o<i.length;o++)r[i[o]]=[]}for(tine)for(nine[t])for(i=e[t][n].stateArray||[],o=0;o<i.length;o++){vara=e[t][n];a.action_=[].concat(a.action_);for(vars=0;s<a.action_.length;s++)"string"==typeofa.action_[s]&&(a.action_[s]={type_:a.action_[s]});for(varl=t.split("|"),c=0;c<l.length;c++)if("*"===i[o]){varT=void0;for(Tinr)r[T].push({pattern:l[c],task:a})}elser[i[o]].push({pattern:l[c],task:a})}returnr}mhchemParser$1.mhchemParser=mhchemParser;var_mhchemParser={go:function(e,t){if(!e)return[];void0===t&&(t="ce");varn,r="0",i={parenthesisLevel:0};e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(varo=10,a=[];;){n!==e?(o=10,n=e):o--;vars=_mhchemParser.stateMachines[t],l=s.transitions[r]||s.transitions["*"];e:for(varc=0;c<l.length;c++){varT=_mhchemParser.patterns.match_(l[c].pattern,e);if(T){for(varQ=l[c].task,d=0;d<Q.action_.length;d++){varu=void0;if(s.actions[Q.action_[d].type_])u=s.actions[Q.action_[d].type_](i,T.match_,Q.action_[d].option);else{if(!_mhchemParser.actions[Q.action_[d].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+Q.action_[d].type_+")"];u=_mhchemParser.actions[Q.action_[d].type_](i,T.match_,Q.action_[d].option)}_mhchemParser.concatArray(a,u)}if(r=Q.nextState||r,!(e.length>0))returna;if(Q.revisit||(e=T.remainder),!Q.toContinue)breake}}if(o<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if(Array.isArray(t))for(varn=0;n<t.length;n++)e.push(t[n]);elsee.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){vart=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]+\}))?/);returnt&&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){vart=_mhchemParser.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))returnt;varn=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);returnn?{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
,renderTopRightUI:(e,t)=>this.obsidianMenu.renderButton(e,t),renderEmbeddableMenu:e=>this.embeddableMenu.renderButtons(e),onPaste:(e,t)=>this.onPaste(e,t),onThemeChange:asynce=>this.onThemeChange(e),ownerDocument:this.ownerDocument,ownerWindow:this.ownerWindow,onDrop:e=>this.onDrop(e),onBeforeTextEdit:e=>this.onBeforeTextEdit(e),onBeforeTextSubmit:(e,t,n,r)=>this.onBeforeTextSubmit(e,t,n,r),onLinkOpen:(e,t)=>this.onLinkOpen(e,t),onLinkHover:(e,t)=>this.onLinkHover(e,t),onContextMenu:T,onViewModeChange:e=>this.onViewModeChange(e),validateEmbeddable:!0,renderWebview:DEVICE.isDesktop,renderEmbeddable:(e,t)=>Q(e,t),renderMermaid:shouldRenderMermaid(),obsidianHostPlugin:this.plugin},d(),t.createElement(a,{},t.createElement(a.Center,{},t.createElement(a.Center.Logo,{},t.createElement(LogoWrapper,{},ICONS.ExcalidrawSword)),t.createElement(a.Center.Heading,{},'Type "Excalidraw" in the Command Palette',t.createElement("br"),"Explore the Obsidian Menu in the top right",t.createElement("br"),"Visit the Script Library",t.createElement("br"),"Find help in the hamburger-menu"),t.createElement(a.Center.Menu,{},t.createElement(a.Center.MenuItemLink,{icon:ICONS.YouTube,href:"https://www.youtube.com/@VisualPKM",shortcut:null,"aria-label":"Visual PKM YouTube Channel"}," Check out the Visual PKM YouTube channel."),t.createElement(a.Center.MenuItemLink,{icon:ICONS.Discord,href:"https://discord.gg/DyfAXFwUHc",shortcut:null,"aria-label":"Join the Visual Thinking Discord Server"}," Join the Visual Thinking Discord Server"),t.createElement(a.Center.MenuItemLink,{icon:ICONS.twitter,href:"https://twitter.com/zsviczian",shortcut:null,"aria-label":"Follow me on Twitter"}," Follow me on Twitter"),t.createElement(a.Center.MenuItemLink,{icon:ICONS.heart,href:"https://ko-fi.com/zsolt",shortcut:null,"aria-label":"Donate to support Excalidraw-Obsidian"},' Say "Thank You" & support the plugin.')))),t.createElement(l,{onTextSubmit:asynce=>{vart,n,r,i,o,a;try{consts=awaitpostOpenAI({systemPrompt:"The user will provide you with a text prompt. Your task is to generate a mermaid diagram based on the prompt. Use the graph, sequenceDiagram, flowchart or classDiagram types based on what best fits the request. Return a single message containing only the mermaid diagram in a codeblock. Avoid the use of `()` parenthesis in the mermaid script.",text:e,instruction:"Return a single message containing only the mermaid diagram in a codeblock."});if(!s)return{error:newError("Request failed")};constl=s.json;if(null==l?void0:l.error)returnconsole.log(s),{error:newError(l.error.message)};if(!(null===(r=null===(n=null===(t=null==l?void0:l.choices)||void0===t?void0:t[0])||void0===n?void0:n.message)||void0===r?void0:r.content))returnconsole.log(s),{error:newError("Generation failed... see console log for details")};letc=null===(a=extractCodeBlocks(null===(o=null===(i=l.choices[0])||void0===i?void0:i.message)||void0===o?void0:o.content)[0])||void0===a?void0:a.data;returnc?(c.startsWith("mermaid")&&(c=c.replace(/^mermaid/,"").trim()),{generatedResponse:c,rateLimit:100,rateLimitRemaining:100}):(console.log(s),{error:newError("Generation failed... see console log for details")})}catch(e){thrownewError("Request failed")}}}),t.createElement(s,{})),u());returnt.createElement(t.Fragment,null,g)}));n.createRoot(this.contentEl).render(p)}updateContainerSize(e,t=!1){constn=this.excalidrawAPI;if(!n)return;constr=()=>{constt=e?n.getSceneElements().filter((t=>t.id===e&&"arrow"!==t.type)):n.getSceneElements().filter(isContainer);t.length>0&&(this.initialContainerSizeUpdate&&(this.semaphores.justLoaded=!0),n.updateContainerSize(t)),this.initialContainerSizeUpdate=!1};t?setTimeout((()=>r()),50):r()}zoomToFit(e=!0,t=!1){if(document.body.querySelector("div.modal-container"))return;constn=this.excalidrawAPI;if(!n||this.semaphores.isEditingText||this.semaphores.preventAutozoom)return;constr=this.plugin.settings.zoomToFitMaxLevel,i=n.getSceneElements().filter((e=>e.width<1e4&&e.height<1e4));app.isMobile&&i.length>1e3||i.length>2500?t&&n.scrollToContent():e?setTime