scrapbox-userscript-std-bundled
code:script.js
var f=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var k=e=>e==null,$=e=>typeof e=="string",B=e=>typeof e=="number",Fe=e=>Array.isArray(e),zt=e=>typeof e=="object"&&e!==null,Qt=e=>zt(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,je=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Qt(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var N=class extends Error{constructor(t){super(${t.status} ${t.statusText} when fetching ${t.url});this.response=t;this.name="UnexpectedResponseError";Error.captureStackTrace&&Error.captureStackTrace(this,N)}},E=async e=>{let t=e.clone(),r=await t.text(),o=je(r);if(!o)throw new N(t);return{ok:!1,value:o}};var oe=async e=>{let{sid:t,hostName:r,fetch:o}=f(e??{}),n=new Request(https://${r}/api/users/me,t?{headers:{Cookie:y(t)}}:void 0),s=await o(n);if(!s.ok)throw new N(s);return await s.json()};var y=e=>connect.sid=${e},I=async e=>globalThis._csrf?globalThis._csrf:(await oe(e)).csrfToken;var P=e=>e.replaceAll(" ","_").toLowerCase(),mn=e=>e.replaceAll("_"," "),M=e=>...e.map((t,r)=>t===" "?"_":!Yt.includes(t)||r===e.length-1&&Wt.includes(t)?encodeURIComponent(t):t).join(""),Yt='@$&+=:;",',Wt=':;",',fn=e=>e.replaceAll(" ","_").replace(//?#\{}^|<>%/g,t=>encodeURIComponent(t));var De=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:a}=f(r??{}),i=new URLSearchParams;i.append("followRename",${s??!0});for(let d of a??[])i.append("projects",d);let c=https://${n}/api/pages/${e}/${M(t)}?${i.toString()};return new Request(c,o?{headers:{Cookie:y(o)}}:void 0)},Ue=async e=>{if(!e.ok)return e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:E(e);let t=await e.json();return{ok:!0,value:t}},ne=async(e,t,r)=>{let{fetch:o}=f(r??{}),n=De(e,t,r),s=await o(n);return await Ue(s)};ne.toRequest=De;ne.fromResponse=Ue;var Ae=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:a}=f(t??{}),i=new URLSearchParams;n!==void 0&&i.append("sort",n),s!==void 0&&i.append("limit",${s}),a!==void 0&&i.append("skip",${a});let c=https://${o}/api/pages/${e}?${i.toString()};return new Request(c,r?{headers:{Cookie:y(r)}}:void 0)},$e=async e=>{if(!e.ok)return E(e);let t=await e.json();return{ok:!0,value:t}},qe=async(e,t)=>{let{fetch:r}=f(t??{}),o=await r(Ae(e,t));return await $e(o)};qe.toRequest=Ae;qe.fromResponse=$e;var He=(e,t,r,o)=>{let{sid:n,hostName:s}=f(o??{}),a=https://${s}/api/table/${e}/${M(t)}/${encodeURIComponent(r)}.csv;return new Request(a,n?{headers:{Cookie:y(n)}}:void 0)},_e=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:E(e),Ge=async(e,t,r,o)=>{let{fetch:n}=f(o??{}),s=He(e,t,r,o),a=await n(s);return await _e(a)};Ge.toRequest=He;Ge.fromResponse=_e;var Ke=(e,t)=>{let{sid:r,hostName:o}=f(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:y(r)}}:void 0)},ze=async e=>{if(!e.ok)return E(e);let t=await e.json();return{ok:!0,value:t}},se=async(e,t)=>{let{fetch:r}=f(t??{}),o=Ke(e,t),n=await r(o);return ze(n)};se.toRequest=Ke;se.fromResponse=ze;var Qe=(e,t)=>{let{sid:r,hostName:o}=f(t??{}),n=new URLSearchParams;for(let s of e)n.append("ids",s);return new Request(https://${o}/api/projects?${n.toString()},r?{headers:{Cookie:y(r)}}:void 0)},Ye=async e=>{if(!e.ok)return E(e);let t=await e.json();return{ok:!0,value:t}},We=async(e,t)=>{let{fetch:r}=f(t??{}),o=await r(Qe(e,t));return Ye(o)};We.toRequest=Qe;We.fromResponse=Ye;var qn=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:a,csrf:i}=f(o??{}),c=new Request(https://${s}/api/pages/${e}/replace/links,{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":i??await I(o),...n?{Cookie:y(n)}:{}},body:JSON.stringify({from:t,to:r})}),d=await a(c);if(!d.ok)return E(d);let{message:p}=await d.json();return{ok:!0,value:parseInt(p.match(/\d+/)?.0??"0")}};var Wn=async(e,t,r)=>{if(t.pages.length===0)return{ok:!0,value:"No pages to import."};let{sid:o,hostName:n,fetch:s,csrf:a}=f(r??{}),i=new FormData;i.append("import-file",new Blob(JSON.stringify(t),{type:"application/octet-stream"})),i.append("name","undefined");let c=new Request(https://${n}/api/page-data/import/${e}.json,{method:"POST",headers:{...o?{Cookie:y(o)}:{},Accept:"application/json, text/plain, */*","X-CSRF-TOKEN":a??await I(r)},body:i}),d=await s(c);if(!d.ok)return E(d);let{message:p}=await d.json();return{ok:!0,value:p}},Jn=async(e,t)=>{let{sid:r,hostName:o,fetch:n,metadata:s}=f(t??{}),a=new Request(https://${o}/api/page-data/export/${e}.json?metadata=${s},r?{headers:{Cookie:y(r)}}:void 0),i=await n(a);if(!i.ok)return E(i);let c=await i.json();return{ok:!0,value:c}};var Je=async(e,t,r)=>{let{sid:o,hostName:n,fetch:s,followingId:a}=f(r??{}),i=new Request(https://${n}/api/page-snapshots/${e}/${t}/${a??followingId=${a}:""},o?{headers:{Cookie:y(o)}}:void 0),c=await s(i);if(!c.ok)return c.status===422?{ok:!1,value:{name:"InvalidPageSnapshotIdError",message:await c.text()}}:E(c);let d=await c.json();return{ok:!0,value:{...d,followingId:c.headers.get("X-following-id")??""}}},Jt=async(e,t,r)=>{let o=await Je(e,t,r);return o.ok?async function*(){yield o.value.snapshots;let n=o.value.followingId;for(;n;){let s=await Je(e,t,{followingId:n,...r});if(!s.ok)throw new Error("The authorization cannot be unavailable");yield s.value.snapshots,n=s.value.followingId}}():o.value},os=async(e,t,r)=>{let o=await Jt(e,t,r);return"name"in o?o:async function*(){for await(let n of o)for(let s of n)yield s}()};var Xe=async(e,t)=>{let{sid:r,hostName:o,fetch:n,followingId:s}=f(t??{}),a=new Request(https://${o}/api/pages/${e}/search/titles${s??followingId=${s}:""},r?{headers:{Cookie:y(r)}}:void 0),i=await n(a);if(!i.ok)return i.status===422?{ok:!1,value:{name:"InvalidFollowingIdError",message:await i.text()}}:E(i);let c=await i.json();return{ok:!0,value:{pages:c,followingId:i.headers.get("X-following-id")??""}}},Xt=async(e,t)=>{let r=await Xe(e,t);return r.ok?async function*(){yield r.value.pages;let o=r.value.followingId;for(;o;){let n=await Xe(e,{followingId:o,...t});if(!n.ok)throw new Error("The authorization cannot be unavailable");yield n.value.pages,o=n.value.followingId}}():r.value},ds=async(e,t)=>{let r=await Xt(e,t);return"name"in r?r:async function*(){for await(let o of r)for(let n of o)yield n}()};var xs=async(e,t,r)=>{let{sid:o,hostName:n,fetch:s}=f(r??{}),a=new Request(https://${n}/api/pages/${t}/search/query?q=${encodeURIComponent(e)},o?{headers:{Cookie:y(o)}}:void 0),i=await s(a);if(!i.ok)return i.status===422?{ok:!1,value:{name:"NoQueryError",message:(await i.json()).message}}:E(i);let c=await i.json();return{ok:!0,value:c}},ys=async(e,t)=>{let{sid:r,hostName:o,fetch:n}=f(t??{}),s=new Request(https://${o}/api/projects/search/query?q=${encodeURIComponent(e)},r?{headers:{Cookie:y(r)}}:void 0),a=await n(s);if(!a.ok)return a.status===422?{ok:!1,value:{name:"NoQueryError",message:(await a.json()).message}}:E(a);let i=await a.json();return{ok:!0,value:i}},Es=async(e,t,r)=>{let{sid:o,hostName:n,fetch:s}=f(r??{}),a=new URLSearchParams;a.append("q",encodeURIComponent(e));for(let p of t)a.append("ids",p);let i=new Request(https://${n}/api/projects/search/watch-list?${a.toString()},o?{headers:{Cookie:y(o)}}:void 0),c=await s(i);if(!c.ok)return c.status===422?{ok:!1,value:{name:"NoQueryError",message:(await c.json()).message}}:E(c);let d=await c.json();return{ok:!0,value:d}};var Cs=async(e,t)=>{let{sid:r,hostName:o,fetch:n,csrf:s}=f(t??{}),a=new Request(https://${o}/api/embed-text/url?url=${encodeURIComponent(e.toString())},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":s??await I(t),...r?{Cookie:y(r)}:{}},body:JSON.stringify({timeout:3e3})}),i=await n(a);if(!i.ok)return i.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await i.json()).message}}:E(i);let{title:c}=await i.json();return{ok:!0,value:c}};var Ms=async(e,t)=>{let{sid:r,hostName:o,fetch:n,csrf:s}=f(t??{}),a=new Request(https://${o}/api/embed-text/twitter?url=${encodeURIComponent(e.toString())},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":s??await I(t),...r?{Cookie:y(r)}:{}},body:JSON.stringify({timeout:3e3})}),i=await n(a);if(!i.ok)return i.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await i.json()).message}}:E(i);let c=await i.json();return{ok:!0,value:c}};var $s=async e=>{let{sid:t,hostName:r,gyazoTeamsName:o}=f(e??{}),n=new Request(https://${r}/api/login/gyazo/oauth-upload/token${o??gyazoTeamsName=${o}:""},t?{headers:{Cookie:y(t)}}:void 0),s=await fetch(n);if(!s.ok)return E(s);let{token:a}=await s.json();return{ok:!0,value:a}};var Y=async(e,t)=>{let r=await ne(e,t);if(!r.ok)throw new Error(You have no privilege of editing "/${e}/${t}".);return r.value};var ie=e=>{let t=e.match(/^(\s*)code:(.+?)(\(.+\)){0,1}\s*$/);if(t===null)return null;let r=t2.trim(),o="";if(t3===void 0){let n=r.match(/.+\.(.*)$/);if(n===null)o=r;else{if(n1==="")return null;o=n1.trim()}}else o=t3.slice(1,-1);return{filename:r,lang:o,indent:t1.length}};function q(e){return e.titleLine.text.length-e.titleLine.text.trimStart().length+1}var Ve=async(e,t)=>{let r=await Vt(e),o=[],n={isCodeBlock:!1,filename:"",lang:"",indent:0};for(let s of r)if(n.isCodeBlock){if(er(s.text,n.indent)===null){oo.length-1.nextLine=s,n.isCodeBlock=!1;continue}oo.length-1.bodyLines.push(s)}else{let a=ie(s.text);if(a===null){n.isCodeBlock=!1;continue}n={isCodeBlock:!0,...a},o.push({filename:n.filename,lang:n.lang,titleLine:s,bodyLines:[],nextLine:null,pageInfo:{projectName:e.project,pageTitle:e.title}})}return o.filter(s=>Zt(s,t))},Vt=async e=>e.lines!==void 0?e.lines:(await Y(e.project,e.title)).lines,Zt=(e,t)=>{let r=(o,n)=>!o||o===n;return r(t?.filename,e.filename)&&r(t?.lang,e.lang)&&r(t?.titleLineId,e.titleLine.id)},er=(e,t)=>{let r=e.replaceAll("\r","").match(/^(\s*)(.*)$/);if(r===null||r.length<2)return null;let o=r1,n=r2;return o.length<=t?null:o.slice(o.length-t)+n};var Ze=(e,t,r,o)=>{let{sid:n,hostName:s}=f(o??{}),a=https://${s}/api/code/${e}/${M(t)}/${M(r)};return new Request(a,n?{headers:{Cookie:y(n)}}:void 0)},et=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404&&e.headers.get("Content-Type")?.includes?.("text/plain")?{ok:!1,value:{name:"NotFoundError",message:"Code block is not found"}}:E(e),tt=async(e,t,r,o)=>{let{fetch:n}=f(o??{}),s=Ze(e,t,r,o),a=await n(s);return await et(a)};tt.toRequest=Ze;tt.fromResponse=et;var rt=new TextEncoder().encode("0123456789abcdef");function ot(e){let t=new Uint8Array(e.length*2);for(let r=0;r<t.length;r++){let o=er;tr*2=rto>>4,tr*2+1=rto&15}return t}var nt="md5: data is invalid type",H=64,ae=class{#e;#t;#r;#o;#n;#i;#s;#a;constructor(){this.#e=1732584193,this.#t=4023233417,this.#r=2562383102,this.#o=271733878,this.#n=new Uint8Array(H),this.#i=0,this.#s=0,this.#a=0}#p(t){let r=this.#s;r+=t,r>4294967295&&(this.#a+=1),this.#s=r>>>0}#c(t){let r=this.#e,o=this.#t,n=this.#r,s=this.#o,a=A=>tA|tA+1<<8|tA+2<<16|tA+3<<24,i=(A,Be)=>A<<Be|A>>>32-Be,c=a(0),d=a(4),p=a(8),g=a(12),m=a(16),b=a(20),u=a(24),l=a(28),x=a(32),w=a(36),L=a(40),O=a(44),Z=a(48),ee=a(52),te=a(56),re=a(60);r=o+i(((n^s)&o^s)+r+c+3614090360,7),s=r+i(((o^n)&r^n)+s+d+3905402710,12),n=s+i(((r^o)&s^o)+n+p+606105819,17),o=n+i(((s^r)&n^r)+o+g+3250441966,22),r=o+i(((n^s)&o^s)+r+m+4118548399,7),s=r+i(((o^n)&r^n)+s+b+1200080426,12),n=s+i(((r^o)&s^o)+n+u+2821735955,17),o=n+i(((s^r)&n^r)+o+l+4249261313,22),r=o+i(((n^s)&o^s)+r+x+1770035416,7),s=r+i(((o^n)&r^n)+s+w+2336552879,12),n=s+i(((r^o)&s^o)+n+L+4294925233,17),o=n+i(((s^r)&n^r)+o+O+2304563134,22),r=o+i(((n^s)&o^s)+r+Z+1804603682,7),s=r+i(((o^n)&r^n)+s+ee+4254626195,12),n=s+i(((r^o)&s^o)+n+te+2792965006,17),o=n+i(((s^r)&n^r)+o+re+1236535329,22),r=o+i(((o^n)&s^n)+r+d+4129170786,5),s=r+i(((r^o)&n^o)+s+u+3225465664,9),n=s+i(((s^r)&o^r)+n+O+643717713,14),o=n+i(((n^s)&r^s)+o+c+3921069994,20),r=o+i(((o^n)&s^n)+r+b+3593408605,5),s=r+i(((r^o)&n^o)+s+L+38016083,9),n=s+i(((s^r)&o^r)+n+re+3634488961,14),o=n+i(((n^s)&r^s)+o+m+3889429448,20),r=o+i(((o^n)&s^n)+r+w+568446438,5),s=r+i(((r^o)&n^o)+s+te+3275163606,9),n=s+i(((s^r)&o^r)+n+g+4107603335,14),o=n+i(((n^s)&r^s)+o+x+1163531501,20),r=o+i(((o^n)&s^n)+r+ee+2850285829,5),s=r+i(((r^o)&n^o)+s+p+4243563512,9),n=s+i(((s^r)&o^r)+n+l+1735328473,14),o=n+i(((n^s)&r^s)+o+Z+2368359562,20),r=o+i((o^n^s)+r+b+4294588738,4),s=r+i((r^o^n)+s+x+2272392833,11),n=s+i((s^r^o)+n+O+1839030562,16),o=n+i((n^s^r)+o+te+4259657740,23),r=o+i((o^n^s)+r+d+2763975236,4),s=r+i((r^o^n)+s+m+1272893353,11),n=s+i((s^r^o)+n+l+4139469664,16),o=n+i((n^s^r)+o+L+3200236656,23),r=o+i((o^n^s)+r+ee+681279174,4),s=r+i((r^o^n)+s+c+3936430074,11),n=s+i((s^r^o)+n+g+3572445317,16),o=n+i((n^s^r)+o+u+76029189,23),r=o+i((o^n^s)+r+w+3654602809,4),s=r+i((r^o^n)+s+Z+3873151461,11),n=s+i((s^r^o)+n+re+530742520,16),o=n+i((n^s^r)+o+p+3299628645,23),r=o+i((n^(o|~s))+r+c+4096336452,6),s=r+i((o^(r|~n))+s+l+1126891415,10),n=s+i((r^(s|~o))+n+te+2878612391,15),o=n+i((s^(n|~r))+o+b+4237533241,21),r=o+i((n^(o|~s))+r+Z+1700485571,6),s=r+i((o^(r|~n))+s+g+2399980690,10),n=s+i((r^(s|~o))+n+L+4293915773,15),o=n+i((s^(n|~r))+o+d+2240044497,21),r=o+i((n^(o|~s))+r+x+1873313359,6),s=r+i((o^(r|~n))+s+re+4264355552,10),n=s+i((r^(s|~o))+n+u+2734768916,15),o=n+i((s^(n|~r))+o+ee+1309151649,21),r=o+i((n^(o|~s))+r+m+4149444226,6),s=r+i((o^(r|~n))+s+O+3174756917,10),n=s+i((r^(s|~o))+n+p+718787259,15),o=n+i((s^(n|~r))+o+w+3951481745,21),this.#e=this.#e+r>>>0,this.#t=this.#t+o>>>0,this.#r=this.#r+n>>>0,this.#o=this.#o+s>>>0}update(t){let r;if(typeof t=="string")r=new TextEncoder().encode(t);else if(typeof t=="object")if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new Uint8Array(t);else throw new TypeError(nt);else throw new TypeError(nt);let o=this.#i,n=H-o;if(r.length<n)this.#n.set(r,o),o+=r.length;else{this.#n.set(r.slice(0,n),o),this.#c(this.#n);let s=n;for(;s+H<=r.length;)this.#c(r.slice(s,s+H)),s+=H;this.#n.fill(0).set(r.slice(s),0),o=r.length-s}return this.#i=o,this.#p(r.length),this}digest(){let t=H-this.#i;t<9&&(t+=H);let r=new Uint8Array(t);r0=128;let o=this.#s<<3,n=this.#a<<3|this.#s>>>29;rr.length-8=o&255,rr.length-7=o>>>8&255,rr.length-6=o>>>16&255,rr.length-5=o>>>24&255,rr.length-4=n&255,rr.length-3=n>>>8&255,rr.length-2=n>>>16&255,rr.length-1=n>>>24&255,this.update(r.buffer);let s=new ArrayBuffer(16),a=new DataView(s);return a.setUint32(0,this.#e,!0),a.setUint32(4,this.#t,!0),a.setUint32(8,this.#r,!0),a.setUint32(12,this.#o,!0),s}toString(t="hex"){let r=this.digest();switch(t){case"hex":return new TextDecoder().decode(ot(new Uint8Array(r)));case"base64":{let o=new Uint8Array(r),n="";for(let s=0;s<o.length;++s)n+=String.fromCharCode(os);return btoa(n)}default:throw new Error("md5: invalid format")}}};var fi=async(e,t,r)=>{let o=new ae().update(await e.arrayBuffer()).toString(),n=await tr(e,t,o,r);if(!n.ok)return n;if("embedUrl"in n.value)return{ok:!0,value:n.value};let s=await rr(n.value.signedUrl,e,r);return s.ok?or(t,n.value.fileId,o,r):s},tr=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:a,csrf:i}=f(o??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},d=i??await I(),p=new Request(https://${s}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":d,...n?{Cookie:y(n)}:{}}}),g=await a(p);return g.ok?{ok:!0,value:await g.json()}:E(g)},rr=async(e,t,r)=>{let{sid:o,fetch:n}=f(r??{}),s=await n(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...o?{Cookie:y(o)}:{}}});if(!s.ok){if(s.headers.get("Content-Type")?.includes?.("/xml"))return{ok:!1,value:{name:"GCSError",message:await s.text()}};throw new N(s)}return{ok:!0,value:void 0}},or=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:a,csrf:i}=f(o??{}),c=i??await I(),d=new Request(https://${s}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":c,...n?{Cookie:y(n)}:{}}}),p=await a(d);if(!p.ok){try{if(p.status===404)return{ok:!1,value:{name:"NotFoundError",message:(await p.json()).message}}}catch{throw new N(p)}throw new N(p)}let g=await p.json();return{ok:!0,value:g}};var st=(e,t)=>{if(!Array.isArray(e))throw new TypeError("${t}" must be an array but actual is "${e}")};var ce=!1,it=null;scrapbox.addListener("lines:changed",()=>ce=!1);scrapbox.addListener("layout:changed",()=>ce=!1);var at=()=>(ce||(it=scrapbox.Page.lines,ce=!0),it);var ct=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")},pt=(e,t)=>{if(!(e instanceof HTMLAnchorElement))throw new TypeError("${t}" must be HTMLAnchorElememt but actual is "${e}")},dt=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Ai=()=>S(document.getElementById("editor"),"div#editor"),W=()=>S(document.getElementsByClassName("lines").item(0),"div.lines"),$i=()=>S(document.getElementById("compute-line"),"div#compute-line"),qi=()=>S(document.getElementsByClassName("cursor-line").item(0),"div.cursor-line"),F=()=>{let e=document.getElementById("text-input");if(!!e)return dt(e,"textarea#text-input"),e},Hi=()=>S(document.getElementsByClassName("cursor").item(0),"div.cursor"),_i=()=>S(document.getElementsByClassName("selections")?.0,"div.selections"),Gi=()=>S(document.getElementsByClassName("related-page-list clearfix")0?.getElementsByClassName?.("grid")?.item(0),".related-page-list.clearfix div.grid"),Ki=()=>S(document.getElementsByClassName("popup-menu")?.0,"div.popup-menu"),zi=()=>S(document.getElementsByClassName("page-menu")?.0,"div.page-menu"),Qi=()=>Ie(document.getElementById("page-info-menu"),"a#page-info-menu"),nr=()=>Ie(document.getElementById("page-edit-menu"),"a#page-edit-menu"),Yi=()=>Array.from(nr()?.nextElementSibling?.getElementsByTagName?.("a")??[]),Wi=()=>Ie(document.getElementsByClassName("random-jump-button").item(0),"a#random-jump-button"),Ji=()=>Array.from(document.getElementsByClassName("page-menu-extension")).flatMap(e=>{let t=e.getElementsByTagName("a").item(0);return t?t:[]}),lt=()=>S(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),S=(e,t)=>{if(!!e)return ct(e,t),e},Ie=(e,t)=>{if(!!e)return pt(e,t),e};var K=()=>{let e=W();if(!e)throw Error("div.lines is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.lines must has the property whose name starts with "__reactFiber"');return et.return.stateNode.props.lines};var pe=e=>e.match(/^(\s*)/)?.1?.length??0,ut=(e,t)=>{let r=pe(mt(e,t)),o=0;for(;e+o+1<t.length&&pe(mt(e+o+1,t))>r;)o++;return o},mt=(e,t)=>{let r=te;return $(r)?r:r.text};var de=e=>{if(k(e))return;if(B(e))return le(e)?.id;if($(e))return e.startsWith("L")?e.slice(1):e;if(e.classList.contains("line"))return e.id.slice(1);let t=e.closest(".line");if(t)return t.id.slice(1)},_=e=>{if(k(e))return;if(B(e))return e;let t=de(e);return t?K().findIndex(r=>r.id===t):-1},ft=e=>{if(k(e))return;if(B(e))return Re()e;let t=de(e);return t?Re().find(r=>r.id===t):void 0},le=e=>{if(k(e))return;if(B(e))return K()e;let t=de(e);return t?K().find(r=>r.id===t):void 0},ue=e=>{if(Pe(e))return e;let t=de(e);if(k(t))return t;let r=document.getElementById(L${t});if(!k(r))return r},Pe=e=>e instanceof HTMLDivElement&&e.classList.contains("line"),me=()=>K().length,Re=()=>{let e=at();return st(e,"scrapbox.Page.lines"),e},Ne=e=>{if(k(e))return;if(B(e)||$(e))return le(e)?.text;if(!(e instanceof HTMLElement))return;if(Pe(e))return le(e)?.text;if(e.classList.contains("char-index"))return e.textContent??void 0;if(e.classList.contains("line")||e.getElementsByClassName("lines")?.0)return K().map(({text:o})=>o).join(` );let t=[],r=le(e);if(!k(r)){for(let o of sr(e))t.push(ir(o));return r.text.slice(Math.min(...t),Math.max(...t)+1)}},ca=e=>{let t=e.closest(".link");if(!k(t))return t},pa=e=>{let t=e.closest(".page-link");if(!k(t))return t},da=e=>{let t=e.closest(".link, .page-link");if(!k(t))return t},la=e=>{let t=e.closest(".formula");if(!k(t))return t},ua=e=>{let t=_(e);if(!k(t))return ft(t+1)},ma=e=>{let t=_(e);if(!k(t))return ft(t-1)},gt=()=>{let e=W()?.firstElementChild;if(!k(e))return e},Se=()=>{let e=W()?.lastElementChild;if(!k(e))return e},fa=e=>{let t=Ne(e);if(!k(t))return pe(t)},ga=e=>{let t=_(e);if(!k(t))return ut(t,Re())};function*sr(e){let t=e.getElementsByClassName("char-index");for(let r=0;r<t.length;r++)yield t[0]}var J=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index"),ir=e=>{if(!J(e))throw Error("A char DOM is required.");let t=e.className.match(/c-(\d+)/)?.[1];if(k(t))throw Error('.char-index must have ".c-{\\d}"');return parseInt(t)},ht=e=>{let t=e?.getElementsByClassName?.("c-0")?.[0];return J(t)?t:void 0},ha=e=>{let t=e?.querySelector(".char-index:last-of-type");return J(t)?t:void 0},xt=(e,t)=>{let r=ue(e)?.getElementsByClassName?.(c-${t})?.[0];return J(r)?r:void 0},xa=(e,t)=>{let r=document.elementsFromPoint(e,t),o=r.find(s=>J(s)),n=r.find(s=>Pe(s));return{char:k(o)?void 0:o,line:k(n)?void 0:n}};var h=(e,t)=>{let{noModifiedKeys:r=!1,...o}=t??{},n={bubbles:!0,cancelable:!0,keyCode:ar[e],...r?{}:{...o}},s=F();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",n)),s.dispatchEvent(new KeyboardEvent("keyup",n))},ar={Backspace:8,Tab:9,Enter:13,Delete:46,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,a:65,A:65,b:66,B:66,c:67,C:67,d:68,D:68,e:69,E:69,f:70,F:70,g:71,G:71,h:72,H:72,i:73,I:73,j:74,J:74,k:75,K:75,l:76,L:76,m:77,M:77,n:78,N:78,o:79,O:79,p:80,P:80,q:81,Q:81,r:82,R:82,s:83,S:83,t:84,T:84,u:85,U:85,v:86,V:86,w:87,W:87,x:88,X:88,y:89,Y:89,z:90,Z:90,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,F1:113,F2:114,F3:115,F4:116,F5:117,F6:118,F7:119,F8:120,F9:121,F10:122,F11:123,F12:124,":":186,"*":186,";":187,"+":187,"-":189,"=":189,".":190,">":190,"/":191,"?":191,"@":192,"":192,"":219,"{":219,"\\":220,"|":220,"":221,"}":221,"^":222,"~":222,_:226};var j=e=>new Promise(t=>setTimeout(()=>t(),e));var fe=async(e,t)=>{let r={button:t.button??0,clientX:t.X,clientY:t.Y,bubbles:!0,cancelable:!0,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,view:window};e.dispatchEvent(new MouseEvent("mousedown",r)),e.dispatchEvent(new MouseEvent("mouseup",r)),e.dispatchEvent(new MouseEvent("click",r)),await j(10)},yt=async(e,t)=>{let r=new Touch({identifier:0,target:e,clientX:t.X,clientY:t.Y,pageX:t.X+globalThis.scrollX,pageY:t.Y+globalThis.scrollY}),o={button:t.button??0,clientX:t.X,clientY:t.Y,changedTouches:r,touches:r,bubbles:!0,cancelable:!0,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,view:window};e.dispatchEvent(new TouchEvent("touchstart",o)),e.dispatchEvent(new MouseEvent("mousedown",o)),await j(t.holding??1e3),e.dispatchEvent(new MouseEvent("mouseup",o)),e.dispatchEvent(new TouchEvent("touchend",o)),e.dispatchEvent(new MouseEvent("click",o)),await j(10)};var X=()=>{let e=F();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.cursor must has the property whose name starts with "__reactFiber"');return et.return.return.stateNode.props};var V=e=>{let{top:t,bottom:r}=e.getBoundingClientRect();return t>=0&&r<=globalThis.innerHeight};function*v(e,t){for(let r=e;r<t;r++)yield r}var Ba=async(e=1e3)=>{let t=ue(X().position.line)?.getElementsByClassName("text")?.0;if(!t)throw Error(".line .target can't be found.");V(t)||t.scrollIntoView({block:"center"});let{right:r,top:o,height:n}=t.getBoundingClientRect();await yt(t,{X:r+1,Y:o+n/2,holding:e})},cr=(e=1)=>{for(let t of v(0,e))h("ArrowLeft")},Fa=(e=1)=>{for(let t of v(0,e))h("ArrowUp")},ja=(e=1)=>{for(let t of v(0,e))h("ArrowDown")},Da=(e=1)=>{for(let t of v(0,e))h("ArrowRight")},Ua=()=>{h("End"),h("Home")},Aa=()=>{h("End"),cr(Ne(X().position.line)?.match?.(/(\s*)$/)?.1?.length??0)},ge=()=>{h("Home"),h("Home")},$a=()=>{h("End")},qa=async()=>{let e=gt();if(!e)throw Error(".line:first-of-type can't be found.");V(e)||e.scrollIntoView({block:"center"});let t=ht(e);if(!t)throw Error(".line:first-of-type .c-0 can't be found.");let{left:r,top:o}=t.getBoundingClientRect();await fe(e,{X:r,Y:o})},Ha=async()=>{await Et(Se())},D=async e=>{await Et(ue(e))},Et=async e=>{if(!e)throw Error("The target line DOM is failed to find.");V(e)||e.scrollIntoView({block:"center"});let{right:t,top:r,height:o}=e.getElementsByClassName("text")0.getBoundingClientRect();await fe(e,{X:t+1,Y:r+o/2})},_a=async(e,t)=>{let r=xt(e,t);if(!r)throw Error(Could not find the char DOM at line: ${_(e)}, column: ${t});V(r)||r.scrollIntoView({block:"center"});let{left:o,top:n}=r.getBoundingClientRect();await fe(r,{X:o,Y:n})},bt=()=>{let e=Se()?.clientHeight;if(e===void 0)throw Error("Could not find .line:last-of-type");return Math.round(globalThis.innerHeight/e)},Ga=async(e=1)=>{let t=_(X().position.line);if(t===void 0)throw Error("Could not detect the present cursor line No.");let r=Math.round((t-bt()/2)*e);await D(Math.max(r,0))},Ka=async(e=1)=>{let t=_(X().position.line);if(t===void 0)throw Error("Could not detect the present cursor line No.");let r=Math.round((t+bt()/2)*e);await D(Math.min(r,me()-1))},za=(e=1)=>{for(let t of v(0,e))h("PageUp")},Qa=(e=1)=>{for(let t of v(0,e))h("PageDown")};var rc=(e=1)=>{for(let t of v(0,e))h("z",{ctrlKey:!0})},oc=(e=1)=>{for(let t of v(0,e))h("z",{shiftKey:!0,ctrlKey:!0})},nc=(e=1)=>{for(let t of v(0,e))h("i",{ctrlKey:!0})},sc=(e=1)=>{for(let t of v(0,e))h("t",{altKey:!0})},ic=async(e,t)=>{await D(e),ge(),h("Enter"),h("ArrowUp"),await vt(t)},ac=async(e,t,r)=>{await D(e),ge();for(let o of v(e,t))h("ArrowDown",{shiftKey:!0});h("End",{shiftKey:!0}),await vt(r)},cc=async(e,t=1)=>{if(B(e)){me()===e+t?(await D(e-1),h("ArrowRight",{shiftKey:!0})):(await D(e),ge());for(let r=0;r<t;r++)h("ArrowRight",{shiftKey:!0}),h("End",{shiftKey:!0});h("ArrowRight",{shiftKey:!0}),h("Delete");return}if($(e)||Fe(e)){let r=Array.isArray(e)?e:e;for(let o of r)await D(o),h("Home",{shiftKey:!0}),h("Home",{shiftKey:!0}),h("Backspace"),h("Backspace");return}throw new TypeError(The type of value must be number | string | string[] but actual is "${typeof e}")},pc=(e=1)=>{for(let t of v(0,e))h("ArrowRight",{ctrlKey:!0})},dc=(e=1)=>{for(let t of v(0,e))h("ArrowLeft",{ctrlKey:!0})},lc=e=>{e>0?kt(e):wt(-e)},uc=(e,t)=>{let r=t-e;r>=0?kt(r):wt(-r-1)},wt=(e=1)=>{for(let t of v(0,e))h("ArrowUp",{ctrlKey:!0})},kt=(e=1)=>{for(let t of v(0,e))h("ArrowDown",{ctrlKey:!0})},mc=(e=1)=>{for(let t of v(0,e))h("ArrowRight",{altKey:!0})},fc=(e=1)=>{for(let t of v(0,e))h("ArrowLeft",{altKey:!0})},gc=e=>{e>0?dr(e):pr(-e)},pr=(e=1)=>{for(let t of v(0,e))h("ArrowUp",{altKey:!0})},dr=(e=1)=>{for(let t of v(0,e))h("ArrowDown",{altKey:!0})},vt=async e=>{let t=F();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await j(1)};var yc=()=>{let e=lt();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=Lt(...r);o&&t.append(o)},dispose:()=>t.remove()}},Lt=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":returnlr();case"check-circle":returnur();case"exclamation-triangle":returnmr();case"text":returnhe(o.text);case"group":{let n=Lt(...o.items);return n?n:[]}}});if(t.length===0)return;if(t.length===1)return t0;let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},he=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},lr=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),he(e)},ur=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),he(e)},mr=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),he(e)};var Tt=e=>{let t=JSON.parse(localStorage.getItem("pageTransitionContext")??""),r=e.type==="page"?e.from.project===e.to.project?e.from.title===e.to.title?{titleHint:e.to.title}:{linkFrom:e.from.title}:{linkFrom:/${e.from.project}/${e.from.title}}:{searchQuery:e.query};t[page_${P(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var fr=(e,t,r)=>{let o=new URL(/${e}/${M(t)},location.href);if(r?.body&&(o.search=?body=${encodeURIComponent(r.body)}),r?.id&&(o.hash=#${r.id}),r?.context&&Tt({...r?.context,to:{project:e,title:t}}),r?.newTab!==!1&&(r?.newTab===!0||e!==scrapbox.Project.name)){globalThis.open(o);return}if(r?.reload!==!1&&(r?.reload===!0||e!==scrapbox.Project.name)){globalThis.open(o,"_self");return}let n=document.createElement("a");n.href=o.toString(),document.body.append(n),n.click(),n.remove()},Tc=(e,t,r)=>fr(e,t,{newTab:!1,reload:!1,body:r});var Ic=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}},Pc=async e=>{await Ct({title:"prefetch",body:{urls:e.map(t=>t.toString())}})},Rc=async e=>{await Ct({title:"fetchApiCache",body:{url:e}})},Ct=e=>{let{controller:t}=navigator.serviceWorker;if(!t){let r=new Error;throw r.name="ServiceWorkerNotActiveYetError",r.message="Service worker is not active yet",r}return new Promise((r,o)=>{let n=new MessageChannel;n.port1.addEventListener("message",s=>s.data?.error?o(s.data.error):r(s.data)),t.postMessage(e,n.port2)})};var xe=()=>{let e=F();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(s=>s.startsWith("__reactFiber"));if(!t)throw Error('#text-input must has the property whose name starts with "__reactFiber"');let r=et.return.return.stateNode._stores,o=r.find(s=>s.constructor.name==="Cursor");if(!o)throw Error('#text-input must has a "Cursor" store.');let n=r.find(s=>s.constructor.name==="Selection");if(!n)throw Error('#text-input must has a "Selection" store.');return{cursor:o,selection:n}};var Bc=()=>xe().cursor;var Dc=()=>xe().selection;var Ac=e=>{let t=new Map;for(let r of e){if(!("codeBlock"in r))continue;let{filename:o,lang:n,...s}=r.codeBlock,a=t.get(o)??{filename:o,lang:n,blocks:[]};if(s.start||a.blocks.length===0)a.blocks.push({startId:r.id,endId:r.id,updated:r.updated,indent:s.indent-1,lines:[]});else{let i=a.blocksa.blocks.length-1;i.endId=r.id,i.updated=Math.max(i.updated,r.updated),i.lines.push(...r.text.slice(i.indent+1).join(""))}t.set(o,a)}return t};var It=e=>gr.includes(e.name),gr="SocketIOError","DuplicateTitleError","NotFastForwardError";var z=async()=>{let t=(await xr())("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]});return await new Promise((r,o)=>{let n=s=>o(s);t.once("connect",()=>{t.off("disconnect",n),r()}),t.once("disconnect",n)}),t},hr="4.2.0",Pt=https://cdnjs.cloudflare.com/ajax/libs/socket.io/${hr}/socket.io.min.js,Oe,xr=async()=>{if(Oe)throw Oe;if(!document.querySelector(script[src="${Pt}"])){let e=document.createElement("script");e.src=Pt,await new Promise((t,r)=>{e.onload=()=>t(),e.onerror=o=>{Oe=o,r(o)},document.head.append(e)})}return new Promise(e=>{let t=setInterval(()=>{!io||(clearInterval(t),e(io))},500)})};var ye=(e,t=9e4)=>{let r=(n,s)=>{let a;return new Promise((i,c)=>{let d=p=>{clearTimeout(a),c(new Error(p))};e.emit(n,s,p=>{switch(clearTimeout(a),e.off("disconnect",d),n){case"socket.io-request":"error"in p?typeof p.error=="object"&&p.error&&"name"in p.error&&typeof p.error.name=="string"&&It({name:p.error.name})?i({ok:!1,value:p.error}):i({ok:!1,value:{name:"UnexpectedError",value:p.error}}):"data"in p&&i({ok:!0,value:p.data});break;case"cursor":"error"in p?i({ok:!1,value:{name:"UnexpectedError",value:p.error}}):"data"in p&&i({ok:!0,value:p.data});break}c(new Error('Invalid response: missing "data" or "error" field'))}),a=setTimeout(()=>{e.off("disconnect",d),i({ok:!1,value:{name:"TimeoutError",message:Timeout: exceeded ${t}ms}})},t),e.once("disconnect",d)})};async function*o(...n){let s,a=()=>new Promise(c=>s=c),i=c=>{s?.(c)};for(let c of n)e.on(c,i);try{for(;;)yield await a()}finally{for(let c of n)e.off(c,i)}}return{request:r,response:o}};var kp=()=>z(),Ee=async e=>{if(e.connected)return;let t=new Promise(r=>e.once("connect",()=>r()));e.connect(),await t},be=async e=>{if(e.disconnected)return;let t=new Promise(r=>{let o=n=>{n==="io client disconnect"&&(r(),e.off("disconnect",o))};e.on("disconnect",o)});e.disconnect(),await t};var we=(e,t)=>{let r=e.length>t.length,o=r?t:e,n=r?e:t,s=o.length+1,a=o.length+n.length+3,i=new Array(a);i.fill(-1);let c=[];function d(l,x,w){let L=Math.max(x,w),O=L-l;for(;O<o.length&&L<n.length&&oO===nL;)++O,++L;return il+s=c.length,c.push([{x:O,y:L},il+(x>w?-1:1)+s]),L}let p=new Array(a);p.fill(-1);let g=-1,m=n.length-o.length;do{++g;for(let l=-g;l<=m-1;++l)pl+s=d(l,pl-1+s+1,pl+1+s);for(let l=m+g;l>=m+1;--l)pl+s=d(l,pl-1+s+1,pl+1+s);pm+s=d(m,pm-1+s+1,pm+1+s)}while(pm+s!==n.length);let b=[],u=im+s;for(;u!==-1;)b.push(cu0),u=cu1;return{from:e,to:t,editDistance:m+g*2,buildSES:function*(){let l=0,x=0;for(let{x:w,y:L}of yr(b))for(;l<w||x<L;)L-w>x-l?(yield{value:nx,type:r?"deleted":"added"},++x):L-w<x-l?(yield{value:ol,type:r?"added":"deleted"},++l):(yield{value:ol,type:"common"},++l,++x)}}};function*ke(e){let t=[],r=[];function*o(){if(t.length>r.length){for(let n=0;n<r.length;n++)yield Rt(tn,rn);for(let n=r.length;n<t.length;n++)yield tn}else{for(let n=0;n<t.length;n++)yield Rt(tn,rn);for(let n=t.length;n<r.length;n++)yield rn}t=[],r=[]}for(let n of e)switch(n.type){case"added":t.push(n);break;case"deleted":r.push(n);break;case"common":yield*o(),yield n;break}yield*o()}var Rt=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*yr(e){for(let t=e.length-1;t>=0;t--)yield et}var ve,Nt=async()=>{if(ve!==void 0)return ve;let e=await oe();if(e.isGuest)throw new Error("this script can only be executed by Logged in users");return ve=e.id,ve},St=new Map,Le=async e=>{let t=St.get(e);if(t!==void 0)return t;let r=await se(e);if(!r.ok){let{name:n,message:s}=r.value;throw new Error(${n} ${s})}let{id:o}=r.value;return St.set(e,o),o},Ot=e=>e.padStart(8,"0"),Q=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${Ot(t).slice(-8)}${e.slice(-6)}0000${Ot(r)}};function*Te(e,t,{userId:r}){let{buildSES:o}=we(e.map(({text:a})=>a),t),n=0,s=e0.id;for(let a of ke(o())){switch(a.type){case"added":yield{_insert:s,lines:{id:Q(r),text:a.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:a.value}};break}n++,s=en?.id??"_end"}}var Er=e=>({type:"title",text:e.rows0.text}),br=e=>{let{rows:t,...r}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(o+1)).join(` )}},T=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,a)=>{var i,c,d,p,g,m;if(!t&&s.nested)return(i=a?.())!==null&&i!==void 0?i:[];if(!r&&s.quoted)return(c=a?.())!==null&&c!==void 0?c:[];for(let b of o){let u=b.exec(n);if(u===null)continue;let l=n.substring(0,u.index),x=n.substring(u.index+((p=(d=u[0])===null||d===void 0?void 0:d.length)!==null&&p!==void 0?p:0)),w=e((g=u[0])!==null&&g!==void 0?g:"",s);return[...U(l,s),...w,...U(x,s)]}return(m=a?.())!==null&&m!==void 0?m:[]},C=e=>[{type:"plain",raw:e,text:e}],wr=T(C,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),kr=/^>.*$/,vr=(e,t)=>t.context==="table"?C(e,t):[{type:"quote",raw:e,nodes:U(e.substring(1),{...t,quoted:!0})}],Lr=T(vr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[kr]}),Tr=/^\? .+$/,Cr=(e,t)=>t.context==="table"?C(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],Ir=T(Cr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Tr]}),Pr=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,Rr=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Nr=(e,t)=>{if(t.context==="table")return C(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?${r}/thumb/1000:r}]},Sr=T(Nr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Pr,Rr]}),Or=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function Mt(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return C(t,r);let o=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),n=o.lastIndexOf(".icon"),s=o.substring(0,n),a=s.startsWith("/")?"root":"relative",i=o.substring(n+5,o.length),c=i.startsWith("*")?parseInt(i.substring(1),10):1;return new Array(c).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Mr=Mt("icon"),Br=T(Mr,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Or]}),Fr=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,jr=Mt("strongIcon"),Dr=T(jr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Fr]}),Ur=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Ar=(e,t)=>t.context==="table"?C(e,t):[{type:"strong",raw:e,nodes:U(e.substring(2,e.length-2),{...t,nested:!0})}],$r=T(Ar,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ur]}),qr=/\[\$ .+? \]/,Hr=/\[\$ [^\]]+\]/,_r=(e,t)=>t.context==="table"?C(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Gr=T(_r,{parseOnNested:!1,parseOnQuoted:!0,patterns:[qr,Hr]}),Kr=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,zr=(e,t)=>{if(t.context==="table")return C(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let a=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:U(n,{...t,nested:!0})}]},Qr=T(zr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Kr]}),Yr=/.*?/,Wr=(e,t)=>t.context==="table"?C(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Jr=T(Wr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Yr]}),Xr=/^[$%] .+$/,Vr=(e,t)=>{var r;if(t.context==="table")return C(e,t);let o=(r=e[0])!==null&&r!==void 0?r:"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:o,text:n}]},Zr=T(Vr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Xr]}),eo=/\[\s+\]/,to=(e,t)=>t.context==="table"?C(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],ro=T(to,{parseOnNested:!1,parseOnQuoted:!0,patterns:[eo]}),oo=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,no=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,so=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,ao=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,co=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||po(e),po=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),lo=(e,t)=>{if(t.context==="table")return C(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).trimLeft():"",[s,a]=co(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},uo=T(lo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[oo,no,so,ao]}),mo=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,fo=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,go=/\[https?:\/\/[^\s\]]+\]/,ho=/https?:\/\/[^\s]+/,xo=(e,t)=>{if(t.context==="table")return C(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},yo=T(xo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[mo,fo,go,ho]}),Bt=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Ft=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Eo=e=>{let[t="",r="",o=""]=e.split(","),n=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(o)?parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:a}},bo=(e,t)=>{var r;if(t.context==="table")return C(e,t);let o=(r=e.match(Bt))!==null&&r!==void 0?r:e.match(Ft);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=n?o:[o[0],o[2],o[1]],{latitude:i,longitude:c,zoom:d}=Eo(s),p=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${i},${c},${d}z:https://www.google.com/maps/@${i},${c},${d}z;return[{type:"googleMap",raw:e,latitude:i,longitude:c,zoom:d,place:a,url:p}]},wo=T(bo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Bt,Ft]}),ko=/\[\/?[^[\]]+\]/,vo=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},Lo=T(vo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ko]}),To=/(?:^|\s)#\S+/,Co=(e,t)=>{if(t.context==="table")return C(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...C(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},Io=T(Co,{parseOnNested:!0,parseOnQuoted:!0,patterns:[To]}),Po=/^[0-9]+\. .*$/,Ro=(e,t)=>{if(t.context==="table")return C(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:U(s,{...t,nested:!0})}]},No=T(Ro,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Po]}),So=(e,t,r)=>{var o;return e===""?[]:(o=r?.())!==null&&o!==void 0?o:[]},Oo=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>wr(t,r))(),U=Oo(So,Lr,Ir,Jr,Zr,Gr,ro,Qr,Sr,Dr,$r,uo,yo,Br,wo,Lo,Io,No),Mo=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(a=>a.text.substring(o+1)).map(a=>a.split(" ").map(i=>U(i,{nested:!1,quoted:!1,context:"table"})))}},Bo=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:U(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},Fo=e=>{switch(e.type){case"title":return Er(e);case"codeBlock":return br(e);case"table":return Mo(e);case"line":return Bo(e)}},jo=e=>e.split( ).map(t=>{var r,o,n;return{indent:(n=(o=(r=/^\s+/.exec(t))===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.length)!==null&&n!==void 0?n:0,text:t}}),Do=(e,t)=>{var r,o;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((o=(r=e.rows[0])===null||r===void 0?void 0:r.indent)!==null&&o!==void 0?o:0)},jt=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Do(r,t)?(r.rows.push(t),e):(e.push({type:/^\s*code:/.test(t.text)?"codeBlock":/^\s*table:/.test(t.text)?"table":"line",rows:[t]}),e)},Uo=(e,t)=>{var r;if(!((r=t.hasTitle)!==null&&r!==void 0)||r){let[o,...n]=e;return o===void 0?[]:[{type:"title",rows:[o]},...n.reduce(jt,[])]}return e.reduce(jt,[])},Dt=(e,t)=>{var r;let o=jo(e);return Uo(o,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(Fo)};var Ao=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,$o=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,qo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,Ho=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Ce=e=>{if(Ao.test(e)){let t=new URL(e).searchParams,r=t.get("v");if(r)return{pathType:"com",videoId:r,params:t}}{let t=e.match($o);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(qo);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(Ho);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Ut=e=>{let t=Dt(e,{hasTitle:!0}).flatMap(u=>{switch(u.type){case"codeBlock":case"title":return[];case"line":case"table":return u}}),r=new Map,o=[],n=new Set,s=[],a=new Set,i=[],c=null,d=new Set,p=new Set,g=new RegExp(${location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),m=u=>{switch(u.type){case"hashTag":if(r.has(P(u.href)))return;r.set(P(u.href),!1),o.push(u.href);return;case"link":switch(u.pathType){case"relative":{let l=At(u.href);if(r.get(P(l)))return;r.set(P(l),!0),o.push(l);return}case"root":{let l=At(u.href);if(/^\/[\w\d-]+\/?$/.test(l)||n.has(P(l)))return;n.add(P(l)),s.push(l);return}case"absolute":{let l=Ce(u.href);if(l&&l.pathType!=="list"){c??=https://i.ytimg.com/vi/${l.videoId}/mqdefault.jpg;return}let x=u.href.match(g)?.[1];x&&d.add(x);return}default:return}case"icon":case"strongIcon":{if(u.pathType==="root"||a.has(P(u.path)))return;a.add(P(u.path)),i.push(u.path);return}case"image":case"strongImage":{c??=u.src.endsWith("/thumb/1000")?u.src.replace(/\/thumb\/1000$/,"/raw"):u.src;{let l=u.src.match(g)?.[1];l&&d.add(l)}if(u.type==="image"){let l=u.link.match(g)?.[1];l&&d.add(l)}return}case"helpfeel":p.add(u.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let l of u.nodes)m(l);return}default:return}},b=[];for(let u of t)switch(u.type){case"line":for(let l of u.nodes)m(l);continue;case"table":{for(let l of u.cells)for(let x of l)for(let w of x)m(w);if(!["infobox","cosense"].includes(u.fileName))continue;b.push(...u.cells.map(l=>l.map(x=>x.map(w=>w.raw).join("")).join(" ").trim()));continue}}return[o,s,i,c,[...d],[...p],b]},At=e=>e.replace(/#[a-f\d]{24,32}$/,""),$t=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?[t.trimStart().slice(2)]:[]);var G=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));function*qt(e,t,r){let o=t.flatMap(b=>b.split( ));for(let b of Te(e.lines,o,{userId:r}))yield b;(e.lines[0].text!==o[0]||!e.persistent)&&(yield{title:o[0]});let n=e.lines.slice(1,6).map(b=>b.text),s=o.slice(1,6);n.join("")!==s.join("")&&(yield{descriptions:s});let[a,i,c,d,p,g,m]=Ut(o.join(
));G(e.links,a)||(yield{links:a}),G(e.projectLinks,i)||(yield{projectLinks:i}),G(e.icons,c)||(yield{icons:c}),e.image!==d&&(yield{image:d}),G(e.files,p)||(yield{files:p}),G($t(e.lines),g)||(yield{helpfeels:g}),G(e.infoboxDefinition,m)||(yield{infoboxDefinition:m})}var R=async(e,t,r,o)=>{let[n,s,a]=await Promise.all([Y(e,t),Le(e),Nt()]),i={...n,projectId:s,userId:a},c=o?.socket,d=c??await z();await Ee(d);try{let{request:p}=ye(d),g=0,m=[],b;for(;o?.maxAttempts===void 0||g<o.maxAttempts;){let u=r(i,g,m,b);if(m=u instanceof Promise?await u:u,g++,m.length===0)return{ok:!0,value:i.commitId};let l={kind:"page",projectId:s,pageId:i.id,parentId:i.commitId,userId:a,changes:m,cursor:null,freeze:!0};for(;;){let x=await p("socket.io-request",{method:"commit",data:l});if(x.ok)return i.commitId=x.value.commitId,{ok:!0,value:i.commitId};let w=x.value.name;if(w==="UnexpectedError"){let L=new Error;throw L.name=x.value.name,L.message=JSON.stringify(x.value),L}if(w==="TimeoutError"||w==="SocketIOError"){await j(3e3);break}w==="NotFastForwardError"&&(i={...await Y(e,t),projectId:s,userId:a}),b=w}}return{ok:!1,value:{name:"RetryError",attempts:g,message:Retrying exceeded the maxAttempts (${g}).}}}finally{c||await be(d)}};var Ht=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,o=t?.[2]?parseInt(t[2])+1:2;return${r}_${o}};var xd=(e,t,r,o)=>R(e,t,async(n,s,a,i)=>{if(i==="DuplicateTitleError"){let p=Ht(t);return a.map(g=>("title"in g&&(g.title=p),g))}let c=r(n.lines,{...n,attempts:s}),d=c instanceof Promise?await c:c;return d===void 0?[]:d.length===0?[{deleted:!0}]:[...qt(n,d,n.userId)]},o);var kd=(e,t,r)=>R(e,t,o=>o.persistent?[{deleted:!0}]:[],r);var Id=(e,t,r)=>R(e,t,o=>{if(o.pin>0||!o.persistent&&!(r?.create??!1))return[];let n=[{pin:_o()}];return o.persistent||n.unshift({title:t}),n},r),Pd=(e,t,r)=>R(e,t,o=>o.pin==0||!o.persistent?[]:[{pin:0}],r),_o=()=>Number.MAX_SAFE_INTEGER-Math.floor(Date.now()/1e3);async function*jd(e,t,r){let o=await Le(e),n=r?.socket,s=n??await z();await Ee(s);let{request:a,response:i}=ye(s);try{await a("socket.io-request",{method:"room:join",data:{projectId:o,pageId:null,projectUpdatesStream:!0}}),yield*i(...t.map(c=>projectUpdatesStream:${c}))}finally{n||await be(s)}}function Me(e){if(Array.isArray(e)||!(e instanceof Object))return!1;let t=e,{filename:r,content:o,lang:n}=t;return typeof r=="string"&&(typeof o=="string"||Array.isArray(o)&&(o.length==0||typeof o[0]=="string"))&&(typeof n=="string"||n===void 0)}var Kd=(e,t,r)=>{let o=Go(e),n=q(t),s=t.bodyLines.map(a=>({...a,text:a.text.slice(n)}));return R(t.pageInfo.projectName,t.pageInfo.pageTitle,a=>{let i=Te(s,o,a),c=[...Ko([...i],t)];if(Me(e)){let d=zo(e,t);d&&c.push(d)}return r?.debug&&(console.log("%cvvv original code block vvv","color: limegreen;"),console.log(t),console.log("%cvvv new codes vvv","color: limegreen;"),console.log(e),console.log("%cvvv commits vvv","color: limegreen;"),console.log(c)),c},r)},Go=e=>{let t=Me(e)?e.content:e;return Array.isArray(t)?t:t.split(
)};function*Ko(e,t){let{nextLine:r}=t,o=" ".repeat(q(t));for(let n of e)"_delete"in n?yield n:"_update"in n?yield{...n,lines:{...n.lines,text:o+n.lines.text}}:n._insert!="_end"||r===null?yield{...n,lines:{...n.lines,text:o+n.lines.text}}:yield{_insert:r.id,lines:{...n.lines,text:o+n.lines.text}}}var zo=(e,t)=>{let r=t.titleLine.id,o=ie(t.titleLine.text);if(o&&e.filename.trim()==o.filename&&e.lang?.trim()==o.lang)return null;let n=(()=>{let a=e.filename.match(/.+\.(.*)$/);return a===null?e.filename:a[1]===""?"":a[1].trim()})(),s=e.filename+(e.lang&&e.lang!=n?(${e.lang}):"");return{_update:r,lines:{text:" ".repeat(q(t)-1)+"code:"+s}}};var tl=(e,t,r,o)=>{let n={insertPositionIfNotExist:"notInsert",isInsertEmptyLineInTail:!0,debug:!1},s=o?{...n,...o}:n;return R(t,r,async a=>{let i=a.lines,c=await Ve({project:t,title:r,lines:i},{filename:e.filename}),d=[...Yo(c,e,i,{...s,userId:a.userId})];if(s.debug){console.log("%cvvv original code Blocks vvv","color: limegreen;"),console.log(c),console.log("%cvvv new codes vvv","color: limegreen;");let p=Array.isArray(e.content)?e.content:e.content.split(
);console.log(p),console.log("%cvvv commits vvv","color: limegreen;"),console.log(d)}return d},o)},Qo=e=>e.map(t=>{let r=q(t);return t.bodyLines.map(o=>({...o,text:o.text.slice(r)}))}).flat();function*Yo(e,t,r,{userId:o,insertPositionIfNotExist:n,isInsertEmptyLineInTail:s}){function a(m){return" ".repeat(q(m))}let i=[...e],c=Qo(e);if(i.length<=0){if(n==="notInsert")return;let m=n==="top"&&r.length>1?r[1]:null,b={_insert:m?.id??"_end",lines:{id:Q(o),text:Wo(t)}};yield b,i.push({titleLine:{...b.lines,userId:o,created:-1,updated:-1},bodyLines:[],nextLine:m})}let{buildSES:d}=we(c.map(m=>m.text),Array.isArray(t.content)?t.content:t.content.split(
)),p=0,g=!1;for(let m of ke(d())){let{lineId:b,codeIndex:u}=(()=>{if(p>=c.length){let x=i.length-1;return{lineId:i[x].nextLine?.id??"_end",codeIndex:x}}return{lineId:c[p].id,codeIndex:i.findIndex(x=>x.bodyLines.some(w=>w.id==c[p].id))}})(),l=i[u];if(m.type=="added"){let x=b==l.bodyLines[0]?.id&&u>=1?i[u-1]:i[u],w=x?.nextLine?.id??"_end";yield{_insert:w,lines:{id:Q(o),text:a(x)+m.value}},w=="_end"&&(g=!0);continue}else m.type=="deleted"?yield{_delete:b,lines:-1}:m.type=="replaced"&&(yield{_update:b,lines:{text:a(l)+m.value}});p++}g&&s&&(yield{_insert:"_end",lines:{id:Q(o),text:""}})}var Wo=e=>code:${e.filename+(e.lang?(${e.lang}):"")}`;var Jo=/https?:\/\/vimeo\.com\/(0-9+)/i,_t=e=>{let t=e.match(Jo);if(!!t)return t1};var Xo=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/(a-zA-Z\d_-+)(?:\?^\s{0,100}|)/,Gt=e=>{let t=e.match(Xo);if(!t)return;let,r,o=t;return{videoId:o,pathType:r}};var Vo=/https?:\/\/anchor\.fm\/a-zA-Z\d_-+\/episodes\/(a-zA-Z\d_-+(?:\/a-zA-Z\d_-+)?)(?:\?^\s{0,100}|)/,Kt=e=>{let t=e.match(Vo);if(!t)return;let,r=t;return r};var wl=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let a=Ce(n);if(a)return{type:"youtube",href:n,...a,...s};let i=_t(n);if(i)return{type:"vimeo",videoId:i,href:n,...s};let c=Gt(n);if(c)return{type:"spotify",href:n,...c,...s};let d=Kt(n);if(d)return{type:"anchor-fm",videoId:d,href:n,...s};if(en(n))return{type:"video",href:n,...s}}return Zo(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},Zo=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),en=e=>/\.(?:mp4|webm)$/.test(e);export{N as UnexpectedResponseError,X as caret,fe as click,$i as computeLine,Ee as connect,y as cookie,Hi as cursor,qi as cursorLine,cc as deleteLines,kd as deletePage,be as disconnect,dr as downBlocks,kt as downLines,Ai as editor,M as encodeTitleURI,Jn as exportPages,Ac as extractCodeFiles,Rc as fetchApiCache,Ic as findLatestCache,Ba as focusEnd,le as getBaseLine,I as getCSRFToken,xt as getCharDOM,sr as getChars,tt as getCodeBlock,Ve as getCodeBlocks,xa as getDOMFromPoint,ca as getExternalLink,la as getFormula,$s as getGyazoToken,ht as getHeadCharDOM,gt as getHeadLineDOM,fa as getIndentCount,ga as getIndentLineCount,ir as getIndex,pa as getInternalLink,ft as getLine,me as getLineCount,ue as getLineDOM,de as getLineId,_ as getLineNo,Re as getLines,da as getLink,Xe as getLinks,ua as getNextLine,ne as getPage,ma as getPrevLine,oe as getProfile,se as getProject,Je as getSnapshots,Ge as getTable,ha as getTailCharDOM,Se as getTailLineDOM,Ne as getText,Ms as getTweetInfo,Cs as getWebPageTitle,_a as goChar,$a as goEnd,Aa as goEndWithoutBlank,ge as goHead,qa as goHeadLine,Ua as goHeadWithoutBlank,Ha as goLastLine,D as goLine,Gi as grid,yt as holdDown,Wn as importPages,mc as indentBlocks,pc as indentLines,nc as insertIcon,ic as insertLine,vt as insertText,sc as insertTimestamp,J as isCharDOM,Pe as isLineDOM,W as lines,qe as listPages,We as listProjects,jd as listenStream,E as makeError,kp as makeSocket,gc as moveBlocks,ja as moveDown,cr as moveLeft,lc as moveLines,uc as moveLinesBefore,Da as moveRight,Fa as moveUp,fr as open,Tc as openInTheSameTab,fc as outdentBlocks,dc as outdentLines,Ji as pageCustomButtons,Yi as pageEditButtons,nr as pageEditMenu,Qi as pageInfoMenu,zi as pageMenu,wl as parseAbsoluteLink,xd as patch,Id as pin,_o as pinNumber,Ki as popupMenu,Pc as prefetch,h as press,Tt as pushPageTransition,Wi as randomJumpButton,ds as readLinks,Xt as readLinksBulk,os as readSnapshots,Jt as readSnapshotsBulk,oc as redo,ac as replaceLines,qn as replaceLinks,mn as revertTitleLc,Qa as scrollDown,Ka as scrollHalfDown,Ga as scrollHalfUp,za as scrollUp,ys as searchForJoinedProjects,xs as searchForPages,Es as searchForWatchList,_i as selections,f as setDefaults,j as sleep,lt as statusBar,Bc as takeCursor,K as takeInternalLines,Dc as takeSelection,xe as takeStores,F as textInput,fn as toReadableTitleURI,P as toTitleLc,rc as undo,Pd as unpin,pr as upBlocks,wt as upLines,Kd as updateCodeBlock,tl as updateCodeFile,fi as uploadToGCS,yc as useStatusBar};