ScrapBubble-min
/takker/takker99/ScrapBubbleをこのリンクでbuildしたもの
code:mod.js
var Oe,k,Zt,En,oe,Vt,er,ct,tr,dt,lt,pt,rr,_e={},or=[],_n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,mt=Array.isArray;function J(e,t){for(var r in t)er=tr;return e}function ft(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function nr(e,t,r){var o,n,s,a={};for(s in t)s=="key"?o=ts:s=="ref"?n=ts:as=ts;if(arguments.length>2&&(a.children=arguments.length>3?Oe.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)as===void 0&&(as=e.defaultPropss);return Ie(e,a,o,n,null)}function Ie(e,t,r,o,n){var s={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:n??++Zt,__i:-1,__u:0};return n==null&&k.vnode!=null&&k.vnode(s),s}function P(e){return e.children}function Me(e,t){this.props=e,this.context=t}function le(e,t){if(t==null)return e.__?le(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__kt)!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?le(e):null}function sr(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.__kt)!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return sr(e)}}function ut(e){(!e.__d&&(e.__d=!0)&&oe.push(e)&&!Fe.__r++||Vt!==k.debounceRendering)&&((Vt=k.debounceRendering)||er)(Fe)}function Fe(){var e,t,r,o,n,s,a,l;for(oe.sort(ct);e=oe.shift();)e.__d&&(t=oe.length,o=void 0,s=(n=(r=e).__v).__e,a=[],l=[],r.__P&&((o=J({},n)).__v=n.__v+1,k.vnode&&k.vnode(o),gt(r.__P,o,n,r.__n,r.__P.namespaceURI,32&n.__u?s:null,a,s??le(n),!!(32&n.__u),l),o.__v=n.__v,o.__.__ko.__i=o,cr(a,o,l),o.__e!=s&&sr(o)),oe.length>t&&oe.sort(ct));Fe.__r=0}function ir(e,t,r,o,n,s,a,l,i,c,m){var u,g,d,f,b,w,y=o&&o.__k||or,E=t.length;for(i=kn(r,t,y,i,E),u=0;u<E;u++)(d=r.__ku)!=null&&(g=d.__i===-1?_e:yd.__i||_e,d.__i=u,w=gt(e,d,g,n,s,a,l,i,c,m),f=d.__e,d.ref&&g.ref!=d.ref&&(g.ref&&ht(g.ref,null,d),m.push(d.ref,d.__c||f,d)),b==null&&f!=null&&(b=f),4&d.__u||g.__k===d.__k?i=ar(d,i,e):typeof d.type=="function"&&w!==void 0?i=w:f&&(i=f.nextSibling),d.__u&=-7);return r.__e=b,i}function kn(e,t,r,o,n){var s,a,l,i,c,m=r.length,u=m,g=0;for(e.__k=new Array(n),s=0;s<n;s++)(a=ts)!=null&&typeof a!="boolean"&&typeof a!="function"?(i=s+g,(a=e.__ks=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Ie(null,a,null,null,null):mt(a)?Ie(P,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?Ie(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,l=null,(c=a.__i=Tn(a,r,i,u))!==-1&&(u--,(l=rc)&&(l.__u|=2)),l==null||l.__v===null?(c==-1&&g--,typeof a.type!="function"&&(a.__u|=4)):c!=i&&(c==i-1?g--:c==i+1?g++:(c>i?g--:g++,a.__u|=4))):e.__ks=null;if(u)for(s=0;s<m;s++)(l=rs)!=null&&!(2&l.__u)&&(l.__e==o&&(o=le(l)),lr(l,l));return o}function ar(e,t,r){var o,n;if(typeof e.type=="function"){for(o=e.__k,n=0;o&&n<o.length;n++)on&&(on.__=e,t=ar(on,t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=le(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Tn(e,t,r,o){var n,s,a=e.key,l=e.type,i=tr;if(i===null||i&&a==i.key&&l===i.type&&!(2&i.__u))return r;if(o>(i!=null&&!(2&i.__u)?1:0))for(n=r-1,s=r+1;n>=0||s<t.length;){if(n>=0){if((i=tn)&&!(2&i.__u)&&a==i.key&&l===i.type)return n;n--}if(s<t.length){if((i=ts)&&!(2&i.__u)&&a==i.key&&l===i.type)return s;s++}}return-1}function Yt(e,t,r){t0=="-"?e.setProperty(t,r??""):et=r==null?"":typeof r!="number"||_n.test(t)?r:r+"px"}function Se(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||Yt(e.style,t,"");if(r)for(t in r)o&&rt===ot||Yt(e.style,t,rt)}else if(t0=="o"&&t1=="n")s=t!=(t=t.replace(tr,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.lt+s=r,r?o?r.u=o.u:(r.u=dt,e.addEventListener(t,s?pt:lt,s)):e.removeEventListener(t,s?pt:lt,s);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{et=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t4!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Jt(e){return function(t){if(this.l){var r=this.lt.type+e;if(t.t==null)t.t=dt++;else if(t.t<r.u)return;return r(k.event?k.event(t):t)}}}function gt(e,t,r,o,n,s,a,l,i,c){var m,u,g,d,f,b,w,y,E,re,Y,Re,xe,Xt,Ce,it,at,G=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(i=!!(32&r.__u),s=l=t.__e=r.__e),(m=k.__b)&&m(t);e:if(typeof G=="function")try{if(y=t.props,E="prototype"in G&&G.prototype.render,re=(m=G.contextType)&&om.__c,Y=m?re?re.props.value:m.__:o,r.__c?w=(u=t.__c=r.__c).__=u.__E:(E?t.__c=u=new G(y,Y):(t.__c=u=new Me(y,Y),u.constructor=G,u.render=Pn),re&&re.sub(u),u.props=y,u.state||(u.state={}),u.context=Y,u.__n=o,g=u.__d=!0,u.__h=[],u._sb=[]),E&&u.__s==null&&(u.__s=u.state),E&&G.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=J({},u.__s)),J(u.__s,G.getDerivedStateFromProps(y,u.__s))),d=u.props,f=u.state,u.__v=t,g)E&&G.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),E&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(E&&G.getDerivedStateFromProps==null&&y!==d&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(y,Y),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(y,u.__s,Y)===!1||t.__v==r.__v)){for(t.__v!=r.__v&&(u.props=y,u.state=u.__s,u.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(Ee){Ee&&(Ee.__=t)}),Re=0;Re<u._sb.length;Re++)u.__h.push(u._sbRe);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(y,u.__s,Y),E&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(d,f,b)})}if(u.context=Y,u.props=y,u.__P=e,u.__e=!1,xe=k.__r,Xt=0,E){for(u.state=u.__s,u.__d=!1,xe&&xe(t),m=u.render(u.props,u.state,u.context),Ce=0;Ce<u._sb.length;Ce++)u.__h.push(u._sbCe);u._sb=[]}else do u.__d=!1,xe&&xe(t),m=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++Xt<25);u.state=u.__s,u.getChildContext!=null&&(o=J(J({},o),u.getChildContext())),E&&!g&&u.getSnapshotBeforeUpdate!=null&&(b=u.getSnapshotBeforeUpdate(d,f)),l=ir(e,mt(it=m!=null&&m.type===P&&m.key==null?m.props.children:m)?it:it,t,r,o,n,s,a,l,i,c),u.base=t.__e,t.__u&=-161,u.__h.length&&a.push(u),w&&(u.__E=u.__=null)}catch(Ee){if(t.__v=null,i||s!=null)if(Ee.then){for(t.__u|=i?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;ss.indexOf(l)=null,t.__e=l}else for(at=s.length;at--;)ft(sat);else t.__e=r.__e,t.__k=r.__k;k.__e(Ee,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=wn(r.__e,t,r,o,n,s,a,i,c);return(m=k.diffed)&&m(t),128&t.__u?void 0:l}function cr(e,t,r){for(var o=0;o<r.length;o++)ht(ro,r++o,r++o);k.__c&&k.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(s){s.call(n)})}catch(s){k.__e(s,n.__v)}})}function wn(e,t,r,o,n,s,a,l,i){var c,m,u,g,d,f,b,w=r.props,y=t.props,E=t.type;if(E=="svg"?n="http://www.w3.org/2000/svg":E=="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((d=s[c])&&"setAttribute"in d==!!E&&(E?d.localName==E:d.nodeType==3)){e=d,sc=null;break}}if(e==null){if(E==null)return document.createTextNode(y);e=document.createElementNS(n,E,y.is&&y),l&&(k.__m&&k.__m(t,s),l=!1),s=null}if(E===null)w===y||l&&e.data===y||(e.data=y);else{if(s=s&&Oe.call(e.childNodes),w=r.props||_e,!l&&s!=null)for(w={},c=0;c<e.attributes.length;c++)w[(d=e.attributesc).name]=d.value;for(c in w)if(d=wc,c!="children"){if(c=="dangerouslySetInnerHTML")u=d;else if(!(c in y)){if(c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y)continue;Se(e,c,null,d,n)}}for(c in y)d=yc,c=="children"?g=d:c=="dangerouslySetInnerHTML"?m=d:c=="value"?f=d:c=="checked"?b=d:l&&typeof d!="function"||wc===d||Se(e,c,d,wc,n);if(m)l||u&&(m.__html===u.__html||m.__html===e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(u&&(e.innerHTML=""),ir(e,mt(g)?g:g,t,r,o,E=="foreignObject"?"http://www.w3.org/1999/xhtml":n,s,a,s?s[0]:r.__k&&le(r,0),l,i),s!=null)for(c=s.length;c--;)ft(s[c]);l||(c="value",E=="progress"&&f==null?e.removeAttribute("value"):f!==void 0&&(f!==ec||E=="progress"&&!f||E=="option"&&f!==wc)&&Se(e,c,f,wc,n),c="checked",b!==void 0&&b!==ec&&Se(e,c,b,wc,n))}return e}function ht(e,t,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(n){k.__e(n,r)}}function lr(e,t,r){var o,n;if(k.unmount&&k.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){k.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)on&&lr(on,t,r||typeof e.type!="function");r||ft(e.__e),e.__c=e.__=e.__e=void 0}function Pn(e,t,r){return this.constructor(e,r)}function bt(e,t,r){var o,n,s,a;t==document&&(t=document.documentElement),k.__&&k.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],a=[],gt(t,e=(!o&&r||t).__k=nr(P,null,e),n||_e,_e,t.namespaceURI,!o&&r?r:n?null:t.firstChild?Oe.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o,a),cr(s,e,a)}function yt(e,t){var r={__c:t="__cC"+rr++,__:e,Consumer:function(o,n){return o.children(n)},Provider:function(o){var n,s;return this.getChildContext||(n=new Set,(s={})t=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&n.forEach(function(l){l.__e=!0,ut(l)})},this.sub=function(a){n.add(a);var l=a.componentWillUnmount;a.componentWillUnmount=function(){n&&n.delete(a),l&&l.call(a)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}Oe=or.slice,k={__e:function(e,t,r,o){for(var n,s,a;t=t.__;)if((n=t.__c)&&!n.__)try{if((s=n.constructor)&&s.getDerivedStateFromError!=null&&(n.setState(s.getDerivedStateFromError(e)),a=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,o||{}),a=n.__d),a)return n.__E=n}catch(l){e=l}throw e}},Zt=0,En=function(e){return e!=null&&e.constructor==null},Me.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=J({},this.state),typeof e=="function"&&(e=e(J({},r),this.props)),e&&J(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),ut(this))},Me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ut(this))},Me.prototype.render=P,oe=[],er=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ct=function(e,t){return e.__v.__b-t.__v.__b},Fe.__r=0,tr=/(PointerCapture)$|Capture$/i,dt=0,lt=Jt(!1),pt=Jt(!0),rr=0;var ne,N,xt,pr,ke=0,yr=[],R=k,ur=R.__b,dr=R.__r,mr=R.diffed,fr=R.__c,gr=R.unmount,hr=R.__;function Te(e,t){R.__h&&R.__h(N,e,ke||t),ke=0;var r=N.__H||(N.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function j(e){return ke=1,vn(Er,e)}function vn(e,t,r){var o=Te(ne++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):Er(void 0,t),function(l){var i=o.__N?o.__N0:o.__0,c=o.t(i,l);i!==c&&(o.__N=[c,o.__1],o.__c.setState({}))}],o.__c=N,!N.u)){var n=function(l,i,c){if(!o.__c.__H)return!0;var m=o.__c.__H.__.filter(function(g){return!!g.__c});if(m.every(function(g){return!g.__N}))return!s||s.call(this,l,i,c);var u=o.__c.props!==l;return m.forEach(function(g){if(g.__N){var d=g.__0;g.__=g.__N,g.__N=void 0,d!==g.__0&&(u=!0)}}),s&&s.call(this,l,i,c)||u};N.u=!0;var s=N.shouldComponentUpdate,a=N.componentWillUpdate;N.componentWillUpdate=function(l,i,c){if(this.__e){var m=s;s=void 0,n(l,i,c),s=m}a&&a.call(this,l,i,c)},N.shouldComponentUpdate=n}return o.__N||o.__}function W(e,t){var r=Te(ne++,3);!R.__s&&kt(r.__H,t)&&(r.__=e,r.i=t,N.__H.__h.push(r))}function xr(e,t){var r=Te(ne++,4);!R.__s&&kt(r.__H,t)&&(r.__=e,r.i=t,N.__h.push(r))}function _t(e){return ke=5,v(function(){return{current:e}},[])}function v(e,t){var r=Te(ne++,7);return kt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function H(e,t){return ke=8,v(function(){return e},t)}function Z(e){var t=N.contexte.__c,r=Te(ne++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(N)),t.props.value):e.__}function Nn(){for(var e;e=yr.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Be),e.__H.__h.forEach(Et),e.__H.__h=[]}catch(t){e.__H.__h=[],R.__e(t,e.__v)}}R.__b=function(e){N=null,ur&&ur(e)},R.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),hr&&hr(e,t)},R.__r=function(e){dr&&dr(e),ne=0;var t=(N=e.__c).__H;t&&(xt===N?(t.__h=[],N.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Be),t.__h.forEach(Et),t.__h=[],ne=0)),xt=N},R.diffed=function(e){mr&&mr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(yr.push(t)!==1&&pr===R.requestAnimationFrame||((pr=R.requestAnimationFrame)||Ln)(Nn)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),xt=N=null},R.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Be),r.__h=r.__h.filter(function(o){return!o.__||Et(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],R.__e(o,r.__v)}}),fr&&fr(e,t)},R.unmount=function(e){gr&&gr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Be(o)}catch(n){t=n}}),r.__H=void 0,t&&R.__e(t,r.__v))};var br=typeof requestAnimationFrame=="function";function Ln(e){var t,r=function(){clearTimeout(o),br&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,100);br&&(t=requestAnimationFrame(r))}function Be(e){var t=N,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),N=t}function Et(e){var t=N;e.__c=e.__(),N=t}function kt(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==eo})}function Er(e,t){return typeof t=="function"?t(e):t}var _r=" must not return ",Rn="transformer",Cn="recoverer",Sn="defaultValue",pa=Rn+_r,kr="called with ",ua=Sn+" must not be ",da=Cn+_r,In="Ok",Tr="Err",Mn=kr+Tr,ma=kr+In,fa="Carrying E in "+Tr+" instead of throwing it directly. See .cause",Tt="an instance of Error of the current realm.",ga="The thrown value is not "+Tt,ha="The contained E should be "+Tt,ba="This .cause is not "+Tt;function wt(e){return e.ok}function Q(e){return{ok:!0,val:e,err:null}}function L(e){return!e.ok}function pe(e){return{ok:!1,val:null,err:e}}function C(e){return Fn(e,Mn)}function Fn(e,t){if(L(e))throw new TypeError(t);return e.val}function wr(e){return e.val}function On(e){return e.err}async function Pr(e,t){if(L(e))return e;let r=wr(e);return await t(r)}async function M(e,t){if(L(e))return e;let r=wr(e),o=await t(r);return Q(o)}async function B(e,t){if(wt(e))return e;let r=On(e),o=await t(r);return pe(o)}var F=e=>e.ok?Q(e):pe({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var vr=async(e,t)=>{let r=new Request(e,t);try{return Q(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return pe({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return pe({name:"NetworkError",message:o.message,request:r});throw o}};var S=e=>{let{fetch:t=vr,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var O=e=>connect.sid=${e};function je(e,t={}){if(e===null)return"null";if(Array.isArray(e))return jn(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:Hn(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function jn(e,t){let{threshold:r=20}=t,o=e.map(a=>je(a,t)),n=o.join(", ");if(n.length<=r)return[${n}];let s=o.join(`,
);return[
${Nr(2,s)}
]}function Hn(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(a=>${a.toString()}: ${je(ea,t)}),n=o.join(", ");if(n.length<=r)return{${n}};let s=o.join(,
);return{
${Nr(2,s)}
}}function Nr(e,t){let r=" ".repeat(e);return t.split(
).map(o=>${r}${o}).join(
)}function He(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${t}(${r.map(n=>je(n)).join(", ")}),o)}})}function Ae(e){return Array.isArray(e)}function Lr(e){return He(t=>Ae(t)&&t.every(r=>e(r)),"isArrayOf",e)}function Pt(e){let t=new Set(e);return He(r=>t.has(r),"isLiteralOneOf",e)}function vt(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function se(e){return typeof e=="string"}var A=async(e,t)=>{let r=e.response.clone(),o=Pt(t);try{let n=await r.json();if(!vt(n))return;if(r.status===422){if(!se(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!se(n.message)?void 0:n.name==="NotLoggedInError"?!vt(n.detals)||!se(n.detals.project)||!Lr(An)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},An=Pt(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var $=e=>e.replaceAll(" ","_").toLowerCase();var D=e=>[...e].map((t,r)=>t===" "?"_":!$n.includes(t)||r===e.length-1&&Dn.includes(t)?encodeURIComponent(t):t).join(""),$n='@$&+=:;",',Dn=':;",';var Rr=" must not return ",Un="transformer",qn="recoverer",zn="defaultValue",Kn=Un+Rr,Gn="called with ",Wn=zn+" must not be ",Qn=qn+Rr,$e="null or undefined",Za=Kn+$e,ec=Gn+$e,Xn=Wn+$e,tc=Qn+$e;function Cr(e){return e!=null}function Vn(e,t){if(Cr(e))return e;throw new TypeError(t)}function Sr(e,t){return Cr(e)?e:Vn(t,Xn)}var Ir=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:a}=S(r??{}),l=new URLSearchParams([["followRename",${s??!0}],...a?.map?.(i=>["projects",i])??[]]);return new Request(https://${n}/api/pages/${e}/${D(t)}?${l},o?{headers:{Cookie:O(o)}}:void 0)},Mr=async e=>B(await M(F(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:Sr(await A(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),Nt=(()=>{let e=async(t,r,o)=>Pr(await S(o??{}).fetch(Ir(t,r,o)),n=>Mr(n));return e.toRequest=Ir,e.fromResponse=Mr,e})();var Fr=(e,t)=>{let{sid:r,hostName:o}=S(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:O(r)}}:void 0)},Or=async e=>M(await B(F(e),async t=>await A(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),Lt=(()=>{let e=async(t,r)=>{let{fetch:o}=S(r??{}),n=Fr(t,r),s=await o(n);return L(s)?s:Or(C(s))};return e.toRequest=Fr,e.fromResponse=Or,e})(),Br=(e,t)=>{let{sid:r,hostName:o}=S(t??{}),n=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${o}/api/projects?${n},r?{headers:{Cookie:O(r)}}:void 0)},jr=async e=>M(await B(F(e),async t=>await A(t,["NotLoggedInError"])??t),t=>t.json()),Hr=(()=>{let e=async(t,r)=>{let{fetch:o}=S(r??{}),n=await o(Br(t,r));return L(n)?n:jr(C(n))};return e.toRequest=Br,e.fromResponse=jr,e})();var Il=new TextEncoder;var Bl=new TextEncoder().encode("0123456789abcdef"),jl=new TextEncoder,Hl=new TextDecoder;var Yn=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Jn=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,Zn=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,es=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Ar=e=>{if(Yn.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(Jn);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(Zn);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(es);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var ts=/https?:\/\/vimeo\.com\/([0-9]+)/i,$r=e=>{let t=e.match(ts);if(t)return t[1]};var rs=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Dr=e=>{let t=e.match(rs);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var os=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Ur=e=>{let t=e.match(os);if(!t)return;let[,r]=t;return r};var qr=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let a=Ar(n);if(a)return{type:"youtube",href:n,...a,...s};let l=$r(n);if(l)return{type:"vimeo",videoId:l,href:n,...s};let i=Dr(n);if(i)return{type:"spotify",href:n,...i,...s};let c=Ur(n);if(c)return{type:"anchor-fm",videoId:c,href:n,...s};if(ss(n))return{type:"video",href:n,...s}}return ns(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},ns=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),ss=e=>/\.(?:mp4|webm)$/.test(e);var zr=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,a])=>a-s).map(([s])=>s),o=await Hr([]);if(L(o))return r;let n=C(o).projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var is;(e=>{})(is||={});var as="0.13.3",Kr,Rt,Gr=async(e=as)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(Rt)throw Rt;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,await new Promise((o,n)=>{r.onload=()=>o(),r.onerror=s=>{Rt=s,n(s)},document.head.append(r)})}return new Promise(r=>{let o=setInterval(()=>{Kr&&(clearInterval(o),r(Kr))},500)})};var Ue=(e,t)=>{let[r,o]=j("");return{ref:H(s=>{if(!s){o("");return}Gr().then(a=>{try{a.render(e,s,t),o("")}catch(l){if(l instanceof Error&&l.name==="ParseError")o(l.message.slice(19));else throw l}})},[e,...Object.values(t??{})]),error:r}};function ie(e,t={}){let{signal:r,persistent:o=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((n,s)=>{let a=()=>{clearTimeout(i),s(r?.reason)},i=setTimeout(()=>{r?.removeEventListener("abort",a),n()},e);if(r?.addEventListener("abort",a,{once:!0}),o===!1)try{Deno.unrefTimer(i)}catch(c){if(!(c instanceof ReferenceError))throw c;console.error("persistent option is only available in Deno")}})}var Ct=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_${$(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var Wr=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 gs=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),Qr=(e,t)=>{let r=e[e.length-1];return r!==void 0&&gs(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)},Xr=(e,t)=>{if(t.hasTitle??!0){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(Qr,[])]}return e.reduce(Qr,[])};var Vr=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var Yr=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(o+1)).join(
)}};var h=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,a)=>{if(!t&&s.nested)return a?.()??[];if(!r&&s.quoted)return a?.()??[];for(let l of o){let i=l.exec(n);if(i===null)continue;let c=n.substring(0,i.index),m=n.substring(i.index+(i[0]?.length??0)),u=e(i[0]??"",s);return[...U(c,s),...u,...U(m,s)]}return a?.()??[]};var x=e=>[{type:"plain",raw:e,text:e}],Jr=h(x,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var hs=/\[\s+\]/,bs=(e,t)=>t.context==="table"?x(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Zr=h(bs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[hs]});var ys=/.*?/,xs=(e,t)=>t.context==="table"?x(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],eo=h(xs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ys]});var Es=/^[$%] .+$/,_s=(e,t)=>{if(t.context==="table")return x(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},to=h(_s,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Es]});var ks=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Ts=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let a=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:U(n,{...t,nested:!0})}]},ro=h(Ts,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ks]});var ws=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,Ps=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,vs=/\[https?:\/\/[^\s\]]+\]/,Ns=/https?:\/\/[^\s]+/,Ls=(e,t)=>{if(t.context==="table")return x(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()}]},oo=h(Ls,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ws,Ps,vs,Ns]});var Rs=/\[\$ .+? \]/,Cs=/\[\$ [^\]]+\]/,Ss=(e,t)=>t.context==="table"?x(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],no=h(Ss,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Rs,Cs]});var so=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,io=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Is=e=>{let[t="",r="",o=""]=e.split(","),n=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(o)?Number.parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:a}},Ms=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.match(so)??e.match(io);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,n="",s=""]=o?r:[r[0],r[2],r[1]],{latitude:a,longitude:l,zoom:i}=Is(n),c=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${a},${l},${i}z:https://www.google.com/maps/@${a},${l},${i}z;return[{type:"googleMap",raw:e,latitude:a,longitude:l,zoom:i,place:s,url:c}]},ao=h(Ms,{parseOnNested:!1,parseOnQuoted:!0,patterns:[so,io]});var Fs=/(?:^|\s)#\S+/,Os=(e,t)=>{if(t.context==="table")return x(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[...x(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},co=h(Os,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Fs]});var Bs=/^\? .+$/,js=(e,t)=>t.context==="table"?x(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],lo=h(js,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Bs]});var Hs=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,As=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),o=t.substring(0,r),n=o.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),a=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:o,pathType:n,type:"icon",raw:e}))},po=h(As,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Hs]});var $s=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Ds=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,Us=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,qs=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,zs=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Ks(e),Ks=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),Gs=(e,t)=>{if(t.context==="table")return x(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).replace(/^\s+/,""):"",[s,a]=zs(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},uo=h(Gs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[$s,Ds,Us,qs]});var Ws=/\[\/?[^[\]]+\]/,Qs=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},mo=h(Qs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Ws]});var Xs=/^[0-9]+\. .*$/,Vs=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=Number.parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:U(s,{...t,nested:!1})}]},fo=h(Vs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Xs]});var Ys=/^>.*$/,Js=(e,t)=>t.context==="table"?x(e,t):[{type:"quote",raw:e,nodes:U(e.substring(1),{...t,quoted:!0})}],go=h(Js,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Ys]});var Zs=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,ei=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.substring(2,e.length-2),o=r.lastIndexOf(".icon"),n=r.substring(0,o),s=n.startsWith("/")?"root":"relative",a=r.substring(o+5,r.length),l=a.startsWith("*")?Number.parseInt(a.substring(1),10):1;return new Array(l).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},ho=h(ei,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Zs]});var ti=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,ri=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,oi=(e,t)=>{if(t.context==="table")return x(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}]},bo=h(oi,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ti,ri]});var ni=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,si=(e,t)=>t.context==="table"?x(e,t):[{type:"strong",raw:e,nodes:U(e.substring(2,e.length-2),{...t,nested:!0})}],yo=h(si,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ni]});var ii=(e,t,r)=>e===""?[]:r?.()??[],ai=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>Jr(t,r))(),U=ai(ii,go,lo,fo,eo,to,no,Zr,ro,bo,ho,yo,uo,oo,po,ao,mo,co);var xo=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:U(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Eo=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(a=>a.text.substring(o+1)).map(a=>a.split(" ").map(l=>U(l,{nested:!1,quoted:!1,context:"table"})))}};var _o=e=>({type:"title",text:e.rows[0].text});var ko=e=>{switch(e.type){case"title":return _o(e);case"codeBlock":return Yr(e);case"table":return Eo(e);case"line":return xo(e)}};var we=(e,t)=>{let r=Vr(e);return Xr(r,{hasTitle:t?.hasTitle??!0}).map(ko)};var To=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let a=s[0]().finally(()=>o(a)).then(l=>s[1](l)).catch(l=>s[2](l));r.add(a)};return n=>{if(r.size<e){let s=n().finally(()=>o(s));return r.add(s),s}return new Promise((s,a)=>{t.push([n,s,a])})}};var ci="0.6.5",vo=ScrapBubble-${ci},wo=await globalThis.caches.open(vo);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==vo&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var Po=To(3);async function*ze(e,t){let r=((t?.saveFailedResponse?wo.match(e):void 0)??Wr(e,t)).then(a=>["cache",a]);{let a=ie(1e3).then(()=>"timeout"),l=await Promise.race([r,a]);if(l!=="timeout"){l[1]&&(yield["cache",l[1]]);let i=await Po(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await wo.put(e,i.clone()),yield["network",i]}}let o=Po(()=>fetch(e)).then(a=>["network",a]),[n,s]=await Promise.race([r,o]);if(n==="network"){yield[n,s];return}s&&(yield[n,s]),yield await o}var No=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Ke=()=>{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 q=!1,Lo=e=>{q=typeof e=="boolean"?e:new Set(e)},ee=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)=>{q!==!0&&(!q||!q.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{q!==!0&&(!q||!q.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{q!==!0&&(!q||!q.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(q!==!0&&(!q||!q.has(e))))return r(...o)}]}}));var St=Ke(),Ge=new Map,li=ee("ScrapBubble:useProject.ts"),Ro=e=>{let[t,r]=j();return W(()=>{St.on(e,r);let o=Ge.get(e);return o?r(o.loading?void 0:o.value):(Ge.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=Lt.toRequest(e);for await(let[,s]of ze(n)){let a=await Lt.fromResponse(s);Ge.set(e,{loading:!1,value:a}),St.dispatch(e,a);break}}catch(n){li.error(n),Ge.delete(e)}})()),()=>St.off(e,r)},[e]),t};var pi=["default-light","default-dark","default-minimal"],ui=["paper-light","paper-dark-dark","paper-dark"],Co=["blue","purple","green","orange","red"],di=["hacker1","hacker2"],So=["winter","spring","summer","automn"],Io=["tropical"],Mo=["kyoto","newyork","paris"],Fo=["mred","lgreen"],Jf=["default-light","default-minimal","paper-light",...Co,...So,...Io,...Mo,...Fo];var mi=[...pi,...ui,...Co,...di,...So,...Io,...Mo,...Fo];function Oo(e){return mi.includes(e)}var Bo="default-light",ae=e=>{let t=Ro(e);return v(()=>{if(!t||L(t))return Bo;let r=C(t).theme;return Oo(r)?r:Bo},[t])};var ue=(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 de=e=>{let{top:t,right:r,left:o,bottom:n}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),a=(o-s.left)/s.width>.5;return{top:Math.round(n-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...a?{right:Math.round(s.right-r)}:{left:Math.round(o-s.left)},maxWidth:a?r-10:document.documentElement.clientWidth-o-10}};var fi=0,pg=Array.isArray;function p(e,t,r,o,n,s){t||(t={});var a,l,i=t;"ref"in t&&(a=t.ref,delete t.ref);var c={type:e,props:i,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--fi,__i:-1,__u:0,__source:n,__self:s};if(typeof e=="function"&&(a=e.defaultProps))for(l in a)i[l]===void 0&&(i[l]=a[l]);return k.vnode&&k.vnode(c),c}var jo=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:a,prefetch:l})=>{let i=v(()=>o?[]:we(r.join(
),{hasTitle:!1}),[o,r]),c=ae(e),m=H(async({currentTarget:g})=>{l(e,t),await ue(g,a)&&s({project:e,title:t,linkTo:n,type:"link",position:de(g)})},[e,t,a,n?.project,n?.titleLc]),u=v(()=>n?()=>{Ct({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return p("a",{className:"related-page-card page-link",type:"link","data-theme":c,href:/${e}/${D(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:m,onClick:u,children:[p("div",{class:"hover"}),p("div",{class:"content",children:[p("div",{class:"header",children:p("div",{class:"title",children:t})}),o?p("div",{class:"thumbnail",children:p("img",{src:o})}):p("div",{class:"description",children:i.flatMap((g,d)=>g.type==="line"?[p("p",{children:g.nodes.map(f=>p(Ho,{node:f,project:e}))},d)]:[])})]})]})},Ho=({node:e,project:t})=>{switch(e.type){case"code":return p("code",{children:e.text});case"formula":return p(gi,{node:e});case"commandLine":return p("code",{children:[e.symbol," $",e.text]});case"helpfeel":return p("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return p(P,{children:e.nodes.map(r=>p(Ho,{node:r,project:t}))});case"icon":case"strongIcon":return p(hi,{node:e,project:t});case"hashTag":return p(bi,{node:e});case"link":return p(yi,{node:e});case"plain":case"blank":return p(P,{children:e.text});default:return p(P,{})}},gi=({node:{formula:e}})=>{let{ref:t,error:r}=Ue(e);return p("span",{className:formula ${r?" error":""},children:r?p("code",{children:e}):p("span",{className:"katex-display",ref:t})})},hi=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return p("img",{class:"icon",src:/api/pages/${o}/${D(n)}/icon})},bi=({node:{href:e}})=>p("span",{class:"page-link",children:["#",e]}),yi=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?p("span",{class:"page-link",children:t}):p("span",{class:"link",children:r||t});var T=(e,t)=>/${e.toLowerCase()}/${$(t)},We=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var zo=Symbol.for("immer-nothing"),Ao=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function K(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var me=Object.getPrototypeOf;function fe(e){return!!e&&!!e[_]}function V(e){return e?Ko(e)||Array.isArray(e)||!!e[Ao]||!!e.constructor?.[Ao]||Je(e)||Ze(e):!1}var xi=Object.prototype.constructor.toString();function Ko(e){if(!e||typeof e!="object")return!1;let t=me(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)===xi}function Pe(e,t){Ye(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,o)=>t(o,r,e))}function Ye(e){let t=e[_];return t?t.type_:Array.isArray(e)?1:Je(e)?2:Ze(e)?3:0}function Ft(e,t){return Ye(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Go(e,t,r){let o=Ye(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function Ei(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Je(e){return e instanceof Map}function Ze(e){return e instanceof Set}function I(e){return e.copy_||e.base_}function Ot(e,t){if(Je(e))return new Map(e);if(Ze(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Ko(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 a=n[s],l=o[a];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(o[a]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[a]})}return Object.create(me(e),o)}else{let o=me(e);if(o!==null&&r)return{...e};let n=Object.create(o);return Object.assign(n,e)}}function At(e,t=!1){return et(e)||fe(e)||!V(e)||(Ye(e)>1&&(e.set=e.add=e.clear=e.delete=_i),Object.freeze(e),t&&Object.entries(e).forEach(([r,o])=>At(o,!0))),e}function _i(){K(2)}function et(e){return Object.isFrozen(e)}var Bt={};function ce(e){let t=Bt[e];return t||K(0,e),t}function ki(e,t){Bt[e]||(Bt[e]=t)}var ve;function Qe(){return ve}function Ti(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function $o(e,t){t&&(ce("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function jt(e){Ht(e),e.drafts_.forEach(wi),e.drafts_=null}function Ht(e){e===ve&&(ve=e.parent_)}function Do(e){return ve=Ti(ve,e)}function wi(e){let t=e[_];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Uo(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[_].modified_&&(jt(t),K(4)),V(e)&&(e=Xe(t,e),t.parent_||Ve(t,e)),t.patches_&&ce("Patches").generateReplacementPatches_(r[_].base_,e,t.patches_,t.inversePatches_)):e=Xe(t,r,[]),jt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==zo?e:void 0}function Xe(e,t,r){if(et(t))return t;let o=t[_];if(!o)return Pe(t,(n,s)=>qo(e,o,t,n,s,r)),t;if(o.scope_!==e)return t;if(!o.modified_)return Ve(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let n=o.copy_,s=n,a=!1;o.type_===3&&(s=new Set(n),n.clear(),a=!0),Pe(s,(l,i)=>qo(e,o,n,l,i,r,a)),Ve(e,n,!1),r&&e.patches_&&ce("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function qo(e,t,r,o,n,s,a){if(fe(n)){let l=s&&t&&t.type_!==3&&!Ft(t.assigned_,o)?s.concat(o):void 0,i=Xe(e,n,l);if(Go(r,o,i),fe(i))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(V(n)&&!et(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Xe(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,o)&&Ve(e,n)}}function Ve(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&At(t,r)}function Pi(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Qe(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=$t;r&&(n=[o],s=Ne);let{revoke:a,proxy:l}=Proxy.revocable(n,s);return o.draft_=l,o.revoke_=a,l}var $t={get(e,t){if(t===_)return e;let r=I(e);if(!Ft(r,t))return vi(e,r,t);let o=r[t];return e.finalized_||!V(o)?o:o===It(e.base_,t)?(Mt(e),e.copy_[t]=Le(o,e)):o},has(e,t){return t in I(e)},ownKeys(e){return Reflect.ownKeys(I(e))},set(e,t,r){let o=Wo(I(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=It(I(e),t),s=n?.[_];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Ei(r,n)&&(r!==void 0||Ft(e.base_,t)))return!0;Mt(e),X(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 It(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mt(e),X(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=I(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){K(11)},getPrototypeOf(e){return me(e.base_)},setPrototypeOf(){K(12)}},Ne={};Pe($t,(e,t)=>{Ne[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ne.deleteProperty=function(e,t){return Ne.set.call(this,e,t,void 0)};Ne.set=function(e,t,r){return $t.set.call(this,e[0],t,r,e[0])};function It(e,t){let r=e[_];return(r?I(r):e)[t]}function vi(e,t,r){let o=Wo(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Wo(e,t){if(!(t in e))return;let r=me(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=me(r)}}function X(e){e.modified_||(e.modified_=!0,e.parent_&&X(e.parent_))}function Mt(e){e.copy_||(e.copy_=Ot(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ni=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 a=this;return function(l=s,...i){return a.produce(l,c=>r.call(this,c,...i))}}typeof r!="function"&&K(6),o!==void 0&&typeof o!="function"&&K(7);let n;if(V(t)){let s=Do(this),a=Le(t,void 0),l=!0;try{n=r(a),l=!1}finally{l?jt(s):Ht(s)}return $o(s,o),Uo(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===zo&&(n=void 0),this.autoFreeze_&&At(n,!0),o){let s=[],a=[];ce("Patches").generateReplacementPatches_(t,n,s,a),o(s,a)}return n}else K(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let o,n;return[this.produce(t,r,(s,a)=>{o=s,n=a}),o,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){V(e)||K(8),fe(e)&&(e=Li(e));let t=Do(this),r=Le(e,void 0);return r[_].isManual_=!0,Ht(t),r}finishDraft(e,t){let r=e&&e[_];(!r||!r.isManual_)&&K(9);let{scope_:o}=r;return $o(o,t),Uo(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=ce("Patches").applyPatches_;return fe(e)?o(e,t):this.produce(e,n=>o(n,t))}};function Le(e,t){let r=Je(e)?ce("MapSet").proxyMap_(e,t):Ze(e)?ce("MapSet").proxySet_(e,t):Pi(e,t);return(t?t.scope_:Qe()).drafts_.push(r),r}function Li(e){return fe(e)||K(10,e),Qo(e)}function Qo(e){if(!V(e)||et(e))return e;let t=e[_],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Ot(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Ot(e,!0);return Pe(r,(o,n)=>{Go(r,o,Qo(n))}),t&&(t.finalized_=!1),r}function Xo(){class e extends Map{constructor(i,c){super(),this[_]={type_:2,parent_:c,scope_:c?c.scope_:Qe(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return I(this[_]).size}has(i){return I(this[_]).has(i)}set(i,c){let m=this[_];return a(m),(!I(m).has(i)||I(m).get(i)!==c)&&(r(m),X(m),m.assigned_.set(i,!0),m.copy_.set(i,c),m.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let c=this[_];return a(c),r(c),X(c),c.base_.has(i)?c.assigned_.set(i,!1):c.assigned_.delete(i),c.copy_.delete(i),!0}clear(){let i=this[_];a(i),I(i).size&&(r(i),X(i),i.assigned_=new Map,Pe(i.base_,c=>{i.assigned_.set(c,!1)}),i.copy_.clear())}forEach(i,c){let m=this[_];I(m).forEach((u,g,d)=>{i.call(c,this.get(g),g,this)})}get(i){let c=this[_];a(c);let m=I(c).get(i);if(c.finalized_||!V(m)||m!==c.base_.get(i))return m;let u=Le(m,c);return r(c),c.copy_.set(i,u),u}keys(){return I(this[_]).keys()}values(){let i=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let c=i.next();return c.done?c:{done:!1,value:this.get(c.value)}}}}entries(){let i=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let c=i.next();if(c.done)return c;let m=this.get(c.value);return{done:!1,value:[c.value,m]}}}}[Symbol.iterator](){return this.entries()}}function t(l,i){return new e(l,i)}function r(l){l.copy_||(l.assigned_=new Map,l.copy_=new Map(l.base_))}class o extends Set{constructor(i,c){super(),this[_]={type_:3,parent_:c,scope_:c?c.scope_:Qe(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return I(this[_]).size}has(i){let c=this[_];return a(c),c.copy_?!!(c.copy_.has(i)||c.drafts_.has(i)&&c.copy_.has(c.drafts_.get(i))):c.base_.has(i)}add(i){let c=this[_];return a(c),this.has(i)||(s(c),X(c),c.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let c=this[_];return a(c),s(c),X(c),c.copy_.delete(i)||(c.drafts_.has(i)?c.copy_.delete(c.drafts_.get(i)):!1)}clear(){let i=this[_];a(i),I(i).size&&(s(i),X(i),i.copy_.clear())}values(){let i=this[_];return a(i),s(i),i.copy_.values()}entries(){let i=this[_];return a(i),s(i),i.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(i,c){let m=this.values(),u=m.next();for(;!u.done;)i.call(c,u.value,u.value,this),u=m.next()}}function n(l,i){return new o(l,i)}function s(l){l.copy_||(l.copy_=new Set,l.base_.forEach(i=>{if(V(i)){let c=Le(i,l);l.drafts_.set(i,c),l.copy_.add(c)}else l.copy_.add(i)}))}function a(l){l.revoked_&&K(3,JSON.stringify(I(l)))}ki("MapSet",{proxyMap_:t,proxySet_:n})}var z=new Ni,tt=z.produce,Lg=z.produceWithPatches.bind(z),Rg=z.setAutoFreeze.bind(z),Cg=z.setUseStrictShallowCopy.bind(z),Sg=z.applyPatches.bind(z),Ig=z.createDraft.bind(z),Mg=z.finishDraft.bind(z);Xo();var Vo=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},Yo=(e,t)=>tt(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...a}=t;Object.assign(r,a),Dt(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}Dt(r)&&!Dt(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)}),Dt=e=>e.lines[0].id==="dummy";var Jo=(e,t)=>{let r=new Map,o=$(t.title);for(let i of t.links){let c=Ut(e,i);c.linked=[o],r.set(T(e,i),c)}let n=T(e,o),s=t.projectLinks.map(i=>{let c=We(i);return T(c.project,c.titleLc)}),a={...rt(e,t),linked:[],projectLinked:[]};r.set(n,a);let l=t.links.map(i=>$(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(o)&&a.linked.push(i.titleLc);for(let g of i.linksLc.filter(d=>l.includes(d))){let d=T(e,g),f=r.get(d)??Ut(e,g);if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let c=T(e,i.titleLc),m=rt(e,i),u=r.get(c)?.linked;u&&(m.linked=u),r.set(c,m)}for(let i of t.relatedPages.projectLinks1hop){let c=T(i.projectName,i.titleLc);s.includes(c)||a.projectLinked.push(c);let m=rt(i.projectName,i),u=r.get(c)?.projectLinked;u&&(m.projectLinked=u),r.set(c,m)}a.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let g of i.linksLc){let d=T(e,g),f=r.get(d)??Ut(e,g);if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let c=T(e,i.titleLc),m=rt(e,i),u=r.get(c)?.linked;u&&(m.linked=u),r.set(c,m)}return r},rt=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:$(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}),Ut=(e,t)=>({project:e,titleLc:$(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var ot=ee("ScrapBubble:bubble.ts"),qt=new Map,nt=new Set,zt=Ke();function*en(e){for(let t of e)yield qt.get(t)}var tn=(e,t)=>zt.on(e,t),rn=(e,t)=>zt.off(e,t),on=async(e,t,r,o)=>{let n=[];for(let s of[...t].reverse()){let a=T(s,e);nt.has(a)||n.push(Ri(s,e,r,o))}await Promise.all(n)},Zo=0,Ri=async(e,t,r,o)=>{let n=T(e,t);if(nt.has(n))return;nt.add(n);let s=Zo++,a=${s} Check update ${n};ot.time(a);try{let l=Nt.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[i,c]of ze(l,{ignoreSearch:!0,saveFailedResponse:!0})){ot.debug(${s}${i} ${n});let m=await Nt.fromResponse(c);if(wt(m)){let u=Jo(e,C(m));for(let[g,d]of u){let f=qt.get(g),b=Yo(f,d);b&&f!==b&&(qt.set(g,b),zt.dispatch(g,d))}}if(o?.ignoreFetch===!0||i==="cache"&&!No(c,o?.maxAge??60))break}}catch(l){ot.error(l)}finally{nt.delete(n),ot.timeEnd(a),Zo--}};var nn=ee("ScrapBubble:useBubbleData.ts"),ge=e=>{let[t,r]=j(Kt(e));return W(()=>{r(Kt(e));let o,n=()=>{clearTimeout(o),o=setTimeout(()=>{nn.debug(Update ${e.length} pages),r(Kt(e))},10)};return e.forEach(s=>tn(s,n)),()=>e.forEach(s=>rn(s,n))},e),t},Kt=e=>{let t=[...en(e)].flatMap(r=>r?[r]:[]);return nn.debug(Required: ${e.length} pages, ${t.length} found,t),t};var sn=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=v(()=>[...t.keys(),...r.keys()],[t,r]),a=ge(s),l=v(()=>[...o],[o]),i=v(()=>{let m=(u,g)=>{let d=l.indexOf(u.project),f=l.indexOf(g.project);return d===f?g.updated-u.updated:d<0?1:f<0?-1:d-f};return[...a].sort(m)},[a,l]),c=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 p("ul",{className:"card-bubble",style:c,onClick:n.onClick,children:i.map(({project:m,titleLc:u,lines:[{text:g}],descriptions:d,image:f})=>{let b=T(m,u),w=t.get(b)??r.get(b);return p("li",{children:p(jo,{project:m,title:g,linkTo:w,descriptions:d,thumbnail:f??"",...n})},b)})})};var he=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 Gt=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&$(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=he({pathType:r.pathType,href:r.href});return o?!n&&$(s)===e.titleLc:n===e.project&&$(s)===e.titleLc}case"quote":case"strong":case"decoration":return Gt(e,r.nodes)}});var te=yt({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),cn=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:a,...l})=>{let i=v(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),c=v(()=>{let d=0;return we(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]),m=v(()=>{if(s&&i.includes(s))return s;if(a)return c.find(d=>d.type!=="line"?!1:Gt(a,d.nodes))?.id},[c,i,s,a?.project,a?.titleLc]),u=_t(null);W(()=>{if(!m)return;let d=u.current?.querySelector(data-id="${m}"),f=globalThis.scrollY;d?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,f)},[m]);let g=ae(t);return p("div",{className:"lines","data-theme":g,ref:u,children:p(te.Provider,{value:{project:t,title:r,whiteList:o,...l},children:c.map(d=>{switch(d.type){case"title":return p(P,{children:[p(ye,{index:d.id,indent:0,noIndent:n,permalink:d.id===m,children:p("a",{className:"page-link",type:"link",href:/${t}/${D(d.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:d.text})},d.id),p("hr",{})]});case"codeBlock":return p(Ci,{block:d,noIndent:n,ids:d.ids,scrollId:m},d.ids[0]);case"table":return p(Si,{block:d,noIndent:n,ids:d.ids,scrollId:m},d.ids[0]);case"line":return p(ye,{index:d.id,indent:d.indent,noIndent:n,permalink:d.id===m,children:d.nodes.length>0?d.nodes.map(f=>p(be,{node:f})):p("br",{})},d.id)}})})})},ye=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>p("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:o}),Ci=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=Z(te),[l,i]=j(""),c=H(async m=>{m.preventDefault(),m.stopPropagation();try{await navigator.clipboard.writeText(t),i("Copied"),await ie(1e3),i("")}catch(u){alert(Failed to copy the code block
Error: ${u})}},[t]);return p(P,{children:[p(ye,{index:o[0],indent:r,permalink:o[0]===n,children:p("span",{className:"code-block",children:[p("span",{className:"code-block-start",children:p("a",{href:/api/code/${s}/${D(a)}/${e},target:"_blank",children:e})}),p("span",{className:"copy",title:"Copy",onClick:c,children:l})]})}),p(P,{children:t.split(
).map((m,u)=>p(ye,{index:o[u+1],indent:r,permalink:o[u+1]===n,children:p("code",{className:"code-block",children:m})}))})]})},Si=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=Z(te);return p(P,{children:[p(ye,{index:o[0],indent:r,permalink:o[0]===n,children:p("span",{className:"table-block",children:p("span",{className:"table-block-start",children:p("a",{href:/api/table/${s}/${D(a)}/${e}.csv,target:"_blank",children:e})})})}),p(P,{children:t.map((l,i)=>p(ye,{index:o[i+1],indent:r,permalink:o[i+1]===n,children:p("span",{className:"table-block table-block-row",children:l.map((c,m)=>p("span",{className:cell col-${m},children:c.map(u=>p(be,{node:u}))}))})}))})]})},be=({node:e})=>{switch(e.type){case"code":return p("code",{className:"code",children:e.text});case"formula":return p(Ii,{node:e});case"commandLine":return p(Fi,{node:e});case"helpfeel":return p("code",{className:"helpfeel",children:[p("span",{className:"prefix",children:"?"})," ",p("span",{className:"entry",children:e.text})]});case"quote":return p("blockquote",{className:"quote",children:e.nodes.map(t=>p(be,{node:t}))});case"strong":return p("strong",{children:e.nodes.map(t=>p(be,{node:t}))});case"decoration":return p(Mi,{node:e});case"plain":case"blank":return p(P,{children:e.text});case"hashTag":return p(ji,{node:e});case"link":return p(Hi,{node:e});case"googleMap":return p(Oi,{node:e});case"icon":return p(an,{node:e});case"strongIcon":return p(an,{node:e,strong:!0});case"image":return p(Bi,{node:e});case"strongImage":return p("img",{className:"image strong-image",src:e.src});case"numberList":return p(P,{children:[${e.number}. ,e.nodes.map(t=>p(be,{node:t}))]})}},Ii=({node:{formula:e}})=>{let{ref:t,error:r}=Ue(e);return p("span",{className:formula ${r?" error":""},children:r?p("code",{children:e}):p("span",{className:"katex-display",ref:t})})},Mi=({node:{decos:e,nodes:t}})=>p("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>p(be,{node:r}))}),Fi=({node:e})=>{let[t,r]=j(""),o=H(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await ie(1e3),r("")}catch(s){alert(Failed to copy the code block
Error: ${s})}},[e.text]);return p(P,{children:[p("code",{className:"cli",children:[p("span",{className:"prefix",children:e.symbol})," ",p("span",{className:"command",children:e.text})]}),p("span",{className:"tool-buttons",children:p("span",{title:"Copy",className:"copy",onClick:o,children:t})})]})},Oi=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>p("span",{className:"pointing-device-map",children:p("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank",children:p("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${globalThis._csrf}})})}),an=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=Z(te),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],a=D(s);return p("a",{href:/${n}/${a},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",children:p("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${a}/icon,children:s})})},Bi=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return p("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank",children:p("img",{className:"image",src:t})})},ji=({node:{href:e}})=>{let{project:t}=Z(te),r=ln(t,e),o=pn(t,e,"hashtag");return p("a",{href:/${t}/${D(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,children:["#",e]})},Hi=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return p(Ai,{pathType:e,href:t.href});case"absolute":{let r=qr({pathType:e,...t});switch(r.type){case"youtube":return p($i,{...r});case"vimeo":return p(Di,{...r});case"spotify":return p(Ui,{...r});case"anchor-fm":return p(qi,{...r});case"audio":return p(zi,{...r});case"video":return p(Gi,{...r});case"absoluteLink":return p("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},Ai=({pathType:e,href:t})=>{let{project:r}=Z(te),{project:o=r,title:n,hash:s=""}=he({pathType:e,href:t}),a=pn(o,n,"link",s),l=ln(o,n??"");return p("a",{className:page-link${n!==void 0&&l?" empty-page-link":""},type:"link",href:/${o}${n===void 0?"":/${D(n)}${s===""?"":#${s}}},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:a,children:t})},$i=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 p("div",{className:"iframe-video-player",children:p("iframe",{src:t,allowFullScreen:!0,type:"text/html"})})},Di=({videoId:e})=>p("div",{className:"iframe-video-player",children:p("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0,type:"text/html"})}),Ui=e=>p("div",{className:"iframe-video-player",children:p("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0,type:"text/html",scrolling:"no"})}),qi=e=>p("div",{className:"iframe-video-player",children:p("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})}),zi=e=>e.content===""?p("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):p(Ki,{...e}),Ki=({href:e,content:t})=>{let r=_t(null),o=H(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return p("span",{className:"audio-link",children:[p("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),p("span",{className:"play",onClick:o,children:"♬"}),p("audio",{preload:"none",src:e,ref:r})]})},Gi=({href:e})=>p("div",{className:"video-player",children:p("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),ln=(e,t)=>{let{whiteList:r}=Z(te),o=v(()=>(r.has(e)?[...r]:[e,...r]).map(s=>T(s,t)),[r,e]),n=ge(o);return v(()=>Vo(n),n)},pn=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:a}=Z(te);return H(async({currentTarget:l})=>{t&&(a(e,t),await ue(l,n)&&s({project:e,title:t,hash:o,type:r,position:de(l)}))},[e,t,o,r,n,a,s])};var un=({pages:e,onClick:t,source:r,whiteList:o,...n})=>{let[s,a]=j(T(e[0].project,e[0].titleLc)),l=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 p("div",{className:"text-bubble",style:l,onClick:t,children:[e.length>1&&p("div",{role:"tablist",children:e.map(i=>p(Wi,{project:i.project,titleLc:i.titleLc,selected:s===T(i.project,i.titleLc),tabSelector:a},T(i.project,i.titleLc)))}),e.map(i=>p(Qi,{selected:s===T(i.project,i.titleLc),...i,title:i.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:o,...n},T(i.project,i.titleLc)))]})},Wi=({project:e,titleLc:t,tabSelector:r,selected:o})=>{let n=H(()=>r(T(e,t)),[e,t]),s=ae(e);return p("button",{role:"tab","aria-selected":o,"data-theme":s,tabIndex:-1,onClick:n,children:e})},Qi=({selected:e,...t})=>{let r=ae(t.project);return p("div",{role:"tabpanel","data-theme":r,hidden:!e,children:p(cn,{...t})})};var dn=ee("ScrapBubble:Bubble.tsx"),mn=({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,a,l]=Vi(e,n,r,t);return p(P,{children:[Xi(l)&&p(un,{pages:l,source:e,whiteList:r,onClick:o.hide,...o}),p(sn,{linked:s,externalLinked:a,onClick:o.hide,source:e,projectsForSort:n,...o})]})},Xi=e=>e.length>0,Vi=(e,t,r,o)=>{let[[n,s,a],l]=j([new Map,new Map,[]]),i=v(()=>{let u=[...t].map(g=>T(g,e.title));return dn.debug("projects",u),u},[t,e.title]),c=ge(i),m=v(()=>o.map(u=>$(u)),[o]);return xr(()=>{let u=new Map,g=new Map,d=[];for(let f of c){let b={project:f.project,titleLc:f.titleLc};for(let y of f.projectLinked??[]){let{project:E,titleLc:re}=We(y);m.includes(re)&&r.has(E)||g.has(y)||g.set(y,b)}if(!r.has(f.project))continue;let w={titleLc:f.titleLc};for(let y of f.linked??[]){if(m.includes(y))continue;let E=T(f.project,y);u.has(E)||u.set(E,w)}m.includes(f.titleLc)||f.exists&&d.push(f)}l(tt(f=>{dn.debug(depth: ${m.length}, bubbled from ${T(e.project,e.title)}, bubbles,,c,"before",f[0],"internal cards,",u,"external cards",g);for(let b of f[0].keys())u.has(b)||f[0].delete(b);for(let[b,w]of u)f[0].set(b,w);for(let b of f[1].keys())g.has(b)||f[1].delete(b);for(let[b,w]of g)f[1].set(b,w);f[2]=d}))},[c,r,m]),[n,s,a]};var fn=(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 gn=e=>{let t=v(()=>fn(e.style,import.meta.url),[e.style]);return p(P,{children:t!==""&&(t instanceof URL?p("link",{rel:"stylesheet",href:t.href}):p("style",{children:t}))})};var hn=String.raw*{box-sizing:border-box}a{background-color:transparent;text-decoration:none;cursor:pointer}img{display:inline-block;max-width:100%;max-height:100px}code{font-family:var(--code-text-font, Menlo, Monaco, Consolas, "Courier New", monospace);font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}blockquote{background-color:var(--quote-bg-color, rgba(0,0,0,.05));display:block;border-left:solid 4px #a0a0a0;padding-left:4px;margin:0}strong{font-weight:700}iframe{display:inline-block;margin:3px 0;vertical-align:middle;max-width:100%;width:640px;height:360px;border:0}audio{display:inline-block;vertical-align:middle;white-space:initial;max-width:100%}.formula{margin:auto 6px}.formula.error code{color:#fd7373}.katex-display{display:inline-block!important;margin:0!important;text-align:inherit!important}.error .katex-display{display:none}.cli{border-radius:4px}.cli .prefix{color:#9c6248}.helpfeel{background-color:#fbebdd;border-radius:4px;padding:3px!important}.helpfeel .prefix{color:#f17c00}.helpfeel .entry{color:#cc5020}.code-block{display:block;line-height:1.7em;background-color:var(--code-bg, rgba(0,0,0,.04))}.code-block-start{font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#342d9c;background-color:#ffcfc6;font-size:.9em;padding:1px 2px}.code-block-start a{color:#342d9c;text-decoration:underline}code.code-block,.table-block.table-block-row{padding-left:1em}.copy{font-family:"Font Awesome 5 Free";cursor:pointer}.table-block{white-space:nowrap}.table-block-start{padding:1px 2px;font-size:.9em;background-color:#ffcfc6}.table-block-start a{color:#342d9c;text-decoration:underline}.cell{margin:0;padding:0 2px 0 8px;box-sizing:content-box;display:inline-block;white-space:pre}.cell:nth-child(odd){background-color:#0000000a}.cell:nth-child(2n){background-color:#0000000f}.strong-image{max-height:100%}.icon{height:11px;vertical-align:middle}.strong-icon{height:13.2px}.tool-button{margin-left:1em;cursor:pointer;font-size:.9em}.deco-\/{font-style:italic}.deco-\*-1{font-weight:700}.deco-\*-2{font-weight:700;font-size:1.2em}.deco-\*-3{font-weight:700;font-size:1.44em}.deco-\*-4{font-weight:700;font-size:1.73em}.deco-\*-5{font-weight:700;font-size:2.07em}.deco-\*-6{font-weight:700;font-size:2.49em}.deco-\*-7{font-weight:700;font-size:3em}.deco-\*-8{font-weight:700;font-size:3.58em}.deco-\*-9{font-weight:700;font-size:4.3em}.deco-\*-10{font-weight:700;font-size:5.16em}.deco--{text-decoration:line-through}.deco-_{text-decoration:underline}.page-link{color:var(--page-link-color, #5e8af7)}a.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}a.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}a.link:hover{color:var(--page-link-color-hover-color, #2d67f5)}.link img{padding-bottom:3px;border-style:none none solid;border-width:1.5px;border-color:#8fadf9}.permalink{background-color:var(--line-permalink-color, rgba(234,218,74,.75))}.status-bar{display:inline-block;position:absolute;background-color:var(--page-bg, #fefefe);cursor:default}.status-bar>*{border:1px solid var(--status-bar-border-color, #a9aaaf)}.status-bar.top-left{top:0;left:0}.status-bar.top-left>*{border-top:none;border-left:none}.status-bar.top-left :last-of-type{border-bottom-right-radius:3px}.status-bar.top-right{top:0;right:0}.status-bar.top-right>*{border-top:none;border-right:none}.status-bar.top-right :last-of-type{border-bottom-left-radius:3px}.status-bar.bottom-right{bottom:0;right:0}.status-bar.bottom-right>*{border-bottom:none;border-right:none}.status-bar.bottom-right :last-of-type{border-top-left-radius:3px}.status-bar.bottom-left{bottom:0;left:0}.status-bar.bottom-left>*{border-bottom:none;border-left:none}.status-bar.bottom-left :last-of-type{border-top-right-radius:3px}.text-bubble{font-size:11px;line-height:1.42857;user-select:text;position:absolute;color:var(--page-text-color, #4a4a4a);box-shadow:0 6px 12px #0000002d;display:flex;flex-direction:column;z-index:9000;&.no-scroll{overflow-y:hidden}data-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}data-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}data-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}data-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}data-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}data-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}data-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}data-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}data-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}data-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}data-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}data-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}role=tabpanel{padding:5px 0 5px 5px;border-radius:4px;background-color:var(--page-bg, #fefefe);max-height:80vh;overflow-y:auto}role=tabpanel,button{border:1px solid var(--text-bubble-border-color, hsl(221, 15%, 25%))}button{cursor:default;color:inherit;font-size:inherit;line-height:inherit;background-color:var(--page-bg, #fefefe);border-radius:4px 4px 0 0}buttonaria-selected=true{background-color:var(--text-bubble-border-color, hsl(221, 15%, 25%))}}.project-badge{text-decoration:none;color:var(--tool-text-color, #363c49)}.related-page-carddata-theme=default-dark{--card-title-bg: hsl(0, 0%, 39%)}.related-page-carddata-theme=default-minimal{--card-title-bg: hsl(0, 0%, 89%)}.related-page-carddata-theme=paper-light{--card-title-bg: hsl(53, 8%, 58%)}.related-page-carddata-theme=paper-dark-dark{--card-title-bg: hsl(203, 42%, 17%)}.related-page-carddata-theme=blue{--card-title-bg: hsl(227, 68%, 62%)}.related-page-carddata-theme=purple{--card-title-bg: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--card-title-bg: hsl(136, 29%, 50%)}.related-page-carddata-theme=orange{--card-title-bg: hsl(43, 71%, 51%)}.related-page-carddata-theme=red{--card-title-bg: hsl(4, 58%, 56%)}.related-page-carddata-theme=spring{--card-title-bg: hsl(72, 64%, 57%)}.related-page-carddata-theme=kyoto{--card-title-bg: hsl(331, 21%, 26%)}.related-page-carddata-theme=newyork{--card-title-bg: hsl(176, 29%, 67%)}.related-page-card{display:block;position:relative;height:inherit;width:inherit;overflow:hidden;text-overflow:ellipsis;font-family:Roboto,Helvetica,Arial,Hiragino Sans,sans-serif;background-color:var(--card-bg, #fff);color:var(--card-title-color, #555);word-break:break-word;text-decoration:none}.related-page-card:hover{box-shadow:var(--card-box-hover-shadow, 0 2px 0 rgba(0,0,0,.23))}.related-page-card:focus{outline:0;box-shadow:0 0 0 3px #66afe999;border-color:#66afe9;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.related-page-card.hover{opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;background-color:var(--card-hover-bg, rgba(0,0,0,.05));mix-blend-mode:multiply;z-index:1;transition:background-color .1s}.related-page-card:hover .hover{opacity:1}.related-page-card:active .hover{opacity:1;background-color:var(--card-active-bg, rgba(0,0,0,.1))}.related-page-card .content{height:calc(100% - 5px);width:inherit;display:flex;flex-direction:column;overflow:hidden}.related-page-card .content .header{width:100%;color:#396bdd;text-overflow:ellipsis;border-top:var(--card-title-bg, #f2f2f3) solid 10px;padding:8px 10px}.related-page-card .content .header .title{font-size:11px;line-height:16px;font-weight:700;max-height:48px;color:var(--card-title-color, #363c49);margin:0;overflow:hidden;display:block;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-overflow:ellipsis}.related-page-card .content .description{line-height:16px;padding:8px 10px 0;font-size:10px;white-space:pre-line;column-count:1;column-gap:2em;column-width:10em;height:inherit;color:var(--card-description-color, gray);flex-shrink:16;overflow:hidden}.related-page-card .content .thumbnail{display:block;width:100%;margin:0 auto;padding:0 5px}.related-page-card .content .description p{margin:0;display:block}.related-page-card .content .description code{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}.related-page-card .content .description .icon{height:9px;vertical-align:middle}.related-page-card .content .description .page-link{background-color:transparent;text-decoration:none;cursor:pointer;color:var(--page-link-color, #5e8af7)}.card-bubble{background-color:var(--page-bg, #FFF);box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;position:absolute;max-width:80vw;box-sizing:content-box;z-index:9000;font-size:11px;line-height:1.42857;display:flex;padding:0;margin:0;list-style:none;overflow-x:auto;overflow-y:visible}.card-bubble li{display:block;position:relative;float:none;margin:5px;box-sizing:border-box;box-shadow:var(--card-box-shadow, 0 2px 0 rgba(0,0,0,.12));border-radius:2px;width:120px;height:120px}
;var bn=()=>{let[e,t]=j([{bubble:o=>r(0,o),hide:()=>r(0)}]),r=H((o,n)=>{t(([s,...a])=>[s,...n?[...a.slice(0,o),n===a.at(o)?.source?a.at(o):{source:n,parentTitles:[scrapbox.Page.title??"",...a.slice(0,o).map(l=>l.source.title)],bubble:l=>r(o+1,l),hide:()=>r(o+1)}]:[...a.slice(0,o)]])},[]);return e};var Wt=(e,t,r,o,n)=>{W(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var yn=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),st=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var Qt="scrap-bubble",xn=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...a]=bn(),l=H((i,c)=>on(c,t.has(i)?t:new Set([i]),r),[t,r]);return Wt(document,"pointerenter",async i=>{let c=i.target;if(!st(c)&&!yn(c))return;let{project:m=scrapbox.Project.name,title:u,hash:g=""}=st(c)?he({pathType:"root",href:${new URL(c.href).pathname}${new URL(c.href).hash}`}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(m==="")return;let d=decodeURIComponent(u??"");l(m,d),await ue(c,e)&&n({project:m,title:d,hash:g,position:de(c),type:Yi(c)})},{capture:!0},e,t,r),Wt(document,"click",i=>{i.target.dataset.userscriptName!==Qt&&s()},{capture:!0},s),W(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),s),p(P,{children:[p("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),p("style",{children:hn}),p(gn,{style:o}),a.map(i=>p(mn,{...i,whiteList:t,delay:e,prefetch:l},T(i.source.project,i.source.title)))]})},Yi=e=>st(e)?e.type==="link"?"link":"hashtag":"title";var qb=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await zr()).slice(0,100),style:n="",debug:s=!1}=e??{};Lo(s);let a=document.createElement("div");a.dataset.userscriptName=Qt,document.body.append(a);let l=a.attachShadow({mode:"open"});bt(p(xn,{delay:t,whiteList:new Set(scrapbox.Project.name,...r),watchList:new Set(o),style:n}),l)};export{qb as mount};