SharedUserScripts-min
全プロジェクトで使うUserScript
code:script.js
function Fr(e){return Array.isArray(e)}function He(e){return typeof e=="string"}var fi=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var mi=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Jn=()=>gi(document.getElementsByClassName("lines").item(0),"div.lines");var zt=()=>{let e=document.getElementById("text-input");if(e)return mi(e,"textarea#text-input"),e};var di=()=>gi(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),gi=(e,t)=>{if(e)return fi(e,t),e};var Yn=()=>{let e=Jn();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 by=2**31-1;var hi=e=>{let t=zt();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});return t.dispatchEvent(r),scrapbox.Page.waitForSave()};var xi=()=>{let e=di();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 n=yi(...r);n&&t.append(n)},dispose:()=>t.remove(),Symbol.dispose:()=>t.remove()}},yi=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnLu();case"check-circle":returnvu();case"exclamation-triangle":returnFu();case"text":returnMr(n.text);case"group":{let o=yi(...n.items);return o?o:[]}}});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},Mr=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Lu=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Mr(e)},vu=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Mr(e)},Fu=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Mr(e)};var Ft=e=>...e.map((t,r)=>t===" "?"_":!Mu.includes(t)||r===e.length-1&&Uu.includes(t)?encodeURIComponent(t):t).join(""),Mu='@$&+=:;",',Uu=':;",';var Ur=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let i=await(await caches.open(n)).match(e,t);if(i)return i}},Ir=async(e,t)=>{let r=t.clone();return await(await caches.open(Iu(new Date))).put(e,r)},Iu=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var Qn=(e,...t)=>{let r=t.reduce((n,o)=>He(n)?n:n instanceof Promise?n.then(i=>He(i)?i:o(i)):o(n),e);return r instanceof Promise?r.then(n=>${n}):${e}};function Ue(e){return e.val}function ze(e){return e.err}var Ei=" must not return ",$u="transformer",ju="recoverer",Bu="defaultValue",qt=$u+Ei,ut="called with ",Kt=Bu+" must not be ",Jt=ju+Ei;var Hu="Ok",Ri="Err",bi=ut+Ri,wi=ut+Hu,Wu="Carrying E in "+Ri+" instead of throwing it directly. See .cause",Xn="an instance of Error of the current realm.",tR="The thrown value is not "+Xn,rR="The contained E should be "+Xn,Vu="This .cause is not "+Xn;function ke(e){return e.ok}function re(e){return{ok:!0,val:e,err:null}}function ee(e){return!e.ok}function X(e){return{ok:!1,val:null,err:e}}function pe(e){return ki(e,bi)}function Le(e){return Ti(e,wi)}function ki(e,t){if(ee(e))throw new TypeError(t);return e.val}function Ti(e,t){if(ke(e))throw new TypeError(t);return e.err}async function qe(e,t){if(ee(e))return e;let r=Ue(e),n=await t(r);return re(n)}function Zn(e,t,r){if(ke(e)){let o=Ue(e);return r(o)}let n=ze(e);return t(n)}var Dr="null",lb=qt+Dr,qu=ut+Dr,cb=Kt+Dr,ub=Jt+Dr;var $r="undefined",gb=qt+$r,Ku=ut+$r,hb=Kt+$r,xb=Jt+$r;var Yt=e=>e.ok?re(e):X({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Ai=e=>window.GM_fetch?.(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x)?.then?.(t=>qe(Yt(t),r=>r.json()));var jr=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}};var _i=(e,t)=>{let{title:r,description:n,metadataIsPublic:o,collectionId:i,refererURL:s,accessToken:a,created:l,app:c,fetch:u}=jr(t),p=new FormData;return p.append("imagedata",e),p.append("access_token",a),s&&p.append("referer_url",s.toString()),c!==void 0&&p.append("app",c),r!==void 0&&p.append("title",r),n!=null&&p.append("desc",n),i&&p.append("collection_id",i),o&&p.append("metadata_is_public","true"),l!==void 0&&p.append("created_at",${l}),u("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:p})};function ve(e){return e.val}function Ie(e){return e.err}var Ni=" must not return ",Yu="transformer",Qu="recoverer",Xu="defaultValue",Qt=Yu+Ni,pt="called with ",Xt=Xu+" must not be ",Zt=Qu+Ni;var Zu="Ok",Si="Err",Ci=pt+Si,ep=pt+Zu,tp="Carrying E in "+Si+" instead of throwing it directly. See .cause",eo="an instance of Error of the current realm.",qk="The thrown value is not "+eo,Kk="The contained E should be "+eo,rp="This .cause is not "+eo;function Ne(e){return e.ok}function fe(e){return{ok:!0,val:e,err:null}}function Y(e){return!e.ok}function Fe(e){return{ok:!1,val:null,err:e}}function ae(e){return Pi(e,Ci)}function Pi(e,t){if(Y(e))throw new TypeError(t);return e.val}function yr(e,t){if(Y(e))return e;let r=ve(e),n=t(r);return fe(n)}async function ge(e,t){if(Y(e))return e;let r=ve(e),n=await t(r);return fe(n)}async function Re(e,t){if(Ne(e))return e;let r=Ie(e),n=await t(r);return Fe(n)}async function Br(e,t){if(Ne(e))return e;let r=Ie(e);return await t(r)}var Hr="null",sO=Qt+Hr,ip=pt+Hr,aO=Xt+Hr,lO=Zt+Hr;var Wr="undefined",mO=Qt+Wr,sp=pt+Wr,dO=Xt+Wr,gO=Zt+Wr;var he=e=>e.ok?fe(e):Fe({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var vi=async(e,t)=>{let r=new Request(e,t);try{return fe(await globalThis.fetch(r))}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return Fe({name:"AbortError",message:n.message,request:r});if(n instanceof TypeError)return Fe({name:"NetworkError",message:n.message,request:r});throw n}};var me=e=>{let{fetch:t=vi,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Fi=e=>{let{sid:t,hostName:r}=me(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:xe(t)}}:void 0)},Mi=e=>ge(he(e),async t=>await t.json()),Ui=(()=>{let e=async t=>{let{fetch:r,...n}=me(t??{}),o=await r(Fi(n));return Y(o)?o:Mi(ae(o))};return e.toRequest=Fi,e.fromResponse=Mi,e})();var xe=e=>connect.sid=${e},ft=async e=>{let t=e?.csrf??globalThis._csrf;return t?fe(t):yr(await Ui(e),r=>r.csrfToken)};function Vr(e,t={}){if(e===null)return"null";if(Array.isArray(e))return cp(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:up(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function cp(e,t){let{threshold:r=20}=t,n=e.map(s=>Vr(s,t)),o=n.join(", ");if(o.length<=r)return[${o}];let i=n.join(`, );return[
${Ii(2,i)}
]}function up(e,t){let{threshold:r=20}=t,n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(s=>${s.toString()}: ${Vr(es,t)}),o=n.join(", ");if(o.length<=r)return{${o}};let i=n.join(, );return{
${Ii(2,i)}
}}function Ii(e,t){let r=" ".repeat(e);return t.split(
).map(n=>${r}${n}).join(
)}function Gr(e,t,...r){let n;return Object.defineProperties(e,{name:{get:()=>n||(n=${t}(${r.map(o=>Vr(o)).join(", ")}),n)}})}function Di(e){return Gr(t=>Fr(t)&&t.every(r=>e(r)),"isArrayOf",e)}function to(e){let t=new Set(e);return Gr(r=>t.has(r),"isLiteralOneOf",e)}function ro(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}var De=async(e,t)=>{let r=e.response.clone(),n=to(t);try{let o=await r.json();if(!ro(o))return;if(r.status===422){if(!He(o.message))return;for(let i of["NoQueryError","InvalidURLError"])if(t.includes(i))return{name:i,message:o.message}}return!n(o.name)||!He(o.message)?void 0:o.name==="NotLoggedInError"?!ro(o.detals)||!He(o.detals.project)||!Di(pp)(o.detals.loginStrategies)?void 0:{name:o.name,message:o.message,details:{project:o.detals.project,loginStrategies:o.detals.loginStrategies}}:{name:o.name,message:o.message}}catch(o){if(o instanceof SyntaxError)return;throw o}},pp=to(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var zr="null or undefined",er=Qt+zr,fp=pt+zr,no=Xt+zr,qr=Zt+zr;function rt(e){return e==null}function Kr(e){return rt(e)?Fe(void 0):fe(e)}var $i=(e,t)=>{let{sid:r,hostName:n}=me(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:xe(r)}}:void 0)},ji=async e=>ge(await Re(he(e),async t=>await De(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),Bi=(()=>{let e=async(t,r)=>{let{fetch:n}=me(r??{}),o=$i(t,r),i=await n(o);return Y(i)?i:ji(ae(i))};return e.toRequest=$i,e.fromResponse=ji,e})();var Hi=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=me(t??{}),i=await ft(t);if(Y(i))return i;let s=new Request(https://${n}/api/embed-text/url?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":ae(i),...r?{Cookie:xe(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(s);return Y(a)?a:ge(await Re(he(ae(a)),async l=>await De(l,["SessionError","BadRequestError","InvalidURLError"])??l),async l=>{let{title:c}=await l.json();return c})};var Wi=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=me(t??{}),i=await ft(t);if(Y(i))return i;let s=new Request(https://${n}/api/embed-text/twitter?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":ae(i),...r?{Cookie:xe(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(s);return Y(a)?a:Re(await ge(he(ae(a)),l=>l.json()),async l=>l.response.status===422?{name:"InvalidURLError",message:(await l.response.json()).message}:await De(l,["SessionError","BadRequestError"])??l)};var Vi=async e=>{let{fetch:t,sid:r,hostName:n,gyazoTeamsName:o}=me(e??{}),i=new Request(https://${n}/api/login/gyazo/oauth-upload/token${o??gyazoTeamsName=${o}:""},r?{headers:{Cookie:xe(r)}}:void 0),s=await t(i);return Y(s)?s:ge(await Re(he(ae(s)),async a=>await De(a,["NotLoggedInError"])??a),a=>a.json().then(l=>l.token))};var qi=e=>{let t=typeof e=="string"?new TextEncoder().encode(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=[1732584193,4023233417,2562383102,271733878],n=new Uint8Array(oo),o=0,i=0,s=0;[r,n,o,i,s]=zi(r,n,o,i,s,t);let a=oo-o;a<9&&(a+=oo);let l=new Uint8Array(a);l[0]=128,[i,s]=[i<<3,s<<3|i>>>29],l[l.length-8]=i&255,l[l.length-7]=i>>>8&255,l[l.length-6]=i>>>16&255,l[l.length-5]=i>>>24&255,l[l.length-4]=s&255,l[l.length-3]=s>>>8&255,l[l.length-2]=s>>>16&255,l[l.length-1]=s>>>24&255,[r,n,o,i,s]=zi(r,n,o,i,s,new Uint8Array(l.buffer));let c=new ArrayBuffer(16),u=new DataView(c);return u.setUint32(0,r[0],!0),u.setUint32(4,r[1],!0),u.setUint32(8,r[2],!0),u.setUint32(12,r[3],!0),c},oo=64,j=(e,t)=>e<<t|e>>>32-t,$e=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Gi=(e,t)=>{let[r,n,o,i]=e,s=$e(t,0),a=$e(t,4),l=$e(t,8),c=$e(t,12),u=$e(t,16),p=$e(t,20),m=$e(t,24),f=$e(t,28),E=$e(t,32),S=$e(t,36),C=$e(t,40),_=$e(t,44),W=$e(t,48),R=$e(t,52),w=$e(t,56),b=$e(t,60);return r=n+j(((o^i)&n^i)+r+s+3614090360,7),i=r+j(((n^o)&r^o)+i+a+3905402710,12),o=i+j(((r^n)&i^n)+o+l+606105819,17),n=o+j(((i^r)&o^r)+n+c+3250441966,22),r=n+j(((o^i)&n^i)+r+u+4118548399,7),i=r+j(((n^o)&r^o)+i+p+1200080426,12),o=i+j(((r^n)&i^n)+o+m+2821735955,17),n=o+j(((i^r)&o^r)+n+f+4249261313,22),r=n+j(((o^i)&n^i)+r+E+1770035416,7),i=r+j(((n^o)&r^o)+i+S+2336552879,12),o=i+j(((r^n)&i^n)+o+C+4294925233,17),n=o+j(((i^r)&o^r)+n+_+2304563134,22),r=n+j(((o^i)&n^i)+r+W+1804603682,7),i=r+j(((n^o)&r^o)+i+R+4254626195,12),o=i+j(((r^n)&i^n)+o+w+2792965006,17),n=o+j(((i^r)&o^r)+n+b+1236535329,22),r=n+j(((n^o)&i^o)+r+a+4129170786,5),i=r+j(((r^n)&o^n)+i+m+3225465664,9),o=i+j(((i^r)&n^r)+o+_+643717713,14),n=o+j(((o^i)&r^i)+n+s+3921069994,20),r=n+j(((n^o)&i^o)+r+p+3593408605,5),i=r+j(((r^n)&o^n)+i+C+38016083,9),o=i+j(((i^r)&n^r)+o+b+3634488961,14),n=o+j(((o^i)&r^i)+n+u+3889429448,20),r=n+j(((n^o)&i^o)+r+S+568446438,5),i=r+j(((r^n)&o^n)+i+w+3275163606,9),o=i+j(((i^r)&n^r)+o+c+4107603335,14),n=o+j(((o^i)&r^i)+n+E+1163531501,20),r=n+j(((n^o)&i^o)+r+R+2850285829,5),i=r+j(((r^n)&o^n)+i+l+4243563512,9),o=i+j(((i^r)&n^r)+o+f+1735328473,14),n=o+j(((o^i)&r^i)+n+W+2368359562,20),r=n+j((n^o^i)+r+p+4294588738,4),i=r+j((r^n^o)+i+E+2272392833,11),o=i+j((i^r^n)+o+_+1839030562,16),n=o+j((o^i^r)+n+w+4259657740,23),r=n+j((n^o^i)+r+a+2763975236,4),i=r+j((r^n^o)+i+u+1272893353,11),o=i+j((i^r^n)+o+f+4139469664,16),n=o+j((o^i^r)+n+C+3200236656,23),r=n+j((n^o^i)+r+R+681279174,4),i=r+j((r^n^o)+i+s+3936430074,11),o=i+j((i^r^n)+o+c+3572445317,16),n=o+j((o^i^r)+n+m+76029189,23),r=n+j((n^o^i)+r+S+3654602809,4),i=r+j((r^n^o)+i+W+3873151461,11),o=i+j((i^r^n)+o+b+530742520,16),n=o+j((o^i^r)+n+l+3299628645,23),r=n+j((o^(n|~i))+r+s+4096336452,6),i=r+j((n^(r|~o))+i+f+1126891415,10),o=i+j((r^(i|~n))+o+w+2878612391,15),n=o+j((i^(o|~r))+n+p+4237533241,21),r=n+j((o^(n|~i))+r+W+1700485571,6),i=r+j((n^(r|~o))+i+c+2399980690,10),o=i+j((r^(i|~n))+o+C+4293915773,15),n=o+j((i^(o|~r))+n+a+2240044497,21),r=n+j((o^(n|~i))+r+E+1873313359,6),i=r+j((n^(r|~o))+i+b+4264355552,10),o=i+j((r^(i|~n))+o+m+2734768916,15),n=o+j((i^(o|~r))+n+R+1309151649,21),r=n+j((o^(n|~i))+r+u+4149444226,6),i=r+j((n^(r|~o))+i+_+3174756917,10),o=i+j((r^(i|~n))+o+l+718787259,15),n=o+j((i^(o|~r))+n+S+3951481745,21),[e[0]+r>>>0,e[1]+n>>>0,e[2]+o>>>0,e[3]+i>>>0]},zi=(e,t,r,n,o,i)=>{let s=64-r;if(i.length<s)t.set(i,r),r+=i.length;else{t.set(i.slice(0,s),r),e=Gi(e,t);let a=s;for(;a+64<=i.length;)e=Gi(e,i.slice(a,a+64)),a+=64;t.fill(0).set(i.slice(a),0),r=i.length-a}return[n,o]=dp(n,o,i.length),[e,t,r,n,o]},dp=(e,t,r)=>(e+=r,e>4294967295&&(t+=1),[e>>>0,t]);var gp=new TextEncoder().encode("0123456789abcdef"),Ki=new Uint8Array(128).fill(16);gp.forEach((e,t)=>Ki[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Ki[e]=t+10);function Ji(e){return e*2}function Yi(e,t,r,n){for(;t<e.length;++t){let o=e[t];e[r++]=n[o>>4],e[r++]=n[o&15]}return r}function Qi(e,t){let r=e.length;if(e.byteOffset){let n=new Uint8Array(e.buffer);n.set(e),e=n.subarray(0,r)}return e=new Uint8Array(e.buffer.transfer(t)),e.set(e.subarray(0,r),t-r),[e,t-r]}var Xi=new TextEncoder().encode("0123456789abcdef"),Zi=new Uint8Array(128).fill(16);Xi.forEach((e,t)=>Zi[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Zi[e]=t+10);function es(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,r]=Qi(e,Ji(e.length));return Yi(t,r,0,Xi),new TextDecoder().decode(t)}var ts=async(e,t,r)=>{let n=${es(qi(await e.arrayBuffer()))},o=await hp(e,t,n,r);if(Y(o))return o;let i=ae(o);if("embedUrl"in i)return fe(i);let s=await xp(i.signedUrl,e,r);return Y(s)?s:yp(t,i.fileId,n,r)},hp=async(e,t,r,n)=>{let{sid:o,hostName:i,fetch:s,csrf:a}=me(n??{}),l={md5:r,size:e.size,contentType:e.type,name:e.name},c=await Br(Kr(a),()=>ft(n));if(Y(c))return c;let u=new Request(https://${i}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":ae(c),...o?{Cookie:xe(o)}:{}}}),p=await s(u);return Y(p)?p:ge(await Re(he(ae(p)),async m=>m.response.status===402?{name:"FileCapacityError",message:(await m.response.json()).message}:m),m=>m.json())},xp=async(e,t,r)=>{let{sid:n,fetch:o}=me(r??{}),i=await o(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...n?{Cookie:xe(n)}:{}}});return Y(i)?i:yr(await Re(he(ae(i)),async s=>s.response.headers.get("Content-Type")?.includes?.("/xml")?{name:"GCSError",message:await s.response.text()}:s),()=>{})},yp=async(e,t,r,n)=>{let{sid:o,hostName:i,fetch:s,csrf:a}=me(n??{}),l=await Br(Kr(a),()=>ft(n));if(Y(l))return l;let c=new Request(https://${i}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":ae(l),...o?{Cookie:xe(o)}:{}}}),u=await s(c);return Y(u)?u:ge(await Re(he(ae(u)),async p=>p.response.status===404?{name:"NotFoundError",message:(await p.response.json()).message}:p),p=>p.json())};var rs=(e,t)=>{let r=new FormData;return r.append("data",e),r.append("metadata",JSON.stringify({app:"Gyazo",title:e.name})),GM_fetch(https://gif.gyazo.com/${t?.teams?"teams":"gif"}/upload,{method:"POST",body:r,credentials:"include",headers:{Origin:"https://gyazo.com","sec-fetch-site":"same-site"},referrer:"https://gyazo.com/"})};var Jr="",ns=!1,Yr=new Map,os=async(e,t,r,n)=>{let o=Yr.get(e.href);if(o)return o;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let l=await GM_fetch(e);if(!l.ok)return;let c=l.headers.get("content-type")?.split?.(";")?.[0]??${e}.endsWith(".mp4")?"video/mp4":"video/webm",u=new File([await l.blob()],n||${t},{type:c});if(c==="video/mp4"){let f=await rs(u);if(f.ok){let E=new URL(await f.text());return Yr.set(e.href,E),E}}let p=await ts(u,r);if(ee(p))throw Error(Le(p).name);let m=new URL(pe(p).embedUrl);return Yr.set(e.href,m),m}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(ns){if(!Jr)return}else{let l=await Vi();if(ns=!0,ee(l)){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(Jr=pe(l)||"",!Jr){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let i=await GM_fetch(e);if(!i.ok)return;let s=await _i(await i.blob(),{accessToken:Jr,refererURL:t,description:n});if(ee(s))throw Error(Le(s).name);let a=new URL(pe(s).permalink_url);return Yr.set(e.href,a),a};var as=[["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]],Ep=Object.fromEntries([...as.map(([e,t])=>[t,e]),["'","'"],[" "," "]]),Rp=new Map(as),SC=new RegExp([${...Rp.keys().join("")}],"g");var bp={entityList:Ep},wp=1114111,kp=/&#([0-9]+);/g,Tp=/&#x(\p{AHex}+);/gu,is=new WeakMap;function io(e,t={}){let{entityList:r}={...bp,...t},n=is.get(r);return n||(n=new RegExp((${Object.keys(r).sort((o,i)=>i.length-o.length).join("|")}),"g"),is.set(r,n)),e.replaceAll(n,o=>r[o]).replaceAll(kp,(o,i)=>ss(i,10)).replaceAll(Tp,(o,i)=>ss(i,16))}function ss(e,t){let r=parseInt(e,t);return r>wp?"�":String.fromCodePoint(r)}var tr=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),n=[...e.entities.hashtags.map(s=>({type:"hashtag",...s})),...e.entities.symbols.map(s=>({type:"symbol",...s})),...e.entities.user_mentions.map(s=>({type:"mention",name:s.name,screenName:s.screen_name,indices:s.indices})),...e.entities.urls.map(s=>{let a={type:"url",indices:s.indices,url:new URL(s.expanded_url)};if(e.card&&e.card?.url===s.url){let{description:l,title:c}=e.card.binding_values,u="STRING";l?.type===u&&(a.description=l.string_value),c?.type===u&&(a.title=c.string_value)}return a}),...e.entities.media?.map?.(s=>({type:"media",indices:s.indices,media:e.mediaDetails?.flatMap?.(a=>a.url===s.url?[{type:a.type,url:new URL(a.video_info?.variants?.sort?.((l,c)=>(c.bitrate??0)-(l.bitrate??0))?.[0].url??a.media_url_https)}]:[])??[]}))??[]].sort((s,a)=>s.indices[0]-a.indices[0]),o=[];{let s=0,a=e.text;for(let{indices:l,...c}of n){let u=[...a].slice(0,l[0]-s).join("");o.push({type:"plain",text:io(u)}),o.push(c),a=[...a].slice(l[1]-s).join(""),s=l[1]}a&&o.push({type:"plain",text:io(a)})}let i={id:e.id_str,content:o,author:t,posted:r,replyCount:"reply_count"in e?e.reply_count:e.conversation_count};return e.self_thread&&(i.rootId=e.self_thread.id_str),e.in_reply_to_status_id_str&&(i.replyId=e.in_reply_to_status_id_str),e.parent&&(i.replyTo=tr(e.parent)),e.quoted_tweet&&(i.quote=tr(e.quoted_tweet)),i};var Op=["landing","product","enterprise","pricing","try-enterprise","contact","terms","privacy","jp-commercial-act","support","case","features","business","auth","login","logout","oauth2","_","api","app.html","assets","file","files","billing","billings","config","feed","index","io","new","opensearch","project","projects","search","setting","settings","setup-profile","slide","socket.io","stream","user","users"],Qr=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,n,o]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!n||Op.includes(n)?r:o?n===e?${decodeURIComponent(o)}:/${n}/${decodeURIComponent(o)}:/${n}};var ls=(e=Ap)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:www\.|mobile\.|m\.|)(?:twitter|x)\.com\/[A-Za-z0-9_]*\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let n=await(Ai(r)??Wi(t.href));if(ee(n))throw Le(n);let o=pe(n);return e("images"in o?{...o,id:r}:o,t)})():t},Ap=async e=>{if("images"in e)return gt(e);let{quote:t,replyTo:r,...n}=tr(e);return[...r?[...(await gt(r)).split( ).map(o=> > ${o}),...r.quote?(await gt(r.quote)).split(
).map(o=> > ${o}):[]]:[],...(await gt(n)).split(
).map(o=>> ${o}),...t?(await gt(t)).split(
).map(o=>> > ${o}):[]].join(
)?.map?.(o=>> ${ao(o)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(o=>[${o}])}]:[]].join(
);let r=e.content,n=e.author.screenName;return[@${ao(n)} ${t},...(await Promise.all(r.map(async o=>{switch(o.type){case"plain":return o.text;case"hashtag":return #${o.text} ;case"symbol":return #$${o.text} ;case"mention":return@${o.screenName};case"media":{let i=[],s=1;for(;s<o.media.length;s+=2)i.push([${await so(o.medias-1,t)}] [${await so(o.medias,t)}]);return s===o.media.length&&i.push([${await so(o.medias-1,t)}]), ${i.join(`
`)}
}case"url":return${Qr()(o.url)} }}))).join("").split(
)].join(
)},Xr="",_p=async()=>{if(Xr)return Xr;let e=await Bi(scrapbox.Project.name);if(ee(e))throw new Error(Le(e).name);return Xr=pe(e).id,Xr},so=async(e,t)=>await os(e.url,t,await _p(),"")??e.url,ao=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var cs=e=>window.GM_fetch?.(https://t.co/${e})?.then?.(t=>qe(Yt(t),async r=>{let n=new DOMParser().parseFromString(await r.text(),"text/html");try{return new URL(n.title)}catch(o){if(o instanceof TypeError)return;throw o}}));var us=e=>{let t=window.GM_fetch;if("bit.ly","amzn.to","amzn.asia","goo.gl","s.nikkei.com","apple.co","nico.ms","w.wiki".includes(e.hostname)&&t)return t(e).then(n=>n.ok?new URL(n.url):e);if(e.hostname!=="t.co")return e;let r=cs(e.pathname.slice(1));return r?r.then(n=>Zn(n,()=>e,o=>o??e)):e};var ps=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,o=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!o)return e;e.hostname=${o}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",n=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${n}#${r}]:[${t} - Wikipedia ${n}]};var fs=e=>{if(e.hostname!=="www.wikiwand.com")return e;let,t,r=e.pathname.match(/^\/(^\/+)\/(^\/+)/)??[];return!t||!r||(e.hostname=${t}.wikipedia.org,e.pathname=/wiki/${r},e.hash=e.hash.startsWith("#/")?#${e.hash.slice(2)}:e.hash),e};var lo=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var ms=/charset=(^;+)/,ds=e=>window.GM_fetch?.(${e})?.then?.(t=>qe(Yt(t),async r=>{let n=r.headers.get("content-type")?.match?.(ms)?.1??await Np(r.clone());return new TextDecoder(n).decode(await r.arrayBuffer())})),Np=async e=>{let t=new DOMParser().parseFromString(await e.text(),"text/html");return t.querySelector("metacharset")?.getAttribute?.("charset")??t.querySelector('metahttp-equiv="content-type"')?.getAttribute?.("content")?.match?.(ms)?.1??"utf-8"};var gs=(e=Sp)=>async t=>e(await Cp(t),t),Sp=(e,t)=>{let r=(He(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},Cp=async e=>{let t=ds(e);if(!t){let n=await Hi(e);if(ee(n))throw Le(n);return pe(n)}let r=await t;if(ee(r))throw Le(r);return new DOMParser().parseFromString(pe(r),"text/html")};var hs=e=>{if(!/^(?:www\.)?amazon(?:\.co|com)?\.(?:au|br|ca|fr|de|in|it|jp|mx|nl|sg|es|tr|ae|uk|cn)$/.test(e.hostname))return e;let,t=e.pathname.match(/\/dp\/(\w\d+)/)??e.pathname.match(/\/gp\/product\/(\w\d+)/)??e.pathname.match(/\/exec\/obidos\/asin\/(\w\d+)/)??e.pathname.match(/\/o\/ASIN\/(\w\d+)/)??[];return t&&(e.hash="",e.search="",e.pathname=/dp/${t}),e};var xs=e=>{if(!/(?:0-9a-z-\.)?gyazo\.com/.test(e.hostname))return e;let,t=e.pathname.match(/^\/(0-9a-f{32})(?:\/raw)?$/)??[];return t?[https://gyazo.com/${t}]:e};var ys=(e,...t)=>{if(e instanceof URL)return Qn(new URL(e),...t);let r=0,n=0,o=0,i=!1,s=e.split(/(https?:\/\/\S+)/g).map(u=>{if(!/^https?:\/\/\S+$/.test(u))return u;r++;try{let p=Qn(new URL(u),...t);return He(p)?(n++,p):(i=!0,p,u)}catch(p){return console.error(p),o++,u}});if(!i)return s.join("");let{render:a,dispose:l}=xi(),c=()=>a({type:"spinner"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed});return c(),Promise.all(s.map(async u=>{if(He(u))return u;try{let p=await u0;return n++,p}catch(p){return console.error(p),o++,u1}finally{c()}})).then(u=>(a({type:"check-circle"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed}),u.join(""))).finally(()=>{setTimeout(l,1e3)})};var Es=async e=>{if("images"in e)return gt(e);let{quote:t,...r}=tr(e);return[...t?(await gt(t)).split(` ).map(n=>> ${n}):[],...(await gt(r)).split(
).map(n=>> ${n})].join(
)};var Pp=[lo,us,lo,fs,hs,Qr(),xs,ls(Es),ps,e=>{if(e.hostname==="raw.githubusercontent.com")return${e};if(e.hostname!=="github.com")return e;let[t,r,n]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!n)return e;let[,o,i]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${o&&i?L${o}-${i}/:o?L${o}/:""}https://raw.githubusercontent.com/${t}/${r}/${n}#.svg ${e}]},gs()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=ys(e,...Pp);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return hi(r)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[([^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~][^\[\]]*)\]/g,"$1")).join( );if(e!=t)return t}});scrapbox.PopupMenu.addButton({title:"[]",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[([^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~][^\[\]]*)\]/g,"$1")).join( );if(e!=t)return t}});scrapbox.PopupMenu.addButton({title:"$",onClick:e=>$ ${e}});scrapbox.PopupMenu.addButton({title:"LaTeX→Scb",onClick:e=>e.replace(/\$(.+?)\$/g,"[$ $1 ]").replace(/\\\((.+?)\\\)/g,"[$ $1 ]").replace(/\$\$(.+?)\$\$/gs,(t,r)=>"[$ "+r.replace(/\n/g," ").replace(/\s*>/g,"")+" ]").replace(/\\\[(.+?)\\\]/gs,(t,r)=>"[$ "+r.replace(/\n/g," ").replace(/\s*>/g,"")+" ]")});function Lp(e){let t=/[,&;]|and|\n/gi,r=new RegExp("[\\d†\\*]|(\\s[a-z])+(\\s*$)|ORCID|View ORCID Profile|Author links open overlay panel|https?:\\/\\/\\S+","gi"),n=i=>i.toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ");return e.replace(t,",").split(",").map(i=>i.replace(r,"").trim()).filter(i=>i.length>1).map(i=>${n(i)}).join(", ")}scrapbox.PopupMenu.addButton({title:"link authors",onClick:Lp});var Rs=document.createElement("i");function rr(e){let t="&"+e+";";Rs.innerHTML=t;let r=Rs.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}var vp={};function ws(e,t){let r=t||vp,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,o=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return ks(e,n,o)}function ks(e,t,r){if(Fp(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return bs(e.children,t,r)}return Array.isArray(e)?bs(e,t,r):""}function bs(e,t,r){let n=[],o=-1;for(;++o<e.length;)n[o]=ks(e[o],t,r);return n.join("")}function Fp(e){return!!(e&&typeof e=="object")}function Zr(e,t){let r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCharCode(r)}var Mp=/\\([!-/:-@[-{-~])|&(#(?:\d{1,7}|x\da-f{1,6})|\da-z{1,31});/gi;function en(e){return e.replace(Mp,Up)}function Up(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),o=n===120||n===88;return Zr(r.slice(o?2:1),o?16:10)}return rr(r)||e}function Me(e){return e.replace(/\t\n\r +/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Ip=/[!-\/:-@\[-\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,Se=wt(/[A-Za-z]/),Te=wt(/[\dA-Za-z]/),Ts=wt(/[#-'*+\--9=?A-Z^-~]/);function Mt(e){return e!==null&&(e<32||e===127)}var Er=wt(/\d/),Os=wt(/[\dA-Fa-f]/),As=wt(/[!-/:-@[-{-~]/);function U(e){return e!==null&&e<-2}function Q(e){return e!==null&&(e<0||e===32)}function z(e){return e===-2||e===-1||e===32}var Ut=wt(Ip),nt=wt(/\s/);function wt(e){return t;function t(r){return r!==null&&e.test(String.fromCharCode(r))}}function tn(e,t,r,n,o,i,s,a,l){let c=l||Number.POSITIVE_INFINITY,u=0;return p;function p(_){return _===60?(e.enter(n),e.enter(o),e.enter(i),e.consume(_),e.exit(i),m):_===null||_===32||_===41||Mt(_)?r(_):(e.enter(n),e.enter(s),e.enter(a),e.enter("chunkString",{contentType:"string"}),S(_))}function m(_){return _===62?(e.enter(i),e.consume(_),e.exit(i),e.exit(o),e.exit(n),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),f(_))}function f(_){return _===62?(e.exit("chunkString"),e.exit(a),m(_)):_===null||_===60||U(_)?r(_):(e.consume(_),_===92?E:f)}function E(_){return _===60||_===62||_===92?(e.consume(_),f):f(_)}function S(_){return!u&&(_===null||_===41||Q(_))?(e.exit("chunkString"),e.exit(a),e.exit(s),e.exit(n),t(_)):u<c&&_===40?(e.consume(_),u++,S):_===41?(e.consume(_),u--,S):_===null||_===32||_===40||Mt(_)?r(_):(e.consume(_),_===92?C:S)}function C(_){return _===40||_===41||_===92?(e.consume(_),S):S(_)}}function rn(e,t,r,n,o,i){let s=this,a=0,l;return c;function c(f){return e.enter(n),e.enter(o),e.consume(f),e.exit(o),e.enter(i),u}function u(f){return a>999||f===null||f===91||f===93&&!l||f===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?r(f):f===93?(e.exit(i),e.enter(o),e.consume(f),e.exit(o),e.exit(n),t):U(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),p(f))}function p(f){return f===null||f===91||f===93||U(f)||a++>999?(e.exit("chunkString"),u(f)):(e.consume(f),l||(l=!z(f)),f===92?m:p)}function m(f){return f===91||f===92||f===93?(e.consume(f),a++,p):p(f)}}function V(e,t,r,n){let o=n?n-1:Number.POSITIVE_INFINITY,i=0;return s;function s(l){return z(l)?(e.enter(r),a(l)):t(l)}function a(l){return z(l)&&i++<o?(e.consume(l),a):(e.exit(r),t(l))}}function nn(e,t,r,n,o,i){let s;return a;function a(m){return m===34||m===39||m===40?(e.enter(n),e.enter(o),e.consume(m),e.exit(o),s=m===40?41:m,l):r(m)}function l(m){return m===s?(e.enter(o),e.consume(m),e.exit(o),e.exit(n),t):(e.enter(i),c(m))}function c(m){return m===s?(e.exit(i),l(s)):m===null?r(m):U(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),V(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===s||m===null||U(m)?(e.exit("chunkString"),c(m)):(e.consume(m),m===92?p:u)}function p(m){return m===s||m===92?(e.consume(m),u):u(m)}}function It(e,t){let r;return n;function n(o){return U(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r=!0,n):z(o)?V(e,n,r?"linePrefix":"lineSuffix")(o):t(o)}}function be(e,t,r,n){let o=e.length,i=0,s;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,r=r>0?r:0,n.length<1e4)s=Array.from(n),s.unshift(t,r),e.splice(...s);else for(r&&e.splice(t,r);i<n.length;)s=n.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function We(e,t){return e.length>0?(be(e,e.length,0,t),e):t}function nr(e){if(e===null||Q(e)||nt(e))return 1;if(Ut(e))return 2}var _s="address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul",co="pre","script","style","textarea";function kt(e,t,r){let n=[],o=-1;for(;++o<e.length;){let i=eo.resolveAll;i&&!n.includes(i)&&(t=i(t,r),n.push(i))}return t}function on(e){let t={},r=-1,n,o,i,s,a,l,c;for(;++r<e.length;){for(;r in t;)r=tr;if(n=er,r&&n1.type==="chunkFlow"&&er-11.type==="listItemPrefix"&&(l=n1._tokenizer.events,i=0,i<l.length&&li1.type==="lineEndingBlank"&&(i+=2),i<l.length&&li1.type==="content"))for(;++i<l.length&&li1.type!=="content";)li1.type==="chunkText"&&(li1._isInFirstContentOfListItem=!0,i++);if(n0==="enter")n1.contentType&&(Object.assign(t,Dp(e,r)),r=tr,c=!0);else if(n1._container){for(i=r,o=void 0;i--&&(s=ei,s1.type==="lineEnding"||s1.type==="lineEndingBlank");)s0==="enter"&&(o&&(eo1.type="lineEndingBlank"),s1.type="lineEnding",o=i);o&&(n1.end=Object.assign({},eo1.start),a=e.slice(o,r),a.unshift(n),be(e,o,r-o+1,a))}}return!c}function Dp(e,t){let r=et1,n=et2,o=t-1,i=[],s=r._tokenizer||n.parserr.contentType(r.start),a=s.events,l=[],c={},u,p,m=-1,f=r,E=0,S=0,C=S;for(;f;){for(;e++o1!==f;);i.push(o),f._tokenizer||(u=n.sliceStream(f),f.next||u.push(null),p&&s.defineSkip(f.start),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(u),f._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),p=f,f=f.next}for(f=r;++m<a.length;)am0==="exit"&&am-10==="enter"&&am1.type===am-11.type&&am1.start.line!==am1.end.line&&(S=m+1,C.push(S),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(s.events=[],f?(f._tokenizer=void 0,f.previous=void 0):C.pop(),m=C.length;m--;){let _=a.slice(Cm,Cm+1),W=i.pop();l.unshift(W,W+_.length-1),be(e,W,2,_)}for(m=-1;++m<l.length;)c[E+lm0]=E+lm1,E+=lm1-lm0-1;return c}var sn={name:"attention",tokenize:jp,resolveAll:$p};function $p(e,t){let r=-1,n,o,i,s,a,l,c,u;for(;++r<e.length;)if(er0==="enter"&&er1.type==="attentionSequence"&&er1._close){for(n=r;n--;)if(en0==="exit"&&en1.type==="attentionSequence"&&en1._open&&t.sliceSerialize(en1).charCodeAt(0)===t.sliceSerialize(er1).charCodeAt(0)){if((en1._close||er1._open)&&(er1.end.offset-er1.start.offset)%3&&!((en1.end.offset-en1.start.offset+er1.end.offset-er1.start.offset)%3))continue;l=en1.end.offset-en1.start.offset>1&&er1.end.offset-er1.start.offset>1?2:1;let p=Object.assign({},en1.end),m=Object.assign({},er1.start);Ns(p,-l),Ns(m,l),s={type:l>1?"strongSequence":"emphasisSequence",start:p,end:Object.assign({},en1.end)},a={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},er1.start),end:m},i={type:l>1?"strongText":"emphasisText",start:Object.assign({},en1.end),end:Object.assign({},er1.start)},o={type:l>1?"strong":"emphasis",start:Object.assign({},s.start),end:Object.assign({},a.end)},en1.end=Object.assign({},s.start),er1.start=Object.assign({},a.end),c=[],en1.end.offset-en1.start.offset&&(c=We(c,"enter",en1,t],["exit",en1,t)),c=We(c,"enter",o,t],"enter",s,t,"exit",s,t,["enter",i,t),c=We(c,kt(t.parser.constructs.insideSpan.null,e.slice(n+1,r),t)),c=We(c,"exit",i,t],"enter",a,t,"exit",a,t,["exit",o,t),er1.end.offset-er1.start.offset?(u=2,c=We(c,"enter",er1,t],["exit",er1,t)):u=0,be(e,n-1,r-n+3,c),r=n+c.length-u-2;break}}for(r=-1;++r<e.length;)er1.type==="attentionSequence"&&(er1.type="data");return e}function jp(e,t){let r=this.parser.constructs.attentionMarkers.null,n=this.previous,o=nr(n),i;return s;function s(l){return i=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===i)return e.consume(l),a;let c=e.exit("attentionSequence"),u=nr(l),p=!u||u===2&&o||r.includes(l),m=!o||o===2&&u||r.includes(n);return c._open=!!(i===42?p:p&&(o||!m)),c._close=!!(i===42?m:m&&(u||!p)),t(l)}}function Ns(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Cs={name:"autolink",tokenize:Bp};function Bp(e,t,r){let n=0;return o;function o(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(f){return Se(f)?(e.consume(f),s):c(f)}function s(f){return f===43||f===45||f===46||Te(f)?(n=1,a(f)):c(f)}function a(f){return f===58?(e.consume(f),n=0,l):(f===43||f===45||f===46||Te(f))&&n++<32?(e.consume(f),a):(n=0,c(f))}function l(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Mt(f)?r(f):(e.consume(f),l)}function c(f){return f===64?(e.consume(f),u):Ts(f)?(e.consume(f),c):r(f)}function u(f){return Te(f)?p(f):r(f)}function p(f){return f===46?(e.consume(f),n=0,u):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):m(f)}function m(f){if((f===45||Te(f))&&n++<63){let E=f===45?m:p;return e.consume(f),E}return r(f)}}var Dt={tokenize:Hp,partial:!0};function Hp(e,t,r){return n;function n(i){return z(i)?V(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||U(i)?t(i):r(i)}}var uo={name:"blockQuote",tokenize:Wp,continuation:{tokenize:Vp},exit:Gp};function Wp(e,t,r){let n=this;return o;function o(s){if(s===62){let a=n.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),i}return r(s)}function i(s){return z(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function Vp(e,t,r){let n=this;return o;function o(s){return z(s)?V(e,i,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):i(s)}function i(s){return e.attempt(uo,t,r)(s)}}function Gp(e){e.exit("blockQuote")}var po={name:"characterEscape",tokenize:zp};function zp(e,t,r){return n;function n(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return As(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(i)}}var fo={name:"characterReference",tokenize:qp};function qp(e,t,r){let n=this,o=0,i,s;return a;function a(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),l}function l(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,s=Te,u(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,s=Os,u):(e.enter("characterReferenceValue"),i=7,s=Er,u(p))}function u(p){if(p===59&&o){let m=e.exit("characterReferenceValue");return s===Te&&!rr(n.sliceSerialize(m))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(p)&&o++<i?(e.consume(p),u):r(p)}}var Ss={tokenize:Jp,partial:!0},mo={name:"codeFenced",tokenize:Kp,concrete:!0};function Kp(e,t,r){let n=this,o={tokenize:b,partial:!0},i=0,s=0,a;return l;function l(h){return c(h)}function c(h){let N=n.eventsn.events.length-1;return i=N&&N1.type==="linePrefix"?N2.sliceSerialize(N1,!0).length:0,a=h,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(h)}function u(h){return h===a?(s++,e.consume(h),u):s<3?r(h):(e.exit("codeFencedFenceSequence"),z(h)?V(e,p,"whitespace")(h):p(h))}function p(h){return h===null||U(h)?(e.exit("codeFencedFence"),n.interrupt?t(h):e.check(Ss,S,w)(h)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(h))}function m(h){return h===null||U(h)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(h)):z(h)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),V(e,f,"whitespace")(h)):h===96&&h===a?r(h):(e.consume(h),m)}function f(h){return h===null||U(h)?p(h):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(h))}function E(h){return h===null||U(h)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(h)):h===96&&h===a?r(h):(e.consume(h),E)}function S(h){return e.attempt(o,w,C)(h)}function C(h){return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),_}function _(h){return i>0&&z(h)?V(e,W,"linePrefix",i+1)(h):W(h)}function W(h){return h===null||U(h)?e.check(Ss,S,w)(h):(e.enter("codeFlowValue"),R(h))}function R(h){return h===null||U(h)?(e.exit("codeFlowValue"),W(h)):(e.consume(h),R)}function w(h){return e.exit("codeFenced"),t(h)}function b(h,N,P){let M=0;return x;function x(F){return h.enter("lineEnding"),h.consume(F),h.exit("lineEnding"),T}function T(F){return h.enter("codeFencedFence"),z(F)?V(h,O,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):O(F)}function O(F){return F===a?(h.enter("codeFencedFenceSequence"),A(F)):P(F)}function A(F){return F===a?(M++,h.consume(F),A):M>=s?(h.exit("codeFencedFenceSequence"),z(F)?V(h,L,"whitespace")(F):L(F)):P(F)}function L(F){return F===null||U(F)?(h.exit("codeFencedFence"),N(F)):P(F)}}}function Jp(e,t,r){let n=this;return o;function o(s){return s===null?r(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i)}function i(s){return n.parser.lazyn.now().line?r(s):t(s)}}var an={name:"codeIndented",tokenize:Qp},Yp={tokenize:Xp,partial:!0};function Qp(e,t,r){let n=this;return o;function o(c){return e.enter("codeIndented"),V(e,i,"linePrefix",5)(c)}function i(c){let u=n.eventsn.events.length-1;return u&&u1.type==="linePrefix"&&u2.sliceSerialize(u1,!0).length>=4?s(c):r(c)}function s(c){return c===null?l(c):U(c)?e.attempt(Yp,s,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||U(c)?(e.exit("codeFlowValue"),s(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function Xp(e,t,r){let n=this;return o;function o(s){return n.parser.lazyn.now().line?r(s):U(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),o):V(e,i,"linePrefix",5)(s)}function i(s){let a=n.eventsn.events.length-1;return a&&a1.type==="linePrefix"&&a2.sliceSerialize(a1,!0).length>=4?t(s):U(s)?o(s):r(s)}}var Ps={name:"codeText",tokenize:tf,resolve:Zp,previous:ef};function Zp(e){let t=e.length-4,r=3,n,o;if((er1.type==="lineEnding"||er1.type==="space")&&(et1.type==="lineEnding"||et1.type==="space")){for(n=r;++n<t;)if(en1.type==="codeTextData"){er1.type="codeTextPadding",et1.type="codeTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)o===void 0?n!==t&&en1.type!=="lineEnding"&&(o=n):(n===t||en1.type==="lineEnding")&&(eo1.type="codeTextData",n!==o+2&&(eo1.end=en-11.end,e.splice(o+2,n-o-2),t-=n-o-2,n=o+2),o=void 0);return e}function ef(e){return e!==96||this.eventsthis.events.length-11.type==="characterEscape"}function tf(e,t,r){let n=this,o=0,i,s;return a;function a(m){return e.enter("codeText"),e.enter("codeTextSequence"),l(m)}function l(m){return m===96?(e.consume(m),o++,l):(e.exit("codeTextSequence"),c(m))}function c(m){return m===null?r(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),c):m===96?(s=e.enter("codeTextSequence"),i=0,p(m)):U(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(m))}function u(m){return m===null||m===32||m===96||U(m)?(e.exit("codeTextData"),c(m)):(e.consume(m),u)}function p(m){return m===96?(e.consume(m),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(s.type="codeTextData",u(m))}}var Ls={tokenize:of,resolve:nf},rf={tokenize:sf,partial:!0};function nf(e){return on(e),e}function of(e,t){let r;return n;function n(a){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),o(a)}function o(a){return a===null?i(a):U(a)?e.check(rf,s,i)(a):(e.consume(a),o)}function i(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function s(a){return e.consume(a),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,o}}function sf(e,t,r){let n=this;return o;function o(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),V(e,i,"linePrefix")}function i(s){if(s===null||U(s))return r(s);let a=n.eventsn.events.length-1;return!n.parser.constructs.disable.null.includes("codeIndented")&&a&&a1.type==="linePrefix"&&a2.sliceSerialize(a1,!0).length>=4?t(s):e.interrupt(n.parser.constructs.flow,r,t)(s)}}var vs={name:"definition",tokenize:lf},af={tokenize:cf,partial:!0};function lf(e,t,r){let n=this,o;return i;function i(f){return e.enter("definition"),s(f)}function s(f){return rn.call(n,e,a,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(f){return o=Me(n.sliceSerialize(n.eventsn.events.length-11).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),l):r(f)}function l(f){return Q(f)?It(e,c)(f):c(f)}function c(f){return tn(e,u,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return e.attempt(af,p,p)(f)}function p(f){return z(f)?V(e,m,"whitespace")(f):m(f)}function m(f){return f===null||U(f)?(e.exit("definition"),n.parser.defined.push(o),t(f)):r(f)}}function cf(e,t,r){return n;function n(a){return Q(a)?It(e,o)(a):r(a)}function o(a){return nn(e,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function i(a){return z(a)?V(e,s,"whitespace")(a):s(a)}function s(a){return a===null||U(a)?t(a):r(a)}}var Fs={name:"hardBreakEscape",tokenize:uf};function uf(e,t,r){return n;function n(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return U(i)?(e.exit("hardBreakEscape"),t(i)):r(i)}}var Ms={name:"headingAtx",tokenize:ff,resolve:pf};function pf(e,t){let r=e.length-2,n=3,o,i;return en1.type==="whitespace"&&(n+=2),r-2>n&&er1.type==="whitespace"&&(r-=2),er1.type==="atxHeadingSequence"&&(n===r-1||r-4>n&&er-21.type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(o={type:"atxHeadingText",start:en1.start,end:er1.end},i={type:"chunkText",start:en1.start,end:er1.end,contentType:"text"},be(e,n,r-n+1,"enter",o,t],"enter",i,t,"exit",i,t,["exit",o,t)),e}function ff(e,t,r){let n=0;return o;function o(u){return e.enter("atxHeading"),i(u)}function i(u){return e.enter("atxHeadingSequence"),s(u)}function s(u){return u===35&&n++<6?(e.consume(u),s):u===null||Q(u)?(e.exit("atxHeadingSequence"),a(u)):r(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||U(u)?(e.exit("atxHeading"),t(u)):z(u)?V(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||Q(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}var Us={name:"htmlFlow",tokenize:hf,resolveTo:gf,concrete:!0},mf={tokenize:yf,partial:!0},df={tokenize:xf,partial:!0};function gf(e){let t=e.length;for(;t--&&!(et0==="enter"&&et1.type==="htmlFlow"););return t>1&&et-21.type==="linePrefix"&&(et1.start=et-21.start,et+11.start=et-21.start,e.splice(t-2,2)),e}function hf(e,t,r){let n=this,o,i,s,a,l;return c;function c(g){return u(g)}function u(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),p}function p(g){return g===33?(e.consume(g),m):g===47?(e.consume(g),i=!0,S):g===63?(e.consume(g),o=3,n.interrupt?t:d):Se(g)?(e.consume(g),s=String.fromCharCode(g),C):r(g)}function m(g){return g===45?(e.consume(g),o=2,f):g===91?(e.consume(g),o=5,a=0,E):Se(g)?(e.consume(g),o=4,n.interrupt?t:d):r(g)}function f(g){return g===45?(e.consume(g),n.interrupt?t:d):r(g)}function E(g){let le="CDATA[";return g===le.charCodeAt(a++)?(e.consume(g),a===le.length?n.interrupt?t:O:E):r(g)}function S(g){return Se(g)?(e.consume(g),s=String.fromCharCode(g),C):r(g)}function C(g){if(g===null||g===47||g===62||Q(g)){let le=g===47,ie=s.toLowerCase();return!le&&!i&&co.includes(ie)?(o=1,n.interrupt?t(g):O(g)):_s.includes(s.toLowerCase())?(o=6,le?(e.consume(g),_):n.interrupt?t(g):O(g)):(o=7,n.interrupt&&!n.parser.lazyn.now().line?r(g):i?W(g):R(g))}return g===45||Te(g)?(e.consume(g),s+=String.fromCharCode(g),C):r(g)}function _(g){return g===62?(e.consume(g),n.interrupt?t:O):r(g)}function W(g){return z(g)?(e.consume(g),W):x(g)}function R(g){return g===47?(e.consume(g),x):g===58||g===95||Se(g)?(e.consume(g),w):z(g)?(e.consume(g),R):x(g)}function w(g){return g===45||g===46||g===58||g===95||Te(g)?(e.consume(g),w):b(g)}function b(g){return g===61?(e.consume(g),h):z(g)?(e.consume(g),b):R(g)}function h(g){return g===null||g===60||g===61||g===62||g===96?r(g):g===34||g===39?(e.consume(g),l=g,N):z(g)?(e.consume(g),h):P(g)}function N(g){return g===l?(e.consume(g),l=null,M):g===null||U(g)?r(g):(e.consume(g),N)}function P(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||Q(g)?b(g):(e.consume(g),P)}function M(g){return g===47||g===62||z(g)?R(g):r(g)}function x(g){return g===62?(e.consume(g),T):r(g)}function T(g){return g===null||U(g)?O(g):z(g)?(e.consume(g),T):r(g)}function O(g){return g===45&&o===2?(e.consume(g),D):g===60&&o===1?(e.consume(g),$):g===62&&o===4?(e.consume(g),q):g===63&&o===3?(e.consume(g),d):g===93&&o===5?(e.consume(g),B):U(g)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(mf,J,A)(g)):g===null||U(g)?(e.exit("htmlFlowData"),A(g)):(e.consume(g),O)}function A(g){return e.check(df,L,J)(g)}function L(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),F}function F(g){return g===null||U(g)?A(g):(e.enter("htmlFlowData"),O(g))}function D(g){return g===45?(e.consume(g),d):O(g)}function $(g){return g===47?(e.consume(g),s="",G):O(g)}function G(g){if(g===62){let le=s.toLowerCase();return co.includes(le)?(e.consume(g),q):O(g)}return Se(g)&&s.length<8?(e.consume(g),s+=String.fromCharCode(g),G):O(g)}function B(g){return g===93?(e.consume(g),d):O(g)}function d(g){return g===62?(e.consume(g),q):g===45&&o===2?(e.consume(g),d):O(g)}function q(g){return g===null||U(g)?(e.exit("htmlFlowData"),J(g)):(e.consume(g),q)}function J(g){return e.exit("htmlFlow"),t(g)}}function xf(e,t,r){let n=this;return o;function o(s){return U(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):r(s)}function i(s){return n.parser.lazyn.now().line?r(s):t(s)}}function yf(e,t,r){return n;function n(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Dt,t,r)}}var Is={name:"htmlText",tokenize:Ef};function Ef(e,t,r){let n=this,o,i,s;return a;function a(d){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(d),l}function l(d){return d===33?(e.consume(d),c):d===47?(e.consume(d),b):d===63?(e.consume(d),R):Se(d)?(e.consume(d),P):r(d)}function c(d){return d===45?(e.consume(d),u):d===91?(e.consume(d),i=0,E):Se(d)?(e.consume(d),W):r(d)}function u(d){return d===45?(e.consume(d),f):r(d)}function p(d){return d===null?r(d):d===45?(e.consume(d),m):U(d)?(s=p,$(d)):(e.consume(d),p)}function m(d){return d===45?(e.consume(d),f):p(d)}function f(d){return d===62?D(d):d===45?m(d):p(d)}function E(d){let q="CDATA[";return d===q.charCodeAt(i++)?(e.consume(d),i===q.length?S:E):r(d)}function S(d){return d===null?r(d):d===93?(e.consume(d),C):U(d)?(s=S,$(d)):(e.consume(d),S)}function C(d){return d===93?(e.consume(d),_):S(d)}function _(d){return d===62?D(d):d===93?(e.consume(d),_):S(d)}function W(d){return d===null||d===62?D(d):U(d)?(s=W,$(d)):(e.consume(d),W)}function R(d){return d===null?r(d):d===63?(e.consume(d),w):U(d)?(s=R,$(d)):(e.consume(d),R)}function w(d){return d===62?D(d):R(d)}function b(d){return Se(d)?(e.consume(d),h):r(d)}function h(d){return d===45||Te(d)?(e.consume(d),h):N(d)}function N(d){return U(d)?(s=N,$(d)):z(d)?(e.consume(d),N):D(d)}function P(d){return d===45||Te(d)?(e.consume(d),P):d===47||d===62||Q(d)?M(d):r(d)}function M(d){return d===47?(e.consume(d),D):d===58||d===95||Se(d)?(e.consume(d),x):U(d)?(s=M,$(d)):z(d)?(e.consume(d),M):D(d)}function x(d){return d===45||d===46||d===58||d===95||Te(d)?(e.consume(d),x):T(d)}function T(d){return d===61?(e.consume(d),O):U(d)?(s=T,$(d)):z(d)?(e.consume(d),T):M(d)}function O(d){return d===null||d===60||d===61||d===62||d===96?r(d):d===34||d===39?(e.consume(d),o=d,A):U(d)?(s=O,$(d)):z(d)?(e.consume(d),O):(e.consume(d),L)}function A(d){return d===o?(e.consume(d),o=void 0,F):d===null?r(d):U(d)?(s=A,$(d)):(e.consume(d),A)}function L(d){return d===null||d===34||d===39||d===60||d===61||d===96?r(d):d===47||d===62||Q(d)?M(d):(e.consume(d),L)}function F(d){return d===47||d===62||Q(d)?M(d):r(d)}function D(d){return d===62?(e.consume(d),e.exit("htmlTextData"),e.exit("htmlText"),t):r(d)}function $(d){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),G}function G(d){return z(d)?V(e,B,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):B(d)}function B(d){return e.enter("htmlTextData"),s(d)}}var ln={name:"labelEnd",tokenize:Of,resolveTo:Tf,resolveAll:kf},Rf={tokenize:Af},bf={tokenize:_f},wf={tokenize:Nf};function kf(e){let t=-1;for(;++t<e.length;){let r=et1;(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(e.splice(t+1,r.type==="labelImage"?4:2),r.type="data",t++)}return e}function Tf(e,t){let r=e.length,n=0,o,i,s,a;for(;r--;)if(o=er1,i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;er0==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(s){if(er0==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=r,o.type!=="labelLink")){n=2;break}}else o.type==="labelEnd"&&(s=r);let l={type:ei1.type==="labelLink"?"link":"image",start:Object.assign({},ei1.start),end:Object.assign({},ee.length-11.end)},c={type:"label",start:Object.assign({},ei1.start),end:Object.assign({},es1.end)},u={type:"labelText",start:Object.assign({},ei+n+21.end),end:Object.assign({},es-21.start)};return a="enter",l,t],["enter",c,t,a=We(a,e.slice(i+1,i+n+3)),a=We(a,"enter",u,t),a=We(a,kt(t.parser.constructs.insideSpan.null,e.slice(i+n+4,s-3),t)),a=We(a,"exit",u,t],es-2,es-1,["exit",c,t),a=We(a,e.slice(s+1)),a=We(a,"exit",l,t),be(e,i,e.length,a),e}function Of(e,t,r){let n=this,o=n.events.length,i,s;for(;o--;)if((n.eventso1.type==="labelImage"||n.eventso1.type==="labelLink")&&!n.eventso1._balanced){i=n.eventso1;break}return a;function a(m){return i?i._inactive?p(m):(s=n.parser.defined.includes(Me(n.sliceSerialize({start:i.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),l):r(m)}function l(m){return m===40?e.attempt(Rf,u,s?u:p)(m):m===91?e.attempt(bf,u,s?c:p)(m):s?u(m):p(m)}function c(m){return e.attempt(wf,u,p)(m)}function u(m){return t(m)}function p(m){return i._balanced=!0,r(m)}}function Af(e,t,r){return n;function n(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),o}function o(p){return Q(p)?It(e,i)(p):i(p)}function i(p){return p===41?u(p):tn(e,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function s(p){return Q(p)?It(e,l)(p):u(p)}function a(p){return r(p)}function l(p){return p===34||p===39||p===40?nn(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):u(p)}function c(p){return Q(p)?It(e,u)(p):u(p)}function u(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):r(p)}}function _f(e,t,r){let n=this;return o;function o(a){return rn.call(n,e,i,s,"reference","referenceMarker","referenceString")(a)}function i(a){return n.parser.defined.includes(Me(n.sliceSerialize(n.eventsn.events.length-11).slice(1,-1)))?t(a):r(a)}function s(a){return r(a)}}function Nf(e,t,r){return n;function n(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):r(i)}}var Ds={name:"labelStartImage",tokenize:Sf,resolveAll:ln.resolveAll};function Sf(e,t,r){let n=this;return o;function o(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),i}function i(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),s):r(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):t(a)}}var $s={name:"labelStartLink",tokenize:Cf,resolveAll:ln.resolveAll};function Cf(e,t,r){let n=this;return o;function o(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),i}function i(s){return s===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(s):t(s)}}var cn={name:"lineEnding",tokenize:Pf};function Pf(e,t){return r;function r(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),V(e,t,"linePrefix")}}var Rr={name:"thematicBreak",tokenize:Lf};function Lf(e,t,r){let n=0,o;return i;function i(c){return e.enter("thematicBreak"),s(c)}function s(c){return o=c,a(c)}function a(c){return c===o?(e.enter("thematicBreakSequence"),l(c)):n>=3&&(c===null||U(c))?(e.exit("thematicBreak"),t(c)):r(c)}function l(c){return c===o?(e.consume(c),n++,l):(e.exit("thematicBreakSequence"),z(c)?V(e,a,"whitespace")(c):a(c))}}var Ve={name:"list",tokenize:Mf,continuation:{tokenize:Uf},exit:Df},vf={tokenize:$f,partial:!0},Ff={tokenize:If,partial:!0};function Mf(e,t,r){let n=this,o=n.eventsn.events.length-1,i=o&&o1.type==="linePrefix"?o2.sliceSerialize(o1,!0).length:0,s=0;return a;function a(f){let E=n.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(E==="listUnordered"?!n.containerState.marker||f===n.containerState.marker:Er(f)){if(n.containerState.type||(n.containerState.type=E,e.enter(E,{_container:!0})),E==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(Rr,r,c)(f):c(f);if(!n.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(f)}return r(f)}function l(f){return Er(f)&&++s<10?(e.consume(f),l):(!n.interrupt||s<2)&&(n.containerState.marker?f===n.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),c(f)):r(f)}function c(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||f,e.check(Dt,n.interrupt?r:u,e.attempt(vf,m,p))}function u(f){return n.containerState.initialBlankLine=!0,i++,m(f)}function p(f){return z(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),m):r(f)}function m(f){return n.containerState.size=i+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function Uf(e,t,r){let n=this;return n.containerState._closeFlow=void 0,e.check(Dt,o,i);function o(a){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,V(e,t,"listItemIndent",n.containerState.size+1)(a)}function i(a){return n.containerState.furtherBlankLines||!z(a)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,s(a)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(Ff,t,s)(a))}function s(a){return n.containerState._closeFlow=!0,n.interrupt=void 0,V(e,e.attempt(Ve,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function If(e,t,r){let n=this;return V(e,o,"listItemIndent",n.containerState.size+1);function o(i){let s=n.eventsn.events.length-1;return s&&s1.type==="listItemIndent"&&s2.sliceSerialize(s1,!0).length===n.containerState.size?t(i):r(i)}}function Df(e){e.exit(this.containerState.type)}function $f(e,t,r){let n=this;return V(e,o,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let s=n.eventsn.events.length-1;return!z(i)&&s&&s1.type==="listItemPrefixWhitespace"?t(i):r(i)}}var go={name:"setextUnderline",tokenize:Bf,resolveTo:jf};function jf(e,t){let r=e.length,n,o,i;for(;r--;)if(er0==="enter"){if(er1.type==="content"){n=r;break}er1.type==="paragraph"&&(o=r)}else er1.type==="content"&&e.splice(r,1),!i&&er1.type==="definition"&&(i=r);let s={type:"setextHeading",start:Object.assign({},eo1.start),end:Object.assign({},ee.length-11.end)};return eo1.type="setextHeadingText",i?(e.splice(o,0,"enter",s,t),e.splice(i+1,0,["exit",en1,t]),en1.end=Object.assign({},ei1.end)):en1=s,e.push("exit",s,t),e}function Bf(e,t,r){let n=this,o;return i;function i(c){let u=n.events.length,p;for(;u--;)if(n.eventsu1.type!=="lineEnding"&&n.eventsu1.type!=="linePrefix"&&n.eventsu1.type!=="content"){p=n.eventsu1.type==="paragraph";break}return!n.parser.lazyn.now().line&&(n.interrupt||p)?(e.enter("setextHeadingLine"),o=c,s(c)):r(c)}function s(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===o?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),z(c)?V(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||U(c)?(e.exit("setextHeadingLine"),t(c)):r(c)}}var js={}.hasOwnProperty;function un(e){let t={},r=-1;for(;++r<e.length;)Hf(t,er);return t}function Hf(e,t){let r;for(r in t){let n=(js.call(e,r)?er:void 0)||(er={}),o=tr,i;if(o)for(i in o){js.call(n,i)||(ni=[]);let s=oi;Wf(ni,Array.isArray(s)?s:s?s:[])}}}function Wf(e,t){let r=-1,n=[];for(;++r<t.length;)(tr.add==="after"?e:n).push(tr);be(e,0,0,n)}var Vf=Object.defineProperty,Gf=(e,t)=>{for(var r in t)Vf(e,r,{get:tr,enumerable:!0})},zf={tokenize:qf};function qf(e){let t=e.attempt(this.parser.constructs.contentInitial,n,o),r;return t;function n(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),V(e,t,"linePrefix")}function o(a){return e.enter("paragraph"),i(a)}function i(a){let l=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,s(a)}function s(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return U(a)?(e.consume(a),e.exit("chunkText"),i):(e.consume(a),s)}}var Kf={tokenize:Jf},Bs={tokenize:Yf};function Jf(e){let t=this,r=[],n=0,o,i,s;return a;function a(R){if(n<r.length){let w=rn;return t.containerState=w1,e.attempt(w0.continuation,l,c)(R)}return c(R)}function l(R){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&W();let w=t.events.length,b=w,h;for(;b--;)if(t.eventsb0==="exit"&&t.eventsb1.type==="chunkFlow"){h=t.eventsb1.end;break}_(n);let N=w;for(;N<t.events.length;)t.eventsN1.end=Object.assign({},h),N++;return be(t.events,b+1,0,t.events.slice(w)),t.events.length=N,c(R)}return a(R)}function c(R){if(n===r.length){if(!o)return m(R);if(o.currentConstruct&&o.currentConstruct.concrete)return E(R);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Bs,u,p)(R)}function u(R){return o&&W(),_(n),m(R)}function p(R){return t.parser.lazyt.now().line=n!==r.length,s=t.now().offset,E(R)}function m(R){return t.containerState={},e.attempt(Bs,f,E)(R)}function f(R){return n++,r.push(t.currentConstruct,t.containerState),m(R)}function E(R){if(R===null){o&&W(),_(0),e.consume(R);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{contentType:"flow",previous:i,_tokenizer:o}),S(R)}function S(R){if(R===null){C(e.exit("chunkFlow"),!0),_(0),e.consume(R);return}return U(R)?(e.consume(R),C(e.exit("chunkFlow")),n=0,t.interrupt=void 0,a):(e.consume(R),S)}function C(R,w){let b=t.sliceStream(R);if(w&&b.push(null),R.previous=i,i&&(i.next=R),i=R,o.defineSkip(R.start),o.write(b),t.parser.lazyR.start.line){let h=o.events.length;for(;h--;)if(o.eventsh1.start.offset<s&&(!o.eventsh1.end||o.eventsh1.end.offset>s))return;let N=t.events.length,P=N,M,x;for(;P--;)if(t.eventsP0==="exit"&&t.eventsP1.type==="chunkFlow"){if(M){x=t.eventsP1.end;break}M=!0}for(_(n),h=N;h<t.events.length;)t.eventsh1.end=Object.assign({},x),h++;be(t.events,P+1,0,t.events.slice(N)),t.events.length=h}}function _(R){let w=r.length;for(;w-- >R;){let b=rw;t.containerState=b1,b0.exit.call(t,e)}r.length=R}function W(){o.write(null),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function Yf(e,t,r){return V(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var Qf={tokenize:Xf};function Xf(e){let t=this,r=e.attempt(Dt,n,e.attempt(this.parser.constructs.flowInitial,o,V(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Ls,o)),"linePrefix")));return r;function n(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var Zf={resolveAll:Ws()},em=Hs("string"),tm=Hs("text");function Hs(e){return{tokenize:t,resolveAll:Ws(e==="text"?rm:void 0)};function t(r){let n=this,o=this.parser.constructse,i=r.attempt(o,s,a);return s;function s(u){return c(u)?i(u):a(u)}function a(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),l}function l(u){return c(u)?(r.exit("data"),i(u)):(r.consume(u),l)}function c(u){if(u===null)return!0;let p=ou,m=-1;if(p)for(;++m<p.length;){let f=pm;if(!f.previous||f.previous.call(n,n.previous))return!0}return!1}}}function Ws(e){return t;function t(r,n){let o=-1,i;for(;++o<=r.length;)i===void 0?ro&&ro1.type==="data"&&(i=o,o++):(!ro||ro1.type!=="data")&&(o!==i+2&&(ri1.end=ro-11.end,r.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(r,n):r}}function rm(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||er1.type==="lineEnding")&&er-11.type==="data"){let n=er-11,o=t.sliceStream(n),i=o.length,s=-1,a=0,l;for(;i--;){let c=oi;if(typeof c=="string"){for(s=c.length;c.charCodeAt(s-1)===32;)a++,s--;if(s)break;s=-1}else if(c===-2)l=!0,a++;else if(c!==-1){i++;break}}if(a){let c={type:r===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{line:n.end.line,column:n.end.column-a,offset:n.end.offset-a,_index:n.start._index+i,_bufferIndex:i?s:n.start._bufferIndex+s},end:Object.assign({},n.end)};n.end=Object.assign({},c.start),n.start.offset===n.end.offset?Object.assign(n,c):(e.splice(r,0,"enter",c,t,"exit",c,t),r+=2)}r++}return e}function nm(e,t,r){let n=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),o={},i=[],s=[],a=[],l=!0,c={consume:w,enter:b,exit:h,attempt:M(N),check:M(P),interrupt:M(P,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:S,sliceSerialize:E,now:C,defineSkip:_,write:f},p=t.tokenize.call(u,c),m;return t.resolveAll&&i.push(t),u;function f(A){return s=We(s,A),W(),ss.length-1!==null?[]:(x(t,0),u.events=kt(i,u.events,u),u.events)}function E(A,L){return im(S(A),L)}function S(A){return om(s,A)}function C(){let{line:A,column:L,offset:F,_index:D,_bufferIndex:$}=n;return{line:A,column:L,offset:F,_index:D,_bufferIndex:$}}function _(A){oA.line=A.column,O()}function W(){let A;for(;n._index<s.length;){let L=sn._index;if(typeof L=="string")for(A=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===A&&n._bufferIndex<L.length;)R(L.charCodeAt(n._bufferIndex));else R(L)}}function R(A){l=void 0,m=A,p=p(A)}function w(A){U(A)?(n.line++,n.column=1,n.offset+=A===-3?2:1,O()):A!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===sn._index.length&&(n._bufferIndex=-1,n._index++)),u.previous=A,l=!0}function b(A,L){let F=L||{};return F.type=A,F.start=C(),u.events.push("enter",F,u),a.push(F),F}function h(A){let L=a.pop();return L.end=C(),u.events.push("exit",L,u),L}function N(A,L){x(A,L.from)}function P(A,L){L.restore()}function M(A,L){return F;function F(D,$,G){let B,d,q,J;return Array.isArray(D)?le(D):"tokenize"in D?le(D):g(D);function g(oe){return Be;function Be(_e){let Pe=_e!==null&&oe_e,et=_e!==null&&oe.null,gr=[...Array.isArray(Pe)?Pe:Pe?Pe:[],...Array.isArray(et)?et:et?et:[]];return le(gr)(_e)}}function le(oe){return B=oe,d=0,oe.length===0?G:ie(oed)}function ie(oe){return Be;function Be(_e){return J=T(),q=oe,oe.partial||(u.currentConstruct=oe),oe.name&&u.parser.constructs.disable.null.includes(oe.name)?ne(_e):oe.tokenize.call(L?Object.assign(Object.create(u),L):u,c,I,ne)(_e)}}function I(oe){return l=!0,A(q,J),$}function ne(oe){return l=!0,J.restore(),++d<B.length?ie(Bd):G}}}function x(A,L){A.resolveAll&&!i.includes(A)&&i.push(A),A.resolve&&be(u.events,L,u.events.length-L,A.resolve(u.events.slice(L),u)),A.resolveTo&&(u.events=A.resolveTo(u.events,u))}function T(){let A=C(),L=u.previous,F=u.currentConstruct,D=u.events.length,$=Array.from(a);return{restore:G,from:D};function G(){n=A,u.previous=L,u.currentConstruct=F,u.events.length=D,a=$,O()}}function O(){n.line in o&&n.column<2&&(n.column=on.line,n.offset+=on.line-1)}}function om(e,t){let r=t.start._index,n=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,s;if(r===o)s=[er.slice(n,i)];else{if(s=e.slice(r,o),n>-1){let a=s0;typeof a=="string"?s0=a.slice(n):s.shift()}i>0&&s.push(eo.slice(0,i))}return s}function im(e,t){let r=-1,n=[],o;for(;++r<e.length;){let i=er,s;if(typeof i=="string")s=i;else switch(i){case-5:{s="\r";break}case-4:{s=` ;break}case-3:{s=\r
;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&o)continue;s=" ";break}default:s=String.fromCharCode(i)}o=i===-2,n.push(s)}return n.join("")}var Vs={};Gf(Vs,{attentionMarkers:()=>mm,contentInitial:()=>am,disable:()=>dm,document:()=>sm,flow:()=>cm,flowInitial:()=>lm,insideSpan:()=>fm,string:()=>um,text:()=>pm});var sm={42:Ve,43:Ve,45:Ve,48:Ve,49:Ve,50:Ve,51:Ve,52:Ve,53:Ve,54:Ve,55:Ve,56:Ve,57:Ve,62:uo},am={91:vs},lm={[-2]:an,[-1]:an,32:an},cm={35:Ms,42:Rr,45:[go,Rr],60:Us,61:go,95:Rr,96:mo,126:mo},um={38:fo,92:po},pm={[-5]:cn,[-4]:cn,[-3]:cn,33:Ds,38:fo,42:sn,60:[Cs,Is],91:$s,92:[Fs,po],93:ln,95:sn,96:Ps},fm={null:[sn,Zf]},mm={null:[42,95]},dm={null:[]};function Gs(e){let t=un([Vs,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:n(zf),document:n(Kf),flow:n(Qf),string:n(em),text:n(tm)};return r;function n(o){return i;function i(s){return nm(r,o,s)}}}function zs(e){for(;!on(e););return e}var qs=/[\0\t\n\r]/g;function Ks(){let e=1,t="",r=!0,n;return o;function o(i,s,a){let l=[],c,u,p,m,f;for(i=t+i.toString(s),p=0,t="",r&&(i.charCodeAt(0)===65279&&p++,r=void 0);p<i.length;){if(qs.lastIndex=p,c=qs.exec(i),m=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(m),!c){t=i.slice(p);break}if(f===10&&p===m&&n)l.push(-3),n=void 0;else switch(n&&(l.push(-5),n=void 0),p<m&&(l.push(i.slice(p,m)),e+=m-p),f){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:n=!0,e=1}p=m+1}return a&&(n&&l.push(-5),t&&l.push(t),l.push(null)),l}}function br(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Js(e.position):"start"in e||"end"in e?Js(e):"line"in e||"column"in e?ho(e):""}function ho(e){return Ys(e&&e.line)+":"+Ys(e&&e.column)}function Js(e){return ho(e&&e.start)+"-"+ho(e&&e.end)}function Ys(e){return e&&typeof e=="number"?e:1}var Xs={}.hasOwnProperty,Zs=function(e,t,r){return typeof t!="string"&&(r=t,t=void 0),gm(r)(zs(Gs(r).document().write(Ks()(e,t,!0))))};function gm(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ui),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ai),blockQuote:a(Pe),characterEscape:T,characterReference:T,codeFenced:a(et),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:a(et,l),codeText:a(gr,l),codeTextData:T,data:T,codeFlowValue:T,definition:a(zn),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:a(qn),hardBreakEscape:a(li),hardBreakTrailing:a(li),htmlFlow:a(ci,l),htmlFlowData:T,htmlText:a(ci,l),htmlTextData:T,image:a(bu),label:l,link:a(ui),listItem:a(wu),listItemValue:E,listOrdered:a(pi,f),listUnordered:a(pi),paragraph:a(ku),reference:ie,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:a(ai),strong:a(Tu),thematicBreak:a(Au)},exit:{atxHeading:u(),atxHeadingSequence:N,autolink:u(),autolinkEmail:_e,autolinkProtocol:Be,blockQuote:u(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:oe,codeFenced:u(W),codeFencedFence:_,codeFencedFenceInfo:S,codeFencedFenceMeta:C,codeFlowValue:O,codeIndented:u(R),codeText:u($),codeTextData:O,data:O,definition:u(),definitionDestinationString:h,definitionLabelString:w,definitionTitleString:b,emphasis:u(),hardBreakEscape:u(L),hardBreakTrailing:u(L),htmlFlow:u(F),htmlFlowData:O,htmlText:u(D),htmlTextData:O,image:u(B),label:q,labelText:d,lineEnding:A,link:u(G),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:I,resourceDestinationString:J,resourceTitleString:g,resource:le,setextHeading:u(x),setextHeadingLineSequence:M,setextHeadingText:P,strong:u(),thematicBreak:u()}};ea(t,(e||{}).mdastExtensions||[]);let r={};return n;function n(k){let v={type:"root",children:[]},K={stack:[v],tokenStack:[],config:t,enter:c,exit:p,buffer:l,resume:m,setData:i,getData:s},se=[],ce=-1;for(;++ce<k.length;)if(k[ce][1].type==="listOrdered"||k[ce][1].type==="listUnordered")if(k[ce][0]==="enter")se.push(ce);else{let tt=se.pop();ce=o(k,tt,ce)}for(ce=-1;++ce<k.length;){let tt=t[k[ce][0]];Xs.call(tt,k[ce][1].type)&&tt[k[ce][1].type].call(Object.assign({sliceSerialize:k[ce][2].sliceSerialize},K),k[ce][1])}if(K.tokenStack.length>0){let tt=K.tokenStack[K.tokenStack.length-1];(tt[1]||Qs).call(K,void 0,tt[0])}for(v.position={start:Tt(k.length>0?k[0][1].start:{line:1,column:1,offset:0}),end:Tt(k.length>0?k[k.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce<t.transforms.length;)v=t.transforms[ce](v)||v;return v}function o(k,v,K){let se=v-1,ce=-1,tt=!1,vt,lt,hr,xr;for(;++se<=K;){let Ee=k[se];if(Ee[1].type==="listUnordered"||Ee[1].type==="listOrdered"||Ee[1].type==="blockQuote"?(Ee[0]==="enter"?ce++:ce--,xr=void 0):Ee[1].type==="lineEndingBlank"?Ee[0]==="enter"&&(vt&&!xr&&!ce&&!hr&&(hr=se),xr=void 0):Ee[1].type==="linePrefix"||Ee[1].type==="listItemValue"||Ee[1].type==="listItemMarker"||Ee[1].type==="listItemPrefix"||Ee[1].type==="listItemPrefixWhitespace"||(xr=void 0),!ce&&Ee[0]==="enter"&&Ee[1].type==="listItemPrefix"||ce===-1&&Ee[0]==="exit"&&(Ee[1].type==="listUnordered"||Ee[1].type==="listOrdered")){if(vt){let Kn=se;for(lt=void 0;Kn--;){let ct=k[Kn];if(ct[1].type==="lineEnding"||ct[1].type==="lineEndingBlank"){if(ct[0]==="exit")continue;lt&&(k[lt][1].type="lineEndingBlank",tt=!0),ct[1].type="lineEnding",lt=Kn}else if(!(ct[1].type==="linePrefix"||ct[1].type==="blockQuotePrefix"||ct[1].type==="blockQuotePrefixWhitespace"||ct[1].type==="blockQuoteMarker"||ct[1].type==="listItemIndent"))break}hr&&(!lt||hr<lt)&&(vt._spread=!0),vt.end=Object.assign({},lt?k[lt][1].start:Ee[1].end),k.splice(lt||se,0,["exit",vt,Ee[2]]),se++,K++}Ee[1].type==="listItemPrefix"&&(vt={type:"listItem",_spread:!1,start:Object.assign({},Ee[1].start),end:void 0},k.splice(se,0,["enter",vt,Ee[2]]),se++,K++,hr=void 0,xr=!0)}}return k[v][1]._spread=tt,K}function i(k,v){r[k]=v}function s(k){return r[k]}function a(k,v){return K;function K(se){c.call(this,k(se),se),v&&v.call(this,se)}}function l(){this.stack.push({type:"fragment",children:[]})}function c(k,v,K){return this.stack[this.stack.length-1].children.push(k),this.stack.push(k),this.tokenStack.push([v,K]),k.position={start:Tt(v.start)},k}function u(k){return v;function v(K){k&&k.call(this,K),p.call(this,K)}}function p(k,v){let K=this.stack.pop(),se=this.tokenStack.pop();if(se)se[0].type!==k.type&&(v?v.call(this,k,se[0]):(se[1]||Qs).call(this,k,se[0]));else throw new Error("Cannot close "+k.type+" ("+br({start:k.start,end:k.end})+"): it’s not open");return K.position.end=Tt(k.end),K}function m(){return ws(this.stack.pop())}function f(){i("expectingFirstListItemValue",!0)}function E(k){if(s("expectingFirstListItemValue")){let v=this.stack[this.stack.length-2];v.start=Number.parseInt(this.sliceSerialize(k),10),i("expectingFirstListItemValue")}}function S(){let k=this.resume(),v=this.stack[this.stack.length-1];v.lang=k}function C(){let k=this.resume(),v=this.stack[this.stack.length-1];v.meta=k}function _(){s("flowCodeInside")||(this.buffer(),i("flowCodeInside",!0))}function W(){let k=this.resume(),v=this.stack[this.stack.length-1];v.value=k.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),i("flowCodeInside")}function R(){let k=this.resume(),v=this.stack[this.stack.length-1];v.value=k.replace(/(\r?\n|\r)$/g,"")}function w(k){let v=this.resume(),K=this.stack[this.stack.length-1];K.label=v,K.identifier=Me(this.sliceSerialize(k)).toLowerCase()}function b(){let k=this.resume(),v=this.stack[this.stack.length-1];v.title=k}function h(){let k=this.resume(),v=this.stack[this.stack.length-1];v.url=k}function N(k){let v=this.stack[this.stack.length-1];if(!v.depth){let K=this.sliceSerialize(k).length;v.depth=K}}function P(){i("setextHeadingSlurpLineEnding",!0)}function M(k){let v=this.stack[this.stack.length-1];v.depth=this.sliceSerialize(k).charCodeAt(0)===61?1:2}function x(){i("setextHeadingSlurpLineEnding")}function T(k){let v=this.stack[this.stack.length-1],K=v.children[v.children.length-1];(!K||K.type!=="text")&&(K=Ou(),K.position={start:Tt(k.start)},v.children.push(K)),this.stack.push(K)}function O(k){let v=this.stack.pop();v.value+=this.sliceSerialize(k),v.position.end=Tt(k.end)}function A(k){let v=this.stack[this.stack.length-1];if(s("atHardBreak")){let K=v.children[v.children.length-1];K.position.end=Tt(k.end),i("atHardBreak");return}!s("setextHeadingSlurpLineEnding")&&t.canContainEols.includes(v.type)&&(T.call(this,k),O.call(this,k))}function L(){i("atHardBreak",!0)}function F(){let k=this.resume(),v=this.stack[this.stack.length-1];v.value=k}function D(){let k=this.resume(),v=this.stack[this.stack.length-1];v.value=k}function $(){let k=this.resume(),v=this.stack[this.stack.length-1];v.value=k}function G(){let k=this.stack[this.stack.length-1];if(s("inReference")){let v=s("referenceType")||"shortcut";k.type+="Reference",k.referenceType=v,delete k.url,delete k.title}else delete k.identifier,delete k.label;i("referenceType")}function B(){let k=this.stack[this.stack.length-1];if(s("inReference")){let v=s("referenceType")||"shortcut";k.type+="Reference",k.referenceType=v,delete k.url,delete k.title}else delete k.identifier,delete k.label;i("referenceType")}function d(k){let v=this.sliceSerialize(k),K=this.stack[this.stack.length-2];K.label=en(v),K.identifier=Me(v).toLowerCase()}function q(){let k=this.stack[this.stack.length-1],v=this.resume(),K=this.stack[this.stack.length-1];if(i("inReference",!0),K.type==="link"){let se=k.children;K.children=se}else K.alt=v}function J(){let k=this.resume(),v=this.stack[this.stack.length-1];v.url=k}function g(){let k=this.resume(),v=this.stack[this.stack.length-1];v.title=k}function le(){i("inReference")}function ie(){i("referenceType","collapsed")}function I(k){let v=this.resume(),K=this.stack[this.stack.length-1];K.label=v,K.identifier=Me(this.sliceSerialize(k)).toLowerCase(),i("referenceType","full")}function ne(k){i("characterReferenceType",k.type)}function oe(k){let v=this.sliceSerialize(k),K=s("characterReferenceType"),se;K?(se=Zr(v,K==="characterReferenceMarkerNumeric"?10:16),i("characterReferenceType")):se=rr(v);let ce=this.stack.pop();ce.value+=se,ce.position.end=Tt(k.end)}function Be(k){O.call(this,k);let v=this.stack[this.stack.length-1];v.url=this.sliceSerialize(k)}function _e(k){O.call(this,k);let v=this.stack[this.stack.length-1];v.url="mailto:"+this.sliceSerialize(k)}function Pe(){return{type:"blockquote",children:[]}}function et(){return{type:"code",lang:null,meta:null,value:""}}function gr(){return{type:"inlineCode",value:""}}function zn(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qn(){return{type:"emphasis",children:[]}}function ai(){return{type:"heading",depth:void 0,children:[]}}function li(){return{type:"break"}}function ci(){return{type:"html",value:""}}function bu(){return{type:"image",title:null,url:"",alt:null}}function ui(){return{type:"link",title:null,url:"",children:[]}}function pi(k){return{type:"list",ordered:k.type==="listOrdered",start:null,spread:k._spread,children:[]}}function wu(k){return{type:"listItem",spread:k._spread,checked:null,children:[]}}function ku(){return{type:"paragraph",children:[]}}function Tu(){return{type:"strong",children:[]}}function Ou(){return{type:"text",value:""}}function Au(){return{type:"thematicBreak"}}}function Tt(e){return{line:e.line,column:e.column,offset:e.offset}}function ea(e,t){let r=-1;for(;++r<t.length;){let n=t[r];Array.isArray(n)?ea(e,n):hm(e,n)}}function hm(e,t){let r;for(r in t)if(Xs.call(t,r)){if(r==="canContainEols"){let n=t[r];n&&e[r].push(...n)}else if(r==="transforms"){let n=t[r];n&&e[r].push(...n)}else if(r==="enter"||r==="exit"){let n=t[r];n&&Object.assign(e[r],n)}}}function Qs(e,t){throw e?new Error("Cannot close "+e.type+" ("+br({start:e.start,end:e.end})+"): a different token ("+t.type+", "+br({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token ("+t.type+", "+br({start:t.start,end:t.end})+") is still open")}function xo(e,t){let r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,o=r.indexOf(t);for(;o!==-1;)n++,o=r.indexOf(t,o+t.length);return n}function yo(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var wr=function(e){if(e==null)return Rm;if(typeof e=="string")return Em(e);if(typeof e=="object")return Array.isArray(e)?xm(e):ym(e);if(typeof e=="function")return pn(e);throw new Error("Expected function, string, or object as test")};function xm(e){let t=[],r=-1;for(;++r<e.length;)t[r]=wr(e[r]);return pn(n);function n(...o){let i=-1;for(;++i<t.length;)if(t[i].call(this,...o))return!0;return!1}}function ym(e){return pn(t);function t(r){let n;for(n in e)if(r[n]!==e[n])return!1;return!0}}function Em(e){return pn(t);function t(r){return r&&r.type===e}}function pn(e){return t;function t(r,...n){return!!(r&&typeof r=="object"&&"type"in r&&e.call(this,r,...n))}}function Rm(){return!0}var bm=!0,ta=!1,wm="skip",ra=function(e,t,r,n){typeof t=="function"&&typeof r!="function"&&(n=r,r=t,t=null);let o=wr(t),i=n?-1:1;s(e,void 0,[])();function s(a,l,c){let u=a&&typeof a=="object"?a:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(a.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=[],f,E,S;if((!t||o(a,l,c[c.length-1]||null))&&(m=km(r(a,c)),m[0]===ta))return m;if(a.children&&m[0]!==wm)for(E=(n?a.children.length:-1)+i,S=c.concat(a);E>-1&&E<a.children.length;){if(f=s(a.children[E],E,S)(),f[0]===ta)return f;E=typeof f[1]=="number"?f[1]:E+i}return m}}};function km(e){return Array.isArray(e)?e:typeof e=="number"?[bm,e]:[e]}var Tm={}.hasOwnProperty,ia=function(e,t,r,n){let o,i;typeof t=="string"||t instanceof RegExp?(i=[[t,r]],o=n):(i=t,o=r),o||(o={});let s=wr(o.ignore||[]),a=Om(i),l=-1;for(;++l<a.length;)ra(e,"text",c);return e;function c(p,m){let f=-1,E;for(;++f<m.length;){let S=m[f];if(s(S,E?E.children.indexOf(S):void 0,E))return;E=S}if(E)return u(p,m)}function u(p,m){let f=m[m.length-1],E=a[l][0],S=a[l][1],C=0,_=f.children.indexOf(p),W=!1,R=[];E.lastIndex=0;let w=E.exec(p.value);for(;w;){let b=w.index,h={index:w.index,input:w.input,stack:[...m,p]},N=S(...w,h);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N!==!1&&(C!==b&&R.push({type:"text",value:p.value.slice(C,b)}),Array.isArray(N)?R.push(...N):N&&R.push(N),C=b+w[0].length,W=!0),!E.global)break;w=E.exec(p.value)}return W?(C<p.value.length&&R.push({type:"text",value:p.value.slice(C)}),f.children.splice(_,1,...R)):R=[p],_+R.length}};function Om(e){let t=[];if(typeof e!="object")throw new TypeError("Expected array or object as schema");if(Array.isArray(e)){let r=-1;for(;++r<e.length;)t.push([na(e[r][0]),oa(e[r][1])])}else{let r;for(r in e)Tm.call(e,r)&&t.push([na(r),oa(e[r])])}return t}function na(e){return typeof e=="string"?new RegExp(yo(e),"g"):e}function oa(e){return typeof e=="function"?e:()=>e}var sa={transforms:[Pm],enter:{literalAutolink:Am,literalAutolinkEmail:Eo,literalAutolinkHttp:Eo,literalAutolinkWww:Eo},exit:{literalAutolink:Cm,literalAutolinkEmail:Sm,literalAutolinkHttp:_m,literalAutolinkWww:Nm}};function Am(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Eo(e){this.config.enter.autolinkProtocol.call(this,e)}function _m(e){this.config.exit.autolinkProtocol.call(this,e)}function Nm(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.url="http://"+this.sliceSerialize(e)}function Sm(e){this.config.exit.autolinkEmail.call(this,e)}function Cm(e){this.exit(e)}function Pm(e){ia(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Lm],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,vm]],{ignore:["link","linkReference"]})}function Lm(e,t,r,n,o){let i="";if(!aa(o)||(/^w/i.test(t)&&(r=t+r,t="",i="http://"),!Fm(r)))return!1;let s=Mm(r+n);if(!s[0])return!1;let a={type:"link",title:null,url:i+t+s[0],children:[{type:"text",value:t+s[0]}]};return s[1]?[a,{type:"text",value:s[1]}]:a}function vm(e,t,r,n){return!aa(n,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}function Fm(e){let t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Mm(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],n=r.indexOf(")"),o=xo(e,"("),i=xo(e,")");for(;n!==-1&&o>i;)e+=r.slice(0,n+1),r=r.slice(n+1),n=r.indexOf(")"),i++;return[e,r]}function aa(e,t){let r=e.input.charCodeAt(e.index-1);return(e.index===0||nt(r)||Ut(r))&&(!t||r!==47)}function la(e){return e.label||!e.identifier?e.label||"":en(e.identifier)}function Um(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function Im(e,t){return ca(e,t.inConstruct,!0)&&!ca(e,t.notInConstruct,!1)}function ca(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let n=-1;for(;++n<t.length;)if(e.includes(t[n]))return!0;return!1}function pa(e,t,r){let n=(r.before||"")+(t||"")+(r.after||""),o=[],i=[],s={},a=-1;for(;++a<e.unsafe.length;){let u=e.unsafe[a];if(!Im(e.stack,u))continue;let p=Um(u),m;for(;m=p.exec(n);){let f="before"in u||!!u.atBreak,E="after"in u,S=m.index+(f?m[1].length:0);o.includes(S)?(s[S].before&&!f&&(s[S].before=!1),s[S].after&&!E&&(s[S].after=!1)):(o.push(S),s[S]={before:f,after:E})}}o.sort(Dm);let l=r.before?r.before.length:0,c=n.length-(r.after?r.after.length:0);for(a=-1;++a<o.length;){let u=o[a];u<l||u>=c||u+1<c&&o[a+1]===u+1&&s[u].after&&!s[u+1].before&&!s[u+1].after||o[a-1]===u-1&&s[u].before&&!s[u-1].before&&!s[u-1].after||(l!==u&&i.push(ua(n.slice(l,u),"\\")),l=u,/[!-/:-@[-{-~]/.test(n.charAt(u))&&(!r.encode||!r.encode.includes(n.charAt(u)))?i.push("\\"):(i.push("&#x"+n.charCodeAt(u).toString(16).toUpperCase()+";"),l++))}return i.push(ua(n.slice(l,c),r.after)),i.join("")}function Dm(e,t){return e-t}function ua(e,t){let r=/\\(?=[!-/:-@[-{-~])/g,n=[],o=[],i=e+t,s=-1,a=0,l;for(;l=r.exec(i);)n.push(l.index);for(;++s<n.length;)a!==n[s]&&o.push(e.slice(a,n[s])),o.push("\\"),a=n[s];return o.push(e.slice(a)),o.join("")}function kr(e){let t=e||{},r=t.now||{},n=t.lineShift||0,o=r.line||1,i=r.column||1;return{move:l,current:s,shift:a};function s(){return{now:{line:o,column:i},lineShift:n}}function a(c){n+=c}function l(c){let u=c||"",p=u.split(/\r?\n|\r/g),m=p[p.length-1];return o+=p.length-1,i=p.length===1?i+m.length:1+m.length+n,u}}qm.peek=Km;function fa(){return{enter:{gfmFootnoteDefinition:$m,gfmFootnoteDefinitionLabelString:jm,gfmFootnoteCall:Wm,gfmFootnoteCallString:Vm},exit:{gfmFootnoteDefinition:Hm,gfmFootnoteDefinitionLabelString:Bm,gfmFootnoteCall:zm,gfmFootnoteCallString:Gm}}}function $m(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function jm(){this.buffer()}function Bm(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=Me(this.sliceSerialize(e)).toLowerCase()}function Hm(e){this.exit(e)}function Wm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Vm(){this.buffer()}function Gm(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=Me(this.sliceSerialize(e)).toLowerCase()}function zm(e){this.exit(e)}function qm(e,t,r,n){let o=kr(n),i=o.move("[^"),s=r.enter("footnoteReference"),a=r.enter("reference");return i+=o.move(pa(r,la(e),{...o.current(),before:i,after:"]"})),a(),s(),i+=o.move("]"),i}function Km(){return"["}function Ro(e,t,r){let n=t.indexStack,o=e.children||[],i=[],s=-1,a=r.before;n.push(-1);let l=t.createTracker(r);for(;++s<o.length;){let c=o[s],u;if(n[n.length-1]=s,s+1<o.length){let p=t.handle.handlers[o[s+1].type];p&&p.peek&&(p=p.peek),u=p?p(o[s+1],e,t,{before:"",after:"",...l.current()}).charAt(0):""}else u=r.after;i.length>0&&(a==="\r"||a===
)&&c.type==="html"&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),a=" ",l=t.createTracker(r),l.move(i.join(""))),i.push(l.move(t.handle(c,e,t,{...l.current(),before:a,after:u}))),a=i[i.length-1].slice(-1)}return n.pop(),i.join("")}Qm.peek=Xm;var ma={canContainEols:["delete"],enter:{strikethrough:Jm},exit:{strikethrough:Ym}};function Jm(e){this.enter({type:"delete",children:[]},e)}function Ym(e){this.exit(e)}function Qm(e,t,r,n){let o=kr(n),i=r.enter("strikethrough"),s=o.move("~~");return s+=Ro(e,r,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function Xm(){return"~"}function Zm(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}da.peek=ed;function da(e,t,r){let n=e.value||"",o="",i=-1;for(;new RegExp("(^|[^])"+o+"([^]|$)").test(n);)o+="";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^|$/.test(n))&&(n=" "+n+" ");++i<r.unsafe.length;){let s=r.unsafe[i],a=Zm(s),l;if(s.atBreak)for(;l=a.exec(n);){let c=l.index;n.charCodeAt(c)===10&&n.charCodeAt(c-1)===13&&c--,n=n.slice(0,c)+" "+n.slice(l.index+1)}}return o+n+o}function ed(){return""}var ha={enter:{table:td,tableData:ga,tableHeader:ga,tableRow:nd},exit:{codeText:od,table:rd,tableData:bo,tableHeader:bo,tableRow:bo}};function td(e){let t=e._align;this.enter({type:"table",align:t.map(r=>r==="none"?null:r),children:[]},e),this.setData("inTable",!0)}function rd(e){this.exit(e),this.setData("inTable")}function nd(e){this.enter({type:"tableRow",children:[]},e)}function bo(e){this.exit(e)}function ga(e){this.enter({type:"tableCell",children:[]},e)}function od(e){let t=this.resume();this.getData("inTable")&&(t=t.replace(/\\(\\|)/g,id));let r=this.stackthis.stack.length-1;r.value=t,this.exit(e)}function id(e,t){return t==="|"?t:e}var ya={exit:{taskListCheckValueChecked:xa,taskListCheckValueUnchecked:xa,paragraph:sd}};function xa(e){let t=this.stackthis.stack.length-2;t.checked=e.type==="taskListCheckValueChecked"}function sd(e){let t=this.stackthis.stack.length-2;if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){let r=this.stackthis.stack.length-1,n=r.children0;if(n&&n.type==="text"){let o=t.children,i=-1,s;for(;++i<o.length;){let a=oi;if(a.type==="paragraph"){s=a;break}}s===r&&(n.value=n.value.slice(1),n.value.length===0?r.children.shift():r.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,r.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Ea(){returnsa,fa(),ma,ha,ya}var ld={tokenize:md,partial:!0},Ra={tokenize:dd,partial:!0},ba={tokenize:gd,partial:!0},wa={tokenize:hd,partial:!0},cd={tokenize:xd,partial:!0},ka={tokenize:pd,previous:Aa},Ta={tokenize:fd,previous:_a},ht={tokenize:ud,previous:Na},ot={},Oa={text:ot},$t=48;for(;$t<123;)ot$t=ht,$t++,$t===58?$t=65:$t===91&&($t=97);ot43=ht;ot45=ht;ot46=ht;ot95=ht;ot72=ht,Ta;ot104=ht,Ta;ot87=ht,ka;ot119=ht,ka;function ud(e,t,r){let n=this,o,i;return s;function s(p){return!wo(p)||!Na.call(n,n.previous)||ko(n.events)?r(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(p))}function a(p){return wo(p)?(e.consume(p),a):p===64?(e.consume(p),l):r(p)}function l(p){return p===46?e.check(cd,u,c)(p):p===45||p===95||Te(p)?(i=!0,e.consume(p),l):u(p)}function c(p){return e.consume(p),o=!0,l}function u(p){return i&&o&&Se(n.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):r(p)}}function pd(e,t,r){let n=this;return o;function o(s){return s!==87&&s!==119||!Aa.call(n,n.previous)||ko(n.events)?r(s):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(ld,e.attempt(Ra,e.attempt(ba,i),r),r)(s))}function i(s){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(s)}}function fd(e,t,r){let n=this,o="",i=!1;return s;function s(p){return(p===72||p===104)&&_a.call(n,n.previous)&&!ko(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),e.consume(p),a):r(p)}function a(p){if(Se(p)&&o.length<5)return o+=String.fromCodePoint(p),e.consume(p),a;if(p===58){let m=o.toLowerCase();if(m==="http"||m==="https")return e.consume(p),l}return r(p)}function l(p){return p===47?(e.consume(p),i?c:(i=!0,l)):r(p)}function c(p){return p===null||Mt(p)||Q(p)||nt(p)||Ut(p)?r(p):e.attempt(Ra,e.attempt(ba,u),r)(p)}function u(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function md(e,t,r){let n=0;return o;function o(s){return(s===87||s===119)&&n<3?(n++,e.consume(s),o):s===46&&n===3?(e.consume(s),i):r(s)}function i(s){return s===null?r(s):t(s)}}function dd(e,t,r){let n,o,i;return s;function s(c){return c===46||c===95?e.check(wa,l,a)(c):c===null||Q(c)||nt(c)||c!==45&&Ut(c)?l(c):(i=!0,e.consume(c),s)}function a(c){return c===95?n=!0:(o=n,n=void 0),e.consume(c),s}function l(c){return o||n||!i?r(c):t(c)}}function gd(e,t){let r=0,n=0;return o;function o(s){return s===40?(r++,e.consume(s),o):s===41&&n<r?i(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?e.check(wa,t,i)(s):s===null||Q(s)||nt(s)?t(s):(e.consume(s),o)}function i(s){return s===41&&n++,e.consume(s),o}}function hd(e,t,r){return n;function n(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),n):a===38?(e.consume(a),i):a===93?(e.consume(a),o):a===60||a===null||Q(a)||nt(a)?t(a):r(a)}function o(a){return a===null||a===40||a===91||Q(a)||nt(a)?t(a):n(a)}function i(a){return Se(a)?s(a):r(a)}function s(a){return a===59?(e.consume(a),n):Se(a)?(e.consume(a),s):r(a)}}function xd(e,t,r){return n;function n(i){return e.consume(i),o}function o(i){return Te(i)?r(i):t(i)}}function Aa(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Q(e)}function _a(e){return!Se(e)}function Na(e){return!(e===47||wo(e))}function wo(e){return e===43||e===45||e===46||e===95||Te(e)}function ko(e){let t=e.length,r=!1;for(;t--;){let n=et1;if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){r=!0;break}if(n._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(ee.length-11._gfmAutolinkLiteralWalkedInto=!0),r}var yd={tokenize:Od,partial:!0};function Sa(){return{document:{91:{tokenize:wd,continuation:{tokenize:kd},exit:Td}},text:{91:{tokenize:bd},93:{add:"after",tokenize:Ed,resolveTo:Rd}}}}function Ed(e,t,r){let n=this,o=n.events.length,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),s;for(;o--;){let l=n.eventso1;if(l.type==="labelImage"){s=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!s||!s._balanced)return r(l);let c=Me(n.sliceSerialize({start:s.end,end:n.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Rd(e,t){let r=e.length,n;for(;r--;)if(er1.type==="labelImage"&&er0==="enter"){n=er1;break}er+11.type="data",er+31.type="gfmFootnoteCallLabelMarker";let o={type:"gfmFootnoteCall",start:Object.assign({},er+31.start),end:Object.assign({},ee.length-11.end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},er+31.end),end:Object.assign({},er+31.end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},ee.length-11.start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},l=[er+1,er+2,"enter",o,t,er+3,er+4,"enter",i,t,"exit",i,t,"enter",s,t,"enter",a,t,"exit",a,t,"exit",s,t,ee.length-2,ee.length-1,"exit",o,t];return e.splice(r,e.length-r+1,...l),e}function bd(e,t,r){let n=this,o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),i=0,s;return a;function a(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),l}function l(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(p){if(i>999||p===93&&!s||p===null||p===91||Q(p))return r(p);if(p===93){e.exit("chunkString");let m=e.exit("gfmFootnoteCallString");return o.includes(Me(n.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return Q(p)||(s=!0),i++,e.consume(p),p===92?u:c}function u(p){return p===91||p===92||p===93?(e.consume(p),i++,c):c(p)}}function wd(e,t,r){let n=this,o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),i,s=0,a;return l;function l(E){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(E){return E===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):r(E)}function u(E){if(s>999||E===93&&!a||E===null||E===91||Q(E))return r(E);if(E===93){e.exit("chunkString");let S=e.exit("gfmFootnoteDefinitionLabelString");return i=Me(n.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return Q(E)||(a=!0),s++,e.consume(E),E===92?p:u}function p(E){return E===91||E===92||E===93?(e.consume(E),s++,u):u(E)}function m(E){return E===58?(e.enter("definitionMarker"),e.consume(E),e.exit("definitionMarker"),o.includes(i)||o.push(i),V(e,f,"gfmFootnoteDefinitionWhitespace")):r(E)}function f(E){return t(E)}}function kd(e,t,r){return e.check(Dt,t,e.attempt(yd,t,r))}function Td(e){e.exit("gfmFootnoteDefinition")}function Od(e,t,r){let n=this;return V(e,o,"gfmFootnoteDefinitionIndent",5);function o(i){let s=n.eventsn.events.length-1;return s&&s1.type==="gfmFootnoteDefinitionIndent"&&s2.sliceSerialize(s1,!0).length===4?t(i):r(i)}}var bD={}.hasOwnProperty;function Ca(e){let t=(e||{}).singleTilde,r={tokenize:o,resolveAll:n};return t==null&&(t=!0),{text:{126:r},insideSpan:{null:r},attentionMarkers:{null:126}};function n(i,s){let a=-1;for(;++a<i.length;)if(ia0==="enter"&&ia1.type==="strikethroughSequenceTemporary"&&ia1._close){let l=a;for(;l--;)if(il0==="exit"&&il1.type==="strikethroughSequenceTemporary"&&il1._open&&ia1.end.offset-ia1.start.offset===il1.end.offset-il1.start.offset){ia1.type="strikethroughSequence",il1.type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},il1.start),end:Object.assign({},ia1.end)},u={type:"strikethroughText",start:Object.assign({},il1.end),end:Object.assign({},ia1.start)},p="enter",c,s],["enter",il1,s],["exit",il1,s],["enter",u,s,m=s.parser.constructs.insideSpan.null;m&&be(p,p.length,0,kt(m,i.slice(l+1,a),s)),be(p,p.length,0,"exit",u,s],["enter",ia1,s],["exit",ia1,s],["exit",c,s),be(i,l-1,a-l+3,p),a=l+p.length-2;break}}for(a=-1;++a<i.length;)ia1.type==="strikethroughSequenceTemporary"&&(ia1.type="data");return i}function o(i,s,a){let l=this.previous,c=this.events,u=0;return p;function p(f){return l===126&&cc.length-11.type!=="characterEscape"?a(f):(i.enter("strikethroughSequenceTemporary"),m(f))}function m(f){let E=nr(l);if(f===126)return u>1?a(f):(i.consume(f),u++,m);if(u<2&&!t)return a(f);let S=i.exit("strikethroughSequenceTemporary"),C=nr(f);return S._open=!C||C===2&&!!E,S._close=!E||E===2&&!!C,s(f)}}}var Ad=class{constructor(){this.map=[]}add(e,t,r){_d(this,e,t,r)}consume(e){if(this.map.sort((o,i)=>o0-i0),this.map.length===0)return;let t=this.map.length,r=[];for(;t>0;)t-=1,r.push(e.slice(this.mapt0+this.mapt1)),r.push(this.mapt2),e.length=this.mapt0;r.push(...e),e.length=0;let n=r.pop();for(;n;)e.push(...n),n=r.pop();this.map.length=0}};function _d(e,t,r,n){let o=0;if(!(r===0&&n.length===0)){for(;o<e.map.length;){if(e.mapo0===t){e.mapo1+=r,e.mapo2.push(...n);return}o+=1}e.map.push(t,r,n)}}function Nd(e,t){let r=!1,n=[];for(;t<e.length;){let o=et;if(r){if(o0==="enter")o1.type==="tableContent"&&n.push(et+11.type==="tableDelimiterMarker"?"left":"none");else if(o1.type==="tableContent"){if(et-11.type==="tableDelimiterMarker"){let i=n.length-1;ni=ni==="left"?"center":"right"}}else if(o1.type==="tableDelimiterRow")break}else o0==="enter"&&o1.type==="tableDelimiterRow"&&(r=!0);t+=1}return n}var La={flow:{null:{tokenize:Sd,resolveAll:Cd}}};function Sd(e,t,r){let n=this,o=0,i=0,s;return a;function a(x){let T=n.events.length-1;for(;T>-1;){let L=n.eventsT1.type;if(L==="lineEnding"||L==="linePrefix")T--;else break}let O=T>-1?n.eventsT1.type:null,A=O==="tableHead"||O==="tableRow"?h:l;return A===h&&n.parser.lazyn.now().line?r(x):A(x)}function l(x){return e.enter("tableHead"),e.enter("tableRow"),c(x)}function c(x){return x===124||(s=!0,i+=1),u(x)}function u(x){return x===null?r(x):U(x)?i>1?(i=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),f):r(x):z(x)?V(e,u,"whitespace")(x):(i+=1,s&&(s=!1,o+=1),x===124?(e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),s=!0,u):(e.enter("data"),p(x)))}function p(x){return x===null||x===124||Q(x)?(e.exit("data"),u(x)):(e.consume(x),x===92?m:p)}function m(x){return x===92||x===124?(e.consume(x),p):p(x)}function f(x){return n.interrupt=!1,n.parser.lazyn.now().line?r(x):(e.enter("tableDelimiterRow"),s=!1,z(x)?V(e,E,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):E(x))}function E(x){return x===45||x===58?C(x):x===124?(s=!0,e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),S):b(x)}function S(x){return z(x)?V(e,C,"whitespace")(x):C(x)}function C(x){return x===58?(i+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(x),e.exit("tableDelimiterMarker"),_):x===45?(i+=1,_(x)):x===null||U(x)?w(x):b(x)}function _(x){return x===45?(e.enter("tableDelimiterFiller"),W(x)):b(x)}function W(x){return x===45?(e.consume(x),W):x===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(x),e.exit("tableDelimiterMarker"),R):(e.exit("tableDelimiterFiller"),R(x))}function R(x){return z(x)?V(e,w,"whitespace")(x):w(x)}function w(x){return x===124?E(x):x===null||U(x)?!s||o!==i?b(x):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(x)):b(x)}function b(x){return r(x)}function h(x){return e.enter("tableRow"),N(x)}function N(x){return x===124?(e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),N):x===null||U(x)?(e.exit("tableRow"),t(x)):z(x)?V(e,N,"whitespace")(x):(e.enter("data"),P(x))}function P(x){return x===null||x===124||Q(x)?(e.exit("data"),N(x)):(e.consume(x),x===92?M:P)}function M(x){return x===92||x===124?(e.consume(x),P):P(x)}}function Cd(e,t){let r=-1,n=!0,o=0,i=0,0,0,0,s=0,0,0,0,a=!1,l=0,c,u,p,m=new Ad;for(;++r<e.length;){let f=er,E=f1;f0==="enter"?E.type==="tableHead"?(a=!1,l!==0&&(Pa(m,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},m.add(r,0,"enter",c,t)):E.type==="tableRow"||E.type==="tableDelimiterRow"?(n=!0,p=void 0,i=0,0,0,0,s=0,r+1,0,0,a&&(a=!1,u={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},m.add(r,0,"enter",u,t)),o=E.type==="tableDelimiterRow"?2:u?3:1):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(n=!1,s2===0&&(i1!==0&&(s0=s1,p=fn(m,t,i,o,void 0,p),i=0,0,0,0),s2=r)):E.type==="tableCellDivider"&&(n?n=!1:(i1!==0&&(s0=s1,p=fn(m,t,i,o,void 0,p)),i=s,s=[i1,r,0,0])):E.type==="tableHead"?(a=!0,l=r):E.type==="tableRow"||E.type==="tableDelimiterRow"?(l=r,i1!==0?(s0=s1,p=fn(m,t,i,o,r,p)):s1!==0&&(p=fn(m,t,s,o,r,p)),o=0):o&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(s3=r)}for(l!==0&&Pa(m,t,l,c,u),m.consume(t.events),r=-1;++r<t.events.length;){let f=t.eventsr;f0==="enter"&&f1.type==="table"&&(f1._align=Nd(t.events,r))}return e}function fn(e,t,r,n,o,i){let s=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",a="tableContent";r0!==0&&(i.end=Object.assign({},or(t.events,r0)),e.add(r0,0,"exit",i,t));let l=or(t.events,r1);if(i={type:s,start:Object.assign({},l),end:Object.assign({},l)},e.add(r1,0,"enter",i,t),r2!==0){let c=or(t.events,r2),u=or(t.events,r3),p={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(r2,0,"enter",p,t),n!==2){let m=t.events[r2],f=t.events[r3];if(m1.end=Object.assign({},f1.end),m1.type="chunkText",m1.contentType="text",r3>r2+1){let E=r2+1,S=r3-r2-1;e.add(E,S,[])}}e.add(r3+1,0,"exit",p,t)}return o!==void 0&&(i.end=Object.assign({},or(t.events,o)),e.add(o,0,"exit",i,t),i=void 0),i}function Pa(e,t,r,n,o){let i=[],s=or(t.events,r);o&&(o.end=Object.assign({},s),i.push("exit",o,t)),n.end=Object.assign({},s),i.push("exit",n,t),e.add(r+1,0,i)}function or(e,t){let r=et,n=r0==="enter"?"start":"end";return r1n}var Pd=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|title|textarea|xmp)(?=\t\n\f\r />)/gi,qD=new RegExp("^"+Pd.source,"i");var Ld={tokenize:vd},va={text:{91:Ld}};function vd(e,t,r){let n=this;return o;function o(l){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?r(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return Q(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),s):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),s):r(l)}function s(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):r(l)}function a(l){return U(l)?t(l):z(l)?e.check({tokenize:Fd},t,r)(l):r(l)}}function Fd(e,t,r){return V(e,n,"whitespace");function n(o){return o===null?r(o):t(o)}}function Fa(e){return un(Oa,Sa(),Ca(e),La,va)}var Ia=e=>Zs(e,{extensions:Fa(),mdastExtensions:Ea()}).children.map(t=>sr(t)).join(` ),To=(e,t="txt")=>[code:${t},...e.split(
).map(r=> ${r})].join(
),sr=e=>{switch(e.type){case"paragraph":return e.children.map(t=>ir(t)).join("");case"heading":return Md(e);case"code":return To(e.value,e.lang??"txt");case"yaml":return To(e.value,"yaml");case"thematicBreak":return"[/icons/hr.icon]";case"table":return["table:table",...e.children.map(t=> ${Ua(t)})].join(
);case"tableRow":return Ua(e);case"tableCell":return Da(e);case"footnoteDefinition":return${e.label}: ${e.children.map(t=>sr(t)).join("").replaceAll(`
," ")};case"definition":return[${e.label}]: ${e.url};case"list":return e.children.map((t,r)=>{let n=e.ordered?${(e.start??1)+r}. :"";return Ma(t,n)}).join(`
);case"listItem":return Ma(e);case"blockquote":return e.children.map(t=>sr(t).split(
).map(n=>> ${n}).join(
)).join(
);default:return ir(e)}},Md=e=>e.children.map(t=>${sr(t)}).join(""),Ma=(e,t="")=>{if(e.children.length===0)return"";let r=sr(e.children[0]),n=${t}${r},o=e.children.slice(1).map(i=>sr(i).split(
).map(a=> ${a}).join(
)).join(
);return o?${n}
${o}:n},ir=e=>{let t=n=>{if(n.title)return${n.title} ${n.url};let o=n.children.map(i=>ir(i)).join("");return o!==n.url?${o} ${n.url}:${n.url}},r=n=>${n};switch(e.type){case"link":return t(e);case"inlineCode":return\${e.value}\`;case"html":return To(e.value,"html");case"text":return e.value;case"break":return` ," ");switch(e.type){case"footnote":return${n};case"emphasis":return${n};case"strong":return${n};case"delete":return${n};default:return n}}}},Ua=e=> ${e.children.map(t=>Da(t)).join(" ")},Da=e=>e.children.map(t=>ir(t)).join("").replaceAll( ," ").replace(/\s+/g," ").trimEnd();cosense.PopupMenu.addButton({title:"From Markdown",onClick:Ia});scrapbox.TimeStamp.removeAllFormats();scrapbox.TimeStamp.addFormat("YYYY/M/D");scrapbox.TimeStamp.addFormat("[[]YYYY/M/D[]]");scrapbox.TimeStamp.addFormat("YYYY/M/D HH:mm:ss");var $a=e=>{{let r=e.match(/^([^(]+)\(([^)]+)\)$/);if(r)return{fileName:r[1],lang:r[2]}}let t=e.split(".").pop();return t===void 0?{fileName:e,lang:e}:{fileName:e,lang:t}};var Ud=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),ja=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Ud(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)},Ba=(e,t)=>{if(t.hasTitle??!0){let[r,...n]=e;return r===void 0?[]:[{type:"title",rows:[r]},...n.reduce(ja,[])]}return e.reduce(ja,[])};var Ha=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var Wa=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},i=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:i,content:r.map(s=>s.text.substring(n+1)).join(
)}};var Z=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,i,s)=>{if(!t&&i.nested)return s?.()??[];if(!r&&i.quoted)return s?.()??[];for(let a of n){let l=a.exec(o);if(l===null)continue;let c=o.substring(0,l.index),u=o.substring(l.index+(l[0]?.length??0)),p=e(l[0]??"",i);return[...Ge(c,i),...p,...Ge(u,i)]}return s?.()??[]};var te=e=>[{type:"plain",raw:e,text:e}],Va=Z(te,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var Id=/\[\s+\]/,Dd=(e,t)=>t.context==="table"?te(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Ga=Z(Dd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Id]});var $d=/.*?/,jd=(e,t)=>t.context==="table"?te(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],za=Z(jd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$d]});var Bd=/^[$%] .+$/,Hd=(e,t)=>{if(t.context==="table")return te(e,t);let r=e[0]??"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:n}]},qa=Z(Hd,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Bd]});var Wd=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Vd=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),i=new Set(n);if(i.has("*")){let s=n.split("*").length-1;i.delete("*"),i.add(*-${Math.min(s,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(i),nodes:Ge(o,{...t,nested:!0})}]},Ka=Z(Vd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Wd]});var Gd=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,zd=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,qd=/\[https?:\/\/[^\s\]]+\]/,Kd=/https?:\/\/[^\s]+/,Jd=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let i=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:i.trim()}]},Ja=Z(Jd,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Gd,zd,qd,Kd]});var Yd=/\[\$ .+? \]/,Qd=/\[\$ [^\]]+\]/,Xd=(e,t)=>t.context==="table"?te(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Ya=Z(Xd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Yd,Qd]});var Qa=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Xa=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Zd=e=>{let[t="",r="",n=""]=e.split(","),o=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),i=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),s=/^Z\d+$/.test(n)?Number.parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:i,zoom:s}},eg=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.match(Qa)??e.match(Xa);if(r===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,o="",i=""]=n?r:[r[0],r[2],r[1]],{latitude:s,longitude:a,zoom:l}=Zd(o),c=i!==""?https://www.google.com/maps/place/${encodeURIComponent(i)}/@${s},${a},${l}z:https://www.google.com/maps/@${s},${a},${l}z;return[{type:"googleMap",raw:e,latitude:s,longitude:a,zoom:l,place:i,url:c}]},Za=Z(eg,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Qa,Xa]});var tg=/(?:^|\s)#\S+/,rg=(e,t)=>{if(t.context==="table")return te(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...te(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},el=Z(rg,{parseOnNested:!0,parseOnQuoted:!0,patterns:[tg]});var ng=/^\? .+$/,og=(e,t)=>t.context==="table"?te(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],tl=Z(og,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ng]});var ig=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,sg=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),n=t.substring(0,r),o=n.startsWith("/")?"root":"relative",i=t.substring(r+5,t.length),s=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(s).fill({}).map(()=>({path:n,pathType:o,type:"icon",raw:e}))},rl=Z(sg,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ig]});var ag=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,lg=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,cg=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,ug=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,pg=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||fg(e),fg=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),mg=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[i,s]=pg(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(i)?${i}/thumb/1000:i,link:s}]},nl=Z(mg,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ag,lg,cg,ug]});var dg=/\[\/?[^[\]]+\]/,gg=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},ol=Z(gg,{parseOnNested:!0,parseOnQuoted:!0,patterns:[dg]});var hg=/^[0-9]+\. .*$/,xg=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=Number.parseInt(n,10),i=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:Ge(i,{...t,nested:!1})}]},il=Z(xg,{parseOnNested:!1,parseOnQuoted:!1,patterns:[hg]});var yg=/^>.*$/,Eg=(e,t)=>t.context==="table"?te(e,t):[{type:"quote",raw:e,nodes:Ge(e.substring(1),{...t,quoted:!0})}],sl=Z(Eg,{parseOnNested:!1,parseOnQuoted:!1,patterns:[yg]});var Rg=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,bg=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.substring(2,e.length-2),n=r.lastIndexOf(".icon"),o=r.substring(0,n),i=o.startsWith("/")?"root":"relative",s=r.substring(n+5,r.length),a=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:o,pathType:i,type:"strongIcon",raw:e}))},al=Z(bg,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Rg]});var wg=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,kg=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Tg=(e,t)=>{if(t.context==="table")return te(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},ll=Z(Tg,{parseOnNested:!1,parseOnQuoted:!0,patterns:[wg,kg]});var Og=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Ag=(e,t)=>t.context==="table"?te(e,t):[{type:"strong",raw:e,nodes:Ge(e.substring(2,e.length-2),{...t,nested:!0})}],cl=Z(Ag,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Og]});var _g=(e,t,r)=>e===""?[]:r?.()??[],Ng=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>Va(t,r))(),Ge=Ng(_g,sl,tl,il,za,qa,Ya,Ga,Ka,ll,al,cl,nl,Ja,rl,Za,ol,el);var ul=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:Ge(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var pl=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},i=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:i,cells:r.map(s=>s.text.substring(n+1)).map(s=>s.split(" ").map(a=>Ge(a,{nested:!1,quoted:!1,context:"table"})))}};var fl=e=>({type:"title",text:e.rows[0].text});var ml=e=>{switch(e.type){case"title":return fl(e);case"codeBlock":return Wa(e);case"table":return pl(e);case"line":return ul(e)}};var Oo=(e,t)=>{let r=Ha(e);return Ba(r,{hasTitle:t?.hasTitle??!0}).map(ml)};var dl=(e,t,r)=>{if(r.length===0)return[];let n=r.map(a=>a.text).join( ),o=Oo(n,{hasTitle:!0}),i=new Map,s=0;for(let a of o)switch(a.type){case"title":case"line":{s++;break}case"table":s+=a.cells.length+1;break;case"codeBlock":{let{fileName:l,lang:c}=$a(a.fileName),u=i.get(l);i.set(l,{path:u?.path??https://scrapbox.io/api/code/${e}/${Ft(t)}/${Ft(l)},lang:u?.lang??c,startIds:[...u?.startIds??[],r[s].id]}),s+=a.content.split( ).length+1;break}}return i.values()};function _o(e){let t=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(Xe(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let o of n)t(o)}else{let o=Object.keys(n);r.write8(6),r.write32(o.length);for(let i of o)r.write(Xe(i)),t(n[i])}},r=new mn;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ao(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function gl(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ar(r.read());case 4:return r.read();case 5:{let s=r.read32(),a=[];for(let l=0;l<s;l++)a.push(t());return a}case 6:{let s=r.read32(),a={};for(let l=0;l<s;l++)a[ar(r.read())]=t();return a}default:throw new Error("Invalid packet")}},r=new mn(e),n=r.read32(),o=(n&1)===0;n>>>=1;let i=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:i}}var mn=class{constructor(t=new Uint8Array(1024)){this.buf=t}len=0;ptr=0;_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Ao(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ao(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return No(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),n=this._read(r.length);return r.set(this.buf.subarray(n,n+t)),r}},Xe,ar,hl;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;Xe=r=>e.encode(r),ar=r=>t.decode(r),hl='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(Xe("")instanceof Uint8Array))throw new Error(Invariant violation: "${hl} instanceof Uint8Array" is incorrectly false
This indicates that your JavaScript environment is broken. You cannot use
esbuild in this environment because esbuild relies on this invariant. This
is not a problem with esbuild. You need to fix your environment instead.
);function No(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ao(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var Tr="0.23.0";var Oe=JSON.stringify,xl="warning",yl="silent";function El(e){if(Ce(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var hn=()=>null,de=e=>typeof e=="boolean"?null:"a boolean",H=e=>typeof e=="string"?null:"a string",xn=e=>e instanceof RegExp?null:"a RegExp object",Bt=e=>typeof e=="number"&&e===(e|0)?null:"an integer",wl=e=>typeof e=="function"?null:"a function",ye=e=>Array.isArray(e)?null:"an array",Je=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Cg=e=>typeof e=="object"&&e!==null?null:"an array or an object",Pg=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Rl=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",kl=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",Lg=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",vg=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Tl=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Fg=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function y(e,t,r,n){let o=e[r];if(t[r+""]=!0,o===void 0)return;let i=n(o);if(i!==null)throw new Error(${Oe(r)} must be ${i});return o}function Ae(e,t,r){for(let n in e)if(!(n in t))throw new Error(Invalid option ${r}: ${Oe(n)})}function Ol(e){let t=Object.create(null),r=y(e,t,"wasmModule",Pg),n=y(e,t,"workerURL",Fg);return Ae(e,t,"in initialize() call"),{wasmModule:r,workerURL:n}}function Al(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let n=e[r];if(typeof n=="string"||n===!1)t[r]=n;else throw new Error(Expected ${Oe(r)} in mangle cache to map to either a string or false)}}return t}function yn(e,t,r,n,o){let i=y(t,r,"color",de),s=y(t,r,"logLevel",H),a=y(t,r,"logLimit",Bt);i!==void 0?e.push(--color=${i}):n&&e.push("--color=true"),e.push(--log-level=${s||o}),e.push(--log-limit=${a||0})}function Ce(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+Oe(r):""} to be a string, got ${typeof e} instead);return e}function _l(e,t,r){let n=y(t,r,"legalComments",H),o=y(t,r,"sourceRoot",H),i=y(t,r,"sourcesContent",de),s=y(t,r,"target",vg),a=y(t,r,"format",H),l=y(t,r,"globalName",H),c=y(t,r,"mangleProps",xn),u=y(t,r,"reserveProps",xn),p=y(t,r,"mangleQuoted",de),m=y(t,r,"minify",de),f=y(t,r,"minifySyntax",de),E=y(t,r,"minifyWhitespace",de),S=y(t,r,"minifyIdentifiers",de),C=y(t,r,"lineLimit",Bt),_=y(t,r,"drop",ye),W=y(t,r,"dropLabels",ye),R=y(t,r,"charset",H),w=y(t,r,"treeShaking",de),b=y(t,r,"ignoreAnnotations",de),h=y(t,r,"jsx",H),N=y(t,r,"jsxFactory",H),P=y(t,r,"jsxFragment",H),M=y(t,r,"jsxImportSource",H),x=y(t,r,"jsxDev",de),T=y(t,r,"jsxSideEffects",de),O=y(t,r,"define",Je),A=y(t,r,"logOverride",Je),L=y(t,r,"supported",Je),F=y(t,r,"pure",ye),D=y(t,r,"keepNames",de),$=y(t,r,"platform",H),G=y(t,r,"tsconfigRaw",Lg);if(n&&e.push(--legal-comments=${n}),o!==void 0&&e.push(--source-root=${o}),i!==void 0&&e.push(--sources-content=${i}),s&&(Array.isArray(s)?e.push(--target=${Array.from(s).map(El).join(",")}):e.push(--target=${El(s)})),a&&e.push(--format=${a}),l&&e.push(--global-name=${l}),$&&e.push(--platform=${$}),G&&e.push(--tsconfig-raw=${typeof G=="string"?G:JSON.stringify(G)}),m&&e.push("--minify"),f&&e.push("--minify-syntax"),E&&e.push("--minify-whitespace"),S&&e.push("--minify-identifiers"),C&&e.push(--line-limit=${C}),R&&e.push(--charset=${R}),w!==void 0&&e.push(--tree-shaking=${w}),b&&e.push("--ignore-annotations"),_)for(let B of _)e.push(--drop:${Ce(B,"drop")});if(W&&e.push(--drop-labels=${Array.from(W).map(B=>Ce(B,"dropLabels")).join(",")}),c&&e.push(--mangle-props=${c.source}),u&&e.push(--reserve-props=${u.source}),p!==void 0&&e.push(--mangle-quoted=${p}),h&&e.push(--jsx=${h}),N&&e.push(--jsx-factory=${N}),P&&e.push(--jsx-fragment=${P}),M&&e.push(--jsx-import-source=${M}),x&&e.push("--jsx-dev"),T&&e.push("--jsx-side-effects"),O)for(let B in O){if(B.indexOf("=")>=0)throw new Error(Invalid define: ${B});e.push(--define:${B}=${Ce(OB,"define",B)})}if(A)for(let B in A){if(B.indexOf("=")>=0)throw new Error(Invalid log override: ${B});e.push(--log-override:${B}=${Ce(AB,"log override",B)})}if(L)for(let B in L){if(B.indexOf("=")>=0)throw new Error(Invalid supported: ${B});let d=L[B];if(typeof d!="boolean")throw new Error(Expected value for supported ${Oe(B)} to be a boolean, got ${typeof d} instead);e.push(--supported:${B}=${d})}if(F)for(let B of F)e.push(--pure:${Ce(B,"pure")});D&&e.push("--keep-names")}function Mg(e,t,r,n,o){let i=[],s=[],a=Object.create(null),l=null,c=null;yn(i,t,a,r,n),_l(i,t,a);let u=y(t,a,"sourcemap",kl),p=y(t,a,"bundle",de),m=y(t,a,"splitting",de),f=y(t,a,"preserveSymlinks",de),E=y(t,a,"metafile",de),S=y(t,a,"outfile",H),C=y(t,a,"outdir",H),_=y(t,a,"outbase",H),W=y(t,a,"tsconfig",H),R=y(t,a,"resolveExtensions",ye),w=y(t,a,"nodePaths",ye),b=y(t,a,"mainFields",ye),h=y(t,a,"conditions",ye),N=y(t,a,"external",ye),P=y(t,a,"packages",H),M=y(t,a,"alias",Je),x=y(t,a,"loader",Je),T=y(t,a,"outExtension",Je),O=y(t,a,"publicPath",H),A=y(t,a,"entryNames",H),L=y(t,a,"chunkNames",H),F=y(t,a,"assetNames",H),D=y(t,a,"inject",ye),$=y(t,a,"banner",Je),G=y(t,a,"footer",Je),B=y(t,a,"entryPoints",Cg),d=y(t,a,"absWorkingDir",H),q=y(t,a,"stdin",Je),J=y(t,a,"write",de)??o,g=y(t,a,"allowOverwrite",de),le=y(t,a,"mangleCache",Je);if(a.plugins=!0,Ae(t,a,in ${e}() call),u&&i.push(--sourcemap${u===!0?"":=${u}}),p&&i.push("--bundle"),g&&i.push("--allow-overwrite"),m&&i.push("--splitting"),f&&i.push("--preserve-symlinks"),E&&i.push("--metafile"),S&&i.push(--outfile=${S}),C&&i.push(--outdir=${C}),_&&i.push(--outbase=${_}),W&&i.push(--tsconfig=${W}),P&&i.push(--packages=${P}),R){let I=[];for(let ne of R){if(Ce(ne,"resolve extension"),ne.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${ne});I.push(ne)}i.push(--resolve-extensions=${I.join(",")})}if(O&&i.push(--public-path=${O}),A&&i.push(--entry-names=${A}),L&&i.push(--chunk-names=${L}),F&&i.push(--asset-names=${F}),b){let I=[];for(let ne of b){if(Ce(ne,"main field"),ne.indexOf(",")>=0)throw new Error(Invalid main field: ${ne});I.push(ne)}i.push(--main-fields=${I.join(",")})}if(h){let I=[];for(let ne of h){if(Ce(ne,"condition"),ne.indexOf(",")>=0)throw new Error(Invalid condition: ${ne});I.push(ne)}i.push(--conditions=${I.join(",")})}if(N)for(let I of N)i.push(--external:${Ce(I,"external")});if(M)for(let I in M){if(I.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${I});i.push(--alias:${I}=${Ce(MI,"alias",I)})}if($)for(let I in $){if(I.indexOf("=")>=0)throw new Error(Invalid banner file type: ${I});i.push(--banner:${I}=${Ce($I,"banner",I)})}if(G)for(let I in G){if(I.indexOf("=")>=0)throw new Error(Invalid footer file type: ${I});i.push(--footer:${I}=${Ce(GI,"footer",I)})}if(D)for(let I of D)i.push(--inject:${Ce(I,"inject")});if(x)for(let I in x){if(I.indexOf("=")>=0)throw new Error(Invalid loader extension: ${I});i.push(--loader:${I}=${Ce(xI,"loader",I)})}if(T)for(let I in T){if(I.indexOf("=")>=0)throw new Error(Invalid out extension: ${I});i.push(--out-extension:${I}=${Ce(TI,"out extension",I)})}if(B)if(Array.isArray(B))for(let I=0,ne=B.length;I<ne;I++){let oe=B[I];if(typeof oe=="object"&&oe!==null){let Be=Object.create(null),_e=y(oe,Be,"in",H),Pe=y(oe,Be,"out",H);if(Ae(oe,Be,"in entry point at index "+I),_e===void 0)throw new Error('Missing property "in" for entry point at index '+I);if(Pe===void 0)throw new Error('Missing property "out" for entry point at index '+I);s.push([Pe,_e])}else s.push(["",Ce(oe,"entry point at index "+I)])}else for(let I in B)s.push([I,Ce(B[I],"entry point",I)]);if(q){let I=Object.create(null),ne=y(q,I,"contents",Tl),oe=y(q,I,"resolveDir",H),Be=y(q,I,"sourcefile",H),_e=y(q,I,"loader",H);Ae(q,I,'in "stdin" object'),Be&&i.push(--sourcefile=${Be}),_e&&i.push(--loader=${_e}),oe&&(c=oe),typeof ne=="string"?l=Xe(ne):ne instanceof Uint8Array&&(l=ne)}let ie=[];if(w)for(let I of w)I+="",ie.push(I);return{entries:s,flags:i,write:J,stdinContents:l,stdinResolveDir:c,absWorkingDir:d,nodePaths:ie,mangleCache:Al(le)}}function Ug(e,t,r,n){let o=[],i=Object.create(null);yn(o,t,i,r,n),_l(o,t,i);let s=y(t,i,"sourcemap",kl),a=y(t,i,"sourcefile",H),l=y(t,i,"loader",H),c=y(t,i,"banner",H),u=y(t,i,"footer",H),p=y(t,i,"mangleCache",Je);return Ae(t,i,in ${e}() call),s&&o.push(--sourcemap=${s===!0?"external":s}),a&&o.push(--sourcefile=${a}),l&&o.push(--loader=${l}),c&&o.push(--banner=${c}),u&&o.push(--footer=${u}),{flags:o,mangleCache:Al(p)}}function Nl(e){let t={},r={didClose:!1,reason:""},n={},o=0,i=0,s=new Uint8Array(16*1024),a=0,l=R=>{let w=a+R.length;if(w>s.length){let h=new Uint8Array(w*2);h.set(s),s=h}s.set(R,a),a+=R.length;let b=0;for(;b+4<=a;){let h=No(s,b);if(b+4+h>a)break;b+=4,E(s.subarray(b,b+h)),b+=h}b>0&&(s.copyWithin(0,b,a),a-=b)},c=R=>{r.didClose=!0,R&&(r.reason=": "+(R.message||R));let w="The service was stopped"+r.reason;for(let b in n)n[b](w,null);n={}},u=(R,w,b)=>{if(r.didClose)return b("The service is no longer running"+r.reason,null);let h=o++;n[h]=(N,P)=>{try{b(N,P)}finally{R&&R.unref()}},R&&R.ref(),e.writeToStdin(_o({id:h,isRequest:!0,value:w}))},p=(R,w)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(_o({id:R,isRequest:!1,value:w}))},m=async(R,w)=>{try{if(w.command==="ping"){p(R,{});return}if(typeof w.key=="number"){let b=t[w.key];if(!b)return;let h=b[w.command];if(h){await h(R,w);return}}throw new Error("Invalid command: "+w.command)}catch(b){let h=[jt(b,e,null,void 0,"")];try{p(R,{errors:h})}catch{}}},f=!0,E=R=>{if(f){f=!1;let b=String.fromCharCode(...R);if(b!==Tr)throw new Error(Cannot start service: Host version "${Tr}" does not match binary version ${Oe(b)});return}let w=gl(R);if(w.isRequest)m(w.id,w.value);else{let b=n[w.id];delete n[w.id],w.value.error?b(w.value.error,{}):b(null,w.value)}};return{readFromStdout:l,afterClose:c,service:{buildOrContext:({callName:R,refs:w,options:b,isTTY:h,defaultWD:N,callback:P})=>{let M=0,x=i++,T={},O={ref(){++M===1&&w&&w.ref()},unref(){--M===0&&(delete t[x],w&&w.unref())}};t[x]=T,O.ref(),Ig(R,x,u,p,O,e,T,b,h,N,(A,L)=>{try{P(A,L)}finally{O.unref()}})},transform:({callName:R,refs:w,input:b,options:h,isTTY:N,fs:P,callback:M})=>{let x=Sl(),T=O=>{try{if(typeof b!="string"&&!(b instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:A,mangleCache:L}=Ug(R,h,N,yl),F={command:"transform",flags:A,inputFS:O!==null,input:O!==null?Xe(O):typeof b=="string"?Xe(b):b};L&&(F.mangleCache=L),u(w,F,(D,$)=>{if(D)return M(new Error(D),null);let G=lr($.errors,x),B=lr($.warnings,x),d=1,q=()=>{if(--d===0){let J={warnings:B,code:$.code,map:$.map,mangleCache:void 0,legalComments:void 0};"legalComments"in $&&(J.legalComments=$?.legalComments),$.mangleCache&&(J.mangleCache=$?.mangleCache),M(null,J)}};if(G.length>0)return M(Or("Transform failed",G,B),null);$.codeFS&&(d++,P.readFile($.code,(J,g)=>{J!==null?M(J,null):($.code=g,q())})),$.mapFS&&(d++,P.readFile($.map,(J,g)=>{J!==null?M(J,null):($.map=g,q())})),q()})}catch(A){let L=[];try{yn(L,h,{},N,yl)}catch{}let F=jt(A,e,x,void 0,"");u(w,{command:"error",flags:L,error:F},()=>{F.detail=x.load(F.detail),M(Or("Transform failed",[F],[]),null)})}};if((typeof b=="string"||b instanceof Uint8Array)&&b.length>1024*1024){let O=T;T=()=>P.writeFile(b,O)}T(null)},formatMessages:({callName:R,refs:w,messages:b,options:h,callback:N})=>{if(!h)throw new Error(Missing second argument in ${R}() call);let P={},M=y(h,P,"kind",H),x=y(h,P,"color",de),T=y(h,P,"terminalWidth",Bt);if(Ae(h,P,in ${R}() call),M===void 0)throw new Error(Missing "kind" in ${R}() call);if(M!=="error"&&M!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${R}() call);let O={command:"format-msgs",messages:xt(b,"messages",null,"",T),isWarning:M==="warning"};x!==void 0&&(O.color=x),T!==void 0&&(O.terminalWidth=T),u(w,O,(A,L)=>{if(A)return N(new Error(A),null);N(null,L.messages)})},analyzeMetafile:({callName:R,refs:w,metafile:b,options:h,callback:N})=>{h===void 0&&(h={});let P={},M=y(h,P,"color",de),x=y(h,P,"verbose",de);Ae(h,P,in ${R}() call);let T={command:"analyze-metafile",metafile:b};M!==void 0&&(T.color=M),x!==void 0&&(T.verbose=x),u(w,T,(O,A)=>{if(O)return N(new Error(O),null);N(null,A.result)})}}}}function Ig(e,t,r,n,o,i,s,a,l,c,u){let p=Sl(),m=e==="context",f=(C,_)=>{let W=[];try{yn(W,a,{},l,xl)}catch{}let R=jt(C,i,p,void 0,_);r(o,{command:"error",flags:W,error:R},()=>{R.detail=p.load(R.detail),u(Or(m?"Context failed":"Build failed",[R],[]),null)})},E;if(typeof a=="object"){let C=a.plugins;if(C!==void 0){if(!Array.isArray(C))return f(new Error('"plugins" must be an array'),"");E=C}}if(E&&E.length>0){if(i.isSync)return f(new Error("Cannot use plugins in synchronous API calls"),"");Dg(t,r,n,o,i,s,a,E,p).then(C=>{if(!C.ok)return f(C.error,C.pluginName);try{S(C.requestPlugins,C.runOnEndCallbacks,C.scheduleOnDisposeCallbacks)}catch(_){f(_,"")}},C=>f(C,""));return}try{S(null,(C,_)=>_([],[]),()=>{})}catch(C){f(C,"")}function S(C,_,W){let R=i.hasFS,{entries:w,flags:b,write:h,stdinContents:N,stdinResolveDir:P,absWorkingDir:M,nodePaths:x,mangleCache:T}=Mg(e,a,l,xl,R);if(h&&!i.hasFS)throw new Error('The "write" option is unavailable in this environment');let O={command:"build",key:t,entries:w,flags:b,write:h,stdinContents:N,stdinResolveDir:P,absWorkingDir:M||c,nodePaths:x,context:m};C&&(O.plugins=C),T&&(O.mangleCache=T);let A=(D,$)=>{let G={errors:lr(D.errors,p),warnings:lr(D.warnings,p),outputFiles:void 0,metafile:void 0,mangleCache:void 0},B=G.errors.slice(),d=G.warnings.slice();D.outputFiles&&(G.outputFiles=D.outputFiles.map(jg)),D.metafile&&(G.metafile=JSON.parse(D.metafile)),D.mangleCache&&(G.mangleCache=D.mangleCache),D.writeToStdout!==void 0&&console.log(ar(D.writeToStdout).replace(/\n$/,"")),_(G,(q,J)=>{if(B.length>0||q.length>0){let g=Or("Build failed",B.concat(q),d.concat(J));return $(g,null,q,J)}$(null,G,q,J)})},L,F;m&&(s["on-end"]=(D,$)=>new Promise(G=>{A($,(B,d,q,J)=>{let g={errors:q,warnings:J};F&&F(B,d),L=void 0,F=void 0,n(D,g),G()})})),r(o,O,(D,$)=>{if(D)return u(new Error(D),null);if(!m)return A($,(d,q)=>(W(),u(d,q)));if($.errors.length>0)return u(Or("Context failed",$.errors,$.warnings),null);let G=!1,B={rebuild:()=>(L||(L=new Promise((d,q)=>{let J;F=(le,ie)=>{J||(J=()=>le?q(le):d(ie))};let g=()=>{r(o,{command:"rebuild",key:t},(ie,I)=>{ie?q(new Error(ie)):J?J():g()})};g()})),L),watch:(d={})=>new Promise((q,J)=>{if(!i.hasFS)throw new Error('Cannot use the "watch" API in this environment');Ae(d,{},"in watch() call"),r(o,{command:"watch",key:t},ie=>{ie?J(new Error(ie)):q(void 0)})}),serve:(d={})=>new Promise((q,J)=>{if(!i.hasFS)throw new Error('Cannot use the "serve" API in this environment');let g={},le=y(d,g,"port",Bt),ie=y(d,g,"host",H),I=y(d,g,"servedir",H),ne=y(d,g,"keyfile",H),oe=y(d,g,"certfile",H),Be=y(d,g,"fallback",H),_e=y(d,g,"onRequest",wl);Ae(d,g,"in serve() call");let Pe={command:"serve",key:t,onRequest:!!_e};le!==void 0&&(Pe.port=le),ie!==void 0&&(Pe.host=ie),I!==void 0&&(Pe.servedir=I),ne!==void 0&&(Pe.keyfile=ne),oe!==void 0&&(Pe.certfile=oe),Be!==void 0&&(Pe.fallback=Be),r(o,Pe,(et,gr)=>{if(et)return J(new Error(et));_e&&(s["serve-request"]=(zn,qn)=>{_e(qn.args),n(zn,{})}),q(gr)})}),cancel:()=>new Promise(d=>{if(G)return d();r(o,{command:"cancel",key:t},()=>{d()})}),dispose:()=>new Promise(d=>{if(G)return d();G=!0,r(o,{command:"dispose",key:t},()=>{d(),W(),o.unref()})})};o.ref(),u(null,B)})}}var Dg=async(e,t,r,n,o,i,s,a,l)=>{let c=[],u=[],p={},m={},f=[],E=0,S=0,C=[],_=!1;a=[...a];for(let w of a){let b={};if(typeof w!="object")throw new Error(Plugin at index ${S} must be an object);let h=y(w,b,"name",H);if(typeof h!="string"||h==="")throw new Error(Plugin at index ${S} is missing a name);try{let N=y(w,b,"setup",wl);if(typeof N!="function")throw new Error("Plugin is missing a setup function");Ae(w,b,on plugin ${Oe(h)});let P={name:h,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};S++;let x=N({initialOptions:s,resolve:(T,O={})=>{if(!_)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof T!="string")throw new Error("The path to resolve must be a string");let A=Object.create(null),L=y(O,A,"pluginName",H),F=y(O,A,"importer",H),D=y(O,A,"namespace",H),$=y(O,A,"resolveDir",H),G=y(O,A,"kind",H),B=y(O,A,"pluginData",hn),d=y(O,A,"with",Je);return Ae(O,A,"in resolve() call"),new Promise((q,J)=>{let g={command:"resolve",path:T,key:e,pluginName:h};if(L!=null&&(g.pluginName=L),F!=null&&(g.importer=F),D!=null&&(g.namespace=D),$!=null&&(g.resolveDir=$),G!=null)g.kind=G;else throw new Error('Must specify "kind" when calling "resolve"');B!=null&&(g.pluginData=l.store(B)),d!=null&&(g.with=$g(d,"with")),t(n,g,(le,ie)=>{le!==null?J(new Error(le)):q({errors:lr(ie.errors,l),warnings:lr(ie.warnings,l),path:ie.path,external:ie.external,sideEffects:ie.sideEffects,namespace:ie.namespace,suffix:ie.suffix,pluginData:l.load(ie.pluginData)})})})},onStart(T){let O='This error came from the "onStart" callback registered here:',A=dn(new Error(O),o,"onStart");c.push({name:h,callback:T,note:A}),P.onStart=!0},onEnd(T){let O='This error came from the "onEnd" callback registered here:',A=dn(new Error(O),o,"onEnd");u.push({name:h,callback:T,note:A}),P.onEnd=!0},onResolve(T,O){let A='This error came from the "onResolve" callback registered here:',L=dn(new Error(A),o,"onResolve"),F={},D=y(T,F,"filter",xn),$=y(T,F,"namespace",H);if(Ae(T,F,in onResolve() call for plugin ${Oe(h)}),D==null)throw new Error("onResolve() call is missing a filter");let G=E++;p[G]={name:h,callback:O,note:L},P.onResolve.push({id:G,filter:D.source,namespace:$||""})},onLoad(T,O){let A='This error came from the "onLoad" callback registered here:',L=dn(new Error(A),o,"onLoad"),F={},D=y(T,F,"filter",xn),$=y(T,F,"namespace",H);if(Ae(T,F,in onLoad() call for plugin ${Oe(h)}),D==null)throw new Error("onLoad() call is missing a filter");let G=E++;m[G]={name:h,callback:O,note:L},P.onLoad.push({id:G,filter:D.source,namespace:$||""})},onDispose(T){f.push(T)},esbuild:o.esbuild});x&&await x,C.push(P)}catch(N){return{ok:!1,error:N,pluginName:h}}}i["on-start"]=async(w,b)=>{let h={errors:[],warnings:[]};await Promise.all(c.map(async({name:N,callback:P,note:M})=>{try{let x=await P();if(x!=null){if(typeof x!="object")throw new Error(Expected onStart() callback in plugin ${Oe(N)} to return an object);let T={},O=y(x,T,"errors",ye),A=y(x,T,"warnings",ye);Ae(x,T,from onStart() callback in plugin ${Oe(N)}),O!=null&&h.errors.push(...xt(O,"errors",l,N,void 0)),A!=null&&h.warnings.push(...xt(A,"warnings",l,N,void 0))}}catch(x){h.errors.push(jt(x,o,l,M&&M(),N))}})),r(w,h)},i["on-resolve"]=async(w,b)=>{let h={},N="",P,M;for(let x of b.ids)try{({name:N,callback:P,note:M}=p[x]);let T=await P({path:b.path,importer:b.importer,namespace:b.namespace,resolveDir:b.resolveDir,kind:b.kind,pluginData:l.load(b.pluginData),with:b.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onResolve() callback in plugin ${Oe(N)} to return an object);let O={},A=y(T,O,"pluginName",H),L=y(T,O,"path",H),F=y(T,O,"namespace",H),D=y(T,O,"suffix",H),$=y(T,O,"external",de),G=y(T,O,"sideEffects",de),B=y(T,O,"pluginData",hn),d=y(T,O,"errors",ye),q=y(T,O,"warnings",ye),J=y(T,O,"watchFiles",ye),g=y(T,O,"watchDirs",ye);Ae(T,O,from onResolve() callback in plugin ${Oe(N)}),h.id=x,A!=null&&(h.pluginName=A),L!=null&&(h.path=L),F!=null&&(h.namespace=F),D!=null&&(h.suffix=D),$!=null&&(h.external=$),G!=null&&(h.sideEffects=G),B!=null&&(h.pluginData=l.store(B)),d!=null&&(h.errors=xt(d,"errors",l,N,void 0)),q!=null&&(h.warnings=xt(q,"warnings",l,N,void 0)),J!=null&&(h.watchFiles=gn(J,"watchFiles")),g!=null&&(h.watchDirs=gn(g,"watchDirs"));break}}catch(T){h={id:x,errors:[jt(T,o,l,M&&M(),N)]};break}r(w,h)},i["on-load"]=async(w,b)=>{let h={},N="",P,M;for(let x of b.ids)try{({name:N,callback:P,note:M}=m[x]);let T=await P({path:b.path,namespace:b.namespace,suffix:b.suffix,pluginData:l.load(b.pluginData),with:b.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onLoad() callback in plugin ${Oe(N)} to return an object);let O={},A=y(T,O,"pluginName",H),L=y(T,O,"contents",Tl),F=y(T,O,"resolveDir",H),D=y(T,O,"pluginData",hn),$=y(T,O,"loader",H),G=y(T,O,"errors",ye),B=y(T,O,"warnings",ye),d=y(T,O,"watchFiles",ye),q=y(T,O,"watchDirs",ye);Ae(T,O,from onLoad() callback in plugin ${Oe(N)}),h.id=x,A!=null&&(h.pluginName=A),L instanceof Uint8Array?h.contents=L:L!=null&&(h.contents=Xe(L)),F!=null&&(h.resolveDir=F),D!=null&&(h.pluginData=l.store(D)),$!=null&&(h.loader=$),G!=null&&(h.errors=xt(G,"errors",l,N,void 0)),B!=null&&(h.warnings=xt(B,"warnings",l,N,void 0)),d!=null&&(h.watchFiles=gn(d,"watchFiles")),q!=null&&(h.watchDirs=gn(q,"watchDirs"));break}}catch(T){h={id:x,errors:[jt(T,o,l,M&&M(),N)]};break}r(w,h)};let W=(w,b)=>b([],[]);u.length>0&&(W=(w,b)=>{(async()=>{let h=[],N=[];for(let{name:P,callback:M,note:x}of u){let T,O;try{let A=await M(w);if(A!=null){if(typeof A!="object")throw new Error(Expected onEnd() callback in plugin ${Oe(P)} to return an object);let L={},F=y(A,L,"errors",ye),D=y(A,L,"warnings",ye);Ae(A,L,from onEnd() callback in plugin ${Oe(P)}),F!=null&&(T=xt(F,"errors",l,P,void 0)),D!=null&&(O=xt(D,"warnings",l,P,void 0))}}catch(A){T=[jt(A,o,l,x&&x(),P)]}if(T){h.push(...T);try{w.errors.push(...T)}catch{}}if(O){N.push(...O);try{w.warnings.push(...O)}catch{}}}b(h,N)})()});let R=()=>{for(let w of f)setTimeout(()=>w(),0)};return _=!0,{ok:!0,requestPlugins:C,runOnEndCallbacks:W,scheduleOnDisposeCallbacks:R}};function Sl(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let n=t++;return e.set(n,r),n}}}function dn(e,t,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let i=(e.stack+"").split( );i.splice(1,1);let s=Cl(t,i,r);if(s)return n={text:e.message,location:s},n}catch{}}}function jt(e,t,r,n,o){let i="Internal error",s=null;try{i=(e&&e.message||e)+""}catch{}try{s=Cl(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:o,text:i,location:s,notes:n?[n]:[],detail:r?r.store(e):-1}}function Cl(e,t,r){let n=" at ";if(e.readFileSync&&!t[0].startsWith(n)&&t[1].startsWith(n))for(let o=1;o<t.length;o++){let i=t[o];if(i.startsWith(n))for(i=i.slice(n.length);;){let s=/^(?:new |async )?\S+ \((.*)\)$/.exec(i);if(s){i=s[1];continue}if(s=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(i),s){i=s[1];continue}if(s=/^(\S+):(\d+):(\d+)$/.exec(i),s){let a;try{a=e.readFileSync(s[1],"utf8")}catch{break}let l=a.split(/\r\n|\r|\n|\u2028|\u2029/)[+s[2]-1]||"",c=+s[3]-1,u=l.slice(c,c+r.length)===r?r.length:0;return{file:s[1],namespace:"file",line:+s[2],column:Xe(l.slice(0,c)).length,length:Xe(l.slice(c,c+u)).length,lineText:l+
+t.slice(1).join(
),suggestion:""}}break}}return null}function Or(e,t,r){let n=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,n+1).map((i,s)=>{if(s===n)return
...;if(!i.location)return
${a}:${l}:${c}: ERROR: ${u}${i.text}}).join("");let o=new Error(e);for(let[i,s]of[["errors",t],["warnings",r]])Object.defineProperty(o,i,{configurable:!0,enumerable:!0,get:()=>s,set:a=>Object.defineProperty(o,i,{configurable:!0,enumerable:!0,value:a})});return o}function lr(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function bl(e,t,r){if(e==null)return null;let n={},o=y(e,n,"file",H),i=y(e,n,"namespace",H),s=y(e,n,"line",Bt),a=y(e,n,"column",Bt),l=y(e,n,"length",Bt),c=y(e,n,"lineText",H),u=y(e,n,"suggestion",H);if(Ae(e,n,t),c){let p=c.slice(0,(a&&a>0?a:0)+(l&&l>0?l:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(p)&&!/\n/.test(c)&&(c=p)}return{file:o||"",namespace:i||"",line:s||0,column:a||0,length:l||0,lineText:c||"",suggestion:u||""}}function xt(e,t,r,n,o){let i=[],s=0;for(let a of e){let l={},c=y(a,l,"id",H),u=y(a,l,"pluginName",H),p=y(a,l,"text",H),m=y(a,l,"location",Rl),f=y(a,l,"notes",ye),E=y(a,l,"detail",hn),S=in element ${s} of "${t}";Ae(a,l,S);let C=[];if(f)for(let _ of f){let W={},R=y(_,W,"text",H),w=y(_,W,"location",Rl);Ae(_,W,S),C.push({text:R||"",location:bl(w,S,o)})}i.push({id:c||"",pluginName:u||n,text:p||"",location:bl(m,S,o),notes:C,detail:r?r.store(E):-1}),s++}return i}function gn(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(${Oe(t)} must be an array of strings);r.push(n)}return r}function $g(e,t){let r=Object.create(null);for(let n in e){let o=e[n];if(typeof o!="string")throw new Error(key ${Oe(n)} in object ${Oe(t)} must be a string);r[n]=o}return r}function jg({path:e,contents:t,hash:r}){let n=null;return{path:e,contents:t,hash:r,get text(){let o=this.contents;return(n===null||o!==t)&&(t=o,n=ar(o)),n}}}var Ll=Tr,Rn=e=>bn().build(e),vl=(e,t)=>bn().transform(e,t),Fl=(e,t)=>bn().formatMessages(e,t),Ml=(e,t)=>bn().analyzeMetafile(e,t);var Ht,Pl,En,bn=()=>{if(En)return En;throw Ht?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},wn=e=>{e=Ol(e||{});let t=e.wasmModule,r=e.workerURL;if(!t)throw new Error('Must provide the "wasmModule" option');if(Ht)throw new Error('Cannot call "initialize" more than once');return Ht=Hg(t,r),Ht.catch(()=>{Ht=void 0}),Ht},Hg=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),n,o,i=new Promise((l,c)=>{n=l,o=c});r.onmessage=({data:l})=>{r.onmessage=({data:c})=>s(c),l?o(l):n()},r.postMessage(e);let{readFromStdout:s,service:a}=Nl({writeToStdin(l){r.postMessage(l)},isSync:!1,hasFS:!1,esbuild:{build:Rn,transform:vl,formatMessages:Fl,analyzeMetafile:Ml,version:Ll,initialize:wn}});await i,Pl=()=>{r.terminate(),Ht=void 0,Pl=void 0,En=void 0},En={build:l=>new Promise((c,u)=>a.buildOrContext({callName:"build",refs:null,options:l,isTTY:!1,defaultWD:"/",callback:(p,m)=>p?u(p):c(m)})),transform:(l,c)=>new Promise((u,p)=>a.transform({callName:"transform",refs:null,input:l,options:c||{},isTTY:!1,fs:{readFile(m,f){f(new Error("Internal error"),null)},writeFile(m,f){f(null)}},callback:(m,f)=>m?p(m):u(f)})),formatMessages:(l,c)=>new Promise((u,p)=>a.formatMessages({callName:"formatMessages",refs:null,messages:l,options:c,callback:(m,f)=>m?p(m):u(f)})),analyzeMetafile:(l,c)=>new Promise((u,p)=>a.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof l=="string"?l:JSON.stringify(l),options:c,callback:(m,f)=>m?p(m):u(f)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function je(e){if(typeof e!="string")throw new TypeError(Path must be a string. Received ${JSON.stringify(e)})}function it(e){return e===47||e===92}function yt(e){return e>=97&&e<=122||e>=65&&e<=90}function On(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError("Must be a file URL.");return e}function Ul(e){e=On(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}function Co(e){je(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return it(r)?!0:!!(yt(r)&&t>2&&e.charCodeAt(1)===58&&it(e.charCodeAt(2)))}var An=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function _n(e,t=""){if(!e)throw new An(t)}var th={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Nn(e){return e.replaceAll(/[\s]/g,t=>th[t]??t)}function $l(e){if(!Co(e))throw new TypeError("Must be an absolute path.");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Nn(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError("Invalid hostname.");return n}function Et(e){return e===47}function Bl(e){return e=On(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Lo(e){return je(e),e.length>0&&Et(e.charCodeAt(0))}function Wl(e){if(!Lo(e))throw new TypeError("Must be an absolute path.");let t=new URL("file:///");return t.pathname=Nn(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}var mh=(()=>{let{Deno:e}=globalThis;if(typeof e?.build?.os=="string")return e.build.os;let{navigator:t}=globalThis;return t?.appVersion?.includes?.("Win")?"windows":"linux"})(),we=mh==="windows";var cr=we?"\\":"/";function Sn(e){return we?Ul(e):Bl(e)}function _r(e){return we?$l(e):Wl(e)}function Cn(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Pn(e){let t={},r=Object.keys(e).sort((n,o)=>o.length-n.length);for(let n of r)t[n]=e[n];return t}function Vl(e){return Cn(e)&&(e.imports!==void 0?vo(e.imports):!0)&&(e.scopes!==void 0?Fo(e.scopes):!0)}function vo(e){return Cn(e)}function Fo(e){return Cn(e)&&Object.values(e).every(t=>Mo(t))}function Mo(e){return Cn(e)}function Ln(e){try{return new URL(e),!0}catch{return!1}}function zl(e,t){let r={};for(let[n,o]of Object.entries(e)){let i=gh(n,t);if(i===null)continue;if(typeof o!="string"){console.warn("addresses need to be strings."),r[i]=null;continue}let s=Uo(o,t);if(s===null){console.warn("the address was invalid."),r[i]=null;continue}if(n.endsWith("/")&&!st(s).endsWith("/")){console.warn("an invalid address was given for the specifier key specifierKey; since specifierKey ended in a slash, the address needs to as well."),r[i]=null;continue}r[i]=st(s)}return Pn(r)}function st(e){return e.href}function dh(e,t){let r={};for(let[o,i]of Object.entries(e)){if(!Mo(i))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let s;try{s=new URL(o,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let a=st(s);r[a]=zl(i,t)}let n={};for(let o of Object.keys(r))n[o]=Pn(r[o]);return Pn(n)}function gh(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=Uo(e,t);return r!==null?st(r):e}function Uo(e,t){if(t&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")))try{return new URL(e,t)}catch{return null}try{return new URL(e)}catch{return null}}var hh=["ftp","file","http","https","ws","wss"];function xh(e){return hh.some(t=>st(e).startsWith(t))}function Gl(e,t,r){for(let[n,o]of Object.entries(r))if(n===e){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Ln(o))throw new TypeError("resolutionResult must be an URL.");return o}else if(n.endsWith("/")&&e.startsWith(n)&&(t===null||xh(t))){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Ln(o))throw new TypeError("resolutionResult must be an URL.");let i=e.slice(n.length);if(!o.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let s=new URL(i,o);if(!Ln(s))throw new TypeError("url must be an URL.");if(!st(s).startsWith(o))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return st(s)}catch{throw new TypeError("resolution of normalizedSpecifier was blocked since the afterPrefix portion could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.")}}return null}function Io(e,t){let r={};if(!Vl(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:n,scopes:o}=e;if(n!==void 0){if(!vo(n))throw new TypeError('"imports" top-level key needs to be an object.');r=zl(n,t)}let i={};if(o!==void 0){if(!Fo(o))throw new TypeError('"scopes" top-level key needs to be an object.');i=dh(o,t)}return Object.keys(e).find(s=>s!=="imports"&&s!=="scopes")&&console.warn("an invalid top-level key was present in the import map."),{imports:r,scopes:i}}function ql(e,{imports:t={},scopes:r={}},n){let o=st(n),i=Uo(e,n),s=i!==null?st(i):e;for(let[l,c]of Object.entries(r))if(l===o||l.endsWith("/")&&o.startsWith(l)){let u=Gl(s,i,c);if(u!==null)return u}let a=Gl(s,i,t);if(a!==null)return a;if(i!==null)return st(i);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}function Jl(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new Do(e,{allowTrailingComma:t}).parse()}var Kl=globalThis.JSON.parse,Do=class{#s=new Set( \r
);#n=new Set([..."[]{}:,/",...this.#s]);#t;#e;#i;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#i=this.#f(),this.#a=r}parse(){let t=this.#o(),r=this.#u(t),{done:n,value:o}=this.#i.next();if(!n)throw new SyntaxError(At(o));return r}#o(){let{done:t,value:r}=this.#i.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#f(){for(let t=0;t<this.#e;t++)if(!this.#s.has(this.#t[t])){if(this.#t[t]==="/"&&this.#t[t+1]==="*"){t+=2;let r=!1;for(;t<this.#e;t++)if(this.#t[t]==="*"&&this.#t[t+1]==="/"){r=!0;break}if(!r)throw new SyntaxError("Unexpected end of JSONC input");t++;continue}if(this.#t[t]==="/"&&this.#t[t+1]==="/"){for(t+=2;t<this.#e&&!(this.#t[t]===
||this.#t[t]==="\r");t++);continue}switch(this.#t[t]){case"{":yield{type:"BeginObject",position:t};break;case"}":yield{type:"EndObject",position:t};break;case"[":yield{type:"BeginArray",position:t};break;case"]":yield{type:"EndArray",position:t};break;case":":yield{type:"NameSeparator",position:t};break;case",":yield{type:"ValueSeparator",position:t};break;case'"':{let r=t,n=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!n);t++)n=this.#t[t]==="\\"&&!n;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#n.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#u(t){switch(t.type){case"BeginObject":return this.#m();case"BeginArray":return this.#r();case"NullOrTrueOrFalseOrNumber":return this.#h(t);case"String":return this.#g(t);default:throw new SyntaxError(At(t))}}#m(){let t={};for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndObject")return t;if(n.type!=="String")throw new SyntaxError(At(n));let o=this.#g(n),i=this.#o();if(i.type!=="NameSeparator")throw new SyntaxError(At(i));let s=this.#o();Object.defineProperty(t,o,{value:this.#u(s),writable:!0,enumerable:!0,configurable:!0});let a=this.#o();if(a.type==="EndObject")return t;if(a.type!=="ValueSeparator")throw new SyntaxError(At(a))}}#r(){let t=[];for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndArray")return t;t.push(this.#u(n));let o=this.#o();if(o.type==="EndArray")return t;if(o.type!=="ValueSeparator")throw new SyntaxError(At(o))}}#g(t){let r;try{r=Kl(t.sourceText)}catch{throw new SyntaxError(At(t))}return _n(typeof r=="string"),r}#h(t){if(t.sourceText==="null")return null;if(t.sourceText==="true")return!0;if(t.sourceText==="false")return!1;let r;try{r=Kl(t.sourceText)}catch{throw new SyntaxError(At(t))}return _n(typeof r=="number"),r}};function At({type:e,sourceText:t,position:r}){let n="";switch(e){case"BeginObject":n="{";break;case"EndObject":n="}";break;case"BeginArray":n="[";break;case"EndArray":n="]";break;case"NameSeparator":n=":";break;case"ValueSeparator":n=",";break;case"NullOrTrueOrFalseOrNumber":case"String":n=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${n} in JSONC at position ${r}}function Fn(e){if(e.protocol==="file:")return{path:Sn(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function $o(e){let t=await Deno.readTextFile(e),r=Jl(t);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(Deno config at ${e} must be an object);if("imports"in r&&(typeof r.imports!="object"||r.imports===null||Array.isArray(r.imports)))throw new Error(Deno config at ${e} has invalid "imports" key);if("scopes"in r&&(typeof r.scopes!="object"||r.scopes===null||Array.isArray(r.scopes)))throw new Error(Deno config at ${e} has invalid "scopes" key);if("lock"in r&&typeof r.lock!="boolean"&&typeof r.lock!="string")throw new Error(Deno config at ${e} has invalid "lock" key);if("importMap"in r&&typeof r.importMap!="string")throw new Error(Deno config at ${e} has invalid "importMap" key);return r}function Yl(e){if(e.imports!==void 0){let t=[];for(let[r,n]of Object.entries(e.imports))if(t.push([r,n]),!r.endsWith("/")&&n&&(n.startsWith("jsr:")||n.startsWith("npm:"))&&!e.imports[r+"/"]){let o=r+"/",i=n.slice(0,4)+"/"+n.slice(n[4]==="/"?5:4)+"/";t.push([o,i])}e.imports=Object.fromEntries(t)}}var Eh=${cr}node_modules${cr},Rh=${cr}node_modules;function vn(e){return e.includes(Eh)||e.endsWith(Rh)}function jo(e){return(e.namespace===""||e.namespace==="file")&&(vn(e.resolveDir)||vn(e.path)||vn(e.importer))}function Bo(e={}){return{name:"deno-resolver",setup(t){let r=null,n=(t.initialOptions.external??[]).map(o=>new RegExp("^"+o.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let i;if(e.importMapURL===void 0&&e.configPath!==void 0){let s=await $o(e.configPath);if(s.imports!==void 0||s.scopes!==void 0){let a={imports:s.imports,scopes:s.scopes};Yl(a),r=Io(a,_r(e.configPath))}else s.importMap!==void 0&&(i=new URL(s.importMap,_r(e.configPath)).href)}else e.importMapURL!==void 0&&(i=e.importMapURL);if(i){let s=await fetch(i),a=await s.json();r=Io(a,new URL(s.url))}}),t.onResolve({filter:/.*/},async function(i){if(jo(i))return;let s;if(i.importer!==""){if(i.namespace==="")throw new Error("[assert] namespace is empty");s=new URL(${i.namespace}:${i.importer})}else if(i.resolveDir!=="")s=new URL(${_r(i.resolveDir).href}/);else return;let a;if(r!==null){let p=ql(i.path,r,new URL(s));a=new URL(p)}else a=new URL(i.path,s);for(let p of n)if(p.test(a.href))return{path:a.href,external:!0};let{path:l,namespace:c}=Fn(a);return await t.resolve(l,{namespace:c,kind:i.kind})})}}}var J4=new TextEncoder;var bh=[],wh=[],Ho="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=Ho.length;e<t;++e)bh[e]=Ho[e],wh[Ho.charCodeAt(e)]=e;var hz=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var Ch=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var Ql=Bo;var Mn="null or undefined",ur=qt+Mn,Ph=ut+Mn,Wo=Kt+Mn,Un=Jt+Mn;function Ze(e){return e!=null}function Vo(e,t){if(Ze(e))return re(e);let r=t();return X(r)}var Xl=e=>!!(Lh.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),Lh=["i.gyazo.com","t.gyazo.com","scrapbox.io","api.openai.com","*.openai.azure.com","maps.googleapis.com","upload.gyazo.com","storage.googleapis.com","sentry.io"];function Nt(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function Wt(e){return e===47}function In(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError(URL must be a file URL: received "${e.protocol}");return e}function pr(e){return e=In(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Zl(e){e instanceof URL&&(e=pr(e)),Nt(e);let t=-1,r=0,n=-1,o=!0,i=0;for(let s=e.length-1;s>=0;--s){let a=e.charCodeAt(s);if(Wt(a)){if(!o){r=s+1;break}continue}n===-1&&(o=!1,n=s+1),a===46?t===-1?t=s:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||n===-1||i===0||i===1&&t===n-1&&t===r+1?"":e.slice(t,n)}function ec(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let n=t.length-1;n>=0;--n)if(e.charCodeAt(r+n)!==t.charCodeAt(n))return e;return e.slice(0,-t.length)}function tc(e,t,r=0){let n=!1,o=e.length;for(let i=e.length-1;i>=r;--i)if(t(e.charCodeAt(i))){if(n){r=i+1;break}}else n||(n=!0,o=i+1);return e.slice(r,o)}function rc(e,t){if(Nt(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function nc(e,t){if(e.length<=1)return e;let r=e.length;for(let n=e.length-1;n>0&&t(e.charCodeAt(n));n--)r=n;return e.slice(0,r)}function oc(e,t=""){e instanceof URL&&(e=pr(e)),rc(e,t);let r=tc(e,Wt),n=nc(r,Wt);return t?ec(n,t):n}function ic(){let e=globalThis,t=e.Deno?.build?.os;return typeof t=="string"?t==="windows":e.navigator?.platform?.startsWith("Win")??e.process?.platform?.startsWith("win")??!1}var Dn=ic();function sc(e){e=In(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}function ac(e){return Dn?sc(e):pr(e)}var Fh={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function $n(e){return e.replaceAll(/[\s]/g,t=>Fh[t]??t)}function lc(e){return Nt(e),e.length>0&&Wt(e.charCodeAt(0))}function cc(e){if(!lc(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=$n(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function zo(e){return e===47||e===92}function uc(e){return e>=97&&e<=122||e>=65&&e<=90}function pc(e){Nt(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return zo(r)?!0:!!(uc(r)&&t>2&&e.charCodeAt(1)===58&&zo(e.charCodeAt(2)))}function fc(e){if(!pc(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=$n(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError(Invalid hostname: "${n.hostname}");return n}function mc(e){return Dn?fc(e):cc(e)}var dc=e=>{if(e.protocol==="file:")return{path:ac(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},qo=e=>e.namespace==="file"?mc(e.path):new URL(${e.namespace}:${e.path});var gc=(e,t)=>{let r=Vo(Bh(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(ee(r))return r;let{url:n,start:o,end:i}=pe(r);return URL.canParse(n,t)?re({url:new URL(n,t),start:o,end:i}):X({name:"InvalidURLError",message:Invalid URL: ${n}})},Bh=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,n=e.length,o=r;for(;o<n&&e.charCodeAt(o)>32;)o++;if(o!==r&&(t[1]==="/"||e.indexOf("*/",o)>0))return{url:e.slice(r,o),start:r,end:o}}};var Hh=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],hc=e=>Hh.includes(e),xc=e=>/^js|^ts|css$/.test(e),yc=e=>{let t=e.url,r=oc(t);if(hc(r))return r;if(r==="mjs")return"js";let n=new URL(t);n.search="",n.hash="";let o=Zl(n.href).slice(1);if(hc(o))return o;if(o==="mjs")return"js";let s=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return Wh(s)},Wh=e=>{let t=e.split("/")[1]??"plain";if(/(?:^plain$|^xml|^svg|^x?html)/.test(t))return"text";if(t.startsWith("json"))return"json";switch(t){case"javascript":return"js";case"typescript":return"ts";case"css":return"css";default:return"text"}};function jn(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function bc(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Jo(e=[],t=[]){let r=Math.max(e.length,t.length);for(let n=0;n<r;n++){let o=e[n],i=t[n];if(o===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(o===void 0)return-1;if(typeof o=="string"&&typeof i=="number")return 1;if(typeof o=="number"&&typeof i=="string"||o<i)return-1;if(o>i)return 1}return 0}var fr="0|[1-9]\\d*",Vh="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Gh=(?<major>${fr})\\.(?<minor>${fr})\\.(?<patch>${fr}),Ec=(?:${fr}|${Vh}),wc=(?:-(?<prerelease>${Ec}(?:\\.${Ec})*)),Rc="[0-9A-Za-z-]+",kc=(?:\\+(?<buildmetadata>${Rc}(?:\\.${Rc})*)),Tc=v?${Gh}${wc}?${kc}?,Oc=new RegExp(^${Tc}$),Ac="(?:<|>)?=?",zh="x|X|\\*",Ko=${fr}|${zh},Bn=v=\\s*(?<major>${Ko})(?:\\.(?<minor>${Ko})(?:\\.(?<patch>${Ko})${wc}?${kc}?)?)?,_c=new RegExp(^(?<operator>~>?|\\^|${Ac})\\s*${Bn}$),Nc=new RegExp(^(?<operator>${Ac})\\s*(${Tc})$|^$);function Yo(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var Qo=256;var qh=new RegExp(^${fr}$);function Ke(e){return e.split(".").filter(Boolean).map(t=>{if(qh.test(t)){let r=Number(t);if(Yo(r))return r}return t})}function at(e){return e.split(".").filter(Boolean)}function St(e,t){let r=Number(e);if(!Yo(r))throw new TypeError(t);return r}function Vt(e){return Number.isNaN(e.major)&&Number.isNaN(e.minor)&&Number.isNaN(e.patch)&&(e.prerelease===void 0||e.prerelease.length===0)&&(e.build===void 0||e.build.length===0)}function Ye(e,t){return e===t?0:jn(e.major,t.major)||jn(e.minor,t.minor)||jn(e.patch,t.patch)||bc(e.prerelease,t.prerelease)||Jo(e.prerelease,t.prerelease)}function Xo(e){return e.toFixed(0)}function Gt(e){let t=Xo(e.major),r=Xo(e.minor),n=Xo(e.patch),o=e.prerelease?.join(".")??"",i=e.build?.join(".")??"";return[[${t}.${r}.${n},o].filter(l=>l).join("-"),i].filter(l=>l).join("+")}function Kh(e,t){if(Vt(t))return!0;let r=Ye(e,t);switch(t.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function Hn(e,t){for(let r of t)if(!Kh(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(Vt(r))continue;let{major:n,minor:o,patch:i,prerelease:s}=r;if(s&&s.length>0&&e.major===n&&e.minor===o&&e.patch===i)return!0}return!1}return!0}function Wn(e,t){return t.some(r=>Hn(e,r))}var Vn={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},mr={operator:void 0,...Vn};function Sc(e,t){return Ye(e,t)>0}function Nr(e,t){let r;for(let n of e)Wn(n,t)&&(r=r&&Sc(r,n)?r:n);return r}function Jh(e){let r=e.match(Nc)?.groups;if(!r)return null;let{operator:n,prerelease:o,buildmetadata:i}=r,s=r.major?{major:St(r.major,Cannot parse comparator ${e}: invalid major version),minor:St(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:St(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:o?Ke(o):[],build:i?at(i):[]}:Vn;return{operator:n||void 0,...s}}function ue(e){return!e||e.toLowerCase()==="x"||e==="*"}function Yh(e){if(!ue(e.major))return ue(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:ue(e.patch)?{operator:">=",major:+e.major,minor:+e.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?Ke(e.prerelease):[],build:[]}}function Qh(e){if(!ue(e.major))return ue(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:ue(e.patch)?{operator:"<",major:+e.major,minor:+e.minor+1,patch:0,prerelease:[],build:[]}:e.prerelease?{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:Ke(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:[],build:[]}}function Xh(e){let t=e.match(new RegExp(^${Bn})),r=t?.groups;if(!r)return null;let n=t[0].length,o=e.slice(n).match(/^\s+-\s+/);if(!o)return null;let i=o[0].length,a=e.slice(n+i).match(new RegExp(^${Bn}\\s*$))?.groups;if(!a)return null;let l=Yh(r),c=Qh(a);return[l,c].filter(Boolean)}function Zh(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[mr];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return o===0?[{operator:">=",major:o,minor:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}]:[{operator:">=",major:o,minor:i,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];let a=Ke(e.prerelease??"");return o===0?i===0?[{operator:">=",major:o,minor:i,patch:s,prerelease:a},{operator:"<",major:o,minor:i,patch:s+1}]:[{operator:">=",major:o,minor:i,patch:s,prerelease:a},{operator:"<",major:o,minor:i+1,patch:0}]:[{operator:">=",major:o,minor:i,patch:s,prerelease:a},{operator:"<",major:o+1,minor:0,patch:0}]}function ex(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[mr];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}];let a=Ke(e.prerelease??"");return[{operator:">=",major:o,minor:i,patch:s,prerelease:a},{operator:"<",major:o,minor:i+1,patch:0}]}function tx(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:o,minor:0,patch:0}]:[{operator:"<",major:o,minor:0,patch:0}];if(n)return[{operator:"<",major:o,minor:i,patch:0}];let a=Ke(e.prerelease??""),l=at(e.build??"");return[{operator:"<",major:o,minor:i,patch:s,prerelease:a,build:l}]}function rx(e){let t=ue(e.minor),r=ue(e.patch),n=+e.major,o=+e.minor,i=+e.patch;if(t)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:o+1,patch:0}];if(r)return[{operator:"<",major:n,minor:o+1,patch:0}];let s=Ke(e.prerelease??""),a=at(e.build??"");return[{operator:"<=",major:n,minor:o,patch:i,prerelease:s,build:a}]}function nx(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:i+1,patch:0}];let a=Ke(e.prerelease??""),l=at(e.build??"");return[{operator:">",major:o,minor:i,patch:s,prerelease:a,build:l}]}function ox(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[mr];if(r)return n?[{operator:">=",major:o,minor:0,patch:0}]:[{operator:">=",major:o,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:i,patch:0}];let a=Ke(e.prerelease??""),l=at(e.build??"");return[{operator:">=",major:o,minor:i,patch:s,prerelease:a,build:l}]}function ix(e){let t=ue(e.major),r=ue(e.minor),n=ue(e.patch),o=+e.major,i=+e.minor,s=+e.patch;if(t)return[mr];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}];let a=Ke(e.prerelease??""),l=at(e.build??"");return[{operator:void 0,major:o,minor:i,patch:s,prerelease:a,build:l}]}function sx(e){let t=e.match(_c)?.groups;if(!t)return Jh(e);switch(t.operator){case"^":return Zh(t);case"~":case"~>":return ex(t);case"<":return tx(t);case"<=":return rx(t);case">":return nx(t);case">=":return ox(t);case"=":case"":return ix(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function ax(e){return e.split(/\s+/).flatMap(sx)}function Cc(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>Xh(r)||ax(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Zo(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>Qo)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${Qo});e=e.trim();let t=e.match(Oc)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=St(t.major,Cannot parse version ${e}: invalid major version),n=St(t.minor,Cannot parse version ${e}: invalid minor version),o=St(t.patch,Cannot parse version ${e}: invalid patch version),i=t.prerelease?Ke(t.prerelease):[],s=t.buildmetadata?at(t.buildmetadata):[];return{major:r,minor:n,patch:o,prerelease:i,build:s}}function ei(e){try{return Cc(e)}catch{return}}function ti(e){try{return Zo(e)}catch{return}}var Sr={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var Ct=async e=>{try{let t=await fetch(e);return t.ok?re([t,!1]):X({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return X({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return X({name:"AbortError",message:t.message,request:e});throw t}};var ri="https://jsr.io",Pc=async(e,t)=>{let r=await(t?.fetch??Ct)(new Request(${t?.endpoint??ri}/${e}/meta.json),t?.cacheFirst);return qe(r,([n])=>n.json())};var Lc=async(e,t,r)=>{let n=await(r?.fetch??Ct)(new Request(${r?.endpoint??ri}/${e}/${t}_meta.json),r?.cacheFirst);return qe(n,([o])=>o.json())};var vc=async(e,t)=>{let r=await(t?.fetch??Ct)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return qe(r,([n])=>n.json())};var Uc=(e,t)=>({name:"InvalidPackageVersionError",message:No version of ${e.name} satisfies "${e.tag??"*"}" (available: ${t.slice(0,10).join(", ")}${t.length>10?, ... (${t.length-10} more versions):""}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableVersions:t}),Gn=(e,t)=>({name:"InvalidEntryPointError",message:${e.entryPoint} is not a valid entry point for ${e.name}@${e.tag??"*"} (available: ${t.join(", ")}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableEntryPoints:t}),Ic=async(e,t)=>{if(t?.resolvedVersions){let l=new Map(t.resolvedVersions.get(e.name)??[]),c=Nr([...l.keys()],e.range);if(c){let u=l.get(c)??Cr,p=u[e.entryPoint];return typeof p!="string"&&console.log(p),p?re(Fc(e.name,Gt(c),p)):X(Gn(e,Object.keys(u)))}}let r=await vc(e.name,t);if(ee(r))return r;let n=pe(r),o=new Map(Object.entries(n.versions).flatMap(([l,{exports:c}])=>{let u=ti(l);return u?[[u,c??Cr]]:[]})),i=Nr([...o.keys()],e.range);if(!i)return X(Uc(e,Object.keys(n.versions)));let s={...Cr};for(let l of Object.keys(o.get(i)??Cr))s[l]=l;let a=s[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[i,s]]),re(Fc(e.name,Gt(i),a))):X(Gn(e,Object.keys(s)))},Fc=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),Dc=async(e,t)=>{if(t?.resolvedVersions){let a=new Map(t.resolvedVersions.get(e.name)??[]),l=Nr([...a.keys()],e.range);if(l){let c=a.get(l)??Cr,u=c[e.entryPoint];return u?re(Mc(e.name,Gt(l),u)):X(Gn(e,Object.keys(c)))}}let r=await lx(e,t);if(ee(r))return r;let n=pe(r),o=await Lc(e.name,Gt(n),t);if(ee(o))return o;let i=pe(o).exports,s=i[e.entryPoint];return s?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[n,i]]),re(Mc(e.name,Gt(n),s))):X(Gn(e,Object.keys(pe(o).exports)))},Mc=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),lx=async(e,t)=>{let r=await Pc(e.name,t);if(ee(r))return r;let n=pe(r),o=Object.keys(n.versions).flatMap(s=>{let a=ti(s);return a?[a]:[]}),i=Nr(o,e.range);return i?re(i):X(Uc(e,Object.keys(n.versions)))},Cr={".":"./"};var cx=e=>({name:"OnlyScopeProvidedError",specifier:e}),$c=e=>({name:"PackageNotFoundError",specifier:e}),jc=e=>{if(e.protocol!=="npm:")return X({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,n,o;if(t[r]==="@"){let p=t.indexOf("/",r);if(p===-1)return X(cx(e));n=t.indexOf("/",p+1),o=t.indexOf("@",p+1)}else n=t.indexOf("/",r),o=t.indexOf("@",r);if(n===-1&&(n=t.length),o===-1&&(o=t.length),o=Math.min(o,n),r===o)return X($c(e));let i=t.slice(r,o),s=decodeURIComponent(t.slice(o+1,n)),a=s?ei(s)??[[Sr]]:[[Sr]],l=t.slice(n+1),c=l?./${l}:".",u={name:i,range:a,entryPoint:c};return s&&(u.tag=s),re(u)},Bc=e=>{if(e.protocol!=="jsr:")return X({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return X({name:"ScopeNotFoundError",specifier:e});let n=t.indexOf("/",r);if(n===-1)return X($c(e));let o=t.indexOf("/",n+1),i=t.indexOf("@",n+1);o===-1&&(o=t.length),i===-1&&(i=t.length),i=Math.min(i,o);let s=t.slice(r,i),a=decodeURIComponent(t.slice(i+1,o)),l=a?ei(a)??[[Sr]]:[[Sr]],c=t.slice(o+1),u=c?./${c}:".",p={name:s,range:l,entryPoint:u};return a&&(p.tag=a),re(p)};var Hc=e=>new Promise((t,r)=>{let n=new FileReader;n.addEventListener("load",()=>{let o=n.result,i=o.indexOf(";");o.startsWith("; charset=utf-8",i)?t(${o.slice(0,i)}${o.slice(i+15)}):t(o)}),n.addEventListener("error",()=>r(n.error)),n.readAsDataURL(e)});var Gc=e=>{let t=new Map,r=async n=>{let o=n.namespace==="npm",i=(o?jc:Bc)(qo(n));if(ee(i)){let a=Le(i);return{errors:[{text:a.name,detail:a}]}}let s=await(o?Ic:Dc)(pe(i),{resolvedVersions:t,...e});if(ee(s)){let a=Le(s);return{errors:[{text:${a.name} ${a.message},detail:a}]}}return dc(pe(s))};return{name:"remote-loader",setup({onLoad:n,onResolve:o,initialOptions:i}){for(let s of[...Wc,...Vc])o({filter:/.*/,namespace:s.slice(0,-1)},ux);o({filter:/.*/,namespace:"npm"},r),o({filter:/.*/,namespace:"jsr"},r);for(let s of Wc)n({filter:/.*/,namespace:s.slice(0,-1)},a=>px(qo(a),{...e,sourcemap:i.sourcemap!==!1&&i.sourcemap!==void 0}));for(let s of Vc)n({filter:/.*/,namespace:s.slice(0,-1)},()=>{throw new Error(${s} import is not supported yet.)})}}},ux=e=>({path:e.path,namespace:e.namespace}),Wc=["http:","https:","data:"],Vc=["node:"],px=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(c=>c.test(e)):!0,n=t.fetch??Ct,o=await n(new Request(e),r);if(ee(o))return{errors:[{text:${Le(o).message} Failed to fetch ${e},detail:Le(o)}]};let[i,s]=pe(o),a=yc(i);t.onProgress?.({path:e,done:i.clone().blob().then(c=>({size:c.size,loader:a,isCache:s}))});let l=await i.blob();if(t.sourcemap&&xc(a)){let c=await l.text(),u=gc(c,e);if(ke(u)){let{url:p,start:m,end:f}=pe(u);if(p.protocol!=="data:"){let E=await n(new Request(p),r);if(ee(E))return{contents:c,loader:a,warnings:[{text:${Le(E).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${p}},{text:Original URL: ${e}}],detail:Le(E)}]};let S=await pe(E)[0].blob().then(Hc);return{contents:c.slice(0,m)+S+c.slice(f),loader:a}}}}return{contents:new Uint8Array(await l.arrayBuffer()),loader:a}};var vr=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,n,o,i){this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=o,this.modifier=i}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},fx=/[$_\p{ID_Start}]/u,mx=/[$_\u200C\u200D\p{ID_Continue}]/u,oi=".*";function dx(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function Kc(e,t=!1){let r=[],n=0;for(;n<e.length;){let o=e[n],i=function(s){if(!t)throw new TypeError(s);r.push({type:"INVALID_CHAR",index:n,value:e[n++]})};if(o==="*"){r.push({type:"ASTERISK",index:n,value:e[n++]});continue}if(o==="+"||o==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:e[n++]});continue}if(o==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});continue}if(o==="{"){r.push({type:"OPEN",index:n,value:e[n++]});continue}if(o==="}"){r.push({type:"CLOSE",index:n,value:e[n++]});continue}if(o===":"){let s="",a=n+1;for(;a<e.length;){let l=e.substr(a,1);if(a===n+1&&fx.test(l)||a!==n+1&&mx.test(l)){s+=e[a++];continue}break}if(!s){i(Missing parameter name at ${n});continue}r.push({type:"NAME",index:n,value:s}),n=a;continue}if(o==="("){let s=1,a="",l=n+1,c=!1;if(e[l]==="?"){i(Pattern cannot start with "?" at ${l});continue}for(;l<e.length;){if(!dx(e[l],!1)){i(Invalid character '${el}' at ${l}.),c=!0;break}if(e[l]==="\\"){a+=e[l++]+e[l++];continue}if(e[l]===")"){if(s--,s===0){l++;break}}else if(e[l]==="("&&(s++,e[l+1]!=="?")){i(Capturing groups are not allowed at ${l}),c=!0;break}a+=e[l++]}if(c)continue;if(s){i(Unbalanced pattern at ${n});continue}if(!a){i(Missing pattern at ${n});continue}r.push({type:"REGEX",index:n,value:a}),n=l;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function Jc(e,t={}){let r=Kc(e);t.delimiter??="/#?",t.prefixes??="./";let n=^${Qe(t.delimiter)}+?,o=[],i=0,s=0,a="",l=new Set,c=R=>{if(s<r.length&&r[s].type===R)return r[s++].value},u=()=>c("OTHER_MODIFIER")??c("ASTERISK"),p=R=>{let w=c(R);if(w!==void 0)return w;let{type:b,index:h}=r[s];throw new TypeError(Unexpected ${b} at ${h}, expected ${R})},m=()=>{let R="",w;for(;w=c("CHAR")??c("ESCAPED_CHAR");)R+=w;return R},f=R=>R,E=t.encodePart||f,S="",C=R=>{S+=R},_=()=>{S.length&&(o.push(new vr(3,"","",E(S),"",3)),S="")},W=(R,w,b,h,N)=>{let P=3;switch(N){case"?":P=1;break;case"*":P=0;break;case"+":P=2;break}if(!w&&!b&&P===3){C(R);return}if(_(),!w&&!b){if(!R)return;o.push(new vr(3,"","",E(R),"",P));return}let M;b?b==="*"?M=oi:M=b:M=n;let x=2;M===n?(x=1,M=""):M===oi&&(x=0,M="");let T;if(w?T=w:b&&(T=i++),l.has(T))throw new TypeError(Duplicate name '${T}'.);l.add(T),o.push(new vr(x,T,E(R),M,E(h),P))};for(;s<r.length;){let R=c("CHAR"),w=c("NAME"),b=c("REGEX");if(!w&&!b&&(b=c("ASTERISK")),w||b){let N=R??"";t.prefixes.indexOf(N)===-1&&(C(N),N=""),_();let P=u();W(N,w,b,"",P);continue}let h=R??c("ESCAPED_CHAR");if(h){C(h);continue}if(c("OPEN")){let N=m(),P=c("NAME"),M=c("REGEX");!P&&!M&&(M=c("ASTERISK"));let x=m();p("CLOSE");let T=u();W(N,P,M,x,T);continue}_(),p("END")}return o}function Qe(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function zc(e){return e&&e.ignoreCase?"ui":"u"}function gx(e,t,r){return Yc(Jc(e,r),t,r)}function dr(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function Yc(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let a of e){if(a.type===3){a.modifier===3?n+=Qe(a.value):n+=(?:${Qe(a.value)})${dr(a.modifier)};continue}t&&t.push(a.name);let l=^${Qe(r.delimiter)}+?,c=a.value;if(a.type===1?c=l:a.type===0&&(c=oi),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?n+=(${c})${dr(a.modifier)}:n+=((?:${c})${dr(a.modifier)});continue}if(a.modifier===3||a.modifier===1){n+=(?:${Qe(a.prefix)}(${c})${Qe(a.suffix)}),n+=dr(a.modifier);continue}n+=(?:${Qe(a.prefix)},n+=((?:${c})(?:,n+=Qe(a.suffix),n+=Qe(a.prefix),n+=(?:${c}))*)${Qe(a.suffix)}),a.modifier===0&&(n+="?")}let o=${Qe(r.endsWith)}|$,i=${Qe(r.delimiter)};if(r.end)return r.strict||(n+=${i}?),r.endsWith.length?n+=(?=${o}):n+="$",new RegExp(n,zc(r));r.strict||(n+=(?:${i}(?=${o}))?);let s=!1;if(e.length){let a=e[e.length-1];a.type===3&&a.modifier===3&&(s=r.delimiter.indexOf(a)>-1)}return s||(n+=(?=${i}|${o})),new RegExp(n,zc(r))}var Lt={delimiter:"",prefixes:"",sensitive:!0,strict:!0},hx={delimiter:".",prefixes:"",sensitive:!0,strict:!0},xx={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function yx(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function Qc(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function Ex(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function Xc(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var Zc=["ftp","file","http","https","ws","wss"];function eu(e){if(!e)return!0;for(let t of Zc)if(e.test(t))return!0;return!1}function Rx(e,t){if(e=Qc(e,"#"),t||e==="")return e;let r=new URL("https://example.com");return r.hash=e,r.hash?r.hash.substring(1,r.hash.length):""}function bx(e,t){if(e=Qc(e,"?"),t||e==="")return e;let r=new URL("https://example.com");return r.search=e,r.search?r.search.substring(1,r.search.length):""}function wx(e,t){return t||e===""?e:Xc(e)?nu(e):ru(e)}function kx(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function Tx(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function Ox(e,t,r){if(r||e==="")return e;if(t&&!Zc.includes(t))return new URL(${t}:${e}).pathname;let n=e[0]=="/";return e=new URL(n?e:"/-"+e,"https://example.com").pathname,n||(e=e.substring(2,e.length)),e}function Ax(e,t,r){return tu(t)===e&&(e=""),r||e===""?e:ou(e)}function _x(e,t){return e=Ex(e,":"),t||e===""?e:ii(e)}function tu(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function ii(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function Nx(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function Sx(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function ru(e){if(e==="")return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw new TypeError(Invalid hostname '${e}');let t=new URL("https://example.com");return t.hostname=e,t.hostname}function nu(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function ou(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function Cx(e){if(e==="")return e;let t=new URL("https://example.com");return t.pathname=e[0]!=="/"?"/-"+e:e,e[0]!=="/"?t.pathname.substring(2,t.pathname.length):t.pathname}function Px(e){return e===""?e:new URL(data:${e}).pathname}function Lx(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function vx(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var Fx=class{#s;#n=[];#t={};#e=0;#i=1;#a=0;#o=0;#f=0;#u=0;#m=!1;constructor(e){this.#s=e}get result(){return this.#t}parse(){for(this.#n=Kc(this.#s,!0);this.#e<this.#n.length;this.#e+=this.#i){if(this.#i=1,this.#n[this.#e].type==="END"){if(this.#o===0){this.#h(),this.#p()?this.#r(9,1):this.#d()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#x(5);continue}this.#r(10,0);break}if(this.#f>0)if(this.#A())this.#f-=1;else continue;if(this.#O()){this.#f+=1;continue}switch(this.#o){case 0:this.#b()&&this.#x(1);break;case 1:if(this.#b()){this.#S();let e=7,t=1;this.#w()?(e=2,t=3):this.#m&&(e=2),this.#r(e,t)}break;case 2:this.#E()?this.#x(3):(this.#R()||this.#d()||this.#p())&&this.#x(5);break;case 3:this.#k()?this.#r(4,1):this.#E()&&this.#r(5,1);break;case 4:this.#E()&&this.#r(5,1);break;case 5:this.#_()?this.#u+=1:this.#N()&&(this.#u-=1),this.#T()&&!this.#u?this.#r(6,1):this.#R()?this.#r(7,0):this.#d()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 6:this.#R()?this.#r(7,0):this.#d()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 7:this.#d()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 8:this.#p()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#r(e,t){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#c();break;case 2:break;case 3:this.#t.username=this.#c();break;case 4:this.#t.password=this.#c();break;case 5:this.#t.hostname=this.#c();break;case 6:this.#t.port=this.#c();break;case 7:this.#t.pathname=this.#c();break;case 8:this.#t.search=this.#c();break;case 9:this.#t.hash=this.#c();break;case 10:break}this.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#m?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??="")),this.#g(e,t)}#g(e,t){this.#o=e,this.#a=this.#e+t,this.#e+=t,this.#i=0}#h(){this.#e=this.#a,this.#i=0}#x(e){this.#h(),this.#o=e}#y(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#l(e,t){let r=this.#y(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#b(){return this.#l(this.#e,":")}#w(){return this.#l(this.#e+1,"/")&&this.#l(this.#e+2,"/")}#E(){return this.#l(this.#e,"@")}#k(){return this.#l(this.#e,":")}#T(){return this.#l(this.#e,":")}#R(){return this.#l(this.#e,"/")}#d(){if(this.#l(this.#e,"?"))return!0;if(this.#n[this.#e].value!=="?")return!1;let e=this.#y(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#p(){return this.#l(this.#e,"#")}#O(){return this.#n[this.#e].type=="OPEN"}#A(){return this.#n[this.#e].type=="CLOSE"}#_(){return this.#l(this.#e,"[")}#N(){return this.#l(this.#e,"]")}#c(){let e=this.#n[this.#e],t=this.#y(this.#a).index;return this.#s.substring(t,e.index)}#S(){let e={};Object.assign(e,Lt),e.encodePart=ii;let t=gx(this.#c(),void 0,e);this.#m=eu(t)}},ni=["protocol","username","password","hostname","port","pathname","search","hash"],Pt="*";function qc(e,t){if(typeof e!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(e,t);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function bt(e,t){return t?Lr(e):e}function Pr(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=bt(n.protocol.substring(0,n.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=bt(n.username,r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=bt(n.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=bt(n.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=bt(n.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=bt(n.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=bt(n.search.substring(1,n.search.length),r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=bt(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=_x(t.protocol,r)),typeof t.username=="string"&&(e.username=Tx(t.username,r)),typeof t.password=="string"&&(e.password=kx(t.password,r)),typeof t.hostname=="string"&&(e.hostname=wx(t.hostname,r)),typeof t.port=="string"&&(e.port=Ax(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!yx(e.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(e.pathname=bt(n.pathname.substring(0,o+1),r)+e.pathname)}e.pathname=Ox(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=bx(t.search,r)),typeof t.hash=="string"&&(e.hash=Rx(t.hash,r)),e}function Lr(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function Mx(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function Ux(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",n=^${Mx(t.delimiter)}+?,o=/[$_\u200C\u200D\p{ID_Continue}]/u,i="";for(let s=0;s<e.length;++s){let a=e[s];if(a.type===3){if(a.modifier===3){i+=Lr(a.value);continue}i+={${Lr(a.value)}}${dr(a.modifier)};continue}let l=a.hasCustomName(),c=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!t.prefixes.includes(a.prefix)),u=s>0?e[s-1]:null,p=s<e.length-1?e[s+1]:null;if(!c&&l&&a.type===1&&a.modifier===3&&p&&!p.prefix.length&&!p.suffix.length)if(p.type===3){let m=p.value.length>0?p.value[0]:"";c=o.test(m)}else c=!p.hasCustomName();if(!c&&!a.prefix.length&&u&&u.type===3){let m=u.value[u.value.length-1];c=t.prefixes.includes(m)}c&&(i+="{"),i+=Lr(a.prefix),l&&(i+=:${a.name}),a.type===2?i+=(${a.value}):a.type===1?l||(i+=(${n})):a.type===0&&(!l&&(!u||u.type===3||u.modifier!==3||c||a.prefix!=="")?i+="*":i+=(${r})),a.type===1&&l&&a.suffix.length&&o.test(a.suffix[0])&&(i+="\\"),i+=Lr(a.suffix),c&&(i+="}"),a.modifier!==3&&(i+=dr(a.modifier))}return i}var iu=class{#s;#n={};#t={};#e={};#i={};#a=!1;constructor(e={},t,r){try{let n;if(typeof t=="string"?n=t:r=t,typeof e=="string"){let a=new Fx(e);if(a.parse(),e=a.result,n===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=n}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let o={ignoreCase:r.ignoreCase===!0},i={pathname:Pt,protocol:Pt,username:Pt,password:Pt,hostname:Pt,port:Pt,search:Pt,hash:Pt};this.#s=Pr(i,e,!0),tu(this.#s.protocol)===this.#s.port&&(this.#s.port="");let s;for(s of ni){if(!(s in this.#s))continue;let a={},l=this.#s[s];switch(this.#t[s]=[],s){case"protocol":Object.assign(a,Lt),a.encodePart=ii;break;case"username":Object.assign(a,Lt),a.encodePart=Nx;break;case"password":Object.assign(a,Lt),a.encodePart=Sx;break;case"hostname":Object.assign(a,hx),Xc(l)?a.encodePart=nu:a.encodePart=ru;break;case"port":Object.assign(a,Lt),a.encodePart=ou;break;case"pathname":eu(this.#n.protocol)?(Object.assign(a,xx,o),a.encodePart=Cx):(Object.assign(a,Lt,o),a.encodePart=Px);break;case"search":Object.assign(a,Lt,o),a.encodePart=Lx;break;case"hash":Object.assign(a,Lt,o),a.encodePart=vx;break}try{this.#i[s]=Jc(l,a),this.#n[s]=Yc(this.#i[s],this.#t[s],a),this.#e[s]=Ux(this.#i[s],a),this.#a=this.#a||this.#i[s].some(c=>c.type===2)}catch{throw new TypeError(invalid ${s} pattern '${this.#ss}'.)}}}catch(n){throw new TypeError(Failed to construct 'URLPattern': ${n.message})}}test(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return!1;try{typeof e=="object"?r=Pr(r,e,!1):r=Pr(r,qc(e,t),!1)}catch{return!1}let n;for(n of ni)if(!this.#n[n].exec(r[n]))return!1;return!0}exec(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return;try{typeof e=="object"?r=Pr(r,e,!1):r=Pr(r,qc(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let o;for(o of ni){let i=this.#n[o].exec(r[o]);if(!i)return null;let s={};for(let[a,l]of this.#t[o].entries())if(typeof l=="string"||typeof l=="number"){let c=i[a+1];s[l]=c}n[o]={input:r[o]??"",groups:s}}return n}static compareComponent(e,t,r){let n=(a,l)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(a[c]<l[c])return-1;if(a[c]!==l[c])return 1}return 0},o=new vr(3,"","","","",3),i=new vr(0,"","","","",3),s=(a,l)=>{let c=0;for(;c<Math.min(a.length,l.length);++c){let u=n(a[c],l[c]);if(u)return u}return a.length===l.length?0:n(a[c]??o,l[c]??o)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?s(t.#i[e],[i]):!t.#e[e]&&r.#e[e]?s([i],r.#i[e]):s(t.#i[e],r.#i[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#a}};globalThis.URLPattern||(globalThis.URLPattern=iu);var su,au=async(e,t)=>(su??=wn({wasmModule:e,workerURL:t}),await su,async r=>{let{outputFiles:n}=await Rn({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[Ql(),Gc({fetch:Ix,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:n[0].text}}),Ix=async(e,t)=>{let r=Xl(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let n=await si(e);if(n)return n}try{let n=await r(e);return n.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await Ir(e,n),re([n,!1])):await si(e)??X({name:"HTTPError",message:${n.status} ${n.statusText},response:n})}catch(n){let o=await si(e);if(o)return o;if(n instanceof TypeError)return X({name:"NetworkError",message:n.message,request:e});if(n instanceof DOMException)return X({name:"AbortError",message:n.message,request:e});throw n}},si=async e=>{if(e.url.startsWith("data:"))return;let t=await Ur(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),re([t,!0])};var lu=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var cu=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},uu=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},pu=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},fu=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var mu=()=>{let e;return{show:(n,{x:o,y:i})=>{e=Dx(),e.append($x(n)),e.style.visibility="hidden",document.body.append(e);let{height:s}=e.getBoundingClientRect();e.style.top=${i-s}px,e.style.left=${o}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(n=>setTimeout(n,150)),e?.remove?.()}}},Dx=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},$x=e=>{let t=document.createElement("pre");return t.classList.add("tooltip-inner"),t.style.textAlign="unset",t.style.maxWidth="70vw",t.style.margin="unset",t.innerText=e,t};var du=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:n}=mu();return{component:e,setStatus:async(i,s)=>{switch(e.textContent="",await n(),i){case"loading":e.append(pu());break;case"pass":e.append(cu());break;case"fail":e.append(uu());break;case"none":break}s!==void 0&&i!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await n();else{let{top:a,left:l}=e.getBoundingClientRect();r(s,{y:a+globalThis.scrollY,x:l})}t=!t}):e.style.pointerEvents="none"}}};var gu=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(fu()),t.addEventListener("click",e),t};var hu=e=>{let{component:t,setStatus:r}=du(),n=document.createElement("div");return n.style.position="absolute",n.style.left="-2em",n.style.zIndex="1",n.style.display="flex",n.style.flexFlow="column",n.append(gu(e),t),{menu:n,setStatus:r}};function xu(e){return new Promise(t=>setTimeout(t,e))}function yu(e,t){let{trailing:r=!1,interval:n=0}=t??{},o,i=!1,s=c=>{o?.resolve?.({executed:!1}),o=c},a=()=>{let{...c}=o;return o=void 0,c},l=async()=>{if(i||!o)return;i=!0,n>0&&await xu(n);let{parameters:c,resolve:u,reject:p}=a();try{let m=await e(...c);i=!1,u({result:m,executed:!0})}catch(m){i=!1,p(m)}finally{r?await l():(s(),await Promise.resolve())}};return(...c)=>new Promise((u,p)=>{s({parameters:c,resolve:u,reject:p}),l()})}var Eu,Ru=async(e,t)=>{let r=[],o=yu(async()=>{r.forEach(({menu:s,setStatus:a})=>{a("none"),s.remove()});let i=dl(scrapbox.Project.name,scrapbox.Page.title??"",Yn());for(let s of i){let a=s.lang.toLowerCase();if(lu(a))for(let l of s.startIds){let c=document.getElementById(L${l}),{menu:u,setStatus:p}=hu(async()=>{await p("loading");try{Eu??=await au(e,t);let{contents:m}=await Eu(s.path);console.debug("execute:",m),await Function(return (async()=>{${m}})())(),await p("pass")}catch(m){console.error(m),await p("fail",${m}`)}});r.push({menu:u,setStatus:p}),c?.insertBefore?.(u,c?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await o(),scrapbox.addListener("lines:changed",o),()=>{scrapbox.removeListener("lines:changed",o),r.forEach(({menu:i,setStatus:s})=>{s("none"),i.remove()})}};var jx="https://scrapbox.io/files/6730bb5886d646fa1d630a2a.wasm",Bx="https://scrapbox.io/api/code/yosider-scripts/esbuild-wasm-no-blob-min/worker.js";(async()=>{let e=new Request(jx),t=await Ur(e)||await Hx(e);await Ru(await WebAssembly.compileStreaming(t),Bx)})();async function Hx(e){let t=await fetch(e);return await Ir(e,t),t} /** @license
* esbuild-wasm@v0.21.5
*
* MIT License
*
* Copyright (c) 2020 Evan Wallace
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
code:script-pc.js
var mo=Object.defineProperty;var go=(e,t)=>()=>(e&&(t=e(e=0)),t);var ho=(e,t)=>{for(var r in t)mo(e,r,{get:tr,enumerable:!0})};var po={};ho(po,{execute:()=>va});async function va(e=[]){let t=[...new Set(...e)].filter(r=>r!==scrapbox.Project.name);scrapbox.PageMenu.addMenu({title:uo,image:"https://gyazo.com/54226f0588bb63aa3ff505fad0af824a/raw",onClick:async()=>{let r=scrapbox.PageMenu(uo);r.removeAllItems(),r.emitChange(),!(await Promise.all(t.map(o=>Ea(o,r)))).some(o=>o)&&r.addItem({title:"No page found.",onClick:()=>{}})}})}async function Ea(e,t){let r=await fetch(/api/pages/${e}/${scrapbox.Page.title});if(!r.ok)return!1;let{lines:n}=await r.json();return n.length<3&&!n1?.text?!1:(t.addItem({title:/${e}/${scrapbox.Page.title},onClick:()=>window.open(https://scrapbox.io/${e}/${scrapbox.Page.title})}),!0)}var uo,fo=go(()=>{uo="OtherProjects"});var Ce=(e,t)=>Object.hasOwn(e,t),At={left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",bs:"Backspace",menu:"ContextMenu",apps:"ContextMenu",del:"Delete",return:"Enter",cr:"Enter",esc:"Escape",pgup:"PageUp",pgdn:"PageDown",lt:"<",less:"<",lesser:"<",gt:">",greater:">"},qt=e=>{let t=e.toLowerCase();return Ce(At,t)?Att:e},Ft={Backquote:["","~"],Digit1:["1","!"],Digit2:["2","@"],Digit3:["3","#"],Digit4:["4","$"],Digit5:["5","%"],Digit6:["6","^"],Digit7:["7","&"],Digit8:["8","*"],Digit9:["9","("],Digit0:["0",")"],Minus:["-","_"],Equal:["=","+"],Backslash:["\\","|"],BracketLeft:["[","{"],BracketRight:["]","}"],Semicolon:[";",":"],Quote:["'",'"'],Comma:[",","<"],Period:[".",">"],Slash:["/","?"]},bo=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return Ce(Ft,e)?Ft[e][t?1:0]:e},Ut={"<":"lt",">":"gt"},xo=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,ut=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=bo(e.code||"",t):(r=qt(r),r===" "&&(r="Space")),xo.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let n="";return e.altKey&&(n+="a-"),e.ctrlKey&&(n+="c-"),e.metaKey&&(n+="m-"),t&&(n+="s-"),Ce(Ut,r)&&(r=Ut[r]),n||r.length>1?<${n}${r}>:r},Kt={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},yo=e=>{if(e.length===1)return/\s/.test(e)?{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}}:{ok:!0,value:{key:e}};let t=e.match(/^<((?:[a-z]-)*)([a-z\d]+|[^<>\s])>$/i);if(!t)return{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}};let[,r,n]=t,o={key:qt(n)};for(let s of r.split("-").slice(0,-1)){let a=s.toLowerCase();if(!Ce(Kt,a))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let l=Kt[a];if(o[l]!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(o[l]=!0,o.key.length===1&&o.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:o}},zt=e=>{let t=yo(e);return t.ok?{ok:!0,value:ut(t.value)}:t},Gt=e=>e.match(/<[^<>\s]+>|[\s\S]|^$/g);var A=!1;var Wt=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{A!==!0&&(!A||!A.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{A!==!0&&(!A||!A.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{A!==!0&&(!A||!A.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(A!==!0&&(!A||!A.has(e))))return r(...n)}]}}));var Q=Wt("ScrapBindings:mod.ts"),Ne=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let n=new Map,o=[];for(let[s,a]of t instanceof Map?t.entries():typeof t=="string"?[[t,r]]:Object.entries(t)){let l=Xt(s);if(!l.ok){for(let u of l.value)Q.error(${s}: ${u.message});n.set(s,l.value);continue}let i=l.value;this.bindings.set(i,a),i.startsWith(this.currentSequence)&&this.filtered.add(i),o.push(i)}return Q.debug("Binded the following commands:",o),this.emitChange(),n}unbind(...t){for(let r of t){let n=Xt(r);if(!n.ok)continue;let o=n.value;this.bindings.delete(o),this.filtered.delete(o)}this.emitChange()}reset(){this.bindings.clear(),this.emitChange()}bindings=new Map;onSequenceUpdate;flushInterval;_sequence="";set currentSequence(t){let r=this._sequence!==t;this._sequence=t,r&&this.onSequenceUpdate?.(t)}get currentSequence(){return this._sequence}prevBestMatchCommand;filtered=new Set;timer;backToInitial=()=>{clearTimeout(this.timer),this.currentSequence="",this.prevBestMatchCommand=void 0,this.filtered=new Set(this.bindings.keys()),Q.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=ut(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,Q.debug("sequence",this.currentSequence);let n;for(let s of this.filtered){if(s.startsWith(this.currentSequence)||this.filtered.delete(s),this.currentSequence!==s)continue;let a=this.bindings.get(s);if(!a){this.filtered.delete(s);continue}n=()=>{Q.debug(run ${s});try{a(t)}catch(l){Q.error(l)}finally{this.backToInitial()}}}let o=this.filtered.size;if(Q.debug(${o} candidates: ${...this.filtered.keys().join(", ")}),o>0&&(this.prevBestMatchCommand=n),this.prevBestMatchCommand&&o<2){if(this.prevBestMatchCommand(),o===0){this.handleKeydown(t);return}return}if(o===0){this.backToInitial();return}t.preventDefault(),t.stopPropagation(),this.timer=setTimeout(this.prevBestMatchCommand??this.backToInitial,this.flushInterval)};emitChange=()=>{if(this.bindings.size===0){this.backToInitial(),this.target.removeEventListener("keydown",this.handleKeydown);return}this.target.addEventListener("keydown",this.handleKeydown)}},vo={name:"InvalidSequenceError",message:"cannot parse the sequence"},Xt=e=>{let t=Gt(e);if(!t)return{ok:!1,value:[vo]};let r="",n=[];for(let o of t){let s=zt(o);if(!s.ok){n.push(s.value);continue}r+=s.value}return n.length>0?{ok:!1,value:n}:{ok:!0,value:r}};var Yt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Vt=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var H=()=>{let e=document.getElementById("text-input");if(e)return Vt(e,"textarea#text-input"),e};var Qt=()=>Zt(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Jt=()=>Zt(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),Zt=(e,t)=>{if(e)return Yt(e,t),e};var K=(e,t)=>{let{noModifiedKeys:r=!1,...n}=t??{},o={bubbles:!0,cancelable:!0,keyCode:_o[e],...r?{}:{...n}},s=H();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",o)),s.dispatchEvent(new KeyboardEvent("keyup",o))},_o={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 vc=2**31-1;var ge=e=>{let t=H();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});return t.dispatchEvent(r),scrapbox.Page.waitForSave()};var tr=()=>{let e=Jt();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 n=rr(...r);n&&t.append(n)},dispose:()=>t.remove(),Symbol.dispose:()=>t.remove()}},rr=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnPo();case"check-circle":returnCo();case"exclamation-triangle":returnNo();case"text":returnSe(n.text);case"group":{let o=rr(...n.items);return o?o:[]}}});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},Se=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Po=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Se(e)},Co=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Se(e)},No=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Se(e)};var dt=()=>{let e=H();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,n=r.find(s=>s.constructor.name==="Cursor");if(!n)throw Error('#text-input must has a "Cursor" store.');let o=r.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:n,selection:o}};var nr=()=>dt().cursor;var he=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),or=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var Ie=new Map,pt=new Map,ft=()=>{scrapbox.on("layout:changed",()=>{let e=H();if(e)for(lett,rof Ie)for(letn,oof r)for(let s of o)e.addEventListener(t,n,or(s))}),ft=void 0},Re=(e,t,r)=>{ft?.();let n=Ie.get(e)??new Map,o=n.get(t)??new Set;if(o.has(he(r)))return;if(o.add(he(r)),n.set(t,o),Ie.set(e,n),typeof r=="object"&&r?.once){let a=pt.get(t)??new Map,l=he(r),i=function(c){return mt(e,t,r),a.delete(l),t.call(this,c)};a.set(l,i),pt.set(t,a);let u=H();if(!u)return;u.addEventListener(e,i,r)}let s=H();s&&s.addEventListener(e,t,r)},mt=(e,t,r)=>{ft?.();let n=Ie.get(e);if(!n)return;let o=n.get(t);if(!o)return;let s=he(r);if(o.delete(s),typeof r=="object"&&r?.once){let l=pt.get(t);if(!l)return;let i=l.get(s);if(!i)return;let u=H();if(!u)return;u.removeEventListener(e,i,r),l.delete(s);return}let a=H();a&&a.removeEventListener(e,t,r)};Re("keydown",async e=>{e.key!=="Enter"||e.metaKey||e.altKey||!e.ctrlKey||e.shiftKey||await gt()});async function gt(){if(scrapbox.Layout!=="page")return;let e=nr(),t=e.getPosition().line,r=scrapbox.Page.linest;!("codeBlock"in r)||r.codeBlock.start||r.codeBlock.end||(K("End"),K("Enter"),e.setPosition({line:e.getPosition().line,char:r.codeBlock.indent-1}),K("End",{shiftKey:!0}),await ge(code:${r.codeBlock.filename??""}),K("Home"),K("Enter"),K("ArrowUp"))}var Oe=e=>e.preventDefault(),He=e=>e.stopPropagation(),Be=(e,t)=>{let r=Qt()?.getElementsByClassName?.("button");if(!r)return;let n=...r.find(o=>t instanceof RegExp?t.test(o.textContent??""):o.textContent===t);n instanceof HTMLDivElement&&e.target===document.activeElement&&(Oe(e),He(e),n.click())},sr={u:e=>Be(e,"URL"),う:e=>Be(e,"URL"),4:e=>Be(e,"$"),l:e=>Be(e,"link authors"),"<A-q>":e=>{Oe(e),He(e),ge("todo.icon")},"<A-w>":e=>{Oe(e),He(e),ge("done.icon")},"<C-Enter>":e=>{Oe(e),He(e),gt()}};var{render:So}=tr(),ht,Io=e=>{ht!==void 0&&cancelAnimationFrame(ht),ht=requestAnimationFrame(()=>So({type:"text",text:e}))},ar=new Ne({addEventListener:Re,removeEventListener:mt},{onSequenceUpdate:Io}),ir=ar.bind(sr);ir.size>0&&alert(...ir.entries().map((e,t)=>`${e}: ${t.map(r=>- ${r}).join(`
)}).join(`
));var Ue,h,pr,Ro,be,fr,cr,mr,je={},gr=[],Bo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function G(e,t){for(var r in t)e[r]=t[r];return e}function hr(e){var t=e.parentNode;t&&t.removeChild(e)}function d(e,t,r){var n,o,s,a={};for(s in t)s=="key"?n=t[s]:s=="ref"?o=t[s]:a[s]=t[s];if(arguments.length>2&&(a.children=arguments.length>3?Ue.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)a[s]===void 0&&(a[s]=e.defaultProps[s]);return De(e,a,n,o,null)}function De(e,t,r,n,o){var s={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:o??++pr};return o==null&&h.vnode!=null&&h.vnode(s),s}function L(e){return e.children}function $e(e,t){this.props=e,this.context=t}function re(e,t){if(t==null)return e.__?re(e.__,e.__.__k.indexOf(e)+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?re(e):null}function br(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return br(e)}}function bt(e){(!e.__d&&(e.__d=!0)&&be.push(e)&&!Ae.__r++||cr!==h.debounceRendering)&&((cr=h.debounceRendering)||fr)(Ae)}function Ae(){for(var e;Ae.__r=be.length;)e=be.sort(function(t,r){return t.__v.__b-r.__v.__b}),be=[],e.some(function(t){var r,n,o,s,a,l;t.__d&&(a=(s=(r=t).__v).__e,(l=r.__P)&&(n=[],(o=G({},s)).__v=s.__v+1,xt(l,s,o,r.__n,l.ownerSVGElement!==void 0,s.__h!=null?[a]:null,n,a??re(s),s.__h),Er(n,s),s.__e!=a&&br(s)))})}function xr(e,t,r,n,o,s,a,l,i,u){var c,m,g,p,f,b,x,w=n&&n.__k||gr,I=w.length;for(r.__k=[],c=0;c<t.length;c++)if((p=r.__k[c]=(p=t[c])==null||typeof p=="boolean"?null:typeof p=="string"||typeof p=="number"||typeof p=="bigint"?De(null,p,null,null,p):Array.isArray(p)?De(L,{children:p},null,null,null):p.__b>0?De(p.type,p.props,p.key,null,p.__v):p)!=null){if(p.__=r,p.__b=r.__b+1,(g=w[c])===null||g&&p.key==g.key&&p.type===g.type)w[c]=void 0;else for(m=0;m<I;m++){if((g=w[m])&&p.key==g.key&&p.type===g.type){w[m]=void 0;break}g=null}xt(e,p,g=g||je,o,s,a,l,i,u),f=p.__e,(m=p.ref)&&g.ref!=m&&(x||(x=[]),g.ref&&x.push(g.ref,null,p),x.push(m,p.__c||f,p)),f!=null?(b==null&&(b=f),typeof p.type=="function"&&p.__k===g.__k?p.__d=i=yr(p,i,e):i=vr(e,p,g,w,f,i),typeof r.type=="function"&&(r.__d=i)):i&&g.__e==i&&i.parentNode!=e&&(i=re(g))}for(r.__e=b,c=I;c--;)w[c]!=null&&(typeof r.type=="function"&&w[c].__e!=null&&w[c].__e==r.__d&&(r.__d=re(n,c+1)),kr(w[c],w[c]));if(x)for(c=0;c<x.length;c++)wr(x[c],x[++c],x[++c])}function yr(e,t,r){for(var n,o=e.__k,s=0;o&&s<o.length;s++)(n=o[s])&&(n.__=e,t=typeof n.type=="function"?yr(n,t,r):vr(r,n,n,o,n.__e,t));return t}function vr(e,t,r,n,o,s){var a,l,i;if(t.__d!==void 0)a=t.__d,t.__d=void 0;else if(r==null||o!=s||o.parentNode==null)e:if(s==null||s.parentNode!==e)e.appendChild(o),a=null;else{for(l=s,i=0;(l=l.nextSibling)&&i<n.length;i+=2)if(l==o)break e;e.insertBefore(o,s),a=s}return a!==void 0?a:o.nextSibling}function Oo(e,t,r,n,o){var s;for(s in r)s==="children"||s==="key"||s in t||Fe(e,s,null,r[s],n);for(s in t)o&&typeof t[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||r[s]===t[s]||Fe(e,s,t[s],r[s],n)}function lr(e,t,r){t[0]==="-"?e.setProperty(t,r):e[t]=r==null?"":typeof r!="number"||Bo.test(t)?r:r+"px"}function Fe(e,t,r,n,o){var s;e:if(t==="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||lr(e.style,t,"");if(r)for(t in r)n&&r[t]===n[t]||lr(e.style,t,r[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?n||e.addEventListener(t,s?dr:ur,s):e.removeEventListener(t,s?dr:ur,s);else if(t!=="dangerouslySetInnerHTML"){if(o)t=t.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if(t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r!=null&&(r!==!1||t[0]==="a"&&t[1]==="r")?e.setAttribute(t,r):e.removeAttribute(t))}}function ur(e){this.l[e.type+!1](h.event?h.event(e):e)}function dr(e){this.l[e.type+!0](h.event?h.event(e):e)}function xt(e,t,r,n,o,s,a,l,i){var u,c,m,g,p,f,b,x,w,I,te,U=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(i=r.__h,l=t.__e=r.__e,t.__h=null,s=[l]),(u=h.__b)&&u(t);try{e:if(typeof U=="function"){if(x=t.props,w=(u=U.contextType)&&n[u.__c],I=u?w?w.props.value:u.__:n,r.__c?b=(c=t.__c=r.__c).__=c.__E:("prototype"in U&&U.prototype.render?t.__c=c=new U(x,I):(t.__c=c=new $e(x,I),c.constructor=U,c.render=Do),w&&w.sub(c),c.props=x,c.state||(c.state={}),c.context=I,c.__n=n,m=c.__d=!0,c.__h=[]),c.__s==null&&(c.__s=c.state),U.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=G({},c.__s)),G(c.__s,U.getDerivedStateFromProps(x,c.__s))),g=c.props,p=c.state,m)U.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(U.getDerivedStateFromProps==null&&x!==g&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(x,I),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(x,c.__s,I)===!1||t.__v===r.__v){c.props=x,c.state=c.__s,t.__v!==r.__v&&(c.__d=!1),c.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(Pe){Pe&&(Pe.__=t)}),c.__h.length&&a.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(x,c.__s,I),c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(g,p,f)})}c.context=I,c.props=x,c.state=c.__s,(u=h.__r)&&u(t),c.__d=!1,c.__v=t,c.__P=e,u=c.render(c.props,c.state,c.context),c.state=c.__s,c.getChildContext!=null&&(n=G(G({},n),c.getChildContext())),m||c.getSnapshotBeforeUpdate==null||(f=c.getSnapshotBeforeUpdate(g,p)),te=u!=null&&u.type===L&&u.key==null?u.props.children:u,xr(e,Array.isArray(te)?te:[te],t,r,n,o,s,a,l,i),c.base=t.__e,t.__h=null,c.__h.length&&a.push(c),b&&(c.__E=c.__=null),c.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=Ho(r.__e,t,r,n,o,s,a,i);(u=h.diffed)&&u(t)}catch(Pe){t.__v=null,(i||s!=null)&&(t.__e=l,t.__h=!!i,s[s.indexOf(l)]=null),h.__e(Pe,t,r)}}function Er(e,t){h.__c&&h.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(n){n.call(r)})}catch(n){h.__e(n,r.__v)}})}function Ho(e,t,r,n,o,s,a,l){var i,u,c,m=r.props,g=t.props,p=t.type,f=0;if(p==="svg"&&(o=!0),s!=null){for(;f<s.length;f++)if((i=s[f])&&"setAttribute"in i==!!p&&(p?i.localName===p:i.nodeType===3)){e=i,s[f]=null;break}}if(e==null){if(p===null)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",p):document.createElement(p,g.is&&g),s=null,l=!1}if(p===null)m===g||l&&e.data===g||(e.data=g);else{if(s=s&&Ue.call(e.childNodes),u=(m=r.props||je).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,!l){if(s!=null)for(m={},f=0;f<e.attributes.length;f++)m[e.attributes[f].name]=e.attributes[f].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}if(Oo(e,g,m,o,l),c)t.__k=[];else if(f=t.props.children,xr(e,Array.isArray(f)?f:[f],t,r,n,o&&p!=="foreignObject",s,a,s?s[0]:r.__k&&re(r,0),l),s!=null)for(f=s.length;f--;)s[f]!=null&&hr(s[f]);l||("value"in g&&(f=g.value)!==void 0&&(f!==m.value||f!==e.value||p==="progress"&&!f)&&Fe(e,"value",f,m.value,!1),"checked"in g&&(f=g.checked)!==void 0&&f!==e.checked&&Fe(e,"checked",f,m.checked,!1))}return e}function wr(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(n){h.__e(n,r)}}function kr(e,t,r){var n,o;if(h.unmount&&h.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||wr(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){h.__e(s,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&kr(n[o],t,typeof e.type!="function");r||e.__e==null||hr(e.__e),e.__e=e.__d=void 0}function Do(e,t,r){return this.constructor(e,r)}function Ke(e,t,r){var n,o,s;h.__&&h.__(e,t),o=(n=typeof r=="function")?null:r&&r.__k||t.__k,s=[],xt(t,e=(!n&&r||t).__k=d(L,null,[e]),o||je,je,t.ownerSVGElement!==void 0,!n&&r?[r]:o?null:t.firstChild?Ue.call(t.childNodes):null,s,!n&&r?r:o?o.__e:t.firstChild,n),Er(s,e)}function yt(e,t){var r={__c:t="__cC"+mr++,__:e,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,s;return this.getChildContext||(o=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&o.some(bt)},this.sub=function(a){o.push(a);var l=a.componentWillUnmount;a.componentWillUnmount=function(){o.splice(o.indexOf(a),1),l&&l.call(a)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}Ue=gr.slice,h={__e:function(e,t){for(var r,n,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&n.getDerivedStateFromError!=null&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e),o=r.__d),o)return r.__E=r}catch(s){e=s}throw e}},pr=0,Ro=function(e){return e!=null&&e.constructor===void 0},$e.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=G({},this.state),typeof e=="function"&&(e=e(G({},r),this.props)),e&&G(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),bt(this))},$e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),bt(this))},$e.prototype.render=L,be=[],fr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ae.__r=0,mr=0;var ne,R,Lr,xe=0,vt=[],_r=h.__b,Tr=h.__r,Mr=h.diffed,Pr=h.__c,Cr=h.unmount;function ye(e,t){h.__h&&h.__h(R,e,xe||t),xe=0;var r=R.__H||(R.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function M(e){return xe=1,$o(Sr,e)}function $o(e,t,r){var n=ye(ne++,2);return n.t=e,n.__c||(n.__=[r?r(t):Sr(void 0,t),function(o){var s=n.t(n.__[0],o);n.__[0]!==s&&(n.__=[s,n.__[1]],n.__c.setState({}))}],n.__c=R),n.__}function D(e,t){var r=ye(ne++,3);!h.__s&&wt(r.__H,t)&&(r.__=e,r.__H=t,R.__H.__h.push(r))}function ze(e,t){var r=ye(ne++,4);!h.__s&&wt(r.__H,t)&&(r.__=e,r.__H=t,R.__h.push(r))}function oe(e){return xe=5,E(function(){return{current:e}},[])}function E(e,t){var r=ye(ne++,7);return wt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function O(e,t){return xe=8,E(function(){return e},t)}function W(e){var t=R.context[e.__c],r=ye(ne++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(R)),t.props.value):e.__}function jo(){var e;for(vt.sort(function(t,r){return t.__v.__b-r.__v.__b});e=vt.pop();)if(e.__P)try{e.__H.__h.forEach(qe),e.__H.__h.forEach(Et),e.__H.__h=[]}catch(t){e.__H.__h=[],h.__e(t,e.__v)}}h.__b=function(e){R=null,_r&&_r(e)},h.__r=function(e){Tr&&Tr(e),ne=0;var t=(R=e.__c).__H;t&&(t.__h.forEach(qe),t.__h.forEach(Et),t.__h=[])},h.diffed=function(e){Mr&&Mr(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(vt.push(t)!==1&&Lr===h.requestAnimationFrame||((Lr=h.requestAnimationFrame)||function(r){var n,o=function(){clearTimeout(s),Nr&&cancelAnimationFrame(n),setTimeout(r)},s=setTimeout(o,100);Nr&&(n=requestAnimationFrame(o))})(jo)),R=null},h.__c=function(e,t){t.some(function(r){try{r.__h.forEach(qe),r.__h=r.__h.filter(function(n){return!n.__||Et(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],h.__e(n,r.__v)}}),Pr&&Pr(e,t)},h.unmount=function(e){Cr&&Cr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{qe(n)}catch(o){t=o}}),t&&h.__e(t,r.__v))};var Nr=typeof requestAnimationFrame=="function";function qe(e){var t=R,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),R=t}function Et(e){var t=R;e.__c=e.__(),R=t}function wt(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Sr(e,t){return typeof t=="function"?t(e):t}var k=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Fo=e=>typeof e=="object"&&e!==null,Uo=e=>Fo(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Ir=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Uo(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var ve=class e extends Error{constructor(r){super(${r.status} ${r.statusText} when fetching ${r.url});this.response=r;Error.captureStackTrace&&Error.captureStackTrace(this,e)}name="UnexpectedResponseError"},T=async e=>{let t=e.clone(),r=await t.text(),n=Ir(r);if(!n)throw new ve(t);return{ok:!1,value:n}};var _=e=>connect.sid=${e};var B=e=>e.replaceAll(" ","_").toLowerCase();var P=e=>[...e].map((t,r)=>t===" "?"_":!Ko.includes(t)||r===e.length-1&&qo.includes(t)?encodeURIComponent(t):t).join(""),Ko='@$&+=:;",',qo=':;",';var Rr=(e,t,r)=>{let{sid:n,hostName:o,followRename:s,projects:a}=k(r??{}),l=new URLSearchParams;l.append("followRename",${s??!0});for(let u of a??[])l.append("projects",u);let i=https://${o}/api/pages/${e}/${P(t)}?${l.toString()};return new Request(i,n?{headers:{Cookie:_(n)}}:void 0)},Br=async e=>e.ok?{ok:!0,value:await e.json()}:e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:T(e),se=async(e,t,r)=>{let{fetch:n}=k(r??{}),o=Rr(e,t,r),s=await n(o);return await Br(s)};se.toRequest=Rr;se.fromResponse=Br;var Or=(e,t)=>{let{sid:r,hostName:n,sort:o,limit:s,skip:a}=k(t??{}),l=new URLSearchParams;o!==void 0&&l.append("sort",o),s!==void 0&&l.append("limit",${s}),a!==void 0&&l.append("skip",${a});let i=https://${n}/api/pages/${e}?${l.toString()};return new Request(i,r?{headers:{Cookie:_(r)}}:void 0)},Hr=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),Dr=async(e,t)=>{let{fetch:r}=k(t??{}),n=await r(Or(e,t));return await Hr(n)};Dr.toRequest=Or;Dr.fromResponse=Hr;var $r=(e,t,r,n)=>{let{sid:o,hostName:s}=k(n??{}),a=https://${s}/api/table/${e}/${P(t)}/${encodeURIComponent(r)}.csv;return new Request(a,o?{headers:{Cookie:_(o)}}:void 0)},jr=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:T(e),Ar=async(e,t,r,n)=>{let{fetch:o}=k(n??{}),s=$r(e,t,r,n),a=await o(s);return await jr(a)};Ar.toRequest=$r;Ar.fromResponse=jr;var Fr=(e,t)=>{let{sid:r,hostName:n}=k(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:_(r)}}:void 0)},Ur=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),Ee=async(e,t)=>{let{fetch:r}=k(t??{}),n=Fr(e,t),o=await r(n);return Ur(o)};Ee.toRequest=Fr;Ee.fromResponse=Ur;var Kr=(e,t)=>{let{sid:r,hostName:n}=k(t??{}),o=new URLSearchParams;for(let s of e)o.append("ids",s);return new Request(https://${n}/api/projects?${o.toString()},r?{headers:{Cookie:_(r)}}:void 0)},qr=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),Ge=async(e,t)=>{let{fetch:r}=k(t??{}),n=await r(Kr(e,t));return qr(n)};Ge.toRequest=Kr;Ge.fromResponse=qr;var zr=(e,t,r,n)=>{let{sid:o,hostName:s}=k(n??{}),a=https://${s}/api/code/${e}/${P(t)}/${P(r)};return new Request(a,o?{headers:{Cookie:_(o)}}:void 0)},Gr=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"}}:T(e),Wr=async(e,t,r,n)=>{let{fetch:o}=k(n??{}),s=zr(e,t,r,n),a=await o(s);return await Gr(a)};Wr.toRequest=zr;Wr.fromResponse=Gr;var op=new TextEncoder().encode("0123456789abcdef");var J=e=>new Promise(t=>setTimeout(()=>t(),e));var Wo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Xo=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,Yo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,Vo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Xr=e=>{if(Wo.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(Xo);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"dotbe"}}}{let t=e.match(Yo);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"short"}}}{let t=e.match(Vo);if(t){let[,r,n]=t;return{listId:n,params:new URLSearchParams(r),pathType:"list"}}}};var Qo=/https?:\/\/vimeo\.com\/([0-9]+)/i,Yr=e=>{let t=e.match(Qo);if(t)return t[1]};var Jo=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Vr=e=>{let t=e.match(Jo);if(!t)return;let[,r,n]=t;return{videoId:n,pathType:r}};var Zo=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Qr=e=>{let t=e.match(Zo);if(!t)return;let[,r]=t;return r};var Jr=e=>{let{type:t,pathType:r,content:n,href:o,...s}=e;if(n===""){let a=Xr(o);if(a)return{type:"youtube",href:o,...a,...s};let l=Yr(o);if(l)return{type:"vimeo",videoId:l,href:o,...s};let i=Vr(o);if(i)return{type:"spotify",href:o,...i,...s};let u=Qr(o);if(u)return{type:"anchor-fm",videoId:u,href:o,...s};if(ts(o))return{type:"video",href:o,...s}}return es(o)?{type:"audio",content:n,href:o,...s}:{type:"absoluteLink",content:n,href:o,...s}},es=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),ts=e=>/\.(?:mp4|webm)$/.test(e);var Zr=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,a])=>a-s).map(([s])=>s),n=await Ge([]);if(!n.ok)return r;let o=n.value.projects.map(s=>s.id);return r.filter(s=>!o.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var rs;(e=>{})(rs||={});var ns="0.13.3",en,tn=async(e=ns)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(document.querySelector(scriptsrc="${t}"))return window.katex!==void 0?Promise.resolve(window.katex):await new Promise(n=>{let o=setInterval(()=>{window.katex!==void 0&&(clearInterval(o),n(window.katex))},500)});let r=document.createElement("script");return r.src=t,en??=new Promise((n,o)=>{r.onload=()=>n(window.katex),r.onerror=s=>o(s),document.head.append(r)}),en};var we=(e,t={})=>{let r=oe(null),[n,o]=M(e),[s,a]=M("");return D(()=>{(async()=>{let{render:l}=await tn();if(r.current)try{l(n,r.current,t),a("")}catch(i){if(i instanceof Error&&i.name==="ParseError")a(i.message.slice(19));else throw i}})()},[n]),{ref:r,error:s,setFormula:o}};var rn=!1;scrapbox.addListener("lines:changed",()=>rn=!1);scrapbox.addListener("layout:changed",()=>rn=!1);var nn=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var ie=()=>{let e=document.getElementById("text-input");if(e)return nn(e,"textarea#text-input"),e};var kt=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_${B(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var sn=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(e,t);if(s)return s}};var an=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var ds=new Map;scrapbox.on("layout:changed",()=>{let e=ie();if(e)for(let[t,r]of ds)for(let[n,o]of r)for(let s of o)e.addEventListener(t,n,an(s))});var ps=e=>({type:"title",text:e.rows[0].text}),fs=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(n+1)).join( )}},C=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,s,a)=>{var l,i,u,c,m,g;if(!t&&s.nested)return(l=a?.())!==null&&l!==void 0?l:[];if(!r&&s.quoted)return(i=a?.())!==null&&i!==void 0?i:[];for(let p of n){let f=p.exec(o);if(f===null)continue;let b=o.substring(0,f.index),x=o.substring(f.index+((c=(u=f[0])===null||u===void 0?void 0:u.length)!==null&&c!==void 0?c:0)),w=e((m=f[0])!==null&&m!==void 0?m:"",s);return[...X(b,s),...w,...X(x,s)]}return(g=a?.())!==null&&g!==void 0?g:[]},S=e=>[{type:"plain",raw:e,text:e}],ms=C(S,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),gs=/^>.*$/,hs=(e,t)=>t.context==="table"?S(e,t):[{type:"quote",raw:e,nodes:X(e.substring(1),{...t,quoted:!0})}],bs=C(hs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[gs]}),xs=/^\? .+$/,ys=(e,t)=>t.context==="table"?S(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],vs=C(ys,{parseOnNested:!1,parseOnQuoted:!1,patterns:[xs]}),Es=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,ws=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,ks=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},Ls=C(ks,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Es,ws]}),_s=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function ln(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return S(t,r);let n=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),o=n.lastIndexOf(".icon"),s=n.substring(0,o),a=s.startsWith("/")?"root":"relative",l=n.substring(o+5,n.length),i=l.startsWith("*")?parseInt(l.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Ts=ln("icon"),Ms=C(Ts,{parseOnNested:!0,parseOnQuoted:!0,patterns:[_s]}),Ps=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Cs=ln("strongIcon"),Ns=C(Cs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ps]}),Ss=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Is=(e,t)=>t.context==="table"?S(e,t):[{type:"strong",raw:e,nodes:X(e.substring(2,e.length-2),{...t,nested:!0})}],Rs=C(Is,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ss]}),Bs=/\[\$ .+? \]/,Os=/\[\$ [^\]]+\]/,Hs=(e,t)=>t.context==="table"?S(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Ds=C(Hs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Bs,Os]}),$s=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,js=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),s=new Set(n);if(s.has("*")){let a=n.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(s),nodes:X(o,{...t,nested:!0})}]},As=C(js,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$s]}),Fs=/.*?/,Us=(e,t)=>t.context==="table"?S(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Ks=C(Us,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Fs]}),qs=/^[$%] .+$/,zs=(e,t)=>{var r;if(t.context==="table")return S(e,t);let n=(r=e[0])!==null&&r!==void 0?r:"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:n,text:o}]},Gs=C(zs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[qs]}),Ws=/\[\s+\]/,Xs=(e,t)=>t.context==="table"?S(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Ys=C(Xs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ws]}),Vs=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Qs=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Js=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,Zs=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,ei=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||ti(e),ti=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),ri=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).trimLeft():"",[s,a]=ei(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},ni=C(ri,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Vs,Qs,Js,Zs]}),oi=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,si=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,ii=/\[https?:\/\/[^\s\]]+\]/,ai=/https?:\/\/[^\s]+/,ci=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let s=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},li=C(ci,{parseOnNested:!0,parseOnQuoted:!0,patterns:[oi,si,ii,ai]}),un=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,dn=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,ui=e=>{let[t="",r="",n=""]=e.split(","),o=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(n)?parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:a}},di=(e,t)=>{var r;if(t.context==="table")return S(e,t);let n=(r=e.match(un))!==null&&r!==void 0?r:e.match(dn);if(n===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=o?n:[n[0],n[2],n[1]],{latitude:l,longitude:i,zoom:u}=ui(s),c=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${l},${i},${u}z:https://www.google.com/maps/@${l},${i},${u}z;return[{type:"googleMap",raw:e,latitude:l,longitude:i,zoom:u,place:a,url:c}]},pi=C(di,{parseOnNested:!1,parseOnQuoted:!0,patterns:[un,dn]}),fi=/\[\/?[^[\]]+\]/,mi=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},gi=C(mi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[fi]}),hi=/(?:^|\s)#\S+/,bi=(e,t)=>{if(t.context==="table")return S(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...S(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},xi=C(bi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[hi]}),yi=/^[0-9]+\. .*$/,vi=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=parseInt(n,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:X(s,{...t,nested:!0})}]},Ei=C(vi,{parseOnNested:!1,parseOnQuoted:!1,patterns:[yi]}),wi=(e,t,r)=>{var n;return e===""?[]:(n=r?.())!==null&&n!==void 0?n:[]},ki=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>ms(t,r))(),X=ki(wi,bs,vs,Ks,Gs,Ds,Ys,As,Ls,Ns,Rs,ni,li,Ms,pi,gi,xi,Ei),Li=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:s,cells:r.map(a=>a.text.substring(n+1)).map(a=>a.split(" ").map(l=>X(l,{nested:!1,quoted:!1,context:"table"})))}},_i=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:X(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},Ti=e=>{switch(e.type){case"title":return ps(e);case"codeBlock":return fs(e);case"table":return Li(e);case"line":return _i(e)}},Mi=e=>e.split( ).map(t=>{var r,n,o;return{indent:(o=(n=(r=/^\s+/.exec(t))===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.length)!==null&&o!==void 0?o:0,text:t}}),Pi=(e,t)=>{var r,n;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((n=(r=e.rows[0])===null||r===void 0?void 0:r.indent)!==null&&n!==void 0?n:0)},cn=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Pi(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)},Ci=(e,t)=>{var r;if(!((r=t.hasTitle)!==null&&r!==void 0)||r){let[n,...o]=e;return n===void 0?[]:[{type:"title",rows:[n]},...o.reduce(cn,[])]}return e.reduce(cn,[])},ke=(e,t)=>{var r;let n=Mi(e);return Ci(n,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(Ti)};var pn=e=>{let t=[],r=new Set,n=o=>{r.delete(o);let s=t.pop();if(!s)return;let a=s[0]().finally(()=>n(a)).then(l=>s[1](l)).catch(l=>s[2](l));r.add(a)};return o=>{if(r.size<e){let s=o().finally(()=>n(s));return r.add(s),s}return new Promise((s,a)=>{t.push([o,s,a])})}};var Ni="0.6.5",gn=ScrapBubble-${Ni},fn=await globalThis.caches.open(gn);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==gn&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var mn=pn(3);async function*Xe(e,t){let r=((t?.saveFailedResponse?fn.match(e):void 0)??sn(e,t)).then(a=>["cache",a]);{let a=J(1e3).then(()=>"timeout"),l=await Promise.race([r,a]);if(l!=="timeout"){l[1]&&(yield["cache",l[1]]);let i=await mn(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await fn.put(e,i.clone()),yield["network",i]}}let n=mn(()=>fetch(e)).then(a=>["network",a]),[o,s]=await Promise.race([r,n]);if(o==="network"){yield[o,s];return}s&&(yield[o,s]),yield await n}var hn=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Ye=()=>{let e=new Map;return{dispatch:(t,r)=>{let n=e.get(t);if(n)for(let o of n)o(r)},on:(t,r)=>{let n=e.get(t)??new Set;n.add(r),e.set(t,n)},off:(t,r)=>{let n=e.get(t);n&&n.delete(r)}}};var $=!1,bn=e=>{$=typeof e=="boolean"?e:new Set(e)},Y=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{$!==!0&&(!$||!$.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{$!==!0&&(!$||!$.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{$!==!0&&(!$||!$.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!($!==!0&&(!$||!$.has(e))))return r(...n)}]}}));var Lt=Ye(),Ve=new Map,Si=Y("ScrapBubble:useProject.ts"),xn=e=>{let[t,r]=M();return D(()=>{Lt.on(e,r);let n=Ve.get(e);return n?r(n.loading?void 0:n.value):(Ve.set(e,{loading:!0}),r(void 0),(async()=>{try{let o=Ee.toRequest(e);for await(let[,s]of Xe(o)){let a=await Ee.fromResponse(s);Ve.set(e,{loading:!1,value:a}),Lt.dispatch(e,a);break}}catch(o){Si.error(o),Ve.delete(e)}})()),()=>Lt.off(e,r)},[e]),t};var Ii=["default-light","default-dark","default-minimal"],Ri=["paper-light","paper-dark-dark","paper-dark"],yn=["blue","purple","green","orange","red"],Bi=["hacker1","hacker2"],vn=["winter","spring","summer","automn"],En=["tropical"],wn=["kyoto","newyork","paris"],kn=["mred","lgreen"],Mg=["default-light","default-minimal","paper-light",...yn,...vn,...En,...wn,...kn];var Oi=[...Ii,...Ri,...yn,...Bi,...vn,...En,...wn,...kn];function Ln(e){return Oi.includes(e)}var _n="default-light",Z=e=>{let t=xn(e);return E(()=>{if(!t||!t.ok)return _n;let r=t.value.theme;return Ln(r)?r:_n},[t])};var ae=(e,t)=>new Promise(r=>{let n=!1,o=()=>{n=!0,r(!1)};e.addEventListener("click",o),e.addEventListener("pointerleave",o),setTimeout(()=>{n||r(!0),e.removeEventListener("click",o),e.removeEventListener("pointerleave",o),r(!1)},t)});var ce=e=>{let{top:t,right:r,left:n,bottom:o}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),a=(n-s.left)/s.width>.5;return{top:Math.round(o-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...a?{right:Math.round(s.right-r)}:{left:Math.round(n-s.left)},maxWidth:a?r-10:document.documentElement.clientWidth-n-10}};var Tn=({project:e,title:t,descriptions:r,thumbnail:n,linkTo:o,bubble:s,delay:a,prefetch:l})=>{let i=E(()=>n?[]:ke(r.join( ),{hasTitle:!1}),[n,r]),u=Z(e),c=O(async({currentTarget:g})=>{l(e,t),await ae(g,a)&&s({project:e,title:t,linkTo:o,type:"link",position:ce(g)})},[e,t,a,o?.project,o?.titleLc]),m=E(()=>o?()=>{kt({type:"page",from:{project:o.project??e,title:o.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,o?.project,o?.titleLc]);return d("a",{className:"related-page-card page-link",type:"link","data-theme":u,href:/${e}/${P(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:c,onClick:m},d("div",{class:"hover"}),d("div",{class:"content"},d("div",{class:"header"},d("div",{class:"title"},t)),n?d("div",{class:"thumbnail"},d("img",{src:n})):d("div",{class:"description"},i.flatMap((g,p)=>g.type==="line"?[d("p",{key:p},g.nodes.map(f=>d(Mn,{node:f,project:e})))]:[]))))},Mn=({node:e,project:t})=>{switch(e.type){case"code":return d("code",null,e.text);case"formula":return d(Hi,{node:e});case"commandLine":return d("code",null,e.symbol," $",e.text);case"helpfeel":return d("code",null,"? ",e.text);case"quote":case"strong":case"decoration":return d(L,null,e.nodes.map(r=>d(Mn,{node:r,project:t})));case"icon":case"strongIcon":return d(Di,{node:e,project:t});case"hashTag":return d($i,{node:e});case"link":return d(ji,{node:e});case"plain":case"blank":return d(L,null,e.text);default:return d(L,null)}},Hi=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:n}=we("");return n(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},Di=({node:{pathType:e,path:t},project:r})=>{let[n,o]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return d("img",{class:"icon",src:/api/pages/${n}/${P(o)}/icon})},$i=({node:{href:e}})=>d("span",{class:"page-link"},"#",e),ji=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?d("span",{class:"page-link"},t):d("span",{class:"link"},r||t);var v=(e,t)=>/${e}/${B(t)},Qe=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var Rn=Symbol.for("immer-nothing"),Pn=Symbol.for("immer-draftable"),y=Symbol.for("immer-state");function F(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var le=Object.getPrototypeOf;function ue(e){return!!e&&!!e[y]}function z(e){return e?Bn(e)||Array.isArray(e)||!!e[Pn]||!!e.constructor?.[Pn]||rt(e)||nt(e):!1}var Ai=Object.prototype.constructor.toString();function Bn(e){if(!e||typeof e!="object")return!1;let t=le(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Ai}function Le(e,t){tt(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function tt(e){let t=e[y];return t?t.type_:Array.isArray(e)?1:rt(e)?2:nt(e)?3:0}function Mt(e,t){return tt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function On(e,t,r){let n=tt(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function Fi(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function rt(e){return e instanceof Map}function nt(e){return e instanceof Set}function N(e){return e.copy_||e.base_}function Pt(e,t){if(rt(e))return new Map(e);if(nt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Bn(e);if(t===!0||t==="class_only"&&!r){let n=Object.getOwnPropertyDescriptors(e);delete n[y];let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++){let a=o[s],l=n[a];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(n[a]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[a]})}return Object.create(le(e),n)}else{let n=le(e);if(n!==null&&r)return{...e};let o=Object.create(n);return Object.assign(o,e)}}function It(e,t=!1){return ot(e)||ue(e)||!z(e)||(tt(e)>1&&(e.set=e.add=e.clear=e.delete=Ui),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>It(n,!0))),e}function Ui(){F(2)}function ot(e){return Object.isFrozen(e)}var Ct={};function ee(e){let t=Ct[e];return t||F(0,e),t}function Ki(e,t){Ct[e]||(Ct[e]=t)}var _e;function Je(){return _e}function qi(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Cn(e,t){t&&(ee("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Nt(e){St(e),e.drafts_.forEach(zi),e.drafts_=null}function St(e){e===_e&&(_e=e.parent_)}function Nn(e){return _e=qi(_e,e)}function zi(e){let t=e[y];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Sn(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[y].modified_&&(Nt(t),F(4)),z(e)&&(e=Ze(t,e),t.parent_||et(t,e)),t.patches_&&ee("Patches").generateReplacementPatches_(r[y].base_,e,t.patches_,t.inversePatches_)):e=Ze(t,r,[]),Nt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Rn?e:void 0}function Ze(e,t,r){if(ot(t))return t;let n=t[y];if(!n)return Le(t,(o,s)=>In(e,n,t,o,s,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return et(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,a=!1;n.type_===3&&(s=new Set(o),o.clear(),a=!0),Le(s,(l,i)=>In(e,n,o,l,i,r,a)),et(e,o,!1),r&&e.patches_&&ee("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function In(e,t,r,n,o,s,a){if(ue(o)){let l=s&&t&&t.type_!==3&&!Mt(t.assigned_,n)?s.concat(n):void 0,i=Ze(e,o,l);if(On(r,n,i),ue(i))e.canAutoFreeze_=!1;else return}else a&&r.add(o);if(z(o)&&!ot(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ze(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&et(e,o)}}function et(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&It(t,r)}function Gi(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:Je(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=Rt;r&&(o=[n],s=Te);let{revoke:a,proxy:l}=Proxy.revocable(o,s);return n.draft_=l,n.revoke_=a,l}var Rt={get(e,t){if(t===y)return e;let r=N(e);if(!Mt(r,t))return Wi(e,r,t);let n=r[t];return e.finalized_||!z(n)?n:n===_t(e.base_,t)?(Tt(e),e.copy_[t]=Me(n,e)):n},has(e,t){return t in N(e)},ownKeys(e){return Reflect.ownKeys(N(e))},set(e,t,r){let n=Hn(N(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=_t(N(e),t),s=o?.[y];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Fi(r,o)&&(r!==void 0||Mt(e.base_,t)))return!0;Tt(e),q(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return _t(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Tt(e),q(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=N(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){F(11)},getPrototypeOf(e){return le(e.base_)},setPrototypeOf(){F(12)}},Te={};Le(Rt,(e,t)=>{Te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Te.deleteProperty=function(e,t){return Te.set.call(this,e,t,void 0)};Te.set=function(e,t,r){return Rt.set.call(this,e[0],t,r,e[0])};function _t(e,t){let r=e[y];return(r?N(r):e)[t]}function Wi(e,t,r){let n=Hn(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function Hn(e,t){if(!(t in e))return;let r=le(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=le(r)}}function q(e){e.modified_||(e.modified_=!0,e.parent_&&q(e.parent_))}function Tt(e){e.copy_||(e.copy_=Pt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Xi=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let a=this;return function(l=s,...i){return a.produce(l,u=>r.call(this,u,...i))}}typeof r!="function"&&F(6),n!==void 0&&typeof n!="function"&&F(7);let o;if(z(t)){let s=Nn(this),a=Me(t,void 0),l=!0;try{o=r(a),l=!1}finally{l?Nt(s):St(s)}return Cn(s,n),Sn(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===Rn&&(o=void 0),this.autoFreeze_&&It(o,!0),n){let s=[],a=[];ee("Patches").generateReplacementPatches_(t,o,s,a),n(s,a)}return o}else F(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let n,o;return[this.produce(t,r,(s,a)=>{n=s,o=a}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){z(e)||F(8),ue(e)&&(e=Yi(e));let t=Nn(this),r=Me(e,void 0);return r[y].isManual_=!0,St(t),r}finishDraft(e,t){let r=e&&e[y];(!r||!r.isManual_)&&F(9);let{scope_:n}=r;return Cn(n,t),Sn(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=ee("Patches").applyPatches_;return ue(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Me(e,t){let r=rt(e)?ee("MapSet").proxyMap_(e,t):nt(e)?ee("MapSet").proxySet_(e,t):Gi(e,t);return(t?t.scope_:Je()).drafts_.push(r),r}function Yi(e){return ue(e)||F(10,e),Dn(e)}function Dn(e){if(!z(e)||ot(e))return e;let t=e[y],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Pt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Pt(e,!0);return Le(r,(n,o)=>{On(r,n,Dn(o))}),t&&(t.finalized_=!1),r}function $n(){class e extends Map{constructor(i,u){super(),this[y]={type_:2,parent_:u,scope_:u?u.scope_:Je(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return N(this[y]).size}has(i){return N(this[y]).has(i)}set(i,u){let c=this[y];return a(c),(!N(c).has(i)||N(c).get(i)!==u)&&(r(c),q(c),c.assigned_.set(i,!0),c.copy_.set(i,u),c.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let u=this[y];return a(u),r(u),q(u),u.base_.has(i)?u.assigned_.set(i,!1):u.assigned_.delete(i),u.copy_.delete(i),!0}clear(){let i=this[y];a(i),N(i).size&&(r(i),q(i),i.assigned_=new Map,Le(i.base_,u=>{i.assigned_.set(u,!1)}),i.copy_.clear())}forEach(i,u){let c=this[y];N(c).forEach((m,g,p)=>{i.call(u,this.get(g),g,this)})}get(i){let u=this[y];a(u);let c=N(u).get(i);if(u.finalized_||!z(c)||c!==u.base_.get(i))return c;let m=Me(c,u);return r(u),u.copy_.set(i,m),m}keys(){return N(this[y]).keys()}values(){let i=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let u=i.next();return u.done?u:{done:!1,value:this.get(u.value)}}}}entries(){let i=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let u=i.next();if(u.done)return u;let c=this.get(u.value);return{done:!1,value:[u.value,c]}}}}[Symbol.iterator](){return this.entries()}}function t(l,i){return new e(l,i)}function r(l){l.copy_||(l.assigned_=new Map,l.copy_=new Map(l.base_))}class n extends Set{constructor(i,u){super(),this[y]={type_:3,parent_:u,scope_:u?u.scope_:Je(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return N(this[y]).size}has(i){let u=this[y];return a(u),u.copy_?!!(u.copy_.has(i)||u.drafts_.has(i)&&u.copy_.has(u.drafts_.get(i))):u.base_.has(i)}add(i){let u=this[y];return a(u),this.has(i)||(s(u),q(u),u.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let u=this[y];return a(u),s(u),q(u),u.copy_.delete(i)||(u.drafts_.has(i)?u.copy_.delete(u.drafts_.get(i)):!1)}clear(){let i=this[y];a(i),N(i).size&&(s(i),q(i),i.copy_.clear())}values(){let i=this[y];return a(i),s(i),i.copy_.values()}entries(){let i=this[y];return a(i),s(i),i.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(i,u){let c=this.values(),m=c.next();for(;!m.done;)i.call(u,m.value,m.value,this),m=c.next()}}function o(l,i){return new n(l,i)}function s(l){l.copy_||(l.copy_=new Set,l.base_.forEach(i=>{if(z(i)){let u=Me(i,l);l.drafts_.set(i,u),l.copy_.add(u)}else l.copy_.add(i)}))}function a(l){l.revoked_&&F(3,JSON.stringify(N(l)))}Ki("MapSet",{proxyMap_:t,proxySet_:o})}var j=new Xi,st=j.produce,Wg=j.produceWithPatches.bind(j),Xg=j.setAutoFreeze.bind(j),Yg=j.setUseStrictShallowCopy.bind(j),Vg=j.applyPatches.bind(j),Qg=j.createDraft.bind(j),Jg=j.finishDraft.bind(j);$n();var jn=e=>{let t=0;for(let r of e)if(r&&(r.exists||(t+=(r.linked?.length??0)+(r.projectLinked?.length??0),t>1)))return!1;return t<2},An=(e,t)=>st(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:n,linked:o,projectLinked:s,...a}=t;Object.assign(r,a),Bt(t)||(r.lines=n),o&&(r.linked??=o),s&&(r.projectLinked??=s);return}Bt(r)&&!Bt(t)&&(r.lines=t.lines),t.linked&&(t.isLinkedCorrect||!r.isLinkedCorrect&&(r.linked?.length??0)<=t.linked.length)&&(r.linked=t.linked),t.projectLinked&&(r.projectLinked=t.projectLinked)}),Bt=e=>e.lines[0].id==="dummy";var Fn=(e,t)=>{let r=new Map,n=B(t.title);for(let i of t.links){let u=Vi(e,i);u.linked=[n],r.set(v(e,i),u)}let o=v(e,n),s=t.projectLinks.map(i=>{let u=Qe(i);return v(u.project,u.titleLc)}),a={...it(e,t),linked:[],projectLinked:[]};r.set(o,a);let l=t.links.map(i=>B(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(n)&&a.linked.push(i.titleLc);for(let g of i.linksLc.filter(p=>l.includes(p))){let p=v(e,g),f=r.get(p);if(!f)throw Error(storage already must have "${p}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let u=v(e,i.titleLc),c=it(e,i),m=r.get(u)?.linked;m&&(c.linked=m),r.set(u,c)}for(let i of t.relatedPages.projectLinks1hop){let u=v(i.projectName,i.titleLc);s.includes(u)||a.projectLinked.push(u);let c=it(i.projectName,i),m=r.get(u)?.projectLinked;m&&(c.projectLinked=m),r.set(u,c)}a.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let g of i.linksLc){let p=v(e,g),f=r.get(p);if(!f)throw Error(storage already must have "${p}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let u=v(e,i.titleLc),c=it(e,i),m=r.get(u)?.linked;m&&(c.linked=m),r.set(u,c)}return r},it=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:B(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:t.descriptions,image:t.image,lines:"lines"in t?t.lines:[t.title,...t.descriptions].map(r=>({text:r,id:"dummy",userId:"dummy",updated:t.updated,created:t.updated})),updated:t.updated,isLinkedCorrect:!1}),Vi=(e,t)=>({project:e,titleLc:B(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var at=Y("ScrapBubble:bubble.ts"),Ot=new Map,ct=new Set,Ht=Ye();function*Kn(e){for(let t of e)yield Ot.get(t)}var qn=(e,t)=>Ht.on(e,t),zn=(e,t)=>Ht.off(e,t),Gn=async(e,t,r,n)=>{let o=[];for(let s of[...t].reverse()){let a=v(s,e);ct.has(a)||o.push(Qi(s,e,r,n))}await Promise.all(o)},Un=0,Qi=async(e,t,r,n)=>{let o=v(e,t);if(ct.has(o))return;ct.add(o);let s=Un++,a=${s} Check update ${o};at.time(a);try{let l=se.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[i,u]of Xe(l,{ignoreSearch:!0,saveFailedResponse:!0})){at.debug(${s}${i} ${o});let c=await se.fromResponse(u);if(c.ok){let m=Fn(e,c.value);for(let[g,p]of m){let f=Ot.get(g),b=An(f,p);b&&f!==b&&(Ot.set(g,b),Ht.dispatch(g,p))}}if(n?.ignoreFetch===!0||i==="cache"&&!hn(u,n?.maxAge??60))break}}catch(l){at.error(l)}finally{ct.delete(o),at.timeEnd(a),Un--}};var Wn=Y("ScrapBubble:useBubbleData.ts"),de=e=>{let[t,r]=M([]);return ze(()=>{let n=()=>{r(()=>{let a=[...Kn(e)].flatMap(l=>l?[l]:[]);return Wn.debug(Required: ${e.length} pages, ${a.length} found,a),a})};n();let o,s=()=>{clearTimeout(o),o=setTimeout(()=>{Wn.debug(Update ${e.length} pages),n()},10)};return e.forEach(a=>qn(a,s)),()=>e.forEach(a=>zn(a,s))},e),t};var Xn=({source:e,linked:t,externalLinked:r,projectsForSort:n,...o})=>{let s=E(()=>[...t.keys(),...r.keys()],[t,r]),a=de(s),l=E(()=>[...n],[n]),i=E(()=>{let c=(m,g)=>{let p=l.indexOf(m.project),f=l.indexOf(g.project);return p===f?g.updated-m.updated:p<0?1:f<0?-1:p-f};return[...a].sort(c)},[a,l]),u=E(()=>({bottom:${e.position.bottom}px,maxWidth:${e.position.maxWidth}px,..."left"in e.position?{left:${e.position.left}px}:{right:${e.position.right}px}}),[e.position]);return d("ul",{className:"card-bubble",style:u,onClick:o.onClick},i.map(({project:c,titleLc:m,lines:[{text:g}],descriptions:p,image:f})=>{let b=v(c,m),x=t.get(b)??r.get(b);return d("li",{key:b},d(Tn,{project:c,title:g,linkTo:x,descriptions:p,thumbnail:f??"",...o}))}))};var pe=e=>{if(e.pathType==="root"){let[,t="",r=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(t==="")throw SyntaxError(Failed to get a project name from "${e.href}");let[,n]=r?.match?.(/#([a-f\d]{24,32})$/)??["",""];return r===""?{project:t}:n===""?{project:t,title:r}:{project:t,title:r.slice(0,-1-n.length),hash:n}}else{let[,t]=e.href.match(/#([a-f\d]{24,32})$/)??["",""];return t===""?{title:e.href}:{title:e.href.slice(0,-1-t.length),hash:t}}};var Dt=(e,t)=>t.some(r=>{let n=!e.project;switch(r.type){case"hashTag":return n&&B(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==n)return!1;let{project:o,title:s=""}=pe({pathType:r.pathType,href:r.href});return n?!o&&B(s)===e.titleLc:o===e.project&&B(s)===e.titleLc}case"quote":case"strong":case"decoration":return Dt(e,r.nodes)}});var V=yt({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Vn=({lines:e,project:t,title:r,whiteList:n,noIndent:o,hash:s,linkTo:a,...l})=>{let i=E(()=>e.flatMap(p=>typeof p=="string"?[]:[p.id]),[e]),u=E(()=>{let p=0;return ke(e.map(f=>typeof f=="string"?f:f.text).join( ),{hasTitle:!0}).map(f=>{switch(f.type){case"title":case"line":return{...f,id:i[p++]};case"codeBlock":{let b=p;return p+=f.content.split(
).length+1,{...f,ids:i.slice(b,p)}}case"table":{let b=p;return p+=f.cells.length+1,{...f,ids:i.slice(b,p)}}}})},[e,i]),c=E(()=>{if(s&&i.includes(s))return s;if(a)return u.find(p=>p.type!=="line"?!1:Dt(a,p.nodes))?.id},[u,i,s,a?.project,a?.titleLc]),m=oe(null);D(()=>{if(!c)return;let p=m.current?.querySelector(data-id="${c}"),f=globalThis.scrollY;p?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,f)},[c]);let g=Z(t);return d("div",{className:"lines","data-theme":g,ref:m},d(V.Provider,{value:{project:t,title:r,whiteList:n,...l}},u.map(p=>{switch(p.type){case"title":return d(L,null,d(me,{key:p.id,index:p.id,indent:0,noIndent:o,permalink:p.id===c},d("a",{className:"page-link",type:"link",href:/${t}/${P(p.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank"},p.text)),d("hr",null));case"codeBlock":return d(Ji,{key:p.ids[0],block:p,noIndent:o,ids:p.ids,scrollId:c});case"table":return d(Zi,{key:p.ids[0],block:p,noIndent:o,ids:p.ids,scrollId:c});case"line":return d(me,{key:p.id,index:p.id,indent:p.indent,noIndent:o,permalink:p.id===c},p.nodes.length>0?p.nodes.map(f=>d(fe,{node:f})):d("br",null))}})))},me=({index:e,indent:t,noIndent:r,children:n,permalink:o})=>d("div",{className:line${o?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em}},n),Ji=({block:{fileName:e,content:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:a}=W(V),[l,i]=M(""),u=O(async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(t),i("Copied"),await J(1e3),i("")}catch(m){alert(Failed to copy the code block Error:${m.message})}},[t]);return d(L,null,d(me,{index:n[0],indent:r,permalink:n[0]===o},d("span",{className:"code-block"},d("span",{className:"code-block-start"},d("a",{href:/api/code/${s}/${P(a)}/${e},target:"_blank"},e)),d("span",{className:"copy",title:"Copy",onClick:u},l))),d(L,null,t.split(
).map((c,m)=>d(me,{index:n[m+1],indent:r,permalink:n[m+1]===o},d("code",{className:"code-block"},c)))))},Zi=({block:{fileName:e,cells:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:a}=W(V);return d(L,null,d(me,{index:n[0],indent:r,permalink:n[0]===o},d("span",{className:"table-block"},d("span",{className:"table-block-start"},d("a",{href:/api/table/${s}/${P(a)}/${e}.csv,target:"_blank"},e)))),d(L,null,t.map((l,i)=>d(me,{index:n[i+1],indent:r,permalink:n[i+1]===o},d("span",{className:"table-block table-block-row"},l.map((u,c)=>d("span",{className:cell col-${c}},u.map(m=>d(fe,{node:m})))))))))},fe=({node:e})=>{switch(e.type){case"code":return d("code",{className:"code"},e.text);case"formula":return d(ea,{node:e});case"commandLine":return d(ra,{node:e});case"helpfeel":return d("code",{className:"helpfeel"},d("span",{className:"prefix"},"?")," ",d("span",{className:"entry"},e.text));case"quote":return d("blockquote",{className:"quote"},e.nodes.map(t=>d(fe,{node:t})));case"strong":return d("strong",null,e.nodes.map(t=>d(fe,{node:t})));case"decoration":return d(ta,{node:e});case"plain":case"blank":return d(L,null,e.text);case"hashTag":return d(sa,{node:e});case"link":return d(ia,{node:e});case"googleMap":return d(na,{node:e});case"icon":return d(Yn,{node:e});case"strongIcon":return d(Yn,{node:e,strong:!0});case"image":return d(oa,{node:e});case"strongImage":return d("img",{className:"image strong-image",src:e.src});case"numberList":return d(L,null,${e.number}. ,e.nodes.map(t=>d(fe,{node:t})))}},ea=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:n}=we("");return n(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},ta=({node:{decos:e,nodes:t}})=>d("span",{className:e.map(r=>deco-${r}).join(" ")},t.map(r=>d(fe,{node:r}))),ra=({node:e})=>{let[t,r]=M(""),n=O(async o=>{o.preventDefault(),o.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await J(1e3),r("")}catch(s){alert(Failed to copy the code block
Error:${s.message})}},[e.text]);return d(L,null,d("code",{className:"cli"},d("span",{className:"prefix"},e.symbol)," ",d("span",{className:"command"},e.text)),d("span",{className:"tool-buttons"},d("span",{title:"Copy",className:"copy",onClick:n},t)))},na=({node:{place:e,latitude:t,longitude:r,zoom:n}})=>d("span",{className:"pointing-device-map"},d("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${n}z,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${n}&_csrf=${globalThis._csrf}}))),Yn=({node:{pathType:e,path:t},strong:r})=>{let{project:n}=W(V),[o,s]=e==="relative"?[n,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[n,t],a=P(s);return d("a",{href:/${o}/${a},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank"},d("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${o}/${a}/icon},s))},oa=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return d("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"image",src:t}))},sa=({node:{href:e}})=>{let{project:t}=W(V),r=Qn(t,e),n=Jn(t,e,"hashtag");return d("a",{href:/${t}/${P(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:n},"#",e)},ia=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return d(aa,{pathType:e,href:t.href});case"absolute":{let r=Jr({pathType:e,...t});switch(r.type){case"youtube":return d(ca,{...r});case"vimeo":return d(la,{...r});case"spotify":return d(ua,{...r});case"anchor-fm":return d(da,{...r});case"audio":return d(pa,{...r});case"video":return d(ma,{...r});case"absoluteLink":return d("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},aa=({pathType:e,href:t})=>{let{project:r}=W(V),{project:n=r,title:o,hash:s=""}=pe({pathType:e,href:t}),a=Jn(n,o,"link",s),l=Qn(n,o??"");return d("a",{className:page-link${o!==void 0&&l?" empty-page-link":""},type:"link",href:/${n}${o===void 0?"":/${P(o)}${s===""?"":#${s}}},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",onPointerEnter:a},t)},ca=e=>{e.params.append("autoplay","0");let t=e.pathType==="list"?https://www.youtube.com/embed/?${e.params.toString()}&list=${e.listId}:https://www.youtube.com/embed/${e.videoId}?${e.params.toString()};return d("div",{className:"iframe-video-player"},d("iframe",{src:t,allowFullScreen:!0,type:"text/html"}))},la=({videoId:e})=>d("div",{className:"iframe-video-player"},d("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0,type:"text/html"})),ua=e=>d("div",{className:"iframe-video-player"},d("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0,type:"text/html",scrolling:"no"})),da=e=>d("div",{className:"iframe-video-player"},d("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})),pa=e=>e.content===""?d("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):d(fa,{...e}),fa=({href:e,content:t})=>{let r=oe(null),n=O(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return d("span",{className:"audio-link"},d("a",{href:e,rel:"noopener noreferrer",target:"_blank"},t),d("span",{className:"play",onClick:n},"♬"),d("audio",{preload:"none",src:e,ref:r}))},ma=({href:e})=>d("div",{className:"video-player"},d("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})),Qn=(e,t)=>{let{whiteList:r}=W(V),n=E(()=>(r.has(e)?[...r]:[e,...r]).map(s=>v(s,t)),[r,e]),o=de(n);return E(()=>jn(o),o)},Jn=(e,t,r,n)=>{let{delay:o,bubble:s,prefetch:a}=W(V);return O(async({currentTarget:l})=>{t&&(a(e,t),await ae(l,o)&&s({project:e,title:t,hash:n,type:r,position:ce(l)}))},[e,t,n,r,o,a,s])};var Zn=({pages:e,onClick:t,source:r,whiteList:n,...o})=>{let[s,a]=M(v(e[0].project,e[0].titleLc)),l=E(()=>({top:${r.position.top}px,maxWidth:${r.position.maxWidth}px,..."left"in r.position?{left:${r.position.left}px}:{right:${r.position.right}px}}),[r.position]);return d("div",{className:"text-bubble",style:l,onClick:t},e.length>1&&d("div",{role:"tablist"},e.map(i=>d(ga,{key:v(i.project,i.titleLc),project:i.project,titleLc:i.titleLc,selected:s===v(i.project,i.titleLc),tabSelector:a}))),e.map(i=>d(ha,{key:v(i.project,i.titleLc),selected:s===v(i.project,i.titleLc),...i,title:i.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:n,...o})))},ga=({project:e,titleLc:t,tabSelector:r,selected:n})=>{let o=O(()=>r(v(e,t)),[e,t]),s=Z(e);return d("button",{role:"tab","aria-selected":n,"data-theme":s,tabIndex:-1,onClick:o},e)},ha=({selected:e,...t})=>{let r=Z(t.project);return d("div",{role:"tabpanel","data-theme":r,hidden:!e},d(Vn,{...t}))};var eo=Y("ScrapBubble:Bubble.tsx"),to=({source:e,parentTitles:t,whiteList:r,...n})=>{let o=E(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,a,l]=xa(e,o,r,t);return d(L,null,ba(l)&&d(Zn,{pages:l,source:e,whiteList:r,onClick:n.hide,...n}),d(Xn,{linked:s,externalLinked:a,onClick:n.hide,source:e,projectsForSort:o,...n}))},ba=e=>e.length>0,xa=(e,t,r,n)=>{let[[o,s,a],l]=M([new Map,new Map,[]]),i=E(()=>{let m=[...t].map(g=>v(g,e.title));return eo.debug("projects",m),m},[t,e.title]),u=de(i),c=E(()=>n.map(m=>B(m)),[n]);return ze(()=>{let m=new Map,g=new Map,p=[];for(let f of u){let b={project:f.project,titleLc:f.titleLc};for(let w of f.projectLinked??[]){let{project:I,titleLc:te}=Qe(w);c.includes(te)&&r.has(I)||g.has(w)||g.set(w,b)}if(!r.has(f.project))continue;let x={titleLc:f.titleLc};for(let w of f.linked??[]){if(c.includes(w))continue;let I=v(f.project,w);m.has(I)||m.set(I,x)}c.includes(f.titleLc)||f.exists&&p.push(f)}l(st(f=>{eo.debug(depth: ${c.length}, bubbled from ${v(e.project,e.title)}, bubbles,,u,"before",f[0],"internal cards,",m,"external cards",g);for(let b of f[0].keys())m.has(b)||f[0].delete(b);for(let[b,x]of m)f[0].set(b,x);for(let b of f[1].keys())g.has(b)||f[1].delete(b);for(let[b,x]of g)f[1].set(b,x);f[2]=p}))},[u,r,c]),[o,s,a]};var ro=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var no=e=>{let t=E(()=>ro(e.style,import.meta.url),[e.style]);return d(L,null,t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",null,t)))};var oo=String.raw*{box-sizing:border-box}a{background-color:transparent;text-decoration:none;cursor:pointer}img{display:inline-block;max-width:100%;max-height:100px}code{font-family:var(--code-text-font, Menlo, Monaco, Consolas, "Courier New", monospace);font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}blockquote{background-color:var(--quote-bg-color, rgba(0,0,0,.05));display:block;border-left:solid 4px #a0a0a0;padding-left:4px;margin:0}strong{font-weight:700}iframe{display:inline-block;margin:3px 0;vertical-align:middle;max-width:100%;width:640px;height:360px;border:0}audio{display:inline-block;vertical-align:middle;white-space:initial;max-width:100%}.formula{margin:auto 6px}.formula.error code{color:#fd7373}.katex-display{display:inline-block!important;margin:0!important;text-align:inherit!important}.error .katex-display{display:none}.cli{border-radius:4px}.cli .prefix{color:#9c6248}.helpfeel{background-color:#fbebdd;border-radius:4px;padding:3px!important}.helpfeel .prefix{color:#f17c00}.helpfeel .entry{color:#cc5020}.code-block{display:block;line-height:1.7em;background-color:var(--code-bg, rgba(0,0,0,.04))}.code-block-start{font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#342d9c;background-color:#ffcfc6;font-size:.9em;padding:1px 2px}.code-block-start a{color:#342d9c;text-decoration:underline}code.code-block,.table-block.table-block-row{padding-left:1em}.copy{font-family:"Font Awesome 5 Free";cursor:pointer}.table-block{white-space:nowrap}.table-block-start{padding:1px 2px;font-size:.9em;background-color:#ffcfc6}.table-block-start a{color:#342d9c;text-decoration:underline}.cell{margin:0;padding:0 2px 0 8px;box-sizing:content-box;display:inline-block;white-space:pre}.cell:nth-child(odd){background-color:#0000000a}.cell:nth-child(2n){background-color:#0000000f}.strong-image{max-height:100%}.icon{height:11px;vertical-align:middle}.strong-icon{height:13.2px}.tool-button{margin-left:1em;cursor:pointer;font-size:.9em}.deco-\/{font-style:italic}.deco-\*-1{font-weight:700}.deco-\*-2{font-weight:700;font-size:1.2em}.deco-\*-3{font-weight:700;font-size:1.44em}.deco-\*-4{font-weight:700;font-size:1.73em}.deco-\*-5{font-weight:700;font-size:2.07em}.deco-\*-6{font-weight:700;font-size:2.49em}.deco-\*-7{font-weight:700;font-size:3em}.deco-\*-8{font-weight:700;font-size:3.58em}.deco-\*-9{font-weight:700;font-size:4.3em}.deco-\*-10{font-weight:700;font-size:5.16em}.deco--{text-decoration:line-through}.deco-_{text-decoration:underline}.page-link{color:var(--page-link-color, #5e8af7)}a.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}a.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}a.link:hover{color:var(--page-link-color-hover-color, #2d67f5)}.link img{padding-bottom:3px;border-style:none none solid;border-width:1.5px;border-color:#8fadf9}.permalink{background-color:var(--line-permalink-color, rgba(234,218,74,.75))}.status-bar{display:inline-block;position:absolute;background-color:var(--page-bg, #fefefe);cursor:default}.status-bar>*{border:1px solid var(--status-bar-border-color, #a9aaaf)}.status-bar.top-left{top:0;left:0}.status-bar.top-left>*{border-top:none;border-left:none}.status-bar.top-left :last-of-type{border-bottom-right-radius:3px}.status-bar.top-right{top:0;right:0}.status-bar.top-right>*{border-top:none;border-right:none}.status-bar.top-right :last-of-type{border-bottom-left-radius:3px}.status-bar.bottom-right{bottom:0;right:0}.status-bar.bottom-right>*{border-bottom:none;border-right:none}.status-bar.bottom-right :last-of-type{border-top-left-radius:3px}.status-bar.bottom-left{bottom:0;left:0}.status-bar.bottom-left>*{border-bottom:none;border-left:none}.status-bar.bottom-left :last-of-type{border-top-right-radius:3px}.text-bubble{font-size:11px;line-height:1.42857;user-select:text;position:absolute;color:var(--page-text-color, #4a4a4a);box-shadow:0 6px 12px #0000002d;display:flex;flex-direction:column;z-index:9000;&.no-scroll{overflow-y:hidden}data-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}data-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}data-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}data-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}data-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}data-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}data-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}data-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}data-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}data-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}data-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}data-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}role=tabpanel{padding:5px 0 5px 5px;border-radius:4px;background-color:var(--page-bg, #fefefe);max-height:80vh;overflow-y:auto}role=tabpanel,button{border:1px solid var(--text-bubble-border-color, hsl(221, 15%, 25%))}button{cursor:default;color:inherit;font-size:inherit;line-height:inherit;background-color:var(--page-bg, #fefefe);border-radius:4px 4px 0 0}buttonaria-selected=true{background-color:var(--text-bubble-border-color, hsl(221, 15%, 25%))}}.project-badge{text-decoration:none;color:var(--tool-text-color, #363c49)}.related-page-carddata-theme=default-dark{--card-title-bg: hsl(0, 0%, 39%)}.related-page-carddata-theme=default-minimal{--card-title-bg: hsl(0, 0%, 89%)}.related-page-carddata-theme=paper-light{--card-title-bg: hsl(53, 8%, 58%)}.related-page-carddata-theme=paper-dark-dark{--card-title-bg: hsl(203, 42%, 17%)}.related-page-carddata-theme=blue{--card-title-bg: hsl(227, 68%, 62%)}.related-page-carddata-theme=purple{--card-title-bg: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--card-title-bg: hsl(136, 29%, 50%)}.related-page-carddata-theme=orange{--card-title-bg: hsl(43, 71%, 51%)}.related-page-carddata-theme=red{--card-title-bg: hsl(4, 58%, 56%)}.related-page-carddata-theme=spring{--card-title-bg: hsl(72, 64%, 57%)}.related-page-carddata-theme=kyoto{--card-title-bg: hsl(331, 21%, 26%)}.related-page-carddata-theme=newyork{--card-title-bg: hsl(176, 29%, 67%)}.related-page-card{display:block;position:relative;height:inherit;width:inherit;overflow:hidden;text-overflow:ellipsis;font-family:Roboto,Helvetica,Arial,Hiragino Sans,sans-serif;background-color:var(--card-bg, #fff);color:var(--card-title-color, #555);word-break:break-word;text-decoration:none}.related-page-card:hover{box-shadow:var(--card-box-hover-shadow, 0 2px 0 rgba(0,0,0,.23))}.related-page-card:focus{outline:0;box-shadow:0 0 0 3px #66afe999;border-color:#66afe9;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.related-page-card.hover{opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;background-color:var(--card-hover-bg, rgba(0,0,0,.05));mix-blend-mode:multiply;z-index:1;transition:background-color .1s}.related-page-card:hover .hover{opacity:1}.related-page-card:active .hover{opacity:1;background-color:var(--card-active-bg, rgba(0,0,0,.1))}.related-page-card .content{height:calc(100% - 5px);width:inherit;display:flex;flex-direction:column;overflow:hidden}.related-page-card .content .header{width:100%;color:#396bdd;text-overflow:ellipsis;border-top:var(--card-title-bg, #f2f2f3) solid 10px;padding:8px 10px}.related-page-card .content .header .title{font-size:11px;line-height:16px;font-weight:700;max-height:48px;color:var(--card-title-color, #363c49);margin:0;overflow:hidden;display:block;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-overflow:ellipsis}.related-page-card .content .description{line-height:16px;padding:8px 10px 0;font-size:10px;white-space:pre-line;column-count:1;column-gap:2em;column-width:10em;height:inherit;color:var(--card-description-color, gray);flex-shrink:16;overflow:hidden}.related-page-card .content .thumbnail{display:block;width:100%;margin:0 auto;padding:0 5px}.related-page-card .content .description p{margin:0;display:block}.related-page-card .content .description code{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}.related-page-card .content .description .icon{height:9px;vertical-align:middle}.related-page-card .content .description .page-link{background-color:transparent;text-decoration:none;cursor:pointer;color:var(--page-link-color, #5e8af7)}.card-bubble{background-color:var(--page-bg, #FFF);box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;position:absolute;max-width:80vw;box-sizing:content-box;z-index:9000;font-size:11px;line-height:1.42857;display:flex;padding:0;margin:0;list-style:none;overflow-x:auto;overflow-y:visible}.card-bubble li{display:block;position:relative;float:none;margin:5px;box-sizing:border-box;box-shadow:var(--card-box-shadow, 0 2px 0 rgba(0,0,0,.12));border-radius:2px;width:120px;height:120px} ;var so=()=>{let[e,t]=M([]),r=O((s,a)=>t(l=>a?[...l.slice(0,s),a]:[...l.slice(0,s)]),[]),[n,o]=M([{bubble:s=>r(0,s),hide:()=>r(0)}]);return D(()=>{o(([s,...a])=>[s,...e.map((l,i)=>l===a.at(i)?.source?a.at(i):{source:l,parentTitles:[scrapbox.Page.title??"",...e.slice(0,i).map(u=>u.title)],bubble:u=>r(i+1,u),hide:()=>r(i+1)})])},[e]),n};var $t=(e,t,r,n,o)=>{D(()=>(e.addEventListener(t,r,n),()=>e.removeEventListener(t,r,n)),[e,t,n,...o??[]])};var io=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),lt=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var jt="scrap-bubble",ao=({delay:e,whiteList:t,watchList:r,style:n})=>{let[{bubble:o,hide:s},...a]=so(),l=O((i,u)=>Gn(u,t.has(i)?t:new Set([i]),r),[t,r]);return $t(document,"pointerenter",async i=>{let u=i.target;if(!lt(u)&&!io(u))return;let{project:c=scrapbox.Project.name,title:m,hash:g=""}=lt(u)?pe({pathType:"root",href:${new URL(u.href).pathname}${new URL(u.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(c==="")return;let p=decodeURIComponent(m??"");l(c,p),await ae(u,e)&&o({project:c,title:p,hash:g,position:ce(u),type:ya(u)})},{capture:!0},[e,t,r]),$t(document,"click",i=>{i.target.dataset.userscriptName!==jt&&s()},{capture:!0},[s]),D(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),d(L,null,d("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),d("style",null,oo),d(no,{style:n}),a.map(i=>d(to,{key:v(i.source.project,i.source.title),...i,whiteList:t,delay:e,prefetch:l})))},ya=e=>lt(e)?e.type==="link"?"link":"hashtag":"title";var co=async e=>{let{delay:t=500,whiteList:r=[],watchList:n=(await Zr()).slice(0,100),style:o="",debug:s=!1}=e??{};bn(s);let a=document.createElement("div");a.dataset.userscriptName=jt,document.body.append(a);let l=a.attachShadow({mode:"open"});Ke(d(ao,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(n),style:o}),l)};co({whiteList:["yosider-private","villagepump","shokai","arpla","nishio","motoso","takker","sta"]});var lo="Jump to an unread page";scrapbox.PageMenu.addMenu({title:lo,image:"https://gyazo.com/f74d4fc373248fb2abac31ff1f69b482/raw",onClick:async()=>{let e=scrapbox.Project.name,t=scrapbox.Project.pages.filter(s=>s.exists&&s.title!==scrapbox.Page.title),r=async()=>{let s=t[Math.floor(Math.random()*t.length)].title;return await(await fetch(/api/pages/${e}/${encodeURIComponent(s)})).json()},n=scrapbox.PageMenu(lo);n.removeAllItems(),n.emitChange();let o=0;for(;;){let s=await r(),a=${++o}: /${e}/${s.title};n.addItem({title:a,onClick:()=>{}}),console.log(a);let l=s.lines.find(i=>s.lastAccessed<i.updated);if(l){let i=document.createElement("a");i.href=./${encodeURIComponent(s.title)}#${l.id}`,i.rel="route",document.body.appendChild(i),i.click(),i.remove();return}}}});(async()=>{let{execute:e}=await Promise.resolve().then(()=>(fo(),po));e("yosider-private","AGI","villagepump","programming-notes","yosider-scripts")})();export{ar as scrapBindings}; code:script-mobile.js