-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgithub.plug.json
executable file
·66 lines (66 loc) · 54.7 KB
/
github.plug.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
"name": "github",
"imports": [
"https://get.silverbullet.md/global.plug.json"
],
"functions": {
"queryEvents": {
"events": [
"query:gh-event"
],
"code": "(() => { var mod=(()=>{var S=Object.create;var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var x=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var w=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of L(e))!Y.call(r,i)&&i!==t&&p(r,i,{get:()=>e[i],enumerable:!(n=I(e,i))||n.enumerable});return r};var T=(r,e,t)=>(t=r!=null?S(R(r)):{},v(e||!r||!r.__esModule?p(t,\"default\",{value:r,enumerable:!0}):t,r)),D=r=>v(p({},\"__esModule\",{value:!0}),r);var J={};w(J,{default:()=>H});function g(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...g(n,e)];return t}function d(r,e){return g(r,t=>t.type===e)[0]}function P(r,e){g(r,e)}function A(r,e){let t=[];if(r.filter.length===0)t=e.slice();else{e:for(let n of e){let i=n;for(let{op:s,prop:a,value:c}of r.filter)switch(s){case\"=\":{let u=i[a];if(Array.isArray(u)&&!Array.isArray(c)){if(!u.includes(c))continue e}else if(Array.isArray(u)&&Array.isArray(c)){if(!u.some(O=>c.includes(O)))continue e}else if(u!=c)continue e;break}case\"!=\":if(i[a]==c)continue e;break;case\"<\":if(!(i[a]<c))continue e;break;case\"<=\":if(!(i[a]<=c))continue e;break;case\">\":if(!(i[a]>c))continue e;break;case\">=\":if(!(i[a]>=c))continue e;break;case\"=~\":if(!new RegExp(c).exec(i[a]))continue e;break;case\"!=~\":if(new RegExp(c).exec(i[a]))continue e;break;case\"in\":if(!c.includes(i[a]))continue e;break}t.push(i)}}return r.ordering.length>0&&(t=t.sort((n,i)=>{for(let{orderBy:s,orderDesc:a}of r.ordering){if(n[s]<i[s]||n[s]===void 0)return a?1:-1;if(n[s]>i[s]||i[s]===void 0)return a?-1:1}return 0})),r.limit&&(t=t.slice(0,r.limit)),r.select&&(t=t.map(n=>{let i={};for(let s of r.select)i[s]=n[s];return i})),t}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var o=self.syscall;var f={};w(f,{parseMarkdown:()=>Q});function Q(r){return o(\"markdown.parseMarkdown\",r)}var y=class{listPages(e=!1){return o(\"space.listPages\",e)}getPageMeta(e){return o(\"space.getPageMeta\",e)}readPage(e){return o(\"space.readPage\",e)}writePage(e,t){return o(\"space.writePage\",e,t)}deletePage(e){return o(\"space.deletePage\",e)}listPlugs(){return o(\"space.listPlugs\")}listAttachments(){return o(\"space.listAttachments\")}getAttachmentMeta(e){return o(\"space.getAttachmentMeta\",e)}readAttachment(e){return o(\"space.readAttachment\",e)}writeAttachment(e,t,n){return o(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return o(\"space.deleteAttachment\",e)}readFile(e,t){return o(\"space.readFile\",e,t)}getFileMeta(e){return o(\"space.getFileMeta\",e)}writeFile(e,t,n){return o(\"space.writeFile\",e,t,n)}deleteFile(e){return o(\"space.deleteFile\",e)}listFiles(e){return o(\"space.listFiles\",e)}},m=new y;var h=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function _(r,e){let t=await m.readPage(r),n=await f.parseMarkdown(t),i;return P(n,s=>{if(s.type!==\"FencedCode\")return!1;let a=d(s,\"CodeInfo\");if(e&&!a||e&&!e.includes(a.children[0].text))return!1;let c=d(s,\"CodeText\");return c?(i=c.children[0].text,!0):!1}),i}async function k(r,e=[\"yaml\"]){let t=await _(r,e);if(t!==void 0)try{return h.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function N(r){try{let e=await k(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let i=e[n];if(i)t.push(i);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function V(){try{let[r]=await N([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var l=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,i){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:i})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new l(await V())}};var E=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function F({query:r}){let e=await l.fromConfig(),t=r.filter.find(s=>s.prop===\"username\");if(!t)throw Error(\"No 'username' filter specified, this is mandatory\");let n=[];if(t.op===\"=\")n=[t.value];else if(t.op===\"in\")n=t.value;else throw new Error(`Unsupported operator ${t.op}`);let i=[];for(let s of await Promise.all(n.map(a=>e.listEvents(a))))i.push(...s);return r.filter.splice(r.filter.indexOf(t),1),A(r,i.map(s=>$(s)))}function $(r,e=\"\"){let t={};for(let[n,i]of Object.entries(r))e&&(n=e+\"_\"+n),i&&typeof i==\"object\"?t={...t,...$(i,n)}:t[n]=i;return t}var H=F;return D(J);})();\n return mod;})()"
},
"queryPulls": {
"events": [
"query:gh-pull"
],
"code": "(() => { var mod=(()=>{var S=Object.create;var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var x=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var w=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of L(e))!Y.call(r,i)&&i!==t&&p(r,i,{get:()=>e[i],enumerable:!(n=I(e,i))||n.enumerable});return r};var T=(r,e,t)=>(t=r!=null?S(R(r)):{},v(e||!r||!r.__esModule?p(t,\"default\",{value:r,enumerable:!0}):t,r)),D=r=>v(p({},\"__esModule\",{value:!0}),r);var J={};w(J,{default:()=>H});function g(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...g(n,e)];return t}function d(r,e){return g(r,t=>t.type===e)[0]}function P(r,e){g(r,e)}function A(r,e){let t=[];if(r.filter.length===0)t=e.slice();else{e:for(let n of e){let i=n;for(let{op:s,prop:a,value:c}of r.filter)switch(s){case\"=\":{let u=i[a];if(Array.isArray(u)&&!Array.isArray(c)){if(!u.includes(c))continue e}else if(Array.isArray(u)&&Array.isArray(c)){if(!u.some(O=>c.includes(O)))continue e}else if(u!=c)continue e;break}case\"!=\":if(i[a]==c)continue e;break;case\"<\":if(!(i[a]<c))continue e;break;case\"<=\":if(!(i[a]<=c))continue e;break;case\">\":if(!(i[a]>c))continue e;break;case\">=\":if(!(i[a]>=c))continue e;break;case\"=~\":if(!new RegExp(c).exec(i[a]))continue e;break;case\"!=~\":if(new RegExp(c).exec(i[a]))continue e;break;case\"in\":if(!c.includes(i[a]))continue e;break}t.push(i)}}return r.ordering.length>0&&(t=t.sort((n,i)=>{for(let{orderBy:s,orderDesc:a}of r.ordering){if(n[s]<i[s]||n[s]===void 0)return a?1:-1;if(n[s]>i[s]||i[s]===void 0)return a?-1:1}return 0})),r.limit&&(t=t.slice(0,r.limit)),r.select&&(t=t.map(n=>{let i={};for(let s of r.select)i[s]=n[s];return i})),t}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var o=self.syscall;var f={};w(f,{parseMarkdown:()=>Q});function Q(r){return o(\"markdown.parseMarkdown\",r)}var y=class{listPages(e=!1){return o(\"space.listPages\",e)}getPageMeta(e){return o(\"space.getPageMeta\",e)}readPage(e){return o(\"space.readPage\",e)}writePage(e,t){return o(\"space.writePage\",e,t)}deletePage(e){return o(\"space.deletePage\",e)}listPlugs(){return o(\"space.listPlugs\")}listAttachments(){return o(\"space.listAttachments\")}getAttachmentMeta(e){return o(\"space.getAttachmentMeta\",e)}readAttachment(e){return o(\"space.readAttachment\",e)}writeAttachment(e,t,n){return o(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return o(\"space.deleteAttachment\",e)}readFile(e,t){return o(\"space.readFile\",e,t)}getFileMeta(e){return o(\"space.getFileMeta\",e)}writeFile(e,t,n){return o(\"space.writeFile\",e,t,n)}deleteFile(e){return o(\"space.deleteFile\",e)}listFiles(e){return o(\"space.listFiles\",e)}},m=new y;var h=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function _(r,e){let t=await m.readPage(r),n=await f.parseMarkdown(t),i;return P(n,s=>{if(s.type!==\"FencedCode\")return!1;let a=d(s,\"CodeInfo\");if(e&&!a||e&&!e.includes(a.children[0].text))return!1;let c=d(s,\"CodeText\");return c?(i=c.children[0].text,!0):!1}),i}async function k(r,e=[\"yaml\"]){let t=await _(r,e);if(t!==void 0)try{return h.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function N(r){try{let e=await k(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let i=e[n];if(i)t.push(i);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function V(){try{let[r]=await N([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var l=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,i){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:i})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new l(await V())}};var E=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function F({query:r}){let e=await l.fromConfig(),t=r.filter.find(s=>s.prop===\"repo\");if(!t)throw Error(\"No 'repo' specified, this is mandatory\");r.filter.splice(r.filter.indexOf(t),1);let n=[];if(t.op===\"=\")n=[t.value];else if(t.op===\"in\")n=t.value;else throw new Error(`Unsupported operator ${t.op}`);let i=[];for(let s of await Promise.all(n.map(a=>e.listPulls(a,\"all\",\"updated\"))))i.push(...s);return i=A(r,i.map(s=>$(s))),i}function $(r,e=\"\"){let t={};for(let[n,i]of Object.entries(r))e&&(n=e+\"_\"+n),i&&typeof i==\"object\"?t={...t,...$(i,n)}:t[n]=i;return t}var H=F;return D(J);})();\n return mod;})()"
},
"queryNotifications": {
"events": [
"query:gh-notification"
],
"code": "(() => { var mod=(()=>{var S=Object.create;var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var x=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var w=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of L(e))!Y.call(r,i)&&i!==t&&p(r,i,{get:()=>e[i],enumerable:!(n=I(e,i))||n.enumerable});return r};var T=(r,e,t)=>(t=r!=null?S(R(r)):{},v(e||!r||!r.__esModule?p(t,\"default\",{value:r,enumerable:!0}):t,r)),D=r=>v(p({},\"__esModule\",{value:!0}),r);var J={};w(J,{default:()=>H});function g(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...g(n,e)];return t}function d(r,e){return g(r,t=>t.type===e)[0]}function P(r,e){g(r,e)}function A(r,e){let t=[];if(r.filter.length===0)t=e.slice();else{e:for(let n of e){let i=n;for(let{op:a,prop:c,value:s}of r.filter)switch(a){case\"=\":{let u=i[c];if(Array.isArray(u)&&!Array.isArray(s)){if(!u.includes(s))continue e}else if(Array.isArray(u)&&Array.isArray(s)){if(!u.some(O=>s.includes(O)))continue e}else if(u!=s)continue e;break}case\"!=\":if(i[c]==s)continue e;break;case\"<\":if(!(i[c]<s))continue e;break;case\"<=\":if(!(i[c]<=s))continue e;break;case\">\":if(!(i[c]>s))continue e;break;case\">=\":if(!(i[c]>=s))continue e;break;case\"=~\":if(!new RegExp(s).exec(i[c]))continue e;break;case\"!=~\":if(new RegExp(s).exec(i[c]))continue e;break;case\"in\":if(!s.includes(i[c]))continue e;break}t.push(i)}}return r.ordering.length>0&&(t=t.sort((n,i)=>{for(let{orderBy:a,orderDesc:c}of r.ordering){if(n[a]<i[a]||n[a]===void 0)return c?1:-1;if(n[a]>i[a]||i[a]===void 0)return c?-1:1}return 0})),r.limit&&(t=t.slice(0,r.limit)),r.select&&(t=t.map(n=>{let i={};for(let a of r.select)i[a]=n[a];return i})),t}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var o=self.syscall;var f={};w(f,{parseMarkdown:()=>Q});function Q(r){return o(\"markdown.parseMarkdown\",r)}var y=class{listPages(e=!1){return o(\"space.listPages\",e)}getPageMeta(e){return o(\"space.getPageMeta\",e)}readPage(e){return o(\"space.readPage\",e)}writePage(e,t){return o(\"space.writePage\",e,t)}deletePage(e){return o(\"space.deletePage\",e)}listPlugs(){return o(\"space.listPlugs\")}listAttachments(){return o(\"space.listAttachments\")}getAttachmentMeta(e){return o(\"space.getAttachmentMeta\",e)}readAttachment(e){return o(\"space.readAttachment\",e)}writeAttachment(e,t,n){return o(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return o(\"space.deleteAttachment\",e)}readFile(e,t){return o(\"space.readFile\",e,t)}getFileMeta(e){return o(\"space.getFileMeta\",e)}writeFile(e,t,n){return o(\"space.writeFile\",e,t,n)}deleteFile(e){return o(\"space.deleteFile\",e)}listFiles(e){return o(\"space.listFiles\",e)}},m=new y;var h=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function _(r,e){let t=await m.readPage(r),n=await f.parseMarkdown(t),i;return P(n,a=>{if(a.type!==\"FencedCode\")return!1;let c=d(a,\"CodeInfo\");if(e&&!c||e&&!e.includes(c.children[0].text))return!1;let s=d(a,\"CodeText\");return s?(i=s.children[0].text,!0):!1}),i}async function k(r,e=[\"yaml\"]){let t=await _(r,e);if(t!==void 0)try{return h.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function N(r){try{let e=await k(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let i=e[n];if(i)t.push(i);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function V(){try{let[r]=await N([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var l=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,i){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:i})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new l(await V())}};var E=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function F({query:r}){let t=await(await l.fromConfig()).listNotifications();return t=A(r,t.map(n=>$(n))),t}function $(r,e=\"\"){let t={};for(let[n,i]of Object.entries(r))e&&(n=e+\"_\"+n),i&&typeof i==\"object\"?t={...t,...$(i,n)}:t[n]=i;return t}var H=F;return D(J);})();\n return mod;})()"
},
"querySearchIssues": {
"events": [
"query:gh-search-issue"
],
"code": "(() => { var mod=(()=>{var S=Object.create;var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var x=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var w=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0})},v=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of L(e))!Y.call(r,i)&&i!==t&&p(r,i,{get:()=>e[i],enumerable:!(n=I(e,i))||n.enumerable});return r};var T=(r,e,t)=>(t=r!=null?S(R(r)):{},v(e||!r||!r.__esModule?p(t,\"default\",{value:r,enumerable:!0}):t,r)),D=r=>v(p({},\"__esModule\",{value:!0}),r);var J={};w(J,{default:()=>H});function g(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...g(n,e)];return t}function d(r,e){return g(r,t=>t.type===e)[0]}function P(r,e){g(r,e)}function A(r,e){let t=[];if(r.filter.length===0)t=e.slice();else{e:for(let n of e){let i=n;for(let{op:a,prop:s,value:c}of r.filter)switch(a){case\"=\":{let u=i[s];if(Array.isArray(u)&&!Array.isArray(c)){if(!u.includes(c))continue e}else if(Array.isArray(u)&&Array.isArray(c)){if(!u.some(O=>c.includes(O)))continue e}else if(u!=c)continue e;break}case\"!=\":if(i[s]==c)continue e;break;case\"<\":if(!(i[s]<c))continue e;break;case\"<=\":if(!(i[s]<=c))continue e;break;case\">\":if(!(i[s]>c))continue e;break;case\">=\":if(!(i[s]>=c))continue e;break;case\"=~\":if(!new RegExp(c).exec(i[s]))continue e;break;case\"!=~\":if(new RegExp(c).exec(i[s]))continue e;break;case\"in\":if(!c.includes(i[s]))continue e;break}t.push(i)}}return r.ordering.length>0&&(t=t.sort((n,i)=>{for(let{orderBy:a,orderDesc:s}of r.ordering){if(n[a]<i[a]||n[a]===void 0)return s?1:-1;if(n[a]>i[a]||i[a]===void 0)return s?-1:1}return 0})),r.limit&&(t=t.slice(0,r.limit)),r.select&&(t=t.map(n=>{let i={};for(let a of r.select)i[a]=n[a];return i})),t}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var o=self.syscall;var f={};w(f,{parseMarkdown:()=>Q});function Q(r){return o(\"markdown.parseMarkdown\",r)}var y=class{listPages(e=!1){return o(\"space.listPages\",e)}getPageMeta(e){return o(\"space.getPageMeta\",e)}readPage(e){return o(\"space.readPage\",e)}writePage(e,t){return o(\"space.writePage\",e,t)}deletePage(e){return o(\"space.deletePage\",e)}listPlugs(){return o(\"space.listPlugs\")}listAttachments(){return o(\"space.listAttachments\")}getAttachmentMeta(e){return o(\"space.getAttachmentMeta\",e)}readAttachment(e){return o(\"space.readAttachment\",e)}writeAttachment(e,t,n){return o(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return o(\"space.deleteAttachment\",e)}readFile(e,t){return o(\"space.readFile\",e,t)}getFileMeta(e){return o(\"space.getFileMeta\",e)}writeFile(e,t,n){return o(\"space.writeFile\",e,t,n)}deleteFile(e){return o(\"space.deleteFile\",e)}listFiles(e){return o(\"space.listFiles\",e)}},m=new y;var h=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function _(r,e){let t=await m.readPage(r),n=await f.parseMarkdown(t),i;return P(n,a=>{if(a.type!==\"FencedCode\")return!1;let s=d(a,\"CodeInfo\");if(e&&!s||e&&!e.includes(s.children[0].text))return!1;let c=d(a,\"CodeText\");return c?(i=c.children[0].text,!0):!1}),i}async function k(r,e=[\"yaml\"]){let t=await _(r,e);if(t!==void 0)try{return h.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function N(r){try{let e=await k(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let i=e[n];if(i)t.push(i);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function V(){try{let[r]=await N([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var l=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,i){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:i})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new l(await V())}};var E=T(x(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function F({query:r}){let e=await l.fromConfig(),t=r.filter.find(s=>s.prop===\"query\");if(!t)throw Error(\"No 'query' specified, this is mandatory\");r.filter=r.filter.filter(s=>s.prop!==\"query\");let n=\"\";if(t.op===\"=\")n=t.value;else throw new Error(`Unsupported operator ${t.op}`);let i=await e.searchIssues(n);return A(r,i.items.map(s=>$(s)))}function $(r,e=\"\"){let t={};for(let[n,i]of Object.entries(r))e&&(n=e+\"_\"+n),i&&typeof i==\"object\"?t={...t,...$(i,n)}:t[n]=i;return t}var H=F;return D(J);})();\n return mod;})()"
},
"shareGistCommand": {
"command": {
"name": "Share: Gist: Public Gist"
},
"code": "(() => { var mod=(()=>{var Y=Object.create;var x=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var F=(e=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(e,{get:(t,r)=>(typeof require!=\"undefined\"?require:t)[r]}):e)(function(e){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+e+'\" is not supported')});var w=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},$=(e,t,r,i)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let o of D(t))!j.call(e,o)&&o!==r&&x(e,o,{get:()=>t[o],enumerable:!(i=G(t,o))||i.enumerable});return e};var O=(e,t,r)=>(r=e!=null?Y(U(e)):{},$(t||!e||!e.__esModule?x(r,\"default\",{value:e,enumerable:!0}):r,e)),Q=e=>$(x({},\"__esModule\",{value:!0}),e);var Ce={};w(Ce,{default:()=>Ae});function b(e){if(!!e.children)for(let t of e.children){if(t.parent)return;t.parent=e,b(t)}}function A(e,t){if(t(e))return[e];let r=[];if(e.children)for(let i of e.children)r=[...r,...A(i,t)];return r}function v(e,t){if(e.children){let r=e.children.slice();for(let i of r){let o=t(i);if(o!==void 0){let s=e.children.indexOf(i);o?e.children.splice(s,1,o):e.children.splice(s,1)}else v(i,t)}}}function T(e,t){return A(e,r=>r.type===t)[0]}function C(e,t){A(e,t)}function f(e){let t=[];if(e.text!==void 0)return e.text;for(let r of e.children)t.push(f(r));return t.join(\"\")}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var n=self.syscall;var a={};w(a,{confirm:()=>fe,dispatch:()=>le,downloadFile:()=>ee,filterBox:()=>re,flashNotification:()=>te,getCurrentPage:()=>B,getCursor:()=>H,getSelection:()=>J,getText:()=>V,getUiOption:()=>pe,hidePanel:()=>ie,insertAtCursor:()=>ce,insertAtPos:()=>oe,moveCursor:()=>ae,navigate:()=>X,openUrl:()=>K,prompt:()=>ue,reloadPage:()=>Z,replaceRange:()=>se,save:()=>z,setPage:()=>_,setSelection:()=>W,setUiOption:()=>de,showPanel:()=>ne,vimEx:()=>me});function B(){return n(\"editor.getCurrentPage\")}function _(e){return n(\"editor.setPage\",e)}function V(){return n(\"editor.getText\")}function H(){return n(\"editor.getCursor\")}function J(){return n(\"editor.getSelection\")}function W(e,t){return n(\"editor.setSelection\",e,t)}function z(){return n(\"editor.save\")}function X(e,t,r=!1,i=!1){return n(\"editor.navigate\",e,t,r,i)}function Z(){return n(\"editor.reloadPage\")}function K(e){return n(\"editor.openUrl\",e)}function ee(e,t){return n(\"editor.downloadFile\",e,t)}function te(e,t=\"info\"){return n(\"editor.flashNotification\",e,t)}function re(e,t,r=\"\",i=\"\"){return n(\"editor.filterBox\",e,t,r,i)}function ne(e,t,r,i=\"\"){return n(\"editor.showPanel\",e,t,r,i)}function ie(e){return n(\"editor.hidePanel\",e)}function oe(e,t){return n(\"editor.insertAtPos\",e,t)}function se(e,t,r){return n(\"editor.replaceRange\",e,t,r)}function ae(e,t=!1){return n(\"editor.moveCursor\",e,t)}function ce(e){return n(\"editor.insertAtCursor\",e)}function le(e){return n(\"editor.dispatch\",e)}function ue(e,t=\"\"){return n(\"editor.prompt\",e,t)}function fe(e){return n(\"editor.confirm\",e)}function pe(e){return n(\"editor.getUiOption\",e)}function de(e,t){return n(\"editor.setUiOption\",e,t)}function me(e){return n(\"editor.vimEx\",e)}var d={};w(d,{parseMarkdown:()=>Pe});function Pe(e){return n(\"markdown.parseMarkdown\",e)}var M=class{listPages(t=!1){return n(\"space.listPages\",t)}getPageMeta(t){return n(\"space.getPageMeta\",t)}readPage(t){return n(\"space.readPage\",t)}writePage(t,r){return n(\"space.writePage\",t,r)}deletePage(t){return n(\"space.deletePage\",t)}listPlugs(){return n(\"space.listPlugs\")}listAttachments(){return n(\"space.listAttachments\")}getAttachmentMeta(t){return n(\"space.getAttachmentMeta\",t)}readAttachment(t){return n(\"space.readAttachment\",t)}writeAttachment(t,r,i){return n(\"space.writeAttachment\",t,r,i)}deleteAttachment(t){return n(\"space.deleteAttachment\",t)}readFile(t,r){return n(\"space.readFile\",t,r)}getFileMeta(t){return n(\"space.getFileMeta\",t)}writeFile(t,r,i){return n(\"space.writeFile\",t,r,i)}deleteFile(t){return n(\"space.deleteFile\",t)}listFiles(t){return n(\"space.listFiles\",t)}},k=new M;var m={};w(m,{getEnv:()=>Te,invokeCommand:()=>xe,invokeFunction:()=>he,listCommands:()=>we,reloadPlugs:()=>ve});function he(e,t,...r){return n(\"system.invokeFunction\",e,t,...r)}function xe(e){return n(\"system.invokeCommand\",e)}function we(){return n(\"system.listCommands\")}function ve(){n(\"system.reloadPlugs\")}function Te(){return n(\"system.getEnv\")}var S=O(F(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));var c=O(F(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));function I(e,t=[]){let r={};return b(e),v(e,i=>{if(i.type===\"Hashtag\"){if(i.parent&&i.parent.type===\"Paragraph\"){let u=i.children[0].text.substring(1);r.tags||(r.tags=[]),Array.isArray(r.tags)&&!r.tags.includes(u)&&r.tags.push(u)}return}if(i.type===\"FrontMatter\"){let u=i.children[1].children[0],P=f(u);try{let y=c.parse(P),h={...y};if(r={...r,...y},t.length>0){let N=!1;for(let E of t)E in h&&(delete h[E],N=!0);N&&(u.text=c.stringify(h))}if(Object.keys(h).length===0)return null}catch(y){console.error(\"Could not parse frontmatter\",y)}}if(i.type!==\"FencedCode\")return;let o=T(i,\"CodeInfo\");if(!o||o.children[0].text!==\"meta\")return;let s=T(i,\"CodeText\");if(!s)return;let p=s.children[0].text,l=c.parse(p),g={...l};if(r={...r,...l},t.length>0){let u=!1;for(let P of t)P in g&&(delete g[P],u=!0);u&&(s.children[0].text=c.stringify(g).trim())}if(Object.keys(g).length===0)return null}),r.name&&(r.displayName=r.name,delete r.name),r}function L(e,t){let r=null;return C(e,i=>{if(i.type===\"FrontMatter\"){let o=i.children[1].children[0],s=f(o);try{let l={...c.parse(s),...t};r={changes:{from:o.from,to:o.to,insert:c.stringify(l,{noArrayIndent:!0})}}}catch(p){console.error(\"Error parsing YAML\",p)}return!0}return!1}),r||(r={changes:{from:0,to:0,insert:`---\n`+c.stringify(t,{noArrayIndent:!0})+`---\n`}}),r}async function R(){let e=await a.getCurrentPage(),t=await a.getText(),r=await d.parseMarkdown(t),{$share:i}=I(r,[\"$share\"]),o=f(r);i||(i=[]);for(let l of i)if(l.startsWith(\"gh-gist:\")){await m.invokeFunction(\"server\",\"updateGist\",{name:e,uri:l}),await a.flashNotification(\"Updated!\"),await a.openUrl(`https://gist.github.com/${l.split(\":\")[1]}`);return}let s=await m.invokeFunction(\"server\",\"createGist\",e,o),p=L(r,{$share:[...i,`gh-gist:${s}`]});await a.flashNotification(\"Done!\"),await a.dispatch(p),await a.openUrl(`https://gist.github.com/${s}`)}var Ae=R;return Q(Ce);})();\n return mod;})()"
},
"loadGistCommand": {
"command": {
"name": "Share: Gist: Load"
},
"code": "(() => { var mod=(()=>{var T=Object.create;var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var m=(t=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(t,{get:(e,n)=>(typeof require!=\"undefined\"?require:e)[n]}):t)(function(t){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+t+'\" is not supported')});var f=(t,e)=>{for(var n in e)a(t,n,{get:e[n],enumerable:!0})},g=(t,e,n,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of A(e))!M.call(t,o)&&o!==n&&a(t,o,{get:()=>e[o],enumerable:!(i=b(e,o))||i.enumerable});return t};var P=(t,e,n)=>(n=t!=null?T(C(t)):{},g(e||!t||!t.__esModule?a(n,\"default\",{value:t,enumerable:!0}):n,t)),k=t=>g(a({},\"__esModule\",{value:!0}),t);var pe={};f(pe,{default:()=>fe});typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var r=self.syscall;var s={};f(s,{confirm:()=>X,dispatch:()=>W,downloadFile:()=>U,filterBox:()=>Q,flashNotification:()=>j,getCurrentPage:()=>F,getCursor:()=>S,getSelection:()=>I,getText:()=>O,getUiOption:()=>Z,hidePanel:()=>B,insertAtCursor:()=>J,insertAtPos:()=>_,moveCursor:()=>H,navigate:()=>Y,openUrl:()=>D,prompt:()=>z,reloadPage:()=>G,replaceRange:()=>V,save:()=>R,setPage:()=>$,setSelection:()=>L,setUiOption:()=>K,showPanel:()=>q,vimEx:()=>ee});function F(){return r(\"editor.getCurrentPage\")}function $(t){return r(\"editor.setPage\",t)}function O(){return r(\"editor.getText\")}function S(){return r(\"editor.getCursor\")}function I(){return r(\"editor.getSelection\")}function L(t,e){return r(\"editor.setSelection\",t,e)}function R(){return r(\"editor.save\")}function Y(t,e,n=!1,i=!1){return r(\"editor.navigate\",t,e,n,i)}function G(){return r(\"editor.reloadPage\")}function D(t){return r(\"editor.openUrl\",t)}function U(t,e){return r(\"editor.downloadFile\",t,e)}function j(t,e=\"info\"){return r(\"editor.flashNotification\",t,e)}function Q(t,e,n=\"\",i=\"\"){return r(\"editor.filterBox\",t,e,n,i)}function q(t,e,n,i=\"\"){return r(\"editor.showPanel\",t,e,n,i)}function B(t){return r(\"editor.hidePanel\",t)}function _(t,e){return r(\"editor.insertAtPos\",t,e)}function V(t,e,n){return r(\"editor.replaceRange\",t,e,n)}function H(t,e=!1){return r(\"editor.moveCursor\",t,e)}function J(t){return r(\"editor.insertAtCursor\",t)}function W(t){return r(\"editor.dispatch\",t)}function z(t,e=\"\"){return r(\"editor.prompt\",t,e)}function X(t){return r(\"editor.confirm\",t)}function Z(t){return r(\"editor.getUiOption\",t)}function K(t,e){return r(\"editor.setUiOption\",t,e)}function ee(t){return r(\"editor.vimEx\",t)}var d=class{listPages(e=!1){return r(\"space.listPages\",e)}getPageMeta(e){return r(\"space.getPageMeta\",e)}readPage(e){return r(\"space.readPage\",e)}writePage(e,n){return r(\"space.writePage\",e,n)}deletePage(e){return r(\"space.deletePage\",e)}listPlugs(){return r(\"space.listPlugs\")}listAttachments(){return r(\"space.listAttachments\")}getAttachmentMeta(e){return r(\"space.getAttachmentMeta\",e)}readAttachment(e){return r(\"space.readAttachment\",e)}writeAttachment(e,n,i){return r(\"space.writeAttachment\",e,n,i)}deleteAttachment(e){return r(\"space.deleteAttachment\",e)}readFile(e,n){return r(\"space.readFile\",e,n)}getFileMeta(e){return r(\"space.getFileMeta\",e)}writeFile(e,n,i){return r(\"space.writeFile\",e,n,i)}deleteFile(e){return r(\"space.deleteFile\",e)}listFiles(e){return r(\"space.listFiles\",e)}},c=new d;var l={};f(l,{getEnv:()=>ae,invokeCommand:()=>ie,invokeFunction:()=>ne,listCommands:()=>oe,reloadPlugs:()=>se});function ne(t,e,...n){return r(\"system.invokeFunction\",t,e,...n)}function ie(t){return r(\"system.invokeCommand\",t)}function oe(){return r(\"system.listCommands\")}function se(){r(\"system.reloadPlugs\")}function ae(){return r(\"system.getEnv\")}var h=P(m(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));var x=P(m(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function w(){let t=await s.prompt(\"Gist URL:\");if(!t)return;let e=t.split(\"/\"),n=e[e.length-1],i=await l.invokeFunction(\"server\",\"getGist\",n);if(Object.keys(i).length!==1){await s.flashNotification(\"Only gists with a single file are supported\",\"error\");return}let o=Object.keys(i)[0].replace(/\\.md$/,\"\"),v=Object.values(i)[0].content,u=await s.prompt(\"Page name:\",o);!u||(await c.writePage(u,`---\n$share:\n- 'gh-gist:${n}'\n---\n${v}`),await s.navigate(u))}var fe=w;return k(pe);})();\n return mod;})()"
},
"openGistCommand": {
"command": {
"name": "Share: Gist: Open In Browser"
},
"code": "(() => { var mod=(()=>{var L=Object.create;var P=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var M=(e=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(e,{get:(t,r)=>(typeof require!=\"undefined\"?require:t)[r]}):e)(function(e){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+e+'\" is not supported')});var x=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},k=(e,t,r,i)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let o of Y(t))!D.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(i=R(t,o))||i.enumerable});return e};var N=(e,t,r)=>(r=e!=null?L(G(e)):{},k(t||!e||!e.__esModule?P(r,\"default\",{value:e,enumerable:!0}):r,e)),U=e=>k(P({},\"__esModule\",{value:!0}),e);var xe={};x(xe,{default:()=>he});function w(e){if(!!e.children)for(let t of e.children){if(t.parent)return;t.parent=e,w(t)}}function E(e,t){if(t(e))return[e];let r=[];if(e.children)for(let i of e.children)r=[...r,...E(i,t)];return r}function y(e,t){if(e.children){let r=e.children.slice();for(let i of r){let o=t(i);if(o!==void 0){let s=e.children.indexOf(i);o?e.children.splice(s,1,o):e.children.splice(s,1)}else y(i,t)}}}function h(e,t){return E(e,r=>r.type===t)[0]}function u(e){let t=[];if(e.text!==void 0)return e.text;for(let r of e.children)t.push(u(r));return t.join(\"\")}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var n=self.syscall;var c={};x(c,{confirm:()=>le,dispatch:()=>ae,downloadFile:()=>Z,filterBox:()=>ee,flashNotification:()=>K,getCurrentPage:()=>Q,getCursor:()=>_,getSelection:()=>V,getText:()=>B,getUiOption:()=>ue,hidePanel:()=>re,insertAtCursor:()=>se,insertAtPos:()=>ne,moveCursor:()=>oe,navigate:()=>W,openUrl:()=>X,prompt:()=>ce,reloadPage:()=>z,replaceRange:()=>ie,save:()=>J,setPage:()=>q,setSelection:()=>H,setUiOption:()=>fe,showPanel:()=>te,vimEx:()=>pe});function Q(){return n(\"editor.getCurrentPage\")}function q(e){return n(\"editor.setPage\",e)}function B(){return n(\"editor.getText\")}function _(){return n(\"editor.getCursor\")}function V(){return n(\"editor.getSelection\")}function H(e,t){return n(\"editor.setSelection\",e,t)}function J(){return n(\"editor.save\")}function W(e,t,r=!1,i=!1){return n(\"editor.navigate\",e,t,r,i)}function z(){return n(\"editor.reloadPage\")}function X(e){return n(\"editor.openUrl\",e)}function Z(e,t){return n(\"editor.downloadFile\",e,t)}function K(e,t=\"info\"){return n(\"editor.flashNotification\",e,t)}function ee(e,t,r=\"\",i=\"\"){return n(\"editor.filterBox\",e,t,r,i)}function te(e,t,r,i=\"\"){return n(\"editor.showPanel\",e,t,r,i)}function re(e){return n(\"editor.hidePanel\",e)}function ne(e,t){return n(\"editor.insertAtPos\",e,t)}function ie(e,t,r){return n(\"editor.replaceRange\",e,t,r)}function oe(e,t=!1){return n(\"editor.moveCursor\",e,t)}function se(e){return n(\"editor.insertAtCursor\",e)}function ae(e){return n(\"editor.dispatch\",e)}function ce(e,t=\"\"){return n(\"editor.prompt\",e,t)}function le(e){return n(\"editor.confirm\",e)}function ue(e){return n(\"editor.getUiOption\",e)}function fe(e,t){return n(\"editor.setUiOption\",e,t)}function pe(e){return n(\"editor.vimEx\",e)}var f={};x(f,{parseMarkdown:()=>me});function me(e){return n(\"markdown.parseMarkdown\",e)}var v=class{listPages(t=!1){return n(\"space.listPages\",t)}getPageMeta(t){return n(\"space.getPageMeta\",t)}readPage(t){return n(\"space.readPage\",t)}writePage(t,r){return n(\"space.writePage\",t,r)}deletePage(t){return n(\"space.deletePage\",t)}listPlugs(){return n(\"space.listPlugs\")}listAttachments(){return n(\"space.listAttachments\")}getAttachmentMeta(t){return n(\"space.getAttachmentMeta\",t)}readAttachment(t){return n(\"space.readAttachment\",t)}writeAttachment(t,r,i){return n(\"space.writeAttachment\",t,r,i)}deleteAttachment(t){return n(\"space.deleteAttachment\",t)}readFile(t,r){return n(\"space.readFile\",t,r)}getFileMeta(t){return n(\"space.getFileMeta\",t)}writeFile(t,r,i){return n(\"space.writeFile\",t,r,i)}deleteFile(t){return n(\"space.deleteFile\",t)}listFiles(t){return n(\"space.listFiles\",t)}},T=new v;var $=N(M(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));var l=N(M(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));function O(e,t=[]){let r={};return w(e),y(e,i=>{if(i.type===\"Hashtag\"){if(i.parent&&i.parent.type===\"Paragraph\"){let a=i.children[0].text.substring(1);r.tags||(r.tags=[]),Array.isArray(r.tags)&&!r.tags.includes(a)&&r.tags.push(a)}return}if(i.type===\"FrontMatter\"){let a=i.children[1].children[0],d=u(a);try{let m=l.parse(d),g={...m};if(r={...r,...m},t.length>0){let A=!1;for(let C of t)C in g&&(delete g[C],A=!0);A&&(a.text=l.stringify(g))}if(Object.keys(g).length===0)return null}catch(m){console.error(\"Could not parse frontmatter\",m)}}if(i.type!==\"FencedCode\")return;let o=h(i,\"CodeInfo\");if(!o||o.children[0].text!==\"meta\")return;let s=h(i,\"CodeText\");if(!s)return;let I=s.children[0].text,b=l.parse(I),p={...b};if(r={...r,...b},t.length>0){let a=!1;for(let d of t)d in p&&(delete p[d],a=!0);a&&(s.children[0].text=l.stringify(p).trim())}if(Object.keys(p).length===0)return null}),r.name&&(r.displayName=r.name,delete r.name),r}async function S(){let e=await c.getText(),t=await f.parseMarkdown(e),{$share:r}=O(t);if(!r){await c.flashNotification(\"Not currently shared as gist\",\"error\");return}for(let i of r)if(i.startsWith(\"gh-gist:\")){let s=`https://gist.github.com/${i.split(\":\")[1]}`;await c.openUrl(s);return}await c.flashNotification(\"Not currently shared as gist\",\"error\")}var he=S;return U(xe);})();\n return mod;})()"
},
"createGist": {
"env": "server",
"code": "(() => { var mod=(()=>{var E=Object.create;var c=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var h=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var x=(r,e)=>{for(var t in e)c(r,t,{get:e[t],enumerable:!0})},w=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of $(e))!S.call(r,o)&&o!==t&&c(r,o,{get:()=>e[o],enumerable:!(n=F(e,o))||n.enumerable});return r};var v=(r,e,t)=>(t=r!=null?E(O(r)):{},w(e||!r||!r.__esModule?c(t,\"default\",{value:r,enumerable:!0}):t,r)),I=r=>w(c({},\"__esModule\",{value:!0}),r);var B={};x(B,{default:()=>q});function p(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...p(n,e)];return t}function l(r,e){return p(r,t=>t.type===e)[0]}function d(r,e){p(r,e)}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var i=self.syscall;var a={};x(a,{parseMarkdown:()=>G});function G(r){return i(\"markdown.parseMarkdown\",r)}var m=class{listPages(e=!1){return i(\"space.listPages\",e)}getPageMeta(e){return i(\"space.getPageMeta\",e)}readPage(e){return i(\"space.readPage\",e)}writePage(e,t){return i(\"space.writePage\",e,t)}deletePage(e){return i(\"space.deletePage\",e)}listPlugs(){return i(\"space.listPlugs\")}listAttachments(){return i(\"space.listAttachments\")}getAttachmentMeta(e){return i(\"space.getAttachmentMeta\",e)}readAttachment(e){return i(\"space.readAttachment\",e)}writeAttachment(e,t,n){return i(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return i(\"space.deleteAttachment\",e)}readFile(e,t){return i(\"space.readFile\",e,t)}getFileMeta(e){return i(\"space.getFileMeta\",e)}writeFile(e,t,n){return i(\"space.writeFile\",e,t,n)}deleteFile(e){return i(\"space.deleteFile\",e)}listFiles(e){return i(\"space.listFiles\",e)}},u=new m;var g=v(h(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function j(r,e){let t=await u.readPage(r),n=await a.parseMarkdown(t),o;return d(n,f=>{if(f.type!==\"FencedCode\")return!1;let P=l(f,\"CodeInfo\");if(e&&!P||e&&!e.includes(P.children[0].text))return!1;let y=l(f,\"CodeText\");return y?(o=y.children[0].text,!0):!1}),o}async function C(r,e=[\"yaml\"]){let t=await j(r,e);if(t!==void 0)try{return g.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function M(r){try{let e=await C(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let o=e[n];if(o)t.push(o);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function Q(){try{let[r]=await M([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var s=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,o){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:o})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new s(await Q())}};var k=v(h(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function N(r,e){return(await s.fromConfig()).createGist(\"\",!0,{[`${r}.md`]:{content:e}})}var q=N;return I(B);})();\n return mod;})()"
},
"updateGist": {
"env": "server",
"events": [
"share:gh-gist"
],
"code": "(() => { var mod=(()=>{var D=Object.create;var w=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var E=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var F=(r,e)=>{for(var t in e)w(r,t,{get:e[t],enumerable:!0})},$=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of j(e))!q.call(r,i)&&i!==t&&w(r,i,{get:()=>e[i],enumerable:!(n=U(e,i))||n.enumerable});return r};var O=(r,e,t)=>(t=r!=null?D(Q(r)):{},$(e||!r||!r.__esModule?w(t,\"default\",{value:r,enumerable:!0}):t,r)),B=r=>$(w({},\"__esModule\",{value:!0}),r);var K={};F(K,{default:()=>Z});function T(r){if(!!r.children)for(let e of r.children){if(e.parent)return;e.parent=r,T(e)}}function b(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...b(n,e)];return t}function v(r,e){if(r.children){let t=r.children.slice();for(let n of t){let i=e(n);if(i!==void 0){let s=r.children.indexOf(n);i?r.children.splice(s,1,i):r.children.splice(s,1)}else v(n,e)}}}function c(r,e){return b(r,t=>t.type===e)[0]}function A(r,e){b(r,e)}function l(r){let e=[];if(r.text!==void 0)return r.text;for(let t of r.children)e.push(l(t));return e.join(\"\")}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var o=self.syscall;var u={};F(u,{parseMarkdown:()=>H});function H(r){return o(\"markdown.parseMarkdown\",r)}var C=class{listPages(e=!1){return o(\"space.listPages\",e)}getPageMeta(e){return o(\"space.getPageMeta\",e)}readPage(e){return o(\"space.readPage\",e)}writePage(e,t){return o(\"space.writePage\",e,t)}deletePage(e){return o(\"space.deletePage\",e)}listPlugs(){return o(\"space.listPlugs\")}listAttachments(){return o(\"space.listAttachments\")}getAttachmentMeta(e){return o(\"space.getAttachmentMeta\",e)}readAttachment(e){return o(\"space.readAttachment\",e)}writeAttachment(e,t,n){return o(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return o(\"space.deleteAttachment\",e)}readFile(e,t){return o(\"space.readFile\",e,t)}getFileMeta(e){return o(\"space.getFileMeta\",e)}writeFile(e,t,n){return o(\"space.writeFile\",e,t,n)}deleteFile(e){return o(\"space.deleteFile\",e)}listFiles(e){return o(\"space.listFiles\",e)}},m=new C;var M=O(E(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function z(r,e){let t=await m.readPage(r),n=await u.parseMarkdown(t),i;return A(n,s=>{if(s.type!==\"FencedCode\")return!1;let g=c(s,\"CodeInfo\");if(e&&!g||e&&!e.includes(g.children[0].text))return!1;let d=c(s,\"CodeText\");return d?(i=d.children[0].text,!0):!1}),i}async function L(r,e=[\"yaml\"]){let t=await z(r,e);if(t!==void 0)try{return M.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function R(r){try{let e=await L(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let i=e[n];if(i)t.push(i);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function X(){try{let[r]=await R([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var f=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,i){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:i})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new f(await X())}};var p=O(E(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));function Y(r,e=[]){let t={};return T(r),v(r,n=>{if(n.type===\"Hashtag\"){if(n.parent&&n.parent.type===\"Paragraph\"){let a=n.children[0].text.substring(1);t.tags||(t.tags=[]),Array.isArray(t.tags)&&!t.tags.includes(a)&&t.tags.push(a)}return}if(n.type===\"FrontMatter\"){let a=n.children[1].children[0],y=l(a);try{let h=p.parse(y),x={...h};if(t={...t,...h},e.length>0){let k=!1;for(let N of e)N in x&&(delete x[N],k=!0);k&&(a.text=p.stringify(x))}if(Object.keys(x).length===0)return null}catch(h){console.error(\"Could not parse frontmatter\",h)}}if(n.type!==\"FencedCode\")return;let i=c(n,\"CodeInfo\");if(!i||i.children[0].text!==\"meta\")return;let s=c(n,\"CodeText\");if(!s)return;let g=s.children[0].text,d=p.parse(g),P={...d};if(t={...t,...d},e.length>0){let a=!1;for(let y of e)y in P&&(delete P[y],a=!0);a&&(s.children[0].text=p.stringify(P).trim())}if(Object.keys(P).length===0)return null}),t.name&&(t.displayName=t.name,delete t.name),t}async function G(r){let e=r.uri.split(\":\")[1],t=await f.fromConfig(),n=await m.readPage(r.name),i=await u.parseMarkdown(n);Y(i,[\"$share\"]);let s=l(i);return await t.updateGist(e,\"\",!0,{[`${r.name}.md`]:{content:s}}),!0}var Z=G;return B(K);})();\n return mod;})()"
},
"getGist": {
"env": "server",
"code": "(() => { var mod=(()=>{var E=Object.create;var c=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var h=(r=>typeof require!=\"undefined\"?require:typeof Proxy!=\"undefined\"?new Proxy(r,{get:(e,t)=>(typeof require!=\"undefined\"?require:e)[t]}):r)(function(r){if(typeof require!=\"undefined\")return require.apply(this,arguments);throw new Error('Dynamic require of \"'+r+'\" is not supported')});var x=(r,e)=>{for(var t in e)c(r,t,{get:e[t],enumerable:!0})},w=(r,e,t,n)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of $(e))!S.call(r,o)&&o!==t&&c(r,o,{get:()=>e[o],enumerable:!(n=F(e,o))||n.enumerable});return r};var v=(r,e,t)=>(t=r!=null?E(O(r)):{},w(e||!r||!r.__esModule?c(t,\"default\",{value:r,enumerable:!0}):t,r)),I=r=>w(c({},\"__esModule\",{value:!0}),r);var B={};x(B,{default:()=>q});function p(r,e){if(e(r))return[r];let t=[];if(r.children)for(let n of r.children)t=[...t,...p(n,e)];return t}function l(r,e){return p(r,t=>t.type===e)[0]}function d(r,e){p(r,e)}typeof self>\"u\"&&(self={syscall:()=>{throw new Error(\"Not implemented here\")}});var i=self.syscall;var a={};x(a,{parseMarkdown:()=>G});function G(r){return i(\"markdown.parseMarkdown\",r)}var m=class{listPages(e=!1){return i(\"space.listPages\",e)}getPageMeta(e){return i(\"space.getPageMeta\",e)}readPage(e){return i(\"space.readPage\",e)}writePage(e,t){return i(\"space.writePage\",e,t)}deletePage(e){return i(\"space.deletePage\",e)}listPlugs(){return i(\"space.listPlugs\")}listAttachments(){return i(\"space.listAttachments\")}getAttachmentMeta(e){return i(\"space.getAttachmentMeta\",e)}readAttachment(e){return i(\"space.readAttachment\",e)}writeAttachment(e,t,n){return i(\"space.writeAttachment\",e,t,n)}deleteAttachment(e){return i(\"space.deleteAttachment\",e)}readFile(e,t){return i(\"space.readFile\",e,t)}getFileMeta(e){return i(\"space.getFileMeta\",e)}writeFile(e,t,n){return i(\"space.writeFile\",e,t,n)}deleteFile(e){return i(\"space.deleteFile\",e)}listFiles(e){return i(\"space.listFiles\",e)}},u=new m;var g=v(h(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function j(r,e){let t=await u.readPage(r),n=await a.parseMarkdown(t),o;return d(n,f=>{if(f.type!==\"FencedCode\")return!1;let P=l(f,\"CodeInfo\");if(e&&!P||e&&!e.includes(P.children[0].text))return!1;let y=l(f,\"CodeText\");return y?(o=y.children[0].text,!0):!1}),o}async function C(r,e=[\"yaml\"]){let t=await j(r,e);if(t!==void 0)try{return g.parse(t)}catch(n){throw console.error(\"YAML Page parser error\",n),new Error(`YAML Error: ${n.message}`)}}async function M(r){try{let e=await C(\"SECRETS\",[\"yaml\",\"secrets\"]),t=[];for(let n of r){let o=e[n];if(o)t.push(o);else throw new Error(`No such secret: ${n}`)}return t}catch(e){throw e.message===\"Page not found\"?new Error(`No such secret: ${r[0]}`):e}}async function Q(){try{let[r]=await M([\"githubToken\"]);return r}catch{console.error(\"No github-config page found, using default config\");return}}var s=class{constructor(e){this.token=e}async apiCall(e,t={}){let n=await fetch(e,{...t,headers:{Authorization:this.token?`token ${this.token}`:void 0}});if(n.status<200||n.status>=300)throw new Error(await n.text());return n.json()}listEvents(e){return this.apiCall(`https://api.github.com/users/${e}/events?per_page=100`)}listPulls(e,t=\"all\",n=\"updated\"){return this.apiCall(`https://api.github.com/repos/${e}/pulls?state=${t}&sort=${n}&direction=desc&per_page=100`)}searchIssues(e,t=\"\"){return e=encodeURIComponent(e),this.apiCall(`https://api.github.com/search/issues?q=${e}&sort=${t}&direction=desc&per_page=100`)}listNotifications(){return this.apiCall(\"https://api.github.com/notifications?per_page=100\")}async createGist(e,t,n){return(await this.apiCall(\"https://api.github.com/gists\",{method:\"POST\",body:JSON.stringify({description:e,public:t,files:n})})).id}updateGist(e,t,n,o){return this.apiCall(`https://api.github.com/gists/${e}`,{method:\"PATCH\",body:JSON.stringify({description:t,public:n,files:o})})}async getGist(e){return(await this.apiCall(`https://api.github.com/gists/${e}`)).files}static async fromConfig(){return new s(await Q())}};var k=v(h(\"https://deno.land/std@0.184.0/yaml/mod.ts\"));async function N(r){return(await s.fromConfig()).getGist(r)}var q=N;return I(B);})();\n return mod;})()"
}
},
"assets": {}
}