From b9a01ca547862d992c968cf1025735d2d99f55cd Mon Sep 17 00:00:00 2001 From: blurymind Date: Thu, 5 Sep 2024 23:13:51 +0100 Subject: [PATCH] Updates --- index.html | 4 +- js/main.06152b0e08b70fd763db.js | 1 - js/main.43480244c0cadf3ee66a.js | 1 + ...3db.js => runtime.43480244c0cadf3ee66a.js} | 0 ...63db.js => vendor.43480244c0cadf3ee66a.js} | 0 public/plugins/resources-editor.js | 135 ++++++++++++------ public/version.json | 2 +- public/web-components.js | 54 ++++--- sw.js | 2 +- 9 files changed, 132 insertions(+), 67 deletions(-) delete mode 100644 js/main.06152b0e08b70fd763db.js create mode 100644 js/main.43480244c0cadf3ee66a.js rename js/{runtime.06152b0e08b70fd763db.js => runtime.43480244c0cadf3ee66a.js} (100%) rename js/{vendor.06152b0e08b70fd763db.js => vendor.43480244c0cadf3ee66a.js} (100%) diff --git a/index.html b/index.html index cc54eb028..a0b2142af 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ -Yarn
 
\n

\n + add\n
\n
\n\n ';var n=e("#table"),o=e("#save-btn");this.table=n,this.rows=n.find("tr:not(:hidden)"),e("#save-btn").addClass("hide"),e(".table-add").on("click",this.tableAdd),e(".table-remove").on("click",(function(){console.log({removeThis:this}),e(this).parents("tr").detach()})),i.fn.pop=[].pop,i.fn.shift=[].shift,o.on("click",this.getValue)},this.init(),this.setValue=(e=[])=>{e.forEach(this.tableAdd)}}}.call(this,n("EVdn"),n("EVdn"))},LaP9:function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id="LaP9"},P0sH:function(e,t,n){"use strict";(function(e,i){n.d(t,"a",(function(){return g}));var o=n("owJe"),s=n("W2Rx"),r=n("5dEm"),a=n("INAQ"),l=n("pYPP"),d=n("fkuv"),c=n("2Qx2"),p=n("oj90"),u=n("l8+o"),g=(n("+NoZ"),function(t,g){const h=this;this.utils=p.Utils,this.setTheme=function(t,n){let i=n?n.target.value:t;setTimeout(h.initGrid,50),setTimeout(h.workspace.updateArrows,50),e("#theme-stylesheet").attr("href",p.Utils.getPublicPath(`themes/${i}.css`))},this.setLanguage=function(e,t){const n=t?t.target.value:e;Object(o.load_dictionary)(h.settings.language().split("-")[0]);const i=new CustomEvent("yarnSetLanguage");i.language=n,window.dispatchEvent(i),window.parent.dispatchEvent(i)},this.log=function(e){h.settings.developmentModeEnabled()&&console.log(e)},this.setDocumentType=function(e,t){const n=t?t.target.value:e;h.settings.documentType(n),h.log("Set doc type",e,app.data.inkCompiler),"ink"===n?(null===app.data.inkCompiler&&(app.data.inkCompiler=new app.data.InkCompiler),c.a.addGlobalScopeToInkDoc(),app.setMarkupLanguage("html")):app.data.inkCompiler=null,app.updateNodeLinks();const i=new CustomEvent("yarnSetDocumentType");i.language=n,window.dispatchEvent(i),window.parent.dispatchEvent(i)},this.setMarkupLanguage=function(e,t){const n=t?t.target.value:e;app.settings.markupLanguage(n),h.richTextFormatter=new u.a(h),h.mustRefreshNodes.notifySubscribers()},this.setGistPluginsFile=function(e,t){const n=t?t.target.value:e;app.settings.gistPluginsFile(n)},this.setFiletypeVersion=function(e,t){const n=t?t.target.value:e;h.filetypeVersion=n},this.setGistCredentials=function(e,t){const{token:n,file:i}=e;c.a.storage.setCredentials(n,i)},this.input=new a.a(h),this.settings=new l.a(h),this.workspace=new r.a(h),this.ui=new d.a(h),this.richTextFormatter=new u.a(h),this.data=c.a,this.name=i.observable(t),this.version=i.observable(g),this.editing=i.observable(null),this.nodes=i.observableArray([]),this.tags=i.observableArray([]),this.mustRefreshNodes=i.observable(),this.mustUpdateTags=!0,this.nodeHistory=[],this.nodeFuture=[],this.editingHistory=[],this.editingSaveHistoryTimeout=null,this.focusedNodeIdx=-1,this.isElectron=!1,this.editor=null,this.nodeVisitHistory=[],this.plugins={pluginStorage:{}},this.clipboard="",this.nodeClipboard=[],this.speachInstance=null,this.editingPath=i.observable(null),this.$searchField=e(".search-field"),this.isEditorInPreviewMode=!1,this.isEditorInPlayMode=i.observable(!1),this.isEditorSplit=!1,this.isEditorFocused=!1,this.editorResizeHandleOptions={handleSelector:"#editor-resize-handle",resizeHeight:!1,resizeWidthFrom:"right",onDragStart:function(){h.isSplitEditorInFocus=!0,e("#node-editor").removeClass("split-editor-out-of-focus")},onDragEnd:function(){h.editor.resize(),h.settings.editorSplitSize(e("#editor-form").width())}},this.inEditor=()=>(h.editing()||h.isEditorSplit&&h.isEditorFocused)&&!h.ui.isDialogOpen(),this.inWorkspace=()=>(!h.editing()||h.isEditorSplit&&!1===h.isEditorFocused)&&!h.ui.isDialogOpen(),this.run=function(){var t="Unknown OS";-1!=navigator.platform.indexOf("Win")&&(t="Windows"),-1!=navigator.platform.indexOf("Mac")&&(t="MacOS"),-1!=navigator.platform.indexOf("X11")&&(t="UNIX"),-1!=navigator.platform.indexOf("Linux")&&(t="Linux"),-1!=navigator.platform.indexOf("Linux")&&(t="Linux"),h.isElectron=navigator.userAgent.toLowerCase().includes("electron");var n=navigator.userAgent||navigator.vendor||window.opera;let o;/android|iPad|iPhone|iPod/.test(n.toLowerCase())&&!window.MSStream&&(t="mobile"),"Windows"==t&&(h.workspace.zoomSpeed=.1),window.addEventListener("beforeunload",e=>(this.data.saveAppStateToLocalStorage(),null)),window.addEventListener("DOMContentLoaded",e=>{if(h.electron){const e=h.electron.remote.process.argv.length>1?h.electron.remote.process.argv[1]:null;if(e&&app.fs.existsSync(e))return void this.data.openFileFromFilePath(e)}this.data.loadAppStateFromLocalStorage();const t=new URL(window.location),n=t.searchParams.get("text")||t.searchParams.get("url");null!==n&&h.insertTextAtCursor(n+"\n",!0)});const s=e("#addPwa")[0];s.style.display="none",window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),o=e,s.style.display="block",s.addEventListener("click",e=>{s.style.display="none",o.prompt(),o.userChoice.then(e=>{"accepted"===e.outcome?(h.log("User accepted the A2HS prompt"),s.style.display="none"):h.log("User dismissed the A2HS prompt"),o=null})})}),e("#app").show(),i.applyBindings(h,e("#app")[0]),h.editingVisualStudioCodeFile()||h.newNode().title("Start"),h.settings.apply(),e(".search-title input").click(h.updateSearch),e(".search-body input").click(h.updateSearch),e(".search-tags input").click(h.updateSearch),h.$searchField.on("input",h.updateSearch),h.$searchField.on("keyup",(function(e){27==e.keyCode?h.clearSearch():h.searchWarp()})),"mobile"===t&&h.workspace.setZoom(3),e(window).on("resize",(function(){h.ui.isScreenNarrow()&&h.editing()&&h.isEditorSplit&&h.toggleEditorView(),h.workspace.updateArrows(),h.initGrid()})),setTimeout(h.initGrid,50),this.guessPopUpHelper=function(){/color=#([a-zA-Z0-9]{3,6})$/.test(h.getTagBeforeCursor())&&h.insertColorCode()},this.insertEmoji=function(){this.emPicker.toggle(),h.togglePreviewMode(!0),e("#emojiPicker-container").css({left:h.input.mouse.x-200,top:h.input.mouse.y-125}),e("#emojiPicker-container").show()},this.insertColorCode=function(){e("#colorPicker-container").is(":visible")||(e("#colorPicker").spectrum("set",h.editor.getSelectedText()),e("#colorPicker").spectrum("toggle"),e("#colorPicker-container").css({left:h.input.mouse.x-70,top:h.input.mouse.y-50}),e("#colorPicker-container").show(),h.togglePreviewMode(!0),setTimeout(()=>{const t=e("#colorPicker").spectrum("get");h.applyPickerColorEditor(t)},100))},this.applyPickerColorEditor=function(e){const t=JSON.parse(JSON.stringify(h.editor.selection.getRange()));h.editor.selection.setRange(t);const n=e.toHexString().replace("#","");h.editor.session.replace(t,n),h.editor.selection.setRange({start:h.editor.getCursorPosition(),end:{row:h.editor.getCursorPosition().row,column:h.editor.getCursorPosition().column-n.length}}),h.togglePreviewMode(!0)},document.addEventListener("contextmenu",(function(e){h.editing()&&e.preventDefault()}),!1),document.ondragover=document.ondrop=e=>{e.preventDefault()},document.body.ondrop=e=>{e.preventDefault();for(var t=0;t{const t=e.data;switch(t.type){case"UpdateNode":h.nodes().forEach(e=>{e.title().trim()===t.payload.originalNodeTitle.trim()&&(e.title(t.payload.title),e.tags(t.payload.tags),e.body(t.payload.body),h.setYarnDocumentIsDirty())})}});var r=new CustomEvent("yarnReady");r.document=document,r.data=c.a,r.app=this,window.dispatchEvent(r),window.parent.dispatchEvent(r);const a=new URLSearchParams(window.location.href.split("?")[1]),l=a.get("gist"),d=a.get("fileName");l&&d&&fetch("https://api.github.com/gists/"+l).then(e=>e.json()).then(e=>{const t=e.files[d].content;c.a.openGist(t,d)})},this.limitNodesUpdate=function(e){h.nodes.extend({rateLimit:{method:"notifyWhenChangesStop",timeout:250}}),e(),h.nodes.limit(e=>()=>e())},this.getNodesConnectedTo=function(e){var t=[],n=h.nodes();for(var i in n)if(n[i]!=e&&n[i].isConnectedTo(e,!0)){var o=!1;for(var s in t)if(t[s]==n[i]){o=!0;break}o||t.push(n[i])}return t},this.matchConnectedColorID=function(e){var t=h.getNodesConnectedTo(e);for(var n in t)t[n].colorID(e.colorID())},this.quit=function(){h.isElectron},this.canEditNodeMeta=function(e){return"ink"!==app.settings.documentType()||e.trim()!==c.a.InkGlobalScopeNodeName},this.sanitiseNodeTitle=function(){"ink"===app.settings.documentType()&&(app.editing().title().startsWith("function ")||app.editing().title(app.editing().title().replace(/[ ]/g,"_")))},this.validateTitle=function(){var t=document.getElementById("editorTitle").value,n=e("#editorTitle");h.getOtherNodeTitles().includes(t)||h.titleExistsTwice(t)?(n.attr("class","title title-error"),n.attr("title","Another node has the same title")):"yarn"!==app.settings.documentType()||RegExp("^[a-z0-9]+$","i").test(t)?(n.removeAttr("title"),n.removeClass("title-error")):(n.attr("class","title title-error"),n.attr("title","Only upper or lower case letters and numbers are allowed in a node title."))},this.refreshWindowTitle=function(){let e="";"LOCAL"===app.settings.lastStorageHost()?e="Yarn - "+(c.a.editingPath()||c.a.editingName())+" "+(c.a.isDocumentDirty()?"*":""):"GIST"===app.settings.lastStorageHost()&&(e="Gist - "+(c.a.editingPath()||c.a.editingName())+" "+(c.a.isDocumentDirty()?"*":"")),h.electron?h.electron.remote.getCurrentWindow().setTitle(e):document.title=e},this.usingVisualStudioCodeExtension=function(){return!!window.vsCodeApi},this.editingVisualStudioCodeFile=function(){return!0===window.editingVsCodeFile},this.setYarnDocumentIsDirty=function(){h.usingVisualStudioCodeExtension()&&h.editingVisualStudioCodeFile()&&c.a.getSaveData(c.a.editingType()).then(e=>{window.vsCodeApi.postMessage({type:"DocumentEdit",payload:e})})},this.recordNodeAction=function(e,t){if(h.nodeFuture.length>0){for(var n=0;n=0&&h.nodes.splice(t,1),h.updateNodeLinks()}var n=null;if(n="undo"==e?h.nodeHistory.pop():h.nodeFuture.pop()){var i=n.action,o=n.node;"undo"==e?("created"==i?(n.lastX=o.x(),n.lastY=o.y(),t(o)):"removed"==i&&h.recreateNode(o,n.lastX,n.lastY),h.nodeFuture.push(n),h.setYarnDocumentIsDirty()):("created"==i?h.recreateNode(o,n.lastX,n.lastY):"removed"==i&&t(o),h.nodeHistory.push(n),h.setYarnDocumentIsDirty())}},this.recreateNode=function(e,t,n){h.nodes.push(e),e.moveTo(t,n),h.updateNodeLinks()},this.setSelectedColors=function(e){var t=h.workspace.getSelectedNodes();for(var n in t.splice(t.indexOf(e),1),t)t[n].colorID(e.colorID())},this.pasteNodes=function(){h.nodeClipboard.length&&(h.workspace.deselectAll(),h.nodeClipboard.forEach((function(e){var t=new s.a({title:h.getUniqueTitle(e.title()),body:e.body(),tags:e.tags(),colorID:e.colorID(),x:e.createX,y:e.createY});h.nodes.push(t),h.workspace.selectNodes(t),h.recordNodeAction("created",t)})),h.updateNodeLinks())},this.confirmDeleteNodes=function(e){const t=Array.isArray(e)?void 0:e,n=Array.isArray(e)?[...e]:t&&t.selected?[...h.workspace.getSelectedNodes()]:[e];n.length&&Swal.fire({title:"Are you sure?",text:`${n.length} ${1===n.length?"node":"nodes"} will be deleted.`,icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!",cancelButtonText:"No, cancel!",reverseButtons:!0}).then(e=>{e.value&&h.deleteNodes(n)})},this.deleteNodes=function(e){const t=Array.isArray(e)?e:[e],n=[];for(let e=t.length-1;e>=0;--e)n.push(t[e].remove());Promise.all(n).then(()=>{h.limitNodesUpdate(()=>{for(let e=t.length-1;e>=0;--e)h.inEditor()&&h.editing()===t[e]&&h.closeEditor(),h.deleteNode(t[e]);h.updateNodeLinks(),h.workspace.deselectNodes(t),h.workspace.updateArrows()})})},this.deleteNode=function(e){const t=h.nodes.indexOf(e);t>=0&&(h.recordNodeAction("removed",e),h.nodes.splice(t,1)),h.setYarnDocumentIsDirty()},this.cloneNodeArray=function(e){return e.map((function(e){return new s.a({title:e.title(),body:e.body(),tags:e.tags(),colorID:e.colorID(),x:e.x()+10,y:e.y()+10})}))},this.newNode=function(e=!0){var t=new s.a;return h.nodes.push(t),e&&h.updateNodeLinks(),h.recordNodeAction("created",t),t},this.newNodeAt=function(e,t){var n=new s.a({x:e-100,y:t-100});return h.nodes.push(n),h.updateNodeLinks(),h.recordNodeAction("created",n),n},this.searchTextInEditor=function(e=!0){e?h.editor.execCommand("find"):h.editor.searchBox&&h.editor.searchBox.hide()},this.showRandomQuote=function(){e.ajax({url:"https://api.forismatic.com/api/1.0/?",dataType:"jsonp",data:"method=getQuote&format=jsonp&lang=en&jsonp=?",success:function(e){Swal.fire({text:e.quoteText+"\n\n-"+e.quoteAuthor})}})},this.editNode=function(t,n=!0){if(!n&&!t.active())return;if(h.settings.alwaysOpenNodesInVisualStudioCodeEditor())return void h.editNodeInVisualStudioCodeEditor(t);h.editing()&&h.editing()!==t&&h.saveNode(!1),h.isEditorInPlayMode()&&h.togglePlayMode(!1),h.isEditorInPreviewMode&&h.togglePreviewMode(!1),t.oldTitle=t.title(),h.editing(t),h.mustUpdateTags=!0,e("#node-editor-background").css({opacity:0}).transition({opacity:1},250),e("#node-editor").css({y:"-100",opacity:0}).transition({y:"0",opacity:1},250),h.editor=ace.edit("editor"),h.editor.setOptions({scrollPastEnd:.5}),h.editor.focus(),h.editor.navigateFileEnd(),e("#colorPicker").spectrum({flat:!0,showButtons:!1,showInput:!0,showPalette:!0,preferredFormat:"hex",palette:[["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"]],move:function(e){h.applyPickerColorEditor(e)},clickoutFiresChange:!0});const i=ace.require("ace/ext/language_tools"),s=p.Utils.createAutocompleter("ink"===app.settings.documentType()?["divert.target"]:["string.llink","string.rlink"],app.getOtherNodeTitles().map(e=>{const n=h.getNodeByTitle(e);return{word:e,title:e,about:`${n.tags().length>0?`tags: ${n.tags()}
`:""}Preview:
${n.clippedBody()}`,titleStyle:t.titleStyles[n.colorID()]}}),"Node Link");i.setCompleters([s,i.keyWordCompleter,i.textCompleter,i.snippetCompleter]);let r=void 0;h.editor.getSession().on("change",(function(e){const t=h.settings.autoCloseTags();if("insert"===e.action&&t){if(h.richTextFormatter.justInsertedAutoComplete)return void(h.richTextFormatter.justInsertedAutoComplete=!1);r&&clearTimeout(r),r=setTimeout(()=>{r=void 0,h.richTextFormatter.completableTags.forEach(e=>{if(h.getTagBeforeCursor()===e.Start){h.richTextFormatter.justInsertedAutoComplete=!0;let t=e.Completion,n=e.Offset;h.settings.autoCloseBrackets()&&e.BehaviorCompletion&&(t=e.BehaviorCompletion,n+=1),e.Completion&&h.insertTextAtCursor(t),e.Offset&&h.moveEditCursor(n),e.Func&&e.Func()}})},200)}})),this.emPicker=new EmojiPicker(document.getElementById("emojiPickerDom"),e=>{h.insertTextAtCursor(e.char),this.emPicker.toggle(),h.togglePreviewMode(!1)}),Object(o.enable_spellcheck)(),h.toggleInvertColors(),h.toggleShowCounter(),h.toggleSpellCheck(),h.validateTitle(),h.updateEditorStats(),h.updateEditorOptions(),h.$searchField.val().length>0&&e(".search-body input").is(":checked")&&h.editor.findAll(h.$searchField.val()),h.settings.editorSplit()&&(h.splitEditor(),h.workspace.warpToNodeByIdx(t.index()-1)),"right"===h.settings.editorSplitDirection()?(e("#editor-form").addClass("split-editor-right"),e("#editor-resize-handle").addClass("float-right")):(e("#editor-form").removeClass("split-editor-right"),e("#editor-resize-handle").removeClass("float-right")),e(".node-editor").on("pointerdown","> *",(function(e){h.isEditorSplit&&(h.focusEditor(!0),e.stopPropagation())})),e(".app-info").hide(),h.editor.resize(),null!=t.undoManager&&h.editor.session.setUndoManager(t.undoManager);var a=new CustomEvent("yarnEditorOpen");a.document=document,a.data=c.a,a.app=app,window.dispatchEvent(a),window.parent.dispatchEvent(a)},this.splitEditor=function(){h.isEditorSplit=!0,h.focusEditor(!0),h.settings.editorSplit(!0),h.editorResizeHandleOptions.resizeWidthFrom="right"===h.settings.editorSplitDirection()?"left":"right",e("#editor-form").width(h.settings.editorSplitSize()).addClass("split-editor").toggleClass("split-editor-right","right"===h.settings.editorSplitDirection()).resizable(h.editorResizeHandleOptions),e("#node-editor-background").addClass("hidden"),e("#node-editor").css({"z-index":10002}),e("#editor-resize-handle").removeClass("hidden").toggleClass("float-right","right"===h.settings.editorSplitDirection()),e("#split-editor-button").addClass("hidden"),e("#snap-editor-button").removeClass("hidden"),e("#exit-editor").removeClass("hidden"),e("#full-size-editor-button").removeClass("hidden"),e("#split-button-separator").removeClass("hidden"),h.ui.checkAndMoveAppButtons()},this.toggleEditorView=function(){h.settings.editorSplit(!h.settings.editorSplit()),h.reopenEditor()},this.reopenEditor=function(){h.saveNode();let e=h.editing();h.closeEditor(),setTimeout(()=>{h.editNode(e)},250)},this.editorSnapToggle=function(){h.settings.editorSplitDirection("right"===h.settings.editorSplitDirection()?"left":"right"),h.reopenEditor()},this.focusEditor=function(t){!0===t?(e("#node-editor").removeClass("split-editor-unfocused"),h.isEditorFocused=!0):(e("#node-editor").addClass("split-editor-unfocused"),h.isEditorFocused=!1)},this.getSplitEditorXOffset=function(){let t=0;return h.inEditor()&&h.settings.editorSplit()&&(t=e("#editor-form").width()/2,"right"===h.settings.editorSplitDirection()&&(t*=-1)),t},this.editNodeInVisualStudioCodeEditor=function(e){h.usingVisualStudioCodeExtension()?(h.setYarnDocumentIsDirty(),window.vsCodeApi.postMessage({type:"OpenNode",payload:{title:e.title().trim(),tags:e.tags().trim(),body:h.trimBodyLinks(e.body().trim())}})):console.error("Tried to open node in Visual Studio Code text editor but we're not in the Visual Studio Code extension")},this.chooseRelativePathImage=function(e){h.insertTextAtCursor(e)},this.getNodeByTitle=function(e){return h.nodes().find(t=>t.title().trim().toLowerCase()===e.trim().toLowerCase())},this.openNodeByTitle=function(e,t=""){h.isEditorInPlayMode()&&h.togglePlayMode(),h.makeNodeWithName(e);const n=h.nodes().find(t=>t.title().trim().toLowerCase()===e.trim().toLowerCase());n&&(h.editNode(n,!0),t&&setTimeout(()=>h.editor.find(t),200))},this.openLastEditedNode=function(){if(0===h.nodeVisitHistory.length)h.saveNode(),h.closeEditor();else{const e=h.nodeVisitHistory.pop();h.propagateUpdateFromNode(h.editing()),h.openNodeByTitle(e)}},this.getSpellCheckSuggestionItems=function(){var e=Object(o.suggest_word_for_misspelled)(h.editor.getSelectedText());if(e){var t={};return e.forEach(e=>{t[e]={name:e,icon:"edit",callback:e=>{h.insertTextAtCursor(e)}}}),t}return!1},this.getThesaurusItems=function(){var e=n("GLdW")(h.editor.getSelectedText());if(!e)return!1;var t=[];if(Object.keys(e).forEach((function(n){e[n].forEach((function(e){t.includes(e)||e===n||t.push(e)}))})),t.length>0){var i={};return t.forEach(e=>{i[e]={name:e,icon:"edit",callback:e=>{h.insertTextAtCursor(e)}}}),i}return!1},this.toggleSpellCheck=function(){setTimeout((function(){h.settings.spellcheckEnabled()?Object(o.enable_spellcheck)():Object(o.disable_spellcheck)()}),50)},this.toggleInvertColors=function(){const t=h.settings.invertColorsEnabled()?{filter:"invert(100%)"}:{filter:"invert(0%)"};e("#app").css(t),e("#app-bg").css(t),e(".tooltip").css(t),e(".node .body").css(t),e(".editor-container .editor-preview").css(t)},this.initGrid=function(){if(h.settings.snapGridEnabled()){var t=e(window).width(),n=e(window).height();e("#grid-canvas").attr("width",t),e("#grid-canvas").attr("height",n),e("#gridSize").attr("disabled",!1),h.workspace.gridContext.strokeStyle=h.workspace.gridContext.fillStyle=e(".grid-canvas").css("color")}else e("#gridSize").attr("disabled",!0);app.workspace.updateGrid()},this.toggleShowCounter=function(){h.settings.editorStatsEnabled()?e(".node-editor .form .editor-counter").css({display:"initial"}):e(".node-editor .form .editor-counter").css({display:"none"})},this.toggleAutocompleteSuggestions=function(){h.settings.autocompleteSuggestionsEnabled(!h.settings.autocompleteSuggestionsEnabled()),h.updateEditorOptions()},this.toggleAutoCloseBrackets=function(){h.settings.autoCloseBrackets(!h.settings.autoCloseBrackets()),h.updateEditorOptions()},this.updateEditorOptions=function(){h.editor.setOptions({enableBasicAutocompletion:app.settings.autocompleteSuggestionsEnabled(),enableLiveAutocompletion:app.settings.autocompleteSuggestionsEnabled(),behavioursEnabled:app.settings.autoCloseBrackets()})},this.togglePreviewMode=function(t){const n=e(".editor")[0],i=e("#editor-preview")[0];h.isEditorInPreviewMode=t,app.ui.dispatchEvent("yarnInPreviewMode"),t?(e(".bbcode-toolbar").addClass("hidden"),n.style.display="none",i.style.display="block",i.innerHTML=h.richTextFormatter.richTextToHtml(h.editing().body(),!0),i.scrollTop=h.editor.renderer.scrollTop):(e(".bbcode-toolbar").removeClass("hidden"),h.editor.session.setScrollTop(i.scrollTop),i.innerHTML="",i.style.display="none",n.style.display="flex",h.editor.focus(),h.editor.resize(),e("#colorPicker-container").is(":visible")&&e("#colorPicker-container").hide(),e("#emojiPicker-container").is(":visible")&&e("#emojiPicker-container").hide())},this.appendText=function(e){h.editing().body(h.editing().body()+e);const t=h.editor.session.getLength()-1,n=h.editor.session.getLine(t).length;h.editor.gotoLine(t+1,n)},this.moveEditCursor=function(e){const t=h.editor.getCursorPosition();h.editor.gotoLine(t.row+1,t.column+e),h.editor.focus()},this.insertTextAtCursor=function(e,t=!1){if(!h.editing())return;h.editor.session.replace(h.editor.selection.getRange(),"");const n=h.editor.getCursorPosition();if(h.editor.session.insert(n,e),t){const e=h.editor.getCursorPosition();editor.scrollToLine(e.row,!0,!0,(function(){})),h.editor.focus()}h.updateEditorStats(),h.editor.focus()},this.getTagBeforeCursor=function(){const e=h.editor.getSelectionRange(),t=e.start.row,n=h.editor.session.getLine(t).substring(e.start.column-2,e.start.column+2);if(!n)return"";if("ink"===app.settings.documentType()){if(["->"].includes(n.trim()))return n.trim()}else if(["[[","<<"].includes(n.trim())||n.includes("|"))return n.trim();return h.richTextFormatter.identifyTag(n)},this.saveNode=function(){const t=h.editing();if(t){const n=e("#editorTitle")[0],i=h.getFutureEditedNodeTitle();n.value=i,t.title(i),t.body(h.trimBodyLinks(t.body().trim())),h.makeNewNodesFromLinks(),h.propagateUpdateFromNode(t),h.workspace.updateArrows(),setTimeout(h.updateSearch,600),h.setYarnDocumentIsDirty(),app.ui.dispatchEvent("yarnSavedNode")}},this.closeEditor=function(){h.editing().undoManager=h.editor.session.getUndoManager(),e("#node-editor-background").transition({opacity:0},250),e("#node-editor").transition({y:"-100",opacity:0},250,(function(e){h.editing(null),h.editor.destroy(),h.editor=null,this.emPicker=null})),h.isEditorSplit=!1,h.isEditorFocused=!1,e(".app-info").show(),app.ui.resetAppButtonsLocation(),h.isEditorInPlayMode()&&h.togglePlayMode(!1),h.isEditorInPreviewMode&&h.togglePreviewMode(!1)},this.convertMarkup=function(){h.nodes().forEach(e=>{e.body(h.richTextFormatter.convert(e.body()))})},this.updateSearch=p.Utils.debounce((function(){const t=app.$searchField.val().toLowerCase();for(var n=0;n{n.includes(e)||t.push(e)}),e.linkedFrom().forEach(e=>{n.includes(e)||t.push(e)}))},this.updateTagsRepository=p.Utils.debounce((function(){if(!app.mustUpdateTags)return;app.mustUpdateTags=!1;h.tags().forEach(e=>e.count=0),h.nodes().forEach(e=>{p.Utils.uniqueSplit(e.tags()," ").forEach(e=>{const t=h.tags().find(t=>t.text==e);if(t)++t.count;else{const t=(()=>{const e=h.tags().map(e=>e.id);for(let t=1;;++t)if(!e.includes(t))return t})();h.tags.push({id:t,style:"tag-style-"+t,text:e,count:1})}})});let e=h.tags().length;for(;e--;)0===h.tags()[e].count&&h.tags().splice(e,1)}),500),this.makeNewNodesFromLinks=function(){if(!h.settings.createNodesEnabled())return console.info("Autocreate new nodes disabled");var e=h.editing().getLinksInNode();if(null!=e)for(var t=0;t0&&!n.includes(e)&&e!=h.editing().title()&&h.newNodeAt(h.editing().x()+t,h.editing().y()-120).title(e)},this.titleExistsTwice=function(e){return h.nodes().filter(t=>t.title().trim()===e.trim()).length>1},this.getFutureEditedNodeTitle=function(){const t=e("#editorTitle")[0];return h.getUniqueTitle(t.value.trim())},this.getOtherNodeTitles=function(){const e=[];return h.nodes().forEach(t=>{if(!h.editing()||t.title()!==h.editing().title()){if("ink"===app.settings.documentType()&&t.title().trim()===c.a.InkGlobalScopeNodeName)return;e.push(t.title().trim())}}),e},this.getHighlightedText=function(t){t=(t=(t=(t=(t=(t=(t=(t=t.replace(/\/g,">")).replace(/\<\<(.*?)\>\>/g,'

<<

$1

>>

')).replace(/\[\[([^\|]*?)\]\]/g,'

[[

$1

]]

')).replace(/\[\[([^\[\]]*?)\|([^\[\]]*?)\]\]/g,'

[[

$1

|

$2

]]

')).replace(/[^:]\/\/(.*)?($|\n)/g,'//$1\n')).replace(/\/\*((.|[\r\n])*)?\*\//gm,'/*$1*/')).replace(/\/\%((.|[\r\n])*)?\%\//gm,'/%$1%/');var n=e("
");return n[0].innerHTML=t,n.find(".comment").each((function(){e(this).find("p").each((function(){e(this).removeClass()}))})),n.find(".linkname").each((function(){var t=e(this).text(),n=!1;for(var i in h.nodes())if(h.nodes()[i].title().toLowerCase()==t.toLowerCase()){n=!0;break}n||e(this).removeClass("linkname")})),t=n[0].innerHTML},this.updateLineNumbers=function(t){for(var n=t.split("\n"),i="",o=0;o0)&&(i+=o+1+"
");e(".editor-container .lines").html(i)},this.moveNodes=function(e,t){for(var n in h.nodes()){var i=h.nodes()[n];i.moveTo(i.x()+e,i.y()+t)}},this.getFirstFoundNode=function(e){return h.nodes().find(t=>t.title().toLowerCase().trim()===e)},this.searchWarp=function(){var e=h.$searchField.val().toLowerCase().trim();if(""===e)h.workspace.warpToNodeByIdx(0);else{const t=h.getFirstFoundNode(e);h.workspace.warpToNodeByIdx(h.nodes.indexOf(t))}},this.clearSearch=function(){h.$searchField.val(""),h.updateSearch()},this.updateEditorStats=function(){var t=h.editor.getSession().getValue(),n=h.editor.getCursorPosition(),i=t.split("\n");e(".editor-counter .character-count").html(t.length),e(".editor-counter .line-count").html(i.length),e(".editor-counter .row-index").html(n.row),e(".editor-counter .column-index").html(n.column),c.a.saveAppStateToLocalStorage()},this.getUniqueTitle=function(e){var t=h.getOtherNodeTitles();if(e&&!t.includes(e))return e;var n=e||"Node",i=2;const o=n.match(/^(.*)(_([0-9]+))$/);if(o&&4===o.length&&(n=o[1],i=Number(o[3])),!t.includes(n))return n;for(;;++i){var s=n+"_"+i;if(!t.includes(s))return s}},this.navigateToNodeDuringPlayTest=function(e,t=""){h.openNodeByTitle(e,t),h.togglePlayMode(!0),app.workspace.warpToNode(app.getFirstFoundNode(e))}})}).call(this,n("EVdn"),n("Z1dp"))},"P85/":function(e,t,n){},VgQK:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function({app:e,createButton:t,onLoad:n,setPluginStore:i,getGistFileUrl:o,getSelectedResourceUrl:s,updateUrlParams:r}){const a=this;this.name="ResourcesEditor",this.resourcesFileUrl="",this.resourcesFileContent="",this.initResourcesFile=()=>new Promise(t=>{e.data.storage.getGistFiles(e.ui.openSettingsDialog).then(({filesInGist:n})=>{const i=Object.values(n).find(e=>"resources.json"===e.filename);if(i)return this.resourcesFileUrl=i.raw_url,e.data.storage.getContentOrRaw(i.content,i.raw_url).then(e=>{t({...i,content:e})});e.data.storage.editGistFile("resources.json","{}").then(({file:e})=>{console.log({result:result}),ToastWc.show({type:"success",content:"Created a resources.json file",time:3e3}),this.resourcesFileUrl=e.raw_url,t(e)})})}),this.onCommitResourceFiles=t=>{this.isBusy("Uploading changes to gist..."),e.data.storage.editGistFile("resources.json",t).then(e=>{ToastWc.show({type:"info",content:"Saved resources on gist",time:1e3}),this.isBusy("Updating list..."),this.updateResourcesList(t)})},this.updateResourcesList=e=>{const t=JSON.parse(e),n=Object.keys(JSON.parse(e)),i=n.map(e=>{const n=t[e],i="committed"in n;return``});document.getElementById("resource-list-label").innerHTML=n.length+" files",document.getElementById("resources-editor-select").innerHTML=i.join(""),this.onSelectScroll({target:document.getElementById("resources-editor-select")}),this.isBusy("")},this.onOpenResourcesEditor=async()=>{a.name;const{value:t}=await Swal.fire({showCloseButton:!1,showCancelButton:!1,title:"",html:'\n
\n \n \n Files in\n \n
\n ',showConfirmButton:!1,focusConfirm:!1,customClass:"swal-wide",width:window.innerWidth-20+"px",onBeforeOpen:()=>{},onAfterClose:()=>{r("selectedResource","")},onOpen:()=>{this.isBusy=e=>{document.querySelector("spinner-component").isBusy(e)},this.isBusy("Loading files from gist..."),document.querySelector("resources-component").addEventListener("isBusy",e=>{this.isBusy(e.detail.message)}),document.querySelector("resources-component").addEventListener("commitNewContent",t=>{const n=t.detail;e.data.storage.editGistFile("resources.json",n).then(e=>{ToastWc.show({type:"info",content:"Saved resources on gist",time:1e3}),this.isBusy("Updating list..."),document.querySelector("resources-component").updateResourcesList(n)})}),this.initResourcesFile().then(t=>{ToastWc.show({type:"success",content:"Editing resources.json at\n"+t.raw_url,time:2e3,onClick:()=>window.open(t.raw_url,"_blank")}),r("selectedResource","none"),document.querySelector("resources-component").init({file:t,darkMode:"dracula"===e.settings.theme()})})},preConfirm:()=>(i(a.name,"resourcesEditorOpen",!1),"")})},n(()=>{this.gistId=o(),o()&&s()&&this.onOpenResourcesEditor(this.resourcesFileContent),t(a.name,{name:"Resources",attachTo:e.settings.developmentModeEnabled()?"appHeader":"fileMenuDropdown",onClick:"onOpenResourcesEditor()",className:"item",id:"resourcesEditorButton",iconName:"image",...e.settings.developmentModeEnabled()?{className:"bbcode-button",style:"padding: 0 10px; margin-top: 3px; font-size: small",as:"span"}:{}})})}},W2Rx:function(e,t,n){"use strict";(function(e,i){n.d(t,"a",(function(){return r}));var o=n("oj90");let s=0;let r=function(t={}){const n=this;this.titleStyles=["title-style-1","title-style-2","title-style-3","title-style-4","title-style-5","title-style-6","title-style-7","title-style-8","title-style-9"],this.index=e.observable(s++),this.title=e.observable(t.title||app.getUniqueTitle()),this.tags=e.observable(t.tags||""),this.body=e.observable(t.body||""),this.active=e.observable(t.active||!0),this.width=200,this.height=200,this.tempOpacity=null,this.style=null,this.colorID=e.observable(t.colorID||0),this.checked=!1,this.selected=!1,this.createX=t.x||null,this.createY=t.y||null,this.undoManager=null,this.clippedTags=e.computed((function(){return app.updateTagsRepository(),o.Utils.uniqueSplit(n.tags()," ").map(e=>app.tags().find(t=>t.text===e)).filter(e=>e)}),this),this.clippedBody=e.computed((function(){if(app.ui.isScreenNarrow()&&app.editing())return;app.mustRefreshNodes();let e=app.getHighlightedText(this.body());return e=app.richTextFormatter.richTextToHtml(e),e=e.substr(0,225),e}),this),this.linkedTo=e.observableArray(),this.linkedFrom=e.observableArray(),this.element=null,this.canDoubleClick=!0,this.create=function(){if(n.style=window.getComputedStyle(i(n.element).get(0)),n.createX&&n.createY)n.x(n.createX),n.y(n.createY);else{let e=i(n.element).parent();n.x((-e.offset().left+i(window).width()/2-100)/app.workspace.scale),n.y((-e.offset().top+i(window).height()/2-100)/app.workspace.scale)}app.workspace.bringToFront(n.element),app.workspace.startUpdatingArrows(),i(n.element).css({opacity:0,scale:.8,y:"-=80px",rotate:"45deg"}).transition({opacity:1,scale:1,y:"+=80px",rotate:"0deg"},250,"easeInQuad",(function(){app.workspace.stopUpdatingArrows(),app.workspace.updateArrows()})),n.drag(),i(n.element).on("dblclick",(function(){n.canDoubleClick&&app.editNode(n)})),o.Utils.addDoubleTapDetector(n.element,(function(){n.canDoubleClick&&app.editNode(n)})),i(n.element).on("click",(function(e){e.ctrlKey&&(n.selected?app.workspace.deselectNodes(n):app.workspace.selectNodes(n))}))},this.setSelected=function(e){n.selected=e,n.selected?i(n.element).addClass("selected"):i(n.element).removeClass("selected")},this.toggleSelected=function(){n.setSelected(!n.selected)},this.x=function(e){if(null!=e&&i(n.element).css({x:Math.floor(e)}),n.style)return Math.floor(new WebKitCSSMatrix(n.style.webkitTransform).m41)},this.y=function(e){if(null!=e&&i(n.element).css({y:Math.floor(e)}),n.style)return Math.floor(new WebKitCSSMatrix(n.style.webkitTransform).m42)},this.resetDoubleClick=function(){n.canDoubleClick=!0},this.cycleColorDown=function(){n.doCycleColorDown(),setTimeout(n.resetDoubleClick,500),n.canDoubleClick=!1,app.input.isShiftDown&&app.matchConnectedColorID(n),n.selected&&app.setSelectedColors(n),app.setYarnDocumentIsDirty()},this.cycleColorUp=function(){n.doCycleColorUp(),setTimeout(n.resetDoubleClick,500),n.canDoubleClick=!1,app.input.isShiftDown&&app.matchConnectedColorID(n),n.selected&&app.setSelectedColors(n),app.setYarnDocumentIsDirty()},this.doCycleColorDown=function(){n.colorID(n.colorID()-1),n.colorID()<0&&n.colorID(8)},this.doCycleColorUp=function(){n.colorID(n.colorID()+1),n.colorID()>8&&n.colorID(0)},this.remove=async function(){return new Promise((e,t)=>{i(n.element).transition({opacity:0,scale:.8,y:"-=80px",rotate:"-45deg"},250,"easeInQuad",e)})},this.drag=function(){const e={x:0,y:0};let t=!1,o=!1;i(document.body).on("mousemove touchmove",(function(i){if(t){const t=app.input.isScreenTouched&&i.changedTouches?i.changedTouches[0].pageX:i.pageX,s=app.input.isScreenTouched&&i.changedTouches?i.changedTouches[0].pageY:i.pageY;let{x:r,y:a}=app.workspace.toWorkspaceCoordinates(t,s);r-=e.x,a-=e.y;let l=r-n.x(),d=a-n.y();const c=app.workspace.getSelectedNodes();if(("mousemove"===i.originalEvent.type||c.includes(n)&&"touchmove"===i.originalEvent.type)&&(n.x(r),n.y(a)),o&&(n.selected?c.splice(c.indexOf(n),1):c=app.getNodesConnectedTo(n),c.length>0))for(let e in c)c[e].active()&&(c[e].x(c[e].x()+l),c[e].y(c[e].y()+d));app.workspace.updateArrows()}})),i(n.element).on("pointerdown",(function(i){if(!t&&n.active()&&0===i.button){t=!0,(app.input.isShiftDown||n.selected)&&(o=!0);const{x:s,y:r}=app.workspace.toWorkspaceCoordinates(i.pageX,i.pageY);e.x=app.settings.snapGridEnabled()?app.workspace.stepify(s-n.x(),app.settings.gridSize()):s-n.x(),e.y=app.settings.snapGridEnabled()?app.workspace.stepify(r-n.y(),app.settings.gridSize()):r-n.y()}})),i(n.element).on("touchend",(function(e){app.workspace.selectNodes(n)})),i(document).on("pointerup touchend",(function(){(t||o)&&(t=!1,o=!1,app.setYarnDocumentIsDirty())}))},this.moveTo=function(e,t){app.workspace.startUpdatingArrows(),i(n.element).clearQueue(),i(n.element).transition({x:e,y:t},app.stopUpdatingArrows,500)},this.isConnectedTo=function(e,t){if(t&&e.isConnectedTo(n,!1))return!0;let i=n.linkedTo();for(let t in i){if(i[t]==e)return!0;if(i[t].isConnectedTo(e,!1))return!0;if(e.isConnectedTo(i[t],!1))return!0}return!1},this.getLinksInNode=function(e){const t="yarn"===app.settings.documentType();let i=(e||n).body().match(t?/\[\[(.*?)\]\]/g:/\-\>(.*)/g);if(null!=i){let e={};for(let n=i.length-1;n>=0;n--)t?(i[n]=i[n].substr(2,i[n].length-4).trim(),i[n].indexOf("|")>=0&&(i[n]=i[n].split("|")[1]),null!=e[i[n]]&&i.splice(n,1),e[i[n]]=!0):i[n]=i[n].substr(2,i[n].length).trim();return i}},this.updateLinks=function(){n.resetDoubleClick(),n.updateLinksFromParents(),n.updateLinksToChildren()},this.updateLinksFromParents=function(){n.oldTitle&&n.oldTitle!==n.title()&&(n.linkedFrom.removeAll(),app.nodes().forEach(e=>{const t=n.getLinksInNode(e);if(t)if(t.includes(n.oldTitle)){const t=RegExp("\\|\\s*"+n.oldTitle+"\\s*\\]\\]","g"),i=RegExp("\\[\\[\\s*"+n.oldTitle+"\\s*\\]\\]","g");let o=e.body().replace(t,"|"+n.title()+"]]");o=o.replace(i,"[["+n.title()+"]]"),e.body(o),n.linkedFrom.push(e)}else t.includes(n.title())&&n.linkedFrom.push(e)}),n.oldTitle=void 0)},this.updateLinksToChildren=function(){n.linkedTo.removeAll();let e=n.getLinksInNode();if(e)for(let t in app.nodes()){let i=app.nodes()[t];for(let t=0;tfetch(e))).then(e=>Promise.all(e.map(e=>e.text()))).then(e=>{l.ink=e[0],l.yarn=e[1]});var d=function(t){const n=this,o=e=>(n.pluginStorage||(n.pluginStorage={}),n.pluginStorage[e]||(n.pluginStorage={...n.pluginStorage,[e]:{}}),this.pluginStorage[e]);window.addEventListener("yarnLoadedData",e=>{if(null!==t.data.documentHeader()){const e=t.data.documentHeader();"pluginStorage"in e&&(n.pluginStorage=e.pluginStorage)}}),window.addEventListener("newYarnFileStarted",e=>{n.pluginStorage={}});const s=t.data.db,r=()=>s.getDbValue("volatilePlugins"),d=e=>s.save("volatilePlugins",e),c=new URL(window.location.href),p=c.searchParams;console.log({urlParams:p,url:c});const u=()=>p.get("gistPlugins")||t.settings.gistPluginsFile();this.rawUrls={};const g=()=>new Promise(e=>{t.data.storage.getGist(u()).then(({filesInGist:n})=>{const i=Object.values(n).filter(e=>"JavaScript"===e.language||e.filename.endsWith(".js")||e.filename.endsWith(".json")||e.filename.endsWith(".txt")).map(e=>(this.rawUrls[e.filename]=e.raw_url,t.data.storage.getContentOrRaw(e.content,e.raw_url).then(t=>({...e,content:t}))));e(Promise.all(i))})}),h=(e=!1)=>new Promise(t=>r().then(n=>e?(console.log("---- fetching from gist files ----"),g().then(e=>{const i={};e.forEach(e=>{i[e.filename]=e}),t({...i,...n})}).catch(()=>t(n))):t(n))),f=e=>{try{const t=new Function("parameters","return "+e);if("function"==typeof t){const n=t();if(n){const t=e.indexOf("script:"),i=n()||{},o=e.substring(0,t).split("\n").length;return[{console:!1,...i,scriptStartLn:o},e]}}}catch(t){return console.log({e:t,fileContents:e}),[null,e,t]}return[null,e]},m={app:t,createButton:(e,{name:t,iconName:n,onClick:i,attachTo:o,className:s="item bbcode-button",title:r,onPointerDown:a,onDoubleClick:l,id:d,as:c="span",style:p=""})=>{const u=d||t||r||n;if(null!==document.getElementById(u))return void console.error(`Plugin button creation: Button with the id ${u} already exists. Skip creating it.`);const g=document.createElement(c);return g.id=u,g.innerHTML=`\n \n \n ${t||""}\n \n `,document.getElementById(o).appendChild(g),g},createToggle:(e,{id:t,attachTo:n,className:i,title:o,tooltipId:s,toggleValueKey:r,onToggle:a,enableKey:l,iconName:d,name:c})=>{const p=t||c||o||d;if(null!==document.getElementById(p))return void console.error(`Plugin button creation: Button with the id ${p} already exists. Skip creating it.`);const u=document.createElement("span");return u.id=p,u.className="styled-checkbox",u.innerHTML=`\n \n \n `,document.getElementById(n).appendChild(u),u},getPluginStore:o,setPluginStore:(e,t,i)=>{const s={...o(e),[t]:i};n.pluginStorage={...n.pluginStorage,[e]:s}},addSettingsItem:({title:n,valueKey:i,defaultValue:o,optionsKey:s,options:r,setterKey:a,settingsColumn:l})=>{t.settings[i]=e.observable(t.settings.storage.getItem(i)||o).extend({persist:i}),t.ui[s]=r,t[a]=function(e,n){const o=n?n.target.value:e;t.settings[i](o)},window.addEventListener("settingsOpened",()=>{const e=t.ui[s].map(e=>``).join(""),o=`\n \n
\n \n
\n `,r=document.createElement("div");r.className="settings-item",r.innerHTML=o,document.getElementById("settingsColumn"+(l||"A")).appendChild(r),document.getElementById("mySelect").addEventListener("change",e=>{t[a](!1,e)})})},onYarnLoadedData:e=>{window.addEventListener("yarnLoadedData",t=>{e(t)})},onYarnEditorOpen:e=>{window.addEventListener("yarnEditorOpen",t=>{e(t)})},onYarnInPreviewMode:e=>{window.addEventListener("yarnSavedNode",t=>{e(t)})},onYarnSavedNode:e=>{window.addEventListener("yarnInPreviewMode",t=>{e(t)})},onYarnSetLanguage:e=>{window.addEventListener("yarnSetLanguage",t=>{e(t)})},onYarnLoadedStateFromLocalStorage:e=>{window.addEventListener("yarnLoadedStateFromLocalStorage",t=>{e(t)})},onYarnSavedStateToLocalStorage:e=>{window.addEventListener("yarnSavedStateToLocalStorage",t=>{e(t)})},onYarnSetDocumentType:e=>{window.addEventListener("yarnSetDocumentType",t=>{e(t)})},onKeyUp:e=>{i(document).on("keyup",t=>{e(t)})},onKeyDown:e=>{i(document).on("keydown",t=>{e(t)})},onLoad:e=>{window.addEventListener("DOMContentLoaded",t=>{e(t)})},getVloatilePlugins:r,setVloatilePlugin:(e,t)=>r().then(n=>(n=n||{},s.save("volatilePlugins",{...n,[e]:{...n[e],...t}}))),setVloatilePlugins:d,getGistPluginFiles:g,getGistPluginFile:e=>{if(!u())return Promise.resolve(`// ${e}:\n// No gist id specified - to look for the file`);console.log({rawUrls:this.rawUrls});const n=this.rawUrls[e];return n?t.data.storage.getGistFileFromRawUrl(n):Promise.resolve(`// ${e}:\n// Not found at ${u()}\n// Check if it was deleted or renamed before comitting\n// Commiting changes will create the file at that gist.`)},saveGistPlugin:(e,n)=>(console.log({gistId:t.settings.gistPluginsFile(),fileName:e,contents:n}),t.data.storage.editGist(t.settings.gistPluginsFile(),e,n).then(t=>(this.rawUrls[e]=t.file.raw_url,t))),isGistTokenInvalid:()=>t.data.storage.getIsTokenInvalid(),urlParams:p,updateUrlParams:(e,t)=>{console.log("updateUrlParams",{key:e,value:t}),t?c.searchParams.set(e,t):c.searchParams.delete(e),window.history.replaceState(null,null,c)},getGistPluginsFileUrl:()=>p.get("pluginFile"),getGistPluginsId:u,pluginModeUrl:()=>p.get("mode"),getPluginsList:h,deleteGistPlugin:e=>t.data.storage.deleteGistFile(u(),e),deleteVolatilePlugin:e=>r().then(t=>(e in t&&delete t[e],s.save("volatilePlugins",{...t}))),getExtensionScriptData:f,getPreviewHtml:(e,t,n={})=>{const i=(e.modules||[]).filter(e=>!e.includes("/")&&e in t&&t[e].content).map(e=>{try{const[n,i]=f(t[e].content);if(console.log(e,"----\x3e",{includeData:n}),n&&"script"in n){const t=n.script.toString();return{id:e,body:t.startsWith("function ")?""+t:((e=(()=>{}))=>{const t=e.toString();return e.toString().slice(t.indexOf("{")+1,t.lastIndexOf("}"))})(n.script)}}if(i)return{id:e,body:i}}catch(e){return!1}}).filter(Boolean),o=(e.modules||[]).filter(e=>e.includes("/"));return console.log({data:e,otherFiles:t,localModules:i,remoteModules:o}),`\n \n \n \n \n