generated at
ScrapBubble
takker氏が制作したUserScript版のScrapScripts
詳細は以下を参照。

v0.6.3 を仕様
あまりにもコードが長いので、2回に分けてコピペする必要がある

javascript
import { mount } from "https://scrapbox.io/api/code/Mijinko/ScrapBubble/script.js"; mount();

script.js
var pe,b,Qe,Nr,re,Ve,Ye,Je,de={},Ze=[],Pr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function O(e,t){for(var r in t)e[r]=t[r];return e}function et(e){var t=e.parentNode;t&&t.removeChild(e)}function a(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?pe.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 ue(e,c,o,n,null)}function ue(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??++Qe};return n==null&&b.vnode!=null&&b.vnode(s),s}function k(e){return e.children}function me(e,t){this.props=e,this.context=t}function z(e,t){if(t==null)return e.__?z(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"?z(e):null}function tt(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 tt(e)}}function Ie(e){(!e.__d&&(e.__d=!0)&&re.push(e)&&!fe.__r++||Ye!==b.debounceRendering)&&((Ye=b.debounceRendering)||Ve)(fe)}function fe(){for(var e;fe.__r=re.length;)e=re.sort(function(t,r){return t.__v.__b-r.__v.__b}),re=[],e.some(function(t){var r,o,n,s,c,l;t.__d&&(c=(s=(r=t).__v).__e,(l=r.__P)&&(o=[],(n=O({},s)).__v=s.__v+1,Me(l,s,n,r.__n,l.ownerSVGElement!==void 0,s.__h!=null?[c]:null,o,c??z(s),s.__h),ct(o,s),s.__e!=c&&tt(s)))})}function rt(e,t,r,o,n,s,c,l,m,p){var i,d,u,f,g,h,x,y=o&&o.__k||Ze,w=y.length;for(r.__k=[],i=0;i<t.length;i++)if((f=r.__k[i]=(f=t[i])==null||typeof f=="boolean"?null:typeof f=="string"||typeof f=="number"||typeof f=="bigint"?ue(null,f,null,null,f):Array.isArray(f)?ue(k,{children:f},null,null,null):f.__b>0?ue(f.type,f.props,f.key,null,f.__v):f)!=null){if(f.__=r,f.__b=r.__b+1,(u=y[i])===null||u&&f.key==u.key&&f.type===u.type)y[i]=void 0;else for(d=0;d<w;d++){if((u=y[d])&&f.key==u.key&&f.type===u.type){y[d]=void 0;break}u=null}Me(e,f,u=u||de,n,s,c,l,m,p),g=f.__e,(d=f.ref)&&u.ref!=d&&(x||(x=[]),u.ref&&x.push(u.ref,null,f),x.push(d,f.__c||g,f)),g!=null?(h==null&&(h=g),typeof f.type=="function"&&f.__k===u.__k?f.__d=m=ot(f,m,e):m=nt(e,f,u,y,g,m),typeof r.type=="function"&&(r.__d=m)):m&&u.__e==m&&m.parentNode!=e&&(m=z(u))}for(r.__e=h,i=w;i--;)y[i]!=null&&(typeof r.type=="function"&&y[i].__e!=null&&y[i].__e==r.__d&&(r.__d=z(o,i+1)),pt(y[i],y[i]));if(x)for(i=0;i<x.length;i++)lt(x[i],x[++i],x[++i])}function ot(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"?ot(o,t,r):nt(r,o,o,n,o.__e,t));return t}function nt(e,t,r,o,n,s){var c,l,m;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(l=s,m=0;(l=l.nextSibling)&&m<o.length;m+=2)if(l==n)break e;e.insertBefore(n,s),c=s}return c!==void 0?c:n.nextSibling}function Ir(e,t,r,o,n){var s;for(s in r)s==="children"||s==="key"||s in t||ge(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]||ge(e,s,t[s],r[s],o)}function st(e,t,r){t[0]==="-"?e.setProperty(t,r):e[t]=r==null?"":typeof r!="number"||Pr.test(t)?r:r+"px"}function ge(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||st(e.style,t,"");if(r)for(t in r)o&&r[t]===o[t]||st(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?at:it,s):e.removeEventListener(t,s?at:it,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 it(e){this.l[e.type+!1](b.event?b.event(e):e)}function at(e){this.l[e.type+!0](b.event?b.event(e):e)}function Me(e,t,r,o,n,s,c,l,m){var p,i,d,u,f,g,h,x,y,w,I,T=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(m=r.__h,l=t.__e=r.__e,t.__h=null,s=[l]),(p=b.__b)&&p(t);try{e:if(typeof T=="function"){if(x=t.props,y=(p=T.contextType)&&o[p.__c],w=p?y?y.props.value:p.__:o,r.__c?h=(i=t.__c=r.__c).__=i.__E:("prototype"in T&&T.prototype.render?t.__c=i=new T(x,w):(t.__c=i=new me(x,w),i.constructor=T,i.render=Rr),y&&y.sub(i),i.props=x,i.state||(i.state={}),i.context=w,i.__n=o,d=i.__d=!0,i.__h=[]),i.__s==null&&(i.__s=i.state),T.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=O({},i.__s)),O(i.__s,T.getDerivedStateFromProps(x,i.__s))),u=i.props,f=i.state,d)T.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(T.getDerivedStateFromProps==null&&x!==u&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(x,w),!i.__e&&i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(x,i.__s,w)===!1||t.__v===r.__v){i.props=x,i.state=i.__s,t.__v!==r.__v&&(i.__d=!1),i.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(H){H&&(H.__=t)}),i.__h.length&&c.push(i);break e}i.componentWillUpdate!=null&&i.componentWillUpdate(x,i.__s,w),i.componentDidUpdate!=null&&i.__h.push(function(){i.componentDidUpdate(u,f,g)})}i.context=w,i.props=x,i.state=i.__s,(p=b.__r)&&p(t),i.__d=!1,i.__v=t,i.__P=e,p=i.render(i.props,i.state,i.context),i.state=i.__s,i.getChildContext!=null&&(o=O(O({},o),i.getChildContext())),d||i.getSnapshotBeforeUpdate==null||(g=i.getSnapshotBeforeUpdate(u,f)),I=p!=null&&p.type===k&&p.key==null?p.props.children:p,rt(e,Array.isArray(I)?I:[I],t,r,o,n,s,c,l,m),i.base=t.__e,t.__h=null,i.__h.length&&c.push(i),h&&(i.__E=i.__=null),i.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=Mr(r.__e,t,r,o,n,s,c,m);(p=b.diffed)&&p(t)}catch(H){t.__v=null,(m||s!=null)&&(t.__e=l,t.__h=!!m,s[s.indexOf(l)]=null),b.__e(H,t,r)}}function ct(e,t){b.__c&&b.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(o){o.call(r)})}catch(o){b.__e(o,r.__v)}})}function Mr(e,t,r,o,n,s,c,l){var m,p,i,d=r.props,u=t.props,f=t.type,g=0;if(f==="svg"&&(n=!0),s!=null){for(;g<s.length;g++)if((m=s[g])&&"setAttribute"in m==!!f&&(f?m.localName===f:m.nodeType===3)){e=m,s[g]=null;break}}if(e==null){if(f===null)return document.createTextNode(u);e=n?document.createElementNS("http://www.w3.org/2000/svg",f):document.createElement(f,u.is&&u),s=null,l=!1}if(f===null)d===u||l&&e.data===u||(e.data=u);else{if(s=s&&pe.call(e.childNodes),p=(d=r.props||de).dangerouslySetInnerHTML,i=u.dangerouslySetInnerHTML,!l){if(s!=null)for(d={},g=0;g<e.attributes.length;g++)d[e.attributes[g].name]=e.attributes[g].value;(i||p)&&(i&&(p&&i.__html==p.__html||i.__html===e.innerHTML)||(e.innerHTML=i&&i.__html||""))}if(Ir(e,u,d,n,l),i)t.__k=[];else if(g=t.props.children,rt(e,Array.isArray(g)?g:[g],t,r,o,n&&f!=="foreignObject",s,c,s?s[0]:r.__k&&z(r,0),l),s!=null)for(g=s.length;g--;)s[g]!=null&&et(s[g]);l||("value"in u&&(g=u.value)!==void 0&&(g!==d.value||g!==e.value||f==="progress"&&!g)&&ge(e,"value",g,d.value,!1),"checked"in u&&(g=u.checked)!==void 0&&g!==e.checked&&ge(e,"checked",g,d.checked,!1))}return e}function lt(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(o){b.__e(o,r)}}function pt(e,t,r){var o,n;if(b.unmount&&b.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||lt(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){b.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)o[n]&&pt(o[n],t,typeof e.type!="function");r||e.__e==null||et(e.__e),e.__e=e.__d=void 0}function Rr(e,t,r){return this.constructor(e,r)}function be(e,t,r){var o,n,s;b.__&&b.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],Me(t,e=(!o&&r||t).__k=a(k,null,[e]),n||de,de,t.ownerSVGElement!==void 0,!o&&r?[r]:n?null:t.firstChild?pe.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o),ct(s,e)}function Re(e,t){var r={__c:t="__cC"+Je++,__: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(Ie)},this.sub=function(c){n.push(c);var l=c.componentWillUnmount;c.componentWillUnmount=function(){n.splice(n.indexOf(c),1),l&&l.call(c)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}pe=Ze.slice,b={__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}},Qe=0,Nr=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=O({},this.state),typeof e=="function"&&(e=e(O({},r),this.props)),e&&O(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),Ie(this))},me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ie(this))},me.prototype.render=k,re=[],Ve=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,fe.__r=0,Je=0;var W,M,dt,oe=0,Se=[],ut=b.__b,mt=b.__r,ft=b.diffed,gt=b.__c,bt=b.unmount;function ne(e,t){b.__h&&b.__h(M,e,oe||t),oe=0;var r=M.__H||(M.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function R(e){return oe=1,Sr(xt,e)}function Sr(e,t,r){var o=ne(W++,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=M),o.__}function C(e,t){var r=ne(W++,3);!b.__s&&je(r.__H,t)&&(r.__=e,r.__H=t,M.__H.__h.push(r))}function he(e,t){var r=ne(W++,4);!b.__s&&je(r.__H,t)&&(r.__=e,r.__H=t,M.__h.push(r))}function U(e){return oe=5,v(function(){return{current:e}},[])}function v(e,t){var r=ne(W++,7);return je(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function $(e,t){return oe=8,v(function(){return e},t)}function D(e){var t=M.context[e.__c],r=ne(W++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(M)),t.props.value):e.__}function Cr(){var e;for(Se.sort(function(t,r){return t.__v.__b-r.__v.__b});e=Se.pop();)if(e.__P)try{e.__H.__h.forEach(xe),e.__H.__h.forEach(Ce),e.__H.__h=[]}catch(t){e.__H.__h=[],b.__e(t,e.__v)}}b.__b=function(e){M=null,ut&&ut(e)},b.__r=function(e){mt&&mt(e),W=0;var t=(M=e.__c).__H;t&&(t.__h.forEach(xe),t.__h.forEach(Ce),t.__h=[])},b.diffed=function(e){ft&&ft(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(Se.push(t)!==1&&dt===b.requestAnimationFrame||((dt=b.requestAnimationFrame)||function(r){var o,n=function(){clearTimeout(s),ht&&cancelAnimationFrame(o),setTimeout(r)},s=setTimeout(n,100);ht&&(o=requestAnimationFrame(n))})(Cr)),M=null},b.__c=function(e,t){t.some(function(r){try{r.__h.forEach(xe),r.__h=r.__h.filter(function(o){return!o.__||Ce(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],b.__e(o,r.__v)}}),gt&&gt(e,t)},b.unmount=function(e){bt&&bt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{xe(o)}catch(n){t=n}}),t&&b.__e(t,r.__v))};var ht=typeof requestAnimationFrame=="function";function xe(e){var t=M,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),M=t}function Ce(e){var t=M;e.__c=e.__(),M=t}function je(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 q=(e,t)=>{if(!(e instanceof HTMLDivElement))throw Error(`${t??"value"} must be HTMLDivElement`)};var yt=()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e);return Object.entries(t).sort(([,r],[,o])=>o-r).map(([r])=>r)}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var Br=e=>typeof e=="object"&&e!==null,$r=e=>Br(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,kt=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return $r(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var vt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError(`"${t}" must be HTMLDivElememt but actual is "${e}"`)};var G=()=>Hr(document.getElementById("editor"),"div#editor");var Hr=(e,t)=>{if(!!e)return vt(e,t),e};var ye=e=>new Promise(t=>setTimeout(()=>t(),e));var N=e=>e.replaceAll(" ","_").toLowerCase();var j=e=>[...e].map((t,r)=>t===" "?"_":!Ur.includes(t)||r===e.length-1&&qr.includes(t)?encodeURIComponent(t):t).join(""),Ur='@$&+=:;",',qr=':;",';var _=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var se=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,se)}},B=async e=>{let t=e.clone(),r=await t.text(),o=kt(r);if(!o)throw new se(t);return{ok:!1,value:o}};var S=e=>`connect.sid=${e}`;var _t=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:c}=_(r??{}),l=new URLSearchParams;l.append("followRename",`${s??!0}`);for(let p of c??[])l.append("projects",p);let m=`https://${n}/api/pages/${e}/${j(t)}?${l.toString()}`;return new Request(m,o?{headers:{Cookie:S(o)}}:void 0)},Et=async e=>{if(!e.ok)return e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:B(e);let t=await e.json();return{ok:!0,value:t}},X=async(e,t,r)=>{let{fetch:o}=_(r??{}),n=_t(e,t,r),s=await o(n);return await Et(s)};X.toRequest=_t;X.fromResponse=Et;var Lt=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:c}=_(t??{}),l=new URLSearchParams;n!==void 0&&l.append("sort",n),s!==void 0&&l.append("limit",`${s}`),c!==void 0&&l.append("skip",`${c}`);let m=`https://${o}/api/pages/${e}?${l.toString()}`;return new Request(m,r?{headers:{Cookie:S(r)}}:void 0)},Tt=async e=>{if(!e.ok)return B(e);let t=await e.json();return{ok:!0,value:t}},Nt=async(e,t)=>{let{fetch:r}=_(t??{}),o=await r(Lt(e,t));return await Tt(o)};Nt.toRequest=Lt;Nt.fromResponse=Tt;var Pt=(e,t)=>{let{sid:r,hostName:o}=_(t??{});return new Request(`https://${o}/api/projects/${e}`,r?{headers:{Cookie:S(r)}}:void 0)},It=async e=>{if(!e.ok)return B(e);let t=await e.json();return{ok:!0,value:t}},ke=async(e,t)=>{let{fetch:r}=_(t??{}),o=Pt(e,t),n=await r(o);return It(n)};ke.toRequest=Pt;ke.fromResponse=It;var Mt=(e,t)=>{let{sid:r,hostName:o}=_(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:S(r)}}:void 0)},Rt=async e=>{if(!e.ok)return B(e);let t=await e.json();return{ok:!0,value:t}},St=async(e,t)=>{let{fetch:r}=_(t??{}),o=await r(Mt(e,t));return Rt(o)};St.toRequest=Mt;St.fromResponse=Rt;var zr=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Wr=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,Gr=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,Xr=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Ct=e=>{if(zr.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(Wr);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(Gr);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(Xr);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Qr=/https?:\/\/vimeo\.com\/([0-9]+)/i,jt=e=>{let t=e.match(Qr);if(!!t)return t[1]};var Vr=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Bt=e=>{let t=e.match(Vr);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var Yr=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,$t=e=>{let t=e.match(Yr);if(!t)return;let[,r]=t;return r};var Ht=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let c=Ct(n);if(c)return{type:"youtube",href:n,...c,...s};let l=jt(n);if(l)return{type:"vimeo",videoId:l,href:n,...s};let m=Bt(n);if(m)return{type:"spotify",href:n,...m,...s};let p=$t(n);if(p)return{type:"anchor-fm",videoId:p,href:n,...s};if(Zr(n))return{type:"video",href:n,...s}}return Jr(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},Jr=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),Zr=e=>/\.(?:mp4|webm)$/.test(e);var Ot;(function(e){})(Ot||(Ot={}));var eo="0.13.3",Dt,Ft=async(e=eo)=>{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,Dt??=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>n(s),document.head.append(r)}),Dt};var ie=(e,t={})=>{let r=U(null),[o,n]=R(e),[s,c]=R("");return C(()=>{(async()=>{let{render:l}=await Ft();if(!!r.current)try{l(o,r.current,t),c("")}catch(m){if(m instanceof Error&&m.name==="ParseError")c(m.message.slice("KaTeX parse error: ".length));else throw m}})()},[o]),{ref:r,error:s,setFormula:n}};var Q=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 He=(e,t)=>t.some(r=>{let o=typeof e=="string";switch(r.type){case"hashTag":return o&&N(r.href)===N(e);case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=Q({pathType:r.pathType,href:r.href});return o?!n&&N(s)===N(e):n===e.project&&N(s)===N(e.title)}case"quote":case"strong":case"decoration":return He(e,r.nodes)}});var E=(e,t)=>`/${e}/${N(t)}`,ve=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError(`"${e}" cannnot match "/([^/]+)/(.+)"`);return{project:t[1],titleLc:t[2]}};var V=(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 to="0.3.0",At=`ScrapBubble-${to}`,Oe=await globalThis.caches.open(At);for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==At&&(await globalThis.caches.delete(e),console.log(`[ScrapBubble] deleted old cache :"${e}"`));var Ut=async(e,t)=>{let{maxAge:r=60}=t??{},o=new Request(e),n=await De(o,t);if(!n||Fe(n,r)){let s=await globalThis.fetch(e);return await Oe.put(o,s.clone()),s}else return n},De=async(e,t)=>await Oe.match(e,t),qt=async(e,t)=>{await Oe.put(e,t)},Fe=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var we=()=>{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 Kt=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},Ae=(e,t)=>{if(!e)return t;if(e.updated<t.updated){let{lines:n,...s}=t,c={...s,lines:Ue(t)?e.lines:n};return e.linked&&(c.linked??=e.linked),e.projectLinked&&(c.projectLinked??=e.projectLinked),c}let r=!1,o={...e};if(Ue(o)&&!Ue(t)&&(o.lines=t.lines,r=!0),t.linked&&(o.linked?.length!==t.linked?.length||o.linked?.some?.((n,s)=>n!==t.linked?.[s]))&&(o.linked=t.linked,r=!0),t.projectLinked&&(o.projectLinked?.length!==t.projectLinked?.length||o.projectLinked?.some?.((n,s)=>n!==t.projectLinked?.[s]))&&(o.projectLinked=t.projectLinked,r=!0),o.checked!==t.checked){let n=Math.max(o.checked,t.checked);if(!r)return e.checked=n,e;o.checked=n,r=!0}return r?o:e},Ue=e=>e.lines[0].id==="dummy";var qe=e=>Math.round(e.getTime()/1e3);var Ke=(e,t,r)=>{let o=new Map;r??=new Date;let n=N(t.title);for(let p of t.links){let i=ro(e,p,r);i.linked=[n],o.set(E(e,p),i)}let s=E(e,n),c=t.projectLinks.map(p=>{let i=ve(p);return E(i.project,i.titleLc)}),l={..._e(e,t,r),linked:[],projectLinked:[]};o.set(s,l);let m=t.links.map(p=>N(p));for(let p of t.relatedPages.links1hop){p.linksLc.includes(n)&&l.linked.push(p.titleLc);for(let f of p.linksLc.filter(g=>m.includes(g))){let g=E(e,f),h=o.get(g);if(!h)throw Error(`storage already must have "${g}"`);if(!h.linked){h.linked=[p.titleLc];continue}h.linked.push(p.titleLc)}let i=E(e,p.titleLc),d=_e(e,p,r),u=o.get(i)?.linked;u&&(d.linked=u),o.set(i,d)}for(let p of t.relatedPages.projectLinks1hop){let i=E(p.projectName,p.titleLc);c.includes(i)||l.projectLinked.push(i);let d=_e(p.projectName,p,r),u=o.get(i)?.projectLinked;u&&(d.projectLinked=u),o.set(i,d)}for(let p of t.relatedPages.links2hop){for(let f of p.linksLc){let g=E(e,f),h=o.get(g);if(!h)throw Error(`storage already must have "${g}"`);if(!h.linked){h.linked=[p.titleLc];continue}h.linked.push(p.titleLc)}let i=E(e,p.titleLc),d=_e(e,p,r),u=o.get(i)?.linked;u&&(d.linked=u),o.set(i,d)}return o},_e=(e,t,r)=>({project:e,titleLc:"titleLc"in t?t.titleLc:N(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(o=>({text:o,id:"dummy",userId:"dummy",updated:t.updated,created:t.updated})),updated:t.updated,checked:qe(r)}),ro=(e,t,r)=>({project:e,titleLc:N(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,checked:qe(r)});var zt=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.shift();if(!s)return;let c=s[0]().then(l=>s[1](l)).catch(l=>s[2](l));r.add(c),c.finally(()=>o(c))};return n=>{if(r.size<e){let s=n();return r.add(s),s.finally(()=>o(s)),s}return new Promise((s,c)=>{t.push([n,s,c])})}};var Wt=!1,Gt=e=>{Wt=e},oo="[ScrapBubble]",Y=Object.fromEntries([...Object.entries(console)].map(([e,t])=>typeof t!="function"?[e,t]:[e,(r,...o)=>{!Wt||t(typeof r=="string"?`${oo} ${r}`:r,...o)}]));var ae=new Map,Ee=new Set,Le=we();function*ze(e){for(let t of e)yield ae.get(t)}var Xt=(e,t)=>Le.on(e,t),Qt=(e,t)=>Le.off(e,t),Vt=(e,t,r,o)=>{for(let n of t){let s=E(n,e);Ee.has(s)||so(n,e,r,o)}},Yt=0,no=zt(3),so=async(e,t,r,o)=>{let n=E(e,t);if(Ee.has(n))return;Ee.add(n);let s=Yt++;Y.time(`[${s}] Check update ${n}`);try{let c=X.toRequest(e,t,{followRename:!0,projects:r}),l=new URL(c.url),m=`${l.origin}${l.pathname}`,p=await De(m);if(p){let u=await X.fromResponse(p);if(u.ok){let f=Ke(e,u.value);for(let[g,h]of f){let x=ae.get(g),y=Ae(x,h);x!==y&&(ae.set(g,y),Le.dispatch(g,h))}}}if(o?.ignoreFetch===!0||p&&!Fe(p,o?.maxAge??60))return;let i=await no(()=>fetch(c));Y.debug(`%c[${s}]Fetch`,"color: gray;",n);let d=await X.fromResponse(i.clone());if(await qt(m,i),d.ok){let u=Ke(e,d.value);for(let[f,g]of u){let h=ae.get(f),x=Ae(h,g);h!==x&&(ae.set(f,x),Le.dispatch(f,g))}}}catch(c){console.error(c)}finally{Ee.delete(n),Y.timeEnd(`[${s}] Check update ${n}`),Yt--}};var K=e=>{let[t,r]=R([]);return he(()=>{r([...ze(e)].flatMap(s=>s?[s]:[]));let o,n=()=>{clearTimeout(o),o=setTimeout(()=>{Y.debug(`%cUpdate ${e.length} pages`,"color: gray;"),r([...ze(e)].flatMap(s=>s?[s]:[]))},10)};return e.forEach(s=>Xt(s,n)),()=>e.forEach(s=>Qt(s,n))},[e]),t};var J=e=>{let t=G();q(t,"#editor");let{top:r,right:o,left:n,bottom:s}=e.getBoundingClientRect(),c=t.getBoundingClientRect(),l=(n-c.left)/c.width>.5;return{top:Math.round(s-c.top),bottom:Math.round(c.bottom-r),...l?{right:Math.round(c.right-o)}:{left:Math.round(n-c.left)},maxWidth:l?o-10:document.documentElement.clientWidth-n-10}};var io=e=>({type:"title",text:e.rows[0].text}),ao=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(` `)}},L=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,c)=>{var l,m,p,i,d,u;if(!t&&s.nested)return(l=c?.())!==null&&l!==void 0?l:[];if(!r&&s.quoted)return(m=c?.())!==null&&m!==void 0?m:[];for(let f of o){let g=f.exec(n);if(g===null)continue;let h=n.substring(0,g.index),x=n.substring(g.index+((i=(p=g[0])===null||p===void 0?void 0:p.length)!==null&&i!==void 0?i:0)),y=e((d=g[0])!==null&&d!==void 0?d:"",s);return[...F(h,s),...y,...F(x,s)]}return(u=c?.())!==null&&u!==void 0?u:[]},P=e=>[{type:"plain",raw:e,text:e}],co=L(P,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),lo=/^>.*$/,po=(e,t)=>t.context==="table"?P(e,t):[{type:"quote",raw:e,nodes:F(e.substring(1),{...t,quoted:!0})}],uo=L(po,{parseOnNested:!1,parseOnQuoted:!1,patterns:[lo]}),mo=/^\? .+$/,fo=(e,t)=>t.context==="table"?P(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],go=L(fo,{parseOnNested:!1,parseOnQuoted:!1,patterns:[mo]}),bo=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,ho=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,xo=(e,t)=>{if(t.context==="table")return P(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}]},yo=L(xo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[bo,ho]}),ko=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function Jt(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return P(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",l=o.substring(n+5,o.length),m=l.startsWith("*")?parseInt(l.substring(1),10):1;return new Array(m).fill({}).map(()=>({path:s,pathType:c,type:e,raw:t}))}}var vo=Jt("icon"),wo=L(vo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ko]}),_o=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Eo=Jt("strongIcon"),Lo=L(Eo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[_o]}),To=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,No=(e,t)=>t.context==="table"?P(e,t):[{type:"strong",raw:e,nodes:F(e.substring(2,e.length-2),{...t,nested:!0})}],Po=L(No,{parseOnNested:!1,parseOnQuoted:!0,patterns:[To]}),Io=/\[\$ .+? \]/,Mo=/\[\$ [^\]]+\]/,Ro=(e,t)=>t.context==="table"?P(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],So=L(Ro,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Io,Mo]}),Co=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,jo=(e,t)=>{if(t.context==="table")return P(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:F(n,{...t,nested:!0})}]},Bo=L(jo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Co]}),$o=/`.*?`/,Ho=(e,t)=>t.context==="table"?P(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Oo=L(Ho,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$o]}),Do=/^[$%] .+$/,Fo=(e,t)=>{var r;if(t.context==="table")return P(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}]},Ao=L(Fo,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Do]}),Uo=/\[\s+\]/,qo=(e,t)=>t.context==="table"?P(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Ko=L(qo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Uo]}),zo=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Wo=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Go=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,Xo=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,Qo=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||Vo(e),Vo=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),Yo=(e,t)=>{if(t.context==="table")return P(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]=Qo(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}]},Jo=L(Yo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[zo,Wo,Go,Xo]}),Zo=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,en=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,tn=/\[https?:\/\/[^\s\]]+\]/,rn=/https?:\/\/[^\s]+/,on=(e,t)=>{if(t.context==="table")return P(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()}]},nn=L(on,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Zo,en,tn,rn]}),Zt=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,er=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,sn=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}},an=(e,t)=>{var r;if(t.context==="table")return P(e,t);let o=(r=e.match(Zt))!==null&&r!==void 0?r:e.match(er);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",c=""]=n?o:[o[0],o[2],o[1]],{latitude:l,longitude:m,zoom:p}=sn(s),i=c!==""?`https://www.google.com/maps/place/${encodeURIComponent(c)}/@${l},${m},${p}z`:`https://www.google.com/maps/@${l},${m},${p}z`;return[{type:"googleMap",raw:e,latitude:l,longitude:m,zoom:p,place:c,url:i}]},cn=L(an,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Zt,er]}),ln=/\[\/?[^[\]]+\]/,pn=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},dn=L(pn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ln]}),un=/(?:^|\s)#\S+/,mn=(e,t)=>{if(t.context==="table")return P(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[...P(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},fn=L(mn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[un]}),gn=/^[0-9]+\. .*$/,bn=(e,t)=>{if(t.context==="table")return P(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:F(s,{...t,nested:!0})}]},hn=L(bn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[gn]}),xn=(e,t,r)=>{var o;return e===""?[]:(o=r?.())!==null&&o!==void 0?o:[]},yn=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>co(t,r))(),F=yn(xn,uo,go,Oo,Ao,So,Ko,Bo,yo,Lo,Po,Jo,nn,wo,cn,dn,fn,hn),kn=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(l=>F(l,{nested:!1,quoted:!1,context:"table"})))}},vn=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:F(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},wn=e=>{switch(e.type){case"title":return io(e);case"codeBlock":return ao(e);case"table":return kn(e);case"line":return vn(e)}},_n=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}}),En=(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)},tr=(e,t)=>{let r=e[e.length-1];return r!==void 0&&En(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)},Ln=(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(tr,[])]}return e.reduce(tr,[])},ce=(e,t)=>{var r;let o=_n(e);return Ln(o,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(wn)};var A=Re({title:"",project:"",whiteList:[],bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),rr=({lines:e,project:t,title:r,whiteList:o,noIndent:n,scrollTo:s,...c})=>{let l=v(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),m=v(()=>{let d=0;return ce(e.map(u=>typeof u=="string"?u:u.text).join(` `),{hasTitle:!0}).map(u=>{switch(u.type){case"title":case"line":return{...u,id:l[d++]};case"codeBlock":{let f=d;return d+=u.content.split(` `).length+1,{...u,ids:l.slice(f,d)}}case"table":{let f=d;return d+=u.cells.length+1,{...u,ids:l.slice(f,d)}}}})},[e,l]),p=v(()=>{if(!s)return;let d=s.type==="id"?s.value:m.find(u=>u.type!=="line"?!1:He(s.value,u.nodes))?.id??"";if(!!l.includes(d))return d},[s,m,l]),i=U(null);return C(()=>{if(!p)return;let d=i.current?.querySelector(`[data-id="${p}"]`),u=window.scrollY;d?.scrollIntoView?.({block:"center"}),window.scroll(0,u)},[p]),a("div",{className:"lines",ref:i},a(A.Provider,{value:{project:t,title:r,whiteList:o,...c}},m.map(d=>{switch(d.type){case"title":return a(k,null,a(Z,{key:d.id,index:d.id,indent:0,noIndent:n,permalink:d.id===p},d.text),a("hr",null));case"codeBlock":return a(Tn,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:p});case"table":return a(Nn,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:p});case"line":return a(Z,{key:d.id,index:d.id,indent:d.indent,noIndent:n,permalink:d.id===p},d.nodes.length>0?d.nodes.map(u=>a(ee,{node:u})):a("br",null))}})))},Z=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>a("div",{className:`line${n?" permalink":""}`,"data-id":e,"data-indent":t,style:{"margin-left":r?"":`${1*t}em`}},o),Tn=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:c}=D(A),[l,m]=R(""),p=$(async i=>{i.preventDefault(),i.stopPropagation();try{await navigator.clipboard.writeText(t),m("Copied"),await ye(1e3),m("")}catch(d){alert(`Failed to copy the code block Error:${d.message}`)}},[t]);return a(k,null,a(Z,{index:o[0],indent:r,permalink:o[0]===n},a("span",{className:"code-block"},a("span",{className:"code-block-start"},e.includes(".")?a("a",{href:`/api/code/${s}/${j(c)}/${e}`,target:"_blank"},e):e),a("span",{className:"copy",title:"Copy",onClick:p},l))),a(k,null,t.split(` `).map((i,d)=>a(Z,{index:o[d+1],indent:r,permalink:o[d+1]===n},a("code",{className:"code-block"},i)))))},Nn=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:c}=D(A);return a(k,null,a(Z,{index:o[0],indent:r,permalink:o[0]===n},a("span",{className:"table-block"},a("span",{className:"table-block-start"},a("a",{href:`/api/table/${s}/${j(c)}/${e}.csv`,target:"_blank"},e)))),a(k,null,t.map((l,m)=>a(Z,{index:o[m+1],indent:r,permalink:o[m+1]===n},a("span",{className:"table-block table-block-row"},l.map((p,i)=>a("span",{className:`cell col-${i}`},p.map(d=>a(ee,{node:d})))))))))},ee=({node:e})=>{switch(e.type){case"code":return a("code",{className:"code"},e.text);case"formula":return a(Pn,{node:e});case"commandLine":return a("code",{className:"cli"},a("span",{className:"prefix"},e.symbol)," ",a("span",{className:"command"},e.text));case"helpfeel":return a("code",{className:"helpfeel"},a("span",{className:"prefix"},"?")," ",a("span",{className:"entry"},e.text));case"quote":return a("blockquote",{className:"quote"},e.nodes.map(t=>a(ee,{node:t})));case"strong":return a("strong",null,e.nodes.map(t=>a(ee,{node:t})));case"decoration":return a(In,{node:e});case"plain":case"blank":return a(k,null,e.text);case"hashTag":return a(Sn,{node:e});case"link":return a(Cn,{node:e});case"googleMap":return a(Mn,{node:e});case"icon":return a(or,{node:e});case"strongIcon":return a(or,{node:e,strong:!0});case"image":return a(Rn,{node:e});case"strongImage":return a("img",{className:"image strong-image",src:e.src});case"numberList":return a(k,null,`${e.number}. `,e.nodes.map(t=>a(ee,{node:t})))}},Pn=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=ie("");return o(e),a("span",{className:`formula ${r?" error":""}`},r?a("code",null,e):a("span",{className:"katex-display",ref:t}))},In=({node:{decos:e,nodes:t}})=>a("span",{className:e.map(r=>`deco-${r}`).join(" ")},t.map(r=>a(ee,{node:r}))),Mn=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>a("span",{className:"pointing-device-map"},a("a",{href:`https://www.google.com/maps/search/${e}/@${t},${r},${o}z`,rel:"noopner noreferrer",target:"_blank"},a("img",{className:"google-map",src:`/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${window._csrf}`}))),or=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=D(A),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],c=j(s);return a("a",{href:`/${n}/${c}`,rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank"},a("img",{className:r?"icon strong-icon":"icon",alt:s,src:`/api/pages/${n}/${c}/icon`},s))},Rn=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-"/thumb/1000".length):t);return a("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},a("img",{className:"image",src:t}))},Sn=({node:{href:e}})=>{let{project:t}=D(A),r=nr(t,e),o=sr(t,e);return a("a",{ref:o,href:`/${t}/${j(e)}`,className:`page-link${r?" empty-page-link":""}`,type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank"},"#",e)},Cn=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return a(jn,{pathType:e,href:t.href});case"absolute":{let r=Ht({pathType:e,...t});switch(r.type){case"youtube":return a(Bn,{...r});case"vimeo":return a($n,{...r});case"spotify":return a(Hn,{...r});case"anchor-fm":return a(On,{...r});case"audio":return a(Dn,{...r});case"video":return a(An,{...r});case"absoluteLink":return a("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},jn=({pathType:e,href:t})=>{let{project:r}=D(A),{project:o=r,title:n,hash:s=""}=Q({pathType:e,href:t}),c=sr(o,n),l=nr(o,n??"");return a("a",{ref:n?c:void 0,className:`page-link${n!==void 0&&l?" empty-page-link":""}`,type:"link",href:`/${o}${n===void 0?"":`/${j(n)}${s===""?"":`#${s}`}`}`,rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank"},t)},Bn=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 a("div",{className:"iframe-video-player"},a("iframe",{src:t,allowFullScreen:!0,type:"text/html"}))},$n=({videoId:e})=>a("div",{className:"iframe-video-player"},a("iframe",{src:`https://player.vimeo.com/video/${e}`,allowFullScreen:!0,type:"text/html"})),Hn=e=>a("div",{className:"iframe-video-player"},a("iframe",{className:`spotify type-${e.pathType}`,src:`https://open.spotify.com/embed/${e.pathType}/${e.videoId}`,allowFullScreen:!0,type:"text/html",scrolling:"no"})),On=e=>a("div",{className:"iframe-video-player"},a("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})),Dn=e=>e.content===""?a("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):a(Fn,{...e}),Fn=({href:e,content:t})=>{let r=U(null),o=$(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return a("span",{className:"audio-link"},a("a",{href:e,rel:"noopener noreferrer",target:"_blank"},t),a("span",{className:"play",onClick:o},"♬"),a("audio",{preload:"none",src:e,ref:r}))},An=({href:e})=>a("div",{className:"video-player"},a("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})),nr=(e,t)=>{let{whiteList:r}=D(A),o=v(()=>(r.includes(e)?r:[e,...r]).map(s=>E(s,t)),[r,e]),n=K(o);return v(()=>Kt(n),n)},sr=(e,t)=>{let{delay:r,bubble:o,prefetch:n}=D(A),s=U(null);return C(()=>{if(!s.current||!t)return;let c=s.current,l=async()=>{n(e,t),!!await V(c,r)&&o({project:e,title:t,type:"link",position:J(c)})};return c.addEventListener("pointerenter",l),()=>c.removeEventListener("pointerenter",l)},[e,t,r,n,o]),s};var We=we(),Te=new Map,ir=e=>{let[t,r]=R();return C(()=>{We.on(e,r);let o=Te.get(e);return o?r(o.loading?void 0:o.value):(Te.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=await ke(e,{fetch:s=>Ut(s)});Te.set(e,{loading:!1,value:n}),We.dispatch(e,n)}catch(n){console.error(n),Te.delete(e)}})()),()=>We.off(e,r)},[e]),t};var Un=["default-light","default-dark","default-minimal"],qn=["paper-light","paper-dark-dark","paper-dark"],ar=["blue","purple","green","orange","red"],Kn=["hacker1","hacker2"],cr=["winter","spring","summer","automn"],lr=["tropical"],pr=["kyoto","newyork","paris"],dr=["mred","lgreen"],wp=["default-light","default-minimal","paper-light",...ar,...cr,...lr,...pr,...dr];var zn=[...Un,...qn,...ar,...Kn,...cr,...lr,...pr,...dr];function ur(e){return zn.includes(e)}var mr="default-light",Ne=e=>{let t=ir(e);return v(()=>{if(!t||!t.ok)return mr;let r=t.value.theme;return ur(r)?r:mr},[t])};var fr=({project:e,title:t,descriptions:r,thumbnail:o,linkedTo:n,linkedType:s,bubble:c,delay:l,prefetch:m})=>{let p=v(()=>o?[]:ce(r.join(` `),{hasTitle:!1}),[o,r]),i=Ne(e),d=$(async({currentTarget:u})=>{m(e,t),!!await V(u,l)&&c({project:e,title:t,type:"link",position:J(u)})},[e,t,l]);return a("a",{className:"related-page-card page-link",type:"link","data-theme":i,"data-linked-to":n,"data-linked-type":s,href:`/${e}/${j(t)}`,rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:d},a("div",{class:"hover"}),a("div",{class:"content"},a("div",{class:"header"},a("div",{class:"title"},t)),o?a("div",{class:"thumbnail"},a("img",{src:o})):a("div",{class:"description"},p.flatMap((u,f)=>u.type==="line"?[a("p",{key:f},u.nodes.map(g=>a(gr,{node:g,project:e})))]:[]))))},gr=({node:e,project:t})=>{switch(e.type){case"code":return a("code",null,e.text);case"formula":return a(Wn,{node:e});case"commandLine":return a("code",null,e.symbol," $",e.text);case"helpfeel":return a("code",null,"? ",e.text);case"quote":case"strong":case"decoration":return a(k,null,e.nodes.map(r=>a(gr,{node:r,project:t})));case"icon":case"strongIcon":return a(Gn,{node:e,project:t});case"hashTag":return a(Xn,{node:e});case"link":return a(Qn,{node:e});case"plain":case"blank":return a(k,null,e.text);default:return a(k,null)}},Wn=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=ie("");return o(e),a("span",{className:`formula ${r?" error":""}`},r?a("code",null,e):a("span",{className:"katex-display",ref:t}))},Gn=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return a("img",{class:"icon",src:`/api/pages/${o}/${j(n)}/icon`})},Xn=({node:{href:e}})=>a("span",{class:"page-link"},"#",e),Qn=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?a("span",{class:"page-link"},t):a("span",{class:"link"},r||t);var br=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=K(t),c=K(r),l=v(()=>{let p=(i,d)=>{let u=o.indexOf(i.project),f=o.indexOf(d.project);return u===f?d.updated-i.updated:u<0?1:f<0?-1:u-f};return[...s,...c].sort(p)},[s,c,o]),m=v(()=>Vn(e.position,"card"),[e.position]);return a("ul",{className:"card-bubble",style:m,onClick:n.onClick},l.map(({project:p,lines:[{text:i}],descriptions:d,image:u})=>a("li",null,a(fr,{key:E(p,i),project:p,title:i,linkedTo:e.title,linkedType:e.type,descriptions:d,thumbnail:u??"",...n}))))},Vn=(e,t)=>({...t==="page"?{top:`${e.top}px`}:{bottom:`${e.bottom}px`},maxWidth:`${e.maxWidth}px`,..."left"in e?{left:`${e.left}px`}:{right:`${e.right}px`}});var hr=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=v(()=>r.includes(e.project)?[e.project,...r.filter(h=>h!==e.project)]:[e.project],[r,e.project]),s=v(()=>n.map(h=>E(h,e.title)),[n,e.title]),c=K(s),l=v(()=>t.map(h=>N(h)),[t]),[[m,p,i],d]=R([[],[],[]]);he(()=>{let h=new Set,x=new Set,y=[];for(let w of c){for(let I of w.projectLinked??[]){let{project:T,titleLc:H}=ve(I);l.includes(H)&&r.includes(T)||x.add(I)}if(!!r.includes(w.project)){for(let I of w.linked??[])l.includes(I)||h.add(E(w.project,I));l.includes(w.titleLc)||!w.exists||y.push(w)}}d(w=>{let[I,T,H]=w,le=!1;return(I.length!==h.size||I.some(te=>!h.has(te)))&&(I=[...h],le=!0),(T.length!==x.size||T.some(te=>!x.has(te)))&&(T=[...x],le=!0),(H.length!==y.length||H.some((te,Tr)=>y[Tr]!==te))&&(H=y,le=!0),le?[I,T,H]:w})},[c,r,l]);let u=$(()=>o.hide(),[o.hide]),f=Ne(i[0]?.project??e.project),g=v(()=>Zn(e.position,"page"),[e.position]);return a(k,null,i.length>0&&a("div",{className:"text-bubble",style:g,"data-theme":f,onClick:u},a(Yn,null,i[0].project!==scrapbox.Project.name&&a(Jn,{project:i[0].project,title:i[0].lines[0].text})),a(rr,{lines:i[0].lines,project:i[0].project,title:i[0].lines[0].text,scrollTo:e.scrollTo,whiteList:r,...o})),a(br,{linked:m,externalLinked:p,onClick:u,source:e,projectsForSort:n,...o}))},Yn=({children:e})=>a("div",{className:"status-bar top-right"},e),Jn=({project:e,title:t})=>a("a",{href:`/${e}/${j(t)}`,target:"_blank",rel:"noopener noreferrer"},e),Zn=(e,t)=>({...t==="page"?{top:`${e.top}px`}:{bottom:`${e.bottom}px`},maxWidth:`${e.maxWidth}px`,..."left"in e?{left:`${e.left}px`}:{right:`${e.right}px`}});var xr=(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 yr=e=>{let t=v(()=>xr(e.style,import.meta.url),[e.style]);return a(k,null,t!==""&&(t instanceof URL?a("link",{rel:"stylesheet",href:t.href}):a("style",null,t)))};var kr=`*{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(2n+1){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}.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)}.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}.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{padding:5px 0 5px 5px;font-size:11px;line-height:1.42857;user-select:text;position:absolute;max-height:80vh;overflow-y:auto;background-color:var(--page-bg, #fefefe);color:var(--page-text-color, #4a4a4a);border-radius:4px;--text-bubble-border-color: hsl(221, 15%, 25%);border:1px solid var(--text-bubble-border-color, #f2f2f3);--status-bar-border-color: var(--text-bubble-border-color, #f2f2f3);box-shadow:0 6px 12px #0000002d;z-index:9000}.text-bubble.no-scroll{overflow-y:hidden}.text-bubble[data-theme=default-dark]{--text-bubble-border-color: hsl(0, 0%, 39%)}.text-bubble[data-theme=default-minimal]{--text-bubble-border-color: hsl(0, 0%, 89%)}.text-bubble[data-theme=paper-light]{--text-bubble-border-color: hsl(53, 8%, 58%)}.text-bubble[data-theme=paper-dark-dark]{--text-bubble-border-color: hsl(203, 42%, 17%)}.text-bubble[data-theme=blue]{--text-bubble-border-color: hsl(227, 68%, 62%)}.text-bubble[data-theme=purple]{--text-bubble-border-color: hsl(267, 39%, 60%)}.text-bubble[data-theme=green]{--text-bubble-border-color: hsl(136, 29%, 50%)}.text-bubble[data-theme=orange]{--text-bubble-border-color: hsl(43, 71%, 51%)}.text-bubble[data-theme=red]{--text-bubble-border-color: hsl(4, 58%, 56%)}.text-bubble[data-theme=spring]{--text-bubble-border-color: hsl(72, 64%, 57%)}.text-bubble[data-theme=kyoto]{--text-bubble-border-color: hsl(331, 21%, 26%)}.text-bubble[data-theme=newyork]{--text-bubble-border-color: hsl(176, 29%, 67%)}.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 vr=()=>{let[e,t]=R([]),r=$((s,c)=>t(l=>c?[...l.slice(0,s),c]:[...l.slice(0,s)]),[]),[o,n]=R([{bubble:s=>r(0,s),hide:()=>r(0)}]);return C(()=>{n(([s,...c])=>[s,...e.map((l,m)=>l===c.at(m)?.source?c.at(m):{source:l,parentTitles:[scrapbox.Page.title??"",...e.slice(0,m).map(p=>p.title)],bubble:p=>r(m+1,p),hide:()=>r(m+1)})])},[e]),o};var Ge=(e,t,r,o,n)=>{C(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var wr=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),Pe=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link"),_r=(e,...t)=>e!==void 0&&t.includes(e);var Xe="scrap-bubble",Er=G();q(Er,"#editor");var Lr=({delay:e,whiteList:t,scrollTargets:r,watchList:o,style:n})=>{let[{bubble:s,hide:c},...l]=vr(),m=$((p,i)=>{let d=[scrapbox.Project.name,...t.filter(u=>u!==scrapbox.Project.name)];Vt(i,d.includes(p)?d:[p],o)},[t,o]);return Ge(Er,"pointerenter",async p=>{q(p.currentTarget,"event.currentTarget");let i=p.target;if(!Pe(i)&&!wr(i))return;let{project:d=scrapbox.Project.name,title:u,hash:f=""}=Pe(i)?Q({pathType:"root",href:`${new URL(i.href).pathname}${new URL(i.href).hash}`}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(d==="")return;let g=decodeURIComponent(u??"");if(m(d,g),!await V(i,e))return;let h=f!==""&&r.includes("lineId")?{type:"id",value:f}:i.dataset.linkedTo&&_r(i.dataset.linkedType,"link","hashtag","title")&&r.includes(i.dataset.linkedType)?{type:"link",value:i.dataset.linkedTo}:void 0;s({project:d,title:g,scrollTo:h,position:J(i),type:es(i)})},{capture:!0},[e,t,o]),Ge(document,"click",p=>{p.target.dataset.userscriptName!==Xe&&c()},{capture:!0},[c]),C(()=>(scrapbox.addListener("page:changed",c),()=>scrapbox.removeListener("page:changed",c)),[c]),a(k,null,a("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),a("style",null,kr),a(yr,{style:n}),l.map(p=>a(hr,{...p,whiteList:t,delay:e,prefetch:m})))},es=e=>Pe(e)?e.type==="link"?"link":"hashtag":"title";var Md=e=>{let{delay:t=500,whiteList:r=[],watchList:o=yt().slice(0,100),scrollTargets:n=["link","hashtag","lineId","title"],style:s="",debug:c=!1}=e??{};Gt(c);let l=document.createElement("div");l.dataset.userscriptName=Xe;let m=G();q(m,"#editor"),m.append(l);let p=l.attachShadow({mode:"open"});be(a(Lr,{delay:t,whiteList:[scrapbox.Project.name,...r],watchList:o,scrollTargets:n,style:s}),p)};export{Md as mount};