import-dev
code:script.js
await import("../../takker-dist/import-devにbackgroundでテストコードを貼り付けるUserScript/script.js");
const { setup } = await import("./mod.js");
const { toggle } = await setup();
scrapbox.PageMenu.addItem({
title: "履歴スライダー",
onClick: toggle,
});
code:mod.js
var z,g,he,Je,C,le,Re,xe,ye,ne,te,re,Qe,j={},Ee=[],Ze=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,Y=Array.isArray;function N(e,t){for(var r in t)er=tr;return e}function se(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Xe(e,t,r){var o,i,n,a={};for(n in t)n=="key"?o=tn:n=="ref"?i=tn:an=tn;if(arguments.length>2&&(a.children=arguments.length>3?z.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(n in e.defaultProps)an===void 0&&(an=e.defaultPropsn);return G(e,a,o,i,null)}function G(e,t,r,o,i){var n={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++he,__i:-1,__u:0};return i==null&&g.vnode!=null&&g.vnode(n),n}function T(e){return e.children}function W(e,t){this.props=e,this.context=t}function H(e,t){if(t==null)return e.__?H(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__kt)!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?H(e):null}function be(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 be(e)}}function _e(e){(!e.__d&&(e.__d=!0)&&C.push(e)&&!V.__r++||le!=g.debounceRendering)&&((le=g.debounceRendering)||Re)(V)}function V(){for(var e,t,r,o,i,n,a,p=1;C.length;)C.length>p&&C.sort(xe),e=C.shift(),p=C.length,e.__d&&(r=void 0,i=(o=(t=e).__v).__e,n=[],a=[],t.__P&&((r=N({},o)).__v=o.__v+1,g.vnode&&g.vnode(r),ie(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?i:null,n,i??H(o),!!(32&o.__u),a),r.__v=o.__v,r.__.__kr.__i=r,we(n,r,a),r.__e!=i&&be(r)));V.__r=0}function ve(e,t,r,o,i,n,a,p,u,c,f){var s,l,d,_,b,x,h=o&&o.__k||Ee,m=t.length;for(u=Ke(r,t,h,u,m),s=0;s<m;s++)(d=r.__ks)!=null&&(l=d.__i==-1?j:hd.__i||j,d.__i=s,x=ie(e,d,l,i,n,a,p,u,c,f),_=d.__e,d.ref&&l.ref!=d.ref&&(l.ref&&ae(l.ref,null,d),f.push(d.ref,d.__c||_,d)),b==null&&_!=null&&(b=_),4&d.__u||l.__k===d.__k?u=ke(d,u,e):typeof d.type=="function"&&x!==void 0?u=x:_&&(u=_.nextSibling),d.__u&=-7);return r.__e=b,u}function Ke(e,t,r,o,i){var n,a,p,u,c,f=r.length,s=f,l=0;for(e.__k=new Array(i),n=0;n<i;n++)(a=tn)!=null&&typeof a!="boolean"&&typeof a!="function"?(u=n+l,(a=e.__kn=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?G(null,a,null,null,null):Y(a)?G(T,{children:a},null,null,null):a.constructor==null&&a.__b>0?G(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,p=null,(c=a.__i=et(a,r,u,s))!=-1&&(s--,(p=rc)&&(p.__u|=2)),p==null||p.__v==null?(c==-1&&(i>f?l--:i<f&&l++),typeof a.type!="function"&&(a.__u|=4)):c!=u&&(c==u-1?l--:c==u+1?l++:(c>u?l--:l++,a.__u|=4))):e.__kn=null;if(s)for(n=0;n<f;n++)(p=rn)!=null&&!(2&p.__u)&&(p.__e==o&&(o=H(p)),Ne(p,p));return o}function ke(e,t,r){var o,i;if(typeof e.type=="function"){for(o=e.__k,i=0;o&&i<o.length;i++)oi&&(oi.__=e,t=ke(oi,t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=H(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function et(e,t,r,o){var i,n,a,p=e.key,u=e.type,c=tr,f=c!=null&&(2&c.__u)==0;if(c===null&&e.key==null||f&&p==c.key&&u==c.type)return r;if(o>(f?1:0)){for(i=r-1,n=r+1;i>=0||n<t.length;)if((c=ta=i>=0?i--:n++)!=null&&!(2&c.__u)&&p==c.key&&u==c.type)return a}return-1}function me(e,t,r){t0=="-"?e.setProperty(t,r??""):et=r==null?"":typeof r!="number"||Ze.test(t)?r:r+"px"}function D(e,t,r,o,i){var n,a;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)r&&t in r||me(e.style,t,"");if(r)for(t in r)o&&rt==ot||me(e.style,t,rt)}else if(t0=="o"&&t1=="n")n=t!=(t=t.replace(ye,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.lt+n=r,r?o?r.u=o.u:(r.u=ne,e.addEventListener(t,n?re:te,n)):e.removeEventListener(t,n?re:te,n);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{et=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t4!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function ge(e){return function(t){if(this.l){var r=this.lt.type+e;if(t.t==null)t.t=ne++;else if(t.t<r.u)return;return r(g.event?g.event(t):t)}}}function ie(e,t,r,o,i,n,a,p,u,c){var f,s,l,d,_,b,x,h,m,F,w,I,U,de,B,q,ee,P=t.type;if(t.constructor!=null)return null;128&r.__u&&(u=!!(32&r.__u),n=p=t.__e=r.__e),(f=g.__b)&&f(t);e:if(typeof P=="function")try{if(h=t.props,m="prototype"in P&&P.prototype.render,F=(f=P.contextType)&&of.__c,w=f?F?F.props.value:f.__:o,r.__c?x=(s=t.__c=r.__c).__=s.__E:(m?t.__c=s=new P(h,w):(t.__c=s=new W(h,w),s.constructor=P,s.render=rt),F&&F.sub(s),s.props=h,s.state||(s.state={}),s.context=w,s.__n=o,l=s.__d=!0,s.__h=[],s._sb=[]),m&&s.__s==null&&(s.__s=s.state),m&&P.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=N({},s.__s)),N(s.__s,P.getDerivedStateFromProps(h,s.__s))),d=s.props,_=s.state,s.__v=t,l)m&&P.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),m&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(m&&P.getDerivedStateFromProps==null&&h!==d&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(h,w),!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(h,s.__s,w)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(s.props=h,s.state=s.__s,s.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(S){S&&(S.__=t)}),I=0;I<s._sb.length;I++)s.__h.push(s._sbI);s._sb=[],s.__h.length&&a.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(h,s.__s,w),m&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(d,_,b)})}if(s.context=w,s.props=h,s.__P=e,s.__e=!1,U=g.__r,de=0,m){for(s.state=s.__s,s.__d=!1,U&&U(t),f=s.render(s.props,s.state,s.context),B=0;B<s._sb.length;B++)s.__h.push(s._sbB);s._sb=[]}else do s.__d=!1,U&&U(t),f=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++de<25);s.state=s.__s,s.getChildContext!=null&&(o=N(N({},o),s.getChildContext())),m&&!l&&s.getSnapshotBeforeUpdate!=null&&(b=s.getSnapshotBeforeUpdate(d,_)),q=f,f!=null&&f.type===T&&f.key==null&&(q=Pe(f.props.children)),p=ve(e,Y(q)?q:q,t,r,o,i,n,a,p,u,c),s.base=t.__e,t.__u&=-161,s.__h.length&&a.push(s),x&&(s.__E=s.__=null)}catch(S){if(t.__v=null,u||n!=null)if(S.then){for(t.__u|=u?160:128;p&&p.nodeType==8&&p.nextSibling;)p=p.nextSibling;nn.indexOf(p)=null,t.__e=p}else{for(ee=n.length;ee--;)se(nee);oe(t)}else t.__e=r.__e,t.__k=r.__k,S.then||oe(t);g.__e(S,t,r)}else n==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):p=t.__e=tt(r.__e,t,r,o,i,n,a,u,c);return(f=g.diffed)&&f(t),128&t.__u?void 0:p}function oe(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(oe)}function we(e,t,r){for(var o=0;o<r.length;o++)ae(ro,r++o,r++o);g.__c&&g.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(n){n.call(i)})}catch(n){g.__e(n,i.__v)}})}function Pe(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:Y(e)?e.map(Pe):N({},e)}function tt(e,t,r,o,i,n,a,p,u){var c,f,s,l,d,_,b,x=r.props,h=t.props,m=t.type;if(m=="svg"?i="http://www.w3.org/2000/svg":m=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),n!=null){for(c=0;c<n.length;c++)if((d=n[c])&&"setAttribute"in d==!!m&&(m?d.localName==m:d.nodeType==3)){e=d,nc=null;break}}if(e==null){if(m==null)return document.createTextNode(h);e=document.createElementNS(i,m,h.is&&h),p&&(g.__m&&g.__m(t,n),p=!1),n=null}if(m==null)x===h||p&&e.data==h||(e.data=h);else{if(n=n&&z.call(e.childNodes),x=r.props||j,!p&&n!=null)for(x={},c=0;c<e.attributes.length;c++)x[(d=e.attributesc).name]=d.value;for(c in x)if(d=xc,c!="children"){if(c=="dangerouslySetInnerHTML")s=d;else if(!(c in h)){if(c=="value"&&"defaultValue"in h||c=="checked"&&"defaultChecked"in h)continue;D(e,c,null,d,i)}}for(c in h)d=hc,c=="children"?l=d:c=="dangerouslySetInnerHTML"?f=d:c=="value"?_=d:c=="checked"?b=d:p&&typeof d!="function"||xc===d||D(e,c,d,xc,i);if(f)p||s&&(f.__html==s.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(s&&(e.innerHTML=""),ve(t.type=="template"?e.content:e,Y(l)?l:l,t,r,o,m=="foreignObject"?"http://www.w3.org/1999/xhtml":i,n,a,n?n[0]:r.__k&&H(r,0),p,u),n!=null)for(c=n.length;c--;)se(n[c]);p||(c="value",m=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[c]||m=="progress"&&!_||m=="option"&&_!=x[c])&&D(e,c,_,x[c],i),c="checked",b!=null&&b!=e[c]&&D(e,c,b,x[c],i))}return e}function ae(e,t,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(i){g.__e(i,r)}}function Ne(e,t,r){var o,i;if(g.unmount&&g.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||ae(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(n){g.__e(n,t)}o.base=o.__P=null}if(o=e.__k)for(i=0;i<o.length;i++)oi&&Ne(oi,t,r||typeof e.type!="function");r||se(e.__e),e.__c=e.__=e.__e=void 0}function rt(e,t,r){return this.constructor(e,r)}function Te(e,t,r){var o,i,n,a;t==document&&(t=document.documentElement),g.__&&g.__(e,t),i=(o=typeof r=="function")?null:r&&r.__k||t.__k,n=[],a=[],ie(t,e=(!o&&r||t).__k=Xe(T,null,e),i||j,j,t.namespaceURI,!o&&r?r:i?null:t.firstChild?z.call(t.childNodes):null,n,!o&&r?r:i?i.__e:t.firstChild,o,a),we(n,e,a)}z=Ee.slice,g={__e:function(e,t,r,o){for(var i,n,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((n=i.constructor)&&n.getDerivedStateFromError!=null&&(i.setState(n.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,o||{}),a=i.__d),a)return i.__E=i}catch(p){e=p}throw e}},he=0,Je=function(e){return e!=null&&e.constructor==null},W.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=N({},this.state),typeof e=="function"&&(e=e(N({},r),this.props)),e&&N(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),_e(this))},W.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),_e(this))},W.prototype.render=T,C=[],Re=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(e,t){return e.__v.__b-t.__v.__b},V.__r=0,ye=/(PointerCapture)$|Capture$/i,ne=0,te=ge(!1),re=ge(!0),Qe=0;var $,R,pe,Oe,Q=0,Ue=[],y=g,Ie=y.__b,Le=y.__r,Ce=y.diffed,Me=y.__c,Fe=y.unmount,Se=y.__;function ue(e,t){y.__h&&y.__h(R,e,Q||t),Q=0;var r=R.__H||(R.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function M(e){return Q=1,ot(je,e)}function ot(e,t,r){var o=ue($++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):je(void 0,t),function(p){var u=o.__N?o.__N0:o.__0,c=o.t(u,p);u!==c&&(o.__N=[c,o.__1],o.__c.setState({}))}],o.__c=R,!R.__f)){var i=function(p,u,c){if(!o.__c.__H)return!0;var f=o.__c.__H.__.filter(function(l){return!!l.__c});if(f.every(function(l){return!l.__N}))return!n||n.call(this,p,u,c);var s=o.__c.props!==p;return f.forEach(function(l){if(l.__N){var d=l.__0;l.__=l.__N,l.__N=void 0,d!==l.__0&&(s=!0)}}),n&&n.call(this,p,u,c)||s};R.__f=!0;var n=R.shouldComponentUpdate,a=R.componentWillUpdate;R.componentWillUpdate=function(p,u,c){if(this.__e){var f=n;n=void 0,i(p,u,c),n=f}a&&a.call(this,p,u,c)},R.shouldComponentUpdate=i}return o.__N||o.__}function A(e,t){var r=ue($++,3);!y.__s&&qe(r.__H,t)&&(r.__=e,r.u=t,R.__H.__h.push(r))}function nt(e,t){var r=ue($++,7);return qe(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function L(e,t){return Q=8,nt(function(){return e},t)}function st(){for(var e;e=Ue.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(J),e.__H.__h.forEach(ce),e.__H.__h=[]}catch(t){e.__H.__h=[],y.__e(t,e.__v)}}y.__b=function(e){R=null,Ie&&Ie(e)},y.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Se&&Se(e,t)},y.__r=function(e){Le&&Le(e),$=0;var t=(R=e.__c).__H;t&&(pe===R?(t.__h=[],R.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(J),t.__h.forEach(ce),t.__h=[],$=0)),pe=R},y.diffed=function(e){Ce&&Ce(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ue.push(t)!==1&&Oe===y.requestAnimationFrame||((Oe=y.requestAnimationFrame)||it)(st)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),pe=R=null},y.__c=function(e,t){t.some(function(r){try{r.__h.forEach(J),r.__h=r.__h.filter(function(o){return!o.__||ce(o)})}catch(o){t.some(function(i){i.__h&&(i.__h=[])}),t=[],y.__e(o,r.__v)}}),Me&&Me(e,t)},y.unmount=function(e){Fe&&Fe(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{J(o)}catch(i){t=i}}),r.__H=void 0,t&&y.__e(t,r.__v))};var He=typeof requestAnimationFrame=="function";function it(e){var t,r=function(){clearTimeout(o),He&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,35);He&&(t=requestAnimationFrame(r))}function J(e){var t=R,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),R=t}function ce(e){var t=R;e.__c=e.__(),R=t}function qe(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==eo})}function je(e,t){return typeof t=="function"?t(e):t}var at=Math.pow(10,8)*24*60*60*1e3,It=-at;var pt=3600;var $e=pt*24,Lt=$e*7,ct=$e*365.2425,ut=ct/12,Ct=ut*3,fe=Symbol.for("constructDateFrom");function Ae(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&fe in e?efe(t):e instanceof Date?new e.constructor(t):new Date(t)}function Z(e,t){return Ae(t||e,e)}function Be(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="object Date"}function De(e){return!(!Be(e)&&typeof e!="number"||isNaN(+Z(e)))}function O(e,t){let r=e<0?"-":"",o=Math.abs(e).toString().padStart(t,"0");return r+o}var Ge={y(e,t){let r=e.getFullYear(),o=r>0?r:1-r;return O(t==="yy"?o%100:o,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):O(r+1,2)},d(e,t){return O(e.getDate(),t.length)},a(e,t){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r0;case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return O(e.getHours()%12||12,t.length)},H(e,t){return O(e.getHours(),t.length)},m(e,t){return O(e.getMinutes(),t.length)},s(e,t){return O(e.getSeconds(),t.length)},S(e,t){let r=t.length,o=e.getMilliseconds(),i=Math.trunc(o*Math.pow(10,r-3));return O(i,t.length)}};var ft=/(\w)\1*|''|'(''|^')+('|$)|./g,dt=/^'(^*?)'?$/,lt=/''/g,_t=/a-zA-Z/;function X(e,t){let r=Z(e);if(!De(r))throw new RangeError("Invalid time value");let o=t.match(ft);return o?o.map(n=>{if(n==="''")return"'";let a=n0;if(a==="'")return mt(n);let p=Gea;if(p)return p(r,n);if(a.match(_t))throw new RangeError("Format string contains an unescaped latin alphabet character "+a+"");return n}).join(""):""}function mt(e){let t=e.match(dt);return t?t1.replace(lt,"'"):e}var We=(e,t,r=0,o=[])=>{leti,n=M("uninitialized"),a,p=M({ok:!0,value:t}),u=L(e,o);return A(()=>{(async()=>{let c=setTimeout(()=>n("pending"),r);try{let f=await u();if(f===void 0)return;p({ok:!0,value:f})}catch(f){p({ok:!1,value:f})}finally{clearTimeout(c),n("resolved")}})()},u,r,...o),a.ok?{result:a.value,state:i}:{result:a.value,state:"rejected"}};var Ve=(e,t)=>{let r=new Map;if(t.length===0)return r;let o=...e;for(let i of t){r.set(i.created,...o);for(let n of i.changes)if("_insert"in n){let a=n.lines.id,p=o.find(c=>c.id===a),u=!1;if(p&&p.text==="-1"){p.text=n.lines.text;for(let c of r.values()){let f=c.find(s=>s.id===a);f&&(f.created=i.created)}p.updated=i.created,p.userId=i.userId,u=!0}u||(o=o.filter(c=>c.id!==n.lines.id))}else if("_update"in n){let a=o.findIndex(p=>p.id===n._update);if(a!==-1){let p=oa;p.text==="-1"?(p.text=n.lines.text,p.updated=i.created,p.userId=i.userId):oa={...p,text:n.lines.origText,updated:-1}}}else if("_delete"in n){let a={id:n._delete,text:"-1",userId:"-1",created:-1,updated:-1};o.push(a)}}return r};var E=e=>{let{fetch:t=(i,n)=>globalThis.fetch(i,n),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var v=e=>connect.sid=${e};var gt=(e,t,r)=>{let{sid:o,baseURL:i,head:n}=E(r??{});return new Request(${i}api/commits/${e}/${t}?head=${n??""},o?{headers:{Cookie:v(o)}}:void 0)},ze=(e,t,r)=>E(r??{}).fetch(gt(e,t,r));var K=e=>...e.map((t,r)=>t===" "?"_":!xt.includes(t)||r===e.length-1&&yt.includes(t)?encodeURIComponent(t):t).join(""),xt='@$&+=:;",',yt=':;",';var Et=(e,t,r)=>{let{sid:o,baseURL:i,followRename:n,projects:a}=E(r??{}),p=new URLSearchParams([["followRename",${n??!0}],...a?.map?.(u=>"projects",u)??[]]);return new Request(${i}api/pages/${e}/${K(t)}?${p},o?{headers:{Cookie:v(o)}}:void 0)},Ye=(e,t,r)=>E(r??{}).fetch(Et(e,t,r));var bt=0,En=Array.isArray;function k(e,t,r,o,i,n){t||(t={});var a,p,u=t;if("ref"in u)for(p in u={},t)p=="ref"?a=tp:up=tp;var c={type:e,props:u,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bt,__i:-1,__u:0,__source:i,__self:n};if(typeof e=="function"&&(a=e.defaultProps))for(p in a)up===void 0&&(up=ap);return g.vnode&&g.vnode(c),c}var On=()=>{let e=document.createElement("div");e.dataset.userscriptName="takker99/scrapbox-history-slider";let t=e.attachShadow({mode:"open"});return document.body.append(e),new Promise(r=>Te(k(vt,{getController:o=>r(o)}),t))},vt=({getController:e})=>{lett,r=M(!0),o=L(()=>r(!1),[]),i=L(()=>r(!0),[]),n=L(()=>r(_=>!_),[]);A(()=>e({open:o,close:i,toggle:n}),e);let a=L(_=>{_.target instanceof HTMLElement&&_.target.id==="background"&&i()},[]),{state:p,result:u}=We(async()=>{if(t||scrapbox.Layout!=="page")return;let_,b=await Promise.all(Ye(scrapbox.Project.name,scrapbox.Page.title||""),ze(scrapbox.Project.name,scrapbox.Page.id));if(!_.ok)throw new Error(Failed to fetch page: ${_.statusText});if(!b.ok)throw new Error(Failed to fetch commits: ${b.statusText});letx,h=await Promise.all(_.json(),b.json()),m=Ve(x.lines,h.commits);return{range:...m.keys().sort((w,I)=>w-I),getSnapshot:w=>m.get(w)?.map?.(I=>I.text)??[]}},{range:[],getSnapshot:()=>[]},1e3,t),c,f=M(0),s,l=M(0);A(()=>{if(p!=="resolved")return;let _=Math.max(0,u.range.length-1);f(_),l(_)},u);let d=L(_=>l(parseInt(_.currentTarget.value)),[]);return k(T,{children:[k("style",{children:'.modal{position:fixed;inset:0;z-index:1050;background-color:#000c;display:flex;flex-direction:column;align-items:center;row-gap:10px;padding:10px}.closed{display:none}.modal>*{color:var(--page-text-color, #4a4a4a);background-color:var(--page-bg, #fefefe);border:2px solid var(--body-bg, #dcdde0);border-radius:4px;padding:5px;width:calc(var(--item-width, 100%) - 10px)}@media (min-width: 768px){.modal{padding:30px}}.controller{display:flex;flex-direction:row-reverse;gap:.2em}input{width:100%}time{white-space:nowrap}.viewer{overflow-y:scroll}pre{width:100%;font-family:var(--history-slider-pre-font, Menlo,Monaco,Consolas,"Courier New",monospace);word-break:break-all;word-wrap:break-word;white-space:pre-wrap}'}),k("div",{id:"background",className:modal${t?" closed":""},onClick:a,children:[k("div",{className:"controller",children:[k("button",{type:"button",className:"close-button",onClick:i,children:"x"}),p==="resolved"&&u.range.length===0&&k("span",{className:"not-found",children:"no history found."}),p!=="rejected"&&u.range.length>0&&k(T,{children:[k("input",{type:"range",max:c,min:"0",step:"1",value:s,title:X(new Date(u.ranges*1e3),"yyyy-MM-dd HH:mm:ss"),onInput:d}),k("time",{dateTime:X(new Date(u.ranges*1e3),"yyyy-MM-dd HH:mm:ss"),children:X(new Date(u.ranges*1e3),"yyyy-MM-dd HH:mm:ss")})]})]}),p!=="rejected"?k("div",{className:"viewer",children:k("pre",{children:u.getSnapshot(u.ranges).join(` )})}):k("div",{className:"error viewer",children:Error: ${JSON.stringify(u)}`})]})]})};export{On as setup};