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