From f66787686264978d6b1e2957a6fbbfa930bc2deb Mon Sep 17 00:00:00 2001 From: progrium Date: Tue, 15 Aug 2023 19:43:52 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20treehous?= =?UTF-8?q?edev/treehouse@01855518917b8e38337f07cc39dfc51ece0babcd=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog/feed.rss | 2 +- lib/treehouse.min.js | 7 ++++--- lib/treehouse.min.js.map | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/blog/feed.rss b/blog/feed.rss index 26337e6..ae43a96 100644 --- a/blog/feed.rss +++ b/blog/feed.rss @@ -5,7 +5,7 @@ https://treehouse.sh/ An open source note-taking frontend to extend and customize. - Tue, 08 Aug 2023 16:13:49 GMT + Tue, 15 Aug 2023 19:43:48 GMT en Lume v1.17.5 diff --git a/lib/treehouse.min.js b/lib/treehouse.min.js index 557d60c..f59453d 100644 --- a/lib/treehouse.min.js +++ b/lib/treehouse.min.js @@ -1,4 +1,5 @@ -var ge=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var a=(r,e)=>ge(r,"name",{value:e,configurable:!0});var D=(r,e,t,n)=>{for(var o=n>1?void 0:n?We(e,t):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ge(e,t,o),o};var we=navigator.userAgent.toLowerCase().indexOf("mac")!==-1;function K(r){if(!r)return[];let e={backspace:"\u232B",shift:"\u21E7",meta:"\u2318",tab:"\u21B9",ctrl:"\u2303",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",enter:"\u23CE"};return r.toLowerCase().split("+").map(ve).map(n=>Object.keys(e).includes(n)?e[n]:n)}a(K,"bindingSymbols");function ve(r){return!we&&r==="meta"?"ctrl":r}a(ve,"filterKeyForNonMacMeta");var ee=class{constructor(){this.bindings=[]}registerBinding(e){this.bindings.push(e)}getBinding(e){for(let t of this.bindings)if(t.command===e)return t;return null}evaluateEvent(e){e:for(let t of this.bindings){let n=t.key.toLowerCase().split("+");if(n.pop()===e.key.toLowerCase()){for(let i of["shift","ctrl","alt","meta"]){let s=n.includes(i);if(!we){if(i==="meta")continue;i==="ctrl"&&(s=n.includes("meta")||n.includes("ctrl"))}let l=e[`${ve(i)}Key`];if(!l&&s||l&&!s)continue e}return t}}return null}};a(ee,"KeyBindings");var te=class{constructor(){this.commands={}}registerCommand(e){this.commands[e.id]=e}canExecuteCommand(e,...t){return this.commands[e]?!(this.commands[e].when&&!this.commands[e].when(...t)):!1}executeCommand(e,...t){return new Promise(n=>{let o=this.commands[e].action(...t);n(o)})}};a(te,"CommandRegistry");var ne=class{constructor(){this.menus={}}registerMenu(e,t){this.menus[e]=t}};a(ne,"MenuRegistry");function ke(r,e,t,n){return t?e.disabled||!r.canExecuteCommand(t.id,n):e.disabled}a(ke,"isDisabled");var ye={view({attrs:{workbench:r,x:e,y:t,items:n,align:o,commands:i,ctx:s}}){let l=a((d,c)=>p=>{p.stopPropagation(),!ke(r,d,c,s)&&(r.closeMenu(),d.onclick&&d.onclick(),c&&r.executeCommand(c.id,s))},"onclick");return m("ul",{class:"menu",style:{margin:"0",display:"inline-block"}},n.filter(d=>!d.when||d.when()).map(d=>{let c="",p,h;return d.command&&(h=i.find(k=>k.id===d.command),p=r.keybindings.getBinding(h.id),c=h.title),d.title&&(c=d.title()),m("li",{onclick:l(d,h),class:ke(r,d,h,s)?"disabled":"",style:{display:"flex"}},m("div",null,c),p&&m("div",{class:"keybindings grow text-right"},K(p.key).join(" ").toUpperCase()))}))}};var J={onupdate({state:r,dom:e}){let t=e.querySelector(".items").children;r.selected!==void 0&&t.length>0&&t[r.selected].scrollIntoView({block:"nearest"})},oncreate({attrs:r,state:e,dom:t}){r.inputview&&t.querySelector("input")?.focus(),e.selected===void 0&&(e.selected=0)},view({attrs:r,state:e}){e.selected=e.selected===void 0?0:e.selected,e.input=e.input===void 0?r.input||"":e.input,e.items===void 0&&(e.items=[],r.onchange(e));let t=a(o=>{let i=a((s,l)=>(s%l+l)%l,"mod");if(o.key==="ArrowDown")return e.selected===void 0?(e.selected=0,!1):(e.selected=i(e.selected+1,e.items.length),!1);if(o.key==="ArrowUp")return e.selected===void 0&&(e.selected=0),e.selected=i(e.selected-1,e.items.length),!1;if(o.key==="Enter")return e.selected!==void 0&&r.onpick(e.items[e.selected]),!1},"onkeydown"),n=a(o=>{e.input=o.target.value,e.selected=0,r.onchange(e)},"oninput");return m("div",{class:"picker"},r.inputview(t,n,e.input),m("div",{class:"items"},e.items.map((o,i)=>m("div",{class:e.selected===i?"item selected":"item",onclick:()=>r.onpick(o),onmouseover:()=>e.selected=i},r.itemview(o,i)))))}};var be={view({attrs:{workbench:r,ctx:e}}){let t=a(d=>(d.title||d.id).replace("-"," ").replace(/(^|\s)\S/g,p=>p.toUpperCase()),"getTitle"),n=a((d,c)=>t(d).localeCompare(t(c)),"sort"),o=a(d=>{r.closeDialog(),r.commands.executeCommand(d.id,e)},"onpick"),i=a(d=>{d.items=l.filter(c=>(c.title||c.id).toLowerCase().includes(d.input.toLowerCase()))},"onchange"),s=a(d=>{let c=r.keybindings.getBinding(d.id);return c?K(c.key).join(" ").toUpperCase():""},"getBindingSymbols"),l=Object.values(r.commands.commands).filter(d=>!d.hidden).filter(d=>r.canExecuteCommand(d.id,e)).sort(n);return m("div",{class:"palette"},m(J,{onpick:o,onchange:i,inputview:(d,c)=>m("div",null,m("input",{style:{width:"98%"},type:"text",onkeydown:d,oninput:c,placeholder:"Enter command..."})),itemview:d=>m("div",{class:"flex"},m("div",null,t(d)),m("div",{class:"keybindings grow text-right"},s(d)))}))}};function z(r,e){return r.value&&r.value[e]instanceof Function}a(z,"hasHook");function V(r,e,...t){if(z(r,e))return r.value[e].apply(r.value,t)}a(V,"triggerHook");function $(r,e){for(let t of r.components)if(z(t,e))return!0;return!1}a($,"objectHas");function oe(r,e,...t){for(let n of r.components)if(z(n,e))return n.value[e].apply(n.value,t)}a(oe,"objectCall");function se(r,e,...t){let n=[];for(let o of r.components)z(o,e)&&n.push(o.value);return n}a(se,"componentsWith");function M(r){return $(r,"objectChildren")}a(M,"objectManaged");var he={};function I(r){he[Q(r)]=r}a(I,"component");function Q(r){return r.prototype===void 0&&(r=r.constructor),`treehouse.${r.name}`}a(Q,"componentName");function Y(r){return typeof r=="string"?he[r]:he[Q(r)]}a(Y,"getComponent");function xe(r,e){let t=new(Y(r));return t.fromJSON instanceof Function?t.fromJSON(e):Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),t}a(xe,"inflateToComponent");function Ce(r){if(r===void 0)return;if(!Y(r))return structuredClone(r);let t=JSON.parse(JSON.stringify(r)||""),n=new r.constructor;return n.fromJSON instanceof Function?n.fromJSON(t):Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)),n}a(Ce,"duplicate");var v=class{constructor(){}onAttach(e){this.object=e.parent,this.object.setAttr("view","document")}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"node-bullet"},m("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),m("polyline",{points:"14 2 14 8 20 8"}),m("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),m("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),m("polyline",{points:"10 9 9 9 8 9"}))}toJSON(e){return{}}static initialize(e){e.commands.registerCommand({id:"make-document",title:"Make Document",action:t=>{if(!t.node)return;let n=new v;t.node.addComponent(n),t.node.changed(),e.executeCommand("zoom",t)}})}};a(v,"Document"),v=D([I],v);var W={view({attrs:{workbench:r,path:e,onkeydown:t,oninput:n,disallowEmpty:o,editValue:i,placeholder:s},state:l}){let d=e.node,c=i?"value":"name",p=a(()=>c==="name"?$(d,"displayName")?oe(d,"displayName",d):d.name:d[c]||"","display"),h=a(()=>{l.initialValue=d[c],r.context.node=d,r.context.path=e},"onfocus"),k=a(()=>d[c],"getter"),N=a((g,y)=>{d.isDestroyed||(o&&g.length===0?d[c]=l.initialValue:d[c]=g),y&&(r.context.node=null)},"setter");d.raw.Rel==="Fields"&&(s=i?"Value":"Field");let w=`input-${e.id}-${d.id}`;c==="value"&&(w=w+"-value");let f=Ue;return d.parent&&d.parent.hasComponent(v)&&window.Editor&&(f=qe),m(f,{id:w,getter:k,setter:N,display:p,onkeydown:t,onfocus:h,oninput:n,placeholder:s})}},qe={oncreate({dom:r,state:e,attrs:{id:t,onkeydown:n,onfocus:o,onblur:i,oninput:s,getter:l,setter:d,display:c,placeholder:p}}){let h=e.editing?e.buffer:c?c():l(),k=a(g=>{g.key==="Enter"&&(g.preventDefault(),g.stopPropagation())},"defaultKeydown"),N=a(g=>{o&&o(g),e.editing=!0,e.buffer=l()},"startEdit"),w=a(g=>{e.editing&&(e.editing=!1,d(e.buffer,!0),e.buffer=void 0),i&&i(g)},"finishEdit"),f=a(g=>{e.buffer=g.target.value,d(e.buffer,!1),s&&s(g)},"edit");e.editor=new window.Editor(r,h,p),e.editor.onblur=w,e.editor.onfocus=N,e.editor.oninput=f,e.editor.onkeydown=n||k,r.editor=e.editor,r.id=t},onupdate({dom:r,state:e,attrs:{getter:t,display:n}}){e.editor.value=e.editing?e.buffer:n?n():t()},view(){return m("div",{class:"text-editor"})}},Ue={oncreate({dom:r,attrs:e}){let t=r.querySelector("textarea"),n=t.offsetHeight,o=r.querySelector("span");this.updateHeight=()=>{o.style.width=`${Math.max(t.offsetWidth,100)}px`,o.innerHTML=t.value.replace(` -`,"
");let i=o.offsetHeight;i===0&&n>0&&(i=n),t.style.height=i>0?`${i}px`:"var(--body-line-height)"},t.addEventListener("input",()=>this.updateHeight()),t.addEventListener("blur",()=>o.innerHTML=""),setTimeout(()=>this.updateHeight(),50),e.onmount&&e.onmount(t)},onupdate(){this.updateHeight()},view({attrs:{id:r,onkeydown:e,onfocus:t,onblur:n,oninput:o,getter:i,setter:s,display:l,placeholder:d},state:c}){let p=c.editing?c.buffer:l?l():i();return m("div",{class:"text-editor"},m("textarea",{id:r,rows:"1",onfocus:a(f=>{t&&t(f),c.editing=!0,c.buffer=i()},"startEdit"),onblur:a(f=>{c.editing&&(c.editing=!1,s(c.buffer,!0),c.buffer=void 0),n&&n(f)},"finishEdit"),oninput:a(f=>{c.buffer=f.target.value,s(c.buffer,!1),o&&o(f)},"edit"),placeholder:d,onkeydown:e||a(f=>{f.key==="Enter"&&(f.preventDefault(),f.stopPropagation())},"defaultKeydown"),value:p},p),m("span",{style:{visibility:"hidden",position:"fixed"}}))}};var Ne={view({attrs:{node:r,workbench:e,panel:t}}){return m("div",{class:"empty-view"})}};var ae={view({attrs:{workbench:r,path:e}}){return m("div",{class:"new-node flex flex-row items-center"},m("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 16"},m("circle",{cx:"8",cy:"7",r:"7"}),m("path",{style:{transform:"translate(0px, -1px)"},d:"M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"})),m("div",{class:"flex grow"},m("input",{class:"grow",type:"text",onkeydown:a(n=>{if(n.key==="Tab"){if(n.stopPropagation(),n.preventDefault(),node.childCount>0){let o=e.node.children[e.node.childCount-1];r.executeCommand("insert-child",{node:o,path:e})}}else r.executeCommand("insert-child",{node:e.node,path:e},n.target.value)},"keydown"),value:""})))}};function ze(r,e=1e3){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{r.apply(this,n)},e)}}a(ze,"debounce");var H=class{constructor(){this.workbench=window.workbench,this.searchDebounce=ze(this.search.bind(this)),this.query="",this.initialSearch=!1}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",class:"node-bullet",width:"15",height:"15",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},e?m("circle",{id:"node-collapsed-handle",stroke:"none",cx:"12",cy:"12",r:"12"}):null,m("svg",{xmlns:"http://www.w3.org/2000/svg",x:"3",y:"3",width:"19",height:"19",viewBox:"0 0 24 24"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})))}belowEditor(){return Ve}onAttach(e){this.component=e,this.object=e.parent,e.bus.observe(t=>{e.isDestroyed||this.searchDebounce()})}search(){if(!this.object)return;if(!this.query){this.lastQuery="",this.results=[];return}this.initialSearch=!0;let e=this.workbench.search(this.query).filter(t=>t.id!==this.object.id&&t.id!==this.component.id);(e.length!==this.lastResultCount||this.query!==this.lastQuery)&&(this.results&&this.results.forEach(t=>t.destroy()),this.results=e.map(t=>{let n=this.object.bus.make("");return n.raw.Parent="@tmp",n.refTo=t,n}),this.lastQuery=this.query,this.lastResultCount=e.length)}objectChildren(e,t){return!this.results&&this.query&&!this.initialSearch&&this.search(),this.results||[]}toJSON(e){return{query:this.query}}fromJSON(e){this.query=e.query||""}static initialize(e){e.commands.registerCommand({id:"make-smart-node",title:"Make Smart Node",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.childCount>0||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{e.defocus();let n=new H;t.node.addComponent(n),e.workspace.setExpanded(t.path.head,t.node,!0),t.node.name===""&&setTimeout(()=>{t.node.name="Unnamed Smart Node",m.redraw(),document.querySelector(`#node-${t.path.id}-${t.node.id} input`).focus()},10)}})}};a(H,"SmartNode"),H=D([I],H);var Ve={view({attrs:{node:r,component:e,expanded:t}}){if(!t)return;let n=a(o=>{e.query=o.target.value,e.search(),r.changed()},"oninput");return m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex"}),m("input",{type:"text",class:"grow",placeholder:"Enter search",value:e.query,oninput:n,style:{background:"inherit",border:"1px solid var(--color-outline-secondary)",outline:"0",padding:"var(--1)",marginBottom:"var(--1)",borderRadius:"var(--border-radius)"}}))}};var Se={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){let n=e.node;e.node.refTo&&(n=e.node.refTo);let o=!1;return(n.childCount===0&&n.getLinked("Fields").length===0||t)&&(o=!0),n.hasComponent(H)&&(o=!1),m("div",{class:"list-view"},m("div",{class:"fields"},n.getLinked("Fields").length>0&&n.getLinked("Fields").map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)}))),m("div",{class:"children"},n.childCount>0&&n.children.map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)})),o&&m(ae,{workbench:r,path:e})))}};var De={view({attrs:{workbench:r,path:e},state:t}){let n=e.node;t.fields=t.fields===void 0?new Set:t.fields,n.children.forEach(i=>{i.getLinked("Fields").forEach(s=>t.fields.add(s.name))});let o=a((i,s)=>{let l=i.getLinked("Fields").filter(d=>d.name===s);return l.length===0?"":m(W,{editValue:!0,workbench:r,path:e.append(l[0])})},"getFieldEditor");return m("table",{class:"table-view",style:{gridTemplateColumns:`repeat(${t.fields.size+1}, 1fr)`}},m("thead",null,m("tr",null,m("th",null,"Title"),[...t.fields].map(i=>m("th",null,i)))),m("tbody",null,n.children.map(i=>m("tr",null,m("td",null,m(q,{key:i.id,workbench:r,path:e.append(i)})),[...t.fields].map(s=>m("td",null,o(i,s)))))))}};var Ie={view({attrs:{workbench:r,path:e},state:t}){let n=e.node;t.tabs=t.tabs===void 0?new Set:t.tabs,t.selectedTab=t.selectedTab===void 0?"":t.selectedTab,n.children.forEach(s=>{t.tabs.add(s.raw),t.selectedTab===""&&(t.selectedTab=s.raw.ID)});let o=a(s=>{t.selectedTab=s},"handleTabClick"),i=n.children.find(s=>s.id===t.selectedTab);return m("div",{class:"tabs-view"},m("div",{class:"tabs"},[...t.tabs].map(s=>m("div",{class:s.ID===t.selectedTab?"active":"",onclick:()=>o(s.ID)},s.Name)),m("div",{style:{flexGrow:1}})),m("div",{class:"tab-content"},m(ie(i.getAttr("view")||"list"),{workbench:r,path:e.append(i)})))}};var Le={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){let n=e.node;e.node.refTo&&(n=e.node.refTo);let o=!1;return(n.childCount===0&&n.getLinked("Fields").length===0||t)&&(o=!0),m("div",{class:"document-view"},m("div",{class:"fields"},n.getLinked("Fields").length>0&&n.getLinked("Fields").map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)}))),m("div",{class:"children"},n.childCount>0&&n.children.map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)})),o&&m(ae,{workbench:r,path:e})))}};var Ee={list:Se,table:De,tabs:Ie,document:Le};function ie(r){return Ee[r]||Ne}a(ie,"getView");window.registerView=(r,e)=>{Ee[r]=e,workbench.commands.registerCommand({id:`view-${r}`,title:`View as ${Qe(r)}`,action:t=>{t.node&&t.node.setAttr("view",r)}})};function Qe(r){return r.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})}a(Qe,"toTitleCase");var O=class{constructor(){}onAttach(e){this.object=e.parent}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",class:"node-bullet"},e?m("circle",{id:"node-collapsed-handle",stroke:"none",cx:"12",cy:"12",r:"12"}):null,m("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),m("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))}toJSON(e){return{}}static initialize(e){e.commands.registerCommand({id:"make-template",title:"Make Template",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{let n=new O;t.node.addComponent(n),t.node.changed()}})}static findNode(e,t){let n=null;return e.mainNode().walk(o=>o.value instanceof O&&o.value.object.name===t?(n=o.value.object,!0):!1,{includeComponents:!0}),n}};a(O,"Template"),O=D([I],O);var L=class{constructor(e){this.name=e}afterEditor(){return Ke}static initialize(e){e.commands.registerCommand({id:"add-tag",title:"Add tag",hidden:!0,action:(t,n)=>{if(!t.node)return;let o=new L(n);t.node.addComponent(o);let i=O.findNode(e.workspace,n);i&&(i.fields.map(s=>s.duplicate()).forEach(s=>{t.node.addLinked("Fields",s),s.raw.Parent=t.node.raw.ID}),i.children.map(s=>s.duplicate()).forEach(s=>{t.node.addChild(s),s.raw.Parent=t.node.raw.ID})),t.node.changed()}})}static findAll(e){let t=new Set;return e.mainNode().walk(n=>(n.value instanceof L&&t.add(n.value.name),!1),{includeComponents:!0}),[...t]}static findTagged(e,t){let n=[];return e.mainNode().walk(o=>(o.value instanceof L&&o.value.name===t&&n.push(o.parent),!1),{includeComponents:!0}),n}static showPopover(e,t,n,o,i){let s=L.findAll(e.workspace),l=e.getInput(t),d=l.getBoundingClientRect(),c=document.body.scrollLeft+d.x+l.selectionStart*10+20,p=document.body.scrollTop+d.y+d.height;e.showPopover(()=>m(J,{onpick:h=>{i(),e.getInput(t).blur(),n.name=n.name.replace(/\s*#\w*/,""),e.executeCommand("add-tag",{node:n,path:t},h.name)},onchange:h=>{n.name.includes("#")?h.input=n.name.split("#")[1]:h.input="";let k=[...s].filter(N=>N.toLowerCase().startsWith(h.input.toLowerCase())).map(N=>({name:N}));(k[0]&&k[0].name!=h.input&&h.input!=""||k.length===0)&&k.unshift({name:h.input,prefix:"Create tag: "}),h.items=k},inputview:o,itemview:h=>m("div",{class:"flex"},m("div",null,h.prefix||"",h.name))}),{top:`${p}px`,left:`${c}px`})}};a(L,"Tag"),L=D([I],L);var Ke={view({attrs:{node:r,component:e}}){return m("div",{tabindex:"1",class:"badge flex flex-row items-center",onkeydown:a(n=>{n.key==="Backspace"&&(r.removeComponent(e),r.changed())},"onkeydown")},m("span",null,"#\xA0"),m("div",{style:{whiteSpace:"nowrap"}},e.name))}};var de={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){return m(ie(e.node.getAttr("view")||"list"),{workbench:r,path:e,alwaysShowNew:t})}},q={view({attrs:r,state:e,children:t}){let{path:n,workbench:o}=r,i=n.node,s=!1,l=i;i.refTo&&(s=!0,i=l.refTo);let d=!1;o.clipboard&&o.clipboard.op==="cut"&&o.clipboard.node.id===i.id&&(d=!0);let c=o.workspace.getExpanded(n.head,l),p=$(i,"handlePlaceholder")?oe(i,"handlePlaceholder"):"",h=a(u=>{e.hover=!0,u.stopPropagation()},"hover"),k=a(u=>{e.hover=!1,u.stopPropagation()},"unhover"),N=a(()=>{e.tagPopover&&(o.closePopover(),e.tagPopover=void 0)},"cancelTagPopover"),w=a(u=>{e.tagPopover?(e.tagPopover.oninput(u),u.target.value.includes("#")||N()):u.target.value.includes("#")&&(e.tagPopover={},L.showPopover(o,n,i,(P,x)=>{e.tagPopover={onkeydown:P,oninput:x}},N))},"oninput"),f=a(u=>{if(e.tagPopover){if(u.key==="Escape"){N();return}if(e.tagPopover.onkeydown(u)===!1)return u.stopPropagation(),!1}let P=u.shiftKey||u.metaKey||u.altKey||u.ctrlKey;switch(u.key){case"ArrowUp":u.target.selectionStart!==0&&!P&&u.stopPropagation();break;case"ArrowDown":u.target.selectionStart!==u.target.value.length&&u.target.selectionStart!==0&&!P&&u.stopPropagation();break;case"Backspace":if(u.target.value===""){if(u.preventDefault(),u.stopPropagation(),i.childCount>0)return;o.executeCommand("delete",{node:i,path:n,event:u});return}if(u.target.value!==""&&u.target.selectionStart===0&&u.target.selectionEnd===0){if(u.preventDefault(),u.stopPropagation(),i.childCount>0)return;let x=o.workspace.findAbove(n);if(!x)return;let C=x.node.name;x.node.name=C+u.target.value,i.destroy(),m.redraw.sync(),o.focus(x,C.length);return}break;case"Enter":if(u.preventDefault(),u.ctrlKey||u.shiftKey||u.metaKey||u.altKey)return;if(u.target.selectionStart===u.target.value.length){i.childCount>0&&o.workspace.getExpanded(n.head,i)?o.executeCommand("insert-child",{node:i,path:n},"",0):o.executeCommand("insert",{node:i,path:n}),u.stopPropagation();return}if(u.target.selectionStart===0){o.executeCommand("insert-before",{node:i,path:n}),u.stopPropagation();return}if(u.target.selectionStart>0&&u.target.selectionStart{i.name=u.target.value.slice(0,u.target.selectionStart)}),u.stopPropagation();return}break}},"onkeydown"),g=a(u=>{u.preventDefault(),u.stopPropagation(),o.executeCommand("zoom",{node:i,path:n}),document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},"open"),y=a(u=>{if(i.hasComponent(v)){g(u);return}c?o.executeCommand("collapse",{node:l,path:n}):o.executeCommand("expand",{node:l,path:n}),u.stopPropagation()},"toggle"),B=a(u=>u.childCount+u.getLinked("Fields").length,"subCount"),j=a(()=>{if(i.id===o.context?.node?.id||e.hover||i.name.length>0||p.length>0)return!0},"showHandle");return m("div",{onmouseover:h,onmouseout:k,id:`node-${n.id}-${l.id}`,class:d?"cut-node":""},m("div",{class:"node-row-outer-wrapper flex flex-row items-start"},m("svg",{class:"node-menu shrink-0",xmlns:"http://www.w3.org/2000/svg",onclick:u=>o.showMenu(u,{node:l,path:n}),oncontextmenu:u=>o.showMenu(u,{node:l,path:n}),"data-menu":"node",viewBox:"0 0 16 16"},e.hover&&m("path",{style:{transform:"translateY(-1px)"},fill:"currentColor","fill-rule":"evenodd",d:"M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"})),m("div",{class:"node-handle shrink-0",onclick:y,ondblclick:g,oncontextmenu:u=>o.showMenu(u,{node:l,path:n}),"data-menu":"node",style:{display:j()?"block":"none"}},$(i,"handleIcon")?oe(i,"handleIcon",B(i)>0&&!c):m("svg",{class:"node-bullet",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},B(i)>0&&!c?m("circle",{id:"node-collapsed-handle",cx:"8",cy:"8",r:"8"}):null,m("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"}),",",s?m("circle",{id:"node-reference-handle",cx:"8",cy:"8",r:"7",fill:"none","stroke-width":"1",stroke:"currentColor","stroke-dasharray":"3,3"}):null)),i.raw.Rel==="Fields"?m("div",{class:"flex grow items-start flex-row"},m("div",null,m(W,{workbench:o,path:n,onkeydown:f,oninput:w})),m(W,{editValue:!0,workbench:o,path:n,onkeydown:f,oninput:w})):m("div",{class:"flex grow items-start flex-row",style:{gap:"0.5rem"}},$(i,"beforeEditor")&&se(i,"beforeEditor").map(u=>m(u.beforeEditor(),{node:i,component:u})),m(W,{workbench:o,path:n,onkeydown:f,oninput:w,placeholder:p}),$(i,"afterEditor")&&se(i,"afterEditor").map(u=>m(u.afterEditor(),{node:i,component:u})))),$(i,"belowEditor")&&se(i,"belowEditor").map(u=>m(u.belowEditor(),{node:i,component:u,expanded:c})),c===!0&&m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex",onclick:y}),m("div",{class:"view grow"},m(ie(i.getAttr("view")||"list"),{workbench:o,path:n}))))}};var Ae={view({attrs:{workbench:r,node:e}}){let t=new T(e,"quickadd");return m("div",{class:"notice"},m("h3",null,"Quick Add"),m(de,{workbench:r,path:t,alwaysShowNew:!0}),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{r.commitQuickAdd(),r.closeDialog()}},"Add to Today")))}};var Pe={view({attrs:{workbench:r},state:e}){let t=r.workspace.settings.theme;return e.selectedTheme=e.selectedTheme===void 0?t:e.selectedTheme,m("div",{class:"notice"},m("h3",null,"Settings"),m("div",{class:"flex flex-row"},m("div",{class:"grow"},"Theme"),m("div",null,m("select",{name:"theme",oninput:a(o=>{e.selectedTheme=o.target.value},"oninput")},m("option",{selected:e.selectedTheme==="",value:""},"Light"),m("option",{selected:e.selectedTheme==="darkmode",value:"darkmode"},"Dark"),m("option",{selected:e.selectedTheme==="sepia",value:"sepia"},"Sepia"),m("option",{selected:e.selectedTheme==="sublime",value:"sublime"},"Sublime")))),m("div",{class:"button-bar"},m("button",{onclick:()=>{r.closeDialog()}},"Cancel"),m("button",{class:"primary",onclick:async o=>{t!==e.selectedTheme?(r.workspace.settings.theme=e.selectedTheme,await r.workspace.save(!0),location.reload()):r.closeDialog()}},"Save Changes")))}};var Fe={view(){return m("div",{class:"notice"},m("h3",null,"Refresh to view latest updates"),m("p",null,"Your notes were updated in another browser session. Refresh the page to view the latest version."),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{location.reload()}},"Refresh Now")))}},Te={view({attrs:{workbench:r}}){return m("div",{class:"notice"},m("h3",null,"Treehouse is under active development"),m("p",null,"This is a preview based on our main branch, which is actively being developed."),m("p",null,"If you find a bug, please report it via \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0> ",m("strong",null,"Submit Issue"),"."),m("p",null,"Data is stored using localstorage, which you can reset via \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0> ",m("strong",null,"Reset Demo"),"."),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{localStorage.setItem("firsttime","1"),r.closeDialog()}},"Got it")))}},Be={view({attrs:{workbench:r,finished:e}}){return m("div",{class:"notice"},m("h3",null,"Login with GitHub"),m("p",null,"The GitHub backend is experimental so use at your own risk!"),m("p",null,"To store your workbench we will create a public repository called ",m("pre",{style:{display:"inline"}},".treehouse.sh")," if it doesn't already exist. You can manually make this repository private via GitHub if you want."),m("p",null,"You can Logout via the \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0 menu in the top right to return to the localstorage backend."),m("div",{class:"button-bar"},m("button",{onclick:()=>{r.closeDialog()}},"Cancel"),m("button",{class:"primary",onclick:()=>{r.closeDialog(),localStorage.setItem("github","1"),e()}},"Log in with GitHub")))}};var G=class{constructor(e){this.commands=new te,this.keybindings=new ee,this.menus=new ne,this.backend=e,this.workspace=new _(e.files),this.context={node:null},this.panels=[],this.drawer={open:!1},this.dialog={body:()=>null},this.menu={body:()=>null}}get mainPanel(){return this.panels[0]}async initialize(){if(await this.workspace.load(),this.workspace.rawNodes.forEach(e=>this.backend.index.index(e)),this.workspace.observe(e=>{this.workspace.save(),e.isDestroyed?this.backend.index.remove(e.id):(this.backend.index.index(e.raw),e.components.forEach(t=>this.backend.index.index(t.raw)))}),this.workspace.lastOpenedID?this.openNewPanel(this.workspace.find(this.workspace.lastOpenedID)||this.workspace.mainNode()):this.openNewPanel(this.workspace.mainNode()),this.backend.loadExtensions&&await this.backend.loadExtensions(),this.workspace.settings.theme){let e=document.createElement("link");e.setAttribute("href",`https://treehouse.sh/style/themes/${this.workspace.settings.theme}.css`),e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)}m.redraw()}authenticated(){return this.backend.auth&&this.backend.auth.currentUser()}openQuickAdd(){let e=this.workspace.find("@quickadd");e||(e=this.workspace.new("@quickadd")),this.showDialog(()=>m(Ae,{workbench:this,node:e}),!0),setTimeout(()=>{document.querySelector("main > dialog .new-node input").focus()},1)}commitQuickAdd(){let e=this.workspace.find("@quickadd");if(!e)return;let t=this.todayNode();e.children.forEach(n=>n.parent=t)}clearQuickAdd(){let e=this.workspace.find("@quickadd");e&&e.children.forEach(t=>t.destroy())}todayNode(){let e=new Date,t=e.toUTCString().split(e.getFullYear())[0],n=`Week ${String(Je(e)).padStart(2,"0")}`,i=["@calendar",`${e.getFullYear()}`,n,t].join("/"),s=this.workspace.find(i);return s||(s=this.workspace.new(i)),s}openToday(){this.open(this.todayNode())}open(e){this.workspace.expanded[e.id]||(this.workspace.expanded[e.id]={}),this.workspace.lastOpenedID=e.id,this.workspace.save();let t=new T(e);this.panels[0]=t,this.context.path=t}openNewPanel(e){this.workspace.expanded[e.id]||(this.workspace.expanded[e.id]={}),this.workspace.lastOpenedID=e.id,this.workspace.save();let t=new T(e);this.panels.push(t),this.context.path=t}closePanel(e){this.panels=this.panels.filter(t=>t.name!==e.name)}defocus(){let e=this.getInput(this.context.path);e&&e.blur(),this.context.node=null,this.context.path=null}focus(e,t=0){let n=this.getInput(e);n?(this.context.path=e,n.focus(),t!==void 0&&n.setSelectionRange(t,t)):console.warn("unable to find input for",e)}getInput(e){let t=`input-${e.id}-${e.node.id}`;e.node.raw.Rel==="Fields"&&e.node.name!==""&&(t=t+"-value");let n=document.getElementById(t);return n.editor?n.editor:n}canExecuteCommand(e,t,...n){return t=this.newContext(t),this.commands.canExecuteCommand(e,t,...n)}executeCommand(e,t,...n){return t=this.newContext(t),console.log(e,t,...n),this.commands.executeCommand(e,t,...n)}newContext(e){return Object.assign({},this.context,e)}showMenu(e,t,n){e.stopPropagation(),e.preventDefault();let o=e.target.closest("*[data-menu]"),i=o.getBoundingClientRect();if(!n){let d=o.dataset.align||"left";n={top:`${document.body.scrollTop+i.y+i.height}px`},d==="right"?(n.marginLeft="auto",n.marginRight=`${document.body.offsetWidth-i.right}px`):(n.marginLeft=`${document.body.scrollLeft+i.x}px`,n.marginRight="auto")}let s=this.menus.menus[o.dataset.menu],l=s.filter(d=>d.command).map(d=>this.commands.commands[d.command]);s&&(this.menu={body:()=>m(ye,{workbench:this,ctx:this.newContext(t),items:s,commands:l}),style:n},m.redraw(),setTimeout(()=>{document.querySelector("main > dialog.menu").showModal()},0))}closeMenu(){document.querySelector("main > dialog.menu").close(),workbench.menu.body=()=>null}showPalette(e,t,n){this.showDialog(()=>m(be,{workbench:this,ctx:n}),!1,{left:`${e}px`,top:`${t}px`})}showNotice(e,t){this.showDialog(()=>m({firsttime:Te,github:Be,lockstolen:Fe}[e],{workbench:this,finished:t}),!0,void 0,e==="lockstolen")}toggleDrawer(){this.drawer.open=!this.drawer.open,m.redraw()}showSettings(){this.showDialog(()=>m(Pe,{workbench:this}),!0)}showPopover(e,t){this.popover={body:e,style:t},m.redraw()}closePopover(){this.popover=null,m.redraw()}showDialog(e,t,n,o){this.dialog={body:e,backdrop:t,style:n,explicitClose:o},m.redraw(),setTimeout(()=>{document.querySelector("main > dialog.modal").showModal()},0)}isDialogOpen(){return document.querySelector("main > dialog.modal").hasAttribute("open")}closeDialog(){document.querySelector("main > dialog.modal").close(),this.dialog.body=()=>null}search(e){if(!e)return[];let t=e.split(/\s+(?=(?:[^\'"]*[\'"][^\'"]*[\'"])*[^\'"]*$)/),n=t.filter(l=>!l.includes(":")).join(" "),o=Object.fromEntries(t.filter(l=>l.includes(":")).map(l=>l.toLowerCase().split(":")));!n&&Object.keys(o).length>0&&(n=Object.keys(o)[0]);let i=a(l=>{if(Object.keys(o).length>0){let d={};for(let c of l.getLinked("Fields"))d[c.name.toLowerCase()]=c.value.toLowerCase();for(let c in o)if(!d[c]||d[c]!==o[c].replace(/['"]/g,""))return!1}return!0},"passFieldQuery");if(n.startsWith("#"))return L.findTagged(this.workspace,n.replace("#","")).filter(i);let s={};return this.backend.index.search(n).forEach(l=>{let d=window.workbench.workspace.find(l);d&&(d.value&&(d=d.parent,!d.raw)||i(d)&&(s[d.id]=d))}),Object.values(s)}};a(G,"Workbench");function Je(r){var e=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);var n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e-n)/864e5+1)/7)}a(Je,"getWeekOfYear");function Re(r){function e(x,C){var S=x<>>32-C;return S}a(e,"rotate_left");function t(x){var C="",S,F,fe;for(S=0;S<=6;S+=2)F=x>>>S*4+4&15,fe=x>>>S*4&15,C+=F.toString(16)+fe.toString(16);return C}a(t,"lsb_hex");function n(x){var C="",S,F;for(S=7;S>=0;S--)F=x>>>S*4&15,C+=F.toString(16);return C}a(n,"cvt_hex");function o(x){x=x.replace(/\r\n/g,` -`);for(var C="",S=0;S127&&F<2048?(C+=String.fromCharCode(F>>6|192),C+=String.fromCharCode(F&63|128)):(C+=String.fromCharCode(F>>12|224),C+=String.fromCharCode(F>>6&63|128),C+=String.fromCharCode(F&63|128))}return C}a(o,"Utf8Encode");var i,s,l,d=new Array(80),c=1732584193,p=4023233417,h=2562383102,k=271733878,N=3285377520,w,f,g,y,B,P;r=o(r);var j=r.length,u=new Array;for(s=0;s>>29),u.push(j<<3&4294967295),i=0;ie.id)].join(":"))}get node(){return this.nodes[this.nodes.length-1]}get previous(){return this.nodes.length<2?null:this.nodes[this.nodes.length-2]}get head(){return this.nodes[0]}};a(T,"Path");var X=class{constructor(){this.nodes={"@root":{ID:"@root",Name:"@root",Linked:{Children:[],Components:[]},Attrs:{}}},this.observers=[]}changed(e){this.observers.forEach(t=>t(e))}import(e){for(let t of e)t.Value&&Y(t.Name)&&(t.Value=xe(t.Name,t.Value),t.Rel="Components"),this.nodes[t.ID]=t;for(let t of e){if(t.Parent==="@tmp"){delete this.nodes[t.ID];continue}if(!t.ID.startsWith("@")&&t.Parent===void 0){delete this.nodes[t.ID];continue}if(t.Parent&&!this.nodes[t.Parent]){delete this.nodes[t.ID];continue}let n=this.find(t.ID);if(n){if(n.parent&&!n.parent.raw){delete this.nodes[t.ID];continue}V(n,"onAttach",n)}}}export(){let e=[];for(let t of Object.values(this.nodes))e.push(t);return e}make(e,t){let n=null;if(e.includes("/")){let s=e.split("/");n=this.find(s[0]);for(let l=1;le.Parent===void 0).map(e=>new E(this,e.ID))}root(e){e=e||"@root";let t=this.roots().find(n=>n.name===e);return t===void 0?null:t}find(e){let t=this.nodes[e];if(t)return new E(this,t.ID);let n=e.split("/");if(n.length===1&&n[0].startsWith("@"))return null;let o=this.root(n[0]);if(!o&&this.nodes[n[0]]&&(o=new E(this,this.nodes[n[0]].ID)),o?n.shift():o=this.root("@root"),!o)return null;let i=a((s,l)=>(s.refTo&&(s=s.refTo),s.children.find(d=>d.name===l)),"findChild");for(let s of n){let l=i(o,s);if(!l)return null;o=l}return o}walk(e,t){for(let n of this.roots())if(n.walk(e,t))return}observe(e){this.observers.push(e)}};a(X,"Bus");var Ye=a(()=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2);return r+e},"uniqueId");var E=class{constructor(e,t){this._bus=e,this._id=t}[Symbol.for("Deno.customInspect")](){return`Node[${this.id}:${this.name}]`}get id(){return this._id}get bus(){return this._bus}get raw(){let e=this._bus.nodes[this.id];if(!e)throw`use of non-existent node ${this.id}`;return e}get name(){return this.refTo?this.refTo.name:this.raw.Name}set name(e){this.refTo?this.refTo.name=e:this.raw.Name=e,this.changed()}get value(){return this.refTo?this.refTo.value:this.raw.Value}set value(e){this.refTo?this.refTo.value=e:this.raw.Value=e,this.changed()}get parent(){return!this.raw.Parent||!this._bus.nodes[this.raw.Parent]?null:new E(this._bus,this.raw.Parent)}set parent(e){let t=this.parent;t!==null&&t.raw.Linked.Children.splice(this.siblingIndex,1),e!==null?(this.raw.Parent=e.id,e.raw.Linked.Children.push(this.id),V(e,"onAttach",e)):this.raw.Parent=void 0,this.changed()}get refTo(){let e=this.raw.Attrs.refTo;return!e||!this._bus.nodes[e]?null:new E(this._bus,e)}set refTo(e){if(!e){delete this.raw.Attrs.refTo,this.changed();return}this.raw.Attrs.refTo=e.id,this.changed()}get siblingIndex(){let e=this.parent;if(e===null)return 0;let t=this.raw.Rel||"Children";return e.raw.Linked[t].findIndex(n=>n===this.id)}set siblingIndex(e){let t=this.parent;if(t===null)return;let n=this.raw.Rel||"Children";t.raw.Linked[n].splice(this.siblingIndex,1),t.raw.Linked[n].splice(e,0,this.id),t.changed()}get prevSibling(){let e=this.parent;if(e===null||this.siblingIndex===0)return null;let t=this.raw.Rel||"Children";return e.getLinked(t)[this.siblingIndex-1]}get nextSibling(){let e=this.parent;if(e===null||this.siblingIndex===e.children.length-1)return null;let t=this.raw.Rel||"Children";return e.getLinked(t)[this.siblingIndex+1]}get ancestors(){let e=[],t=this.parent;for(;t!==null;)e.push(t),t=t.parent;return e}get isDestroyed(){return!this._bus.nodes.hasOwnProperty(this.id)}get path(){let e=this,t=[];for(;e;)t.unshift(e.name),e=e.parent;return t.join("/")}get children(){if(this.refTo)return this.refTo.children;let e=[];this.raw.Linked.Children&&(e=this.raw.Linked.Children.map(t=>new E(this._bus,t)));for(let t of this.components)if(z(t,"objectChildren"))return V(t,"objectChildren",this,e);return e}get childCount(){if(this.refTo)return this.refTo.childCount;for(let e of this.components)if(z(e,"objectChildren"))return V(e,"objectChildren",this,null).length;return this.raw.Linked.Children?this.raw.Linked.Children.length:0}addChild(e){if(this.refTo){this.refTo.addChild(e);return}this.raw.Linked.Children.push(e.id),this.changed()}removeChild(e){if(this.refTo){this.refTo.removeChild(e);return}let t=this.raw.Linked.Children.filter(n=>n===e.id);this.raw.Linked.Children=t,this.changed()}get fields(){return this.raw.Linked.Fields?this.raw.Linked.Fields.map(e=>new E(this._bus,e)):[]}get fieldCount(){return this.raw.Linked.Fields?this.raw.Linked.Fields.length:0}get components(){return this.raw.Linked.Components?this.raw.Linked.Components.map(e=>new E(this._bus,e)):[]}get componentCount(){return this.raw.Linked.Components?this.raw.Linked.Components.length:0}addComponent(e){let t=this.bus.make(Q(e),e);t.raw.Parent=this.id,t.raw.Rel="Components",this.raw.Linked.Components.push(t.id),V(t,"onAttach",t),this.changed()}removeComponent(e){let t;e.name&&Y(e)?t=this.components.filter(n=>n.name===Q(e)):t=this.components.filter(n=>n.value===e),t.length>0&&t[0].destroy(),this.changed()}hasComponent(e){return this.components.filter(n=>n.name===Q(e)).length>0}getComponent(e){let t=this.components.filter(n=>n.name===Q(e));return t.length>0?t[0].value:null}getLinked(e){return this.raw.Linked[e]?this.raw.Linked[e].map(t=>new E(this._bus,t)):[]}addLinked(e,t){this.raw.Linked[e]||(this.raw.Linked[e]=[]),t.raw.Rel=e,this.raw.Linked[e].push(t.id),this.changed()}removeLinked(e,t){this.raw.Linked[e]||(this.raw.Linked[e]=[]);let n=this.raw.Linked[e].filter(o=>o===t.id);this.raw.Linked[e]=n,this.changed()}moveLinked(e,t,n){this.raw.Linked[e]||(this.raw.Linked[e]=[]);let o=this.raw.Linked[e].findIndex(s=>s===t.id);if(o===-1)return;let i=this.raw.Linked[e];i.splice(n,0,i.splice(o,1)[0]),this.raw.Linked[e]=i,this.changed()}getAttr(e){return this.raw.Attrs[e]||""}setAttr(e,t){this.raw.Attrs[e]=t,this.changed()}find(e){return this.bus.find([this.path,e].join("/"))}walk(e,t){if(t=t||{followRefs:!1,includeComponents:!1},e(this))return!0;let n=this.children;if(this.refTo&&t.followRefs){if(e(this.refTo))return!0;n=this.refTo.children}for(let o of n)if(o.walk(e,t))return!0;if(t.includeComponents){for(let o of this.components)if(o.walk(e,t))return!0}return!1}destroy(){if(this.isDestroyed)return;if(this.refTo){this._bus.destroy(this);return}let e=[];this.walk(t=>(e.push(t),!1),{followRefs:!1,includeComponents:!0}),e.reverse().forEach(t=>this._bus.destroy(t))}duplicate(){let e=this._bus.make(this.name,Ce(this.value));return e.raw.Rel=this.raw.Rel,this.fields.map(t=>t.duplicate()).forEach(t=>{e.addLinked("Fields",t),t.raw.Parent=e.raw.ID}),this.components.map(t=>t.duplicate()).forEach(t=>{e.addLinked("Components",t),t.raw.Parent=e.raw.ID}),this.children.map(t=>t.duplicate()).forEach(t=>{e.addChild(t),t.raw.Parent=e.raw.ID}),e}changed(){this._bus.changed(this)}};a(E,"Node");var _=class{constructor(e){this.fs=e,this.bus=new X,this.expanded={},this.settings={},this.writeDebounce=_e(async(t,n)=>{try{await this.fs.writeFile(t,n),console.log("Saved workspace.")}catch(o){console.error(o),document.dispatchEvent(new CustomEvent("BackendError"))}})}get rawNodes(){return this.bus.export()}observe(e){this.bus.observe(e)}async save(e){let t=JSON.stringify({version:1,lastopen:this.lastOpenedID,expanded:this.expanded,nodes:this.rawNodes,settings:this.settings},null,2);e?await this.fs.writeFile("workspace.json",t):this.writeDebounce("workspace.json",t)}async load(){let e=JSON.parse(await this.fs.readFile("workspace.json")||"{}");if(e.nodes&&(e.nodes=e.nodes.map(t=>(t.Name==="treehouse.SearchNode"&&(t.Name="treehouse.SmartNode"),t)),this.bus.import(e.nodes),console.log(`Loaded ${e.nodes.length} nodes.`)),e.expanded)for(let t in e.expanded)for(let n in e.expanded[t])this.bus.find(n)&&(this.expanded[t]||(this.expanded[t]={}),this.expanded[t][n]=e.expanded[t][n]);e.lastopen&&(this.lastOpenedID=e.lastopen),e.settings&&(this.settings=Object.assign(this.settings,e.settings))}mainNode(){let e=this.bus.find("@workspace");if(!e){console.info("Building missing workspace node.");let t=this.bus.find("@root"),n=this.bus.make("@workspace");n.name="Workspace",n.parent=t;let o=this.bus.make("@calendar");o.name="Calendar",o.parent=n;let i=this.bus.make("Home");i.parent=n,e=n}return e}find(e){return this.bus.find(e)}new(e,t){return this.bus.make(e,t)}getExpanded(e,t){this.expanded[e.id]||(this.expanded[e.id]={});let n=this.expanded[e.id][t.id];return n===void 0&&(n=!1),n}setExpanded(e,t,n){this.expanded[e.id]||(this.expanded[e.id]={}),this.expanded[e.id][t.id]=n,this.save()}findAbove(e){if(e.node.id===e.head.id)return null;let t=e.clone();t.pop();let n=e.node.prevSibling;if(!n){let i=e.previous.getLinked("Fields").length;return e.node.raw.Rel!=="Fields"&&i>0?t.append(e.previous.getLinked("Fields")[i-1]):t}let o=a(i=>{if(!this.getExpanded(e.head,i.node))return i;let l=i.node.getLinked("Fields").length;if(i.node.childCount===0&&l>0){let c=i.node.getLinked("Fields")[l-1];return o(i.append(c))}if(i.node.childCount===0)return i;let d=i.node.children[i.node.childCount-1];return o(i.append(d))},"lastSubIfExpanded");return o(t.append(n))}findBelow(e){let t=e.clone();if(this.getExpanded(e.head,e.node)&&e.node.getLinked("Fields").length>0)return t.append(e.node.getLinked("Fields")[0]);if(this.getExpanded(e.head,e.node)&&e.node.childCount>0)return t.append(e.node.children[0]);let n=a(o=>{let i=o.node.nextSibling;if(i)return o.pop(),o.append(i);let s=o.previous;return s?o.node.raw.Rel==="Fields"&&s.childCount>0?(o.pop(),o.append(s.children[0])):(o.pop(),n(o)):null},"nextSiblingOrParentNextSibling");return n(t)}};a(_,"Workspace");function _e(r,e=3e3){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{r.apply(this,n)},e)}}a(_e,"debounce");var je={view({attrs:r,children:e}){let t=r.open;return m("div",{class:`drawer ${t?"open":"closed"}`},e)}};var R=class{constructor(){this.markdown=""}};a(R,"Page"),R=D([I],R);var Me={view({attrs:r}){let e=r.path,t=r.workbench,n=e.node,o=a(p=>{t.executeCommand("close-panel",{},e)},"close"),i=a(p=>{e.pop()===e.node&&e.pop()},"goBack"),s=a(p=>{t.panels=[e],t.context.path=e},"maximize"),l=a(p=>{n.getComponent(R).markdown=p.target.value,n.changed()},"editMarkdown");function d(p=""){return 20+(p.match(/\n/g)||[]).length*20}a(d,"calcHeight");let c="";return n.getAttr("view")&&(c=`${n.getAttr("view")}-panel`),m("div",{class:`panel flex flex-col grow ${c}`},m("div",{class:"bar flex"},e.length>1?m("div",{class:"panel-back",style:{rightPadding:"var(--padding)"}},m("svg",{onclick:i,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},m("path",{"fill-rule":"evenodd",d:"M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"}))):null,m("div",{class:"panel-back-parent grow"},n.parent&&n.parent.id!=="@root"?m("span",{style:{cursor:"pointer"},onclick:()=>t.open(n.parent)},n.parent.name):m("span",null,"\xA0")),t.panels.length>1?m("div",{class:"panel-icons flex items-center"},m("svg",{onclick:s,style:{cursor:"pointer"},xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-maximize-2"},m("polyline",{points:"15 3 21 3 21 9"}),m("polyline",{points:"9 21 3 21 3 15"}),m("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),m("line",{x1:"3",y1:"21",x2:"10",y2:"14"})),m("svg",{onclick:o,style:{cursor:"pointer"},xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},m("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null),m("div",{class:"body flex flex-col"},m("div",{class:"title-node",oncontextmenu:p=>t.showMenu(p,{node:n,path:e}),"data-menu":"node"},m(W,{workbench:t,path:e,disallowEmpty:!0})),n.hasComponent(R)?m("textarea",{oninput:l,value:n.getComponent(R).markdown,placeholder:"Enter Markdown text here",style:{marginLeft:"var(--padding)",padding:"var(--padding)",outline:"0",height:`${d(n.getComponent(R).markdown)}px`,border:"0"}},n.getComponent(R).markdown):null,m(de,{workbench:t,path:e.sub(),alwaysShowNew:!0})))}};var Oe={view({attrs:r}){let e=r.workbench,t={"":["pick-command"],Edit:["cut","copy","copy-reference","paste","mark-done","insert","delete"],Navigate:["expand","collapse","indent","outdent","move-up","move-down","prev","next"]},n=a(o=>{let i=e.keybindings.getBinding(o.id);return i?K(i.key).join(" ").toUpperCase():""},"getBindingSymbols");return m("div",{class:"reference"},m("h2",null,"Keyboard Shortcuts"),Object.entries(t).map(([o,i])=>m("div",null,o.length!==0&&m("h3",null,o),m("div",null,i.map(s=>e.commands.commands[s]).map(s=>m("div",{class:"flex item"},m("div",{class:"keybindings text-left"},n(s)),m("div",{class:"grow"},s.title)))))))}};var me={view({attrs:{input:r,workbench:e}}){return m("div",{class:"search"},m(J,{onpick:a(o=>{e.closeDialog(),e.open(o)},"onpick"),onchange:a(o=>{o.input?o.items=e.search(o.input):o.items=[]},"onchange"),input:r,inputview:(o,i,s)=>m("div",{class:"flex items-center"},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0 items-center"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),m("input",{type:"text",placeholder:"Search",value:s,onkeydown:o,oninput:i})),itemview:o=>m("div",null,o.name)}))}};var He={view({attrs:{workbench:r},state:e}){e.open=e.open===void 0?!0:e.open;let t=a(n=>{e.open?e.open=!1:e.open=!0},"toggle");return m("main",{class:"workbench m-0 flex flex-row absolute inset-0",style:{overflow:"none"}},m("div",{class:"sidebar flex flex-col",style:{width:e.open?"256px":"52px"}},m("div",{class:"sidebar-top",style:{height:"56px"}},m("div",{class:"logo"})),m("div",{class:"grow sidebar-main"},e.open&&r.workspace.bus.root().children.map(n=>m($e,{node:n,expanded:!0,level:0,workbench:r}))),m("div",{class:"sidebar-bottom"},m("svg",{onclick:t,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-sidebar"},m("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"9",y1:"3",x2:"9",y2:"21"})))),m("div",{class:"main flex flex-col grow"},m("div",{class:"topbar flex"},m("div",{class:"topbar-item",onclick:()=>r.openToday(),style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",display:"flex",alignItems:"center"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-calendar"},m("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),m("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),m("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),m("div",null,"Today")),m("div",{class:"topbar-item",onclick:()=>r.openQuickAdd(),style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",display:"flex",alignItems:"center"}},m("svg",{style:{marginRight:"var(--1)"},xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-plus-circle"},m("circle",{cx:"12",cy:"12",r:"10"}),m("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),m("line",{x1:"8",y1:"12",x2:"16",y2:"12"})),m("div",null,"Quick Add")),m("div",{class:"searchbar flex grow"},m("div",null,m("div",{class:"flex",style:{margin:"1px"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),m("input",{type:"text",placeholder:"Search",onkeydown:n=>{if(n.key==="Control"||n.key==="Alt"||n.key==="Shift"||n.key==="Meta")return;let o=n.target.getBoundingClientRect();r.showDialog(()=>m(me,{workbench:r,input:n.key}),!1,{left:`${o.left-33}px`,top:`${o.top-9}px`,width:`${o.width+33}px`}),n.preventDefault()},style:{border:"0",outline:"0",background:"transparent",paddingTop:"3px"}})))),m("div",{onclick:()=>r.toggleDrawer(),"data-menu":"keyboard-reference","data-align":"right",style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",marginTop:"-2px"}},m("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},m("g",{"clip-path":"url(#clip0_442_8012)"},m("path",{d:"M20 6H4C2.89543 6 2 6.76751 2 7.71429V16.2857C2 17.2325 2.89543 18 4 18H20C21.1046 18 22 17.2325 22 16.2857V7.71429C22 6.76751 21.1046 6 20 6Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M6 10H6.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M7.5 12H7.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M10.5 12H10.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M13.5 12H13.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M16.5 12H16.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M9 10H9.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M12 10H12.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M15 10H15.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M18 10H18.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M5 15H19",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})),m("defs",null,m("clipPath",{id:"clip0_442_8012"},m("rect",{width:"22",height:"14",fill:"white",transform:"translate(1 5)"}))))),m("div",{onclick:n=>r.showMenu(n),"data-menu":"settings","data-align":"right",style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})))),m("div",{class:"panels flex flex-row grow",style:{position:"relative",overflow:"hidden"}},r.panels.map(n=>m("div",null,m(Me,{workbench:r,path:n}))),m(je,{open:r.drawer.open},m(Oe,{workbench:r}))),m("div",{class:"mobile-nav flex-row"},m("div",null,m("svg",{onclick:()=>{let n=document.querySelector(".sidebar").style;n.display!=="flex"?n.display="flex":n.display="none"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-sidebar"},m("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"9",y1:"3",x2:"9",y2:"21"}))),m("div",{onclick:()=>r.openToday()},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-calendar"},m("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),m("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),m("line",{x1:"3",y1:"10",x2:"21",y2:"10"}))),m("div",{onclick:()=>r.openQuickAdd()},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-plus-circle"},m("circle",{cx:"12",cy:"12",r:"10"}),m("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),m("line",{x1:"8",y1:"12",x2:"16",y2:"12"}))),m("div",{onclick:()=>r.showDialog(()=>m(me,{workbench:r}),!0,{top:"25%",bottom:"100px"})},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}))),m("div",{onclick:n=>r.showMenu(n,void 0,{bottom:"100px",marginTop:"auto"}),"data-menu":"settings"},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"}))))),r.popover&&m("div",{class:"popover",style:{position:"absolute",...r.popover.style}},r.popover.body()),m("dialog",{class:r.dialog.backdrop?"popover modal backdrop":"popover modal",style:r.dialog.style?{margin:"0",...r.dialog.style}:{top:"-50%"},oncancel:n=>{if(r.dialog.explicitClose===!0){n.preventDefault();return}r.dialog.body=()=>null},onclick:n=>{let i=n.target.closest("dialog").getBoundingClientRect(),s=n.clientX==0&&n.clientY==0;r.dialog.explicitClose!==!0&&(n.clientXi.right||n.clientYi.bottom)&&!s&&r.closeDialog()}},r.dialog.body()),m("dialog",{class:"menu popover",style:{margin:"0",...r.menu.style},oncancel:n=>{r.menu.body=()=>null},onclick:n=>{let i=n.target.closest("dialog").getBoundingClientRect();(n.clientXi.right||n.clientYi.bottom)&&r.closeMenu()}},r.menu.body()))}},$e={view({attrs:{node:r,workbench:e,expanded:t,level:n},state:o}){o.expanded=o.expanded===void 0?t:o.expanded;let i=r.childCount>0&&n<3,s=a(d=>{i&&(o.expanded?o.expanded=!1:o.expanded=!0,d.stopPropagation())},"toggle"),l=a(d=>{document.querySelector(".mobile-nav").offsetHeight&&(document.querySelector(".sidebar").style.display="none"),e.open(r)},"open");return m("div",null,m("div",{class:"sidebar-item flex"},m("svg",{onclick:s,class:"feather feather-chevron-right shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},i?o.expanded?m("polyline",{points:"6 9 12 15 18 9"}):m("polyline",{points:"9 18 15 12 9 6"}):null),m("div",{class:"sidebar-item-label grow",onclick:l,style:{cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},r.name)),o.expanded&&m("div",{class:"sidebar-item-nested"},r.children.filter(d=>d.name!=="").map(d=>m($e,{workbench:e,node:d,level:n+1}))))}};var A=class{constructor(){this.checked=!1}beforeEditor(){return Xe}};a(A,"Checkbox"),A=D([I],A);var Xe={view({attrs:{node:r}}){return m("input",{type:"checkbox",style:{marginTop:"0.3rem"},onclick:a(t=>{let n=r.getComponent(A);n.checked=!n.checked,r.changed()},"toggleCheckbox"),checked:r.getComponent(A).checked})}};var U=class{constructor(){}handleIcon(){return m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("polyline",{points:"4 7 4 4 20 4 20 7"}),m("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),m("line",{x1:"12",y1:"4",x2:"12",y2:"20"}))}};a(U,"TextField"),U=D([I],U);var b=class{constructor(){this.log=[],this.showLog=!1}onAttach(e){this.component=e,this.object=e.parent}fromJSON(e){e.startedAt&&(this.startedAt=new Date(e.startedAt)),this.log=(e.log||[]).map(t=>[new Date(t[0]),new Date(t[1])]),this.showLog=e.showLog}toJSON(e){return{startedAt:this.startedAt,log:this.log,showLog:this.showLog}}localTotal(){return this.log.map(this.entryDuration).reduce((e,t)=>e+t,0)}grandTotal(){let e=this.localTotal();return this.object&&this.object.children.forEach(t=>{t.hasComponent(b)&&(e+=t.getComponent(b).grandTotal())}),e}start(){this.startedAt||(this.startedAt=new Date)}stop(){if(!this.startedAt)return;let e=new Date;(e.getTime()-this.startedAt.getTime())/1e3>=60&&this.log.push([this.startedAt,e]),this.startedAt=void 0}formatEntry(e){return e.length!==2?"":`${this.formatDate(e[0])} - ${new Intl.DateTimeFormat("en",{timeStyle:"short"}).format(e[1])}`}entryDuration(e){let t=e[0];return((e[1]||new Date).getTime()-t.getTime())/1e3}formatDate(e){return e?new Intl.DateTimeFormat("en",{dateStyle:"short",timeStyle:"short"}).format(e):""}formatDuration(e){let t=e/60,n=Math.floor(t%60);return t=t/60,`${Math.floor(t%60)}:${n.toLocaleString("en-US",{minimumIntegerDigits:2,useGrouping:!1})}`}afterEditor(){return Ze}belowEditor(){return et}static initialize(e){e.commands.registerCommand({id:"stop-clock",title:"Stop clock",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{if(!t.node.hasComponent(b)){let n=new b;t.node.addComponent(n)}t.node.getComponent(b).stop(),t.node.changed()}}),e.keybindings.registerBinding({command:"stop-clock",key:"meta+o"}),e.commands.registerCommand({id:"start-clock",title:"Start clock",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{if(!t.node.hasComponent(b)){let n=new b;t.node.addComponent(n)}t.node.getComponent(b).start(),t.node.changed()}}),e.keybindings.registerBinding({command:"start-clock",key:"meta+i"}),e.commands.registerCommand({id:"remove-clock",title:"Remove clock",when:t=>!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)?!1:!!t.node.hasComponent(b),action:t=>{t.node.removeComponent(b)}})}};a(b,"Clock"),b=D([I],b);var Ze={view({attrs:{node:r}}){let e=r.getComponent(b),t=a(()=>{e.showLog=!e.showLog,r.changed()},"toggleLog");return!e.showLog&&e.startedAt?m("div",{tabindex:"1",onclick:t,class:"badge flex flex-row items-center",style:{background:"green",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{class:"blink",style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration([e.startedAt])))):m("div",{tabindex:"1",onclick:t,class:"badge flex flex-row items-center",style:{background:"gray",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.grandTotal())))}},et={view({attrs:{node:r}}){let e=r.getComponent(b);if(e.showLog)return m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex"}),m("div",{class:"grow"},e.startedAt&&m("div",{class:"flex flex-row",style:{marginBottom:"2px"}},m("div",{class:"grow"},e.formatDate(e.startedAt)," - ..."),m("div",{class:"flex flex-row items-center",style:{background:"green",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{class:"blink",style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration([e.startedAt]))))),e.log.toReversed().map(t=>m("div",{class:"flex flex-row",style:{marginBottom:"2px"}},m("div",{class:"grow"},e.formatEntry(t)),m("div",{class:"flex flex-row items-center",style:{background:"#aaa",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration(t))))))))}};var Z=class{constructor(){this.auth=null,this.files=new ce,window.MiniSearch?this.index=new re:this.index=new le}};a(Z,"BrowserBackend");var re=class{constructor(){this.indexer=new MiniSearch({idField:"ID",fields:["ID","Name","Value","Value.markdown"],storeFields:["ID"],extractField:(e,t)=>t.split(".").reduce((n,o)=>n&&n[o],e)})}index(e){this.indexer.has(e.ID)?this.indexer.replace(e):this.indexer.add(e)}remove(e){try{this.indexer.discard(e)}catch{}}search(e){let t=this.indexer.autoSuggest(e);return t.length===0?[]:this.indexer.search(t[0].suggestion,{prefix:!0,combineWith:"AND"}).map(n=>n.ID)}};a(re,"SearchIndex_MiniSearch");var le=class{constructor(){this.nodes={}}index(e){this.nodes[e.ID]=e.Name}remove(e){delete this.nodes[e]}search(e){let t=[];for(let n in this.nodes)this.nodes[n].includes(e)&&t.push(n);return t}};a(le,"SearchIndex_Dumb");var ce=class{async readFile(e){return localStorage.getItem(`treehouse:${e}`)}async writeFile(e,t){localStorage.setItem(`treehouse:${e}`,t)}};a(ce,"FileStore");import{encode as tt,decode as nt}from"https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.mjs";var ue=class{constructor(e,t,n){this.loginURL=e,this.clientFactory=t,this.auth=this,this.shas={},this.opts=Object.assign({domain:"treehouse.sh",checkDomain:!1,privateRepo:!1},n||{});let o=new Z;this.index=o.index,this.files=o.files}get repoName(){return`${this.user?.userID().toLowerCase()}.${this.opts.domain}`}async initialize(){let e=new URL(location.href).searchParams.get("code");if(e)try{let i=location.search.replace(/\bcode=\w+/,"").replace(/\?$/,"");history.pushState({},"",`${location.pathname}${i}`);let l=await(await fetch(this.loginURL,{method:"POST",mode:"cors",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})})).json();if(l.error)throw l.error;localStorage.setItem("treehouse:gh-token",l.token)}catch(i){this.reset(),console.error(i);return}let t=new URL(location.href).searchParams.get("access_token");if(t)try{let i=location.search.replace(/\baccess_token=\w+/,"").replace(/\?$/,"");history.pushState({},"",`${location.pathname}${i}`),localStorage.setItem("treehouse:gh-token",t)}catch(i){this.reset(),console.error(i);return}try{if(await this.authenticate(),!this.user)throw"authentication failed"}catch(i){console.error(i),this.opts.authFallbackURL&&(location.href=this.opts.authFallbackURL);return}if(this.opts.checkDomain&&this.repoName!==location.hostname.toLowerCase()){location.hostname=this.repoName;return}try{await this.client.rest.repos.get({owner:this.user.userID(),repo:this.repoName})}catch(i){if(i.message!=="Not Found")throw i;console.log("Creating repository...");let s=await this.client.rest.repos.createForAuthenticatedUser({name:this.repoName,private:this.opts.privateRepo});if(s.status!==201){console.error(s);return}}try{await this.client.rest.repos.getContent({owner:this.user.userID(),repo:this.repoName,path:"workspace.json"})}catch(i){if(i.name!=="HttpError")throw i;console.log("Creating workspace.json...");let s=await this.client.rest.repos.createOrUpdateFileContents({owner:this.user.userID(),repo:this.repoName,path:"workspace.json",message:"initial commit",content:btoa(JSON.stringify([]))});if(s.status!==201){console.error(s);return}}this.files=this;let n=ot();await this.readFile("treehouse.lock"),await this.writeFile("treehouse.lock",n);let o=setInterval(async()=>{await this.readFile("treehouse.lock")!==n&&(clearInterval(o),document.dispatchEvent(new CustomEvent("BackendError")),console.warn("lock stolen!"))},5e3)}async loadExtensions(){try{if((await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:"",random:Math.random().toString(36).substring(2)})).data.find(t=>t.type==="dir"&&t.name==="ext")){let t=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:"ext",random:Math.random().toString(36).substring(2)});for(let n of t.data)if(n.name.endsWith(".css")){let o=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:n.path,random:Math.random().toString(36).substring(2)}),i=document.createElement("link");i.setAttribute("href",`data:text/css;charset=utf-8;base64,${o.data.content}`),i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),document.head.appendChild(i)}else if(n.name.endsWith(".js")){let o=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:n.path,random:Math.random().toString(36).substring(2)}),i=document.createElement("script");i.setAttribute("type","module"),i.setAttribute("src",`data:text/javascript;charset=utf-8;base64,${o.data.content}`),document.head.appendChild(i)}}}catch{}}async authenticate(){let e=localStorage.getItem("treehouse:gh-token");if(!e)return;this.client=new this.clientFactory({auth:e});let t=await this.client.rest.users.getAuthenticated();!t||t.error||(this.user=new pe(t.data),m&&m.redraw())}currentUser(){return this.user}login(){location.assign(this.loginURL)}reset(){localStorage.removeItem("treehouse:gh-token"),this.user=null,m&&m.redraw()}logout(){this.reset(),location.reload()}async readFile(e){try{let t=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:e,random:Math.random().toString(36).substring(2)});return this.shas[e]=t.data.sha,nt(t.data.content)}catch(t){return t.name!=="HttpError"&&console.error(t),null}}async writeFile(e,t){let n=await this.client.rest.repos.createOrUpdateFileContents({owner:this.user?.userID(),repo:this.repoName,path:e,message:"autosave",content:tt(t),sha:this.shas[e]});this.shas[e]=n.data.content.sha}};a(ue,"GitHubBackend");var pe=class{constructor(e){this.user=e}userID(){return this.user.login}displayName(){return this.user.name}avatarURL(){return this.user.avatar_url}};a(pe,"User");function ot(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2);return r+e}a(ot,"uniqueID");async function ri(r,e,t){t.initialize&&await t.initialize();let n=new G(t);window.workbench=n,await n.initialize(),[b,U,R,v,A,L,O,H].forEach(o=>{o.initialize&&o.initialize(n)}),r.addEventListener("BackendError",()=>{n.showNotice("lockstolen",()=>{location.reload()})}),n.commands.registerCommand({id:"cut",title:"Cut",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"cut",node:o.node}}}),n.keybindings.registerBinding({command:"cut",key:"meta+x"}),n.commands.registerCommand({id:"copy",title:"Copy",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"copy",node:o.node}}}),n.keybindings.registerBinding({command:"copy",key:"meta+c"}),n.commands.registerCommand({id:"copy-reference",title:"Copy as Reference",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"copyref",node:o.node}}}),n.keybindings.registerBinding({command:"copy-reference",key:"shift+ctrl+c"}),n.commands.registerCommand({id:"paste",title:"Paste",when:o=>!!n.clipboard,action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;switch(n.clipboard.op){case"copy":n.clipboard.node=n.clipboard.node.duplicate();break;case"copyref":let s=n.workspace.new("");s.refTo=n.clipboard.node,n.clipboard.node=s;break}n.clipboard.node.raw.Rel==="Fields"?(n.clipboard.node.raw.Parent=o.node.parent.id,o.node.parent.addLinked("Fields",n.clipboard.node)):(n.clipboard.node.parent=o.node.parent,n.clipboard.node.siblingIndex=o.node.siblingIndex),m.redraw.sync();let i=o.path.clone();i.pop(),n.focus(i.append(n.clipboard.node))}}),n.keybindings.registerBinding({command:"paste",key:"meta+v"}),n.commands.registerCommand({id:"view-list",title:"View as List",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{o.node.setAttr("view","list")}}),n.commands.registerCommand({id:"view-table",title:"View as Table",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{o.node.setAttr("view","table"),o.node.children.forEach(i=>{n.workspace.setExpanded(o.path.head,i,!1)})}}),n.commands.registerCommand({id:"view-tabs",title:"View as Tabs",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{o.node.setAttr("view","tabs")}}),n.commands.registerCommand({id:"add-checkbox",title:"Add checkbox",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{let i=new A;o.node.addComponent(i)}}),n.commands.registerCommand({id:"remove-checkbox",title:"Remove checkbox",when:o=>!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)?!1:!!o.node.hasComponent(A),action:o=>{o.node.removeComponent(A)}}),n.commands.registerCommand({id:"create-field",title:"Create Field",action:o=>{if(!o.node||o.node.childCount>0||o.node.componentCount>0||o.path.previous&&M(o.path.previous))return;let i=o.path.clone();i.pop();let s=n.workspace.new(o.node.name,"");s.raw.Parent=o.node.parent.id;let l=new U;s.addComponent(l),o.node.parent.addLinked("Fields",s),i.push(s),o.node.destroy(),m.redraw.sync(),n.focus(i)}}),n.commands.registerCommand({id:"mark-done",title:"Mark Done",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{if(o.node)if(o.node.hasComponent(A)){let i=o.node.getComponent(A);i.checked?o.node.removeComponent(A):(i.checked=!0,o.node.changed())}else{let i=new A;o.node.addComponent(i)}}}),n.keybindings.registerBinding({command:"mark-done",key:"meta+enter"}),n.commands.registerCommand({id:"expand",title:"Expand",action:o=>{o.node&&(n.workspace.setExpanded(o.path.head,o.node,!0),m.redraw())}}),n.keybindings.registerBinding({command:"expand",key:"meta+arrowdown"}),n.commands.registerCommand({id:"collapse",title:"Collapse",action:o=>{o.node&&(n.workspace.setExpanded(o.path.head,o.node,!1),m.redraw())}}),n.keybindings.registerBinding({command:"collapse",key:"meta+arrowup"}),n.commands.registerCommand({id:"indent",title:"Indent",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{let i=o.node,s=o.path.clone(),l=i.prevSibling;for(;l&&M(l);)if(l=l.prevSibling,!l)return;l!==null&&(s.pop(),s.push(l),i.parent=l,s.push(i),n.workspace.setExpanded(o.path.head,l,!0),m.redraw.sync(),n.focus(s))}}),n.keybindings.registerBinding({command:"indent",key:"tab"}),n.commands.registerCommand({id:"outdent",title:"Outdent",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.path.previous&&M(o.path.previous)||o.node.parent&&o.node.parent.hasComponent(v)),action:o=>{let i=o.node,s=o.path.previous,l=o.path.clone();s!==null&&s.id!=="@root"&&s.id!==n.workspace.lastOpenedID&&(l.pop(),l.pop(),i.parent=s.parent,l.push(i),i.siblingIndex=s.siblingIndex+1,s.childCount===0&&s.getLinked("Fields").length===0&&n.workspace.setExpanded(o.path.head,s,!1),m.redraw.sync(),n.focus(l))}}),n.keybindings.registerBinding({command:"outdent",key:"shift+tab"}),n.commands.registerCommand({id:"move-up",title:"Move Up",action:o=>{if(!o.node)return;let i=o.node,s=i.parent;if(s!==null&&s.id!=="@root"){let l=s.childCount;if(i.siblingIndex===0){if(!s.prevSibling)return;let d=o.path.clone();d.pop(),d.pop();let c=s.prevSibling;for(;c&&M(c);)if(c=c.prevSibling,!c)return;d.push(c),d.push(i),i.parent=c,i.siblingIndex=c.childCount-1,n.workspace.setExpanded(o.path.head,c,!0),m.redraw.sync(),n.focus(d)}else{if(l===1)return;i.siblingIndex=i.siblingIndex-1,m.redraw.sync()}}}}),n.keybindings.registerBinding({command:"move-up",key:"shift+meta+arrowup"}),n.commands.registerCommand({id:"move-down",title:"Move Down",action:o=>{if(!o.node)return;let i=o.node,s=i.parent;if(s!==null&&s.id!=="@root"){let l=s.childCount;if(i.siblingIndex===l-1){if(!s.nextSibling)return;let d=o.path.clone();d.pop(),d.pop();let c=s.nextSibling;for(;c&&M(c);)if(c=c.nextSibling,!c)return;d.push(c),d.push(i),i.parent=c,i.siblingIndex=0,n.workspace.setExpanded(o.path.head,c,!0),m.redraw.sync(),n.focus(d)}else{if(l===1)return;i.siblingIndex=i.siblingIndex+1,m.redraw.sync()}}}}),n.keybindings.registerBinding({command:"move-down",key:"shift+meta+arrowdown"}),n.commands.registerCommand({id:"insert-child",title:"Insert Child",action:(o,i="",s)=>{if(!o.node||M(o.node))return;let l=n.workspace.new(i);l.parent=o.node,s!==void 0&&(l.siblingIndex=s),n.workspace.setExpanded(o.path.head,o.node,!0),m.redraw.sync(),n.focus(o.path.append(l),i.length)}}),n.commands.registerCommand({id:"insert-before",title:"Insert Before",action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let i=n.workspace.new("");i.parent=o.node.parent,i.siblingIndex=o.node.siblingIndex,m.redraw.sync();let s=o.path.clone();s.pop(),n.focus(s.append(i))}}),n.commands.registerCommand({id:"insert",title:"Insert Node",action:(o,i="")=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let s=n.workspace.new(i);s.parent=o.node.parent,s.siblingIndex=o.node.siblingIndex+1,m.redraw.sync();let l=o.path.clone();l.pop(),n.focus(l.append(s))}}),n.keybindings.registerBinding({command:"insert",key:"shift+enter"}),n.commands.registerCommand({id:"create-reference",title:"Create Reference",action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let i=n.workspace.new("");i.parent=o.node.parent,i.siblingIndex=o.node.siblingIndex+1,i.refTo=o.node,m.redraw.sync();let s=o.path.clone();s.pop(),n.focus(s.append(i))}}),n.commands.registerCommand({id:"delete",title:"Delete Node",action:o=>{if(!o.node||o.node.id.startsWith("@")||o.path.previous&&M(o.path.previous))return;let i=n.workspace.findAbove(o.path);if(o.node.destroy(),m.redraw.sync(),i){let s=0;o.event&&o.event.key==="Backspace"&&(i.node.value?s=i.node.value.length:s=i.node.name.length),i.node.childCount===0&&n.workspace.setExpanded(o.path.head,i.node,!1),n.focus(i,s)}}}),n.keybindings.registerBinding({command:"delete",key:"shift+meta+backspace"}),n.commands.registerCommand({id:"prev",title:"Previous Node",action:o=>{if(!o.node)return;let i=n.workspace.findAbove(o.path);i&&n.focus(i)}}),n.keybindings.registerBinding({command:"prev",key:"arrowup"}),n.commands.registerCommand({id:"next",title:"Next Node",action:o=>{if(!o.node)return;let i=n.workspace.findBelow(o.path);i&&n.focus(i)}}),n.keybindings.registerBinding({command:"next",key:"arrowdown"}),n.commands.registerCommand({id:"pick-command",title:"Command Palette",hidden:!0,when:o=>!n.isDialogOpen(),action:o=>{let i=o.node,s=o.path,l=!1;i||(i=o.path.head,s=new T(o.path.head,o.path.name),l=!0);let d=n.getInput(s),c=d.getBoundingClientRect(),p=r.body.scrollLeft+c.x+d.selectionStart*10+20,h=r.body.scrollTop+c.y-8;d.coordsAtCursor&&(p=d.coordsAtCursor.left-17,h=d.coordsAtCursor.top-16),l&&(p=r.body.scrollLeft+c.x,h=r.body.scrollTop+c.y+c.height),n.showPalette(p,h,n.newContext({node:i}))}}),n.keybindings.registerBinding({command:"pick-command",key:"meta+k"}),n.commands.registerCommand({id:"new-panel",title:"Open in New Panel",action:o=>{o.node&&(n.openNewPanel(o.node),m.redraw())}}),n.commands.registerCommand({id:"close-panel",title:"Close Panel",action:(o,i)=>{n.closePanel(i||o.path),n.context.path=n.mainPanel,m.redraw()}}),n.commands.registerCommand({id:"zoom",title:"Open",action:o=>{n.workspace.lastOpenedID=o.node.id,n.workspace.save(),n.context.path=o.path.append(o.node),n.panels[0]=n.context.path,m.redraw()}}),n.commands.registerCommand({id:"generate-random",hidden:!0,title:"Generate Random Children",action:o=>{o.node&&[...Array(100)].forEach(()=>{let i=n.workspace.new(it(8));i.parent=o.node})}}),n.menus.registerMenu("node",[{command:"zoom"},{command:"new-panel"},{command:"cut"},{command:"copy"},{command:"paste"},{command:"indent"},{command:"outdent"},{command:"move-up"},{command:"move-down"},{command:"delete"}]),n.menus.registerMenu("settings",[{title:()=>`${n.backend.auth?.currentUser()?.userID()} @ GitHub`,disabled:!0,when:()=>n.authenticated()},{title:()=>"Login with GitHub",when:()=>!n.authenticated(),onclick:()=>{localStorage.getItem("github")?n.backend.auth.login():n.showNotice("github",()=>{n.backend.auth.login()})}},{title:()=>"Reset Demo",when:()=>!n.authenticated(),onclick:()=>{localStorage.clear(),location.reload()}},{title:()=>"Settings",onclick:()=>n.showSettings()},{title:()=>"Documentation",onclick:()=>window.open("https://treehouse.sh/docs/user","_blank")},{title:()=>"Submit Issue",onclick:()=>window.open("https://github.com/treehousedev/treehouse/issues","_blank")},{title:()=>"Logout",when:()=>n.authenticated(),onclick:()=>n.backend.auth.logout()}]),r.addEventListener("keydown",o=>{let i=n.keybindings.evaluateEvent(o);if(i&&n.canExecuteCommand(i.command,n.context)){n.executeCommand(i.command,n.context),o.stopPropagation(),o.preventDefault();return}}),m.mount(e,{view:()=>m(He,{workbench:n})})}a(ri,"setup");function it(r=10){let e=a((o,i)=>Math.round(Math.random()*(i-o)+o),"random"),t=a(()=>{let o=["got","ability","shop","recall","fruit","easy","dirty","giant","shaking","ground","weather","lesson","almost","square","forward","bend","cold","broken","distant","adjective"];return o[e(0,o.length-1)]},"word");return a(o=>[...Array(o)].map((i,s)=>t()).join(" ").trim(),"words")(e(2,r))}a(it,"generateName");export{Z as BrowserBackend,ue as GitHubBackend,re as SearchIndex_MiniSearch,ri as setup}; +var ge=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var a=(r,e)=>ge(r,"name",{value:e,configurable:!0});var L=(r,e,t,n)=>{for(var o=n>1?void 0:n?We(e,t):e,i=r.length-1,s;i>=0;i--)(s=r[i])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ge(e,t,o),o};var we=navigator.userAgent.toLowerCase().indexOf("mac")!==-1;function K(r){if(!r)return[];let e={backspace:"\u232B",shift:"\u21E7",meta:"\u2318",tab:"\u21B9",ctrl:"\u2303",arrowup:"\u2191",arrowdown:"\u2193",arrowleft:"\u2190",arrowright:"\u2192",enter:"\u23CE"};return r.toLowerCase().split("+").map(ve).map(n=>Object.keys(e).includes(n)?e[n]:n)}a(K,"bindingSymbols");function ve(r){return!we&&r==="meta"?"ctrl":r}a(ve,"filterKeyForNonMacMeta");var ee=class{constructor(){this.bindings=[]}registerBinding(e){this.bindings.push(e)}getBinding(e){for(let t of this.bindings)if(t.command===e)return t;return null}evaluateEvent(e){e:for(let t of this.bindings){let n=t.key.toLowerCase().split("+");if(n.pop()===e.key.toLowerCase()){for(let i of["shift","ctrl","alt","meta"]){let s=n.includes(i);if(!we){if(i==="meta")continue;i==="ctrl"&&(s=n.includes("meta")||n.includes("ctrl"))}let l=e[`${ve(i)}Key`];if(!l&&s||l&&!s)continue e}return t}}return null}};a(ee,"KeyBindings");var te=class{constructor(){this.commands={}}registerCommand(e){this.commands[e.id]=e}canExecuteCommand(e,...t){return this.commands[e]?!(this.commands[e].when&&!this.commands[e].when(...t)):!1}executeCommand(e,...t){return new Promise(n=>{let o=this.commands[e].action(...t);n(o)})}};a(te,"CommandRegistry");var ne=class{constructor(){this.menus={}}registerMenu(e,t){this.menus[e]=t}};a(ne,"MenuRegistry");function ke(r,e,t,n){return t?e.disabled||!r.canExecuteCommand(t.id,n):e.disabled}a(ke,"isDisabled");var ye={view({attrs:{workbench:r,x:e,y:t,items:n,align:o,commands:i,ctx:s}}){let l=a((d,u)=>h=>{h.stopPropagation(),!ke(r,d,u,s)&&(r.closeMenu(),d.onclick&&d.onclick(),u&&r.executeCommand(u.id,s))},"onclick");return m("ul",{class:"menu",style:{margin:"0",display:"inline-block"}},n.filter(d=>!d.when||d.when()).map(d=>{let u="",h,p;return d.command&&(p=i.find(b=>b.id===d.command),h=r.keybindings.getBinding(p.id),u=p.title),d.title&&(u=d.title()),m("li",{onclick:l(d,p),class:ke(r,d,p,s)?"disabled":"",style:{display:"flex"}},m("div",null,u),h&&m("div",{class:"keybindings grow text-right"},K(h.key).join(" ").toUpperCase()))}))}};var J={onupdate({state:r,dom:e}){let t=e.querySelector(".items").children;r.selected!==void 0&&t.length>0&&t[r.selected].scrollIntoView({block:"nearest"})},oncreate({attrs:r,state:e,dom:t}){r.inputview&&t.querySelector("input")?.focus(),e.selected===void 0&&(e.selected=0)},view({attrs:r,state:e}){e.selected=e.selected===void 0?0:e.selected,e.input=e.input===void 0?r.input||"":e.input,e.items===void 0&&(e.items=[],r.onchange(e));let t=a(o=>{let i=a((s,l)=>(s%l+l)%l,"mod");if(o.key==="ArrowDown")return e.selected===void 0?(e.selected=0,!1):(e.selected=i(e.selected+1,e.items.length),!1);if(o.key==="ArrowUp")return e.selected===void 0&&(e.selected=0),e.selected=i(e.selected-1,e.items.length),!1;if(o.key==="Enter")return e.selected!==void 0&&r.onpick(e.items[e.selected]),!1},"onkeydown"),n=a(o=>{e.input=o.target.value,e.selected=0,r.onchange(e)},"oninput");return m("div",{class:"picker"},r.inputview(t,n,e.input),m("div",{class:"items"},e.items.map((o,i)=>m("div",{class:e.selected===i?"item selected":"item",onclick:()=>r.onpick(o),onmouseover:()=>e.selected=i},r.itemview(o,i)))))}};var be={view({attrs:{workbench:r,ctx:e}}){let t=a(d=>(d.title||d.id).replace("-"," ").replace(/(^|\s)\S/g,h=>h.toUpperCase()),"getTitle"),n=a((d,u)=>t(d).localeCompare(t(u)),"sort"),o=a(d=>{r.closeDialog(),r.commands.executeCommand(d.id,e)},"onpick"),i=a(d=>{d.items=l.filter(u=>(u.title||u.id).toLowerCase().includes(d.input.toLowerCase()))},"onchange"),s=a(d=>{let u=r.keybindings.getBinding(d.id);return u?K(u.key).join(" ").toUpperCase():""},"getBindingSymbols"),l=Object.values(r.commands.commands).filter(d=>!d.hidden).filter(d=>r.canExecuteCommand(d.id,e)).sort(n);return m("div",{class:"palette"},m(J,{onpick:o,onchange:i,inputview:(d,u)=>m("div",null,m("input",{style:{width:"98%"},type:"text",onkeydown:d,oninput:u,placeholder:"Enter command..."})),itemview:d=>m("div",{class:"flex"},m("div",null,t(d)),m("div",{class:"keybindings grow text-right"},s(d)))}))}};function z(r,e){return r.value&&r.value[e]instanceof Function}a(z,"hasHook");function V(r,e,...t){if(z(r,e))return r.value[e].apply(r.value,t)}a(V,"triggerHook");function $(r,e){for(let t of r.components)if(z(t,e))return!0;return!1}a($,"objectHas");function oe(r,e,...t){for(let n of r.components)if(z(n,e))return n.value[e].apply(n.value,t)}a(oe,"objectCall");function se(r,e,...t){let n=[];for(let o of r.components)z(o,e)&&n.push(o.value);return n}a(se,"componentsWith");function M(r){return $(r,"objectChildren")}a(M,"objectManaged");var he={};function E(r){he[Q(r)]=r}a(E,"component");function Q(r){return r.prototype===void 0&&(r=r.constructor),`treehouse.${r.name}`}a(Q,"componentName");function Y(r){return typeof r=="string"?he[r]:he[Q(r)]}a(Y,"getComponent");function xe(r,e){let t=new(Y(r));return t.fromJSON instanceof Function?t.fromJSON(e):Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),t}a(xe,"inflateToComponent");function Ce(r){if(r===void 0)return;if(!Y(r))return structuredClone(r);let t=JSON.parse(JSON.stringify(r)||""),n=new r.constructor;return n.fromJSON instanceof Function?n.fromJSON(t):Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)),n}a(Ce,"duplicate");var C=class{constructor(){}onAttach(e){this.object=e.parent,this.object.setAttr("view","document")}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"node-bullet"},m("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),m("polyline",{points:"14 2 14 8 20 8"}),m("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),m("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),m("polyline",{points:"10 9 9 9 8 9"}))}toJSON(e){return{}}static initialize(e){e.commands.registerCommand({id:"make-document",title:"Make Document",action:t=>{if(!t.node)return;let n=new C;t.node.addComponent(n),t.node.changed(),e.executeCommand("zoom",t)}})}};a(C,"Document"),C=L([E],C);var W={view({attrs:{workbench:r,path:e,onkeydown:t,oninput:n,disallowEmpty:o,editValue:i,placeholder:s},state:l}){let d=e.node,u=i?"value":"name",h=a(()=>u==="name"?$(d,"displayName")?oe(d,"displayName",d):d.name:d[u]||"","display"),p=a(()=>{l.initialValue=d[u],r.context.node=d,r.context.path=e},"onfocus"),b=a(()=>d[u],"getter"),I=a((f,x)=>{d.isDestroyed||(o&&f.length===0?d[u]=l.initialValue:d[u]=f),x&&(r.context.node=null)},"setter");d.raw.Rel==="Fields"&&(s=i?"Value":"Field");let v=`input-${e.id}-${d.id}`;u==="value"&&(v=v+"-value");let w=Ue;return d.parent&&d.parent.hasComponent(C)&&window.Editor&&(w=qe),m(w,{id:v,getter:b,setter:I,display:h,onkeydown:t,onfocus:p,oninput:n,placeholder:s,workbench:r,path:e})}},qe={oncreate({dom:r,state:e,attrs:{id:t,onkeydown:n,onfocus:o,onblur:i,oninput:s,getter:l,setter:d,display:u,placeholder:h}}){let p=e.editing?e.buffer:u?u():l(),b=a(f=>{f.key==="Enter"&&(f.preventDefault(),f.stopPropagation())},"defaultKeydown"),I=a(f=>{o&&o(f),e.editing=!0,e.buffer=l()},"startEdit"),v=a(f=>{e.editing&&(e.editing=!1,d(e.buffer,!0),e.buffer=void 0),i&&i(f)},"finishEdit"),w=a(f=>{e.buffer=f.target.value,d(e.buffer,!1),s&&s(f)},"edit");e.editor=new window.Editor(r,p,h),e.editor.onblur=v,e.editor.onfocus=I,e.editor.oninput=w,e.editor.onkeydown=n||b,r.editor=e.editor,r.id=t},onupdate({dom:r,state:e,attrs:{getter:t,display:n}}){e.editor.value=e.editing?e.buffer:n?n():t()},view(){return m("div",{class:"text-editor"})}},Ue={oncreate({dom:r,attrs:e}){let t=r.querySelector("textarea"),n=t.offsetHeight,o=r.querySelector("span");this.updateHeight=()=>{o.style.width=`${Math.max(t.offsetWidth,100)}px`,o.innerHTML=t.value.replace(` +`,"
");let i=o.offsetHeight;i===0&&n>0&&(i=n),t.style.height=i>0?`${i}px`:"var(--body-line-height)"},t.addEventListener("input",()=>this.updateHeight()),t.addEventListener("blur",()=>o.innerHTML=""),setTimeout(()=>this.updateHeight(),50),e.onmount&&e.onmount(t)},onupdate(){this.updateHeight()},view({attrs:{id:r,onkeydown:e,onfocus:t,onblur:n,oninput:o,getter:i,setter:s,display:l,placeholder:d,path:u,workbench:h},state:p}){let b=p.editing?p.buffer:l?l():i();return m("div",{class:"text-editor"},m("textarea",{id:r,rows:"1",onfocus:a(g=>{t&&t(g),p.editing=!0,p.buffer=i()},"startEdit"),onblur:a(g=>{p.editing&&(p.editing=!1,s(p.buffer,!0),p.buffer=void 0),n&&n(g)},"finishEdit"),oninput:a(g=>{p.buffer=g.target.value,s(p.buffer,!1),o&&o(g)},"edit"),onpaste:a(g=>{let F=g.clipboardData.getData("Text");if(F.length>0){g.preventDefault(),g.stopPropagation();let c=F.split(` +`).map(k=>k.trim()).filter(k=>k.length>0);p.buffer=c.shift(),s(p.buffer,!0);let S=u.node;for(let k of c){let y=h.workspace.new(k);y.parent=S.parent,y.siblingIndex=S.siblingIndex+1,m.redraw.sync();let D=u.clone();D.pop(),h.focus(D.append(y)),S=y}}},"handlePaste"),placeholder:d,onkeydown:e||a(g=>{g.key==="Enter"&&(g.preventDefault(),g.stopPropagation())},"defaultKeydown"),value:b},b),m("span",{style:{visibility:"hidden",position:"fixed"}}))}};var Ne={view({attrs:{node:r,workbench:e,panel:t}}){return m("div",{class:"empty-view"})}};var ae={view({attrs:{workbench:r,path:e}}){return m("div",{class:"new-node flex flex-row items-center"},m("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 16"},m("circle",{cx:"8",cy:"7",r:"7"}),m("path",{style:{transform:"translate(0px, -1px)"},d:"M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"})),m("div",{class:"flex grow"},m("input",{class:"grow",type:"text",onkeydown:a(n=>{if(n.key==="Tab"){if(n.stopPropagation(),n.preventDefault(),node.childCount>0){let o=e.node.children[e.node.childCount-1];r.executeCommand("insert-child",{node:o,path:e})}}else r.executeCommand("insert-child",{node:e.node,path:e},n.target.value)},"keydown"),value:""})))}};function ze(r,e=1e3){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{r.apply(this,n)},e)}}a(ze,"debounce");var H=class{constructor(){this.workbench=window.workbench,this.searchDebounce=ze(this.search.bind(this)),this.query="",this.initialSearch=!1}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",class:"node-bullet",width:"15",height:"15",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round"},e?m("circle",{id:"node-collapsed-handle",stroke:"none",cx:"12",cy:"12",r:"12"}):null,m("svg",{xmlns:"http://www.w3.org/2000/svg",x:"3",y:"3",width:"19",height:"19",viewBox:"0 0 24 24"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})))}belowEditor(){return Ve}onAttach(e){this.component=e,this.object=e.parent,e.bus.observe(t=>{e.isDestroyed||this.searchDebounce()})}search(){if(!this.object)return;if(!this.query){this.lastQuery="",this.results=[];return}this.initialSearch=!0;let e=this.workbench.search(this.query).filter(t=>t.id!==this.object.id&&t.id!==this.component.id);(e.length!==this.lastResultCount||this.query!==this.lastQuery)&&(this.results&&this.results.forEach(t=>t.destroy()),this.results=e.map(t=>{let n=this.object.bus.make("");return n.raw.Parent="@tmp",n.refTo=t,n}),this.lastQuery=this.query,this.lastResultCount=e.length)}objectChildren(e,t){return!this.results&&this.query&&!this.initialSearch&&this.search(),this.results||[]}toJSON(e){return{query:this.query}}fromJSON(e){this.query=e.query||""}static initialize(e){e.commands.registerCommand({id:"make-smart-node",title:"Make Smart Node",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.childCount>0||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{e.defocus();let n=new H;t.node.addComponent(n),e.workspace.setExpanded(t.path.head,t.node,!0),t.node.name===""&&setTimeout(()=>{t.node.name="Unnamed Smart Node",m.redraw(),document.querySelector(`#node-${t.path.id}-${t.node.id} input`).focus()},10)}})}};a(H,"SmartNode"),H=L([E],H);var Ve={view({attrs:{node:r,component:e,expanded:t}}){if(!t)return;let n=a(o=>{e.query=o.target.value,e.search(),r.changed()},"oninput");return m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex"}),m("input",{type:"text",class:"grow",placeholder:"Enter search",value:e.query,oninput:n,style:{background:"inherit",border:"1px solid var(--color-outline-secondary)",outline:"0",padding:"var(--1)",marginBottom:"var(--1)",borderRadius:"var(--border-radius)"}}))}};var Se={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){let n=e.node;e.node.refTo&&(n=e.node.refTo);let o=!1;return(n.childCount===0&&n.getLinked("Fields").length===0||t)&&(o=!0),n.hasComponent(H)&&(o=!1),m("div",{class:"list-view"},m("div",{class:"fields"},n.getLinked("Fields").length>0&&n.getLinked("Fields").map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)}))),m("div",{class:"children"},n.childCount>0&&n.children.map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)})),o&&m(ae,{workbench:r,path:e})))}};var De={view({attrs:{workbench:r,path:e},state:t}){let n=e.node;t.fields=t.fields===void 0?new Set:t.fields,n.children.forEach(i=>{i.getLinked("Fields").forEach(s=>t.fields.add(s.name))});let o=a((i,s)=>{let l=i.getLinked("Fields").filter(d=>d.name===s);return l.length===0?"":m(W,{editValue:!0,workbench:r,path:e.append(l[0])})},"getFieldEditor");return m("table",{class:"table-view",style:{gridTemplateColumns:`repeat(${t.fields.size+1}, 1fr)`}},m("thead",null,m("tr",null,m("th",null,"Title"),[...t.fields].map(i=>m("th",null,i)))),m("tbody",null,n.children.map(i=>m("tr",null,m("td",null,m(q,{key:i.id,workbench:r,path:e.append(i)})),[...t.fields].map(s=>m("td",null,o(i,s)))))))}};var Ie={view({attrs:{workbench:r,path:e},state:t}){let n=e.node;t.tabs=t.tabs===void 0?new Set:t.tabs,t.selectedTab=t.selectedTab===void 0?"":t.selectedTab,n.children.forEach(s=>{t.tabs.add(s.raw),t.selectedTab===""&&(t.selectedTab=s.raw.ID)});let o=a(s=>{t.selectedTab=s},"handleTabClick"),i=n.children.find(s=>s.id===t.selectedTab);return m("div",{class:"tabs-view"},m("div",{class:"tabs"},[...t.tabs].map(s=>m("div",{class:s.ID===t.selectedTab?"active":"",onclick:()=>o(s.ID)},s.Name)),m("div",{style:{flexGrow:1}})),m("div",{class:"tab-content"},m(ie(i.getAttr("view")||"list"),{workbench:r,path:e.append(i)})))}};var Le={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){let n=e.node;e.node.refTo&&(n=e.node.refTo);let o=!1;return(n.childCount===0&&n.getLinked("Fields").length===0||t)&&(o=!0),m("div",{class:"document-view"},m("div",{class:"fields"},n.getLinked("Fields").length>0&&n.getLinked("Fields").map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)}))),m("div",{class:"children"},n.childCount>0&&n.children.map(i=>m(q,{key:i.id,workbench:r,path:e.append(i)})),o&&m(ae,{workbench:r,path:e})))}};var Ee={list:Se,table:De,tabs:Ie,document:Le};function ie(r){return Ee[r]||Ne}a(ie,"getView");window.registerView=(r,e)=>{Ee[r]=e,workbench.commands.registerCommand({id:`view-${r}`,title:`View as ${Qe(r)}`,action:t=>{t.node&&t.node.setAttr("view",r)}})};function Qe(r){return r.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})}a(Qe,"toTitleCase");var O=class{constructor(){}onAttach(e){this.object=e.parent}handleIcon(e=!1){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"3","stroke-linecap":"round","stroke-linejoin":"round",class:"node-bullet"},e?m("circle",{id:"node-collapsed-handle",stroke:"none",cx:"12",cy:"12",r:"12"}):null,m("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),m("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))}toJSON(e){return{}}static initialize(e){e.commands.registerCommand({id:"make-template",title:"Make Template",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{let n=new O;t.node.addComponent(n),t.node.changed()}})}static findNode(e,t){let n=null;return e.mainNode().walk(o=>o.value instanceof O&&o.value.object.name===t?(n=o.value.object,!0):!1,{includeComponents:!0}),n}};a(O,"Template"),O=L([E],O);var A=class{constructor(e){this.name=e}afterEditor(){return Ke}static initialize(e){e.commands.registerCommand({id:"add-tag",title:"Add tag",hidden:!0,action:(t,n)=>{if(!t.node)return;let o=new A(n);t.node.addComponent(o);let i=O.findNode(e.workspace,n);i&&(i.fields.map(s=>s.duplicate()).forEach(s=>{t.node.addLinked("Fields",s),s.raw.Parent=t.node.raw.ID}),i.children.map(s=>s.duplicate()).forEach(s=>{t.node.addChild(s),s.raw.Parent=t.node.raw.ID})),t.node.changed()}})}static findAll(e){let t=new Set;return e.mainNode().walk(n=>(n.value instanceof A&&t.add(n.value.name),!1),{includeComponents:!0}),[...t]}static findTagged(e,t){let n=[];return e.mainNode().walk(o=>(o.value instanceof A&&o.value.name===t&&n.push(o.parent),!1),{includeComponents:!0}),n}static showPopover(e,t,n,o,i){let s=A.findAll(e.workspace),l=e.getInput(t),d=l.getBoundingClientRect(),u=document.body.scrollLeft+d.x+l.selectionStart*10+20,h=document.body.scrollTop+d.y+d.height;e.showPopover(()=>m(J,{onpick:p=>{i(),e.getInput(t).blur(),n.name=n.name.replace(/\s*#\w*/,""),e.executeCommand("add-tag",{node:n,path:t},p.name)},onchange:p=>{n.name.includes("#")?p.input=n.name.split("#")[1]:p.input="";let b=[...s].filter(I=>I.toLowerCase().startsWith(p.input.toLowerCase())).map(I=>({name:I}));(b[0]&&b[0].name!=p.input&&p.input!=""||b.length===0)&&b.unshift({name:p.input,prefix:"Create tag: "}),p.items=b},inputview:o,itemview:p=>m("div",{class:"flex"},m("div",null,p.prefix||"",p.name))}),{top:`${h}px`,left:`${u}px`})}};a(A,"Tag"),A=L([E],A);var Ke={view({attrs:{node:r,component:e}}){return m("div",{tabindex:"1",class:"badge flex flex-row items-center",onkeydown:a(n=>{n.key==="Backspace"&&(r.removeComponent(e),r.changed())},"onkeydown")},m("span",null,"#\xA0"),m("div",{style:{whiteSpace:"nowrap"}},e.name))}};var de={view({attrs:{workbench:r,path:e,alwaysShowNew:t}}){return m(ie(e.node.getAttr("view")||"list"),{workbench:r,path:e,alwaysShowNew:t})}},q={view({attrs:r,state:e,children:t}){let{path:n,workbench:o}=r,i=n.node,s=!1,l=i;i.refTo&&(s=!0,i=l.refTo);let d=!1;o.clipboard&&o.clipboard.op==="cut"&&o.clipboard.node.id===i.id&&(d=!0);let u=o.workspace.getExpanded(n.head,l),h=$(i,"handlePlaceholder")?oe(i,"handlePlaceholder"):"",p=a(c=>{e.hover=!0,c.stopPropagation()},"hover"),b=a(c=>{e.hover=!1,c.stopPropagation()},"unhover"),I=a(()=>{e.tagPopover&&(o.closePopover(),e.tagPopover=void 0)},"cancelTagPopover"),v=a(c=>{e.tagPopover?(e.tagPopover.oninput(c),c.target.value.includes("#")||I()):c.target.value.includes("#")&&(e.tagPopover={},A.showPopover(o,n,i,(S,k)=>{e.tagPopover={onkeydown:S,oninput:k}},I))},"oninput"),w=a(c=>{if(e.tagPopover){if(c.key==="Escape"){I();return}if(e.tagPopover.onkeydown(c)===!1)return c.stopPropagation(),!1}let S=c.shiftKey||c.metaKey||c.altKey||c.ctrlKey;switch(c.key){case"ArrowUp":c.target.selectionStart!==0&&!S&&c.stopPropagation();break;case"ArrowDown":c.target.selectionStart!==c.target.value.length&&c.target.selectionStart!==0&&!S&&c.stopPropagation();break;case"Backspace":if(c.target.value===""){if(c.preventDefault(),c.stopPropagation(),i.childCount>0)return;o.executeCommand("delete",{node:i,path:n,event:c});return}if(c.target.value!==""&&c.target.selectionStart===0&&c.target.selectionEnd===0){if(c.preventDefault(),c.stopPropagation(),i.childCount>0)return;let k=o.workspace.findAbove(n);if(!k)return;let y=k.node.name;k.node.name=y+c.target.value,i.destroy(),m.redraw.sync(),o.focus(k,y.length);return}break;case"Enter":if(c.preventDefault(),c.ctrlKey||c.shiftKey||c.metaKey||c.altKey)return;if(c.target.selectionStart===c.target.value.length){i.childCount>0&&o.workspace.getExpanded(n.head,i)?o.executeCommand("insert-child",{node:i,path:n},"",0):o.executeCommand("insert",{node:i,path:n}),c.stopPropagation();return}if(c.target.selectionStart===0){o.executeCommand("insert-before",{node:i,path:n}),c.stopPropagation();return}if(c.target.selectionStart>0&&c.target.selectionStart{i.name=c.target.value.slice(0,c.target.selectionStart)}),c.stopPropagation();return}break}},"onkeydown"),f=a(c=>{c.preventDefault(),c.stopPropagation(),o.executeCommand("zoom",{node:i,path:n}),document.selection&&document.selection.empty?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()},"open"),x=a(c=>{if(i.hasComponent(C)){f(c);return}u?o.executeCommand("collapse",{node:l,path:n}):o.executeCommand("expand",{node:l,path:n}),c.stopPropagation()},"toggle"),g=a(c=>c.childCount+c.getLinked("Fields").length,"subCount"),F=a(()=>{if(i.id===o.context?.node?.id||e.hover||i.name.length>0||h.length>0)return!0},"showHandle");return m("div",{onmouseover:p,onmouseout:b,id:`node-${n.id}-${l.id}`,class:d?"cut-node":""},m("div",{class:"node-row-outer-wrapper flex flex-row items-start"},m("svg",{class:"node-menu shrink-0",xmlns:"http://www.w3.org/2000/svg",onclick:c=>o.showMenu(c,{node:l,path:n}),oncontextmenu:c=>o.showMenu(c,{node:l,path:n}),"data-menu":"node",viewBox:"0 0 16 16"},e.hover&&m("path",{style:{transform:"translateY(-1px)"},fill:"currentColor","fill-rule":"evenodd",d:"M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z"})),m("div",{class:"node-handle shrink-0",onclick:x,ondblclick:f,oncontextmenu:c=>o.showMenu(c,{node:l,path:n}),"data-menu":"node",style:{display:F()?"block":"none"}},$(i,"handleIcon")?oe(i,"handleIcon",g(i)>0&&!u):m("svg",{class:"node-bullet",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},g(i)>0&&!u?m("circle",{id:"node-collapsed-handle",cx:"8",cy:"8",r:"8"}):null,m("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"}),",",s?m("circle",{id:"node-reference-handle",cx:"8",cy:"8",r:"7",fill:"none","stroke-width":"1",stroke:"currentColor","stroke-dasharray":"3,3"}):null)),i.raw.Rel==="Fields"?m("div",{class:"flex grow items-start flex-row"},m("div",null,m(W,{workbench:o,path:n,onkeydown:w,oninput:v})),m(W,{editValue:!0,workbench:o,path:n,onkeydown:w,oninput:v})):m("div",{class:"flex grow items-start flex-row",style:{gap:"0.5rem"}},$(i,"beforeEditor")&&se(i,"beforeEditor").map(c=>m(c.beforeEditor(),{node:i,component:c})),m(W,{workbench:o,path:n,onkeydown:w,oninput:v,placeholder:h}),$(i,"afterEditor")&&se(i,"afterEditor").map(c=>m(c.afterEditor(),{node:i,component:c})))),$(i,"belowEditor")&&se(i,"belowEditor").map(c=>m(c.belowEditor(),{node:i,component:c,expanded:u})),u===!0&&m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex",onclick:x}),m("div",{class:"view grow"},m(ie(i.getAttr("view")||"list"),{workbench:o,path:n}))))}};var Ae={view({attrs:{workbench:r,node:e}}){let t=new R(e,"quickadd");return m("div",{class:"notice"},m("h3",null,"Quick Add"),m(de,{workbench:r,path:t,alwaysShowNew:!0}),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{r.commitQuickAdd(),r.closeDialog()}},"Add to Today")))}};var Pe={view({attrs:{workbench:r},state:e}){let t=r.workspace.settings.theme;return e.selectedTheme=e.selectedTheme===void 0?t:e.selectedTheme,m("div",{class:"notice"},m("h3",null,"Settings"),m("div",{class:"flex flex-row"},m("div",{class:"grow"},"Theme"),m("div",null,m("select",{name:"theme",oninput:a(o=>{e.selectedTheme=o.target.value},"oninput")},m("option",{selected:e.selectedTheme==="",value:""},"Light"),m("option",{selected:e.selectedTheme==="darkmode",value:"darkmode"},"Dark"),m("option",{selected:e.selectedTheme==="sepia",value:"sepia"},"Sepia"),m("option",{selected:e.selectedTheme==="sublime",value:"sublime"},"Sublime")))),m("div",{class:"button-bar"},m("button",{onclick:()=>{r.closeDialog()}},"Cancel"),m("button",{class:"primary",onclick:async o=>{t!==e.selectedTheme?(r.workspace.settings.theme=e.selectedTheme,await r.workspace.save(!0),location.reload()):r.closeDialog()}},"Save Changes")))}};var Te={view(){return m("div",{class:"notice"},m("h3",null,"Refresh to view latest updates"),m("p",null,"Your notes were updated in another browser session. Refresh the page to view the latest version."),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{location.reload()}},"Refresh Now")))}},Fe={view({attrs:{workbench:r}}){return m("div",{class:"notice"},m("h3",null,"Treehouse is under active development"),m("p",null,"This is a preview based on our main branch, which is actively being developed."),m("p",null,"If you find a bug, please report it via \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0> ",m("strong",null,"Submit Issue"),"."),m("p",null,"Data is stored using localstorage, which you can reset via \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0> ",m("strong",null,"Reset Demo"),"."),m("div",{class:"button-bar"},m("button",{class:"primary",onclick:()=>{localStorage.setItem("firsttime","1"),r.closeDialog()}},"Got it")))}},Be={view({attrs:{workbench:r,finished:e}}){return m("div",{class:"notice"},m("h3",null,"Login with GitHub"),m("p",null,"The GitHub backend is experimental so use at your own risk!"),m("p",null,"To store your workbench we will create a public repository called ",m("pre",{style:{display:"inline"}},".treehouse.sh")," if it doesn't already exist. You can manually make this repository private via GitHub if you want."),m("p",null,"You can Logout via the \xA0",m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 14",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})),"\xA0 menu in the top right to return to the localstorage backend."),m("div",{class:"button-bar"},m("button",{onclick:()=>{r.closeDialog()}},"Cancel"),m("button",{class:"primary",onclick:()=>{r.closeDialog(),localStorage.setItem("github","1"),e()}},"Log in with GitHub")))}};var G=class{constructor(e){this.commands=new te,this.keybindings=new ee,this.menus=new ne,this.backend=e,this.workspace=new _(e.files),this.context={node:null},this.panels=[],this.drawer={open:!1},this.dialog={body:()=>null},this.menu={body:()=>null}}get mainPanel(){return this.panels[0]}async initialize(){if(await this.workspace.load(),this.workspace.rawNodes.forEach(e=>this.backend.index.index(e)),this.workspace.observe(e=>{this.workspace.save(),e.isDestroyed?this.backend.index.remove(e.id):(this.backend.index.index(e.raw),e.components.forEach(t=>this.backend.index.index(t.raw)))}),this.workspace.lastOpenedID?this.openNewPanel(this.workspace.find(this.workspace.lastOpenedID)||this.workspace.mainNode()):this.openNewPanel(this.workspace.mainNode()),this.backend.loadExtensions&&await this.backend.loadExtensions(),this.workspace.settings.theme){let e=document.createElement("link");e.setAttribute("href",`https://treehouse.sh/style/themes/${this.workspace.settings.theme}.css`),e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)}m.redraw()}authenticated(){return this.backend.auth&&this.backend.auth.currentUser()}openQuickAdd(){let e=this.workspace.find("@quickadd");e||(e=this.workspace.new("@quickadd")),this.showDialog(()=>m(Ae,{workbench:this,node:e}),!0),setTimeout(()=>{document.querySelector("main > dialog .new-node input").focus()},1)}commitQuickAdd(){let e=this.workspace.find("@quickadd");if(!e)return;let t=this.todayNode();e.children.forEach(n=>n.parent=t)}clearQuickAdd(){let e=this.workspace.find("@quickadd");e&&e.children.forEach(t=>t.destroy())}todayNode(){let e=new Date,t=e.toUTCString().split(e.getFullYear())[0],n=`Week ${String(Je(e)).padStart(2,"0")}`,i=["@calendar",`${e.getFullYear()}`,n,t].join("/"),s=this.workspace.find(i);return s||(s=this.workspace.new(i)),s}openToday(){this.open(this.todayNode())}open(e){this.workspace.expanded[e.id]||(this.workspace.expanded[e.id]={}),this.workspace.lastOpenedID=e.id,this.workspace.save();let t=new R(e);this.panels[0]=t,this.context.path=t}openNewPanel(e){this.workspace.expanded[e.id]||(this.workspace.expanded[e.id]={}),this.workspace.lastOpenedID=e.id,this.workspace.save();let t=new R(e);this.panels.push(t),this.context.path=t}closePanel(e){this.panels=this.panels.filter(t=>t.name!==e.name)}defocus(){let e=this.getInput(this.context.path);e&&e.blur(),this.context.node=null,this.context.path=null}focus(e,t=0){let n=this.getInput(e);n?(this.context.path=e,n.focus(),t!==void 0&&n.setSelectionRange(t,t)):console.warn("unable to find input for",e)}getInput(e){let t=`input-${e.id}-${e.node.id}`;e.node.raw.Rel==="Fields"&&e.node.name!==""&&(t=t+"-value");let n=document.getElementById(t);return n.editor?n.editor:n}canExecuteCommand(e,t,...n){return t=this.newContext(t),this.commands.canExecuteCommand(e,t,...n)}executeCommand(e,t,...n){return t=this.newContext(t),console.log(e,t,...n),this.commands.executeCommand(e,t,...n)}newContext(e){return Object.assign({},this.context,e)}showMenu(e,t,n){e.stopPropagation(),e.preventDefault();let o=e.target.closest("*[data-menu]"),i=o.getBoundingClientRect();if(!n){let d=o.dataset.align||"left";n={top:`${document.body.scrollTop+i.y+i.height}px`},d==="right"?(n.marginLeft="auto",n.marginRight=`${document.body.offsetWidth-i.right}px`):(n.marginLeft=`${document.body.scrollLeft+i.x}px`,n.marginRight="auto")}let s=this.menus.menus[o.dataset.menu],l=s.filter(d=>d.command).map(d=>this.commands.commands[d.command]);s&&(this.menu={body:()=>m(ye,{workbench:this,ctx:this.newContext(t),items:s,commands:l}),style:n},m.redraw(),setTimeout(()=>{document.querySelector("main > dialog.menu").showModal()},0))}closeMenu(){document.querySelector("main > dialog.menu").close(),workbench.menu.body=()=>null}showPalette(e,t,n){this.showDialog(()=>m(be,{workbench:this,ctx:n}),!1,{left:`${e}px`,top:`${t}px`})}showNotice(e,t){this.showDialog(()=>m({firsttime:Fe,github:Be,lockstolen:Te}[e],{workbench:this,finished:t}),!0,void 0,e==="lockstolen")}toggleDrawer(){this.drawer.open=!this.drawer.open,m.redraw()}showSettings(){this.showDialog(()=>m(Pe,{workbench:this}),!0)}showPopover(e,t){this.popover={body:e,style:t},m.redraw()}closePopover(){this.popover=null,m.redraw()}showDialog(e,t,n,o){this.dialog={body:e,backdrop:t,style:n,explicitClose:o},m.redraw(),setTimeout(()=>{document.querySelector("main > dialog.modal").showModal()},0)}isDialogOpen(){return document.querySelector("main > dialog.modal").hasAttribute("open")}closeDialog(){document.querySelector("main > dialog.modal").close(),this.dialog.body=()=>null}search(e){if(!e)return[];let t=e.split(/\s+(?=(?:[^\'"]*[\'"][^\'"]*[\'"])*[^\'"]*$)/),n=t.filter(l=>!l.includes(":")).join(" "),o=Object.fromEntries(t.filter(l=>l.includes(":")).map(l=>l.toLowerCase().split(":")));!n&&Object.keys(o).length>0&&(n=Object.keys(o)[0]);let i=a(l=>{if(Object.keys(o).length>0){let d={};for(let u of l.getLinked("Fields"))d[u.name.toLowerCase()]=u.value.toLowerCase();for(let u in o)if(!d[u]||d[u]!==o[u].replace(/['"]/g,""))return!1}return!0},"passFieldQuery");if(n.startsWith("#"))return A.findTagged(this.workspace,n.replace("#","")).filter(i);let s={};return this.backend.index.search(n).forEach(l=>{let d=window.workbench.workspace.find(l);d&&(d.value&&(d=d.parent,!d.raw)||i(d)&&(s[d.id]=d))}),Object.values(s)}};a(G,"Workbench");function Je(r){var e=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);var n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e-n)/864e5+1)/7)}a(Je,"getWeekOfYear");function Re(r){function e(k,y){var D=k<>>32-y;return D}a(e,"rotate_left");function t(k){var y="",D,B,fe;for(D=0;D<=6;D+=2)B=k>>>D*4+4&15,fe=k>>>D*4&15,y+=B.toString(16)+fe.toString(16);return y}a(t,"lsb_hex");function n(k){var y="",D,B;for(D=7;D>=0;D--)B=k>>>D*4&15,y+=B.toString(16);return y}a(n,"cvt_hex");function o(k){k=k.replace(/\r\n/g,` +`);for(var y="",D=0;D127&&B<2048?(y+=String.fromCharCode(B>>6|192),y+=String.fromCharCode(B&63|128)):(y+=String.fromCharCode(B>>12|224),y+=String.fromCharCode(B>>6&63|128),y+=String.fromCharCode(B&63|128))}return y}a(o,"Utf8Encode");var i,s,l,d=new Array(80),u=1732584193,h=4023233417,p=2562383102,b=271733878,I=3285377520,v,w,f,x,g,S;r=o(r);var F=r.length,c=new Array;for(s=0;s>>29),c.push(F<<3&4294967295),i=0;ie.id)].join(":"))}get node(){return this.nodes[this.nodes.length-1]}get previous(){return this.nodes.length<2?null:this.nodes[this.nodes.length-2]}get head(){return this.nodes[0]}};a(R,"Path");var X=class{constructor(){this.nodes={"@root":{ID:"@root",Name:"@root",Linked:{Children:[],Components:[]},Attrs:{}}},this.observers=[]}changed(e){this.observers.forEach(t=>t(e))}import(e){for(let t of e)t.Value&&Y(t.Name)&&(t.Value=xe(t.Name,t.Value),t.Rel="Components"),this.nodes[t.ID]=t;for(let t of e){if(t.Parent==="@tmp"){delete this.nodes[t.ID];continue}if(!t.ID.startsWith("@")&&t.Parent===void 0){delete this.nodes[t.ID];continue}if(t.Parent&&!this.nodes[t.Parent]){delete this.nodes[t.ID];continue}let n=this.find(t.ID);if(n){if(n.parent&&!n.parent.raw){delete this.nodes[t.ID];continue}V(n,"onAttach",n)}}}export(){let e=[];for(let t of Object.values(this.nodes))e.push(t);return e}make(e,t){let n=null;if(e.includes("/")){let s=e.split("/");n=this.find(s[0]);for(let l=1;le.Parent===void 0).map(e=>new P(this,e.ID))}root(e){e=e||"@root";let t=this.roots().find(n=>n.name===e);return t===void 0?null:t}find(e){let t=this.nodes[e];if(t)return new P(this,t.ID);let n=e.split("/");if(n.length===1&&n[0].startsWith("@"))return null;let o=this.root(n[0]);if(!o&&this.nodes[n[0]]&&(o=new P(this,this.nodes[n[0]].ID)),o?n.shift():o=this.root("@root"),!o)return null;let i=a((s,l)=>(s.refTo&&(s=s.refTo),s.children.find(d=>d.name===l)),"findChild");for(let s of n){let l=i(o,s);if(!l)return null;o=l}return o}walk(e,t){for(let n of this.roots())if(n.walk(e,t))return}observe(e){this.observers.push(e)}};a(X,"Bus");var Ye=a(()=>{let r=Date.now().toString(36),e=Math.random().toString(36).substring(2);return r+e},"uniqueId");var P=class{constructor(e,t){this._bus=e,this._id=t}[Symbol.for("Deno.customInspect")](){return`Node[${this.id}:${this.name}]`}get id(){return this._id}get bus(){return this._bus}get raw(){let e=this._bus.nodes[this.id];if(!e)throw`use of non-existent node ${this.id}`;return e}get name(){return this.refTo?this.refTo.name:this.raw.Name}set name(e){this.refTo?this.refTo.name=e:this.raw.Name=e,this.changed()}get value(){return this.refTo?this.refTo.value:this.raw.Value}set value(e){this.refTo?this.refTo.value=e:this.raw.Value=e,this.changed()}get parent(){return!this.raw.Parent||!this._bus.nodes[this.raw.Parent]?null:new P(this._bus,this.raw.Parent)}set parent(e){let t=this.parent;t!==null&&t.raw.Linked.Children.splice(this.siblingIndex,1),e!==null?(this.raw.Parent=e.id,e.raw.Linked.Children.push(this.id),V(e,"onAttach",e)):this.raw.Parent=void 0,this.changed()}get refTo(){let e=this.raw.Attrs.refTo;return!e||!this._bus.nodes[e]?null:new P(this._bus,e)}set refTo(e){if(!e){delete this.raw.Attrs.refTo,this.changed();return}this.raw.Attrs.refTo=e.id,this.changed()}get siblingIndex(){let e=this.parent;if(e===null)return 0;let t=this.raw.Rel||"Children";return e.raw.Linked[t].findIndex(n=>n===this.id)}set siblingIndex(e){let t=this.parent;if(t===null)return;let n=this.raw.Rel||"Children";t.raw.Linked[n].splice(this.siblingIndex,1),t.raw.Linked[n].splice(e,0,this.id),t.changed()}get prevSibling(){let e=this.parent;if(e===null||this.siblingIndex===0)return null;let t=this.raw.Rel||"Children";return e.getLinked(t)[this.siblingIndex-1]}get nextSibling(){let e=this.parent;if(e===null||this.siblingIndex===e.children.length-1)return null;let t=this.raw.Rel||"Children";return e.getLinked(t)[this.siblingIndex+1]}get ancestors(){let e=[],t=this.parent;for(;t!==null;)e.push(t),t=t.parent;return e}get isDestroyed(){return!this._bus.nodes.hasOwnProperty(this.id)}get path(){let e=this,t=[];for(;e;)t.unshift(e.name),e=e.parent;return t.join("/")}get children(){if(this.refTo)return this.refTo.children;let e=[];this.raw.Linked.Children&&(e=this.raw.Linked.Children.map(t=>new P(this._bus,t)));for(let t of this.components)if(z(t,"objectChildren"))return V(t,"objectChildren",this,e);return e}get childCount(){if(this.refTo)return this.refTo.childCount;for(let e of this.components)if(z(e,"objectChildren"))return V(e,"objectChildren",this,null).length;return this.raw.Linked.Children?this.raw.Linked.Children.length:0}addChild(e){if(this.refTo){this.refTo.addChild(e);return}this.raw.Linked.Children.push(e.id),this.changed()}removeChild(e){if(this.refTo){this.refTo.removeChild(e);return}let t=this.raw.Linked.Children.filter(n=>n===e.id);this.raw.Linked.Children=t,this.changed()}get fields(){return this.raw.Linked.Fields?this.raw.Linked.Fields.map(e=>new P(this._bus,e)):[]}get fieldCount(){return this.raw.Linked.Fields?this.raw.Linked.Fields.length:0}get components(){return this.raw.Linked.Components?this.raw.Linked.Components.map(e=>new P(this._bus,e)):[]}get componentCount(){return this.raw.Linked.Components?this.raw.Linked.Components.length:0}addComponent(e){let t=this.bus.make(Q(e),e);t.raw.Parent=this.id,t.raw.Rel="Components",this.raw.Linked.Components.push(t.id),V(t,"onAttach",t),this.changed()}removeComponent(e){let t;e.name&&Y(e)?t=this.components.filter(n=>n.name===Q(e)):t=this.components.filter(n=>n.value===e),t.length>0&&t[0].destroy(),this.changed()}hasComponent(e){return this.components.filter(n=>n.name===Q(e)).length>0}getComponent(e){let t=this.components.filter(n=>n.name===Q(e));return t.length>0?t[0].value:null}getLinked(e){return this.raw.Linked[e]?this.raw.Linked[e].map(t=>new P(this._bus,t)):[]}addLinked(e,t){this.raw.Linked[e]||(this.raw.Linked[e]=[]),t.raw.Rel=e,this.raw.Linked[e].push(t.id),this.changed()}removeLinked(e,t){this.raw.Linked[e]||(this.raw.Linked[e]=[]);let n=this.raw.Linked[e].filter(o=>o===t.id);this.raw.Linked[e]=n,this.changed()}moveLinked(e,t,n){this.raw.Linked[e]||(this.raw.Linked[e]=[]);let o=this.raw.Linked[e].findIndex(s=>s===t.id);if(o===-1)return;let i=this.raw.Linked[e];i.splice(n,0,i.splice(o,1)[0]),this.raw.Linked[e]=i,this.changed()}getAttr(e){return this.raw.Attrs[e]||""}setAttr(e,t){this.raw.Attrs[e]=t,this.changed()}find(e){return this.bus.find([this.path,e].join("/"))}walk(e,t){if(t=t||{followRefs:!1,includeComponents:!1},e(this))return!0;let n=this.children;if(this.refTo&&t.followRefs){if(e(this.refTo))return!0;n=this.refTo.children}for(let o of n)if(o.walk(e,t))return!0;if(t.includeComponents){for(let o of this.components)if(o.walk(e,t))return!0}return!1}destroy(){if(this.isDestroyed)return;if(this.refTo){this._bus.destroy(this);return}let e=[];this.walk(t=>(e.push(t),!1),{followRefs:!1,includeComponents:!0}),e.reverse().forEach(t=>this._bus.destroy(t))}duplicate(){let e=this._bus.make(this.name,Ce(this.value));return e.raw.Rel=this.raw.Rel,this.fields.map(t=>t.duplicate()).forEach(t=>{e.addLinked("Fields",t),t.raw.Parent=e.raw.ID}),this.components.map(t=>t.duplicate()).forEach(t=>{e.addLinked("Components",t),t.raw.Parent=e.raw.ID}),this.children.map(t=>t.duplicate()).forEach(t=>{e.addChild(t),t.raw.Parent=e.raw.ID}),e}changed(){this._bus.changed(this)}};a(P,"Node");var _=class{constructor(e){this.fs=e,this.bus=new X,this.expanded={},this.settings={},this.writeDebounce=_e(async(t,n)=>{try{await this.fs.writeFile(t,n),console.log("Saved workspace.")}catch(o){console.error(o),document.dispatchEvent(new CustomEvent("BackendError"))}})}get rawNodes(){return this.bus.export()}observe(e){this.bus.observe(e)}async save(e){let t=JSON.stringify({version:1,lastopen:this.lastOpenedID,expanded:this.expanded,nodes:this.rawNodes,settings:this.settings},null,2);e?await this.fs.writeFile("workspace.json",t):this.writeDebounce("workspace.json",t)}async load(){let e=JSON.parse(await this.fs.readFile("workspace.json")||"{}");if(e.nodes&&(e.nodes=e.nodes.map(t=>(t.Name==="treehouse.SearchNode"&&(t.Name="treehouse.SmartNode"),t)),this.bus.import(e.nodes),console.log(`Loaded ${e.nodes.length} nodes.`)),e.expanded)for(let t in e.expanded)for(let n in e.expanded[t])this.bus.find(n)&&(this.expanded[t]||(this.expanded[t]={}),this.expanded[t][n]=e.expanded[t][n]);e.lastopen&&(this.lastOpenedID=e.lastopen),e.settings&&(this.settings=Object.assign(this.settings,e.settings))}mainNode(){let e=this.bus.find("@workspace");if(!e){console.info("Building missing workspace node.");let t=this.bus.find("@root"),n=this.bus.make("@workspace");n.name="Workspace",n.parent=t;let o=this.bus.make("@calendar");o.name="Calendar",o.parent=n;let i=this.bus.make("Home");i.parent=n,e=n}return e}find(e){return this.bus.find(e)}new(e,t){return this.bus.make(e,t)}getExpanded(e,t){this.expanded[e.id]||(this.expanded[e.id]={});let n=this.expanded[e.id][t.id];return n===void 0&&(n=!1),n}setExpanded(e,t,n){this.expanded[e.id]||(this.expanded[e.id]={}),this.expanded[e.id][t.id]=n,this.save()}findAbove(e){if(e.node.id===e.head.id)return null;let t=e.clone();t.pop();let n=e.node.prevSibling;if(!n){let i=e.previous.getLinked("Fields").length;return e.node.raw.Rel!=="Fields"&&i>0?t.append(e.previous.getLinked("Fields")[i-1]):t}let o=a(i=>{if(!this.getExpanded(e.head,i.node))return i;let l=i.node.getLinked("Fields").length;if(i.node.childCount===0&&l>0){let u=i.node.getLinked("Fields")[l-1];return o(i.append(u))}if(i.node.childCount===0)return i;let d=i.node.children[i.node.childCount-1];return o(i.append(d))},"lastSubIfExpanded");return o(t.append(n))}findBelow(e){let t=e.clone();if(this.getExpanded(e.head,e.node)&&e.node.getLinked("Fields").length>0)return t.append(e.node.getLinked("Fields")[0]);if(this.getExpanded(e.head,e.node)&&e.node.childCount>0)return t.append(e.node.children[0]);let n=a(o=>{let i=o.node.nextSibling;if(i)return o.pop(),o.append(i);let s=o.previous;return s?o.node.raw.Rel==="Fields"&&s.childCount>0?(o.pop(),o.append(s.children[0])):(o.pop(),n(o)):null},"nextSiblingOrParentNextSibling");return n(t)}};a(_,"Workspace");function _e(r,e=3e3){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{r.apply(this,n)},e)}}a(_e,"debounce");var je={view({attrs:r,children:e}){let t=r.open;return m("div",{class:`drawer ${t?"open":"closed"}`},e)}};var j=class{constructor(){this.markdown=""}};a(j,"Page"),j=L([E],j);var Me={view({attrs:r}){let e=r.path,t=r.workbench,n=e.node,o=a(h=>{t.executeCommand("close-panel",{},e)},"close"),i=a(h=>{e.pop()===e.node&&e.pop()},"goBack"),s=a(h=>{t.panels=[e],t.context.path=e},"maximize"),l=a(h=>{n.getComponent(j).markdown=h.target.value,n.changed()},"editMarkdown");function d(h=""){return 20+(h.match(/\n/g)||[]).length*20}a(d,"calcHeight");let u="";return n.getAttr("view")&&(u=`${n.getAttr("view")}-panel`),m("div",{class:`panel flex flex-col grow ${u}`},m("div",{class:"bar flex"},e.length>1?m("div",{class:"panel-back",style:{rightPadding:"var(--padding)"}},m("svg",{onclick:i,xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},m("path",{"fill-rule":"evenodd",d:"M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z"}))):null,m("div",{class:"panel-back-parent grow"},n.parent&&n.parent.id!=="@root"?m("span",{style:{cursor:"pointer"},onclick:()=>t.open(n.parent)},n.parent.name):m("span",null,"\xA0")),t.panels.length>1?m("div",{class:"panel-icons flex items-center"},m("svg",{onclick:s,style:{cursor:"pointer"},xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-maximize-2"},m("polyline",{points:"15 3 21 3 21 9"}),m("polyline",{points:"9 21 3 21 3 15"}),m("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),m("line",{x1:"3",y1:"21",x2:"10",y2:"14"})),m("svg",{onclick:o,style:{cursor:"pointer"},xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-x"},m("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),m("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null),m("div",{class:"body flex flex-col"},m("div",{class:"title-node",oncontextmenu:h=>t.showMenu(h,{node:n,path:e}),"data-menu":"node"},m(W,{workbench:t,path:e,disallowEmpty:!0})),n.hasComponent(j)?m("textarea",{oninput:l,value:n.getComponent(j).markdown,placeholder:"Enter Markdown text here",style:{marginLeft:"var(--padding)",padding:"var(--padding)",outline:"0",height:`${d(n.getComponent(j).markdown)}px`,border:"0"}},n.getComponent(j).markdown):null,m(de,{workbench:t,path:e.sub(),alwaysShowNew:!0})))}};var Oe={view({attrs:r}){let e=r.workbench,t={"":["pick-command"],Edit:["cut","copy","copy-reference","paste","mark-done","insert","delete"],Navigate:["expand","collapse","indent","outdent","move-up","move-down","prev","next"]},n=a(o=>{let i=e.keybindings.getBinding(o.id);return i?K(i.key).join(" ").toUpperCase():""},"getBindingSymbols");return m("div",{class:"reference"},m("h2",null,"Keyboard Shortcuts"),Object.entries(t).map(([o,i])=>m("div",null,o.length!==0&&m("h3",null,o),m("div",null,i.map(s=>e.commands.commands[s]).map(s=>m("div",{class:"flex item"},m("div",{class:"keybindings text-left"},n(s)),m("div",{class:"grow"},s.title)))))))}};var me={view({attrs:{input:r,workbench:e}}){return m("div",{class:"search"},m(J,{onpick:a(o=>{e.closeDialog(),e.open(o)},"onpick"),onchange:a(o=>{o.input?o.items=e.search(o.input):o.items=[]},"onchange"),input:r,inputview:(o,i,s)=>m("div",{class:"flex items-center"},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0 items-center"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),m("input",{type:"text",placeholder:"Search",value:s,onkeydown:o,oninput:i})),itemview:o=>m("div",null,o.name)}))}};var He={view({attrs:{workbench:r},state:e}){e.open=e.open===void 0?!0:e.open;let t=a(n=>{e.open?e.open=!1:e.open=!0},"toggle");return m("main",{class:"workbench m-0 flex flex-row absolute inset-0",style:{overflow:"none"}},m("div",{class:"sidebar flex flex-col",style:{width:e.open?"256px":"52px"}},m("div",{class:"sidebar-top",style:{height:"56px"}},m("div",{class:"logo"})),m("div",{class:"grow sidebar-main"},e.open&&r.workspace.bus.root().children.map(n=>m($e,{node:n,expanded:!0,level:0,workbench:r}))),m("div",{class:"sidebar-bottom"},m("svg",{onclick:t,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-sidebar"},m("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"9",y1:"3",x2:"9",y2:"21"})))),m("div",{class:"main flex flex-col grow"},m("div",{class:"topbar flex"},m("div",{class:"topbar-item",onclick:()=>r.openToday(),style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",display:"flex",alignItems:"center"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-calendar"},m("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),m("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),m("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),m("div",null,"Today")),m("div",{class:"topbar-item",onclick:()=>r.openQuickAdd(),style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",display:"flex",alignItems:"center"}},m("svg",{style:{marginRight:"var(--1)"},xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-plus-circle"},m("circle",{cx:"12",cy:"12",r:"10"}),m("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),m("line",{x1:"8",y1:"12",x2:"16",y2:"12"})),m("div",null,"Quick Add")),m("div",{class:"searchbar flex grow"},m("div",null,m("div",{class:"flex",style:{margin:"1px"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})),m("input",{type:"text",placeholder:"Search",onkeydown:n=>{if(n.key==="Control"||n.key==="Alt"||n.key==="Shift"||n.key==="Meta")return;let o=n.target.getBoundingClientRect();r.showDialog(()=>m(me,{workbench:r,input:n.key}),!1,{left:`${o.left-33}px`,top:`${o.top-9}px`,width:`${o.width+33}px`}),n.preventDefault()},style:{border:"0",outline:"0",background:"transparent",paddingTop:"3px"}})))),m("div",{onclick:()=>r.toggleDrawer(),"data-menu":"keyboard-reference","data-align":"right",style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)",marginTop:"-2px"}},m("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},m("g",{"clip-path":"url(#clip0_442_8012)"},m("path",{d:"M20 6H4C2.89543 6 2 6.76751 2 7.71429V16.2857C2 17.2325 2.89543 18 4 18H20C21.1046 18 22 17.2325 22 16.2857V7.71429C22 6.76751 21.1046 6 20 6Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M6 10H6.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M7.5 12H7.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M10.5 12H10.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M13.5 12H13.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M16.5 12H16.51",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M9 10H9.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M12 10H12.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M15 10H15.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M18 10H18.01",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),m("path",{d:"M5 15H19",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})),m("defs",null,m("clipPath",{id:"clip0_442_8012"},m("rect",{width:"22",height:"14",fill:"white",transform:"translate(1 5)"}))))),m("div",{onclick:n=>r.showMenu(n),"data-menu":"settings","data-align":"right",style:{cursor:"pointer",marginLeft:"var(--padding)",marginRight:"var(--padding)"}},m("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"})))),m("div",{class:"panels flex flex-row grow",style:{position:"relative",overflow:"hidden"}},r.panels.map(n=>m("div",null,m(Me,{workbench:r,path:n}))),m(je,{open:r.drawer.open},m(Oe,{workbench:r}))),m("div",{class:"mobile-nav flex-row"},m("div",null,m("svg",{onclick:()=>{let n=document.querySelector(".sidebar").style;n.display!=="flex"?n.display="flex":n.display="none"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-sidebar"},m("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"9",y1:"3",x2:"9",y2:"21"}))),m("div",{onclick:()=>r.openToday()},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-calendar"},m("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),m("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),m("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),m("line",{x1:"3",y1:"10",x2:"21",y2:"10"}))),m("div",{onclick:()=>r.openQuickAdd()},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-plus-circle"},m("circle",{cx:"12",cy:"12",r:"10"}),m("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),m("line",{x1:"8",y1:"12",x2:"16",y2:"12"}))),m("div",{onclick:()=>r.showDialog(()=>m(me,{workbench:r}),!0,{top:"25%",bottom:"100px"})},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-search shrink-0"},m("circle",{cx:"11",cy:"11",r:"8"}),m("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}))),m("div",{onclick:n=>r.showMenu(n,void 0,{bottom:"100px",marginTop:"auto"}),"data-menu":"settings"},m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"feather feather-menu"},m("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),m("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),m("line",{x1:"3",y1:"18",x2:"21",y2:"18"}))))),r.popover&&m("div",{class:"popover",style:{position:"absolute",...r.popover.style}},r.popover.body()),m("dialog",{class:r.dialog.backdrop?"popover modal backdrop":"popover modal",style:r.dialog.style?{margin:"0",...r.dialog.style}:{top:"-50%"},oncancel:n=>{if(r.dialog.explicitClose===!0){n.preventDefault();return}r.dialog.body=()=>null},onclick:n=>{let i=n.target.closest("dialog").getBoundingClientRect(),s=n.clientX==0&&n.clientY==0;r.dialog.explicitClose!==!0&&(n.clientXi.right||n.clientYi.bottom)&&!s&&r.closeDialog()}},r.dialog.body()),m("dialog",{class:"menu popover",style:{margin:"0",...r.menu.style},oncancel:n=>{r.menu.body=()=>null},onclick:n=>{let i=n.target.closest("dialog").getBoundingClientRect();(n.clientXi.right||n.clientYi.bottom)&&r.closeMenu()}},r.menu.body()))}},$e={view({attrs:{node:r,workbench:e,expanded:t,level:n},state:o}){o.expanded=o.expanded===void 0?t:o.expanded;let i=r.childCount>0&&n<3,s=a(d=>{i&&(o.expanded?o.expanded=!1:o.expanded=!0,d.stopPropagation())},"toggle"),l=a(d=>{document.querySelector(".mobile-nav").offsetHeight&&(document.querySelector(".sidebar").style.display="none"),e.open(r)},"open");return m("div",null,m("div",{class:"sidebar-item flex"},m("svg",{onclick:s,class:"feather feather-chevron-right shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",xmlns:"http://www.w3.org/2000/svg"},i?o.expanded?m("polyline",{points:"6 9 12 15 18 9"}):m("polyline",{points:"9 18 15 12 9 6"}):null),m("div",{class:"sidebar-item-label grow",onclick:l,style:{cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},r.name)),o.expanded&&m("div",{class:"sidebar-item-nested"},r.children.filter(d=>d.name!=="").map(d=>m($e,{workbench:e,node:d,level:n+1}))))}};var T=class{constructor(){this.checked=!1}beforeEditor(){return Xe}};a(T,"Checkbox"),T=L([E],T);var Xe={view({attrs:{node:r}}){return m("input",{type:"checkbox",style:{marginTop:"0.3rem"},onclick:a(t=>{let n=r.getComponent(T);n.checked=!n.checked,r.changed()},"toggleCheckbox"),checked:r.getComponent(T).checked})}};var U=class{constructor(){}handleIcon(){return m("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("polyline",{points:"4 7 4 4 20 4 20 7"}),m("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),m("line",{x1:"12",y1:"4",x2:"12",y2:"20"}))}};a(U,"TextField"),U=L([E],U);var N=class{constructor(){this.log=[],this.showLog=!1}onAttach(e){this.component=e,this.object=e.parent}fromJSON(e){e.startedAt&&(this.startedAt=new Date(e.startedAt)),this.log=(e.log||[]).map(t=>[new Date(t[0]),new Date(t[1])]),this.showLog=e.showLog}toJSON(e){return{startedAt:this.startedAt,log:this.log,showLog:this.showLog}}localTotal(){return this.log.map(this.entryDuration).reduce((e,t)=>e+t,0)}grandTotal(){let e=this.localTotal();return this.object&&this.object.children.forEach(t=>{t.hasComponent(N)&&(e+=t.getComponent(N).grandTotal())}),e}start(){this.startedAt||(this.startedAt=new Date)}stop(){if(!this.startedAt)return;let e=new Date;(e.getTime()-this.startedAt.getTime())/1e3>=60&&this.log.push([this.startedAt,e]),this.startedAt=void 0}formatEntry(e){return e.length!==2?"":`${this.formatDate(e[0])} - ${new Intl.DateTimeFormat("en",{timeStyle:"short"}).format(e[1])}`}entryDuration(e){let t=e[0];return((e[1]||new Date).getTime()-t.getTime())/1e3}formatDate(e){return e?new Intl.DateTimeFormat("en",{dateStyle:"short",timeStyle:"short"}).format(e):""}formatDuration(e){let t=e/60,n=Math.floor(t%60);return t=t/60,`${Math.floor(t%60)}:${n.toLocaleString("en-US",{minimumIntegerDigits:2,useGrouping:!1})}`}afterEditor(){return Ze}belowEditor(){return et}static initialize(e){e.commands.registerCommand({id:"stop-clock",title:"Stop clock",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{if(!t.node.hasComponent(N)){let n=new N;t.node.addComponent(n)}t.node.getComponent(N).stop(),t.node.changed()}}),e.keybindings.registerBinding({command:"stop-clock",key:"meta+o"}),e.commands.registerCommand({id:"start-clock",title:"Start clock",when:t=>!(!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)),action:t=>{if(!t.node.hasComponent(N)){let n=new N;t.node.addComponent(n)}t.node.getComponent(N).start(),t.node.changed()}}),e.keybindings.registerBinding({command:"start-clock",key:"meta+i"}),e.commands.registerCommand({id:"remove-clock",title:"Remove clock",when:t=>!t.node||t.node.raw.Rel==="Fields"||t.node.parent&&t.node.parent.hasComponent(Document)?!1:!!t.node.hasComponent(N),action:t=>{t.node.removeComponent(N)}})}};a(N,"Clock"),N=L([E],N);var Ze={view({attrs:{node:r}}){let e=r.getComponent(N),t=a(()=>{e.showLog=!e.showLog,r.changed()},"toggleLog");return!e.showLog&&e.startedAt?m("div",{tabindex:"1",onclick:t,class:"badge flex flex-row items-center",style:{background:"green",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{class:"blink",style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration([e.startedAt])))):m("div",{tabindex:"1",onclick:t,class:"badge flex flex-row items-center",style:{background:"gray",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.grandTotal())))}},et={view({attrs:{node:r}}){let e=r.getComponent(N);if(e.showLog)return m("div",{class:"expanded-node flex flex-row"},m("div",{class:"indent flex"}),m("div",{class:"grow"},e.startedAt&&m("div",{class:"flex flex-row",style:{marginBottom:"2px"}},m("div",{class:"grow"},e.formatDate(e.startedAt)," - ..."),m("div",{class:"flex flex-row items-center",style:{background:"green",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{class:"blink",style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration([e.startedAt]))))),e.log.toReversed().map(t=>m("div",{class:"flex flex-row",style:{marginBottom:"2px"}},m("div",{class:"grow"},e.formatEntry(t)),m("div",{class:"flex flex-row items-center",style:{background:"#aaa",lineHeight:"var(--body-line-height)",paddingLeft:"0.25rem",paddingRight:"0.25rem",borderRadius:"4px",color:"white"}},m("svg",{style:{width:"1rem",height:"1rem",marginRight:"0.25rem"},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},m("circle",{cx:"12",cy:"12",r:"10"}),m("polyline",{points:"12 6 12 12 16 14"})),m("div",null,e.formatDuration(e.entryDuration(t))))))))}};var Z=class{constructor(){this.auth=null,this.files=new ce,window.MiniSearch?this.index=new re:this.index=new le}};a(Z,"BrowserBackend");var re=class{constructor(){this.indexer=new MiniSearch({idField:"ID",fields:["ID","Name","Value","Value.markdown"],storeFields:["ID"],extractField:(e,t)=>t.split(".").reduce((n,o)=>n&&n[o],e)})}index(e){this.indexer.has(e.ID)?this.indexer.replace(e):this.indexer.add(e)}remove(e){try{this.indexer.discard(e)}catch{}}search(e){let t=this.indexer.autoSuggest(e);return t.length===0?[]:this.indexer.search(t[0].suggestion,{prefix:!0,combineWith:"AND"}).map(n=>n.ID)}};a(re,"SearchIndex_MiniSearch");var le=class{constructor(){this.nodes={}}index(e){this.nodes[e.ID]=e.Name}remove(e){delete this.nodes[e]}search(e){let t=[];for(let n in this.nodes)this.nodes[n].includes(e)&&t.push(n);return t}};a(le,"SearchIndex_Dumb");var ce=class{async readFile(e){return localStorage.getItem(`treehouse:${e}`)}async writeFile(e,t){localStorage.setItem(`treehouse:${e}`,t)}};a(ce,"FileStore");import{encode as tt,decode as nt}from"https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.mjs";var ue=class{constructor(e,t,n){this.loginURL=e,this.clientFactory=t,this.auth=this,this.shas={},this.opts=Object.assign({domain:"treehouse.sh",checkDomain:!1,privateRepo:!1},n||{});let o=new Z;this.index=o.index,this.files=o.files}get repoName(){return`${this.user?.userID().toLowerCase()}.${this.opts.domain}`}async initialize(){let e=new URL(location.href).searchParams.get("code");if(e)try{let i=location.search.replace(/\bcode=\w+/,"").replace(/\?$/,"");history.pushState({},"",`${location.pathname}${i}`);let l=await(await fetch(this.loginURL,{method:"POST",mode:"cors",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})})).json();if(l.error)throw l.error;localStorage.setItem("treehouse:gh-token",l.token)}catch(i){this.reset(),console.error(i);return}let t=new URL(location.href).searchParams.get("access_token");if(t)try{let i=location.search.replace(/\baccess_token=\w+/,"").replace(/\?$/,"");history.pushState({},"",`${location.pathname}${i}`),localStorage.setItem("treehouse:gh-token",t)}catch(i){this.reset(),console.error(i);return}try{if(await this.authenticate(),!this.user)throw"authentication failed"}catch(i){console.error(i),this.opts.authFallbackURL&&(location.href=this.opts.authFallbackURL);return}if(this.opts.checkDomain&&this.repoName!==location.hostname.toLowerCase()){location.hostname=this.repoName;return}try{await this.client.rest.repos.get({owner:this.user.userID(),repo:this.repoName})}catch(i){if(i.message!=="Not Found")throw i;console.log("Creating repository...");let s=await this.client.rest.repos.createForAuthenticatedUser({name:this.repoName,private:this.opts.privateRepo});if(s.status!==201){console.error(s);return}}try{await this.client.rest.repos.getContent({owner:this.user.userID(),repo:this.repoName,path:"workspace.json"})}catch(i){if(i.name!=="HttpError")throw i;console.log("Creating workspace.json...");let s=await this.client.rest.repos.createOrUpdateFileContents({owner:this.user.userID(),repo:this.repoName,path:"workspace.json",message:"initial commit",content:btoa(JSON.stringify([]))});if(s.status!==201){console.error(s);return}}this.files=this;let n=ot();await this.readFile("treehouse.lock"),await this.writeFile("treehouse.lock",n);let o=setInterval(async()=>{await this.readFile("treehouse.lock")!==n&&(clearInterval(o),document.dispatchEvent(new CustomEvent("BackendError")),console.warn("lock stolen!"))},5e3)}async loadExtensions(){try{if((await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:"",random:Math.random().toString(36).substring(2)})).data.find(t=>t.type==="dir"&&t.name==="ext")){let t=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:"ext",random:Math.random().toString(36).substring(2)});for(let n of t.data)if(n.name.endsWith(".css")){let o=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:n.path,random:Math.random().toString(36).substring(2)}),i=document.createElement("link");i.setAttribute("href",`data:text/css;charset=utf-8;base64,${o.data.content}`),i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),document.head.appendChild(i)}else if(n.name.endsWith(".js")){let o=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:n.path,random:Math.random().toString(36).substring(2)}),i=document.createElement("script");i.setAttribute("type","module"),i.setAttribute("src",`data:text/javascript;charset=utf-8;base64,${o.data.content}`),document.head.appendChild(i)}}}catch{}}async authenticate(){let e=localStorage.getItem("treehouse:gh-token");if(!e)return;this.client=new this.clientFactory({auth:e});let t=await this.client.rest.users.getAuthenticated();!t||t.error||(this.user=new pe(t.data),m&&m.redraw())}currentUser(){return this.user}login(){location.assign(this.loginURL)}reset(){localStorage.removeItem("treehouse:gh-token"),this.user=null,m&&m.redraw()}logout(){this.reset(),location.reload()}async readFile(e){try{let t=await this.client.rest.repos.getContent({owner:this.user?.userID(),repo:this.repoName,path:e,random:Math.random().toString(36).substring(2)});return this.shas[e]=t.data.sha,nt(t.data.content)}catch(t){return t.name!=="HttpError"&&console.error(t),null}}async writeFile(e,t){let n=await this.client.rest.repos.createOrUpdateFileContents({owner:this.user?.userID(),repo:this.repoName,path:e,message:"autosave",content:tt(t),sha:this.shas[e]});this.shas[e]=n.data.content.sha}};a(ue,"GitHubBackend");var pe=class{constructor(e){this.user=e}userID(){return this.user.login}displayName(){return this.user.name}avatarURL(){return this.user.avatar_url}};a(pe,"User");function ot(){let r=Date.now().toString(36),e=Math.random().toString(36).substring(2);return r+e}a(ot,"uniqueID");async function ri(r,e,t){t.initialize&&await t.initialize();let n=new G(t);window.workbench=n,await n.initialize(),[N,U,j,C,T,A,O,H].forEach(o=>{o.initialize&&o.initialize(n)}),r.addEventListener("BackendError",()=>{n.showNotice("lockstolen",()=>{location.reload()})}),n.commands.registerCommand({id:"cut",title:"Cut",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"cut",node:o.node}}}),n.keybindings.registerBinding({command:"cut",key:"meta+x"}),n.commands.registerCommand({id:"copy",title:"Copy",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"copy",node:o.node}}}),n.keybindings.registerBinding({command:"copy",key:"meta+c"}),n.commands.registerCommand({id:"copy-reference",title:"Copy as Reference",when:o=>{if(!o.node)return!1;let i=n.getInput(o.path);return i&&i.selectionStart===i.selectionEnd?!0:(n.clipboard=void 0,!1)},action:o=>{n.clipboard={op:"copyref",node:o.node}}}),n.keybindings.registerBinding({command:"copy-reference",key:"shift+ctrl+c"}),n.commands.registerCommand({id:"paste",title:"Paste",when:o=>!!n.clipboard,action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;switch(n.clipboard.op){case"copy":n.clipboard.node=n.clipboard.node.duplicate();break;case"copyref":let s=n.workspace.new("");s.refTo=n.clipboard.node,n.clipboard.node=s;break}n.clipboard.node.raw.Rel==="Fields"?(n.clipboard.node.raw.Parent=o.node.parent.id,o.node.parent.addLinked("Fields",n.clipboard.node)):(n.clipboard.node.parent=o.node.parent,n.clipboard.node.siblingIndex=o.node.siblingIndex),m.redraw.sync();let i=o.path.clone();i.pop(),n.focus(i.append(n.clipboard.node))}}),n.keybindings.registerBinding({command:"paste",key:"meta+v"}),n.commands.registerCommand({id:"view-list",title:"View as List",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{o.node.setAttr("view","list")}}),n.commands.registerCommand({id:"view-table",title:"View as Table",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{o.node.setAttr("view","table"),o.node.children.forEach(i=>{n.workspace.setExpanded(o.path.head,i,!1)})}}),n.commands.registerCommand({id:"view-tabs",title:"View as Tabs",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{o.node.setAttr("view","tabs")}}),n.commands.registerCommand({id:"add-checkbox",title:"Add checkbox",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{let i=new T;o.node.addComponent(i)}}),n.commands.registerCommand({id:"remove-checkbox",title:"Remove checkbox",when:o=>!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)?!1:!!o.node.hasComponent(T),action:o=>{o.node.removeComponent(T)}}),n.commands.registerCommand({id:"create-field",title:"Create Field",action:o=>{if(!o.node||o.node.childCount>0||o.node.componentCount>0||o.path.previous&&M(o.path.previous))return;let i=o.path.clone();i.pop();let s=n.workspace.new(o.node.name,"");s.raw.Parent=o.node.parent.id;let l=new U;s.addComponent(l),o.node.parent.addLinked("Fields",s),i.push(s),o.node.destroy(),m.redraw.sync(),n.focus(i)}}),n.commands.registerCommand({id:"mark-done",title:"Mark Done",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{if(o.node)if(o.node.hasComponent(T)){let i=o.node.getComponent(T);i.checked?o.node.removeComponent(T):(i.checked=!0,o.node.changed())}else{let i=new T;o.node.addComponent(i)}}}),n.keybindings.registerBinding({command:"mark-done",key:"meta+enter"}),n.commands.registerCommand({id:"expand",title:"Expand",action:o=>{o.node&&(n.workspace.setExpanded(o.path.head,o.node,!0),m.redraw())}}),n.keybindings.registerBinding({command:"expand",key:"meta+arrowdown"}),n.commands.registerCommand({id:"collapse",title:"Collapse",action:o=>{o.node&&(n.workspace.setExpanded(o.path.head,o.node,!1),m.redraw())}}),n.keybindings.registerBinding({command:"collapse",key:"meta+arrowup"}),n.commands.registerCommand({id:"indent",title:"Indent",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{let i=o.node,s=o.path.clone(),l=i.prevSibling;for(;l&&M(l);)if(l=l.prevSibling,!l)return;l!==null&&(s.pop(),s.push(l),i.parent=l,s.push(i),n.workspace.setExpanded(o.path.head,l,!0),m.redraw.sync(),n.focus(s))}}),n.keybindings.registerBinding({command:"indent",key:"tab"}),n.commands.registerCommand({id:"outdent",title:"Outdent",when:o=>!(!o.node||o.node.raw.Rel==="Fields"||o.path.previous&&M(o.path.previous)||o.node.parent&&o.node.parent.hasComponent(C)),action:o=>{let i=o.node,s=o.path.previous,l=o.path.clone();s!==null&&s.id!=="@root"&&s.id!==n.workspace.lastOpenedID&&(l.pop(),l.pop(),i.parent=s.parent,l.push(i),i.siblingIndex=s.siblingIndex+1,s.childCount===0&&s.getLinked("Fields").length===0&&n.workspace.setExpanded(o.path.head,s,!1),m.redraw.sync(),n.focus(l))}}),n.keybindings.registerBinding({command:"outdent",key:"shift+tab"}),n.commands.registerCommand({id:"move-up",title:"Move Up",action:o=>{if(!o.node)return;let i=o.node,s=i.parent;if(s!==null&&s.id!=="@root"){let l=s.childCount;if(i.siblingIndex===0){if(!s.prevSibling)return;let d=o.path.clone();d.pop(),d.pop();let u=s.prevSibling;for(;u&&M(u);)if(u=u.prevSibling,!u)return;d.push(u),d.push(i),i.parent=u,i.siblingIndex=u.childCount-1,n.workspace.setExpanded(o.path.head,u,!0),m.redraw.sync(),n.focus(d)}else{if(l===1)return;i.siblingIndex=i.siblingIndex-1,m.redraw.sync()}}}}),n.keybindings.registerBinding({command:"move-up",key:"shift+meta+arrowup"}),n.commands.registerCommand({id:"move-down",title:"Move Down",action:o=>{if(!o.node)return;let i=o.node,s=i.parent;if(s!==null&&s.id!=="@root"){let l=s.childCount;if(i.siblingIndex===l-1){if(!s.nextSibling)return;let d=o.path.clone();d.pop(),d.pop();let u=s.nextSibling;for(;u&&M(u);)if(u=u.nextSibling,!u)return;d.push(u),d.push(i),i.parent=u,i.siblingIndex=0,n.workspace.setExpanded(o.path.head,u,!0),m.redraw.sync(),n.focus(d)}else{if(l===1)return;i.siblingIndex=i.siblingIndex+1,m.redraw.sync()}}}}),n.keybindings.registerBinding({command:"move-down",key:"shift+meta+arrowdown"}),n.commands.registerCommand({id:"insert-child",title:"Insert Child",action:(o,i="",s)=>{if(!o.node||M(o.node))return;let l=n.workspace.new(i);l.parent=o.node,s!==void 0&&(l.siblingIndex=s),n.workspace.setExpanded(o.path.head,o.node,!0),m.redraw.sync(),n.focus(o.path.append(l),i.length)}}),n.commands.registerCommand({id:"insert-before",title:"Insert Before",action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let i=n.workspace.new("");i.parent=o.node.parent,i.siblingIndex=o.node.siblingIndex,m.redraw.sync();let s=o.path.clone();s.pop(),n.focus(s.append(i))}}),n.commands.registerCommand({id:"insert",title:"Insert Node",action:(o,i="")=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let s=n.workspace.new(i);s.parent=o.node.parent,s.siblingIndex=o.node.siblingIndex+1,m.redraw.sync();let l=o.path.clone();l.pop(),n.focus(l.append(s))}}),n.keybindings.registerBinding({command:"insert",key:"shift+enter"}),n.commands.registerCommand({id:"create-reference",title:"Create Reference",action:o=>{if(!o.node||o.path.previous&&M(o.path.previous))return;let i=n.workspace.new("");i.parent=o.node.parent,i.siblingIndex=o.node.siblingIndex+1,i.refTo=o.node,m.redraw.sync();let s=o.path.clone();s.pop(),n.focus(s.append(i))}}),n.commands.registerCommand({id:"delete",title:"Delete Node",action:o=>{if(!o.node||o.node.id.startsWith("@")||o.path.previous&&M(o.path.previous))return;let i=n.workspace.findAbove(o.path);if(o.node.destroy(),m.redraw.sync(),i){let s=0;o.event&&o.event.key==="Backspace"&&(i.node.value?s=i.node.value.length:s=i.node.name.length),i.node.childCount===0&&n.workspace.setExpanded(o.path.head,i.node,!1),n.focus(i,s)}}}),n.keybindings.registerBinding({command:"delete",key:"shift+meta+backspace"}),n.commands.registerCommand({id:"prev",title:"Previous Node",action:o=>{if(!o.node)return;let i=n.workspace.findAbove(o.path);i&&n.focus(i)}}),n.keybindings.registerBinding({command:"prev",key:"arrowup"}),n.commands.registerCommand({id:"next",title:"Next Node",action:o=>{if(!o.node)return;let i=n.workspace.findBelow(o.path);i&&n.focus(i)}}),n.keybindings.registerBinding({command:"next",key:"arrowdown"}),n.commands.registerCommand({id:"pick-command",title:"Command Palette",hidden:!0,when:o=>!n.isDialogOpen(),action:o=>{let i=o.node,s=o.path,l=!1;i||(i=o.path.head,s=new R(o.path.head,o.path.name),l=!0);let d=n.getInput(s),u=d.getBoundingClientRect(),h=r.body.scrollLeft+u.x+d.selectionStart*10+20,p=r.body.scrollTop+u.y-8;d.coordsAtCursor&&(h=d.coordsAtCursor.left-17,p=d.coordsAtCursor.top-16),l&&(h=r.body.scrollLeft+u.x,p=r.body.scrollTop+u.y+u.height),n.showPalette(h,p,n.newContext({node:i}))}}),n.keybindings.registerBinding({command:"pick-command",key:"meta+k"}),n.commands.registerCommand({id:"new-panel",title:"Open in New Panel",action:o=>{o.node&&(n.openNewPanel(o.node),m.redraw())}}),n.commands.registerCommand({id:"close-panel",title:"Close Panel",action:(o,i)=>{n.closePanel(i||o.path),n.context.path=n.mainPanel,m.redraw()}}),n.commands.registerCommand({id:"zoom",title:"Open",action:o=>{n.workspace.lastOpenedID=o.node.id,n.workspace.save(),n.context.path=o.path.append(o.node),n.panels[0]=n.context.path,m.redraw()}}),n.commands.registerCommand({id:"generate-random",hidden:!0,title:"Generate Random Children",action:o=>{o.node&&[...Array(100)].forEach(()=>{let i=n.workspace.new(it(8));i.parent=o.node})}}),n.menus.registerMenu("node",[{command:"zoom"},{command:"new-panel"},{command:"cut"},{command:"copy"},{command:"paste"},{command:"indent"},{command:"outdent"},{command:"move-up"},{command:"move-down"},{command:"delete"}]),n.menus.registerMenu("settings",[{title:()=>`${n.backend.auth?.currentUser()?.userID()} @ GitHub`,disabled:!0,when:()=>n.authenticated()},{title:()=>"Login with GitHub",when:()=>!n.authenticated(),onclick:()=>{localStorage.getItem("github")?n.backend.auth.login():n.showNotice("github",()=>{n.backend.auth.login()})}},{title:()=>"Reset Demo",when:()=>!n.authenticated(),onclick:()=>{localStorage.clear(),location.reload()}},{title:()=>"Settings",onclick:()=>n.showSettings()},{title:()=>"Documentation",onclick:()=>window.open("https://treehouse.sh/docs/user","_blank")},{title:()=>"Submit Issue",onclick:()=>window.open("https://github.com/treehousedev/treehouse/issues","_blank")},{title:()=>"Logout",when:()=>n.authenticated(),onclick:()=>n.backend.auth.logout()}]),r.addEventListener("keydown",o=>{let i=n.keybindings.evaluateEvent(o);if(i&&n.canExecuteCommand(i.command,n.context)){n.executeCommand(i.command,n.context),o.stopPropagation(),o.preventDefault();return}}),m.mount(e,{view:()=>m(He,{workbench:n})})}a(ri,"setup");function it(r=10){let e=a((o,i)=>Math.round(Math.random()*(i-o)+o),"random"),t=a(()=>{let o=["got","ability","shop","recall","fruit","easy","dirty","giant","shaking","ground","weather","lesson","almost","square","forward","bend","cold","broken","distant","adjective"];return o[e(0,o.length-1)]},"word");return a(o=>[...Array(o)].map((i,s)=>t()).join(" ").trim(),"words")(e(2,r))}a(it,"generateName");export{Z as BrowserBackend,ue as GitHubBackend,re as SearchIndex_MiniSearch,ri as setup}; //# sourceMappingURL=treehouse.min.js.map diff --git a/lib/treehouse.min.js.map b/lib/treehouse.min.js.map index e1e4338..e2b8123 100644 --- a/lib/treehouse.min.js.map +++ b/lib/treehouse.min.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../../../lib/action/keybinds.ts", "../../../lib/action/commands.ts", "../../../lib/action/menus.ts", "../../../lib/ui/menu.tsx", "../../../lib/ui/picker.tsx", "../../../lib/ui/palette.tsx", "../../../lib/model/hooks.ts", "../../../lib/model/components.ts", "../../../lib/com/document.tsx", "../../../lib/ui/node/editor.tsx", "../../../lib/view/empty.tsx", "../../../lib/ui/node/new.tsx", "../../../lib/com/smartnode.tsx", "../../../lib/view/list.tsx", "../../../lib/view/table.tsx", "../../../lib/view/tabs.tsx", "../../../lib/view/document.tsx", "../../../lib/view/views.ts", "../../../lib/com/template.tsx", "../../../lib/com/tag.tsx", "../../../lib/ui/outline.tsx", "../../../lib/ui/quickadd.tsx", "../../../lib/ui/settings.tsx", "../../../lib/ui/notices.tsx", "../../../lib/workbench/workbench.ts", "../../../lib/workbench/util.js", "../../../lib/workbench/path.ts", "../../../lib/model/module/bus.ts", "../../../lib/model/module/node.ts", "../../../lib/workbench/workspace.ts", "../../../lib/ui/drawer.tsx", "../../../lib/com/page.tsx", "../../../lib/ui/panel.tsx", "../../../lib/ui/reference.tsx", "../../../lib/ui/search.tsx", "../../../lib/ui/app.tsx", "../../../lib/com/checkbox.tsx", "../../../lib/com/textfield.tsx", "../../../lib/com/clock.tsx", "../../../lib/backend/browser.ts", "../../../lib/backend/github.ts", "../../../lib/mod.ts"], - "sourcesContent": ["\nconst isMac = (navigator.userAgent.toLowerCase().indexOf(\"mac\") !== -1);\n\nexport function bindingSymbols(key?: string): string[] {\n if (!key) return [];\n const symbols = {\n \"backspace\": \"\u232B\",\n \"shift\": \"\u21E7\",\n \"meta\": \"\u2318\",\n \"tab\": \"\u21B9\",\n \"ctrl\": \"\u2303\",\n \"arrowup\": \"\u2191\",\n \"arrowdown\": \"\u2193\",\n \"arrowleft\": \"\u2190\",\n \"arrowright\": \"\u2192\",\n \"enter\": \"\u23CE\"\n };\n const keys = key.toLowerCase().split(\"+\");\n return keys.map(filterKeyForNonMacMeta).map(k => (Object.keys(symbols).includes(k)) ? symbols[k] : k);\n}\n\n// if key is meta and not on a mac, change it to ctrl,\n// otherwise return the key as is\nfunction filterKeyForNonMacMeta(key: string): string {\n return (!isMac && key === \"meta\") ? \"ctrl\": key;\n}\n\nexport interface Binding {\n command: string;\n key: string;\n //when\n //args\n}\n\nexport class KeyBindings {\n bindings: Binding[];\n\n constructor() {\n this.bindings = [];\n }\n\n registerBinding(binding: Binding) {\n this.bindings.push(binding);\n }\n\n getBinding(commandId: string): Binding|null {\n for (const b of this.bindings) {\n if (b.command === commandId) {\n return b;\n }\n }\n return null;\n }\n\n evaluateEvent(event: KeyboardEvent): Binding|null {\n bindings: for (const b of this.bindings) {\n let modifiers = b.key.toLowerCase().split(\"+\");\n let key = modifiers.pop();\n if (key !== event.key.toLowerCase()) {\n continue;\n }\n for (const checkMod of [\"shift\", \"ctrl\", \"alt\", \"meta\"]) {\n let hasMod = modifiers.includes(checkMod);\n if (!isMac) {\n if (checkMod === \"meta\") continue;\n if (checkMod === \"ctrl\") {\n hasMod = modifiers.includes(\"meta\") || modifiers.includes(\"ctrl\");\n }\n }\n // @ts-ignore\n const modState = event[`${filterKeyForNonMacMeta(checkMod)}Key`];\n if (!modState && hasMod) {\n continue bindings;\n }\n if (modState && !hasMod) {\n continue bindings;\n }\n }\n return b;\n }\n return null;\n }\n}", "\nexport interface Command {\n id: string;\n title?: string;\n category?: string;\n icon?: string;\n hidden?: boolean;\n action: Function;\n when?: Function;\n}\n\nexport class CommandRegistry {\n commands: {[index: string]: Command}\n\n constructor() {\n this.commands = {};\n }\n\n registerCommand(cmd: Command) {\n this.commands[cmd.id] = cmd;\n }\n\n canExecuteCommand(id: string, ...rest: any): boolean {\n if (this.commands[id]) {\n if (this.commands[id].when && !this.commands[id].when(...rest)) {\n return false;\n }\n return true;\n }\n return false;\n }\n\n executeCommand(id: string, ...rest: any): Promise {\n return new Promise((resolve) => {\n const ret = this.commands[id].action(...rest);\n resolve(ret);\n });\n }\n}", "\nexport interface MenuItem {\n command: string;\n //alt?: string;\n when?: Function;\n title?: Function;\n onclick?: Function;\n disabled?: boolean;\n //group\n //submenu\n}\n\nexport class MenuRegistry {\n menus: {[index: string]: MenuItem[]};\n\n constructor() {\n this.menus = {};\n }\n\n registerMenu(id: string, items: MenuItem[]) {\n this.menus[id] = items;\n }\n}", "import { bindingSymbols } from \"../action/keybinds.ts\";\n\nfunction isDisabled(workbench, item, cmd, ctx) {\n if (cmd) {\n return item.disabled || !workbench.canExecuteCommand(cmd.id, ctx);\n }\n return item.disabled;\n}\n\nexport const Menu: m.Component = {\n view({attrs: {workbench, x, y, items, align, commands, ctx}}) {\n const onclick = (item, cmd) => (e) => {\n e.stopPropagation();\n if (isDisabled(workbench, item, cmd, ctx)) {\n return;\n }\n workbench.closeMenu();\n if (item.onclick) {\n item.onclick();\n }\n if (cmd) {\n workbench.executeCommand(cmd.id, ctx);\n }\n };\n return (\n
    \n {items.filter(i => !i.when || i.when()).map(i => {\n let title = \"\";\n let binding = undefined;\n let cmd = undefined;\n if (i.command) {\n cmd = commands.find(c => c.id === i.command);\n binding = workbench.keybindings.getBinding(cmd.id);\n title = cmd.title;\n }\n if (i.title) {\n title = i.title();\n }\n return (\n
  • \n
    {title}
    \n {binding &&
    {bindingSymbols(binding.key).join(\" \").toUpperCase()}
    }\n
  • \n )\n })}\n
\n ) \n }\n};\n\n/*
  • Indent
    shift+A
  • \n
  • Open in new panel
    shift+meta+Backspace
  • \n
    \n
  • Show list view
  • \n
  • Move
  • \n
  • Delete node
  • \n
    */\n", "\nexport interface Attrs {\n input: string;\n inputview: (onkeydown: Function, oninput: Function) => any;\n itemview: (item: any, idx: number) => any;\n onpick: (item: any) => void;\n onchange: (State) => void;\n}\n\nexport interface State {\n selected: number;\n input: string;\n items: any[];\n}\n\nexport const Picker: m.Component = {\n onupdate({ state, dom }) {\n const items = dom.querySelector(\".items\").children;\n if (state.selected !== undefined && items.length > 0) {\n items[state.selected].scrollIntoView({ block: \"nearest\" });\n }\n },\n\n oncreate({ attrs, state, dom }) {\n if (attrs.inputview) {\n dom.querySelector(\"input\")?.focus();\n }\n if (state.selected === undefined) {\n state.selected = 0;\n }\n },\n\n view({ attrs, state }) {\n \n state.selected = (state.selected === undefined) ? 0 : state.selected;\n state.input = (state.input === undefined) ? (attrs.input || \"\") : state.input;\n if (state.items === undefined) {\n state.items = [];\n attrs.onchange(state);\n }\n\n const onkeydown = (e) => {\n const mod = (a, b) => ((a % b) + b) % b;\n if (e.key === \"ArrowDown\") {\n if (state.selected === undefined) {\n state.selected = 0;\n return false;\n }\n state.selected = mod(state.selected + 1, state.items.length);\n return false;\n }\n if (e.key === \"ArrowUp\") {\n if (state.selected === undefined) {\n state.selected = 0;\n }\n state.selected = mod(state.selected - 1, state.items.length);\n return false;\n }\n if (e.key === \"Enter\") {\n if (state.selected !== undefined) {\n attrs.onpick(state.items[state.selected]);\n }\n return false;\n }\n }\n const oninput = (e) => {\n state.input = e.target.value;\n state.selected = 0;\n attrs.onchange(state);\n }\n return (\n
    \n {attrs.inputview(onkeydown, oninput, state.input)}\n
    \n {state.items.map((item, idx) => (\n
    attrs.onpick(item)}\n onmouseover={() => state.selected = idx}>\n {attrs.itemview(item, idx)}\n
    \n ))}\n
    \n
    \n )\n }\n}\n", "import { bindingSymbols } from \"../action/keybinds.ts\";\nimport { Picker } from \"./picker.tsx\";\n\nexport const CommandPalette: m.Component = {\n\n view({ attrs: { workbench, ctx } }) {\n const getTitle = (cmd) => {\n const title = cmd.title || cmd.id;\n return title.replace('-', ' ').replace(/(^|\\s)\\S/g, t => t.toUpperCase());\n }\n const sort = (a, b) => {\n return getTitle(a).localeCompare(getTitle(b));\n }\n const onpick = (cmd) => {\n workbench.closeDialog();\n workbench.commands.executeCommand(cmd.id, ctx);\n }\n const onchange = (state) => {\n state.items = cmds.filter(cmd => {\n const value = cmd.title || cmd.id;\n return value.toLowerCase().includes(state.input.toLowerCase());\n })\n }\n const getBindingSymbols = (cmd) => {\n const binding = workbench.keybindings.getBinding(cmd.id);\n return binding ? bindingSymbols(binding.key).join(\" \").toUpperCase() : \"\";\n }\n\n const cmds = Object.values(workbench.commands.commands)\n .filter(cmd => !cmd.hidden)\n .filter(cmd => workbench.canExecuteCommand(cmd.id, ctx))\n .sort(sort);\n\n return (\n
    \n \n
    \n \n
    \n }\n itemview={(cmd) => \n
    \n
    {getTitle(cmd)}
    \n
    {getBindingSymbols(cmd)}
    \n
    \n } />\n
    \n )\n }\n}\n\n", "/**\n * Hooks are single method interfaces implemented by component values. There are\n * some system hook interfaces defined here as well as utilities for working with\n * system and app hooks.\n * \n * @module\n */\nimport { Node } from \"./mod.ts\";\n\n// triggered on parent set or import (if has parent), or addcomponent\nexport interface AttachListener {\n onAttach(node: Node): void;\n}\n\n// called on accessing children\nexport interface ChildProvider {\n objectChildren(node: Node, children: Node[]): Node[];\n}\n\nexport function hasHook(node: Node, hook: string): boolean {\n return node.value && node.value[hook] instanceof Function;\n}\n\nexport function triggerHook(node: Node, hook: string, ...args: any[]): any {\n if (hasHook(node, hook)) {\n return node.value[hook].apply(node.value, args);\n }\n}\n\nexport function objectHas(obj: Node, hook: string): boolean {\n for (const com of obj.components) {\n if (hasHook(com, hook)) return true;\n }\n return false;\n}\n\nexport function objectCall(obj: Node, hook: string, ...args: any[]): any {\n for (const com of obj.components) {\n if (hasHook(com, hook)) {\n return com.value[hook].apply(com.value, args);\n }\n }\n}\n\nexport function componentsWith(obj: Node, hook: string, ...args: any[]): any[] {\n const ret = [];\n for (const com of obj.components) {\n if (hasHook(com, hook)) {\n ret.push(com.value);\n }\n }\n return ret;\n}\n\n\n\n// shorthand for nodes that have child provider hook.\n// use this to determine if some commands should be\n// prevented since visible children will not be impacted.\nexport function objectManaged(obj: Node): boolean {\n return objectHas(obj, \"objectChildren\");\n}", "/**\n * Components are classes that can be used for component values in component nodes.\n * These classes need to be registered so they can be properly \"hydrated\" from \n * marshaled form (usually JSON) back into class instances.\n * \n * @module\n */\n\nconst registry: Record = {};\n\nexport function component(target: any) {\n registry[componentName(target)] = target;\n}\n\nexport function componentName(target: any): string {\n if (target.prototype === undefined) {\n target = target.constructor;\n }\n return `treehouse.${target.name}`;\n}\n\nexport function getComponent(com: any): any {\n if (typeof com === \"string\") {\n return registry[com];\n }\n return registry[componentName(com)];\n}\n\nexport function inflateToComponent(com: any, obj: any): any {\n const o = new (getComponent(com));\n if (o[\"fromJSON\"] instanceof Function) {\n o.fromJSON(obj);\n } else {\n Object.defineProperties(o, Object.getOwnPropertyDescriptors(obj));\n }\n return o;\n}\n\nexport function duplicate(obj: any): any {\n if (obj === undefined) {\n return undefined;\n }\n const com = getComponent(obj);\n if (!com) {\n return structuredClone(obj);\n }\n const src = JSON.parse(JSON.stringify(obj)||\"\");\n const dst = new obj.constructor();\n if (dst[\"fromJSON\"] instanceof Function) {\n dst.fromJSON(src);\n } else {\n Object.defineProperties(dst, Object.getOwnPropertyDescriptors(src));\n }\n return dst;\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Document {\n object?: Node;\n\n constructor() {\n }\n\n onAttach(node: Node) {\n this.object = node.parent;\n this.object.setAttr(\"view\", \"document\");\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {/* {collapsed?:null} */}\n \n \n \n \n \n \n );\n }\n\n toJSON(key: string): any {\n return {};\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-document\",\n title: \"Make Document\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const doc = new Document();\n ctx.node.addComponent(doc);\n ctx.node.changed();\n workbench.executeCommand(\"zoom\", ctx);\n }\n });\n }\n}\n", "import { objectCall, objectHas } from \"../../model/hooks.ts\";\nimport { Document } from \"../../com/document.tsx\";\n\nexport const NodeEditor: m.Component = {\n view ({attrs: {workbench, path, onkeydown, oninput, disallowEmpty, editValue, placeholder}, state}) {\n const node = path.node;\n let prop = (editValue) ? \"value\" : \"name\";\n \n const display = () => {\n if (prop === \"name\") {\n return objectHas(node, \"displayName\") ? objectCall(node, \"displayName\", node) : node.name;\n }\n return node[prop] || \"\";\n }\n const onfocus = () => {\n state.initialValue = node[prop];\n workbench.context.node = node;\n workbench.context.path = path;\n }\n const getter = () => {\n return node[prop];\n }\n const setter = (v, finished) => {\n if (!node.isDestroyed) {\n if (disallowEmpty && v.length === 0) {\n node[prop] = state.initialValue;\n } else {\n node[prop] = v;\n }\n }\n if (finished) {\n workbench.context.node = null;\n }\n }\n\n if (node.raw.Rel === \"Fields\") {\n placeholder = (editValue) ? \"Value\" : \"Field\";\n }\n \n let id = `input-${path.id}-${node.id}`;\n if (prop === \"value\") {\n id = id+\"-value\";\n }\n let editor = TextAreaEditor;\n if (node.parent && node.parent.hasComponent(Document) && window.Editor) {\n editor = CodeMirrorEditor;\n }\n return m(editor, {id, getter, setter, display, onkeydown, onfocus, oninput, placeholder});\n }\n}\n\n\ninterface Attrs {\n id?: string;\n onkeydown?: Function;\n onfocus?: Function;\n onblur?: Function;\n onmount?: Function;\n getter: Function;\n setter: Function;\n display?: Function;\n}\n\ninterface State {\n editing: boolean;\n buffer: string;\n}\n\nexport const CodeMirrorEditor: m.Component = {\n oncreate({dom,state,attrs: {id, onkeydown, onfocus, onblur, oninput, getter, setter, display, placeholder}}) {\n const value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n\n const defaultKeydown = (e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n const startEdit = (e) => {\n if (onfocus) onfocus(e);\n state.editing = true;\n state.buffer = getter();\n }\n const finishEdit = (e) => {\n // safari can trigger blur more than once\n // for a given element, namely when clicking\n // into devtools. this prevents the second \n // blur setting node name to undefined/empty.\n if (state.editing) {\n state.editing = false;\n setter(state.buffer, true);\n state.buffer = undefined;\n }\n if (onblur) onblur(e);\n }\n const edit = (e) => {\n state.buffer = e.target.value;\n setter(state.buffer, false);\n if (oninput) {\n oninput(e);\n }\n }\n\n state.editor = new window.Editor(dom, value, placeholder);\n state.editor.onblur = finishEdit;\n state.editor.onfocus = startEdit;\n state.editor.oninput = edit;\n state.editor.onkeydown = onkeydown||defaultKeydown;\n dom.editor = state.editor;\n dom.id = id;\n },\n onupdate({dom,state,attrs: {getter, display}}) {\n state.editor.value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n },\n view () {\n return (\n
    \n )\n }\n}\n\nexport const TextAreaEditor: m.Component = {\n oncreate({dom,attrs}) {\n const textarea = dom.querySelector(\"textarea\");\n const initialHeight = textarea.offsetHeight;\n const span = dom.querySelector(\"span\");\n this.updateHeight = () => {\n span.style.width = `${Math.max(textarea.offsetWidth, 100)}px`;\n span.innerHTML = textarea.value.replace(\"\\n\", \"
    \");\n let height = span.offsetHeight;\n if (height === 0 && initialHeight > 0) {\n height = initialHeight;\n }\n textarea.style.height = (height > 0) ? `${height}px` : `var(--body-line-height)`;\n }\n textarea.addEventListener(\"input\", () => this.updateHeight());\n textarea.addEventListener(\"blur\", () => span.innerHTML = \"\");\n setTimeout(() => this.updateHeight(), 50);\n if (attrs.onmount) attrs.onmount(textarea);\n },\n onupdate() {\n this.updateHeight();\n },\n view ({attrs: {id, onkeydown, onfocus, onblur, oninput, getter, setter, display, placeholder}, state}) {\n const value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n \n const defaultKeydown = (e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n const startEdit = (e) => {\n if (onfocus) onfocus(e);\n state.editing = true;\n state.buffer = getter();\n }\n const finishEdit = (e) => {\n // safari can trigger blur more than once\n // for a given element, namely when clicking\n // into devtools. this prevents the second \n // blur setting node name to undefined/empty.\n if (state.editing) {\n state.editing = false;\n setter(state.buffer, true);\n state.buffer = undefined;\n }\n if (onblur) onblur(e);\n }\n const edit = (e) => {\n state.buffer = e.target.value;\n setter(state.buffer, false);\n if (oninput) {\n oninput(e);\n }\n }\n \n return (\n
    \n {value}\n \n
    \n )\n }\n}", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {node, workbench, panel}}) {\n return (\n
    \n
    \n )\n }\n}", "\nexport const NewNode = {\n view({attrs: {workbench, path}}) {\n const keydown = (e) => {\n if (e.key === \"Tab\") {\n e.stopPropagation();\n e.preventDefault();\n if (node.childCount > 0) {\n const lastchild = path.node.children[path.node.childCount-1];\n workbench.executeCommand(\"insert-child\", {node: lastchild, path});\n }\n } else {\n workbench.executeCommand(\"insert-child\", {node: path.node, path}, e.target.value);\n }\n }\n return (\n
    \n \n \n \n \n
    \n \n
    \n
    \n )\n }\n}", "import { Workbench } from \"../workbench/mod.ts\";\nimport { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\nfunction debounce(func, timeout = 1000){\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => { func.apply(this, args); }, timeout);\n };\n}\n\n@component\nexport class SmartNode {\n workbench: Workbench;\n component?: Node;\n object?: Node;\n results?: Node[];\n query: string;\n\n lastQuery?: string;\n lastResultCount?: number;\n initialSearch: boolean;\n\n constructor() {\n this.workbench = window.workbench;\n this.searchDebounce = debounce(this.search.bind(this));\n this.query = \"\";\n this.initialSearch = false;\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {collapsed?:null}\n \n \n \n \n \n );\n }\n\n belowEditor() {\n return SmartFilter;\n }\n\n onAttach(node: Node) {\n this.component = node;\n this.object = node.parent;\n node.bus.observe((n: Node) => {\n if (!node.isDestroyed) {\n this.searchDebounce();\n }\n });\n }\n\n search() {\n if (!this.object) return;\n if (!this.query) {\n this.lastQuery = \"\";\n this.results = [];\n return;\n }\n this.initialSearch = true;\n\n const results = this.workbench.search(this.query)\n .filter(n => n.id !== this.object.id && n.id !== this.component.id);\n \n if (results.length !== this.lastResultCount || this.query !== this.lastQuery) {\n if (this.results) {\n // clean up old results\n this.results.forEach((n) => n.destroy());\n }\n this.results = results.map(n => {\n const ref = this.object.bus.make(\"\");\n ref.raw.Parent = \"@tmp\"; // cleaned up next import\n ref.refTo = n;\n return ref;\n });\n this.lastQuery = this.query;\n this.lastResultCount = results.length;\n }\n }\n\n objectChildren(node: Node, children: Node[]): Node[] {\n if (!this.results && this.query && !this.initialSearch) {\n this.search();\n }\n return this.results || [];\n }\n\n toJSON(key: string): any {\n return {\n query: this.query\n };\n }\n\n fromJSON(obj: any) {\n this.query = obj.query || \"\";\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-smart-node\",\n title: \"Make Smart Node\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.childCount > 0) return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n workbench.defocus();\n const search = new SmartNode();\n ctx.node.addComponent(search);\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n if (ctx.node.name === \"\") {\n setTimeout(() => {\n // defocusing will overwrite this from buffer\n // without a delay\n ctx.node.name = \"Unnamed Smart Node\";\n m.redraw();\n document.querySelector(`#node-${ctx.path.id}-${ctx.node.id} input`).focus();\n }, 10);\n }\n }\n });\n }\n}\n\n\nconst SmartFilter = {\n view({attrs: {node, component, expanded}}) {\n if (!expanded) return;\n\n const oninput = (e) => {\n component.query = e.target.value;\n component.search();\n node.changed();\n }\n return (\n
    \n
    \n \n
    \n )\n }\n}", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\nimport { SmartNode } from \"../com/smartnode.tsx\";\n\nexport default {\n view({attrs: {workbench, path, alwaysShowNew}}) {\n let node = path.node;\n if (path.node.refTo) {\n node = path.node.refTo;\n }\n let showNew = false;\n if ((node.childCount === 0 && node.getLinked(\"Fields\").length === 0) || alwaysShowNew) {\n showNew = true;\n }\n // TODO: find some way to not hardcode this rule\n if (node.hasComponent(SmartNode)) {\n showNew = false;\n }\n return (\n
    \n
    \n {(node.getLinked(\"Fields\").length > 0) &&\n node.getLinked(\"Fields\").map(n => )\n }\n
    \n
    \n {(node.childCount > 0) && node.children.map(n => )}\n {showNew && }\n
    \n
    \n )\n }\n}", "import { NodeEditor, TextAreaEditor } from \"../ui/node/editor.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {workbench, path}, state}) {\n const node = path.node;\n state.fields = (state.fields === undefined) ? new Set() : state.fields;\n node.children.forEach(n => {\n n.getLinked(\"Fields\").forEach(f => state.fields.add(f.name));\n });\n const getFieldEditor = (node, field) => {\n const fields = node.getLinked(\"Fields\").filter(f => f.name === field);\n if (fields.length === 0) return \"\";\n return \n }\n return (\n \n \n \n \n {[...state.fields].map(f => )}\n \n \n \n {node.children.map(n => (\n \n \n {[...state.fields].map(f => )}\n \n ))}\n \n
    Title{f}
    {getFieldEditor(n, f)}
    \n )\n }\n}", "\nimport { getView } from \"../view/views.ts\";\n\nexport default {\n view({ attrs: { workbench, path }, state }) {\n const node = path.node;\n state.tabs = (state.tabs === undefined) ? new Set() : state.tabs;\n state.selectedTab = (state.selectedTab === undefined) ? \"\" : state.selectedTab;\n node.children.forEach(n => {\n state.tabs.add(n.raw);\n if (state.selectedTab === \"\") state.selectedTab = n.raw.ID;\n });\n const handleTabClick = (id) => {\n state.selectedTab = id;\n };\n const selectedNode = node.children.find(n => n.id === state.selectedTab);\n return (\n
    \n
    \n {[...state.tabs].map(n =>
    handleTabClick(n.ID)}>{n.Name}
    )}\n
    \n
    \n
    \n {m(getView(selectedNode.getAttr(\"view\")||\"list\"), {workbench, path: path.append(selectedNode)})}\n
    \n
    \n )\n }\n}\n", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {workbench, path, alwaysShowNew}}) {\n let node = path.node;\n if (path.node.refTo) {\n node = path.node.refTo;\n }\n let showNew = false;\n if ((node.childCount === 0 && node.getLinked(\"Fields\").length === 0) || alwaysShowNew) {\n showNew = true;\n }\n return (\n
    \n
    \n {(node.getLinked(\"Fields\").length > 0) &&\n node.getLinked(\"Fields\").map(n => )\n }\n
    \n
    \n {(node.childCount > 0) && node.children.map(n => )}\n {showNew && }\n
    \n
    \n )\n }\n}", "import empty from \"./empty.tsx\";\nimport list from \"./list.tsx\";\nimport table from \"./table.tsx\";\nimport tabs from \"./tabs.tsx\";\nimport document from \"./document.tsx\";\n\nexport const views = {\n list,\n table,\n tabs,\n document,\n}\n\nexport function getView(name) {\n return views[name] || empty;\n}\n\nwindow.registerView = (name, view) => {\n views[name] = view;\n workbench.commands.registerCommand({\n id: `view-${name}`,\n title: `View as ${toTitleCase(name)}`,\n action: (ctx: Context) => {\n if (!ctx.node) return;\n ctx.node.setAttr(\"view\", name);\n }\n });\n}\n\nfunction toTitleCase(str) {\n return str.replace(\n /\\w\\S*/g,\n function(txt) {\n return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();\n }\n );\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Template {\n object?: Node;\n\n constructor() {\n }\n\n onAttach(node: Node) {\n this.object = node.parent;\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {collapsed?:null}\n \n \n \n );\n }\n\n toJSON(key: string): any {\n return {};\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-template\",\n title: \"Make Template\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const tmpl = new Template();\n ctx.node.addComponent(tmpl);\n ctx.node.changed();\n }\n });\n }\n\n static findNode(ws: Workspace, name: string): Node|null {\n let node = null;\n ws.mainNode().walk((n) => {\n if (n.value instanceof Template && n.value.object.name === name) {\n node = n.value.object;\n return true;\n }\n return false;\n }, {includeComponents: true});\n return node;\n }\n}\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { Workbench, Workspace } from \"../workbench/mod.ts\";\nimport { Path } from \"../workbench/path.ts\";\nimport { Template } from \"./template.tsx\";\nimport { Picker } from \"../ui/picker.tsx\";\n\n@component\nexport class Tag {\n name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n afterEditor() {\n return TagBadge;\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"add-tag\",\n title: \"Add tag\",\n hidden: true,\n action: (ctx: Context, name: string) => {\n if (!ctx.node) return;\n const tag = new Tag(name);\n ctx.node.addComponent(tag);\n const tmpl = Template.findNode(workbench.workspace, name);\n if (tmpl) {\n tmpl.fields.map(f => f.duplicate()).forEach(f => {\n ctx.node.addLinked(\"Fields\", f);\n f.raw.Parent = ctx.node.raw.ID;\n });\n tmpl.children.map(c => c.duplicate()).forEach(c => {\n ctx.node.addChild(c);\n c.raw.Parent = ctx.node.raw.ID;\n });\n }\n ctx.node.changed();\n }\n });\n }\n\n static findAll(ws: Workspace): string[] {\n const tags = new Set();\n ws.mainNode().walk((n) => {\n if (n.value instanceof Tag) {\n tags.add(n.value.name);\n }\n return false;\n }, {includeComponents: true});\n return [...tags];\n }\n\n static findTagged(ws: Workspace, name: string): Node[] {\n const nodes = [];\n ws.mainNode().walk((n) => {\n if (n.value instanceof Tag && n.value.name === name) {\n nodes.push(n.parent);\n }\n return false;\n }, {includeComponents: true});\n return nodes;\n }\n\n static showPopover(bench: Workbench, path: Path, node: Node, inputview: Function, closer: Function) {\n const tags = Tag.findAll(bench.workspace);\n const trigger = bench.getInput(path);\n const rect = trigger.getBoundingClientRect();\n let x = document.body.scrollLeft + rect.x + (trigger.selectionStart * 10) + 20;\n let y = document.body.scrollTop + rect.y + rect.height;\n bench.showPopover(() => (\n {\n closer();\n bench.getInput(path).blur();\n node.name = node.name.replace(/\\s*#\\w*/, \"\");\n bench.executeCommand(\"add-tag\", {node, path}, item.name);\n }}\n onchange={(state) => {\n if (node.name.includes(\"#\")) {\n state.input = node.name.split(\"#\")[1];\n } else {\n state.input = \"\";\n }\n const filtered = [...tags]\n .filter(t => t.toLowerCase().startsWith(state.input.toLowerCase()))\n .map(t => {return {name: t}});\n if ((filtered[0] && filtered[0].name != state.input && state.input != \"\") || filtered.length === 0) {\n filtered.unshift({name: state.input, prefix: \"Create tag: \"});\n }\n state.items = filtered;\n }}\n inputview={inputview}\n itemview={(item) => \n
    \n
    {item.prefix||\"\"}{item.name}
    \n
    \n }\n />\n ), {top: `${y}px`, left: `${x}px`});\n }\n}\n\nconst TagBadge = {\n view({attrs: {node, component}}) {\n const onkeydown = (e) => {\n if (e.key === \"Backspace\") {\n node.removeComponent(component);\n node.changed();\n }\n };\n return (\n
    \n \n
    {component.name}
    \n
    \n )\n }\n}", "\nimport { Workbench, Path } from \"../workbench/mod.ts\";\nimport { objectCall, componentsWith, objectHas } from \"../model/hooks.ts\";\nimport { NodeEditor } from \"./node/editor.tsx\";\n\nimport { Checkbox } from \"../com/checkbox.tsx\";\nimport { Document } from \"../com/document.tsx\";\nimport { getView } from \"../view/views.ts\";\n\nimport { Tag } from \"../com/tag.tsx\";\n\nexport interface Attrs {\n path: Path;\n workbench: Workbench;\n}\n\nexport interface State {\n hover: boolean;\n tagPopover?: Popover;\n}\n\ninterface Popover {\n onkeydown: Function;\n oninput: Function;\n}\n\nexport const OutlineEditor: m.Component = {\n view ({attrs: {workbench, path, alwaysShowNew}}) {\n return m(getView(path.node.getAttr(\"view\")||\"list\"), {workbench, path, alwaysShowNew});\n }\n}\n\n// handles: expanded state, node menu+handle, children\nexport const OutlineNode: m.Component = {\n view ({attrs, state, children}) {\n let {path, workbench} = attrs;\n let node = path.node;\n\n let isRef = false;\n let handleNode = node;\n if (node.refTo) {\n isRef = true;\n node = handleNode.refTo;\n }\n\n let isCut = false;\n if (workbench.clipboard && workbench.clipboard.op === \"cut\") {\n if (workbench.clipboard.node.id === node.id) {\n isCut = true;\n }\n }\n\n const expanded = workbench.workspace.getExpanded(path.head, handleNode);\n const placeholder = objectHas(node, \"handlePlaceholder\") ? objectCall(node, \"handlePlaceholder\") : '';\n\n const hover = (e) => {\n state.hover = true;\n e.stopPropagation();\n }\n \n const unhover = (e) => {\n state.hover = false;\n e.stopPropagation();\n }\n \n\n const cancelTagPopover = () => {\n if (state.tagPopover) {\n workbench.closePopover();\n state.tagPopover = undefined;\n }\n }\n\n const oninput = (e) => {\n if (state.tagPopover) {\n state.tagPopover.oninput(e);\n if (!e.target.value.includes(\"#\")) {\n cancelTagPopover();\n }\n } else {\n if (e.target.value.includes(\"#\")) {\n state.tagPopover = {};\n // Don't love that we're hard depending on Tag\n Tag.showPopover(workbench, path, node, (onkeydown, oninput) => {\n state.tagPopover = {onkeydown, oninput};\n }, cancelTagPopover);\n }\n }\n }\n\n const onkeydown = (e) => {\n if (state.tagPopover) {\n if (e.key === \"Escape\") {\n cancelTagPopover();\n return;\n }\n if (state.tagPopover.onkeydown(e) === false) {\n e.stopPropagation();\n return false;\n }\n }\n const anyModifiers = e.shiftKey || e.metaKey || e.altKey || e.ctrlKey;\n switch (e.key) {\n case \"ArrowUp\":\n if (e.target.selectionStart !== 0 && !anyModifiers) {\n e.stopPropagation()\n }\n break;\n case \"ArrowDown\":\n if (e.target.selectionStart !== e.target.value.length && e.target.selectionStart !== 0 && !anyModifiers) {\n e.stopPropagation()\n }\n break;\n case \"Backspace\":\n // cursor at beginning of empty text\n if (e.target.value === \"\") {\n e.preventDefault();\n e.stopPropagation();\n if (node.childCount > 0) {\n return;\n }\n workbench.executeCommand(\"delete\", {node, path, event: e});\n return;\n }\n // cursor at beginning of non-empty text\n if (e.target.value !== \"\" && e.target.selectionStart === 0 && e.target.selectionEnd === 0) {\n e.preventDefault();\n e.stopPropagation();\n if (node.childCount > 0) {\n return;\n }\n \n // TODO: make this work as a command?\n const above = workbench.workspace.findAbove(path);\n if (!above) {\n return;\n }\n const oldName = above.node.name;\n above.node.name = oldName+e.target.value;\n node.destroy();\n m.redraw.sync();\n workbench.focus(above, oldName.length);\n \n return;\n }\n break;\n case \"Enter\":\n e.preventDefault();\n if (e.ctrlKey || e.shiftKey || e.metaKey || e.altKey) return;\n // cursor at end of text\n if (e.target.selectionStart === e.target.value.length) {\n if (node.childCount > 0 && workbench.workspace.getExpanded(path.head, node)) {\n workbench.executeCommand(\"insert-child\", {node, path}, \"\", 0);\n } else {\n workbench.executeCommand(\"insert\", {node, path});\n }\n e.stopPropagation();\n return;\n }\n // cursor at beginning of text\n if (e.target.selectionStart === 0) {\n workbench.executeCommand(\"insert-before\", {node, path});\n e.stopPropagation();\n return;\n }\n // cursor in middle of text\n if (e.target.selectionStart > 0 && e.target.selectionStart < e.target.value.length) {\n workbench.executeCommand(\"insert\", {node, path}, e.target.value.slice(e.target.selectionStart)).then(() => {\n node.name = e.target.value.slice(0, e.target.selectionStart);\n });\n e.stopPropagation();\n return;\n }\n break;\n }\n }\n\n const open = (e) => {\n e.preventDefault();\n e.stopPropagation();\n \n workbench.executeCommand(\"zoom\", {node, path});\n \n // clear text selection that happens after from double click\n if (document.selection && document.selection.empty) {\n document.selection.empty();\n } else if (window.getSelection) {\n window.getSelection().removeAllRanges();\n }\n }\n\n const toggle = (e) => {\n // TODO: hook or something so to not hardcode\n if (node.hasComponent(Document)) {\n open(e);\n return;\n }\n if (expanded) {\n workbench.executeCommand(\"collapse\", {node: handleNode, path});\n } else {\n workbench.executeCommand(\"expand\", {node: handleNode, path});\n }\n e.stopPropagation();\n }\n\n const subCount = (n) => {\n return n.childCount + n.getLinked(\"Fields\").length;\n }\n\n const showHandle = () => {\n if (node.id === workbench.context?.node?.id || state.hover) {\n return true;\n }\n if (node.name.length > 0) return true;\n if (placeholder.length > 0) return true;\n }\n\n return (\n
    \n
    \n workbench.showMenu(e, {node: handleNode, path})}\n oncontextmenu={(e) => workbench.showMenu(e, {node: handleNode, path})} \n data-menu=\"node\"\n viewBox=\"0 0 16 16\">\n {state.hover && }\n \n
    workbench.showMenu(e, {node: handleNode, path})} data-menu=\"node\" style={{ display: showHandle() ? 'block' : 'none' }}>\n {(objectHas(node, \"handleIcon\"))\n ? objectCall(node, \"handleIcon\", subCount(node) > 0 && !expanded)\n : \n {(subCount(node) > 0 && !expanded)?:null}\n ,\n {(isRef)?:null}\n \n }\n
    \n {(node.raw.Rel === \"Fields\") \n ?
    \n
    \n \n
    \n \n
    \n :
    \n {objectHas(node, \"beforeEditor\") && componentsWith(node, \"beforeEditor\").map(component => m(component.beforeEditor(), {node, component}))}\n \n {objectHas(node, \"afterEditor\") && componentsWith(node, \"afterEditor\").map(component => m(component.afterEditor(), {node, component}))}\n
    \n }\n
    \n {objectHas(node, \"belowEditor\") && componentsWith(node, \"belowEditor\").map(component => m(component.belowEditor(), {node, component, expanded}))}\n {(expanded === true) &&\n
    \n
    \n
    \n {m(getView(node.getAttr(\"view\")||\"list\"), {workbench, path})}\n
    \n
    \n }\n
    \n )\n }\n};\n\n\n\n\n\n\n\n", "import { OutlineEditor } from \"./outline.tsx\";\nimport { Path } from \"../workbench/mod.ts\";\n\nexport const QuickAdd = {\n view({attrs: {workbench, node}}) {\n const path = new Path(node, \"quickadd\");\n return (\n
    \n

    Quick Add

    \n \n
    \n \n \n
    \n
    \n )\n }\n}", "\nexport const Settings = {\n view({attrs: {workbench}, state}) {\n const currentTheme = workbench.workspace.settings.theme;\n state.selectedTheme = (state.selectedTheme === undefined) ? currentTheme : state.selectedTheme;\n const oninput = (e) => {\n state.selectedTheme = e.target.value;\n }\n return (\n
    \n

    Settings

    \n
    \n
    Theme
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n )\n }\n}", "\nexport const LockStolenMessage = {\n view() {\n return (\n
    \n

    Refresh to view latest updates

    \n

    \n Your notes were updated in another browser session. Refresh the page to view the latest version.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n\nexport const FirstTimeMessage = {\n view({attrs: {workbench}}) {\n return (\n
    \n

    Treehouse is under active development

    \n

    This is a preview based on our main branch, which is actively being developed.

    \n

    If you find a bug, please report it via \n  \n  > Submit Issue.\n

    \n

    \n Data is stored using localstorage, which you can reset via \n  \n  > Reset Demo.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n\nexport const GitHubMessage = {\n view({attrs: {workbench, finished}}) {\n return (\n
    \n

    Login with GitHub

    \n

    The GitHub backend is experimental so use at your own risk!

    \n

    To store your workbench we will create a public repository called

    <username>.treehouse.sh
    if it doesn't already exist. You can manually make this repository private via GitHub if you want.

    \n

    You can Logout via the \n  \n  \n menu in the top right to return to the localstorage backend.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n", "import { Backend } from \"../backend/mod.ts\";\nimport { KeyBindings } from \"../action/keybinds.ts\";\nimport { CommandRegistry } from \"../action/commands.ts\";\nimport { MenuRegistry } from \"../action/menus.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { objectHas, objectCall } from \"../model/hooks.ts\";\n\nimport { Menu } from \"../ui/menu.tsx\";\nimport { CommandPalette } from \"../ui/palette.tsx\";\nimport { QuickAdd } from \"../ui/quickadd.tsx\";\nimport { Settings } from \"../ui/settings.tsx\";\nimport { FirstTimeMessage, GitHubMessage, LockStolenMessage } from \"../ui/notices.tsx\";\n\nimport { Workspace, Context, Path } from \"./mod.ts\";\nimport { Tag } from \"../com/tag.tsx\";\n\nexport interface Clipboard {\n op: \"cut\"|\"copy\"|\"copyref\";\n node: Node;\n}\n\nexport interface Drawer {\n open: boolean;\n}\n\n/**\n * Workbench is the top-level controller for the Treehouse frontend.\n * \n * It manages the user action registries, open panels, open workspace,\n * user context, and provides an API used by UI components to \n * trigger various pop-overs, work with quick add, or anything else\n * not provided by the backend or workspace.\n */\nexport class Workbench {\n commands: CommandRegistry;\n keybindings: KeyBindings;\n menus: MenuRegistry;\n\n backend: Backend;\n workspace: Workspace;\n \n context: Context;\n panels: Path[];\n clipboard?: Clipboard;\n drawer: Drawer;\n\n popover: any;\n dialog: any;\n menu: any;\n\n constructor(backend: Backend) {\n this.commands = new CommandRegistry();\n this.keybindings = new KeyBindings();\n this.menus = new MenuRegistry();\n\n this.backend = backend;\n this.workspace = new Workspace(backend.files);\n\n this.context = {node: null};\n this.panels = [];\n this.drawer = { open: false };\n\n this.dialog = {body: () => null};\n this.menu = {body: () => null};\n \n }\n\n get mainPanel(): Path {\n return this.panels[0];\n }\n\n async initialize() {\n await this.workspace.load();\n\n this.workspace.rawNodes.forEach(n => this.backend.index.index(n));\n this.workspace.observe((n => {\n this.workspace.save();\n if (n.isDestroyed) {\n this.backend.index.remove(n.id);\n } else {\n this.backend.index.index(n.raw);\n n.components.forEach(com => this.backend.index.index(com.raw));\n }\n }));\n\n \n if (this.workspace.lastOpenedID) {\n this.openNewPanel(this.workspace.find(this.workspace.lastOpenedID) || this.workspace.mainNode());\n } else {\n this.openNewPanel(this.workspace.mainNode());\n }\n\n if (this.backend.loadExtensions) {\n await this.backend.loadExtensions();\n }\n \n if (this.workspace.settings.theme) {\n const css = document.createElement(\"link\");\n // TODO: figure out better way to couple themes than hardcoded hotlinked URL\n css.setAttribute(\"href\", `https://treehouse.sh/style/themes/${this.workspace.settings.theme}.css`);\n css.setAttribute(\"rel\", \"stylesheet\");\n css.setAttribute(\"type\", \"text/css\");\n document.head.appendChild(css);\n }\n\n m.redraw();\n \n }\n\n authenticated(): boolean {\n return this.backend.auth && this.backend.auth.currentUser();\n }\n\n openQuickAdd() {\n let node = this.workspace.find(\"@quickadd\");\n if (!node) {\n node = this.workspace.new(\"@quickadd\");\n }\n this.showDialog(() => m(QuickAdd, {workbench: this, node}), true);\n setTimeout(() => {\n document.querySelector(\"main > dialog .new-node input\").focus();\n }, 1);\n }\n\n commitQuickAdd() {\n const node = this.workspace.find(\"@quickadd\");\n if (!node) return;\n const today = this.todayNode();\n node.children.forEach(n => n.parent = today);\n }\n\n clearQuickAdd() {\n const node = this.workspace.find(\"@quickadd\");\n if (!node) return;\n node.children.forEach(n => n.destroy());\n }\n\n // TODO: goto workspace\n todayNode(): Node {\n const today = new Date();\n const dayNode = today.toUTCString().split(today.getFullYear())[0];\n const weekNode = `Week ${String(getWeekOfYear(today)).padStart(2, \"0\")}`;\n const yearNode = `${today.getFullYear()}`;\n const todayPath = [\"@calendar\", yearNode, weekNode, dayNode].join(\"/\");\n let todayNode = this.workspace.find(todayPath);\n if (!todayNode) {\n todayNode = this.workspace.new(todayPath);\n }\n return todayNode;\n }\n\n openToday() {\n this.open(this.todayNode());\n }\n\n open(n: Node) {\n // TODO: not sure this is still necessary\n if (!this.workspace.expanded[n.id]) {\n this.workspace.expanded[n.id] = {};\n }\n\n this.workspace.lastOpenedID = n.id;\n this.workspace.save();\n const p = new Path(n);\n this.panels[0] = p\n this.context.path = p;\n }\n\n openNewPanel(n: Node) {\n // TODO: not sure this is still necessary\n if (!this.workspace.expanded[n.id]) {\n this.workspace.expanded[n.id] = {};\n }\n\n this.workspace.lastOpenedID = n.id;\n this.workspace.save();\n const p = new Path(n);\n this.panels.push(p);\n this.context.path = p;\n }\n\n closePanel(panel: Path) {\n this.panels = this.panels.filter(p => p.name !== panel.name);\n }\n\n defocus() {\n const input = this.getInput(this.context.path);\n if (input) {\n input.blur();\n }\n this.context.node = null;\n this.context.path = null;\n }\n\n focus(path: Path, pos?: number = 0) {\n const input = this.getInput(path);\n if (input) {\n this.context.path = path;\n input.focus();\n if (pos !== undefined) {\n input.setSelectionRange(pos,pos);\n }\n } else {\n console.warn(\"unable to find input for\", path);\n }\n }\n\n getInput(path: Path): any {\n let id = `input-${path.id}-${path.node.id}`;\n // kludge:\n if (path.node.raw.Rel === \"Fields\") {\n if (path.node.name !== \"\") {\n id = id+\"-value\"; \n }\n }\n const el = document.getElementById(id);\n if (el.editor) {\n return el.editor;\n }\n return el;\n }\n\n canExecuteCommand(id: string, ctx: any, ...rest: any): boolean {\n ctx = this.newContext(ctx);\n return this.commands.canExecuteCommand(id, ctx, ...rest);\n }\n \n executeCommand(id: string, ctx: any, ...rest: any): Promise {\n ctx = this.newContext(ctx);\n console.log(id, ctx, ...rest);\n return this.commands.executeCommand(id, ctx, ...rest);\n }\n\n newContext(ctx: any): Context {\n return Object.assign({}, this.context, ctx);\n }\n\n showMenu(event: Event, ctx: any, style?: {}) {\n event.stopPropagation();\n event.preventDefault();\n const trigger = event.target.closest(\"*[data-menu]\");\n const rect = trigger.getBoundingClientRect();\n if (!style) {\n const align = trigger.dataset[\"align\"] || \"left\";\n style = {\n top: `${document.body.scrollTop+rect.y+rect.height}px`\n }\n if (align === \"right\") {\n style.marginLeft = \"auto\";\n style.marginRight = `${document.body.offsetWidth - rect.right}px`;\n } else {\n style.marginLeft = `${document.body.scrollLeft+rect.x}px`;\n style.marginRight = \"auto\";\n }\n }\n const items = this.menus.menus[trigger.dataset[\"menu\"]];\n const cmds = items.filter(i => i.command).map(i => this.commands.commands[i.command]);\n if (!items) return;\n this.menu = {body: () => m(Menu, { \n workbench: this,\n ctx: this.newContext(ctx), \n items: items,\n commands: cmds,\n }), style};\n m.redraw();\n setTimeout(() => {\n // this next frame timeout is so any current dialog can close before attempting\n // to showModal on already open dialog, which causes exception.\n document.querySelector(\"main > dialog.menu\").showModal();\n }, 0);\n }\n\n closeMenu() {\n document.querySelector(\"main > dialog.menu\").close();\n workbench.menu.body = () => null;\n }\n\n showPalette(x: number, y: number, ctx: Context) {\n this.showDialog(() => m(CommandPalette, {workbench: this, ctx}), false, {left: `${x}px`, top: `${y}px`});\n }\n\n showNotice(notice, finished) {\n this.showDialog(() => m({\n \"firsttime\": FirstTimeMessage,\n \"github\": GitHubMessage,\n \"lockstolen\": LockStolenMessage,\n }[notice], {workbench: this, finished}), true, undefined, (notice===\"lockstolen\")?true:false);\n }\n\n toggleDrawer() {\n this.drawer.open = !this.drawer.open;\n m.redraw();\n }\n\n showSettings() {\n this.showDialog(() => m(Settings, {workbench: this}), true);\n }\n\n showPopover(body: any, style?: {}) {\n this.popover = {body, style};\n m.redraw();\n }\n\n closePopover() {\n this.popover = null;\n m.redraw();\n }\n\n showDialog(body: any, backdrop?: boolean, style?: {}, explicitClose?: boolean) {\n this.dialog = {body, backdrop, style, explicitClose};\n m.redraw();\n setTimeout(() => {\n // this next frame timeout is so any current dialog can close before attempting\n // to showModal on already open dialog, which causes exception.\n document.querySelector(\"main > dialog.modal\").showModal();\n }, 0);\n }\n\n isDialogOpen(): boolean {\n return document.querySelector(\"main > dialog.modal\").hasAttribute(\"open\");\n }\n\n closeDialog() {\n document.querySelector(\"main > dialog.modal\").close();\n this.dialog.body = () => null;\n }\n\n search(query: string): Node[] {\n if (!query) return [];\n // this regex selects spaces NOT inside quotes\n let splitQuery = query.split(/\\s+(?=(?:[^\\'\"]*[\\'\"][^\\'\"]*[\\'\"])*[^\\'\"]*$)/);\n let textQuery = splitQuery.filter(term => !term.includes(\":\")).join(\" \");\n let fieldQuery = Object.fromEntries(splitQuery.filter(term => term.includes(\":\")).map(term => term.toLowerCase().split(\":\")));\n if (!textQuery && Object.keys(fieldQuery).length > 0) {\n // when text query is empty, no results will show up,\n // but we index field names, so this works for now.\n textQuery = Object.keys(fieldQuery)[0];\n }\n const passFieldQuery = (node: Node): boolean => {\n // kludgy filter on fields\n if (Object.keys(fieldQuery).length > 0) {\n const fields = {};\n for (const f of node.getLinked(\"Fields\")) {\n fields[f.name.toLowerCase()] = f.value.toLowerCase();\n }\n for (const f in fieldQuery) {\n if (!fields[f] || fields[f] !== fieldQuery[f].replace(/['\"]/g, \"\")) {\n return false;\n }\n }\n }\n return true;\n }\n // simple, limited search for tag implementation\n if (textQuery.startsWith(\"#\")) {\n return Tag.findTagged(this.workspace, textQuery.replace(\"#\", \"\")).filter(passFieldQuery);\n }\n let resultCache = {};\n this.backend.index.search(textQuery).forEach(id => {\n let node = window.workbench.workspace.find(id);\n if (!node) {\n return;\n }\n // if component/field value, get the parent\n if (node.value) {\n node = node.parent;\n // parent might not actually exist\n if (!node.raw) return;\n }\n if (!passFieldQuery(node)) {\n return;\n }\n resultCache[node.id] = node;\n });\n return Object.values(resultCache);\n }\n\n\n}\n\n\nfunction getWeekOfYear(date) {\n var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n var dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));\n return Math.ceil((((d - yearStart) / 86400000) + 1)/7);\n}", "\n/**\n* Secure Hash Algorithm (SHA1)\n* http://www.webtoolkit.info/\n**/\nexport function SHA1(msg) {\n function rotate_left(n,s) {\n var t4 = ( n<>>(32-s));\n return t4;\n };\n function lsb_hex(val) {\n var str='';\n var i;\n var vh;\n var vl;\n for( i=0; i<=6; i+=2 ) {\n vh = (val>>>(i*4+4))&0x0f;\n vl = (val>>>(i*4))&0x0f;\n str += vh.toString(16) + vl.toString(16);\n }\n return str;\n };\n function cvt_hex(val) {\n var str='';\n var i;\n var v;\n for( i=7; i>=0; i-- ) {\n v = (val>>>(i*4))&0x0f;\n str += v.toString(16);\n }\n return str;\n };\n function Utf8Encode(string) {\n string = string.replace(/\\r\\n/g,'\\n');\n var utftext = '';\n for (var n = 0; n < string.length; n++) {\n var c = string.charCodeAt(n);\n if (c < 128) {\n utftext += String.fromCharCode(c);\n }\n else if((c > 127) && (c < 2048)) {\n utftext += String.fromCharCode((c >> 6) | 192);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n else {\n utftext += String.fromCharCode((c >> 12) | 224);\n utftext += String.fromCharCode(((c >> 6) & 63) | 128);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n }\n return utftext;\n };\n var blockstart;\n var i, j;\n var W = new Array(80);\n var H0 = 0x67452301;\n var H1 = 0xEFCDAB89;\n var H2 = 0x98BADCFE;\n var H3 = 0x10325476;\n var H4 = 0xC3D2E1F0;\n var A, B, C, D, E;\n var temp;\n msg = Utf8Encode(msg);\n var msg_len = msg.length;\n var word_array = new Array();\n for( i=0; i>>29 );\n word_array.push( (msg_len<<3)&0x0ffffffff );\n for ( blockstart=0; blockstart n.id)].join(\":\"));\n }\n\n get node(): Node {\n return this.nodes[this.nodes.length-1];\n }\n\n get previous(): Node|null {\n if (this.nodes.length < 2) return null;\n return this.nodes[this.nodes.length-2];\n }\n\n get head(): Node {\n return this.nodes[0];\n }\n}\n\n", "import { RawNode, Node as INode, Bus as IBus, WalkFunc, ObserverFunc, WalkOptions } from \"../mod.ts\";\nimport { componentName, getComponent, inflateToComponent } from \"../components.ts\";\nimport { triggerHook, hasHook } from \"../hooks.ts\";\nimport { Node } from \"./mod.ts\";\n\nexport class Bus {\n nodes: Record;\n observers: ObserverFunc[];\n\n constructor() {\n this.nodes = {\"@root\": {\n ID: \"@root\",\n Name: \"@root\",\n Linked: {Children: [], Components: []},\n Attrs: {}\n }};\n this.observers = [];\n }\n\n changed(n: INode) {\n this.observers.forEach(cb => cb(n));\n }\n\n /* Bus interface */\n\n import(nodes: RawNode[]) {\n for (const n of nodes) {\n if (n.Value && getComponent(n.Name)) {\n n.Value = inflateToComponent(n.Name, n.Value);\n n.Rel = \"Components\"; // kludge\n }\n this.nodes[n.ID] = n;\n }\n for (const n of nodes) {\n // clear stored tmp nodes\n if (n.Parent === \"@tmp\") {\n delete this.nodes[n.ID];\n continue;\n }\n // clear nodes with no parent that aren't system\n if (!n.ID.startsWith(\"@\") && n.Parent === undefined) {\n delete this.nodes[n.ID];\n continue;\n }\n // clear nodes with non-existant parent\n if (n.Parent && !this.nodes[n.Parent]) {\n delete this.nodes[n.ID];\n continue;\n }\n const node = this.find(n.ID);\n if (node) {\n // check orphan\n if (node.parent && !node.parent.raw) {\n delete this.nodes[n.ID];\n continue;\n }\n // trigger attach\n triggerHook(node, \"onAttach\", node);\n }\n }\n }\n\n export(): RawNode[] {\n const nodes: RawNode[] = [];\n for (const n of Object.values(this.nodes)) {\n nodes.push(n);\n }\n return nodes;\n }\n\n make(name: string, value?: any): INode {\n let parent: INode|null = null;\n if (name.includes(\"/\")) {\n const parts = name.split(\"/\");\n parent = this.find(parts[0]);\n for (let i = 1; i < parts.length-1; i++) {\n if (parent === null) {\n throw \"unable to get root\";\n }\n \n let child = parent.find(parts[i]);\n if (!child) {\n child = this.make(parts.slice(0, i+1).join(\"/\"));\n }\n parent = child;\n }\n name = parts[parts.length-1];\n }\n const id = (name.startsWith(\"@\"))?name:uniqueId();\n this.nodes[id] = {\n ID: id,\n Name: name,\n Value: value,\n Linked: {Children: [], Components: []},\n Attrs: {}\n };\n const node = new Node(this, id);\n if (parent) {\n node.parent = parent;\n }\n return node;\n }\n\n // destroys node but not linked nodes\n destroy(n: INode) {\n const p = n.parent;\n if (p !== null && !p.isDestroyed) {\n let rel = n.raw.Rel || \"Children\";\n if (p.raw.Linked[rel].includes(n.id)) {\n p.raw.Linked[rel].splice(n.siblingIndex, 1);\n }\n }\n delete this.nodes[n.id];\n if (p) {\n this.changed(p);\n }\n }\n\n roots(): INode[] {\n return Object.values(this.nodes).filter(n => n.Parent === undefined).map(n => new Node(this, n.ID));\n }\n\n root(name?: string): INode|null {\n name = name || \"@root\"\n const node = this.roots().find(root => root.name === name);\n if (node === undefined) return null;\n return node;\n }\n\n find(path:string): INode|null {\n const byId = this.nodes[path];\n if (byId) return new Node(this, byId.ID);\n const parts = path.split(\"/\");\n if (parts.length === 1 && parts[0].startsWith(\"@\")) {\n // did not find @id by ID so return null\n return null;\n }\n let cur = this.root(parts[0]);\n if (!cur && this.nodes[parts[0]]) {\n cur = new Node(this, this.nodes[parts[0]].ID);\n }\n if (cur) {\n parts.shift();\n } else {\n cur = this.root(\"@root\"); \n }\n if (!cur) {\n return null;\n }\n const findChild = (n: INode, name: string): INode|undefined => {\n if (n.refTo) {\n n = n.refTo;\n }\n return n.children.find(child => child.name === name);\n }\n for (const name of parts) {\n const child = findChild(cur, name);\n if (!child) return null;\n cur = child;\n }\n return cur;\n }\n\n walk(fn: WalkFunc, opts?: WalkOptions) {\n for (const root of this.roots()) {\n if (root.walk(fn, opts)) return;\n }\n }\n\n observe(fn: ObserverFunc) {\n this.observers.push(fn);\n }\n}\n\nconst uniqueId = () => {\n const dateString = Date.now().toString(36);\n const randomness = Math.random().toString(36).substring(2);\n return dateString + randomness;\n};\n", "import { RawNode, Node as INode, Bus as IBus, WalkFunc, WalkOptions } from \"../mod.ts\";\nimport { componentName, getComponent, duplicate } from \"../components.ts\";\nimport { triggerHook, hasHook } from \"../hooks.ts\";\nimport { Bus } from \"./mod.ts\";\n\nexport class Node {\n _id: string;\n _bus: Bus;\n\n constructor(bus: Bus, id: string) {\n this._bus = bus;\n this._id = id;\n }\n\n [Symbol.for(\"Deno.customInspect\")]() {\n return `Node[${this.id}:${this.name}]`;\n }\n\n /* Node interface */\n\n get id(): string {\n return this._id;\n }\n\n get bus(): IBus {\n return this._bus;\n }\n\n get raw(): RawNode {\n const raw = this._bus.nodes[this.id];\n if (!raw) throw `use of non-existent node ${this.id}`;\n return raw;\n }\n\n\n get name(): string {\n if (this.refTo) {\n return this.refTo.name;\n }\n return this.raw.Name;\n }\n\n set name(val: string) {\n if (this.refTo) {\n this.refTo.name = val;\n } else {\n this.raw.Name = val;\n }\n this.changed();\n }\n\n get value(): any {\n if (this.refTo) {\n return this.refTo.value;\n }\n return this.raw.Value;\n }\n\n set value(val: string) {\n if (this.refTo) {\n this.refTo.value = val;\n } else {\n this.raw.Value = val;\n }\n this.changed();\n }\n\n get parent(): INode|null {\n if (!this.raw.Parent) return null;\n if (!this._bus.nodes[this.raw.Parent]) return null;\n return new Node(this._bus, this.raw.Parent);\n }\n\n set parent(n: INode|null) {\n const p = this.parent;\n if (p !== null) {\n p.raw.Linked.Children.splice(this.siblingIndex, 1);\n }\n if (n !== null) {\n this.raw.Parent = n.id;\n n.raw.Linked.Children.push(this.id);\n triggerHook(n, \"onAttach\", n);\n } else {\n this.raw.Parent = undefined;\n }\n this.changed();\n }\n\n get refTo(): INode|null {\n const id = this.raw.Attrs[\"refTo\"];\n if (!id) return null;\n const refTo = this._bus.nodes[id];\n if (!refTo) return null;\n return new Node(this._bus, id);\n }\n\n set refTo(n: INode|null) {\n if (!n) {\n delete this.raw.Attrs[\"refTo\"];\n this.changed();\n return;\n }\n this.raw.Attrs[\"refTo\"] = n.id;\n this.changed();\n }\n\n get siblingIndex(): number {\n const p = this.parent;\n if (p === null) return 0;\n let rel = this.raw.Rel || \"Children\";\n return p.raw.Linked[rel].findIndex(id => id === this.id);\n }\n\n set siblingIndex(i: number) {\n const p = this.parent;\n if (p === null) return;\n let rel = this.raw.Rel || \"Children\";\n p.raw.Linked[rel].splice(this.siblingIndex, 1);\n p.raw.Linked[rel].splice(i, 0, this.id);\n p.changed();\n }\n\n get prevSibling(): INode|null {\n const p = this.parent;\n if (p === null) return null;\n if (this.siblingIndex === 0) return null;\n let rel = this.raw.Rel || \"Children\";\n return p.getLinked(rel)[this.siblingIndex-1];\n }\n\n get nextSibling(): INode|null {\n const p = this.parent;\n if (p === null) return null;\n if (this.siblingIndex === p.children.length-1) return null;\n let rel = this.raw.Rel || \"Children\";\n return p.getLinked(rel)[this.siblingIndex+1];\n }\n\n get ancestors(): INode[] {\n const anc = [];\n let p = this.parent;\n while (p !== null) {\n anc.push(p);\n p = p.parent;\n }\n return anc;\n }\n\n get isDestroyed(): boolean {\n return !this._bus.nodes.hasOwnProperty(this.id);\n }\n\n get path(): string {\n let cur: INode|null = this;\n const path = [];\n while (cur) {\n path.unshift(cur.name);\n cur = cur.parent;\n }\n return path.join(\"/\");\n }\n\n get children(): INode[] {\n if (this.refTo) return this.refTo.children;\n let children: INode[] = [];\n if (this.raw.Linked.Children) {\n children = this.raw.Linked.Children.map(id => new Node(this._bus, id));\n };\n for (const com of this.components) {\n if (hasHook(com, \"objectChildren\")) {\n return triggerHook(com, \"objectChildren\", this, children);\n }\n }\n return children;\n }\n\n get childCount(): number {\n if (this.refTo) return this.refTo.childCount;\n for (const com of this.components) {\n if (hasHook(com, \"objectChildren\")) {\n return triggerHook(com, \"objectChildren\", this, null).length;\n }\n }\n if (!this.raw.Linked.Children) return 0;\n return this.raw.Linked.Children.length;\n }\n\n addChild(node: INode) {\n if (this.refTo) {\n this.refTo.addChild(node);\n return;\n }\n this.raw.Linked.Children.push(node.id);\n this.changed();\n } \n\n removeChild(node: INode) {\n if (this.refTo) {\n this.refTo.removeChild(node);\n return;\n }\n const children = this.raw.Linked.Children.filter(id => id === node.id);\n this.raw.Linked.Children = children;\n this.changed();\n }\n\n get fields(): INode[] {\n if (!this.raw.Linked.Fields) return [];\n return this.raw.Linked.Fields.map(id => new Node(this._bus, id));\n }\n\n get fieldCount(): number {\n if (!this.raw.Linked.Fields) return 0;\n return this.raw.Linked.Fields.length;\n }\n\n get components(): INode[] {\n if (!this.raw.Linked.Components) return [];\n return this.raw.Linked.Components.map(id => new Node(this._bus, id));\n }\n\n get componentCount(): number {\n if (!this.raw.Linked.Components) return 0;\n return this.raw.Linked.Components.length;\n }\n\n addComponent(obj: any) {\n const node = this.bus.make(componentName(obj), obj);\n node.raw.Parent = this.id;\n node.raw.Rel = \"Components\" // kludge\n this.raw.Linked.Components.push(node.id);\n triggerHook(node, \"onAttach\", node);\n this.changed();\n } \n\n removeComponent(obj: any) {\n let coms;\n if (obj.name && getComponent(obj)) {\n coms = this.components.filter(n => n.name === componentName(obj));\n } else {\n coms = this.components.filter(n => n.value === obj);\n }\n if (coms.length > 0) {\n coms[0].destroy();\n }\n this.changed();\n }\n \n hasComponent(type: any): boolean {\n const coms = this.components.filter(n => n.name === componentName(type));\n if (coms.length > 0) {\n return true;\n }\n return false;\n }\n\n getComponent(type: any): any|null {\n const coms = this.components.filter(n => n.name === componentName(type));\n if (coms.length > 0) {\n return coms[0].value;\n }\n return null;\n }\n // getComponentsInChildren\n // getComponentsInParents\n\n getLinked(rel: string): INode[] {\n if (!this.raw.Linked[rel]) return [];\n return this.raw.Linked[rel].map(id => new Node(this._bus, id));\n }\n\n addLinked(rel: string, node: INode) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n node.raw.Rel = rel; // kludge\n this.raw.Linked[rel].push(node.id);\n this.changed();\n } \n\n removeLinked(rel: string, node: INode) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n const linked = this.raw.Linked[rel].filter(id => id === node.id);\n this.raw.Linked[rel] = linked;\n this.changed();\n }\n\n moveLinked(rel: string, node: INode, idx: number) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n const oldIdx = this.raw.Linked[rel].findIndex(id => id === node.id);\n if (oldIdx === -1) return;\n const linked = this.raw.Linked[rel];\n linked.splice(idx, 0, linked.splice(oldIdx, 1)[0]);\n this.raw.Linked[rel] = linked;\n this.changed();\n }\n\n getAttr(name: string): string {\n return this.raw.Attrs[name] || \"\";\n }\n\n setAttr(name: string, value: string) {\n this.raw.Attrs[name] = value;\n this.changed();\n }\n\n find(path: string): INode|null {\n return this.bus.find([this.path, path].join(\"/\"));\n }\n\n walk(fn: WalkFunc, opts?: WalkOptions): boolean {\n opts = opts || {\n followRefs: false,\n includeComponents: false\n };\n if (fn(this)) {\n return true;\n }\n let children = this.children;\n if (this.refTo && opts.followRefs) {\n if (fn(this.refTo)) {\n return true;\n }\n children = this.refTo.children;\n }\n for (const child of children) {\n if (child.walk(fn, opts)) return true;\n }\n if (opts.includeComponents) {\n for (const com of this.components) {\n if (com.walk(fn, opts)) return true;\n }\n }\n return false;\n }\n\n destroy() {\n if (this.isDestroyed) return;\n if (this.refTo) {\n this._bus.destroy(this);\n return;\n }\n const nodes: INode[] = [];\n this.walk((n: INode): boolean => {\n nodes.push(n);\n return false;\n }, {\n followRefs: false,\n includeComponents: true\n });\n nodes.reverse().forEach(n => this._bus.destroy(n));\n }\n\n duplicate(): INode {\n const n = this._bus.make(this.name, duplicate(this.value));\n n.raw.Rel = this.raw.Rel;\n this.fields.map(f => f.duplicate()).forEach(f => {\n n.addLinked(\"Fields\", f);\n f.raw.Parent = n.raw.ID;\n });\n this.components.map(c => c.duplicate()).forEach(c => {\n n.addLinked(\"Components\", c);\n c.raw.Parent = n.raw.ID;\n });\n this.children.map(c => c.duplicate()).forEach(c => {\n n.addChild(c);\n c.raw.Parent = n.raw.ID;\n });\n return n;\n }\n\n changed() {\n this._bus.changed(this);\n }\n \n // duplicate?\n}\n", "import { FileStore } from \"../backend/mod.ts\";\nimport { Bus, Node, RawNode } from \"../model/mod.ts\";\nimport { Path } from \"./mod.ts\";\nimport * as module from \"../model/module/mod.ts\";\n\n\n/**\n * Workspace is a container for nodes and manages marshaling them using\n * the FileStore backend API. It also keeps track of what nodes have been\n * expanded and what node was last opened. It serializes as JSON with a\n * version indicator and will handle migrations of old versions to the \n * latest when loading. Saving is currently debounced here so this applies\n * to all backends. \n */\nexport class Workspace {\n fs: FileStore;\n bus: Bus;\n\n lastOpenedID: string;\n expanded: { [key: string]: { [key: string]: boolean } }; // [rootid][id]\n settings: {};\n\n constructor(fs: FileStore) {\n this.fs = fs;\n this.bus = new module.Bus();\n this.expanded = {};\n this.settings = {};\n\n this.writeDebounce = debounce(async (path, contents) => {\n try {\n await this.fs.writeFile(path, contents);\n console.log(\"Saved workspace.\");\n } catch (e: Error) {\n console.error(e);\n document.dispatchEvent(new CustomEvent(\"BackendError\"));\n }\n });\n }\n\n get rawNodes(): RawNode[] {\n return this.bus.export();\n }\n\n observe(fn: (n: Node) => void) {\n this.bus.observe(fn);\n }\n\n async save(immediate?: boolean) {\n const contents = JSON.stringify({\n version: 1,\n lastopen: this.lastOpenedID,\n expanded: this.expanded,\n nodes: this.rawNodes,\n settings: this.settings\n }, null, 2);\n if (immediate) {\n await this.fs.writeFile(\"workspace.json\", contents);\n } else {\n this.writeDebounce(\"workspace.json\", contents);\n }\n }\n\n async load() {\n let doc = JSON.parse(await this.fs.readFile(\"workspace.json\") || \"{}\");\n if (doc.nodes) {\n doc.nodes = doc.nodes.map(n => {\n // any node migrations:\n if (n.Name === \"treehouse.SearchNode\") {\n n.Name = \"treehouse.SmartNode\";\n }\n return n;\n })\n this.bus.import(doc.nodes);\n console.log(`Loaded ${doc.nodes.length} nodes.`);\n }\n if (doc.expanded) {\n // Only import the node keys that still exist\n // in the workspace.\n for (const n in doc.expanded) {\n for (const i in doc.expanded[n]) {\n if (this.bus.find(i)) {\n if (!this.expanded[n]) this.expanded[n] = {};\n this.expanded[n][i] = doc.expanded[n][i];\n }\n }\n }\n }\n if (doc.lastopen) {\n this.lastOpenedID = doc.lastopen;\n }\n if (doc.settings) {\n this.settings = Object.assign(this.settings, doc.settings);\n }\n }\n\n mainNode(): Node {\n let main = this.bus.find(\"@workspace\");\n if (!main) {\n console.info(\"Building missing workspace node.\")\n const root = this.bus.find(\"@root\");\n const ws = this.bus.make(\"@workspace\");\n ws.name = \"Workspace\";\n ws.parent = root;\n const cal = this.bus.make(\"@calendar\");\n cal.name = \"Calendar\";\n cal.parent = ws;\n const home = this.bus.make(\"Home\");\n home.parent = ws;\n main = ws;\n }\n return main;\n }\n\n find(path: string): Node | null {\n return this.bus.find(path)\n }\n\n new(name: string, value?: any): Node {\n return this.bus.make(name, value);\n }\n\n // TODO: take single Path\n getExpanded(head: Node, n: Node): boolean {\n if (!this.expanded[head.id]) {\n this.expanded[head.id] = {};\n }\n let expanded = this.expanded[head.id][n.id];\n if (expanded === undefined) {\n expanded = false;\n }\n return expanded;\n }\n\n // TODO: take single Path\n setExpanded(head: Node, n: Node, b: boolean) {\n if (!this.expanded[head.id]) {\n this.expanded[head.id] = {};\n }\n this.expanded[head.id][n.id] = b;\n this.save();\n }\n\n findAbove(path: Path): Path | null {\n if (path.node.id === path.head.id) {\n return null;\n }\n const p = path.clone();\n p.pop(); // pop to parent\n let prev = path.node.prevSibling;\n if (!prev) {\n // if not a field and parent has fields, return last field\n const fieldCount = path.previous.getLinked(\"Fields\").length;\n if (path.node.raw.Rel !== \"Fields\" && fieldCount > 0) {\n return p.append(path.previous.getLinked(\"Fields\")[fieldCount - 1]);\n }\n // if no prev sibling, and no fields, return parent\n return p;\n }\n const lastSubIfExpanded = (p: Path): Path => {\n const expanded = this.getExpanded(path.head, p.node);\n if (!expanded) {\n // if not expanded, return input path\n return p;\n }\n const fieldCount = p.node.getLinked(\"Fields\").length;\n if (p.node.childCount === 0 && fieldCount > 0) {\n const lastField = p.node.getLinked(\"Fields\")[fieldCount - 1];\n // if expanded, no children, has fields, return last field or its last sub if expanded\n return lastSubIfExpanded(p.append(lastField));\n }\n if (p.node.childCount === 0) {\n // expanded, no fields, no children\n return p;\n }\n const lastChild = p.node.children[p.node.childCount - 1];\n // return last child or its last sub if expanded\n return lastSubIfExpanded(p.append(lastChild));\n }\n // return prev sibling or its last child if expanded\n return lastSubIfExpanded(p.append(prev));\n }\n\n findBelow(path: Path): Path | null {\n // TODO: find a way to indicate pseudo \"new\" node for expanded leaf nodes\n const p = path.clone();\n if (this.getExpanded(path.head, path.node) && path.node.getLinked(\"Fields\").length > 0) {\n // if expanded and fields, return first field\n return p.append(path.node.getLinked(\"Fields\")[0]);\n }\n if (this.getExpanded(path.head, path.node) && path.node.childCount > 0) {\n // if expanded and children, return first child\n return p.append(path.node.children[0]);\n }\n const nextSiblingOrParentNextSibling = (p: Path): Path | null => {\n const next = p.node.nextSibling;\n if (next) {\n p.pop(); // pop to parent\n // if next sibling, return that\n return p.append(next);\n }\n const parent = p.previous;\n if (!parent) {\n // if no parent, return null\n return null;\n }\n if (p.node.raw.Rel === \"Fields\" && parent.childCount > 0) {\n p.pop(); // pop to parent\n // if field and parent has children, return first child\n return p.append(parent.children[0]);\n }\n p.pop(); // pop to parent\n // return parents next sibling or parents parents next sibling\n return nextSiblingOrParentNextSibling(p);\n }\n // return next sibling or parents next sibling\n return nextSiblingOrParentNextSibling(p);\n }\n\n}\n\n\nfunction debounce(func, timeout = 3000) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => { func.apply(this, args); }, timeout);\n };\n}\n", "export const Drawer = {\n view({ attrs, children }) {\n const open = attrs.open;\n return (\n
    \n {children}\n
    \n )\n }\n};\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n// deprecated\n\n@component\nexport class Page {\n markdown: string;\n\n constructor() {\n this.markdown = \"\";\n }\n}\n", "import { OutlineEditor } from \"./outline.tsx\";\nimport { NodeEditor } from \"./node/editor.tsx\";\nimport { Page } from \"../com/page.tsx\";\n\nexport const Panel = {\n view({ attrs }) {\n const path = attrs.path;\n const workbench = attrs.workbench;\n const node = path.node;\n\n const close = (e) => {\n workbench.executeCommand(\"close-panel\", {}, path);\n }\n const goBack = (e) => {\n let node = path.pop();\n // if there was a duplicate id in the path,\n // pop again\n if (node === path.node) {\n path.pop();\n }\n }\n const maximize = (e) => {\n // todo: should be a command\n workbench.panels = [path];\n workbench.context.path = path;\n }\n const editMarkdown = (e) => {\n node.getComponent(Page).markdown = e.target.value;\n node.changed();\n }\n function calcHeight(value = \"\") {\n let numberOfLineBreaks = (value.match(/\\n/g) || []).length;\n // min-height + lines x line-height + padding + border\n let newHeight = 20 + numberOfLineBreaks * 20;\n return newHeight;\n }\n let viewClass = \"\";\n if (node.getAttr(\"view\")) {\n viewClass = `${node.getAttr(\"view\")}-panel`\n }\n return
    \n
    \n {(path.length > 1) ?\n
    \n \n \n \n
    \n : null}\n\n
    \n {(node.parent && node.parent.id !== \"@root\") ? workbench.open(node.parent)}>{node.parent.name} :  }\n
    \n\n {(workbench.panels.length > 1) ?\n
    \n \n \n
    \n : null}\n
    \n\n
    \n
    workbench.showMenu(e, { node, path })} data-menu=\"node\">\n \n
    \n {(node.hasComponent(Page)) ?\n \n : null}\n \n
    \n
    \n }\n};\n", "import { bindingSymbols } from \"../action/keybinds.ts\";\n\nexport const KeyboardReference = {\n view({ attrs }) {\n const workbench = attrs.workbench;\n const shortcuts = {\n \"\": [\n \"pick-command\",\n ],\n \"Edit\": [\n \"cut\",\n \"copy\",\n \"copy-reference\",\n \"paste\",\n \"mark-done\",\n \"insert\",\n \"delete\",\n ],\n \"Navigate\": [\n \"expand\",\n \"collapse\",\n \"indent\",\n \"outdent\",\n \"move-up\",\n \"move-down\",\n \"prev\",\n \"next\",\n ],\n };\n\n const getBindingSymbols = (cmd) => {\n const binding = workbench.keybindings.getBinding(cmd.id);\n return binding ? bindingSymbols(binding.key).join(\" \").toUpperCase() : \"\";\n };\n\n return (\n
    \n

    Keyboard Shortcuts

    \n\n {Object.entries(shortcuts).map(([header, ids]) => {\n return (\n
    \n {(header.length !== 0) &&

    {header}

    }\n
    \n {ids.map(id => workbench.commands.commands[id]).map(cmd => (\n
    \n
    {getBindingSymbols(cmd)}
    \n
    {cmd.title}
    \n
    \n ))}\n
    \n
    \n );\n })}\n
    \n )\n }\n}", "import { Picker } from \"./picker.tsx\";\n\nexport const Search: m.Component = {\n\n view({ attrs: { input, workbench } }) {\n \n const onpick = (node) => {\n workbench.closeDialog();\n workbench.open(node);\n }\n const onchange = (state) => {\n if (state.input) {\n state.items = workbench.search(state.input);\n } else {\n state.items = [];\n } \n }\n\n return (\n
    \n \n
    \n \n \n
    \n }\n itemview={(result) =>
    {result.name}
    } />\n
    \n )\n }\n}\n", "import { Drawer as DrawerComponent } from \"./drawer.tsx\";\nimport { Panel as PanelComponent } from \"./panel.tsx\";\nimport { KeyboardReference } from './reference.tsx';\nimport { Search } from \"./search.tsx\";\nimport { Notice } from \"./notices.tsx\";\n\nexport const App: m.Component = {\n view ({attrs: {workbench}, state}) {\n state.open = (state.open === undefined) ? true : state.open;\n const toggle = (e) => {\n if (state.open) {\n state.open = false;\n } else {\n state.open = true;\n }\n }\n return (\n
    \n\n
    \n
    \n
    \n
    \n
    \n {state.open && workbench.workspace.bus.root().children.map(node => )}\n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    workbench.openToday()} style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", display: \"flex\", alignItems: \"center\"}}>\n \n \n {/* {(new Date()).getDate()} */}\n \n
    Today
    \n
    \n
    workbench.openQuickAdd()} style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", display: \"flex\", alignItems: \"center\"}}>\n \n
    Quick Add
    \n
    \n\n
    \n
    \n
    \n \n {\n if (e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift' || e.key === 'Meta') return;\n const input = e.target.getBoundingClientRect();\n workbench.showDialog(() => , false, {\n // TODO: make these not so hardcoded offsets\n left: `${input.left-33}px`,\n top: `${input.top-9}px`,\n width: `${input.width+33}px`\n });\n e.preventDefault();\n }} \n style={{\n border: \"0\", \n outline: \"0\", \n background: \"transparent\", \n paddingTop: \"3px\"\n }} />\n
    \n
    \n
    \n \n
    workbench.toggleDrawer()} data-menu=\"keyboard-reference\" data-align=\"right\" style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", marginTop: \"-2px\"}}>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n\n
    workbench.showMenu(e)} data-menu=\"settings\" data-align=\"right\" style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\"}}>\n \n
    \n
    \n\n
    \n {workbench.panels.map(path =>
    )}\n \n \n \n
    \n\n
    \n
    \n {\n const sidebarStyle = document.querySelector(\".sidebar\").style;\n if (sidebarStyle.display !== \"flex\") {\n sidebarStyle.display = \"flex\";\n } else {\n sidebarStyle.display = \"none\";\n }\n }} xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"feather feather-sidebar\">\n
    \n
    workbench.openToday()}>\n \n \n \n
    \n
    workbench.openQuickAdd()}>\n \n
    \n
    workbench.showDialog(() => , true, {top: \"25%\", bottom: \"100px\"})}>\n \n
    \n
    workbench.showMenu(e, undefined, {bottom: \"100px\", marginTop: \"auto\"})} data-menu=\"settings\">\n \n
    \n
    \n
    \n\n \n {workbench.popover && \n
    \n {workbench.popover.body()}\n
    \n }\n\n\n {\n if (workbench.dialog.explicitClose === true) {\n e.preventDefault();\n return;\n }\n // resets body\n workbench.dialog.body = () => null;\n }}\n onclick={e => {\n const dialog = e.target.closest(\"dialog\");\n const rect = dialog.getBoundingClientRect();\n const zeroClick = (e.clientX == 0 && e.clientY == 0); // clicking select dropdown gives 0,0\n if ((workbench.dialog.explicitClose !== true) && (\n e.clientX < rect.left ||\n e.clientX > rect.right ||\n e.clientY < rect.top ||\n e.clientY > rect.bottom\n ) && !zeroClick) {\n workbench.closeDialog();\n }\n }}>\n {workbench.dialog.body()}\n \n\n {\n // resets body\n workbench.menu.body = () => null;\n }}\n onclick={e => {\n const dialog = e.target.closest(\"dialog\");\n const rect = dialog.getBoundingClientRect();\n if (e.clientX < rect.left ||\n e.clientX > rect.right ||\n e.clientY < rect.top ||\n e.clientY > rect.bottom\n ) {\n workbench.closeMenu();\n }\n }}>\n {workbench.menu.body()}\n \n
    \n )\n }\n};\n\nconst NavNode: m.Component = {\n view ({attrs: {node, workbench, expanded, level}, state}) {\n state.expanded = (state.expanded === undefined) ? expanded : state.expanded;\n const expandable = (node.childCount > 0 && level < 3);\n const toggle = (e) => {\n if (!expandable) return;\n if (state.expanded) {\n state.expanded = false;\n } else {\n state.expanded = true;\n }\n e.stopPropagation();\n }\n const open = (e) => {\n const mobileNav = document.querySelector(\".mobile-nav\");\n if (mobileNav.offsetHeight) {\n document.querySelector(\".sidebar\").style.display = \"none\";\n }\n workbench.open(node);\n }\n return (\n
    \n
    \n \n {(expandable)\n ?(state.expanded)\n ? \n : \n :null}\n \n \n
    \n {node.name}\n
    \n
    \n {state.expanded && \n
    \n {node.children.filter(n => n.name !== \"\").map(n => )}\n
    \n }\n
    \n )\n }\n};\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Checkbox {\n checked: boolean;\n\n constructor() {\n this.checked = false;\n }\n\n beforeEditor() {\n return CheckboxEditor;\n }\n}\n\nconst CheckboxEditor = {\n view({attrs: {node}}) {\n const toggleCheckbox = (e) => {\n const checkbox = node.getComponent(Checkbox);\n checkbox.checked = !checkbox.checked;\n node.changed();\n }\n return \n }\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class TextField {\n constructor() {\n \n }\n\n handleIcon(): any {\n return \n }\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { Workbench, Context } from \"../workbench/mod.ts\";\n\n@component\nexport class Clock {\n startedAt?: Date;\n log: Date[][];\n showLog: boolean;\n\n component?: Node;\n object?: Node;\n\n constructor() {\n this.log = [];\n this.showLog = false;\n }\n\n onAttach(node: Node) {\n this.component = node;\n this.object = node.parent;\n }\n\n\n fromJSON(obj: any) {\n if (obj.startedAt) {\n this.startedAt = new Date(obj.startedAt);\n }\n this.log = (obj.log||[]).map(entry => [new Date(entry[0]), new Date(entry[1])]);\n this.showLog = obj.showLog;\n }\n\n toJSON(key: string): any {\n return {\n startedAt: this.startedAt, \n log: this.log,\n showLog: this.showLog\n };\n }\n\n localTotal(): number {\n return this.log.map(this.entryDuration).reduce((acc, val) => acc+val, 0);\n }\n\n grandTotal(): number {\n let total = this.localTotal();\n if (this.object) {\n this.object.children.forEach(child => {\n if (child.hasComponent(Clock)) {\n total += child.getComponent(Clock).grandTotal();\n }\n });\n }\n return total;\n }\n\n start() {\n if (this.startedAt) return;\n this.startedAt = new Date();\n }\n\n stop() {\n if (!this.startedAt) return;\n let now = new Date();\n let diff = now.getTime() - this.startedAt.getTime();\n if (diff/1000 >= 60) {\n // only log if more than a minute\n this.log.push([this.startedAt, now]);\n }\n this.startedAt = undefined;\n }\n\n formatEntry(entry: Date[]): string {\n if (entry.length !== 2) return \"\";\n return `${this.formatDate(entry[0])} - ${new Intl.DateTimeFormat(\"en\", {\n timeStyle: \"short\",\n }).format(entry[1])}`;\n }\n\n // duration in seconds\n entryDuration(entry: Date[]): number {\n const a = entry[0];\n const b = entry[1] || new Date();\n return (b.getTime() - a.getTime()) / 1000;\n }\n\n formatDate(d?: Date): string {\n if (!d) {\n return \"\";\n }\n return new Intl.DateTimeFormat(\"en\", {\n dateStyle: \"short\",\n timeStyle: \"short\",\n }).format(d);\n }\n\n formatDuration(seconds: number): string {\n let dur = seconds / 60;\n let min = Math.floor(dur % 60);\n dur = dur / 60;\n let hrs = Math.floor(dur % 60);\n return `${hrs}:${min.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping: false})}`;\n }\n\n afterEditor() {\n return ClockBadge;\n }\n\n belowEditor() {\n return ClockLog;\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"stop-clock\",\n title: \"Stop clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node.hasComponent(Clock)) {\n const clock = new Clock();\n ctx.node.addComponent(clock);\n }\n ctx.node.getComponent(Clock).stop();\n ctx.node.changed();\n }\n });\n workbench.keybindings.registerBinding({command: \"stop-clock\", key: \"meta+o\" });\n workbench.commands.registerCommand({\n id: \"start-clock\",\n title: \"Start clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node.hasComponent(Clock)) {\n const clock = new Clock();\n ctx.node.addComponent(clock);\n }\n ctx.node.getComponent(Clock).start();\n ctx.node.changed();\n }\n });\n workbench.keybindings.registerBinding({command: \"start-clock\", key: \"meta+i\" });\n workbench.commands.registerCommand({\n id: \"remove-clock\",\n title: \"Remove clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n if (ctx.node.hasComponent(Clock)) return true;\n return false;\n },\n action: (ctx: Context) => {\n ctx.node.removeComponent(Clock);\n }\n });\n }\n}\n\nconst ClockBadge = {\n view({attrs: {node}}) {\n const clock = node.getComponent(Clock);\n const toggleLog = () => {\n clock.showLog = !clock.showLog;\n node.changed();\n }\n if (!clock.showLog && clock.startedAt) {\n return (\n
    \n \n
    {clock.formatDuration(clock.entryDuration([clock.startedAt]))}
    \n
    \n )\n }\n return (\n
    \n \n
    {clock.formatDuration(clock.grandTotal())}
    \n
    \n )\n }\n}\n\nconst ClockLog = {\n view({attrs: {node}}) {\n const clock = node.getComponent(Clock);\n if (!clock.showLog) return;\n return (\n
    \n
    \n
    \n {clock.startedAt &&\n
    \n
    {clock.formatDate(clock.startedAt)} - ...
    \n
    \n \n
    {clock.formatDuration(clock.entryDuration([clock.startedAt]))}
    \n
    \n
    \n }\n {clock.log.toReversed().map(entry => (\n
    \n
    {clock.formatEntry(entry)}
    \n
    \n \n
    {clock.formatDuration(clock.entryDuration(entry))}
    \n
    \n
    \n ))}\n
    \n
    \n )\n }\n}\n", "import {RawNode} from \"../model/mod.ts\";\n\n\nexport class BrowserBackend {\n auth: null;\n index: SearchIndex;\n files: FileStore;\n\n constructor() {\n this.auth = null;\n this.files = new FileStore();\n if (window.MiniSearch) {\n this.index = new SearchIndex_MiniSearch();\n } else {\n this.index = new SearchIndex_Dumb();\n }\n }\n}\n\nexport class SearchIndex_MiniSearch {\n indexer: any; // MiniSearch\n\n constructor() {\n this.indexer = new MiniSearch({\n idField: \"ID\",\n fields: ['ID', 'Name', 'Value', 'Value.markdown'], // fields to index for full-text search\n storeFields: ['ID'], // fields to return with search results\n extractField: (document, fieldName) => {\n return fieldName.split('.').reduce((doc, key) => doc && doc[key], document);\n }\n });\n }\n\n index(node: RawNode) {\n if (this.indexer.has(node.ID)) {\n this.indexer.replace(node); \n } else {\n this.indexer.add(node);\n }\n }\n\n remove(id: string) {\n try {\n this.indexer.discard(id);\n } catch {}\n }\n\n search(query: string): string[] {\n const suggested = this.indexer.autoSuggest(query);\n if (suggested.length === 0) return [];\n return this.indexer.search(suggested[0].suggestion, {\n prefix: true,\n combineWith: 'AND',\n }).map(doc => doc.ID);\n }\n}\n\n\nexport class SearchIndex_Dumb {\n nodes: Record;\n\n constructor() {\n this.nodes = {};\n }\n\n index(node: RawNode) {\n this.nodes[node.ID] = node.Name;\n }\n\n remove(id: string) {\n delete this.nodes[id];\n }\n\n search(query: string): string[] {\n const results: string[] = [];\n for (const id in this.nodes) {\n if (this.nodes[id].includes(query)) {\n results.push(id);\n }\n }\n return results;\n }\n}\n\n\n\nexport class FileStore {\n async readFile(path: string): string|null {\n return localStorage.getItem(`treehouse:${path}`);\n }\n\n async writeFile(path: string, contents: string) {\n localStorage.setItem(`treehouse:${path}`, contents);\n }\n}", "\nimport { Authenticator, SearchIndex, FileStore } from \"./mod.ts\";\nimport { BrowserBackend } from \"./browser.ts\";\nimport { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.mjs';\n\nexport interface Options {\n domain: string; // domain used with username subdomain to produce repo name\n checkDomain: boolean; // redirect to user domain if it is not current location\n authFallbackURL?: string; // URL to redirect to if auth fails\n privateRepo?: boolean; // if the user workspace repo should be created private\n}\n\nexport class GitHubBackend {\n auth: Authenticator;\n\n index: SearchIndex;\n files: FileStore;\n\n loginURL: string;\n clientFactory: any; // Octokit class\n client: any; // Octokit instance\n user: User|null;\n shas: Record; // path => sha\n \n opts: Options;\n\n constructor(loginURL: string, octokit: any, opts?: Options) {\n this.loginURL = loginURL;\n this.clientFactory = octokit;\n this.auth = this;\n this.shas = {};\n\n this.opts = Object.assign({\n domain: \"treehouse.sh\",\n checkDomain: false,\n privateRepo: false\n }, opts || {});\n\n const localbackend = new BrowserBackend();\n this.index = localbackend.index;\n this.files = localbackend.files;\n\n \n }\n\n get repoName(): string {\n return `${this.user?.userID().toLowerCase()}.${this.opts.domain}`;\n }\n\n async initialize() {\n // delegate authorize callback to loginURL\n const code = new URL(location.href).searchParams.get(\"code\");\n if (code) {\n try {\n // remove ?code=... from URL\n const querystring = location.search.replace(/\\bcode=\\w+/, \"\").replace(/\\?$/, \"\");\n history.pushState({}, \"\", `${location.pathname}${querystring}`);\n \n const response = await fetch(this.loginURL, {\n method: \"POST\",\n mode: \"cors\",\n headers: {\"content-type\": \"application/json\"},\n body: JSON.stringify({ code })\n });\n \n const result = await response.json();\n if (result.error) {\n throw result.error;\n }\n \n localStorage.setItem(\"treehouse:gh-token\", result.token);\n \n } catch (e: Error) {\n this.reset();\n console.error(e);\n return;\n }\n }\n\n // capture access token if provided directly\n const token = new URL(location.href).searchParams.get(\"access_token\");\n if (token) {\n try {\n // remove ?access_token=... from URL\n const querystring = location.search.replace(/\\baccess_token=\\w+/, \"\").replace(/\\?$/, \"\");\n history.pushState({}, \"\", `${location.pathname}${querystring}`);\n \n localStorage.setItem(\"treehouse:gh-token\", token);\n } catch (e: Error) {\n this.reset();\n console.error(e);\n return;\n }\n }\n\n try {\n await this.authenticate();\n if (!this.user) {\n throw \"authentication failed\";\n }\n } catch (e: Error) {\n console.error(e);\n if (this.opts.authFallbackURL) {\n location.href = this.opts.authFallbackURL;\n }\n return;\n }\n \n // check domain if set to\n if (this.opts.checkDomain && this.repoName !== location.hostname.toLowerCase()) {\n location.hostname = this.repoName;\n return;\n }\n\n // check if repo exists\n try {\n await this.client.rest.repos.get({\n owner: this.user.userID(), \n repo: this.repoName\n });\n } catch (e: Error) {\n if (e.message !== \"Not Found\") {\n throw e;\n }\n // create if not\n console.log(\"Creating repository...\");\n const resp = await this.client.rest.repos.createForAuthenticatedUser({name: this.repoName, private: this.opts.privateRepo});\n if (resp.status !== 201) {\n console.error(resp);\n return;\n }\n }\n\n // check for workspace.json now\n try {\n await this.client.rest.repos.getContent({\n owner: this.user.userID(), \n repo: this.repoName,\n path: \"workspace.json\"\n });\n } catch (e: Error) {\n if (e.name !== \"HttpError\") {\n throw e;\n }\n // create empty if not\n console.log(\"Creating workspace.json...\");\n const resp = await this.client.rest.repos.createOrUpdateFileContents({\n owner: this.user.userID(), \n repo: this.repoName,\n path: \"workspace.json\", \n message: \"initial commit\", \n content: btoa(JSON.stringify([]))\n });\n if (resp.status !== 201) {\n console.error(resp);\n return;\n }\n }\n \n this.files = this;\n\n \n \n const sessID = uniqueID();\n await this.readFile(\"treehouse.lock\");\n await this.writeFile(\"treehouse.lock\", sessID);\n const lockCheck = setInterval(async () => {\n const lockFile = await this.readFile(\"treehouse.lock\");\n if (lockFile !== sessID) {\n clearInterval(lockCheck);\n document.dispatchEvent(new CustomEvent(\"BackendError\"));\n console.warn(\"lock stolen!\");\n }\n }, 5000);\n }\n\n async loadExtensions() {\n try {\n const dirCheck = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: \"\",\n random: Math.random().toString(36).substring(2)\n });\n if (dirCheck.data.find(o => o.type === \"dir\" && o.name === \"ext\")) {\n const dirList = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: \"ext\",\n random: Math.random().toString(36).substring(2)\n });\n for (const file of dirList.data) {\n if (file.name.endsWith(\".css\")) {\n // Load CSS \n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: file.path,\n random: Math.random().toString(36).substring(2)\n });\n const css = document.createElement(\"link\");\n css.setAttribute(\"href\", `data:text/css;charset=utf-8;base64,${resp.data.content}`);\n css.setAttribute(\"rel\", \"stylesheet\");\n css.setAttribute(\"type\", \"text/css\");\n document.head.appendChild(css);\n } else if (file.name.endsWith(\".js\")) {\n // Load JavaScript\n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: file.path,\n random: Math.random().toString(36).substring(2)\n });\n const js = document.createElement(\"script\");\n js.setAttribute(\"type\", \"module\");\n js.setAttribute(\"src\", `data:text/javascript;charset=utf-8;base64,${resp.data.content}`);\n document.head.appendChild(js);\n }\n }\n }\n \n } catch (e: Error) {}\n \n }\n \n async authenticate() {\n const token = localStorage.getItem(\"treehouse:gh-token\");\n if (!token) {\n return;\n }\n\n this.client = new this.clientFactory({auth: token});\n const resp = await this.client.rest.users.getAuthenticated();\n if (!resp || resp.error) {\n return;\n }\n this.user = new User(resp.data);\n\n if(m)m.redraw();\n }\n\n currentUser(): User|null {\n return this.user;\n }\n\n login() {\n location.assign(this.loginURL);\n }\n\n reset() {\n localStorage.removeItem(\"treehouse:gh-token\");\n this.user = null;\n\n if(m)m.redraw();\n }\n \n logout() {\n this.reset();\n location.reload();\n }\n\n\n async readFile(path: string): string|null {\n try {\n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: path,\n random: Math.random().toString(36).substring(2)\n });\n this.shas[path] = resp.data.sha;\n return decode(resp.data.content);\n } catch (e: Error) {\n if (e.name !== \"HttpError\") {\n console.error(e);\n }\n return null;\n }\n }\n\n async writeFile(path: string, contents: string) {\n const resp = await this.client.rest.repos.createOrUpdateFileContents({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: path, \n message: \"autosave\", \n content: encode(contents), \n sha: this.shas[path]\n });\n this.shas[path] = resp.data.content.sha;\n }\n}\n\nexport class User {\n user: any; // github user object\n\n constructor(user: any) {\n this.user = user;\n }\n\n userID(): string {\n return this.user.login;\n }\n\n displayName(): string {\n return this.user.name;\n }\n\n avatarURL(): string {\n return this.user.avatar_url;\n }\n}\n\nfunction uniqueID() {\n const dateString = Date.now().toString(36);\n const randomness = Math.random().toString(36).substring(2);\n return dateString + randomness;\n};", "/**\n * A configurable, embeddable frontend for a graph/outline based note-taking tool.\n * \n * Treehouse can be embedded on a page and given a backend for a fully functional\n * SPA. The backend adapter provides hooks to integrate with various backends.\n * \n * Typical usage involves including resource dependencies on the page then running:\n * \n * ```ts\n * import {setup, BrowserBackend} from \"https://treehouse.sh/lib/treehouse.min.js\";\n * setup(document, document.body, new BrowserBackend());\n * ```\n * \n * In this case using the built-in BrowserBackend to store state in localStorage.\n * For more information see the [Quickstart Guide](https://treehouse.sh/docs/quickstart/).\n * \n * @module\n */\nimport { Path, Workbench } from \"./workbench/mod.ts\";\nimport { App } from \"./ui/app.tsx\";\nimport { Backend } from \"./backend/mod.ts\";\nimport { SmartNode } from \"./com/smartnode.tsx\";\nimport { Checkbox } from \"./com/checkbox.tsx\";\nimport { Page } from \"./com/page.tsx\";\nimport { TextField } from \"./com/textfield.tsx\";\nimport { Clock } from \"./com/clock.tsx\";\nimport { Tag } from \"./com/tag.tsx\";\nimport { Template } from \"./com/template.tsx\";\nimport { Document } from \"./com/document.tsx\";\nimport { objectManaged } from \"./model/hooks.ts\";\n\nexport { BrowserBackend, SearchIndex_MiniSearch } from \"./backend/browser.ts\";\nexport { GitHubBackend } from \"./backend/github.ts\";\n\n\n/**\n * setup initializes and mounts a workbench UI with a given backend adapter to a document.\n * More specifically, first it initializes the given backend, then creates and initializes\n * a Workbench instance with that backend, then it mounts the App component to the given\n * target element. It will also add some event listeners to the document and currently\n * this is where it registers all the built-in commands and their keybindings, as well\n * as menus. \n */\nexport async function setup(document: Document, target: HTMLElement, backend: Backend) {\n if (backend.initialize) {\n await backend.initialize();\n }\n\n const workbench = new Workbench(backend);\n window.workbench = workbench;\n\n await workbench.initialize();\n\n // TODO: better way to initialize components? \n [\n Clock,\n TextField,\n Page,\n Document,\n Checkbox,\n Tag,\n Template,\n SmartNode,\n ].forEach(com => {\n if (com.initialize) {\n com.initialize(workbench);\n }\n });\n\n\n // pretty specific to github backend right now\n document.addEventListener(\"BackendError\", () => {\n workbench.showNotice(\"lockstolen\", () => {\n location.reload();\n });\n });\n\n workbench.commands.registerCommand({\n id: \"cut\",\n title: \"Cut\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n \n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"cut\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"cut\", key: \"meta+x\" });\n\n workbench.commands.registerCommand({\n id: \"copy\",\n title: \"Copy\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n\n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"copy\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"copy\", key: \"meta+c\" });\n\n workbench.commands.registerCommand({\n id: \"copy-reference\",\n title: \"Copy as Reference\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n \n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"copyref\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"copy-reference\", key: \"shift+ctrl+c\" });\n\n workbench.commands.registerCommand({\n id: \"paste\",\n title: \"Paste\",\n when: (ctx: Context) => {\n if (workbench.clipboard) {\n return true;\n }\n return false;\n },\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n switch (workbench.clipboard.op) {\n case \"copy\":\n workbench.clipboard.node = workbench.clipboard.node.duplicate();\n break;\n case \"copyref\":\n const ref = workbench.workspace.new(\"\");\n ref.refTo = workbench.clipboard.node;\n workbench.clipboard.node = ref;\n break;\n }\n if (workbench.clipboard.node.raw.Rel === \"Fields\") {\n workbench.clipboard.node.raw.Parent = ctx.node.parent.id;\n ctx.node.parent.addLinked(\"Fields\", workbench.clipboard.node);\n } else {\n workbench.clipboard.node.parent = ctx.node.parent;\n workbench.clipboard.node.siblingIndex = ctx.node.siblingIndex; \n }\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(workbench.clipboard.node));\n }\n });\n workbench.keybindings.registerBinding({ command: \"paste\", key: \"meta+v\" });\n\n\n\n workbench.commands.registerCommand({\n id: \"view-list\",\n title: \"View as List\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"list\");\n }\n });\n\n workbench.commands.registerCommand({\n id: \"view-table\",\n title: \"View as Table\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"table\");\n ctx.node.children.forEach(child => {\n workbench.workspace.setExpanded(ctx.path.head, child, false);\n });\n }\n });\n\n workbench.commands.registerCommand({\n id: \"view-tabs\",\n title: \"View as Tabs\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"tabs\");\n }\n });\n\n\n workbench.commands.registerCommand({\n id: \"add-checkbox\",\n title: \"Add checkbox\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const checkbox = new Checkbox();\n ctx.node.addComponent(checkbox);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"remove-checkbox\",\n title: \"Remove checkbox\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n if (ctx.node.hasComponent(Checkbox)) return true;\n return false;\n },\n action: (ctx: Context) => {\n ctx.node.removeComponent(Checkbox);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"create-field\",\n title: \"Create Field\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.childCount > 0) return;\n if (ctx.node.componentCount > 0) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const path = ctx.path.clone();\n path.pop(); // drop node\n const field = workbench.workspace.new(ctx.node.name, \"\");\n field.raw.Parent = ctx.node.parent.id;\n const text = new TextField();\n field.addComponent(text);\n ctx.node.parent.addLinked(\"Fields\", field);\n path.push(field);\n ctx.node.destroy();\n m.redraw.sync();\n workbench.focus(path);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"mark-done\",\n title: \"Mark Done\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.hasComponent(Checkbox)) {\n const checkbox = ctx.node.getComponent(Checkbox);\n if (!checkbox.checked) {\n checkbox.checked = true;\n ctx.node.changed();\n } else {\n ctx.node.removeComponent(Checkbox);\n }\n } else {\n const checkbox = new Checkbox();\n ctx.node.addComponent(checkbox);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"mark-done\", key: \"meta+enter\" });\n\n\n\n workbench.commands.registerCommand({\n id: \"expand\",\n title: \"Expand\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n m.redraw();\n }\n });\n workbench.keybindings.registerBinding({ command: \"expand\", key: \"meta+arrowdown\" });\n workbench.commands.registerCommand({\n id: \"collapse\",\n title: \"Collapse\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, false);\n m.redraw();\n }\n });\n workbench.keybindings.registerBinding({ command: \"collapse\", key: \"meta+arrowup\" });\n workbench.commands.registerCommand({\n id: \"indent\",\n title: \"Indent\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const node = ctx.node; // redraw seems to unset ctx.node\n const path = ctx.path.clone();\n let prev = node.prevSibling;\n while (prev && objectManaged(prev)) {\n prev = prev.prevSibling;\n if (!prev) return;\n }\n if (prev !== null) {\n path.pop(); // drop node\n path.push(prev);\n node.parent = prev;\n path.push(node);\n workbench.workspace.setExpanded(ctx.path.head, prev, true);\n m.redraw.sync();\n workbench.focus(path);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"indent\", key: \"tab\" });\n workbench.commands.registerCommand({\n id: \"outdent\",\n title: \"Outdent\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = ctx.path.previous;\n const path = ctx.path.clone();\n if (parent !== null && parent.id !== \"@root\" && parent.id !== workbench.workspace.lastOpenedID) {\n path.pop(); // drop node\n path.pop(); // drop parent\n node.parent = parent.parent;\n path.push(node);\n node.siblingIndex = parent.siblingIndex + 1;\n if (parent.childCount === 0 && parent.getLinked(\"Fields\").length === 0) {\n workbench.workspace.setExpanded(ctx.path.head, parent, false);\n }\n m.redraw.sync();\n workbench.focus(path);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"outdent\", key: \"shift+tab\" });\n workbench.commands.registerCommand({\n id: \"move-up\",\n title: \"Move Up\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = node.parent;\n if (parent !== null && parent.id !== \"@root\") {\n const children = parent.childCount;\n if (node.siblingIndex === 0) {\n if (!parent.prevSibling) {\n return;\n }\n const p = ctx.path.clone();\n p.pop(); // drop node\n p.pop(); // drop parent\n let parentSib = parent.prevSibling;\n while (parentSib && objectManaged(parentSib)) {\n parentSib = parentSib.prevSibling;\n if (!parentSib) return;\n }\n p.push(parentSib);\n p.push(node);\n node.parent = parentSib;\n node.siblingIndex = parentSib.childCount - 1;\n workbench.workspace.setExpanded(ctx.path.head, parentSib, true);\n m.redraw.sync();\n workbench.focus(p);\n } else {\n if (children === 1) {\n return;\n }\n node.siblingIndex = node.siblingIndex - 1;\n m.redraw.sync();\n }\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"move-up\", key: \"shift+meta+arrowup\" });\n workbench.commands.registerCommand({\n id: \"move-down\",\n title: \"Move Down\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = node.parent;\n if (parent !== null && parent.id !== \"@root\") {\n const children = parent.childCount;\n // if last child\n if (node.siblingIndex === children - 1) {\n if (!parent.nextSibling) {\n return;\n }\n const p = ctx.path.clone();\n p.pop(); // drop node\n p.pop(); // drop parent\n let parentSib = parent.nextSibling;\n while (parentSib && objectManaged(parentSib)) {\n parentSib = parentSib.nextSibling;\n if (!parentSib) return;\n }\n p.push(parentSib);\n p.push(node);\n node.parent = parentSib;\n node.siblingIndex = 0;\n workbench.workspace.setExpanded(ctx.path.head, parentSib, true);\n m.redraw.sync();\n workbench.focus(p);\n } else {\n if (children === 1) {\n return;\n }\n node.siblingIndex = node.siblingIndex + 1;\n m.redraw.sync();\n }\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"move-down\", key: \"shift+meta+arrowdown\" });\n workbench.commands.registerCommand({\n id: \"insert-child\",\n title: \"Insert Child\",\n action: (ctx: Context, name: string = \"\", siblingIndex?: number) => {\n if (!ctx.node) return;\n if (objectManaged(ctx.node)) return;\n const node = workbench.workspace.new(name);\n node.parent = ctx.node;\n if (siblingIndex !== undefined) {\n node.siblingIndex = siblingIndex;\n }\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n m.redraw.sync();\n workbench.focus(ctx.path.append(node), name.length);\n }\n });\n workbench.commands.registerCommand({\n id: \"insert-before\",\n title: \"Insert Before\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(\"\");\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.commands.registerCommand({\n id: \"insert\",\n title: \"Insert Node\",\n action: (ctx: Context, name: string = \"\") => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(name);\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex + 1;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.keybindings.registerBinding({ command: \"insert\", key: \"shift+enter\" });\n workbench.commands.registerCommand({\n id: \"create-reference\",\n title: \"Create Reference\",\n action: (ctx: Context) => {\n // TODO: prevent creating reference to reference\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(\"\");\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex + 1;\n node.refTo = ctx.node;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.commands.registerCommand({\n id: \"delete\",\n title: \"Delete Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.id.startsWith(\"@\")) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return; // should probably provide feedback or disable delete\n const above = workbench.workspace.findAbove(ctx.path);\n ctx.node.destroy();\n m.redraw.sync();\n if (above) {\n let pos = 0;\n if (ctx.event && ctx.event.key === \"Backspace\") {\n if (above.node.value) {\n pos = above.node.value.length;\n } else {\n pos = above.node.name.length;\n }\n }\n if (above.node.childCount === 0) {\n // TODO: use subCount\n workbench.workspace.setExpanded(ctx.path.head, above.node, false);\n }\n workbench.focus(above, pos);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"delete\", key: \"shift+meta+backspace\" });\n workbench.commands.registerCommand({\n id: \"prev\",\n title: \"Previous Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const above = workbench.workspace.findAbove(ctx.path);\n if (above) {\n workbench.focus(above);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"prev\", key: \"arrowup\" });\n workbench.commands.registerCommand({\n id: \"next\",\n title: \"Next Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const below = workbench.workspace.findBelow(ctx.path);\n if (below) {\n workbench.focus(below);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"next\", key: \"arrowdown\" });\n workbench.commands.registerCommand({\n id: \"pick-command\",\n title: \"Command Palette\",\n hidden: true,\n when: (ctx: Context) => {\n if (workbench.isDialogOpen()) return false;\n return true;\n },\n action: (ctx: Context) => {\n let node = ctx.node;\n let path = ctx.path;\n let posBelow = false;\n if (!node) {\n // no node is selected, use panel node\n node = ctx.path.head;\n path = new Path(ctx.path.head, ctx.path.name);\n posBelow = true;\n }\n const trigger = workbench.getInput(path);\n const rect = trigger.getBoundingClientRect();\n let x = document.body.scrollLeft + rect.x + (trigger.selectionStart * 10) + 20;\n let y = document.body.scrollTop + rect.y - 8;\n if (trigger.coordsAtCursor) {\n x = trigger.coordsAtCursor.left-17;\n y = trigger.coordsAtCursor.top-16;\n }\n if (posBelow) {\n x = document.body.scrollLeft + rect.x;\n y = document.body.scrollTop + rect.y + rect.height;\n }\n workbench.showPalette(x, y, workbench.newContext({ node }));\n }\n });\n workbench.keybindings.registerBinding({ command: \"pick-command\", key: \"meta+k\" });\n workbench.commands.registerCommand({\n id: \"new-panel\",\n title: \"Open in New Panel\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.openNewPanel(ctx.node);\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"close-panel\",\n title: \"Close Panel\",\n action: (ctx: Context, panel?: Path) => {\n workbench.closePanel(panel || ctx.path);\n workbench.context.path = workbench.mainPanel;\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"zoom\",\n title: \"Open\",\n action: (ctx: Context) => {\n workbench.workspace.lastOpenedID = ctx.node.id;\n workbench.workspace.save();\n workbench.context.path = ctx.path.append(ctx.node);\n workbench.panels[0] = workbench.context.path;\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"generate-random\",\n hidden: true,\n title: \"Generate Random Children\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n [...Array(100)].forEach(() => {\n const node = workbench.workspace.new(generateName(8));\n node.parent = ctx.node;\n });\n }\n });\n\n\n\n workbench.menus.registerMenu(\"node\", [\n { command: \"zoom\" },\n { command: \"new-panel\" },\n { command: \"cut\" },\n { command: \"copy\" },\n { command: \"paste\" },\n { command: \"indent\" },\n { command: \"outdent\" },\n { command: \"move-up\" },\n { command: \"move-down\" },\n { command: \"delete\" },\n // {command: \"add-checkbox\"}, \n // {command: \"remove-checkbox\"},\n // {command: \"mark-done\"},\n // {command: \"add-page\"},\n // {command: \"remove-page\"},\n // {command: \"generate-random\"},\n // {command: \"create-reference\"},\n ]);\n\n workbench.menus.registerMenu(\"settings\", [\n { title: () => `${workbench.backend.auth?.currentUser()?.userID()} @ GitHub`, disabled: true, when: () => workbench.authenticated() },\n {\n title: () => \"Login with GitHub\", when: () => !workbench.authenticated(), onclick: () => {\n if (!localStorage.getItem(\"github\")) {\n workbench.showNotice(\"github\", () => {\n workbench.backend.auth.login()\n })\n } else {\n workbench.backend.auth.login()\n }\n }\n },\n {\n title: () => \"Reset Demo\", when: () => !workbench.authenticated(), onclick: () => {\n localStorage.clear();\n location.reload();\n }\n },\n { title: () => \"Settings\", onclick: () => workbench.showSettings() },\n { title: () => \"Documentation\", onclick: () => window.open(\"https://treehouse.sh/docs/user\", \"_blank\") },\n { title: () => \"Submit Issue\", onclick: () => window.open(\"https://github.com/treehousedev/treehouse/issues\", \"_blank\") },\n { title: () => \"Logout\", when: () => workbench.authenticated(), onclick: () => workbench.backend.auth.logout() },\n ]);\n\n document.addEventListener(\"keydown\", (e) => {\n const binding = workbench.keybindings.evaluateEvent(e);\n if (binding && workbench.canExecuteCommand(binding.command, workbench.context)) {\n workbench.executeCommand(binding.command, workbench.context);\n e.stopPropagation();\n e.preventDefault();\n return;\n }\n });\n\n\n m.mount(target, { view: () => m(App, { workbench }) });\n}\n\n\n\nfunction generateName(length = 10) {\n const random = (min: any, max: any) => {\n return Math.round(Math.random() * (max - min) + min)\n };\n const word = () => {\n const words = [\n 'got',\n 'ability',\n 'shop',\n 'recall',\n 'fruit',\n 'easy',\n 'dirty',\n 'giant',\n 'shaking',\n 'ground',\n 'weather',\n 'lesson',\n 'almost',\n 'square',\n 'forward',\n 'bend',\n 'cold',\n 'broken',\n 'distant',\n 'adjective'\n ];\n return words[random(0, words.length - 1)];\n };\n const words = (length) => (\n [...Array(length)]\n .map((_, i) => word())\n .join(' ')\n .trim()\n );\n return words(random(2, length))\n}\n"], - "mappings": "gQACA,IAAMA,GAAS,UAAU,UAAU,YAAY,EAAE,QAAQ,KAAK,IAAM,GAE7D,SAASC,EAAeC,EAAwB,CACrD,GAAI,CAACA,EAAK,MAAO,CAAC,EAClB,IAAMC,EAAU,CACd,UAAa,SACb,MAAS,SACT,KAAQ,SACR,IAAO,SACP,KAAQ,SACR,QAAW,SACX,UAAa,SACb,UAAa,SACb,WAAc,SACd,MAAS,QACX,EAEA,OADaD,EAAI,YAAY,EAAE,MAAM,GAAG,EAC5B,IAAIE,EAAsB,EAAE,IAAIC,GAAM,OAAO,KAAKF,CAAO,EAAE,SAASE,CAAC,EAAKF,EAAQE,CAAC,EAAIA,CAAC,CACtG,CAhBgBC,EAAAL,EAAA,kBAoBhB,SAASG,GAAuBF,EAAqB,CACnD,MAAQ,CAACF,IAASE,IAAQ,OAAU,OAAQA,CAC9C,CAFSI,EAAAF,GAAA,0BAWF,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H,EAAO,EAAGD,CAAM,CAAC,CAChC,CApCSD,EAAAJ,GAAA", - "names": ["isMac", "bindingSymbols", "key", "symbols", "filterKeyForNonMacMeta", "k", "__name", "KeyBindings", "binding", "commandId", "b", "event", "bindings", "modifiers", "checkMod", "hasMod", "modState", "CommandRegistry", "cmd", "id", "rest", "resolve", "ret", "__name", "MenuRegistry", "id", "items", "__name", "isDisabled", "workbench", "item", "cmd", "ctx", "__name", "Menu", "x", "y", "items", "align", "commands", "onclick", "e", "i", "title", "binding", "c", "bindingSymbols", "Picker", "state", "dom", "items", "attrs", "onkeydown", "__name", "e", "mod", "a", "b", "oninput", "item", "idx", "CommandPalette", "workbench", "ctx", "getTitle", "__name", "cmd", "t", "sort", "a", "b", "onpick", "onchange", "state", "cmds", "getBindingSymbols", "binding", "bindingSymbols", "Picker", "onkeydown", "oninput", "hasHook", "node", "hook", "__name", "triggerHook", "args", "objectHas", "obj", "com", "objectCall", "componentsWith", "ret", "objectManaged", "registry", "component", "target", "componentName", "__name", "getComponent", "com", "inflateToComponent", "obj", "o", "duplicate", "src", "dst", "Document", "node", "collapsed", "key", "workbench", "ctx", "doc", "__name", "__decorateClass", "component", "NodeEditor", "workbench", "path", "onkeydown", "oninput", "disallowEmpty", "editValue", "placeholder", "state", "node", "prop", "display", "__name", "objectHas", "objectCall", "onfocus", "getter", "setter", "v", "finished", "id", "editor", "TextAreaEditor", "Document", "CodeMirrorEditor", "dom", "onblur", "value", "defaultKeydown", "e", "startEdit", "finishEdit", "edit", "attrs", "textarea", "initialHeight", "span", "height", "empty_default", "node", "workbench", "panel", "NewNode", "workbench", "path", "__name", "e", "lastchild", "debounce", "func", "timeout", "timer", "args", "__name", "SmartNode", "collapsed", "SmartFilter", "node", "n", "results", "ref", "children", "key", "obj", "workbench", "ctx", "search", "__decorateClass", "component", "expanded", "oninput", "e", "list_default", "workbench", "path", "alwaysShowNew", "node", "showNew", "SmartNode", "n", "OutlineNode", "NewNode", "table_default", "workbench", "path", "state", "node", "n", "f", "getFieldEditor", "__name", "field", "fields", "NodeEditor", "OutlineNode", "tabs_default", "workbench", "path", "state", "node", "n", "handleTabClick", "__name", "id", "selectedNode", "getView", "document_default", "workbench", "path", "alwaysShowNew", "node", "showNew", "n", "OutlineNode", "NewNode", "views", "list_default", "table_default", "tabs_default", "document_default", "getView", "name", "empty_default", "__name", "view", "toTitleCase", "ctx", "str", "txt", "Template", "node", "collapsed", "key", "workbench", "ctx", "tmpl", "ws", "name", "n", "__name", "__decorateClass", "component", "Tag", "name", "TagBadge", "workbench", "ctx", "tag", "tmpl", "Template", "f", "c", "ws", "tags", "nodes", "n", "bench", "path", "node", "inputview", "closer", "trigger", "rect", "x", "y", "Picker", "item", "state", "filtered", "t", "__name", "__decorateClass", "component", "e", "OutlineEditor", "workbench", "path", "alwaysShowNew", "getView", "OutlineNode", "attrs", "state", "children", "node", "isRef", "handleNode", "isCut", "expanded", "placeholder", "objectHas", "objectCall", "hover", "__name", "e", "unhover", "cancelTagPopover", "oninput", "Tag", "onkeydown", "anyModifiers", "above", "oldName", "open", "toggle", "Document", "subCount", "n", "showHandle", "NodeEditor", "componentsWith", "component", "QuickAdd", "workbench", "node", "path", "Path", "OutlineEditor", "Settings", "workbench", "state", "currentTheme", "__name", "e", "LockStolenMessage", "FirstTimeMessage", "workbench", "GitHubMessage", "finished", "Workbench", "backend", "CommandRegistry", "KeyBindings", "MenuRegistry", "Workspace", "n", "com", "css", "node", "QuickAdd", "today", "dayNode", "weekNode", "getWeekOfYear", "todayPath", "todayNode", "p", "Path", "panel", "input", "path", "pos", "id", "el", "ctx", "rest", "event", "style", "trigger", "rect", "align", "items", "cmds", "i", "Menu", "x", "y", "CommandPalette", "notice", "finished", "FirstTimeMessage", "GitHubMessage", "LockStolenMessage", "Settings", "body", "backdrop", "explicitClose", "query", "splitQuery", "textQuery", "term", "fieldQuery", "passFieldQuery", "__name", "fields", "f", "Tag", "resultCache", "date", "d", "dayNum", "yearStart", "SHA1", "msg", "rotate_left", "n", "s", "t4", "__name", "lsb_hex", "val", "str", "i", "vh", "vl", "cvt_hex", "v", "Utf8Encode", "string", "utftext", "c", "blockstart", "j", "W", "H0", "H1", "H2", "H3", "H4", "A", "B", "C", "D", "E", "temp", "msg_len", "word_array", "Path", "head", "name", "node", "p", "SHA1", "n", "__name", "Bus", "n", "cb", "nodes", "getComponent", "inflateToComponent", "node", "triggerHook", "name", "value", "parent", "parts", "i", "child", "id", "uniqueId", "Node", "p", "rel", "root", "path", "byId", "cur", "findChild", "__name", "fn", "opts", "dateString", "randomness", "Node", "bus", "id", "raw", "val", "n", "p", "triggerHook", "rel", "i", "anc", "cur", "path", "children", "com", "hasHook", "node", "obj", "componentName", "coms", "getComponent", "type", "linked", "idx", "oldIdx", "name", "value", "fn", "opts", "child", "nodes", "duplicate", "f", "c", "__name", "Workspace", "fs", "Bus", "debounce", "path", "contents", "e", "fn", "immediate", "doc", "n", "i", "main", "root", "ws", "cal", "home", "name", "value", "head", "expanded", "b", "p", "prev", "fieldCount", "lastSubIfExpanded", "__name", "lastField", "lastChild", "nextSiblingOrParentNextSibling", "next", "parent", "func", "timeout", "timer", "args", "Drawer", "attrs", "children", "open", "Page", "__name", "__decorateClass", "component", "Panel", "attrs", "path", "workbench", "node", "close", "__name", "e", "goBack", "maximize", "editMarkdown", "Page", "calcHeight", "value", "viewClass", "NodeEditor", "OutlineEditor", "KeyboardReference", "attrs", "workbench", "shortcuts", "getBindingSymbols", "__name", "cmd", "binding", "bindingSymbols", "header", "ids", "id", "Search", "input", "workbench", "Picker", "__name", "node", "state", "onkeydown", "oninput", "value", "result", "App", "workbench", "state", "toggle", "__name", "e", "node", "NavNode", "input", "Search", "path", "Panel", "Drawer", "KeyboardReference", "sidebarStyle", "rect", "zeroClick", "expanded", "level", "expandable", "open", "n", "Checkbox", "CheckboxEditor", "__name", "__decorateClass", "component", "node", "e", "checkbox", "TextField", "__name", "__decorateClass", "component", "Clock", "node", "obj", "entry", "key", "acc", "val", "total", "child", "now", "a", "d", "seconds", "dur", "min", "ClockBadge", "ClockLog", "workbench", "ctx", "clock", "__name", "__decorateClass", "component", "toggleLog", "BrowserBackend", "FileStore", "SearchIndex_MiniSearch", "SearchIndex_Dumb", "__name", "document", "fieldName", "doc", "key", "node", "id", "query", "suggested", "results", "path", "contents", "encode", "decode", "GitHubBackend", "loginURL", "octokit", "opts", "localbackend", "BrowserBackend", "code", "querystring", "result", "e", "token", "resp", "sessID", "uniqueID", "lockCheck", "o", "dirList", "file", "css", "js", "User", "path", "decode", "contents", "encode", "__name", "user", "dateString", "randomness", "setup", "document", "target", "backend", "workbench", "Workbench", "Clock", "TextField", "Page", "Document", "Checkbox", "Tag", "Template", "SmartNode", "com", "ctx", "input", "objectManaged", "ref", "p", "child", "checkbox", "path", "field", "text", "node", "prev", "parent", "children", "parentSib", "name", "siblingIndex", "above", "pos", "below", "posBelow", "Path", "trigger", "rect", "x", "y", "panel", "generateName", "e", "binding", "App", "__name", "length", "random", "min", "max", "word", "words", "_", "i"] + "sourcesContent": ["\nconst isMac = (navigator.userAgent.toLowerCase().indexOf(\"mac\") !== -1);\n\nexport function bindingSymbols(key?: string): string[] {\n if (!key) return [];\n const symbols = {\n \"backspace\": \"\u232B\",\n \"shift\": \"\u21E7\",\n \"meta\": \"\u2318\",\n \"tab\": \"\u21B9\",\n \"ctrl\": \"\u2303\",\n \"arrowup\": \"\u2191\",\n \"arrowdown\": \"\u2193\",\n \"arrowleft\": \"\u2190\",\n \"arrowright\": \"\u2192\",\n \"enter\": \"\u23CE\"\n };\n const keys = key.toLowerCase().split(\"+\");\n return keys.map(filterKeyForNonMacMeta).map(k => (Object.keys(symbols).includes(k)) ? symbols[k] : k);\n}\n\n// if key is meta and not on a mac, change it to ctrl,\n// otherwise return the key as is\nfunction filterKeyForNonMacMeta(key: string): string {\n return (!isMac && key === \"meta\") ? \"ctrl\": key;\n}\n\nexport interface Binding {\n command: string;\n key: string;\n //when\n //args\n}\n\nexport class KeyBindings {\n bindings: Binding[];\n\n constructor() {\n this.bindings = [];\n }\n\n registerBinding(binding: Binding) {\n this.bindings.push(binding);\n }\n\n getBinding(commandId: string): Binding|null {\n for (const b of this.bindings) {\n if (b.command === commandId) {\n return b;\n }\n }\n return null;\n }\n\n evaluateEvent(event: KeyboardEvent): Binding|null {\n bindings: for (const b of this.bindings) {\n let modifiers = b.key.toLowerCase().split(\"+\");\n let key = modifiers.pop();\n if (key !== event.key.toLowerCase()) {\n continue;\n }\n for (const checkMod of [\"shift\", \"ctrl\", \"alt\", \"meta\"]) {\n let hasMod = modifiers.includes(checkMod);\n if (!isMac) {\n if (checkMod === \"meta\") continue;\n if (checkMod === \"ctrl\") {\n hasMod = modifiers.includes(\"meta\") || modifiers.includes(\"ctrl\");\n }\n }\n // @ts-ignore\n const modState = event[`${filterKeyForNonMacMeta(checkMod)}Key`];\n if (!modState && hasMod) {\n continue bindings;\n }\n if (modState && !hasMod) {\n continue bindings;\n }\n }\n return b;\n }\n return null;\n }\n}", "\nexport interface Command {\n id: string;\n title?: string;\n category?: string;\n icon?: string;\n hidden?: boolean;\n action: Function;\n when?: Function;\n}\n\nexport class CommandRegistry {\n commands: {[index: string]: Command}\n\n constructor() {\n this.commands = {};\n }\n\n registerCommand(cmd: Command) {\n this.commands[cmd.id] = cmd;\n }\n\n canExecuteCommand(id: string, ...rest: any): boolean {\n if (this.commands[id]) {\n if (this.commands[id].when && !this.commands[id].when(...rest)) {\n return false;\n }\n return true;\n }\n return false;\n }\n\n executeCommand(id: string, ...rest: any): Promise {\n return new Promise((resolve) => {\n const ret = this.commands[id].action(...rest);\n resolve(ret);\n });\n }\n}", "\nexport interface MenuItem {\n command: string;\n //alt?: string;\n when?: Function;\n title?: Function;\n onclick?: Function;\n disabled?: boolean;\n //group\n //submenu\n}\n\nexport class MenuRegistry {\n menus: {[index: string]: MenuItem[]};\n\n constructor() {\n this.menus = {};\n }\n\n registerMenu(id: string, items: MenuItem[]) {\n this.menus[id] = items;\n }\n}", "import { bindingSymbols } from \"../action/keybinds.ts\";\n\nfunction isDisabled(workbench, item, cmd, ctx) {\n if (cmd) {\n return item.disabled || !workbench.canExecuteCommand(cmd.id, ctx);\n }\n return item.disabled;\n}\n\nexport const Menu: m.Component = {\n view({attrs: {workbench, x, y, items, align, commands, ctx}}) {\n const onclick = (item, cmd) => (e) => {\n e.stopPropagation();\n if (isDisabled(workbench, item, cmd, ctx)) {\n return;\n }\n workbench.closeMenu();\n if (item.onclick) {\n item.onclick();\n }\n if (cmd) {\n workbench.executeCommand(cmd.id, ctx);\n }\n };\n return (\n
      \n {items.filter(i => !i.when || i.when()).map(i => {\n let title = \"\";\n let binding = undefined;\n let cmd = undefined;\n if (i.command) {\n cmd = commands.find(c => c.id === i.command);\n binding = workbench.keybindings.getBinding(cmd.id);\n title = cmd.title;\n }\n if (i.title) {\n title = i.title();\n }\n return (\n
    • \n
      {title}
      \n {binding &&
      {bindingSymbols(binding.key).join(\" \").toUpperCase()}
      }\n
    • \n )\n })}\n
    \n ) \n }\n};\n\n/*
  • Indent
    shift+A
  • \n
  • Open in new panel
    shift+meta+Backspace
  • \n
    \n
  • Show list view
  • \n
  • Move
  • \n
  • Delete node
  • \n
    */\n", "\nexport interface Attrs {\n input: string;\n inputview: (onkeydown: Function, oninput: Function) => any;\n itemview: (item: any, idx: number) => any;\n onpick: (item: any) => void;\n onchange: (State) => void;\n}\n\nexport interface State {\n selected: number;\n input: string;\n items: any[];\n}\n\nexport const Picker: m.Component = {\n onupdate({ state, dom }) {\n const items = dom.querySelector(\".items\").children;\n if (state.selected !== undefined && items.length > 0) {\n items[state.selected].scrollIntoView({ block: \"nearest\" });\n }\n },\n\n oncreate({ attrs, state, dom }) {\n if (attrs.inputview) {\n dom.querySelector(\"input\")?.focus();\n }\n if (state.selected === undefined) {\n state.selected = 0;\n }\n },\n\n view({ attrs, state }) {\n \n state.selected = (state.selected === undefined) ? 0 : state.selected;\n state.input = (state.input === undefined) ? (attrs.input || \"\") : state.input;\n if (state.items === undefined) {\n state.items = [];\n attrs.onchange(state);\n }\n\n const onkeydown = (e) => {\n const mod = (a, b) => ((a % b) + b) % b;\n if (e.key === \"ArrowDown\") {\n if (state.selected === undefined) {\n state.selected = 0;\n return false;\n }\n state.selected = mod(state.selected + 1, state.items.length);\n return false;\n }\n if (e.key === \"ArrowUp\") {\n if (state.selected === undefined) {\n state.selected = 0;\n }\n state.selected = mod(state.selected - 1, state.items.length);\n return false;\n }\n if (e.key === \"Enter\") {\n if (state.selected !== undefined) {\n attrs.onpick(state.items[state.selected]);\n }\n return false;\n }\n }\n const oninput = (e) => {\n state.input = e.target.value;\n state.selected = 0;\n attrs.onchange(state);\n }\n return (\n
    \n {attrs.inputview(onkeydown, oninput, state.input)}\n
    \n {state.items.map((item, idx) => (\n
    attrs.onpick(item)}\n onmouseover={() => state.selected = idx}>\n {attrs.itemview(item, idx)}\n
    \n ))}\n
    \n
    \n )\n }\n}\n", "import { bindingSymbols } from \"../action/keybinds.ts\";\nimport { Picker } from \"./picker.tsx\";\n\nexport const CommandPalette: m.Component = {\n\n view({ attrs: { workbench, ctx } }) {\n const getTitle = (cmd) => {\n const title = cmd.title || cmd.id;\n return title.replace('-', ' ').replace(/(^|\\s)\\S/g, t => t.toUpperCase());\n }\n const sort = (a, b) => {\n return getTitle(a).localeCompare(getTitle(b));\n }\n const onpick = (cmd) => {\n workbench.closeDialog();\n workbench.commands.executeCommand(cmd.id, ctx);\n }\n const onchange = (state) => {\n state.items = cmds.filter(cmd => {\n const value = cmd.title || cmd.id;\n return value.toLowerCase().includes(state.input.toLowerCase());\n })\n }\n const getBindingSymbols = (cmd) => {\n const binding = workbench.keybindings.getBinding(cmd.id);\n return binding ? bindingSymbols(binding.key).join(\" \").toUpperCase() : \"\";\n }\n\n const cmds = Object.values(workbench.commands.commands)\n .filter(cmd => !cmd.hidden)\n .filter(cmd => workbench.canExecuteCommand(cmd.id, ctx))\n .sort(sort);\n\n return (\n
    \n \n
    \n \n
    \n }\n itemview={(cmd) => \n
    \n
    {getTitle(cmd)}
    \n
    {getBindingSymbols(cmd)}
    \n
    \n } />\n
    \n )\n }\n}\n\n", "/**\n * Hooks are single method interfaces implemented by component values. There are\n * some system hook interfaces defined here as well as utilities for working with\n * system and app hooks.\n * \n * @module\n */\nimport { Node } from \"./mod.ts\";\n\n// triggered on parent set or import (if has parent), or addcomponent\nexport interface AttachListener {\n onAttach(node: Node): void;\n}\n\n// called on accessing children\nexport interface ChildProvider {\n objectChildren(node: Node, children: Node[]): Node[];\n}\n\nexport function hasHook(node: Node, hook: string): boolean {\n return node.value && node.value[hook] instanceof Function;\n}\n\nexport function triggerHook(node: Node, hook: string, ...args: any[]): any {\n if (hasHook(node, hook)) {\n return node.value[hook].apply(node.value, args);\n }\n}\n\nexport function objectHas(obj: Node, hook: string): boolean {\n for (const com of obj.components) {\n if (hasHook(com, hook)) return true;\n }\n return false;\n}\n\nexport function objectCall(obj: Node, hook: string, ...args: any[]): any {\n for (const com of obj.components) {\n if (hasHook(com, hook)) {\n return com.value[hook].apply(com.value, args);\n }\n }\n}\n\nexport function componentsWith(obj: Node, hook: string, ...args: any[]): any[] {\n const ret = [];\n for (const com of obj.components) {\n if (hasHook(com, hook)) {\n ret.push(com.value);\n }\n }\n return ret;\n}\n\n\n\n// shorthand for nodes that have child provider hook.\n// use this to determine if some commands should be\n// prevented since visible children will not be impacted.\nexport function objectManaged(obj: Node): boolean {\n return objectHas(obj, \"objectChildren\");\n}", "/**\n * Components are classes that can be used for component values in component nodes.\n * These classes need to be registered so they can be properly \"hydrated\" from \n * marshaled form (usually JSON) back into class instances.\n * \n * @module\n */\n\nconst registry: Record = {};\n\nexport function component(target: any) {\n registry[componentName(target)] = target;\n}\n\nexport function componentName(target: any): string {\n if (target.prototype === undefined) {\n target = target.constructor;\n }\n return `treehouse.${target.name}`;\n}\n\nexport function getComponent(com: any): any {\n if (typeof com === \"string\") {\n return registry[com];\n }\n return registry[componentName(com)];\n}\n\nexport function inflateToComponent(com: any, obj: any): any {\n const o = new (getComponent(com));\n if (o[\"fromJSON\"] instanceof Function) {\n o.fromJSON(obj);\n } else {\n Object.defineProperties(o, Object.getOwnPropertyDescriptors(obj));\n }\n return o;\n}\n\nexport function duplicate(obj: any): any {\n if (obj === undefined) {\n return undefined;\n }\n const com = getComponent(obj);\n if (!com) {\n return structuredClone(obj);\n }\n const src = JSON.parse(JSON.stringify(obj)||\"\");\n const dst = new obj.constructor();\n if (dst[\"fromJSON\"] instanceof Function) {\n dst.fromJSON(src);\n } else {\n Object.defineProperties(dst, Object.getOwnPropertyDescriptors(src));\n }\n return dst;\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Document {\n object?: Node;\n\n constructor() {\n }\n\n onAttach(node: Node) {\n this.object = node.parent;\n this.object.setAttr(\"view\", \"document\");\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {/* {collapsed?:null} */}\n \n \n \n \n \n \n );\n }\n\n toJSON(key: string): any {\n return {};\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-document\",\n title: \"Make Document\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const doc = new Document();\n ctx.node.addComponent(doc);\n ctx.node.changed();\n workbench.executeCommand(\"zoom\", ctx);\n }\n });\n }\n}\n", "import { objectCall, objectHas } from \"../../model/hooks.ts\";\nimport { Document } from \"../../com/document.tsx\";\n\nexport const NodeEditor: m.Component = {\n view ({attrs: {workbench, path, onkeydown, oninput, disallowEmpty, editValue, placeholder}, state}) {\n const node = path.node;\n let prop = (editValue) ? \"value\" : \"name\";\n \n const display = () => {\n if (prop === \"name\") {\n return objectHas(node, \"displayName\") ? objectCall(node, \"displayName\", node) : node.name;\n }\n return node[prop] || \"\";\n }\n const onfocus = () => {\n state.initialValue = node[prop];\n workbench.context.node = node;\n workbench.context.path = path;\n }\n const getter = () => {\n return node[prop];\n }\n const setter = (v, finished) => {\n if (!node.isDestroyed) {\n if (disallowEmpty && v.length === 0) {\n node[prop] = state.initialValue;\n } else {\n node[prop] = v;\n }\n }\n if (finished) {\n workbench.context.node = null;\n }\n }\n\n if (node.raw.Rel === \"Fields\") {\n placeholder = (editValue) ? \"Value\" : \"Field\";\n }\n \n let id = `input-${path.id}-${node.id}`;\n if (prop === \"value\") {\n id = id+\"-value\";\n }\n let editor = TextAreaEditor;\n if (node.parent && node.parent.hasComponent(Document) && window.Editor) {\n editor = CodeMirrorEditor;\n }\n return m(editor, {id, getter, setter, display, onkeydown, onfocus, oninput, placeholder, workbench, path});\n }\n}\n\n\ninterface Attrs {\n id?: string;\n onkeydown?: Function;\n onfocus?: Function;\n onblur?: Function;\n onmount?: Function;\n getter: Function;\n setter: Function;\n display?: Function;\n}\n\ninterface State {\n editing: boolean;\n buffer: string;\n}\n\nexport const CodeMirrorEditor: m.Component = {\n oncreate({dom,state,attrs: {id, onkeydown, onfocus, onblur, oninput, getter, setter, display, placeholder}}) {\n const value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n\n const defaultKeydown = (e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n const startEdit = (e) => {\n if (onfocus) onfocus(e);\n state.editing = true;\n state.buffer = getter();\n }\n const finishEdit = (e) => {\n // safari can trigger blur more than once\n // for a given element, namely when clicking\n // into devtools. this prevents the second \n // blur setting node name to undefined/empty.\n if (state.editing) {\n state.editing = false;\n setter(state.buffer, true);\n state.buffer = undefined;\n }\n if (onblur) onblur(e);\n }\n const edit = (e) => {\n state.buffer = e.target.value;\n setter(state.buffer, false);\n if (oninput) {\n oninput(e);\n }\n }\n\n state.editor = new window.Editor(dom, value, placeholder);\n state.editor.onblur = finishEdit;\n state.editor.onfocus = startEdit;\n state.editor.oninput = edit;\n state.editor.onkeydown = onkeydown||defaultKeydown;\n dom.editor = state.editor;\n dom.id = id;\n },\n onupdate({dom,state,attrs: {getter, display}}) {\n state.editor.value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n },\n view () {\n return (\n
    \n )\n }\n}\n\nexport const TextAreaEditor: m.Component = {\n oncreate({dom,attrs}) {\n const textarea = dom.querySelector(\"textarea\");\n const initialHeight = textarea.offsetHeight;\n const span = dom.querySelector(\"span\");\n this.updateHeight = () => {\n span.style.width = `${Math.max(textarea.offsetWidth, 100)}px`;\n span.innerHTML = textarea.value.replace(\"\\n\", \"
    \");\n let height = span.offsetHeight;\n if (height === 0 && initialHeight > 0) {\n height = initialHeight;\n }\n textarea.style.height = (height > 0) ? `${height}px` : `var(--body-line-height)`;\n }\n textarea.addEventListener(\"input\", () => this.updateHeight());\n textarea.addEventListener(\"blur\", () => span.innerHTML = \"\");\n setTimeout(() => this.updateHeight(), 50);\n if (attrs.onmount) attrs.onmount(textarea);\n },\n onupdate() {\n this.updateHeight();\n },\n view ({attrs: {id, onkeydown, onfocus, onblur, oninput, getter, setter, display, placeholder, path, workbench}, state}) {\n const value = (state.editing) \n ? state.buffer \n : (display) ? display() : getter();\n \n const defaultKeydown = (e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n }\n }\n const startEdit = (e) => {\n if (onfocus) onfocus(e);\n state.editing = true;\n state.buffer = getter();\n }\n const finishEdit = (e) => {\n // safari can trigger blur more than once\n // for a given element, namely when clicking\n // into devtools. this prevents the second \n // blur setting node name to undefined/empty.\n if (state.editing) {\n state.editing = false;\n setter(state.buffer, true);\n state.buffer = undefined;\n }\n if (onblur) onblur(e);\n }\n const edit = (e) => {\n state.buffer = e.target.value;\n setter(state.buffer, false);\n if (oninput) {\n oninput(e);\n }\n }\n const handlePaste = (e) => {\n const textData = e.clipboardData.getData('Text');\n if (textData.length > 0) {\n e.preventDefault();\n e.stopPropagation();\n\n const lines = textData.split('\\n').map(line => line.trim()).filter(line => line.length > 0);\n state.buffer = lines.shift();\n setter(state.buffer, true);\n\n let node = path.node;\n for (const line of lines) {\n const newNode = workbench.workspace.new(line);\n newNode.parent = node.parent;\n newNode.siblingIndex = node.siblingIndex + 1;\n m.redraw.sync();\n const p = path.clone();\n p.pop();\n workbench.focus(p.append(newNode));\n node = newNode;\n }\n }\n }\n \n return (\n
    \n {value}\n \n
    \n )\n }\n}", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {node, workbench, panel}}) {\n return (\n
    \n
    \n )\n }\n}", "\nexport const NewNode = {\n view({attrs: {workbench, path}}) {\n const keydown = (e) => {\n if (e.key === \"Tab\") {\n e.stopPropagation();\n e.preventDefault();\n if (node.childCount > 0) {\n const lastchild = path.node.children[path.node.childCount-1];\n workbench.executeCommand(\"insert-child\", {node: lastchild, path});\n }\n } else {\n workbench.executeCommand(\"insert-child\", {node: path.node, path}, e.target.value);\n }\n }\n return (\n
    \n \n \n \n \n
    \n \n
    \n
    \n )\n }\n}", "import { Workbench } from \"../workbench/mod.ts\";\nimport { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\nfunction debounce(func, timeout = 1000){\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => { func.apply(this, args); }, timeout);\n };\n}\n\n@component\nexport class SmartNode {\n workbench: Workbench;\n component?: Node;\n object?: Node;\n results?: Node[];\n query: string;\n\n lastQuery?: string;\n lastResultCount?: number;\n initialSearch: boolean;\n\n constructor() {\n this.workbench = window.workbench;\n this.searchDebounce = debounce(this.search.bind(this));\n this.query = \"\";\n this.initialSearch = false;\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {collapsed?:null}\n \n \n \n \n \n );\n }\n\n belowEditor() {\n return SmartFilter;\n }\n\n onAttach(node: Node) {\n this.component = node;\n this.object = node.parent;\n node.bus.observe((n: Node) => {\n if (!node.isDestroyed) {\n this.searchDebounce();\n }\n });\n }\n\n search() {\n if (!this.object) return;\n if (!this.query) {\n this.lastQuery = \"\";\n this.results = [];\n return;\n }\n this.initialSearch = true;\n\n const results = this.workbench.search(this.query)\n .filter(n => n.id !== this.object.id && n.id !== this.component.id);\n \n if (results.length !== this.lastResultCount || this.query !== this.lastQuery) {\n if (this.results) {\n // clean up old results\n this.results.forEach((n) => n.destroy());\n }\n this.results = results.map(n => {\n const ref = this.object.bus.make(\"\");\n ref.raw.Parent = \"@tmp\"; // cleaned up next import\n ref.refTo = n;\n return ref;\n });\n this.lastQuery = this.query;\n this.lastResultCount = results.length;\n }\n }\n\n objectChildren(node: Node, children: Node[]): Node[] {\n if (!this.results && this.query && !this.initialSearch) {\n this.search();\n }\n return this.results || [];\n }\n\n toJSON(key: string): any {\n return {\n query: this.query\n };\n }\n\n fromJSON(obj: any) {\n this.query = obj.query || \"\";\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-smart-node\",\n title: \"Make Smart Node\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.childCount > 0) return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n workbench.defocus();\n const search = new SmartNode();\n ctx.node.addComponent(search);\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n if (ctx.node.name === \"\") {\n setTimeout(() => {\n // defocusing will overwrite this from buffer\n // without a delay\n ctx.node.name = \"Unnamed Smart Node\";\n m.redraw();\n document.querySelector(`#node-${ctx.path.id}-${ctx.node.id} input`).focus();\n }, 10);\n }\n }\n });\n }\n}\n\n\nconst SmartFilter = {\n view({attrs: {node, component, expanded}}) {\n if (!expanded) return;\n\n const oninput = (e) => {\n component.query = e.target.value;\n component.search();\n node.changed();\n }\n return (\n
    \n
    \n \n
    \n )\n }\n}", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\nimport { SmartNode } from \"../com/smartnode.tsx\";\n\nexport default {\n view({attrs: {workbench, path, alwaysShowNew}}) {\n let node = path.node;\n if (path.node.refTo) {\n node = path.node.refTo;\n }\n let showNew = false;\n if ((node.childCount === 0 && node.getLinked(\"Fields\").length === 0) || alwaysShowNew) {\n showNew = true;\n }\n // TODO: find some way to not hardcode this rule\n if (node.hasComponent(SmartNode)) {\n showNew = false;\n }\n return (\n
    \n
    \n {(node.getLinked(\"Fields\").length > 0) &&\n node.getLinked(\"Fields\").map(n => )\n }\n
    \n
    \n {(node.childCount > 0) && node.children.map(n => )}\n {showNew && }\n
    \n
    \n )\n }\n}", "import { NodeEditor, TextAreaEditor } from \"../ui/node/editor.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {workbench, path}, state}) {\n const node = path.node;\n state.fields = (state.fields === undefined) ? new Set() : state.fields;\n node.children.forEach(n => {\n n.getLinked(\"Fields\").forEach(f => state.fields.add(f.name));\n });\n const getFieldEditor = (node, field) => {\n const fields = node.getLinked(\"Fields\").filter(f => f.name === field);\n if (fields.length === 0) return \"\";\n return \n }\n return (\n \n \n \n \n {[...state.fields].map(f => )}\n \n \n \n {node.children.map(n => (\n \n \n {[...state.fields].map(f => )}\n \n ))}\n \n
    Title{f}
    {getFieldEditor(n, f)}
    \n )\n }\n}", "\nimport { getView } from \"../view/views.ts\";\n\nexport default {\n view({ attrs: { workbench, path }, state }) {\n const node = path.node;\n state.tabs = (state.tabs === undefined) ? new Set() : state.tabs;\n state.selectedTab = (state.selectedTab === undefined) ? \"\" : state.selectedTab;\n node.children.forEach(n => {\n state.tabs.add(n.raw);\n if (state.selectedTab === \"\") state.selectedTab = n.raw.ID;\n });\n const handleTabClick = (id) => {\n state.selectedTab = id;\n };\n const selectedNode = node.children.find(n => n.id === state.selectedTab);\n return (\n
    \n
    \n {[...state.tabs].map(n =>
    handleTabClick(n.ID)}>{n.Name}
    )}\n
    \n
    \n
    \n {m(getView(selectedNode.getAttr(\"view\")||\"list\"), {workbench, path: path.append(selectedNode)})}\n
    \n
    \n )\n }\n}\n", "import { NewNode } from \"../ui/node/new.tsx\";\nimport { OutlineNode } from \"../ui/outline.tsx\";\n\nexport default {\n view({attrs: {workbench, path, alwaysShowNew}}) {\n let node = path.node;\n if (path.node.refTo) {\n node = path.node.refTo;\n }\n let showNew = false;\n if ((node.childCount === 0 && node.getLinked(\"Fields\").length === 0) || alwaysShowNew) {\n showNew = true;\n }\n return (\n
    \n
    \n {(node.getLinked(\"Fields\").length > 0) &&\n node.getLinked(\"Fields\").map(n => )\n }\n
    \n
    \n {(node.childCount > 0) && node.children.map(n => )}\n {showNew && }\n
    \n
    \n )\n }\n}", "import empty from \"./empty.tsx\";\nimport list from \"./list.tsx\";\nimport table from \"./table.tsx\";\nimport tabs from \"./tabs.tsx\";\nimport document from \"./document.tsx\";\n\nexport const views = {\n list,\n table,\n tabs,\n document,\n}\n\nexport function getView(name) {\n return views[name] || empty;\n}\n\nwindow.registerView = (name, view) => {\n views[name] = view;\n workbench.commands.registerCommand({\n id: `view-${name}`,\n title: `View as ${toTitleCase(name)}`,\n action: (ctx: Context) => {\n if (!ctx.node) return;\n ctx.node.setAttr(\"view\", name);\n }\n });\n}\n\nfunction toTitleCase(str) {\n return str.replace(\n /\\w\\S*/g,\n function(txt) {\n return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();\n }\n );\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Template {\n object?: Node;\n\n constructor() {\n }\n\n onAttach(node: Node) {\n this.object = node.parent;\n }\n\n handleIcon(collapsed: boolean = false): any {\n return (\n \n {collapsed?:null}\n \n \n \n );\n }\n\n toJSON(key: string): any {\n return {};\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"make-template\",\n title: \"Make Template\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const tmpl = new Template();\n ctx.node.addComponent(tmpl);\n ctx.node.changed();\n }\n });\n }\n\n static findNode(ws: Workspace, name: string): Node|null {\n let node = null;\n ws.mainNode().walk((n) => {\n if (n.value instanceof Template && n.value.object.name === name) {\n node = n.value.object;\n return true;\n }\n return false;\n }, {includeComponents: true});\n return node;\n }\n}\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { Workbench, Workspace } from \"../workbench/mod.ts\";\nimport { Path } from \"../workbench/path.ts\";\nimport { Template } from \"./template.tsx\";\nimport { Picker } from \"../ui/picker.tsx\";\n\n@component\nexport class Tag {\n name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n afterEditor() {\n return TagBadge;\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"add-tag\",\n title: \"Add tag\",\n hidden: true,\n action: (ctx: Context, name: string) => {\n if (!ctx.node) return;\n const tag = new Tag(name);\n ctx.node.addComponent(tag);\n const tmpl = Template.findNode(workbench.workspace, name);\n if (tmpl) {\n tmpl.fields.map(f => f.duplicate()).forEach(f => {\n ctx.node.addLinked(\"Fields\", f);\n f.raw.Parent = ctx.node.raw.ID;\n });\n tmpl.children.map(c => c.duplicate()).forEach(c => {\n ctx.node.addChild(c);\n c.raw.Parent = ctx.node.raw.ID;\n });\n }\n ctx.node.changed();\n }\n });\n }\n\n static findAll(ws: Workspace): string[] {\n const tags = new Set();\n ws.mainNode().walk((n) => {\n if (n.value instanceof Tag) {\n tags.add(n.value.name);\n }\n return false;\n }, {includeComponents: true});\n return [...tags];\n }\n\n static findTagged(ws: Workspace, name: string): Node[] {\n const nodes = [];\n ws.mainNode().walk((n) => {\n if (n.value instanceof Tag && n.value.name === name) {\n nodes.push(n.parent);\n }\n return false;\n }, {includeComponents: true});\n return nodes;\n }\n\n static showPopover(bench: Workbench, path: Path, node: Node, inputview: Function, closer: Function) {\n const tags = Tag.findAll(bench.workspace);\n const trigger = bench.getInput(path);\n const rect = trigger.getBoundingClientRect();\n let x = document.body.scrollLeft + rect.x + (trigger.selectionStart * 10) + 20;\n let y = document.body.scrollTop + rect.y + rect.height;\n bench.showPopover(() => (\n {\n closer();\n bench.getInput(path).blur();\n node.name = node.name.replace(/\\s*#\\w*/, \"\");\n bench.executeCommand(\"add-tag\", {node, path}, item.name);\n }}\n onchange={(state) => {\n if (node.name.includes(\"#\")) {\n state.input = node.name.split(\"#\")[1];\n } else {\n state.input = \"\";\n }\n const filtered = [...tags]\n .filter(t => t.toLowerCase().startsWith(state.input.toLowerCase()))\n .map(t => {return {name: t}});\n if ((filtered[0] && filtered[0].name != state.input && state.input != \"\") || filtered.length === 0) {\n filtered.unshift({name: state.input, prefix: \"Create tag: \"});\n }\n state.items = filtered;\n }}\n inputview={inputview}\n itemview={(item) => \n
    \n
    {item.prefix||\"\"}{item.name}
    \n
    \n }\n />\n ), {top: `${y}px`, left: `${x}px`});\n }\n}\n\nconst TagBadge = {\n view({attrs: {node, component}}) {\n const onkeydown = (e) => {\n if (e.key === \"Backspace\") {\n node.removeComponent(component);\n node.changed();\n }\n };\n return (\n
    \n \n
    {component.name}
    \n
    \n )\n }\n}", "\nimport { Workbench, Path } from \"../workbench/mod.ts\";\nimport { objectCall, componentsWith, objectHas } from \"../model/hooks.ts\";\nimport { NodeEditor } from \"./node/editor.tsx\";\n\nimport { Checkbox } from \"../com/checkbox.tsx\";\nimport { Document } from \"../com/document.tsx\";\nimport { getView } from \"../view/views.ts\";\n\nimport { Tag } from \"../com/tag.tsx\";\n\nexport interface Attrs {\n path: Path;\n workbench: Workbench;\n}\n\nexport interface State {\n hover: boolean;\n tagPopover?: Popover;\n}\n\ninterface Popover {\n onkeydown: Function;\n oninput: Function;\n}\n\nexport const OutlineEditor: m.Component = {\n view ({attrs: {workbench, path, alwaysShowNew}}) {\n return m(getView(path.node.getAttr(\"view\")||\"list\"), {workbench, path, alwaysShowNew});\n }\n}\n\n// handles: expanded state, node menu+handle, children\nexport const OutlineNode: m.Component = {\n view ({attrs, state, children}) {\n let {path, workbench} = attrs;\n let node = path.node;\n\n let isRef = false;\n let handleNode = node;\n if (node.refTo) {\n isRef = true;\n node = handleNode.refTo;\n }\n\n let isCut = false;\n if (workbench.clipboard && workbench.clipboard.op === \"cut\") {\n if (workbench.clipboard.node.id === node.id) {\n isCut = true;\n }\n }\n\n const expanded = workbench.workspace.getExpanded(path.head, handleNode);\n const placeholder = objectHas(node, \"handlePlaceholder\") ? objectCall(node, \"handlePlaceholder\") : '';\n\n const hover = (e) => {\n state.hover = true;\n e.stopPropagation();\n }\n \n const unhover = (e) => {\n state.hover = false;\n e.stopPropagation();\n }\n \n\n const cancelTagPopover = () => {\n if (state.tagPopover) {\n workbench.closePopover();\n state.tagPopover = undefined;\n }\n }\n\n const oninput = (e) => {\n if (state.tagPopover) {\n state.tagPopover.oninput(e);\n if (!e.target.value.includes(\"#\")) {\n cancelTagPopover();\n }\n } else {\n if (e.target.value.includes(\"#\")) {\n state.tagPopover = {};\n // Don't love that we're hard depending on Tag\n Tag.showPopover(workbench, path, node, (onkeydown, oninput) => {\n state.tagPopover = {onkeydown, oninput};\n }, cancelTagPopover);\n }\n }\n }\n\n const onkeydown = (e) => {\n if (state.tagPopover) {\n if (e.key === \"Escape\") {\n cancelTagPopover();\n return;\n }\n if (state.tagPopover.onkeydown(e) === false) {\n e.stopPropagation();\n return false;\n }\n }\n const anyModifiers = e.shiftKey || e.metaKey || e.altKey || e.ctrlKey;\n switch (e.key) {\n case \"ArrowUp\":\n if (e.target.selectionStart !== 0 && !anyModifiers) {\n e.stopPropagation()\n }\n break;\n case \"ArrowDown\":\n if (e.target.selectionStart !== e.target.value.length && e.target.selectionStart !== 0 && !anyModifiers) {\n e.stopPropagation()\n }\n break;\n case \"Backspace\":\n // cursor at beginning of empty text\n if (e.target.value === \"\") {\n e.preventDefault();\n e.stopPropagation();\n if (node.childCount > 0) {\n return;\n }\n workbench.executeCommand(\"delete\", {node, path, event: e});\n return;\n }\n // cursor at beginning of non-empty text\n if (e.target.value !== \"\" && e.target.selectionStart === 0 && e.target.selectionEnd === 0) {\n e.preventDefault();\n e.stopPropagation();\n if (node.childCount > 0) {\n return;\n }\n \n // TODO: make this work as a command?\n const above = workbench.workspace.findAbove(path);\n if (!above) {\n return;\n }\n const oldName = above.node.name;\n above.node.name = oldName+e.target.value;\n node.destroy();\n m.redraw.sync();\n workbench.focus(above, oldName.length);\n \n return;\n }\n break;\n case \"Enter\":\n e.preventDefault();\n if (e.ctrlKey || e.shiftKey || e.metaKey || e.altKey) return;\n // cursor at end of text\n if (e.target.selectionStart === e.target.value.length) {\n if (node.childCount > 0 && workbench.workspace.getExpanded(path.head, node)) {\n workbench.executeCommand(\"insert-child\", {node, path}, \"\", 0);\n } else {\n workbench.executeCommand(\"insert\", {node, path});\n }\n e.stopPropagation();\n return;\n }\n // cursor at beginning of text\n if (e.target.selectionStart === 0) {\n workbench.executeCommand(\"insert-before\", {node, path});\n e.stopPropagation();\n return;\n }\n // cursor in middle of text\n if (e.target.selectionStart > 0 && e.target.selectionStart < e.target.value.length) {\n workbench.executeCommand(\"insert\", {node, path}, e.target.value.slice(e.target.selectionStart)).then(() => {\n node.name = e.target.value.slice(0, e.target.selectionStart);\n });\n e.stopPropagation();\n return;\n }\n break;\n }\n }\n\n const open = (e) => {\n e.preventDefault();\n e.stopPropagation();\n \n workbench.executeCommand(\"zoom\", {node, path});\n \n // clear text selection that happens after from double click\n if (document.selection && document.selection.empty) {\n document.selection.empty();\n } else if (window.getSelection) {\n window.getSelection().removeAllRanges();\n }\n }\n\n const toggle = (e) => {\n // TODO: hook or something so to not hardcode\n if (node.hasComponent(Document)) {\n open(e);\n return;\n }\n if (expanded) {\n workbench.executeCommand(\"collapse\", {node: handleNode, path});\n } else {\n workbench.executeCommand(\"expand\", {node: handleNode, path});\n }\n e.stopPropagation();\n }\n\n const subCount = (n) => {\n return n.childCount + n.getLinked(\"Fields\").length;\n }\n\n const showHandle = () => {\n if (node.id === workbench.context?.node?.id || state.hover) {\n return true;\n }\n if (node.name.length > 0) return true;\n if (placeholder.length > 0) return true;\n }\n\n return (\n
    \n
    \n workbench.showMenu(e, {node: handleNode, path})}\n oncontextmenu={(e) => workbench.showMenu(e, {node: handleNode, path})} \n data-menu=\"node\"\n viewBox=\"0 0 16 16\">\n {state.hover && }\n \n
    workbench.showMenu(e, {node: handleNode, path})} data-menu=\"node\" style={{ display: showHandle() ? 'block' : 'none' }}>\n {(objectHas(node, \"handleIcon\"))\n ? objectCall(node, \"handleIcon\", subCount(node) > 0 && !expanded)\n : \n {(subCount(node) > 0 && !expanded)?:null}\n ,\n {(isRef)?:null}\n \n }\n
    \n {(node.raw.Rel === \"Fields\") \n ?
    \n
    \n \n
    \n \n
    \n :
    \n {objectHas(node, \"beforeEditor\") && componentsWith(node, \"beforeEditor\").map(component => m(component.beforeEditor(), {node, component}))}\n \n {objectHas(node, \"afterEditor\") && componentsWith(node, \"afterEditor\").map(component => m(component.afterEditor(), {node, component}))}\n
    \n }\n
    \n {objectHas(node, \"belowEditor\") && componentsWith(node, \"belowEditor\").map(component => m(component.belowEditor(), {node, component, expanded}))}\n {(expanded === true) &&\n
    \n
    \n
    \n {m(getView(node.getAttr(\"view\")||\"list\"), {workbench, path})}\n
    \n
    \n }\n
    \n )\n }\n};\n\n\n\n\n\n\n\n", "import { OutlineEditor } from \"./outline.tsx\";\nimport { Path } from \"../workbench/mod.ts\";\n\nexport const QuickAdd = {\n view({attrs: {workbench, node}}) {\n const path = new Path(node, \"quickadd\");\n return (\n
    \n

    Quick Add

    \n \n
    \n \n \n
    \n
    \n )\n }\n}", "\nexport const Settings = {\n view({attrs: {workbench}, state}) {\n const currentTheme = workbench.workspace.settings.theme;\n state.selectedTheme = (state.selectedTheme === undefined) ? currentTheme : state.selectedTheme;\n const oninput = (e) => {\n state.selectedTheme = e.target.value;\n }\n return (\n
    \n

    Settings

    \n
    \n
    Theme
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n )\n }\n}", "\nexport const LockStolenMessage = {\n view() {\n return (\n
    \n

    Refresh to view latest updates

    \n

    \n Your notes were updated in another browser session. Refresh the page to view the latest version.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n\nexport const FirstTimeMessage = {\n view({attrs: {workbench}}) {\n return (\n
    \n

    Treehouse is under active development

    \n

    This is a preview based on our main branch, which is actively being developed.

    \n

    If you find a bug, please report it via \n  \n  > Submit Issue.\n

    \n

    \n Data is stored using localstorage, which you can reset via \n  \n  > Reset Demo.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n\nexport const GitHubMessage = {\n view({attrs: {workbench, finished}}) {\n return (\n
    \n

    Login with GitHub

    \n

    The GitHub backend is experimental so use at your own risk!

    \n

    To store your workbench we will create a public repository called

    <username>.treehouse.sh
    if it doesn't already exist. You can manually make this repository private via GitHub if you want.

    \n

    You can Logout via the \n  \n  \n menu in the top right to return to the localstorage backend.\n

    \n
    \n \n \n
    \n
    \n )\n }\n}\n", "import { Backend } from \"../backend/mod.ts\";\nimport { KeyBindings } from \"../action/keybinds.ts\";\nimport { CommandRegistry } from \"../action/commands.ts\";\nimport { MenuRegistry } from \"../action/menus.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { objectHas, objectCall } from \"../model/hooks.ts\";\n\nimport { Menu } from \"../ui/menu.tsx\";\nimport { CommandPalette } from \"../ui/palette.tsx\";\nimport { QuickAdd } from \"../ui/quickadd.tsx\";\nimport { Settings } from \"../ui/settings.tsx\";\nimport { FirstTimeMessage, GitHubMessage, LockStolenMessage } from \"../ui/notices.tsx\";\n\nimport { Workspace, Context, Path } from \"./mod.ts\";\nimport { Tag } from \"../com/tag.tsx\";\n\nexport interface Clipboard {\n op: \"cut\"|\"copy\"|\"copyref\";\n node: Node;\n}\n\nexport interface Drawer {\n open: boolean;\n}\n\n/**\n * Workbench is the top-level controller for the Treehouse frontend.\n * \n * It manages the user action registries, open panels, open workspace,\n * user context, and provides an API used by UI components to \n * trigger various pop-overs, work with quick add, or anything else\n * not provided by the backend or workspace.\n */\nexport class Workbench {\n commands: CommandRegistry;\n keybindings: KeyBindings;\n menus: MenuRegistry;\n\n backend: Backend;\n workspace: Workspace;\n \n context: Context;\n panels: Path[];\n clipboard?: Clipboard;\n drawer: Drawer;\n\n popover: any;\n dialog: any;\n menu: any;\n\n constructor(backend: Backend) {\n this.commands = new CommandRegistry();\n this.keybindings = new KeyBindings();\n this.menus = new MenuRegistry();\n\n this.backend = backend;\n this.workspace = new Workspace(backend.files);\n\n this.context = {node: null};\n this.panels = [];\n this.drawer = { open: false };\n\n this.dialog = {body: () => null};\n this.menu = {body: () => null};\n \n }\n\n get mainPanel(): Path {\n return this.panels[0];\n }\n\n async initialize() {\n await this.workspace.load();\n\n this.workspace.rawNodes.forEach(n => this.backend.index.index(n));\n this.workspace.observe((n => {\n this.workspace.save();\n if (n.isDestroyed) {\n this.backend.index.remove(n.id);\n } else {\n this.backend.index.index(n.raw);\n n.components.forEach(com => this.backend.index.index(com.raw));\n }\n }));\n\n \n if (this.workspace.lastOpenedID) {\n this.openNewPanel(this.workspace.find(this.workspace.lastOpenedID) || this.workspace.mainNode());\n } else {\n this.openNewPanel(this.workspace.mainNode());\n }\n\n if (this.backend.loadExtensions) {\n await this.backend.loadExtensions();\n }\n \n if (this.workspace.settings.theme) {\n const css = document.createElement(\"link\");\n // TODO: figure out better way to couple themes than hardcoded hotlinked URL\n css.setAttribute(\"href\", `https://treehouse.sh/style/themes/${this.workspace.settings.theme}.css`);\n css.setAttribute(\"rel\", \"stylesheet\");\n css.setAttribute(\"type\", \"text/css\");\n document.head.appendChild(css);\n }\n\n m.redraw();\n \n }\n\n authenticated(): boolean {\n return this.backend.auth && this.backend.auth.currentUser();\n }\n\n openQuickAdd() {\n let node = this.workspace.find(\"@quickadd\");\n if (!node) {\n node = this.workspace.new(\"@quickadd\");\n }\n this.showDialog(() => m(QuickAdd, {workbench: this, node}), true);\n setTimeout(() => {\n document.querySelector(\"main > dialog .new-node input\").focus();\n }, 1);\n }\n\n commitQuickAdd() {\n const node = this.workspace.find(\"@quickadd\");\n if (!node) return;\n const today = this.todayNode();\n node.children.forEach(n => n.parent = today);\n }\n\n clearQuickAdd() {\n const node = this.workspace.find(\"@quickadd\");\n if (!node) return;\n node.children.forEach(n => n.destroy());\n }\n\n // TODO: goto workspace\n todayNode(): Node {\n const today = new Date();\n const dayNode = today.toUTCString().split(today.getFullYear())[0];\n const weekNode = `Week ${String(getWeekOfYear(today)).padStart(2, \"0\")}`;\n const yearNode = `${today.getFullYear()}`;\n const todayPath = [\"@calendar\", yearNode, weekNode, dayNode].join(\"/\");\n let todayNode = this.workspace.find(todayPath);\n if (!todayNode) {\n todayNode = this.workspace.new(todayPath);\n }\n return todayNode;\n }\n\n openToday() {\n this.open(this.todayNode());\n }\n\n open(n: Node) {\n // TODO: not sure this is still necessary\n if (!this.workspace.expanded[n.id]) {\n this.workspace.expanded[n.id] = {};\n }\n\n this.workspace.lastOpenedID = n.id;\n this.workspace.save();\n const p = new Path(n);\n this.panels[0] = p\n this.context.path = p;\n }\n\n openNewPanel(n: Node) {\n // TODO: not sure this is still necessary\n if (!this.workspace.expanded[n.id]) {\n this.workspace.expanded[n.id] = {};\n }\n\n this.workspace.lastOpenedID = n.id;\n this.workspace.save();\n const p = new Path(n);\n this.panels.push(p);\n this.context.path = p;\n }\n\n closePanel(panel: Path) {\n this.panels = this.panels.filter(p => p.name !== panel.name);\n }\n\n defocus() {\n const input = this.getInput(this.context.path);\n if (input) {\n input.blur();\n }\n this.context.node = null;\n this.context.path = null;\n }\n\n focus(path: Path, pos?: number = 0) {\n const input = this.getInput(path);\n if (input) {\n this.context.path = path;\n input.focus();\n if (pos !== undefined) {\n input.setSelectionRange(pos,pos);\n }\n } else {\n console.warn(\"unable to find input for\", path);\n }\n }\n\n getInput(path: Path): any {\n let id = `input-${path.id}-${path.node.id}`;\n // kludge:\n if (path.node.raw.Rel === \"Fields\") {\n if (path.node.name !== \"\") {\n id = id+\"-value\"; \n }\n }\n const el = document.getElementById(id);\n if (el.editor) {\n return el.editor;\n }\n return el;\n }\n\n canExecuteCommand(id: string, ctx: any, ...rest: any): boolean {\n ctx = this.newContext(ctx);\n return this.commands.canExecuteCommand(id, ctx, ...rest);\n }\n \n executeCommand(id: string, ctx: any, ...rest: any): Promise {\n ctx = this.newContext(ctx);\n console.log(id, ctx, ...rest);\n return this.commands.executeCommand(id, ctx, ...rest);\n }\n\n newContext(ctx: any): Context {\n return Object.assign({}, this.context, ctx);\n }\n\n showMenu(event: Event, ctx: any, style?: {}) {\n event.stopPropagation();\n event.preventDefault();\n const trigger = event.target.closest(\"*[data-menu]\");\n const rect = trigger.getBoundingClientRect();\n if (!style) {\n const align = trigger.dataset[\"align\"] || \"left\";\n style = {\n top: `${document.body.scrollTop+rect.y+rect.height}px`\n }\n if (align === \"right\") {\n style.marginLeft = \"auto\";\n style.marginRight = `${document.body.offsetWidth - rect.right}px`;\n } else {\n style.marginLeft = `${document.body.scrollLeft+rect.x}px`;\n style.marginRight = \"auto\";\n }\n }\n const items = this.menus.menus[trigger.dataset[\"menu\"]];\n const cmds = items.filter(i => i.command).map(i => this.commands.commands[i.command]);\n if (!items) return;\n this.menu = {body: () => m(Menu, { \n workbench: this,\n ctx: this.newContext(ctx), \n items: items,\n commands: cmds,\n }), style};\n m.redraw();\n setTimeout(() => {\n // this next frame timeout is so any current dialog can close before attempting\n // to showModal on already open dialog, which causes exception.\n document.querySelector(\"main > dialog.menu\").showModal();\n }, 0);\n }\n\n closeMenu() {\n document.querySelector(\"main > dialog.menu\").close();\n workbench.menu.body = () => null;\n }\n\n showPalette(x: number, y: number, ctx: Context) {\n this.showDialog(() => m(CommandPalette, {workbench: this, ctx}), false, {left: `${x}px`, top: `${y}px`});\n }\n\n showNotice(notice, finished) {\n this.showDialog(() => m({\n \"firsttime\": FirstTimeMessage,\n \"github\": GitHubMessage,\n \"lockstolen\": LockStolenMessage,\n }[notice], {workbench: this, finished}), true, undefined, (notice===\"lockstolen\")?true:false);\n }\n\n toggleDrawer() {\n this.drawer.open = !this.drawer.open;\n m.redraw();\n }\n\n showSettings() {\n this.showDialog(() => m(Settings, {workbench: this}), true);\n }\n\n showPopover(body: any, style?: {}) {\n this.popover = {body, style};\n m.redraw();\n }\n\n closePopover() {\n this.popover = null;\n m.redraw();\n }\n\n showDialog(body: any, backdrop?: boolean, style?: {}, explicitClose?: boolean) {\n this.dialog = {body, backdrop, style, explicitClose};\n m.redraw();\n setTimeout(() => {\n // this next frame timeout is so any current dialog can close before attempting\n // to showModal on already open dialog, which causes exception.\n document.querySelector(\"main > dialog.modal\").showModal();\n }, 0);\n }\n\n isDialogOpen(): boolean {\n return document.querySelector(\"main > dialog.modal\").hasAttribute(\"open\");\n }\n\n closeDialog() {\n document.querySelector(\"main > dialog.modal\").close();\n this.dialog.body = () => null;\n }\n\n search(query: string): Node[] {\n if (!query) return [];\n // this regex selects spaces NOT inside quotes\n let splitQuery = query.split(/\\s+(?=(?:[^\\'\"]*[\\'\"][^\\'\"]*[\\'\"])*[^\\'\"]*$)/);\n let textQuery = splitQuery.filter(term => !term.includes(\":\")).join(\" \");\n let fieldQuery = Object.fromEntries(splitQuery.filter(term => term.includes(\":\")).map(term => term.toLowerCase().split(\":\")));\n if (!textQuery && Object.keys(fieldQuery).length > 0) {\n // when text query is empty, no results will show up,\n // but we index field names, so this works for now.\n textQuery = Object.keys(fieldQuery)[0];\n }\n const passFieldQuery = (node: Node): boolean => {\n // kludgy filter on fields\n if (Object.keys(fieldQuery).length > 0) {\n const fields = {};\n for (const f of node.getLinked(\"Fields\")) {\n fields[f.name.toLowerCase()] = f.value.toLowerCase();\n }\n for (const f in fieldQuery) {\n if (!fields[f] || fields[f] !== fieldQuery[f].replace(/['\"]/g, \"\")) {\n return false;\n }\n }\n }\n return true;\n }\n // simple, limited search for tag implementation\n if (textQuery.startsWith(\"#\")) {\n return Tag.findTagged(this.workspace, textQuery.replace(\"#\", \"\")).filter(passFieldQuery);\n }\n let resultCache = {};\n this.backend.index.search(textQuery).forEach(id => {\n let node = window.workbench.workspace.find(id);\n if (!node) {\n return;\n }\n // if component/field value, get the parent\n if (node.value) {\n node = node.parent;\n // parent might not actually exist\n if (!node.raw) return;\n }\n if (!passFieldQuery(node)) {\n return;\n }\n resultCache[node.id] = node;\n });\n return Object.values(resultCache);\n }\n\n\n}\n\n\nfunction getWeekOfYear(date) {\n var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n var dayNum = d.getUTCDay() || 7;\n d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));\n return Math.ceil((((d - yearStart) / 86400000) + 1)/7);\n}", "\n/**\n* Secure Hash Algorithm (SHA1)\n* http://www.webtoolkit.info/\n**/\nexport function SHA1(msg) {\n function rotate_left(n,s) {\n var t4 = ( n<>>(32-s));\n return t4;\n };\n function lsb_hex(val) {\n var str='';\n var i;\n var vh;\n var vl;\n for( i=0; i<=6; i+=2 ) {\n vh = (val>>>(i*4+4))&0x0f;\n vl = (val>>>(i*4))&0x0f;\n str += vh.toString(16) + vl.toString(16);\n }\n return str;\n };\n function cvt_hex(val) {\n var str='';\n var i;\n var v;\n for( i=7; i>=0; i-- ) {\n v = (val>>>(i*4))&0x0f;\n str += v.toString(16);\n }\n return str;\n };\n function Utf8Encode(string) {\n string = string.replace(/\\r\\n/g,'\\n');\n var utftext = '';\n for (var n = 0; n < string.length; n++) {\n var c = string.charCodeAt(n);\n if (c < 128) {\n utftext += String.fromCharCode(c);\n }\n else if((c > 127) && (c < 2048)) {\n utftext += String.fromCharCode((c >> 6) | 192);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n else {\n utftext += String.fromCharCode((c >> 12) | 224);\n utftext += String.fromCharCode(((c >> 6) & 63) | 128);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n }\n return utftext;\n };\n var blockstart;\n var i, j;\n var W = new Array(80);\n var H0 = 0x67452301;\n var H1 = 0xEFCDAB89;\n var H2 = 0x98BADCFE;\n var H3 = 0x10325476;\n var H4 = 0xC3D2E1F0;\n var A, B, C, D, E;\n var temp;\n msg = Utf8Encode(msg);\n var msg_len = msg.length;\n var word_array = new Array();\n for( i=0; i>>29 );\n word_array.push( (msg_len<<3)&0x0ffffffff );\n for ( blockstart=0; blockstart n.id)].join(\":\"));\n }\n\n get node(): Node {\n return this.nodes[this.nodes.length-1];\n }\n\n get previous(): Node|null {\n if (this.nodes.length < 2) return null;\n return this.nodes[this.nodes.length-2];\n }\n\n get head(): Node {\n return this.nodes[0];\n }\n}\n\n", "import { RawNode, Node as INode, Bus as IBus, WalkFunc, ObserverFunc, WalkOptions } from \"../mod.ts\";\nimport { componentName, getComponent, inflateToComponent } from \"../components.ts\";\nimport { triggerHook, hasHook } from \"../hooks.ts\";\nimport { Node } from \"./mod.ts\";\n\nexport class Bus {\n nodes: Record;\n observers: ObserverFunc[];\n\n constructor() {\n this.nodes = {\"@root\": {\n ID: \"@root\",\n Name: \"@root\",\n Linked: {Children: [], Components: []},\n Attrs: {}\n }};\n this.observers = [];\n }\n\n changed(n: INode) {\n this.observers.forEach(cb => cb(n));\n }\n\n /* Bus interface */\n\n import(nodes: RawNode[]) {\n for (const n of nodes) {\n if (n.Value && getComponent(n.Name)) {\n n.Value = inflateToComponent(n.Name, n.Value);\n n.Rel = \"Components\"; // kludge\n }\n this.nodes[n.ID] = n;\n }\n for (const n of nodes) {\n // clear stored tmp nodes\n if (n.Parent === \"@tmp\") {\n delete this.nodes[n.ID];\n continue;\n }\n // clear nodes with no parent that aren't system\n if (!n.ID.startsWith(\"@\") && n.Parent === undefined) {\n delete this.nodes[n.ID];\n continue;\n }\n // clear nodes with non-existant parent\n if (n.Parent && !this.nodes[n.Parent]) {\n delete this.nodes[n.ID];\n continue;\n }\n const node = this.find(n.ID);\n if (node) {\n // check orphan\n if (node.parent && !node.parent.raw) {\n delete this.nodes[n.ID];\n continue;\n }\n // trigger attach\n triggerHook(node, \"onAttach\", node);\n }\n }\n }\n\n export(): RawNode[] {\n const nodes: RawNode[] = [];\n for (const n of Object.values(this.nodes)) {\n nodes.push(n);\n }\n return nodes;\n }\n\n make(name: string, value?: any): INode {\n let parent: INode|null = null;\n if (name.includes(\"/\")) {\n const parts = name.split(\"/\");\n parent = this.find(parts[0]);\n for (let i = 1; i < parts.length-1; i++) {\n if (parent === null) {\n throw \"unable to get root\";\n }\n \n let child = parent.find(parts[i]);\n if (!child) {\n child = this.make(parts.slice(0, i+1).join(\"/\"));\n }\n parent = child;\n }\n name = parts[parts.length-1];\n }\n const id = (name.startsWith(\"@\"))?name:uniqueId();\n this.nodes[id] = {\n ID: id,\n Name: name,\n Value: value,\n Linked: {Children: [], Components: []},\n Attrs: {}\n };\n const node = new Node(this, id);\n if (parent) {\n node.parent = parent;\n }\n return node;\n }\n\n // destroys node but not linked nodes\n destroy(n: INode) {\n const p = n.parent;\n if (p !== null && !p.isDestroyed) {\n let rel = n.raw.Rel || \"Children\";\n if (p.raw.Linked[rel].includes(n.id)) {\n p.raw.Linked[rel].splice(n.siblingIndex, 1);\n }\n }\n delete this.nodes[n.id];\n if (p) {\n this.changed(p);\n }\n }\n\n roots(): INode[] {\n return Object.values(this.nodes).filter(n => n.Parent === undefined).map(n => new Node(this, n.ID));\n }\n\n root(name?: string): INode|null {\n name = name || \"@root\"\n const node = this.roots().find(root => root.name === name);\n if (node === undefined) return null;\n return node;\n }\n\n find(path:string): INode|null {\n const byId = this.nodes[path];\n if (byId) return new Node(this, byId.ID);\n const parts = path.split(\"/\");\n if (parts.length === 1 && parts[0].startsWith(\"@\")) {\n // did not find @id by ID so return null\n return null;\n }\n let cur = this.root(parts[0]);\n if (!cur && this.nodes[parts[0]]) {\n cur = new Node(this, this.nodes[parts[0]].ID);\n }\n if (cur) {\n parts.shift();\n } else {\n cur = this.root(\"@root\"); \n }\n if (!cur) {\n return null;\n }\n const findChild = (n: INode, name: string): INode|undefined => {\n if (n.refTo) {\n n = n.refTo;\n }\n return n.children.find(child => child.name === name);\n }\n for (const name of parts) {\n const child = findChild(cur, name);\n if (!child) return null;\n cur = child;\n }\n return cur;\n }\n\n walk(fn: WalkFunc, opts?: WalkOptions) {\n for (const root of this.roots()) {\n if (root.walk(fn, opts)) return;\n }\n }\n\n observe(fn: ObserverFunc) {\n this.observers.push(fn);\n }\n}\n\nconst uniqueId = () => {\n const dateString = Date.now().toString(36);\n const randomness = Math.random().toString(36).substring(2);\n return dateString + randomness;\n};\n", "import { RawNode, Node as INode, Bus as IBus, WalkFunc, WalkOptions } from \"../mod.ts\";\nimport { componentName, getComponent, duplicate } from \"../components.ts\";\nimport { triggerHook, hasHook } from \"../hooks.ts\";\nimport { Bus } from \"./mod.ts\";\n\nexport class Node {\n _id: string;\n _bus: Bus;\n\n constructor(bus: Bus, id: string) {\n this._bus = bus;\n this._id = id;\n }\n\n [Symbol.for(\"Deno.customInspect\")]() {\n return `Node[${this.id}:${this.name}]`;\n }\n\n /* Node interface */\n\n get id(): string {\n return this._id;\n }\n\n get bus(): IBus {\n return this._bus;\n }\n\n get raw(): RawNode {\n const raw = this._bus.nodes[this.id];\n if (!raw) throw `use of non-existent node ${this.id}`;\n return raw;\n }\n\n\n get name(): string {\n if (this.refTo) {\n return this.refTo.name;\n }\n return this.raw.Name;\n }\n\n set name(val: string) {\n if (this.refTo) {\n this.refTo.name = val;\n } else {\n this.raw.Name = val;\n }\n this.changed();\n }\n\n get value(): any {\n if (this.refTo) {\n return this.refTo.value;\n }\n return this.raw.Value;\n }\n\n set value(val: string) {\n if (this.refTo) {\n this.refTo.value = val;\n } else {\n this.raw.Value = val;\n }\n this.changed();\n }\n\n get parent(): INode|null {\n if (!this.raw.Parent) return null;\n if (!this._bus.nodes[this.raw.Parent]) return null;\n return new Node(this._bus, this.raw.Parent);\n }\n\n set parent(n: INode|null) {\n const p = this.parent;\n if (p !== null) {\n p.raw.Linked.Children.splice(this.siblingIndex, 1);\n }\n if (n !== null) {\n this.raw.Parent = n.id;\n n.raw.Linked.Children.push(this.id);\n triggerHook(n, \"onAttach\", n);\n } else {\n this.raw.Parent = undefined;\n }\n this.changed();\n }\n\n get refTo(): INode|null {\n const id = this.raw.Attrs[\"refTo\"];\n if (!id) return null;\n const refTo = this._bus.nodes[id];\n if (!refTo) return null;\n return new Node(this._bus, id);\n }\n\n set refTo(n: INode|null) {\n if (!n) {\n delete this.raw.Attrs[\"refTo\"];\n this.changed();\n return;\n }\n this.raw.Attrs[\"refTo\"] = n.id;\n this.changed();\n }\n\n get siblingIndex(): number {\n const p = this.parent;\n if (p === null) return 0;\n let rel = this.raw.Rel || \"Children\";\n return p.raw.Linked[rel].findIndex(id => id === this.id);\n }\n\n set siblingIndex(i: number) {\n const p = this.parent;\n if (p === null) return;\n let rel = this.raw.Rel || \"Children\";\n p.raw.Linked[rel].splice(this.siblingIndex, 1);\n p.raw.Linked[rel].splice(i, 0, this.id);\n p.changed();\n }\n\n get prevSibling(): INode|null {\n const p = this.parent;\n if (p === null) return null;\n if (this.siblingIndex === 0) return null;\n let rel = this.raw.Rel || \"Children\";\n return p.getLinked(rel)[this.siblingIndex-1];\n }\n\n get nextSibling(): INode|null {\n const p = this.parent;\n if (p === null) return null;\n if (this.siblingIndex === p.children.length-1) return null;\n let rel = this.raw.Rel || \"Children\";\n return p.getLinked(rel)[this.siblingIndex+1];\n }\n\n get ancestors(): INode[] {\n const anc = [];\n let p = this.parent;\n while (p !== null) {\n anc.push(p);\n p = p.parent;\n }\n return anc;\n }\n\n get isDestroyed(): boolean {\n return !this._bus.nodes.hasOwnProperty(this.id);\n }\n\n get path(): string {\n let cur: INode|null = this;\n const path = [];\n while (cur) {\n path.unshift(cur.name);\n cur = cur.parent;\n }\n return path.join(\"/\");\n }\n\n get children(): INode[] {\n if (this.refTo) return this.refTo.children;\n let children: INode[] = [];\n if (this.raw.Linked.Children) {\n children = this.raw.Linked.Children.map(id => new Node(this._bus, id));\n };\n for (const com of this.components) {\n if (hasHook(com, \"objectChildren\")) {\n return triggerHook(com, \"objectChildren\", this, children);\n }\n }\n return children;\n }\n\n get childCount(): number {\n if (this.refTo) return this.refTo.childCount;\n for (const com of this.components) {\n if (hasHook(com, \"objectChildren\")) {\n return triggerHook(com, \"objectChildren\", this, null).length;\n }\n }\n if (!this.raw.Linked.Children) return 0;\n return this.raw.Linked.Children.length;\n }\n\n addChild(node: INode) {\n if (this.refTo) {\n this.refTo.addChild(node);\n return;\n }\n this.raw.Linked.Children.push(node.id);\n this.changed();\n } \n\n removeChild(node: INode) {\n if (this.refTo) {\n this.refTo.removeChild(node);\n return;\n }\n const children = this.raw.Linked.Children.filter(id => id === node.id);\n this.raw.Linked.Children = children;\n this.changed();\n }\n\n get fields(): INode[] {\n if (!this.raw.Linked.Fields) return [];\n return this.raw.Linked.Fields.map(id => new Node(this._bus, id));\n }\n\n get fieldCount(): number {\n if (!this.raw.Linked.Fields) return 0;\n return this.raw.Linked.Fields.length;\n }\n\n get components(): INode[] {\n if (!this.raw.Linked.Components) return [];\n return this.raw.Linked.Components.map(id => new Node(this._bus, id));\n }\n\n get componentCount(): number {\n if (!this.raw.Linked.Components) return 0;\n return this.raw.Linked.Components.length;\n }\n\n addComponent(obj: any) {\n const node = this.bus.make(componentName(obj), obj);\n node.raw.Parent = this.id;\n node.raw.Rel = \"Components\" // kludge\n this.raw.Linked.Components.push(node.id);\n triggerHook(node, \"onAttach\", node);\n this.changed();\n } \n\n removeComponent(obj: any) {\n let coms;\n if (obj.name && getComponent(obj)) {\n coms = this.components.filter(n => n.name === componentName(obj));\n } else {\n coms = this.components.filter(n => n.value === obj);\n }\n if (coms.length > 0) {\n coms[0].destroy();\n }\n this.changed();\n }\n \n hasComponent(type: any): boolean {\n const coms = this.components.filter(n => n.name === componentName(type));\n if (coms.length > 0) {\n return true;\n }\n return false;\n }\n\n getComponent(type: any): any|null {\n const coms = this.components.filter(n => n.name === componentName(type));\n if (coms.length > 0) {\n return coms[0].value;\n }\n return null;\n }\n // getComponentsInChildren\n // getComponentsInParents\n\n getLinked(rel: string): INode[] {\n if (!this.raw.Linked[rel]) return [];\n return this.raw.Linked[rel].map(id => new Node(this._bus, id));\n }\n\n addLinked(rel: string, node: INode) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n node.raw.Rel = rel; // kludge\n this.raw.Linked[rel].push(node.id);\n this.changed();\n } \n\n removeLinked(rel: string, node: INode) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n const linked = this.raw.Linked[rel].filter(id => id === node.id);\n this.raw.Linked[rel] = linked;\n this.changed();\n }\n\n moveLinked(rel: string, node: INode, idx: number) {\n if (!this.raw.Linked[rel]) {\n this.raw.Linked[rel] = [];\n }\n const oldIdx = this.raw.Linked[rel].findIndex(id => id === node.id);\n if (oldIdx === -1) return;\n const linked = this.raw.Linked[rel];\n linked.splice(idx, 0, linked.splice(oldIdx, 1)[0]);\n this.raw.Linked[rel] = linked;\n this.changed();\n }\n\n getAttr(name: string): string {\n return this.raw.Attrs[name] || \"\";\n }\n\n setAttr(name: string, value: string) {\n this.raw.Attrs[name] = value;\n this.changed();\n }\n\n find(path: string): INode|null {\n return this.bus.find([this.path, path].join(\"/\"));\n }\n\n walk(fn: WalkFunc, opts?: WalkOptions): boolean {\n opts = opts || {\n followRefs: false,\n includeComponents: false\n };\n if (fn(this)) {\n return true;\n }\n let children = this.children;\n if (this.refTo && opts.followRefs) {\n if (fn(this.refTo)) {\n return true;\n }\n children = this.refTo.children;\n }\n for (const child of children) {\n if (child.walk(fn, opts)) return true;\n }\n if (opts.includeComponents) {\n for (const com of this.components) {\n if (com.walk(fn, opts)) return true;\n }\n }\n return false;\n }\n\n destroy() {\n if (this.isDestroyed) return;\n if (this.refTo) {\n this._bus.destroy(this);\n return;\n }\n const nodes: INode[] = [];\n this.walk((n: INode): boolean => {\n nodes.push(n);\n return false;\n }, {\n followRefs: false,\n includeComponents: true\n });\n nodes.reverse().forEach(n => this._bus.destroy(n));\n }\n\n duplicate(): INode {\n const n = this._bus.make(this.name, duplicate(this.value));\n n.raw.Rel = this.raw.Rel;\n this.fields.map(f => f.duplicate()).forEach(f => {\n n.addLinked(\"Fields\", f);\n f.raw.Parent = n.raw.ID;\n });\n this.components.map(c => c.duplicate()).forEach(c => {\n n.addLinked(\"Components\", c);\n c.raw.Parent = n.raw.ID;\n });\n this.children.map(c => c.duplicate()).forEach(c => {\n n.addChild(c);\n c.raw.Parent = n.raw.ID;\n });\n return n;\n }\n\n changed() {\n this._bus.changed(this);\n }\n \n // duplicate?\n}\n", "import { FileStore } from \"../backend/mod.ts\";\nimport { Bus, Node, RawNode } from \"../model/mod.ts\";\nimport { Path } from \"./mod.ts\";\nimport * as module from \"../model/module/mod.ts\";\n\n\n/**\n * Workspace is a container for nodes and manages marshaling them using\n * the FileStore backend API. It also keeps track of what nodes have been\n * expanded and what node was last opened. It serializes as JSON with a\n * version indicator and will handle migrations of old versions to the \n * latest when loading. Saving is currently debounced here so this applies\n * to all backends. \n */\nexport class Workspace {\n fs: FileStore;\n bus: Bus;\n\n lastOpenedID: string;\n expanded: { [key: string]: { [key: string]: boolean } }; // [rootid][id]\n settings: {};\n\n constructor(fs: FileStore) {\n this.fs = fs;\n this.bus = new module.Bus();\n this.expanded = {};\n this.settings = {};\n\n this.writeDebounce = debounce(async (path, contents) => {\n try {\n await this.fs.writeFile(path, contents);\n console.log(\"Saved workspace.\");\n } catch (e: Error) {\n console.error(e);\n document.dispatchEvent(new CustomEvent(\"BackendError\"));\n }\n });\n }\n\n get rawNodes(): RawNode[] {\n return this.bus.export();\n }\n\n observe(fn: (n: Node) => void) {\n this.bus.observe(fn);\n }\n\n async save(immediate?: boolean) {\n const contents = JSON.stringify({\n version: 1,\n lastopen: this.lastOpenedID,\n expanded: this.expanded,\n nodes: this.rawNodes,\n settings: this.settings\n }, null, 2);\n if (immediate) {\n await this.fs.writeFile(\"workspace.json\", contents);\n } else {\n this.writeDebounce(\"workspace.json\", contents);\n }\n }\n\n async load() {\n let doc = JSON.parse(await this.fs.readFile(\"workspace.json\") || \"{}\");\n if (doc.nodes) {\n doc.nodes = doc.nodes.map(n => {\n // any node migrations:\n if (n.Name === \"treehouse.SearchNode\") {\n n.Name = \"treehouse.SmartNode\";\n }\n return n;\n })\n this.bus.import(doc.nodes);\n console.log(`Loaded ${doc.nodes.length} nodes.`);\n }\n if (doc.expanded) {\n // Only import the node keys that still exist\n // in the workspace.\n for (const n in doc.expanded) {\n for (const i in doc.expanded[n]) {\n if (this.bus.find(i)) {\n if (!this.expanded[n]) this.expanded[n] = {};\n this.expanded[n][i] = doc.expanded[n][i];\n }\n }\n }\n }\n if (doc.lastopen) {\n this.lastOpenedID = doc.lastopen;\n }\n if (doc.settings) {\n this.settings = Object.assign(this.settings, doc.settings);\n }\n }\n\n mainNode(): Node {\n let main = this.bus.find(\"@workspace\");\n if (!main) {\n console.info(\"Building missing workspace node.\")\n const root = this.bus.find(\"@root\");\n const ws = this.bus.make(\"@workspace\");\n ws.name = \"Workspace\";\n ws.parent = root;\n const cal = this.bus.make(\"@calendar\");\n cal.name = \"Calendar\";\n cal.parent = ws;\n const home = this.bus.make(\"Home\");\n home.parent = ws;\n main = ws;\n }\n return main;\n }\n\n find(path: string): Node | null {\n return this.bus.find(path)\n }\n\n new(name: string, value?: any): Node {\n return this.bus.make(name, value);\n }\n\n // TODO: take single Path\n getExpanded(head: Node, n: Node): boolean {\n if (!this.expanded[head.id]) {\n this.expanded[head.id] = {};\n }\n let expanded = this.expanded[head.id][n.id];\n if (expanded === undefined) {\n expanded = false;\n }\n return expanded;\n }\n\n // TODO: take single Path\n setExpanded(head: Node, n: Node, b: boolean) {\n if (!this.expanded[head.id]) {\n this.expanded[head.id] = {};\n }\n this.expanded[head.id][n.id] = b;\n this.save();\n }\n\n findAbove(path: Path): Path | null {\n if (path.node.id === path.head.id) {\n return null;\n }\n const p = path.clone();\n p.pop(); // pop to parent\n let prev = path.node.prevSibling;\n if (!prev) {\n // if not a field and parent has fields, return last field\n const fieldCount = path.previous.getLinked(\"Fields\").length;\n if (path.node.raw.Rel !== \"Fields\" && fieldCount > 0) {\n return p.append(path.previous.getLinked(\"Fields\")[fieldCount - 1]);\n }\n // if no prev sibling, and no fields, return parent\n return p;\n }\n const lastSubIfExpanded = (p: Path): Path => {\n const expanded = this.getExpanded(path.head, p.node);\n if (!expanded) {\n // if not expanded, return input path\n return p;\n }\n const fieldCount = p.node.getLinked(\"Fields\").length;\n if (p.node.childCount === 0 && fieldCount > 0) {\n const lastField = p.node.getLinked(\"Fields\")[fieldCount - 1];\n // if expanded, no children, has fields, return last field or its last sub if expanded\n return lastSubIfExpanded(p.append(lastField));\n }\n if (p.node.childCount === 0) {\n // expanded, no fields, no children\n return p;\n }\n const lastChild = p.node.children[p.node.childCount - 1];\n // return last child or its last sub if expanded\n return lastSubIfExpanded(p.append(lastChild));\n }\n // return prev sibling or its last child if expanded\n return lastSubIfExpanded(p.append(prev));\n }\n\n findBelow(path: Path): Path | null {\n // TODO: find a way to indicate pseudo \"new\" node for expanded leaf nodes\n const p = path.clone();\n if (this.getExpanded(path.head, path.node) && path.node.getLinked(\"Fields\").length > 0) {\n // if expanded and fields, return first field\n return p.append(path.node.getLinked(\"Fields\")[0]);\n }\n if (this.getExpanded(path.head, path.node) && path.node.childCount > 0) {\n // if expanded and children, return first child\n return p.append(path.node.children[0]);\n }\n const nextSiblingOrParentNextSibling = (p: Path): Path | null => {\n const next = p.node.nextSibling;\n if (next) {\n p.pop(); // pop to parent\n // if next sibling, return that\n return p.append(next);\n }\n const parent = p.previous;\n if (!parent) {\n // if no parent, return null\n return null;\n }\n if (p.node.raw.Rel === \"Fields\" && parent.childCount > 0) {\n p.pop(); // pop to parent\n // if field and parent has children, return first child\n return p.append(parent.children[0]);\n }\n p.pop(); // pop to parent\n // return parents next sibling or parents parents next sibling\n return nextSiblingOrParentNextSibling(p);\n }\n // return next sibling or parents next sibling\n return nextSiblingOrParentNextSibling(p);\n }\n\n}\n\n\nfunction debounce(func, timeout = 3000) {\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => { func.apply(this, args); }, timeout);\n };\n}\n", "export const Drawer = {\n view({ attrs, children }) {\n const open = attrs.open;\n return (\n
    \n {children}\n
    \n )\n }\n};\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n// deprecated\n\n@component\nexport class Page {\n markdown: string;\n\n constructor() {\n this.markdown = \"\";\n }\n}\n", "import { OutlineEditor } from \"./outline.tsx\";\nimport { NodeEditor } from \"./node/editor.tsx\";\nimport { Page } from \"../com/page.tsx\";\n\nexport const Panel = {\n view({ attrs }) {\n const path = attrs.path;\n const workbench = attrs.workbench;\n const node = path.node;\n\n const close = (e) => {\n workbench.executeCommand(\"close-panel\", {}, path);\n }\n const goBack = (e) => {\n let node = path.pop();\n // if there was a duplicate id in the path,\n // pop again\n if (node === path.node) {\n path.pop();\n }\n }\n const maximize = (e) => {\n // todo: should be a command\n workbench.panels = [path];\n workbench.context.path = path;\n }\n const editMarkdown = (e) => {\n node.getComponent(Page).markdown = e.target.value;\n node.changed();\n }\n function calcHeight(value = \"\") {\n let numberOfLineBreaks = (value.match(/\\n/g) || []).length;\n // min-height + lines x line-height + padding + border\n let newHeight = 20 + numberOfLineBreaks * 20;\n return newHeight;\n }\n let viewClass = \"\";\n if (node.getAttr(\"view\")) {\n viewClass = `${node.getAttr(\"view\")}-panel`\n }\n return
    \n
    \n {(path.length > 1) ?\n
    \n \n \n \n
    \n : null}\n\n
    \n {(node.parent && node.parent.id !== \"@root\") ? workbench.open(node.parent)}>{node.parent.name} :  }\n
    \n\n {(workbench.panels.length > 1) ?\n
    \n \n \n
    \n : null}\n
    \n\n
    \n
    workbench.showMenu(e, { node, path })} data-menu=\"node\">\n \n
    \n {(node.hasComponent(Page)) ?\n \n : null}\n \n
    \n
    \n }\n};\n", "import { bindingSymbols } from \"../action/keybinds.ts\";\n\nexport const KeyboardReference = {\n view({ attrs }) {\n const workbench = attrs.workbench;\n const shortcuts = {\n \"\": [\n \"pick-command\",\n ],\n \"Edit\": [\n \"cut\",\n \"copy\",\n \"copy-reference\",\n \"paste\",\n \"mark-done\",\n \"insert\",\n \"delete\",\n ],\n \"Navigate\": [\n \"expand\",\n \"collapse\",\n \"indent\",\n \"outdent\",\n \"move-up\",\n \"move-down\",\n \"prev\",\n \"next\",\n ],\n };\n\n const getBindingSymbols = (cmd) => {\n const binding = workbench.keybindings.getBinding(cmd.id);\n return binding ? bindingSymbols(binding.key).join(\" \").toUpperCase() : \"\";\n };\n\n return (\n
    \n

    Keyboard Shortcuts

    \n\n {Object.entries(shortcuts).map(([header, ids]) => {\n return (\n
    \n {(header.length !== 0) &&

    {header}

    }\n
    \n {ids.map(id => workbench.commands.commands[id]).map(cmd => (\n
    \n
    {getBindingSymbols(cmd)}
    \n
    {cmd.title}
    \n
    \n ))}\n
    \n
    \n );\n })}\n
    \n )\n }\n}", "import { Picker } from \"./picker.tsx\";\n\nexport const Search: m.Component = {\n\n view({ attrs: { input, workbench } }) {\n \n const onpick = (node) => {\n workbench.closeDialog();\n workbench.open(node);\n }\n const onchange = (state) => {\n if (state.input) {\n state.items = workbench.search(state.input);\n } else {\n state.items = [];\n } \n }\n\n return (\n
    \n \n
    \n \n \n
    \n }\n itemview={(result) =>
    {result.name}
    } />\n
    \n )\n }\n}\n", "import { Drawer as DrawerComponent } from \"./drawer.tsx\";\nimport { Panel as PanelComponent } from \"./panel.tsx\";\nimport { KeyboardReference } from './reference.tsx';\nimport { Search } from \"./search.tsx\";\nimport { Notice } from \"./notices.tsx\";\n\nexport const App: m.Component = {\n view ({attrs: {workbench}, state}) {\n state.open = (state.open === undefined) ? true : state.open;\n const toggle = (e) => {\n if (state.open) {\n state.open = false;\n } else {\n state.open = true;\n }\n }\n return (\n
    \n\n
    \n
    \n
    \n
    \n
    \n {state.open && workbench.workspace.bus.root().children.map(node => )}\n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    workbench.openToday()} style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", display: \"flex\", alignItems: \"center\"}}>\n \n \n {/* {(new Date()).getDate()} */}\n \n
    Today
    \n
    \n
    workbench.openQuickAdd()} style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", display: \"flex\", alignItems: \"center\"}}>\n \n
    Quick Add
    \n
    \n\n
    \n
    \n
    \n \n {\n if (e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift' || e.key === 'Meta') return;\n const input = e.target.getBoundingClientRect();\n workbench.showDialog(() => , false, {\n // TODO: make these not so hardcoded offsets\n left: `${input.left-33}px`,\n top: `${input.top-9}px`,\n width: `${input.width+33}px`\n });\n e.preventDefault();\n }} \n style={{\n border: \"0\", \n outline: \"0\", \n background: \"transparent\", \n paddingTop: \"3px\"\n }} />\n
    \n
    \n
    \n \n
    workbench.toggleDrawer()} data-menu=\"keyboard-reference\" data-align=\"right\" style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\", marginTop: \"-2px\"}}>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n\n
    workbench.showMenu(e)} data-menu=\"settings\" data-align=\"right\" style={{cursor: \"pointer\", marginLeft: \"var(--padding)\", marginRight: \"var(--padding)\"}}>\n \n
    \n
    \n\n
    \n {workbench.panels.map(path =>
    )}\n \n \n \n
    \n\n
    \n
    \n {\n const sidebarStyle = document.querySelector(\".sidebar\").style;\n if (sidebarStyle.display !== \"flex\") {\n sidebarStyle.display = \"flex\";\n } else {\n sidebarStyle.display = \"none\";\n }\n }} xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"feather feather-sidebar\">\n
    \n
    workbench.openToday()}>\n \n \n \n
    \n
    workbench.openQuickAdd()}>\n \n
    \n
    workbench.showDialog(() => , true, {top: \"25%\", bottom: \"100px\"})}>\n \n
    \n
    workbench.showMenu(e, undefined, {bottom: \"100px\", marginTop: \"auto\"})} data-menu=\"settings\">\n \n
    \n
    \n
    \n\n \n {workbench.popover && \n
    \n {workbench.popover.body()}\n
    \n }\n\n\n {\n if (workbench.dialog.explicitClose === true) {\n e.preventDefault();\n return;\n }\n // resets body\n workbench.dialog.body = () => null;\n }}\n onclick={e => {\n const dialog = e.target.closest(\"dialog\");\n const rect = dialog.getBoundingClientRect();\n const zeroClick = (e.clientX == 0 && e.clientY == 0); // clicking select dropdown gives 0,0\n if ((workbench.dialog.explicitClose !== true) && (\n e.clientX < rect.left ||\n e.clientX > rect.right ||\n e.clientY < rect.top ||\n e.clientY > rect.bottom\n ) && !zeroClick) {\n workbench.closeDialog();\n }\n }}>\n {workbench.dialog.body()}\n \n\n {\n // resets body\n workbench.menu.body = () => null;\n }}\n onclick={e => {\n const dialog = e.target.closest(\"dialog\");\n const rect = dialog.getBoundingClientRect();\n if (e.clientX < rect.left ||\n e.clientX > rect.right ||\n e.clientY < rect.top ||\n e.clientY > rect.bottom\n ) {\n workbench.closeMenu();\n }\n }}>\n {workbench.menu.body()}\n \n
    \n )\n }\n};\n\nconst NavNode: m.Component = {\n view ({attrs: {node, workbench, expanded, level}, state}) {\n state.expanded = (state.expanded === undefined) ? expanded : state.expanded;\n const expandable = (node.childCount > 0 && level < 3);\n const toggle = (e) => {\n if (!expandable) return;\n if (state.expanded) {\n state.expanded = false;\n } else {\n state.expanded = true;\n }\n e.stopPropagation();\n }\n const open = (e) => {\n const mobileNav = document.querySelector(\".mobile-nav\");\n if (mobileNav.offsetHeight) {\n document.querySelector(\".sidebar\").style.display = \"none\";\n }\n workbench.open(node);\n }\n return (\n
    \n
    \n \n {(expandable)\n ?(state.expanded)\n ? \n : \n :null}\n \n \n
    \n {node.name}\n
    \n
    \n {state.expanded && \n
    \n {node.children.filter(n => n.name !== \"\").map(n => )}\n
    \n }\n
    \n )\n }\n};\n", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class Checkbox {\n checked: boolean;\n\n constructor() {\n this.checked = false;\n }\n\n beforeEditor() {\n return CheckboxEditor;\n }\n}\n\nconst CheckboxEditor = {\n view({attrs: {node}}) {\n const toggleCheckbox = (e) => {\n const checkbox = node.getComponent(Checkbox);\n checkbox.checked = !checkbox.checked;\n node.changed();\n }\n return \n }\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\n\n@component\nexport class TextField {\n constructor() {\n \n }\n\n handleIcon(): any {\n return \n }\n}", "import { component } from \"../model/components.ts\";\nimport { Node } from \"../model/mod.ts\";\nimport { Workbench, Context } from \"../workbench/mod.ts\";\n\n@component\nexport class Clock {\n startedAt?: Date;\n log: Date[][];\n showLog: boolean;\n\n component?: Node;\n object?: Node;\n\n constructor() {\n this.log = [];\n this.showLog = false;\n }\n\n onAttach(node: Node) {\n this.component = node;\n this.object = node.parent;\n }\n\n\n fromJSON(obj: any) {\n if (obj.startedAt) {\n this.startedAt = new Date(obj.startedAt);\n }\n this.log = (obj.log||[]).map(entry => [new Date(entry[0]), new Date(entry[1])]);\n this.showLog = obj.showLog;\n }\n\n toJSON(key: string): any {\n return {\n startedAt: this.startedAt, \n log: this.log,\n showLog: this.showLog\n };\n }\n\n localTotal(): number {\n return this.log.map(this.entryDuration).reduce((acc, val) => acc+val, 0);\n }\n\n grandTotal(): number {\n let total = this.localTotal();\n if (this.object) {\n this.object.children.forEach(child => {\n if (child.hasComponent(Clock)) {\n total += child.getComponent(Clock).grandTotal();\n }\n });\n }\n return total;\n }\n\n start() {\n if (this.startedAt) return;\n this.startedAt = new Date();\n }\n\n stop() {\n if (!this.startedAt) return;\n let now = new Date();\n let diff = now.getTime() - this.startedAt.getTime();\n if (diff/1000 >= 60) {\n // only log if more than a minute\n this.log.push([this.startedAt, now]);\n }\n this.startedAt = undefined;\n }\n\n formatEntry(entry: Date[]): string {\n if (entry.length !== 2) return \"\";\n return `${this.formatDate(entry[0])} - ${new Intl.DateTimeFormat(\"en\", {\n timeStyle: \"short\",\n }).format(entry[1])}`;\n }\n\n // duration in seconds\n entryDuration(entry: Date[]): number {\n const a = entry[0];\n const b = entry[1] || new Date();\n return (b.getTime() - a.getTime()) / 1000;\n }\n\n formatDate(d?: Date): string {\n if (!d) {\n return \"\";\n }\n return new Intl.DateTimeFormat(\"en\", {\n dateStyle: \"short\",\n timeStyle: \"short\",\n }).format(d);\n }\n\n formatDuration(seconds: number): string {\n let dur = seconds / 60;\n let min = Math.floor(dur % 60);\n dur = dur / 60;\n let hrs = Math.floor(dur % 60);\n return `${hrs}:${min.toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping: false})}`;\n }\n\n afterEditor() {\n return ClockBadge;\n }\n\n belowEditor() {\n return ClockLog;\n }\n\n static initialize(workbench: Workbench) {\n workbench.commands.registerCommand({\n id: \"stop-clock\",\n title: \"Stop clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node.hasComponent(Clock)) {\n const clock = new Clock();\n ctx.node.addComponent(clock);\n }\n ctx.node.getComponent(Clock).stop();\n ctx.node.changed();\n }\n });\n workbench.keybindings.registerBinding({command: \"stop-clock\", key: \"meta+o\" });\n workbench.commands.registerCommand({\n id: \"start-clock\",\n title: \"Start clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node.hasComponent(Clock)) {\n const clock = new Clock();\n ctx.node.addComponent(clock);\n }\n ctx.node.getComponent(Clock).start();\n ctx.node.changed();\n }\n });\n workbench.keybindings.registerBinding({command: \"start-clock\", key: \"meta+i\" });\n workbench.commands.registerCommand({\n id: \"remove-clock\",\n title: \"Remove clock\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n if (ctx.node.hasComponent(Clock)) return true;\n return false;\n },\n action: (ctx: Context) => {\n ctx.node.removeComponent(Clock);\n }\n });\n }\n}\n\nconst ClockBadge = {\n view({attrs: {node}}) {\n const clock = node.getComponent(Clock);\n const toggleLog = () => {\n clock.showLog = !clock.showLog;\n node.changed();\n }\n if (!clock.showLog && clock.startedAt) {\n return (\n
    \n \n
    {clock.formatDuration(clock.entryDuration([clock.startedAt]))}
    \n
    \n )\n }\n return (\n
    \n \n
    {clock.formatDuration(clock.grandTotal())}
    \n
    \n )\n }\n}\n\nconst ClockLog = {\n view({attrs: {node}}) {\n const clock = node.getComponent(Clock);\n if (!clock.showLog) return;\n return (\n
    \n
    \n
    \n {clock.startedAt &&\n
    \n
    {clock.formatDate(clock.startedAt)} - ...
    \n
    \n \n
    {clock.formatDuration(clock.entryDuration([clock.startedAt]))}
    \n
    \n
    \n }\n {clock.log.toReversed().map(entry => (\n
    \n
    {clock.formatEntry(entry)}
    \n
    \n \n
    {clock.formatDuration(clock.entryDuration(entry))}
    \n
    \n
    \n ))}\n
    \n
    \n )\n }\n}\n", "import {RawNode} from \"../model/mod.ts\";\n\n\nexport class BrowserBackend {\n auth: null;\n index: SearchIndex;\n files: FileStore;\n\n constructor() {\n this.auth = null;\n this.files = new FileStore();\n if (window.MiniSearch) {\n this.index = new SearchIndex_MiniSearch();\n } else {\n this.index = new SearchIndex_Dumb();\n }\n }\n}\n\nexport class SearchIndex_MiniSearch {\n indexer: any; // MiniSearch\n\n constructor() {\n this.indexer = new MiniSearch({\n idField: \"ID\",\n fields: ['ID', 'Name', 'Value', 'Value.markdown'], // fields to index for full-text search\n storeFields: ['ID'], // fields to return with search results\n extractField: (document, fieldName) => {\n return fieldName.split('.').reduce((doc, key) => doc && doc[key], document);\n }\n });\n }\n\n index(node: RawNode) {\n if (this.indexer.has(node.ID)) {\n this.indexer.replace(node); \n } else {\n this.indexer.add(node);\n }\n }\n\n remove(id: string) {\n try {\n this.indexer.discard(id);\n } catch {}\n }\n\n search(query: string): string[] {\n const suggested = this.indexer.autoSuggest(query);\n if (suggested.length === 0) return [];\n return this.indexer.search(suggested[0].suggestion, {\n prefix: true,\n combineWith: 'AND',\n }).map(doc => doc.ID);\n }\n}\n\n\nexport class SearchIndex_Dumb {\n nodes: Record;\n\n constructor() {\n this.nodes = {};\n }\n\n index(node: RawNode) {\n this.nodes[node.ID] = node.Name;\n }\n\n remove(id: string) {\n delete this.nodes[id];\n }\n\n search(query: string): string[] {\n const results: string[] = [];\n for (const id in this.nodes) {\n if (this.nodes[id].includes(query)) {\n results.push(id);\n }\n }\n return results;\n }\n}\n\n\n\nexport class FileStore {\n async readFile(path: string): string|null {\n return localStorage.getItem(`treehouse:${path}`);\n }\n\n async writeFile(path: string, contents: string) {\n localStorage.setItem(`treehouse:${path}`, contents);\n }\n}", "\nimport { Authenticator, SearchIndex, FileStore } from \"./mod.ts\";\nimport { BrowserBackend } from \"./browser.ts\";\nimport { encode, decode } from 'https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.mjs';\n\nexport interface Options {\n domain: string; // domain used with username subdomain to produce repo name\n checkDomain: boolean; // redirect to user domain if it is not current location\n authFallbackURL?: string; // URL to redirect to if auth fails\n privateRepo?: boolean; // if the user workspace repo should be created private\n}\n\nexport class GitHubBackend {\n auth: Authenticator;\n\n index: SearchIndex;\n files: FileStore;\n\n loginURL: string;\n clientFactory: any; // Octokit class\n client: any; // Octokit instance\n user: User|null;\n shas: Record; // path => sha\n \n opts: Options;\n\n constructor(loginURL: string, octokit: any, opts?: Options) {\n this.loginURL = loginURL;\n this.clientFactory = octokit;\n this.auth = this;\n this.shas = {};\n\n this.opts = Object.assign({\n domain: \"treehouse.sh\",\n checkDomain: false,\n privateRepo: false\n }, opts || {});\n\n const localbackend = new BrowserBackend();\n this.index = localbackend.index;\n this.files = localbackend.files;\n\n \n }\n\n get repoName(): string {\n return `${this.user?.userID().toLowerCase()}.${this.opts.domain}`;\n }\n\n async initialize() {\n // delegate authorize callback to loginURL\n const code = new URL(location.href).searchParams.get(\"code\");\n if (code) {\n try {\n // remove ?code=... from URL\n const querystring = location.search.replace(/\\bcode=\\w+/, \"\").replace(/\\?$/, \"\");\n history.pushState({}, \"\", `${location.pathname}${querystring}`);\n \n const response = await fetch(this.loginURL, {\n method: \"POST\",\n mode: \"cors\",\n headers: {\"content-type\": \"application/json\"},\n body: JSON.stringify({ code })\n });\n \n const result = await response.json();\n if (result.error) {\n throw result.error;\n }\n \n localStorage.setItem(\"treehouse:gh-token\", result.token);\n \n } catch (e: Error) {\n this.reset();\n console.error(e);\n return;\n }\n }\n\n // capture access token if provided directly\n const token = new URL(location.href).searchParams.get(\"access_token\");\n if (token) {\n try {\n // remove ?access_token=... from URL\n const querystring = location.search.replace(/\\baccess_token=\\w+/, \"\").replace(/\\?$/, \"\");\n history.pushState({}, \"\", `${location.pathname}${querystring}`);\n \n localStorage.setItem(\"treehouse:gh-token\", token);\n } catch (e: Error) {\n this.reset();\n console.error(e);\n return;\n }\n }\n\n try {\n await this.authenticate();\n if (!this.user) {\n throw \"authentication failed\";\n }\n } catch (e: Error) {\n console.error(e);\n if (this.opts.authFallbackURL) {\n location.href = this.opts.authFallbackURL;\n }\n return;\n }\n \n // check domain if set to\n if (this.opts.checkDomain && this.repoName !== location.hostname.toLowerCase()) {\n location.hostname = this.repoName;\n return;\n }\n\n // check if repo exists\n try {\n await this.client.rest.repos.get({\n owner: this.user.userID(), \n repo: this.repoName\n });\n } catch (e: Error) {\n if (e.message !== \"Not Found\") {\n throw e;\n }\n // create if not\n console.log(\"Creating repository...\");\n const resp = await this.client.rest.repos.createForAuthenticatedUser({name: this.repoName, private: this.opts.privateRepo});\n if (resp.status !== 201) {\n console.error(resp);\n return;\n }\n }\n\n // check for workspace.json now\n try {\n await this.client.rest.repos.getContent({\n owner: this.user.userID(), \n repo: this.repoName,\n path: \"workspace.json\"\n });\n } catch (e: Error) {\n if (e.name !== \"HttpError\") {\n throw e;\n }\n // create empty if not\n console.log(\"Creating workspace.json...\");\n const resp = await this.client.rest.repos.createOrUpdateFileContents({\n owner: this.user.userID(), \n repo: this.repoName,\n path: \"workspace.json\", \n message: \"initial commit\", \n content: btoa(JSON.stringify([]))\n });\n if (resp.status !== 201) {\n console.error(resp);\n return;\n }\n }\n \n this.files = this;\n\n \n \n const sessID = uniqueID();\n await this.readFile(\"treehouse.lock\");\n await this.writeFile(\"treehouse.lock\", sessID);\n const lockCheck = setInterval(async () => {\n const lockFile = await this.readFile(\"treehouse.lock\");\n if (lockFile !== sessID) {\n clearInterval(lockCheck);\n document.dispatchEvent(new CustomEvent(\"BackendError\"));\n console.warn(\"lock stolen!\");\n }\n }, 5000);\n }\n\n async loadExtensions() {\n try {\n const dirCheck = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: \"\",\n random: Math.random().toString(36).substring(2)\n });\n if (dirCheck.data.find(o => o.type === \"dir\" && o.name === \"ext\")) {\n const dirList = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: \"ext\",\n random: Math.random().toString(36).substring(2)\n });\n for (const file of dirList.data) {\n if (file.name.endsWith(\".css\")) {\n // Load CSS \n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: file.path,\n random: Math.random().toString(36).substring(2)\n });\n const css = document.createElement(\"link\");\n css.setAttribute(\"href\", `data:text/css;charset=utf-8;base64,${resp.data.content}`);\n css.setAttribute(\"rel\", \"stylesheet\");\n css.setAttribute(\"type\", \"text/css\");\n document.head.appendChild(css);\n } else if (file.name.endsWith(\".js\")) {\n // Load JavaScript\n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: file.path,\n random: Math.random().toString(36).substring(2)\n });\n const js = document.createElement(\"script\");\n js.setAttribute(\"type\", \"module\");\n js.setAttribute(\"src\", `data:text/javascript;charset=utf-8;base64,${resp.data.content}`);\n document.head.appendChild(js);\n }\n }\n }\n \n } catch (e: Error) {}\n \n }\n \n async authenticate() {\n const token = localStorage.getItem(\"treehouse:gh-token\");\n if (!token) {\n return;\n }\n\n this.client = new this.clientFactory({auth: token});\n const resp = await this.client.rest.users.getAuthenticated();\n if (!resp || resp.error) {\n return;\n }\n this.user = new User(resp.data);\n\n if(m)m.redraw();\n }\n\n currentUser(): User|null {\n return this.user;\n }\n\n login() {\n location.assign(this.loginURL);\n }\n\n reset() {\n localStorage.removeItem(\"treehouse:gh-token\");\n this.user = null;\n\n if(m)m.redraw();\n }\n \n logout() {\n this.reset();\n location.reload();\n }\n\n\n async readFile(path: string): string|null {\n try {\n const resp = await this.client.rest.repos.getContent({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: path,\n random: Math.random().toString(36).substring(2)\n });\n this.shas[path] = resp.data.sha;\n return decode(resp.data.content);\n } catch (e: Error) {\n if (e.name !== \"HttpError\") {\n console.error(e);\n }\n return null;\n }\n }\n\n async writeFile(path: string, contents: string) {\n const resp = await this.client.rest.repos.createOrUpdateFileContents({\n owner: this.user?.userID(), \n repo: this.repoName, \n path: path, \n message: \"autosave\", \n content: encode(contents), \n sha: this.shas[path]\n });\n this.shas[path] = resp.data.content.sha;\n }\n}\n\nexport class User {\n user: any; // github user object\n\n constructor(user: any) {\n this.user = user;\n }\n\n userID(): string {\n return this.user.login;\n }\n\n displayName(): string {\n return this.user.name;\n }\n\n avatarURL(): string {\n return this.user.avatar_url;\n }\n}\n\nfunction uniqueID() {\n const dateString = Date.now().toString(36);\n const randomness = Math.random().toString(36).substring(2);\n return dateString + randomness;\n};", "/**\n * A configurable, embeddable frontend for a graph/outline based note-taking tool.\n * \n * Treehouse can be embedded on a page and given a backend for a fully functional\n * SPA. The backend adapter provides hooks to integrate with various backends.\n * \n * Typical usage involves including resource dependencies on the page then running:\n * \n * ```ts\n * import {setup, BrowserBackend} from \"https://treehouse.sh/lib/treehouse.min.js\";\n * setup(document, document.body, new BrowserBackend());\n * ```\n * \n * In this case using the built-in BrowserBackend to store state in localStorage.\n * For more information see the [Quickstart Guide](https://treehouse.sh/docs/quickstart/).\n * \n * @module\n */\nimport { Path, Workbench } from \"./workbench/mod.ts\";\nimport { App } from \"./ui/app.tsx\";\nimport { Backend } from \"./backend/mod.ts\";\nimport { SmartNode } from \"./com/smartnode.tsx\";\nimport { Checkbox } from \"./com/checkbox.tsx\";\nimport { Page } from \"./com/page.tsx\";\nimport { TextField } from \"./com/textfield.tsx\";\nimport { Clock } from \"./com/clock.tsx\";\nimport { Tag } from \"./com/tag.tsx\";\nimport { Template } from \"./com/template.tsx\";\nimport { Document } from \"./com/document.tsx\";\nimport { objectManaged } from \"./model/hooks.ts\";\n\nexport { BrowserBackend, SearchIndex_MiniSearch } from \"./backend/browser.ts\";\nexport { GitHubBackend } from \"./backend/github.ts\";\n\n\n/**\n * setup initializes and mounts a workbench UI with a given backend adapter to a document.\n * More specifically, first it initializes the given backend, then creates and initializes\n * a Workbench instance with that backend, then it mounts the App component to the given\n * target element. It will also add some event listeners to the document and currently\n * this is where it registers all the built-in commands and their keybindings, as well\n * as menus. \n */\nexport async function setup(document: Document, target: HTMLElement, backend: Backend) {\n if (backend.initialize) {\n await backend.initialize();\n }\n\n const workbench = new Workbench(backend);\n window.workbench = workbench;\n\n await workbench.initialize();\n\n // TODO: better way to initialize components? \n [\n Clock,\n TextField,\n Page,\n Document,\n Checkbox,\n Tag,\n Template,\n SmartNode,\n ].forEach(com => {\n if (com.initialize) {\n com.initialize(workbench);\n }\n });\n\n\n // pretty specific to github backend right now\n document.addEventListener(\"BackendError\", () => {\n workbench.showNotice(\"lockstolen\", () => {\n location.reload();\n });\n });\n\n workbench.commands.registerCommand({\n id: \"cut\",\n title: \"Cut\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n \n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"cut\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"cut\", key: \"meta+x\" });\n\n workbench.commands.registerCommand({\n id: \"copy\",\n title: \"Copy\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n\n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"copy\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"copy\", key: \"meta+c\" });\n\n workbench.commands.registerCommand({\n id: \"copy-reference\",\n title: \"Copy as Reference\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n \n // no text is selected\n const input = workbench.getInput(ctx.path);\n if (input && input.selectionStart === input.selectionEnd) {\n return true;\n }\n\n // builtin copy is being performed,\n // clear clipboard so it doesn't override on paste\n workbench.clipboard = undefined;\n\n return false;\n },\n action: (ctx: Context) => {\n workbench.clipboard = {op: \"copyref\", node: ctx.node};\n }\n });\n workbench.keybindings.registerBinding({ command: \"copy-reference\", key: \"shift+ctrl+c\" });\n\n workbench.commands.registerCommand({\n id: \"paste\",\n title: \"Paste\",\n when: (ctx: Context) => {\n if (workbench.clipboard) {\n return true;\n }\n return false;\n },\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n switch (workbench.clipboard.op) {\n case \"copy\":\n workbench.clipboard.node = workbench.clipboard.node.duplicate();\n break;\n case \"copyref\":\n const ref = workbench.workspace.new(\"\");\n ref.refTo = workbench.clipboard.node;\n workbench.clipboard.node = ref;\n break;\n }\n if (workbench.clipboard.node.raw.Rel === \"Fields\") {\n workbench.clipboard.node.raw.Parent = ctx.node.parent.id;\n ctx.node.parent.addLinked(\"Fields\", workbench.clipboard.node);\n } else {\n workbench.clipboard.node.parent = ctx.node.parent;\n workbench.clipboard.node.siblingIndex = ctx.node.siblingIndex; \n }\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(workbench.clipboard.node));\n }\n });\n workbench.keybindings.registerBinding({ command: \"paste\", key: \"meta+v\" });\n\n\n\n workbench.commands.registerCommand({\n id: \"view-list\",\n title: \"View as List\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"list\");\n }\n });\n\n workbench.commands.registerCommand({\n id: \"view-table\",\n title: \"View as Table\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"table\");\n ctx.node.children.forEach(child => {\n workbench.workspace.setExpanded(ctx.path.head, child, false);\n });\n }\n });\n\n workbench.commands.registerCommand({\n id: \"view-tabs\",\n title: \"View as Tabs\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n ctx.node.setAttr(\"view\", \"tabs\");\n }\n });\n\n\n workbench.commands.registerCommand({\n id: \"add-checkbox\",\n title: \"Add checkbox\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const checkbox = new Checkbox();\n ctx.node.addComponent(checkbox);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"remove-checkbox\",\n title: \"Remove checkbox\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n if (ctx.node.hasComponent(Checkbox)) return true;\n return false;\n },\n action: (ctx: Context) => {\n ctx.node.removeComponent(Checkbox);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"create-field\",\n title: \"Create Field\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.childCount > 0) return;\n if (ctx.node.componentCount > 0) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const path = ctx.path.clone();\n path.pop(); // drop node\n const field = workbench.workspace.new(ctx.node.name, \"\");\n field.raw.Parent = ctx.node.parent.id;\n const text = new TextField();\n field.addComponent(text);\n ctx.node.parent.addLinked(\"Fields\", field);\n path.push(field);\n ctx.node.destroy();\n m.redraw.sync();\n workbench.focus(path);\n }\n });\n\n workbench.commands.registerCommand({\n id: \"mark-done\",\n title: \"Mark Done\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.hasComponent(Checkbox)) {\n const checkbox = ctx.node.getComponent(Checkbox);\n if (!checkbox.checked) {\n checkbox.checked = true;\n ctx.node.changed();\n } else {\n ctx.node.removeComponent(Checkbox);\n }\n } else {\n const checkbox = new Checkbox();\n ctx.node.addComponent(checkbox);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"mark-done\", key: \"meta+enter\" });\n\n\n\n workbench.commands.registerCommand({\n id: \"expand\",\n title: \"Expand\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n m.redraw();\n }\n });\n workbench.keybindings.registerBinding({ command: \"expand\", key: \"meta+arrowdown\" });\n workbench.commands.registerCommand({\n id: \"collapse\",\n title: \"Collapse\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, false);\n m.redraw();\n }\n });\n workbench.keybindings.registerBinding({ command: \"collapse\", key: \"meta+arrowup\" });\n workbench.commands.registerCommand({\n id: \"indent\",\n title: \"Indent\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const node = ctx.node; // redraw seems to unset ctx.node\n const path = ctx.path.clone();\n let prev = node.prevSibling;\n while (prev && objectManaged(prev)) {\n prev = prev.prevSibling;\n if (!prev) return;\n }\n if (prev !== null) {\n path.pop(); // drop node\n path.push(prev);\n node.parent = prev;\n path.push(node);\n workbench.workspace.setExpanded(ctx.path.head, prev, true);\n m.redraw.sync();\n workbench.focus(path);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"indent\", key: \"tab\" });\n workbench.commands.registerCommand({\n id: \"outdent\",\n title: \"Outdent\",\n when: (ctx: Context) => {\n if (!ctx.node) return false;\n if (ctx.node.raw.Rel === \"Fields\") return false;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return false;\n if (ctx.node.parent && ctx.node.parent.hasComponent(Document)) return false;\n return true;\n },\n action: (ctx: Context) => {\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = ctx.path.previous;\n const path = ctx.path.clone();\n if (parent !== null && parent.id !== \"@root\" && parent.id !== workbench.workspace.lastOpenedID) {\n path.pop(); // drop node\n path.pop(); // drop parent\n node.parent = parent.parent;\n path.push(node);\n node.siblingIndex = parent.siblingIndex + 1;\n if (parent.childCount === 0 && parent.getLinked(\"Fields\").length === 0) {\n workbench.workspace.setExpanded(ctx.path.head, parent, false);\n }\n m.redraw.sync();\n workbench.focus(path);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"outdent\", key: \"shift+tab\" });\n workbench.commands.registerCommand({\n id: \"move-up\",\n title: \"Move Up\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = node.parent;\n if (parent !== null && parent.id !== \"@root\") {\n const children = parent.childCount;\n if (node.siblingIndex === 0) {\n if (!parent.prevSibling) {\n return;\n }\n const p = ctx.path.clone();\n p.pop(); // drop node\n p.pop(); // drop parent\n let parentSib = parent.prevSibling;\n while (parentSib && objectManaged(parentSib)) {\n parentSib = parentSib.prevSibling;\n if (!parentSib) return;\n }\n p.push(parentSib);\n p.push(node);\n node.parent = parentSib;\n node.siblingIndex = parentSib.childCount - 1;\n workbench.workspace.setExpanded(ctx.path.head, parentSib, true);\n m.redraw.sync();\n workbench.focus(p);\n } else {\n if (children === 1) {\n return;\n }\n node.siblingIndex = node.siblingIndex - 1;\n m.redraw.sync();\n }\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"move-up\", key: \"shift+meta+arrowup\" });\n workbench.commands.registerCommand({\n id: \"move-down\",\n title: \"Move Down\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const node = ctx.node; // redraw seems to unset ctx.node\n const parent = node.parent;\n if (parent !== null && parent.id !== \"@root\") {\n const children = parent.childCount;\n // if last child\n if (node.siblingIndex === children - 1) {\n if (!parent.nextSibling) {\n return;\n }\n const p = ctx.path.clone();\n p.pop(); // drop node\n p.pop(); // drop parent\n let parentSib = parent.nextSibling;\n while (parentSib && objectManaged(parentSib)) {\n parentSib = parentSib.nextSibling;\n if (!parentSib) return;\n }\n p.push(parentSib);\n p.push(node);\n node.parent = parentSib;\n node.siblingIndex = 0;\n workbench.workspace.setExpanded(ctx.path.head, parentSib, true);\n m.redraw.sync();\n workbench.focus(p);\n } else {\n if (children === 1) {\n return;\n }\n node.siblingIndex = node.siblingIndex + 1;\n m.redraw.sync();\n }\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"move-down\", key: \"shift+meta+arrowdown\" });\n workbench.commands.registerCommand({\n id: \"insert-child\",\n title: \"Insert Child\",\n action: (ctx: Context, name: string = \"\", siblingIndex?: number) => {\n if (!ctx.node) return;\n if (objectManaged(ctx.node)) return;\n const node = workbench.workspace.new(name);\n node.parent = ctx.node;\n if (siblingIndex !== undefined) {\n node.siblingIndex = siblingIndex;\n }\n workbench.workspace.setExpanded(ctx.path.head, ctx.node, true);\n m.redraw.sync();\n workbench.focus(ctx.path.append(node), name.length);\n }\n });\n workbench.commands.registerCommand({\n id: \"insert-before\",\n title: \"Insert Before\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(\"\");\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.commands.registerCommand({\n id: \"insert\",\n title: \"Insert Node\",\n action: (ctx: Context, name: string = \"\") => {\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(name);\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex + 1;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.keybindings.registerBinding({ command: \"insert\", key: \"shift+enter\" });\n workbench.commands.registerCommand({\n id: \"create-reference\",\n title: \"Create Reference\",\n action: (ctx: Context) => {\n // TODO: prevent creating reference to reference\n if (!ctx.node) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return;\n const node = workbench.workspace.new(\"\");\n node.parent = ctx.node.parent;\n node.siblingIndex = ctx.node.siblingIndex + 1;\n node.refTo = ctx.node;\n m.redraw.sync();\n const p = ctx.path.clone();\n p.pop();\n workbench.focus(p.append(node));\n }\n });\n workbench.commands.registerCommand({\n id: \"delete\",\n title: \"Delete Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n if (ctx.node.id.startsWith(\"@\")) return;\n if (ctx.path.previous && objectManaged(ctx.path.previous)) return; // should probably provide feedback or disable delete\n const above = workbench.workspace.findAbove(ctx.path);\n ctx.node.destroy();\n m.redraw.sync();\n if (above) {\n let pos = 0;\n if (ctx.event && ctx.event.key === \"Backspace\") {\n if (above.node.value) {\n pos = above.node.value.length;\n } else {\n pos = above.node.name.length;\n }\n }\n if (above.node.childCount === 0) {\n // TODO: use subCount\n workbench.workspace.setExpanded(ctx.path.head, above.node, false);\n }\n workbench.focus(above, pos);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"delete\", key: \"shift+meta+backspace\" });\n workbench.commands.registerCommand({\n id: \"prev\",\n title: \"Previous Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const above = workbench.workspace.findAbove(ctx.path);\n if (above) {\n workbench.focus(above);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"prev\", key: \"arrowup\" });\n workbench.commands.registerCommand({\n id: \"next\",\n title: \"Next Node\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n const below = workbench.workspace.findBelow(ctx.path);\n if (below) {\n workbench.focus(below);\n }\n }\n });\n workbench.keybindings.registerBinding({ command: \"next\", key: \"arrowdown\" });\n workbench.commands.registerCommand({\n id: \"pick-command\",\n title: \"Command Palette\",\n hidden: true,\n when: (ctx: Context) => {\n if (workbench.isDialogOpen()) return false;\n return true;\n },\n action: (ctx: Context) => {\n let node = ctx.node;\n let path = ctx.path;\n let posBelow = false;\n if (!node) {\n // no node is selected, use panel node\n node = ctx.path.head;\n path = new Path(ctx.path.head, ctx.path.name);\n posBelow = true;\n }\n const trigger = workbench.getInput(path);\n const rect = trigger.getBoundingClientRect();\n let x = document.body.scrollLeft + rect.x + (trigger.selectionStart * 10) + 20;\n let y = document.body.scrollTop + rect.y - 8;\n if (trigger.coordsAtCursor) {\n x = trigger.coordsAtCursor.left-17;\n y = trigger.coordsAtCursor.top-16;\n }\n if (posBelow) {\n x = document.body.scrollLeft + rect.x;\n y = document.body.scrollTop + rect.y + rect.height;\n }\n workbench.showPalette(x, y, workbench.newContext({ node }));\n }\n });\n workbench.keybindings.registerBinding({ command: \"pick-command\", key: \"meta+k\" });\n workbench.commands.registerCommand({\n id: \"new-panel\",\n title: \"Open in New Panel\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n workbench.openNewPanel(ctx.node);\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"close-panel\",\n title: \"Close Panel\",\n action: (ctx: Context, panel?: Path) => {\n workbench.closePanel(panel || ctx.path);\n workbench.context.path = workbench.mainPanel;\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"zoom\",\n title: \"Open\",\n action: (ctx: Context) => {\n workbench.workspace.lastOpenedID = ctx.node.id;\n workbench.workspace.save();\n workbench.context.path = ctx.path.append(ctx.node);\n workbench.panels[0] = workbench.context.path;\n m.redraw();\n }\n });\n workbench.commands.registerCommand({\n id: \"generate-random\",\n hidden: true,\n title: \"Generate Random Children\",\n action: (ctx: Context) => {\n if (!ctx.node) return;\n [...Array(100)].forEach(() => {\n const node = workbench.workspace.new(generateName(8));\n node.parent = ctx.node;\n });\n }\n });\n\n\n\n workbench.menus.registerMenu(\"node\", [\n { command: \"zoom\" },\n { command: \"new-panel\" },\n { command: \"cut\" },\n { command: \"copy\" },\n { command: \"paste\" },\n { command: \"indent\" },\n { command: \"outdent\" },\n { command: \"move-up\" },\n { command: \"move-down\" },\n { command: \"delete\" },\n // {command: \"add-checkbox\"}, \n // {command: \"remove-checkbox\"},\n // {command: \"mark-done\"},\n // {command: \"add-page\"},\n // {command: \"remove-page\"},\n // {command: \"generate-random\"},\n // {command: \"create-reference\"},\n ]);\n\n workbench.menus.registerMenu(\"settings\", [\n { title: () => `${workbench.backend.auth?.currentUser()?.userID()} @ GitHub`, disabled: true, when: () => workbench.authenticated() },\n {\n title: () => \"Login with GitHub\", when: () => !workbench.authenticated(), onclick: () => {\n if (!localStorage.getItem(\"github\")) {\n workbench.showNotice(\"github\", () => {\n workbench.backend.auth.login()\n })\n } else {\n workbench.backend.auth.login()\n }\n }\n },\n {\n title: () => \"Reset Demo\", when: () => !workbench.authenticated(), onclick: () => {\n localStorage.clear();\n location.reload();\n }\n },\n { title: () => \"Settings\", onclick: () => workbench.showSettings() },\n { title: () => \"Documentation\", onclick: () => window.open(\"https://treehouse.sh/docs/user\", \"_blank\") },\n { title: () => \"Submit Issue\", onclick: () => window.open(\"https://github.com/treehousedev/treehouse/issues\", \"_blank\") },\n { title: () => \"Logout\", when: () => workbench.authenticated(), onclick: () => workbench.backend.auth.logout() },\n ]);\n\n document.addEventListener(\"keydown\", (e) => {\n const binding = workbench.keybindings.evaluateEvent(e);\n if (binding && workbench.canExecuteCommand(binding.command, workbench.context)) {\n workbench.executeCommand(binding.command, workbench.context);\n e.stopPropagation();\n e.preventDefault();\n return;\n }\n });\n\n\n m.mount(target, { view: () => m(App, { workbench }) });\n}\n\n\n\nfunction generateName(length = 10) {\n const random = (min: any, max: any) => {\n return Math.round(Math.random() * (max - min) + min)\n };\n const word = () => {\n const words = [\n 'got',\n 'ability',\n 'shop',\n 'recall',\n 'fruit',\n 'easy',\n 'dirty',\n 'giant',\n 'shaking',\n 'ground',\n 'weather',\n 'lesson',\n 'almost',\n 'square',\n 'forward',\n 'bend',\n 'cold',\n 'broken',\n 'distant',\n 'adjective'\n ];\n return words[random(0, words.length - 1)];\n };\n const words = (length) => (\n [...Array(length)]\n .map((_, i) => word())\n .join(' ')\n .trim()\n );\n return words(random(2, length))\n}\n"], + "mappings": "gQACA,IAAMA,GAAS,UAAU,UAAU,YAAY,EAAE,QAAQ,KAAK,IAAM,GAE7D,SAASC,EAAeC,EAAwB,CACrD,GAAI,CAACA,EAAK,MAAO,CAAC,EAClB,IAAMC,EAAU,CACd,UAAa,SACb,MAAS,SACT,KAAQ,SACR,IAAO,SACP,KAAQ,SACR,QAAW,SACX,UAAa,SACb,UAAa,SACb,WAAc,SACd,MAAS,QACX,EAEA,OADaD,EAAI,YAAY,EAAE,MAAM,GAAG,EAC5B,IAAIE,EAAsB,EAAE,IAAIC,GAAM,OAAO,KAAKF,CAAO,EAAE,SAASE,C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AC,EAEDH,EAAS,iBAAiB,UAAY0C,GAAM,CAC1C,IAAMC,EAAUxC,EAAU,YAAY,cAAcuC,CAAC,EACrD,GAAIC,GAAWxC,EAAU,kBAAkBwC,EAAQ,QAASxC,EAAU,OAAO,EAAG,CAC9EA,EAAU,eAAewC,EAAQ,QAASxC,EAAU,OAAO,EAC3DuC,EAAE,gBAAgB,EAClBA,EAAE,eAAe,EACjB,MACF,CACF,CAAC,EAGD,EAAE,MAAMzC,EAAQ,CAAE,KAAM,IAAM,EAAE2C,GAAK,CAAE,UAAAzC,CAAU,CAAC,CAAE,CAAC,CACvD,CAxqBsB0C,EAAA9C,GAAA,SA4qBtB,SAAS0C,GAAaK,EAAS,GAAI,CACjC,IAAMC,EAASF,EAAA,CAACG,EAAUC,IACjB,KAAK,MAAM,KAAK,OAAO,GAAKA,EAAMD,GAAOA,CAAG,EADtC,UAGTE,EAAOL,EAAA,IAAM,CACjB,IAAMM,EAAQ,CACZ,MACA,UACA,OACA,SACA,QACA,OACA,QACA,QACA,UACA,SACA,UACA,SACA,SACA,SACA,UACA,OACA,OACA,SACA,UACA,WACF,EACA,OAAOA,EAAMJ,EAAO,EAAGI,EAAM,OAAS,CAAC,CAAC,CAC1C,EAxBa,QA+Bb,OANcN,EAACC,GACb,CAAC,GAAG,MAAMA,CAAM,CAAC,EACd,IAAI,CAACM,EAAGC,IAAMH,EAAK,CAAC,EACpB,KAAK,GAAG,EACR,KAAK,EAJI,SAMDH,EAAO,EAAGD,CAAM,CAAC,CAChC,CApCSD,EAAAJ,GAAA", + "names": ["isMac", "bindingSymbols", "key", "symbols", "filterKeyForNonMacMeta", "k", "__name", "KeyBindings", "binding", "commandId", "b", "event", "bindings", "modifiers", "checkMod", "hasMod", "modState", "CommandRegistry", "cmd", "id", "rest", "resolve", "ret", "__name", "MenuRegistry", "id", "items", "__name", "isDisabled", "workbench", "item", "cmd", "ctx", "__name", "Menu", "x", "y", "items", "align", "commands", "onclick", "e", "i", "title", "binding", "c", "bindingSymbols", "Picker", "state", "dom", "items", "attrs", "onkeydown", "__name", "e", "mod", "a", "b", "oninput", "item", "idx", "CommandPalette", "workbench", "ctx", "getTitle", "__name", "cmd", "t", "sort", "a", "b", "onpick", "onchange", "state", "cmds", "getBindingSymbols", "binding", "bindingSymbols", "Picker", "onkeydown", "oninput", "hasHook", "node", "hook", "__name", "triggerHook", "args", "objectHas", "obj", "com", "objectCall", "componentsWith", "ret", "objectManaged", "registry", "component", "target", "componentName", "__name", "getComponent", "com", "inflateToComponent", "obj", "o", "duplicate", "src", "dst", "Document", "node", "collapsed", "key", "workbench", "ctx", "doc", "__name", "__decorateClass", "component", "NodeEditor", "workbench", "path", "onkeydown", "oninput", "disallowEmpty", "editValue", "placeholder", "state", "node", "prop", "display", "__name", "objectHas", "objectCall", "onfocus", "getter", "setter", "v", "finished", "id", "editor", "TextAreaEditor", "Document", "CodeMirrorEditor", "dom", "onblur", "value", "defaultKeydown", "e", "startEdit", "finishEdit", "edit", "attrs", "textarea", "initialHeight", "span", "height", "textData", "lines", "line", "newNode", "p", "empty_default", "node", "workbench", "panel", "NewNode", "workbench", "path", "__name", "e", "lastchild", "debounce", "func", "timeout", "timer", "args", "__name", "SmartNode", "collapsed", "SmartFilter", "node", "n", "results", "ref", "children", "key", "obj", "workbench", "ctx", "search", "__decorateClass", "component", "expanded", "oninput", "e", "list_default", "workbench", "path", "alwaysShowNew", "node", "showNew", "SmartNode", "n", "OutlineNode", "NewNode", "table_default", "workbench", "path", "state", "node", "n", "f", "getFieldEditor", "__name", "field", "fields", "NodeEditor", "OutlineNode", "tabs_default", "workbench", "path", "state", "node", "n", "handleTabClick", "__name", "id", "selectedNode", "getView", "document_default", "workbench", "path", "alwaysShowNew", "node", "showNew", "n", "OutlineNode", "NewNode", "views", "list_default", "table_default", "tabs_default", "document_default", "getView", "name", "empty_default", "__name", "view", "toTitleCase", "ctx", "str", "txt", "Template", "node", "collapsed", "key", "workbench", "ctx", "tmpl", "ws", "name", "n", "__name", "__decorateClass", "component", "Tag", "name", "TagBadge", "workbench", "ctx", "tag", "tmpl", "Template", "f", "c", "ws", "tags", "nodes", "n", "bench", "path", "node", "inputview", "closer", "trigger", "rect", "x", "y", "Picker", "item", "state", "filtered", "t", "__name", "__decorateClass", "component", "e", "OutlineEditor", "workbench", "path", "alwaysShowNew", "getView", "OutlineNode", "attrs", "state", "children", "node", "isRef", "handleNode", "isCut", "expanded", "placeholder", "objectHas", "objectCall", "hover", "__name", "e", "unhover", "cancelTagPopover", "oninput", "Tag", "onkeydown", "anyModifiers", "above", "oldName", "open", "toggle", "Document", "subCount", "n", "showHandle", "NodeEditor", "componentsWith", "component", "QuickAdd", "workbench", "node", "path", "Path", "OutlineEditor", "Settings", "workbench", "state", "currentTheme", "__name", "e", "LockStolenMessage", "FirstTimeMessage", "workbench", "GitHubMessage", "finished", "Workbench", "backend", "CommandRegistry", "KeyBindings", "MenuRegistry", "Workspace", "n", "com", "css", "node", "QuickAdd", "today", "dayNode", "weekNode", "getWeekOfYear", "todayPath", "todayNode", "p", "Path", "panel", "input", "path", "pos", "id", "el", "ctx", "rest", "event", "style", "trigger", "rect", "align", "items", "cmds", "i", "Menu", "x", "y", "CommandPalette", "notice", "finished", "FirstTimeMessage", "GitHubMessage", "LockStolenMessage", "Settings", "body", "backdrop", "explicitClose", "query", "splitQuery", "textQuery", "term", "fieldQuery", "passFieldQuery", "__name", "fields", "f", "Tag", "resultCache", "date", "d", "dayNum", "yearStart", "SHA1", "msg", "rotate_left", "n", "s", "t4", "__name", "lsb_hex", "val", "str", "i", "vh", "vl", "cvt_hex", "v", "Utf8Encode", "string", "utftext", "c", "blockstart", "j", "W", "H0", "H1", "H2", "H3", "H4", "A", "B", "C", "D", "E", "temp", "msg_len", "word_array", "Path", "head", "name", "node", "p", "SHA1", "n", "__name", "Bus", "n", "cb", "nodes", "getComponent", "inflateToComponent", "node", "triggerHook", "name", "value", "parent", "parts", "i", "child", "id", "uniqueId", "Node", "p", "rel", "root", "path", "byId", "cur", "findChild", "__name", "fn", "opts", "dateString", "randomness", "Node", "bus", "id", "raw", "val", "n", "p", "triggerHook", "rel", "i", "anc", "cur", "path", "children", "com", "hasHook", "node", "obj", "componentName", "coms", "getComponent", "type", "linked", "idx", "oldIdx", "name", "value", "fn", "opts", "child", "nodes", "duplicate", "f", "c", "__name", "Workspace", "fs", "Bus", "debounce", "path", "contents", "e", "fn", "immediate", "doc", "n", "i", "main", "root", "ws", "cal", "home", "name", "value", "head", "expanded", "b", "p", "prev", "fieldCount", "lastSubIfExpanded", "__name", "lastField", "lastChild", "nextSiblingOrParentNextSibling", "next", "parent", "func", "timeout", "timer", "args", "Drawer", "attrs", "children", "open", "Page", "__name", "__decorateClass", "component", "Panel", "attrs", "path", "workbench", "node", "close", "__name", "e", "goBack", "maximize", "editMarkdown", "Page", "calcHeight", "value", "viewClass", "NodeEditor", "OutlineEditor", "KeyboardReference", "attrs", "workbench", "shortcuts", "getBindingSymbols", "__name", "cmd", "binding", "bindingSymbols", "header", "ids", "id", "Search", "input", "workbench", "Picker", "__name", "node", "state", "onkeydown", "oninput", "value", "result", "App", "workbench", "state", "toggle", "__name", "e", "node", "NavNode", "input", "Search", "path", "Panel", "Drawer", "KeyboardReference", "sidebarStyle", "rect", "zeroClick", "expanded", "level", "expandable", "open", "n", "Checkbox", "CheckboxEditor", "__name", "__decorateClass", "component", "node", "e", "checkbox", "TextField", "__name", "__decorateClass", "component", "Clock", "node", "obj", "entry", "key", "acc", "val", "total", "child", "now", "a", "d", "seconds", "dur", "min", "ClockBadge", "ClockLog", "workbench", "ctx", "clock", "__name", "__decorateClass", "component", "toggleLog", "BrowserBackend", "FileStore", "SearchIndex_MiniSearch", "SearchIndex_Dumb", "__name", "document", "fieldName", "doc", "key", "node", "id", "query", "suggested", "results", "path", "contents", "encode", "decode", "GitHubBackend", "loginURL", "octokit", "opts", "localbackend", "BrowserBackend", "code", "querystring", "result", "e", "token", "resp", "sessID", "uniqueID", "lockCheck", "o", "dirList", "file", "css", "js", "User", "path", "decode", "contents", "encode", "__name", "user", "dateString", "randomness", "setup", "document", "target", "backend", "workbench", "Workbench", "Clock", "TextField", "Page", "Document", "Checkbox", "Tag", "Template", "SmartNode", "com", "ctx", "input", "objectManaged", "ref", "p", "child", "checkbox", "path", "field", "text", "node", "prev", "parent", "children", "parentSib", "name", "siblingIndex", "above", "pos", "below", "posBelow", "Path", "trigger", "rect", "x", "y", "panel", "generateName", "e", "binding", "App", "__name", "length", "random", "min", "max", "word", "words", "_", "i"] }