xx202import
code:style.css
@import '/api/code/crapbox/%E3%83%94%E3%83%B3%E7%95%99%E3%82%81%E3%81%95%E3%82%8C%E3%81%9F%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E7%8B%AC%E7%AB%8B%E3%81%97%E3%81%A6%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E3%82%B3%E3%83%BC%E3%83%89%E3%83%96%E3%83%AD%E3%83%83%E3%82%AF_%E3%81%AB%E8%A1%8C%E7%95%AA%E5%8F%B7%E3%82%92%E3%81%A4%E3%81%91%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E3%82%A4%E3%83%B3%E3%83%87%E3%83%B3%E3%83%88%E3%81%AB%E7%B8%A6%E7%B7%9A%E3%82%92%E8%A1%A8%E7%A4%BA%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E3%82%A4%E3%83%B3%E3%83%87%E3%83%B3%E3%83%88%E3%81%AB%E5%BF%9C%E3%81%98%E3%81%A6%E7%AE%87%E6%9D%A1%E6%9B%B8%E3%81%8D%E3%81%AEbullet%E3%81%AE%E8%89%B2%E3%82%92%E8%96%84%E3%81%8F%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E7%AE%87%E6%9D%A1%E6%9B%B8%E3%81%8D%E3%81%AEBullet%E3%82%92%E6%8E%A7%E3%81%88%E3%82%81%E3%81%AB%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E7%AE%87%E6%9D%A1%E6%9B%B8%E3%81%8D%E3%81%AE%E3%82%A4%E3%83%B3%E3%83%87%E3%83%B3%E3%83%88%E5%B9%85%E3%82%92%E5%8D%8A%E5%88%86%E3%81%AB%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E5%A4%96%E9%83%A8%E3%83%AA%E3%83%B3%E3%82%AF%E3%82%92%E5%8C%BA%E5%88%A5%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%9A%E3%83%BC%E3%82%B8%E3%82%92%E9%9D%9E%E8%A1%A8%E7%A4%BA%E5%8C%96%E3%81%99%E3%82%8B/style.css';
code:style.css
@import '/api/code/crapbox/Private_Project%E3%81%B8%E3%81%AE%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%A7%E3%81%82%E3%82%8B%E3%81%93%E3%81%A8%E3%82%92%E6%98%8E%E7%A4%BA%E3%81%99%E3%82%8B/style.css';
code:style.css
/*@import '/api/code/crapbox/%E7%94%BB%E5%83%8F%E3%82%92%E4%B8%A6%E3%81%B9%E3%81%A6%E8%A1%A8%E7%A4%BA/style.css';
code:script.js
(function(){let e={position:"fixed",bottom:"20px",right:"10px",width:"50px",height:"50px",backgroundColor:"#000000","border-radius":"50%",color:"black",fontSize:"16px",cursor:"pointer"},t=document.createElement("button");t.textContent="日記",t.style.cssText=Object.keys(e).map(n=>${n}: ${e[n]}).join(";"),t.addEventListener("click",()=>{console.log("hogehoge");let n=new Date,r=n.getFullYear(),o=n.getMonth()+1,s=n.getDate(),i=${r}/${o.toString().padStart(2,"0")}/${s.toString().padStart(2,"0")};location.href=https://scrapbox.io/crapbox/${i}}),document.body.appendChild(t)})();scrapbox.PopupMenu.addButton({title:"MdSc",onClick:e=>(e=e.split(/\n/).map(t=>t.replace(/^\*\-\+ /g," ")).join(` ),e=e.split(/\n/).map(t=>t.replace(/[\*\-\+] /g,"")).join(
),e=e.split(/\n/).map(t=>t.replace(/ {4}/g," ")).join(
),e=e.split(/\n/).map(t=>t.replace(/^([0-9]+\. )/g," $1")).join(
),e=e.split(/\n/).map(t=>t.replace(/\*{2}([^*]+)\*{2}/g,"[* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\_{2}([^_]+)\_{2}/g,"[* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\_([^_]+)\_/g,"[/ $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\~\~(\~+|[^~]+)\~\~/g,"[- $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^# (.*)/g,"[******* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{2} (.*)/g,"[****** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{3} (.*)/g,"[***** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{4} (.*)/g,"[**** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{5} (.*)/g,"[*** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{6} (.*)/g,"[** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/!?\[\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/!\[([^\]]+)\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1 $2]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\[([^\]]+)\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1 $2]")).join(
),e=e.split(/\n/).map(t=>t.replace(/<(https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)>/g,"[$1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^([\*|\-|\_]){3,}/g,"[/icons/hr.icon]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\\([\\||\*|_|\{|\}|\|\|\(|\)|#|\+|\-|\.|\!])/g,"$1")).join(` ),e)});var ge,w,lt,rr,X,it,dt,Se,Ne,Pe,Ie,or,te={},pt=[],sr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,De=Array.isArray;function $(e,t){for(var n in t)e[n]=t[n];return e}function ft(e){var t=e.parentNode;t&&t.removeChild(e)}function g(e,t,n){var r,o,s,i={};for(s in t)s=="key"?r=t[s]:s=="ref"?o=t[s]:i[s]=t[s];if(arguments.length>2&&(i.children=arguments.length>3?ge.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)i[s]===void 0&&(i[s]=e.defaultProps[s]);return pe(e,i,r,o,null)}function pe(e,t,n,r,o){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o??++lt,__i:-1,__u:0};return o==null&&w.vnode!=null&&w.vnode(s),s}function I(e){return e.children}function fe(e,t){this.props=e,this.context=t}function Y(e,t){if(t==null)return e.__?Y(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Y(e):null}function mt(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return mt(e)}}function at(e){(!e.__d&&(e.__d=!0)&&X.push(e)&&!me.__r++||it!==w.debounceRendering)&&((it=w.debounceRendering)||dt)(me)}function me(){var e,t,n,r,o,s,i,a;for(X.sort(Se);e=X.shift();)e.__d&&(t=X.length,r=void 0,s=(o=(n=e).__v).__e,i=[],a=[],n.__P&&((r=$({},o)).__v=o.__v+1,w.vnode&&w.vnode(r),je(n.__P,r,o,n.__n,n.__P.namespaceURI,32&o.__u?[s]:null,i,s??Y(o),!!(32&o.__u),a),r.__v=o.__v,r.__.__k[r.__i]=r,xt(i,r,a),r.__e!=s&&mt(r)),X.length>t&&X.sort(Se));me.__r=0}function gt(e,t,n,r,o,s,i,a,u,l,d){var c,f,p,v,L,b=r&&r.__k||pt,m=t.length;for(n.__d=u,ir(n,t,b),u=n.__d,c=0;c<m;c++)(p=n.__k[c])!=null&&typeof p!="boolean"&&typeof p!="function"&&(f=p.__i===-1?te:b[p.__i]||te,p.__i=c,je(e,p,f,o,s,i,a,u,l,d),v=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&He(f.ref,null,p),d.push(p.ref,p.__c||v,p)),L==null&&v!=null&&(L=v),65536&p.__u||f.__k===p.__k?(u&&typeof p.type=="string"&&!e.contains(u)&&(u=Y(f)),u=ht(p,u,e)):typeof p.type=="function"&&p.__d!==void 0?u=p.__d:v&&(u=v.nextSibling),p.__d=void 0,p.__u&=-196609);n.__d=u,n.__e=L}function ir(e,t,n){var r,o,s,i,a,u=t.length,l=n.length,d=l,c=0;for(e.__k=[],r=0;r<u;r++)i=r+c,(o=e.__k[r]=(o=t[r])==null||typeof o=="boolean"||typeof o=="function"?null:typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?pe(null,o,null,null,null):De(o)?pe(I,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?pe(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)!=null?(o.__=e,o.__b=e.__b+1,a=ar(o,n,i,d),o.__i=a,s=null,a!==-1&&(d--,(s=n[a])&&(s.__u|=131072)),s==null||s.__v===null?(a==-1&&c--,typeof o.type!="function"&&(o.__u|=65536)):a!==i&&(a==i-1?c=a-i:a==i+1?c++:a>i?d>u-i?c+=a-i:c--:a<i&&c++,a!==r+c&&(o.__u|=65536))):(s=n[i])&&s.key==null&&s.__e&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Y(s)),Re(s,s,!1),n[i]=null,d--);if(d)for(r=0;r<l;r++)(s=n[r])!=null&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Y(s)),Re(s,s))}function ht(e,t,n){var r,o;if(typeof e.type=="function"){for(r=e.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=e,t=ht(r[o],t,n));return t}e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function ar(e,t,n,r){var o=e.key,s=e.type,i=n-1,a=n+1,u=t[n];if(u===null||u&&o==u.key&&s===u.type&&!(131072&u.__u))return n;if(r>(u!=null&&!(131072&u.__u)?1:0))for(;i>=0||a<t.length;){if(i>=0){if((u=t[i])&&!(131072&u.__u)&&o==u.key&&s===u.type)return i;i--}if(a<t.length){if((u=t[a])&&!(131072&u.__u)&&o==u.key&&s===u.type)return a;a++}}return-1}function ct(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||sr.test(t)?n:n+"px"}function de(e,t,n,r,o){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||ct(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||ct(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Ne,e.addEventListener(t,s?Ie:Pe,s)):e.removeEventListener(t,s?Ie:Pe,s);else{if(o=="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{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function ut(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Ne++;else if(t.t<n.u)return;return n(w.event?w.event(t):t)}}}function je(e,t,n,r,o,s,i,a,u,l){var d,c,f,p,v,L,b,m,y,A,j,G,F,Z,V,ee,h=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),s=[a=t.__e=n.__e]),(d=w.__b)&&d(t);e:if(typeof h=="function")try{if(m=t.props,y="prototype"in h&&h.prototype.render,A=(d=h.contextType)&&r[d.__c],j=d?A?A.props.value:d.__:r,n.__c?b=(c=t.__c=n.__c).__=c.__E:(y?t.__c=c=new h(m,j):(t.__c=c=new fe(m,j),c.constructor=h,c.render=ur),A&&A.sub(c),c.props=m,c.state||(c.state={}),c.context=j,c.__n=r,f=c.__d=!0,c.__h=[],c._sb=[]),y&&c.__s==null&&(c.__s=c.state),y&&h.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=$({},c.__s)),$(c.__s,h.getDerivedStateFromProps(m,c.__s))),p=c.props,v=c.state,c.__v=t,f)y&&h.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),y&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(y&&h.getDerivedStateFromProps==null&&m!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(m,j),!c.__e&&(c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(m,c.__s,j)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(c.props=m,c.state=c.__s,c.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(S){S&&(S.__=t)}),G=0;G<c._sb.length;G++)c.__h.push(c._sb[G]);c._sb=[],c.__h.length&&i.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(m,c.__s,j),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,v,L)})}if(c.context=j,c.props=m,c.__P=e,c.__e=!1,F=w.__r,Z=0,y){for(c.state=c.__s,c.__d=!1,F&&F(t),d=c.render(c.props,c.state,c.context),V=0;V<c._sb.length;V++)c.__h.push(c._sb[V]);c._sb=[]}else do c.__d=!1,F&&F(t),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++Z<25);c.state=c.__s,c.getChildContext!=null&&(r=$($({},r),c.getChildContext())),y&&!f&&c.getSnapshotBeforeUpdate!=null&&(L=c.getSnapshotBeforeUpdate(p,v)),gt(e,De(ee=d!=null&&d.type===I&&d.key==null?d.props.children:d)?ee:[ee],t,n,r,o,s,i,a,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&i.push(c),b&&(c.__E=c.__=null)}catch(S){t.__v=null,u||s!=null?(t.__e=a,t.__u|=u?160:32,s[s.indexOf(a)]=null):(t.__e=n.__e,t.__k=n.__k),w.__e(S,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=cr(n.__e,t,n,r,o,s,i,u,l);(d=w.diffed)&&d(t)}function xt(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)He(n[r],n[++r],n[++r]);w.__c&&w.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(s){s.call(o)})}catch(s){w.__e(s,o.__v)}})}function cr(e,t,n,r,o,s,i,a,u){var l,d,c,f,p,v,L,b=n.props,m=t.props,y=t.type;if(y==="svg"?o="http://www.w3.org/2000/svg":y==="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((p=s[l])&&"setAttribute"in p==!!y&&(y?p.localName===y:p.nodeType===3)){e=p,s[l]=null;break}}if(e==null){if(y===null)return document.createTextNode(m);e=document.createElementNS(o,y,m.is&&m),s=null,a=!1}if(y===null)b===m||a&&e.data===m||(e.data=m);else{if(s=s&&ge.call(e.childNodes),b=n.props||te,!a&&s!=null)for(b={},l=0;l<e.attributes.length;l++)b[(p=e.attributes[l]).name]=p.value;for(l in b)if(p=b[l],l!="children"){if(l=="dangerouslySetInnerHTML")c=p;else if(l!=="key"&&!(l in m)){if(l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m)continue;de(e,l,null,p,o)}}for(l in m)p=m[l],l=="children"?f=p:l=="dangerouslySetInnerHTML"?d=p:l=="value"?v=p:l=="checked"?L=p:l==="key"||a&&typeof p!="function"||b[l]===p||de(e,l,p,b[l],o);if(d)a||c&&(d.__html===c.__html||d.__html===e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(c&&(e.innerHTML=""),gt(e,De(f)?f:[f],t,n,r,y==="foreignObject"?"http://www.w3.org/1999/xhtml":o,s,i,s?s[0]:n.__k&&Y(n,0),a,u),s!=null)for(l=s.length;l--;)s[l]!=null&&ft(s[l]);a||(l="value",v!==void 0&&(v!==e[l]||y==="progress"&&!v||y==="option"&&v!==b[l])&&de(e,l,v,b[l],o),l="checked",L!==void 0&&L!==e[l]&&de(e,l,L,b[l],o))}return e}function He(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(r){w.__e(r,n)}}function Re(e,t,n){var r,o;if(w.unmount&&w.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||He(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){w.__e(s,t)}r.base=r.__P=null}if(r=e.__k)for(o=0;o<r.length;o++)r[o]&&Re(r[o],t,n||typeof e.type!="function");n||e.__e==null||ft(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function ur(e,t,n){return this.constructor(e,n)}function Oe(e,t,n){var r,o,s,i;w.__&&w.__(e,t),o=(r=typeof n=="function")?null:n&&n.__k||t.__k,s=[],i=[],je(t,e=(!r&&n||t).__k=g(I,null,[e]),o||te,te,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?ge.call(t.childNodes):null,s,!r&&n?n:o?o.__e:t.firstChild,r,i),xt(s,e,i)}ge=pt.slice,w={__e:function(e,t,n,r){for(var o,s,i;t=t.__;)if((o=t.__c)&&!o.__)try{if((s=o.constructor)&&s.getDerivedStateFromError!=null&&(o.setState(s.getDerivedStateFromError(e)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,r||{}),i=o.__d),i)return o.__E=o}catch(a){e=a}throw e}},lt=0,rr=function(e){return e!=null&&e.constructor==null},fe.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=$({},this.state),typeof e=="function"&&(e=e($({},n),this.props)),e&&$(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),at(this))},fe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),at(this))},fe.prototype.render=I,X=[],dt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Se=function(e,t){return e.__v.__b-t.__v.__b},me.__r=0,Ne=0,Pe=ut(!1),Ie=ut(!0),or=0;var ne,_,Be,bt,re=0,Tt=[],T=w,yt=T.__b,Et=T.__r,vt=T.diffed,wt=T.__c,Lt=T.unmount,_t=T.__;function Fe(e,t){T.__h&&T.__h(_,e,re||t),re=0;var n=_.__H||(_.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function D(e){return re=1,oe(Mt,e)}function oe(e,t,n){var r=Fe(ne++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Mt(void 0,t),function(a){var u=r.__N?r.__N[0]:r.__[0],l=r.t(u,a);u!==l&&(r.__N=[l,r.__[1]],r.__c.setState({}))}],r.__c=_,!_.u)){var o=function(a,u,l){if(!r.__c.__H)return!0;var d=r.__c.__H.__.filter(function(f){return!!f.__c});if(d.every(function(f){return!f.__N}))return!s||s.call(this,a,u,l);var c=!1;return d.forEach(function(f){if(f.__N){var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(c=!0)}}),!(!c&&r.__c.props===a)&&(!s||s.call(this,a,u,l))};_.u=!0;var s=_.shouldComponentUpdate,i=_.componentWillUpdate;_.componentWillUpdate=function(a,u,l){if(this.__e){var d=s;s=void 0,o(a,u,l),s=d}i&&i.call(this,a,u,l)},_.shouldComponentUpdate=o}return r.__N||r.__}function P(e,t){var n=Fe(ne++,3);!T.__s&&Ct(n.__H,t)&&(n.__=e,n.i=t,_.__H.__h.push(n))}function se(e){return re=5,M(function(){return{current:e}},[])}function M(e,t){var n=Fe(ne++,7);return Ct(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function x(e,t){return re=8,M(function(){return e},t)}function lr(){for(var e;e=Tt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(he),e.__H.__h.forEach(Ae),e.__H.__h=[]}catch(t){e.__H.__h=[],T.__e(t,e.__v)}}T.__b=function(e){_=null,yt&&yt(e)},T.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_t&&_t(e,t)},T.__r=function(e){Et&&Et(e),ne=0;var t=(_=e.__c).__H;t&&(Be===_?(t.__h=[],_.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(t.__h.forEach(he),t.__h.forEach(Ae),t.__h=[],ne=0)),Be=_},T.diffed=function(e){vt&&vt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Tt.push(t)!==1&&bt===T.requestAnimationFrame||((bt=T.requestAnimationFrame)||dr)(lr)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),Be=_=null},T.__c=function(e,t){t.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(r){return!r.__||Ae(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],T.__e(r,n.__v)}}),wt&&wt(e,t)},T.unmount=function(e){Lt&&Lt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{he(r)}catch(o){t=o}}),n.__H=void 0,t&&T.__e(t,n.__v))};var kt=typeof requestAnimationFrame=="function";function dr(e){var t,n=function(){clearTimeout(r),kt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);kt&&(t=requestAnimationFrame(n))}function he(e){var t=_,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),_=t}function Ae(e){var t=_;e.__c=e.__(),_=t}function Ct(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Mt(e,t){return typeof t=="function"?t(e):t}var ie=e=>e==null,xe=e=>typeof e=="string",be=e=>typeof e=="number";var St=!1;scrapbox.addListener("lines:changed",()=>St=!1);scrapbox.addListener("layout:changed",()=>St=!1);var Pt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var It=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var $e=()=>pr(document.getElementsByClassName("lines").item(0),"div.lines");var O=()=>{let e=document.getElementById("text-input");if(e)return It(e,"textarea#text-input"),e};var pr=(e,t)=>{if(e)return Pt(e,t),e};var Ue=()=>{let e=$e();if(!e)throw Error("div.lines is not found.");let t=Object.keys(e).find(n=>n.startsWith("__reactFiber"));if(!t)throw Error('div.lines must has the property whose name starts with "__reactFiber"');return e[t].return.stateNode.props.lines};var Rt=e=>{if(ie(e))return;if(be(e))return mr(e)?.id;if(xe(e))return e.startsWith("L")?e.slice(1):e;if(e.classList.contains("line"))return e.id.slice(1);let t=e.closest(".line");if(t)return t.id.slice(1)};var mr=e=>{if(ie(e))return;if(be(e))return Ue()[e];let t=Rt(e);return t?Ue().find(n=>n.id===t):void 0},Nt=e=>{if(gr(e))return e;let t=Rt(e);if(ie(t))return t;let n=document.getElementById(L${t});if(!ie(n))return n},gr=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var hr=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index");var Ke=(e,t)=>{let n=Nt(e)?.getElementsByClassName?.(c-${t})?.[0];return hr(n)?n:void 0};var qe=e=>new Promise(t=>setTimeout(()=>t(),e));var Dt=async e=>{let t=O();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let n=new InputEvent("input",{bubbles:!0});t.dispatchEvent(n),await qe(1)};var Ge=e=>e.replaceAll(" ","_").toLowerCase(),jt=e=>e.replaceAll("_"," "),ae=e=>[...e].map((t,n)=>t===" "?"_":!Er.includes(t)||n===e.length-1&&vr.includes(t)?encodeURIComponent(t):t).join(""),Er='@$&+=:;",',vr=':;",';var W=()=>{let e=O();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(s=>s.startsWith("__reactFiber"));if(!t)throw Error('#text-input must has the property whose name starts with "__reactFiber"');let n=e[t].return.return.stateNode._stores,r=n.find(s=>s.constructor.name==="Cursor");if(!r)throw Error('#text-input must has a "Cursor" store.');let o=n.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:r,selection:o}};var Ht=()=>W().cursor;var Ot=()=>W().selection;var Bt=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var wr=new Map;scrapbox.on("layout:changed",()=>{let e=O();if(e)for(let[t,n]of wr)for(let[r,o]of n)for(let s of o)e.addEventListener(t,r,Bt(s))});var At=({title:e,projects:t,selected:n,confirm:r})=>g("div",{className:candidate${n?" selected":""}},g(Lr,{title:e,confirm:r}),t.map(o=>g(_r,{project:o.name,title:e,mark:o.mark,confirm:o.confirm}))),Lr=({title:e,confirm:t})=>g("a",{className:"button",tabIndex:0,role:"menuitem",href:./${ae(e)},onClick:Ft(t)},e),_r=({project:e,title:t,mark:n,confirm:r})=>n===""?g(I,null):g("a",{className:"mark",tabIndex:0,href:../${e}/${ae(t)},onClick:Ft(r),title:/${e}/${ae(t)}},n instanceof URL?g("img",{src:n.href}):${n}),Ft=e=>x(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},[e]);var $t=(e,t)=>{let[n,r]=D(null),o=x(u=>r(l=>{if(e.length===0)return null;if(l===null)return t(e[0]);let d=e.findIndex(c=>t(c)===l);return t(u?.cyclic?e[(d+1)%e.length]:e.at(d+1)??e[0])}),[e,t]),s=x(u=>r(l=>{if(e.length===0)return null;if(l===null)return t(e[e.length-1]);let d=e.findIndex(c=>t(c)===l);return d<0?t(e[e.length-1]):t(u?.cyclic?e[(d-1+e.length)%e.length]:e.at(d-1)??e[e.length-1])}),[e,t]),i=x(()=>r(e.length===0?null:t(e[0])),[e,t]),a=x(()=>r(e.length===0?null:t(e[e.length-1])),[e,t]);return{selectedId:n,next:o,prev:s,selectFirst:i,selectLast:a}};var Ut=e=>{let[t,n]=D(null),r=M(()=>{let o=t?.getBoundingClientRect?.(),i=Ke(e.line,e.char)?.getBoundingClientRect?.();return!i||!o?{}:{top:${i.bottom-o.top}px,left:${i?.left??0-o.left}px,right:${o.right-(i?.left??0)}px}},[t,e.line,e.char]);return{updateStandardElement:n,...r}};var Ye="enableProjectsOnSuggestion",Kt=(e,t)=>{let[n,r]=D(ye([...e],t)),o=x((s,i)=>{kr(s,i,e,t),r(ye([...e],t))},[e,t.enableSelfProjectOnStart]);return P(()=>{let s=i=>{i.key===Ye&&r(ye([...e],t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},[e,t.enableSelfProjectOnStart]),{projects:n,set:o}},Xe=!0,ye=(e,t)=>{try{let n=localStorage.getItem(Ye);if(n===null)return Ee(e),e;let r=JSON.parse(n);return Array.isArray(r)&&r.every(o=>typeof o=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?r:r.includes(scrapbox.Project.name)?Xe?r:r.filter(o=>o!==scrapbox.Project.name):Xe?[...r,scrapbox.Project.name]:r:(Ee(e),e)}catch(n){if(!(n instanceof TypeError))throw n;return Ee(e),e}},kr=(e,t,n,r)=>{let o=ye([...n],r);r.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(Xe=t),Ee(t?[...o,e]:o.filter(s=>s!==e))},Ee=e=>localStorage.setItem(Ye,JSON.stringify(e));var qt=()=>M(()=>document.documentElement.dataset.os??"",[]);var ce=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(n){if(!(n instanceof TypeError))throw n;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(r){if(!(r instanceof TypeError))throw r;return e}}};var Gt=({progress:e})=>g("div",{className:"progress",style:background: linear-gradient(to right, var(--select-suggest-border-color, #eee) ${(e*100).toPrecision(3)}%, transparent ${(e*100).toPrecision(3)}%)});var Yt=({position:e,start:t,enableSelfProjectOnStart:n,projects:r,...o})=>{let{projects:s,set:i}=Kt(r,{enableSelfProjectOnStart:n}),{updateStandardElement:a,top:u,left:l,right:d}=Ut({line:e.line,char:t}),c=qt();return g(I,null,g(Cr,{itemCount:o.items.length,enableProjects:s,projects:r,top:u,right:d,set:i,os:c,...o}),g(Tr,{updateStandardElement:a,start:t,enableProjects:s,projects:r,top:u,left:l,os:c,...o}))},Tr=({start:e,updateStandardElement:t,confirmAfter:n,cancel:r,query:o,enableProjects:s,projects:i,items:a,top:u,left:l,progress:d,callback:c,limit:f,mark:p,os:v})=>{let L=x((h,S,H)=>{let le=[${S?/${S}/${h}:h}${H?.icon?".icon":""}];n((st,{line:nr})=>[${...st.slice(0,e).join("")}${le}${...st.slice(e+...o.length).join("")},{line:nr,char:e+[...le].length}])},[e,o]),b=M(()=>i.size>1||!i.has(scrapbox.Project.name),[i]),m=M(()=>{let h=[];for(let S of a){if(h.length===f)break;S.projects.some(H=>s.includes(H))&&h.push({title:S.title,projects:S.projects.flatMap(H=>s.includes(H)?[{name:H,mark:b?ce(p[H]??"",import.meta.url)||H[0]:"",confirm:le=>L(S.title,H,le)}]:[]),confirm:H=>L(S.title,void 0,H)})}return h},[s,b,a,f,p,L]),{selectedId:y,next:A,prev:j,selectLast:G,selectFirst:F}=$t(m,Xt),Z=x(h=>y===null?!1:(m.find(S=>Xt(S)===y)?.confirm?.(h),!0),[y,m]);P(()=>c(m.length===0?void 0:{selectNext:h=>(A(h),!0),selectPrev:h=>(j(h),!0),selectFirst:()=>(F(),!0),selectLast:()=>(G(),!0),confirm:Z,cancel:()=>(r(),!0)}),[c,m.length,A,j,F,G,Z]);let V=M(()=>m.length>0&&u!=null&&l!=null?{top:u,left:l}:{display:"none"},[m.length,u,l]),ee=x(h=>{if(!h){t(h);return}let S=h.parentNode;if(!(S instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(S.host.parentElement)},[t]);return g("div",{ref:ee,className:"container candidates","data-os":v,style:V},m.map(h=>g(At,{key:h.title,...h,selected:y===h.title})),a.length>f&&g("div",{className:"counter"},${a.length-f} more links),g(Gt,{progress:d}))},Cr=({enableProjects:e,projects:t,projectScore:n,mark:r,itemCount:o,top:s,right:i,set:a,os:u,freezeUntil:l})=>{let d=M(()=>[...t].sort((f,p)=>(n.get(p)??0)-(n.get(f)??0)).flatMap(f=>n.has(f)?[{name:f,enable:e.includes(f),mark:ce(r[f]??"",import.meta.url)||f[0],score:n.get(f),onClick:()=>l(()=>{a(f,!e.includes(f)),O().focus()})}]:[]),[t,n,e,r]),c=M(()=>o>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},[s,i,o,t.size]);return g("div",{className:"container projects","data-os":u,style:c},d.map(f=>g(Mr,{key:f.name,...f})))},Mr=e=>g("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name},e.mark instanceof URL?g("img",{src:e.mark.href}):${e.mark}),Xt=e=>e.title;var R=!1,We=e=>{R=typeof e=="boolean"?e:new Set(e)},J=e=>Object.fromEntries([...Object.entries(console)].map(([t,n])=>{if(typeof n!="function")return[t,n];switch(t){case"warn":case"error":return[t,(...r)=>n(%c${e},"color: gray",...r)];case"log":case"info":case"debug":return[t,(...r)=>{R!==!0&&(!R||!R.has(e))||n(%c${e},"color: gray",...r)}];case"assert":return[t,(r,...o)=>{R!==!0&&(!R||!R.has(e))||n(r,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,r=>{R!==!0&&(!R||!R.has(e))||n(${e} ${r})}];default:return[t,(...r)=>{if(!(R!==!0&&(!R||!R.has(e))))return n(...r)}]}}));var E=e=>{let{fetch:t=globalThis.fetch,hostName:n="scrapbox.io",...r}=e;return{fetch:t,hostName:n,...r}};var Sr=e=>typeof e=="object"&&e!==null,Pr=e=>Sr(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Wt=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Pr(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var ue=class e extends Error{constructor(n){super(${n.status} ${n.statusText} when fetching ${n.url});this.response=n;Error.captureStackTrace&&Error.captureStackTrace(this,e)}name="UnexpectedResponseError"},C=async e=>{let t=e.clone(),n=await t.text(),r=Wt(n);if(!r)throw new ue(t);return{ok:!1,value:r}};var k=e=>connect.sid=${e};var ve=e=>e.replaceAll(" ","_").toLowerCase();var U=e=>[...e].map((t,n)=>t===" "?"_":!Ir.includes(t)||n===e.length-1&&Rr.includes(t)?encodeURIComponent(t):t).join(""),Ir='@$&+=:;",',Rr=':;",';var Vt=(e,t,n)=>{let{sid:r,hostName:o,followRename:s,projects:i}=E(n??{}),a=new URLSearchParams;a.append("followRename",${s??!0});for(let l of i??[])a.append("projects",l);let u=https://${o}/api/pages/${e}/${U(t)}?${a.toString()};return new Request(u,r?{headers:{Cookie:k(r)}}:void 0)},Jt=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."}}:C(e),Ve=async(e,t,n)=>{let{fetch:r}=E(n??{}),o=Vt(e,t,n),s=await r(o);return await Jt(s)};Ve.toRequest=Vt;Ve.fromResponse=Jt;var zt=(e,t)=>{let{sid:n,hostName:r,sort:o,limit:s,skip:i}=E(t??{}),a=new URLSearchParams;o!==void 0&&a.append("sort",o),s!==void 0&&a.append("limit",${s}),i!==void 0&&a.append("skip",${i});let u=https://${r}/api/pages/${e}?${a.toString()};return new Request(u,n?{headers:{Cookie:k(n)}}:void 0)},Qt=async e=>e.ok?{ok:!0,value:await e.json()}:C(e),Zt=async(e,t)=>{let{fetch:n}=E(t??{}),r=await n(zt(e,t));return await Qt(r)};Zt.toRequest=zt;Zt.fromResponse=Qt;var en=(e,t,n,r)=>{let{sid:o,hostName:s}=E(r??{}),i=https://${s}/api/table/${e}/${U(t)}/${encodeURIComponent(n)}.csv;return new Request(i,o?{headers:{Cookie:k(o)}}:void 0)},tn=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:C(e),nn=async(e,t,n,r)=>{let{fetch:o}=E(r??{}),s=en(e,t,n,r),i=await o(s);return await tn(i)};nn.toRequest=en;nn.fromResponse=tn;var rn=(e,t)=>{let{sid:n,hostName:r}=E(t??{});return new Request(https://${r}/api/projects/${e},n?{headers:{Cookie:k(n)}}:void 0)},on=async e=>e.ok?{ok:!0,value:await e.json()}:C(e),we=async(e,t)=>{let{fetch:n}=E(t??{}),r=rn(e,t),o=await n(r);return on(o)};we.toRequest=rn;we.fromResponse=on;var sn=(e,t)=>{let{sid:n,hostName:r}=E(t??{}),o=new URLSearchParams;for(let s of e)o.append("ids",s);return new Request(https://${r}/api/projects?${o.toString()},n?{headers:{Cookie:k(n)}}:void 0)},an=async e=>e.ok?{ok:!0,value:await e.json()}:C(e),Le=async(e,t)=>{let{fetch:n}=E(t??{}),r=await n(sn(e,t));return an(r)};Le.toRequest=sn;Le.fromResponse=an;var cn=async(e,t)=>{let{sid:n,hostName:r,fetch:o,followingId:s}=E(t??{}),i=new Request(https://${r}/api/pages/${e}/search/titles${s??followingId=${s}:""},n?{headers:{Cookie:k(n)}}:void 0),a=await o(i);return a.ok?{ok:!0,value:{pages:await a.json(),followingId:a.headers.get("X-following-id")??""}}:a.status===422?{ok:!1,value:{name:"InvalidFollowingIdError",message:await a.text()}}:C(a)};var un=(e,t,n,r)=>{let{sid:o,hostName:s}=E(r??{}),i=https://${s}/api/code/${e}/${U(t)}/${U(n)};return new Request(i,o?{headers:{Cookie:k(o)}}:void 0)},ln=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404&&e.headers.get("Content-Type")?.includes?.("text/plain")?{ok:!1,value:{name:"NotFoundError",message:"Code block is not found"}}:C(e),dn=async(e,t,n,r)=>{let{fetch:o}=E(r??{}),s=un(e,t,n,r),i=await o(s);return await ln(i)};dn.toRequest=un;dn.fromResponse=ln;var qc=new TextEncoder().encode("0123456789abcdef");var pn=!1;scrapbox.addListener("lines:changed",()=>pn=!1);scrapbox.addListener("layout:changed",()=>pn=!1);var fn=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var z=()=>{let e=document.getElementById("text-input");if(e)return fn(e,"textarea#text-input"),e};var gn=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var Kr=new Map;scrapbox.on("layout:changed",()=>{let e=z();if(e)for(let[t,n]of Kr)for(let[r,o]of n)for(let s of o)e.addEventListener(t,r,gn(s))});var hn=e=>{let[t,n,r,...o]=e;return{title:t,links:o,image:n,exists:r>=0,updated:Math.min(0,r)}},xn=e=>[e.title,e.image,e.exists?e.updated:-1,...e.links];var bn=e=>{let t=new Map;for(let n of e){let r=ve(n.title);t.set(r,{title:n.title,image:n.image,updated:n.updated,links:n.links,exists:!0});for(let o of n.links){let s=ve(o);t.has(s)||t.set(s,{title:o,updated:0,links:[],exists:!1})}}return[...t.values()].map(n=>xn(n))};var yn=J("scrapbox-storage:remote.ts"),En=async e=>{let t,n=[],r=download and create Links of "${e}";yn.time(r);do{let s=await cn(e,{followingId:t});if(!s.ok)return s;t=s.value.followingId,n.push(...s.value.pages)}while(t);let o=bn(n);return yn.timeEnd(r),{ok:!0,value:o}};async function*vn(e){let t=[],n=[],r=new Map;for(let s of e)s.id?t.push(s.id):n.push(s.project),r.set(s.project,s.checked);let o=await Le(t);if(!o.ok)n=e.map(s=>s.project);else for(let s of o.value.projects)r.has(s.name)&&(yield{ok:!0,value:{...s,checked:r.get(s.name)??0}});for(let s of n){let i=await we(s);yield i.ok?{ok:!0,value:{...i.value,checked:r.get(s)??0}}:{ok:!1,value:{...i.value,project:s}}}}var Qe=(e,t)=>t.some(n=>e instanceof n),wn,Ln;function qr(){return wn||(wn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gr(){return Ln||(Ln=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ze=new WeakMap,Je=new WeakMap,ke=new WeakMap;function Xr(e){let t=new Promise((n,r)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{n(K(e.result)),o()},i=()=>{r(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return ke.set(t,e),t}function Yr(e){if(Ze.has(e))return;let t=new Promise((n,r)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{n(),o()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});Ze.set(e,t)}var et={get(e,t,n){if(e instanceof IDBTransaction){if(t==="done")return Ze.get(e);if(t==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return K(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Cn(e){et=e(et)}function Wr(e){return Gr().includes(e)?function(...t){return e.apply(tt(this),t),K(this.request)}:function(...t){return K(e.apply(tt(this),t))}}function Vr(e){return typeof e=="function"?Wr(e):(e instanceof IDBTransaction&&Yr(e),Qe(e,qr())?new Proxy(e,et):e)}function K(e){if(e instanceof IDBRequest)return Xr(e);if(Je.has(e))return Je.get(e);let t=Vr(e);return t!==e&&(Je.set(e,t),ke.set(t,e)),t}var tt=e=>ke.get(e);function Mn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),a=K(i);return r&&i.addEventListener("upgradeneeded",u=>{r(K(i.result),u.oldVersion,u.newVersion,K(i.transaction),u)}),n&&i.addEventListener("blocked",u=>n(u.oldVersion,u.newVersion,u)),a.then(u=>{s&&u.addEventListener("close",()=>s()),o&&u.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function Sn(e,{blocked:t}={}){let n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",r=>t(r.oldVersion,r)),K(n).then(()=>{})}var Jr=["get","getKey","getAll","getAllKeys","count"],zr=["put","add","delete","clear"],ze=new Map;function _n(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(ze.get(t))return ze.get(t);let n=t.replace(/FromIndex$/,""),r=t!==n,o=zr.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(o||Jr.includes(n)))return;let s=async function(i,...a){let u=this.transaction(i,o?"readwrite":"readonly"),l=u.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[n](...a),o&&u.done]))[0]};return ze.set(t,s),s}Cn(e=>({...e,get:(t,n,r)=>_n(t,n)||e.get(t,n,r),has:(t,n)=>!!_n(t,n)||e.has(t,n)}));var Qr=["continue","continuePrimaryKey","advance"],kn={},nt=new WeakMap,Pn=new WeakMap,Zr={get(e,t){if(!Qr.includes(t))return e[t];let n=kn[t];return n||(n=kn[t]=function(...r){nt.set(this,Pn.get(this)[t](...r))}),n}};async function*eo(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let n=new Proxy(t,Zr);for(Pn.set(n,t),ke.set(n,tt(t));t;)yield n,t=await(nt.get(n)||t.continue()),nt.delete(n)}function Tn(e,t){return t===Symbol.asyncIterator&&Qe(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Qe(e,[IDBIndex,IDBObjectStore])}Cn(e=>({...e,get(t,n,r){return Tn(t,n)?eo:e.get(t,n,r)},has(t,n){return Tn(t,n)||e.has(t,n)}}));var In=J("scrapbox-storage:db.ts"),Rn,Te=async()=>(Rn??=await Mn("scrapbox-storage",1,{upgrade(e){In.time("update DB");for(let t of e.objectStoreNames)e.deleteObjectStore(t);e.createObjectStore("links",{keyPath:"project"}),e.createObjectStore("status",{keyPath:"project"}),In.timeEnd("update DB")}}),Rn),Nn=async e=>(await Te()).put("links",e);var Ce=new Map,Dn=e=>{let t={type:"update",projects:e};jn(t);let n=new BroadcastChannel(Hn);n.postMessage(t),n.close()},jn=e=>{for(let t of new Set(e.projects.flatMap(n=>[...Ce.get(n)??[]])))t?.(e)},Hn="scrapbox-storage-notify",to=new BroadcastChannel(Hn);to.addEventListener("message",e=>jn(e.data));var rt=(e,t)=>{for(let n of e){let r=Ce.get(n)??new Set;r.add(t),Ce.set(n,r)}return()=>{for(let n of e)Ce.get(n)?.delete?.(t)}};var B=J("scrapbox-storage:mod.ts"),On=async(e,t)=>{let n=await Te(),r=[],o=[];try{{B.debug("check updates of links...");let a=n.transaction("status","readwrite");await Promise.all(e.map(async u=>{let l=await a.store.get(u);if(l?.isValid===!1)return;let d=l?.checked??0,c=new Date().getTime()/1e3;if(d+t>c||l?.updating&&d+600>c)return;let f={project:u,id:l?.id,isValid:!0,checked:d,updated:l?.updated??0,updating:!0};r.push(f),a.store.put(f)})),await a.done,B.debug(checked. ${r.length} projects maybe need upgrade.)}if(r.length===0)return[];let s=[],i=[];for await(let a of vn(r)){if(!a.ok)switch(o.push({project:a.value.project,isValid:!1}),a.value.name){case"NotFoundError":B.warn("${a.value.project}" is not found.);continue;case"NotMemberError":B.warn(You are not a member of "${a.value.project}".);continue;case"NotLoggedInError":B.warn(You are not a member of "${a.value.project}" or You are not logged in yet.);continue}if(a.value.updated<a.value.checked)B.debug(no updates in "${a.value.name}");else{let u=await En(a.value.name);if(!u.ok)throw Error(${u.value.name} ${u.value.message});let l={project:a.value.name,links:u.value};i.push(l),B.time(write data of "${a.value.name}"),await Nn(l),s.push(a.value.name),B.timeEnd(write data of "${a.value.name}")}o.push({project:a.value.name,isValid:!0,id:a.value.id,checked:new Date().getTime()/1e3,updated:a.value.updated,updating:!1})}return s.length>0&&Dn(s),i}finally{let s=n.transaction("status","readwrite"),i=s.store;await Promise.all(o.map(a=>i.put(a))),await s.done}},Bn=async e=>{let t=[],n=new Date;{let o=(await Te()).transaction("links","readonly");await Promise.all(e.map(async s=>{let i=await o.store.get(s);t.push(i??{project:s,links:[]})})),await o.done}let r=new Date().getTime()-n.getTime();return B.debug(Read links of ${e.length} projects in ${r}ms),t};Sn("userscript-links").catch(e=>console.error(e));var N=!1,An=e=>{N=typeof e=="boolean"?e:new Set(e)},q=e=>Object.fromEntries([...Object.entries(console)].map(([t,n])=>{if(typeof n!="function")return[t,n];switch(t){case"warn":case"error":return[t,(...r)=>n(%c${e},"color: gray",...r)];case"log":case"info":case"debug":return[t,(...r)=>{N!==!0&&(!N||!N.has(e))||n(%c${e},"color: gray",...r)}];case"assert":return[t,(r,...o)=>{N!==!0&&(!N||!N.has(e))||n(r,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,r=>{N!==!0&&(!N||!N.has(e))||n(${e} ${r})}];default:return[t,(...r)=>{if(!(N!==!0&&(!N||!N.has(e))))return n(...r)}]}}));var ot=q("scrapbox-select-suggestion:useSource.ts"),Fn=e=>{let[t,n]=D([]),r=x(o=>{let s=new Date,i=new Map;for(let{project:l,links:d}of o)for(let c of d){let{title:f,updated:p,image:v}=hn(c),L=Ge(f),b=i.get(L);i.set(L,{title:b?.title??f,updated:Math.max(b?.updated??0,p),metadata:[...b?.metadata??[],{project:l,image:v}]})}let a=[...i.entries()].map(([l,d])=>({titleLc:l,...d})),u=new Date().getTime()-s.getTime();ot.debug(Compiled ${a.length} source in ${u}ms),ot.debug("Detect changes!"),n(a)},[]);return P(()=>{let o=!1,s=async()=>{let l=await Bn([...e]);o||r(l)};s();let i=rt([...e],({projects:l})=>{ot.debug(Detect ${l.length} projects' update:,l),s()}),a=()=>On([...e],600);a();let u=setInterval(a,600*1e3);return()=>{o=!0,clearInterval(u),i()}},[e]),t};var $n=e=>{let t=M(()=>ce(e.style,import.meta.url),[e.style]);return g(I,null,t!==""&&(t instanceof URL?g("link",{rel:"stylesheet",href:t.href}):g("style",null,t)))};var Un=()=>g("style",null,.container { position: absolute;
margin-top: 14px;
max-height: 80vh;
z-index: 301;
background-color: var(--select-suggest-bg, #111); font-family: var(--select-suggest-font-family, "Open Sans", Helvetica, Arial, "Hiragino Sans", sans-serif);
font-size: 14px;
color: var(--select-suggest-text-color, #eee); border-radius: 4px;
}
.candidates {
max-width: 80vw;
}
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
padding: 6px;
}
.candidates > :not(:first-child) {
border-top: 1px solid var(--select-suggest-border-color, #eee); }
.candidates > *{
line-height: 1.2em;
padding: 0.5em 10px;
}
.candidate {
display: flex;
}
a {
display: block;
text-decoration: none;
color: inherit;
}
a:not(.mark) {
width: 100%;
}
.selected a {
background-color: var(--select-suggest-selected-bg, #222); text-decoration: underline
}
img {
height: 1.3em;
width: 1.3em;
position: relative;
object-fit: cover;
object-position: 0% 0%;
}
.disabled {
filter: grayscale(1.0) opacity(0.5);
}
.counter {
color: var(--select-suggest-information-text-color, #aaa); font-size: 80%;
font-style: italic;
}
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
});function*Kn(e){if(!("nodes"in e))return;let t=0;function*n(r){for(let o of Array.isArray(r)?r:[r]){if(typeof o=="string"){t+=[...o].length;continue}switch(o.type){case"link":yield{whole:o.unit.whole,start:t},t+=[...o.unit.whole].length;break;case"indent":case"quote":t+=[...o.unit.tag].length,yield*n(o.children);break;case"deco":t+=[...o.unit.deco].length+2,yield*n(o.children),t++;break;case"strong":t+=2,yield*n(o.children),t+=2;break;default:t+=[...o.unit.whole].length;break}}}yield*n(e.nodes)}var qn=(e,t)=>{if(t.type==="unlock"){if(!e.lock)return e;let{lock:i,...a}=e;return{...a}}if(e.lock)return e;switch(t.type){case"lock":{let{lock:i,...a}=e;return{lock:!0,...a}}case"enable":return e.type==="disabled"&&e.isManuallyDisabled?{type:"ready"}:e;case"disable":return e.type==="disabled"&&e.isManuallyDisabled?e:{type:"disabled",isManuallyDisabled:!0}}if(e.type==="disabled")return e.isManuallyDisabled||!t.lines?e:{type:"ready"};if(t.type==="cancel")return e.type==="completion"?{type:"cancelled",context:e.context}:e;if(!t.lines)return{type:"disabled"};let n=Math.min(t.range.start.char,t.range.end.char),r=Math.max(t.range.start.char,t.range.end.char),o=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(n,r).join(""):"";if(ro(t.lines[t.position.line],o)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:o,start:n,position:t.position};if(o!=="")return e.type==="completion"?{type:"ready"}:e;let s=no(t.lines[t.position.line],t.position.char);return s?e.type==="cancelled"&&e.context==="input"?e:e.type==="completion"||t.type==="lines:changed"?{type:"completion",context:"input",query:s.whole,start:s.start,position:t.position}:e.type==="ready"?e:{type:"ready"}:e.type==="ready"?e:{type:"ready"}},no=(e,t)=>{for(let{whole:n,start:r}of Kn(e))if(!(t<=r||r+[...n].length<=t))return{whole:n,start:r}},ro=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var Gn=()=>{let e=se(scrapbox.Page.lines),t=se(!1);return P(()=>{let n=()=>{t.current=!0};return scrapbox.addListener("lines:changed",n),scrapbox.addListener("layout:changed",n),()=>{scrapbox.removeListener("lines:changed",n),scrapbox.removeListener("layout:changed",n)}},[]),x(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var oo=q("scrapbox-select-suggestion:useLifecycle.ts"),Xn=()=>{let[e,t]=oe(qn,{type:"ready"}),n=Gn(),r=M(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:u,selection:l}=W();t({type:a,lines:n(),range:l.getRange({normalizeOrder:!0}),position:u.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);P(()=>{let i=()=>{r("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{r("selection:changed")},u=Ot();return u.addChangeListener(a),()=>{scrapbox.removeListener("lines:changed",i),scrapbox.removeListener("layout:changed",i),u.removeChangeListener(a)}},[]),P(()=>{if(e.context!=="input")return;let i=()=>{r("cursor:changed")},a=Ht();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[o,s]=D(e);return o!==e&&(s(e),oo.debug("Detect changes",e)),{state:e,setEnable:x(i=>t({type:i?"enable":"disable"}),[]),cancel:x(()=>t({type:"cancel"}),[]),freezeUntil:x(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:x(async i=>{let a=n();if(!a)return;t({type:"lock"});let{cursor:u,selection:l}=W(),d=u.getPosition().line,c=a[d].text,[f,p]=i(c,u.getPosition());l.setRange({start:{line:d,char:0},end:{line:d,char:[...c].length}}),await Dt(f),u.setPosition(p),u.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var Yn=(e,t)=>{let n=e.dist-t.dist;if(n!==0)return n;let r=e.matches.map(([i])=>i).sort(),o=t.matches.map(([i])=>i).sort();for(let i=0;i<r.length;i++){let a=r[i]-(o[i]??o.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var Wn=e=>{let t=new Map,n=[...e].reverse();{let i=1;for(let a of n){t.set(a,(t.get(a)??0)|i);let u=a.toLowerCase();t.set(u,(t.get(u)??0)|i);let l=a.toUpperCase();t.set(l,(t.get(l)??0)|i),i<<=1}}let r=n.length,o=~(-1<<r),s=1<<r-1;return i=>{let a=0,u=o,l=[...i].reverse(),d=[],c=l.length;d[c]=r;for(let f of l){let p=t.get(f)??0,v=p|a,L=(p&u)+u^u|p,b=a|~(L|u),m=u&L;d[c-1]=d[c]+(b&s?1:m&s?-1:0),u=m<<1|~(v|b<<1),a=b<<1&v,c--}return d}};var so=[0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],Vn=e=>{let t=jt(e.trim()).split(/\s+/).sort((n,r)=>r.length-n.length);if(!(t.length===0||t.every(n=>n==="")))return n=>{let r=[...n];for(let o of t)r=io(o,r);return r}},io=(e,t)=>{let n=[...e].length,r=so[n],o=Wn(e);return t.flatMap(({title:s,dist:i,matches:a,...u})=>{a??=[],i??=0;let l=o(s).flatMap((c,f)=>c<=r&&a.every(([p,v])=>f+n<=p||v<f)?[[f,c]]:[]);if(l.length===0)return[];let d=l.reduce((c,[f,p])=>(c.dist<=p||(c.dist=p,c.start=f),c),{dist:n,start:0});return a.push([d.start,d.start+n-1]),[{title:s,dist:d.dist+i,matches:a,...u}]})};var ao=q("scrapbox-select-suggestion:cancelableSearch.ts");async function*Jn(e,t,n){let r=Vn(e);if(!r)return;let o=n?.chunk??1e3,s=Math.floor(t.length/o)+1,i=0,a=new Date;try{for(;i<s;i++)await new Promise(u=>requestAnimationFrame(u)),yield[r(t.slice(i*o,(i+1)*o)),(i+1)/s]}finally{let l=new Date().getTime()-a.getTime();ao.debug(search ${(i/s*100).toPrecision(3)}% of the source for "${e}" in ${l}ms`)}}function zn(e,t){let n=null,r=null,o=(...s)=>{o.clear(),r=()=>{o.clear(),e.call(o,...s)},n=setTimeout(r,t)};return o.clear=()=>{typeof n=="number"&&(clearTimeout(n),n=null,r=null)},o.flush=()=>{r?.()},Object.defineProperty(o,"pending",{get:()=>typeof n=="number"}),o}var co=q("scrapbox-select-suggestion:useSearch.ts"),Qn=e=>{let t=x((o,s,i)=>{let a=!1,u=Jn(o,s,{chunk:5e3});return{run:async()=>{if(i){let f=[];for await(letpof u){if(a)return;f.push(...p)}r({progress:1,candidates:f});return}let l=zn(r,500),d=!1,c=[];for await(letf,pof u){if(a){l.clear();return}c=...c,...f,r({progress:p}),f.length!==0&&(l({progress:p,candidates:c}),d||(l.flush(),d=!0))}l({progress:1,candidates:c}),l.flush()},abort:()=>a=!0}},[]),n,r=oe(M(()=>uo(t),t),{source:e});return[M(()=>{if(!Q(n))return;leto,s=lo(n.candidates);return co.debug("Detect changes",{progress:n.progress,items:s}),{progress:n.progress,projectScore:o,items:s}},n),{search:x(o=>r({query:o}),[]),update:x(o=>r({source:o}),[])}]},Q=e=>"query"in e,uo=e=>(t,n)=>{if("query"in n){let i=Q(t)?t.query:"";if(n.query===i)return t;let a=Q(t)?t.job:void 0;if(!n.query)return a?.abort?.(),{source:t.source};let{run:u,abort:l}=e(n.query,t.source,!1),d=a?.abort?.()?.then?.(u)??u();return{query:n.query,source:t.source,job:{done:d,abort:()=>(l(),d)},progress:0,candidates:!i||!Q(t)?[]:t.candidates}}if("source"in n){if(!Q(t))return n.source===t.source?t:n;let{source:i,job:a,...u}=t;if(n.source===i)return t;let{run:l,abort:d}=e(t.query,i,!1),c=a.done.then(l);return{source:n.source,job:{done:c,abort:()=>a.abort().then(()=>(d(),c))},...u}}if(!Q(t))return t;if(!n.candidates){let{progress:i,...a}=t;return i===n.progress?t:{progress:n.progress,...a}}let{candidates:r,progress:o,...s}=t;return r===n.candidates&&o===n.progress?t:{candidates:n.candidates??r,progress:n.progress,...s}},lo=e=>{let t=new Map,n=[];for(let r of e.sort(Yn)){let o=r.metadata.map(({project:s})=>s);for(let s of o)t.set(s,(t.get(s)??0)+.5**r.dist);n.push({title:r.title,dist:r.dist,projects:o})}returnt,n};var Zn=(e,t)=>{let n=se({...t});P(()=>(Object.assign(n.current,t),()=>{for(let r of Object.keys(t))delete n.currentr}),...Object.keys(t).sort().map(r=>tr)),P(()=>{e(n.current)},e)};var po={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},er=e=>{let t=Fn(e.projects),n,{update:r,search:o}=Qn(t),{state:s,setEnable:i,...a}=Xn();r(t),o(s.type==="completion"?s.context==="input"?s.query.slice(1,-1):s.query:"");letu,l=D(),{callback:d,style:c,...f}=e;return Zn(d,{enable:x(()=>i(!0),[]),disable:x(()=>i(!1),[]),...s.type!=="completion"||!u?po:u}),g(I,null,g(Un,null),g($n,{style:c}),s.type==="completion"&&n&&g(Yt,{callback:l,...n,...s,...a,...f}))};var tr=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let n=t.attachShadow({mode:"open"});document.body.append(t);let{limit:r=5,debug:o=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0}=e??{},u=new Set([...a?scrapbox.Project.name:[],...e?.projects??scrapbox.Project.name]);return An(o),We(o),new Promise(l=>Oe(g(er,{limit:r,projects:u,mark:s,style:i,callback:l,enableSelfProjectOnStart:a}),n))};var fo=scrapbox.Project.name,"crapbox","accojams-private","magicalfireru","villagepump",Me=await tr({limit:10,projects:fo,mark:{crapbox:"/api/pages/crapbox/kbyshwtn/icon","accojams-private":"/api/pages/accojams-private/accojams/icon",magicalfireru:"/api/pages/magicalfireru/mfurのアイコン/icon",villagepump:"/api/pages/villagepump/井戸端/icon"}});document.getElementById("text-input").addEventListener("keydown",e=>{if(!(e.ctrlKey||e.metaKey||e.altKey)){switch(e.key){case"Tab":{if(!(e.shiftKey?Me.selectPrev({cyclic:!0}):Me.selectNext({cyclic:!0})))return;break}case"Enter":{if(e.shiftKey||!Me.confirm())return;break}case"Escape":{if(e.shiftKey||!Me.cancel())return;break}default:return}e.preventDefault(),e.stopPropagation()}});