mod.jsvar Ne,h,Lt,So,ge,Tt,Nt,Pt,Pe={},St=[],Mo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function K(e,t){for(var r in t)e[r]=t[r];return e}function Mt(e){var t=e.parentNode;t&&t.removeChild(e)}function u(e,t,r){var o,n,s,c={};for(s in t)s=="key"?o=t[s]:s=="ref"?n=t[s]:c[s]=t[s];if(arguments.length>2&&(c.children=arguments.length>3?Ne.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)c[s]===void 0&&(c[s]=e.defaultProps[s]);return Se(e,c,o,n,null)}function Se(e,t,r,o,n){var s={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:n??++Lt};return n==null&&h.vnode!=null&&h.vnode(s),s}function E(e){return e.children}function Me(e,t){this.props=e,this.context=t}function te(e,t){if(t==null)return e.__?te(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"?te(e):null}function Ct(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 Ct(e)}}function et(e){(!e.__d&&(e.__d=!0)&&ge.push(e)&&!Ce.__r++||Nt!==h.debounceRendering)&&((Nt=h.debounceRendering)||Tt)(Ce)}function Ce(){for(var e;Ce.__r=ge.length;)e=ge.sort(function(t,r){return t.__v.__b-r.__v.__b}),ge=[],e.some(function(t){var r,o,n,s,c,a;t.__d&&(c=(s=(r=t).__v).__e,(a=r.__P)&&(o=[],(n=K({},s)).__v=s.__v+1,tt(a,s,n,r.__n,a.ownerSVGElement!==void 0,s.__h!=null?[c]:null,o,c??te(s),s.__h),Ft(o,s),s.__e!=c&&Ct(s)))})}function It(e,t,r,o,n,s,c,a,i,p){var l,m,g,d,f,b,x,y=o&&o.__k||St,L=y.length;for(r.__k=[],l=0;l<t.length;l++)if((d=r.__k[l]=(d=t[l])==null||typeof d=="boolean"?null:typeof d=="string"||typeof d=="number"||typeof d=="bigint"?Se(null,d,null,null,d):Array.isArray(d)?Se(E,{children:d},null,null,null):d.__b>0?Se(d.type,d.props,d.key,null,d.__v):d)!=null){if(d.__=r,d.__b=r.__b+1,(g=y[l])===null||g&&d.key==g.key&&d.type===g.type)y[l]=void 0;else for(m=0;m<L;m++){if((g=y[m])&&d.key==g.key&&d.type===g.type){y[m]=void 0;break}g=null}tt(e,d,g=g||Pe,n,s,c,a,i,p),f=d.__e,(m=d.ref)&&g.ref!=m&&(x||(x=[]),g.ref&&x.push(g.ref,null,d),x.push(m,d.__c||f,d)),f!=null?(b==null&&(b=f),typeof d.type=="function"&&d.__k===g.__k?d.__d=i=Rt(d,i,e):i=Bt(e,d,g,y,f,i),typeof r.type=="function"&&(r.__d=i)):i&&g.__e==i&&i.parentNode!=e&&(i=te(g))}for(r.__e=b,l=L;l--;)y[l]!=null&&(typeof r.type=="function"&&y[l].__e!=null&&y[l].__e==r.__d&&(r.__d=te(o,l+1)),Dt(y[l],y[l]));if(x)for(l=0;l<x.length;l++)Ht(x[l],x[++l],x[++l])}function Rt(e,t,r){for(var o,n=e.__k,s=0;n&&s<n.length;s++)(o=n[s])&&(o.__=e,t=typeof o.type=="function"?Rt(o,t,r):Bt(r,o,o,n,o.__e,t));return t}function Bt(e,t,r,o,n,s){var c,a,i;if(t.__d!==void 0)c=t.__d,t.__d=void 0;else if(r==null||n!=s||n.parentNode==null)e:if(s==null||s.parentNode!==e)e.appendChild(n),c=null;else{for(a=s,i=0;(a=a.nextSibling)&&i<o.length;i+=2)if(a==n)break e;e.insertBefore(n,s),c=s}return c!==void 0?c:n.nextSibling}function Co(e,t,r,o,n){var s;for(s in r)s==="children"||s==="key"||s in t||Ie(e,s,null,r[s],o);for(s in t)n&&typeof t[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||r[s]===t[s]||Ie(e,s,t[s],r[s],o)}function jt(e,t,r){t[0]==="-"?e.setProperty(t,r):e[t]=r==null?"":typeof r!="number"||Mo.test(t)?r:r+"px"}function Ie(e,t,r,o,n){var s;e:if(t==="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)r&&t in r||jt(e.style,t,"");if(r)for(t in r)o&&r[t]===o[t]||jt(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?o||e.addEventListener(t,s?$t:Ot,s):e.removeEventListener(t,s?$t:Ot,s);else if(t!=="dangerouslySetInnerHTML"){if(n)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 Ot(e){this.l[e.type+!1](h.event?h.event(e):e)}function $t(e){this.l[e.type+!0](h.event?h.event(e):e)}function tt(e,t,r,o,n,s,c,a,i){var p,l,m,g,d,f,b,x,y,L,A,R=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(i=r.__h,a=t.__e=r.__e,t.__h=null,s=[a]),(p=h.__b)&&p(t);try{e:if(typeof R=="function"){if(x=t.props,y=(p=R.contextType)&&o[p.__c],L=p?y?y.props.value:p.__:o,r.__c?b=(l=t.__c=r.__c).__=l.__E:("prototype"in R&&R.prototype.render?t.__c=l=new R(x,L):(t.__c=l=new Me(x,L),l.constructor=R,l.render=Ro),y&&y.sub(l),l.props=x,l.state||(l.state={}),l.context=L,l.__n=o,m=l.__d=!0,l.__h=[]),l.__s==null&&(l.__s=l.state),R.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=K({},l.__s)),K(l.__s,R.getDerivedStateFromProps(x,l.__s))),g=l.props,d=l.state,m)R.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(R.getDerivedStateFromProps==null&&x!==g&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(x,L),!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(x,l.__s,L)===!1||t.__v===r.__v){l.props=x,l.state=l.__s,t.__v!==r.__v&&(l.__d=!1),l.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(U){U&&(U.__=t)}),l.__h.length&&c.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(x,l.__s,L),l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(g,d,f)})}l.context=L,l.props=x,l.state=l.__s,(p=h.__r)&&p(t),l.__d=!1,l.__v=t,l.__P=e,p=l.render(l.props,l.state,l.context),l.state=l.__s,l.getChildContext!=null&&(o=K(K({},o),l.getChildContext())),m||l.getSnapshotBeforeUpdate==null||(f=l.getSnapshotBeforeUpdate(g,d)),A=p!=null&&p.type===E&&p.key==null?p.props.children:p,It(e,Array.isArray(A)?A:[A],t,r,o,n,s,c,a,i),l.base=t.__e,t.__h=null,l.__h.length&&c.push(l),b&&(l.__E=l.__=null),l.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=Io(r.__e,t,r,o,n,s,c,i);(p=h.diffed)&&p(t)}catch(U){t.__v=null,(i||s!=null)&&(t.__e=a,t.__h=!!i,s[s.indexOf(a)]=null),h.__e(U,t,r)}}function Ft(e,t){h.__c&&h.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(o){o.call(r)})}catch(o){h.__e(o,r.__v)}})}function Io(e,t,r,o,n,s,c,a){var i,p,l,m=r.props,g=t.props,d=t.type,f=0;if(d==="svg"&&(n=!0),s!=null){for(;f<s.length;f++)if((i=s[f])&&"setAttribute"in i==!!d&&(d?i.localName===d:i.nodeType===3)){e=i,s[f]=null;break}}if(e==null){if(d===null)return document.createTextNode(g);e=n?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,g.is&&g),s=null,a=!1}if(d===null)m===g||a&&e.data===g||(e.data=g);else{if(s=s&&Ne.call(e.childNodes),p=(m=r.props||Pe).dangerouslySetInnerHTML,l=g.dangerouslySetInnerHTML,!a){if(s!=null)for(m={},f=0;f<e.attributes.length;f++)m[e.attributes[f].name]=e.attributes[f].value;(l||p)&&(l&&(p&&l.__html==p.__html||l.__html===e.innerHTML)||(e.innerHTML=l&&l.__html||""))}if(Co(e,g,m,n,a),l)t.__k=[];else if(f=t.props.children,It(e,Array.isArray(f)?f:[f],t,r,o,n&&d!=="foreignObject",s,c,s?s[0]:r.__k&&te(r,0),a),s!=null)for(f=s.length;f--;)s[f]!=null&&Mt(s[f]);a||("value"in g&&(f=g.value)!==void 0&&(f!==m.value||f!==e.value||d==="progress"&&!f)&&Ie(e,"value",f,m.value,!1),"checked"in g&&(f=g.checked)!==void 0&&f!==e.checked&&Ie(e,"checked",f,m.checked,!1))}return e}function Ht(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(o){h.__e(o,r)}}function Dt(e,t,r){var o,n;if(h.unmount&&h.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||Ht(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){h.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)o[n]&&Dt(o[n],t,typeof e.type!="function");r||e.__e==null||Mt(e.__e),e.__e=e.__d=void 0}function Ro(e,t,r){return this.constructor(e,r)}function Re(e,t,r){var o,n,s;h.__&&h.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],tt(t,e=(!o&&r||t).__k=u(E,null,[e]),n||Pe,Pe,t.ownerSVGElement!==void 0,!o&&r?[r]:n?null:t.firstChild?Ne.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o),Ft(s,e)}function rt(e,t){var r={__c:t="__cC"+Pt++,__:e,Consumer:function(o,n){return o.children(n)},Provider:function(o){var n,s;return this.getChildContext||(n=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(c){this.props.value!==c.value&&n.some(et)},this.sub=function(c){n.push(c);var a=c.componentWillUnmount;c.componentWillUnmount=function(){n.splice(n.indexOf(c),1),a&&a.call(c)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}Ne=St.slice,h={__e:function(e,t){for(var r,o,n;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(e)),n=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e),n=r.__d),n)return r.__E=r}catch(s){e=s}throw e}},Lt=0,So=function(e){return e!=null&&e.constructor===void 0},Me.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=K({},this.state),typeof e=="function"&&(e=e(K({},r),this.props)),e&&K(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),et(this))},Me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),et(this))},Me.prototype.render=E,ge=[],Tt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ce.__r=0,Pt=0;var re,B,At,he=0,ot=[],Ut=h.__b,qt=h.__r,zt=h.diffed,Kt=h.__c,Gt=h.unmount;function be(e,t){h.__h&&h.__h(B,e,he||t),he=0;var r=B.__H||(B.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function P(e){return he=1,Bo(Xt,e)}function Bo(e,t,r){var o=be(re++,2);return o.t=e,o.__c||(o.__=[r?r(t):Xt(void 0,t),function(n){var s=o.t(o.__[0],n);o.__[0]!==s&&(o.__=[s,o.__[1]],o.__c.setState({}))}],o.__c=B),o.__}function $(e,t){var r=be(re++,3);!h.__s&&st(r.__H,t)&&(r.__=e,r.__H=t,B.__H.__h.push(r))}function Be(e,t){var r=be(re++,4);!h.__s&&st(r.__H,t)&&(r.__=e,r.__H=t,B.__h.push(r))}function oe(e){return he=5,v(function(){return{current:e}},[])}function v(e,t){var r=be(re++,7);return st(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function O(e,t){return he=8,v(function(){return e},t)}function G(e){var t=B.context[e.__c],r=be(re++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(B)),t.props.value):e.__}function jo(){var e;for(ot.sort(function(t,r){return t.__v.__b-r.__v.__b});e=ot.pop();)if(e.__P)try{e.__H.__h.forEach(je),e.__H.__h.forEach(nt),e.__H.__h=[]}catch(t){e.__H.__h=[],h.__e(t,e.__v)}}h.__b=function(e){B=null,Ut&&Ut(e)},h.__r=function(e){qt&&qt(e),re=0;var t=(B=e.__c).__H;t&&(t.__h.forEach(je),t.__h.forEach(nt),t.__h=[])},h.diffed=function(e){zt&&zt(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(ot.push(t)!==1&&At===h.requestAnimationFrame||((At=h.requestAnimationFrame)||function(r){var o,n=function(){clearTimeout(s),Wt&&cancelAnimationFrame(o),setTimeout(r)},s=setTimeout(n,100);Wt&&(o=requestAnimationFrame(n))})(jo)),B=null},h.__c=function(e,t){t.some(function(r){try{r.__h.forEach(je),r.__h=r.__h.filter(function(o){return!o.__||nt(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],h.__e(o,r.__v)}}),Kt&&Kt(e,t)},h.unmount=function(e){Gt&&Gt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{je(o)}catch(n){t=n}}),t&&h.__e(t,r.__v))};var Wt=typeof requestAnimationFrame=="function";function je(e){var t=B,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),B=t}function nt(e){var t=B;e.__c=e.__(),B=t}function st(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==e[o]})}function Xt(e,t){return typeof t=="function"?t(e):t}var w=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var $o=e=>typeof e=="object"&&e!==null,Fo=e=>$o(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Vt=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Fo(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var ne=class extends Error{constructor(t){super(`${t.status} ${t.statusText} when fetching ${t.url}`);this.response=t;this.name="UnexpectedResponseError";Error.captureStackTrace&&Error.captureStackTrace(this,ne)}},N=async e=>{let t=e.clone(),r=await t.text(),o=Vt(r);if(!o)throw new ne(t);return{ok:!1,value:o}};var T=e=>`connect.sid=${e}`;var j=e=>e.replaceAll(" ","_").toLowerCase();var S=e=>[...e].map((t,r)=>t===" "?"_":!Ho.includes(t)||r===e.length-1&&Do.includes(t)?encodeURIComponent(t):t).join(""),Ho='@$&+=:;",',Do=':;",';var Yt=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:c}=w(r??{}),a=new URLSearchParams;a.append("followRename",`${s??!0}`);for(let p of c??[])a.append("projects",p);let i=`https://${n}/api/pages/${e}/${S(t)}?${a.toString()}`;return new Request(i,o?{headers:{Cookie:T(o)}}:void 0)},Qt=async e=>{if(!e.ok)return e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:N(e);let t=await e.json();return{ok:!0,value:t}},se=async(e,t,r)=>{let{fetch:o}=w(r??{}),n=Yt(e,t,r),s=await o(n);return await Qt(s)};se.toRequest=Yt;se.fromResponse=Qt;var Jt=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:c}=w(t??{}),a=new URLSearchParams;n!==void 0&&a.append("sort",n),s!==void 0&&a.append("limit",`${s}`),c!==void 0&&a.append("skip",`${c}`);let i=`https://${o}/api/pages/${e}?${a.toString()}`;return new Request(i,r?{headers:{Cookie:T(r)}}:void 0)},Zt=async e=>{if(!e.ok)return N(e);let t=await e.json();return{ok:!0,value:t}},er=async(e,t)=>{let{fetch:r}=w(t??{}),o=await r(Jt(e,t));return await Zt(o)};er.toRequest=Jt;er.fromResponse=Zt;var tr=(e,t,r,o)=>{let{sid:n,hostName:s}=w(o??{}),c=`https://${s}/api/table/${e}/${S(t)}/${encodeURIComponent(r)}.csv`;return new Request(c,n?{headers:{Cookie:T(n)}}:void 0)},rr=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:N(e),or=async(e,t,r,o)=>{let{fetch:n}=w(o??{}),s=tr(e,t,r,o),c=await n(s);return await rr(c)};or.toRequest=tr;or.fromResponse=rr;var nr=(e,t)=>{let{sid:r,hostName:o}=w(t??{});return new Request(`https://${o}/api/projects/${e}`,r?{headers:{Cookie:T(r)}}:void 0)},sr=async e=>{if(!e.ok)return N(e);let t=await e.json();return{ok:!0,value:t}},xe=async(e,t)=>{let{fetch:r}=w(t??{}),o=nr(e,t),n=await r(o);return sr(n)};xe.toRequest=nr;xe.fromResponse=sr;var ir=(e,t)=>{let{sid:r,hostName:o}=w(t??{}),n=new URLSearchParams;for(let s of e)n.append("ids",s);return new Request(`https://${o}/api/projects?${n.toString()}`,r?{headers:{Cookie:T(r)}}:void 0)},ar=async e=>{if(!e.ok)return N(e);let t=await e.json();return{ok:!0,value:t}},Oe=async(e,t)=>{let{fetch:r}=w(t??{}),o=await r(ir(e,t));return ar(o)};Oe.toRequest=ir;Oe.fromResponse=ar;var cr=(e,t,r,o)=>{let{sid:n,hostName:s}=w(o??{}),c=`https://${s}/api/code/${e}/${S(t)}/${S(r)}`;return new Request(c,n?{headers:{Cookie:T(n)}}:void 0)},lr=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"}}:N(e),pr=async(e,t,r,o)=>{let{fetch:n}=w(o??{}),s=cr(e,t,r,o),c=await n(s);return await lr(c)};pr.toRequest=cr;pr.fromResponse=lr;var ur=new TextEncoder().encode("0123456789abcdef");function dr(e){let t=new Uint8Array(e.length*2);for(let r=0;r<t.length;r++){let o=e[r];t[r*2]=ur[o>>4],t[r*2+1]=ur[o&15]}return t}var fr="md5: `data` is invalid type",Q=64,it=class{#e;#t;#r;#o;#n;#i;#s;#a;constructor(){this.#e=1732584193,this.#t=4023233417,this.#r=2562383102,this.#o=271733878,this.#n=new Uint8Array(Q),this.#i=0,this.#s=0,this.#a=0}#l(t){let r=this.#s;r+=t,r>4294967295&&(this.#a+=1),this.#s=r>>>0}#c(t){let r=this.#e,o=this.#t,n=this.#r,s=this.#o,c=Y=>t[Y]|t[Y+1]<<8|t[Y+2]<<16|t[Y+3]<<24,a=(Y,Et)=>Y<<Et|Y>>>32-Et,i=c(0),p=c(4),l=c(8),m=c(12),g=c(16),d=c(20),f=c(24),b=c(28),x=c(32),y=c(36),L=c(40),A=c(44),R=c(48),U=c(52),Le=c(56),Te=c(60);r=o+a(((n^s)&o^s)+r+i+3614090360,7),s=r+a(((o^n)&r^n)+s+p+3905402710,12),n=s+a(((r^o)&s^o)+n+l+606105819,17),o=n+a(((s^r)&n^r)+o+m+3250441966,22),r=o+a(((n^s)&o^s)+r+g+4118548399,7),s=r+a(((o^n)&r^n)+s+d+1200080426,12),n=s+a(((r^o)&s^o)+n+f+2821735955,17),o=n+a(((s^r)&n^r)+o+b+4249261313,22),r=o+a(((n^s)&o^s)+r+x+1770035416,7),s=r+a(((o^n)&r^n)+s+y+2336552879,12),n=s+a(((r^o)&s^o)+n+L+4294925233,17),o=n+a(((s^r)&n^r)+o+A+2304563134,22),r=o+a(((n^s)&o^s)+r+R+1804603682,7),s=r+a(((o^n)&r^n)+s+U+4254626195,12),n=s+a(((r^o)&s^o)+n+Le+2792965006,17),o=n+a(((s^r)&n^r)+o+Te+1236535329,22),r=o+a(((o^n)&s^n)+r+p+4129170786,5),s=r+a(((r^o)&n^o)+s+f+3225465664,9),n=s+a(((s^r)&o^r)+n+A+643717713,14),o=n+a(((n^s)&r^s)+o+i+3921069994,20),r=o+a(((o^n)&s^n)+r+d+3593408605,5),s=r+a(((r^o)&n^o)+s+L+38016083,9),n=s+a(((s^r)&o^r)+n+Te+3634488961,14),o=n+a(((n^s)&r^s)+o+g+3889429448,20),r=o+a(((o^n)&s^n)+r+y+568446438,5),s=r+a(((r^o)&n^o)+s+Le+3275163606,9),n=s+a(((s^r)&o^r)+n+m+4107603335,14),o=n+a(((n^s)&r^s)+o+x+1163531501,20),r=o+a(((o^n)&s^n)+r+U+2850285829,5),s=r+a(((r^o)&n^o)+s+l+4243563512,9),n=s+a(((s^r)&o^r)+n+b+1735328473,14),o=n+a(((n^s)&r^s)+o+R+2368359562,20),r=o+a((o^n^s)+r+d+4294588738,4),s=r+a((r^o^n)+s+x+2272392833,11),n=s+a((s^r^o)+n+A+1839030562,16),o=n+a((n^s^r)+o+Le+4259657740,23),r=o+a((o^n^s)+r+p+2763975236,4),s=r+a((r^o^n)+s+g+1272893353,11),n=s+a((s^r^o)+n+b+4139469664,16),o=n+a((n^s^r)+o+L+3200236656,23),r=o+a((o^n^s)+r+U+681279174,4),s=r+a((r^o^n)+s+i+3936430074,11),n=s+a((s^r^o)+n+m+3572445317,16),o=n+a((n^s^r)+o+f+76029189,23),r=o+a((o^n^s)+r+y+3654602809,4),s=r+a((r^o^n)+s+R+3873151461,11),n=s+a((s^r^o)+n+Te+530742520,16),o=n+a((n^s^r)+o+l+3299628645,23),r=o+a((n^(o|~s))+r+i+4096336452,6),s=r+a((o^(r|~n))+s+b+1126891415,10),n=s+a((r^(s|~o))+n+Le+2878612391,15),o=n+a((s^(n|~r))+o+d+4237533241,21),r=o+a((n^(o|~s))+r+R+1700485571,6),s=r+a((o^(r|~n))+s+m+2399980690,10),n=s+a((r^(s|~o))+n+L+4293915773,15),o=n+a((s^(n|~r))+o+p+2240044497,21),r=o+a((n^(o|~s))+r+x+1873313359,6),s=r+a((o^(r|~n))+s+Te+4264355552,10),n=s+a((r^(s|~o))+n+f+2734768916,15),o=n+a((s^(n|~r))+o+U+1309151649,21),r=o+a((n^(o|~s))+r+g+4149444226,6),s=r+a((o^(r|~n))+s+A+3174756917,10),n=s+a((r^(s|~o))+n+l+718787259,15),o=n+a((s^(n|~r))+o+y+3951481745,21),this.#e=this.#e+r>>>0,this.#t=this.#t+o>>>0,this.#r=this.#r+n>>>0,this.#o=this.#o+s>>>0}update(t){let r;if(typeof t=="string")r=new TextEncoder().encode(t);else if(typeof t=="object")if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new Uint8Array(t);else throw new TypeError(fr);else throw new TypeError(fr);let o=this.#i,n=Q-o;if(r.length<n)this.#n.set(r,o),o+=r.length;else{this.#n.set(r.slice(0,n),o),this.#c(this.#n);let s=n;for(;s+Q<=r.length;)this.#c(r.slice(s,s+Q)),s+=Q;this.#n.fill(0).set(r.slice(s),0),o=r.length-s}return this.#i=o,this.#l(r.length),this}digest(){let t=Q-this.#i;t<9&&(t+=Q);let r=new Uint8Array(t);r[0]=128;let o=this.#s<<3,n=this.#a<<3|this.#s>>>29;r[r.length-8]=o&255,r[r.length-7]=o>>>8&255,r[r.length-6]=o>>>16&255,r[r.length-5]=o>>>24&255,r[r.length-4]=n&255,r[r.length-3]=n>>>8&255,r[r.length-2]=n>>>16&255,r[r.length-1]=n>>>24&255,this.update(r.buffer);let s=new ArrayBuffer(16),c=new DataView(s);return c.setUint32(0,this.#e,!0),c.setUint32(4,this.#t,!0),c.setUint32(8,this.#r,!0),c.setUint32(12,this.#o,!0),s}toString(t="hex"){let r=this.digest();switch(t){case"hex":return new TextDecoder().decode(dr(new Uint8Array(r)));case"base64":{let o=new Uint8Array(r),n="";for(let s=0;s<o.length;++s)n+=String.fromCharCode(o[s]);return btoa(n)}default:throw new Error("md5: invalid format")}}};var J=e=>new Promise(t=>setTimeout(()=>t(),e));var Ao=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Uo=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,qo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,zo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,mr=e=>{if(Ao.test(e)){let t=new URL(e).searchParams,r=t.get("v");if(r)return{pathType:"com",videoId:r,params:t}}{let t=e.match(Uo);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(qo);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(zo);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Ko=/https?:\/\/vimeo\.com\/([0-9]+)/i,gr=e=>{let t=e.match(Ko);if(!!t)return t[1]};var Go=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,hr=e=>{let t=e.match(Go);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var Wo=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,br=e=>{let t=e.match(Wo);if(!t)return;let[,r]=t;return r};var xr=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let c=mr(n);if(c)return{type:"youtube",href:n,...c,...s};let a=gr(n);if(a)return{type:"vimeo",videoId:a,href:n,...s};let i=hr(n);if(i)return{type:"spotify",href:n,...i,...s};let p=br(n);if(p)return{type:"anchor-fm",videoId:p,href:n,...s};if(Vo(n))return{type:"video",href:n,...s}}return Xo(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},Xo=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),Vo=e=>/\.(?:mp4|webm)$/.test(e);var yr=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,c])=>c-s).map(([s])=>s),o=await Oe([]);if(!o.ok)return r;let n=o.value.projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var _r;(function(e){})(_r||(_r={}));var Yo="0.13.3",kr,vr=async(e=Yo)=>{let t=`https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js`;if(document.querySelector(`script[src="${t}"]`))return window.katex!==void 0?Promise.resolve(window.katex):await new Promise(o=>{let n=setInterval(()=>{window.katex!==void 0&&(clearInterval(n),o(window.katex))},500)});let r=document.createElement("script");return r.src=t,kr??=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>n(s),document.head.append(r)}),kr};var ye=(e,t={})=>{let r=oe(null),[o,n]=P(e),[s,c]=P("");return $(()=>{(async()=>{let{render:a}=await vr();if(!!r.current)try{a(o,r.current,t),c("")}catch(i){if(i instanceof Error&&i.name==="ParseError")c(i.message.slice("KaTeX parse error: ".length));else throw i}})()},[o]),{ref:r,error:s,setFormula:n}};var wr=!1;scrapbox.addListener("lines:changed",()=>wr=!1);scrapbox.addListener("layout:changed",()=>wr=!1);var Er=(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 Er(e,"textarea#text-input"),e};var at=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_${j(e.to.title)}`]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var Tr=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}};var Nr=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 on=new Map,Jp=new Map;scrapbox.on("layout:changed",()=>{let e=ie();if(!!e)for(let[t,r]of on)for(let[o,n]of r)for(let s of n)e.addEventListener(t,o,Nr(s))});var nn=e=>({type:"title",text:e.rows[0].text}),sn=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(c=>c.text.substring(o+1)).join(`
`)}},M=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,c)=>{var a,i,p,l,m,g;if(!t&&s.nested)return(a=c?.())!==null&&a!==void 0?a:[];if(!r&&s.quoted)return(i=c?.())!==null&&i!==void 0?i:[];for(let d of o){let f=d.exec(n);if(f===null)continue;let b=n.substring(0,f.index),x=n.substring(f.index+((l=(p=f[0])===null||p===void 0?void 0:p.length)!==null&&l!==void 0?l:0)),y=e((m=f[0])!==null&&m!==void 0?m:"",s);return[...W(b,s),...y,...W(x,s)]}return(g=c?.())!==null&&g!==void 0?g:[]},I=e=>[{type:"plain",raw:e,text:e}],an=M(I,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),cn=/^>.*$/,ln=(e,t)=>t.context==="table"?I(e,t):[{type:"quote",raw:e,nodes:W(e.substring(1),{...t,quoted:!0})}],pn=M(ln,{parseOnNested:!1,parseOnQuoted:!1,patterns:[cn]}),un=/^\? .+$/,dn=(e,t)=>t.context==="table"?I(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],fn=M(dn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[un]}),mn=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,gn=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,hn=(e,t)=>{if(t.context==="table")return I(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?`${r}/thumb/1000`:r}]},bn=M(hn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[mn,gn]}),xn=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function Pr(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return I(t,r);let o=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),n=o.lastIndexOf(".icon"),s=o.substring(0,n),c=s.startsWith("/")?"root":"relative",a=o.substring(n+5,o.length),i=a.startsWith("*")?parseInt(a.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:s,pathType:c,type:e,raw:t}))}}var yn=Pr("icon"),_n=M(yn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[xn]}),kn=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,vn=Pr("strongIcon"),wn=M(vn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[kn]}),En=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Ln=(e,t)=>t.context==="table"?I(e,t):[{type:"strong",raw:e,nodes:W(e.substring(2,e.length-2),{...t,nested:!0})}],Tn=M(Ln,{parseOnNested:!1,parseOnQuoted:!0,patterns:[En]}),Nn=/\[\$ .+? \]/,Pn=/\[\$ [^\]]+\]/,Sn=(e,t)=>t.context==="table"?I(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Mn=M(Sn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Nn,Pn]}),Cn=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,In=(e,t)=>{if(t.context==="table")return I(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let c=o.split("*").length-1;s.delete("*"),s.add(`*-${Math.min(c,10)}`)}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:W(n,{...t,nested:!0})}]},Rn=M(In,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Cn]}),Bn=/`.*?`/,jn=(e,t)=>t.context==="table"?I(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],On=M(jn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Bn]}),$n=/^[$%] .+$/,Fn=(e,t)=>{var r;if(t.context==="table")return I(e,t);let o=(r=e[0])!==null&&r!==void 0?r:"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:o,text:n}]},Hn=M(Fn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[$n]}),Dn=/\[\s+\]/,An=(e,t)=>t.context==="table"?I(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Un=M(An,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Dn]}),qn=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,zn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Kn=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,Gn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,Wn=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||Xn(e),Xn=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),Vn=(e,t)=>{if(t.context==="table")return I(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).trimLeft():"",[s,c]=Wn(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?`${s}/thumb/1000`:s,link:c}]},Yn=M(Vn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[qn,zn,Kn,Gn]}),Qn=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,Jn=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,Zn=/\[https?:\/\/[^\s\]]+\]/,es=/https?:\/\/[^\s]+/,ts=(e,t)=>{if(t.context==="table")return I(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},rs=M(ts,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Qn,Jn,Zn,es]}),Sr=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Mr=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,os=e=>{let[t="",r="",o=""]=e.split(","),n=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),c=/^Z\d+$/.test(o)?parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:c}},ns=(e,t)=>{var r;if(t.context==="table")return I(e,t);let o=(r=e.match(Sr))!==null&&r!==void 0?r:e.match(Mr);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",c=""]=n?o:[o[0],o[2],o[1]],{latitude:a,longitude:i,zoom:p}=os(s),l=c!==""?`https://www.google.com/maps/place/${encodeURIComponent(c)}/@${a},${i},${p}z`:`https://www.google.com/maps/@${a},${i},${p}z`;return[{type:"googleMap",raw:e,latitude:a,longitude:i,zoom:p,place:c,url:l}]},ss=M(ns,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Sr,Mr]}),is=/\[\/?[^[\]]+\]/,as=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},cs=M(as,{parseOnNested:!0,parseOnQuoted:!0,patterns:[is]}),ls=/(?:^|\s)#\S+/,ps=(e,t)=>{if(t.context==="table")return I(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...I(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},us=M(ps,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ls]}),ds=/^[0-9]+\. .*$/,fs=(e,t)=>{if(t.context==="table")return I(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:W(s,{...t,nested:!0})}]},ms=M(fs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ds]}),gs=(e,t,r)=>{var o;return e===""?[]:(o=r?.())!==null&&o!==void 0?o:[]},hs=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>an(t,r))(),W=hs(gs,pn,fn,On,Hn,Mn,Un,Rn,bn,wn,Tn,Yn,rs,_n,ss,cs,us,ms),bs=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(c=>c.text.substring(o+1)).map(c=>c.split(" ").map(a=>W(a,{nested:!1,quoted:!1,context:"table"})))}},xs=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:W(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},ys=e=>{switch(e.type){case"title":return nn(e);case"codeBlock":return sn(e);case"table":return bs(e);case"line":return xs(e)}},_s=e=>e.split(`
`).map(t=>{var r,o,n;return{indent:(n=(o=(r=/^\s+/.exec(t))===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.length)!==null&&n!==void 0?n:0,text:t}}),ks=(e,t)=>{var r,o;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((o=(r=e.rows[0])===null||r===void 0?void 0:r.indent)!==null&&o!==void 0?o:0)},Cr=(e,t)=>{let r=e[e.length-1];return r!==void 0&&ks(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)},vs=(e,t)=>{var r;if(!((r=t.hasTitle)!==null&&r!==void 0)||r){let[o,...n]=e;return o===void 0?[]:[{type:"title",rows:[o]},...n.reduce(Cr,[])]}return e.reduce(Cr,[])},_e=(e,t)=>{var r;let o=_s(e);return vs(o,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(ys)};var Ir=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let c=s[0]().finally(()=>o(c)).then(a=>s[1](a)).catch(a=>s[2](a));r.add(c)};return n=>{if(r.size<e){let s=n().finally(()=>o(s));return r.add(s),s}return new Promise((s,c)=>{t.push([n,s,c])})}};var ws="0.6.5",Rr=`ScrapBubble-${ws}`,Br=await globalThis.caches.open(Rr);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Rr&&(await globalThis.caches.delete(e),console.log(`[ScrapBubble] deleted old cache :"${e}"`))})();var jr=Ir(3);async function*Fe(e,t){let r=((t?.saveFailedResponse?Br.match(e):void 0)??Tr(e,t)).then(c=>["cache",c]);{let c=J(1e3).then(()=>"timeout"),a=await Promise.race([r,c]);if(a!=="timeout"){a[1]&&(yield["cache",a[1]]);let i=await jr(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await Br.put(e,i.clone()),yield["network",i]}}let o=jr(()=>fetch(e)).then(c=>["network",c]),[n,s]=await Promise.race([r,o]);if(n==="network"){yield[n,s];return}s&&(yield[n,s]),yield await o}var Or=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var He=()=>{let e=new Map;return{dispatch:(t,r)=>{let o=e.get(t);if(!!o)for(let n of o)n(r)},on:(t,r)=>{let o=e.get(t)??new Set;o.add(r),e.set(t,o)},off:(t,r)=>{let o=e.get(t);!o||o.delete(r)}}};var F=!1,$r=e=>{F=typeof e=="boolean"?e:new Set(e)},X=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(`%c${e}`,"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{F!==!0&&(!F||!F.has(e))||r(`%c${e}`,"color: gray",...o)}];case"assert":return[t,(o,...n)=>{F!==!0&&(!F||!F.has(e))||r(o,`%c${e}`,"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{F!==!0&&(!F||!F.has(e))||r(`${e} ${o}`)}];default:return[t,(...o)=>{if(!(F!==!0&&(!F||!F.has(e))))return r(...o)}]}}));var ct=He(),De=new Map,Es=X("ScrapBubble:useProject.ts"),Fr=e=>{let[t,r]=P();return $(()=>{ct.on(e,r);let o=De.get(e);return o?r(o.loading?void 0:o.value):(De.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=xe.toRequest(e);for await(let[,s]of Fe(n)){let c=await xe.fromResponse(s);De.set(e,{loading:!1,value:c}),ct.dispatch(e,c);break}}catch(n){Es.error(n),De.delete(e)}})()),()=>ct.off(e,r)},[e]),t};var Ls=["default-light","default-dark","default-minimal"],Ts=["paper-light","paper-dark-dark","paper-dark"],Hr=["blue","purple","green","orange","red"],Ns=["hacker1","hacker2"],Dr=["winter","spring","summer","automn"],Ar=["tropical"],Ur=["kyoto","newyork","paris"],qr=["mred","lgreen"],Hu=["default-light","default-minimal","paper-light",...Hr,...Dr,...Ar,...Ur,...qr];var Ps=[...Ls,...Ts,...Hr,...Ns,...Dr,...Ar,...Ur,...qr];function zr(e){return Ps.includes(e)}var Kr="default-light",Z=e=>{let t=Fr(e);return v(()=>{if(!t||!t.ok)return Kr;let r=t.value.theme;return zr(r)?r:Kr},[t])};var ae=(e,t)=>new Promise(r=>{let o=!1,n=()=>{o=!0,r(!1)};e.addEventListener("click",n),e.addEventListener("pointerleave",n),setTimeout(()=>{o||r(!0),e.removeEventListener("click",n),e.removeEventListener("pointerleave",n),r(!1)},t)});var ce=e=>{let{top:t,right:r,left:o,bottom:n}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),c=(o-s.left)/s.width>.5;return{top:Math.round(n-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...c?{right:Math.round(s.right-r)}:{left:Math.round(o-s.left)},maxWidth:c?r-10:document.documentElement.clientWidth-o-10}};var Gr=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:c,prefetch:a})=>{let i=v(()=>o?[]:_e(r.join(`
`),{hasTitle:!1}),[o,r]),p=Z(e),l=O(async({currentTarget:g})=>{a(e,t),!!await ae(g,c)&&s({project:e,title:t,linkTo:n,type:"link",position:ce(g)})},[e,t,c,n?.project,n?.titleLc]),m=v(()=>n?()=>{at({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return u("a",{className:"related-page-card page-link",type:"link","data-theme":p,href:`/${e}/${S(t)}`,rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:l,onClick:m},u("div",{class:"hover"}),u("div",{class:"content"},u("div",{class:"header"},u("div",{class:"title"},t)),o?u("div",{class:"thumbnail"},u("img",{src:o})):u("div",{class:"description"},i.flatMap((g,d)=>g.type==="line"?[u("p",{key:d},g.nodes.map(f=>u(Wr,{node:f,project:e})))]:[]))))},Wr=({node:e,project:t})=>{switch(e.type){case"code":return u("code",null,e.text);case"formula":return u(Ss,{node:e});case"commandLine":return u("code",null,e.symbol," $",e.text);case"helpfeel":return u("code",null,"? ",e.text);case"quote":case"strong":case"decoration":return u(E,null,e.nodes.map(r=>u(Wr,{node:r,project:t})));case"icon":case"strongIcon":return u(Ms,{node:e,project:t});case"hashTag":return u(Cs,{node:e});case"link":return u(Is,{node:e});case"plain":case"blank":return u(E,null,e.text);default:return u(E,null)}},Ss=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=ye("");return o(e),u("span",{className:`formula ${r?" error":""}`},r?u("code",null,e):u("span",{className:"katex-display",ref:t}))},Ms=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return u("img",{class:"icon",src:`/api/pages/${o}/${S(n)}/icon`})},Cs=({node:{href:e}})=>u("span",{class:"page-link"},"#",e),Is=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?u("span",{class:"page-link"},t):u("span",{class:"link"},r||t);var k=(e,t)=>`/${e}/${j(t)}`,Ae=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError(`"${e}" cannnot match "/([^/]+)/(.+)"`);return{project:t[1],titleLc:t[2]}};var Xr=Symbol.for("immer-nothing"),Vr=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function D(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var le=Object.getPrototypeOf;function pe(e){return!!e&&!!e[_]}function q(e){return e?Yr(e)||Array.isArray(e)||!!e[Vr]||!!e.constructor?.[Vr]||qe(e)||ze(e):!1}var Rs=Object.prototype.constructor.toString();function Yr(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)===Rs}function ke(e,t){Ue(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,o)=>t(o,r,e))}function Ue(e){let t=e[_];return t?t.type_:Array.isArray(e)?1:qe(e)?2:ze(e)?3:0}function lt(e,t){return Ue(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Qr(e,t,r){let o=Ue(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function Bs(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function qe(e){return e instanceof Map}function ze(e){return e instanceof Set}function C(e){return e.copy_||e.base_}function pt(e,t){if(qe(e))return new Map(e);if(ze(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Yr(e);if(t===!0||t==="class_only"&&!r){let o=Object.getOwnPropertyDescriptors(e);delete o[_];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){let c=n[s],a=o[c];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(o[c]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[c]})}return Object.create(le(e),o)}else{let o=le(e);if(o!==null&&r)return{...e};let n=Object.create(o);return Object.assign(n,e)}}function ut(e,t=!1){return Ke(e)||pe(e)||!q(e)||(Ue(e)>1&&(e.set=e.add=e.clear=e.delete=js),Object.freeze(e),t&&Object.entries(e).forEach(([r,o])=>ut(o,!0))),e}function js(){D(2)}function Ke(e){return Object.isFrozen(e)}var dt={};function ee(e){let t=dt[e];return t||D(0,e),t}function Os(e,t){dt[e]||(dt[e]=t)}var ve;function Ge(){return ve}function $s(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Jr(e,t){t&&(ee("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ft(e){mt(e),e.drafts_.forEach(Fs),e.drafts_=null}function mt(e){e===ve&&(ve=e.parent_)}function Zr(e){return ve=$s(ve,e)}function Fs(e){let t=e[_];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function eo(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[_].modified_&&(ft(t),D(4)),q(e)&&(e=We(t,e),t.parent_||Xe(t,e)),t.patches_&&ee("Patches").generateReplacementPatches_(r[_].base_,e,t.patches_,t.inversePatches_)):e=We(t,r,[]),ft(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Xr?e:void 0}function We(e,t,r){if(Ke(t))return t;let o=t[_];if(!o)return ke(t,(n,s)=>to(e,o,t,n,s,r)),t;if(o.scope_!==e)return t;if(!o.modified_)return Xe(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let n=o.copy_,s=n,c=!1;o.type_===3&&(s=new Set(n),n.clear(),c=!0),ke(s,(a,i)=>to(e,o,n,a,i,r,c)),Xe(e,n,!1),r&&e.patches_&&ee("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function to(e,t,r,o,n,s,c){if(pe(n)){let a=s&&t&&t.type_!==3&&!lt(t.assigned_,o)?s.concat(o):void 0,i=We(e,n,a);if(Qr(r,o,i),pe(i))e.canAutoFreeze_=!1;else return}else c&&r.add(n);if(q(n)&&!Ke(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;We(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,o)&&Xe(e,n)}}function Xe(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ut(t,r)}function Hs(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Ge(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=gt;r&&(n=[o],s=we);let{revoke:c,proxy:a}=Proxy.revocable(n,s);return o.draft_=a,o.revoke_=c,a}var gt={get(e,t){if(t===_)return e;let r=C(e);if(!lt(r,t))return Ds(e,r,t);let o=r[t];return e.finalized_||!q(o)?o:o===ht(e.base_,t)?(bt(e),e.copy_[t]=Ee(o,e)):o},has(e,t){return t in C(e)},ownKeys(e){return Reflect.ownKeys(C(e))},set(e,t,r){let o=ro(C(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=ht(C(e),t),s=n?.[_];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Bs(r,n)&&(r!==void 0||lt(e.base_,t)))return!0;bt(e),z(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 ht(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,bt(e),z(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=C(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){D(11)},getPrototypeOf(e){return le(e.base_)},setPrototypeOf(){D(12)}},we={};ke(gt,(e,t)=>{we[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});we.deleteProperty=function(e,t){return we.set.call(this,e,t,void 0)};we.set=function(e,t,r){return gt.set.call(this,e[0],t,r,e[0])};function ht(e,t){let r=e[_];return(r?C(r):e)[t]}function Ds(e,t,r){let o=ro(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function ro(e,t){if(!(t in e))return;let r=le(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=le(r)}}function z(e){e.modified_||(e.modified_=!0,e.parent_&&z(e.parent_))}function bt(e){e.copy_||(e.copy_=pt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var As=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,o)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let c=this;return function(a=s,...i){return c.produce(a,p=>r.call(this,p,...i))}}typeof r!="function"&&D(6),o!==void 0&&typeof o!="function"&&D(7);let n;if(q(t)){let s=Zr(this),c=Ee(t,void 0),a=!0;try{n=r(c),a=!1}finally{a?ft(s):mt(s)}return Jr(s,o),eo(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===Xr&&(n=void 0),this.autoFreeze_&&ut(n,!0),o){let s=[],c=[];ee("Patches").generateReplacementPatches_(t,n,s,c),o(s,c)}return n}else D(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...c)=>this.produceWithPatches(s,a=>t(a,...c));let o,n;return[this.produce(t,r,(s,c)=>{o=s,n=c}),o,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){q(e)||D(8),pe(e)&&(e=Us(e));let t=Zr(this),r=Ee(e,void 0);return r[_].isManual_=!0,mt(t),r}finishDraft(e,t){let r=e&&e[_];(!r||!r.isManual_)&&D(9);let{scope_:o}=r;return Jr(o,t),eo(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let o=ee("Patches").applyPatches_;return pe(e)?o(e,t):this.produce(e,n=>o(n,t))}};function Ee(e,t){let r=qe(e)?ee("MapSet").proxyMap_(e,t):ze(e)?ee("MapSet").proxySet_(e,t):Hs(e,t);return(t?t.scope_:Ge()).drafts_.push(r),r}function Us(e){return pe(e)||D(10,e),oo(e)}function oo(e){if(!q(e)||Ke(e))return e;let t=e[_],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 ke(r,(o,n)=>{Qr(r,o,oo(n))}),t&&(t.finalized_=!1),r}function no(){class e extends Map{constructor(i,p){super(),this[_]={type_:2,parent_:p,scope_:p?p.scope_:Ge(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return C(this[_]).size}has(i){return C(this[_]).has(i)}set(i,p){let l=this[_];return c(l),(!C(l).has(i)||C(l).get(i)!==p)&&(r(l),z(l),l.assigned_.set(i,!0),l.copy_.set(i,p),l.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let p=this[_];return c(p),r(p),z(p),p.base_.has(i)?p.assigned_.set(i,!1):p.assigned_.delete(i),p.copy_.delete(i),!0}clear(){let i=this[_];c(i),C(i).size&&(r(i),z(i),i.assigned_=new Map,ke(i.base_,p=>{i.assigned_.set(p,!1)}),i.copy_.clear())}forEach(i,p){let l=this[_];C(l).forEach((m,g,d)=>{i.call(p,this.get(g),g,this)})}get(i){let p=this[_];c(p);let l=C(p).get(i);if(p.finalized_||!q(l)||l!==p.base_.get(i))return l;let m=Ee(l,p);return r(p),p.copy_.set(i,m),m}keys(){return C(this[_]).keys()}values(){let i=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let p=i.next();return p.done?p:{done:!1,value:this.get(p.value)}}}}entries(){let i=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let p=i.next();if(p.done)return p;let l=this.get(p.value);return{done:!1,value:[p.value,l]}}}}[Symbol.iterator](){return this.entries()}}function t(a,i){return new e(a,i)}function r(a){a.copy_||(a.assigned_=new Map,a.copy_=new Map(a.base_))}class o extends Set{constructor(i,p){super(),this[_]={type_:3,parent_:p,scope_:p?p.scope_:Ge(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return C(this[_]).size}has(i){let p=this[_];return c(p),p.copy_?!!(p.copy_.has(i)||p.drafts_.has(i)&&p.copy_.has(p.drafts_.get(i))):p.base_.has(i)}add(i){let p=this[_];return c(p),this.has(i)||(s(p),z(p),p.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let p=this[_];return c(p),s(p),z(p),p.copy_.delete(i)||(p.drafts_.has(i)?p.copy_.delete(p.drafts_.get(i)):!1)}clear(){let i=this[_];c(i),C(i).size&&(s(i),z(i),i.copy_.clear())}values(){let i=this[_];return c(i),s(i),i.copy_.values()}entries(){let i=this[_];return c(i),s(i),i.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(i,p){let l=this.values(),m=l.next();for(;!m.done;)i.call(p,m.value,m.value,this),m=l.next()}}function n(a,i){return new o(a,i)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(i=>{if(q(i)){let p=Ee(i,a);a.drafts_.set(i,p),a.copy_.add(p)}else a.copy_.add(i)}))}function c(a){a.revoked_&&D(3,JSON.stringify(C(a)))}Os("MapSet",{proxyMap_:t,proxySet_:n})}var H=new As,Ve=H.produce,sd=H.produceWithPatches.bind(H),id=H.setAutoFreeze.bind(H),ad=H.setUseStrictShallowCopy.bind(H),cd=H.applyPatches.bind(H),ld=H.createDraft.bind(H),pd=H.finishDraft.bind(H);no();var so=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},io=(e,t)=>Ve(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...c}=t;Object.assign(r,c),xt(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}xt(r)&&!xt(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)}),xt=e=>e.lines[0].id==="dummy";var ao=(e,t)=>{let r=new Map,o=j(t.title);for(let i of t.links){let p=qs(e,i);p.linked=[o],r.set(k(e,i),p)}let n=k(e,o),s=t.projectLinks.map(i=>{let p=Ae(i);return k(p.project,p.titleLc)}),c={...Ye(e,t),linked:[],projectLinked:[]};r.set(n,c);let a=t.links.map(i=>j(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(o)&&c.linked.push(i.titleLc);for(let g of i.linksLc.filter(d=>a.includes(d))){let d=k(e,g),f=r.get(d);if(!f)throw Error(`storage already must have "${d}"`);if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let p=k(e,i.titleLc),l=Ye(e,i),m=r.get(p)?.linked;m&&(l.linked=m),r.set(p,l)}for(let i of t.relatedPages.projectLinks1hop){let p=k(i.projectName,i.titleLc);s.includes(p)||c.projectLinked.push(p);let l=Ye(i.projectName,i),m=r.get(p)?.projectLinked;m&&(l.projectLinked=m),r.set(p,l)}c.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let g of i.linksLc){let d=k(e,g),f=r.get(d);if(!f)throw Error(`storage already must have "${d}"`);if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let p=k(e,i.titleLc),l=Ye(e,i),m=r.get(p)?.linked;m&&(l.linked=m),r.set(p,l)}return r},Ye=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:j(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}),qs=(e,t)=>({project:e,titleLc:j(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var Qe=X("ScrapBubble:bubble.ts"),yt=new Map,Je=new Set,_t=He();function*co(e){for(let t of e)yield yt.get(t)}var lo=(e,t)=>_t.on(e,t),po=(e,t)=>_t.off(e,t),uo=async(e,t,r,o)=>{let n=[];for(let s of[...t].reverse()){let c=k(s,e);Je.has(c)||n.push(zs(s,e,r,o))}await Promise.all(n)},fo=0,zs=async(e,t,r,o)=>{let n=k(e,t);if(Je.has(n))return;Je.add(n);let s=fo++,c=`[${s}] Check update ${n}`;Qe.time(c);try{let a=se.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[i,p]of Fe(a,{ignoreSearch:!0,saveFailedResponse:!0})){Qe.debug(`[${s}]${i} ${n}`);let l=await se.fromResponse(p);if(l.ok){let m=ao(e,l.value);for(let[g,d]of m){let f=yt.get(g),b=io(f,d);!b||f!==b&&(yt.set(g,b),_t.dispatch(g,d))}}if(o?.ignoreFetch===!0||i==="cache"&&!Or(p,o?.maxAge??60))break}}catch(a){Qe.error(a)}finally{Je.delete(n),Qe.timeEnd(c),fo--}};var mo=X("ScrapBubble:useBubbleData.ts"),ue=e=>{let[t,r]=P([]);return Be(()=>{let o=()=>{r(()=>{let c=[...co(e)].flatMap(a=>a?[a]:[]);return mo.debug(`Required: ${e.length} pages, ${c.length} found`,c),c})};o();let n,s=()=>{clearTimeout(n),n=setTimeout(()=>{mo.debug(`Update ${e.length} pages`),o()},10)};return e.forEach(c=>lo(c,s)),()=>e.forEach(c=>po(c,s))},e),t};var go=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=v(()=>[...t.keys(),...r.keys()],[t,r]),c=ue(s),a=v(()=>[...o],[o]),i=v(()=>{let l=(m,g)=>{let d=a.indexOf(m.project),f=a.indexOf(g.project);return d===f?g.updated-m.updated:d<0?1:f<0?-1:d-f};return[...c].sort(l)},[c,a]),p=v(()=>({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 u("ul",{className:"card-bubble",style:p,onClick:n.onClick},i.map(({project:l,titleLc:m,lines:[{text:g}],descriptions:d,image:f})=>{let b=k(l,m),x=t.get(b)??r.get(b);return u("li",{key:b},u(Gr,{project:l,title:g,linkTo:x,descriptions:d,thumbnail:f??"",...n}))}))};var de=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[,o]=r?.match?.(/#([a-f\d]{24,32})$/)??["",""];return r===""?{project:t}:o===""?{project:t,title:r}:{project:t,title:r.slice(0,-1-o.length),hash:o}}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 kt=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&j(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=de({pathType:r.pathType,href:r.href});return o?!n&&j(s)===e.titleLc:n===e.project&&j(s)===e.titleLc}case"quote":case"strong":case"decoration":return kt(e,r.nodes)}});var V=rt({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),ho=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:c,...a})=>{let i=v(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),p=v(()=>{let d=0;return _e(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[d++]};case"codeBlock":{let b=d;return d+=f.content.split(`
`).length+1,{...f,ids:i.slice(b,d)}}case"table":{let b=d;return d+=f.cells.length+1,{...f,ids:i.slice(b,d)}}}})},[e,i]),l=v(()=>{if(s&&i.includes(s))return s;if(!!c)return p.find(d=>d.type!=="line"?!1:kt(c,d.nodes))?.id},[p,i,s,c?.project,c?.titleLc]),m=oe(null);$(()=>{if(!l)return;let d=m.current?.querySelector(`[data-id="${l}"]`),f=globalThis.scrollY;d?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,f)},[l]);let g=Z(t);return u("div",{className:"lines","data-theme":g,ref:m},u(V.Provider,{value:{project:t,title:r,whiteList:o,...a}},p.map(d=>{switch(d.type){case"title":return u(E,null,u(fe,{key:d.id,index:d.id,indent:0,noIndent:n,permalink:d.id===l},u("a",{className:"page-link",type:"link",href:`/${t}/${S(d.text)}`,rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank"},d.text)),u("hr",null));case"codeBlock":return u(Ks,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:l});case"table":return u(Gs,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:l});case"line":return u(fe,{key:d.id,index:d.id,indent:d.indent,noIndent:n,permalink:d.id===l},d.nodes.length>0?d.nodes.map(f=>u(me,{node:f})):u("br",null))}})))},fe=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>u("div",{className:`line${n?" permalink":""}`,"data-id":e,"data-indent":t,style:{"margin-left":r?"":`${1*t}em`}},o),Ks=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:c}=G(V),[a,i]=P(""),p=O(async l=>{l.preventDefault(),l.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 u(E,null,u(fe,{index:o[0],indent:r,permalink:o[0]===n},u("span",{className:"code-block"},u("span",{className:"code-block-start"},u("a",{href:`/api/code/${s}/${S(c)}/${e}`,target:"_blank"},e)),u("span",{className:"copy",title:"Copy",onClick:p},a))),u(E,null,t.split(`
`).map((l,m)=>u(fe,{index:o[m+1],indent:r,permalink:o[m+1]===n},u("code",{className:"code-block"},l)))))},Gs=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:c}=G(V);return u(E,null,u(fe,{index:o[0],indent:r,permalink:o[0]===n},u("span",{className:"table-block"},u("span",{className:"table-block-start"},u("a",{href:`/api/table/${s}/${S(c)}/${e}.csv`,target:"_blank"},e)))),u(E,null,t.map((a,i)=>u(fe,{index:o[i+1],indent:r,permalink:o[i+1]===n},u("span",{className:"table-block table-block-row"},a.map((p,l)=>u("span",{className:`cell col-${l}`},p.map(m=>u(me,{node:m})))))))))},me=({node:e})=>{switch(e.type){case"code":return u("code",{className:"code"},e.text);case"formula":return u(Ws,{node:e});case"commandLine":return u(Vs,{node:e});case"helpfeel":return u("code",{className:"helpfeel"},u("span",{className:"prefix"},"?")," ",u("span",{className:"entry"},e.text));case"quote":return u("blockquote",{className:"quote"},e.nodes.map(t=>u(me,{node:t})));case"strong":return u("strong",null,e.nodes.map(t=>u(me,{node:t})));case"decoration":return u(Xs,{node:e});case"plain":case"blank":return u(E,null,e.text);case"hashTag":return u(Js,{node:e});case"link":return u(Zs,{node:e});case"googleMap":return u(Ys,{node:e});case"icon":return u(bo,{node:e});case"strongIcon":return u(bo,{node:e,strong:!0});case"image":return u(Qs,{node:e});case"strongImage":return u("img",{className:"image strong-image",src:e.src});case"numberList":return u(E,null,`${e.number}. `,e.nodes.map(t=>u(me,{node:t})))}},Ws=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=ye("");return o(e),u("span",{className:`formula ${r?" error":""}`},r?u("code",null,e):u("span",{className:"katex-display",ref:t}))},Xs=({node:{decos:e,nodes:t}})=>u("span",{className:e.map(r=>`deco-${r}`).join(" ")},t.map(r=>u(me,{node:r}))),Vs=({node:e})=>{let[t,r]=P(""),o=O(async n=>{n.preventDefault(),n.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 u(E,null,u("code",{className:"cli"},u("span",{className:"prefix"},e.symbol)," ",u("span",{className:"command"},e.text)),u("span",{className:"tool-buttons"},u("span",{title:"Copy",className:"copy",onClick:o},t)))},Ys=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>u("span",{className:"pointing-device-map"},u("a",{href:`https://www.google.com/maps/search/${e}/@${t},${r},${o}z`,rel:"noopner noreferrer",target:"_blank"},u("img",{className:"google-map",src:`/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${globalThis._csrf}`}))),bo=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=G(V),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],c=S(s);return u("a",{href:`/${n}/${c}`,rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank"},u("img",{className:r?"icon strong-icon":"icon",alt:s,src:`/api/pages/${n}/${c}/icon`},s))},Qs=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-"/thumb/1000".length):t);return u("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},u("img",{className:"image",src:t}))},Js=({node:{href:e}})=>{let{project:t}=G(V),r=xo(t,e),o=yo(t,e,"hashtag");return u("a",{href:`/${t}/${S(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:o},"#",e)},Zs=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return u(ei,{pathType:e,href:t.href});case"absolute":{let r=xr({pathType:e,...t});switch(r.type){case"youtube":return u(ti,{...r});case"vimeo":return u(ri,{...r});case"spotify":return u(oi,{...r});case"anchor-fm":return u(ni,{...r});case"audio":return u(si,{...r});case"video":return u(ai,{...r});case"absoluteLink":return u("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},ei=({pathType:e,href:t})=>{let{project:r}=G(V),{project:o=r,title:n,hash:s=""}=de({pathType:e,href:t}),c=yo(o,n,"link",s),a=xo(o,n??"");return u("a",{className:`page-link${n!==void 0&&a?" empty-page-link":""}`,type:"link",href:`/${o}${n===void 0?"":`/${S(n)}${s===""?"":`#${s}`}`}`,rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:c},t)},ti=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 u("div",{className:"iframe-video-player"},u("iframe",{src:t,allowFullScreen:!0,type:"text/html"}))},ri=({videoId:e})=>u("div",{className:"iframe-video-player"},u("iframe",{src:`https://player.vimeo.com/video/${e}`,allowFullScreen:!0,type:"text/html"})),oi=e=>u("div",{className:"iframe-video-player"},u("iframe",{className:`spotify type-${e.pathType}`,src:`https://open.spotify.com/embed/${e.pathType}/${e.videoId}`,allowFullScreen:!0,type:"text/html",scrolling:"no"})),ni=e=>u("div",{className:"iframe-video-player"},u("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})),si=e=>e.content===""?u("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):u(ii,{...e}),ii=({href:e,content:t})=>{let r=oe(null),o=O(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return u("span",{className:"audio-link"},u("a",{href:e,rel:"noopener noreferrer",target:"_blank"},t),u("span",{className:"play",onClick:o},"♬"),u("audio",{preload:"none",src:e,ref:r}))},ai=({href:e})=>u("div",{className:"video-player"},u("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})),xo=(e,t)=>{let{whiteList:r}=G(V),o=v(()=>(r.has(e)?[...r]:[e,...r]).map(s=>k(s,t)),[r,e]),n=ue(o);return v(()=>so(n),n)},yo=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:c}=G(V);return O(async({currentTarget:a})=>{!t||(c(e,t),!!await ae(a,n)&&s({project:e,title:t,hash:o,type:r,position:ce(a)}))},[e,t,o,r,n,c,s])};var _o=({pages:e,onClick:t,source:r,whiteList:o,...n})=>{let[s,c]=P(k(e[0].project,e[0].titleLc)),a=v(()=>({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 u("div",{className:"text-bubble",style:a,onClick:t},e.length>1&&u("div",{role:"tablist"},e.map(i=>u(ci,{key:k(i.project,i.titleLc),project:i.project,titleLc:i.titleLc,selected:s===k(i.project,i.titleLc),tabSelector:c}))),e.map(i=>u(li,{key:k(i.project,i.titleLc),selected:s===k(i.project,i.titleLc),...i,title:i.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:o,...n})))},ci=({project:e,titleLc:t,tabSelector:r,selected:o})=>{let n=O(()=>r(k(e,t)),[e,t]),s=Z(e);return u("button",{role:"tab","aria-selected":o,"data-theme":s,tabIndex:-1,onClick:n},e)},li=({selected:e,...t})=>{let r=Z(t.project);return u("div",{role:"tabpanel","data-theme":r,hidden:!e},u(ho,{...t}))};var ko=X("ScrapBubble:Bubble.tsx"),vo=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=v(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,c,a]=ui(e,n,r,t);return u(E,null,pi(a)&&u(_o,{pages:a,source:e,whiteList:r,onClick:o.hide,...o}),u(go,{linked:s,externalLinked:c,onClick:o.hide,source:e,projectsForSort:n,...o}))},pi=e=>e.length>0,ui=(e,t,r,o)=>{let[[n,s,c],a]=P([new Map,new Map,[]]),i=v(()=>{let m=[...t].map(g=>k(g,e.title));return ko.debug("projects",m),m},[t,e.title]),p=ue(i),l=v(()=>o.map(m=>j(m)),[o]);return Be(()=>{let m=new Map,g=new Map,d=[];for(let f of p){let b={project:f.project,titleLc:f.titleLc};for(let y of f.projectLinked??[]){let{project:L,titleLc:A}=Ae(y);l.includes(A)&&r.has(L)||g.has(y)||g.set(y,b)}if(!r.has(f.project))continue;let x={titleLc:f.titleLc};for(let y of f.linked??[]){if(l.includes(y))continue;let L=k(f.project,y);m.has(L)||m.set(L,x)}l.includes(f.titleLc)||!f.exists||d.push(f)}a(Ve(f=>{ko.debug(`depth: ${l.length}, bubbled from ${k(e.project,e.title)}, bubbles,`,p,"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]=d}))},[p,r,l]),[n,s,c]};var wo=(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(o){if(!(o instanceof TypeError))throw o;return e}}};var Eo=e=>{let t=v(()=>wo(e.style,import.meta.url),[e.style]);return u(E,null,t!==""&&(t instanceof URL?u("link",{rel:"stylesheet",href:t.href}):u("style",null,t)))};var Lo=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}button[aria-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-card[data-theme=default-dark]{--card-title-bg: hsl(0, 0%, 39%)}.related-page-card[data-theme=default-minimal]{--card-title-bg: hsl(0, 0%, 89%)}.related-page-card[data-theme=paper-light]{--card-title-bg: hsl(53, 8%, 58%)}.related-page-card[data-theme=paper-dark-dark]{--card-title-bg: hsl(203, 42%, 17%)}.related-page-card[data-theme=blue]{--card-title-bg: hsl(227, 68%, 62%)}.related-page-card[data-theme=purple]{--card-title-bg: hsl(267, 39%, 60%)}.text-bubble[data-theme=green]{--card-title-bg: hsl(136, 29%, 50%)}.related-page-card[data-theme=orange]{--card-title-bg: hsl(43, 71%, 51%)}.related-page-card[data-theme=red]{--card-title-bg: hsl(4, 58%, 56%)}.related-page-card[data-theme=spring]{--card-title-bg: hsl(72, 64%, 57%)}.related-page-card[data-theme=kyoto]{--card-title-bg: hsl(331, 21%, 26%)}.related-page-card[data-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 To=()=>{let[e,t]=P([]),r=O((s,c)=>t(a=>c?[...a.slice(0,s),c]:[...a.slice(0,s)]),[]),[o,n]=P([{bubble:s=>r(0,s),hide:()=>r(0)}]);return $(()=>{n(([s,...c])=>[s,...e.map((a,i)=>a===c.at(i)?.source?c.at(i):{source:a,parentTitles:[scrapbox.Page.title??"",...e.slice(0,i).map(p=>p.title)],bubble:p=>r(i+1,p),hide:()=>r(i+1)})])},[e]),o};var vt=(e,t,r,o,n)=>{$(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var No=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),Ze=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var wt="scrap-bubble",Po=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...c]=To(),a=O((i,p)=>uo(p,t.has(i)?t:new Set([i]),r),[t,r]);return vt(document,"pointerenter",async i=>{let p=i.target;if(!Ze(p)&&!No(p))return;let{project:l=scrapbox.Project.name,title:m,hash:g=""}=Ze(p)?de({pathType:"root",href:`${new URL(p.href).pathname}${new URL(p.href).hash}`}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(l==="")return;let d=decodeURIComponent(m??"");a(l,d),!!await ae(p,e)&&n({project:l,title:d,hash:g,position:ce(p),type:di(p)})},{capture:!0},[e,t,r]),vt(document,"click",i=>{i.target.dataset.userscriptName!==wt&&s()},{capture:!0},[s]),$(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),u(E,null,u("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),u("style",null,Lo),u(Eo,{style:o}),c.map(i=>u(vo,{key:k(i.source.project,i.source.title),...i,whiteList:t,delay:e,prefetch:a})))},di=e=>Ze(e)?e.type==="link"?"link":"hashtag":"title";var lm=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await yr()).slice(0,100),style:n="",debug:s=!1}=e??{};$r(s);let c=document.createElement("div");c.dataset.userscriptName=wt,document.body.append(c);let a=c.attachShadow({mode:"open"});Re(u(Po,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(o),style:n}),a)};export{lm as mount};